better-auth 1.7.11 → 1.7.13
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 +5 -10
- package/dist/api/dispatch.d.mts +3 -5
- package/dist/api/dispatch.mjs +6 -4
- package/dist/api/index.d.mts +506 -508
- package/dist/api/index.mjs +35 -34
- package/dist/api/middlewares/authorization.d.mts +15 -12
- 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 +4 -7
- package/dist/api/routes/account.d.mts +11 -15
- package/dist/api/routes/account.mjs +7 -4
- package/dist/api/routes/callback.d.mts +2 -5
- package/dist/api/routes/callback.mjs +14 -53
- package/dist/api/routes/email-verification.d.mts +7 -12
- package/dist/api/routes/error.d.mts +2 -5
- package/dist/api/routes/index.d.mts +2 -1
- package/dist/api/routes/ok.d.mts +2 -5
- package/dist/api/routes/password.d.mts +8 -11
- package/dist/api/routes/password.mjs +3 -2
- package/dist/api/routes/session.d.mts +26 -29
- package/dist/api/routes/session.mjs +1 -1
- package/dist/api/routes/sign-in.d.mts +4 -6
- package/dist/api/routes/sign-out.d.mts +2 -5
- package/dist/api/routes/sign-up.d.mts +4 -6
- package/dist/api/routes/update-session.d.mts +4 -6
- package/dist/api/routes/update-user.d.mts +14 -16
- package/dist/api/routes/update-user.mjs +1 -1
- package/dist/api/state/oauth.d.mts +0 -3
- package/dist/api/state/oauth.mjs +2 -1
- package/dist/auth/full.d.mts +3 -4
- package/dist/auth/minimal.d.mts +3 -3
- package/dist/client/broadcast-channel.d.mts +6 -7
- package/dist/client/config.d.mts +15 -19
- package/dist/client/config.mjs +2 -2
- package/dist/client/equality.d.mts +3 -5
- package/dist/client/focus-manager.d.mts +4 -5
- package/dist/client/index.d.mts +8 -7
- package/dist/client/lynx/index.d.mts +6 -7
- package/dist/client/lynx/index.mjs +3 -2
- package/dist/client/lynx/lynx-store.d.mts +3 -4
- package/dist/client/online-manager.d.mts +4 -5
- package/dist/client/parser.d.mts +9 -5
- package/dist/client/path-to-object.d.mts +13 -14
- package/dist/client/plugins/index.d.mts +1 -1
- package/dist/client/plugins/infer-plugin.d.mts +2 -4
- package/dist/client/query.d.mts +4 -6
- package/dist/client/react/index.d.mts +6 -7
- package/dist/client/react/index.mjs +3 -2
- package/dist/client/react/react-store.d.mts +3 -4
- package/dist/client/session-atom.d.mts +4 -4
- package/dist/client/session-refresh.d.mts +3 -5
- package/dist/client/solid/index.d.mts +6 -7
- package/dist/client/solid/index.mjs +3 -2
- package/dist/client/svelte/index.d.mts +6 -7
- package/dist/client/svelte/index.mjs +3 -2
- package/dist/client/types.d.mts +11 -11
- package/dist/client/vanilla.d.mts +4 -5
- package/dist/client/vanilla.mjs +3 -2
- package/dist/client/vue/index.d.mts +6 -7
- package/dist/client/vue/index.mjs +3 -2
- package/dist/context/create-context.mjs +7 -7
- package/dist/context/helpers.mjs +9 -7
- package/dist/cookies/cookie-utils.d.mts +13 -13
- package/dist/cookies/cookie-utils.mjs +1 -3
- package/dist/cookies/index.d.mts +17 -18
- package/dist/cookies/index.mjs +11 -7
- package/dist/cookies/jwt.mjs +2 -1
- package/dist/cookies/session-store.d.mts +6 -5
- package/dist/cookies/session-store.mjs +3 -2
- package/dist/crypto/buffer.d.mts +2 -3
- package/dist/crypto/index.d.mts +9 -16
- package/dist/crypto/index.mjs +2 -1
- package/dist/crypto/jwt.d.mts +5 -7
- package/dist/crypto/jwt.mjs +2 -1
- package/dist/crypto/password.d.mts +1 -5
- package/dist/crypto/random.d.mts +2 -3
- package/dist/db/adapter-base.d.mts +2 -4
- package/dist/db/adapter-kysely.d.mts +2 -4
- package/dist/db/field-converter.d.mts +3 -5
- package/dist/db/field.d.mts +11 -12
- package/dist/db/get-migration.d.mts +4 -8
- package/dist/db/get-migration.mjs +22 -22
- package/dist/db/get-schema.d.mts +2 -4
- package/dist/db/internal-adapter.d.mts +2 -4
- package/dist/db/internal-adapter.mjs +6 -4
- package/dist/db/revoke-unproven-account-access.d.mts +3 -4
- package/dist/db/schema.d.mts +15 -16
- package/dist/db/schema.mjs +6 -3
- package/dist/db/to-zod.d.mts +5 -9
- package/dist/db/with-hooks.d.mts +3 -5
- package/dist/index.d.mts +4 -3
- package/dist/integrations/next-js.d.mts +7 -11
- package/dist/integrations/node.d.mts +5 -7
- package/dist/integrations/node.mjs +4 -2
- package/dist/integrations/solid-start.d.mts +2 -3
- package/dist/integrations/svelte-kit.d.mts +6 -14
- package/dist/integrations/tanstack-start-solid.d.mts +4 -8
- package/dist/integrations/tanstack-start.d.mts +4 -8
- package/dist/oauth2/callback.mjs +68 -0
- package/dist/oauth2/link-account.d.mts +5 -11
- package/dist/oauth2/link-account.mjs +12 -6
- package/dist/oauth2/state.d.mts +5 -7
- package/dist/oauth2/state.mjs +1 -1
- package/dist/oauth2/utils.d.mts +4 -6
- package/dist/package.mjs +1 -1
- package/dist/plugins/access/access.d.mts +4 -6
- package/dist/plugins/access/index.mjs +1 -2
- package/dist/plugins/access/types.d.mts +12 -14
- package/dist/plugins/additional-fields/client.d.mts +2 -4
- package/dist/plugins/admin/access/index.mjs +1 -2
- package/dist/plugins/admin/access/statement.d.mts +7 -7
- package/dist/plugins/admin/admin.d.mts +122 -128
- package/dist/plugins/admin/client.d.mts +32 -32
- package/dist/plugins/admin/client.mjs +1 -1
- package/dist/plugins/admin/error-codes.d.mts +25 -28
- package/dist/plugins/admin/index.d.mts +1 -1
- package/dist/plugins/admin/index.mjs +1 -2
- package/dist/plugins/admin/schema.d.mts +3 -4
- package/dist/plugins/admin/types.d.mts +8 -8
- package/dist/plugins/anonymous/client.d.mts +10 -12
- package/dist/plugins/anonymous/client.mjs +1 -1
- package/dist/plugins/anonymous/error-codes.d.mts +10 -13
- package/dist/plugins/anonymous/index.d.mts +17 -21
- package/dist/plugins/anonymous/schema.d.mts +2 -3
- package/dist/plugins/anonymous/types.d.mts +5 -6
- package/dist/plugins/bearer/index.d.mts +7 -11
- package/dist/plugins/captcha/constants.d.mts +2 -3
- package/dist/plugins/captcha/index.d.mts +6 -9
- package/dist/plugins/captcha/types.d.mts +11 -13
- package/dist/plugins/custom-session/client.d.mts +2 -4
- package/dist/plugins/custom-session/index.d.mts +10 -16
- package/dist/plugins/device-authorization/client.d.mts +2 -4
- package/dist/plugins/device-authorization/index.d.mts +39 -44
- package/dist/plugins/device-authorization/index.mjs +10 -9
- package/dist/plugins/device-authorization/routes.d.mts +7 -5
- package/dist/plugins/device-authorization/routes.mjs +6 -5
- package/dist/plugins/device-authorization/schema.d.mts +2 -3
- package/dist/plugins/email-otp/client.d.mts +5 -7
- package/dist/plugins/email-otp/client.mjs +1 -1
- package/dist/plugins/email-otp/error-codes.d.mts +5 -8
- package/dist/plugins/email-otp/index.d.mts +69 -76
- package/dist/plugins/email-otp/otp-token.mjs +19 -7
- package/dist/plugins/email-otp/types.d.mts +2 -4
- package/dist/plugins/generic-oauth/index.d.mts +9 -13
- package/dist/plugins/generic-oauth/index.mjs +6 -4
- package/dist/plugins/generic-oauth/providers/auth0.d.mts +3 -5
- package/dist/plugins/generic-oauth/providers/gumroad.d.mts +3 -5
- package/dist/plugins/generic-oauth/providers/hubspot.d.mts +3 -5
- package/dist/plugins/generic-oauth/providers/hubspot.mjs +2 -1
- package/dist/plugins/generic-oauth/providers/index.d.mts +2 -1
- package/dist/plugins/generic-oauth/providers/keycloak.d.mts +3 -5
- package/dist/plugins/generic-oauth/providers/line.d.mts +3 -5
- package/dist/plugins/generic-oauth/providers/microsoft-entra-id.d.mts +3 -5
- package/dist/plugins/generic-oauth/providers/okta.d.mts +3 -5
- package/dist/plugins/generic-oauth/providers/patreon.d.mts +3 -5
- package/dist/plugins/generic-oauth/providers/slack.d.mts +3 -5
- package/dist/plugins/generic-oauth/providers/yandex.d.mts +3 -5
- package/dist/plugins/generic-oauth/types.d.mts +6 -7
- package/dist/plugins/haveibeenpwned/index.d.mts +7 -11
- package/dist/plugins/index.d.mts +4 -1
- package/dist/plugins/jwt/adapter.mjs +14 -3
- package/dist/plugins/jwt/client.d.mts +2 -3
- package/dist/plugins/jwt/cookie-cache.mjs +3 -8
- package/dist/plugins/jwt/index.d.mts +11 -14
- package/dist/plugins/jwt/index.mjs +3 -3
- package/dist/plugins/jwt/schema.d.mts +2 -3
- package/dist/plugins/jwt/sign.d.mts +9 -8
- package/dist/plugins/jwt/sign.mjs +6 -5
- package/dist/plugins/jwt/types.d.mts +7 -8
- package/dist/plugins/jwt/utils.d.mts +6 -9
- package/dist/plugins/jwt/verify.d.mts +2 -4
- package/dist/plugins/jwt/verify.mjs +10 -4
- package/dist/plugins/last-login-method/client.d.mts +3 -4
- package/dist/plugins/last-login-method/index.d.mts +5 -9
- package/dist/plugins/last-login-method/index.mjs +1 -1
- package/dist/plugins/magic-link/client.d.mts +2 -4
- package/dist/plugins/magic-link/index.d.mts +7 -10
- package/dist/plugins/magic-link/index.mjs +20 -17
- package/dist/plugins/multi-session/client.d.mts +3 -5
- package/dist/plugins/multi-session/client.mjs +1 -1
- package/dist/plugins/multi-session/error-codes.d.mts +3 -6
- package/dist/plugins/multi-session/index.d.mts +10 -14
- package/dist/plugins/oauth-popup/client.d.mts +11 -17
- package/dist/plugins/oauth-popup/client.mjs +6 -4
- package/dist/plugins/oauth-popup/constants.d.mts +5 -6
- package/dist/plugins/oauth-popup/error-codes.d.mts +6 -9
- package/dist/plugins/oauth-popup/index.d.mts +11 -15
- package/dist/plugins/oauth-popup/index.mjs +8 -7
- package/dist/plugins/oauth-popup/types.d.mts +4 -6
- package/dist/plugins/oauth-proxy/index.d.mts +11 -15
- package/dist/plugins/oauth-proxy/index.mjs +24 -48
- package/dist/plugins/one-tap/client.d.mts +6 -9
- package/dist/plugins/one-tap/index.d.mts +4 -7
- package/dist/plugins/one-time-token/client.d.mts +2 -3
- package/dist/plugins/one-time-token/index.d.mts +8 -10
- package/dist/plugins/open-api/generator.d.mts +8 -8
- package/dist/plugins/open-api/generator.mjs +5 -5
- package/dist/plugins/open-api/index.d.mts +5 -7
- package/dist/plugins/organization/access/index.mjs +1 -2
- package/dist/plugins/organization/access/statement.d.mts +8 -8
- package/dist/plugins/organization/adapter.d.mts +60 -87
- package/dist/plugins/organization/adapter.mjs +14 -10
- package/dist/plugins/organization/client.d.mts +108 -107
- package/dist/plugins/organization/client.mjs +9 -5
- package/dist/plugins/organization/error-codes.d.mts +61 -64
- package/dist/plugins/organization/has-permission.d.mts +2 -4
- 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 +20 -20
- package/dist/plugins/organization/organization.mjs +13 -8
- package/dist/plugins/organization/permission.d.mts +4 -5
- package/dist/plugins/organization/routes/crud-access-control.d.mts +28 -28
- package/dist/plugins/organization/routes/crud-invites.d.mts +64 -65
- package/dist/plugins/organization/routes/crud-invites.mjs +21 -18
- package/dist/plugins/organization/routes/crud-members.d.mts +53 -56
- package/dist/plugins/organization/routes/crud-members.mjs +23 -21
- package/dist/plugins/organization/routes/crud-org.d.mts +63 -65
- package/dist/plugins/organization/routes/crud-org.mjs +4 -2
- package/dist/plugins/organization/routes/crud-team.d.mts +65 -66
- package/dist/plugins/organization/routes/crud-team.mjs +4 -2
- package/dist/plugins/organization/schema.d.mts +33 -33
- package/dist/plugins/organization/schema.mjs +1 -1
- package/dist/plugins/organization/types.d.mts +16 -17
- package/dist/plugins/phone-number/client.d.mts +14 -16
- package/dist/plugins/phone-number/client.mjs +1 -1
- package/dist/plugins/phone-number/error-codes.d.mts +14 -17
- package/dist/plugins/phone-number/index.d.mts +48 -54
- package/dist/plugins/phone-number/schema.d.mts +2 -3
- package/dist/plugins/phone-number/types.d.mts +4 -5
- package/dist/plugins/siwe/client.d.mts +2 -4
- package/dist/plugins/siwe/index.d.mts +7 -9
- package/dist/plugins/siwe/index.mjs +1 -1
- package/dist/plugins/siwe/parse-message.mjs +1 -3
- package/dist/plugins/siwe/schema.d.mts +3 -4
- package/dist/plugins/siwe/types.d.mts +4 -4
- package/dist/plugins/test-utils/auth-helpers.mjs +4 -2
- package/dist/plugins/test-utils/index.d.mts +3 -5
- package/dist/plugins/test-utils/types.d.mts +7 -7
- package/dist/plugins/two-factor/backup-codes/index.d.mts +11 -14
- package/dist/plugins/two-factor/backup-codes/index.mjs +12 -6
- package/dist/plugins/two-factor/client.d.mts +16 -19
- package/dist/plugins/two-factor/client.mjs +1 -1
- package/dist/plugins/two-factor/constant.mjs +1 -1
- package/dist/plugins/two-factor/error-code.d.mts +15 -18
- package/dist/plugins/two-factor/index.d.mts +31 -35
- package/dist/plugins/two-factor/index.mjs +6 -3
- package/dist/plugins/two-factor/otp/index.d.mts +5 -8
- package/dist/plugins/two-factor/otp/index.mjs +159 -154
- package/dist/plugins/two-factor/schema.d.mts +2 -3
- package/dist/plugins/two-factor/totp/index.d.mts +7 -10
- package/dist/plugins/two-factor/totp/index.mjs +153 -148
- package/dist/plugins/two-factor/types.d.mts +6 -7
- package/dist/plugins/username/client.d.mts +12 -14
- package/dist/plugins/username/client.mjs +1 -1
- package/dist/plugins/username/error-codes.d.mts +11 -14
- package/dist/plugins/username/index.d.mts +26 -31
- package/dist/plugins/username/schema.d.mts +7 -10
- package/dist/state.d.mts +4 -5
- package/dist/test-utils/headers.d.mts +2 -3
- package/dist/test-utils/http-test-instance.d.mts +26 -29
- package/dist/test-utils/test-instance.d.mts +7 -6
- package/dist/test-utils/test-instance.mjs +4 -2
- package/dist/types/adapter.d.mts +1 -1
- package/dist/types/api.d.mts +4 -6
- package/dist/types/auth.d.mts +2 -4
- package/dist/types/helper.d.mts +11 -12
- package/dist/types/index.d.mts +2 -2
- package/dist/types/models.d.mts +4 -5
- package/dist/types/plugins.d.mts +7 -8
- package/dist/utils/hide-metadata.d.mts +2 -3
- package/dist/utils/index.d.mts +2 -1
- package/dist/utils/is-api-error.mjs +1 -2
- package/dist/utils/time.d.mts +4 -4
- package/dist/utils/url.d.mts +13 -15
- package/dist/utils/wildcard.mjs +5 -3
- package/package.json +13 -13
package/dist/state.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { GenericEndpointContext } from "@better-auth/core";
|
|
2
2
|
import { BetterAuthError } from "@better-auth/core/error";
|
|
3
3
|
import * as z from "zod";
|
|
4
|
-
|
|
5
4
|
//#region src/state.d.ts
|
|
6
5
|
declare const stateDataSchema: z.ZodObject<{
|
|
7
6
|
callbackURL: z.ZodString;
|
|
@@ -18,14 +17,14 @@ declare const stateDataSchema: z.ZodObject<{
|
|
|
18
17
|
idTokenNonce: z.ZodOptional<z.ZodString>;
|
|
19
18
|
serverContext: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
20
19
|
}, z.core.$loose>;
|
|
21
|
-
type StateData = z.infer<typeof stateDataSchema>;
|
|
22
|
-
declare function generateGenericState(c: GenericEndpointContext, stateData: StateData, settings?: {
|
|
20
|
+
export type StateData = z.infer<typeof stateDataSchema>;
|
|
21
|
+
export declare function generateGenericState(c: GenericEndpointContext, stateData: StateData, settings?: {
|
|
23
22
|
cookieName: string;
|
|
24
23
|
}): Promise<{
|
|
25
24
|
state: string;
|
|
26
25
|
codeVerifier: string;
|
|
27
26
|
}>;
|
|
28
|
-
declare function parseGenericState(c: GenericEndpointContext, state: string | undefined, settings?: {
|
|
27
|
+
export declare function parseGenericState(c: GenericEndpointContext, state: string | undefined, settings?: {
|
|
29
28
|
cookieName?: string;
|
|
30
29
|
skipStateCookieCheck?: boolean;
|
|
31
30
|
}): Promise<{
|
|
@@ -45,4 +44,4 @@ declare function parseGenericState(c: GenericEndpointContext, state: string | un
|
|
|
45
44
|
serverContext?: Record<string, unknown> | undefined;
|
|
46
45
|
}>;
|
|
47
46
|
//#endregion
|
|
48
|
-
export {
|
|
47
|
+
export {};
|
|
@@ -3,6 +3,5 @@
|
|
|
3
3
|
* converts set cookie containing headers to
|
|
4
4
|
* cookie containing headers
|
|
5
5
|
*/
|
|
6
|
-
declare function convertSetCookieToCookie(headers: Headers): Headers;
|
|
7
|
-
//#endregion
|
|
8
|
-
export { convertSetCookieToCookie };
|
|
6
|
+
export declare function convertSetCookieToCookie(headers: Headers): Headers;
|
|
7
|
+
//#endregion
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import { SessionQueryParams } from "../client/types.mjs";
|
|
2
2
|
import { Auth } from "../types/auth.mjs";
|
|
3
|
+
import "../index.mjs";
|
|
3
4
|
import { setCookieToHeader } from "../cookies/cookie-utils.mjs";
|
|
5
|
+
import "../cookies/index.mjs";
|
|
4
6
|
import { getTestInstance } from "./test-instance.mjs";
|
|
5
|
-
import * as _$_better_auth_core0 from "@better-auth/core";
|
|
6
7
|
import { BetterAuthClientOptions, BetterAuthOptions } from "@better-auth/core";
|
|
7
|
-
import * as _$_better_auth_core_db_adapter0 from "@better-auth/core/db/adapter";
|
|
8
|
-
import * as _$nanostores from "nanostores";
|
|
9
|
-
import * as _$_better_fetch_fetch0 from "@better-fetch/fetch";
|
|
10
8
|
import { IncomingMessage, ServerResponse, createServer } from "node:http";
|
|
11
9
|
import { AddressInfo } from "node:net";
|
|
12
|
-
|
|
13
10
|
//#region src/test-utils/http-test-instance.d.ts
|
|
14
11
|
/** A Node request handler that can be installed on an HTTP test listener. */
|
|
15
|
-
type HttpTestRequestHandler = (req: IncomingMessage, res: ServerResponse) => unknown | Promise<unknown>;
|
|
12
|
+
export type HttpTestRequestHandler = (req: IncomingMessage, res: ServerResponse) => unknown | Promise<unknown>;
|
|
16
13
|
/** A bound HTTP test listener whose request handler can be installed later. */
|
|
17
|
-
type HttpTestServer = {
|
|
14
|
+
export type HttpTestServer = {
|
|
18
15
|
url: string;
|
|
19
16
|
address: AddressInfo;
|
|
20
17
|
server: ReturnType<typeof createServer>;
|
|
@@ -22,7 +19,7 @@ type HttpTestServer = {
|
|
|
22
19
|
close: () => Promise<void>;
|
|
23
20
|
};
|
|
24
21
|
type GetTestInstanceConfig = NonNullable<Parameters<typeof getTestInstance>[1]>;
|
|
25
|
-
type HttpTestInstanceConfig<C extends BetterAuthClientOptions> = Omit<GetTestInstanceConfig, "port" | "clientOptions"> & {
|
|
22
|
+
export type HttpTestInstanceConfig<C extends BetterAuthClientOptions> = Omit<GetTestInstanceConfig, "port" | "clientOptions"> & {
|
|
26
23
|
clientOptions?: C;
|
|
27
24
|
/**
|
|
28
25
|
* Customizes the HTTP request listener. Receives the bound auth instance
|
|
@@ -40,7 +37,7 @@ type HttpTestInstanceConfig<C extends BetterAuthClientOptions> = Omit<GetTestIns
|
|
|
40
37
|
* handler exists. This lets tests construct URL-sensitive applications only
|
|
41
38
|
* after the listener owns its port, then install the application handler.
|
|
42
39
|
*/
|
|
43
|
-
declare function createHttpTestServer(): Promise<HttpTestServer>;
|
|
40
|
+
export declare function createHttpTestServer(): Promise<HttpTestServer>;
|
|
44
41
|
/**
|
|
45
42
|
* Like `getTestInstance`, but bound to an actual HTTP listener on an
|
|
46
43
|
* OS-assigned port (`port: 0`). The discovered URL is fed back into the auth
|
|
@@ -55,37 +52,37 @@ declare function createHttpTestServer(): Promise<HttpTestServer>;
|
|
|
55
52
|
* `baseURL` passed in `options` is ignored — the URL must match the
|
|
56
53
|
* listener.
|
|
57
54
|
*/
|
|
58
|
-
declare function getHttpTestInstance<O extends Partial<BetterAuthOptions>, C extends BetterAuthClientOptions>(options?: O, config?: HttpTestInstanceConfig<C>): Promise<{
|
|
55
|
+
export declare function getHttpTestInstance<O extends Partial<BetterAuthOptions>, C extends BetterAuthClientOptions>(options?: O, config?: HttpTestInstanceConfig<C>): Promise<{
|
|
59
56
|
server: HttpTestServer;
|
|
60
57
|
baseURL: string;
|
|
61
58
|
port: number;
|
|
62
59
|
auth: Auth<O>;
|
|
63
60
|
client: {
|
|
64
61
|
hydrateSession(session: null): void;
|
|
65
|
-
useSession:
|
|
62
|
+
useSession: import("nanostores").Atom<{
|
|
66
63
|
data: never;
|
|
67
|
-
error:
|
|
64
|
+
error: import("@better-fetch/fetch").BetterFetchError | null;
|
|
68
65
|
isPending: boolean;
|
|
69
66
|
isRefetching: boolean;
|
|
70
67
|
refetch: (queryParams?: {
|
|
71
68
|
query?: SessionQueryParams;
|
|
72
69
|
} | undefined) => Promise<void>;
|
|
73
70
|
}>;
|
|
74
|
-
$fetch:
|
|
75
|
-
plugins: (
|
|
71
|
+
$fetch: import("@better-fetch/fetch").BetterFetch<{
|
|
72
|
+
plugins: (import("@better-fetch/fetch").BetterFetchPlugin<Record<string, any>> | {
|
|
76
73
|
id: string;
|
|
77
74
|
name: string;
|
|
78
75
|
hooks: {
|
|
79
|
-
onSuccess(context:
|
|
76
|
+
onSuccess(context: import("@better-fetch/fetch").SuccessContext<any>): void;
|
|
80
77
|
};
|
|
81
78
|
} | {
|
|
82
79
|
id: string;
|
|
83
80
|
name: string;
|
|
84
81
|
hooks: {
|
|
85
|
-
onSuccess: ((context:
|
|
86
|
-
onError: ((context:
|
|
87
|
-
onRequest: (<T extends Record<string, any>>(context:
|
|
88
|
-
onResponse: ((context:
|
|
82
|
+
onSuccess: ((context: import("@better-fetch/fetch").SuccessContext<any>) => Promise<void> | void) | undefined;
|
|
83
|
+
onError: ((context: import("@better-fetch/fetch").ErrorContext) => Promise<void> | void) | undefined;
|
|
84
|
+
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;
|
|
85
|
+
onResponse: ((context: import("@better-fetch/fetch").ResponseContext) => Promise<Response | void | import("@better-fetch/fetch").ResponseContext> | Response | import("@better-fetch/fetch").ResponseContext | void) | undefined;
|
|
89
86
|
};
|
|
90
87
|
})[];
|
|
91
88
|
cache?: RequestCache | undefined;
|
|
@@ -100,12 +97,12 @@ declare function getHttpTestInstance<O extends Partial<BetterAuthOptions>, C ext
|
|
|
100
97
|
referrerPolicy?: ReferrerPolicy | undefined;
|
|
101
98
|
signal?: AbortSignal | null;
|
|
102
99
|
window?: null | undefined;
|
|
103
|
-
onRetry?: ((response:
|
|
100
|
+
onRetry?: ((response: import("@better-fetch/fetch").ResponseContext) => Promise<void> | void) | undefined;
|
|
104
101
|
hookOptions?: {
|
|
105
102
|
cloneResponse?: boolean;
|
|
106
103
|
} | undefined;
|
|
107
104
|
timeout?: number | undefined;
|
|
108
|
-
customFetchImpl:
|
|
105
|
+
customFetchImpl: import("@better-fetch/fetch").FetchEsque;
|
|
109
106
|
baseURL: string;
|
|
110
107
|
throw?: boolean | undefined;
|
|
111
108
|
auth?: ({
|
|
@@ -131,17 +128,17 @@ declare function getHttpTestInstance<O extends Partial<BetterAuthOptions>, C ext
|
|
|
131
128
|
params?: any;
|
|
132
129
|
duplex?: "full" | "half" | undefined;
|
|
133
130
|
jsonParser: (text: string) => Promise<any> | any;
|
|
134
|
-
retry?:
|
|
131
|
+
retry?: import("@better-fetch/fetch").RetryOptions | undefined;
|
|
135
132
|
retryAttempt?: number | undefined;
|
|
136
|
-
output?: (
|
|
137
|
-
errorSchema?:
|
|
133
|
+
output?: (import("@better-fetch/fetch").StandardSchemaV1 | typeof Blob | typeof File) | undefined;
|
|
134
|
+
errorSchema?: import("@better-fetch/fetch").StandardSchemaV1 | undefined;
|
|
138
135
|
disableValidation?: boolean | undefined;
|
|
139
136
|
disableSignal?: boolean | undefined;
|
|
140
137
|
}, unknown, unknown, {}>;
|
|
141
138
|
$store: {
|
|
142
139
|
notify: (signal?: (Omit<string, "$sessionSignal"> | "$sessionSignal") | undefined) => void;
|
|
143
140
|
listen: (signal: Omit<string, "$sessionSignal"> | "$sessionSignal", listener: (value: boolean, oldValue?: boolean | undefined) => void) => void;
|
|
144
|
-
atoms: Record<string,
|
|
141
|
+
atoms: Record<string, import("nanostores").WritableAtom<any>>;
|
|
145
142
|
};
|
|
146
143
|
$Infer: {
|
|
147
144
|
Session: never;
|
|
@@ -405,9 +402,9 @@ declare function getHttpTestInstance<O extends Partial<BetterAuthOptions>, C ext
|
|
|
405
402
|
}>;
|
|
406
403
|
cookieSetter: typeof setCookieToHeader;
|
|
407
404
|
customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
408
|
-
sessionSetter: (headers: Headers) => (context:
|
|
409
|
-
db:
|
|
410
|
-
runWithUser: (email: string, password: string, fn: (headers: Headers) =>
|
|
405
|
+
sessionSetter: (headers: Headers) => (context: import("@better-fetch/fetch").SuccessContext) => void;
|
|
406
|
+
db: import("@better-auth/core/db/adapter").DBAdapter<BetterAuthOptions>;
|
|
407
|
+
runWithUser: (email: string, password: string, fn: (headers: Headers) => import("@better-auth/core").Awaitable<void>) => Promise<void>;
|
|
411
408
|
}>;
|
|
412
409
|
//#endregion
|
|
413
|
-
export {
|
|
410
|
+
export {};
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { Session, User } from "../types/models.mjs";
|
|
2
2
|
import { Auth } from "../types/auth.mjs";
|
|
3
|
+
import "../types/index.mjs";
|
|
4
|
+
import "../index.mjs";
|
|
3
5
|
import { AuthClient } from "../client/vanilla.mjs";
|
|
6
|
+
import "../client/index.mjs";
|
|
4
7
|
import { setCookieToHeader } from "../cookies/cookie-utils.mjs";
|
|
8
|
+
import "../cookies/index.mjs";
|
|
5
9
|
import { Awaitable, BetterAuthClientOptions, BetterAuthOptions } from "@better-auth/core";
|
|
6
|
-
import * as _$_better_auth_core_db_adapter0 from "@better-auth/core/db/adapter";
|
|
7
10
|
import { SuccessContext } from "@better-fetch/fetch";
|
|
8
|
-
|
|
9
11
|
//#region src/test-utils/test-instance.d.ts
|
|
10
|
-
declare function getTestInstance<O extends Partial<BetterAuthOptions>, C extends BetterAuthClientOptions>(options?: O | undefined, config?: {
|
|
12
|
+
export declare function getTestInstance<O extends Partial<BetterAuthOptions>, C extends BetterAuthClientOptions>(options?: O | undefined, config?: {
|
|
11
13
|
clientOptions?: C;
|
|
12
14
|
port?: number;
|
|
13
15
|
disableTestUser?: boolean;
|
|
@@ -49,8 +51,7 @@ declare function getTestInstance<O extends Partial<BetterAuthOptions>, C extends
|
|
|
49
51
|
cookieSetter: typeof setCookieToHeader;
|
|
50
52
|
customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
51
53
|
sessionSetter: (headers: Headers) => (context: SuccessContext) => void;
|
|
52
|
-
db:
|
|
54
|
+
db: import("@better-auth/core/db/adapter").DBAdapter<BetterAuthOptions>;
|
|
53
55
|
runWithUser: (email: string, password: string, fn: (headers: Headers) => Awaitable<void>) => Promise<void>;
|
|
54
56
|
}>;
|
|
55
|
-
//#endregion
|
|
56
|
-
export { getTestInstance };
|
|
57
|
+
//#endregion
|
|
@@ -180,7 +180,8 @@ async function getTestInstance(options, config) {
|
|
|
180
180
|
email: testUser.email,
|
|
181
181
|
password: testUser.password,
|
|
182
182
|
fetchOptions: { onSuccess(context) {
|
|
183
|
-
const
|
|
183
|
+
const header = context.response.headers.get("set-cookie");
|
|
184
|
+
const signedCookie = parseSetCookieHeader(header || "").get("better-auth.session_token")?.value;
|
|
184
185
|
headers.set("cookie", `better-auth.session_token=${signedCookie}`);
|
|
185
186
|
} }
|
|
186
187
|
});
|
|
@@ -202,7 +203,8 @@ async function getTestInstance(options, config) {
|
|
|
202
203
|
email,
|
|
203
204
|
password,
|
|
204
205
|
fetchOptions: { onSuccess(context) {
|
|
205
|
-
const
|
|
206
|
+
const header = context.response.headers.get("set-cookie");
|
|
207
|
+
const signedCookie = parseSetCookieHeader(header || "").get("better-auth.session_token")?.value;
|
|
206
208
|
headers.set("cookie", `better-auth.session_token=${signedCookie}`);
|
|
207
209
|
} }
|
|
208
210
|
});
|
package/dist/types/adapter.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { DBAdapter as DBAdapter$1, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, JoinConfig, JoinOption, Where as Where$1 } from "@better-auth/core/db/adapter";
|
|
2
|
-
export {
|
|
2
|
+
export type { DBAdapter$1 as DBAdapter, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, JoinConfig, JoinOption, Where$1 as Where };
|
package/dist/types/api.d.mts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { PrettifyDeep, UnionToIntersection } from "./helper.mjs";
|
|
2
2
|
import { Endpoint } from "better-call";
|
|
3
|
-
|
|
4
3
|
//#region src/types/api.d.ts
|
|
5
|
-
type FilteredAPI<API> = Omit<API, API extends { [key in infer K]: Endpoint } ? K extends string ? K extends "getSession" ? never : API[K]["options"]["metadata"] extends {
|
|
4
|
+
export type FilteredAPI<API> = Omit<API, API extends { [key in infer K]: Endpoint; } ? K extends string ? K extends "getSession" ? never : API[K]["options"]["metadata"] extends {
|
|
6
5
|
isAction: false;
|
|
7
6
|
} | {
|
|
8
7
|
scope: "http";
|
|
9
8
|
} ? K : never : never : never>;
|
|
10
|
-
type InferSessionAPI<API> = API extends {
|
|
9
|
+
export type InferSessionAPI<API> = API extends {
|
|
11
10
|
[key: string]: infer E;
|
|
12
11
|
} ? UnionToIntersection<E extends Endpoint ? E["path"] extends "/get-session" ? {
|
|
13
12
|
getSession: <R extends boolean, H extends boolean = false>(context: {
|
|
@@ -23,6 +22,5 @@ type InferSessionAPI<API> = API extends {
|
|
|
23
22
|
response: PrettifyDeep<Awaited<ReturnType<E>>> | null;
|
|
24
23
|
}> : Promise<PrettifyDeep<Awaited<ReturnType<E>>> | null> : Promise<Response>;
|
|
25
24
|
} : never : never> : never;
|
|
26
|
-
type InferAPI<API> = InferSessionAPI<API> & FilteredAPI<API>;
|
|
27
|
-
//#endregion
|
|
28
|
-
export { FilteredAPI, InferAPI, InferSessionAPI };
|
|
25
|
+
export type InferAPI<API> = InferSessionAPI<API> & FilteredAPI<API>;
|
|
26
|
+
//#endregion
|
package/dist/types/auth.d.mts
CHANGED
|
@@ -4,9 +4,8 @@ import { InferPluginContext, InferPluginErrorCodes } from "./plugins.mjs";
|
|
|
4
4
|
import { router } from "../api/index.mjs";
|
|
5
5
|
import { AuthContext, BetterAuthOptions } from "@better-auth/core";
|
|
6
6
|
import { BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
7
|
-
|
|
8
7
|
//#region src/types/auth.d.ts
|
|
9
|
-
type Auth<Options extends BetterAuthOptions = BetterAuthOptions> = {
|
|
8
|
+
export type Auth<Options extends BetterAuthOptions = BetterAuthOptions> = {
|
|
10
9
|
handler: (request: Request) => Promise<Response>;
|
|
11
10
|
/**
|
|
12
11
|
* Alias for {@link Auth.handler}.
|
|
@@ -28,5 +27,4 @@ type Auth<Options extends BetterAuthOptions = BetterAuthOptions> = {
|
|
|
28
27
|
};
|
|
29
28
|
} & InferPluginTypes<Options>;
|
|
30
29
|
};
|
|
31
|
-
//#endregion
|
|
32
|
-
export { Auth };
|
|
30
|
+
//#endregion
|
package/dist/types/helper.d.mts
CHANGED
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
//#region src/types/helper.d.ts
|
|
2
|
-
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
3
|
-
type Prettify<T> = Omit<T, never>;
|
|
4
|
-
type PrettifyDeep<T> = { [K in keyof T]: T[K] extends ((...args: any[]) => any) ? T[K] : T[K] extends object ? T[K] extends Array<any> ? T[K] : T[K] extends Date ? T[K] : PrettifyDeep<T[K]> : T[K] } & {};
|
|
5
|
-
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
6
|
-
type RequiredKeysOf<BaseType extends object> = Exclude<{ [Key in keyof BaseType]: BaseType extends Record<Key, BaseType[Key]> ? Key : never }[keyof BaseType], undefined>;
|
|
7
|
-
type HasRequiredKeys<BaseType> = IsAny<BaseType> extends true ? false : [BaseType] extends [object] ? RequiredKeysOf<BaseType & object> extends never ? false : true : false;
|
|
8
|
-
type StripEmptyObjects<T extends object> = { [K in keyof T]: T[K] };
|
|
2
|
+
export type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
3
|
+
export type Prettify<T> = Omit<T, never>;
|
|
4
|
+
export type PrettifyDeep<T> = { [K in keyof T]: T[K] extends ((...args: any[]) => any) ? T[K] : T[K] extends object ? T[K] extends Array<any> ? T[K] : T[K] extends Date ? T[K] : PrettifyDeep<T[K]> : T[K]; } & {};
|
|
5
|
+
export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
6
|
+
export type RequiredKeysOf<BaseType extends object> = Exclude<{ [Key in keyof BaseType]: BaseType extends Record<Key, BaseType[Key]> ? Key : never; }[keyof BaseType], undefined>;
|
|
7
|
+
export type HasRequiredKeys<BaseType> = IsAny<BaseType> extends true ? false : [BaseType] extends [object] ? RequiredKeysOf<BaseType & object> extends never ? false : true : false;
|
|
8
|
+
export type StripEmptyObjects<T extends object> = { [K in keyof T]: T[K]; };
|
|
9
9
|
/**
|
|
10
10
|
* Object merge replacing `Base`'s keys with `Override`'s.
|
|
11
11
|
* The naive `Omit<Base, keyof Override> & Override` form breaks under generics.
|
|
12
12
|
*
|
|
13
13
|
* @see https://github.com/microsoft/TypeScript/issues/57466#issuecomment-1957988380
|
|
14
14
|
*/
|
|
15
|
-
type OverrideMerge<Base, Override> = Base extends unknown ? Override extends unknown ? Prettify<{ [K in keyof Base as K extends keyof Override ? never : K]: Base[K] } & Override> : never : never;
|
|
15
|
+
export type OverrideMerge<Base, Override> = Base extends unknown ? Override extends unknown ? Prettify<{ [K in keyof Base as K extends keyof Override ? never : K]: Base[K]; } & Override> : never : never;
|
|
16
16
|
/**
|
|
17
17
|
* Extracts a Record-typed field from a plugin, guarding against `any`.
|
|
18
18
|
*/
|
|
19
|
-
type ExtractPluginField<T, Field extends string> = IsAny<T> extends true ? {} : T extends { [K in Field]?: Record<string, any
|
|
19
|
+
export type ExtractPluginField<T, Field extends string> = IsAny<T> extends true ? {} : T extends { [K in Field]?: Record<string, any>; } ? T[Field] extends Record<string, any> ? T[Field] : {} : {};
|
|
20
20
|
/**
|
|
21
21
|
* Walks a plugin tuple with tail-recursive accumulator (TS 4.5+),
|
|
22
22
|
* extracting and intersecting the given field from each element.
|
|
23
23
|
*/
|
|
24
|
-
type InferPluginFieldFromTuple<T extends readonly unknown[], Field extends string, Acc = {}> = T extends readonly [infer Head, ...infer Tail] ? InferPluginFieldFromTuple<Tail, Field, Acc & ExtractPluginField<Head, Field>> : Acc;
|
|
25
|
-
//#endregion
|
|
26
|
-
export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, UnionToIntersection };
|
|
24
|
+
export type InferPluginFieldFromTuple<T extends readonly unknown[], Field extends string, Acc = {}> = T extends readonly [infer Head, ...infer Tail] ? InferPluginFieldFromTuple<Tail, Field, Acc & ExtractPluginField<Head, Field>> : Acc;
|
|
25
|
+
//#endregion
|
package/dist/types/index.d.mts
CHANGED
|
@@ -6,5 +6,5 @@ import { Account, AdditionalSessionFieldsInput, AdditionalUserFieldsInput, Infer
|
|
|
6
6
|
import { InferOptionSchema, InferPluginContext, InferPluginErrorCodes, InferPluginIDs } from "./plugins.mjs";
|
|
7
7
|
import { Auth } from "./auth.mjs";
|
|
8
8
|
import { BetterAuthAdvancedOptions, BetterAuthCookies, BetterAuthOptions, BetterAuthPlugin, BetterAuthRateLimitOptions, StoreIdentifierOption, UserProvisioningSource, ValidateUserInfoAction, ValidateUserInfoMethod, ValidateUserInfoOAuthInfo, ValidateUserInfoResult, ValidateUserInfoSSOInfo, ValidateUserInfoSource } from "@better-auth/core";
|
|
9
|
-
export * from "@better-auth/core/social-providers";
|
|
10
|
-
export { Account, AdditionalSessionFieldsInput, AdditionalUserFieldsInput, Auth, type BetterAuthAdvancedOptions, BetterAuthClientOptions, BetterAuthClientPlugin, type BetterAuthCookies, type BetterAuthOptions, type BetterAuthPlugin, type BetterAuthRateLimitOptions, ClientAtomListener, ClientStore, DBAdapter, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, ExtractPluginField, FilteredAPI, HasRequiredKeys, InferAPI, InferActions, InferAdditionalFromClient, InferClientAPI, InferErrorCodes, InferOptionSchema, InferPluginContext, InferPluginErrorCodes, InferPluginFieldFromTuple, InferPluginIDs, InferPluginTypes, InferSessionAPI, InferSessionFromClient, InferUserFromClient, IsAny, IsSignal, JoinConfig, JoinOption, OverrideMerge, Prettify, PrettifyDeep, RateLimit, RequiredKeysOf, Session, SessionQueryParams, type StoreIdentifierOption, StripEmptyObjects, UnionToIntersection, User, type UserProvisioningSource, type ValidateUserInfoAction, type ValidateUserInfoMethod, type ValidateUserInfoOAuthInfo, type ValidateUserInfoResult, type ValidateUserInfoSSOInfo, type ValidateUserInfoSource, Verification, Where };
|
|
9
|
+
export type * from "@better-auth/core/social-providers";
|
|
10
|
+
export { type Account, type AdditionalSessionFieldsInput, type AdditionalUserFieldsInput, type Auth, type BetterAuthAdvancedOptions, type BetterAuthClientOptions, type BetterAuthClientPlugin, type BetterAuthCookies, type BetterAuthOptions, type BetterAuthPlugin, type BetterAuthRateLimitOptions, type ClientAtomListener, type ClientStore, type DBAdapter, type DBAdapterInstance, type DBAdapterSchemaCreation, type DBTransactionAdapter, type ExtractPluginField, FilteredAPI, type HasRequiredKeys, InferAPI, InferActions, InferAdditionalFromClient, InferClientAPI, InferErrorCodes, type InferOptionSchema, type InferPluginContext, type InferPluginErrorCodes, type InferPluginFieldFromTuple, type InferPluginIDs, type InferPluginTypes, InferSessionAPI, InferSessionFromClient, InferUserFromClient, type IsAny, IsSignal, type JoinConfig, type JoinOption, type OverrideMerge, type Prettify, type PrettifyDeep, type RateLimit, type RequiredKeysOf, type Session, SessionQueryParams, type StoreIdentifierOption, type StripEmptyObjects, type UnionToIntersection, type User, type UserProvisioningSource, type ValidateUserInfoAction, type ValidateUserInfoMethod, type ValidateUserInfoOAuthInfo, type ValidateUserInfoResult, type ValidateUserInfoSSOInfo, type ValidateUserInfoSource, type Verification, type Where };
|
package/dist/types/models.d.mts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { ExtractPluginField, InferPluginFieldFromTuple, UnionToIntersection } from "./helper.mjs";
|
|
2
2
|
import { BetterAuthOptions } from "@better-auth/core";
|
|
3
3
|
import { Account, InferDBFieldsFromOptionsInput, InferDBFieldsFromPluginsInput, RateLimit, Session as Session$1, User as User$1, Verification } from "@better-auth/core/db";
|
|
4
|
-
|
|
5
4
|
//#region src/types/models.d.ts
|
|
6
|
-
type AdditionalUserFieldsInput<Options extends BetterAuthOptions> = InferDBFieldsFromPluginsInput<"user", Options["plugins"]> & InferDBFieldsFromOptionsInput<Options["user"]>;
|
|
7
|
-
type AdditionalSessionFieldsInput<Options extends BetterAuthOptions> = InferDBFieldsFromPluginsInput<"session", Options["plugins"]> & InferDBFieldsFromOptionsInput<Options["session"]>;
|
|
8
|
-
type InferPluginTypes<O extends BetterAuthOptions> = O["plugins"] extends readonly [unknown, ...unknown[]] ? InferPluginFieldFromTuple<O["plugins"], "$Infer"> : O["plugins"] extends Array<infer P> ? UnionToIntersection<ExtractPluginField<P, "$Infer">> : {};
|
|
5
|
+
export type AdditionalUserFieldsInput<Options extends BetterAuthOptions> = InferDBFieldsFromPluginsInput<"user", Options["plugins"]> & InferDBFieldsFromOptionsInput<Options["user"]>;
|
|
6
|
+
export type AdditionalSessionFieldsInput<Options extends BetterAuthOptions> = InferDBFieldsFromPluginsInput<"session", Options["plugins"]> & InferDBFieldsFromOptionsInput<Options["session"]>;
|
|
7
|
+
export type InferPluginTypes<O extends BetterAuthOptions> = O["plugins"] extends readonly [unknown, ...unknown[]] ? InferPluginFieldFromTuple<O["plugins"], "$Infer"> : O["plugins"] extends Array<infer P> ? UnionToIntersection<ExtractPluginField<P, "$Infer">> : {};
|
|
9
8
|
//#endregion
|
|
10
|
-
export {
|
|
9
|
+
export type { Account, RateLimit, Session$1 as Session, User$1 as User, Verification };
|
package/dist/types/plugins.d.mts
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { ExtractPluginField, InferPluginFieldFromTuple, UnionToIntersection } from "./helper.mjs";
|
|
2
2
|
import { AuthContext, BetterAuthOptions, BetterAuthPlugin } from "@better-auth/core";
|
|
3
3
|
import { BetterAuthPluginDBSchema } from "@better-auth/core/db";
|
|
4
|
-
|
|
5
4
|
//#region src/types/plugins.d.ts
|
|
6
|
-
type InferOptionSchema<S extends BetterAuthPluginDBSchema> = S extends Record<string, {
|
|
5
|
+
export type InferOptionSchema<S extends BetterAuthPluginDBSchema> = S extends Record<string, {
|
|
7
6
|
fields: infer Fields;
|
|
8
7
|
}> ? { [K in keyof S]?: {
|
|
9
8
|
modelName?: string | undefined;
|
|
10
|
-
fields?: { [P in keyof Fields]?: string } | undefined;
|
|
11
|
-
} } : never;
|
|
12
|
-
type InferPluginErrorCodes<O extends BetterAuthOptions> = O["plugins"] extends readonly [unknown, ...unknown[]] ? InferPluginFieldFromTuple<O["plugins"], "$ERROR_CODES"> : O["plugins"] extends Array<infer P> ? UnionToIntersection<ExtractPluginField<P, "$ERROR_CODES">> : {};
|
|
13
|
-
type InferPluginIDs<O extends BetterAuthOptions> = O["plugins"] extends Array<infer P> ? UnionToIntersection<P extends BetterAuthPlugin ? P["id"] : never> : never;
|
|
9
|
+
fields?: { [P in keyof Fields]?: string; } | undefined;
|
|
10
|
+
}; } : never;
|
|
11
|
+
export type InferPluginErrorCodes<O extends BetterAuthOptions> = O["plugins"] extends readonly [unknown, ...unknown[]] ? InferPluginFieldFromTuple<O["plugins"], "$ERROR_CODES"> : O["plugins"] extends Array<infer P> ? UnionToIntersection<ExtractPluginField<P, "$ERROR_CODES">> : {};
|
|
12
|
+
export type InferPluginIDs<O extends BetterAuthOptions> = O["plugins"] extends Array<infer P> ? UnionToIntersection<P extends BetterAuthPlugin ? P["id"] : never> : never;
|
|
14
13
|
type ExtractInitContext<P extends BetterAuthPlugin> = P["init"] extends ((...args: any[]) => infer R) ? Awaited<R> extends {
|
|
15
14
|
context?: infer C;
|
|
16
15
|
} ? C extends Record<string, any> ? Omit<C, keyof AuthContext> : {} : {} : {};
|
|
17
|
-
type InferPluginContext<O extends BetterAuthOptions> = O["plugins"] extends Array<infer P> ? UnionToIntersection<P extends BetterAuthPlugin ? ExtractInitContext<P> : {}> : {};
|
|
16
|
+
export type InferPluginContext<O extends BetterAuthOptions> = O["plugins"] extends Array<infer P> ? UnionToIntersection<P extends BetterAuthPlugin ? ExtractInitContext<P> : {}> : {};
|
|
18
17
|
//#endregion
|
|
19
|
-
export {
|
|
18
|
+
export {};
|
package/dist/utils/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GenerateStateOptions, generateIdTokenNonce, generateState, parseState } from "../oauth2/state.mjs";
|
|
2
2
|
import { StateData, generateGenericState, parseGenericState } from "../state.mjs";
|
|
3
3
|
import { HIDE_METADATA } from "./hide-metadata.mjs";
|
|
4
|
-
import { getBaseURL, getHost, getHostFromSource, getOrigin, getProtocol, getProtocolFromSource, isDynamicBaseURLConfig, isRequestLike, matchesHostPattern, resolveBaseURL, resolveDynamicBaseURL, trimTrailingSlashes } from "./url.mjs";
|
|
4
|
+
import { getBaseURL, getHost, getHostFromSource, getOrigin, getProtocol, getProtocolFromSource, isDynamicBaseURLConfig, isRequestLike, matchesHostPattern, resolveBaseURL, resolveDynamicBaseURL, trimTrailingSlashes } from "./url.mjs";
|
|
5
|
+
export { GenerateStateOptions, HIDE_METADATA, type StateData, generateGenericState, generateIdTokenNonce, generateState, getBaseURL, getHost, getHostFromSource, getOrigin, getProtocol, getProtocolFromSource, isDynamicBaseURLConfig, isRequestLike, matchesHostPattern, parseGenericState, parseState, resolveBaseURL, resolveDynamicBaseURL, trimTrailingSlashes };
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { isAPIError };
|
|
1
|
+
export { isAPIError } from "@better-auth/core/utils/is-api-error";
|
package/dist/utils/time.d.mts
CHANGED
|
@@ -15,7 +15,7 @@ type BaseTimeString = `${number}${UnitAnyCase}` | `${number} ${UnitAnyCase}`;
|
|
|
15
15
|
* A typed string representing a time duration.
|
|
16
16
|
* Supports formats like "7d", "30m", "1 hour", "2 hours ago", "-5m", etc.
|
|
17
17
|
*/
|
|
18
|
-
type TimeString = BaseTimeString | `${BaseTimeString}${Suffix}` | `${Prefix}${BaseTimeString}`;
|
|
18
|
+
export type TimeString = BaseTimeString | `${BaseTimeString}${Suffix}` | `${Prefix}${BaseTimeString}`;
|
|
19
19
|
/**
|
|
20
20
|
* Parse a time string and return the value in milliseconds.
|
|
21
21
|
*
|
|
@@ -29,7 +29,7 @@ type TimeString = BaseTimeString | `${BaseTimeString}${Suffix}` | `${Prefix}${Ba
|
|
|
29
29
|
* ms("30s") // 30000
|
|
30
30
|
* ms("2 hours ago") // -7200000
|
|
31
31
|
*/
|
|
32
|
-
declare function ms(value: TimeString): number;
|
|
32
|
+
export declare function ms(value: TimeString): number;
|
|
33
33
|
/**
|
|
34
34
|
* Parse a time string and return the value in seconds.
|
|
35
35
|
*
|
|
@@ -43,6 +43,6 @@ declare function ms(value: TimeString): number;
|
|
|
43
43
|
* sec("-30s") // -30
|
|
44
44
|
* sec("2 hours ago") // -7200
|
|
45
45
|
*/
|
|
46
|
-
declare function sec(value: TimeString): number;
|
|
46
|
+
export declare function sec(value: TimeString): number;
|
|
47
47
|
//#endregion
|
|
48
|
-
export {
|
|
48
|
+
export {};
|
package/dist/utils/url.d.mts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { BaseURLConfig, DynamicBaseURLConfig } from "@better-auth/core";
|
|
2
|
-
|
|
3
2
|
//#region src/utils/url.d.ts
|
|
4
|
-
declare function trimTrailingSlashes(value: string): string;
|
|
5
|
-
declare function getBaseURL(url?: string, path?: string, request?: Request, loadEnv?: boolean, trustedProxyHeaders?: boolean | undefined): string | undefined;
|
|
6
|
-
declare function getOrigin(url: string): string | null;
|
|
7
|
-
declare function getProtocol(url: string): string | null;
|
|
8
|
-
declare function getHost(url: string): string | null;
|
|
3
|
+
export declare function trimTrailingSlashes(value: string): string;
|
|
4
|
+
export declare function getBaseURL(url?: string, path?: string, request?: Request, loadEnv?: boolean, trustedProxyHeaders?: boolean | undefined): string | undefined;
|
|
5
|
+
export declare function getOrigin(url: string): string | null;
|
|
6
|
+
export declare function getProtocol(url: string): string | null;
|
|
7
|
+
export declare function getHost(url: string): string | null;
|
|
9
8
|
/**
|
|
10
9
|
* Checks if the baseURL config is a dynamic config object
|
|
11
10
|
*/
|
|
12
|
-
declare function isDynamicBaseURLConfig(config: BaseURLConfig | undefined): config is DynamicBaseURLConfig;
|
|
11
|
+
export declare function isDynamicBaseURLConfig(config: BaseURLConfig | undefined): config is DynamicBaseURLConfig;
|
|
13
12
|
/**
|
|
14
13
|
* Check if a value is a `Request`
|
|
15
14
|
* - `instanceof`: works for native Request instances
|
|
@@ -21,19 +20,19 @@ declare function isDynamicBaseURLConfig(config: BaseURLConfig | undefined): conf
|
|
|
21
20
|
* @param value The value to check
|
|
22
21
|
* @returns `true` if the value is a Request instance
|
|
23
22
|
*/
|
|
24
|
-
declare function isRequestLike(value: unknown): value is Request;
|
|
23
|
+
export declare function isRequestLike(value: unknown): value is Request;
|
|
25
24
|
/**
|
|
26
25
|
* Extracts the host from a `Request` or `Headers`.
|
|
27
26
|
* Honors `x-forwarded-host` only when `trustedProxyHeaders` is enabled,
|
|
28
27
|
* then falls back to the `host` header and finally the request URL.
|
|
29
28
|
*/
|
|
30
|
-
declare function getHostFromSource(source: Request | Headers, trustedProxyHeaders?: boolean): string | null;
|
|
29
|
+
export declare function getHostFromSource(source: Request | Headers, trustedProxyHeaders?: boolean): string | null;
|
|
31
30
|
/**
|
|
32
31
|
* Extracts the protocol from a `Request` or `Headers`.
|
|
33
32
|
* Honors `x-forwarded-proto` only when `trustedProxyHeaders` is enabled,
|
|
34
33
|
* then falls back to the request URL, then to "https".
|
|
35
34
|
*/
|
|
36
|
-
declare function getProtocolFromSource(source: Request | Headers, configProtocol?: "http" | "https" | "auto" | undefined, trustedProxyHeaders?: boolean): "http" | "https";
|
|
35
|
+
export declare function getProtocolFromSource(source: Request | Headers, configProtocol?: "http" | "https" | "auto" | undefined, trustedProxyHeaders?: boolean): "http" | "https";
|
|
37
36
|
/**
|
|
38
37
|
* Matches a hostname against a host pattern.
|
|
39
38
|
* Supports wildcard patterns like `*.vercel.app` or `preview-*.myapp.com`.
|
|
@@ -50,7 +49,7 @@ declare function getProtocolFromSource(source: Request | Headers, configProtocol
|
|
|
50
49
|
* matchesHostPattern("evil.com", "myapp.com") // false
|
|
51
50
|
* ```
|
|
52
51
|
*/
|
|
53
|
-
declare const matchesHostPattern: (host: string, pattern: string) => boolean;
|
|
52
|
+
export declare const matchesHostPattern: (host: string, pattern: string) => boolean;
|
|
54
53
|
/**
|
|
55
54
|
* Resolves the base URL from a dynamic config based on the incoming request.
|
|
56
55
|
* Validates the derived host against the allowedHosts allowlist.
|
|
@@ -61,7 +60,7 @@ declare const matchesHostPattern: (host: string, pattern: string) => boolean;
|
|
|
61
60
|
* @returns The resolved base URL with path
|
|
62
61
|
* @throws BetterAuthError if host is not in allowedHosts and no fallback is set
|
|
63
62
|
*/
|
|
64
|
-
declare function resolveDynamicBaseURL(config: DynamicBaseURLConfig, source: Request | Headers, basePath: string, trustedProxyHeaders?: boolean): string;
|
|
63
|
+
export declare function resolveDynamicBaseURL(config: DynamicBaseURLConfig, source: Request | Headers, basePath: string, trustedProxyHeaders?: boolean): string;
|
|
65
64
|
/**
|
|
66
65
|
* Resolves the base URL from any config type (static string or dynamic object).
|
|
67
66
|
* This is the main entry point for base URL resolution.
|
|
@@ -73,6 +72,5 @@ declare function resolveDynamicBaseURL(config: DynamicBaseURLConfig, source: Req
|
|
|
73
72
|
* @param trustedProxyHeaders Whether to trust proxy headers (for legacy behavior)
|
|
74
73
|
* @returns The resolved base URL with path
|
|
75
74
|
*/
|
|
76
|
-
declare function resolveBaseURL(config: BaseURLConfig | undefined, basePath: string, source?: Request | Headers, loadEnv?: boolean, trustedProxyHeaders?: boolean): string | undefined;
|
|
77
|
-
//#endregion
|
|
78
|
-
export { getBaseURL, getHost, getHostFromSource, getOrigin, getProtocol, getProtocolFromSource, isDynamicBaseURLConfig, isRequestLike, matchesHostPattern, resolveBaseURL, resolveDynamicBaseURL, trimTrailingSlashes };
|
|
75
|
+
export declare function resolveBaseURL(config: BaseURLConfig | undefined, basePath: string, source?: Request | Headers, loadEnv?: boolean, trustedProxyHeaders?: boolean): string | undefined;
|
|
76
|
+
//#endregion
|
package/dist/utils/wildcard.mjs
CHANGED
|
@@ -44,9 +44,11 @@ function transform(pattern, separator = true) {
|
|
|
44
44
|
const nextSegment = segments[s + 1];
|
|
45
45
|
let currentSeparator = "";
|
|
46
46
|
if (!segment && s > 0) continue;
|
|
47
|
-
if (separator)
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
if (separator) {
|
|
48
|
+
if (s === segments.length - 1) currentSeparator = optionalSeparator;
|
|
49
|
+
else if (nextSegment !== "**") currentSeparator = requiredSeparator;
|
|
50
|
+
else currentSeparator = "";
|
|
51
|
+
}
|
|
50
52
|
if (separator && segment === "**") {
|
|
51
53
|
if (currentSeparator) {
|
|
52
54
|
result += s === 0 ? "" : currentSeparator;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "better-auth",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.13",
|
|
4
4
|
"description": "The most comprehensive authentication framework for TypeScript.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -493,23 +493,23 @@
|
|
|
493
493
|
}
|
|
494
494
|
},
|
|
495
495
|
"dependencies": {
|
|
496
|
-
"@better-auth/utils": "0.5.
|
|
497
|
-
"@better-fetch/fetch": "1.3.
|
|
496
|
+
"@better-auth/utils": "0.5.1",
|
|
497
|
+
"@better-fetch/fetch": "1.3.3",
|
|
498
498
|
"@noble/ciphers": "^2.2.0",
|
|
499
499
|
"@noble/hashes": "^2.2.0",
|
|
500
|
-
"better-call": "1.4.
|
|
500
|
+
"better-call": "1.4.4",
|
|
501
501
|
"defu": "^6.1.4",
|
|
502
502
|
"jose": "^6.2.3",
|
|
503
503
|
"kysely": "^0.28.17 || ^0.29.0",
|
|
504
504
|
"nanostores": "^1.3.0",
|
|
505
505
|
"zod": "^4.5.4",
|
|
506
|
-
"@better-auth/core": "1.7.
|
|
507
|
-
"@better-auth/drizzle-adapter": "1.7.
|
|
508
|
-
"@better-auth/kysely-adapter": "1.7.
|
|
509
|
-
"@better-auth/memory-adapter": "1.7.
|
|
510
|
-
"@better-auth/mongo-adapter": "1.7.
|
|
511
|
-
"@better-auth/prisma-adapter": "1.7.
|
|
512
|
-
"@better-auth/telemetry": "1.7.
|
|
506
|
+
"@better-auth/core": "1.7.13",
|
|
507
|
+
"@better-auth/drizzle-adapter": "1.7.13",
|
|
508
|
+
"@better-auth/kysely-adapter": "1.7.13",
|
|
509
|
+
"@better-auth/memory-adapter": "1.7.13",
|
|
510
|
+
"@better-auth/mongo-adapter": "1.7.13",
|
|
511
|
+
"@better-auth/prisma-adapter": "1.7.13",
|
|
512
|
+
"@better-auth/telemetry": "1.7.13"
|
|
513
513
|
},
|
|
514
514
|
"devDependencies": {
|
|
515
515
|
"@lynx-js/react": "^0.121.2",
|
|
@@ -527,12 +527,12 @@
|
|
|
527
527
|
"botid": "^1.5.10",
|
|
528
528
|
"happy-dom": "^20.8.9",
|
|
529
529
|
"msw": "^2.14.6",
|
|
530
|
-
"next": "^16.
|
|
530
|
+
"next": "^16.4.2",
|
|
531
531
|
"oauth2-mock-server": "^9.0.0",
|
|
532
532
|
"react": "^19.2.7",
|
|
533
533
|
"react-dom": "^19.2.7",
|
|
534
534
|
"solid-js": "^1.9.11",
|
|
535
|
-
"tsdown": "0.
|
|
535
|
+
"tsdown": "0.23.1",
|
|
536
536
|
"type-fest": "^5.7.0",
|
|
537
537
|
"typescript": "^6.0.3",
|
|
538
538
|
"vitest": "^5.0.0",
|