@openeudi/openid4vp 0.10.0 → 0.11.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
@@ -18,6 +18,15 @@ interface AuthorizationRequest {
18
18
  interface SignedAuthorizationRequestInput {
19
19
  clientIdPrefix?: 'x509_san_dns' | 'x509_hash';
20
20
  hostname?: string;
21
+ /**
22
+ * Permit a self-signed leaf certificate for the verifier's own identity.
23
+ *
24
+ * Defaults to `false`. HAIP 1.0 Final requires the verifier certificate to
25
+ * chain to a trust anchor the wallet recognises; a self-signed leaf asserts
26
+ * an identity nothing vouches for, so wallets enforcing the profile will
27
+ * reject the request object. Set this only for local development or tests.
28
+ */
29
+ allowSelfSignedCertificate?: boolean;
21
30
  requestUri: string;
22
31
  responseUri: string;
23
32
  nonce: string;
@@ -615,7 +624,7 @@ declare class LotlFetchError extends OpenID4VPError {
615
624
  declare class LotlSignatureError extends OpenID4VPError {
616
625
  readonly code: "lotl_signature_invalid";
617
626
  }
618
- type SignedRequestBuildErrorCode = 'empty_cert_chain' | 'hostname_cert_mismatch' | 'signing_key_cert_mismatch' | 'missing_encryption_jwk' | 'missing_encryption_alg' | 'missing_vp_formats' | 'unsupported_signing_alg' | 'empty_supported_enc_values' | 'missing_hostname';
627
+ type SignedRequestBuildErrorCode = 'empty_cert_chain' | 'hostname_cert_mismatch' | 'signing_key_cert_mismatch' | 'missing_encryption_jwk' | 'missing_encryption_alg' | 'missing_vp_formats' | 'unsupported_signing_alg' | 'empty_supported_enc_values' | 'missing_hostname' | 'self_signed_leaf';
619
628
  declare class SignedRequestBuildError extends OpenID4VPError {
620
629
  readonly code: SignedRequestBuildErrorCode;
621
630
  constructor(code: SignedRequestBuildErrorCode, message: string);
@@ -684,6 +693,6 @@ declare class LotlTrustStore implements TrustStore {
684
693
  private refresh;
685
694
  }
686
695
 
687
- declare const VERSION = "0.10.0";
696
+ declare const VERSION = "0.11.0";
688
697
 
689
698
  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, MissingVerifierEncryptionKeyError, 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
@@ -18,6 +18,15 @@ interface AuthorizationRequest {
18
18
  interface SignedAuthorizationRequestInput {
19
19
  clientIdPrefix?: 'x509_san_dns' | 'x509_hash';
20
20
  hostname?: string;
21
+ /**
22
+ * Permit a self-signed leaf certificate for the verifier's own identity.
23
+ *
24
+ * Defaults to `false`. HAIP 1.0 Final requires the verifier certificate to
25
+ * chain to a trust anchor the wallet recognises; a self-signed leaf asserts
26
+ * an identity nothing vouches for, so wallets enforcing the profile will
27
+ * reject the request object. Set this only for local development or tests.
28
+ */
29
+ allowSelfSignedCertificate?: boolean;
21
30
  requestUri: string;
22
31
  responseUri: string;
23
32
  nonce: string;
@@ -615,7 +624,7 @@ declare class LotlFetchError extends OpenID4VPError {
615
624
  declare class LotlSignatureError extends OpenID4VPError {
616
625
  readonly code: "lotl_signature_invalid";
617
626
  }
618
- type SignedRequestBuildErrorCode = 'empty_cert_chain' | 'hostname_cert_mismatch' | 'signing_key_cert_mismatch' | 'missing_encryption_jwk' | 'missing_encryption_alg' | 'missing_vp_formats' | 'unsupported_signing_alg' | 'empty_supported_enc_values' | 'missing_hostname';
627
+ type SignedRequestBuildErrorCode = 'empty_cert_chain' | 'hostname_cert_mismatch' | 'signing_key_cert_mismatch' | 'missing_encryption_jwk' | 'missing_encryption_alg' | 'missing_vp_formats' | 'unsupported_signing_alg' | 'empty_supported_enc_values' | 'missing_hostname' | 'self_signed_leaf';
619
628
  declare class SignedRequestBuildError extends OpenID4VPError {
620
629
  readonly code: SignedRequestBuildErrorCode;
621
630
  constructor(code: SignedRequestBuildErrorCode, message: string);
@@ -684,6 +693,6 @@ declare class LotlTrustStore implements TrustStore {
684
693
  private refresh;
685
694
  }
686
695
 
687
- declare const VERSION = "0.10.0";
696
+ declare const VERSION = "0.11.0";
688
697
 
689
698
  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, MissingVerifierEncryptionKeyError, 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.js CHANGED
@@ -8274,6 +8274,12 @@ async function createSignedAuthorizationRequest(input, query) {
8274
8274
  "signer.publicKey SPKI does not match leaf certificate SPKI"
8275
8275
  );
8276
8276
  }
8277
+ if (input.allowSelfSignedCertificate !== true && await leafCert.isSelfSigned()) {
8278
+ throw new SignedRequestBuildError(
8279
+ "self_signed_leaf",
8280
+ "leaf certificate is self-signed; HAIP 1.0 Final requires a certificate chaining to a trust anchor. Pass allowSelfSignedCertificate: true to override for local development or tests."
8281
+ );
8282
+ }
8277
8283
  const responseMode = input.responseMode ?? "direct_post.jwt";
8278
8284
  if (responseMode === "direct_post.jwt") {
8279
8285
  if (!input.encryptionKey?.publicJwk) {
@@ -9674,8 +9680,9 @@ async function verifyPresentation(vpToken, query, options) {
9674
9680
  const parsed = await parsePresentation(vpToken, options);
9675
9681
  const dcqlFormat = INTERNAL_TO_DCQL_FORMAT[parsed.format] ?? parsed.format;
9676
9682
  const decodedClaims = parsed.format === "mdoc" && parsed.namespacedClaims !== void 0 ? parsed.namespacedClaims : parsed.claims;
9683
+ const presentedCredentialQuery = query.credentials.find((c) => c.format === dcqlFormat) ?? query.credentials[0];
9677
9684
  const decoded = {
9678
- id: query.credentials[0]?.id ?? "presented",
9685
+ id: presentedCredentialQuery?.id ?? "presented",
9679
9686
  format: dcqlFormat,
9680
9687
  claims: decodedClaims
9681
9688
  };
@@ -9796,8 +9803,12 @@ async function verifyAuthorizationResponse(envelope, query, options) {
9796
9803
  if (queryIds.length > 1 || presentationCount > 1) {
9797
9804
  throw new MultipleCredentialsNotSupportedError(queryIds.length, presentationCount);
9798
9805
  }
9799
- const presentation = vpToken[queryIds[0]][0];
9800
- const decodedPresentation = query.credentials[0]?.format === "mso_mdoc" && typeof presentation === "string" ? base64UrlToBytes(presentation) : presentation;
9806
+ const presentedQueryId = queryIds[0];
9807
+ const presentation = vpToken[presentedQueryId][0];
9808
+ const presentedCredentialQuery = query.credentials.find(
9809
+ (c) => c.id === presentedQueryId
9810
+ );
9811
+ const decodedPresentation = presentedCredentialQuery?.format === "mso_mdoc" && typeof presentation === "string" ? base64UrlToBytes(presentation) : presentation;
9801
9812
  return verifyPresentation(decodedPresentation, query, options);
9802
9813
  }
9803
9814
 
@@ -10430,7 +10441,7 @@ function equalBytes(a, b) {
10430
10441
 
10431
10442
  // src/index.ts
10432
10443
  init_errors();
10433
- var VERSION = "0.10.0";
10444
+ var VERSION = "0.11.0";
10434
10445
  /*! Bundled license information:
10435
10446
 
10436
10447
  pvtsutils/build/index.es.js: