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
|
@@ -35,6 +35,8 @@ const getSession = () => createAuthEndpoint("/get-session", {
|
|
|
35
35
|
} }
|
|
36
36
|
} }
|
|
37
37
|
}, async (ctx) => {
|
|
38
|
+
ctx.setHeader("cache-control", "no-store");
|
|
39
|
+
ctx.setHeader("pragma", "no-cache");
|
|
38
40
|
const deferSessionRefresh = ctx.context.options.session?.deferSessionRefresh;
|
|
39
41
|
const isPostRequest = ctx.method === "POST";
|
|
40
42
|
if (isPostRequest && !deferSessionRefresh) throw APIError.from("METHOD_NOT_ALLOWED", BASE_ERROR_CODES.METHOD_NOT_ALLOWED_DEFER_SESSION_REQUIRED);
|
|
@@ -291,8 +293,10 @@ const getSessionFromCtx = async (ctx, config) => {
|
|
|
291
293
|
return null;
|
|
292
294
|
}
|
|
293
295
|
if (session.headers) session.headers.forEach((value, key) => {
|
|
296
|
+
const lowerKey = key.toLowerCase();
|
|
297
|
+
if (lowerKey === "cache-control" || lowerKey === "pragma") return;
|
|
294
298
|
if (!ctx.context.responseHeaders) ctx.context.responseHeaders = new Headers({ [key]: value });
|
|
295
|
-
else if (
|
|
299
|
+
else if (lowerKey === "set-cookie") ctx.context.responseHeaders.append(key, value);
|
|
296
300
|
else ctx.context.responseHeaders.set(key, value);
|
|
297
301
|
});
|
|
298
302
|
ctx.context.session = session.response;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { BetterAuthOptions } from "@better-auth/core";
|
|
2
2
|
import { User } from "@better-auth/core/db";
|
|
3
|
-
import * as better_call0 from "better-call";
|
|
4
3
|
import * as z from "zod";
|
|
5
|
-
|
|
6
4
|
//#region src/api/routes/sign-in.d.ts
|
|
7
5
|
declare const socialSignInBodySchema: z.ZodObject<{
|
|
8
6
|
callbackURL: z.ZodOptional<z.ZodString>;
|
|
@@ -29,7 +27,7 @@ declare const socialSignInBodySchema: z.ZodObject<{
|
|
|
29
27
|
loginHint: z.ZodOptional<z.ZodString>;
|
|
30
28
|
additionalData: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
31
29
|
}, z.core.$strip>;
|
|
32
|
-
declare const signInSocial: <O extends BetterAuthOptions>() =>
|
|
30
|
+
declare const signInSocial: <O extends BetterAuthOptions>() => import("better-call").StrictEndpoint<"/sign-in/social", {
|
|
33
31
|
method: "POST";
|
|
34
32
|
operationId: string;
|
|
35
33
|
body: z.ZodObject<{
|
|
@@ -110,10 +108,10 @@ declare const signInSocial: <O extends BetterAuthOptions>() => better_call0.Stri
|
|
|
110
108
|
url: undefined;
|
|
111
109
|
user: User<O["user"], O["plugins"]>;
|
|
112
110
|
}>;
|
|
113
|
-
declare const signInEmail: <O extends BetterAuthOptions>() =>
|
|
111
|
+
declare const signInEmail: <O extends BetterAuthOptions>() => import("better-call").StrictEndpoint<"/sign-in/email", {
|
|
114
112
|
method: "POST";
|
|
115
113
|
operationId: string;
|
|
116
|
-
use: ((inputContext:
|
|
114
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>)[];
|
|
117
115
|
cloneRequest: true;
|
|
118
116
|
body: z.ZodObject<{
|
|
119
117
|
email: z.ZodString;
|
|
@@ -5,6 +5,7 @@ import { getAwaitableValue } from "../../context/helpers.mjs";
|
|
|
5
5
|
import { missingEmailLogMessage } from "../../oauth2/errors.mjs";
|
|
6
6
|
import { handleOAuthUserInfo } from "../../oauth2/link-account.mjs";
|
|
7
7
|
import { generateState } from "../../oauth2/state.mjs";
|
|
8
|
+
import { safeCloneRequest } from "../../utils/request.mjs";
|
|
8
9
|
import { createEmailVerificationToken } from "./email-verification.mjs";
|
|
9
10
|
import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
10
11
|
import { SocialProviderListEnum } from "@better-auth/core/social-providers";
|
|
@@ -12,17 +13,71 @@ import { createAuthEndpoint } from "@better-auth/core/api";
|
|
|
12
13
|
import * as z from "zod";
|
|
13
14
|
//#region src/api/routes/sign-in.ts
|
|
14
15
|
const socialSignInBodySchema = z.object({
|
|
16
|
+
/**
|
|
17
|
+
* Callback URL to redirect to after the user
|
|
18
|
+
* has signed in.
|
|
19
|
+
*/
|
|
15
20
|
callbackURL: z.string().meta({ description: "Callback URL to redirect to after the user has signed in" }).optional(),
|
|
21
|
+
/**
|
|
22
|
+
* callback url to redirect if the user is newly registered.
|
|
23
|
+
*
|
|
24
|
+
* useful if you have different routes for existing users and new users
|
|
25
|
+
*/
|
|
16
26
|
newUserCallbackURL: z.string().optional(),
|
|
27
|
+
/**
|
|
28
|
+
* Callback url to redirect to if an error happens
|
|
29
|
+
*
|
|
30
|
+
* If it's initiated from the client sdk this defaults to
|
|
31
|
+
* the current url.
|
|
32
|
+
*/
|
|
17
33
|
errorCallbackURL: z.string().meta({ description: "Callback URL to redirect to if an error happens" }).optional(),
|
|
34
|
+
/**
|
|
35
|
+
* OAuth2 provider to use`
|
|
36
|
+
*/
|
|
18
37
|
provider: SocialProviderListEnum,
|
|
38
|
+
/**
|
|
39
|
+
* Disable automatic redirection to the provider
|
|
40
|
+
*
|
|
41
|
+
* This is useful if you want to handle the redirection
|
|
42
|
+
* yourself like in a popup or a different tab.
|
|
43
|
+
*/
|
|
19
44
|
disableRedirect: z.boolean().meta({ description: "Disable automatic redirection to the provider. Useful for handling the redirection yourself" }).optional(),
|
|
45
|
+
/**
|
|
46
|
+
* ID token from the provider
|
|
47
|
+
*
|
|
48
|
+
* This is used to sign in the user
|
|
49
|
+
* if the user is already signed in with the
|
|
50
|
+
* provider in the frontend.
|
|
51
|
+
*
|
|
52
|
+
* Only applicable if the provider supports
|
|
53
|
+
* it. Currently only `apple` and `google` is
|
|
54
|
+
* supported out of the box.
|
|
55
|
+
*/
|
|
20
56
|
idToken: z.optional(z.object({
|
|
57
|
+
/**
|
|
58
|
+
* ID token from the provider
|
|
59
|
+
*/
|
|
21
60
|
token: z.string().meta({ description: "ID token from the provider" }),
|
|
61
|
+
/**
|
|
62
|
+
* The nonce used to generate the token
|
|
63
|
+
*/
|
|
22
64
|
nonce: z.string().meta({ description: "Nonce used to generate the token" }).optional(),
|
|
65
|
+
/**
|
|
66
|
+
* Access token from the provider
|
|
67
|
+
*/
|
|
23
68
|
accessToken: z.string().meta({ description: "Access token from the provider" }).optional(),
|
|
69
|
+
/**
|
|
70
|
+
* Refresh token from the provider
|
|
71
|
+
*/
|
|
24
72
|
refreshToken: z.string().meta({ description: "Refresh token from the provider" }).optional(),
|
|
73
|
+
/**
|
|
74
|
+
* Expiry date of the token
|
|
75
|
+
*/
|
|
25
76
|
expiresAt: z.number().meta({ description: "Expiry date of the token" }).optional(),
|
|
77
|
+
/**
|
|
78
|
+
* The user object from the provider.
|
|
79
|
+
* This is only available for some providers like Apple.
|
|
80
|
+
*/
|
|
26
81
|
user: z.object({
|
|
27
82
|
name: z.object({
|
|
28
83
|
firstName: z.string().optional(),
|
|
@@ -32,8 +87,21 @@ const socialSignInBodySchema = z.object({
|
|
|
32
87
|
}).meta({ description: "The user object from the provider. Only available for some providers like Apple." }).optional()
|
|
33
88
|
})),
|
|
34
89
|
scopes: z.array(z.string()).meta({ description: "Array of scopes to request from the provider. This will override the default scopes passed." }).optional(),
|
|
90
|
+
/**
|
|
91
|
+
* Explicitly request sign-up
|
|
92
|
+
*
|
|
93
|
+
* Should be used to allow sign up when
|
|
94
|
+
* disableImplicitSignUp for this provider is
|
|
95
|
+
* true
|
|
96
|
+
*/
|
|
35
97
|
requestSignUp: z.boolean().meta({ description: "Explicitly request sign-up. Useful when disableImplicitSignUp is true for this provider" }).optional(),
|
|
98
|
+
/**
|
|
99
|
+
* The login hint to use for the authorization code request
|
|
100
|
+
*/
|
|
36
101
|
loginHint: z.string().meta({ description: "The login hint to use for the authorization code request" }).optional(),
|
|
102
|
+
/**
|
|
103
|
+
* Additional data to be passed through the OAuth flow
|
|
104
|
+
*/
|
|
37
105
|
additionalData: z.record(z.string(), z.any()).optional().meta({ description: "Additional data to be passed through the OAuth flow" })
|
|
38
106
|
});
|
|
39
107
|
const signInSocial = () => createAuthEndpoint("/sign-in/social", {
|
|
@@ -79,7 +147,7 @@ const signInSocial = () => createAuthEndpoint("/sign-in/social", {
|
|
|
79
147
|
throw APIError.from("NOT_FOUND", BASE_ERROR_CODES.ID_TOKEN_NOT_SUPPORTED);
|
|
80
148
|
}
|
|
81
149
|
const { token, nonce } = c.body.idToken;
|
|
82
|
-
if (!await provider.verifyIdToken(token, nonce)) {
|
|
150
|
+
if (!await provider.verifyIdToken(token, nonce, c)) {
|
|
83
151
|
c.context.logger.warn("Invalid id token", { provider: c.body.provider });
|
|
84
152
|
throw APIError.from("UNAUTHORIZED", BASE_ERROR_CODES.INVALID_TOKEN);
|
|
85
153
|
}
|
|
@@ -146,9 +214,23 @@ const signInEmail = () => createAuthEndpoint("/sign-in/email", {
|
|
|
146
214
|
use: [formCsrfMiddleware],
|
|
147
215
|
cloneRequest: true,
|
|
148
216
|
body: z.object({
|
|
217
|
+
/**
|
|
218
|
+
* Email of the user
|
|
219
|
+
*/
|
|
149
220
|
email: z.string().meta({ description: "Email of the user" }),
|
|
221
|
+
/**
|
|
222
|
+
* Password of the user
|
|
223
|
+
*/
|
|
150
224
|
password: z.string().meta({ description: "Password of the user" }),
|
|
225
|
+
/**
|
|
226
|
+
* Callback URL to use as a redirect for email
|
|
227
|
+
* verification and for possible redirects
|
|
228
|
+
*/
|
|
151
229
|
callbackURL: z.string().meta({ description: "Callback URL to use as a redirect for email verification" }).optional(),
|
|
230
|
+
/**
|
|
231
|
+
* If this is false, the session will not be remembered
|
|
232
|
+
* @default true
|
|
233
|
+
*/
|
|
152
234
|
rememberMe: z.boolean().meta({ description: "If this is false, the session will not be remembered. Default is `true`." }).default(true).optional()
|
|
153
235
|
}),
|
|
154
236
|
metadata: {
|
|
@@ -237,7 +319,7 @@ const signInEmail = () => createAuthEndpoint("/sign-in/email", {
|
|
|
237
319
|
user: user.user,
|
|
238
320
|
url,
|
|
239
321
|
token
|
|
240
|
-
}, ctx.request
|
|
322
|
+
}, safeCloneRequest(ctx.request)));
|
|
241
323
|
}
|
|
242
324
|
throw APIError.from("FORBIDDEN", BASE_ERROR_CODES.EMAIL_NOT_VERIFIED);
|
|
243
325
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import * as better_call0 from "better-call";
|
|
2
|
-
|
|
3
1
|
//#region src/api/routes/sign-out.d.ts
|
|
4
|
-
declare const signOut:
|
|
2
|
+
declare const signOut: import("better-call").StrictEndpoint<"/sign-out", {
|
|
5
3
|
method: "POST";
|
|
6
4
|
operationId: string;
|
|
7
5
|
requireHeaders: true;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { AdditionalUserFieldsInput, User } from "../../types/models.mjs";
|
|
2
|
+
import "../../types/index.mjs";
|
|
2
3
|
import { BetterAuthOptions } 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/sign-up.d.ts
|
|
7
|
-
declare const signUpEmail: <O extends BetterAuthOptions>() =>
|
|
6
|
+
declare const signUpEmail: <O extends BetterAuthOptions>() => import("better-call").StrictEndpoint<"/sign-up/email", {
|
|
8
7
|
method: "POST";
|
|
9
8
|
operationId: string;
|
|
10
|
-
use: ((inputContext:
|
|
9
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>)[];
|
|
11
10
|
body: z.ZodIntersection<z.ZodObject<{
|
|
12
11
|
name: z.ZodString;
|
|
13
12
|
email: z.ZodEmail;
|
|
@@ -2,6 +2,7 @@ import { isAPIError } from "../../utils/is-api-error.mjs";
|
|
|
2
2
|
import { formCsrfMiddleware } from "../middlewares/origin-check.mjs";
|
|
3
3
|
import { buildSyntheticUserOutput, parseUserInput, parseUserOutput } from "../../db/schema.mjs";
|
|
4
4
|
import { setSessionCookie } from "../../cookies/index.mjs";
|
|
5
|
+
import { safeCloneRequest } from "../../utils/request.mjs";
|
|
5
6
|
import { createEmailVerificationToken } from "./email-verification.mjs";
|
|
6
7
|
import { runWithTransaction } from "@better-auth/core/context";
|
|
7
8
|
import { isDevelopment } from "@better-auth/core/env";
|
|
@@ -171,7 +172,7 @@ const signUpEmail = () => createAuthEndpoint("/sign-up/email", {
|
|
|
171
172
|
* between existing and non-existing emails.
|
|
172
173
|
*/
|
|
173
174
|
await ctx.context.password.hash(password);
|
|
174
|
-
if (ctx.context.options.emailAndPassword?.onExistingUserSignUp) await ctx.context.runInBackgroundOrAwait(ctx.context.options.emailAndPassword.onExistingUserSignUp({ user: dbUser.user }, ctx.request
|
|
175
|
+
if (ctx.context.options.emailAndPassword?.onExistingUserSignUp) await ctx.context.runInBackgroundOrAwait(ctx.context.options.emailAndPassword.onExistingUserSignUp({ user: dbUser.user }, safeCloneRequest(ctx.request)));
|
|
175
176
|
const now = /* @__PURE__ */ new Date();
|
|
176
177
|
const generatedId = ctx.context.generateId({ model: "user" }) || generateId();
|
|
177
178
|
const coreFields = {
|
|
@@ -246,7 +247,7 @@ const signUpEmail = () => createAuthEndpoint("/sign-up/email", {
|
|
|
246
247
|
user: createdUser,
|
|
247
248
|
url,
|
|
248
249
|
token
|
|
249
|
-
}, ctx.request
|
|
250
|
+
}, safeCloneRequest(ctx.request)));
|
|
250
251
|
}
|
|
251
252
|
if (shouldSkipAutoSignIn) return ctx.json({
|
|
252
253
|
token: null,
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { AdditionalSessionFieldsInput } from "../../types/models.mjs";
|
|
2
|
+
import "../../types/index.mjs";
|
|
2
3
|
import { BetterAuthOptions } 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/update-session.d.ts
|
|
7
|
-
declare const updateSession: <O extends BetterAuthOptions>() =>
|
|
6
|
+
declare const updateSession: <O extends BetterAuthOptions>() => import("better-call").StrictEndpoint<"/update-session", {
|
|
8
7
|
method: "POST";
|
|
9
8
|
operationId: string;
|
|
10
9
|
body: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
11
|
-
use: ((inputContext:
|
|
10
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
12
11
|
session: {
|
|
13
12
|
session: Record<string, any> & {
|
|
14
13
|
id: string;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { AdditionalUserFieldsInput } from "../../types/models.mjs";
|
|
2
|
+
import "../../types/index.mjs";
|
|
2
3
|
import { BetterAuthOptions } 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/update-user.d.ts
|
|
7
|
-
declare const updateUser: <O extends BetterAuthOptions>() =>
|
|
6
|
+
declare const updateUser: <O extends BetterAuthOptions>() => import("better-call").StrictEndpoint<"/update-user", {
|
|
8
7
|
method: "POST";
|
|
9
8
|
operationId: string;
|
|
10
9
|
body: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
11
|
-
use: ((inputContext:
|
|
10
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
12
11
|
session: {
|
|
13
12
|
session: Record<string, any> & {
|
|
14
13
|
id: string;
|
|
@@ -84,7 +83,7 @@ declare const updateUser: <O extends BetterAuthOptions>() => better_call0.Strict
|
|
|
84
83
|
}, {
|
|
85
84
|
status: boolean;
|
|
86
85
|
}>;
|
|
87
|
-
declare const changePassword:
|
|
86
|
+
declare const changePassword: import("better-call").StrictEndpoint<"/change-password", {
|
|
88
87
|
method: "POST";
|
|
89
88
|
operationId: string;
|
|
90
89
|
body: z.ZodObject<{
|
|
@@ -92,7 +91,7 @@ declare const changePassword: better_call0.StrictEndpoint<"/change-password", {
|
|
|
92
91
|
currentPassword: z.ZodString;
|
|
93
92
|
revokeOtherSessions: z.ZodOptional<z.ZodBoolean>;
|
|
94
93
|
}, z.core.$strip>;
|
|
95
|
-
use: ((inputContext:
|
|
94
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
96
95
|
session: {
|
|
97
96
|
session: Record<string, any> & {
|
|
98
97
|
id: string;
|
|
@@ -200,12 +199,12 @@ declare const changePassword: better_call0.StrictEndpoint<"/change-password", {
|
|
|
200
199
|
image?: string | null | undefined;
|
|
201
200
|
};
|
|
202
201
|
}>;
|
|
203
|
-
declare const setPassword:
|
|
202
|
+
declare const setPassword: import("better-call").StrictEndpoint<string, {
|
|
204
203
|
method: "POST";
|
|
205
204
|
body: z.ZodObject<{
|
|
206
205
|
newPassword: z.ZodString;
|
|
207
206
|
}, z.core.$strip>;
|
|
208
|
-
use: ((inputContext:
|
|
207
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
209
208
|
session: {
|
|
210
209
|
session: Record<string, any> & {
|
|
211
210
|
id: string;
|
|
@@ -231,9 +230,9 @@ declare const setPassword: better_call0.StrictEndpoint<string, {
|
|
|
231
230
|
}, {
|
|
232
231
|
status: boolean;
|
|
233
232
|
}>;
|
|
234
|
-
declare const deleteUser:
|
|
233
|
+
declare const deleteUser: import("better-call").StrictEndpoint<"/delete-user", {
|
|
235
234
|
method: "POST";
|
|
236
|
-
use: ((inputContext:
|
|
235
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
237
236
|
session: {
|
|
238
237
|
session: Record<string, any> & {
|
|
239
238
|
id: string;
|
|
@@ -318,13 +317,13 @@ declare const deleteUser: better_call0.StrictEndpoint<"/delete-user", {
|
|
|
318
317
|
success: boolean;
|
|
319
318
|
message: string;
|
|
320
319
|
}>;
|
|
321
|
-
declare const deleteUserCallback:
|
|
320
|
+
declare const deleteUserCallback: import("better-call").StrictEndpoint<"/delete-user/callback", {
|
|
322
321
|
method: "GET";
|
|
323
322
|
query: z.ZodObject<{
|
|
324
323
|
token: z.ZodString;
|
|
325
324
|
callbackURL: z.ZodOptional<z.ZodString>;
|
|
326
325
|
}, z.core.$strip>;
|
|
327
|
-
use: ((inputContext:
|
|
326
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>)[];
|
|
328
327
|
metadata: {
|
|
329
328
|
openapi: {
|
|
330
329
|
description: string;
|
|
@@ -358,13 +357,13 @@ declare const deleteUserCallback: better_call0.StrictEndpoint<"/delete-user/call
|
|
|
358
357
|
success: boolean;
|
|
359
358
|
message: string;
|
|
360
359
|
}>;
|
|
361
|
-
declare const changeEmail:
|
|
360
|
+
declare const changeEmail: import("better-call").StrictEndpoint<"/change-email", {
|
|
362
361
|
method: "POST";
|
|
363
362
|
body: z.ZodObject<{
|
|
364
363
|
newEmail: z.ZodEmail;
|
|
365
364
|
callbackURL: z.ZodOptional<z.ZodString>;
|
|
366
365
|
}, z.core.$strip>;
|
|
367
|
-
use: ((inputContext:
|
|
366
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
368
367
|
session: {
|
|
369
368
|
session: Record<string, any> & {
|
|
370
369
|
id: string;
|
|
@@ -76,8 +76,18 @@ const changePassword = createAuthEndpoint("/change-password", {
|
|
|
76
76
|
method: "POST",
|
|
77
77
|
operationId: "changePassword",
|
|
78
78
|
body: z.object({
|
|
79
|
+
/**
|
|
80
|
+
* The new password to set
|
|
81
|
+
*/
|
|
79
82
|
newPassword: z.string().meta({ description: "The new password to set" }),
|
|
83
|
+
/**
|
|
84
|
+
* The current password of the user
|
|
85
|
+
*/
|
|
80
86
|
currentPassword: z.string().meta({ description: "The current password is required" }),
|
|
87
|
+
/**
|
|
88
|
+
* revoke all sessions that are not the
|
|
89
|
+
* current one logged in by the user
|
|
90
|
+
*/
|
|
81
91
|
revokeOtherSessions: z.boolean().meta({ description: "Must be a boolean value" }).optional()
|
|
82
92
|
}),
|
|
83
93
|
use: [sensitiveSessionMiddleware],
|
|
@@ -184,7 +194,11 @@ const changePassword = createAuthEndpoint("/change-password", {
|
|
|
184
194
|
});
|
|
185
195
|
const setPassword = createAuthEndpoint.serverOnly({
|
|
186
196
|
method: "POST",
|
|
187
|
-
body: z.object({
|
|
197
|
+
body: z.object({
|
|
198
|
+
/**
|
|
199
|
+
* The new password to set
|
|
200
|
+
*/
|
|
201
|
+
newPassword: z.string().meta({ description: "The new password to set is required" }) }),
|
|
188
202
|
use: [sensitiveSessionMiddleware]
|
|
189
203
|
}, async (ctx) => {
|
|
190
204
|
const { newPassword } = ctx.body;
|
|
@@ -216,8 +230,19 @@ const deleteUser = createAuthEndpoint("/delete-user", {
|
|
|
216
230
|
method: "POST",
|
|
217
231
|
use: [sensitiveSessionMiddleware],
|
|
218
232
|
body: z.object({
|
|
233
|
+
/**
|
|
234
|
+
* The callback URL to redirect to after the user is deleted
|
|
235
|
+
* this is only used on delete user callback
|
|
236
|
+
*/
|
|
219
237
|
callbackURL: z.string().meta({ description: "The callback URL to redirect to after the user is deleted" }).optional(),
|
|
238
|
+
/**
|
|
239
|
+
* The password of the user. If the password isn't provided, session freshness
|
|
240
|
+
* will be checked.
|
|
241
|
+
*/
|
|
220
242
|
password: z.string().meta({ description: "The password of the user is required to delete the user" }).optional(),
|
|
243
|
+
/**
|
|
244
|
+
* The token to delete the user. If the token is provided, the user will be deleted
|
|
245
|
+
*/
|
|
221
246
|
token: z.string().meta({ description: "The token to delete the user is required" }).optional()
|
|
222
247
|
}),
|
|
223
248
|
metadata: { openapi: {
|
package/dist/auth/full.d.mts
CHANGED
package/dist/auth/minimal.d.mts
CHANGED
package/dist/client/config.d.mts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { BetterAuthClientOptions, ClientAtomListener } from "@better-auth/core";
|
|
2
2
|
import { WritableAtom } from "nanostores";
|
|
3
|
-
import * as _better_fetch_fetch0 from "@better-fetch/fetch";
|
|
4
|
-
|
|
5
3
|
//#region src/client/config.d.ts
|
|
6
4
|
declare const getClientConfig: (options?: BetterAuthClientOptions | undefined, loadEnv?: boolean | undefined) => {
|
|
7
5
|
readonly baseURL: string;
|
|
@@ -9,21 +7,21 @@ declare const getClientConfig: (options?: BetterAuthClientOptions | undefined, l
|
|
|
9
7
|
pluginsAtoms: Record<string, WritableAtom<any>>;
|
|
10
8
|
pluginPathMethods: Record<string, "GET" | "POST">;
|
|
11
9
|
atomListeners: ClientAtomListener[];
|
|
12
|
-
$fetch:
|
|
13
|
-
plugins: (
|
|
10
|
+
$fetch: import("@better-fetch/fetch").BetterFetch<{
|
|
11
|
+
plugins: (import("@better-fetch/fetch").BetterFetchPlugin<Record<string, any>> | {
|
|
14
12
|
id: string;
|
|
15
13
|
name: string;
|
|
16
14
|
hooks: {
|
|
17
|
-
onSuccess(context:
|
|
15
|
+
onSuccess(context: import("@better-fetch/fetch").SuccessContext<any>): void;
|
|
18
16
|
};
|
|
19
17
|
} | {
|
|
20
18
|
id: string;
|
|
21
19
|
name: string;
|
|
22
20
|
hooks: {
|
|
23
|
-
onSuccess: ((context:
|
|
24
|
-
onError: ((context:
|
|
25
|
-
onRequest: (<T extends Record<string, any>>(context:
|
|
26
|
-
onResponse: ((context:
|
|
21
|
+
onSuccess: ((context: import("@better-fetch/fetch").SuccessContext<any>) => Promise<void> | void) | undefined;
|
|
22
|
+
onError: ((context: import("@better-fetch/fetch").ErrorContext) => Promise<void> | void) | undefined;
|
|
23
|
+
onRequest: (<T extends Record<string, any>>(context: import("@better-fetch/fetch").RequestContext<T>) => Promise<import("@better-fetch/fetch").RequestContext | void> | import("@better-fetch/fetch").RequestContext | void) | undefined;
|
|
24
|
+
onResponse: ((context: import("@better-fetch/fetch").ResponseContext) => Promise<Response | void | import("@better-fetch/fetch").ResponseContext> | Response | import("@better-fetch/fetch").ResponseContext | void) | undefined;
|
|
27
25
|
};
|
|
28
26
|
})[];
|
|
29
27
|
priority?: RequestPriority | undefined;
|
|
@@ -38,12 +36,12 @@ declare const getClientConfig: (options?: BetterAuthClientOptions | undefined, l
|
|
|
38
36
|
referrerPolicy?: ReferrerPolicy | undefined;
|
|
39
37
|
signal?: (AbortSignal | null) | undefined;
|
|
40
38
|
window?: null | undefined;
|
|
41
|
-
onRetry?: ((response:
|
|
39
|
+
onRetry?: ((response: import("@better-fetch/fetch").ResponseContext) => Promise<void> | void) | undefined;
|
|
42
40
|
hookOptions?: {
|
|
43
41
|
cloneResponse?: boolean;
|
|
44
42
|
} | undefined;
|
|
45
43
|
timeout?: number | undefined;
|
|
46
|
-
customFetchImpl:
|
|
44
|
+
customFetchImpl: import("@better-fetch/fetch").FetchEsque;
|
|
47
45
|
baseURL: string;
|
|
48
46
|
throw?: boolean | undefined;
|
|
49
47
|
auth?: ({
|
|
@@ -69,10 +67,10 @@ declare const getClientConfig: (options?: BetterAuthClientOptions | undefined, l
|
|
|
69
67
|
params?: any;
|
|
70
68
|
duplex?: "full" | "half" | undefined;
|
|
71
69
|
jsonParser: (text: string) => Promise<any> | any;
|
|
72
|
-
retry?:
|
|
70
|
+
retry?: import("@better-fetch/fetch").RetryOptions | undefined;
|
|
73
71
|
retryAttempt?: number | undefined;
|
|
74
|
-
output?: (
|
|
75
|
-
errorSchema?:
|
|
72
|
+
output?: (import("@better-fetch/fetch").StandardSchemaV1 | typeof Blob | typeof File) | undefined;
|
|
73
|
+
errorSchema?: import("@better-fetch/fetch").StandardSchemaV1 | undefined;
|
|
76
74
|
disableValidation?: boolean | undefined;
|
|
77
75
|
disableSignal?: boolean | undefined;
|
|
78
76
|
}, unknown, unknown, {}>;
|
package/dist/client/config.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { getBaseURL } from "../utils/url.mjs";
|
|
|
2
2
|
import { parseJSON } from "./parser.mjs";
|
|
3
3
|
import { redirectPlugin } from "./fetch-plugins.mjs";
|
|
4
4
|
import { getSessionAtom } from "./session-atom.mjs";
|
|
5
|
-
import { defu } from "defu";
|
|
5
|
+
import { defu as defu$1 } from "defu";
|
|
6
6
|
import { createFetch } from "@better-fetch/fetch";
|
|
7
7
|
//#region src/client/config.ts
|
|
8
8
|
const resolvePublicAuthUrl = (basePath) => {
|
|
@@ -88,7 +88,7 @@ const getClientConfig = (options, loadEnv) => {
|
|
|
88
88
|
},
|
|
89
89
|
atoms: pluginsAtoms
|
|
90
90
|
};
|
|
91
|
-
for (const plugin of plugins) if (plugin.getActions) pluginsActions = defu(plugin.getActions?.($fetch, $store, options) ?? {}, pluginsActions);
|
|
91
|
+
for (const plugin of plugins) if (plugin.getActions) pluginsActions = defu$1(plugin.getActions?.($fetch, $store, options) ?? {}, pluginsActions);
|
|
92
92
|
return {
|
|
93
93
|
get baseURL() {
|
|
94
94
|
return baseURL;
|
package/dist/client/index.d.mts
CHANGED
|
@@ -11,17 +11,18 @@ import { SessionRefreshOptions, createSessionRefreshManager } from "./session-re
|
|
|
11
11
|
import { AuthClient, createAuthClient } from "./vanilla.mjs";
|
|
12
12
|
import { AccessControl, ArrayElement, ExactRoleStatements, Role, RoleAuthorizeRequest, RoleInput, RoleStatements, Statements, SubArray, Subset } from "../plugins/access/types.mjs";
|
|
13
13
|
import { AuthorizeResponse, createAccessControl, role } from "../plugins/access/access.mjs";
|
|
14
|
+
import "../plugins/access/index.mjs";
|
|
14
15
|
import { OrganizationOptions } from "../plugins/organization/types.mjs";
|
|
15
16
|
import { InferInvitation, InferMember, InferOrganization, InferOrganizationRolesFromOption, InferOrganizationZodRolesFromOption, InferTeam, Invitation, InvitationInput, InvitationStatus, Member, MemberInput, Organization, OrganizationInput, OrganizationRole, OrganizationSchema, Team, TeamInput, TeamMember, TeamMemberInput, defaultRolesSchema, invitationSchema, invitationStatus, memberSchema, organizationRoleSchema, organizationSchema, roleSchema, teamMemberSchema, teamSchema } from "../plugins/organization/schema.mjs";
|
|
16
17
|
import { getOrgAdapter } from "../plugins/organization/adapter.mjs";
|
|
17
18
|
import { hasPermission } from "../plugins/organization/has-permission.mjs";
|
|
18
19
|
import { DefaultOrganizationPlugin, DynamicAccessControlEndpoints, OrganizationCreator, OrganizationEndpoints, OrganizationPlugin, TeamEndpoints, organization, parseRoles } from "../plugins/organization/organization.mjs";
|
|
20
|
+
import "../plugins/organization/index.mjs";
|
|
19
21
|
import { BetterAuthOptions, BetterAuthPlugin } from "@better-auth/core";
|
|
20
22
|
import { DBPrimitive } from "@better-auth/core/db";
|
|
21
|
-
export * from "@better-auth/core/db";
|
|
22
|
-
export * from "nanostores";
|
|
23
|
-
export * from "@better-fetch/fetch";
|
|
24
|
-
|
|
23
|
+
export type * from "@better-auth/core/db";
|
|
24
|
+
export type * from "nanostores";
|
|
25
|
+
export type * from "@better-fetch/fetch";
|
|
25
26
|
//#region src/client/index.d.ts
|
|
26
27
|
declare const InferPlugin: <T extends BetterAuthPlugin>() => {
|
|
27
28
|
id: "infer-server-plugin";
|
|
@@ -32,4 +33,4 @@ declare function InferAuth<O extends {
|
|
|
32
33
|
options: BetterAuthOptions;
|
|
33
34
|
}>(): O["options"];
|
|
34
35
|
//#endregion
|
|
35
|
-
export { AccessControl, ArrayElement, AuthClient, AuthQueryAtom, AuthQueryState, AuthorizeResponse, BetterAuthClientOptions, BetterAuthClientPlugin, BroadcastChannel, BroadcastListener, BroadcastMessage, CamelCase, ClientAtomListener, ClientStore, type DBPrimitive, DefaultOrganizationPlugin, DynamicAccessControlEndpoints, ExactRoleStatements, ExtractPluginField, type FocusListener, type FocusManager, HasRequiredKeys, InferActions, InferAdditionalFromClient, InferAuth, InferClientAPI, InferCtx, InferErrorCodes, InferInvitation, InferMember, InferOrganization, InferOrganizationRolesFromOption, InferOrganizationZodRolesFromOption, InferPlugin, InferPluginFieldFromTuple, InferRoute, InferRoutes, InferSessionFromClient, InferSessionUpdateCtx, InferSignUpEmailCtx, InferTeam, InferUserFromClient, InferUserUpdateCtx, Invitation, InvitationInput, InvitationStatus, IsAny, IsSignal, Member, MemberInput, MergeRoutes, type OnlineListener, type OnlineManager, Organization, OrganizationCreator, OrganizationEndpoints, OrganizationInput, OrganizationOptions, OrganizationPlugin, OrganizationRole, OrganizationSchema, OverrideMerge, PathToObject, Prettify, PrettifyDeep, ProxyRequest, RequiredKeysOf, Role, RoleAuthorizeRequest, RoleInput, RoleStatements, SessionQueryParams, SessionRefreshOptions, Statements, StripEmptyObjects, SubArray, Subset, Team, TeamEndpoints, TeamInput, TeamMember, TeamMemberInput, type UnionToIntersection, createAccessControl, createAuthClient, createSessionRefreshManager, defaultRolesSchema, getGlobalBroadcastChannel, getOrgAdapter, hasPermission, invitationSchema, invitationStatus, isJsonEqual, kBroadcastChannel, kFocusManager, kOnlineManager, memberSchema, organization, organizationRoleSchema, organizationSchema, parseJSON, parseRoles, role, roleSchema, teamMemberSchema, teamSchema, useAuthQuery, withEquality };
|
|
36
|
+
export { type AccessControl, type ArrayElement, AuthClient, AuthQueryAtom, AuthQueryState, type AuthorizeResponse, type BetterAuthClientOptions, type BetterAuthClientPlugin, BroadcastChannel, BroadcastListener, BroadcastMessage, type CamelCase, type ClientAtomListener, type ClientStore, type DBPrimitive, type DefaultOrganizationPlugin, type DynamicAccessControlEndpoints, type ExactRoleStatements, type ExtractPluginField, type FocusListener, type FocusManager, type HasRequiredKeys, InferActions, InferAdditionalFromClient, InferAuth, InferClientAPI, type InferCtx, InferErrorCodes, type InferInvitation, type InferMember, type InferOrganization, type InferOrganizationRolesFromOption, type InferOrganizationZodRolesFromOption, InferPlugin, type InferPluginFieldFromTuple, type InferRoute, type InferRoutes, InferSessionFromClient, type InferSessionUpdateCtx, type InferSignUpEmailCtx, type InferTeam, InferUserFromClient, type InferUserUpdateCtx, type Invitation, type InvitationInput, type InvitationStatus, type IsAny, IsSignal, type Member, type MemberInput, type MergeRoutes, type OnlineListener, type OnlineManager, type Organization, type OrganizationCreator, type OrganizationEndpoints, type OrganizationInput, type OrganizationOptions, type OrganizationPlugin, type OrganizationRole, type OrganizationSchema, type OverrideMerge, type PathToObject, type Prettify, type PrettifyDeep, type ProxyRequest, type RequiredKeysOf, type Role, type RoleAuthorizeRequest, type RoleInput, type RoleStatements, SessionQueryParams, SessionRefreshOptions, type Statements, type StripEmptyObjects, type SubArray, type Subset, type Team, type TeamEndpoints, type TeamInput, type TeamMember, type TeamMemberInput, type UnionToIntersection, type createAccessControl, createAuthClient, createSessionRefreshManager, type defaultRolesSchema, getGlobalBroadcastChannel, type getOrgAdapter, type hasPermission, type invitationSchema, type invitationStatus, isJsonEqual, kBroadcastChannel, kFocusManager, kOnlineManager, type memberSchema, type organization, type organizationRoleSchema, type organizationSchema, parseJSON, type parseRoles, type role, type roleSchema, type teamMemberSchema, type teamSchema, useAuthQuery, withEquality };
|
|
@@ -5,15 +5,14 @@ import { useStore } from "./lynx-store.mjs";
|
|
|
5
5
|
import { BetterAuthClientOptions } from "@better-auth/core";
|
|
6
6
|
import { BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
7
7
|
import { BetterFetchError, BetterFetchResponse } from "@better-fetch/fetch";
|
|
8
|
-
export * from "nanostores";
|
|
9
|
-
export * from "@better-fetch/fetch";
|
|
10
|
-
|
|
8
|
+
export type * from "nanostores";
|
|
9
|
+
export type * from "@better-fetch/fetch";
|
|
11
10
|
//#region src/client/lynx/index.d.ts
|
|
12
11
|
type InferResolvedHooks<O extends BetterAuthClientOptions> = O extends {
|
|
13
12
|
plugins: Array<infer Plugin>;
|
|
14
13
|
} ? UnionToIntersection<Plugin extends {
|
|
15
14
|
getAtoms?: infer GetAtoms;
|
|
16
|
-
} ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => ReturnType<Atoms[key]["get"]
|
|
15
|
+
} ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => ReturnType<Atoms[key]["get"]>; } : {} : {} : {}> : {};
|
|
17
16
|
type ClientConfig = ReturnType<typeof getClientConfig>;
|
|
18
17
|
type ClientSession<Option extends BetterAuthClientOptions> = InferClientAPI<Option> extends {
|
|
19
18
|
getSession: () => Promise<infer Res>;
|
|
@@ -39,4 +38,4 @@ type LynxAuthClient<Option extends BetterAuthClientOptions> = UnionToIntersectio
|
|
|
39
38
|
};
|
|
40
39
|
declare function createAuthClient<Option extends BetterAuthClientOptions>(options?: Option | undefined): LynxAuthClient<Option>;
|
|
41
40
|
//#endregion
|
|
42
|
-
export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, LynxAuthClient, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, type UnionToIntersection, createAuthClient, useStore };
|
|
41
|
+
export { type ExtractPluginField, type HasRequiredKeys, type InferPluginFieldFromTuple, type IsAny, LynxAuthClient, type OverrideMerge, type Prettify, type PrettifyDeep, type RequiredKeysOf, type StripEmptyObjects, type UnionToIntersection, createAuthClient, useStore };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Store, StoreValue } from "nanostores";
|
|
2
2
|
import { DependencyList } from "@lynx-js/react";
|
|
3
|
-
|
|
4
3
|
//#region src/client/lynx/lynx-store.d.ts
|
|
5
4
|
type StoreKeys<T> = T extends {
|
|
6
5
|
setKey: (k: infer K, v: any) => unknown;
|
|
@@ -43,4 +42,4 @@ interface UseStoreOptions<SomeStore> {
|
|
|
43
42
|
*/
|
|
44
43
|
declare function useStore<SomeStore extends Store>(store: SomeStore, options?: UseStoreOptions<SomeStore>): StoreValue<SomeStore>;
|
|
45
44
|
//#endregion
|
|
46
|
-
export { useStore };
|
|
45
|
+
export { UseStoreOptions, useStore };
|
package/dist/client/parser.d.mts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
//#region src/client/parser.d.ts
|
|
2
2
|
type ParseOptions = {
|
|
3
|
-
/** Throw errors instead of returning the original value */
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
/** Throw errors instead of returning the original value */
|
|
4
|
+
strict?: boolean | undefined;
|
|
5
|
+
/** Log warnings when suspicious patterns are detected */
|
|
6
|
+
warnings?: boolean | undefined;
|
|
7
|
+
/** Custom reviver function */
|
|
8
|
+
reviver?: ((key: string, value: any) => any) | undefined;
|
|
9
|
+
/** Automatically convert ISO date strings to Date objects */
|
|
6
10
|
parseDates?: boolean | undefined;
|
|
7
11
|
};
|
|
8
12
|
declare function parseJSON<T = unknown>(value: unknown, options?: ParseOptions): T;
|