@sphereon/oid4vci-client 0.19.1-next.220 → 0.19.1-next.234

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.cjs CHANGED
@@ -1099,6 +1099,12 @@ function filterSupportedCredentials(credentialOffer, credentialsSupported) {
1099
1099
  __name(filterSupportedCredentials, "filterSupportedCredentials");
1100
1100
  var createAuthorizationRequestUrl = /* @__PURE__ */ __name(async ({ pkce, endpointMetadata, authorizationRequest, credentialOffer, credentialConfigurationSupported, clientId, version }) => {
1101
1101
  function removeDisplayAndValueTypes(obj) {
1102
+ if (Array.isArray(obj)) {
1103
+ return obj.map((item) => removeDisplayAndValueTypes(item));
1104
+ }
1105
+ if (typeof obj !== "object" || obj === null) {
1106
+ return obj;
1107
+ }
1102
1108
  const newObj = {
1103
1109
  ...obj
1104
1110
  };
@@ -1108,7 +1114,7 @@ var createAuthorizationRequestUrl = /* @__PURE__ */ __name(async ({ pkce, endpoi
1108
1114
  "value_type"
1109
1115
  ].includes(prop)) {
1110
1116
  delete newObj[prop];
1111
- } else if (typeof newObj[prop] === "object") {
1117
+ } else if (typeof newObj[prop] === "object" && newObj[prop] !== null) {
1112
1118
  newObj[prop] = removeDisplayAndValueTypes(newObj[prop]);
1113
1119
  }
1114
1120
  }
@@ -1199,7 +1205,7 @@ var createAuthorizationRequestUrl = /* @__PURE__ */ __name(async ({ pkce, endpoi
1199
1205
  ...credentialOffer?.issuerState && {
1200
1206
  issuer_state: credentialOffer.issuerState
1201
1207
  },
1202
- scope: authorizationRequest.scope
1208
+ scope: authorizationRequest.scope ?? "openid"
1203
1209
  };
1204
1210
  if (credentialOffer?.issuerState) {
1205
1211
  queryObj.state = credentialOffer?.issuerState;
@@ -1208,7 +1214,7 @@ var createAuthorizationRequestUrl = /* @__PURE__ */ __name(async ({ pkce, endpoi
1208
1214
  throw Error(`PAR mode is set to required by Authorization Server does not support PAR!`);
1209
1215
  } else if (parEndpoint && parMode !== import_oid4vci_common11.PARMode.NEVER) {
1210
1216
  logger4.debug(`USING PAR with endpoint ${parEndpoint}`);
1211
- const parResponse = await (0, import_oid4vci_common11.formPost)(parEndpoint, (0, import_oid4vci_common11.convertJsonToURI)(queryObj, {
1217
+ const parBody = (0, import_oid4vci_common11.convertJsonToURI)(queryObj, {
1212
1218
  mode: import_oid4vci_common11.JsonURIMode.X_FORM_WWW_URLENCODED,
1213
1219
  uriTypeProperties: [
1214
1220
  "client_id",
@@ -1219,7 +1225,8 @@ var createAuthorizationRequestUrl = /* @__PURE__ */ __name(async ({ pkce, endpoi
1219
1225
  "issuer_state",
1220
1226
  "state"
1221
1227
  ]
1222
- }), {
1228
+ });
1229
+ const parResponse = await (0, import_oid4vci_common11.formPost)(parEndpoint, parBody, {
1223
1230
  contentType: "application/x-www-form-urlencoded",
1224
1231
  accept: "application/json"
1225
1232
  });
@@ -1231,6 +1238,7 @@ var createAuthorizationRequestUrl = /* @__PURE__ */ __name(async ({ pkce, endpoi
1231
1238
  } else {
1232
1239
  logger4.debug(`PAR response: ${JSON.stringify(parResponse.successBody, null, 2)}`);
1233
1240
  queryObj = {
1241
+ /*response_type: ResponseType.AUTH_CODE,*/
1234
1242
  client_id,
1235
1243
  request_uri: parResponse.successBody.request_uri
1236
1244
  };
@@ -1298,6 +1306,11 @@ var handleLocations = /* @__PURE__ */ __name((endpointMetadata, authorizationDet
1298
1306
  endpointMetadata.issuer
1299
1307
  ];
1300
1308
  }
1309
+ if (Array.isArray(authorizationDetails.locations)) {
1310
+ authorizationDetails.locations = [
1311
+ ...new Set(authorizationDetails.locations)
1312
+ ];
1313
+ }
1301
1314
  }
1302
1315
  return authorizationDetails;
1303
1316
  }, "handleLocations");
@@ -1380,7 +1393,17 @@ function findAuthorizationDetail(authorizationDetails, preferredConfigId) {
1380
1393
  return void 0;
1381
1394
  }
1382
1395
  if (preferredConfigId) {
1383
- const match = openIdCredentialDetails.find((detail) => typeof detail === "object" && detail !== null && detail.credential_configuration_id === preferredConfigId);
1396
+ const match = openIdCredentialDetails.find((detail) => {
1397
+ if (typeof detail !== "object" || detail === null) return false;
1398
+ const detailObj = detail;
1399
+ if (detailObj.credential_configuration_id === preferredConfigId) {
1400
+ return true;
1401
+ }
1402
+ if (detailObj.credential_identifier === preferredConfigId) {
1403
+ return true;
1404
+ }
1405
+ return Array.isArray(detailObj.credential_identifiers) && detailObj.credential_identifiers.includes(preferredConfigId);
1406
+ });
1384
1407
  if (match) {
1385
1408
  return match;
1386
1409
  }
@@ -1497,11 +1520,6 @@ var CredentialRequestClient = class {
1497
1520
  });
1498
1521
  }
1499
1522
  response.access_token = requestToken;
1500
- if (uniformRequest.credential_subject_issuance && response.successBody || response.successBody?.credential_subject_issuance) {
1501
- if (JSON.stringify(uniformRequest.credential_subject_issuance) !== JSON.stringify(response.successBody?.credential_subject_issuance)) {
1502
- throw Error("Subject signing was requested, but issuer did not provide the options in its response");
1503
- }
1504
- }
1505
1523
  logger5.debug(`Credential endpoint ${credentialEndpoint} response:\r
1506
1524
  ${JSON.stringify(response, null, 2)}`);
1507
1525
  return {
@@ -2933,6 +2951,7 @@ ${JSON.stringify(response.errorBody)}`);
2933
2951
  if (!this.shouldRetryWithFreshNonce(e)) {
2934
2952
  return Promise.reject(e instanceof Error ? e : Error(String(e)));
2935
2953
  }
2954
+ ;
2936
2955
  this._state.cachedCNonce = void 0;
2937
2956
  try {
2938
2957
  await this.acquireNonceViaV15Delegate();