IO Wallet SDK
    Preparing search index...

    Function createCredentialResponse

    • Creates a credential response according to the configured Italian Wallet specification version.

      Supports both immediate and deferred issuance flows, with optional JWE encryption of the generated response payload.

      Version Differences:

      • v1.0 deferred flow uses lead_time
      • v1.3 deferred flow uses interval
      • immediate flow has the same shape in both versions (credentials, optional notification_id)

      Parameters

      Returns Promise<
          CreateCredentialResponseResultWithFlow<
              { credentials: { credential: string }[]; notification_id?: string },
          >,
      >

      An object containing:

      • credentialResponse: plain version-specific credential response JSON
      • credentialResponseJwt: encrypted JWE string when encryption is requested

      When the generated response does not satisfy the version schema.

      When encryption is requested but callbacks.encryptJwe is not provided.

      For unexpected errors during response creation.

      v1.0 - Immediate flow without encryption
      const config = new IoWalletSdkConfig({ itWalletSpecsVersion: ItWalletSpecsVersion.V1_0 });
      const result = await createCredentialResponse({
      config,
      flow: {
      credentials: [{ credential: "eyJ..." }],
      notificationId: "notif-123",
      },
      });
      // result.credentialResponse = { credentials: [{ credential: "eyJ..." }], notification_id: "notif-123" }
      // result.credentialResponseJwt = undefined
      v1.3 - Immediate flow with encryption
      const config = new IoWalletSdkConfig({ itWalletSpecsVersion: ItWalletSpecsVersion.V1_3 });
      const result = await createCredentialResponse({
      callbacks: { encryptJwe: myEncryptJweCallback },
      config,
      credentialResponseEncryption: {
      alg: "ECDH-ES",
      enc: "A256GCM",
      jwk: issuerEncryptionPublicJwk,
      },
      flow: {
      credentials: [{ credential: "eyJ..." }],
      },
      });
      // result.credentialResponse contains plain JSON
      // result.credentialResponseJwt contains encrypted JWE
      v1.0 - Deferred flow without encryption
      const config = new IoWalletSdkConfig({ itWalletSpecsVersion: ItWalletSpecsVersion.V1_0 });
      const result = await createCredentialResponse({
      config,
      flow: {
      leadTime: 300,
      transactionId: "tx-v1-0",
      },
      });
      // result.credentialResponse = { lead_time: 300, transaction_id: "tx-v1-0" }
      v1.3 - Deferred flow with encryption
      const config = new IoWalletSdkConfig({ itWalletSpecsVersion: ItWalletSpecsVersion.V1_3 });
      const result = await createCredentialResponse({
      callbacks: { encryptJwe: myEncryptJweCallback },
      config,
      credentialResponseEncryption: {
      alg: "ECDH-ES",
      enc: "A256GCM",
      jwk: issuerEncryptionPublicJwk,
      },
      flow: {
      interval: 60,
      transactionId: "tx-v1-3",
      },
      });
      // result.credentialResponse = { interval: 60, transaction_id: "tx-v1-3" }
      // result.credentialResponseJwt contains encrypted JWE
    • Creates a credential response according to the configured Italian Wallet specification version.

      Supports both immediate and deferred issuance flows, with optional JWE encryption of the generated response payload.

      Version Differences:

      • v1.0 deferred flow uses lead_time
      • v1.3 deferred flow uses interval
      • immediate flow has the same shape in both versions (credentials, optional notification_id)

      Parameters

      Returns Promise<
          CreateCredentialResponseResultWithFlow<
              { lead_time: number; transaction_id: string },
          >,
      >

      An object containing:

      • credentialResponse: plain version-specific credential response JSON
      • credentialResponseJwt: encrypted JWE string when encryption is requested

      When the generated response does not satisfy the version schema.

      When encryption is requested but callbacks.encryptJwe is not provided.

      For unexpected errors during response creation.

      v1.0 - Immediate flow without encryption
      const config = new IoWalletSdkConfig({ itWalletSpecsVersion: ItWalletSpecsVersion.V1_0 });
      const result = await createCredentialResponse({
      config,
      flow: {
      credentials: [{ credential: "eyJ..." }],
      notificationId: "notif-123",
      },
      });
      // result.credentialResponse = { credentials: [{ credential: "eyJ..." }], notification_id: "notif-123" }
      // result.credentialResponseJwt = undefined
      v1.3 - Immediate flow with encryption
      const config = new IoWalletSdkConfig({ itWalletSpecsVersion: ItWalletSpecsVersion.V1_3 });
      const result = await createCredentialResponse({
      callbacks: { encryptJwe: myEncryptJweCallback },
      config,
      credentialResponseEncryption: {
      alg: "ECDH-ES",
      enc: "A256GCM",
      jwk: issuerEncryptionPublicJwk,
      },
      flow: {
      credentials: [{ credential: "eyJ..." }],
      },
      });
      // result.credentialResponse contains plain JSON
      // result.credentialResponseJwt contains encrypted JWE
      v1.0 - Deferred flow without encryption
      const config = new IoWalletSdkConfig({ itWalletSpecsVersion: ItWalletSpecsVersion.V1_0 });
      const result = await createCredentialResponse({
      config,
      flow: {
      leadTime: 300,
      transactionId: "tx-v1-0",
      },
      });
      // result.credentialResponse = { lead_time: 300, transaction_id: "tx-v1-0" }
      v1.3 - Deferred flow with encryption
      const config = new IoWalletSdkConfig({ itWalletSpecsVersion: ItWalletSpecsVersion.V1_3 });
      const result = await createCredentialResponse({
      callbacks: { encryptJwe: myEncryptJweCallback },
      config,
      credentialResponseEncryption: {
      alg: "ECDH-ES",
      enc: "A256GCM",
      jwk: issuerEncryptionPublicJwk,
      },
      flow: {
      interval: 60,
      transactionId: "tx-v1-3",
      },
      });
      // result.credentialResponse = { interval: 60, transaction_id: "tx-v1-3" }
      // result.credentialResponseJwt contains encrypted JWE
    • Creates a credential response according to the configured Italian Wallet specification version.

      Supports both immediate and deferred issuance flows, with optional JWE encryption of the generated response payload.

      Version Differences:

      • v1.0 deferred flow uses lead_time
      • v1.3 deferred flow uses interval
      • immediate flow has the same shape in both versions (credentials, optional notification_id)

      Parameters

      Returns Promise<
          CreateCredentialResponseResultWithFlow<
              { interval: number; transaction_id: string },
          >,
      >

      An object containing:

      • credentialResponse: plain version-specific credential response JSON
      • credentialResponseJwt: encrypted JWE string when encryption is requested

      When the generated response does not satisfy the version schema.

      When encryption is requested but callbacks.encryptJwe is not provided.

      For unexpected errors during response creation.

      v1.0 - Immediate flow without encryption
      const config = new IoWalletSdkConfig({ itWalletSpecsVersion: ItWalletSpecsVersion.V1_0 });
      const result = await createCredentialResponse({
      config,
      flow: {
      credentials: [{ credential: "eyJ..." }],
      notificationId: "notif-123",
      },
      });
      // result.credentialResponse = { credentials: [{ credential: "eyJ..." }], notification_id: "notif-123" }
      // result.credentialResponseJwt = undefined
      v1.3 - Immediate flow with encryption
      const config = new IoWalletSdkConfig({ itWalletSpecsVersion: ItWalletSpecsVersion.V1_3 });
      const result = await createCredentialResponse({
      callbacks: { encryptJwe: myEncryptJweCallback },
      config,
      credentialResponseEncryption: {
      alg: "ECDH-ES",
      enc: "A256GCM",
      jwk: issuerEncryptionPublicJwk,
      },
      flow: {
      credentials: [{ credential: "eyJ..." }],
      },
      });
      // result.credentialResponse contains plain JSON
      // result.credentialResponseJwt contains encrypted JWE
      v1.0 - Deferred flow without encryption
      const config = new IoWalletSdkConfig({ itWalletSpecsVersion: ItWalletSpecsVersion.V1_0 });
      const result = await createCredentialResponse({
      config,
      flow: {
      leadTime: 300,
      transactionId: "tx-v1-0",
      },
      });
      // result.credentialResponse = { lead_time: 300, transaction_id: "tx-v1-0" }
      v1.3 - Deferred flow with encryption
      const config = new IoWalletSdkConfig({ itWalletSpecsVersion: ItWalletSpecsVersion.V1_3 });
      const result = await createCredentialResponse({
      callbacks: { encryptJwe: myEncryptJweCallback },
      config,
      credentialResponseEncryption: {
      alg: "ECDH-ES",
      enc: "A256GCM",
      jwk: issuerEncryptionPublicJwk,
      },
      flow: {
      interval: 60,
      transactionId: "tx-v1-3",
      },
      });
      // result.credentialResponse = { interval: 60, transaction_id: "tx-v1-3" }
      // result.credentialResponseJwt contains encrypted JWE
    • Creates a credential response according to the configured Italian Wallet specification version.

      Supports both immediate and deferred issuance flows, with optional JWE encryption of the generated response payload.

      Version Differences:

      • v1.0 deferred flow uses lead_time
      • v1.3 deferred flow uses interval
      • immediate flow has the same shape in both versions (credentials, optional notification_id)

      Parameters

      Returns Promise<CreateCredentialResponseResult>

      An object containing:

      • credentialResponse: plain version-specific credential response JSON
      • credentialResponseJwt: encrypted JWE string when encryption is requested

      When the generated response does not satisfy the version schema.

      When encryption is requested but callbacks.encryptJwe is not provided.

      For unexpected errors during response creation.

      v1.0 - Immediate flow without encryption
      const config = new IoWalletSdkConfig({ itWalletSpecsVersion: ItWalletSpecsVersion.V1_0 });
      const result = await createCredentialResponse({
      config,
      flow: {
      credentials: [{ credential: "eyJ..." }],
      notificationId: "notif-123",
      },
      });
      // result.credentialResponse = { credentials: [{ credential: "eyJ..." }], notification_id: "notif-123" }
      // result.credentialResponseJwt = undefined
      v1.3 - Immediate flow with encryption
      const config = new IoWalletSdkConfig({ itWalletSpecsVersion: ItWalletSpecsVersion.V1_3 });
      const result = await createCredentialResponse({
      callbacks: { encryptJwe: myEncryptJweCallback },
      config,
      credentialResponseEncryption: {
      alg: "ECDH-ES",
      enc: "A256GCM",
      jwk: issuerEncryptionPublicJwk,
      },
      flow: {
      credentials: [{ credential: "eyJ..." }],
      },
      });
      // result.credentialResponse contains plain JSON
      // result.credentialResponseJwt contains encrypted JWE
      v1.0 - Deferred flow without encryption
      const config = new IoWalletSdkConfig({ itWalletSpecsVersion: ItWalletSpecsVersion.V1_0 });
      const result = await createCredentialResponse({
      config,
      flow: {
      leadTime: 300,
      transactionId: "tx-v1-0",
      },
      });
      // result.credentialResponse = { lead_time: 300, transaction_id: "tx-v1-0" }
      v1.3 - Deferred flow with encryption
      const config = new IoWalletSdkConfig({ itWalletSpecsVersion: ItWalletSpecsVersion.V1_3 });
      const result = await createCredentialResponse({
      callbacks: { encryptJwe: myEncryptJweCallback },
      config,
      credentialResponseEncryption: {
      alg: "ECDH-ES",
      enc: "A256GCM",
      jwk: issuerEncryptionPublicJwk,
      },
      flow: {
      interval: 60,
      transactionId: "tx-v1-3",
      },
      });
      // result.credentialResponse = { interval: 60, transaction_id: "tx-v1-3" }
      // result.credentialResponseJwt contains encrypted JWE