better-auth 0.2.6 → 0.2.8-beta.2
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/.DS_Store +0 -0
- package/dist/adapters/drizzle.d.ts +2 -2
- package/dist/adapters/drizzle.js +21 -2
- package/dist/adapters/mongodb.d.ts +2 -2
- package/dist/adapters/prisma.d.ts +2 -2
- package/dist/adapters/prisma.js +21 -2
- package/dist/api.d.ts +2 -2
- package/dist/api.js +6 -0
- package/dist/cli.js +23 -6
- package/dist/client/plugins.d.ts +4 -4
- package/dist/client.d.ts +2 -2
- package/dist/{index-Cc76Cf2k.d.ts → index-C9Y_qmSM.d.ts} +2 -2
- package/dist/{index-Ckd9h_O2.d.ts → index-DAMIZ_6a.d.ts} +83 -25
- package/dist/{index-37csVPVw.d.ts → index-XxjbEPqj.d.ts} +18 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +132 -78
- package/dist/next-js.d.ts +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/plugins.d.ts +4 -4
- package/dist/plugins.js +6 -0
- package/dist/react.d.ts +2 -2
- package/dist/social.d.ts +1 -1
- package/dist/solid-start.d.ts +2 -2
- package/dist/solid.d.ts +2 -2
- package/dist/svelte-kit.d.ts +2 -2
- package/dist/svelte.d.ts +2 -2
- package/dist/types.d.ts +4 -4
- package/dist/utils.d.ts +3 -3
- package/dist/vue.d.ts +2 -2
- package/package.json +1 -1
package/dist/.DS_Store
ADDED
|
Binary file
|
package/dist/adapters/drizzle.js
CHANGED
|
@@ -41,11 +41,13 @@ 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;
|
|
44
46
|
return {
|
|
45
47
|
user: {
|
|
46
48
|
tableName: options.user?.modelName || "user",
|
|
47
49
|
fields: {
|
|
48
|
-
name: {
|
|
50
|
+
[userFields?.name || "name"]: {
|
|
49
51
|
type: "string",
|
|
50
52
|
required: true
|
|
51
53
|
},
|
|
@@ -108,7 +110,7 @@ var getAuthTables = (options) => {
|
|
|
108
110
|
account: {
|
|
109
111
|
tableName: options.account?.modelName || "account",
|
|
110
112
|
fields: {
|
|
111
|
-
accountId: {
|
|
113
|
+
[accountFields?.accountId || "accountId"]: {
|
|
112
114
|
type: "string",
|
|
113
115
|
required: true
|
|
114
116
|
},
|
|
@@ -149,6 +151,23 @@ var getAuthTables = (options) => {
|
|
|
149
151
|
},
|
|
150
152
|
order: 2
|
|
151
153
|
},
|
|
154
|
+
verification: {
|
|
155
|
+
tableName: options.verification?.modelName || "verification",
|
|
156
|
+
fields: {
|
|
157
|
+
identifier: {
|
|
158
|
+
type: "string",
|
|
159
|
+
required: true
|
|
160
|
+
},
|
|
161
|
+
value: {
|
|
162
|
+
type: "string",
|
|
163
|
+
required: true
|
|
164
|
+
},
|
|
165
|
+
expiresAt: {
|
|
166
|
+
type: "date",
|
|
167
|
+
required: true
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
},
|
|
152
171
|
...pluginTables,
|
|
153
172
|
...shouldAddRateLimitTable ? rateLimitTable : {}
|
|
154
173
|
};
|
package/dist/adapters/prisma.js
CHANGED
|
@@ -47,11 +47,13 @@ var getAuthTables = (options) => {
|
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
const { user, session, account, ...pluginTables } = pluginSchema || {};
|
|
50
|
+
const accountFields = options.account?.fields;
|
|
51
|
+
const userFields = options.user?.fields;
|
|
50
52
|
return {
|
|
51
53
|
user: {
|
|
52
54
|
tableName: options.user?.modelName || "user",
|
|
53
55
|
fields: {
|
|
54
|
-
name: {
|
|
56
|
+
[userFields?.name || "name"]: {
|
|
55
57
|
type: "string",
|
|
56
58
|
required: true
|
|
57
59
|
},
|
|
@@ -114,7 +116,7 @@ var getAuthTables = (options) => {
|
|
|
114
116
|
account: {
|
|
115
117
|
tableName: options.account?.modelName || "account",
|
|
116
118
|
fields: {
|
|
117
|
-
accountId: {
|
|
119
|
+
[accountFields?.accountId || "accountId"]: {
|
|
118
120
|
type: "string",
|
|
119
121
|
required: true
|
|
120
122
|
},
|
|
@@ -155,6 +157,23 @@ var getAuthTables = (options) => {
|
|
|
155
157
|
},
|
|
156
158
|
order: 2
|
|
157
159
|
},
|
|
160
|
+
verification: {
|
|
161
|
+
tableName: options.verification?.modelName || "verification",
|
|
162
|
+
fields: {
|
|
163
|
+
identifier: {
|
|
164
|
+
type: "string",
|
|
165
|
+
required: true
|
|
166
|
+
},
|
|
167
|
+
value: {
|
|
168
|
+
type: "string",
|
|
169
|
+
required: true
|
|
170
|
+
},
|
|
171
|
+
expiresAt: {
|
|
172
|
+
type: "date",
|
|
173
|
+
required: true
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
},
|
|
158
177
|
...pluginTables,
|
|
159
178
|
...shouldAddRateLimitTable ? rateLimitTable : {}
|
|
160
179
|
};
|
package/dist/api.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { b as AuthEndpoint, d as AuthMiddleware, y as callbackOAuth, X as changePassword, a as createAuthEndpoint, c as createAuthMiddleware, Q as createEmailVerificationToken, a1 as csrfMiddleware, _ as error, M as forgetPassword, N as forgetPasswordCallback, Z as getCSRFToken, u as getEndpoints, z as getSession, C as getSessionFromCtx, E as listSessions, $ as ok, o as optionsMiddleware, O as resetPassword, J as revokeSession, K as revokeSessions, v as router, T as sendVerificationEmail, D as sessionMiddleware, Y as setPassword, x as signInEmail, w as signInOAuth, L as signOut, a0 as signUpEmail, V as updateUser, U as verifyEmail } from './index-
|
|
1
|
+
export { b as AuthEndpoint, d as AuthMiddleware, y as callbackOAuth, X as changePassword, a as createAuthEndpoint, c as createAuthMiddleware, Q as createEmailVerificationToken, a1 as csrfMiddleware, _ as error, M as forgetPassword, N as forgetPasswordCallback, Z as getCSRFToken, u as getEndpoints, z as getSession, C as getSessionFromCtx, E as listSessions, $ as ok, o as optionsMiddleware, O as resetPassword, J as revokeSession, K as revokeSessions, v as router, T as sendVerificationEmail, D as sessionMiddleware, Y as setPassword, x as signInEmail, w as signInOAuth, L as signOut, a0 as signUpEmail, V as updateUser, U as verifyEmail } from './index-DAMIZ_6a.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
import './helper-D-PIAORk.js';
|
|
4
4
|
import 'better-call';
|
|
5
5
|
import 'kysely';
|
|
6
|
-
import './index-
|
|
6
|
+
import './index-XxjbEPqj.js';
|
|
7
7
|
import 'arctic';
|
|
8
8
|
import 'better-sqlite3';
|
|
9
9
|
import 'mysql2';
|
package/dist/api.js
CHANGED
|
@@ -1096,6 +1096,12 @@ z.object({
|
|
|
1096
1096
|
ipAddress: z.string().optional(),
|
|
1097
1097
|
userAgent: z.string().optional()
|
|
1098
1098
|
});
|
|
1099
|
+
z.object({
|
|
1100
|
+
id: z.string(),
|
|
1101
|
+
value: z.string(),
|
|
1102
|
+
expiresAt: z.date(),
|
|
1103
|
+
identifier: z.string()
|
|
1104
|
+
});
|
|
1099
1105
|
var generateId = () => {
|
|
1100
1106
|
return generateRandomString(36, alphabet("a-z", "0-9"));
|
|
1101
1107
|
};
|
package/dist/cli.js
CHANGED
|
@@ -9,8 +9,6 @@ import babelPresetReact from '@babel/preset-react';
|
|
|
9
9
|
import { z } from 'zod';
|
|
10
10
|
import { existsSync } from 'fs';
|
|
11
11
|
import { SqliteDialect, MysqlDialect, PostgresDialect, Kysely } from 'kysely';
|
|
12
|
-
import Database from 'better-sqlite3';
|
|
13
|
-
import { Pool } from 'pg';
|
|
14
12
|
import ora2 from 'ora';
|
|
15
13
|
import chalk from 'chalk';
|
|
16
14
|
import prompts3 from 'prompts';
|
|
@@ -146,7 +144,7 @@ var createKyselyAdapter = async (config) => {
|
|
|
146
144
|
databaseType = "postgres";
|
|
147
145
|
}
|
|
148
146
|
}
|
|
149
|
-
if (
|
|
147
|
+
if ("aggregate" in db) {
|
|
150
148
|
dialect = new SqliteDialect({
|
|
151
149
|
database: db
|
|
152
150
|
});
|
|
@@ -158,7 +156,7 @@ var createKyselyAdapter = async (config) => {
|
|
|
158
156
|
});
|
|
159
157
|
databaseType = "mysql";
|
|
160
158
|
}
|
|
161
|
-
if (
|
|
159
|
+
if ("connect" in db) {
|
|
162
160
|
dialect = new PostgresDialect({
|
|
163
161
|
pool: db
|
|
164
162
|
});
|
|
@@ -208,11 +206,13 @@ var getAuthTables = (options) => {
|
|
|
208
206
|
}
|
|
209
207
|
};
|
|
210
208
|
const { user, session, account, ...pluginTables } = pluginSchema || {};
|
|
209
|
+
const accountFields = options.account?.fields;
|
|
210
|
+
const userFields = options.user?.fields;
|
|
211
211
|
return {
|
|
212
212
|
user: {
|
|
213
213
|
tableName: options.user?.modelName || "user",
|
|
214
214
|
fields: {
|
|
215
|
-
name: {
|
|
215
|
+
[userFields?.name || "name"]: {
|
|
216
216
|
type: "string",
|
|
217
217
|
required: true
|
|
218
218
|
},
|
|
@@ -275,7 +275,7 @@ var getAuthTables = (options) => {
|
|
|
275
275
|
account: {
|
|
276
276
|
tableName: options.account?.modelName || "account",
|
|
277
277
|
fields: {
|
|
278
|
-
accountId: {
|
|
278
|
+
[accountFields?.accountId || "accountId"]: {
|
|
279
279
|
type: "string",
|
|
280
280
|
required: true
|
|
281
281
|
},
|
|
@@ -316,6 +316,23 @@ var getAuthTables = (options) => {
|
|
|
316
316
|
},
|
|
317
317
|
order: 2
|
|
318
318
|
},
|
|
319
|
+
verification: {
|
|
320
|
+
tableName: options.verification?.modelName || "verification",
|
|
321
|
+
fields: {
|
|
322
|
+
identifier: {
|
|
323
|
+
type: "string",
|
|
324
|
+
required: true
|
|
325
|
+
},
|
|
326
|
+
value: {
|
|
327
|
+
type: "string",
|
|
328
|
+
required: true
|
|
329
|
+
},
|
|
330
|
+
expiresAt: {
|
|
331
|
+
type: "date",
|
|
332
|
+
required: true
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
},
|
|
319
336
|
...pluginTables,
|
|
320
337
|
...shouldAddRateLimitTable ? rateLimitTable : {}
|
|
321
338
|
};
|
package/dist/client/plugins.d.ts
CHANGED
|
@@ -2,14 +2,14 @@ import * as nanostores from 'nanostores';
|
|
|
2
2
|
import { A as AccessControl, S as StatementsPrimitive, R as Role } from '../statement-BYDTZ_xW.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, d as Organization, M as Member, I as Invitation, u as username, m as magicLink } from '../index-
|
|
6
|
-
export { g as getPasskeyActions, c as passkeyClient, a as twoFactorClient } from '../index-
|
|
5
|
+
import { o as organization, d as Organization, M as Member, I as Invitation, u as username, m as magicLink } from '../index-C9Y_qmSM.js';
|
|
6
|
+
export { g as getPasskeyActions, c as passkeyClient, a as twoFactorClient } from '../index-C9Y_qmSM.js';
|
|
7
7
|
import { P as Prettify } from '../helper-D-PIAORk.js';
|
|
8
|
-
import '../index-
|
|
8
|
+
import '../index-XxjbEPqj.js';
|
|
9
9
|
import 'arctic';
|
|
10
10
|
import 'zod';
|
|
11
11
|
import 'better-call';
|
|
12
|
-
import '../index-
|
|
12
|
+
import '../index-DAMIZ_6a.js';
|
|
13
13
|
import 'kysely';
|
|
14
14
|
import 'better-sqlite3';
|
|
15
15
|
import 'mysql2';
|
package/dist/client.d.ts
CHANGED
|
@@ -6,9 +6,9 @@ import { BetterFetch, BetterFetchError, BetterFetchOption } from '@better-fetch/
|
|
|
6
6
|
import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from './helper-D-PIAORk.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-DAMIZ_6a.js';
|
|
10
10
|
import 'kysely';
|
|
11
|
-
import './index-
|
|
11
|
+
import './index-XxjbEPqj.js';
|
|
12
12
|
import 'arctic';
|
|
13
13
|
import 'better-call';
|
|
14
14
|
import 'better-sqlite3';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { U as User, S as Session } from './index-
|
|
1
|
+
import { U as User, S as Session } from './index-XxjbEPqj.js';
|
|
2
2
|
import * as better_call from 'better-call';
|
|
3
3
|
import { z, ZodObject, ZodOptional, ZodArray, ZodLiteral } from 'zod';
|
|
4
4
|
import { P as Prettify } from './helper-D-PIAORk.js';
|
|
5
5
|
import { A as AccessControl, R as Role, S as StatementsPrimitive, g as defaultRoles } from './statement-BYDTZ_xW.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 } from './index-
|
|
8
|
+
import { H as HookEndpointContext } from './index-DAMIZ_6a.js';
|
|
9
9
|
import * as nanostores from 'nanostores';
|
|
10
10
|
import { atom } from 'nanostores';
|
|
11
11
|
import * as _simplewebauthn_types from '@simplewebauthn/types';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as kysely from 'kysely';
|
|
2
2
|
import { Kysely, Migration, PostgresPool, Dialect } from 'kysely';
|
|
3
|
-
import { S as Session, U as User, A as Account, O as OAuthProvider, a as AppleProfile, D as DiscordProfile, F as FacebookProfile, G as GithubProfile, b as GoogleProfile, c as SpotifyProfile, T as TwitchProfile, d as TwitterProfile, e as SocialProviders, f as OAuthProviderList } from './index-
|
|
3
|
+
import { S as Session, U as User, A as Account, V as Verification, O as OAuthProvider, a as AppleProfile, D as DiscordProfile, F as FacebookProfile, G as GithubProfile, b as GoogleProfile, c as SpotifyProfile, T as TwitchProfile, d as TwitterProfile, e as SocialProviders, f as OAuthProviderList } from './index-XxjbEPqj.js';
|
|
4
4
|
import * as better_call from 'better-call';
|
|
5
5
|
import { ContextTools, CookieOptions, Endpoint, EndpointResponse, Context, Prettify as Prettify$1 } from 'better-call';
|
|
6
6
|
import * as zod from 'zod';
|
|
@@ -224,6 +224,25 @@ declare const createInternalAdapter: (adapter: Adapter, options: BetterAuthOptio
|
|
|
224
224
|
expiresAt?: Date | null | undefined;
|
|
225
225
|
password?: string | null | undefined;
|
|
226
226
|
} | null>;
|
|
227
|
+
createVerificationValue: (identifier: string, value: string) => Promise<{
|
|
228
|
+
id: string;
|
|
229
|
+
identifier: string;
|
|
230
|
+
value: string;
|
|
231
|
+
expiresAt: Date;
|
|
232
|
+
} | null>;
|
|
233
|
+
findVerificationValue: (identifier: string) => Promise<{
|
|
234
|
+
id: string;
|
|
235
|
+
expiresAt: Date;
|
|
236
|
+
value: string;
|
|
237
|
+
identifier: string;
|
|
238
|
+
} | null>;
|
|
239
|
+
deleteVerificationValue: (id: string) => Promise<void>;
|
|
240
|
+
updateVerificationValue: (id: string, data: Partial<Verification>) => Promise<{
|
|
241
|
+
id: string;
|
|
242
|
+
expiresAt: Date;
|
|
243
|
+
value: string;
|
|
244
|
+
identifier: string;
|
|
245
|
+
} | null>;
|
|
227
246
|
};
|
|
228
247
|
|
|
229
248
|
type FieldAttribute<T extends FieldType = FieldType> = {
|
|
@@ -613,19 +632,26 @@ declare const init: (opts: BetterAuthOptions) => Promise<{
|
|
|
613
632
|
socialProviders?: SocialProviders;
|
|
614
633
|
user?: {
|
|
615
634
|
modelName?: string;
|
|
635
|
+
fields?: Partial<Record<keyof User, string>>;
|
|
616
636
|
};
|
|
617
637
|
session?: {
|
|
618
638
|
modelName?: string;
|
|
639
|
+
fields?: Partial<Record<keyof Session, string>>;
|
|
619
640
|
expiresIn?: number;
|
|
620
641
|
updateAge?: number;
|
|
621
642
|
};
|
|
622
643
|
account?: {
|
|
623
644
|
modelName?: string;
|
|
645
|
+
fields?: Partial<Record<keyof Account, string>>;
|
|
624
646
|
accountLinking?: {
|
|
625
647
|
enabled?: boolean;
|
|
626
648
|
trustedProviders?: Array<OAuthProviderList[number] | "email-password">;
|
|
627
649
|
};
|
|
628
650
|
};
|
|
651
|
+
verification?: {
|
|
652
|
+
modelName?: string;
|
|
653
|
+
fields?: Partial<Record<keyof Verification, string>>;
|
|
654
|
+
};
|
|
629
655
|
trustedOrigins?: string[];
|
|
630
656
|
rateLimit?: {
|
|
631
657
|
enabled?: boolean;
|
|
@@ -676,6 +702,12 @@ declare const init: (opts: BetterAuthOptions) => Promise<{
|
|
|
676
702
|
}>;
|
|
677
703
|
after?: (account: Account) => Promise<void>;
|
|
678
704
|
}; };
|
|
705
|
+
verification?: { [key in "create" | "update"]: {
|
|
706
|
+
before?: (verification: Verification) => Promise<boolean | void | {
|
|
707
|
+
data: Verification & Record<string, any>;
|
|
708
|
+
}>;
|
|
709
|
+
after?: (verification: Verification) => Promise<void>;
|
|
710
|
+
}; };
|
|
679
711
|
};
|
|
680
712
|
};
|
|
681
713
|
}>;
|
|
@@ -1057,9 +1089,11 @@ interface BetterAuthOptions {
|
|
|
1057
1089
|
* The model name for the user. Defaults to "user".
|
|
1058
1090
|
*/
|
|
1059
1091
|
modelName?: string;
|
|
1092
|
+
fields?: Partial<Record<keyof User, string>>;
|
|
1060
1093
|
};
|
|
1061
1094
|
session?: {
|
|
1062
1095
|
modelName?: string;
|
|
1096
|
+
fields?: Partial<Record<keyof Session, string>>;
|
|
1063
1097
|
/**
|
|
1064
1098
|
* Expiration time for the session token. The value
|
|
1065
1099
|
* should be in seconds.
|
|
@@ -1076,6 +1110,7 @@ interface BetterAuthOptions {
|
|
|
1076
1110
|
};
|
|
1077
1111
|
account?: {
|
|
1078
1112
|
modelName?: string;
|
|
1113
|
+
fields?: Partial<Record<keyof Account, string>>;
|
|
1079
1114
|
accountLinking?: {
|
|
1080
1115
|
/**
|
|
1081
1116
|
* Enable account linking
|
|
@@ -1089,6 +1124,13 @@ interface BetterAuthOptions {
|
|
|
1089
1124
|
trustedProviders?: Array<OAuthProviderList[number] | "email-password">;
|
|
1090
1125
|
};
|
|
1091
1126
|
};
|
|
1127
|
+
/**
|
|
1128
|
+
* Verification configuration
|
|
1129
|
+
*/
|
|
1130
|
+
verification?: {
|
|
1131
|
+
modelName?: string;
|
|
1132
|
+
fields?: Partial<Record<keyof Verification, string>>;
|
|
1133
|
+
};
|
|
1092
1134
|
/**
|
|
1093
1135
|
* List of trusted origins.
|
|
1094
1136
|
*/
|
|
@@ -1259,6 +1301,22 @@ interface BetterAuthOptions {
|
|
|
1259
1301
|
after?: (account: Account) => Promise<void>;
|
|
1260
1302
|
};
|
|
1261
1303
|
};
|
|
1304
|
+
verification?: {
|
|
1305
|
+
[key in "create" | "update"]: {
|
|
1306
|
+
/**
|
|
1307
|
+
* Hook that is called before a user is created.
|
|
1308
|
+
* if the hook returns false, the user will not be created.
|
|
1309
|
+
* If the hook returns an object, it'll be used instead of the original data
|
|
1310
|
+
*/
|
|
1311
|
+
before?: (verification: Verification) => Promise<boolean | void | {
|
|
1312
|
+
data: Verification & Record<string, any>;
|
|
1313
|
+
}>;
|
|
1314
|
+
/**
|
|
1315
|
+
* Hook that is called after a user is created.
|
|
1316
|
+
*/
|
|
1317
|
+
after?: (verification: Verification) => Promise<void>;
|
|
1318
|
+
};
|
|
1319
|
+
};
|
|
1262
1320
|
};
|
|
1263
1321
|
}
|
|
1264
1322
|
|
|
@@ -1285,17 +1343,17 @@ declare const signInOAuth: {
|
|
|
1285
1343
|
/**
|
|
1286
1344
|
* OAuth2 provider to use`
|
|
1287
1345
|
*/
|
|
1288
|
-
provider: z.ZodEnum<["github", ...("
|
|
1346
|
+
provider: z.ZodEnum<["github", ...("github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter")[]]>;
|
|
1289
1347
|
/**
|
|
1290
1348
|
* If this is true the session will only be valid for the current browser session
|
|
1291
1349
|
*/
|
|
1292
1350
|
dontRememberMe: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
1293
1351
|
}, "strip", z.ZodTypeAny, {
|
|
1294
|
-
provider: "
|
|
1352
|
+
provider: "github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter";
|
|
1295
1353
|
callbackURL?: string | undefined;
|
|
1296
1354
|
dontRememberMe?: boolean | undefined;
|
|
1297
1355
|
}, {
|
|
1298
|
-
provider: "
|
|
1356
|
+
provider: "github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter";
|
|
1299
1357
|
callbackURL?: string | undefined;
|
|
1300
1358
|
dontRememberMe?: boolean | undefined;
|
|
1301
1359
|
}>;
|
|
@@ -1328,17 +1386,17 @@ declare const signInOAuth: {
|
|
|
1328
1386
|
/**
|
|
1329
1387
|
* OAuth2 provider to use`
|
|
1330
1388
|
*/
|
|
1331
|
-
provider: z.ZodEnum<["github", ...("
|
|
1389
|
+
provider: z.ZodEnum<["github", ...("github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter")[]]>;
|
|
1332
1390
|
/**
|
|
1333
1391
|
* If this is true the session will only be valid for the current browser session
|
|
1334
1392
|
*/
|
|
1335
1393
|
dontRememberMe: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
1336
1394
|
}, "strip", z.ZodTypeAny, {
|
|
1337
|
-
provider: "
|
|
1395
|
+
provider: "github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter";
|
|
1338
1396
|
callbackURL?: string | undefined;
|
|
1339
1397
|
dontRememberMe?: boolean | undefined;
|
|
1340
1398
|
}, {
|
|
1341
|
-
provider: "
|
|
1399
|
+
provider: "github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter";
|
|
1342
1400
|
callbackURL?: string | undefined;
|
|
1343
1401
|
dontRememberMe?: boolean | undefined;
|
|
1344
1402
|
}>;
|
|
@@ -2422,14 +2480,14 @@ declare function getEndpoints<C extends AuthContext, Option extends BetterAuthOp
|
|
|
2422
2480
|
}>>;
|
|
2423
2481
|
body: zod.ZodObject<{
|
|
2424
2482
|
callbackURL: zod.ZodOptional<zod.ZodString>;
|
|
2425
|
-
provider: zod.ZodEnum<["github", ...("
|
|
2483
|
+
provider: zod.ZodEnum<["github", ...("github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter")[]]>;
|
|
2426
2484
|
dontRememberMe: zod.ZodOptional<zod.ZodDefault<zod.ZodBoolean>>;
|
|
2427
2485
|
}, "strip", zod.ZodTypeAny, {
|
|
2428
|
-
provider: "
|
|
2486
|
+
provider: "github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter";
|
|
2429
2487
|
callbackURL?: string | undefined;
|
|
2430
2488
|
dontRememberMe?: boolean | undefined;
|
|
2431
2489
|
}, {
|
|
2432
|
-
provider: "
|
|
2490
|
+
provider: "github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter";
|
|
2433
2491
|
callbackURL?: string | undefined;
|
|
2434
2492
|
dontRememberMe?: boolean | undefined;
|
|
2435
2493
|
}>;
|
|
@@ -2452,14 +2510,14 @@ declare function getEndpoints<C extends AuthContext, Option extends BetterAuthOp
|
|
|
2452
2510
|
}>>;
|
|
2453
2511
|
body: zod.ZodObject<{
|
|
2454
2512
|
callbackURL: zod.ZodOptional<zod.ZodString>;
|
|
2455
|
-
provider: zod.ZodEnum<["github", ...("
|
|
2513
|
+
provider: zod.ZodEnum<["github", ...("github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter")[]]>;
|
|
2456
2514
|
dontRememberMe: zod.ZodOptional<zod.ZodDefault<zod.ZodBoolean>>;
|
|
2457
2515
|
}, "strip", zod.ZodTypeAny, {
|
|
2458
|
-
provider: "
|
|
2516
|
+
provider: "github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter";
|
|
2459
2517
|
callbackURL?: string | undefined;
|
|
2460
2518
|
dontRememberMe?: boolean | undefined;
|
|
2461
2519
|
}, {
|
|
2462
|
-
provider: "
|
|
2520
|
+
provider: "github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter";
|
|
2463
2521
|
callbackURL?: string | undefined;
|
|
2464
2522
|
dontRememberMe?: boolean | undefined;
|
|
2465
2523
|
}>;
|
|
@@ -3419,14 +3477,14 @@ declare const router: <C extends AuthContext, Option extends BetterAuthOptions>(
|
|
|
3419
3477
|
}>>;
|
|
3420
3478
|
body: zod.ZodObject<{
|
|
3421
3479
|
callbackURL: zod.ZodOptional<zod.ZodString>;
|
|
3422
|
-
provider: zod.ZodEnum<["github", ...("
|
|
3480
|
+
provider: zod.ZodEnum<["github", ...("github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter")[]]>;
|
|
3423
3481
|
dontRememberMe: zod.ZodOptional<zod.ZodDefault<zod.ZodBoolean>>;
|
|
3424
3482
|
}, "strip", zod.ZodTypeAny, {
|
|
3425
|
-
provider: "
|
|
3483
|
+
provider: "github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter";
|
|
3426
3484
|
callbackURL?: string | undefined;
|
|
3427
3485
|
dontRememberMe?: boolean | undefined;
|
|
3428
3486
|
}, {
|
|
3429
|
-
provider: "
|
|
3487
|
+
provider: "github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter";
|
|
3430
3488
|
callbackURL?: string | undefined;
|
|
3431
3489
|
dontRememberMe?: boolean | undefined;
|
|
3432
3490
|
}>;
|
|
@@ -3449,14 +3507,14 @@ declare const router: <C extends AuthContext, Option extends BetterAuthOptions>(
|
|
|
3449
3507
|
}>>;
|
|
3450
3508
|
body: zod.ZodObject<{
|
|
3451
3509
|
callbackURL: zod.ZodOptional<zod.ZodString>;
|
|
3452
|
-
provider: zod.ZodEnum<["github", ...("
|
|
3510
|
+
provider: zod.ZodEnum<["github", ...("github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter")[]]>;
|
|
3453
3511
|
dontRememberMe: zod.ZodOptional<zod.ZodDefault<zod.ZodBoolean>>;
|
|
3454
3512
|
}, "strip", zod.ZodTypeAny, {
|
|
3455
|
-
provider: "
|
|
3513
|
+
provider: "github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter";
|
|
3456
3514
|
callbackURL?: string | undefined;
|
|
3457
3515
|
dontRememberMe?: boolean | undefined;
|
|
3458
3516
|
}, {
|
|
3459
|
-
provider: "
|
|
3517
|
+
provider: "github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter";
|
|
3460
3518
|
callbackURL?: string | undefined;
|
|
3461
3519
|
dontRememberMe?: boolean | undefined;
|
|
3462
3520
|
}>;
|
|
@@ -4418,14 +4476,14 @@ declare const betterAuth: <O extends BetterAuthOptions>(options: O) => {
|
|
|
4418
4476
|
}>>;
|
|
4419
4477
|
body: zod.ZodObject<{
|
|
4420
4478
|
callbackURL: zod.ZodOptional<zod.ZodString>;
|
|
4421
|
-
provider: zod.ZodEnum<["github", ...("
|
|
4479
|
+
provider: zod.ZodEnum<["github", ...("github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter")[]]>;
|
|
4422
4480
|
dontRememberMe: zod.ZodOptional<zod.ZodDefault<zod.ZodBoolean>>;
|
|
4423
4481
|
}, "strip", zod.ZodTypeAny, {
|
|
4424
|
-
provider: "
|
|
4482
|
+
provider: "github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter";
|
|
4425
4483
|
callbackURL?: string | undefined;
|
|
4426
4484
|
dontRememberMe?: boolean | undefined;
|
|
4427
4485
|
}, {
|
|
4428
|
-
provider: "
|
|
4486
|
+
provider: "github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter";
|
|
4429
4487
|
callbackURL?: string | undefined;
|
|
4430
4488
|
dontRememberMe?: boolean | undefined;
|
|
4431
4489
|
}>;
|
|
@@ -4448,14 +4506,14 @@ declare const betterAuth: <O extends BetterAuthOptions>(options: O) => {
|
|
|
4448
4506
|
}>>;
|
|
4449
4507
|
body: zod.ZodObject<{
|
|
4450
4508
|
callbackURL: zod.ZodOptional<zod.ZodString>;
|
|
4451
|
-
provider: zod.ZodEnum<["github", ...("
|
|
4509
|
+
provider: zod.ZodEnum<["github", ...("github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter")[]]>;
|
|
4452
4510
|
dontRememberMe: zod.ZodOptional<zod.ZodDefault<zod.ZodBoolean>>;
|
|
4453
4511
|
}, "strip", zod.ZodTypeAny, {
|
|
4454
|
-
provider: "
|
|
4512
|
+
provider: "github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter";
|
|
4455
4513
|
callbackURL?: string | undefined;
|
|
4456
4514
|
dontRememberMe?: boolean | undefined;
|
|
4457
4515
|
}, {
|
|
4458
|
-
provider: "
|
|
4516
|
+
provider: "github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter";
|
|
4459
4517
|
callbackURL?: string | undefined;
|
|
4460
4518
|
dontRememberMe?: boolean | undefined;
|
|
4461
4519
|
}>;
|
|
@@ -84,9 +84,26 @@ declare const sessionSchema: z.ZodObject<{
|
|
|
84
84
|
ipAddress?: string | undefined;
|
|
85
85
|
userAgent?: string | undefined;
|
|
86
86
|
}>;
|
|
87
|
+
declare const verificationSchema: z.ZodObject<{
|
|
88
|
+
id: z.ZodString;
|
|
89
|
+
value: z.ZodString;
|
|
90
|
+
expiresAt: z.ZodDate;
|
|
91
|
+
identifier: z.ZodString;
|
|
92
|
+
}, "strip", z.ZodTypeAny, {
|
|
93
|
+
id: string;
|
|
94
|
+
expiresAt: Date;
|
|
95
|
+
value: string;
|
|
96
|
+
identifier: string;
|
|
97
|
+
}, {
|
|
98
|
+
id: string;
|
|
99
|
+
expiresAt: Date;
|
|
100
|
+
value: string;
|
|
101
|
+
identifier: string;
|
|
102
|
+
}>;
|
|
87
103
|
type User = z.infer<typeof userSchema>;
|
|
88
104
|
type Account = z.infer<typeof accountSchema>;
|
|
89
105
|
type Session = z.infer<typeof sessionSchema>;
|
|
106
|
+
type Verification = z.infer<typeof verificationSchema>;
|
|
90
107
|
|
|
91
108
|
interface TwitterProfile {
|
|
92
109
|
data: {
|
|
@@ -826,4 +843,4 @@ type SocialProviders = typeof oAuthProviders extends {
|
|
|
826
843
|
enabled?: boolean;
|
|
827
844
|
}>>> : never : never;
|
|
828
845
|
|
|
829
|
-
export { type Account as A, type DiscordProfile as D, type FacebookProfile as F, type GithubProfile as G, type OAuthProvider as O, type ProviderOptions as P, type Session as S, type TwitchProfile as T, type User as U, type AppleProfile as a, type GoogleProfile as b, type SpotifyProfile as c, type TwitterProfile as d, type SocialProviders as e, type OAuthProviderList as f, oAuthProviderList as g, type GithubOptions as h, github as i, type GoogleOptions as j, google as k, type AppleOptions as l, apple as m, type DiscordOptions as n, oAuthProviders as o, discord as p, type SpotifyOptions as q, type TwitchOptions as r, spotify as s, twitch as t, type FacebookOptions as u, facebook as v, type TwitterOption as w, twitter as x };
|
|
846
|
+
export { type Account as A, type DiscordProfile as D, type FacebookProfile as F, type GithubProfile as G, type OAuthProvider as O, type ProviderOptions as P, type Session as S, type TwitchProfile as T, type User as U, type Verification as V, type AppleProfile as a, type GoogleProfile as b, type SpotifyProfile as c, type TwitterProfile as d, type SocialProviders as e, type OAuthProviderList as f, oAuthProviderList as g, type GithubOptions as h, github as i, type GoogleOptions as j, google as k, type AppleOptions as l, apple as m, type DiscordOptions as n, oAuthProviders as o, discord as p, type SpotifyOptions as q, type TwitchOptions as r, spotify as s, twitch as t, type FacebookOptions as u, facebook as v, type TwitterOption as w, twitter as x };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { e as Auth, a2 as betterAuth } from './index-
|
|
1
|
+
export { e as Auth, a2 as betterAuth } from './index-DAMIZ_6a.js';
|
|
2
2
|
import 'kysely';
|
|
3
|
-
import './index-
|
|
3
|
+
import './index-XxjbEPqj.js';
|
|
4
4
|
import 'arctic';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import './helper-D-PIAORk.js';
|
package/dist/index.js
CHANGED
|
@@ -13,8 +13,6 @@ import { TimeSpan } from 'oslo';
|
|
|
13
13
|
import { generateRandomString, alphabet, constantTimeEqual } from 'oslo/crypto';
|
|
14
14
|
import chalk from 'chalk';
|
|
15
15
|
import { SqliteDialect, MysqlDialect, PostgresDialect, Kysely } from 'kysely';
|
|
16
|
-
import Database from 'better-sqlite3';
|
|
17
|
-
import { Pool } from 'pg';
|
|
18
16
|
import { scrypt } from 'node:crypto';
|
|
19
17
|
import { encodeHex, decodeHex } from 'oslo/encoding';
|
|
20
18
|
|
|
@@ -1194,6 +1192,12 @@ z.object({
|
|
|
1194
1192
|
ipAddress: z.string().optional(),
|
|
1195
1193
|
userAgent: z.string().optional()
|
|
1196
1194
|
});
|
|
1195
|
+
z.object({
|
|
1196
|
+
id: z.string(),
|
|
1197
|
+
value: z.string(),
|
|
1198
|
+
expiresAt: z.date(),
|
|
1199
|
+
identifier: z.string()
|
|
1200
|
+
});
|
|
1197
1201
|
var generateId = () => {
|
|
1198
1202
|
return generateRandomString(36, alphabet("a-z", "0-9"));
|
|
1199
1203
|
};
|
|
@@ -2551,11 +2555,13 @@ var getAuthTables = (options) => {
|
|
|
2551
2555
|
}
|
|
2552
2556
|
};
|
|
2553
2557
|
const { user, session, account, ...pluginTables } = pluginSchema || {};
|
|
2558
|
+
const accountFields = options.account?.fields;
|
|
2559
|
+
const userFields = options.user?.fields;
|
|
2554
2560
|
return {
|
|
2555
2561
|
user: {
|
|
2556
2562
|
tableName: options.user?.modelName || "user",
|
|
2557
2563
|
fields: {
|
|
2558
|
-
name: {
|
|
2564
|
+
[userFields?.name || "name"]: {
|
|
2559
2565
|
type: "string",
|
|
2560
2566
|
required: true
|
|
2561
2567
|
},
|
|
@@ -2618,7 +2624,7 @@ var getAuthTables = (options) => {
|
|
|
2618
2624
|
account: {
|
|
2619
2625
|
tableName: options.account?.modelName || "account",
|
|
2620
2626
|
fields: {
|
|
2621
|
-
accountId: {
|
|
2627
|
+
[accountFields?.accountId || "accountId"]: {
|
|
2622
2628
|
type: "string",
|
|
2623
2629
|
required: true
|
|
2624
2630
|
},
|
|
@@ -2659,6 +2665,23 @@ var getAuthTables = (options) => {
|
|
|
2659
2665
|
},
|
|
2660
2666
|
order: 2
|
|
2661
2667
|
},
|
|
2668
|
+
verification: {
|
|
2669
|
+
tableName: options.verification?.modelName || "verification",
|
|
2670
|
+
fields: {
|
|
2671
|
+
identifier: {
|
|
2672
|
+
type: "string",
|
|
2673
|
+
required: true
|
|
2674
|
+
},
|
|
2675
|
+
value: {
|
|
2676
|
+
type: "string",
|
|
2677
|
+
required: true
|
|
2678
|
+
},
|
|
2679
|
+
expiresAt: {
|
|
2680
|
+
type: "date",
|
|
2681
|
+
required: true
|
|
2682
|
+
}
|
|
2683
|
+
}
|
|
2684
|
+
},
|
|
2662
2685
|
...pluginTables,
|
|
2663
2686
|
...shouldAddRateLimitTable ? rateLimitTable : {}
|
|
2664
2687
|
};
|
|
@@ -2679,7 +2702,7 @@ var createKyselyAdapter = async (config2) => {
|
|
|
2679
2702
|
databaseType = "postgres";
|
|
2680
2703
|
}
|
|
2681
2704
|
}
|
|
2682
|
-
if (
|
|
2705
|
+
if ("aggregate" in db) {
|
|
2683
2706
|
dialect = new SqliteDialect({
|
|
2684
2707
|
database: db
|
|
2685
2708
|
});
|
|
@@ -2691,7 +2714,7 @@ var createKyselyAdapter = async (config2) => {
|
|
|
2691
2714
|
});
|
|
2692
2715
|
databaseType = "mysql";
|
|
2693
2716
|
}
|
|
2694
|
-
if (
|
|
2717
|
+
if ("connect" in db) {
|
|
2695
2718
|
dialect = new PostgresDialect({
|
|
2696
2719
|
pool: db
|
|
2697
2720
|
});
|
|
@@ -3141,24 +3164,26 @@ var verifyPassword = async (hash, password) => {
|
|
|
3141
3164
|
const targetKey = await generateKey(password, salt);
|
|
3142
3165
|
return constantTimeEqual(targetKey, decodeHex(key));
|
|
3143
3166
|
};
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3167
|
+
|
|
3168
|
+
// src/db/with-hooks.ts
|
|
3169
|
+
function getWithHooks(adapter, options) {
|
|
3147
3170
|
const hooks = options.databaseHooks;
|
|
3171
|
+
const tables = getAuthTables(options);
|
|
3148
3172
|
async function createWithHooks(data, model) {
|
|
3173
|
+
let actualData = data;
|
|
3149
3174
|
if (hooks?.[model]?.create?.before) {
|
|
3150
3175
|
const result = await hooks[model].create.before(data);
|
|
3151
3176
|
if (result === false) {
|
|
3152
3177
|
return null;
|
|
3153
3178
|
}
|
|
3154
3179
|
const isObject = typeof result === "object";
|
|
3155
|
-
isObject ? result.data : result;
|
|
3180
|
+
actualData = isObject ? result.data : result;
|
|
3156
3181
|
}
|
|
3157
3182
|
const created = await adapter.create({
|
|
3158
3183
|
model: tables[model].tableName,
|
|
3159
3184
|
data: {
|
|
3160
3185
|
id: generateId(),
|
|
3161
|
-
...
|
|
3186
|
+
...actualData
|
|
3162
3187
|
}
|
|
3163
3188
|
});
|
|
3164
3189
|
if (hooks?.[model]?.create?.after && created) {
|
|
@@ -3166,6 +3191,37 @@ var createInternalAdapter = (adapter, options) => {
|
|
|
3166
3191
|
}
|
|
3167
3192
|
return created;
|
|
3168
3193
|
}
|
|
3194
|
+
async function updateWithHooks(data, where, model) {
|
|
3195
|
+
let actualData = data;
|
|
3196
|
+
if (hooks?.[model]?.update?.before) {
|
|
3197
|
+
const result = await hooks[model].update.before(data);
|
|
3198
|
+
if (result === false) {
|
|
3199
|
+
return null;
|
|
3200
|
+
}
|
|
3201
|
+
const isObject = typeof result === "object";
|
|
3202
|
+
actualData = isObject ? result.data : result;
|
|
3203
|
+
}
|
|
3204
|
+
const updated = await adapter.update({
|
|
3205
|
+
model: tables[model].tableName,
|
|
3206
|
+
update: actualData,
|
|
3207
|
+
where
|
|
3208
|
+
});
|
|
3209
|
+
if (hooks?.[model]?.update?.after && updated) {
|
|
3210
|
+
await hooks[model].update.after(updated);
|
|
3211
|
+
}
|
|
3212
|
+
return updated;
|
|
3213
|
+
}
|
|
3214
|
+
return {
|
|
3215
|
+
createWithHooks,
|
|
3216
|
+
updateWithHooks
|
|
3217
|
+
};
|
|
3218
|
+
}
|
|
3219
|
+
|
|
3220
|
+
// src/db/internal-adapter.ts
|
|
3221
|
+
var createInternalAdapter = (adapter, options) => {
|
|
3222
|
+
const sessionExpiration = options.session?.expiresIn || 60 * 60 * 24 * 7;
|
|
3223
|
+
const tables = getAuthTables(options);
|
|
3224
|
+
const { createWithHooks, updateWithHooks } = getWithHooks(adapter, options);
|
|
3169
3225
|
return {
|
|
3170
3226
|
createOAuthUser: async (user, account) => {
|
|
3171
3227
|
try {
|
|
@@ -3232,30 +3288,15 @@ var createInternalAdapter = (adapter, options) => {
|
|
|
3232
3288
|
};
|
|
3233
3289
|
},
|
|
3234
3290
|
updateSession: async (sessionId, session) => {
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
session = typeof result === "object" ? result.data : result;
|
|
3241
|
-
}
|
|
3242
|
-
const updatedSession = await adapter.update({
|
|
3243
|
-
model: tables.session.tableName,
|
|
3244
|
-
where: [
|
|
3245
|
-
{
|
|
3246
|
-
field: "id",
|
|
3247
|
-
value: sessionId
|
|
3248
|
-
}
|
|
3249
|
-
],
|
|
3250
|
-
update: session
|
|
3251
|
-
});
|
|
3252
|
-
if (hooks?.session?.update?.after && updatedSession) {
|
|
3253
|
-
await hooks.session.update.after(updatedSession);
|
|
3254
|
-
}
|
|
3291
|
+
const updatedSession = await updateWithHooks(
|
|
3292
|
+
session,
|
|
3293
|
+
[{ field: "id", value: sessionId }],
|
|
3294
|
+
"session"
|
|
3295
|
+
);
|
|
3255
3296
|
return updatedSession;
|
|
3256
3297
|
},
|
|
3257
3298
|
deleteSession: async (id) => {
|
|
3258
|
-
|
|
3299
|
+
await adapter.delete({
|
|
3259
3300
|
model: tables.session.tableName,
|
|
3260
3301
|
where: [
|
|
3261
3302
|
{
|
|
@@ -3264,7 +3305,6 @@ var createInternalAdapter = (adapter, options) => {
|
|
|
3264
3305
|
}
|
|
3265
3306
|
]
|
|
3266
3307
|
});
|
|
3267
|
-
return session;
|
|
3268
3308
|
},
|
|
3269
3309
|
deleteSessions: async (userId) => {
|
|
3270
3310
|
return await adapter.delete({
|
|
@@ -3319,45 +3359,30 @@ var createInternalAdapter = (adapter, options) => {
|
|
|
3319
3359
|
return _account;
|
|
3320
3360
|
},
|
|
3321
3361
|
updateUserByEmail: async (email, data) => {
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
data = typeof result === "object" ? result.data : result;
|
|
3328
|
-
}
|
|
3329
|
-
const user = await adapter.update({
|
|
3330
|
-
model: tables.user.tableName,
|
|
3331
|
-
where: [
|
|
3332
|
-
{
|
|
3333
|
-
value: email,
|
|
3334
|
-
field: "email"
|
|
3335
|
-
}
|
|
3336
|
-
],
|
|
3337
|
-
update: data
|
|
3338
|
-
});
|
|
3339
|
-
if (hooks?.user?.update?.after && user) {
|
|
3340
|
-
await hooks.user.update.after(user);
|
|
3341
|
-
}
|
|
3362
|
+
const user = await updateWithHooks(
|
|
3363
|
+
data,
|
|
3364
|
+
[{ field: "email", value: email }],
|
|
3365
|
+
"user"
|
|
3366
|
+
);
|
|
3342
3367
|
return user;
|
|
3343
3368
|
},
|
|
3344
3369
|
updatePassword: async (userId, password) => {
|
|
3345
|
-
const account = await
|
|
3346
|
-
|
|
3347
|
-
|
|
3370
|
+
const account = await updateWithHooks(
|
|
3371
|
+
{
|
|
3372
|
+
password
|
|
3373
|
+
},
|
|
3374
|
+
[
|
|
3348
3375
|
{
|
|
3349
|
-
|
|
3350
|
-
|
|
3376
|
+
field: "userId",
|
|
3377
|
+
value: userId
|
|
3351
3378
|
},
|
|
3352
3379
|
{
|
|
3353
3380
|
field: "providerId",
|
|
3354
3381
|
value: "credential"
|
|
3355
3382
|
}
|
|
3356
3383
|
],
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
}
|
|
3360
|
-
});
|
|
3384
|
+
"account"
|
|
3385
|
+
);
|
|
3361
3386
|
return account;
|
|
3362
3387
|
},
|
|
3363
3388
|
findAccounts: async (userId) => {
|
|
@@ -3373,27 +3398,56 @@ var createInternalAdapter = (adapter, options) => {
|
|
|
3373
3398
|
return accounts;
|
|
3374
3399
|
},
|
|
3375
3400
|
updateAccount: async (accountId, data) => {
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3401
|
+
const account = await updateWithHooks(
|
|
3402
|
+
data,
|
|
3403
|
+
[{ field: "id", value: accountId }],
|
|
3404
|
+
"account"
|
|
3405
|
+
);
|
|
3406
|
+
return account;
|
|
3407
|
+
},
|
|
3408
|
+
createVerificationValue: async (identifier, value) => {
|
|
3409
|
+
const verification = await createWithHooks(
|
|
3410
|
+
{
|
|
3411
|
+
id: generateId(),
|
|
3412
|
+
identifier,
|
|
3413
|
+
value,
|
|
3414
|
+
expiresAt: getDate(1e3 * 60 * 60 * 24)
|
|
3415
|
+
// 1 day
|
|
3416
|
+
},
|
|
3417
|
+
"verification"
|
|
3418
|
+
);
|
|
3419
|
+
return verification;
|
|
3420
|
+
},
|
|
3421
|
+
findVerificationValue: async (identifier) => {
|
|
3422
|
+
const verification = await adapter.findOne({
|
|
3423
|
+
model: tables.verification.tableName,
|
|
3424
|
+
where: [
|
|
3425
|
+
{
|
|
3426
|
+
field: "identifier",
|
|
3427
|
+
value: identifier
|
|
3428
|
+
}
|
|
3429
|
+
]
|
|
3430
|
+
});
|
|
3431
|
+
return verification;
|
|
3432
|
+
},
|
|
3433
|
+
deleteVerificationValue: async (id) => {
|
|
3434
|
+
await adapter.delete({
|
|
3435
|
+
model: tables.verification.tableName,
|
|
3385
3436
|
where: [
|
|
3386
3437
|
{
|
|
3387
3438
|
field: "id",
|
|
3388
|
-
value:
|
|
3439
|
+
value: id
|
|
3389
3440
|
}
|
|
3390
|
-
]
|
|
3391
|
-
update: data
|
|
3441
|
+
]
|
|
3392
3442
|
});
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3443
|
+
},
|
|
3444
|
+
updateVerificationValue: async (id, data) => {
|
|
3445
|
+
const verification = await updateWithHooks(
|
|
3446
|
+
data,
|
|
3447
|
+
[{ field: "id", value: id }],
|
|
3448
|
+
"verification"
|
|
3449
|
+
);
|
|
3450
|
+
return verification;
|
|
3397
3451
|
}
|
|
3398
3452
|
};
|
|
3399
3453
|
};
|
package/dist/next-js.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e as Auth } from './index-
|
|
2
|
-
import { U as User, S as Session } from './index-
|
|
1
|
+
import { e as Auth } from './index-DAMIZ_6a.js';
|
|
2
|
+
import { U as User, S as Session } from './index-XxjbEPqj.js';
|
|
3
3
|
import { NextRequest } from 'next/server';
|
|
4
4
|
import 'kysely';
|
|
5
5
|
import 'better-call';
|
package/dist/node.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as http from 'http';
|
|
2
|
-
import { e as Auth } from './index-
|
|
2
|
+
import { e as Auth } from './index-DAMIZ_6a.js';
|
|
3
3
|
import 'kysely';
|
|
4
|
-
import './index-
|
|
4
|
+
import './index-XxjbEPqj.js';
|
|
5
5
|
import 'arctic';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import './helper-D-PIAORk.js';
|
package/dist/plugins.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { O as OrganizationOptions, b as Passkey, P as PasskeyOptions, W as WebAuthnCookieType, g as getPasskeyActions, m as magicLink, o as organization, p as passkey, c as passkeyClient, t as twoFactor, a as twoFactorClient, u as username } from './index-
|
|
1
|
+
export { O as OrganizationOptions, b as Passkey, P as PasskeyOptions, W as WebAuthnCookieType, g as getPasskeyActions, m as magicLink, o as organization, p as passkey, c as passkeyClient, t as twoFactor, a as twoFactorClient, u as username } from './index-C9Y_qmSM.js';
|
|
2
2
|
export { i as ac } from './index-D1yWsqP4.js';
|
|
3
|
-
import { H as HookEndpointContext } from './index-
|
|
4
|
-
export { b as AuthEndpoint, d as AuthMiddleware, B as BetterAuthPlugin, P as PluginSchema, a as createAuthEndpoint, c as createAuthMiddleware, o as optionsMiddleware } from './index-
|
|
3
|
+
import { H as HookEndpointContext } from './index-DAMIZ_6a.js';
|
|
4
|
+
export { b as AuthEndpoint, d as AuthMiddleware, B as BetterAuthPlugin, P as PluginSchema, a as createAuthEndpoint, c as createAuthMiddleware, o as optionsMiddleware } from './index-DAMIZ_6a.js';
|
|
5
5
|
export { H as HIDE_METADATA } from './hide-metadata-DEHJp1rk.js';
|
|
6
|
-
import './index-
|
|
6
|
+
import './index-XxjbEPqj.js';
|
|
7
7
|
import 'arctic';
|
|
8
8
|
import 'zod';
|
|
9
9
|
import './helper-D-PIAORk.js';
|
package/dist/plugins.js
CHANGED
|
@@ -1022,6 +1022,12 @@ z.object({
|
|
|
1022
1022
|
ipAddress: z.string().optional(),
|
|
1023
1023
|
userAgent: z.string().optional()
|
|
1024
1024
|
});
|
|
1025
|
+
z.object({
|
|
1026
|
+
id: z.string(),
|
|
1027
|
+
value: z.string(),
|
|
1028
|
+
expiresAt: z.date(),
|
|
1029
|
+
identifier: z.string()
|
|
1030
|
+
});
|
|
1025
1031
|
var generateId = () => {
|
|
1026
1032
|
return generateRandomString(36, alphabet("a-z", "0-9"));
|
|
1027
1033
|
};
|
package/dist/react.d.ts
CHANGED
|
@@ -3,9 +3,9 @@ import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from
|
|
|
3
3
|
import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
|
|
4
4
|
import { useStore } from '@nanostores/react';
|
|
5
5
|
import 'zod';
|
|
6
|
-
import './index-
|
|
6
|
+
import './index-DAMIZ_6a.js';
|
|
7
7
|
import 'kysely';
|
|
8
|
-
import './index-
|
|
8
|
+
import './index-XxjbEPqj.js';
|
|
9
9
|
import 'arctic';
|
|
10
10
|
import 'better-call';
|
|
11
11
|
import 'better-sqlite3';
|
package/dist/social.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { l as AppleOptions, a as AppleProfile, n as DiscordOptions, D as DiscordProfile, u as FacebookOptions, F as FacebookProfile, h as GithubOptions, G as GithubProfile, j as GoogleOptions, b as GoogleProfile, O as OAuthProvider, f as OAuthProviderList, P as ProviderOptions, e as SocialProviders, q as SpotifyOptions, c as SpotifyProfile, r as TwitchOptions, T as TwitchProfile, w as TwitterOption, d as TwitterProfile, m as apple, p as discord, v as facebook, i as github, k as google, g as oAuthProviderList, o as oAuthProviders, s as spotify, t as twitch, x as twitter } from './index-
|
|
1
|
+
export { l as AppleOptions, a as AppleProfile, n as DiscordOptions, D as DiscordProfile, u as FacebookOptions, F as FacebookProfile, h as GithubOptions, G as GithubProfile, j as GoogleOptions, b as GoogleProfile, O as OAuthProvider, f as OAuthProviderList, P as ProviderOptions, e as SocialProviders, q as SpotifyOptions, c as SpotifyProfile, r as TwitchOptions, T as TwitchProfile, w as TwitterOption, d as TwitterProfile, m as apple, p as discord, v as facebook, i as github, k as google, g as oAuthProviderList, o as oAuthProviders, s as spotify, t as twitch, x as twitter } from './index-XxjbEPqj.js';
|
|
2
2
|
import 'arctic';
|
|
3
3
|
import './helper-D-PIAORk.js';
|
|
4
4
|
import 'zod';
|
package/dist/solid-start.d.ts
CHANGED
package/dist/solid.d.ts
CHANGED
|
@@ -3,9 +3,9 @@ import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from
|
|
|
3
3
|
import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
|
|
4
4
|
import { Accessor } from 'solid-js';
|
|
5
5
|
import 'zod';
|
|
6
|
-
import './index-
|
|
6
|
+
import './index-DAMIZ_6a.js';
|
|
7
7
|
import 'kysely';
|
|
8
|
-
import './index-
|
|
8
|
+
import './index-XxjbEPqj.js';
|
|
9
9
|
import 'arctic';
|
|
10
10
|
import 'better-call';
|
|
11
11
|
import 'better-sqlite3';
|
package/dist/svelte-kit.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { e as Auth, f as BetterAuthOptions } from './index-
|
|
1
|
+
import { e as Auth, f as BetterAuthOptions } from './index-DAMIZ_6a.js';
|
|
2
2
|
import 'kysely';
|
|
3
|
-
import './index-
|
|
3
|
+
import './index-XxjbEPqj.js';
|
|
4
4
|
import 'arctic';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import './helper-D-PIAORk.js';
|
package/dist/svelte.d.ts
CHANGED
|
@@ -3,9 +3,9 @@ import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
|
3
3
|
import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from './helper-D-PIAORk.js';
|
|
4
4
|
import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
|
|
5
5
|
import 'zod';
|
|
6
|
-
import './index-
|
|
6
|
+
import './index-DAMIZ_6a.js';
|
|
7
7
|
import 'kysely';
|
|
8
|
-
import './index-
|
|
8
|
+
import './index-XxjbEPqj.js';
|
|
9
9
|
import 'arctic';
|
|
10
10
|
import 'better-call';
|
|
11
11
|
import 'better-sqlite3';
|
package/dist/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { B as BetterAuthPlugin, e as Auth, F as FieldAttribute, I as InferFieldOutput } from './index-
|
|
2
|
-
export { A as Adapter, g as AuthContext, f as BetterAuthOptions, G as GenericEndpointContext, H as HookEndpointContext, r as InferPluginTypes, q as InferSession, n as InferUser, P as PluginSchema, R as RateLimit, S as SessionAdapter, W as Where, t as init } from './index-
|
|
1
|
+
import { B as BetterAuthPlugin, e as Auth, F as FieldAttribute, I as InferFieldOutput } from './index-DAMIZ_6a.js';
|
|
2
|
+
export { A as Adapter, g as AuthContext, f as BetterAuthOptions, G as GenericEndpointContext, H as HookEndpointContext, r as InferPluginTypes, q as InferSession, n as InferUser, P as PluginSchema, R as RateLimit, S as SessionAdapter, W as Where, t as init } from './index-DAMIZ_6a.js';
|
|
3
3
|
import { U as UnionToIntersection, H as HasRequiredKeys, P as Prettify, L as LiteralString, S as StripEmptyObjects } from './helper-D-PIAORk.js';
|
|
4
4
|
export { a as LiteralUnion, R as RequiredKeysOf, W as WithoutEmpty } from './helper-D-PIAORk.js';
|
|
5
|
-
import { S as Session, U as User } from './index-
|
|
6
|
-
export { O as OAuthProvider, f as OAuthProviderList, P as ProviderOptions } from './index-
|
|
5
|
+
import { S as Session, U as User } from './index-XxjbEPqj.js';
|
|
6
|
+
export { O as OAuthProvider, f as OAuthProviderList, P as ProviderOptions } from './index-XxjbEPqj.js';
|
|
7
7
|
import { BetterFetchOption, BetterFetchResponse, BetterFetch, BetterFetchPlugin } from '@better-fetch/fetch';
|
|
8
8
|
import { Atom } from 'nanostores';
|
|
9
9
|
import { Endpoint, Context } from 'better-call';
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { g as AuthContext, G as GenericEndpointContext } from './index-
|
|
2
|
-
export { j as BetterAuthCookies, i as createCookieGetter, l as createLogger, k as deleteSessionCookie, h as getCookies, m as logger, p as parseSetCookieHeader, s as setSessionCookie } from './index-
|
|
1
|
+
import { g as AuthContext, G as GenericEndpointContext } from './index-DAMIZ_6a.js';
|
|
2
|
+
export { j as BetterAuthCookies, i as createCookieGetter, l as createLogger, k as deleteSessionCookie, h as getCookies, m as logger, p as parseSetCookieHeader, s as setSessionCookie } from './index-DAMIZ_6a.js';
|
|
3
3
|
export { H as HIDE_METADATA } from './hide-metadata-DEHJp1rk.js';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import 'kysely';
|
|
6
|
-
import './index-
|
|
6
|
+
import './index-XxjbEPqj.js';
|
|
7
7
|
import 'arctic';
|
|
8
8
|
import './helper-D-PIAORk.js';
|
|
9
9
|
import 'better-call';
|
package/dist/vue.d.ts
CHANGED
|
@@ -3,9 +3,9 @@ import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from
|
|
|
3
3
|
import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
|
|
4
4
|
import { Ref, DeepReadonly } from 'vue';
|
|
5
5
|
import 'zod';
|
|
6
|
-
import './index-
|
|
6
|
+
import './index-DAMIZ_6a.js';
|
|
7
7
|
import 'kysely';
|
|
8
|
-
import './index-
|
|
8
|
+
import './index-XxjbEPqj.js';
|
|
9
9
|
import 'arctic';
|
|
10
10
|
import 'better-call';
|
|
11
11
|
import 'better-sqlite3';
|