better-auth 0.4.5 → 0.4.6
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/drizzle.d.ts +1 -1
- package/dist/adapters/drizzle.js +5 -6
- package/dist/adapters/mongodb.d.ts +1 -1
- package/dist/adapters/prisma.d.ts +1 -1
- package/dist/api.d.ts +1 -1
- package/dist/cli.js +5 -6
- package/dist/client/plugins.d.ts +3 -3
- package/dist/client.d.ts +1 -1
- package/dist/{index-B5SM-JCa.d.ts → index-BJKlHmT9.d.ts} +50 -25
- package/dist/{index-45sX2yHG.d.ts → index-DFhZxdCd.d.ts} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +68 -12
- package/dist/next-js.d.ts +12 -1
- package/dist/node.d.ts +1 -1
- package/dist/plugins.d.ts +3 -3
- package/dist/plugins.js +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/solid-start.d.ts +1 -1
- package/dist/solid.d.ts +1 -1
- package/dist/svelte-kit.d.ts +1 -1
- package/dist/svelte.d.ts +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/vue.d.ts +1 -1
- package/package.json +1 -1
package/dist/adapters/drizzle.js
CHANGED
|
@@ -41,8 +41,6 @@ var getAuthTables = (options) => {
|
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
const { user, session, account, ...pluginTables } = pluginSchema || {};
|
|
44
|
-
const accountFields = options.account?.fields;
|
|
45
|
-
const userFields = options.user?.fields;
|
|
46
44
|
return {
|
|
47
45
|
user: {
|
|
48
46
|
tableName: options.user?.modelName || "user",
|
|
@@ -84,7 +82,7 @@ var getAuthTables = (options) => {
|
|
|
84
82
|
...user?.fields,
|
|
85
83
|
...options.user?.additionalFields
|
|
86
84
|
},
|
|
87
|
-
order:
|
|
85
|
+
order: 1
|
|
88
86
|
},
|
|
89
87
|
session: {
|
|
90
88
|
tableName: options.session?.modelName || "session",
|
|
@@ -117,7 +115,7 @@ var getAuthTables = (options) => {
|
|
|
117
115
|
...session?.fields,
|
|
118
116
|
...options.session?.additionalFields
|
|
119
117
|
},
|
|
120
|
-
order:
|
|
118
|
+
order: 2
|
|
121
119
|
},
|
|
122
120
|
account: {
|
|
123
121
|
tableName: options.account?.modelName || "account",
|
|
@@ -169,7 +167,7 @@ var getAuthTables = (options) => {
|
|
|
169
167
|
},
|
|
170
168
|
...account?.fields
|
|
171
169
|
},
|
|
172
|
-
order:
|
|
170
|
+
order: 3
|
|
173
171
|
},
|
|
174
172
|
verification: {
|
|
175
173
|
tableName: options.verification?.modelName || "verification",
|
|
@@ -189,7 +187,8 @@ var getAuthTables = (options) => {
|
|
|
189
187
|
required: true,
|
|
190
188
|
fieldName: options.verification?.fields?.expiresAt || "expiresAt"
|
|
191
189
|
}
|
|
192
|
-
}
|
|
190
|
+
},
|
|
191
|
+
order: 4
|
|
193
192
|
},
|
|
194
193
|
...pluginTables,
|
|
195
194
|
...shouldAddRateLimitTable ? rateLimitTable : {}
|
package/dist/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { e as AuthEndpoint, f as AuthMiddleware, v as callbackOAuth, T as changePassword, d as createAuthEndpoint, c as createAuthMiddleware, M as createEmailVerificationToken, $ as csrfMiddleware, V as deleteUser, Y as error, J as forgetPassword, K as forgetPasswordCallback, X as getCSRFToken, r as getEndpoints, w as getSession, x as getSessionFromCtx, z as listSessions, Z as ok, o as optionsMiddleware, L as resetPassword, C as revokeSession, D as revokeSessions, s as router, N as sendVerificationEmail, y as sessionMiddleware, U as setPassword, u as signInEmail, t as signInOAuth, E as signOut, _ as signUpEmail, Q as updateUser, O as verifyEmail } from './index-
|
|
1
|
+
export { e as AuthEndpoint, f as AuthMiddleware, v as callbackOAuth, T as changePassword, d as createAuthEndpoint, c as createAuthMiddleware, M as createEmailVerificationToken, $ as csrfMiddleware, V as deleteUser, Y as error, J as forgetPassword, K as forgetPasswordCallback, X as getCSRFToken, r as getEndpoints, w as getSession, x as getSessionFromCtx, z as listSessions, Z as ok, o as optionsMiddleware, L as resetPassword, C as revokeSession, D as revokeSessions, s as router, N as sendVerificationEmail, y as sessionMiddleware, U as setPassword, u as signInEmail, t as signInOAuth, E as signOut, _ as signUpEmail, Q as updateUser, O as verifyEmail } from './index-BJKlHmT9.js';
|
|
2
2
|
import './helper-DPDj8Nix.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
export { APIError } from 'better-call';
|
package/dist/cli.js
CHANGED
|
@@ -313,8 +313,6 @@ var getAuthTables = (options) => {
|
|
|
313
313
|
}
|
|
314
314
|
};
|
|
315
315
|
const { user, session, account, ...pluginTables } = pluginSchema || {};
|
|
316
|
-
const accountFields = options.account?.fields;
|
|
317
|
-
const userFields = options.user?.fields;
|
|
318
316
|
return {
|
|
319
317
|
user: {
|
|
320
318
|
tableName: options.user?.modelName || "user",
|
|
@@ -356,7 +354,7 @@ var getAuthTables = (options) => {
|
|
|
356
354
|
...user?.fields,
|
|
357
355
|
...options.user?.additionalFields
|
|
358
356
|
},
|
|
359
|
-
order:
|
|
357
|
+
order: 1
|
|
360
358
|
},
|
|
361
359
|
session: {
|
|
362
360
|
tableName: options.session?.modelName || "session",
|
|
@@ -389,7 +387,7 @@ var getAuthTables = (options) => {
|
|
|
389
387
|
...session?.fields,
|
|
390
388
|
...options.session?.additionalFields
|
|
391
389
|
},
|
|
392
|
-
order:
|
|
390
|
+
order: 2
|
|
393
391
|
},
|
|
394
392
|
account: {
|
|
395
393
|
tableName: options.account?.modelName || "account",
|
|
@@ -441,7 +439,7 @@ var getAuthTables = (options) => {
|
|
|
441
439
|
},
|
|
442
440
|
...account?.fields
|
|
443
441
|
},
|
|
444
|
-
order:
|
|
442
|
+
order: 3
|
|
445
443
|
},
|
|
446
444
|
verification: {
|
|
447
445
|
tableName: options.verification?.modelName || "verification",
|
|
@@ -461,7 +459,8 @@ var getAuthTables = (options) => {
|
|
|
461
459
|
required: true,
|
|
462
460
|
fieldName: options.verification?.fields?.expiresAt || "expiresAt"
|
|
463
461
|
}
|
|
464
|
-
}
|
|
462
|
+
},
|
|
463
|
+
order: 4
|
|
465
464
|
},
|
|
466
465
|
...pluginTables,
|
|
467
466
|
...shouldAddRateLimitTable ? rateLimitTable : {}
|
package/dist/client/plugins.d.ts
CHANGED
|
@@ -2,10 +2,10 @@ import * as nanostores from 'nanostores';
|
|
|
2
2
|
import { A as AccessControl, S as StatementsPrimitive, R as Role } from '../statement-CfnyN34h.js';
|
|
3
3
|
import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
4
4
|
import { BetterFetchOption } from '@better-fetch/fetch';
|
|
5
|
-
import { o as organization, j as Organization, M as Member, I as Invitation, u as username, m as magicLink, d as phoneNumber, e as anonymous, i as admin } from '../index-
|
|
6
|
-
export { g as getPasskeyActions, c as passkeyClient, a as twoFactorClient } from '../index-
|
|
5
|
+
import { o as organization, j as Organization, M as Member, I as Invitation, u as username, m as magicLink, d as phoneNumber, e as anonymous, i as admin } from '../index-DFhZxdCd.js';
|
|
6
|
+
export { g as getPasskeyActions, c as passkeyClient, a as twoFactorClient } from '../index-DFhZxdCd.js';
|
|
7
7
|
import { P as Prettify } from '../helper-DPDj8Nix.js';
|
|
8
|
-
import { F as FieldAttribute, B as BetterAuthOptions, b as BetterAuthPlugin } from '../index-
|
|
8
|
+
import { F as FieldAttribute, B as BetterAuthOptions, b as BetterAuthPlugin } from '../index-BJKlHmT9.js';
|
|
9
9
|
import * as better_call from 'better-call';
|
|
10
10
|
import { z } from 'zod';
|
|
11
11
|
import { O as OAuth2Tokens, U as User } from '../types-IzAbV4nB.js';
|
package/dist/client.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { BetterFetch, BetterFetchError, BetterFetchOption } from '@better-fetch/
|
|
|
6
6
|
import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from './helper-DPDj8Nix.js';
|
|
7
7
|
import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, InferSessionFromClient, InferUserFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
|
|
8
8
|
export { AtomListener, InferPluginsFromClient } from './types.js';
|
|
9
|
-
import './index-
|
|
9
|
+
import './index-BJKlHmT9.js';
|
|
10
10
|
import 'kysely';
|
|
11
11
|
import './types-IzAbV4nB.js';
|
|
12
12
|
import 'better-call';
|
|
@@ -37,9 +37,22 @@ type zodKey<T> = isAny<T> extends true ? "any" : equals<T, boolean> extends true
|
|
|
37
37
|
} ? "object" : "rest";
|
|
38
38
|
|
|
39
39
|
type BetterAuthDbSchema = Record<string, {
|
|
40
|
+
/**
|
|
41
|
+
* The name of the table in the database
|
|
42
|
+
*/
|
|
40
43
|
tableName: string;
|
|
44
|
+
/**
|
|
45
|
+
* The fields of the table
|
|
46
|
+
*/
|
|
41
47
|
fields: Record<string, FieldAttribute>;
|
|
48
|
+
/**
|
|
49
|
+
* Whether to disable migrations for this table
|
|
50
|
+
* @default false
|
|
51
|
+
*/
|
|
42
52
|
disableMigrations?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* The order of the table
|
|
55
|
+
*/
|
|
43
56
|
order?: number;
|
|
44
57
|
}>;
|
|
45
58
|
declare const getAuthTables: (options: BetterAuthOptions) => BetterAuthDbSchema;
|
|
@@ -729,6 +742,18 @@ interface BetterAuthOptions {
|
|
|
729
742
|
additionalFields?: {
|
|
730
743
|
[key: string]: FieldAttribute;
|
|
731
744
|
};
|
|
745
|
+
/**
|
|
746
|
+
* By default if secondary storage is provided
|
|
747
|
+
* the session is stored in the secondary storage.
|
|
748
|
+
*
|
|
749
|
+
* Set this to true to store the session in the database
|
|
750
|
+
* as well.
|
|
751
|
+
*
|
|
752
|
+
* Reads are always done from the secondary storage.
|
|
753
|
+
*
|
|
754
|
+
* @default false
|
|
755
|
+
*/
|
|
756
|
+
storeSessionInDatabase?: boolean;
|
|
732
757
|
};
|
|
733
758
|
account?: {
|
|
734
759
|
modelName?: string;
|
|
@@ -1008,7 +1033,7 @@ declare const createInternalAdapter: (adapter: Adapter, ctx: {
|
|
|
1008
1033
|
expiresAt: Date;
|
|
1009
1034
|
ipAddress?: string | undefined;
|
|
1010
1035
|
userAgent?: string | undefined;
|
|
1011
|
-
}
|
|
1036
|
+
}>;
|
|
1012
1037
|
findSession: (sessionId: string) => Promise<{
|
|
1013
1038
|
session: Session;
|
|
1014
1039
|
user: User;
|
|
@@ -1161,12 +1186,12 @@ declare const signInOAuth: {
|
|
|
1161
1186
|
/**
|
|
1162
1187
|
* OAuth2 provider to use`
|
|
1163
1188
|
*/
|
|
1164
|
-
provider: z.ZodEnum<["github", ...("
|
|
1189
|
+
provider: z.ZodEnum<["github", ...("apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter")[]]>;
|
|
1165
1190
|
}, "strip", z.ZodTypeAny, {
|
|
1166
|
-
provider: "
|
|
1191
|
+
provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
|
|
1167
1192
|
callbackURL?: string | undefined;
|
|
1168
1193
|
}, {
|
|
1169
|
-
provider: "
|
|
1194
|
+
provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
|
|
1170
1195
|
callbackURL?: string | undefined;
|
|
1171
1196
|
}>;
|
|
1172
1197
|
}>]>(...ctx: C): Promise<C extends [{
|
|
@@ -1200,12 +1225,12 @@ declare const signInOAuth: {
|
|
|
1200
1225
|
/**
|
|
1201
1226
|
* OAuth2 provider to use`
|
|
1202
1227
|
*/
|
|
1203
|
-
provider: z.ZodEnum<["github", ...("
|
|
1228
|
+
provider: z.ZodEnum<["github", ...("apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter")[]]>;
|
|
1204
1229
|
}, "strip", z.ZodTypeAny, {
|
|
1205
|
-
provider: "
|
|
1230
|
+
provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
|
|
1206
1231
|
callbackURL?: string | undefined;
|
|
1207
1232
|
}, {
|
|
1208
|
-
provider: "
|
|
1233
|
+
provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
|
|
1209
1234
|
callbackURL?: string | undefined;
|
|
1210
1235
|
}>;
|
|
1211
1236
|
};
|
|
@@ -2422,12 +2447,12 @@ declare function getEndpoints<C extends AuthContext, Option extends BetterAuthOp
|
|
|
2422
2447
|
}>>;
|
|
2423
2448
|
body: zod.ZodObject<{
|
|
2424
2449
|
callbackURL: zod.ZodOptional<zod.ZodString>;
|
|
2425
|
-
provider: zod.ZodEnum<["github", ...("
|
|
2450
|
+
provider: zod.ZodEnum<["github", ...("apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter")[]]>;
|
|
2426
2451
|
}, "strip", zod.ZodTypeAny, {
|
|
2427
|
-
provider: "
|
|
2452
|
+
provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
|
|
2428
2453
|
callbackURL?: string | undefined;
|
|
2429
2454
|
}, {
|
|
2430
|
-
provider: "
|
|
2455
|
+
provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
|
|
2431
2456
|
callbackURL?: string | undefined;
|
|
2432
2457
|
}>;
|
|
2433
2458
|
}>]>(...ctx: C_1): Promise<C_1 extends [{
|
|
@@ -2451,12 +2476,12 @@ declare function getEndpoints<C extends AuthContext, Option extends BetterAuthOp
|
|
|
2451
2476
|
}>>;
|
|
2452
2477
|
body: zod.ZodObject<{
|
|
2453
2478
|
callbackURL: zod.ZodOptional<zod.ZodString>;
|
|
2454
|
-
provider: zod.ZodEnum<["github", ...("
|
|
2479
|
+
provider: zod.ZodEnum<["github", ...("apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter")[]]>;
|
|
2455
2480
|
}, "strip", zod.ZodTypeAny, {
|
|
2456
|
-
provider: "
|
|
2481
|
+
provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
|
|
2457
2482
|
callbackURL?: string | undefined;
|
|
2458
2483
|
}, {
|
|
2459
|
-
provider: "
|
|
2484
|
+
provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
|
|
2460
2485
|
callbackURL?: string | undefined;
|
|
2461
2486
|
}>;
|
|
2462
2487
|
};
|
|
@@ -3531,12 +3556,12 @@ declare const router: <C extends AuthContext, Option extends BetterAuthOptions>(
|
|
|
3531
3556
|
}>>;
|
|
3532
3557
|
body: zod.ZodObject<{
|
|
3533
3558
|
callbackURL: zod.ZodOptional<zod.ZodString>;
|
|
3534
|
-
provider: zod.ZodEnum<["github", ...("
|
|
3559
|
+
provider: zod.ZodEnum<["github", ...("apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter")[]]>;
|
|
3535
3560
|
}, "strip", zod.ZodTypeAny, {
|
|
3536
|
-
provider: "
|
|
3561
|
+
provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
|
|
3537
3562
|
callbackURL?: string | undefined;
|
|
3538
3563
|
}, {
|
|
3539
|
-
provider: "
|
|
3564
|
+
provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
|
|
3540
3565
|
callbackURL?: string | undefined;
|
|
3541
3566
|
}>;
|
|
3542
3567
|
}>]>(...ctx: C_1): Promise<C_1 extends [{
|
|
@@ -3560,12 +3585,12 @@ declare const router: <C extends AuthContext, Option extends BetterAuthOptions>(
|
|
|
3560
3585
|
}>>;
|
|
3561
3586
|
body: zod.ZodObject<{
|
|
3562
3587
|
callbackURL: zod.ZodOptional<zod.ZodString>;
|
|
3563
|
-
provider: zod.ZodEnum<["github", ...("
|
|
3588
|
+
provider: zod.ZodEnum<["github", ...("apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter")[]]>;
|
|
3564
3589
|
}, "strip", zod.ZodTypeAny, {
|
|
3565
|
-
provider: "
|
|
3590
|
+
provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
|
|
3566
3591
|
callbackURL?: string | undefined;
|
|
3567
3592
|
}, {
|
|
3568
|
-
provider: "
|
|
3593
|
+
provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
|
|
3569
3594
|
callbackURL?: string | undefined;
|
|
3570
3595
|
}>;
|
|
3571
3596
|
};
|
|
@@ -4642,12 +4667,12 @@ declare const betterAuth: <O extends BetterAuthOptions>(options: O) => {
|
|
|
4642
4667
|
}>>;
|
|
4643
4668
|
body: zod.ZodObject<{
|
|
4644
4669
|
callbackURL: zod.ZodOptional<zod.ZodString>;
|
|
4645
|
-
provider: zod.ZodEnum<["github", ...("
|
|
4670
|
+
provider: zod.ZodEnum<["github", ...("apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter")[]]>;
|
|
4646
4671
|
}, "strip", zod.ZodTypeAny, {
|
|
4647
|
-
provider: "
|
|
4672
|
+
provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
|
|
4648
4673
|
callbackURL?: string | undefined;
|
|
4649
4674
|
}, {
|
|
4650
|
-
provider: "
|
|
4675
|
+
provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
|
|
4651
4676
|
callbackURL?: string | undefined;
|
|
4652
4677
|
}>;
|
|
4653
4678
|
}>]>(...ctx: C): Promise<C extends [{
|
|
@@ -4671,12 +4696,12 @@ declare const betterAuth: <O extends BetterAuthOptions>(options: O) => {
|
|
|
4671
4696
|
}>>;
|
|
4672
4697
|
body: zod.ZodObject<{
|
|
4673
4698
|
callbackURL: zod.ZodOptional<zod.ZodString>;
|
|
4674
|
-
provider: zod.ZodEnum<["github", ...("
|
|
4699
|
+
provider: zod.ZodEnum<["github", ...("apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter")[]]>;
|
|
4675
4700
|
}, "strip", zod.ZodTypeAny, {
|
|
4676
|
-
provider: "
|
|
4701
|
+
provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
|
|
4677
4702
|
callbackURL?: string | undefined;
|
|
4678
4703
|
}, {
|
|
4679
|
-
provider: "
|
|
4704
|
+
provider: "apple" | "discord" | "facebook" | "github" | "google" | "microsoft" | "spotify" | "twitch" | "twitter";
|
|
4680
4705
|
callbackURL?: string | undefined;
|
|
4681
4706
|
}>;
|
|
4682
4707
|
};
|
|
@@ -5,7 +5,7 @@ import { P as Prettify } from './helper-DPDj8Nix.js';
|
|
|
5
5
|
import { A as AccessControl, R as Role, S as StatementsPrimitive, g as defaultRoles } from './statement-CfnyN34h.js';
|
|
6
6
|
import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
7
7
|
import { BetterFetch, BetterFetchOption } from '@better-fetch/fetch';
|
|
8
|
-
import { H as HookEndpointContext, g as AuthContext } from './index-
|
|
8
|
+
import { H as HookEndpointContext, g as AuthContext } from './index-BJKlHmT9.js';
|
|
9
9
|
import * as nanostores from 'nanostores';
|
|
10
10
|
import { atom } from 'nanostores';
|
|
11
11
|
import * as _simplewebauthn_types from '@simplewebauthn/types';
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -2879,8 +2879,6 @@ var getAuthTables = (options) => {
|
|
|
2879
2879
|
}
|
|
2880
2880
|
};
|
|
2881
2881
|
const { user, session, account, ...pluginTables } = pluginSchema || {};
|
|
2882
|
-
const accountFields = options.account?.fields;
|
|
2883
|
-
const userFields = options.user?.fields;
|
|
2884
2882
|
return {
|
|
2885
2883
|
user: {
|
|
2886
2884
|
tableName: options.user?.modelName || "user",
|
|
@@ -2922,7 +2920,7 @@ var getAuthTables = (options) => {
|
|
|
2922
2920
|
...user?.fields,
|
|
2923
2921
|
...options.user?.additionalFields
|
|
2924
2922
|
},
|
|
2925
|
-
order:
|
|
2923
|
+
order: 1
|
|
2926
2924
|
},
|
|
2927
2925
|
session: {
|
|
2928
2926
|
tableName: options.session?.modelName || "session",
|
|
@@ -2955,7 +2953,7 @@ var getAuthTables = (options) => {
|
|
|
2955
2953
|
...session?.fields,
|
|
2956
2954
|
...options.session?.additionalFields
|
|
2957
2955
|
},
|
|
2958
|
-
order:
|
|
2956
|
+
order: 2
|
|
2959
2957
|
},
|
|
2960
2958
|
account: {
|
|
2961
2959
|
tableName: options.account?.modelName || "account",
|
|
@@ -3007,7 +3005,7 @@ var getAuthTables = (options) => {
|
|
|
3007
3005
|
},
|
|
3008
3006
|
...account?.fields
|
|
3009
3007
|
},
|
|
3010
|
-
order:
|
|
3008
|
+
order: 3
|
|
3011
3009
|
},
|
|
3012
3010
|
verification: {
|
|
3013
3011
|
tableName: options.verification?.modelName || "verification",
|
|
@@ -3027,7 +3025,8 @@ var getAuthTables = (options) => {
|
|
|
3027
3025
|
required: true,
|
|
3028
3026
|
fieldName: options.verification?.fields?.expiresAt || "expiresAt"
|
|
3029
3027
|
}
|
|
3030
|
-
}
|
|
3028
|
+
},
|
|
3029
|
+
order: 4
|
|
3031
3030
|
},
|
|
3032
3031
|
...pluginTables,
|
|
3033
3032
|
...shouldAddRateLimitTable ? rateLimitTable : {}
|
|
@@ -3780,22 +3779,26 @@ var createInternalAdapter = (adapter, ctx) => {
|
|
|
3780
3779
|
userAgent: headers?.get("user-agent") || "",
|
|
3781
3780
|
...override
|
|
3782
3781
|
};
|
|
3783
|
-
|
|
3784
|
-
if (secondaryStorage && session) {
|
|
3782
|
+
if (secondaryStorage) {
|
|
3785
3783
|
const user = await adapter.findOne({
|
|
3786
3784
|
model: tables.user.tableName,
|
|
3787
3785
|
where: [{ field: "id", value: userId }]
|
|
3788
3786
|
});
|
|
3789
3787
|
secondaryStorage.set(
|
|
3790
|
-
|
|
3788
|
+
data.id,
|
|
3791
3789
|
JSON.stringify({
|
|
3792
|
-
session,
|
|
3790
|
+
session: data,
|
|
3793
3791
|
user
|
|
3794
3792
|
}),
|
|
3795
3793
|
sessionExpiration
|
|
3796
3794
|
);
|
|
3795
|
+
if (options.session?.storeSessionInDatabase) {
|
|
3796
|
+
await createWithHooks(data, "session");
|
|
3797
|
+
}
|
|
3798
|
+
} else {
|
|
3799
|
+
await createWithHooks(data, "session");
|
|
3797
3800
|
}
|
|
3798
|
-
return
|
|
3801
|
+
return data;
|
|
3799
3802
|
},
|
|
3800
3803
|
findSession: async (sessionId) => {
|
|
3801
3804
|
if (secondaryStorage) {
|
|
@@ -3845,6 +3848,35 @@ var createInternalAdapter = (adapter, ctx) => {
|
|
|
3845
3848
|
};
|
|
3846
3849
|
},
|
|
3847
3850
|
updateSession: async (sessionId, session) => {
|
|
3851
|
+
if (secondaryStorage) {
|
|
3852
|
+
const currentSession = await secondaryStorage.get(sessionId);
|
|
3853
|
+
let updatedSession2 = null;
|
|
3854
|
+
if (currentSession) {
|
|
3855
|
+
const parsedSession = JSON.parse(currentSession);
|
|
3856
|
+
updatedSession2 = {
|
|
3857
|
+
...parsedSession.session,
|
|
3858
|
+
...session
|
|
3859
|
+
};
|
|
3860
|
+
await secondaryStorage.set(
|
|
3861
|
+
sessionId,
|
|
3862
|
+
JSON.stringify({
|
|
3863
|
+
session: updatedSession2,
|
|
3864
|
+
user: parsedSession.user
|
|
3865
|
+
}),
|
|
3866
|
+
parsedSession.session.expiresAt ? new Date(parsedSession.session.expiresAt).getTime() : void 0
|
|
3867
|
+
);
|
|
3868
|
+
} else {
|
|
3869
|
+
return null;
|
|
3870
|
+
}
|
|
3871
|
+
if (options.session?.storeSessionInDatabase) {
|
|
3872
|
+
await updateWithHooks(
|
|
3873
|
+
session,
|
|
3874
|
+
[{ field: "id", value: sessionId }],
|
|
3875
|
+
"session"
|
|
3876
|
+
);
|
|
3877
|
+
}
|
|
3878
|
+
return updatedSession2;
|
|
3879
|
+
}
|
|
3848
3880
|
const updatedSession = await updateWithHooks(
|
|
3849
3881
|
session,
|
|
3850
3882
|
[{ field: "id", value: sessionId }],
|
|
@@ -3855,6 +3887,18 @@ var createInternalAdapter = (adapter, ctx) => {
|
|
|
3855
3887
|
deleteSession: async (id) => {
|
|
3856
3888
|
if (secondaryStorage) {
|
|
3857
3889
|
await secondaryStorage.delete(id);
|
|
3890
|
+
if (options.session?.storeSessionInDatabase) {
|
|
3891
|
+
await adapter.delete({
|
|
3892
|
+
model: tables.session.tableName,
|
|
3893
|
+
where: [
|
|
3894
|
+
{
|
|
3895
|
+
field: "id",
|
|
3896
|
+
value: id
|
|
3897
|
+
}
|
|
3898
|
+
]
|
|
3899
|
+
});
|
|
3900
|
+
}
|
|
3901
|
+
return;
|
|
3858
3902
|
}
|
|
3859
3903
|
await adapter.delete({
|
|
3860
3904
|
model: tables.session.tableName,
|
|
@@ -3872,7 +3916,7 @@ var createInternalAdapter = (adapter, ctx) => {
|
|
|
3872
3916
|
model: tables.session.tableName,
|
|
3873
3917
|
where: [
|
|
3874
3918
|
{
|
|
3875
|
-
field: "userId",
|
|
3919
|
+
field: tables.session.fields.userId.fieldName || "userId",
|
|
3876
3920
|
value: userId
|
|
3877
3921
|
}
|
|
3878
3922
|
]
|
|
@@ -3880,6 +3924,18 @@ var createInternalAdapter = (adapter, ctx) => {
|
|
|
3880
3924
|
for (const session of sessions) {
|
|
3881
3925
|
await secondaryStorage.delete(session.id);
|
|
3882
3926
|
}
|
|
3927
|
+
if (options.session?.storeSessionInDatabase) {
|
|
3928
|
+
await adapter.delete({
|
|
3929
|
+
model: tables.session.tableName,
|
|
3930
|
+
where: [
|
|
3931
|
+
{
|
|
3932
|
+
field: tables.session.fields.userId.fieldName || "userId",
|
|
3933
|
+
value: userId
|
|
3934
|
+
}
|
|
3935
|
+
]
|
|
3936
|
+
});
|
|
3937
|
+
}
|
|
3938
|
+
return;
|
|
3883
3939
|
}
|
|
3884
3940
|
await adapter.delete({
|
|
3885
3941
|
model: tables.session.tableName,
|
package/dist/next-js.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as Auth } from './index-
|
|
1
|
+
import { a as Auth } from './index-BJKlHmT9.js';
|
|
2
2
|
import { U as User, S as Session } from './types-IzAbV4nB.js';
|
|
3
3
|
import { NextRequest } from 'next/server';
|
|
4
4
|
import 'zod';
|
|
@@ -17,8 +17,19 @@ declare function toNextJsHandler(auth: Auth | Auth["handler"]): {
|
|
|
17
17
|
* If not, it redirects to the redirectTo URL.
|
|
18
18
|
*/
|
|
19
19
|
declare function authMiddleware(options: {
|
|
20
|
+
/**
|
|
21
|
+
* The base path of the auth API
|
|
22
|
+
* @default "/api/auth"
|
|
23
|
+
*/
|
|
20
24
|
basePath?: string;
|
|
25
|
+
/**
|
|
26
|
+
* The URL to redirect to if the user is not authenticated
|
|
27
|
+
* @default "/"
|
|
28
|
+
*/
|
|
21
29
|
redirectTo?: string;
|
|
30
|
+
/**
|
|
31
|
+
* A custom redirect function
|
|
32
|
+
*/
|
|
22
33
|
customRedirect?: (session: {
|
|
23
34
|
user: User;
|
|
24
35
|
session: Session;
|
package/dist/node.d.ts
CHANGED
package/dist/plugins.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { A as AnonymousOptions, O as OrganizationOptions, b as Passkey, P as PasskeyOptions, U as UserWithPhoneNumber, f as UserWithRole, i as admin, h as adminMiddleware, e as anonymous, g as getPasskeyActions, m as magicLink, o as organization, p as passkey, c as passkeyClient, d as phoneNumber, t as twoFactor, a as twoFactorClient, u as username } from './index-
|
|
1
|
+
export { A as AnonymousOptions, O as OrganizationOptions, b as Passkey, P as PasskeyOptions, U as UserWithPhoneNumber, f as UserWithRole, i as admin, h as adminMiddleware, e as anonymous, g as getPasskeyActions, m as magicLink, o as organization, p as passkey, c as passkeyClient, d as phoneNumber, t as twoFactor, a as twoFactorClient, u as username } from './index-DFhZxdCd.js';
|
|
2
2
|
export { i as ac } from './index-DfAHOgpj.js';
|
|
3
|
-
import { H as HookEndpointContext } from './index-
|
|
4
|
-
export { e as AuthEndpoint, f as AuthMiddleware, b as BetterAuthPlugin, P as PluginSchema, d as createAuthEndpoint, c as createAuthMiddleware, o as optionsMiddleware } from './index-
|
|
3
|
+
import { H as HookEndpointContext } from './index-BJKlHmT9.js';
|
|
4
|
+
export { e as AuthEndpoint, f as AuthMiddleware, b as BetterAuthPlugin, P as PluginSchema, d as createAuthEndpoint, c as createAuthMiddleware, o as optionsMiddleware } from './index-BJKlHmT9.js';
|
|
5
5
|
import './types-IzAbV4nB.js';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import './helper-DPDj8Nix.js';
|
package/dist/plugins.js
CHANGED
|
@@ -5500,7 +5500,7 @@ var bearer = () => {
|
|
|
5500
5500
|
}
|
|
5501
5501
|
let signedToken = "";
|
|
5502
5502
|
if (token.includes(".")) {
|
|
5503
|
-
signedToken = token
|
|
5503
|
+
signedToken = token;
|
|
5504
5504
|
} else {
|
|
5505
5505
|
signedToken = await serializeSigned("", token, c2.context.secret);
|
|
5506
5506
|
}
|
package/dist/react.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
|
3
3
|
import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from './helper-DPDj8Nix.js';
|
|
4
4
|
import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
|
|
5
5
|
import { useStore } from '@nanostores/react';
|
|
6
|
-
import './index-
|
|
6
|
+
import './index-BJKlHmT9.js';
|
|
7
7
|
import 'kysely';
|
|
8
8
|
import './types-IzAbV4nB.js';
|
|
9
9
|
import 'better-call';
|
package/dist/solid-start.d.ts
CHANGED
package/dist/solid.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
|
3
3
|
import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from './helper-DPDj8Nix.js';
|
|
4
4
|
import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
|
|
5
5
|
import { Accessor } from 'solid-js';
|
|
6
|
-
import './index-
|
|
6
|
+
import './index-BJKlHmT9.js';
|
|
7
7
|
import 'kysely';
|
|
8
8
|
import './types-IzAbV4nB.js';
|
|
9
9
|
import 'better-call';
|
package/dist/svelte-kit.d.ts
CHANGED
package/dist/svelte.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as nanostores from 'nanostores';
|
|
|
3
3
|
import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
4
4
|
import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from './helper-DPDj8Nix.js';
|
|
5
5
|
import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
|
|
6
|
-
import './index-
|
|
6
|
+
import './index-BJKlHmT9.js';
|
|
7
7
|
import 'kysely';
|
|
8
8
|
import './types-IzAbV4nB.js';
|
|
9
9
|
import 'better-call';
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as BetterAuthPlugin, a as Auth, I as InferFieldsInputClient, h as InferFieldsOutput } from './index-
|
|
2
|
-
export { A as Adapter, k as AdditionalSessionFieldsInput, l as AdditionalSessionFieldsOutput, i as AdditionalUserFieldsInput, j as AdditionalUserFieldsOutput, g as AuthContext, B as BetterAuthOptions, G as GenericEndpointContext, H as HookEndpointContext, p as InferPluginTypes, n as InferSession, m as InferUser, P as PluginSchema, R as RateLimit, S as SecondaryStorage, W as Where, q as init } from './index-
|
|
1
|
+
import { b as BetterAuthPlugin, a as Auth, I as InferFieldsInputClient, h as InferFieldsOutput } from './index-BJKlHmT9.js';
|
|
2
|
+
export { A as Adapter, k as AdditionalSessionFieldsInput, l as AdditionalSessionFieldsOutput, i as AdditionalUserFieldsInput, j as AdditionalUserFieldsOutput, g as AuthContext, B as BetterAuthOptions, G as GenericEndpointContext, H as HookEndpointContext, p as InferPluginTypes, n as InferSession, m as InferUser, P as PluginSchema, R as RateLimit, S as SecondaryStorage, W as Where, q as init } from './index-BJKlHmT9.js';
|
|
3
3
|
import { U as UnionToIntersection, H as HasRequiredKeys, P as Prettify, S as StripEmptyObjects, L as LiteralString } from './helper-DPDj8Nix.js';
|
|
4
4
|
export { D as DeepPartial, a as LiteralUnion, R as RequiredKeysOf, W as WithoutEmpty } from './helper-DPDj8Nix.js';
|
|
5
5
|
import { S as Session, U as User } from './types-IzAbV4nB.js';
|
package/dist/vue.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
|
3
3
|
import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from './helper-DPDj8Nix.js';
|
|
4
4
|
import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
|
|
5
5
|
import { Ref, DeepReadonly } from 'vue';
|
|
6
|
-
import './index-
|
|
6
|
+
import './index-BJKlHmT9.js';
|
|
7
7
|
import 'kysely';
|
|
8
8
|
import './types-IzAbV4nB.js';
|
|
9
9
|
import 'better-call';
|