@openid4vc/oauth2 0.4.2-alpha-20251205122424 → 0.4.2-alpha-20251209051701
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.mjs +17 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContentType, Headers, InvalidFetchResponseError, InvalidFetchResponseError as InvalidFetchResponseError$1, URL, ValidationError, addSecondsToDate, createFetcher, createZodFetcher, dateToSeconds, decodeBase64, decodeUtf8String, encodeToBase64Url, encodeToUtf8String, encodeWwwAuthenticateHeader, formatZodError, getGlobalConfig, joinUriParts, objectToQueryParams, parseWithErrorHandling, parseWwwAuthenticateHeader, setGlobalConfig, stringToJsonWithErrorHandling, zHttpMethod, zHttpsUrl, zInteger } from "@openid4vc/utils";
|
|
1
|
+
import { ContentType, Headers, InvalidFetchResponseError, InvalidFetchResponseError as InvalidFetchResponseError$1, OpenId4VcBaseError, URL, ValidationError, addSecondsToDate, createFetcher, createZodFetcher, dateToSeconds, decodeBase64, decodeUtf8String, encodeToBase64Url, encodeToUtf8String, encodeWwwAuthenticateHeader, formatZodError, getGlobalConfig, joinUriParts, objectToQueryParams, parseWithErrorHandling, parseWwwAuthenticateHeader, setGlobalConfig, stringToJsonWithErrorHandling, zHttpMethod, zHttpsUrl, zInteger } from "@openid4vc/utils";
|
|
2
2
|
import z$1, { z } from "zod";
|
|
3
3
|
|
|
4
4
|
//#region src/callbacks.ts
|
|
@@ -347,9 +347,13 @@ async function verifyJwt(options) {
|
|
|
347
347
|
} };
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
+
//#endregion
|
|
351
|
+
//#region ../utils/src/error/OpenId4VcBaseError.ts
|
|
352
|
+
var OpenId4VcBaseError$1 = class extends Error {};
|
|
353
|
+
|
|
350
354
|
//#endregion
|
|
351
355
|
//#region ../utils/src/error/ValidationError.ts
|
|
352
|
-
var ValidationError$1 = class extends
|
|
356
|
+
var ValidationError$1 = class extends OpenId4VcBaseError$1 {
|
|
353
357
|
constructor(message, zodError) {
|
|
354
358
|
super(message);
|
|
355
359
|
this.message = `${message}\n${zodError ? z$1.prettifyError(zodError) : ""}`;
|
|
@@ -1606,9 +1610,17 @@ async function fetchAuthorizationServerMetadata(issuer, fetch) {
|
|
|
1606
1610
|
const openIdConfigurationWellKnownMetadataUrl = joinUriParts(issuer, [wellKnownOpenIdConfigurationServerSuffix]);
|
|
1607
1611
|
const authorizationServerWellKnownMetadataUrl = joinUriParts(parsedIssuerUrl.origin, [wellKnownAuthorizationServerSuffix, parsedIssuerUrl.pathname]);
|
|
1608
1612
|
const nonCompliantAuthorizationServerWellKnownMetadataUrl = joinUriParts(issuer, [wellKnownAuthorizationServerSuffix]);
|
|
1609
|
-
let
|
|
1610
|
-
|
|
1611
|
-
|
|
1613
|
+
let firstError = null;
|
|
1614
|
+
let authorizationServerResult = await fetchWellKnownMetadata(authorizationServerWellKnownMetadataUrl, zAuthorizationServerMetadata, { fetch }).catch((error) => {
|
|
1615
|
+
if (error instanceof OpenId4VcBaseError) throw error;
|
|
1616
|
+
firstError = error;
|
|
1617
|
+
});
|
|
1618
|
+
if (!authorizationServerResult && nonCompliantAuthorizationServerWellKnownMetadataUrl !== authorizationServerWellKnownMetadataUrl) authorizationServerResult = await fetchWellKnownMetadata(nonCompliantAuthorizationServerWellKnownMetadataUrl, zAuthorizationServerMetadata, { fetch }).catch((error) => {
|
|
1619
|
+
if (error instanceof OpenId4VcBaseError) throw error;
|
|
1620
|
+
});
|
|
1621
|
+
if (!authorizationServerResult) authorizationServerResult = await fetchWellKnownMetadata(openIdConfigurationWellKnownMetadataUrl, zAuthorizationServerMetadata, { fetch }).catch((error) => {
|
|
1622
|
+
throw firstError ?? error;
|
|
1623
|
+
});
|
|
1612
1624
|
if (authorizationServerResult && authorizationServerResult.issuer !== issuer) throw new Oauth2Error(`The 'issuer' parameter '${authorizationServerResult.issuer}' in the well known authorization server metadata at '${authorizationServerWellKnownMetadataUrl}' does not match the provided issuer '${issuer}'.`);
|
|
1613
1625
|
return authorizationServerResult;
|
|
1614
1626
|
}
|