better-auth 0.3.4 → 0.3.5-beta.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/adapters/drizzle.d.ts +1 -1
- package/dist/adapters/mongodb.d.ts +1 -1
- package/dist/adapters/prisma.d.ts +1 -1
- package/dist/api.d.ts +1 -1
- package/dist/api.js +31 -9
- package/dist/client/plugins.d.ts +3 -3
- package/dist/client.d.ts +1 -1
- package/dist/{index-D1AQaiQ6.d.ts → index-BYsLBcLO.d.ts} +2 -2
- package/dist/{index-CHZzPeLv.d.ts → index-DUQYmBZY.d.ts} +31 -31
- package/dist/index.d.ts +1 -1
- package/dist/index.js +38 -11
- package/dist/next-js.d.ts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/plugins.d.ts +11 -6
- package/dist/plugins.js +43 -29
- package/dist/react.d.ts +1 -1
- package/dist/solid-start.d.ts +1 -1
- package/dist/solid.d.ts +1 -1
- package/dist/svelte-kit.d.ts +1 -1
- package/dist/svelte.d.ts +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/vue.d.ts +1 -1
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { e as AuthEndpoint, f as AuthMiddleware, v as callbackOAuth, T as changePassword, d as createAuthEndpoint, c as createAuthMiddleware, M as createEmailVerificationToken, $ as csrfMiddleware, V as deleteUser, Y as error, J as forgetPassword, K as forgetPasswordCallback, X as getCSRFToken, r as getEndpoints, w as getSession, x as getSessionFromCtx, z as listSessions, Z as ok, o as optionsMiddleware, L as resetPassword, C as revokeSession, D as revokeSessions, s as router, N as sendVerificationEmail, y as sessionMiddleware, U as setPassword, u as signInEmail, t as signInOAuth, E as signOut, _ as signUpEmail, Q as updateUser, O as verifyEmail } from './index-DUQYmBZY.js';
|
|
2
2
|
import './helper-DPDj8Nix.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
export { APIError } from 'better-call';
|
package/dist/api.js
CHANGED
|
@@ -1273,10 +1273,10 @@ function generateRandomInteger(max) {
|
|
|
1273
1273
|
}
|
|
1274
1274
|
return result;
|
|
1275
1275
|
}
|
|
1276
|
-
function generateRandomString(length,
|
|
1276
|
+
function generateRandomString(length, alphabet3) {
|
|
1277
1277
|
let result = "";
|
|
1278
1278
|
for (let i = 0; i < length; i++) {
|
|
1279
|
-
result +=
|
|
1279
|
+
result += alphabet3[generateRandomInteger(alphabet3.length)];
|
|
1280
1280
|
}
|
|
1281
1281
|
return result;
|
|
1282
1282
|
}
|
|
@@ -1973,7 +1973,6 @@ var setPassword = createAuthEndpoint(
|
|
|
1973
1973
|
const passwordHash = await ctx.context.password.hash(newPassword);
|
|
1974
1974
|
if (!account) {
|
|
1975
1975
|
await ctx.context.internalAdapter.linkAccount({
|
|
1976
|
-
id: generateRandomString(32, alphabet("a-z", "0-9", "A-Z")),
|
|
1977
1976
|
userId: session.user.id,
|
|
1978
1977
|
providerId: "credential",
|
|
1979
1978
|
accountId: session.user.id,
|
|
@@ -2219,14 +2218,11 @@ var signUpEmail = () => createAuthEndpoint(
|
|
|
2219
2218
|
additionalFields
|
|
2220
2219
|
);
|
|
2221
2220
|
const createdUser = await ctx.context.internalAdapter.createUser({
|
|
2222
|
-
id: generateRandomString(32, alphabet("a-z", "0-9", "A-Z")),
|
|
2223
2221
|
email: email.toLowerCase(),
|
|
2224
2222
|
name,
|
|
2225
2223
|
image,
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
updatedAt: /* @__PURE__ */ new Date(),
|
|
2229
|
-
...additionalData
|
|
2224
|
+
...additionalData,
|
|
2225
|
+
emailVerified: false
|
|
2230
2226
|
});
|
|
2231
2227
|
if (!createdUser) {
|
|
2232
2228
|
throw new APIError9("BAD_REQUEST", {
|
|
@@ -2540,7 +2536,33 @@ function getEndpoints(ctx, options) {
|
|
|
2540
2536
|
let api = {};
|
|
2541
2537
|
for (const [key, value] of Object.entries(endpoints)) {
|
|
2542
2538
|
api[key] = async (context) => {
|
|
2543
|
-
|
|
2539
|
+
let c = await ctx;
|
|
2540
|
+
for (const plugin of options.plugins || []) {
|
|
2541
|
+
if (plugin.hooks?.before) {
|
|
2542
|
+
for (const hook of plugin.hooks.before) {
|
|
2543
|
+
const match = hook.matcher({
|
|
2544
|
+
...value,
|
|
2545
|
+
...context,
|
|
2546
|
+
context: c
|
|
2547
|
+
});
|
|
2548
|
+
if (match) {
|
|
2549
|
+
const hookRes = await hook.handler({
|
|
2550
|
+
...context,
|
|
2551
|
+
context: {
|
|
2552
|
+
...c,
|
|
2553
|
+
...context.context
|
|
2554
|
+
}
|
|
2555
|
+
});
|
|
2556
|
+
if (hookRes && "context" in hookRes) {
|
|
2557
|
+
c = {
|
|
2558
|
+
...c,
|
|
2559
|
+
...hookRes.context
|
|
2560
|
+
};
|
|
2561
|
+
}
|
|
2562
|
+
}
|
|
2563
|
+
}
|
|
2564
|
+
}
|
|
2565
|
+
}
|
|
2544
2566
|
const endpointRes = await value({
|
|
2545
2567
|
...context,
|
|
2546
2568
|
context: {
|
package/dist/client/plugins.d.ts
CHANGED
|
@@ -2,10 +2,10 @@ import * as nanostores from 'nanostores';
|
|
|
2
2
|
import { A as AccessControl, S as StatementsPrimitive, R as Role } from '../statement-CfnyN34h.js';
|
|
3
3
|
import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
4
4
|
import { BetterFetchOption } from '@better-fetch/fetch';
|
|
5
|
-
import { o as organization, f as Organization, M as Member, I as Invitation, u as username, m as magicLink, d as phoneNumber, e as anonymous } from '../index-
|
|
6
|
-
export { g as getPasskeyActions, c as passkeyClient, a as twoFactorClient } from '../index-
|
|
5
|
+
import { o as organization, f as Organization, M as Member, I as Invitation, u as username, m as magicLink, d as phoneNumber, e as anonymous } from '../index-BYsLBcLO.js';
|
|
6
|
+
export { g as getPasskeyActions, c as passkeyClient, a as twoFactorClient } from '../index-BYsLBcLO.js';
|
|
7
7
|
import { P as Prettify } from '../helper-DPDj8Nix.js';
|
|
8
|
-
import { F as FieldAttribute, B as BetterAuthOptions,
|
|
8
|
+
import { F as FieldAttribute, B as BetterAuthOptions, b as BetterAuthPlugin } from '../index-DUQYmBZY.js';
|
|
9
9
|
import '../index-QaO4zgiz.js';
|
|
10
10
|
import 'arctic';
|
|
11
11
|
import 'zod';
|
package/dist/client.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { BetterFetch, BetterFetchError, BetterFetchOption } from '@better-fetch/
|
|
|
6
6
|
import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from './helper-DPDj8Nix.js';
|
|
7
7
|
import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, InferSessionFromClient, InferUserFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
|
|
8
8
|
export { AtomListener, InferPluginsFromClient } from './types.js';
|
|
9
|
-
import './index-
|
|
9
|
+
import './index-DUQYmBZY.js';
|
|
10
10
|
import 'kysely';
|
|
11
11
|
import './index-QaO4zgiz.js';
|
|
12
12
|
import 'arctic';
|
|
@@ -5,7 +5,7 @@ import { P as Prettify } from './helper-DPDj8Nix.js';
|
|
|
5
5
|
import { A as AccessControl, R as Role, S as StatementsPrimitive, g as defaultRoles } from './statement-CfnyN34h.js';
|
|
6
6
|
import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
7
7
|
import { BetterFetch, BetterFetchOption } from '@better-fetch/fetch';
|
|
8
|
-
import { H as HookEndpointContext } from './index-
|
|
8
|
+
import { H as HookEndpointContext } from './index-DUQYmBZY.js';
|
|
9
9
|
import * as nanostores from 'nanostores';
|
|
10
10
|
import { atom } from 'nanostores';
|
|
11
11
|
import * as _simplewebauthn_types from '@simplewebauthn/types';
|
|
@@ -4636,7 +4636,7 @@ declare const anonymous: (options?: AnonymousOptions) => {
|
|
|
4636
4636
|
name: string;
|
|
4637
4637
|
image?: string | undefined;
|
|
4638
4638
|
id: string;
|
|
4639
|
-
emailVerified
|
|
4639
|
+
emailVerified?: boolean | undefined;
|
|
4640
4640
|
createdAt: Date;
|
|
4641
4641
|
updatedAt: Date;
|
|
4642
4642
|
};
|
|
@@ -1181,7 +1181,7 @@ declare const createInternalAdapter: (adapter: Adapter, ctx: {
|
|
|
1181
1181
|
name: string;
|
|
1182
1182
|
image?: string | undefined;
|
|
1183
1183
|
id: string;
|
|
1184
|
-
emailVerified
|
|
1184
|
+
emailVerified?: boolean | undefined;
|
|
1185
1185
|
createdAt: Date;
|
|
1186
1186
|
updatedAt: Date;
|
|
1187
1187
|
} | null>;
|
|
@@ -1251,7 +1251,7 @@ declare const createInternalAdapter: (adapter: Adapter, ctx: {
|
|
|
1251
1251
|
updatedAt: Date;
|
|
1252
1252
|
image?: string | undefined;
|
|
1253
1253
|
} | null>;
|
|
1254
|
-
linkAccount: (account: Account) => Promise<{
|
|
1254
|
+
linkAccount: (account: Omit<Account, "id"> & Record<string, any>) => Promise<{
|
|
1255
1255
|
id: string;
|
|
1256
1256
|
providerId: string;
|
|
1257
1257
|
accountId: string;
|
|
@@ -1357,17 +1357,17 @@ declare const signInOAuth: {
|
|
|
1357
1357
|
/**
|
|
1358
1358
|
* OAuth2 provider to use`
|
|
1359
1359
|
*/
|
|
1360
|
-
provider: z.ZodEnum<["github", ...("
|
|
1360
|
+
provider: z.ZodEnum<["github", ...("github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter")[]]>;
|
|
1361
1361
|
/**
|
|
1362
1362
|
* If this is true the session will only be valid for the current browser session
|
|
1363
1363
|
*/
|
|
1364
1364
|
dontRememberMe: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
1365
1365
|
}, "strip", z.ZodTypeAny, {
|
|
1366
|
-
provider: "
|
|
1366
|
+
provider: "github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter";
|
|
1367
1367
|
callbackURL?: string | undefined;
|
|
1368
1368
|
dontRememberMe?: boolean | undefined;
|
|
1369
1369
|
}, {
|
|
1370
|
-
provider: "
|
|
1370
|
+
provider: "github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter";
|
|
1371
1371
|
callbackURL?: string | undefined;
|
|
1372
1372
|
dontRememberMe?: boolean | undefined;
|
|
1373
1373
|
}>;
|
|
@@ -1402,17 +1402,17 @@ declare const signInOAuth: {
|
|
|
1402
1402
|
/**
|
|
1403
1403
|
* OAuth2 provider to use`
|
|
1404
1404
|
*/
|
|
1405
|
-
provider: z.ZodEnum<["github", ...("
|
|
1405
|
+
provider: z.ZodEnum<["github", ...("github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter")[]]>;
|
|
1406
1406
|
/**
|
|
1407
1407
|
* If this is true the session will only be valid for the current browser session
|
|
1408
1408
|
*/
|
|
1409
1409
|
dontRememberMe: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
1410
1410
|
}, "strip", z.ZodTypeAny, {
|
|
1411
|
-
provider: "
|
|
1411
|
+
provider: "github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter";
|
|
1412
1412
|
callbackURL?: string | undefined;
|
|
1413
1413
|
dontRememberMe?: boolean | undefined;
|
|
1414
1414
|
}, {
|
|
1415
|
-
provider: "
|
|
1415
|
+
provider: "github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter";
|
|
1416
1416
|
callbackURL?: string | undefined;
|
|
1417
1417
|
dontRememberMe?: boolean | undefined;
|
|
1418
1418
|
}>;
|
|
@@ -2517,7 +2517,7 @@ declare const signUpEmail: <O extends BetterAuthOptions>() => {
|
|
|
2517
2517
|
name: string;
|
|
2518
2518
|
image?: string | undefined;
|
|
2519
2519
|
id: string;
|
|
2520
|
-
emailVerified
|
|
2520
|
+
emailVerified?: boolean | undefined;
|
|
2521
2521
|
createdAt: Date;
|
|
2522
2522
|
updatedAt: Date;
|
|
2523
2523
|
};
|
|
@@ -2628,14 +2628,14 @@ declare function getEndpoints<C extends AuthContext, Option extends BetterAuthOp
|
|
|
2628
2628
|
}>>;
|
|
2629
2629
|
body: zod.ZodObject<{
|
|
2630
2630
|
callbackURL: zod.ZodOptional<zod.ZodString>;
|
|
2631
|
-
provider: zod.ZodEnum<["github", ...("
|
|
2631
|
+
provider: zod.ZodEnum<["github", ...("github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter")[]]>;
|
|
2632
2632
|
dontRememberMe: zod.ZodOptional<zod.ZodDefault<zod.ZodBoolean>>;
|
|
2633
2633
|
}, "strip", zod.ZodTypeAny, {
|
|
2634
|
-
provider: "
|
|
2634
|
+
provider: "github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter";
|
|
2635
2635
|
callbackURL?: string | undefined;
|
|
2636
2636
|
dontRememberMe?: boolean | undefined;
|
|
2637
2637
|
}, {
|
|
2638
|
-
provider: "
|
|
2638
|
+
provider: "github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter";
|
|
2639
2639
|
callbackURL?: string | undefined;
|
|
2640
2640
|
dontRememberMe?: boolean | undefined;
|
|
2641
2641
|
}>;
|
|
@@ -2660,14 +2660,14 @@ declare function getEndpoints<C extends AuthContext, Option extends BetterAuthOp
|
|
|
2660
2660
|
}>>;
|
|
2661
2661
|
body: zod.ZodObject<{
|
|
2662
2662
|
callbackURL: zod.ZodOptional<zod.ZodString>;
|
|
2663
|
-
provider: zod.ZodEnum<["github", ...("
|
|
2663
|
+
provider: zod.ZodEnum<["github", ...("github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter")[]]>;
|
|
2664
2664
|
dontRememberMe: zod.ZodOptional<zod.ZodDefault<zod.ZodBoolean>>;
|
|
2665
2665
|
}, "strip", zod.ZodTypeAny, {
|
|
2666
|
-
provider: "
|
|
2666
|
+
provider: "github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter";
|
|
2667
2667
|
callbackURL?: string | undefined;
|
|
2668
2668
|
dontRememberMe?: boolean | undefined;
|
|
2669
2669
|
}, {
|
|
2670
|
-
provider: "
|
|
2670
|
+
provider: "github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter";
|
|
2671
2671
|
callbackURL?: string | undefined;
|
|
2672
2672
|
dontRememberMe?: boolean | undefined;
|
|
2673
2673
|
}>;
|
|
@@ -2884,7 +2884,7 @@ declare function getEndpoints<C extends AuthContext, Option extends BetterAuthOp
|
|
|
2884
2884
|
name: string;
|
|
2885
2885
|
image?: string | undefined;
|
|
2886
2886
|
id: string;
|
|
2887
|
-
emailVerified
|
|
2887
|
+
emailVerified?: boolean | undefined;
|
|
2888
2888
|
createdAt: Date;
|
|
2889
2889
|
updatedAt: Date;
|
|
2890
2890
|
};
|
|
@@ -3741,14 +3741,14 @@ declare const router: <C extends AuthContext, Option extends BetterAuthOptions>(
|
|
|
3741
3741
|
}>>;
|
|
3742
3742
|
body: zod.ZodObject<{
|
|
3743
3743
|
callbackURL: zod.ZodOptional<zod.ZodString>;
|
|
3744
|
-
provider: zod.ZodEnum<["github", ...("
|
|
3744
|
+
provider: zod.ZodEnum<["github", ...("github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter")[]]>;
|
|
3745
3745
|
dontRememberMe: zod.ZodOptional<zod.ZodDefault<zod.ZodBoolean>>;
|
|
3746
3746
|
}, "strip", zod.ZodTypeAny, {
|
|
3747
|
-
provider: "
|
|
3747
|
+
provider: "github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter";
|
|
3748
3748
|
callbackURL?: string | undefined;
|
|
3749
3749
|
dontRememberMe?: boolean | undefined;
|
|
3750
3750
|
}, {
|
|
3751
|
-
provider: "
|
|
3751
|
+
provider: "github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter";
|
|
3752
3752
|
callbackURL?: string | undefined;
|
|
3753
3753
|
dontRememberMe?: boolean | undefined;
|
|
3754
3754
|
}>;
|
|
@@ -3773,14 +3773,14 @@ declare const router: <C extends AuthContext, Option extends BetterAuthOptions>(
|
|
|
3773
3773
|
}>>;
|
|
3774
3774
|
body: zod.ZodObject<{
|
|
3775
3775
|
callbackURL: zod.ZodOptional<zod.ZodString>;
|
|
3776
|
-
provider: zod.ZodEnum<["github", ...("
|
|
3776
|
+
provider: zod.ZodEnum<["github", ...("github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter")[]]>;
|
|
3777
3777
|
dontRememberMe: zod.ZodOptional<zod.ZodDefault<zod.ZodBoolean>>;
|
|
3778
3778
|
}, "strip", zod.ZodTypeAny, {
|
|
3779
|
-
provider: "
|
|
3779
|
+
provider: "github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter";
|
|
3780
3780
|
callbackURL?: string | undefined;
|
|
3781
3781
|
dontRememberMe?: boolean | undefined;
|
|
3782
3782
|
}, {
|
|
3783
|
-
provider: "
|
|
3783
|
+
provider: "github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter";
|
|
3784
3784
|
callbackURL?: string | undefined;
|
|
3785
3785
|
dontRememberMe?: boolean | undefined;
|
|
3786
3786
|
}>;
|
|
@@ -3997,7 +3997,7 @@ declare const router: <C extends AuthContext, Option extends BetterAuthOptions>(
|
|
|
3997
3997
|
name: string;
|
|
3998
3998
|
image?: string | undefined;
|
|
3999
3999
|
id: string;
|
|
4000
|
-
emailVerified
|
|
4000
|
+
emailVerified?: boolean | undefined;
|
|
4001
4001
|
createdAt: Date;
|
|
4002
4002
|
updatedAt: Date;
|
|
4003
4003
|
};
|
|
@@ -4856,14 +4856,14 @@ declare const betterAuth: <O extends BetterAuthOptions>(options: O) => {
|
|
|
4856
4856
|
}>>;
|
|
4857
4857
|
body: zod.ZodObject<{
|
|
4858
4858
|
callbackURL: zod.ZodOptional<zod.ZodString>;
|
|
4859
|
-
provider: zod.ZodEnum<["github", ...("
|
|
4859
|
+
provider: zod.ZodEnum<["github", ...("github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter")[]]>;
|
|
4860
4860
|
dontRememberMe: zod.ZodOptional<zod.ZodDefault<zod.ZodBoolean>>;
|
|
4861
4861
|
}, "strip", zod.ZodTypeAny, {
|
|
4862
|
-
provider: "
|
|
4862
|
+
provider: "github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter";
|
|
4863
4863
|
callbackURL?: string | undefined;
|
|
4864
4864
|
dontRememberMe?: boolean | undefined;
|
|
4865
4865
|
}, {
|
|
4866
|
-
provider: "
|
|
4866
|
+
provider: "github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter";
|
|
4867
4867
|
callbackURL?: string | undefined;
|
|
4868
4868
|
dontRememberMe?: boolean | undefined;
|
|
4869
4869
|
}>;
|
|
@@ -4888,14 +4888,14 @@ declare const betterAuth: <O extends BetterAuthOptions>(options: O) => {
|
|
|
4888
4888
|
}>>;
|
|
4889
4889
|
body: zod.ZodObject<{
|
|
4890
4890
|
callbackURL: zod.ZodOptional<zod.ZodString>;
|
|
4891
|
-
provider: zod.ZodEnum<["github", ...("
|
|
4891
|
+
provider: zod.ZodEnum<["github", ...("github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter")[]]>;
|
|
4892
4892
|
dontRememberMe: zod.ZodOptional<zod.ZodDefault<zod.ZodBoolean>>;
|
|
4893
4893
|
}, "strip", zod.ZodTypeAny, {
|
|
4894
|
-
provider: "
|
|
4894
|
+
provider: "github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter";
|
|
4895
4895
|
callbackURL?: string | undefined;
|
|
4896
4896
|
dontRememberMe?: boolean | undefined;
|
|
4897
4897
|
}, {
|
|
4898
|
-
provider: "
|
|
4898
|
+
provider: "github" | "apple" | "discord" | "facebook" | "microsoft" | "google" | "spotify" | "twitch" | "twitter";
|
|
4899
4899
|
callbackURL?: string | undefined;
|
|
4900
4900
|
dontRememberMe?: boolean | undefined;
|
|
4901
4901
|
}>;
|
|
@@ -5112,7 +5112,7 @@ declare const betterAuth: <O extends BetterAuthOptions>(options: O) => {
|
|
|
5112
5112
|
name: string;
|
|
5113
5113
|
image?: string | undefined;
|
|
5114
5114
|
id: string;
|
|
5115
|
-
emailVerified
|
|
5115
|
+
emailVerified?: boolean | undefined;
|
|
5116
5116
|
createdAt: Date;
|
|
5117
5117
|
updatedAt: Date;
|
|
5118
5118
|
};
|
|
@@ -5922,4 +5922,4 @@ type Auth = {
|
|
|
5922
5922
|
options: BetterAuthOptions;
|
|
5923
5923
|
};
|
|
5924
5924
|
|
|
5925
|
-
export { csrfMiddleware as $, type Adapter as A, type BetterAuthOptions as B, revokeSession as C, revokeSessions as D, signOut as E, type FieldAttribute as F, type GenericEndpointContext as G, type HookEndpointContext as H, type InferFieldsInputClient as I, forgetPassword as J, forgetPasswordCallback as K, resetPassword as L, createEmailVerificationToken as M, sendVerificationEmail as N, verifyEmail as O, type PluginSchema as P, updateUser as Q, type RateLimit as R, type SecondaryStorage as S, changePassword as T, setPassword as U, deleteUser as V, type Where as W, getCSRFToken as X, error as Y, ok as Z, signUpEmail as _, type Auth as a, betterAuth as a0, type
|
|
5925
|
+
export { csrfMiddleware as $, type Adapter as A, type BetterAuthOptions as B, revokeSession as C, revokeSessions as D, signOut as E, type FieldAttribute as F, type GenericEndpointContext as G, type HookEndpointContext as H, type InferFieldsInputClient as I, forgetPassword as J, forgetPasswordCallback as K, resetPassword as L, createEmailVerificationToken as M, sendVerificationEmail as N, verifyEmail as O, type PluginSchema as P, updateUser as Q, type RateLimit as R, type SecondaryStorage as S, changePassword as T, setPassword as U, deleteUser as V, type Where as W, getCSRFToken as X, error as Y, ok as Z, signUpEmail as _, type Auth as a, betterAuth as a0, type BetterAuthPlugin as b, createAuthMiddleware as c, createAuthEndpoint as d, type AuthEndpoint as e, type AuthMiddleware as f, type InferFieldsOutput as g, type AdditionalUserFieldsInput as h, type AdditionalUserFieldsOutput as i, type AdditionalSessionFieldsInput as j, type AdditionalSessionFieldsOutput as k, type InferUser as l, type InferSession as m, type InferPluginTypes as n, optionsMiddleware as o, init as p, type AuthContext as q, getEndpoints as r, router as s, signInOAuth as t, signInEmail as u, callbackOAuth as v, getSession as w, getSessionFromCtx as x, sessionMiddleware as y, listSessions as z };
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1363,10 +1363,10 @@ function generateRandomInteger(max) {
|
|
|
1363
1363
|
}
|
|
1364
1364
|
return result;
|
|
1365
1365
|
}
|
|
1366
|
-
function generateRandomString(length,
|
|
1366
|
+
function generateRandomString(length, alphabet3) {
|
|
1367
1367
|
let result = "";
|
|
1368
1368
|
for (let i = 0; i < length; i++) {
|
|
1369
|
-
result +=
|
|
1369
|
+
result += alphabet3[generateRandomInteger(alphabet3.length)];
|
|
1370
1370
|
}
|
|
1371
1371
|
return result;
|
|
1372
1372
|
}
|
|
@@ -2063,7 +2063,6 @@ var setPassword = createAuthEndpoint(
|
|
|
2063
2063
|
const passwordHash = await ctx.context.password.hash(newPassword);
|
|
2064
2064
|
if (!account) {
|
|
2065
2065
|
await ctx.context.internalAdapter.linkAccount({
|
|
2066
|
-
id: generateRandomString(32, alphabet("a-z", "0-9", "A-Z")),
|
|
2067
2066
|
userId: session.user.id,
|
|
2068
2067
|
providerId: "credential",
|
|
2069
2068
|
accountId: session.user.id,
|
|
@@ -2309,14 +2308,11 @@ var signUpEmail = () => createAuthEndpoint(
|
|
|
2309
2308
|
additionalFields
|
|
2310
2309
|
);
|
|
2311
2310
|
const createdUser = await ctx.context.internalAdapter.createUser({
|
|
2312
|
-
id: generateRandomString(32, alphabet("a-z", "0-9", "A-Z")),
|
|
2313
2311
|
email: email.toLowerCase(),
|
|
2314
2312
|
name,
|
|
2315
2313
|
image,
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
updatedAt: /* @__PURE__ */ new Date(),
|
|
2319
|
-
...additionalData
|
|
2314
|
+
...additionalData,
|
|
2315
|
+
emailVerified: false
|
|
2320
2316
|
});
|
|
2321
2317
|
if (!createdUser) {
|
|
2322
2318
|
throw new APIError9("BAD_REQUEST", {
|
|
@@ -2630,7 +2626,33 @@ function getEndpoints(ctx, options) {
|
|
|
2630
2626
|
let api = {};
|
|
2631
2627
|
for (const [key, value] of Object.entries(endpoints)) {
|
|
2632
2628
|
api[key] = async (context) => {
|
|
2633
|
-
|
|
2629
|
+
let c = await ctx;
|
|
2630
|
+
for (const plugin of options.plugins || []) {
|
|
2631
|
+
if (plugin.hooks?.before) {
|
|
2632
|
+
for (const hook of plugin.hooks.before) {
|
|
2633
|
+
const match = hook.matcher({
|
|
2634
|
+
...value,
|
|
2635
|
+
...context,
|
|
2636
|
+
context: c
|
|
2637
|
+
});
|
|
2638
|
+
if (match) {
|
|
2639
|
+
const hookRes = await hook.handler({
|
|
2640
|
+
...context,
|
|
2641
|
+
context: {
|
|
2642
|
+
...c,
|
|
2643
|
+
...context.context
|
|
2644
|
+
}
|
|
2645
|
+
});
|
|
2646
|
+
if (hookRes && "context" in hookRes) {
|
|
2647
|
+
c = {
|
|
2648
|
+
...c,
|
|
2649
|
+
...hookRes.context
|
|
2650
|
+
};
|
|
2651
|
+
}
|
|
2652
|
+
}
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2655
|
+
}
|
|
2634
2656
|
const endpointRes = await value({
|
|
2635
2657
|
...context,
|
|
2636
2658
|
context: {
|
|
@@ -3608,7 +3630,6 @@ var createInternalAdapter = (adapter, ctx) => {
|
|
|
3608
3630
|
const createdUser = await createWithHooks(
|
|
3609
3631
|
{
|
|
3610
3632
|
id: generateId(),
|
|
3611
|
-
emailVerified: false,
|
|
3612
3633
|
createdAt: /* @__PURE__ */ new Date(),
|
|
3613
3634
|
updatedAt: /* @__PURE__ */ new Date(),
|
|
3614
3635
|
...user
|
|
@@ -3779,7 +3800,13 @@ var createInternalAdapter = (adapter, ctx) => {
|
|
|
3779
3800
|
return user;
|
|
3780
3801
|
},
|
|
3781
3802
|
linkAccount: async (account) => {
|
|
3782
|
-
const _account = await createWithHooks(
|
|
3803
|
+
const _account = await createWithHooks(
|
|
3804
|
+
{
|
|
3805
|
+
...account,
|
|
3806
|
+
id: generateId()
|
|
3807
|
+
},
|
|
3808
|
+
"account"
|
|
3809
|
+
);
|
|
3783
3810
|
return _account;
|
|
3784
3811
|
},
|
|
3785
3812
|
updateUser: async (userId, data) => {
|
package/dist/next-js.d.ts
CHANGED
package/dist/node.d.ts
CHANGED
package/dist/plugins.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { A as AnonymousOptions, O as OrganizationOptions, b as Passkey, P as PasskeyOptions, U as UserWithPhoneNumber, e as anonymous, g as getPasskeyActions, m as magicLink, o as organization, p as passkey, c as passkeyClient, d as phoneNumber, t as twoFactor, a as twoFactorClient, u as username } from './index-
|
|
1
|
+
export { A as AnonymousOptions, O as OrganizationOptions, b as Passkey, P as PasskeyOptions, U as UserWithPhoneNumber, e as anonymous, g as getPasskeyActions, m as magicLink, o as organization, p as passkey, c as passkeyClient, d as phoneNumber, t as twoFactor, a as twoFactorClient, u as username } from './index-BYsLBcLO.js';
|
|
2
2
|
export { i as ac } from './index-DfAHOgpj.js';
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
3
|
+
import { H as HookEndpointContext } from './index-DUQYmBZY.js';
|
|
4
|
+
export { e as AuthEndpoint, f as AuthMiddleware, b as BetterAuthPlugin, P as PluginSchema, d as createAuthEndpoint, c as createAuthMiddleware, o as optionsMiddleware } from './index-DUQYmBZY.js';
|
|
5
5
|
import './index-QaO4zgiz.js';
|
|
6
6
|
import 'arctic';
|
|
7
7
|
import 'zod';
|
|
@@ -20,9 +20,14 @@ import 'mysql2';
|
|
|
20
20
|
*/
|
|
21
21
|
declare const bearer: () => {
|
|
22
22
|
id: "bearer";
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
hooks: {
|
|
24
|
+
before: {
|
|
25
|
+
matcher(context: HookEndpointContext): boolean;
|
|
26
|
+
handler: (c: HookEndpointContext) => Promise<{
|
|
27
|
+
context: HookEndpointContext;
|
|
28
|
+
} | undefined>;
|
|
29
|
+
}[];
|
|
30
|
+
};
|
|
26
31
|
};
|
|
27
32
|
|
|
28
33
|
declare const HIDE_METADATA: {
|
package/dist/plugins.js
CHANGED
|
@@ -1193,10 +1193,10 @@ function generateRandomInteger(max) {
|
|
|
1193
1193
|
}
|
|
1194
1194
|
return result;
|
|
1195
1195
|
}
|
|
1196
|
-
function generateRandomString(length,
|
|
1196
|
+
function generateRandomString(length, alphabet3) {
|
|
1197
1197
|
let result = "";
|
|
1198
1198
|
for (let i = 0; i < length; i++) {
|
|
1199
|
-
result +=
|
|
1199
|
+
result += alphabet3[generateRandomInteger(alphabet3.length)];
|
|
1200
1200
|
}
|
|
1201
1201
|
return result;
|
|
1202
1202
|
}
|
|
@@ -1893,7 +1893,6 @@ var setPassword = createAuthEndpoint(
|
|
|
1893
1893
|
const passwordHash = await ctx.context.password.hash(newPassword);
|
|
1894
1894
|
if (!account) {
|
|
1895
1895
|
await ctx.context.internalAdapter.linkAccount({
|
|
1896
|
-
id: generateRandomString(32, alphabet("a-z", "0-9", "A-Z")),
|
|
1897
1896
|
userId: session.user.id,
|
|
1898
1897
|
providerId: "credential",
|
|
1899
1898
|
accountId: session.user.id,
|
|
@@ -2174,14 +2173,11 @@ var signUpEmail = () => createAuthEndpoint(
|
|
|
2174
2173
|
additionalFields
|
|
2175
2174
|
);
|
|
2176
2175
|
const createdUser = await ctx.context.internalAdapter.createUser({
|
|
2177
|
-
id: generateRandomString(32, alphabet("a-z", "0-9", "A-Z")),
|
|
2178
2176
|
email: email.toLowerCase(),
|
|
2179
2177
|
name,
|
|
2180
2178
|
image,
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
updatedAt: /* @__PURE__ */ new Date(),
|
|
2184
|
-
...additionalData
|
|
2179
|
+
...additionalData,
|
|
2180
|
+
emailVerified: false
|
|
2185
2181
|
});
|
|
2186
2182
|
if (!createdUser) {
|
|
2187
2183
|
throw new APIError8("BAD_REQUEST", {
|
|
@@ -4859,7 +4855,7 @@ var passkey = (options) => {
|
|
|
4859
4855
|
authenticatorAttachment: "platform"
|
|
4860
4856
|
}
|
|
4861
4857
|
});
|
|
4862
|
-
const id =
|
|
4858
|
+
const id = generateId();
|
|
4863
4859
|
await ctx.setSignedCookie(
|
|
4864
4860
|
opts.advanced.webAuthnChallengeCookie,
|
|
4865
4861
|
id,
|
|
@@ -4928,7 +4924,7 @@ var passkey = (options) => {
|
|
|
4928
4924
|
id: session?.user.id || ""
|
|
4929
4925
|
}
|
|
4930
4926
|
};
|
|
4931
|
-
const id =
|
|
4927
|
+
const id = generateId();
|
|
4932
4928
|
await ctx.setSignedCookie(
|
|
4933
4929
|
opts.advanced.webAuthnChallengeCookie,
|
|
4934
4930
|
id,
|
|
@@ -5014,7 +5010,7 @@ var passkey = (options) => {
|
|
|
5014
5010
|
credentialBackedUp
|
|
5015
5011
|
} = registrationInfo;
|
|
5016
5012
|
const pubKey = Buffer.from(credentialPublicKey).toString("base64");
|
|
5017
|
-
const userID =
|
|
5013
|
+
const userID = generateId();
|
|
5018
5014
|
const newPasskey = {
|
|
5019
5015
|
name: ctx.body.name,
|
|
5020
5016
|
userId: userData.id,
|
|
@@ -5425,23 +5421,42 @@ import { serializeSigned } from "better-call";
|
|
|
5425
5421
|
var bearer = () => {
|
|
5426
5422
|
return {
|
|
5427
5423
|
id: "bearer",
|
|
5428
|
-
|
|
5429
|
-
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
|
|
5438
|
-
|
|
5439
|
-
|
|
5440
|
-
|
|
5441
|
-
|
|
5442
|
-
|
|
5443
|
-
|
|
5444
|
-
|
|
5424
|
+
hooks: {
|
|
5425
|
+
before: [
|
|
5426
|
+
{
|
|
5427
|
+
matcher(context) {
|
|
5428
|
+
return Boolean(
|
|
5429
|
+
context.request?.headers.get("authorization") || context.headers?.get("authorization")
|
|
5430
|
+
);
|
|
5431
|
+
},
|
|
5432
|
+
handler: async (c) => {
|
|
5433
|
+
const token = c.request?.headers.get("authorization")?.replace("Bearer ", "") || c.headers?.get("authorization")?.replace("Bearer ", "");
|
|
5434
|
+
if (!token) {
|
|
5435
|
+
return;
|
|
5436
|
+
}
|
|
5437
|
+
const signedToken = await serializeSigned(
|
|
5438
|
+
"",
|
|
5439
|
+
token,
|
|
5440
|
+
c.context.secret
|
|
5441
|
+
);
|
|
5442
|
+
if (c.request) {
|
|
5443
|
+
c.request.headers.set(
|
|
5444
|
+
"cookie",
|
|
5445
|
+
`${c.context.authCookies.sessionToken.name}=${signedToken.replace("=", "")}`
|
|
5446
|
+
);
|
|
5447
|
+
}
|
|
5448
|
+
if (c.headers) {
|
|
5449
|
+
c.headers.set(
|
|
5450
|
+
"cookie",
|
|
5451
|
+
`${c.context.authCookies.sessionToken.name}=${signedToken.replace("=", "")}`
|
|
5452
|
+
);
|
|
5453
|
+
}
|
|
5454
|
+
return {
|
|
5455
|
+
context: c
|
|
5456
|
+
};
|
|
5457
|
+
}
|
|
5458
|
+
}
|
|
5459
|
+
]
|
|
5445
5460
|
}
|
|
5446
5461
|
};
|
|
5447
5462
|
};
|
|
@@ -6016,7 +6031,6 @@ var anonymous = (options) => {
|
|
|
6016
6031
|
}
|
|
6017
6032
|
const hash = await ctx.context.password.hash(password);
|
|
6018
6033
|
const updateUserAccount = await ctx.context.internalAdapter.linkAccount({
|
|
6019
|
-
id: generateRandomString(32, alphabet("a-z", "0-9", "A-Z")),
|
|
6020
6034
|
userId: updatedUser.id,
|
|
6021
6035
|
providerId: "credential",
|
|
6022
6036
|
password: hash,
|
package/dist/react.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 { useStore } from '@nanostores/react';
|
|
6
|
-
import './index-
|
|
6
|
+
import './index-DUQYmBZY.js';
|
|
7
7
|
import 'kysely';
|
|
8
8
|
import './index-QaO4zgiz.js';
|
|
9
9
|
import 'arctic';
|
package/dist/solid-start.d.ts
CHANGED
package/dist/solid.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 { Accessor } from 'solid-js';
|
|
6
|
-
import './index-
|
|
6
|
+
import './index-DUQYmBZY.js';
|
|
7
7
|
import 'kysely';
|
|
8
8
|
import './index-QaO4zgiz.js';
|
|
9
9
|
import 'arctic';
|
package/dist/svelte-kit.d.ts
CHANGED
package/dist/svelte.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as nanostores from 'nanostores';
|
|
|
3
3
|
import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
4
4
|
import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from './helper-DPDj8Nix.js';
|
|
5
5
|
import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
|
|
6
|
-
import './index-
|
|
6
|
+
import './index-DUQYmBZY.js';
|
|
7
7
|
import 'kysely';
|
|
8
8
|
import './index-QaO4zgiz.js';
|
|
9
9
|
import 'arctic';
|
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, I as InferFieldsInputClient, g as InferFieldsOutput } from './index-DUQYmBZY.js';
|
|
2
|
+
export { A as Adapter, j as AdditionalSessionFieldsInput, k as AdditionalSessionFieldsOutput, h as AdditionalUserFieldsInput, i as AdditionalUserFieldsOutput, q as AuthContext, B as BetterAuthOptions, G as GenericEndpointContext, H as HookEndpointContext, n as InferPluginTypes, m as InferSession, l as InferUser, P as PluginSchema, R as RateLimit, S as SecondaryStorage, W as Where, p as init } from './index-DUQYmBZY.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-QaO4zgiz.js';
|
package/dist/vue.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 { Ref, DeepReadonly } from 'vue';
|
|
6
|
-
import './index-
|
|
6
|
+
import './index-DUQYmBZY.js';
|
|
7
7
|
import 'kysely';
|
|
8
8
|
import './index-QaO4zgiz.js';
|
|
9
9
|
import 'arctic';
|