yarn add @proofofpassport/sdk
yarn install-sdk
yarn test
To use the ProofOfPassportWeb2Verifier
in Web2 applications, import and initialize it as follows:
import { ProofOfPassportWeb2Verifier } from '@proofofpassport/sdk';
const verifier = new ProofOfPassportWeb2Verifier({
scope: "yourScope",
requirements: [["older_than", "18"], ["nationality", "France"]]
});
Parameter | Optional | Description |
---|---|---|
scope |
No | The scope of your application, is unique for each application. |
attestationId |
Yes | The ID of the attestation, defaults to PASSPORT_ATTESTATION_ID . |
requirements |
Yes | An array of requirements, each an array with an attribute and its expected value. |
rpcUrl |
Yes | The RPC URL to connect to the blockchain, defaults to DEFAULT_RPC_URL . |
Finally, verify the proof:
The function fired from the Proof of Passport app will send a ProofOfPassportWeb2Inputs
object.
const result = await verifier.verify(proofOfPassportWeb2Inputs); // proofOfPassportWeb2Inputs : ProofOfPassportWeb2Inputs
For Web3 applications, use the ProofOfPassportWeb3Verifier
as follows:
import { ProofOfPassportWeb3Verifier } from '@proofofpassport/sdk';
const verifier = new ProofOfPassportWeb3Verifier({
scope: "yourScope",
rpcUrl: "https://custom.rpc.url"
});
Parameter | Optional | Description |
---|---|---|
scope |
No | The scope of the verification. |
attestationId |
Yes | The ID of the attestation, defaults to PASSPORT_ATTESTATION_ID . |
requirements |
Yes | An array of requirements, each an array with an attribute and its expected value. |
rpcUrl |
Yes | The RPC URL to connect to the blockchain, defaults to DEFAULT_RPC_URL . |
const result = await verifier.verify(address, tokenId);
Each verification will returns a ProofOfPassportReport object which contains all the informations about the verification of each requirement.
If a requirement is not satisfied, the corresponding field will be set to true
.
The valid
field will be false
if there is at least one requirement that is not satisfied.
nullifier
and user_identifier
are also accessible as report fields.
const report = await verifier.verify(publicSignals, proof);
const nullifier = report.nullifier;
const userIdentifier = report.user_identifier;