@pagopa/io-wallet-oid4vci 1.5.7 → 2.0.0-apt
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +15697 -773
- package/dist/index.d.ts +15697 -773
- package/dist/index.js +479 -288
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +343 -147
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -8
package/dist/index.mjs
CHANGED
|
@@ -100,7 +100,7 @@ var CredentialAuthorizationHeaderError = class extends Oid4vciError {
|
|
|
100
100
|
import {
|
|
101
101
|
jwtSignerFromJwt,
|
|
102
102
|
verifyJwt
|
|
103
|
-
} from "@
|
|
103
|
+
} from "@pagopa/io-wallet-utils";
|
|
104
104
|
async function verifyAuthorizationResponse(options) {
|
|
105
105
|
if (options.authorizationResponse.iss !== options.iss)
|
|
106
106
|
throw new Oid4vciError(
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
[
|
|
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
|
|
379
|
+
import { z as z5 } from "zod";
|
|
258
380
|
|
|
259
381
|
// src/credential-offer/v1.3/z-credential-offer.ts
|
|
260
|
-
import { z as
|
|
261
|
-
var zAuthorizationCodeGrantV1_3 =
|
|
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:
|
|
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:
|
|
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:
|
|
399
|
+
scope: z3.string()
|
|
278
400
|
});
|
|
279
|
-
var zCredentialOfferGrantsV1_3 =
|
|
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 =
|
|
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:
|
|
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:
|
|
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
|
|
306
|
-
var zAuthorizationCodeGrantV1_4 =
|
|
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:
|
|
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:
|
|
439
|
+
issuer_state: z4.string().optional()
|
|
318
440
|
});
|
|
319
|
-
var zCredentialOfferGrantsV1_4 =
|
|
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 =
|
|
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:
|
|
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:
|
|
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 =
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
-
[
|
|
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 {
|
|
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
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
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
|
-
[
|
|
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
|
|
717
|
+
import { z as z7 } from "zod";
|
|
558
718
|
|
|
559
719
|
// src/credential-request/z-base-credential-request.ts
|
|
560
|
-
import { z as
|
|
561
|
-
var zBaseCredentialRequest =
|
|
562
|
-
credential_configuration_id:
|
|
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:
|
|
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:
|
|
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 =
|
|
591
|
-
jwt:
|
|
592
|
-
proof_type:
|
|
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({
|
|
@@ -637,19 +797,17 @@ var createCredentialRequest = async (options) => {
|
|
|
637
797
|
// src/credential-request/v1.3/create-credential-request.ts
|
|
638
798
|
import {
|
|
639
799
|
HashAlgorithm,
|
|
640
|
-
calculateJwkThumbprint
|
|
641
|
-
} from "@openid4vc/oauth2";
|
|
642
|
-
import {
|
|
643
800
|
ValidationError as ValidationError3,
|
|
801
|
+
calculateJwkThumbprint,
|
|
644
802
|
dateToSeconds as dateToSeconds2,
|
|
645
803
|
parseWithErrorHandling as parseWithErrorHandling2
|
|
646
804
|
} from "@pagopa/io-wallet-utils";
|
|
647
805
|
|
|
648
806
|
// src/credential-request/v1.3/z-credential.ts
|
|
649
|
-
import { z as
|
|
650
|
-
var zCredentialRequestProofJwt =
|
|
651
|
-
var zCredentialRequestProofs =
|
|
652
|
-
jwt:
|
|
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)
|
|
653
811
|
});
|
|
654
812
|
var zCredentialRequestV1_3 = zBaseCredentialRequest.extend({
|
|
655
813
|
proofs: zCredentialRequestProofs.describe(
|
|
@@ -733,6 +891,7 @@ var createCredentialRequest2 = async (options) => {
|
|
|
733
891
|
|
|
734
892
|
// src/credential-request/create-credential-request.ts
|
|
735
893
|
var dispatchCreateCredentialRequest = createVersionDispatcher3({
|
|
894
|
+
[ItWalletSpecsVersion6.APTITUDE]: (o) => createCredentialRequest2(o),
|
|
736
895
|
[ItWalletSpecsVersion6.V1_0]: (o) => createCredentialRequest(o),
|
|
737
896
|
[ItWalletSpecsVersion6.V1_3]: (o) => createCredentialRequest2(o),
|
|
738
897
|
[ItWalletSpecsVersion6.V1_4]: (o) => (
|
|
@@ -746,39 +905,37 @@ async function createCredentialRequest3(options) {
|
|
|
746
905
|
}
|
|
747
906
|
|
|
748
907
|
// src/credential-request/parse-credential-request.ts
|
|
749
|
-
import {
|
|
750
|
-
Oauth2JwtParseError,
|
|
751
|
-
decodeJwt,
|
|
752
|
-
extractDpopJwtFromHeaders
|
|
753
|
-
} from "@pagopa/io-wallet-oauth2";
|
|
908
|
+
import { extractDpopJwtFromHeaders } from "@pagopa/io-wallet-oauth2";
|
|
754
909
|
import {
|
|
755
910
|
HEADERS,
|
|
756
911
|
HashAlgorithm as HashAlgorithm2,
|
|
757
912
|
ItWalletSpecsVersion as ItWalletSpecsVersion7,
|
|
758
913
|
ItWalletSpecsVersionError as ItWalletSpecsVersionError4,
|
|
914
|
+
JwtParseError,
|
|
759
915
|
ValidationError as ValidationError4,
|
|
760
916
|
calculateJwkThumbprint as calculateJwkThumbprint2,
|
|
761
917
|
createVersionDispatcher as createVersionDispatcher4,
|
|
918
|
+
decodeJwt as decodeJwt2,
|
|
762
919
|
parseWithErrorHandling as parseWithErrorHandling3
|
|
763
920
|
} from "@pagopa/io-wallet-utils";
|
|
764
921
|
|
|
765
922
|
// src/credential-request/z-proof-jwt.ts
|
|
766
|
-
import { zJwk } from "@pagopa/io-wallet-
|
|
767
|
-
import { z as
|
|
768
|
-
var zBaseProofJwtHeader =
|
|
769
|
-
alg:
|
|
923
|
+
import { zJwk } from "@pagopa/io-wallet-utils";
|
|
924
|
+
import { z as z9 } from "zod";
|
|
925
|
+
var zBaseProofJwtHeader = z9.object({
|
|
926
|
+
alg: z9.string().min(1),
|
|
770
927
|
jwk: zJwk,
|
|
771
|
-
typ:
|
|
928
|
+
typ: z9.literal("openid4vci-proof+jwt")
|
|
772
929
|
});
|
|
773
930
|
var zProofJwtHeaderV1_0 = zBaseProofJwtHeader.loose();
|
|
774
931
|
var zProofJwtHeaderV1_3 = zBaseProofJwtHeader.extend({
|
|
775
|
-
key_attestation:
|
|
932
|
+
key_attestation: z9.string().min(1)
|
|
776
933
|
}).loose();
|
|
777
|
-
var zProofJwtPayload =
|
|
778
|
-
aud:
|
|
779
|
-
iat:
|
|
780
|
-
iss:
|
|
781
|
-
nonce:
|
|
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)
|
|
782
939
|
});
|
|
783
940
|
|
|
784
941
|
// src/credential-request/parse-credential-request.ts
|
|
@@ -839,7 +996,7 @@ function validateProofPayloadSemantics(options) {
|
|
|
839
996
|
}
|
|
840
997
|
}
|
|
841
998
|
function parseProofJwt(options) {
|
|
842
|
-
const decoded =
|
|
999
|
+
const decoded = decodeJwt2({
|
|
843
1000
|
errorMessagePrefix: "Error decoding credential request proof JWT:",
|
|
844
1001
|
jwt: options.jwt
|
|
845
1002
|
});
|
|
@@ -1021,7 +1178,25 @@ function parseCredentialRequestV1_4(options) {
|
|
|
1021
1178
|
// V1_4 reuses V1_3 proof schema
|
|
1022
1179
|
});
|
|
1023
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
|
+
}
|
|
1024
1198
|
var dispatchParseCredentialRequest = createVersionDispatcher4({
|
|
1199
|
+
[ItWalletSpecsVersion7.APTITUDE]: parseCredentialRequestAPTITUDE,
|
|
1025
1200
|
[ItWalletSpecsVersion7.V1_0]: parseCredentialRequestV1_0,
|
|
1026
1201
|
[ItWalletSpecsVersion7.V1_3]: parseCredentialRequestV1_3,
|
|
1027
1202
|
[ItWalletSpecsVersion7.V1_4]: parseCredentialRequestV1_4
|
|
@@ -1040,7 +1215,7 @@ async function parseCredentialRequest(options) {
|
|
|
1040
1215
|
isDeferredFlow
|
|
1041
1216
|
});
|
|
1042
1217
|
} catch (error) {
|
|
1043
|
-
if (error instanceof ItWalletSpecsVersionError4 || error instanceof
|
|
1218
|
+
if (error instanceof ItWalletSpecsVersionError4 || error instanceof JwtParseError || error instanceof ValidationError4 || error instanceof CredentialAuthorizationHeaderError || error instanceof MissingDpopProofError || error instanceof InvalidDpopProofError) {
|
|
1044
1219
|
throw error;
|
|
1045
1220
|
}
|
|
1046
1221
|
throw new ParseCredentialRequestError(
|
|
@@ -1051,67 +1226,70 @@ async function parseCredentialRequest(options) {
|
|
|
1051
1226
|
}
|
|
1052
1227
|
|
|
1053
1228
|
// src/credential-request/verify-credential-request-jwt-proof.ts
|
|
1054
|
-
import { calculateJwkThumbprint as calculateJwkThumbprint3, jwtSignerFromJwt as jwtSignerFromJwt3 } from "@openid4vc/oauth2";
|
|
1055
1229
|
import {
|
|
1056
1230
|
HashAlgorithm as HashAlgorithm3,
|
|
1057
|
-
Oauth2JwtParseError as Oauth2JwtParseError3,
|
|
1058
|
-
decodeJwt as decodeJwt3,
|
|
1059
|
-
verifyJwt as verifyJwt3
|
|
1060
|
-
} from "@pagopa/io-wallet-oauth2";
|
|
1061
|
-
import {
|
|
1062
1231
|
ItWalletSpecsVersion as ItWalletSpecsVersion8,
|
|
1063
1232
|
ItWalletSpecsVersionError as ItWalletSpecsVersionError5,
|
|
1233
|
+
JwtParseError as JwtParseError3,
|
|
1064
1234
|
ValidationError as ValidationError6,
|
|
1235
|
+
calculateJwkThumbprint as calculateJwkThumbprint3,
|
|
1065
1236
|
createVersionDispatcher as createVersionDispatcher5,
|
|
1237
|
+
decodeJwt as decodeJwt4,
|
|
1238
|
+
jwtSignerFromJwt as jwtSignerFromJwt3,
|
|
1239
|
+
verifyJwt as verifyJwt3,
|
|
1066
1240
|
verifyJwtIatOrThrow
|
|
1067
1241
|
} from "@pagopa/io-wallet-utils";
|
|
1068
1242
|
|
|
1069
1243
|
// src/credential-request/verify-key-attestation-jwt.ts
|
|
1070
1244
|
import {
|
|
1071
|
-
|
|
1245
|
+
JwtParseError as JwtParseError2,
|
|
1246
|
+
ValidationError as ValidationError5,
|
|
1247
|
+
decodeJwt as decodeJwt3,
|
|
1072
1248
|
jwtSignerFromJwt as jwtSignerFromJwt2,
|
|
1073
1249
|
verifyJwt as verifyJwt2
|
|
1074
|
-
} from "@
|
|
1075
|
-
import { decodeJwt as decodeJwt2 } from "@pagopa/io-wallet-oauth2";
|
|
1076
|
-
import { ValidationError as ValidationError5 } from "@pagopa/io-wallet-utils";
|
|
1250
|
+
} from "@pagopa/io-wallet-utils";
|
|
1077
1251
|
|
|
1078
1252
|
// src/wallet-provider/z-key-attestation.ts
|
|
1079
|
-
import { zCertificateChain, zJwk as zJwk2, zTrustChain } from "@pagopa/io-wallet-oauth2";
|
|
1080
1253
|
import { zKeyStorageLevelV1_3 } from "@pagopa/io-wallet-oid-federation";
|
|
1081
|
-
import {
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1254
|
+
import {
|
|
1255
|
+
zCertificateChain,
|
|
1256
|
+
zItwSupportedSignatureAlg,
|
|
1257
|
+
zJwk as zJwk2,
|
|
1258
|
+
zTrustChain
|
|
1259
|
+
} from "@pagopa/io-wallet-utils";
|
|
1260
|
+
import { z as z10 } from "zod";
|
|
1261
|
+
var zStatusList = z10.object({
|
|
1262
|
+
idx: z10.number(),
|
|
1263
|
+
uri: z10.url()
|
|
1086
1264
|
});
|
|
1087
|
-
var zKeyAttestationStatus =
|
|
1265
|
+
var zKeyAttestationStatus = z10.object({
|
|
1088
1266
|
status_list: zStatusList
|
|
1089
1267
|
});
|
|
1090
1268
|
var zKeyAttestationAlg = zItwSupportedSignatureAlg;
|
|
1091
|
-
var zKeyAttestationHeader =
|
|
1269
|
+
var zKeyAttestationHeader = z10.object({
|
|
1092
1270
|
alg: zKeyAttestationAlg,
|
|
1093
|
-
kid:
|
|
1271
|
+
kid: z10.string(),
|
|
1094
1272
|
trust_chain: zTrustChain.optional(),
|
|
1095
|
-
typ:
|
|
1273
|
+
typ: z10.literal("key-attestation+jwt"),
|
|
1096
1274
|
x5c: zCertificateChain
|
|
1097
1275
|
});
|
|
1098
|
-
var zKeyAttestationPayload =
|
|
1099
|
-
attested_keys:
|
|
1100
|
-
certification:
|
|
1101
|
-
exp:
|
|
1102
|
-
iat:
|
|
1103
|
-
iss:
|
|
1104
|
-
key_storage:
|
|
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(),
|
|
1105
1283
|
status: zKeyAttestationStatus,
|
|
1106
|
-
user_authentication:
|
|
1284
|
+
user_authentication: z10.array(zKeyStorageLevelV1_3).nonempty()
|
|
1107
1285
|
});
|
|
1108
|
-
var zKeyAttestationTypeHeader =
|
|
1286
|
+
var zKeyAttestationTypeHeader = z10.literal("key-attestation+jwt");
|
|
1109
1287
|
var keyAttestationTypeHeader = zKeyAttestationTypeHeader.value;
|
|
1110
1288
|
|
|
1111
1289
|
// src/credential-request/verify-key-attestation-jwt.ts
|
|
1112
1290
|
async function verifyKeyAttestationJwt(options) {
|
|
1113
1291
|
try {
|
|
1114
|
-
const { header, payload } =
|
|
1292
|
+
const { header, payload } = decodeJwt3({
|
|
1115
1293
|
errorMessagePrefix: "Error decoding key attestation JWT:",
|
|
1116
1294
|
headerSchema: zKeyAttestationHeader,
|
|
1117
1295
|
jwt: options.keyAttestationJwt,
|
|
@@ -1140,7 +1318,7 @@ async function verifyKeyAttestationJwt(options) {
|
|
|
1140
1318
|
}
|
|
1141
1319
|
return { header, payload, signer };
|
|
1142
1320
|
} catch (error) {
|
|
1143
|
-
if (error instanceof VerifyKeyAttestationJwtError || error instanceof ValidationError5 || error instanceof
|
|
1321
|
+
if (error instanceof VerifyKeyAttestationJwtError || error instanceof ValidationError5 || error instanceof JwtParseError2) {
|
|
1144
1322
|
throw error;
|
|
1145
1323
|
}
|
|
1146
1324
|
throw new VerifyKeyAttestationJwtError(
|
|
@@ -1184,7 +1362,7 @@ function verifyProofJwtIatOrThrow(options) {
|
|
|
1184
1362
|
}
|
|
1185
1363
|
}
|
|
1186
1364
|
async function verifyProofV1_0(options) {
|
|
1187
|
-
const { header, payload } =
|
|
1365
|
+
const { header, payload } = decodeJwt4({
|
|
1188
1366
|
errorMessagePrefix: "Error decoding credential request proof JWT:",
|
|
1189
1367
|
headerSchema: zProofJwtHeaderV1_0,
|
|
1190
1368
|
jwt: options.jwt,
|
|
@@ -1206,7 +1384,7 @@ async function verifyProofV1_0(options) {
|
|
|
1206
1384
|
return { header, payload, signer };
|
|
1207
1385
|
}
|
|
1208
1386
|
async function verifyProofV1_3(options) {
|
|
1209
|
-
const { header, payload } =
|
|
1387
|
+
const { header, payload } = decodeJwt4({
|
|
1210
1388
|
errorMessagePrefix: "Error decoding credential request proof JWT:",
|
|
1211
1389
|
headerSchema: zProofJwtHeaderV1_3,
|
|
1212
1390
|
jwt: options.jwt,
|
|
@@ -1256,6 +1434,7 @@ async function verifyProofV1_3(options) {
|
|
|
1256
1434
|
return { header, keyAttestation: keyAttestationResult, payload, signer };
|
|
1257
1435
|
}
|
|
1258
1436
|
var dispatchVerifyProof = createVersionDispatcher5({
|
|
1437
|
+
[ItWalletSpecsVersion8.APTITUDE]: (o) => verifyProofV1_3(o),
|
|
1259
1438
|
[ItWalletSpecsVersion8.V1_0]: (o) => verifyProofV1_0(o),
|
|
1260
1439
|
[ItWalletSpecsVersion8.V1_3]: (o) => verifyProofV1_3(o),
|
|
1261
1440
|
[ItWalletSpecsVersion8.V1_4]: (o) => verifyProofV1_3(o)
|
|
@@ -1270,7 +1449,7 @@ async function verifyCredentialRequestJwtProof(options) {
|
|
|
1270
1449
|
}
|
|
1271
1450
|
return await dispatchVerifyProof({ ...options, now });
|
|
1272
1451
|
} catch (error) {
|
|
1273
|
-
if (error instanceof VerifyCredentialRequestJwtProofError || error instanceof VerifyKeyAttestationJwtError || error instanceof ItWalletSpecsVersionError5 || error instanceof ValidationError6 || error instanceof
|
|
1452
|
+
if (error instanceof VerifyCredentialRequestJwtProofError || error instanceof VerifyKeyAttestationJwtError || error instanceof ItWalletSpecsVersionError5 || error instanceof ValidationError6 || error instanceof JwtParseError3) {
|
|
1274
1453
|
throw error;
|
|
1275
1454
|
}
|
|
1276
1455
|
throw new VerifyCredentialRequestJwtProofError(
|
|
@@ -1291,30 +1470,30 @@ import {
|
|
|
1291
1470
|
import { parseWithErrorHandling as parseWithErrorHandling4 } from "@pagopa/io-wallet-utils";
|
|
1292
1471
|
|
|
1293
1472
|
// src/credential-response/v1.0/z-credential-response.ts
|
|
1294
|
-
import { z as
|
|
1473
|
+
import { z as z12 } from "zod";
|
|
1295
1474
|
|
|
1296
1475
|
// src/credential-response/z-immediate-credential-response.ts
|
|
1297
|
-
import { z as
|
|
1298
|
-
var zCredentialObject =
|
|
1299
|
-
credential:
|
|
1476
|
+
import { z as z11 } from "zod";
|
|
1477
|
+
var zCredentialObject = z11.object({
|
|
1478
|
+
credential: z11.string()
|
|
1300
1479
|
});
|
|
1301
|
-
var zImmediateCredentialResponse =
|
|
1302
|
-
credentials:
|
|
1480
|
+
var zImmediateCredentialResponse = z11.strictObject({
|
|
1481
|
+
credentials: z11.array(zCredentialObject).nonempty().describe(
|
|
1303
1482
|
"Conditional. Array of issued Digital Credentials as JSON objects with `credential` member containing encoded credential string. Present for immediate issuance (HTTP 200)."
|
|
1304
1483
|
),
|
|
1305
|
-
notification_id:
|
|
1484
|
+
notification_id: z11.string().optional().describe(
|
|
1306
1485
|
"OPTIONAL. Identifier for notification requests. Only present with credentials parameter."
|
|
1307
1486
|
)
|
|
1308
1487
|
});
|
|
1309
1488
|
|
|
1310
1489
|
// src/credential-response/v1.0/z-credential-response.ts
|
|
1311
|
-
var zDeferredCredentialResponseV1_0 =
|
|
1312
|
-
lead_time:
|
|
1490
|
+
var zDeferredCredentialResponseV1_0 = z12.strictObject({
|
|
1491
|
+
lead_time: z12.number().int().positive().describe(
|
|
1313
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."
|
|
1314
1493
|
),
|
|
1315
|
-
transaction_id:
|
|
1494
|
+
transaction_id: z12.string().nonempty()
|
|
1316
1495
|
});
|
|
1317
|
-
var zCredentialResponseV1_0 =
|
|
1496
|
+
var zCredentialResponseV1_0 = z12.union([
|
|
1318
1497
|
zImmediateCredentialResponse,
|
|
1319
1498
|
zDeferredCredentialResponseV1_0
|
|
1320
1499
|
]);
|
|
@@ -1347,14 +1526,14 @@ function createCredentialResponseV1_0(flow) {
|
|
|
1347
1526
|
import { parseWithErrorHandling as parseWithErrorHandling5 } from "@pagopa/io-wallet-utils";
|
|
1348
1527
|
|
|
1349
1528
|
// src/credential-response/v1.3/z-credential-response.ts
|
|
1350
|
-
import { z as
|
|
1351
|
-
var zDeferredCredentialResponseV1_3 =
|
|
1352
|
-
interval:
|
|
1529
|
+
import { z as z13 } from "zod";
|
|
1530
|
+
var zDeferredCredentialResponseV1_3 = z13.strictObject({
|
|
1531
|
+
interval: z13.number().int().positive().describe(
|
|
1353
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"
|
|
1354
1533
|
),
|
|
1355
|
-
transaction_id:
|
|
1534
|
+
transaction_id: z13.string().nonempty()
|
|
1356
1535
|
});
|
|
1357
|
-
var zCredentialResponseV1_3 =
|
|
1536
|
+
var zCredentialResponseV1_3 = z13.union([
|
|
1358
1537
|
zImmediateCredentialResponse,
|
|
1359
1538
|
zDeferredCredentialResponseV1_3
|
|
1360
1539
|
]);
|
|
@@ -1385,6 +1564,9 @@ function createCredentialResponseV1_3(flow) {
|
|
|
1385
1564
|
|
|
1386
1565
|
// src/credential-response/create-credential-response.ts
|
|
1387
1566
|
var dispatchBuildVersionedResponse = createVersionDispatcher6({
|
|
1567
|
+
[ItWalletSpecsVersion9.APTITUDE]: (o) => createCredentialResponseV1_3(
|
|
1568
|
+
o.flow
|
|
1569
|
+
),
|
|
1388
1570
|
[ItWalletSpecsVersion9.V1_0]: (o) => createCredentialResponseV1_0(
|
|
1389
1571
|
o.flow
|
|
1390
1572
|
),
|
|
@@ -1451,11 +1633,11 @@ import {
|
|
|
1451
1633
|
} from "@pagopa/io-wallet-utils";
|
|
1452
1634
|
|
|
1453
1635
|
// src/credential-response/z-credential-response.ts
|
|
1454
|
-
import { zAlgValueNotNone, zJwk as zJwk3 } from "@pagopa/io-wallet-
|
|
1455
|
-
import { z as
|
|
1456
|
-
var zCredentialResponseEncryption =
|
|
1636
|
+
import { zAlgValueNotNone, zJwk as zJwk3 } from "@pagopa/io-wallet-utils";
|
|
1637
|
+
import { z as z14 } from "zod";
|
|
1638
|
+
var zCredentialResponseEncryption = z14.looseObject({
|
|
1457
1639
|
alg: zAlgValueNotNone,
|
|
1458
|
-
enc:
|
|
1640
|
+
enc: z14.string(),
|
|
1459
1641
|
jwk: zJwk3
|
|
1460
1642
|
});
|
|
1461
1643
|
|
|
@@ -1500,7 +1682,6 @@ async function fetchCredentialResponse(options) {
|
|
|
1500
1682
|
}
|
|
1501
1683
|
|
|
1502
1684
|
// src/metadata/fetch-metadata.ts
|
|
1503
|
-
import { decodeJwt as decodeJwt4 } from "@pagopa/io-wallet-oauth2";
|
|
1504
1685
|
import { itWalletEntityStatementClaimsSchema as itWalletEntityStatementClaimsSchema2 } from "@pagopa/io-wallet-oid-federation";
|
|
1505
1686
|
import {
|
|
1506
1687
|
ItWalletSpecsVersion as ItWalletSpecsVersion10,
|
|
@@ -1509,10 +1690,11 @@ import {
|
|
|
1509
1690
|
ValidationError as ValidationError9,
|
|
1510
1691
|
createFetcher as createFetcher4,
|
|
1511
1692
|
createVersionDispatcher as createVersionDispatcher7,
|
|
1693
|
+
decodeJwt as decodeJwt5,
|
|
1512
1694
|
hasStatusOrThrow as hasStatusOrThrow4,
|
|
1513
1695
|
parseWithErrorHandling as parseWithErrorHandling7
|
|
1514
1696
|
} from "@pagopa/io-wallet-utils";
|
|
1515
|
-
import
|
|
1697
|
+
import z16 from "zod";
|
|
1516
1698
|
|
|
1517
1699
|
// src/metadata/z-metadata-response.ts
|
|
1518
1700
|
import {
|
|
@@ -1521,33 +1703,33 @@ import {
|
|
|
1521
1703
|
itWalletMetadataV1_3,
|
|
1522
1704
|
itWalletMetadataV1_4
|
|
1523
1705
|
} from "@pagopa/io-wallet-oid-federation";
|
|
1524
|
-
import { z as
|
|
1525
|
-
var zMetadataResponseV1_0 =
|
|
1526
|
-
discoveredVia:
|
|
1706
|
+
import { z as z15 } from "zod";
|
|
1707
|
+
var zMetadataResponseV1_0 = z15.object({
|
|
1708
|
+
discoveredVia: z15.enum(["federation"]),
|
|
1527
1709
|
metadata: itWalletMetadataV1_0,
|
|
1528
1710
|
openid_federation_claims: itWalletEntityStatementClaimsSchema
|
|
1529
1711
|
});
|
|
1530
|
-
var zMetadataResponseV1_3 =
|
|
1712
|
+
var zMetadataResponseV1_3 = z15.object({
|
|
1531
1713
|
/**
|
|
1532
1714
|
* Entity statement claims of the Authorization Server, present only when the
|
|
1533
1715
|
* selected authorization server was resolved through a federation entity
|
|
1534
1716
|
* distinct from the Credential Issuer.
|
|
1535
1717
|
*/
|
|
1536
1718
|
authorization_server_federation_claims: itWalletEntityStatementClaimsSchema.optional(),
|
|
1537
|
-
discoveredVia:
|
|
1719
|
+
discoveredVia: z15.enum(["federation", "oid4vci"]),
|
|
1538
1720
|
metadata: itWalletMetadataV1_3,
|
|
1539
1721
|
openid_federation_claims: itWalletEntityStatementClaimsSchema.optional()
|
|
1540
1722
|
});
|
|
1541
1723
|
var zMetadataResponseV1_4 = zMetadataResponseV1_3.extend({
|
|
1542
1724
|
metadata: itWalletMetadataV1_4
|
|
1543
1725
|
});
|
|
1544
|
-
var zMetadataResponse =
|
|
1726
|
+
var zMetadataResponse = z15.union([
|
|
1545
1727
|
zMetadataResponseV1_0,
|
|
1546
1728
|
zMetadataResponseV1_3,
|
|
1547
1729
|
zMetadataResponseV1_4
|
|
1548
1730
|
]);
|
|
1549
|
-
var zPartialIssuerMetadata =
|
|
1550
|
-
authorization_servers:
|
|
1731
|
+
var zPartialIssuerMetadata = z15.looseObject({
|
|
1732
|
+
authorization_servers: z15.tuple([z15.url()], z15.url()).optional()
|
|
1551
1733
|
});
|
|
1552
1734
|
|
|
1553
1735
|
// src/metadata/fetch-metadata.ts
|
|
@@ -1565,7 +1747,7 @@ async function tryFederationDiscovery(fetch, baseUrl, verifyJwt4) {
|
|
|
1565
1747
|
return void 0;
|
|
1566
1748
|
}
|
|
1567
1749
|
const entityStatement = await response.text();
|
|
1568
|
-
const { header, payload } =
|
|
1750
|
+
const { header, payload } = decodeJwt5({
|
|
1569
1751
|
errorMessagePrefix: "Error decoding entity statement JWT:",
|
|
1570
1752
|
jwt: entityStatement,
|
|
1571
1753
|
payloadSchema: itWalletEntityStatementClaimsSchema2
|
|
@@ -1614,7 +1796,7 @@ async function applyFederationAuthorizationServerSelection(fetch, federationResu
|
|
|
1614
1796
|
if (!selectedAuthorizationServer || selectedAuthorizationServer === credentialIssuer) {
|
|
1615
1797
|
return federationResult;
|
|
1616
1798
|
}
|
|
1617
|
-
const parsedSelectedAuthorizationServer =
|
|
1799
|
+
const parsedSelectedAuthorizationServer = z16.url().safeParse(selectedAuthorizationServer);
|
|
1618
1800
|
if (!parsedSelectedAuthorizationServer.success || !parsedSelectedAuthorizationServer.data.startsWith("https://")) {
|
|
1619
1801
|
throw new ValidationError9(
|
|
1620
1802
|
"selected authorization server is not a valid HTTPS URL"
|
|
@@ -1652,7 +1834,7 @@ async function fallbackDiscovery(fetch, baseUrl, authorizationServer) {
|
|
|
1652
1834
|
let oauthAuthorizationServer;
|
|
1653
1835
|
if (authorizationServers && authorizationServers.length > 0) {
|
|
1654
1836
|
const selectedAuthorizationServer = authorizationServer ?? authorizationServers[0];
|
|
1655
|
-
const parsedUrl =
|
|
1837
|
+
const parsedUrl = z16.url().safeParse(selectedAuthorizationServer);
|
|
1656
1838
|
if (!parsedUrl.success || !parsedUrl.data.startsWith("https://")) {
|
|
1657
1839
|
throw new ValidationError9(
|
|
1658
1840
|
"selected authorization server is not a valid HTTPS URL"
|
|
@@ -1730,13 +1912,14 @@ async function fetchMetadataV1_4(options) {
|
|
|
1730
1912
|
);
|
|
1731
1913
|
}
|
|
1732
1914
|
var dispatchFetchMetadata = createVersionDispatcher7({
|
|
1915
|
+
[ItWalletSpecsVersion10.APTITUDE]: (o) => fetchMetadataV1_4(o),
|
|
1733
1916
|
[ItWalletSpecsVersion10.V1_0]: (o) => fetchMetadataV1_0(o),
|
|
1734
1917
|
[ItWalletSpecsVersion10.V1_3]: (o) => fetchMetadataV1_3(o),
|
|
1735
1918
|
[ItWalletSpecsVersion10.V1_4]: (o) => fetchMetadataV1_4(o)
|
|
1736
1919
|
});
|
|
1737
1920
|
async function fetchMetadata(options) {
|
|
1738
1921
|
try {
|
|
1739
|
-
const urlValidation =
|
|
1922
|
+
const urlValidation = z16.url().safeParse(options.credentialIssuerUrl);
|
|
1740
1923
|
if (!urlValidation.success || !urlValidation.data.startsWith("https://")) {
|
|
1741
1924
|
throw new ValidationError9(
|
|
1742
1925
|
"credentialIssuerUrl must be a valid HTTPS URL"
|
|
@@ -1897,7 +2080,7 @@ var WalletProvider = class {
|
|
|
1897
2080
|
* status: { status_list: { idx: 2, uri: "https://status.example.com" } } // Optional
|
|
1898
2081
|
* });
|
|
1899
2082
|
*
|
|
1900
|
-
* @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
|
|
1901
2084
|
* const jwt = await provider.createItWalletAttestationJwt({
|
|
1902
2085
|
* callbacks: { hash: myHashCallback, signJwt: mySignJwtCallback },
|
|
1903
2086
|
* dpopJwkPublic: myJwk,
|
|
@@ -1916,6 +2099,18 @@ var WalletProvider = class {
|
|
|
1916
2099
|
*/
|
|
1917
2100
|
async createItWalletAttestationJwt(options) {
|
|
1918
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
|
+
},
|
|
1919
2114
|
[ItWalletSpecsVersion11.V1_0]: () => {
|
|
1920
2115
|
assertV1_0Options(options);
|
|
1921
2116
|
return createWalletAttestationJwtV1_0({
|
|
@@ -1959,6 +2154,7 @@ var WalletProvider = class {
|
|
|
1959
2154
|
}
|
|
1960
2155
|
};
|
|
1961
2156
|
export {
|
|
2157
|
+
CREDENTIAL_OFFER_GRANTS,
|
|
1962
2158
|
CreateCredentialResponseError,
|
|
1963
2159
|
CredentialAuthorizationHeaderError,
|
|
1964
2160
|
CredentialOfferError,
|