@openid4vc/openid4vci 0.3.0-alpha-20250714110838 → 0.3.0-alpha-20250811083900
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 +9140 -4844
- package/dist/index.d.ts +9140 -4844
- package/dist/index.js +487 -285
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +421 -219
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
|
|
21
21
|
// src/version.ts
|
|
22
22
|
var Openid4vciDraftVersion = /* @__PURE__ */ ((Openid4vciDraftVersion2) => {
|
|
23
|
+
Openid4vciDraftVersion2["Draft16"] = "Draft16";
|
|
23
24
|
Openid4vciDraftVersion2["Draft15"] = "Draft15";
|
|
24
25
|
Openid4vciDraftVersion2["Draft14"] = "Draft14";
|
|
25
26
|
Openid4vciDraftVersion2["Draft11"] = "Draft11";
|
|
@@ -110,7 +111,7 @@ async function resolveCredentialOffer(credentialOffer, options) {
|
|
|
110
111
|
);
|
|
111
112
|
if (!response.ok || !result) {
|
|
112
113
|
throw new InvalidFetchResponseError(
|
|
113
|
-
`Fetching credential offer from '${parsedQueryParams.credential_offer_uri}' resulted in an
|
|
114
|
+
`Fetching credential offer from '${parsedQueryParams.credential_offer_uri}' resulted in an unsuccessful response with status '${response.status}'`,
|
|
114
115
|
await response.clone().text(),
|
|
115
116
|
response
|
|
116
117
|
);
|
|
@@ -242,7 +243,7 @@ import { zHttpsUrl as zHttpsUrl2 } from "@openid4vc/utils";
|
|
|
242
243
|
import z12 from "zod";
|
|
243
244
|
|
|
244
245
|
// src/formats/credential/mso-mdoc/z-mso-mdoc.ts
|
|
245
|
-
import
|
|
246
|
+
import z5 from "zod";
|
|
246
247
|
|
|
247
248
|
// src/metadata/credential-issuer/z-claims-description.ts
|
|
248
249
|
import z2 from "zod";
|
|
@@ -272,98 +273,196 @@ var zMsoMdocIssuerMetadataClaimsDescription = zIssuerMetadataClaimsDescription.e
|
|
|
272
273
|
path: zMsoMdocClaimsDescriptionPath
|
|
273
274
|
});
|
|
274
275
|
|
|
276
|
+
// src/metadata/credential-issuer/z-credential-configuration-supported-common.ts
|
|
277
|
+
import z4 from "zod";
|
|
278
|
+
|
|
279
|
+
// src/key-attestation/z-key-attestation.ts
|
|
280
|
+
import { zJwk, zJwtHeader, zJwtPayload } from "@openid4vc/oauth2";
|
|
281
|
+
import { zInteger } from "@openid4vc/utils";
|
|
282
|
+
import z3 from "zod";
|
|
283
|
+
var zKeyAttestationJwtHeader = z3.object({
|
|
284
|
+
...zJwtHeader.shape,
|
|
285
|
+
typ: z3.literal("keyattestation+jwt").or(
|
|
286
|
+
// Draft 16
|
|
287
|
+
z3.literal("key-attestation+jwt")
|
|
288
|
+
)
|
|
289
|
+
}).passthrough().refine(({ kid, jwk }) => jwk === void 0 || kid === void 0, {
|
|
290
|
+
message: `Both 'jwk' and 'kid' are defined. Only one is allowed`
|
|
291
|
+
}).refine(({ trust_chain, kid }) => !trust_chain || !kid, {
|
|
292
|
+
message: `When 'trust_chain' is provided, 'kid' is required`
|
|
293
|
+
});
|
|
294
|
+
var zIso18045 = z3.enum(["iso_18045_high", "iso_18045_moderate", "iso_18045_enhanced-basic", "iso_18045_basic"]);
|
|
295
|
+
var zIso18045OrStringArray = z3.array(z3.union([zIso18045, z3.string()]));
|
|
296
|
+
var zKeyAttestationJwtPayload = z3.object({
|
|
297
|
+
...zJwtPayload.shape,
|
|
298
|
+
iat: zInteger,
|
|
299
|
+
attested_keys: z3.array(zJwk),
|
|
300
|
+
key_storage: z3.optional(zIso18045OrStringArray),
|
|
301
|
+
user_authentication: z3.optional(zIso18045OrStringArray),
|
|
302
|
+
certification: z3.optional(z3.string().url())
|
|
303
|
+
}).passthrough();
|
|
304
|
+
var zKeyAttestationJwtPayloadForUse = (use) => z3.object({
|
|
305
|
+
...zKeyAttestationJwtPayload.shape,
|
|
306
|
+
// REQUIRED when used as proof_type.attesation directly
|
|
307
|
+
nonce: use === "proof_type.attestation" ? z3.string({
|
|
308
|
+
message: `Nonce must be defined when key attestation is used as 'proof_type.attestation' directly`
|
|
309
|
+
}) : z3.optional(z3.string()),
|
|
310
|
+
// REQUIRED when used within header of proof_type.jwt
|
|
311
|
+
exp: use === "proof_type.jwt" ? zInteger : z3.optional(zInteger)
|
|
312
|
+
}).passthrough();
|
|
313
|
+
|
|
314
|
+
// src/metadata/credential-issuer/z-credential-configuration-supported-common.ts
|
|
315
|
+
var zCredentialConfigurationSupportedCommonCredentialMetadata = z4.object({
|
|
316
|
+
display: z4.array(
|
|
317
|
+
z4.object({
|
|
318
|
+
name: z4.string(),
|
|
319
|
+
locale: z4.string().optional(),
|
|
320
|
+
logo: z4.object({
|
|
321
|
+
// FIXME: make required again, but need to support draft 11 first
|
|
322
|
+
uri: z4.string().optional(),
|
|
323
|
+
alt_text: z4.string().optional()
|
|
324
|
+
}).passthrough().optional(),
|
|
325
|
+
description: z4.string().optional(),
|
|
326
|
+
background_color: z4.string().optional(),
|
|
327
|
+
background_image: z4.object({
|
|
328
|
+
// TODO: should be required, but paradym's metadata is wrong here.
|
|
329
|
+
uri: z4.string().optional()
|
|
330
|
+
}).passthrough().optional(),
|
|
331
|
+
text_color: z4.string().optional()
|
|
332
|
+
}).passthrough()
|
|
333
|
+
).optional()
|
|
334
|
+
});
|
|
335
|
+
var zCredentialConfigurationSupportedCommon = z4.object({
|
|
336
|
+
format: z4.string(),
|
|
337
|
+
scope: z4.string().optional(),
|
|
338
|
+
cryptographic_binding_methods_supported: z4.array(z4.string()).optional(),
|
|
339
|
+
credential_signing_alg_values_supported: z4.array(z4.string()).or(z4.array(z4.number())).optional(),
|
|
340
|
+
proof_types_supported: z4.record(
|
|
341
|
+
z4.union([z4.literal("jwt"), z4.literal("attestation"), z4.string()]),
|
|
342
|
+
z4.object({
|
|
343
|
+
proof_signing_alg_values_supported: z4.array(z4.string()),
|
|
344
|
+
key_attestations_required: z4.object({
|
|
345
|
+
key_storage: zIso18045OrStringArray.optional(),
|
|
346
|
+
user_authentication: zIso18045OrStringArray.optional()
|
|
347
|
+
}).passthrough().optional()
|
|
348
|
+
})
|
|
349
|
+
).optional(),
|
|
350
|
+
credential_metadata: zCredentialConfigurationSupportedCommonCredentialMetadata.optional()
|
|
351
|
+
}).passthrough();
|
|
352
|
+
|
|
275
353
|
// src/formats/credential/mso-mdoc/z-mso-mdoc.ts
|
|
276
|
-
var zMsoMdocFormatIdentifier =
|
|
277
|
-
var zMsoMdocCredentialIssuerMetadata =
|
|
354
|
+
var zMsoMdocFormatIdentifier = z5.literal("mso_mdoc");
|
|
355
|
+
var zMsoMdocCredentialIssuerMetadata = z5.object({
|
|
356
|
+
format: zMsoMdocFormatIdentifier,
|
|
357
|
+
doctype: z5.string(),
|
|
358
|
+
credential_metadata: zCredentialConfigurationSupportedCommonCredentialMetadata.extend({
|
|
359
|
+
claims: z5.array(zMsoMdocIssuerMetadataClaimsDescription).optional()
|
|
360
|
+
}).optional()
|
|
361
|
+
});
|
|
362
|
+
var zMsoMdocCredentialIssuerMetadataDraft15 = z5.object({
|
|
278
363
|
format: zMsoMdocFormatIdentifier,
|
|
279
|
-
doctype:
|
|
280
|
-
claims:
|
|
364
|
+
doctype: z5.string(),
|
|
365
|
+
claims: z5.array(zMsoMdocIssuerMetadataClaimsDescription).optional()
|
|
281
366
|
});
|
|
282
|
-
var zMsoMdocCredentialIssuerMetadataDraft14 =
|
|
367
|
+
var zMsoMdocCredentialIssuerMetadataDraft14 = z5.object({
|
|
283
368
|
format: zMsoMdocFormatIdentifier,
|
|
284
|
-
doctype:
|
|
369
|
+
doctype: z5.string(),
|
|
285
370
|
claims: zCredentialConfigurationSupportedClaimsDraft14.optional(),
|
|
286
|
-
order:
|
|
371
|
+
order: z5.optional(z5.array(z5.string()))
|
|
287
372
|
});
|
|
288
|
-
var zMsoMdocCredentialRequestFormatDraft14 =
|
|
373
|
+
var zMsoMdocCredentialRequestFormatDraft14 = z5.object({
|
|
289
374
|
format: zMsoMdocFormatIdentifier,
|
|
290
|
-
doctype:
|
|
375
|
+
doctype: z5.string(),
|
|
291
376
|
// Format based request is removed in Draft 15, so only old claims syntax supported.
|
|
292
|
-
claims:
|
|
377
|
+
claims: z5.optional(zCredentialConfigurationSupportedClaimsDraft14)
|
|
293
378
|
});
|
|
294
379
|
|
|
295
380
|
// src/formats/credential/sd-jwt-vc/z-sd-jwt-vc.ts
|
|
296
|
-
import
|
|
297
|
-
var zSdJwtVcFormatIdentifier =
|
|
298
|
-
var zSdJwtVcCredentialIssuerMetadataDraft14 =
|
|
299
|
-
vct:
|
|
381
|
+
import z6 from "zod";
|
|
382
|
+
var zSdJwtVcFormatIdentifier = z6.literal("vc+sd-jwt");
|
|
383
|
+
var zSdJwtVcCredentialIssuerMetadataDraft14 = z6.object({
|
|
384
|
+
vct: z6.string(),
|
|
300
385
|
format: zSdJwtVcFormatIdentifier,
|
|
301
|
-
claims:
|
|
302
|
-
order:
|
|
386
|
+
claims: z6.optional(zCredentialConfigurationSupportedClaimsDraft14),
|
|
387
|
+
order: z6.optional(z6.array(z6.string()))
|
|
303
388
|
});
|
|
304
|
-
var zSdJwtVcCredentialRequestFormatDraft14 =
|
|
389
|
+
var zSdJwtVcCredentialRequestFormatDraft14 = z6.object({
|
|
305
390
|
format: zSdJwtVcFormatIdentifier,
|
|
306
|
-
vct:
|
|
307
|
-
claims:
|
|
391
|
+
vct: z6.string(),
|
|
392
|
+
claims: z6.optional(zCredentialConfigurationSupportedClaimsDraft14)
|
|
308
393
|
});
|
|
309
394
|
|
|
310
395
|
// src/formats/credential/sd-jwt-dc/z-sd-jwt-dc.ts
|
|
311
|
-
import
|
|
312
|
-
var zSdJwtDcFormatIdentifier =
|
|
313
|
-
var zSdJwtDcCredentialIssuerMetadata =
|
|
314
|
-
vct:
|
|
396
|
+
import z7 from "zod";
|
|
397
|
+
var zSdJwtDcFormatIdentifier = z7.literal("dc+sd-jwt");
|
|
398
|
+
var zSdJwtDcCredentialIssuerMetadata = z7.object({
|
|
399
|
+
vct: z7.string(),
|
|
315
400
|
format: zSdJwtDcFormatIdentifier,
|
|
316
|
-
|
|
401
|
+
credential_metadata: zCredentialConfigurationSupportedCommonCredentialMetadata.extend({
|
|
402
|
+
claims: z7.array(zIssuerMetadataClaimsDescription).optional()
|
|
403
|
+
}).optional()
|
|
404
|
+
});
|
|
405
|
+
var zSdJwtDcCredentialIssuerMetadataDraft15 = z7.object({
|
|
406
|
+
vct: z7.string(),
|
|
407
|
+
format: zSdJwtDcFormatIdentifier,
|
|
408
|
+
claims: z7.array(zIssuerMetadataClaimsDescription).optional()
|
|
317
409
|
});
|
|
318
410
|
|
|
319
411
|
// src/formats/credential/w3c-vc/z-w3c-ldp-vc.ts
|
|
320
|
-
import
|
|
412
|
+
import z9 from "zod";
|
|
321
413
|
|
|
322
414
|
// src/formats/credential/w3c-vc/z-w3c-vc-common.ts
|
|
323
|
-
import
|
|
324
|
-
var zCredentialSubjectLeafTypeDraft14 =
|
|
325
|
-
mandatory:
|
|
326
|
-
value_type:
|
|
327
|
-
display:
|
|
328
|
-
|
|
329
|
-
name:
|
|
330
|
-
locale:
|
|
415
|
+
import z8 from "zod";
|
|
416
|
+
var zCredentialSubjectLeafTypeDraft14 = z8.object({
|
|
417
|
+
mandatory: z8.boolean().optional(),
|
|
418
|
+
value_type: z8.string().optional(),
|
|
419
|
+
display: z8.array(
|
|
420
|
+
z8.object({
|
|
421
|
+
name: z8.string().optional(),
|
|
422
|
+
locale: z8.string().optional()
|
|
331
423
|
}).passthrough()
|
|
332
424
|
).optional()
|
|
333
425
|
}).passthrough();
|
|
334
|
-
var zClaimValueSchemaDraft14 =
|
|
335
|
-
|
|
336
|
-
|
|
426
|
+
var zClaimValueSchemaDraft14 = z8.union([
|
|
427
|
+
z8.array(z8.any()),
|
|
428
|
+
z8.record(z8.string(), z8.any()),
|
|
337
429
|
zCredentialSubjectLeafTypeDraft14
|
|
338
430
|
]);
|
|
339
|
-
var zW3cVcCredentialSubjectDraft14 =
|
|
340
|
-
var zW3cVcJsonLdCredentialDefinition =
|
|
341
|
-
"@context":
|
|
342
|
-
type:
|
|
431
|
+
var zW3cVcCredentialSubjectDraft14 = z8.record(z8.string(), zClaimValueSchemaDraft14);
|
|
432
|
+
var zW3cVcJsonLdCredentialDefinition = z8.object({
|
|
433
|
+
"@context": z8.array(z8.string()),
|
|
434
|
+
type: z8.array(z8.string())
|
|
343
435
|
}).passthrough();
|
|
344
436
|
var zW3cVcJsonLdCredentialDefinitionDraft14 = zW3cVcJsonLdCredentialDefinition.extend({
|
|
345
437
|
credentialSubject: zW3cVcCredentialSubjectDraft14.optional()
|
|
346
438
|
});
|
|
347
439
|
|
|
348
440
|
// src/formats/credential/w3c-vc/z-w3c-ldp-vc.ts
|
|
349
|
-
var zLdpVcFormatIdentifier =
|
|
350
|
-
var zLdpVcCredentialIssuerMetadata =
|
|
441
|
+
var zLdpVcFormatIdentifier = z9.literal("ldp_vc");
|
|
442
|
+
var zLdpVcCredentialIssuerMetadata = z9.object({
|
|
443
|
+
format: zLdpVcFormatIdentifier,
|
|
444
|
+
credential_definition: zW3cVcJsonLdCredentialDefinition,
|
|
445
|
+
credential_metadata: zCredentialConfigurationSupportedCommonCredentialMetadata.extend({
|
|
446
|
+
claims: zIssuerMetadataClaimsDescription.optional()
|
|
447
|
+
}).optional()
|
|
448
|
+
});
|
|
449
|
+
var zLdpVcCredentialIssuerMetadataDraft15 = z9.object({
|
|
351
450
|
format: zLdpVcFormatIdentifier,
|
|
352
451
|
credential_definition: zW3cVcJsonLdCredentialDefinition,
|
|
353
452
|
claims: zIssuerMetadataClaimsDescription.optional()
|
|
354
453
|
});
|
|
355
|
-
var zLdpVcCredentialIssuerMetadataDraft14 =
|
|
454
|
+
var zLdpVcCredentialIssuerMetadataDraft14 = z9.object({
|
|
356
455
|
format: zLdpVcFormatIdentifier,
|
|
357
456
|
credential_definition: zW3cVcJsonLdCredentialDefinitionDraft14,
|
|
358
|
-
order:
|
|
457
|
+
order: z9.array(z9.string()).optional()
|
|
359
458
|
});
|
|
360
|
-
var zLdpVcCredentialIssuerMetadataDraft11 =
|
|
361
|
-
order:
|
|
459
|
+
var zLdpVcCredentialIssuerMetadataDraft11 = z9.object({
|
|
460
|
+
order: z9.array(z9.string()).optional(),
|
|
362
461
|
format: zLdpVcFormatIdentifier,
|
|
363
462
|
// Credential definition was spread on top level instead of a separatey property in v11
|
|
364
463
|
// As well as using types instead of type
|
|
365
|
-
"@context":
|
|
366
|
-
types:
|
|
464
|
+
"@context": z9.array(z9.string()),
|
|
465
|
+
types: z9.array(z9.string()),
|
|
367
466
|
credentialSubject: zW3cVcCredentialSubjectDraft14.optional()
|
|
368
467
|
}).passthrough();
|
|
369
468
|
var zLdpVcCredentialIssuerMetadataDraft11To14 = zLdpVcCredentialIssuerMetadataDraft11.transform(
|
|
@@ -382,16 +481,16 @@ var zLdpVcCredentialIssuerMetadataDraft14To11 = zLdpVcCredentialIssuerMetadataDr
|
|
|
382
481
|
...credentialDefinition,
|
|
383
482
|
types: type
|
|
384
483
|
})).pipe(zLdpVcCredentialIssuerMetadataDraft11);
|
|
385
|
-
var zLdpVcCredentialRequestFormatDraft14 =
|
|
484
|
+
var zLdpVcCredentialRequestFormatDraft14 = z9.object({
|
|
386
485
|
format: zLdpVcFormatIdentifier,
|
|
387
486
|
credential_definition: zW3cVcJsonLdCredentialDefinitionDraft14
|
|
388
487
|
});
|
|
389
|
-
var zLdpVcCredentialRequestDraft11 =
|
|
488
|
+
var zLdpVcCredentialRequestDraft11 = z9.object({
|
|
390
489
|
format: zLdpVcFormatIdentifier,
|
|
391
|
-
credential_definition:
|
|
392
|
-
"@context":
|
|
490
|
+
credential_definition: z9.object({
|
|
491
|
+
"@context": z9.array(z9.string()),
|
|
393
492
|
// credential_definition was using types instead of type in v11
|
|
394
|
-
types:
|
|
493
|
+
types: z9.array(z9.string()),
|
|
395
494
|
credentialSubject: zW3cVcCredentialSubjectDraft14.optional()
|
|
396
495
|
})
|
|
397
496
|
}).passthrough();
|
|
@@ -413,25 +512,32 @@ var zLdpVcCredentialRequestDraft14To11 = zLdpVcCredentialRequestFormatDraft14.pa
|
|
|
413
512
|
})).pipe(zLdpVcCredentialRequestDraft11);
|
|
414
513
|
|
|
415
514
|
// src/formats/credential/w3c-vc/z-w3c-jwt-vc-json-ld.ts
|
|
416
|
-
import
|
|
417
|
-
var zJwtVcJsonLdFormatIdentifier =
|
|
418
|
-
var zJwtVcJsonLdCredentialIssuerMetadata =
|
|
515
|
+
import z10 from "zod";
|
|
516
|
+
var zJwtVcJsonLdFormatIdentifier = z10.literal("jwt_vc_json-ld");
|
|
517
|
+
var zJwtVcJsonLdCredentialIssuerMetadata = z10.object({
|
|
518
|
+
format: zJwtVcJsonLdFormatIdentifier,
|
|
519
|
+
credential_definition: zW3cVcJsonLdCredentialDefinition,
|
|
520
|
+
credential_metadata: zCredentialConfigurationSupportedCommonCredentialMetadata.extend({
|
|
521
|
+
claims: zIssuerMetadataClaimsDescription.optional()
|
|
522
|
+
}).optional()
|
|
523
|
+
});
|
|
524
|
+
var zJwtVcJsonLdCredentialIssuerMetadataDraft15 = z10.object({
|
|
419
525
|
format: zJwtVcJsonLdFormatIdentifier,
|
|
420
526
|
credential_definition: zW3cVcJsonLdCredentialDefinition,
|
|
421
527
|
claims: zIssuerMetadataClaimsDescription.optional()
|
|
422
528
|
});
|
|
423
|
-
var zJwtVcJsonLdCredentialIssuerMetadataDraft14 =
|
|
529
|
+
var zJwtVcJsonLdCredentialIssuerMetadataDraft14 = z10.object({
|
|
424
530
|
format: zJwtVcJsonLdFormatIdentifier,
|
|
425
531
|
credential_definition: zW3cVcJsonLdCredentialDefinitionDraft14,
|
|
426
|
-
order:
|
|
532
|
+
order: z10.optional(z10.array(z10.string()))
|
|
427
533
|
});
|
|
428
|
-
var zJwtVcJsonLdCredentialIssuerMetadataDraft11 =
|
|
429
|
-
order:
|
|
534
|
+
var zJwtVcJsonLdCredentialIssuerMetadataDraft11 = z10.object({
|
|
535
|
+
order: z10.array(z10.string()).optional(),
|
|
430
536
|
format: zJwtVcJsonLdFormatIdentifier,
|
|
431
537
|
// Credential definition was spread on top level instead of a separatey property in v11
|
|
432
538
|
// As well as using types instead of type
|
|
433
|
-
"@context":
|
|
434
|
-
types:
|
|
539
|
+
"@context": z10.array(z10.string()),
|
|
540
|
+
types: z10.array(z10.string()),
|
|
435
541
|
credentialSubject: zW3cVcCredentialSubjectDraft14.optional()
|
|
436
542
|
}).passthrough();
|
|
437
543
|
var zJwtVcJsonLdCredentialIssuerMetadataDraft11To14 = zJwtVcJsonLdCredentialIssuerMetadataDraft11.transform(
|
|
@@ -450,17 +556,17 @@ var zJwtVcJsonLdCredentialIssuerMetadataDraft14To11 = zJwtVcJsonLdCredentialIssu
|
|
|
450
556
|
...credentialDefinition,
|
|
451
557
|
types: type
|
|
452
558
|
})).pipe(zJwtVcJsonLdCredentialIssuerMetadataDraft11);
|
|
453
|
-
var zJwtVcJsonLdCredentialRequestFormatDraft14 =
|
|
559
|
+
var zJwtVcJsonLdCredentialRequestFormatDraft14 = z10.object({
|
|
454
560
|
format: zJwtVcJsonLdFormatIdentifier,
|
|
455
561
|
credential_definition: zW3cVcJsonLdCredentialDefinition
|
|
456
562
|
});
|
|
457
|
-
var zJwtVcJsonLdCredentialRequestDraft11 =
|
|
563
|
+
var zJwtVcJsonLdCredentialRequestDraft11 = z10.object({
|
|
458
564
|
format: zJwtVcJsonLdFormatIdentifier,
|
|
459
|
-
credential_definition:
|
|
460
|
-
"@context":
|
|
565
|
+
credential_definition: z10.object({
|
|
566
|
+
"@context": z10.array(z10.string()),
|
|
461
567
|
// credential_definition was using types instead of type in v11
|
|
462
|
-
types:
|
|
463
|
-
credentialSubject:
|
|
568
|
+
types: z10.array(z10.string()),
|
|
569
|
+
credentialSubject: z10.optional(zW3cVcCredentialSubjectDraft14)
|
|
464
570
|
}).passthrough()
|
|
465
571
|
}).passthrough();
|
|
466
572
|
var zJwtVcJsonLdCredentialRequestDraft11To14 = zJwtVcJsonLdCredentialRequestDraft11.transform(
|
|
@@ -481,30 +587,37 @@ var zJwtVcJsonLdCredentialRequestDraft14To11 = zJwtVcJsonLdCredentialRequestForm
|
|
|
481
587
|
})).pipe(zJwtVcJsonLdCredentialRequestDraft11);
|
|
482
588
|
|
|
483
589
|
// src/formats/credential/w3c-vc/z-w3c-jwt-vc-json.ts
|
|
484
|
-
import
|
|
485
|
-
var zJwtVcJsonFormatIdentifier =
|
|
486
|
-
var zJwtVcJsonCredentialDefinition =
|
|
487
|
-
type:
|
|
590
|
+
import z11 from "zod";
|
|
591
|
+
var zJwtVcJsonFormatIdentifier = z11.literal("jwt_vc_json");
|
|
592
|
+
var zJwtVcJsonCredentialDefinition = z11.object({
|
|
593
|
+
type: z11.array(z11.string())
|
|
488
594
|
}).passthrough();
|
|
489
595
|
var zJwtVcJsonCredentialDefinitionDraft14 = zJwtVcJsonCredentialDefinition.extend({
|
|
490
596
|
credentialSubject: zW3cVcCredentialSubjectDraft14.optional()
|
|
491
597
|
});
|
|
492
|
-
var zJwtVcJsonCredentialIssuerMetadata =
|
|
598
|
+
var zJwtVcJsonCredentialIssuerMetadata = z11.object({
|
|
599
|
+
format: zJwtVcJsonFormatIdentifier,
|
|
600
|
+
credential_definition: zJwtVcJsonCredentialDefinition,
|
|
601
|
+
credential_metadata: zCredentialConfigurationSupportedCommonCredentialMetadata.extend({
|
|
602
|
+
claims: zIssuerMetadataClaimsDescription.optional()
|
|
603
|
+
}).optional()
|
|
604
|
+
});
|
|
605
|
+
var zJwtVcJsonCredentialIssuerMetadataDraft15 = z11.object({
|
|
493
606
|
format: zJwtVcJsonFormatIdentifier,
|
|
494
607
|
credential_definition: zJwtVcJsonCredentialDefinition,
|
|
495
608
|
claims: zIssuerMetadataClaimsDescription.optional()
|
|
496
609
|
});
|
|
497
|
-
var zJwtVcJsonCredentialIssuerMetadataDraft14 =
|
|
610
|
+
var zJwtVcJsonCredentialIssuerMetadataDraft14 = z11.object({
|
|
498
611
|
format: zJwtVcJsonFormatIdentifier,
|
|
499
612
|
credential_definition: zJwtVcJsonCredentialDefinitionDraft14,
|
|
500
|
-
order:
|
|
613
|
+
order: z11.array(z11.string()).optional()
|
|
501
614
|
});
|
|
502
|
-
var zJwtVcJsonCredentialIssuerMetadataDraft11 =
|
|
615
|
+
var zJwtVcJsonCredentialIssuerMetadataDraft11 = z11.object({
|
|
503
616
|
format: zJwtVcJsonFormatIdentifier,
|
|
504
|
-
order:
|
|
617
|
+
order: z11.array(z11.string()).optional(),
|
|
505
618
|
// Credential definition was spread on top level instead of a separatey property in v11
|
|
506
619
|
// As well as using types instead of type
|
|
507
|
-
types:
|
|
620
|
+
types: z11.array(z11.string()),
|
|
508
621
|
credentialSubject: zW3cVcCredentialSubjectDraft14.optional()
|
|
509
622
|
}).passthrough();
|
|
510
623
|
var zJwtVcJsonCredentialIssuerMetadataDraft11To14 = zJwtVcJsonCredentialIssuerMetadataDraft11.transform(
|
|
@@ -522,16 +635,16 @@ var zJwtVcJsonCredentialIssuerMetadataDraft14To11 = zJwtVcJsonCredentialIssuerMe
|
|
|
522
635
|
types: type,
|
|
523
636
|
...credentialDefinition
|
|
524
637
|
})).pipe(zJwtVcJsonCredentialIssuerMetadataDraft11);
|
|
525
|
-
var zJwtVcJsonCredentialRequestFormatDraft14 =
|
|
638
|
+
var zJwtVcJsonCredentialRequestFormatDraft14 = z11.object({
|
|
526
639
|
format: zJwtVcJsonFormatIdentifier,
|
|
527
640
|
credential_definition: zJwtVcJsonCredentialDefinition
|
|
528
641
|
});
|
|
529
|
-
var zJwtVcJsonCredentialRequestDraft11 =
|
|
642
|
+
var zJwtVcJsonCredentialRequestDraft11 = z11.object({
|
|
530
643
|
format: zJwtVcJsonFormatIdentifier,
|
|
531
644
|
// Credential definition was spread on top level instead of a separatey property in v11
|
|
532
645
|
// As well as using types instead of type
|
|
533
|
-
types:
|
|
534
|
-
credentialSubject:
|
|
646
|
+
types: z11.array(z11.string()),
|
|
647
|
+
credentialSubject: z11.optional(zW3cVcCredentialSubjectDraft14)
|
|
535
648
|
}).passthrough();
|
|
536
649
|
var zJwtVcJsonCredentialRequestDraft11To14 = zJwtVcJsonCredentialRequestDraft11.transform(
|
|
537
650
|
({ types, credentialSubject, ...rest }) => {
|
|
@@ -551,80 +664,6 @@ var zJwtVcJsonCredentialRequestDraft14To11 = zJwtVcJsonCredentialRequestFormatDr
|
|
|
551
664
|
...credentialDefinition
|
|
552
665
|
})).pipe(zJwtVcJsonCredentialRequestDraft11);
|
|
553
666
|
|
|
554
|
-
// src/metadata/credential-issuer/z-credential-configuration-supported-common.ts
|
|
555
|
-
import z11 from "zod";
|
|
556
|
-
|
|
557
|
-
// src/key-attestation/z-key-attestation.ts
|
|
558
|
-
import { zJwk, zJwtHeader, zJwtPayload } from "@openid4vc/oauth2";
|
|
559
|
-
import { zInteger } from "@openid4vc/utils";
|
|
560
|
-
import z10 from "zod";
|
|
561
|
-
var zKeyAttestationJwtHeader = z10.object({
|
|
562
|
-
...zJwtHeader.shape,
|
|
563
|
-
typ: z10.literal("keyattestation+jwt").or(
|
|
564
|
-
// Draft 16
|
|
565
|
-
z10.literal("key-attestation+jwt")
|
|
566
|
-
)
|
|
567
|
-
}).passthrough().refine(({ kid, jwk }) => jwk === void 0 || kid === void 0, {
|
|
568
|
-
message: `Both 'jwk' and 'kid' are defined. Only one is allowed`
|
|
569
|
-
}).refine(({ trust_chain, kid }) => !trust_chain || !kid, {
|
|
570
|
-
message: `When 'trust_chain' is provided, 'kid' is required`
|
|
571
|
-
});
|
|
572
|
-
var zIso18045 = z10.enum(["iso_18045_high", "iso_18045_moderate", "iso_18045_enhanced-basic", "iso_18045_basic"]);
|
|
573
|
-
var zIso18045OrStringArray = z10.array(z10.union([zIso18045, z10.string()]));
|
|
574
|
-
var zKeyAttestationJwtPayload = z10.object({
|
|
575
|
-
...zJwtPayload.shape,
|
|
576
|
-
iat: zInteger,
|
|
577
|
-
attested_keys: z10.array(zJwk),
|
|
578
|
-
key_storage: z10.optional(zIso18045OrStringArray),
|
|
579
|
-
user_authentication: z10.optional(zIso18045OrStringArray),
|
|
580
|
-
certification: z10.optional(z10.string().url())
|
|
581
|
-
}).passthrough();
|
|
582
|
-
var zKeyAttestationJwtPayloadForUse = (use) => z10.object({
|
|
583
|
-
...zKeyAttestationJwtPayload.shape,
|
|
584
|
-
// REQUIRED when used as proof_type.attesation directly
|
|
585
|
-
nonce: use === "proof_type.attestation" ? z10.string({
|
|
586
|
-
message: `Nonce must be defined when key attestation is used as 'proof_type.attestation' directly`
|
|
587
|
-
}) : z10.optional(z10.string()),
|
|
588
|
-
// REQUIRED when used within header of proof_type.jwt
|
|
589
|
-
exp: use === "proof_type.jwt" ? zInteger : z10.optional(zInteger)
|
|
590
|
-
}).passthrough();
|
|
591
|
-
|
|
592
|
-
// src/metadata/credential-issuer/z-credential-configuration-supported-common.ts
|
|
593
|
-
var zCredentialConfigurationSupportedCommon = z11.object({
|
|
594
|
-
format: z11.string(),
|
|
595
|
-
scope: z11.string().optional(),
|
|
596
|
-
cryptographic_binding_methods_supported: z11.array(z11.string()).optional(),
|
|
597
|
-
credential_signing_alg_values_supported: z11.array(z11.string()).optional(),
|
|
598
|
-
proof_types_supported: z11.record(
|
|
599
|
-
z11.union([z11.literal("jwt"), z11.literal("attestation"), z11.string()]),
|
|
600
|
-
z11.object({
|
|
601
|
-
proof_signing_alg_values_supported: z11.array(z11.string()),
|
|
602
|
-
key_attestations_required: z11.object({
|
|
603
|
-
key_storage: zIso18045OrStringArray.optional(),
|
|
604
|
-
user_authentication: zIso18045OrStringArray.optional()
|
|
605
|
-
}).passthrough().optional()
|
|
606
|
-
})
|
|
607
|
-
).optional(),
|
|
608
|
-
display: z11.array(
|
|
609
|
-
z11.object({
|
|
610
|
-
name: z11.string(),
|
|
611
|
-
locale: z11.string().optional(),
|
|
612
|
-
logo: z11.object({
|
|
613
|
-
// FIXME: make required again, but need to support draft 11 first
|
|
614
|
-
uri: z11.string().optional(),
|
|
615
|
-
alt_text: z11.string().optional()
|
|
616
|
-
}).passthrough().optional(),
|
|
617
|
-
description: z11.string().optional(),
|
|
618
|
-
background_color: z11.string().optional(),
|
|
619
|
-
background_image: z11.object({
|
|
620
|
-
// TODO: should be required, but paradym's metadata is wrong here.
|
|
621
|
-
uri: z11.string().optional()
|
|
622
|
-
}).passthrough().optional(),
|
|
623
|
-
text_color: z11.string().optional()
|
|
624
|
-
}).passthrough()
|
|
625
|
-
).optional()
|
|
626
|
-
}).passthrough();
|
|
627
|
-
|
|
628
667
|
// src/metadata/credential-issuer/z-credential-issuer-metadata.ts
|
|
629
668
|
var allCredentialIssuerMetadataFormats = [
|
|
630
669
|
zSdJwtDcCredentialIssuerMetadata,
|
|
@@ -632,6 +671,11 @@ var allCredentialIssuerMetadataFormats = [
|
|
|
632
671
|
zJwtVcJsonLdCredentialIssuerMetadata,
|
|
633
672
|
zLdpVcCredentialIssuerMetadata,
|
|
634
673
|
zJwtVcJsonCredentialIssuerMetadata,
|
|
674
|
+
zSdJwtDcCredentialIssuerMetadataDraft15,
|
|
675
|
+
zMsoMdocCredentialIssuerMetadataDraft15,
|
|
676
|
+
zJwtVcJsonLdCredentialIssuerMetadataDraft15,
|
|
677
|
+
zLdpVcCredentialIssuerMetadataDraft15,
|
|
678
|
+
zJwtVcJsonCredentialIssuerMetadataDraft15,
|
|
635
679
|
zMsoMdocCredentialIssuerMetadataDraft14,
|
|
636
680
|
zSdJwtVcCredentialIssuerMetadataDraft14,
|
|
637
681
|
zJwtVcJsonLdCredentialIssuerMetadataDraft14,
|
|
@@ -676,7 +720,7 @@ var zCredentialIssuerMetadataDisplayEntry = z12.object({
|
|
|
676
720
|
alt_text: z12.string().optional()
|
|
677
721
|
}).passthrough().optional()
|
|
678
722
|
}).passthrough();
|
|
679
|
-
var
|
|
723
|
+
var zCredentialIssuerMetadataDraft14Draft15Draft16 = z12.object({
|
|
680
724
|
credential_issuer: zHttpsUrl2,
|
|
681
725
|
authorization_servers: z12.array(zHttpsUrl2).optional(),
|
|
682
726
|
credential_endpoint: zHttpsUrl2,
|
|
@@ -749,7 +793,13 @@ var zCredentialConfigurationSupportedDraft11To14 = z12.object({
|
|
|
749
793
|
}
|
|
750
794
|
return z12.NEVER;
|
|
751
795
|
}).pipe(zCredentialConfigurationSupportedWithFormats);
|
|
752
|
-
var
|
|
796
|
+
var zCredentialConfigurationSupportedDraft16To15 = zCredentialConfigurationSupportedWithFormats.transform(
|
|
797
|
+
({ credential_metadata, ...rest }) => ({
|
|
798
|
+
...credential_metadata,
|
|
799
|
+
...rest
|
|
800
|
+
})
|
|
801
|
+
);
|
|
802
|
+
var zCredentialConfigurationSupportedDraft14To11 = zCredentialConfigurationSupportedDraft16To15.and(
|
|
753
803
|
z12.object({
|
|
754
804
|
id: z12.string()
|
|
755
805
|
}).passthrough()
|
|
@@ -776,7 +826,7 @@ var zCredentialConfigurationSupportedDraft14To11 = zCredentialConfigurationSuppo
|
|
|
776
826
|
zJwtVcJsonCredentialIssuerMetadataDraft14To11,
|
|
777
827
|
zJwtVcJsonLdCredentialIssuerMetadataDraft14To11,
|
|
778
828
|
// To handle unrecognized formats and not error immediately we allow the common format as well
|
|
779
|
-
// but they can't use any of the
|
|
829
|
+
// but they can't use any of the format identifiers that have a specific transformation. This way if a format is
|
|
780
830
|
// has a transformation it NEEDS to use the format specific transformation, and otherwise we fall back to the common validation
|
|
781
831
|
z12.object({
|
|
782
832
|
format: z12.string().refine(
|
|
@@ -789,7 +839,7 @@ var zCredentialConfigurationSupportedDraft14To11 = zCredentialConfigurationSuppo
|
|
|
789
839
|
}).passthrough()
|
|
790
840
|
])
|
|
791
841
|
);
|
|
792
|
-
var
|
|
842
|
+
var zCredentialIssuerMetadataDraft11To16 = z12.object({
|
|
793
843
|
authorization_server: z12.string().optional(),
|
|
794
844
|
credentials_supported: z12.array(
|
|
795
845
|
z12.object({
|
|
@@ -807,11 +857,11 @@ var zCredentialIssuerMetadataDraft11To14 = z12.object({
|
|
|
807
857
|
};
|
|
808
858
|
}).pipe(
|
|
809
859
|
z12.object({
|
|
810
|
-
// Update from v11
|
|
860
|
+
// Update from v11 structure to v14 structure
|
|
811
861
|
credential_configurations_supported: z12.record(z12.string(), zCredentialConfigurationSupportedDraft11To14)
|
|
812
862
|
}).passthrough()
|
|
813
|
-
).pipe(
|
|
814
|
-
var zCredentialIssuerMetadataWithDraft11 =
|
|
863
|
+
).pipe(zCredentialIssuerMetadataDraft14Draft15Draft16);
|
|
864
|
+
var zCredentialIssuerMetadataWithDraft11 = zCredentialIssuerMetadataDraft14Draft15Draft16.transform((issuerMetadata) => ({
|
|
815
865
|
...issuerMetadata,
|
|
816
866
|
...issuerMetadata.authorization_servers ? { authorization_server: issuerMetadata.authorization_servers[0] } : {},
|
|
817
867
|
credentials_supported: Object.entries(issuerMetadata.credential_configurations_supported).map(([id, value]) => ({
|
|
@@ -819,37 +869,39 @@ var zCredentialIssuerMetadataWithDraft11 = zCredentialIssuerMetadataDraft14Draft
|
|
|
819
869
|
id
|
|
820
870
|
}))
|
|
821
871
|
})).pipe(
|
|
822
|
-
|
|
872
|
+
zCredentialIssuerMetadataDraft14Draft15Draft16.extend({
|
|
823
873
|
credentials_supported: z12.array(zCredentialConfigurationSupportedDraft14To11)
|
|
824
874
|
})
|
|
825
875
|
);
|
|
826
876
|
var zCredentialIssuerMetadata = z12.union([
|
|
827
|
-
// First prioritize draft 15/14 (and 13)
|
|
828
|
-
|
|
829
|
-
// Then try parsing draft 11 and transform into draft
|
|
830
|
-
|
|
877
|
+
// First prioritize draft 16/15/14 (and 13)
|
|
878
|
+
zCredentialIssuerMetadataDraft14Draft15Draft16,
|
|
879
|
+
// Then try parsing draft 11 and transform into draft 16
|
|
880
|
+
zCredentialIssuerMetadataDraft11To16
|
|
831
881
|
]);
|
|
832
882
|
var zCredentialIssuerMetadataWithDraftVersion = z12.union([
|
|
833
|
-
|
|
834
|
-
const
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
)
|
|
883
|
+
zCredentialIssuerMetadataDraft14Draft15Draft16.transform((credentialIssuerMetadata) => {
|
|
884
|
+
const credentialConfigurations = Object.values(credentialIssuerMetadata.credential_configurations_supported);
|
|
885
|
+
const isDraft15 = credentialConfigurations.some((configuration) => {
|
|
886
|
+
const knownConfiguration = configuration;
|
|
887
|
+
if (knownConfiguration.format === zSdJwtDcFormatIdentifier.value) return true;
|
|
888
|
+
if (Array.isArray(knownConfiguration.claims)) return true;
|
|
889
|
+
if (Object.values(knownConfiguration.proof_types_supported ?? {}).some(
|
|
890
|
+
(proofType) => proofType.key_attestations_required !== void 0
|
|
891
|
+
))
|
|
892
|
+
return true;
|
|
893
|
+
return false;
|
|
894
|
+
});
|
|
895
|
+
const isDraft16 = credentialConfigurations.some((configuration) => {
|
|
896
|
+
return configuration.credential_metadata;
|
|
897
|
+
});
|
|
846
898
|
return {
|
|
847
899
|
credentialIssuerMetadata,
|
|
848
|
-
originalDraftVersion: isDraft15 ? "Draft15" /* Draft15 */ : "Draft14" /* Draft14 */
|
|
900
|
+
originalDraftVersion: isDraft16 ? "Draft16" /* Draft16 */ : isDraft15 ? "Draft15" /* Draft15 */ : "Draft14" /* Draft14 */
|
|
849
901
|
};
|
|
850
902
|
}),
|
|
851
903
|
// Then try parsing draft 11 and transform into draft 14
|
|
852
|
-
|
|
904
|
+
zCredentialIssuerMetadataDraft11To16.transform((credentialIssuerMetadata) => ({
|
|
853
905
|
credentialIssuerMetadata,
|
|
854
906
|
originalDraftVersion: "Draft11" /* Draft11 */
|
|
855
907
|
}))
|
|
@@ -1110,6 +1162,7 @@ import {
|
|
|
1110
1162
|
import { ContentType as ContentType2, isResponseContentType, parseWithErrorHandling as parseWithErrorHandling3 } from "@openid4vc/utils";
|
|
1111
1163
|
|
|
1112
1164
|
// src/credential-request/z-credential-request.ts
|
|
1165
|
+
import { zJwk as zJwk3 } from "@openid4vc/oauth2";
|
|
1113
1166
|
import z16 from "zod";
|
|
1114
1167
|
|
|
1115
1168
|
// src/credential-request/z-credential-request-common.ts
|
|
@@ -1210,7 +1263,7 @@ var zCredentialRequestFormat = z16.object({
|
|
|
1210
1263
|
credential_identifier: z16.never({ message: "'credential_identifier' cannot be defined when 'format' is set." }).optional(),
|
|
1211
1264
|
credential_configuration_id: z16.never({ message: "'credential_configuration_id' cannot be defined when 'format' is set." }).optional()
|
|
1212
1265
|
}).passthrough();
|
|
1213
|
-
var
|
|
1266
|
+
var zCredentialRequestDraft14WithFormat = zCredentialRequestCommon.and(zCredentialRequestFormat).transform((data, ctx) => {
|
|
1214
1267
|
if (!allCredentialRequestFormatIdentifiers.includes(
|
|
1215
1268
|
data.format
|
|
1216
1269
|
))
|
|
@@ -1229,7 +1282,7 @@ var zCredentialRequestDraft15 = z16.union([
|
|
|
1229
1282
|
zCredentialRequestCommon.and(zCredentialRequestCredentialConfigurationId)
|
|
1230
1283
|
]);
|
|
1231
1284
|
var zCredentialRequestDraft14 = z16.union([
|
|
1232
|
-
|
|
1285
|
+
zCredentialRequestDraft14WithFormat,
|
|
1233
1286
|
zCredentialRequestCommon.and(zAuthorizationDetailsCredentialRequest)
|
|
1234
1287
|
]);
|
|
1235
1288
|
var zCredentialRequestDraft11To14 = zCredentialRequestCommon.and(zCredentialRequestFormat).transform((data, ctx) => {
|
|
@@ -1270,6 +1323,14 @@ var zCredentialRequest = z16.union([
|
|
|
1270
1323
|
zCredentialRequestDraft14,
|
|
1271
1324
|
zCredentialRequestDraft11To14
|
|
1272
1325
|
]);
|
|
1326
|
+
var zDeferredCredentialRequest = z16.object({
|
|
1327
|
+
transaction_id: z16.string().nonempty(),
|
|
1328
|
+
credential_response_encryption: z16.object({
|
|
1329
|
+
jwk: zJwk3,
|
|
1330
|
+
alg: z16.string(),
|
|
1331
|
+
enc: z16.string()
|
|
1332
|
+
}).passthrough().optional()
|
|
1333
|
+
});
|
|
1273
1334
|
|
|
1274
1335
|
// src/credential-request/z-credential-response.ts
|
|
1275
1336
|
import z18 from "zod";
|
|
@@ -1294,11 +1355,14 @@ var Oauth2ErrorCodes = /* @__PURE__ */ ((Oauth2ErrorCodes4) => {
|
|
|
1294
1355
|
Oauth2ErrorCodes4["InsufficientAuthorization"] = "insufficient_authorization";
|
|
1295
1356
|
Oauth2ErrorCodes4["InvalidCredentialRequest"] = "invalid_credential_request";
|
|
1296
1357
|
Oauth2ErrorCodes4["CredentialRequestDenied"] = "credential_request_denied";
|
|
1297
|
-
Oauth2ErrorCodes4["UnsupportedCredentialType"] = "unsupported_credential_type";
|
|
1298
|
-
Oauth2ErrorCodes4["UnsupportedCredentialFormat"] = "unsupported_credential_format";
|
|
1299
1358
|
Oauth2ErrorCodes4["InvalidProof"] = "invalid_proof";
|
|
1300
1359
|
Oauth2ErrorCodes4["InvalidNonce"] = "invalid_nonce";
|
|
1301
1360
|
Oauth2ErrorCodes4["InvalidEncryptionParameters"] = "invalid_encryption_parameters";
|
|
1361
|
+
Oauth2ErrorCodes4["UnknownCredentialConfiguration"] = "unknown_credential_configuration";
|
|
1362
|
+
Oauth2ErrorCodes4["UnknownCredentialIdentifier"] = "unknown_credential_identifier";
|
|
1363
|
+
Oauth2ErrorCodes4["InvalidTransactionId"] = "invalid_transaction_id";
|
|
1364
|
+
Oauth2ErrorCodes4["UnsupportedCredentialType"] = "unsupported_credential_type";
|
|
1365
|
+
Oauth2ErrorCodes4["UnsupportedCredentialFormat"] = "unsupported_credential_format";
|
|
1302
1366
|
Oauth2ErrorCodes4["InvalidRequestUri"] = "invalid_request_uri";
|
|
1303
1367
|
Oauth2ErrorCodes4["InvalidRequestObject"] = "invalid_request_object";
|
|
1304
1368
|
Oauth2ErrorCodes4["RequestNotSupported"] = "request_not_supported";
|
|
@@ -1320,33 +1384,57 @@ var zOauth2ErrorResponse = z17.object({
|
|
|
1320
1384
|
|
|
1321
1385
|
// src/credential-request/z-credential-response.ts
|
|
1322
1386
|
var zCredentialEncoding = z18.union([z18.string(), z18.record(z18.string(), z18.any())]);
|
|
1323
|
-
var
|
|
1324
|
-
credential: z18.optional(zCredentialEncoding),
|
|
1387
|
+
var zBaseCredentialResponse = z18.object({
|
|
1325
1388
|
credentials: z18.optional(z18.array(zCredentialEncoding)),
|
|
1389
|
+
interval: z18.number().int().positive().optional(),
|
|
1390
|
+
notification_id: z18.string().optional()
|
|
1391
|
+
}).passthrough();
|
|
1392
|
+
var zCredentialResponse = zBaseCredentialResponse.extend({
|
|
1393
|
+
credential: z18.optional(zCredentialEncoding),
|
|
1326
1394
|
transaction_id: z18.string().optional(),
|
|
1327
1395
|
c_nonce: z18.string().optional(),
|
|
1328
|
-
c_nonce_expires_in: z18.number().int().optional()
|
|
1329
|
-
|
|
1330
|
-
}
|
|
1331
|
-
(
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
message: `Exactly one of 'credential', 'credentials', or 'transaction_id' MUST be defined.`
|
|
1396
|
+
c_nonce_expires_in: z18.number().int().optional()
|
|
1397
|
+
}).passthrough().superRefine((value, ctx) => {
|
|
1398
|
+
const { credential, credentials, transaction_id, interval, notification_id } = value;
|
|
1399
|
+
if ([credential, credentials, transaction_id].filter((i) => i !== void 0).length !== 1) {
|
|
1400
|
+
ctx.addIssue({
|
|
1401
|
+
code: z18.ZodIssueCode.custom,
|
|
1402
|
+
message: `Exactly one of 'credential', 'credentials', or 'transaction_id' MUST be defined.`
|
|
1403
|
+
});
|
|
1337
1404
|
}
|
|
1338
|
-
)
|
|
1405
|
+
if (transaction_id && !interval) {
|
|
1406
|
+
ctx.addIssue({
|
|
1407
|
+
code: z18.ZodIssueCode.custom,
|
|
1408
|
+
message: `'interval' MUST be defined when 'transaction_id' is defined.`
|
|
1409
|
+
});
|
|
1410
|
+
}
|
|
1411
|
+
if (notification_id && !(credentials || credential)) {
|
|
1412
|
+
ctx.addIssue({
|
|
1413
|
+
code: z18.ZodIssueCode.custom,
|
|
1414
|
+
message: `'notification_id' MUST NOT be defined when 'credential' or 'credentials' are not defined.`
|
|
1415
|
+
});
|
|
1416
|
+
}
|
|
1417
|
+
});
|
|
1339
1418
|
var zCredentialErrorResponse = z18.object({
|
|
1340
1419
|
...zOauth2ErrorResponse.shape,
|
|
1341
1420
|
c_nonce: z18.string().optional(),
|
|
1342
1421
|
c_nonce_expires_in: z18.number().int().optional()
|
|
1343
1422
|
}).passthrough();
|
|
1423
|
+
var zDeferredCredentialResponse = zBaseCredentialResponse.refine(
|
|
1424
|
+
(value) => {
|
|
1425
|
+
const { credentials, interval } = value;
|
|
1426
|
+
return [credentials, interval].filter((i) => i !== void 0).length === 1;
|
|
1427
|
+
},
|
|
1428
|
+
{
|
|
1429
|
+
message: `Exactly one of 'credentials' or 'interval' MUST be defined.`
|
|
1430
|
+
}
|
|
1431
|
+
);
|
|
1344
1432
|
|
|
1345
1433
|
// src/credential-request/retrieve-credentials.ts
|
|
1346
1434
|
async function retrieveCredentialsWithCredentialConfigurationId(options) {
|
|
1347
|
-
if (options.issuerMetadata.originalDraftVersion !== "Draft15" /* Draft15 */) {
|
|
1435
|
+
if (options.issuerMetadata.originalDraftVersion !== "Draft15" /* Draft15 */ && options.issuerMetadata.originalDraftVersion !== "Draft16" /* Draft16 */) {
|
|
1348
1436
|
throw new Openid4vciError(
|
|
1349
|
-
"Requesting credentials based on
|
|
1437
|
+
"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."
|
|
1350
1438
|
);
|
|
1351
1439
|
}
|
|
1352
1440
|
getCredentialConfigurationSupportedById(
|
|
@@ -1368,7 +1456,7 @@ async function retrieveCredentialsWithCredentialConfigurationId(options) {
|
|
|
1368
1456
|
});
|
|
1369
1457
|
}
|
|
1370
1458
|
async function retrieveCredentialsWithFormat(options) {
|
|
1371
|
-
if (options.issuerMetadata.originalDraftVersion === "Draft15" /* Draft15 */) {
|
|
1459
|
+
if (options.issuerMetadata.originalDraftVersion === "Draft15" /* Draft15 */ || options.issuerMetadata.originalDraftVersion === "Draft16" /* Draft16 */) {
|
|
1372
1460
|
throw new Openid4vciError(
|
|
1373
1461
|
"Requesting credentials based on format is not supported in OpenID4VCI draft 15. Provide the credential configuration id directly in the request."
|
|
1374
1462
|
);
|
|
@@ -1448,6 +1536,54 @@ async function retrieveCredentials(options) {
|
|
|
1448
1536
|
credentialResponse: credentialResponseResult.data
|
|
1449
1537
|
};
|
|
1450
1538
|
}
|
|
1539
|
+
async function retrieveDeferredCredentials(options) {
|
|
1540
|
+
const credentialEndpoint = options.issuerMetadata.credentialIssuer.deferred_credential_endpoint;
|
|
1541
|
+
if (!credentialEndpoint) {
|
|
1542
|
+
throw new Openid4vciError(
|
|
1543
|
+
`Credential issuer '${options.issuerMetadata.credentialIssuer.credential_issuer}' does not support deferred credential retrieval.`
|
|
1544
|
+
);
|
|
1545
|
+
}
|
|
1546
|
+
const deferredCredentialRequest = parseWithErrorHandling3(
|
|
1547
|
+
zDeferredCredentialRequest,
|
|
1548
|
+
{
|
|
1549
|
+
transaction_id: options.transactionId,
|
|
1550
|
+
...options.additionalRequestPayload
|
|
1551
|
+
},
|
|
1552
|
+
"Error validating deferred credential request"
|
|
1553
|
+
);
|
|
1554
|
+
const resourceResponse = await resourceRequest({
|
|
1555
|
+
dpop: options.dpop,
|
|
1556
|
+
accessToken: options.accessToken,
|
|
1557
|
+
callbacks: options.callbacks,
|
|
1558
|
+
url: credentialEndpoint,
|
|
1559
|
+
requestOptions: {
|
|
1560
|
+
method: "POST",
|
|
1561
|
+
headers: {
|
|
1562
|
+
"Content-Type": ContentType2.Json
|
|
1563
|
+
},
|
|
1564
|
+
body: JSON.stringify(deferredCredentialRequest)
|
|
1565
|
+
}
|
|
1566
|
+
});
|
|
1567
|
+
if (!resourceResponse.ok) {
|
|
1568
|
+
const deferredCredentialErrorResponseResult = isResponseContentType(ContentType2.Json, resourceResponse.response) ? zCredentialErrorResponse.safeParse(await resourceResponse.response.clone().json()) : void 0;
|
|
1569
|
+
return {
|
|
1570
|
+
...resourceResponse,
|
|
1571
|
+
deferredCredentialErrorResponseResult
|
|
1572
|
+
};
|
|
1573
|
+
}
|
|
1574
|
+
const deferredCredentialResponseResult = isResponseContentType(ContentType2.Json, resourceResponse.response) ? zCredentialResponse.safeParse(await resourceResponse.response.clone().json()) : void 0;
|
|
1575
|
+
if (!deferredCredentialResponseResult?.success) {
|
|
1576
|
+
return {
|
|
1577
|
+
...resourceResponse,
|
|
1578
|
+
ok: false,
|
|
1579
|
+
deferredCredentialResponseResult
|
|
1580
|
+
};
|
|
1581
|
+
}
|
|
1582
|
+
return {
|
|
1583
|
+
...resourceResponse,
|
|
1584
|
+
deferredCredentialResponse: deferredCredentialResponseResult.data
|
|
1585
|
+
};
|
|
1586
|
+
}
|
|
1451
1587
|
|
|
1452
1588
|
// src/formats/proof-type/jwt/jwt-proof-type.ts
|
|
1453
1589
|
import { decodeJwt as decodeJwt2, isJwkInSet, jwtHeaderFromJwtSigner as jwtHeaderFromJwtSigner2 } from "@openid4vc/oauth2";
|
|
@@ -1604,7 +1740,7 @@ async function requestNonce(options) {
|
|
|
1604
1740
|
});
|
|
1605
1741
|
if (!response.ok || !result) {
|
|
1606
1742
|
throw new InvalidFetchResponseError2(
|
|
1607
|
-
`Requesting nonce from '${nonceEndpoint}' resulted in an
|
|
1743
|
+
`Requesting nonce from '${nonceEndpoint}' resulted in an unsuccessful response with status '${response.status}'`,
|
|
1608
1744
|
await response.clone().text(),
|
|
1609
1745
|
response
|
|
1610
1746
|
);
|
|
@@ -1642,7 +1778,7 @@ var zNotificationErrorResponse = z20.object({
|
|
|
1642
1778
|
}).passthrough();
|
|
1643
1779
|
|
|
1644
1780
|
// src/notification/notification.ts
|
|
1645
|
-
async function
|
|
1781
|
+
async function sendNotification(options) {
|
|
1646
1782
|
const notificationEndpoint = options.issuerMetadata.credentialIssuer.notification_endpoint;
|
|
1647
1783
|
if (!notificationEndpoint) {
|
|
1648
1784
|
throw new Oauth2Error6(
|
|
@@ -1717,7 +1853,7 @@ var Openid4vciClient = class {
|
|
|
1717
1853
|
* Retrieve an authorization code for a presentation during issuance session
|
|
1718
1854
|
*
|
|
1719
1855
|
* This can only be called if an authorization challenge was performed before and returned a
|
|
1720
|
-
* `presentation`
|
|
1856
|
+
* `presentation` parameter along with an `auth_session`. If the presentation response included
|
|
1721
1857
|
* an `presentation_during_issuance_session` parameter it MUST be included in this request as well.
|
|
1722
1858
|
*/
|
|
1723
1859
|
async retrieveAuthorizationCodeUsingPresentation(options) {
|
|
@@ -1750,9 +1886,9 @@ var Openid4vciClient = class {
|
|
|
1750
1886
|
*
|
|
1751
1887
|
* In case the authorization challenge request returns an error with `insufficient_authorization`
|
|
1752
1888
|
* with a `presentation` field it means the authorization server expects presentation of credentials
|
|
1753
|
-
* before issuance of
|
|
1889
|
+
* before issuance of credentials. If this is the case, the value in `presentation` should be treated
|
|
1754
1890
|
* as an openid4vp authorization request and submitted to the verifier. Once the presentation response
|
|
1755
|
-
* has been submitted, the RP will
|
|
1891
|
+
* has been submitted, the RP will respond with a `presentation_during_issuance_session` parameter.
|
|
1756
1892
|
* Together with the `auth_session` parameter returned in this call you can retrieve an `authorization_code`
|
|
1757
1893
|
* using
|
|
1758
1894
|
*/
|
|
@@ -1926,7 +2062,7 @@ var Openid4vciClient = class {
|
|
|
1926
2062
|
* Request a nonce to be used in credential request proofs from the `nonce_endpoint`
|
|
1927
2063
|
*
|
|
1928
2064
|
* @throws Openid4vciError - if no `nonce_endpoint` is configured in the issuer metadata
|
|
1929
|
-
* @
|
|
2065
|
+
* @throws InvalidFetchResponseError - if the nonce endpoint did not return a successful response
|
|
1930
2066
|
* @throws ValidationError - if validating the nonce response failed
|
|
1931
2067
|
*/
|
|
1932
2068
|
async requestNonce(options) {
|
|
@@ -1978,7 +2114,7 @@ var Openid4vciClient = class {
|
|
|
1978
2114
|
};
|
|
1979
2115
|
}
|
|
1980
2116
|
/**
|
|
1981
|
-
* @throws Openid4vciRetrieveCredentialsError - if an
|
|
2117
|
+
* @throws Openid4vciRetrieveCredentialsError - if an unsuccessful response or the response couldn't be parsed as credential response
|
|
1982
2118
|
* @throws ValidationError - if validation of the credential request failed
|
|
1983
2119
|
* @throws Openid4vciError - if the `credentialConfigurationId` couldn't be found, or if the the format specific request couldn't be constructed
|
|
1984
2120
|
*/
|
|
@@ -1992,7 +2128,7 @@ var Openid4vciClient = class {
|
|
|
1992
2128
|
dpop
|
|
1993
2129
|
}) {
|
|
1994
2130
|
let credentialResponse;
|
|
1995
|
-
if (issuerMetadata.originalDraftVersion === "Draft15" /* Draft15 */) {
|
|
2131
|
+
if (issuerMetadata.originalDraftVersion === "Draft15" /* Draft15 */ || issuerMetadata.originalDraftVersion === "Draft16" /* Draft16 */) {
|
|
1996
2132
|
credentialResponse = await retrieveCredentialsWithCredentialConfigurationId({
|
|
1997
2133
|
accessToken,
|
|
1998
2134
|
credentialConfigurationId,
|
|
@@ -2029,7 +2165,25 @@ var Openid4vciClient = class {
|
|
|
2029
2165
|
return credentialResponse;
|
|
2030
2166
|
}
|
|
2031
2167
|
/**
|
|
2032
|
-
* @throws
|
|
2168
|
+
* @throws Openid4vciRetrieveCredentialsError - if an unsuccessful response or the response couldn't be parsed as credential response
|
|
2169
|
+
* @throws ValidationError - if validation of the credential request failed
|
|
2170
|
+
*/
|
|
2171
|
+
async retrieveDeferredCredentials(options) {
|
|
2172
|
+
const credentialResponse = await retrieveDeferredCredentials({
|
|
2173
|
+
...options,
|
|
2174
|
+
callbacks: this.options.callbacks
|
|
2175
|
+
});
|
|
2176
|
+
if (!credentialResponse.ok) {
|
|
2177
|
+
throw new Openid4vciRetrieveCredentialsError(
|
|
2178
|
+
`Error retrieving deferred credentials from '${options.issuerMetadata.credentialIssuer.credential_issuer}'`,
|
|
2179
|
+
credentialResponse,
|
|
2180
|
+
await credentialResponse.response.clone().text()
|
|
2181
|
+
);
|
|
2182
|
+
}
|
|
2183
|
+
return credentialResponse;
|
|
2184
|
+
}
|
|
2185
|
+
/**
|
|
2186
|
+
* @throws Openid4vciSendNotificationError - if an unsuccessful response
|
|
2033
2187
|
* @throws ValidationError - if validation of the notification request failed
|
|
2034
2188
|
*/
|
|
2035
2189
|
async sendNotification({
|
|
@@ -2039,7 +2193,7 @@ var Openid4vciClient = class {
|
|
|
2039
2193
|
accessToken,
|
|
2040
2194
|
dpop
|
|
2041
2195
|
}) {
|
|
2042
|
-
const notificationResponse = await
|
|
2196
|
+
const notificationResponse = await sendNotification({
|
|
2043
2197
|
accessToken,
|
|
2044
2198
|
issuerMetadata,
|
|
2045
2199
|
additionalRequestPayload,
|
|
@@ -2064,7 +2218,7 @@ import {
|
|
|
2064
2218
|
Oauth2JwtVerificationError,
|
|
2065
2219
|
Oauth2ServerErrorResponseError
|
|
2066
2220
|
} from "@openid4vc/oauth2";
|
|
2067
|
-
import { ValidationError as ValidationError4, parseWithErrorHandling as
|
|
2221
|
+
import { ValidationError as ValidationError4, parseWithErrorHandling as parseWithErrorHandling11 } from "@openid4vc/utils";
|
|
2068
2222
|
|
|
2069
2223
|
// src/credential-request/credential-response.ts
|
|
2070
2224
|
import { parseWithErrorHandling as parseWithErrorHandling8 } from "@openid4vc/utils";
|
|
@@ -2075,6 +2229,8 @@ function createCredentialResponse(options) {
|
|
|
2075
2229
|
credential: options.credential,
|
|
2076
2230
|
credentials: options.credentials,
|
|
2077
2231
|
notification_id: options.notificationId,
|
|
2232
|
+
transaction_id: options.transactionId,
|
|
2233
|
+
interval: options.interval,
|
|
2078
2234
|
// NOTE `format` is removed in draft 13. For now if a format was requested
|
|
2079
2235
|
// we just always return it in the response as well.
|
|
2080
2236
|
format: options.credentialRequest.format?.format,
|
|
@@ -2082,6 +2238,14 @@ function createCredentialResponse(options) {
|
|
|
2082
2238
|
});
|
|
2083
2239
|
return credentialResponse;
|
|
2084
2240
|
}
|
|
2241
|
+
function createDeferredCredentialResponse(options) {
|
|
2242
|
+
return parseWithErrorHandling8(zDeferredCredentialResponse, {
|
|
2243
|
+
credentials: options.credentials,
|
|
2244
|
+
notification_id: options.notificationId,
|
|
2245
|
+
interval: options.interval,
|
|
2246
|
+
...options.additionalPayload
|
|
2247
|
+
});
|
|
2248
|
+
}
|
|
2085
2249
|
|
|
2086
2250
|
// src/credential-request/parse-credential-request.ts
|
|
2087
2251
|
import { parseWithErrorHandling as parseWithErrorHandling9 } from "@openid4vc/utils";
|
|
@@ -2145,6 +2309,19 @@ function parseCredentialRequest(options) {
|
|
|
2145
2309
|
};
|
|
2146
2310
|
}
|
|
2147
2311
|
|
|
2312
|
+
// src/credential-request/parse-deferred-credential-request.ts
|
|
2313
|
+
import { parseWithErrorHandling as parseWithErrorHandling10 } from "@openid4vc/utils";
|
|
2314
|
+
function parseDeferredCredentialRequest(options) {
|
|
2315
|
+
const deferredCredentialRequest = parseWithErrorHandling10(
|
|
2316
|
+
zDeferredCredentialRequest,
|
|
2317
|
+
options.deferredCredentialRequest,
|
|
2318
|
+
"Error validating credential request"
|
|
2319
|
+
);
|
|
2320
|
+
return {
|
|
2321
|
+
deferredCredentialRequest
|
|
2322
|
+
};
|
|
2323
|
+
}
|
|
2324
|
+
|
|
2148
2325
|
// src/formats/proof-type/attestation/attestation-proof-type.ts
|
|
2149
2326
|
async function verifyCredentialRequestAttestationProof(options) {
|
|
2150
2327
|
const verificationResult = await verifyKeyAttestationJwt({
|
|
@@ -2160,7 +2337,7 @@ var Openid4vciIssuer = class {
|
|
|
2160
2337
|
this.options = options;
|
|
2161
2338
|
}
|
|
2162
2339
|
getCredentialIssuerMetadataDraft11(credentialIssuerMetadata) {
|
|
2163
|
-
return
|
|
2340
|
+
return parseWithErrorHandling11(zCredentialIssuerMetadataWithDraft11, credentialIssuerMetadata);
|
|
2164
2341
|
}
|
|
2165
2342
|
getKnownCredentialConfigurationsSupported(credentialIssuerMetadata) {
|
|
2166
2343
|
return extractKnownCredentialConfigurationSupportedFormats(
|
|
@@ -2171,7 +2348,7 @@ var Openid4vciIssuer = class {
|
|
|
2171
2348
|
* Create issuer metadata and validates the structure is correct
|
|
2172
2349
|
*/
|
|
2173
2350
|
createCredentialIssuerMetadata(credentialIssuerMetadata) {
|
|
2174
|
-
return
|
|
2351
|
+
return parseWithErrorHandling11(
|
|
2175
2352
|
zCredentialIssuerMetadata,
|
|
2176
2353
|
credentialIssuerMetadata,
|
|
2177
2354
|
"Error validating credential issuer metadata"
|
|
@@ -2208,7 +2385,7 @@ var Openid4vciIssuer = class {
|
|
|
2208
2385
|
{
|
|
2209
2386
|
error: Oauth2ErrorCodes3.InvalidProof,
|
|
2210
2387
|
error_description: (
|
|
2211
|
-
//
|
|
2388
|
+
// TODO: error should have a internalErrorMessage and a publicErrorMessage
|
|
2212
2389
|
error instanceof Oauth2JwtVerificationError || error instanceof Openid4vciError ? error.message : "Invalid proof"
|
|
2213
2390
|
)
|
|
2214
2391
|
},
|
|
@@ -2237,7 +2414,7 @@ var Openid4vciIssuer = class {
|
|
|
2237
2414
|
{
|
|
2238
2415
|
error: Oauth2ErrorCodes3.InvalidProof,
|
|
2239
2416
|
error_description: (
|
|
2240
|
-
//
|
|
2417
|
+
// TODO: error should have a internalErrorMessage and a publicErrorMessage
|
|
2241
2418
|
error instanceof Oauth2JwtVerificationError || error instanceof Openid4vciError ? error.message : "Invalid proof"
|
|
2242
2419
|
)
|
|
2243
2420
|
},
|
|
@@ -2271,12 +2448,37 @@ var Openid4vciIssuer = class {
|
|
|
2271
2448
|
);
|
|
2272
2449
|
}
|
|
2273
2450
|
}
|
|
2451
|
+
/**
|
|
2452
|
+
* @throws Oauth2ServerErrorResponseError - when validation of the deferred credential request fails
|
|
2453
|
+
*/
|
|
2454
|
+
parseDeferredCredentialRequest(options) {
|
|
2455
|
+
try {
|
|
2456
|
+
return parseDeferredCredentialRequest(options);
|
|
2457
|
+
} catch (error) {
|
|
2458
|
+
throw new Oauth2ServerErrorResponseError(
|
|
2459
|
+
{
|
|
2460
|
+
error: Oauth2ErrorCodes3.InvalidCredentialRequest,
|
|
2461
|
+
error_description: error instanceof ValidationError4 ? error.message : "Invalid request"
|
|
2462
|
+
},
|
|
2463
|
+
{
|
|
2464
|
+
internalMessage: "Error parsing deferred credential request",
|
|
2465
|
+
cause: error
|
|
2466
|
+
}
|
|
2467
|
+
);
|
|
2468
|
+
}
|
|
2469
|
+
}
|
|
2274
2470
|
/**
|
|
2275
2471
|
* @throws ValidationError - when validation of the credential response fails
|
|
2276
2472
|
*/
|
|
2277
2473
|
createCredentialResponse(options) {
|
|
2278
2474
|
return createCredentialResponse(options);
|
|
2279
2475
|
}
|
|
2476
|
+
/**
|
|
2477
|
+
* @throws ValidationError - when validation of the credential response fails
|
|
2478
|
+
*/
|
|
2479
|
+
createDeferredCredentialResponse(options) {
|
|
2480
|
+
return createDeferredCredentialResponse(options);
|
|
2481
|
+
}
|
|
2280
2482
|
/**
|
|
2281
2483
|
* @throws ValidationError - when validation of the nonce response fails
|
|
2282
2484
|
*/
|