better-auth 1.6.22 → 1.6.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/index.d.mts +1 -6
- package/dist/api/dispatch.d.mts +0 -1
- package/dist/api/index.d.mts +476 -478
- package/dist/api/middlewares/authorization.d.mts +12 -8
- package/dist/api/middlewares/authorization.mjs +2 -1
- package/dist/api/middlewares/index.d.mts +2 -1
- package/dist/api/middlewares/origin-check.d.mts +3 -5
- package/dist/api/routes/account.d.mts +10 -13
- package/dist/api/routes/account.mjs +35 -7
- package/dist/api/routes/callback.d.mts +1 -3
- package/dist/api/routes/callback.mjs +4 -0
- package/dist/api/routes/email-verification.d.mts +4 -8
- package/dist/api/routes/email-verification.mjs +15 -2
- package/dist/api/routes/error.d.mts +1 -3
- package/dist/api/routes/index.d.mts +2 -1
- package/dist/api/routes/ok.d.mts +1 -3
- package/dist/api/routes/password.d.mts +7 -9
- package/dist/api/routes/password.mjs +14 -1
- package/dist/api/routes/session.d.mts +22 -24
- package/dist/api/routes/session.mjs +5 -1
- package/dist/api/routes/sign-in.d.mts +3 -5
- package/dist/api/routes/sign-in.mjs +84 -2
- package/dist/api/routes/sign-out.d.mts +1 -3
- package/dist/api/routes/sign-up.d.mts +3 -4
- package/dist/api/routes/sign-up.mjs +3 -2
- package/dist/api/routes/update-session.d.mts +3 -4
- package/dist/api/routes/update-user.d.mts +13 -14
- package/dist/api/routes/update-user.mjs +26 -1
- package/dist/auth/full.d.mts +1 -1
- package/dist/auth/minimal.d.mts +1 -1
- package/dist/client/config.d.mts +12 -14
- package/dist/client/config.mjs +2 -2
- package/dist/client/equality.d.mts +0 -1
- package/dist/client/index.d.mts +6 -5
- package/dist/client/lynx/index.d.mts +4 -5
- package/dist/client/lynx/lynx-store.d.mts +1 -2
- package/dist/client/parser.d.mts +7 -3
- package/dist/client/path-to-object.d.mts +3 -4
- package/dist/client/plugins/index.d.mts +2 -1
- package/dist/client/plugins/infer-plugin.d.mts +0 -1
- package/dist/client/query.d.mts +0 -1
- package/dist/client/query.mjs +38 -20
- package/dist/client/react/index.d.mts +4 -5
- package/dist/client/react/react-store.d.mts +1 -2
- package/dist/client/session-refresh.d.mts +0 -1
- package/dist/client/solid/index.d.mts +5 -6
- package/dist/client/svelte/index.d.mts +5 -6
- package/dist/client/types.d.mts +2 -2
- package/dist/client/vanilla.d.mts +2 -3
- package/dist/client/vue/index.d.mts +5 -6
- package/dist/context/create-context.mjs +3 -3
- package/dist/context/helpers.mjs +2 -2
- package/dist/cookies/cookie-utils.d.mts +1 -1
- package/dist/cookies/index.d.mts +6 -7
- package/dist/cookies/index.mjs +4 -0
- package/dist/cookies/session-store.d.mts +1 -0
- package/dist/cookies/session-store.mjs +6 -1
- package/dist/crypto/index.d.mts +2 -9
- package/dist/crypto/jwt.d.mts +0 -1
- package/dist/crypto/password.d.mts +1 -5
- package/dist/db/adapter-base.d.mts +0 -1
- package/dist/db/adapter-kysely.d.mts +0 -1
- package/dist/db/field-converter.d.mts +0 -1
- package/dist/db/field.d.mts +9 -10
- package/dist/db/get-migration.d.mts +0 -1
- package/dist/db/get-migration.mjs +8 -4
- package/dist/db/get-schema.d.mts +0 -1
- package/dist/db/internal-adapter.d.mts +0 -1
- package/dist/db/internal-adapter.mjs +61 -1
- package/dist/db/revoke-unproven-account-access.d.mts +0 -1
- package/dist/db/schema.d.mts +2 -2
- package/dist/db/to-zod.d.mts +3 -7
- package/dist/db/with-hooks.d.mts +0 -1
- package/dist/index.d.mts +4 -3
- package/dist/integrations/next-js.d.mts +4 -7
- package/dist/integrations/node.d.mts +2 -3
- package/dist/integrations/svelte-kit.d.mts +2 -9
- package/dist/integrations/tanstack-start-solid.d.mts +2 -5
- package/dist/integrations/tanstack-start.d.mts +2 -5
- package/dist/oauth2/link-account.d.mts +1 -1
- package/dist/oauth2/state.d.mts +0 -1
- package/dist/oauth2/utils.d.mts +0 -1
- package/dist/package.mjs +1 -1
- package/dist/plugins/access/access.d.mts +0 -1
- package/dist/plugins/access/types.d.mts +4 -5
- package/dist/plugins/additional-fields/client.d.mts +0 -1
- package/dist/plugins/admin/access/statement.d.mts +1 -0
- package/dist/plugins/admin/admin.d.mts +120 -125
- package/dist/plugins/admin/client.d.mts +30 -30
- package/dist/plugins/admin/client.mjs +1 -1
- package/dist/plugins/admin/error-codes.d.mts +23 -25
- package/dist/plugins/admin/index.d.mts +1 -1
- package/dist/plugins/admin/routes.mjs +9 -0
- package/dist/plugins/admin/schema.d.mts +1 -1
- package/dist/plugins/admin/types.d.mts +3 -2
- package/dist/plugins/anonymous/client.d.mts +9 -11
- package/dist/plugins/anonymous/client.mjs +1 -1
- package/dist/plugins/anonymous/error-codes.d.mts +8 -10
- package/dist/plugins/anonymous/index.d.mts +14 -18
- package/dist/plugins/anonymous/types.d.mts +1 -1
- package/dist/plugins/bearer/index.d.mts +4 -7
- package/dist/plugins/captcha/index.d.mts +5 -8
- package/dist/plugins/captcha/types.d.mts +0 -1
- package/dist/plugins/custom-session/client.d.mts +0 -1
- package/dist/plugins/custom-session/index.d.mts +7 -12
- package/dist/plugins/device-authorization/client.d.mts +0 -1
- package/dist/plugins/device-authorization/index.d.mts +19 -22
- package/dist/plugins/email-otp/client.d.mts +4 -6
- package/dist/plugins/email-otp/client.mjs +1 -1
- package/dist/plugins/email-otp/error-codes.d.mts +3 -5
- package/dist/plugins/email-otp/index.d.mts +67 -73
- package/dist/plugins/email-otp/routes.mjs +2 -0
- package/dist/plugins/email-otp/types.d.mts +0 -1
- package/dist/plugins/generic-oauth/client.d.mts +11 -11
- package/dist/plugins/generic-oauth/client.mjs +1 -1
- package/dist/plugins/generic-oauth/error-codes.d.mts +8 -10
- package/dist/plugins/generic-oauth/index.d.mts +41 -44
- package/dist/plugins/generic-oauth/index.mjs +2 -1
- package/dist/plugins/generic-oauth/providers/auth0.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/gumroad.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/hubspot.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/index.d.mts +3 -1
- package/dist/plugins/generic-oauth/providers/keycloak.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/line.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/microsoft-entra-id.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/okta.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/patreon.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/slack.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/yandex.d.mts +28 -0
- package/dist/plugins/generic-oauth/providers/yandex.mjs +60 -0
- package/dist/plugins/generic-oauth/routes.mjs +14 -0
- package/dist/plugins/generic-oauth/types.d.mts +1 -2
- package/dist/plugins/haveibeenpwned/index.d.mts +3 -6
- package/dist/plugins/index.d.mts +5 -1
- package/dist/plugins/index.mjs +2 -1
- package/dist/plugins/jwt/client.d.mts +2 -4
- package/dist/plugins/jwt/index.d.mts +8 -11
- package/dist/plugins/jwt/sign.d.mts +2 -2
- package/dist/plugins/jwt/types.d.mts +1 -1
- package/dist/plugins/jwt/utils.d.mts +2 -4
- package/dist/plugins/jwt/verify.d.mts +0 -1
- package/dist/plugins/last-login-method/client.mjs +13 -0
- package/dist/plugins/last-login-method/index.d.mts +11 -5
- package/dist/plugins/last-login-method/index.mjs +8 -0
- package/dist/plugins/magic-link/client.d.mts +0 -1
- package/dist/plugins/magic-link/index.d.mts +4 -5
- package/dist/plugins/magic-link/index.mjs +32 -1
- package/dist/plugins/mcp/authorize.mjs +12 -0
- package/dist/plugins/mcp/client/adapters.d.mts +0 -1
- package/dist/plugins/mcp/client/index.d.mts +2 -0
- package/dist/plugins/mcp/client/index.mjs +36 -11
- package/dist/plugins/mcp/index.d.mts +10 -11
- package/dist/plugins/multi-session/client.d.mts +2 -4
- package/dist/plugins/multi-session/client.mjs +1 -1
- package/dist/plugins/multi-session/error-codes.d.mts +1 -3
- package/dist/plugins/multi-session/index.d.mts +7 -11
- package/dist/plugins/multi-session/index.mjs +45 -0
- package/dist/plugins/oauth-popup/client.d.mts +6 -12
- package/dist/plugins/oauth-popup/client.mjs +5 -3
- package/dist/plugins/oauth-popup/error-codes.d.mts +4 -6
- package/dist/plugins/oauth-popup/index.d.mts +8 -12
- package/dist/plugins/oauth-popup/index.mjs +1 -1
- package/dist/plugins/oauth-popup/types.d.mts +1 -2
- package/dist/plugins/oauth-proxy/index.d.mts +6 -9
- package/dist/plugins/oauth-proxy/index.mjs +2 -2
- package/dist/plugins/oidc-provider/authorize.mjs +9 -0
- package/dist/plugins/oidc-provider/client.d.mts +1 -2
- package/dist/plugins/oidc-provider/index.d.mts +15 -17
- package/dist/plugins/oidc-provider/index.mjs +26 -2
- package/dist/plugins/oidc-provider/schema.d.mts +0 -1
- package/dist/plugins/oidc-provider/schema.mjs +37 -0
- package/dist/plugins/oidc-provider/types.d.mts +1 -1
- package/dist/plugins/one-tap/client.d.mts +3 -6
- package/dist/plugins/one-tap/client.mjs +3 -0
- package/dist/plugins/one-tap/index.d.mts +1 -3
- package/dist/plugins/one-tap/index.mjs +5 -0
- package/dist/plugins/one-time-token/client.d.mts +1 -2
- package/dist/plugins/one-time-token/index.d.mts +5 -6
- package/dist/plugins/one-time-token/index.mjs +30 -0
- package/dist/plugins/open-api/generator.d.mts +0 -1
- package/dist/plugins/open-api/generator.mjs +81 -5
- package/dist/plugins/open-api/index.d.mts +3 -5
- package/dist/plugins/organization/access/statement.d.mts +1 -0
- package/dist/plugins/organization/adapter.d.mts +56 -82
- package/dist/plugins/organization/adapter.mjs +17 -3
- package/dist/plugins/organization/client.d.mts +106 -105
- package/dist/plugins/organization/client.mjs +7 -4
- package/dist/plugins/organization/error-codes.d.mts +59 -61
- package/dist/plugins/organization/has-permission.d.mts +0 -1
- package/dist/plugins/organization/has-permission.mjs +1 -1
- package/dist/plugins/organization/index.d.mts +1 -1
- package/dist/plugins/organization/organization.d.mts +7 -7
- package/dist/plugins/organization/organization.mjs +434 -1
- package/dist/plugins/organization/permission.d.mts +2 -2
- package/dist/plugins/organization/routes/crud-access-control.d.mts +17 -17
- package/dist/plugins/organization/routes/crud-invites.d.mts +53 -54
- package/dist/plugins/organization/routes/crud-invites.mjs +1 -1
- package/dist/plugins/organization/routes/crud-members.d.mts +44 -46
- package/dist/plugins/organization/routes/crud-members.mjs +4 -1
- package/dist/plugins/organization/routes/crud-org.d.mts +47 -48
- package/dist/plugins/organization/routes/crud-org.mjs +2 -2
- package/dist/plugins/organization/routes/crud-team.d.mts +50 -51
- package/dist/plugins/organization/schema.d.mts +4 -4
- package/dist/plugins/organization/schema.mjs +1 -1
- package/dist/plugins/organization/types.d.mts +16 -16
- package/dist/plugins/phone-number/client.d.mts +13 -15
- package/dist/plugins/phone-number/client.mjs +1 -1
- package/dist/plugins/phone-number/error-codes.d.mts +12 -14
- package/dist/plugins/phone-number/index.d.mts +41 -47
- package/dist/plugins/phone-number/routes.mjs +15 -0
- package/dist/plugins/phone-number/types.d.mts +1 -1
- package/dist/plugins/siwe/client.d.mts +0 -1
- package/dist/plugins/siwe/index.d.mts +4 -5
- package/dist/plugins/test-utils/index.d.mts +2 -4
- package/dist/plugins/test-utils/types.d.mts +1 -0
- package/dist/plugins/two-factor/backup-codes/index.d.mts +4 -6
- package/dist/plugins/two-factor/backup-codes/index.mjs +52 -1
- package/dist/plugins/two-factor/client.d.mts +12 -15
- package/dist/plugins/two-factor/client.mjs +1 -1
- package/dist/plugins/two-factor/error-code.d.mts +10 -12
- package/dist/plugins/two-factor/index.d.mts +27 -31
- package/dist/plugins/two-factor/index.mjs +30 -0
- package/dist/plugins/two-factor/otp/index.d.mts +2 -4
- package/dist/plugins/two-factor/otp/index.mjs +42 -1
- package/dist/plugins/two-factor/totp/index.d.mts +4 -6
- package/dist/plugins/two-factor/totp/index.mjs +47 -0
- package/dist/plugins/two-factor/types.d.mts +1 -1
- package/dist/plugins/username/client.d.mts +9 -11
- package/dist/plugins/username/client.mjs +1 -1
- package/dist/plugins/username/error-codes.d.mts +8 -10
- package/dist/plugins/username/index.d.mts +17 -22
- package/dist/plugins/username/schema.d.mts +3 -5
- package/dist/state.d.mts +0 -1
- package/dist/state.mjs +4 -0
- package/dist/test-utils/test-instance.d.mts +5 -3
- package/dist/test-utils/test-instance.mjs +4 -1
- package/dist/types/adapter.d.mts +1 -1
- package/dist/types/api.d.mts +1 -2
- package/dist/types/auth.d.mts +0 -1
- package/dist/types/helper.d.mts +5 -5
- package/dist/types/index.d.mts +2 -2
- package/dist/types/models.d.mts +0 -1
- package/dist/types/plugins.d.mts +2 -3
- package/dist/utils/index.d.mts +2 -1
- package/dist/utils/request.mjs +23 -0
- package/dist/utils/url.d.mts +0 -1
- package/package.json +10 -10
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Session as Session$1, User as User$1 } from "../../types/models.mjs";
|
|
2
|
+
import "../../types/index.mjs";
|
|
2
3
|
import { AccessControl, Role } from "../access/types.mjs";
|
|
4
|
+
import "../access/index.mjs";
|
|
3
5
|
import { Invitation, Member, Organization, OrganizationRole, Team, TeamMember } from "./schema.mjs";
|
|
4
6
|
import { AuthContext, Awaitable, GenericEndpointContext } from "@better-auth/core";
|
|
5
7
|
import { DBFieldAttribute } from "@better-auth/core/db";
|
|
6
|
-
|
|
7
8
|
//#region src/plugins/organization/types.d.ts
|
|
8
9
|
interface OrganizationOptions {
|
|
9
10
|
/**
|
|
@@ -59,7 +60,7 @@ interface OrganizationOptions {
|
|
|
59
60
|
/**
|
|
60
61
|
* Custom permissions for roles.
|
|
61
62
|
*/
|
|
62
|
-
roles?: { [key in string]?: Role<any
|
|
63
|
+
roles?: { [key in string]?: Role<any>; } | undefined;
|
|
63
64
|
/**
|
|
64
65
|
* Dynamic access control for the organization plugin.
|
|
65
66
|
*/
|
|
@@ -242,7 +243,6 @@ interface OrganizationOptions {
|
|
|
242
243
|
/**
|
|
243
244
|
* The request object
|
|
244
245
|
*/
|
|
245
|
-
|
|
246
246
|
request?: Request) => Promise<void>) | undefined;
|
|
247
247
|
/**
|
|
248
248
|
* The schema for the organization plugin.
|
|
@@ -256,32 +256,32 @@ interface OrganizationOptions {
|
|
|
256
256
|
};
|
|
257
257
|
organization?: {
|
|
258
258
|
modelName?: string;
|
|
259
|
-
fields?: { [key in keyof Omit<Organization, "id">]?: string };
|
|
260
|
-
additionalFields?: { [key in string]: DBFieldAttribute };
|
|
259
|
+
fields?: { [key in keyof Omit<Organization, "id">]?: string; };
|
|
260
|
+
additionalFields?: { [key in string]: DBFieldAttribute; };
|
|
261
261
|
};
|
|
262
262
|
member?: {
|
|
263
263
|
modelName?: string;
|
|
264
|
-
fields?: { [key in keyof Omit<Member, "id">]?: string };
|
|
265
|
-
additionalFields?: { [key in string]: DBFieldAttribute };
|
|
264
|
+
fields?: { [key in keyof Omit<Member, "id">]?: string; };
|
|
265
|
+
additionalFields?: { [key in string]: DBFieldAttribute; };
|
|
266
266
|
};
|
|
267
267
|
invitation?: {
|
|
268
268
|
modelName?: string;
|
|
269
|
-
fields?: { [key in keyof Omit<Invitation, "id">]?: string };
|
|
270
|
-
additionalFields?: { [key in string]: DBFieldAttribute };
|
|
269
|
+
fields?: { [key in keyof Omit<Invitation, "id">]?: string; };
|
|
270
|
+
additionalFields?: { [key in string]: DBFieldAttribute; };
|
|
271
271
|
};
|
|
272
272
|
team?: {
|
|
273
273
|
modelName?: string;
|
|
274
|
-
fields?: { [key in keyof Omit<Team, "id">]?: string };
|
|
275
|
-
additionalFields?: { [key in string]: DBFieldAttribute };
|
|
274
|
+
fields?: { [key in keyof Omit<Team, "id">]?: string; };
|
|
275
|
+
additionalFields?: { [key in string]: DBFieldAttribute; };
|
|
276
276
|
};
|
|
277
277
|
teamMember?: {
|
|
278
278
|
modelName?: string;
|
|
279
|
-
fields?: { [key in keyof Omit<TeamMember, "id">]?: string };
|
|
279
|
+
fields?: { [key in keyof Omit<TeamMember, "id">]?: string; };
|
|
280
280
|
};
|
|
281
281
|
organizationRole?: {
|
|
282
282
|
modelName?: string;
|
|
283
|
-
fields?: { [key in keyof Omit<OrganizationRole, "id">]?: string };
|
|
284
|
-
additionalFields?: { [key in string]: DBFieldAttribute };
|
|
283
|
+
fields?: { [key in keyof Omit<OrganizationRole, "id">]?: string; };
|
|
284
|
+
additionalFields?: { [key in string]: DBFieldAttribute; };
|
|
285
285
|
};
|
|
286
286
|
} | undefined;
|
|
287
287
|
/**
|
|
@@ -396,14 +396,14 @@ interface OrganizationOptions {
|
|
|
396
396
|
beforeDeleteOrganization?: (data: {
|
|
397
397
|
organization: Organization & Record<string, any>;
|
|
398
398
|
user: User$1 & Record<string, any>;
|
|
399
|
-
}) => Promise<void>;
|
|
399
|
+
}, ctx?: GenericEndpointContext) => Promise<void>;
|
|
400
400
|
/**
|
|
401
401
|
* A callback that runs after the organization is deleted
|
|
402
402
|
*/
|
|
403
403
|
afterDeleteOrganization?: (data: {
|
|
404
404
|
organization: Organization & Record<string, any>;
|
|
405
405
|
user: User$1 & Record<string, any>;
|
|
406
|
-
}) => Promise<void>;
|
|
406
|
+
}, ctx?: GenericEndpointContext) => Promise<void>;
|
|
407
407
|
/**
|
|
408
408
|
* Member hooks
|
|
409
409
|
*/
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { PhoneNumberOptions, UserWithPhoneNumber } from "./types.mjs";
|
|
2
2
|
import { phoneNumber } from "./index.mjs";
|
|
3
3
|
import { PHONE_NUMBER_ERROR_CODES } from "./error-codes.mjs";
|
|
4
|
-
import * as _better_auth_core_utils_error_codes0 from "@better-auth/core/utils/error-codes";
|
|
5
|
-
|
|
6
4
|
//#region src/plugins/phone-number/client.d.ts
|
|
7
5
|
declare const phoneNumberClient: () => {
|
|
8
6
|
id: "phoneNumber";
|
|
@@ -13,19 +11,19 @@ declare const phoneNumberClient: () => {
|
|
|
13
11
|
signal: "$sessionSignal";
|
|
14
12
|
}[];
|
|
15
13
|
$ERROR_CODES: {
|
|
16
|
-
OTP_EXPIRED:
|
|
17
|
-
INVALID_OTP:
|
|
18
|
-
TOO_MANY_ATTEMPTS:
|
|
19
|
-
INVALID_PHONE_NUMBER:
|
|
20
|
-
PHONE_NUMBER_EXIST:
|
|
21
|
-
PHONE_NUMBER_NOT_EXIST:
|
|
22
|
-
INVALID_PHONE_NUMBER_OR_PASSWORD:
|
|
23
|
-
UNEXPECTED_ERROR:
|
|
24
|
-
OTP_NOT_FOUND:
|
|
25
|
-
PHONE_NUMBER_NOT_VERIFIED:
|
|
26
|
-
PHONE_NUMBER_CANNOT_BE_UPDATED:
|
|
27
|
-
SEND_OTP_NOT_IMPLEMENTED:
|
|
14
|
+
OTP_EXPIRED: import("@better-auth/core/utils/error-codes").RawError<"OTP_EXPIRED">;
|
|
15
|
+
INVALID_OTP: import("@better-auth/core/utils/error-codes").RawError<"INVALID_OTP">;
|
|
16
|
+
TOO_MANY_ATTEMPTS: import("@better-auth/core/utils/error-codes").RawError<"TOO_MANY_ATTEMPTS">;
|
|
17
|
+
INVALID_PHONE_NUMBER: import("@better-auth/core/utils/error-codes").RawError<"INVALID_PHONE_NUMBER">;
|
|
18
|
+
PHONE_NUMBER_EXIST: import("@better-auth/core/utils/error-codes").RawError<"PHONE_NUMBER_EXIST">;
|
|
19
|
+
PHONE_NUMBER_NOT_EXIST: import("@better-auth/core/utils/error-codes").RawError<"PHONE_NUMBER_NOT_EXIST">;
|
|
20
|
+
INVALID_PHONE_NUMBER_OR_PASSWORD: import("@better-auth/core/utils/error-codes").RawError<"INVALID_PHONE_NUMBER_OR_PASSWORD">;
|
|
21
|
+
UNEXPECTED_ERROR: import("@better-auth/core/utils/error-codes").RawError<"UNEXPECTED_ERROR">;
|
|
22
|
+
OTP_NOT_FOUND: import("@better-auth/core/utils/error-codes").RawError<"OTP_NOT_FOUND">;
|
|
23
|
+
PHONE_NUMBER_NOT_VERIFIED: import("@better-auth/core/utils/error-codes").RawError<"PHONE_NUMBER_NOT_VERIFIED">;
|
|
24
|
+
PHONE_NUMBER_CANNOT_BE_UPDATED: import("@better-auth/core/utils/error-codes").RawError<"PHONE_NUMBER_CANNOT_BE_UPDATED">;
|
|
25
|
+
SEND_OTP_NOT_IMPLEMENTED: import("@better-auth/core/utils/error-codes").RawError<"SEND_OTP_NOT_IMPLEMENTED">;
|
|
28
26
|
};
|
|
29
27
|
};
|
|
30
28
|
//#endregion
|
|
31
|
-
export { phoneNumberClient };
|
|
29
|
+
export { PHONE_NUMBER_ERROR_CODES, type PhoneNumberOptions, type UserWithPhoneNumber, phoneNumberClient };
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import * as _better_auth_core_utils_error_codes0 from "@better-auth/core/utils/error-codes";
|
|
2
|
-
|
|
3
1
|
//#region src/plugins/phone-number/error-codes.d.ts
|
|
4
2
|
declare const PHONE_NUMBER_ERROR_CODES: {
|
|
5
|
-
OTP_EXPIRED:
|
|
6
|
-
INVALID_OTP:
|
|
7
|
-
TOO_MANY_ATTEMPTS:
|
|
8
|
-
INVALID_PHONE_NUMBER:
|
|
9
|
-
PHONE_NUMBER_EXIST:
|
|
10
|
-
PHONE_NUMBER_NOT_EXIST:
|
|
11
|
-
INVALID_PHONE_NUMBER_OR_PASSWORD:
|
|
12
|
-
UNEXPECTED_ERROR:
|
|
13
|
-
OTP_NOT_FOUND:
|
|
14
|
-
PHONE_NUMBER_NOT_VERIFIED:
|
|
15
|
-
PHONE_NUMBER_CANNOT_BE_UPDATED:
|
|
16
|
-
SEND_OTP_NOT_IMPLEMENTED:
|
|
3
|
+
OTP_EXPIRED: import("@better-auth/core/utils/error-codes").RawError<"OTP_EXPIRED">;
|
|
4
|
+
INVALID_OTP: import("@better-auth/core/utils/error-codes").RawError<"INVALID_OTP">;
|
|
5
|
+
TOO_MANY_ATTEMPTS: import("@better-auth/core/utils/error-codes").RawError<"TOO_MANY_ATTEMPTS">;
|
|
6
|
+
INVALID_PHONE_NUMBER: import("@better-auth/core/utils/error-codes").RawError<"INVALID_PHONE_NUMBER">;
|
|
7
|
+
PHONE_NUMBER_EXIST: import("@better-auth/core/utils/error-codes").RawError<"PHONE_NUMBER_EXIST">;
|
|
8
|
+
PHONE_NUMBER_NOT_EXIST: import("@better-auth/core/utils/error-codes").RawError<"PHONE_NUMBER_NOT_EXIST">;
|
|
9
|
+
INVALID_PHONE_NUMBER_OR_PASSWORD: import("@better-auth/core/utils/error-codes").RawError<"INVALID_PHONE_NUMBER_OR_PASSWORD">;
|
|
10
|
+
UNEXPECTED_ERROR: import("@better-auth/core/utils/error-codes").RawError<"UNEXPECTED_ERROR">;
|
|
11
|
+
OTP_NOT_FOUND: import("@better-auth/core/utils/error-codes").RawError<"OTP_NOT_FOUND">;
|
|
12
|
+
PHONE_NUMBER_NOT_VERIFIED: import("@better-auth/core/utils/error-codes").RawError<"PHONE_NUMBER_NOT_VERIFIED">;
|
|
13
|
+
PHONE_NUMBER_CANNOT_BE_UPDATED: import("@better-auth/core/utils/error-codes").RawError<"PHONE_NUMBER_CANNOT_BE_UPDATED">;
|
|
14
|
+
SEND_OTP_NOT_IMPLEMENTED: import("@better-auth/core/utils/error-codes").RawError<"SEND_OTP_NOT_IMPLEMENTED">;
|
|
17
15
|
};
|
|
18
16
|
//#endregion
|
|
19
17
|
export { PHONE_NUMBER_ERROR_CODES };
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import { PhoneNumberOptions, UserWithPhoneNumber } from "./types.mjs";
|
|
2
|
-
import * as _better_auth_core0 from "@better-auth/core";
|
|
3
|
-
import * as _better_auth_core_utils_error_codes0 from "@better-auth/core/utils/error-codes";
|
|
4
|
-
import * as better_call0 from "better-call";
|
|
5
|
-
import * as zod from "zod";
|
|
6
|
-
import * as zod_v4_core0 from "zod/v4/core";
|
|
7
|
-
|
|
8
2
|
//#region src/plugins/phone-number/index.d.ts
|
|
9
3
|
declare module "@better-auth/core" {
|
|
10
4
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
@@ -48,18 +42,18 @@ declare const phoneNumber: (options?: PhoneNumberOptions | undefined) => {
|
|
|
48
42
|
};
|
|
49
43
|
hooks: {
|
|
50
44
|
before: {
|
|
51
|
-
matcher: (ctx:
|
|
52
|
-
handler: (inputContext:
|
|
45
|
+
matcher: (ctx: import("@better-auth/core").HookEndpointContext) => boolean;
|
|
46
|
+
handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<never>;
|
|
53
47
|
}[];
|
|
54
48
|
};
|
|
55
49
|
endpoints: {
|
|
56
|
-
signInPhoneNumber:
|
|
50
|
+
signInPhoneNumber: import("better-call").StrictEndpoint<"/sign-in/phone-number", {
|
|
57
51
|
method: "POST";
|
|
58
|
-
body: zod.ZodObject<{
|
|
59
|
-
phoneNumber: zod.ZodString;
|
|
60
|
-
password: zod.ZodString;
|
|
61
|
-
rememberMe: zod.ZodOptional<zod.ZodBoolean>;
|
|
62
|
-
},
|
|
52
|
+
body: import("zod").ZodObject<{
|
|
53
|
+
phoneNumber: import("zod").ZodString;
|
|
54
|
+
password: import("zod").ZodString;
|
|
55
|
+
rememberMe: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
56
|
+
}, import("zod/v4/core").$strip>;
|
|
63
57
|
metadata: {
|
|
64
58
|
openapi: {
|
|
65
59
|
summary: string;
|
|
@@ -93,11 +87,11 @@ declare const phoneNumber: (options?: PhoneNumberOptions | undefined) => {
|
|
|
93
87
|
token: string;
|
|
94
88
|
user: UserWithPhoneNumber;
|
|
95
89
|
}>;
|
|
96
|
-
sendPhoneNumberOTP:
|
|
90
|
+
sendPhoneNumberOTP: import("better-call").StrictEndpoint<"/phone-number/send-otp", {
|
|
97
91
|
method: "POST";
|
|
98
|
-
body: zod.ZodObject<{
|
|
99
|
-
phoneNumber: zod.ZodString;
|
|
100
|
-
},
|
|
92
|
+
body: import("zod").ZodObject<{
|
|
93
|
+
phoneNumber: import("zod").ZodString;
|
|
94
|
+
}, import("zod/v4/core").$strip>;
|
|
101
95
|
metadata: {
|
|
102
96
|
openapi: {
|
|
103
97
|
summary: string;
|
|
@@ -124,14 +118,14 @@ declare const phoneNumber: (options?: PhoneNumberOptions | undefined) => {
|
|
|
124
118
|
}, {
|
|
125
119
|
message: string;
|
|
126
120
|
}>;
|
|
127
|
-
verifyPhoneNumber:
|
|
121
|
+
verifyPhoneNumber: import("better-call").StrictEndpoint<"/phone-number/verify", {
|
|
128
122
|
method: "POST";
|
|
129
|
-
body: zod.ZodIntersection<zod.ZodObject<{
|
|
130
|
-
phoneNumber: zod.ZodString;
|
|
131
|
-
code: zod.ZodString;
|
|
132
|
-
disableSession: zod.ZodOptional<zod.ZodBoolean>;
|
|
133
|
-
updatePhoneNumber: zod.ZodOptional<zod.ZodBoolean>;
|
|
134
|
-
},
|
|
123
|
+
body: import("zod").ZodIntersection<import("zod").ZodObject<{
|
|
124
|
+
phoneNumber: import("zod").ZodString;
|
|
125
|
+
code: import("zod").ZodString;
|
|
126
|
+
disableSession: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
127
|
+
updatePhoneNumber: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
128
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>;
|
|
135
129
|
metadata: {
|
|
136
130
|
openapi: {
|
|
137
131
|
summary: string;
|
|
@@ -235,11 +229,11 @@ declare const phoneNumber: (options?: PhoneNumberOptions | undefined) => {
|
|
|
235
229
|
token: null;
|
|
236
230
|
user: UserWithPhoneNumber;
|
|
237
231
|
}>;
|
|
238
|
-
requestPasswordResetPhoneNumber:
|
|
232
|
+
requestPasswordResetPhoneNumber: import("better-call").StrictEndpoint<"/phone-number/request-password-reset", {
|
|
239
233
|
method: "POST";
|
|
240
|
-
body: zod.ZodObject<{
|
|
241
|
-
phoneNumber: zod.ZodString;
|
|
242
|
-
},
|
|
234
|
+
body: import("zod").ZodObject<{
|
|
235
|
+
phoneNumber: import("zod").ZodString;
|
|
236
|
+
}, import("zod/v4/core").$strip>;
|
|
243
237
|
metadata: {
|
|
244
238
|
openapi: {
|
|
245
239
|
description: string;
|
|
@@ -268,13 +262,13 @@ declare const phoneNumber: (options?: PhoneNumberOptions | undefined) => {
|
|
|
268
262
|
}, {
|
|
269
263
|
status: boolean;
|
|
270
264
|
}>;
|
|
271
|
-
resetPasswordPhoneNumber:
|
|
265
|
+
resetPasswordPhoneNumber: import("better-call").StrictEndpoint<"/phone-number/reset-password", {
|
|
272
266
|
method: "POST";
|
|
273
|
-
body: zod.ZodObject<{
|
|
274
|
-
otp: zod.ZodString;
|
|
275
|
-
phoneNumber: zod.ZodString;
|
|
276
|
-
newPassword: zod.ZodString;
|
|
277
|
-
},
|
|
267
|
+
body: import("zod").ZodObject<{
|
|
268
|
+
otp: import("zod").ZodString;
|
|
269
|
+
phoneNumber: import("zod").ZodString;
|
|
270
|
+
newPassword: import("zod").ZodString;
|
|
271
|
+
}, import("zod/v4/core").$strip>;
|
|
278
272
|
metadata: {
|
|
279
273
|
openapi: {
|
|
280
274
|
description: string;
|
|
@@ -330,18 +324,18 @@ declare const phoneNumber: (options?: PhoneNumberOptions | undefined) => {
|
|
|
330
324
|
}[];
|
|
331
325
|
options: PhoneNumberOptions | undefined;
|
|
332
326
|
$ERROR_CODES: {
|
|
333
|
-
OTP_EXPIRED:
|
|
334
|
-
INVALID_OTP:
|
|
335
|
-
TOO_MANY_ATTEMPTS:
|
|
336
|
-
INVALID_PHONE_NUMBER:
|
|
337
|
-
PHONE_NUMBER_EXIST:
|
|
338
|
-
PHONE_NUMBER_NOT_EXIST:
|
|
339
|
-
INVALID_PHONE_NUMBER_OR_PASSWORD:
|
|
340
|
-
UNEXPECTED_ERROR:
|
|
341
|
-
OTP_NOT_FOUND:
|
|
342
|
-
PHONE_NUMBER_NOT_VERIFIED:
|
|
343
|
-
PHONE_NUMBER_CANNOT_BE_UPDATED:
|
|
344
|
-
SEND_OTP_NOT_IMPLEMENTED:
|
|
327
|
+
OTP_EXPIRED: import("@better-auth/core/utils/error-codes").RawError<"OTP_EXPIRED">;
|
|
328
|
+
INVALID_OTP: import("@better-auth/core/utils/error-codes").RawError<"INVALID_OTP">;
|
|
329
|
+
TOO_MANY_ATTEMPTS: import("@better-auth/core/utils/error-codes").RawError<"TOO_MANY_ATTEMPTS">;
|
|
330
|
+
INVALID_PHONE_NUMBER: import("@better-auth/core/utils/error-codes").RawError<"INVALID_PHONE_NUMBER">;
|
|
331
|
+
PHONE_NUMBER_EXIST: import("@better-auth/core/utils/error-codes").RawError<"PHONE_NUMBER_EXIST">;
|
|
332
|
+
PHONE_NUMBER_NOT_EXIST: import("@better-auth/core/utils/error-codes").RawError<"PHONE_NUMBER_NOT_EXIST">;
|
|
333
|
+
INVALID_PHONE_NUMBER_OR_PASSWORD: import("@better-auth/core/utils/error-codes").RawError<"INVALID_PHONE_NUMBER_OR_PASSWORD">;
|
|
334
|
+
UNEXPECTED_ERROR: import("@better-auth/core/utils/error-codes").RawError<"UNEXPECTED_ERROR">;
|
|
335
|
+
OTP_NOT_FOUND: import("@better-auth/core/utils/error-codes").RawError<"OTP_NOT_FOUND">;
|
|
336
|
+
PHONE_NUMBER_NOT_VERIFIED: import("@better-auth/core/utils/error-codes").RawError<"PHONE_NUMBER_NOT_VERIFIED">;
|
|
337
|
+
PHONE_NUMBER_CANNOT_BE_UPDATED: import("@better-auth/core/utils/error-codes").RawError<"PHONE_NUMBER_CANNOT_BE_UPDATED">;
|
|
338
|
+
SEND_OTP_NOT_IMPLEMENTED: import("@better-auth/core/utils/error-codes").RawError<"SEND_OTP_NOT_IMPLEMENTED">;
|
|
345
339
|
};
|
|
346
340
|
};
|
|
347
341
|
//#endregion
|
|
@@ -166,9 +166,24 @@ const sendPhoneNumberOTP = (opts) => createAuthEndpoint("/phone-number/send-otp"
|
|
|
166
166
|
return ctx.json({ message: "code sent" });
|
|
167
167
|
});
|
|
168
168
|
const verifyPhoneNumberBodySchema = z.object({
|
|
169
|
+
/**
|
|
170
|
+
* Phone number
|
|
171
|
+
*/
|
|
169
172
|
phoneNumber: z.string().meta({ description: "Phone number to verify. Eg: \"+1234567890\"" }),
|
|
173
|
+
/**
|
|
174
|
+
* OTP code
|
|
175
|
+
*/
|
|
170
176
|
code: z.string().meta({ description: "OTP code. Eg: \"123456\"" }),
|
|
177
|
+
/**
|
|
178
|
+
* Disable session creation after verification
|
|
179
|
+
* @default false
|
|
180
|
+
*/
|
|
171
181
|
disableSession: z.boolean().meta({ description: "Disable session creation after verification. Eg: false" }).optional(),
|
|
182
|
+
/**
|
|
183
|
+
* This checks if there is a session already
|
|
184
|
+
* and updates the phone number with the provided
|
|
185
|
+
* phone number
|
|
186
|
+
*/
|
|
172
187
|
updatePhoneNumber: z.boolean().meta({ description: "Check if there is a session and update the phone number. Eg: true" }).optional()
|
|
173
188
|
}).and(z.record(z.string(), z.any()));
|
|
174
189
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { User } from "../../types/models.mjs";
|
|
2
2
|
import { InferOptionSchema } from "../../types/plugins.mjs";
|
|
3
|
+
import "../../types/index.mjs";
|
|
3
4
|
import { schema } from "./schema.mjs";
|
|
4
5
|
import { Awaitable, GenericEndpointContext } from "@better-auth/core";
|
|
5
|
-
|
|
6
6
|
//#region src/plugins/phone-number/types.d.ts
|
|
7
7
|
interface UserWithPhoneNumber extends User {
|
|
8
8
|
phoneNumber: string;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { InferOptionSchema } from "../../types/plugins.mjs";
|
|
2
|
+
import "../../types/index.mjs";
|
|
2
3
|
import { WalletAddressSchema, schema } from "./schema.mjs";
|
|
3
4
|
import { ENSLookupArgs, ENSLookupResult, SIWEVerifyMessageArgs } from "./types.mjs";
|
|
4
|
-
import * as better_call0 from "better-call";
|
|
5
5
|
import * as z from "zod";
|
|
6
|
-
|
|
7
6
|
//#region src/plugins/siwe/index.d.ts
|
|
8
7
|
declare module "@better-auth/core" {
|
|
9
8
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
@@ -26,7 +25,7 @@ declare const siwe: (options: SIWEPluginOptions) => {
|
|
|
26
25
|
version: string;
|
|
27
26
|
schema: WalletAddressSchema;
|
|
28
27
|
endpoints: {
|
|
29
|
-
getSiweNonce:
|
|
28
|
+
getSiweNonce: import("better-call").StrictEndpoint<"/siwe/nonce" | "/siwe/get-nonce", {
|
|
30
29
|
method: "POST";
|
|
31
30
|
body: z.ZodObject<{
|
|
32
31
|
walletAddress: z.ZodOptional<z.ZodString>;
|
|
@@ -36,7 +35,7 @@ declare const siwe: (options: SIWEPluginOptions) => {
|
|
|
36
35
|
}, {
|
|
37
36
|
nonce: string;
|
|
38
37
|
}>;
|
|
39
|
-
getNonce:
|
|
38
|
+
getNonce: import("better-call").StrictEndpoint<"/siwe/nonce" | "/siwe/get-nonce", {
|
|
40
39
|
method: "POST";
|
|
41
40
|
body: z.ZodObject<{
|
|
42
41
|
walletAddress: z.ZodOptional<z.ZodString>;
|
|
@@ -46,7 +45,7 @@ declare const siwe: (options: SIWEPluginOptions) => {
|
|
|
46
45
|
}, {
|
|
47
46
|
nonce: string;
|
|
48
47
|
}>;
|
|
49
|
-
verifySiweMessage:
|
|
48
|
+
verifySiweMessage: import("better-call").StrictEndpoint<"/siwe/verify", {
|
|
50
49
|
method: "POST";
|
|
51
50
|
body: z.ZodObject<{
|
|
52
51
|
message: z.ZodString;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { LoginResult, TestCookie, TestHelpers, TestUtilsOptions } from "./types.mjs";
|
|
2
|
-
import * as _better_auth_core0 from "@better-auth/core";
|
|
3
|
-
|
|
4
2
|
//#region src/plugins/test-utils/index.d.ts
|
|
5
3
|
declare module "@better-auth/core" {
|
|
6
4
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
@@ -50,7 +48,7 @@ declare module "@better-auth/core" {
|
|
|
50
48
|
declare const testUtils: (options?: TestUtilsOptions) => {
|
|
51
49
|
id: "test-utils";
|
|
52
50
|
version: string;
|
|
53
|
-
init(ctx:
|
|
51
|
+
init(ctx: import("@better-auth/core").AuthContext): {
|
|
54
52
|
context: {
|
|
55
53
|
test: TestHelpers;
|
|
56
54
|
};
|
|
@@ -70,4 +68,4 @@ declare const testUtils: (options?: TestUtilsOptions) => {
|
|
|
70
68
|
options: TestUtilsOptions;
|
|
71
69
|
};
|
|
72
70
|
//#endregion
|
|
73
|
-
export { testUtils };
|
|
71
|
+
export { type LoginResult, type TestCookie, type TestHelpers, type TestUtilsOptions, testUtils };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { SecretConfig } from "../../../crypto/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/backup-codes/index.d.ts
|
|
7
5
|
interface BackupCodeOptions {
|
|
8
6
|
/**
|
|
@@ -71,7 +69,7 @@ declare const backupCode2fa: (opts: BackupCodeOptions) => {
|
|
|
71
69
|
*
|
|
72
70
|
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#api-method-two-factor-verify-backup-code)
|
|
73
71
|
*/
|
|
74
|
-
verifyBackupCode:
|
|
72
|
+
verifyBackupCode: import("better-call").StrictEndpoint<"/two-factor/verify-backup-code", {
|
|
75
73
|
method: "POST";
|
|
76
74
|
body: z.ZodObject<{
|
|
77
75
|
code: z.ZodString;
|
|
@@ -197,14 +195,14 @@ declare const backupCode2fa: (opts: BackupCodeOptions) => {
|
|
|
197
195
|
*
|
|
198
196
|
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#api-method-two-factor-generate-backup-codes)
|
|
199
197
|
*/
|
|
200
|
-
generateBackupCodes:
|
|
198
|
+
generateBackupCodes: import("better-call").StrictEndpoint<"/two-factor/generate-backup-codes", {
|
|
201
199
|
method: "POST";
|
|
202
200
|
body: z.ZodObject<{
|
|
203
201
|
password: z.ZodOptional<z.ZodString>;
|
|
204
202
|
}, z.core.$strip> | z.ZodObject<{
|
|
205
203
|
password: z.ZodString;
|
|
206
204
|
}, z.core.$strip>;
|
|
207
|
-
use: ((inputContext:
|
|
205
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
208
206
|
session: {
|
|
209
207
|
session: Record<string, any> & {
|
|
210
208
|
id: string;
|
|
@@ -276,7 +274,7 @@ declare const backupCode2fa: (opts: BackupCodeOptions) => {
|
|
|
276
274
|
*
|
|
277
275
|
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#api-method-two-factor-view-backup-codes)
|
|
278
276
|
*/
|
|
279
|
-
viewBackupCodes:
|
|
277
|
+
viewBackupCodes: import("better-call").StrictEndpoint<string, {
|
|
280
278
|
method: "POST";
|
|
281
279
|
body: z.ZodObject<{
|
|
282
280
|
userId: z.ZodCoercedString<unknown>;
|
|
@@ -51,7 +51,15 @@ async function getBackupCodes(backupCodes, key, options) {
|
|
|
51
51
|
}
|
|
52
52
|
const verifyBackupCodeBodySchema = z.object({
|
|
53
53
|
code: z.string().meta({ description: `A backup code to verify. Eg: "123456"` }),
|
|
54
|
+
/**
|
|
55
|
+
* Disable setting the session cookie
|
|
56
|
+
*/
|
|
54
57
|
disableSession: z.boolean().meta({ description: "If true, the session cookie will not be set." }).optional(),
|
|
58
|
+
/**
|
|
59
|
+
* if true, the device will be trusted
|
|
60
|
+
* for 30 days. It'll be refreshed on
|
|
61
|
+
* every sign in request within this time.
|
|
62
|
+
*/
|
|
55
63
|
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()
|
|
56
64
|
});
|
|
57
65
|
const viewBackupCodesBodySchema = z.object({ userId: z.coerce.string().meta({ description: `The user ID to view all backup codes. Eg: "user-id"` }) });
|
|
@@ -63,6 +71,21 @@ const backupCode2fa = (opts) => {
|
|
|
63
71
|
id: "backup_code",
|
|
64
72
|
version: PACKAGE_VERSION,
|
|
65
73
|
endpoints: {
|
|
74
|
+
/**
|
|
75
|
+
* ### Endpoint
|
|
76
|
+
*
|
|
77
|
+
* POST `/two-factor/verify-backup-code`
|
|
78
|
+
*
|
|
79
|
+
* ### API Methods
|
|
80
|
+
*
|
|
81
|
+
* **server:**
|
|
82
|
+
* `auth.api.verifyBackupCode`
|
|
83
|
+
*
|
|
84
|
+
* **client:**
|
|
85
|
+
* `authClient.twoFactor.verifyBackupCode`
|
|
86
|
+
*
|
|
87
|
+
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#api-method-two-factor-verify-backup-code)
|
|
88
|
+
*/
|
|
66
89
|
verifyBackupCode: createAuthEndpoint("/two-factor/verify-backup-code", {
|
|
67
90
|
method: "POST",
|
|
68
91
|
body: verifyBackupCodeBodySchema,
|
|
@@ -209,6 +232,21 @@ const backupCode2fa = (opts) => {
|
|
|
209
232
|
user: parseUserOutput(ctx.context.options, session.user)
|
|
210
233
|
});
|
|
211
234
|
}),
|
|
235
|
+
/**
|
|
236
|
+
* ### Endpoint
|
|
237
|
+
*
|
|
238
|
+
* POST `/two-factor/generate-backup-codes`
|
|
239
|
+
*
|
|
240
|
+
* ### API Methods
|
|
241
|
+
*
|
|
242
|
+
* **server:**
|
|
243
|
+
* `auth.api.generateBackupCodes`
|
|
244
|
+
*
|
|
245
|
+
* **client:**
|
|
246
|
+
* `authClient.twoFactor.generateBackupCodes`
|
|
247
|
+
*
|
|
248
|
+
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#api-method-two-factor-generate-backup-codes)
|
|
249
|
+
*/
|
|
212
250
|
generateBackupCodes: createAuthEndpoint("/two-factor/generate-backup-codes", {
|
|
213
251
|
method: "POST",
|
|
214
252
|
body: generateBackupCodesBodySchema,
|
|
@@ -264,6 +302,19 @@ const backupCode2fa = (opts) => {
|
|
|
264
302
|
backupCodes: backupCodes.backupCodes
|
|
265
303
|
});
|
|
266
304
|
}),
|
|
305
|
+
/**
|
|
306
|
+
* A server-only function that returns a user's decrypted two-factor
|
|
307
|
+
* backup codes. It is not exposed over HTTP and has no client method;
|
|
308
|
+
* call it from trusted server code with a `userId` taken from an
|
|
309
|
+
* authenticated session.
|
|
310
|
+
*
|
|
311
|
+
* ### API Methods
|
|
312
|
+
*
|
|
313
|
+
* **server:**
|
|
314
|
+
* `auth.api.viewBackupCodes`
|
|
315
|
+
*
|
|
316
|
+
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#api-method-two-factor-view-backup-codes)
|
|
317
|
+
*/
|
|
267
318
|
viewBackupCodes: createAuthEndpoint.serverOnly({
|
|
268
319
|
method: "POST",
|
|
269
320
|
body: viewBackupCodesBodySchema
|
|
@@ -287,4 +338,4 @@ const backupCode2fa = (opts) => {
|
|
|
287
338
|
};
|
|
288
339
|
};
|
|
289
340
|
//#endregion
|
|
290
|
-
export { backupCode2fa, generateBackupCodes };
|
|
341
|
+
export { backupCode2fa, encodeBackupCodes, generateBackupCodes, getBackupCodes, verifyBackupCode };
|
|
@@ -4,9 +4,6 @@ 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 { twoFactor } from "./index.mjs";
|
|
7
|
-
import * as _better_auth_core_utils_error_codes0 from "@better-auth/core/utils/error-codes";
|
|
8
|
-
import * as _better_fetch_fetch0 from "@better-fetch/fetch";
|
|
9
|
-
|
|
10
7
|
//#region src/plugins/two-factor/client.d.ts
|
|
11
8
|
declare const twoFactorClient: (options?: {
|
|
12
9
|
/**
|
|
@@ -53,21 +50,21 @@ declare const twoFactorClient: (options?: {
|
|
|
53
50
|
id: string;
|
|
54
51
|
name: string;
|
|
55
52
|
hooks: {
|
|
56
|
-
onSuccess(context:
|
|
53
|
+
onSuccess(context: import("@better-fetch/fetch").SuccessContext<any>): Promise<void>;
|
|
57
54
|
};
|
|
58
55
|
}[];
|
|
59
56
|
$ERROR_CODES: {
|
|
60
|
-
OTP_NOT_ENABLED:
|
|
61
|
-
OTP_HAS_EXPIRED:
|
|
62
|
-
TOTP_NOT_ENABLED:
|
|
63
|
-
TWO_FACTOR_NOT_ENABLED:
|
|
64
|
-
BACKUP_CODES_NOT_ENABLED:
|
|
65
|
-
INVALID_BACKUP_CODE:
|
|
66
|
-
INVALID_CODE:
|
|
67
|
-
TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE:
|
|
68
|
-
ACCOUNT_TEMPORARILY_LOCKED:
|
|
69
|
-
INVALID_TWO_FACTOR_COOKIE:
|
|
57
|
+
OTP_NOT_ENABLED: import("@better-auth/core/utils/error-codes").RawError<"OTP_NOT_ENABLED">;
|
|
58
|
+
OTP_HAS_EXPIRED: import("@better-auth/core/utils/error-codes").RawError<"OTP_HAS_EXPIRED">;
|
|
59
|
+
TOTP_NOT_ENABLED: import("@better-auth/core/utils/error-codes").RawError<"TOTP_NOT_ENABLED">;
|
|
60
|
+
TWO_FACTOR_NOT_ENABLED: import("@better-auth/core/utils/error-codes").RawError<"TWO_FACTOR_NOT_ENABLED">;
|
|
61
|
+
BACKUP_CODES_NOT_ENABLED: import("@better-auth/core/utils/error-codes").RawError<"BACKUP_CODES_NOT_ENABLED">;
|
|
62
|
+
INVALID_BACKUP_CODE: import("@better-auth/core/utils/error-codes").RawError<"INVALID_BACKUP_CODE">;
|
|
63
|
+
INVALID_CODE: import("@better-auth/core/utils/error-codes").RawError<"INVALID_CODE">;
|
|
64
|
+
TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE: import("@better-auth/core/utils/error-codes").RawError<"TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE">;
|
|
65
|
+
ACCOUNT_TEMPORARILY_LOCKED: import("@better-auth/core/utils/error-codes").RawError<"ACCOUNT_TEMPORARILY_LOCKED">;
|
|
66
|
+
INVALID_TWO_FACTOR_COOKIE: import("@better-auth/core/utils/error-codes").RawError<"INVALID_TWO_FACTOR_COOKIE">;
|
|
70
67
|
};
|
|
71
68
|
};
|
|
72
69
|
//#endregion
|
|
73
|
-
export { twoFactorClient };
|
|
70
|
+
export { type BackupCodeOptions, type OTPOptions, type TOTPOptions, TWO_FACTOR_ERROR_CODES, type TwoFactorOptions, type TwoFactorProvider, type TwoFactorTable, type UserWithTwoFactor, type backupCode2fa, type encodeBackupCodes, type generateBackupCodes, type getBackupCodes, type otp2fa, type totp2fa, twoFactorClient, type verifyBackupCode };
|