@openid4vc/openid4vp 0.3.0-alpha-20250401105222 → 0.3.0-alpha-20250404180231

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
@@ -15926,6 +15926,15 @@ type Openid4vpAuthorizationResponse = z.infer<typeof zOpenid4vpAuthorizationResp
15926
15926
 
15927
15927
  interface CreateOpenid4vpAuthorizationResponseOptions {
15928
15928
  authorizationRequestPayload: Openid4vpAuthorizationRequest | Openid4vpAuthorizationRequestDcApi;
15929
+ /**
15930
+ * Optional client metadata to use for sending the authorization response. In case of e.g. OpenID Federation
15931
+ * the client metadata needs to be resolved and verified externally.
15932
+ */
15933
+ clientMetadata?: ClientMetadata;
15934
+ /**
15935
+ * The origin of the reuqest, required when creating a response for the Digital Credentials API.
15936
+ */
15937
+ origin?: string;
15929
15938
  authorizationResponsePayload: Openid4vpAuthorizationResponse & {
15930
15939
  state?: never;
15931
15940
  };
package/dist/index.d.ts CHANGED
@@ -15926,6 +15926,15 @@ type Openid4vpAuthorizationResponse = z.infer<typeof zOpenid4vpAuthorizationResp
15926
15926
 
15927
15927
  interface CreateOpenid4vpAuthorizationResponseOptions {
15928
15928
  authorizationRequestPayload: Openid4vpAuthorizationRequest | Openid4vpAuthorizationRequestDcApi;
15929
+ /**
15930
+ * Optional client metadata to use for sending the authorization response. In case of e.g. OpenID Federation
15931
+ * the client metadata needs to be resolved and verified externally.
15932
+ */
15933
+ clientMetadata?: ClientMetadata;
15934
+ /**
15935
+ * The origin of the reuqest, required when creating a response for the Digital Credentials API.
15936
+ */
15937
+ origin?: string;
15929
15938
  authorizationResponsePayload: Openid4vpAuthorizationResponse & {
15930
15939
  state?: never;
15931
15940
  };
package/dist/index.js CHANGED
@@ -983,15 +983,12 @@ function parseAuthorizationRequestVersion(request) {
983
983
  requirements.push(["<", 23]);
984
984
  requirements.push([">=", 21]);
985
985
  }
986
- if (isOpenid4vpAuthorizationRequestDcApi(request) && request.response_mode === "dc_api" || request.response_mode === "dc_api.jwt") {
986
+ if (isOpenid4vpAuthorizationRequestDcApi(request) && (request.response_mode === "dc_api" || request.response_mode === "dc_api.jwt")) {
987
987
  requirements.push([">=", 23]);
988
988
  }
989
989
  if (isOpenid4vpAuthorizationRequestDcApi(request) && (request.transaction_data || request.dcql_query)) {
990
990
  requirements.push([">=", 23]);
991
991
  }
992
- if (request.dcql_query) {
993
- requirements.push([">=", 22]);
994
- }
995
992
  if (request.transaction_data) {
996
993
  requirements.push([">=", 22]);
997
994
  }
@@ -1428,11 +1425,17 @@ function jarmAssertMetadataSupported(options) {
1428
1425
 
1429
1426
  // src/authorization-response/create-authorization-response.ts
1430
1427
  async function createOpenid4vpAuthorizationResponse(options) {
1431
- const { authorizationRequestPayload, jarm, callbacks } = options;
1428
+ const { authorizationRequestPayload, jarm, callbacks, origin } = options;
1432
1429
  const authorizationResponsePayload = {
1433
1430
  ...options.authorizationResponsePayload,
1434
1431
  state: authorizationRequestPayload.state
1435
1432
  };
1433
+ const { clientIdScheme } = getOpenid4vpClientId({
1434
+ responseMode: authorizationRequestPayload.response_mode,
1435
+ clientId: authorizationRequestPayload.client_id,
1436
+ legacyClientIdScheme: authorizationRequestPayload.client_id_scheme,
1437
+ origin
1438
+ });
1436
1439
  if (authorizationRequestPayload.response_mode && isJarmResponseMode(authorizationRequestPayload.response_mode) && !jarm) {
1437
1440
  throw new import_oauth222.Oauth2Error(
1438
1441
  `Missing jarm options for creating Jarm response with response mode '${authorizationRequestPayload.response_mode}'`
@@ -1443,14 +1446,20 @@ async function createOpenid4vpAuthorizationResponse(options) {
1443
1446
  authorizationResponsePayload
1444
1447
  };
1445
1448
  }
1446
- if (!authorizationRequestPayload.client_metadata) {
1449
+ if (clientIdScheme === "https" && !options.clientMetadata) {
1450
+ throw new import_oauth222.Oauth2Error(
1451
+ "When OpenID Federation is used as the client id scheme (https), passing externally fetched and verified 'clientMetadata' to the 'createOpenid4vpAuthorizationResponse' is required."
1452
+ );
1453
+ }
1454
+ const clientMetadata = options.clientMetadata ?? authorizationRequestPayload.client_metadata;
1455
+ if (!clientMetadata) {
1447
1456
  throw new import_oauth222.Oauth2Error("Missing client metadata in the request params to assert Jarm metadata support.");
1448
1457
  }
1449
1458
  let jwks;
1450
- if (authorizationRequestPayload.client_metadata.jwks) {
1451
- jwks = authorizationRequestPayload.client_metadata.jwks;
1452
- } else if (authorizationRequestPayload.client_metadata.jwks_uri) {
1453
- jwks = await (0, import_oauth222.fetchJwks)(authorizationRequestPayload.client_metadata.jwks_uri, options.callbacks.fetch);
1459
+ if (clientMetadata.jwks) {
1460
+ jwks = clientMetadata.jwks;
1461
+ } else if (clientMetadata.jwks_uri) {
1462
+ jwks = await (0, import_oauth222.fetchJwks)(clientMetadata.jwks_uri, options.callbacks.fetch);
1454
1463
  } else {
1455
1464
  throw new import_oauth222.Oauth2ServerErrorResponseError({
1456
1465
  error: import_oauth222.Oauth2ErrorCodes.InvalidRequest,
@@ -1458,11 +1467,11 @@ async function createOpenid4vpAuthorizationResponse(options) {
1458
1467
  });
1459
1468
  }
1460
1469
  const supportedJarmMetadata = jarmAssertMetadataSupported({
1461
- clientMetadata: authorizationRequestPayload.client_metadata,
1470
+ clientMetadata,
1462
1471
  serverMetadata: jarm.serverMetadata
1463
1472
  });
1464
1473
  const clientMetaJwks = extractJwksFromClientMetadata({
1465
- ...authorizationRequestPayload.client_metadata,
1474
+ ...clientMetadata,
1466
1475
  jwks
1467
1476
  });
1468
1477
  if (!clientMetaJwks?.encJwk) {