@sphereon/ssi-sdk.oid4vci-holder 0.34.1-feature.SSISDK.78.280 → 0.34.1-feature.SSISDK.82.and.SSISDK.70.345

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
@@ -391,7 +391,7 @@ var oid4vciRequireAuthorizationGuard = /* @__PURE__ */ __name((ctx, _event) => {
391
391
  if (!openID4VCIClientState) {
392
392
  throw Error("Missing openID4VCI client state in context");
393
393
  }
394
- if (openID4VCIClientState.authorizationRequestOpts) {
394
+ if (openID4VCIClientState.authorizationURL && openID4VCIClientState.authorizationRequestOpts) {
395
395
  return !ctx.openID4VCIClientState?.authorizationCodeResponse;
396
396
  } else if (openID4VCIClientState.credentialOffer?.supportedFlows?.includes(import_oid4vci_common.AuthzFlowType.AUTHORIZATION_CODE_FLOW)) {
397
397
  return !ctx.openID4VCIClientState?.authorizationCodeResponse;
@@ -413,6 +413,7 @@ var createOID4VCIMachine = /* @__PURE__ */ __name((opts) => {
413
413
  // TODO WAL-671 we need to store the data from OpenIdProvider here in the context and make sure we can restart the machine with it and init the OpenIdProvider
414
414
  accessTokenOpts: opts?.accessTokenOpts,
415
415
  requestData: opts?.requestData,
416
+ walletType: opts?.walletType ?? "NATURAL_PERSON",
416
417
  trustAnchors: opts?.trustAnchors ?? [],
417
418
  issuanceOpt: opts?.issuanceOpt,
418
419
  didMethodPreferences: opts?.didMethodPreferences,
@@ -678,6 +679,10 @@ var createOID4VCIMachine = /* @__PURE__ */ __name((opts) => {
678
679
  target: OID4VCIMachineStates.startFirstPartApplicationFlow,
679
680
  cond: OID4VCIMachineGuards.isFirstPartyApplication
680
681
  },
682
+ {
683
+ target: OID4VCIMachineStates.prepareAuthorizationRequest,
684
+ cond: OID4VCIMachineGuards.requireAuthorizationGuard
685
+ },
681
686
  {
682
687
  target: OID4VCIMachineStates.initiateAuthorizationRequest,
683
688
  cond: OID4VCIMachineGuards.requireAuthorizationGuard
@@ -753,6 +758,10 @@ var createOID4VCIMachine = /* @__PURE__ */ __name((opts) => {
753
758
  target: OID4VCIMachineStates.startFirstPartApplicationFlow,
754
759
  cond: OID4VCIMachineGuards.isFirstPartyApplication
755
760
  },
761
+ {
762
+ target: OID4VCIMachineStates.prepareAuthorizationRequest,
763
+ cond: OID4VCIMachineGuards.requireAuthorizationGuard
764
+ },
756
765
  {
757
766
  target: OID4VCIMachineStates.verifyPin,
758
767
  cond: OID4VCIMachineGuards.requirePinGuard
@@ -1766,7 +1775,7 @@ var mapCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
1766
1775
  });
1767
1776
  let uniformVerifiableCredential;
1768
1777
  if (import_ssi_types.CredentialMapper.isSdJwtDecodedCredential(wrappedVerifiableCredential.credential)) {
1769
- uniformVerifiableCredential = await (0, import_ssi_types.sdJwtDecodedCredentialToUniformCredential)(wrappedVerifiableCredential.credential);
1778
+ uniformVerifiableCredential = (0, import_ssi_types.sdJwtDecodedCredentialToUniformCredential)(wrappedVerifiableCredential.credential);
1770
1779
  } else if (import_ssi_types.CredentialMapper.isSdJwtEncoded(wrappedVerifiableCredential.credential)) {
1771
1780
  if (!hasher) {
1772
1781
  return Promise.reject("a hasher is required for encoded SD-JWT credentials");
@@ -1912,7 +1921,7 @@ var getCredentialConfigsSupportedBySingleTypeOrId = /* @__PURE__ */ __name(async
1912
1921
  }
1913
1922
  __name(createIdFromTypes, "createIdFromTypes");
1914
1923
  if (configurationId) {
1915
- const allSupported2 = client.getCredentialsSupported(format);
1924
+ const allSupported2 = client.getCredentialsSupported(void 0, format);
1916
1925
  return Object.fromEntries(Object.entries(allSupported2).filter(([id, supported]) => id === configurationId || supported.id === configurationId || createIdFromTypes(supported) === configurationId));
1917
1926
  }
1918
1927
  if (!client.credentialOffer) {
@@ -2377,7 +2386,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
2377
2386
  ...this.defaultAuthorizationRequestOpts,
2378
2387
  ...args.authorizationRequestOpts
2379
2388
  };
2380
- authorizationRequestOpts.authorizationDetails = authorizationRequestOpts?.authorizationDetails ? (0, import_utils2.asArray)(authorizationRequestOpts.authorizationDetails).filter((detail) => typeof detail === "string" || this.vcFormatPreferences.includes(detail.format)) : void 0;
2389
+ authorizationRequestOpts.authorizationDetails = authorizationRequestOpts?.authorizationDetails ? (0, import_utils2.asArray)(authorizationRequestOpts.authorizationDetails) : void 0;
2381
2390
  if (!authorizationRequestOpts.redirectUri) {
2382
2391
  authorizationRequestOpts.redirectUri = _OID4VCIHolder.DEFAULT_MOBILE_REDIRECT_URI;
2383
2392
  }
@@ -2392,7 +2401,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
2392
2401
  let oid4vciClient;
2393
2402
  let offer;
2394
2403
  if (requestData.existingClientState) {
2395
- oid4vciClient = await import_oid4vci_client3.OpenID4VCIClient.fromState({
2404
+ oid4vciClient = await import_oid4vci_client3.OpenID4VCIClientV1_0_15.fromState({
2396
2405
  state: requestData.existingClientState
2397
2406
  });
2398
2407
  offer = oid4vciClient.credentialOffer;
@@ -2409,7 +2418,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
2409
2418
  }
2410
2419
  if (!offer) {
2411
2420
  logger.log(`Issuer url received (no credential offer): ${uri}`);
2412
- oid4vciClient = await import_oid4vci_client3.OpenID4VCIClient.fromCredentialIssuer({
2421
+ oid4vciClient = await import_oid4vci_client3.OpenID4VCIClientV1_0_15.fromCredentialIssuer({
2413
2422
  credentialIssuer: uri,
2414
2423
  authorizationRequest: authorizationRequestOpts,
2415
2424
  clientId: authorizationRequestOpts.clientId,
@@ -2417,7 +2426,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
2417
2426
  });
2418
2427
  } else {
2419
2428
  logger.log(`Credential offer received: ${uri}`);
2420
- oid4vciClient = await import_oid4vci_client3.OpenID4VCIClient.fromURI({
2429
+ oid4vciClient = await import_oid4vci_client3.OpenID4VCIClientV1_0_15.fromURI({
2421
2430
  uri,
2422
2431
  authorizationRequest: authorizationRequestOpts,
2423
2432
  clientId: authorizationRequestOpts.clientId,
@@ -2429,7 +2438,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
2429
2438
  if (offer) {
2430
2439
  configurationIds = offer.original_credential_offer.credential_configuration_ids;
2431
2440
  } else {
2432
- configurationIds = (0, import_utils2.asArray)(authorizationRequestOpts.authorizationDetails).filter((authDetails) => typeof authDetails !== "string").map((authReqOpts) => authReqOpts.credential_configuration_id).filter((id) => !!id);
2441
+ configurationIds = (0, import_utils2.asArray)(authorizationRequestOpts.authorizationDetails).map((authReqOpts) => authReqOpts.credential_configuration_id).filter((id) => !!id);
2433
2442
  }
2434
2443
  const credentialsSupported = await getCredentialConfigsSupportedMerged({
2435
2444
  client: oid4vciClient,
@@ -2545,12 +2554,12 @@ var OID4VCIHolder = class _OID4VCIHolder {
2545
2554
  return party;
2546
2555
  }
2547
2556
  async oid4vciHolderGetCredentials(args, context) {
2548
- const { verificationCode, openID4VCIClientState, didMethodPreferences = this.didMethodPreferences, issuanceOpt, accessTokenOpts } = args;
2557
+ const { verificationCode, openID4VCIClientState, didMethodPreferences, issuanceOpt, accessTokenOpts, walletType } = args;
2549
2558
  logger.debug(`Getting credentials`, issuanceOpt, accessTokenOpts);
2550
2559
  if (!openID4VCIClientState) {
2551
2560
  return Promise.reject(Error("Missing openID4VCI client state in context"));
2552
2561
  }
2553
- const client = await import_oid4vci_client3.OpenID4VCIClient.fromState({
2562
+ const client = await import_oid4vci_client3.OpenID4VCIClientV1_0_15.fromState({
2554
2563
  state: openID4VCIClientState
2555
2564
  });
2556
2565
  const credentialsSupported = await getCredentialConfigsSupportedMerged({
@@ -2564,7 +2573,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
2564
2573
  credentialsSupported,
2565
2574
  serverMetadata,
2566
2575
  context,
2567
- didMethodPreferences: Array.isArray(didMethodPreferences) && didMethodPreferences.length > 0 ? didMethodPreferences : this.didMethodPreferences,
2576
+ didMethodPreferences: this.selectDidMethodPreferences(didMethodPreferences, walletType),
2568
2577
  jwtCryptographicSuitePreferences: this.jwtCryptographicSuitePreferences,
2569
2578
  jsonldCryptographicSuitePreferences: this.jsonldCryptographicSuitePreferences,
2570
2579
  ...issuanceOpt && {
@@ -2581,6 +2590,16 @@ var OID4VCIHolder = class _OID4VCIHolder {
2581
2590
  logger.log(`Credentials received`, allCredentials);
2582
2591
  return allCredentials;
2583
2592
  }
2593
+ selectDidMethodPreferences(didMethodPreferences, walletType) {
2594
+ const supportedDidMethodEnums = Array.isArray(didMethodPreferences) && didMethodPreferences.length > 0 ? didMethodPreferences : this.didMethodPreferences;
2595
+ if (walletType === "ORGANIZATIONAL") {
2596
+ return [
2597
+ import_ssi_sdk_ext5.SupportedDidMethodEnum.DID_WEB,
2598
+ ...supportedDidMethodEnums
2599
+ ];
2600
+ }
2601
+ return supportedDidMethodEnums;
2602
+ }
2584
2603
  async oid4vciHolderGetCredential(args, context) {
2585
2604
  const { issuanceOpt, pin, client, accessTokenOpts } = args;
2586
2605
  logger.info(`Getting credential`, issuanceOpt);
@@ -3132,6 +3151,7 @@ var OID4VCIHolderLinkHandler = class extends import_ssi_sdk4.LinkHandlerAdapter
3132
3151
  stateNavigationListener;
3133
3152
  firstPartyStateNavigationListener;
3134
3153
  noStateMachinePersistence;
3154
+ walletType;
3135
3155
  authorizationRequestOpts;
3136
3156
  clientOpts;
3137
3157
  trustAnchors;
@@ -3143,6 +3163,7 @@ var OID4VCIHolderLinkHandler = class extends import_ssi_sdk4.LinkHandlerAdapter
3143
3163
  this.authorizationRequestOpts = args.authorizationRequestOpts;
3144
3164
  this.clientOpts = args.clientOpts;
3145
3165
  this.context = args.context;
3166
+ this.walletType = args.walletType ?? "NATURAL_PERSON";
3146
3167
  this.noStateMachinePersistence = args.noStateMachinePersistence === true;
3147
3168
  this.stateNavigationListener = args.stateNavigationListener;
3148
3169
  this.firstPartyStateNavigationListener = args.firstPartyStateNavigationListener;
@@ -3179,7 +3200,8 @@ var OID4VCIHolderLinkHandler = class extends import_ssi_sdk4.LinkHandlerAdapter
3179
3200
  clientOpts
3180
3201
  },
3181
3202
  stateNavigationListener: this.stateNavigationListener,
3182
- firstPartyStateNavigationListener: this.firstPartyStateNavigationListener
3203
+ firstPartyStateNavigationListener: this.firstPartyStateNavigationListener,
3204
+ walletType: this.walletType
3183
3205
  });
3184
3206
  const interpreter = oid4vciMachine.interpreter;
3185
3207
  if (!opts?.machineState && this.context.agent.availableMethods().includes("machineStatesFindActive")) {