@pagopa/io-wallet-oid4vci 2.0.0-launchpad → 2.0.2-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.mjs CHANGED
@@ -201,6 +201,91 @@ async function sendAuthorizationResponseAndExtractCode(options) {
201
201
  }
202
202
  }
203
203
 
204
+ // src/credential-offer/APTITUDE/z-credential-offer.ts
205
+ import { z as z2 } from "zod";
206
+ var zTxCodePreAuthorizedCodeGrantAPTITUDE = z2.object({
207
+ /**
208
+ * OPTIONAL. String containing guidance for the Holder
209
+ * of the Wallet on how to obtain the Transaction Code.
210
+ */
211
+ description: z2.string().max(300).optional(),
212
+ /**
213
+ * OPTIONAL. String specifying the input character set.
214
+ * Possible values are numeric (only digits) and text (any characters).
215
+ * The default is numeric.
216
+ */
217
+ input_mode: z2.enum(["numeric", "digit"]).optional(),
218
+ /**
219
+ * OPTIONAL. Integer specifying the length of the Transaction Code.
220
+ */
221
+ length: z2.number().optional()
222
+ });
223
+ var zAuthorizationCodeGrantAPTITUDE = z2.object({
224
+ /**
225
+ * CONDITIONALLY REQUIRED. HTTPS URL of the Authorization Server.
226
+ * REQUIRED only when the Credential Issuer uses multiple Authorization Servers.
227
+ * If present, MUST match one of the authorization_servers in the Credential Issuer metadata.
228
+ */
229
+ authorization_server: z2.url().optional(),
230
+ /**
231
+ * OPTIONAL. String value representing the issuer state.
232
+ * Used to correlate the authorization request with the credential offer.
233
+ */
234
+ issuer_state: z2.string().optional()
235
+ });
236
+ var zPreAuthorizedCodeGrantAPTITUDE = z2.object({
237
+ /**
238
+ * CONDITIONALLY REQUIRED. HTTPS URL of the Authorization Server.
239
+ * REQUIRED only when the Credential Issuer uses multiple Authorization Servers.
240
+ * If present, MUST match one of the authorization_servers in the Credential Issuer metadata.
241
+ */
242
+ authorization_server: z2.url().optional(),
243
+ /**
244
+ * REQUIRED. The code representing the Credential Issuer's authorization for
245
+ * the Wallet to obtain Credentials of a certain type
246
+ */
247
+ "pre-authorized_code": z2.string(),
248
+ /**
249
+ * OPTIONAL. Object indicating that a Transaction Code is required if present, even if empty.
250
+ * It describes the requirements for a Transaction Code, which the Authorization Server expects
251
+ * the End-User to present along with the Token Request in a Pre-Authorized Code Flow.
252
+ * If the Authorization Server does not expect a Transaction Code, this object is absent;
253
+ */
254
+ tx_code: zTxCodePreAuthorizedCodeGrantAPTITUDE.optional()
255
+ });
256
+ var zCredentialOfferGrantsAPTITUDE = z2.object({
257
+ /**
258
+ * OPTIONAL. Authorization Code grant details.
259
+ */
260
+ authorization_code: zAuthorizationCodeGrantAPTITUDE.optional(),
261
+ /**
262
+ * OPTIONAL. Pre-Authorized Code grant details.
263
+ */
264
+ "urn:ietf:params:oauth:grant-type:pre-authorized_code": zPreAuthorizedCodeGrantAPTITUDE.optional()
265
+ });
266
+ var zCredentialOfferAPTITUDE = z2.object({
267
+ /**
268
+ * REQUIRED. Array of credential configuration identifiers.
269
+ * References the types of credentials offered as defined in the Credential Issuer metadata.
270
+ */
271
+ credential_configuration_ids: z2.array(z2.string()).min(1),
272
+ /**
273
+ * REQUIRED. HTTPS URL of the Credential Issuer.
274
+ * The Credential Issuer from which the wallet will request credentials.
275
+ */
276
+ credential_issuer: z2.url(),
277
+ /**
278
+ * REQUIRED. Grant information for the credential offer.
279
+ * IT-Wallet v1.4 requires authorization_code or pre-auhorized code grant.
280
+ */
281
+ grants: zCredentialOfferGrantsAPTITUDE
282
+ });
283
+ var CREDENTIAL_OFFER_GRANTS = /* @__PURE__ */ ((CREDENTIAL_OFFER_GRANTS2) => {
284
+ CREDENTIAL_OFFER_GRANTS2["AUTHORIZATION_CODE"] = "authorization_code";
285
+ CREDENTIAL_OFFER_GRANTS2["PREAUTHORIZED_CODE"] = "urn:ietf:params:oauth:grant-type:pre-authorized_code";
286
+ return CREDENTIAL_OFFER_GRANTS2;
287
+ })(CREDENTIAL_OFFER_GRANTS || {});
288
+
204
289
  // src/credential-offer/extract-grant-details.ts
205
290
  import {
206
291
  ItWalletSpecsVersion,
@@ -217,33 +302,70 @@ function requireAuthorizationCodeGrant(credentialOffer) {
217
302
  }
218
303
  return authCodeGrant;
219
304
  }
305
+ function requireAuthorizationCodeOrPreAuthorizedCodeGrant(credentialOffer) {
306
+ if (!credentialOffer.grants) {
307
+ throw new CredentialOfferError("No grants found in credential offer");
308
+ }
309
+ const grants = credentialOffer.grants;
310
+ if (!grants["authorization_code" /* AUTHORIZATION_CODE */] && !grants["urn:ietf:params:oauth:grant-type:pre-authorized_code" /* PREAUTHORIZED_CODE */]) {
311
+ throw new CredentialOfferError(
312
+ "either one of authorization_code or pre-authorized code grant is required"
313
+ );
314
+ }
315
+ return grants;
316
+ }
220
317
  function extractGrantDetailsV1_3(options) {
221
318
  const authCodeGrant = requireAuthorizationCodeGrant(options.credentialOffer);
222
319
  return {
223
- authorizationCodeGrant: {
320
+ ["authorization_code" /* AUTHORIZATION_CODE */]: {
224
321
  authorizationServer: authCodeGrant.authorization_server,
225
322
  issuerState: authCodeGrant.issuer_state,
226
323
  scope: authCodeGrant.scope
227
- },
228
- grantType: "authorization_code"
324
+ }
229
325
  };
230
326
  }
231
327
  function extractGrantDetailsV1_4(options) {
232
328
  const authCodeGrant = requireAuthorizationCodeGrant(options.credentialOffer);
233
329
  return {
234
- authorizationCodeGrant: {
330
+ ["authorization_code" /* AUTHORIZATION_CODE */]: {
235
331
  authorizationServer: authCodeGrant.authorization_server,
236
332
  issuerState: authCodeGrant.issuer_state
333
+ }
334
+ };
335
+ }
336
+ function extractGrantDetailsAPTITUDE(options) {
337
+ const grants = requireAuthorizationCodeOrPreAuthorizedCodeGrant(
338
+ options.credentialOffer
339
+ );
340
+ const authorizationCodeGrant = grants["authorization_code" /* AUTHORIZATION_CODE */];
341
+ const preAuthorizedCodeGrant = grants["urn:ietf:params:oauth:grant-type:pre-authorized_code" /* PREAUTHORIZED_CODE */];
342
+ return {
343
+ ...authorizationCodeGrant && {
344
+ ["authorization_code" /* AUTHORIZATION_CODE */]: {
345
+ authorizationServer: authorizationCodeGrant.authorization_server,
346
+ issuerState: authorizationCodeGrant.issuer_state
347
+ }
237
348
  },
238
- grantType: "authorization_code"
349
+ ...preAuthorizedCodeGrant && {
350
+ ["urn:ietf:params:oauth:grant-type:pre-authorized_code" /* PREAUTHORIZED_CODE */]: {
351
+ authorizationServer: preAuthorizedCodeGrant.authorization_server,
352
+ preAuthorizedCode: preAuthorizedCodeGrant["pre-authorized_code"],
353
+ txCode: preAuthorizedCodeGrant.tx_code
354
+ }
355
+ }
239
356
  };
240
357
  }
241
358
  var dispatchExtractGrantDetails = createVersionDispatcher({
359
+ [ItWalletSpecsVersion.APTITUDE]: (o) => extractGrantDetailsAPTITUDE(o),
242
360
  [ItWalletSpecsVersion.V1_0]: () => {
243
361
  throw new ItWalletSpecsVersionError(
244
362
  "extractGrantDetails",
245
363
  ItWalletSpecsVersion.V1_0,
246
- [ItWalletSpecsVersion.V1_3, ItWalletSpecsVersion.V1_4]
364
+ [
365
+ ItWalletSpecsVersion.V1_3,
366
+ ItWalletSpecsVersion.V1_4,
367
+ ItWalletSpecsVersion.APTITUDE
368
+ ]
247
369
  );
248
370
  },
249
371
  [ItWalletSpecsVersion.V1_3]: (o) => extractGrantDetailsV1_3(o),
@@ -254,46 +376,46 @@ function extractGrantDetails(options) {
254
376
  }
255
377
 
256
378
  // src/credential-offer/z-credential-offer.ts
257
- import { z as z4 } from "zod";
379
+ import { z as z5 } from "zod";
258
380
 
259
381
  // src/credential-offer/v1.3/z-credential-offer.ts
260
- import { z as z2 } from "zod";
261
- var zAuthorizationCodeGrantV1_3 = z2.object({
382
+ import { z as z3 } from "zod";
383
+ var zAuthorizationCodeGrantV1_3 = z3.object({
262
384
  /**
263
385
  * CONDITIONALLY REQUIRED. HTTPS URL of the Authorization Server.
264
386
  * REQUIRED only when the Credential Issuer uses multiple Authorization Servers.
265
387
  * If present, MUST match one of the authorization_servers in the Credential Issuer metadata.
266
388
  */
267
- authorization_server: z2.url().optional(),
389
+ authorization_server: z3.url().optional(),
268
390
  /**
269
391
  * OPTIONAL. String value representing the issuer state.
270
392
  * Used to correlate the authorization request with the credential offer.
271
393
  */
272
- issuer_state: z2.string().optional(),
394
+ issuer_state: z3.string().optional(),
273
395
  /**
274
396
  * REQUIRED. OAuth 2.0 scope value.
275
397
  * Defines the scope of access requested by the credential offer.
276
398
  */
277
- scope: z2.string()
399
+ scope: z3.string()
278
400
  });
279
- var zCredentialOfferGrantsV1_3 = z2.object({
401
+ var zCredentialOfferGrantsV1_3 = z3.object({
280
402
  /**
281
403
  * REQUIRED. Authorization Code grant details.
282
404
  * IT-Wallet v1.3 only supports authorization_code grant.
283
405
  */
284
406
  authorization_code: zAuthorizationCodeGrantV1_3
285
407
  });
286
- var zCredentialOfferV1_3 = z2.object({
408
+ var zCredentialOfferV1_3 = z3.object({
287
409
  /**
288
410
  * REQUIRED. Array of credential configuration identifiers.
289
411
  * References the types of credentials offered as defined in the Credential Issuer metadata.
290
412
  */
291
- credential_configuration_ids: z2.array(z2.string()).min(1),
413
+ credential_configuration_ids: z3.array(z3.string()).min(1),
292
414
  /**
293
415
  * REQUIRED. HTTPS URL of the Credential Issuer.
294
416
  * The Credential Issuer from which the wallet will request credentials.
295
417
  */
296
- credential_issuer: z2.url(),
418
+ credential_issuer: z3.url(),
297
419
  /**
298
420
  * REQUIRED. Grant information for the credential offer.
299
421
  * IT-Wallet v1.3 requires authorization_code grant.
@@ -302,38 +424,38 @@ var zCredentialOfferV1_3 = z2.object({
302
424
  });
303
425
 
304
426
  // src/credential-offer/v1.4/z-credential-offer.ts
305
- import { z as z3 } from "zod";
306
- var zAuthorizationCodeGrantV1_4 = z3.object({
427
+ import { z as z4 } from "zod";
428
+ var zAuthorizationCodeGrantV1_4 = z4.object({
307
429
  /**
308
430
  * CONDITIONALLY REQUIRED. HTTPS URL of the Authorization Server.
309
431
  * REQUIRED only when the Credential Issuer uses multiple Authorization Servers.
310
432
  * If present, MUST match one of the authorization_servers in the Credential Issuer metadata.
311
433
  */
312
- authorization_server: z3.url().optional(),
434
+ authorization_server: z4.url().optional(),
313
435
  /**
314
436
  * OPTIONAL. String value representing the issuer state.
315
437
  * Used to correlate the authorization request with the credential offer.
316
438
  */
317
- issuer_state: z3.string().optional()
439
+ issuer_state: z4.string().optional()
318
440
  });
319
- var zCredentialOfferGrantsV1_4 = z3.object({
441
+ var zCredentialOfferGrantsV1_4 = z4.object({
320
442
  /**
321
443
  * REQUIRED. Authorization Code grant details.
322
444
  * IT-Wallet v1.4 only supports authorization_code grant.
323
445
  */
324
446
  authorization_code: zAuthorizationCodeGrantV1_4
325
447
  });
326
- var zCredentialOfferV1_4 = z3.object({
448
+ var zCredentialOfferV1_4 = z4.object({
327
449
  /**
328
450
  * REQUIRED. Array of credential configuration identifiers.
329
451
  * References the types of credentials offered as defined in the Credential Issuer metadata.
330
452
  */
331
- credential_configuration_ids: z3.array(z3.string()).min(1),
453
+ credential_configuration_ids: z4.array(z4.string()).min(1),
332
454
  /**
333
455
  * REQUIRED. HTTPS URL of the Credential Issuer.
334
456
  * The Credential Issuer from which the wallet will request credentials.
335
457
  */
336
- credential_issuer: z3.url(),
458
+ credential_issuer: z4.url(),
337
459
  /**
338
460
  * REQUIRED. Grant information for the credential offer.
339
461
  * IT-Wallet v1.4 requires authorization_code grant.
@@ -342,22 +464,22 @@ var zCredentialOfferV1_4 = z3.object({
342
464
  });
343
465
 
344
466
  // src/credential-offer/z-credential-offer.ts
345
- var zCredentialOfferUri = z4.object({
467
+ var zCredentialOfferUri = z5.object({
346
468
  /**
347
469
  * OPTIONAL. Inline credential offer JSON (by value).
348
470
  * URL-encoded JSON string containing the credential offer.
349
471
  */
350
- credential_offer: z4.string().optional(),
472
+ credential_offer: z5.string().optional(),
351
473
  /**
352
474
  * OPTIONAL. URL pointing to the credential offer JSON (by reference).
353
475
  * HTTPS URL where the credential offer can be fetched.
354
476
  */
355
- credential_offer_uri: z4.url().optional(),
477
+ credential_offer_uri: z5.url().optional(),
356
478
  /**
357
479
  * URL scheme used for the credential offer.
358
480
  * Determines the invocation method.
359
481
  */
360
- scheme: z4.enum(["openid-credential-offer", "haip-vci", "https"])
482
+ scheme: z5.enum(["openid-credential-offer", "haip-vci", "https"])
361
483
  }).refine((data) => data.credential_offer || data.credential_offer_uri, {
362
484
  message: "Either credential_offer or credential_offer_uri must be present"
363
485
  });
@@ -408,11 +530,17 @@ function parseCredentialOfferForVersion(config, data) {
408
530
  return zCredentialOfferV1_3.parse(data);
409
531
  case ItWalletSpecsVersion2.V1_4:
410
532
  return zCredentialOfferV1_4.parse(data);
533
+ case ItWalletSpecsVersion2.APTITUDE:
534
+ return zCredentialOfferAPTITUDE.parse(data);
411
535
  default:
412
536
  throw new ItWalletSpecsVersionError2(
413
537
  "resolveCredentialOffer",
414
538
  config.itWalletSpecsVersion,
415
- [ItWalletSpecsVersion2.V1_3, ItWalletSpecsVersion2.V1_4]
539
+ [
540
+ ItWalletSpecsVersion2.V1_3,
541
+ ItWalletSpecsVersion2.V1_4,
542
+ ItWalletSpecsVersion2.APTITUDE
543
+ ]
416
544
  );
417
545
  }
418
546
  }
@@ -483,7 +611,7 @@ function assertAuthorizationServerAllowed(authorizationServer, authorizationServ
483
611
  }
484
612
  }
485
613
  function validateBaseCredentialOffer(options) {
486
- const { credentialIssuerMetadata, credentialOffer, versionLabel } = options;
614
+ const { credentialOffer, versionLabel } = options;
487
615
  if (!credentialOffer.credential_issuer.startsWith("https://")) {
488
616
  throw new CredentialOfferError("credential_issuer must be an HTTPS URL");
489
617
  }
@@ -497,6 +625,11 @@ function validateBaseCredentialOffer(options) {
497
625
  `grants is REQUIRED for IT-Wallet ${versionLabel}`
498
626
  );
499
627
  }
628
+ }
629
+ async function validateCredentialOfferV1_3(options) {
630
+ const versionLabel = "v1.3";
631
+ const { credentialIssuerMetadata, credentialOffer } = options;
632
+ validateBaseCredentialOffer({ credentialOffer, versionLabel });
500
633
  const authCodeGrant = credentialOffer.grants.authorization_code;
501
634
  if (!authCodeGrant) {
502
635
  throw new CredentialOfferError(
@@ -507,30 +640,57 @@ function validateBaseCredentialOffer(options) {
507
640
  authCodeGrant.authorization_server,
508
641
  credentialIssuerMetadata?.authorization_servers
509
642
  );
510
- }
511
- async function validateCredentialOfferV1_3(options) {
512
- validateBaseCredentialOffer({
513
- credentialIssuerMetadata: options.credentialIssuerMetadata,
514
- credentialOffer: options.credentialOffer,
515
- versionLabel: "v1.3"
516
- });
517
643
  if (!options.credentialOffer.grants.authorization_code.scope) {
518
644
  throw new CredentialOfferError("authorization_code.scope is REQUIRED");
519
645
  }
520
646
  }
521
647
  async function validateCredentialOfferV1_4(options) {
522
- validateBaseCredentialOffer({
523
- credentialIssuerMetadata: options.credentialIssuerMetadata,
524
- credentialOffer: options.credentialOffer,
525
- versionLabel: "v1.4"
526
- });
648
+ const versionLabel = "v1.4";
649
+ const { credentialIssuerMetadata, credentialOffer } = options;
650
+ validateBaseCredentialOffer({ credentialOffer, versionLabel });
651
+ const authCodeGrant = credentialOffer.grants.authorization_code;
652
+ if (!authCodeGrant) {
653
+ throw new CredentialOfferError(
654
+ `authorization_code grant is REQUIRED for IT-Wallet ${versionLabel}`
655
+ );
656
+ }
657
+ assertAuthorizationServerAllowed(
658
+ authCodeGrant.authorization_server,
659
+ credentialIssuerMetadata?.authorization_servers
660
+ );
661
+ }
662
+ async function validateCredentialOfferAPTITUDE(options) {
663
+ const versionLabel = "APTITUDE";
664
+ const {
665
+ credentialIssuerMetadata,
666
+ credentialOffer,
667
+ grantType = "authorization_code" /* AUTHORIZATION_CODE */
668
+ } = options;
669
+ validateBaseCredentialOffer({ credentialOffer, versionLabel });
670
+ const grant = credentialOffer.grants[grantType];
671
+ if (!grant) {
672
+ throw new CredentialOfferError(
673
+ `${grantType} grant as specified is REQUIRED for IT-Wallet ${versionLabel}`
674
+ );
675
+ }
676
+ assertAuthorizationServerAllowed(
677
+ grant.authorization_server,
678
+ credentialIssuerMetadata?.authorization_servers
679
+ );
527
680
  }
528
681
  var dispatchValidateCredentialOffer = createVersionDispatcher2({
682
+ [ItWalletSpecsVersion3.APTITUDE]: (o) => validateCredentialOfferAPTITUDE(
683
+ o
684
+ ),
529
685
  [ItWalletSpecsVersion3.V1_0]: () => {
530
686
  throw new ItWalletSpecsVersionError3(
531
687
  "validateCredentialOffer",
532
688
  ItWalletSpecsVersion3.V1_0,
533
- [ItWalletSpecsVersion3.V1_3, ItWalletSpecsVersion3.V1_4]
689
+ [
690
+ ItWalletSpecsVersion3.V1_3,
691
+ ItWalletSpecsVersion3.V1_4,
692
+ ItWalletSpecsVersion3.APTITUDE
693
+ ]
534
694
  );
535
695
  },
536
696
  [ItWalletSpecsVersion3.V1_3]: (o) => validateCredentialOfferV1_3(o),
@@ -554,18 +714,18 @@ import {
554
714
  } from "@pagopa/io-wallet-utils";
555
715
 
556
716
  // src/credential-request/v1.0/z-credential.ts
557
- import { z as z6 } from "zod";
717
+ import { z as z7 } from "zod";
558
718
 
559
719
  // src/credential-request/z-base-credential-request.ts
560
- import { z as z5 } from "zod";
561
- var zBaseCredentialRequest = z5.object({
562
- credential_configuration_id: z5.string().optional().describe(
720
+ import { z as z6 } from "zod";
721
+ var zBaseCredentialRequest = z6.object({
722
+ credential_configuration_id: z6.string().optional().describe(
563
723
  "REQUIRED if credential_identifier param is absent. MUST NOT be used otherwise."
564
724
  ),
565
- credential_identifier: z5.string().optional().describe(
725
+ credential_identifier: z6.string().optional().describe(
566
726
  "REQUIRED when Authorization Details of type openid_credential was returned. MUST NOT be used if credential_configuration_id is present."
567
727
  ),
568
- transaction_id: z5.string().optional().describe(
728
+ transaction_id: z6.string().optional().describe(
569
729
  "REQUIRED only in case of deferred flow. MUST NOT be present in immediate flow."
570
730
  )
571
731
  });
@@ -587,9 +747,9 @@ function credentialRequestRefiner(data, ctx) {
587
747
  }
588
748
 
589
749
  // src/credential-request/v1.0/z-credential.ts
590
- var zCredentialRequestProof = z6.object({
591
- jwt: z6.string().min(1, "JWT must not be empty"),
592
- proof_type: z6.literal("jwt")
750
+ var zCredentialRequestProof = z7.object({
751
+ jwt: z7.string().min(1, "JWT must not be empty"),
752
+ proof_type: z7.literal("jwt")
593
753
  // MUST be "jwt"
594
754
  });
595
755
  var zCredentialRequestV1_0 = zBaseCredentialRequest.extend({
@@ -644,10 +804,10 @@ import {
644
804
  } from "@pagopa/io-wallet-utils";
645
805
 
646
806
  // src/credential-request/v1.3/z-credential.ts
647
- import { z as z7 } from "zod";
648
- var zCredentialRequestProofJwt = z7.string().min(1, "JWT must not be empty in credential request proofs array");
649
- var zCredentialRequestProofs = z7.object({
650
- jwt: z7.tuple([zCredentialRequestProofJwt], zCredentialRequestProofJwt)
807
+ import { z as z8 } from "zod";
808
+ var zCredentialRequestProofJwt = z8.string().min(1, "JWT must not be empty in credential request proofs array");
809
+ var zCredentialRequestProofs = z8.object({
810
+ jwt: z8.tuple([zCredentialRequestProofJwt], zCredentialRequestProofJwt)
651
811
  });
652
812
  var zCredentialRequestV1_3 = zBaseCredentialRequest.extend({
653
813
  proofs: zCredentialRequestProofs.describe(
@@ -731,6 +891,7 @@ var createCredentialRequest2 = async (options) => {
731
891
 
732
892
  // src/credential-request/create-credential-request.ts
733
893
  var dispatchCreateCredentialRequest = createVersionDispatcher3({
894
+ [ItWalletSpecsVersion6.APTITUDE]: (o) => createCredentialRequest2(o),
734
895
  [ItWalletSpecsVersion6.V1_0]: (o) => createCredentialRequest(o),
735
896
  [ItWalletSpecsVersion6.V1_3]: (o) => createCredentialRequest2(o),
736
897
  [ItWalletSpecsVersion6.V1_4]: (o) => (
@@ -760,21 +921,21 @@ import {
760
921
 
761
922
  // src/credential-request/z-proof-jwt.ts
762
923
  import { zJwk } from "@pagopa/io-wallet-utils";
763
- import { z as z8 } from "zod";
764
- var zBaseProofJwtHeader = z8.object({
765
- alg: z8.string().min(1),
924
+ import { z as z9 } from "zod";
925
+ var zBaseProofJwtHeader = z9.object({
926
+ alg: z9.string().min(1),
766
927
  jwk: zJwk,
767
- typ: z8.literal("openid4vci-proof+jwt")
928
+ typ: z9.literal("openid4vci-proof+jwt")
768
929
  });
769
930
  var zProofJwtHeaderV1_0 = zBaseProofJwtHeader.loose();
770
931
  var zProofJwtHeaderV1_3 = zBaseProofJwtHeader.extend({
771
- key_attestation: z8.string().min(1)
932
+ key_attestation: z9.string().min(1)
772
933
  }).loose();
773
- var zProofJwtPayload = z8.looseObject({
774
- aud: z8.string().min(1),
775
- iat: z8.number(),
776
- iss: z8.string().min(1).optional(),
777
- nonce: z8.string().min(1)
934
+ var zProofJwtPayload = z9.looseObject({
935
+ aud: z9.string().min(1),
936
+ iat: z9.number(),
937
+ iss: z9.string().min(1).optional(),
938
+ nonce: z9.string().min(1)
778
939
  });
779
940
 
780
941
  // src/credential-request/parse-credential-request.ts
@@ -1017,7 +1178,25 @@ function parseCredentialRequestV1_4(options) {
1017
1178
  // V1_4 reuses V1_3 proof schema
1018
1179
  });
1019
1180
  }
1181
+ function parseCredentialRequestAPTITUDE(options) {
1182
+ const credentialRequest = parseWithErrorHandling3(
1183
+ zCredentialRequestV1_3,
1184
+ options.credentialRequest,
1185
+ "Invalid credential request format for ItWalletSpecsVersion APTITUDE"
1186
+ );
1187
+ return toResult({
1188
+ accessToken: options.accessToken,
1189
+ callbacks: options.callbacks,
1190
+ credentialRequest,
1191
+ dpopProof: options.dpopProof,
1192
+ expected: options.expected,
1193
+ grantType: options.grantType,
1194
+ isDeferredFlow: options.isDeferredFlow,
1195
+ itWalletSpecsVersion: ItWalletSpecsVersion7.APTITUDE
1196
+ });
1197
+ }
1020
1198
  var dispatchParseCredentialRequest = createVersionDispatcher4({
1199
+ [ItWalletSpecsVersion7.APTITUDE]: parseCredentialRequestAPTITUDE,
1021
1200
  [ItWalletSpecsVersion7.V1_0]: parseCredentialRequestV1_0,
1022
1201
  [ItWalletSpecsVersion7.V1_3]: parseCredentialRequestV1_3,
1023
1202
  [ItWalletSpecsVersion7.V1_4]: parseCredentialRequestV1_4
@@ -1078,33 +1257,33 @@ import {
1078
1257
  zJwk as zJwk2,
1079
1258
  zTrustChain
1080
1259
  } from "@pagopa/io-wallet-utils";
1081
- import { z as z9 } from "zod";
1082
- var zStatusList = z9.object({
1083
- idx: z9.number(),
1084
- uri: z9.url()
1260
+ import { z as z10 } from "zod";
1261
+ var zStatusList = z10.object({
1262
+ idx: z10.number(),
1263
+ uri: z10.url()
1085
1264
  });
1086
- var zKeyAttestationStatus = z9.object({
1265
+ var zKeyAttestationStatus = z10.object({
1087
1266
  status_list: zStatusList
1088
1267
  });
1089
1268
  var zKeyAttestationAlg = zItwSupportedSignatureAlg;
1090
- var zKeyAttestationHeader = z9.object({
1269
+ var zKeyAttestationHeader = z10.object({
1091
1270
  alg: zKeyAttestationAlg,
1092
- kid: z9.string(),
1271
+ kid: z10.string(),
1093
1272
  trust_chain: zTrustChain.optional(),
1094
- typ: z9.literal("key-attestation+jwt"),
1273
+ typ: z10.literal("key-attestation+jwt"),
1095
1274
  x5c: zCertificateChain
1096
1275
  });
1097
- var zKeyAttestationPayload = z9.object({
1098
- attested_keys: z9.array(zJwk2).nonempty(),
1099
- certification: z9.string().optional(),
1100
- exp: z9.number(),
1101
- iat: z9.number(),
1102
- iss: z9.string(),
1103
- key_storage: z9.array(zKeyStorageLevelV1_3).nonempty(),
1276
+ var zKeyAttestationPayload = z10.object({
1277
+ attested_keys: z10.array(zJwk2).nonempty(),
1278
+ certification: z10.string().optional(),
1279
+ exp: z10.number(),
1280
+ iat: z10.number(),
1281
+ iss: z10.string(),
1282
+ key_storage: z10.array(zKeyStorageLevelV1_3).nonempty(),
1104
1283
  status: zKeyAttestationStatus,
1105
- user_authentication: z9.array(zKeyStorageLevelV1_3).nonempty()
1284
+ user_authentication: z10.array(zKeyStorageLevelV1_3).nonempty()
1106
1285
  });
1107
- var zKeyAttestationTypeHeader = z9.literal("key-attestation+jwt");
1286
+ var zKeyAttestationTypeHeader = z10.literal("key-attestation+jwt");
1108
1287
  var keyAttestationTypeHeader = zKeyAttestationTypeHeader.value;
1109
1288
 
1110
1289
  // src/credential-request/verify-key-attestation-jwt.ts
@@ -1255,6 +1434,7 @@ async function verifyProofV1_3(options) {
1255
1434
  return { header, keyAttestation: keyAttestationResult, payload, signer };
1256
1435
  }
1257
1436
  var dispatchVerifyProof = createVersionDispatcher5({
1437
+ [ItWalletSpecsVersion8.APTITUDE]: (o) => verifyProofV1_3(o),
1258
1438
  [ItWalletSpecsVersion8.V1_0]: (o) => verifyProofV1_0(o),
1259
1439
  [ItWalletSpecsVersion8.V1_3]: (o) => verifyProofV1_3(o),
1260
1440
  [ItWalletSpecsVersion8.V1_4]: (o) => verifyProofV1_3(o)
@@ -1290,30 +1470,30 @@ import {
1290
1470
  import { parseWithErrorHandling as parseWithErrorHandling4 } from "@pagopa/io-wallet-utils";
1291
1471
 
1292
1472
  // src/credential-response/v1.0/z-credential-response.ts
1293
- import { z as z11 } from "zod";
1473
+ import { z as z12 } from "zod";
1294
1474
 
1295
1475
  // src/credential-response/z-immediate-credential-response.ts
1296
- import { z as z10 } from "zod";
1297
- var zCredentialObject = z10.object({
1298
- credential: z10.string()
1476
+ import { z as z11 } from "zod";
1477
+ var zCredentialObject = z11.object({
1478
+ credential: z11.string()
1299
1479
  });
1300
- var zImmediateCredentialResponse = z10.strictObject({
1301
- credentials: z10.array(zCredentialObject).nonempty().describe(
1480
+ var zImmediateCredentialResponse = z11.strictObject({
1481
+ credentials: z11.array(zCredentialObject).nonempty().describe(
1302
1482
  "Conditional. Array of issued Digital Credentials as JSON objects with `credential` member containing encoded credential string. Present for immediate issuance (HTTP 200)."
1303
1483
  ),
1304
- notification_id: z10.string().optional().describe(
1484
+ notification_id: z11.string().optional().describe(
1305
1485
  "OPTIONAL. Identifier for notification requests. Only present with credentials parameter."
1306
1486
  )
1307
1487
  });
1308
1488
 
1309
1489
  // src/credential-response/v1.0/z-credential-response.ts
1310
- var zDeferredCredentialResponseV1_0 = z11.strictObject({
1311
- lead_time: z11.number().int().positive().describe(
1490
+ var zDeferredCredentialResponseV1_0 = z12.strictObject({
1491
+ lead_time: z12.number().int().positive().describe(
1312
1492
  "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."
1313
1493
  ),
1314
- transaction_id: z11.string().nonempty()
1494
+ transaction_id: z12.string().nonempty()
1315
1495
  });
1316
- var zCredentialResponseV1_0 = z11.union([
1496
+ var zCredentialResponseV1_0 = z12.union([
1317
1497
  zImmediateCredentialResponse,
1318
1498
  zDeferredCredentialResponseV1_0
1319
1499
  ]);
@@ -1346,14 +1526,14 @@ function createCredentialResponseV1_0(flow) {
1346
1526
  import { parseWithErrorHandling as parseWithErrorHandling5 } from "@pagopa/io-wallet-utils";
1347
1527
 
1348
1528
  // src/credential-response/v1.3/z-credential-response.ts
1349
- import { z as z12 } from "zod";
1350
- var zDeferredCredentialResponseV1_3 = z12.strictObject({
1351
- interval: z12.number().int().positive().describe(
1529
+ import { z as z13 } from "zod";
1530
+ var zDeferredCredentialResponseV1_3 = z13.strictObject({
1531
+ interval: z13.number().int().positive().describe(
1352
1532
  "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"
1353
1533
  ),
1354
- transaction_id: z12.string().nonempty()
1534
+ transaction_id: z13.string().nonempty()
1355
1535
  });
1356
- var zCredentialResponseV1_3 = z12.union([
1536
+ var zCredentialResponseV1_3 = z13.union([
1357
1537
  zImmediateCredentialResponse,
1358
1538
  zDeferredCredentialResponseV1_3
1359
1539
  ]);
@@ -1384,6 +1564,9 @@ function createCredentialResponseV1_3(flow) {
1384
1564
 
1385
1565
  // src/credential-response/create-credential-response.ts
1386
1566
  var dispatchBuildVersionedResponse = createVersionDispatcher6({
1567
+ [ItWalletSpecsVersion9.APTITUDE]: (o) => createCredentialResponseV1_3(
1568
+ o.flow
1569
+ ),
1387
1570
  [ItWalletSpecsVersion9.V1_0]: (o) => createCredentialResponseV1_0(
1388
1571
  o.flow
1389
1572
  ),
@@ -1451,10 +1634,10 @@ import {
1451
1634
 
1452
1635
  // src/credential-response/z-credential-response.ts
1453
1636
  import { zAlgValueNotNone, zJwk as zJwk3 } from "@pagopa/io-wallet-utils";
1454
- import { z as z13 } from "zod";
1455
- var zCredentialResponseEncryption = z13.looseObject({
1637
+ import { z as z14 } from "zod";
1638
+ var zCredentialResponseEncryption = z14.looseObject({
1456
1639
  alg: zAlgValueNotNone,
1457
- enc: z13.string(),
1640
+ enc: z14.string(),
1458
1641
  jwk: zJwk3
1459
1642
  });
1460
1643
 
@@ -1511,7 +1694,7 @@ import {
1511
1694
  hasStatusOrThrow as hasStatusOrThrow4,
1512
1695
  parseWithErrorHandling as parseWithErrorHandling7
1513
1696
  } from "@pagopa/io-wallet-utils";
1514
- import z15 from "zod";
1697
+ import z16 from "zod";
1515
1698
 
1516
1699
  // src/metadata/z-metadata-response.ts
1517
1700
  import {
@@ -1520,33 +1703,33 @@ import {
1520
1703
  itWalletMetadataV1_3,
1521
1704
  itWalletMetadataV1_4
1522
1705
  } from "@pagopa/io-wallet-oid-federation";
1523
- import { z as z14 } from "zod";
1524
- var zMetadataResponseV1_0 = z14.object({
1525
- discoveredVia: z14.enum(["federation"]),
1706
+ import { z as z15 } from "zod";
1707
+ var zMetadataResponseV1_0 = z15.object({
1708
+ discoveredVia: z15.enum(["federation"]),
1526
1709
  metadata: itWalletMetadataV1_0,
1527
1710
  openid_federation_claims: itWalletEntityStatementClaimsSchema
1528
1711
  });
1529
- var zMetadataResponseV1_3 = z14.object({
1712
+ var zMetadataResponseV1_3 = z15.object({
1530
1713
  /**
1531
1714
  * Entity statement claims of the Authorization Server, present only when the
1532
1715
  * selected authorization server was resolved through a federation entity
1533
1716
  * distinct from the Credential Issuer.
1534
1717
  */
1535
1718
  authorization_server_federation_claims: itWalletEntityStatementClaimsSchema.optional(),
1536
- discoveredVia: z14.enum(["federation", "oid4vci"]),
1719
+ discoveredVia: z15.enum(["federation", "oid4vci"]),
1537
1720
  metadata: itWalletMetadataV1_3,
1538
1721
  openid_federation_claims: itWalletEntityStatementClaimsSchema.optional()
1539
1722
  });
1540
1723
  var zMetadataResponseV1_4 = zMetadataResponseV1_3.extend({
1541
1724
  metadata: itWalletMetadataV1_4
1542
1725
  });
1543
- var zMetadataResponse = z14.union([
1726
+ var zMetadataResponse = z15.union([
1544
1727
  zMetadataResponseV1_0,
1545
1728
  zMetadataResponseV1_3,
1546
1729
  zMetadataResponseV1_4
1547
1730
  ]);
1548
- var zPartialIssuerMetadata = z14.looseObject({
1549
- authorization_servers: z14.tuple([z14.url()], z14.url()).optional()
1731
+ var zPartialIssuerMetadata = z15.looseObject({
1732
+ authorization_servers: z15.tuple([z15.url()], z15.url()).optional()
1550
1733
  });
1551
1734
 
1552
1735
  // src/metadata/fetch-metadata.ts
@@ -1613,7 +1796,7 @@ async function applyFederationAuthorizationServerSelection(fetch, federationResu
1613
1796
  if (!selectedAuthorizationServer || selectedAuthorizationServer === credentialIssuer) {
1614
1797
  return federationResult;
1615
1798
  }
1616
- const parsedSelectedAuthorizationServer = z15.url().safeParse(selectedAuthorizationServer);
1799
+ const parsedSelectedAuthorizationServer = z16.url().safeParse(selectedAuthorizationServer);
1617
1800
  if (!parsedSelectedAuthorizationServer.success || !parsedSelectedAuthorizationServer.data.startsWith("https://")) {
1618
1801
  throw new ValidationError9(
1619
1802
  "selected authorization server is not a valid HTTPS URL"
@@ -1651,7 +1834,7 @@ async function fallbackDiscovery(fetch, baseUrl, authorizationServer) {
1651
1834
  let oauthAuthorizationServer;
1652
1835
  if (authorizationServers && authorizationServers.length > 0) {
1653
1836
  const selectedAuthorizationServer = authorizationServer ?? authorizationServers[0];
1654
- const parsedUrl = z15.url().safeParse(selectedAuthorizationServer);
1837
+ const parsedUrl = z16.url().safeParse(selectedAuthorizationServer);
1655
1838
  if (!parsedUrl.success || !parsedUrl.data.startsWith("https://")) {
1656
1839
  throw new ValidationError9(
1657
1840
  "selected authorization server is not a valid HTTPS URL"
@@ -1729,13 +1912,14 @@ async function fetchMetadataV1_4(options) {
1729
1912
  );
1730
1913
  }
1731
1914
  var dispatchFetchMetadata = createVersionDispatcher7({
1915
+ [ItWalletSpecsVersion10.APTITUDE]: (o) => fetchMetadataV1_4(o),
1732
1916
  [ItWalletSpecsVersion10.V1_0]: (o) => fetchMetadataV1_0(o),
1733
1917
  [ItWalletSpecsVersion10.V1_3]: (o) => fetchMetadataV1_3(o),
1734
1918
  [ItWalletSpecsVersion10.V1_4]: (o) => fetchMetadataV1_4(o)
1735
1919
  });
1736
1920
  async function fetchMetadata(options) {
1737
1921
  try {
1738
- const urlValidation = z15.url().safeParse(options.credentialIssuerUrl);
1922
+ const urlValidation = z16.url().safeParse(options.credentialIssuerUrl);
1739
1923
  if (!urlValidation.success || !urlValidation.data.startsWith("https://")) {
1740
1924
  throw new ValidationError9(
1741
1925
  "credentialIssuerUrl must be a valid HTTPS URL"
@@ -1896,7 +2080,7 @@ var WalletProvider = class {
1896
2080
  * status: { status_list: { idx: 2, uri: "https://status.example.com" } } // Optional
1897
2081
  * });
1898
2082
  *
1899
- * @example v1.4 - Wallet attestation with required wallet_link and wallet_name
2083
+ * @example v1.4, APTITUDE - Wallet attestation with required wallet_link and wallet_name
1900
2084
  * const jwt = await provider.createItWalletAttestationJwt({
1901
2085
  * callbacks: { hash: myHashCallback, signJwt: mySignJwtCallback },
1902
2086
  * dpopJwkPublic: myJwk,
@@ -1915,6 +2099,18 @@ var WalletProvider = class {
1915
2099
  */
1916
2100
  async createItWalletAttestationJwt(options) {
1917
2101
  return dispatchByVersion(this.specVersion, {
2102
+ [ItWalletSpecsVersion11.APTITUDE]: () => {
2103
+ assertV1_4Options(options);
2104
+ return createWalletAttestationJwtV1_4({
2105
+ callbacks: options.callbacks,
2106
+ dpopJwkPublic: options.dpopJwkPublic,
2107
+ expiresAt: options.expiresAt,
2108
+ issuer: options.issuer,
2109
+ signer: options.signer,
2110
+ walletLink: options.walletLink,
2111
+ walletName: options.walletName
2112
+ });
2113
+ },
1918
2114
  [ItWalletSpecsVersion11.V1_0]: () => {
1919
2115
  assertV1_0Options(options);
1920
2116
  return createWalletAttestationJwtV1_0({
@@ -1958,6 +2154,7 @@ var WalletProvider = class {
1958
2154
  }
1959
2155
  };
1960
2156
  export {
2157
+ CREDENTIAL_OFFER_GRANTS,
1961
2158
  CreateCredentialResponseError,
1962
2159
  CredentialAuthorizationHeaderError,
1963
2160
  CredentialOfferError,