@better-auth/core 1.4.7 → 1.4.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/.turbo/turbo-build.log +7 -7
- package/dist/api/index.d.mts +1 -1
- package/dist/context/index.d.mts +1 -1
- package/dist/db/adapter/index.d.mts +1 -1
- package/dist/db/adapter/index.mjs +1 -1
- package/dist/db/index.d.mts +2 -2
- package/dist/db/index.mjs +1 -1
- package/dist/{get-tables-DeuRhD_P.mjs → get-tables-CMc_Emww.mjs} +4 -2
- package/dist/{index-NeeRjOR2.d.mts → index-CTa0oOlQ.d.mts} +25 -53
- package/dist/index.d.mts +2 -2
- package/dist/oauth2/index.d.mts +1 -1
- package/dist/social-providers/index.d.mts +1 -1
- package/package.json +1 -1
- package/src/db/adapter/types.ts +5 -5
- package/src/db/get-tables.ts +4 -1
- package/src/db/index.ts +1 -36
- package/src/db/test/get-tables.test.ts +21 -0
- package/src/db/type.ts +6 -6
- package/src/oauth2/oauth-provider.ts +2 -2
- package/src/types/helper.ts +9 -1
- package/src/types/init-options.ts +8 -2
- package/src/types/plugin.ts +2 -3
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @better-auth/core@1.4.
|
|
2
|
+
> @better-auth/core@1.4.8-beta.2 build /home/runner/work/better-auth/better-auth/packages/core
|
|
3
3
|
> tsdown
|
|
4
4
|
|
|
5
5
|
[34mℹ[39m tsdown [2mv0.17.2[22m powered by rolldown [2mv1.0.0-beta.53[22m
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
[34mℹ[39m [2mdist/[22m[1mindex.mjs[22m [2m 0.01 kB[22m [2m│ gzip: 0.03 kB[22m
|
|
22
22
|
[34mℹ[39m [2mdist/[22moauth2-D2y9ALiO.mjs [2m 9.19 kB[22m [2m│ gzip: 2.13 kB[22m
|
|
23
23
|
[34mℹ[39m [2mdist/[22menv-DbssmzoK.mjs [2m 7.67 kB[22m [2m│ gzip: 2.54 kB[22m
|
|
24
|
-
[34mℹ[39m [2mdist/[22mget-tables-
|
|
24
|
+
[34mℹ[39m [2mdist/[22mget-tables-CMc_Emww.mjs [2m 6.76 kB[22m [2m│ gzip: 1.30 kB[22m
|
|
25
25
|
[34mℹ[39m [2mdist/[22mcontext-DblZrIwO.mjs [2m 3.89 kB[22m [2m│ gzip: 1.00 kB[22m
|
|
26
26
|
[34mℹ[39m [2mdist/[22merror-CzMAIrPb.mjs [2m 1.77 kB[22m [2m│ gzip: 0.79 kB[22m
|
|
27
27
|
[34mℹ[39m [2mdist/[22mutils-NloIXYE0.mjs [2m 1.10 kB[22m [2m│ gzip: 0.55 kB[22m
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
[34mℹ[39m [2mdist/[22m[32m[1merror/index.d.mts[22m[39m [2m 1.84 kB[22m [2m│ gzip: 0.72 kB[22m
|
|
31
31
|
[34mℹ[39m [2mdist/[22m[32m[1mdb/adapter/index.d.mts[22m[39m [2m 1.34 kB[22m [2m│ gzip: 0.42 kB[22m
|
|
32
32
|
[34mℹ[39m [2mdist/[22m[32m[1mutils/index.d.mts[22m[39m [2m 1.19 kB[22m [2m│ gzip: 0.55 kB[22m
|
|
33
|
-
[34mℹ[39m [2mdist/[22m[32m[
|
|
34
|
-
[34mℹ[39m [2mdist/[22m[32m[
|
|
33
|
+
[34mℹ[39m [2mdist/[22m[32m[1mindex.d.mts[22m[39m [2m 0.92 kB[22m [2m│ gzip: 0.35 kB[22m
|
|
34
|
+
[34mℹ[39m [2mdist/[22m[32m[1mdb/index.d.mts[22m[39m [2m 0.81 kB[22m [2m│ gzip: 0.34 kB[22m
|
|
35
35
|
[34mℹ[39m [2mdist/[22m[32m[1moauth2/index.d.mts[22m[39m [2m 0.76 kB[22m [2m│ gzip: 0.28 kB[22m
|
|
36
36
|
[34mℹ[39m [2mdist/[22m[32m[1menv/index.d.mts[22m[39m [2m 0.59 kB[22m [2m│ gzip: 0.30 kB[22m
|
|
37
37
|
[34mℹ[39m [2mdist/[22m[32m[1mapi/index.d.mts[22m[39m [2m 0.26 kB[22m [2m│ gzip: 0.14 kB[22m
|
|
38
38
|
[34mℹ[39m [2mdist/[22m[32m[1masync_hooks/index.d.mts[22m[39m [2m 0.24 kB[22m [2m│ gzip: 0.16 kB[22m
|
|
39
39
|
[34mℹ[39m [2mdist/[22m[32m[1masync_hooks/pure.index.d.mts[22m[39m [2m 0.22 kB[22m [2m│ gzip: 0.16 kB[22m
|
|
40
|
-
[34mℹ[39m [2mdist/[22m[32mindex-
|
|
40
|
+
[34mℹ[39m [2mdist/[22m[32mindex-CTa0oOlQ.d.mts[39m [2m217.82 kB[22m [2m│ gzip: 34.28 kB[22m
|
|
41
41
|
[34mℹ[39m [2mdist/[22m[32mindex-BRBu0-5h.d.mts[39m [2m 3.31 kB[22m [2m│ gzip: 1.11 kB[22m
|
|
42
|
-
[34mℹ[39m 32 files, total:
|
|
43
|
-
[32m✔[39m Build complete in [
|
|
42
|
+
[34mℹ[39m 32 files, total: 392.43 kB
|
|
43
|
+
[32m✔[39m Build complete in [32m4594ms[39m
|
package/dist/api/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as optionsMiddleware, i as createAuthMiddleware, n as AuthMiddleware, r as createAuthEndpoint, t as AuthEndpoint } from "../index-
|
|
1
|
+
import { a as optionsMiddleware, i as createAuthMiddleware, n as AuthMiddleware, r as createAuthEndpoint, t as AuthEndpoint } from "../index-CTa0oOlQ.mjs";
|
|
2
2
|
export { AuthEndpoint, AuthMiddleware, createAuthEndpoint, createAuthMiddleware, optionsMiddleware };
|
package/dist/context/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Kn as DBAdapter, Zn as DBTransactionAdapter, f as AuthContext } from "../index-
|
|
1
|
+
import { Kn as DBAdapter, Zn as DBTransactionAdapter, f as AuthContext } from "../index-CTa0oOlQ.mjs";
|
|
2
2
|
import { AsyncLocalStorage } from "@better-auth/core/async_hooks";
|
|
3
3
|
import { EndpointContext, InputContext } from "better-call";
|
|
4
4
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $n as JoinOption, Gn as CustomAdapter, Jn as DBAdapterFactoryConfig, Kn as DBAdapter, Qn as JoinConfig, Wn as CleanedWhere, Xn as DBAdapterSchemaCreation, Yn as DBAdapterInstance, Zn as DBTransactionAdapter,
|
|
1
|
+
import { $n as JoinOption, Cr as initGetDefaultFieldName, Gn as CustomAdapter, Jn as DBAdapterFactoryConfig, Kn as DBAdapter, Qn as JoinConfig, Sr as initGetDefaultModelName, Wn as CleanedWhere, Xn as DBAdapterSchemaCreation, Yn as DBAdapterInstance, Zn as DBTransactionAdapter, ar as createAdapterFactory, br as initGetFieldName, cr as AdapterFactoryCustomizeAdapterCreator, dr as CreateAdapterOptions, er as Where, fr as CreateCustomAdapter, ir as createAdapter, lr as AdapterFactoryOptions, nr as withApplyDefault, or as AdapterConfig, qn as DBAdapterDebugLogOption, rr as AdapterFactory, sr as AdapterFactoryConfig, tr as deepmerge, ur as AdapterTestDebugLogs, vr as initGetModelName, xr as initGetFieldAttributes, yr as initGetIdField } from "../../index-CTa0oOlQ.mjs";
|
|
2
2
|
export { AdapterConfig, AdapterFactory, AdapterFactoryConfig, AdapterFactoryCustomizeAdapterCreator, AdapterFactoryOptions, AdapterTestDebugLogs, CleanedWhere, CreateAdapterOptions, CreateCustomAdapter, CustomAdapter, DBAdapter, DBAdapterDebugLogOption, DBAdapterFactoryConfig, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, JoinConfig, JoinOption, Where, createAdapter, createAdapterFactory, deepmerge, initGetDefaultFieldName, initGetDefaultModelName, initGetFieldAttributes, initGetFieldName, initGetIdField, initGetModelName, withApplyDefault };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as getAuthTables } from "../../get-tables-
|
|
1
|
+
import { t as getAuthTables } from "../../get-tables-CMc_Emww.mjs";
|
|
2
2
|
import { i as logger, n as createLogger, o as getColorDepth, t as TTY_COLORS } from "../../env-DbssmzoK.mjs";
|
|
3
3
|
import { n as safeJSONParse, r as generateId } from "../../utils-NloIXYE0.mjs";
|
|
4
4
|
import { t as BetterAuthError } from "../../error-CzMAIrPb.mjs";
|
package/dist/db/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Ar as
|
|
2
|
-
export { Account,
|
|
1
|
+
import { Ar as sessionSchema, Br as DBFieldAttributeConfig, Dr as userSchema, Er as User, Fr as BetterAuthPluginDBSchema, Hr as DBPrimitive, Ir as getAuthTables, Lr as BaseModelNames, Mr as rateLimitSchema, Nr as Account, Or as coreSchema, Pr as accountSchema, Rr as BetterAuthDBSchema, Tr as verificationSchema, Ur as ModelNames, Vr as DBFieldType, Wr as SecondaryStorage, jr as RateLimit, kr as Session, wr as Verification, zr as DBFieldAttribute } from "../index-CTa0oOlQ.mjs";
|
|
2
|
+
export { Account, BaseModelNames, BetterAuthDBSchema, BetterAuthPluginDBSchema, DBFieldAttribute, DBFieldAttributeConfig, DBFieldType, DBPrimitive, ModelNames, RateLimit, SecondaryStorage, Session, User, Verification, accountSchema, coreSchema, getAuthTables, rateLimitSchema, sessionSchema, userSchema, verificationSchema };
|
package/dist/db/index.mjs
CHANGED
|
@@ -31,7 +31,7 @@ const getAuthTables = (options) => {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
} };
|
|
34
|
-
const { user, session, account, ...pluginTables } = pluginSchema;
|
|
34
|
+
const { user, session, account, verification, ...pluginTables } = pluginSchema;
|
|
35
35
|
const sessionTable = { session: {
|
|
36
36
|
modelName: options.session?.modelName || "session",
|
|
37
37
|
fields: {
|
|
@@ -239,7 +239,9 @@ const getAuthTables = (options) => {
|
|
|
239
239
|
defaultValue: () => /* @__PURE__ */ new Date(),
|
|
240
240
|
onUpdate: () => /* @__PURE__ */ new Date(),
|
|
241
241
|
fieldName: options.verification?.fields?.updatedAt || "updatedAt"
|
|
242
|
-
}
|
|
242
|
+
},
|
|
243
|
+
...verification?.fields,
|
|
244
|
+
...options.verification?.additionalFields
|
|
243
245
|
},
|
|
244
246
|
order: 4
|
|
245
247
|
},
|
|
@@ -49,8 +49,8 @@ type DBFieldAttributeConfig = {
|
|
|
49
49
|
* transform the value before storing it.
|
|
50
50
|
*/
|
|
51
51
|
transform?: {
|
|
52
|
-
input?: (value: DBPrimitive) =>
|
|
53
|
-
output?: (value: DBPrimitive) =>
|
|
52
|
+
input?: (value: DBPrimitive) => Awaitable<DBPrimitive>;
|
|
53
|
+
output?: (value: DBPrimitive) => Awaitable<DBPrimitive>;
|
|
54
54
|
} | undefined;
|
|
55
55
|
/**
|
|
56
56
|
* Reference to another model.
|
|
@@ -127,7 +127,7 @@ interface SecondaryStorage {
|
|
|
127
127
|
* @param key - Key to get
|
|
128
128
|
* @returns - Value of the key
|
|
129
129
|
*/
|
|
130
|
-
get: (key: string) =>
|
|
130
|
+
get: (key: string) => Awaitable<unknown>;
|
|
131
131
|
set: (
|
|
132
132
|
/**
|
|
133
133
|
* Key to store
|
|
@@ -140,14 +140,17 @@ interface SecondaryStorage {
|
|
|
140
140
|
/**
|
|
141
141
|
* Time to live in seconds
|
|
142
142
|
*/
|
|
143
|
-
ttl?: number | undefined) =>
|
|
143
|
+
ttl?: number | undefined) => Awaitable<void | null | unknown>;
|
|
144
144
|
/**
|
|
145
145
|
*
|
|
146
146
|
* @param key - Key to delete
|
|
147
147
|
*/
|
|
148
|
-
delete: (key: string) =>
|
|
148
|
+
delete: (key: string) => Awaitable<void | null | string>;
|
|
149
149
|
}
|
|
150
150
|
//#endregion
|
|
151
|
+
//#region src/db/get-tables.d.ts
|
|
152
|
+
declare const getAuthTables: (options: BetterAuthOptions) => BetterAuthDBSchema;
|
|
153
|
+
//#endregion
|
|
151
154
|
//#region src/db/plugin.d.ts
|
|
152
155
|
type BetterAuthPluginDBSchema = { [table in string]: {
|
|
153
156
|
fields: {
|
|
@@ -249,35 +252,6 @@ declare const verificationSchema: z.ZodObject<{
|
|
|
249
252
|
*/
|
|
250
253
|
type Verification = z.infer<typeof verificationSchema>;
|
|
251
254
|
//#endregion
|
|
252
|
-
//#region src/db/get-tables.d.ts
|
|
253
|
-
declare const getAuthTables: (options: BetterAuthOptions) => BetterAuthDBSchema;
|
|
254
|
-
//#endregion
|
|
255
|
-
//#region src/db/index.d.ts
|
|
256
|
-
/**
|
|
257
|
-
* @deprecated Backport for 1.3.x, we will remove this in 1.4.x
|
|
258
|
-
*/
|
|
259
|
-
type AuthPluginSchema = BetterAuthPluginDBSchema;
|
|
260
|
-
/**
|
|
261
|
-
* @deprecated Backport for 1.3.x, we will remove this in 1.4.x
|
|
262
|
-
*/
|
|
263
|
-
type FieldAttribute = DBFieldAttribute;
|
|
264
|
-
/**
|
|
265
|
-
* @deprecated Backport for 1.3.x, we will remove this in 1.4.x
|
|
266
|
-
*/
|
|
267
|
-
type FieldAttributeConfig = DBFieldAttributeConfig;
|
|
268
|
-
/**
|
|
269
|
-
* @deprecated Backport for 1.3.x, we will remove this in 1.4.x
|
|
270
|
-
*/
|
|
271
|
-
type FieldType = DBFieldType;
|
|
272
|
-
/**
|
|
273
|
-
* @deprecated Backport for 1.3.x, we will remove this in 1.4.x
|
|
274
|
-
*/
|
|
275
|
-
type Primitive$1 = DBPrimitive;
|
|
276
|
-
/**
|
|
277
|
-
* @deprecated Backport for 1.3.x, we will remove this in 1.4.x
|
|
278
|
-
*/
|
|
279
|
-
type BetterAuthDbSchema = BetterAuthDBSchema;
|
|
280
|
-
//#endregion
|
|
281
255
|
//#region src/db/adapter/get-default-field-name.d.ts
|
|
282
256
|
declare const initGetDefaultFieldName: ({
|
|
283
257
|
schema,
|
|
@@ -384,6 +358,7 @@ declare const initGetModelName: ({
|
|
|
384
358
|
//#endregion
|
|
385
359
|
//#region src/types/helper.d.ts
|
|
386
360
|
type Primitive = string | number | symbol | bigint | boolean | null | undefined;
|
|
361
|
+
type Awaitable<T> = T | Promise<T>;
|
|
387
362
|
type LiteralString = "" | (string & Record<never, never>);
|
|
388
363
|
type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
|
|
389
364
|
type Prettify<T> = { [K in keyof T]: T[K] } & {};
|
|
@@ -414,7 +389,7 @@ type AdapterFactoryCustomizeAdapterCreator = (config: {
|
|
|
414
389
|
*
|
|
415
390
|
* If the config has defined `debugLogs` as `false`, no logs will be shown.
|
|
416
391
|
*/
|
|
417
|
-
debugLog: (...args:
|
|
392
|
+
debugLog: (...args: unknown[]) => void;
|
|
418
393
|
/**
|
|
419
394
|
* Get the model name which is expected to be saved in the database based on the user's schema.
|
|
420
395
|
*/
|
|
@@ -472,8 +447,8 @@ type AdapterFactoryCustomizeAdapterCreator = (config: {
|
|
|
472
447
|
model: string;
|
|
473
448
|
field: string;
|
|
474
449
|
}) => DBFieldAttribute;
|
|
475
|
-
transformInput: (data: Record<string,
|
|
476
|
-
transformOutput: (data: Record<string,
|
|
450
|
+
transformInput: (data: Record<string, unknown>, defaultModelName: string, action: "create" | "update", forceAllowId?: boolean | undefined) => Promise<Record<string, unknown>>;
|
|
451
|
+
transformOutput: (data: Record<string, unknown>, defaultModelName: string, select?: string[] | undefined, joinConfig?: JoinConfig | undefined) => Promise<Record<string, unknown>>;
|
|
477
452
|
transformWhereClause: <W extends Where[] | undefined>({
|
|
478
453
|
model,
|
|
479
454
|
where
|
|
@@ -1068,7 +1043,7 @@ interface OAuthProvider<T extends Record<string, any> = Record<string, any>, O e
|
|
|
1068
1043
|
redirectURI: string;
|
|
1069
1044
|
display?: string | undefined;
|
|
1070
1045
|
loginHint?: string | undefined;
|
|
1071
|
-
}) =>
|
|
1046
|
+
}) => Awaitable<URL>;
|
|
1072
1047
|
name: string;
|
|
1073
1048
|
validateAuthorizationCode: (data: {
|
|
1074
1049
|
code: string;
|
|
@@ -3706,7 +3681,8 @@ declare const zoom: (userOptions: ZoomOptions) => {
|
|
|
3706
3681
|
refreshAccessToken: (refreshToken: string) => Promise<OAuth2Tokens>;
|
|
3707
3682
|
getUserInfo(token: OAuth2Tokens & {
|
|
3708
3683
|
user?: {
|
|
3709
|
-
name
|
|
3684
|
+
name
|
|
3685
|
+
/** The user's cluster (Example: "us04") */? /** The user's cluster (Example: "us04") */: {
|
|
3710
3686
|
firstName?: string;
|
|
3711
3687
|
lastName?: string;
|
|
3712
3688
|
};
|
|
@@ -4305,16 +4281,7 @@ declare const paypal: (options: PayPalOptions) => {
|
|
|
4305
4281
|
getUserInfo(token: OAuth2Tokens & {
|
|
4306
4282
|
user?: {
|
|
4307
4283
|
name?: {
|
|
4308
|
-
firstName
|
|
4309
|
-
/**
|
|
4310
|
-
* Whether to request shipping address information
|
|
4311
|
-
* @default false
|
|
4312
|
-
*/?
|
|
4313
|
-
/**
|
|
4314
|
-
* Whether to request shipping address information
|
|
4315
|
-
* @default false
|
|
4316
|
-
*/
|
|
4317
|
-
: string;
|
|
4284
|
+
firstName?: string;
|
|
4318
4285
|
lastName?: string;
|
|
4319
4286
|
};
|
|
4320
4287
|
email?: string;
|
|
@@ -6173,7 +6140,6 @@ type SocialProviders = { [K in SocialProviderList[number]]?: Parameters<(typeof
|
|
|
6173
6140
|
type SocialProviderList = typeof socialProviderList;
|
|
6174
6141
|
//#endregion
|
|
6175
6142
|
//#region src/types/plugin.d.ts
|
|
6176
|
-
type Awaitable<T> = T | Promise<T>;
|
|
6177
6143
|
type DeepPartial<T> = T extends Function ? T : T extends object ? { [K in keyof T]?: DeepPartial<T[K]> } : T;
|
|
6178
6144
|
type HookEndpointContext = Partial<EndpointContext<string, any> & Omit<InputContext<string, any>, "method">> & {
|
|
6179
6145
|
path: string;
|
|
@@ -6280,7 +6246,7 @@ type BetterAuthPlugin = {
|
|
|
6280
6246
|
* This will override the default database operations
|
|
6281
6247
|
*/
|
|
6282
6248
|
adapter?: {
|
|
6283
|
-
[key: string]: (...args: any[]) =>
|
|
6249
|
+
[key: string]: (...args: any[]) => Awaitable<any>;
|
|
6284
6250
|
};
|
|
6285
6251
|
};
|
|
6286
6252
|
//#endregion
|
|
@@ -7134,6 +7100,12 @@ type BetterAuthOptions = {
|
|
|
7134
7100
|
* Map verification fields
|
|
7135
7101
|
*/
|
|
7136
7102
|
fields?: Partial<Record<keyof OmitId<Verification>, string>>;
|
|
7103
|
+
/**
|
|
7104
|
+
* Additional fields for the verification
|
|
7105
|
+
*/
|
|
7106
|
+
additionalFields?: {
|
|
7107
|
+
[key: string]: DBFieldAttribute;
|
|
7108
|
+
};
|
|
7137
7109
|
/**
|
|
7138
7110
|
* disable cleaning up expired values when a verification value is
|
|
7139
7111
|
* fetched
|
|
@@ -7143,7 +7115,7 @@ type BetterAuthOptions = {
|
|
|
7143
7115
|
/**
|
|
7144
7116
|
* List of trusted origins.
|
|
7145
7117
|
*/
|
|
7146
|
-
trustedOrigins?: (string[] | ((request: Request) =>
|
|
7118
|
+
trustedOrigins?: (string[] | ((request: Request) => Awaitable<string[]>)) | undefined;
|
|
7147
7119
|
/**
|
|
7148
7120
|
* Rate limiting configuration
|
|
7149
7121
|
*/
|
|
@@ -7750,4 +7722,4 @@ declare function createAuthEndpoint<Path extends string, Options extends Endpoin
|
|
|
7750
7722
|
type AuthEndpoint<Path extends string, Opts extends EndpointOptions, R> = ReturnType<typeof createAuthEndpoint<Path, Opts, R>>;
|
|
7751
7723
|
type AuthMiddleware = ReturnType<typeof createAuthMiddleware>;
|
|
7752
7724
|
//#endregion
|
|
7753
|
-
export { AccountStatus as $, JoinOption as $n, GoogleProfile as $t, PolarOptions as A, createAuthorizationCodeRequest as An,
|
|
7725
|
+
export { AccountStatus as $, JoinOption as $n, GoogleProfile as $t, PolarOptions as A, createAuthorizationCodeRequest as An, sessionSchema as Ar, linear as At, LineIdTokenPayload as B, OAuth2Tokens as Bn, DBFieldAttributeConfig as Br, TwitchOptions as Bt, SocialProviderListEnum as C, atlassian as Cn, initGetDefaultFieldName as Cr, gitlab as Ct, VercelOptions as D, apple as Dn, userSchema as Dr, LinearOptions as Dt, socialProviders as E, AppleProfile as En, User as Er, linkedin as Et, PayPalTokenResponse as F, createRefreshAccessTokenRequest as Fn, BetterAuthPluginDBSchema as Fr, DropboxProfile as Ft, NaverProfile as G, CustomAdapter as Gn, spotify as Gt, LineUserInfo as H, OAuthProvider as Hn, DBPrimitive as Hr, twitch as Ht, paypal as I, refreshAccessToken as In, getAuthTables as Ir, dropbox as It, KakaoProfile as J, DBAdapterFactoryConfig as Jn, slack as Jt, naver as K, DBAdapter as Kn, SlackOptions as Kt, PaybinOptions as L, createAuthorizationURL as Ln, BaseModelNames as Lr, TwitterOption as Lt, polar as M, validateToken as Mn, rateLimitSchema as Mr, KickProfile as Mt, PayPalOptions as N, generateCodeChallenge as Nn, Account as Nr, kick as Nt, VercelProfile as O, getApplePublicKey as On, coreSchema as Or, LinearProfile as Ot, PayPalProfile as P, getOAuth2Tokens as Pn, accountSchema as Pr, DropboxOptions as Pt, notion as Q, JoinConfig as Qn, GoogleOptions as Qt, PaybinProfile as R, clientCredentialsToken as Rn, BetterAuthDBSchema as Rr, TwitterProfile as Rt, SocialProviderList as S, AtlassianProfile as Sn, initGetDefaultModelName as Sr, GitlabProfile as St, socialProviderList as T, AppleOptions as Tn, verificationSchema as Tr, LinkedInProfile as Tt, line as U, ProviderOptions as Un, ModelNames as Ur, SpotifyOptions as Ut, LineOptions as V, OAuth2UserInfo as Vn, DBFieldType as Vr, TwitchProfile as Vt, NaverOptions as W, CleanedWhere as Wn, SecondaryStorage as Wr, SpotifyProfile as Wt, NotionOptions as X, DBAdapterSchemaCreation as Xn, HuggingFaceProfile as Xt, kakao as Y, DBAdapterInstance as Yn, HuggingFaceOptions as Yt, NotionProfile as Z, DBTransactionAdapter as Zn, huggingface as Zt, BetterAuthRateLimitOptions as _, CognitoOptions as _n, Primitive as _r, reddit as _t, optionsMiddleware as a, GithubOptions as an, createAdapterFactory as ar, zoom as at, HookEndpointContext as b, getCognitoPublicKey as bn, initGetFieldName as br, tiktok as bt, BetterAuthClientPlugin as c, FigmaOptions as cn, AdapterFactoryCustomizeAdapterCreator as cr, vk as ct, ClientStore as d, FacebookOptions as dn, CreateAdapterOptions as dr, salesforce as dt, getGooglePublicKey as en, Where as er, LoginType as et, AuthContext as f, FacebookProfile as fn, CreateCustomAdapter as fr, RobloxOptions as ft, BetterAuthOptions as g, discord as gn, Prettify as gr, RedditProfile as gt, BetterAuthAdvancedOptions as h, DiscordProfile as hn, LiteralUnion as hr, RedditOptions as ht, createAuthMiddleware as i, microsoft as in, createAdapter as ir, ZoomProfile as it, PolarProfile as j, validateAuthorizationCode as jn, RateLimit as jr, KickOptions as jt, vercel as k, BetterAuthCookies as kn, Session as kr, LinearUser as kt, ClientAtomListener as l, FigmaProfile as ln, AdapterFactoryOptions as lr, SalesforceOptions as lt, InternalAdapter as m, DiscordOptions as mn, LiteralString as mr, roblox as mt, AuthMiddleware as n, MicrosoftEntraIDProfile as nn, withApplyDefault as nr, PronounOption as nt, StandardSchemaV1$1 as o, GithubProfile as on, AdapterConfig as or, VkOption as ot, GenericEndpointContext as p, facebook as pn, Awaitable as pr, RobloxProfile as pt, KakaoOptions as q, DBAdapterDebugLogOption as qn, SlackProfile as qt, createAuthEndpoint as r, MicrosoftOptions as rn, AdapterFactory as rr, ZoomOptions as rt, BetterAuthClientOptions as s, github as sn, AdapterFactoryConfig as sr, VkProfile as st, AuthEndpoint as t, google as tn, deepmerge as tr, PhoneNumber as tt, ClientFetchOption as u, figma as un, AdapterTestDebugLogs as ur, SalesforceProfile as ut, GenerateIdFn as v, CognitoProfile as vn, initGetModelName as vr, TiktokOptions as vt, SocialProviders as w, AppleNonConformUser as wn, Verification as wr, LinkedInOptions as wt, SocialProvider as x, AtlassianOptions as xn, initGetFieldAttributes as xr, GitlabOptions as xt, BetterAuthPlugin as y, cognito as yn, initGetIdField as yr, TiktokProfile as yt, paybin as z, createClientCredentialsTokenRequest as zn, DBFieldAttribute as zr, twitter as zt };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as BetterAuthRateLimitOptions, b as HookEndpointContext, c as BetterAuthClientPlugin, d as ClientStore, f as AuthContext, g as BetterAuthOptions, h as BetterAuthAdvancedOptions, hr as
|
|
2
|
-
export { AuthContext, BetterAuthAdvancedOptions, BetterAuthClientOptions, BetterAuthClientPlugin, BetterAuthCookies, BetterAuthOptions, BetterAuthPlugin, BetterAuthRateLimitOptions, ClientAtomListener, ClientFetchOption, ClientStore, GenerateIdFn, GenericEndpointContext, HookEndpointContext, InternalAdapter, LiteralString, LiteralUnion, Prettify, StandardSchemaV1 };
|
|
1
|
+
import { _ as BetterAuthRateLimitOptions, _r as Primitive, b as HookEndpointContext, c as BetterAuthClientPlugin, d as ClientStore, f as AuthContext, g as BetterAuthOptions, gr as Prettify, h as BetterAuthAdvancedOptions, hr as LiteralUnion, kn as BetterAuthCookies, l as ClientAtomListener, m as InternalAdapter, mr as LiteralString, o as StandardSchemaV1, p as GenericEndpointContext, pr as Awaitable, s as BetterAuthClientOptions, u as ClientFetchOption, v as GenerateIdFn, y as BetterAuthPlugin } from "./index-CTa0oOlQ.mjs";
|
|
2
|
+
export { AuthContext, Awaitable, BetterAuthAdvancedOptions, BetterAuthClientOptions, BetterAuthClientPlugin, BetterAuthCookies, BetterAuthOptions, BetterAuthPlugin, BetterAuthRateLimitOptions, ClientAtomListener, ClientFetchOption, ClientStore, GenerateIdFn, GenericEndpointContext, HookEndpointContext, InternalAdapter, LiteralString, LiteralUnion, Prettify, Primitive, StandardSchemaV1 };
|
package/dist/oauth2/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { An as createAuthorizationCodeRequest, Bn as OAuth2Tokens, Fn as createRefreshAccessTokenRequest, Hn as OAuthProvider, In as refreshAccessToken, Ln as createAuthorizationURL, Mn as validateToken, Nn as generateCodeChallenge, Pn as getOAuth2Tokens, Rn as clientCredentialsToken, Un as ProviderOptions, Vn as OAuth2UserInfo, jn as validateAuthorizationCode, zn as createClientCredentialsTokenRequest } from "../index-
|
|
1
|
+
import { An as createAuthorizationCodeRequest, Bn as OAuth2Tokens, Fn as createRefreshAccessTokenRequest, Hn as OAuthProvider, In as refreshAccessToken, Ln as createAuthorizationURL, Mn as validateToken, Nn as generateCodeChallenge, Pn as getOAuth2Tokens, Rn as clientCredentialsToken, Un as ProviderOptions, Vn as OAuth2UserInfo, jn as validateAuthorizationCode, zn as createClientCredentialsTokenRequest } from "../index-CTa0oOlQ.mjs";
|
|
2
2
|
export { OAuth2Tokens, OAuth2UserInfo, OAuthProvider, ProviderOptions, clientCredentialsToken, createAuthorizationCodeRequest, createAuthorizationURL, createClientCredentialsTokenRequest, createRefreshAccessTokenRequest, generateCodeChallenge, getOAuth2Tokens, refreshAccessToken, validateAuthorizationCode, validateToken };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as AccountStatus, $t as GoogleProfile, A as PolarOptions, At as linear, B as LineIdTokenPayload, Bt as TwitchOptions, C as SocialProviderListEnum, Cn as atlassian, Ct as gitlab, D as VercelOptions, Dn as apple, Dt as LinearOptions, E as socialProviders, En as AppleProfile, Et as linkedin, F as PayPalTokenResponse, Ft as DropboxProfile, G as NaverProfile, Gt as spotify, H as LineUserInfo, Ht as twitch, I as paypal, It as dropbox, J as KakaoProfile, Jt as slack, K as naver, Kt as SlackOptions, L as PaybinOptions, Lt as TwitterOption, M as polar, Mt as KickProfile, N as PayPalOptions, Nt as kick, O as VercelProfile, On as getApplePublicKey, Ot as LinearProfile, P as PayPalProfile, Pt as DropboxOptions, Q as notion, Qt as GoogleOptions, R as PaybinProfile, Rt as TwitterProfile, S as SocialProviderList, Sn as AtlassianProfile, St as GitlabProfile, T as socialProviderList, Tn as AppleOptions, Tt as LinkedInProfile, U as line, Ut as SpotifyOptions, V as LineOptions, Vt as TwitchProfile, W as NaverOptions, Wt as SpotifyProfile, X as NotionOptions, Xt as HuggingFaceProfile, Y as kakao, Yt as HuggingFaceOptions, Z as NotionProfile, Zt as huggingface, _n as CognitoOptions, _t as reddit, an as GithubOptions, at as zoom, bn as getCognitoPublicKey, bt as tiktok, cn as FigmaOptions, ct as vk, dn as FacebookOptions, dt as salesforce, en as getGooglePublicKey, et as LoginType, fn as FacebookProfile, ft as RobloxOptions, gn as discord, gt as RedditProfile, hn as DiscordProfile, ht as RedditOptions, in as microsoft, it as ZoomProfile, j as PolarProfile, jt as KickOptions, k as vercel, kt as LinearUser, ln as FigmaProfile, lt as SalesforceOptions, mn as DiscordOptions, mt as roblox, nn as MicrosoftEntraIDProfile, nt as PronounOption, on as GithubProfile, ot as VkOption, pn as facebook, pt as RobloxProfile, q as KakaoOptions, qt as SlackProfile, rn as MicrosoftOptions, rt as ZoomOptions, sn as github, st as VkProfile, tn as google, tt as PhoneNumber, un as figma, ut as SalesforceProfile, vn as CognitoProfile, vt as TiktokOptions, w as SocialProviders, wn as AppleNonConformUser, wt as LinkedInOptions, x as SocialProvider, xn as AtlassianOptions, xt as GitlabOptions, yn as cognito, yt as TiktokProfile, z as paybin, zt as twitter } from "../index-
|
|
1
|
+
import { $ as AccountStatus, $t as GoogleProfile, A as PolarOptions, At as linear, B as LineIdTokenPayload, Bt as TwitchOptions, C as SocialProviderListEnum, Cn as atlassian, Ct as gitlab, D as VercelOptions, Dn as apple, Dt as LinearOptions, E as socialProviders, En as AppleProfile, Et as linkedin, F as PayPalTokenResponse, Ft as DropboxProfile, G as NaverProfile, Gt as spotify, H as LineUserInfo, Ht as twitch, I as paypal, It as dropbox, J as KakaoProfile, Jt as slack, K as naver, Kt as SlackOptions, L as PaybinOptions, Lt as TwitterOption, M as polar, Mt as KickProfile, N as PayPalOptions, Nt as kick, O as VercelProfile, On as getApplePublicKey, Ot as LinearProfile, P as PayPalProfile, Pt as DropboxOptions, Q as notion, Qt as GoogleOptions, R as PaybinProfile, Rt as TwitterProfile, S as SocialProviderList, Sn as AtlassianProfile, St as GitlabProfile, T as socialProviderList, Tn as AppleOptions, Tt as LinkedInProfile, U as line, Ut as SpotifyOptions, V as LineOptions, Vt as TwitchProfile, W as NaverOptions, Wt as SpotifyProfile, X as NotionOptions, Xt as HuggingFaceProfile, Y as kakao, Yt as HuggingFaceOptions, Z as NotionProfile, Zt as huggingface, _n as CognitoOptions, _t as reddit, an as GithubOptions, at as zoom, bn as getCognitoPublicKey, bt as tiktok, cn as FigmaOptions, ct as vk, dn as FacebookOptions, dt as salesforce, en as getGooglePublicKey, et as LoginType, fn as FacebookProfile, ft as RobloxOptions, gn as discord, gt as RedditProfile, hn as DiscordProfile, ht as RedditOptions, in as microsoft, it as ZoomProfile, j as PolarProfile, jt as KickOptions, k as vercel, kt as LinearUser, ln as FigmaProfile, lt as SalesforceOptions, mn as DiscordOptions, mt as roblox, nn as MicrosoftEntraIDProfile, nt as PronounOption, on as GithubProfile, ot as VkOption, pn as facebook, pt as RobloxProfile, q as KakaoOptions, qt as SlackProfile, rn as MicrosoftOptions, rt as ZoomOptions, sn as github, st as VkProfile, tn as google, tt as PhoneNumber, un as figma, ut as SalesforceProfile, vn as CognitoProfile, vt as TiktokOptions, w as SocialProviders, wn as AppleNonConformUser, wt as LinkedInOptions, x as SocialProvider, xn as AtlassianOptions, xt as GitlabOptions, yn as cognito, yt as TiktokProfile, z as paybin, zt as twitter } from "../index-CTa0oOlQ.mjs";
|
|
2
2
|
export { AccountStatus, AppleNonConformUser, AppleOptions, AppleProfile, AtlassianOptions, AtlassianProfile, CognitoOptions, CognitoProfile, DiscordOptions, DiscordProfile, DropboxOptions, DropboxProfile, FacebookOptions, FacebookProfile, FigmaOptions, FigmaProfile, GithubOptions, GithubProfile, GitlabOptions, GitlabProfile, GoogleOptions, GoogleProfile, HuggingFaceOptions, HuggingFaceProfile, KakaoOptions, KakaoProfile, KickOptions, KickProfile, LineIdTokenPayload, LineOptions, LineUserInfo, LinearOptions, LinearProfile, LinearUser, LinkedInOptions, LinkedInProfile, LoginType, MicrosoftEntraIDProfile, MicrosoftOptions, NaverOptions, NaverProfile, NotionOptions, NotionProfile, PayPalOptions, PayPalProfile, PayPalTokenResponse, PaybinOptions, PaybinProfile, PhoneNumber, PolarOptions, PolarProfile, PronounOption, RedditOptions, RedditProfile, RobloxOptions, RobloxProfile, SalesforceOptions, SalesforceProfile, SlackOptions, SlackProfile, SocialProvider, SocialProviderList, SocialProviderListEnum, SocialProviders, SpotifyOptions, SpotifyProfile, TiktokOptions, TiktokProfile, TwitchOptions, TwitchProfile, TwitterOption, TwitterProfile, VercelOptions, VercelProfile, VkOption, VkProfile, ZoomOptions, ZoomProfile, apple, atlassian, cognito, discord, dropbox, facebook, figma, getApplePublicKey, getCognitoPublicKey, getGooglePublicKey, github, gitlab, google, huggingface, kakao, kick, line, linear, linkedin, microsoft, naver, notion, paybin, paypal, polar, reddit, roblox, salesforce, slack, socialProviderList, socialProviders, spotify, tiktok, twitch, twitter, vercel, vk, zoom };
|
package/package.json
CHANGED
package/src/db/adapter/types.ts
CHANGED
|
@@ -43,7 +43,7 @@ export type AdapterFactoryCustomizeAdapterCreator = (config: {
|
|
|
43
43
|
*
|
|
44
44
|
* If the config has defined `debugLogs` as `false`, no logs will be shown.
|
|
45
45
|
*/
|
|
46
|
-
debugLog: (...args:
|
|
46
|
+
debugLog: (...args: unknown[]) => void;
|
|
47
47
|
/**
|
|
48
48
|
* Get the model name which is expected to be saved in the database based on the user's schema.
|
|
49
49
|
*/
|
|
@@ -97,17 +97,17 @@ export type AdapterFactoryCustomizeAdapterCreator = (config: {
|
|
|
97
97
|
}) => DBFieldAttribute;
|
|
98
98
|
// The following functions are exposed primarily for the purpose of having wrapper adapters.
|
|
99
99
|
transformInput: (
|
|
100
|
-
data: Record<string,
|
|
100
|
+
data: Record<string, unknown>,
|
|
101
101
|
defaultModelName: string,
|
|
102
102
|
action: "create" | "update",
|
|
103
103
|
forceAllowId?: boolean | undefined,
|
|
104
|
-
) => Promise<Record<string,
|
|
104
|
+
) => Promise<Record<string, unknown>>;
|
|
105
105
|
transformOutput: (
|
|
106
|
-
data: Record<string,
|
|
106
|
+
data: Record<string, unknown>,
|
|
107
107
|
defaultModelName: string,
|
|
108
108
|
select?: string[] | undefined,
|
|
109
109
|
joinConfig?: JoinConfig | undefined,
|
|
110
|
-
) => Promise<Record<string,
|
|
110
|
+
) => Promise<Record<string, unknown>>;
|
|
111
111
|
transformWhereClause: <W extends Where[] | undefined>({
|
|
112
112
|
model,
|
|
113
113
|
where,
|
package/src/db/get-tables.ts
CHANGED
|
@@ -47,7 +47,8 @@ export const getAuthTables = (
|
|
|
47
47
|
},
|
|
48
48
|
} satisfies BetterAuthDBSchema;
|
|
49
49
|
|
|
50
|
-
const { user, session, account, ...pluginTables } =
|
|
50
|
+
const { user, session, account, verification, ...pluginTables } =
|
|
51
|
+
pluginSchema;
|
|
51
52
|
|
|
52
53
|
const sessionTable = {
|
|
53
54
|
session: {
|
|
@@ -267,6 +268,8 @@ export const getAuthTables = (
|
|
|
267
268
|
onUpdate: () => new Date(),
|
|
268
269
|
fieldName: options.verification?.fields?.updatedAt || "updatedAt",
|
|
269
270
|
},
|
|
271
|
+
...verification?.fields,
|
|
272
|
+
...options.verification?.additionalFields,
|
|
270
273
|
},
|
|
271
274
|
order: 4,
|
|
272
275
|
},
|
package/src/db/index.ts
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import type {
|
|
3
|
-
BetterAuthDBSchema,
|
|
4
|
-
DBFieldAttribute,
|
|
5
|
-
DBFieldAttributeConfig,
|
|
6
|
-
DBFieldType,
|
|
7
|
-
DBPrimitive,
|
|
8
|
-
} from "./type";
|
|
9
|
-
|
|
1
|
+
export { getAuthTables } from "./get-tables";
|
|
10
2
|
export type { BetterAuthPluginDBSchema } from "./plugin";
|
|
11
3
|
export { type Account, accountSchema } from "./schema/account";
|
|
12
4
|
export { type RateLimit, rateLimitSchema } from "./schema/rate-limit";
|
|
@@ -24,30 +16,3 @@ export type {
|
|
|
24
16
|
ModelNames,
|
|
25
17
|
SecondaryStorage,
|
|
26
18
|
} from "./type";
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @deprecated Backport for 1.3.x, we will remove this in 1.4.x
|
|
30
|
-
*/
|
|
31
|
-
export type AuthPluginSchema = BetterAuthPluginDBSchema;
|
|
32
|
-
/**
|
|
33
|
-
* @deprecated Backport for 1.3.x, we will remove this in 1.4.x
|
|
34
|
-
*/
|
|
35
|
-
export type FieldAttribute = DBFieldAttribute;
|
|
36
|
-
/**
|
|
37
|
-
* @deprecated Backport for 1.3.x, we will remove this in 1.4.x
|
|
38
|
-
*/
|
|
39
|
-
export type FieldAttributeConfig = DBFieldAttributeConfig;
|
|
40
|
-
/**
|
|
41
|
-
* @deprecated Backport for 1.3.x, we will remove this in 1.4.x
|
|
42
|
-
*/
|
|
43
|
-
export type FieldType = DBFieldType;
|
|
44
|
-
/**
|
|
45
|
-
* @deprecated Backport for 1.3.x, we will remove this in 1.4.x
|
|
46
|
-
*/
|
|
47
|
-
export type Primitive = DBPrimitive;
|
|
48
|
-
/**
|
|
49
|
-
* @deprecated Backport for 1.3.x, we will remove this in 1.4.x
|
|
50
|
-
*/
|
|
51
|
-
export type BetterAuthDbSchema = BetterAuthDBSchema;
|
|
52
|
-
|
|
53
|
-
export { getAuthTables } from "./get-tables";
|
|
@@ -59,4 +59,25 @@ describe("getAuthTables", () => {
|
|
|
59
59
|
expect(refreshTokenExpiresAtField.fieldName).toBe("refreshTokenExpiresAt");
|
|
60
60
|
expect(accessTokenExpiresAtField.fieldName).toBe("accessTokenExpiresAt");
|
|
61
61
|
});
|
|
62
|
+
|
|
63
|
+
it("should merge additionalFields into verification table metadata", () => {
|
|
64
|
+
const tables = getAuthTables({
|
|
65
|
+
verification: {
|
|
66
|
+
additionalFields: {
|
|
67
|
+
newField: {
|
|
68
|
+
fieldName: "new_field",
|
|
69
|
+
type: "string",
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const verificationTable = tables.verification;
|
|
76
|
+
const newField = verificationTable!.fields.newField!;
|
|
77
|
+
|
|
78
|
+
console.log(newField);
|
|
79
|
+
expect(newField).not.toBeUndefined();
|
|
80
|
+
expect(newField.fieldName).toBe("new_field");
|
|
81
|
+
expect(newField.type).toBe("string");
|
|
82
|
+
});
|
|
62
83
|
});
|
package/src/db/type.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StandardSchemaV1 } from "@standard-schema/spec";
|
|
2
|
-
import type { LiteralString } from "../types";
|
|
2
|
+
import type { Awaitable, LiteralString } from "../types";
|
|
3
3
|
|
|
4
4
|
export type BaseModelNames = "user" | "account" | "session" | "verification";
|
|
5
5
|
|
|
@@ -63,8 +63,8 @@ export type DBFieldAttributeConfig = {
|
|
|
63
63
|
*/
|
|
64
64
|
transform?:
|
|
65
65
|
| {
|
|
66
|
-
input?: (value: DBPrimitive) =>
|
|
67
|
-
output?: (value: DBPrimitive) =>
|
|
66
|
+
input?: (value: DBPrimitive) => Awaitable<DBPrimitive>;
|
|
67
|
+
output?: (value: DBPrimitive) => Awaitable<DBPrimitive>;
|
|
68
68
|
}
|
|
69
69
|
| undefined;
|
|
70
70
|
/**
|
|
@@ -157,7 +157,7 @@ export interface SecondaryStorage {
|
|
|
157
157
|
* @param key - Key to get
|
|
158
158
|
* @returns - Value of the key
|
|
159
159
|
*/
|
|
160
|
-
get: (key: string) =>
|
|
160
|
+
get: (key: string) => Awaitable<unknown>;
|
|
161
161
|
set: (
|
|
162
162
|
/**
|
|
163
163
|
* Key to store
|
|
@@ -171,10 +171,10 @@ export interface SecondaryStorage {
|
|
|
171
171
|
* Time to live in seconds
|
|
172
172
|
*/
|
|
173
173
|
ttl?: number | undefined,
|
|
174
|
-
) =>
|
|
174
|
+
) => Awaitable<void | null | unknown>;
|
|
175
175
|
/**
|
|
176
176
|
*
|
|
177
177
|
* @param key - Key to delete
|
|
178
178
|
*/
|
|
179
|
-
delete: (key: string) =>
|
|
179
|
+
delete: (key: string) => Awaitable<void | null | string>;
|
|
180
180
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LiteralString } from "../types";
|
|
1
|
+
import type { Awaitable, LiteralString } from "../types";
|
|
2
2
|
|
|
3
3
|
export interface OAuth2Tokens {
|
|
4
4
|
tokenType?: string | undefined;
|
|
@@ -35,7 +35,7 @@ export interface OAuthProvider<
|
|
|
35
35
|
redirectURI: string;
|
|
36
36
|
display?: string | undefined;
|
|
37
37
|
loginHint?: string | undefined;
|
|
38
|
-
}) =>
|
|
38
|
+
}) => Awaitable<URL>;
|
|
39
39
|
name: string;
|
|
40
40
|
validateAuthorizationCode: (data: {
|
|
41
41
|
code: string;
|
package/src/types/helper.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
type Primitive =
|
|
1
|
+
export type Primitive =
|
|
2
|
+
| string
|
|
3
|
+
| number
|
|
4
|
+
| symbol
|
|
5
|
+
| bigint
|
|
6
|
+
| boolean
|
|
7
|
+
| null
|
|
8
|
+
| undefined;
|
|
2
9
|
|
|
10
|
+
export type Awaitable<T> = T | Promise<T>;
|
|
3
11
|
export type LiteralString = "" | (string & Record<never, never>);
|
|
4
12
|
export type LiteralUnion<LiteralType, BaseType extends Primitive> =
|
|
5
13
|
| LiteralType
|
|
@@ -23,7 +23,7 @@ import type { DBAdapterDebugLogOption, DBAdapterInstance } from "../db/adapter";
|
|
|
23
23
|
import type { Logger } from "../env";
|
|
24
24
|
import type { SocialProviderList, SocialProviders } from "../social-providers";
|
|
25
25
|
import type { AuthContext, GenericEndpointContext } from "./context";
|
|
26
|
-
import type { LiteralUnion } from "./helper";
|
|
26
|
+
import type { Awaitable, LiteralUnion } from "./helper";
|
|
27
27
|
import type { BetterAuthPlugin } from "./plugin";
|
|
28
28
|
|
|
29
29
|
type KyselyDatabaseType = "postgres" | "mysql" | "sqlite" | "mssql";
|
|
@@ -954,6 +954,12 @@ export type BetterAuthOptions = {
|
|
|
954
954
|
* Map verification fields
|
|
955
955
|
*/
|
|
956
956
|
fields?: Partial<Record<keyof OmitId<Verification>, string>>;
|
|
957
|
+
/**
|
|
958
|
+
* Additional fields for the verification
|
|
959
|
+
*/
|
|
960
|
+
additionalFields?: {
|
|
961
|
+
[key: string]: DBFieldAttribute;
|
|
962
|
+
};
|
|
957
963
|
/**
|
|
958
964
|
* disable cleaning up expired values when a verification value is
|
|
959
965
|
* fetched
|
|
@@ -965,7 +971,7 @@ export type BetterAuthOptions = {
|
|
|
965
971
|
* List of trusted origins.
|
|
966
972
|
*/
|
|
967
973
|
trustedOrigins?:
|
|
968
|
-
| (string[] | ((request: Request) =>
|
|
974
|
+
| (string[] | ((request: Request) => Awaitable<string[]>))
|
|
969
975
|
| undefined;
|
|
970
976
|
/**
|
|
971
977
|
* Rate limiting configuration
|
package/src/types/plugin.ts
CHANGED
|
@@ -8,10 +8,9 @@ import type { Migration } from "kysely";
|
|
|
8
8
|
import type { AuthMiddleware } from "../api";
|
|
9
9
|
import type { BetterAuthPluginDBSchema } from "../db";
|
|
10
10
|
import type { AuthContext } from "./context";
|
|
11
|
-
import type { LiteralString } from "./helper";
|
|
11
|
+
import type { Awaitable, LiteralString } from "./helper";
|
|
12
12
|
import type { BetterAuthOptions } from "./init-options";
|
|
13
13
|
|
|
14
|
-
type Awaitable<T> = T | Promise<T>;
|
|
15
14
|
type DeepPartial<T> = T extends Function
|
|
16
15
|
? T
|
|
17
16
|
: T extends object
|
|
@@ -153,6 +152,6 @@ export type BetterAuthPlugin = {
|
|
|
153
152
|
* This will override the default database operations
|
|
154
153
|
*/
|
|
155
154
|
adapter?: {
|
|
156
|
-
[key: string]: (...args: any[]) =>
|
|
155
|
+
[key: string]: (...args: any[]) => Awaitable<any>;
|
|
157
156
|
};
|
|
158
157
|
};
|