@openid4vc/openid4vci 0.3.0-alpha-20251017121147 → 0.3.0-alpha-20251021081452
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 +3868 -44137
- package/dist/index.d.ts +3868 -44137
- package/dist/index.js +148 -114
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +148 -114
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ zod = __toESM(zod);
|
|
|
30
30
|
|
|
31
31
|
//#region src/version.ts
|
|
32
32
|
let Openid4vciDraftVersion = /* @__PURE__ */ function(Openid4vciDraftVersion$1) {
|
|
33
|
-
Openid4vciDraftVersion$1["
|
|
33
|
+
Openid4vciDraftVersion$1["V1"] = "V1";
|
|
34
34
|
Openid4vciDraftVersion$1["Draft15"] = "Draft15";
|
|
35
35
|
Openid4vciDraftVersion$1["Draft14"] = "Draft14";
|
|
36
36
|
Openid4vciDraftVersion$1["Draft11"] = "Draft11";
|
|
@@ -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
|
|
@@ -329,7 +330,7 @@ const zLegacySdJwtVcFormatIdentifier = zod.default.literal("vc+sd-jwt");
|
|
|
329
330
|
* of the OpenID for Verifiable Presentations specification. Please update your
|
|
330
331
|
* implementations accordingly.
|
|
331
332
|
*/
|
|
332
|
-
const
|
|
333
|
+
const zLegacySdJwtVcCredentialIssuerMetadataV1 = zCredentialConfigurationSupportedCommon.extend({
|
|
333
334
|
vct: zod.default.string(),
|
|
334
335
|
format: zLegacySdJwtVcFormatIdentifier,
|
|
335
336
|
order: zod.default.optional(zod.default.array(zod.default.string())),
|
|
@@ -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,
|
|
@@ -606,7 +607,7 @@ const allCredentialIssuerMetadataFormats = [
|
|
|
606
607
|
zJwtVcJsonCredentialIssuerMetadata,
|
|
607
608
|
zSdJwtW3VcCredentialIssuerMetadata,
|
|
608
609
|
zSdJwtW3VcCredentialIssuerMetadataDraft15,
|
|
609
|
-
|
|
610
|
+
zLegacySdJwtVcCredentialIssuerMetadataV1,
|
|
610
611
|
zSdJwtDcCredentialIssuerMetadataDraft15,
|
|
611
612
|
zMsoMdocCredentialIssuerMetadataDraft15,
|
|
612
613
|
zJwtVcJsonLdCredentialIssuerMetadataDraft15,
|
|
@@ -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,9 +637,9 @@ 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
|
-
}).
|
|
638
|
-
const
|
|
640
|
+
}).loose().optional()
|
|
641
|
+
}).loose();
|
|
642
|
+
const zCredentialIssuerMetadataDraft14Draft15V1 = zod.default.object({
|
|
639
643
|
credential_issuer: __openid4vc_utils.zHttpsUrl,
|
|
640
644
|
authorization_servers: zod.default.array(__openid4vc_utils.zHttpsUrl).optional(),
|
|
641
645
|
credential_endpoint: __openid4vc_utils.zHttpsUrl,
|
|
@@ -646,22 +650,21 @@ 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() }).
|
|
651
|
-
signed_metadata: __openid4vc_oauth2.zCompactJwt.optional(),
|
|
653
|
+
}).loose().optional(),
|
|
654
|
+
batch_credential_issuance: zod.default.object({ batch_size: zod.default.number().positive() }).loose().optional(),
|
|
652
655
|
display: zod.default.array(zCredentialIssuerMetadataDisplayEntry).optional(),
|
|
653
656
|
credential_configurations_supported: zod.default.record(zod.default.string(), zCredentialConfigurationSupportedWithFormats)
|
|
654
|
-
}).
|
|
657
|
+
}).loose();
|
|
655
658
|
const zCredentialConfigurationSupportedDraft11To16 = zod.default.object({
|
|
656
659
|
id: zod.default.string().optional(),
|
|
657
660
|
format: zod.default.string(),
|
|
658
661
|
cryptographic_suites_supported: zod.default.array(zod.default.string()).optional(),
|
|
659
662
|
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
|
-
}).
|
|
663
|
+
logo: zod.default.object({ url: zod.default.url().optional() }).loose().optional(),
|
|
664
|
+
background_image: zod.default.object({ url: zod.default.url().optional() }).loose().optional()
|
|
665
|
+
}).loose()).optional(),
|
|
663
666
|
claims: zod.default.any().optional()
|
|
664
|
-
}).
|
|
667
|
+
}).loose().transform(({ cryptographic_suites_supported, display, claims, id,...rest }) => ({
|
|
665
668
|
...rest,
|
|
666
669
|
...cryptographic_suites_supported ? { credential_signing_alg_values_supported: cryptographic_suites_supported } : {},
|
|
667
670
|
...claims || display ? { credential_metadata: {
|
|
@@ -681,13 +684,16 @@ const zCredentialConfigurationSupportedDraft11To16 = zod.default.object({
|
|
|
681
684
|
if (!Object.keys(formatSpecificTransformations).includes(data.format)) return data;
|
|
682
685
|
const result = formatSpecificTransformations[data.format].safeParse(data);
|
|
683
686
|
if (result.success) return result.data;
|
|
684
|
-
for (const issue of result.error.issues) ctx.addIssue(
|
|
687
|
+
for (const issue of result.error.issues) ctx.addIssue({
|
|
688
|
+
...issue,
|
|
689
|
+
code: issue.code
|
|
690
|
+
});
|
|
685
691
|
return zod.default.NEVER;
|
|
686
692
|
}).pipe(zCredentialConfigurationSupportedWithFormats);
|
|
687
|
-
const
|
|
693
|
+
const zCredentialConfigurationSupportedV1ToDraft11 = zCredentialConfigurationSupportedWithFormats.transform(({ credential_metadata,...rest }) => ({
|
|
688
694
|
...credential_metadata,
|
|
689
695
|
...rest
|
|
690
|
-
})).and(zod.default.object({ id: zod.default.string() }).
|
|
696
|
+
})).and(zod.default.object({ id: zod.default.string() }).loose()).transform(({ id, credential_signing_alg_values_supported, display, proof_types_supported, scope,...rest }) => ({
|
|
691
697
|
...rest,
|
|
692
698
|
...credential_signing_alg_values_supported ? { cryptographic_suites_supported: credential_signing_alg_values_supported } : {},
|
|
693
699
|
...display ? { display: display.map(({ logo, background_image,...displayRest }) => {
|
|
@@ -714,28 +720,28 @@ const zCredentialConfigurationSupportedDraft16To11 = zCredentialConfigurationSup
|
|
|
714
720
|
zLdpVcFormatIdentifier.value,
|
|
715
721
|
zJwtVcJsonFormatIdentifier.value,
|
|
716
722
|
zJwtVcJsonLdFormatIdentifier.value
|
|
717
|
-
].includes(input)) }).
|
|
723
|
+
].includes(input)) }).loose()
|
|
718
724
|
]));
|
|
719
725
|
const zCredentialIssuerMetadataDraft11To16 = zod.default.object({
|
|
720
726
|
authorization_server: zod.default.string().optional(),
|
|
721
|
-
credentials_supported: zod.default.array(zod.default.object({ id: zod.default.string().optional() }).
|
|
722
|
-
}).
|
|
727
|
+
credentials_supported: zod.default.array(zod.default.object({ id: zod.default.string().optional() }).loose())
|
|
728
|
+
}).loose().transform(({ authorization_server, credentials_supported,...rest }) => {
|
|
723
729
|
return {
|
|
724
730
|
...rest,
|
|
725
731
|
...authorization_server ? { authorization_servers: [authorization_server] } : {},
|
|
726
732
|
credential_configurations_supported: Object.fromEntries(credentials_supported.map((supported) => supported.id ? [supported.id, supported] : void 0).filter((i) => i !== void 0))
|
|
727
733
|
};
|
|
728
|
-
}).pipe(zod.default.object({ credential_configurations_supported: zod.default.record(zod.default.string(), zCredentialConfigurationSupportedDraft11To16) }).
|
|
729
|
-
const zCredentialIssuerMetadataWithDraft11 =
|
|
734
|
+
}).pipe(zod.default.object({ credential_configurations_supported: zod.default.record(zod.default.string(), zCredentialConfigurationSupportedDraft11To16) }).loose()).pipe(zCredentialIssuerMetadataDraft14Draft15V1);
|
|
735
|
+
const zCredentialIssuerMetadataWithDraft11 = zCredentialIssuerMetadataDraft14Draft15V1.transform((issuerMetadata) => ({
|
|
730
736
|
...issuerMetadata,
|
|
731
737
|
...issuerMetadata.authorization_servers ? { authorization_server: issuerMetadata.authorization_servers[0] } : {},
|
|
732
738
|
credentials_supported: Object.entries(issuerMetadata.credential_configurations_supported).map(([id, value]) => ({
|
|
733
739
|
...value,
|
|
734
740
|
id
|
|
735
741
|
}))
|
|
736
|
-
})).pipe(
|
|
737
|
-
const zCredentialIssuerMetadata = zod.default.union([
|
|
738
|
-
const zCredentialIssuerMetadataWithDraftVersion = zod.default.union([
|
|
742
|
+
})).pipe(zCredentialIssuerMetadataDraft14Draft15V1.extend({ credentials_supported: zod.default.array(zCredentialConfigurationSupportedV1ToDraft11) }));
|
|
743
|
+
const zCredentialIssuerMetadata = zod.default.union([zCredentialIssuerMetadataDraft14Draft15V1, zCredentialIssuerMetadataDraft11To16]);
|
|
744
|
+
const zCredentialIssuerMetadataWithDraftVersion = zod.default.union([zCredentialIssuerMetadataDraft14Draft15V1.transform((credentialIssuerMetadata) => {
|
|
739
745
|
const credentialConfigurations = Object.values(credentialIssuerMetadata.credential_configurations_supported);
|
|
740
746
|
const isDraft15 = credentialConfigurations.some((configuration) => {
|
|
741
747
|
const knownConfiguration = configuration;
|
|
@@ -746,9 +752,7 @@ const zCredentialIssuerMetadataWithDraftVersion = zod.default.union([zCredential
|
|
|
746
752
|
});
|
|
747
753
|
return {
|
|
748
754
|
credentialIssuerMetadata,
|
|
749
|
-
originalDraftVersion: credentialConfigurations.some((configuration) =>
|
|
750
|
-
return configuration.credential_metadata;
|
|
751
|
-
}) ? Openid4vciDraftVersion.Draft16 : isDraft15 ? Openid4vciDraftVersion.Draft15 : Openid4vciDraftVersion.Draft14
|
|
755
|
+
originalDraftVersion: credentialConfigurations.some((configuration) => configuration.credential_metadata) ? Openid4vciDraftVersion.V1 : isDraft15 ? Openid4vciDraftVersion.Draft15 : Openid4vciDraftVersion.Draft14
|
|
752
756
|
};
|
|
753
757
|
}), zCredentialIssuerMetadataDraft11To16.transform((credentialIssuerMetadata) => ({
|
|
754
758
|
credentialIssuerMetadata,
|
|
@@ -927,7 +931,7 @@ function credentialsSupportedToCredentialConfigurationsSupported(credentialsSupp
|
|
|
927
931
|
//#region src/credential-request/format-payload.ts
|
|
928
932
|
function getCredentialRequestFormatPayloadForCredentialConfigurationId(options) {
|
|
929
933
|
const credentialConfiguration = getCredentialConfigurationSupportedById(options.issuerMetadata.credentialIssuer.credential_configurations_supported, options.credentialConfigurationId);
|
|
930
|
-
if ((0, __openid4vc_utils.zIs)(
|
|
934
|
+
if ((0, __openid4vc_utils.zIs)(zLegacySdJwtVcCredentialIssuerMetadataV1, credentialConfiguration) || (0, __openid4vc_utils.zIs)(zLegacySdJwtVcCredentialIssuerMetadataDraft14, credentialConfiguration)) return {
|
|
931
935
|
format: credentialConfiguration.format,
|
|
932
936
|
vct: credentialConfiguration.vct
|
|
933
937
|
};
|
|
@@ -982,16 +986,16 @@ const zCredentialRequestProofJwt = zod.default.object({
|
|
|
982
986
|
const zCredentialRequestJwtProofTypeHeader = __openid4vc_oauth2.zJwtHeader.merge(zod.default.object({
|
|
983
987
|
key_attestation: zod.default.optional(__openid4vc_oauth2.zCompactJwt),
|
|
984
988
|
typ: zod.default.literal("openid4vci-proof+jwt")
|
|
985
|
-
})).
|
|
989
|
+
})).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` });
|
|
986
990
|
const zCredentialRequestJwtProofTypePayload = zod.default.object({
|
|
987
991
|
...__openid4vc_oauth2.zJwtPayload.shape,
|
|
988
992
|
aud: __openid4vc_utils.zHttpsUrl,
|
|
989
993
|
iat: __openid4vc_utils.zInteger
|
|
990
|
-
}).
|
|
994
|
+
}).loose();
|
|
991
995
|
|
|
992
996
|
//#endregion
|
|
993
997
|
//#region src/credential-request/z-credential-request-common.ts
|
|
994
|
-
const zCredentialRequestProofCommon = zod.default.object({ proof_type: zod.default.string() }).
|
|
998
|
+
const zCredentialRequestProofCommon = zod.default.object({ proof_type: zod.default.string() }).loose();
|
|
995
999
|
const allCredentialRequestProofs = [zCredentialRequestProofJwt, zCredentialRequestProofAttestation];
|
|
996
1000
|
const zCredentialRequestProof = zod.default.union([zCredentialRequestProofCommon, zod.default.discriminatedUnion("proof_type", allCredentialRequestProofs)]);
|
|
997
1001
|
const zCredentialRequestProofsCommon = zod.default.record(zod.default.string(), zod.default.array(zod.default.unknown()));
|
|
@@ -1006,8 +1010,8 @@ const zCredentialRequestCommon = zod.default.object({
|
|
|
1006
1010
|
jwk: __openid4vc_oauth2.zJwk,
|
|
1007
1011
|
alg: zod.default.string(),
|
|
1008
1012
|
enc: zod.default.string()
|
|
1009
|
-
}).
|
|
1010
|
-
}).
|
|
1013
|
+
}).loose().optional()
|
|
1014
|
+
}).loose().refine(({ proof, proofs }) => !(proof !== void 0 && proofs !== void 0), { message: `Both 'proof' and 'proofs' are defined. Only one is allowed` });
|
|
1011
1015
|
|
|
1012
1016
|
//#endregion
|
|
1013
1017
|
//#region src/credential-request/z-credential-request.ts
|
|
@@ -1034,12 +1038,15 @@ const zCredentialRequestFormat = zod.default.object({
|
|
|
1034
1038
|
format: zod.default.string(),
|
|
1035
1039
|
credential_identifier: zod.default.never({ message: "'credential_identifier' cannot be defined when 'format' is set." }).optional(),
|
|
1036
1040
|
credential_configuration_id: zod.default.never({ message: "'credential_configuration_id' cannot be defined when 'format' is set." }).optional()
|
|
1037
|
-
}).
|
|
1041
|
+
}).loose();
|
|
1038
1042
|
const zCredentialRequestDraft14WithFormat = zCredentialRequestCommon.and(zCredentialRequestFormat).transform((data, ctx) => {
|
|
1039
1043
|
if (!allCredentialRequestFormatIdentifiers.includes(data.format)) return data;
|
|
1040
|
-
const result = zod.default.object({}).
|
|
1044
|
+
const result = zod.default.object({}).loose().and(zod.default.union(allCredentialRequestFormats)).safeParse(data);
|
|
1041
1045
|
if (result.success) return result.data;
|
|
1042
|
-
for (const issue of result.error.issues) ctx.addIssue(
|
|
1046
|
+
for (const issue of result.error.issues) ctx.addIssue({
|
|
1047
|
+
...issue,
|
|
1048
|
+
code: issue.code
|
|
1049
|
+
});
|
|
1043
1050
|
return zod.default.NEVER;
|
|
1044
1051
|
});
|
|
1045
1052
|
const zCredentialRequestDraft15 = zod.default.union([zCredentialRequestCommon.and(zAuthorizationDetailsCredentialRequest), zCredentialRequestCommon.and(zCredentialRequestCredentialConfigurationId)]);
|
|
@@ -1053,10 +1060,22 @@ const zCredentialRequestDraft11To14 = zCredentialRequestCommon.and(zCredentialRe
|
|
|
1053
1060
|
if (!Object.keys(formatSpecificTransformations).includes(data.format)) return data;
|
|
1054
1061
|
const result = formatSpecificTransformations[data.format].safeParse(data);
|
|
1055
1062
|
if (result.success) return result.data;
|
|
1056
|
-
for (const issue of result.error.issues) ctx.addIssue(
|
|
1063
|
+
for (const issue of result.error.issues) ctx.addIssue({
|
|
1064
|
+
...issue,
|
|
1065
|
+
code: issue.code
|
|
1066
|
+
});
|
|
1057
1067
|
return zod.default.NEVER;
|
|
1058
1068
|
}).pipe(zCredentialRequestDraft14);
|
|
1059
|
-
const zCredentialRequestDraft14To11 = zCredentialRequestDraft14.
|
|
1069
|
+
const zCredentialRequestDraft14To11 = zCredentialRequestDraft14.transform((data, ctx) => {
|
|
1070
|
+
if (data.credential_identifier !== void 0) {
|
|
1071
|
+
ctx.addIssue({
|
|
1072
|
+
code: "custom",
|
|
1073
|
+
continue: false,
|
|
1074
|
+
message: `'credential_identifier' is not supported in OpenID4VCI draft 11`,
|
|
1075
|
+
path: ["credential_identifier"]
|
|
1076
|
+
});
|
|
1077
|
+
return zod.default.NEVER;
|
|
1078
|
+
}
|
|
1060
1079
|
const formatSpecificTransformations = {
|
|
1061
1080
|
[zLdpVcFormatIdentifier.value]: zLdpVcCredentialRequestDraft14To11,
|
|
1062
1081
|
[zJwtVcJsonFormatIdentifier.value]: zJwtVcJsonCredentialRequestDraft14To11,
|
|
@@ -1065,7 +1084,10 @@ const zCredentialRequestDraft14To11 = zCredentialRequestDraft14.refine((data) =>
|
|
|
1065
1084
|
if (!Object.keys(formatSpecificTransformations).includes(data.format)) return data;
|
|
1066
1085
|
const result = formatSpecificTransformations[data.format].safeParse(data);
|
|
1067
1086
|
if (result.success) return result.data;
|
|
1068
|
-
for (const issue of result.error.issues) ctx.addIssue(
|
|
1087
|
+
for (const issue of result.error.issues) ctx.addIssue({
|
|
1088
|
+
...issue,
|
|
1089
|
+
code: issue.code
|
|
1090
|
+
});
|
|
1069
1091
|
return zod.default.NEVER;
|
|
1070
1092
|
});
|
|
1071
1093
|
const zCredentialRequest = zod.default.union([
|
|
@@ -1079,7 +1101,7 @@ const zDeferredCredentialRequest = zod.default.object({
|
|
|
1079
1101
|
jwk: __openid4vc_oauth2.zJwk,
|
|
1080
1102
|
alg: zod.default.string(),
|
|
1081
1103
|
enc: zod.default.string()
|
|
1082
|
-
}).
|
|
1104
|
+
}).loose().optional()
|
|
1083
1105
|
});
|
|
1084
1106
|
|
|
1085
1107
|
//#endregion
|
|
@@ -1124,40 +1146,40 @@ let Oauth2ErrorCodes$2 = /* @__PURE__ */ function(Oauth2ErrorCodes$3) {
|
|
|
1124
1146
|
return Oauth2ErrorCodes$3;
|
|
1125
1147
|
}({});
|
|
1126
1148
|
const zOauth2ErrorResponse = zod.default.object({
|
|
1127
|
-
error: zod.default.union([zod.default.
|
|
1149
|
+
error: zod.default.union([zod.default.enum(Oauth2ErrorCodes$2), zod.default.string()]),
|
|
1128
1150
|
error_description: zod.default.string().optional(),
|
|
1129
1151
|
error_uri: zod.default.string().optional()
|
|
1130
|
-
}).
|
|
1152
|
+
}).loose();
|
|
1131
1153
|
|
|
1132
1154
|
//#endregion
|
|
1133
1155
|
//#region src/credential-request/z-credential-response.ts
|
|
1134
1156
|
const zCredentialEncoding = zod.default.union([zod.default.string(), zod.default.record(zod.default.string(), zod.default.any())]);
|
|
1135
1157
|
const zBaseCredentialResponse = zod.default.object({
|
|
1136
1158
|
credentials: zod.default.union([zod.default.array(zod.default.object({ credential: zCredentialEncoding })), zod.default.array(zCredentialEncoding)]).optional(),
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1159
|
+
notification_id: zod.default.string().optional(),
|
|
1160
|
+
transaction_id: zod.default.string().optional(),
|
|
1161
|
+
interval: zod.default.number().int().positive().optional()
|
|
1162
|
+
}).loose();
|
|
1140
1163
|
const zCredentialResponse = zBaseCredentialResponse.extend({
|
|
1141
1164
|
credential: zod.default.optional(zCredentialEncoding),
|
|
1142
|
-
transaction_id: zod.default.string().optional(),
|
|
1143
1165
|
c_nonce: zod.default.string().optional(),
|
|
1144
1166
|
c_nonce_expires_in: zod.default.number().int().optional()
|
|
1145
|
-
}).
|
|
1167
|
+
}).loose().superRefine((value, ctx) => {
|
|
1146
1168
|
const { credential, credentials, transaction_id, interval, notification_id } = value;
|
|
1147
1169
|
if ([
|
|
1148
1170
|
credential,
|
|
1149
1171
|
credentials,
|
|
1150
1172
|
transaction_id
|
|
1151
1173
|
].filter((i) => i !== void 0).length !== 1) ctx.addIssue({
|
|
1152
|
-
code:
|
|
1174
|
+
code: "custom",
|
|
1153
1175
|
message: `Exactly one of 'credential', 'credentials', or 'transaction_id' MUST be defined.`
|
|
1154
1176
|
});
|
|
1155
1177
|
if (transaction_id && !interval) ctx.addIssue({
|
|
1156
|
-
code:
|
|
1178
|
+
code: "custom",
|
|
1157
1179
|
message: `'interval' MUST be defined when 'transaction_id' is defined.`
|
|
1158
1180
|
});
|
|
1159
1181
|
if (notification_id && !(credentials || credential)) ctx.addIssue({
|
|
1160
|
-
code:
|
|
1182
|
+
code: "custom",
|
|
1161
1183
|
message: `'notification_id' MUST NOT be defined when 'credential' or 'credentials' are not defined.`
|
|
1162
1184
|
});
|
|
1163
1185
|
});
|
|
@@ -1165,16 +1187,27 @@ const zCredentialErrorResponse = zod.default.object({
|
|
|
1165
1187
|
...zOauth2ErrorResponse.shape,
|
|
1166
1188
|
c_nonce: zod.default.string().optional(),
|
|
1167
1189
|
c_nonce_expires_in: zod.default.number().int().optional()
|
|
1168
|
-
}).
|
|
1169
|
-
const zDeferredCredentialResponse = zBaseCredentialResponse.
|
|
1170
|
-
const { credentials, interval } = value;
|
|
1171
|
-
|
|
1172
|
-
|
|
1190
|
+
}).loose();
|
|
1191
|
+
const zDeferredCredentialResponse = zBaseCredentialResponse.superRefine((value, ctx) => {
|
|
1192
|
+
const { credentials, transaction_id, interval, notification_id } = value;
|
|
1193
|
+
if ([credentials, transaction_id].filter((i) => i !== void 0).length !== 1) ctx.addIssue({
|
|
1194
|
+
code: "custom",
|
|
1195
|
+
message: `Exactly one of 'credentials', or 'transaction_id' MUST be defined.`
|
|
1196
|
+
});
|
|
1197
|
+
if (transaction_id && !interval) ctx.addIssue({
|
|
1198
|
+
code: "custom",
|
|
1199
|
+
message: `'interval' MUST be defined when 'transaction_id' is defined.`
|
|
1200
|
+
});
|
|
1201
|
+
if (notification_id && credentials) ctx.addIssue({
|
|
1202
|
+
code: "custom",
|
|
1203
|
+
message: `'notification_id' MUST NOT be defined when 'credentials' is not defined.`
|
|
1204
|
+
});
|
|
1205
|
+
});
|
|
1173
1206
|
|
|
1174
1207
|
//#endregion
|
|
1175
1208
|
//#region src/credential-request/retrieve-credentials.ts
|
|
1176
1209
|
async function retrieveCredentialsWithCredentialConfigurationId(options) {
|
|
1177
|
-
if (options.issuerMetadata.originalDraftVersion !== Openid4vciDraftVersion.Draft15 && options.issuerMetadata.originalDraftVersion !== Openid4vciDraftVersion.
|
|
1210
|
+
if (options.issuerMetadata.originalDraftVersion !== Openid4vciDraftVersion.Draft15 && options.issuerMetadata.originalDraftVersion !== Openid4vciDraftVersion.V1) throw new Openid4vciError("Requesting credentials based on credential configuration ID is not supported in OpenID4VCI below draft 15. Make sure to provide the format and format specific claims in the request.");
|
|
1178
1211
|
getCredentialConfigurationSupportedById(options.issuerMetadata.credentialIssuer.credential_configurations_supported, options.credentialConfigurationId);
|
|
1179
1212
|
const credentialRequest = {
|
|
1180
1213
|
...options.additionalRequestPayload,
|
|
@@ -1191,7 +1224,7 @@ async function retrieveCredentialsWithCredentialConfigurationId(options) {
|
|
|
1191
1224
|
});
|
|
1192
1225
|
}
|
|
1193
1226
|
async function retrieveCredentialsWithFormat(options) {
|
|
1194
|
-
if (options.issuerMetadata.originalDraftVersion === Openid4vciDraftVersion.Draft15 || options.issuerMetadata.originalDraftVersion === Openid4vciDraftVersion.
|
|
1227
|
+
if (options.issuerMetadata.originalDraftVersion === Openid4vciDraftVersion.Draft15 || options.issuerMetadata.originalDraftVersion === Openid4vciDraftVersion.V1) throw new Openid4vciError("Requesting credentials based on format is not supported on OpenID4VCI above draft 15. Provide the credential configuration id directly in the request.");
|
|
1195
1228
|
const credentialRequest = {
|
|
1196
1229
|
...options.formatPayload,
|
|
1197
1230
|
...options.additionalRequestPayload,
|
|
@@ -1273,7 +1306,7 @@ async function retrieveDeferredCredentials(options) {
|
|
|
1273
1306
|
deferredCredentialErrorResponseResult
|
|
1274
1307
|
};
|
|
1275
1308
|
}
|
|
1276
|
-
const deferredCredentialResponseResult = (0, __openid4vc_utils.isResponseContentType)(__openid4vc_utils.ContentType.Json, resourceResponse.response) ? zDeferredCredentialResponse.safeParse(await resourceResponse.response.clone().json()) : void 0;
|
|
1309
|
+
const deferredCredentialResponseResult = (0, __openid4vc_utils.isResponseContentType)(__openid4vc_utils.ContentType.Json, resourceResponse.response) ? zDeferredCredentialResponse.refine((response) => response.credentials || response.transaction_id === options.transactionId, { error: `Transaction id in deferred credential response does not match transaction id in deferred credential request '${options.transactionId}'` }).safeParse(await resourceResponse.response.clone().json()) : void 0;
|
|
1277
1310
|
if (!deferredCredentialResponseResult?.success) return {
|
|
1278
1311
|
...resourceResponse,
|
|
1279
1312
|
ok: false,
|
|
@@ -1391,7 +1424,7 @@ async function resolveIssuerMetadata(credentialIssuer, options) {
|
|
|
1391
1424
|
const zNonceResponse = zod.default.object({
|
|
1392
1425
|
c_nonce: zod.default.string(),
|
|
1393
1426
|
c_nonce_expires_in: zod.default.optional(__openid4vc_utils.zInteger)
|
|
1394
|
-
}).
|
|
1427
|
+
}).loose();
|
|
1395
1428
|
|
|
1396
1429
|
//#endregion
|
|
1397
1430
|
//#region src/nonce/nonce-request.ts
|
|
@@ -1430,8 +1463,8 @@ const zNotificationRequest = zod.default.object({
|
|
|
1430
1463
|
notification_id: zod.default.string(),
|
|
1431
1464
|
event: zNotificationEvent,
|
|
1432
1465
|
event_description: zod.default.optional(zod.default.string())
|
|
1433
|
-
}).
|
|
1434
|
-
const zNotificationErrorResponse = zod.default.object({ error: zod.default.enum(["invalid_notification_id", "invalid_notification_request"]) }).
|
|
1466
|
+
}).loose();
|
|
1467
|
+
const zNotificationErrorResponse = zod.default.object({ error: zod.default.enum(["invalid_notification_id", "invalid_notification_request"]) }).loose();
|
|
1435
1468
|
|
|
1436
1469
|
//#endregion
|
|
1437
1470
|
//#region src/notification/notification.ts
|
|
@@ -1691,7 +1724,7 @@ var Openid4vciClient = class {
|
|
|
1691
1724
|
*/
|
|
1692
1725
|
async retrieveCredentials({ issuerMetadata, proof, proofs, credentialConfigurationId, additionalRequestPayload, accessToken, dpop }) {
|
|
1693
1726
|
let credentialResponse;
|
|
1694
|
-
if (issuerMetadata.originalDraftVersion === Openid4vciDraftVersion.Draft15 || issuerMetadata.originalDraftVersion === Openid4vciDraftVersion.
|
|
1727
|
+
if (issuerMetadata.originalDraftVersion === Openid4vciDraftVersion.Draft15 || issuerMetadata.originalDraftVersion === Openid4vciDraftVersion.V1) credentialResponse = await retrieveCredentialsWithCredentialConfigurationId({
|
|
1695
1728
|
accessToken,
|
|
1696
1729
|
credentialConfigurationId,
|
|
1697
1730
|
issuerMetadata,
|
|
@@ -1766,6 +1799,7 @@ function createDeferredCredentialResponse(options) {
|
|
|
1766
1799
|
return (0, __openid4vc_utils.parseWithErrorHandling)(zDeferredCredentialResponse, {
|
|
1767
1800
|
credentials: options.credentials,
|
|
1768
1801
|
notification_id: options.notificationId,
|
|
1802
|
+
transaction_id: options.transactionId,
|
|
1769
1803
|
interval: options.interval,
|
|
1770
1804
|
...options.additionalPayload
|
|
1771
1805
|
});
|