You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Install the zuauth package with npm:
npm i zuauth
or yarn:
yarn add zuauth
📜 Tutorial
Note
The example in the repository uses iron-session to manage sessions, but you are of course free to integrate your preferred solution.
Server
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.
// When the popup is closed and the user successfully
// generates the PCD, they can login.
useEffect(()=>{
;(asyncfunction(){
if(pcd){
const{ data }=awaitaxios.post("/api/login",{ pcd })
setUser(data.user)
}
})()
},[pcd])
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 the pcd state variable within the useZuAuth hook. It's important to check if the value is defined.