better-auth 1.6.26 → 1.6.28
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 +6 -1
- package/dist/api/dispatch.d.mts +1 -0
- package/dist/api/index.d.mts +508 -505
- package/dist/api/middlewares/authorization.d.mts +10 -14
- package/dist/api/middlewares/authorization.mjs +1 -2
- package/dist/api/middlewares/index.d.mts +1 -2
- package/dist/api/middlewares/origin-check.d.mts +5 -3
- package/dist/api/routes/account.d.mts +16 -13
- package/dist/api/routes/callback.d.mts +3 -1
- package/dist/api/routes/email-verification.d.mts +8 -4
- package/dist/api/routes/error.d.mts +3 -1
- package/dist/api/routes/index.d.mts +1 -2
- package/dist/api/routes/ok.d.mts +3 -1
- package/dist/api/routes/password.d.mts +10 -8
- package/dist/api/routes/session.d.mts +32 -30
- package/dist/api/routes/session.mjs +2 -3
- package/dist/api/routes/sign-in.d.mts +5 -3
- package/dist/api/routes/sign-out.d.mts +3 -1
- package/dist/api/routes/sign-up.d.mts +4 -3
- package/dist/api/routes/update-session.d.mts +5 -4
- package/dist/api/routes/update-user.d.mts +19 -18
- package/dist/auth/full.d.mts +1 -1
- package/dist/auth/minimal.d.mts +1 -1
- package/dist/client/config.d.mts +14 -12
- package/dist/client/config.mjs +2 -2
- package/dist/client/equality.d.mts +1 -0
- package/dist/client/index.d.mts +5 -6
- package/dist/client/lynx/index.d.mts +5 -4
- package/dist/client/lynx/lynx-store.d.mts +2 -1
- package/dist/client/parser.d.mts +3 -7
- package/dist/client/path-to-object.d.mts +4 -3
- package/dist/client/plugins/index.d.mts +1 -1
- package/dist/client/plugins/infer-plugin.d.mts +1 -0
- package/dist/client/query.d.mts +1 -0
- package/dist/client/react/index.d.mts +5 -4
- package/dist/client/react/react-store.d.mts +2 -1
- package/dist/client/session-atom.mjs +59 -46
- package/dist/client/session-refresh.d.mts +1 -0
- package/dist/client/solid/index.d.mts +5 -4
- package/dist/client/svelte/index.d.mts +5 -4
- package/dist/client/types.d.mts +2 -2
- package/dist/client/vanilla.d.mts +2 -1
- package/dist/client/vue/index.d.mts +5 -4
- package/dist/context/create-context.mjs +3 -3
- package/dist/context/helpers.mjs +2 -2
- package/dist/cookies/index.d.mts +7 -6
- package/dist/cookies/session-store.d.mts +0 -1
- package/dist/cookies/session-store.mjs +1 -2
- package/dist/crypto/index.d.mts +9 -2
- package/dist/crypto/jwt.d.mts +1 -0
- package/dist/crypto/password.d.mts +5 -1
- package/dist/db/adapter-base.d.mts +1 -0
- package/dist/db/adapter-kysely.d.mts +1 -0
- package/dist/db/field-converter.d.mts +1 -0
- package/dist/db/field.d.mts +10 -9
- package/dist/db/get-migration.d.mts +1 -0
- package/dist/db/get-schema.d.mts +1 -0
- package/dist/db/internal-adapter.d.mts +1 -0
- package/dist/db/internal-adapter.mjs +1 -2
- package/dist/db/revoke-unproven-account-access.d.mts +1 -0
- package/dist/db/schema.d.mts +2 -2
- package/dist/db/to-zod.d.mts +7 -3
- package/dist/db/with-hooks.d.mts +1 -0
- package/dist/index.d.mts +3 -4
- package/dist/integrations/next-js.d.mts +7 -4
- package/dist/integrations/node.d.mts +3 -2
- package/dist/integrations/svelte-kit.d.mts +9 -2
- package/dist/integrations/tanstack-start-solid.d.mts +5 -2
- package/dist/integrations/tanstack-start.d.mts +5 -2
- package/dist/oauth2/link-account.d.mts +1 -1
- package/dist/oauth2/state.d.mts +1 -0
- package/dist/oauth2/utils.d.mts +1 -0
- package/dist/package.mjs +1 -1
- package/dist/plugins/access/access.d.mts +1 -0
- package/dist/plugins/access/types.d.mts +5 -4
- package/dist/plugins/additional-fields/client.d.mts +1 -0
- package/dist/plugins/admin/access/statement.d.mts +0 -1
- package/dist/plugins/admin/admin.d.mts +137 -132
- 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 +25 -23
- package/dist/plugins/admin/index.d.mts +1 -1
- package/dist/plugins/admin/schema.d.mts +1 -1
- package/dist/plugins/admin/types.d.mts +2 -3
- package/dist/plugins/anonymous/client.d.mts +11 -9
- package/dist/plugins/anonymous/client.mjs +1 -1
- package/dist/plugins/anonymous/error-codes.d.mts +10 -8
- package/dist/plugins/anonymous/index.d.mts +19 -15
- package/dist/plugins/anonymous/types.d.mts +1 -1
- package/dist/plugins/bearer/index.d.mts +8 -5
- package/dist/plugins/captcha/index.d.mts +8 -5
- package/dist/plugins/captcha/types.d.mts +1 -0
- package/dist/plugins/custom-session/client.d.mts +1 -0
- package/dist/plugins/custom-session/index.d.mts +12 -7
- package/dist/plugins/device-authorization/client.d.mts +1 -0
- package/dist/plugins/device-authorization/index.d.mts +22 -19
- package/dist/plugins/email-otp/client.d.mts +6 -4
- package/dist/plugins/email-otp/client.mjs +1 -1
- package/dist/plugins/email-otp/error-codes.d.mts +5 -3
- package/dist/plugins/email-otp/index.d.mts +76 -69
- package/dist/plugins/email-otp/types.d.mts +1 -0
- package/dist/plugins/generic-oauth/client.d.mts +11 -10
- package/dist/plugins/generic-oauth/client.mjs +1 -1
- package/dist/plugins/generic-oauth/error-codes.d.mts +10 -8
- package/dist/plugins/generic-oauth/index.d.mts +45 -41
- package/dist/plugins/generic-oauth/providers/auth0.d.mts +1 -0
- package/dist/plugins/generic-oauth/providers/gumroad.d.mts +1 -0
- package/dist/plugins/generic-oauth/providers/hubspot.d.mts +1 -0
- package/dist/plugins/generic-oauth/providers/index.d.mts +1 -2
- package/dist/plugins/generic-oauth/providers/keycloak.d.mts +1 -0
- package/dist/plugins/generic-oauth/providers/line.d.mts +1 -0
- package/dist/plugins/generic-oauth/providers/microsoft-entra-id.d.mts +1 -0
- package/dist/plugins/generic-oauth/providers/okta.d.mts +1 -0
- package/dist/plugins/generic-oauth/providers/patreon.d.mts +1 -0
- package/dist/plugins/generic-oauth/providers/slack.d.mts +1 -0
- package/dist/plugins/generic-oauth/providers/yandex.d.mts +1 -0
- package/dist/plugins/generic-oauth/types.d.mts +2 -1
- package/dist/plugins/haveibeenpwned/index.d.mts +6 -3
- package/dist/plugins/index.d.mts +1 -4
- package/dist/plugins/jwt/client.d.mts +2 -1
- package/dist/plugins/jwt/index.d.mts +12 -9
- 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 +4 -2
- package/dist/plugins/jwt/verify.d.mts +1 -0
- package/dist/plugins/last-login-method/index.d.mts +6 -3
- package/dist/plugins/magic-link/client.d.mts +1 -0
- package/dist/plugins/magic-link/index.d.mts +6 -4
- package/dist/plugins/mcp/client/adapters.d.mts +1 -0
- package/dist/plugins/mcp/client/index.mjs +2 -4
- package/dist/plugins/mcp/index.d.mts +12 -11
- package/dist/plugins/multi-session/client.d.mts +4 -2
- package/dist/plugins/multi-session/client.mjs +1 -1
- package/dist/plugins/multi-session/error-codes.d.mts +3 -1
- package/dist/plugins/multi-session/index.d.mts +12 -8
- package/dist/plugins/oauth-popup/client.d.mts +12 -6
- package/dist/plugins/oauth-popup/client.mjs +3 -5
- package/dist/plugins/oauth-popup/error-codes.d.mts +6 -4
- package/dist/plugins/oauth-popup/index.d.mts +12 -8
- package/dist/plugins/oauth-popup/index.mjs +1 -1
- package/dist/plugins/oauth-popup/types.d.mts +2 -1
- package/dist/plugins/oauth-proxy/index.d.mts +9 -6
- package/dist/plugins/oauth-proxy/index.mjs +2 -2
- package/dist/plugins/oidc-provider/client.d.mts +2 -1
- package/dist/plugins/oidc-provider/index.d.mts +20 -18
- package/dist/plugins/oidc-provider/schema.d.mts +1 -0
- package/dist/plugins/oidc-provider/types.d.mts +1 -1
- package/dist/plugins/one-tap/client.d.mts +3 -1
- package/dist/plugins/one-tap/index.d.mts +3 -1
- package/dist/plugins/one-time-token/client.d.mts +2 -1
- package/dist/plugins/one-time-token/index.d.mts +7 -6
- package/dist/plugins/open-api/generator.d.mts +1 -0
- package/dist/plugins/open-api/generator.mjs +5 -5
- package/dist/plugins/open-api/index.d.mts +5 -3
- package/dist/plugins/organization/access/statement.d.mts +0 -1
- package/dist/plugins/organization/adapter.d.mts +82 -56
- package/dist/plugins/organization/client.d.mts +103 -104
- package/dist/plugins/organization/client.mjs +4 -7
- package/dist/plugins/organization/error-codes.d.mts +61 -59
- package/dist/plugins/organization/has-permission.d.mts +1 -0
- 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 +33 -9
- package/dist/plugins/organization/organization.mjs +1 -1
- package/dist/plugins/organization/permission.d.mts +2 -2
- package/dist/plugins/organization/routes/crud-access-control.d.mts +147 -27
- package/dist/plugins/organization/routes/crud-invites.d.mts +186 -65
- package/dist/plugins/organization/routes/crud-invites.mjs +1 -1
- package/dist/plugins/organization/routes/crud-members.d.mts +178 -56
- package/dist/plugins/organization/routes/crud-members.mjs +1 -1
- package/dist/plugins/organization/routes/crud-org.d.mts +130 -57
- package/dist/plugins/organization/routes/crud-team.d.mts +235 -66
- package/dist/plugins/organization/schema.d.mts +4 -4
- package/dist/plugins/organization/schema.mjs +1 -1
- package/dist/plugins/organization/types.d.mts +14 -14
- package/dist/plugins/phone-number/client.d.mts +15 -13
- package/dist/plugins/phone-number/client.mjs +1 -1
- package/dist/plugins/phone-number/error-codes.d.mts +14 -12
- package/dist/plugins/phone-number/index.d.mts +47 -41
- package/dist/plugins/phone-number/types.d.mts +1 -1
- package/dist/plugins/siwe/client.d.mts +1 -0
- package/dist/plugins/siwe/index.d.mts +5 -4
- package/dist/plugins/test-utils/index.d.mts +4 -2
- package/dist/plugins/test-utils/types.d.mts +0 -1
- package/dist/plugins/two-factor/backup-codes/index.d.mts +7 -5
- package/dist/plugins/two-factor/backup-codes/index.mjs +1 -1
- package/dist/plugins/two-factor/client.d.mts +15 -12
- package/dist/plugins/two-factor/client.mjs +1 -1
- package/dist/plugins/two-factor/error-code.d.mts +12 -10
- package/dist/plugins/two-factor/index.d.mts +36 -32
- package/dist/plugins/two-factor/otp/index.d.mts +4 -2
- package/dist/plugins/two-factor/totp/index.d.mts +7 -5
- package/dist/plugins/two-factor/types.d.mts +1 -1
- package/dist/plugins/username/client.d.mts +11 -9
- package/dist/plugins/username/client.mjs +1 -1
- package/dist/plugins/username/error-codes.d.mts +10 -8
- package/dist/plugins/username/index.d.mts +22 -17
- package/dist/plugins/username/schema.d.mts +5 -3
- package/dist/state.d.mts +1 -0
- package/dist/test-utils/test-instance.d.mts +3 -5
- package/dist/types/adapter.d.mts +1 -1
- package/dist/types/api.d.mts +2 -1
- package/dist/types/auth.d.mts +1 -0
- package/dist/types/helper.d.mts +5 -5
- package/dist/types/index.d.mts +2 -2
- package/dist/types/models.d.mts +1 -0
- package/dist/types/plugins.d.mts +3 -2
- package/dist/utils/index.d.mts +1 -2
- package/dist/utils/url.d.mts +1 -0
- package/package.json +12 -11
|
@@ -4,7 +4,11 @@ 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";
|
|
7
10
|
import * as z from "zod";
|
|
11
|
+
|
|
8
12
|
//#region src/plugins/two-factor/index.d.ts
|
|
9
13
|
declare module "@better-auth/core" {
|
|
10
14
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
@@ -32,7 +36,7 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
32
36
|
*
|
|
33
37
|
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#api-method-two-factor-enable)
|
|
34
38
|
*/
|
|
35
|
-
enableTwoFactor:
|
|
39
|
+
enableTwoFactor: _$better_call0.StrictEndpoint<"/two-factor/enable", {
|
|
36
40
|
method: "POST";
|
|
37
41
|
body: z.ZodObject<{
|
|
38
42
|
password: z.ZodOptional<z.ZodString>;
|
|
@@ -41,7 +45,7 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
41
45
|
password: z.ZodString;
|
|
42
46
|
issuer: z.ZodOptional<z.ZodString>;
|
|
43
47
|
}, z.core.$strip>;
|
|
44
|
-
use: (
|
|
48
|
+
use: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
|
|
45
49
|
session: {
|
|
46
50
|
session: Record<string, any> & {
|
|
47
51
|
id: string;
|
|
@@ -63,7 +67,7 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
63
67
|
image?: string | null | undefined;
|
|
64
68
|
};
|
|
65
69
|
};
|
|
66
|
-
}
|
|
70
|
+
}>>[];
|
|
67
71
|
metadata: {
|
|
68
72
|
openapi: {
|
|
69
73
|
summary: string;
|
|
@@ -114,14 +118,14 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
114
118
|
*
|
|
115
119
|
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#api-method-two-factor-disable)
|
|
116
120
|
*/
|
|
117
|
-
disableTwoFactor:
|
|
121
|
+
disableTwoFactor: _$better_call0.StrictEndpoint<"/two-factor/disable", {
|
|
118
122
|
method: "POST";
|
|
119
123
|
body: z.ZodObject<{
|
|
120
124
|
password: z.ZodOptional<z.ZodString>;
|
|
121
125
|
}, z.core.$strip> | z.ZodObject<{
|
|
122
126
|
password: z.ZodString;
|
|
123
127
|
}, z.core.$strip>;
|
|
124
|
-
use: (
|
|
128
|
+
use: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
|
|
125
129
|
session: {
|
|
126
130
|
session: Record<string, any> & {
|
|
127
131
|
id: string;
|
|
@@ -143,7 +147,7 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
143
147
|
image?: string | null | undefined;
|
|
144
148
|
};
|
|
145
149
|
};
|
|
146
|
-
}
|
|
150
|
+
}>>[];
|
|
147
151
|
metadata: {
|
|
148
152
|
openapi: {
|
|
149
153
|
summary: string;
|
|
@@ -170,7 +174,7 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
170
174
|
}, {
|
|
171
175
|
status: boolean;
|
|
172
176
|
}>;
|
|
173
|
-
verifyBackupCode:
|
|
177
|
+
verifyBackupCode: _$better_call0.StrictEndpoint<"/two-factor/verify-backup-code", {
|
|
174
178
|
method: "POST";
|
|
175
179
|
body: z.ZodObject<{
|
|
176
180
|
code: z.ZodString;
|
|
@@ -281,14 +285,14 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
281
285
|
image?: string | null | undefined;
|
|
282
286
|
}) | UserWithTwoFactor;
|
|
283
287
|
}>;
|
|
284
|
-
generateBackupCodes:
|
|
288
|
+
generateBackupCodes: _$better_call0.StrictEndpoint<"/two-factor/generate-backup-codes", {
|
|
285
289
|
method: "POST";
|
|
286
290
|
body: z.ZodObject<{
|
|
287
291
|
password: z.ZodOptional<z.ZodString>;
|
|
288
292
|
}, z.core.$strip> | z.ZodObject<{
|
|
289
293
|
password: z.ZodString;
|
|
290
294
|
}, z.core.$strip>;
|
|
291
|
-
use: (
|
|
295
|
+
use: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
|
|
292
296
|
session: {
|
|
293
297
|
session: Record<string, any> & {
|
|
294
298
|
id: string;
|
|
@@ -310,7 +314,7 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
310
314
|
image?: string | null | undefined;
|
|
311
315
|
};
|
|
312
316
|
};
|
|
313
|
-
}
|
|
317
|
+
}>>[];
|
|
314
318
|
metadata: {
|
|
315
319
|
openapi: {
|
|
316
320
|
description: string;
|
|
@@ -347,7 +351,7 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
347
351
|
status: boolean;
|
|
348
352
|
backupCodes: string[];
|
|
349
353
|
}>;
|
|
350
|
-
viewBackupCodes:
|
|
354
|
+
viewBackupCodes: _$better_call0.StrictEndpoint<string, {
|
|
351
355
|
method: "POST";
|
|
352
356
|
body: z.ZodObject<{
|
|
353
357
|
userId: z.ZodCoercedString<unknown>;
|
|
@@ -356,7 +360,7 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
356
360
|
status: boolean;
|
|
357
361
|
backupCodes: string[];
|
|
358
362
|
}>;
|
|
359
|
-
sendTwoFactorOTP:
|
|
363
|
+
sendTwoFactorOTP: _$better_call0.StrictEndpoint<"/two-factor/send-otp", {
|
|
360
364
|
method: "POST";
|
|
361
365
|
body: z.ZodOptional<z.ZodObject<{
|
|
362
366
|
trustDevice: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -387,7 +391,7 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
387
391
|
}, {
|
|
388
392
|
status: boolean;
|
|
389
393
|
}>;
|
|
390
|
-
verifyTwoFactorOTP:
|
|
394
|
+
verifyTwoFactorOTP: _$better_call0.StrictEndpoint<"/two-factor/verify-otp", {
|
|
391
395
|
method: "POST";
|
|
392
396
|
body: z.ZodObject<{
|
|
393
397
|
code: z.ZodString;
|
|
@@ -476,7 +480,7 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
476
480
|
image?: string | null | undefined;
|
|
477
481
|
};
|
|
478
482
|
}>;
|
|
479
|
-
generateTOTP:
|
|
483
|
+
generateTOTP: _$better_call0.StrictEndpoint<string, {
|
|
480
484
|
method: "POST";
|
|
481
485
|
body: z.ZodObject<{
|
|
482
486
|
secret: z.ZodString;
|
|
@@ -507,9 +511,9 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
507
511
|
}, {
|
|
508
512
|
code: string;
|
|
509
513
|
}>;
|
|
510
|
-
getTOTPURI:
|
|
514
|
+
getTOTPURI: _$better_call0.StrictEndpoint<"/two-factor/get-totp-uri", {
|
|
511
515
|
method: "POST";
|
|
512
|
-
use: (
|
|
516
|
+
use: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
|
|
513
517
|
session: {
|
|
514
518
|
session: Record<string, any> & {
|
|
515
519
|
id: string;
|
|
@@ -531,7 +535,7 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
531
535
|
image?: string | null | undefined;
|
|
532
536
|
};
|
|
533
537
|
};
|
|
534
|
-
}
|
|
538
|
+
}>>[];
|
|
535
539
|
body: z.ZodObject<{
|
|
536
540
|
password: z.ZodOptional<z.ZodString>;
|
|
537
541
|
}, z.core.$strip> | z.ZodObject<{
|
|
@@ -563,7 +567,7 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
563
567
|
}, {
|
|
564
568
|
totpURI: string;
|
|
565
569
|
}>;
|
|
566
|
-
verifyTOTP:
|
|
570
|
+
verifyTOTP: _$better_call0.StrictEndpoint<"/two-factor/verify-totp", {
|
|
567
571
|
method: "POST";
|
|
568
572
|
body: z.ZodObject<{
|
|
569
573
|
code: z.ZodString;
|
|
@@ -611,11 +615,11 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
611
615
|
options: NoInfer<O>;
|
|
612
616
|
hooks: {
|
|
613
617
|
after: {
|
|
614
|
-
matcher(context:
|
|
615
|
-
handler: (inputContext:
|
|
618
|
+
matcher(context: _$_better_auth_core0.HookEndpointContext): boolean;
|
|
619
|
+
handler: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
|
|
616
620
|
twoFactorRedirect: boolean;
|
|
617
621
|
twoFactorMethods: string[];
|
|
618
|
-
} | undefined
|
|
622
|
+
} | undefined>>;
|
|
619
623
|
}[];
|
|
620
624
|
};
|
|
621
625
|
schema: {
|
|
@@ -680,17 +684,17 @@ declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
680
684
|
max: number;
|
|
681
685
|
}[];
|
|
682
686
|
$ERROR_CODES: {
|
|
683
|
-
OTP_NOT_ENABLED:
|
|
684
|
-
OTP_HAS_EXPIRED:
|
|
685
|
-
TOTP_NOT_ENABLED:
|
|
686
|
-
TWO_FACTOR_NOT_ENABLED:
|
|
687
|
-
BACKUP_CODES_NOT_ENABLED:
|
|
688
|
-
INVALID_BACKUP_CODE:
|
|
689
|
-
INVALID_CODE:
|
|
690
|
-
TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE:
|
|
691
|
-
ACCOUNT_TEMPORARILY_LOCKED:
|
|
692
|
-
INVALID_TWO_FACTOR_COOKIE:
|
|
687
|
+
OTP_NOT_ENABLED: _$_better_auth_core_utils_error_codes0.RawError<"OTP_NOT_ENABLED">;
|
|
688
|
+
OTP_HAS_EXPIRED: _$_better_auth_core_utils_error_codes0.RawError<"OTP_HAS_EXPIRED">;
|
|
689
|
+
TOTP_NOT_ENABLED: _$_better_auth_core_utils_error_codes0.RawError<"TOTP_NOT_ENABLED">;
|
|
690
|
+
TWO_FACTOR_NOT_ENABLED: _$_better_auth_core_utils_error_codes0.RawError<"TWO_FACTOR_NOT_ENABLED">;
|
|
691
|
+
BACKUP_CODES_NOT_ENABLED: _$_better_auth_core_utils_error_codes0.RawError<"BACKUP_CODES_NOT_ENABLED">;
|
|
692
|
+
INVALID_BACKUP_CODE: _$_better_auth_core_utils_error_codes0.RawError<"INVALID_BACKUP_CODE">;
|
|
693
|
+
INVALID_CODE: _$_better_auth_core_utils_error_codes0.RawError<"INVALID_CODE">;
|
|
694
|
+
TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE: _$_better_auth_core_utils_error_codes0.RawError<"TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE">;
|
|
695
|
+
ACCOUNT_TEMPORARILY_LOCKED: _$_better_auth_core_utils_error_codes0.RawError<"ACCOUNT_TEMPORARILY_LOCKED">;
|
|
696
|
+
INVALID_TWO_FACTOR_COOKIE: _$_better_auth_core_utils_error_codes0.RawError<"INVALID_TWO_FACTOR_COOKIE">;
|
|
693
697
|
};
|
|
694
698
|
};
|
|
695
699
|
//#endregion
|
|
696
|
-
export {
|
|
700
|
+
export { BackupCodeOptions, OTPOptions, TOTPOptions, TWO_FACTOR_ERROR_CODES, TwoFactorOptions, TwoFactorProvider, TwoFactorTable, UserWithTwoFactor, backupCode2fa, encodeBackupCodes, generateBackupCodes, getBackupCodes, otp2fa, totp2fa, twoFactor, twoFactorClient, verifyBackupCode };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { UserWithTwoFactor } from "../types.mjs";
|
|
2
2
|
import { Awaitable, GenericEndpointContext } from "@better-auth/core";
|
|
3
|
+
import * as _$better_call0 from "better-call";
|
|
3
4
|
import * as z from "zod";
|
|
5
|
+
|
|
4
6
|
//#region src/plugins/two-factor/otp/index.d.ts
|
|
5
7
|
interface OTPOptions {
|
|
6
8
|
/**
|
|
@@ -73,7 +75,7 @@ declare const otp2fa: (options?: OTPOptions | undefined) => {
|
|
|
73
75
|
*
|
|
74
76
|
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#api-method-two-factor-send-otp)
|
|
75
77
|
*/
|
|
76
|
-
sendTwoFactorOTP:
|
|
78
|
+
sendTwoFactorOTP: _$better_call0.StrictEndpoint<"/two-factor/send-otp", {
|
|
77
79
|
method: "POST";
|
|
78
80
|
body: z.ZodOptional<z.ZodObject<{
|
|
79
81
|
trustDevice: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -119,7 +121,7 @@ declare const otp2fa: (options?: OTPOptions | undefined) => {
|
|
|
119
121
|
*
|
|
120
122
|
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#api-method-two-factor-verify-otp)
|
|
121
123
|
*/
|
|
122
|
-
verifyTwoFactorOTP:
|
|
124
|
+
verifyTwoFactorOTP: _$better_call0.StrictEndpoint<"/two-factor/verify-otp", {
|
|
123
125
|
method: "POST";
|
|
124
126
|
body: z.ZodObject<{
|
|
125
127
|
code: z.ZodString;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { BackupCodeOptions } from "../backup-codes/index.mjs";
|
|
2
2
|
import { UserWithTwoFactor } from "../types.mjs";
|
|
3
|
+
import * as _$better_call0 from "better-call";
|
|
3
4
|
import * as z from "zod";
|
|
5
|
+
|
|
4
6
|
//#region src/plugins/two-factor/totp/index.d.ts
|
|
5
7
|
type TOTPOptions = {
|
|
6
8
|
/**
|
|
@@ -50,7 +52,7 @@ declare const totp2fa: (options?: TOTPOptions | undefined) => {
|
|
|
50
52
|
*
|
|
51
53
|
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#totp)
|
|
52
54
|
*/
|
|
53
|
-
generateTOTP:
|
|
55
|
+
generateTOTP: _$better_call0.StrictEndpoint<string, {
|
|
54
56
|
method: "POST";
|
|
55
57
|
body: z.ZodObject<{
|
|
56
58
|
secret: z.ZodString;
|
|
@@ -96,9 +98,9 @@ declare const totp2fa: (options?: TOTPOptions | undefined) => {
|
|
|
96
98
|
*
|
|
97
99
|
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#getting-totp-uri)
|
|
98
100
|
*/
|
|
99
|
-
getTOTPURI:
|
|
101
|
+
getTOTPURI: _$better_call0.StrictEndpoint<"/two-factor/get-totp-uri", {
|
|
100
102
|
method: "POST";
|
|
101
|
-
use: (
|
|
103
|
+
use: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
|
|
102
104
|
session: {
|
|
103
105
|
session: Record<string, any> & {
|
|
104
106
|
id: string;
|
|
@@ -120,7 +122,7 @@ declare const totp2fa: (options?: TOTPOptions | undefined) => {
|
|
|
120
122
|
image?: string | null | undefined;
|
|
121
123
|
};
|
|
122
124
|
};
|
|
123
|
-
}
|
|
125
|
+
}>>[];
|
|
124
126
|
body: z.ZodObject<{
|
|
125
127
|
password: z.ZodOptional<z.ZodString>;
|
|
126
128
|
}, z.core.$strip> | z.ZodObject<{
|
|
@@ -167,7 +169,7 @@ declare const totp2fa: (options?: TOTPOptions | undefined) => {
|
|
|
167
169
|
*
|
|
168
170
|
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/2fa#verifying-totp)
|
|
169
171
|
*/
|
|
170
|
-
verifyTOTP:
|
|
172
|
+
verifyTOTP: _$better_call0.StrictEndpoint<"/two-factor/verify-totp", {
|
|
171
173
|
method: "POST";
|
|
172
174
|
body: z.ZodObject<{
|
|
173
175
|
code: z.ZodString;
|
|
@@ -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";
|
|
4
3
|
import { BackupCodeOptions } from "./backup-codes/index.mjs";
|
|
5
4
|
import { OTPOptions } from "./otp/index.mjs";
|
|
6
5
|
import { schema } from "./schema.mjs";
|
|
7
6
|
import { TOTPOptions } from "./totp/index.mjs";
|
|
8
7
|
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,5 +1,7 @@
|
|
|
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
|
+
|
|
3
5
|
//#region src/plugins/username/client.d.ts
|
|
4
6
|
declare const usernameClient: () => {
|
|
5
7
|
id: "username";
|
|
@@ -10,15 +12,15 @@ declare const usernameClient: () => {
|
|
|
10
12
|
signal: "$sessionSignal";
|
|
11
13
|
}[];
|
|
12
14
|
$ERROR_CODES: {
|
|
13
|
-
EMAIL_NOT_VERIFIED:
|
|
14
|
-
UNEXPECTED_ERROR:
|
|
15
|
-
INVALID_USERNAME_OR_PASSWORD:
|
|
16
|
-
USERNAME_IS_ALREADY_TAKEN:
|
|
17
|
-
USERNAME_TOO_SHORT:
|
|
18
|
-
USERNAME_TOO_LONG:
|
|
19
|
-
INVALID_USERNAME:
|
|
20
|
-
INVALID_DISPLAY_USERNAME:
|
|
15
|
+
EMAIL_NOT_VERIFIED: _$_better_auth_core_utils_error_codes0.RawError<"EMAIL_NOT_VERIFIED">;
|
|
16
|
+
UNEXPECTED_ERROR: _$_better_auth_core_utils_error_codes0.RawError<"UNEXPECTED_ERROR">;
|
|
17
|
+
INVALID_USERNAME_OR_PASSWORD: _$_better_auth_core_utils_error_codes0.RawError<"INVALID_USERNAME_OR_PASSWORD">;
|
|
18
|
+
USERNAME_IS_ALREADY_TAKEN: _$_better_auth_core_utils_error_codes0.RawError<"USERNAME_IS_ALREADY_TAKEN">;
|
|
19
|
+
USERNAME_TOO_SHORT: _$_better_auth_core_utils_error_codes0.RawError<"USERNAME_TOO_SHORT">;
|
|
20
|
+
USERNAME_TOO_LONG: _$_better_auth_core_utils_error_codes0.RawError<"USERNAME_TOO_LONG">;
|
|
21
|
+
INVALID_USERNAME: _$_better_auth_core_utils_error_codes0.RawError<"INVALID_USERNAME">;
|
|
22
|
+
INVALID_DISPLAY_USERNAME: _$_better_auth_core_utils_error_codes0.RawError<"INVALID_DISPLAY_USERNAME">;
|
|
21
23
|
};
|
|
22
24
|
};
|
|
23
25
|
//#endregion
|
|
24
|
-
export {
|
|
26
|
+
export { usernameClient };
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import * as _$_better_auth_core_utils_error_codes0 from "@better-auth/core/utils/error-codes";
|
|
2
|
+
|
|
1
3
|
//#region src/plugins/username/error-codes.d.ts
|
|
2
4
|
declare const USERNAME_ERROR_CODES: {
|
|
3
|
-
EMAIL_NOT_VERIFIED:
|
|
4
|
-
UNEXPECTED_ERROR:
|
|
5
|
-
INVALID_USERNAME_OR_PASSWORD:
|
|
6
|
-
USERNAME_IS_ALREADY_TAKEN:
|
|
7
|
-
USERNAME_TOO_SHORT:
|
|
8
|
-
USERNAME_TOO_LONG:
|
|
9
|
-
INVALID_USERNAME:
|
|
10
|
-
INVALID_DISPLAY_USERNAME:
|
|
5
|
+
EMAIL_NOT_VERIFIED: _$_better_auth_core_utils_error_codes0.RawError<"EMAIL_NOT_VERIFIED">;
|
|
6
|
+
UNEXPECTED_ERROR: _$_better_auth_core_utils_error_codes0.RawError<"UNEXPECTED_ERROR">;
|
|
7
|
+
INVALID_USERNAME_OR_PASSWORD: _$_better_auth_core_utils_error_codes0.RawError<"INVALID_USERNAME_OR_PASSWORD">;
|
|
8
|
+
USERNAME_IS_ALREADY_TAKEN: _$_better_auth_core_utils_error_codes0.RawError<"USERNAME_IS_ALREADY_TAKEN">;
|
|
9
|
+
USERNAME_TOO_SHORT: _$_better_auth_core_utils_error_codes0.RawError<"USERNAME_TOO_SHORT">;
|
|
10
|
+
USERNAME_TOO_LONG: _$_better_auth_core_utils_error_codes0.RawError<"USERNAME_TOO_LONG">;
|
|
11
|
+
INVALID_USERNAME: _$_better_auth_core_utils_error_codes0.RawError<"INVALID_USERNAME">;
|
|
12
|
+
INVALID_DISPLAY_USERNAME: _$_better_auth_core_utils_error_codes0.RawError<"INVALID_DISPLAY_USERNAME">;
|
|
11
13
|
};
|
|
12
14
|
//#endregion
|
|
13
15
|
export { USERNAME_ERROR_CODES };
|
|
@@ -1,7 +1,12 @@
|
|
|
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";
|
|
4
8
|
import * as z from "zod";
|
|
9
|
+
|
|
5
10
|
//#region src/plugins/username/index.d.ts
|
|
6
11
|
declare module "@better-auth/core" {
|
|
7
12
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
@@ -71,7 +76,7 @@ type UsernameOptions = {
|
|
|
71
76
|
declare const username: (options?: UsernameOptions | undefined) => {
|
|
72
77
|
id: "username";
|
|
73
78
|
version: string;
|
|
74
|
-
init(ctx:
|
|
79
|
+
init(ctx: _$_better_auth_core0.AuthContext): {
|
|
75
80
|
options: {
|
|
76
81
|
databaseHooks: {
|
|
77
82
|
user: {
|
|
@@ -84,7 +89,7 @@ declare const username: (options?: UsernameOptions | undefined) => {
|
|
|
84
89
|
emailVerified: boolean;
|
|
85
90
|
name: string;
|
|
86
91
|
image?: string | null | undefined;
|
|
87
|
-
} & Record<string, unknown>, context:
|
|
92
|
+
} & Record<string, unknown>, context: _$_better_auth_core0.GenericEndpointContext | null): Promise<{
|
|
88
93
|
data: {
|
|
89
94
|
username: string;
|
|
90
95
|
displayUsername: string;
|
|
@@ -118,7 +123,7 @@ declare const username: (options?: UsernameOptions | undefined) => {
|
|
|
118
123
|
emailVerified: boolean;
|
|
119
124
|
name: string;
|
|
120
125
|
image?: string | null | undefined;
|
|
121
|
-
}> & Record<string, unknown>, context:
|
|
126
|
+
}> & Record<string, unknown>, context: _$_better_auth_core0.GenericEndpointContext | null): Promise<{
|
|
122
127
|
data: {
|
|
123
128
|
displayUsername?: string | undefined;
|
|
124
129
|
username: string;
|
|
@@ -148,7 +153,7 @@ declare const username: (options?: UsernameOptions | undefined) => {
|
|
|
148
153
|
};
|
|
149
154
|
};
|
|
150
155
|
endpoints: {
|
|
151
|
-
signInUsername:
|
|
156
|
+
signInUsername: _$better_call0.StrictEndpoint<"/sign-in/username", {
|
|
152
157
|
method: "POST";
|
|
153
158
|
body: z.ZodObject<{
|
|
154
159
|
username: z.ZodString;
|
|
@@ -225,7 +230,7 @@ declare const username: (options?: UsernameOptions | undefined) => {
|
|
|
225
230
|
displayUsername: string;
|
|
226
231
|
};
|
|
227
232
|
}>;
|
|
228
|
-
isUsernameAvailable:
|
|
233
|
+
isUsernameAvailable: _$better_call0.StrictEndpoint<"/is-username-available", {
|
|
229
234
|
method: "POST";
|
|
230
235
|
body: z.ZodObject<{
|
|
231
236
|
username: z.ZodString;
|
|
@@ -244,14 +249,14 @@ declare const username: (options?: UsernameOptions | undefined) => {
|
|
|
244
249
|
unique: true;
|
|
245
250
|
returned: true;
|
|
246
251
|
transform: {
|
|
247
|
-
input(value:
|
|
252
|
+
input(value: _$_better_auth_core_db0.DBPrimitive): string | number | boolean | Date | Record<string, unknown> | unknown[] | null | undefined;
|
|
248
253
|
};
|
|
249
254
|
};
|
|
250
255
|
displayUsername: {
|
|
251
256
|
type: "string";
|
|
252
257
|
required: false;
|
|
253
258
|
transform: {
|
|
254
|
-
input(value:
|
|
259
|
+
input(value: _$_better_auth_core_db0.DBPrimitive): string | number | boolean | Date | Record<string, unknown> | unknown[] | null | undefined;
|
|
255
260
|
};
|
|
256
261
|
};
|
|
257
262
|
};
|
|
@@ -259,20 +264,20 @@ declare const username: (options?: UsernameOptions | undefined) => {
|
|
|
259
264
|
};
|
|
260
265
|
hooks: {
|
|
261
266
|
before: {
|
|
262
|
-
matcher(context:
|
|
263
|
-
handler: (inputContext:
|
|
267
|
+
matcher(context: _$_better_auth_core0.HookEndpointContext): boolean;
|
|
268
|
+
handler: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<void>>;
|
|
264
269
|
}[];
|
|
265
270
|
};
|
|
266
271
|
options: UsernameOptions | undefined;
|
|
267
272
|
$ERROR_CODES: {
|
|
268
|
-
EMAIL_NOT_VERIFIED:
|
|
269
|
-
UNEXPECTED_ERROR:
|
|
270
|
-
INVALID_USERNAME_OR_PASSWORD:
|
|
271
|
-
USERNAME_IS_ALREADY_TAKEN:
|
|
272
|
-
USERNAME_TOO_SHORT:
|
|
273
|
-
USERNAME_TOO_LONG:
|
|
274
|
-
INVALID_USERNAME:
|
|
275
|
-
INVALID_DISPLAY_USERNAME:
|
|
273
|
+
EMAIL_NOT_VERIFIED: _$_better_auth_core_utils_error_codes0.RawError<"EMAIL_NOT_VERIFIED">;
|
|
274
|
+
UNEXPECTED_ERROR: _$_better_auth_core_utils_error_codes0.RawError<"UNEXPECTED_ERROR">;
|
|
275
|
+
INVALID_USERNAME_OR_PASSWORD: _$_better_auth_core_utils_error_codes0.RawError<"INVALID_USERNAME_OR_PASSWORD">;
|
|
276
|
+
USERNAME_IS_ALREADY_TAKEN: _$_better_auth_core_utils_error_codes0.RawError<"USERNAME_IS_ALREADY_TAKEN">;
|
|
277
|
+
USERNAME_TOO_SHORT: _$_better_auth_core_utils_error_codes0.RawError<"USERNAME_TOO_SHORT">;
|
|
278
|
+
USERNAME_TOO_LONG: _$_better_auth_core_utils_error_codes0.RawError<"USERNAME_TOO_LONG">;
|
|
279
|
+
INVALID_USERNAME: _$_better_auth_core_utils_error_codes0.RawError<"INVALID_USERNAME">;
|
|
280
|
+
INVALID_DISPLAY_USERNAME: _$_better_auth_core_utils_error_codes0.RawError<"INVALID_DISPLAY_USERNAME">;
|
|
276
281
|
};
|
|
277
282
|
};
|
|
278
283
|
//#endregion
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as _$_better_auth_core_db0 from "@better-auth/core/db";
|
|
2
|
+
|
|
1
3
|
//#region src/plugins/username/schema.d.ts
|
|
2
4
|
declare const getSchema: (normalizer: {
|
|
3
5
|
username: (username: string) => string;
|
|
@@ -12,14 +14,14 @@ declare const getSchema: (normalizer: {
|
|
|
12
14
|
unique: true;
|
|
13
15
|
returned: true;
|
|
14
16
|
transform: {
|
|
15
|
-
input(value:
|
|
17
|
+
input(value: _$_better_auth_core_db0.DBPrimitive): string | number | boolean | Date | Record<string, unknown> | unknown[] | null | undefined;
|
|
16
18
|
};
|
|
17
19
|
};
|
|
18
20
|
displayUsername: {
|
|
19
21
|
type: "string";
|
|
20
22
|
required: false;
|
|
21
23
|
transform: {
|
|
22
|
-
input(value:
|
|
24
|
+
input(value: _$_better_auth_core_db0.DBPrimitive): string | number | boolean | Date | Record<string, unknown> | unknown[] | null | undefined;
|
|
23
25
|
};
|
|
24
26
|
};
|
|
25
27
|
};
|
|
@@ -27,4 +29,4 @@ declare const getSchema: (normalizer: {
|
|
|
27
29
|
};
|
|
28
30
|
type UsernameSchema = ReturnType<typeof getSchema>;
|
|
29
31
|
//#endregion
|
|
30
|
-
export { UsernameSchema
|
|
32
|
+
export { UsernameSchema };
|
package/dist/state.d.mts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
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";
|
|
5
3
|
import { AuthClient } from "../client/vanilla.mjs";
|
|
6
|
-
import "../client/index.mjs";
|
|
7
4
|
import { setCookieToHeader } from "../cookies/cookie-utils.mjs";
|
|
8
|
-
import "../cookies/index.mjs";
|
|
9
5
|
import { Awaitable, BetterAuthClientOptions, BetterAuthOptions } from "@better-auth/core";
|
|
6
|
+
import * as _$_better_auth_core_db_adapter0 from "@better-auth/core/db/adapter";
|
|
10
7
|
import { SuccessContext } from "@better-fetch/fetch";
|
|
8
|
+
|
|
11
9
|
//#region src/test-utils/test-instance.d.ts
|
|
12
10
|
declare function getTestInstance<O extends Partial<BetterAuthOptions>, C extends BetterAuthClientOptions>(options?: O | undefined, config?: {
|
|
13
11
|
clientOptions?: C;
|
|
@@ -50,7 +48,7 @@ declare function getTestInstance<O extends Partial<BetterAuthOptions>, C extends
|
|
|
50
48
|
cookieSetter: typeof setCookieToHeader;
|
|
51
49
|
customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
52
50
|
sessionSetter: (headers: Headers) => (context: SuccessContext) => void;
|
|
53
|
-
db:
|
|
51
|
+
db: _$_better_auth_core_db_adapter0.DBAdapter<BetterAuthOptions>;
|
|
54
52
|
runWithUser: (email: string, password: string, fn: (headers: Headers) => Awaitable<void>) => Promise<void>;
|
|
55
53
|
}>;
|
|
56
54
|
//#endregion
|
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 type
|
|
2
|
+
export { type DBAdapter$1 as DBAdapter, type DBAdapterInstance, type DBAdapterSchemaCreation, type DBTransactionAdapter, type JoinConfig, type JoinOption, type Where$1 as Where };
|
package/dist/types/api.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { PrettifyDeep, UnionToIntersection } from "./helper.mjs";
|
|
2
2
|
import { Endpoint } from "better-call";
|
|
3
|
+
|
|
3
4
|
//#region src/types/api.d.ts
|
|
4
|
-
type FilteredAPI<API> = Omit<API, API extends { [key in infer K]: Endpoint
|
|
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 {
|
|
5
6
|
isAction: false;
|
|
6
7
|
} | {
|
|
7
8
|
scope: "http";
|
package/dist/types/auth.d.mts
CHANGED
|
@@ -4,6 +4,7 @@ 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
|
+
|
|
7
8
|
//#region src/types/auth.d.ts
|
|
8
9
|
type Auth<Options extends BetterAuthOptions = BetterAuthOptions> = {
|
|
9
10
|
handler: (request: Request) => Promise<Response>;
|
package/dist/types/helper.d.mts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
//#region src/types/helper.d.ts
|
|
2
2
|
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
3
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]
|
|
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
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
|
|
6
|
+
type RequiredKeysOf<BaseType extends object> = Exclude<{ [Key in keyof BaseType]: BaseType extends Record<Key, BaseType[Key]> ? Key : never }[keyof BaseType], undefined>;
|
|
7
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]
|
|
8
|
+
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]
|
|
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;
|
|
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
|
+
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.
|
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 } from "@better-auth/core";
|
|
9
|
-
export
|
|
10
|
-
export {
|
|
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, Verification, Where };
|
package/dist/types/models.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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
|
+
|
|
4
5
|
//#region src/types/models.d.ts
|
|
5
6
|
type AdditionalUserFieldsInput<Options extends BetterAuthOptions> = InferDBFieldsFromPluginsInput<"user", Options["plugins"]> & InferDBFieldsFromOptionsInput<Options["user"]>;
|
|
6
7
|
type AdditionalSessionFieldsInput<Options extends BetterAuthOptions> = InferDBFieldsFromPluginsInput<"session", Options["plugins"]> & InferDBFieldsFromOptionsInput<Options["session"]>;
|
package/dist/types/plugins.d.mts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
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
|
+
|
|
4
5
|
//#region src/types/plugins.d.ts
|
|
5
6
|
type InferOptionSchema<S extends BetterAuthPluginDBSchema> = S extends Record<string, {
|
|
6
7
|
fields: infer Fields;
|
|
7
8
|
}> ? { [K in keyof S]?: {
|
|
8
9
|
modelName?: string | undefined;
|
|
9
|
-
fields?: { [P in keyof Fields]?: string
|
|
10
|
-
}
|
|
10
|
+
fields?: { [P in keyof Fields]?: string } | undefined;
|
|
11
|
+
} } : never;
|
|
11
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">> : {};
|
|
12
13
|
type InferPluginIDs<O extends BetterAuthOptions> = O["plugins"] extends Array<infer P> ? UnionToIntersection<P extends BetterAuthPlugin ? P["id"] : never> : never;
|
|
13
14
|
type ExtractInitContext<P extends BetterAuthPlugin> = P["init"] extends ((...args: any[]) => infer R) ? Awaited<R> extends {
|