better-auth 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/adapters/index.d.mts +1 -6
- package/dist/api/dispatch.d.mts +0 -1
- package/dist/api/index.d.mts +476 -478
- package/dist/api/middlewares/authorization.d.mts +12 -8
- package/dist/api/middlewares/authorization.mjs +2 -1
- package/dist/api/middlewares/index.d.mts +2 -1
- package/dist/api/middlewares/origin-check.d.mts +3 -5
- package/dist/api/routes/account.d.mts +10 -13
- package/dist/api/routes/account.mjs +35 -7
- package/dist/api/routes/callback.d.mts +1 -3
- package/dist/api/routes/callback.mjs +4 -0
- package/dist/api/routes/email-verification.d.mts +4 -8
- package/dist/api/routes/email-verification.mjs +15 -2
- package/dist/api/routes/error.d.mts +1 -3
- package/dist/api/routes/index.d.mts +2 -1
- package/dist/api/routes/ok.d.mts +1 -3
- package/dist/api/routes/password.d.mts +7 -9
- package/dist/api/routes/password.mjs +14 -1
- package/dist/api/routes/session.d.mts +22 -24
- package/dist/api/routes/session.mjs +5 -1
- package/dist/api/routes/sign-in.d.mts +3 -5
- package/dist/api/routes/sign-in.mjs +84 -2
- package/dist/api/routes/sign-out.d.mts +1 -3
- package/dist/api/routes/sign-up.d.mts +3 -4
- package/dist/api/routes/sign-up.mjs +3 -2
- package/dist/api/routes/update-session.d.mts +3 -4
- package/dist/api/routes/update-user.d.mts +13 -14
- package/dist/api/routes/update-user.mjs +26 -1
- package/dist/auth/full.d.mts +1 -1
- package/dist/auth/minimal.d.mts +1 -1
- package/dist/client/config.d.mts +12 -14
- package/dist/client/config.mjs +2 -2
- package/dist/client/equality.d.mts +0 -1
- package/dist/client/index.d.mts +6 -5
- package/dist/client/lynx/index.d.mts +4 -5
- package/dist/client/lynx/lynx-store.d.mts +1 -2
- package/dist/client/parser.d.mts +7 -3
- package/dist/client/path-to-object.d.mts +3 -4
- package/dist/client/plugins/index.d.mts +2 -1
- package/dist/client/plugins/infer-plugin.d.mts +0 -1
- package/dist/client/query.d.mts +0 -1
- package/dist/client/query.mjs +38 -20
- package/dist/client/react/index.d.mts +4 -5
- package/dist/client/react/react-store.d.mts +1 -2
- package/dist/client/session-refresh.d.mts +0 -1
- package/dist/client/solid/index.d.mts +5 -6
- package/dist/client/svelte/index.d.mts +5 -6
- package/dist/client/types.d.mts +2 -2
- package/dist/client/vanilla.d.mts +2 -3
- package/dist/client/vue/index.d.mts +5 -6
- package/dist/context/create-context.mjs +3 -3
- package/dist/context/helpers.mjs +2 -2
- package/dist/cookies/cookie-utils.d.mts +1 -1
- package/dist/cookies/index.d.mts +6 -7
- package/dist/cookies/index.mjs +4 -0
- package/dist/cookies/session-store.d.mts +1 -0
- package/dist/cookies/session-store.mjs +6 -1
- package/dist/crypto/index.d.mts +2 -9
- package/dist/crypto/jwt.d.mts +0 -1
- package/dist/crypto/password.d.mts +1 -5
- package/dist/db/adapter-base.d.mts +0 -1
- package/dist/db/adapter-kysely.d.mts +0 -1
- package/dist/db/field-converter.d.mts +0 -1
- package/dist/db/field.d.mts +9 -10
- package/dist/db/get-migration.d.mts +0 -1
- package/dist/db/get-migration.mjs +8 -4
- package/dist/db/get-schema.d.mts +0 -1
- package/dist/db/internal-adapter.d.mts +0 -1
- package/dist/db/internal-adapter.mjs +61 -1
- package/dist/db/revoke-unproven-account-access.d.mts +0 -1
- package/dist/db/schema.d.mts +2 -2
- package/dist/db/to-zod.d.mts +3 -7
- package/dist/db/with-hooks.d.mts +0 -1
- package/dist/index.d.mts +4 -3
- package/dist/integrations/next-js.d.mts +4 -7
- package/dist/integrations/node.d.mts +2 -3
- package/dist/integrations/svelte-kit.d.mts +2 -9
- package/dist/integrations/tanstack-start-solid.d.mts +2 -5
- package/dist/integrations/tanstack-start.d.mts +2 -5
- package/dist/oauth2/link-account.d.mts +1 -1
- package/dist/oauth2/state.d.mts +0 -1
- package/dist/oauth2/utils.d.mts +0 -1
- package/dist/package.mjs +1 -1
- package/dist/plugins/access/access.d.mts +0 -1
- package/dist/plugins/access/types.d.mts +4 -5
- package/dist/plugins/additional-fields/client.d.mts +0 -1
- package/dist/plugins/admin/access/statement.d.mts +1 -0
- package/dist/plugins/admin/admin.d.mts +120 -125
- package/dist/plugins/admin/client.d.mts +30 -30
- package/dist/plugins/admin/client.mjs +1 -1
- package/dist/plugins/admin/error-codes.d.mts +23 -25
- package/dist/plugins/admin/index.d.mts +1 -1
- package/dist/plugins/admin/routes.mjs +9 -0
- package/dist/plugins/admin/schema.d.mts +1 -1
- package/dist/plugins/admin/types.d.mts +3 -2
- package/dist/plugins/anonymous/client.d.mts +9 -11
- package/dist/plugins/anonymous/client.mjs +1 -1
- package/dist/plugins/anonymous/error-codes.d.mts +8 -10
- package/dist/plugins/anonymous/index.d.mts +14 -18
- package/dist/plugins/anonymous/types.d.mts +1 -1
- package/dist/plugins/bearer/index.d.mts +4 -7
- package/dist/plugins/captcha/index.d.mts +5 -8
- package/dist/plugins/captcha/types.d.mts +0 -1
- package/dist/plugins/custom-session/client.d.mts +0 -1
- package/dist/plugins/custom-session/index.d.mts +7 -12
- package/dist/plugins/device-authorization/client.d.mts +0 -1
- package/dist/plugins/device-authorization/index.d.mts +19 -22
- package/dist/plugins/email-otp/client.d.mts +4 -6
- package/dist/plugins/email-otp/client.mjs +1 -1
- package/dist/plugins/email-otp/error-codes.d.mts +3 -5
- package/dist/plugins/email-otp/index.d.mts +67 -73
- package/dist/plugins/email-otp/routes.mjs +2 -0
- package/dist/plugins/email-otp/types.d.mts +0 -1
- package/dist/plugins/generic-oauth/client.d.mts +11 -11
- package/dist/plugins/generic-oauth/client.mjs +1 -1
- package/dist/plugins/generic-oauth/error-codes.d.mts +8 -10
- package/dist/plugins/generic-oauth/index.d.mts +41 -44
- package/dist/plugins/generic-oauth/index.mjs +2 -1
- package/dist/plugins/generic-oauth/providers/auth0.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/gumroad.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/hubspot.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/index.d.mts +3 -1
- package/dist/plugins/generic-oauth/providers/keycloak.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/line.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/microsoft-entra-id.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/okta.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/patreon.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/slack.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/yandex.d.mts +28 -0
- package/dist/plugins/generic-oauth/providers/yandex.mjs +60 -0
- package/dist/plugins/generic-oauth/routes.mjs +14 -0
- package/dist/plugins/generic-oauth/types.d.mts +1 -2
- package/dist/plugins/haveibeenpwned/index.d.mts +3 -6
- package/dist/plugins/index.d.mts +5 -1
- package/dist/plugins/index.mjs +2 -1
- package/dist/plugins/jwt/client.d.mts +2 -4
- package/dist/plugins/jwt/index.d.mts +8 -11
- package/dist/plugins/jwt/sign.d.mts +2 -2
- package/dist/plugins/jwt/types.d.mts +1 -1
- package/dist/plugins/jwt/utils.d.mts +2 -4
- package/dist/plugins/jwt/verify.d.mts +0 -1
- package/dist/plugins/last-login-method/client.mjs +13 -0
- package/dist/plugins/last-login-method/index.d.mts +11 -5
- package/dist/plugins/last-login-method/index.mjs +8 -0
- package/dist/plugins/magic-link/client.d.mts +0 -1
- package/dist/plugins/magic-link/index.d.mts +4 -5
- package/dist/plugins/magic-link/index.mjs +32 -1
- package/dist/plugins/mcp/authorize.mjs +12 -0
- package/dist/plugins/mcp/client/adapters.d.mts +0 -1
- package/dist/plugins/mcp/client/index.d.mts +2 -0
- package/dist/plugins/mcp/client/index.mjs +36 -11
- package/dist/plugins/mcp/index.d.mts +10 -11
- package/dist/plugins/multi-session/client.d.mts +2 -4
- package/dist/plugins/multi-session/client.mjs +1 -1
- package/dist/plugins/multi-session/error-codes.d.mts +1 -3
- package/dist/plugins/multi-session/index.d.mts +7 -11
- package/dist/plugins/multi-session/index.mjs +45 -0
- package/dist/plugins/oauth-popup/client.d.mts +6 -12
- package/dist/plugins/oauth-popup/client.mjs +5 -3
- package/dist/plugins/oauth-popup/error-codes.d.mts +4 -6
- package/dist/plugins/oauth-popup/index.d.mts +8 -12
- package/dist/plugins/oauth-popup/index.mjs +1 -1
- package/dist/plugins/oauth-popup/types.d.mts +1 -2
- package/dist/plugins/oauth-proxy/index.d.mts +6 -9
- package/dist/plugins/oauth-proxy/index.mjs +2 -2
- package/dist/plugins/oidc-provider/authorize.mjs +9 -0
- package/dist/plugins/oidc-provider/client.d.mts +1 -2
- package/dist/plugins/oidc-provider/index.d.mts +15 -17
- package/dist/plugins/oidc-provider/index.mjs +26 -2
- package/dist/plugins/oidc-provider/schema.d.mts +0 -1
- package/dist/plugins/oidc-provider/schema.mjs +37 -0
- package/dist/plugins/oidc-provider/types.d.mts +1 -1
- package/dist/plugins/one-tap/client.d.mts +3 -6
- package/dist/plugins/one-tap/client.mjs +3 -0
- package/dist/plugins/one-tap/index.d.mts +1 -3
- package/dist/plugins/one-tap/index.mjs +5 -0
- package/dist/plugins/one-time-token/client.d.mts +1 -2
- package/dist/plugins/one-time-token/index.d.mts +5 -6
- package/dist/plugins/one-time-token/index.mjs +30 -0
- package/dist/plugins/open-api/generator.d.mts +0 -1
- package/dist/plugins/open-api/generator.mjs +81 -5
- package/dist/plugins/open-api/index.d.mts +3 -5
- package/dist/plugins/organization/access/statement.d.mts +1 -0
- package/dist/plugins/organization/adapter.d.mts +56 -82
- package/dist/plugins/organization/adapter.mjs +17 -3
- package/dist/plugins/organization/client.d.mts +106 -105
- package/dist/plugins/organization/client.mjs +7 -4
- package/dist/plugins/organization/error-codes.d.mts +59 -61
- package/dist/plugins/organization/has-permission.d.mts +0 -1
- package/dist/plugins/organization/has-permission.mjs +1 -1
- package/dist/plugins/organization/index.d.mts +1 -1
- package/dist/plugins/organization/organization.d.mts +7 -7
- package/dist/plugins/organization/organization.mjs +434 -1
- package/dist/plugins/organization/permission.d.mts +2 -2
- package/dist/plugins/organization/routes/crud-access-control.d.mts +17 -17
- package/dist/plugins/organization/routes/crud-invites.d.mts +53 -54
- package/dist/plugins/organization/routes/crud-invites.mjs +1 -1
- package/dist/plugins/organization/routes/crud-members.d.mts +44 -46
- package/dist/plugins/organization/routes/crud-members.mjs +4 -1
- package/dist/plugins/organization/routes/crud-org.d.mts +47 -48
- package/dist/plugins/organization/routes/crud-org.mjs +2 -2
- package/dist/plugins/organization/routes/crud-team.d.mts +50 -51
- package/dist/plugins/organization/schema.d.mts +4 -4
- package/dist/plugins/organization/schema.mjs +1 -1
- package/dist/plugins/organization/types.d.mts +16 -16
- package/dist/plugins/phone-number/client.d.mts +13 -15
- package/dist/plugins/phone-number/client.mjs +1 -1
- package/dist/plugins/phone-number/error-codes.d.mts +12 -14
- package/dist/plugins/phone-number/index.d.mts +41 -47
- package/dist/plugins/phone-number/routes.mjs +15 -0
- package/dist/plugins/phone-number/types.d.mts +1 -1
- package/dist/plugins/siwe/client.d.mts +0 -1
- package/dist/plugins/siwe/index.d.mts +4 -5
- package/dist/plugins/test-utils/index.d.mts +2 -4
- package/dist/plugins/test-utils/types.d.mts +1 -0
- package/dist/plugins/two-factor/backup-codes/index.d.mts +4 -6
- package/dist/plugins/two-factor/backup-codes/index.mjs +52 -1
- package/dist/plugins/two-factor/client.d.mts +12 -15
- package/dist/plugins/two-factor/client.mjs +1 -1
- package/dist/plugins/two-factor/error-code.d.mts +10 -12
- package/dist/plugins/two-factor/index.d.mts +27 -31
- package/dist/plugins/two-factor/index.mjs +30 -0
- package/dist/plugins/two-factor/otp/index.d.mts +2 -4
- package/dist/plugins/two-factor/otp/index.mjs +42 -1
- package/dist/plugins/two-factor/totp/index.d.mts +4 -6
- package/dist/plugins/two-factor/totp/index.mjs +47 -0
- package/dist/plugins/two-factor/types.d.mts +1 -1
- package/dist/plugins/username/client.d.mts +9 -11
- package/dist/plugins/username/client.mjs +1 -1
- package/dist/plugins/username/error-codes.d.mts +8 -10
- package/dist/plugins/username/index.d.mts +17 -22
- package/dist/plugins/username/schema.d.mts +3 -5
- package/dist/state.d.mts +0 -1
- package/dist/state.mjs +4 -0
- package/dist/test-utils/test-instance.d.mts +5 -3
- package/dist/test-utils/test-instance.mjs +4 -1
- package/dist/types/adapter.d.mts +1 -1
- package/dist/types/api.d.mts +1 -2
- package/dist/types/auth.d.mts +0 -1
- package/dist/types/helper.d.mts +5 -5
- package/dist/types/index.d.mts +2 -2
- package/dist/types/models.d.mts +0 -1
- package/dist/types/plugins.d.mts +2 -3
- package/dist/utils/index.d.mts +2 -1
- package/dist/utils/request.mjs +23 -0
- package/dist/utils/url.d.mts +0 -1
- package/package.json +10 -10
|
@@ -17,7 +17,19 @@ function buildCorsHeaders(authURL, allowedOrigin) {
|
|
|
17
17
|
function makeWWWAuthenticate(authURL, resource) {
|
|
18
18
|
return `Bearer resource_metadata="${resource ? `${resource}/.well-known/oauth-protected-resource` : `${authURL}/.well-known/oauth-protected-resource`}"`;
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function addExposeHeader(headers, headerName) {
|
|
21
|
+
const exposedHeaders = headers["Access-Control-Expose-Headers"];
|
|
22
|
+
if (!exposedHeaders) return {
|
|
23
|
+
...headers,
|
|
24
|
+
"Access-Control-Expose-Headers": headerName
|
|
25
|
+
};
|
|
26
|
+
const alreadyExposed = exposedHeaders.split(",").some((header) => header.trim().toLowerCase() === headerName.toLowerCase());
|
|
27
|
+
return {
|
|
28
|
+
...headers,
|
|
29
|
+
"Access-Control-Expose-Headers": alreadyExposed ? exposedHeaders : `${exposedHeaders}, ${headerName}`
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function make401Response(authURL, resource, corsHeaders) {
|
|
21
33
|
const wwwAuth = makeWWWAuthenticate(authURL, resource);
|
|
22
34
|
return Response.json({
|
|
23
35
|
jsonrpc: "2.0",
|
|
@@ -29,10 +41,13 @@ function make401Response(authURL, resource) {
|
|
|
29
41
|
id: null
|
|
30
42
|
}, {
|
|
31
43
|
status: 401,
|
|
32
|
-
headers: {
|
|
44
|
+
headers: {
|
|
45
|
+
...addExposeHeader(corsHeaders, "WWW-Authenticate"),
|
|
46
|
+
"WWW-Authenticate": wwwAuth
|
|
47
|
+
}
|
|
33
48
|
});
|
|
34
49
|
}
|
|
35
|
-
function send401Node(res, wwwAuth, message) {
|
|
50
|
+
function send401Node(res, wwwAuth, message, corsHeaders) {
|
|
36
51
|
const body = JSON.stringify({
|
|
37
52
|
jsonrpc: "2.0",
|
|
38
53
|
error: {
|
|
@@ -41,13 +56,21 @@ function send401Node(res, wwwAuth, message) {
|
|
|
41
56
|
},
|
|
42
57
|
id: null
|
|
43
58
|
});
|
|
59
|
+
const existingExposedHeaders = res.get?.("Access-Control-Expose-Headers") ?? res.getHeader?.("Access-Control-Expose-Headers") ?? res.getHeader?.("access-control-expose-headers");
|
|
60
|
+
const headers = {
|
|
61
|
+
...addExposeHeader({
|
|
62
|
+
...corsHeaders,
|
|
63
|
+
...existingExposedHeaders ? { "Access-Control-Expose-Headers": Array.isArray(existingExposedHeaders) ? existingExposedHeaders.join(", ") : String(existingExposedHeaders) } : {}
|
|
64
|
+
}, "WWW-Authenticate"),
|
|
65
|
+
"WWW-Authenticate": wwwAuth
|
|
66
|
+
};
|
|
44
67
|
if (typeof res.set === "function") {
|
|
45
|
-
res.set(
|
|
68
|
+
for (const [name, value] of Object.entries(headers)) res.set(name, value);
|
|
46
69
|
res.status?.(401).json(JSON.parse(body));
|
|
47
70
|
} else if (typeof res.writeHead === "function") {
|
|
48
71
|
res.writeHead(401, {
|
|
49
72
|
"Content-Type": "application/json",
|
|
50
|
-
|
|
73
|
+
...headers
|
|
51
74
|
});
|
|
52
75
|
res.end?.(body);
|
|
53
76
|
}
|
|
@@ -78,9 +101,10 @@ function createMcpAuthClient(options) {
|
|
|
78
101
|
headers: corsHeaders
|
|
79
102
|
});
|
|
80
103
|
const authHeader = req.headers.get("Authorization");
|
|
81
|
-
if (!authHeader || !authHeader.startsWith("Bearer ")) return make401Response(authURL, options.resource);
|
|
82
|
-
const
|
|
83
|
-
|
|
104
|
+
if (!authHeader || !authHeader.startsWith("Bearer ")) return make401Response(authURL, options.resource, corsHeaders);
|
|
105
|
+
const token = authHeader.slice(7);
|
|
106
|
+
const session = await verifyToken(token);
|
|
107
|
+
if (!session) return make401Response(authURL, options.resource, corsHeaders);
|
|
84
108
|
return fn(req, session);
|
|
85
109
|
};
|
|
86
110
|
};
|
|
@@ -128,12 +152,13 @@ function createMcpAuthClient(options) {
|
|
|
128
152
|
return async (req, res, next) => {
|
|
129
153
|
const authHeader = req.headers?.authorization ?? req.headers?.get?.("Authorization") ?? req.get?.("Authorization");
|
|
130
154
|
if (!authHeader || !authHeader.startsWith("Bearer ")) {
|
|
131
|
-
send401Node(res, makeWWWAuthenticate(authURL, options.resource), "Unauthorized: Authentication required");
|
|
155
|
+
send401Node(res, makeWWWAuthenticate(authURL, options.resource), "Unauthorized: Authentication required", corsHeaders);
|
|
132
156
|
return;
|
|
133
157
|
}
|
|
134
|
-
const
|
|
158
|
+
const token = authHeader.slice(7);
|
|
159
|
+
const session = await verifyToken(token);
|
|
135
160
|
if (!session) {
|
|
136
|
-
send401Node(res, makeWWWAuthenticate(authURL, options.resource), "Invalid or expired token");
|
|
161
|
+
send401Node(res, makeWWWAuthenticate(authURL, options.resource), "Invalid or expired token", corsHeaders);
|
|
137
162
|
return;
|
|
138
163
|
}
|
|
139
164
|
req.mcpSession = session;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { OAuthAccessToken, OIDCMetadata, OIDCOptions } from "../oidc-provider/types.mjs";
|
|
2
|
+
import "../oidc-provider/index.mjs";
|
|
2
3
|
import { BetterAuthOptions, GenericEndpointContext } from "@better-auth/core";
|
|
3
|
-
import * as better_call0 from "better-call";
|
|
4
4
|
import * as z from "zod";
|
|
5
|
-
|
|
6
5
|
//#region src/plugins/mcp/index.d.ts
|
|
7
6
|
declare module "@better-auth/core" {
|
|
8
7
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
@@ -31,18 +30,18 @@ declare const mcp: (options: MCPOptions) => {
|
|
|
31
30
|
hooks: {
|
|
32
31
|
after: {
|
|
33
32
|
matcher(): true;
|
|
34
|
-
handler: (inputContext:
|
|
33
|
+
handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>;
|
|
35
34
|
}[];
|
|
36
35
|
};
|
|
37
36
|
endpoints: {
|
|
38
|
-
oAuthConsent:
|
|
37
|
+
oAuthConsent: import("better-call").StrictEndpoint<"/oauth2/consent", {
|
|
39
38
|
method: "POST";
|
|
40
39
|
operationId: string;
|
|
41
40
|
body: z.ZodObject<{
|
|
42
41
|
accept: z.ZodBoolean;
|
|
43
42
|
consent_code: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
44
43
|
}, z.core.$strip>;
|
|
45
|
-
use: ((inputContext:
|
|
44
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
46
45
|
session: {
|
|
47
46
|
session: Record<string, any> & {
|
|
48
47
|
id: string;
|
|
@@ -114,13 +113,13 @@ declare const mcp: (options: MCPOptions) => {
|
|
|
114
113
|
}, {
|
|
115
114
|
redirectURI: string;
|
|
116
115
|
}>;
|
|
117
|
-
getMcpOAuthConfig:
|
|
116
|
+
getMcpOAuthConfig: import("better-call").StrictEndpoint<"/.well-known/oauth-authorization-server", {
|
|
118
117
|
method: "GET";
|
|
119
118
|
metadata: {
|
|
120
119
|
readonly scope: "server";
|
|
121
120
|
};
|
|
122
121
|
}, OIDCMetadata | null>;
|
|
123
|
-
getMCPProtectedResource:
|
|
122
|
+
getMCPProtectedResource: import("better-call").StrictEndpoint<"/.well-known/oauth-protected-resource", {
|
|
124
123
|
method: "GET";
|
|
125
124
|
metadata: {
|
|
126
125
|
readonly scope: "server";
|
|
@@ -133,7 +132,7 @@ declare const mcp: (options: MCPOptions) => {
|
|
|
133
132
|
bearer_methods_supported: string[];
|
|
134
133
|
resource_signing_alg_values_supported: string[];
|
|
135
134
|
}>;
|
|
136
|
-
mcpOAuthAuthorize:
|
|
135
|
+
mcpOAuthAuthorize: import("better-call").StrictEndpoint<"/mcp/authorize", {
|
|
137
136
|
method: "GET";
|
|
138
137
|
query: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
139
138
|
metadata: {
|
|
@@ -156,7 +155,7 @@ declare const mcp: (options: MCPOptions) => {
|
|
|
156
155
|
};
|
|
157
156
|
};
|
|
158
157
|
}, void>;
|
|
159
|
-
mcpOAuthToken:
|
|
158
|
+
mcpOAuthToken: import("better-call").StrictEndpoint<"/mcp/token", {
|
|
160
159
|
method: "POST";
|
|
161
160
|
body: z.ZodRecord<z.ZodAny, z.ZodAny>;
|
|
162
161
|
metadata: {
|
|
@@ -177,7 +176,7 @@ declare const mcp: (options: MCPOptions) => {
|
|
|
177
176
|
scope: string;
|
|
178
177
|
id_token: string | undefined;
|
|
179
178
|
}>;
|
|
180
|
-
registerMcpClient:
|
|
179
|
+
registerMcpClient: import("better-call").StrictEndpoint<"/mcp/register", {
|
|
181
180
|
method: "POST";
|
|
182
181
|
body: z.ZodObject<{
|
|
183
182
|
redirect_uris: z.ZodArray<z.ZodString>;
|
|
@@ -295,7 +294,7 @@ declare const mcp: (options: MCPOptions) => {
|
|
|
295
294
|
};
|
|
296
295
|
};
|
|
297
296
|
}, Response>;
|
|
298
|
-
getMcpSession:
|
|
297
|
+
getMcpSession: import("better-call").StrictEndpoint<"/mcp/get-session", {
|
|
299
298
|
method: "GET";
|
|
300
299
|
requireHeaders: true;
|
|
301
300
|
}, OAuthAccessToken | null>;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { MULTI_SESSION_ERROR_CODES } from "./error-codes.mjs";
|
|
2
2
|
import { MultiSessionConfig, multiSession } from "./index.mjs";
|
|
3
|
-
import * as _better_auth_core_utils_error_codes0 from "@better-auth/core/utils/error-codes";
|
|
4
|
-
|
|
5
3
|
//#region src/plugins/multi-session/client.d.ts
|
|
6
4
|
declare const multiSessionClient: () => {
|
|
7
5
|
id: "multi-session";
|
|
@@ -12,8 +10,8 @@ declare const multiSessionClient: () => {
|
|
|
12
10
|
signal: "$sessionSignal";
|
|
13
11
|
}[];
|
|
14
12
|
$ERROR_CODES: {
|
|
15
|
-
INVALID_SESSION_TOKEN:
|
|
13
|
+
INVALID_SESSION_TOKEN: import("@better-auth/core/utils/error-codes").RawError<"INVALID_SESSION_TOKEN">;
|
|
16
14
|
};
|
|
17
15
|
};
|
|
18
16
|
//#endregion
|
|
19
|
-
export { multiSessionClient };
|
|
17
|
+
export { MULTI_SESSION_ERROR_CODES, type MultiSessionConfig, multiSessionClient };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import * as _better_auth_core_utils_error_codes0 from "@better-auth/core/utils/error-codes";
|
|
2
|
-
|
|
3
1
|
//#region src/plugins/multi-session/error-codes.d.ts
|
|
4
2
|
declare const MULTI_SESSION_ERROR_CODES: {
|
|
5
|
-
INVALID_SESSION_TOKEN:
|
|
3
|
+
INVALID_SESSION_TOKEN: import("@better-auth/core/utils/error-codes").RawError<"INVALID_SESSION_TOKEN">;
|
|
6
4
|
};
|
|
7
5
|
//#endregion
|
|
8
6
|
export { MULTI_SESSION_ERROR_CODES };
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { MULTI_SESSION_ERROR_CODES } from "./error-codes.mjs";
|
|
2
|
-
import * as _better_auth_core0 from "@better-auth/core";
|
|
3
|
-
import * as _better_auth_core_utils_error_codes0 from "@better-auth/core/utils/error-codes";
|
|
4
|
-
import * as better_call0 from "better-call";
|
|
5
2
|
import * as z from "zod";
|
|
6
|
-
|
|
7
3
|
//#region src/plugins/multi-session/index.d.ts
|
|
8
4
|
declare module "@better-auth/core" {
|
|
9
5
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
@@ -39,7 +35,7 @@ declare const multiSession: (options?: MultiSessionConfig | undefined) => {
|
|
|
39
35
|
*
|
|
40
36
|
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/multi-session#api-method-multi-session-list-device-sessions)
|
|
41
37
|
*/
|
|
42
|
-
listDeviceSessions:
|
|
38
|
+
listDeviceSessions: import("better-call").StrictEndpoint<"/multi-session/list-device-sessions", {
|
|
43
39
|
method: "GET";
|
|
44
40
|
requireHeaders: true;
|
|
45
41
|
}, {
|
|
@@ -78,7 +74,7 @@ declare const multiSession: (options?: MultiSessionConfig | undefined) => {
|
|
|
78
74
|
*
|
|
79
75
|
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/multi-session#api-method-multi-session-set-active)
|
|
80
76
|
*/
|
|
81
|
-
setActiveSession:
|
|
77
|
+
setActiveSession: import("better-call").StrictEndpoint<"/multi-session/set-active", {
|
|
82
78
|
method: "POST";
|
|
83
79
|
body: z.ZodObject<{
|
|
84
80
|
sessionToken: z.ZodString;
|
|
@@ -142,13 +138,13 @@ declare const multiSession: (options?: MultiSessionConfig | undefined) => {
|
|
|
142
138
|
*
|
|
143
139
|
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/multi-session#api-method-multi-session-revoke)
|
|
144
140
|
*/
|
|
145
|
-
revokeDeviceSession:
|
|
141
|
+
revokeDeviceSession: import("better-call").StrictEndpoint<"/multi-session/revoke", {
|
|
146
142
|
method: "POST";
|
|
147
143
|
body: z.ZodObject<{
|
|
148
144
|
sessionToken: z.ZodString;
|
|
149
145
|
}, z.core.$strip>;
|
|
150
146
|
requireHeaders: true;
|
|
151
|
-
use: ((inputContext:
|
|
147
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
152
148
|
session: {
|
|
153
149
|
session: Record<string, any> & {
|
|
154
150
|
id: string;
|
|
@@ -199,13 +195,13 @@ declare const multiSession: (options?: MultiSessionConfig | undefined) => {
|
|
|
199
195
|
};
|
|
200
196
|
hooks: {
|
|
201
197
|
after: {
|
|
202
|
-
matcher: (context:
|
|
203
|
-
handler: (inputContext:
|
|
198
|
+
matcher: (context: import("@better-auth/core").HookEndpointContext) => boolean;
|
|
199
|
+
handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>;
|
|
204
200
|
}[];
|
|
205
201
|
};
|
|
206
202
|
options: MultiSessionConfig | undefined;
|
|
207
203
|
$ERROR_CODES: {
|
|
208
|
-
INVALID_SESSION_TOKEN:
|
|
204
|
+
INVALID_SESSION_TOKEN: import("@better-auth/core/utils/error-codes").RawError<"INVALID_SESSION_TOKEN">;
|
|
209
205
|
};
|
|
210
206
|
};
|
|
211
207
|
//#endregion
|
|
@@ -20,6 +20,21 @@ const multiSession = (options) => {
|
|
|
20
20
|
id: "multi-session",
|
|
21
21
|
version: PACKAGE_VERSION,
|
|
22
22
|
endpoints: {
|
|
23
|
+
/**
|
|
24
|
+
* ### Endpoint
|
|
25
|
+
*
|
|
26
|
+
* GET `/multi-session/list-device-sessions`
|
|
27
|
+
*
|
|
28
|
+
* ### API Methods
|
|
29
|
+
*
|
|
30
|
+
* **server:**
|
|
31
|
+
* `auth.api.listDeviceSessions`
|
|
32
|
+
*
|
|
33
|
+
* **client:**
|
|
34
|
+
* `authClient.multiSession.listDeviceSessions`
|
|
35
|
+
*
|
|
36
|
+
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/multi-session#api-method-multi-session-list-device-sessions)
|
|
37
|
+
*/
|
|
23
38
|
listDeviceSessions: createAuthEndpoint("/multi-session/list-device-sessions", {
|
|
24
39
|
method: "GET",
|
|
25
40
|
requireHeaders: true
|
|
@@ -38,6 +53,21 @@ const multiSession = (options) => {
|
|
|
38
53
|
user: parseUserOutput(ctx.context.options, item.user)
|
|
39
54
|
})));
|
|
40
55
|
}),
|
|
56
|
+
/**
|
|
57
|
+
* ### Endpoint
|
|
58
|
+
*
|
|
59
|
+
* POST `/multi-session/set-active`
|
|
60
|
+
*
|
|
61
|
+
* ### API Methods
|
|
62
|
+
*
|
|
63
|
+
* **server:**
|
|
64
|
+
* `auth.api.setActiveSession`
|
|
65
|
+
*
|
|
66
|
+
* **client:**
|
|
67
|
+
* `authClient.multiSession.setActive`
|
|
68
|
+
*
|
|
69
|
+
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/multi-session#api-method-multi-session-set-active)
|
|
70
|
+
*/
|
|
41
71
|
setActiveSession: createAuthEndpoint("/multi-session/set-active", {
|
|
42
72
|
method: "POST",
|
|
43
73
|
body: setActiveSessionBodySchema,
|
|
@@ -71,6 +101,21 @@ const multiSession = (options) => {
|
|
|
71
101
|
user: parseUserOutput(ctx.context.options, session.user)
|
|
72
102
|
});
|
|
73
103
|
}),
|
|
104
|
+
/**
|
|
105
|
+
* ### Endpoint
|
|
106
|
+
*
|
|
107
|
+
* POST `/multi-session/revoke`
|
|
108
|
+
*
|
|
109
|
+
* ### API Methods
|
|
110
|
+
*
|
|
111
|
+
* **server:**
|
|
112
|
+
* `auth.api.revokeDeviceSession`
|
|
113
|
+
*
|
|
114
|
+
* **client:**
|
|
115
|
+
* `authClient.multiSession.revoke`
|
|
116
|
+
*
|
|
117
|
+
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/multi-session#api-method-multi-session-revoke)
|
|
118
|
+
*/
|
|
74
119
|
revokeDeviceSession: createAuthEndpoint("/multi-session/revoke", {
|
|
75
120
|
method: "POST",
|
|
76
121
|
body: revokeDeviceSessionBodySchema,
|
|
@@ -2,9 +2,7 @@ import { POPUP_TOKEN_STORAGE_KEY } from "./constants.mjs";
|
|
|
2
2
|
import { OAUTH_POPUP_ERROR_CODES } from "./error-codes.mjs";
|
|
3
3
|
import { oauthPopup } from "./index.mjs";
|
|
4
4
|
import { BetterAuthClientOptions, ClientStore } from "@better-auth/core";
|
|
5
|
-
import * as _better_auth_core_utils_error_codes0 from "@better-auth/core/utils/error-codes";
|
|
6
5
|
import { BetterFetch, BetterFetchPlugin } from "@better-fetch/fetch";
|
|
7
|
-
|
|
8
6
|
//#region src/plugins/oauth-popup/client.d.ts
|
|
9
7
|
/** Inputs for `authClient.signIn.popup`; mirror the redirect sign-in. */
|
|
10
8
|
interface SignInPopupOptions {
|
|
@@ -52,11 +50,7 @@ interface SignInPopupDeps {
|
|
|
52
50
|
* page to post the session token back, stores it for the bearer fetch plugin,
|
|
53
51
|
* and refreshes the reactive session.
|
|
54
52
|
*/
|
|
55
|
-
declare function createSignInPopup({
|
|
56
|
-
$fetch,
|
|
57
|
-
options,
|
|
58
|
-
notifySessionSignal
|
|
59
|
-
}: SignInPopupDeps): (opts: SignInPopupOptions) => Promise<SignInPopupResult>;
|
|
53
|
+
declare function createSignInPopup({ $fetch, options, notifySessionSignal }: SignInPopupDeps): (opts: SignInPopupOptions) => Promise<SignInPopupResult>;
|
|
60
54
|
/**
|
|
61
55
|
* Client plugin for popup OAuth sign-in. Adds `authClient.signIn.popup`. Pair
|
|
62
56
|
* with the server `oauthPopup` and `bearer` plugins.
|
|
@@ -66,10 +60,10 @@ declare const oauthPopupClient: () => {
|
|
|
66
60
|
version: string;
|
|
67
61
|
$InferServerPlugin: ReturnType<typeof oauthPopup>;
|
|
68
62
|
$ERROR_CODES: {
|
|
69
|
-
POPUP_SIGN_IN_FAILED:
|
|
70
|
-
POPUP_BLOCKED:
|
|
71
|
-
POPUP_CLOSED:
|
|
72
|
-
POPUP_TIMEOUT:
|
|
63
|
+
POPUP_SIGN_IN_FAILED: import("@better-auth/core/utils/error-codes").RawError<"POPUP_SIGN_IN_FAILED">;
|
|
64
|
+
POPUP_BLOCKED: import("@better-auth/core/utils/error-codes").RawError<"POPUP_BLOCKED">;
|
|
65
|
+
POPUP_CLOSED: import("@better-auth/core/utils/error-codes").RawError<"POPUP_CLOSED">;
|
|
66
|
+
POPUP_TIMEOUT: import("@better-auth/core/utils/error-codes").RawError<"POPUP_TIMEOUT">;
|
|
73
67
|
};
|
|
74
68
|
fetchPlugins: BetterFetchPlugin[];
|
|
75
69
|
getActions: ($fetch: BetterFetch, $store: ClientStore, options: BetterAuthClientOptions | undefined) => {
|
|
@@ -79,4 +73,4 @@ declare const oauthPopupClient: () => {
|
|
|
79
73
|
};
|
|
80
74
|
};
|
|
81
75
|
//#endregion
|
|
82
|
-
export { SignInPopupOptions, SignInPopupResult, createSignInPopup, getStoredPopupToken, oauthPopupClient, popupBearerFetchPlugin };
|
|
76
|
+
export { OAUTH_POPUP_ERROR_CODES, POPUP_TOKEN_STORAGE_KEY, SignInPopupOptions, SignInPopupResult, createSignInPopup, getStoredPopupToken, oauthPopupClient, popupBearerFetchPlugin };
|
|
@@ -74,10 +74,12 @@ function popupError(code, status) {
|
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
76
|
function centeredFeatures() {
|
|
77
|
-
|
|
77
|
+
const left = window.screenX + (window.outerWidth - POPUP_WIDTH) / 2;
|
|
78
|
+
const top = window.screenY + (window.outerHeight - POPUP_HEIGHT) / 2;
|
|
79
|
+
return `width=${POPUP_WIDTH},height=${POPUP_HEIGHT},left=${left},top=${top},menubar=no,toolbar=no`;
|
|
78
80
|
}
|
|
79
81
|
function randomNonce() {
|
|
80
|
-
const bytes = new Uint8Array(16);
|
|
82
|
+
const bytes = /* @__PURE__ */ new Uint8Array(16);
|
|
81
83
|
crypto.getRandomValues(bytes);
|
|
82
84
|
return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
83
85
|
}
|
|
@@ -200,4 +202,4 @@ const oauthPopupClient = () => {
|
|
|
200
202
|
};
|
|
201
203
|
};
|
|
202
204
|
//#endregion
|
|
203
|
-
export { createSignInPopup, getStoredPopupToken, oauthPopupClient, popupBearerFetchPlugin };
|
|
205
|
+
export { OAUTH_POPUP_ERROR_CODES, POPUP_TOKEN_STORAGE_KEY, createSignInPopup, getStoredPopupToken, oauthPopupClient, popupBearerFetchPlugin };
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import * as _better_auth_core_utils_error_codes0 from "@better-auth/core/utils/error-codes";
|
|
2
|
-
|
|
3
1
|
//#region src/plugins/oauth-popup/error-codes.d.ts
|
|
4
2
|
declare const OAUTH_POPUP_ERROR_CODES: {
|
|
5
|
-
POPUP_SIGN_IN_FAILED:
|
|
6
|
-
POPUP_BLOCKED:
|
|
7
|
-
POPUP_CLOSED:
|
|
8
|
-
POPUP_TIMEOUT:
|
|
3
|
+
POPUP_SIGN_IN_FAILED: import("@better-auth/core/utils/error-codes").RawError<"POPUP_SIGN_IN_FAILED">;
|
|
4
|
+
POPUP_BLOCKED: import("@better-auth/core/utils/error-codes").RawError<"POPUP_BLOCKED">;
|
|
5
|
+
POPUP_CLOSED: import("@better-auth/core/utils/error-codes").RawError<"POPUP_CLOSED">;
|
|
6
|
+
POPUP_TIMEOUT: import("@better-auth/core/utils/error-codes").RawError<"POPUP_TIMEOUT">;
|
|
9
7
|
};
|
|
10
8
|
//#endregion
|
|
11
9
|
export { OAUTH_POPUP_ERROR_CODES };
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { OAUTH_POPUP_DATA_ELEMENT_ID, OAUTH_POPUP_MESSAGE_TYPE, POPUP_MARKER_COOKIE } from "./constants.mjs";
|
|
2
2
|
import { OAUTH_POPUP_ERROR_CODES } from "./error-codes.mjs";
|
|
3
3
|
import { OAuthPopupData, OAuthPopupMessage } from "./types.mjs";
|
|
4
|
-
import * as _better_auth_core0 from "@better-auth/core";
|
|
5
|
-
import * as _better_auth_core_utils_error_codes0 from "@better-auth/core/utils/error-codes";
|
|
6
|
-
import * as better_call0 from "better-call";
|
|
7
4
|
import * as z from "zod";
|
|
8
|
-
|
|
9
5
|
//#region src/plugins/oauth-popup/index.d.ts
|
|
10
6
|
declare module "@better-auth/core" {
|
|
11
7
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
@@ -32,13 +28,13 @@ declare const oauthPopup: () => {
|
|
|
32
28
|
id: "oauth-popup";
|
|
33
29
|
version: string;
|
|
34
30
|
$ERROR_CODES: {
|
|
35
|
-
POPUP_SIGN_IN_FAILED:
|
|
36
|
-
POPUP_BLOCKED:
|
|
37
|
-
POPUP_CLOSED:
|
|
38
|
-
POPUP_TIMEOUT:
|
|
31
|
+
POPUP_SIGN_IN_FAILED: import("@better-auth/core/utils/error-codes").RawError<"POPUP_SIGN_IN_FAILED">;
|
|
32
|
+
POPUP_BLOCKED: import("@better-auth/core/utils/error-codes").RawError<"POPUP_BLOCKED">;
|
|
33
|
+
POPUP_CLOSED: import("@better-auth/core/utils/error-codes").RawError<"POPUP_CLOSED">;
|
|
34
|
+
POPUP_TIMEOUT: import("@better-auth/core/utils/error-codes").RawError<"POPUP_TIMEOUT">;
|
|
39
35
|
};
|
|
40
36
|
endpoints: {
|
|
41
|
-
oauthPopupStart:
|
|
37
|
+
oauthPopupStart: import("better-call").StrictEndpoint<"/oauth-popup/start", {
|
|
42
38
|
method: "GET";
|
|
43
39
|
query: z.ZodObject<{
|
|
44
40
|
provider: z.ZodString;
|
|
@@ -58,10 +54,10 @@ declare const oauthPopup: () => {
|
|
|
58
54
|
};
|
|
59
55
|
hooks: {
|
|
60
56
|
after: {
|
|
61
|
-
matcher(context:
|
|
62
|
-
handler: (inputContext:
|
|
57
|
+
matcher(context: import("@better-auth/core").HookEndpointContext): boolean;
|
|
58
|
+
handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>;
|
|
63
59
|
}[];
|
|
64
60
|
};
|
|
65
61
|
};
|
|
66
62
|
//#endregion
|
|
67
|
-
export { OAUTH_POPUP_COMPLETE_SCRIPT, OAUTH_POPUP_SCRIPT_CSP_HASH, oauthPopup };
|
|
63
|
+
export { OAUTH_POPUP_COMPLETE_SCRIPT, OAUTH_POPUP_DATA_ELEMENT_ID, OAUTH_POPUP_ERROR_CODES, OAUTH_POPUP_MESSAGE_TYPE, OAUTH_POPUP_SCRIPT_CSP_HASH, type OAuthPopupData, type OAuthPopupMessage, POPUP_MARKER_COOKIE, oauthPopup };
|
|
@@ -225,4 +225,4 @@ const oauthPopup = () => {
|
|
|
225
225
|
};
|
|
226
226
|
};
|
|
227
227
|
//#endregion
|
|
228
|
-
export { OAUTH_POPUP_COMPLETE_SCRIPT, OAUTH_POPUP_SCRIPT_CSP_HASH, oauthPopup };
|
|
228
|
+
export { OAUTH_POPUP_COMPLETE_SCRIPT, OAUTH_POPUP_DATA_ELEMENT_ID, OAUTH_POPUP_ERROR_CODES, OAUTH_POPUP_MESSAGE_TYPE, OAUTH_POPUP_SCRIPT_CSP_HASH, POPUP_MARKER_COOKIE, oauthPopup };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { OAUTH_POPUP_MESSAGE_TYPE } from "./constants.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/plugins/oauth-popup/types.d.ts
|
|
4
3
|
/** OAuth error relayed to the opener when the flow fails. */
|
|
5
4
|
interface OAuthPopupError {
|
|
@@ -27,4 +26,4 @@ interface OAuthPopupData extends OAuthPopupMessage {
|
|
|
27
26
|
targetOrigin: string;
|
|
28
27
|
}
|
|
29
28
|
//#endregion
|
|
30
|
-
export { OAuthPopupData, OAuthPopupMessage };
|
|
29
|
+
export { OAuthPopupData, OAuthPopupError, OAuthPopupMessage };
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import * as _better_auth_core0 from "@better-auth/core";
|
|
2
1
|
import { SecretConfig } from "@better-auth/core";
|
|
3
|
-
import * as better_call0 from "better-call";
|
|
4
2
|
import * as z from "zod";
|
|
5
|
-
|
|
6
3
|
//#region src/plugins/oauth-proxy/index.d.ts
|
|
7
4
|
declare module "@better-auth/core" {
|
|
8
5
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
@@ -58,14 +55,14 @@ declare const oAuthProxy: <O extends OAuthProxyOptions>(opts?: O) => {
|
|
|
58
55
|
version: string;
|
|
59
56
|
options: NoInfer<O>;
|
|
60
57
|
endpoints: {
|
|
61
|
-
oAuthProxy:
|
|
58
|
+
oAuthProxy: import("better-call").StrictEndpoint<"/oauth-proxy-callback", {
|
|
62
59
|
method: "GET";
|
|
63
60
|
operationId: string;
|
|
64
61
|
query: z.ZodObject<{
|
|
65
62
|
callbackURL: z.ZodString;
|
|
66
63
|
profile: z.ZodOptional<z.ZodString>;
|
|
67
64
|
}, z.core.$strip>;
|
|
68
|
-
use: ((inputContext:
|
|
65
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>)[];
|
|
69
66
|
metadata: {
|
|
70
67
|
openapi: {
|
|
71
68
|
operationId: string;
|
|
@@ -100,12 +97,12 @@ declare const oAuthProxy: <O extends OAuthProxyOptions>(opts?: O) => {
|
|
|
100
97
|
};
|
|
101
98
|
hooks: {
|
|
102
99
|
before: {
|
|
103
|
-
matcher(context:
|
|
104
|
-
handler: (inputContext:
|
|
100
|
+
matcher(context: import("@better-auth/core").HookEndpointContext): boolean;
|
|
101
|
+
handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>;
|
|
105
102
|
}[];
|
|
106
103
|
after: {
|
|
107
|
-
matcher(context:
|
|
108
|
-
handler: (inputContext:
|
|
104
|
+
matcher(context: import("@better-auth/core").HookEndpointContext): boolean;
|
|
105
|
+
handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>;
|
|
109
106
|
}[];
|
|
110
107
|
};
|
|
111
108
|
};
|
|
@@ -10,7 +10,7 @@ import { parseGenericState } from "../../state.mjs";
|
|
|
10
10
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
11
11
|
import { parseJSON } from "../../client/parser.mjs";
|
|
12
12
|
import { checkSkipProxy, resolveCurrentURL, stripTrailingSlash } from "./utils.mjs";
|
|
13
|
-
import { defu } from "defu";
|
|
13
|
+
import { defu as defu$1 } from "defu";
|
|
14
14
|
import { createAuthEndpoint, createAuthMiddleware } from "@better-auth/core/api";
|
|
15
15
|
import * as z from "zod";
|
|
16
16
|
//#region src/plugins/oauth-proxy/index.ts
|
|
@@ -148,7 +148,7 @@ const oAuthProxy = (opts) => {
|
|
|
148
148
|
return context.path === "/callback/:id";
|
|
149
149
|
},
|
|
150
150
|
handler: createAuthMiddleware(async (ctx) => {
|
|
151
|
-
const callbackParams = defu(ctx.query, ctx.body);
|
|
151
|
+
const callbackParams = defu$1(ctx.query, ctx.body);
|
|
152
152
|
const state = callbackParams.state;
|
|
153
153
|
if (!state || typeof state !== "string") return;
|
|
154
154
|
let statePackage;
|
|
@@ -142,6 +142,15 @@ async function authorize(ctx, options) {
|
|
|
142
142
|
scope: requestScope,
|
|
143
143
|
userId: session.user.id,
|
|
144
144
|
authTime: new Date(session.session.createdAt).getTime(),
|
|
145
|
+
/**
|
|
146
|
+
* Consent is required per OIDC spec unless:
|
|
147
|
+
* 1. Client is trusted (skipConsent = true)
|
|
148
|
+
* 2. User has already consented (and prompt is not "consent")
|
|
149
|
+
*
|
|
150
|
+
* When consent is required, the code needs to be treated as a
|
|
151
|
+
* consent request. Once the user consents, the code will be
|
|
152
|
+
* updated with the actual authorization code.
|
|
153
|
+
*/
|
|
145
154
|
requireConsent,
|
|
146
155
|
state: requireConsent ? query.state : null,
|
|
147
156
|
codeChallenge: query.code_challenge,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AuthorizationQuery, Client, CodeVerificationValue, OAuthAccessToken, OIDCMetadata, OIDCOptions, TokenBody } from "./types.mjs";
|
|
2
2
|
import { oidcProvider } from "./index.mjs";
|
|
3
|
-
|
|
4
3
|
//#region src/plugins/oidc-provider/client.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* @deprecated Use `@better-auth/oauth-provider` instead. This plugin will be removed in the next major version.
|
|
@@ -13,4 +12,4 @@ declare const oidcClient: () => {
|
|
|
13
12
|
};
|
|
14
13
|
type OidcClientPlugin = ReturnType<typeof oidcClient>;
|
|
15
14
|
//#endregion
|
|
16
|
-
export { OidcClientPlugin, oidcClient };
|
|
15
|
+
export { type AuthorizationQuery, type Client, type CodeVerificationValue, type OAuthAccessToken, type OIDCMetadata, type OIDCOptions, OidcClientPlugin, type TokenBody, oidcClient };
|