better-auth 1.6.23 → 1.6.25
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 +1 -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 +6 -6
- package/dist/client/solid/index.mjs +4 -2
- 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 +10 -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 +40 -44
- 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 +2 -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 +0 -1
- 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 +4 -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 +6 -1
- 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 +11 -11
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import * as _better_auth_core_utils_error_codes0 from "@better-auth/core/utils/error-codes";
|
|
2
|
-
|
|
3
1
|
//#region src/plugins/two-factor/error-code.d.ts
|
|
4
2
|
declare const TWO_FACTOR_ERROR_CODES: {
|
|
5
|
-
OTP_NOT_ENABLED:
|
|
6
|
-
OTP_HAS_EXPIRED:
|
|
7
|
-
TOTP_NOT_ENABLED:
|
|
8
|
-
TWO_FACTOR_NOT_ENABLED:
|
|
9
|
-
BACKUP_CODES_NOT_ENABLED:
|
|
10
|
-
INVALID_BACKUP_CODE:
|
|
11
|
-
INVALID_CODE:
|
|
12
|
-
TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE:
|
|
13
|
-
ACCOUNT_TEMPORARILY_LOCKED:
|
|
14
|
-
INVALID_TWO_FACTOR_COOKIE:
|
|
3
|
+
OTP_NOT_ENABLED: import("@better-auth/core/utils/error-codes").RawError<"OTP_NOT_ENABLED">;
|
|
4
|
+
OTP_HAS_EXPIRED: import("@better-auth/core/utils/error-codes").RawError<"OTP_HAS_EXPIRED">;
|
|
5
|
+
TOTP_NOT_ENABLED: import("@better-auth/core/utils/error-codes").RawError<"TOTP_NOT_ENABLED">;
|
|
6
|
+
TWO_FACTOR_NOT_ENABLED: import("@better-auth/core/utils/error-codes").RawError<"TWO_FACTOR_NOT_ENABLED">;
|
|
7
|
+
BACKUP_CODES_NOT_ENABLED: import("@better-auth/core/utils/error-codes").RawError<"BACKUP_CODES_NOT_ENABLED">;
|
|
8
|
+
INVALID_BACKUP_CODE: import("@better-auth/core/utils/error-codes").RawError<"INVALID_BACKUP_CODE">;
|
|
9
|
+
INVALID_CODE: import("@better-auth/core/utils/error-codes").RawError<"INVALID_CODE">;
|
|
10
|
+
TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE: import("@better-auth/core/utils/error-codes").RawError<"TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE">;
|
|
11
|
+
ACCOUNT_TEMPORARILY_LOCKED: import("@better-auth/core/utils/error-codes").RawError<"ACCOUNT_TEMPORARILY_LOCKED">;
|
|
12
|
+
INVALID_TWO_FACTOR_COOKIE: import("@better-auth/core/utils/error-codes").RawError<"INVALID_TWO_FACTOR_COOKIE">;
|
|
15
13
|
};
|
|
16
14
|
//#endregion
|
|
17
15
|
export { TWO_FACTOR_ERROR_CODES };
|
|
@@ -4,11 +4,7 @@ import { TOTPOptions, totp2fa } from "./totp/index.mjs";
|
|
|
4
4
|
import { TwoFactorOptions, TwoFactorProvider, TwoFactorTable, UserWithTwoFactor } from "./types.mjs";
|
|
5
5
|
import { TWO_FACTOR_ERROR_CODES } from "./error-code.mjs";
|
|
6
6
|
import { twoFactorClient } from "./client.mjs";
|
|
7
|
-
import * as _better_auth_core0 from "@better-auth/core";
|
|
8
|
-
import * as _better_auth_core_utils_error_codes0 from "@better-auth/core/utils/error-codes";
|
|
9
|
-
import * as better_call0 from "better-call";
|
|
10
7
|
import * as z from "zod";
|
|
11
|
-
|
|
12
8
|
//#region src/plugins/two-factor/index.d.ts
|
|
13
9
|
declare module "@better-auth/core" {
|
|
14
10
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
@@ -36,7 +32,7 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
36
32
|
*
|
|
37
33
|
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#api-method-two-factor-enable)
|
|
38
34
|
*/
|
|
39
|
-
enableTwoFactor:
|
|
35
|
+
enableTwoFactor: import("better-call").StrictEndpoint<"/two-factor/enable", {
|
|
40
36
|
method: "POST";
|
|
41
37
|
body: z.ZodObject<{
|
|
42
38
|
password: z.ZodOptional<z.ZodString>;
|
|
@@ -45,7 +41,7 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
45
41
|
password: z.ZodString;
|
|
46
42
|
issuer: z.ZodOptional<z.ZodString>;
|
|
47
43
|
}, z.core.$strip>;
|
|
48
|
-
use: ((inputContext:
|
|
44
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
49
45
|
session: {
|
|
50
46
|
session: Record<string, any> & {
|
|
51
47
|
id: string;
|
|
@@ -118,14 +114,14 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
118
114
|
*
|
|
119
115
|
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#api-method-two-factor-disable)
|
|
120
116
|
*/
|
|
121
|
-
disableTwoFactor:
|
|
117
|
+
disableTwoFactor: import("better-call").StrictEndpoint<"/two-factor/disable", {
|
|
122
118
|
method: "POST";
|
|
123
119
|
body: z.ZodObject<{
|
|
124
120
|
password: z.ZodOptional<z.ZodString>;
|
|
125
121
|
}, z.core.$strip> | z.ZodObject<{
|
|
126
122
|
password: z.ZodString;
|
|
127
123
|
}, z.core.$strip>;
|
|
128
|
-
use: ((inputContext:
|
|
124
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
129
125
|
session: {
|
|
130
126
|
session: Record<string, any> & {
|
|
131
127
|
id: string;
|
|
@@ -174,7 +170,7 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
174
170
|
}, {
|
|
175
171
|
status: boolean;
|
|
176
172
|
}>;
|
|
177
|
-
verifyBackupCode:
|
|
173
|
+
verifyBackupCode: import("better-call").StrictEndpoint<"/two-factor/verify-backup-code", {
|
|
178
174
|
method: "POST";
|
|
179
175
|
body: z.ZodObject<{
|
|
180
176
|
code: z.ZodString;
|
|
@@ -285,14 +281,14 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
285
281
|
image?: string | null | undefined;
|
|
286
282
|
}) | UserWithTwoFactor;
|
|
287
283
|
}>;
|
|
288
|
-
generateBackupCodes:
|
|
284
|
+
generateBackupCodes: import("better-call").StrictEndpoint<"/two-factor/generate-backup-codes", {
|
|
289
285
|
method: "POST";
|
|
290
286
|
body: z.ZodObject<{
|
|
291
287
|
password: z.ZodOptional<z.ZodString>;
|
|
292
288
|
}, z.core.$strip> | z.ZodObject<{
|
|
293
289
|
password: z.ZodString;
|
|
294
290
|
}, z.core.$strip>;
|
|
295
|
-
use: ((inputContext:
|
|
291
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
296
292
|
session: {
|
|
297
293
|
session: Record<string, any> & {
|
|
298
294
|
id: string;
|
|
@@ -351,7 +347,7 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
351
347
|
status: boolean;
|
|
352
348
|
backupCodes: string[];
|
|
353
349
|
}>;
|
|
354
|
-
viewBackupCodes:
|
|
350
|
+
viewBackupCodes: import("better-call").StrictEndpoint<string, {
|
|
355
351
|
method: "POST";
|
|
356
352
|
body: z.ZodObject<{
|
|
357
353
|
userId: z.ZodCoercedString<unknown>;
|
|
@@ -360,7 +356,7 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
360
356
|
status: boolean;
|
|
361
357
|
backupCodes: string[];
|
|
362
358
|
}>;
|
|
363
|
-
sendTwoFactorOTP:
|
|
359
|
+
sendTwoFactorOTP: import("better-call").StrictEndpoint<"/two-factor/send-otp", {
|
|
364
360
|
method: "POST";
|
|
365
361
|
body: z.ZodOptional<z.ZodObject<{
|
|
366
362
|
trustDevice: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -391,7 +387,7 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
391
387
|
}, {
|
|
392
388
|
status: boolean;
|
|
393
389
|
}>;
|
|
394
|
-
verifyTwoFactorOTP:
|
|
390
|
+
verifyTwoFactorOTP: import("better-call").StrictEndpoint<"/two-factor/verify-otp", {
|
|
395
391
|
method: "POST";
|
|
396
392
|
body: z.ZodObject<{
|
|
397
393
|
code: z.ZodString;
|
|
@@ -480,7 +476,7 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
480
476
|
image?: string | null | undefined;
|
|
481
477
|
};
|
|
482
478
|
}>;
|
|
483
|
-
generateTOTP:
|
|
479
|
+
generateTOTP: import("better-call").StrictEndpoint<string, {
|
|
484
480
|
method: "POST";
|
|
485
481
|
body: z.ZodObject<{
|
|
486
482
|
secret: z.ZodString;
|
|
@@ -511,9 +507,9 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
511
507
|
}, {
|
|
512
508
|
code: string;
|
|
513
509
|
}>;
|
|
514
|
-
getTOTPURI:
|
|
510
|
+
getTOTPURI: import("better-call").StrictEndpoint<"/two-factor/get-totp-uri", {
|
|
515
511
|
method: "POST";
|
|
516
|
-
use: ((inputContext:
|
|
512
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
517
513
|
session: {
|
|
518
514
|
session: Record<string, any> & {
|
|
519
515
|
id: string;
|
|
@@ -567,7 +563,7 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
567
563
|
}, {
|
|
568
564
|
totpURI: string;
|
|
569
565
|
}>;
|
|
570
|
-
verifyTOTP:
|
|
566
|
+
verifyTOTP: import("better-call").StrictEndpoint<"/two-factor/verify-totp", {
|
|
571
567
|
method: "POST";
|
|
572
568
|
body: z.ZodObject<{
|
|
573
569
|
code: z.ZodString;
|
|
@@ -615,8 +611,8 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
615
611
|
options: NoInfer<O>;
|
|
616
612
|
hooks: {
|
|
617
613
|
after: {
|
|
618
|
-
matcher(context:
|
|
619
|
-
handler: (inputContext:
|
|
614
|
+
matcher(context: import("@better-auth/core").HookEndpointContext): boolean;
|
|
615
|
+
handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
620
616
|
twoFactorRedirect: boolean;
|
|
621
617
|
twoFactorMethods: string[];
|
|
622
618
|
} | undefined>;
|
|
@@ -684,17 +680,17 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
684
680
|
max: number;
|
|
685
681
|
}[];
|
|
686
682
|
$ERROR_CODES: {
|
|
687
|
-
OTP_NOT_ENABLED:
|
|
688
|
-
OTP_HAS_EXPIRED:
|
|
689
|
-
TOTP_NOT_ENABLED:
|
|
690
|
-
TWO_FACTOR_NOT_ENABLED:
|
|
691
|
-
BACKUP_CODES_NOT_ENABLED:
|
|
692
|
-
INVALID_BACKUP_CODE:
|
|
693
|
-
INVALID_CODE:
|
|
694
|
-
TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE:
|
|
695
|
-
ACCOUNT_TEMPORARILY_LOCKED:
|
|
696
|
-
INVALID_TWO_FACTOR_COOKIE:
|
|
683
|
+
OTP_NOT_ENABLED: import("@better-auth/core/utils/error-codes").RawError<"OTP_NOT_ENABLED">;
|
|
684
|
+
OTP_HAS_EXPIRED: import("@better-auth/core/utils/error-codes").RawError<"OTP_HAS_EXPIRED">;
|
|
685
|
+
TOTP_NOT_ENABLED: import("@better-auth/core/utils/error-codes").RawError<"TOTP_NOT_ENABLED">;
|
|
686
|
+
TWO_FACTOR_NOT_ENABLED: import("@better-auth/core/utils/error-codes").RawError<"TWO_FACTOR_NOT_ENABLED">;
|
|
687
|
+
BACKUP_CODES_NOT_ENABLED: import("@better-auth/core/utils/error-codes").RawError<"BACKUP_CODES_NOT_ENABLED">;
|
|
688
|
+
INVALID_BACKUP_CODE: import("@better-auth/core/utils/error-codes").RawError<"INVALID_BACKUP_CODE">;
|
|
689
|
+
INVALID_CODE: import("@better-auth/core/utils/error-codes").RawError<"INVALID_CODE">;
|
|
690
|
+
TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE: import("@better-auth/core/utils/error-codes").RawError<"TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE">;
|
|
691
|
+
ACCOUNT_TEMPORARILY_LOCKED: import("@better-auth/core/utils/error-codes").RawError<"ACCOUNT_TEMPORARILY_LOCKED">;
|
|
692
|
+
INVALID_TWO_FACTOR_COOKIE: import("@better-auth/core/utils/error-codes").RawError<"INVALID_TWO_FACTOR_COOKIE">;
|
|
697
693
|
};
|
|
698
694
|
};
|
|
699
695
|
//#endregion
|
|
700
|
-
export { BackupCodeOptions, OTPOptions, TOTPOptions, TWO_FACTOR_ERROR_CODES, TwoFactorOptions, TwoFactorProvider, TwoFactorTable, UserWithTwoFactor, backupCode2fa, encodeBackupCodes, generateBackupCodes, getBackupCodes, otp2fa, totp2fa, twoFactor, twoFactorClient, verifyBackupCode };
|
|
696
|
+
export { type BackupCodeOptions, type OTPOptions, type TOTPOptions, TWO_FACTOR_ERROR_CODES, TwoFactorOptions, TwoFactorProvider, TwoFactorTable, UserWithTwoFactor, type backupCode2fa, type encodeBackupCodes, type generateBackupCodes, type getBackupCodes, type otp2fa, type totp2fa, twoFactor, twoFactorClient, type verifyBackupCode };
|
|
@@ -51,6 +51,21 @@ const twoFactor = (options) => {
|
|
|
51
51
|
...totp.endpoints,
|
|
52
52
|
...otp.endpoints,
|
|
53
53
|
...backupCode.endpoints,
|
|
54
|
+
/**
|
|
55
|
+
* ### Endpoint
|
|
56
|
+
*
|
|
57
|
+
* POST `/two-factor/enable`
|
|
58
|
+
*
|
|
59
|
+
* ### API Methods
|
|
60
|
+
*
|
|
61
|
+
* **server:**
|
|
62
|
+
* `auth.api.enableTwoFactor`
|
|
63
|
+
*
|
|
64
|
+
* **client:**
|
|
65
|
+
* `authClient.twoFactor.enable`
|
|
66
|
+
*
|
|
67
|
+
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#api-method-two-factor-enable)
|
|
68
|
+
*/
|
|
54
69
|
enableTwoFactor: createAuthEndpoint("/two-factor/enable", {
|
|
55
70
|
method: "POST",
|
|
56
71
|
body: enableTwoFactorBodySchema,
|
|
@@ -135,6 +150,21 @@ const twoFactor = (options) => {
|
|
|
135
150
|
backupCodes: backupCodes.backupCodes
|
|
136
151
|
});
|
|
137
152
|
}),
|
|
153
|
+
/**
|
|
154
|
+
* ### Endpoint
|
|
155
|
+
*
|
|
156
|
+
* POST `/two-factor/disable`
|
|
157
|
+
*
|
|
158
|
+
* ### API Methods
|
|
159
|
+
*
|
|
160
|
+
* **server:**
|
|
161
|
+
* `auth.api.disableTwoFactor`
|
|
162
|
+
*
|
|
163
|
+
* **client:**
|
|
164
|
+
* `authClient.twoFactor.disable`
|
|
165
|
+
*
|
|
166
|
+
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#api-method-two-factor-disable)
|
|
167
|
+
*/
|
|
138
168
|
disableTwoFactor: createAuthEndpoint("/two-factor/disable", {
|
|
139
169
|
method: "POST",
|
|
140
170
|
body: disableTwoFactorBodySchema,
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { UserWithTwoFactor } from "../types.mjs";
|
|
2
2
|
import { Awaitable, GenericEndpointContext } from "@better-auth/core";
|
|
3
|
-
import * as better_call0 from "better-call";
|
|
4
3
|
import * as z from "zod";
|
|
5
|
-
|
|
6
4
|
//#region src/plugins/two-factor/otp/index.d.ts
|
|
7
5
|
interface OTPOptions {
|
|
8
6
|
/**
|
|
@@ -75,7 +73,7 @@ declare const otp2fa: (options?: OTPOptions | undefined) => {
|
|
|
75
73
|
*
|
|
76
74
|
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#api-method-two-factor-send-otp)
|
|
77
75
|
*/
|
|
78
|
-
sendTwoFactorOTP:
|
|
76
|
+
sendTwoFactorOTP: import("better-call").StrictEndpoint<"/two-factor/send-otp", {
|
|
79
77
|
method: "POST";
|
|
80
78
|
body: z.ZodOptional<z.ZodObject<{
|
|
81
79
|
trustDevice: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -121,7 +119,7 @@ declare const otp2fa: (options?: OTPOptions | undefined) => {
|
|
|
121
119
|
*
|
|
122
120
|
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#api-method-two-factor-verify-otp)
|
|
123
121
|
*/
|
|
124
|
-
verifyTwoFactorOTP:
|
|
122
|
+
verifyTwoFactorOTP: import("better-call").StrictEndpoint<"/two-factor/verify-otp", {
|
|
125
123
|
method: "POST";
|
|
126
124
|
body: z.ZodObject<{
|
|
127
125
|
code: z.ZodString;
|
|
@@ -13,9 +13,20 @@ import * as z from "zod";
|
|
|
13
13
|
//#region src/plugins/two-factor/otp/index.ts
|
|
14
14
|
const verifyOTPBodySchema = z.object({
|
|
15
15
|
code: z.string().meta({ description: "The otp code to verify. Eg: \"012345\"" }),
|
|
16
|
+
/**
|
|
17
|
+
* if true, the device will be trusted
|
|
18
|
+
* for 30 days. It'll be refreshed on
|
|
19
|
+
* every sign in request within this time.
|
|
20
|
+
*/
|
|
16
21
|
trustDevice: z.boolean().optional().meta({ description: "If true, the device will be trusted for 30 days. It'll be refreshed on every sign in request within this time. Eg: true" })
|
|
17
22
|
});
|
|
18
|
-
const send2FaOTPBodySchema = z.object({
|
|
23
|
+
const send2FaOTPBodySchema = z.object({
|
|
24
|
+
/**
|
|
25
|
+
* if true, the device will be trusted
|
|
26
|
+
* for 30 days. It'll be refreshed on
|
|
27
|
+
* every sign in request within this time.
|
|
28
|
+
*/
|
|
29
|
+
trustDevice: z.boolean().optional().meta({ description: "If true, the device will be trusted for 30 days. It'll be refreshed on every sign in request within this time. Eg: true" }) }).optional();
|
|
19
30
|
/**
|
|
20
31
|
* The otp adapter is created from the totp adapter.
|
|
21
32
|
*/
|
|
@@ -50,6 +61,21 @@ const otp2fa = (options) => {
|
|
|
50
61
|
id: "otp",
|
|
51
62
|
version: PACKAGE_VERSION,
|
|
52
63
|
endpoints: {
|
|
64
|
+
/**
|
|
65
|
+
* ### Endpoint
|
|
66
|
+
*
|
|
67
|
+
* POST `/two-factor/send-otp`
|
|
68
|
+
*
|
|
69
|
+
* ### API Methods
|
|
70
|
+
*
|
|
71
|
+
* **server:**
|
|
72
|
+
* `auth.api.sendTwoFactorOTP`
|
|
73
|
+
*
|
|
74
|
+
* **client:**
|
|
75
|
+
* `authClient.twoFactor.sendOtp`
|
|
76
|
+
*
|
|
77
|
+
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#api-method-two-factor-send-otp)
|
|
78
|
+
*/
|
|
53
79
|
sendTwoFactorOTP: createAuthEndpoint("/two-factor/send-otp", {
|
|
54
80
|
method: "POST",
|
|
55
81
|
body: send2FaOTPBodySchema,
|
|
@@ -89,6 +115,21 @@ const otp2fa = (options) => {
|
|
|
89
115
|
}));
|
|
90
116
|
return ctx.json({ status: true });
|
|
91
117
|
}),
|
|
118
|
+
/**
|
|
119
|
+
* ### Endpoint
|
|
120
|
+
*
|
|
121
|
+
* POST `/two-factor/verify-otp`
|
|
122
|
+
*
|
|
123
|
+
* ### API Methods
|
|
124
|
+
*
|
|
125
|
+
* **server:**
|
|
126
|
+
* `auth.api.verifyTwoFactorOTP`
|
|
127
|
+
*
|
|
128
|
+
* **client:**
|
|
129
|
+
* `authClient.twoFactor.verifyOtp`
|
|
130
|
+
*
|
|
131
|
+
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#api-method-two-factor-verify-otp)
|
|
132
|
+
*/
|
|
92
133
|
verifyTwoFactorOTP: createAuthEndpoint("/two-factor/verify-otp", {
|
|
93
134
|
method: "POST",
|
|
94
135
|
body: verifyOTPBodySchema,
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { BackupCodeOptions } from "../backup-codes/index.mjs";
|
|
2
2
|
import { UserWithTwoFactor } from "../types.mjs";
|
|
3
|
-
import * as better_call0 from "better-call";
|
|
4
3
|
import * as z from "zod";
|
|
5
|
-
|
|
6
4
|
//#region src/plugins/two-factor/totp/index.d.ts
|
|
7
5
|
type TOTPOptions = {
|
|
8
6
|
/**
|
|
@@ -52,7 +50,7 @@ declare const totp2fa: (options?: TOTPOptions | undefined) => {
|
|
|
52
50
|
*
|
|
53
51
|
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#totp)
|
|
54
52
|
*/
|
|
55
|
-
generateTOTP:
|
|
53
|
+
generateTOTP: import("better-call").StrictEndpoint<string, {
|
|
56
54
|
method: "POST";
|
|
57
55
|
body: z.ZodObject<{
|
|
58
56
|
secret: z.ZodString;
|
|
@@ -98,9 +96,9 @@ declare const totp2fa: (options?: TOTPOptions | undefined) => {
|
|
|
98
96
|
*
|
|
99
97
|
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#getting-totp-uri)
|
|
100
98
|
*/
|
|
101
|
-
getTOTPURI:
|
|
99
|
+
getTOTPURI: import("better-call").StrictEndpoint<"/two-factor/get-totp-uri", {
|
|
102
100
|
method: "POST";
|
|
103
|
-
use: ((inputContext:
|
|
101
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
104
102
|
session: {
|
|
105
103
|
session: Record<string, any> & {
|
|
106
104
|
id: string;
|
|
@@ -169,7 +167,7 @@ declare const totp2fa: (options?: TOTPOptions | undefined) => {
|
|
|
169
167
|
*
|
|
170
168
|
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#verifying-totp)
|
|
171
169
|
*/
|
|
172
|
-
verifyTOTP:
|
|
170
|
+
verifyTOTP: import("better-call").StrictEndpoint<"/two-factor/verify-totp", {
|
|
173
171
|
method: "POST";
|
|
174
172
|
body: z.ZodObject<{
|
|
175
173
|
code: z.ZodString;
|
|
@@ -13,6 +13,11 @@ import { createOTP } from "@better-auth/utils/otp";
|
|
|
13
13
|
const generateTOTPBodySchema = z.object({ secret: z.string().meta({ description: "The secret to generate the TOTP code" }) });
|
|
14
14
|
const verifyTOTPBodySchema = z.object({
|
|
15
15
|
code: z.string().meta({ description: "The otp code to verify. Eg: \"012345\"" }),
|
|
16
|
+
/**
|
|
17
|
+
* if true, the device will be trusted
|
|
18
|
+
* for 30 days. It'll be refreshed on
|
|
19
|
+
* every sign in request within this time.
|
|
20
|
+
*/
|
|
16
21
|
trustDevice: z.boolean().meta({ description: "If true, the device will be trusted for 30 days. It'll be refreshed on every sign in request within this time. Eg: true" }).optional()
|
|
17
22
|
});
|
|
18
23
|
const totp2fa = (options) => {
|
|
@@ -28,6 +33,18 @@ const totp2fa = (options) => {
|
|
|
28
33
|
id: "totp",
|
|
29
34
|
version: PACKAGE_VERSION,
|
|
30
35
|
endpoints: {
|
|
36
|
+
/**
|
|
37
|
+
* ### Endpoint
|
|
38
|
+
*
|
|
39
|
+
* POST `/totp/generate`
|
|
40
|
+
*
|
|
41
|
+
* ### API Methods
|
|
42
|
+
*
|
|
43
|
+
* **server:**
|
|
44
|
+
* `auth.api.generateTOTP`
|
|
45
|
+
*
|
|
46
|
+
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#totp)
|
|
47
|
+
*/
|
|
31
48
|
generateTOTP: createAuthEndpoint.serverOnly({
|
|
32
49
|
method: "POST",
|
|
33
50
|
body: generateTOTPBodySchema,
|
|
@@ -55,6 +72,21 @@ const totp2fa = (options) => {
|
|
|
55
72
|
digits: opts.digits
|
|
56
73
|
}).totp() };
|
|
57
74
|
}),
|
|
75
|
+
/**
|
|
76
|
+
* ### Endpoint
|
|
77
|
+
*
|
|
78
|
+
* POST `/two-factor/get-totp-uri`
|
|
79
|
+
*
|
|
80
|
+
* ### API Methods
|
|
81
|
+
*
|
|
82
|
+
* **server:**
|
|
83
|
+
* `auth.api.getTOTPURI`
|
|
84
|
+
*
|
|
85
|
+
* **client:**
|
|
86
|
+
* `authClient.twoFactor.getTotpUri`
|
|
87
|
+
*
|
|
88
|
+
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#getting-totp-uri)
|
|
89
|
+
*/
|
|
58
90
|
getTOTPURI: createAuthEndpoint("/two-factor/get-totp-uri", {
|
|
59
91
|
method: "POST",
|
|
60
92
|
use: [sessionMiddleware],
|
|
@@ -100,6 +132,21 @@ const totp2fa = (options) => {
|
|
|
100
132
|
period: opts.period
|
|
101
133
|
}).url(options?.issuer || ctx.context.appName, user.email) };
|
|
102
134
|
}),
|
|
135
|
+
/**
|
|
136
|
+
* ### Endpoint
|
|
137
|
+
*
|
|
138
|
+
* POST `/two-factor/verify-totp`
|
|
139
|
+
*
|
|
140
|
+
* ### API Methods
|
|
141
|
+
*
|
|
142
|
+
* **server:**
|
|
143
|
+
* `auth.api.verifyTOTP`
|
|
144
|
+
*
|
|
145
|
+
* **client:**
|
|
146
|
+
* `authClient.twoFactor.verifyTotp`
|
|
147
|
+
*
|
|
148
|
+
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#verifying-totp)
|
|
149
|
+
*/
|
|
103
150
|
verifyTOTP: createAuthEndpoint("/two-factor/verify-totp", {
|
|
104
151
|
method: "POST",
|
|
105
152
|
body: verifyTOTPBodySchema,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { User } from "../../types/models.mjs";
|
|
2
2
|
import { InferOptionSchema } from "../../types/plugins.mjs";
|
|
3
|
+
import "../../types/index.mjs";
|
|
3
4
|
import { BackupCodeOptions } from "./backup-codes/index.mjs";
|
|
4
5
|
import { OTPOptions } from "./otp/index.mjs";
|
|
5
6
|
import { schema } from "./schema.mjs";
|
|
6
7
|
import { TOTPOptions } from "./totp/index.mjs";
|
|
7
8
|
import { BetterAuthPlugin, LiteralString } from "@better-auth/core";
|
|
8
|
-
|
|
9
9
|
//#region src/plugins/two-factor/types.d.ts
|
|
10
10
|
interface TwoFactorOptions {
|
|
11
11
|
/**
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { USERNAME_ERROR_CODES } from "./error-codes.mjs";
|
|
2
2
|
import { username } from "./index.mjs";
|
|
3
|
-
import * as _better_auth_core_utils_error_codes0 from "@better-auth/core/utils/error-codes";
|
|
4
|
-
|
|
5
3
|
//#region src/plugins/username/client.d.ts
|
|
6
4
|
declare const usernameClient: () => {
|
|
7
5
|
id: "username";
|
|
@@ -12,15 +10,15 @@ declare const usernameClient: () => {
|
|
|
12
10
|
signal: "$sessionSignal";
|
|
13
11
|
}[];
|
|
14
12
|
$ERROR_CODES: {
|
|
15
|
-
EMAIL_NOT_VERIFIED:
|
|
16
|
-
UNEXPECTED_ERROR:
|
|
17
|
-
INVALID_USERNAME_OR_PASSWORD:
|
|
18
|
-
USERNAME_IS_ALREADY_TAKEN:
|
|
19
|
-
USERNAME_TOO_SHORT:
|
|
20
|
-
USERNAME_TOO_LONG:
|
|
21
|
-
INVALID_USERNAME:
|
|
22
|
-
INVALID_DISPLAY_USERNAME:
|
|
13
|
+
EMAIL_NOT_VERIFIED: import("@better-auth/core/utils/error-codes").RawError<"EMAIL_NOT_VERIFIED">;
|
|
14
|
+
UNEXPECTED_ERROR: import("@better-auth/core/utils/error-codes").RawError<"UNEXPECTED_ERROR">;
|
|
15
|
+
INVALID_USERNAME_OR_PASSWORD: import("@better-auth/core/utils/error-codes").RawError<"INVALID_USERNAME_OR_PASSWORD">;
|
|
16
|
+
USERNAME_IS_ALREADY_TAKEN: import("@better-auth/core/utils/error-codes").RawError<"USERNAME_IS_ALREADY_TAKEN">;
|
|
17
|
+
USERNAME_TOO_SHORT: import("@better-auth/core/utils/error-codes").RawError<"USERNAME_TOO_SHORT">;
|
|
18
|
+
USERNAME_TOO_LONG: import("@better-auth/core/utils/error-codes").RawError<"USERNAME_TOO_LONG">;
|
|
19
|
+
INVALID_USERNAME: import("@better-auth/core/utils/error-codes").RawError<"INVALID_USERNAME">;
|
|
20
|
+
INVALID_DISPLAY_USERNAME: import("@better-auth/core/utils/error-codes").RawError<"INVALID_DISPLAY_USERNAME">;
|
|
23
21
|
};
|
|
24
22
|
};
|
|
25
23
|
//#endregion
|
|
26
|
-
export { usernameClient };
|
|
24
|
+
export { USERNAME_ERROR_CODES, usernameClient };
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import * as _better_auth_core_utils_error_codes0 from "@better-auth/core/utils/error-codes";
|
|
2
|
-
|
|
3
1
|
//#region src/plugins/username/error-codes.d.ts
|
|
4
2
|
declare const USERNAME_ERROR_CODES: {
|
|
5
|
-
EMAIL_NOT_VERIFIED:
|
|
6
|
-
UNEXPECTED_ERROR:
|
|
7
|
-
INVALID_USERNAME_OR_PASSWORD:
|
|
8
|
-
USERNAME_IS_ALREADY_TAKEN:
|
|
9
|
-
USERNAME_TOO_SHORT:
|
|
10
|
-
USERNAME_TOO_LONG:
|
|
11
|
-
INVALID_USERNAME:
|
|
12
|
-
INVALID_DISPLAY_USERNAME:
|
|
3
|
+
EMAIL_NOT_VERIFIED: import("@better-auth/core/utils/error-codes").RawError<"EMAIL_NOT_VERIFIED">;
|
|
4
|
+
UNEXPECTED_ERROR: import("@better-auth/core/utils/error-codes").RawError<"UNEXPECTED_ERROR">;
|
|
5
|
+
INVALID_USERNAME_OR_PASSWORD: import("@better-auth/core/utils/error-codes").RawError<"INVALID_USERNAME_OR_PASSWORD">;
|
|
6
|
+
USERNAME_IS_ALREADY_TAKEN: import("@better-auth/core/utils/error-codes").RawError<"USERNAME_IS_ALREADY_TAKEN">;
|
|
7
|
+
USERNAME_TOO_SHORT: import("@better-auth/core/utils/error-codes").RawError<"USERNAME_TOO_SHORT">;
|
|
8
|
+
USERNAME_TOO_LONG: import("@better-auth/core/utils/error-codes").RawError<"USERNAME_TOO_LONG">;
|
|
9
|
+
INVALID_USERNAME: import("@better-auth/core/utils/error-codes").RawError<"INVALID_USERNAME">;
|
|
10
|
+
INVALID_DISPLAY_USERNAME: import("@better-auth/core/utils/error-codes").RawError<"INVALID_DISPLAY_USERNAME">;
|
|
13
11
|
};
|
|
14
12
|
//#endregion
|
|
15
13
|
export { USERNAME_ERROR_CODES };
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import { InferOptionSchema } from "../../types/plugins.mjs";
|
|
2
2
|
import { UsernameSchema } from "./schema.mjs";
|
|
3
3
|
import { USERNAME_ERROR_CODES } from "./error-codes.mjs";
|
|
4
|
-
import * as _better_auth_core0 from "@better-auth/core";
|
|
5
|
-
import * as _better_auth_core_db0 from "@better-auth/core/db";
|
|
6
|
-
import * as _better_auth_core_utils_error_codes0 from "@better-auth/core/utils/error-codes";
|
|
7
|
-
import * as better_call0 from "better-call";
|
|
8
4
|
import * as z from "zod";
|
|
9
|
-
|
|
10
5
|
//#region src/plugins/username/index.d.ts
|
|
11
6
|
declare module "@better-auth/core" {
|
|
12
7
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
@@ -76,7 +71,7 @@ type UsernameOptions = {
|
|
|
76
71
|
declare const username: (options?: UsernameOptions | undefined) => {
|
|
77
72
|
id: "username";
|
|
78
73
|
version: string;
|
|
79
|
-
init(ctx:
|
|
74
|
+
init(ctx: import("@better-auth/core").AuthContext): {
|
|
80
75
|
options: {
|
|
81
76
|
databaseHooks: {
|
|
82
77
|
user: {
|
|
@@ -89,7 +84,7 @@ declare const username: (options?: UsernameOptions | undefined) => {
|
|
|
89
84
|
emailVerified: boolean;
|
|
90
85
|
name: string;
|
|
91
86
|
image?: string | null | undefined;
|
|
92
|
-
} & Record<string, unknown>, context:
|
|
87
|
+
} & Record<string, unknown>, context: import("@better-auth/core").GenericEndpointContext | null): Promise<{
|
|
93
88
|
data: {
|
|
94
89
|
username: string;
|
|
95
90
|
displayUsername: string;
|
|
@@ -123,7 +118,7 @@ declare const username: (options?: UsernameOptions | undefined) => {
|
|
|
123
118
|
emailVerified: boolean;
|
|
124
119
|
name: string;
|
|
125
120
|
image?: string | null | undefined;
|
|
126
|
-
}> & Record<string, unknown>, context:
|
|
121
|
+
}> & Record<string, unknown>, context: import("@better-auth/core").GenericEndpointContext | null): Promise<{
|
|
127
122
|
data: {
|
|
128
123
|
displayUsername?: string | undefined;
|
|
129
124
|
username: string;
|
|
@@ -153,7 +148,7 @@ declare const username: (options?: UsernameOptions | undefined) => {
|
|
|
153
148
|
};
|
|
154
149
|
};
|
|
155
150
|
endpoints: {
|
|
156
|
-
signInUsername:
|
|
151
|
+
signInUsername: import("better-call").StrictEndpoint<"/sign-in/username", {
|
|
157
152
|
method: "POST";
|
|
158
153
|
body: z.ZodObject<{
|
|
159
154
|
username: z.ZodString;
|
|
@@ -230,7 +225,7 @@ declare const username: (options?: UsernameOptions | undefined) => {
|
|
|
230
225
|
displayUsername: string;
|
|
231
226
|
};
|
|
232
227
|
}>;
|
|
233
|
-
isUsernameAvailable:
|
|
228
|
+
isUsernameAvailable: import("better-call").StrictEndpoint<"/is-username-available", {
|
|
234
229
|
method: "POST";
|
|
235
230
|
body: z.ZodObject<{
|
|
236
231
|
username: z.ZodString;
|
|
@@ -249,14 +244,14 @@ declare const username: (options?: UsernameOptions | undefined) => {
|
|
|
249
244
|
unique: true;
|
|
250
245
|
returned: true;
|
|
251
246
|
transform: {
|
|
252
|
-
input(value:
|
|
247
|
+
input(value: import("@better-auth/core/db").DBPrimitive): string | number | boolean | Date | Record<string, unknown> | unknown[] | null | undefined;
|
|
253
248
|
};
|
|
254
249
|
};
|
|
255
250
|
displayUsername: {
|
|
256
251
|
type: "string";
|
|
257
252
|
required: false;
|
|
258
253
|
transform: {
|
|
259
|
-
input(value:
|
|
254
|
+
input(value: import("@better-auth/core/db").DBPrimitive): string | number | boolean | Date | Record<string, unknown> | unknown[] | null | undefined;
|
|
260
255
|
};
|
|
261
256
|
};
|
|
262
257
|
};
|
|
@@ -264,20 +259,20 @@ declare const username: (options?: UsernameOptions | undefined) => {
|
|
|
264
259
|
};
|
|
265
260
|
hooks: {
|
|
266
261
|
before: {
|
|
267
|
-
matcher(context:
|
|
268
|
-
handler: (inputContext:
|
|
262
|
+
matcher(context: import("@better-auth/core").HookEndpointContext): boolean;
|
|
263
|
+
handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>;
|
|
269
264
|
}[];
|
|
270
265
|
};
|
|
271
266
|
options: UsernameOptions | undefined;
|
|
272
267
|
$ERROR_CODES: {
|
|
273
|
-
EMAIL_NOT_VERIFIED:
|
|
274
|
-
UNEXPECTED_ERROR:
|
|
275
|
-
INVALID_USERNAME_OR_PASSWORD:
|
|
276
|
-
USERNAME_IS_ALREADY_TAKEN:
|
|
277
|
-
USERNAME_TOO_SHORT:
|
|
278
|
-
USERNAME_TOO_LONG:
|
|
279
|
-
INVALID_USERNAME:
|
|
280
|
-
INVALID_DISPLAY_USERNAME:
|
|
268
|
+
EMAIL_NOT_VERIFIED: import("@better-auth/core/utils/error-codes").RawError<"EMAIL_NOT_VERIFIED">;
|
|
269
|
+
UNEXPECTED_ERROR: import("@better-auth/core/utils/error-codes").RawError<"UNEXPECTED_ERROR">;
|
|
270
|
+
INVALID_USERNAME_OR_PASSWORD: import("@better-auth/core/utils/error-codes").RawError<"INVALID_USERNAME_OR_PASSWORD">;
|
|
271
|
+
USERNAME_IS_ALREADY_TAKEN: import("@better-auth/core/utils/error-codes").RawError<"USERNAME_IS_ALREADY_TAKEN">;
|
|
272
|
+
USERNAME_TOO_SHORT: import("@better-auth/core/utils/error-codes").RawError<"USERNAME_TOO_SHORT">;
|
|
273
|
+
USERNAME_TOO_LONG: import("@better-auth/core/utils/error-codes").RawError<"USERNAME_TOO_LONG">;
|
|
274
|
+
INVALID_USERNAME: import("@better-auth/core/utils/error-codes").RawError<"INVALID_USERNAME">;
|
|
275
|
+
INVALID_DISPLAY_USERNAME: import("@better-auth/core/utils/error-codes").RawError<"INVALID_DISPLAY_USERNAME">;
|
|
281
276
|
};
|
|
282
277
|
};
|
|
283
278
|
//#endregion
|