Generating QR Code for Claiming JWS Credential

Step 1: Import Required Modules

Import the necessary modules at the beginning of your script:

import { Credential, DIDAccount, QRGenerator } from "@didpass/issuer-sdk";
import { QRTypes } from "@didpass/issuer-sdk/lib/types/QRTypes";

Step 2: Set Up Details

Replace the placeholder values with your actual details:

const privateKey = "YOUR_PRIVATE_KEY";

const callbackUrl = "YOUR_CALLBACK_URL";
const did = "USER_WALLET_DID";
const sessionId = "YOUR_SESSION_ID";

const credentialId = "YOUR_CREDENTIAL_ID";
const description = "YOUR_CREDENTIAL_DESCRIPTION";
const qrType = QRTypes.TYPE_CREDENTIAL_JWT;
const preview = {
  nik: "YOUR_CREDENTIAL_NIK_PREVIEW",
  name: "YOUR_CREDENTIAL_NAME_PREVIEW",
};

const credentials = [
  {
    id: credentialId,
    description: description,
    preview: preview, // optional
  },
];

Step 3: Generate QR Code

Generate the QR code for credential:

Step 4: Return QR Code

Return the generated QR code:

Final Code

Here's the complete code:

Last updated