NodeJS SDK
Usage
NodeJS SDK for Reclaim Protocol
Quickstart
We will be creating two endpoints
- Start Verification
- Process Verification
Import the library
Part 1 : Start Verification Endpoint
Init
- You can get the
RECLAIMPROTOCOL_APP_IDandRECLAIMPROTOCOL_APP_SECRETusing this guide - The
PROVIDER_IDis the proof you want the user to generate. You can see all the available providers here. If you are just testing the flow, you can use the provider idff4d7afe-4b78-4795-9429-d20df2deaad7.
Success Callback
This is the endpoint to which the proofs will be submitted after the verification - this is where you will process the verification. We will define this endpoint in the next section.
Set Context
You can set context to the proof request that helps identify the request when you receive it back in the callback once the proof is generated.
address: this is usually a unique identifier for the user. This could be an email address, a wallet address, or just a session id generated on your system. Set the variable you'd need to identify the user in the callback endpoint, when the proof is sent to your backend.message: this is an open field where you can add any other information that you want passed around from the build request to the callback endpoint. You can stringify jsons here for convenience.
Both context address and context message are tamper resistant. Even if the user tries to edit one byte, the proof verification will fail.
Open verification
Store the Provider Version
- Store
(providerId, providerVersion)corresponding to this user's uuid that you stored inaddress. You will need this providerVersion
More options
Part 2 : Process Verification endpoint
Be sure to expose this endpoint over the public internet. If testing locally, use Ngrok
Verify Proofs
You can get the provider version
- [ Recommended ] Storing the provider version when initiating the verification.
- You can also hardcode the expected provider version by picking the latest version from the developer tool.
Continue Business Logic
context.address&context.message: Same asaddressandmessageset in Set Context. Use this to map user to verification.extractedParameters: JSON object of all the data that has been extracted and verified. You can see the structure of each provider's response in the Provider Explorer.