@openeudi/openid4vp 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -287,8 +287,23 @@ interface ParseOptions {
287
287
  nonce: string;
288
288
  /** Expected audience for key binding JWT verification. Optional. */
289
289
  audience?: string;
290
+ /**
291
+ * Force holder-binding verification even when the issuer JWT carries no
292
+ * `cnf` claim. When the credential IS holder-bound (`cnf` present), a
293
+ * KB-JWT is ALWAYS required regardless of this flag — this flag only
294
+ * extends the requirement to credentials that lack `cnf`. Default: false.
295
+ */
296
+ requireKeyBinding?: boolean;
290
297
  /** Allowed JWT signature algorithms. Defaults to ['ES256', 'ES384', 'ES512']. */
291
298
  allowedAlgorithms?: string[];
299
+ /**
300
+ * CBOR bytes of the ISO 18013-5 `SessionTranscript` data item for the current
301
+ * OpenID4VP exchange. REQUIRED to verify mDOC device authentication — the
302
+ * mDOC parser fails closed without it, since device proof-of-possession and
303
+ * replay/nonce binding cannot otherwise be checked. Construct it from the
304
+ * OpenID4VP handover (client_id, response_uri, nonce, mdoc-generated-nonce).
305
+ */
306
+ mdocSessionTranscript?: Uint8Array;
292
307
  /**
293
308
  * Explicit opt-in to skip the trust check. When omitted or `false`,
294
309
  * either `trustedCertificates` must be non-empty OR `trustStore` must be
@@ -359,6 +374,42 @@ interface EncryptedResponse {
359
374
  }
360
375
  type VerifyAuthorizationResponseOptions = VerifyOptions & {
361
376
  decryptionKey?: CryptoKey;
377
+ /**
378
+ * The OpenID4VP verifier's `client_id`, as sent in the authorization request.
379
+ * Combined with {@link responseUri}, {@link ParseOptions.nonce} and the
380
+ * `mdoc-generated-nonce` (carried in the JWE `apu` header, ISO 18013-7 Annex B),
381
+ * it lets the encrypted-response path auto-build the mDOC SessionTranscript the
382
+ * mDOC parser requires — so callers need not construct the CBOR by hand. Ignored
383
+ * when the caller supplies {@link ParseOptions.mdocSessionTranscript} explicitly.
384
+ */
385
+ clientId?: string;
386
+ /**
387
+ * The OpenID4VP verifier's `response_uri`, as sent in the authorization request.
388
+ * See {@link clientId} — used to auto-build the mDOC SessionTranscript.
389
+ */
390
+ responseUri?: string;
391
+ /**
392
+ * Which mDOC SessionTranscript layout to auto-build when {@link clientId},
393
+ * {@link responseUri} and {@link ParseOptions.nonce} are present and the
394
+ * caller has not supplied {@link ParseOptions.mdocSessionTranscript}:
395
+ *
396
+ * - `'iso-18013-7'` (default): the ISO 18013-7 Annex B `OID4VPHandover`,
397
+ * derived from the `mdoc-generated-nonce` carried in the JWE `apu` header.
398
+ * This is the id2/id3-era layout and is kept as the default for
399
+ * backwards compatibility.
400
+ * - `'openid4vp-1.0'`: the OpenID4VP 1.0 (Final) `OpenID4VPHandover`
401
+ * (§B.2.6), derived from {@link verifierEncryptionJwk}'s RFC 7638
402
+ * thumbprint instead of an `apu` nonce.
403
+ */
404
+ sessionTranscriptProfile?: 'iso-18013-7' | 'openid4vp-1.0';
405
+ /**
406
+ * The verifier's response-encryption public JWK. Required when
407
+ * {@link sessionTranscriptProfile} is `'openid4vp-1.0'` and the response is
408
+ * encrypted — its RFC 7638 SHA-256 thumbprint is embedded in the
409
+ * OpenID4VPHandover SessionTranscript. Ignored for the `'iso-18013-7'`
410
+ * profile (which uses the JWE `apu` header instead).
411
+ */
412
+ verifierEncryptionJwk?: JsonWebKey;
362
413
  };
363
414
 
364
415
  /**
@@ -402,6 +453,55 @@ declare function verifyAuthorizationResponse(envelope: AuthorizationResponse | E
402
453
  */
403
454
  declare function decryptAuthorizationResponse(jwe: string, privateKey: CryptoKey): Promise<AuthorizationResponse>;
404
455
 
456
+ /**
457
+ * Build the ISO 18013-7 Annex B `OID4VPHandover` SessionTranscript:
458
+ *
459
+ * SessionTranscript = [ null, null, OID4VPHandover ]
460
+ * OID4VPHandover = [ clientIdHash, responseUriHash, nonce ]
461
+ * clientIdHash = SHA-256(cbor([clientId, mdocGeneratedNonce]))
462
+ * responseUriHash = SHA-256(cbor([responseUri, mdocGeneratedNonce]))
463
+ *
464
+ * Used to bind an mdoc DeviceAuthentication to the OpenID4VP authorization
465
+ * request/response exchange it was presented in.
466
+ */
467
+ declare function buildOid4vpSessionTranscript(params: {
468
+ clientId: string;
469
+ responseUri: string;
470
+ nonce: string;
471
+ mdocGeneratedNonce: string;
472
+ }): Promise<Uint8Array>;
473
+ /**
474
+ * Build the OpenID for Verifiable Presentations 1.0 (Final) `OpenID4VPHandover`
475
+ * SessionTranscript (OID4VP 1.0 §B.2.6, `response_uri` flavour):
476
+ *
477
+ * SessionTranscript = [ null, null, OpenID4VPHandover ]
478
+ * OpenID4VPHandover = [ "OpenID4VPHandover", SHA-256(cbor(OpenID4VPHandoverInfo)) ]
479
+ * OpenID4VPHandoverInfo = [ clientId, nonce, jwkThumbprint | null, responseUri ]
480
+ *
481
+ * `jwkThumbprint` is the RFC 7638 SHA-256 thumbprint of the verifier's response
482
+ * ENCRYPTION public JWK as RAW 32 bytes, or CBOR `null` for an unencrypted
483
+ * response. `clientId` is passed verbatim and is expected to already carry its
484
+ * client-id-prefix (e.g. `x509_san_dns:v.example`) — the suite hashes the same
485
+ * `client_id` string it received in the request.
486
+ *
487
+ * This is a DIFFERENT structure from the ISO 18013-7 Annex B `OID4VPHandover`
488
+ * built by `buildOid4vpSessionTranscript` above (which uses an mdoc-generated
489
+ * nonce and separate client_id/response_uri hashes). 1.0-Final wallets tested
490
+ * by the OIDF `oid4vp-1final-verifier-*` modules require THIS layout.
491
+ *
492
+ * Layout confirmed against OID4VP 1.0 Final §B.2.6 and the suite class
493
+ * net.openid.conformance.condition.client.AbstractCreateVP1FinalIsoMdocRedirectSessionTranscript
494
+ * at tag release-v5.1.42: element order [clientId, nonce, thumb|null, responseUri];
495
+ * thumbprint embedded as raw bytes; outer hash is SHA-256 over the CBOR of the
496
+ * 4-element info array.
497
+ */
498
+ declare function buildOpenID4VPHandoverSessionTranscript(params: {
499
+ clientId: string;
500
+ nonce: string;
501
+ responseUri: string;
502
+ verifierEncryptionJwk?: JsonWebKey;
503
+ }): Promise<Uint8Array>;
504
+
405
505
  /**
406
506
  * SD-JWT VC credential parser.
407
507
  *
@@ -578,4 +678,4 @@ declare class LotlTrustStore implements TrustStore {
578
678
 
579
679
  declare const VERSION = "0.8.0";
580
680
 
581
- export { type AuthorizationRequest, type AuthorizationRequestInput, type AuthorizationResponse, type Cache, CertificateChainError, type ChainErrorReason, CompositeTrustStore, type CredentialClaims, type CredentialFormat, DecryptionFailedError, type EncryptedResponse, ExpiredCredentialError, type Fetcher, HAIP_DOCTYPE_NAMESPACES, type HaipQueryInput, type HaipValidationCode, HaipValidationError, type ICredentialParser, InMemoryCache, InvalidSignatureError, type IssuerInfo, type LotlAnchorMetadata, LotlFetchError, LotlSignatureError, LotlTrustStore, type LotlTrustStoreOptions, MalformedCredentialError, MdocParser, MissingDecryptionKeyError, MultipleCredentialsNotSupportedError, NonceValidationError, OpenID4VPError, type ParseOptions, type PresentationResult, RevocationCheckFailedError, RevokedCertificateError, SdJwtParser, type SignedAuthorizationRequest, type SignedAuthorizationRequestInput, SignedRequestBuildError, type SignedRequestBuildErrorCode, StaticTrustStore, type TrustAnchor, TrustAnchorNotFoundError, type TrustStore, type TrustStoreHint, type TrustStoreInput, UnsupportedFormatError, UnsupportedJweError, VERSION, type VerifyAuthorizationResponseOptions, type VerifyOptions, type VerifyResult, buildHaipQuery, createAuthorizationRequest, createSignedAuthorizationRequest, decryptAuthorizationResponse, isHaipQuery, parsePresentation, validateHaipQuery, verifyAuthorizationResponse, verifyPresentation };
681
+ export { type AuthorizationRequest, type AuthorizationRequestInput, type AuthorizationResponse, type Cache, CertificateChainError, type ChainErrorReason, CompositeTrustStore, type CredentialClaims, type CredentialFormat, DecryptionFailedError, type EncryptedResponse, ExpiredCredentialError, type Fetcher, HAIP_DOCTYPE_NAMESPACES, type HaipQueryInput, type HaipValidationCode, HaipValidationError, type ICredentialParser, InMemoryCache, InvalidSignatureError, type IssuerInfo, type LotlAnchorMetadata, LotlFetchError, LotlSignatureError, LotlTrustStore, type LotlTrustStoreOptions, MalformedCredentialError, MdocParser, MissingDecryptionKeyError, MultipleCredentialsNotSupportedError, NonceValidationError, OpenID4VPError, type ParseOptions, type PresentationResult, RevocationCheckFailedError, RevokedCertificateError, SdJwtParser, type SignedAuthorizationRequest, type SignedAuthorizationRequestInput, SignedRequestBuildError, type SignedRequestBuildErrorCode, StaticTrustStore, type TrustAnchor, TrustAnchorNotFoundError, type TrustStore, type TrustStoreHint, type TrustStoreInput, UnsupportedFormatError, UnsupportedJweError, VERSION, type VerifyAuthorizationResponseOptions, type VerifyOptions, type VerifyResult, buildHaipQuery, buildOid4vpSessionTranscript, buildOpenID4VPHandoverSessionTranscript, createAuthorizationRequest, createSignedAuthorizationRequest, decryptAuthorizationResponse, isHaipQuery, parsePresentation, validateHaipQuery, verifyAuthorizationResponse, verifyPresentation };
package/dist/index.d.ts CHANGED
@@ -287,8 +287,23 @@ interface ParseOptions {
287
287
  nonce: string;
288
288
  /** Expected audience for key binding JWT verification. Optional. */
289
289
  audience?: string;
290
+ /**
291
+ * Force holder-binding verification even when the issuer JWT carries no
292
+ * `cnf` claim. When the credential IS holder-bound (`cnf` present), a
293
+ * KB-JWT is ALWAYS required regardless of this flag — this flag only
294
+ * extends the requirement to credentials that lack `cnf`. Default: false.
295
+ */
296
+ requireKeyBinding?: boolean;
290
297
  /** Allowed JWT signature algorithms. Defaults to ['ES256', 'ES384', 'ES512']. */
291
298
  allowedAlgorithms?: string[];
299
+ /**
300
+ * CBOR bytes of the ISO 18013-5 `SessionTranscript` data item for the current
301
+ * OpenID4VP exchange. REQUIRED to verify mDOC device authentication — the
302
+ * mDOC parser fails closed without it, since device proof-of-possession and
303
+ * replay/nonce binding cannot otherwise be checked. Construct it from the
304
+ * OpenID4VP handover (client_id, response_uri, nonce, mdoc-generated-nonce).
305
+ */
306
+ mdocSessionTranscript?: Uint8Array;
292
307
  /**
293
308
  * Explicit opt-in to skip the trust check. When omitted or `false`,
294
309
  * either `trustedCertificates` must be non-empty OR `trustStore` must be
@@ -359,6 +374,42 @@ interface EncryptedResponse {
359
374
  }
360
375
  type VerifyAuthorizationResponseOptions = VerifyOptions & {
361
376
  decryptionKey?: CryptoKey;
377
+ /**
378
+ * The OpenID4VP verifier's `client_id`, as sent in the authorization request.
379
+ * Combined with {@link responseUri}, {@link ParseOptions.nonce} and the
380
+ * `mdoc-generated-nonce` (carried in the JWE `apu` header, ISO 18013-7 Annex B),
381
+ * it lets the encrypted-response path auto-build the mDOC SessionTranscript the
382
+ * mDOC parser requires — so callers need not construct the CBOR by hand. Ignored
383
+ * when the caller supplies {@link ParseOptions.mdocSessionTranscript} explicitly.
384
+ */
385
+ clientId?: string;
386
+ /**
387
+ * The OpenID4VP verifier's `response_uri`, as sent in the authorization request.
388
+ * See {@link clientId} — used to auto-build the mDOC SessionTranscript.
389
+ */
390
+ responseUri?: string;
391
+ /**
392
+ * Which mDOC SessionTranscript layout to auto-build when {@link clientId},
393
+ * {@link responseUri} and {@link ParseOptions.nonce} are present and the
394
+ * caller has not supplied {@link ParseOptions.mdocSessionTranscript}:
395
+ *
396
+ * - `'iso-18013-7'` (default): the ISO 18013-7 Annex B `OID4VPHandover`,
397
+ * derived from the `mdoc-generated-nonce` carried in the JWE `apu` header.
398
+ * This is the id2/id3-era layout and is kept as the default for
399
+ * backwards compatibility.
400
+ * - `'openid4vp-1.0'`: the OpenID4VP 1.0 (Final) `OpenID4VPHandover`
401
+ * (§B.2.6), derived from {@link verifierEncryptionJwk}'s RFC 7638
402
+ * thumbprint instead of an `apu` nonce.
403
+ */
404
+ sessionTranscriptProfile?: 'iso-18013-7' | 'openid4vp-1.0';
405
+ /**
406
+ * The verifier's response-encryption public JWK. Required when
407
+ * {@link sessionTranscriptProfile} is `'openid4vp-1.0'` and the response is
408
+ * encrypted — its RFC 7638 SHA-256 thumbprint is embedded in the
409
+ * OpenID4VPHandover SessionTranscript. Ignored for the `'iso-18013-7'`
410
+ * profile (which uses the JWE `apu` header instead).
411
+ */
412
+ verifierEncryptionJwk?: JsonWebKey;
362
413
  };
363
414
 
364
415
  /**
@@ -402,6 +453,55 @@ declare function verifyAuthorizationResponse(envelope: AuthorizationResponse | E
402
453
  */
403
454
  declare function decryptAuthorizationResponse(jwe: string, privateKey: CryptoKey): Promise<AuthorizationResponse>;
404
455
 
456
+ /**
457
+ * Build the ISO 18013-7 Annex B `OID4VPHandover` SessionTranscript:
458
+ *
459
+ * SessionTranscript = [ null, null, OID4VPHandover ]
460
+ * OID4VPHandover = [ clientIdHash, responseUriHash, nonce ]
461
+ * clientIdHash = SHA-256(cbor([clientId, mdocGeneratedNonce]))
462
+ * responseUriHash = SHA-256(cbor([responseUri, mdocGeneratedNonce]))
463
+ *
464
+ * Used to bind an mdoc DeviceAuthentication to the OpenID4VP authorization
465
+ * request/response exchange it was presented in.
466
+ */
467
+ declare function buildOid4vpSessionTranscript(params: {
468
+ clientId: string;
469
+ responseUri: string;
470
+ nonce: string;
471
+ mdocGeneratedNonce: string;
472
+ }): Promise<Uint8Array>;
473
+ /**
474
+ * Build the OpenID for Verifiable Presentations 1.0 (Final) `OpenID4VPHandover`
475
+ * SessionTranscript (OID4VP 1.0 §B.2.6, `response_uri` flavour):
476
+ *
477
+ * SessionTranscript = [ null, null, OpenID4VPHandover ]
478
+ * OpenID4VPHandover = [ "OpenID4VPHandover", SHA-256(cbor(OpenID4VPHandoverInfo)) ]
479
+ * OpenID4VPHandoverInfo = [ clientId, nonce, jwkThumbprint | null, responseUri ]
480
+ *
481
+ * `jwkThumbprint` is the RFC 7638 SHA-256 thumbprint of the verifier's response
482
+ * ENCRYPTION public JWK as RAW 32 bytes, or CBOR `null` for an unencrypted
483
+ * response. `clientId` is passed verbatim and is expected to already carry its
484
+ * client-id-prefix (e.g. `x509_san_dns:v.example`) — the suite hashes the same
485
+ * `client_id` string it received in the request.
486
+ *
487
+ * This is a DIFFERENT structure from the ISO 18013-7 Annex B `OID4VPHandover`
488
+ * built by `buildOid4vpSessionTranscript` above (which uses an mdoc-generated
489
+ * nonce and separate client_id/response_uri hashes). 1.0-Final wallets tested
490
+ * by the OIDF `oid4vp-1final-verifier-*` modules require THIS layout.
491
+ *
492
+ * Layout confirmed against OID4VP 1.0 Final §B.2.6 and the suite class
493
+ * net.openid.conformance.condition.client.AbstractCreateVP1FinalIsoMdocRedirectSessionTranscript
494
+ * at tag release-v5.1.42: element order [clientId, nonce, thumb|null, responseUri];
495
+ * thumbprint embedded as raw bytes; outer hash is SHA-256 over the CBOR of the
496
+ * 4-element info array.
497
+ */
498
+ declare function buildOpenID4VPHandoverSessionTranscript(params: {
499
+ clientId: string;
500
+ nonce: string;
501
+ responseUri: string;
502
+ verifierEncryptionJwk?: JsonWebKey;
503
+ }): Promise<Uint8Array>;
504
+
405
505
  /**
406
506
  * SD-JWT VC credential parser.
407
507
  *
@@ -578,4 +678,4 @@ declare class LotlTrustStore implements TrustStore {
578
678
 
579
679
  declare const VERSION = "0.8.0";
580
680
 
581
- export { type AuthorizationRequest, type AuthorizationRequestInput, type AuthorizationResponse, type Cache, CertificateChainError, type ChainErrorReason, CompositeTrustStore, type CredentialClaims, type CredentialFormat, DecryptionFailedError, type EncryptedResponse, ExpiredCredentialError, type Fetcher, HAIP_DOCTYPE_NAMESPACES, type HaipQueryInput, type HaipValidationCode, HaipValidationError, type ICredentialParser, InMemoryCache, InvalidSignatureError, type IssuerInfo, type LotlAnchorMetadata, LotlFetchError, LotlSignatureError, LotlTrustStore, type LotlTrustStoreOptions, MalformedCredentialError, MdocParser, MissingDecryptionKeyError, MultipleCredentialsNotSupportedError, NonceValidationError, OpenID4VPError, type ParseOptions, type PresentationResult, RevocationCheckFailedError, RevokedCertificateError, SdJwtParser, type SignedAuthorizationRequest, type SignedAuthorizationRequestInput, SignedRequestBuildError, type SignedRequestBuildErrorCode, StaticTrustStore, type TrustAnchor, TrustAnchorNotFoundError, type TrustStore, type TrustStoreHint, type TrustStoreInput, UnsupportedFormatError, UnsupportedJweError, VERSION, type VerifyAuthorizationResponseOptions, type VerifyOptions, type VerifyResult, buildHaipQuery, createAuthorizationRequest, createSignedAuthorizationRequest, decryptAuthorizationResponse, isHaipQuery, parsePresentation, validateHaipQuery, verifyAuthorizationResponse, verifyPresentation };
681
+ export { type AuthorizationRequest, type AuthorizationRequestInput, type AuthorizationResponse, type Cache, CertificateChainError, type ChainErrorReason, CompositeTrustStore, type CredentialClaims, type CredentialFormat, DecryptionFailedError, type EncryptedResponse, ExpiredCredentialError, type Fetcher, HAIP_DOCTYPE_NAMESPACES, type HaipQueryInput, type HaipValidationCode, HaipValidationError, type ICredentialParser, InMemoryCache, InvalidSignatureError, type IssuerInfo, type LotlAnchorMetadata, LotlFetchError, LotlSignatureError, LotlTrustStore, type LotlTrustStoreOptions, MalformedCredentialError, MdocParser, MissingDecryptionKeyError, MultipleCredentialsNotSupportedError, NonceValidationError, OpenID4VPError, type ParseOptions, type PresentationResult, RevocationCheckFailedError, RevokedCertificateError, SdJwtParser, type SignedAuthorizationRequest, type SignedAuthorizationRequestInput, SignedRequestBuildError, type SignedRequestBuildErrorCode, StaticTrustStore, type TrustAnchor, TrustAnchorNotFoundError, type TrustStore, type TrustStoreHint, type TrustStoreInput, UnsupportedFormatError, UnsupportedJweError, VERSION, type VerifyAuthorizationResponseOptions, type VerifyOptions, type VerifyResult, buildHaipQuery, buildOid4vpSessionTranscript, buildOpenID4VPHandoverSessionTranscript, createAuthorizationRequest, createSignedAuthorizationRequest, decryptAuthorizationResponse, isHaipQuery, parsePresentation, validateHaipQuery, verifyAuthorizationResponse, verifyPresentation };