better-auth 1.6.26 → 1.6.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/dist/adapters/index.d.mts +6 -1
- package/dist/api/dispatch.d.mts +1 -0
- package/dist/api/index.d.mts +508 -505
- package/dist/api/middlewares/authorization.d.mts +10 -14
- package/dist/api/middlewares/authorization.mjs +1 -2
- package/dist/api/middlewares/index.d.mts +1 -2
- package/dist/api/middlewares/origin-check.d.mts +5 -3
- package/dist/api/routes/account.d.mts +16 -13
- package/dist/api/routes/callback.d.mts +3 -1
- package/dist/api/routes/email-verification.d.mts +8 -4
- package/dist/api/routes/error.d.mts +3 -1
- package/dist/api/routes/index.d.mts +1 -2
- package/dist/api/routes/ok.d.mts +3 -1
- package/dist/api/routes/password.d.mts +10 -8
- package/dist/api/routes/session.d.mts +32 -30
- package/dist/api/routes/session.mjs +2 -3
- package/dist/api/routes/sign-in.d.mts +5 -3
- package/dist/api/routes/sign-out.d.mts +3 -1
- package/dist/api/routes/sign-up.d.mts +4 -3
- package/dist/api/routes/update-session.d.mts +5 -4
- package/dist/api/routes/update-user.d.mts +19 -18
- package/dist/auth/full.d.mts +1 -1
- package/dist/auth/minimal.d.mts +1 -1
- package/dist/client/config.d.mts +14 -12
- package/dist/client/config.mjs +2 -2
- package/dist/client/equality.d.mts +1 -0
- package/dist/client/index.d.mts +5 -6
- package/dist/client/lynx/index.d.mts +5 -4
- package/dist/client/lynx/lynx-store.d.mts +2 -1
- package/dist/client/parser.d.mts +3 -7
- package/dist/client/path-to-object.d.mts +4 -3
- package/dist/client/plugins/index.d.mts +1 -1
- package/dist/client/plugins/infer-plugin.d.mts +1 -0
- package/dist/client/query.d.mts +1 -0
- package/dist/client/react/index.d.mts +5 -4
- package/dist/client/react/react-store.d.mts +2 -1
- package/dist/client/session-atom.mjs +59 -46
- package/dist/client/session-refresh.d.mts +1 -0
- package/dist/client/solid/index.d.mts +5 -4
- package/dist/client/svelte/index.d.mts +5 -4
- package/dist/client/types.d.mts +2 -2
- package/dist/client/vanilla.d.mts +2 -1
- package/dist/client/vue/index.d.mts +5 -4
- package/dist/context/create-context.mjs +3 -3
- package/dist/context/helpers.mjs +2 -2
- package/dist/cookies/index.d.mts +7 -6
- package/dist/cookies/session-store.d.mts +0 -1
- package/dist/cookies/session-store.mjs +1 -2
- package/dist/crypto/index.d.mts +9 -2
- package/dist/crypto/jwt.d.mts +1 -0
- package/dist/crypto/password.d.mts +5 -1
- package/dist/db/adapter-base.d.mts +1 -0
- package/dist/db/adapter-kysely.d.mts +1 -0
- package/dist/db/field-converter.d.mts +1 -0
- package/dist/db/field.d.mts +10 -9
- package/dist/db/get-migration.d.mts +1 -0
- package/dist/db/get-schema.d.mts +1 -0
- package/dist/db/internal-adapter.d.mts +1 -0
- package/dist/db/internal-adapter.mjs +1 -2
- package/dist/db/revoke-unproven-account-access.d.mts +1 -0
- package/dist/db/schema.d.mts +2 -2
- package/dist/db/to-zod.d.mts +7 -3
- package/dist/db/with-hooks.d.mts +1 -0
- package/dist/index.d.mts +3 -4
- package/dist/integrations/next-js.d.mts +7 -4
- package/dist/integrations/node.d.mts +3 -2
- package/dist/integrations/svelte-kit.d.mts +9 -2
- package/dist/integrations/tanstack-start-solid.d.mts +5 -2
- package/dist/integrations/tanstack-start.d.mts +5 -2
- package/dist/oauth2/link-account.d.mts +1 -1
- package/dist/oauth2/state.d.mts +1 -0
- package/dist/oauth2/utils.d.mts +1 -0
- package/dist/package.mjs +1 -1
- package/dist/plugins/access/access.d.mts +1 -0
- package/dist/plugins/access/types.d.mts +5 -4
- package/dist/plugins/additional-fields/client.d.mts +1 -0
- package/dist/plugins/admin/access/statement.d.mts +0 -1
- package/dist/plugins/admin/admin.d.mts +137 -132
- package/dist/plugins/admin/client.d.mts +30 -30
- package/dist/plugins/admin/client.mjs +1 -1
- package/dist/plugins/admin/error-codes.d.mts +25 -23
- package/dist/plugins/admin/index.d.mts +1 -1
- package/dist/plugins/admin/schema.d.mts +1 -1
- package/dist/plugins/admin/types.d.mts +2 -3
- package/dist/plugins/anonymous/client.d.mts +11 -9
- package/dist/plugins/anonymous/client.mjs +1 -1
- package/dist/plugins/anonymous/error-codes.d.mts +10 -8
- package/dist/plugins/anonymous/index.d.mts +19 -15
- package/dist/plugins/anonymous/types.d.mts +1 -1
- package/dist/plugins/bearer/index.d.mts +8 -5
- package/dist/plugins/captcha/index.d.mts +8 -5
- package/dist/plugins/captcha/types.d.mts +1 -0
- package/dist/plugins/custom-session/client.d.mts +1 -0
- package/dist/plugins/custom-session/index.d.mts +12 -7
- package/dist/plugins/device-authorization/client.d.mts +1 -0
- package/dist/plugins/device-authorization/index.d.mts +22 -19
- package/dist/plugins/email-otp/client.d.mts +6 -4
- package/dist/plugins/email-otp/client.mjs +1 -1
- package/dist/plugins/email-otp/error-codes.d.mts +5 -3
- package/dist/plugins/email-otp/index.d.mts +76 -69
- package/dist/plugins/email-otp/types.d.mts +1 -0
- package/dist/plugins/generic-oauth/client.d.mts +11 -10
- package/dist/plugins/generic-oauth/client.mjs +1 -1
- package/dist/plugins/generic-oauth/error-codes.d.mts +10 -8
- package/dist/plugins/generic-oauth/index.d.mts +45 -41
- package/dist/plugins/generic-oauth/providers/auth0.d.mts +1 -0
- package/dist/plugins/generic-oauth/providers/gumroad.d.mts +1 -0
- package/dist/plugins/generic-oauth/providers/hubspot.d.mts +1 -0
- package/dist/plugins/generic-oauth/providers/index.d.mts +1 -2
- package/dist/plugins/generic-oauth/providers/keycloak.d.mts +1 -0
- package/dist/plugins/generic-oauth/providers/line.d.mts +1 -0
- package/dist/plugins/generic-oauth/providers/microsoft-entra-id.d.mts +1 -0
- package/dist/plugins/generic-oauth/providers/okta.d.mts +1 -0
- package/dist/plugins/generic-oauth/providers/patreon.d.mts +1 -0
- package/dist/plugins/generic-oauth/providers/slack.d.mts +1 -0
- package/dist/plugins/generic-oauth/providers/yandex.d.mts +1 -0
- package/dist/plugins/generic-oauth/types.d.mts +2 -1
- package/dist/plugins/haveibeenpwned/index.d.mts +6 -3
- package/dist/plugins/index.d.mts +1 -4
- package/dist/plugins/jwt/client.d.mts +2 -1
- package/dist/plugins/jwt/index.d.mts +12 -9
- package/dist/plugins/jwt/sign.d.mts +2 -2
- package/dist/plugins/jwt/types.d.mts +1 -1
- package/dist/plugins/jwt/utils.d.mts +4 -2
- package/dist/plugins/jwt/verify.d.mts +1 -0
- package/dist/plugins/last-login-method/index.d.mts +6 -3
- package/dist/plugins/magic-link/client.d.mts +1 -0
- package/dist/plugins/magic-link/index.d.mts +6 -4
- package/dist/plugins/mcp/client/adapters.d.mts +1 -0
- package/dist/plugins/mcp/client/index.mjs +2 -4
- package/dist/plugins/mcp/index.d.mts +12 -11
- package/dist/plugins/multi-session/client.d.mts +4 -2
- package/dist/plugins/multi-session/client.mjs +1 -1
- package/dist/plugins/multi-session/error-codes.d.mts +3 -1
- package/dist/plugins/multi-session/index.d.mts +12 -8
- package/dist/plugins/oauth-popup/client.d.mts +12 -6
- package/dist/plugins/oauth-popup/client.mjs +3 -5
- package/dist/plugins/oauth-popup/error-codes.d.mts +6 -4
- package/dist/plugins/oauth-popup/index.d.mts +12 -8
- package/dist/plugins/oauth-popup/index.mjs +1 -1
- package/dist/plugins/oauth-popup/types.d.mts +2 -1
- package/dist/plugins/oauth-proxy/index.d.mts +9 -6
- package/dist/plugins/oauth-proxy/index.mjs +2 -2
- package/dist/plugins/oidc-provider/client.d.mts +2 -1
- package/dist/plugins/oidc-provider/index.d.mts +20 -18
- package/dist/plugins/oidc-provider/schema.d.mts +1 -0
- package/dist/plugins/oidc-provider/types.d.mts +1 -1
- package/dist/plugins/one-tap/client.d.mts +3 -1
- package/dist/plugins/one-tap/index.d.mts +3 -1
- package/dist/plugins/one-time-token/client.d.mts +2 -1
- package/dist/plugins/one-time-token/index.d.mts +7 -6
- package/dist/plugins/open-api/generator.d.mts +1 -0
- package/dist/plugins/open-api/generator.mjs +5 -5
- package/dist/plugins/open-api/index.d.mts +5 -3
- package/dist/plugins/organization/access/statement.d.mts +0 -1
- package/dist/plugins/organization/adapter.d.mts +82 -56
- package/dist/plugins/organization/client.d.mts +103 -104
- package/dist/plugins/organization/client.mjs +4 -7
- package/dist/plugins/organization/error-codes.d.mts +61 -59
- package/dist/plugins/organization/has-permission.d.mts +1 -0
- package/dist/plugins/organization/has-permission.mjs +1 -1
- package/dist/plugins/organization/index.d.mts +1 -1
- package/dist/plugins/organization/organization.d.mts +33 -9
- package/dist/plugins/organization/organization.mjs +1 -1
- package/dist/plugins/organization/permission.d.mts +2 -2
- package/dist/plugins/organization/routes/crud-access-control.d.mts +147 -27
- package/dist/plugins/organization/routes/crud-invites.d.mts +186 -65
- package/dist/plugins/organization/routes/crud-invites.mjs +1 -1
- package/dist/plugins/organization/routes/crud-members.d.mts +178 -56
- package/dist/plugins/organization/routes/crud-members.mjs +1 -1
- package/dist/plugins/organization/routes/crud-org.d.mts +130 -57
- package/dist/plugins/organization/routes/crud-team.d.mts +235 -66
- package/dist/plugins/organization/schema.d.mts +4 -4
- package/dist/plugins/organization/schema.mjs +1 -1
- package/dist/plugins/organization/types.d.mts +14 -14
- package/dist/plugins/phone-number/client.d.mts +15 -13
- package/dist/plugins/phone-number/client.mjs +1 -1
- package/dist/plugins/phone-number/error-codes.d.mts +14 -12
- package/dist/plugins/phone-number/index.d.mts +47 -41
- package/dist/plugins/phone-number/types.d.mts +1 -1
- package/dist/plugins/siwe/client.d.mts +1 -0
- package/dist/plugins/siwe/index.d.mts +5 -4
- package/dist/plugins/test-utils/index.d.mts +4 -2
- package/dist/plugins/test-utils/types.d.mts +0 -1
- package/dist/plugins/two-factor/backup-codes/index.d.mts +7 -5
- package/dist/plugins/two-factor/backup-codes/index.mjs +1 -1
- package/dist/plugins/two-factor/client.d.mts +15 -12
- package/dist/plugins/two-factor/client.mjs +1 -1
- package/dist/plugins/two-factor/error-code.d.mts +12 -10
- package/dist/plugins/two-factor/index.d.mts +36 -32
- package/dist/plugins/two-factor/otp/index.d.mts +4 -2
- package/dist/plugins/two-factor/totp/index.d.mts +7 -5
- package/dist/plugins/two-factor/types.d.mts +1 -1
- package/dist/plugins/username/client.d.mts +11 -9
- package/dist/plugins/username/client.mjs +1 -1
- package/dist/plugins/username/error-codes.d.mts +10 -8
- package/dist/plugins/username/index.d.mts +22 -17
- package/dist/plugins/username/schema.d.mts +5 -3
- package/dist/state.d.mts +1 -0
- package/dist/test-utils/test-instance.d.mts +3 -5
- package/dist/types/adapter.d.mts +1 -1
- package/dist/types/api.d.mts +2 -1
- package/dist/types/auth.d.mts +1 -0
- package/dist/types/helper.d.mts +5 -5
- package/dist/types/index.d.mts +2 -2
- package/dist/types/models.d.mts +1 -0
- package/dist/types/plugins.d.mts +3 -2
- package/dist/utils/index.d.mts +1 -2
- package/dist/utils/url.d.mts +1 -0
- package/package.json +12 -11
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { isJsonEqual, withEquality } from "./equality.mjs";
|
|
2
2
|
import { createSessionRefreshManager } from "./session-refresh.mjs";
|
|
3
|
-
import { atom, onMount } from "nanostores";
|
|
3
|
+
import { STORE_UNMOUNT_DELAY, atom, onMount } from "nanostores";
|
|
4
4
|
//#region src/client/session-atom.ts
|
|
5
5
|
const isServer = () => typeof window === "undefined";
|
|
6
|
+
const SESSION_MOUNT_DEDUPE_INTERVAL = STORE_UNMOUNT_DELAY;
|
|
6
7
|
/**
|
|
7
8
|
* Normalize $fetch response: `throw: true` returns data directly,
|
|
8
9
|
* otherwise `{ data, error }`.
|
|
@@ -24,7 +25,13 @@ function isSessionAtomEqual(a, b) {
|
|
|
24
25
|
}
|
|
25
26
|
function getSessionAtom($fetch, options) {
|
|
26
27
|
const $signal = atom(false);
|
|
27
|
-
let
|
|
28
|
+
let flight;
|
|
29
|
+
let freshUntil = 0;
|
|
30
|
+
let sessionRevision = 0;
|
|
31
|
+
$signal.listen(() => {
|
|
32
|
+
sessionRevision++;
|
|
33
|
+
freshUntil = 0;
|
|
34
|
+
});
|
|
28
35
|
const refetch = (queryParams) => fetchSession(queryParams);
|
|
29
36
|
const session = atom({
|
|
30
37
|
data: null,
|
|
@@ -34,23 +41,8 @@ function getSessionAtom($fetch, options) {
|
|
|
34
41
|
refetch
|
|
35
42
|
});
|
|
36
43
|
withEquality(session, isSessionAtomEqual);
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
const current = session.get();
|
|
40
|
-
abortController = void 0;
|
|
41
|
-
if (!current.isPending && !current.isRefetching) return;
|
|
42
|
-
session.set({
|
|
43
|
-
...current,
|
|
44
|
-
isPending: false,
|
|
45
|
-
isRefetching: false,
|
|
46
|
-
refetch
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
const fetchSession = async (queryParams) => {
|
|
50
|
-
abortController?.abort();
|
|
51
|
-
const controller = new AbortController();
|
|
52
|
-
abortController = controller;
|
|
53
|
-
const current = session.get();
|
|
44
|
+
const executeSessionFetch = async (signal, queryParams) => {
|
|
45
|
+
const current = session.value;
|
|
54
46
|
session.set({
|
|
55
47
|
...current,
|
|
56
48
|
isPending: current.data === null,
|
|
@@ -58,35 +50,29 @@ function getSessionAtom($fetch, options) {
|
|
|
58
50
|
error: null,
|
|
59
51
|
refetch
|
|
60
52
|
});
|
|
53
|
+
if (signal.aborted) return "aborted";
|
|
61
54
|
try {
|
|
62
55
|
const res = await $fetch("/get-session", {
|
|
63
56
|
method: "GET",
|
|
64
57
|
query: queryParams?.query,
|
|
65
|
-
signal
|
|
58
|
+
signal
|
|
66
59
|
});
|
|
67
|
-
if (
|
|
68
|
-
settleAbortedFetch(controller);
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
60
|
+
if (signal.aborted) return "aborted";
|
|
71
61
|
let { data, error } = normalizeSessionResponse(res);
|
|
62
|
+
let outcome = "fresh";
|
|
72
63
|
if (data?.needsRefresh) try {
|
|
73
64
|
const refreshRes = await $fetch("/get-session", {
|
|
74
65
|
method: "POST",
|
|
75
|
-
signal
|
|
66
|
+
signal
|
|
76
67
|
});
|
|
77
|
-
if (
|
|
78
|
-
settleAbortedFetch(controller);
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
68
|
+
if (signal.aborted) return "aborted";
|
|
81
69
|
({data, error} = normalizeSessionResponse(refreshRes));
|
|
82
70
|
} catch {
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
71
|
+
if (signal.aborted) return "aborted";
|
|
72
|
+
outcome = "stale";
|
|
87
73
|
}
|
|
88
74
|
if (error) {
|
|
89
|
-
const latest = session.
|
|
75
|
+
const latest = session.value;
|
|
90
76
|
const isUnauthorized = error?.status === 401;
|
|
91
77
|
session.set({
|
|
92
78
|
data: isUnauthorized ? null : latest.data,
|
|
@@ -95,10 +81,10 @@ function getSessionAtom($fetch, options) {
|
|
|
95
81
|
isRefetching: false,
|
|
96
82
|
refetch
|
|
97
83
|
});
|
|
98
|
-
return;
|
|
84
|
+
return "failed";
|
|
99
85
|
}
|
|
100
86
|
const sessionData = normalizeSessionData(data);
|
|
101
|
-
const current = session.
|
|
87
|
+
const current = session.value;
|
|
102
88
|
const stableData = current.data != null && sessionData != null && isJsonEqual(current.data, sessionData) ? current.data : sessionData;
|
|
103
89
|
session.set({
|
|
104
90
|
data: stableData,
|
|
@@ -107,12 +93,10 @@ function getSessionAtom($fetch, options) {
|
|
|
107
93
|
isRefetching: false,
|
|
108
94
|
refetch
|
|
109
95
|
});
|
|
96
|
+
return outcome;
|
|
110
97
|
} catch (fetchError) {
|
|
111
|
-
if (
|
|
112
|
-
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
const latest = session.get();
|
|
98
|
+
if (signal.aborted) return "aborted";
|
|
99
|
+
const latest = session.value;
|
|
116
100
|
session.set({
|
|
117
101
|
data: latest.data,
|
|
118
102
|
error: fetchError,
|
|
@@ -120,17 +104,49 @@ function getSessionAtom($fetch, options) {
|
|
|
120
104
|
isRefetching: false,
|
|
121
105
|
refetch
|
|
122
106
|
});
|
|
107
|
+
return "failed";
|
|
123
108
|
}
|
|
124
109
|
};
|
|
110
|
+
const getFreshUntil = () => {
|
|
111
|
+
const expiresAt = session.value.data?.session?.expiresAt;
|
|
112
|
+
const sessionExpiresAt = expiresAt instanceof Date ? expiresAt.getTime() : Number.POSITIVE_INFINITY;
|
|
113
|
+
return Math.min(Date.now() + SESSION_MOUNT_DEDUPE_INTERVAL, sessionExpiresAt);
|
|
114
|
+
};
|
|
115
|
+
const fetchSession = (queryParams) => {
|
|
116
|
+
freshUntil = 0;
|
|
117
|
+
flight?.cancel();
|
|
118
|
+
const controller = new AbortController();
|
|
119
|
+
const request = {
|
|
120
|
+
cancel: () => controller.abort(),
|
|
121
|
+
promise: Promise.resolve().then(() => {
|
|
122
|
+
if (controller.signal.aborted) return "aborted";
|
|
123
|
+
return executeSessionFetch(controller.signal, queryParams);
|
|
124
|
+
}),
|
|
125
|
+
revision: sessionRevision
|
|
126
|
+
};
|
|
127
|
+
flight = request;
|
|
128
|
+
const settleFlight = (outcome) => {
|
|
129
|
+
if (flight !== request) return;
|
|
130
|
+
flight = void 0;
|
|
131
|
+
if (outcome === "fresh" && request.revision === sessionRevision) freshUntil = getFreshUntil();
|
|
132
|
+
};
|
|
133
|
+
request.promise.then(settleFlight, () => settleFlight("failed"));
|
|
134
|
+
return request.promise.then(() => void 0);
|
|
135
|
+
};
|
|
136
|
+
const fetchSessionOnMount = () => {
|
|
137
|
+
if (flight?.revision === sessionRevision) return flight.promise.then(() => void 0);
|
|
138
|
+
if (Date.now() < freshUntil) return Promise.resolve();
|
|
139
|
+
return fetchSession();
|
|
140
|
+
};
|
|
125
141
|
let broadcastSessionUpdate = () => {};
|
|
126
142
|
onMount(session, () => {
|
|
127
143
|
let timeoutId;
|
|
128
144
|
if (!isServer()) timeoutId = setTimeout(() => {
|
|
129
|
-
|
|
145
|
+
fetchSessionOnMount();
|
|
130
146
|
}, 0);
|
|
131
147
|
const refreshManager = createSessionRefreshManager({
|
|
132
148
|
fetchSession,
|
|
133
|
-
shouldPollSession: () => session.
|
|
149
|
+
shouldPollSession: () => session.value.data != null,
|
|
134
150
|
sessionSignal: $signal,
|
|
135
151
|
options
|
|
136
152
|
});
|
|
@@ -138,9 +154,6 @@ function getSessionAtom($fetch, options) {
|
|
|
138
154
|
broadcastSessionUpdate = refreshManager.broadcastSessionUpdate;
|
|
139
155
|
return () => {
|
|
140
156
|
if (timeoutId) clearTimeout(timeoutId);
|
|
141
|
-
const controller = abortController;
|
|
142
|
-
controller?.abort();
|
|
143
|
-
if (controller) settleAbortedFetch(controller);
|
|
144
157
|
refreshManager.cleanup();
|
|
145
158
|
};
|
|
146
159
|
});
|
|
@@ -5,14 +5,15 @@ import { BetterAuthClientOptions } from "@better-auth/core";
|
|
|
5
5
|
import { BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
6
6
|
import { BetterFetchError, BetterFetchResponse } from "@better-fetch/fetch";
|
|
7
7
|
import { Accessor } from "solid-js";
|
|
8
|
-
export
|
|
9
|
-
export
|
|
8
|
+
export * from "nanostores";
|
|
9
|
+
export * from "@better-fetch/fetch";
|
|
10
|
+
|
|
10
11
|
//#region src/client/solid/index.d.ts
|
|
11
12
|
type InferResolvedHooks<O extends BetterAuthClientOptions> = O extends {
|
|
12
13
|
plugins: Array<infer Plugin>;
|
|
13
14
|
} ? UnionToIntersection<Plugin extends {
|
|
14
15
|
getAtoms?: infer GetAtoms;
|
|
15
|
-
} ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => Accessor<ReturnType<Atoms[key]["get"]
|
|
16
|
+
} ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => Accessor<ReturnType<Atoms[key]["get"]>> } : {} : {} : {}> : {};
|
|
16
17
|
type ClientConfig = ReturnType<typeof getClientConfig>;
|
|
17
18
|
type ClientSession<Option extends BetterAuthClientOptions> = InferClientAPI<Option> extends {
|
|
18
19
|
getSession: () => Promise<infer Res>;
|
|
@@ -39,4 +40,4 @@ type SolidAuthClient<Option extends BetterAuthClientOptions> = UnionToIntersecti
|
|
|
39
40
|
};
|
|
40
41
|
declare function createAuthClient<Option extends BetterAuthClientOptions>(options?: Option | undefined): SolidAuthClient<Option>;
|
|
41
42
|
//#endregion
|
|
42
|
-
export {
|
|
43
|
+
export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, SolidAuthClient, StripEmptyObjects, type UnionToIntersection, createAuthClient };
|
|
@@ -5,14 +5,15 @@ import { BetterAuthClientOptions } from "@better-auth/core";
|
|
|
5
5
|
import { BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
6
6
|
import { Atom } from "nanostores";
|
|
7
7
|
import { BetterFetchError, BetterFetchResponse } from "@better-fetch/fetch";
|
|
8
|
-
export
|
|
9
|
-
export
|
|
8
|
+
export * from "nanostores";
|
|
9
|
+
export * from "@better-fetch/fetch";
|
|
10
|
+
|
|
10
11
|
//#region src/client/svelte/index.d.ts
|
|
11
12
|
type InferResolvedHooks<O extends BetterAuthClientOptions> = O extends {
|
|
12
13
|
plugins: Array<infer Plugin>;
|
|
13
14
|
} ? UnionToIntersection<Plugin extends {
|
|
14
15
|
getAtoms?: infer GetAtoms;
|
|
15
|
-
} ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => Atoms[key]
|
|
16
|
+
} ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => Atoms[key] } : {} : {} : {}> : {};
|
|
16
17
|
type ClientConfig = ReturnType<typeof getClientConfig>;
|
|
17
18
|
type ClientSession<Option extends BetterAuthClientOptions> = InferClientAPI<Option> extends {
|
|
18
19
|
getSession: () => Promise<infer Res>;
|
|
@@ -39,4 +40,4 @@ type SvelteAuthClient<Option extends BetterAuthClientOptions> = UnionToIntersect
|
|
|
39
40
|
};
|
|
40
41
|
declare function createAuthClient<Option extends BetterAuthClientOptions>(options?: Option | undefined): SvelteAuthClient<Option>;
|
|
41
42
|
//#endregion
|
|
42
|
-
export {
|
|
43
|
+
export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, SvelteAuthClient, type UnionToIntersection, createAuthClient };
|
package/dist/client/types.d.mts
CHANGED
|
@@ -3,9 +3,9 @@ import { StripEmptyObjects, UnionToIntersection } from "../types/helper.mjs";
|
|
|
3
3
|
import { InferRoutes } from "./path-to-object.mjs";
|
|
4
4
|
import { Session as Session$1, User as User$1 } from "../types/models.mjs";
|
|
5
5
|
import { Auth } from "../types/auth.mjs";
|
|
6
|
-
import "../types/index.mjs";
|
|
7
6
|
import { BetterAuthClientOptions as BetterAuthClientOptions$1, BetterAuthClientPlugin, ClientAtomListener as ClientAtomListener$1, ClientStore as ClientStore$1 } from "@better-auth/core";
|
|
8
7
|
import { DBFieldAttribute, InferDBFieldsOutput } from "@better-auth/core/db";
|
|
8
|
+
|
|
9
9
|
//#region src/client/types.d.ts
|
|
10
10
|
type ClientPluginError<K extends string = string> = {
|
|
11
11
|
readonly code: K;
|
|
@@ -28,7 +28,7 @@ type InferErrorCodes<O extends BetterAuthClientOptions$1> = O["plugins"] extends
|
|
|
28
28
|
$InferServerPlugin?: infer ServerPlugin;
|
|
29
29
|
} ? ServerPlugin extends {
|
|
30
30
|
$ERROR_CODES?: infer E;
|
|
31
|
-
} ? { [K in keyof E & string]: E[K] extends ClientPluginError ? ClientPluginError<K> : never
|
|
31
|
+
} ? { [K in keyof E & string]: E[K] extends ClientPluginError ? ClientPluginError<K> : never } : {} : {}> : {};
|
|
32
32
|
/**
|
|
33
33
|
* signals are just used to recall a computed value.
|
|
34
34
|
* as a convention they start with "$"
|
|
@@ -5,12 +5,13 @@ import { BetterAuthClientOptions } from "@better-auth/core";
|
|
|
5
5
|
import { BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
6
6
|
import { Atom } from "nanostores";
|
|
7
7
|
import { BetterFetchError, BetterFetchResponse } from "@better-fetch/fetch";
|
|
8
|
+
|
|
8
9
|
//#region src/client/vanilla.d.ts
|
|
9
10
|
type InferResolvedHooks<O extends BetterAuthClientOptions> = O extends {
|
|
10
11
|
plugins: Array<infer Plugin>;
|
|
11
12
|
} ? UnionToIntersection<Plugin extends {
|
|
12
13
|
getAtoms?: infer GetAtoms;
|
|
13
|
-
} ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: Atoms[key]
|
|
14
|
+
} ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: Atoms[key] } : {} : {} : {}> : {};
|
|
14
15
|
type ClientConfig = ReturnType<typeof getClientConfig>;
|
|
15
16
|
type ClientSession<Option extends BetterAuthClientOptions> = InferClientAPI<Option> extends {
|
|
16
17
|
getSession: () => Promise<infer Res>;
|
|
@@ -5,14 +5,15 @@ import { BetterAuthClientOptions } from "@better-auth/core";
|
|
|
5
5
|
import { BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
6
6
|
import { BetterFetchError, BetterFetchResponse } from "@better-fetch/fetch";
|
|
7
7
|
import { DeepReadonly, Ref } from "vue";
|
|
8
|
-
export
|
|
9
|
-
export
|
|
8
|
+
export * from "nanostores";
|
|
9
|
+
export * from "@better-fetch/fetch";
|
|
10
|
+
|
|
10
11
|
//#region src/client/vue/index.d.ts
|
|
11
12
|
type InferResolvedHooks<O extends BetterAuthClientOptions> = O extends {
|
|
12
13
|
plugins: Array<infer Plugin>;
|
|
13
14
|
} ? UnionToIntersection<Plugin extends {
|
|
14
15
|
getAtoms?: infer GetAtoms;
|
|
15
|
-
} ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => DeepReadonly<Ref<ReturnType<Atoms[key]["get"]
|
|
16
|
+
} ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => DeepReadonly<Ref<ReturnType<Atoms[key]["get"]>>> } : {} : {} : {}> : {};
|
|
16
17
|
type ClientConfig = ReturnType<typeof getClientConfig>;
|
|
17
18
|
type ClientSession<Option extends BetterAuthClientOptions> = InferClientAPI<Option> extends {
|
|
18
19
|
getSession: () => Promise<infer Res>;
|
|
@@ -51,4 +52,4 @@ type VueAuthClient<Option extends BetterAuthClientOptions> = UnionToIntersection
|
|
|
51
52
|
};
|
|
52
53
|
declare function createAuthClient<Option extends BetterAuthClientOptions>(options?: Option | undefined): VueAuthClient<Option>;
|
|
53
54
|
//#endregion
|
|
54
|
-
export {
|
|
55
|
+
export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, type UnionToIntersection, VueAuthClient, createAuthClient };
|
|
@@ -18,7 +18,7 @@ import { generateId } from "@better-auth/core/utils/id";
|
|
|
18
18
|
import { socialProviders } from "@better-auth/core/social-providers";
|
|
19
19
|
import { findInvalidTrustedProxies } from "@better-auth/core/utils/ip";
|
|
20
20
|
import { createTelemetry } from "@better-auth/telemetry";
|
|
21
|
-
import defu from "defu";
|
|
21
|
+
import defu$1 from "defu";
|
|
22
22
|
//#region src/context/create-context.ts
|
|
23
23
|
/**
|
|
24
24
|
* Estimates the entropy of a string in bits.
|
|
@@ -45,13 +45,13 @@ function validateSecret(secret, logger) {
|
|
|
45
45
|
}
|
|
46
46
|
async function createAuthContext(adapter, options, getDatabaseType) {
|
|
47
47
|
const isStateful = hasServerSessionStore(options);
|
|
48
|
-
if (!isStateful) options = defu(options, { session: { cookieCache: {
|
|
48
|
+
if (!isStateful) options = defu$1(options, { session: { cookieCache: {
|
|
49
49
|
enabled: true,
|
|
50
50
|
strategy: "jwe",
|
|
51
51
|
refreshCache: true,
|
|
52
52
|
maxAge: options.session?.expiresIn || 3600 * 24 * 7
|
|
53
53
|
} } });
|
|
54
|
-
if (!options.database) options = defu(options, { account: { storeAccountCookie: true } });
|
|
54
|
+
if (!options.database) options = defu$1(options, { account: { storeAccountCookie: true } });
|
|
55
55
|
const plugins = options.plugins || [];
|
|
56
56
|
const internalPlugins = getInternalPlugins(options);
|
|
57
57
|
const logger = createLogger(options.logger);
|
package/dist/context/helpers.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { createCookieGetter, getCookies } from "../cookies/index.mjs";
|
|
|
4
4
|
import { createInternalAdapter } from "../db/internal-adapter.mjs";
|
|
5
5
|
import { env } from "@better-auth/core/env";
|
|
6
6
|
import { BetterAuthError } from "@better-auth/core/error";
|
|
7
|
-
import { defu
|
|
7
|
+
import { defu } from "defu";
|
|
8
8
|
import { isLoopbackHost } from "@better-auth/core/utils/host";
|
|
9
9
|
//#region src/context/helpers.ts
|
|
10
10
|
async function runPluginInit(context) {
|
|
@@ -25,7 +25,7 @@ async function runPluginInit(context) {
|
|
|
25
25
|
hooks: databaseHooks
|
|
26
26
|
});
|
|
27
27
|
if (trustedOrigins) pluginTrustedOrigins.push(trustedOrigins);
|
|
28
|
-
options = defu
|
|
28
|
+
options = defu(options, restOpts);
|
|
29
29
|
}
|
|
30
30
|
if (result.context) Object.assign(context, result.context);
|
|
31
31
|
}
|
package/dist/cookies/index.d.mts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Session, User } from "../types/models.mjs";
|
|
2
|
-
import "../types/index.mjs";
|
|
3
2
|
import { CookieAttributes, HOST_COOKIE_PREFIX, SECURE_COOKIE_PREFIX, applySetCookies, cookieNameRegex, parseCookies, parseSetCookieHeader, setCookieToHeader, setRequestCookie, splitSetCookieHeader, stripSecureCookiePrefix, toCookieOptions } from "./cookie-utils.mjs";
|
|
4
3
|
import { createSessionStore, getAccountCookie, getChunkedCookie } from "./session-store.mjs";
|
|
5
4
|
import { BetterAuthCookie, BetterAuthCookies, BetterAuthOptions, GenericEndpointContext } from "@better-auth/core";
|
|
5
|
+
import * as _$better_call0 from "better-call";
|
|
6
6
|
import { CookieOptions } from "better-call";
|
|
7
|
+
|
|
7
8
|
//#region src/cookies/index.d.ts
|
|
8
9
|
declare function createCookieGetter(options: BetterAuthOptions): (cookieName: string, overrideAttributes?: Partial<CookieOptions>) => {
|
|
9
10
|
name: string;
|
|
@@ -16,7 +17,7 @@ declare function createCookieGetter(options: BetterAuthOptions): (cookieName: st
|
|
|
16
17
|
secure: boolean;
|
|
17
18
|
sameSite: "Strict" | "Lax" | "None" | "strict" | "lax" | "none";
|
|
18
19
|
partitioned?: boolean;
|
|
19
|
-
prefix?:
|
|
20
|
+
prefix?: _$better_call0.CookiePrefixOptions;
|
|
20
21
|
};
|
|
21
22
|
};
|
|
22
23
|
declare function getCookies(options: BetterAuthOptions): {
|
|
@@ -31,7 +32,7 @@ declare function getCookies(options: BetterAuthOptions): {
|
|
|
31
32
|
secure: boolean;
|
|
32
33
|
sameSite: "Strict" | "Lax" | "None" | "strict" | "lax" | "none";
|
|
33
34
|
partitioned?: boolean;
|
|
34
|
-
prefix?:
|
|
35
|
+
prefix?: _$better_call0.CookiePrefixOptions;
|
|
35
36
|
};
|
|
36
37
|
};
|
|
37
38
|
/**
|
|
@@ -49,7 +50,7 @@ declare function getCookies(options: BetterAuthOptions): {
|
|
|
49
50
|
secure: boolean;
|
|
50
51
|
sameSite: "Strict" | "Lax" | "None" | "strict" | "lax" | "none";
|
|
51
52
|
partitioned?: boolean;
|
|
52
|
-
prefix?:
|
|
53
|
+
prefix?: _$better_call0.CookiePrefixOptions;
|
|
53
54
|
};
|
|
54
55
|
};
|
|
55
56
|
dontRememberToken: {
|
|
@@ -63,7 +64,7 @@ declare function getCookies(options: BetterAuthOptions): {
|
|
|
63
64
|
secure: boolean;
|
|
64
65
|
sameSite: "Strict" | "Lax" | "None" | "strict" | "lax" | "none";
|
|
65
66
|
partitioned?: boolean;
|
|
66
|
-
prefix?:
|
|
67
|
+
prefix?: _$better_call0.CookiePrefixOptions;
|
|
67
68
|
};
|
|
68
69
|
};
|
|
69
70
|
accountData: {
|
|
@@ -77,7 +78,7 @@ declare function getCookies(options: BetterAuthOptions): {
|
|
|
77
78
|
secure: boolean;
|
|
78
79
|
sameSite: "Strict" | "Lax" | "None" | "strict" | "lax" | "none";
|
|
79
80
|
partitioned?: boolean;
|
|
80
|
-
prefix?:
|
|
81
|
+
prefix?: _$better_call0.CookiePrefixOptions;
|
|
81
82
|
};
|
|
82
83
|
};
|
|
83
84
|
};
|
|
@@ -24,8 +24,7 @@ const MAX_COOKIE_CHUNKS = 100;
|
|
|
24
24
|
* wire. Non-positive when the name and attributes alone overflow.
|
|
25
25
|
*/
|
|
26
26
|
function getMaxCookieValueSize(name, options) {
|
|
27
|
-
|
|
28
|
-
return MAX_COOKIE_SIZE - overhead;
|
|
27
|
+
return MAX_COOKIE_SIZE - serializeCookie(name, "", { ...options }).length;
|
|
29
28
|
}
|
|
30
29
|
/**
|
|
31
30
|
* Read all existing chunks from cookies
|
package/dist/crypto/index.d.mts
CHANGED
|
@@ -3,6 +3,7 @@ import { signJWT, symmetricDecodeJWT, symmetricEncodeJWT, verifyJWT } from "./jw
|
|
|
3
3
|
import { hashPassword, verifyPassword } from "./password.mjs";
|
|
4
4
|
import { generateRandomString } from "./random.mjs";
|
|
5
5
|
import { SecretConfig } from "@better-auth/core";
|
|
6
|
+
|
|
6
7
|
//#region src/crypto/index.d.ts
|
|
7
8
|
declare function parseEnvelope(data: string): {
|
|
8
9
|
version: number;
|
|
@@ -13,12 +14,18 @@ type SymmetricEncryptOptions = {
|
|
|
13
14
|
key: string | SecretConfig;
|
|
14
15
|
data: string;
|
|
15
16
|
};
|
|
16
|
-
declare const symmetricEncrypt: ({
|
|
17
|
+
declare const symmetricEncrypt: ({
|
|
18
|
+
key,
|
|
19
|
+
data
|
|
20
|
+
}: SymmetricEncryptOptions) => Promise<string>;
|
|
17
21
|
type SymmetricDecryptOptions = {
|
|
18
22
|
key: string | SecretConfig;
|
|
19
23
|
data: string;
|
|
20
24
|
};
|
|
21
|
-
declare const symmetricDecrypt: ({
|
|
25
|
+
declare const symmetricDecrypt: ({
|
|
26
|
+
key,
|
|
27
|
+
data
|
|
28
|
+
}: SymmetricDecryptOptions) => Promise<string>;
|
|
22
29
|
declare const getCryptoKey: (secret: string | BufferSource) => Promise<CryptoKey>;
|
|
23
30
|
declare const makeSignature: (value: string, secret: string | BufferSource) => Promise<string>;
|
|
24
31
|
//#endregion
|
package/dist/crypto/jwt.d.mts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { hashPassword } from "@better-auth/utils/password";
|
|
2
|
+
|
|
2
3
|
//#region src/crypto/password.d.ts
|
|
3
4
|
declare const hashPassword$1: typeof hashPassword;
|
|
4
|
-
declare const verifyPassword$1: ({
|
|
5
|
+
declare const verifyPassword$1: ({
|
|
6
|
+
hash,
|
|
7
|
+
password
|
|
8
|
+
}: {
|
|
5
9
|
hash: string;
|
|
6
10
|
password: string;
|
|
7
11
|
}) => Promise<boolean>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BetterAuthOptions } from "@better-auth/core";
|
|
2
2
|
import { DBAdapter } from "@better-auth/core/db/adapter";
|
|
3
|
+
|
|
3
4
|
//#region src/db/adapter-base.d.ts
|
|
4
5
|
declare function getBaseAdapter(options: BetterAuthOptions, handleDirectDatabase: (options: BetterAuthOptions) => Promise<DBAdapter<BetterAuthOptions>>): Promise<DBAdapter<BetterAuthOptions>>;
|
|
5
6
|
//#endregion
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DBFieldAttribute } from "@better-auth/core/db";
|
|
2
|
+
|
|
2
3
|
//#region src/db/field-converter.d.ts
|
|
3
4
|
declare function convertToDB<T extends Record<string, any>>(fields: Record<string, DBFieldAttribute>, values: T): T;
|
|
4
5
|
declare function convertFromDB<T extends Record<string, any>>(fields: Record<string, DBFieldAttribute>, values: T | null): T | null;
|
package/dist/db/field.d.mts
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { DBFieldAttribute, InferDBValueType } from "@better-auth/core/db";
|
|
2
|
+
|
|
2
3
|
//#region src/db/field.d.ts
|
|
3
|
-
type InferFieldsOutput<Fields extends Record<string, DBFieldAttribute>> = Fields extends Record<infer Key, DBFieldAttribute> ? { [key in Key as Fields[key]["returned"] extends false ? never : Fields[key]["required"] extends false ? Fields[key]["defaultValue"] extends boolean | string | number | Date ? key : never : key]: InferFieldOutput<Fields[key]
|
|
4
|
+
type InferFieldsOutput<Fields extends Record<string, DBFieldAttribute>> = Fields extends Record<infer Key, DBFieldAttribute> ? { [key in Key as Fields[key]["returned"] extends false ? never : Fields[key]["required"] extends false ? Fields[key]["defaultValue"] extends boolean | string | number | Date ? key : never : key]: InferFieldOutput<Fields[key]> } & { [key in Key as Fields[key]["returned"] extends false ? never : Fields[key]["required"] extends false ? Fields[key]["defaultValue"] extends boolean | string | number | Date ? never : key : never]?: InferFieldOutput<Fields[key]> | null } : never;
|
|
4
5
|
/**
|
|
5
6
|
* For client will add "?" on optional fields
|
|
6
7
|
*/
|
|
7
|
-
type InferFieldsInputClient<Fields extends Record<string, DBFieldAttribute>> = Fields extends Record<infer Key, DBFieldAttribute> ? { [key in Key as Fields[key]["required"] extends false ? never : Fields[key]["defaultValue"] extends string | number | boolean | Date ? never : Fields[key]["input"] extends false ? never : key]: InferFieldInput<Fields[key]
|
|
8
|
+
type InferFieldsInputClient<Fields extends Record<string, DBFieldAttribute>> = Fields extends Record<infer Key, DBFieldAttribute> ? { [key in Key as Fields[key]["required"] extends false ? never : Fields[key]["defaultValue"] extends string | number | boolean | Date ? never : Fields[key]["input"] extends false ? never : key]: InferFieldInput<Fields[key]> } & { [key in Key as Fields[key]["input"] extends false ? never : Fields[key]["required"] extends false ? key : Fields[key]["defaultValue"] extends string | number | boolean | Date ? key : never]?: InferFieldInput<Fields[key]> | undefined | null } : never;
|
|
8
9
|
type InferFieldOutput<T extends DBFieldAttribute> = T["returned"] extends false ? never : T["required"] extends false ? InferDBValueType<T["type"]> | undefined | null : InferDBValueType<T["type"]>;
|
|
9
10
|
/**
|
|
10
11
|
* Converts a Record<string, DBFieldAttribute> to an object type
|
|
11
12
|
* with keys and value types inferred from DBFieldAttribute["type"].
|
|
12
13
|
*/
|
|
13
|
-
type FieldAttributeToObject<Fields extends Record<string, DBFieldAttribute>> = AddOptionalFields<{ [K in keyof Fields]: InferDBValueType<Fields[K]["type"]
|
|
14
|
+
type FieldAttributeToObject<Fields extends Record<string, DBFieldAttribute>> = AddOptionalFields<{ [K in keyof Fields]: InferDBValueType<Fields[K]["type"]> }, Fields>;
|
|
14
15
|
type AddOptionalFields<T extends Record<string, any>, Fields extends Record<keyof T, DBFieldAttribute>> = { [K in keyof T as Fields[K] extends {
|
|
15
16
|
required: false;
|
|
16
|
-
} ? never : K]: T[K]
|
|
17
|
+
} ? never : K]: T[K] } & { [K in keyof T as Fields[K] extends {
|
|
17
18
|
required: false;
|
|
18
|
-
} ? K : never]?: T[K]
|
|
19
|
+
} ? K : never]?: T[K] };
|
|
19
20
|
/**
|
|
20
21
|
* Infer the additional fields from the plugin options.
|
|
21
22
|
* For example, you can infer the additional fields of the org plugin's organization schema like this:
|
|
@@ -29,12 +30,12 @@ type AddOptionalFields<T extends Record<string, any>, Fields extends Record<keyo
|
|
|
29
30
|
type InferAdditionalFieldsFromPluginOptions<SchemaName extends string, Options extends {
|
|
30
31
|
schema?: { [key in SchemaName]?: {
|
|
31
32
|
additionalFields?: Record<string, DBFieldAttribute>;
|
|
32
|
-
}
|
|
33
|
+
} } | undefined;
|
|
33
34
|
}, isClientSide extends boolean = true> = Options["schema"] extends { [key in SchemaName]?: {
|
|
34
35
|
additionalFields: infer Field extends Record<string, DBFieldAttribute>;
|
|
35
|
-
}
|
|
36
|
-
type RemoveFieldsWithInputFalse<T extends Record<string, DBFieldAttribute>> = { [K in keyof T as T[K]["input"] extends false ? never : K]: T[K]
|
|
37
|
-
type RemoveFieldsWithReturnedFalse<T extends Record<string, DBFieldAttribute>> = { [K in keyof T as T[K]["returned"] extends false ? never : K]: T[K]
|
|
36
|
+
} } ? isClientSide extends true ? FieldAttributeToObject<RemoveFieldsWithInputFalse<Field>> : FieldAttributeToObject<Field> : {};
|
|
37
|
+
type RemoveFieldsWithInputFalse<T extends Record<string, DBFieldAttribute>> = { [K in keyof T as T[K]["input"] extends false ? never : K]: T[K] };
|
|
38
|
+
type RemoveFieldsWithReturnedFalse<T extends Record<string, DBFieldAttribute>> = { [K in keyof T as T[K]["returned"] extends false ? never : K]: T[K] };
|
|
38
39
|
type InferFieldInput<T extends DBFieldAttribute> = InferDBValueType<T["type"]>;
|
|
39
40
|
//#endregion
|
|
40
41
|
export { FieldAttributeToObject, InferAdditionalFieldsFromPluginOptions, InferFieldsInputClient, InferFieldsOutput, RemoveFieldsWithReturnedFalse };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BetterAuthOptions } from "@better-auth/core";
|
|
2
2
|
import { DBFieldAttribute, DBFieldType } from "@better-auth/core/db";
|
|
3
3
|
import { KyselyDatabaseType } from "@better-auth/kysely-adapter";
|
|
4
|
+
|
|
4
5
|
//#region src/db/get-migration.d.ts
|
|
5
6
|
declare function matchType(columnDataType: string, fieldType: DBFieldType, dbType: KyselyDatabaseType): boolean;
|
|
6
7
|
declare function getMigrations(config: BetterAuthOptions): Promise<{
|
package/dist/db/get-schema.d.mts
CHANGED
|
@@ -2,6 +2,7 @@ import { DatabaseHooksEntry } from "./with-hooks.mjs";
|
|
|
2
2
|
import { AuthContext, BetterAuthOptions, InternalAdapter } from "@better-auth/core";
|
|
3
3
|
import { InternalLogger } from "@better-auth/core/env";
|
|
4
4
|
import { DBAdapter } from "@better-auth/core/db/adapter";
|
|
5
|
+
|
|
5
6
|
//#region src/db/internal-adapter.d.ts
|
|
6
7
|
declare const createInternalAdapter: (adapter: DBAdapter<BetterAuthOptions>, ctx: {
|
|
7
8
|
options: Omit<BetterAuthOptions, "logger">;
|
|
@@ -698,8 +698,7 @@ const createInternalAdapter = (adapter, ctx) => {
|
|
|
698
698
|
logger.warn("Secondary storage does not implement `getAndDelete`, so single-use verification values cannot be consumed atomically across processes. Implement `getAndDelete` or use database-backed verification storage to guarantee single use.");
|
|
699
699
|
}
|
|
700
700
|
return withVerificationConsumeLock(key, async () => {
|
|
701
|
-
const
|
|
702
|
-
const parsed = hydrateCachedVerification(raw);
|
|
701
|
+
const parsed = hydrateCachedVerification(await secondaryStorage.get(key));
|
|
703
702
|
if (!parsed) return null;
|
|
704
703
|
await secondaryStorage.delete(key);
|
|
705
704
|
return parsed;
|
package/dist/db/schema.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Account, Session as Session$1, User as User$1 } from "../types/models.mjs";
|
|
2
|
-
import "../types/index.mjs";
|
|
3
2
|
import { BetterAuthOptions } from "@better-auth/core";
|
|
4
3
|
import { BetterAuthPluginDBSchema, DBFieldAttribute } from "@better-auth/core/db";
|
|
4
|
+
|
|
5
5
|
//#region src/db/schema.d.ts
|
|
6
6
|
declare function parseUserOutput<T extends User$1>(options: BetterAuthOptions, user: T): T;
|
|
7
7
|
/**
|
|
@@ -57,6 +57,6 @@ declare function mergeSchema<S extends BetterAuthPluginDBSchema>(schema: S, newS
|
|
|
57
57
|
fields?: {
|
|
58
58
|
[P: string]: string;
|
|
59
59
|
} | undefined;
|
|
60
|
-
} | undefined
|
|
60
|
+
} | undefined } | undefined): S;
|
|
61
61
|
//#endregion
|
|
62
62
|
export { buildSyntheticUserOutput, getSessionDefaultFields, mergeSchema, parseAccountInput, parseAccountOutput, parseAdditionalUserInput, parseAdditionalUserInputFromProviderProfile, parseInputData, parseSessionInput, parseSessionOutput, parseUserInput, parseUserOutput };
|