@pagopa/io-wallet-oid4vci 1.5.7 → 2.0.0-apt

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
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
+ CREDENTIAL_OFFER_GRANTS: () => CREDENTIAL_OFFER_GRANTS,
33
34
  CreateCredentialResponseError: () => CreateCredentialResponseError,
34
35
  CredentialAuthorizationHeaderError: () => CredentialAuthorizationHeaderError,
35
36
  CredentialOfferError: () => CredentialOfferError,
@@ -95,7 +96,7 @@ module.exports = __toCommonJS(index_exports);
95
96
  // src/authorization-response/complete-authorization.ts
96
97
  var import_io_wallet_oauth2 = require("@pagopa/io-wallet-oauth2");
97
98
  var import_io_wallet_oid4vp = require("@pagopa/io-wallet-oid4vp");
98
- var import_io_wallet_utils = require("@pagopa/io-wallet-utils");
99
+ var import_io_wallet_utils2 = require("@pagopa/io-wallet-utils");
99
100
 
100
101
  // src/errors.ts
101
102
  var Oid4vciError = class extends Error {
@@ -184,7 +185,7 @@ var CredentialAuthorizationHeaderError = class extends Oid4vciError {
184
185
  };
185
186
 
186
187
  // src/authorization-response/verify-authorization-response.ts
187
- var import_oauth2 = require("@openid4vc/oauth2");
188
+ var import_io_wallet_utils = require("@pagopa/io-wallet-utils");
188
189
  async function verifyAuthorizationResponse(options) {
189
190
  if (options.authorizationResponse.iss !== options.iss)
190
191
  throw new Oid4vciError(
@@ -199,12 +200,12 @@ async function verifyAuthorizationResponse(options) {
199
200
  async function verifyAuthorizationResponseFormPostJWT(options) {
200
201
  try {
201
202
  const decodedJwt = options.authorizationResponseDecoded;
202
- await (0, import_oauth2.verifyJwt)({
203
+ await (0, import_io_wallet_utils.verifyJwt)({
203
204
  compact: options.authorizationResponseCompact,
204
205
  errorMessage: "Error verifying JWT signature",
205
206
  header: decodedJwt.header,
206
207
  payload: decodedJwt.payload,
207
- signer: options.signer ?? (0, import_oauth2.jwtSignerFromJwt)({
208
+ signer: options.signer ?? (0, import_io_wallet_utils.jwtSignerFromJwt)({
208
209
  header: decodedJwt.header,
209
210
  payload: decodedJwt.payload
210
211
  }),
@@ -234,18 +235,18 @@ var zAuthorizationResponse = import_zod.default.object({
234
235
  // src/authorization-response/complete-authorization.ts
235
236
  async function completeAuthorization(options) {
236
237
  try {
237
- const fetch = (0, import_io_wallet_utils.createFetcher)(options.callbacks.fetch);
238
+ const fetch = (0, import_io_wallet_utils2.createFetcher)(options.callbacks.fetch);
238
239
  const authorizationResponseResult = await fetch(options.response_uri);
239
- await (0, import_io_wallet_utils.hasStatusOrThrow)(
240
+ await (0, import_io_wallet_utils2.hasStatusOrThrow)(
240
241
  200,
241
- import_io_wallet_utils.UnexpectedStatusCodeError
242
+ import_io_wallet_utils2.UnexpectedStatusCodeError
242
243
  )(authorizationResponseResult);
243
244
  return await (0, import_io_wallet_oauth2.getJwtFromFormPost)({
244
245
  formData: await authorizationResponseResult.text(),
245
246
  schema: zAuthorizationResponse
246
247
  });
247
248
  } catch (error) {
248
- if (error instanceof import_io_wallet_utils.UnexpectedStatusCodeError || error instanceof import_io_wallet_utils.ValidationError || error instanceof Oid4vciError) {
249
+ if (error instanceof import_io_wallet_utils2.UnexpectedStatusCodeError || error instanceof import_io_wallet_utils2.ValidationError || error instanceof Oid4vciError) {
249
250
  throw error;
250
251
  }
251
252
  throw new Oid4vciError(
@@ -276,7 +277,7 @@ async function sendAuthorizationResponseAndExtractCode(options) {
276
277
  state: options.state
277
278
  });
278
279
  } catch (error) {
279
- if (error instanceof import_io_wallet_utils.UnexpectedStatusCodeError || error instanceof import_io_wallet_utils.ValidationError || error instanceof Oid4vciError) {
280
+ if (error instanceof import_io_wallet_utils2.UnexpectedStatusCodeError || error instanceof import_io_wallet_utils2.ValidationError || error instanceof Oid4vciError) {
280
281
  throw error;
281
282
  }
282
283
  throw new Oid4vciError(
@@ -285,8 +286,93 @@ async function sendAuthorizationResponseAndExtractCode(options) {
285
286
  }
286
287
  }
287
288
 
289
+ // src/credential-offer/APTITUDE/z-credential-offer.ts
290
+ var import_zod2 = require("zod");
291
+ var zTxCodePreAuthorizedCodeGrantAPTITUDE = import_zod2.z.object({
292
+ /**
293
+ * OPTIONAL. String containing guidance for the Holder
294
+ * of the Wallet on how to obtain the Transaction Code.
295
+ */
296
+ description: import_zod2.z.string().max(300).optional(),
297
+ /**
298
+ * OPTIONAL. String specifying the input character set.
299
+ * Possible values are numeric (only digits) and text (any characters).
300
+ * The default is numeric.
301
+ */
302
+ input_mode: import_zod2.z.enum(["numeric", "digit"]).optional(),
303
+ /**
304
+ * OPTIONAL. Integer specifying the length of the Transaction Code.
305
+ */
306
+ length: import_zod2.z.number().optional()
307
+ });
308
+ var zAuthorizationCodeGrantAPTITUDE = import_zod2.z.object({
309
+ /**
310
+ * CONDITIONALLY REQUIRED. HTTPS URL of the Authorization Server.
311
+ * REQUIRED only when the Credential Issuer uses multiple Authorization Servers.
312
+ * If present, MUST match one of the authorization_servers in the Credential Issuer metadata.
313
+ */
314
+ authorization_server: import_zod2.z.url().optional(),
315
+ /**
316
+ * OPTIONAL. String value representing the issuer state.
317
+ * Used to correlate the authorization request with the credential offer.
318
+ */
319
+ issuer_state: import_zod2.z.string().optional()
320
+ });
321
+ var zPreAuthorizedCodeGrantAPTITUDE = import_zod2.z.object({
322
+ /**
323
+ * CONDITIONALLY REQUIRED. HTTPS URL of the Authorization Server.
324
+ * REQUIRED only when the Credential Issuer uses multiple Authorization Servers.
325
+ * If present, MUST match one of the authorization_servers in the Credential Issuer metadata.
326
+ */
327
+ authorization_server: import_zod2.z.url().optional(),
328
+ /**
329
+ * REQUIRED. The code representing the Credential Issuer's authorization for
330
+ * the Wallet to obtain Credentials of a certain type
331
+ */
332
+ "pre-authorized_code": import_zod2.z.string(),
333
+ /**
334
+ * OPTIONAL. Object indicating that a Transaction Code is required if present, even if empty.
335
+ * It describes the requirements for a Transaction Code, which the Authorization Server expects
336
+ * the End-User to present along with the Token Request in a Pre-Authorized Code Flow.
337
+ * If the Authorization Server does not expect a Transaction Code, this object is absent;
338
+ */
339
+ tx_code: zTxCodePreAuthorizedCodeGrantAPTITUDE.optional()
340
+ });
341
+ var zCredentialOfferGrantsAPTITUDE = import_zod2.z.object({
342
+ /**
343
+ * OPTIONAL. Authorization Code grant details.
344
+ */
345
+ authorization_code: zAuthorizationCodeGrantAPTITUDE.optional(),
346
+ /**
347
+ * OPTIONAL. Pre-Authorized Code grant details.
348
+ */
349
+ "urn:ietf:params:oauth:grant-type:pre-authorized_code": zPreAuthorizedCodeGrantAPTITUDE.optional()
350
+ });
351
+ var zCredentialOfferAPTITUDE = import_zod2.z.object({
352
+ /**
353
+ * REQUIRED. Array of credential configuration identifiers.
354
+ * References the types of credentials offered as defined in the Credential Issuer metadata.
355
+ */
356
+ credential_configuration_ids: import_zod2.z.array(import_zod2.z.string()).min(1),
357
+ /**
358
+ * REQUIRED. HTTPS URL of the Credential Issuer.
359
+ * The Credential Issuer from which the wallet will request credentials.
360
+ */
361
+ credential_issuer: import_zod2.z.url(),
362
+ /**
363
+ * REQUIRED. Grant information for the credential offer.
364
+ * IT-Wallet v1.4 requires authorization_code or pre-auhorized code grant.
365
+ */
366
+ grants: zCredentialOfferGrantsAPTITUDE
367
+ });
368
+ var CREDENTIAL_OFFER_GRANTS = /* @__PURE__ */ ((CREDENTIAL_OFFER_GRANTS2) => {
369
+ CREDENTIAL_OFFER_GRANTS2["AUTHORIZATION_CODE"] = "authorization_code";
370
+ CREDENTIAL_OFFER_GRANTS2["PREAUTHORIZED_CODE"] = "urn:ietf:params:oauth:grant-type:pre-authorized_code";
371
+ return CREDENTIAL_OFFER_GRANTS2;
372
+ })(CREDENTIAL_OFFER_GRANTS || {});
373
+
288
374
  // src/credential-offer/extract-grant-details.ts
289
- var import_io_wallet_utils2 = require("@pagopa/io-wallet-utils");
375
+ var import_io_wallet_utils3 = require("@pagopa/io-wallet-utils");
290
376
  function requireAuthorizationCodeGrant(credentialOffer) {
291
377
  if (!credentialOffer.grants) {
292
378
  throw new CredentialOfferError("No grants found in credential offer");
@@ -297,83 +383,120 @@ function requireAuthorizationCodeGrant(credentialOffer) {
297
383
  }
298
384
  return authCodeGrant;
299
385
  }
386
+ function requireAuthorizationCodeOrPreAuthorizedCodeGrant(credentialOffer) {
387
+ if (!credentialOffer.grants) {
388
+ throw new CredentialOfferError("No grants found in credential offer");
389
+ }
390
+ const grants = credentialOffer.grants;
391
+ if (!grants["authorization_code" /* AUTHORIZATION_CODE */] && !grants["urn:ietf:params:oauth:grant-type:pre-authorized_code" /* PREAUTHORIZED_CODE */]) {
392
+ throw new CredentialOfferError(
393
+ "either one of authorization_code or pre-authorized code grant is required"
394
+ );
395
+ }
396
+ return grants;
397
+ }
300
398
  function extractGrantDetailsV1_3(options) {
301
399
  const authCodeGrant = requireAuthorizationCodeGrant(options.credentialOffer);
302
400
  return {
303
- authorizationCodeGrant: {
401
+ ["authorization_code" /* AUTHORIZATION_CODE */]: {
304
402
  authorizationServer: authCodeGrant.authorization_server,
305
403
  issuerState: authCodeGrant.issuer_state,
306
404
  scope: authCodeGrant.scope
307
- },
308
- grantType: "authorization_code"
405
+ }
309
406
  };
310
407
  }
311
408
  function extractGrantDetailsV1_4(options) {
312
409
  const authCodeGrant = requireAuthorizationCodeGrant(options.credentialOffer);
313
410
  return {
314
- authorizationCodeGrant: {
411
+ ["authorization_code" /* AUTHORIZATION_CODE */]: {
315
412
  authorizationServer: authCodeGrant.authorization_server,
316
413
  issuerState: authCodeGrant.issuer_state
414
+ }
415
+ };
416
+ }
417
+ function extractGrantDetailsAPTITUDE(options) {
418
+ const grants = requireAuthorizationCodeOrPreAuthorizedCodeGrant(
419
+ options.credentialOffer
420
+ );
421
+ const authorizationCodeGrant = grants["authorization_code" /* AUTHORIZATION_CODE */];
422
+ const preAuthorizedCodeGrant = grants["urn:ietf:params:oauth:grant-type:pre-authorized_code" /* PREAUTHORIZED_CODE */];
423
+ return {
424
+ ...authorizationCodeGrant && {
425
+ ["authorization_code" /* AUTHORIZATION_CODE */]: {
426
+ authorizationServer: authorizationCodeGrant.authorization_server,
427
+ issuerState: authorizationCodeGrant.issuer_state
428
+ }
317
429
  },
318
- grantType: "authorization_code"
430
+ ...preAuthorizedCodeGrant && {
431
+ ["urn:ietf:params:oauth:grant-type:pre-authorized_code" /* PREAUTHORIZED_CODE */]: {
432
+ authorizationServer: preAuthorizedCodeGrant.authorization_server,
433
+ preAuthorizedCode: preAuthorizedCodeGrant["pre-authorized_code"],
434
+ txCode: preAuthorizedCodeGrant.tx_code
435
+ }
436
+ }
319
437
  };
320
438
  }
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(
439
+ var dispatchExtractGrantDetails = (0, import_io_wallet_utils3.createVersionDispatcher)({
440
+ [import_io_wallet_utils3.ItWalletSpecsVersion.APTITUDE]: (o) => extractGrantDetailsAPTITUDE(o),
441
+ [import_io_wallet_utils3.ItWalletSpecsVersion.V1_0]: () => {
442
+ throw new import_io_wallet_utils3.ItWalletSpecsVersionError(
324
443
  "extractGrantDetails",
325
- import_io_wallet_utils2.ItWalletSpecsVersion.V1_0,
326
- [import_io_wallet_utils2.ItWalletSpecsVersion.V1_3, import_io_wallet_utils2.ItWalletSpecsVersion.V1_4]
444
+ import_io_wallet_utils3.ItWalletSpecsVersion.V1_0,
445
+ [
446
+ import_io_wallet_utils3.ItWalletSpecsVersion.V1_3,
447
+ import_io_wallet_utils3.ItWalletSpecsVersion.V1_4,
448
+ import_io_wallet_utils3.ItWalletSpecsVersion.APTITUDE
449
+ ]
327
450
  );
328
451
  },
329
- [import_io_wallet_utils2.ItWalletSpecsVersion.V1_3]: (o) => extractGrantDetailsV1_3(o),
330
- [import_io_wallet_utils2.ItWalletSpecsVersion.V1_4]: (o) => extractGrantDetailsV1_4(o)
452
+ [import_io_wallet_utils3.ItWalletSpecsVersion.V1_3]: (o) => extractGrantDetailsV1_3(o),
453
+ [import_io_wallet_utils3.ItWalletSpecsVersion.V1_4]: (o) => extractGrantDetailsV1_4(o)
331
454
  });
332
455
  function extractGrantDetails(options) {
333
456
  return dispatchExtractGrantDetails(options);
334
457
  }
335
458
 
336
459
  // src/credential-offer/z-credential-offer.ts
337
- var import_zod4 = require("zod");
460
+ var import_zod5 = require("zod");
338
461
 
339
462
  // src/credential-offer/v1.3/z-credential-offer.ts
340
- var import_zod2 = require("zod");
341
- var zAuthorizationCodeGrantV1_3 = import_zod2.z.object({
463
+ var import_zod3 = require("zod");
464
+ var zAuthorizationCodeGrantV1_3 = import_zod3.z.object({
342
465
  /**
343
466
  * CONDITIONALLY REQUIRED. HTTPS URL of the Authorization Server.
344
467
  * REQUIRED only when the Credential Issuer uses multiple Authorization Servers.
345
468
  * If present, MUST match one of the authorization_servers in the Credential Issuer metadata.
346
469
  */
347
- authorization_server: import_zod2.z.url().optional(),
470
+ authorization_server: import_zod3.z.url().optional(),
348
471
  /**
349
472
  * OPTIONAL. String value representing the issuer state.
350
473
  * Used to correlate the authorization request with the credential offer.
351
474
  */
352
- issuer_state: import_zod2.z.string().optional(),
475
+ issuer_state: import_zod3.z.string().optional(),
353
476
  /**
354
477
  * REQUIRED. OAuth 2.0 scope value.
355
478
  * Defines the scope of access requested by the credential offer.
356
479
  */
357
- scope: import_zod2.z.string()
480
+ scope: import_zod3.z.string()
358
481
  });
359
- var zCredentialOfferGrantsV1_3 = import_zod2.z.object({
482
+ var zCredentialOfferGrantsV1_3 = import_zod3.z.object({
360
483
  /**
361
484
  * REQUIRED. Authorization Code grant details.
362
485
  * IT-Wallet v1.3 only supports authorization_code grant.
363
486
  */
364
487
  authorization_code: zAuthorizationCodeGrantV1_3
365
488
  });
366
- var zCredentialOfferV1_3 = import_zod2.z.object({
489
+ var zCredentialOfferV1_3 = import_zod3.z.object({
367
490
  /**
368
491
  * REQUIRED. Array of credential configuration identifiers.
369
492
  * References the types of credentials offered as defined in the Credential Issuer metadata.
370
493
  */
371
- credential_configuration_ids: import_zod2.z.array(import_zod2.z.string()).min(1),
494
+ credential_configuration_ids: import_zod3.z.array(import_zod3.z.string()).min(1),
372
495
  /**
373
496
  * REQUIRED. HTTPS URL of the Credential Issuer.
374
497
  * The Credential Issuer from which the wallet will request credentials.
375
498
  */
376
- credential_issuer: import_zod2.z.url(),
499
+ credential_issuer: import_zod3.z.url(),
377
500
  /**
378
501
  * REQUIRED. Grant information for the credential offer.
379
502
  * IT-Wallet v1.3 requires authorization_code grant.
@@ -382,38 +505,38 @@ var zCredentialOfferV1_3 = import_zod2.z.object({
382
505
  });
383
506
 
384
507
  // src/credential-offer/v1.4/z-credential-offer.ts
385
- var import_zod3 = require("zod");
386
- var zAuthorizationCodeGrantV1_4 = import_zod3.z.object({
508
+ var import_zod4 = require("zod");
509
+ var zAuthorizationCodeGrantV1_4 = import_zod4.z.object({
387
510
  /**
388
511
  * CONDITIONALLY REQUIRED. HTTPS URL of the Authorization Server.
389
512
  * REQUIRED only when the Credential Issuer uses multiple Authorization Servers.
390
513
  * If present, MUST match one of the authorization_servers in the Credential Issuer metadata.
391
514
  */
392
- authorization_server: import_zod3.z.url().optional(),
515
+ authorization_server: import_zod4.z.url().optional(),
393
516
  /**
394
517
  * OPTIONAL. String value representing the issuer state.
395
518
  * Used to correlate the authorization request with the credential offer.
396
519
  */
397
- issuer_state: import_zod3.z.string().optional()
520
+ issuer_state: import_zod4.z.string().optional()
398
521
  });
399
- var zCredentialOfferGrantsV1_4 = import_zod3.z.object({
522
+ var zCredentialOfferGrantsV1_4 = import_zod4.z.object({
400
523
  /**
401
524
  * REQUIRED. Authorization Code grant details.
402
525
  * IT-Wallet v1.4 only supports authorization_code grant.
403
526
  */
404
527
  authorization_code: zAuthorizationCodeGrantV1_4
405
528
  });
406
- var zCredentialOfferV1_4 = import_zod3.z.object({
529
+ var zCredentialOfferV1_4 = import_zod4.z.object({
407
530
  /**
408
531
  * REQUIRED. Array of credential configuration identifiers.
409
532
  * References the types of credentials offered as defined in the Credential Issuer metadata.
410
533
  */
411
- credential_configuration_ids: import_zod3.z.array(import_zod3.z.string()).min(1),
534
+ credential_configuration_ids: import_zod4.z.array(import_zod4.z.string()).min(1),
412
535
  /**
413
536
  * REQUIRED. HTTPS URL of the Credential Issuer.
414
537
  * The Credential Issuer from which the wallet will request credentials.
415
538
  */
416
- credential_issuer: import_zod3.z.url(),
539
+ credential_issuer: import_zod4.z.url(),
417
540
  /**
418
541
  * REQUIRED. Grant information for the credential offer.
419
542
  * IT-Wallet v1.4 requires authorization_code grant.
@@ -422,22 +545,22 @@ var zCredentialOfferV1_4 = import_zod3.z.object({
422
545
  });
423
546
 
424
547
  // src/credential-offer/z-credential-offer.ts
425
- var zCredentialOfferUri = import_zod4.z.object({
548
+ var zCredentialOfferUri = import_zod5.z.object({
426
549
  /**
427
550
  * OPTIONAL. Inline credential offer JSON (by value).
428
551
  * URL-encoded JSON string containing the credential offer.
429
552
  */
430
- credential_offer: import_zod4.z.string().optional(),
553
+ credential_offer: import_zod5.z.string().optional(),
431
554
  /**
432
555
  * OPTIONAL. URL pointing to the credential offer JSON (by reference).
433
556
  * HTTPS URL where the credential offer can be fetched.
434
557
  */
435
- credential_offer_uri: import_zod4.z.url().optional(),
558
+ credential_offer_uri: import_zod5.z.url().optional(),
436
559
  /**
437
560
  * URL scheme used for the credential offer.
438
561
  * Determines the invocation method.
439
562
  */
440
- scheme: import_zod4.z.enum(["openid-credential-offer", "haip-vci", "https"])
563
+ scheme: import_zod5.z.enum(["openid-credential-offer", "haip-vci", "https"])
441
564
  }).refine((data) => data.credential_offer || data.credential_offer_uri, {
442
565
  message: "Either credential_offer or credential_offer_uri must be present"
443
566
  });
@@ -475,18 +598,24 @@ async function parseCredentialOfferUri(options) {
475
598
  }
476
599
 
477
600
  // src/credential-offer/resolve-credential-offer.ts
478
- var import_io_wallet_utils3 = require("@pagopa/io-wallet-utils");
601
+ var import_io_wallet_utils4 = require("@pagopa/io-wallet-utils");
479
602
  function parseCredentialOfferForVersion(config, data) {
480
603
  switch (config.itWalletSpecsVersion) {
481
- case import_io_wallet_utils3.ItWalletSpecsVersion.V1_3:
604
+ case import_io_wallet_utils4.ItWalletSpecsVersion.V1_3:
482
605
  return zCredentialOfferV1_3.parse(data);
483
- case import_io_wallet_utils3.ItWalletSpecsVersion.V1_4:
606
+ case import_io_wallet_utils4.ItWalletSpecsVersion.V1_4:
484
607
  return zCredentialOfferV1_4.parse(data);
608
+ case import_io_wallet_utils4.ItWalletSpecsVersion.APTITUDE:
609
+ return zCredentialOfferAPTITUDE.parse(data);
485
610
  default:
486
- throw new import_io_wallet_utils3.ItWalletSpecsVersionError(
611
+ throw new import_io_wallet_utils4.ItWalletSpecsVersionError(
487
612
  "resolveCredentialOffer",
488
613
  config.itWalletSpecsVersion,
489
- [import_io_wallet_utils3.ItWalletSpecsVersion.V1_3, import_io_wallet_utils3.ItWalletSpecsVersion.V1_4]
614
+ [
615
+ import_io_wallet_utils4.ItWalletSpecsVersion.V1_3,
616
+ import_io_wallet_utils4.ItWalletSpecsVersion.V1_4,
617
+ import_io_wallet_utils4.ItWalletSpecsVersion.APTITUDE
618
+ ]
490
619
  );
491
620
  }
492
621
  }
@@ -501,14 +630,14 @@ async function resolveCredentialOffer(options) {
501
630
  return parseCredentialOfferForVersion(config, offerJson2);
502
631
  }
503
632
  if (parsed.credential_offer_uri) {
504
- const fetch = (0, import_io_wallet_utils3.createFetcher)(callbacks.fetch);
633
+ const fetch = (0, import_io_wallet_utils4.createFetcher)(callbacks.fetch);
505
634
  const response = await fetch(parsed.credential_offer_uri, {
506
635
  headers: {
507
636
  Accept: "application/json"
508
637
  },
509
638
  method: "GET"
510
639
  });
511
- await (0, import_io_wallet_utils3.hasStatusOrThrow)(200, import_io_wallet_utils3.UnexpectedStatusCodeError)(response);
640
+ await (0, import_io_wallet_utils4.hasStatusOrThrow)(200, import_io_wallet_utils4.UnexpectedStatusCodeError)(response);
512
641
  const offerJson2 = await response.json();
513
642
  return parseCredentialOfferForVersion(config, offerJson2);
514
643
  }
@@ -516,7 +645,7 @@ async function resolveCredentialOffer(options) {
516
645
  const offerJson = JSON.parse(credentialOffer);
517
646
  return parseCredentialOfferForVersion(config, offerJson);
518
647
  } catch (error) {
519
- if (error instanceof CredentialOfferError || error instanceof import_io_wallet_utils3.UnexpectedStatusCodeError || error instanceof import_io_wallet_utils3.ItWalletSpecsVersionError) {
648
+ if (error instanceof CredentialOfferError || error instanceof import_io_wallet_utils4.UnexpectedStatusCodeError || error instanceof import_io_wallet_utils4.ItWalletSpecsVersionError) {
520
649
  throw error;
521
650
  }
522
651
  throw new CredentialOfferError(
@@ -526,7 +655,7 @@ async function resolveCredentialOffer(options) {
526
655
  }
527
656
 
528
657
  // src/credential-offer/validate-credential-offer.ts
529
- var import_io_wallet_utils4 = require("@pagopa/io-wallet-utils");
658
+ var import_io_wallet_utils5 = require("@pagopa/io-wallet-utils");
530
659
  function assertAuthorizationServerAllowed(authorizationServer, authorizationServers) {
531
660
  if (!authorizationServer) {
532
661
  if (authorizationServers && authorizationServers.length > 1) {
@@ -553,7 +682,7 @@ function assertAuthorizationServerAllowed(authorizationServer, authorizationServ
553
682
  }
554
683
  }
555
684
  function validateBaseCredentialOffer(options) {
556
- const { credentialIssuerMetadata, credentialOffer, versionLabel } = options;
685
+ const { credentialOffer, versionLabel } = options;
557
686
  if (!credentialOffer.credential_issuer.startsWith("https://")) {
558
687
  throw new CredentialOfferError("credential_issuer must be an HTTPS URL");
559
688
  }
@@ -567,6 +696,11 @@ function validateBaseCredentialOffer(options) {
567
696
  `grants is REQUIRED for IT-Wallet ${versionLabel}`
568
697
  );
569
698
  }
699
+ }
700
+ async function validateCredentialOfferV1_3(options) {
701
+ const versionLabel = "v1.3";
702
+ const { credentialIssuerMetadata, credentialOffer } = options;
703
+ validateBaseCredentialOffer({ credentialOffer, versionLabel });
570
704
  const authCodeGrant = credentialOffer.grants.authorization_code;
571
705
  if (!authCodeGrant) {
572
706
  throw new CredentialOfferError(
@@ -577,58 +711,85 @@ function validateBaseCredentialOffer(options) {
577
711
  authCodeGrant.authorization_server,
578
712
  credentialIssuerMetadata?.authorization_servers
579
713
  );
580
- }
581
- async function validateCredentialOfferV1_3(options) {
582
- validateBaseCredentialOffer({
583
- credentialIssuerMetadata: options.credentialIssuerMetadata,
584
- credentialOffer: options.credentialOffer,
585
- versionLabel: "v1.3"
586
- });
587
714
  if (!options.credentialOffer.grants.authorization_code.scope) {
588
715
  throw new CredentialOfferError("authorization_code.scope is REQUIRED");
589
716
  }
590
717
  }
591
718
  async function validateCredentialOfferV1_4(options) {
592
- validateBaseCredentialOffer({
593
- credentialIssuerMetadata: options.credentialIssuerMetadata,
594
- credentialOffer: options.credentialOffer,
595
- versionLabel: "v1.4"
596
- });
719
+ const versionLabel = "v1.4";
720
+ const { credentialIssuerMetadata, credentialOffer } = options;
721
+ validateBaseCredentialOffer({ credentialOffer, versionLabel });
722
+ const authCodeGrant = credentialOffer.grants.authorization_code;
723
+ if (!authCodeGrant) {
724
+ throw new CredentialOfferError(
725
+ `authorization_code grant is REQUIRED for IT-Wallet ${versionLabel}`
726
+ );
727
+ }
728
+ assertAuthorizationServerAllowed(
729
+ authCodeGrant.authorization_server,
730
+ credentialIssuerMetadata?.authorization_servers
731
+ );
597
732
  }
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(
733
+ async function validateCredentialOfferAPTITUDE(options) {
734
+ const versionLabel = "APTITUDE";
735
+ const {
736
+ credentialIssuerMetadata,
737
+ credentialOffer,
738
+ grantType = "authorization_code" /* AUTHORIZATION_CODE */
739
+ } = options;
740
+ validateBaseCredentialOffer({ credentialOffer, versionLabel });
741
+ const grant = credentialOffer.grants[grantType];
742
+ if (!grant) {
743
+ throw new CredentialOfferError(
744
+ `${grantType} grant as specified is REQUIRED for IT-Wallet ${versionLabel}`
745
+ );
746
+ }
747
+ assertAuthorizationServerAllowed(
748
+ grant.authorization_server,
749
+ credentialIssuerMetadata?.authorization_servers
750
+ );
751
+ }
752
+ var dispatchValidateCredentialOffer = (0, import_io_wallet_utils5.createVersionDispatcher)({
753
+ [import_io_wallet_utils5.ItWalletSpecsVersion.APTITUDE]: (o) => validateCredentialOfferAPTITUDE(
754
+ o
755
+ ),
756
+ [import_io_wallet_utils5.ItWalletSpecsVersion.V1_0]: () => {
757
+ throw new import_io_wallet_utils5.ItWalletSpecsVersionError(
601
758
  "validateCredentialOffer",
602
- import_io_wallet_utils4.ItWalletSpecsVersion.V1_0,
603
- [import_io_wallet_utils4.ItWalletSpecsVersion.V1_3, import_io_wallet_utils4.ItWalletSpecsVersion.V1_4]
759
+ import_io_wallet_utils5.ItWalletSpecsVersion.V1_0,
760
+ [
761
+ import_io_wallet_utils5.ItWalletSpecsVersion.V1_3,
762
+ import_io_wallet_utils5.ItWalletSpecsVersion.V1_4,
763
+ import_io_wallet_utils5.ItWalletSpecsVersion.APTITUDE
764
+ ]
604
765
  );
605
766
  },
606
- [import_io_wallet_utils4.ItWalletSpecsVersion.V1_3]: (o) => validateCredentialOfferV1_3(o),
607
- [import_io_wallet_utils4.ItWalletSpecsVersion.V1_4]: (o) => validateCredentialOfferV1_4(o)
767
+ [import_io_wallet_utils5.ItWalletSpecsVersion.V1_3]: (o) => validateCredentialOfferV1_3(o),
768
+ [import_io_wallet_utils5.ItWalletSpecsVersion.V1_4]: (o) => validateCredentialOfferV1_4(o)
608
769
  });
609
770
  async function validateCredentialOffer(options) {
610
771
  return dispatchValidateCredentialOffer(options);
611
772
  }
612
773
 
613
774
  // src/credential-request/create-credential-request.ts
614
- var import_io_wallet_utils7 = require("@pagopa/io-wallet-utils");
775
+ var import_io_wallet_utils8 = require("@pagopa/io-wallet-utils");
615
776
 
616
777
  // src/credential-request/v1.0/create-credential-request.ts
617
- var import_io_wallet_utils5 = require("@pagopa/io-wallet-utils");
778
+ var import_io_wallet_utils6 = require("@pagopa/io-wallet-utils");
618
779
 
619
780
  // src/credential-request/v1.0/z-credential.ts
620
- var import_zod6 = require("zod");
781
+ var import_zod7 = require("zod");
621
782
 
622
783
  // src/credential-request/z-base-credential-request.ts
623
- var import_zod5 = require("zod");
624
- var zBaseCredentialRequest = import_zod5.z.object({
625
- credential_configuration_id: import_zod5.z.string().optional().describe(
784
+ var import_zod6 = require("zod");
785
+ var zBaseCredentialRequest = import_zod6.z.object({
786
+ credential_configuration_id: import_zod6.z.string().optional().describe(
626
787
  "REQUIRED if credential_identifier param is absent. MUST NOT be used otherwise."
627
788
  ),
628
- credential_identifier: import_zod5.z.string().optional().describe(
789
+ credential_identifier: import_zod6.z.string().optional().describe(
629
790
  "REQUIRED when Authorization Details of type openid_credential was returned. MUST NOT be used if credential_configuration_id is present."
630
791
  ),
631
- transaction_id: import_zod5.z.string().optional().describe(
792
+ transaction_id: import_zod6.z.string().optional().describe(
632
793
  "REQUIRED only in case of deferred flow. MUST NOT be present in immediate flow."
633
794
  )
634
795
  });
@@ -650,9 +811,9 @@ function credentialRequestRefiner(data, ctx) {
650
811
  }
651
812
 
652
813
  // src/credential-request/v1.0/z-credential.ts
653
- var zCredentialRequestProof = import_zod6.z.object({
654
- jwt: import_zod6.z.string().min(1, "JWT must not be empty"),
655
- proof_type: import_zod6.z.literal("jwt")
814
+ var zCredentialRequestProof = import_zod7.z.object({
815
+ jwt: import_zod7.z.string().min(1, "JWT must not be empty"),
816
+ proof_type: import_zod7.z.literal("jwt")
656
817
  // MUST be "jwt"
657
818
  });
658
819
  var zCredentialRequestV1_0 = zBaseCredentialRequest.extend({
@@ -675,12 +836,12 @@ var createCredentialRequest = async (options) => {
675
836
  },
676
837
  payload: {
677
838
  aud: options.issuerIdentifier,
678
- iat: (0, import_io_wallet_utils5.dateToSeconds)(/* @__PURE__ */ new Date()),
839
+ iat: (0, import_io_wallet_utils6.dateToSeconds)(/* @__PURE__ */ new Date()),
679
840
  iss: options.clientId,
680
841
  nonce: options.nonce
681
842
  }
682
843
  });
683
- return (0, import_io_wallet_utils5.parseWithErrorHandling)(zCredentialRequestV1_0, {
844
+ return (0, import_io_wallet_utils6.parseWithErrorHandling)(zCredentialRequestV1_0, {
684
845
  credential_identifier: options.credential_identifier,
685
846
  proof: {
686
847
  jwt: proofJwt.jwt,
@@ -688,7 +849,7 @@ var createCredentialRequest = async (options) => {
688
849
  }
689
850
  });
690
851
  } catch (error) {
691
- if (error instanceof import_io_wallet_utils5.ValidationError) {
852
+ if (error instanceof import_io_wallet_utils6.ValidationError) {
692
853
  throw error;
693
854
  }
694
855
  throw new Oid4vciError(
@@ -698,14 +859,13 @@ var createCredentialRequest = async (options) => {
698
859
  };
699
860
 
700
861
  // 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");
862
+ var import_io_wallet_utils7 = require("@pagopa/io-wallet-utils");
703
863
 
704
864
  // src/credential-request/v1.3/z-credential.ts
705
- var import_zod7 = require("zod");
706
- var zCredentialRequestProofJwt = import_zod7.z.string().min(1, "JWT must not be empty in credential request proofs array");
707
- var zCredentialRequestProofs = import_zod7.z.object({
708
- jwt: import_zod7.z.tuple([zCredentialRequestProofJwt], zCredentialRequestProofJwt)
865
+ var import_zod8 = require("zod");
866
+ var zCredentialRequestProofJwt = import_zod8.z.string().min(1, "JWT must not be empty in credential request proofs array");
867
+ var zCredentialRequestProofs = import_zod8.z.object({
868
+ jwt: import_zod8.z.tuple([zCredentialRequestProofJwt], zCredentialRequestProofJwt)
709
869
  });
710
870
  var zCredentialRequestV1_3 = zBaseCredentialRequest.extend({
711
871
  proofs: zCredentialRequestProofs.describe(
@@ -721,16 +881,16 @@ var createCredentialRequest2 = async (options) => {
721
881
  const { maxBatchSize, signers } = options;
722
882
  const [firstSigner, ...otherSigners] = signers;
723
883
  if (!firstSigner) {
724
- throw new import_io_wallet_utils6.ValidationError("At least one signer is required");
884
+ throw new import_io_wallet_utils7.ValidationError("At least one signer is required");
725
885
  }
726
886
  if (maxBatchSize !== void 0) {
727
887
  if (!Number.isInteger(maxBatchSize) || maxBatchSize <= 0) {
728
- throw new import_io_wallet_utils6.ValidationError(
888
+ throw new import_io_wallet_utils7.ValidationError(
729
889
  "Invalid maxBatchSize: it must be a positive integer"
730
890
  );
731
891
  }
732
892
  if (signers.length > maxBatchSize) {
733
- throw new import_io_wallet_utils6.ValidationError(
893
+ throw new import_io_wallet_utils7.ValidationError(
734
894
  "The number of provided signers exceeds the maximum batch size allowed"
735
895
  );
736
896
  }
@@ -739,8 +899,8 @@ var createCredentialRequest2 = async (options) => {
739
899
  if (signers.length > 1) {
740
900
  const allThumbprints = await Promise.all(
741
901
  signers.map(
742
- (signer) => (0, import_oauth22.calculateJwkThumbprint)({
743
- hashAlgorithm: import_oauth22.HashAlgorithm.Sha256,
902
+ (signer) => (0, import_io_wallet_utils7.calculateJwkThumbprint)({
903
+ hashAlgorithm: import_io_wallet_utils7.HashAlgorithm.Sha256,
744
904
  hashCallback: hash,
745
905
  jwk: signer.publicJwk
746
906
  })
@@ -748,7 +908,7 @@ var createCredentialRequest2 = async (options) => {
748
908
  );
749
909
  const uniqueThumbprints = new Set(allThumbprints);
750
910
  if (uniqueThumbprints.size !== allThumbprints.length) {
751
- throw new import_io_wallet_utils6.ValidationError(
911
+ throw new import_io_wallet_utils7.ValidationError(
752
912
  "Found multiple signers with the same JWK: each JWT proof must be unique and linked to a different credential key pair"
753
913
  );
754
914
  }
@@ -762,7 +922,7 @@ var createCredentialRequest2 = async (options) => {
762
922
  },
763
923
  payload: {
764
924
  aud: options.issuerIdentifier,
765
- iat: (0, import_io_wallet_utils6.dateToSeconds)(/* @__PURE__ */ new Date()),
925
+ iat: (0, import_io_wallet_utils7.dateToSeconds)(/* @__PURE__ */ new Date()),
766
926
  iss: options.clientId,
767
927
  nonce: options.nonce
768
928
  }
@@ -771,14 +931,14 @@ var createCredentialRequest2 = async (options) => {
771
931
  createProofJwt(firstSigner),
772
932
  ...otherSigners.map(createProofJwt)
773
933
  ]);
774
- return (0, import_io_wallet_utils6.parseWithErrorHandling)(zCredentialRequestV1_3, {
934
+ return (0, import_io_wallet_utils7.parseWithErrorHandling)(zCredentialRequestV1_3, {
775
935
  credential_identifier: options.credential_identifier,
776
936
  proofs: {
777
937
  jwt: proofJwts
778
938
  }
779
939
  });
780
940
  } catch (error) {
781
- if (error instanceof import_io_wallet_utils6.ValidationError) {
941
+ if (error instanceof import_io_wallet_utils7.ValidationError) {
782
942
  throw error;
783
943
  }
784
944
  throw new Oid4vciError(
@@ -788,10 +948,11 @@ var createCredentialRequest2 = async (options) => {
788
948
  };
789
949
 
790
950
  // 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) => (
951
+ var dispatchCreateCredentialRequest = (0, import_io_wallet_utils8.createVersionDispatcher)({
952
+ [import_io_wallet_utils8.ItWalletSpecsVersion.APTITUDE]: (o) => createCredentialRequest2(o),
953
+ [import_io_wallet_utils8.ItWalletSpecsVersion.V1_0]: (o) => createCredentialRequest(o),
954
+ [import_io_wallet_utils8.ItWalletSpecsVersion.V1_3]: (o) => createCredentialRequest2(o),
955
+ [import_io_wallet_utils8.ItWalletSpecsVersion.V1_4]: (o) => (
795
956
  // V1_4 reuses V1_3 credential request schema — no breaking changes between versions.
796
957
  // Verified against compare/1.3.3...1.4.1: credential request parameters (format, proofs, key_attestation) identical.
797
958
  createCredentialRequest2(o)
@@ -802,26 +963,26 @@ async function createCredentialRequest3(options) {
802
963
  }
803
964
 
804
965
  // 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");
966
+ var import_io_wallet_oauth22 = require("@pagopa/io-wallet-oauth2");
967
+ var import_io_wallet_utils10 = require("@pagopa/io-wallet-utils");
807
968
 
808
969
  // src/credential-request/z-proof-jwt.ts
809
- var import_io_wallet_oauth22 = require("@pagopa/io-wallet-oauth2");
810
- var import_zod8 = require("zod");
811
- var zBaseProofJwtHeader = import_zod8.z.object({
812
- alg: import_zod8.z.string().min(1),
813
- jwk: import_io_wallet_oauth22.zJwk,
814
- typ: import_zod8.z.literal("openid4vci-proof+jwt")
970
+ var import_io_wallet_utils9 = require("@pagopa/io-wallet-utils");
971
+ var import_zod9 = require("zod");
972
+ var zBaseProofJwtHeader = import_zod9.z.object({
973
+ alg: import_zod9.z.string().min(1),
974
+ jwk: import_io_wallet_utils9.zJwk,
975
+ typ: import_zod9.z.literal("openid4vci-proof+jwt")
815
976
  });
816
977
  var zProofJwtHeaderV1_0 = zBaseProofJwtHeader.loose();
817
978
  var zProofJwtHeaderV1_3 = zBaseProofJwtHeader.extend({
818
- key_attestation: import_zod8.z.string().min(1)
979
+ key_attestation: import_zod9.z.string().min(1)
819
980
  }).loose();
820
- var zProofJwtPayload = import_zod8.z.looseObject({
821
- aud: import_zod8.z.string().min(1),
822
- iat: import_zod8.z.number(),
823
- iss: import_zod8.z.string().min(1).optional(),
824
- nonce: import_zod8.z.string().min(1)
981
+ var zProofJwtPayload = import_zod9.z.looseObject({
982
+ aud: import_zod9.z.string().min(1),
983
+ iat: import_zod9.z.number(),
984
+ iss: import_zod9.z.string().min(1).optional(),
985
+ nonce: import_zod9.z.string().min(1)
825
986
  });
826
987
 
827
988
  // src/credential-request/parse-credential-request.ts
@@ -830,12 +991,12 @@ function validateExpectedValues(credentialRequest, expected) {
830
991
  return;
831
992
  }
832
993
  if (expected.credential_identifier && credentialRequest.credential_identifier !== expected.credential_identifier) {
833
- throw new import_io_wallet_utils8.ValidationError(
994
+ throw new import_io_wallet_utils10.ValidationError(
834
995
  "credential_identifier does not match expected value"
835
996
  );
836
997
  }
837
998
  if (expected.credential_configuration_id && credentialRequest.credential_configuration_id !== expected.credential_configuration_id) {
838
- throw new import_io_wallet_utils8.ValidationError(
999
+ throw new import_io_wallet_utils10.ValidationError(
839
1000
  "credential_configuration_id does not match expected value"
840
1001
  );
841
1002
  }
@@ -843,12 +1004,12 @@ function validateExpectedValues(credentialRequest, expected) {
843
1004
  function validateTransactionContext(options) {
844
1005
  const { credentialRequest, isDeferredFlow } = options;
845
1006
  if (isDeferredFlow && !credentialRequest.transaction_id) {
846
- throw new import_io_wallet_utils8.ValidationError(
1007
+ throw new import_io_wallet_utils10.ValidationError(
847
1008
  "transaction_id is required for deferred credential issuance"
848
1009
  );
849
1010
  }
850
1011
  if (!isDeferredFlow && credentialRequest.transaction_id) {
851
- throw new import_io_wallet_utils8.ValidationError(
1012
+ throw new import_io_wallet_utils10.ValidationError(
852
1013
  "transaction_id must not be present in immediate credential issuance flow"
853
1014
  );
854
1015
  }
@@ -856,45 +1017,45 @@ function validateTransactionContext(options) {
856
1017
  function validateProofPayloadSemantics(options) {
857
1018
  const { expected, grantType, payload } = options;
858
1019
  if (grantType === "authorization_code" && !payload.iss) {
859
- throw new import_io_wallet_utils8.ValidationError(
1020
+ throw new import_io_wallet_utils10.ValidationError(
860
1021
  "Credential proof JWT payload must include iss for authorization_code grant"
861
1022
  );
862
1023
  }
863
1024
  if (expected?.audience && payload.aud !== expected.audience) {
864
- throw new import_io_wallet_utils8.ValidationError(
1025
+ throw new import_io_wallet_utils10.ValidationError(
865
1026
  "Credential proof JWT aud does not match expected audience"
866
1027
  );
867
1028
  }
868
1029
  if (expected?.nonce && payload.nonce !== expected.nonce) {
869
- throw new import_io_wallet_utils8.ValidationError(
1030
+ throw new import_io_wallet_utils10.ValidationError(
870
1031
  "Credential proof JWT nonce does not match expected nonce"
871
1032
  );
872
1033
  }
873
1034
  if (expected?.issuer && payload.iss && payload.iss !== expected.issuer) {
874
- throw new import_io_wallet_utils8.ValidationError(
1035
+ throw new import_io_wallet_utils10.ValidationError(
875
1036
  "Credential proof JWT iss does not match expected issuer"
876
1037
  );
877
1038
  }
878
1039
  if (grantType === "authorization_code" && expected?.issuer && !payload.iss) {
879
- throw new import_io_wallet_utils8.ValidationError(
1040
+ throw new import_io_wallet_utils10.ValidationError(
880
1041
  "Credential proof JWT payload is missing expected issuer (iss)"
881
1042
  );
882
1043
  }
883
1044
  }
884
1045
  function parseProofJwt(options) {
885
- const decoded = (0, import_io_wallet_oauth23.decodeJwt)({
1046
+ const decoded = (0, import_io_wallet_utils10.decodeJwt)({
886
1047
  errorMessagePrefix: "Error decoding credential request proof JWT:",
887
1048
  jwt: options.jwt
888
1049
  });
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);
1050
+ 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
1051
  if (!headerValidation.success) {
891
- throw new import_io_wallet_utils8.ValidationError(
1052
+ throw new import_io_wallet_utils10.ValidationError(
892
1053
  "Credential proof JWT header is invalid or missing required claims"
893
1054
  );
894
1055
  }
895
1056
  const payloadValidation = zProofJwtPayload.safeParse(decoded.payload);
896
1057
  if (!payloadValidation.success) {
897
- throw new import_io_wallet_utils8.ValidationError(
1058
+ throw new import_io_wallet_utils10.ValidationError(
898
1059
  "Credential proof JWT payload is invalid or missing required claims"
899
1060
  );
900
1061
  }
@@ -917,8 +1078,8 @@ async function validateProofJwkUniqueness(options) {
917
1078
  }
918
1079
  const thumbprints = await Promise.all(
919
1080
  options.proofs.map(
920
- (proof) => (0, import_io_wallet_utils8.calculateJwkThumbprint)({
921
- hashAlgorithm: import_io_wallet_utils8.HashAlgorithm.Sha256,
1081
+ (proof) => (0, import_io_wallet_utils10.calculateJwkThumbprint)({
1082
+ hashAlgorithm: import_io_wallet_utils10.HashAlgorithm.Sha256,
922
1083
  hashCallback: options.callbacks.hash,
923
1084
  jwk: proof.header.jwk
924
1085
  })
@@ -926,7 +1087,7 @@ async function validateProofJwkUniqueness(options) {
926
1087
  );
927
1088
  const uniqueThumbprints = new Set(thumbprints);
928
1089
  if (uniqueThumbprints.size !== thumbprints.length) {
929
- throw new import_io_wallet_utils8.ValidationError(
1090
+ throw new import_io_wallet_utils10.ValidationError(
930
1091
  "Credential request proofs must use unique jwk header values"
931
1092
  );
932
1093
  }
@@ -986,7 +1147,7 @@ async function toResult(options) {
986
1147
  };
987
1148
  }
988
1149
  function parseAuthorizationHeader(headers) {
989
- const authorizationHeader = headers.get(import_io_wallet_utils8.HEADERS.AUTHORIZATION)?.trim();
1150
+ const authorizationHeader = headers.get(import_io_wallet_utils10.HEADERS.AUTHORIZATION)?.trim();
990
1151
  if (!authorizationHeader) {
991
1152
  throw new CredentialAuthorizationHeaderError(
992
1153
  "Credential request is missing required 'Authorization' header with DPoP scheme"
@@ -1001,7 +1162,7 @@ function parseAuthorizationHeader(headers) {
1001
1162
  return token;
1002
1163
  }
1003
1164
  function parseDpopProof(headers) {
1004
- const extracted = (0, import_io_wallet_oauth23.extractDpopJwtFromHeaders)(headers);
1165
+ const extracted = (0, import_io_wallet_oauth22.extractDpopJwtFromHeaders)(headers);
1005
1166
  if (!extracted.valid) {
1006
1167
  throw new InvalidDpopProofError(
1007
1168
  "Credential request contains a 'DPoP' header, but the value is not a valid JWT format"
@@ -1013,7 +1174,7 @@ function parseDpopProof(headers) {
1013
1174
  return extracted.dpopJwt;
1014
1175
  }
1015
1176
  function parseCredentialRequestV1_0(options) {
1016
- const credentialRequest = (0, import_io_wallet_utils8.parseWithErrorHandling)(
1177
+ const credentialRequest = (0, import_io_wallet_utils10.parseWithErrorHandling)(
1017
1178
  zCredentialRequestV1_0,
1018
1179
  options.credentialRequest,
1019
1180
  "Invalid credential request format for ItWalletSpecsVersion 1.0"
@@ -1026,11 +1187,11 @@ function parseCredentialRequestV1_0(options) {
1026
1187
  expected: options.expected,
1027
1188
  grantType: options.grantType,
1028
1189
  isDeferredFlow: options.isDeferredFlow,
1029
- itWalletSpecsVersion: import_io_wallet_utils8.ItWalletSpecsVersion.V1_0
1190
+ itWalletSpecsVersion: import_io_wallet_utils10.ItWalletSpecsVersion.V1_0
1030
1191
  });
1031
1192
  }
1032
1193
  function parseCredentialRequestV1_3(options) {
1033
- const credentialRequest = (0, import_io_wallet_utils8.parseWithErrorHandling)(
1194
+ const credentialRequest = (0, import_io_wallet_utils10.parseWithErrorHandling)(
1034
1195
  zCredentialRequestV1_3,
1035
1196
  options.credentialRequest,
1036
1197
  "Invalid credential request format for ItWalletSpecsVersion 1.3"
@@ -1043,11 +1204,11 @@ function parseCredentialRequestV1_3(options) {
1043
1204
  expected: options.expected,
1044
1205
  grantType: options.grantType,
1045
1206
  isDeferredFlow: options.isDeferredFlow,
1046
- itWalletSpecsVersion: import_io_wallet_utils8.ItWalletSpecsVersion.V1_3
1207
+ itWalletSpecsVersion: import_io_wallet_utils10.ItWalletSpecsVersion.V1_3
1047
1208
  });
1048
1209
  }
1049
1210
  function parseCredentialRequestV1_4(options) {
1050
- const credentialRequest = (0, import_io_wallet_utils8.parseWithErrorHandling)(
1211
+ const credentialRequest = (0, import_io_wallet_utils10.parseWithErrorHandling)(
1051
1212
  zCredentialRequestV1_3,
1052
1213
  options.credentialRequest,
1053
1214
  "Invalid credential request format for ItWalletSpecsVersion 1.4"
@@ -1060,14 +1221,32 @@ function parseCredentialRequestV1_4(options) {
1060
1221
  expected: options.expected,
1061
1222
  grantType: options.grantType,
1062
1223
  isDeferredFlow: options.isDeferredFlow,
1063
- itWalletSpecsVersion: import_io_wallet_utils8.ItWalletSpecsVersion.V1_4
1224
+ itWalletSpecsVersion: import_io_wallet_utils10.ItWalletSpecsVersion.V1_4
1064
1225
  // V1_4 reuses V1_3 proof schema
1065
1226
  });
1066
1227
  }
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
1228
+ function parseCredentialRequestAPTITUDE(options) {
1229
+ const credentialRequest = (0, import_io_wallet_utils10.parseWithErrorHandling)(
1230
+ zCredentialRequestV1_3,
1231
+ options.credentialRequest,
1232
+ "Invalid credential request format for ItWalletSpecsVersion APTITUDE"
1233
+ );
1234
+ return toResult({
1235
+ accessToken: options.accessToken,
1236
+ callbacks: options.callbacks,
1237
+ credentialRequest,
1238
+ dpopProof: options.dpopProof,
1239
+ expected: options.expected,
1240
+ grantType: options.grantType,
1241
+ isDeferredFlow: options.isDeferredFlow,
1242
+ itWalletSpecsVersion: import_io_wallet_utils10.ItWalletSpecsVersion.APTITUDE
1243
+ });
1244
+ }
1245
+ var dispatchParseCredentialRequest = (0, import_io_wallet_utils10.createVersionDispatcher)({
1246
+ [import_io_wallet_utils10.ItWalletSpecsVersion.APTITUDE]: parseCredentialRequestAPTITUDE,
1247
+ [import_io_wallet_utils10.ItWalletSpecsVersion.V1_0]: parseCredentialRequestV1_0,
1248
+ [import_io_wallet_utils10.ItWalletSpecsVersion.V1_3]: parseCredentialRequestV1_3,
1249
+ [import_io_wallet_utils10.ItWalletSpecsVersion.V1_4]: parseCredentialRequestV1_4
1071
1250
  });
1072
1251
  async function parseCredentialRequest(options) {
1073
1252
  const grantType = options.grantType ?? "authorization_code";
@@ -1083,7 +1262,7 @@ async function parseCredentialRequest(options) {
1083
1262
  isDeferredFlow
1084
1263
  });
1085
1264
  } 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) {
1265
+ 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
1266
  throw error;
1088
1267
  }
1089
1268
  throw new ParseCredentialRequestError(
@@ -1094,64 +1273,59 @@ async function parseCredentialRequest(options) {
1094
1273
  }
1095
1274
 
1096
1275
  // 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");
1276
+ var import_io_wallet_utils13 = require("@pagopa/io-wallet-utils");
1100
1277
 
1101
1278
  // 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");
1279
+ var import_io_wallet_utils12 = require("@pagopa/io-wallet-utils");
1105
1280
 
1106
1281
  // src/wallet-provider/z-key-attestation.ts
1107
- var import_io_wallet_oauth24 = require("@pagopa/io-wallet-oauth2");
1108
1282
  var import_io_wallet_oid_federation = require("@pagopa/io-wallet-oid-federation");
1109
- var import_io_wallet_utils9 = require("@pagopa/io-wallet-utils");
1110
- var import_zod9 = require("zod");
1111
- var zStatusList = import_zod9.z.object({
1112
- idx: import_zod9.z.number(),
1113
- uri: import_zod9.z.url()
1283
+ var import_io_wallet_utils11 = require("@pagopa/io-wallet-utils");
1284
+ var import_zod10 = require("zod");
1285
+ var zStatusList = import_zod10.z.object({
1286
+ idx: import_zod10.z.number(),
1287
+ uri: import_zod10.z.url()
1114
1288
  });
1115
- var zKeyAttestationStatus = import_zod9.z.object({
1289
+ var zKeyAttestationStatus = import_zod10.z.object({
1116
1290
  status_list: zStatusList
1117
1291
  });
1118
- var zKeyAttestationAlg = import_io_wallet_utils9.zItwSupportedSignatureAlg;
1119
- var zKeyAttestationHeader = import_zod9.z.object({
1292
+ var zKeyAttestationAlg = import_io_wallet_utils11.zItwSupportedSignatureAlg;
1293
+ var zKeyAttestationHeader = import_zod10.z.object({
1120
1294
  alg: zKeyAttestationAlg,
1121
- kid: import_zod9.z.string(),
1122
- trust_chain: import_io_wallet_oauth24.zTrustChain.optional(),
1123
- typ: import_zod9.z.literal("key-attestation+jwt"),
1124
- x5c: import_io_wallet_oauth24.zCertificateChain
1295
+ kid: import_zod10.z.string(),
1296
+ trust_chain: import_io_wallet_utils11.zTrustChain.optional(),
1297
+ typ: import_zod10.z.literal("key-attestation+jwt"),
1298
+ x5c: import_io_wallet_utils11.zCertificateChain
1125
1299
  });
1126
- var zKeyAttestationPayload = import_zod9.z.object({
1127
- attested_keys: import_zod9.z.array(import_io_wallet_oauth24.zJwk).nonempty(),
1128
- certification: import_zod9.z.string().optional(),
1129
- exp: import_zod9.z.number(),
1130
- iat: import_zod9.z.number(),
1131
- iss: import_zod9.z.string(),
1132
- key_storage: import_zod9.z.array(import_io_wallet_oid_federation.zKeyStorageLevelV1_3).nonempty(),
1300
+ var zKeyAttestationPayload = import_zod10.z.object({
1301
+ attested_keys: import_zod10.z.array(import_io_wallet_utils11.zJwk).nonempty(),
1302
+ certification: import_zod10.z.string().optional(),
1303
+ exp: import_zod10.z.number(),
1304
+ iat: import_zod10.z.number(),
1305
+ iss: import_zod10.z.string(),
1306
+ key_storage: import_zod10.z.array(import_io_wallet_oid_federation.zKeyStorageLevelV1_3).nonempty(),
1133
1307
  status: zKeyAttestationStatus,
1134
- user_authentication: import_zod9.z.array(import_io_wallet_oid_federation.zKeyStorageLevelV1_3).nonempty()
1308
+ user_authentication: import_zod10.z.array(import_io_wallet_oid_federation.zKeyStorageLevelV1_3).nonempty()
1135
1309
  });
1136
- var zKeyAttestationTypeHeader = import_zod9.z.literal("key-attestation+jwt");
1310
+ var zKeyAttestationTypeHeader = import_zod10.z.literal("key-attestation+jwt");
1137
1311
  var keyAttestationTypeHeader = zKeyAttestationTypeHeader.value;
1138
1312
 
1139
1313
  // src/credential-request/verify-key-attestation-jwt.ts
1140
1314
  async function verifyKeyAttestationJwt(options) {
1141
1315
  try {
1142
- const { header, payload } = (0, import_io_wallet_oauth25.decodeJwt)({
1316
+ const { header, payload } = (0, import_io_wallet_utils12.decodeJwt)({
1143
1317
  errorMessagePrefix: "Error decoding key attestation JWT:",
1144
1318
  headerSchema: zKeyAttestationHeader,
1145
1319
  jwt: options.keyAttestationJwt,
1146
1320
  payloadSchema: zKeyAttestationPayload
1147
1321
  });
1148
- const { signer } = await (0, import_oauth23.verifyJwt)({
1322
+ const { signer } = await (0, import_io_wallet_utils12.verifyJwt)({
1149
1323
  compact: options.keyAttestationJwt,
1150
1324
  errorMessage: "Key attestation JWT verification failed.",
1151
1325
  header,
1152
1326
  now: options.now,
1153
1327
  payload,
1154
- signer: (0, import_oauth23.jwtSignerFromJwt)({ header, payload }),
1328
+ signer: (0, import_io_wallet_utils12.jwtSignerFromJwt)({ header, payload }),
1155
1329
  verifyJwtCallback: options.callbacks.verifyJwt
1156
1330
  });
1157
1331
  if (options.fetchStatusList) {
@@ -1168,7 +1342,7 @@ async function verifyKeyAttestationJwt(options) {
1168
1342
  }
1169
1343
  return { header, payload, signer };
1170
1344
  } catch (error) {
1171
- if (error instanceof VerifyKeyAttestationJwtError || error instanceof import_io_wallet_utils10.ValidationError || error instanceof import_oauth23.Oauth2JwtParseError) {
1345
+ if (error instanceof VerifyKeyAttestationJwtError || error instanceof import_io_wallet_utils12.ValidationError || error instanceof import_io_wallet_utils12.JwtParseError) {
1172
1346
  throw error;
1173
1347
  }
1174
1348
  throw new VerifyKeyAttestationJwtError(
@@ -1180,15 +1354,15 @@ async function verifyKeyAttestationJwt(options) {
1180
1354
 
1181
1355
  // src/credential-request/verify-credential-request-jwt-proof.ts
1182
1356
  async function isJwkInSet(options) {
1183
- const targetThumbprint = await (0, import_oauth24.calculateJwkThumbprint)({
1184
- hashAlgorithm: import_io_wallet_oauth26.HashAlgorithm.Sha256,
1357
+ const targetThumbprint = await (0, import_io_wallet_utils13.calculateJwkThumbprint)({
1358
+ hashAlgorithm: import_io_wallet_utils13.HashAlgorithm.Sha256,
1185
1359
  hashCallback: options.callbacks.hash,
1186
1360
  jwk: options.jwk
1187
1361
  });
1188
1362
  const thumbprints = await Promise.all(
1189
1363
  options.jwks.map(
1190
- (jwk) => (0, import_oauth24.calculateJwkThumbprint)({
1191
- hashAlgorithm: import_io_wallet_oauth26.HashAlgorithm.Sha256,
1364
+ (jwk) => (0, import_io_wallet_utils13.calculateJwkThumbprint)({
1365
+ hashAlgorithm: import_io_wallet_utils13.HashAlgorithm.Sha256,
1192
1366
  hashCallback: options.callbacks.hash,
1193
1367
  jwk
1194
1368
  })
@@ -1198,7 +1372,7 @@ async function isJwkInSet(options) {
1198
1372
  }
1199
1373
  function verifyProofJwtIatOrThrow(options) {
1200
1374
  try {
1201
- (0, import_io_wallet_utils11.verifyJwtIatOrThrow)({
1375
+ (0, import_io_wallet_utils13.verifyJwtIatOrThrow)({
1202
1376
  iat: options.payload.iat,
1203
1377
  now: options.now
1204
1378
  });
@@ -1212,14 +1386,14 @@ function verifyProofJwtIatOrThrow(options) {
1212
1386
  }
1213
1387
  }
1214
1388
  async function verifyProofV1_0(options) {
1215
- const { header, payload } = (0, import_io_wallet_oauth26.decodeJwt)({
1389
+ const { header, payload } = (0, import_io_wallet_utils13.decodeJwt)({
1216
1390
  errorMessagePrefix: "Error decoding credential request proof JWT:",
1217
1391
  headerSchema: zProofJwtHeaderV1_0,
1218
1392
  jwt: options.jwt,
1219
1393
  payloadSchema: zProofJwtPayload
1220
1394
  });
1221
1395
  verifyProofJwtIatOrThrow({ now: options.now, payload });
1222
- const { signer } = await (0, import_io_wallet_oauth26.verifyJwt)({
1396
+ const { signer } = await (0, import_io_wallet_utils13.verifyJwt)({
1223
1397
  compact: options.jwt,
1224
1398
  errorMessage: "Error verifying credential request proof jwt.",
1225
1399
  expectedAudience: options.credentialIssuer,
@@ -1228,20 +1402,20 @@ async function verifyProofV1_0(options) {
1228
1402
  header,
1229
1403
  now: options.now,
1230
1404
  payload,
1231
- signer: (0, import_oauth24.jwtSignerFromJwt)({ header, payload }),
1405
+ signer: (0, import_io_wallet_utils13.jwtSignerFromJwt)({ header, payload }),
1232
1406
  verifyJwtCallback: options.callbacks.verifyJwt
1233
1407
  });
1234
1408
  return { header, payload, signer };
1235
1409
  }
1236
1410
  async function verifyProofV1_3(options) {
1237
- const { header, payload } = (0, import_io_wallet_oauth26.decodeJwt)({
1411
+ const { header, payload } = (0, import_io_wallet_utils13.decodeJwt)({
1238
1412
  errorMessagePrefix: "Error decoding credential request proof JWT:",
1239
1413
  headerSchema: zProofJwtHeaderV1_3,
1240
1414
  jwt: options.jwt,
1241
1415
  payloadSchema: zProofJwtPayload
1242
1416
  });
1243
1417
  verifyProofJwtIatOrThrow({ now: options.now, payload });
1244
- const { signer } = await (0, import_io_wallet_oauth26.verifyJwt)({
1418
+ const { signer } = await (0, import_io_wallet_utils13.verifyJwt)({
1245
1419
  compact: options.jwt,
1246
1420
  errorMessage: "Error verifying credential request proof jwt.",
1247
1421
  expectedAudience: options.credentialIssuer,
@@ -1250,7 +1424,7 @@ async function verifyProofV1_3(options) {
1250
1424
  header,
1251
1425
  now: options.now,
1252
1426
  payload,
1253
- signer: (0, import_oauth24.jwtSignerFromJwt)({ header, payload }),
1427
+ signer: (0, import_io_wallet_utils13.jwtSignerFromJwt)({ header, payload }),
1254
1428
  verifyJwtCallback: options.callbacks.verifyJwt
1255
1429
  });
1256
1430
  if (options.trustedWalletProviderIssuers.length === 0) {
@@ -1283,10 +1457,11 @@ async function verifyProofV1_3(options) {
1283
1457
  }
1284
1458
  return { header, keyAttestation: keyAttestationResult, payload, signer };
1285
1459
  }
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)
1460
+ var dispatchVerifyProof = (0, import_io_wallet_utils13.createVersionDispatcher)({
1461
+ [import_io_wallet_utils13.ItWalletSpecsVersion.APTITUDE]: (o) => verifyProofV1_3(o),
1462
+ [import_io_wallet_utils13.ItWalletSpecsVersion.V1_0]: (o) => verifyProofV1_0(o),
1463
+ [import_io_wallet_utils13.ItWalletSpecsVersion.V1_3]: (o) => verifyProofV1_3(o),
1464
+ [import_io_wallet_utils13.ItWalletSpecsVersion.V1_4]: (o) => verifyProofV1_3(o)
1290
1465
  });
1291
1466
  async function verifyCredentialRequestJwtProof(options) {
1292
1467
  try {
@@ -1298,7 +1473,7 @@ async function verifyCredentialRequestJwtProof(options) {
1298
1473
  }
1299
1474
  return await dispatchVerifyProof({ ...options, now });
1300
1475
  } 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) {
1476
+ 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
1477
  throw error;
1303
1478
  }
1304
1479
  throw new VerifyCredentialRequestJwtProofError(
@@ -1309,36 +1484,36 @@ async function verifyCredentialRequestJwtProof(options) {
1309
1484
  }
1310
1485
 
1311
1486
  // src/credential-response/create-credential-response.ts
1312
- var import_io_wallet_utils14 = require("@pagopa/io-wallet-utils");
1487
+ var import_io_wallet_utils16 = require("@pagopa/io-wallet-utils");
1313
1488
 
1314
1489
  // src/credential-response/v1.0/create-credential-response.ts
1315
- var import_io_wallet_utils12 = require("@pagopa/io-wallet-utils");
1490
+ var import_io_wallet_utils14 = require("@pagopa/io-wallet-utils");
1316
1491
 
1317
1492
  // src/credential-response/v1.0/z-credential-response.ts
1318
- var import_zod11 = require("zod");
1493
+ var import_zod12 = require("zod");
1319
1494
 
1320
1495
  // src/credential-response/z-immediate-credential-response.ts
1321
- var import_zod10 = require("zod");
1322
- var zCredentialObject = import_zod10.z.object({
1323
- credential: import_zod10.z.string()
1496
+ var import_zod11 = require("zod");
1497
+ var zCredentialObject = import_zod11.z.object({
1498
+ credential: import_zod11.z.string()
1324
1499
  });
1325
- var zImmediateCredentialResponse = import_zod10.z.strictObject({
1326
- credentials: import_zod10.z.array(zCredentialObject).nonempty().describe(
1500
+ var zImmediateCredentialResponse = import_zod11.z.strictObject({
1501
+ credentials: import_zod11.z.array(zCredentialObject).nonempty().describe(
1327
1502
  "Conditional. Array of issued Digital Credentials as JSON objects with `credential` member containing encoded credential string. Present for immediate issuance (HTTP 200)."
1328
1503
  ),
1329
- notification_id: import_zod10.z.string().optional().describe(
1504
+ notification_id: import_zod11.z.string().optional().describe(
1330
1505
  "OPTIONAL. Identifier for notification requests. Only present with credentials parameter."
1331
1506
  )
1332
1507
  });
1333
1508
 
1334
1509
  // src/credential-response/v1.0/z-credential-response.ts
1335
- var zDeferredCredentialResponseV1_0 = import_zod11.z.strictObject({
1336
- lead_time: import_zod11.z.number().int().positive().describe(
1510
+ var zDeferredCredentialResponseV1_0 = import_zod12.z.strictObject({
1511
+ lead_time: import_zod12.z.number().int().positive().describe(
1337
1512
  "REQUIRED if credentials is not present, otherwise it MUST NOT be present. The amount of time (in seconds) required before making a Deferred Credential Request."
1338
1513
  ),
1339
- transaction_id: import_zod11.z.string().nonempty()
1514
+ transaction_id: import_zod12.z.string().nonempty()
1340
1515
  });
1341
- var zCredentialResponseV1_0 = import_zod11.z.union([
1516
+ var zCredentialResponseV1_0 = import_zod12.z.union([
1342
1517
  zImmediateCredentialResponse,
1343
1518
  zDeferredCredentialResponseV1_0
1344
1519
  ]);
@@ -1346,7 +1521,7 @@ var zCredentialResponseV1_0 = import_zod11.z.union([
1346
1521
  // src/credential-response/v1.0/create-credential-response.ts
1347
1522
  function createCredentialResponseV1_0(flow) {
1348
1523
  if ("credentials" in flow) {
1349
- return (0, import_io_wallet_utils12.parseWithErrorHandling)(
1524
+ return (0, import_io_wallet_utils14.parseWithErrorHandling)(
1350
1525
  zCredentialResponseV1_0,
1351
1526
  {
1352
1527
  credentials: flow.credentials,
@@ -1357,7 +1532,7 @@ function createCredentialResponseV1_0(flow) {
1357
1532
  "Invalid credential response for ItWalletSpecsVersion 1.0"
1358
1533
  );
1359
1534
  }
1360
- return (0, import_io_wallet_utils12.parseWithErrorHandling)(
1535
+ return (0, import_io_wallet_utils14.parseWithErrorHandling)(
1361
1536
  zCredentialResponseV1_0,
1362
1537
  {
1363
1538
  lead_time: flow.leadTime,
@@ -1368,17 +1543,17 @@ function createCredentialResponseV1_0(flow) {
1368
1543
  }
1369
1544
 
1370
1545
  // src/credential-response/v1.3/create-credential-response.ts
1371
- var import_io_wallet_utils13 = require("@pagopa/io-wallet-utils");
1546
+ var import_io_wallet_utils15 = require("@pagopa/io-wallet-utils");
1372
1547
 
1373
1548
  // src/credential-response/v1.3/z-credential-response.ts
1374
- var import_zod12 = require("zod");
1375
- var zDeferredCredentialResponseV1_3 = import_zod12.z.strictObject({
1376
- interval: import_zod12.z.number().int().positive().describe(
1549
+ var import_zod13 = require("zod");
1550
+ var zDeferredCredentialResponseV1_3 = import_zod13.z.strictObject({
1551
+ interval: import_zod13.z.number().int().positive().describe(
1377
1552
  "REQUIRED if transaction_id is present, otherwise it MUST NOT be present. The amount of time (in seconds) required before making a Deferred Credential Request"
1378
1553
  ),
1379
- transaction_id: import_zod12.z.string().nonempty()
1554
+ transaction_id: import_zod13.z.string().nonempty()
1380
1555
  });
1381
- var zCredentialResponseV1_3 = import_zod12.z.union([
1556
+ var zCredentialResponseV1_3 = import_zod13.z.union([
1382
1557
  zImmediateCredentialResponse,
1383
1558
  zDeferredCredentialResponseV1_3
1384
1559
  ]);
@@ -1386,7 +1561,7 @@ var zCredentialResponseV1_3 = import_zod12.z.union([
1386
1561
  // src/credential-response/v1.3/create-credential-response.ts
1387
1562
  function createCredentialResponseV1_3(flow) {
1388
1563
  if ("credentials" in flow) {
1389
- return (0, import_io_wallet_utils13.parseWithErrorHandling)(
1564
+ return (0, import_io_wallet_utils15.parseWithErrorHandling)(
1390
1565
  zCredentialResponseV1_3,
1391
1566
  {
1392
1567
  credentials: flow.credentials,
@@ -1397,7 +1572,7 @@ function createCredentialResponseV1_3(flow) {
1397
1572
  "Invalid credential response for ItWalletSpecsVersion 1.3"
1398
1573
  );
1399
1574
  }
1400
- return (0, import_io_wallet_utils13.parseWithErrorHandling)(
1575
+ return (0, import_io_wallet_utils15.parseWithErrorHandling)(
1401
1576
  zCredentialResponseV1_3,
1402
1577
  {
1403
1578
  interval: flow.interval,
@@ -1408,14 +1583,17 @@ function createCredentialResponseV1_3(flow) {
1408
1583
  }
1409
1584
 
1410
1585
  // 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(
1586
+ var dispatchBuildVersionedResponse = (0, import_io_wallet_utils16.createVersionDispatcher)({
1587
+ [import_io_wallet_utils16.ItWalletSpecsVersion.APTITUDE]: (o) => createCredentialResponseV1_3(
1413
1588
  o.flow
1414
1589
  ),
1415
- [import_io_wallet_utils14.ItWalletSpecsVersion.V1_3]: (o) => createCredentialResponseV1_3(
1590
+ [import_io_wallet_utils16.ItWalletSpecsVersion.V1_0]: (o) => createCredentialResponseV1_0(
1416
1591
  o.flow
1417
1592
  ),
1418
- [import_io_wallet_utils14.ItWalletSpecsVersion.V1_4]: (o) => createCredentialResponseV1_3(
1593
+ [import_io_wallet_utils16.ItWalletSpecsVersion.V1_3]: (o) => createCredentialResponseV1_3(
1594
+ o.flow
1595
+ ),
1596
+ [import_io_wallet_utils16.ItWalletSpecsVersion.V1_4]: (o) => createCredentialResponseV1_3(
1419
1597
  o.flow
1420
1598
  // V1_4 reuses V1_3 credential response schema — no breaking changes between versions.
1421
1599
  // Verified against compare/1.3.3...1.4.1: credential response parameters identical.
@@ -1440,7 +1618,7 @@ async function createCredentialResponse(options) {
1440
1618
  }
1441
1619
  return { credentialResponse, credentialResponseJwt };
1442
1620
  } catch (error) {
1443
- if (error instanceof import_io_wallet_utils14.ValidationError || error instanceof Oid4vciError) {
1621
+ if (error instanceof import_io_wallet_utils16.ValidationError || error instanceof Oid4vciError) {
1444
1622
  throw error;
1445
1623
  }
1446
1624
  throw new CreateCredentialResponseError(
@@ -1464,49 +1642,49 @@ async function encryptResponse(credentialResponse, credentialResponseEncryption,
1464
1642
  }
1465
1643
 
1466
1644
  // src/credential-response/fetch-credential-response.ts
1467
- var import_io_wallet_utils15 = require("@pagopa/io-wallet-utils");
1645
+ var import_io_wallet_utils18 = require("@pagopa/io-wallet-utils");
1468
1646
 
1469
1647
  // src/credential-response/z-credential-response.ts
1470
- var import_io_wallet_oauth27 = require("@pagopa/io-wallet-oauth2");
1471
- var import_zod13 = require("zod");
1472
- var zCredentialResponseEncryption = import_zod13.z.looseObject({
1473
- alg: import_io_wallet_oauth27.zAlgValueNotNone,
1474
- enc: import_zod13.z.string(),
1475
- jwk: import_io_wallet_oauth27.zJwk
1648
+ var import_io_wallet_utils17 = require("@pagopa/io-wallet-utils");
1649
+ var import_zod14 = require("zod");
1650
+ var zCredentialResponseEncryption = import_zod14.z.looseObject({
1651
+ alg: import_io_wallet_utils17.zAlgValueNotNone,
1652
+ enc: import_zod14.z.string(),
1653
+ jwk: import_io_wallet_utils17.zJwk
1476
1654
  });
1477
1655
 
1478
1656
  // src/credential-response/fetch-credential-response.ts
1479
1657
  async function fetchCredentialResponse(options) {
1480
1658
  try {
1481
- const fetch = (0, import_io_wallet_utils15.createFetcher)(options.callbacks.fetch);
1659
+ const fetch = (0, import_io_wallet_utils18.createFetcher)(options.callbacks.fetch);
1482
1660
  const credentialResponse = await fetch(options.credentialEndpoint, {
1483
1661
  body: JSON.stringify(options.credentialRequest),
1484
1662
  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
1663
+ [import_io_wallet_utils18.HEADERS.AUTHORIZATION]: `DPoP ${options.accessToken}`,
1664
+ [import_io_wallet_utils18.HEADERS.CONTENT_TYPE]: import_io_wallet_utils18.CONTENT_TYPES.JSON,
1665
+ [import_io_wallet_utils18.HEADERS.DPOP]: options.dPoP
1488
1666
  },
1489
1667
  method: "POST"
1490
1668
  });
1491
- await (0, import_io_wallet_utils15.hasStatusOrThrow)(
1669
+ await (0, import_io_wallet_utils18.hasStatusOrThrow)(
1492
1670
  [200, 202],
1493
- import_io_wallet_utils15.UnexpectedStatusCodeError
1671
+ import_io_wallet_utils18.UnexpectedStatusCodeError
1494
1672
  )(credentialResponse);
1495
1673
  const credentialResponseJson = await credentialResponse.json();
1496
1674
  if ("proof" in options.credentialRequest) {
1497
- return (0, import_io_wallet_utils15.parseWithErrorHandling)(
1675
+ return (0, import_io_wallet_utils18.parseWithErrorHandling)(
1498
1676
  zCredentialResponseV1_0,
1499
1677
  credentialResponseJson,
1500
1678
  `Failed to parse credential response (v1.0)`
1501
1679
  );
1502
1680
  }
1503
- return (0, import_io_wallet_utils15.parseWithErrorHandling)(
1681
+ return (0, import_io_wallet_utils18.parseWithErrorHandling)(
1504
1682
  zCredentialResponseV1_3,
1505
1683
  credentialResponseJson,
1506
1684
  `Failed to parse credential response (v1.3)`
1507
1685
  );
1508
1686
  } catch (error) {
1509
- if (error instanceof import_io_wallet_utils15.UnexpectedStatusCodeError || error instanceof import_io_wallet_utils15.ValidationError) {
1687
+ if (error instanceof import_io_wallet_utils18.UnexpectedStatusCodeError || error instanceof import_io_wallet_utils18.ValidationError) {
1510
1688
  throw error;
1511
1689
  }
1512
1690
  throw new FetchCredentialResponseError(
@@ -1516,40 +1694,39 @@ async function fetchCredentialResponse(options) {
1516
1694
  }
1517
1695
 
1518
1696
  // src/metadata/fetch-metadata.ts
1519
- var import_io_wallet_oauth28 = require("@pagopa/io-wallet-oauth2");
1520
1697
  var import_io_wallet_oid_federation3 = require("@pagopa/io-wallet-oid-federation");
1521
- var import_io_wallet_utils16 = require("@pagopa/io-wallet-utils");
1522
- var import_zod15 = __toESM(require("zod"));
1698
+ var import_io_wallet_utils19 = require("@pagopa/io-wallet-utils");
1699
+ var import_zod16 = __toESM(require("zod"));
1523
1700
 
1524
1701
  // src/metadata/z-metadata-response.ts
1525
1702
  var import_io_wallet_oid_federation2 = require("@pagopa/io-wallet-oid-federation");
1526
- var import_zod14 = require("zod");
1527
- var zMetadataResponseV1_0 = import_zod14.z.object({
1528
- discoveredVia: import_zod14.z.enum(["federation"]),
1703
+ var import_zod15 = require("zod");
1704
+ var zMetadataResponseV1_0 = import_zod15.z.object({
1705
+ discoveredVia: import_zod15.z.enum(["federation"]),
1529
1706
  metadata: import_io_wallet_oid_federation2.itWalletMetadataV1_0,
1530
1707
  openid_federation_claims: import_io_wallet_oid_federation2.itWalletEntityStatementClaimsSchema
1531
1708
  });
1532
- var zMetadataResponseV1_3 = import_zod14.z.object({
1709
+ var zMetadataResponseV1_3 = import_zod15.z.object({
1533
1710
  /**
1534
1711
  * Entity statement claims of the Authorization Server, present only when the
1535
1712
  * selected authorization server was resolved through a federation entity
1536
1713
  * distinct from the Credential Issuer.
1537
1714
  */
1538
1715
  authorization_server_federation_claims: import_io_wallet_oid_federation2.itWalletEntityStatementClaimsSchema.optional(),
1539
- discoveredVia: import_zod14.z.enum(["federation", "oid4vci"]),
1716
+ discoveredVia: import_zod15.z.enum(["federation", "oid4vci"]),
1540
1717
  metadata: import_io_wallet_oid_federation2.itWalletMetadataV1_3,
1541
1718
  openid_federation_claims: import_io_wallet_oid_federation2.itWalletEntityStatementClaimsSchema.optional()
1542
1719
  });
1543
1720
  var zMetadataResponseV1_4 = zMetadataResponseV1_3.extend({
1544
1721
  metadata: import_io_wallet_oid_federation2.itWalletMetadataV1_4
1545
1722
  });
1546
- var zMetadataResponse = import_zod14.z.union([
1723
+ var zMetadataResponse = import_zod15.z.union([
1547
1724
  zMetadataResponseV1_0,
1548
1725
  zMetadataResponseV1_3,
1549
1726
  zMetadataResponseV1_4
1550
1727
  ]);
1551
- var zPartialIssuerMetadata = import_zod14.z.looseObject({
1552
- authorization_servers: import_zod14.z.tuple([import_zod14.z.url()], import_zod14.z.url()).optional()
1728
+ var zPartialIssuerMetadata = import_zod15.z.looseObject({
1729
+ authorization_servers: import_zod15.z.tuple([import_zod15.z.url()], import_zod15.z.url()).optional()
1553
1730
  });
1554
1731
 
1555
1732
  // src/metadata/fetch-metadata.ts
@@ -1567,7 +1744,7 @@ async function tryFederationDiscovery(fetch, baseUrl, verifyJwt4) {
1567
1744
  return void 0;
1568
1745
  }
1569
1746
  const entityStatement = await response.text();
1570
- const { header, payload } = (0, import_io_wallet_oauth28.decodeJwt)({
1747
+ const { header, payload } = (0, import_io_wallet_utils19.decodeJwt)({
1571
1748
  errorMessagePrefix: "Error decoding entity statement JWT:",
1572
1749
  jwt: entityStatement,
1573
1750
  payloadSchema: import_io_wallet_oid_federation3.itWalletEntityStatementClaimsSchema
@@ -1584,7 +1761,7 @@ async function tryFederationDiscovery(fetch, baseUrl, verifyJwt4) {
1584
1761
  payload
1585
1762
  });
1586
1763
  if (!result.verified) {
1587
- throw new import_io_wallet_utils16.ValidationError(
1764
+ throw new import_io_wallet_utils19.ValidationError(
1588
1765
  "Entity statement signature verification failed"
1589
1766
  );
1590
1767
  }
@@ -1595,7 +1772,7 @@ async function tryFederationDiscovery(fetch, baseUrl, verifyJwt4) {
1595
1772
  openid_federation_claims: payload
1596
1773
  };
1597
1774
  } catch (error) {
1598
- if (error instanceof import_io_wallet_utils16.ValidationError) {
1775
+ if (error instanceof import_io_wallet_utils19.ValidationError) {
1599
1776
  throw error;
1600
1777
  }
1601
1778
  return void 0;
@@ -1616,9 +1793,9 @@ async function applyFederationAuthorizationServerSelection(fetch, federationResu
1616
1793
  if (!selectedAuthorizationServer || selectedAuthorizationServer === credentialIssuer) {
1617
1794
  return federationResult;
1618
1795
  }
1619
- const parsedSelectedAuthorizationServer = import_zod15.default.url().safeParse(selectedAuthorizationServer);
1796
+ const parsedSelectedAuthorizationServer = import_zod16.default.url().safeParse(selectedAuthorizationServer);
1620
1797
  if (!parsedSelectedAuthorizationServer.success || !parsedSelectedAuthorizationServer.data.startsWith("https://")) {
1621
- throw new import_io_wallet_utils16.ValidationError(
1798
+ throw new import_io_wallet_utils19.ValidationError(
1622
1799
  "selected authorization server is not a valid HTTPS URL"
1623
1800
  );
1624
1801
  }
@@ -1628,7 +1805,7 @@ async function applyFederationAuthorizationServerSelection(fetch, federationResu
1628
1805
  verifyJwt4
1629
1806
  );
1630
1807
  if (!authorizationServerResult) {
1631
- throw new import_io_wallet_utils16.ValidationError(
1808
+ throw new import_io_wallet_utils19.ValidationError(
1632
1809
  `Federation discovery did not yield OpenID Federation metadata for authorization server '${selectedAuthorizationServer}'`
1633
1810
  );
1634
1811
  }
@@ -1643,8 +1820,8 @@ async function fallbackDiscovery(fetch, baseUrl, authorizationServer) {
1643
1820
  ensureTrailingSlash(baseUrl)
1644
1821
  ).toString();
1645
1822
  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)(
1823
+ await (0, import_io_wallet_utils19.hasStatusOrThrow)(200, import_io_wallet_utils19.UnexpectedStatusCodeError)(issuerResponse);
1824
+ const issuerJson = (0, import_io_wallet_utils19.parseWithErrorHandling)(
1648
1825
  zPartialIssuerMetadata,
1649
1826
  await issuerResponse.json(),
1650
1827
  "Failed to parse credential issuer metadata"
@@ -1654,9 +1831,9 @@ async function fallbackDiscovery(fetch, baseUrl, authorizationServer) {
1654
1831
  let oauthAuthorizationServer;
1655
1832
  if (authorizationServers && authorizationServers.length > 0) {
1656
1833
  const selectedAuthorizationServer = authorizationServer ?? authorizationServers[0];
1657
- const parsedUrl = import_zod15.default.url().safeParse(selectedAuthorizationServer);
1834
+ const parsedUrl = import_zod16.default.url().safeParse(selectedAuthorizationServer);
1658
1835
  if (!parsedUrl.success || !parsedUrl.data.startsWith("https://")) {
1659
- throw new import_io_wallet_utils16.ValidationError(
1836
+ throw new import_io_wallet_utils19.ValidationError(
1660
1837
  "selected authorization server is not a valid HTTPS URL"
1661
1838
  );
1662
1839
  }
@@ -1665,7 +1842,7 @@ async function fallbackDiscovery(fetch, baseUrl, authorizationServer) {
1665
1842
  ensureTrailingSlash(parsedUrl.data)
1666
1843
  ).toString();
1667
1844
  const authServerResponse = await fetch(authServerUrl);
1668
- await (0, import_io_wallet_utils16.hasStatusOrThrow)(200, import_io_wallet_utils16.UnexpectedStatusCodeError)(authServerResponse);
1845
+ await (0, import_io_wallet_utils19.hasStatusOrThrow)(200, import_io_wallet_utils19.UnexpectedStatusCodeError)(authServerResponse);
1669
1846
  oauthAuthorizationServer = await authServerResponse.json();
1670
1847
  } else {
1671
1848
  oauthAuthorizationServer = issuerJson;
@@ -1679,7 +1856,7 @@ async function fallbackDiscovery(fetch, baseUrl, authorizationServer) {
1679
1856
  };
1680
1857
  }
1681
1858
  var fetchMetadataWithFallbackDiscovery = async (options) => {
1682
- const fetch = (0, import_io_wallet_utils16.createFetcher)(options.callbacks.fetch);
1859
+ const fetch = (0, import_io_wallet_utils19.createFetcher)(options.callbacks.fetch);
1683
1860
  const federationResult = await tryFederationDiscovery(
1684
1861
  fetch,
1685
1862
  options.credentialIssuerUrl,
@@ -1698,7 +1875,7 @@ var fetchMetadataWithFallbackDiscovery = async (options) => {
1698
1875
  return raw;
1699
1876
  };
1700
1877
  async function fetchMetadataV1_0(options) {
1701
- const fetch = (0, import_io_wallet_utils16.createFetcher)(options.callbacks.fetch);
1878
+ const fetch = (0, import_io_wallet_utils19.createFetcher)(options.callbacks.fetch);
1702
1879
  const federationResult = await tryFederationDiscovery(
1703
1880
  fetch,
1704
1881
  options.credentialIssuerUrl,
@@ -1709,7 +1886,7 @@ async function fetchMetadataV1_0(options) {
1709
1886
  `Federation discovery failed for IT Wallet v1.0; no fallback available for credentialIssuerUrl ${options.credentialIssuerUrl}`
1710
1887
  );
1711
1888
  }
1712
- return (0, import_io_wallet_utils16.parseWithErrorHandling)(
1889
+ return (0, import_io_wallet_utils19.parseWithErrorHandling)(
1713
1890
  zMetadataResponseV1_0,
1714
1891
  federationResult,
1715
1892
  "Failed to parse v1.0 metadata response"
@@ -1717,7 +1894,7 @@ async function fetchMetadataV1_0(options) {
1717
1894
  }
1718
1895
  async function fetchMetadataV1_3(options) {
1719
1896
  const raw = await fetchMetadataWithFallbackDiscovery(options);
1720
- return (0, import_io_wallet_utils16.parseWithErrorHandling)(
1897
+ return (0, import_io_wallet_utils19.parseWithErrorHandling)(
1721
1898
  zMetadataResponseV1_3,
1722
1899
  raw,
1723
1900
  "Failed to parse v1.3 metadata response"
@@ -1725,28 +1902,29 @@ async function fetchMetadataV1_3(options) {
1725
1902
  }
1726
1903
  async function fetchMetadataV1_4(options) {
1727
1904
  const raw = await fetchMetadataWithFallbackDiscovery(options);
1728
- return (0, import_io_wallet_utils16.parseWithErrorHandling)(
1905
+ return (0, import_io_wallet_utils19.parseWithErrorHandling)(
1729
1906
  zMetadataResponseV1_4,
1730
1907
  raw,
1731
1908
  "Failed to parse v1.4 metadata response"
1732
1909
  );
1733
1910
  }
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)
1911
+ var dispatchFetchMetadata = (0, import_io_wallet_utils19.createVersionDispatcher)({
1912
+ [import_io_wallet_utils19.ItWalletSpecsVersion.APTITUDE]: (o) => fetchMetadataV1_4(o),
1913
+ [import_io_wallet_utils19.ItWalletSpecsVersion.V1_0]: (o) => fetchMetadataV1_0(o),
1914
+ [import_io_wallet_utils19.ItWalletSpecsVersion.V1_3]: (o) => fetchMetadataV1_3(o),
1915
+ [import_io_wallet_utils19.ItWalletSpecsVersion.V1_4]: (o) => fetchMetadataV1_4(o)
1738
1916
  });
1739
1917
  async function fetchMetadata(options) {
1740
1918
  try {
1741
- const urlValidation = import_zod15.default.url().safeParse(options.credentialIssuerUrl);
1919
+ const urlValidation = import_zod16.default.url().safeParse(options.credentialIssuerUrl);
1742
1920
  if (!urlValidation.success || !urlValidation.data.startsWith("https://")) {
1743
- throw new import_io_wallet_utils16.ValidationError(
1921
+ throw new import_io_wallet_utils19.ValidationError(
1744
1922
  "credentialIssuerUrl must be a valid HTTPS URL"
1745
1923
  );
1746
1924
  }
1747
1925
  return await dispatchFetchMetadata(options);
1748
1926
  } 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) {
1927
+ 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
1928
  throw error;
1751
1929
  }
1752
1930
  throw new FetchMetadataError("Unexpected error during metadata fetch", {
@@ -1756,8 +1934,8 @@ async function fetchMetadata(options) {
1756
1934
  }
1757
1935
 
1758
1936
  // 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");
1937
+ var import_io_wallet_oauth23 = require("@pagopa/io-wallet-oauth2");
1938
+ var import_io_wallet_utils20 = require("@pagopa/io-wallet-utils");
1761
1939
  function assertV1_0Options(options) {
1762
1940
  if (options.signer.method !== "federation") {
1763
1941
  throw new WalletProviderError(
@@ -1815,7 +1993,7 @@ var WalletProvider = class {
1815
1993
  const { signJwt } = options.callbacks;
1816
1994
  const now = /* @__PURE__ */ new Date();
1817
1995
  const issuedAt = options.issuedAt ?? now;
1818
- const expiresAt = options.expiresAt ?? (0, import_io_wallet_utils17.addSecondsToDate)(now, 3600 * 24 * 360);
1996
+ const expiresAt = options.expiresAt ?? (0, import_io_wallet_utils20.addSecondsToDate)(now, 3600 * 24 * 360);
1819
1997
  const header = {
1820
1998
  alg: options.signer.alg,
1821
1999
  kid: options.signer.kid,
@@ -1825,8 +2003,8 @@ var WalletProvider = class {
1825
2003
  };
1826
2004
  const payload = {
1827
2005
  attested_keys: options.attestedKeys,
1828
- exp: (0, import_io_wallet_utils17.dateToSeconds)(expiresAt),
1829
- iat: (0, import_io_wallet_utils17.dateToSeconds)(issuedAt),
2006
+ exp: (0, import_io_wallet_utils20.dateToSeconds)(expiresAt),
2007
+ iat: (0, import_io_wallet_utils20.dateToSeconds)(issuedAt),
1830
2008
  iss: options.issuer,
1831
2009
  key_storage: options.keyStorage,
1832
2010
  status: options.status,
@@ -1890,7 +2068,7 @@ var WalletProvider = class {
1890
2068
  * status: { status_list: { idx: 2, uri: "https://status.example.com" } } // Optional
1891
2069
  * });
1892
2070
  *
1893
- * @example v1.4 - Wallet attestation with required wallet_link and wallet_name
2071
+ * @example v1.4, APTITUDE - Wallet attestation with required wallet_link and wallet_name
1894
2072
  * const jwt = await provider.createItWalletAttestationJwt({
1895
2073
  * callbacks: { hash: myHashCallback, signJwt: mySignJwtCallback },
1896
2074
  * dpopJwkPublic: myJwk,
@@ -1908,10 +2086,22 @@ var WalletProvider = class {
1908
2086
  * });
1909
2087
  */
1910
2088
  async createItWalletAttestationJwt(options) {
1911
- return (0, import_io_wallet_utils17.dispatchByVersion)(this.specVersion, {
1912
- [import_io_wallet_utils17.ItWalletSpecsVersion.V1_0]: () => {
2089
+ return (0, import_io_wallet_utils20.dispatchByVersion)(this.specVersion, {
2090
+ [import_io_wallet_utils20.ItWalletSpecsVersion.APTITUDE]: () => {
2091
+ assertV1_4Options(options);
2092
+ return (0, import_io_wallet_oauth23.createWalletAttestationJwtV1_4)({
2093
+ callbacks: options.callbacks,
2094
+ dpopJwkPublic: options.dpopJwkPublic,
2095
+ expiresAt: options.expiresAt,
2096
+ issuer: options.issuer,
2097
+ signer: options.signer,
2098
+ walletLink: options.walletLink,
2099
+ walletName: options.walletName
2100
+ });
2101
+ },
2102
+ [import_io_wallet_utils20.ItWalletSpecsVersion.V1_0]: () => {
1913
2103
  assertV1_0Options(options);
1914
- return (0, import_io_wallet_oauth29.createWalletAttestationJwtV1_0)({
2104
+ return (0, import_io_wallet_oauth23.createWalletAttestationJwtV1_0)({
1915
2105
  authenticatorAssuranceLevel: options.authenticatorAssuranceLevel,
1916
2106
  callbacks: options.callbacks,
1917
2107
  dpopJwkPublic: options.dpopJwkPublic,
@@ -1922,9 +2112,9 @@ var WalletProvider = class {
1922
2112
  walletName: options.walletName
1923
2113
  });
1924
2114
  },
1925
- [import_io_wallet_utils17.ItWalletSpecsVersion.V1_3]: () => {
2115
+ [import_io_wallet_utils20.ItWalletSpecsVersion.V1_3]: () => {
1926
2116
  assertV1_3Options(options);
1927
- return (0, import_io_wallet_oauth29.createWalletAttestationJwtV1_3)({
2117
+ return (0, import_io_wallet_oauth23.createWalletAttestationJwtV1_3)({
1928
2118
  callbacks: options.callbacks,
1929
2119
  dpopJwkPublic: options.dpopJwkPublic,
1930
2120
  expiresAt: options.expiresAt,
@@ -1936,9 +2126,9 @@ var WalletProvider = class {
1936
2126
  walletName: options.walletName
1937
2127
  });
1938
2128
  },
1939
- [import_io_wallet_utils17.ItWalletSpecsVersion.V1_4]: () => {
2129
+ [import_io_wallet_utils20.ItWalletSpecsVersion.V1_4]: () => {
1940
2130
  assertV1_4Options(options);
1941
- return (0, import_io_wallet_oauth29.createWalletAttestationJwtV1_4)({
2131
+ return (0, import_io_wallet_oauth23.createWalletAttestationJwtV1_4)({
1942
2132
  callbacks: options.callbacks,
1943
2133
  dpopJwkPublic: options.dpopJwkPublic,
1944
2134
  expiresAt: options.expiresAt,
@@ -1953,6 +2143,7 @@ var WalletProvider = class {
1953
2143
  };
1954
2144
  // Annotate the CommonJS export names for ESM import in node:
1955
2145
  0 && (module.exports = {
2146
+ CREDENTIAL_OFFER_GRANTS,
1956
2147
  CreateCredentialResponseError,
1957
2148
  CredentialAuthorizationHeaderError,
1958
2149
  CredentialOfferError,