@openid4vc/openid4vp 0.3.0-alpha-20250713104548 → 0.3.0-alpha-20250713140735

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.mts CHANGED
@@ -11687,6 +11687,14 @@ declare const zClientMetadata: z.ZodObject<{
11687
11687
  }, z.ZodTypeAny, "passthrough">>;
11688
11688
  type ClientMetadata = z.infer<typeof zClientMetadata>;
11689
11689
 
11690
+ /**
11691
+ * The Openid4vpVersionNumber
11692
+ *
11693
+ * 100 means 1.0 final, all others are draft versions
11694
+ */
11695
+ type Openid4vpVersionNumber = 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 100;
11696
+ declare function parseAuthorizationRequestVersion(request: Openid4vpAuthorizationRequest | Openid4vpAuthorizationRequestDcApi): Openid4vpVersionNumber;
11697
+
11690
11698
  declare const zClientIdPrefix: z.ZodEnum<["pre-registered", "redirect_uri", "verifier_attestation", "https", "openid_federation", "did", "decentralized_identifier", "x509_san_uri", "x509_hash", "x509_san_dns", "origin", "web-origin"]>;
11691
11699
  declare const zUniformClientIdPrefix: z.ZodEnum<["pre-registered", "redirect_uri", "verifier_attestation", "openid_federation", "decentralized_identifier", "x509_san_uri", "x509_hash", "x509_san_dns", "origin"]>;
11692
11700
  type ClientIdPrefix = z.infer<typeof zClientIdPrefix>;
@@ -11753,6 +11761,15 @@ interface GetOpenid4vpClientIdOptions {
11753
11761
  legacyClientIdScheme?: unknown;
11754
11762
  responseMode: unknown;
11755
11763
  origin?: string;
11764
+ /**
11765
+ * The version of OpenID4VP used.
11766
+ *
11767
+ * Currently it is only used for:
11768
+ * - determining whether effective client id is `origin:` or `web-origin:` when DC API is used.
11769
+ *
11770
+ * When no version is provided, it is assumed version 1.0 (100) is used.
11771
+ */
11772
+ version?: Openid4vpVersionNumber;
11756
11773
  }
11757
11774
  /**
11758
11775
  * Get the client id for an authorization request based on the response_mode, client_id, client_id_scheme and origin values.
@@ -12573,14 +12590,6 @@ declare const zJarmClientMetadata: z.ZodObject<{
12573
12590
  }>;
12574
12591
  type JarmClientMetadata = z.infer<typeof zJarmClientMetadata>;
12575
12592
 
12576
- /**
12577
- * The Openid4vpVersionNumber
12578
- *
12579
- * 100 means 1.0 final, all others are draft versions
12580
- */
12581
- type Openid4vpVersionNumber = 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 100;
12582
- declare function parseAuthorizationRequestVersion(request: Openid4vpAuthorizationRequest | Openid4vpAuthorizationRequestDcApi): Openid4vpVersionNumber;
12583
-
12584
12593
  interface CreateJarAuthorizationRequestOptions {
12585
12594
  authorizationRequestPayload: JwtPayload & {
12586
12595
  client_id?: string;
package/dist/index.d.ts CHANGED
@@ -11687,6 +11687,14 @@ declare const zClientMetadata: z.ZodObject<{
11687
11687
  }, z.ZodTypeAny, "passthrough">>;
11688
11688
  type ClientMetadata = z.infer<typeof zClientMetadata>;
11689
11689
 
11690
+ /**
11691
+ * The Openid4vpVersionNumber
11692
+ *
11693
+ * 100 means 1.0 final, all others are draft versions
11694
+ */
11695
+ type Openid4vpVersionNumber = 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 100;
11696
+ declare function parseAuthorizationRequestVersion(request: Openid4vpAuthorizationRequest | Openid4vpAuthorizationRequestDcApi): Openid4vpVersionNumber;
11697
+
11690
11698
  declare const zClientIdPrefix: z.ZodEnum<["pre-registered", "redirect_uri", "verifier_attestation", "https", "openid_federation", "did", "decentralized_identifier", "x509_san_uri", "x509_hash", "x509_san_dns", "origin", "web-origin"]>;
11691
11699
  declare const zUniformClientIdPrefix: z.ZodEnum<["pre-registered", "redirect_uri", "verifier_attestation", "openid_federation", "decentralized_identifier", "x509_san_uri", "x509_hash", "x509_san_dns", "origin"]>;
11692
11700
  type ClientIdPrefix = z.infer<typeof zClientIdPrefix>;
@@ -11753,6 +11761,15 @@ interface GetOpenid4vpClientIdOptions {
11753
11761
  legacyClientIdScheme?: unknown;
11754
11762
  responseMode: unknown;
11755
11763
  origin?: string;
11764
+ /**
11765
+ * The version of OpenID4VP used.
11766
+ *
11767
+ * Currently it is only used for:
11768
+ * - determining whether effective client id is `origin:` or `web-origin:` when DC API is used.
11769
+ *
11770
+ * When no version is provided, it is assumed version 1.0 (100) is used.
11771
+ */
11772
+ version?: Openid4vpVersionNumber;
11756
11773
  }
11757
11774
  /**
11758
11775
  * Get the client id for an authorization request based on the response_mode, client_id, client_id_scheme and origin values.
@@ -12573,14 +12590,6 @@ declare const zJarmClientMetadata: z.ZodObject<{
12573
12590
  }>;
12574
12591
  type JarmClientMetadata = z.infer<typeof zJarmClientMetadata>;
12575
12592
 
12576
- /**
12577
- * The Openid4vpVersionNumber
12578
- *
12579
- * 100 means 1.0 final, all others are draft versions
12580
- */
12581
- type Openid4vpVersionNumber = 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 100;
12582
- declare function parseAuthorizationRequestVersion(request: Openid4vpAuthorizationRequest | Openid4vpAuthorizationRequestDcApi): Openid4vpVersionNumber;
12583
-
12584
12593
  interface CreateJarAuthorizationRequestOptions {
12585
12594
  authorizationRequestPayload: JwtPayload & {
12586
12595
  client_id?: string;
package/dist/index.js CHANGED
@@ -350,6 +350,7 @@ function getOpenid4vpClientId(options) {
350
350
  const original = {
351
351
  clientId: options.clientId
352
352
  };
353
+ const version = options.version ?? 100;
353
354
  if (isOpenid4vpResponseModeDcApi(options.responseMode)) {
354
355
  if (!options.clientId) {
355
356
  if (!options.origin) {
@@ -362,10 +363,7 @@ function getOpenid4vpClientId(options) {
362
363
  clientIdPrefix: "origin",
363
364
  effectiveClientIdPrefix: "origin",
364
365
  clientIdIdentifier: options.origin,
365
- // FIXME: draft 24 uses web-origin, draft 25+ uses origin
366
- // But it's not really possible to know which one to use as the
367
- // 'effective' client id. Defaulting to origin: since that's newer
368
- effectiveClientId: `origin:${options.origin}`,
366
+ effectiveClientId: version >= 25 ? `origin:${options.origin}` : `web-origin:${options.origin}`,
369
367
  original
370
368
  };
371
369
  }
@@ -813,10 +811,10 @@ function parseAuthorizationRequestVersion(request) {
813
811
  if (request.client_metadata?.vp_formats_supported?.mso_mdoc?.issuer_signed_alg_values || request.client_metadata?.vp_formats_supported?.mso_mdoc?.device_signed_alg_values) {
814
812
  requirements.push(["<", 28]);
815
813
  }
816
- if (request.client_metadata?.vp_formats) {
814
+ if (request.client_metadata?.vp_formats_supported) {
817
815
  requirements.push([">=", 27]);
818
816
  }
819
- if (request.client_metadata?.vp_formats_supported) {
817
+ if (request.client_metadata?.vp_formats) {
820
818
  requirements.push(["<", 27]);
821
819
  }
822
820
  if (request.client_id?.startsWith("openid_federation:") || request.client_id?.startsWith("decentralized_identifier:")) {
@@ -1457,6 +1455,7 @@ async function resolveOpenid4vpAuthorizationRequest(options) {
1457
1455
  disableOriginValidation
1458
1456
  });
1459
1457
  }
1458
+ const version = parseAuthorizationRequestVersion(authorizationRequestPayload);
1460
1459
  let clientMetadata = authorizationRequestPayload.client_metadata;
1461
1460
  if (!isOpenid4vpAuthorizationRequestDcApi(authorizationRequestPayload) && !clientMetadata && authorizationRequestPayload.client_metadata_uri) {
1462
1461
  clientMetadata = await fetchClientMetadata({ clientMetadataUri: authorizationRequestPayload.client_metadata_uri });
@@ -1468,7 +1467,8 @@ async function resolveOpenid4vpAuthorizationRequest(options) {
1468
1467
  },
1469
1468
  jar,
1470
1469
  callbacks,
1471
- origin
1470
+ origin,
1471
+ version
1472
1472
  });
1473
1473
  let pex;
1474
1474
  let dcql;
@@ -1495,7 +1495,7 @@ async function resolveOpenid4vpAuthorizationRequest(options) {
1495
1495
  client: clientMeta,
1496
1496
  pex,
1497
1497
  dcql,
1498
- version: parseAuthorizationRequestVersion(authorizationRequestPayload)
1498
+ version
1499
1499
  };
1500
1500
  }
1501
1501
  function validateOpenId4vpAuthorizationRequestPayload(options) {