@better-auth/oauth-provider 1.7.0-rc.1 → 1.7.0-rc.2
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/{client-assertion-D-tAYsKC.mjs → client-assertion-C-Cg0dCs.mjs} +14 -3
- package/dist/client-resource.d.mts +8 -9
- package/dist/client-resource.mjs +27 -4
- package/dist/client.d.mts +2 -4
- package/dist/client.mjs +1 -2
- package/dist/index.d.mts +11 -10
- package/dist/index.mjs +2786 -172
- package/dist/{oauth-ScTJEcFV.d.mts → oauth-CSzjH7fO.d.mts} +26 -13
- package/dist/{oauth-BrNRbP2A.d.mts → oauth-DdSU0qF6.d.mts} +72 -65
- package/dist/{utils-DO8lmoDw.mjs → resource-challenge-2qgK1B-a.mjs} +84 -29
- package/dist/{signed-query-Df1MNiSH.mjs → version-C0y8aPv-.mjs} +5 -2
- package/package.json +7 -6
- package/dist/introspect-DvHp2a64.mjs +0 -2507
- package/dist/resource-challenge-B-cqv4ur.mjs +0 -63
- package/dist/rolldown-runtime-wcPFST8Q.mjs +0 -13
- package/dist/version--aseHtsu.mjs +0 -5
|
@@ -1,11 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as getClient } from "./utils-DO8lmoDw.mjs";
|
|
1
|
+
import { o as getClient } from "./resource-challenge-2qgK1B-a.mjs";
|
|
3
2
|
import { isPublicRoutableHost } from "@better-auth/core/utils/host";
|
|
4
3
|
import { APIError } from "better-call";
|
|
5
4
|
import { CLIENT_ASSERTION_TYPE, PRIVATE_KEY_JWT_SIGNING_ALGORITHMS } from "@better-auth/core/oauth2";
|
|
6
5
|
import { base64Url } from "@better-auth/utils/base64";
|
|
7
6
|
import { createHash } from "@better-auth/utils/hash";
|
|
8
7
|
import { createLocalJWKSet, decodeJwt, decodeProtectedHeader, jwtVerify } from "jose";
|
|
8
|
+
//#region \0rolldown/runtime.js
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __exportAll = (all, no_symbols) => {
|
|
11
|
+
let target = {};
|
|
12
|
+
for (var name in all) __defProp(target, name, {
|
|
13
|
+
get: all[name],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
17
|
+
return target;
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
9
20
|
//#region src/utils/client-assertion.ts
|
|
10
21
|
var client_assertion_exports = /* @__PURE__ */ __exportAll({
|
|
11
22
|
consumeClientAssertion: () => consumeClientAssertion,
|
|
@@ -293,4 +304,4 @@ async function verifyClientAssertion(ctx, opts, clientAssertion, clientAssertion
|
|
|
293
304
|
return { clientId };
|
|
294
305
|
}
|
|
295
306
|
//#endregion
|
|
296
|
-
export { consumeClientAssertion as n, isPrivateHostname as r, client_assertion_exports as t };
|
|
307
|
+
export { __exportAll as i, consumeClientAssertion as n, isPrivateHostname as r, client_assertion_exports as t };
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import { c as ResourceServerMetadata } from "./oauth-
|
|
1
|
+
import { c as ResourceServerMetadata } from "./oauth-CSzjH7fO.mjs";
|
|
2
2
|
import { ResourceRequestInput, VerifyAccessTokenRequestOptions } from "better-auth/oauth2";
|
|
3
3
|
import { JWTPayload, JWTVerifyOptions } from "jose";
|
|
4
4
|
import { BetterAuthOptions } from "better-auth/types";
|
|
5
|
-
|
|
6
5
|
//#region src/client-resource.d.ts
|
|
7
6
|
type ResourceClientAuth = {
|
|
8
|
-
options:
|
|
9
|
-
baseURL?: BetterAuthOptions["baseURL"];
|
|
10
|
-
basePath?: BetterAuthOptions["basePath"];
|
|
11
|
-
};
|
|
7
|
+
options: BetterAuthOptions;
|
|
12
8
|
$context: Promise<unknown>;
|
|
13
9
|
};
|
|
14
10
|
declare const oauthProviderResourceClient: <T extends ResourceClientAuth | undefined = undefined>(auth?: T) => {
|
|
@@ -78,7 +74,8 @@ type VerifyAccessTokenAuthOpts = {
|
|
|
78
74
|
verifyOptions?: JWTVerifyOptions & Required<Pick<JWTVerifyOptions, "audience">>;
|
|
79
75
|
scopes?: string[];
|
|
80
76
|
jwksUrl?: string;
|
|
81
|
-
remoteVerify?: VerifyAccessTokenRemote;
|
|
77
|
+
remoteVerify?: VerifyAccessTokenRemote;
|
|
78
|
+
/** Maps non-url (ie urn, client) resources to resource_metadata */
|
|
82
79
|
resourceMetadataMappings?: Record<string, string>;
|
|
83
80
|
};
|
|
84
81
|
type VerifyAccessTokenRequestAuthOpts = VerifyAccessTokenAuthOpts & {
|
|
@@ -88,13 +85,15 @@ type VerifyAccessTokenNoAuthOpts = {
|
|
|
88
85
|
verifyOptions: JWTVerifyOptions & Required<Pick<JWTVerifyOptions, "audience" | "issuer">>;
|
|
89
86
|
scopes?: string[];
|
|
90
87
|
jwksUrl: string;
|
|
91
|
-
remoteVerify?: VerifyAccessTokenRemote;
|
|
88
|
+
remoteVerify?: VerifyAccessTokenRemote;
|
|
89
|
+
/** Maps non-url (ie urn, client) resources to resource_metadata */
|
|
92
90
|
resourceMetadataMappings?: Record<string, string>;
|
|
93
91
|
} | {
|
|
94
92
|
verifyOptions: JWTVerifyOptions & Required<Pick<JWTVerifyOptions, "audience" | "issuer">>;
|
|
95
93
|
scopes?: string[];
|
|
96
94
|
jwksUrl?: string;
|
|
97
|
-
remoteVerify: VerifyAccessTokenRemote;
|
|
95
|
+
remoteVerify: VerifyAccessTokenRemote;
|
|
96
|
+
/** Maps non-url (ie urn, client) resources to resource_metadata */
|
|
98
97
|
resourceMetadataMappings?: Record<string, string>;
|
|
99
98
|
};
|
|
100
99
|
type VerifyAccessTokenRequestNoAuthOpts = VerifyAccessTokenNoAuthOpts & {
|
package/dist/client-resource.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as PACKAGE_VERSION } from "./version
|
|
3
|
-
import { t as raiseResourceServerChallenge } from "./resource-challenge-B-cqv4ur.mjs";
|
|
1
|
+
import { c as getOAuthProviderPlugin, s as getJwtPlugin, t as raiseResourceServerChallenge } from "./resource-challenge-2qgK1B-a.mjs";
|
|
2
|
+
import { t as PACKAGE_VERSION } from "./version-C0y8aPv-.mjs";
|
|
4
3
|
import { APIError } from "better-call";
|
|
5
4
|
import { logger } from "@better-auth/core/env";
|
|
6
5
|
import { BetterAuthError } from "@better-auth/core/error";
|
|
@@ -50,6 +49,14 @@ const oauthProviderResourceClient = (auth) => {
|
|
|
50
49
|
version: PACKAGE_VERSION,
|
|
51
50
|
getActions() {
|
|
52
51
|
return {
|
|
52
|
+
/**
|
|
53
|
+
* Performs verification of an access token for your APIs. Can perform
|
|
54
|
+
* local verification using `jwksUrl` by default. Can also be configured
|
|
55
|
+
* for remote introspection using `remoteVerify` if a confidential client
|
|
56
|
+
* is set up for this API.
|
|
57
|
+
*
|
|
58
|
+
* The optional auth parameter can fill known values automatically.
|
|
59
|
+
*/
|
|
53
60
|
verifyBearerToken: (async (token, opts) => {
|
|
54
61
|
const verifyOptions = await resolveVerifyAccessTokenOptions(opts);
|
|
55
62
|
try {
|
|
@@ -62,6 +69,12 @@ const oauthProviderResourceClient = (auth) => {
|
|
|
62
69
|
});
|
|
63
70
|
}
|
|
64
71
|
}),
|
|
72
|
+
/**
|
|
73
|
+
* Performs verification of a protected-resource request. Use this for
|
|
74
|
+
* new resource-server integrations so sender-constrained DPoP access
|
|
75
|
+
* tokens are enforced with the request method, URL, Authorization
|
|
76
|
+
* scheme, DPoP proof, `ath`, and `cnf.jkt` binding.
|
|
77
|
+
*/
|
|
65
78
|
verifyAccessTokenRequest: (async (request, opts) => {
|
|
66
79
|
const verifyOptions = await resolveVerifyAccessTokenOptions(opts);
|
|
67
80
|
try {
|
|
@@ -73,13 +86,23 @@ const oauthProviderResourceClient = (auth) => {
|
|
|
73
86
|
});
|
|
74
87
|
}
|
|
75
88
|
}),
|
|
89
|
+
/**
|
|
90
|
+
* An authorization server does not typically publish
|
|
91
|
+
* the `/.well-known/oauth-protected-resource` themselves.
|
|
92
|
+
* Thus, we provide a client-only endpoint to help set up
|
|
93
|
+
* your protected resource metadata.
|
|
94
|
+
*
|
|
95
|
+
* The optional auth parameter can fill known values automatically.
|
|
96
|
+
*
|
|
97
|
+
* @see https://datatracker.ietf.org/doc/html/rfc8414#section-2
|
|
98
|
+
*/
|
|
76
99
|
getProtectedResourceMetadata: (async (overrides, opts) => {
|
|
77
100
|
const resource = overrides?.resource ?? authServerBaseUrl;
|
|
78
101
|
const oauthProviderOptions = (await getOauthProviderPlugin())?.options;
|
|
79
102
|
if (!resource) throw Error("missing required resource");
|
|
80
103
|
if (oauthProviderOptions?.scopes && opts?.externalScopes && (overrides?.authorization_servers?.length ?? 0) <= 1) throw new BetterAuthError("external scopes should not be provided with one authorization server");
|
|
81
104
|
if (overrides?.scopes_supported) {
|
|
82
|
-
const allValidScopes = new Set([...oauthProviderOptions?.scopes ?? [], ...opts?.externalScopes ?? []]);
|
|
105
|
+
const allValidScopes = /* @__PURE__ */ new Set([...oauthProviderOptions?.scopes ?? [], ...opts?.externalScopes ?? []]);
|
|
83
106
|
for (const sc of overrides.scopes_supported) {
|
|
84
107
|
if (sc === "openid") throw new BetterAuthError("Only the Auth Server should utilize the openid scope");
|
|
85
108
|
if ([
|
package/dist/client.d.mts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { r as oauthProvider } from "./oauth-
|
|
2
|
-
import * as _better_fetch_fetch0 from "@better-fetch/fetch";
|
|
3
|
-
|
|
1
|
+
import { r as oauthProvider } from "./oauth-DdSU0qF6.mjs";
|
|
4
2
|
//#region src/client.d.ts
|
|
5
3
|
declare const oauthProviderClient: () => {
|
|
6
4
|
id: "oauth-provider-client";
|
|
@@ -10,7 +8,7 @@ declare const oauthProviderClient: () => {
|
|
|
10
8
|
name: string;
|
|
11
9
|
description: string;
|
|
12
10
|
hooks: {
|
|
13
|
-
onRequest<T extends Record<string, any>>(ctx:
|
|
11
|
+
onRequest<T extends Record<string, any>>(ctx: import("@better-fetch/fetch").RequestContext<T>): Promise<void>;
|
|
14
12
|
};
|
|
15
13
|
}[];
|
|
16
14
|
$InferServerPlugin: ReturnType<typeof oauthProvider>;
|
package/dist/client.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as PACKAGE_VERSION } from "./version--aseHtsu.mjs";
|
|
1
|
+
import { n as buildSignedOAuthQuery, t as PACKAGE_VERSION } from "./version-C0y8aPv-.mjs";
|
|
3
2
|
import { safeJSONParse } from "@better-auth/core/utils/json";
|
|
4
3
|
//#region src/client.ts
|
|
5
4
|
const oauthProviderClient = () => {
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { A as OAuthProviderExtension, B as StoreTokenType, C as OAuthConsent, D as OAuthOpaqueAccessToken, E as OAuthMetadataExtensionInput, F as OAuthTokenResponse, H as VerificationValue, I as OAuthUserInfoExtensionInput, L as Prompt, M as OAuthResource, N as OAuthResourceInput, O as OAuthOptions, P as OAuthTokenIssueParams, R as SchemaClient, S as OAuthClientResource, T as OAuthExtensionGrantHandlerInput, U as ClientRegistrationRequest, V as StoredAuthorizationQuery, W as ResourceUriSchema, _ as OAuthClaimExtensionInput, a as GrantType, b as OAuthClientAuthenticationResult, c as ResourceServerMetadata, d as ActiveAccessTokenPayload, f as AuthorizePrompt, g as OAuthAuthorizationQuery, h as OAuthAuthenticatedClient, i as Confirmation, j as OAuthRefreshToken, k as OAuthProviderApi, l as TokenEndpointAuthMethod, m as InitialAccessTokenAuthorization, n as AuthServerMetadata, o as OAuthClient, p as ClientDiscovery, r as BearerMethodsSupported, s as OIDCMetadata, t as AuthMethod, u as TokenType, v as OAuthClientAuthenticationInput, w as OAuthExtensionGrantHandler, x as OAuthClientAuthenticationStrategy, y as OAuthClientAuthenticationRequest, z as Scope } from "./oauth-
|
|
2
|
-
import { a as OAuthEndpointErrorResult, c as OAuthFieldErrorCode, i as getIssuer, l as OAuthFieldErrorCodeMap, n as getOAuthProviderState, o as OAuthEndpointRedirectContext, r as oauthProvider, s as OAuthErrorCode, t as DEFAULT_OAUTH_SCOPES, u as OAuthRedirectOnError } from "./oauth-
|
|
1
|
+
import { A as OAuthProviderExtension, B as StoreTokenType, C as OAuthConsent, D as OAuthOpaqueAccessToken, E as OAuthMetadataExtensionInput, F as OAuthTokenResponse, H as VerificationValue, I as OAuthUserInfoExtensionInput, L as Prompt, M as OAuthResource, N as OAuthResourceInput, O as OAuthOptions, P as OAuthTokenIssueParams, R as SchemaClient, S as OAuthClientResource, T as OAuthExtensionGrantHandlerInput, U as ClientRegistrationRequest, V as StoredAuthorizationQuery, W as ResourceUriSchema, _ as OAuthClaimExtensionInput, a as GrantType, b as OAuthClientAuthenticationResult, c as ResourceServerMetadata, d as ActiveAccessTokenPayload, f as AuthorizePrompt, g as OAuthAuthorizationQuery, h as OAuthAuthenticatedClient, i as Confirmation, j as OAuthRefreshToken, k as OAuthProviderApi, l as TokenEndpointAuthMethod, m as InitialAccessTokenAuthorization, n as AuthServerMetadata, o as OAuthClient, p as ClientDiscovery, r as BearerMethodsSupported, s as OIDCMetadata, t as AuthMethod, u as TokenType, v as OAuthClientAuthenticationInput, w as OAuthExtensionGrantHandler, x as OAuthClientAuthenticationStrategy, y as OAuthClientAuthenticationRequest, z as Scope } from "./oauth-CSzjH7fO.mjs";
|
|
2
|
+
import { a as OAuthEndpointErrorResult, c as OAuthFieldErrorCode, i as getIssuer, l as OAuthFieldErrorCodeMap, n as getOAuthProviderState, o as OAuthEndpointRedirectContext, r as oauthProvider, s as OAuthErrorCode, t as DEFAULT_OAUTH_SCOPES, u as OAuthRedirectOnError } from "./oauth-DdSU0qF6.mjs";
|
|
3
3
|
import { getSessionFromCtx } from "better-auth/api";
|
|
4
4
|
import { JWSAlgorithms, JwtOptions } from "better-auth/plugins";
|
|
5
5
|
import { AuthContext, GenericEndpointContext } from "@better-auth/core";
|
|
6
|
-
import * as better_auth0 from "better-auth";
|
|
7
|
-
|
|
8
6
|
//#region src/extensions.d.ts
|
|
9
7
|
/**
|
|
10
8
|
* Registers an {@link OAuthProviderExtension} with the OAuth Provider plugin
|
|
@@ -67,17 +65,17 @@ declare function oidcServerMetadata(ctx: GenericEndpointContext, opts: OAuthOpti
|
|
|
67
65
|
response_modes_supported: "query"[];
|
|
68
66
|
grant_types_supported: GrantType[];
|
|
69
67
|
token_endpoint_auth_methods_supported?: TokenEndpointAuthMethod[] | undefined;
|
|
70
|
-
token_endpoint_auth_signing_alg_values_supported?:
|
|
68
|
+
token_endpoint_auth_signing_alg_values_supported?: import("better-auth").PrivateKeyJwtSigningAlgorithm[] | undefined;
|
|
71
69
|
service_documentation?: string | undefined;
|
|
72
70
|
ui_locales_supported?: string[] | undefined;
|
|
73
71
|
op_policy_uri?: string | undefined;
|
|
74
72
|
op_tos_uri?: string | undefined;
|
|
75
73
|
revocation_endpoint?: string | undefined;
|
|
76
74
|
revocation_endpoint_auth_methods_supported?: TokenEndpointAuthMethod[] | undefined;
|
|
77
|
-
revocation_endpoint_auth_signing_alg_values_supported?:
|
|
75
|
+
revocation_endpoint_auth_signing_alg_values_supported?: import("better-auth").PrivateKeyJwtSigningAlgorithm[] | undefined;
|
|
78
76
|
introspection_endpoint?: string | undefined;
|
|
79
77
|
introspection_endpoint_auth_methods_supported?: TokenEndpointAuthMethod[] | undefined;
|
|
80
|
-
introspection_endpoint_auth_signing_alg_values_supported?:
|
|
78
|
+
introspection_endpoint_auth_signing_alg_values_supported?: import("better-auth").PrivateKeyJwtSigningAlgorithm[] | undefined;
|
|
81
79
|
code_challenge_methods_supported: "S256"[];
|
|
82
80
|
authorization_response_iss_parameter_supported?: boolean | undefined;
|
|
83
81
|
client_id_metadata_document_supported?: boolean | undefined;
|
|
@@ -144,8 +142,11 @@ declare function oauthToSchema(input: OAuthClient): SchemaClient<Scope[]>;
|
|
|
144
142
|
* @internal
|
|
145
143
|
*/
|
|
146
144
|
declare function raiseResourceServerChallenge(error: unknown, resource: string | string[], opts?: {
|
|
147
|
-
/** Maps non-URL (urn, client) resources to their resource_metadata URL. */
|
|
148
|
-
|
|
145
|
+
/** Maps non-URL (urn, client) resources to their resource_metadata URL. */
|
|
146
|
+
resourceMetadataMappings?: Record<string, string>;
|
|
147
|
+
/** DPoP JWS algorithms to advertise in RFC 9449 challenges. */
|
|
148
|
+
dpopSigningAlgorithms?: readonly string[];
|
|
149
|
+
/** Space-delimited scopes to advertise in RFC 6750 bearer challenges. */
|
|
149
150
|
scope?: string;
|
|
150
151
|
}): never;
|
|
151
152
|
//#endregion
|
|
@@ -194,4 +195,4 @@ declare function consumeClientAssertion(ctx: GenericEndpointContext, opts: OAuth
|
|
|
194
195
|
expectedAudience: string;
|
|
195
196
|
}): Promise<void>;
|
|
196
197
|
//#endregion
|
|
197
|
-
export { ActiveAccessTokenPayload, AuthMethod, AuthServerMetadata, AuthorizePrompt, BearerMethodsSupported, ClientDiscovery, ClientRegistrationRequest, Confirmation, DEFAULT_OAUTH_SCOPES, GrantType, InitialAccessTokenAuthorization, OAuthAuthenticatedClient, OAuthAuthorizationQuery, OAuthClaimExtensionInput, type OAuthClient, OAuthClientAuthenticationInput, OAuthClientAuthenticationRequest, OAuthClientAuthenticationResult, OAuthClientAuthenticationStrategy, OAuthClientResource, OAuthConsent, type OAuthEndpointErrorResult, type OAuthEndpointRedirectContext, type OAuthErrorCode, OAuthExtensionGrantHandler, OAuthExtensionGrantHandlerInput, type OAuthFieldErrorCode, type OAuthFieldErrorCodeMap, OAuthMetadataExtensionInput, OAuthOpaqueAccessToken, OAuthOptions, OAuthProviderApi, OAuthProviderExtension, type OAuthRedirectOnError, OAuthRefreshToken, OAuthResource, OAuthResourceInput, OAuthTokenIssueParams, OAuthTokenResponse, OAuthUserInfoExtensionInput, OIDCMetadata, Prompt, type ResourceServerMetadata, ResourceUriSchema, SchemaClient, Scope, StoreTokenType, StoredAuthorizationQuery, TokenEndpointAuthMethod, TokenType, VerificationValue, authServerMetadata, checkOAuthClient, consumeClientAssertion, extendOAuthProvider, getIssuer, getOAuthProviderApi, getOAuthProviderState, metadataResponse, oauthAuthorizationServerMetadata, oauthProvider, oauthProviderAuthServerMetadata, oauthProviderOpenIdConfigMetadata, oauthToSchema, oidcServerMetadata, raiseResourceServerChallenge };
|
|
198
|
+
export { type ActiveAccessTokenPayload, type AuthMethod, type AuthServerMetadata, type AuthorizePrompt, type BearerMethodsSupported, type ClientDiscovery, type ClientRegistrationRequest, type Confirmation, DEFAULT_OAUTH_SCOPES, type GrantType, type InitialAccessTokenAuthorization, type OAuthAuthenticatedClient, type OAuthAuthorizationQuery, type OAuthClaimExtensionInput, type OAuthClient, type OAuthClientAuthenticationInput, type OAuthClientAuthenticationRequest, type OAuthClientAuthenticationResult, type OAuthClientAuthenticationStrategy, type OAuthClientResource, type OAuthConsent, type OAuthEndpointErrorResult, type OAuthEndpointRedirectContext, type OAuthErrorCode, type OAuthExtensionGrantHandler, type OAuthExtensionGrantHandlerInput, type OAuthFieldErrorCode, type OAuthFieldErrorCodeMap, type OAuthMetadataExtensionInput, type OAuthOpaqueAccessToken, type OAuthOptions, type OAuthProviderApi, type OAuthProviderExtension, type OAuthRedirectOnError, type OAuthRefreshToken, type OAuthResource, type OAuthResourceInput, type OAuthTokenIssueParams, type OAuthTokenResponse, type OAuthUserInfoExtensionInput, type OIDCMetadata, type Prompt, type ResourceServerMetadata, ResourceUriSchema, type SchemaClient, type Scope, type StoreTokenType, type StoredAuthorizationQuery, type TokenEndpointAuthMethod, type TokenType, type VerificationValue, authServerMetadata, checkOAuthClient, consumeClientAssertion, extendOAuthProvider, getIssuer, getOAuthProviderApi, getOAuthProviderState, metadataResponse, oauthAuthorizationServerMetadata, oauthProvider, oauthProviderAuthServerMetadata, oauthProviderOpenIdConfigMetadata, oauthToSchema, oidcServerMetadata, raiseResourceServerChallenge };
|