@better-auth/core 1.4.0-beta.6 → 1.4.0-beta.7
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 +14 -9
- package/build.config.ts +6 -1
- package/dist/async_hooks/index.cjs +27 -0
- package/dist/async_hooks/index.d.cts +10 -0
- package/dist/async_hooks/index.d.mts +10 -0
- package/dist/async_hooks/index.d.ts +10 -0
- package/dist/async_hooks/index.mjs +25 -0
- package/dist/db/adapter/index.cjs +2 -0
- package/dist/db/adapter/index.d.cts +23 -0
- package/dist/db/adapter/index.d.mts +23 -0
- package/dist/db/adapter/index.d.ts +23 -0
- package/dist/db/adapter/index.mjs +1 -0
- package/dist/db/index.cjs +73 -0
- package/dist/db/index.d.cts +91 -105
- package/dist/db/index.d.mts +91 -105
- package/dist/db/index.d.ts +91 -105
- package/dist/db/index.mjs +54 -0
- package/dist/index.d.cts +114 -1
- package/dist/index.d.mts +114 -1
- package/dist/index.d.ts +114 -1
- package/dist/shared/core.CnvFgghY.d.cts +117 -0
- package/dist/shared/core.CnvFgghY.d.mts +117 -0
- package/dist/shared/core.CnvFgghY.d.ts +117 -0
- package/package.json +24 -1
- package/src/async_hooks/index.ts +43 -0
- package/src/db/adapter/index.ts +24 -0
- package/src/db/index.ts +11 -0
- package/src/db/plugin.ts +11 -0
- package/src/db/schema/account.ts +34 -0
- package/src/db/schema/session.ts +17 -0
- package/src/db/schema/shared.ts +7 -0
- package/src/db/schema/user.ts +16 -0
- package/src/db/schema/verification.ts +15 -0
- package/src/db/type.ts +22 -0
- package/src/index.ts +3 -1
- package/src/types/helper.ts +5 -0
- package/src/types/index.ts +2 -1
- package/src/types/init-options.ts +119 -0
- package/tsconfig.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { coreSchema } from "./shared";
|
|
3
|
+
|
|
4
|
+
export const userSchema = coreSchema.extend({
|
|
5
|
+
email: z.string().transform((val) => val.toLowerCase()),
|
|
6
|
+
emailVerified: z.boolean().default(false),
|
|
7
|
+
name: z.string(),
|
|
8
|
+
image: z.string().nullish(),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* User schema type used by better-auth, note that it's possible that user could have additional fields
|
|
13
|
+
*
|
|
14
|
+
* todo: we should use generics to extend this type with additional fields from plugins and options in the future
|
|
15
|
+
*/
|
|
16
|
+
export type User = z.infer<typeof userSchema>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { coreSchema } from "./shared";
|
|
3
|
+
|
|
4
|
+
export const verificationSchema = coreSchema.extend({
|
|
5
|
+
value: z.string(),
|
|
6
|
+
expiresAt: z.date(),
|
|
7
|
+
identifier: z.string(),
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Verification schema type used by better-auth, note that it's possible that verification could have additional fields
|
|
12
|
+
*
|
|
13
|
+
* todo: we should use generics to extend this type with additional fields from plugins and options in the future
|
|
14
|
+
*/
|
|
15
|
+
export type Verification = z.infer<typeof verificationSchema>;
|
package/src/db/type.ts
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
import type { ZodType } from "zod";
|
|
2
2
|
import type { LiteralString } from "../types";
|
|
3
3
|
|
|
4
|
+
declare module "../index" {
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
6
|
+
interface BetterAuthMutators<O, C> {
|
|
7
|
+
"better-auth/db": {
|
|
8
|
+
// todo: we should infer the schema from the adapter
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type Models =
|
|
14
|
+
| "user"
|
|
15
|
+
| "account"
|
|
16
|
+
| "session"
|
|
17
|
+
| "verification"
|
|
18
|
+
| "rate-limit"
|
|
19
|
+
| "organization"
|
|
20
|
+
| "member"
|
|
21
|
+
| "invitation"
|
|
22
|
+
| "jwks"
|
|
23
|
+
| "passkey"
|
|
24
|
+
| "two-factor";
|
|
25
|
+
|
|
4
26
|
export type DBFieldType =
|
|
5
27
|
| "string"
|
|
6
28
|
| "number"
|
package/src/index.ts
CHANGED
package/src/types/helper.ts
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
+
type Primitive = string | number | symbol | bigint | boolean | null | undefined;
|
|
2
|
+
|
|
1
3
|
export type LiteralString = "" | (string & Record<never, never>);
|
|
4
|
+
export type LiteralUnion<LiteralType, BaseType extends Primitive> =
|
|
5
|
+
| LiteralType
|
|
6
|
+
| (BaseType & Record<never, never>);
|
package/src/types/index.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from "./helper";
|
|
1
|
+
export type * from "./helper";
|
|
2
|
+
export type { BetterAuthAdvancedOptions, GenerateIdFn } from "./init-options";
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { CookieOptions } from "better-call";
|
|
2
|
+
import type { LiteralUnion } from "./helper";
|
|
3
|
+
import type { Models } from "../db/type";
|
|
4
|
+
|
|
5
|
+
export type GenerateIdFn = (options: {
|
|
6
|
+
model: LiteralUnion<Models, string>;
|
|
7
|
+
size?: number;
|
|
8
|
+
}) => string | false;
|
|
9
|
+
|
|
10
|
+
export type BetterAuthAdvancedOptions = {
|
|
11
|
+
/**
|
|
12
|
+
* Ip address configuration
|
|
13
|
+
*/
|
|
14
|
+
ipAddress?: {
|
|
15
|
+
/**
|
|
16
|
+
* List of headers to use for ip address
|
|
17
|
+
*
|
|
18
|
+
* Ip address is used for rate limiting and session tracking
|
|
19
|
+
*
|
|
20
|
+
* @example ["x-client-ip", "x-forwarded-for", "cf-connecting-ip"]
|
|
21
|
+
*
|
|
22
|
+
* @default
|
|
23
|
+
* @link https://github.com/better-auth/better-auth/blob/main/packages/better-auth/src/utils/get-request-ip.ts#L8
|
|
24
|
+
*/
|
|
25
|
+
ipAddressHeaders?: string[];
|
|
26
|
+
/**
|
|
27
|
+
* Disable ip tracking
|
|
28
|
+
*
|
|
29
|
+
* ⚠︎ This is a security risk and it may expose your application to abuse
|
|
30
|
+
*/
|
|
31
|
+
disableIpTracking?: boolean;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Use secure cookies
|
|
35
|
+
*
|
|
36
|
+
* @default false
|
|
37
|
+
*/
|
|
38
|
+
useSecureCookies?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Disable trusted origins check
|
|
41
|
+
*
|
|
42
|
+
* ⚠︎ This is a security risk and it may expose your application to CSRF attacks
|
|
43
|
+
*/
|
|
44
|
+
disableCSRFCheck?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Configure cookies to be cross subdomains
|
|
47
|
+
*/
|
|
48
|
+
crossSubDomainCookies?: {
|
|
49
|
+
/**
|
|
50
|
+
* Enable cross subdomain cookies
|
|
51
|
+
*/
|
|
52
|
+
enabled: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Additional cookies to be shared across subdomains
|
|
55
|
+
*/
|
|
56
|
+
additionalCookies?: string[];
|
|
57
|
+
/**
|
|
58
|
+
* The domain to use for the cookies
|
|
59
|
+
*
|
|
60
|
+
* By default, the domain will be the root
|
|
61
|
+
* domain from the base URL.
|
|
62
|
+
*/
|
|
63
|
+
domain?: string;
|
|
64
|
+
};
|
|
65
|
+
/*
|
|
66
|
+
* Allows you to change default cookie names and attributes
|
|
67
|
+
*
|
|
68
|
+
* default cookie names:
|
|
69
|
+
* - "session_token"
|
|
70
|
+
* - "session_data"
|
|
71
|
+
* - "dont_remember"
|
|
72
|
+
*
|
|
73
|
+
* plugins can also add additional cookies
|
|
74
|
+
*/
|
|
75
|
+
cookies?: {
|
|
76
|
+
[key: string]: {
|
|
77
|
+
name?: string;
|
|
78
|
+
attributes?: CookieOptions;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
defaultCookieAttributes?: CookieOptions;
|
|
82
|
+
/**
|
|
83
|
+
* Prefix for cookies. If a cookie name is provided
|
|
84
|
+
* in cookies config, this will be overridden.
|
|
85
|
+
*
|
|
86
|
+
* @default
|
|
87
|
+
* ```txt
|
|
88
|
+
* "appName" -> which defaults to "better-auth"
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
cookiePrefix?: string;
|
|
92
|
+
/**
|
|
93
|
+
* Database configuration.
|
|
94
|
+
*/
|
|
95
|
+
database?: {
|
|
96
|
+
/**
|
|
97
|
+
* The default number of records to return from the database
|
|
98
|
+
* when using the `findMany` adapter method.
|
|
99
|
+
*
|
|
100
|
+
* @default 100
|
|
101
|
+
*/
|
|
102
|
+
defaultFindManyLimit?: number;
|
|
103
|
+
/**
|
|
104
|
+
* If your database auto increments number ids, set this to `true`.
|
|
105
|
+
*
|
|
106
|
+
* Note: If enabled, we will not handle ID generation (including if you use `generateId`), and it would be expected that your database will provide the ID automatically.
|
|
107
|
+
*
|
|
108
|
+
* @default false
|
|
109
|
+
*/
|
|
110
|
+
useNumberId?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Custom generateId function.
|
|
113
|
+
*
|
|
114
|
+
* If not provided, random ids will be generated.
|
|
115
|
+
* If set to false, the database's auto generated id will be used.
|
|
116
|
+
*/
|
|
117
|
+
generateId?: GenerateIdFn | false;
|
|
118
|
+
};
|
|
119
|
+
};
|