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
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import * as better_call0 from "better-call";
|
|
2
|
-
|
|
3
1
|
//#region src/api/middlewares/authorization.d.ts
|
|
4
2
|
/**
|
|
5
3
|
* Middleware that verifies the authenticated user owns a resource.
|
|
@@ -14,9 +12,13 @@ import * as better_call0 from "better-call";
|
|
|
14
12
|
* so the handler can use it without a redundant DB query.
|
|
15
13
|
*/
|
|
16
14
|
declare function requireResourceOwnership(config: {
|
|
17
|
-
/** Database model name (e.g., "passkey", "apiKey") */
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
/** Database model name (e.g., "passkey", "apiKey") */
|
|
16
|
+
model: string;
|
|
17
|
+
/** Request parameter name containing the resource ID */
|
|
18
|
+
idParam: string;
|
|
19
|
+
/** Where to find the ID: "body" or "query" */
|
|
20
|
+
idSource: "body" | "query";
|
|
21
|
+
/** Field on the resource that holds the owner's user ID. Default: "userId" */
|
|
20
22
|
ownerField?: string;
|
|
21
23
|
/**
|
|
22
24
|
* Custom error to throw when the resource is not found.
|
|
@@ -41,7 +43,7 @@ declare function requireResourceOwnership(config: {
|
|
|
41
43
|
* @default "FORBIDDEN" (403)
|
|
42
44
|
*/
|
|
43
45
|
forbiddenStatus?: "FORBIDDEN" | "UNAUTHORIZED";
|
|
44
|
-
}): (inputContext:
|
|
46
|
+
}): (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
45
47
|
verifiedResource: {};
|
|
46
48
|
}>;
|
|
47
49
|
/**
|
|
@@ -55,14 +57,16 @@ declare function requireResourceOwnership(config: {
|
|
|
55
57
|
* The verified member is returned on `ctx.context.verifiedMember`.
|
|
56
58
|
*/
|
|
57
59
|
declare function requireOrgRole(config: {
|
|
58
|
-
/** Request parameter name containing the organization ID */
|
|
60
|
+
/** Request parameter name containing the organization ID */
|
|
61
|
+
orgIdParam: string;
|
|
62
|
+
/** Where to find the org ID: "body" or "query" */
|
|
59
63
|
orgIdSource: "body" | "query";
|
|
60
64
|
/**
|
|
61
65
|
* Roles that are authorized to proceed. If omitted or empty,
|
|
62
66
|
* any org membership is sufficient.
|
|
63
67
|
*/
|
|
64
68
|
allowedRoles?: string[];
|
|
65
|
-
}): (inputContext:
|
|
69
|
+
}): (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
66
70
|
verifiedMember: {};
|
|
67
71
|
}>;
|
|
68
72
|
//#endregion
|
|
@@ -69,7 +69,8 @@ function requireOrgRole(config) {
|
|
|
69
69
|
});
|
|
70
70
|
if (!member) throw new APIError("FORBIDDEN", { message: "Not a member of this organization" });
|
|
71
71
|
if (config.allowedRoles?.length) {
|
|
72
|
-
|
|
72
|
+
const rawRole = member.role ?? "";
|
|
73
|
+
if (!parseMemberRoles(rawRole).some((role) => config.allowedRoles.includes(role))) throw new APIError("FORBIDDEN", { message: "Insufficient role for this operation" });
|
|
73
74
|
}
|
|
74
75
|
return { verifiedMember: member };
|
|
75
76
|
});
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { requireOrgRole, requireResourceOwnership } from "./authorization.mjs";
|
|
2
|
-
import { formCsrfMiddleware, originCheck, originCheckMiddleware } from "./origin-check.mjs";
|
|
2
|
+
import { formCsrfMiddleware, originCheck, originCheckMiddleware } from "./origin-check.mjs";
|
|
3
|
+
export { formCsrfMiddleware, originCheck, originCheckMiddleware, requireOrgRole, requireResourceOwnership };
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { GenericEndpointContext } from "@better-auth/core";
|
|
2
|
-
import * as better_call0 from "better-call";
|
|
3
|
-
|
|
4
2
|
//#region src/api/middlewares/origin-check.d.ts
|
|
5
3
|
/**
|
|
6
4
|
* A middleware to validate callbackURL and origin against trustedOrigins.
|
|
7
5
|
* Also handles CSRF protection using Fetch Metadata for first-login scenarios.
|
|
8
6
|
*/
|
|
9
|
-
declare const originCheckMiddleware: (inputContext:
|
|
10
|
-
declare const originCheck: (getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext:
|
|
7
|
+
declare const originCheckMiddleware: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>;
|
|
8
|
+
declare const originCheck: (getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>;
|
|
11
9
|
/**
|
|
12
10
|
* Middleware for CSRF protection using Fetch Metadata headers.
|
|
13
11
|
* This prevents cross-site navigation login attacks while supporting progressive enhancement.
|
|
14
12
|
*/
|
|
15
|
-
declare const formCsrfMiddleware: (inputContext:
|
|
13
|
+
declare const formCsrfMiddleware: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>;
|
|
16
14
|
//#endregion
|
|
17
15
|
export { formCsrfMiddleware, originCheck, originCheckMiddleware };
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import * as _better_auth_core_oauth20 from "@better-auth/core/oauth2";
|
|
2
|
-
import * as better_call0 from "better-call";
|
|
3
1
|
import * as z from "zod";
|
|
4
|
-
|
|
5
2
|
//#region src/api/routes/account.d.ts
|
|
6
|
-
declare const listUserAccounts:
|
|
3
|
+
declare const listUserAccounts: import("better-call").StrictEndpoint<"/list-accounts", {
|
|
7
4
|
method: "GET";
|
|
8
|
-
use: ((inputContext:
|
|
5
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
9
6
|
session: {
|
|
10
7
|
session: Record<string, any> & {
|
|
11
8
|
id: string;
|
|
@@ -87,7 +84,7 @@ declare const listUserAccounts: better_call0.StrictEndpoint<"/list-accounts", {
|
|
|
87
84
|
providerId: string;
|
|
88
85
|
accountId: string;
|
|
89
86
|
}[]>;
|
|
90
|
-
declare const linkSocialAccount:
|
|
87
|
+
declare const linkSocialAccount: import("better-call").StrictEndpoint<"/link-social", {
|
|
91
88
|
method: "POST";
|
|
92
89
|
requireHeaders: true;
|
|
93
90
|
body: z.ZodObject<{
|
|
@@ -106,7 +103,7 @@ declare const linkSocialAccount: better_call0.StrictEndpoint<"/link-social", {
|
|
|
106
103
|
disableRedirect: z.ZodOptional<z.ZodBoolean>;
|
|
107
104
|
additionalData: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
108
105
|
}, z.core.$strip>;
|
|
109
|
-
use: ((inputContext:
|
|
106
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
110
107
|
session: {
|
|
111
108
|
session: Record<string, any> & {
|
|
112
109
|
id: string;
|
|
@@ -165,13 +162,13 @@ declare const linkSocialAccount: better_call0.StrictEndpoint<"/link-social", {
|
|
|
165
162
|
url: string;
|
|
166
163
|
redirect: boolean;
|
|
167
164
|
}>;
|
|
168
|
-
declare const unlinkAccount:
|
|
165
|
+
declare const unlinkAccount: import("better-call").StrictEndpoint<"/unlink-account", {
|
|
169
166
|
method: "POST";
|
|
170
167
|
body: z.ZodObject<{
|
|
171
168
|
providerId: z.ZodString;
|
|
172
169
|
accountId: z.ZodOptional<z.ZodString>;
|
|
173
170
|
}, z.core.$strip>;
|
|
174
|
-
use: ((inputContext:
|
|
171
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
175
172
|
session: {
|
|
176
173
|
session: Record<string, any> & {
|
|
177
174
|
id: string;
|
|
@@ -219,7 +216,7 @@ declare const unlinkAccount: better_call0.StrictEndpoint<"/unlink-account", {
|
|
|
219
216
|
}, {
|
|
220
217
|
status: boolean;
|
|
221
218
|
}>;
|
|
222
|
-
declare const getAccessToken:
|
|
219
|
+
declare const getAccessToken: import("better-call").StrictEndpoint<"/get-access-token", {
|
|
223
220
|
method: "POST";
|
|
224
221
|
body: z.ZodObject<{
|
|
225
222
|
providerId: z.ZodString;
|
|
@@ -267,7 +264,7 @@ declare const getAccessToken: better_call0.StrictEndpoint<"/get-access-token", {
|
|
|
267
264
|
scopes: string[];
|
|
268
265
|
idToken: string | undefined;
|
|
269
266
|
}>;
|
|
270
|
-
declare const refreshToken:
|
|
267
|
+
declare const refreshToken: import("better-call").StrictEndpoint<"/refresh-token", {
|
|
271
268
|
method: "POST";
|
|
272
269
|
body: z.ZodObject<{
|
|
273
270
|
providerId: z.ZodString;
|
|
@@ -326,7 +323,7 @@ declare const refreshToken: better_call0.StrictEndpoint<"/refresh-token", {
|
|
|
326
323
|
providerId: string;
|
|
327
324
|
accountId: string;
|
|
328
325
|
}>;
|
|
329
|
-
declare const accountInfo:
|
|
326
|
+
declare const accountInfo: import("better-call").StrictEndpoint<"/account-info", {
|
|
330
327
|
method: "GET";
|
|
331
328
|
metadata: {
|
|
332
329
|
openapi: {
|
|
@@ -381,7 +378,7 @@ declare const accountInfo: better_call0.StrictEndpoint<"/account-info", {
|
|
|
381
378
|
userId: z.ZodOptional<z.ZodString>;
|
|
382
379
|
}, z.core.$strip>>;
|
|
383
380
|
}, {
|
|
384
|
-
user:
|
|
381
|
+
user: import("@better-auth/core/oauth2").OAuth2UserInfo;
|
|
385
382
|
data: Record<string, any>;
|
|
386
383
|
} | null>;
|
|
387
384
|
//#endregion
|
|
@@ -70,8 +70,17 @@ const linkSocialAccount = createAuthEndpoint("/link-social", {
|
|
|
70
70
|
method: "POST",
|
|
71
71
|
requireHeaders: true,
|
|
72
72
|
body: z.object({
|
|
73
|
+
/**
|
|
74
|
+
* Callback URL to redirect to after the user has signed in.
|
|
75
|
+
*/
|
|
73
76
|
callbackURL: z.string().meta({ description: "The URL to redirect to after the user has signed in" }).optional(),
|
|
77
|
+
/**
|
|
78
|
+
* OAuth2 provider to use
|
|
79
|
+
*/
|
|
74
80
|
provider: SocialProviderListEnum,
|
|
81
|
+
/**
|
|
82
|
+
* ID Token for direct authentication without redirect
|
|
83
|
+
*/
|
|
75
84
|
idToken: z.object({
|
|
76
85
|
token: z.string(),
|
|
77
86
|
nonce: z.string().optional(),
|
|
@@ -79,10 +88,30 @@ const linkSocialAccount = createAuthEndpoint("/link-social", {
|
|
|
79
88
|
refreshToken: z.string().optional(),
|
|
80
89
|
scopes: z.array(z.string()).optional()
|
|
81
90
|
}).optional(),
|
|
91
|
+
/**
|
|
92
|
+
* Whether to allow sign up for new users
|
|
93
|
+
*/
|
|
82
94
|
requestSignUp: z.boolean().optional(),
|
|
95
|
+
/**
|
|
96
|
+
* Additional scopes to request when linking the account.
|
|
97
|
+
* This is useful for requesting additional permissions when
|
|
98
|
+
* linking a social account compared to the initial authentication.
|
|
99
|
+
*/
|
|
83
100
|
scopes: z.array(z.string()).meta({ description: "Additional scopes to request from the provider" }).optional(),
|
|
101
|
+
/**
|
|
102
|
+
* The URL to redirect to if there is an error during the link process.
|
|
103
|
+
*/
|
|
84
104
|
errorCallbackURL: z.string().meta({ description: "The URL to redirect to if there is an error during the link process" }).optional(),
|
|
105
|
+
/**
|
|
106
|
+
* Disable automatic redirection to the provider
|
|
107
|
+
*
|
|
108
|
+
* This is useful if you want to handle the redirection
|
|
109
|
+
* yourself like in a popup or a different tab.
|
|
110
|
+
*/
|
|
85
111
|
disableRedirect: z.boolean().meta({ description: "Disable automatic redirection to the provider. Useful for handling the redirection yourself" }).optional(),
|
|
112
|
+
/**
|
|
113
|
+
* Any additional data to pass through the oauth flow.
|
|
114
|
+
*/
|
|
86
115
|
additionalData: z.record(z.string(), z.any()).optional()
|
|
87
116
|
}),
|
|
88
117
|
use: [sessionMiddleware],
|
|
@@ -121,7 +150,7 @@ const linkSocialAccount = createAuthEndpoint("/link-social", {
|
|
|
121
150
|
throw APIError.from("NOT_FOUND", BASE_ERROR_CODES.ID_TOKEN_NOT_SUPPORTED);
|
|
122
151
|
}
|
|
123
152
|
const { token, nonce } = c.body.idToken;
|
|
124
|
-
if (!await provider.verifyIdToken(token, nonce)) {
|
|
153
|
+
if (!await provider.verifyIdToken(token, nonce, c)) {
|
|
125
154
|
c.context.logger.warn("Invalid id token", { provider: c.body.provider });
|
|
126
155
|
throw APIError.from("UNAUTHORIZED", BASE_ERROR_CODES.INVALID_TOKEN);
|
|
127
156
|
}
|
|
@@ -452,11 +481,6 @@ const refreshToken = createAuthEndpoint("/refresh-token", {
|
|
|
452
481
|
});
|
|
453
482
|
}
|
|
454
483
|
});
|
|
455
|
-
const accountInfoQuerySchema = z.optional(z.object({
|
|
456
|
-
accountId: z.string().meta({ description: "The provider given account id for which to get the account info" }).optional(),
|
|
457
|
-
providerId: z.string().meta({ description: "The provider ID to disambiguate provider-issued account IDs" }).optional(),
|
|
458
|
-
userId: z.string().meta({ description: "The user ID associated with the account" }).optional()
|
|
459
|
-
}));
|
|
460
484
|
const accountInfo = createAuthEndpoint("/account-info", {
|
|
461
485
|
method: "GET",
|
|
462
486
|
metadata: { openapi: {
|
|
@@ -488,7 +512,11 @@ const accountInfo = createAuthEndpoint("/account-info", {
|
|
|
488
512
|
} } }
|
|
489
513
|
} }
|
|
490
514
|
} },
|
|
491
|
-
query:
|
|
515
|
+
query: z.optional(z.object({
|
|
516
|
+
accountId: z.string().meta({ description: "The provider given account id for which to get the account info" }).optional(),
|
|
517
|
+
providerId: z.string().meta({ description: "The provider ID to disambiguate provider-issued account IDs" }).optional(),
|
|
518
|
+
userId: z.string().meta({ description: "The user ID associated with the account" }).optional()
|
|
519
|
+
}))
|
|
492
520
|
}, async (ctx) => {
|
|
493
521
|
const { accountId: providedAccountId, providerId: providedProviderId, userId } = ctx.query || {};
|
|
494
522
|
const resolvedUserId = await resolveUserId(ctx, userId);
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import * as better_call0 from "better-call";
|
|
2
1
|
import * as z from "zod";
|
|
3
|
-
|
|
4
2
|
//#region src/api/routes/callback.d.ts
|
|
5
|
-
declare const callbackOAuth:
|
|
3
|
+
declare const callbackOAuth: import("better-call").StrictEndpoint<"/callback/:id", {
|
|
6
4
|
method: ("GET" | "POST")[];
|
|
7
5
|
operationId: string;
|
|
8
6
|
body: z.ZodOptional<z.ZodObject<{
|
|
@@ -79,6 +79,10 @@ const callbackOAuth = createAuthEndpoint("/callback/:id", {
|
|
|
79
79
|
const parsedUserData = userData ? safeJSONParse(userData) : null;
|
|
80
80
|
const userInfo = await provider.getUserInfo({
|
|
81
81
|
...tokens,
|
|
82
|
+
/**
|
|
83
|
+
* The user object from the provider
|
|
84
|
+
* This is only available for some providers like Apple
|
|
85
|
+
*/
|
|
82
86
|
user: parsedUserData ?? void 0
|
|
83
87
|
}).then((res) => res?.user);
|
|
84
88
|
if (!userInfo || userInfo.id === void 0 || userInfo.id === null || userInfo.id === "") {
|
|
@@ -1,30 +1,26 @@
|
|
|
1
1
|
import { User } from "../../types/models.mjs";
|
|
2
|
+
import "../../types/index.mjs";
|
|
2
3
|
import { 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/api/routes/email-verification.d.ts
|
|
7
6
|
declare function createEmailVerificationToken(secret: string, email: string,
|
|
8
7
|
/**
|
|
9
8
|
* The email to update from
|
|
10
9
|
*/
|
|
11
|
-
|
|
12
10
|
updateTo?: string | undefined,
|
|
13
11
|
/**
|
|
14
12
|
* The time in seconds for the token to expire
|
|
15
13
|
*/
|
|
16
|
-
|
|
17
14
|
expiresIn?: number,
|
|
18
15
|
/**
|
|
19
16
|
* Extra payload to include in the token
|
|
20
17
|
*/
|
|
21
|
-
|
|
22
18
|
extraPayload?: Record<string, any>): Promise<string>;
|
|
23
19
|
/**
|
|
24
20
|
* A function to send a verification email to the user
|
|
25
21
|
*/
|
|
26
22
|
declare function sendVerificationEmailFn(ctx: GenericEndpointContext, user: User): Promise<void>;
|
|
27
|
-
declare const sendVerificationEmail:
|
|
23
|
+
declare const sendVerificationEmail: import("better-call").StrictEndpoint<"/send-verification-email", {
|
|
28
24
|
method: "POST";
|
|
29
25
|
operationId: string;
|
|
30
26
|
cloneRequest: true;
|
|
@@ -100,14 +96,14 @@ declare const sendVerificationEmail: better_call0.StrictEndpoint<"/send-verifica
|
|
|
100
96
|
}, {
|
|
101
97
|
status: boolean;
|
|
102
98
|
}>;
|
|
103
|
-
declare const verifyEmail:
|
|
99
|
+
declare const verifyEmail: import("better-call").StrictEndpoint<"/verify-email", {
|
|
104
100
|
method: "GET";
|
|
105
101
|
operationId: string;
|
|
106
102
|
query: z.ZodObject<{
|
|
107
103
|
token: z.ZodString;
|
|
108
104
|
callbackURL: z.ZodOptional<z.ZodString>;
|
|
109
105
|
}, z.core.$strip>;
|
|
110
|
-
use: ((inputContext:
|
|
106
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>)[];
|
|
111
107
|
metadata: {
|
|
112
108
|
openapi: {
|
|
113
109
|
description: string;
|
|
@@ -3,6 +3,7 @@ import { signJWT } from "../../crypto/jwt.mjs";
|
|
|
3
3
|
import { parseUserOutput } from "../../db/schema.mjs";
|
|
4
4
|
import { setSessionCookie } from "../../cookies/index.mjs";
|
|
5
5
|
import { getSessionFromCtx } from "./session.mjs";
|
|
6
|
+
import { safeCloneRequest } from "../../utils/request.mjs";
|
|
6
7
|
import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
7
8
|
import { createAuthEndpoint } from "@better-auth/core/api";
|
|
8
9
|
import * as z from "zod";
|
|
@@ -188,6 +189,9 @@ const verifyEmail = createAuthEndpoint("/verify-email", {
|
|
|
188
189
|
const session = await getSessionFromCtx(ctx);
|
|
189
190
|
if (session && session.user.email !== parsed.email) return redirectOnError(BASE_ERROR_CODES.INVALID_USER);
|
|
190
191
|
switch (parsed.requestType) {
|
|
192
|
+
/**
|
|
193
|
+
* User clicks confirmation -> sends verification to new email
|
|
194
|
+
*/
|
|
191
195
|
case "change-email-confirmation": {
|
|
192
196
|
const newToken = await createEmailVerificationToken(ctx.context.secret, parsed.email, parsed.updateTo, ctx.context.options.emailVerification?.expiresIn, { requestType: "change-email-verification" });
|
|
193
197
|
const updateCallbackURL = ctx.query.callbackURL ? encodeURIComponent(ctx.query.callbackURL) : encodeURIComponent("/");
|
|
@@ -199,10 +203,13 @@ const verifyEmail = createAuthEndpoint("/verify-email", {
|
|
|
199
203
|
},
|
|
200
204
|
url,
|
|
201
205
|
token: newToken
|
|
202
|
-
}, ctx.request
|
|
206
|
+
}, safeCloneRequest(ctx.request)));
|
|
203
207
|
if (ctx.query.callbackURL) throw ctx.redirect(ctx.query.callbackURL);
|
|
204
208
|
return ctx.json({ status: true });
|
|
205
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* User clicks verification -> updates email
|
|
212
|
+
*/
|
|
206
213
|
case "change-email-verification": {
|
|
207
214
|
let activeSession = session;
|
|
208
215
|
if (!activeSession) {
|
|
@@ -232,6 +239,12 @@ const verifyEmail = createAuthEndpoint("/verify-email", {
|
|
|
232
239
|
user: parseUserOutput(ctx.context.options, updatedUser)
|
|
233
240
|
});
|
|
234
241
|
}
|
|
242
|
+
/**
|
|
243
|
+
* Legacy flow
|
|
244
|
+
*
|
|
245
|
+
* - skips two-step verification
|
|
246
|
+
* - updates email immediately
|
|
247
|
+
*/
|
|
235
248
|
default: {
|
|
236
249
|
let activeSession = session;
|
|
237
250
|
if (!activeSession) {
|
|
@@ -252,7 +265,7 @@ const verifyEmail = createAuthEndpoint("/verify-email", {
|
|
|
252
265
|
user: updatedUser,
|
|
253
266
|
url: `${ctx.context.baseURL}/verify-email?token=${newToken}&callbackURL=${updateCallbackURL}`,
|
|
254
267
|
token: newToken
|
|
255
|
-
}, ctx.request
|
|
268
|
+
}, safeCloneRequest(ctx.request)));
|
|
256
269
|
await setSessionCookie(ctx, {
|
|
257
270
|
session: activeSession.session,
|
|
258
271
|
user: {
|
|
@@ -9,4 +9,5 @@ import { signInEmail, signInSocial } from "./sign-in.mjs";
|
|
|
9
9
|
import { signOut } from "./sign-out.mjs";
|
|
10
10
|
import { signUpEmail } from "./sign-up.mjs";
|
|
11
11
|
import { updateSession } from "./update-session.mjs";
|
|
12
|
-
import { changeEmail, changePassword, deleteUser, deleteUserCallback, setPassword, updateUser } from "./update-user.mjs";
|
|
12
|
+
import { changeEmail, changePassword, deleteUser, deleteUserCallback, setPassword, updateUser } from "./update-user.mjs";
|
|
13
|
+
export { accountInfo, callbackOAuth, changeEmail, changePassword, createEmailVerificationToken, deleteUser, deleteUserCallback, error, freshSessionMiddleware, getAccessToken, getAuthoritativeSessionFromCtx, getSession, getSessionFromCtx, isStateful, linkSocialAccount, listSessions, listUserAccounts, ok, refreshToken, requestOnlySessionMiddleware, requestPasswordReset, requestPasswordResetCallback, resetPassword, revokeOtherSessions, revokeSession, revokeSessions, sendVerificationEmail, sendVerificationEmailFn, sensitiveSessionMiddleware, sessionMiddleware, setPassword, signInEmail, signInSocial, signOut, signUpEmail, unlinkAccount, updateSession, updateUser, verifyEmail, verifyPassword };
|
package/dist/api/routes/ok.d.mts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import * as better_call0 from "better-call";
|
|
2
1
|
import * as z from "zod";
|
|
3
|
-
|
|
4
2
|
//#region src/api/routes/password.d.ts
|
|
5
|
-
declare const requestPasswordReset:
|
|
3
|
+
declare const requestPasswordReset: import("better-call").StrictEndpoint<"/request-password-reset", {
|
|
6
4
|
method: "POST";
|
|
7
5
|
body: z.ZodObject<{
|
|
8
6
|
email: z.ZodEmail;
|
|
@@ -34,18 +32,18 @@ declare const requestPasswordReset: better_call0.StrictEndpoint<"/request-passwo
|
|
|
34
32
|
};
|
|
35
33
|
};
|
|
36
34
|
};
|
|
37
|
-
use: ((inputContext:
|
|
35
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>)[];
|
|
38
36
|
}, {
|
|
39
37
|
status: boolean;
|
|
40
38
|
message: string;
|
|
41
39
|
}>;
|
|
42
|
-
declare const requestPasswordResetCallback:
|
|
40
|
+
declare const requestPasswordResetCallback: import("better-call").StrictEndpoint<"/reset-password/:token", {
|
|
43
41
|
method: "GET";
|
|
44
42
|
operationId: string;
|
|
45
43
|
query: z.ZodObject<{
|
|
46
44
|
callbackURL: z.ZodString;
|
|
47
45
|
}, z.core.$strip>;
|
|
48
|
-
use: ((inputContext:
|
|
46
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>)[];
|
|
49
47
|
metadata: {
|
|
50
48
|
openapi: {
|
|
51
49
|
operationId: string;
|
|
@@ -87,7 +85,7 @@ declare const requestPasswordResetCallback: better_call0.StrictEndpoint<"/reset-
|
|
|
87
85
|
};
|
|
88
86
|
};
|
|
89
87
|
}, never>;
|
|
90
|
-
declare const resetPassword:
|
|
88
|
+
declare const resetPassword: import("better-call").StrictEndpoint<"/reset-password", {
|
|
91
89
|
method: "POST";
|
|
92
90
|
operationId: string;
|
|
93
91
|
query: z.ZodOptional<z.ZodObject<{
|
|
@@ -123,7 +121,7 @@ declare const resetPassword: better_call0.StrictEndpoint<"/reset-password", {
|
|
|
123
121
|
}, {
|
|
124
122
|
status: boolean;
|
|
125
123
|
}>;
|
|
126
|
-
declare const verifyPassword:
|
|
124
|
+
declare const verifyPassword: import("better-call").StrictEndpoint<"/verify-password", {
|
|
127
125
|
method: "POST";
|
|
128
126
|
body: z.ZodObject<{
|
|
129
127
|
password: z.ZodString;
|
|
@@ -152,7 +150,7 @@ declare const verifyPassword: better_call0.StrictEndpoint<"/verify-password", {
|
|
|
152
150
|
};
|
|
153
151
|
};
|
|
154
152
|
};
|
|
155
|
-
use: ((inputContext:
|
|
153
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
156
154
|
session: {
|
|
157
155
|
session: Record<string, any> & {
|
|
158
156
|
id: string;
|
|
@@ -20,7 +20,16 @@ function redirectCallback(ctx, callbackURL, query) {
|
|
|
20
20
|
const requestPasswordReset = createAuthEndpoint("/request-password-reset", {
|
|
21
21
|
method: "POST",
|
|
22
22
|
body: z.object({
|
|
23
|
+
/**
|
|
24
|
+
* The email address of the user to send a password reset email to.
|
|
25
|
+
*/
|
|
23
26
|
email: z.email().meta({ description: "The email address of the user to send a password reset email to" }),
|
|
27
|
+
/**
|
|
28
|
+
* The URL to redirect the user to reset their password.
|
|
29
|
+
* If the token isn't valid or expired, it'll be redirected with a query parameter `?
|
|
30
|
+
* error=INVALID_TOKEN`. If the token is valid, it'll be redirected with a query parameter `?
|
|
31
|
+
* token=VALID_TOKEN
|
|
32
|
+
*/
|
|
24
33
|
redirectTo: z.string().meta({ description: "The URL to redirect the user to reset their password. If the token isn't valid or expired, it'll be redirected with a query parameter `?error=INVALID_TOKEN`. If the token is valid, it'll be redirected with a query parameter `?token=VALID_TOKEN" }).optional()
|
|
25
34
|
}),
|
|
26
35
|
metadata: { openapi: {
|
|
@@ -165,7 +174,11 @@ const resetPassword = createAuthEndpoint("/reset-password", {
|
|
|
165
174
|
});
|
|
166
175
|
const verifyPassword = createAuthEndpoint("/verify-password", {
|
|
167
176
|
method: "POST",
|
|
168
|
-
body: z.object({
|
|
177
|
+
body: z.object({
|
|
178
|
+
/**
|
|
179
|
+
* The password to verify
|
|
180
|
+
*/
|
|
181
|
+
password: z.string().meta({ description: "The password to verify" }) }),
|
|
169
182
|
metadata: {
|
|
170
183
|
scope: "server",
|
|
171
184
|
openapi: {
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { Prettify
|
|
2
|
-
import { Session
|
|
1
|
+
import { Prettify } from "../../types/helper.mjs";
|
|
2
|
+
import { Session, User } from "../../types/models.mjs";
|
|
3
|
+
import "../../types/index.mjs";
|
|
3
4
|
import { BetterAuthOptions, GenericEndpointContext } from "@better-auth/core";
|
|
4
|
-
import * as _better_auth_core_db0 from "@better-auth/core/db";
|
|
5
|
-
import * as better_call0 from "better-call";
|
|
6
5
|
import * as z from "zod";
|
|
7
|
-
|
|
8
6
|
//#region src/api/routes/session.d.ts
|
|
9
|
-
declare const getSession: <Option extends BetterAuthOptions>() =>
|
|
7
|
+
declare const getSession: <Option extends BetterAuthOptions>() => import("better-call").StrictEndpoint<"/get-session", {
|
|
10
8
|
method: ("GET" | "POST")[];
|
|
11
9
|
operationId: string;
|
|
12
10
|
query: z.ZodOptional<z.ZodObject<{
|
|
@@ -42,8 +40,8 @@ declare const getSession: <Option extends BetterAuthOptions>() => better_call0.S
|
|
|
42
40
|
};
|
|
43
41
|
};
|
|
44
42
|
}, {
|
|
45
|
-
session: Session
|
|
46
|
-
user: User
|
|
43
|
+
session: Session<Option["session"], Option["plugins"]>;
|
|
44
|
+
user: User<Option["user"], Option["plugins"]>;
|
|
47
45
|
} | null>;
|
|
48
46
|
/**
|
|
49
47
|
* Whether the deployment keeps sessions in a durable server-side store
|
|
@@ -60,8 +58,8 @@ declare const getSessionFromCtx: <U extends Record<string, any> = Record<string,
|
|
|
60
58
|
disableCookieCache?: boolean;
|
|
61
59
|
disableRefresh?: boolean;
|
|
62
60
|
} | undefined) => Promise<{
|
|
63
|
-
session: S & Session
|
|
64
|
-
user: U & User
|
|
61
|
+
session: S & Session;
|
|
62
|
+
user: U & User;
|
|
65
63
|
} | null>;
|
|
66
64
|
/**
|
|
67
65
|
* Reads the session from the source that can authorize sensitive work.
|
|
@@ -94,7 +92,7 @@ declare const getAuthoritativeSessionFromCtx: <U extends Record<string, any> = R
|
|
|
94
92
|
/**
|
|
95
93
|
* The middleware forces the endpoint to require a valid session.
|
|
96
94
|
*/
|
|
97
|
-
declare const sessionMiddleware: (inputContext:
|
|
95
|
+
declare const sessionMiddleware: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
98
96
|
session: {
|
|
99
97
|
session: Record<string, any> & {
|
|
100
98
|
id: string;
|
|
@@ -121,7 +119,7 @@ declare const sessionMiddleware: (inputContext: better_call0.MiddlewareInputCont
|
|
|
121
119
|
* This middleware forces the endpoint to require a valid authoritative session.
|
|
122
120
|
* This should be used for sensitive operations like password changes, account deletion, etc.
|
|
123
121
|
*/
|
|
124
|
-
declare const sensitiveSessionMiddleware: (inputContext:
|
|
122
|
+
declare const sensitiveSessionMiddleware: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
125
123
|
session: {
|
|
126
124
|
session: Record<string, any> & {
|
|
127
125
|
id: string;
|
|
@@ -148,7 +146,7 @@ declare const sensitiveSessionMiddleware: (inputContext: better_call0.Middleware
|
|
|
148
146
|
* This middleware allows you to call the endpoint on the client if session is valid.
|
|
149
147
|
* However, if called on the server, no session is required.
|
|
150
148
|
*/
|
|
151
|
-
declare const requestOnlySessionMiddleware: (inputContext:
|
|
149
|
+
declare const requestOnlySessionMiddleware: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
152
150
|
session: {
|
|
153
151
|
session: Record<string, any> & {
|
|
154
152
|
id: string;
|
|
@@ -178,7 +176,7 @@ declare const requestOnlySessionMiddleware: (inputContext: better_call0.Middlewa
|
|
|
178
176
|
* Session freshness check will be skipped if the session config's freshAge
|
|
179
177
|
* is set to 0
|
|
180
178
|
*/
|
|
181
|
-
declare const freshSessionMiddleware: (inputContext:
|
|
179
|
+
declare const freshSessionMiddleware: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
182
180
|
session: {
|
|
183
181
|
session: Record<string, any> & {
|
|
184
182
|
id: string;
|
|
@@ -204,10 +202,10 @@ declare const freshSessionMiddleware: (inputContext: better_call0.MiddlewareInpu
|
|
|
204
202
|
/**
|
|
205
203
|
* user active sessions list
|
|
206
204
|
*/
|
|
207
|
-
declare const listSessions: <Option extends BetterAuthOptions>() =>
|
|
205
|
+
declare const listSessions: <Option extends BetterAuthOptions>() => import("better-call").StrictEndpoint<"/list-sessions", {
|
|
208
206
|
method: "GET";
|
|
209
207
|
operationId: string;
|
|
210
|
-
use: ((inputContext:
|
|
208
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
211
209
|
session: {
|
|
212
210
|
session: Record<string, any> & {
|
|
213
211
|
id: string;
|
|
@@ -252,7 +250,7 @@ declare const listSessions: <Option extends BetterAuthOptions>() => better_call0
|
|
|
252
250
|
};
|
|
253
251
|
};
|
|
254
252
|
};
|
|
255
|
-
}, Prettify
|
|
253
|
+
}, Prettify<{
|
|
256
254
|
id: string;
|
|
257
255
|
createdAt: Date;
|
|
258
256
|
updatedAt: Date;
|
|
@@ -261,16 +259,16 @@ declare const listSessions: <Option extends BetterAuthOptions>() => better_call0
|
|
|
261
259
|
token: string;
|
|
262
260
|
ipAddress?: string | null | undefined;
|
|
263
261
|
userAgent?: string | null | undefined;
|
|
264
|
-
} &
|
|
262
|
+
} & import("@better-auth/core/db").InferDBFieldsFromOptions<Option["session"]> & import("@better-auth/core/db").InferDBFieldsFromPlugins<"session", Option["plugins"]> extends (infer T) ? { [K in keyof T]: T[K]; } : never>[]>;
|
|
265
263
|
/**
|
|
266
264
|
* revoke a single session
|
|
267
265
|
*/
|
|
268
|
-
declare const revokeSession:
|
|
266
|
+
declare const revokeSession: import("better-call").StrictEndpoint<"/revoke-session", {
|
|
269
267
|
method: "POST";
|
|
270
268
|
body: z.ZodObject<{
|
|
271
269
|
token: z.ZodString;
|
|
272
270
|
}, z.core.$strip>;
|
|
273
|
-
use: ((inputContext:
|
|
271
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
274
272
|
session: {
|
|
275
273
|
session: Record<string, any> & {
|
|
276
274
|
id: string;
|
|
@@ -340,9 +338,9 @@ declare const revokeSession: better_call0.StrictEndpoint<"/revoke-session", {
|
|
|
340
338
|
/**
|
|
341
339
|
* revoke all user sessions
|
|
342
340
|
*/
|
|
343
|
-
declare const revokeSessions:
|
|
341
|
+
declare const revokeSessions: import("better-call").StrictEndpoint<"/revoke-sessions", {
|
|
344
342
|
method: "POST";
|
|
345
|
-
use: ((inputContext:
|
|
343
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
346
344
|
session: {
|
|
347
345
|
session: Record<string, any> & {
|
|
348
346
|
id: string;
|
|
@@ -393,10 +391,10 @@ declare const revokeSessions: better_call0.StrictEndpoint<"/revoke-sessions", {
|
|
|
393
391
|
}, {
|
|
394
392
|
status: boolean;
|
|
395
393
|
}>;
|
|
396
|
-
declare const revokeOtherSessions:
|
|
394
|
+
declare const revokeOtherSessions: import("better-call").StrictEndpoint<"/revoke-other-sessions", {
|
|
397
395
|
method: "POST";
|
|
398
396
|
requireHeaders: true;
|
|
399
|
-
use: ((inputContext:
|
|
397
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
400
398
|
session: {
|
|
401
399
|
session: Record<string, any> & {
|
|
402
400
|
id: string;
|