@openid4vc/openid4vp 0.3.0-alpha-20250224151429 → 0.3.0-alpha-20250225103926
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 +3259 -1544
- package/dist/index.d.ts +3259 -1544
- package/dist/index.js +87 -113
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +88 -112
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -47,16 +47,16 @@ var zJarmAuthResponseEncryptedOnly = z2.object({
|
|
|
47
47
|
|
|
48
48
|
// src/jarm/jarm-auth-response/jarm-validate-auth-response.ts
|
|
49
49
|
var jarmAuthResponseValidate = (options) => {
|
|
50
|
-
const {
|
|
51
|
-
if (!zJarmAuthResponse.safeParse(
|
|
50
|
+
const { clientId, authorizationResponse } = options;
|
|
51
|
+
if (!zJarmAuthResponse.safeParse(authorizationResponse).success) {
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
|
-
if (
|
|
54
|
+
if (clientId !== authorizationResponse.aud) {
|
|
55
55
|
throw new Oauth2Error(
|
|
56
|
-
`Invalid 'aud' claim in JARM authorization response. Expected '${
|
|
56
|
+
`Invalid 'aud' claim in JARM authorization response. Expected '${clientId}' received '${JSON.stringify(authorizationResponse.aud)}'.`
|
|
57
57
|
);
|
|
58
58
|
}
|
|
59
|
-
if (
|
|
59
|
+
if (authorizationResponse.exp !== void 0 && authorizationResponse.exp < dateToSeconds()) {
|
|
60
60
|
throw new Oauth2Error("Jarm auth response is expired.");
|
|
61
61
|
}
|
|
62
62
|
};
|
|
@@ -103,18 +103,14 @@ async function verifyJarmAuthorizationResponse(options) {
|
|
|
103
103
|
const jsonRequestData = JSON.parse(decryptedRequestData);
|
|
104
104
|
jarmAuthResponse = zJarmAuthResponseEncryptedOnly.parse(jsonRequestData);
|
|
105
105
|
}
|
|
106
|
-
const {
|
|
107
|
-
jarmAuthResponseValidate({
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
type = "encrypted";
|
|
113
|
-
} else {
|
|
114
|
-
type = "signed";
|
|
115
|
-
}
|
|
106
|
+
const { authorizationRequest } = await callbacks.getOpenid4vpAuthorizationRequest(jarmAuthResponse);
|
|
107
|
+
jarmAuthResponseValidate({
|
|
108
|
+
clientId: authorizationRequest.client_id,
|
|
109
|
+
authorizationResponse: jarmAuthResponse
|
|
110
|
+
});
|
|
111
|
+
const type = requestDataIsEncrypted && responseIsSigned ? "SignedEncrypted" /* SignedEncrypted */ : requestDataIsEncrypted ? "Encrypted" /* Encrypted */ : "Signed" /* Signed */;
|
|
116
112
|
const issuer = jarmAuthResponse.iss;
|
|
117
|
-
return {
|
|
113
|
+
return { authorizationRequest, jarmAuthResponse, type, issuer };
|
|
118
114
|
}
|
|
119
115
|
|
|
120
116
|
// src/jarm/metadata/z-jarm-client-metadata.ts
|
|
@@ -193,7 +189,7 @@ import {
|
|
|
193
189
|
jwtHeaderFromJwtSigner
|
|
194
190
|
} from "@openid4vc/oauth2";
|
|
195
191
|
async function createJarAuthRequest(options) {
|
|
196
|
-
const { jwtSigner,
|
|
192
|
+
const { jwtSigner, jweEncryptor, authRequestParams, requestUri, callbacks } = options;
|
|
197
193
|
let requestObjectJwt;
|
|
198
194
|
let encryptionJwk;
|
|
199
195
|
const { jwt, signerJwk } = await callbacks.signJwt(jwtSigner, {
|
|
@@ -201,8 +197,8 @@ async function createJarAuthRequest(options) {
|
|
|
201
197
|
payload: { ...options.additionalJwtPayload, ...authRequestParams }
|
|
202
198
|
});
|
|
203
199
|
requestObjectJwt = jwt;
|
|
204
|
-
if (
|
|
205
|
-
const encryptionResult = await callbacks.encryptJwe(
|
|
200
|
+
if (jweEncryptor) {
|
|
201
|
+
const encryptionResult = await callbacks.encryptJwe(jweEncryptor, requestObjectJwt);
|
|
206
202
|
requestObjectJwt = encryptionResult.jwe;
|
|
207
203
|
encryptionJwk = encryptionResult.encryptionJwk;
|
|
208
204
|
}
|
|
@@ -476,36 +472,36 @@ function isJarAuthRequest(request) {
|
|
|
476
472
|
|
|
477
473
|
// src/authorization-request/parse-authorization-request-params.ts
|
|
478
474
|
function parseOpenid4vpAuthorizationRequestPayload(options) {
|
|
479
|
-
const {
|
|
475
|
+
const { authorizationRequest } = options;
|
|
480
476
|
let provided = "params";
|
|
481
477
|
let params;
|
|
482
|
-
if (typeof
|
|
483
|
-
if (
|
|
484
|
-
const url = new URL2(
|
|
478
|
+
if (typeof authorizationRequest === "string") {
|
|
479
|
+
if (authorizationRequest.includes("://")) {
|
|
480
|
+
const url = new URL2(authorizationRequest);
|
|
485
481
|
params = Object.fromEntries(url.searchParams);
|
|
486
482
|
provided = "uri";
|
|
487
483
|
} else {
|
|
488
|
-
const decoded = decodeJwt2({ jwt:
|
|
484
|
+
const decoded = decodeJwt2({ jwt: authorizationRequest });
|
|
489
485
|
params = decoded.payload;
|
|
490
486
|
provided = "jwt";
|
|
491
487
|
}
|
|
492
488
|
} else {
|
|
493
|
-
params =
|
|
489
|
+
params = authorizationRequest;
|
|
494
490
|
}
|
|
495
491
|
const parsedRequest = parseWithErrorHandling3(
|
|
496
492
|
z10.union([zOpenid4vpAuthorizationRequest, zJarAuthRequest, zOpenid4vpAuthorizationRequestDcApi]),
|
|
497
493
|
params
|
|
498
494
|
);
|
|
499
|
-
if (
|
|
495
|
+
if (isJarAuthRequest(parsedRequest)) {
|
|
500
496
|
return {
|
|
501
|
-
type: "
|
|
497
|
+
type: "jar",
|
|
502
498
|
provided,
|
|
503
499
|
params: parsedRequest
|
|
504
500
|
};
|
|
505
501
|
}
|
|
506
|
-
if (
|
|
502
|
+
if (isOpenid4vpAuthorizationRequestDcApi(parsedRequest)) {
|
|
507
503
|
return {
|
|
508
|
-
type: "
|
|
504
|
+
type: "openid4vp_dc_api",
|
|
509
505
|
provided,
|
|
510
506
|
params: parsedRequest
|
|
511
507
|
};
|
|
@@ -523,36 +519,27 @@ import { parseWithErrorHandling as parseWithErrorHandling4 } from "@openid4vc/ut
|
|
|
523
519
|
import z14 from "zod";
|
|
524
520
|
|
|
525
521
|
// src/client-identifier-scheme/parse-client-identifier-scheme.ts
|
|
526
|
-
import { Oauth2ErrorCodes as Oauth2ErrorCodes3, Oauth2ServerErrorResponseError as Oauth2ServerErrorResponseError4 } from "@openid4vc/oauth2";
|
|
527
|
-
function getClientId(
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
if (request.client_id) {
|
|
531
|
-
return request.client_id;
|
|
532
|
-
}
|
|
533
|
-
if (!origin) {
|
|
522
|
+
import { Oauth2ErrorCodes as Oauth2ErrorCodes3, Oauth2ServerErrorResponseError as Oauth2ServerErrorResponseError4, getGlobalConfig } from "@openid4vc/oauth2";
|
|
523
|
+
function getClientId(options) {
|
|
524
|
+
if (isOpenid4vpAuthorizationRequestDcApi(options.request)) {
|
|
525
|
+
if (!options.origin) {
|
|
534
526
|
throw new Oauth2ServerErrorResponseError4({
|
|
535
527
|
error: Oauth2ErrorCodes3.InvalidRequest,
|
|
536
|
-
error_description:
|
|
528
|
+
error_description: "Failed to parse client identifier. 'origin' is required for requests with response_mode 'dc_api' and 'dc_api.jwt'"
|
|
537
529
|
});
|
|
538
530
|
}
|
|
539
|
-
return `web-origin:${origin}`;
|
|
531
|
+
if (!options.jar || !options.request.client_id) return `web-origin:${options.origin}`;
|
|
532
|
+
return options.request.client_id;
|
|
540
533
|
}
|
|
541
|
-
return request.client_id;
|
|
534
|
+
return options.request.client_id;
|
|
542
535
|
}
|
|
543
536
|
function parseClientIdentifier(options, parserConfig) {
|
|
544
537
|
const { request, jar } = options;
|
|
545
538
|
const isDcApiRequest = isOpenid4vpAuthorizationRequestDcApi(request);
|
|
546
|
-
const clientId = getClientId(
|
|
539
|
+
const clientId = getClientId(options);
|
|
547
540
|
const parserConfigWithDefaults = {
|
|
548
541
|
supportedSchemes: parserConfig?.supportedSchemes || Object.values(zClientIdScheme.options)
|
|
549
542
|
};
|
|
550
|
-
if (isDcApiRequest && !jar && request.client_id) {
|
|
551
|
-
throw new Oauth2ServerErrorResponseError4({
|
|
552
|
-
error: Oauth2ErrorCodes3.InvalidRequest,
|
|
553
|
-
error_description: `The 'client_id' parameter MUST be omitted in unsigned openid4vp dc api authorization requests.`
|
|
554
|
-
});
|
|
555
|
-
}
|
|
556
543
|
const colonIndex = clientId.indexOf(":");
|
|
557
544
|
if (colonIndex === -1) {
|
|
558
545
|
return {
|
|
@@ -578,7 +565,7 @@ function parseClientIdentifier(options, parserConfig) {
|
|
|
578
565
|
error_description: `The client identifier scheme 'https' is not supported when using the dc_api response mode.`
|
|
579
566
|
});
|
|
580
567
|
}
|
|
581
|
-
if (!clientId.startsWith("https://") && !clientId.startsWith("http://")) {
|
|
568
|
+
if (!clientId.startsWith("https://") && !(getGlobalConfig().allowInsecureUrls && clientId.startsWith("http://"))) {
|
|
582
569
|
throw new Oauth2ServerErrorResponseError4({
|
|
583
570
|
error: Oauth2ErrorCodes3.InvalidRequest,
|
|
584
571
|
error_description: "Invalid client identifier. Client identifier must start with https:// or http:// if allowInsecureUrls is true."
|
|
@@ -640,7 +627,7 @@ function parseClientIdentifier(options, parserConfig) {
|
|
|
640
627
|
scheme,
|
|
641
628
|
identifier: clientId,
|
|
642
629
|
originalValue: clientId,
|
|
643
|
-
|
|
630
|
+
didUrl: jar.signer.publicJwk.kid
|
|
644
631
|
};
|
|
645
632
|
}
|
|
646
633
|
if (scheme === "x509_san_dns" || scheme === "x509_san_uri") {
|
|
@@ -656,7 +643,17 @@ function parseClientIdentifier(options, parserConfig) {
|
|
|
656
643
|
error_description: "Something went wrong. The JWT signer method is not x5c but the client identifier scheme is x509_san_dns."
|
|
657
644
|
});
|
|
658
645
|
}
|
|
659
|
-
if (scheme === "x509_san_dns"
|
|
646
|
+
if (scheme === "x509_san_dns") {
|
|
647
|
+
if (!options.callbacks.getX509CertificateMetadata) {
|
|
648
|
+
throw new Oauth2ServerErrorResponseError4(
|
|
649
|
+
{
|
|
650
|
+
error: Oauth2ErrorCodes3.ServerError
|
|
651
|
+
},
|
|
652
|
+
{
|
|
653
|
+
internalMessage: "Missing required 'getX509CertificateMetadata' callback for verification of 'x509_san_dns' client id scheme"
|
|
654
|
+
}
|
|
655
|
+
);
|
|
656
|
+
}
|
|
660
657
|
const { sanDnsNames } = options.callbacks.getX509CertificateMetadata(jar.signer.x5c[0]);
|
|
661
658
|
if (!sanDnsNames.includes(identifierPart)) {
|
|
662
659
|
throw new Oauth2ServerErrorResponseError4({
|
|
@@ -671,7 +668,17 @@ function parseClientIdentifier(options, parserConfig) {
|
|
|
671
668
|
error_description: "Invalid client identifier. The fully qualified domain name of the redirect_uri value MUST match the Client Identifier without the prefix x509_san_dns."
|
|
672
669
|
});
|
|
673
670
|
}
|
|
674
|
-
} else if (scheme === "x509_san_uri"
|
|
671
|
+
} else if (scheme === "x509_san_uri") {
|
|
672
|
+
if (!options.callbacks.getX509CertificateMetadata) {
|
|
673
|
+
throw new Oauth2ServerErrorResponseError4(
|
|
674
|
+
{
|
|
675
|
+
error: Oauth2ErrorCodes3.ServerError
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
internalMessage: "Missing required 'getX509CertificateMetadata' callback for verification of 'x509_san_uri' client id scheme"
|
|
679
|
+
}
|
|
680
|
+
);
|
|
681
|
+
}
|
|
675
682
|
const { sanUriNames } = options.callbacks.getX509CertificateMetadata(jar.signer.x5c[0]);
|
|
676
683
|
if (!sanUriNames.includes(identifierPart)) {
|
|
677
684
|
throw new Oauth2ServerErrorResponseError4({
|
|
@@ -980,26 +987,26 @@ import {
|
|
|
980
987
|
jwtHeaderFromJwtSigner as jwtHeaderFromJwtSigner2
|
|
981
988
|
} from "@openid4vc/oauth2";
|
|
982
989
|
async function createJarmAuthResponse(options) {
|
|
983
|
-
const { jarmAuthResponse,
|
|
984
|
-
if (!jwtSigner &&
|
|
985
|
-
const { jwe } = await callbacks.encryptJwe(
|
|
990
|
+
const { jarmAuthResponse, jweEncryptor, jwtSigner, callbacks } = options;
|
|
991
|
+
if (!jwtSigner && jweEncryptor) {
|
|
992
|
+
const { jwe } = await callbacks.encryptJwe(jweEncryptor, JSON.stringify(jarmAuthResponse));
|
|
986
993
|
return { jarmAuthResponseJwt: jwe };
|
|
987
994
|
}
|
|
988
|
-
if (jwtSigner && !
|
|
995
|
+
if (jwtSigner && !jweEncryptor) {
|
|
989
996
|
const signed2 = await callbacks.signJwt(jwtSigner, {
|
|
990
997
|
header: jwtHeaderFromJwtSigner2(jwtSigner),
|
|
991
998
|
payload: jarmAuthResponse
|
|
992
999
|
});
|
|
993
1000
|
return { jarmAuthResponseJwt: signed2.jwt };
|
|
994
1001
|
}
|
|
995
|
-
if (!jwtSigner || !
|
|
1002
|
+
if (!jwtSigner || !jweEncryptor) {
|
|
996
1003
|
throw new Oauth2Error5("JWT signer and/or encryptor are required to create a JARM auth response.");
|
|
997
1004
|
}
|
|
998
1005
|
const signed = await callbacks.signJwt(jwtSigner, {
|
|
999
1006
|
header: jwtHeaderFromJwtSigner2(jwtSigner),
|
|
1000
1007
|
payload: jarmAuthResponse
|
|
1001
1008
|
});
|
|
1002
|
-
const encrypted = await callbacks.encryptJwe(
|
|
1009
|
+
const encrypted = await callbacks.encryptJwe(jweEncryptor, signed.jwt);
|
|
1003
1010
|
return { jarmAuthResponseJwt: encrypted.jwe };
|
|
1004
1011
|
}
|
|
1005
1012
|
|
|
@@ -1081,13 +1088,7 @@ async function createOpenid4vpAuthorizationResponse(options) {
|
|
|
1081
1088
|
}
|
|
1082
1089
|
if (!jarm) {
|
|
1083
1090
|
return {
|
|
1084
|
-
responseParams: openid4vpAuthResponseParams
|
|
1085
|
-
...isOpenid4vpAuthorizationRequestDcApi(openid4vpAuthResponseParams) && {
|
|
1086
|
-
dcApiResponseParams: {
|
|
1087
|
-
protocol: "openid4vp",
|
|
1088
|
-
data: openid4vpAuthResponseParams
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
+
responseParams: openid4vpAuthResponseParams
|
|
1091
1092
|
};
|
|
1092
1093
|
}
|
|
1093
1094
|
if (!requestParams.client_metadata) {
|
|
@@ -1141,7 +1142,7 @@ async function createOpenid4vpAuthorizationResponse(options) {
|
|
|
1141
1142
|
const result = await createJarmAuthResponse({
|
|
1142
1143
|
jarmAuthResponse: jarmResponseParams,
|
|
1143
1144
|
jwtSigner: jarm?.jwtSigner,
|
|
1144
|
-
|
|
1145
|
+
jweEncryptor: jarm?.encryption && (supportedJarmMetadata.type === "encrypt" || supportedJarmMetadata.type === "sign_encrypt") ? {
|
|
1145
1146
|
method: "jwk",
|
|
1146
1147
|
publicJwk: clientMetaJwks.encJwk,
|
|
1147
1148
|
apu: jarm.encryption?.nonce,
|
|
@@ -1156,13 +1157,7 @@ async function createOpenid4vpAuthorizationResponse(options) {
|
|
|
1156
1157
|
});
|
|
1157
1158
|
return {
|
|
1158
1159
|
responseParams: jarmResponseParams,
|
|
1159
|
-
jarm: { responseJwt: result.jarmAuthResponseJwt }
|
|
1160
|
-
...isOpenid4vpAuthorizationRequestDcApi(openid4vpAuthResponseParams) && {
|
|
1161
|
-
dcApiResponseParams: {
|
|
1162
|
-
protocol: "openid4vp",
|
|
1163
|
-
data: jarmResponseParams
|
|
1164
|
-
}
|
|
1165
|
-
}
|
|
1160
|
+
jarm: { responseJwt: result.jarmAuthResponseJwt }
|
|
1166
1161
|
};
|
|
1167
1162
|
}
|
|
1168
1163
|
|
|
@@ -1420,7 +1415,7 @@ import { z as z18 } from "zod";
|
|
|
1420
1415
|
|
|
1421
1416
|
// src/vp-token/z-vp-token.ts
|
|
1422
1417
|
import { z as z17 } from "zod";
|
|
1423
|
-
var zVpToken = z17.union([z17.string(), z17.array(z17.string()
|
|
1418
|
+
var zVpToken = z17.union([z17.string(), z17.array(z17.union([z17.string(), z17.record(z17.any())])), z17.record(z17.any())]);
|
|
1424
1419
|
|
|
1425
1420
|
// src/authorization-response/z-authorization-response.ts
|
|
1426
1421
|
var zOpenid4vpAuthorizationResponse = z18.object({
|
|
@@ -1434,25 +1429,8 @@ var zOpenid4vpAuthorizationResponse = z18.object({
|
|
|
1434
1429
|
expires_in: z18.number().optional()
|
|
1435
1430
|
}).passthrough();
|
|
1436
1431
|
|
|
1437
|
-
// src/authorization-response/z-authorization-response-dc-api.ts
|
|
1438
|
-
import { z as z19 } from "zod";
|
|
1439
|
-
var zOpenid4vpAuthorizationResponseDcApi = z19.object({
|
|
1440
|
-
protocol: z19.literal("openid4vp"),
|
|
1441
|
-
data: zOpenid4vpAuthorizationResponse
|
|
1442
|
-
}).passthrough();
|
|
1443
|
-
function isOpenid4vpAuthorizationResponseDcApi(response) {
|
|
1444
|
-
return "protocol" in response && "data" in response;
|
|
1445
|
-
}
|
|
1446
|
-
|
|
1447
1432
|
// src/authorization-response/parse-authorization-response-payload.ts
|
|
1448
1433
|
function parseOpenid4VpAuthorizationResponsePayload(payload) {
|
|
1449
|
-
if (isOpenid4vpAuthorizationRequestDcApi(payload)) {
|
|
1450
|
-
return parseWithErrorHandling6(
|
|
1451
|
-
zOpenid4vpAuthorizationResponseDcApi,
|
|
1452
|
-
payload,
|
|
1453
|
-
"Failed to to parse openid4vp dc_api authorization response."
|
|
1454
|
-
);
|
|
1455
|
-
}
|
|
1456
1434
|
return parseWithErrorHandling6(
|
|
1457
1435
|
zOpenid4vpAuthorizationResponse,
|
|
1458
1436
|
payload,
|
|
@@ -1469,30 +1447,30 @@ import {
|
|
|
1469
1447
|
zJwtHeader as zJwtHeader2
|
|
1470
1448
|
} from "@openid4vc/oauth2";
|
|
1471
1449
|
import { decodeBase64 as decodeBase642, encodeToUtf8String as encodeToUtf8String2, parseWithErrorHandling as parseWithErrorHandling7 } from "@openid4vc/utils";
|
|
1472
|
-
import
|
|
1450
|
+
import z19 from "zod";
|
|
1473
1451
|
async function parseJarmAuthorizationResponse(options) {
|
|
1474
1452
|
const { jarmResponseJwt, callbacks } = options;
|
|
1475
1453
|
const jarmAuthorizationResponseJwt = parseWithErrorHandling7(
|
|
1476
|
-
|
|
1454
|
+
z19.union([zCompactJwt4, zCompactJwe3]),
|
|
1477
1455
|
jarmResponseJwt,
|
|
1478
1456
|
"Invalid jarm authorization response jwt."
|
|
1479
1457
|
);
|
|
1480
1458
|
const verifiedJarmResponse = await verifyJarmAuthorizationResponse({ jarmAuthorizationResponseJwt, callbacks });
|
|
1481
|
-
const zJarmHeader =
|
|
1459
|
+
const zJarmHeader = z19.object({ ...zJwtHeader2.shape, apu: z19.string().optional(), apv: z19.string().optional() });
|
|
1482
1460
|
const { header: jarmHeader } = decodeJwtHeader2({
|
|
1483
1461
|
jwt: jarmAuthorizationResponseJwt,
|
|
1484
1462
|
headerSchema: zJarmHeader
|
|
1485
1463
|
});
|
|
1486
1464
|
const parsedAuthorizationRequest = parseOpenid4vpAuthorizationRequestPayload({
|
|
1487
|
-
|
|
1465
|
+
authorizationRequest: verifiedJarmResponse.authorizationRequest
|
|
1488
1466
|
});
|
|
1489
|
-
if (parsedAuthorizationRequest.type !== "openid4vp") {
|
|
1467
|
+
if (parsedAuthorizationRequest.type !== "openid4vp" && parsedAuthorizationRequest.type !== "openid4vp_dc_api") {
|
|
1490
1468
|
throw new Oauth2Error12("Invalid authorization request. Could not parse openid4vp authorization request.");
|
|
1491
1469
|
}
|
|
1492
1470
|
const authResponsePayload = parseOpenid4VpAuthorizationResponsePayload(verifiedJarmResponse.jarmAuthResponse);
|
|
1493
1471
|
const validateOpenId4vpResponse = validateOpenid4vpAuthorizationResponse({
|
|
1494
1472
|
authorizationRequest: parsedAuthorizationRequest.params,
|
|
1495
|
-
authorizationResponse:
|
|
1473
|
+
authorizationResponse: authResponsePayload
|
|
1496
1474
|
});
|
|
1497
1475
|
const authRequestPayload = parsedAuthorizationRequest.params;
|
|
1498
1476
|
if (!authRequestPayload.response_mode || !isJarmResponseMode(authRequestPayload.response_mode)) {
|
|
@@ -1525,15 +1503,15 @@ async function parseOpenid4vpAuthorizationResponse(options) {
|
|
|
1525
1503
|
return parseJarmAuthorizationResponse({ jarmResponseJwt: responsePayload.response, callbacks });
|
|
1526
1504
|
}
|
|
1527
1505
|
const authResponsePayload = parseOpenid4VpAuthorizationResponsePayload(responsePayload);
|
|
1528
|
-
const
|
|
1529
|
-
const parsedAuthRequest = parseOpenid4vpAuthorizationRequestPayload({
|
|
1506
|
+
const { authorizationRequest } = await callbacks.getOpenid4vpAuthorizationRequest(authResponsePayload);
|
|
1507
|
+
const parsedAuthRequest = parseOpenid4vpAuthorizationRequestPayload({ authorizationRequest });
|
|
1530
1508
|
if (parsedAuthRequest.type !== "openid4vp" && parsedAuthRequest.type !== "openid4vp_dc_api") {
|
|
1531
1509
|
throw new Oauth2Error13("Invalid authorization request. Could not parse openid4vp authorization request.");
|
|
1532
1510
|
}
|
|
1533
1511
|
const authRequestPayload = parsedAuthRequest.params;
|
|
1534
1512
|
const validateOpenId4vpResponse = validateOpenid4vpAuthorizationResponse({
|
|
1535
1513
|
authorizationRequest: authRequestPayload,
|
|
1536
|
-
authorizationResponse:
|
|
1514
|
+
authorizationResponse: authResponsePayload
|
|
1537
1515
|
});
|
|
1538
1516
|
if (authRequestPayload.response_mode && isJarmResponseMode(authRequestPayload.response_mode)) {
|
|
1539
1517
|
throw new Oauth2ServerErrorResponseError10(
|
|
@@ -1599,22 +1577,22 @@ var Openid4vpVerifier = class {
|
|
|
1599
1577
|
};
|
|
1600
1578
|
|
|
1601
1579
|
// src/models/z-credential-formats.ts
|
|
1602
|
-
import { z as
|
|
1603
|
-
var zCredentialFormat =
|
|
1580
|
+
import { z as z20 } from "zod";
|
|
1581
|
+
var zCredentialFormat = z20.enum(["jwt_vc_json", "ldp_vc", "ac_vc", "mso_mdoc", "dc+sd-jwt"]);
|
|
1604
1582
|
|
|
1605
1583
|
// src/models/z-proof-formats.ts
|
|
1606
|
-
import { z as
|
|
1607
|
-
var zProofFormat =
|
|
1584
|
+
import { z as z21 } from "zod";
|
|
1585
|
+
var zProofFormat = z21.enum(["jwt_vp_json", "ldc_vp", "ac_vp", "dc+sd-jwt", "mso_mdoc"]);
|
|
1608
1586
|
|
|
1609
1587
|
// src/models/z-wallet-metadata.ts
|
|
1610
|
-
import { z as
|
|
1611
|
-
var zWalletMetadata =
|
|
1612
|
-
presentation_definition_uri_supported:
|
|
1588
|
+
import { z as z22 } from "zod";
|
|
1589
|
+
var zWalletMetadata = z22.object({
|
|
1590
|
+
presentation_definition_uri_supported: z22.optional(z22.boolean()),
|
|
1613
1591
|
vp_formats_supported: zVpFormatsSupported,
|
|
1614
|
-
client_id_schemes_supported:
|
|
1615
|
-
request_object_signing_alg_values_supported:
|
|
1616
|
-
authorization_encryption_alg_values_supported:
|
|
1617
|
-
authorization_encryption_enc_values_supported:
|
|
1592
|
+
client_id_schemes_supported: z22.optional(z22.array(zClientIdScheme)),
|
|
1593
|
+
request_object_signing_alg_values_supported: z22.optional(z22.array(z22.string())),
|
|
1594
|
+
authorization_encryption_alg_values_supported: z22.optional(z22.array(z22.string())),
|
|
1595
|
+
authorization_encryption_enc_values_supported: z22.optional(z22.array(z22.string()))
|
|
1618
1596
|
});
|
|
1619
1597
|
export {
|
|
1620
1598
|
Openid4vpClient,
|
|
@@ -1623,7 +1601,6 @@ export {
|
|
|
1623
1601
|
createOpenid4vpAuthorizationResponse,
|
|
1624
1602
|
isJarmResponseMode,
|
|
1625
1603
|
isOpenid4vpAuthorizationRequestDcApi,
|
|
1626
|
-
isOpenid4vpAuthorizationResponseDcApi,
|
|
1627
1604
|
parseJarmAuthorizationResponse,
|
|
1628
1605
|
parseOpenid4vpAuthorizationRequestPayload,
|
|
1629
1606
|
parseOpenid4vpAuthorizationResponse,
|
|
@@ -1639,7 +1616,6 @@ export {
|
|
|
1639
1616
|
zCredentialFormat,
|
|
1640
1617
|
zJarmClientMetadata,
|
|
1641
1618
|
zOpenid4vpAuthorizationResponse,
|
|
1642
|
-
zOpenid4vpAuthorizationResponseDcApi,
|
|
1643
1619
|
zProofFormat,
|
|
1644
1620
|
zWalletMetadata
|
|
1645
1621
|
};
|