better-auth 0.2.8-beta.8 → 0.2.8
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/.DS_Store +0 -0
- package/dist/access.js +13 -2
- package/dist/adapters/drizzle.d.ts +1 -1
- package/dist/adapters/drizzle.js +13 -23
- package/dist/adapters/mongodb.d.ts +1 -1
- package/dist/adapters/mongodb.js +3 -2
- package/dist/adapters/prisma.d.ts +1 -1
- package/dist/adapters/prisma.js +3 -280
- package/dist/api.d.ts +1 -1
- package/dist/api.js +407 -269
- package/dist/cli.js +213 -55
- package/dist/client/plugins.d.ts +5 -3
- package/dist/client/plugins.js +49 -34
- package/dist/client.d.ts +3 -1
- package/dist/client.js +34 -32
- package/dist/{index-CKn-Zrry.d.ts → index-C9S3KShG.d.ts} +50 -63
- package/dist/{index-DtRHPoYF.d.ts → index-UOcOxfoL.d.ts} +6 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.js +501 -372
- package/dist/next-js.d.ts +1 -1
- package/dist/next-js.js +6 -5
- package/dist/node.d.ts +1 -1
- package/dist/node.js +5 -5
- package/dist/plugins.d.ts +8 -5
- package/dist/plugins.js +716 -498
- package/dist/react.d.ts +4 -2
- package/dist/react.js +37 -33
- package/dist/social.js +116 -68
- package/dist/solid-start.d.ts +1 -1
- package/dist/solid-start.js +3 -2
- package/dist/solid.d.ts +2 -1
- package/dist/solid.js +35 -32
- package/dist/svelte-kit.d.ts +1 -1
- package/dist/svelte-kit.js +6 -4
- package/dist/svelte.d.ts +2 -1
- package/dist/svelte.js +33 -32
- package/dist/types.d.ts +2 -2
- package/dist/types.js +0 -1
- package/dist/vue.d.ts +3 -1
- package/dist/vue.js +35 -32
- package/package.json +2 -3
- package/dist/hide-metadata-DEHJp1rk.d.ts +0 -5
- package/dist/utils.d.ts +0 -51
- package/dist/utils.js +0 -426
package/dist/svelte.js
CHANGED
|
@@ -1,27 +1,5 @@
|
|
|
1
|
-
import { createFetch, betterFetch } from '@better-fetch/fetch';
|
|
2
|
-
import 'oslo';
|
|
3
|
-
import 'nanoid';
|
|
4
|
-
import { createConsola } from 'consola';
|
|
5
|
-
import 'oslo/oauth2';
|
|
6
|
-
import 'zod';
|
|
7
|
-
import { atom, onMount } from 'nanostores';
|
|
8
|
-
|
|
9
1
|
// src/client/config.ts
|
|
10
|
-
|
|
11
|
-
formatOptions: {
|
|
12
|
-
date: false,
|
|
13
|
-
colors: true,
|
|
14
|
-
compact: true
|
|
15
|
-
},
|
|
16
|
-
defaults: {
|
|
17
|
-
tag: "Better Auth"
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
// src/utils/misc.ts
|
|
22
|
-
function capitalizeFirstLetter(str) {
|
|
23
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
24
|
-
}
|
|
2
|
+
import { createFetch } from "@better-fetch/fetch";
|
|
25
3
|
|
|
26
4
|
// src/error/better-auth-error.ts
|
|
27
5
|
var BetterAuthError = class extends Error {
|
|
@@ -67,6 +45,12 @@ function getBaseURL(url, path) {
|
|
|
67
45
|
}
|
|
68
46
|
return void 0;
|
|
69
47
|
}
|
|
48
|
+
|
|
49
|
+
// src/client/config.ts
|
|
50
|
+
import "nanostores";
|
|
51
|
+
|
|
52
|
+
// src/client/fetch-plugins.ts
|
|
53
|
+
import { betterFetch } from "@better-fetch/fetch";
|
|
70
54
|
var redirectPlugin = {
|
|
71
55
|
id: "redirect",
|
|
72
56
|
name: "Redirect",
|
|
@@ -201,6 +185,11 @@ var getClientConfig = (options) => {
|
|
|
201
185
|
};
|
|
202
186
|
};
|
|
203
187
|
|
|
188
|
+
// src/utils/misc.ts
|
|
189
|
+
function capitalizeFirstLetter(str) {
|
|
190
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
191
|
+
}
|
|
192
|
+
|
|
204
193
|
// src/client/proxy.ts
|
|
205
194
|
function getMethod(path, knownPathMethods, args) {
|
|
206
195
|
const method = knownPathMethods[path];
|
|
@@ -273,11 +262,19 @@ function createDynamicPathProxy(routes, client, knownPathMethods, atoms, atomLis
|
|
|
273
262
|
}
|
|
274
263
|
return createProxy();
|
|
275
264
|
}
|
|
265
|
+
|
|
266
|
+
// src/client/session-atom.ts
|
|
267
|
+
import { atom as atom2 } from "nanostores";
|
|
268
|
+
|
|
269
|
+
// src/client/query.ts
|
|
270
|
+
import "@better-fetch/fetch";
|
|
271
|
+
import { atom, onMount } from "nanostores";
|
|
276
272
|
var useAuthQuery = (initializedAtom, path, $fetch, options) => {
|
|
277
273
|
const value = atom({
|
|
278
274
|
data: null,
|
|
279
275
|
error: null,
|
|
280
|
-
isPending: false
|
|
276
|
+
isPending: false,
|
|
277
|
+
isRefetching: false
|
|
281
278
|
});
|
|
282
279
|
const fn = () => {
|
|
283
280
|
const opts = typeof options === "function" ? options({
|
|
@@ -291,24 +288,27 @@ var useAuthQuery = (initializedAtom, path, $fetch, options) => {
|
|
|
291
288
|
value.set({
|
|
292
289
|
data: context.data,
|
|
293
290
|
error: null,
|
|
294
|
-
isPending: false
|
|
291
|
+
isPending: false,
|
|
292
|
+
isRefetching: false
|
|
295
293
|
});
|
|
296
294
|
await opts?.onSuccess?.(context);
|
|
297
295
|
},
|
|
298
296
|
async onError(context) {
|
|
299
297
|
value.set({
|
|
300
298
|
error: context.error,
|
|
301
|
-
data:
|
|
302
|
-
isPending: false
|
|
299
|
+
data: value.get().data,
|
|
300
|
+
isPending: false,
|
|
301
|
+
isRefetching: false
|
|
303
302
|
});
|
|
304
303
|
await opts?.onError?.(context);
|
|
305
304
|
},
|
|
306
305
|
async onRequest(context) {
|
|
307
306
|
const currentValue = value.get();
|
|
308
307
|
value.set({
|
|
309
|
-
isPending:
|
|
308
|
+
isPending: currentValue.data === null,
|
|
310
309
|
data: currentValue.data,
|
|
311
|
-
error:
|
|
310
|
+
error: null,
|
|
311
|
+
isRefetching: true
|
|
312
312
|
});
|
|
313
313
|
await opts?.onRequest?.(context);
|
|
314
314
|
}
|
|
@@ -337,7 +337,7 @@ var useAuthQuery = (initializedAtom, path, $fetch, options) => {
|
|
|
337
337
|
|
|
338
338
|
// src/client/session-atom.ts
|
|
339
339
|
function getSessionAtom($fetch) {
|
|
340
|
-
const $signal =
|
|
340
|
+
const $signal = atom2(false);
|
|
341
341
|
const session = useAuthQuery($signal, "/session", $fetch, {
|
|
342
342
|
method: "GET"
|
|
343
343
|
});
|
|
@@ -379,5 +379,6 @@ function createAuthClient(options) {
|
|
|
379
379
|
);
|
|
380
380
|
return proxy;
|
|
381
381
|
}
|
|
382
|
-
|
|
383
|
-
|
|
382
|
+
export {
|
|
383
|
+
createAuthClient
|
|
384
|
+
};
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { A as Adapter,
|
|
1
|
+
import { b as BetterAuthPlugin, a as Auth, F as FieldAttribute, I as InferFieldOutput } from './index-C9S3KShG.js';
|
|
2
|
+
export { A as Adapter, k as AuthContext, B as BetterAuthOptions, G as GenericEndpointContext, H as HookEndpointContext, i as InferPluginTypes, h as InferSession, g as InferUser, P as PluginSchema, R as RateLimit, S as SessionAdapter, W as Where, j as init } from './index-C9S3KShG.js';
|
|
3
3
|
import { U as UnionToIntersection, H as HasRequiredKeys, P as Prettify, S as StripEmptyObjects, L as LiteralString } from './helper-DPDj8Nix.js';
|
|
4
4
|
export { D as DeepPartial, a as LiteralUnion, R as RequiredKeysOf, W as WithoutEmpty } from './helper-DPDj8Nix.js';
|
|
5
5
|
import { S as Session, U as User } from './index-JM-i6hLs.js';
|
package/dist/types.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
package/dist/vue.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from
|
|
|
3
3
|
import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
|
|
4
4
|
import { Ref, DeepReadonly } from 'vue';
|
|
5
5
|
import 'zod';
|
|
6
|
-
import './index-
|
|
6
|
+
import './index-C9S3KShG.js';
|
|
7
7
|
import 'kysely';
|
|
8
8
|
import './index-JM-i6hLs.js';
|
|
9
9
|
import 'arctic';
|
|
@@ -37,6 +37,7 @@ declare function createAuthClient<Option extends ClientOptions>(options?: Option
|
|
|
37
37
|
} | null;
|
|
38
38
|
readonly error: null | _better_fetch_fetch.BetterFetchError;
|
|
39
39
|
readonly isPending: boolean;
|
|
40
|
+
readonly isRefetching: boolean;
|
|
40
41
|
}, {
|
|
41
42
|
readonly data: {
|
|
42
43
|
readonly user: DeepReadonly<Prettify<StripEmptyObjects<{
|
|
@@ -58,6 +59,7 @@ declare function createAuthClient<Option extends ClientOptions>(options?: Option
|
|
|
58
59
|
} | null;
|
|
59
60
|
readonly error: null | _better_fetch_fetch.BetterFetchError;
|
|
60
61
|
readonly isPending: boolean;
|
|
62
|
+
readonly isRefetching: boolean;
|
|
61
63
|
}>>;
|
|
62
64
|
$Infer: {
|
|
63
65
|
Session: {
|
package/dist/vue.js
CHANGED
|
@@ -1,28 +1,8 @@
|
|
|
1
|
-
import { useStore } from '@nanostores/vue';
|
|
2
|
-
import { createFetch, betterFetch } from '@better-fetch/fetch';
|
|
3
|
-
import 'oslo';
|
|
4
|
-
import 'nanoid';
|
|
5
|
-
import { createConsola } from 'consola';
|
|
6
|
-
import 'oslo/oauth2';
|
|
7
|
-
import 'zod';
|
|
8
|
-
import { atom, onMount } from 'nanostores';
|
|
9
|
-
|
|
10
1
|
// src/client/vue.ts
|
|
11
|
-
|
|
12
|
-
formatOptions: {
|
|
13
|
-
date: false,
|
|
14
|
-
colors: true,
|
|
15
|
-
compact: true
|
|
16
|
-
},
|
|
17
|
-
defaults: {
|
|
18
|
-
tag: "Better Auth"
|
|
19
|
-
}
|
|
20
|
-
});
|
|
2
|
+
import { useStore } from "@nanostores/vue";
|
|
21
3
|
|
|
22
|
-
// src/
|
|
23
|
-
|
|
24
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
25
|
-
}
|
|
4
|
+
// src/client/config.ts
|
|
5
|
+
import { createFetch } from "@better-fetch/fetch";
|
|
26
6
|
|
|
27
7
|
// src/error/better-auth-error.ts
|
|
28
8
|
var BetterAuthError = class extends Error {
|
|
@@ -68,6 +48,12 @@ function getBaseURL(url, path) {
|
|
|
68
48
|
}
|
|
69
49
|
return void 0;
|
|
70
50
|
}
|
|
51
|
+
|
|
52
|
+
// src/client/config.ts
|
|
53
|
+
import "nanostores";
|
|
54
|
+
|
|
55
|
+
// src/client/fetch-plugins.ts
|
|
56
|
+
import { betterFetch } from "@better-fetch/fetch";
|
|
71
57
|
var redirectPlugin = {
|
|
72
58
|
id: "redirect",
|
|
73
59
|
name: "Redirect",
|
|
@@ -202,6 +188,11 @@ var getClientConfig = (options) => {
|
|
|
202
188
|
};
|
|
203
189
|
};
|
|
204
190
|
|
|
191
|
+
// src/utils/misc.ts
|
|
192
|
+
function capitalizeFirstLetter(str) {
|
|
193
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
194
|
+
}
|
|
195
|
+
|
|
205
196
|
// src/client/proxy.ts
|
|
206
197
|
function getMethod(path, knownPathMethods, args) {
|
|
207
198
|
const method = knownPathMethods[path];
|
|
@@ -274,11 +265,19 @@ function createDynamicPathProxy(routes, client, knownPathMethods, atoms, atomLis
|
|
|
274
265
|
}
|
|
275
266
|
return createProxy();
|
|
276
267
|
}
|
|
268
|
+
|
|
269
|
+
// src/client/session-atom.ts
|
|
270
|
+
import { atom as atom2 } from "nanostores";
|
|
271
|
+
|
|
272
|
+
// src/client/query.ts
|
|
273
|
+
import "@better-fetch/fetch";
|
|
274
|
+
import { atom, onMount } from "nanostores";
|
|
277
275
|
var useAuthQuery = (initializedAtom, path, $fetch, options) => {
|
|
278
276
|
const value = atom({
|
|
279
277
|
data: null,
|
|
280
278
|
error: null,
|
|
281
|
-
isPending: false
|
|
279
|
+
isPending: false,
|
|
280
|
+
isRefetching: false
|
|
282
281
|
});
|
|
283
282
|
const fn = () => {
|
|
284
283
|
const opts = typeof options === "function" ? options({
|
|
@@ -292,24 +291,27 @@ var useAuthQuery = (initializedAtom, path, $fetch, options) => {
|
|
|
292
291
|
value.set({
|
|
293
292
|
data: context.data,
|
|
294
293
|
error: null,
|
|
295
|
-
isPending: false
|
|
294
|
+
isPending: false,
|
|
295
|
+
isRefetching: false
|
|
296
296
|
});
|
|
297
297
|
await opts?.onSuccess?.(context);
|
|
298
298
|
},
|
|
299
299
|
async onError(context) {
|
|
300
300
|
value.set({
|
|
301
301
|
error: context.error,
|
|
302
|
-
data:
|
|
303
|
-
isPending: false
|
|
302
|
+
data: value.get().data,
|
|
303
|
+
isPending: false,
|
|
304
|
+
isRefetching: false
|
|
304
305
|
});
|
|
305
306
|
await opts?.onError?.(context);
|
|
306
307
|
},
|
|
307
308
|
async onRequest(context) {
|
|
308
309
|
const currentValue = value.get();
|
|
309
310
|
value.set({
|
|
310
|
-
isPending:
|
|
311
|
+
isPending: currentValue.data === null,
|
|
311
312
|
data: currentValue.data,
|
|
312
|
-
error:
|
|
313
|
+
error: null,
|
|
314
|
+
isRefetching: true
|
|
313
315
|
});
|
|
314
316
|
await opts?.onRequest?.(context);
|
|
315
317
|
}
|
|
@@ -338,7 +340,7 @@ var useAuthQuery = (initializedAtom, path, $fetch, options) => {
|
|
|
338
340
|
|
|
339
341
|
// src/client/session-atom.ts
|
|
340
342
|
function getSessionAtom($fetch) {
|
|
341
|
-
const $signal =
|
|
343
|
+
const $signal = atom2(false);
|
|
342
344
|
const session = useAuthQuery($signal, "/session", $fetch, {
|
|
343
345
|
method: "GET"
|
|
344
346
|
});
|
|
@@ -386,5 +388,6 @@ function createAuthClient(options) {
|
|
|
386
388
|
);
|
|
387
389
|
return proxy;
|
|
388
390
|
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
+
export {
|
|
392
|
+
createAuthClient
|
|
393
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "better-auth",
|
|
3
|
-
"version": "0.2.8
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"description": "The most comprehensive authentication library for TypeScript.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -39,8 +39,7 @@
|
|
|
39
39
|
"./node": "./dist/node.js",
|
|
40
40
|
"./adapters/prisma": "./dist/adapters/prisma.js",
|
|
41
41
|
"./adapters/drizzle": "./dist/adapters/drizzle.js",
|
|
42
|
-
"./adapters/mongodb": "./dist/adapters/mongodb.js"
|
|
43
|
-
"./utils": "./dist/utils.js"
|
|
42
|
+
"./adapters/mongodb": "./dist/adapters/mongodb.js"
|
|
44
43
|
},
|
|
45
44
|
"devDependencies": {
|
|
46
45
|
"@prisma/client": "^5.19.1",
|
package/dist/utils.d.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { g as AuthContext, G as GenericEndpointContext } from './index-CKn-Zrry.js';
|
|
2
|
-
export { j as BetterAuthCookies, i as createCookieGetter, l as createLogger, k as deleteSessionCookie, h as getCookies, m as logger, p as parseSetCookieHeader, s as setSessionCookie } from './index-CKn-Zrry.js';
|
|
3
|
-
export { H as HIDE_METADATA } from './hide-metadata-DEHJp1rk.js';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
import 'kysely';
|
|
6
|
-
import './index-JM-i6hLs.js';
|
|
7
|
-
import 'arctic';
|
|
8
|
-
import './helper-DPDj8Nix.js';
|
|
9
|
-
import 'better-call';
|
|
10
|
-
import 'better-sqlite3';
|
|
11
|
-
import 'mysql2';
|
|
12
|
-
|
|
13
|
-
declare const shimContext: <T extends Record<string, any>>(originalObject: T, newContext: Record<string, any>) => T;
|
|
14
|
-
declare const shimEndpoint: (ctx: AuthContext, value: any) => (context: any) => Promise<any>;
|
|
15
|
-
|
|
16
|
-
declare function getBaseURL(url?: string, path?: string): string | undefined;
|
|
17
|
-
|
|
18
|
-
declare const clone: <T extends object>(object: T) => T;
|
|
19
|
-
|
|
20
|
-
declare const getDate: (span: number, unit?: "sec" | "ms") => Date;
|
|
21
|
-
|
|
22
|
-
declare function getIp(req: Request): string | null;
|
|
23
|
-
|
|
24
|
-
declare const generateId: (size?: number) => string;
|
|
25
|
-
|
|
26
|
-
declare const merge: (objects: object[]) => object;
|
|
27
|
-
|
|
28
|
-
declare function capitalizeFirstLetter(str: string): string;
|
|
29
|
-
|
|
30
|
-
declare function validatePassword(ctx: GenericEndpointContext, data: {
|
|
31
|
-
password: string;
|
|
32
|
-
userId: string;
|
|
33
|
-
}): Promise<boolean>;
|
|
34
|
-
|
|
35
|
-
declare function generateState(callbackURL?: string, currentURL?: string, dontRememberMe?: boolean): {
|
|
36
|
-
state: string;
|
|
37
|
-
code: string;
|
|
38
|
-
};
|
|
39
|
-
declare function parseState(state: string): z.SafeParseReturnType<{
|
|
40
|
-
code: string;
|
|
41
|
-
callbackURL?: string | undefined;
|
|
42
|
-
currentURL?: string | undefined;
|
|
43
|
-
dontRememberMe?: boolean | undefined;
|
|
44
|
-
}, {
|
|
45
|
-
code: string;
|
|
46
|
-
callbackURL?: string | undefined;
|
|
47
|
-
currentURL?: string | undefined;
|
|
48
|
-
dontRememberMe?: boolean | undefined;
|
|
49
|
-
}>;
|
|
50
|
-
|
|
51
|
-
export { capitalizeFirstLetter, clone, generateId, generateState, getBaseURL, getDate, getIp, merge, parseState, shimContext, shimEndpoint, validatePassword };
|