@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.mjs
CHANGED
|
@@ -158,11 +158,10 @@ var zOpenid4vpAuthorizationRequestDcApi = zOpenid4vpAuthorizationRequest.pick({
|
|
|
158
158
|
scope: z5.never().optional()
|
|
159
159
|
// TODO: should we disallow any properties specifically, such as redirect_uri and response_uri?
|
|
160
160
|
});
|
|
161
|
-
function isOpenid4vpResponseModeDcApi(responseMode) {
|
|
162
|
-
return responseMode !== void 0 && zOpenid4vpResponseModeDcApi.options.includes(responseMode);
|
|
163
|
-
}
|
|
164
161
|
function isOpenid4vpAuthorizationRequestDcApi(request) {
|
|
165
|
-
return
|
|
162
|
+
return request.response_mode !== void 0 && zOpenid4vpResponseModeDcApi.options.includes(
|
|
163
|
+
request.response_mode
|
|
164
|
+
);
|
|
166
165
|
}
|
|
167
166
|
|
|
168
167
|
// src/client-identifier-scheme/z-client-id-scheme.ts
|
|
@@ -189,13 +188,7 @@ var zLegacyClientIdScheme = z6.enum([
|
|
|
189
188
|
|
|
190
189
|
// src/client-identifier-scheme/parse-client-identifier-scheme.ts
|
|
191
190
|
function getOpenid4vpClientId(options) {
|
|
192
|
-
if (
|
|
193
|
-
if (options.legacyClientIdScheme) {
|
|
194
|
-
throw new Oauth2ServerErrorResponseError({
|
|
195
|
-
error: Oauth2ErrorCodes.InvalidRequest,
|
|
196
|
-
error_description: `Failed to parse client identifier. response_mode '${options.responseMode}' is not supported in combination with 'client_id_scheme'`
|
|
197
|
-
});
|
|
198
|
-
}
|
|
191
|
+
if (isOpenid4vpAuthorizationRequestDcApi(options.authorizationRequestPayload)) {
|
|
199
192
|
if (!options.origin) {
|
|
200
193
|
throw new Oauth2ServerErrorResponseError({
|
|
201
194
|
error: Oauth2ErrorCodes.InvalidRequest,
|
|
@@ -203,45 +196,44 @@ function getOpenid4vpClientId(options) {
|
|
|
203
196
|
});
|
|
204
197
|
}
|
|
205
198
|
return {
|
|
206
|
-
clientId: options.
|
|
199
|
+
clientId: options.authorizationRequestPayload.client_id ?? `web-origin:${options.origin}`
|
|
207
200
|
};
|
|
208
201
|
}
|
|
209
|
-
if (!options.
|
|
202
|
+
if (!options.authorizationRequestPayload.client_id) {
|
|
210
203
|
throw new Oauth2ServerErrorResponseError({
|
|
211
204
|
error: Oauth2ErrorCodes.InvalidRequest,
|
|
212
|
-
error_description: `Failed to parse client identifier. Missing required client_id parameter for response_mode '${options.
|
|
205
|
+
error_description: `Failed to parse client identifier. Missing required client_id parameter for response_mode '${options.authorizationRequestPayload.response_mode}'.`
|
|
213
206
|
});
|
|
214
207
|
}
|
|
215
|
-
if (options.
|
|
216
|
-
const parsedClientIdScheme = zLegacyClientIdScheme.safeParse(options.
|
|
208
|
+
if (options.authorizationRequestPayload.client_id_scheme) {
|
|
209
|
+
const parsedClientIdScheme = zLegacyClientIdScheme.safeParse(options.authorizationRequestPayload.client_id_scheme);
|
|
217
210
|
if (!parsedClientIdScheme.success) {
|
|
218
211
|
throw new Oauth2ServerErrorResponseError({
|
|
219
212
|
error: Oauth2ErrorCodes.InvalidRequest,
|
|
220
|
-
error_description: `Failed to parse client identifier. Unsupported client_id_scheme value '${options.
|
|
213
|
+
error_description: `Failed to parse client identifier. Unsupported client_id_scheme value '${options.authorizationRequestPayload.client_id_scheme}'.`
|
|
221
214
|
});
|
|
222
215
|
}
|
|
223
216
|
const clientIdScheme = parsedClientIdScheme.data === "entity_id" ? "https" : parsedClientIdScheme.data;
|
|
224
217
|
if (clientIdScheme === "https" || clientIdScheme === "did" || clientIdScheme === "pre-registered") {
|
|
225
|
-
return { clientId: options.
|
|
218
|
+
return { clientId: options.authorizationRequestPayload.client_id };
|
|
226
219
|
}
|
|
227
220
|
return {
|
|
228
|
-
clientId: `${clientIdScheme}:${options.
|
|
229
|
-
legacyClientId: options.
|
|
221
|
+
clientId: `${clientIdScheme}:${options.authorizationRequestPayload.client_id}`,
|
|
222
|
+
legacyClientId: options.authorizationRequestPayload.client_id
|
|
230
223
|
};
|
|
231
224
|
}
|
|
232
225
|
return {
|
|
233
|
-
clientId: options.
|
|
226
|
+
clientId: options.authorizationRequestPayload.client_id
|
|
234
227
|
};
|
|
235
228
|
}
|
|
236
229
|
function parseClientIdentifier(options, parserConfig) {
|
|
237
|
-
const { authorizationRequestPayload, jar } = options;
|
|
230
|
+
const { authorizationRequestPayload, jar, origin } = options;
|
|
238
231
|
const parserConfigWithDefaults = {
|
|
239
232
|
supportedSchemes: parserConfig?.supportedSchemes || Object.values(zClientIdScheme.options)
|
|
240
233
|
};
|
|
241
234
|
const { clientId, legacyClientId } = getOpenid4vpClientId({
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
legacyClientIdScheme: authorizationRequestPayload.client_id_scheme
|
|
235
|
+
authorizationRequestPayload,
|
|
236
|
+
origin
|
|
245
237
|
});
|
|
246
238
|
const colonIndex = clientId.indexOf(":");
|
|
247
239
|
if (colonIndex === -1) {
|
|
@@ -1598,9 +1590,7 @@ async function parseOpenid4vpAuthorizationResponse(options) {
|
|
|
1598
1590
|
const { authorizationResponse, callbacks, authorizationRequestPayload, origin } = options;
|
|
1599
1591
|
const expectedClientId = getOpenid4vpClientId({
|
|
1600
1592
|
origin,
|
|
1601
|
-
|
|
1602
|
-
clientId: authorizationRequestPayload.client_id,
|
|
1603
|
-
legacyClientIdScheme: authorizationRequestPayload.client_id_scheme
|
|
1593
|
+
authorizationRequestPayload
|
|
1604
1594
|
});
|
|
1605
1595
|
if (authorizationResponse.response) {
|
|
1606
1596
|
return parseJarmAuthorizationResponse({
|