@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.d.mts
CHANGED
|
@@ -1699,6 +1699,7 @@ type DecodeJwtResult<HeaderSchema extends BaseSchema | undefined = undefined, Pa
|
|
|
1699
1699
|
header: InferSchemaOrDefaultOutput<HeaderSchema, typeof zJwtHeader>;
|
|
1700
1700
|
payload: InferSchemaOrDefaultOutput<PayloadSchema, typeof zJwtPayload>;
|
|
1701
1701
|
signature: string;
|
|
1702
|
+
compact: string;
|
|
1702
1703
|
};
|
|
1703
1704
|
declare function decodeJwt<HeaderSchema extends BaseSchema | undefined = undefined, PayloadSchema extends BaseSchema | undefined = undefined>(options: DecodeJwtOptions<HeaderSchema, PayloadSchema>): DecodeJwtResult<HeaderSchema, PayloadSchema>;
|
|
1704
1705
|
declare function jwtHeaderFromJwtSigner(signer: JwtSigner): {
|
|
@@ -1973,6 +1974,18 @@ declare function getAuthorizationServerMetadataFromList(authorizationServersMeta
|
|
|
1973
1974
|
declare function fetchJwks(jwksUrl: string, fetch?: Fetch): Promise<JwkSet>;
|
|
1974
1975
|
//#endregion
|
|
1975
1976
|
//#region src/metadata/fetch-well-known-metadata.d.ts
|
|
1977
|
+
interface FetchWellKnownMetadataOptions {
|
|
1978
|
+
/**
|
|
1979
|
+
* Custom fetch implementation to use for fetching the metadata
|
|
1980
|
+
*/
|
|
1981
|
+
fetch?: Fetch;
|
|
1982
|
+
/**
|
|
1983
|
+
* The accepted content types. If not provided a default of `ContentType.Json`
|
|
1984
|
+
* will be used. This will be used for the `Accept` header, as well as verified
|
|
1985
|
+
* against the `Content-Type` response header.
|
|
1986
|
+
*/
|
|
1987
|
+
acceptedContentType?: [ContentType, ...ContentType[]];
|
|
1988
|
+
}
|
|
1976
1989
|
/**
|
|
1977
1990
|
* Fetch well known metadata and validate the response.
|
|
1978
1991
|
*
|
|
@@ -1984,7 +1997,7 @@ declare function fetchJwks(jwksUrl: string, fetch?: Fetch): Promise<JwkSet>;
|
|
|
1984
1997
|
* @throws {InvalidFetchResponseError} if no successful or 404 response
|
|
1985
1998
|
* @throws {Error} if parsing json from response fails
|
|
1986
1999
|
*/
|
|
1987
|
-
declare function fetchWellKnownMetadata<Schema extends BaseSchema>(wellKnownMetadataUrl: string, schema: Schema,
|
|
2000
|
+
declare function fetchWellKnownMetadata<Schema extends BaseSchema>(wellKnownMetadataUrl: string, schema: Schema, options?: FetchWellKnownMetadataOptions): Promise<z$1.infer<Schema> | null>;
|
|
1988
2001
|
//#endregion
|
|
1989
2002
|
//#region src/access-token/create-access-token.d.ts
|
|
1990
2003
|
interface CreateAccessTokenOptions {
|
package/dist/index.d.ts
CHANGED
|
@@ -1699,6 +1699,7 @@ type DecodeJwtResult<HeaderSchema extends BaseSchema | undefined = undefined, Pa
|
|
|
1699
1699
|
header: InferSchemaOrDefaultOutput<HeaderSchema, typeof zJwtHeader>;
|
|
1700
1700
|
payload: InferSchemaOrDefaultOutput<PayloadSchema, typeof zJwtPayload>;
|
|
1701
1701
|
signature: string;
|
|
1702
|
+
compact: string;
|
|
1702
1703
|
};
|
|
1703
1704
|
declare function decodeJwt<HeaderSchema extends BaseSchema | undefined = undefined, PayloadSchema extends BaseSchema | undefined = undefined>(options: DecodeJwtOptions<HeaderSchema, PayloadSchema>): DecodeJwtResult<HeaderSchema, PayloadSchema>;
|
|
1704
1705
|
declare function jwtHeaderFromJwtSigner(signer: JwtSigner): {
|
|
@@ -1973,6 +1974,18 @@ declare function getAuthorizationServerMetadataFromList(authorizationServersMeta
|
|
|
1973
1974
|
declare function fetchJwks(jwksUrl: string, fetch?: Fetch): Promise<JwkSet>;
|
|
1974
1975
|
//#endregion
|
|
1975
1976
|
//#region src/metadata/fetch-well-known-metadata.d.ts
|
|
1977
|
+
interface FetchWellKnownMetadataOptions {
|
|
1978
|
+
/**
|
|
1979
|
+
* Custom fetch implementation to use for fetching the metadata
|
|
1980
|
+
*/
|
|
1981
|
+
fetch?: Fetch;
|
|
1982
|
+
/**
|
|
1983
|
+
* The accepted content types. If not provided a default of `ContentType.Json`
|
|
1984
|
+
* will be used. This will be used for the `Accept` header, as well as verified
|
|
1985
|
+
* against the `Content-Type` response header.
|
|
1986
|
+
*/
|
|
1987
|
+
acceptedContentType?: [ContentType, ...ContentType[]];
|
|
1988
|
+
}
|
|
1976
1989
|
/**
|
|
1977
1990
|
* Fetch well known metadata and validate the response.
|
|
1978
1991
|
*
|
|
@@ -1984,7 +1997,7 @@ declare function fetchJwks(jwksUrl: string, fetch?: Fetch): Promise<JwkSet>;
|
|
|
1984
1997
|
* @throws {InvalidFetchResponseError} if no successful or 404 response
|
|
1985
1998
|
* @throws {Error} if parsing json from response fails
|
|
1986
1999
|
*/
|
|
1987
|
-
declare function fetchWellKnownMetadata<Schema extends BaseSchema>(wellKnownMetadataUrl: string, schema: Schema,
|
|
2000
|
+
declare function fetchWellKnownMetadata<Schema extends BaseSchema>(wellKnownMetadataUrl: string, schema: Schema, options?: FetchWellKnownMetadataOptions): Promise<z$1.infer<Schema> | null>;
|
|
1988
2001
|
//#endregion
|
|
1989
2002
|
//#region src/access-token/create-access-token.d.ts
|
|
1990
2003
|
interface CreateAccessTokenOptions {
|
package/dist/index.js
CHANGED
|
@@ -234,7 +234,8 @@ function decodeJwt(options) {
|
|
|
234
234
|
return {
|
|
235
235
|
header,
|
|
236
236
|
payload: (0, __openid4vc_utils.parseWithErrorHandling)(options.payloadSchema ?? zJwtPayload, payloadJson),
|
|
237
|
-
signature: jwtParts[2]
|
|
237
|
+
signature: jwtParts[2],
|
|
238
|
+
compact: options.jwt
|
|
238
239
|
};
|
|
239
240
|
}
|
|
240
241
|
function jwtHeaderFromJwtSigner(signer) {
|
|
@@ -880,8 +881,8 @@ var Oauth2ResourceUnauthorizedError = class Oauth2ResourceUnauthorizedError exte
|
|
|
880
881
|
* @throws {InvalidFetchResponseError} if no successful or 404 response
|
|
881
882
|
* @throws {Error} if parsing json from response fails
|
|
882
883
|
*/
|
|
883
|
-
async function fetchWellKnownMetadata(wellKnownMetadataUrl, schema,
|
|
884
|
-
const { result, response } = await (0, __openid4vc_utils.createZodFetcher)(fetch)(schema, __openid4vc_utils.ContentType.Json, wellKnownMetadataUrl);
|
|
884
|
+
async function fetchWellKnownMetadata(wellKnownMetadataUrl, schema, options) {
|
|
885
|
+
const { result, response } = await (0, __openid4vc_utils.createZodFetcher)(options?.fetch)(schema, options?.acceptedContentType ?? [__openid4vc_utils.ContentType.Json], wellKnownMetadataUrl);
|
|
885
886
|
if (response.status === 404) return null;
|
|
886
887
|
if (!response.ok) throw new __openid4vc_utils.InvalidFetchResponseError(`Fetching well known metadata from '${wellKnownMetadataUrl}' resulted in an unsuccessful response with status '${response.status}'.`, await response.clone().text(), response);
|
|
887
888
|
if (!result?.success) throw new ValidationError$1(`Validation of metadata from '${wellKnownMetadataUrl}' failed`, result?.error);
|
|
@@ -933,9 +934,9 @@ async function fetchAuthorizationServerMetadata(issuer, fetch) {
|
|
|
933
934
|
const openIdConfigurationWellKnownMetadataUrl = (0, __openid4vc_utils.joinUriParts)(issuer, [wellKnownOpenIdConfigurationServerSuffix]);
|
|
934
935
|
const authorizationServerWellKnownMetadataUrl = (0, __openid4vc_utils.joinUriParts)(parsedIssuerUrl.origin, [wellKnownAuthorizationServerSuffix, parsedIssuerUrl.pathname]);
|
|
935
936
|
const nonCompliantAuthorizationServerWellKnownMetadataUrl = (0, __openid4vc_utils.joinUriParts)(issuer, [wellKnownAuthorizationServerSuffix]);
|
|
936
|
-
let authorizationServerResult = await fetchWellKnownMetadata(authorizationServerWellKnownMetadataUrl, zAuthorizationServerMetadata, fetch);
|
|
937
|
-
if (!authorizationServerResult && nonCompliantAuthorizationServerWellKnownMetadataUrl !== authorizationServerWellKnownMetadataUrl) authorizationServerResult = await fetchWellKnownMetadata(nonCompliantAuthorizationServerWellKnownMetadataUrl, zAuthorizationServerMetadata, fetch);
|
|
938
|
-
if (!authorizationServerResult) authorizationServerResult = await fetchWellKnownMetadata(openIdConfigurationWellKnownMetadataUrl, zAuthorizationServerMetadata, fetch);
|
|
937
|
+
let authorizationServerResult = await fetchWellKnownMetadata(authorizationServerWellKnownMetadataUrl, zAuthorizationServerMetadata, { fetch });
|
|
938
|
+
if (!authorizationServerResult && nonCompliantAuthorizationServerWellKnownMetadataUrl !== authorizationServerWellKnownMetadataUrl) authorizationServerResult = await fetchWellKnownMetadata(nonCompliantAuthorizationServerWellKnownMetadataUrl, zAuthorizationServerMetadata, { fetch });
|
|
939
|
+
if (!authorizationServerResult) authorizationServerResult = await fetchWellKnownMetadata(openIdConfigurationWellKnownMetadataUrl, zAuthorizationServerMetadata, { fetch });
|
|
939
940
|
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}'.`);
|
|
940
941
|
return authorizationServerResult;
|
|
941
942
|
}
|