Generating Signed DVR Token

Step 1: Import Addition Required Modules
Import the addition necessary modules at the beginning of your Code:
import type { DataVerificationRequest } from "@didpass/verifier-sdk";
Step 2: Initialize DataVerificationRequest Instance
Initialize the DataVerificationRequest instance to be signed:
const user_data_verifying_key = {
KeysetEndpoint: {
jku: "YOUR_ISSUER_JWK_SET_URL",
kid: "YOUR_ISSUER_KID",
},
};
const dvr = new DataVerificationRequest(
dvrTitle, //YOUR_DVR_TITLE
dvrId, //YOUR_DVR_ID
query_engine_ver, //YOUR_QUERY_ENGINE_VERSION, you get this from zkpass-client
query_method_ver, //YOUR_QUERY_METHOD_VERSION, you get this from zkpass-client
query, //YOUR_FULL_QUERY
user_data_url, //YOUR_USER_DATA_URL
user_data_verifying_key
);
Step 3: Set Up Details
Replace the placeholder values with your actual details:
const dvrDto = {
keyInPem: "YOUR_VERIFIER_PRIVATE_KEY",
dvr, //Initialized in Step 2
verifyingKeyJKWS: {
jku: "YOUR_VERIFIER_JWK_SET_URL",
kid: "YOUR_VERIFIER_KID",
},
};
const siweDto = {
siweMessage: "YOUR_SIWE_MESSAGE",
siweSignature: "YOUR_SIWE_SIGNATURE"
}
Step 4: Generate Signed DVR
Generate the signed DVR token:
const signedDVRToken = await verifier.signDvrToken(
dvrDto,
siweDto
);
Step 5: Return Signed DVR Token
Return the generated signed DVR Token:
return signedDVRToken;
Final Code
Here's the complete code:
import type { Verifier, DataVerificationRequest } from "@didpass/verifier-sdk";
async function generateSignedDvrToken() {
const verifier = new Verifier();
const user_data_verifying_key = {
KeysetEndpoint: {
jku: "YOUR_ISSUER_JWK_SET_URL",
kid: "YOUR_ISSUER_KID",
},
};
const dvr = new DataVerificationRequest(
dvrTitle, //YOUR_DVR_TITLE
dvrId, //YOUR_DVR_ID
query_engine_ver, //YOUR_QUERY_ENGINE_VERSION, you get this from zkpass-client
query_method_ver, //YOUR_QUERY_METHOD_VERSION, you get this from zkpass-client
query, //YOUR_FULL_QUERY
user_data_url, //YOUR_USER_DATA_URL
user_data_verifying_key
);
const dvrDto = {
keyInPem: "YOUR_VERIFIER_PRIVATE_KEY",
dvr, //Initialized in Step 2
verifyingKeyJKWS: {
jku: "YOUR_VERIFIER_JWK_SET_URL",
kid: "YOUR_VERIFIER_KID",
},
};
const siweDto = {
siweMessage: "YOUR_SIWE_MESSAGE",
siweSignature: "YOUR_SIWE_SIGNATURE",
};
const signedDVRToken = await verifier.signDvrToken(dvrDto, siweDto);
return signedDVRToken;
}
Last updated