@openid4vc/oauth2 0.3.0-alpha-20251017122507 → 0.3.0-alpha-20251021082313
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 +14 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -209,7 +209,8 @@ function decodeJwt(options) {
|
|
|
209
209
|
return {
|
|
210
210
|
header,
|
|
211
211
|
payload: parseWithErrorHandling(options.payloadSchema ?? zJwtPayload, payloadJson),
|
|
212
|
-
signature: jwtParts[2]
|
|
212
|
+
signature: jwtParts[2],
|
|
213
|
+
compact: options.jwt
|
|
213
214
|
};
|
|
214
215
|
}
|
|
215
216
|
function jwtHeaderFromJwtSigner(signer) {
|
|
@@ -855,8 +856,8 @@ var Oauth2ResourceUnauthorizedError = class Oauth2ResourceUnauthorizedError exte
|
|
|
855
856
|
* @throws {InvalidFetchResponseError} if no successful or 404 response
|
|
856
857
|
* @throws {Error} if parsing json from response fails
|
|
857
858
|
*/
|
|
858
|
-
async function fetchWellKnownMetadata(wellKnownMetadataUrl, schema,
|
|
859
|
-
const { result, response } = await createZodFetcher(fetch)(schema, ContentType.Json, wellKnownMetadataUrl);
|
|
859
|
+
async function fetchWellKnownMetadata(wellKnownMetadataUrl, schema, options) {
|
|
860
|
+
const { result, response } = await createZodFetcher(options?.fetch)(schema, options?.acceptedContentType ?? [ContentType.Json], wellKnownMetadataUrl);
|
|
860
861
|
if (response.status === 404) return null;
|
|
861
862
|
if (!response.ok) throw new InvalidFetchResponseError$1(`Fetching well known metadata from '${wellKnownMetadataUrl}' resulted in an unsuccessful response with status '${response.status}'.`, await response.clone().text(), response);
|
|
862
863
|
if (!result?.success) throw new ValidationError$1(`Validation of metadata from '${wellKnownMetadataUrl}' failed`, result?.error);
|
|
@@ -908,9 +909,9 @@ async function fetchAuthorizationServerMetadata(issuer, fetch) {
|
|
|
908
909
|
const openIdConfigurationWellKnownMetadataUrl = joinUriParts(issuer, [wellKnownOpenIdConfigurationServerSuffix]);
|
|
909
910
|
const authorizationServerWellKnownMetadataUrl = joinUriParts(parsedIssuerUrl.origin, [wellKnownAuthorizationServerSuffix, parsedIssuerUrl.pathname]);
|
|
910
911
|
const nonCompliantAuthorizationServerWellKnownMetadataUrl = joinUriParts(issuer, [wellKnownAuthorizationServerSuffix]);
|
|
911
|
-
let authorizationServerResult = await fetchWellKnownMetadata(authorizationServerWellKnownMetadataUrl, zAuthorizationServerMetadata, fetch);
|
|
912
|
-
if (!authorizationServerResult && nonCompliantAuthorizationServerWellKnownMetadataUrl !== authorizationServerWellKnownMetadataUrl) authorizationServerResult = await fetchWellKnownMetadata(nonCompliantAuthorizationServerWellKnownMetadataUrl, zAuthorizationServerMetadata, fetch);
|
|
913
|
-
if (!authorizationServerResult) authorizationServerResult = await fetchWellKnownMetadata(openIdConfigurationWellKnownMetadataUrl, zAuthorizationServerMetadata, fetch);
|
|
912
|
+
let authorizationServerResult = await fetchWellKnownMetadata(authorizationServerWellKnownMetadataUrl, zAuthorizationServerMetadata, { fetch });
|
|
913
|
+
if (!authorizationServerResult && nonCompliantAuthorizationServerWellKnownMetadataUrl !== authorizationServerWellKnownMetadataUrl) authorizationServerResult = await fetchWellKnownMetadata(nonCompliantAuthorizationServerWellKnownMetadataUrl, zAuthorizationServerMetadata, { fetch });
|
|
914
|
+
if (!authorizationServerResult) authorizationServerResult = await fetchWellKnownMetadata(openIdConfigurationWellKnownMetadataUrl, zAuthorizationServerMetadata, { fetch });
|
|
914
915
|
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}'.`);
|
|
915
916
|
return authorizationServerResult;
|
|
916
917
|
}
|