@openid4vc/openid4vp 0.3.0-alpha-20250307131618 → 0.3.0-alpha-20250315153009
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 +11394 -7826
- package/dist/index.d.ts +11394 -7826
- package/dist/index.js +410 -443
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +383 -417
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -70,132 +70,41 @@ var zClientIdScheme = import_zod.z.enum([
|
|
|
70
70
|
"web-origin"
|
|
71
71
|
]);
|
|
72
72
|
|
|
73
|
-
// src/jarm/jarm-
|
|
74
|
-
var
|
|
75
|
-
var
|
|
76
|
-
|
|
77
|
-
// src/jarm/jarm-auth-response/jarm-validate-auth-response.ts
|
|
78
|
-
var import_oauth22 = require("@openid4vc/oauth2");
|
|
79
|
-
var import_utils = require("@openid4vc/utils");
|
|
73
|
+
// src/jarm/jarm-authorization-response/verify-jarm-authorization-response.ts
|
|
74
|
+
var import_oauth24 = require("@openid4vc/oauth2");
|
|
75
|
+
var import_zod4 = __toESM(require("zod"));
|
|
80
76
|
|
|
81
|
-
// src/jarm/
|
|
77
|
+
// src/jarm/metadata/z-jarm-client-metadata.ts
|
|
82
78
|
var import_oauth2 = require("@openid4vc/oauth2");
|
|
79
|
+
var import_utils = require("@openid4vc/utils");
|
|
83
80
|
var import_zod2 = require("zod");
|
|
84
|
-
var
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
* aud: The client_id of the client the response is intended for
|
|
89
|
-
* exp: The expiration time of the JWT. A maximum JWT lifetime of 10 minutes is RECOMMENDED.
|
|
90
|
-
*/
|
|
91
|
-
...import_oauth2.zJwtPayload.shape,
|
|
92
|
-
...import_oauth2.zJwtPayload.pick({ iss: true, aud: true, exp: true }).required().shape,
|
|
93
|
-
state: import_zod2.z.optional(import_zod2.z.string())
|
|
94
|
-
}).passthrough();
|
|
95
|
-
var zJarmAuthResponseEncryptedOnly = import_zod2.z.object({
|
|
96
|
-
...import_oauth2.zJwtPayload.shape,
|
|
97
|
-
state: import_zod2.z.optional(import_zod2.z.string())
|
|
98
|
-
}).passthrough();
|
|
99
|
-
|
|
100
|
-
// src/jarm/jarm-auth-response/jarm-validate-auth-response.ts
|
|
101
|
-
var jarmAuthResponseValidate = (options) => {
|
|
102
|
-
const { clientId, authorizationResponse } = options;
|
|
103
|
-
if (!zJarmAuthResponse.safeParse(authorizationResponse).success) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
if (clientId !== authorizationResponse.aud) {
|
|
107
|
-
throw new import_oauth22.Oauth2Error(
|
|
108
|
-
`Invalid 'aud' claim in JARM authorization response. Expected '${clientId}' received '${JSON.stringify(authorizationResponse.aud)}'.`
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
if (authorizationResponse.exp !== void 0 && authorizationResponse.exp < (0, import_utils.dateToSeconds)()) {
|
|
112
|
-
throw new import_oauth22.Oauth2Error("Jarm auth response is expired.");
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
// src/jarm/jarm-auth-response/verify-jarm-auth-response.ts
|
|
117
|
-
var decryptJarmRequestData = async (options) => {
|
|
118
|
-
const { requestData, callbacks } = options;
|
|
119
|
-
const { header } = (0, import_oauth23.decodeJwtHeader)({ jwt: requestData });
|
|
120
|
-
if (!header.kid) {
|
|
121
|
-
throw new import_oauth23.Oauth2Error('Jarm JWE is missing the protected header field "kid".');
|
|
122
|
-
}
|
|
123
|
-
const result = await callbacks.decryptJwe(requestData);
|
|
124
|
-
if (!result.decrypted) {
|
|
125
|
-
throw new import_oauth23.Oauth2Error("Failed to decrypt jarm auth response.");
|
|
126
|
-
}
|
|
127
|
-
return result.payload;
|
|
128
|
-
};
|
|
129
|
-
async function verifyJarmAuthorizationResponse(options) {
|
|
130
|
-
const { jarmAuthorizationResponseJwt, callbacks } = options;
|
|
131
|
-
const requestDataIsEncrypted = import_oauth23.zCompactJwe.safeParse(jarmAuthorizationResponseJwt).success;
|
|
132
|
-
const decryptedRequestData = requestDataIsEncrypted ? await decryptJarmRequestData({ requestData: jarmAuthorizationResponseJwt, callbacks }) : jarmAuthorizationResponseJwt;
|
|
133
|
-
const responseIsSigned = import_oauth23.zCompactJwt.safeParse(decryptedRequestData).success;
|
|
134
|
-
if (!requestDataIsEncrypted && !responseIsSigned) {
|
|
135
|
-
throw new import_oauth23.Oauth2Error("Jarm Auth Response must be either encrypted, signed, or signed and encrypted.");
|
|
136
|
-
}
|
|
137
|
-
let jarmAuthResponse;
|
|
138
|
-
if (responseIsSigned) {
|
|
139
|
-
const { header: jwsProtectedHeader, payload: jwsPayload } = (0, import_oauth23.decodeJwt)({
|
|
140
|
-
jwt: decryptedRequestData,
|
|
141
|
-
headerSchema: import_zod3.default.object({ ...import_oauth23.zJwtHeader.shape, kid: import_zod3.default.string() })
|
|
142
|
-
});
|
|
143
|
-
const response = zJarmAuthResponse.parse(jwsPayload);
|
|
144
|
-
const jwtSigner = (0, import_oauth23.jwtSignerFromJwt)({ header: jwsProtectedHeader, payload: jwsPayload });
|
|
145
|
-
const verificationResult = await options.callbacks.verifyJwt(jwtSigner, {
|
|
146
|
-
compact: decryptedRequestData,
|
|
147
|
-
header: jwsProtectedHeader,
|
|
148
|
-
payload: jwsPayload
|
|
149
|
-
});
|
|
150
|
-
if (!verificationResult.verified) {
|
|
151
|
-
throw new import_oauth23.Oauth2Error("Jarm Auth Response is not valid.");
|
|
152
|
-
}
|
|
153
|
-
jarmAuthResponse = response;
|
|
154
|
-
} else {
|
|
155
|
-
const jsonRequestData = JSON.parse(decryptedRequestData);
|
|
156
|
-
jarmAuthResponse = zJarmAuthResponseEncryptedOnly.parse(jsonRequestData);
|
|
157
|
-
}
|
|
158
|
-
const { authorizationRequest } = await callbacks.getOpenid4vpAuthorizationRequest(jarmAuthResponse);
|
|
159
|
-
jarmAuthResponseValidate({
|
|
160
|
-
clientId: authorizationRequest.client_id,
|
|
161
|
-
authorizationResponse: jarmAuthResponse
|
|
162
|
-
});
|
|
163
|
-
const type = requestDataIsEncrypted && responseIsSigned ? "SignedEncrypted" /* SignedEncrypted */ : requestDataIsEncrypted ? "Encrypted" /* Encrypted */ : "Signed" /* Signed */;
|
|
164
|
-
const issuer = jarmAuthResponse.iss;
|
|
165
|
-
return { authorizationRequest, jarmAuthResponse, type, issuer };
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// src/jarm/metadata/z-jarm-client-metadata.ts
|
|
169
|
-
var import_oauth24 = require("@openid4vc/oauth2");
|
|
170
|
-
var import_utils2 = require("@openid4vc/utils");
|
|
171
|
-
var import_zod4 = require("zod");
|
|
172
|
-
var zJarmSignOnlyClientMetadata = import_zod4.z.object({
|
|
173
|
-
authorization_signed_response_alg: import_oauth24.zAlgValueNotNone,
|
|
174
|
-
authorization_encrypted_response_alg: import_zod4.z.optional(import_zod4.z.never()),
|
|
175
|
-
authorization_encrypted_response_enc: import_zod4.z.optional(import_zod4.z.never())
|
|
81
|
+
var zJarmSignOnlyClientMetadata = import_zod2.z.object({
|
|
82
|
+
authorization_signed_response_alg: import_oauth2.zAlgValueNotNone,
|
|
83
|
+
authorization_encrypted_response_alg: import_zod2.z.optional(import_zod2.z.never()),
|
|
84
|
+
authorization_encrypted_response_enc: import_zod2.z.optional(import_zod2.z.never())
|
|
176
85
|
});
|
|
177
|
-
var zJarmEncryptOnlyClientMetadata =
|
|
178
|
-
authorization_signed_response_alg:
|
|
179
|
-
authorization_encrypted_response_alg:
|
|
180
|
-
authorization_encrypted_response_enc:
|
|
86
|
+
var zJarmEncryptOnlyClientMetadata = import_zod2.z.object({
|
|
87
|
+
authorization_signed_response_alg: import_zod2.z.optional(import_zod2.z.never()),
|
|
88
|
+
authorization_encrypted_response_alg: import_zod2.z.string(),
|
|
89
|
+
authorization_encrypted_response_enc: import_zod2.z.optional(import_zod2.z.string())
|
|
181
90
|
});
|
|
182
|
-
var zJarmSignEncryptClientMetadata =
|
|
91
|
+
var zJarmSignEncryptClientMetadata = import_zod2.z.object({
|
|
183
92
|
authorization_signed_response_alg: zJarmSignOnlyClientMetadata.shape.authorization_signed_response_alg,
|
|
184
93
|
authorization_encrypted_response_alg: zJarmEncryptOnlyClientMetadata.shape.authorization_encrypted_response_alg,
|
|
185
94
|
authorization_encrypted_response_enc: zJarmEncryptOnlyClientMetadata.shape.authorization_encrypted_response_enc
|
|
186
95
|
});
|
|
187
|
-
var zJarmClientMetadata =
|
|
188
|
-
authorization_signed_response_alg:
|
|
189
|
-
authorization_encrypted_response_alg:
|
|
96
|
+
var zJarmClientMetadata = import_zod2.z.object({
|
|
97
|
+
authorization_signed_response_alg: import_zod2.z.optional(zJarmSignOnlyClientMetadata.shape.authorization_signed_response_alg),
|
|
98
|
+
authorization_encrypted_response_alg: import_zod2.z.optional(
|
|
190
99
|
zJarmEncryptOnlyClientMetadata.shape.authorization_encrypted_response_alg
|
|
191
100
|
),
|
|
192
|
-
authorization_encrypted_response_enc:
|
|
101
|
+
authorization_encrypted_response_enc: import_zod2.z.optional(
|
|
193
102
|
zJarmEncryptOnlyClientMetadata.shape.authorization_encrypted_response_enc
|
|
194
103
|
)
|
|
195
104
|
});
|
|
196
105
|
var zJarmClientMetadataParsed = zJarmClientMetadata.transform((client_metadata) => {
|
|
197
|
-
const parsedClientMeta = (0,
|
|
198
|
-
|
|
106
|
+
const parsedClientMeta = (0, import_utils.parseWithErrorHandling)(
|
|
107
|
+
import_zod2.z.union([zJarmEncryptOnlyClientMetadata, zJarmSignOnlyClientMetadata, zJarmSignEncryptClientMetadata]),
|
|
199
108
|
client_metadata,
|
|
200
109
|
"Invalid jarm client metadata."
|
|
201
110
|
);
|
|
@@ -229,32 +138,138 @@ var zJarmClientMetadataParsed = zJarmClientMetadata.transform((client_metadata)
|
|
|
229
138
|
}
|
|
230
139
|
};
|
|
231
140
|
}
|
|
232
|
-
throw new
|
|
141
|
+
throw new import_oauth2.Oauth2Error("Invalid jarm client metadata. Failed to parse.");
|
|
233
142
|
});
|
|
234
143
|
|
|
144
|
+
// src/jarm/jarm-extract-jwks.ts
|
|
145
|
+
function extractJwksFromClientMetadata(clientMetadata) {
|
|
146
|
+
const parsed = zJarmClientMetadataParsed.parse(clientMetadata);
|
|
147
|
+
const encryptionAlg = parsed.client_metadata.authorization_encrypted_response_enc;
|
|
148
|
+
const signingAlg = parsed.client_metadata.authorization_signed_response_alg;
|
|
149
|
+
const encJwk = clientMetadata.jwks.keys.find((key) => key.use === "enc" && key.alg === encryptionAlg) ?? clientMetadata.jwks.keys.find((key) => key.use === "enc") ?? // fallback, take first key. HAIP does not specify requirement on enc
|
|
150
|
+
clientMetadata.jwks.keys?.[0];
|
|
151
|
+
const sigJwk = clientMetadata.jwks.keys.find((key) => key.use === "sig" && key.alg === signingAlg) ?? clientMetadata.jwks.keys.find((key) => key.use === "sig") ?? // falback, take first key
|
|
152
|
+
clientMetadata.jwks.keys?.[0];
|
|
153
|
+
return { encJwk, sigJwk };
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// src/jarm/jarm-authorization-response/jarm-validate-authorization-response.ts
|
|
157
|
+
var import_oauth23 = require("@openid4vc/oauth2");
|
|
158
|
+
var import_utils2 = require("@openid4vc/utils");
|
|
159
|
+
|
|
160
|
+
// src/jarm/jarm-authorization-response/z-jarm-authorization-response.ts
|
|
161
|
+
var import_oauth22 = require("@openid4vc/oauth2");
|
|
162
|
+
var import_zod3 = require("zod");
|
|
163
|
+
var zJarmHeader = import_zod3.z.object({ ...import_oauth22.zJwtHeader.shape, apu: import_zod3.z.string().optional(), apv: import_zod3.z.string().optional() });
|
|
164
|
+
var zJarmAuthorizationResponse = import_zod3.z.object({
|
|
165
|
+
/**
|
|
166
|
+
* iss: The issuer URL of the authorization server that created the response
|
|
167
|
+
* aud: The client_id of the client the response is intended for
|
|
168
|
+
* exp: The expiration time of the JWT. A maximum JWT lifetime of 10 minutes is RECOMMENDED.
|
|
169
|
+
*/
|
|
170
|
+
...import_oauth22.zJwtPayload.shape,
|
|
171
|
+
...import_oauth22.zJwtPayload.pick({ iss: true, aud: true, exp: true }).required().shape,
|
|
172
|
+
state: import_zod3.z.optional(import_zod3.z.string())
|
|
173
|
+
}).passthrough();
|
|
174
|
+
var zJarmAuthorizationResponseEncryptedOnly = import_zod3.z.object({
|
|
175
|
+
...import_oauth22.zJwtPayload.shape,
|
|
176
|
+
state: import_zod3.z.optional(import_zod3.z.string())
|
|
177
|
+
}).passthrough();
|
|
178
|
+
|
|
179
|
+
// src/jarm/jarm-authorization-response/jarm-validate-authorization-response.ts
|
|
180
|
+
var jarmAuthorizationResponseValidate = (options) => {
|
|
181
|
+
const { expectedClientId, authorizationResponse } = options;
|
|
182
|
+
if (!zJarmAuthorizationResponse.safeParse(authorizationResponse).success) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (expectedClientId !== authorizationResponse.aud) {
|
|
186
|
+
throw new import_oauth23.Oauth2Error(
|
|
187
|
+
`Invalid 'aud' claim in JARM authorization response. Expected '${expectedClientId}' received '${JSON.stringify(authorizationResponse.aud)}'.`
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
if (authorizationResponse.exp !== void 0 && authorizationResponse.exp < (0, import_utils2.dateToSeconds)()) {
|
|
191
|
+
throw new import_oauth23.Oauth2Error("Jarm auth response is expired.");
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
// src/jarm/jarm-authorization-response/verify-jarm-authorization-response.ts
|
|
196
|
+
var decryptJarmAuthorizationResponseJwt = async (options) => {
|
|
197
|
+
const { jarmAuthorizationResponseJwt, callbacks, authorizationRequestPayload } = options;
|
|
198
|
+
const encryptionJwk = authorizationRequestPayload.client_metadata?.jwks ? extractJwksFromClientMetadata({
|
|
199
|
+
...authorizationRequestPayload.client_metadata,
|
|
200
|
+
jwks: authorizationRequestPayload.client_metadata.jwks
|
|
201
|
+
}).encJwk : void 0;
|
|
202
|
+
const result = await callbacks.decryptJwe(jarmAuthorizationResponseJwt, { jwk: encryptionJwk });
|
|
203
|
+
if (!result.decrypted) {
|
|
204
|
+
throw new import_oauth24.Oauth2Error("Failed to decrypt jarm auth response.");
|
|
205
|
+
}
|
|
206
|
+
return result.payload;
|
|
207
|
+
};
|
|
208
|
+
async function verifyJarmAuthorizationResponse(options) {
|
|
209
|
+
const { jarmAuthorizationResponseJwt, callbacks, expectedClientId, authorizationRequestPayload } = options;
|
|
210
|
+
const requestDataIsEncrypted = import_oauth24.zCompactJwe.safeParse(jarmAuthorizationResponseJwt).success;
|
|
211
|
+
const decryptedRequestData = requestDataIsEncrypted ? await decryptJarmAuthorizationResponseJwt({
|
|
212
|
+
jarmAuthorizationResponseJwt,
|
|
213
|
+
callbacks,
|
|
214
|
+
authorizationRequestPayload
|
|
215
|
+
}) : jarmAuthorizationResponseJwt;
|
|
216
|
+
const responseIsSigned = import_oauth24.zCompactJwt.safeParse(decryptedRequestData).success;
|
|
217
|
+
if (!requestDataIsEncrypted && !responseIsSigned) {
|
|
218
|
+
throw new import_oauth24.Oauth2Error("Jarm Auth Response must be either encrypted, signed, or signed and encrypted.");
|
|
219
|
+
}
|
|
220
|
+
let jarmAuthorizationResponse;
|
|
221
|
+
if (responseIsSigned) {
|
|
222
|
+
const { header: jwsProtectedHeader, payload: jwsPayload } = (0, import_oauth24.decodeJwt)({
|
|
223
|
+
jwt: decryptedRequestData,
|
|
224
|
+
headerSchema: import_zod4.default.object({ ...import_oauth24.zJwtHeader.shape, kid: import_zod4.default.string() })
|
|
225
|
+
});
|
|
226
|
+
const response = zJarmAuthorizationResponse.parse(jwsPayload);
|
|
227
|
+
const jwtSigner = (0, import_oauth24.jwtSignerFromJwt)({ header: jwsProtectedHeader, payload: jwsPayload });
|
|
228
|
+
const verificationResult = await options.callbacks.verifyJwt(jwtSigner, {
|
|
229
|
+
compact: decryptedRequestData,
|
|
230
|
+
header: jwsProtectedHeader,
|
|
231
|
+
payload: jwsPayload
|
|
232
|
+
});
|
|
233
|
+
if (!verificationResult.verified) {
|
|
234
|
+
throw new import_oauth24.Oauth2Error("Jarm Auth Response is not valid.");
|
|
235
|
+
}
|
|
236
|
+
jarmAuthorizationResponse = response;
|
|
237
|
+
} else {
|
|
238
|
+
const jsonRequestData = JSON.parse(decryptedRequestData);
|
|
239
|
+
jarmAuthorizationResponse = zJarmAuthorizationResponseEncryptedOnly.parse(jsonRequestData);
|
|
240
|
+
}
|
|
241
|
+
jarmAuthorizationResponseValidate({
|
|
242
|
+
expectedClientId,
|
|
243
|
+
authorizationResponse: jarmAuthorizationResponse
|
|
244
|
+
});
|
|
245
|
+
const type = requestDataIsEncrypted && responseIsSigned ? "SignedEncrypted" /* SignedEncrypted */ : requestDataIsEncrypted ? "Encrypted" /* Encrypted */ : "Signed" /* Signed */;
|
|
246
|
+
const issuer = jarmAuthorizationResponse.iss;
|
|
247
|
+
return { jarmAuthorizationResponse, type, issuer };
|
|
248
|
+
}
|
|
249
|
+
|
|
235
250
|
// src/authorization-request/create-authorization-request.ts
|
|
236
251
|
var import_oauth29 = require("@openid4vc/oauth2");
|
|
237
252
|
var import_utils6 = require("@openid4vc/utils");
|
|
238
253
|
|
|
239
|
-
// src/jar/create-jar-
|
|
254
|
+
// src/jar/create-jar-authorization-request.ts
|
|
240
255
|
var import_oauth25 = require("@openid4vc/oauth2");
|
|
241
|
-
async function
|
|
242
|
-
const { jwtSigner, jweEncryptor,
|
|
243
|
-
let
|
|
256
|
+
async function createJarAuthorizationRequest(options) {
|
|
257
|
+
const { jwtSigner, jweEncryptor, authorizationRequestPayload, requestUri, callbacks } = options;
|
|
258
|
+
let authorizationRequestJwt;
|
|
244
259
|
let encryptionJwk;
|
|
245
260
|
const { jwt, signerJwk } = await callbacks.signJwt(jwtSigner, {
|
|
246
261
|
header: { ...(0, import_oauth25.jwtHeaderFromJwtSigner)(jwtSigner), typ: "oauth-authz-req+jwt" },
|
|
247
|
-
payload: { ...options.additionalJwtPayload, ...
|
|
262
|
+
payload: { ...options.additionalJwtPayload, ...authorizationRequestPayload }
|
|
248
263
|
});
|
|
249
|
-
|
|
264
|
+
authorizationRequestJwt = jwt;
|
|
250
265
|
if (jweEncryptor) {
|
|
251
|
-
const encryptionResult = await callbacks.encryptJwe(jweEncryptor,
|
|
252
|
-
|
|
266
|
+
const encryptionResult = await callbacks.encryptJwe(jweEncryptor, authorizationRequestJwt);
|
|
267
|
+
authorizationRequestJwt = encryptionResult.jwe;
|
|
253
268
|
encryptionJwk = encryptionResult.encryptionJwk;
|
|
254
269
|
}
|
|
255
|
-
const client_id =
|
|
256
|
-
const
|
|
257
|
-
return {
|
|
270
|
+
const client_id = authorizationRequestPayload.client_id;
|
|
271
|
+
const jarAuthorizationRequest = requestUri ? { client_id, request_uri: requestUri } : { client_id, request: authorizationRequestJwt };
|
|
272
|
+
return { jarAuthorizationRequest, signerJwk, encryptionJwk, authorizationRequestJwt };
|
|
258
273
|
}
|
|
259
274
|
|
|
260
275
|
// src/authorization-request/validate-authorization-request.ts
|
|
@@ -323,20 +338,20 @@ var validateOpenid4vpAuthorizationRequestPayload = (options) => {
|
|
|
323
338
|
// src/authorization-request/validate-authorization-request-dc-api.ts
|
|
324
339
|
var import_oauth27 = require("@openid4vc/oauth2");
|
|
325
340
|
var validateOpenid4vpAuthorizationRequestDcApiPayload = (options) => {
|
|
326
|
-
const { params, isJarRequest,
|
|
341
|
+
const { params, isJarRequest, disableOriginValidation, origin } = options;
|
|
327
342
|
if (isJarRequest && !params.expected_origins) {
|
|
328
343
|
throw new import_oauth27.Oauth2ServerErrorResponseError({
|
|
329
344
|
error: import_oauth27.Oauth2ErrorCodes.InvalidRequest,
|
|
330
345
|
error_description: `The 'expected_origins' parameter MUST be present when using the dc_api response mode in combinaction with jar.`
|
|
331
346
|
});
|
|
332
347
|
}
|
|
333
|
-
if ([params.presentation_definition, params.dcql_query].filter(Boolean).length
|
|
348
|
+
if ([params.presentation_definition, params.dcql_query].filter(Boolean).length !== 1) {
|
|
334
349
|
throw new import_oauth27.Oauth2ServerErrorResponseError({
|
|
335
350
|
error: import_oauth27.Oauth2ErrorCodes.InvalidRequest,
|
|
336
|
-
error_description: "Exactly one of the following parameters MUST be present in the Authorization Request: dcql_query
|
|
351
|
+
error_description: "Exactly one of the following parameters MUST be present in the Authorization Request: dcql_query or presentation_definition"
|
|
337
352
|
});
|
|
338
353
|
}
|
|
339
|
-
if (params.expected_origins && !
|
|
354
|
+
if (params.expected_origins && !disableOriginValidation) {
|
|
340
355
|
if (!origin) {
|
|
341
356
|
throw new import_oauth27.Oauth2ServerErrorResponseError({
|
|
342
357
|
error: import_oauth27.Oauth2ErrorCodes.InvalidRequest,
|
|
@@ -420,7 +435,8 @@ var zOpenid4vpAuthorizationRequestDcApi = zOpenid4vpAuthorizationRequest.pick({
|
|
|
420
435
|
presentation_definition: true,
|
|
421
436
|
client_metadata: true,
|
|
422
437
|
transaction_data: true,
|
|
423
|
-
dcql_query: true
|
|
438
|
+
dcql_query: true,
|
|
439
|
+
trust_chain: true
|
|
424
440
|
}).extend({
|
|
425
441
|
client_id: import_zod8.z.optional(import_zod8.z.string()),
|
|
426
442
|
expected_origins: import_zod8.z.array(import_zod8.z.string()).optional(),
|
|
@@ -441,64 +457,67 @@ function isOpenid4vpAuthorizationRequestDcApi(request) {
|
|
|
441
457
|
|
|
442
458
|
// src/authorization-request/create-authorization-request.ts
|
|
443
459
|
async function createOpenid4vpAuthorizationRequest(options) {
|
|
444
|
-
const { jar, scheme = "openid4vp://",
|
|
460
|
+
const { jar, scheme = "openid4vp://", wallet, callbacks } = options;
|
|
445
461
|
let additionalJwtPayload;
|
|
446
|
-
let
|
|
447
|
-
if (isOpenid4vpAuthorizationRequestDcApi(
|
|
448
|
-
|
|
462
|
+
let authorizationRequestPayload;
|
|
463
|
+
if (isOpenid4vpAuthorizationRequestDcApi(options.authorizationRequestPayload)) {
|
|
464
|
+
authorizationRequestPayload = (0, import_utils6.parseWithErrorHandling)(
|
|
449
465
|
zOpenid4vpAuthorizationRequestDcApi,
|
|
450
|
-
|
|
466
|
+
options.authorizationRequestPayload,
|
|
451
467
|
"Invalid authorization request. Could not parse openid4vp dc_api authorization request."
|
|
452
468
|
);
|
|
453
|
-
if (jar && !
|
|
469
|
+
if (jar && !authorizationRequestPayload.expected_origins) {
|
|
454
470
|
throw new import_oauth29.Oauth2Error(
|
|
455
471
|
`The 'expected_origins' parameter MUST be present when using the dc_api response mode in combination with jar.`
|
|
456
472
|
);
|
|
457
473
|
}
|
|
458
474
|
validateOpenid4vpAuthorizationRequestDcApiPayload({
|
|
459
|
-
params:
|
|
475
|
+
params: authorizationRequestPayload,
|
|
460
476
|
isJarRequest: Boolean(jar),
|
|
461
|
-
|
|
477
|
+
disableOriginValidation: true
|
|
462
478
|
});
|
|
463
479
|
} else {
|
|
464
|
-
|
|
480
|
+
authorizationRequestPayload = (0, import_utils6.parseWithErrorHandling)(
|
|
465
481
|
zOpenid4vpAuthorizationRequest,
|
|
466
|
-
|
|
482
|
+
options.authorizationRequestPayload,
|
|
467
483
|
"Invalid authorization request. Could not parse openid4vp authorization request."
|
|
468
484
|
);
|
|
469
|
-
validateOpenid4vpAuthorizationRequestPayload({
|
|
485
|
+
validateOpenid4vpAuthorizationRequestPayload({
|
|
486
|
+
params: authorizationRequestPayload,
|
|
487
|
+
walletVerificationOptions: wallet
|
|
488
|
+
});
|
|
470
489
|
}
|
|
471
490
|
if (jar) {
|
|
472
491
|
if (!jar.additionalJwtPayload?.aud) {
|
|
473
492
|
additionalJwtPayload = { ...jar.additionalJwtPayload, aud: jar.requestUri };
|
|
474
493
|
}
|
|
475
|
-
|
|
476
|
-
if (jar) {
|
|
477
|
-
const jarResult = await createJarAuthRequest({
|
|
494
|
+
const jarResult = await createJarAuthorizationRequest({
|
|
478
495
|
...jar,
|
|
479
|
-
|
|
496
|
+
authorizationRequestPayload,
|
|
480
497
|
additionalJwtPayload,
|
|
481
498
|
callbacks
|
|
482
499
|
});
|
|
483
500
|
const url2 = new import_utils6.URL(scheme);
|
|
484
501
|
url2.search = `?${new import_utils6.URLSearchParams([
|
|
485
502
|
...url2.searchParams.entries(),
|
|
486
|
-
...(0, import_utils6.objectToQueryParams)(jarResult.
|
|
503
|
+
...(0, import_utils6.objectToQueryParams)(jarResult.jarAuthorizationRequest).entries()
|
|
487
504
|
]).toString()}`;
|
|
488
505
|
return {
|
|
489
|
-
|
|
490
|
-
|
|
506
|
+
authorizationRequestPayload,
|
|
507
|
+
authorizationRequestObject: jarResult.jarAuthorizationRequest,
|
|
508
|
+
authorizationRequest: url2.toString(),
|
|
491
509
|
jar: { ...jar, ...jarResult }
|
|
492
510
|
};
|
|
493
511
|
}
|
|
494
512
|
const url = new import_utils6.URL(scheme);
|
|
495
513
|
url.search = `?${new import_utils6.URLSearchParams([
|
|
496
514
|
...url.searchParams.entries(),
|
|
497
|
-
...(0, import_utils6.objectToQueryParams)(
|
|
515
|
+
...(0, import_utils6.objectToQueryParams)(authorizationRequestPayload).entries()
|
|
498
516
|
]).toString()}`;
|
|
499
517
|
return {
|
|
500
|
-
|
|
501
|
-
|
|
518
|
+
authorizationRequestPayload,
|
|
519
|
+
authorizationRequestObject: authorizationRequestPayload,
|
|
520
|
+
authorizationRequest: url.toString(),
|
|
502
521
|
jar: void 0
|
|
503
522
|
};
|
|
504
523
|
}
|
|
@@ -509,11 +528,11 @@ var import_utils8 = require("@openid4vc/utils");
|
|
|
509
528
|
var import_utils9 = require("@openid4vc/utils");
|
|
510
529
|
var import_zod10 = __toESM(require("zod"));
|
|
511
530
|
|
|
512
|
-
// src/jar/z-jar-
|
|
531
|
+
// src/jar/z-jar-authorization-request.ts
|
|
513
532
|
var import_oauth210 = require("@openid4vc/oauth2");
|
|
514
533
|
var import_utils7 = require("@openid4vc/utils");
|
|
515
534
|
var import_zod9 = require("zod");
|
|
516
|
-
var
|
|
535
|
+
var zJarAuthorizationRequest = import_zod9.z.object({
|
|
517
536
|
request: import_zod9.z.optional(import_zod9.z.string()),
|
|
518
537
|
request_uri: import_zod9.z.optional(import_utils7.zHttpsUrl),
|
|
519
538
|
request_uri_method: import_zod9.z.optional(import_zod9.z.string()),
|
|
@@ -535,7 +554,7 @@ function validateJarRequestParams(options) {
|
|
|
535
554
|
}
|
|
536
555
|
return jarRequestParams;
|
|
537
556
|
}
|
|
538
|
-
function
|
|
557
|
+
function isJarAuthorizationRequest(request) {
|
|
539
558
|
return "request" in request || "request_uri" in request;
|
|
540
559
|
}
|
|
541
560
|
|
|
@@ -558,10 +577,10 @@ function parseOpenid4vpAuthorizationRequestPayload(options) {
|
|
|
558
577
|
params = authorizationRequest;
|
|
559
578
|
}
|
|
560
579
|
const parsedRequest = (0, import_utils9.parseWithErrorHandling)(
|
|
561
|
-
import_zod10.default.union([zOpenid4vpAuthorizationRequest,
|
|
580
|
+
import_zod10.default.union([zOpenid4vpAuthorizationRequest, zJarAuthorizationRequest, zOpenid4vpAuthorizationRequestDcApi]),
|
|
562
581
|
params
|
|
563
582
|
);
|
|
564
|
-
if (
|
|
583
|
+
if (isJarAuthorizationRequest(parsedRequest)) {
|
|
565
584
|
return {
|
|
566
585
|
type: "jar",
|
|
567
586
|
provided,
|
|
@@ -584,17 +603,17 @@ function parseOpenid4vpAuthorizationRequestPayload(options) {
|
|
|
584
603
|
|
|
585
604
|
// src/authorization-request/resolve-authorization-request.ts
|
|
586
605
|
var import_oauth219 = require("@openid4vc/oauth2");
|
|
587
|
-
var
|
|
588
|
-
var
|
|
606
|
+
var import_utils14 = require("@openid4vc/utils");
|
|
607
|
+
var import_zod14 = __toESM(require("zod"));
|
|
589
608
|
|
|
590
609
|
// src/client-identifier-scheme/parse-client-identifier-scheme.ts
|
|
591
610
|
var import_oauth213 = require("@openid4vc/oauth2");
|
|
611
|
+
var import_utils10 = require("@openid4vc/utils");
|
|
592
612
|
|
|
593
613
|
// src/version.ts
|
|
594
614
|
var import_oauth212 = require("@openid4vc/oauth2");
|
|
595
615
|
function parseAuthorizationRequestVersion(request) {
|
|
596
616
|
const requirements = [];
|
|
597
|
-
const vp_formats = request.client_metadata?.vp_formats;
|
|
598
617
|
if (isOpenid4vpAuthorizationRequestDcApi(request) && (request.response_mode === "w3c_dc_api" || request.response_mode === "w3c_dc_api.jwt")) {
|
|
599
618
|
requirements.push(["<", 23]);
|
|
600
619
|
requirements.push([">=", 21]);
|
|
@@ -655,70 +674,56 @@ function parseAuthorizationRequestVersion(request) {
|
|
|
655
674
|
|
|
656
675
|
// src/client-identifier-scheme/parse-client-identifier-scheme.ts
|
|
657
676
|
function getClientId(options) {
|
|
658
|
-
|
|
677
|
+
const version = parseAuthorizationRequestVersion(options.authorizationRequestPayload);
|
|
678
|
+
if (version < 22) {
|
|
679
|
+
return getLegacyClientId(options);
|
|
680
|
+
}
|
|
681
|
+
if (isOpenid4vpAuthorizationRequestDcApi(options.authorizationRequestPayload)) {
|
|
659
682
|
if (!options.origin) {
|
|
660
683
|
throw new import_oauth213.Oauth2ServerErrorResponseError({
|
|
661
684
|
error: import_oauth213.Oauth2ErrorCodes.InvalidRequest,
|
|
662
685
|
error_description: "Failed to parse client identifier. 'origin' is required for requests with response_mode 'dc_api' and 'dc_api.jwt'"
|
|
663
686
|
});
|
|
664
687
|
}
|
|
665
|
-
if (!options.jar || !options.
|
|
666
|
-
return options.
|
|
688
|
+
if (!options.jar || !options.authorizationRequestPayload.client_id) return `web-origin:${options.origin}`;
|
|
689
|
+
return options.authorizationRequestPayload.client_id;
|
|
667
690
|
}
|
|
668
|
-
return options.
|
|
691
|
+
return options.authorizationRequestPayload.client_id;
|
|
669
692
|
}
|
|
670
693
|
function getLegacyClientId(options) {
|
|
671
|
-
const legacyClientIdScheme = options.
|
|
672
|
-
|
|
673
|
-
if (
|
|
674
|
-
clientIdScheme = "https";
|
|
675
|
-
} else {
|
|
676
|
-
clientIdScheme = legacyClientIdScheme;
|
|
677
|
-
}
|
|
678
|
-
if (isOpenid4vpAuthorizationRequestDcApi(options.request)) {
|
|
694
|
+
const legacyClientIdScheme = options.authorizationRequestPayload.client_id_scheme ?? "pre-registered";
|
|
695
|
+
const clientIdScheme = legacyClientIdScheme === "entity_id" ? "https" : legacyClientIdScheme;
|
|
696
|
+
if (isOpenid4vpAuthorizationRequestDcApi(options.authorizationRequestPayload)) {
|
|
679
697
|
if (!options.origin) {
|
|
680
698
|
throw new import_oauth213.Oauth2ServerErrorResponseError({
|
|
681
699
|
error: import_oauth213.Oauth2ErrorCodes.InvalidRequest,
|
|
682
700
|
error_description: "Failed to parse client identifier. 'origin' is required for requests with response_mode 'dc_api' and 'dc_api.jwt'"
|
|
683
701
|
});
|
|
684
702
|
}
|
|
685
|
-
if (!options.jar || !options.
|
|
686
|
-
return `${clientIdScheme}:${options.
|
|
703
|
+
if (!options.jar || !options.authorizationRequestPayload.client_id) return `web-origin:${options.origin}`;
|
|
704
|
+
return `${clientIdScheme}:${options.authorizationRequestPayload.client_id}`;
|
|
687
705
|
}
|
|
688
706
|
if (clientIdScheme === "https" || clientIdScheme === "did") {
|
|
689
|
-
return options.
|
|
707
|
+
return options.authorizationRequestPayload.client_id;
|
|
690
708
|
}
|
|
691
709
|
if (clientIdScheme === "pre-registered") {
|
|
692
|
-
return options.
|
|
710
|
+
return options.authorizationRequestPayload.client_id;
|
|
693
711
|
}
|
|
694
|
-
return `${clientIdScheme}:${options.
|
|
712
|
+
return `${clientIdScheme}:${options.authorizationRequestPayload.client_id}`;
|
|
695
713
|
}
|
|
696
714
|
function parseClientIdentifier(options, parserConfig) {
|
|
697
|
-
const {
|
|
698
|
-
const version = parseAuthorizationRequestVersion(request);
|
|
699
|
-
if (version < 22) {
|
|
700
|
-
const legacyClientIdScheme = request.client_id_scheme ?? "pre-registered";
|
|
701
|
-
let clientIdSchem;
|
|
702
|
-
if (legacyClientIdScheme) {
|
|
703
|
-
if (legacyClientIdScheme === "entity_id") {
|
|
704
|
-
clientIdSchem = "https";
|
|
705
|
-
} else {
|
|
706
|
-
clientIdSchem = legacyClientIdScheme;
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
const isDcApiRequest = isOpenid4vpAuthorizationRequestDcApi(request);
|
|
711
|
-
const clientId = version < 22 ? getLegacyClientId(options) : getClientId(options);
|
|
715
|
+
const { authorizationRequestPayload, jar } = options;
|
|
712
716
|
const parserConfigWithDefaults = {
|
|
713
717
|
supportedSchemes: parserConfig?.supportedSchemes || Object.values(zClientIdScheme.options)
|
|
714
718
|
};
|
|
719
|
+
const clientId = getClientId(options);
|
|
715
720
|
const colonIndex = clientId.indexOf(":");
|
|
716
721
|
if (colonIndex === -1) {
|
|
717
722
|
return {
|
|
718
723
|
scheme: "pre-registered",
|
|
719
724
|
identifier: clientId,
|
|
720
725
|
originalValue: clientId,
|
|
721
|
-
clientMetadata:
|
|
726
|
+
clientMetadata: authorizationRequestPayload.client_metadata
|
|
722
727
|
};
|
|
723
728
|
}
|
|
724
729
|
const schemePart = clientId.substring(0, colonIndex);
|
|
@@ -731,12 +736,6 @@ function parseClientIdentifier(options, parserConfig) {
|
|
|
731
736
|
}
|
|
732
737
|
const scheme = schemePart;
|
|
733
738
|
if (scheme === "https") {
|
|
734
|
-
if (isDcApiRequest) {
|
|
735
|
-
throw new import_oauth213.Oauth2ServerErrorResponseError({
|
|
736
|
-
error: import_oauth213.Oauth2ErrorCodes.InvalidRequest,
|
|
737
|
-
error_description: `The client identifier scheme 'https' is not supported when using the dc_api response mode.`
|
|
738
|
-
});
|
|
739
|
-
}
|
|
740
739
|
if (!clientId.startsWith("https://") && !((0, import_oauth213.getGlobalConfig)().allowInsecureUrls && clientId.startsWith("http://"))) {
|
|
741
740
|
throw new import_oauth213.Oauth2ServerErrorResponseError({
|
|
742
741
|
error: import_oauth213.Oauth2ErrorCodes.InvalidRequest,
|
|
@@ -747,7 +746,7 @@ function parseClientIdentifier(options, parserConfig) {
|
|
|
747
746
|
scheme,
|
|
748
747
|
identifier: clientId,
|
|
749
748
|
originalValue: clientId,
|
|
750
|
-
trustChain:
|
|
749
|
+
trustChain: authorizationRequestPayload.trust_chain
|
|
751
750
|
};
|
|
752
751
|
}
|
|
753
752
|
if (scheme === "redirect_uri") {
|
|
@@ -757,7 +756,7 @@ function parseClientIdentifier(options, parserConfig) {
|
|
|
757
756
|
error_description: 'Using client identifier scheme "redirect_uri" the request MUST NOT be signed.'
|
|
758
757
|
});
|
|
759
758
|
}
|
|
760
|
-
if (isOpenid4vpAuthorizationRequestDcApi(
|
|
759
|
+
if (isOpenid4vpAuthorizationRequestDcApi(authorizationRequestPayload)) {
|
|
761
760
|
throw new import_oauth213.Oauth2ServerErrorResponseError({
|
|
762
761
|
error: import_oauth213.Oauth2ErrorCodes.InvalidRequest,
|
|
763
762
|
error_description: `The client identifier scheme 'redirect_uri' is not supported when using the dc_api response mode.`
|
|
@@ -767,7 +766,7 @@ function parseClientIdentifier(options, parserConfig) {
|
|
|
767
766
|
scheme,
|
|
768
767
|
identifier: identifierPart,
|
|
769
768
|
originalValue: clientId,
|
|
770
|
-
redirectUri:
|
|
769
|
+
redirectUri: authorizationRequestPayload.redirect_uri ?? authorizationRequestPayload.response_uri
|
|
771
770
|
};
|
|
772
771
|
}
|
|
773
772
|
if (scheme === "did") {
|
|
@@ -833,9 +832,9 @@ function parseClientIdentifier(options, parserConfig) {
|
|
|
833
832
|
error_description: `Invalid client identifier. One of the leaf certificates san dns names [${sanDnsNames.join(", ")}] must match the client identifier '${identifierPart}'. `
|
|
834
833
|
});
|
|
835
834
|
}
|
|
836
|
-
if (!isOpenid4vpAuthorizationRequestDcApi(
|
|
837
|
-
const uri =
|
|
838
|
-
if (!uri ||
|
|
835
|
+
if (!isOpenid4vpAuthorizationRequestDcApi(authorizationRequestPayload)) {
|
|
836
|
+
const uri = authorizationRequestPayload.redirect_uri ?? authorizationRequestPayload.response_uri;
|
|
837
|
+
if (!uri || new import_utils10.URL(uri).hostname !== identifierPart) {
|
|
839
838
|
throw new import_oauth213.Oauth2ServerErrorResponseError({
|
|
840
839
|
error: import_oauth213.Oauth2ErrorCodes.InvalidRequest,
|
|
841
840
|
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."
|
|
@@ -860,8 +859,8 @@ function parseClientIdentifier(options, parserConfig) {
|
|
|
860
859
|
error_description: `Invalid client identifier. One of the leaf certificates san uri names [${sanUriNames.join(", ")}] must match the client identifier '${identifierPart}'.`
|
|
861
860
|
});
|
|
862
861
|
}
|
|
863
|
-
if (!isOpenid4vpAuthorizationRequestDcApi(
|
|
864
|
-
const uri =
|
|
862
|
+
if (!isOpenid4vpAuthorizationRequestDcApi(authorizationRequestPayload)) {
|
|
863
|
+
const uri = authorizationRequestPayload.redirect_uri || authorizationRequestPayload.response_uri;
|
|
865
864
|
if (!uri || uri !== identifierPart) {
|
|
866
865
|
throw new import_oauth213.Oauth2ServerErrorResponseError({
|
|
867
866
|
error: import_oauth213.Oauth2ErrorCodes.InvalidRequest,
|
|
@@ -882,7 +881,7 @@ function parseClientIdentifier(options, parserConfig) {
|
|
|
882
881
|
scheme,
|
|
883
882
|
identifier: identifierPart,
|
|
884
883
|
originalValue: clientId,
|
|
885
|
-
clientMetadata:
|
|
884
|
+
clientMetadata: authorizationRequestPayload.client_metadata
|
|
886
885
|
};
|
|
887
886
|
}
|
|
888
887
|
if (scheme === "verifier_attestation") {
|
|
@@ -899,42 +898,17 @@ function parseClientIdentifier(options, parserConfig) {
|
|
|
899
898
|
originalValue: clientId
|
|
900
899
|
};
|
|
901
900
|
}
|
|
902
|
-
function getDomainFromUrl(url) {
|
|
903
|
-
try {
|
|
904
|
-
const regex = /[#/?]/;
|
|
905
|
-
const domain = url.split("://")[1].split(regex)[0];
|
|
906
|
-
return domain;
|
|
907
|
-
} catch (error) {
|
|
908
|
-
throw new import_oauth213.Oauth2ServerErrorResponseError({
|
|
909
|
-
error: import_oauth213.Oauth2ErrorCodes.ServerError,
|
|
910
|
-
error_description: `Url '${url}' is not a valid URL`
|
|
911
|
-
});
|
|
912
|
-
}
|
|
913
|
-
}
|
|
914
901
|
|
|
915
902
|
// src/fetch-client-metadata.ts
|
|
916
903
|
var import_oauth214 = require("@openid4vc/oauth2");
|
|
917
|
-
var
|
|
918
|
-
|
|
919
|
-
// src/models/z-wallet-metadata.ts
|
|
920
|
-
var import_zod11 = require("zod");
|
|
921
|
-
var zWalletMetadata = import_zod11.z.object({
|
|
922
|
-
presentation_definition_uri_supported: import_zod11.z.optional(import_zod11.z.boolean()),
|
|
923
|
-
vp_formats_supported: zVpFormatsSupported,
|
|
924
|
-
client_id_schemes_supported: import_zod11.z.optional(import_zod11.z.array(zClientIdScheme)),
|
|
925
|
-
request_object_signing_alg_values_supported: import_zod11.z.optional(import_zod11.z.array(import_zod11.z.string())),
|
|
926
|
-
authorization_encryption_alg_values_supported: import_zod11.z.optional(import_zod11.z.array(import_zod11.z.string())),
|
|
927
|
-
authorization_encryption_enc_values_supported: import_zod11.z.optional(import_zod11.z.array(import_zod11.z.string()))
|
|
928
|
-
});
|
|
929
|
-
|
|
930
|
-
// src/fetch-client-metadata.ts
|
|
904
|
+
var import_utils11 = require("@openid4vc/utils");
|
|
931
905
|
async function fetchClientMetadata(options) {
|
|
932
906
|
const { fetch, clientMetadataUri } = options;
|
|
933
|
-
const fetcher = (0,
|
|
934
|
-
const { result, response } = await fetcher(
|
|
907
|
+
const fetcher = (0, import_utils11.createZodFetcher)(fetch);
|
|
908
|
+
const { result, response } = await fetcher(zClientMetadata, import_utils11.ContentType.Json, clientMetadataUri, {
|
|
935
909
|
method: "GET",
|
|
936
910
|
headers: {
|
|
937
|
-
Accept:
|
|
911
|
+
Accept: import_utils11.ContentType.Json
|
|
938
912
|
}
|
|
939
913
|
});
|
|
940
914
|
if (!response.ok) {
|
|
@@ -957,23 +931,23 @@ var import_oauth217 = require("@openid4vc/oauth2");
|
|
|
957
931
|
|
|
958
932
|
// src/jar/jar-request-object/fetch-jar-request-object.ts
|
|
959
933
|
var import_oauth215 = require("@openid4vc/oauth2");
|
|
960
|
-
var
|
|
961
|
-
var
|
|
934
|
+
var import_utils12 = require("@openid4vc/utils");
|
|
935
|
+
var import_zod11 = require("zod");
|
|
962
936
|
async function fetchJarRequestObject(options) {
|
|
963
937
|
const { requestUri, clientIdentifierScheme, method, wallet, fetch } = options;
|
|
964
|
-
const fetcher = (0,
|
|
938
|
+
const fetcher = (0, import_utils12.createZodFetcher)(fetch);
|
|
965
939
|
let requestBody = wallet.metadata ? { wallet_metadata: wallet.metadata, wallet_nonce: wallet.nonce } : void 0;
|
|
966
940
|
if (requestBody?.wallet_metadata?.request_object_signing_alg_values_supported && clientIdentifierScheme === "redirect_uri") {
|
|
967
941
|
const { request_object_signing_alg_values_supported, ...rest } = requestBody.wallet_metadata;
|
|
968
942
|
requestBody = { ...requestBody, wallet_metadata: { ...rest } };
|
|
969
943
|
}
|
|
970
|
-
const { result, response } = await fetcher(
|
|
944
|
+
const { result, response } = await fetcher(import_zod11.z.string(), import_utils12.ContentType.OAuthAuthorizationRequestJwt, requestUri, {
|
|
971
945
|
method,
|
|
972
946
|
headers: {
|
|
973
|
-
Accept: `${
|
|
974
|
-
"Content-Type":
|
|
947
|
+
Accept: `${import_utils12.ContentType.OAuthAuthorizationRequestJwt}, ${import_utils12.ContentType.Jwt};q=0.9`,
|
|
948
|
+
"Content-Type": import_utils12.ContentType.XWwwFormUrlencoded
|
|
975
949
|
},
|
|
976
|
-
body: method === "POST" ? (0,
|
|
950
|
+
body: method === "POST" ? (0, import_utils12.objectToQueryParams)(wallet.metadata ?? {}) : void 0
|
|
977
951
|
});
|
|
978
952
|
if (!response.ok) {
|
|
979
953
|
throw new import_oauth215.Oauth2ServerErrorResponseError({
|
|
@@ -992,10 +966,10 @@ async function fetchJarRequestObject(options) {
|
|
|
992
966
|
|
|
993
967
|
// src/jar/jar-request-object/z-jar-request-object.ts
|
|
994
968
|
var import_oauth216 = require("@openid4vc/oauth2");
|
|
995
|
-
var
|
|
996
|
-
var zJarRequestObjectPayload =
|
|
969
|
+
var import_zod12 = require("zod");
|
|
970
|
+
var zJarRequestObjectPayload = import_zod12.z.object({
|
|
997
971
|
...import_oauth216.zJwtPayload.shape,
|
|
998
|
-
client_id:
|
|
972
|
+
client_id: import_zod12.z.string()
|
|
999
973
|
}).passthrough();
|
|
1000
974
|
|
|
1001
975
|
// src/jar/handle-jar-request/verify-jar-request.ts
|
|
@@ -1026,17 +1000,17 @@ async function verifyJarRequest(options) {
|
|
|
1026
1000
|
error_description: "Jar Request Object is not a valid JWS."
|
|
1027
1001
|
});
|
|
1028
1002
|
}
|
|
1029
|
-
const {
|
|
1003
|
+
const { authorizationRequestParams, signer } = await verifyJarRequestObject({
|
|
1030
1004
|
decryptedRequestObject,
|
|
1031
1005
|
callbacks
|
|
1032
1006
|
});
|
|
1033
|
-
if (!
|
|
1007
|
+
if (!authorizationRequestParams.client_id) {
|
|
1034
1008
|
throw new import_oauth217.Oauth2ServerErrorResponseError({
|
|
1035
1009
|
error: import_oauth217.Oauth2ErrorCodes.InvalidRequestObject,
|
|
1036
1010
|
error_description: 'Jar Request Object is missing the required "client_id" field.'
|
|
1037
1011
|
});
|
|
1038
1012
|
}
|
|
1039
|
-
if (jarRequestParams.client_id !==
|
|
1013
|
+
if (jarRequestParams.client_id !== authorizationRequestParams.client_id) {
|
|
1040
1014
|
throw new import_oauth217.Oauth2ServerErrorResponseError({
|
|
1041
1015
|
error: import_oauth217.Oauth2ErrorCodes.InvalidRequest,
|
|
1042
1016
|
error_description: "client_id does not match the request object client_id."
|
|
@@ -1044,7 +1018,7 @@ async function verifyJarRequest(options) {
|
|
|
1044
1018
|
}
|
|
1045
1019
|
return {
|
|
1046
1020
|
sendBy,
|
|
1047
|
-
|
|
1021
|
+
authorizationRequestParams,
|
|
1048
1022
|
signer,
|
|
1049
1023
|
decryptionJwk
|
|
1050
1024
|
};
|
|
@@ -1085,26 +1059,26 @@ async function verifyJarRequestObject(options) {
|
|
|
1085
1059
|
error_description: `Invalid Jar Request Object typ header. Expected "oauth-authz-req+jwt", received "${jwt.header.typ}".`
|
|
1086
1060
|
});
|
|
1087
1061
|
}
|
|
1088
|
-
return {
|
|
1062
|
+
return { authorizationRequestParams: jwt.payload, signer };
|
|
1089
1063
|
}
|
|
1090
1064
|
|
|
1091
1065
|
// src/transaction-data/parse-transaction-data.ts
|
|
1092
1066
|
var import_oauth218 = require("@openid4vc/oauth2");
|
|
1093
|
-
var
|
|
1067
|
+
var import_utils13 = require("@openid4vc/utils");
|
|
1094
1068
|
|
|
1095
1069
|
// src/transaction-data/z-transaction-data.ts
|
|
1096
|
-
var
|
|
1097
|
-
var zTransactionEntry =
|
|
1098
|
-
type:
|
|
1099
|
-
credential_ids:
|
|
1100
|
-
transaction_data_hashes_alg:
|
|
1070
|
+
var import_zod13 = require("zod");
|
|
1071
|
+
var zTransactionEntry = import_zod13.z.object({
|
|
1072
|
+
type: import_zod13.z.string(),
|
|
1073
|
+
credential_ids: import_zod13.z.array(import_zod13.z.string()).nonempty(),
|
|
1074
|
+
transaction_data_hashes_alg: import_zod13.z.array(import_zod13.z.string()).optional()
|
|
1101
1075
|
});
|
|
1102
|
-
var zTransactionData =
|
|
1076
|
+
var zTransactionData = import_zod13.z.array(zTransactionEntry);
|
|
1103
1077
|
|
|
1104
1078
|
// src/transaction-data/parse-transaction-data.ts
|
|
1105
1079
|
function parseTransactionData(options) {
|
|
1106
1080
|
const { transactionData } = options;
|
|
1107
|
-
const decoded = transactionData.map((tdEntry) => (0,
|
|
1081
|
+
const decoded = transactionData.map((tdEntry) => (0, import_utils13.parseIfJson)((0, import_utils13.encodeToUtf8String)((0, import_utils13.decodeBase64)(tdEntry))));
|
|
1108
1082
|
const parsedResult = zTransactionData.safeParse(decoded);
|
|
1109
1083
|
if (!parsedResult.success) {
|
|
1110
1084
|
throw new import_oauth218.Oauth2ServerErrorResponseError({
|
|
@@ -1121,138 +1095,132 @@ function parseTransactionData(options) {
|
|
|
1121
1095
|
|
|
1122
1096
|
// src/authorization-request/resolve-authorization-request.ts
|
|
1123
1097
|
async function resolveOpenid4vpAuthorizationRequest(options) {
|
|
1124
|
-
const {
|
|
1125
|
-
let
|
|
1126
|
-
const parsed = (0,
|
|
1127
|
-
|
|
1128
|
-
|
|
1098
|
+
const { wallet, callbacks, origin, disableOriginValidation } = options;
|
|
1099
|
+
let authorizationRequestPayload;
|
|
1100
|
+
const parsed = (0, import_utils14.parseWithErrorHandling)(
|
|
1101
|
+
import_zod14.default.union([zOpenid4vpAuthorizationRequestDcApi, zOpenid4vpAuthorizationRequest, zJarAuthorizationRequest]),
|
|
1102
|
+
options.authorizationRequestPayload,
|
|
1129
1103
|
"Invalid authorization request. Could not parse openid4vp authorization request as openid4vp or jar auth request."
|
|
1130
1104
|
);
|
|
1131
1105
|
let jar;
|
|
1132
|
-
if (
|
|
1106
|
+
if (isJarAuthorizationRequest(parsed)) {
|
|
1133
1107
|
jar = await verifyJarRequest({ jarRequestParams: parsed, callbacks, wallet });
|
|
1134
|
-
const
|
|
1135
|
-
|
|
1136
|
-
jar.
|
|
1108
|
+
const parsedJarAuthorizationRequestPayload = (0, import_utils14.parseWithErrorHandling)(
|
|
1109
|
+
import_zod14.default.union([zOpenid4vpAuthorizationRequestDcApi, zOpenid4vpAuthorizationRequest]),
|
|
1110
|
+
jar.authorizationRequestParams,
|
|
1137
1111
|
"Invalid authorization request. Could not parse jar request payload as openid4vp auth request."
|
|
1138
1112
|
);
|
|
1139
|
-
|
|
1140
|
-
|
|
1113
|
+
authorizationRequestPayload = validateOpenId4vpAuthorizationRequestPayload({
|
|
1114
|
+
authorizationRequestPayload: parsedJarAuthorizationRequestPayload,
|
|
1141
1115
|
wallet,
|
|
1142
1116
|
jar: true,
|
|
1143
1117
|
origin,
|
|
1144
|
-
|
|
1118
|
+
disableOriginValidation
|
|
1145
1119
|
});
|
|
1146
1120
|
} else {
|
|
1147
|
-
|
|
1148
|
-
|
|
1121
|
+
authorizationRequestPayload = validateOpenId4vpAuthorizationRequestPayload({
|
|
1122
|
+
authorizationRequestPayload: parsed,
|
|
1149
1123
|
wallet,
|
|
1150
1124
|
jar: false,
|
|
1151
1125
|
origin,
|
|
1152
|
-
|
|
1126
|
+
disableOriginValidation
|
|
1153
1127
|
});
|
|
1154
1128
|
}
|
|
1155
|
-
let clientMetadata;
|
|
1156
|
-
if (!isOpenid4vpAuthorizationRequestDcApi(
|
|
1157
|
-
clientMetadata = await fetchClientMetadata({ clientMetadataUri:
|
|
1129
|
+
let clientMetadata = authorizationRequestPayload.client_metadata;
|
|
1130
|
+
if (!isOpenid4vpAuthorizationRequestDcApi(authorizationRequestPayload) && !clientMetadata && authorizationRequestPayload.client_metadata_uri) {
|
|
1131
|
+
clientMetadata = await fetchClientMetadata({ clientMetadataUri: authorizationRequestPayload.client_metadata_uri });
|
|
1158
1132
|
}
|
|
1159
1133
|
const clientMeta = parseClientIdentifier({
|
|
1160
|
-
|
|
1134
|
+
authorizationRequestPayload: {
|
|
1135
|
+
...authorizationRequestPayload,
|
|
1136
|
+
client_metadata: clientMetadata
|
|
1137
|
+
},
|
|
1161
1138
|
jar,
|
|
1162
1139
|
callbacks,
|
|
1163
1140
|
origin
|
|
1164
1141
|
});
|
|
1165
1142
|
let pex;
|
|
1166
1143
|
let dcql;
|
|
1167
|
-
if (
|
|
1168
|
-
if (
|
|
1144
|
+
if (authorizationRequestPayload.presentation_definition || authorizationRequestPayload.presentation_definition_uri) {
|
|
1145
|
+
if (authorizationRequestPayload.presentation_definition_uri) {
|
|
1169
1146
|
throw new import_oauth219.Oauth2ServerErrorResponseError({
|
|
1170
1147
|
error: import_oauth219.Oauth2ErrorCodes.InvalidRequest,
|
|
1171
1148
|
error_description: "Cannot fetch presentation definition from URI. Not supported."
|
|
1172
1149
|
});
|
|
1173
1150
|
}
|
|
1174
1151
|
pex = {
|
|
1175
|
-
presentation_definition:
|
|
1176
|
-
presentation_definition_uri:
|
|
1152
|
+
presentation_definition: authorizationRequestPayload.presentation_definition,
|
|
1153
|
+
presentation_definition_uri: authorizationRequestPayload.presentation_definition_uri
|
|
1177
1154
|
};
|
|
1178
1155
|
}
|
|
1179
|
-
if (
|
|
1180
|
-
dcql = { query:
|
|
1156
|
+
if (authorizationRequestPayload.dcql_query) {
|
|
1157
|
+
dcql = { query: authorizationRequestPayload.dcql_query };
|
|
1181
1158
|
}
|
|
1182
|
-
const transactionData =
|
|
1159
|
+
const transactionData = authorizationRequestPayload.transaction_data ? parseTransactionData({ transactionData: authorizationRequestPayload.transaction_data }) : void 0;
|
|
1183
1160
|
return {
|
|
1184
1161
|
transactionData,
|
|
1185
|
-
|
|
1162
|
+
authorizationRequestPayload,
|
|
1186
1163
|
jar,
|
|
1187
|
-
client:
|
|
1164
|
+
client: clientMeta,
|
|
1188
1165
|
pex,
|
|
1189
1166
|
dcql
|
|
1190
1167
|
};
|
|
1191
1168
|
}
|
|
1192
|
-
function
|
|
1193
|
-
const {
|
|
1194
|
-
if (isOpenid4vpAuthorizationRequestDcApi(
|
|
1169
|
+
function validateOpenId4vpAuthorizationRequestPayload(options) {
|
|
1170
|
+
const { authorizationRequestPayload, wallet, jar, origin, disableOriginValidation } = options;
|
|
1171
|
+
if (isOpenid4vpAuthorizationRequestDcApi(authorizationRequestPayload)) {
|
|
1195
1172
|
validateOpenid4vpAuthorizationRequestDcApiPayload({
|
|
1196
|
-
params:
|
|
1173
|
+
params: authorizationRequestPayload,
|
|
1197
1174
|
isJarRequest: jar,
|
|
1198
|
-
|
|
1175
|
+
disableOriginValidation,
|
|
1199
1176
|
origin
|
|
1200
1177
|
});
|
|
1201
|
-
return
|
|
1178
|
+
return authorizationRequestPayload;
|
|
1202
1179
|
}
|
|
1203
|
-
validateOpenid4vpAuthorizationRequestPayload({
|
|
1204
|
-
|
|
1180
|
+
validateOpenid4vpAuthorizationRequestPayload({
|
|
1181
|
+
params: authorizationRequestPayload,
|
|
1182
|
+
walletVerificationOptions: wallet
|
|
1183
|
+
});
|
|
1184
|
+
return authorizationRequestPayload;
|
|
1205
1185
|
}
|
|
1206
1186
|
|
|
1207
1187
|
// src/authorization-response/create-authorization-response.ts
|
|
1208
1188
|
var import_oauth222 = require("@openid4vc/oauth2");
|
|
1209
|
-
var
|
|
1189
|
+
var import_utils15 = require("@openid4vc/utils");
|
|
1210
1190
|
|
|
1211
1191
|
// ../utils/src/date.ts
|
|
1212
1192
|
function addSecondsToDate(date, seconds) {
|
|
1213
1193
|
return new Date(date.getTime() + seconds * 1e3);
|
|
1214
1194
|
}
|
|
1215
1195
|
|
|
1216
|
-
// src/jarm/jarm-
|
|
1196
|
+
// src/jarm/jarm-authorization-response-create.ts
|
|
1217
1197
|
var import_oauth220 = require("@openid4vc/oauth2");
|
|
1218
|
-
async function
|
|
1219
|
-
const {
|
|
1198
|
+
async function createJarmAuthorizationResponse(options) {
|
|
1199
|
+
const { jarmAuthorizationResponse, jweEncryptor, jwtSigner, callbacks } = options;
|
|
1220
1200
|
if (!jwtSigner && jweEncryptor) {
|
|
1221
|
-
const { jwe } = await callbacks.encryptJwe(jweEncryptor, JSON.stringify(
|
|
1222
|
-
return {
|
|
1201
|
+
const { jwe } = await callbacks.encryptJwe(jweEncryptor, JSON.stringify(jarmAuthorizationResponse));
|
|
1202
|
+
return { jarmAuthorizationResponseJwt: jwe };
|
|
1223
1203
|
}
|
|
1224
1204
|
if (jwtSigner && !jweEncryptor) {
|
|
1225
1205
|
const signed2 = await callbacks.signJwt(jwtSigner, {
|
|
1226
1206
|
header: (0, import_oauth220.jwtHeaderFromJwtSigner)(jwtSigner),
|
|
1227
|
-
payload:
|
|
1207
|
+
payload: jarmAuthorizationResponse
|
|
1228
1208
|
});
|
|
1229
|
-
return {
|
|
1209
|
+
return { jarmAuthorizationResponseJwt: signed2.jwt };
|
|
1230
1210
|
}
|
|
1231
1211
|
if (!jwtSigner || !jweEncryptor) {
|
|
1232
1212
|
throw new import_oauth220.Oauth2Error("JWT signer and/or encryptor are required to create a JARM auth response.");
|
|
1233
1213
|
}
|
|
1234
1214
|
const signed = await callbacks.signJwt(jwtSigner, {
|
|
1235
1215
|
header: (0, import_oauth220.jwtHeaderFromJwtSigner)(jwtSigner),
|
|
1236
|
-
payload:
|
|
1216
|
+
payload: jarmAuthorizationResponse
|
|
1237
1217
|
});
|
|
1238
1218
|
const encrypted = await callbacks.encryptJwe(jweEncryptor, signed.jwt);
|
|
1239
|
-
return {
|
|
1240
|
-
}
|
|
1241
|
-
|
|
1242
|
-
// src/jarm/jarm-extract-jwks.ts
|
|
1243
|
-
function extractJwksFromClientMetadata(clientMetadata) {
|
|
1244
|
-
const parsed = zJarmClientMetadataParsed.parse(clientMetadata);
|
|
1245
|
-
const encryptionAlg = parsed.client_metadata.authorization_encrypted_response_enc;
|
|
1246
|
-
const signingAlg = parsed.client_metadata.authorization_signed_response_alg;
|
|
1247
|
-
const encJwk = clientMetadata.jwks.keys.find((key) => key.use === "enc" && key.alg === encryptionAlg) ?? clientMetadata.jwks.keys.find((key) => key.use === "enc") ?? // fallback, take first key. HAIP does not specify requirement on enc
|
|
1248
|
-
clientMetadata.jwks.keys?.[0];
|
|
1249
|
-
const sigJwk = clientMetadata.jwks.keys.find((key) => key.use === "sig" && key.alg === signingAlg) ?? clientMetadata.jwks.keys.find((key) => key.use === "sig") ?? // falback, take first key
|
|
1250
|
-
clientMetadata.jwks.keys?.[0];
|
|
1251
|
-
return { encJwk, sigJwk };
|
|
1219
|
+
return { jarmAuthorizationResponseJwt: encrypted.jwe };
|
|
1252
1220
|
}
|
|
1253
1221
|
|
|
1254
1222
|
// src/jarm/jarm-response-mode.ts
|
|
1255
|
-
var
|
|
1223
|
+
var import_zod15 = require("zod");
|
|
1256
1224
|
var jarmResponseMode = [
|
|
1257
1225
|
"jwt",
|
|
1258
1226
|
"query.jwt",
|
|
@@ -1261,7 +1229,7 @@ var jarmResponseMode = [
|
|
|
1261
1229
|
"direct_post.jwt",
|
|
1262
1230
|
"dc_api.jwt"
|
|
1263
1231
|
];
|
|
1264
|
-
var zJarmResponseMode =
|
|
1232
|
+
var zJarmResponseMode = import_zod15.z.enum(jarmResponseMode);
|
|
1265
1233
|
var isJarmResponseMode = (responseMode) => {
|
|
1266
1234
|
return jarmResponseMode.includes(responseMode);
|
|
1267
1235
|
};
|
|
@@ -1307,37 +1275,37 @@ function jarmAssertMetadataSupported(options) {
|
|
|
1307
1275
|
|
|
1308
1276
|
// src/authorization-response/create-authorization-response.ts
|
|
1309
1277
|
async function createOpenid4vpAuthorizationResponse(options) {
|
|
1310
|
-
const {
|
|
1311
|
-
const
|
|
1312
|
-
...options.
|
|
1313
|
-
..."state" in
|
|
1278
|
+
const { authorizationRequestPayload, jarm, callbacks } = options;
|
|
1279
|
+
const authorizationResponsePayload = {
|
|
1280
|
+
...options.authorizationResponsePayload,
|
|
1281
|
+
..."state" in authorizationRequestPayload && { state: authorizationRequestPayload.state }
|
|
1314
1282
|
};
|
|
1315
|
-
if (
|
|
1283
|
+
if (authorizationRequestPayload.response_mode && isJarmResponseMode(authorizationRequestPayload.response_mode) && !jarm) {
|
|
1316
1284
|
throw new import_oauth222.Oauth2Error(
|
|
1317
|
-
`Missing jarm options for creating Jarm response with response mode '${
|
|
1285
|
+
`Missing jarm options for creating Jarm response with response mode '${authorizationRequestPayload.response_mode}'`
|
|
1318
1286
|
);
|
|
1319
1287
|
}
|
|
1320
1288
|
if (!jarm) {
|
|
1321
1289
|
return {
|
|
1322
|
-
|
|
1290
|
+
authorizationResponsePayload
|
|
1323
1291
|
};
|
|
1324
1292
|
}
|
|
1325
|
-
if (!
|
|
1293
|
+
if (!authorizationRequestPayload.client_metadata) {
|
|
1326
1294
|
throw new import_oauth222.Oauth2Error("Missing client metadata in the request params to assert Jarm metadata support.");
|
|
1327
1295
|
}
|
|
1328
|
-
if (!
|
|
1296
|
+
if (!authorizationRequestPayload.client_metadata.jwks) {
|
|
1329
1297
|
throw new import_oauth222.Oauth2ServerErrorResponseError({
|
|
1330
1298
|
error: import_oauth222.Oauth2ErrorCodes.InvalidRequest,
|
|
1331
1299
|
error_description: "Missing JWKS in client metadata. Cannot extract encryption JWK."
|
|
1332
1300
|
});
|
|
1333
1301
|
}
|
|
1334
1302
|
const supportedJarmMetadata = jarmAssertMetadataSupported({
|
|
1335
|
-
clientMetadata:
|
|
1303
|
+
clientMetadata: authorizationRequestPayload.client_metadata,
|
|
1336
1304
|
serverMetadata: jarm.serverMetadata
|
|
1337
1305
|
});
|
|
1338
1306
|
const clientMetaJwks = extractJwksFromClientMetadata({
|
|
1339
|
-
...
|
|
1340
|
-
jwks:
|
|
1307
|
+
...authorizationRequestPayload.client_metadata,
|
|
1308
|
+
jwks: authorizationRequestPayload.client_metadata.jwks
|
|
1341
1309
|
});
|
|
1342
1310
|
if (!clientMetaJwks?.encJwk) {
|
|
1343
1311
|
throw new import_oauth222.Oauth2ServerErrorResponseError({
|
|
@@ -1362,22 +1330,22 @@ async function createOpenid4vpAuthorizationResponse(options) {
|
|
|
1362
1330
|
additionalJwtPayload = {
|
|
1363
1331
|
iss: jarm.authorizationServer,
|
|
1364
1332
|
aud: jarm.audience,
|
|
1365
|
-
exp: jarm.expiresInSeconds ?? (0,
|
|
1333
|
+
exp: jarm.expiresInSeconds ?? (0, import_utils15.dateToSeconds)(addSecondsToDate(/* @__PURE__ */ new Date(), 60 * 10))
|
|
1366
1334
|
// default: 10 minutes
|
|
1367
1335
|
};
|
|
1368
1336
|
}
|
|
1369
1337
|
const jarmResponsePayload = {
|
|
1370
|
-
...
|
|
1338
|
+
...authorizationResponsePayload,
|
|
1371
1339
|
...additionalJwtPayload
|
|
1372
1340
|
};
|
|
1373
|
-
const result = await
|
|
1374
|
-
|
|
1341
|
+
const result = await createJarmAuthorizationResponse({
|
|
1342
|
+
jarmAuthorizationResponse: jarmResponsePayload,
|
|
1375
1343
|
jwtSigner: jarm?.jwtSigner,
|
|
1376
1344
|
jweEncryptor: jarm?.encryption && (supportedJarmMetadata.type === "encrypt" || supportedJarmMetadata.type === "sign_encrypt") ? {
|
|
1377
1345
|
method: "jwk",
|
|
1378
1346
|
publicJwk: clientMetaJwks.encJwk,
|
|
1379
1347
|
apu: jarm.encryption?.nonce,
|
|
1380
|
-
apv:
|
|
1348
|
+
apv: authorizationRequestPayload.nonce,
|
|
1381
1349
|
alg: supportedJarmMetadata.client_metadata.authorization_encrypted_response_alg,
|
|
1382
1350
|
enc: supportedJarmMetadata.client_metadata.authorization_encrypted_response_enc
|
|
1383
1351
|
} : void 0,
|
|
@@ -1387,32 +1355,32 @@ async function createOpenid4vpAuthorizationResponse(options) {
|
|
|
1387
1355
|
}
|
|
1388
1356
|
});
|
|
1389
1357
|
return {
|
|
1390
|
-
|
|
1391
|
-
jarm: { responseJwt: result.
|
|
1358
|
+
authorizationResponsePayload: jarmResponsePayload,
|
|
1359
|
+
jarm: { responseJwt: result.jarmAuthorizationResponseJwt }
|
|
1392
1360
|
};
|
|
1393
1361
|
}
|
|
1394
1362
|
|
|
1395
1363
|
// src/authorization-response/submit-authorization-response.ts
|
|
1396
1364
|
var import_oauth224 = require("@openid4vc/oauth2");
|
|
1397
|
-
var import_utils16 = require("@openid4vc/utils");
|
|
1398
1365
|
var import_utils17 = require("@openid4vc/utils");
|
|
1366
|
+
var import_utils18 = require("@openid4vc/utils");
|
|
1399
1367
|
|
|
1400
|
-
// src/jarm/jarm-
|
|
1368
|
+
// src/jarm/jarm-authorizatino-response-send.ts
|
|
1401
1369
|
var import_oauth223 = require("@openid4vc/oauth2");
|
|
1402
|
-
var
|
|
1403
|
-
var
|
|
1404
|
-
const {
|
|
1405
|
-
const responseEndpoint =
|
|
1370
|
+
var import_utils16 = require("@openid4vc/utils");
|
|
1371
|
+
var jarmAuthorizationResponseSend = (options) => {
|
|
1372
|
+
const { authorizationRequestPayload, jarmAuthorizationResponseJwt, callbacks } = options;
|
|
1373
|
+
const responseEndpoint = authorizationRequestPayload.response_uri ?? authorizationRequestPayload.redirect_uri;
|
|
1406
1374
|
if (!responseEndpoint) {
|
|
1407
1375
|
throw new import_oauth223.Oauth2Error(`Either 'response_uri' or 'redirect_uri' MUST be present in the authorization request`);
|
|
1408
1376
|
}
|
|
1409
|
-
const responseEndpointUrl = new
|
|
1410
|
-
return handleDirectPostJwt(responseEndpointUrl,
|
|
1377
|
+
const responseEndpointUrl = new import_utils16.URL(responseEndpoint);
|
|
1378
|
+
return handleDirectPostJwt(responseEndpointUrl, jarmAuthorizationResponseJwt, callbacks);
|
|
1411
1379
|
};
|
|
1412
1380
|
async function handleDirectPostJwt(responseEndpoint, responseJwt, callbacks) {
|
|
1413
|
-
const response = await (callbacks.fetch ??
|
|
1381
|
+
const response = await (callbacks.fetch ?? import_utils16.defaultFetcher)(responseEndpoint, {
|
|
1414
1382
|
method: "POST",
|
|
1415
|
-
headers: { "Content-Type":
|
|
1383
|
+
headers: { "Content-Type": import_utils16.ContentType.XWwwFormUrlencoded },
|
|
1416
1384
|
body: `response=${responseJwt}`
|
|
1417
1385
|
});
|
|
1418
1386
|
return {
|
|
@@ -1423,12 +1391,12 @@ async function handleDirectPostJwt(responseEndpoint, responseJwt, callbacks) {
|
|
|
1423
1391
|
|
|
1424
1392
|
// src/authorization-response/submit-authorization-response.ts
|
|
1425
1393
|
async function submitOpenid4vpAuthorizationResponse(options) {
|
|
1426
|
-
const {
|
|
1427
|
-
const url =
|
|
1394
|
+
const { authorizationRequestPayload, authorizationResponsePayload, jarm, callbacks } = options;
|
|
1395
|
+
const url = authorizationRequestPayload.response_uri;
|
|
1428
1396
|
if (jarm) {
|
|
1429
|
-
return
|
|
1430
|
-
|
|
1431
|
-
|
|
1397
|
+
return jarmAuthorizationResponseSend({
|
|
1398
|
+
authorizationRequestPayload,
|
|
1399
|
+
jarmAuthorizationResponseJwt: jarm.responseJwt,
|
|
1432
1400
|
callbacks
|
|
1433
1401
|
});
|
|
1434
1402
|
}
|
|
@@ -1437,13 +1405,13 @@ async function submitOpenid4vpAuthorizationResponse(options) {
|
|
|
1437
1405
|
"Failed to submit OpenId4Vp Authorization Response. No redirect_uri or response_uri provided."
|
|
1438
1406
|
);
|
|
1439
1407
|
}
|
|
1440
|
-
const fetch = callbacks.fetch ??
|
|
1441
|
-
const encodedResponse = (0,
|
|
1408
|
+
const fetch = callbacks.fetch ?? import_utils17.defaultFetcher;
|
|
1409
|
+
const encodedResponse = (0, import_utils18.objectToQueryParams)(authorizationResponsePayload);
|
|
1442
1410
|
const submissionResponse = await fetch(url, {
|
|
1443
1411
|
method: "POST",
|
|
1444
1412
|
body: encodedResponse,
|
|
1445
1413
|
headers: {
|
|
1446
|
-
"Content-Type":
|
|
1414
|
+
"Content-Type": import_utils17.ContentType.XWwwFormUrlencoded
|
|
1447
1415
|
}
|
|
1448
1416
|
});
|
|
1449
1417
|
return {
|
|
@@ -1456,76 +1424,76 @@ async function submitOpenid4vpAuthorizationResponse(options) {
|
|
|
1456
1424
|
var import_oauth225 = require("@openid4vc/oauth2");
|
|
1457
1425
|
|
|
1458
1426
|
// src/vp-token/parse-vp-token.ts
|
|
1459
|
-
var
|
|
1427
|
+
var import_utils19 = require("@openid4vc/utils");
|
|
1460
1428
|
|
|
1461
1429
|
// src/vp-token/z-vp-token.ts
|
|
1462
|
-
var
|
|
1463
|
-
var zVpTokenPexEntry =
|
|
1430
|
+
var import_zod16 = require("zod");
|
|
1431
|
+
var zVpTokenPexEntry = import_zod16.z.union([import_zod16.z.string(), import_zod16.z.record(import_zod16.z.any())], {
|
|
1464
1432
|
message: "pex vp_token entry must be a string or object"
|
|
1465
1433
|
});
|
|
1466
|
-
var zVpTokenPex =
|
|
1467
|
-
[zVpTokenPexEntry,
|
|
1434
|
+
var zVpTokenPex = import_zod16.z.union(
|
|
1435
|
+
[zVpTokenPexEntry, import_zod16.z.array(zVpTokenPexEntry).nonempty("Must have at least entry in vp_token array")],
|
|
1468
1436
|
{
|
|
1469
1437
|
message: "pex vp_token must be a string, object or array of strings and objects"
|
|
1470
1438
|
}
|
|
1471
1439
|
);
|
|
1472
|
-
var zVpTokenDcql =
|
|
1440
|
+
var zVpTokenDcql = import_zod16.z.record(import_zod16.z.union([import_zod16.z.string(), import_zod16.z.record(import_zod16.z.any())]), {
|
|
1473
1441
|
message: "dcql vp_token must be an object with keys referencing the dcql credential query id, and values the encoded (string or object) presentation"
|
|
1474
1442
|
});
|
|
1475
1443
|
var zVpToken = zVpTokenDcql.or(zVpTokenPex);
|
|
1476
1444
|
|
|
1477
1445
|
// src/vp-token/parse-vp-token.ts
|
|
1478
1446
|
function parsePexVpToken(vpToken) {
|
|
1479
|
-
const parsedVpToken = (0,
|
|
1447
|
+
const parsedVpToken = (0, import_utils19.parseWithErrorHandling)(
|
|
1480
1448
|
zVpTokenPex,
|
|
1481
|
-
(0,
|
|
1449
|
+
(0, import_utils19.parseIfJson)(vpToken),
|
|
1482
1450
|
"Could not parse presentation exchange vp_token. Expected a string or an array of strings"
|
|
1483
1451
|
);
|
|
1484
1452
|
return Array.isArray(parsedVpToken) ? parsedVpToken : [parsedVpToken];
|
|
1485
1453
|
}
|
|
1486
1454
|
function parseDcqlVpToken(vpToken) {
|
|
1487
|
-
return (0,
|
|
1455
|
+
return (0, import_utils19.parseWithErrorHandling)(
|
|
1488
1456
|
zVpTokenDcql,
|
|
1489
|
-
(0,
|
|
1457
|
+
(0, import_utils19.parseIfJson)(vpToken),
|
|
1490
1458
|
"Could not parse dcql vp_token. Expected an object where the values are encoded presentations"
|
|
1491
1459
|
);
|
|
1492
1460
|
}
|
|
1493
1461
|
|
|
1494
1462
|
// src/authorization-response/validate-authorization-response.ts
|
|
1495
1463
|
function validateOpenid4vpAuthorizationResponsePayload(options) {
|
|
1496
|
-
const {
|
|
1497
|
-
if ("state" in
|
|
1464
|
+
const { authorizationRequestPayload, authorizationResponsePayload } = options;
|
|
1465
|
+
if ("state" in authorizationRequestPayload && authorizationRequestPayload.state !== authorizationResponsePayload.state) {
|
|
1498
1466
|
throw new import_oauth225.Oauth2Error("OpenId4Vp Authorization Response state mismatch.");
|
|
1499
1467
|
}
|
|
1500
|
-
if (
|
|
1468
|
+
if (authorizationResponsePayload.id_token) {
|
|
1501
1469
|
throw new import_oauth225.Oauth2Error("OpenId4Vp Authorization Response id_token is not supported.");
|
|
1502
1470
|
}
|
|
1503
|
-
if (
|
|
1504
|
-
if (!
|
|
1471
|
+
if (authorizationResponsePayload.presentation_submission) {
|
|
1472
|
+
if (!authorizationRequestPayload.presentation_definition) {
|
|
1505
1473
|
throw new import_oauth225.Oauth2Error("OpenId4Vp Authorization Request is missing the required presentation_definition.");
|
|
1506
1474
|
}
|
|
1507
1475
|
return {
|
|
1508
1476
|
type: "pex",
|
|
1509
|
-
pex: "scope" in
|
|
1510
|
-
scope:
|
|
1511
|
-
presentationSubmission:
|
|
1512
|
-
presentations: parsePexVpToken(
|
|
1477
|
+
pex: "scope" in authorizationRequestPayload && authorizationRequestPayload.scope ? {
|
|
1478
|
+
scope: authorizationRequestPayload.scope,
|
|
1479
|
+
presentationSubmission: authorizationResponsePayload.presentation_submission,
|
|
1480
|
+
presentations: parsePexVpToken(authorizationResponsePayload.vp_token)
|
|
1513
1481
|
} : {
|
|
1514
|
-
presentationDefinition:
|
|
1515
|
-
presentationSubmission:
|
|
1516
|
-
presentations: parsePexVpToken(
|
|
1482
|
+
presentationDefinition: authorizationRequestPayload.presentation_definition,
|
|
1483
|
+
presentationSubmission: authorizationResponsePayload.presentation_submission,
|
|
1484
|
+
presentations: parsePexVpToken(authorizationResponsePayload.vp_token)
|
|
1517
1485
|
}
|
|
1518
1486
|
};
|
|
1519
1487
|
}
|
|
1520
|
-
if (
|
|
1521
|
-
const presentations = parseDcqlVpToken(
|
|
1488
|
+
if (authorizationRequestPayload.dcql_query) {
|
|
1489
|
+
const presentations = parseDcqlVpToken(authorizationResponsePayload.vp_token);
|
|
1522
1490
|
return {
|
|
1523
1491
|
type: "dcql",
|
|
1524
|
-
dcql: "scope" in
|
|
1525
|
-
scope:
|
|
1492
|
+
dcql: "scope" in authorizationRequestPayload && authorizationRequestPayload.scope ? {
|
|
1493
|
+
scope: authorizationRequestPayload.scope,
|
|
1526
1494
|
presentations
|
|
1527
1495
|
} : {
|
|
1528
|
-
query:
|
|
1496
|
+
query: authorizationRequestPayload.dcql_query,
|
|
1529
1497
|
presentations
|
|
1530
1498
|
}
|
|
1531
1499
|
};
|
|
@@ -1539,31 +1507,31 @@ function validateOpenid4vpAuthorizationResponsePayload(options) {
|
|
|
1539
1507
|
var import_oauth227 = require("@openid4vc/oauth2");
|
|
1540
1508
|
|
|
1541
1509
|
// src/authorization-response/parse-authorization-response-payload.ts
|
|
1542
|
-
var
|
|
1510
|
+
var import_utils20 = require("@openid4vc/utils");
|
|
1543
1511
|
|
|
1544
1512
|
// src/authorization-response/z-authorization-response.ts
|
|
1545
|
-
var
|
|
1513
|
+
var import_zod18 = require("zod");
|
|
1546
1514
|
|
|
1547
1515
|
// src/models/z-pex.ts
|
|
1548
|
-
var
|
|
1549
|
-
var zPexPresentationDefinition =
|
|
1550
|
-
var zPexPresentationSubmission =
|
|
1516
|
+
var import_zod17 = require("zod");
|
|
1517
|
+
var zPexPresentationDefinition = import_zod17.z.record(import_zod17.z.any());
|
|
1518
|
+
var zPexPresentationSubmission = import_zod17.z.record(import_zod17.z.any());
|
|
1551
1519
|
|
|
1552
1520
|
// src/authorization-response/z-authorization-response.ts
|
|
1553
|
-
var zOpenid4vpAuthorizationResponse =
|
|
1554
|
-
state:
|
|
1555
|
-
id_token:
|
|
1521
|
+
var zOpenid4vpAuthorizationResponse = import_zod18.z.object({
|
|
1522
|
+
state: import_zod18.z.string().optional(),
|
|
1523
|
+
id_token: import_zod18.z.string().optional(),
|
|
1556
1524
|
vp_token: zVpToken,
|
|
1557
1525
|
presentation_submission: zPexPresentationSubmission.optional(),
|
|
1558
|
-
refresh_token:
|
|
1559
|
-
token_type:
|
|
1560
|
-
access_token:
|
|
1561
|
-
expires_in:
|
|
1526
|
+
refresh_token: import_zod18.z.string().optional(),
|
|
1527
|
+
token_type: import_zod18.z.string().optional(),
|
|
1528
|
+
access_token: import_zod18.z.string().optional(),
|
|
1529
|
+
expires_in: import_zod18.z.number().optional()
|
|
1562
1530
|
}).passthrough();
|
|
1563
1531
|
|
|
1564
1532
|
// src/authorization-response/parse-authorization-response-payload.ts
|
|
1565
1533
|
function parseOpenid4VpAuthorizationResponsePayload(payload) {
|
|
1566
|
-
return (0,
|
|
1534
|
+
return (0, import_utils20.parseWithErrorHandling)(
|
|
1567
1535
|
zOpenid4vpAuthorizationResponse,
|
|
1568
1536
|
payload,
|
|
1569
1537
|
"Failed to parse openid4vp authorization response."
|
|
@@ -1572,72 +1540,61 @@ function parseOpenid4VpAuthorizationResponsePayload(payload) {
|
|
|
1572
1540
|
|
|
1573
1541
|
// src/authorization-response/parse-jarm-authorization-response.ts
|
|
1574
1542
|
var import_oauth226 = require("@openid4vc/oauth2");
|
|
1575
|
-
var
|
|
1576
|
-
var
|
|
1543
|
+
var import_utils21 = require("@openid4vc/utils");
|
|
1544
|
+
var import_zod19 = __toESM(require("zod"));
|
|
1577
1545
|
async function parseJarmAuthorizationResponse(options) {
|
|
1578
|
-
const { jarmResponseJwt, callbacks } = options;
|
|
1579
|
-
const jarmAuthorizationResponseJwt = (0,
|
|
1580
|
-
|
|
1546
|
+
const { jarmResponseJwt, callbacks, authorizationRequestPayload, expectedClientId } = options;
|
|
1547
|
+
const jarmAuthorizationResponseJwt = (0, import_utils21.parseWithErrorHandling)(
|
|
1548
|
+
import_zod19.default.union([import_oauth226.zCompactJwt, import_oauth226.zCompactJwe]),
|
|
1581
1549
|
jarmResponseJwt,
|
|
1582
1550
|
"Invalid jarm authorization response jwt."
|
|
1583
1551
|
);
|
|
1584
|
-
const verifiedJarmResponse = await verifyJarmAuthorizationResponse({
|
|
1552
|
+
const verifiedJarmResponse = await verifyJarmAuthorizationResponse({
|
|
1553
|
+
jarmAuthorizationResponseJwt,
|
|
1554
|
+
callbacks,
|
|
1555
|
+
expectedClientId,
|
|
1556
|
+
authorizationRequestPayload
|
|
1557
|
+
});
|
|
1585
1558
|
const { header: jarmHeader } = (0, import_oauth226.decodeJwtHeader)({
|
|
1586
1559
|
jwt: jarmAuthorizationResponseJwt,
|
|
1587
1560
|
headerSchema: zJarmHeader
|
|
1588
1561
|
});
|
|
1589
|
-
const
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
if (parsedAuthorizationRequest.type !== "openid4vp" && parsedAuthorizationRequest.type !== "openid4vp_dc_api") {
|
|
1593
|
-
throw new import_oauth226.Oauth2Error("Invalid authorization request. Could not parse openid4vp authorization request.");
|
|
1594
|
-
}
|
|
1595
|
-
const authorizationResponsePayload = parseOpenid4VpAuthorizationResponsePayload(verifiedJarmResponse.jarmAuthResponse);
|
|
1562
|
+
const authorizationResponsePayload = parseOpenid4VpAuthorizationResponsePayload(
|
|
1563
|
+
verifiedJarmResponse.jarmAuthorizationResponse
|
|
1564
|
+
);
|
|
1596
1565
|
const validateOpenId4vpResponse = validateOpenid4vpAuthorizationResponsePayload({
|
|
1597
|
-
|
|
1598
|
-
|
|
1566
|
+
authorizationRequestPayload,
|
|
1567
|
+
authorizationResponsePayload
|
|
1599
1568
|
});
|
|
1600
|
-
const authorizationRequestPayload = parsedAuthorizationRequest.params;
|
|
1601
1569
|
if (!authorizationRequestPayload.response_mode || !isJarmResponseMode(authorizationRequestPayload.response_mode)) {
|
|
1602
1570
|
throw new import_oauth226.Oauth2Error(
|
|
1603
1571
|
`Invalid response mode for jarm response. Response mode: '${authorizationRequestPayload.response_mode ?? "fragment"}'`
|
|
1604
1572
|
);
|
|
1605
1573
|
}
|
|
1606
|
-
let mdocGeneratedNonce = void 0;
|
|
1607
|
-
if (jarmHeader?.apu) {
|
|
1608
|
-
mdocGeneratedNonce = (0, import_utils20.encodeToUtf8String)((0, import_utils20.decodeBase64)(jarmHeader.apu));
|
|
1609
|
-
}
|
|
1610
|
-
if (jarmHeader?.apv) {
|
|
1611
|
-
const jarmRequestNonce = (0, import_utils20.encodeToUtf8String)((0, import_utils20.decodeBase64)(jarmHeader.apv));
|
|
1612
|
-
if (jarmRequestNonce !== authorizationRequestPayload.nonce) {
|
|
1613
|
-
throw new import_oauth226.Oauth2Error("The nonce in the jarm header does not match the nonce in the request.");
|
|
1614
|
-
}
|
|
1615
|
-
}
|
|
1616
1574
|
return {
|
|
1617
1575
|
...validateOpenId4vpResponse,
|
|
1618
|
-
jarm: { ...verifiedJarmResponse, jarmHeader
|
|
1576
|
+
jarm: { ...verifiedJarmResponse, jarmHeader },
|
|
1619
1577
|
expectedNonce: authorizationRequestPayload.nonce,
|
|
1620
|
-
authorizationResponsePayload
|
|
1621
|
-
authorizationRequestPayload
|
|
1578
|
+
authorizationResponsePayload
|
|
1622
1579
|
};
|
|
1623
1580
|
}
|
|
1624
1581
|
|
|
1625
1582
|
// src/authorization-response/parse-authorization-response.ts
|
|
1626
1583
|
async function parseOpenid4vpAuthorizationResponse(options) {
|
|
1627
|
-
const {
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1584
|
+
const { authorizationResponse, callbacks, authorizationRequestPayload, origin } = options;
|
|
1585
|
+
const expectedClientId = getClientId({ authorizationRequestPayload, origin });
|
|
1586
|
+
if (authorizationResponse.response) {
|
|
1587
|
+
return parseJarmAuthorizationResponse({
|
|
1588
|
+
jarmResponseJwt: authorizationResponse.response,
|
|
1589
|
+
callbacks,
|
|
1590
|
+
authorizationRequestPayload,
|
|
1591
|
+
expectedClientId
|
|
1592
|
+
});
|
|
1636
1593
|
}
|
|
1637
|
-
const
|
|
1638
|
-
const
|
|
1639
|
-
|
|
1640
|
-
|
|
1594
|
+
const authorizationResponsePayload = parseOpenid4VpAuthorizationResponsePayload(authorizationResponse);
|
|
1595
|
+
const validatedOpenId4vpResponse = validateOpenid4vpAuthorizationResponsePayload({
|
|
1596
|
+
authorizationRequestPayload,
|
|
1597
|
+
authorizationResponsePayload
|
|
1641
1598
|
});
|
|
1642
1599
|
if (authorizationRequestPayload.response_mode && isJarmResponseMode(authorizationRequestPayload.response_mode)) {
|
|
1643
1600
|
throw new import_oauth227.Oauth2ServerErrorResponseError(
|
|
@@ -1651,10 +1608,9 @@ async function parseOpenid4vpAuthorizationResponse(options) {
|
|
|
1651
1608
|
);
|
|
1652
1609
|
}
|
|
1653
1610
|
return {
|
|
1654
|
-
...
|
|
1611
|
+
...validatedOpenId4vpResponse,
|
|
1655
1612
|
expectedNonce: authorizationRequestPayload.nonce,
|
|
1656
1613
|
authorizationResponsePayload,
|
|
1657
|
-
authorizationRequestPayload,
|
|
1658
1614
|
jarm: void 0
|
|
1659
1615
|
};
|
|
1660
1616
|
}
|
|
@@ -1680,7 +1636,7 @@ var Openid4vpClient = class {
|
|
|
1680
1636
|
|
|
1681
1637
|
// src/transaction-data/verify-transaction-data.ts
|
|
1682
1638
|
var import_oauth228 = require("@openid4vc/oauth2");
|
|
1683
|
-
var
|
|
1639
|
+
var import_utils22 = require("@openid4vc/utils");
|
|
1684
1640
|
async function verifyTransactionData(options) {
|
|
1685
1641
|
const parsedTransactionData = parseTransactionData({
|
|
1686
1642
|
transactionData: options.transactionData
|
|
@@ -1707,7 +1663,7 @@ async function verifyTransactionDataEntry({
|
|
|
1707
1663
|
);
|
|
1708
1664
|
const hashes = {};
|
|
1709
1665
|
for (const alg of supportedAlgs) {
|
|
1710
|
-
hashes[alg] = (0,
|
|
1666
|
+
hashes[alg] = (0, import_utils22.encodeToBase64Url)(await callbacks.hash((0, import_utils22.decodeUtf8String)(entry.encoded), alg));
|
|
1711
1667
|
}
|
|
1712
1668
|
for (const credentialId of entry.transactionData.credential_ids) {
|
|
1713
1669
|
const transactionDataHashesCredential = credentials[credentialId];
|
|
@@ -1775,12 +1731,23 @@ var Openid4vpVerifier = class {
|
|
|
1775
1731
|
};
|
|
1776
1732
|
|
|
1777
1733
|
// src/models/z-credential-formats.ts
|
|
1778
|
-
var
|
|
1779
|
-
var zCredentialFormat =
|
|
1734
|
+
var import_zod20 = require("zod");
|
|
1735
|
+
var zCredentialFormat = import_zod20.z.enum(["jwt_vc_json", "ldp_vc", "ac_vc", "mso_mdoc", "dc+sd-jwt", "vc+sd-jwt"]);
|
|
1780
1736
|
|
|
1781
1737
|
// src/models/z-proof-formats.ts
|
|
1738
|
+
var import_zod21 = require("zod");
|
|
1739
|
+
var zProofFormat = import_zod21.z.enum(["jwt_vp_json", "ldc_vp", "ac_vp", "dc+sd-jwt", "vc+sd-jwt", "mso_mdoc"]);
|
|
1740
|
+
|
|
1741
|
+
// src/models/z-wallet-metadata.ts
|
|
1782
1742
|
var import_zod22 = require("zod");
|
|
1783
|
-
var
|
|
1743
|
+
var zWalletMetadata = import_zod22.z.object({
|
|
1744
|
+
presentation_definition_uri_supported: import_zod22.z.optional(import_zod22.z.boolean()),
|
|
1745
|
+
vp_formats_supported: zVpFormatsSupported,
|
|
1746
|
+
client_id_schemes_supported: import_zod22.z.optional(import_zod22.z.array(zClientIdScheme)),
|
|
1747
|
+
request_object_signing_alg_values_supported: import_zod22.z.optional(import_zod22.z.array(import_zod22.z.string())),
|
|
1748
|
+
authorization_encryption_alg_values_supported: import_zod22.z.optional(import_zod22.z.array(import_zod22.z.string())),
|
|
1749
|
+
authorization_encryption_enc_values_supported: import_zod22.z.optional(import_zod22.z.array(import_zod22.z.string()))
|
|
1750
|
+
});
|
|
1784
1751
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1785
1752
|
0 && (module.exports = {
|
|
1786
1753
|
Openid4vpClient,
|