@pagopa/io-wallet-oid4vci 2.0.0-launchpad → 2.0.1-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,
@@ -285,6 +286,91 @@ 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
375
  var import_io_wallet_utils3 = require("@pagopa/io-wallet-utils");
290
376
  function requireAuthorizationCodeGrant(credentialOffer) {
@@ -297,33 +383,70 @@ 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
439
  var dispatchExtractGrantDetails = (0, import_io_wallet_utils3.createVersionDispatcher)({
440
+ [import_io_wallet_utils3.ItWalletSpecsVersion.APTITUDE]: (o) => extractGrantDetailsAPTITUDE(o),
322
441
  [import_io_wallet_utils3.ItWalletSpecsVersion.V1_0]: () => {
323
442
  throw new import_io_wallet_utils3.ItWalletSpecsVersionError(
324
443
  "extractGrantDetails",
325
444
  import_io_wallet_utils3.ItWalletSpecsVersion.V1_0,
326
- [import_io_wallet_utils3.ItWalletSpecsVersion.V1_3, import_io_wallet_utils3.ItWalletSpecsVersion.V1_4]
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
452
  [import_io_wallet_utils3.ItWalletSpecsVersion.V1_3]: (o) => extractGrantDetailsV1_3(o),
@@ -334,46 +457,46 @@ function extractGrantDetails(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
  });
@@ -482,11 +605,17 @@ function parseCredentialOfferForVersion(config, data) {
482
605
  return zCredentialOfferV1_3.parse(data);
483
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
611
  throw new import_io_wallet_utils4.ItWalletSpecsVersionError(
487
612
  "resolveCredentialOffer",
488
613
  config.itWalletSpecsVersion,
489
- [import_io_wallet_utils4.ItWalletSpecsVersion.V1_3, import_io_wallet_utils4.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
  }
@@ -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,30 +711,57 @@ 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
+ );
732
+ }
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
+ );
597
751
  }
598
752
  var dispatchValidateCredentialOffer = (0, import_io_wallet_utils5.createVersionDispatcher)({
753
+ [import_io_wallet_utils5.ItWalletSpecsVersion.APTITUDE]: (o) => validateCredentialOfferAPTITUDE(
754
+ o
755
+ ),
599
756
  [import_io_wallet_utils5.ItWalletSpecsVersion.V1_0]: () => {
600
757
  throw new import_io_wallet_utils5.ItWalletSpecsVersionError(
601
758
  "validateCredentialOffer",
602
759
  import_io_wallet_utils5.ItWalletSpecsVersion.V1_0,
603
- [import_io_wallet_utils5.ItWalletSpecsVersion.V1_3, import_io_wallet_utils5.ItWalletSpecsVersion.V1_4]
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
767
  [import_io_wallet_utils5.ItWalletSpecsVersion.V1_3]: (o) => validateCredentialOfferV1_3(o),
@@ -617,18 +778,18 @@ var import_io_wallet_utils8 = require("@pagopa/io-wallet-utils");
617
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({
@@ -701,10 +862,10 @@ var createCredentialRequest = async (options) => {
701
862
  var import_io_wallet_utils7 = require("@pagopa/io-wallet-utils");
702
863
 
703
864
  // src/credential-request/v1.3/z-credential.ts
704
- var import_zod7 = require("zod");
705
- var zCredentialRequestProofJwt = import_zod7.z.string().min(1, "JWT must not be empty in credential request proofs array");
706
- var zCredentialRequestProofs = import_zod7.z.object({
707
- 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)
708
869
  });
709
870
  var zCredentialRequestV1_3 = zBaseCredentialRequest.extend({
710
871
  proofs: zCredentialRequestProofs.describe(
@@ -788,6 +949,7 @@ var createCredentialRequest2 = async (options) => {
788
949
 
789
950
  // src/credential-request/create-credential-request.ts
790
951
  var dispatchCreateCredentialRequest = (0, import_io_wallet_utils8.createVersionDispatcher)({
952
+ [import_io_wallet_utils8.ItWalletSpecsVersion.APTITUDE]: (o) => createCredentialRequest2(o),
791
953
  [import_io_wallet_utils8.ItWalletSpecsVersion.V1_0]: (o) => createCredentialRequest(o),
792
954
  [import_io_wallet_utils8.ItWalletSpecsVersion.V1_3]: (o) => createCredentialRequest2(o),
793
955
  [import_io_wallet_utils8.ItWalletSpecsVersion.V1_4]: (o) => (
@@ -806,21 +968,21 @@ var import_io_wallet_utils10 = require("@pagopa/io-wallet-utils");
806
968
 
807
969
  // src/credential-request/z-proof-jwt.ts
808
970
  var import_io_wallet_utils9 = require("@pagopa/io-wallet-utils");
809
- var import_zod8 = require("zod");
810
- var zBaseProofJwtHeader = import_zod8.z.object({
811
- alg: import_zod8.z.string().min(1),
971
+ var import_zod9 = require("zod");
972
+ var zBaseProofJwtHeader = import_zod9.z.object({
973
+ alg: import_zod9.z.string().min(1),
812
974
  jwk: import_io_wallet_utils9.zJwk,
813
- typ: import_zod8.z.literal("openid4vci-proof+jwt")
975
+ typ: import_zod9.z.literal("openid4vci-proof+jwt")
814
976
  });
815
977
  var zProofJwtHeaderV1_0 = zBaseProofJwtHeader.loose();
816
978
  var zProofJwtHeaderV1_3 = zBaseProofJwtHeader.extend({
817
- key_attestation: import_zod8.z.string().min(1)
979
+ key_attestation: import_zod9.z.string().min(1)
818
980
  }).loose();
819
- var zProofJwtPayload = import_zod8.z.looseObject({
820
- aud: import_zod8.z.string().min(1),
821
- iat: import_zod8.z.number(),
822
- iss: import_zod8.z.string().min(1).optional(),
823
- 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)
824
986
  });
825
987
 
826
988
  // src/credential-request/parse-credential-request.ts
@@ -1063,7 +1225,25 @@ function parseCredentialRequestV1_4(options) {
1063
1225
  // V1_4 reuses V1_3 proof schema
1064
1226
  });
1065
1227
  }
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
+ }
1066
1245
  var dispatchParseCredentialRequest = (0, import_io_wallet_utils10.createVersionDispatcher)({
1246
+ [import_io_wallet_utils10.ItWalletSpecsVersion.APTITUDE]: parseCredentialRequestAPTITUDE,
1067
1247
  [import_io_wallet_utils10.ItWalletSpecsVersion.V1_0]: parseCredentialRequestV1_0,
1068
1248
  [import_io_wallet_utils10.ItWalletSpecsVersion.V1_3]: parseCredentialRequestV1_3,
1069
1249
  [import_io_wallet_utils10.ItWalletSpecsVersion.V1_4]: parseCredentialRequestV1_4
@@ -1101,33 +1281,33 @@ var import_io_wallet_utils12 = require("@pagopa/io-wallet-utils");
1101
1281
  // src/wallet-provider/z-key-attestation.ts
1102
1282
  var import_io_wallet_oid_federation = require("@pagopa/io-wallet-oid-federation");
1103
1283
  var import_io_wallet_utils11 = require("@pagopa/io-wallet-utils");
1104
- var import_zod9 = require("zod");
1105
- var zStatusList = import_zod9.z.object({
1106
- idx: import_zod9.z.number(),
1107
- uri: import_zod9.z.url()
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()
1108
1288
  });
1109
- var zKeyAttestationStatus = import_zod9.z.object({
1289
+ var zKeyAttestationStatus = import_zod10.z.object({
1110
1290
  status_list: zStatusList
1111
1291
  });
1112
1292
  var zKeyAttestationAlg = import_io_wallet_utils11.zItwSupportedSignatureAlg;
1113
- var zKeyAttestationHeader = import_zod9.z.object({
1293
+ var zKeyAttestationHeader = import_zod10.z.object({
1114
1294
  alg: zKeyAttestationAlg,
1115
- kid: import_zod9.z.string(),
1295
+ kid: import_zod10.z.string(),
1116
1296
  trust_chain: import_io_wallet_utils11.zTrustChain.optional(),
1117
- typ: import_zod9.z.literal("key-attestation+jwt"),
1297
+ typ: import_zod10.z.literal("key-attestation+jwt"),
1118
1298
  x5c: import_io_wallet_utils11.zCertificateChain
1119
1299
  });
1120
- var zKeyAttestationPayload = import_zod9.z.object({
1121
- attested_keys: import_zod9.z.array(import_io_wallet_utils11.zJwk).nonempty(),
1122
- certification: import_zod9.z.string().optional(),
1123
- exp: import_zod9.z.number(),
1124
- iat: import_zod9.z.number(),
1125
- iss: import_zod9.z.string(),
1126
- 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(),
1127
1307
  status: zKeyAttestationStatus,
1128
- 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()
1129
1309
  });
1130
- var zKeyAttestationTypeHeader = import_zod9.z.literal("key-attestation+jwt");
1310
+ var zKeyAttestationTypeHeader = import_zod10.z.literal("key-attestation+jwt");
1131
1311
  var keyAttestationTypeHeader = zKeyAttestationTypeHeader.value;
1132
1312
 
1133
1313
  // src/credential-request/verify-key-attestation-jwt.ts
@@ -1278,6 +1458,7 @@ async function verifyProofV1_3(options) {
1278
1458
  return { header, keyAttestation: keyAttestationResult, payload, signer };
1279
1459
  }
1280
1460
  var dispatchVerifyProof = (0, import_io_wallet_utils13.createVersionDispatcher)({
1461
+ [import_io_wallet_utils13.ItWalletSpecsVersion.APTITUDE]: (o) => verifyProofV1_3(o),
1281
1462
  [import_io_wallet_utils13.ItWalletSpecsVersion.V1_0]: (o) => verifyProofV1_0(o),
1282
1463
  [import_io_wallet_utils13.ItWalletSpecsVersion.V1_3]: (o) => verifyProofV1_3(o),
1283
1464
  [import_io_wallet_utils13.ItWalletSpecsVersion.V1_4]: (o) => verifyProofV1_3(o)
@@ -1309,30 +1490,30 @@ var import_io_wallet_utils16 = require("@pagopa/io-wallet-utils");
1309
1490
  var import_io_wallet_utils14 = require("@pagopa/io-wallet-utils");
1310
1491
 
1311
1492
  // src/credential-response/v1.0/z-credential-response.ts
1312
- var import_zod11 = require("zod");
1493
+ var import_zod12 = require("zod");
1313
1494
 
1314
1495
  // src/credential-response/z-immediate-credential-response.ts
1315
- var import_zod10 = require("zod");
1316
- var zCredentialObject = import_zod10.z.object({
1317
- credential: import_zod10.z.string()
1496
+ var import_zod11 = require("zod");
1497
+ var zCredentialObject = import_zod11.z.object({
1498
+ credential: import_zod11.z.string()
1318
1499
  });
1319
- var zImmediateCredentialResponse = import_zod10.z.strictObject({
1320
- credentials: import_zod10.z.array(zCredentialObject).nonempty().describe(
1500
+ var zImmediateCredentialResponse = import_zod11.z.strictObject({
1501
+ credentials: import_zod11.z.array(zCredentialObject).nonempty().describe(
1321
1502
  "Conditional. Array of issued Digital Credentials as JSON objects with `credential` member containing encoded credential string. Present for immediate issuance (HTTP 200)."
1322
1503
  ),
1323
- notification_id: import_zod10.z.string().optional().describe(
1504
+ notification_id: import_zod11.z.string().optional().describe(
1324
1505
  "OPTIONAL. Identifier for notification requests. Only present with credentials parameter."
1325
1506
  )
1326
1507
  });
1327
1508
 
1328
1509
  // src/credential-response/v1.0/z-credential-response.ts
1329
- var zDeferredCredentialResponseV1_0 = import_zod11.z.strictObject({
1330
- 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(
1331
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."
1332
1513
  ),
1333
- transaction_id: import_zod11.z.string().nonempty()
1514
+ transaction_id: import_zod12.z.string().nonempty()
1334
1515
  });
1335
- var zCredentialResponseV1_0 = import_zod11.z.union([
1516
+ var zCredentialResponseV1_0 = import_zod12.z.union([
1336
1517
  zImmediateCredentialResponse,
1337
1518
  zDeferredCredentialResponseV1_0
1338
1519
  ]);
@@ -1365,14 +1546,14 @@ function createCredentialResponseV1_0(flow) {
1365
1546
  var import_io_wallet_utils15 = require("@pagopa/io-wallet-utils");
1366
1547
 
1367
1548
  // src/credential-response/v1.3/z-credential-response.ts
1368
- var import_zod12 = require("zod");
1369
- var zDeferredCredentialResponseV1_3 = import_zod12.z.strictObject({
1370
- 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(
1371
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"
1372
1553
  ),
1373
- transaction_id: import_zod12.z.string().nonempty()
1554
+ transaction_id: import_zod13.z.string().nonempty()
1374
1555
  });
1375
- var zCredentialResponseV1_3 = import_zod12.z.union([
1556
+ var zCredentialResponseV1_3 = import_zod13.z.union([
1376
1557
  zImmediateCredentialResponse,
1377
1558
  zDeferredCredentialResponseV1_3
1378
1559
  ]);
@@ -1403,6 +1584,9 @@ function createCredentialResponseV1_3(flow) {
1403
1584
 
1404
1585
  // src/credential-response/create-credential-response.ts
1405
1586
  var dispatchBuildVersionedResponse = (0, import_io_wallet_utils16.createVersionDispatcher)({
1587
+ [import_io_wallet_utils16.ItWalletSpecsVersion.APTITUDE]: (o) => createCredentialResponseV1_3(
1588
+ o.flow
1589
+ ),
1406
1590
  [import_io_wallet_utils16.ItWalletSpecsVersion.V1_0]: (o) => createCredentialResponseV1_0(
1407
1591
  o.flow
1408
1592
  ),
@@ -1462,10 +1646,10 @@ var import_io_wallet_utils18 = require("@pagopa/io-wallet-utils");
1462
1646
 
1463
1647
  // src/credential-response/z-credential-response.ts
1464
1648
  var import_io_wallet_utils17 = require("@pagopa/io-wallet-utils");
1465
- var import_zod13 = require("zod");
1466
- var zCredentialResponseEncryption = import_zod13.z.looseObject({
1649
+ var import_zod14 = require("zod");
1650
+ var zCredentialResponseEncryption = import_zod14.z.looseObject({
1467
1651
  alg: import_io_wallet_utils17.zAlgValueNotNone,
1468
- enc: import_zod13.z.string(),
1652
+ enc: import_zod14.z.string(),
1469
1653
  jwk: import_io_wallet_utils17.zJwk
1470
1654
  });
1471
1655
 
@@ -1512,37 +1696,37 @@ async function fetchCredentialResponse(options) {
1512
1696
  // src/metadata/fetch-metadata.ts
1513
1697
  var import_io_wallet_oid_federation3 = require("@pagopa/io-wallet-oid-federation");
1514
1698
  var import_io_wallet_utils19 = require("@pagopa/io-wallet-utils");
1515
- var import_zod15 = __toESM(require("zod"));
1699
+ var import_zod16 = __toESM(require("zod"));
1516
1700
 
1517
1701
  // src/metadata/z-metadata-response.ts
1518
1702
  var import_io_wallet_oid_federation2 = require("@pagopa/io-wallet-oid-federation");
1519
- var import_zod14 = require("zod");
1520
- var zMetadataResponseV1_0 = import_zod14.z.object({
1521
- 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"]),
1522
1706
  metadata: import_io_wallet_oid_federation2.itWalletMetadataV1_0,
1523
1707
  openid_federation_claims: import_io_wallet_oid_federation2.itWalletEntityStatementClaimsSchema
1524
1708
  });
1525
- var zMetadataResponseV1_3 = import_zod14.z.object({
1709
+ var zMetadataResponseV1_3 = import_zod15.z.object({
1526
1710
  /**
1527
1711
  * Entity statement claims of the Authorization Server, present only when the
1528
1712
  * selected authorization server was resolved through a federation entity
1529
1713
  * distinct from the Credential Issuer.
1530
1714
  */
1531
1715
  authorization_server_federation_claims: import_io_wallet_oid_federation2.itWalletEntityStatementClaimsSchema.optional(),
1532
- discoveredVia: import_zod14.z.enum(["federation", "oid4vci"]),
1716
+ discoveredVia: import_zod15.z.enum(["federation", "oid4vci"]),
1533
1717
  metadata: import_io_wallet_oid_federation2.itWalletMetadataV1_3,
1534
1718
  openid_federation_claims: import_io_wallet_oid_federation2.itWalletEntityStatementClaimsSchema.optional()
1535
1719
  });
1536
1720
  var zMetadataResponseV1_4 = zMetadataResponseV1_3.extend({
1537
1721
  metadata: import_io_wallet_oid_federation2.itWalletMetadataV1_4
1538
1722
  });
1539
- var zMetadataResponse = import_zod14.z.union([
1723
+ var zMetadataResponse = import_zod15.z.union([
1540
1724
  zMetadataResponseV1_0,
1541
1725
  zMetadataResponseV1_3,
1542
1726
  zMetadataResponseV1_4
1543
1727
  ]);
1544
- var zPartialIssuerMetadata = import_zod14.z.looseObject({
1545
- 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()
1546
1730
  });
1547
1731
 
1548
1732
  // src/metadata/fetch-metadata.ts
@@ -1609,7 +1793,7 @@ async function applyFederationAuthorizationServerSelection(fetch, federationResu
1609
1793
  if (!selectedAuthorizationServer || selectedAuthorizationServer === credentialIssuer) {
1610
1794
  return federationResult;
1611
1795
  }
1612
- const parsedSelectedAuthorizationServer = import_zod15.default.url().safeParse(selectedAuthorizationServer);
1796
+ const parsedSelectedAuthorizationServer = import_zod16.default.url().safeParse(selectedAuthorizationServer);
1613
1797
  if (!parsedSelectedAuthorizationServer.success || !parsedSelectedAuthorizationServer.data.startsWith("https://")) {
1614
1798
  throw new import_io_wallet_utils19.ValidationError(
1615
1799
  "selected authorization server is not a valid HTTPS URL"
@@ -1647,7 +1831,7 @@ async function fallbackDiscovery(fetch, baseUrl, authorizationServer) {
1647
1831
  let oauthAuthorizationServer;
1648
1832
  if (authorizationServers && authorizationServers.length > 0) {
1649
1833
  const selectedAuthorizationServer = authorizationServer ?? authorizationServers[0];
1650
- const parsedUrl = import_zod15.default.url().safeParse(selectedAuthorizationServer);
1834
+ const parsedUrl = import_zod16.default.url().safeParse(selectedAuthorizationServer);
1651
1835
  if (!parsedUrl.success || !parsedUrl.data.startsWith("https://")) {
1652
1836
  throw new import_io_wallet_utils19.ValidationError(
1653
1837
  "selected authorization server is not a valid HTTPS URL"
@@ -1725,13 +1909,14 @@ async function fetchMetadataV1_4(options) {
1725
1909
  );
1726
1910
  }
1727
1911
  var dispatchFetchMetadata = (0, import_io_wallet_utils19.createVersionDispatcher)({
1912
+ [import_io_wallet_utils19.ItWalletSpecsVersion.APTITUDE]: (o) => fetchMetadataV1_4(o),
1728
1913
  [import_io_wallet_utils19.ItWalletSpecsVersion.V1_0]: (o) => fetchMetadataV1_0(o),
1729
1914
  [import_io_wallet_utils19.ItWalletSpecsVersion.V1_3]: (o) => fetchMetadataV1_3(o),
1730
1915
  [import_io_wallet_utils19.ItWalletSpecsVersion.V1_4]: (o) => fetchMetadataV1_4(o)
1731
1916
  });
1732
1917
  async function fetchMetadata(options) {
1733
1918
  try {
1734
- const urlValidation = import_zod15.default.url().safeParse(options.credentialIssuerUrl);
1919
+ const urlValidation = import_zod16.default.url().safeParse(options.credentialIssuerUrl);
1735
1920
  if (!urlValidation.success || !urlValidation.data.startsWith("https://")) {
1736
1921
  throw new import_io_wallet_utils19.ValidationError(
1737
1922
  "credentialIssuerUrl must be a valid HTTPS URL"
@@ -1883,7 +2068,7 @@ var WalletProvider = class {
1883
2068
  * status: { status_list: { idx: 2, uri: "https://status.example.com" } } // Optional
1884
2069
  * });
1885
2070
  *
1886
- * @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
1887
2072
  * const jwt = await provider.createItWalletAttestationJwt({
1888
2073
  * callbacks: { hash: myHashCallback, signJwt: mySignJwtCallback },
1889
2074
  * dpopJwkPublic: myJwk,
@@ -1902,6 +2087,18 @@ var WalletProvider = class {
1902
2087
  */
1903
2088
  async createItWalletAttestationJwt(options) {
1904
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
+ },
1905
2102
  [import_io_wallet_utils20.ItWalletSpecsVersion.V1_0]: () => {
1906
2103
  assertV1_0Options(options);
1907
2104
  return (0, import_io_wallet_oauth23.createWalletAttestationJwtV1_0)({
@@ -1946,6 +2143,7 @@ var WalletProvider = class {
1946
2143
  };
1947
2144
  // Annotate the CommonJS export names for ESM import in node:
1948
2145
  0 && (module.exports = {
2146
+ CREDENTIAL_OFFER_GRANTS,
1949
2147
  CreateCredentialResponseError,
1950
2148
  CredentialAuthorizationHeaderError,
1951
2149
  CredentialOfferError,