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/react.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 { useStore } from '@nanostores/react';
|
|
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';
|
|
@@ -12,6 +12,7 @@ import 'better-sqlite3';
|
|
|
12
12
|
import 'mysql2';
|
|
13
13
|
import 'nanostores';
|
|
14
14
|
|
|
15
|
+
declare function capitalizeFirstLetter(str: string): string;
|
|
15
16
|
type InferResolvedHooks<O extends ClientOptions> = O["plugins"] extends Array<infer Plugin> ? Plugin extends BetterAuthClientPlugin ? Plugin["getAtoms"] extends (fetch: any) => infer Atoms ? Atoms extends Record<string, any> ? {
|
|
16
17
|
[key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => ReturnType<Atoms[key]["get"]>;
|
|
17
18
|
} : {} : {} : {} : {};
|
|
@@ -54,6 +55,7 @@ declare function createAuthClient<Option extends ClientOptions>(options?: Option
|
|
|
54
55
|
} | null;
|
|
55
56
|
error: null | _better_fetch_fetch.BetterFetchError;
|
|
56
57
|
isPending: boolean;
|
|
58
|
+
isRefetching: boolean;
|
|
57
59
|
};
|
|
58
60
|
$Infer: {
|
|
59
61
|
Session: {
|
|
@@ -78,4 +80,4 @@ declare function createAuthClient<Option extends ClientOptions>(options?: Option
|
|
|
78
80
|
};
|
|
79
81
|
declare const useAuthQuery: typeof useStore;
|
|
80
82
|
|
|
81
|
-
export { createAuthClient, useAuthQuery };
|
|
83
|
+
export { capitalizeFirstLetter, createAuthClient, useAuthQuery };
|
package/dist/react.js
CHANGED
|
@@ -1,29 +1,8 @@
|
|
|
1
|
-
import { useStore } from '@nanostores/react';
|
|
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
|
-
import 'react';
|
|
10
|
-
|
|
11
1
|
// src/client/react.ts
|
|
12
|
-
|
|
13
|
-
formatOptions: {
|
|
14
|
-
date: false,
|
|
15
|
-
colors: true,
|
|
16
|
-
compact: true
|
|
17
|
-
},
|
|
18
|
-
defaults: {
|
|
19
|
-
tag: "Better Auth"
|
|
20
|
-
}
|
|
21
|
-
});
|
|
2
|
+
import { useStore } from "@nanostores/react";
|
|
22
3
|
|
|
23
|
-
// src/
|
|
24
|
-
|
|
25
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
26
|
-
}
|
|
4
|
+
// src/client/config.ts
|
|
5
|
+
import { createFetch } from "@better-fetch/fetch";
|
|
27
6
|
|
|
28
7
|
// src/error/better-auth-error.ts
|
|
29
8
|
var BetterAuthError = class extends Error {
|
|
@@ -69,6 +48,12 @@ function getBaseURL(url, path) {
|
|
|
69
48
|
}
|
|
70
49
|
return void 0;
|
|
71
50
|
}
|
|
51
|
+
|
|
52
|
+
// src/client/config.ts
|
|
53
|
+
import "nanostores";
|
|
54
|
+
|
|
55
|
+
// src/client/fetch-plugins.ts
|
|
56
|
+
import { betterFetch } from "@better-fetch/fetch";
|
|
72
57
|
var redirectPlugin = {
|
|
73
58
|
id: "redirect",
|
|
74
59
|
name: "Redirect",
|
|
@@ -275,11 +260,19 @@ function createDynamicPathProxy(routes, client, knownPathMethods, atoms, atomLis
|
|
|
275
260
|
}
|
|
276
261
|
return createProxy();
|
|
277
262
|
}
|
|
263
|
+
|
|
264
|
+
// src/client/session-atom.ts
|
|
265
|
+
import { atom as atom2 } from "nanostores";
|
|
266
|
+
|
|
267
|
+
// src/client/query.ts
|
|
268
|
+
import "@better-fetch/fetch";
|
|
269
|
+
import { atom, onMount } from "nanostores";
|
|
278
270
|
var useAuthQuery = (initializedAtom, path, $fetch, options) => {
|
|
279
271
|
const value = atom({
|
|
280
272
|
data: null,
|
|
281
273
|
error: null,
|
|
282
|
-
isPending: false
|
|
274
|
+
isPending: false,
|
|
275
|
+
isRefetching: false
|
|
283
276
|
});
|
|
284
277
|
const fn = () => {
|
|
285
278
|
const opts = typeof options === "function" ? options({
|
|
@@ -293,24 +286,27 @@ var useAuthQuery = (initializedAtom, path, $fetch, options) => {
|
|
|
293
286
|
value.set({
|
|
294
287
|
data: context.data,
|
|
295
288
|
error: null,
|
|
296
|
-
isPending: false
|
|
289
|
+
isPending: false,
|
|
290
|
+
isRefetching: false
|
|
297
291
|
});
|
|
298
292
|
await opts?.onSuccess?.(context);
|
|
299
293
|
},
|
|
300
294
|
async onError(context) {
|
|
301
295
|
value.set({
|
|
302
296
|
error: context.error,
|
|
303
|
-
data:
|
|
304
|
-
isPending: false
|
|
297
|
+
data: value.get().data,
|
|
298
|
+
isPending: false,
|
|
299
|
+
isRefetching: false
|
|
305
300
|
});
|
|
306
301
|
await opts?.onError?.(context);
|
|
307
302
|
},
|
|
308
303
|
async onRequest(context) {
|
|
309
304
|
const currentValue = value.get();
|
|
310
305
|
value.set({
|
|
311
|
-
isPending:
|
|
306
|
+
isPending: currentValue.data === null,
|
|
312
307
|
data: currentValue.data,
|
|
313
|
-
error:
|
|
308
|
+
error: null,
|
|
309
|
+
isRefetching: true
|
|
314
310
|
});
|
|
315
311
|
await opts?.onRequest?.(context);
|
|
316
312
|
}
|
|
@@ -339,7 +335,7 @@ var useAuthQuery = (initializedAtom, path, $fetch, options) => {
|
|
|
339
335
|
|
|
340
336
|
// src/client/session-atom.ts
|
|
341
337
|
function getSessionAtom($fetch) {
|
|
342
|
-
const $signal =
|
|
338
|
+
const $signal = atom2(false);
|
|
343
339
|
const session = useAuthQuery($signal, "/session", $fetch, {
|
|
344
340
|
method: "GET"
|
|
345
341
|
});
|
|
@@ -349,9 +345,14 @@ function getSessionAtom($fetch) {
|
|
|
349
345
|
$Infer: {}
|
|
350
346
|
};
|
|
351
347
|
}
|
|
348
|
+
|
|
349
|
+
// src/client/react.ts
|
|
352
350
|
function getAtomKey(str) {
|
|
353
351
|
return `use${capitalizeFirstLetter(str)}`;
|
|
354
352
|
}
|
|
353
|
+
function capitalizeFirstLetter(str) {
|
|
354
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
355
|
+
}
|
|
355
356
|
function createAuthClient(options) {
|
|
356
357
|
const {
|
|
357
358
|
pluginPathMethods,
|
|
@@ -387,5 +388,8 @@ function createAuthClient(options) {
|
|
|
387
388
|
return proxy;
|
|
388
389
|
}
|
|
389
390
|
var useAuthQuery2 = useStore;
|
|
390
|
-
|
|
391
|
-
|
|
391
|
+
export {
|
|
392
|
+
capitalizeFirstLetter,
|
|
393
|
+
createAuthClient,
|
|
394
|
+
useAuthQuery2 as useAuthQuery
|
|
395
|
+
};
|
package/dist/social.js
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
import { Facebook, GitHub, Google, Spotify, Twitch, Twitter, OAuth2Tokens } from 'arctic';
|
|
2
|
-
import { parseJWT } from 'oslo/jwt';
|
|
3
|
-
import { betterFetch } from '@better-fetch/fetch';
|
|
4
|
-
import 'oslo';
|
|
5
|
-
import 'nanoid';
|
|
6
|
-
import { createConsola } from 'consola';
|
|
7
|
-
import 'oslo/oauth2';
|
|
8
|
-
import 'zod';
|
|
9
|
-
|
|
10
1
|
// src/social-providers/apple.ts
|
|
2
|
+
import "arctic";
|
|
3
|
+
import { parseJWT } from "oslo/jwt";
|
|
4
|
+
import "@better-fetch/fetch";
|
|
5
|
+
|
|
6
|
+
// src/error/better-auth-error.ts
|
|
7
|
+
var BetterAuthError = class extends Error {
|
|
8
|
+
constructor(message, cause) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = "BetterAuthError";
|
|
11
|
+
this.message = message;
|
|
12
|
+
this.cause = cause;
|
|
13
|
+
this.stack = "";
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// src/social-providers/utils.ts
|
|
18
|
+
import { OAuth2Tokens } from "arctic";
|
|
11
19
|
|
|
12
20
|
// src/utils/base-url.ts
|
|
13
21
|
function checkHasPath(url) {
|
|
@@ -29,6 +37,9 @@ function withPath(url, path = "/api/auth") {
|
|
|
29
37
|
return `${url}${path}`;
|
|
30
38
|
}
|
|
31
39
|
function getBaseURL(url, path) {
|
|
40
|
+
if (url) {
|
|
41
|
+
return withPath(url, path);
|
|
42
|
+
}
|
|
32
43
|
const env = process?.env || {};
|
|
33
44
|
const fromEnv = env.BETTER_AUTH_URL || env.NEXT_PUBLIC_BETTER_AUTH_URL || env.PUBLIC_BETTER_AUTH_URL || env.NUXT_PUBLIC_BETTER_AUTH_URL || env.NUXT_PUBLIC_AUTH_URL || (env.BASE_URL !== "/" ? env.BASE_URL : void 0);
|
|
34
45
|
if (fromEnv) {
|
|
@@ -39,56 +50,9 @@ function getBaseURL(url, path) {
|
|
|
39
50
|
}
|
|
40
51
|
return void 0;
|
|
41
52
|
}
|
|
42
|
-
var consola = createConsola({
|
|
43
|
-
formatOptions: {
|
|
44
|
-
date: false,
|
|
45
|
-
colors: true,
|
|
46
|
-
compact: true
|
|
47
|
-
},
|
|
48
|
-
defaults: {
|
|
49
|
-
tag: "Better Auth"
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
var createLogger = (options) => {
|
|
53
|
-
return {
|
|
54
|
-
log: (...args) => {
|
|
55
|
-
consola.log("", ...args);
|
|
56
|
-
},
|
|
57
|
-
error: (...args) => {
|
|
58
|
-
consola.error("", ...args);
|
|
59
|
-
},
|
|
60
|
-
warn: (...args) => {
|
|
61
|
-
consola.warn("", ...args);
|
|
62
|
-
},
|
|
63
|
-
info: (...args) => {
|
|
64
|
-
consola.info("", ...args);
|
|
65
|
-
},
|
|
66
|
-
debug: (...args) => {
|
|
67
|
-
consola.debug("", ...args);
|
|
68
|
-
},
|
|
69
|
-
box: (...args) => {
|
|
70
|
-
consola.box("", ...args);
|
|
71
|
-
},
|
|
72
|
-
success: (...args) => {
|
|
73
|
-
consola.success("", ...args);
|
|
74
|
-
},
|
|
75
|
-
break: (...args) => {
|
|
76
|
-
console.log("\n");
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
var logger = createLogger();
|
|
81
53
|
|
|
82
|
-
// src/
|
|
83
|
-
|
|
84
|
-
constructor(message, cause) {
|
|
85
|
-
super(message);
|
|
86
|
-
this.name = "BetterAuthError";
|
|
87
|
-
this.message = message;
|
|
88
|
-
this.cause = cause;
|
|
89
|
-
this.stack = "";
|
|
90
|
-
}
|
|
91
|
-
};
|
|
54
|
+
// src/social-providers/utils.ts
|
|
55
|
+
import { betterFetch } from "@better-fetch/fetch";
|
|
92
56
|
function getRedirectURI(providerId, redirectURI) {
|
|
93
57
|
return redirectURI || `${getBaseURL()}/callback/${providerId}`;
|
|
94
58
|
}
|
|
@@ -160,6 +124,9 @@ var apple = (options) => {
|
|
|
160
124
|
}
|
|
161
125
|
};
|
|
162
126
|
};
|
|
127
|
+
|
|
128
|
+
// src/social-providers/discord.ts
|
|
129
|
+
import { betterFetch as betterFetch3 } from "@better-fetch/fetch";
|
|
163
130
|
var discord = (options) => {
|
|
164
131
|
return {
|
|
165
132
|
id: "discord",
|
|
@@ -183,7 +150,7 @@ var discord = (options) => {
|
|
|
183
150
|
});
|
|
184
151
|
},
|
|
185
152
|
async getUserInfo(token) {
|
|
186
|
-
const { data: profile, error } = await
|
|
153
|
+
const { data: profile, error } = await betterFetch3(
|
|
187
154
|
"https://discord.com/api/users/@me",
|
|
188
155
|
{
|
|
189
156
|
headers: {
|
|
@@ -214,6 +181,10 @@ var discord = (options) => {
|
|
|
214
181
|
}
|
|
215
182
|
};
|
|
216
183
|
};
|
|
184
|
+
|
|
185
|
+
// src/social-providers/facebook.ts
|
|
186
|
+
import { betterFetch as betterFetch4 } from "@better-fetch/fetch";
|
|
187
|
+
import { Facebook } from "arctic";
|
|
217
188
|
var facebook = (options) => {
|
|
218
189
|
const facebookArctic = new Facebook(
|
|
219
190
|
options.clientId,
|
|
@@ -237,7 +208,7 @@ var facebook = (options) => {
|
|
|
237
208
|
});
|
|
238
209
|
},
|
|
239
210
|
async getUserInfo(token) {
|
|
240
|
-
const { data: profile, error } = await
|
|
211
|
+
const { data: profile, error } = await betterFetch4(
|
|
241
212
|
"https://graph.facebook.com/me",
|
|
242
213
|
{
|
|
243
214
|
auth: {
|
|
@@ -261,6 +232,10 @@ var facebook = (options) => {
|
|
|
261
232
|
}
|
|
262
233
|
};
|
|
263
234
|
};
|
|
235
|
+
|
|
236
|
+
// src/social-providers/github.ts
|
|
237
|
+
import { betterFetch as betterFetch5 } from "@better-fetch/fetch";
|
|
238
|
+
import { GitHub } from "arctic";
|
|
264
239
|
var github = ({
|
|
265
240
|
clientId,
|
|
266
241
|
clientSecret,
|
|
@@ -282,7 +257,7 @@ var github = ({
|
|
|
282
257
|
return await githubArctic.validateAuthorizationCode(state);
|
|
283
258
|
},
|
|
284
259
|
async getUserInfo(token) {
|
|
285
|
-
const { data: profile, error } = await
|
|
260
|
+
const { data: profile, error } = await betterFetch5(
|
|
286
261
|
"https://api.github.com/user",
|
|
287
262
|
{
|
|
288
263
|
auth: {
|
|
@@ -296,7 +271,7 @@ var github = ({
|
|
|
296
271
|
}
|
|
297
272
|
let emailVerified = false;
|
|
298
273
|
if (!profile.email) {
|
|
299
|
-
const { data, error: error2 } = await
|
|
274
|
+
const { data, error: error2 } = await betterFetch5("https://api.github.com/user/emails", {
|
|
300
275
|
auth: {
|
|
301
276
|
type: "Bearer",
|
|
302
277
|
token: token.accessToken()
|
|
@@ -322,6 +297,54 @@ var github = ({
|
|
|
322
297
|
}
|
|
323
298
|
};
|
|
324
299
|
};
|
|
300
|
+
|
|
301
|
+
// src/social-providers/google.ts
|
|
302
|
+
import { Google } from "arctic";
|
|
303
|
+
import { parseJWT as parseJWT2 } from "oslo/jwt";
|
|
304
|
+
|
|
305
|
+
// src/utils/logger.ts
|
|
306
|
+
import { createConsola } from "consola";
|
|
307
|
+
var consola = createConsola({
|
|
308
|
+
formatOptions: {
|
|
309
|
+
date: false,
|
|
310
|
+
colors: true,
|
|
311
|
+
compact: true
|
|
312
|
+
},
|
|
313
|
+
defaults: {
|
|
314
|
+
tag: "Better Auth"
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
var createLogger = (options) => {
|
|
318
|
+
return {
|
|
319
|
+
log: (...args) => {
|
|
320
|
+
!options?.disabled && consola.log("", ...args);
|
|
321
|
+
},
|
|
322
|
+
error: (...args) => {
|
|
323
|
+
!options?.disabled && consola.error("", ...args);
|
|
324
|
+
},
|
|
325
|
+
warn: (...args) => {
|
|
326
|
+
!options?.disabled && consola.warn("", ...args);
|
|
327
|
+
},
|
|
328
|
+
info: (...args) => {
|
|
329
|
+
!options?.disabled && consola.info("", ...args);
|
|
330
|
+
},
|
|
331
|
+
debug: (...args) => {
|
|
332
|
+
!options?.disabled && consola.debug("", ...args);
|
|
333
|
+
},
|
|
334
|
+
box: (...args) => {
|
|
335
|
+
!options?.disabled && consola.box("", ...args);
|
|
336
|
+
},
|
|
337
|
+
success: (...args) => {
|
|
338
|
+
!options?.disabled && consola.success("", ...args);
|
|
339
|
+
},
|
|
340
|
+
break: (...args) => {
|
|
341
|
+
!options?.disabled && console.log("\n");
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
};
|
|
345
|
+
var logger = createLogger();
|
|
346
|
+
|
|
347
|
+
// src/social-providers/google.ts
|
|
325
348
|
var google = (options) => {
|
|
326
349
|
const googleArctic = new Google(
|
|
327
350
|
options.clientId,
|
|
@@ -362,7 +385,7 @@ var google = (options) => {
|
|
|
362
385
|
if (!token.idToken) {
|
|
363
386
|
return null;
|
|
364
387
|
}
|
|
365
|
-
const user =
|
|
388
|
+
const user = parseJWT2(token.idToken())?.payload;
|
|
366
389
|
return {
|
|
367
390
|
user: {
|
|
368
391
|
id: user.sub,
|
|
@@ -376,6 +399,10 @@ var google = (options) => {
|
|
|
376
399
|
}
|
|
377
400
|
};
|
|
378
401
|
};
|
|
402
|
+
|
|
403
|
+
// src/social-providers/spotify.ts
|
|
404
|
+
import { betterFetch as betterFetch6 } from "@better-fetch/fetch";
|
|
405
|
+
import { Spotify } from "arctic";
|
|
379
406
|
var spotify = (options) => {
|
|
380
407
|
const spotifyArctic = new Spotify(
|
|
381
408
|
options.clientId,
|
|
@@ -399,7 +426,7 @@ var spotify = (options) => {
|
|
|
399
426
|
});
|
|
400
427
|
},
|
|
401
428
|
async getUserInfo(token) {
|
|
402
|
-
const { data: profile, error } = await
|
|
429
|
+
const { data: profile, error } = await betterFetch6(
|
|
403
430
|
"https://api.spotify.com/v1/me",
|
|
404
431
|
{
|
|
405
432
|
method: "GET",
|
|
@@ -424,6 +451,10 @@ var spotify = (options) => {
|
|
|
424
451
|
}
|
|
425
452
|
};
|
|
426
453
|
};
|
|
454
|
+
|
|
455
|
+
// src/social-providers/twitch.ts
|
|
456
|
+
import { betterFetch as betterFetch7 } from "@better-fetch/fetch";
|
|
457
|
+
import { Twitch } from "arctic";
|
|
427
458
|
var twitch = (options) => {
|
|
428
459
|
const twitchArctic = new Twitch(
|
|
429
460
|
options.clientId,
|
|
@@ -446,7 +477,7 @@ var twitch = (options) => {
|
|
|
446
477
|
});
|
|
447
478
|
},
|
|
448
479
|
async getUserInfo(token) {
|
|
449
|
-
const { data: profile, error } = await
|
|
480
|
+
const { data: profile, error } = await betterFetch7(
|
|
450
481
|
"https://api.twitch.tv/helix/users",
|
|
451
482
|
{
|
|
452
483
|
method: "GET",
|
|
@@ -471,6 +502,10 @@ var twitch = (options) => {
|
|
|
471
502
|
}
|
|
472
503
|
};
|
|
473
504
|
};
|
|
505
|
+
|
|
506
|
+
// src/social-providers/twitter.ts
|
|
507
|
+
import { betterFetch as betterFetch8 } from "@better-fetch/fetch";
|
|
508
|
+
import { Twitter } from "arctic";
|
|
474
509
|
var twitter = (options) => {
|
|
475
510
|
const twitterArctic = new Twitter(
|
|
476
511
|
options.clientId,
|
|
@@ -498,7 +533,7 @@ var twitter = (options) => {
|
|
|
498
533
|
});
|
|
499
534
|
},
|
|
500
535
|
async getUserInfo(token) {
|
|
501
|
-
const { data: profile, error } = await
|
|
536
|
+
const { data: profile, error } = await betterFetch8(
|
|
502
537
|
"https://api.x.com/2/users/me?user.fields=profile_image_url",
|
|
503
538
|
{
|
|
504
539
|
method: "GET",
|
|
@@ -527,6 +562,9 @@ var twitter = (options) => {
|
|
|
527
562
|
};
|
|
528
563
|
};
|
|
529
564
|
|
|
565
|
+
// src/types/provider.ts
|
|
566
|
+
import "arctic";
|
|
567
|
+
|
|
530
568
|
// src/social-providers/index.ts
|
|
531
569
|
var oAuthProviders = {
|
|
532
570
|
apple,
|
|
@@ -539,5 +577,15 @@ var oAuthProviders = {
|
|
|
539
577
|
twitter
|
|
540
578
|
};
|
|
541
579
|
var oAuthProviderList = Object.keys(oAuthProviders);
|
|
542
|
-
|
|
543
|
-
|
|
580
|
+
export {
|
|
581
|
+
apple,
|
|
582
|
+
discord,
|
|
583
|
+
facebook,
|
|
584
|
+
github,
|
|
585
|
+
google,
|
|
586
|
+
oAuthProviderList,
|
|
587
|
+
oAuthProviders,
|
|
588
|
+
spotify,
|
|
589
|
+
twitch,
|
|
590
|
+
twitter
|
|
591
|
+
};
|
package/dist/solid-start.d.ts
CHANGED
package/dist/solid-start.js
CHANGED
package/dist/solid.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 { Accessor } from 'solid-js';
|
|
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
|
error: null | _better_fetch_fetch.BetterFetchError;
|
|
39
39
|
isPending: boolean;
|
|
40
|
+
isRefetching: boolean;
|
|
40
41
|
}>;
|
|
41
42
|
$Infer: {
|
|
42
43
|
Session: {
|
package/dist/solid.js
CHANGED
|
@@ -1,28 +1,8 @@
|
|
|
1
|
-
import { useStore } from '@nanostores/solid';
|
|
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/solid.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/solid";
|
|
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",
|
|
@@ -274,11 +260,24 @@ function createDynamicPathProxy(routes, client, knownPathMethods, atoms, atomLis
|
|
|
274
260
|
}
|
|
275
261
|
return createProxy();
|
|
276
262
|
}
|
|
263
|
+
|
|
264
|
+
// src/utils/misc.ts
|
|
265
|
+
function capitalizeFirstLetter(str) {
|
|
266
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
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/dist/svelte-kit.d.ts
CHANGED
package/dist/svelte-kit.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { building } from '$app/environment';
|
|
2
|
-
|
|
3
1
|
// src/integrations/svelte-kit.ts
|
|
2
|
+
import { building } from "$app/environment";
|
|
4
3
|
var toSvelteKitHandler = (auth) => {
|
|
5
4
|
return (event) => auth.handler(event.request);
|
|
6
5
|
};
|
|
@@ -28,5 +27,8 @@ function isAuthPath(url, options) {
|
|
|
28
27
|
return false;
|
|
29
28
|
return true;
|
|
30
29
|
}
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
export {
|
|
31
|
+
isAuthPath,
|
|
32
|
+
svelteKitHandler,
|
|
33
|
+
toSvelteKitHandler
|
|
34
|
+
};
|
package/dist/svelte.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
|
3
3
|
import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from './helper-DPDj8Nix.js';
|
|
4
4
|
import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
|
|
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';
|
|
@@ -36,6 +36,7 @@ declare function createAuthClient<Option extends ClientOptions>(options?: Option
|
|
|
36
36
|
} | null;
|
|
37
37
|
error: null | _better_fetch_fetch.BetterFetchError;
|
|
38
38
|
isPending: boolean;
|
|
39
|
+
isRefetching: boolean;
|
|
39
40
|
}>;
|
|
40
41
|
$Infer: {
|
|
41
42
|
Session: {
|