Claiming and Signing Credential

Step 1: Import Required Modules

Import the necessary modules at the beginning of your script:

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

Step 2: Set Up Credential Payload

Replace the placeholder values with your actual Credential payload:

// this is the payload sent by wallet
const credentialPayload = {
  credentialId: "YOUR_CREDENTIAL_ID",
  did: "USER_DID",
  qrType: QRTypes.TYPE_CREDENTIAL_VC,
  message: "MESSAGE_FROM_WALLET",
  signature: "SIGNATURE_FROM_WALLET",
};

Step 3: Set Up Credential Details

Replace the placeholder values with your actual credential details:

const credentialSubject = {
  // Replace with user's credential subject data for VC (based on credentialId)
};

const type = "YOUR_CREDENTIAL_TYPE"; // ex: KtpCred
const validFrom = "VALID_FROM_DATE"; // Optional
const validUntil = "VALID_UNTIL_DATE"; // Optional

Step 4: Claim and Sign Credential

Claim and sign the credential using the provided payload and details:

Step 5: Return Signed Credential

Return the signed credential:

Final Code

Here's the complete code:

Last updated