@better-auth/core 1.3.26 → 1.3.28
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 +60 -9
- package/build.config.ts +7 -0
- package/dist/db/adapter/index.cjs +2 -0
- package/dist/db/adapter/index.d.cts +14 -0
- package/dist/db/adapter/index.d.mts +14 -0
- package/dist/db/adapter/index.d.ts +14 -0
- package/dist/db/adapter/index.mjs +1 -0
- package/dist/db/index.cjs +89 -0
- package/dist/db/index.d.cts +16 -107
- package/dist/db/index.d.mts +16 -107
- package/dist/db/index.d.ts +16 -107
- package/dist/db/index.mjs +69 -0
- package/dist/env/index.cjs +312 -0
- package/dist/env/index.d.cts +36 -0
- package/dist/env/index.d.mts +36 -0
- package/dist/env/index.d.ts +36 -0
- package/dist/env/index.mjs +297 -0
- package/dist/error/index.cjs +44 -0
- package/dist/error/index.d.cts +33 -0
- package/dist/error/index.d.mts +33 -0
- package/dist/error/index.d.ts +33 -0
- package/dist/error/index.mjs +41 -0
- package/dist/index.d.cts +179 -1
- package/dist/index.d.mts +179 -1
- package/dist/index.d.ts +179 -1
- package/dist/middleware/index.cjs +25 -0
- package/dist/middleware/index.d.cts +14 -0
- package/dist/middleware/index.d.mts +14 -0
- package/dist/middleware/index.d.ts +14 -0
- package/dist/middleware/index.mjs +21 -0
- package/dist/oauth2/index.cjs +368 -0
- package/dist/oauth2/index.d.cts +100 -0
- package/dist/oauth2/index.d.mts +100 -0
- package/dist/oauth2/index.d.ts +100 -0
- package/dist/oauth2/index.mjs +357 -0
- package/dist/shared/core.BJPBStdk.d.ts +1693 -0
- package/dist/shared/core.Bl6TpxyD.d.mts +181 -0
- package/dist/shared/core.Bqe5IGAi.d.ts +13 -0
- package/dist/shared/core.BwoNUcJQ.d.cts +53 -0
- package/dist/shared/core.BwoNUcJQ.d.mts +53 -0
- package/dist/shared/core.BwoNUcJQ.d.ts +53 -0
- package/dist/shared/core.CajxAutx.d.cts +143 -0
- package/dist/shared/core.CajxAutx.d.mts +143 -0
- package/dist/shared/core.CajxAutx.d.ts +143 -0
- package/dist/shared/core.CkkLHQWc.d.mts +1693 -0
- package/dist/shared/core.DkdZ1o38.d.ts +181 -0
- package/dist/shared/core.Dl-70uns.d.cts +84 -0
- package/dist/shared/core.Dl-70uns.d.mts +84 -0
- package/dist/shared/core.Dl-70uns.d.ts +84 -0
- package/dist/shared/core.DyEdx0m7.d.cts +181 -0
- package/dist/shared/core.E9DfzGLz.d.mts +13 -0
- package/dist/shared/core.HqYn20Fi.d.cts +13 -0
- package/dist/shared/core.gYIBmdi1.d.cts +1693 -0
- package/dist/social-providers/index.cjs +2793 -0
- package/dist/social-providers/index.d.cts +3903 -0
- package/dist/social-providers/index.d.mts +3903 -0
- package/dist/social-providers/index.d.ts +3903 -0
- package/dist/social-providers/index.mjs +2743 -0
- package/dist/utils/index.cjs +7 -0
- package/dist/utils/index.d.cts +10 -0
- package/dist/utils/index.d.mts +10 -0
- package/dist/utils/index.d.ts +10 -0
- package/dist/utils/index.mjs +5 -0
- package/package.json +109 -2
- package/src/db/adapter/index.ts +448 -0
- package/src/db/index.ts +13 -0
- package/src/db/plugin.ts +11 -0
- package/src/db/schema/account.ts +34 -0
- package/src/db/schema/rate-limit.ts +21 -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 +50 -0
- package/src/env/color-depth.ts +172 -0
- package/src/env/env-impl.ts +123 -0
- package/src/env/index.ts +23 -0
- package/src/env/logger.test.ts +33 -0
- package/src/env/logger.ts +145 -0
- package/src/error/codes.ts +31 -0
- package/src/error/index.ts +11 -0
- package/src/index.ts +1 -1
- package/src/middleware/index.ts +33 -0
- package/src/oauth2/client-credentials-token.ts +102 -0
- package/src/oauth2/create-authorization-url.ts +85 -0
- package/src/oauth2/index.ts +22 -0
- package/src/oauth2/oauth-provider.ts +194 -0
- package/src/oauth2/refresh-access-token.ts +124 -0
- package/src/oauth2/utils.ts +36 -0
- package/src/oauth2/validate-authorization-code.ts +156 -0
- package/src/social-providers/apple.ts +213 -0
- package/src/social-providers/atlassian.ts +130 -0
- package/src/social-providers/cognito.ts +269 -0
- package/src/social-providers/discord.ts +172 -0
- package/src/social-providers/dropbox.ts +112 -0
- package/src/social-providers/facebook.ts +204 -0
- package/src/social-providers/figma.ts +115 -0
- package/src/social-providers/github.ts +154 -0
- package/src/social-providers/gitlab.ts +152 -0
- package/src/social-providers/google.ts +171 -0
- package/src/social-providers/huggingface.ts +116 -0
- package/src/social-providers/index.ts +118 -0
- package/src/social-providers/kakao.ts +178 -0
- package/src/social-providers/kick.ts +95 -0
- package/src/social-providers/line.ts +169 -0
- package/src/social-providers/linear.ts +120 -0
- package/src/social-providers/linkedin.ts +110 -0
- package/src/social-providers/microsoft-entra-id.ts +243 -0
- package/src/social-providers/naver.ts +112 -0
- package/src/social-providers/notion.ts +106 -0
- package/src/social-providers/paypal.ts +261 -0
- package/src/social-providers/reddit.ts +122 -0
- package/src/social-providers/roblox.ts +110 -0
- package/src/social-providers/salesforce.ts +157 -0
- package/src/social-providers/slack.ts +114 -0
- package/src/social-providers/spotify.ts +93 -0
- package/src/social-providers/tiktok.ts +211 -0
- package/src/social-providers/twitch.ts +111 -0
- package/src/social-providers/twitter.ts +194 -0
- package/src/social-providers/vk.ts +128 -0
- package/src/social-providers/zoom.ts +218 -0
- package/src/types/context.ts +313 -0
- package/src/types/cookie.ts +7 -0
- package/src/types/helper.ts +5 -0
- package/src/types/index.ts +20 -1
- package/src/types/init-options.ts +1161 -0
- package/src/types/plugin-client.ts +69 -0
- package/src/types/plugin.ts +134 -0
- package/src/utils/error-codes.ts +51 -0
- package/src/utils/index.ts +1 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { L as LiteralString } from './core.CajxAutx.js';
|
|
2
|
+
|
|
3
|
+
interface OAuth2Tokens {
|
|
4
|
+
tokenType?: string;
|
|
5
|
+
accessToken?: string;
|
|
6
|
+
refreshToken?: string;
|
|
7
|
+
accessTokenExpiresAt?: Date;
|
|
8
|
+
refreshTokenExpiresAt?: Date;
|
|
9
|
+
scopes?: string[];
|
|
10
|
+
idToken?: string;
|
|
11
|
+
}
|
|
12
|
+
type OAuth2UserInfo = {
|
|
13
|
+
id: string | number;
|
|
14
|
+
name?: string;
|
|
15
|
+
email?: string | null;
|
|
16
|
+
image?: string;
|
|
17
|
+
emailVerified: boolean;
|
|
18
|
+
};
|
|
19
|
+
interface OAuthProvider<T extends Record<string, any> = Record<string, any>, O extends Record<string, any> = Partial<ProviderOptions>> {
|
|
20
|
+
id: LiteralString;
|
|
21
|
+
createAuthorizationURL: (data: {
|
|
22
|
+
state: string;
|
|
23
|
+
codeVerifier: string;
|
|
24
|
+
scopes?: string[];
|
|
25
|
+
redirectURI: string;
|
|
26
|
+
display?: string;
|
|
27
|
+
loginHint?: string;
|
|
28
|
+
}) => Promise<URL> | URL;
|
|
29
|
+
name: string;
|
|
30
|
+
validateAuthorizationCode: (data: {
|
|
31
|
+
code: string;
|
|
32
|
+
redirectURI: string;
|
|
33
|
+
codeVerifier?: string;
|
|
34
|
+
deviceId?: string;
|
|
35
|
+
}) => Promise<OAuth2Tokens>;
|
|
36
|
+
getUserInfo: (token: OAuth2Tokens & {
|
|
37
|
+
/**
|
|
38
|
+
* The user object from the provider
|
|
39
|
+
* This is only available for some providers like Apple
|
|
40
|
+
*/
|
|
41
|
+
user?: {
|
|
42
|
+
name?: {
|
|
43
|
+
firstName?: string;
|
|
44
|
+
lastName?: string;
|
|
45
|
+
};
|
|
46
|
+
email?: string;
|
|
47
|
+
};
|
|
48
|
+
}) => Promise<{
|
|
49
|
+
user: OAuth2UserInfo;
|
|
50
|
+
data: T;
|
|
51
|
+
} | null>;
|
|
52
|
+
/**
|
|
53
|
+
* Custom function to refresh a token
|
|
54
|
+
*/
|
|
55
|
+
refreshAccessToken?: (refreshToken: string) => Promise<OAuth2Tokens>;
|
|
56
|
+
revokeToken?: (token: string) => Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Verify the id token
|
|
59
|
+
* @param token - The id token
|
|
60
|
+
* @param nonce - The nonce
|
|
61
|
+
* @returns True if the id token is valid, false otherwise
|
|
62
|
+
*/
|
|
63
|
+
verifyIdToken?: (token: string, nonce?: string) => Promise<boolean>;
|
|
64
|
+
/**
|
|
65
|
+
* Disable implicit sign up for new users. When set to true for the provider,
|
|
66
|
+
* sign-in need to be called with with requestSignUp as true to create new users.
|
|
67
|
+
*/
|
|
68
|
+
disableImplicitSignUp?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Disable sign up for new users.
|
|
71
|
+
*/
|
|
72
|
+
disableSignUp?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Options for the provider
|
|
75
|
+
*/
|
|
76
|
+
options?: O;
|
|
77
|
+
}
|
|
78
|
+
type ProviderOptions<Profile extends Record<string, any> = any> = {
|
|
79
|
+
/**
|
|
80
|
+
* The client ID of your application.
|
|
81
|
+
*
|
|
82
|
+
* This is usually a string but can be any type depending on the provider.
|
|
83
|
+
*/
|
|
84
|
+
clientId?: unknown;
|
|
85
|
+
/**
|
|
86
|
+
* The client secret of your application
|
|
87
|
+
*/
|
|
88
|
+
clientSecret?: string;
|
|
89
|
+
/**
|
|
90
|
+
* The scopes you want to request from the provider
|
|
91
|
+
*/
|
|
92
|
+
scope?: string[];
|
|
93
|
+
/**
|
|
94
|
+
* Remove default scopes of the provider
|
|
95
|
+
*/
|
|
96
|
+
disableDefaultScope?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* The redirect URL for your application. This is where the provider will
|
|
99
|
+
* redirect the user after the sign in process. Make sure this URL is
|
|
100
|
+
* whitelisted in the provider's dashboard.
|
|
101
|
+
*/
|
|
102
|
+
redirectURI?: string;
|
|
103
|
+
/**
|
|
104
|
+
* The client key of your application
|
|
105
|
+
* Tiktok Social Provider uses this field instead of clientId
|
|
106
|
+
*/
|
|
107
|
+
clientKey?: string;
|
|
108
|
+
/**
|
|
109
|
+
* Disable provider from allowing users to sign in
|
|
110
|
+
* with this provider with an id token sent from the
|
|
111
|
+
* client.
|
|
112
|
+
*/
|
|
113
|
+
disableIdTokenSignIn?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* verifyIdToken function to verify the id token
|
|
116
|
+
*/
|
|
117
|
+
verifyIdToken?: (token: string, nonce?: string) => Promise<boolean>;
|
|
118
|
+
/**
|
|
119
|
+
* Custom function to get user info from the provider
|
|
120
|
+
*/
|
|
121
|
+
getUserInfo?: (token: OAuth2Tokens) => Promise<{
|
|
122
|
+
user: {
|
|
123
|
+
id: string;
|
|
124
|
+
name?: string;
|
|
125
|
+
email?: string | null;
|
|
126
|
+
image?: string;
|
|
127
|
+
emailVerified: boolean;
|
|
128
|
+
[key: string]: any;
|
|
129
|
+
};
|
|
130
|
+
data: any;
|
|
131
|
+
}>;
|
|
132
|
+
/**
|
|
133
|
+
* Custom function to refresh a token
|
|
134
|
+
*/
|
|
135
|
+
refreshAccessToken?: (refreshToken: string) => Promise<OAuth2Tokens>;
|
|
136
|
+
/**
|
|
137
|
+
* Custom function to map the provider profile to a
|
|
138
|
+
* user.
|
|
139
|
+
*/
|
|
140
|
+
mapProfileToUser?: (profile: Profile) => {
|
|
141
|
+
id?: string;
|
|
142
|
+
name?: string;
|
|
143
|
+
email?: string | null;
|
|
144
|
+
image?: string;
|
|
145
|
+
emailVerified?: boolean;
|
|
146
|
+
[key: string]: any;
|
|
147
|
+
} | Promise<{
|
|
148
|
+
id?: string;
|
|
149
|
+
name?: string;
|
|
150
|
+
email?: string | null;
|
|
151
|
+
image?: string;
|
|
152
|
+
emailVerified?: boolean;
|
|
153
|
+
[key: string]: any;
|
|
154
|
+
}>;
|
|
155
|
+
/**
|
|
156
|
+
* Disable implicit sign up for new users. When set to true for the provider,
|
|
157
|
+
* sign-in need to be called with with requestSignUp as true to create new users.
|
|
158
|
+
*/
|
|
159
|
+
disableImplicitSignUp?: boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Disable sign up for new users.
|
|
162
|
+
*/
|
|
163
|
+
disableSignUp?: boolean;
|
|
164
|
+
/**
|
|
165
|
+
* The prompt to use for the authorization code request
|
|
166
|
+
*/
|
|
167
|
+
prompt?: "select_account" | "consent" | "login" | "none" | "select_account consent";
|
|
168
|
+
/**
|
|
169
|
+
* The response mode to use for the authorization code request
|
|
170
|
+
*/
|
|
171
|
+
responseMode?: "query" | "form_post";
|
|
172
|
+
/**
|
|
173
|
+
* If enabled, the user info will be overridden with the provider user info
|
|
174
|
+
* This is useful if you want to use the provider user info to update the user info
|
|
175
|
+
*
|
|
176
|
+
* @default false
|
|
177
|
+
*/
|
|
178
|
+
overrideUserInfoOnSignIn?: boolean;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
export type { OAuth2Tokens as O, ProviderOptions as P, OAuthProvider as a, OAuth2UserInfo as b };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const userSchema: z.ZodObject<{
|
|
4
|
+
id: z.ZodString;
|
|
5
|
+
createdAt: z.ZodDefault<z.ZodDate>;
|
|
6
|
+
updatedAt: z.ZodDefault<z.ZodDate>;
|
|
7
|
+
email: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
8
|
+
emailVerified: z.ZodDefault<z.ZodBoolean>;
|
|
9
|
+
name: z.ZodString;
|
|
10
|
+
image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
/**
|
|
13
|
+
* User schema type used by better-auth, note that it's possible that user could have additional fields
|
|
14
|
+
*
|
|
15
|
+
* todo: we should use generics to extend this type with additional fields from plugins and options in the future
|
|
16
|
+
*/
|
|
17
|
+
type User = z.infer<typeof userSchema>;
|
|
18
|
+
|
|
19
|
+
declare const accountSchema: z.ZodObject<{
|
|
20
|
+
id: z.ZodString;
|
|
21
|
+
createdAt: z.ZodDefault<z.ZodDate>;
|
|
22
|
+
updatedAt: z.ZodDefault<z.ZodDate>;
|
|
23
|
+
providerId: z.ZodString;
|
|
24
|
+
accountId: z.ZodString;
|
|
25
|
+
userId: z.ZodCoercedString<unknown>;
|
|
26
|
+
accessToken: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
27
|
+
refreshToken: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
28
|
+
idToken: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
29
|
+
accessTokenExpiresAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
30
|
+
refreshTokenExpiresAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
31
|
+
scope: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
32
|
+
password: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
/**
|
|
35
|
+
* Account schema type used by better-auth, note that it's possible that account could have additional fields
|
|
36
|
+
*
|
|
37
|
+
* todo: we should use generics to extend this type with additional fields from plugins and options in the future
|
|
38
|
+
*/
|
|
39
|
+
type Account = z.infer<typeof accountSchema>;
|
|
40
|
+
|
|
41
|
+
declare const sessionSchema: z.ZodObject<{
|
|
42
|
+
id: z.ZodString;
|
|
43
|
+
createdAt: z.ZodDefault<z.ZodDate>;
|
|
44
|
+
updatedAt: z.ZodDefault<z.ZodDate>;
|
|
45
|
+
userId: z.ZodCoercedString<unknown>;
|
|
46
|
+
expiresAt: z.ZodDate;
|
|
47
|
+
token: z.ZodString;
|
|
48
|
+
ipAddress: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
49
|
+
userAgent: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
50
|
+
}, z.core.$strip>;
|
|
51
|
+
/**
|
|
52
|
+
* Session schema type used by better-auth, note that it's possible that session could have additional fields
|
|
53
|
+
*
|
|
54
|
+
* todo: we should use generics to extend this type with additional fields from plugins and options in the future
|
|
55
|
+
*/
|
|
56
|
+
type Session = z.infer<typeof sessionSchema>;
|
|
57
|
+
|
|
58
|
+
declare const verificationSchema: z.ZodObject<{
|
|
59
|
+
id: z.ZodString;
|
|
60
|
+
createdAt: z.ZodDefault<z.ZodDate>;
|
|
61
|
+
updatedAt: z.ZodDefault<z.ZodDate>;
|
|
62
|
+
value: z.ZodString;
|
|
63
|
+
expiresAt: z.ZodDate;
|
|
64
|
+
identifier: z.ZodString;
|
|
65
|
+
}, z.core.$strip>;
|
|
66
|
+
/**
|
|
67
|
+
* Verification schema type used by better-auth, note that it's possible that verification could have additional fields
|
|
68
|
+
*
|
|
69
|
+
* todo: we should use generics to extend this type with additional fields from plugins and options in the future
|
|
70
|
+
*/
|
|
71
|
+
type Verification = z.infer<typeof verificationSchema>;
|
|
72
|
+
|
|
73
|
+
declare const rateLimitSchema: z.ZodObject<{
|
|
74
|
+
key: z.ZodString;
|
|
75
|
+
count: z.ZodNumber;
|
|
76
|
+
lastRequest: z.ZodNumber;
|
|
77
|
+
}, z.core.$strip>;
|
|
78
|
+
/**
|
|
79
|
+
* Rate limit schema type used by better-auth for rate limiting
|
|
80
|
+
*/
|
|
81
|
+
type RateLimit = z.infer<typeof rateLimitSchema>;
|
|
82
|
+
|
|
83
|
+
export { accountSchema as a, rateLimitSchema as r, sessionSchema as s, userSchema as u, verificationSchema as v };
|
|
84
|
+
export type { Account as A, RateLimit as R, Session as S, User as U, Verification as V };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const userSchema: z.ZodObject<{
|
|
4
|
+
id: z.ZodString;
|
|
5
|
+
createdAt: z.ZodDefault<z.ZodDate>;
|
|
6
|
+
updatedAt: z.ZodDefault<z.ZodDate>;
|
|
7
|
+
email: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
8
|
+
emailVerified: z.ZodDefault<z.ZodBoolean>;
|
|
9
|
+
name: z.ZodString;
|
|
10
|
+
image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
/**
|
|
13
|
+
* User schema type used by better-auth, note that it's possible that user could have additional fields
|
|
14
|
+
*
|
|
15
|
+
* todo: we should use generics to extend this type with additional fields from plugins and options in the future
|
|
16
|
+
*/
|
|
17
|
+
type User = z.infer<typeof userSchema>;
|
|
18
|
+
|
|
19
|
+
declare const accountSchema: z.ZodObject<{
|
|
20
|
+
id: z.ZodString;
|
|
21
|
+
createdAt: z.ZodDefault<z.ZodDate>;
|
|
22
|
+
updatedAt: z.ZodDefault<z.ZodDate>;
|
|
23
|
+
providerId: z.ZodString;
|
|
24
|
+
accountId: z.ZodString;
|
|
25
|
+
userId: z.ZodCoercedString<unknown>;
|
|
26
|
+
accessToken: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
27
|
+
refreshToken: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
28
|
+
idToken: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
29
|
+
accessTokenExpiresAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
30
|
+
refreshTokenExpiresAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
31
|
+
scope: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
32
|
+
password: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
/**
|
|
35
|
+
* Account schema type used by better-auth, note that it's possible that account could have additional fields
|
|
36
|
+
*
|
|
37
|
+
* todo: we should use generics to extend this type with additional fields from plugins and options in the future
|
|
38
|
+
*/
|
|
39
|
+
type Account = z.infer<typeof accountSchema>;
|
|
40
|
+
|
|
41
|
+
declare const sessionSchema: z.ZodObject<{
|
|
42
|
+
id: z.ZodString;
|
|
43
|
+
createdAt: z.ZodDefault<z.ZodDate>;
|
|
44
|
+
updatedAt: z.ZodDefault<z.ZodDate>;
|
|
45
|
+
userId: z.ZodCoercedString<unknown>;
|
|
46
|
+
expiresAt: z.ZodDate;
|
|
47
|
+
token: z.ZodString;
|
|
48
|
+
ipAddress: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
49
|
+
userAgent: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
50
|
+
}, z.core.$strip>;
|
|
51
|
+
/**
|
|
52
|
+
* Session schema type used by better-auth, note that it's possible that session could have additional fields
|
|
53
|
+
*
|
|
54
|
+
* todo: we should use generics to extend this type with additional fields from plugins and options in the future
|
|
55
|
+
*/
|
|
56
|
+
type Session = z.infer<typeof sessionSchema>;
|
|
57
|
+
|
|
58
|
+
declare const verificationSchema: z.ZodObject<{
|
|
59
|
+
id: z.ZodString;
|
|
60
|
+
createdAt: z.ZodDefault<z.ZodDate>;
|
|
61
|
+
updatedAt: z.ZodDefault<z.ZodDate>;
|
|
62
|
+
value: z.ZodString;
|
|
63
|
+
expiresAt: z.ZodDate;
|
|
64
|
+
identifier: z.ZodString;
|
|
65
|
+
}, z.core.$strip>;
|
|
66
|
+
/**
|
|
67
|
+
* Verification schema type used by better-auth, note that it's possible that verification could have additional fields
|
|
68
|
+
*
|
|
69
|
+
* todo: we should use generics to extend this type with additional fields from plugins and options in the future
|
|
70
|
+
*/
|
|
71
|
+
type Verification = z.infer<typeof verificationSchema>;
|
|
72
|
+
|
|
73
|
+
declare const rateLimitSchema: z.ZodObject<{
|
|
74
|
+
key: z.ZodString;
|
|
75
|
+
count: z.ZodNumber;
|
|
76
|
+
lastRequest: z.ZodNumber;
|
|
77
|
+
}, z.core.$strip>;
|
|
78
|
+
/**
|
|
79
|
+
* Rate limit schema type used by better-auth for rate limiting
|
|
80
|
+
*/
|
|
81
|
+
type RateLimit = z.infer<typeof rateLimitSchema>;
|
|
82
|
+
|
|
83
|
+
export { accountSchema as a, rateLimitSchema as r, sessionSchema as s, userSchema as u, verificationSchema as v };
|
|
84
|
+
export type { Account as A, RateLimit as R, Session as S, User as U, Verification as V };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const userSchema: z.ZodObject<{
|
|
4
|
+
id: z.ZodString;
|
|
5
|
+
createdAt: z.ZodDefault<z.ZodDate>;
|
|
6
|
+
updatedAt: z.ZodDefault<z.ZodDate>;
|
|
7
|
+
email: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
8
|
+
emailVerified: z.ZodDefault<z.ZodBoolean>;
|
|
9
|
+
name: z.ZodString;
|
|
10
|
+
image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
/**
|
|
13
|
+
* User schema type used by better-auth, note that it's possible that user could have additional fields
|
|
14
|
+
*
|
|
15
|
+
* todo: we should use generics to extend this type with additional fields from plugins and options in the future
|
|
16
|
+
*/
|
|
17
|
+
type User = z.infer<typeof userSchema>;
|
|
18
|
+
|
|
19
|
+
declare const accountSchema: z.ZodObject<{
|
|
20
|
+
id: z.ZodString;
|
|
21
|
+
createdAt: z.ZodDefault<z.ZodDate>;
|
|
22
|
+
updatedAt: z.ZodDefault<z.ZodDate>;
|
|
23
|
+
providerId: z.ZodString;
|
|
24
|
+
accountId: z.ZodString;
|
|
25
|
+
userId: z.ZodCoercedString<unknown>;
|
|
26
|
+
accessToken: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
27
|
+
refreshToken: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
28
|
+
idToken: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
29
|
+
accessTokenExpiresAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
30
|
+
refreshTokenExpiresAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
31
|
+
scope: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
32
|
+
password: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
/**
|
|
35
|
+
* Account schema type used by better-auth, note that it's possible that account could have additional fields
|
|
36
|
+
*
|
|
37
|
+
* todo: we should use generics to extend this type with additional fields from plugins and options in the future
|
|
38
|
+
*/
|
|
39
|
+
type Account = z.infer<typeof accountSchema>;
|
|
40
|
+
|
|
41
|
+
declare const sessionSchema: z.ZodObject<{
|
|
42
|
+
id: z.ZodString;
|
|
43
|
+
createdAt: z.ZodDefault<z.ZodDate>;
|
|
44
|
+
updatedAt: z.ZodDefault<z.ZodDate>;
|
|
45
|
+
userId: z.ZodCoercedString<unknown>;
|
|
46
|
+
expiresAt: z.ZodDate;
|
|
47
|
+
token: z.ZodString;
|
|
48
|
+
ipAddress: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
49
|
+
userAgent: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
50
|
+
}, z.core.$strip>;
|
|
51
|
+
/**
|
|
52
|
+
* Session schema type used by better-auth, note that it's possible that session could have additional fields
|
|
53
|
+
*
|
|
54
|
+
* todo: we should use generics to extend this type with additional fields from plugins and options in the future
|
|
55
|
+
*/
|
|
56
|
+
type Session = z.infer<typeof sessionSchema>;
|
|
57
|
+
|
|
58
|
+
declare const verificationSchema: z.ZodObject<{
|
|
59
|
+
id: z.ZodString;
|
|
60
|
+
createdAt: z.ZodDefault<z.ZodDate>;
|
|
61
|
+
updatedAt: z.ZodDefault<z.ZodDate>;
|
|
62
|
+
value: z.ZodString;
|
|
63
|
+
expiresAt: z.ZodDate;
|
|
64
|
+
identifier: z.ZodString;
|
|
65
|
+
}, z.core.$strip>;
|
|
66
|
+
/**
|
|
67
|
+
* Verification schema type used by better-auth, note that it's possible that verification could have additional fields
|
|
68
|
+
*
|
|
69
|
+
* todo: we should use generics to extend this type with additional fields from plugins and options in the future
|
|
70
|
+
*/
|
|
71
|
+
type Verification = z.infer<typeof verificationSchema>;
|
|
72
|
+
|
|
73
|
+
declare const rateLimitSchema: z.ZodObject<{
|
|
74
|
+
key: z.ZodString;
|
|
75
|
+
count: z.ZodNumber;
|
|
76
|
+
lastRequest: z.ZodNumber;
|
|
77
|
+
}, z.core.$strip>;
|
|
78
|
+
/**
|
|
79
|
+
* Rate limit schema type used by better-auth for rate limiting
|
|
80
|
+
*/
|
|
81
|
+
type RateLimit = z.infer<typeof rateLimitSchema>;
|
|
82
|
+
|
|
83
|
+
export { accountSchema as a, rateLimitSchema as r, sessionSchema as s, userSchema as u, verificationSchema as v };
|
|
84
|
+
export type { Account as A, RateLimit as R, Session as S, User as U, Verification as V };
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { L as LiteralString } from './core.CajxAutx.cjs';
|
|
2
|
+
|
|
3
|
+
interface OAuth2Tokens {
|
|
4
|
+
tokenType?: string;
|
|
5
|
+
accessToken?: string;
|
|
6
|
+
refreshToken?: string;
|
|
7
|
+
accessTokenExpiresAt?: Date;
|
|
8
|
+
refreshTokenExpiresAt?: Date;
|
|
9
|
+
scopes?: string[];
|
|
10
|
+
idToken?: string;
|
|
11
|
+
}
|
|
12
|
+
type OAuth2UserInfo = {
|
|
13
|
+
id: string | number;
|
|
14
|
+
name?: string;
|
|
15
|
+
email?: string | null;
|
|
16
|
+
image?: string;
|
|
17
|
+
emailVerified: boolean;
|
|
18
|
+
};
|
|
19
|
+
interface OAuthProvider<T extends Record<string, any> = Record<string, any>, O extends Record<string, any> = Partial<ProviderOptions>> {
|
|
20
|
+
id: LiteralString;
|
|
21
|
+
createAuthorizationURL: (data: {
|
|
22
|
+
state: string;
|
|
23
|
+
codeVerifier: string;
|
|
24
|
+
scopes?: string[];
|
|
25
|
+
redirectURI: string;
|
|
26
|
+
display?: string;
|
|
27
|
+
loginHint?: string;
|
|
28
|
+
}) => Promise<URL> | URL;
|
|
29
|
+
name: string;
|
|
30
|
+
validateAuthorizationCode: (data: {
|
|
31
|
+
code: string;
|
|
32
|
+
redirectURI: string;
|
|
33
|
+
codeVerifier?: string;
|
|
34
|
+
deviceId?: string;
|
|
35
|
+
}) => Promise<OAuth2Tokens>;
|
|
36
|
+
getUserInfo: (token: OAuth2Tokens & {
|
|
37
|
+
/**
|
|
38
|
+
* The user object from the provider
|
|
39
|
+
* This is only available for some providers like Apple
|
|
40
|
+
*/
|
|
41
|
+
user?: {
|
|
42
|
+
name?: {
|
|
43
|
+
firstName?: string;
|
|
44
|
+
lastName?: string;
|
|
45
|
+
};
|
|
46
|
+
email?: string;
|
|
47
|
+
};
|
|
48
|
+
}) => Promise<{
|
|
49
|
+
user: OAuth2UserInfo;
|
|
50
|
+
data: T;
|
|
51
|
+
} | null>;
|
|
52
|
+
/**
|
|
53
|
+
* Custom function to refresh a token
|
|
54
|
+
*/
|
|
55
|
+
refreshAccessToken?: (refreshToken: string) => Promise<OAuth2Tokens>;
|
|
56
|
+
revokeToken?: (token: string) => Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Verify the id token
|
|
59
|
+
* @param token - The id token
|
|
60
|
+
* @param nonce - The nonce
|
|
61
|
+
* @returns True if the id token is valid, false otherwise
|
|
62
|
+
*/
|
|
63
|
+
verifyIdToken?: (token: string, nonce?: string) => Promise<boolean>;
|
|
64
|
+
/**
|
|
65
|
+
* Disable implicit sign up for new users. When set to true for the provider,
|
|
66
|
+
* sign-in need to be called with with requestSignUp as true to create new users.
|
|
67
|
+
*/
|
|
68
|
+
disableImplicitSignUp?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Disable sign up for new users.
|
|
71
|
+
*/
|
|
72
|
+
disableSignUp?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Options for the provider
|
|
75
|
+
*/
|
|
76
|
+
options?: O;
|
|
77
|
+
}
|
|
78
|
+
type ProviderOptions<Profile extends Record<string, any> = any> = {
|
|
79
|
+
/**
|
|
80
|
+
* The client ID of your application.
|
|
81
|
+
*
|
|
82
|
+
* This is usually a string but can be any type depending on the provider.
|
|
83
|
+
*/
|
|
84
|
+
clientId?: unknown;
|
|
85
|
+
/**
|
|
86
|
+
* The client secret of your application
|
|
87
|
+
*/
|
|
88
|
+
clientSecret?: string;
|
|
89
|
+
/**
|
|
90
|
+
* The scopes you want to request from the provider
|
|
91
|
+
*/
|
|
92
|
+
scope?: string[];
|
|
93
|
+
/**
|
|
94
|
+
* Remove default scopes of the provider
|
|
95
|
+
*/
|
|
96
|
+
disableDefaultScope?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* The redirect URL for your application. This is where the provider will
|
|
99
|
+
* redirect the user after the sign in process. Make sure this URL is
|
|
100
|
+
* whitelisted in the provider's dashboard.
|
|
101
|
+
*/
|
|
102
|
+
redirectURI?: string;
|
|
103
|
+
/**
|
|
104
|
+
* The client key of your application
|
|
105
|
+
* Tiktok Social Provider uses this field instead of clientId
|
|
106
|
+
*/
|
|
107
|
+
clientKey?: string;
|
|
108
|
+
/**
|
|
109
|
+
* Disable provider from allowing users to sign in
|
|
110
|
+
* with this provider with an id token sent from the
|
|
111
|
+
* client.
|
|
112
|
+
*/
|
|
113
|
+
disableIdTokenSignIn?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* verifyIdToken function to verify the id token
|
|
116
|
+
*/
|
|
117
|
+
verifyIdToken?: (token: string, nonce?: string) => Promise<boolean>;
|
|
118
|
+
/**
|
|
119
|
+
* Custom function to get user info from the provider
|
|
120
|
+
*/
|
|
121
|
+
getUserInfo?: (token: OAuth2Tokens) => Promise<{
|
|
122
|
+
user: {
|
|
123
|
+
id: string;
|
|
124
|
+
name?: string;
|
|
125
|
+
email?: string | null;
|
|
126
|
+
image?: string;
|
|
127
|
+
emailVerified: boolean;
|
|
128
|
+
[key: string]: any;
|
|
129
|
+
};
|
|
130
|
+
data: any;
|
|
131
|
+
}>;
|
|
132
|
+
/**
|
|
133
|
+
* Custom function to refresh a token
|
|
134
|
+
*/
|
|
135
|
+
refreshAccessToken?: (refreshToken: string) => Promise<OAuth2Tokens>;
|
|
136
|
+
/**
|
|
137
|
+
* Custom function to map the provider profile to a
|
|
138
|
+
* user.
|
|
139
|
+
*/
|
|
140
|
+
mapProfileToUser?: (profile: Profile) => {
|
|
141
|
+
id?: string;
|
|
142
|
+
name?: string;
|
|
143
|
+
email?: string | null;
|
|
144
|
+
image?: string;
|
|
145
|
+
emailVerified?: boolean;
|
|
146
|
+
[key: string]: any;
|
|
147
|
+
} | Promise<{
|
|
148
|
+
id?: string;
|
|
149
|
+
name?: string;
|
|
150
|
+
email?: string | null;
|
|
151
|
+
image?: string;
|
|
152
|
+
emailVerified?: boolean;
|
|
153
|
+
[key: string]: any;
|
|
154
|
+
}>;
|
|
155
|
+
/**
|
|
156
|
+
* Disable implicit sign up for new users. When set to true for the provider,
|
|
157
|
+
* sign-in need to be called with with requestSignUp as true to create new users.
|
|
158
|
+
*/
|
|
159
|
+
disableImplicitSignUp?: boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Disable sign up for new users.
|
|
162
|
+
*/
|
|
163
|
+
disableSignUp?: boolean;
|
|
164
|
+
/**
|
|
165
|
+
* The prompt to use for the authorization code request
|
|
166
|
+
*/
|
|
167
|
+
prompt?: "select_account" | "consent" | "login" | "none" | "select_account consent";
|
|
168
|
+
/**
|
|
169
|
+
* The response mode to use for the authorization code request
|
|
170
|
+
*/
|
|
171
|
+
responseMode?: "query" | "form_post";
|
|
172
|
+
/**
|
|
173
|
+
* If enabled, the user info will be overridden with the provider user info
|
|
174
|
+
* This is useful if you want to use the provider user info to update the user info
|
|
175
|
+
*
|
|
176
|
+
* @default false
|
|
177
|
+
*/
|
|
178
|
+
overrideUserInfoOnSignIn?: boolean;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
export type { OAuth2Tokens as O, ProviderOptions as P, OAuthProvider as a, OAuth2UserInfo as b };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { D as DBFieldAttribute } from './core.CajxAutx.mjs';
|
|
2
|
+
|
|
3
|
+
type BetterAuthPluginDBSchema = {
|
|
4
|
+
[table in string]: {
|
|
5
|
+
fields: {
|
|
6
|
+
[field in string]: DBFieldAttribute;
|
|
7
|
+
};
|
|
8
|
+
disableMigration?: boolean;
|
|
9
|
+
modelName?: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type { BetterAuthPluginDBSchema as B };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { D as DBFieldAttribute } from './core.CajxAutx.cjs';
|
|
2
|
+
|
|
3
|
+
type BetterAuthPluginDBSchema = {
|
|
4
|
+
[table in string]: {
|
|
5
|
+
fields: {
|
|
6
|
+
[field in string]: DBFieldAttribute;
|
|
7
|
+
};
|
|
8
|
+
disableMigration?: boolean;
|
|
9
|
+
modelName?: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type { BetterAuthPluginDBSchema as B };
|