@better-auth/oauth-provider 1.6.22 → 1.6.24
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-resource.d.mts +7 -5
- package/dist/client-resource.mjs +21 -3
- package/dist/client.d.mts +2 -4
- package/dist/client.mjs +1 -1
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +42 -7
- package/dist/{oauth-D74mBkw6.d.mts → oauth-BFBataE_.d.mts} +25 -13
- package/dist/{oauth-DZ80cNUW.d.mts → oauth-dQVivAXR.d.mts} +50 -54
- package/dist/{utils-DQLdireY.mjs → utils-C7lKElJN.mjs} +4 -10
- package/dist/{version-DaSfXJQ1.mjs → version-rl1vdpzB.mjs} +2 -2
- package/package.json +6 -6
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { s as ResourceServerMetadata } from "./oauth-
|
|
1
|
+
import { s as ResourceServerMetadata } from "./oauth-BFBataE_.mjs";
|
|
2
2
|
import { JWTPayload, JWTVerifyOptions } from "jose";
|
|
3
3
|
import { BetterAuthOptions } from "better-auth/types";
|
|
4
|
-
|
|
5
4
|
//#region src/client-resource.d.ts
|
|
6
5
|
type ResourceClientAuth = {
|
|
7
6
|
options: {
|
|
@@ -69,20 +68,23 @@ type VerifyAccessTokenAuthOpts = {
|
|
|
69
68
|
verifyOptions?: JWTVerifyOptions & Required<Pick<JWTVerifyOptions, "audience">>;
|
|
70
69
|
scopes?: string[];
|
|
71
70
|
jwksUrl?: string;
|
|
72
|
-
remoteVerify?: VerifyAccessTokenRemote;
|
|
71
|
+
remoteVerify?: VerifyAccessTokenRemote;
|
|
72
|
+
/** Maps non-url (ie urn, client) resources to resource_metadata */
|
|
73
73
|
resourceMetadataMappings?: Record<string, string>;
|
|
74
74
|
};
|
|
75
75
|
type VerifyAccessTokenNoAuthOpts = {
|
|
76
76
|
verifyOptions: JWTVerifyOptions & Required<Pick<JWTVerifyOptions, "audience" | "issuer">>;
|
|
77
77
|
scopes?: string[];
|
|
78
78
|
jwksUrl: string;
|
|
79
|
-
remoteVerify?: VerifyAccessTokenRemote;
|
|
79
|
+
remoteVerify?: VerifyAccessTokenRemote;
|
|
80
|
+
/** Maps non-url (ie urn, client) resources to resource_metadata */
|
|
80
81
|
resourceMetadataMappings?: Record<string, string>;
|
|
81
82
|
} | {
|
|
82
83
|
verifyOptions: JWTVerifyOptions & Required<Pick<JWTVerifyOptions, "audience" | "issuer">>;
|
|
83
84
|
scopes?: string[];
|
|
84
85
|
jwksUrl?: string;
|
|
85
|
-
remoteVerify: VerifyAccessTokenRemote;
|
|
86
|
+
remoteVerify: VerifyAccessTokenRemote;
|
|
87
|
+
/** Maps non-url (ie urn, client) resources to resource_metadata */
|
|
86
88
|
resourceMetadataMappings?: Record<string, string>;
|
|
87
89
|
};
|
|
88
90
|
type ProtectedResourceMetadataOutput<T> = T extends undefined ? (overrides: ResourceServerMetadata, opts?: {
|
package/dist/client-resource.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as getJwtPlugin, b as handleMcpErrors, o as getOAuthProviderPlugin } from "./utils-
|
|
2
|
-
import { t as PACKAGE_VERSION } from "./version-
|
|
1
|
+
import { a as getJwtPlugin, b as handleMcpErrors, o as getOAuthProviderPlugin } from "./utils-C7lKElJN.mjs";
|
|
2
|
+
import { t as PACKAGE_VERSION } from "./version-rl1vdpzB.mjs";
|
|
3
3
|
import { verifyAccessToken } from "better-auth/oauth2";
|
|
4
4
|
import { APIError } from "better-call";
|
|
5
5
|
import { logger } from "@better-auth/core/env";
|
|
@@ -26,6 +26,14 @@ const oauthProviderResourceClient = (auth) => {
|
|
|
26
26
|
version: PACKAGE_VERSION,
|
|
27
27
|
getActions() {
|
|
28
28
|
return {
|
|
29
|
+
/**
|
|
30
|
+
* Performs verification of an access token for your APIs. Can perform
|
|
31
|
+
* local verification using `jwksUrl` by default. Can also be configured
|
|
32
|
+
* for remote introspection using `remoteVerify` if a confidential client
|
|
33
|
+
* is set up for this API.
|
|
34
|
+
*
|
|
35
|
+
* The optional auth parameter can fill known values automatically.
|
|
36
|
+
*/
|
|
29
37
|
verifyAccessToken: (async (token, opts) => {
|
|
30
38
|
const jwtPluginOptions = await getJwtPluginOptions();
|
|
31
39
|
const audience = opts?.verifyOptions?.audience ?? authServerBaseUrl;
|
|
@@ -53,13 +61,23 @@ const oauthProviderResourceClient = (auth) => {
|
|
|
53
61
|
throw handleMcpErrors(error, audience, { resourceMetadataMappings: opts?.resourceMetadataMappings });
|
|
54
62
|
}
|
|
55
63
|
}),
|
|
64
|
+
/**
|
|
65
|
+
* An authorization server does not typically publish
|
|
66
|
+
* the `/.well-known/oauth-protected-resource` themselves.
|
|
67
|
+
* Thus, we provide a client-only endpoint to help set up
|
|
68
|
+
* your protected resource metadata.
|
|
69
|
+
*
|
|
70
|
+
* The optional auth parameter can fill known values automatically.
|
|
71
|
+
*
|
|
72
|
+
* @see https://datatracker.ietf.org/doc/html/rfc8414#section-2
|
|
73
|
+
*/
|
|
56
74
|
getProtectedResourceMetadata: (async (overrides, opts) => {
|
|
57
75
|
const resource = overrides?.resource ?? authServerBaseUrl;
|
|
58
76
|
const oauthProviderOptions = (await getOauthProviderPlugin())?.options;
|
|
59
77
|
if (!resource) throw Error("missing required resource");
|
|
60
78
|
if (oauthProviderOptions?.scopes && opts?.externalScopes && (overrides?.authorization_servers?.length ?? 0) <= 1) throw new BetterAuthError("external scopes should not be provided with one authorization server");
|
|
61
79
|
if (overrides?.scopes_supported) {
|
|
62
|
-
const allValidScopes = new Set([...oauthProviderOptions?.scopes ?? [], ...opts?.externalScopes ?? []]);
|
|
80
|
+
const allValidScopes = /* @__PURE__ */ new Set([...oauthProviderOptions?.scopes ?? [], ...opts?.externalScopes ?? []]);
|
|
63
81
|
for (const sc of overrides.scopes_supported) {
|
|
64
82
|
if (sc === "openid") throw new BetterAuthError("Only the Auth Server should utilize the openid scope");
|
|
65
83
|
if ([
|
package/dist/client.d.mts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { n as oauthProvider } from "./oauth-
|
|
2
|
-
import * as _better_fetch_fetch0 from "@better-fetch/fetch";
|
|
3
|
-
|
|
1
|
+
import { n as oauthProvider } from "./oauth-dQVivAXR.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,4 +1,4 @@
|
|
|
1
|
-
import { n as buildSignedOAuthQuery, t as PACKAGE_VERSION } from "./version-
|
|
1
|
+
import { n as buildSignedOAuthQuery, t as PACKAGE_VERSION } from "./version-rl1vdpzB.mjs";
|
|
2
2
|
import { safeJSONParse } from "@better-auth/core/utils/json";
|
|
3
3
|
//#region src/client.ts
|
|
4
4
|
const oauthProviderClient = () => {
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { _ as Scope, a as OAuthClient, b as Awaitable, c as TokenEndpointAuthMethod, d as OAuthConsent, f as OAuthOpaqueAccessToken, g as SchemaClient, h as Prompt, i as GrantType, l as AuthorizePrompt, m as OAuthRefreshToken, n as AuthServerMetadata, o as OIDCMetadata, p as OAuthOptions, r as BearerMethodsSupported, s as ResourceServerMetadata, t as AuthMethod, u as OAuthAuthorizationQuery, v as StoreTokenType, y as VerificationValue } from "./oauth-
|
|
2
|
-
import { n as oauthProvider, t as getOAuthProviderState } from "./oauth-
|
|
1
|
+
import { _ as Scope, a as OAuthClient, b as Awaitable, c as TokenEndpointAuthMethod, d as OAuthConsent, f as OAuthOpaqueAccessToken, g as SchemaClient, h as Prompt, i as GrantType, l as AuthorizePrompt, m as OAuthRefreshToken, n as AuthServerMetadata, o as OIDCMetadata, p as OAuthOptions, r as BearerMethodsSupported, s as ResourceServerMetadata, t as AuthMethod, u as OAuthAuthorizationQuery, v as StoreTokenType, y as VerificationValue } from "./oauth-BFBataE_.mjs";
|
|
2
|
+
import { n as oauthProvider, t as getOAuthProviderState } from "./oauth-dQVivAXR.mjs";
|
|
3
3
|
import { verifyAccessToken } from "better-auth/oauth2";
|
|
4
4
|
import { JWSAlgorithms, JwtOptions } from "better-auth/plugins";
|
|
5
5
|
import { JWTPayload } from "jose";
|
|
6
6
|
import { GenericEndpointContext } from "@better-auth/core";
|
|
7
|
-
|
|
8
7
|
//#region src/mcp.d.ts
|
|
9
8
|
/**
|
|
10
9
|
* A request middleware handler that checks and responds with
|
|
@@ -12,10 +11,11 @@ import { GenericEndpointContext } from "@better-auth/core";
|
|
|
12
11
|
*
|
|
13
12
|
* @external
|
|
14
13
|
*/
|
|
15
|
-
declare const mcpHandler: (
|
|
16
|
-
|
|
14
|
+
declare const mcpHandler: (
|
|
15
|
+
/** Resource is the same url as the audience */
|
|
17
16
|
verifyOptions: Parameters<typeof verifyAccessToken>[1], handler: (req: Request, jwt: JWTPayload) => Awaitable<Response>, opts?: {
|
|
18
|
-
/** Maps non-url (ie urn, client) resources to resource_metadata */
|
|
17
|
+
/** Maps non-url (ie urn, client) resources to resource_metadata */
|
|
18
|
+
resourceMetadataMappings: Record<string, string>;
|
|
19
19
|
}) => (req: Request) => Promise<Response>;
|
|
20
20
|
//#endregion
|
|
21
21
|
//#region src/metadata.d.ts
|
|
@@ -62,4 +62,4 @@ declare const oauthProviderOpenIdConfigMetadata: <Auth extends {
|
|
|
62
62
|
headers?: HeadersInit;
|
|
63
63
|
}) => (request: Request) => Promise<Response>;
|
|
64
64
|
//#endregion
|
|
65
|
-
export { AuthMethod, AuthServerMetadata, AuthorizePrompt, BearerMethodsSupported, GrantType, OAuthAuthorizationQuery, OAuthClient, OAuthConsent, OAuthOpaqueAccessToken, OAuthOptions, OAuthRefreshToken, OIDCMetadata, Prompt, ResourceServerMetadata, SchemaClient, Scope, StoreTokenType, TokenEndpointAuthMethod, VerificationValue, authServerMetadata, getOAuthProviderState, mcpHandler, oauthProvider, oauthProviderAuthServerMetadata, oauthProviderOpenIdConfigMetadata, oidcServerMetadata };
|
|
65
|
+
export { type AuthMethod, type AuthServerMetadata, type AuthorizePrompt, type BearerMethodsSupported, type GrantType, type OAuthAuthorizationQuery, type OAuthClient, type OAuthConsent, type OAuthOpaqueAccessToken, type OAuthOptions, type OAuthRefreshToken, type OIDCMetadata, type Prompt, type ResourceServerMetadata, type SchemaClient, type Scope, type StoreTokenType, type TokenEndpointAuthMethod, type VerificationValue, authServerMetadata, getOAuthProviderState, mcpHandler, oauthProvider, oauthProviderAuthServerMetadata, oauthProviderOpenIdConfigMetadata, oidcServerMetadata };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as storeToken, a as getJwtPlugin, c as isPKCERequired, d as parsePrompt, f as removePromptFromQuery, g as storeClientSecret, h as searchParamsToQuery, i as getClient, l as normalizeTimestampValue, m as resolveSubjectIdentifier, n as clientAllowsGrant, p as resolveSessionAuthTime, r as decryptStoredClientSecret, s as getStoredToken, t as basicToClientCredentials, u as parseClientMetadata, v as validateClientCredentials, x as mcpHandler, y as verifyOAuthQueryParams } from "./utils-
|
|
2
|
-
import { a as postLoginClearedParam, i as getSignedQueryIssuedAt, o as setSignedOAuthQueryParameterNames, r as canonicalizeOAuthQueryParams, s as signedQueryIssuedAtParam, t as PACKAGE_VERSION } from "./version-
|
|
1
|
+
import { _ as storeToken, a as getJwtPlugin, c as isPKCERequired, d as parsePrompt, f as removePromptFromQuery, g as storeClientSecret, h as searchParamsToQuery, i as getClient, l as normalizeTimestampValue, m as resolveSubjectIdentifier, n as clientAllowsGrant, p as resolveSessionAuthTime, r as decryptStoredClientSecret, s as getStoredToken, t as basicToClientCredentials, u as parseClientMetadata, v as validateClientCredentials, x as mcpHandler, y as verifyOAuthQueryParams } from "./utils-C7lKElJN.mjs";
|
|
2
|
+
import { a as postLoginClearedParam, i as getSignedQueryIssuedAt, o as setSignedOAuthQueryParameterNames, r as canonicalizeOAuthQueryParams, s as signedQueryIssuedAtParam, t as PACKAGE_VERSION } from "./version-rl1vdpzB.mjs";
|
|
3
3
|
import { APIError, createAuthEndpoint, createAuthMiddleware, dispatchAuthEndpoint, getOAuthState, getSessionFromCtx, sessionMiddleware } from "better-auth/api";
|
|
4
4
|
import { generateCodeChallenge, getJwks, verifyJwsAccessToken } from "better-auth/oauth2";
|
|
5
5
|
import { APIError as APIError$1 } from "better-call";
|
|
@@ -708,7 +708,7 @@ async function handleClientCredentialsGrant(ctx, opts) {
|
|
|
708
708
|
let requestedScopes = scope?.split(" ");
|
|
709
709
|
if (requestedScopes) {
|
|
710
710
|
const validScopes = new Set(client.scopes ?? opts.scopes);
|
|
711
|
-
const oidcScopes = new Set([
|
|
711
|
+
const oidcScopes = /* @__PURE__ */ new Set([
|
|
712
712
|
"openid",
|
|
713
713
|
"profile",
|
|
714
714
|
"email",
|
|
@@ -1680,6 +1680,7 @@ const adminCreateOAuthClient = (opts) => createAuthEndpoint("/admin/oauth2/creat
|
|
|
1680
1680
|
responses: { "200": {
|
|
1681
1681
|
description: "OAuth2 application registered successfully",
|
|
1682
1682
|
content: { "application/json": { schema: {
|
|
1683
|
+
/** @returns {OauthClient} */
|
|
1683
1684
|
type: "object",
|
|
1684
1685
|
properties: {
|
|
1685
1686
|
client_id: {
|
|
@@ -1855,6 +1856,7 @@ const createOAuthClient = (opts) => createAuthEndpoint("/oauth2/create-client",
|
|
|
1855
1856
|
responses: { "200": {
|
|
1856
1857
|
description: "OAuth2 application registered successfully",
|
|
1857
1858
|
content: { "application/json": { schema: {
|
|
1859
|
+
/** @returns {OauthClient} */
|
|
1858
1860
|
type: "object",
|
|
1859
1861
|
properties: {
|
|
1860
1862
|
client_id: {
|
|
@@ -2581,6 +2583,11 @@ const schema = {
|
|
|
2581
2583
|
}
|
|
2582
2584
|
}
|
|
2583
2585
|
},
|
|
2586
|
+
/**
|
|
2587
|
+
* An opaque refresh token created with "offline_access"
|
|
2588
|
+
*
|
|
2589
|
+
* Refresh tokens are linked to a session.
|
|
2590
|
+
*/
|
|
2584
2591
|
oauthRefreshToken: { fields: {
|
|
2585
2592
|
token: {
|
|
2586
2593
|
type: "string",
|
|
@@ -2634,6 +2641,18 @@ const schema = {
|
|
|
2634
2641
|
required: true
|
|
2635
2642
|
}
|
|
2636
2643
|
} },
|
|
2644
|
+
/**
|
|
2645
|
+
* An opaque access token sent when there is no audience
|
|
2646
|
+
* to assigned to the JWT.
|
|
2647
|
+
*
|
|
2648
|
+
* Access tokens are linked to a session, better-auth
|
|
2649
|
+
* authors SHALL always check for valid session!
|
|
2650
|
+
*
|
|
2651
|
+
* AccessTokens SHALL only be created at refresh,
|
|
2652
|
+
* destroyed at revoke, and read at introspection.
|
|
2653
|
+
* NEVER update an access token! Typically a refresh and
|
|
2654
|
+
* revoke (if not expired) may want to occur at the same time.
|
|
2655
|
+
*/
|
|
2637
2656
|
oauthAccessToken: {
|
|
2638
2657
|
modelName: "oauthAccessToken",
|
|
2639
2658
|
fields: {
|
|
@@ -2738,7 +2757,7 @@ const getOAuthProviderState = oAuthState.get;
|
|
|
2738
2757
|
const oauthProvider = (options) => {
|
|
2739
2758
|
let clientRegistrationAllowedScopes = options.clientRegistrationAllowedScopes;
|
|
2740
2759
|
if (options.clientRegistrationDefaultScopes) {
|
|
2741
|
-
const _allowedScopes = clientRegistrationAllowedScopes ? new Set([...clientRegistrationAllowedScopes, ...options.clientRegistrationDefaultScopes]) : new Set([...options.clientRegistrationDefaultScopes]);
|
|
2760
|
+
const _allowedScopes = clientRegistrationAllowedScopes ? /* @__PURE__ */ new Set([...clientRegistrationAllowedScopes, ...options.clientRegistrationDefaultScopes]) : /* @__PURE__ */ new Set([...options.clientRegistrationDefaultScopes]);
|
|
2742
2761
|
clientRegistrationAllowedScopes = Array.from(_allowedScopes);
|
|
2743
2762
|
}
|
|
2744
2763
|
const scopes = new Set((options.scopes ?? [
|
|
@@ -2751,7 +2770,7 @@ const oauthProvider = (options) => {
|
|
|
2751
2770
|
for (const sc of clientRegistrationAllowedScopes) if (!scopes.has(sc)) throw new BetterAuthError(`clientRegistrationAllowedScope ${sc} not found in scopes`);
|
|
2752
2771
|
}
|
|
2753
2772
|
for (const sc of options.advertisedMetadata?.scopes_supported ?? []) if (!scopes?.has(sc)) throw new BetterAuthError(`advertisedMetadata.scopes_supported ${sc} not found in scopes`);
|
|
2754
|
-
const claims = new Set([
|
|
2773
|
+
const claims = /* @__PURE__ */ new Set([
|
|
2755
2774
|
"sub",
|
|
2756
2775
|
"iss",
|
|
2757
2776
|
"aud",
|
|
@@ -2803,7 +2822,7 @@ const oauthProvider = (options) => {
|
|
|
2803
2822
|
issuerPath = new URL(ctx.baseURL).pathname.replace(/\/$/, "") || "";
|
|
2804
2823
|
}
|
|
2805
2824
|
const endpointCtx = { context: ctx };
|
|
2806
|
-
const authServerMetadataPaths = new Set([`/.well-known/oauth-authorization-server${issuerPath}`, `${issuerPath}/.well-known/oauth-authorization-server`]);
|
|
2825
|
+
const authServerMetadataPaths = /* @__PURE__ */ new Set([`/.well-known/oauth-authorization-server${issuerPath}`, `${issuerPath}/.well-known/oauth-authorization-server`]);
|
|
2807
2826
|
const openIdConfigPath = `${issuerPath}/.well-known/openid-configuration`;
|
|
2808
2827
|
const isAuthServerMetadataRequest = authServerMetadataPaths.has(requestPath);
|
|
2809
2828
|
const isOpenIdConfigRequest = opts.scopes?.includes("openid") && requestPath === openIdConfigPath;
|
|
@@ -2958,7 +2977,8 @@ const oauthProvider = (options) => {
|
|
|
2958
2977
|
}
|
|
2959
2978
|
} }
|
|
2960
2979
|
}, async (ctx) => {
|
|
2961
|
-
|
|
2980
|
+
const settings = ctx.authorizeSettings ?? { isAuthorize: true };
|
|
2981
|
+
return authorizeEndpoint(ctx, opts, settings);
|
|
2962
2982
|
});
|
|
2963
2983
|
const runOAuth2Authorize = (ctx, settings) => dispatchAuthEndpoint(oauth2AuthorizeEndpoint, {
|
|
2964
2984
|
...ctx,
|
|
@@ -3038,6 +3058,13 @@ const oauthProvider = (options) => {
|
|
|
3038
3058
|
}]
|
|
3039
3059
|
},
|
|
3040
3060
|
endpoints: {
|
|
3061
|
+
/**
|
|
3062
|
+
* A server-only endpoint that helps provide the
|
|
3063
|
+
* oAuth Server configuration at the well-known endpoint.
|
|
3064
|
+
*
|
|
3065
|
+
* Provided at /.well-known/oauth-authorization-server/[issuer-path]
|
|
3066
|
+
* (root if no issuer-path).
|
|
3067
|
+
*/
|
|
3041
3068
|
getOAuthServerConfig: createAuthEndpoint("/.well-known/oauth-authorization-server", {
|
|
3042
3069
|
method: "GET",
|
|
3043
3070
|
metadata: { SERVER_ONLY: true }
|
|
@@ -3051,6 +3078,13 @@ const oauthProvider = (options) => {
|
|
|
3051
3078
|
jwt_disabled: opts.disableJwtPlugin
|
|
3052
3079
|
});
|
|
3053
3080
|
}),
|
|
3081
|
+
/**
|
|
3082
|
+
* A server-only endpoint that helps provide the
|
|
3083
|
+
* OpenId configuration at the well-known endpoint.
|
|
3084
|
+
*
|
|
3085
|
+
* Provided at [issuer-path]/.well-known/openid-configuration
|
|
3086
|
+
* (root if no issuer-path).
|
|
3087
|
+
*/
|
|
3054
3088
|
getOpenIdConfig: createAuthEndpoint("/.well-known/openid-configuration", {
|
|
3055
3089
|
method: "GET",
|
|
3056
3090
|
metadata: { SERVER_ONLY: true }
|
|
@@ -3582,6 +3616,7 @@ const oauthProvider = (options) => {
|
|
|
3582
3616
|
responses: { "200": {
|
|
3583
3617
|
description: "OAuth2 application registered successfully",
|
|
3584
3618
|
content: { "application/json": { schema: {
|
|
3619
|
+
/** @returns {OauthClient} */
|
|
3585
3620
|
type: "object",
|
|
3586
3621
|
properties: {
|
|
3587
3622
|
client_id: {
|
|
@@ -2,7 +2,6 @@ import { JWSAlgorithms } from "better-auth/plugins";
|
|
|
2
2
|
import { JWTPayload } from "jose";
|
|
3
3
|
import { InferOptionSchema, Session, User } from "better-auth/types";
|
|
4
4
|
import { GenericEndpointContext, LiteralString } from "@better-auth/core";
|
|
5
|
-
|
|
6
5
|
//#region src/schema.d.ts
|
|
7
6
|
declare const schema: {
|
|
8
7
|
oauthClient: {
|
|
@@ -398,7 +397,7 @@ interface OAuthOptions<Scopes extends readonly Scope[] = InternallySupportedScop
|
|
|
398
397
|
* @example
|
|
399
398
|
* { "write:payments": "5m", "read:payments": "30m" }
|
|
400
399
|
*/
|
|
401
|
-
scopeExpirations?: { [K in Scopes[number]]?: number | string | Date };
|
|
400
|
+
scopeExpirations?: { [K in Scopes[number]]?: number | string | Date; };
|
|
402
401
|
/**
|
|
403
402
|
* Allows /oauth2/public-client-prelogin endpoint to be
|
|
404
403
|
* requestable prior to login via a valid oauth_query.
|
|
@@ -722,10 +721,12 @@ interface OAuthOptions<Scopes extends readonly Scope[] = InternallySupportedScop
|
|
|
722
721
|
* @returns Additional claims for userinfo request
|
|
723
722
|
*/
|
|
724
723
|
customUserInfoClaims?: (info: {
|
|
725
|
-
/** The user object */
|
|
724
|
+
/** The user object */
|
|
725
|
+
user: User & Record<string, unknown>;
|
|
726
726
|
/** The scopes from the access token used
|
|
727
727
|
* in the /userinfo request (matches jwt.scopes) */
|
|
728
|
-
scopes: Scopes;
|
|
728
|
+
scopes: Scopes;
|
|
729
|
+
/** The access token payload used in the /userinfo request */
|
|
729
730
|
jwt: JWTPayload;
|
|
730
731
|
}) => Awaitable<Record<string, any>>;
|
|
731
732
|
/**
|
|
@@ -739,8 +740,11 @@ interface OAuthOptions<Scopes extends readonly Scope[] = InternallySupportedScop
|
|
|
739
740
|
* @param info - context that may be useful when creating custom claims
|
|
740
741
|
*/
|
|
741
742
|
customIdTokenClaims?: (info: {
|
|
742
|
-
/** The user object if token is associated to a user. */
|
|
743
|
-
|
|
743
|
+
/** The user object if token is associated to a user. */
|
|
744
|
+
user: User & Record<string, unknown>;
|
|
745
|
+
/** Scopes granted for this token */
|
|
746
|
+
scopes: Scopes;
|
|
747
|
+
/** oAuthClient metadata */
|
|
744
748
|
metadata?: Record<string, any>;
|
|
745
749
|
}) => Awaitable<Record<string, any>>;
|
|
746
750
|
/**
|
|
@@ -757,10 +761,15 @@ interface OAuthOptions<Scopes extends readonly Scope[] = InternallySupportedScop
|
|
|
757
761
|
* @param info - context that may be useful when creating custom claims
|
|
758
762
|
*/
|
|
759
763
|
customAccessTokenClaims?: (info: {
|
|
760
|
-
/** The user object if token is associated to a user. Null if user doesn't exist. Undefined if user not applicable. */
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
+
/** The user object if token is associated to a user. Null if user doesn't exist. Undefined if user not applicable. */
|
|
765
|
+
user?: (User & Record<string, unknown>) | null;
|
|
766
|
+
/** reference of the consent/authorization */
|
|
767
|
+
referenceId?: string;
|
|
768
|
+
/** Scopes granted for this token */
|
|
769
|
+
scopes: Scopes;
|
|
770
|
+
/** The resource requesting. Provided by the token endpoint. */
|
|
771
|
+
resource?: string;
|
|
772
|
+
/** oAuthClient metadata */
|
|
764
773
|
metadata?: Record<string, any>;
|
|
765
774
|
}) => Awaitable<Record<string, any>>;
|
|
766
775
|
/**
|
|
@@ -775,14 +784,17 @@ interface OAuthOptions<Scopes extends readonly Scope[] = InternallySupportedScop
|
|
|
775
784
|
* @param info - context that may be useful when creating custom fields
|
|
776
785
|
*/
|
|
777
786
|
customTokenResponseFields?: (info: {
|
|
778
|
-
/** The grant type being processed */
|
|
787
|
+
/** The grant type being processed */
|
|
788
|
+
grantType: GrantType;
|
|
779
789
|
/**
|
|
780
790
|
* The user, if applicable.
|
|
781
791
|
* Undefined for `client_credentials` (M2M, no user).
|
|
782
792
|
* Always present for `authorization_code` and `refresh_token`.
|
|
783
793
|
*/
|
|
784
|
-
user?: (User & Record<string, unknown>) | null;
|
|
785
|
-
|
|
794
|
+
user?: (User & Record<string, unknown>) | null;
|
|
795
|
+
/** Scopes granted for this token */
|
|
796
|
+
scopes: Scopes;
|
|
797
|
+
/** oAuthClient metadata */
|
|
786
798
|
metadata?: Record<string, any>;
|
|
787
799
|
/**
|
|
788
800
|
* The authorization code verification value.
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import { _ as Scope, a as OAuthClient, d as OAuthConsent, n as AuthServerMetadata, o as OIDCMetadata, p as OAuthOptions } from "./oauth-
|
|
2
|
-
import * as better_call0 from "better-call";
|
|
1
|
+
import { _ as Scope, a as OAuthClient, d as OAuthConsent, n as AuthServerMetadata, o as OIDCMetadata, p as OAuthOptions } from "./oauth-BFBataE_.mjs";
|
|
3
2
|
import * as z from "zod";
|
|
4
|
-
import * as better_auth_plugins0 from "better-auth/plugins";
|
|
5
|
-
import * as jose from "jose";
|
|
6
|
-
import * as better_auth0 from "better-auth";
|
|
7
|
-
|
|
8
3
|
//#region src/oauth.d.ts
|
|
9
4
|
declare module "@better-auth/core" {
|
|
10
5
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
@@ -29,20 +24,20 @@ declare const oauthProvider: <O extends OAuthOptions<Scope[]>>(options: O) => {
|
|
|
29
24
|
id: "oauth-provider";
|
|
30
25
|
version: string;
|
|
31
26
|
options: NoInfer<O>;
|
|
32
|
-
init: (ctx:
|
|
33
|
-
onRequest: (request: Request, ctx:
|
|
27
|
+
init: (ctx: import("better-auth").AuthContext) => void;
|
|
28
|
+
onRequest: (request: Request, ctx: import("better-auth").AuthContext) => Promise<{
|
|
34
29
|
response: Response;
|
|
35
30
|
} | {
|
|
36
31
|
request: Request;
|
|
37
32
|
} | void>;
|
|
38
33
|
hooks: {
|
|
39
34
|
before: {
|
|
40
|
-
matcher(ctx:
|
|
41
|
-
handler: (inputContext:
|
|
35
|
+
matcher(ctx: import("better-auth").HookEndpointContext): any;
|
|
36
|
+
handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>;
|
|
42
37
|
}[];
|
|
43
38
|
after: {
|
|
44
|
-
matcher(ctx:
|
|
45
|
-
handler: (inputContext:
|
|
39
|
+
matcher(ctx: import("better-auth").HookEndpointContext): boolean;
|
|
40
|
+
handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
46
41
|
redirect: boolean;
|
|
47
42
|
url: string;
|
|
48
43
|
} | undefined>;
|
|
@@ -56,7 +51,7 @@ declare const oauthProvider: <O extends OAuthOptions<Scope[]>>(options: O) => {
|
|
|
56
51
|
* Provided at /.well-known/oauth-authorization-server/[issuer-path]
|
|
57
52
|
* (root if no issuer-path).
|
|
58
53
|
*/
|
|
59
|
-
getOAuthServerConfig:
|
|
54
|
+
getOAuthServerConfig: import("better-call").StrictEndpoint<"/.well-known/oauth-authorization-server", {
|
|
60
55
|
method: "GET";
|
|
61
56
|
metadata: {
|
|
62
57
|
SERVER_ONLY: true;
|
|
@@ -69,15 +64,15 @@ declare const oauthProvider: <O extends OAuthOptions<Scope[]>>(options: O) => {
|
|
|
69
64
|
* Provided at [issuer-path]/.well-known/openid-configuration
|
|
70
65
|
* (root if no issuer-path).
|
|
71
66
|
*/
|
|
72
|
-
getOpenIdConfig:
|
|
67
|
+
getOpenIdConfig: import("better-call").StrictEndpoint<"/.well-known/openid-configuration", {
|
|
73
68
|
method: "GET";
|
|
74
69
|
metadata: {
|
|
75
70
|
SERVER_ONLY: true;
|
|
76
71
|
};
|
|
77
72
|
}, Omit<OIDCMetadata, "id_token_signing_alg_values_supported"> & {
|
|
78
|
-
id_token_signing_alg_values_supported:
|
|
73
|
+
id_token_signing_alg_values_supported: import("better-auth/plugins").JWSAlgorithms[] | ["HS256"];
|
|
79
74
|
}>;
|
|
80
|
-
oauth2Authorize:
|
|
75
|
+
oauth2Authorize: import("better-call").StrictEndpoint<"/oauth2/authorize", {
|
|
81
76
|
method: "GET";
|
|
82
77
|
query: z.ZodObject<{
|
|
83
78
|
response_type: z.ZodOptional<z.ZodEnum<{
|
|
@@ -176,14 +171,14 @@ declare const oauthProvider: <O extends OAuthOptions<Scope[]>>(options: O) => {
|
|
|
176
171
|
redirect: boolean;
|
|
177
172
|
url: string;
|
|
178
173
|
}>;
|
|
179
|
-
oauth2Consent:
|
|
174
|
+
oauth2Consent: import("better-call").StrictEndpoint<"/oauth2/consent", {
|
|
180
175
|
method: "POST";
|
|
181
176
|
body: z.ZodObject<{
|
|
182
177
|
accept: z.ZodBoolean;
|
|
183
178
|
scope: z.ZodOptional<z.ZodString>;
|
|
184
179
|
oauth_query: z.ZodOptional<z.ZodString>;
|
|
185
180
|
}, z.core.$strip>;
|
|
186
|
-
use: ((inputContext:
|
|
181
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
187
182
|
session: {
|
|
188
183
|
session: Record<string, any> & {
|
|
189
184
|
id: string;
|
|
@@ -238,7 +233,7 @@ declare const oauthProvider: <O extends OAuthOptions<Scope[]>>(options: O) => {
|
|
|
238
233
|
redirect: boolean;
|
|
239
234
|
url: string;
|
|
240
235
|
}>;
|
|
241
|
-
oauth2Continue:
|
|
236
|
+
oauth2Continue: import("better-call").StrictEndpoint<"/oauth2/continue", {
|
|
242
237
|
method: "POST";
|
|
243
238
|
body: z.ZodObject<{
|
|
244
239
|
selected: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -246,7 +241,7 @@ declare const oauthProvider: <O extends OAuthOptions<Scope[]>>(options: O) => {
|
|
|
246
241
|
postLogin: z.ZodOptional<z.ZodBoolean>;
|
|
247
242
|
oauth_query: z.ZodOptional<z.ZodString>;
|
|
248
243
|
}, z.core.$strip>;
|
|
249
|
-
use: ((inputContext:
|
|
244
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
250
245
|
session: {
|
|
251
246
|
session: Record<string, any> & {
|
|
252
247
|
id: string;
|
|
@@ -298,7 +293,7 @@ declare const oauthProvider: <O extends OAuthOptions<Scope[]>>(options: O) => {
|
|
|
298
293
|
redirect: boolean;
|
|
299
294
|
url: string;
|
|
300
295
|
}>;
|
|
301
|
-
oauth2Token:
|
|
296
|
+
oauth2Token: import("better-call").StrictEndpoint<"/oauth2/token", {
|
|
302
297
|
method: "POST";
|
|
303
298
|
body: z.ZodObject<{
|
|
304
299
|
grant_type: z.ZodEnum<{
|
|
@@ -443,7 +438,7 @@ declare const oauthProvider: <O extends OAuthOptions<Scope[]>>(options: O) => {
|
|
|
443
438
|
scope: string;
|
|
444
439
|
id_token: string | undefined;
|
|
445
440
|
}>;
|
|
446
|
-
oauth2Introspect:
|
|
441
|
+
oauth2Introspect: import("better-call").StrictEndpoint<"/oauth2/introspect", {
|
|
447
442
|
method: "POST";
|
|
448
443
|
body: z.ZodObject<{
|
|
449
444
|
client_id: z.ZodOptional<z.ZodString>;
|
|
@@ -579,8 +574,8 @@ declare const oauthProvider: <O extends OAuthOptions<Scope[]>>(options: O) => {
|
|
|
579
574
|
};
|
|
580
575
|
};
|
|
581
576
|
};
|
|
582
|
-
}, jose.JWTPayload>;
|
|
583
|
-
oauth2Revoke:
|
|
577
|
+
}, import("jose").JWTPayload>;
|
|
578
|
+
oauth2Revoke: import("better-call").StrictEndpoint<"/oauth2/revoke", {
|
|
584
579
|
method: "POST";
|
|
585
580
|
body: z.ZodObject<{
|
|
586
581
|
client_id: z.ZodOptional<z.ZodString>;
|
|
@@ -663,7 +658,7 @@ declare const oauthProvider: <O extends OAuthOptions<Scope[]>>(options: O) => {
|
|
|
663
658
|
};
|
|
664
659
|
};
|
|
665
660
|
}, null | undefined>;
|
|
666
|
-
oauth2UserInfo:
|
|
661
|
+
oauth2UserInfo: import("better-call").StrictEndpoint<"/oauth2/userinfo", {
|
|
667
662
|
method: ("GET" | "POST")[];
|
|
668
663
|
metadata: {
|
|
669
664
|
openapi: {
|
|
@@ -784,7 +779,7 @@ declare const oauthProvider: <O extends OAuthOptions<Scope[]>>(options: O) => {
|
|
|
784
779
|
family_name?: string | undefined;
|
|
785
780
|
sub: string;
|
|
786
781
|
}>;
|
|
787
|
-
oauth2EndSession:
|
|
782
|
+
oauth2EndSession: import("better-call").StrictEndpoint<"/oauth2/end-session", {
|
|
788
783
|
method: "GET";
|
|
789
784
|
query: z.ZodObject<{
|
|
790
785
|
id_token_hint: z.ZodString;
|
|
@@ -824,7 +819,7 @@ declare const oauthProvider: <O extends OAuthOptions<Scope[]>>(options: O) => {
|
|
|
824
819
|
redirect: boolean;
|
|
825
820
|
url: string;
|
|
826
821
|
} | undefined>;
|
|
827
|
-
registerOAuthClient:
|
|
822
|
+
registerOAuthClient: import("better-call").StrictEndpoint<"/oauth2/register", {
|
|
828
823
|
method: "POST";
|
|
829
824
|
body: z.ZodObject<{
|
|
830
825
|
redirect_uris: z.ZodArray<z.ZodURL>;
|
|
@@ -872,7 +867,8 @@ declare const oauthProvider: <O extends OAuthOptions<Scope[]>>(options: O) => {
|
|
|
872
867
|
content: {
|
|
873
868
|
"application/json": {
|
|
874
869
|
schema: {
|
|
875
|
-
/** @returns {OauthClient} */
|
|
870
|
+
/** @returns {OauthClient} */
|
|
871
|
+
type: "object";
|
|
876
872
|
properties: {
|
|
877
873
|
client_id: {
|
|
878
874
|
type: string;
|
|
@@ -997,7 +993,7 @@ declare const oauthProvider: <O extends OAuthOptions<Scope[]>>(options: O) => {
|
|
|
997
993
|
};
|
|
998
994
|
};
|
|
999
995
|
}, OAuthClient>;
|
|
1000
|
-
adminCreateOAuthClient:
|
|
996
|
+
adminCreateOAuthClient: import("better-call").StrictEndpoint<"/admin/oauth2/create-client", {
|
|
1001
997
|
method: "POST";
|
|
1002
998
|
body: z.ZodObject<{
|
|
1003
999
|
redirect_uris: z.ZodArray<z.ZodURL>;
|
|
@@ -1178,9 +1174,9 @@ declare const oauthProvider: <O extends OAuthOptions<Scope[]>>(options: O) => {
|
|
|
1178
1174
|
};
|
|
1179
1175
|
};
|
|
1180
1176
|
}, OAuthClient>;
|
|
1181
|
-
createOAuthClient:
|
|
1177
|
+
createOAuthClient: import("better-call").StrictEndpoint<"/oauth2/create-client", {
|
|
1182
1178
|
method: "POST";
|
|
1183
|
-
use: ((inputContext:
|
|
1179
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
1184
1180
|
session: {
|
|
1185
1181
|
session: Record<string, any> & {
|
|
1186
1182
|
id: string;
|
|
@@ -1367,9 +1363,9 @@ declare const oauthProvider: <O extends OAuthOptions<Scope[]>>(options: O) => {
|
|
|
1367
1363
|
};
|
|
1368
1364
|
};
|
|
1369
1365
|
}, OAuthClient>;
|
|
1370
|
-
getOAuthClient:
|
|
1366
|
+
getOAuthClient: import("better-call").StrictEndpoint<"/oauth2/get-client", {
|
|
1371
1367
|
method: "GET";
|
|
1372
|
-
use: ((inputContext:
|
|
1368
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
1373
1369
|
session: {
|
|
1374
1370
|
session: Record<string, any> & {
|
|
1375
1371
|
id: string;
|
|
@@ -1401,9 +1397,9 @@ declare const oauthProvider: <O extends OAuthOptions<Scope[]>>(options: O) => {
|
|
|
1401
1397
|
};
|
|
1402
1398
|
};
|
|
1403
1399
|
}, OAuthClient>;
|
|
1404
|
-
getOAuthClientPublic:
|
|
1400
|
+
getOAuthClientPublic: import("better-call").StrictEndpoint<"/oauth2/public-client", {
|
|
1405
1401
|
method: "GET";
|
|
1406
|
-
use: ((inputContext:
|
|
1402
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
1407
1403
|
session: {
|
|
1408
1404
|
session: Record<string, any> & {
|
|
1409
1405
|
id: string;
|
|
@@ -1435,9 +1431,9 @@ declare const oauthProvider: <O extends OAuthOptions<Scope[]>>(options: O) => {
|
|
|
1435
1431
|
};
|
|
1436
1432
|
};
|
|
1437
1433
|
}, OAuthClient>;
|
|
1438
|
-
getOAuthClientPublicPrelogin:
|
|
1434
|
+
getOAuthClientPublicPrelogin: import("better-call").StrictEndpoint<"/oauth2/public-client-prelogin", {
|
|
1439
1435
|
method: "POST";
|
|
1440
|
-
use: ((inputContext:
|
|
1436
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>)[];
|
|
1441
1437
|
body: z.ZodObject<{
|
|
1442
1438
|
client_id: z.ZodString;
|
|
1443
1439
|
oauth_query: z.ZodOptional<z.ZodString>;
|
|
@@ -1448,9 +1444,9 @@ declare const oauthProvider: <O extends OAuthOptions<Scope[]>>(options: O) => {
|
|
|
1448
1444
|
};
|
|
1449
1445
|
};
|
|
1450
1446
|
}, OAuthClient>;
|
|
1451
|
-
getOAuthClients:
|
|
1447
|
+
getOAuthClients: import("better-call").StrictEndpoint<"/oauth2/get-clients", {
|
|
1452
1448
|
method: "GET";
|
|
1453
|
-
use: ((inputContext:
|
|
1449
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
1454
1450
|
session: {
|
|
1455
1451
|
session: Record<string, any> & {
|
|
1456
1452
|
id: string;
|
|
@@ -1479,7 +1475,7 @@ declare const oauthProvider: <O extends OAuthOptions<Scope[]>>(options: O) => {
|
|
|
1479
1475
|
};
|
|
1480
1476
|
};
|
|
1481
1477
|
}, OAuthClient[] | null>;
|
|
1482
|
-
adminUpdateOAuthClient:
|
|
1478
|
+
adminUpdateOAuthClient: import("better-call").StrictEndpoint<"/admin/oauth2/update-client", {
|
|
1483
1479
|
method: "PATCH";
|
|
1484
1480
|
body: z.ZodObject<{
|
|
1485
1481
|
client_id: z.ZodString;
|
|
@@ -1522,9 +1518,9 @@ declare const oauthProvider: <O extends OAuthOptions<Scope[]>>(options: O) => {
|
|
|
1522
1518
|
};
|
|
1523
1519
|
};
|
|
1524
1520
|
}, OAuthClient>;
|
|
1525
|
-
updateOAuthClient:
|
|
1521
|
+
updateOAuthClient: import("better-call").StrictEndpoint<"/oauth2/update-client", {
|
|
1526
1522
|
method: "POST";
|
|
1527
|
-
use: ((inputContext:
|
|
1523
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
1528
1524
|
session: {
|
|
1529
1525
|
session: Record<string, any> & {
|
|
1530
1526
|
id: string;
|
|
@@ -1583,9 +1579,9 @@ declare const oauthProvider: <O extends OAuthOptions<Scope[]>>(options: O) => {
|
|
|
1583
1579
|
};
|
|
1584
1580
|
};
|
|
1585
1581
|
}, OAuthClient>;
|
|
1586
|
-
rotateClientSecret:
|
|
1582
|
+
rotateClientSecret: import("better-call").StrictEndpoint<"/oauth2/client/rotate-secret", {
|
|
1587
1583
|
method: "POST";
|
|
1588
|
-
use: ((inputContext:
|
|
1584
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
1589
1585
|
session: {
|
|
1590
1586
|
session: Record<string, any> & {
|
|
1591
1587
|
id: string;
|
|
@@ -1617,9 +1613,9 @@ declare const oauthProvider: <O extends OAuthOptions<Scope[]>>(options: O) => {
|
|
|
1617
1613
|
};
|
|
1618
1614
|
};
|
|
1619
1615
|
}, OAuthClient>;
|
|
1620
|
-
deleteOAuthClient:
|
|
1616
|
+
deleteOAuthClient: import("better-call").StrictEndpoint<"/oauth2/delete-client", {
|
|
1621
1617
|
method: "POST";
|
|
1622
|
-
use: ((inputContext:
|
|
1618
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
1623
1619
|
session: {
|
|
1624
1620
|
session: Record<string, any> & {
|
|
1625
1621
|
id: string;
|
|
@@ -1651,12 +1647,12 @@ declare const oauthProvider: <O extends OAuthOptions<Scope[]>>(options: O) => {
|
|
|
1651
1647
|
};
|
|
1652
1648
|
};
|
|
1653
1649
|
}, void>;
|
|
1654
|
-
getOAuthConsent:
|
|
1650
|
+
getOAuthConsent: import("better-call").StrictEndpoint<"/oauth2/get-consent", {
|
|
1655
1651
|
method: "GET";
|
|
1656
1652
|
query: z.ZodObject<{
|
|
1657
1653
|
id: z.ZodString;
|
|
1658
1654
|
}, z.core.$strip>;
|
|
1659
|
-
use: ((inputContext:
|
|
1655
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
1660
1656
|
session: {
|
|
1661
1657
|
session: Record<string, any> & {
|
|
1662
1658
|
id: string;
|
|
@@ -1685,9 +1681,9 @@ declare const oauthProvider: <O extends OAuthOptions<Scope[]>>(options: O) => {
|
|
|
1685
1681
|
};
|
|
1686
1682
|
};
|
|
1687
1683
|
}, OAuthConsent<Scope[]>>;
|
|
1688
|
-
getOAuthConsents:
|
|
1684
|
+
getOAuthConsents: import("better-call").StrictEndpoint<"/oauth2/get-consents", {
|
|
1689
1685
|
method: "GET";
|
|
1690
|
-
use: ((inputContext:
|
|
1686
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
1691
1687
|
session: {
|
|
1692
1688
|
session: Record<string, any> & {
|
|
1693
1689
|
id: string;
|
|
@@ -1716,9 +1712,9 @@ declare const oauthProvider: <O extends OAuthOptions<Scope[]>>(options: O) => {
|
|
|
1716
1712
|
};
|
|
1717
1713
|
};
|
|
1718
1714
|
}, OAuthConsent<Scope[]>[]>;
|
|
1719
|
-
updateOAuthConsent:
|
|
1715
|
+
updateOAuthConsent: import("better-call").StrictEndpoint<"/oauth2/update-consent", {
|
|
1720
1716
|
method: "POST";
|
|
1721
|
-
use: ((inputContext:
|
|
1717
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
1722
1718
|
session: {
|
|
1723
1719
|
session: Record<string, any> & {
|
|
1724
1720
|
id: string;
|
|
@@ -1753,9 +1749,9 @@ declare const oauthProvider: <O extends OAuthOptions<Scope[]>>(options: O) => {
|
|
|
1753
1749
|
};
|
|
1754
1750
|
};
|
|
1755
1751
|
}, OAuthConsent<Scope[]> | null>;
|
|
1756
|
-
deleteOAuthConsent:
|
|
1752
|
+
deleteOAuthConsent: import("better-call").StrictEndpoint<"/oauth2/delete-consent", {
|
|
1757
1753
|
method: "POST";
|
|
1758
|
-
use: ((inputContext:
|
|
1754
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
1759
1755
|
session: {
|
|
1760
1756
|
session: Record<string, any> & {
|
|
1761
1757
|
id: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as canonicalizeOAuthQueryParams } from "./version-
|
|
1
|
+
import { r as canonicalizeOAuthQueryParams } from "./version-rl1vdpzB.mjs";
|
|
2
2
|
import { isAPIError } from "better-auth/api";
|
|
3
3
|
import { verifyAccessToken } from "better-auth/oauth2";
|
|
4
4
|
import { APIError as APIError$1 } from "better-call";
|
|
@@ -402,12 +402,6 @@ function removePromptFromQuery(query, prompt) {
|
|
|
402
402
|
}
|
|
403
403
|
return nextQuery;
|
|
404
404
|
}
|
|
405
|
-
var PKCERequirementErrors = /* @__PURE__ */ function(PKCERequirementErrors) {
|
|
406
|
-
PKCERequirementErrors["PUBLIC_CLIENT"] = "pkce is required for public clients";
|
|
407
|
-
PKCERequirementErrors["OFFLINE_ACCESS_SCOPE"] = "pkce is required when requesting offline_access scope";
|
|
408
|
-
PKCERequirementErrors["CLIENT_REQUIRE_PKCE"] = "pkce is required for this client";
|
|
409
|
-
return PKCERequirementErrors;
|
|
410
|
-
}(PKCERequirementErrors || {});
|
|
411
405
|
/**
|
|
412
406
|
* Determines if PKCE is required for a given client and scope.
|
|
413
407
|
*
|
|
@@ -423,9 +417,9 @@ var PKCERequirementErrors = /* @__PURE__ */ function(PKCERequirementErrors) {
|
|
|
423
417
|
* @internal
|
|
424
418
|
*/
|
|
425
419
|
function isPKCERequired(client, requestedScopes) {
|
|
426
|
-
if (client.tokenEndpointAuthMethod === "none" || client.type === "native" || client.type === "user-agent-based" || client.public === true) return
|
|
427
|
-
if (requestedScopes?.includes("offline_access")) return
|
|
428
|
-
if (client.requirePKCE ?? true) return
|
|
420
|
+
if (client.tokenEndpointAuthMethod === "none" || client.type === "native" || client.type === "user-agent-based" || client.public === true) return "pkce is required for public clients";
|
|
421
|
+
if (requestedScopes?.includes("offline_access")) return "pkce is required when requesting offline_access scope";
|
|
422
|
+
if (client.requirePKCE ?? true) return "pkce is required for this client";
|
|
429
423
|
return false;
|
|
430
424
|
}
|
|
431
425
|
//#endregion
|
|
@@ -16,7 +16,7 @@ function canonicalizeOAuthQueryParams(params) {
|
|
|
16
16
|
}
|
|
17
17
|
function setSignedOAuthQueryParameterNames(params) {
|
|
18
18
|
params.delete(signedQueryParameterNameParam);
|
|
19
|
-
const signedParameterNames = [
|
|
19
|
+
const signedParameterNames = [.../* @__PURE__ */ new Set([...params.keys(), signedQueryParameterNameParam])].sort();
|
|
20
20
|
for (const parameterName of signedParameterNames) params.append(signedQueryParameterNameParam, parameterName);
|
|
21
21
|
}
|
|
22
22
|
function getSignedOAuthQueryParameterNames(params) {
|
|
@@ -42,6 +42,6 @@ function getSignedQueryIssuedAt(oauthQuery) {
|
|
|
42
42
|
}
|
|
43
43
|
//#endregion
|
|
44
44
|
//#region src/version.ts
|
|
45
|
-
const PACKAGE_VERSION = "1.6.
|
|
45
|
+
const PACKAGE_VERSION = "1.6.24";
|
|
46
46
|
//#endregion
|
|
47
47
|
export { postLoginClearedParam as a, getSignedQueryIssuedAt as i, buildSignedOAuthQuery as n, setSignedOAuthQueryParameterNames as o, canonicalizeOAuthQueryParams as r, signedQueryIssuedAtParam as s, PACKAGE_VERSION as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/oauth-provider",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.24",
|
|
4
4
|
"description": "An oauth provider plugin for Better Auth",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -63,16 +63,16 @@
|
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
65
65
|
"listhen": "^1.9.0",
|
|
66
|
-
"tsdown": "0.
|
|
67
|
-
"@better-auth/core": "1.6.
|
|
68
|
-
"better-auth": "1.6.
|
|
66
|
+
"tsdown": "0.22.7",
|
|
67
|
+
"@better-auth/core": "1.6.24",
|
|
68
|
+
"better-auth": "1.6.24"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
71
|
"@better-auth/utils": "0.4.2",
|
|
72
72
|
"@better-fetch/fetch": "1.3.1",
|
|
73
73
|
"better-call": "1.3.7",
|
|
74
|
-
"@better-auth/core": "^1.6.
|
|
75
|
-
"better-auth": "^1.6.
|
|
74
|
+
"@better-auth/core": "^1.6.24",
|
|
75
|
+
"better-auth": "^1.6.24"
|
|
76
76
|
},
|
|
77
77
|
"scripts": {
|
|
78
78
|
"build": "tsdown",
|