Examples of NuID's zero knowledge authentication and key management facilities in various languages and frameworks. Open an Issue or PR if you'd like to see your favorite tool here.
This repository contains examples of interacting with various NuID libraries, packages, and APIs across various languages, libraries, and frameworks. The examples provided here are meant to suplement the official documentation found at NuID's Developer Portal.
If you want to run some of these examples, you'll generally need the following:
node & npm
(tested on v12.16.3 LTS)make
# Fetch the code
$ git clone https://github.com/NuID/examples.git
$ cd examples
# All servers will need an API Key to talk to the API
$ export NUID_API_KEY="<your api key>"
# the start target will fetch all necessary dependencies
# use client=js-react and server=js-node defaults
$ make start
# optionally set the client or server examples to use
# see below for supported clients and servers
$ make start server=go
As we add new examples for other languages you'll be able to change
server=<folder>
or client=<folder>
to whichever example you wish to run.
client=<lang>
js-react
(default) - make start
or make start client=js-react
js-react-native
- make start client=js-react-native
server=<lang>
js-node
(default) - make start
or make start server=js-node
clojure-ring
- make start server=clojure-ring
go
- make start server=go
ruby-rails
- make start server=ruby-rails
Lots of the code in each example has been commented, but more documentation can be found on the portal. We're constantly updating the docs with guides, videos, and language reference.
Get in touch with any questions or feedback at [email protected]. We'd love to hear from you.
js-react
+ js-node
exampleProvided here is an example of a Node.js+React application that initially uses password hashing for authentication. Over the course of four tagged commits we'll show how to convert from password hashing to using NuID for credential management, all without changing your login+registration UX.
Note: This repo's directory structure has changed since the tagged commits
linked below, just be aware you'll only see a client
and server
directory
instead of js-react
and js-node
respectively (along with any other language
examples that will be added later). Checking out the main
branch at any time
will get you back to the most recent examples available.
@nuid/zk
npm package to both client and server applications.nuid
field to user table./register
with the email and a verified credential./challenge
to get a challenge for the authenticating user from NuID./challenge
for the user with the given email./login
with the email, challenge JWT, and proof./login
verifies the challenge JWT and proof with NuID.