@pagopa/io-wallet-oid4vci 1.5.8 → 2.0.0-launchpad

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.js CHANGED
@@ -95,7 +95,7 @@ module.exports = __toCommonJS(index_exports);
95
95
  // src/authorization-response/complete-authorization.ts
96
96
  var import_io_wallet_oauth2 = require("@pagopa/io-wallet-oauth2");
97
97
  var import_io_wallet_oid4vp = require("@pagopa/io-wallet-oid4vp");
98
- var import_io_wallet_utils = require("@pagopa/io-wallet-utils");
98
+ var import_io_wallet_utils2 = require("@pagopa/io-wallet-utils");
99
99
 
100
100
  // src/errors.ts
101
101
  var Oid4vciError = class extends Error {
@@ -184,7 +184,7 @@ var CredentialAuthorizationHeaderError = class extends Oid4vciError {
184
184
  };
185
185
 
186
186
  // src/authorization-response/verify-authorization-response.ts
187
- var import_oauth2 = require("@openid4vc/oauth2");
187
+ var import_io_wallet_utils = require("@pagopa/io-wallet-utils");
188
188
  async function verifyAuthorizationResponse(options) {
189
189
  if (options.authorizationResponse.iss !== options.iss)
190
190
  throw new Oid4vciError(
@@ -199,12 +199,12 @@ async function verifyAuthorizationResponse(options) {
199
199
  async function verifyAuthorizationResponseFormPostJWT(options) {
200
200
  try {
201
201
  const decodedJwt = options.authorizationResponseDecoded;
202
- await (0, import_oauth2.verifyJwt)({
202
+ await (0, import_io_wallet_utils.verifyJwt)({
203
203
  compact: options.authorizationResponseCompact,
204
204
  errorMessage: "Error verifying JWT signature",
205
205
  header: decodedJwt.header,
206
206
  payload: decodedJwt.payload,
207
- signer: options.signer ?? (0, import_oauth2.jwtSignerFromJwt)({
207
+ signer: options.signer ?? (0, import_io_wallet_utils.jwtSignerFromJwt)({
208
208
  header: decodedJwt.header,
209
209
  payload: decodedJwt.payload
210
210
  }),
@@ -234,18 +234,18 @@ var zAuthorizationResponse = import_zod.default.object({
234
234
  // src/authorization-response/complete-authorization.ts
235
235
  async function completeAuthorization(options) {
236
236
  try {
237
- const fetch = (0, import_io_wallet_utils.createFetcher)(options.callbacks.fetch);
237
+ const fetch = (0, import_io_wallet_utils2.createFetcher)(options.callbacks.fetch);
238
238
  const authorizationResponseResult = await fetch(options.response_uri);
239
- await (0, import_io_wallet_utils.hasStatusOrThrow)(
239
+ await (0, import_io_wallet_utils2.hasStatusOrThrow)(
240
240
  200,
241
- import_io_wallet_utils.UnexpectedStatusCodeError
241
+ import_io_wallet_utils2.UnexpectedStatusCodeError
242
242
  )(authorizationResponseResult);
243
243
  return await (0, import_io_wallet_oauth2.getJwtFromFormPost)({
244
244
  formData: await authorizationResponseResult.text(),
245
245
  schema: zAuthorizationResponse
246
246
  });
247
247
  } catch (error) {
248
- if (error instanceof import_io_wallet_utils.UnexpectedStatusCodeError || error instanceof import_io_wallet_utils.ValidationError || error instanceof Oid4vciError) {
248
+ if (error instanceof import_io_wallet_utils2.UnexpectedStatusCodeError || error instanceof import_io_wallet_utils2.ValidationError || error instanceof Oid4vciError) {
249
249
  throw error;
250
250
  }
251
251
  throw new Oid4vciError(
@@ -276,7 +276,7 @@ async function sendAuthorizationResponseAndExtractCode(options) {
276
276
  state: options.state
277
277
  });
278
278
  } catch (error) {
279
- if (error instanceof import_io_wallet_utils.UnexpectedStatusCodeError || error instanceof import_io_wallet_utils.ValidationError || error instanceof Oid4vciError) {
279
+ if (error instanceof import_io_wallet_utils2.UnexpectedStatusCodeError || error instanceof import_io_wallet_utils2.ValidationError || error instanceof Oid4vciError) {
280
280
  throw error;
281
281
  }
282
282
  throw new Oid4vciError(
@@ -286,7 +286,7 @@ async function sendAuthorizationResponseAndExtractCode(options) {
286
286
  }
287
287
 
288
288
  // src/credential-offer/extract-grant-details.ts
289
- var import_io_wallet_utils2 = require("@pagopa/io-wallet-utils");
289
+ var import_io_wallet_utils3 = require("@pagopa/io-wallet-utils");
290
290
  function requireAuthorizationCodeGrant(credentialOffer) {
291
291
  if (!credentialOffer.grants) {
292
292
  throw new CredentialOfferError("No grants found in credential offer");
@@ -318,16 +318,16 @@ function extractGrantDetailsV1_4(options) {
318
318
  grantType: "authorization_code"
319
319
  };
320
320
  }
321
- var dispatchExtractGrantDetails = (0, import_io_wallet_utils2.createVersionDispatcher)({
322
- [import_io_wallet_utils2.ItWalletSpecsVersion.V1_0]: () => {
323
- throw new import_io_wallet_utils2.ItWalletSpecsVersionError(
321
+ var dispatchExtractGrantDetails = (0, import_io_wallet_utils3.createVersionDispatcher)({
322
+ [import_io_wallet_utils3.ItWalletSpecsVersion.V1_0]: () => {
323
+ throw new import_io_wallet_utils3.ItWalletSpecsVersionError(
324
324
  "extractGrantDetails",
325
- import_io_wallet_utils2.ItWalletSpecsVersion.V1_0,
326
- [import_io_wallet_utils2.ItWalletSpecsVersion.V1_3, import_io_wallet_utils2.ItWalletSpecsVersion.V1_4]
325
+ import_io_wallet_utils3.ItWalletSpecsVersion.V1_0,
326
+ [import_io_wallet_utils3.ItWalletSpecsVersion.V1_3, import_io_wallet_utils3.ItWalletSpecsVersion.V1_4]
327
327
  );
328
328
  },
329
- [import_io_wallet_utils2.ItWalletSpecsVersion.V1_3]: (o) => extractGrantDetailsV1_3(o),
330
- [import_io_wallet_utils2.ItWalletSpecsVersion.V1_4]: (o) => extractGrantDetailsV1_4(o)
329
+ [import_io_wallet_utils3.ItWalletSpecsVersion.V1_3]: (o) => extractGrantDetailsV1_3(o),
330
+ [import_io_wallet_utils3.ItWalletSpecsVersion.V1_4]: (o) => extractGrantDetailsV1_4(o)
331
331
  });
332
332
  function extractGrantDetails(options) {
333
333
  return dispatchExtractGrantDetails(options);
@@ -475,18 +475,18 @@ async function parseCredentialOfferUri(options) {
475
475
  }
476
476
 
477
477
  // src/credential-offer/resolve-credential-offer.ts
478
- var import_io_wallet_utils3 = require("@pagopa/io-wallet-utils");
478
+ var import_io_wallet_utils4 = require("@pagopa/io-wallet-utils");
479
479
  function parseCredentialOfferForVersion(config, data) {
480
480
  switch (config.itWalletSpecsVersion) {
481
- case import_io_wallet_utils3.ItWalletSpecsVersion.V1_3:
481
+ case import_io_wallet_utils4.ItWalletSpecsVersion.V1_3:
482
482
  return zCredentialOfferV1_3.parse(data);
483
- case import_io_wallet_utils3.ItWalletSpecsVersion.V1_4:
483
+ case import_io_wallet_utils4.ItWalletSpecsVersion.V1_4:
484
484
  return zCredentialOfferV1_4.parse(data);
485
485
  default:
486
- throw new import_io_wallet_utils3.ItWalletSpecsVersionError(
486
+ throw new import_io_wallet_utils4.ItWalletSpecsVersionError(
487
487
  "resolveCredentialOffer",
488
488
  config.itWalletSpecsVersion,
489
- [import_io_wallet_utils3.ItWalletSpecsVersion.V1_3, import_io_wallet_utils3.ItWalletSpecsVersion.V1_4]
489
+ [import_io_wallet_utils4.ItWalletSpecsVersion.V1_3, import_io_wallet_utils4.ItWalletSpecsVersion.V1_4]
490
490
  );
491
491
  }
492
492
  }
@@ -501,14 +501,14 @@ async function resolveCredentialOffer(options) {
501
501
  return parseCredentialOfferForVersion(config, offerJson2);
502
502
  }
503
503
  if (parsed.credential_offer_uri) {
504
- const fetch = (0, import_io_wallet_utils3.createFetcher)(callbacks.fetch);
504
+ const fetch = (0, import_io_wallet_utils4.createFetcher)(callbacks.fetch);
505
505
  const response = await fetch(parsed.credential_offer_uri, {
506
506
  headers: {
507
507
  Accept: "application/json"
508
508
  },
509
509
  method: "GET"
510
510
  });
511
- await (0, import_io_wallet_utils3.hasStatusOrThrow)(200, import_io_wallet_utils3.UnexpectedStatusCodeError)(response);
511
+ await (0, import_io_wallet_utils4.hasStatusOrThrow)(200, import_io_wallet_utils4.UnexpectedStatusCodeError)(response);
512
512
  const offerJson2 = await response.json();
513
513
  return parseCredentialOfferForVersion(config, offerJson2);
514
514
  }
@@ -516,7 +516,7 @@ async function resolveCredentialOffer(options) {
516
516
  const offerJson = JSON.parse(credentialOffer);
517
517
  return parseCredentialOfferForVersion(config, offerJson);
518
518
  } catch (error) {
519
- if (error instanceof CredentialOfferError || error instanceof import_io_wallet_utils3.UnexpectedStatusCodeError || error instanceof import_io_wallet_utils3.ItWalletSpecsVersionError) {
519
+ if (error instanceof CredentialOfferError || error instanceof import_io_wallet_utils4.UnexpectedStatusCodeError || error instanceof import_io_wallet_utils4.ItWalletSpecsVersionError) {
520
520
  throw error;
521
521
  }
522
522
  throw new CredentialOfferError(
@@ -526,7 +526,7 @@ async function resolveCredentialOffer(options) {
526
526
  }
527
527
 
528
528
  // src/credential-offer/validate-credential-offer.ts
529
- var import_io_wallet_utils4 = require("@pagopa/io-wallet-utils");
529
+ var import_io_wallet_utils5 = require("@pagopa/io-wallet-utils");
530
530
  function assertAuthorizationServerAllowed(authorizationServer, authorizationServers) {
531
531
  if (!authorizationServer) {
532
532
  if (authorizationServers && authorizationServers.length > 1) {
@@ -595,26 +595,26 @@ async function validateCredentialOfferV1_4(options) {
595
595
  versionLabel: "v1.4"
596
596
  });
597
597
  }
598
- var dispatchValidateCredentialOffer = (0, import_io_wallet_utils4.createVersionDispatcher)({
599
- [import_io_wallet_utils4.ItWalletSpecsVersion.V1_0]: () => {
600
- throw new import_io_wallet_utils4.ItWalletSpecsVersionError(
598
+ var dispatchValidateCredentialOffer = (0, import_io_wallet_utils5.createVersionDispatcher)({
599
+ [import_io_wallet_utils5.ItWalletSpecsVersion.V1_0]: () => {
600
+ throw new import_io_wallet_utils5.ItWalletSpecsVersionError(
601
601
  "validateCredentialOffer",
602
- import_io_wallet_utils4.ItWalletSpecsVersion.V1_0,
603
- [import_io_wallet_utils4.ItWalletSpecsVersion.V1_3, import_io_wallet_utils4.ItWalletSpecsVersion.V1_4]
602
+ import_io_wallet_utils5.ItWalletSpecsVersion.V1_0,
603
+ [import_io_wallet_utils5.ItWalletSpecsVersion.V1_3, import_io_wallet_utils5.ItWalletSpecsVersion.V1_4]
604
604
  );
605
605
  },
606
- [import_io_wallet_utils4.ItWalletSpecsVersion.V1_3]: (o) => validateCredentialOfferV1_3(o),
607
- [import_io_wallet_utils4.ItWalletSpecsVersion.V1_4]: (o) => validateCredentialOfferV1_4(o)
606
+ [import_io_wallet_utils5.ItWalletSpecsVersion.V1_3]: (o) => validateCredentialOfferV1_3(o),
607
+ [import_io_wallet_utils5.ItWalletSpecsVersion.V1_4]: (o) => validateCredentialOfferV1_4(o)
608
608
  });
609
609
  async function validateCredentialOffer(options) {
610
610
  return dispatchValidateCredentialOffer(options);
611
611
  }
612
612
 
613
613
  // src/credential-request/create-credential-request.ts
614
- var import_io_wallet_utils7 = require("@pagopa/io-wallet-utils");
614
+ var import_io_wallet_utils8 = require("@pagopa/io-wallet-utils");
615
615
 
616
616
  // src/credential-request/v1.0/create-credential-request.ts
617
- var import_io_wallet_utils5 = require("@pagopa/io-wallet-utils");
617
+ var import_io_wallet_utils6 = require("@pagopa/io-wallet-utils");
618
618
 
619
619
  // src/credential-request/v1.0/z-credential.ts
620
620
  var import_zod6 = require("zod");
@@ -675,12 +675,12 @@ var createCredentialRequest = async (options) => {
675
675
  },
676
676
  payload: {
677
677
  aud: options.issuerIdentifier,
678
- iat: (0, import_io_wallet_utils5.dateToSeconds)(/* @__PURE__ */ new Date()),
678
+ iat: (0, import_io_wallet_utils6.dateToSeconds)(/* @__PURE__ */ new Date()),
679
679
  iss: options.clientId,
680
680
  nonce: options.nonce
681
681
  }
682
682
  });
683
- return (0, import_io_wallet_utils5.parseWithErrorHandling)(zCredentialRequestV1_0, {
683
+ return (0, import_io_wallet_utils6.parseWithErrorHandling)(zCredentialRequestV1_0, {
684
684
  credential_identifier: options.credential_identifier,
685
685
  proof: {
686
686
  jwt: proofJwt.jwt,
@@ -688,7 +688,7 @@ var createCredentialRequest = async (options) => {
688
688
  }
689
689
  });
690
690
  } catch (error) {
691
- if (error instanceof import_io_wallet_utils5.ValidationError) {
691
+ if (error instanceof import_io_wallet_utils6.ValidationError) {
692
692
  throw error;
693
693
  }
694
694
  throw new Oid4vciError(
@@ -698,8 +698,7 @@ var createCredentialRequest = async (options) => {
698
698
  };
699
699
 
700
700
  // src/credential-request/v1.3/create-credential-request.ts
701
- var import_oauth22 = require("@openid4vc/oauth2");
702
- var import_io_wallet_utils6 = require("@pagopa/io-wallet-utils");
701
+ var import_io_wallet_utils7 = require("@pagopa/io-wallet-utils");
703
702
 
704
703
  // src/credential-request/v1.3/z-credential.ts
705
704
  var import_zod7 = require("zod");
@@ -721,16 +720,16 @@ var createCredentialRequest2 = async (options) => {
721
720
  const { maxBatchSize, signers } = options;
722
721
  const [firstSigner, ...otherSigners] = signers;
723
722
  if (!firstSigner) {
724
- throw new import_io_wallet_utils6.ValidationError("At least one signer is required");
723
+ throw new import_io_wallet_utils7.ValidationError("At least one signer is required");
725
724
  }
726
725
  if (maxBatchSize !== void 0) {
727
726
  if (!Number.isInteger(maxBatchSize) || maxBatchSize <= 0) {
728
- throw new import_io_wallet_utils6.ValidationError(
727
+ throw new import_io_wallet_utils7.ValidationError(
729
728
  "Invalid maxBatchSize: it must be a positive integer"
730
729
  );
731
730
  }
732
731
  if (signers.length > maxBatchSize) {
733
- throw new import_io_wallet_utils6.ValidationError(
732
+ throw new import_io_wallet_utils7.ValidationError(
734
733
  "The number of provided signers exceeds the maximum batch size allowed"
735
734
  );
736
735
  }
@@ -739,8 +738,8 @@ var createCredentialRequest2 = async (options) => {
739
738
  if (signers.length > 1) {
740
739
  const allThumbprints = await Promise.all(
741
740
  signers.map(
742
- (signer) => (0, import_oauth22.calculateJwkThumbprint)({
743
- hashAlgorithm: import_oauth22.HashAlgorithm.Sha256,
741
+ (signer) => (0, import_io_wallet_utils7.calculateJwkThumbprint)({
742
+ hashAlgorithm: import_io_wallet_utils7.HashAlgorithm.Sha256,
744
743
  hashCallback: hash,
745
744
  jwk: signer.publicJwk
746
745
  })
@@ -748,7 +747,7 @@ var createCredentialRequest2 = async (options) => {
748
747
  );
749
748
  const uniqueThumbprints = new Set(allThumbprints);
750
749
  if (uniqueThumbprints.size !== allThumbprints.length) {
751
- throw new import_io_wallet_utils6.ValidationError(
750
+ throw new import_io_wallet_utils7.ValidationError(
752
751
  "Found multiple signers with the same JWK: each JWT proof must be unique and linked to a different credential key pair"
753
752
  );
754
753
  }
@@ -762,7 +761,7 @@ var createCredentialRequest2 = async (options) => {
762
761
  },
763
762
  payload: {
764
763
  aud: options.issuerIdentifier,
765
- iat: (0, import_io_wallet_utils6.dateToSeconds)(/* @__PURE__ */ new Date()),
764
+ iat: (0, import_io_wallet_utils7.dateToSeconds)(/* @__PURE__ */ new Date()),
766
765
  iss: options.clientId,
767
766
  nonce: options.nonce
768
767
  }
@@ -771,14 +770,14 @@ var createCredentialRequest2 = async (options) => {
771
770
  createProofJwt(firstSigner),
772
771
  ...otherSigners.map(createProofJwt)
773
772
  ]);
774
- return (0, import_io_wallet_utils6.parseWithErrorHandling)(zCredentialRequestV1_3, {
773
+ return (0, import_io_wallet_utils7.parseWithErrorHandling)(zCredentialRequestV1_3, {
775
774
  credential_identifier: options.credential_identifier,
776
775
  proofs: {
777
776
  jwt: proofJwts
778
777
  }
779
778
  });
780
779
  } catch (error) {
781
- if (error instanceof import_io_wallet_utils6.ValidationError) {
780
+ if (error instanceof import_io_wallet_utils7.ValidationError) {
782
781
  throw error;
783
782
  }
784
783
  throw new Oid4vciError(
@@ -788,10 +787,10 @@ var createCredentialRequest2 = async (options) => {
788
787
  };
789
788
 
790
789
  // src/credential-request/create-credential-request.ts
791
- var dispatchCreateCredentialRequest = (0, import_io_wallet_utils7.createVersionDispatcher)({
792
- [import_io_wallet_utils7.ItWalletSpecsVersion.V1_0]: (o) => createCredentialRequest(o),
793
- [import_io_wallet_utils7.ItWalletSpecsVersion.V1_3]: (o) => createCredentialRequest2(o),
794
- [import_io_wallet_utils7.ItWalletSpecsVersion.V1_4]: (o) => (
790
+ var dispatchCreateCredentialRequest = (0, import_io_wallet_utils8.createVersionDispatcher)({
791
+ [import_io_wallet_utils8.ItWalletSpecsVersion.V1_0]: (o) => createCredentialRequest(o),
792
+ [import_io_wallet_utils8.ItWalletSpecsVersion.V1_3]: (o) => createCredentialRequest2(o),
793
+ [import_io_wallet_utils8.ItWalletSpecsVersion.V1_4]: (o) => (
795
794
  // V1_4 reuses V1_3 credential request schema — no breaking changes between versions.
796
795
  // Verified against compare/1.3.3...1.4.1: credential request parameters (format, proofs, key_attestation) identical.
797
796
  createCredentialRequest2(o)
@@ -802,15 +801,15 @@ async function createCredentialRequest3(options) {
802
801
  }
803
802
 
804
803
  // src/credential-request/parse-credential-request.ts
805
- var import_io_wallet_oauth23 = require("@pagopa/io-wallet-oauth2");
806
- var import_io_wallet_utils8 = require("@pagopa/io-wallet-utils");
804
+ var import_io_wallet_oauth22 = require("@pagopa/io-wallet-oauth2");
805
+ var import_io_wallet_utils10 = require("@pagopa/io-wallet-utils");
807
806
 
808
807
  // src/credential-request/z-proof-jwt.ts
809
- var import_io_wallet_oauth22 = require("@pagopa/io-wallet-oauth2");
808
+ var import_io_wallet_utils9 = require("@pagopa/io-wallet-utils");
810
809
  var import_zod8 = require("zod");
811
810
  var zBaseProofJwtHeader = import_zod8.z.object({
812
811
  alg: import_zod8.z.string().min(1),
813
- jwk: import_io_wallet_oauth22.zJwk,
812
+ jwk: import_io_wallet_utils9.zJwk,
814
813
  typ: import_zod8.z.literal("openid4vci-proof+jwt")
815
814
  });
816
815
  var zProofJwtHeaderV1_0 = zBaseProofJwtHeader.loose();
@@ -830,12 +829,12 @@ function validateExpectedValues(credentialRequest, expected) {
830
829
  return;
831
830
  }
832
831
  if (expected.credential_identifier && credentialRequest.credential_identifier !== expected.credential_identifier) {
833
- throw new import_io_wallet_utils8.ValidationError(
832
+ throw new import_io_wallet_utils10.ValidationError(
834
833
  "credential_identifier does not match expected value"
835
834
  );
836
835
  }
837
836
  if (expected.credential_configuration_id && credentialRequest.credential_configuration_id !== expected.credential_configuration_id) {
838
- throw new import_io_wallet_utils8.ValidationError(
837
+ throw new import_io_wallet_utils10.ValidationError(
839
838
  "credential_configuration_id does not match expected value"
840
839
  );
841
840
  }
@@ -843,12 +842,12 @@ function validateExpectedValues(credentialRequest, expected) {
843
842
  function validateTransactionContext(options) {
844
843
  const { credentialRequest, isDeferredFlow } = options;
845
844
  if (isDeferredFlow && !credentialRequest.transaction_id) {
846
- throw new import_io_wallet_utils8.ValidationError(
845
+ throw new import_io_wallet_utils10.ValidationError(
847
846
  "transaction_id is required for deferred credential issuance"
848
847
  );
849
848
  }
850
849
  if (!isDeferredFlow && credentialRequest.transaction_id) {
851
- throw new import_io_wallet_utils8.ValidationError(
850
+ throw new import_io_wallet_utils10.ValidationError(
852
851
  "transaction_id must not be present in immediate credential issuance flow"
853
852
  );
854
853
  }
@@ -856,45 +855,45 @@ function validateTransactionContext(options) {
856
855
  function validateProofPayloadSemantics(options) {
857
856
  const { expected, grantType, payload } = options;
858
857
  if (grantType === "authorization_code" && !payload.iss) {
859
- throw new import_io_wallet_utils8.ValidationError(
858
+ throw new import_io_wallet_utils10.ValidationError(
860
859
  "Credential proof JWT payload must include iss for authorization_code grant"
861
860
  );
862
861
  }
863
862
  if (expected?.audience && payload.aud !== expected.audience) {
864
- throw new import_io_wallet_utils8.ValidationError(
863
+ throw new import_io_wallet_utils10.ValidationError(
865
864
  "Credential proof JWT aud does not match expected audience"
866
865
  );
867
866
  }
868
867
  if (expected?.nonce && payload.nonce !== expected.nonce) {
869
- throw new import_io_wallet_utils8.ValidationError(
868
+ throw new import_io_wallet_utils10.ValidationError(
870
869
  "Credential proof JWT nonce does not match expected nonce"
871
870
  );
872
871
  }
873
872
  if (expected?.issuer && payload.iss && payload.iss !== expected.issuer) {
874
- throw new import_io_wallet_utils8.ValidationError(
873
+ throw new import_io_wallet_utils10.ValidationError(
875
874
  "Credential proof JWT iss does not match expected issuer"
876
875
  );
877
876
  }
878
877
  if (grantType === "authorization_code" && expected?.issuer && !payload.iss) {
879
- throw new import_io_wallet_utils8.ValidationError(
878
+ throw new import_io_wallet_utils10.ValidationError(
880
879
  "Credential proof JWT payload is missing expected issuer (iss)"
881
880
  );
882
881
  }
883
882
  }
884
883
  function parseProofJwt(options) {
885
- const decoded = (0, import_io_wallet_oauth23.decodeJwt)({
884
+ const decoded = (0, import_io_wallet_utils10.decodeJwt)({
886
885
  errorMessagePrefix: "Error decoding credential request proof JWT:",
887
886
  jwt: options.jwt
888
887
  });
889
- const headerValidation = options.itWalletSpecsVersion === import_io_wallet_utils8.ItWalletSpecsVersion.V1_3 || options.itWalletSpecsVersion === import_io_wallet_utils8.ItWalletSpecsVersion.V1_4 ? zProofJwtHeaderV1_3.safeParse(decoded.header) : zProofJwtHeaderV1_0.safeParse(decoded.header);
888
+ const headerValidation = options.itWalletSpecsVersion === import_io_wallet_utils10.ItWalletSpecsVersion.V1_3 || options.itWalletSpecsVersion === import_io_wallet_utils10.ItWalletSpecsVersion.V1_4 ? zProofJwtHeaderV1_3.safeParse(decoded.header) : zProofJwtHeaderV1_0.safeParse(decoded.header);
890
889
  if (!headerValidation.success) {
891
- throw new import_io_wallet_utils8.ValidationError(
890
+ throw new import_io_wallet_utils10.ValidationError(
892
891
  "Credential proof JWT header is invalid or missing required claims"
893
892
  );
894
893
  }
895
894
  const payloadValidation = zProofJwtPayload.safeParse(decoded.payload);
896
895
  if (!payloadValidation.success) {
897
- throw new import_io_wallet_utils8.ValidationError(
896
+ throw new import_io_wallet_utils10.ValidationError(
898
897
  "Credential proof JWT payload is invalid or missing required claims"
899
898
  );
900
899
  }
@@ -917,8 +916,8 @@ async function validateProofJwkUniqueness(options) {
917
916
  }
918
917
  const thumbprints = await Promise.all(
919
918
  options.proofs.map(
920
- (proof) => (0, import_io_wallet_utils8.calculateJwkThumbprint)({
921
- hashAlgorithm: import_io_wallet_utils8.HashAlgorithm.Sha256,
919
+ (proof) => (0, import_io_wallet_utils10.calculateJwkThumbprint)({
920
+ hashAlgorithm: import_io_wallet_utils10.HashAlgorithm.Sha256,
922
921
  hashCallback: options.callbacks.hash,
923
922
  jwk: proof.header.jwk
924
923
  })
@@ -926,7 +925,7 @@ async function validateProofJwkUniqueness(options) {
926
925
  );
927
926
  const uniqueThumbprints = new Set(thumbprints);
928
927
  if (uniqueThumbprints.size !== thumbprints.length) {
929
- throw new import_io_wallet_utils8.ValidationError(
928
+ throw new import_io_wallet_utils10.ValidationError(
930
929
  "Credential request proofs must use unique jwk header values"
931
930
  );
932
931
  }
@@ -986,7 +985,7 @@ async function toResult(options) {
986
985
  };
987
986
  }
988
987
  function parseAuthorizationHeader(headers) {
989
- const authorizationHeader = headers.get(import_io_wallet_utils8.HEADERS.AUTHORIZATION)?.trim();
988
+ const authorizationHeader = headers.get(import_io_wallet_utils10.HEADERS.AUTHORIZATION)?.trim();
990
989
  if (!authorizationHeader) {
991
990
  throw new CredentialAuthorizationHeaderError(
992
991
  "Credential request is missing required 'Authorization' header with DPoP scheme"
@@ -1001,7 +1000,7 @@ function parseAuthorizationHeader(headers) {
1001
1000
  return token;
1002
1001
  }
1003
1002
  function parseDpopProof(headers) {
1004
- const extracted = (0, import_io_wallet_oauth23.extractDpopJwtFromHeaders)(headers);
1003
+ const extracted = (0, import_io_wallet_oauth22.extractDpopJwtFromHeaders)(headers);
1005
1004
  if (!extracted.valid) {
1006
1005
  throw new InvalidDpopProofError(
1007
1006
  "Credential request contains a 'DPoP' header, but the value is not a valid JWT format"
@@ -1013,7 +1012,7 @@ function parseDpopProof(headers) {
1013
1012
  return extracted.dpopJwt;
1014
1013
  }
1015
1014
  function parseCredentialRequestV1_0(options) {
1016
- const credentialRequest = (0, import_io_wallet_utils8.parseWithErrorHandling)(
1015
+ const credentialRequest = (0, import_io_wallet_utils10.parseWithErrorHandling)(
1017
1016
  zCredentialRequestV1_0,
1018
1017
  options.credentialRequest,
1019
1018
  "Invalid credential request format for ItWalletSpecsVersion 1.0"
@@ -1026,11 +1025,11 @@ function parseCredentialRequestV1_0(options) {
1026
1025
  expected: options.expected,
1027
1026
  grantType: options.grantType,
1028
1027
  isDeferredFlow: options.isDeferredFlow,
1029
- itWalletSpecsVersion: import_io_wallet_utils8.ItWalletSpecsVersion.V1_0
1028
+ itWalletSpecsVersion: import_io_wallet_utils10.ItWalletSpecsVersion.V1_0
1030
1029
  });
1031
1030
  }
1032
1031
  function parseCredentialRequestV1_3(options) {
1033
- const credentialRequest = (0, import_io_wallet_utils8.parseWithErrorHandling)(
1032
+ const credentialRequest = (0, import_io_wallet_utils10.parseWithErrorHandling)(
1034
1033
  zCredentialRequestV1_3,
1035
1034
  options.credentialRequest,
1036
1035
  "Invalid credential request format for ItWalletSpecsVersion 1.3"
@@ -1043,11 +1042,11 @@ function parseCredentialRequestV1_3(options) {
1043
1042
  expected: options.expected,
1044
1043
  grantType: options.grantType,
1045
1044
  isDeferredFlow: options.isDeferredFlow,
1046
- itWalletSpecsVersion: import_io_wallet_utils8.ItWalletSpecsVersion.V1_3
1045
+ itWalletSpecsVersion: import_io_wallet_utils10.ItWalletSpecsVersion.V1_3
1047
1046
  });
1048
1047
  }
1049
1048
  function parseCredentialRequestV1_4(options) {
1050
- const credentialRequest = (0, import_io_wallet_utils8.parseWithErrorHandling)(
1049
+ const credentialRequest = (0, import_io_wallet_utils10.parseWithErrorHandling)(
1051
1050
  zCredentialRequestV1_3,
1052
1051
  options.credentialRequest,
1053
1052
  "Invalid credential request format for ItWalletSpecsVersion 1.4"
@@ -1060,14 +1059,14 @@ function parseCredentialRequestV1_4(options) {
1060
1059
  expected: options.expected,
1061
1060
  grantType: options.grantType,
1062
1061
  isDeferredFlow: options.isDeferredFlow,
1063
- itWalletSpecsVersion: import_io_wallet_utils8.ItWalletSpecsVersion.V1_4
1062
+ itWalletSpecsVersion: import_io_wallet_utils10.ItWalletSpecsVersion.V1_4
1064
1063
  // V1_4 reuses V1_3 proof schema
1065
1064
  });
1066
1065
  }
1067
- var dispatchParseCredentialRequest = (0, import_io_wallet_utils8.createVersionDispatcher)({
1068
- [import_io_wallet_utils8.ItWalletSpecsVersion.V1_0]: parseCredentialRequestV1_0,
1069
- [import_io_wallet_utils8.ItWalletSpecsVersion.V1_3]: parseCredentialRequestV1_3,
1070
- [import_io_wallet_utils8.ItWalletSpecsVersion.V1_4]: parseCredentialRequestV1_4
1066
+ var dispatchParseCredentialRequest = (0, import_io_wallet_utils10.createVersionDispatcher)({
1067
+ [import_io_wallet_utils10.ItWalletSpecsVersion.V1_0]: parseCredentialRequestV1_0,
1068
+ [import_io_wallet_utils10.ItWalletSpecsVersion.V1_3]: parseCredentialRequestV1_3,
1069
+ [import_io_wallet_utils10.ItWalletSpecsVersion.V1_4]: parseCredentialRequestV1_4
1071
1070
  });
1072
1071
  async function parseCredentialRequest(options) {
1073
1072
  const grantType = options.grantType ?? "authorization_code";
@@ -1083,7 +1082,7 @@ async function parseCredentialRequest(options) {
1083
1082
  isDeferredFlow
1084
1083
  });
1085
1084
  } catch (error) {
1086
- if (error instanceof import_io_wallet_utils8.ItWalletSpecsVersionError || error instanceof import_io_wallet_oauth23.Oauth2JwtParseError || error instanceof import_io_wallet_utils8.ValidationError || error instanceof CredentialAuthorizationHeaderError || error instanceof MissingDpopProofError || error instanceof InvalidDpopProofError) {
1085
+ if (error instanceof import_io_wallet_utils10.ItWalletSpecsVersionError || error instanceof import_io_wallet_utils10.JwtParseError || error instanceof import_io_wallet_utils10.ValidationError || error instanceof CredentialAuthorizationHeaderError || error instanceof MissingDpopProofError || error instanceof InvalidDpopProofError) {
1087
1086
  throw error;
1088
1087
  }
1089
1088
  throw new ParseCredentialRequestError(
@@ -1094,19 +1093,14 @@ async function parseCredentialRequest(options) {
1094
1093
  }
1095
1094
 
1096
1095
  // src/credential-request/verify-credential-request-jwt-proof.ts
1097
- var import_oauth24 = require("@openid4vc/oauth2");
1098
- var import_io_wallet_oauth26 = require("@pagopa/io-wallet-oauth2");
1099
- var import_io_wallet_utils11 = require("@pagopa/io-wallet-utils");
1096
+ var import_io_wallet_utils13 = require("@pagopa/io-wallet-utils");
1100
1097
 
1101
1098
  // src/credential-request/verify-key-attestation-jwt.ts
1102
- var import_oauth23 = require("@openid4vc/oauth2");
1103
- var import_io_wallet_oauth25 = require("@pagopa/io-wallet-oauth2");
1104
- var import_io_wallet_utils10 = require("@pagopa/io-wallet-utils");
1099
+ var import_io_wallet_utils12 = require("@pagopa/io-wallet-utils");
1105
1100
 
1106
1101
  // src/wallet-provider/z-key-attestation.ts
1107
- var import_io_wallet_oauth24 = require("@pagopa/io-wallet-oauth2");
1108
1102
  var import_io_wallet_oid_federation = require("@pagopa/io-wallet-oid-federation");
1109
- var import_io_wallet_utils9 = require("@pagopa/io-wallet-utils");
1103
+ var import_io_wallet_utils11 = require("@pagopa/io-wallet-utils");
1110
1104
  var import_zod9 = require("zod");
1111
1105
  var zStatusList = import_zod9.z.object({
1112
1106
  idx: import_zod9.z.number(),
@@ -1115,16 +1109,16 @@ var zStatusList = import_zod9.z.object({
1115
1109
  var zKeyAttestationStatus = import_zod9.z.object({
1116
1110
  status_list: zStatusList
1117
1111
  });
1118
- var zKeyAttestationAlg = import_io_wallet_utils9.zItwSupportedSignatureAlg;
1112
+ var zKeyAttestationAlg = import_io_wallet_utils11.zItwSupportedSignatureAlg;
1119
1113
  var zKeyAttestationHeader = import_zod9.z.object({
1120
1114
  alg: zKeyAttestationAlg,
1121
1115
  kid: import_zod9.z.string(),
1122
- trust_chain: import_io_wallet_oauth24.zTrustChain.optional(),
1116
+ trust_chain: import_io_wallet_utils11.zTrustChain.optional(),
1123
1117
  typ: import_zod9.z.literal("key-attestation+jwt"),
1124
- x5c: import_io_wallet_oauth24.zCertificateChain
1118
+ x5c: import_io_wallet_utils11.zCertificateChain
1125
1119
  });
1126
1120
  var zKeyAttestationPayload = import_zod9.z.object({
1127
- attested_keys: import_zod9.z.array(import_io_wallet_oauth24.zJwk).nonempty(),
1121
+ attested_keys: import_zod9.z.array(import_io_wallet_utils11.zJwk).nonempty(),
1128
1122
  certification: import_zod9.z.string().optional(),
1129
1123
  exp: import_zod9.z.number(),
1130
1124
  iat: import_zod9.z.number(),
@@ -1139,19 +1133,19 @@ var keyAttestationTypeHeader = zKeyAttestationTypeHeader.value;
1139
1133
  // src/credential-request/verify-key-attestation-jwt.ts
1140
1134
  async function verifyKeyAttestationJwt(options) {
1141
1135
  try {
1142
- const { header, payload } = (0, import_io_wallet_oauth25.decodeJwt)({
1136
+ const { header, payload } = (0, import_io_wallet_utils12.decodeJwt)({
1143
1137
  errorMessagePrefix: "Error decoding key attestation JWT:",
1144
1138
  headerSchema: zKeyAttestationHeader,
1145
1139
  jwt: options.keyAttestationJwt,
1146
1140
  payloadSchema: zKeyAttestationPayload
1147
1141
  });
1148
- const { signer } = await (0, import_oauth23.verifyJwt)({
1142
+ const { signer } = await (0, import_io_wallet_utils12.verifyJwt)({
1149
1143
  compact: options.keyAttestationJwt,
1150
1144
  errorMessage: "Key attestation JWT verification failed.",
1151
1145
  header,
1152
1146
  now: options.now,
1153
1147
  payload,
1154
- signer: (0, import_oauth23.jwtSignerFromJwt)({ header, payload }),
1148
+ signer: (0, import_io_wallet_utils12.jwtSignerFromJwt)({ header, payload }),
1155
1149
  verifyJwtCallback: options.callbacks.verifyJwt
1156
1150
  });
1157
1151
  if (options.fetchStatusList) {
@@ -1168,7 +1162,7 @@ async function verifyKeyAttestationJwt(options) {
1168
1162
  }
1169
1163
  return { header, payload, signer };
1170
1164
  } catch (error) {
1171
- if (error instanceof VerifyKeyAttestationJwtError || error instanceof import_io_wallet_utils10.ValidationError || error instanceof import_oauth23.Oauth2JwtParseError) {
1165
+ if (error instanceof VerifyKeyAttestationJwtError || error instanceof import_io_wallet_utils12.ValidationError || error instanceof import_io_wallet_utils12.JwtParseError) {
1172
1166
  throw error;
1173
1167
  }
1174
1168
  throw new VerifyKeyAttestationJwtError(
@@ -1180,15 +1174,15 @@ async function verifyKeyAttestationJwt(options) {
1180
1174
 
1181
1175
  // src/credential-request/verify-credential-request-jwt-proof.ts
1182
1176
  async function isJwkInSet(options) {
1183
- const targetThumbprint = await (0, import_oauth24.calculateJwkThumbprint)({
1184
- hashAlgorithm: import_io_wallet_oauth26.HashAlgorithm.Sha256,
1177
+ const targetThumbprint = await (0, import_io_wallet_utils13.calculateJwkThumbprint)({
1178
+ hashAlgorithm: import_io_wallet_utils13.HashAlgorithm.Sha256,
1185
1179
  hashCallback: options.callbacks.hash,
1186
1180
  jwk: options.jwk
1187
1181
  });
1188
1182
  const thumbprints = await Promise.all(
1189
1183
  options.jwks.map(
1190
- (jwk) => (0, import_oauth24.calculateJwkThumbprint)({
1191
- hashAlgorithm: import_io_wallet_oauth26.HashAlgorithm.Sha256,
1184
+ (jwk) => (0, import_io_wallet_utils13.calculateJwkThumbprint)({
1185
+ hashAlgorithm: import_io_wallet_utils13.HashAlgorithm.Sha256,
1192
1186
  hashCallback: options.callbacks.hash,
1193
1187
  jwk
1194
1188
  })
@@ -1198,7 +1192,7 @@ async function isJwkInSet(options) {
1198
1192
  }
1199
1193
  function verifyProofJwtIatOrThrow(options) {
1200
1194
  try {
1201
- (0, import_io_wallet_utils11.verifyJwtIatOrThrow)({
1195
+ (0, import_io_wallet_utils13.verifyJwtIatOrThrow)({
1202
1196
  iat: options.payload.iat,
1203
1197
  now: options.now
1204
1198
  });
@@ -1212,14 +1206,14 @@ function verifyProofJwtIatOrThrow(options) {
1212
1206
  }
1213
1207
  }
1214
1208
  async function verifyProofV1_0(options) {
1215
- const { header, payload } = (0, import_io_wallet_oauth26.decodeJwt)({
1209
+ const { header, payload } = (0, import_io_wallet_utils13.decodeJwt)({
1216
1210
  errorMessagePrefix: "Error decoding credential request proof JWT:",
1217
1211
  headerSchema: zProofJwtHeaderV1_0,
1218
1212
  jwt: options.jwt,
1219
1213
  payloadSchema: zProofJwtPayload
1220
1214
  });
1221
1215
  verifyProofJwtIatOrThrow({ now: options.now, payload });
1222
- const { signer } = await (0, import_io_wallet_oauth26.verifyJwt)({
1216
+ const { signer } = await (0, import_io_wallet_utils13.verifyJwt)({
1223
1217
  compact: options.jwt,
1224
1218
  errorMessage: "Error verifying credential request proof jwt.",
1225
1219
  expectedAudience: options.credentialIssuer,
@@ -1228,20 +1222,20 @@ async function verifyProofV1_0(options) {
1228
1222
  header,
1229
1223
  now: options.now,
1230
1224
  payload,
1231
- signer: (0, import_oauth24.jwtSignerFromJwt)({ header, payload }),
1225
+ signer: (0, import_io_wallet_utils13.jwtSignerFromJwt)({ header, payload }),
1232
1226
  verifyJwtCallback: options.callbacks.verifyJwt
1233
1227
  });
1234
1228
  return { header, payload, signer };
1235
1229
  }
1236
1230
  async function verifyProofV1_3(options) {
1237
- const { header, payload } = (0, import_io_wallet_oauth26.decodeJwt)({
1231
+ const { header, payload } = (0, import_io_wallet_utils13.decodeJwt)({
1238
1232
  errorMessagePrefix: "Error decoding credential request proof JWT:",
1239
1233
  headerSchema: zProofJwtHeaderV1_3,
1240
1234
  jwt: options.jwt,
1241
1235
  payloadSchema: zProofJwtPayload
1242
1236
  });
1243
1237
  verifyProofJwtIatOrThrow({ now: options.now, payload });
1244
- const { signer } = await (0, import_io_wallet_oauth26.verifyJwt)({
1238
+ const { signer } = await (0, import_io_wallet_utils13.verifyJwt)({
1245
1239
  compact: options.jwt,
1246
1240
  errorMessage: "Error verifying credential request proof jwt.",
1247
1241
  expectedAudience: options.credentialIssuer,
@@ -1250,7 +1244,7 @@ async function verifyProofV1_3(options) {
1250
1244
  header,
1251
1245
  now: options.now,
1252
1246
  payload,
1253
- signer: (0, import_oauth24.jwtSignerFromJwt)({ header, payload }),
1247
+ signer: (0, import_io_wallet_utils13.jwtSignerFromJwt)({ header, payload }),
1254
1248
  verifyJwtCallback: options.callbacks.verifyJwt
1255
1249
  });
1256
1250
  if (options.trustedWalletProviderIssuers.length === 0) {
@@ -1283,10 +1277,10 @@ async function verifyProofV1_3(options) {
1283
1277
  }
1284
1278
  return { header, keyAttestation: keyAttestationResult, payload, signer };
1285
1279
  }
1286
- var dispatchVerifyProof = (0, import_io_wallet_utils11.createVersionDispatcher)({
1287
- [import_io_wallet_utils11.ItWalletSpecsVersion.V1_0]: (o) => verifyProofV1_0(o),
1288
- [import_io_wallet_utils11.ItWalletSpecsVersion.V1_3]: (o) => verifyProofV1_3(o),
1289
- [import_io_wallet_utils11.ItWalletSpecsVersion.V1_4]: (o) => verifyProofV1_3(o)
1280
+ var dispatchVerifyProof = (0, import_io_wallet_utils13.createVersionDispatcher)({
1281
+ [import_io_wallet_utils13.ItWalletSpecsVersion.V1_0]: (o) => verifyProofV1_0(o),
1282
+ [import_io_wallet_utils13.ItWalletSpecsVersion.V1_3]: (o) => verifyProofV1_3(o),
1283
+ [import_io_wallet_utils13.ItWalletSpecsVersion.V1_4]: (o) => verifyProofV1_3(o)
1290
1284
  });
1291
1285
  async function verifyCredentialRequestJwtProof(options) {
1292
1286
  try {
@@ -1298,7 +1292,7 @@ async function verifyCredentialRequestJwtProof(options) {
1298
1292
  }
1299
1293
  return await dispatchVerifyProof({ ...options, now });
1300
1294
  } catch (error) {
1301
- if (error instanceof VerifyCredentialRequestJwtProofError || error instanceof VerifyKeyAttestationJwtError || error instanceof import_io_wallet_utils11.ItWalletSpecsVersionError || error instanceof import_io_wallet_utils11.ValidationError || error instanceof import_io_wallet_oauth26.Oauth2JwtParseError) {
1295
+ if (error instanceof VerifyCredentialRequestJwtProofError || error instanceof VerifyKeyAttestationJwtError || error instanceof import_io_wallet_utils13.ItWalletSpecsVersionError || error instanceof import_io_wallet_utils13.ValidationError || error instanceof import_io_wallet_utils13.JwtParseError) {
1302
1296
  throw error;
1303
1297
  }
1304
1298
  throw new VerifyCredentialRequestJwtProofError(
@@ -1309,10 +1303,10 @@ async function verifyCredentialRequestJwtProof(options) {
1309
1303
  }
1310
1304
 
1311
1305
  // src/credential-response/create-credential-response.ts
1312
- var import_io_wallet_utils14 = require("@pagopa/io-wallet-utils");
1306
+ var import_io_wallet_utils16 = require("@pagopa/io-wallet-utils");
1313
1307
 
1314
1308
  // src/credential-response/v1.0/create-credential-response.ts
1315
- var import_io_wallet_utils12 = require("@pagopa/io-wallet-utils");
1309
+ var import_io_wallet_utils14 = require("@pagopa/io-wallet-utils");
1316
1310
 
1317
1311
  // src/credential-response/v1.0/z-credential-response.ts
1318
1312
  var import_zod11 = require("zod");
@@ -1346,7 +1340,7 @@ var zCredentialResponseV1_0 = import_zod11.z.union([
1346
1340
  // src/credential-response/v1.0/create-credential-response.ts
1347
1341
  function createCredentialResponseV1_0(flow) {
1348
1342
  if ("credentials" in flow) {
1349
- return (0, import_io_wallet_utils12.parseWithErrorHandling)(
1343
+ return (0, import_io_wallet_utils14.parseWithErrorHandling)(
1350
1344
  zCredentialResponseV1_0,
1351
1345
  {
1352
1346
  credentials: flow.credentials,
@@ -1357,7 +1351,7 @@ function createCredentialResponseV1_0(flow) {
1357
1351
  "Invalid credential response for ItWalletSpecsVersion 1.0"
1358
1352
  );
1359
1353
  }
1360
- return (0, import_io_wallet_utils12.parseWithErrorHandling)(
1354
+ return (0, import_io_wallet_utils14.parseWithErrorHandling)(
1361
1355
  zCredentialResponseV1_0,
1362
1356
  {
1363
1357
  lead_time: flow.leadTime,
@@ -1368,7 +1362,7 @@ function createCredentialResponseV1_0(flow) {
1368
1362
  }
1369
1363
 
1370
1364
  // src/credential-response/v1.3/create-credential-response.ts
1371
- var import_io_wallet_utils13 = require("@pagopa/io-wallet-utils");
1365
+ var import_io_wallet_utils15 = require("@pagopa/io-wallet-utils");
1372
1366
 
1373
1367
  // src/credential-response/v1.3/z-credential-response.ts
1374
1368
  var import_zod12 = require("zod");
@@ -1386,7 +1380,7 @@ var zCredentialResponseV1_3 = import_zod12.z.union([
1386
1380
  // src/credential-response/v1.3/create-credential-response.ts
1387
1381
  function createCredentialResponseV1_3(flow) {
1388
1382
  if ("credentials" in flow) {
1389
- return (0, import_io_wallet_utils13.parseWithErrorHandling)(
1383
+ return (0, import_io_wallet_utils15.parseWithErrorHandling)(
1390
1384
  zCredentialResponseV1_3,
1391
1385
  {
1392
1386
  credentials: flow.credentials,
@@ -1397,7 +1391,7 @@ function createCredentialResponseV1_3(flow) {
1397
1391
  "Invalid credential response for ItWalletSpecsVersion 1.3"
1398
1392
  );
1399
1393
  }
1400
- return (0, import_io_wallet_utils13.parseWithErrorHandling)(
1394
+ return (0, import_io_wallet_utils15.parseWithErrorHandling)(
1401
1395
  zCredentialResponseV1_3,
1402
1396
  {
1403
1397
  interval: flow.interval,
@@ -1408,14 +1402,14 @@ function createCredentialResponseV1_3(flow) {
1408
1402
  }
1409
1403
 
1410
1404
  // src/credential-response/create-credential-response.ts
1411
- var dispatchBuildVersionedResponse = (0, import_io_wallet_utils14.createVersionDispatcher)({
1412
- [import_io_wallet_utils14.ItWalletSpecsVersion.V1_0]: (o) => createCredentialResponseV1_0(
1405
+ var dispatchBuildVersionedResponse = (0, import_io_wallet_utils16.createVersionDispatcher)({
1406
+ [import_io_wallet_utils16.ItWalletSpecsVersion.V1_0]: (o) => createCredentialResponseV1_0(
1413
1407
  o.flow
1414
1408
  ),
1415
- [import_io_wallet_utils14.ItWalletSpecsVersion.V1_3]: (o) => createCredentialResponseV1_3(
1409
+ [import_io_wallet_utils16.ItWalletSpecsVersion.V1_3]: (o) => createCredentialResponseV1_3(
1416
1410
  o.flow
1417
1411
  ),
1418
- [import_io_wallet_utils14.ItWalletSpecsVersion.V1_4]: (o) => createCredentialResponseV1_3(
1412
+ [import_io_wallet_utils16.ItWalletSpecsVersion.V1_4]: (o) => createCredentialResponseV1_3(
1419
1413
  o.flow
1420
1414
  // V1_4 reuses V1_3 credential response schema — no breaking changes between versions.
1421
1415
  // Verified against compare/1.3.3...1.4.1: credential response parameters identical.
@@ -1440,7 +1434,7 @@ async function createCredentialResponse(options) {
1440
1434
  }
1441
1435
  return { credentialResponse, credentialResponseJwt };
1442
1436
  } catch (error) {
1443
- if (error instanceof import_io_wallet_utils14.ValidationError || error instanceof Oid4vciError) {
1437
+ if (error instanceof import_io_wallet_utils16.ValidationError || error instanceof Oid4vciError) {
1444
1438
  throw error;
1445
1439
  }
1446
1440
  throw new CreateCredentialResponseError(
@@ -1464,49 +1458,49 @@ async function encryptResponse(credentialResponse, credentialResponseEncryption,
1464
1458
  }
1465
1459
 
1466
1460
  // src/credential-response/fetch-credential-response.ts
1467
- var import_io_wallet_utils15 = require("@pagopa/io-wallet-utils");
1461
+ var import_io_wallet_utils18 = require("@pagopa/io-wallet-utils");
1468
1462
 
1469
1463
  // src/credential-response/z-credential-response.ts
1470
- var import_io_wallet_oauth27 = require("@pagopa/io-wallet-oauth2");
1464
+ var import_io_wallet_utils17 = require("@pagopa/io-wallet-utils");
1471
1465
  var import_zod13 = require("zod");
1472
1466
  var zCredentialResponseEncryption = import_zod13.z.looseObject({
1473
- alg: import_io_wallet_oauth27.zAlgValueNotNone,
1467
+ alg: import_io_wallet_utils17.zAlgValueNotNone,
1474
1468
  enc: import_zod13.z.string(),
1475
- jwk: import_io_wallet_oauth27.zJwk
1469
+ jwk: import_io_wallet_utils17.zJwk
1476
1470
  });
1477
1471
 
1478
1472
  // src/credential-response/fetch-credential-response.ts
1479
1473
  async function fetchCredentialResponse(options) {
1480
1474
  try {
1481
- const fetch = (0, import_io_wallet_utils15.createFetcher)(options.callbacks.fetch);
1475
+ const fetch = (0, import_io_wallet_utils18.createFetcher)(options.callbacks.fetch);
1482
1476
  const credentialResponse = await fetch(options.credentialEndpoint, {
1483
1477
  body: JSON.stringify(options.credentialRequest),
1484
1478
  headers: {
1485
- [import_io_wallet_utils15.HEADERS.AUTHORIZATION]: `DPoP ${options.accessToken}`,
1486
- [import_io_wallet_utils15.HEADERS.CONTENT_TYPE]: import_io_wallet_utils15.CONTENT_TYPES.JSON,
1487
- [import_io_wallet_utils15.HEADERS.DPOP]: options.dPoP
1479
+ [import_io_wallet_utils18.HEADERS.AUTHORIZATION]: `DPoP ${options.accessToken}`,
1480
+ [import_io_wallet_utils18.HEADERS.CONTENT_TYPE]: import_io_wallet_utils18.CONTENT_TYPES.JSON,
1481
+ [import_io_wallet_utils18.HEADERS.DPOP]: options.dPoP
1488
1482
  },
1489
1483
  method: "POST"
1490
1484
  });
1491
- await (0, import_io_wallet_utils15.hasStatusOrThrow)(
1485
+ await (0, import_io_wallet_utils18.hasStatusOrThrow)(
1492
1486
  [200, 202],
1493
- import_io_wallet_utils15.UnexpectedStatusCodeError
1487
+ import_io_wallet_utils18.UnexpectedStatusCodeError
1494
1488
  )(credentialResponse);
1495
1489
  const credentialResponseJson = await credentialResponse.json();
1496
1490
  if ("proof" in options.credentialRequest) {
1497
- return (0, import_io_wallet_utils15.parseWithErrorHandling)(
1491
+ return (0, import_io_wallet_utils18.parseWithErrorHandling)(
1498
1492
  zCredentialResponseV1_0,
1499
1493
  credentialResponseJson,
1500
1494
  `Failed to parse credential response (v1.0)`
1501
1495
  );
1502
1496
  }
1503
- return (0, import_io_wallet_utils15.parseWithErrorHandling)(
1497
+ return (0, import_io_wallet_utils18.parseWithErrorHandling)(
1504
1498
  zCredentialResponseV1_3,
1505
1499
  credentialResponseJson,
1506
1500
  `Failed to parse credential response (v1.3)`
1507
1501
  );
1508
1502
  } catch (error) {
1509
- if (error instanceof import_io_wallet_utils15.UnexpectedStatusCodeError || error instanceof import_io_wallet_utils15.ValidationError) {
1503
+ if (error instanceof import_io_wallet_utils18.UnexpectedStatusCodeError || error instanceof import_io_wallet_utils18.ValidationError) {
1510
1504
  throw error;
1511
1505
  }
1512
1506
  throw new FetchCredentialResponseError(
@@ -1516,9 +1510,8 @@ async function fetchCredentialResponse(options) {
1516
1510
  }
1517
1511
 
1518
1512
  // src/metadata/fetch-metadata.ts
1519
- var import_io_wallet_oauth28 = require("@pagopa/io-wallet-oauth2");
1520
1513
  var import_io_wallet_oid_federation3 = require("@pagopa/io-wallet-oid-federation");
1521
- var import_io_wallet_utils16 = require("@pagopa/io-wallet-utils");
1514
+ var import_io_wallet_utils19 = require("@pagopa/io-wallet-utils");
1522
1515
  var import_zod15 = __toESM(require("zod"));
1523
1516
 
1524
1517
  // src/metadata/z-metadata-response.ts
@@ -1567,7 +1560,7 @@ async function tryFederationDiscovery(fetch, baseUrl, verifyJwt4) {
1567
1560
  return void 0;
1568
1561
  }
1569
1562
  const entityStatement = await response.text();
1570
- const { header, payload } = (0, import_io_wallet_oauth28.decodeJwt)({
1563
+ const { header, payload } = (0, import_io_wallet_utils19.decodeJwt)({
1571
1564
  errorMessagePrefix: "Error decoding entity statement JWT:",
1572
1565
  jwt: entityStatement,
1573
1566
  payloadSchema: import_io_wallet_oid_federation3.itWalletEntityStatementClaimsSchema
@@ -1584,7 +1577,7 @@ async function tryFederationDiscovery(fetch, baseUrl, verifyJwt4) {
1584
1577
  payload
1585
1578
  });
1586
1579
  if (!result.verified) {
1587
- throw new import_io_wallet_utils16.ValidationError(
1580
+ throw new import_io_wallet_utils19.ValidationError(
1588
1581
  "Entity statement signature verification failed"
1589
1582
  );
1590
1583
  }
@@ -1595,7 +1588,7 @@ async function tryFederationDiscovery(fetch, baseUrl, verifyJwt4) {
1595
1588
  openid_federation_claims: payload
1596
1589
  };
1597
1590
  } catch (error) {
1598
- if (error instanceof import_io_wallet_utils16.ValidationError) {
1591
+ if (error instanceof import_io_wallet_utils19.ValidationError) {
1599
1592
  throw error;
1600
1593
  }
1601
1594
  return void 0;
@@ -1618,7 +1611,7 @@ async function applyFederationAuthorizationServerSelection(fetch, federationResu
1618
1611
  }
1619
1612
  const parsedSelectedAuthorizationServer = import_zod15.default.url().safeParse(selectedAuthorizationServer);
1620
1613
  if (!parsedSelectedAuthorizationServer.success || !parsedSelectedAuthorizationServer.data.startsWith("https://")) {
1621
- throw new import_io_wallet_utils16.ValidationError(
1614
+ throw new import_io_wallet_utils19.ValidationError(
1622
1615
  "selected authorization server is not a valid HTTPS URL"
1623
1616
  );
1624
1617
  }
@@ -1628,7 +1621,7 @@ async function applyFederationAuthorizationServerSelection(fetch, federationResu
1628
1621
  verifyJwt4
1629
1622
  );
1630
1623
  if (!authorizationServerResult) {
1631
- throw new import_io_wallet_utils16.ValidationError(
1624
+ throw new import_io_wallet_utils19.ValidationError(
1632
1625
  `Federation discovery did not yield OpenID Federation metadata for authorization server '${selectedAuthorizationServer}'`
1633
1626
  );
1634
1627
  }
@@ -1643,8 +1636,8 @@ async function fallbackDiscovery(fetch, baseUrl, authorizationServer) {
1643
1636
  ensureTrailingSlash(baseUrl)
1644
1637
  ).toString();
1645
1638
  const issuerResponse = await fetch(issuerUrl);
1646
- await (0, import_io_wallet_utils16.hasStatusOrThrow)(200, import_io_wallet_utils16.UnexpectedStatusCodeError)(issuerResponse);
1647
- const issuerJson = (0, import_io_wallet_utils16.parseWithErrorHandling)(
1639
+ await (0, import_io_wallet_utils19.hasStatusOrThrow)(200, import_io_wallet_utils19.UnexpectedStatusCodeError)(issuerResponse);
1640
+ const issuerJson = (0, import_io_wallet_utils19.parseWithErrorHandling)(
1648
1641
  zPartialIssuerMetadata,
1649
1642
  await issuerResponse.json(),
1650
1643
  "Failed to parse credential issuer metadata"
@@ -1656,7 +1649,7 @@ async function fallbackDiscovery(fetch, baseUrl, authorizationServer) {
1656
1649
  const selectedAuthorizationServer = authorizationServer ?? authorizationServers[0];
1657
1650
  const parsedUrl = import_zod15.default.url().safeParse(selectedAuthorizationServer);
1658
1651
  if (!parsedUrl.success || !parsedUrl.data.startsWith("https://")) {
1659
- throw new import_io_wallet_utils16.ValidationError(
1652
+ throw new import_io_wallet_utils19.ValidationError(
1660
1653
  "selected authorization server is not a valid HTTPS URL"
1661
1654
  );
1662
1655
  }
@@ -1665,7 +1658,7 @@ async function fallbackDiscovery(fetch, baseUrl, authorizationServer) {
1665
1658
  ensureTrailingSlash(parsedUrl.data)
1666
1659
  ).toString();
1667
1660
  const authServerResponse = await fetch(authServerUrl);
1668
- await (0, import_io_wallet_utils16.hasStatusOrThrow)(200, import_io_wallet_utils16.UnexpectedStatusCodeError)(authServerResponse);
1661
+ await (0, import_io_wallet_utils19.hasStatusOrThrow)(200, import_io_wallet_utils19.UnexpectedStatusCodeError)(authServerResponse);
1669
1662
  oauthAuthorizationServer = await authServerResponse.json();
1670
1663
  } else {
1671
1664
  oauthAuthorizationServer = issuerJson;
@@ -1679,7 +1672,7 @@ async function fallbackDiscovery(fetch, baseUrl, authorizationServer) {
1679
1672
  };
1680
1673
  }
1681
1674
  var fetchMetadataWithFallbackDiscovery = async (options) => {
1682
- const fetch = (0, import_io_wallet_utils16.createFetcher)(options.callbacks.fetch);
1675
+ const fetch = (0, import_io_wallet_utils19.createFetcher)(options.callbacks.fetch);
1683
1676
  const federationResult = await tryFederationDiscovery(
1684
1677
  fetch,
1685
1678
  options.credentialIssuerUrl,
@@ -1698,7 +1691,7 @@ var fetchMetadataWithFallbackDiscovery = async (options) => {
1698
1691
  return raw;
1699
1692
  };
1700
1693
  async function fetchMetadataV1_0(options) {
1701
- const fetch = (0, import_io_wallet_utils16.createFetcher)(options.callbacks.fetch);
1694
+ const fetch = (0, import_io_wallet_utils19.createFetcher)(options.callbacks.fetch);
1702
1695
  const federationResult = await tryFederationDiscovery(
1703
1696
  fetch,
1704
1697
  options.credentialIssuerUrl,
@@ -1709,7 +1702,7 @@ async function fetchMetadataV1_0(options) {
1709
1702
  `Federation discovery failed for IT Wallet v1.0; no fallback available for credentialIssuerUrl ${options.credentialIssuerUrl}`
1710
1703
  );
1711
1704
  }
1712
- return (0, import_io_wallet_utils16.parseWithErrorHandling)(
1705
+ return (0, import_io_wallet_utils19.parseWithErrorHandling)(
1713
1706
  zMetadataResponseV1_0,
1714
1707
  federationResult,
1715
1708
  "Failed to parse v1.0 metadata response"
@@ -1717,7 +1710,7 @@ async function fetchMetadataV1_0(options) {
1717
1710
  }
1718
1711
  async function fetchMetadataV1_3(options) {
1719
1712
  const raw = await fetchMetadataWithFallbackDiscovery(options);
1720
- return (0, import_io_wallet_utils16.parseWithErrorHandling)(
1713
+ return (0, import_io_wallet_utils19.parseWithErrorHandling)(
1721
1714
  zMetadataResponseV1_3,
1722
1715
  raw,
1723
1716
  "Failed to parse v1.3 metadata response"
@@ -1725,28 +1718,28 @@ async function fetchMetadataV1_3(options) {
1725
1718
  }
1726
1719
  async function fetchMetadataV1_4(options) {
1727
1720
  const raw = await fetchMetadataWithFallbackDiscovery(options);
1728
- return (0, import_io_wallet_utils16.parseWithErrorHandling)(
1721
+ return (0, import_io_wallet_utils19.parseWithErrorHandling)(
1729
1722
  zMetadataResponseV1_4,
1730
1723
  raw,
1731
1724
  "Failed to parse v1.4 metadata response"
1732
1725
  );
1733
1726
  }
1734
- var dispatchFetchMetadata = (0, import_io_wallet_utils16.createVersionDispatcher)({
1735
- [import_io_wallet_utils16.ItWalletSpecsVersion.V1_0]: (o) => fetchMetadataV1_0(o),
1736
- [import_io_wallet_utils16.ItWalletSpecsVersion.V1_3]: (o) => fetchMetadataV1_3(o),
1737
- [import_io_wallet_utils16.ItWalletSpecsVersion.V1_4]: (o) => fetchMetadataV1_4(o)
1727
+ var dispatchFetchMetadata = (0, import_io_wallet_utils19.createVersionDispatcher)({
1728
+ [import_io_wallet_utils19.ItWalletSpecsVersion.V1_0]: (o) => fetchMetadataV1_0(o),
1729
+ [import_io_wallet_utils19.ItWalletSpecsVersion.V1_3]: (o) => fetchMetadataV1_3(o),
1730
+ [import_io_wallet_utils19.ItWalletSpecsVersion.V1_4]: (o) => fetchMetadataV1_4(o)
1738
1731
  });
1739
1732
  async function fetchMetadata(options) {
1740
1733
  try {
1741
1734
  const urlValidation = import_zod15.default.url().safeParse(options.credentialIssuerUrl);
1742
1735
  if (!urlValidation.success || !urlValidation.data.startsWith("https://")) {
1743
- throw new import_io_wallet_utils16.ValidationError(
1736
+ throw new import_io_wallet_utils19.ValidationError(
1744
1737
  "credentialIssuerUrl must be a valid HTTPS URL"
1745
1738
  );
1746
1739
  }
1747
1740
  return await dispatchFetchMetadata(options);
1748
1741
  } catch (error) {
1749
- if (error instanceof import_io_wallet_utils16.UnexpectedStatusCodeError || error instanceof import_io_wallet_utils16.ValidationError || error instanceof import_io_wallet_utils16.ItWalletSpecsVersionError || error instanceof CredentialOfferError || error instanceof FetchMetadataError) {
1742
+ if (error instanceof import_io_wallet_utils19.UnexpectedStatusCodeError || error instanceof import_io_wallet_utils19.ValidationError || error instanceof import_io_wallet_utils19.ItWalletSpecsVersionError || error instanceof CredentialOfferError || error instanceof FetchMetadataError) {
1750
1743
  throw error;
1751
1744
  }
1752
1745
  throw new FetchMetadataError("Unexpected error during metadata fetch", {
@@ -1756,8 +1749,8 @@ async function fetchMetadata(options) {
1756
1749
  }
1757
1750
 
1758
1751
  // src/wallet-provider/WalletProvider.ts
1759
- var import_io_wallet_oauth29 = require("@pagopa/io-wallet-oauth2");
1760
- var import_io_wallet_utils17 = require("@pagopa/io-wallet-utils");
1752
+ var import_io_wallet_oauth23 = require("@pagopa/io-wallet-oauth2");
1753
+ var import_io_wallet_utils20 = require("@pagopa/io-wallet-utils");
1761
1754
  function assertV1_0Options(options) {
1762
1755
  if (options.signer.method !== "federation") {
1763
1756
  throw new WalletProviderError(
@@ -1815,7 +1808,7 @@ var WalletProvider = class {
1815
1808
  const { signJwt } = options.callbacks;
1816
1809
  const now = /* @__PURE__ */ new Date();
1817
1810
  const issuedAt = options.issuedAt ?? now;
1818
- const expiresAt = options.expiresAt ?? (0, import_io_wallet_utils17.addSecondsToDate)(now, 3600 * 24 * 360);
1811
+ const expiresAt = options.expiresAt ?? (0, import_io_wallet_utils20.addSecondsToDate)(now, 3600 * 24 * 360);
1819
1812
  const header = {
1820
1813
  alg: options.signer.alg,
1821
1814
  kid: options.signer.kid,
@@ -1825,8 +1818,8 @@ var WalletProvider = class {
1825
1818
  };
1826
1819
  const payload = {
1827
1820
  attested_keys: options.attestedKeys,
1828
- exp: (0, import_io_wallet_utils17.dateToSeconds)(expiresAt),
1829
- iat: (0, import_io_wallet_utils17.dateToSeconds)(issuedAt),
1821
+ exp: (0, import_io_wallet_utils20.dateToSeconds)(expiresAt),
1822
+ iat: (0, import_io_wallet_utils20.dateToSeconds)(issuedAt),
1830
1823
  iss: options.issuer,
1831
1824
  key_storage: options.keyStorage,
1832
1825
  status: options.status,
@@ -1908,10 +1901,10 @@ var WalletProvider = class {
1908
1901
  * });
1909
1902
  */
1910
1903
  async createItWalletAttestationJwt(options) {
1911
- return (0, import_io_wallet_utils17.dispatchByVersion)(this.specVersion, {
1912
- [import_io_wallet_utils17.ItWalletSpecsVersion.V1_0]: () => {
1904
+ return (0, import_io_wallet_utils20.dispatchByVersion)(this.specVersion, {
1905
+ [import_io_wallet_utils20.ItWalletSpecsVersion.V1_0]: () => {
1913
1906
  assertV1_0Options(options);
1914
- return (0, import_io_wallet_oauth29.createWalletAttestationJwtV1_0)({
1907
+ return (0, import_io_wallet_oauth23.createWalletAttestationJwtV1_0)({
1915
1908
  authenticatorAssuranceLevel: options.authenticatorAssuranceLevel,
1916
1909
  callbacks: options.callbacks,
1917
1910
  dpopJwkPublic: options.dpopJwkPublic,
@@ -1922,9 +1915,9 @@ var WalletProvider = class {
1922
1915
  walletName: options.walletName
1923
1916
  });
1924
1917
  },
1925
- [import_io_wallet_utils17.ItWalletSpecsVersion.V1_3]: () => {
1918
+ [import_io_wallet_utils20.ItWalletSpecsVersion.V1_3]: () => {
1926
1919
  assertV1_3Options(options);
1927
- return (0, import_io_wallet_oauth29.createWalletAttestationJwtV1_3)({
1920
+ return (0, import_io_wallet_oauth23.createWalletAttestationJwtV1_3)({
1928
1921
  callbacks: options.callbacks,
1929
1922
  dpopJwkPublic: options.dpopJwkPublic,
1930
1923
  expiresAt: options.expiresAt,
@@ -1936,9 +1929,9 @@ var WalletProvider = class {
1936
1929
  walletName: options.walletName
1937
1930
  });
1938
1931
  },
1939
- [import_io_wallet_utils17.ItWalletSpecsVersion.V1_4]: () => {
1932
+ [import_io_wallet_utils20.ItWalletSpecsVersion.V1_4]: () => {
1940
1933
  assertV1_4Options(options);
1941
- return (0, import_io_wallet_oauth29.createWalletAttestationJwtV1_4)({
1934
+ return (0, import_io_wallet_oauth23.createWalletAttestationJwtV1_4)({
1942
1935
  callbacks: options.callbacks,
1943
1936
  dpopJwkPublic: options.dpopJwkPublic,
1944
1937
  expiresAt: options.expiresAt,