@astralarium/repo-auth 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/README.md +59 -2
- package/dist/client.d.ts +2173 -0
- package/dist/client.js +203 -0
- package/dist/dev-sign-in/client.d.ts +21 -0
- package/dist/dev-sign-in/client.js +17 -0
- package/dist/dev-sign-in/endpoint.d.ts +2 -0
- package/dist/dev-sign-in/endpoint.js +2 -0
- package/dist/dev-sign-in/index.d.ts +4 -0
- package/dist/dev-sign-in/index.js +4 -0
- package/dist/dev-sign-in/provider-user.d.ts +30 -0
- package/dist/dev-sign-in/provider-user.js +55 -0
- package/dist/dev-sign-in/sign-in.d.ts +62 -0
- package/dist/dev-sign-in/sign-in.js +116 -0
- package/dist/index.server.d.ts +645 -0
- package/dist/index.server.js +307 -0
- package/dist/providers/google.d.ts +8 -0
- package/dist/providers/google.js +11 -0
- package/dist/providers/index.d.ts +3 -0
- package/dist/providers/index.js +3 -0
- package/dist/providers/provider.d.ts +135 -0
- package/dist/providers/provider.js +86 -0
- package/dist/request.d.ts +42 -0
- package/dist/request.js +75 -0
- package/dist/schema.d.ts +6 -0
- package/dist/schema.js +23 -0
- package/dist/start/index.d.ts +6 -0
- package/dist/start/index.js +6 -0
- package/dist/start/index.server.d.ts +28 -0
- package/dist/start/index.server.js +29 -0
- package/dist/start/middleware.d.ts +33 -0
- package/dist/start/middleware.js +70 -0
- package/dist/start/return-path.d.ts +16 -0
- package/dist/start/return-path.js +32 -0
- package/dist/start/viewer.d.ts +8 -0
- package/dist/start/viewer.js +15 -0
- package/dist/testkit/index.d.ts +131 -0
- package/dist/testkit/index.js +238 -0
- package/dist/testkit/json-post.d.ts +8 -0
- package/dist/testkit/json-post.js +12 -0
- package/dist/testkit/oidc.d.ts +35 -0
- package/dist/testkit/oidc.js +154 -0
- package/dist/testkit/suites.d.ts +126 -0
- package/dist/testkit/suites.js +255 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.js +1 -0
- package/package.json +86 -3
- package/sql/jobs/schema.sql +19 -0
- package/sql/schema.sql +97 -0
- package/sql/scrub.sql +6 -0
|
@@ -0,0 +1,645 @@
|
|
|
1
|
+
import { type BetterAuthOptions, type BetterAuthPlugin, type Session, type User } from "better-auth";
|
|
2
|
+
import { type Dialect } from "kysely";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import type { DevProviderSignIn } from "./dev-sign-in/sign-in.ts";
|
|
5
|
+
import type { AuthProviderCredentials, AuthProviders } from "./providers/provider.ts";
|
|
6
|
+
import type { SessionLike } from "./types.ts";
|
|
7
|
+
/** `auth.users` columns beside better-auth's core fields. */
|
|
8
|
+
export type AdditionalFields = NonNullable<NonNullable<BetterAuthOptions["user"]>["additionalFields"]>;
|
|
9
|
+
/** App identity and schema; stable across requests. */
|
|
10
|
+
export interface ShellAuthApp<Fields extends AdditionalFields, Projected extends SessionLike> {
|
|
11
|
+
/** Shown on consent screens and in emails. */
|
|
12
|
+
appName: string;
|
|
13
|
+
/** `auth.users` columns beside the core fields, as better-auth field
|
|
14
|
+
* attributes keyed by column. */
|
|
15
|
+
additionalFields: Fields;
|
|
16
|
+
/** Browser-visible session: the `get-session` response and client store. */
|
|
17
|
+
projectSession: (session: ShellSession<Fields>) => Projected;
|
|
18
|
+
/** Session lifetime and refresh age in seconds; better-auth's defaults
|
|
19
|
+
* when omitted. */
|
|
20
|
+
session?: Pick<NonNullable<BetterAuthOptions["session"]>, "expiresIn" | "updateAge">;
|
|
21
|
+
/** OAuth sign-in providers (`defineAuthProviders`); each turns on with
|
|
22
|
+
* its deployment's credentials. */
|
|
23
|
+
providers?: AuthProviders;
|
|
24
|
+
/** Signed-in users link more provider accounts (`/link-social`). */
|
|
25
|
+
linkSocial?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Dev sign-in as any account of a provider (`devProviderSignIn`): `POST
|
|
28
|
+
* /api/auth/dev/sign-in` grants a session for any account id to any
|
|
29
|
+
* caller reaching the server; its trusted-origin `Origin` check is the
|
|
30
|
+
* one gate. Build it under the dev build flag alone
|
|
31
|
+
* (`import.meta.env.DEV`), which drops it from production bundles;
|
|
32
|
+
* `testProductionAuth` proves the production build serves no dev
|
|
33
|
+
* sign-in.
|
|
34
|
+
*/
|
|
35
|
+
devSignIn?: DevProviderSignIn;
|
|
36
|
+
/** Page OAuth failures redirect to, with `error` and `error_description`
|
|
37
|
+
* query params. */
|
|
38
|
+
errorURL: string;
|
|
39
|
+
/** Account options beside the table mapping, e.g. `accountLinking`. */
|
|
40
|
+
account?: Omit<NonNullable<BetterAuthOptions["account"]>, "modelName" | "fields">;
|
|
41
|
+
/** better-auth hooks around `auth.*` row creates, updates, and deletes. */
|
|
42
|
+
databaseHooks?: BetterAuthOptions["databaseHooks"];
|
|
43
|
+
}
|
|
44
|
+
/** `shellAuth`'s config: the app plus its deployment's origin, secret, and
|
|
45
|
+
* provider credentials. */
|
|
46
|
+
export interface ShellAuthConfig<Fields extends AdditionalFields, Projected extends SessionLike> extends ShellAuthApp<Fields, Projected> {
|
|
47
|
+
/** Public origin, or per-request origins constrained to allowed hosts. */
|
|
48
|
+
baseURL: NonNullable<BetterAuthOptions["baseURL"]>;
|
|
49
|
+
/** Signing secret from `configure`'s `env`, so the instance depends on
|
|
50
|
+
* that object alone; required over better-auth's `BETTER_AUTH_SECRET`
|
|
51
|
+
* process-env fallback. */
|
|
52
|
+
secret: string;
|
|
53
|
+
/** Credentials of `providers` (`providers.credentials(env)`); a provider
|
|
54
|
+
* without them stays off. */
|
|
55
|
+
credentials?: AuthProviderCredentials;
|
|
56
|
+
/** better-auth plugins after the session projection and provider
|
|
57
|
+
* plugins. */
|
|
58
|
+
plugins?: BetterAuthPlugin[];
|
|
59
|
+
}
|
|
60
|
+
/** The app's auth declaration, validated; infers `Fields` and
|
|
61
|
+
* `Projected` from the literal. Throws `ExpectedError` naming each
|
|
62
|
+
* invalid value. */
|
|
63
|
+
export declare function defineShellAuthApp<const Fields extends AdditionalFields, Projected extends SessionLike>(app: ShellAuthApp<Fields, Projected>): ShellAuthApp<Fields, Projected>;
|
|
64
|
+
/** `auth.*` table mapping and the app's user columns. */
|
|
65
|
+
declare function schemaOptions<Fields extends AdditionalFields>({ appName, additionalFields, session, account, databaseHooks, }: ShellAuthApp<Fields, SessionLike>): {
|
|
66
|
+
appName: string;
|
|
67
|
+
advanced: {
|
|
68
|
+
disableOriginCheck: false;
|
|
69
|
+
database: {
|
|
70
|
+
generateId: false;
|
|
71
|
+
validateSchema: false;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
rateLimit: {
|
|
75
|
+
enabled: false;
|
|
76
|
+
};
|
|
77
|
+
databaseHooks: {
|
|
78
|
+
user?: {
|
|
79
|
+
create?: {
|
|
80
|
+
before?: (user: User & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<boolean | void | {
|
|
81
|
+
data: {
|
|
82
|
+
id?: string | undefined;
|
|
83
|
+
createdAt?: Date | undefined;
|
|
84
|
+
updatedAt?: Date | undefined;
|
|
85
|
+
email?: string | undefined;
|
|
86
|
+
emailVerified?: boolean | undefined;
|
|
87
|
+
name?: string | undefined;
|
|
88
|
+
image?: string | null | undefined;
|
|
89
|
+
} & Record<string, any>;
|
|
90
|
+
}>;
|
|
91
|
+
after?: (user: User & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<void>;
|
|
92
|
+
};
|
|
93
|
+
update?: {
|
|
94
|
+
before?: (user: Partial<User> & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<boolean | void | {
|
|
95
|
+
data: {
|
|
96
|
+
[x: string]: any;
|
|
97
|
+
id?: string | undefined;
|
|
98
|
+
createdAt?: Date | undefined;
|
|
99
|
+
updatedAt?: Date | undefined;
|
|
100
|
+
email?: string | undefined;
|
|
101
|
+
emailVerified?: boolean | undefined;
|
|
102
|
+
name?: string | undefined;
|
|
103
|
+
image?: string | null | undefined;
|
|
104
|
+
};
|
|
105
|
+
}>;
|
|
106
|
+
after?: (user: User & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<void>;
|
|
107
|
+
};
|
|
108
|
+
delete?: {
|
|
109
|
+
before?: (user: User & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<boolean | void>;
|
|
110
|
+
after?: (user: User & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<void>;
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
session?: {
|
|
114
|
+
create?: {
|
|
115
|
+
before?: (session: Session & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<boolean | void | {
|
|
116
|
+
data: {
|
|
117
|
+
id?: string | undefined;
|
|
118
|
+
createdAt?: Date | undefined;
|
|
119
|
+
updatedAt?: Date | undefined;
|
|
120
|
+
userId?: string | undefined;
|
|
121
|
+
expiresAt?: Date | undefined;
|
|
122
|
+
token?: string | undefined;
|
|
123
|
+
ipAddress?: string | null | undefined;
|
|
124
|
+
userAgent?: string | null | undefined;
|
|
125
|
+
} & Record<string, any>;
|
|
126
|
+
}>;
|
|
127
|
+
after?: (session: Session & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<void>;
|
|
128
|
+
};
|
|
129
|
+
update?: {
|
|
130
|
+
before?: (session: Partial<Session> & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<boolean | void | {
|
|
131
|
+
data: {
|
|
132
|
+
[x: string]: any;
|
|
133
|
+
id?: string | undefined;
|
|
134
|
+
createdAt?: Date | undefined;
|
|
135
|
+
updatedAt?: Date | undefined;
|
|
136
|
+
userId?: string | undefined;
|
|
137
|
+
expiresAt?: Date | undefined;
|
|
138
|
+
token?: string | undefined;
|
|
139
|
+
ipAddress?: string | null | undefined;
|
|
140
|
+
userAgent?: string | null | undefined;
|
|
141
|
+
};
|
|
142
|
+
}>;
|
|
143
|
+
after?: (session: Session & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<void>;
|
|
144
|
+
};
|
|
145
|
+
delete?: {
|
|
146
|
+
before?: (session: Session & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<boolean | void>;
|
|
147
|
+
after?: (session: Session & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<void>;
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
account?: {
|
|
151
|
+
create?: {
|
|
152
|
+
before?: (account: import("better-auth").Account, context: import("better-auth").GenericEndpointContext | null) => Promise<boolean | void | {
|
|
153
|
+
data: {
|
|
154
|
+
id?: string | undefined;
|
|
155
|
+
createdAt?: Date | undefined;
|
|
156
|
+
updatedAt?: Date | undefined;
|
|
157
|
+
providerId?: string | undefined;
|
|
158
|
+
accountId?: string | undefined;
|
|
159
|
+
userId?: string | undefined;
|
|
160
|
+
accessToken?: string | null | undefined;
|
|
161
|
+
refreshToken?: string | null | undefined;
|
|
162
|
+
idToken?: string | null | undefined;
|
|
163
|
+
accessTokenExpiresAt?: Date | null | undefined;
|
|
164
|
+
refreshTokenExpiresAt?: Date | null | undefined;
|
|
165
|
+
scope?: string | null | undefined;
|
|
166
|
+
password?: string | null | undefined;
|
|
167
|
+
} & Record<string, any>;
|
|
168
|
+
}>;
|
|
169
|
+
after?: (account: import("better-auth").Account, context: import("better-auth").GenericEndpointContext | null) => Promise<void>;
|
|
170
|
+
};
|
|
171
|
+
update?: {
|
|
172
|
+
before?: (account: Partial<import("better-auth").Account> & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<boolean | void | {
|
|
173
|
+
data: {
|
|
174
|
+
[x: string]: any;
|
|
175
|
+
id?: string | undefined;
|
|
176
|
+
createdAt?: Date | undefined;
|
|
177
|
+
updatedAt?: Date | undefined;
|
|
178
|
+
providerId?: string | undefined;
|
|
179
|
+
accountId?: string | undefined;
|
|
180
|
+
userId?: string | undefined;
|
|
181
|
+
accessToken?: string | null | undefined;
|
|
182
|
+
refreshToken?: string | null | undefined;
|
|
183
|
+
idToken?: string | null | undefined;
|
|
184
|
+
accessTokenExpiresAt?: Date | null | undefined;
|
|
185
|
+
refreshTokenExpiresAt?: Date | null | undefined;
|
|
186
|
+
scope?: string | null | undefined;
|
|
187
|
+
password?: string | null | undefined;
|
|
188
|
+
};
|
|
189
|
+
}>;
|
|
190
|
+
after?: (account: import("better-auth").Account & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<void>;
|
|
191
|
+
};
|
|
192
|
+
delete?: {
|
|
193
|
+
before?: (account: import("better-auth").Account & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<boolean | void>;
|
|
194
|
+
after?: (account: import("better-auth").Account & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<void>;
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
verification?: {
|
|
198
|
+
create?: {
|
|
199
|
+
before?: (verification: import("better-auth").Verification & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<boolean | void | {
|
|
200
|
+
data: {
|
|
201
|
+
id?: string | undefined;
|
|
202
|
+
createdAt?: Date | undefined;
|
|
203
|
+
updatedAt?: Date | undefined;
|
|
204
|
+
value?: string | undefined;
|
|
205
|
+
expiresAt?: Date | undefined;
|
|
206
|
+
identifier?: string | undefined;
|
|
207
|
+
} & Record<string, any>;
|
|
208
|
+
}>;
|
|
209
|
+
after?: (verification: import("better-auth").Verification & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<void>;
|
|
210
|
+
};
|
|
211
|
+
update?: {
|
|
212
|
+
before?: (verification: Partial<import("better-auth").Verification> & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<boolean | void | {
|
|
213
|
+
data: {
|
|
214
|
+
[x: string]: any;
|
|
215
|
+
id?: string | undefined;
|
|
216
|
+
createdAt?: Date | undefined;
|
|
217
|
+
updatedAt?: Date | undefined;
|
|
218
|
+
value?: string | undefined;
|
|
219
|
+
expiresAt?: Date | undefined;
|
|
220
|
+
identifier?: string | undefined;
|
|
221
|
+
};
|
|
222
|
+
}>;
|
|
223
|
+
after?: (verification: import("better-auth").Verification & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<void>;
|
|
224
|
+
};
|
|
225
|
+
delete?: {
|
|
226
|
+
before?: (verification: import("better-auth").Verification & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<boolean | void>;
|
|
227
|
+
after?: (verification: import("better-auth").Verification & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<void>;
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
} | undefined;
|
|
231
|
+
session: {
|
|
232
|
+
cookieCache: {
|
|
233
|
+
enabled: true;
|
|
234
|
+
maxAge: number;
|
|
235
|
+
};
|
|
236
|
+
modelName: "auth.session";
|
|
237
|
+
fields: {
|
|
238
|
+
userId: string;
|
|
239
|
+
expiresAt: string;
|
|
240
|
+
ipAddress: string;
|
|
241
|
+
userAgent: string;
|
|
242
|
+
createdAt: string;
|
|
243
|
+
updatedAt: string;
|
|
244
|
+
};
|
|
245
|
+
expiresIn?: number;
|
|
246
|
+
updateAge?: number;
|
|
247
|
+
};
|
|
248
|
+
user: {
|
|
249
|
+
modelName: "auth.users";
|
|
250
|
+
fields: {
|
|
251
|
+
name: string;
|
|
252
|
+
email: string;
|
|
253
|
+
emailVerified: string;
|
|
254
|
+
image: string;
|
|
255
|
+
createdAt: string;
|
|
256
|
+
updatedAt: string;
|
|
257
|
+
};
|
|
258
|
+
additionalFields: Fields;
|
|
259
|
+
};
|
|
260
|
+
account: {
|
|
261
|
+
modelName: "auth.account";
|
|
262
|
+
fields: {
|
|
263
|
+
userId: string;
|
|
264
|
+
providerId: string;
|
|
265
|
+
accountId: string;
|
|
266
|
+
accessToken: string;
|
|
267
|
+
refreshToken: string;
|
|
268
|
+
accessTokenExpiresAt: string;
|
|
269
|
+
refreshTokenExpiresAt: string;
|
|
270
|
+
scope: string;
|
|
271
|
+
idToken: string;
|
|
272
|
+
password: string;
|
|
273
|
+
createdAt: string;
|
|
274
|
+
updatedAt: string;
|
|
275
|
+
};
|
|
276
|
+
additionalFields?: {
|
|
277
|
+
[x: string]: import("better-auth").DBFieldAttribute;
|
|
278
|
+
} | undefined;
|
|
279
|
+
updateAccountOnSignIn?: boolean;
|
|
280
|
+
accountLinking?: {
|
|
281
|
+
enabled?: boolean;
|
|
282
|
+
disableImplicitLinking?: boolean;
|
|
283
|
+
requireLocalEmailVerified?: boolean;
|
|
284
|
+
trustedProviders?: Array<import("better-auth").LiteralUnion<import("better-auth").SocialProviderList[number] | "email-password", string>> | ((request?: Request | undefined) => import("better-auth").Awaitable<Array<import("better-auth").LiteralUnion<import("better-auth").SocialProviderList[number] | "email-password", string>>>);
|
|
285
|
+
allowDifferentEmails?: boolean;
|
|
286
|
+
allowUnlinkingAll?: boolean;
|
|
287
|
+
updateUserInfoOnLink?: boolean;
|
|
288
|
+
};
|
|
289
|
+
encryptOAuthTokens?: boolean;
|
|
290
|
+
skipStateCookieCheck?: boolean;
|
|
291
|
+
storeStateStrategy?: "database" | "cookie";
|
|
292
|
+
storeAccountCookie?: boolean;
|
|
293
|
+
};
|
|
294
|
+
verification: {
|
|
295
|
+
modelName: "auth.verification";
|
|
296
|
+
fields: {
|
|
297
|
+
identifier: string;
|
|
298
|
+
value: string;
|
|
299
|
+
expiresAt: string;
|
|
300
|
+
createdAt: string;
|
|
301
|
+
updatedAt: string;
|
|
302
|
+
};
|
|
303
|
+
};
|
|
304
|
+
};
|
|
305
|
+
type SchemaOptions<Fields extends AdditionalFields> = ReturnType<typeof schemaOptions<Fields>>;
|
|
306
|
+
/** A native session read: the row with the app's user columns. */
|
|
307
|
+
export interface ShellSession<Fields extends AdditionalFields> {
|
|
308
|
+
session: Session<SchemaOptions<Fields>["session"]>;
|
|
309
|
+
user: User<SchemaOptions<Fields>["user"]>;
|
|
310
|
+
}
|
|
311
|
+
/** better-auth for `config` over the running scope's database: the `auth.*`
|
|
312
|
+
* schema, the session projection, the providers' plugins, dev sign-in,
|
|
313
|
+
* then `config.plugins`. */
|
|
314
|
+
declare function buildAuth<Fields extends AdditionalFields, Projected extends SessionLike>(config: ShellAuthConfig<Fields, Projected>): import("better-auth").Auth<{
|
|
315
|
+
baseURL: NonNullable<import("better-auth").BaseURLConfig | undefined>;
|
|
316
|
+
secret: string;
|
|
317
|
+
database: {
|
|
318
|
+
dialect: Dialect;
|
|
319
|
+
type: string;
|
|
320
|
+
transaction: boolean;
|
|
321
|
+
};
|
|
322
|
+
socialProviders: import("better-auth").SocialProviders;
|
|
323
|
+
plugins: [{
|
|
324
|
+
id: "session-projection";
|
|
325
|
+
endpoints: {
|
|
326
|
+
getSession: import("better-auth").StrictEndpoint<"/get-session", {
|
|
327
|
+
metadata: {
|
|
328
|
+
CUSTOM_SESSION: boolean;
|
|
329
|
+
openapi: {
|
|
330
|
+
operationId: string;
|
|
331
|
+
description: string;
|
|
332
|
+
responses: {
|
|
333
|
+
"200": {
|
|
334
|
+
description: string;
|
|
335
|
+
content: {
|
|
336
|
+
"application/json": {
|
|
337
|
+
schema: {
|
|
338
|
+
type: "object";
|
|
339
|
+
properties: {
|
|
340
|
+
session: {
|
|
341
|
+
$ref: string;
|
|
342
|
+
};
|
|
343
|
+
user: {
|
|
344
|
+
$ref: string;
|
|
345
|
+
};
|
|
346
|
+
};
|
|
347
|
+
required: string[];
|
|
348
|
+
};
|
|
349
|
+
};
|
|
350
|
+
};
|
|
351
|
+
};
|
|
352
|
+
};
|
|
353
|
+
};
|
|
354
|
+
};
|
|
355
|
+
method: ("GET" | "POST")[];
|
|
356
|
+
operationId: string;
|
|
357
|
+
query: z.ZodOptional<z.ZodObject<{
|
|
358
|
+
disableCookieCache: z.ZodOptional<z.ZodCoercedBoolean<unknown>>;
|
|
359
|
+
disableRefresh: z.ZodOptional<z.ZodCoercedBoolean<unknown>>;
|
|
360
|
+
}, z.core.$strip>>;
|
|
361
|
+
requireHeaders: true;
|
|
362
|
+
}, Projected | null>;
|
|
363
|
+
};
|
|
364
|
+
$Infer: {
|
|
365
|
+
Session: Projected;
|
|
366
|
+
};
|
|
367
|
+
}, ...(BetterAuthPlugin | {
|
|
368
|
+
id: "dev-provider-sign-in";
|
|
369
|
+
endpoints: {
|
|
370
|
+
devProviderSignIn: import("better-auth").StrictEndpoint<"/dev/sign-in", {
|
|
371
|
+
method: "POST";
|
|
372
|
+
body: z.ZodObject<{
|
|
373
|
+
accountId: z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>;
|
|
374
|
+
}, z.core.$strip>;
|
|
375
|
+
requireRequest: true;
|
|
376
|
+
metadata: {
|
|
377
|
+
allowedMediaTypes: string[];
|
|
378
|
+
};
|
|
379
|
+
}, {
|
|
380
|
+
token: string;
|
|
381
|
+
user: {
|
|
382
|
+
id: string;
|
|
383
|
+
};
|
|
384
|
+
}>;
|
|
385
|
+
};
|
|
386
|
+
})[]];
|
|
387
|
+
onAPIError: {
|
|
388
|
+
errorURL: string;
|
|
389
|
+
};
|
|
390
|
+
appName: string;
|
|
391
|
+
advanced: {
|
|
392
|
+
disableOriginCheck: false;
|
|
393
|
+
database: {
|
|
394
|
+
generateId: false;
|
|
395
|
+
validateSchema: false;
|
|
396
|
+
};
|
|
397
|
+
};
|
|
398
|
+
rateLimit: {
|
|
399
|
+
enabled: false;
|
|
400
|
+
};
|
|
401
|
+
databaseHooks: {
|
|
402
|
+
user?: {
|
|
403
|
+
create?: {
|
|
404
|
+
before?: (user: User & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<boolean | void | {
|
|
405
|
+
data: {
|
|
406
|
+
id?: string | undefined;
|
|
407
|
+
createdAt?: Date | undefined;
|
|
408
|
+
updatedAt?: Date | undefined;
|
|
409
|
+
email?: string | undefined;
|
|
410
|
+
emailVerified?: boolean | undefined;
|
|
411
|
+
name?: string | undefined;
|
|
412
|
+
image?: string | null | undefined;
|
|
413
|
+
} & Record<string, any>;
|
|
414
|
+
}>;
|
|
415
|
+
after?: (user: User & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<void>;
|
|
416
|
+
};
|
|
417
|
+
update?: {
|
|
418
|
+
before?: (user: Partial<User> & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<boolean | void | {
|
|
419
|
+
data: {
|
|
420
|
+
[x: string]: any;
|
|
421
|
+
id?: string | undefined;
|
|
422
|
+
createdAt?: Date | undefined;
|
|
423
|
+
updatedAt?: Date | undefined;
|
|
424
|
+
email?: string | undefined;
|
|
425
|
+
emailVerified?: boolean | undefined;
|
|
426
|
+
name?: string | undefined;
|
|
427
|
+
image?: string | null | undefined;
|
|
428
|
+
};
|
|
429
|
+
}>;
|
|
430
|
+
after?: (user: User & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<void>;
|
|
431
|
+
};
|
|
432
|
+
delete?: {
|
|
433
|
+
before?: (user: User & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<boolean | void>;
|
|
434
|
+
after?: (user: User & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<void>;
|
|
435
|
+
};
|
|
436
|
+
};
|
|
437
|
+
session?: {
|
|
438
|
+
create?: {
|
|
439
|
+
before?: (session: Session & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<boolean | void | {
|
|
440
|
+
data: {
|
|
441
|
+
id?: string | undefined;
|
|
442
|
+
createdAt?: Date | undefined;
|
|
443
|
+
updatedAt?: Date | undefined;
|
|
444
|
+
userId?: string | undefined;
|
|
445
|
+
expiresAt?: Date | undefined;
|
|
446
|
+
token?: string | undefined;
|
|
447
|
+
ipAddress?: string | null | undefined;
|
|
448
|
+
userAgent?: string | null | undefined;
|
|
449
|
+
} & Record<string, any>;
|
|
450
|
+
}>;
|
|
451
|
+
after?: (session: Session & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<void>;
|
|
452
|
+
};
|
|
453
|
+
update?: {
|
|
454
|
+
before?: (session: Partial<Session> & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<boolean | void | {
|
|
455
|
+
data: {
|
|
456
|
+
[x: string]: any;
|
|
457
|
+
id?: string | undefined;
|
|
458
|
+
createdAt?: Date | undefined;
|
|
459
|
+
updatedAt?: Date | undefined;
|
|
460
|
+
userId?: string | undefined;
|
|
461
|
+
expiresAt?: Date | undefined;
|
|
462
|
+
token?: string | undefined;
|
|
463
|
+
ipAddress?: string | null | undefined;
|
|
464
|
+
userAgent?: string | null | undefined;
|
|
465
|
+
};
|
|
466
|
+
}>;
|
|
467
|
+
after?: (session: Session & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<void>;
|
|
468
|
+
};
|
|
469
|
+
delete?: {
|
|
470
|
+
before?: (session: Session & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<boolean | void>;
|
|
471
|
+
after?: (session: Session & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<void>;
|
|
472
|
+
};
|
|
473
|
+
};
|
|
474
|
+
account?: {
|
|
475
|
+
create?: {
|
|
476
|
+
before?: (account: import("better-auth").Account, context: import("better-auth").GenericEndpointContext | null) => Promise<boolean | void | {
|
|
477
|
+
data: {
|
|
478
|
+
id?: string | undefined;
|
|
479
|
+
createdAt?: Date | undefined;
|
|
480
|
+
updatedAt?: Date | undefined;
|
|
481
|
+
providerId?: string | undefined;
|
|
482
|
+
accountId?: string | undefined;
|
|
483
|
+
userId?: string | undefined;
|
|
484
|
+
accessToken?: string | null | undefined;
|
|
485
|
+
refreshToken?: string | null | undefined;
|
|
486
|
+
idToken?: string | null | undefined;
|
|
487
|
+
accessTokenExpiresAt?: Date | null | undefined;
|
|
488
|
+
refreshTokenExpiresAt?: Date | null | undefined;
|
|
489
|
+
scope?: string | null | undefined;
|
|
490
|
+
password?: string | null | undefined;
|
|
491
|
+
} & Record<string, any>;
|
|
492
|
+
}>;
|
|
493
|
+
after?: (account: import("better-auth").Account, context: import("better-auth").GenericEndpointContext | null) => Promise<void>;
|
|
494
|
+
};
|
|
495
|
+
update?: {
|
|
496
|
+
before?: (account: Partial<import("better-auth").Account> & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<boolean | void | {
|
|
497
|
+
data: {
|
|
498
|
+
[x: string]: any;
|
|
499
|
+
id?: string | undefined;
|
|
500
|
+
createdAt?: Date | undefined;
|
|
501
|
+
updatedAt?: Date | undefined;
|
|
502
|
+
providerId?: string | undefined;
|
|
503
|
+
accountId?: string | undefined;
|
|
504
|
+
userId?: string | undefined;
|
|
505
|
+
accessToken?: string | null | undefined;
|
|
506
|
+
refreshToken?: string | null | undefined;
|
|
507
|
+
idToken?: string | null | undefined;
|
|
508
|
+
accessTokenExpiresAt?: Date | null | undefined;
|
|
509
|
+
refreshTokenExpiresAt?: Date | null | undefined;
|
|
510
|
+
scope?: string | null | undefined;
|
|
511
|
+
password?: string | null | undefined;
|
|
512
|
+
};
|
|
513
|
+
}>;
|
|
514
|
+
after?: (account: import("better-auth").Account & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<void>;
|
|
515
|
+
};
|
|
516
|
+
delete?: {
|
|
517
|
+
before?: (account: import("better-auth").Account & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<boolean | void>;
|
|
518
|
+
after?: (account: import("better-auth").Account & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<void>;
|
|
519
|
+
};
|
|
520
|
+
};
|
|
521
|
+
verification?: {
|
|
522
|
+
create?: {
|
|
523
|
+
before?: (verification: import("better-auth").Verification & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<boolean | void | {
|
|
524
|
+
data: {
|
|
525
|
+
id?: string | undefined;
|
|
526
|
+
createdAt?: Date | undefined;
|
|
527
|
+
updatedAt?: Date | undefined;
|
|
528
|
+
value?: string | undefined;
|
|
529
|
+
expiresAt?: Date | undefined;
|
|
530
|
+
identifier?: string | undefined;
|
|
531
|
+
} & Record<string, any>;
|
|
532
|
+
}>;
|
|
533
|
+
after?: (verification: import("better-auth").Verification & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<void>;
|
|
534
|
+
};
|
|
535
|
+
update?: {
|
|
536
|
+
before?: (verification: Partial<import("better-auth").Verification> & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<boolean | void | {
|
|
537
|
+
data: {
|
|
538
|
+
[x: string]: any;
|
|
539
|
+
id?: string | undefined;
|
|
540
|
+
createdAt?: Date | undefined;
|
|
541
|
+
updatedAt?: Date | undefined;
|
|
542
|
+
value?: string | undefined;
|
|
543
|
+
expiresAt?: Date | undefined;
|
|
544
|
+
identifier?: string | undefined;
|
|
545
|
+
};
|
|
546
|
+
}>;
|
|
547
|
+
after?: (verification: import("better-auth").Verification & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<void>;
|
|
548
|
+
};
|
|
549
|
+
delete?: {
|
|
550
|
+
before?: (verification: import("better-auth").Verification & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<boolean | void>;
|
|
551
|
+
after?: (verification: import("better-auth").Verification & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<void>;
|
|
552
|
+
};
|
|
553
|
+
};
|
|
554
|
+
} | undefined;
|
|
555
|
+
session: {
|
|
556
|
+
cookieCache: {
|
|
557
|
+
enabled: true;
|
|
558
|
+
maxAge: number;
|
|
559
|
+
};
|
|
560
|
+
modelName: "auth.session";
|
|
561
|
+
fields: {
|
|
562
|
+
userId: string;
|
|
563
|
+
expiresAt: string;
|
|
564
|
+
ipAddress: string;
|
|
565
|
+
userAgent: string;
|
|
566
|
+
createdAt: string;
|
|
567
|
+
updatedAt: string;
|
|
568
|
+
};
|
|
569
|
+
expiresIn?: number;
|
|
570
|
+
updateAge?: number;
|
|
571
|
+
};
|
|
572
|
+
user: {
|
|
573
|
+
modelName: "auth.users";
|
|
574
|
+
fields: {
|
|
575
|
+
name: string;
|
|
576
|
+
email: string;
|
|
577
|
+
emailVerified: string;
|
|
578
|
+
image: string;
|
|
579
|
+
createdAt: string;
|
|
580
|
+
updatedAt: string;
|
|
581
|
+
};
|
|
582
|
+
additionalFields: Fields;
|
|
583
|
+
};
|
|
584
|
+
account: {
|
|
585
|
+
modelName: "auth.account";
|
|
586
|
+
fields: {
|
|
587
|
+
userId: string;
|
|
588
|
+
providerId: string;
|
|
589
|
+
accountId: string;
|
|
590
|
+
accessToken: string;
|
|
591
|
+
refreshToken: string;
|
|
592
|
+
accessTokenExpiresAt: string;
|
|
593
|
+
refreshTokenExpiresAt: string;
|
|
594
|
+
scope: string;
|
|
595
|
+
idToken: string;
|
|
596
|
+
password: string;
|
|
597
|
+
createdAt: string;
|
|
598
|
+
updatedAt: string;
|
|
599
|
+
};
|
|
600
|
+
additionalFields?: {
|
|
601
|
+
[x: string]: import("better-auth").DBFieldAttribute;
|
|
602
|
+
} | undefined;
|
|
603
|
+
updateAccountOnSignIn?: boolean;
|
|
604
|
+
accountLinking?: {
|
|
605
|
+
enabled?: boolean;
|
|
606
|
+
disableImplicitLinking?: boolean;
|
|
607
|
+
requireLocalEmailVerified?: boolean;
|
|
608
|
+
trustedProviders?: Array<import("better-auth").LiteralUnion<import("better-auth").SocialProviderList[number] | "email-password", string>> | ((request?: Request | undefined) => import("better-auth").Awaitable<Array<import("better-auth").LiteralUnion<import("better-auth").SocialProviderList[number] | "email-password", string>>>);
|
|
609
|
+
allowDifferentEmails?: boolean;
|
|
610
|
+
allowUnlinkingAll?: boolean;
|
|
611
|
+
updateUserInfoOnLink?: boolean;
|
|
612
|
+
};
|
|
613
|
+
encryptOAuthTokens?: boolean;
|
|
614
|
+
skipStateCookieCheck?: boolean;
|
|
615
|
+
storeStateStrategy?: "database" | "cookie";
|
|
616
|
+
storeAccountCookie?: boolean;
|
|
617
|
+
};
|
|
618
|
+
verification: {
|
|
619
|
+
modelName: "auth.verification";
|
|
620
|
+
fields: {
|
|
621
|
+
identifier: string;
|
|
622
|
+
value: string;
|
|
623
|
+
expiresAt: string;
|
|
624
|
+
createdAt: string;
|
|
625
|
+
updatedAt: string;
|
|
626
|
+
};
|
|
627
|
+
};
|
|
628
|
+
}>;
|
|
629
|
+
/** The auth instance `shellAuth` builds for `App`. */
|
|
630
|
+
export type ShellAuth<App extends ShellAuthApp<AdditionalFields, SessionLike>> = App extends ShellAuthApp<infer Fields, infer Projected> ? ReturnType<typeof buildAuth<Fields, Projected>> : never;
|
|
631
|
+
/**
|
|
632
|
+
* The auth instance of `configure(env)`, built once per `env` object: one per
|
|
633
|
+
* isolate on Workers, so plugin init runs once. Queries run inside
|
|
634
|
+
* `withShellAuth`. An invalid config throws `ExpectedError` naming each
|
|
635
|
+
* invalid value. A failed init drops the instance; the next call rebuilds
|
|
636
|
+
* it.
|
|
637
|
+
*/
|
|
638
|
+
export declare function shellAuth<Env extends object, Fields extends AdditionalFields, Projected extends SessionLike>(configure: (env: Env) => ShellAuthConfig<Fields, Projected>): (env: Env) => ReturnType<typeof buildAuth<Fields, Projected>>;
|
|
639
|
+
/**
|
|
640
|
+
* Runs `fn` with `shellAuth` queries on a pool over `db`; the pool closes
|
|
641
|
+
* when `fn` settles. `fn` finishes its database reads first: a Response streaming
|
|
642
|
+
* lazily from the database fails.
|
|
643
|
+
*/
|
|
644
|
+
export declare function withShellAuth<T>(db: string, fn: () => Promise<T>): Promise<T>;
|
|
645
|
+
export {};
|