{"id":18450198,"url":"https://github.com/nuid/examples","last_synced_at":"2025-10-30T04:13:17.130Z","repository":{"id":38852451,"uuid":"263207459","full_name":"NuID/examples","owner":"NuID","description":"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.","archived":false,"fork":false,"pushed_at":"2023-01-19T20:54:51.000Z","size":1954,"stargazers_count":43,"open_issues_count":39,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-23T04:11:16.722Z","etag":null,"topics":["authentication","demo","developer-portal","javascript","key-management","login-registration-ux","nodejs","nuid","nuid-portal","proof","ruby","ruby-on-rails","zero-knowledge"],"latest_commit_sha":null,"homepage":"https://nuid.io","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NuID.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-12T02:05:00.000Z","updated_at":"2024-10-25T03:09:32.000Z","dependencies_parsed_at":"2023-01-28T23:15:45.516Z","dependency_job_id":null,"html_url":"https://github.com/NuID/examples","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NuID%2Fexamples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NuID%2Fexamples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NuID%2Fexamples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NuID%2Fexamples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NuID","download_url":"https://codeload.github.com/NuID/examples/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247760845,"owners_count":20991531,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authentication","demo","developer-portal","javascript","key-management","login-registration-ux","nodejs","nuid","nuid-portal","proof","ruby","ruby-on-rails","zero-knowledge"],"created_at":"2024-11-06T07:23:57.306Z","updated_at":"2025-10-30T04:13:12.095Z","avatar_url":"https://github.com/NuID.png","language":"JavaScript","readme":"\u003cp align=\"right\"\u003e\u003ca href=\"https://nuid.io\"\u003e\u003cimg src=\"https://nuid.io/svg/logo.svg\" width=\"20%\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n# NuID :: Examples\n\nThis repository contains examples of interacting with various NuID\nlibraries, packages, and APIs across various languages, libraries, and\nframeworks. The examples provided here are meant to suplement the official\ndocumentation found at NuID's [Developer Portal](https://portal.nuid.io).\n\n## Prerequisites\n\nIf you want to run some of these examples, you'll generally need the following:\n\n* [`node \u0026 npm`](https://nodejs.org/) (tested on v12.16.3 LTS)\n* An API Key (freely available at the [portal](https://portal.nuid.io))\n* [`make`](https://www.gnu.org/software/make/)\n\n## Usage\n\n```bash\n# Fetch the code\n$ git clone https://github.com/NuID/examples.git\n$ cd examples\n\n# All servers will need an API Key to talk to the API\n$ export NUID_API_KEY=\"\u003cyour api key\u003e\"\n\n# the start target will fetch all necessary dependencies\n# use client=js-react and server=js-node defaults\n$ make start\n\n# optionally set the client or server examples to use\n# see below for supported clients and servers\n$ make start server=go\n```\n\nAs we add new examples for other languages you'll be able to change\n`server=\u003cfolder\u003e` or `client=\u003cfolder\u003e` to whichever example you wish to run.\n\n### Supported examples\n\n#### `client=\u003clang\u003e`\n\n+ `js-react` (default) - `make start` or `make start client=js-react`\n+ `js-react-native` - `make start client=js-react-native`\n\n#### `server=\u003clang\u003e`\n\n+ `js-node` (default) - `make start` or `make start server=js-node`\n+ `clojure-ring` - `make start server=clojure-ring`\n+ `go` - `make start server=go`\n+ `ruby-rails` - `make start server=ruby-rails`\n\n## Documentation\n\nLots of the code in each example has been commented, but more documentation can\nbe found on the [portal](https://portal.nuid.io/docs). We're constantly updating\nthe docs with guides, videos, and language reference.\n\n## Contact\n\n[Get in touch](https://portal.nuid.io/support) with any questions or feedback at\n[support@nuid.io](support@nuid.io). We'd love to hear from you.\n\n---\n\n# `js-react` + `js-node` example\n\nProvided here is an example of a Node.js+React application that initially uses\npassword hashing for authentication. Over the course of four tagged commits\nwe'll show how to convert from password hashing to using NuID for credential\nmanagement, all without changing your login+registration UX.\n\nNote: This repo's directory structure has changed since the tagged commits\nlinked below, just be aware you'll only see a `client` and `server` directory\ninstead of `js-react` and `js-node` respectively (along with any other language\nexamples that will be added later). Checking out the `main` branch at any time\nwill get you back to the most recent examples available.\n\n## Overview of NuID\n\n- Trustless authentication using Zero-Knowledge proofs.\n- Slots seamlessly into existing password-based flows.\n- Eliminates password breach risks. Passwords don't leave your client devices\n  and aren't stored on your server.\n- NuID Auth API provides ZK credential creation and retrieval.\n\n## Demo: Initial app uses hashed password authentication\n\n- Two core flows in authentication: registration and login.\n- Email+Password used for registering and authenticating users.\n- Email is the unique key for the user account.\n- Password is always sent to backend, hashed, and stored.\n- [Browse Code](https://github.com/NuID/node-example/tree/v1)\n\n## Demo: Integrate with NuID Auth API\n\n- Add `@nuid/zk` npm package to both client and server applications.\n- Get an API Key from the [NuID Developer Portal](https://portal.nuid.io).\n- Add API Key and URL to server process environment.\n- Create API Post and Get functions to talk to NuID Auth API.\n- [Browse Code](https://github.com/NuID/node-example/tree/v2-nuid-config)\n- [See Diff](https://github.com/NuID/node-example/compare/v1...v2-nuid-config)\n\n## Demo: Convert registration to use NuID\n\n- Add `nuid` field to user table.\n- Client creates a verified credential with the password during registration.\n- Client submits to `/register` with the email and a verified credential.\n- The password is not sent to the server.\n- Server receives verified credential and registers for a new NuID.\n- Server stores the NuID along with the other user parameters.\n- [Browse Code](https://github.com/NuID/node-example/tree/v3-register-with-credential)\n- [See Diff](https://github.com/NuID/node-example/compare/v2-nuid-config...v3-register-with-credential)\n\n## Demo: Convert login to use NuID\n\n- Add server endpoint `/challenge` to get a challenge for the authenticating user from NuID.\n- Client login process asks for a `/challenge` for the user with the given email.\n- Challenge JWT claims are decoded client-side and used to generate a ZK Proof with the password.\n- Client login submits to `/login` with the email, challenge JWT, and proof.\n- The password is not sent to the server.\n- Server `/login` verifies the challenge JWT and proof with NuID.\n- User is now authenticated.\n- [Browse Code](https://github.com/NuID/node-example/tree/v4-login-with-nuid)\n- [See Diff](https://github.com/NuID/node-example/compare/v3-register-with-credential...v4-login-with-nuid)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnuid%2Fexamples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnuid%2Fexamples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnuid%2Fexamples/lists"}