@better-auth/core 1.3.28 → 1.4.0-beta.11
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 +81 -76
- package/dist/api/index.cjs +30 -0
- package/dist/api/index.d.cts +7 -0
- package/dist/api/index.d.ts +7 -0
- package/dist/api/index.js +26 -0
- package/dist/async_hooks/index.cjs +2 -26
- package/dist/async_hooks/index.d.cts +4 -7
- package/dist/async_hooks/index.d.ts +4 -7
- package/dist/async_hooks/index.js +3 -0
- package/dist/async_hooks-CaXONcb9.cjs +24 -0
- package/dist/async_hooks-CkLtIFa6.js +18 -0
- package/dist/chunk-CUT6urMc.cjs +30 -0
- package/dist/context/index.cjs +8 -0
- package/dist/context/index.d.cts +17 -0
- package/dist/context/index.d.ts +17 -0
- package/dist/context/index.js +4 -0
- package/dist/context-DAu9ytQl.cjs +85 -0
- package/dist/context-rhoB1CVr.js +56 -0
- package/dist/db/adapter/index.cjs +0 -2
- package/dist/db/adapter/index.d.cts +7 -14
- package/dist/db/adapter/index.d.ts +7 -14
- package/dist/db/adapter/index.js +1 -0
- package/dist/db/index.cjs +46 -69
- package/dist/db/index.d.cts +3 -39
- package/dist/db/index.d.ts +3 -39
- package/dist/db/index.js +61 -0
- package/dist/env/index.cjs +15 -311
- package/dist/env/index.d.cts +2 -36
- package/dist/env/index.d.ts +2 -36
- package/dist/env/index.js +3 -0
- package/dist/env-D1OdwBk9.cjs +330 -0
- package/dist/env-DzHiLVFb.js +246 -0
- package/dist/error/index.cjs +4 -43
- package/dist/error/index.d.cts +31 -29
- package/dist/error/index.d.ts +31 -29
- package/dist/error/index.js +4 -0
- package/dist/error-H6U5qGNP.js +45 -0
- package/dist/error-k9KM7GAb.cjs +56 -0
- package/dist/helper-DVgWo5zB.d.cts +6 -0
- package/dist/helper-Dm5AtPVS.d.ts +6 -0
- package/dist/index-BPsqLi68.d.ts +4410 -0
- package/dist/index-CgIE2ECh.d.cts +262 -0
- package/dist/index-ChlC5Vy3.d.ts +344 -0
- package/dist/index-Cmh0x42V.d.ts +262 -0
- package/dist/index-CsHMVqbX.d.ts +82 -0
- package/dist/index-DFwrZMma.d.cts +82 -0
- package/dist/index-OrTFOyAG.d.ts +1871 -0
- package/dist/index-_Oiv-VVr.d.cts +344 -0
- package/dist/index-ehsSkBxt.d.cts +4410 -0
- package/dist/index-yBChAjSS.d.cts +1871 -0
- package/dist/index.cjs +0 -2
- package/dist/index.d.cts +7 -180
- package/dist/index.d.ts +7 -180
- package/dist/index.js +1 -0
- package/dist/oauth2/index.cjs +12 -368
- package/dist/oauth2/index.d.cts +3 -100
- package/dist/oauth2/index.d.ts +3 -100
- package/dist/oauth2/index.js +3 -0
- package/dist/oauth2-D_FUKfC8.js +239 -0
- package/dist/oauth2-DqX_pPhp.cjs +302 -0
- package/dist/social-providers/index.cjs +2262 -2645
- package/dist/social-providers/index.d.cts +4 -3903
- package/dist/social-providers/index.d.ts +4 -3903
- package/dist/social-providers/index.js +2370 -0
- package/dist/utils/index.cjs +2 -6
- package/dist/utils/index.d.cts +4 -5
- package/dist/utils/index.d.ts +4 -5
- package/dist/utils/index.js +3 -0
- package/dist/utils-Bs-jKit4.cjs +13 -0
- package/dist/utils-Sn10glI8.js +7 -0
- package/package.json +35 -25
- package/src/api/index.ts +57 -0
- package/src/async_hooks/index.ts +1 -9
- package/src/context/endpoint-context.ts +32 -0
- package/src/context/index.ts +6 -0
- package/src/context/transaction.ts +63 -0
- package/src/db/index.ts +2 -0
- package/src/db/type.ts +1 -10
- package/src/env/color-depth.ts +4 -5
- package/src/error/codes.ts +1 -1
- package/src/social-providers/apple.ts +2 -2
- package/src/social-providers/atlassian.ts +4 -7
- package/src/social-providers/cognito.ts +4 -7
- package/src/social-providers/discord.ts +2 -5
- package/src/social-providers/dropbox.ts +2 -2
- package/src/social-providers/facebook.ts +3 -6
- package/src/social-providers/figma.ts +4 -7
- package/src/social-providers/github.ts +2 -2
- package/src/social-providers/gitlab.ts +2 -2
- package/src/social-providers/google.ts +4 -7
- package/src/social-providers/huggingface.ts +2 -2
- package/src/social-providers/kakao.ts +2 -2
- package/src/social-providers/kick.ts +2 -5
- package/src/social-providers/line.ts +2 -2
- package/src/social-providers/linear.ts +2 -2
- package/src/social-providers/linkedin.ts +2 -2
- package/src/social-providers/microsoft-entra-id.ts +3 -3
- package/src/social-providers/naver.ts +2 -2
- package/src/social-providers/notion.ts +2 -2
- package/src/social-providers/paypal.ts +3 -3
- package/src/social-providers/reddit.ts +2 -2
- package/src/social-providers/roblox.ts +2 -5
- package/src/social-providers/salesforce.ts +4 -7
- package/src/social-providers/slack.ts +2 -5
- package/src/social-providers/spotify.ts +2 -2
- package/src/social-providers/tiktok.ts +2 -5
- package/src/social-providers/twitch.ts +3 -3
- package/src/social-providers/twitter.ts +2 -2
- package/src/social-providers/vk.ts +2 -5
- package/src/social-providers/zoom.ts +2 -5
- package/src/types/context.ts +20 -99
- package/src/types/index.ts +1 -1
- package/src/types/init-options.ts +20 -22
- package/src/types/plugin.ts +3 -3
- package/{build.config.ts → tsdown.config.ts} +8 -11
- package/dist/async_hooks/index.d.mts +0 -10
- package/dist/async_hooks/index.mjs +0 -25
- package/dist/db/adapter/index.d.mts +0 -14
- package/dist/db/adapter/index.mjs +0 -1
- package/dist/db/index.d.mts +0 -39
- package/dist/db/index.mjs +0 -70
- package/dist/env/index.d.mts +0 -36
- package/dist/env/index.mjs +0 -297
- package/dist/error/index.d.mts +0 -33
- package/dist/error/index.mjs +0 -41
- package/dist/index.d.mts +0 -180
- package/dist/index.mjs +0 -1
- package/dist/middleware/index.cjs +0 -25
- package/dist/middleware/index.d.cts +0 -14
- package/dist/middleware/index.d.mts +0 -14
- package/dist/middleware/index.d.ts +0 -14
- package/dist/middleware/index.mjs +0 -21
- package/dist/oauth2/index.d.mts +0 -100
- package/dist/oauth2/index.mjs +0 -357
- package/dist/shared/core.BJPBStdk.d.ts +0 -1693
- package/dist/shared/core.Bl6TpxyD.d.mts +0 -181
- package/dist/shared/core.Bqe5IGAi.d.ts +0 -13
- package/dist/shared/core.BwoNUcJQ.d.cts +0 -53
- package/dist/shared/core.BwoNUcJQ.d.mts +0 -53
- package/dist/shared/core.BwoNUcJQ.d.ts +0 -53
- package/dist/shared/core.CajxAutx.d.cts +0 -143
- package/dist/shared/core.CajxAutx.d.mts +0 -143
- package/dist/shared/core.CajxAutx.d.ts +0 -143
- package/dist/shared/core.CkkLHQWc.d.mts +0 -1693
- package/dist/shared/core.DkdZ1o38.d.ts +0 -181
- package/dist/shared/core.Dl-70uns.d.cts +0 -84
- package/dist/shared/core.Dl-70uns.d.mts +0 -84
- package/dist/shared/core.Dl-70uns.d.ts +0 -84
- package/dist/shared/core.DyEdx0m7.d.cts +0 -181
- package/dist/shared/core.E9DfzGLz.d.mts +0 -13
- package/dist/shared/core.HqYn20Fi.d.cts +0 -13
- package/dist/shared/core.gYIBmdi1.d.cts +0 -1693
- package/dist/social-providers/index.d.mts +0 -3903
- package/dist/social-providers/index.mjs +0 -2743
- package/dist/utils/index.d.mts +0 -10
- package/dist/utils/index.mjs +0 -5
- package/src/middleware/index.ts +0 -33
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
import 'bun:sqlite';
|
|
9
|
-
import 'node:sqlite';
|
|
10
|
-
import '../../social-providers/index.cjs';
|
|
11
|
-
import '@better-auth/core/oauth2';
|
|
12
|
-
import '../../shared/core.DyEdx0m7.cjs';
|
|
13
|
-
import '../../shared/core.BwoNUcJQ.cjs';
|
|
14
|
-
import '@better-auth/core';
|
|
1
|
+
import "../../helper-DVgWo5zB.cjs";
|
|
2
|
+
import "../../index-CgIE2ECh.cjs";
|
|
3
|
+
import { CleanedWhere, CustomAdapter, DBAdapter, DBAdapterDebugLogOption, DBAdapterFactoryConfig, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, Where } from "../../index-yBChAjSS.cjs";
|
|
4
|
+
import "../../index-_Oiv-VVr.cjs";
|
|
5
|
+
import "../../index-ehsSkBxt.cjs";
|
|
6
|
+
import "../../index-DFwrZMma.cjs";
|
|
7
|
+
export { CleanedWhere, CustomAdapter, DBAdapter, DBAdapterDebugLogOption, DBAdapterFactoryConfig, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, Where };
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
import 'bun:sqlite';
|
|
9
|
-
import 'node:sqlite';
|
|
10
|
-
import '../../social-providers/index.js';
|
|
11
|
-
import '@better-auth/core/oauth2';
|
|
12
|
-
import '../../shared/core.DkdZ1o38.js';
|
|
13
|
-
import '../../shared/core.BwoNUcJQ.js';
|
|
14
|
-
import '@better-auth/core';
|
|
1
|
+
import "../../helper-Dm5AtPVS.js";
|
|
2
|
+
import "../../index-Cmh0x42V.js";
|
|
3
|
+
import { CleanedWhere, CustomAdapter, DBAdapter, DBAdapterDebugLogOption, DBAdapterFactoryConfig, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, Where } from "../../index-OrTFOyAG.js";
|
|
4
|
+
import "../../index-ChlC5Vy3.js";
|
|
5
|
+
import "../../index-BPsqLi68.js";
|
|
6
|
+
import "../../index-CsHMVqbX.js";
|
|
7
|
+
export { CleanedWhere, CustomAdapter, DBAdapter, DBAdapterDebugLogOption, DBAdapterFactoryConfig, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, Where };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/db/index.cjs
CHANGED
|
@@ -1,91 +1,68 @@
|
|
|
1
|
-
|
|
1
|
+
const require_chunk = require('../chunk-CUT6urMc.cjs');
|
|
2
|
+
let zod = require("zod");
|
|
3
|
+
zod = require_chunk.__toESM(zod);
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (e) {
|
|
9
|
-
for (const k in e) {
|
|
10
|
-
n[k] = e[k];
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
n.default = e;
|
|
14
|
-
return n;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const z__namespace = /*#__PURE__*/_interopNamespaceCompat(z);
|
|
18
|
-
|
|
19
|
-
const coreSchema = z__namespace.object({
|
|
20
|
-
id: z__namespace.string(),
|
|
21
|
-
createdAt: z__namespace.date().default(() => /* @__PURE__ */ new Date()),
|
|
22
|
-
updatedAt: z__namespace.date().default(() => /* @__PURE__ */ new Date())
|
|
5
|
+
//#region src/db/schema/shared.ts
|
|
6
|
+
const coreSchema = zod.object({
|
|
7
|
+
id: zod.string(),
|
|
8
|
+
createdAt: zod.date().default(() => /* @__PURE__ */ new Date()),
|
|
9
|
+
updatedAt: zod.date().default(() => /* @__PURE__ */ new Date())
|
|
23
10
|
});
|
|
24
11
|
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/db/schema/user.ts
|
|
25
14
|
const userSchema = coreSchema.extend({
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
15
|
+
email: zod.string().transform((val) => val.toLowerCase()),
|
|
16
|
+
emailVerified: zod.boolean().default(false),
|
|
17
|
+
name: zod.string(),
|
|
18
|
+
image: zod.string().nullish()
|
|
30
19
|
});
|
|
31
20
|
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/db/schema/account.ts
|
|
32
23
|
const accountSchema = coreSchema.extend({
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Refresh token expires at
|
|
45
|
-
*/
|
|
46
|
-
refreshTokenExpiresAt: z__namespace.date().nullish(),
|
|
47
|
-
/**
|
|
48
|
-
* The scopes that the user has authorized
|
|
49
|
-
*/
|
|
50
|
-
scope: z__namespace.string().nullish(),
|
|
51
|
-
/**
|
|
52
|
-
* Password is only stored in the credential provider
|
|
53
|
-
*/
|
|
54
|
-
password: z__namespace.string().nullish()
|
|
24
|
+
providerId: zod.string(),
|
|
25
|
+
accountId: zod.string(),
|
|
26
|
+
userId: zod.coerce.string(),
|
|
27
|
+
accessToken: zod.string().nullish(),
|
|
28
|
+
refreshToken: zod.string().nullish(),
|
|
29
|
+
idToken: zod.string().nullish(),
|
|
30
|
+
accessTokenExpiresAt: zod.date().nullish(),
|
|
31
|
+
refreshTokenExpiresAt: zod.date().nullish(),
|
|
32
|
+
scope: zod.string().nullish(),
|
|
33
|
+
password: zod.string().nullish()
|
|
55
34
|
});
|
|
56
35
|
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/db/schema/session.ts
|
|
57
38
|
const sessionSchema = coreSchema.extend({
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
39
|
+
userId: zod.coerce.string(),
|
|
40
|
+
expiresAt: zod.date(),
|
|
41
|
+
token: zod.string(),
|
|
42
|
+
ipAddress: zod.string().nullish(),
|
|
43
|
+
userAgent: zod.string().nullish()
|
|
63
44
|
});
|
|
64
45
|
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/db/schema/verification.ts
|
|
65
48
|
const verificationSchema = coreSchema.extend({
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
49
|
+
value: zod.string(),
|
|
50
|
+
expiresAt: zod.date(),
|
|
51
|
+
identifier: zod.string()
|
|
69
52
|
});
|
|
70
53
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
* The number of requests made
|
|
78
|
-
*/
|
|
79
|
-
count: z__namespace.number(),
|
|
80
|
-
/**
|
|
81
|
-
* The last request time in milliseconds
|
|
82
|
-
*/
|
|
83
|
-
lastRequest: z__namespace.number()
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/db/schema/rate-limit.ts
|
|
56
|
+
const rateLimitSchema = zod.object({
|
|
57
|
+
key: zod.string(),
|
|
58
|
+
count: zod.number(),
|
|
59
|
+
lastRequest: zod.number()
|
|
84
60
|
});
|
|
85
61
|
|
|
62
|
+
//#endregion
|
|
86
63
|
exports.accountSchema = accountSchema;
|
|
87
64
|
exports.coreSchema = coreSchema;
|
|
88
65
|
exports.rateLimitSchema = rateLimitSchema;
|
|
89
66
|
exports.sessionSchema = sessionSchema;
|
|
90
67
|
exports.userSchema = userSchema;
|
|
91
|
-
exports.verificationSchema = verificationSchema;
|
|
68
|
+
exports.verificationSchema = verificationSchema;
|
package/dist/db/index.d.cts
CHANGED
|
@@ -1,39 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import * as z from 'zod';
|
|
5
|
-
export { A as Account, R as RateLimit, S as Session, U as User, V as Verification, a as accountSchema, r as rateLimitSchema, s as sessionSchema, u as userSchema, v as verificationSchema } from '../shared/core.Dl-70uns.cjs';
|
|
6
|
-
|
|
7
|
-
declare const coreSchema: z.ZodObject<{
|
|
8
|
-
id: z.ZodString;
|
|
9
|
-
createdAt: z.ZodDefault<z.ZodDate>;
|
|
10
|
-
updatedAt: z.ZodDefault<z.ZodDate>;
|
|
11
|
-
}, z.core.$strip>;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @deprecated Backport for 1.3.x, we will remove this in 1.4.x
|
|
15
|
-
*/
|
|
16
|
-
type AuthPluginSchema = BetterAuthPluginDBSchema;
|
|
17
|
-
/**
|
|
18
|
-
* @deprecated Backport for 1.3.x, we will remove this in 1.4.x
|
|
19
|
-
*/
|
|
20
|
-
type FieldAttribute = DBFieldAttribute;
|
|
21
|
-
/**
|
|
22
|
-
* @deprecated Backport for 1.3.x, we will remove this in 1.4.x
|
|
23
|
-
*/
|
|
24
|
-
type FieldAttributeConfig = DBFieldAttributeConfig;
|
|
25
|
-
/**
|
|
26
|
-
* @deprecated Backport for 1.3.x, we will remove this in 1.4.x
|
|
27
|
-
*/
|
|
28
|
-
type FieldType = DBFieldType;
|
|
29
|
-
/**
|
|
30
|
-
* @deprecated Backport for 1.3.x, we will remove this in 1.4.x
|
|
31
|
-
*/
|
|
32
|
-
type Primitive = DBPrimitive;
|
|
33
|
-
/**
|
|
34
|
-
* @deprecated Backport for 1.3.x, we will remove this in 1.4.x
|
|
35
|
-
*/
|
|
36
|
-
type BetterAuthDbSchema = BetterAuthDBSchema;
|
|
37
|
-
|
|
38
|
-
export { BetterAuthDBSchema, BetterAuthPluginDBSchema, DBFieldAttribute, DBFieldAttributeConfig, DBFieldType, DBPrimitive, coreSchema };
|
|
39
|
-
export type { AuthPluginSchema, BetterAuthDbSchema, FieldAttribute, FieldAttributeConfig, FieldType, Primitive };
|
|
1
|
+
import "../helper-DVgWo5zB.cjs";
|
|
2
|
+
import { Account, AuthPluginSchema, BetterAuthDBSchema, BetterAuthDbSchema, BetterAuthPluginDBSchema, DBFieldAttribute, DBFieldAttributeConfig, DBFieldType, DBPreservedModels, DBPrimitive, FieldAttribute, FieldAttributeConfig, FieldType, Primitive, RateLimit, SecondaryStorage, Session, User, Verification, accountSchema, coreSchema, rateLimitSchema, sessionSchema, userSchema, verificationSchema } from "../index-CgIE2ECh.cjs";
|
|
3
|
+
export { Account, AuthPluginSchema, BetterAuthDBSchema, BetterAuthDbSchema, BetterAuthPluginDBSchema, DBFieldAttribute, DBFieldAttributeConfig, DBFieldType, DBPreservedModels, DBPrimitive, FieldAttribute, FieldAttributeConfig, FieldType, Primitive, RateLimit, SecondaryStorage, Session, User, Verification, accountSchema, coreSchema, rateLimitSchema, sessionSchema, userSchema, verificationSchema };
|
package/dist/db/index.d.ts
CHANGED
|
@@ -1,39 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import * as z from 'zod';
|
|
5
|
-
export { A as Account, R as RateLimit, S as Session, U as User, V as Verification, a as accountSchema, r as rateLimitSchema, s as sessionSchema, u as userSchema, v as verificationSchema } from '../shared/core.Dl-70uns.js';
|
|
6
|
-
|
|
7
|
-
declare const coreSchema: z.ZodObject<{
|
|
8
|
-
id: z.ZodString;
|
|
9
|
-
createdAt: z.ZodDefault<z.ZodDate>;
|
|
10
|
-
updatedAt: z.ZodDefault<z.ZodDate>;
|
|
11
|
-
}, z.core.$strip>;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @deprecated Backport for 1.3.x, we will remove this in 1.4.x
|
|
15
|
-
*/
|
|
16
|
-
type AuthPluginSchema = BetterAuthPluginDBSchema;
|
|
17
|
-
/**
|
|
18
|
-
* @deprecated Backport for 1.3.x, we will remove this in 1.4.x
|
|
19
|
-
*/
|
|
20
|
-
type FieldAttribute = DBFieldAttribute;
|
|
21
|
-
/**
|
|
22
|
-
* @deprecated Backport for 1.3.x, we will remove this in 1.4.x
|
|
23
|
-
*/
|
|
24
|
-
type FieldAttributeConfig = DBFieldAttributeConfig;
|
|
25
|
-
/**
|
|
26
|
-
* @deprecated Backport for 1.3.x, we will remove this in 1.4.x
|
|
27
|
-
*/
|
|
28
|
-
type FieldType = DBFieldType;
|
|
29
|
-
/**
|
|
30
|
-
* @deprecated Backport for 1.3.x, we will remove this in 1.4.x
|
|
31
|
-
*/
|
|
32
|
-
type Primitive = DBPrimitive;
|
|
33
|
-
/**
|
|
34
|
-
* @deprecated Backport for 1.3.x, we will remove this in 1.4.x
|
|
35
|
-
*/
|
|
36
|
-
type BetterAuthDbSchema = BetterAuthDBSchema;
|
|
37
|
-
|
|
38
|
-
export { BetterAuthDBSchema, BetterAuthPluginDBSchema, DBFieldAttribute, DBFieldAttributeConfig, DBFieldType, DBPrimitive, coreSchema };
|
|
39
|
-
export type { AuthPluginSchema, BetterAuthDbSchema, FieldAttribute, FieldAttributeConfig, FieldType, Primitive };
|
|
1
|
+
import "../helper-Dm5AtPVS.js";
|
|
2
|
+
import { Account, AuthPluginSchema, BetterAuthDBSchema, BetterAuthDbSchema, BetterAuthPluginDBSchema, DBFieldAttribute, DBFieldAttributeConfig, DBFieldType, DBPreservedModels, DBPrimitive, FieldAttribute, FieldAttributeConfig, FieldType, Primitive, RateLimit, SecondaryStorage, Session, User, Verification, accountSchema, coreSchema, rateLimitSchema, sessionSchema, userSchema, verificationSchema } from "../index-Cmh0x42V.js";
|
|
3
|
+
export { Account, AuthPluginSchema, BetterAuthDBSchema, BetterAuthDbSchema, BetterAuthPluginDBSchema, DBFieldAttribute, DBFieldAttributeConfig, DBFieldType, DBPreservedModels, DBPrimitive, FieldAttribute, FieldAttributeConfig, FieldType, Primitive, RateLimit, SecondaryStorage, Session, User, Verification, accountSchema, coreSchema, rateLimitSchema, sessionSchema, userSchema, verificationSchema };
|
package/dist/db/index.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/db/schema/shared.ts
|
|
4
|
+
const coreSchema = z.object({
|
|
5
|
+
id: z.string(),
|
|
6
|
+
createdAt: z.date().default(() => /* @__PURE__ */ new Date()),
|
|
7
|
+
updatedAt: z.date().default(() => /* @__PURE__ */ new Date())
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/db/schema/user.ts
|
|
12
|
+
const userSchema = coreSchema.extend({
|
|
13
|
+
email: z.string().transform((val) => val.toLowerCase()),
|
|
14
|
+
emailVerified: z.boolean().default(false),
|
|
15
|
+
name: z.string(),
|
|
16
|
+
image: z.string().nullish()
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/db/schema/account.ts
|
|
21
|
+
const accountSchema = coreSchema.extend({
|
|
22
|
+
providerId: z.string(),
|
|
23
|
+
accountId: z.string(),
|
|
24
|
+
userId: z.coerce.string(),
|
|
25
|
+
accessToken: z.string().nullish(),
|
|
26
|
+
refreshToken: z.string().nullish(),
|
|
27
|
+
idToken: z.string().nullish(),
|
|
28
|
+
accessTokenExpiresAt: z.date().nullish(),
|
|
29
|
+
refreshTokenExpiresAt: z.date().nullish(),
|
|
30
|
+
scope: z.string().nullish(),
|
|
31
|
+
password: z.string().nullish()
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/db/schema/session.ts
|
|
36
|
+
const sessionSchema = coreSchema.extend({
|
|
37
|
+
userId: z.coerce.string(),
|
|
38
|
+
expiresAt: z.date(),
|
|
39
|
+
token: z.string(),
|
|
40
|
+
ipAddress: z.string().nullish(),
|
|
41
|
+
userAgent: z.string().nullish()
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/db/schema/verification.ts
|
|
46
|
+
const verificationSchema = coreSchema.extend({
|
|
47
|
+
value: z.string(),
|
|
48
|
+
expiresAt: z.date(),
|
|
49
|
+
identifier: z.string()
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/db/schema/rate-limit.ts
|
|
54
|
+
const rateLimitSchema = z.object({
|
|
55
|
+
key: z.string(),
|
|
56
|
+
count: z.number(),
|
|
57
|
+
lastRequest: z.number()
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
export { accountSchema, coreSchema, rateLimitSchema, sessionSchema, userSchema, verificationSchema };
|
package/dist/env/index.cjs
CHANGED
|
@@ -1,312 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
const require_env = require('../env-D1OdwBk9.cjs');
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const env2 = _getEnv(true);
|
|
18
|
-
env2[prop] = value;
|
|
19
|
-
return true;
|
|
20
|
-
},
|
|
21
|
-
deleteProperty(_, prop) {
|
|
22
|
-
if (!prop) {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
const env2 = _getEnv(true);
|
|
26
|
-
delete env2[prop];
|
|
27
|
-
return true;
|
|
28
|
-
},
|
|
29
|
-
ownKeys() {
|
|
30
|
-
const env2 = _getEnv(true);
|
|
31
|
-
return Object.keys(env2);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
function toBoolean(val) {
|
|
35
|
-
return val ? val !== "false" : false;
|
|
36
|
-
}
|
|
37
|
-
const nodeENV = typeof process !== "undefined" && process.env && process.env.NODE_ENV || "";
|
|
38
|
-
const isProduction = nodeENV === "production";
|
|
39
|
-
const isDevelopment = nodeENV === "dev" || nodeENV === "development";
|
|
40
|
-
const isTest = () => nodeENV === "test" || toBoolean(env.TEST);
|
|
41
|
-
function getEnvVar(key, fallback) {
|
|
42
|
-
if (typeof process !== "undefined" && process.env) {
|
|
43
|
-
return process.env[key] ?? fallback;
|
|
44
|
-
}
|
|
45
|
-
if (typeof Deno !== "undefined") {
|
|
46
|
-
return Deno.env.get(key) ?? fallback;
|
|
47
|
-
}
|
|
48
|
-
if (typeof Bun !== "undefined") {
|
|
49
|
-
return Bun.env[key] ?? fallback;
|
|
50
|
-
}
|
|
51
|
-
return fallback;
|
|
52
|
-
}
|
|
53
|
-
function getBooleanEnvVar(key, fallback = true) {
|
|
54
|
-
const value = getEnvVar(key);
|
|
55
|
-
if (!value) return fallback;
|
|
56
|
-
return value !== "0" && value.toLowerCase() !== "false" && value !== "";
|
|
57
|
-
}
|
|
58
|
-
const ENV = Object.freeze({
|
|
59
|
-
get BETTER_AUTH_SECRET() {
|
|
60
|
-
return getEnvVar("BETTER_AUTH_SECRET");
|
|
61
|
-
},
|
|
62
|
-
get AUTH_SECRET() {
|
|
63
|
-
return getEnvVar("AUTH_SECRET");
|
|
64
|
-
},
|
|
65
|
-
get BETTER_AUTH_TELEMETRY() {
|
|
66
|
-
return getEnvVar("BETTER_AUTH_TELEMETRY");
|
|
67
|
-
},
|
|
68
|
-
get BETTER_AUTH_TELEMETRY_ID() {
|
|
69
|
-
return getEnvVar("BETTER_AUTH_TELEMETRY_ID");
|
|
70
|
-
},
|
|
71
|
-
get NODE_ENV() {
|
|
72
|
-
return getEnvVar("NODE_ENV", "development");
|
|
73
|
-
},
|
|
74
|
-
get PACKAGE_VERSION() {
|
|
75
|
-
return getEnvVar("PACKAGE_VERSION", "0.0.0");
|
|
76
|
-
},
|
|
77
|
-
get BETTER_AUTH_TELEMETRY_ENDPOINT() {
|
|
78
|
-
return getEnvVar(
|
|
79
|
-
"BETTER_AUTH_TELEMETRY_ENDPOINT",
|
|
80
|
-
"https://telemetry.better-auth.com/v1/track"
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
const COLORS_2 = 1;
|
|
86
|
-
const COLORS_16 = 4;
|
|
87
|
-
const COLORS_256 = 8;
|
|
88
|
-
const COLORS_16m = 24;
|
|
89
|
-
const TERM_ENVS = {
|
|
90
|
-
eterm: COLORS_16,
|
|
91
|
-
cons25: COLORS_16,
|
|
92
|
-
console: COLORS_16,
|
|
93
|
-
cygwin: COLORS_16,
|
|
94
|
-
dtterm: COLORS_16,
|
|
95
|
-
gnome: COLORS_16,
|
|
96
|
-
hurd: COLORS_16,
|
|
97
|
-
jfbterm: COLORS_16,
|
|
98
|
-
konsole: COLORS_16,
|
|
99
|
-
kterm: COLORS_16,
|
|
100
|
-
mlterm: COLORS_16,
|
|
101
|
-
mosh: COLORS_16m,
|
|
102
|
-
putty: COLORS_16,
|
|
103
|
-
st: COLORS_16,
|
|
104
|
-
// http://lists.schmorp.de/pipermail/rxvt-unicode/2016q2/002261.html
|
|
105
|
-
"rxvt-unicode-24bit": COLORS_16m,
|
|
106
|
-
// https://bugs.launchpad.net/terminator/+bug/1030562
|
|
107
|
-
terminator: COLORS_16m,
|
|
108
|
-
"xterm-kitty": COLORS_16m
|
|
109
|
-
};
|
|
110
|
-
const CI_ENVS_MAP = new Map(
|
|
111
|
-
Object.entries({
|
|
112
|
-
APPVEYOR: COLORS_256,
|
|
113
|
-
BUILDKITE: COLORS_256,
|
|
114
|
-
CIRCLECI: COLORS_16m,
|
|
115
|
-
DRONE: COLORS_256,
|
|
116
|
-
GITEA_ACTIONS: COLORS_16m,
|
|
117
|
-
GITHUB_ACTIONS: COLORS_16m,
|
|
118
|
-
GITLAB_CI: COLORS_256,
|
|
119
|
-
TRAVIS: COLORS_256
|
|
120
|
-
})
|
|
121
|
-
);
|
|
122
|
-
const TERM_ENVS_REG_EXP = [
|
|
123
|
-
/ansi/,
|
|
124
|
-
/color/,
|
|
125
|
-
/linux/,
|
|
126
|
-
/direct/,
|
|
127
|
-
/^con[0-9]*x[0-9]/,
|
|
128
|
-
/^rxvt/,
|
|
129
|
-
/^screen/,
|
|
130
|
-
/^xterm/,
|
|
131
|
-
/^vt100/,
|
|
132
|
-
/^vt220/
|
|
133
|
-
];
|
|
134
|
-
function getColorDepth() {
|
|
135
|
-
if (getEnvVar("FORCE_COLOR") !== void 0) {
|
|
136
|
-
switch (getEnvVar("FORCE_COLOR")) {
|
|
137
|
-
case "":
|
|
138
|
-
case "1":
|
|
139
|
-
case "true":
|
|
140
|
-
return COLORS_16;
|
|
141
|
-
case "2":
|
|
142
|
-
return COLORS_256;
|
|
143
|
-
case "3":
|
|
144
|
-
return COLORS_16m;
|
|
145
|
-
default:
|
|
146
|
-
return COLORS_2;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
if (getEnvVar("NODE_DISABLE_COLORS") !== void 0 && getEnvVar("NODE_DISABLE_COLORS") !== "" || // See https://no-color.org/
|
|
150
|
-
getEnvVar("NO_COLOR") !== void 0 && getEnvVar("NO_COLOR") !== "" || // The "dumb" special terminal, as defined by terminfo, doesn't support
|
|
151
|
-
// ANSI color control codes.
|
|
152
|
-
// See https://invisible-island.net/ncurses/terminfo.ti.html#toc-_Specials
|
|
153
|
-
getEnvVar("TERM") === "dumb") {
|
|
154
|
-
return COLORS_2;
|
|
155
|
-
}
|
|
156
|
-
if (getEnvVar("TMUX")) {
|
|
157
|
-
return COLORS_16m;
|
|
158
|
-
}
|
|
159
|
-
if ("TF_BUILD" in env && "AGENT_NAME" in env) {
|
|
160
|
-
return COLORS_16;
|
|
161
|
-
}
|
|
162
|
-
if ("CI" in env) {
|
|
163
|
-
for (const { 0: envName, 1: colors } of CI_ENVS_MAP) {
|
|
164
|
-
if (envName in env) {
|
|
165
|
-
return colors;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
if (getEnvVar("CI_NAME") === "codeship") {
|
|
169
|
-
return COLORS_256;
|
|
170
|
-
}
|
|
171
|
-
return COLORS_2;
|
|
172
|
-
}
|
|
173
|
-
if ("TEAMCITY_VERSION" in env) {
|
|
174
|
-
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(
|
|
175
|
-
getEnvVar("TEAMCITY_VERSION")
|
|
176
|
-
) !== null ? COLORS_16 : COLORS_2;
|
|
177
|
-
}
|
|
178
|
-
switch (getEnvVar("TERM_PROGRAM")) {
|
|
179
|
-
case "iTerm.app":
|
|
180
|
-
if (!getEnvVar("TERM_PROGRAM_VERSION") || /^[0-2]\./.exec(getEnvVar("TERM_PROGRAM_VERSION")) !== null) {
|
|
181
|
-
return COLORS_256;
|
|
182
|
-
}
|
|
183
|
-
return COLORS_16m;
|
|
184
|
-
case "HyperTerm":
|
|
185
|
-
case "MacTerm":
|
|
186
|
-
return COLORS_16m;
|
|
187
|
-
case "Apple_Terminal":
|
|
188
|
-
return COLORS_256;
|
|
189
|
-
}
|
|
190
|
-
if (getEnvVar("COLORTERM") === "truecolor" || getEnvVar("COLORTERM") === "24bit") {
|
|
191
|
-
return COLORS_16m;
|
|
192
|
-
}
|
|
193
|
-
if (getEnvVar("TERM")) {
|
|
194
|
-
if (/truecolor/.exec(getEnvVar("TERM")) !== null) {
|
|
195
|
-
return COLORS_16m;
|
|
196
|
-
}
|
|
197
|
-
if (/^xterm-256/.exec(getEnvVar("TERM")) !== null) {
|
|
198
|
-
return COLORS_256;
|
|
199
|
-
}
|
|
200
|
-
const termEnv = getEnvVar("TERM").toLowerCase();
|
|
201
|
-
if (TERM_ENVS[termEnv]) {
|
|
202
|
-
return TERM_ENVS[termEnv];
|
|
203
|
-
}
|
|
204
|
-
if (TERM_ENVS_REG_EXP.some((term) => term.exec(termEnv) !== null)) {
|
|
205
|
-
return COLORS_16;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
if (getEnvVar("COLORTERM")) {
|
|
209
|
-
return COLORS_16;
|
|
210
|
-
}
|
|
211
|
-
return COLORS_2;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
const TTY_COLORS = {
|
|
215
|
-
reset: "\x1B[0m",
|
|
216
|
-
bright: "\x1B[1m",
|
|
217
|
-
dim: "\x1B[2m",
|
|
218
|
-
undim: "\x1B[22m",
|
|
219
|
-
underscore: "\x1B[4m",
|
|
220
|
-
blink: "\x1B[5m",
|
|
221
|
-
reverse: "\x1B[7m",
|
|
222
|
-
hidden: "\x1B[8m",
|
|
223
|
-
fg: {
|
|
224
|
-
black: "\x1B[30m",
|
|
225
|
-
red: "\x1B[31m",
|
|
226
|
-
green: "\x1B[32m",
|
|
227
|
-
yellow: "\x1B[33m",
|
|
228
|
-
blue: "\x1B[34m",
|
|
229
|
-
magenta: "\x1B[35m",
|
|
230
|
-
cyan: "\x1B[36m",
|
|
231
|
-
white: "\x1B[37m"
|
|
232
|
-
},
|
|
233
|
-
bg: {
|
|
234
|
-
black: "\x1B[40m",
|
|
235
|
-
red: "\x1B[41m",
|
|
236
|
-
green: "\x1B[42m",
|
|
237
|
-
yellow: "\x1B[43m",
|
|
238
|
-
blue: "\x1B[44m",
|
|
239
|
-
magenta: "\x1B[45m",
|
|
240
|
-
cyan: "\x1B[46m",
|
|
241
|
-
white: "\x1B[47m"
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
const levels = ["info", "success", "warn", "error", "debug"];
|
|
245
|
-
function shouldPublishLog(currentLogLevel, logLevel) {
|
|
246
|
-
return levels.indexOf(logLevel) <= levels.indexOf(currentLogLevel);
|
|
247
|
-
}
|
|
248
|
-
const levelColors = {
|
|
249
|
-
info: TTY_COLORS.fg.blue,
|
|
250
|
-
success: TTY_COLORS.fg.green,
|
|
251
|
-
warn: TTY_COLORS.fg.yellow,
|
|
252
|
-
error: TTY_COLORS.fg.red,
|
|
253
|
-
debug: TTY_COLORS.fg.magenta
|
|
254
|
-
};
|
|
255
|
-
const formatMessage = (level, message, colorsEnabled) => {
|
|
256
|
-
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
257
|
-
if (colorsEnabled) {
|
|
258
|
-
return `${TTY_COLORS.dim}${timestamp}${TTY_COLORS.reset} ${levelColors[level]}${level.toUpperCase()}${TTY_COLORS.reset} ${TTY_COLORS.bright}[Better Auth]:${TTY_COLORS.reset} ${message}`;
|
|
259
|
-
}
|
|
260
|
-
return `${timestamp} ${level.toUpperCase()} [Better Auth]: ${message}`;
|
|
261
|
-
};
|
|
262
|
-
const createLogger = (options) => {
|
|
263
|
-
const enabled = options?.disabled !== true;
|
|
264
|
-
const logLevel = options?.level ?? "error";
|
|
265
|
-
const isDisableColorsSpecified = options?.disableColors !== void 0;
|
|
266
|
-
const colorsEnabled = isDisableColorsSpecified ? !options.disableColors : getColorDepth() !== 1;
|
|
267
|
-
const LogFunc = (level, message, args = []) => {
|
|
268
|
-
if (!enabled || !shouldPublishLog(logLevel, level)) {
|
|
269
|
-
return;
|
|
270
|
-
}
|
|
271
|
-
const formattedMessage = formatMessage(level, message, colorsEnabled);
|
|
272
|
-
if (!options || typeof options.log !== "function") {
|
|
273
|
-
if (level === "error") {
|
|
274
|
-
console.error(formattedMessage, ...args);
|
|
275
|
-
} else if (level === "warn") {
|
|
276
|
-
console.warn(formattedMessage, ...args);
|
|
277
|
-
} else {
|
|
278
|
-
console.log(formattedMessage, ...args);
|
|
279
|
-
}
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
options.log(level === "success" ? "info" : level, message, ...args);
|
|
283
|
-
};
|
|
284
|
-
const logger2 = Object.fromEntries(
|
|
285
|
-
levels.map((level) => [
|
|
286
|
-
level,
|
|
287
|
-
(...[message, ...args]) => LogFunc(level, message, args)
|
|
288
|
-
])
|
|
289
|
-
);
|
|
290
|
-
return {
|
|
291
|
-
...logger2,
|
|
292
|
-
get level() {
|
|
293
|
-
return logLevel;
|
|
294
|
-
}
|
|
295
|
-
};
|
|
296
|
-
};
|
|
297
|
-
const logger = createLogger();
|
|
298
|
-
|
|
299
|
-
exports.ENV = ENV;
|
|
300
|
-
exports.TTY_COLORS = TTY_COLORS;
|
|
301
|
-
exports.createLogger = createLogger;
|
|
302
|
-
exports.env = env;
|
|
303
|
-
exports.getBooleanEnvVar = getBooleanEnvVar;
|
|
304
|
-
exports.getColorDepth = getColorDepth;
|
|
305
|
-
exports.getEnvVar = getEnvVar;
|
|
306
|
-
exports.isDevelopment = isDevelopment;
|
|
307
|
-
exports.isProduction = isProduction;
|
|
308
|
-
exports.isTest = isTest;
|
|
309
|
-
exports.levels = levels;
|
|
310
|
-
exports.logger = logger;
|
|
311
|
-
exports.nodeENV = nodeENV;
|
|
312
|
-
exports.shouldPublishLog = shouldPublishLog;
|
|
3
|
+
exports.ENV = require_env.ENV;
|
|
4
|
+
exports.TTY_COLORS = require_env.TTY_COLORS;
|
|
5
|
+
exports.createLogger = require_env.createLogger;
|
|
6
|
+
exports.env = require_env.env;
|
|
7
|
+
exports.getBooleanEnvVar = require_env.getBooleanEnvVar;
|
|
8
|
+
exports.getColorDepth = require_env.getColorDepth;
|
|
9
|
+
exports.getEnvVar = require_env.getEnvVar;
|
|
10
|
+
exports.isDevelopment = require_env.isDevelopment;
|
|
11
|
+
exports.isProduction = require_env.isProduction;
|
|
12
|
+
exports.isTest = require_env.isTest;
|
|
13
|
+
exports.levels = require_env.levels;
|
|
14
|
+
exports.logger = require_env.logger;
|
|
15
|
+
exports.nodeENV = require_env.nodeENV;
|
|
16
|
+
exports.shouldPublishLog = require_env.shouldPublishLog;
|