@pagopa/io-wallet-oid4vci 2.0.0-apt → 2.0.0-launchpad
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +22 -135
- package/dist/index.d.ts +22 -135
- package/dist/index.js +115 -313
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +115 -312
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -30,7 +30,6 @@ 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,
|
|
34
33
|
CreateCredentialResponseError: () => CreateCredentialResponseError,
|
|
35
34
|
CredentialAuthorizationHeaderError: () => CredentialAuthorizationHeaderError,
|
|
36
35
|
CredentialOfferError: () => CredentialOfferError,
|
|
@@ -286,91 +285,6 @@ async function sendAuthorizationResponseAndExtractCode(options) {
|
|
|
286
285
|
}
|
|
287
286
|
}
|
|
288
287
|
|
|
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
|
-
|
|
374
288
|
// src/credential-offer/extract-grant-details.ts
|
|
375
289
|
var import_io_wallet_utils3 = require("@pagopa/io-wallet-utils");
|
|
376
290
|
function requireAuthorizationCodeGrant(credentialOffer) {
|
|
@@ -383,70 +297,33 @@ function requireAuthorizationCodeGrant(credentialOffer) {
|
|
|
383
297
|
}
|
|
384
298
|
return authCodeGrant;
|
|
385
299
|
}
|
|
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
|
-
}
|
|
398
300
|
function extractGrantDetailsV1_3(options) {
|
|
399
301
|
const authCodeGrant = requireAuthorizationCodeGrant(options.credentialOffer);
|
|
400
302
|
return {
|
|
401
|
-
|
|
303
|
+
authorizationCodeGrant: {
|
|
402
304
|
authorizationServer: authCodeGrant.authorization_server,
|
|
403
305
|
issuerState: authCodeGrant.issuer_state,
|
|
404
306
|
scope: authCodeGrant.scope
|
|
405
|
-
}
|
|
307
|
+
},
|
|
308
|
+
grantType: "authorization_code"
|
|
406
309
|
};
|
|
407
310
|
}
|
|
408
311
|
function extractGrantDetailsV1_4(options) {
|
|
409
312
|
const authCodeGrant = requireAuthorizationCodeGrant(options.credentialOffer);
|
|
410
313
|
return {
|
|
411
|
-
|
|
314
|
+
authorizationCodeGrant: {
|
|
412
315
|
authorizationServer: authCodeGrant.authorization_server,
|
|
413
316
|
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
|
-
}
|
|
429
317
|
},
|
|
430
|
-
|
|
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
|
-
}
|
|
318
|
+
grantType: "authorization_code"
|
|
437
319
|
};
|
|
438
320
|
}
|
|
439
321
|
var dispatchExtractGrantDetails = (0, import_io_wallet_utils3.createVersionDispatcher)({
|
|
440
|
-
[import_io_wallet_utils3.ItWalletSpecsVersion.APTITUDE]: (o) => extractGrantDetailsAPTITUDE(o),
|
|
441
322
|
[import_io_wallet_utils3.ItWalletSpecsVersion.V1_0]: () => {
|
|
442
323
|
throw new import_io_wallet_utils3.ItWalletSpecsVersionError(
|
|
443
324
|
"extractGrantDetails",
|
|
444
325
|
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
|
-
]
|
|
326
|
+
[import_io_wallet_utils3.ItWalletSpecsVersion.V1_3, import_io_wallet_utils3.ItWalletSpecsVersion.V1_4]
|
|
450
327
|
);
|
|
451
328
|
},
|
|
452
329
|
[import_io_wallet_utils3.ItWalletSpecsVersion.V1_3]: (o) => extractGrantDetailsV1_3(o),
|
|
@@ -457,46 +334,46 @@ function extractGrantDetails(options) {
|
|
|
457
334
|
}
|
|
458
335
|
|
|
459
336
|
// src/credential-offer/z-credential-offer.ts
|
|
460
|
-
var
|
|
337
|
+
var import_zod4 = require("zod");
|
|
461
338
|
|
|
462
339
|
// src/credential-offer/v1.3/z-credential-offer.ts
|
|
463
|
-
var
|
|
464
|
-
var zAuthorizationCodeGrantV1_3 =
|
|
340
|
+
var import_zod2 = require("zod");
|
|
341
|
+
var zAuthorizationCodeGrantV1_3 = import_zod2.z.object({
|
|
465
342
|
/**
|
|
466
343
|
* CONDITIONALLY REQUIRED. HTTPS URL of the Authorization Server.
|
|
467
344
|
* REQUIRED only when the Credential Issuer uses multiple Authorization Servers.
|
|
468
345
|
* If present, MUST match one of the authorization_servers in the Credential Issuer metadata.
|
|
469
346
|
*/
|
|
470
|
-
authorization_server:
|
|
347
|
+
authorization_server: import_zod2.z.url().optional(),
|
|
471
348
|
/**
|
|
472
349
|
* OPTIONAL. String value representing the issuer state.
|
|
473
350
|
* Used to correlate the authorization request with the credential offer.
|
|
474
351
|
*/
|
|
475
|
-
issuer_state:
|
|
352
|
+
issuer_state: import_zod2.z.string().optional(),
|
|
476
353
|
/**
|
|
477
354
|
* REQUIRED. OAuth 2.0 scope value.
|
|
478
355
|
* Defines the scope of access requested by the credential offer.
|
|
479
356
|
*/
|
|
480
|
-
scope:
|
|
357
|
+
scope: import_zod2.z.string()
|
|
481
358
|
});
|
|
482
|
-
var zCredentialOfferGrantsV1_3 =
|
|
359
|
+
var zCredentialOfferGrantsV1_3 = import_zod2.z.object({
|
|
483
360
|
/**
|
|
484
361
|
* REQUIRED. Authorization Code grant details.
|
|
485
362
|
* IT-Wallet v1.3 only supports authorization_code grant.
|
|
486
363
|
*/
|
|
487
364
|
authorization_code: zAuthorizationCodeGrantV1_3
|
|
488
365
|
});
|
|
489
|
-
var zCredentialOfferV1_3 =
|
|
366
|
+
var zCredentialOfferV1_3 = import_zod2.z.object({
|
|
490
367
|
/**
|
|
491
368
|
* REQUIRED. Array of credential configuration identifiers.
|
|
492
369
|
* References the types of credentials offered as defined in the Credential Issuer metadata.
|
|
493
370
|
*/
|
|
494
|
-
credential_configuration_ids:
|
|
371
|
+
credential_configuration_ids: import_zod2.z.array(import_zod2.z.string()).min(1),
|
|
495
372
|
/**
|
|
496
373
|
* REQUIRED. HTTPS URL of the Credential Issuer.
|
|
497
374
|
* The Credential Issuer from which the wallet will request credentials.
|
|
498
375
|
*/
|
|
499
|
-
credential_issuer:
|
|
376
|
+
credential_issuer: import_zod2.z.url(),
|
|
500
377
|
/**
|
|
501
378
|
* REQUIRED. Grant information for the credential offer.
|
|
502
379
|
* IT-Wallet v1.3 requires authorization_code grant.
|
|
@@ -505,38 +382,38 @@ var zCredentialOfferV1_3 = import_zod3.z.object({
|
|
|
505
382
|
});
|
|
506
383
|
|
|
507
384
|
// src/credential-offer/v1.4/z-credential-offer.ts
|
|
508
|
-
var
|
|
509
|
-
var zAuthorizationCodeGrantV1_4 =
|
|
385
|
+
var import_zod3 = require("zod");
|
|
386
|
+
var zAuthorizationCodeGrantV1_4 = import_zod3.z.object({
|
|
510
387
|
/**
|
|
511
388
|
* CONDITIONALLY REQUIRED. HTTPS URL of the Authorization Server.
|
|
512
389
|
* REQUIRED only when the Credential Issuer uses multiple Authorization Servers.
|
|
513
390
|
* If present, MUST match one of the authorization_servers in the Credential Issuer metadata.
|
|
514
391
|
*/
|
|
515
|
-
authorization_server:
|
|
392
|
+
authorization_server: import_zod3.z.url().optional(),
|
|
516
393
|
/**
|
|
517
394
|
* OPTIONAL. String value representing the issuer state.
|
|
518
395
|
* Used to correlate the authorization request with the credential offer.
|
|
519
396
|
*/
|
|
520
|
-
issuer_state:
|
|
397
|
+
issuer_state: import_zod3.z.string().optional()
|
|
521
398
|
});
|
|
522
|
-
var zCredentialOfferGrantsV1_4 =
|
|
399
|
+
var zCredentialOfferGrantsV1_4 = import_zod3.z.object({
|
|
523
400
|
/**
|
|
524
401
|
* REQUIRED. Authorization Code grant details.
|
|
525
402
|
* IT-Wallet v1.4 only supports authorization_code grant.
|
|
526
403
|
*/
|
|
527
404
|
authorization_code: zAuthorizationCodeGrantV1_4
|
|
528
405
|
});
|
|
529
|
-
var zCredentialOfferV1_4 =
|
|
406
|
+
var zCredentialOfferV1_4 = import_zod3.z.object({
|
|
530
407
|
/**
|
|
531
408
|
* REQUIRED. Array of credential configuration identifiers.
|
|
532
409
|
* References the types of credentials offered as defined in the Credential Issuer metadata.
|
|
533
410
|
*/
|
|
534
|
-
credential_configuration_ids:
|
|
411
|
+
credential_configuration_ids: import_zod3.z.array(import_zod3.z.string()).min(1),
|
|
535
412
|
/**
|
|
536
413
|
* REQUIRED. HTTPS URL of the Credential Issuer.
|
|
537
414
|
* The Credential Issuer from which the wallet will request credentials.
|
|
538
415
|
*/
|
|
539
|
-
credential_issuer:
|
|
416
|
+
credential_issuer: import_zod3.z.url(),
|
|
540
417
|
/**
|
|
541
418
|
* REQUIRED. Grant information for the credential offer.
|
|
542
419
|
* IT-Wallet v1.4 requires authorization_code grant.
|
|
@@ -545,22 +422,22 @@ var zCredentialOfferV1_4 = import_zod4.z.object({
|
|
|
545
422
|
});
|
|
546
423
|
|
|
547
424
|
// src/credential-offer/z-credential-offer.ts
|
|
548
|
-
var zCredentialOfferUri =
|
|
425
|
+
var zCredentialOfferUri = import_zod4.z.object({
|
|
549
426
|
/**
|
|
550
427
|
* OPTIONAL. Inline credential offer JSON (by value).
|
|
551
428
|
* URL-encoded JSON string containing the credential offer.
|
|
552
429
|
*/
|
|
553
|
-
credential_offer:
|
|
430
|
+
credential_offer: import_zod4.z.string().optional(),
|
|
554
431
|
/**
|
|
555
432
|
* OPTIONAL. URL pointing to the credential offer JSON (by reference).
|
|
556
433
|
* HTTPS URL where the credential offer can be fetched.
|
|
557
434
|
*/
|
|
558
|
-
credential_offer_uri:
|
|
435
|
+
credential_offer_uri: import_zod4.z.url().optional(),
|
|
559
436
|
/**
|
|
560
437
|
* URL scheme used for the credential offer.
|
|
561
438
|
* Determines the invocation method.
|
|
562
439
|
*/
|
|
563
|
-
scheme:
|
|
440
|
+
scheme: import_zod4.z.enum(["openid-credential-offer", "haip-vci", "https"])
|
|
564
441
|
}).refine((data) => data.credential_offer || data.credential_offer_uri, {
|
|
565
442
|
message: "Either credential_offer or credential_offer_uri must be present"
|
|
566
443
|
});
|
|
@@ -605,17 +482,11 @@ function parseCredentialOfferForVersion(config, data) {
|
|
|
605
482
|
return zCredentialOfferV1_3.parse(data);
|
|
606
483
|
case import_io_wallet_utils4.ItWalletSpecsVersion.V1_4:
|
|
607
484
|
return zCredentialOfferV1_4.parse(data);
|
|
608
|
-
case import_io_wallet_utils4.ItWalletSpecsVersion.APTITUDE:
|
|
609
|
-
return zCredentialOfferAPTITUDE.parse(data);
|
|
610
485
|
default:
|
|
611
486
|
throw new import_io_wallet_utils4.ItWalletSpecsVersionError(
|
|
612
487
|
"resolveCredentialOffer",
|
|
613
488
|
config.itWalletSpecsVersion,
|
|
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
|
-
]
|
|
489
|
+
[import_io_wallet_utils4.ItWalletSpecsVersion.V1_3, import_io_wallet_utils4.ItWalletSpecsVersion.V1_4]
|
|
619
490
|
);
|
|
620
491
|
}
|
|
621
492
|
}
|
|
@@ -682,7 +553,7 @@ function assertAuthorizationServerAllowed(authorizationServer, authorizationServ
|
|
|
682
553
|
}
|
|
683
554
|
}
|
|
684
555
|
function validateBaseCredentialOffer(options) {
|
|
685
|
-
const { credentialOffer, versionLabel } = options;
|
|
556
|
+
const { credentialIssuerMetadata, credentialOffer, versionLabel } = options;
|
|
686
557
|
if (!credentialOffer.credential_issuer.startsWith("https://")) {
|
|
687
558
|
throw new CredentialOfferError("credential_issuer must be an HTTPS URL");
|
|
688
559
|
}
|
|
@@ -696,11 +567,6 @@ function validateBaseCredentialOffer(options) {
|
|
|
696
567
|
`grants is REQUIRED for IT-Wallet ${versionLabel}`
|
|
697
568
|
);
|
|
698
569
|
}
|
|
699
|
-
}
|
|
700
|
-
async function validateCredentialOfferV1_3(options) {
|
|
701
|
-
const versionLabel = "v1.3";
|
|
702
|
-
const { credentialIssuerMetadata, credentialOffer } = options;
|
|
703
|
-
validateBaseCredentialOffer({ credentialOffer, versionLabel });
|
|
704
570
|
const authCodeGrant = credentialOffer.grants.authorization_code;
|
|
705
571
|
if (!authCodeGrant) {
|
|
706
572
|
throw new CredentialOfferError(
|
|
@@ -711,57 +577,30 @@ async function validateCredentialOfferV1_3(options) {
|
|
|
711
577
|
authCodeGrant.authorization_server,
|
|
712
578
|
credentialIssuerMetadata?.authorization_servers
|
|
713
579
|
);
|
|
580
|
+
}
|
|
581
|
+
async function validateCredentialOfferV1_3(options) {
|
|
582
|
+
validateBaseCredentialOffer({
|
|
583
|
+
credentialIssuerMetadata: options.credentialIssuerMetadata,
|
|
584
|
+
credentialOffer: options.credentialOffer,
|
|
585
|
+
versionLabel: "v1.3"
|
|
586
|
+
});
|
|
714
587
|
if (!options.credentialOffer.grants.authorization_code.scope) {
|
|
715
588
|
throw new CredentialOfferError("authorization_code.scope is REQUIRED");
|
|
716
589
|
}
|
|
717
590
|
}
|
|
718
591
|
async function validateCredentialOfferV1_4(options) {
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
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
|
-
);
|
|
592
|
+
validateBaseCredentialOffer({
|
|
593
|
+
credentialIssuerMetadata: options.credentialIssuerMetadata,
|
|
594
|
+
credentialOffer: options.credentialOffer,
|
|
595
|
+
versionLabel: "v1.4"
|
|
596
|
+
});
|
|
751
597
|
}
|
|
752
598
|
var dispatchValidateCredentialOffer = (0, import_io_wallet_utils5.createVersionDispatcher)({
|
|
753
|
-
[import_io_wallet_utils5.ItWalletSpecsVersion.APTITUDE]: (o) => validateCredentialOfferAPTITUDE(
|
|
754
|
-
o
|
|
755
|
-
),
|
|
756
599
|
[import_io_wallet_utils5.ItWalletSpecsVersion.V1_0]: () => {
|
|
757
600
|
throw new import_io_wallet_utils5.ItWalletSpecsVersionError(
|
|
758
601
|
"validateCredentialOffer",
|
|
759
602
|
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
|
-
]
|
|
603
|
+
[import_io_wallet_utils5.ItWalletSpecsVersion.V1_3, import_io_wallet_utils5.ItWalletSpecsVersion.V1_4]
|
|
765
604
|
);
|
|
766
605
|
},
|
|
767
606
|
[import_io_wallet_utils5.ItWalletSpecsVersion.V1_3]: (o) => validateCredentialOfferV1_3(o),
|
|
@@ -778,18 +617,18 @@ var import_io_wallet_utils8 = require("@pagopa/io-wallet-utils");
|
|
|
778
617
|
var import_io_wallet_utils6 = require("@pagopa/io-wallet-utils");
|
|
779
618
|
|
|
780
619
|
// src/credential-request/v1.0/z-credential.ts
|
|
781
|
-
var
|
|
620
|
+
var import_zod6 = require("zod");
|
|
782
621
|
|
|
783
622
|
// src/credential-request/z-base-credential-request.ts
|
|
784
|
-
var
|
|
785
|
-
var zBaseCredentialRequest =
|
|
786
|
-
credential_configuration_id:
|
|
623
|
+
var import_zod5 = require("zod");
|
|
624
|
+
var zBaseCredentialRequest = import_zod5.z.object({
|
|
625
|
+
credential_configuration_id: import_zod5.z.string().optional().describe(
|
|
787
626
|
"REQUIRED if credential_identifier param is absent. MUST NOT be used otherwise."
|
|
788
627
|
),
|
|
789
|
-
credential_identifier:
|
|
628
|
+
credential_identifier: import_zod5.z.string().optional().describe(
|
|
790
629
|
"REQUIRED when Authorization Details of type openid_credential was returned. MUST NOT be used if credential_configuration_id is present."
|
|
791
630
|
),
|
|
792
|
-
transaction_id:
|
|
631
|
+
transaction_id: import_zod5.z.string().optional().describe(
|
|
793
632
|
"REQUIRED only in case of deferred flow. MUST NOT be present in immediate flow."
|
|
794
633
|
)
|
|
795
634
|
});
|
|
@@ -811,9 +650,9 @@ function credentialRequestRefiner(data, ctx) {
|
|
|
811
650
|
}
|
|
812
651
|
|
|
813
652
|
// src/credential-request/v1.0/z-credential.ts
|
|
814
|
-
var zCredentialRequestProof =
|
|
815
|
-
jwt:
|
|
816
|
-
proof_type:
|
|
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")
|
|
817
656
|
// MUST be "jwt"
|
|
818
657
|
});
|
|
819
658
|
var zCredentialRequestV1_0 = zBaseCredentialRequest.extend({
|
|
@@ -862,10 +701,10 @@ var createCredentialRequest = async (options) => {
|
|
|
862
701
|
var import_io_wallet_utils7 = require("@pagopa/io-wallet-utils");
|
|
863
702
|
|
|
864
703
|
// src/credential-request/v1.3/z-credential.ts
|
|
865
|
-
var
|
|
866
|
-
var zCredentialRequestProofJwt =
|
|
867
|
-
var zCredentialRequestProofs =
|
|
868
|
-
jwt:
|
|
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)
|
|
869
708
|
});
|
|
870
709
|
var zCredentialRequestV1_3 = zBaseCredentialRequest.extend({
|
|
871
710
|
proofs: zCredentialRequestProofs.describe(
|
|
@@ -949,7 +788,6 @@ var createCredentialRequest2 = async (options) => {
|
|
|
949
788
|
|
|
950
789
|
// src/credential-request/create-credential-request.ts
|
|
951
790
|
var dispatchCreateCredentialRequest = (0, import_io_wallet_utils8.createVersionDispatcher)({
|
|
952
|
-
[import_io_wallet_utils8.ItWalletSpecsVersion.APTITUDE]: (o) => createCredentialRequest2(o),
|
|
953
791
|
[import_io_wallet_utils8.ItWalletSpecsVersion.V1_0]: (o) => createCredentialRequest(o),
|
|
954
792
|
[import_io_wallet_utils8.ItWalletSpecsVersion.V1_3]: (o) => createCredentialRequest2(o),
|
|
955
793
|
[import_io_wallet_utils8.ItWalletSpecsVersion.V1_4]: (o) => (
|
|
@@ -968,21 +806,21 @@ var import_io_wallet_utils10 = require("@pagopa/io-wallet-utils");
|
|
|
968
806
|
|
|
969
807
|
// src/credential-request/z-proof-jwt.ts
|
|
970
808
|
var import_io_wallet_utils9 = require("@pagopa/io-wallet-utils");
|
|
971
|
-
var
|
|
972
|
-
var zBaseProofJwtHeader =
|
|
973
|
-
alg:
|
|
809
|
+
var import_zod8 = require("zod");
|
|
810
|
+
var zBaseProofJwtHeader = import_zod8.z.object({
|
|
811
|
+
alg: import_zod8.z.string().min(1),
|
|
974
812
|
jwk: import_io_wallet_utils9.zJwk,
|
|
975
|
-
typ:
|
|
813
|
+
typ: import_zod8.z.literal("openid4vci-proof+jwt")
|
|
976
814
|
});
|
|
977
815
|
var zProofJwtHeaderV1_0 = zBaseProofJwtHeader.loose();
|
|
978
816
|
var zProofJwtHeaderV1_3 = zBaseProofJwtHeader.extend({
|
|
979
|
-
key_attestation:
|
|
817
|
+
key_attestation: import_zod8.z.string().min(1)
|
|
980
818
|
}).loose();
|
|
981
|
-
var zProofJwtPayload =
|
|
982
|
-
aud:
|
|
983
|
-
iat:
|
|
984
|
-
iss:
|
|
985
|
-
nonce:
|
|
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)
|
|
986
824
|
});
|
|
987
825
|
|
|
988
826
|
// src/credential-request/parse-credential-request.ts
|
|
@@ -1225,25 +1063,7 @@ function parseCredentialRequestV1_4(options) {
|
|
|
1225
1063
|
// V1_4 reuses V1_3 proof schema
|
|
1226
1064
|
});
|
|
1227
1065
|
}
|
|
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
1066
|
var dispatchParseCredentialRequest = (0, import_io_wallet_utils10.createVersionDispatcher)({
|
|
1246
|
-
[import_io_wallet_utils10.ItWalletSpecsVersion.APTITUDE]: parseCredentialRequestAPTITUDE,
|
|
1247
1067
|
[import_io_wallet_utils10.ItWalletSpecsVersion.V1_0]: parseCredentialRequestV1_0,
|
|
1248
1068
|
[import_io_wallet_utils10.ItWalletSpecsVersion.V1_3]: parseCredentialRequestV1_3,
|
|
1249
1069
|
[import_io_wallet_utils10.ItWalletSpecsVersion.V1_4]: parseCredentialRequestV1_4
|
|
@@ -1281,33 +1101,33 @@ var import_io_wallet_utils12 = require("@pagopa/io-wallet-utils");
|
|
|
1281
1101
|
// src/wallet-provider/z-key-attestation.ts
|
|
1282
1102
|
var import_io_wallet_oid_federation = require("@pagopa/io-wallet-oid-federation");
|
|
1283
1103
|
var import_io_wallet_utils11 = require("@pagopa/io-wallet-utils");
|
|
1284
|
-
var
|
|
1285
|
-
var zStatusList =
|
|
1286
|
-
idx:
|
|
1287
|
-
uri:
|
|
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()
|
|
1288
1108
|
});
|
|
1289
|
-
var zKeyAttestationStatus =
|
|
1109
|
+
var zKeyAttestationStatus = import_zod9.z.object({
|
|
1290
1110
|
status_list: zStatusList
|
|
1291
1111
|
});
|
|
1292
1112
|
var zKeyAttestationAlg = import_io_wallet_utils11.zItwSupportedSignatureAlg;
|
|
1293
|
-
var zKeyAttestationHeader =
|
|
1113
|
+
var zKeyAttestationHeader = import_zod9.z.object({
|
|
1294
1114
|
alg: zKeyAttestationAlg,
|
|
1295
|
-
kid:
|
|
1115
|
+
kid: import_zod9.z.string(),
|
|
1296
1116
|
trust_chain: import_io_wallet_utils11.zTrustChain.optional(),
|
|
1297
|
-
typ:
|
|
1117
|
+
typ: import_zod9.z.literal("key-attestation+jwt"),
|
|
1298
1118
|
x5c: import_io_wallet_utils11.zCertificateChain
|
|
1299
1119
|
});
|
|
1300
|
-
var zKeyAttestationPayload =
|
|
1301
|
-
attested_keys:
|
|
1302
|
-
certification:
|
|
1303
|
-
exp:
|
|
1304
|
-
iat:
|
|
1305
|
-
iss:
|
|
1306
|
-
key_storage:
|
|
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(),
|
|
1307
1127
|
status: zKeyAttestationStatus,
|
|
1308
|
-
user_authentication:
|
|
1128
|
+
user_authentication: import_zod9.z.array(import_io_wallet_oid_federation.zKeyStorageLevelV1_3).nonempty()
|
|
1309
1129
|
});
|
|
1310
|
-
var zKeyAttestationTypeHeader =
|
|
1130
|
+
var zKeyAttestationTypeHeader = import_zod9.z.literal("key-attestation+jwt");
|
|
1311
1131
|
var keyAttestationTypeHeader = zKeyAttestationTypeHeader.value;
|
|
1312
1132
|
|
|
1313
1133
|
// src/credential-request/verify-key-attestation-jwt.ts
|
|
@@ -1458,7 +1278,6 @@ async function verifyProofV1_3(options) {
|
|
|
1458
1278
|
return { header, keyAttestation: keyAttestationResult, payload, signer };
|
|
1459
1279
|
}
|
|
1460
1280
|
var dispatchVerifyProof = (0, import_io_wallet_utils13.createVersionDispatcher)({
|
|
1461
|
-
[import_io_wallet_utils13.ItWalletSpecsVersion.APTITUDE]: (o) => verifyProofV1_3(o),
|
|
1462
1281
|
[import_io_wallet_utils13.ItWalletSpecsVersion.V1_0]: (o) => verifyProofV1_0(o),
|
|
1463
1282
|
[import_io_wallet_utils13.ItWalletSpecsVersion.V1_3]: (o) => verifyProofV1_3(o),
|
|
1464
1283
|
[import_io_wallet_utils13.ItWalletSpecsVersion.V1_4]: (o) => verifyProofV1_3(o)
|
|
@@ -1490,30 +1309,30 @@ var import_io_wallet_utils16 = require("@pagopa/io-wallet-utils");
|
|
|
1490
1309
|
var import_io_wallet_utils14 = require("@pagopa/io-wallet-utils");
|
|
1491
1310
|
|
|
1492
1311
|
// src/credential-response/v1.0/z-credential-response.ts
|
|
1493
|
-
var
|
|
1312
|
+
var import_zod11 = require("zod");
|
|
1494
1313
|
|
|
1495
1314
|
// src/credential-response/z-immediate-credential-response.ts
|
|
1496
|
-
var
|
|
1497
|
-
var zCredentialObject =
|
|
1498
|
-
credential:
|
|
1315
|
+
var import_zod10 = require("zod");
|
|
1316
|
+
var zCredentialObject = import_zod10.z.object({
|
|
1317
|
+
credential: import_zod10.z.string()
|
|
1499
1318
|
});
|
|
1500
|
-
var zImmediateCredentialResponse =
|
|
1501
|
-
credentials:
|
|
1319
|
+
var zImmediateCredentialResponse = import_zod10.z.strictObject({
|
|
1320
|
+
credentials: import_zod10.z.array(zCredentialObject).nonempty().describe(
|
|
1502
1321
|
"Conditional. Array of issued Digital Credentials as JSON objects with `credential` member containing encoded credential string. Present for immediate issuance (HTTP 200)."
|
|
1503
1322
|
),
|
|
1504
|
-
notification_id:
|
|
1323
|
+
notification_id: import_zod10.z.string().optional().describe(
|
|
1505
1324
|
"OPTIONAL. Identifier for notification requests. Only present with credentials parameter."
|
|
1506
1325
|
)
|
|
1507
1326
|
});
|
|
1508
1327
|
|
|
1509
1328
|
// src/credential-response/v1.0/z-credential-response.ts
|
|
1510
|
-
var zDeferredCredentialResponseV1_0 =
|
|
1511
|
-
lead_time:
|
|
1329
|
+
var zDeferredCredentialResponseV1_0 = import_zod11.z.strictObject({
|
|
1330
|
+
lead_time: import_zod11.z.number().int().positive().describe(
|
|
1512
1331
|
"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."
|
|
1513
1332
|
),
|
|
1514
|
-
transaction_id:
|
|
1333
|
+
transaction_id: import_zod11.z.string().nonempty()
|
|
1515
1334
|
});
|
|
1516
|
-
var zCredentialResponseV1_0 =
|
|
1335
|
+
var zCredentialResponseV1_0 = import_zod11.z.union([
|
|
1517
1336
|
zImmediateCredentialResponse,
|
|
1518
1337
|
zDeferredCredentialResponseV1_0
|
|
1519
1338
|
]);
|
|
@@ -1546,14 +1365,14 @@ function createCredentialResponseV1_0(flow) {
|
|
|
1546
1365
|
var import_io_wallet_utils15 = require("@pagopa/io-wallet-utils");
|
|
1547
1366
|
|
|
1548
1367
|
// src/credential-response/v1.3/z-credential-response.ts
|
|
1549
|
-
var
|
|
1550
|
-
var zDeferredCredentialResponseV1_3 =
|
|
1551
|
-
interval:
|
|
1368
|
+
var import_zod12 = require("zod");
|
|
1369
|
+
var zDeferredCredentialResponseV1_3 = import_zod12.z.strictObject({
|
|
1370
|
+
interval: import_zod12.z.number().int().positive().describe(
|
|
1552
1371
|
"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"
|
|
1553
1372
|
),
|
|
1554
|
-
transaction_id:
|
|
1373
|
+
transaction_id: import_zod12.z.string().nonempty()
|
|
1555
1374
|
});
|
|
1556
|
-
var zCredentialResponseV1_3 =
|
|
1375
|
+
var zCredentialResponseV1_3 = import_zod12.z.union([
|
|
1557
1376
|
zImmediateCredentialResponse,
|
|
1558
1377
|
zDeferredCredentialResponseV1_3
|
|
1559
1378
|
]);
|
|
@@ -1584,9 +1403,6 @@ function createCredentialResponseV1_3(flow) {
|
|
|
1584
1403
|
|
|
1585
1404
|
// src/credential-response/create-credential-response.ts
|
|
1586
1405
|
var dispatchBuildVersionedResponse = (0, import_io_wallet_utils16.createVersionDispatcher)({
|
|
1587
|
-
[import_io_wallet_utils16.ItWalletSpecsVersion.APTITUDE]: (o) => createCredentialResponseV1_3(
|
|
1588
|
-
o.flow
|
|
1589
|
-
),
|
|
1590
1406
|
[import_io_wallet_utils16.ItWalletSpecsVersion.V1_0]: (o) => createCredentialResponseV1_0(
|
|
1591
1407
|
o.flow
|
|
1592
1408
|
),
|
|
@@ -1646,10 +1462,10 @@ var import_io_wallet_utils18 = require("@pagopa/io-wallet-utils");
|
|
|
1646
1462
|
|
|
1647
1463
|
// src/credential-response/z-credential-response.ts
|
|
1648
1464
|
var import_io_wallet_utils17 = require("@pagopa/io-wallet-utils");
|
|
1649
|
-
var
|
|
1650
|
-
var zCredentialResponseEncryption =
|
|
1465
|
+
var import_zod13 = require("zod");
|
|
1466
|
+
var zCredentialResponseEncryption = import_zod13.z.looseObject({
|
|
1651
1467
|
alg: import_io_wallet_utils17.zAlgValueNotNone,
|
|
1652
|
-
enc:
|
|
1468
|
+
enc: import_zod13.z.string(),
|
|
1653
1469
|
jwk: import_io_wallet_utils17.zJwk
|
|
1654
1470
|
});
|
|
1655
1471
|
|
|
@@ -1696,37 +1512,37 @@ async function fetchCredentialResponse(options) {
|
|
|
1696
1512
|
// src/metadata/fetch-metadata.ts
|
|
1697
1513
|
var import_io_wallet_oid_federation3 = require("@pagopa/io-wallet-oid-federation");
|
|
1698
1514
|
var import_io_wallet_utils19 = require("@pagopa/io-wallet-utils");
|
|
1699
|
-
var
|
|
1515
|
+
var import_zod15 = __toESM(require("zod"));
|
|
1700
1516
|
|
|
1701
1517
|
// src/metadata/z-metadata-response.ts
|
|
1702
1518
|
var import_io_wallet_oid_federation2 = require("@pagopa/io-wallet-oid-federation");
|
|
1703
|
-
var
|
|
1704
|
-
var zMetadataResponseV1_0 =
|
|
1705
|
-
discoveredVia:
|
|
1519
|
+
var import_zod14 = require("zod");
|
|
1520
|
+
var zMetadataResponseV1_0 = import_zod14.z.object({
|
|
1521
|
+
discoveredVia: import_zod14.z.enum(["federation"]),
|
|
1706
1522
|
metadata: import_io_wallet_oid_federation2.itWalletMetadataV1_0,
|
|
1707
1523
|
openid_federation_claims: import_io_wallet_oid_federation2.itWalletEntityStatementClaimsSchema
|
|
1708
1524
|
});
|
|
1709
|
-
var zMetadataResponseV1_3 =
|
|
1525
|
+
var zMetadataResponseV1_3 = import_zod14.z.object({
|
|
1710
1526
|
/**
|
|
1711
1527
|
* Entity statement claims of the Authorization Server, present only when the
|
|
1712
1528
|
* selected authorization server was resolved through a federation entity
|
|
1713
1529
|
* distinct from the Credential Issuer.
|
|
1714
1530
|
*/
|
|
1715
1531
|
authorization_server_federation_claims: import_io_wallet_oid_federation2.itWalletEntityStatementClaimsSchema.optional(),
|
|
1716
|
-
discoveredVia:
|
|
1532
|
+
discoveredVia: import_zod14.z.enum(["federation", "oid4vci"]),
|
|
1717
1533
|
metadata: import_io_wallet_oid_federation2.itWalletMetadataV1_3,
|
|
1718
1534
|
openid_federation_claims: import_io_wallet_oid_federation2.itWalletEntityStatementClaimsSchema.optional()
|
|
1719
1535
|
});
|
|
1720
1536
|
var zMetadataResponseV1_4 = zMetadataResponseV1_3.extend({
|
|
1721
1537
|
metadata: import_io_wallet_oid_federation2.itWalletMetadataV1_4
|
|
1722
1538
|
});
|
|
1723
|
-
var zMetadataResponse =
|
|
1539
|
+
var zMetadataResponse = import_zod14.z.union([
|
|
1724
1540
|
zMetadataResponseV1_0,
|
|
1725
1541
|
zMetadataResponseV1_3,
|
|
1726
1542
|
zMetadataResponseV1_4
|
|
1727
1543
|
]);
|
|
1728
|
-
var zPartialIssuerMetadata =
|
|
1729
|
-
authorization_servers:
|
|
1544
|
+
var zPartialIssuerMetadata = import_zod14.z.looseObject({
|
|
1545
|
+
authorization_servers: import_zod14.z.tuple([import_zod14.z.url()], import_zod14.z.url()).optional()
|
|
1730
1546
|
});
|
|
1731
1547
|
|
|
1732
1548
|
// src/metadata/fetch-metadata.ts
|
|
@@ -1793,7 +1609,7 @@ async function applyFederationAuthorizationServerSelection(fetch, federationResu
|
|
|
1793
1609
|
if (!selectedAuthorizationServer || selectedAuthorizationServer === credentialIssuer) {
|
|
1794
1610
|
return federationResult;
|
|
1795
1611
|
}
|
|
1796
|
-
const parsedSelectedAuthorizationServer =
|
|
1612
|
+
const parsedSelectedAuthorizationServer = import_zod15.default.url().safeParse(selectedAuthorizationServer);
|
|
1797
1613
|
if (!parsedSelectedAuthorizationServer.success || !parsedSelectedAuthorizationServer.data.startsWith("https://")) {
|
|
1798
1614
|
throw new import_io_wallet_utils19.ValidationError(
|
|
1799
1615
|
"selected authorization server is not a valid HTTPS URL"
|
|
@@ -1831,7 +1647,7 @@ async function fallbackDiscovery(fetch, baseUrl, authorizationServer) {
|
|
|
1831
1647
|
let oauthAuthorizationServer;
|
|
1832
1648
|
if (authorizationServers && authorizationServers.length > 0) {
|
|
1833
1649
|
const selectedAuthorizationServer = authorizationServer ?? authorizationServers[0];
|
|
1834
|
-
const parsedUrl =
|
|
1650
|
+
const parsedUrl = import_zod15.default.url().safeParse(selectedAuthorizationServer);
|
|
1835
1651
|
if (!parsedUrl.success || !parsedUrl.data.startsWith("https://")) {
|
|
1836
1652
|
throw new import_io_wallet_utils19.ValidationError(
|
|
1837
1653
|
"selected authorization server is not a valid HTTPS URL"
|
|
@@ -1909,14 +1725,13 @@ async function fetchMetadataV1_4(options) {
|
|
|
1909
1725
|
);
|
|
1910
1726
|
}
|
|
1911
1727
|
var dispatchFetchMetadata = (0, import_io_wallet_utils19.createVersionDispatcher)({
|
|
1912
|
-
[import_io_wallet_utils19.ItWalletSpecsVersion.APTITUDE]: (o) => fetchMetadataV1_4(o),
|
|
1913
1728
|
[import_io_wallet_utils19.ItWalletSpecsVersion.V1_0]: (o) => fetchMetadataV1_0(o),
|
|
1914
1729
|
[import_io_wallet_utils19.ItWalletSpecsVersion.V1_3]: (o) => fetchMetadataV1_3(o),
|
|
1915
1730
|
[import_io_wallet_utils19.ItWalletSpecsVersion.V1_4]: (o) => fetchMetadataV1_4(o)
|
|
1916
1731
|
});
|
|
1917
1732
|
async function fetchMetadata(options) {
|
|
1918
1733
|
try {
|
|
1919
|
-
const urlValidation =
|
|
1734
|
+
const urlValidation = import_zod15.default.url().safeParse(options.credentialIssuerUrl);
|
|
1920
1735
|
if (!urlValidation.success || !urlValidation.data.startsWith("https://")) {
|
|
1921
1736
|
throw new import_io_wallet_utils19.ValidationError(
|
|
1922
1737
|
"credentialIssuerUrl must be a valid HTTPS URL"
|
|
@@ -2068,7 +1883,7 @@ var WalletProvider = class {
|
|
|
2068
1883
|
* status: { status_list: { idx: 2, uri: "https://status.example.com" } } // Optional
|
|
2069
1884
|
* });
|
|
2070
1885
|
*
|
|
2071
|
-
* @example v1.4
|
|
1886
|
+
* @example v1.4 - Wallet attestation with required wallet_link and wallet_name
|
|
2072
1887
|
* const jwt = await provider.createItWalletAttestationJwt({
|
|
2073
1888
|
* callbacks: { hash: myHashCallback, signJwt: mySignJwtCallback },
|
|
2074
1889
|
* dpopJwkPublic: myJwk,
|
|
@@ -2087,18 +1902,6 @@ var WalletProvider = class {
|
|
|
2087
1902
|
*/
|
|
2088
1903
|
async createItWalletAttestationJwt(options) {
|
|
2089
1904
|
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
1905
|
[import_io_wallet_utils20.ItWalletSpecsVersion.V1_0]: () => {
|
|
2103
1906
|
assertV1_0Options(options);
|
|
2104
1907
|
return (0, import_io_wallet_oauth23.createWalletAttestationJwtV1_0)({
|
|
@@ -2143,7 +1946,6 @@ var WalletProvider = class {
|
|
|
2143
1946
|
};
|
|
2144
1947
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2145
1948
|
0 && (module.exports = {
|
|
2146
|
-
CREDENTIAL_OFFER_GRANTS,
|
|
2147
1949
|
CreateCredentialResponseError,
|
|
2148
1950
|
CredentialAuthorizationHeaderError,
|
|
2149
1951
|
CredentialOfferError,
|