A simple package designed to streamline the development of a zero-knowledge authentication system with Zupass tickets.
The repository includes the zuauth package along with a documented example demonstrating how to create an authentication system using NextJS and IronSession. Use the demo and refer to the tutorial section below to understand how to integrate zuauth into your app. |
---|
Install the zuauth
package with npm:
npm i zuauth
or yarn:
yarn add zuauth
[!NOTE]
The example in the repository usesiron-session
to manage sessions, but you are of course free to integrate your preferred solution.
First, you need to create the server-side logic to generate a session nonce and perform the authentication. The example in this repository includes four functions: login, logout, nonce, and user. Remember to add all necessary checks in your login function, particularly ensuring that the ticket has been issued by Zupass and that it is among the supported tickets.
Next, you can proceed with the client side.
- Create a page for the Zupass popup:
- Create another page and define the default set of ticket fields to reveal.
- Check if the user is logged-in.
- Create a function to login, which generates a nonce and user's PCD:
- Check when the PCD is generated and returned by the Zupass popup to call the login API:
[!IMPORTANT]
When the user interacts with the Zupass popup, the output, which is the generated PCD, is not returned by any function but can be found in thepcd
state variable within theuseZuAuth
hook. It's important to check if the value is defined.
- Create a function to allow users to log out:
- Create your UI: