better-auth 0.0.2-beta.7 → 0.0.2
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/access.d.ts +4 -0
- package/dist/access.js +126 -0
- package/dist/access.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +553 -0
- package/dist/cli.js.map +1 -0
- package/dist/client/plugins.d.ts +2436 -0
- package/dist/client/plugins.js +411 -0
- package/dist/client/plugins.js.map +1 -0
- package/dist/client-A2Mt04KQ.d.ts +3503 -0
- package/dist/client.d.ts +1433 -0
- package/dist/client.js +693 -0
- package/dist/client.js.map +1 -0
- package/dist/helper-B5_2Vzba.d.ts +14 -0
- package/dist/index-Dg4eEXZW.d.ts +24 -0
- package/dist/index-W5nXvJ-p.d.ts +1498 -0
- package/dist/index.d.ts +6 -4
- package/dist/index.js +2195 -1191
- package/dist/index.js.map +1 -1
- package/dist/next-js.d.ts +14 -0
- package/dist/next-js.js +14 -0
- package/dist/next-js.js.map +1 -0
- package/dist/plugins.d.ts +892 -49
- package/dist/plugins.js +3951 -253
- package/dist/plugins.js.map +1 -1
- package/dist/preact.d.ts +8 -0
- package/dist/preact.js +294 -0
- package/dist/preact.js.map +1 -0
- package/dist/react.d.ts +14 -0
- package/dist/react.js +314 -0
- package/dist/react.js.map +1 -0
- package/dist/schema-BOszzrbQ.d.ts +792 -0
- package/dist/social.d.ts +4 -0
- package/dist/social.js +509 -0
- package/dist/social.js.map +1 -0
- package/dist/solid-start.d.ts +18 -0
- package/dist/solid-start.js +14 -0
- package/dist/solid-start.js.map +1 -0
- package/dist/solid.d.ts +2790 -0
- package/dist/solid.js +306 -0
- package/dist/solid.js.map +1 -0
- package/dist/statement-COylZd3J.d.ts +81 -0
- package/dist/svelte-kit.d.ts +10 -7
- package/dist/svelte-kit.js +12 -17
- package/dist/svelte-kit.js.map +1 -1
- package/dist/svelte.d.ts +2791 -0
- package/dist/svelte.js +304 -0
- package/dist/svelte.js.map +1 -0
- package/dist/type-DbMyI3b5.d.ts +5724 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/dist/vue.d.ts +14 -0
- package/dist/vue.js +311 -0
- package/dist/vue.js.map +1 -0
- package/package.json +80 -54
- package/LICENSE +0 -21
- package/dist/actions.d.ts +0 -33
- package/dist/actions.js +0 -1373
- package/dist/actions.js.map +0 -1
- package/dist/adapters/drizzle-adapter.d.ts +0 -10
- package/dist/adapters/drizzle-adapter.js +0 -1095
- package/dist/adapters/drizzle-adapter.js.map +0 -1
- package/dist/adapters/memory.d.ts +0 -8
- package/dist/adapters/memory.js +0 -136
- package/dist/adapters/memory.js.map +0 -1
- package/dist/adapters/mongodb-adapter.d.ts +0 -9
- package/dist/adapters/mongodb-adapter.js +0 -97
- package/dist/adapters/mongodb-adapter.js.map +0 -1
- package/dist/adapters/prisma-adapter.d.ts +0 -7
- package/dist/adapters/prisma-adapter.js +0 -144
- package/dist/adapters/prisma-adapter.js.map +0 -1
- package/dist/adapters/redis-adapter.d.ts +0 -7
- package/dist/adapters/redis-adapter.js +0 -65
- package/dist/adapters/redis-adapter.js.map +0 -1
- package/dist/adapters.d.ts +0 -3
- package/dist/adapters.js +0 -206
- package/dist/adapters.js.map +0 -1
- package/dist/h3.d.ts +0 -10
- package/dist/h3.js +0 -326
- package/dist/h3.js.map +0 -1
- package/dist/hono.d.ts +0 -10
- package/dist/hono.js +0 -25
- package/dist/hono.js.map +0 -1
- package/dist/index-UcTu1vUg.d.ts +0 -107
- package/dist/next.d.ts +0 -17
- package/dist/next.js +0 -26
- package/dist/next.js.map +0 -1
- package/dist/options-CH15FEBw.d.ts +0 -1562
- package/dist/providers.d.ts +0 -3
- package/dist/providers.js +0 -653
- package/dist/providers.js.map +0 -1
- package/dist/routes/session.d.ts +0 -39
- package/dist/routes/session.js +0 -128
- package/dist/routes/session.js.map +0 -1
- package/dist/types-DAxaMWCy.d.ts +0 -136
package/dist/types.d.ts
ADDED
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/vue.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import '@vue/reactivity';
|
|
2
|
+
import 'nanostores';
|
|
3
|
+
import './index-W5nXvJ-p.js';
|
|
4
|
+
import 'zod';
|
|
5
|
+
import './helper-B5_2Vzba.js';
|
|
6
|
+
export { d as createAuthClient, a as useAuthStore } from './type-DbMyI3b5.js';
|
|
7
|
+
import '@better-fetch/fetch';
|
|
8
|
+
import 'better-call';
|
|
9
|
+
import '@nanostores/vue';
|
|
10
|
+
import './schema-BOszzrbQ.js';
|
|
11
|
+
import 'arctic';
|
|
12
|
+
import 'kysely';
|
|
13
|
+
import '@nanostores/react';
|
|
14
|
+
import '@nanostores/solid';
|
package/dist/vue.js
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
// src/client/vue.ts
|
|
2
|
+
import { useStore } from "@nanostores/vue";
|
|
3
|
+
|
|
4
|
+
// src/client/base.ts
|
|
5
|
+
import { createFetch } from "@better-fetch/fetch";
|
|
6
|
+
|
|
7
|
+
// src/error/better-auth-error.ts
|
|
8
|
+
var BetterAuthError = class extends Error {
|
|
9
|
+
constructor(message) {
|
|
10
|
+
super(message);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// src/utils/base-url.ts
|
|
15
|
+
function checkHasPath(url) {
|
|
16
|
+
try {
|
|
17
|
+
const parsedUrl = new URL(url);
|
|
18
|
+
return parsedUrl.pathname !== "/";
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.error("Invalid URL:", error);
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function withPath(url, path = "/api/auth") {
|
|
25
|
+
const hasPath = checkHasPath(url);
|
|
26
|
+
if (hasPath) {
|
|
27
|
+
return {
|
|
28
|
+
baseURL: new URL(url).origin,
|
|
29
|
+
withPath: url
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
path = path.startsWith("/") ? path : `/${path}`;
|
|
33
|
+
return {
|
|
34
|
+
baseURL: url,
|
|
35
|
+
withPath: `${url}${path}`
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function getBaseURL(url, path) {
|
|
39
|
+
if (url) {
|
|
40
|
+
return withPath(url, path);
|
|
41
|
+
}
|
|
42
|
+
const env = typeof process !== "undefined" ? process.env : typeof import.meta !== "undefined" ? (
|
|
43
|
+
//@ts-ignore
|
|
44
|
+
import.meta.env
|
|
45
|
+
) : {};
|
|
46
|
+
const fromEnv = env.BETTER_AUTH_URL || env.AUTH_URL || env.NEXT_PUBLIC_AUTH_URL || env.NEXT_PUBLIC_BETTER_AUTH_URL || env.PUBLIC_AUTH_URL || env.PUBLIC_BETTER_AUTH_URL || env.NUXT_PUBLIC_BETTER_AUTH_URL || env.NUXT_PUBLIC_AUTH_URL;
|
|
47
|
+
if (fromEnv) {
|
|
48
|
+
return withPath(fromEnv, path);
|
|
49
|
+
}
|
|
50
|
+
const isDev = !fromEnv && (env.NODE_ENV === "development" || env.NODE_ENV === "test");
|
|
51
|
+
if (isDev) {
|
|
52
|
+
return {
|
|
53
|
+
baseURL: "http://localhost:3000",
|
|
54
|
+
withPath: "http://localhost:3000/api/auth"
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
throw new BetterAuthError(
|
|
58
|
+
"Could not infer baseURL from environment variables"
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// src/client/fetch-plugins.ts
|
|
63
|
+
import { betterFetch } from "@better-fetch/fetch";
|
|
64
|
+
var redirectPlugin = {
|
|
65
|
+
id: "redirect",
|
|
66
|
+
name: "Redirect",
|
|
67
|
+
hooks: {
|
|
68
|
+
onSuccess(context) {
|
|
69
|
+
if (context.data?.url && context.data?.redirect) {
|
|
70
|
+
window.location.href = context.data.url;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
var addCurrentURL = {
|
|
76
|
+
id: "add-current-url",
|
|
77
|
+
name: "Add current URL",
|
|
78
|
+
hooks: {
|
|
79
|
+
onRequest(context) {
|
|
80
|
+
if (typeof window !== "undefined") {
|
|
81
|
+
const url = new URL(context.url);
|
|
82
|
+
url.searchParams.set("currentURL", window.location.href);
|
|
83
|
+
context.url = url;
|
|
84
|
+
}
|
|
85
|
+
return context;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
var csrfPlugin = {
|
|
90
|
+
id: "csrf",
|
|
91
|
+
name: "CSRF Check",
|
|
92
|
+
async init(url, options) {
|
|
93
|
+
if (options?.method !== "GET") {
|
|
94
|
+
options = options || {};
|
|
95
|
+
const { data, error } = await betterFetch("/csrf", {
|
|
96
|
+
body: void 0,
|
|
97
|
+
baseURL: options.baseURL,
|
|
98
|
+
plugins: [],
|
|
99
|
+
method: "GET",
|
|
100
|
+
credentials: "include"
|
|
101
|
+
});
|
|
102
|
+
if (error?.status === 404) {
|
|
103
|
+
throw new BetterAuthError(
|
|
104
|
+
"Route not found. Make sure the server is running and the base URL is correct and includes the path (e.g. http://localhost:3000/api/auth)."
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
if (error) {
|
|
108
|
+
throw new BetterAuthError(error.message || "Failed to get CSRF token.");
|
|
109
|
+
}
|
|
110
|
+
options.body = {
|
|
111
|
+
...options?.body,
|
|
112
|
+
csrfToken: data.csrfToken
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
options.credentials = "include";
|
|
116
|
+
return { url, options };
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
// src/client/proxy.ts
|
|
121
|
+
function getMethod(path, knownPathMethods, args) {
|
|
122
|
+
const method = knownPathMethods[path];
|
|
123
|
+
const { options, query, ...body } = args || {};
|
|
124
|
+
if (method) {
|
|
125
|
+
return method;
|
|
126
|
+
}
|
|
127
|
+
if (options?.method) {
|
|
128
|
+
return options.method;
|
|
129
|
+
}
|
|
130
|
+
if (body && Object.keys(body).length > 0) {
|
|
131
|
+
return "POST";
|
|
132
|
+
}
|
|
133
|
+
return "GET";
|
|
134
|
+
}
|
|
135
|
+
function createDynamicPathProxy(routes, client, knownPathMethods, $signal, $signals) {
|
|
136
|
+
function createProxy(path = []) {
|
|
137
|
+
return new Proxy(function() {
|
|
138
|
+
}, {
|
|
139
|
+
get(target, prop) {
|
|
140
|
+
const fullPath = [...path, prop];
|
|
141
|
+
let current = routes;
|
|
142
|
+
for (const segment of fullPath) {
|
|
143
|
+
if (current && typeof current === "object" && segment in current) {
|
|
144
|
+
current = current[segment];
|
|
145
|
+
} else {
|
|
146
|
+
current = void 0;
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (typeof current === "function") {
|
|
151
|
+
return current;
|
|
152
|
+
}
|
|
153
|
+
return createProxy(fullPath);
|
|
154
|
+
},
|
|
155
|
+
apply: async (_, __, args) => {
|
|
156
|
+
const routePath = "/" + path.map(
|
|
157
|
+
(segment) => segment.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)
|
|
158
|
+
).join("/");
|
|
159
|
+
const arg = args[0] || {};
|
|
160
|
+
const method = getMethod(routePath, knownPathMethods, arg);
|
|
161
|
+
const { query, options, ...body } = arg;
|
|
162
|
+
return await client(routePath, {
|
|
163
|
+
...options,
|
|
164
|
+
body: method === "GET" ? void 0 : body,
|
|
165
|
+
query,
|
|
166
|
+
method,
|
|
167
|
+
async onSuccess(context) {
|
|
168
|
+
const signal = $signal?.find((s) => s.matcher(routePath));
|
|
169
|
+
if (!signal) return;
|
|
170
|
+
const signalAtom = $signals?.[signal.atom];
|
|
171
|
+
if (!signalAtom) return;
|
|
172
|
+
signalAtom.set(!signalAtom.get());
|
|
173
|
+
await options?.onSuccess?.(context);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
return createProxy();
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// src/client/session-atom.ts
|
|
183
|
+
import { atom, computed, task } from "nanostores";
|
|
184
|
+
function getSessionAtom(client) {
|
|
185
|
+
const $signal = atom(false);
|
|
186
|
+
const $session = computed(
|
|
187
|
+
$signal,
|
|
188
|
+
() => task(async () => {
|
|
189
|
+
const session = await client("/session", {
|
|
190
|
+
credentials: "include",
|
|
191
|
+
method: "GET"
|
|
192
|
+
});
|
|
193
|
+
return session.data;
|
|
194
|
+
})
|
|
195
|
+
);
|
|
196
|
+
return { $session, $sessionSignal: $signal };
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// src/client/base.ts
|
|
200
|
+
var createAuthFetch = (options) => {
|
|
201
|
+
const $baseFetch = createFetch();
|
|
202
|
+
return createFetch({
|
|
203
|
+
method: "GET",
|
|
204
|
+
...options,
|
|
205
|
+
baseURL: getBaseURL(options?.baseURL).withPath,
|
|
206
|
+
plugins: [
|
|
207
|
+
...options?.plugins || [],
|
|
208
|
+
...options?.authPlugins?.flatMap((plugin) => plugin($baseFetch).fetchPlugins).filter((plugin) => plugin !== void 0) || [],
|
|
209
|
+
...options?.csrfPlugin !== false ? [csrfPlugin] : [],
|
|
210
|
+
redirectPlugin,
|
|
211
|
+
addCurrentURL
|
|
212
|
+
]
|
|
213
|
+
});
|
|
214
|
+
};
|
|
215
|
+
var createAuthClient = (options, additionalActions = {}) => {
|
|
216
|
+
const $fetch = createAuthFetch(options);
|
|
217
|
+
const { $session, $sessionSignal } = getSessionAtom($fetch);
|
|
218
|
+
let pluginsActions = {};
|
|
219
|
+
const pluginProxySignals = [];
|
|
220
|
+
let pluginSignals = {};
|
|
221
|
+
let pluginPathMethods = {};
|
|
222
|
+
for (const plugin of options?.authPlugins || []) {
|
|
223
|
+
const pl = plugin($fetch);
|
|
224
|
+
if (pl.authProxySignal) {
|
|
225
|
+
pluginProxySignals.push(...pl.authProxySignal);
|
|
226
|
+
}
|
|
227
|
+
if (pl.actions) {
|
|
228
|
+
pluginsActions = {
|
|
229
|
+
...pluginsActions,
|
|
230
|
+
...pl.actions
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
if (pl.signals) {
|
|
234
|
+
pluginSignals = {
|
|
235
|
+
...pluginSignals,
|
|
236
|
+
...pl.signals
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
if (pl.pathMethods) {
|
|
240
|
+
pluginPathMethods = {
|
|
241
|
+
...pluginPathMethods,
|
|
242
|
+
...pl.pathMethods
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
const actions = {
|
|
247
|
+
$atoms: {
|
|
248
|
+
$session
|
|
249
|
+
},
|
|
250
|
+
$fetch,
|
|
251
|
+
...pluginsActions,
|
|
252
|
+
...additionalActions
|
|
253
|
+
};
|
|
254
|
+
const proxy = createDynamicPathProxy(
|
|
255
|
+
actions,
|
|
256
|
+
$fetch,
|
|
257
|
+
{
|
|
258
|
+
...pluginPathMethods,
|
|
259
|
+
"/sign-out": "POST"
|
|
260
|
+
},
|
|
261
|
+
[
|
|
262
|
+
{
|
|
263
|
+
matcher: (path) => path === "/organization/create",
|
|
264
|
+
atom: "$listOrg"
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
matcher: (path) => path.startsWith("/organization"),
|
|
268
|
+
atom: "$activeOrgSignal"
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
matcher: (path) => path === "/sign-out" || path.startsWith("/sign-up") || path.startsWith("/sign-in"),
|
|
272
|
+
atom: "$sessionSignal"
|
|
273
|
+
},
|
|
274
|
+
...pluginProxySignals
|
|
275
|
+
],
|
|
276
|
+
{
|
|
277
|
+
$sessionSignal,
|
|
278
|
+
...pluginSignals
|
|
279
|
+
}
|
|
280
|
+
);
|
|
281
|
+
return proxy;
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
// src/client/vue.ts
|
|
285
|
+
var createAuthClient2 = (options) => {
|
|
286
|
+
const $fetch = createAuthFetch(options);
|
|
287
|
+
const hooks = options?.authPlugins?.reduce(
|
|
288
|
+
(acc, plugin) => {
|
|
289
|
+
return {
|
|
290
|
+
...acc,
|
|
291
|
+
...plugin($fetch).integrations?.vue?.(useStore) || {}
|
|
292
|
+
};
|
|
293
|
+
},
|
|
294
|
+
{}
|
|
295
|
+
);
|
|
296
|
+
const client = createAuthClient(options, hooks);
|
|
297
|
+
function useSession() {
|
|
298
|
+
return useStore(client.$atoms.$session);
|
|
299
|
+
}
|
|
300
|
+
const obj = Object.assign(client, {
|
|
301
|
+
useSession,
|
|
302
|
+
...hooks
|
|
303
|
+
});
|
|
304
|
+
return obj;
|
|
305
|
+
};
|
|
306
|
+
var useAuthStore = useStore;
|
|
307
|
+
export {
|
|
308
|
+
createAuthClient2 as createAuthClient,
|
|
309
|
+
useAuthStore
|
|
310
|
+
};
|
|
311
|
+
//# sourceMappingURL=vue.js.map
|
package/dist/vue.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/client/vue.ts","../src/client/base.ts","../src/error/better-auth-error.ts","../src/utils/base-url.ts","../src/client/fetch-plugins.ts","../src/client/proxy.ts","../src/client/session-atom.ts"],"sourcesContent":["import { useStore } from \"@nanostores/vue\";\nimport { createAuthFetch, createAuthClient as createClient } from \"./base\";\nimport type { AuthPlugin, ClientOptions } from \"./type\";\nimport type { UnionToIntersection } from \"../types/helper\";\n\nexport const createAuthClient = <O extends ClientOptions>(options?: O) => {\n\tconst $fetch = createAuthFetch(options);\n\tconst hooks = options?.authPlugins?.reduce(\n\t\t(acc, plugin) => {\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t...(plugin($fetch).integrations?.vue?.(useStore) || {}),\n\t\t\t};\n\t\t},\n\t\t{} as Record<string, any>,\n\t) as O[\"authPlugins\"] extends Array<infer Pl>\n\t\t? Pl extends AuthPlugin\n\t\t\t? UnionToIntersection<\n\t\t\t\t\tReturnType<Pl>[\"integrations\"] extends\n\t\t\t\t\t\t| {\n\t\t\t\t\t\t\t\tvue?: (useStore: any) => infer R;\n\t\t\t\t\t\t }\n\t\t\t\t\t\t| undefined\n\t\t\t\t\t\t? R\n\t\t\t\t\t\t: {}\n\t\t\t\t>\n\t\t\t: {}\n\t\t: {};\n\tconst client = createClient(options, hooks);\n\tfunction useSession() {\n\t\treturn useStore(client.$atoms.$session);\n\t}\n\tconst obj = Object.assign(client, {\n\t\tuseSession,\n\t\t...hooks,\n\t});\n\treturn obj;\n};\n\nexport const useAuthStore = useStore;\n","import { createFetch } from \"@better-fetch/fetch\";\nimport type { Auth } from \"../auth\";\nimport { getBaseURL } from \"../utils/base-url\";\nimport { addCurrentURL, csrfPlugin, redirectPlugin } from \"./fetch-plugins\";\nimport type { InferRoutes } from \"./path-to-object\";\nimport { createDynamicPathProxy, type AuthProxySignal } from \"./proxy\";\nimport { getSessionAtom } from \"./session-atom\";\nimport type { AuthPlugin, ClientOptions } from \"./type\";\nimport type { UnionToIntersection } from \"../types/helper\";\nimport type { PreinitializedWritableAtom } from \"nanostores\";\nimport type { BetterAuthPlugin } from \"../types/plugins\";\n\n/**\n * used for plugins only\n */\n\nexport const createAuthFetch = (options?: ClientOptions) => {\n\tconst $baseFetch = createFetch();\n\treturn createFetch({\n\t\tmethod: \"GET\",\n\t\t...options,\n\t\tbaseURL: getBaseURL(options?.baseURL).withPath,\n\t\tplugins: [\n\t\t\t...(options?.plugins || []),\n\t\t\t...(options?.authPlugins\n\t\t\t\t?.flatMap((plugin) => plugin($baseFetch).fetchPlugins)\n\t\t\t\t.filter((plugin) => plugin !== undefined) || []),\n\t\t\t...(options?.csrfPlugin !== false ? [csrfPlugin] : []),\n\t\t\tredirectPlugin,\n\t\t\taddCurrentURL,\n\t\t],\n\t});\n};\n\nexport const createAuthClient = <\n\tO extends ClientOptions = ClientOptions,\n\tAT extends Record<string, any> = {},\n>(\n\toptions?: O,\n\tadditionalActions = {} as AT,\n) => {\n\ttype API = O[\"authPlugins\"] extends Array<any>\n\t\t? (O[\"authPlugins\"] extends Array<infer Pl>\n\t\t\t\t? UnionToIntersection<\n\t\t\t\t\t\t//@ts-expect-error\n\t\t\t\t\t\tReturnType<Pl> extends {\n\t\t\t\t\t\t\tplugin: infer Plug;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\t? Plug extends BetterAuthPlugin\n\t\t\t\t\t\t\t\t? Plug[\"endpoints\"]\n\t\t\t\t\t\t\t\t: {}\n\t\t\t\t\t\t\t: {}\n\t\t\t\t\t>\n\t\t\t\t: {}) &\n\t\t\t\tAuth[\"api\"]\n\t\t: Auth[\"api\"];\n\n\tconst $fetch = createAuthFetch(options);\n\n\ttype Plugins = O[\"authPlugins\"] extends Array<AuthPlugin>\n\t\t? Array<ReturnType<O[\"authPlugins\"][number]>[\"plugin\"]>\n\t\t: undefined;\n\t//@ts-expect-error\n\tconst { $session, $sessionSignal } = getSessionAtom<{\n\t\thandler: any;\n\t\tapi: any;\n\t\toptions: {\n\t\t\tdatabase: any;\n\t\t\tplugins: Plugins;\n\t\t};\n\t}>($fetch);\n\n\tlet pluginsActions = {} as Record<string, any>;\n\ttype PluginActions = UnionToIntersection<\n\t\tO[\"authPlugins\"] extends Array<infer Pl>\n\t\t\t? //@ts-expect-error\n\t\t\t\tReturnType<Pl> extends {\n\t\t\t\t\tactions?: infer R;\n\t\t\t\t}\n\t\t\t\t? R\n\t\t\t\t: {}\n\t\t\t: {}\n\t>;\n\n\tconst pluginProxySignals: AuthProxySignal[] = [];\n\tlet pluginSignals: Record<string, PreinitializedWritableAtom<boolean>> = {};\n\tlet pluginPathMethods: Record<string, \"POST\" | \"GET\"> = {};\n\n\tfor (const plugin of options?.authPlugins || []) {\n\t\tconst pl = plugin($fetch);\n\t\tif (pl.authProxySignal) {\n\t\t\tpluginProxySignals.push(...pl.authProxySignal);\n\t\t}\n\t\tif (pl.actions) {\n\t\t\tpluginsActions = {\n\t\t\t\t...pluginsActions,\n\t\t\t\t...pl.actions,\n\t\t\t};\n\t\t}\n\t\tif (pl.signals) {\n\t\t\tpluginSignals = {\n\t\t\t\t...pluginSignals,\n\t\t\t\t...pl.signals,\n\t\t\t};\n\t\t}\n\t\tif (pl.pathMethods) {\n\t\t\tpluginPathMethods = {\n\t\t\t\t...pluginPathMethods,\n\t\t\t\t...pl.pathMethods,\n\t\t\t};\n\t\t}\n\t}\n\n\tconst actions = {\n\t\t$atoms: {\n\t\t\t$session,\n\t\t},\n\t\t$fetch,\n\t\t...(pluginsActions as object),\n\t\t...additionalActions,\n\t};\n\n\ttype Actions = typeof actions & PluginActions;\n\n\tconst proxy = createDynamicPathProxy(\n\t\tactions,\n\t\t$fetch,\n\t\t{\n\t\t\t...pluginPathMethods,\n\t\t\t\"/sign-out\": \"POST\",\n\t\t},\n\t\t[\n\t\t\t{\n\t\t\t\tmatcher: (path) => path === \"/organization/create\",\n\t\t\t\tatom: \"$listOrg\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tmatcher: (path) => path.startsWith(\"/organization\"),\n\t\t\t\tatom: \"$activeOrgSignal\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tmatcher: (path) =>\n\t\t\t\t\tpath === \"/sign-out\" ||\n\t\t\t\t\tpath.startsWith(\"/sign-up\") ||\n\t\t\t\t\tpath.startsWith(\"/sign-in\"),\n\t\t\t\tatom: \"$sessionSignal\",\n\t\t\t},\n\t\t\t...pluginProxySignals,\n\t\t],\n\t\t{\n\t\t\t$sessionSignal,\n\t\t\t...pluginSignals,\n\t\t},\n\t) as unknown as InferRoutes<API> & Actions;\n\treturn proxy;\n};\n","export class BetterAuthError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t}\n}\n","import { BetterAuthError } from \"../error/better-auth-error\";\n\nfunction checkHasPath(url: string): boolean {\n\ttry {\n\t\tconst parsedUrl = new URL(url);\n\t\treturn parsedUrl.pathname !== \"/\";\n\t} catch (error) {\n\t\tconsole.error(\"Invalid URL:\", error);\n\t\treturn false;\n\t}\n}\n\nfunction withPath(url: string, path = \"/api/auth\") {\n\tconst hasPath = checkHasPath(url);\n\tif (hasPath) {\n\t\treturn {\n\t\t\tbaseURL: new URL(url).origin,\n\t\t\twithPath: url,\n\t\t};\n\t}\n\tpath = path.startsWith(\"/\") ? path : `/${path}`;\n\treturn {\n\t\tbaseURL: url,\n\t\twithPath: `${url}${path}`,\n\t};\n}\n\nexport function getBaseURL(url?: string, path?: string) {\n\tif (url) {\n\t\treturn withPath(url, path);\n\t}\n\t//@ts-ignore\n\tconst env: any =\n\t\ttypeof process !== \"undefined\"\n\t\t\t? process.env\n\t\t\t: typeof import.meta !== \"undefined\"\n\t\t\t\t? //@ts-ignore\n\t\t\t\t\timport.meta.env\n\t\t\t\t: {};\n\tconst fromEnv =\n\t\tenv.BETTER_AUTH_URL ||\n\t\tenv.AUTH_URL ||\n\t\tenv.NEXT_PUBLIC_AUTH_URL ||\n\t\tenv.NEXT_PUBLIC_BETTER_AUTH_URL ||\n\t\tenv.PUBLIC_AUTH_URL ||\n\t\tenv.PUBLIC_BETTER_AUTH_URL ||\n\t\tenv.NUXT_PUBLIC_BETTER_AUTH_URL ||\n\t\tenv.NUXT_PUBLIC_AUTH_URL;\n\tif (fromEnv) {\n\t\treturn withPath(fromEnv, path);\n\t}\n\n\tconst isDev =\n\t\t!fromEnv && (env.NODE_ENV === \"development\" || env.NODE_ENV === \"test\");\n\tif (isDev) {\n\t\treturn {\n\t\t\tbaseURL: \"http://localhost:3000\",\n\t\t\twithPath: \"http://localhost:3000/api/auth\",\n\t\t};\n\t}\n\tthrow new BetterAuthError(\n\t\t\"Could not infer baseURL from environment variables\",\n\t);\n}\n","import { type BetterFetchPlugin, betterFetch } from \"@better-fetch/fetch\";\nimport { BetterAuthError } from \"../error/better-auth-error\";\n\nexport const redirectPlugin = {\n\tid: \"redirect\",\n\tname: \"Redirect\",\n\thooks: {\n\t\tonSuccess(context) {\n\t\t\tif (context.data?.url && context.data?.redirect) {\n\t\t\t\twindow.location.href = context.data.url;\n\t\t\t}\n\t\t},\n\t},\n} satisfies BetterFetchPlugin;\n\nexport const addCurrentURL = {\n\tid: \"add-current-url\",\n\tname: \"Add current URL\",\n\thooks: {\n\t\tonRequest(context) {\n\t\t\tif (typeof window !== \"undefined\") {\n\t\t\t\tconst url = new URL(context.url);\n\t\t\t\turl.searchParams.set(\"currentURL\", window.location.href);\n\t\t\t\tcontext.url = url;\n\t\t\t}\n\t\t\treturn context;\n\t\t},\n\t},\n} satisfies BetterFetchPlugin;\n\nexport const csrfPlugin = {\n\tid: \"csrf\",\n\tname: \"CSRF Check\",\n\tasync init(url, options) {\n\t\tif (options?.method !== \"GET\") {\n\t\t\toptions = options || {};\n\t\t\tconst { data, error } = await betterFetch<{\n\t\t\t\tcsrfToken: string;\n\t\t\t}>(\"/csrf\", {\n\t\t\t\tbody: undefined,\n\t\t\t\tbaseURL: options.baseURL,\n\t\t\t\tplugins: [],\n\t\t\t\tmethod: \"GET\",\n\t\t\t\tcredentials: \"include\",\n\t\t\t});\n\t\t\tif (error?.status === 404) {\n\t\t\t\tthrow new BetterAuthError(\n\t\t\t\t\t\"Route not found. Make sure the server is running and the base URL is correct and includes the path (e.g. http://localhost:3000/api/auth).\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (error) {\n\t\t\t\tthrow new BetterAuthError(error.message || \"Failed to get CSRF token.\");\n\t\t\t}\n\t\t\toptions.body = {\n\t\t\t\t...options?.body,\n\t\t\t\tcsrfToken: data.csrfToken,\n\t\t\t};\n\t\t}\n\t\toptions.credentials = \"include\";\n\t\treturn { url, options };\n\t},\n} satisfies BetterFetchPlugin;\n","import type { BetterFetch } from \"@better-fetch/fetch\";\nimport type { PreinitializedWritableAtom } from \"nanostores\";\nimport type { ProxyRequest } from \"./path-to-object\";\nimport type { LiteralUnion } from \"../types/helper\";\n\nfunction getMethod(\n\tpath: string,\n\tknownPathMethods: Record<string, \"POST\" | \"GET\">,\n\targs?: ProxyRequest,\n) {\n\tconst method = knownPathMethods[path];\n\tconst { options, query, ...body } = args || {};\n\tif (method) {\n\t\treturn method;\n\t}\n\tif (options?.method) {\n\t\treturn options.method;\n\t}\n\tif (body && Object.keys(body).length > 0) {\n\t\treturn \"POST\";\n\t}\n\treturn \"GET\";\n}\n\nexport type AuthProxySignal = {\n\tatom: LiteralUnion<string, \"$sessionSignal\">;\n\tmatcher: (path: string) => boolean;\n};\n\nexport function createDynamicPathProxy<T extends Record<string, any>>(\n\troutes: T,\n\tclient: BetterFetch,\n\tknownPathMethods: Record<string, \"POST\" | \"GET\">,\n\t$signal?: AuthProxySignal[],\n\t$signals?: Record<string, PreinitializedWritableAtom<boolean>>,\n): T {\n\tfunction createProxy(path: string[] = []): any {\n\t\treturn new Proxy(function () {}, {\n\t\t\tget(target, prop: string) {\n\t\t\t\tconst fullPath = [...path, prop];\n\t\t\t\tlet current: any = routes;\n\t\t\t\tfor (const segment of fullPath) {\n\t\t\t\t\tif (current && typeof current === \"object\" && segment in current) {\n\t\t\t\t\t\tcurrent = current[segment];\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcurrent = undefined;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (typeof current === \"function\") {\n\t\t\t\t\treturn current;\n\t\t\t\t}\n\n\t\t\t\treturn createProxy(fullPath);\n\t\t\t},\n\t\t\tapply: async (_, __, args) => {\n\t\t\t\tconst routePath =\n\t\t\t\t\t\"/\" +\n\t\t\t\t\tpath\n\t\t\t\t\t\t.map((segment) =>\n\t\t\t\t\t\t\tsegment.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`),\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.join(\"/\");\n\n\t\t\t\tconst arg = (args[0] || {}) as ProxyRequest;\n\t\t\t\tconst method = getMethod(routePath, knownPathMethods, arg);\n\t\t\t\tconst { query, options, ...body } = arg;\n\n\t\t\t\treturn await client(routePath, {\n\t\t\t\t\t...options,\n\t\t\t\t\tbody: method === \"GET\" ? undefined : body,\n\t\t\t\t\tquery: query,\n\t\t\t\t\tmethod,\n\t\t\t\t\tasync onSuccess(context) {\n\t\t\t\t\t\tconst signal = $signal?.find((s) => s.matcher(routePath));\n\t\t\t\t\t\tif (!signal) return;\n\t\t\t\t\t\tconst signalAtom = $signals?.[signal.atom];\n\t\t\t\t\t\tif (!signalAtom) return;\n\t\t\t\t\t\tsignalAtom.set(!signalAtom.get());\n\t\t\t\t\t\tawait options?.onSuccess?.(context);\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t},\n\t\t});\n\t}\n\n\treturn createProxy() as T;\n}\n","import type { BetterFetch } from \"@better-fetch/fetch\";\nimport { atom, computed, task } from \"nanostores\";\nimport type { Auth as BetterAuth } from \"../auth\";\nimport type { Prettify } from \"../types/helper\";\nimport type { InferSession, InferUser } from \"../types/models\";\n\nexport function getSessionAtom<Auth extends BetterAuth>(client: BetterFetch) {\n\ttype UserWithAdditionalFields = InferUser<Auth[\"options\"]>;\n\ttype SessionWithAdditionalFields = InferSession<Auth[\"options\"]>;\n\tconst $signal = atom<boolean>(false);\n\tconst $session = computed($signal, () =>\n\t\ttask(async () => {\n\t\t\tconst session = await client(\"/session\", {\n\t\t\t\tcredentials: \"include\",\n\t\t\t\tmethod: \"GET\",\n\t\t\t});\n\t\t\treturn session.data as {\n\t\t\t\tuser: Prettify<UserWithAdditionalFields>;\n\t\t\t\tsession: Prettify<SessionWithAdditionalFields>;\n\t\t\t} | null;\n\t\t}),\n\t);\n\treturn { $session, $sessionSignal: $signal };\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;;;ACAzB,SAAS,mBAAmB;;;ACArB,IAAM,kBAAN,cAA8B,MAAM;AAAA,EAC1C,YAAY,SAAiB;AAC5B,UAAM,OAAO;AAAA,EACd;AACD;;;ACFA,SAAS,aAAa,KAAsB;AAC3C,MAAI;AACH,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SAAS,KAAK;AAC1C,WAAS,aAAa;AACrB,WAAO,SAAS,OAAO,OAAO,QAAQ;AAAA,EACvC;AACA,QAAM,MAAM,OAAO,OAAO,QAAQ;AAAA,IACjC;AAAA,IACA,GAAG;AAAA,EACJ,CAAC;AACD,SAAO;AACR;AAEO,IAAM,eAAe;","names":["createAuthClient"]}
|
package/package.json
CHANGED
|
@@ -1,73 +1,99 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "better-auth",
|
|
3
|
-
"version": "0.0.2
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Framework-agnostic, batteries included authentication library for typescript",
|
|
4
5
|
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"bin": "./dist/cli.js",
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"executableFiles": [
|
|
11
|
+
"./dist/cli.js"
|
|
12
|
+
]
|
|
13
|
+
},
|
|
5
14
|
"exports": {
|
|
6
15
|
".": "./dist/index.js",
|
|
7
|
-
"./
|
|
8
|
-
"./
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"./
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
"./social-providers": "./dist/social.js",
|
|
17
|
+
"./client": {
|
|
18
|
+
"import": "./dist/client.js",
|
|
19
|
+
"types": "./dist/client.d.ts"
|
|
20
|
+
},
|
|
21
|
+
"./client/plugins": {
|
|
22
|
+
"import": "./dist/client/plugins.js",
|
|
23
|
+
"types": "./dist/client/plugins.d.ts"
|
|
24
|
+
},
|
|
25
|
+
"./types": "./dist/types.js",
|
|
26
|
+
"./cli": "./dist/cli.js",
|
|
27
|
+
"./react": "./dist/react.js",
|
|
28
|
+
"./preact": "./dist/preact.js",
|
|
29
|
+
"./solid": "./dist/solid.js",
|
|
30
|
+
"./vue": "./dist/vue.js",
|
|
15
31
|
"./plugins": "./dist/plugins.js",
|
|
16
|
-
"./
|
|
17
|
-
"./
|
|
18
|
-
"./
|
|
19
|
-
"./
|
|
20
|
-
"./
|
|
21
|
-
"./
|
|
32
|
+
"./plugins/access": "./dist/access.js",
|
|
33
|
+
"./svelte-kit": "./dist/svelte-kit.js",
|
|
34
|
+
"./solid-start": "./dist/solid-start.js",
|
|
35
|
+
"./svelte": "./dist/svelte.js",
|
|
36
|
+
"./next-js": "./dist/next-js.js",
|
|
37
|
+
"./package.json": "./package.json"
|
|
22
38
|
},
|
|
23
39
|
"devDependencies": {
|
|
24
|
-
"@
|
|
25
|
-
"@
|
|
26
|
-
"@
|
|
27
|
-
"@
|
|
28
|
-
"@
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"@types/react": "^18.3.2",
|
|
33
|
-
"better-sqlite3": "^10.0.0",
|
|
34
|
-
"cypress": "^13.9.0",
|
|
35
|
-
"drizzle-kit": "^0.21.2",
|
|
36
|
-
"drizzle-orm": "^0.30.10",
|
|
37
|
-
"h3": "^1.11.1",
|
|
38
|
-
"happy-dom": "^14.10.1",
|
|
39
|
-
"hono": "^4.3.5",
|
|
40
|
+
"@simplewebauthn/types": "^10.0.0",
|
|
41
|
+
"@types/better-sqlite3": "^7.6.11",
|
|
42
|
+
"@types/pg": "^8.11.6",
|
|
43
|
+
"@types/prompts": "^2.4.9",
|
|
44
|
+
"@types/react": "^18.3.3",
|
|
45
|
+
"better-sqlite3": "^11.1.2",
|
|
46
|
+
"h3": "^1.12.0",
|
|
47
|
+
"hono": "^4.5.4",
|
|
40
48
|
"listhen": "^1.7.2",
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"vitest": "^1.6.0",
|
|
48
|
-
"@better-auth/shared": "0.0.2-beta.7"
|
|
49
|
+
"react": "^18.3.1",
|
|
50
|
+
"solid-js": "^1.8.18",
|
|
51
|
+
"swr": "^2.2.5",
|
|
52
|
+
"tsup": "^8.2.4",
|
|
53
|
+
"typescript": "5.6.0-beta",
|
|
54
|
+
"vitest": "^1.6.0"
|
|
49
55
|
},
|
|
50
56
|
"dependencies": {
|
|
51
|
-
"@better-fetch/fetch": "^
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
57
|
+
"@better-fetch/fetch": "^1.1.4",
|
|
58
|
+
"@better-fetch/logger": "^1.1.3",
|
|
59
|
+
"@chronark/access-policies": "^0.0.2",
|
|
60
|
+
"@nanostores/query": "^0.3.4",
|
|
61
|
+
"@nanostores/react": "^0.7.3",
|
|
62
|
+
"@nanostores/solid": "^0.4.2",
|
|
63
|
+
"@nanostores/vue": "^0.10.0",
|
|
64
|
+
"@noble/ciphers": "^0.6.0",
|
|
65
|
+
"@noble/hashes": "^1.4.0",
|
|
66
|
+
"@paralleldrive/cuid2": "^2.2.2",
|
|
67
|
+
"@simplewebauthn/browser": "^10.0.0",
|
|
68
|
+
"@simplewebauthn/server": "^10.0.1",
|
|
69
|
+
"arctic": "2.0.0-next.5",
|
|
70
|
+
"better-call": "^0.1.38",
|
|
71
|
+
"chalk": "^5.3.0",
|
|
72
|
+
"commander": "^12.1.0",
|
|
73
|
+
"consola": "^3.2.3",
|
|
74
|
+
"dotenv": "^16.4.5",
|
|
75
|
+
"jiti": "^1.21.6",
|
|
76
|
+
"jose": "^5.7.0",
|
|
77
|
+
"kysely": "^0.27.4",
|
|
78
|
+
"mysql2": "^3.11.0",
|
|
79
|
+
"nanostores": "^0.11.2",
|
|
80
|
+
"oauth4webapi": "^2.12.0",
|
|
81
|
+
"ora": "^8.0.1",
|
|
82
|
+
"oslo": "^1.2.1",
|
|
83
|
+
"pg": "^8.12.0",
|
|
84
|
+
"prompts": "^2.4.2",
|
|
85
|
+
"tiny-glob": "^0.2.9",
|
|
86
|
+
"ts-morph": "^23.0.0",
|
|
58
87
|
"zod": "^3.22.5"
|
|
59
88
|
},
|
|
60
|
-
"simple-git-hooks": {
|
|
61
|
-
"pre-commit": "bun run lint && bun run format"
|
|
62
|
-
},
|
|
63
89
|
"files": [
|
|
64
|
-
"dist"
|
|
90
|
+
"dist/*"
|
|
65
91
|
],
|
|
66
92
|
"scripts": {
|
|
67
|
-
"build": "tsup --clean",
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
93
|
+
"build": "NODE_OPTIONS='--max-old-space-size=16384' tsup --clean",
|
|
94
|
+
"dev": "NODE_OPTIONS='--max-old-space-size=16384' tsup --watch",
|
|
95
|
+
"test": "vitest",
|
|
96
|
+
"bump": "bumpp",
|
|
71
97
|
"typecheck": "tsc --noEmit"
|
|
72
98
|
}
|
|
73
99
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Bereket Engida
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/dist/actions.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { H as HandlerOptions, I as InferProviderSignin, b as InferSession } from './index-UcTu1vUg.js';
|
|
2
|
-
export { A as Actions, c as InferProviderKeys, d as InferRegister } from './index-UcTu1vUg.js';
|
|
3
|
-
import { B as BetterAuthOptions } from './options-CH15FEBw.js';
|
|
4
|
-
import 'node:http';
|
|
5
|
-
import 'zod';
|
|
6
|
-
import './types-DAxaMWCy.js';
|
|
7
|
-
|
|
8
|
-
declare function getActions<O extends BetterAuthOptions>(options: O, handlerOptions?: HandlerOptions): {
|
|
9
|
-
/**
|
|
10
|
-
* Sign in with a provider. This action will return response object. If
|
|
11
|
-
* it's oauth, it will redirect to the provider. If it's custom, it
|
|
12
|
-
* will return the response object and it'll set the cookies.
|
|
13
|
-
*
|
|
14
|
-
* ► In most cases you should just be using
|
|
15
|
-
* client sdk for sign in instead unless you
|
|
16
|
-
* have a good reason to use this.
|
|
17
|
-
*/
|
|
18
|
-
signIn: <T extends InferProviderSignin<O["providers"]>, K extends keyof T>(request: Request | Headers, input: {
|
|
19
|
-
provider: K;
|
|
20
|
-
data?: T[K]["input"];
|
|
21
|
-
}) => Promise<Response>;
|
|
22
|
-
/**
|
|
23
|
-
* Get the current logged in user session.
|
|
24
|
-
*/
|
|
25
|
-
getSession: (request: Request | Headers) => Promise<InferSession<O>>;
|
|
26
|
-
/**
|
|
27
|
-
* Signout the current user.
|
|
28
|
-
* Delete the session and clear the cookies.
|
|
29
|
-
*/
|
|
30
|
-
signOut: (request: Request | Headers) => Promise<Response>;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export { InferProviderSignin, InferSession, getActions };
|