@openid4vc/openid4vci 0.3.0-alpha-20251017102623 → 0.3.0-alpha-20251017122507
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 +3857 -44136
- package/dist/index.d.ts +3857 -44136
- package/dist/index.js +119 -91
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +119 -91
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -43,23 +43,23 @@ const zTxCode = zod.default.object({
|
|
|
43
43
|
input_mode: zod.default.union([zod.default.literal("numeric"), zod.default.literal("text")]).optional(),
|
|
44
44
|
length: zod.default.number().int().optional(),
|
|
45
45
|
description: zod.default.string().max(300).optional()
|
|
46
|
-
}).
|
|
46
|
+
}).loose();
|
|
47
47
|
const zCredentialOfferGrants = zod.default.object({
|
|
48
48
|
authorization_code: zod.default.object({
|
|
49
49
|
issuer_state: zod.default.string().optional(),
|
|
50
50
|
authorization_server: __openid4vc_utils.zHttpsUrl.optional()
|
|
51
|
-
}).
|
|
51
|
+
}).loose().optional(),
|
|
52
52
|
[__openid4vc_oauth2.preAuthorizedCodeGrantIdentifier]: zod.default.object({
|
|
53
53
|
"pre-authorized_code": zod.default.string(),
|
|
54
54
|
tx_code: zTxCode.optional(),
|
|
55
55
|
authorization_server: __openid4vc_utils.zHttpsUrl.optional()
|
|
56
|
-
}).
|
|
57
|
-
}).
|
|
56
|
+
}).loose().optional()
|
|
57
|
+
}).loose();
|
|
58
58
|
const zCredentialOfferObjectDraft14 = zod.default.object({
|
|
59
59
|
credential_issuer: __openid4vc_utils.zHttpsUrl,
|
|
60
60
|
credential_configuration_ids: zod.default.array(zod.default.string()),
|
|
61
61
|
grants: zod.default.optional(zCredentialOfferGrants)
|
|
62
|
-
}).
|
|
62
|
+
}).loose();
|
|
63
63
|
const zCredentialOfferObjectDraft11To14 = zod.default.object({
|
|
64
64
|
credential_issuer: __openid4vc_utils.zHttpsUrl,
|
|
65
65
|
credentials: zod.default.array(zod.default.string({ message: "Only string credential identifiers are supported for draft 11 credential offers" })),
|
|
@@ -68,9 +68,9 @@ const zCredentialOfferObjectDraft11To14 = zod.default.object({
|
|
|
68
68
|
[__openid4vc_oauth2.preAuthorizedCodeGrantIdentifier]: zod.default.object({
|
|
69
69
|
"pre-authorized_code": zod.default.string(),
|
|
70
70
|
user_pin_required: zod.default.optional(zod.default.boolean())
|
|
71
|
-
}).
|
|
71
|
+
}).loose().optional()
|
|
72
72
|
}))
|
|
73
|
-
}).
|
|
73
|
+
}).loose().transform(({ credentials, grants,...rest }) => {
|
|
74
74
|
const v14 = {
|
|
75
75
|
...rest,
|
|
76
76
|
credential_configuration_ids: credentials
|
|
@@ -177,14 +177,15 @@ const zCredentialConfigurationSupportedClaimsDescriptionDraft14 = zod.default.ob
|
|
|
177
177
|
display: zod.default.array(zod.default.object({
|
|
178
178
|
name: zod.default.string().optional(),
|
|
179
179
|
locale: zod.default.string().optional()
|
|
180
|
-
}).
|
|
181
|
-
}).
|
|
180
|
+
}).loose()).optional()
|
|
181
|
+
}).loose();
|
|
182
182
|
const zCredentialConfigurationSupportedClaimsDraft14 = zod.default.record(zod.default.string(), zod.default.union([zCredentialConfigurationSupportedClaimsDescriptionDraft14, zod.default.lazy(() => zCredentialConfigurationSupportedClaimsDraft14)]));
|
|
183
|
-
const
|
|
183
|
+
const zClaimDescriptionPathValue = zod.default.union([
|
|
184
184
|
zod.default.string(),
|
|
185
185
|
zod.default.number().int().nonnegative(),
|
|
186
186
|
zod.default.null()
|
|
187
|
-
])
|
|
187
|
+
]);
|
|
188
|
+
const zClaimsDescriptionPath = zod.default.tuple([zClaimDescriptionPathValue], zClaimDescriptionPathValue);
|
|
188
189
|
const zMsoMdocClaimsDescriptionPath = zod.default.tuple([zod.default.string(), zod.default.string()], { message: "mso_mdoc claims description path MUST be an array with exactly two string elements, pointing to the namespace and element identifier within an mdoc credential" });
|
|
189
190
|
const zIssuerMetadataClaimsDescription = zod.default.object({
|
|
190
191
|
path: zClaimsDescriptionPath,
|
|
@@ -192,8 +193,8 @@ const zIssuerMetadataClaimsDescription = zod.default.object({
|
|
|
192
193
|
display: zod.default.array(zod.default.object({
|
|
193
194
|
name: zod.default.string().optional(),
|
|
194
195
|
locale: zod.default.string().optional()
|
|
195
|
-
}).
|
|
196
|
-
}).
|
|
196
|
+
}).loose()).optional()
|
|
197
|
+
}).loose();
|
|
197
198
|
const zMsoMdocIssuerMetadataClaimsDescription = zIssuerMetadataClaimsDescription.extend({ path: zMsoMdocClaimsDescriptionPath });
|
|
198
199
|
|
|
199
200
|
//#endregion
|
|
@@ -201,7 +202,7 @@ const zMsoMdocIssuerMetadataClaimsDescription = zIssuerMetadataClaimsDescription
|
|
|
201
202
|
const zKeyAttestationJwtHeader = zod.default.object({
|
|
202
203
|
...__openid4vc_oauth2.zJwtHeader.shape,
|
|
203
204
|
typ: zod.default.literal("keyattestation+jwt").or(zod.default.literal("key-attestation+jwt"))
|
|
204
|
-
}).
|
|
205
|
+
}).loose().refine(({ kid, jwk }) => jwk === void 0 || kid === void 0, { message: `Both 'jwk' and 'kid' are defined. Only one is allowed` }).refine(({ trust_chain, kid }) => !trust_chain || !kid, { message: `When 'trust_chain' is provided, 'kid' is required` });
|
|
205
206
|
const zIso18045 = zod.default.enum([
|
|
206
207
|
"iso_18045_high",
|
|
207
208
|
"iso_18045_moderate",
|
|
@@ -215,13 +216,13 @@ const zKeyAttestationJwtPayload = zod.default.object({
|
|
|
215
216
|
attested_keys: zod.default.array(__openid4vc_oauth2.zJwk),
|
|
216
217
|
key_storage: zod.default.optional(zIso18045OrStringArray),
|
|
217
218
|
user_authentication: zod.default.optional(zIso18045OrStringArray),
|
|
218
|
-
certification: zod.default.optional(zod.default.
|
|
219
|
-
}).
|
|
219
|
+
certification: zod.default.optional(zod.default.url())
|
|
220
|
+
}).loose();
|
|
220
221
|
const zKeyAttestationJwtPayloadForUse = (use) => zod.default.object({
|
|
221
222
|
...zKeyAttestationJwtPayload.shape,
|
|
222
223
|
nonce: use === "proof_type.attestation" ? zod.default.string({ message: `Nonce must be defined when key attestation is used as 'proof_type.attestation' directly` }) : zod.default.optional(zod.default.string()),
|
|
223
224
|
exp: use === "proof_type.jwt" ? __openid4vc_utils.zInteger : zod.default.optional(__openid4vc_utils.zInteger)
|
|
224
|
-
}).
|
|
225
|
+
}).loose();
|
|
225
226
|
|
|
226
227
|
//#endregion
|
|
227
228
|
//#region src/metadata/credential-issuer/z-credential-configuration-supported-common.ts
|
|
@@ -231,12 +232,12 @@ const zCredentialConfigurationSupportedDisplayEntry = zod.default.object({
|
|
|
231
232
|
logo: zod.default.object({
|
|
232
233
|
uri: zod.default.string().optional(),
|
|
233
234
|
alt_text: zod.default.string().optional()
|
|
234
|
-
}).
|
|
235
|
+
}).loose().optional(),
|
|
235
236
|
description: zod.default.string().optional(),
|
|
236
237
|
background_color: zod.default.string().optional(),
|
|
237
|
-
background_image: zod.default.object({ uri: zod.default.string().optional() }).
|
|
238
|
+
background_image: zod.default.object({ uri: zod.default.string().optional() }).loose().optional(),
|
|
238
239
|
text_color: zod.default.string().optional()
|
|
239
|
-
}).
|
|
240
|
+
}).loose();
|
|
240
241
|
const zCredentialConfigurationSupportedCommonCredentialMetadata = zod.default.object({ display: zod.default.array(zCredentialConfigurationSupportedDisplayEntry).optional() });
|
|
241
242
|
const zCredentialConfigurationSupportedCommon = zod.default.object({
|
|
242
243
|
format: zod.default.string(),
|
|
@@ -252,11 +253,11 @@ const zCredentialConfigurationSupportedCommon = zod.default.object({
|
|
|
252
253
|
key_attestations_required: zod.default.object({
|
|
253
254
|
key_storage: zIso18045OrStringArray.optional(),
|
|
254
255
|
user_authentication: zIso18045OrStringArray.optional()
|
|
255
|
-
}).
|
|
256
|
+
}).loose().optional()
|
|
256
257
|
})).optional(),
|
|
257
258
|
credential_metadata: zCredentialConfigurationSupportedCommonCredentialMetadata.optional(),
|
|
258
259
|
claims: zod.default.optional(zod.default.never())
|
|
259
|
-
}).
|
|
260
|
+
}).loose();
|
|
260
261
|
const zCredentialConfigurationSupportedCommonDraft15 = zod.default.object({
|
|
261
262
|
format: zod.default.string(),
|
|
262
263
|
scope: zod.default.string().optional(),
|
|
@@ -271,11 +272,11 @@ const zCredentialConfigurationSupportedCommonDraft15 = zod.default.object({
|
|
|
271
272
|
key_attestations_required: zod.default.object({
|
|
272
273
|
key_storage: zIso18045OrStringArray.optional(),
|
|
273
274
|
user_authentication: zIso18045OrStringArray.optional()
|
|
274
|
-
}).
|
|
275
|
+
}).loose().optional()
|
|
275
276
|
})).optional(),
|
|
276
277
|
display: zod.default.array(zCredentialConfigurationSupportedDisplayEntry).optional(),
|
|
277
278
|
credential_metadata: zod.default.optional(zod.default.never())
|
|
278
|
-
}).
|
|
279
|
+
}).loose();
|
|
279
280
|
|
|
280
281
|
//#endregion
|
|
281
282
|
//#region src/formats/credential/mso-mdoc/z-mso-mdoc.ts
|
|
@@ -368,8 +369,8 @@ const zCredentialSubjectLeafTypeDraft14 = zod.default.object({
|
|
|
368
369
|
display: zod.default.array(zod.default.object({
|
|
369
370
|
name: zod.default.string().optional(),
|
|
370
371
|
locale: zod.default.string().optional()
|
|
371
|
-
}).
|
|
372
|
-
}).
|
|
372
|
+
}).loose()).optional()
|
|
373
|
+
}).loose();
|
|
373
374
|
const zClaimValueSchemaDraft14 = zod.default.union([
|
|
374
375
|
zod.default.array(zod.default.any()),
|
|
375
376
|
zod.default.record(zod.default.string(), zod.default.any()),
|
|
@@ -378,14 +379,14 @@ const zClaimValueSchemaDraft14 = zod.default.union([
|
|
|
378
379
|
const zW3cVcCredentialSubjectDraft14 = zod.default.record(zod.default.string(), zClaimValueSchemaDraft14);
|
|
379
380
|
const zW3cVcJsonLdCredentialDefinition = zod.default.object({
|
|
380
381
|
"@context": zod.default.array(zod.default.string()),
|
|
381
|
-
type: zod.default.
|
|
382
|
-
}).
|
|
382
|
+
type: zod.default.tuple([zod.default.string()], zod.default.string())
|
|
383
|
+
}).loose();
|
|
383
384
|
const zW3cVcJsonLdCredentialDefinitionDraft14 = zW3cVcJsonLdCredentialDefinition.extend({ credentialSubject: zW3cVcCredentialSubjectDraft14.optional() });
|
|
384
385
|
|
|
385
386
|
//#endregion
|
|
386
387
|
//#region src/formats/credential/w3c-vc/z-w3c-jwt-vc-json.ts
|
|
387
388
|
const zJwtVcJsonFormatIdentifier = zod.default.literal("jwt_vc_json");
|
|
388
|
-
const zJwtVcJsonCredentialDefinition = zod.default.object({ type: zod.default.
|
|
389
|
+
const zJwtVcJsonCredentialDefinition = zod.default.object({ type: zod.default.tuple([zod.default.string()], zod.default.string()) }).loose();
|
|
389
390
|
const zJwtVcJsonCredentialDefinitionDraft14 = zJwtVcJsonCredentialDefinition.extend({ credentialSubject: zW3cVcCredentialSubjectDraft14.optional() });
|
|
390
391
|
const zJwtVcJsonCredentialIssuerMetadata = zCredentialConfigurationSupportedCommon.extend({
|
|
391
392
|
format: zJwtVcJsonFormatIdentifier,
|
|
@@ -405,9 +406,9 @@ const zJwtVcJsonCredentialIssuerMetadataDraft14 = zCredentialConfigurationSuppor
|
|
|
405
406
|
const zJwtVcJsonCredentialIssuerMetadataDraft11 = zod.default.object({
|
|
406
407
|
format: zJwtVcJsonFormatIdentifier,
|
|
407
408
|
order: zod.default.array(zod.default.string()).optional(),
|
|
408
|
-
types: zod.default.
|
|
409
|
+
types: zod.default.tuple([zod.default.string()], zod.default.string()),
|
|
409
410
|
credentialSubject: zW3cVcCredentialSubjectDraft14.optional()
|
|
410
|
-
}).
|
|
411
|
+
}).loose();
|
|
411
412
|
const zJwtVcJsonCredentialIssuerMetadataDraft11To14 = zJwtVcJsonCredentialIssuerMetadataDraft11.transform(({ types, credentialSubject,...rest }) => ({
|
|
412
413
|
...rest,
|
|
413
414
|
credential_definition: {
|
|
@@ -415,7 +416,7 @@ const zJwtVcJsonCredentialIssuerMetadataDraft11To14 = zJwtVcJsonCredentialIssuer
|
|
|
415
416
|
...credentialSubject ? { credentialSubject } : {}
|
|
416
417
|
}
|
|
417
418
|
}));
|
|
418
|
-
const zJwtVcJsonCredentialIssuerMetadataDraft14To11 = zJwtVcJsonCredentialIssuerMetadataDraft14.
|
|
419
|
+
const zJwtVcJsonCredentialIssuerMetadataDraft14To11 = zJwtVcJsonCredentialIssuerMetadataDraft14.loose().transform(({ credential_definition: { type,...credentialDefinition },...rest }) => ({
|
|
419
420
|
...rest,
|
|
420
421
|
types: type,
|
|
421
422
|
...credentialDefinition
|
|
@@ -426,9 +427,9 @@ const zJwtVcJsonCredentialRequestFormatDraft14 = zod.default.object({
|
|
|
426
427
|
});
|
|
427
428
|
const zJwtVcJsonCredentialRequestDraft11 = zod.default.object({
|
|
428
429
|
format: zJwtVcJsonFormatIdentifier,
|
|
429
|
-
types: zod.default.
|
|
430
|
+
types: zod.default.tuple([zod.default.string()], zod.default.string()),
|
|
430
431
|
credentialSubject: zod.default.optional(zW3cVcCredentialSubjectDraft14)
|
|
431
|
-
}).
|
|
432
|
+
}).loose();
|
|
432
433
|
const zJwtVcJsonCredentialRequestDraft11To14 = zJwtVcJsonCredentialRequestDraft11.transform(({ types, credentialSubject,...rest }) => {
|
|
433
434
|
return {
|
|
434
435
|
...rest,
|
|
@@ -438,7 +439,7 @@ const zJwtVcJsonCredentialRequestDraft11To14 = zJwtVcJsonCredentialRequestDraft1
|
|
|
438
439
|
}
|
|
439
440
|
};
|
|
440
441
|
});
|
|
441
|
-
const zJwtVcJsonCredentialRequestDraft14To11 = zJwtVcJsonCredentialRequestFormatDraft14.
|
|
442
|
+
const zJwtVcJsonCredentialRequestDraft14To11 = zJwtVcJsonCredentialRequestFormatDraft14.loose().transform(({ credential_definition: { type,...credentialDefinition },...rest }) => ({
|
|
442
443
|
...rest,
|
|
443
444
|
types: type,
|
|
444
445
|
...credentialDefinition
|
|
@@ -466,9 +467,9 @@ const zJwtVcJsonLdCredentialIssuerMetadataDraft11 = zod.default.object({
|
|
|
466
467
|
order: zod.default.array(zod.default.string()).optional(),
|
|
467
468
|
format: zJwtVcJsonLdFormatIdentifier,
|
|
468
469
|
"@context": zod.default.array(zod.default.string()),
|
|
469
|
-
types: zod.default.
|
|
470
|
+
types: zod.default.tuple([zod.default.string()], zod.default.string()),
|
|
470
471
|
credentialSubject: zW3cVcCredentialSubjectDraft14.optional()
|
|
471
|
-
}).
|
|
472
|
+
}).loose();
|
|
472
473
|
const zJwtVcJsonLdCredentialIssuerMetadataDraft11To14 = zJwtVcJsonLdCredentialIssuerMetadataDraft11.transform(({ "@context": context, types, credentialSubject,...rest }) => ({
|
|
473
474
|
...rest,
|
|
474
475
|
credential_definition: {
|
|
@@ -477,7 +478,7 @@ const zJwtVcJsonLdCredentialIssuerMetadataDraft11To14 = zJwtVcJsonLdCredentialIs
|
|
|
477
478
|
...credentialSubject ? { credentialSubject } : {}
|
|
478
479
|
}
|
|
479
480
|
}));
|
|
480
|
-
const zJwtVcJsonLdCredentialIssuerMetadataDraft14To11 = zJwtVcJsonLdCredentialIssuerMetadataDraft14.
|
|
481
|
+
const zJwtVcJsonLdCredentialIssuerMetadataDraft14To11 = zJwtVcJsonLdCredentialIssuerMetadataDraft14.loose().transform(({ credential_definition: { type,...credentialDefinition },...rest }) => ({
|
|
481
482
|
...rest,
|
|
482
483
|
...credentialDefinition,
|
|
483
484
|
types: type
|
|
@@ -490,10 +491,10 @@ const zJwtVcJsonLdCredentialRequestDraft11 = zod.default.object({
|
|
|
490
491
|
format: zJwtVcJsonLdFormatIdentifier,
|
|
491
492
|
credential_definition: zod.default.object({
|
|
492
493
|
"@context": zod.default.array(zod.default.string()),
|
|
493
|
-
types: zod.default.
|
|
494
|
+
types: zod.default.tuple([zod.default.string()], zod.default.string()),
|
|
494
495
|
credentialSubject: zod.default.optional(zW3cVcCredentialSubjectDraft14)
|
|
495
|
-
}).
|
|
496
|
-
}).
|
|
496
|
+
}).loose()
|
|
497
|
+
}).loose();
|
|
497
498
|
const zJwtVcJsonLdCredentialRequestDraft11To14 = zJwtVcJsonLdCredentialRequestDraft11.transform(({ credential_definition: { types,...restCredentialDefinition },...rest }) => ({
|
|
498
499
|
...rest,
|
|
499
500
|
credential_definition: {
|
|
@@ -501,7 +502,7 @@ const zJwtVcJsonLdCredentialRequestDraft11To14 = zJwtVcJsonLdCredentialRequestDr
|
|
|
501
502
|
type: types
|
|
502
503
|
}
|
|
503
504
|
}));
|
|
504
|
-
const zJwtVcJsonLdCredentialRequestDraft14To11 = zJwtVcJsonLdCredentialRequestFormatDraft14.
|
|
505
|
+
const zJwtVcJsonLdCredentialRequestDraft14To11 = zJwtVcJsonLdCredentialRequestFormatDraft14.loose().transform(({ credential_definition: { type,...restCredentialDefinition },...rest }) => ({
|
|
505
506
|
...rest,
|
|
506
507
|
credential_definition: {
|
|
507
508
|
...restCredentialDefinition,
|
|
@@ -531,9 +532,9 @@ const zLdpVcCredentialIssuerMetadataDraft11 = zod.default.object({
|
|
|
531
532
|
order: zod.default.array(zod.default.string()).optional(),
|
|
532
533
|
format: zLdpVcFormatIdentifier,
|
|
533
534
|
"@context": zod.default.array(zod.default.string()),
|
|
534
|
-
types: zod.default.
|
|
535
|
+
types: zod.default.tuple([zod.default.string()], zod.default.string()),
|
|
535
536
|
credentialSubject: zW3cVcCredentialSubjectDraft14.optional()
|
|
536
|
-
}).
|
|
537
|
+
}).loose();
|
|
537
538
|
const zLdpVcCredentialIssuerMetadataDraft11To14 = zLdpVcCredentialIssuerMetadataDraft11.transform(({ "@context": context, types, credentialSubject,...rest }) => ({
|
|
538
539
|
...rest,
|
|
539
540
|
credential_definition: {
|
|
@@ -542,7 +543,7 @@ const zLdpVcCredentialIssuerMetadataDraft11To14 = zLdpVcCredentialIssuerMetadata
|
|
|
542
543
|
...credentialSubject ? { credentialSubject } : {}
|
|
543
544
|
}
|
|
544
545
|
}));
|
|
545
|
-
const zLdpVcCredentialIssuerMetadataDraft14To11 = zLdpVcCredentialIssuerMetadataDraft14.
|
|
546
|
+
const zLdpVcCredentialIssuerMetadataDraft14To11 = zLdpVcCredentialIssuerMetadataDraft14.loose().transform(({ credential_definition: { type,...credentialDefinition },...rest }) => ({
|
|
546
547
|
...rest,
|
|
547
548
|
...credentialDefinition,
|
|
548
549
|
types: type
|
|
@@ -555,10 +556,10 @@ const zLdpVcCredentialRequestDraft11 = zod.default.object({
|
|
|
555
556
|
format: zLdpVcFormatIdentifier,
|
|
556
557
|
credential_definition: zod.default.object({
|
|
557
558
|
"@context": zod.default.array(zod.default.string()),
|
|
558
|
-
types: zod.default.
|
|
559
|
+
types: zod.default.tuple([zod.default.string()], zod.default.string()),
|
|
559
560
|
credentialSubject: zW3cVcCredentialSubjectDraft14.optional()
|
|
560
561
|
})
|
|
561
|
-
}).
|
|
562
|
+
}).loose();
|
|
562
563
|
const zLdpVcCredentialRequestDraft11To14 = zLdpVcCredentialRequestDraft11.transform(({ credential_definition: { types,...restCredentialDefinition },...rest }) => ({
|
|
563
564
|
...rest,
|
|
564
565
|
credential_definition: {
|
|
@@ -566,7 +567,7 @@ const zLdpVcCredentialRequestDraft11To14 = zLdpVcCredentialRequestDraft11.transf
|
|
|
566
567
|
type: types
|
|
567
568
|
}
|
|
568
569
|
}));
|
|
569
|
-
const zLdpVcCredentialRequestDraft14To11 = zLdpVcCredentialRequestFormatDraft14.
|
|
570
|
+
const zLdpVcCredentialRequestDraft14To11 = zLdpVcCredentialRequestFormatDraft14.loose().transform(({ credential_definition: { type,...restCredentialDefinition },...rest }) => ({
|
|
570
571
|
...rest,
|
|
571
572
|
credential_definition: {
|
|
572
573
|
...restCredentialDefinition,
|
|
@@ -577,7 +578,7 @@ const zLdpVcCredentialRequestDraft14To11 = zLdpVcCredentialRequestFormatDraft14.
|
|
|
577
578
|
//#endregion
|
|
578
579
|
//#region src/formats/credential/w3c-vc/z-w3c-sd-jwt-vc.ts
|
|
579
580
|
const zSdJwtW3VcFormatIdentifier = zod.default.literal("vc+sd-jwt");
|
|
580
|
-
const zSdJwtW3VcCredentialDefinition = zod.default.object({ type: zod.default.
|
|
581
|
+
const zSdJwtW3VcCredentialDefinition = zod.default.object({ type: zod.default.tuple([zod.default.string()], zod.default.string()) }).loose();
|
|
581
582
|
const zSdJwtW3VcCredentialIssuerMetadata = zCredentialConfigurationSupportedCommon.extend({
|
|
582
583
|
format: zSdJwtW3VcFormatIdentifier,
|
|
583
584
|
credential_definition: zSdJwtW3VcCredentialDefinition,
|
|
@@ -622,9 +623,12 @@ const allCredentialIssuerMetadataFormatIdentifiers = allCredentialIssuerMetadata
|
|
|
622
623
|
const zCredentialConfigurationSupportedWithFormats = zod.default.union([zCredentialConfigurationSupportedCommon, zCredentialConfigurationSupportedCommonDraft15]).transform((data, ctx) => {
|
|
623
624
|
if (!allCredentialIssuerMetadataFormatIdentifiers.includes(data.format)) return data;
|
|
624
625
|
const validators = allCredentialIssuerMetadataFormats.filter((formatValidator) => formatValidator.shape.format.value === data.format);
|
|
625
|
-
const result = zod.default.object({}).
|
|
626
|
+
const result = zod.default.object({}).loose().and(validators.length > 1 ? zod.default.union(validators) : validators[0]).safeParse(data);
|
|
626
627
|
if (result.success) return result.data;
|
|
627
|
-
for (const issue of result.error.issues) ctx.addIssue(
|
|
628
|
+
for (const issue of result.error.issues) ctx.addIssue({
|
|
629
|
+
...issue,
|
|
630
|
+
code: issue.code
|
|
631
|
+
});
|
|
628
632
|
return zod.default.NEVER;
|
|
629
633
|
});
|
|
630
634
|
const zCredentialIssuerMetadataDisplayEntry = zod.default.object({
|
|
@@ -633,8 +637,8 @@ const zCredentialIssuerMetadataDisplayEntry = zod.default.object({
|
|
|
633
637
|
logo: zod.default.object({
|
|
634
638
|
uri: zod.default.string().optional(),
|
|
635
639
|
alt_text: zod.default.string().optional()
|
|
636
|
-
}).
|
|
637
|
-
}).
|
|
640
|
+
}).loose().optional()
|
|
641
|
+
}).loose();
|
|
638
642
|
const zCredentialIssuerMetadataDraft14Draft15Draft16 = zod.default.object({
|
|
639
643
|
credential_issuer: __openid4vc_utils.zHttpsUrl,
|
|
640
644
|
authorization_servers: zod.default.array(__openid4vc_utils.zHttpsUrl).optional(),
|
|
@@ -646,22 +650,22 @@ const zCredentialIssuerMetadataDraft14Draft15Draft16 = zod.default.object({
|
|
|
646
650
|
alg_values_supported: zod.default.array(zod.default.string()),
|
|
647
651
|
enc_values_supported: zod.default.array(zod.default.string()),
|
|
648
652
|
encryption_required: zod.default.boolean()
|
|
649
|
-
}).
|
|
650
|
-
batch_credential_issuance: zod.default.object({ batch_size: zod.default.number().positive() }).
|
|
653
|
+
}).loose().optional(),
|
|
654
|
+
batch_credential_issuance: zod.default.object({ batch_size: zod.default.number().positive() }).loose().optional(),
|
|
651
655
|
signed_metadata: __openid4vc_oauth2.zCompactJwt.optional(),
|
|
652
656
|
display: zod.default.array(zCredentialIssuerMetadataDisplayEntry).optional(),
|
|
653
657
|
credential_configurations_supported: zod.default.record(zod.default.string(), zCredentialConfigurationSupportedWithFormats)
|
|
654
|
-
}).
|
|
658
|
+
}).loose();
|
|
655
659
|
const zCredentialConfigurationSupportedDraft11To16 = zod.default.object({
|
|
656
660
|
id: zod.default.string().optional(),
|
|
657
661
|
format: zod.default.string(),
|
|
658
662
|
cryptographic_suites_supported: zod.default.array(zod.default.string()).optional(),
|
|
659
663
|
display: zod.default.array(zod.default.object({
|
|
660
|
-
logo: zod.default.object({ url: zod.default.
|
|
661
|
-
background_image: zod.default.object({ url: zod.default.
|
|
662
|
-
}).
|
|
664
|
+
logo: zod.default.object({ url: zod.default.url().optional() }).loose().optional(),
|
|
665
|
+
background_image: zod.default.object({ url: zod.default.url().optional() }).loose().optional()
|
|
666
|
+
}).loose()).optional(),
|
|
663
667
|
claims: zod.default.any().optional()
|
|
664
|
-
}).
|
|
668
|
+
}).loose().transform(({ cryptographic_suites_supported, display, claims, id,...rest }) => ({
|
|
665
669
|
...rest,
|
|
666
670
|
...cryptographic_suites_supported ? { credential_signing_alg_values_supported: cryptographic_suites_supported } : {},
|
|
667
671
|
...claims || display ? { credential_metadata: {
|
|
@@ -681,13 +685,16 @@ const zCredentialConfigurationSupportedDraft11To16 = zod.default.object({
|
|
|
681
685
|
if (!Object.keys(formatSpecificTransformations).includes(data.format)) return data;
|
|
682
686
|
const result = formatSpecificTransformations[data.format].safeParse(data);
|
|
683
687
|
if (result.success) return result.data;
|
|
684
|
-
for (const issue of result.error.issues) ctx.addIssue(
|
|
688
|
+
for (const issue of result.error.issues) ctx.addIssue({
|
|
689
|
+
...issue,
|
|
690
|
+
code: issue.code
|
|
691
|
+
});
|
|
685
692
|
return zod.default.NEVER;
|
|
686
693
|
}).pipe(zCredentialConfigurationSupportedWithFormats);
|
|
687
694
|
const zCredentialConfigurationSupportedDraft16To11 = zCredentialConfigurationSupportedWithFormats.transform(({ credential_metadata,...rest }) => ({
|
|
688
695
|
...credential_metadata,
|
|
689
696
|
...rest
|
|
690
|
-
})).and(zod.default.object({ id: zod.default.string() }).
|
|
697
|
+
})).and(zod.default.object({ id: zod.default.string() }).loose()).transform(({ id, credential_signing_alg_values_supported, display, proof_types_supported, scope,...rest }) => ({
|
|
691
698
|
...rest,
|
|
692
699
|
...credential_signing_alg_values_supported ? { cryptographic_suites_supported: credential_signing_alg_values_supported } : {},
|
|
693
700
|
...display ? { display: display.map(({ logo, background_image,...displayRest }) => {
|
|
@@ -714,18 +721,18 @@ const zCredentialConfigurationSupportedDraft16To11 = zCredentialConfigurationSup
|
|
|
714
721
|
zLdpVcFormatIdentifier.value,
|
|
715
722
|
zJwtVcJsonFormatIdentifier.value,
|
|
716
723
|
zJwtVcJsonLdFormatIdentifier.value
|
|
717
|
-
].includes(input)) }).
|
|
724
|
+
].includes(input)) }).loose()
|
|
718
725
|
]));
|
|
719
726
|
const zCredentialIssuerMetadataDraft11To16 = zod.default.object({
|
|
720
727
|
authorization_server: zod.default.string().optional(),
|
|
721
|
-
credentials_supported: zod.default.array(zod.default.object({ id: zod.default.string().optional() }).
|
|
722
|
-
}).
|
|
728
|
+
credentials_supported: zod.default.array(zod.default.object({ id: zod.default.string().optional() }).loose())
|
|
729
|
+
}).loose().transform(({ authorization_server, credentials_supported,...rest }) => {
|
|
723
730
|
return {
|
|
724
731
|
...rest,
|
|
725
732
|
...authorization_server ? { authorization_servers: [authorization_server] } : {},
|
|
726
733
|
credential_configurations_supported: Object.fromEntries(credentials_supported.map((supported) => supported.id ? [supported.id, supported] : void 0).filter((i) => i !== void 0))
|
|
727
734
|
};
|
|
728
|
-
}).pipe(zod.default.object({ credential_configurations_supported: zod.default.record(zod.default.string(), zCredentialConfigurationSupportedDraft11To16) }).
|
|
735
|
+
}).pipe(zod.default.object({ credential_configurations_supported: zod.default.record(zod.default.string(), zCredentialConfigurationSupportedDraft11To16) }).loose()).pipe(zCredentialIssuerMetadataDraft14Draft15Draft16);
|
|
729
736
|
const zCredentialIssuerMetadataWithDraft11 = zCredentialIssuerMetadataDraft14Draft15Draft16.transform((issuerMetadata) => ({
|
|
730
737
|
...issuerMetadata,
|
|
731
738
|
...issuerMetadata.authorization_servers ? { authorization_server: issuerMetadata.authorization_servers[0] } : {},
|
|
@@ -762,8 +769,11 @@ const wellKnownCredentialIssuerSuffix = ".well-known/openid-credential-issuer";
|
|
|
762
769
|
* @inheritdoc {@link fetchWellKnownMetadata}
|
|
763
770
|
*/
|
|
764
771
|
async function fetchCredentialIssuerMetadata(credentialIssuer, fetch) {
|
|
765
|
-
const
|
|
766
|
-
const
|
|
772
|
+
const parsedIssuerUrl = new __openid4vc_utils.URL(credentialIssuer);
|
|
773
|
+
const legacyWellKnownMetadataUrl = (0, __openid4vc_utils.joinUriParts)(credentialIssuer, [wellKnownCredentialIssuerSuffix]);
|
|
774
|
+
const wellKnownMetadataUrl = (0, __openid4vc_utils.joinUriParts)(parsedIssuerUrl.origin, [wellKnownCredentialIssuerSuffix, parsedIssuerUrl.pathname]);
|
|
775
|
+
let result = await (0, __openid4vc_oauth2.fetchWellKnownMetadata)(wellKnownMetadataUrl, zCredentialIssuerMetadataWithDraftVersion, fetch);
|
|
776
|
+
if (!result && legacyWellKnownMetadataUrl !== wellKnownMetadataUrl) result = await (0, __openid4vc_oauth2.fetchWellKnownMetadata)(legacyWellKnownMetadataUrl, zCredentialIssuerMetadataWithDraftVersion, fetch);
|
|
767
777
|
if (result && result.credentialIssuerMetadata.credential_issuer !== credentialIssuer) throw new __openid4vc_oauth2.Oauth2Error(`The 'credential_issuer' parameter '${result.credentialIssuerMetadata.credential_issuer}' in the well known credential issuer metadata at '${wellKnownMetadataUrl}' does not match the provided credential issuer '${credentialIssuer}'.`);
|
|
768
778
|
return result;
|
|
769
779
|
}
|
|
@@ -979,16 +989,16 @@ const zCredentialRequestProofJwt = zod.default.object({
|
|
|
979
989
|
const zCredentialRequestJwtProofTypeHeader = __openid4vc_oauth2.zJwtHeader.merge(zod.default.object({
|
|
980
990
|
key_attestation: zod.default.optional(__openid4vc_oauth2.zCompactJwt),
|
|
981
991
|
typ: zod.default.literal("openid4vci-proof+jwt")
|
|
982
|
-
})).
|
|
992
|
+
})).loose().refine(({ kid, jwk }) => jwk === void 0 || kid === void 0, { message: `Both 'jwk' and 'kid' are defined. Only one is allowed` }).refine(({ trust_chain, kid }) => !trust_chain || !kid, { message: `When 'trust_chain' is provided, 'kid' is required` });
|
|
983
993
|
const zCredentialRequestJwtProofTypePayload = zod.default.object({
|
|
984
994
|
...__openid4vc_oauth2.zJwtPayload.shape,
|
|
985
995
|
aud: __openid4vc_utils.zHttpsUrl,
|
|
986
996
|
iat: __openid4vc_utils.zInteger
|
|
987
|
-
}).
|
|
997
|
+
}).loose();
|
|
988
998
|
|
|
989
999
|
//#endregion
|
|
990
1000
|
//#region src/credential-request/z-credential-request-common.ts
|
|
991
|
-
const zCredentialRequestProofCommon = zod.default.object({ proof_type: zod.default.string() }).
|
|
1001
|
+
const zCredentialRequestProofCommon = zod.default.object({ proof_type: zod.default.string() }).loose();
|
|
992
1002
|
const allCredentialRequestProofs = [zCredentialRequestProofJwt, zCredentialRequestProofAttestation];
|
|
993
1003
|
const zCredentialRequestProof = zod.default.union([zCredentialRequestProofCommon, zod.default.discriminatedUnion("proof_type", allCredentialRequestProofs)]);
|
|
994
1004
|
const zCredentialRequestProofsCommon = zod.default.record(zod.default.string(), zod.default.array(zod.default.unknown()));
|
|
@@ -1003,8 +1013,8 @@ const zCredentialRequestCommon = zod.default.object({
|
|
|
1003
1013
|
jwk: __openid4vc_oauth2.zJwk,
|
|
1004
1014
|
alg: zod.default.string(),
|
|
1005
1015
|
enc: zod.default.string()
|
|
1006
|
-
}).
|
|
1007
|
-
}).
|
|
1016
|
+
}).loose().optional()
|
|
1017
|
+
}).loose().refine(({ proof, proofs }) => !(proof !== void 0 && proofs !== void 0), { message: `Both 'proof' and 'proofs' are defined. Only one is allowed` });
|
|
1008
1018
|
|
|
1009
1019
|
//#endregion
|
|
1010
1020
|
//#region src/credential-request/z-credential-request.ts
|
|
@@ -1031,12 +1041,15 @@ const zCredentialRequestFormat = zod.default.object({
|
|
|
1031
1041
|
format: zod.default.string(),
|
|
1032
1042
|
credential_identifier: zod.default.never({ message: "'credential_identifier' cannot be defined when 'format' is set." }).optional(),
|
|
1033
1043
|
credential_configuration_id: zod.default.never({ message: "'credential_configuration_id' cannot be defined when 'format' is set." }).optional()
|
|
1034
|
-
}).
|
|
1044
|
+
}).loose();
|
|
1035
1045
|
const zCredentialRequestDraft14WithFormat = zCredentialRequestCommon.and(zCredentialRequestFormat).transform((data, ctx) => {
|
|
1036
1046
|
if (!allCredentialRequestFormatIdentifiers.includes(data.format)) return data;
|
|
1037
|
-
const result = zod.default.object({}).
|
|
1047
|
+
const result = zod.default.object({}).loose().and(zod.default.union(allCredentialRequestFormats)).safeParse(data);
|
|
1038
1048
|
if (result.success) return result.data;
|
|
1039
|
-
for (const issue of result.error.issues) ctx.addIssue(
|
|
1049
|
+
for (const issue of result.error.issues) ctx.addIssue({
|
|
1050
|
+
...issue,
|
|
1051
|
+
code: issue.code
|
|
1052
|
+
});
|
|
1040
1053
|
return zod.default.NEVER;
|
|
1041
1054
|
});
|
|
1042
1055
|
const zCredentialRequestDraft15 = zod.default.union([zCredentialRequestCommon.and(zAuthorizationDetailsCredentialRequest), zCredentialRequestCommon.and(zCredentialRequestCredentialConfigurationId)]);
|
|
@@ -1050,10 +1063,22 @@ const zCredentialRequestDraft11To14 = zCredentialRequestCommon.and(zCredentialRe
|
|
|
1050
1063
|
if (!Object.keys(formatSpecificTransformations).includes(data.format)) return data;
|
|
1051
1064
|
const result = formatSpecificTransformations[data.format].safeParse(data);
|
|
1052
1065
|
if (result.success) return result.data;
|
|
1053
|
-
for (const issue of result.error.issues) ctx.addIssue(
|
|
1066
|
+
for (const issue of result.error.issues) ctx.addIssue({
|
|
1067
|
+
...issue,
|
|
1068
|
+
code: issue.code
|
|
1069
|
+
});
|
|
1054
1070
|
return zod.default.NEVER;
|
|
1055
1071
|
}).pipe(zCredentialRequestDraft14);
|
|
1056
|
-
const zCredentialRequestDraft14To11 = zCredentialRequestDraft14.
|
|
1072
|
+
const zCredentialRequestDraft14To11 = zCredentialRequestDraft14.transform((data, ctx) => {
|
|
1073
|
+
if (data.credential_identifier !== void 0) {
|
|
1074
|
+
ctx.addIssue({
|
|
1075
|
+
code: "custom",
|
|
1076
|
+
continue: false,
|
|
1077
|
+
message: `'credential_identifier' is not supported in OpenID4VCI draft 11`,
|
|
1078
|
+
path: ["credential_identifier"]
|
|
1079
|
+
});
|
|
1080
|
+
return zod.default.NEVER;
|
|
1081
|
+
}
|
|
1057
1082
|
const formatSpecificTransformations = {
|
|
1058
1083
|
[zLdpVcFormatIdentifier.value]: zLdpVcCredentialRequestDraft14To11,
|
|
1059
1084
|
[zJwtVcJsonFormatIdentifier.value]: zJwtVcJsonCredentialRequestDraft14To11,
|
|
@@ -1062,7 +1087,10 @@ const zCredentialRequestDraft14To11 = zCredentialRequestDraft14.refine((data) =>
|
|
|
1062
1087
|
if (!Object.keys(formatSpecificTransformations).includes(data.format)) return data;
|
|
1063
1088
|
const result = formatSpecificTransformations[data.format].safeParse(data);
|
|
1064
1089
|
if (result.success) return result.data;
|
|
1065
|
-
for (const issue of result.error.issues) ctx.addIssue(
|
|
1090
|
+
for (const issue of result.error.issues) ctx.addIssue({
|
|
1091
|
+
...issue,
|
|
1092
|
+
code: issue.code
|
|
1093
|
+
});
|
|
1066
1094
|
return zod.default.NEVER;
|
|
1067
1095
|
});
|
|
1068
1096
|
const zCredentialRequest = zod.default.union([
|
|
@@ -1076,7 +1104,7 @@ const zDeferredCredentialRequest = zod.default.object({
|
|
|
1076
1104
|
jwk: __openid4vc_oauth2.zJwk,
|
|
1077
1105
|
alg: zod.default.string(),
|
|
1078
1106
|
enc: zod.default.string()
|
|
1079
|
-
}).
|
|
1107
|
+
}).loose().optional()
|
|
1080
1108
|
});
|
|
1081
1109
|
|
|
1082
1110
|
//#endregion
|
|
@@ -1121,10 +1149,10 @@ let Oauth2ErrorCodes$2 = /* @__PURE__ */ function(Oauth2ErrorCodes$3) {
|
|
|
1121
1149
|
return Oauth2ErrorCodes$3;
|
|
1122
1150
|
}({});
|
|
1123
1151
|
const zOauth2ErrorResponse = zod.default.object({
|
|
1124
|
-
error: zod.default.union([zod.default.
|
|
1152
|
+
error: zod.default.union([zod.default.enum(Oauth2ErrorCodes$2), zod.default.string()]),
|
|
1125
1153
|
error_description: zod.default.string().optional(),
|
|
1126
1154
|
error_uri: zod.default.string().optional()
|
|
1127
|
-
}).
|
|
1155
|
+
}).loose();
|
|
1128
1156
|
|
|
1129
1157
|
//#endregion
|
|
1130
1158
|
//#region src/credential-request/z-credential-response.ts
|
|
@@ -1133,28 +1161,28 @@ const zBaseCredentialResponse = zod.default.object({
|
|
|
1133
1161
|
credentials: zod.default.union([zod.default.array(zod.default.object({ credential: zCredentialEncoding })), zod.default.array(zCredentialEncoding)]).optional(),
|
|
1134
1162
|
interval: zod.default.number().int().positive().optional(),
|
|
1135
1163
|
notification_id: zod.default.string().optional()
|
|
1136
|
-
}).
|
|
1164
|
+
}).loose();
|
|
1137
1165
|
const zCredentialResponse = zBaseCredentialResponse.extend({
|
|
1138
1166
|
credential: zod.default.optional(zCredentialEncoding),
|
|
1139
1167
|
transaction_id: zod.default.string().optional(),
|
|
1140
1168
|
c_nonce: zod.default.string().optional(),
|
|
1141
1169
|
c_nonce_expires_in: zod.default.number().int().optional()
|
|
1142
|
-
}).
|
|
1170
|
+
}).loose().superRefine((value, ctx) => {
|
|
1143
1171
|
const { credential, credentials, transaction_id, interval, notification_id } = value;
|
|
1144
1172
|
if ([
|
|
1145
1173
|
credential,
|
|
1146
1174
|
credentials,
|
|
1147
1175
|
transaction_id
|
|
1148
1176
|
].filter((i) => i !== void 0).length !== 1) ctx.addIssue({
|
|
1149
|
-
code:
|
|
1177
|
+
code: "custom",
|
|
1150
1178
|
message: `Exactly one of 'credential', 'credentials', or 'transaction_id' MUST be defined.`
|
|
1151
1179
|
});
|
|
1152
1180
|
if (transaction_id && !interval) ctx.addIssue({
|
|
1153
|
-
code:
|
|
1181
|
+
code: "custom",
|
|
1154
1182
|
message: `'interval' MUST be defined when 'transaction_id' is defined.`
|
|
1155
1183
|
});
|
|
1156
1184
|
if (notification_id && !(credentials || credential)) ctx.addIssue({
|
|
1157
|
-
code:
|
|
1185
|
+
code: "custom",
|
|
1158
1186
|
message: `'notification_id' MUST NOT be defined when 'credential' or 'credentials' are not defined.`
|
|
1159
1187
|
});
|
|
1160
1188
|
});
|
|
@@ -1162,7 +1190,7 @@ const zCredentialErrorResponse = zod.default.object({
|
|
|
1162
1190
|
...zOauth2ErrorResponse.shape,
|
|
1163
1191
|
c_nonce: zod.default.string().optional(),
|
|
1164
1192
|
c_nonce_expires_in: zod.default.number().int().optional()
|
|
1165
|
-
}).
|
|
1193
|
+
}).loose();
|
|
1166
1194
|
const zDeferredCredentialResponse = zBaseCredentialResponse.refine((value) => {
|
|
1167
1195
|
const { credentials, interval } = value;
|
|
1168
1196
|
return [credentials, interval].filter((i) => i !== void 0).length === 1;
|
|
@@ -1388,7 +1416,7 @@ async function resolveIssuerMetadata(credentialIssuer, options) {
|
|
|
1388
1416
|
const zNonceResponse = zod.default.object({
|
|
1389
1417
|
c_nonce: zod.default.string(),
|
|
1390
1418
|
c_nonce_expires_in: zod.default.optional(__openid4vc_utils.zInteger)
|
|
1391
|
-
}).
|
|
1419
|
+
}).loose();
|
|
1392
1420
|
|
|
1393
1421
|
//#endregion
|
|
1394
1422
|
//#region src/nonce/nonce-request.ts
|
|
@@ -1427,8 +1455,8 @@ const zNotificationRequest = zod.default.object({
|
|
|
1427
1455
|
notification_id: zod.default.string(),
|
|
1428
1456
|
event: zNotificationEvent,
|
|
1429
1457
|
event_description: zod.default.optional(zod.default.string())
|
|
1430
|
-
}).
|
|
1431
|
-
const zNotificationErrorResponse = zod.default.object({ error: zod.default.enum(["invalid_notification_id", "invalid_notification_request"]) }).
|
|
1458
|
+
}).loose();
|
|
1459
|
+
const zNotificationErrorResponse = zod.default.object({ error: zod.default.enum(["invalid_notification_id", "invalid_notification_request"]) }).loose();
|
|
1432
1460
|
|
|
1433
1461
|
//#endregion
|
|
1434
1462
|
//#region src/notification/notification.ts
|