@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.js
CHANGED
|
@@ -36,7 +36,6 @@ __export(src_exports, {
|
|
|
36
36
|
createOpenid4vpAuthorizationResponse: () => createOpenid4vpAuthorizationResponse,
|
|
37
37
|
isJarmResponseMode: () => isJarmResponseMode,
|
|
38
38
|
isOpenid4vpAuthorizationRequestDcApi: () => isOpenid4vpAuthorizationRequestDcApi,
|
|
39
|
-
isOpenid4vpAuthorizationResponseDcApi: () => isOpenid4vpAuthorizationResponseDcApi,
|
|
40
39
|
parseJarmAuthorizationResponse: () => parseJarmAuthorizationResponse,
|
|
41
40
|
parseOpenid4vpAuthorizationRequestPayload: () => parseOpenid4vpAuthorizationRequestPayload,
|
|
42
41
|
parseOpenid4vpAuthorizationResponse: () => parseOpenid4vpAuthorizationResponse,
|
|
@@ -52,7 +51,6 @@ __export(src_exports, {
|
|
|
52
51
|
zCredentialFormat: () => zCredentialFormat,
|
|
53
52
|
zJarmClientMetadata: () => zJarmClientMetadata,
|
|
54
53
|
zOpenid4vpAuthorizationResponse: () => zOpenid4vpAuthorizationResponse,
|
|
55
|
-
zOpenid4vpAuthorizationResponseDcApi: () => zOpenid4vpAuthorizationResponseDcApi,
|
|
56
54
|
zProofFormat: () => zProofFormat,
|
|
57
55
|
zWalletMetadata: () => zWalletMetadata
|
|
58
56
|
});
|
|
@@ -99,16 +97,16 @@ var zJarmAuthResponseEncryptedOnly = import_zod2.z.object({
|
|
|
99
97
|
|
|
100
98
|
// src/jarm/jarm-auth-response/jarm-validate-auth-response.ts
|
|
101
99
|
var jarmAuthResponseValidate = (options) => {
|
|
102
|
-
const {
|
|
103
|
-
if (!zJarmAuthResponse.safeParse(
|
|
100
|
+
const { clientId, authorizationResponse } = options;
|
|
101
|
+
if (!zJarmAuthResponse.safeParse(authorizationResponse).success) {
|
|
104
102
|
return;
|
|
105
103
|
}
|
|
106
|
-
if (
|
|
104
|
+
if (clientId !== authorizationResponse.aud) {
|
|
107
105
|
throw new import_oauth22.Oauth2Error(
|
|
108
|
-
`Invalid 'aud' claim in JARM authorization response. Expected '${
|
|
106
|
+
`Invalid 'aud' claim in JARM authorization response. Expected '${clientId}' received '${JSON.stringify(authorizationResponse.aud)}'.`
|
|
109
107
|
);
|
|
110
108
|
}
|
|
111
|
-
if (
|
|
109
|
+
if (authorizationResponse.exp !== void 0 && authorizationResponse.exp < (0, import_utils.dateToSeconds)()) {
|
|
112
110
|
throw new import_oauth22.Oauth2Error("Jarm auth response is expired.");
|
|
113
111
|
}
|
|
114
112
|
};
|
|
@@ -155,18 +153,14 @@ async function verifyJarmAuthorizationResponse(options) {
|
|
|
155
153
|
const jsonRequestData = JSON.parse(decryptedRequestData);
|
|
156
154
|
jarmAuthResponse = zJarmAuthResponseEncryptedOnly.parse(jsonRequestData);
|
|
157
155
|
}
|
|
158
|
-
const {
|
|
159
|
-
jarmAuthResponseValidate({
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
type = "encrypted";
|
|
165
|
-
} else {
|
|
166
|
-
type = "signed";
|
|
167
|
-
}
|
|
156
|
+
const { authorizationRequest } = await callbacks.getOpenid4vpAuthorizationRequest(jarmAuthResponse);
|
|
157
|
+
jarmAuthResponseValidate({
|
|
158
|
+
clientId: authorizationRequest.client_id,
|
|
159
|
+
authorizationResponse: jarmAuthResponse
|
|
160
|
+
});
|
|
161
|
+
const type = requestDataIsEncrypted && responseIsSigned ? "SignedEncrypted" /* SignedEncrypted */ : requestDataIsEncrypted ? "Encrypted" /* Encrypted */ : "Signed" /* Signed */;
|
|
168
162
|
const issuer = jarmAuthResponse.iss;
|
|
169
|
-
return {
|
|
163
|
+
return { authorizationRequest, jarmAuthResponse, type, issuer };
|
|
170
164
|
}
|
|
171
165
|
|
|
172
166
|
// src/jarm/metadata/z-jarm-client-metadata.ts
|
|
@@ -243,7 +237,7 @@ var import_utils6 = require("@openid4vc/utils");
|
|
|
243
237
|
// src/jar/create-jar-auth-request.ts
|
|
244
238
|
var import_oauth25 = require("@openid4vc/oauth2");
|
|
245
239
|
async function createJarAuthRequest(options) {
|
|
246
|
-
const { jwtSigner,
|
|
240
|
+
const { jwtSigner, jweEncryptor, authRequestParams, requestUri, callbacks } = options;
|
|
247
241
|
let requestObjectJwt;
|
|
248
242
|
let encryptionJwk;
|
|
249
243
|
const { jwt, signerJwk } = await callbacks.signJwt(jwtSigner, {
|
|
@@ -251,8 +245,8 @@ async function createJarAuthRequest(options) {
|
|
|
251
245
|
payload: { ...options.additionalJwtPayload, ...authRequestParams }
|
|
252
246
|
});
|
|
253
247
|
requestObjectJwt = jwt;
|
|
254
|
-
if (
|
|
255
|
-
const encryptionResult = await callbacks.encryptJwe(
|
|
248
|
+
if (jweEncryptor) {
|
|
249
|
+
const encryptionResult = await callbacks.encryptJwe(jweEncryptor, requestObjectJwt);
|
|
256
250
|
requestObjectJwt = encryptionResult.jwe;
|
|
257
251
|
encryptionJwk = encryptionResult.encryptionJwk;
|
|
258
252
|
}
|
|
@@ -526,36 +520,36 @@ function isJarAuthRequest(request) {
|
|
|
526
520
|
|
|
527
521
|
// src/authorization-request/parse-authorization-request-params.ts
|
|
528
522
|
function parseOpenid4vpAuthorizationRequestPayload(options) {
|
|
529
|
-
const {
|
|
523
|
+
const { authorizationRequest } = options;
|
|
530
524
|
let provided = "params";
|
|
531
525
|
let params;
|
|
532
|
-
if (typeof
|
|
533
|
-
if (
|
|
534
|
-
const url = new import_utils8.URL(
|
|
526
|
+
if (typeof authorizationRequest === "string") {
|
|
527
|
+
if (authorizationRequest.includes("://")) {
|
|
528
|
+
const url = new import_utils8.URL(authorizationRequest);
|
|
535
529
|
params = Object.fromEntries(url.searchParams);
|
|
536
530
|
provided = "uri";
|
|
537
531
|
} else {
|
|
538
|
-
const decoded = (0, import_oauth211.decodeJwt)({ jwt:
|
|
532
|
+
const decoded = (0, import_oauth211.decodeJwt)({ jwt: authorizationRequest });
|
|
539
533
|
params = decoded.payload;
|
|
540
534
|
provided = "jwt";
|
|
541
535
|
}
|
|
542
536
|
} else {
|
|
543
|
-
params =
|
|
537
|
+
params = authorizationRequest;
|
|
544
538
|
}
|
|
545
539
|
const parsedRequest = (0, import_utils9.parseWithErrorHandling)(
|
|
546
540
|
import_zod10.default.union([zOpenid4vpAuthorizationRequest, zJarAuthRequest, zOpenid4vpAuthorizationRequestDcApi]),
|
|
547
541
|
params
|
|
548
542
|
);
|
|
549
|
-
if (
|
|
543
|
+
if (isJarAuthRequest(parsedRequest)) {
|
|
550
544
|
return {
|
|
551
|
-
type: "
|
|
545
|
+
type: "jar",
|
|
552
546
|
provided,
|
|
553
547
|
params: parsedRequest
|
|
554
548
|
};
|
|
555
549
|
}
|
|
556
|
-
if (
|
|
550
|
+
if (isOpenid4vpAuthorizationRequestDcApi(parsedRequest)) {
|
|
557
551
|
return {
|
|
558
|
-
type: "
|
|
552
|
+
type: "openid4vp_dc_api",
|
|
559
553
|
provided,
|
|
560
554
|
params: parsedRequest
|
|
561
555
|
};
|
|
@@ -574,35 +568,26 @@ var import_zod14 = __toESM(require("zod"));
|
|
|
574
568
|
|
|
575
569
|
// src/client-identifier-scheme/parse-client-identifier-scheme.ts
|
|
576
570
|
var import_oauth212 = require("@openid4vc/oauth2");
|
|
577
|
-
function getClientId(
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
if (request.client_id) {
|
|
581
|
-
return request.client_id;
|
|
582
|
-
}
|
|
583
|
-
if (!origin) {
|
|
571
|
+
function getClientId(options) {
|
|
572
|
+
if (isOpenid4vpAuthorizationRequestDcApi(options.request)) {
|
|
573
|
+
if (!options.origin) {
|
|
584
574
|
throw new import_oauth212.Oauth2ServerErrorResponseError({
|
|
585
575
|
error: import_oauth212.Oauth2ErrorCodes.InvalidRequest,
|
|
586
|
-
error_description:
|
|
576
|
+
error_description: "Failed to parse client identifier. 'origin' is required for requests with response_mode 'dc_api' and 'dc_api.jwt'"
|
|
587
577
|
});
|
|
588
578
|
}
|
|
589
|
-
return `web-origin:${origin}`;
|
|
579
|
+
if (!options.jar || !options.request.client_id) return `web-origin:${options.origin}`;
|
|
580
|
+
return options.request.client_id;
|
|
590
581
|
}
|
|
591
|
-
return request.client_id;
|
|
582
|
+
return options.request.client_id;
|
|
592
583
|
}
|
|
593
584
|
function parseClientIdentifier(options, parserConfig) {
|
|
594
585
|
const { request, jar } = options;
|
|
595
586
|
const isDcApiRequest = isOpenid4vpAuthorizationRequestDcApi(request);
|
|
596
|
-
const clientId = getClientId(
|
|
587
|
+
const clientId = getClientId(options);
|
|
597
588
|
const parserConfigWithDefaults = {
|
|
598
589
|
supportedSchemes: parserConfig?.supportedSchemes || Object.values(zClientIdScheme.options)
|
|
599
590
|
};
|
|
600
|
-
if (isDcApiRequest && !jar && request.client_id) {
|
|
601
|
-
throw new import_oauth212.Oauth2ServerErrorResponseError({
|
|
602
|
-
error: import_oauth212.Oauth2ErrorCodes.InvalidRequest,
|
|
603
|
-
error_description: `The 'client_id' parameter MUST be omitted in unsigned openid4vp dc api authorization requests.`
|
|
604
|
-
});
|
|
605
|
-
}
|
|
606
591
|
const colonIndex = clientId.indexOf(":");
|
|
607
592
|
if (colonIndex === -1) {
|
|
608
593
|
return {
|
|
@@ -628,7 +613,7 @@ function parseClientIdentifier(options, parserConfig) {
|
|
|
628
613
|
error_description: `The client identifier scheme 'https' is not supported when using the dc_api response mode.`
|
|
629
614
|
});
|
|
630
615
|
}
|
|
631
|
-
if (!clientId.startsWith("https://") && !clientId.startsWith("http://")) {
|
|
616
|
+
if (!clientId.startsWith("https://") && !((0, import_oauth212.getGlobalConfig)().allowInsecureUrls && clientId.startsWith("http://"))) {
|
|
632
617
|
throw new import_oauth212.Oauth2ServerErrorResponseError({
|
|
633
618
|
error: import_oauth212.Oauth2ErrorCodes.InvalidRequest,
|
|
634
619
|
error_description: "Invalid client identifier. Client identifier must start with https:// or http:// if allowInsecureUrls is true."
|
|
@@ -690,7 +675,7 @@ function parseClientIdentifier(options, parserConfig) {
|
|
|
690
675
|
scheme,
|
|
691
676
|
identifier: clientId,
|
|
692
677
|
originalValue: clientId,
|
|
693
|
-
|
|
678
|
+
didUrl: jar.signer.publicJwk.kid
|
|
694
679
|
};
|
|
695
680
|
}
|
|
696
681
|
if (scheme === "x509_san_dns" || scheme === "x509_san_uri") {
|
|
@@ -706,7 +691,17 @@ function parseClientIdentifier(options, parserConfig) {
|
|
|
706
691
|
error_description: "Something went wrong. The JWT signer method is not x5c but the client identifier scheme is x509_san_dns."
|
|
707
692
|
});
|
|
708
693
|
}
|
|
709
|
-
if (scheme === "x509_san_dns"
|
|
694
|
+
if (scheme === "x509_san_dns") {
|
|
695
|
+
if (!options.callbacks.getX509CertificateMetadata) {
|
|
696
|
+
throw new import_oauth212.Oauth2ServerErrorResponseError(
|
|
697
|
+
{
|
|
698
|
+
error: import_oauth212.Oauth2ErrorCodes.ServerError
|
|
699
|
+
},
|
|
700
|
+
{
|
|
701
|
+
internalMessage: "Missing required 'getX509CertificateMetadata' callback for verification of 'x509_san_dns' client id scheme"
|
|
702
|
+
}
|
|
703
|
+
);
|
|
704
|
+
}
|
|
710
705
|
const { sanDnsNames } = options.callbacks.getX509CertificateMetadata(jar.signer.x5c[0]);
|
|
711
706
|
if (!sanDnsNames.includes(identifierPart)) {
|
|
712
707
|
throw new import_oauth212.Oauth2ServerErrorResponseError({
|
|
@@ -721,7 +716,17 @@ function parseClientIdentifier(options, parserConfig) {
|
|
|
721
716
|
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."
|
|
722
717
|
});
|
|
723
718
|
}
|
|
724
|
-
} else if (scheme === "x509_san_uri"
|
|
719
|
+
} else if (scheme === "x509_san_uri") {
|
|
720
|
+
if (!options.callbacks.getX509CertificateMetadata) {
|
|
721
|
+
throw new import_oauth212.Oauth2ServerErrorResponseError(
|
|
722
|
+
{
|
|
723
|
+
error: import_oauth212.Oauth2ErrorCodes.ServerError
|
|
724
|
+
},
|
|
725
|
+
{
|
|
726
|
+
internalMessage: "Missing required 'getX509CertificateMetadata' callback for verification of 'x509_san_uri' client id scheme"
|
|
727
|
+
}
|
|
728
|
+
);
|
|
729
|
+
}
|
|
725
730
|
const { sanUriNames } = options.callbacks.getX509CertificateMetadata(jar.signer.x5c[0]);
|
|
726
731
|
if (!sanUriNames.includes(identifierPart)) {
|
|
727
732
|
throw new import_oauth212.Oauth2ServerErrorResponseError({
|
|
@@ -1015,26 +1020,26 @@ function addSecondsToDate(date, seconds) {
|
|
|
1015
1020
|
// src/jarm/jarm-auth-response-create.ts
|
|
1016
1021
|
var import_oauth218 = require("@openid4vc/oauth2");
|
|
1017
1022
|
async function createJarmAuthResponse(options) {
|
|
1018
|
-
const { jarmAuthResponse,
|
|
1019
|
-
if (!jwtSigner &&
|
|
1020
|
-
const { jwe } = await callbacks.encryptJwe(
|
|
1023
|
+
const { jarmAuthResponse, jweEncryptor, jwtSigner, callbacks } = options;
|
|
1024
|
+
if (!jwtSigner && jweEncryptor) {
|
|
1025
|
+
const { jwe } = await callbacks.encryptJwe(jweEncryptor, JSON.stringify(jarmAuthResponse));
|
|
1021
1026
|
return { jarmAuthResponseJwt: jwe };
|
|
1022
1027
|
}
|
|
1023
|
-
if (jwtSigner && !
|
|
1028
|
+
if (jwtSigner && !jweEncryptor) {
|
|
1024
1029
|
const signed2 = await callbacks.signJwt(jwtSigner, {
|
|
1025
1030
|
header: (0, import_oauth218.jwtHeaderFromJwtSigner)(jwtSigner),
|
|
1026
1031
|
payload: jarmAuthResponse
|
|
1027
1032
|
});
|
|
1028
1033
|
return { jarmAuthResponseJwt: signed2.jwt };
|
|
1029
1034
|
}
|
|
1030
|
-
if (!jwtSigner || !
|
|
1035
|
+
if (!jwtSigner || !jweEncryptor) {
|
|
1031
1036
|
throw new import_oauth218.Oauth2Error("JWT signer and/or encryptor are required to create a JARM auth response.");
|
|
1032
1037
|
}
|
|
1033
1038
|
const signed = await callbacks.signJwt(jwtSigner, {
|
|
1034
1039
|
header: (0, import_oauth218.jwtHeaderFromJwtSigner)(jwtSigner),
|
|
1035
1040
|
payload: jarmAuthResponse
|
|
1036
1041
|
});
|
|
1037
|
-
const encrypted = await callbacks.encryptJwe(
|
|
1042
|
+
const encrypted = await callbacks.encryptJwe(jweEncryptor, signed.jwt);
|
|
1038
1043
|
return { jarmAuthResponseJwt: encrypted.jwe };
|
|
1039
1044
|
}
|
|
1040
1045
|
|
|
@@ -1116,13 +1121,7 @@ async function createOpenid4vpAuthorizationResponse(options) {
|
|
|
1116
1121
|
}
|
|
1117
1122
|
if (!jarm) {
|
|
1118
1123
|
return {
|
|
1119
|
-
responseParams: openid4vpAuthResponseParams
|
|
1120
|
-
...isOpenid4vpAuthorizationRequestDcApi(openid4vpAuthResponseParams) && {
|
|
1121
|
-
dcApiResponseParams: {
|
|
1122
|
-
protocol: "openid4vp",
|
|
1123
|
-
data: openid4vpAuthResponseParams
|
|
1124
|
-
}
|
|
1125
|
-
}
|
|
1124
|
+
responseParams: openid4vpAuthResponseParams
|
|
1126
1125
|
};
|
|
1127
1126
|
}
|
|
1128
1127
|
if (!requestParams.client_metadata) {
|
|
@@ -1176,7 +1175,7 @@ async function createOpenid4vpAuthorizationResponse(options) {
|
|
|
1176
1175
|
const result = await createJarmAuthResponse({
|
|
1177
1176
|
jarmAuthResponse: jarmResponseParams,
|
|
1178
1177
|
jwtSigner: jarm?.jwtSigner,
|
|
1179
|
-
|
|
1178
|
+
jweEncryptor: jarm?.encryption && (supportedJarmMetadata.type === "encrypt" || supportedJarmMetadata.type === "sign_encrypt") ? {
|
|
1180
1179
|
method: "jwk",
|
|
1181
1180
|
publicJwk: clientMetaJwks.encJwk,
|
|
1182
1181
|
apu: jarm.encryption?.nonce,
|
|
@@ -1191,13 +1190,7 @@ async function createOpenid4vpAuthorizationResponse(options) {
|
|
|
1191
1190
|
});
|
|
1192
1191
|
return {
|
|
1193
1192
|
responseParams: jarmResponseParams,
|
|
1194
|
-
jarm: { responseJwt: result.jarmAuthResponseJwt }
|
|
1195
|
-
...isOpenid4vpAuthorizationRequestDcApi(openid4vpAuthResponseParams) && {
|
|
1196
|
-
dcApiResponseParams: {
|
|
1197
|
-
protocol: "openid4vp",
|
|
1198
|
-
data: jarmResponseParams
|
|
1199
|
-
}
|
|
1200
|
-
}
|
|
1193
|
+
jarm: { responseJwt: result.jarmAuthResponseJwt }
|
|
1201
1194
|
};
|
|
1202
1195
|
}
|
|
1203
1196
|
|
|
@@ -1455,7 +1448,7 @@ var import_zod18 = require("zod");
|
|
|
1455
1448
|
|
|
1456
1449
|
// src/vp-token/z-vp-token.ts
|
|
1457
1450
|
var import_zod17 = require("zod");
|
|
1458
|
-
var zVpToken = import_zod17.z.union([import_zod17.z.string(), import_zod17.z.array(import_zod17.z.string()
|
|
1451
|
+
var zVpToken = import_zod17.z.union([import_zod17.z.string(), import_zod17.z.array(import_zod17.z.union([import_zod17.z.string(), import_zod17.z.record(import_zod17.z.any())])), import_zod17.z.record(import_zod17.z.any())]);
|
|
1459
1452
|
|
|
1460
1453
|
// src/authorization-response/z-authorization-response.ts
|
|
1461
1454
|
var zOpenid4vpAuthorizationResponse = import_zod18.z.object({
|
|
@@ -1469,25 +1462,8 @@ var zOpenid4vpAuthorizationResponse = import_zod18.z.object({
|
|
|
1469
1462
|
expires_in: import_zod18.z.number().optional()
|
|
1470
1463
|
}).passthrough();
|
|
1471
1464
|
|
|
1472
|
-
// src/authorization-response/z-authorization-response-dc-api.ts
|
|
1473
|
-
var import_zod19 = require("zod");
|
|
1474
|
-
var zOpenid4vpAuthorizationResponseDcApi = import_zod19.z.object({
|
|
1475
|
-
protocol: import_zod19.z.literal("openid4vp"),
|
|
1476
|
-
data: zOpenid4vpAuthorizationResponse
|
|
1477
|
-
}).passthrough();
|
|
1478
|
-
function isOpenid4vpAuthorizationResponseDcApi(response) {
|
|
1479
|
-
return "protocol" in response && "data" in response;
|
|
1480
|
-
}
|
|
1481
|
-
|
|
1482
1465
|
// src/authorization-response/parse-authorization-response-payload.ts
|
|
1483
1466
|
function parseOpenid4VpAuthorizationResponsePayload(payload) {
|
|
1484
|
-
if (isOpenid4vpAuthorizationRequestDcApi(payload)) {
|
|
1485
|
-
return (0, import_utils18.parseWithErrorHandling)(
|
|
1486
|
-
zOpenid4vpAuthorizationResponseDcApi,
|
|
1487
|
-
payload,
|
|
1488
|
-
"Failed to to parse openid4vp dc_api authorization response."
|
|
1489
|
-
);
|
|
1490
|
-
}
|
|
1491
1467
|
return (0, import_utils18.parseWithErrorHandling)(
|
|
1492
1468
|
zOpenid4vpAuthorizationResponse,
|
|
1493
1469
|
payload,
|
|
@@ -1498,30 +1474,30 @@ function parseOpenid4VpAuthorizationResponsePayload(payload) {
|
|
|
1498
1474
|
// src/authorization-response/parse-jarm-authorization-response.ts
|
|
1499
1475
|
var import_oauth226 = require("@openid4vc/oauth2");
|
|
1500
1476
|
var import_utils19 = require("@openid4vc/utils");
|
|
1501
|
-
var
|
|
1477
|
+
var import_zod19 = __toESM(require("zod"));
|
|
1502
1478
|
async function parseJarmAuthorizationResponse(options) {
|
|
1503
1479
|
const { jarmResponseJwt, callbacks } = options;
|
|
1504
1480
|
const jarmAuthorizationResponseJwt = (0, import_utils19.parseWithErrorHandling)(
|
|
1505
|
-
|
|
1481
|
+
import_zod19.default.union([import_oauth226.zCompactJwt, import_oauth226.zCompactJwe]),
|
|
1506
1482
|
jarmResponseJwt,
|
|
1507
1483
|
"Invalid jarm authorization response jwt."
|
|
1508
1484
|
);
|
|
1509
1485
|
const verifiedJarmResponse = await verifyJarmAuthorizationResponse({ jarmAuthorizationResponseJwt, callbacks });
|
|
1510
|
-
const zJarmHeader =
|
|
1486
|
+
const zJarmHeader = import_zod19.default.object({ ...import_oauth226.zJwtHeader.shape, apu: import_zod19.default.string().optional(), apv: import_zod19.default.string().optional() });
|
|
1511
1487
|
const { header: jarmHeader } = (0, import_oauth226.decodeJwtHeader)({
|
|
1512
1488
|
jwt: jarmAuthorizationResponseJwt,
|
|
1513
1489
|
headerSchema: zJarmHeader
|
|
1514
1490
|
});
|
|
1515
1491
|
const parsedAuthorizationRequest = parseOpenid4vpAuthorizationRequestPayload({
|
|
1516
|
-
|
|
1492
|
+
authorizationRequest: verifiedJarmResponse.authorizationRequest
|
|
1517
1493
|
});
|
|
1518
|
-
if (parsedAuthorizationRequest.type !== "openid4vp") {
|
|
1494
|
+
if (parsedAuthorizationRequest.type !== "openid4vp" && parsedAuthorizationRequest.type !== "openid4vp_dc_api") {
|
|
1519
1495
|
throw new import_oauth226.Oauth2Error("Invalid authorization request. Could not parse openid4vp authorization request.");
|
|
1520
1496
|
}
|
|
1521
1497
|
const authResponsePayload = parseOpenid4VpAuthorizationResponsePayload(verifiedJarmResponse.jarmAuthResponse);
|
|
1522
1498
|
const validateOpenId4vpResponse = validateOpenid4vpAuthorizationResponse({
|
|
1523
1499
|
authorizationRequest: parsedAuthorizationRequest.params,
|
|
1524
|
-
authorizationResponse:
|
|
1500
|
+
authorizationResponse: authResponsePayload
|
|
1525
1501
|
});
|
|
1526
1502
|
const authRequestPayload = parsedAuthorizationRequest.params;
|
|
1527
1503
|
if (!authRequestPayload.response_mode || !isJarmResponseMode(authRequestPayload.response_mode)) {
|
|
@@ -1554,15 +1530,15 @@ async function parseOpenid4vpAuthorizationResponse(options) {
|
|
|
1554
1530
|
return parseJarmAuthorizationResponse({ jarmResponseJwt: responsePayload.response, callbacks });
|
|
1555
1531
|
}
|
|
1556
1532
|
const authResponsePayload = parseOpenid4VpAuthorizationResponsePayload(responsePayload);
|
|
1557
|
-
const
|
|
1558
|
-
const parsedAuthRequest = parseOpenid4vpAuthorizationRequestPayload({
|
|
1533
|
+
const { authorizationRequest } = await callbacks.getOpenid4vpAuthorizationRequest(authResponsePayload);
|
|
1534
|
+
const parsedAuthRequest = parseOpenid4vpAuthorizationRequestPayload({ authorizationRequest });
|
|
1559
1535
|
if (parsedAuthRequest.type !== "openid4vp" && parsedAuthRequest.type !== "openid4vp_dc_api") {
|
|
1560
1536
|
throw new import_oauth227.Oauth2Error("Invalid authorization request. Could not parse openid4vp authorization request.");
|
|
1561
1537
|
}
|
|
1562
1538
|
const authRequestPayload = parsedAuthRequest.params;
|
|
1563
1539
|
const validateOpenId4vpResponse = validateOpenid4vpAuthorizationResponse({
|
|
1564
1540
|
authorizationRequest: authRequestPayload,
|
|
1565
|
-
authorizationResponse:
|
|
1541
|
+
authorizationResponse: authResponsePayload
|
|
1566
1542
|
});
|
|
1567
1543
|
if (authRequestPayload.response_mode && isJarmResponseMode(authRequestPayload.response_mode)) {
|
|
1568
1544
|
throw new import_oauth227.Oauth2ServerErrorResponseError(
|
|
@@ -1628,22 +1604,22 @@ var Openid4vpVerifier = class {
|
|
|
1628
1604
|
};
|
|
1629
1605
|
|
|
1630
1606
|
// src/models/z-credential-formats.ts
|
|
1631
|
-
var
|
|
1632
|
-
var zCredentialFormat =
|
|
1607
|
+
var import_zod20 = require("zod");
|
|
1608
|
+
var zCredentialFormat = import_zod20.z.enum(["jwt_vc_json", "ldp_vc", "ac_vc", "mso_mdoc", "dc+sd-jwt"]);
|
|
1633
1609
|
|
|
1634
1610
|
// src/models/z-proof-formats.ts
|
|
1635
|
-
var
|
|
1636
|
-
var zProofFormat =
|
|
1611
|
+
var import_zod21 = require("zod");
|
|
1612
|
+
var zProofFormat = import_zod21.z.enum(["jwt_vp_json", "ldc_vp", "ac_vp", "dc+sd-jwt", "mso_mdoc"]);
|
|
1637
1613
|
|
|
1638
1614
|
// src/models/z-wallet-metadata.ts
|
|
1639
|
-
var
|
|
1640
|
-
var zWalletMetadata =
|
|
1641
|
-
presentation_definition_uri_supported:
|
|
1615
|
+
var import_zod22 = require("zod");
|
|
1616
|
+
var zWalletMetadata = import_zod22.z.object({
|
|
1617
|
+
presentation_definition_uri_supported: import_zod22.z.optional(import_zod22.z.boolean()),
|
|
1642
1618
|
vp_formats_supported: zVpFormatsSupported,
|
|
1643
|
-
client_id_schemes_supported:
|
|
1644
|
-
request_object_signing_alg_values_supported:
|
|
1645
|
-
authorization_encryption_alg_values_supported:
|
|
1646
|
-
authorization_encryption_enc_values_supported:
|
|
1619
|
+
client_id_schemes_supported: import_zod22.z.optional(import_zod22.z.array(zClientIdScheme)),
|
|
1620
|
+
request_object_signing_alg_values_supported: import_zod22.z.optional(import_zod22.z.array(import_zod22.z.string())),
|
|
1621
|
+
authorization_encryption_alg_values_supported: import_zod22.z.optional(import_zod22.z.array(import_zod22.z.string())),
|
|
1622
|
+
authorization_encryption_enc_values_supported: import_zod22.z.optional(import_zod22.z.array(import_zod22.z.string()))
|
|
1647
1623
|
});
|
|
1648
1624
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1649
1625
|
0 && (module.exports = {
|
|
@@ -1653,7 +1629,6 @@ var zWalletMetadata = import_zod23.z.object({
|
|
|
1653
1629
|
createOpenid4vpAuthorizationResponse,
|
|
1654
1630
|
isJarmResponseMode,
|
|
1655
1631
|
isOpenid4vpAuthorizationRequestDcApi,
|
|
1656
|
-
isOpenid4vpAuthorizationResponseDcApi,
|
|
1657
1632
|
parseJarmAuthorizationResponse,
|
|
1658
1633
|
parseOpenid4vpAuthorizationRequestPayload,
|
|
1659
1634
|
parseOpenid4vpAuthorizationResponse,
|
|
@@ -1669,7 +1644,6 @@ var zWalletMetadata = import_zod23.z.object({
|
|
|
1669
1644
|
zCredentialFormat,
|
|
1670
1645
|
zJarmClientMetadata,
|
|
1671
1646
|
zOpenid4vpAuthorizationResponse,
|
|
1672
|
-
zOpenid4vpAuthorizationResponseDcApi,
|
|
1673
1647
|
zProofFormat,
|
|
1674
1648
|
zWalletMetadata
|
|
1675
1649
|
});
|