@better-auth/core 1.4.0-beta.17 → 1.4.0-beta.18
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 +10 -10
- package/dist/api/index.d.mts +1 -1
- package/dist/api/index.mjs +1 -1
- package/dist/context/index.d.mts +4 -4
- package/dist/context/index.mjs +1 -1
- package/dist/{context-PRICt3il.mjs → context-DS_VYja7.mjs} +6 -2
- package/dist/db/adapter/index.d.mts +1 -1
- package/dist/db/index.d.mts +1 -1
- package/dist/db/index.mjs +31 -31
- package/dist/{index-CLtokfjz.d.mts → index-_O87hA7T.d.mts} +60 -79
- package/dist/index.d.mts +1 -1
- package/dist/oauth2/index.d.mts +1 -1
- package/dist/social-providers/index.d.mts +1 -1
- package/dist/social-providers/index.mjs +2 -2
- package/package.json +3 -2
- package/src/context/request-state.ts +10 -5
- package/src/types/init-options.ts +0 -23
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
|
|
2
|
-
> @better-auth/core@1.4.0-beta.
|
|
2
|
+
> @better-auth/core@1.4.0-beta.18 build /home/runner/work/better-auth/better-auth/packages/core
|
|
3
3
|
> tsdown
|
|
4
4
|
|
|
5
5
|
[34mℹ[39m tsdown [2mv0.16.0[22m powered by rolldown [2mv1.0.0-beta.46[22m
|
|
6
6
|
[34mℹ[39m Using tsdown config: [4m/home/runner/work/better-auth/better-auth/packages/core/tsdown.config.ts[24m
|
|
7
|
-
[34mℹ[39m entry: [34msrc/index.ts, src/api/index.ts, src/
|
|
7
|
+
[34mℹ[39m entry: [34msrc/index.ts, src/api/index.ts, src/async_hooks/index.ts, src/context/index.ts, src/db/index.ts, src/env/index.ts, src/error/index.ts, src/oauth2/index.ts, src/social-providers/index.ts, src/utils/index.ts, src/db/adapter/index.ts[39m
|
|
8
8
|
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
9
9
|
[34mℹ[39m Build start
|
|
10
10
|
[34mℹ[39m [2mdist/[22m[1msocial-providers/index.mjs[22m [2m 77.62 kB[22m [2m│ gzip: 10.12 kB[22m
|
|
11
|
-
[34mℹ[39m [2mdist/[22m[1mdb/index.mjs[22m [2m 1.
|
|
11
|
+
[34mℹ[39m [2mdist/[22m[1mdb/index.mjs[22m [2m 1.64 kB[22m [2m│ gzip: 0.50 kB[22m
|
|
12
12
|
[34mℹ[39m [2mdist/[22m[1mapi/index.mjs[22m [2m 0.83 kB[22m [2m│ gzip: 0.40 kB[22m
|
|
13
13
|
[34mℹ[39m [2mdist/[22m[1mcontext/index.mjs[22m [2m 0.74 kB[22m [2m│ gzip: 0.27 kB[22m
|
|
14
14
|
[34mℹ[39m [2mdist/[22m[1moauth2/index.mjs[22m [2m 0.61 kB[22m [2m│ gzip: 0.24 kB[22m
|
|
@@ -20,23 +20,23 @@
|
|
|
20
20
|
[34mℹ[39m [2mdist/[22m[1mindex.mjs[22m [2m 0.01 kB[22m [2m│ gzip: 0.03 kB[22m
|
|
21
21
|
[34mℹ[39m [2mdist/[22moauth2-D4PPavcA.mjs [2m 9.16 kB[22m [2m│ gzip: 2.12 kB[22m
|
|
22
22
|
[34mℹ[39m [2mdist/[22menv-YhoEXwYv.mjs [2m 7.67 kB[22m [2m│ gzip: 2.54 kB[22m
|
|
23
|
-
[34mℹ[39m [2mdist/[22mcontext-
|
|
23
|
+
[34mℹ[39m [2mdist/[22mcontext-DS_VYja7.mjs [2m 3.91 kB[22m [2m│ gzip: 1.03 kB[22m
|
|
24
24
|
[34mℹ[39m [2mdist/[22merror-D6EqgOXr.mjs [2m 1.77 kB[22m [2m│ gzip: 0.79 kB[22m
|
|
25
25
|
[34mℹ[39m [2mdist/[22masync_hooks-BQqSywfV.mjs [2m 0.87 kB[22m [2m│ gzip: 0.46 kB[22m
|
|
26
26
|
[34mℹ[39m [2mdist/[22mutils-BFQCAfNW.mjs [2m 0.13 kB[22m [2m│ gzip: 0.12 kB[22m
|
|
27
|
-
[34mℹ[39m [2mdist/[22m[32m[1msocial-providers/index.d.mts[22m[39m [2m 3.78 kB[22m [2m│ gzip: 1.
|
|
28
|
-
[34mℹ[39m [2mdist/[22m[32m[1mcontext/index.d.mts[22m[39m [2m 2.
|
|
27
|
+
[34mℹ[39m [2mdist/[22m[32m[1msocial-providers/index.d.mts[22m[39m [2m 3.78 kB[22m [2m│ gzip: 1.17 kB[22m
|
|
28
|
+
[34mℹ[39m [2mdist/[22m[32m[1mcontext/index.d.mts[22m[39m [2m 2.74 kB[22m [2m│ gzip: 0.79 kB[22m
|
|
29
29
|
[34mℹ[39m [2mdist/[22m[32m[1merror/index.d.mts[22m[39m [2m 1.84 kB[22m [2m│ gzip: 0.72 kB[22m
|
|
30
30
|
[34mℹ[39m [2mdist/[22m[32m[1mdb/index.d.mts[22m[39m [2m 1.01 kB[22m [2m│ gzip: 0.38 kB[22m
|
|
31
31
|
[34mℹ[39m [2mdist/[22m[32m[1mutils/index.d.mts[22m[39m [2m 0.84 kB[22m [2m│ gzip: 0.43 kB[22m
|
|
32
32
|
[34mℹ[39m [2mdist/[22m[32m[1mindex.d.mts[22m[39m [2m 0.83 kB[22m [2m│ gzip: 0.32 kB[22m
|
|
33
|
-
[34mℹ[39m [2mdist/[22m[32m[1moauth2/index.d.mts[22m[39m [2m 0.79 kB[22m [2m│ gzip: 0.
|
|
33
|
+
[34mℹ[39m [2mdist/[22m[32m[1moauth2/index.d.mts[22m[39m [2m 0.79 kB[22m [2m│ gzip: 0.30 kB[22m
|
|
34
34
|
[34mℹ[39m [2mdist/[22m[32m[1menv/index.d.mts[22m[39m [2m 0.59 kB[22m [2m│ gzip: 0.30 kB[22m
|
|
35
35
|
[34mℹ[39m [2mdist/[22m[32m[1mdb/adapter/index.d.mts[22m[39m [2m 0.47 kB[22m [2m│ gzip: 0.22 kB[22m
|
|
36
36
|
[34mℹ[39m [2mdist/[22m[32m[1mapi/index.d.mts[22m[39m [2m 0.29 kB[22m [2m│ gzip: 0.16 kB[22m
|
|
37
37
|
[34mℹ[39m [2mdist/[22m[32m[1masync_hooks/index.d.mts[22m[39m [2m 0.14 kB[22m [2m│ gzip: 0.10 kB[22m
|
|
38
|
-
[34mℹ[39m [2mdist/[22m[32mindex-
|
|
38
|
+
[34mℹ[39m [2mdist/[22m[32mindex-_O87hA7T.d.mts[39m [2m201.05 kB[22m [2m│ gzip: 31.42 kB[22m
|
|
39
39
|
[34mℹ[39m [2mdist/[22m[32mindex-JSfspfWW.d.mts[39m [2m 3.31 kB[22m [2m│ gzip: 1.11 kB[22m
|
|
40
40
|
[34mℹ[39m [2mdist/[22m[32mindex-CRg-E-VF.d.mts[39m [2m 0.24 kB[22m [2m│ gzip: 0.16 kB[22m
|
|
41
|
-
[34mℹ[39m 31 files, total: 323.
|
|
42
|
-
[32m✔[39m Build complete in [
|
|
41
|
+
[34mℹ[39m 31 files, total: 323.70 kB
|
|
42
|
+
[32m✔[39m Build complete in [32m4598ms[39m
|
package/dist/api/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as optionsMiddleware, i as createAuthMiddleware, n as AuthMiddleware, r as createAuthEndpoint, t as AuthEndpoint } from "../index-
|
|
1
|
+
import { a as optionsMiddleware, i as createAuthMiddleware, n as AuthMiddleware, r as createAuthEndpoint, t as AuthEndpoint } from "../index-_O87hA7T.mjs";
|
|
2
2
|
import "../index-JSfspfWW.mjs";
|
|
3
3
|
export { AuthEndpoint, AuthMiddleware, createAuthEndpoint, createAuthMiddleware, optionsMiddleware };
|
package/dist/api/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../async_hooks-BQqSywfV.mjs";
|
|
2
|
-
import { f as runWithEndpointContext } from "../context-
|
|
2
|
+
import { f as runWithEndpointContext } from "../context-DS_VYja7.mjs";
|
|
3
3
|
import { createEndpoint, createMiddleware } from "better-call";
|
|
4
4
|
|
|
5
5
|
//#region src/api/index.ts
|
package/dist/context/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Jn as DBTransactionAdapter, Un as DBAdapter, d as AuthContext } from "../index-
|
|
1
|
+
import { Jn as DBTransactionAdapter, Un as DBAdapter, d as AuthContext } from "../index-_O87hA7T.mjs";
|
|
2
2
|
import "../index-JSfspfWW.mjs";
|
|
3
3
|
import { t as AsyncLocalStorage } from "../index-CRg-E-VF.mjs";
|
|
4
4
|
import { EndpointContext, InputContext } from "better-call";
|
|
@@ -24,11 +24,11 @@ declare function hasRequestState(): Promise<boolean>;
|
|
|
24
24
|
declare function getCurrentRequestState(): Promise<RequestStateWeakMap>;
|
|
25
25
|
declare function runWithRequestState<T>(store: RequestStateWeakMap, fn: () => T): Promise<T>;
|
|
26
26
|
interface RequestState<T> {
|
|
27
|
-
get<S>(): Promise<S
|
|
27
|
+
get<S>(): Promise<S & T>;
|
|
28
28
|
set(value: T): Promise<void>;
|
|
29
29
|
}
|
|
30
|
-
declare function defineRequestState<T>(schema
|
|
31
|
-
declare function defineRequestState<Schema extends StandardSchemaV1>(schema
|
|
30
|
+
declare function defineRequestState<T>(schema?: StandardSchemaV1<T>): RequestState<T>;
|
|
31
|
+
declare function defineRequestState<Schema extends StandardSchemaV1>(schema?: Schema): RequestState<StandardSchemaV1.InferInput<Schema>>;
|
|
32
32
|
//#endregion
|
|
33
33
|
//#region src/context/transaction.d.ts
|
|
34
34
|
/**
|
package/dist/context/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "../async_hooks-BQqSywfV.mjs";
|
|
2
|
-
import { a as defineRequestState, c as hasRequestState, d as getCurrentAuthContextAsyncLocalStorage, f as runWithEndpointContext, i as runWithTransaction, l as runWithRequestState, n as getCurrentDBAdapterAsyncLocalStorage, o as getCurrentRequestState, r as runWithAdapter, s as getRequestStateAsyncLocalStorage, t as getCurrentAdapter, u as getCurrentAuthContext } from "../context-
|
|
2
|
+
import { a as defineRequestState, c as hasRequestState, d as getCurrentAuthContextAsyncLocalStorage, f as runWithEndpointContext, i as runWithTransaction, l as runWithRequestState, n as getCurrentDBAdapterAsyncLocalStorage, o as getCurrentRequestState, r as runWithAdapter, s as getRequestStateAsyncLocalStorage, t as getCurrentAdapter, u as getCurrentAuthContext } from "../context-DS_VYja7.mjs";
|
|
3
3
|
|
|
4
4
|
export { defineRequestState, getCurrentAdapter, getCurrentAuthContext, getCurrentAuthContextAsyncLocalStorage, getCurrentDBAdapterAsyncLocalStorage, getCurrentRequestState, getRequestStateAsyncLocalStorage, hasRequestState, runWithAdapter, runWithEndpointContext, runWithRequestState, runWithTransaction };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { t as getAsyncLocalStorage } from "./async_hooks-BQqSywfV.mjs";
|
|
2
|
+
import z from "zod";
|
|
2
3
|
|
|
3
4
|
//#region src/context/endpoint-context.ts
|
|
4
5
|
let currentContextAsyncStorage = null;
|
|
@@ -44,13 +45,16 @@ async function getCurrentRequestState() {
|
|
|
44
45
|
async function runWithRequestState(store, fn) {
|
|
45
46
|
return (await ensureAsyncStorage$1()).run(store, fn);
|
|
46
47
|
}
|
|
47
|
-
function defineRequestState(schema) {
|
|
48
|
+
function defineRequestState(schema = z.any()) {
|
|
48
49
|
return {
|
|
49
50
|
async get() {
|
|
50
51
|
return (await getCurrentRequestState()).get(schema);
|
|
51
52
|
},
|
|
52
53
|
async set(value) {
|
|
53
|
-
|
|
54
|
+
const store = await getCurrentRequestState();
|
|
55
|
+
const parsedValue = await schema["~standard"].validate(value);
|
|
56
|
+
if (parsedValue.issues) throw new Error(`Invalid value: ${JSON.stringify(parsedValue.issues)}`);
|
|
57
|
+
store.set(schema, parsedValue.value);
|
|
54
58
|
}
|
|
55
59
|
};
|
|
56
60
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Gn as DBAdapterFactoryConfig, Hn as CustomAdapter, Jn as DBTransactionAdapter, Kn as DBAdapterInstance, Un as DBAdapter, Vn as CleanedWhere, Wn as DBAdapterDebugLogOption, Yn as Where, qn as DBAdapterSchemaCreation } from "../../index-
|
|
1
|
+
import { Gn as DBAdapterFactoryConfig, Hn as CustomAdapter, Jn as DBTransactionAdapter, Kn as DBAdapterInstance, Un as DBAdapter, Vn as CleanedWhere, Wn as DBAdapterDebugLogOption, Yn as Where, qn as DBAdapterSchemaCreation } from "../../index-_O87hA7T.mjs";
|
|
2
2
|
import "../../index-JSfspfWW.mjs";
|
|
3
3
|
export { CleanedWhere, CustomAdapter, DBAdapter, DBAdapterDebugLogOption, DBAdapterFactoryConfig, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, Where };
|
package/dist/db/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { $n as FieldAttributeConfig, Qn as FieldAttribute, Xn as AuthPluginSchema, Zn as BetterAuthDbSchema, _r as DBFieldType, ar as userSchema, br as SecondaryStorage, cr as sessionSchema, dr as Account, er as FieldType, fr as accountSchema, gr as DBFieldAttributeConfig, hr as DBFieldAttribute, ir as User, lr as RateLimit, mr as BetterAuthDBSchema, nr as Verification, or as coreSchema, pr as BetterAuthPluginDBSchema, rr as verificationSchema, sr as Session, tr as Primitive, ur as rateLimitSchema, vr as DBPreservedModels, yr as DBPrimitive } from "../index-
|
|
1
|
+
import { $n as FieldAttributeConfig, Qn as FieldAttribute, Xn as AuthPluginSchema, Zn as BetterAuthDbSchema, _r as DBFieldType, ar as userSchema, br as SecondaryStorage, cr as sessionSchema, dr as Account, er as FieldType, fr as accountSchema, gr as DBFieldAttributeConfig, hr as DBFieldAttribute, ir as User, lr as RateLimit, mr as BetterAuthDBSchema, nr as Verification, or as coreSchema, pr as BetterAuthPluginDBSchema, rr as verificationSchema, sr as Session, tr as Primitive, ur as rateLimitSchema, vr as DBPreservedModels, yr as DBPrimitive } from "../index-_O87hA7T.mjs";
|
|
2
2
|
import "../index-JSfspfWW.mjs";
|
|
3
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.mjs
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
import * as z from "zod";
|
|
1
|
+
import * as z$1 from "zod";
|
|
2
2
|
|
|
3
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())
|
|
4
|
+
const coreSchema = z$1.object({
|
|
5
|
+
id: z$1.string(),
|
|
6
|
+
createdAt: z$1.date().default(() => /* @__PURE__ */ new Date()),
|
|
7
|
+
updatedAt: z$1.date().default(() => /* @__PURE__ */ new Date())
|
|
8
8
|
});
|
|
9
9
|
|
|
10
10
|
//#endregion
|
|
11
11
|
//#region src/db/schema/account.ts
|
|
12
12
|
const accountSchema = coreSchema.extend({
|
|
13
|
-
providerId: z.string(),
|
|
14
|
-
accountId: z.string(),
|
|
15
|
-
userId: z.coerce.string(),
|
|
16
|
-
accessToken: z.string().nullish(),
|
|
17
|
-
refreshToken: z.string().nullish(),
|
|
18
|
-
idToken: z.string().nullish(),
|
|
19
|
-
accessTokenExpiresAt: z.date().nullish(),
|
|
20
|
-
refreshTokenExpiresAt: z.date().nullish(),
|
|
21
|
-
scope: z.string().nullish(),
|
|
22
|
-
password: z.string().nullish()
|
|
13
|
+
providerId: z$1.string(),
|
|
14
|
+
accountId: z$1.string(),
|
|
15
|
+
userId: z$1.coerce.string(),
|
|
16
|
+
accessToken: z$1.string().nullish(),
|
|
17
|
+
refreshToken: z$1.string().nullish(),
|
|
18
|
+
idToken: z$1.string().nullish(),
|
|
19
|
+
accessTokenExpiresAt: z$1.date().nullish(),
|
|
20
|
+
refreshTokenExpiresAt: z$1.date().nullish(),
|
|
21
|
+
scope: z$1.string().nullish(),
|
|
22
|
+
password: z$1.string().nullish()
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
//#endregion
|
|
26
26
|
//#region src/db/schema/rate-limit.ts
|
|
27
|
-
const rateLimitSchema = z.object({
|
|
28
|
-
key: z.string(),
|
|
29
|
-
count: z.number(),
|
|
30
|
-
lastRequest: z.number()
|
|
27
|
+
const rateLimitSchema = z$1.object({
|
|
28
|
+
key: z$1.string(),
|
|
29
|
+
count: z$1.number(),
|
|
30
|
+
lastRequest: z$1.number()
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
//#endregion
|
|
34
34
|
//#region src/db/schema/session.ts
|
|
35
35
|
const sessionSchema = coreSchema.extend({
|
|
36
|
-
userId: z.coerce.string(),
|
|
37
|
-
expiresAt: z.date(),
|
|
38
|
-
token: z.string(),
|
|
39
|
-
ipAddress: z.string().nullish(),
|
|
40
|
-
userAgent: z.string().nullish()
|
|
36
|
+
userId: z$1.coerce.string(),
|
|
37
|
+
expiresAt: z$1.date(),
|
|
38
|
+
token: z$1.string(),
|
|
39
|
+
ipAddress: z$1.string().nullish(),
|
|
40
|
+
userAgent: z$1.string().nullish()
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
//#endregion
|
|
44
44
|
//#region src/db/schema/user.ts
|
|
45
45
|
const userSchema = coreSchema.extend({
|
|
46
|
-
email: z.string().transform((val) => val.toLowerCase()),
|
|
47
|
-
emailVerified: z.boolean().default(false),
|
|
48
|
-
name: z.string(),
|
|
49
|
-
image: z.string().nullish()
|
|
46
|
+
email: z$1.string().transform((val) => val.toLowerCase()),
|
|
47
|
+
emailVerified: z$1.boolean().default(false),
|
|
48
|
+
name: z$1.string(),
|
|
49
|
+
image: z$1.string().nullish()
|
|
50
50
|
});
|
|
51
51
|
|
|
52
52
|
//#endregion
|
|
53
53
|
//#region src/db/schema/verification.ts
|
|
54
54
|
const verificationSchema = coreSchema.extend({
|
|
55
|
-
value: z.string(),
|
|
56
|
-
expiresAt: z.date(),
|
|
57
|
-
identifier: z.string()
|
|
55
|
+
value: z$1.string(),
|
|
56
|
+
expiresAt: z$1.date(),
|
|
57
|
+
identifier: z$1.string()
|
|
58
58
|
});
|
|
59
59
|
|
|
60
60
|
//#endregion
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as Logger, o as createLogger } from "./index-JSfspfWW.mjs";
|
|
2
2
|
import * as better_call0 from "better-call";
|
|
3
3
|
import { CookieOptions, Endpoint, EndpointContext, EndpointOptions, InputContext, Middleware } from "better-call";
|
|
4
|
-
import * as z from "zod";
|
|
4
|
+
import * as z$1 from "zod";
|
|
5
5
|
import { BetterFetch, BetterFetchOption, BetterFetchPlugin } from "@better-fetch/fetch";
|
|
6
6
|
import * as jose0 from "jose";
|
|
7
7
|
import { StandardSchemaV1, StandardSchemaV1 as StandardSchemaV1$1 } from "@standard-schema/spec";
|
|
@@ -152,96 +152,96 @@ type BetterAuthPluginDBSchema = { [table in string]: {
|
|
|
152
152
|
} };
|
|
153
153
|
//#endregion
|
|
154
154
|
//#region src/db/schema/account.d.ts
|
|
155
|
-
declare const accountSchema: z.ZodObject<{
|
|
156
|
-
id: z.ZodString;
|
|
157
|
-
createdAt: z.ZodDefault<z.ZodDate>;
|
|
158
|
-
updatedAt: z.ZodDefault<z.ZodDate>;
|
|
159
|
-
providerId: z.ZodString;
|
|
160
|
-
accountId: z.ZodString;
|
|
161
|
-
userId: z.ZodCoercedString<unknown>;
|
|
162
|
-
accessToken: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
163
|
-
refreshToken: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
164
|
-
idToken: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
165
|
-
accessTokenExpiresAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
166
|
-
refreshTokenExpiresAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
167
|
-
scope: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
168
|
-
password: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
169
|
-
}, z.core.$strip>;
|
|
155
|
+
declare const accountSchema: z$1.ZodObject<{
|
|
156
|
+
id: z$1.ZodString;
|
|
157
|
+
createdAt: z$1.ZodDefault<z$1.ZodDate>;
|
|
158
|
+
updatedAt: z$1.ZodDefault<z$1.ZodDate>;
|
|
159
|
+
providerId: z$1.ZodString;
|
|
160
|
+
accountId: z$1.ZodString;
|
|
161
|
+
userId: z$1.ZodCoercedString<unknown>;
|
|
162
|
+
accessToken: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
163
|
+
refreshToken: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
164
|
+
idToken: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
165
|
+
accessTokenExpiresAt: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodDate>>;
|
|
166
|
+
refreshTokenExpiresAt: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodDate>>;
|
|
167
|
+
scope: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
168
|
+
password: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
169
|
+
}, z$1.core.$strip>;
|
|
170
170
|
/**
|
|
171
171
|
* Account schema type used by better-auth, note that it's possible that account could have additional fields
|
|
172
172
|
*
|
|
173
173
|
* todo: we should use generics to extend this type with additional fields from plugins and options in the future
|
|
174
174
|
*/
|
|
175
|
-
type Account = z.infer<typeof accountSchema>;
|
|
175
|
+
type Account = z$1.infer<typeof accountSchema>;
|
|
176
176
|
//#endregion
|
|
177
177
|
//#region src/db/schema/rate-limit.d.ts
|
|
178
|
-
declare const rateLimitSchema: z.ZodObject<{
|
|
179
|
-
key: z.ZodString;
|
|
180
|
-
count: z.ZodNumber;
|
|
181
|
-
lastRequest: z.ZodNumber;
|
|
182
|
-
}, z.core.$strip>;
|
|
178
|
+
declare const rateLimitSchema: z$1.ZodObject<{
|
|
179
|
+
key: z$1.ZodString;
|
|
180
|
+
count: z$1.ZodNumber;
|
|
181
|
+
lastRequest: z$1.ZodNumber;
|
|
182
|
+
}, z$1.core.$strip>;
|
|
183
183
|
/**
|
|
184
184
|
* Rate limit schema type used by better-auth for rate limiting
|
|
185
185
|
*/
|
|
186
|
-
type RateLimit = z.infer<typeof rateLimitSchema>;
|
|
186
|
+
type RateLimit = z$1.infer<typeof rateLimitSchema>;
|
|
187
187
|
//#endregion
|
|
188
188
|
//#region src/db/schema/session.d.ts
|
|
189
|
-
declare const sessionSchema: z.ZodObject<{
|
|
190
|
-
id: z.ZodString;
|
|
191
|
-
createdAt: z.ZodDefault<z.ZodDate>;
|
|
192
|
-
updatedAt: z.ZodDefault<z.ZodDate>;
|
|
193
|
-
userId: z.ZodCoercedString<unknown>;
|
|
194
|
-
expiresAt: z.ZodDate;
|
|
195
|
-
token: z.ZodString;
|
|
196
|
-
ipAddress: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
197
|
-
userAgent: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
198
|
-
}, z.core.$strip>;
|
|
189
|
+
declare const sessionSchema: z$1.ZodObject<{
|
|
190
|
+
id: z$1.ZodString;
|
|
191
|
+
createdAt: z$1.ZodDefault<z$1.ZodDate>;
|
|
192
|
+
updatedAt: z$1.ZodDefault<z$1.ZodDate>;
|
|
193
|
+
userId: z$1.ZodCoercedString<unknown>;
|
|
194
|
+
expiresAt: z$1.ZodDate;
|
|
195
|
+
token: z$1.ZodString;
|
|
196
|
+
ipAddress: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
197
|
+
userAgent: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
198
|
+
}, z$1.core.$strip>;
|
|
199
199
|
/**
|
|
200
200
|
* Session schema type used by better-auth, note that it's possible that session could have additional fields
|
|
201
201
|
*
|
|
202
202
|
* todo: we should use generics to extend this type with additional fields from plugins and options in the future
|
|
203
203
|
*/
|
|
204
|
-
type Session = z.infer<typeof sessionSchema>;
|
|
204
|
+
type Session = z$1.infer<typeof sessionSchema>;
|
|
205
205
|
//#endregion
|
|
206
206
|
//#region src/db/schema/shared.d.ts
|
|
207
|
-
declare const coreSchema: z.ZodObject<{
|
|
208
|
-
id: z.ZodString;
|
|
209
|
-
createdAt: z.ZodDefault<z.ZodDate>;
|
|
210
|
-
updatedAt: z.ZodDefault<z.ZodDate>;
|
|
211
|
-
}, z.core.$strip>;
|
|
207
|
+
declare const coreSchema: z$1.ZodObject<{
|
|
208
|
+
id: z$1.ZodString;
|
|
209
|
+
createdAt: z$1.ZodDefault<z$1.ZodDate>;
|
|
210
|
+
updatedAt: z$1.ZodDefault<z$1.ZodDate>;
|
|
211
|
+
}, z$1.core.$strip>;
|
|
212
212
|
//#endregion
|
|
213
213
|
//#region src/db/schema/user.d.ts
|
|
214
|
-
declare const userSchema: z.ZodObject<{
|
|
215
|
-
id: z.ZodString;
|
|
216
|
-
createdAt: z.ZodDefault<z.ZodDate>;
|
|
217
|
-
updatedAt: z.ZodDefault<z.ZodDate>;
|
|
218
|
-
email: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
219
|
-
emailVerified: z.ZodDefault<z.ZodBoolean>;
|
|
220
|
-
name: z.ZodString;
|
|
221
|
-
image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
222
|
-
}, z.core.$strip>;
|
|
214
|
+
declare const userSchema: z$1.ZodObject<{
|
|
215
|
+
id: z$1.ZodString;
|
|
216
|
+
createdAt: z$1.ZodDefault<z$1.ZodDate>;
|
|
217
|
+
updatedAt: z$1.ZodDefault<z$1.ZodDate>;
|
|
218
|
+
email: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<string, string>>;
|
|
219
|
+
emailVerified: z$1.ZodDefault<z$1.ZodBoolean>;
|
|
220
|
+
name: z$1.ZodString;
|
|
221
|
+
image: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
222
|
+
}, z$1.core.$strip>;
|
|
223
223
|
/**
|
|
224
224
|
* User schema type used by better-auth, note that it's possible that user could have additional fields
|
|
225
225
|
*
|
|
226
226
|
* todo: we should use generics to extend this type with additional fields from plugins and options in the future
|
|
227
227
|
*/
|
|
228
|
-
type User = z.infer<typeof userSchema>;
|
|
228
|
+
type User = z$1.infer<typeof userSchema>;
|
|
229
229
|
//#endregion
|
|
230
230
|
//#region src/db/schema/verification.d.ts
|
|
231
|
-
declare const verificationSchema: z.ZodObject<{
|
|
232
|
-
id: z.ZodString;
|
|
233
|
-
createdAt: z.ZodDefault<z.ZodDate>;
|
|
234
|
-
updatedAt: z.ZodDefault<z.ZodDate>;
|
|
235
|
-
value: z.ZodString;
|
|
236
|
-
expiresAt: z.ZodDate;
|
|
237
|
-
identifier: z.ZodString;
|
|
238
|
-
}, z.core.$strip>;
|
|
231
|
+
declare const verificationSchema: z$1.ZodObject<{
|
|
232
|
+
id: z$1.ZodString;
|
|
233
|
+
createdAt: z$1.ZodDefault<z$1.ZodDate>;
|
|
234
|
+
updatedAt: z$1.ZodDefault<z$1.ZodDate>;
|
|
235
|
+
value: z$1.ZodString;
|
|
236
|
+
expiresAt: z$1.ZodDate;
|
|
237
|
+
identifier: z$1.ZodString;
|
|
238
|
+
}, z$1.core.$strip>;
|
|
239
239
|
/**
|
|
240
240
|
* Verification schema type used by better-auth, note that it's possible that verification could have additional fields
|
|
241
241
|
*
|
|
242
242
|
* todo: we should use generics to extend this type with additional fields from plugins and options in the future
|
|
243
243
|
*/
|
|
244
|
-
type Verification = z.infer<typeof verificationSchema>;
|
|
244
|
+
type Verification = z$1.infer<typeof verificationSchema>;
|
|
245
245
|
//#endregion
|
|
246
246
|
//#region src/db/index.d.ts
|
|
247
247
|
/**
|
|
@@ -5689,8 +5689,8 @@ declare const socialProviders: {
|
|
|
5689
5689
|
};
|
|
5690
5690
|
};
|
|
5691
5691
|
declare const socialProviderList: ["github", ...(keyof typeof socialProviders)[]];
|
|
5692
|
-
declare const SocialProviderListEnum: z.ZodType<SocialProviderList[number] | (string & {})>;
|
|
5693
|
-
type SocialProvider = z.infer<typeof SocialProviderListEnum>;
|
|
5692
|
+
declare const SocialProviderListEnum: z$1.ZodType<SocialProviderList[number] | (string & {})>;
|
|
5693
|
+
type SocialProvider = z$1.infer<typeof SocialProviderListEnum>;
|
|
5694
5694
|
type SocialProviders = { [K in SocialProviderList[number]]?: Parameters<(typeof socialProviders)[K]>[0] & {
|
|
5695
5695
|
enabled?: boolean | undefined;
|
|
5696
5696
|
} };
|
|
@@ -6018,25 +6018,6 @@ type BetterAuthAdvancedOptions = {
|
|
|
6018
6018
|
* @default "cookie"
|
|
6019
6019
|
*/
|
|
6020
6020
|
storeStateStrategy?: "database" | "cookie";
|
|
6021
|
-
/**
|
|
6022
|
-
* Additional data to pass through the oauth flow.
|
|
6023
|
-
*
|
|
6024
|
-
* @default undefined
|
|
6025
|
-
*/
|
|
6026
|
-
additionalData?: {
|
|
6027
|
-
/**
|
|
6028
|
-
* Whether to enable additional data.
|
|
6029
|
-
*
|
|
6030
|
-
* @default false
|
|
6031
|
-
*/
|
|
6032
|
-
enabled?: boolean;
|
|
6033
|
-
/**
|
|
6034
|
-
* Validation schema for the additional data.
|
|
6035
|
-
*
|
|
6036
|
-
* @default undefined
|
|
6037
|
-
*/
|
|
6038
|
-
schema?: StandardSchemaV1;
|
|
6039
|
-
} | undefined;
|
|
6040
6021
|
} | undefined;
|
|
6041
6022
|
};
|
|
6042
6023
|
type BetterAuthOptions = {
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { En as BetterAuthCookies, Tn as LiteralUnion, _ as GenerateIdFn, c as BetterAuthClientPlugin, d as AuthContext, f as GenericEndpointContext, g as BetterAuthRateLimitOptions, h as BetterAuthOptions, l as ClientAtomListener, m as BetterAuthAdvancedOptions, o as StandardSchemaV1, p as InternalAdapter, s as BetterAuthClientOptions, u as ClientStore, v as BetterAuthPlugin, wn as LiteralString, y as HookEndpointContext } from "./index-
|
|
1
|
+
import { En as BetterAuthCookies, Tn as LiteralUnion, _ as GenerateIdFn, c as BetterAuthClientPlugin, d as AuthContext, f as GenericEndpointContext, g as BetterAuthRateLimitOptions, h as BetterAuthOptions, l as ClientAtomListener, m as BetterAuthAdvancedOptions, o as StandardSchemaV1, p as InternalAdapter, s as BetterAuthClientOptions, u as ClientStore, v as BetterAuthPlugin, wn as LiteralString, y as HookEndpointContext } from "./index-_O87hA7T.mjs";
|
|
2
2
|
import "./index-JSfspfWW.mjs";
|
|
3
3
|
export { AuthContext, BetterAuthAdvancedOptions, BetterAuthClientOptions, BetterAuthClientPlugin, BetterAuthCookies, BetterAuthOptions, BetterAuthPlugin, BetterAuthRateLimitOptions, ClientAtomListener, ClientStore, GenerateIdFn, GenericEndpointContext, HookEndpointContext, InternalAdapter, LiteralString, LiteralUnion, StandardSchemaV1 };
|
package/dist/oauth2/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { An as generateCodeChallenge, Bn as ProviderOptions, Dn as createAuthorizationCodeRequest, Fn as clientCredentialsToken, In as createClientCredentialsTokenRequest, Ln as OAuth2Tokens, Mn as createRefreshAccessTokenRequest, Nn as refreshAccessToken, On as validateAuthorizationCode, Pn as createAuthorizationURL, Rn as OAuth2UserInfo, jn as getOAuth2Tokens, kn as validateToken, zn as OAuthProvider } from "../index-
|
|
1
|
+
import { An as generateCodeChallenge, Bn as ProviderOptions, Dn as createAuthorizationCodeRequest, Fn as clientCredentialsToken, In as createClientCredentialsTokenRequest, Ln as OAuth2Tokens, Mn as createRefreshAccessTokenRequest, Nn as refreshAccessToken, On as validateAuthorizationCode, Pn as createAuthorizationURL, Rn as OAuth2UserInfo, jn as getOAuth2Tokens, kn as validateToken, zn as OAuthProvider } from "../index-_O87hA7T.mjs";
|
|
2
2
|
import "../index-JSfspfWW.mjs";
|
|
3
3
|
export { OAuth2Tokens, OAuth2UserInfo, OAuthProvider, ProviderOptions, clientCredentialsToken, createAuthorizationCodeRequest, createAuthorizationURL, createClientCredentialsTokenRequest, createRefreshAccessTokenRequest, generateCodeChallenge, getOAuth2Tokens, refreshAccessToken, validateAuthorizationCode, validateToken };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { $ as ZoomOptions, $t as microsoft, A as PayPalProfile, At as DropboxOptions, B as NaverOptions, Bt as SpotifyProfile, C as SocialProviders, Cn as getApplePublicKey, Ct as LinearOptions, D as PolarProfile, Dt as KickOptions, E as PolarOptions, Et as linear, F as paybin, Ft as twitter, G as kakao, Gt as HuggingFaceOptions, H as naver, Ht as SlackOptions, I as LineIdTokenPayload, It as TwitchOptions, J as notion, Jt as GoogleOptions, K as NotionOptions, Kt as HuggingFaceProfile, L as LineOptions, Lt as TwitchProfile, M as paypal, Mt as dropbox, N as PaybinOptions, Nt as TwitterOption, O as polar, Ot as KickProfile, P as PaybinProfile, Pt as TwitterProfile, Q as PronounOption, Qt as MicrosoftOptions, R as LineUserInfo, Rt as twitch, S as SocialProviderListEnum, Sn as apple, St as linkedin, T as socialProviders, Tt as LinearUser, U as KakaoOptions, Ut as SlackProfile, V as NaverProfile, Vt as spotify, W as KakaoProfile, Wt as slack, X as LoginType, Xt as google, Y as AccountStatus, Yt as GoogleProfile, Z as PhoneNumber, Zt as MicrosoftEntraIDProfile, _n as AtlassianProfile, _t as GitlabOptions, an as figma, at as SalesforceOptions, b as SocialProvider, bn as AppleOptions, bt as LinkedInOptions, cn as facebook, ct as RobloxOptions, dn as discord, dt as RedditOptions, en as GithubOptions, et as ZoomProfile, fn as CognitoOptions, ft as RedditProfile, gn as AtlassianOptions, gt as tiktok, hn as getCognitoPublicKey, ht as TiktokProfile, in as FigmaProfile, it as vk, j as PayPalTokenResponse, jt as DropboxProfile, k as PayPalOptions, kt as kick, ln as DiscordOptions, lt as RobloxProfile, mn as cognito, mt as TiktokOptions, nn as github, nt as VkOption, on as FacebookOptions, ot as SalesforceProfile, pn as CognitoProfile, pt as reddit, q as NotionProfile, qt as huggingface, rn as FigmaOptions, rt as VkProfile, sn as FacebookProfile, st as salesforce, tn as GithubProfile, tt as zoom, un as DiscordProfile, ut as roblox, vn as atlassian, vt as GitlabProfile, w as socialProviderList, wt as LinearProfile, x as SocialProviderList, xn as AppleProfile, xt as LinkedInProfile, yn as AppleNonConformUser, yt as gitlab, z as line, zt as SpotifyOptions } from "../index-
|
|
1
|
+
import { $ as ZoomOptions, $t as microsoft, A as PayPalProfile, At as DropboxOptions, B as NaverOptions, Bt as SpotifyProfile, C as SocialProviders, Cn as getApplePublicKey, Ct as LinearOptions, D as PolarProfile, Dt as KickOptions, E as PolarOptions, Et as linear, F as paybin, Ft as twitter, G as kakao, Gt as HuggingFaceOptions, H as naver, Ht as SlackOptions, I as LineIdTokenPayload, It as TwitchOptions, J as notion, Jt as GoogleOptions, K as NotionOptions, Kt as HuggingFaceProfile, L as LineOptions, Lt as TwitchProfile, M as paypal, Mt as dropbox, N as PaybinOptions, Nt as TwitterOption, O as polar, Ot as KickProfile, P as PaybinProfile, Pt as TwitterProfile, Q as PronounOption, Qt as MicrosoftOptions, R as LineUserInfo, Rt as twitch, S as SocialProviderListEnum, Sn as apple, St as linkedin, T as socialProviders, Tt as LinearUser, U as KakaoOptions, Ut as SlackProfile, V as NaverProfile, Vt as spotify, W as KakaoProfile, Wt as slack, X as LoginType, Xt as google, Y as AccountStatus, Yt as GoogleProfile, Z as PhoneNumber, Zt as MicrosoftEntraIDProfile, _n as AtlassianProfile, _t as GitlabOptions, an as figma, at as SalesforceOptions, b as SocialProvider, bn as AppleOptions, bt as LinkedInOptions, cn as facebook, ct as RobloxOptions, dn as discord, dt as RedditOptions, en as GithubOptions, et as ZoomProfile, fn as CognitoOptions, ft as RedditProfile, gn as AtlassianOptions, gt as tiktok, hn as getCognitoPublicKey, ht as TiktokProfile, in as FigmaProfile, it as vk, j as PayPalTokenResponse, jt as DropboxProfile, k as PayPalOptions, kt as kick, ln as DiscordOptions, lt as RobloxProfile, mn as cognito, mt as TiktokOptions, nn as github, nt as VkOption, on as FacebookOptions, ot as SalesforceProfile, pn as CognitoProfile, pt as reddit, q as NotionProfile, qt as huggingface, rn as FigmaOptions, rt as VkProfile, sn as FacebookProfile, st as salesforce, tn as GithubProfile, tt as zoom, un as DiscordProfile, ut as roblox, vn as atlassian, vt as GitlabProfile, w as socialProviderList, wt as LinearProfile, x as SocialProviderList, xn as AppleProfile, xt as LinkedInProfile, yn as AppleNonConformUser, yt as gitlab, z as line, zt as SpotifyOptions } from "../index-_O87hA7T.mjs";
|
|
2
2
|
import "../index-JSfspfWW.mjs";
|
|
3
3
|
export { AccountStatus, AppleNonConformUser, AppleOptions, AppleProfile, AtlassianOptions, AtlassianProfile, CognitoOptions, CognitoProfile, DiscordOptions, DiscordProfile, DropboxOptions, DropboxProfile, FacebookOptions, FacebookProfile, FigmaOptions, FigmaProfile, GithubOptions, GithubProfile, GitlabOptions, GitlabProfile, GoogleOptions, GoogleProfile, HuggingFaceOptions, HuggingFaceProfile, KakaoOptions, KakaoProfile, KickOptions, KickProfile, LineIdTokenPayload, LineOptions, LineUserInfo, LinearOptions, LinearProfile, LinearUser, LinkedInOptions, LinkedInProfile, LoginType, MicrosoftEntraIDProfile, MicrosoftOptions, NaverOptions, NaverProfile, NotionOptions, NotionProfile, PayPalOptions, PayPalProfile, PayPalTokenResponse, PaybinOptions, PaybinProfile, PhoneNumber, PolarOptions, PolarProfile, PronounOption, RedditOptions, RedditProfile, RobloxOptions, RobloxProfile, SalesforceOptions, SalesforceProfile, SlackOptions, SlackProfile, SocialProvider, SocialProviderList, SocialProviderListEnum, SocialProviders, SpotifyOptions, SpotifyProfile, TiktokOptions, TiktokProfile, TwitchOptions, TwitchProfile, TwitterOption, TwitterProfile, VkOption, VkProfile, ZoomOptions, ZoomProfile, apple, atlassian, cognito, discord, dropbox, facebook, figma, getApplePublicKey, getCognitoPublicKey, github, gitlab, google, huggingface, kakao, kick, line, linear, linkedin, microsoft, naver, notion, paybin, paypal, polar, reddit, roblox, salesforce, slack, socialProviderList, socialProviders, spotify, tiktok, twitch, twitter, vk, zoom };
|
|
@@ -3,7 +3,7 @@ import "../utils-BFQCAfNW.mjs";
|
|
|
3
3
|
import { t as BetterAuthError } from "../error-D6EqgOXr.mjs";
|
|
4
4
|
import { a as refreshAccessToken, c as getOAuth2Tokens, n as validateAuthorizationCode, o as createAuthorizationURL, s as generateCodeChallenge } from "../oauth2-D4PPavcA.mjs";
|
|
5
5
|
import { APIError } from "better-call";
|
|
6
|
-
import * as z from "zod";
|
|
6
|
+
import * as z$1 from "zod";
|
|
7
7
|
import { base64 } from "@better-auth/utils/base64";
|
|
8
8
|
import { betterFetch } from "@better-fetch/fetch";
|
|
9
9
|
import { createRemoteJWKSet, decodeJwt, decodeProtectedHeader, importJWK, jwtVerify } from "jose";
|
|
@@ -2507,7 +2507,7 @@ const socialProviders = {
|
|
|
2507
2507
|
polar
|
|
2508
2508
|
};
|
|
2509
2509
|
const socialProviderList = Object.keys(socialProviders);
|
|
2510
|
-
const SocialProviderListEnum = z.enum(socialProviderList).or(z.string());
|
|
2510
|
+
const SocialProviderListEnum = z$1.enum(socialProviderList).or(z$1.string());
|
|
2511
2511
|
|
|
2512
2512
|
//#endregion
|
|
2513
2513
|
export { SocialProviderListEnum, apple, atlassian, cognito, discord, dropbox, facebook, figma, getApplePublicKey, getCognitoPublicKey, github, gitlab, google, huggingface, kakao, kick, line, linear, linkedin, microsoft, naver, notion, paybin, paypal, polar, reddit, roblox, salesforce, slack, socialProviderList, socialProviders, spotify, tiktok, twitch, twitter, vk, zoom };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/core",
|
|
3
|
-
"version": "1.4.0-beta.
|
|
3
|
+
"version": "1.4.0-beta.18",
|
|
4
4
|
"description": "The most comprehensive authentication framework for TypeScript.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.mjs",
|
|
@@ -125,6 +125,7 @@
|
|
|
125
125
|
"scripts": {
|
|
126
126
|
"build": "tsdown",
|
|
127
127
|
"dev": "tsdown --watch",
|
|
128
|
-
"typecheck": "tsc --project tsconfig.json"
|
|
128
|
+
"typecheck": "tsc --project tsconfig.json",
|
|
129
|
+
"test": "vitest"
|
|
129
130
|
}
|
|
130
131
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { StandardSchemaV1 } from "@standard-schema/spec";
|
|
2
|
+
import z from "zod";
|
|
2
3
|
import { type AsyncLocalStorage, getAsyncLocalStorage } from "../async_hooks";
|
|
3
4
|
|
|
4
5
|
export type RequestStateWeakMap = WeakMap<StandardSchemaV1, any>;
|
|
@@ -43,18 +44,18 @@ export async function runWithRequestState<T>(
|
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
export interface RequestState<T> {
|
|
46
|
-
get<S>(): Promise<S
|
|
47
|
+
get<S>(): Promise<S & T>;
|
|
47
48
|
set(value: T): Promise<void>;
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
export function defineRequestState<T>(
|
|
51
|
-
schema
|
|
52
|
+
schema?: StandardSchemaV1<T>,
|
|
52
53
|
): RequestState<T>;
|
|
53
54
|
export function defineRequestState<Schema extends StandardSchemaV1>(
|
|
54
|
-
schema
|
|
55
|
+
schema?: Schema,
|
|
55
56
|
): RequestState<StandardSchemaV1.InferInput<Schema>>;
|
|
56
57
|
export function defineRequestState(
|
|
57
|
-
schema: StandardSchemaV1,
|
|
58
|
+
schema: StandardSchemaV1 = z.any(),
|
|
58
59
|
): RequestState<any> {
|
|
59
60
|
return {
|
|
60
61
|
async get() {
|
|
@@ -64,7 +65,11 @@ export function defineRequestState(
|
|
|
64
65
|
|
|
65
66
|
async set(value) {
|
|
66
67
|
const store = await getCurrentRequestState();
|
|
67
|
-
|
|
68
|
+
const parsedValue = await schema["~standard"].validate(value);
|
|
69
|
+
if (parsedValue.issues) {
|
|
70
|
+
throw new Error(`Invalid value: ${JSON.stringify(parsedValue.issues)}`);
|
|
71
|
+
}
|
|
72
|
+
store.set(schema, parsedValue.value);
|
|
68
73
|
},
|
|
69
74
|
};
|
|
70
75
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Database as BunDatabase } from "bun:sqlite";
|
|
2
2
|
import type { DatabaseSync } from "node:sqlite";
|
|
3
|
-
import type { StandardSchemaV1 } from "@standard-schema/spec";
|
|
4
3
|
import type { CookieOptions } from "better-call";
|
|
5
4
|
import type {
|
|
6
5
|
Dialect,
|
|
@@ -266,28 +265,6 @@ export type BetterAuthAdvancedOptions = {
|
|
|
266
265
|
* @default "cookie"
|
|
267
266
|
*/
|
|
268
267
|
storeStateStrategy?: "database" | "cookie";
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Additional data to pass through the oauth flow.
|
|
272
|
-
*
|
|
273
|
-
* @default undefined
|
|
274
|
-
*/
|
|
275
|
-
additionalData?:
|
|
276
|
-
| {
|
|
277
|
-
/**
|
|
278
|
-
* Whether to enable additional data.
|
|
279
|
-
*
|
|
280
|
-
* @default false
|
|
281
|
-
*/
|
|
282
|
-
enabled?: boolean;
|
|
283
|
-
/**
|
|
284
|
-
* Validation schema for the additional data.
|
|
285
|
-
*
|
|
286
|
-
* @default undefined
|
|
287
|
-
*/
|
|
288
|
-
schema?: StandardSchemaV1;
|
|
289
|
-
}
|
|
290
|
-
| undefined;
|
|
291
268
|
}
|
|
292
269
|
| undefined;
|
|
293
270
|
};
|