didPass
didPass Developer's Guide
didPass Developer's Guide
  • getting started
    • 👋Welcome to didPass
    • 📘Introduction
    • 🔺Triangle of Trust
    • ⚡Quickstart
      • Issuer - Typescript/Node.js
      • Verifier - Typescript/Node.js
      • Installing The SDK
  • Issuer
    • 📋Requirements
    • 🔧Installation
    • 💻Sample Code
      • Connecting Wallet with Issuer
        • Request Connect QR Code
        • Authenticate with Signature
      • Download Verifiable Credential
        • Generating QR Code for Claiming VC
        • Claiming and Signing Credential
      • Download Jws Credential
        • Generating QR Code for Claiming JWS Credential
        • Claiming JWS Credential
    • API References
  • Verifier
    • 📃Requirements
    • 🛠️Installation
    • 👨‍💻Sample Code
      • Prerequisite
      • Generating QR Code for DVR
      • Generating Signed DVR Token
      • Verifying Siwe
      • Verifying Proof
    • API References
  • Wallet
    • ✅Requirements
    • 📥Installation
    • 🖥️Sample Code
    • API References
  • References
    • didPass User's Guide
    • zkPass User's Guide
    • zkPass Developer's Guide
Powered by GitBook
On this page
  • Step 1: Import Addition Required Modules
  • Step 2: Initialize DataVerificationRequest Instance
  • Step 3: Set Up Details
  • Step 4: Generate Signed DVR
  • Step 5: Return Signed DVR Token
  • Final Code
  1. Verifier
  2. Sample Code

Generating Signed DVR Token

PreviousGenerating QR Code for DVRNextVerifying Siwe

Last updated 1 year ago

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;
}
👨‍💻
This flow diagram illustrates the process of Generating Signed DVR Token