@openid4vc/openid4vp 0.3.0-alpha-20250322171044 → 0.3.0-alpha-20250324175730
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 +37 -26
- package/dist/index.d.ts +37 -26
- package/dist/index.js +175 -87
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +194 -105
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -182,7 +182,7 @@ var zOpenid4vpAuthorizationRequest = import_zod4.z.object({
|
|
|
182
182
|
client_metadata_uri: import_utils3.zHttpsUrl.optional(),
|
|
183
183
|
state: import_zod4.z.string().optional(),
|
|
184
184
|
transaction_data: import_zod4.z.array(import_zod4.z.string().base64url()).optional(),
|
|
185
|
-
trust_chain: import_zod4.z.
|
|
185
|
+
trust_chain: import_zod4.z.array(import_zod4.z.string()).nonempty().optional(),
|
|
186
186
|
client_id_scheme: import_zod4.z.enum([
|
|
187
187
|
"pre-registered",
|
|
188
188
|
"redirect_uri",
|
|
@@ -222,10 +222,11 @@ var zOpenid4vpAuthorizationRequestDcApi = zOpenid4vpAuthorizationRequest.pick({
|
|
|
222
222
|
scope: import_zod5.z.never().optional()
|
|
223
223
|
// TODO: should we disallow any properties specifically, such as redirect_uri and response_uri?
|
|
224
224
|
});
|
|
225
|
+
function isOpenid4vpResponseModeDcApi(responseMode) {
|
|
226
|
+
return responseMode !== void 0 && zOpenid4vpResponseModeDcApi.options.includes(responseMode);
|
|
227
|
+
}
|
|
225
228
|
function isOpenid4vpAuthorizationRequestDcApi(request) {
|
|
226
|
-
return request.response_mode
|
|
227
|
-
request.response_mode
|
|
228
|
-
);
|
|
229
|
+
return isOpenid4vpResponseModeDcApi(request.response_mode);
|
|
229
230
|
}
|
|
230
231
|
|
|
231
232
|
// src/client-identifier-scheme/z-client-id-scheme.ts
|
|
@@ -240,6 +241,15 @@ var zClientIdScheme = import_zod6.z.enum([
|
|
|
240
241
|
"x509_san_uri",
|
|
241
242
|
"web-origin"
|
|
242
243
|
]);
|
|
244
|
+
var zClientIdToClientIdScheme = import_zod6.z.union(
|
|
245
|
+
[
|
|
246
|
+
import_zod6.z.string({ message: "client_id MUST be a string" }).includes(":").transform((clientId) => clientId.split(":")[0]).pipe(zClientIdScheme.exclude(["pre-registered"])),
|
|
247
|
+
import_zod6.z.string().refine((clientId) => clientId.includes(":") === false).transform(() => "pre-registered")
|
|
248
|
+
],
|
|
249
|
+
{
|
|
250
|
+
message: `client_id must either start with a known prefix followed by ':' or contain no ':'. Known prefixes are ${zClientIdScheme.exclude(["pre-registered"]).options.join(", ")}`
|
|
251
|
+
}
|
|
252
|
+
);
|
|
243
253
|
var zLegacyClientIdScheme = import_zod6.z.enum([
|
|
244
254
|
"pre-registered",
|
|
245
255
|
"redirect_uri",
|
|
@@ -249,58 +259,80 @@ var zLegacyClientIdScheme = import_zod6.z.enum([
|
|
|
249
259
|
"x509_san_dns",
|
|
250
260
|
"x509_san_uri"
|
|
251
261
|
]);
|
|
262
|
+
var zLegacyClientIdSchemeToClientIdScheme = zLegacyClientIdScheme.optional().default("pre-registered").transform((clientIdScheme) => clientIdScheme === "entity_id" ? "https" : clientIdScheme);
|
|
252
263
|
|
|
253
264
|
// src/client-identifier-scheme/parse-client-identifier-scheme.ts
|
|
254
265
|
function getOpenid4vpClientId(options) {
|
|
255
|
-
if (
|
|
256
|
-
if (!options.
|
|
266
|
+
if (isOpenid4vpResponseModeDcApi(options.responseMode)) {
|
|
267
|
+
if (!options.clientId) {
|
|
268
|
+
if (!options.origin) {
|
|
269
|
+
throw new import_oauth23.Oauth2ServerErrorResponseError({
|
|
270
|
+
error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
|
|
271
|
+
error_description: "Failed to parse client identifier. 'origin' is required for requests without a client_id and response_mode 'dc_api' and 'dc_api.jwt'"
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
return {
|
|
275
|
+
clientIdScheme: "web-origin",
|
|
276
|
+
clientId: `web-origin:${options.origin}`
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
const parsedClientIdScheme2 = zClientIdToClientIdScheme.safeParse(options.clientId);
|
|
280
|
+
if (!parsedClientIdScheme2.success) {
|
|
257
281
|
throw new import_oauth23.Oauth2ServerErrorResponseError({
|
|
258
282
|
error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
|
|
259
|
-
error_description:
|
|
283
|
+
error_description: `Failed to parse client identifier. Unsupported client_id '${options.clientId}'.`
|
|
260
284
|
});
|
|
261
285
|
}
|
|
262
286
|
return {
|
|
263
|
-
clientId: options.
|
|
287
|
+
clientId: options.clientId,
|
|
288
|
+
clientIdScheme: parsedClientIdScheme2.data
|
|
264
289
|
};
|
|
265
290
|
}
|
|
266
|
-
if (!options.
|
|
291
|
+
if (!options.clientId) {
|
|
267
292
|
throw new import_oauth23.Oauth2ServerErrorResponseError({
|
|
268
293
|
error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
|
|
269
|
-
error_description: `Failed to parse client identifier. Missing required client_id parameter for response_mode '${options.
|
|
294
|
+
error_description: `Failed to parse client identifier. Missing required client_id parameter for response_mode '${options.responseMode}'.`
|
|
270
295
|
});
|
|
271
296
|
}
|
|
272
|
-
if (options.
|
|
273
|
-
const
|
|
274
|
-
if (!
|
|
297
|
+
if (options.legacyClientIdScheme) {
|
|
298
|
+
const parsedClientIdScheme2 = zLegacyClientIdSchemeToClientIdScheme.safeParse(options.legacyClientIdScheme);
|
|
299
|
+
if (!parsedClientIdScheme2.success) {
|
|
275
300
|
throw new import_oauth23.Oauth2ServerErrorResponseError({
|
|
276
301
|
error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
|
|
277
|
-
error_description: `Failed to parse client identifier. Unsupported client_id_scheme value '${options.
|
|
302
|
+
error_description: `Failed to parse client identifier. Unsupported client_id_scheme value '${options.legacyClientIdScheme}'.`
|
|
278
303
|
});
|
|
279
304
|
}
|
|
280
|
-
const clientIdScheme =
|
|
281
|
-
if (clientIdScheme === "https" || clientIdScheme === "did" || clientIdScheme === "pre-registered") {
|
|
282
|
-
return { clientId: options.authorizationRequestPayload.client_id };
|
|
283
|
-
}
|
|
305
|
+
const clientIdScheme = parsedClientIdScheme2.data;
|
|
284
306
|
return {
|
|
285
|
-
clientId: `${
|
|
286
|
-
|
|
307
|
+
clientId: clientIdScheme === "https" || clientIdScheme === "did" || clientIdScheme === "pre-registered" ? options.clientId : `${parsedClientIdScheme2.data}:${options.clientId}`,
|
|
308
|
+
clientIdScheme: parsedClientIdScheme2.data,
|
|
309
|
+
legacyClientId: options.clientId
|
|
287
310
|
};
|
|
288
311
|
}
|
|
312
|
+
const parsedClientIdScheme = zClientIdToClientIdScheme.safeParse(options.clientId);
|
|
313
|
+
if (!parsedClientIdScheme.success) {
|
|
314
|
+
throw new import_oauth23.Oauth2ServerErrorResponseError({
|
|
315
|
+
error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
|
|
316
|
+
error_description: `Failed to parse client identifier. Unsupported client_id '${options.clientId}'.`
|
|
317
|
+
});
|
|
318
|
+
}
|
|
289
319
|
return {
|
|
290
|
-
clientId: options.
|
|
320
|
+
clientId: options.clientId,
|
|
321
|
+
clientIdScheme: parsedClientIdScheme.data
|
|
291
322
|
};
|
|
292
323
|
}
|
|
293
|
-
function
|
|
324
|
+
function validateOpenid4vpClientId(options, parserConfig) {
|
|
294
325
|
const { authorizationRequestPayload, jar, origin } = options;
|
|
295
326
|
const parserConfigWithDefaults = {
|
|
296
327
|
supportedSchemes: parserConfig?.supportedSchemes || Object.values(zClientIdScheme.options)
|
|
297
328
|
};
|
|
298
|
-
const { clientId, legacyClientId } = getOpenid4vpClientId({
|
|
299
|
-
authorizationRequestPayload,
|
|
329
|
+
const { clientId, legacyClientId, clientIdScheme } = getOpenid4vpClientId({
|
|
330
|
+
clientId: authorizationRequestPayload.client_id,
|
|
331
|
+
legacyClientIdScheme: authorizationRequestPayload.client_id_scheme,
|
|
332
|
+
responseMode: authorizationRequestPayload.response_mode,
|
|
300
333
|
origin
|
|
301
334
|
});
|
|
302
|
-
|
|
303
|
-
if (colonIndex === -1) {
|
|
335
|
+
if (clientIdScheme === "pre-registered") {
|
|
304
336
|
return {
|
|
305
337
|
scheme: "pre-registered",
|
|
306
338
|
identifier: clientId,
|
|
@@ -309,16 +341,15 @@ function parseClientIdentifier(options, parserConfig) {
|
|
|
309
341
|
clientMetadata: authorizationRequestPayload.client_metadata
|
|
310
342
|
};
|
|
311
343
|
}
|
|
312
|
-
const
|
|
344
|
+
const colonIndex = clientId.indexOf(":");
|
|
313
345
|
const identifierPart = clientId.substring(colonIndex + 1);
|
|
314
|
-
if (!parserConfigWithDefaults.supportedSchemes.includes(
|
|
346
|
+
if (!parserConfigWithDefaults.supportedSchemes.includes(clientIdScheme)) {
|
|
315
347
|
throw new import_oauth23.Oauth2ServerErrorResponseError({
|
|
316
348
|
error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
|
|
317
|
-
error_description: `Unsupported client identifier scheme. ${
|
|
349
|
+
error_description: `Unsupported client identifier scheme. ${clientIdScheme} is not supported.`
|
|
318
350
|
});
|
|
319
351
|
}
|
|
320
|
-
|
|
321
|
-
if (scheme === "https") {
|
|
352
|
+
if (clientIdScheme === "https") {
|
|
322
353
|
if (!import_utils4.zHttpsUrl.safeParse(clientId).success) {
|
|
323
354
|
throw new import_oauth23.Oauth2ServerErrorResponseError(
|
|
324
355
|
{
|
|
@@ -330,15 +361,27 @@ function parseClientIdentifier(options, parserConfig) {
|
|
|
330
361
|
}
|
|
331
362
|
);
|
|
332
363
|
}
|
|
364
|
+
if (!jar) {
|
|
365
|
+
throw new import_oauth23.Oauth2ServerErrorResponseError({
|
|
366
|
+
error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
|
|
367
|
+
error_description: 'Using client identifier scheme "https" requires a signed JAR request.'
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
if (jar.signer.method !== "federation") {
|
|
371
|
+
throw new import_oauth23.Oauth2ServerErrorResponseError({
|
|
372
|
+
error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
|
|
373
|
+
error_description: "Something went wrong. The JWT signer method is not federation but the client identifier scheme is https."
|
|
374
|
+
});
|
|
375
|
+
}
|
|
333
376
|
return {
|
|
334
|
-
scheme,
|
|
377
|
+
scheme: clientIdScheme,
|
|
335
378
|
identifier: clientId,
|
|
336
379
|
originalValue: clientId,
|
|
337
380
|
legacyClientId,
|
|
338
381
|
trustChain: authorizationRequestPayload.trust_chain
|
|
339
382
|
};
|
|
340
383
|
}
|
|
341
|
-
if (
|
|
384
|
+
if (clientIdScheme === "redirect_uri") {
|
|
342
385
|
if (jar) {
|
|
343
386
|
throw new import_oauth23.Oauth2ServerErrorResponseError({
|
|
344
387
|
error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
|
|
@@ -352,20 +395,26 @@ function parseClientIdentifier(options, parserConfig) {
|
|
|
352
395
|
});
|
|
353
396
|
}
|
|
354
397
|
return {
|
|
355
|
-
scheme,
|
|
398
|
+
scheme: clientIdScheme,
|
|
356
399
|
identifier: identifierPart,
|
|
357
400
|
originalValue: clientId,
|
|
358
401
|
legacyClientId,
|
|
359
402
|
redirectUri: authorizationRequestPayload.redirect_uri ?? authorizationRequestPayload.response_uri
|
|
360
403
|
};
|
|
361
404
|
}
|
|
362
|
-
if (
|
|
405
|
+
if (clientIdScheme === "did") {
|
|
363
406
|
if (!jar) {
|
|
364
407
|
throw new import_oauth23.Oauth2ServerErrorResponseError({
|
|
365
408
|
error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
|
|
366
409
|
error_description: 'Using client identifier scheme "did" requires a signed JAR request.'
|
|
367
410
|
});
|
|
368
411
|
}
|
|
412
|
+
if (jar.signer.method !== "did") {
|
|
413
|
+
throw new import_oauth23.Oauth2ServerErrorResponseError({
|
|
414
|
+
error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
|
|
415
|
+
error_description: "Something went wrong. The JWT signer method is not did but the client identifier scheme is did."
|
|
416
|
+
});
|
|
417
|
+
}
|
|
369
418
|
if (!clientId.startsWith("did:")) {
|
|
370
419
|
throw new import_oauth23.Oauth2ServerErrorResponseError({
|
|
371
420
|
error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
|
|
@@ -385,14 +434,14 @@ function parseClientIdentifier(options, parserConfig) {
|
|
|
385
434
|
});
|
|
386
435
|
}
|
|
387
436
|
return {
|
|
388
|
-
scheme,
|
|
437
|
+
scheme: clientIdScheme,
|
|
389
438
|
identifier: clientId,
|
|
390
439
|
originalValue: clientId,
|
|
391
440
|
legacyClientId,
|
|
392
441
|
didUrl: jar.signer.publicJwk.kid
|
|
393
442
|
};
|
|
394
443
|
}
|
|
395
|
-
if (
|
|
444
|
+
if (clientIdScheme === "x509_san_dns" || clientIdScheme === "x509_san_uri") {
|
|
396
445
|
if (!jar) {
|
|
397
446
|
throw new import_oauth23.Oauth2ServerErrorResponseError({
|
|
398
447
|
error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
|
|
@@ -405,7 +454,7 @@ function parseClientIdentifier(options, parserConfig) {
|
|
|
405
454
|
error_description: "Something went wrong. The JWT signer method is not x5c but the client identifier scheme is x509_san_dns."
|
|
406
455
|
});
|
|
407
456
|
}
|
|
408
|
-
if (
|
|
457
|
+
if (clientIdScheme === "x509_san_dns") {
|
|
409
458
|
if (!options.callbacks.getX509CertificateMetadata) {
|
|
410
459
|
throw new import_oauth23.Oauth2ServerErrorResponseError(
|
|
411
460
|
{
|
|
@@ -432,7 +481,7 @@ function parseClientIdentifier(options, parserConfig) {
|
|
|
432
481
|
});
|
|
433
482
|
}
|
|
434
483
|
}
|
|
435
|
-
} else if (
|
|
484
|
+
} else if (clientIdScheme === "x509_san_uri") {
|
|
436
485
|
if (!options.callbacks.getX509CertificateMetadata) {
|
|
437
486
|
throw new import_oauth23.Oauth2ServerErrorResponseError(
|
|
438
487
|
{
|
|
@@ -461,23 +510,23 @@ function parseClientIdentifier(options, parserConfig) {
|
|
|
461
510
|
}
|
|
462
511
|
}
|
|
463
512
|
return {
|
|
464
|
-
scheme,
|
|
513
|
+
scheme: clientIdScheme,
|
|
465
514
|
identifier: identifierPart,
|
|
466
515
|
originalValue: clientId,
|
|
467
516
|
legacyClientId,
|
|
468
517
|
x5c: jar.signer.x5c
|
|
469
518
|
};
|
|
470
519
|
}
|
|
471
|
-
if (
|
|
520
|
+
if (clientIdScheme === "web-origin") {
|
|
472
521
|
return {
|
|
473
|
-
scheme,
|
|
522
|
+
scheme: clientIdScheme,
|
|
474
523
|
identifier: identifierPart,
|
|
475
524
|
originalValue: clientId,
|
|
476
525
|
legacyClientId,
|
|
477
526
|
clientMetadata: authorizationRequestPayload.client_metadata
|
|
478
527
|
};
|
|
479
528
|
}
|
|
480
|
-
if (
|
|
529
|
+
if (clientIdScheme === "verifier_attestation") {
|
|
481
530
|
if (!jar) {
|
|
482
531
|
throw new import_oauth23.Oauth2ServerErrorResponseError({
|
|
483
532
|
error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
|
|
@@ -486,7 +535,7 @@ function parseClientIdentifier(options, parserConfig) {
|
|
|
486
535
|
}
|
|
487
536
|
}
|
|
488
537
|
return {
|
|
489
|
-
scheme,
|
|
538
|
+
scheme: clientIdScheme,
|
|
490
539
|
identifier: identifierPart,
|
|
491
540
|
legacyClientId,
|
|
492
541
|
originalValue: clientId
|
|
@@ -889,7 +938,7 @@ function parseOpenid4vpAuthorizationRequest(options) {
|
|
|
889
938
|
// src/authorization-request/resolve-authorization-request.ts
|
|
890
939
|
var import_oauth219 = require("@openid4vc/oauth2");
|
|
891
940
|
var import_utils14 = require("@openid4vc/utils");
|
|
892
|
-
var
|
|
941
|
+
var import_zod14 = __toESM(require("zod"));
|
|
893
942
|
|
|
894
943
|
// src/fetch-client-metadata.ts
|
|
895
944
|
var import_oauth213 = require("@openid4vc/oauth2");
|
|
@@ -920,6 +969,7 @@ async function fetchClientMetadata(options) {
|
|
|
920
969
|
|
|
921
970
|
// src/jar/handle-jar-request/verify-jar-request.ts
|
|
922
971
|
var import_oauth217 = require("@openid4vc/oauth2");
|
|
972
|
+
var import_zod12 = __toESM(require("zod"));
|
|
923
973
|
|
|
924
974
|
// src/version.ts
|
|
925
975
|
var import_oauth214 = require("@openid4vc/oauth2");
|
|
@@ -1024,6 +1074,8 @@ var zJarRequestObjectPayload = import_zod11.z.object({
|
|
|
1024
1074
|
}).passthrough();
|
|
1025
1075
|
|
|
1026
1076
|
// src/jar/handle-jar-request/verify-jar-request.ts
|
|
1077
|
+
var zSignedAuthorizationRequestJwtHeaderTyp = import_zod12.default.literal("oauth-authz-req+jwt");
|
|
1078
|
+
var signedAuthorizationRequestJwtHeaderTyp = zSignedAuthorizationRequestJwtHeaderTyp.value;
|
|
1027
1079
|
async function verifyJarRequest(options) {
|
|
1028
1080
|
const { callbacks, wallet = {} } = options;
|
|
1029
1081
|
const jarRequestParams = validateJarRequestParams(options);
|
|
@@ -1103,7 +1155,41 @@ async function decryptJarRequest(options) {
|
|
|
1103
1155
|
async function verifyJarRequestObject(options) {
|
|
1104
1156
|
const { decryptedRequestObject, callbacks } = options;
|
|
1105
1157
|
const jwt = (0, import_oauth217.decodeJwt)({ jwt: decryptedRequestObject, payloadSchema: zJarRequestObjectPayload });
|
|
1106
|
-
|
|
1158
|
+
let jwtSigner;
|
|
1159
|
+
const { clientIdScheme } = getOpenid4vpClientId({
|
|
1160
|
+
responseMode: jwt.payload.response_mode,
|
|
1161
|
+
clientId: jwt.payload.client_id,
|
|
1162
|
+
legacyClientIdScheme: jwt.payload.client_id_scheme
|
|
1163
|
+
});
|
|
1164
|
+
const clientIdToSignerMethod = {
|
|
1165
|
+
did: ["did"],
|
|
1166
|
+
"pre-registered": ["custom", "did", "jwk"],
|
|
1167
|
+
"web-origin": [],
|
|
1168
|
+
// no signing allowed
|
|
1169
|
+
redirect_uri: [],
|
|
1170
|
+
// no signing allowed
|
|
1171
|
+
// Not 100% sure which one are allowed?
|
|
1172
|
+
verifier_attestation: ["did", "federation", "jwk", "x5c", "custom"],
|
|
1173
|
+
x509_san_dns: ["x5c"],
|
|
1174
|
+
x509_san_uri: ["x5c"],
|
|
1175
|
+
// Handled separately
|
|
1176
|
+
https: []
|
|
1177
|
+
};
|
|
1178
|
+
if (clientIdScheme === "https") {
|
|
1179
|
+
if (!jwt.header.kid) {
|
|
1180
|
+
throw new import_oauth217.Oauth2Error(
|
|
1181
|
+
`When OpenID Federation is used for signed authorization request, the 'kid' parameter is required.`
|
|
1182
|
+
);
|
|
1183
|
+
}
|
|
1184
|
+
jwtSigner = {
|
|
1185
|
+
method: "federation",
|
|
1186
|
+
alg: jwt.header.alg,
|
|
1187
|
+
trustChain: jwt.payload.trust_chain,
|
|
1188
|
+
kid: jwt.header.kid
|
|
1189
|
+
};
|
|
1190
|
+
} else {
|
|
1191
|
+
jwtSigner = (0, import_oauth217.jwtSignerFromJwt)({ ...jwt, allowedSignerMethods: clientIdToSignerMethod[clientIdScheme] });
|
|
1192
|
+
}
|
|
1107
1193
|
const { signer } = await (0, import_oauth217.verifyJwt)({
|
|
1108
1194
|
verifyJwtCallback: callbacks.verifyJwt,
|
|
1109
1195
|
compact: decryptedRequestObject,
|
|
@@ -1130,13 +1216,13 @@ var import_oauth218 = require("@openid4vc/oauth2");
|
|
|
1130
1216
|
var import_utils13 = require("@openid4vc/utils");
|
|
1131
1217
|
|
|
1132
1218
|
// src/transaction-data/z-transaction-data.ts
|
|
1133
|
-
var
|
|
1134
|
-
var zTransactionEntry =
|
|
1135
|
-
type:
|
|
1136
|
-
credential_ids:
|
|
1137
|
-
transaction_data_hashes_alg:
|
|
1219
|
+
var import_zod13 = require("zod");
|
|
1220
|
+
var zTransactionEntry = import_zod13.z.object({
|
|
1221
|
+
type: import_zod13.z.string(),
|
|
1222
|
+
credential_ids: import_zod13.z.array(import_zod13.z.string()).nonempty(),
|
|
1223
|
+
transaction_data_hashes_alg: import_zod13.z.array(import_zod13.z.string()).optional()
|
|
1138
1224
|
}).passthrough();
|
|
1139
|
-
var zTransactionData =
|
|
1225
|
+
var zTransactionData = import_zod13.z.array(zTransactionEntry);
|
|
1140
1226
|
|
|
1141
1227
|
// src/transaction-data/parse-transaction-data.ts
|
|
1142
1228
|
function parseTransactionData(options) {
|
|
@@ -1161,7 +1247,7 @@ async function resolveOpenid4vpAuthorizationRequest(options) {
|
|
|
1161
1247
|
const { wallet, callbacks, origin, disableOriginValidation } = options;
|
|
1162
1248
|
let authorizationRequestPayload;
|
|
1163
1249
|
const parsed = (0, import_utils14.parseWithErrorHandling)(
|
|
1164
|
-
|
|
1250
|
+
import_zod14.default.union([zOpenid4vpAuthorizationRequestDcApi, zOpenid4vpAuthorizationRequest, zJarAuthorizationRequest]),
|
|
1165
1251
|
options.authorizationRequestPayload,
|
|
1166
1252
|
"Invalid authorization request. Could not parse openid4vp authorization request as openid4vp or jar auth request."
|
|
1167
1253
|
);
|
|
@@ -1169,7 +1255,7 @@ async function resolveOpenid4vpAuthorizationRequest(options) {
|
|
|
1169
1255
|
if (isJarAuthorizationRequest(parsed)) {
|
|
1170
1256
|
jar = await verifyJarRequest({ jarRequestParams: parsed, callbacks, wallet });
|
|
1171
1257
|
const parsedJarAuthorizationRequestPayload = (0, import_utils14.parseWithErrorHandling)(
|
|
1172
|
-
|
|
1258
|
+
import_zod14.default.union([zOpenid4vpAuthorizationRequestDcApi, zOpenid4vpAuthorizationRequest]),
|
|
1173
1259
|
jar.authorizationRequestPayload,
|
|
1174
1260
|
"Invalid authorization request. Could not parse jar request payload as openid4vp auth request."
|
|
1175
1261
|
);
|
|
@@ -1193,7 +1279,7 @@ async function resolveOpenid4vpAuthorizationRequest(options) {
|
|
|
1193
1279
|
if (!isOpenid4vpAuthorizationRequestDcApi(authorizationRequestPayload) && !clientMetadata && authorizationRequestPayload.client_metadata_uri) {
|
|
1194
1280
|
clientMetadata = await fetchClientMetadata({ clientMetadataUri: authorizationRequestPayload.client_metadata_uri });
|
|
1195
1281
|
}
|
|
1196
|
-
const clientMeta =
|
|
1282
|
+
const clientMeta = validateOpenid4vpClientId({
|
|
1197
1283
|
authorizationRequestPayload: {
|
|
1198
1284
|
...authorizationRequestPayload,
|
|
1199
1285
|
client_metadata: clientMetadata
|
|
@@ -1283,7 +1369,7 @@ async function createJarmAuthorizationResponse(options) {
|
|
|
1283
1369
|
}
|
|
1284
1370
|
|
|
1285
1371
|
// src/jarm/jarm-response-mode.ts
|
|
1286
|
-
var
|
|
1372
|
+
var import_zod15 = require("zod");
|
|
1287
1373
|
var jarmResponseMode = [
|
|
1288
1374
|
"jwt",
|
|
1289
1375
|
"query.jwt",
|
|
@@ -1292,7 +1378,7 @@ var jarmResponseMode = [
|
|
|
1292
1378
|
"direct_post.jwt",
|
|
1293
1379
|
"dc_api.jwt"
|
|
1294
1380
|
];
|
|
1295
|
-
var zJarmResponseMode =
|
|
1381
|
+
var zJarmResponseMode = import_zod15.z.enum(jarmResponseMode);
|
|
1296
1382
|
var isJarmResponseMode = (responseMode) => {
|
|
1297
1383
|
return jarmResponseMode.includes(responseMode);
|
|
1298
1384
|
};
|
|
@@ -1495,17 +1581,17 @@ var import_oauth225 = require("@openid4vc/oauth2");
|
|
|
1495
1581
|
var import_utils19 = require("@openid4vc/utils");
|
|
1496
1582
|
|
|
1497
1583
|
// src/vp-token/z-vp-token.ts
|
|
1498
|
-
var
|
|
1499
|
-
var zVpTokenPexEntry =
|
|
1584
|
+
var import_zod16 = require("zod");
|
|
1585
|
+
var zVpTokenPexEntry = import_zod16.z.union([import_zod16.z.string(), import_zod16.z.record(import_zod16.z.any())], {
|
|
1500
1586
|
message: "pex vp_token entry must be a string or object"
|
|
1501
1587
|
});
|
|
1502
|
-
var zVpTokenPex =
|
|
1503
|
-
[zVpTokenPexEntry,
|
|
1588
|
+
var zVpTokenPex = import_zod16.z.union(
|
|
1589
|
+
[zVpTokenPexEntry, import_zod16.z.array(zVpTokenPexEntry).nonempty("Must have at least entry in vp_token array")],
|
|
1504
1590
|
{
|
|
1505
1591
|
message: "pex vp_token must be a string, object or array of strings and objects"
|
|
1506
1592
|
}
|
|
1507
1593
|
);
|
|
1508
|
-
var zVpTokenDcql =
|
|
1594
|
+
var zVpTokenDcql = import_zod16.z.record(import_zod16.z.union([import_zod16.z.string(), import_zod16.z.record(import_zod16.z.any())]), {
|
|
1509
1595
|
message: "dcql vp_token must be an object with keys referencing the dcql credential query id, and values the encoded (string or object) presentation"
|
|
1510
1596
|
});
|
|
1511
1597
|
var zVpToken = zVpTokenDcql.or(zVpTokenPex);
|
|
@@ -1579,23 +1665,23 @@ var import_utils21 = require("@openid4vc/utils");
|
|
|
1579
1665
|
|
|
1580
1666
|
// src/authorization-response/z-authorization-response.ts
|
|
1581
1667
|
var import_utils20 = require("@openid4vc/utils");
|
|
1582
|
-
var
|
|
1668
|
+
var import_zod18 = require("zod");
|
|
1583
1669
|
|
|
1584
1670
|
// src/models/z-pex.ts
|
|
1585
|
-
var
|
|
1586
|
-
var zPexPresentationDefinition =
|
|
1587
|
-
var zPexPresentationSubmission =
|
|
1671
|
+
var import_zod17 = require("zod");
|
|
1672
|
+
var zPexPresentationDefinition = import_zod17.z.record(import_zod17.z.any());
|
|
1673
|
+
var zPexPresentationSubmission = import_zod17.z.record(import_zod17.z.any());
|
|
1588
1674
|
|
|
1589
1675
|
// src/authorization-response/z-authorization-response.ts
|
|
1590
|
-
var zOpenid4vpAuthorizationResponse =
|
|
1591
|
-
state:
|
|
1592
|
-
id_token:
|
|
1676
|
+
var zOpenid4vpAuthorizationResponse = import_zod18.z.object({
|
|
1677
|
+
state: import_zod18.z.string().optional(),
|
|
1678
|
+
id_token: import_zod18.z.string().optional(),
|
|
1593
1679
|
vp_token: zVpToken,
|
|
1594
1680
|
presentation_submission: zPexPresentationSubmission.or(import_utils20.zStringToJson).optional(),
|
|
1595
|
-
refresh_token:
|
|
1596
|
-
token_type:
|
|
1597
|
-
access_token:
|
|
1598
|
-
expires_in:
|
|
1681
|
+
refresh_token: import_zod18.z.string().optional(),
|
|
1682
|
+
token_type: import_zod18.z.string().optional(),
|
|
1683
|
+
access_token: import_zod18.z.string().optional(),
|
|
1684
|
+
expires_in: import_zod18.z.number().optional()
|
|
1599
1685
|
}).passthrough();
|
|
1600
1686
|
|
|
1601
1687
|
// src/authorization-response/parse-authorization-response-payload.ts
|
|
@@ -1610,11 +1696,11 @@ function parseOpenid4VpAuthorizationResponsePayload(payload) {
|
|
|
1610
1696
|
// src/authorization-response/parse-jarm-authorization-response.ts
|
|
1611
1697
|
var import_oauth226 = require("@openid4vc/oauth2");
|
|
1612
1698
|
var import_utils22 = require("@openid4vc/utils");
|
|
1613
|
-
var
|
|
1699
|
+
var import_zod19 = __toESM(require("zod"));
|
|
1614
1700
|
async function parseJarmAuthorizationResponse(options) {
|
|
1615
1701
|
const { jarmResponseJwt, callbacks, authorizationRequestPayload, expectedClientId } = options;
|
|
1616
1702
|
const jarmAuthorizationResponseJwt = (0, import_utils22.parseWithErrorHandling)(
|
|
1617
|
-
|
|
1703
|
+
import_zod19.default.union([import_oauth226.zCompactJwt, import_oauth226.zCompactJwe]),
|
|
1618
1704
|
jarmResponseJwt,
|
|
1619
1705
|
"Invalid jarm authorization response jwt."
|
|
1620
1706
|
);
|
|
@@ -1653,7 +1739,9 @@ async function parseOpenid4vpAuthorizationResponse(options) {
|
|
|
1653
1739
|
const { authorizationResponse, callbacks, authorizationRequestPayload, origin } = options;
|
|
1654
1740
|
const expectedClientId = getOpenid4vpClientId({
|
|
1655
1741
|
origin,
|
|
1656
|
-
authorizationRequestPayload
|
|
1742
|
+
responseMode: authorizationRequestPayload.response_mode,
|
|
1743
|
+
clientId: authorizationRequestPayload.client_id,
|
|
1744
|
+
legacyClientIdScheme: authorizationRequestPayload.client_id_scheme
|
|
1657
1745
|
});
|
|
1658
1746
|
if (authorizationResponse.response) {
|
|
1659
1747
|
return parseJarmAuthorizationResponse({
|
|
@@ -1808,22 +1896,22 @@ var Openid4vpVerifier = class {
|
|
|
1808
1896
|
};
|
|
1809
1897
|
|
|
1810
1898
|
// src/models/z-credential-formats.ts
|
|
1811
|
-
var
|
|
1812
|
-
var zCredentialFormat =
|
|
1899
|
+
var import_zod20 = require("zod");
|
|
1900
|
+
var zCredentialFormat = import_zod20.z.enum(["jwt_vc_json", "ldp_vc", "ac_vc", "mso_mdoc", "dc+sd-jwt", "vc+sd-jwt"]);
|
|
1813
1901
|
|
|
1814
1902
|
// src/models/z-proof-formats.ts
|
|
1815
|
-
var
|
|
1816
|
-
var zProofFormat =
|
|
1903
|
+
var import_zod21 = require("zod");
|
|
1904
|
+
var zProofFormat = import_zod21.z.enum(["jwt_vp_json", "ldc_vp", "ac_vp", "dc+sd-jwt", "vc+sd-jwt", "mso_mdoc"]);
|
|
1817
1905
|
|
|
1818
1906
|
// src/models/z-wallet-metadata.ts
|
|
1819
|
-
var
|
|
1820
|
-
var zWalletMetadata =
|
|
1821
|
-
presentation_definition_uri_supported:
|
|
1907
|
+
var import_zod22 = require("zod");
|
|
1908
|
+
var zWalletMetadata = import_zod22.z.object({
|
|
1909
|
+
presentation_definition_uri_supported: import_zod22.z.optional(import_zod22.z.boolean()),
|
|
1822
1910
|
vp_formats_supported: zVpFormatsSupported,
|
|
1823
|
-
client_id_schemes_supported:
|
|
1824
|
-
request_object_signing_alg_values_supported:
|
|
1825
|
-
authorization_encryption_alg_values_supported:
|
|
1826
|
-
authorization_encryption_enc_values_supported:
|
|
1911
|
+
client_id_schemes_supported: import_zod22.z.optional(import_zod22.z.array(zClientIdScheme)),
|
|
1912
|
+
request_object_signing_alg_values_supported: import_zod22.z.optional(import_zod22.z.array(import_zod22.z.string())),
|
|
1913
|
+
authorization_encryption_alg_values_supported: import_zod22.z.optional(import_zod22.z.array(import_zod22.z.string())),
|
|
1914
|
+
authorization_encryption_enc_values_supported: import_zod22.z.optional(import_zod22.z.array(import_zod22.z.string()))
|
|
1827
1915
|
});
|
|
1828
1916
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1829
1917
|
0 && (module.exports = {
|