@openid4vc/openid4vp 0.3.0-alpha-20250321115806 → 0.3.0-alpha-20250321121138
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 +1 -3
- package/dist/index.d.ts +1 -3
- package/dist/index.js +18 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -8512,9 +8512,7 @@ type ParsedClientIdentifier = ({
|
|
|
8512
8512
|
legacyClientId?: string;
|
|
8513
8513
|
};
|
|
8514
8514
|
interface GetOpenid4vpClientIdOptions {
|
|
8515
|
-
|
|
8516
|
-
clientId?: string;
|
|
8517
|
-
legacyClientIdScheme?: string;
|
|
8515
|
+
authorizationRequestPayload: Openid4vpAuthorizationRequest | Openid4vpAuthorizationRequestDcApi;
|
|
8518
8516
|
origin?: string;
|
|
8519
8517
|
}
|
|
8520
8518
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -8512,9 +8512,7 @@ type ParsedClientIdentifier = ({
|
|
|
8512
8512
|
legacyClientId?: string;
|
|
8513
8513
|
};
|
|
8514
8514
|
interface GetOpenid4vpClientIdOptions {
|
|
8515
|
-
|
|
8516
|
-
clientId?: string;
|
|
8517
|
-
legacyClientIdScheme?: string;
|
|
8515
|
+
authorizationRequestPayload: Openid4vpAuthorizationRequest | Openid4vpAuthorizationRequestDcApi;
|
|
8518
8516
|
origin?: string;
|
|
8519
8517
|
}
|
|
8520
8518
|
/**
|
package/dist/index.js
CHANGED
|
@@ -219,11 +219,10 @@ var zOpenid4vpAuthorizationRequestDcApi = zOpenid4vpAuthorizationRequest.pick({
|
|
|
219
219
|
scope: import_zod5.z.never().optional()
|
|
220
220
|
// TODO: should we disallow any properties specifically, such as redirect_uri and response_uri?
|
|
221
221
|
});
|
|
222
|
-
function isOpenid4vpResponseModeDcApi(responseMode) {
|
|
223
|
-
return responseMode !== void 0 && zOpenid4vpResponseModeDcApi.options.includes(responseMode);
|
|
224
|
-
}
|
|
225
222
|
function isOpenid4vpAuthorizationRequestDcApi(request) {
|
|
226
|
-
return
|
|
223
|
+
return request.response_mode !== void 0 && zOpenid4vpResponseModeDcApi.options.includes(
|
|
224
|
+
request.response_mode
|
|
225
|
+
);
|
|
227
226
|
}
|
|
228
227
|
|
|
229
228
|
// src/client-identifier-scheme/z-client-id-scheme.ts
|
|
@@ -250,13 +249,7 @@ var zLegacyClientIdScheme = import_zod6.z.enum([
|
|
|
250
249
|
|
|
251
250
|
// src/client-identifier-scheme/parse-client-identifier-scheme.ts
|
|
252
251
|
function getOpenid4vpClientId(options) {
|
|
253
|
-
if (
|
|
254
|
-
if (options.legacyClientIdScheme) {
|
|
255
|
-
throw new import_oauth23.Oauth2ServerErrorResponseError({
|
|
256
|
-
error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
|
|
257
|
-
error_description: `Failed to parse client identifier. response_mode '${options.responseMode}' is not supported in combination with 'client_id_scheme'`
|
|
258
|
-
});
|
|
259
|
-
}
|
|
252
|
+
if (isOpenid4vpAuthorizationRequestDcApi(options.authorizationRequestPayload)) {
|
|
260
253
|
if (!options.origin) {
|
|
261
254
|
throw new import_oauth23.Oauth2ServerErrorResponseError({
|
|
262
255
|
error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
|
|
@@ -264,45 +257,44 @@ function getOpenid4vpClientId(options) {
|
|
|
264
257
|
});
|
|
265
258
|
}
|
|
266
259
|
return {
|
|
267
|
-
clientId: options.
|
|
260
|
+
clientId: options.authorizationRequestPayload.client_id ?? `web-origin:${options.origin}`
|
|
268
261
|
};
|
|
269
262
|
}
|
|
270
|
-
if (!options.
|
|
263
|
+
if (!options.authorizationRequestPayload.client_id) {
|
|
271
264
|
throw new import_oauth23.Oauth2ServerErrorResponseError({
|
|
272
265
|
error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
|
|
273
|
-
error_description: `Failed to parse client identifier. Missing required client_id parameter for response_mode '${options.
|
|
266
|
+
error_description: `Failed to parse client identifier. Missing required client_id parameter for response_mode '${options.authorizationRequestPayload.response_mode}'.`
|
|
274
267
|
});
|
|
275
268
|
}
|
|
276
|
-
if (options.
|
|
277
|
-
const parsedClientIdScheme = zLegacyClientIdScheme.safeParse(options.
|
|
269
|
+
if (options.authorizationRequestPayload.client_id_scheme) {
|
|
270
|
+
const parsedClientIdScheme = zLegacyClientIdScheme.safeParse(options.authorizationRequestPayload.client_id_scheme);
|
|
278
271
|
if (!parsedClientIdScheme.success) {
|
|
279
272
|
throw new import_oauth23.Oauth2ServerErrorResponseError({
|
|
280
273
|
error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
|
|
281
|
-
error_description: `Failed to parse client identifier. Unsupported client_id_scheme value '${options.
|
|
274
|
+
error_description: `Failed to parse client identifier. Unsupported client_id_scheme value '${options.authorizationRequestPayload.client_id_scheme}'.`
|
|
282
275
|
});
|
|
283
276
|
}
|
|
284
277
|
const clientIdScheme = parsedClientIdScheme.data === "entity_id" ? "https" : parsedClientIdScheme.data;
|
|
285
278
|
if (clientIdScheme === "https" || clientIdScheme === "did" || clientIdScheme === "pre-registered") {
|
|
286
|
-
return { clientId: options.
|
|
279
|
+
return { clientId: options.authorizationRequestPayload.client_id };
|
|
287
280
|
}
|
|
288
281
|
return {
|
|
289
|
-
clientId: `${clientIdScheme}:${options.
|
|
290
|
-
legacyClientId: options.
|
|
282
|
+
clientId: `${clientIdScheme}:${options.authorizationRequestPayload.client_id}`,
|
|
283
|
+
legacyClientId: options.authorizationRequestPayload.client_id
|
|
291
284
|
};
|
|
292
285
|
}
|
|
293
286
|
return {
|
|
294
|
-
clientId: options.
|
|
287
|
+
clientId: options.authorizationRequestPayload.client_id
|
|
295
288
|
};
|
|
296
289
|
}
|
|
297
290
|
function parseClientIdentifier(options, parserConfig) {
|
|
298
|
-
const { authorizationRequestPayload, jar } = options;
|
|
291
|
+
const { authorizationRequestPayload, jar, origin } = options;
|
|
299
292
|
const parserConfigWithDefaults = {
|
|
300
293
|
supportedSchemes: parserConfig?.supportedSchemes || Object.values(zClientIdScheme.options)
|
|
301
294
|
};
|
|
302
295
|
const { clientId, legacyClientId } = getOpenid4vpClientId({
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
legacyClientIdScheme: authorizationRequestPayload.client_id_scheme
|
|
296
|
+
authorizationRequestPayload,
|
|
297
|
+
origin
|
|
306
298
|
});
|
|
307
299
|
const colonIndex = clientId.indexOf(":");
|
|
308
300
|
if (colonIndex === -1) {
|
|
@@ -1635,9 +1627,7 @@ async function parseOpenid4vpAuthorizationResponse(options) {
|
|
|
1635
1627
|
const { authorizationResponse, callbacks, authorizationRequestPayload, origin } = options;
|
|
1636
1628
|
const expectedClientId = getOpenid4vpClientId({
|
|
1637
1629
|
origin,
|
|
1638
|
-
|
|
1639
|
-
clientId: authorizationRequestPayload.client_id,
|
|
1640
|
-
legacyClientIdScheme: authorizationRequestPayload.client_id_scheme
|
|
1630
|
+
authorizationRequestPayload
|
|
1641
1631
|
});
|
|
1642
1632
|
if (authorizationResponse.response) {
|
|
1643
1633
|
return parseJarmAuthorizationResponse({
|