@openid4vc/openid4vci 0.3.0-alpha-20250811071720 → 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.js
CHANGED
|
@@ -43,9 +43,9 @@ __export(index_exports, {
|
|
|
43
43
|
determineAuthorizationServerForCredentialOffer: () => determineAuthorizationServerForCredentialOffer,
|
|
44
44
|
extractScopesForCredentialConfigurationIds: () => extractScopesForCredentialConfigurationIds,
|
|
45
45
|
getCredentialConfigurationsMatchingRequestFormat: () => getCredentialConfigurationsMatchingRequestFormat,
|
|
46
|
-
getGlobalConfig: () =>
|
|
46
|
+
getGlobalConfig: () => import_utils22.getGlobalConfig,
|
|
47
47
|
parseKeyAttestationJwt: () => parseKeyAttestationJwt,
|
|
48
|
-
setGlobalConfig: () =>
|
|
48
|
+
setGlobalConfig: () => import_utils22.setGlobalConfig,
|
|
49
49
|
verifyKeyAttestationJwt: () => verifyKeyAttestationJwt
|
|
50
50
|
});
|
|
51
51
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -56,6 +56,7 @@ var import_utils2 = require("@openid4vc/utils");
|
|
|
56
56
|
|
|
57
57
|
// src/version.ts
|
|
58
58
|
var Openid4vciDraftVersion = /* @__PURE__ */ ((Openid4vciDraftVersion2) => {
|
|
59
|
+
Openid4vciDraftVersion2["Draft16"] = "Draft16";
|
|
59
60
|
Openid4vciDraftVersion2["Draft15"] = "Draft15";
|
|
60
61
|
Openid4vciDraftVersion2["Draft14"] = "Draft14";
|
|
61
62
|
Openid4vciDraftVersion2["Draft11"] = "Draft11";
|
|
@@ -144,7 +145,7 @@ async function resolveCredentialOffer(credentialOffer, options) {
|
|
|
144
145
|
);
|
|
145
146
|
if (!response.ok || !result) {
|
|
146
147
|
throw new import_oauth22.InvalidFetchResponseError(
|
|
147
|
-
`Fetching credential offer from '${parsedQueryParams.credential_offer_uri}' resulted in an
|
|
148
|
+
`Fetching credential offer from '${parsedQueryParams.credential_offer_uri}' resulted in an unsuccessful response with status '${response.status}'`,
|
|
148
149
|
await response.clone().text(),
|
|
149
150
|
response
|
|
150
151
|
);
|
|
@@ -261,7 +262,7 @@ async function createCredentialOffer(options) {
|
|
|
261
262
|
}
|
|
262
263
|
|
|
263
264
|
// src/index.ts
|
|
264
|
-
var
|
|
265
|
+
var import_utils22 = require("@openid4vc/utils");
|
|
265
266
|
|
|
266
267
|
// src/credential-request/credential-request-configurations.ts
|
|
267
268
|
var import_utils6 = require("@openid4vc/utils");
|
|
@@ -276,7 +277,7 @@ var import_utils4 = require("@openid4vc/utils");
|
|
|
276
277
|
var import_zod12 = __toESM(require("zod"));
|
|
277
278
|
|
|
278
279
|
// src/formats/credential/mso-mdoc/z-mso-mdoc.ts
|
|
279
|
-
var
|
|
280
|
+
var import_zod5 = __toESM(require("zod"));
|
|
280
281
|
|
|
281
282
|
// src/metadata/credential-issuer/z-claims-description.ts
|
|
282
283
|
var import_zod2 = __toESM(require("zod"));
|
|
@@ -306,98 +307,196 @@ var zMsoMdocIssuerMetadataClaimsDescription = zIssuerMetadataClaimsDescription.e
|
|
|
306
307
|
path: zMsoMdocClaimsDescriptionPath
|
|
307
308
|
});
|
|
308
309
|
|
|
310
|
+
// src/metadata/credential-issuer/z-credential-configuration-supported-common.ts
|
|
311
|
+
var import_zod4 = __toESM(require("zod"));
|
|
312
|
+
|
|
313
|
+
// src/key-attestation/z-key-attestation.ts
|
|
314
|
+
var import_oauth23 = require("@openid4vc/oauth2");
|
|
315
|
+
var import_utils3 = require("@openid4vc/utils");
|
|
316
|
+
var import_zod3 = __toESM(require("zod"));
|
|
317
|
+
var zKeyAttestationJwtHeader = import_zod3.default.object({
|
|
318
|
+
...import_oauth23.zJwtHeader.shape,
|
|
319
|
+
typ: import_zod3.default.literal("keyattestation+jwt").or(
|
|
320
|
+
// Draft 16
|
|
321
|
+
import_zod3.default.literal("key-attestation+jwt")
|
|
322
|
+
)
|
|
323
|
+
}).passthrough().refine(({ kid, jwk }) => jwk === void 0 || kid === void 0, {
|
|
324
|
+
message: `Both 'jwk' and 'kid' are defined. Only one is allowed`
|
|
325
|
+
}).refine(({ trust_chain, kid }) => !trust_chain || !kid, {
|
|
326
|
+
message: `When 'trust_chain' is provided, 'kid' is required`
|
|
327
|
+
});
|
|
328
|
+
var zIso18045 = import_zod3.default.enum(["iso_18045_high", "iso_18045_moderate", "iso_18045_enhanced-basic", "iso_18045_basic"]);
|
|
329
|
+
var zIso18045OrStringArray = import_zod3.default.array(import_zod3.default.union([zIso18045, import_zod3.default.string()]));
|
|
330
|
+
var zKeyAttestationJwtPayload = import_zod3.default.object({
|
|
331
|
+
...import_oauth23.zJwtPayload.shape,
|
|
332
|
+
iat: import_utils3.zInteger,
|
|
333
|
+
attested_keys: import_zod3.default.array(import_oauth23.zJwk),
|
|
334
|
+
key_storage: import_zod3.default.optional(zIso18045OrStringArray),
|
|
335
|
+
user_authentication: import_zod3.default.optional(zIso18045OrStringArray),
|
|
336
|
+
certification: import_zod3.default.optional(import_zod3.default.string().url())
|
|
337
|
+
}).passthrough();
|
|
338
|
+
var zKeyAttestationJwtPayloadForUse = (use) => import_zod3.default.object({
|
|
339
|
+
...zKeyAttestationJwtPayload.shape,
|
|
340
|
+
// REQUIRED when used as proof_type.attesation directly
|
|
341
|
+
nonce: use === "proof_type.attestation" ? import_zod3.default.string({
|
|
342
|
+
message: `Nonce must be defined when key attestation is used as 'proof_type.attestation' directly`
|
|
343
|
+
}) : import_zod3.default.optional(import_zod3.default.string()),
|
|
344
|
+
// REQUIRED when used within header of proof_type.jwt
|
|
345
|
+
exp: use === "proof_type.jwt" ? import_utils3.zInteger : import_zod3.default.optional(import_utils3.zInteger)
|
|
346
|
+
}).passthrough();
|
|
347
|
+
|
|
348
|
+
// src/metadata/credential-issuer/z-credential-configuration-supported-common.ts
|
|
349
|
+
var zCredentialConfigurationSupportedCommonCredentialMetadata = import_zod4.default.object({
|
|
350
|
+
display: import_zod4.default.array(
|
|
351
|
+
import_zod4.default.object({
|
|
352
|
+
name: import_zod4.default.string(),
|
|
353
|
+
locale: import_zod4.default.string().optional(),
|
|
354
|
+
logo: import_zod4.default.object({
|
|
355
|
+
// FIXME: make required again, but need to support draft 11 first
|
|
356
|
+
uri: import_zod4.default.string().optional(),
|
|
357
|
+
alt_text: import_zod4.default.string().optional()
|
|
358
|
+
}).passthrough().optional(),
|
|
359
|
+
description: import_zod4.default.string().optional(),
|
|
360
|
+
background_color: import_zod4.default.string().optional(),
|
|
361
|
+
background_image: import_zod4.default.object({
|
|
362
|
+
// TODO: should be required, but paradym's metadata is wrong here.
|
|
363
|
+
uri: import_zod4.default.string().optional()
|
|
364
|
+
}).passthrough().optional(),
|
|
365
|
+
text_color: import_zod4.default.string().optional()
|
|
366
|
+
}).passthrough()
|
|
367
|
+
).optional()
|
|
368
|
+
});
|
|
369
|
+
var zCredentialConfigurationSupportedCommon = import_zod4.default.object({
|
|
370
|
+
format: import_zod4.default.string(),
|
|
371
|
+
scope: import_zod4.default.string().optional(),
|
|
372
|
+
cryptographic_binding_methods_supported: import_zod4.default.array(import_zod4.default.string()).optional(),
|
|
373
|
+
credential_signing_alg_values_supported: import_zod4.default.array(import_zod4.default.string()).or(import_zod4.default.array(import_zod4.default.number())).optional(),
|
|
374
|
+
proof_types_supported: import_zod4.default.record(
|
|
375
|
+
import_zod4.default.union([import_zod4.default.literal("jwt"), import_zod4.default.literal("attestation"), import_zod4.default.string()]),
|
|
376
|
+
import_zod4.default.object({
|
|
377
|
+
proof_signing_alg_values_supported: import_zod4.default.array(import_zod4.default.string()),
|
|
378
|
+
key_attestations_required: import_zod4.default.object({
|
|
379
|
+
key_storage: zIso18045OrStringArray.optional(),
|
|
380
|
+
user_authentication: zIso18045OrStringArray.optional()
|
|
381
|
+
}).passthrough().optional()
|
|
382
|
+
})
|
|
383
|
+
).optional(),
|
|
384
|
+
credential_metadata: zCredentialConfigurationSupportedCommonCredentialMetadata.optional()
|
|
385
|
+
}).passthrough();
|
|
386
|
+
|
|
309
387
|
// src/formats/credential/mso-mdoc/z-mso-mdoc.ts
|
|
310
|
-
var zMsoMdocFormatIdentifier =
|
|
311
|
-
var zMsoMdocCredentialIssuerMetadata =
|
|
388
|
+
var zMsoMdocFormatIdentifier = import_zod5.default.literal("mso_mdoc");
|
|
389
|
+
var zMsoMdocCredentialIssuerMetadata = import_zod5.default.object({
|
|
312
390
|
format: zMsoMdocFormatIdentifier,
|
|
313
|
-
doctype:
|
|
314
|
-
|
|
391
|
+
doctype: import_zod5.default.string(),
|
|
392
|
+
credential_metadata: zCredentialConfigurationSupportedCommonCredentialMetadata.extend({
|
|
393
|
+
claims: import_zod5.default.array(zMsoMdocIssuerMetadataClaimsDescription).optional()
|
|
394
|
+
}).optional()
|
|
315
395
|
});
|
|
316
|
-
var
|
|
396
|
+
var zMsoMdocCredentialIssuerMetadataDraft15 = import_zod5.default.object({
|
|
317
397
|
format: zMsoMdocFormatIdentifier,
|
|
318
|
-
doctype:
|
|
398
|
+
doctype: import_zod5.default.string(),
|
|
399
|
+
claims: import_zod5.default.array(zMsoMdocIssuerMetadataClaimsDescription).optional()
|
|
400
|
+
});
|
|
401
|
+
var zMsoMdocCredentialIssuerMetadataDraft14 = import_zod5.default.object({
|
|
402
|
+
format: zMsoMdocFormatIdentifier,
|
|
403
|
+
doctype: import_zod5.default.string(),
|
|
319
404
|
claims: zCredentialConfigurationSupportedClaimsDraft14.optional(),
|
|
320
|
-
order:
|
|
405
|
+
order: import_zod5.default.optional(import_zod5.default.array(import_zod5.default.string()))
|
|
321
406
|
});
|
|
322
|
-
var zMsoMdocCredentialRequestFormatDraft14 =
|
|
407
|
+
var zMsoMdocCredentialRequestFormatDraft14 = import_zod5.default.object({
|
|
323
408
|
format: zMsoMdocFormatIdentifier,
|
|
324
|
-
doctype:
|
|
409
|
+
doctype: import_zod5.default.string(),
|
|
325
410
|
// Format based request is removed in Draft 15, so only old claims syntax supported.
|
|
326
|
-
claims:
|
|
411
|
+
claims: import_zod5.default.optional(zCredentialConfigurationSupportedClaimsDraft14)
|
|
327
412
|
});
|
|
328
413
|
|
|
329
414
|
// src/formats/credential/sd-jwt-vc/z-sd-jwt-vc.ts
|
|
330
|
-
var
|
|
331
|
-
var zSdJwtVcFormatIdentifier =
|
|
332
|
-
var zSdJwtVcCredentialIssuerMetadataDraft14 =
|
|
333
|
-
vct:
|
|
415
|
+
var import_zod6 = __toESM(require("zod"));
|
|
416
|
+
var zSdJwtVcFormatIdentifier = import_zod6.default.literal("vc+sd-jwt");
|
|
417
|
+
var zSdJwtVcCredentialIssuerMetadataDraft14 = import_zod6.default.object({
|
|
418
|
+
vct: import_zod6.default.string(),
|
|
334
419
|
format: zSdJwtVcFormatIdentifier,
|
|
335
|
-
claims:
|
|
336
|
-
order:
|
|
420
|
+
claims: import_zod6.default.optional(zCredentialConfigurationSupportedClaimsDraft14),
|
|
421
|
+
order: import_zod6.default.optional(import_zod6.default.array(import_zod6.default.string()))
|
|
337
422
|
});
|
|
338
|
-
var zSdJwtVcCredentialRequestFormatDraft14 =
|
|
423
|
+
var zSdJwtVcCredentialRequestFormatDraft14 = import_zod6.default.object({
|
|
339
424
|
format: zSdJwtVcFormatIdentifier,
|
|
340
|
-
vct:
|
|
341
|
-
claims:
|
|
425
|
+
vct: import_zod6.default.string(),
|
|
426
|
+
claims: import_zod6.default.optional(zCredentialConfigurationSupportedClaimsDraft14)
|
|
342
427
|
});
|
|
343
428
|
|
|
344
429
|
// src/formats/credential/sd-jwt-dc/z-sd-jwt-dc.ts
|
|
345
|
-
var
|
|
346
|
-
var zSdJwtDcFormatIdentifier =
|
|
347
|
-
var zSdJwtDcCredentialIssuerMetadata =
|
|
348
|
-
vct:
|
|
430
|
+
var import_zod7 = __toESM(require("zod"));
|
|
431
|
+
var zSdJwtDcFormatIdentifier = import_zod7.default.literal("dc+sd-jwt");
|
|
432
|
+
var zSdJwtDcCredentialIssuerMetadata = import_zod7.default.object({
|
|
433
|
+
vct: import_zod7.default.string(),
|
|
434
|
+
format: zSdJwtDcFormatIdentifier,
|
|
435
|
+
credential_metadata: zCredentialConfigurationSupportedCommonCredentialMetadata.extend({
|
|
436
|
+
claims: import_zod7.default.array(zIssuerMetadataClaimsDescription).optional()
|
|
437
|
+
}).optional()
|
|
438
|
+
});
|
|
439
|
+
var zSdJwtDcCredentialIssuerMetadataDraft15 = import_zod7.default.object({
|
|
440
|
+
vct: import_zod7.default.string(),
|
|
349
441
|
format: zSdJwtDcFormatIdentifier,
|
|
350
|
-
claims:
|
|
442
|
+
claims: import_zod7.default.array(zIssuerMetadataClaimsDescription).optional()
|
|
351
443
|
});
|
|
352
444
|
|
|
353
445
|
// src/formats/credential/w3c-vc/z-w3c-ldp-vc.ts
|
|
354
|
-
var
|
|
446
|
+
var import_zod9 = __toESM(require("zod"));
|
|
355
447
|
|
|
356
448
|
// src/formats/credential/w3c-vc/z-w3c-vc-common.ts
|
|
357
|
-
var
|
|
358
|
-
var zCredentialSubjectLeafTypeDraft14 =
|
|
359
|
-
mandatory:
|
|
360
|
-
value_type:
|
|
361
|
-
display:
|
|
362
|
-
|
|
363
|
-
name:
|
|
364
|
-
locale:
|
|
449
|
+
var import_zod8 = __toESM(require("zod"));
|
|
450
|
+
var zCredentialSubjectLeafTypeDraft14 = import_zod8.default.object({
|
|
451
|
+
mandatory: import_zod8.default.boolean().optional(),
|
|
452
|
+
value_type: import_zod8.default.string().optional(),
|
|
453
|
+
display: import_zod8.default.array(
|
|
454
|
+
import_zod8.default.object({
|
|
455
|
+
name: import_zod8.default.string().optional(),
|
|
456
|
+
locale: import_zod8.default.string().optional()
|
|
365
457
|
}).passthrough()
|
|
366
458
|
).optional()
|
|
367
459
|
}).passthrough();
|
|
368
|
-
var zClaimValueSchemaDraft14 =
|
|
369
|
-
|
|
370
|
-
|
|
460
|
+
var zClaimValueSchemaDraft14 = import_zod8.default.union([
|
|
461
|
+
import_zod8.default.array(import_zod8.default.any()),
|
|
462
|
+
import_zod8.default.record(import_zod8.default.string(), import_zod8.default.any()),
|
|
371
463
|
zCredentialSubjectLeafTypeDraft14
|
|
372
464
|
]);
|
|
373
|
-
var zW3cVcCredentialSubjectDraft14 =
|
|
374
|
-
var zW3cVcJsonLdCredentialDefinition =
|
|
375
|
-
"@context":
|
|
376
|
-
type:
|
|
465
|
+
var zW3cVcCredentialSubjectDraft14 = import_zod8.default.record(import_zod8.default.string(), zClaimValueSchemaDraft14);
|
|
466
|
+
var zW3cVcJsonLdCredentialDefinition = import_zod8.default.object({
|
|
467
|
+
"@context": import_zod8.default.array(import_zod8.default.string()),
|
|
468
|
+
type: import_zod8.default.array(import_zod8.default.string())
|
|
377
469
|
}).passthrough();
|
|
378
470
|
var zW3cVcJsonLdCredentialDefinitionDraft14 = zW3cVcJsonLdCredentialDefinition.extend({
|
|
379
471
|
credentialSubject: zW3cVcCredentialSubjectDraft14.optional()
|
|
380
472
|
});
|
|
381
473
|
|
|
382
474
|
// src/formats/credential/w3c-vc/z-w3c-ldp-vc.ts
|
|
383
|
-
var zLdpVcFormatIdentifier =
|
|
384
|
-
var zLdpVcCredentialIssuerMetadata =
|
|
475
|
+
var zLdpVcFormatIdentifier = import_zod9.default.literal("ldp_vc");
|
|
476
|
+
var zLdpVcCredentialIssuerMetadata = import_zod9.default.object({
|
|
477
|
+
format: zLdpVcFormatIdentifier,
|
|
478
|
+
credential_definition: zW3cVcJsonLdCredentialDefinition,
|
|
479
|
+
credential_metadata: zCredentialConfigurationSupportedCommonCredentialMetadata.extend({
|
|
480
|
+
claims: zIssuerMetadataClaimsDescription.optional()
|
|
481
|
+
}).optional()
|
|
482
|
+
});
|
|
483
|
+
var zLdpVcCredentialIssuerMetadataDraft15 = import_zod9.default.object({
|
|
385
484
|
format: zLdpVcFormatIdentifier,
|
|
386
485
|
credential_definition: zW3cVcJsonLdCredentialDefinition,
|
|
387
486
|
claims: zIssuerMetadataClaimsDescription.optional()
|
|
388
487
|
});
|
|
389
|
-
var zLdpVcCredentialIssuerMetadataDraft14 =
|
|
488
|
+
var zLdpVcCredentialIssuerMetadataDraft14 = import_zod9.default.object({
|
|
390
489
|
format: zLdpVcFormatIdentifier,
|
|
391
490
|
credential_definition: zW3cVcJsonLdCredentialDefinitionDraft14,
|
|
392
|
-
order:
|
|
491
|
+
order: import_zod9.default.array(import_zod9.default.string()).optional()
|
|
393
492
|
});
|
|
394
|
-
var zLdpVcCredentialIssuerMetadataDraft11 =
|
|
395
|
-
order:
|
|
493
|
+
var zLdpVcCredentialIssuerMetadataDraft11 = import_zod9.default.object({
|
|
494
|
+
order: import_zod9.default.array(import_zod9.default.string()).optional(),
|
|
396
495
|
format: zLdpVcFormatIdentifier,
|
|
397
496
|
// Credential definition was spread on top level instead of a separatey property in v11
|
|
398
497
|
// As well as using types instead of type
|
|
399
|
-
"@context":
|
|
400
|
-
types:
|
|
498
|
+
"@context": import_zod9.default.array(import_zod9.default.string()),
|
|
499
|
+
types: import_zod9.default.array(import_zod9.default.string()),
|
|
401
500
|
credentialSubject: zW3cVcCredentialSubjectDraft14.optional()
|
|
402
501
|
}).passthrough();
|
|
403
502
|
var zLdpVcCredentialIssuerMetadataDraft11To14 = zLdpVcCredentialIssuerMetadataDraft11.transform(
|
|
@@ -416,16 +515,16 @@ var zLdpVcCredentialIssuerMetadataDraft14To11 = zLdpVcCredentialIssuerMetadataDr
|
|
|
416
515
|
...credentialDefinition,
|
|
417
516
|
types: type
|
|
418
517
|
})).pipe(zLdpVcCredentialIssuerMetadataDraft11);
|
|
419
|
-
var zLdpVcCredentialRequestFormatDraft14 =
|
|
518
|
+
var zLdpVcCredentialRequestFormatDraft14 = import_zod9.default.object({
|
|
420
519
|
format: zLdpVcFormatIdentifier,
|
|
421
520
|
credential_definition: zW3cVcJsonLdCredentialDefinitionDraft14
|
|
422
521
|
});
|
|
423
|
-
var zLdpVcCredentialRequestDraft11 =
|
|
522
|
+
var zLdpVcCredentialRequestDraft11 = import_zod9.default.object({
|
|
424
523
|
format: zLdpVcFormatIdentifier,
|
|
425
|
-
credential_definition:
|
|
426
|
-
"@context":
|
|
524
|
+
credential_definition: import_zod9.default.object({
|
|
525
|
+
"@context": import_zod9.default.array(import_zod9.default.string()),
|
|
427
526
|
// credential_definition was using types instead of type in v11
|
|
428
|
-
types:
|
|
527
|
+
types: import_zod9.default.array(import_zod9.default.string()),
|
|
429
528
|
credentialSubject: zW3cVcCredentialSubjectDraft14.optional()
|
|
430
529
|
})
|
|
431
530
|
}).passthrough();
|
|
@@ -447,25 +546,32 @@ var zLdpVcCredentialRequestDraft14To11 = zLdpVcCredentialRequestFormatDraft14.pa
|
|
|
447
546
|
})).pipe(zLdpVcCredentialRequestDraft11);
|
|
448
547
|
|
|
449
548
|
// src/formats/credential/w3c-vc/z-w3c-jwt-vc-json-ld.ts
|
|
450
|
-
var
|
|
451
|
-
var zJwtVcJsonLdFormatIdentifier =
|
|
452
|
-
var zJwtVcJsonLdCredentialIssuerMetadata =
|
|
549
|
+
var import_zod10 = __toESM(require("zod"));
|
|
550
|
+
var zJwtVcJsonLdFormatIdentifier = import_zod10.default.literal("jwt_vc_json-ld");
|
|
551
|
+
var zJwtVcJsonLdCredentialIssuerMetadata = import_zod10.default.object({
|
|
552
|
+
format: zJwtVcJsonLdFormatIdentifier,
|
|
553
|
+
credential_definition: zW3cVcJsonLdCredentialDefinition,
|
|
554
|
+
credential_metadata: zCredentialConfigurationSupportedCommonCredentialMetadata.extend({
|
|
555
|
+
claims: zIssuerMetadataClaimsDescription.optional()
|
|
556
|
+
}).optional()
|
|
557
|
+
});
|
|
558
|
+
var zJwtVcJsonLdCredentialIssuerMetadataDraft15 = import_zod10.default.object({
|
|
453
559
|
format: zJwtVcJsonLdFormatIdentifier,
|
|
454
560
|
credential_definition: zW3cVcJsonLdCredentialDefinition,
|
|
455
561
|
claims: zIssuerMetadataClaimsDescription.optional()
|
|
456
562
|
});
|
|
457
|
-
var zJwtVcJsonLdCredentialIssuerMetadataDraft14 =
|
|
563
|
+
var zJwtVcJsonLdCredentialIssuerMetadataDraft14 = import_zod10.default.object({
|
|
458
564
|
format: zJwtVcJsonLdFormatIdentifier,
|
|
459
565
|
credential_definition: zW3cVcJsonLdCredentialDefinitionDraft14,
|
|
460
|
-
order:
|
|
566
|
+
order: import_zod10.default.optional(import_zod10.default.array(import_zod10.default.string()))
|
|
461
567
|
});
|
|
462
|
-
var zJwtVcJsonLdCredentialIssuerMetadataDraft11 =
|
|
463
|
-
order:
|
|
568
|
+
var zJwtVcJsonLdCredentialIssuerMetadataDraft11 = import_zod10.default.object({
|
|
569
|
+
order: import_zod10.default.array(import_zod10.default.string()).optional(),
|
|
464
570
|
format: zJwtVcJsonLdFormatIdentifier,
|
|
465
571
|
// Credential definition was spread on top level instead of a separatey property in v11
|
|
466
572
|
// As well as using types instead of type
|
|
467
|
-
"@context":
|
|
468
|
-
types:
|
|
573
|
+
"@context": import_zod10.default.array(import_zod10.default.string()),
|
|
574
|
+
types: import_zod10.default.array(import_zod10.default.string()),
|
|
469
575
|
credentialSubject: zW3cVcCredentialSubjectDraft14.optional()
|
|
470
576
|
}).passthrough();
|
|
471
577
|
var zJwtVcJsonLdCredentialIssuerMetadataDraft11To14 = zJwtVcJsonLdCredentialIssuerMetadataDraft11.transform(
|
|
@@ -484,17 +590,17 @@ var zJwtVcJsonLdCredentialIssuerMetadataDraft14To11 = zJwtVcJsonLdCredentialIssu
|
|
|
484
590
|
...credentialDefinition,
|
|
485
591
|
types: type
|
|
486
592
|
})).pipe(zJwtVcJsonLdCredentialIssuerMetadataDraft11);
|
|
487
|
-
var zJwtVcJsonLdCredentialRequestFormatDraft14 =
|
|
593
|
+
var zJwtVcJsonLdCredentialRequestFormatDraft14 = import_zod10.default.object({
|
|
488
594
|
format: zJwtVcJsonLdFormatIdentifier,
|
|
489
595
|
credential_definition: zW3cVcJsonLdCredentialDefinition
|
|
490
596
|
});
|
|
491
|
-
var zJwtVcJsonLdCredentialRequestDraft11 =
|
|
597
|
+
var zJwtVcJsonLdCredentialRequestDraft11 = import_zod10.default.object({
|
|
492
598
|
format: zJwtVcJsonLdFormatIdentifier,
|
|
493
|
-
credential_definition:
|
|
494
|
-
"@context":
|
|
599
|
+
credential_definition: import_zod10.default.object({
|
|
600
|
+
"@context": import_zod10.default.array(import_zod10.default.string()),
|
|
495
601
|
// credential_definition was using types instead of type in v11
|
|
496
|
-
types:
|
|
497
|
-
credentialSubject:
|
|
602
|
+
types: import_zod10.default.array(import_zod10.default.string()),
|
|
603
|
+
credentialSubject: import_zod10.default.optional(zW3cVcCredentialSubjectDraft14)
|
|
498
604
|
}).passthrough()
|
|
499
605
|
}).passthrough();
|
|
500
606
|
var zJwtVcJsonLdCredentialRequestDraft11To14 = zJwtVcJsonLdCredentialRequestDraft11.transform(
|
|
@@ -515,30 +621,37 @@ var zJwtVcJsonLdCredentialRequestDraft14To11 = zJwtVcJsonLdCredentialRequestForm
|
|
|
515
621
|
})).pipe(zJwtVcJsonLdCredentialRequestDraft11);
|
|
516
622
|
|
|
517
623
|
// src/formats/credential/w3c-vc/z-w3c-jwt-vc-json.ts
|
|
518
|
-
var
|
|
519
|
-
var zJwtVcJsonFormatIdentifier =
|
|
520
|
-
var zJwtVcJsonCredentialDefinition =
|
|
521
|
-
type:
|
|
624
|
+
var import_zod11 = __toESM(require("zod"));
|
|
625
|
+
var zJwtVcJsonFormatIdentifier = import_zod11.default.literal("jwt_vc_json");
|
|
626
|
+
var zJwtVcJsonCredentialDefinition = import_zod11.default.object({
|
|
627
|
+
type: import_zod11.default.array(import_zod11.default.string())
|
|
522
628
|
}).passthrough();
|
|
523
629
|
var zJwtVcJsonCredentialDefinitionDraft14 = zJwtVcJsonCredentialDefinition.extend({
|
|
524
630
|
credentialSubject: zW3cVcCredentialSubjectDraft14.optional()
|
|
525
631
|
});
|
|
526
|
-
var zJwtVcJsonCredentialIssuerMetadata =
|
|
632
|
+
var zJwtVcJsonCredentialIssuerMetadata = import_zod11.default.object({
|
|
633
|
+
format: zJwtVcJsonFormatIdentifier,
|
|
634
|
+
credential_definition: zJwtVcJsonCredentialDefinition,
|
|
635
|
+
credential_metadata: zCredentialConfigurationSupportedCommonCredentialMetadata.extend({
|
|
636
|
+
claims: zIssuerMetadataClaimsDescription.optional()
|
|
637
|
+
}).optional()
|
|
638
|
+
});
|
|
639
|
+
var zJwtVcJsonCredentialIssuerMetadataDraft15 = import_zod11.default.object({
|
|
527
640
|
format: zJwtVcJsonFormatIdentifier,
|
|
528
641
|
credential_definition: zJwtVcJsonCredentialDefinition,
|
|
529
642
|
claims: zIssuerMetadataClaimsDescription.optional()
|
|
530
643
|
});
|
|
531
|
-
var zJwtVcJsonCredentialIssuerMetadataDraft14 =
|
|
644
|
+
var zJwtVcJsonCredentialIssuerMetadataDraft14 = import_zod11.default.object({
|
|
532
645
|
format: zJwtVcJsonFormatIdentifier,
|
|
533
646
|
credential_definition: zJwtVcJsonCredentialDefinitionDraft14,
|
|
534
|
-
order:
|
|
647
|
+
order: import_zod11.default.array(import_zod11.default.string()).optional()
|
|
535
648
|
});
|
|
536
|
-
var zJwtVcJsonCredentialIssuerMetadataDraft11 =
|
|
649
|
+
var zJwtVcJsonCredentialIssuerMetadataDraft11 = import_zod11.default.object({
|
|
537
650
|
format: zJwtVcJsonFormatIdentifier,
|
|
538
|
-
order:
|
|
651
|
+
order: import_zod11.default.array(import_zod11.default.string()).optional(),
|
|
539
652
|
// Credential definition was spread on top level instead of a separatey property in v11
|
|
540
653
|
// As well as using types instead of type
|
|
541
|
-
types:
|
|
654
|
+
types: import_zod11.default.array(import_zod11.default.string()),
|
|
542
655
|
credentialSubject: zW3cVcCredentialSubjectDraft14.optional()
|
|
543
656
|
}).passthrough();
|
|
544
657
|
var zJwtVcJsonCredentialIssuerMetadataDraft11To14 = zJwtVcJsonCredentialIssuerMetadataDraft11.transform(
|
|
@@ -556,16 +669,16 @@ var zJwtVcJsonCredentialIssuerMetadataDraft14To11 = zJwtVcJsonCredentialIssuerMe
|
|
|
556
669
|
types: type,
|
|
557
670
|
...credentialDefinition
|
|
558
671
|
})).pipe(zJwtVcJsonCredentialIssuerMetadataDraft11);
|
|
559
|
-
var zJwtVcJsonCredentialRequestFormatDraft14 =
|
|
672
|
+
var zJwtVcJsonCredentialRequestFormatDraft14 = import_zod11.default.object({
|
|
560
673
|
format: zJwtVcJsonFormatIdentifier,
|
|
561
674
|
credential_definition: zJwtVcJsonCredentialDefinition
|
|
562
675
|
});
|
|
563
|
-
var zJwtVcJsonCredentialRequestDraft11 =
|
|
676
|
+
var zJwtVcJsonCredentialRequestDraft11 = import_zod11.default.object({
|
|
564
677
|
format: zJwtVcJsonFormatIdentifier,
|
|
565
678
|
// Credential definition was spread on top level instead of a separatey property in v11
|
|
566
679
|
// As well as using types instead of type
|
|
567
|
-
types:
|
|
568
|
-
credentialSubject:
|
|
680
|
+
types: import_zod11.default.array(import_zod11.default.string()),
|
|
681
|
+
credentialSubject: import_zod11.default.optional(zW3cVcCredentialSubjectDraft14)
|
|
569
682
|
}).passthrough();
|
|
570
683
|
var zJwtVcJsonCredentialRequestDraft11To14 = zJwtVcJsonCredentialRequestDraft11.transform(
|
|
571
684
|
({ types, credentialSubject, ...rest }) => {
|
|
@@ -585,80 +698,6 @@ var zJwtVcJsonCredentialRequestDraft14To11 = zJwtVcJsonCredentialRequestFormatDr
|
|
|
585
698
|
...credentialDefinition
|
|
586
699
|
})).pipe(zJwtVcJsonCredentialRequestDraft11);
|
|
587
700
|
|
|
588
|
-
// src/metadata/credential-issuer/z-credential-configuration-supported-common.ts
|
|
589
|
-
var import_zod11 = __toESM(require("zod"));
|
|
590
|
-
|
|
591
|
-
// src/key-attestation/z-key-attestation.ts
|
|
592
|
-
var import_oauth23 = require("@openid4vc/oauth2");
|
|
593
|
-
var import_utils3 = require("@openid4vc/utils");
|
|
594
|
-
var import_zod10 = __toESM(require("zod"));
|
|
595
|
-
var zKeyAttestationJwtHeader = import_zod10.default.object({
|
|
596
|
-
...import_oauth23.zJwtHeader.shape,
|
|
597
|
-
typ: import_zod10.default.literal("keyattestation+jwt").or(
|
|
598
|
-
// Draft 16
|
|
599
|
-
import_zod10.default.literal("key-attestation+jwt")
|
|
600
|
-
)
|
|
601
|
-
}).passthrough().refine(({ kid, jwk }) => jwk === void 0 || kid === void 0, {
|
|
602
|
-
message: `Both 'jwk' and 'kid' are defined. Only one is allowed`
|
|
603
|
-
}).refine(({ trust_chain, kid }) => !trust_chain || !kid, {
|
|
604
|
-
message: `When 'trust_chain' is provided, 'kid' is required`
|
|
605
|
-
});
|
|
606
|
-
var zIso18045 = import_zod10.default.enum(["iso_18045_high", "iso_18045_moderate", "iso_18045_enhanced-basic", "iso_18045_basic"]);
|
|
607
|
-
var zIso18045OrStringArray = import_zod10.default.array(import_zod10.default.union([zIso18045, import_zod10.default.string()]));
|
|
608
|
-
var zKeyAttestationJwtPayload = import_zod10.default.object({
|
|
609
|
-
...import_oauth23.zJwtPayload.shape,
|
|
610
|
-
iat: import_utils3.zInteger,
|
|
611
|
-
attested_keys: import_zod10.default.array(import_oauth23.zJwk),
|
|
612
|
-
key_storage: import_zod10.default.optional(zIso18045OrStringArray),
|
|
613
|
-
user_authentication: import_zod10.default.optional(zIso18045OrStringArray),
|
|
614
|
-
certification: import_zod10.default.optional(import_zod10.default.string().url())
|
|
615
|
-
}).passthrough();
|
|
616
|
-
var zKeyAttestationJwtPayloadForUse = (use) => import_zod10.default.object({
|
|
617
|
-
...zKeyAttestationJwtPayload.shape,
|
|
618
|
-
// REQUIRED when used as proof_type.attesation directly
|
|
619
|
-
nonce: use === "proof_type.attestation" ? import_zod10.default.string({
|
|
620
|
-
message: `Nonce must be defined when key attestation is used as 'proof_type.attestation' directly`
|
|
621
|
-
}) : import_zod10.default.optional(import_zod10.default.string()),
|
|
622
|
-
// REQUIRED when used within header of proof_type.jwt
|
|
623
|
-
exp: use === "proof_type.jwt" ? import_utils3.zInteger : import_zod10.default.optional(import_utils3.zInteger)
|
|
624
|
-
}).passthrough();
|
|
625
|
-
|
|
626
|
-
// src/metadata/credential-issuer/z-credential-configuration-supported-common.ts
|
|
627
|
-
var zCredentialConfigurationSupportedCommon = import_zod11.default.object({
|
|
628
|
-
format: import_zod11.default.string(),
|
|
629
|
-
scope: import_zod11.default.string().optional(),
|
|
630
|
-
cryptographic_binding_methods_supported: import_zod11.default.array(import_zod11.default.string()).optional(),
|
|
631
|
-
credential_signing_alg_values_supported: import_zod11.default.array(import_zod11.default.string()).optional(),
|
|
632
|
-
proof_types_supported: import_zod11.default.record(
|
|
633
|
-
import_zod11.default.union([import_zod11.default.literal("jwt"), import_zod11.default.literal("attestation"), import_zod11.default.string()]),
|
|
634
|
-
import_zod11.default.object({
|
|
635
|
-
proof_signing_alg_values_supported: import_zod11.default.array(import_zod11.default.string()),
|
|
636
|
-
key_attestations_required: import_zod11.default.object({
|
|
637
|
-
key_storage: zIso18045OrStringArray.optional(),
|
|
638
|
-
user_authentication: zIso18045OrStringArray.optional()
|
|
639
|
-
}).passthrough().optional()
|
|
640
|
-
})
|
|
641
|
-
).optional(),
|
|
642
|
-
display: import_zod11.default.array(
|
|
643
|
-
import_zod11.default.object({
|
|
644
|
-
name: import_zod11.default.string(),
|
|
645
|
-
locale: import_zod11.default.string().optional(),
|
|
646
|
-
logo: import_zod11.default.object({
|
|
647
|
-
// FIXME: make required again, but need to support draft 11 first
|
|
648
|
-
uri: import_zod11.default.string().optional(),
|
|
649
|
-
alt_text: import_zod11.default.string().optional()
|
|
650
|
-
}).passthrough().optional(),
|
|
651
|
-
description: import_zod11.default.string().optional(),
|
|
652
|
-
background_color: import_zod11.default.string().optional(),
|
|
653
|
-
background_image: import_zod11.default.object({
|
|
654
|
-
// TODO: should be required, but paradym's metadata is wrong here.
|
|
655
|
-
uri: import_zod11.default.string().optional()
|
|
656
|
-
}).passthrough().optional(),
|
|
657
|
-
text_color: import_zod11.default.string().optional()
|
|
658
|
-
}).passthrough()
|
|
659
|
-
).optional()
|
|
660
|
-
}).passthrough();
|
|
661
|
-
|
|
662
701
|
// src/metadata/credential-issuer/z-credential-issuer-metadata.ts
|
|
663
702
|
var allCredentialIssuerMetadataFormats = [
|
|
664
703
|
zSdJwtDcCredentialIssuerMetadata,
|
|
@@ -666,6 +705,11 @@ var allCredentialIssuerMetadataFormats = [
|
|
|
666
705
|
zJwtVcJsonLdCredentialIssuerMetadata,
|
|
667
706
|
zLdpVcCredentialIssuerMetadata,
|
|
668
707
|
zJwtVcJsonCredentialIssuerMetadata,
|
|
708
|
+
zSdJwtDcCredentialIssuerMetadataDraft15,
|
|
709
|
+
zMsoMdocCredentialIssuerMetadataDraft15,
|
|
710
|
+
zJwtVcJsonLdCredentialIssuerMetadataDraft15,
|
|
711
|
+
zLdpVcCredentialIssuerMetadataDraft15,
|
|
712
|
+
zJwtVcJsonCredentialIssuerMetadataDraft15,
|
|
669
713
|
zMsoMdocCredentialIssuerMetadataDraft14,
|
|
670
714
|
zSdJwtVcCredentialIssuerMetadataDraft14,
|
|
671
715
|
zJwtVcJsonLdCredentialIssuerMetadataDraft14,
|
|
@@ -710,7 +754,7 @@ var zCredentialIssuerMetadataDisplayEntry = import_zod12.default.object({
|
|
|
710
754
|
alt_text: import_zod12.default.string().optional()
|
|
711
755
|
}).passthrough().optional()
|
|
712
756
|
}).passthrough();
|
|
713
|
-
var
|
|
757
|
+
var zCredentialIssuerMetadataDraft14Draft15Draft16 = import_zod12.default.object({
|
|
714
758
|
credential_issuer: import_utils4.zHttpsUrl,
|
|
715
759
|
authorization_servers: import_zod12.default.array(import_utils4.zHttpsUrl).optional(),
|
|
716
760
|
credential_endpoint: import_utils4.zHttpsUrl,
|
|
@@ -783,7 +827,13 @@ var zCredentialConfigurationSupportedDraft11To14 = import_zod12.default.object({
|
|
|
783
827
|
}
|
|
784
828
|
return import_zod12.default.NEVER;
|
|
785
829
|
}).pipe(zCredentialConfigurationSupportedWithFormats);
|
|
786
|
-
var
|
|
830
|
+
var zCredentialConfigurationSupportedDraft16To15 = zCredentialConfigurationSupportedWithFormats.transform(
|
|
831
|
+
({ credential_metadata, ...rest }) => ({
|
|
832
|
+
...credential_metadata,
|
|
833
|
+
...rest
|
|
834
|
+
})
|
|
835
|
+
);
|
|
836
|
+
var zCredentialConfigurationSupportedDraft14To11 = zCredentialConfigurationSupportedDraft16To15.and(
|
|
787
837
|
import_zod12.default.object({
|
|
788
838
|
id: import_zod12.default.string()
|
|
789
839
|
}).passthrough()
|
|
@@ -810,7 +860,7 @@ var zCredentialConfigurationSupportedDraft14To11 = zCredentialConfigurationSuppo
|
|
|
810
860
|
zJwtVcJsonCredentialIssuerMetadataDraft14To11,
|
|
811
861
|
zJwtVcJsonLdCredentialIssuerMetadataDraft14To11,
|
|
812
862
|
// To handle unrecognized formats and not error immediately we allow the common format as well
|
|
813
|
-
// but they can't use any of the
|
|
863
|
+
// but they can't use any of the format identifiers that have a specific transformation. This way if a format is
|
|
814
864
|
// has a transformation it NEEDS to use the format specific transformation, and otherwise we fall back to the common validation
|
|
815
865
|
import_zod12.default.object({
|
|
816
866
|
format: import_zod12.default.string().refine(
|
|
@@ -823,7 +873,7 @@ var zCredentialConfigurationSupportedDraft14To11 = zCredentialConfigurationSuppo
|
|
|
823
873
|
}).passthrough()
|
|
824
874
|
])
|
|
825
875
|
);
|
|
826
|
-
var
|
|
876
|
+
var zCredentialIssuerMetadataDraft11To16 = import_zod12.default.object({
|
|
827
877
|
authorization_server: import_zod12.default.string().optional(),
|
|
828
878
|
credentials_supported: import_zod12.default.array(
|
|
829
879
|
import_zod12.default.object({
|
|
@@ -841,11 +891,11 @@ var zCredentialIssuerMetadataDraft11To14 = import_zod12.default.object({
|
|
|
841
891
|
};
|
|
842
892
|
}).pipe(
|
|
843
893
|
import_zod12.default.object({
|
|
844
|
-
// Update from v11
|
|
894
|
+
// Update from v11 structure to v14 structure
|
|
845
895
|
credential_configurations_supported: import_zod12.default.record(import_zod12.default.string(), zCredentialConfigurationSupportedDraft11To14)
|
|
846
896
|
}).passthrough()
|
|
847
|
-
).pipe(
|
|
848
|
-
var zCredentialIssuerMetadataWithDraft11 =
|
|
897
|
+
).pipe(zCredentialIssuerMetadataDraft14Draft15Draft16);
|
|
898
|
+
var zCredentialIssuerMetadataWithDraft11 = zCredentialIssuerMetadataDraft14Draft15Draft16.transform((issuerMetadata) => ({
|
|
849
899
|
...issuerMetadata,
|
|
850
900
|
...issuerMetadata.authorization_servers ? { authorization_server: issuerMetadata.authorization_servers[0] } : {},
|
|
851
901
|
credentials_supported: Object.entries(issuerMetadata.credential_configurations_supported).map(([id, value]) => ({
|
|
@@ -853,37 +903,39 @@ var zCredentialIssuerMetadataWithDraft11 = zCredentialIssuerMetadataDraft14Draft
|
|
|
853
903
|
id
|
|
854
904
|
}))
|
|
855
905
|
})).pipe(
|
|
856
|
-
|
|
906
|
+
zCredentialIssuerMetadataDraft14Draft15Draft16.extend({
|
|
857
907
|
credentials_supported: import_zod12.default.array(zCredentialConfigurationSupportedDraft14To11)
|
|
858
908
|
})
|
|
859
909
|
);
|
|
860
910
|
var zCredentialIssuerMetadata = import_zod12.default.union([
|
|
861
|
-
// First prioritize draft 15/14 (and 13)
|
|
862
|
-
|
|
863
|
-
// Then try parsing draft 11 and transform into draft
|
|
864
|
-
|
|
911
|
+
// First prioritize draft 16/15/14 (and 13)
|
|
912
|
+
zCredentialIssuerMetadataDraft14Draft15Draft16,
|
|
913
|
+
// Then try parsing draft 11 and transform into draft 16
|
|
914
|
+
zCredentialIssuerMetadataDraft11To16
|
|
865
915
|
]);
|
|
866
916
|
var zCredentialIssuerMetadataWithDraftVersion = import_zod12.default.union([
|
|
867
|
-
|
|
868
|
-
const
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
)
|
|
917
|
+
zCredentialIssuerMetadataDraft14Draft15Draft16.transform((credentialIssuerMetadata) => {
|
|
918
|
+
const credentialConfigurations = Object.values(credentialIssuerMetadata.credential_configurations_supported);
|
|
919
|
+
const isDraft15 = credentialConfigurations.some((configuration) => {
|
|
920
|
+
const knownConfiguration = configuration;
|
|
921
|
+
if (knownConfiguration.format === zSdJwtDcFormatIdentifier.value) return true;
|
|
922
|
+
if (Array.isArray(knownConfiguration.claims)) return true;
|
|
923
|
+
if (Object.values(knownConfiguration.proof_types_supported ?? {}).some(
|
|
924
|
+
(proofType) => proofType.key_attestations_required !== void 0
|
|
925
|
+
))
|
|
926
|
+
return true;
|
|
927
|
+
return false;
|
|
928
|
+
});
|
|
929
|
+
const isDraft16 = credentialConfigurations.some((configuration) => {
|
|
930
|
+
return configuration.credential_metadata;
|
|
931
|
+
});
|
|
880
932
|
return {
|
|
881
933
|
credentialIssuerMetadata,
|
|
882
|
-
originalDraftVersion: isDraft15 ? "Draft15" /* Draft15 */ : "Draft14" /* Draft14 */
|
|
934
|
+
originalDraftVersion: isDraft16 ? "Draft16" /* Draft16 */ : isDraft15 ? "Draft15" /* Draft15 */ : "Draft14" /* Draft14 */
|
|
883
935
|
};
|
|
884
936
|
}),
|
|
885
937
|
// Then try parsing draft 11 and transform into draft 14
|
|
886
|
-
|
|
938
|
+
zCredentialIssuerMetadataDraft11To16.transform((credentialIssuerMetadata) => ({
|
|
887
939
|
credentialIssuerMetadata,
|
|
888
940
|
originalDraftVersion: "Draft11" /* Draft11 */
|
|
889
941
|
}))
|
|
@@ -1071,7 +1123,7 @@ function credentialsSupportedToCredentialConfigurationsSupported(credentialsSupp
|
|
|
1071
1123
|
}
|
|
1072
1124
|
|
|
1073
1125
|
// src/Openid4vciClient.ts
|
|
1074
|
-
var
|
|
1126
|
+
var import_oauth219 = require("@openid4vc/oauth2");
|
|
1075
1127
|
|
|
1076
1128
|
// src/credential-request/format-payload.ts
|
|
1077
1129
|
var import_utils10 = require("@openid4vc/utils");
|
|
@@ -1129,10 +1181,11 @@ function getCredentialRequestFormatPayloadForCredentialConfigurationId(options)
|
|
|
1129
1181
|
}
|
|
1130
1182
|
|
|
1131
1183
|
// src/credential-request/retrieve-credentials.ts
|
|
1132
|
-
var
|
|
1184
|
+
var import_oauth213 = require("@openid4vc/oauth2");
|
|
1133
1185
|
var import_utils12 = require("@openid4vc/utils");
|
|
1134
1186
|
|
|
1135
1187
|
// src/credential-request/z-credential-request.ts
|
|
1188
|
+
var import_oauth212 = require("@openid4vc/oauth2");
|
|
1136
1189
|
var import_zod16 = __toESM(require("zod"));
|
|
1137
1190
|
|
|
1138
1191
|
// src/credential-request/z-credential-request-common.ts
|
|
@@ -1233,7 +1286,7 @@ var zCredentialRequestFormat = import_zod16.default.object({
|
|
|
1233
1286
|
credential_identifier: import_zod16.default.never({ message: "'credential_identifier' cannot be defined when 'format' is set." }).optional(),
|
|
1234
1287
|
credential_configuration_id: import_zod16.default.never({ message: "'credential_configuration_id' cannot be defined when 'format' is set." }).optional()
|
|
1235
1288
|
}).passthrough();
|
|
1236
|
-
var
|
|
1289
|
+
var zCredentialRequestDraft14WithFormat = zCredentialRequestCommon.and(zCredentialRequestFormat).transform((data, ctx) => {
|
|
1237
1290
|
if (!allCredentialRequestFormatIdentifiers.includes(
|
|
1238
1291
|
data.format
|
|
1239
1292
|
))
|
|
@@ -1252,7 +1305,7 @@ var zCredentialRequestDraft15 = import_zod16.default.union([
|
|
|
1252
1305
|
zCredentialRequestCommon.and(zCredentialRequestCredentialConfigurationId)
|
|
1253
1306
|
]);
|
|
1254
1307
|
var zCredentialRequestDraft14 = import_zod16.default.union([
|
|
1255
|
-
|
|
1308
|
+
zCredentialRequestDraft14WithFormat,
|
|
1256
1309
|
zCredentialRequestCommon.and(zAuthorizationDetailsCredentialRequest)
|
|
1257
1310
|
]);
|
|
1258
1311
|
var zCredentialRequestDraft11To14 = zCredentialRequestCommon.and(zCredentialRequestFormat).transform((data, ctx) => {
|
|
@@ -1293,6 +1346,14 @@ var zCredentialRequest = import_zod16.default.union([
|
|
|
1293
1346
|
zCredentialRequestDraft14,
|
|
1294
1347
|
zCredentialRequestDraft11To14
|
|
1295
1348
|
]);
|
|
1349
|
+
var zDeferredCredentialRequest = import_zod16.default.object({
|
|
1350
|
+
transaction_id: import_zod16.default.string().nonempty(),
|
|
1351
|
+
credential_response_encryption: import_zod16.default.object({
|
|
1352
|
+
jwk: import_oauth212.zJwk,
|
|
1353
|
+
alg: import_zod16.default.string(),
|
|
1354
|
+
enc: import_zod16.default.string()
|
|
1355
|
+
}).passthrough().optional()
|
|
1356
|
+
});
|
|
1296
1357
|
|
|
1297
1358
|
// src/credential-request/z-credential-response.ts
|
|
1298
1359
|
var import_zod18 = __toESM(require("zod"));
|
|
@@ -1317,11 +1378,14 @@ var Oauth2ErrorCodes = /* @__PURE__ */ ((Oauth2ErrorCodes4) => {
|
|
|
1317
1378
|
Oauth2ErrorCodes4["InsufficientAuthorization"] = "insufficient_authorization";
|
|
1318
1379
|
Oauth2ErrorCodes4["InvalidCredentialRequest"] = "invalid_credential_request";
|
|
1319
1380
|
Oauth2ErrorCodes4["CredentialRequestDenied"] = "credential_request_denied";
|
|
1320
|
-
Oauth2ErrorCodes4["UnsupportedCredentialType"] = "unsupported_credential_type";
|
|
1321
|
-
Oauth2ErrorCodes4["UnsupportedCredentialFormat"] = "unsupported_credential_format";
|
|
1322
1381
|
Oauth2ErrorCodes4["InvalidProof"] = "invalid_proof";
|
|
1323
1382
|
Oauth2ErrorCodes4["InvalidNonce"] = "invalid_nonce";
|
|
1324
1383
|
Oauth2ErrorCodes4["InvalidEncryptionParameters"] = "invalid_encryption_parameters";
|
|
1384
|
+
Oauth2ErrorCodes4["UnknownCredentialConfiguration"] = "unknown_credential_configuration";
|
|
1385
|
+
Oauth2ErrorCodes4["UnknownCredentialIdentifier"] = "unknown_credential_identifier";
|
|
1386
|
+
Oauth2ErrorCodes4["InvalidTransactionId"] = "invalid_transaction_id";
|
|
1387
|
+
Oauth2ErrorCodes4["UnsupportedCredentialType"] = "unsupported_credential_type";
|
|
1388
|
+
Oauth2ErrorCodes4["UnsupportedCredentialFormat"] = "unsupported_credential_format";
|
|
1325
1389
|
Oauth2ErrorCodes4["InvalidRequestUri"] = "invalid_request_uri";
|
|
1326
1390
|
Oauth2ErrorCodes4["InvalidRequestObject"] = "invalid_request_object";
|
|
1327
1391
|
Oauth2ErrorCodes4["RequestNotSupported"] = "request_not_supported";
|
|
@@ -1343,33 +1407,57 @@ var zOauth2ErrorResponse = import_zod17.default.object({
|
|
|
1343
1407
|
|
|
1344
1408
|
// src/credential-request/z-credential-response.ts
|
|
1345
1409
|
var zCredentialEncoding = import_zod18.default.union([import_zod18.default.string(), import_zod18.default.record(import_zod18.default.string(), import_zod18.default.any())]);
|
|
1346
|
-
var
|
|
1347
|
-
credential: import_zod18.default.optional(zCredentialEncoding),
|
|
1410
|
+
var zBaseCredentialResponse = import_zod18.default.object({
|
|
1348
1411
|
credentials: import_zod18.default.optional(import_zod18.default.array(zCredentialEncoding)),
|
|
1412
|
+
interval: import_zod18.default.number().int().positive().optional(),
|
|
1413
|
+
notification_id: import_zod18.default.string().optional()
|
|
1414
|
+
}).passthrough();
|
|
1415
|
+
var zCredentialResponse = zBaseCredentialResponse.extend({
|
|
1416
|
+
credential: import_zod18.default.optional(zCredentialEncoding),
|
|
1349
1417
|
transaction_id: import_zod18.default.string().optional(),
|
|
1350
1418
|
c_nonce: import_zod18.default.string().optional(),
|
|
1351
|
-
c_nonce_expires_in: import_zod18.default.number().int().optional()
|
|
1352
|
-
|
|
1353
|
-
}
|
|
1354
|
-
(
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
message: `Exactly one of 'credential', 'credentials', or 'transaction_id' MUST be defined.`
|
|
1419
|
+
c_nonce_expires_in: import_zod18.default.number().int().optional()
|
|
1420
|
+
}).passthrough().superRefine((value, ctx) => {
|
|
1421
|
+
const { credential, credentials, transaction_id, interval, notification_id } = value;
|
|
1422
|
+
if ([credential, credentials, transaction_id].filter((i) => i !== void 0).length !== 1) {
|
|
1423
|
+
ctx.addIssue({
|
|
1424
|
+
code: import_zod18.default.ZodIssueCode.custom,
|
|
1425
|
+
message: `Exactly one of 'credential', 'credentials', or 'transaction_id' MUST be defined.`
|
|
1426
|
+
});
|
|
1360
1427
|
}
|
|
1361
|
-
)
|
|
1428
|
+
if (transaction_id && !interval) {
|
|
1429
|
+
ctx.addIssue({
|
|
1430
|
+
code: import_zod18.default.ZodIssueCode.custom,
|
|
1431
|
+
message: `'interval' MUST be defined when 'transaction_id' is defined.`
|
|
1432
|
+
});
|
|
1433
|
+
}
|
|
1434
|
+
if (notification_id && !(credentials || credential)) {
|
|
1435
|
+
ctx.addIssue({
|
|
1436
|
+
code: import_zod18.default.ZodIssueCode.custom,
|
|
1437
|
+
message: `'notification_id' MUST NOT be defined when 'credential' or 'credentials' are not defined.`
|
|
1438
|
+
});
|
|
1439
|
+
}
|
|
1440
|
+
});
|
|
1362
1441
|
var zCredentialErrorResponse = import_zod18.default.object({
|
|
1363
1442
|
...zOauth2ErrorResponse.shape,
|
|
1364
1443
|
c_nonce: import_zod18.default.string().optional(),
|
|
1365
1444
|
c_nonce_expires_in: import_zod18.default.number().int().optional()
|
|
1366
1445
|
}).passthrough();
|
|
1446
|
+
var zDeferredCredentialResponse = zBaseCredentialResponse.refine(
|
|
1447
|
+
(value) => {
|
|
1448
|
+
const { credentials, interval } = value;
|
|
1449
|
+
return [credentials, interval].filter((i) => i !== void 0).length === 1;
|
|
1450
|
+
},
|
|
1451
|
+
{
|
|
1452
|
+
message: `Exactly one of 'credentials' or 'interval' MUST be defined.`
|
|
1453
|
+
}
|
|
1454
|
+
);
|
|
1367
1455
|
|
|
1368
1456
|
// src/credential-request/retrieve-credentials.ts
|
|
1369
1457
|
async function retrieveCredentialsWithCredentialConfigurationId(options) {
|
|
1370
|
-
if (options.issuerMetadata.originalDraftVersion !== "Draft15" /* Draft15 */) {
|
|
1458
|
+
if (options.issuerMetadata.originalDraftVersion !== "Draft15" /* Draft15 */ && options.issuerMetadata.originalDraftVersion !== "Draft16" /* Draft16 */) {
|
|
1371
1459
|
throw new Openid4vciError(
|
|
1372
|
-
"Requesting credentials based on
|
|
1460
|
+
"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."
|
|
1373
1461
|
);
|
|
1374
1462
|
}
|
|
1375
1463
|
getCredentialConfigurationSupportedById(
|
|
@@ -1391,7 +1479,7 @@ async function retrieveCredentialsWithCredentialConfigurationId(options) {
|
|
|
1391
1479
|
});
|
|
1392
1480
|
}
|
|
1393
1481
|
async function retrieveCredentialsWithFormat(options) {
|
|
1394
|
-
if (options.issuerMetadata.originalDraftVersion === "Draft15" /* Draft15 */) {
|
|
1482
|
+
if (options.issuerMetadata.originalDraftVersion === "Draft15" /* Draft15 */ || options.issuerMetadata.originalDraftVersion === "Draft16" /* Draft16 */) {
|
|
1395
1483
|
throw new Openid4vciError(
|
|
1396
1484
|
"Requesting credentials based on format is not supported in OpenID4VCI draft 15. Provide the credential configuration id directly in the request."
|
|
1397
1485
|
);
|
|
@@ -1420,13 +1508,13 @@ async function retrieveCredentials(options) {
|
|
|
1420
1508
|
if (credentialRequest.proofs) {
|
|
1421
1509
|
const { batch_credential_issuance } = options.issuerMetadata.credentialIssuer;
|
|
1422
1510
|
if (options.issuerMetadata.originalDraftVersion === "Draft11" /* Draft11 */) {
|
|
1423
|
-
throw new
|
|
1511
|
+
throw new import_oauth213.Oauth2Error(
|
|
1424
1512
|
`Credential issuer '${options.issuerMetadata.credentialIssuer.credential_issuer}' does not support batch credential issuance using the 'proofs' request property. Only 'proof' is supported.`
|
|
1425
1513
|
);
|
|
1426
1514
|
}
|
|
1427
1515
|
const proofs = Object.values(credentialRequest.proofs)[0];
|
|
1428
1516
|
if (proofs.length > (batch_credential_issuance?.batch_size ?? 1)) {
|
|
1429
|
-
throw new
|
|
1517
|
+
throw new import_oauth213.Oauth2Error(
|
|
1430
1518
|
`Credential issuer '${options.issuerMetadata.credentialIssuer.credential_issuer}' supports batch issuance, but the max batch size is '${batch_credential_issuance?.batch_size ?? 1}'. A total of '${proofs.length}' proofs were provided.`
|
|
1431
1519
|
);
|
|
1432
1520
|
}
|
|
@@ -1438,7 +1526,7 @@ async function retrieveCredentials(options) {
|
|
|
1438
1526
|
`Error transforming credential request from ${"Draft14" /* Draft14 */} to ${"Draft11" /* Draft11 */}`
|
|
1439
1527
|
);
|
|
1440
1528
|
}
|
|
1441
|
-
const resourceResponse = await (0,
|
|
1529
|
+
const resourceResponse = await (0, import_oauth213.resourceRequest)({
|
|
1442
1530
|
dpop: options.dpop,
|
|
1443
1531
|
accessToken: options.accessToken,
|
|
1444
1532
|
callbacks: options.callbacks,
|
|
@@ -1471,14 +1559,62 @@ async function retrieveCredentials(options) {
|
|
|
1471
1559
|
credentialResponse: credentialResponseResult.data
|
|
1472
1560
|
};
|
|
1473
1561
|
}
|
|
1562
|
+
async function retrieveDeferredCredentials(options) {
|
|
1563
|
+
const credentialEndpoint = options.issuerMetadata.credentialIssuer.deferred_credential_endpoint;
|
|
1564
|
+
if (!credentialEndpoint) {
|
|
1565
|
+
throw new Openid4vciError(
|
|
1566
|
+
`Credential issuer '${options.issuerMetadata.credentialIssuer.credential_issuer}' does not support deferred credential retrieval.`
|
|
1567
|
+
);
|
|
1568
|
+
}
|
|
1569
|
+
const deferredCredentialRequest = (0, import_utils12.parseWithErrorHandling)(
|
|
1570
|
+
zDeferredCredentialRequest,
|
|
1571
|
+
{
|
|
1572
|
+
transaction_id: options.transactionId,
|
|
1573
|
+
...options.additionalRequestPayload
|
|
1574
|
+
},
|
|
1575
|
+
"Error validating deferred credential request"
|
|
1576
|
+
);
|
|
1577
|
+
const resourceResponse = await (0, import_oauth213.resourceRequest)({
|
|
1578
|
+
dpop: options.dpop,
|
|
1579
|
+
accessToken: options.accessToken,
|
|
1580
|
+
callbacks: options.callbacks,
|
|
1581
|
+
url: credentialEndpoint,
|
|
1582
|
+
requestOptions: {
|
|
1583
|
+
method: "POST",
|
|
1584
|
+
headers: {
|
|
1585
|
+
"Content-Type": import_utils12.ContentType.Json
|
|
1586
|
+
},
|
|
1587
|
+
body: JSON.stringify(deferredCredentialRequest)
|
|
1588
|
+
}
|
|
1589
|
+
});
|
|
1590
|
+
if (!resourceResponse.ok) {
|
|
1591
|
+
const deferredCredentialErrorResponseResult = (0, import_utils12.isResponseContentType)(import_utils12.ContentType.Json, resourceResponse.response) ? zCredentialErrorResponse.safeParse(await resourceResponse.response.clone().json()) : void 0;
|
|
1592
|
+
return {
|
|
1593
|
+
...resourceResponse,
|
|
1594
|
+
deferredCredentialErrorResponseResult
|
|
1595
|
+
};
|
|
1596
|
+
}
|
|
1597
|
+
const deferredCredentialResponseResult = (0, import_utils12.isResponseContentType)(import_utils12.ContentType.Json, resourceResponse.response) ? zCredentialResponse.safeParse(await resourceResponse.response.clone().json()) : void 0;
|
|
1598
|
+
if (!deferredCredentialResponseResult?.success) {
|
|
1599
|
+
return {
|
|
1600
|
+
...resourceResponse,
|
|
1601
|
+
ok: false,
|
|
1602
|
+
deferredCredentialResponseResult
|
|
1603
|
+
};
|
|
1604
|
+
}
|
|
1605
|
+
return {
|
|
1606
|
+
...resourceResponse,
|
|
1607
|
+
deferredCredentialResponse: deferredCredentialResponseResult.data
|
|
1608
|
+
};
|
|
1609
|
+
}
|
|
1474
1610
|
|
|
1475
1611
|
// src/formats/proof-type/jwt/jwt-proof-type.ts
|
|
1476
|
-
var import_oauth213 = require("@openid4vc/oauth2");
|
|
1477
1612
|
var import_oauth214 = require("@openid4vc/oauth2");
|
|
1613
|
+
var import_oauth215 = require("@openid4vc/oauth2");
|
|
1478
1614
|
var import_utils13 = require("@openid4vc/utils");
|
|
1479
1615
|
async function createCredentialRequestJwtProof(options) {
|
|
1480
1616
|
const header = (0, import_utils13.parseWithErrorHandling)(zCredentialRequestJwtProofTypeHeader, {
|
|
1481
|
-
...(0,
|
|
1617
|
+
...(0, import_oauth214.jwtHeaderFromJwtSigner)(options.signer),
|
|
1482
1618
|
key_attestation: options.keyAttestationJwt,
|
|
1483
1619
|
typ: "openid4vci-proof+jwt"
|
|
1484
1620
|
});
|
|
@@ -1490,12 +1626,12 @@ async function createCredentialRequestJwtProof(options) {
|
|
|
1490
1626
|
});
|
|
1491
1627
|
const { jwt, signerJwk } = await options.callbacks.signJwt(options.signer, { header, payload });
|
|
1492
1628
|
if (options.keyAttestationJwt) {
|
|
1493
|
-
const decodedKeyAttestation = (0,
|
|
1629
|
+
const decodedKeyAttestation = (0, import_oauth214.decodeJwt)({
|
|
1494
1630
|
jwt: options.keyAttestationJwt,
|
|
1495
1631
|
headerSchema: zKeyAttestationJwtHeader,
|
|
1496
1632
|
payloadSchema: zKeyAttestationJwtPayload
|
|
1497
1633
|
});
|
|
1498
|
-
const isSigedWithAttestedKey = await (0,
|
|
1634
|
+
const isSigedWithAttestedKey = await (0, import_oauth214.isJwkInSet)({
|
|
1499
1635
|
jwk: signerJwk,
|
|
1500
1636
|
jwks: decodedKeyAttestation.payload.attested_keys,
|
|
1501
1637
|
callbacks: options.callbacks
|
|
@@ -1509,7 +1645,7 @@ async function createCredentialRequestJwtProof(options) {
|
|
|
1509
1645
|
return jwt;
|
|
1510
1646
|
}
|
|
1511
1647
|
async function verifyCredentialRequestJwtProof(options) {
|
|
1512
|
-
const { header, payload } = (0,
|
|
1648
|
+
const { header, payload } = (0, import_oauth214.decodeJwt)({
|
|
1513
1649
|
jwt: options.jwt,
|
|
1514
1650
|
headerSchema: zCredentialRequestJwtProofTypeHeader,
|
|
1515
1651
|
payloadSchema: zCredentialRequestJwtProofTypePayload
|
|
@@ -1518,11 +1654,11 @@ async function verifyCredentialRequestJwtProof(options) {
|
|
|
1518
1654
|
if (options.nonceExpiresAt && now > options.nonceExpiresAt.getTime()) {
|
|
1519
1655
|
throw new Openid4vciError("Nonce used for credential request proof expired");
|
|
1520
1656
|
}
|
|
1521
|
-
const { signer } = await (0,
|
|
1657
|
+
const { signer } = await (0, import_oauth215.verifyJwt)({
|
|
1522
1658
|
compact: options.jwt,
|
|
1523
1659
|
header,
|
|
1524
1660
|
payload,
|
|
1525
|
-
signer: (0,
|
|
1661
|
+
signer: (0, import_oauth215.jwtSignerFromJwt)({ header, payload }),
|
|
1526
1662
|
verifyJwtCallback: options.callbacks.verifyJwt,
|
|
1527
1663
|
errorMessage: "Error verifiying credential request proof jwt.",
|
|
1528
1664
|
expectedNonce: options.expectedNonce,
|
|
@@ -1537,7 +1673,7 @@ async function verifyCredentialRequestJwtProof(options) {
|
|
|
1537
1673
|
keyAttestationJwt: header.key_attestation,
|
|
1538
1674
|
use: "proof_type.jwt"
|
|
1539
1675
|
});
|
|
1540
|
-
const isSigedWithAttestedKey = await (0,
|
|
1676
|
+
const isSigedWithAttestedKey = await (0, import_oauth214.isJwkInSet)({
|
|
1541
1677
|
jwk: signer.publicJwk,
|
|
1542
1678
|
jwks: keyAttestationResult.payload.attested_keys,
|
|
1543
1679
|
callbacks: options.callbacks
|
|
@@ -1557,13 +1693,13 @@ async function verifyCredentialRequestJwtProof(options) {
|
|
|
1557
1693
|
}
|
|
1558
1694
|
|
|
1559
1695
|
// src/metadata/fetch-issuer-metadata.ts
|
|
1560
|
-
var
|
|
1696
|
+
var import_oauth216 = require("@openid4vc/oauth2");
|
|
1561
1697
|
var import_utils14 = require("@openid4vc/utils");
|
|
1562
1698
|
async function resolveIssuerMetadata(credentialIssuer, options) {
|
|
1563
1699
|
const allowAuthorizationMetadataFromCredentialIssuerMetadata = options?.allowAuthorizationMetadataFromCredentialIssuerMetadata ?? true;
|
|
1564
1700
|
const credentialIssuerMetadataWithDraftVersion = await fetchCredentialIssuerMetadata(credentialIssuer, options?.fetch);
|
|
1565
1701
|
if (!credentialIssuerMetadataWithDraftVersion) {
|
|
1566
|
-
throw new
|
|
1702
|
+
throw new import_oauth216.Oauth2Error(`Well known credential issuer metadata for issuer '${credentialIssuer}' not found.`);
|
|
1567
1703
|
}
|
|
1568
1704
|
const { credentialIssuerMetadata, originalDraftVersion } = credentialIssuerMetadataWithDraftVersion;
|
|
1569
1705
|
const authorizationServers = credentialIssuerMetadata.authorization_servers ?? [credentialIssuer];
|
|
@@ -1572,10 +1708,10 @@ async function resolveIssuerMetadata(credentialIssuer, options) {
|
|
|
1572
1708
|
if (options?.restrictToAuthorizationServers && !options.restrictToAuthorizationServers.includes(authorizationServer)) {
|
|
1573
1709
|
continue;
|
|
1574
1710
|
}
|
|
1575
|
-
let authorizationServerMetadata = await (0,
|
|
1711
|
+
let authorizationServerMetadata = await (0, import_oauth216.fetchAuthorizationServerMetadata)(authorizationServer, options?.fetch);
|
|
1576
1712
|
if (!authorizationServerMetadata && authorizationServer === credentialIssuer && allowAuthorizationMetadataFromCredentialIssuerMetadata) {
|
|
1577
1713
|
authorizationServerMetadata = (0, import_utils14.parseWithErrorHandling)(
|
|
1578
|
-
|
|
1714
|
+
import_oauth216.zAuthorizationServerMetadata,
|
|
1579
1715
|
{
|
|
1580
1716
|
token_endpoint: credentialIssuerMetadata.token_endpoint,
|
|
1581
1717
|
issuer: credentialIssuer
|
|
@@ -1584,7 +1720,7 @@ async function resolveIssuerMetadata(credentialIssuer, options) {
|
|
|
1584
1720
|
);
|
|
1585
1721
|
}
|
|
1586
1722
|
if (!authorizationServerMetadata) {
|
|
1587
|
-
throw new
|
|
1723
|
+
throw new import_oauth216.Oauth2Error(
|
|
1588
1724
|
`Well known openid configuration or authorization server metadata for authorization server '${authorizationServer}' not found.`
|
|
1589
1725
|
);
|
|
1590
1726
|
}
|
|
@@ -1598,7 +1734,7 @@ async function resolveIssuerMetadata(credentialIssuer, options) {
|
|
|
1598
1734
|
}
|
|
1599
1735
|
|
|
1600
1736
|
// src/nonce/nonce-request.ts
|
|
1601
|
-
var
|
|
1737
|
+
var import_oauth217 = require("@openid4vc/oauth2");
|
|
1602
1738
|
var import_utils16 = require("@openid4vc/utils");
|
|
1603
1739
|
|
|
1604
1740
|
// src/nonce/z-nonce.ts
|
|
@@ -1622,8 +1758,8 @@ async function requestNonce(options) {
|
|
|
1622
1758
|
method: "POST"
|
|
1623
1759
|
});
|
|
1624
1760
|
if (!response.ok || !result) {
|
|
1625
|
-
throw new
|
|
1626
|
-
`Requesting nonce from '${nonceEndpoint}' resulted in an
|
|
1761
|
+
throw new import_oauth217.InvalidFetchResponseError(
|
|
1762
|
+
`Requesting nonce from '${nonceEndpoint}' resulted in an unsuccessful response with status '${response.status}'`,
|
|
1627
1763
|
await response.clone().text(),
|
|
1628
1764
|
response
|
|
1629
1765
|
);
|
|
@@ -1642,7 +1778,7 @@ function createNonceResponse(options) {
|
|
|
1642
1778
|
}
|
|
1643
1779
|
|
|
1644
1780
|
// src/notification/notification.ts
|
|
1645
|
-
var
|
|
1781
|
+
var import_oauth218 = require("@openid4vc/oauth2");
|
|
1646
1782
|
var import_utils17 = require("@openid4vc/utils");
|
|
1647
1783
|
|
|
1648
1784
|
// src/notification/z-notification.ts
|
|
@@ -1658,10 +1794,10 @@ var zNotificationErrorResponse = import_zod20.default.object({
|
|
|
1658
1794
|
}).passthrough();
|
|
1659
1795
|
|
|
1660
1796
|
// src/notification/notification.ts
|
|
1661
|
-
async function
|
|
1797
|
+
async function sendNotification(options) {
|
|
1662
1798
|
const notificationEndpoint = options.issuerMetadata.credentialIssuer.notification_endpoint;
|
|
1663
1799
|
if (!notificationEndpoint) {
|
|
1664
|
-
throw new
|
|
1800
|
+
throw new import_oauth218.Oauth2Error(
|
|
1665
1801
|
`Credential issuer '${options.issuerMetadata.credentialIssuer.credential_issuer}' does not have a notification endpiont configured.`
|
|
1666
1802
|
);
|
|
1667
1803
|
}
|
|
@@ -1674,7 +1810,7 @@ async function sendNotifcation(options) {
|
|
|
1674
1810
|
},
|
|
1675
1811
|
"Error validating notification request"
|
|
1676
1812
|
);
|
|
1677
|
-
const resourceResponse = await (0,
|
|
1813
|
+
const resourceResponse = await (0, import_oauth218.resourceRequest)({
|
|
1678
1814
|
dpop: options.dpop,
|
|
1679
1815
|
accessToken: options.accessToken,
|
|
1680
1816
|
callbacks: options.callbacks,
|
|
@@ -1706,7 +1842,7 @@ var AuthorizationFlow = /* @__PURE__ */ ((AuthorizationFlow2) => {
|
|
|
1706
1842
|
var Openid4vciClient = class {
|
|
1707
1843
|
constructor(options) {
|
|
1708
1844
|
this.options = options;
|
|
1709
|
-
this.oauth2Client = new
|
|
1845
|
+
this.oauth2Client = new import_oauth219.Oauth2Client({
|
|
1710
1846
|
callbacks: this.options.callbacks
|
|
1711
1847
|
});
|
|
1712
1848
|
}
|
|
@@ -1733,23 +1869,23 @@ var Openid4vciClient = class {
|
|
|
1733
1869
|
* Retrieve an authorization code for a presentation during issuance session
|
|
1734
1870
|
*
|
|
1735
1871
|
* This can only be called if an authorization challenge was performed before and returned a
|
|
1736
|
-
* `presentation`
|
|
1872
|
+
* `presentation` parameter along with an `auth_session`. If the presentation response included
|
|
1737
1873
|
* an `presentation_during_issuance_session` parameter it MUST be included in this request as well.
|
|
1738
1874
|
*/
|
|
1739
1875
|
async retrieveAuthorizationCodeUsingPresentation(options) {
|
|
1740
|
-
if (!options.credentialOffer.grants?.[
|
|
1741
|
-
throw new
|
|
1876
|
+
if (!options.credentialOffer.grants?.[import_oauth219.authorizationCodeGrantIdentifier]) {
|
|
1877
|
+
throw new import_oauth219.Oauth2Error(`Provided credential offer does not include the 'authorization_code' grant.`);
|
|
1742
1878
|
}
|
|
1743
|
-
const authorizationCodeGrant = options.credentialOffer.grants[
|
|
1879
|
+
const authorizationCodeGrant = options.credentialOffer.grants[import_oauth219.authorizationCodeGrantIdentifier];
|
|
1744
1880
|
const authorizationServer = determineAuthorizationServerForCredentialOffer({
|
|
1745
1881
|
issuerMetadata: options.issuerMetadata,
|
|
1746
1882
|
grantAuthorizationServer: authorizationCodeGrant.authorization_server
|
|
1747
1883
|
});
|
|
1748
|
-
const authorizationServerMetadata = (0,
|
|
1884
|
+
const authorizationServerMetadata = (0, import_oauth219.getAuthorizationServerMetadataFromList)(
|
|
1749
1885
|
options.issuerMetadata.authorizationServers,
|
|
1750
1886
|
authorizationServer
|
|
1751
1887
|
);
|
|
1752
|
-
const oauth2Client = new
|
|
1888
|
+
const oauth2Client = new import_oauth219.Oauth2Client({ callbacks: this.options.callbacks });
|
|
1753
1889
|
const { authorizationChallengeResponse, dpop } = await oauth2Client.sendAuthorizationChallengeRequest({
|
|
1754
1890
|
authorizationServerMetadata,
|
|
1755
1891
|
authSession: options.authSession,
|
|
@@ -1766,26 +1902,26 @@ var Openid4vciClient = class {
|
|
|
1766
1902
|
*
|
|
1767
1903
|
* In case the authorization challenge request returns an error with `insufficient_authorization`
|
|
1768
1904
|
* with a `presentation` field it means the authorization server expects presentation of credentials
|
|
1769
|
-
* before issuance of
|
|
1905
|
+
* before issuance of credentials. If this is the case, the value in `presentation` should be treated
|
|
1770
1906
|
* as an openid4vp authorization request and submitted to the verifier. Once the presentation response
|
|
1771
|
-
* has been submitted, the RP will
|
|
1907
|
+
* has been submitted, the RP will respond with a `presentation_during_issuance_session` parameter.
|
|
1772
1908
|
* Together with the `auth_session` parameter returned in this call you can retrieve an `authorization_code`
|
|
1773
1909
|
* using
|
|
1774
1910
|
*/
|
|
1775
1911
|
async initiateAuthorization(options) {
|
|
1776
|
-
if (!options.credentialOffer.grants?.[
|
|
1777
|
-
throw new
|
|
1912
|
+
if (!options.credentialOffer.grants?.[import_oauth219.authorizationCodeGrantIdentifier]) {
|
|
1913
|
+
throw new import_oauth219.Oauth2Error(`Provided credential offer does not include the 'authorization_code' grant.`);
|
|
1778
1914
|
}
|
|
1779
|
-
const authorizationCodeGrant = options.credentialOffer.grants[
|
|
1915
|
+
const authorizationCodeGrant = options.credentialOffer.grants[import_oauth219.authorizationCodeGrantIdentifier];
|
|
1780
1916
|
const authorizationServer = determineAuthorizationServerForCredentialOffer({
|
|
1781
1917
|
issuerMetadata: options.issuerMetadata,
|
|
1782
1918
|
grantAuthorizationServer: authorizationCodeGrant.authorization_server
|
|
1783
1919
|
});
|
|
1784
|
-
const authorizationServerMetadata = (0,
|
|
1920
|
+
const authorizationServerMetadata = (0, import_oauth219.getAuthorizationServerMetadataFromList)(
|
|
1785
1921
|
options.issuerMetadata.authorizationServers,
|
|
1786
1922
|
authorizationServer
|
|
1787
1923
|
);
|
|
1788
|
-
const oauth2Client = new
|
|
1924
|
+
const oauth2Client = new import_oauth219.Oauth2Client({ callbacks: this.options.callbacks });
|
|
1789
1925
|
try {
|
|
1790
1926
|
const result = await oauth2Client.initiateAuthorization({
|
|
1791
1927
|
clientId: options.clientId,
|
|
@@ -1806,7 +1942,7 @@ var Openid4vciClient = class {
|
|
|
1806
1942
|
authorizationServer: authorizationServerMetadata.issuer
|
|
1807
1943
|
};
|
|
1808
1944
|
} catch (error) {
|
|
1809
|
-
if (error instanceof
|
|
1945
|
+
if (error instanceof import_oauth219.Oauth2ClientAuthorizationChallengeError && error.errorResponse.error === import_oauth219.Oauth2ErrorCodes.InsufficientAuthorization && error.errorResponse.presentation) {
|
|
1810
1946
|
if (!error.errorResponse.auth_session) {
|
|
1811
1947
|
throw new Openid4vciError(
|
|
1812
1948
|
`Expected 'auth_session' to be defined with authorization challenge response error '${error.errorResponse.error}' and 'presentation' parameter`
|
|
@@ -1827,15 +1963,15 @@ var Openid4vciClient = class {
|
|
|
1827
1963
|
* but specifically focused on a credential offer
|
|
1828
1964
|
*/
|
|
1829
1965
|
async createAuthorizationRequestUrlFromOffer(options) {
|
|
1830
|
-
if (!options.credentialOffer.grants?.[
|
|
1831
|
-
throw new
|
|
1966
|
+
if (!options.credentialOffer.grants?.[import_oauth219.authorizationCodeGrantIdentifier]) {
|
|
1967
|
+
throw new import_oauth219.Oauth2Error(`Provided credential offer does not include the 'authorization_code' grant.`);
|
|
1832
1968
|
}
|
|
1833
|
-
const authorizationCodeGrant = options.credentialOffer.grants[
|
|
1969
|
+
const authorizationCodeGrant = options.credentialOffer.grants[import_oauth219.authorizationCodeGrantIdentifier];
|
|
1834
1970
|
const authorizationServer = determineAuthorizationServerForCredentialOffer({
|
|
1835
1971
|
issuerMetadata: options.issuerMetadata,
|
|
1836
1972
|
grantAuthorizationServer: authorizationCodeGrant.authorization_server
|
|
1837
1973
|
});
|
|
1838
|
-
const authorizationServerMetadata = (0,
|
|
1974
|
+
const authorizationServerMetadata = (0, import_oauth219.getAuthorizationServerMetadataFromList)(
|
|
1839
1975
|
options.issuerMetadata.authorizationServers,
|
|
1840
1976
|
authorizationServer
|
|
1841
1977
|
);
|
|
@@ -1870,20 +2006,20 @@ var Openid4vciClient = class {
|
|
|
1870
2006
|
txCode,
|
|
1871
2007
|
dpop
|
|
1872
2008
|
}) {
|
|
1873
|
-
if (!credentialOffer.grants?.[
|
|
1874
|
-
throw new
|
|
2009
|
+
if (!credentialOffer.grants?.[import_oauth219.preAuthorizedCodeGrantIdentifier]) {
|
|
2010
|
+
throw new import_oauth219.Oauth2Error(`The credential offer does not contain the '${import_oauth219.preAuthorizedCodeGrantIdentifier}' grant.`);
|
|
1875
2011
|
}
|
|
1876
|
-
if (credentialOffer.grants[
|
|
1877
|
-
throw new
|
|
2012
|
+
if (credentialOffer.grants[import_oauth219.preAuthorizedCodeGrantIdentifier].tx_code && !txCode) {
|
|
2013
|
+
throw new import_oauth219.Oauth2Error(
|
|
1878
2014
|
`Retrieving access token requires a 'tx_code' in the request, but the 'txCode' parameter was not provided.`
|
|
1879
2015
|
);
|
|
1880
2016
|
}
|
|
1881
|
-
const preAuthorizedCode = credentialOffer.grants[
|
|
2017
|
+
const preAuthorizedCode = credentialOffer.grants[import_oauth219.preAuthorizedCodeGrantIdentifier]["pre-authorized_code"];
|
|
1882
2018
|
const authorizationServer = determineAuthorizationServerForCredentialOffer({
|
|
1883
|
-
grantAuthorizationServer: credentialOffer.grants[
|
|
2019
|
+
grantAuthorizationServer: credentialOffer.grants[import_oauth219.preAuthorizedCodeGrantIdentifier].authorization_server,
|
|
1884
2020
|
issuerMetadata
|
|
1885
2021
|
});
|
|
1886
|
-
const authorizationServerMetadata = (0,
|
|
2022
|
+
const authorizationServerMetadata = (0, import_oauth219.getAuthorizationServerMetadataFromList)(
|
|
1887
2023
|
issuerMetadata.authorizationServers,
|
|
1888
2024
|
authorizationServer
|
|
1889
2025
|
);
|
|
@@ -1913,14 +2049,14 @@ var Openid4vciClient = class {
|
|
|
1913
2049
|
redirectUri,
|
|
1914
2050
|
dpop
|
|
1915
2051
|
}) {
|
|
1916
|
-
if (!credentialOffer.grants?.[
|
|
1917
|
-
throw new
|
|
2052
|
+
if (!credentialOffer.grants?.[import_oauth219.authorizationCodeGrantIdentifier]) {
|
|
2053
|
+
throw new import_oauth219.Oauth2Error(`The credential offer does not contain the '${import_oauth219.authorizationCodeGrantIdentifier}' grant.`);
|
|
1918
2054
|
}
|
|
1919
2055
|
const authorizationServer = determineAuthorizationServerForCredentialOffer({
|
|
1920
|
-
grantAuthorizationServer: credentialOffer.grants[
|
|
2056
|
+
grantAuthorizationServer: credentialOffer.grants[import_oauth219.authorizationCodeGrantIdentifier].authorization_server,
|
|
1921
2057
|
issuerMetadata
|
|
1922
2058
|
});
|
|
1923
|
-
const authorizationServerMetadata = (0,
|
|
2059
|
+
const authorizationServerMetadata = (0, import_oauth219.getAuthorizationServerMetadataFromList)(
|
|
1924
2060
|
issuerMetadata.authorizationServers,
|
|
1925
2061
|
authorizationServer
|
|
1926
2062
|
);
|
|
@@ -1942,7 +2078,7 @@ var Openid4vciClient = class {
|
|
|
1942
2078
|
* Request a nonce to be used in credential request proofs from the `nonce_endpoint`
|
|
1943
2079
|
*
|
|
1944
2080
|
* @throws Openid4vciError - if no `nonce_endpoint` is configured in the issuer metadata
|
|
1945
|
-
* @
|
|
2081
|
+
* @throws InvalidFetchResponseError - if the nonce endpoint did not return a successful response
|
|
1946
2082
|
* @throws ValidationError - if validating the nonce response failed
|
|
1947
2083
|
*/
|
|
1948
2084
|
async requestNonce(options) {
|
|
@@ -1994,7 +2130,7 @@ var Openid4vciClient = class {
|
|
|
1994
2130
|
};
|
|
1995
2131
|
}
|
|
1996
2132
|
/**
|
|
1997
|
-
* @throws Openid4vciRetrieveCredentialsError - if an
|
|
2133
|
+
* @throws Openid4vciRetrieveCredentialsError - if an unsuccessful response or the response couldn't be parsed as credential response
|
|
1998
2134
|
* @throws ValidationError - if validation of the credential request failed
|
|
1999
2135
|
* @throws Openid4vciError - if the `credentialConfigurationId` couldn't be found, or if the the format specific request couldn't be constructed
|
|
2000
2136
|
*/
|
|
@@ -2008,7 +2144,7 @@ var Openid4vciClient = class {
|
|
|
2008
2144
|
dpop
|
|
2009
2145
|
}) {
|
|
2010
2146
|
let credentialResponse;
|
|
2011
|
-
if (issuerMetadata.originalDraftVersion === "Draft15" /* Draft15 */) {
|
|
2147
|
+
if (issuerMetadata.originalDraftVersion === "Draft15" /* Draft15 */ || issuerMetadata.originalDraftVersion === "Draft16" /* Draft16 */) {
|
|
2012
2148
|
credentialResponse = await retrieveCredentialsWithCredentialConfigurationId({
|
|
2013
2149
|
accessToken,
|
|
2014
2150
|
credentialConfigurationId,
|
|
@@ -2045,7 +2181,25 @@ var Openid4vciClient = class {
|
|
|
2045
2181
|
return credentialResponse;
|
|
2046
2182
|
}
|
|
2047
2183
|
/**
|
|
2048
|
-
* @throws
|
|
2184
|
+
* @throws Openid4vciRetrieveCredentialsError - if an unsuccessful response or the response couldn't be parsed as credential response
|
|
2185
|
+
* @throws ValidationError - if validation of the credential request failed
|
|
2186
|
+
*/
|
|
2187
|
+
async retrieveDeferredCredentials(options) {
|
|
2188
|
+
const credentialResponse = await retrieveDeferredCredentials({
|
|
2189
|
+
...options,
|
|
2190
|
+
callbacks: this.options.callbacks
|
|
2191
|
+
});
|
|
2192
|
+
if (!credentialResponse.ok) {
|
|
2193
|
+
throw new Openid4vciRetrieveCredentialsError(
|
|
2194
|
+
`Error retrieving deferred credentials from '${options.issuerMetadata.credentialIssuer.credential_issuer}'`,
|
|
2195
|
+
credentialResponse,
|
|
2196
|
+
await credentialResponse.response.clone().text()
|
|
2197
|
+
);
|
|
2198
|
+
}
|
|
2199
|
+
return credentialResponse;
|
|
2200
|
+
}
|
|
2201
|
+
/**
|
|
2202
|
+
* @throws Openid4vciSendNotificationError - if an unsuccessful response
|
|
2049
2203
|
* @throws ValidationError - if validation of the notification request failed
|
|
2050
2204
|
*/
|
|
2051
2205
|
async sendNotification({
|
|
@@ -2055,7 +2209,7 @@ var Openid4vciClient = class {
|
|
|
2055
2209
|
accessToken,
|
|
2056
2210
|
dpop
|
|
2057
2211
|
}) {
|
|
2058
|
-
const notificationResponse = await
|
|
2212
|
+
const notificationResponse = await sendNotification({
|
|
2059
2213
|
accessToken,
|
|
2060
2214
|
issuerMetadata,
|
|
2061
2215
|
additionalRequestPayload,
|
|
@@ -2074,8 +2228,8 @@ var Openid4vciClient = class {
|
|
|
2074
2228
|
};
|
|
2075
2229
|
|
|
2076
2230
|
// src/Openid4vciIssuer.ts
|
|
2077
|
-
var
|
|
2078
|
-
var
|
|
2231
|
+
var import_oauth220 = require("@openid4vc/oauth2");
|
|
2232
|
+
var import_utils21 = require("@openid4vc/utils");
|
|
2079
2233
|
|
|
2080
2234
|
// src/credential-request/credential-response.ts
|
|
2081
2235
|
var import_utils18 = require("@openid4vc/utils");
|
|
@@ -2086,6 +2240,8 @@ function createCredentialResponse(options) {
|
|
|
2086
2240
|
credential: options.credential,
|
|
2087
2241
|
credentials: options.credentials,
|
|
2088
2242
|
notification_id: options.notificationId,
|
|
2243
|
+
transaction_id: options.transactionId,
|
|
2244
|
+
interval: options.interval,
|
|
2089
2245
|
// NOTE `format` is removed in draft 13. For now if a format was requested
|
|
2090
2246
|
// we just always return it in the response as well.
|
|
2091
2247
|
format: options.credentialRequest.format?.format,
|
|
@@ -2093,6 +2249,14 @@ function createCredentialResponse(options) {
|
|
|
2093
2249
|
});
|
|
2094
2250
|
return credentialResponse;
|
|
2095
2251
|
}
|
|
2252
|
+
function createDeferredCredentialResponse(options) {
|
|
2253
|
+
return (0, import_utils18.parseWithErrorHandling)(zDeferredCredentialResponse, {
|
|
2254
|
+
credentials: options.credentials,
|
|
2255
|
+
notification_id: options.notificationId,
|
|
2256
|
+
interval: options.interval,
|
|
2257
|
+
...options.additionalPayload
|
|
2258
|
+
});
|
|
2259
|
+
}
|
|
2096
2260
|
|
|
2097
2261
|
// src/credential-request/parse-credential-request.ts
|
|
2098
2262
|
var import_utils19 = require("@openid4vc/utils");
|
|
@@ -2156,6 +2320,19 @@ function parseCredentialRequest(options) {
|
|
|
2156
2320
|
};
|
|
2157
2321
|
}
|
|
2158
2322
|
|
|
2323
|
+
// src/credential-request/parse-deferred-credential-request.ts
|
|
2324
|
+
var import_utils20 = require("@openid4vc/utils");
|
|
2325
|
+
function parseDeferredCredentialRequest(options) {
|
|
2326
|
+
const deferredCredentialRequest = (0, import_utils20.parseWithErrorHandling)(
|
|
2327
|
+
zDeferredCredentialRequest,
|
|
2328
|
+
options.deferredCredentialRequest,
|
|
2329
|
+
"Error validating credential request"
|
|
2330
|
+
);
|
|
2331
|
+
return {
|
|
2332
|
+
deferredCredentialRequest
|
|
2333
|
+
};
|
|
2334
|
+
}
|
|
2335
|
+
|
|
2159
2336
|
// src/formats/proof-type/attestation/attestation-proof-type.ts
|
|
2160
2337
|
async function verifyCredentialRequestAttestationProof(options) {
|
|
2161
2338
|
const verificationResult = await verifyKeyAttestationJwt({
|
|
@@ -2171,7 +2348,7 @@ var Openid4vciIssuer = class {
|
|
|
2171
2348
|
this.options = options;
|
|
2172
2349
|
}
|
|
2173
2350
|
getCredentialIssuerMetadataDraft11(credentialIssuerMetadata) {
|
|
2174
|
-
return (0,
|
|
2351
|
+
return (0, import_utils21.parseWithErrorHandling)(zCredentialIssuerMetadataWithDraft11, credentialIssuerMetadata);
|
|
2175
2352
|
}
|
|
2176
2353
|
getKnownCredentialConfigurationsSupported(credentialIssuerMetadata) {
|
|
2177
2354
|
return extractKnownCredentialConfigurationSupportedFormats(
|
|
@@ -2182,7 +2359,7 @@ var Openid4vciIssuer = class {
|
|
|
2182
2359
|
* Create issuer metadata and validates the structure is correct
|
|
2183
2360
|
*/
|
|
2184
2361
|
createCredentialIssuerMetadata(credentialIssuerMetadata) {
|
|
2185
|
-
return (0,
|
|
2362
|
+
return (0, import_utils21.parseWithErrorHandling)(
|
|
2186
2363
|
zCredentialIssuerMetadata,
|
|
2187
2364
|
credentialIssuerMetadata,
|
|
2188
2365
|
"Error validating credential issuer metadata"
|
|
@@ -2215,12 +2392,12 @@ var Openid4vciIssuer = class {
|
|
|
2215
2392
|
now: options.now
|
|
2216
2393
|
});
|
|
2217
2394
|
} catch (error) {
|
|
2218
|
-
throw new
|
|
2395
|
+
throw new import_oauth220.Oauth2ServerErrorResponseError(
|
|
2219
2396
|
{
|
|
2220
|
-
error:
|
|
2397
|
+
error: import_oauth220.Oauth2ErrorCodes.InvalidProof,
|
|
2221
2398
|
error_description: (
|
|
2222
|
-
//
|
|
2223
|
-
error instanceof
|
|
2399
|
+
// TODO: error should have a internalErrorMessage and a publicErrorMessage
|
|
2400
|
+
error instanceof import_oauth220.Oauth2JwtVerificationError || error instanceof Openid4vciError ? error.message : "Invalid proof"
|
|
2224
2401
|
)
|
|
2225
2402
|
},
|
|
2226
2403
|
{
|
|
@@ -2244,12 +2421,12 @@ var Openid4vciIssuer = class {
|
|
|
2244
2421
|
now: options.now
|
|
2245
2422
|
});
|
|
2246
2423
|
} catch (error) {
|
|
2247
|
-
throw new
|
|
2424
|
+
throw new import_oauth220.Oauth2ServerErrorResponseError(
|
|
2248
2425
|
{
|
|
2249
|
-
error:
|
|
2426
|
+
error: import_oauth220.Oauth2ErrorCodes.InvalidProof,
|
|
2250
2427
|
error_description: (
|
|
2251
|
-
//
|
|
2252
|
-
error instanceof
|
|
2428
|
+
// TODO: error should have a internalErrorMessage and a publicErrorMessage
|
|
2429
|
+
error instanceof import_oauth220.Oauth2JwtVerificationError || error instanceof Openid4vciError ? error.message : "Invalid proof"
|
|
2253
2430
|
)
|
|
2254
2431
|
},
|
|
2255
2432
|
{
|
|
@@ -2267,12 +2444,12 @@ var Openid4vciIssuer = class {
|
|
|
2267
2444
|
try {
|
|
2268
2445
|
return parseCredentialRequest(options);
|
|
2269
2446
|
} catch (error) {
|
|
2270
|
-
throw new
|
|
2447
|
+
throw new import_oauth220.Oauth2ServerErrorResponseError(
|
|
2271
2448
|
{
|
|
2272
|
-
error:
|
|
2449
|
+
error: import_oauth220.Oauth2ErrorCodes.InvalidCredentialRequest,
|
|
2273
2450
|
error_description: (
|
|
2274
2451
|
// TODO: error should have a internalErrorMessage and a publicErrorMessage
|
|
2275
|
-
error instanceof
|
|
2452
|
+
error instanceof import_utils21.ValidationError ? error.message : "Invalid request"
|
|
2276
2453
|
)
|
|
2277
2454
|
},
|
|
2278
2455
|
{
|
|
@@ -2282,12 +2459,37 @@ var Openid4vciIssuer = class {
|
|
|
2282
2459
|
);
|
|
2283
2460
|
}
|
|
2284
2461
|
}
|
|
2462
|
+
/**
|
|
2463
|
+
* @throws Oauth2ServerErrorResponseError - when validation of the deferred credential request fails
|
|
2464
|
+
*/
|
|
2465
|
+
parseDeferredCredentialRequest(options) {
|
|
2466
|
+
try {
|
|
2467
|
+
return parseDeferredCredentialRequest(options);
|
|
2468
|
+
} catch (error) {
|
|
2469
|
+
throw new import_oauth220.Oauth2ServerErrorResponseError(
|
|
2470
|
+
{
|
|
2471
|
+
error: import_oauth220.Oauth2ErrorCodes.InvalidCredentialRequest,
|
|
2472
|
+
error_description: error instanceof import_utils21.ValidationError ? error.message : "Invalid request"
|
|
2473
|
+
},
|
|
2474
|
+
{
|
|
2475
|
+
internalMessage: "Error parsing deferred credential request",
|
|
2476
|
+
cause: error
|
|
2477
|
+
}
|
|
2478
|
+
);
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2285
2481
|
/**
|
|
2286
2482
|
* @throws ValidationError - when validation of the credential response fails
|
|
2287
2483
|
*/
|
|
2288
2484
|
createCredentialResponse(options) {
|
|
2289
2485
|
return createCredentialResponse(options);
|
|
2290
2486
|
}
|
|
2487
|
+
/**
|
|
2488
|
+
* @throws ValidationError - when validation of the credential response fails
|
|
2489
|
+
*/
|
|
2490
|
+
createDeferredCredentialResponse(options) {
|
|
2491
|
+
return createDeferredCredentialResponse(options);
|
|
2492
|
+
}
|
|
2291
2493
|
/**
|
|
2292
2494
|
* @throws ValidationError - when validation of the nonce response fails
|
|
2293
2495
|
*/
|
|
@@ -2295,14 +2497,14 @@ var Openid4vciIssuer = class {
|
|
|
2295
2497
|
return createNonceResponse(options);
|
|
2296
2498
|
}
|
|
2297
2499
|
async verifyWalletAttestation(options) {
|
|
2298
|
-
return new
|
|
2500
|
+
return new import_oauth220.Oauth2AuthorizationServer({
|
|
2299
2501
|
callbacks: this.options.callbacks
|
|
2300
2502
|
}).verifyClientAttestation(options);
|
|
2301
2503
|
}
|
|
2302
2504
|
};
|
|
2303
2505
|
|
|
2304
2506
|
// src/Openid4vciWalletProvider.ts
|
|
2305
|
-
var
|
|
2507
|
+
var import_oauth221 = require("@openid4vc/oauth2");
|
|
2306
2508
|
var Openid4vciWalletProvider = class {
|
|
2307
2509
|
constructor(options) {
|
|
2308
2510
|
this.options = options;
|
|
@@ -2316,7 +2518,7 @@ var Openid4vciWalletProvider = class {
|
|
|
2316
2518
|
wallet_name: options.walletName,
|
|
2317
2519
|
wallet_link: options.walletLink
|
|
2318
2520
|
};
|
|
2319
|
-
return await (0,
|
|
2521
|
+
return await (0, import_oauth221.createClientAttestationJwt)({
|
|
2320
2522
|
...options,
|
|
2321
2523
|
callbacks: this.options.callbacks,
|
|
2322
2524
|
additionalPayload
|