better-auth 1.2.4-beta.1 → 1.2.4-beta.12
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-adapter/index.cjs +6 -0
- package/dist/adapters/drizzle-adapter/index.d.cts +1 -1
- package/dist/adapters/drizzle-adapter/index.d.mts +1 -1
- package/dist/adapters/drizzle-adapter/index.d.ts +1 -1
- package/dist/adapters/drizzle-adapter/index.mjs +7 -1
- package/dist/adapters/kysely-adapter/index.d.cts +1 -1
- package/dist/adapters/kysely-adapter/index.d.mts +1 -1
- package/dist/adapters/kysely-adapter/index.d.ts +1 -1
- package/dist/adapters/memory-adapter/index.d.cts +1 -1
- package/dist/adapters/memory-adapter/index.d.mts +1 -1
- package/dist/adapters/memory-adapter/index.d.ts +1 -1
- package/dist/adapters/mongodb-adapter/index.d.cts +1 -1
- package/dist/adapters/mongodb-adapter/index.d.mts +1 -1
- package/dist/adapters/mongodb-adapter/index.d.ts +1 -1
- package/dist/adapters/prisma-adapter/index.d.cts +1 -1
- package/dist/adapters/prisma-adapter/index.d.mts +1 -1
- package/dist/adapters/prisma-adapter/index.d.ts +1 -1
- package/dist/adapters/test.d.cts +1 -1
- package/dist/adapters/test.d.mts +1 -1
- package/dist/adapters/test.d.ts +1 -1
- package/dist/api/index.cjs +3 -3
- package/dist/api/index.d.cts +1 -1
- package/dist/api/index.d.mts +1 -1
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.mjs +4 -4
- package/dist/client/index.cjs +2 -2
- package/dist/client/index.d.cts +2 -2
- package/dist/client/index.d.mts +2 -2
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.mjs +2 -2
- package/dist/client/plugins/index.cjs +91 -101
- package/dist/client/plugins/index.d.cts +15 -236
- package/dist/client/plugins/index.d.mts +15 -236
- package/dist/client/plugins/index.d.ts +15 -236
- package/dist/client/plugins/index.mjs +92 -102
- package/dist/client/react/index.cjs +17 -13
- package/dist/client/react/index.d.cts +25 -2
- package/dist/client/react/index.d.mts +25 -2
- package/dist/client/react/index.d.ts +25 -2
- package/dist/client/react/index.mjs +17 -13
- package/dist/client/solid/index.cjs +2 -2
- package/dist/client/solid/index.d.cts +1 -1
- package/dist/client/solid/index.d.mts +1 -1
- package/dist/client/solid/index.d.ts +1 -1
- package/dist/client/solid/index.mjs +2 -2
- package/dist/client/svelte/index.cjs +2 -2
- package/dist/client/svelte/index.d.cts +1 -1
- package/dist/client/svelte/index.d.mts +1 -1
- package/dist/client/svelte/index.d.ts +1 -1
- package/dist/client/svelte/index.mjs +2 -2
- package/dist/client/vue/index.cjs +2 -2
- package/dist/client/vue/index.d.cts +1 -1
- package/dist/client/vue/index.d.mts +1 -1
- package/dist/client/vue/index.d.ts +1 -1
- package/dist/client/vue/index.mjs +2 -2
- package/dist/cookies/index.cjs +6 -2
- package/dist/cookies/index.d.cts +1 -1
- package/dist/cookies/index.d.mts +1 -1
- package/dist/cookies/index.d.ts +1 -1
- package/dist/cookies/index.mjs +6 -2
- package/dist/db/index.cjs +1 -1
- package/dist/db/index.d.cts +2 -2
- package/dist/db/index.d.mts +2 -2
- package/dist/db/index.d.ts +2 -2
- package/dist/db/index.mjs +1 -1
- package/dist/index.cjs +15 -11
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +16 -12
- package/dist/integrations/next-js.cjs +5 -5
- package/dist/integrations/next-js.d.cts +1 -1
- package/dist/integrations/next-js.d.mts +1 -1
- package/dist/integrations/next-js.d.ts +1 -1
- package/dist/integrations/next-js.mjs +5 -5
- package/dist/integrations/node.d.cts +1 -1
- package/dist/integrations/node.d.mts +1 -1
- package/dist/integrations/node.d.ts +1 -1
- package/dist/integrations/svelte-kit.d.cts +1 -1
- package/dist/integrations/svelte-kit.d.mts +1 -1
- package/dist/integrations/svelte-kit.d.ts +1 -1
- package/dist/oauth2/index.cjs +1 -1
- package/dist/oauth2/index.d.cts +2 -2
- package/dist/oauth2/index.d.mts +2 -2
- package/dist/oauth2/index.d.ts +2 -2
- package/dist/oauth2/index.mjs +1 -1
- package/dist/plugins/admin/index.cjs +4 -4
- package/dist/plugins/admin/index.d.cts +1 -1
- package/dist/plugins/admin/index.d.mts +1 -1
- package/dist/plugins/admin/index.d.ts +1 -1
- package/dist/plugins/admin/index.mjs +4 -4
- package/dist/plugins/anonymous/index.cjs +3 -3
- package/dist/plugins/anonymous/index.d.cts +1 -1
- package/dist/plugins/anonymous/index.d.mts +1 -1
- package/dist/plugins/anonymous/index.d.ts +1 -1
- package/dist/plugins/anonymous/index.mjs +3 -3
- package/dist/plugins/bearer/index.cjs +3 -3
- package/dist/plugins/bearer/index.d.cts +1 -1
- package/dist/plugins/bearer/index.d.mts +1 -1
- package/dist/plugins/bearer/index.d.ts +1 -1
- package/dist/plugins/bearer/index.mjs +3 -3
- package/dist/plugins/custom-session/index.cjs +3 -3
- package/dist/plugins/custom-session/index.d.cts +1 -1
- package/dist/plugins/custom-session/index.d.mts +1 -1
- package/dist/plugins/custom-session/index.d.ts +1 -1
- package/dist/plugins/custom-session/index.mjs +3 -3
- package/dist/plugins/email-otp/index.cjs +3 -3
- package/dist/plugins/email-otp/index.d.cts +1 -1
- package/dist/plugins/email-otp/index.d.mts +1 -1
- package/dist/plugins/email-otp/index.d.ts +1 -1
- package/dist/plugins/email-otp/index.mjs +3 -3
- package/dist/plugins/generic-oauth/index.cjs +3 -3
- package/dist/plugins/generic-oauth/index.d.cts +1 -1
- package/dist/plugins/generic-oauth/index.d.mts +1 -1
- package/dist/plugins/generic-oauth/index.d.ts +1 -1
- package/dist/plugins/generic-oauth/index.mjs +3 -3
- package/dist/plugins/index.cjs +15 -17
- package/dist/plugins/index.d.cts +3 -3
- package/dist/plugins/index.d.mts +3 -3
- package/dist/plugins/index.d.ts +3 -3
- package/dist/plugins/index.mjs +15 -17
- package/dist/plugins/jwt/index.cjs +8 -4
- package/dist/plugins/jwt/index.d.cts +1 -1
- package/dist/plugins/jwt/index.d.mts +1 -1
- package/dist/plugins/jwt/index.d.ts +1 -1
- package/dist/plugins/jwt/index.mjs +8 -4
- package/dist/plugins/magic-link/index.cjs +3 -3
- package/dist/plugins/magic-link/index.mjs +3 -3
- package/dist/plugins/multi-session/index.cjs +14 -5
- package/dist/plugins/multi-session/index.d.cts +1 -1
- package/dist/plugins/multi-session/index.d.mts +1 -1
- package/dist/plugins/multi-session/index.d.ts +1 -1
- package/dist/plugins/multi-session/index.mjs +14 -5
- package/dist/plugins/oauth-proxy/index.cjs +3 -3
- package/dist/plugins/oauth-proxy/index.d.cts +1 -1
- package/dist/plugins/oauth-proxy/index.d.mts +1 -1
- package/dist/plugins/oauth-proxy/index.d.ts +1 -1
- package/dist/plugins/oauth-proxy/index.mjs +3 -3
- package/dist/plugins/oidc-provider/index.cjs +89 -17
- package/dist/plugins/oidc-provider/index.d.cts +110 -14
- package/dist/plugins/oidc-provider/index.d.mts +110 -14
- package/dist/plugins/oidc-provider/index.d.ts +110 -14
- package/dist/plugins/oidc-provider/index.mjs +89 -17
- package/dist/plugins/one-tap/index.cjs +3 -3
- package/dist/plugins/one-tap/index.mjs +3 -3
- package/dist/plugins/open-api/index.cjs +3 -3
- package/dist/plugins/open-api/index.d.cts +1 -1
- package/dist/plugins/open-api/index.d.mts +1 -1
- package/dist/plugins/open-api/index.d.ts +1 -1
- package/dist/plugins/open-api/index.mjs +3 -3
- package/dist/plugins/organization/index.cjs +5 -5
- package/dist/plugins/organization/index.d.cts +2 -2
- package/dist/plugins/organization/index.d.mts +2 -2
- package/dist/plugins/organization/index.d.ts +2 -2
- package/dist/plugins/organization/index.mjs +5 -5
- package/dist/plugins/passkey/index.cjs +3 -3
- package/dist/plugins/passkey/index.d.cts +1 -1
- package/dist/plugins/passkey/index.d.mts +1 -1
- package/dist/plugins/passkey/index.d.ts +1 -1
- package/dist/plugins/passkey/index.mjs +3 -3
- package/dist/plugins/phone-number/index.cjs +19 -11
- package/dist/plugins/phone-number/index.d.cts +4 -3
- package/dist/plugins/phone-number/index.d.mts +4 -3
- package/dist/plugins/phone-number/index.d.ts +4 -3
- package/dist/plugins/phone-number/index.mjs +19 -11
- package/dist/plugins/sso/index.cjs +3 -3
- package/dist/plugins/sso/index.d.cts +1 -1
- package/dist/plugins/sso/index.d.mts +1 -1
- package/dist/plugins/sso/index.d.ts +1 -1
- package/dist/plugins/sso/index.mjs +3 -3
- package/dist/plugins/two-factor/index.cjs +7 -7
- package/dist/plugins/two-factor/index.d.cts +1 -1
- package/dist/plugins/two-factor/index.d.mts +1 -1
- package/dist/plugins/two-factor/index.d.ts +1 -1
- package/dist/plugins/two-factor/index.mjs +7 -7
- package/dist/plugins/username/index.cjs +3 -3
- package/dist/plugins/username/index.d.cts +1 -1
- package/dist/plugins/username/index.d.mts +1 -1
- package/dist/plugins/username/index.d.ts +1 -1
- package/dist/plugins/username/index.mjs +3 -3
- package/dist/shared/{better-auth.B5NYxGA3.mjs → better-auth.67eSHmUo.mjs} +3 -7
- package/dist/shared/{better-auth.CMz4USTt.cjs → better-auth.B6Xcg5N5.cjs} +1 -1
- package/dist/shared/{better-auth.K251u4eV.mjs → better-auth.BH6IWaNB.mjs} +3 -3
- package/dist/shared/{better-auth.DNb3Aogp.cjs → better-auth.BN2jUYPL.cjs} +1 -1
- package/dist/shared/{better-auth.F2VsZ04W.d.ts → better-auth.BVojg4kv.d.ts} +1 -1
- package/dist/shared/{better-auth.BA2kubRc.d.cts → better-auth.BdjFNTuQ.d.cts} +1 -1
- package/dist/shared/{better-auth.D4ignKqt.d.mts → better-auth.BfPbu6oh.d.mts} +1 -1
- package/dist/shared/{better-auth.DhfiEsxl.cjs → better-auth.C-R0J0n1.cjs} +15 -1
- package/dist/shared/{better-auth.Bd1H94Nk.mjs → better-auth.CABkkSP8.mjs} +1 -1
- package/dist/shared/{better-auth.npe3WWSD.mjs → better-auth.CFZLHBFT.mjs} +23 -24
- package/dist/shared/{better-auth.GgQnT00n.cjs → better-auth.CHHC_PJT.cjs} +1 -0
- package/dist/shared/{better-auth.BI_ldOv7.mjs → better-auth.CHsl8t-G.mjs} +2 -7
- package/dist/shared/{better-auth.BAR_8WbD.d.cts → better-auth.CPKTEzG-.d.cts} +3 -2
- package/dist/shared/{better-auth.DXbPkpEx.cjs → better-auth.CR_ASYNx.cjs} +3 -3
- package/dist/shared/{better-auth.YSKz0i4l.mjs → better-auth.CSVqSIae.mjs} +1 -1
- package/dist/shared/{better-auth.Cx-TsLBb.d.mts → better-auth.CVOWGLfd.d.mts} +1 -1
- package/dist/shared/{better-auth.CoMXyQ1y.mjs → better-auth.CbXAPXob.mjs} +1 -0
- package/dist/shared/{better-auth.imLEY-xr.d.mts → better-auth.Ck0xlDsK.d.mts} +3 -2
- package/dist/shared/{better-auth.BS4hQYkx.d.cts → better-auth.Ckf_tP8g.d.mts} +1 -1
- package/dist/shared/{better-auth.CqfKuHli.mjs → better-auth.CmplT_y7.mjs} +11 -18
- package/dist/shared/{better-auth.BvJDkY_b.cjs → better-auth.Cr6NZZDX.cjs} +11 -18
- package/dist/shared/{better-auth.BLtLzuLI.d.cts → better-auth.DIRcdXVm.d.cts} +1 -1
- package/dist/shared/{better-auth.DayxQ0AW.d.ts → better-auth.DaeQzncE.d.ts} +1 -1
- package/dist/shared/{better-auth.CKg1f8vU.cjs → better-auth.DcpLarbN.cjs} +3 -7
- package/dist/shared/{better-auth.purQujiV.d.ts → better-auth.DiHCWsNg.d.ts} +3 -2
- package/dist/shared/{better-auth.CwDUoRLB.cjs → better-auth.Dxrp37xO.cjs} +2 -7
- package/dist/shared/{better-auth.BzKRBwSF.cjs → better-auth.GVCiTzec.cjs} +23 -24
- package/dist/shared/{better-auth.NcLhHEks.mjs → better-auth.VTXNLFMT.mjs} +15 -1
- package/dist/shared/{better-auth.BxdddeEs.d.mts → better-auth.Vci2tT86.d.cts} +1 -1
- package/dist/shared/{better-auth.977UjO4P.d.ts → better-auth.jVBEmAqh.d.ts} +1 -1
- package/dist/social-providers/index.cjs +3 -1
- package/dist/social-providers/index.mjs +3 -1
- package/dist/types/index.d.cts +4 -3
- package/dist/types/index.d.mts +4 -3
- package/dist/types/index.d.ts +4 -3
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { a as createAuthEndpoint, g as getSessionFromCtx, B as BASE_ERROR_CODES } from '../../shared/better-auth.
|
|
2
|
+
import { a as createAuthEndpoint, g as getSessionFromCtx, B as BASE_ERROR_CODES } from '../../shared/better-auth.CFZLHBFT.mjs';
|
|
3
3
|
import { APIError } from 'better-call';
|
|
4
4
|
import { m as mergeSchema } from '../../shared/better-auth.C24Bzw4w.mjs';
|
|
5
5
|
import { g as generateRandomString } from '../../shared/better-auth.B4Qoxdgc.mjs';
|
|
@@ -23,11 +23,11 @@ import '@better-auth/utils/hex';
|
|
|
23
23
|
import '@noble/hashes/utils';
|
|
24
24
|
import '../../shared/better-auth.DdzSJf-n.mjs';
|
|
25
25
|
import '@better-auth/utils/random';
|
|
26
|
-
import '../../shared/better-auth.
|
|
26
|
+
import '../../shared/better-auth.CbXAPXob.mjs';
|
|
27
27
|
import '../../shared/better-auth.BUPPRXfK.mjs';
|
|
28
28
|
import '@better-auth/utils/hmac';
|
|
29
29
|
import '../../shared/better-auth.DDEbWX-S.mjs';
|
|
30
|
-
import '../../shared/better-auth.
|
|
30
|
+
import '../../shared/better-auth.VTXNLFMT.mjs';
|
|
31
31
|
import 'jose/errors';
|
|
32
32
|
import '../../shared/better-auth.tB5eU6EY.mjs';
|
|
33
33
|
import '@better-auth/utils/binary';
|
|
@@ -47,6 +47,7 @@ const phoneNumber = (options) => {
|
|
|
47
47
|
};
|
|
48
48
|
const ERROR_CODES = {
|
|
49
49
|
INVALID_PHONE_NUMBER: "Invalid phone number",
|
|
50
|
+
PHONE_NUMBER_EXIST: "Phone number already exist",
|
|
50
51
|
INVALID_PHONE_NUMBER_OR_PASSWORD: "Invalid phone number or password",
|
|
51
52
|
UNEXPECTED_ERROR: "Unexpected error",
|
|
52
53
|
OTP_NOT_FOUND: "OTP not found",
|
|
@@ -254,14 +255,7 @@ const phoneNumber = (options) => {
|
|
|
254
255
|
},
|
|
255
256
|
ctx.request
|
|
256
257
|
);
|
|
257
|
-
return ctx.json(
|
|
258
|
-
{ code },
|
|
259
|
-
{
|
|
260
|
-
body: {
|
|
261
|
-
message: "Code sent"
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
);
|
|
258
|
+
return ctx.json({ message: "code sent" });
|
|
265
259
|
}
|
|
266
260
|
),
|
|
267
261
|
verifyPhoneNumber: createAuthEndpoint(
|
|
@@ -354,6 +348,20 @@ const phoneNumber = (options) => {
|
|
|
354
348
|
message: BASE_ERROR_CODES.USER_NOT_FOUND
|
|
355
349
|
});
|
|
356
350
|
}
|
|
351
|
+
const existingUser = await ctx.context.adapter.findMany({
|
|
352
|
+
model: "user",
|
|
353
|
+
where: [
|
|
354
|
+
{
|
|
355
|
+
field: "phoneNumber",
|
|
356
|
+
value: ctx.body.phoneNumber
|
|
357
|
+
}
|
|
358
|
+
]
|
|
359
|
+
});
|
|
360
|
+
if (existingUser.length) {
|
|
361
|
+
throw ctx.error("BAD_REQUEST", {
|
|
362
|
+
message: ERROR_CODES.PHONE_NUMBER_EXIST
|
|
363
|
+
});
|
|
364
|
+
}
|
|
357
365
|
let user2 = await ctx.context.internalAdapter.updateUser(
|
|
358
366
|
session.user.id,
|
|
359
367
|
{
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const zod = require('zod');
|
|
4
4
|
const betterCall = require('better-call');
|
|
5
|
-
const account = require('../../shared/better-auth.
|
|
5
|
+
const account = require('../../shared/better-auth.GVCiTzec.cjs');
|
|
6
6
|
const cookies_index = require('../../cookies/index.cjs');
|
|
7
7
|
require('../../shared/better-auth.CHyZMcYK.cjs');
|
|
8
8
|
require('../../shared/better-auth.DiSjtgs9.cjs');
|
|
@@ -11,7 +11,7 @@ require('defu');
|
|
|
11
11
|
const validateAuthorizationCode = require('../../shared/better-auth.DdjqxOIu.cjs');
|
|
12
12
|
require('@better-auth/utils/hash');
|
|
13
13
|
require('@better-auth/utils/base64');
|
|
14
|
-
const state = require('../../shared/better-auth.
|
|
14
|
+
const state = require('../../shared/better-auth.CHHC_PJT.cjs');
|
|
15
15
|
const fetch = require('@better-fetch/fetch');
|
|
16
16
|
const jose = require('jose');
|
|
17
17
|
require('../../social-providers/index.cjs');
|
|
@@ -29,7 +29,7 @@ require('../../shared/better-auth.C1hdVENX.cjs');
|
|
|
29
29
|
require('../../shared/better-auth.Bg6iw3ig.cjs');
|
|
30
30
|
require('@better-auth/utils/hmac');
|
|
31
31
|
require('../../shared/better-auth.BMYo0QR-.cjs');
|
|
32
|
-
require('../../shared/better-auth.
|
|
32
|
+
require('../../shared/better-auth.C-R0J0n1.cjs');
|
|
33
33
|
require('jose/errors');
|
|
34
34
|
require('../../shared/better-auth.D3mtHEZg.cjs');
|
|
35
35
|
require('@better-auth/utils/binary');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as better_call from 'better-call';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { O as OAuth2Tokens } from '../../shared/better-auth.GFrhA2ZN.cjs';
|
|
4
|
-
import { U as User } from '../../shared/better-auth.
|
|
4
|
+
import { U as User } from '../../shared/better-auth.CPKTEzG-.cjs';
|
|
5
5
|
import '../../shared/better-auth.Bi8FQwDD.cjs';
|
|
6
6
|
import 'jose';
|
|
7
7
|
import 'kysely';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as better_call from 'better-call';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { O as OAuth2Tokens } from '../../shared/better-auth.Dzvtygs8.mjs';
|
|
4
|
-
import { U as User } from '../../shared/better-auth.
|
|
4
|
+
import { U as User } from '../../shared/better-auth.Ck0xlDsK.mjs';
|
|
5
5
|
import '../../shared/better-auth.Bi8FQwDD.mjs';
|
|
6
6
|
import 'jose';
|
|
7
7
|
import 'kysely';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as better_call from 'better-call';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { O as OAuth2Tokens } from '../../shared/better-auth.BRpbZ8Wm.js';
|
|
4
|
-
import { U as User } from '../../shared/better-auth.
|
|
4
|
+
import { U as User } from '../../shared/better-auth.DiHCWsNg.js';
|
|
5
5
|
import '../../shared/better-auth.Bi8FQwDD.js';
|
|
6
6
|
import 'jose';
|
|
7
7
|
import 'kysely';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { APIError } from 'better-call';
|
|
3
|
-
import { a as createAuthEndpoint, h as handleOAuthUserInfo, s as sessionMiddleware } from '../../shared/better-auth.
|
|
3
|
+
import { a as createAuthEndpoint, h as handleOAuthUserInfo, s as sessionMiddleware } from '../../shared/better-auth.CFZLHBFT.mjs';
|
|
4
4
|
import { setSessionCookie } from '../../cookies/index.mjs';
|
|
5
5
|
import '../../shared/better-auth.C24Bzw4w.mjs';
|
|
6
6
|
import '../../shared/better-auth.8zoxzg-F.mjs';
|
|
@@ -9,7 +9,7 @@ import 'defu';
|
|
|
9
9
|
import { v as validateAuthorizationCode, a as validateToken, c as createAuthorizationURL } from '../../shared/better-auth.D7syfoJW.mjs';
|
|
10
10
|
import '@better-auth/utils/hash';
|
|
11
11
|
import '@better-auth/utils/base64';
|
|
12
|
-
import { p as parseState, g as generateState } from '../../shared/better-auth.
|
|
12
|
+
import { p as parseState, g as generateState } from '../../shared/better-auth.CbXAPXob.mjs';
|
|
13
13
|
import { betterFetch, BetterFetchError } from '@better-fetch/fetch';
|
|
14
14
|
import { decodeJwt } from 'jose';
|
|
15
15
|
import '../../social-providers/index.mjs';
|
|
@@ -27,7 +27,7 @@ import '../../shared/better-auth.CW6D9eSx.mjs';
|
|
|
27
27
|
import '../../shared/better-auth.BUPPRXfK.mjs';
|
|
28
28
|
import '@better-auth/utils/hmac';
|
|
29
29
|
import '../../shared/better-auth.DDEbWX-S.mjs';
|
|
30
|
-
import '../../shared/better-auth.
|
|
30
|
+
import '../../shared/better-auth.VTXNLFMT.mjs';
|
|
31
31
|
import 'jose/errors';
|
|
32
32
|
import '../../shared/better-auth.tB5eU6EY.mjs';
|
|
33
33
|
import '@better-auth/utils/binary';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const random = require('../../shared/better-auth.CYeOI8C-.cjs');
|
|
4
4
|
const zod = require('zod');
|
|
5
|
-
const account = require('../../shared/better-auth.
|
|
5
|
+
const account = require('../../shared/better-auth.GVCiTzec.cjs');
|
|
6
6
|
const betterCall = require('better-call');
|
|
7
7
|
const cookies_index = require('../../cookies/index.cjs');
|
|
8
8
|
const schema$1 = require('../../shared/better-auth.CHyZMcYK.cjs');
|
|
@@ -10,7 +10,7 @@ require('../../shared/better-auth.DiSjtgs9.cjs');
|
|
|
10
10
|
require('../../shared/better-auth.GpOOav9x.cjs');
|
|
11
11
|
require('defu');
|
|
12
12
|
const crypto_index = require('../../crypto/index.cjs');
|
|
13
|
-
const verifyMiddleware = require('../../shared/better-auth.
|
|
13
|
+
const verifyMiddleware = require('../../shared/better-auth.B6Xcg5N5.cjs');
|
|
14
14
|
const errorCode = require('../../shared/better-auth.C1-vpKly.cjs');
|
|
15
15
|
require('@better-auth/utils/hash');
|
|
16
16
|
require('@noble/ciphers/chacha');
|
|
@@ -32,21 +32,21 @@ require('@better-fetch/fetch');
|
|
|
32
32
|
require('../../shared/better-auth.DdjqxOIu.cjs');
|
|
33
33
|
require('../../shared/better-auth.C1hdVENX.cjs');
|
|
34
34
|
require('../../shared/better-auth.ANpbi45u.cjs');
|
|
35
|
-
require('../../shared/better-auth.
|
|
35
|
+
require('../../shared/better-auth.CHHC_PJT.cjs');
|
|
36
36
|
require('../../shared/better-auth.Bg6iw3ig.cjs');
|
|
37
37
|
require('../../shared/better-auth.BMYo0QR-.cjs');
|
|
38
|
-
require('../../shared/better-auth.
|
|
38
|
+
require('../../shared/better-auth.C-R0J0n1.cjs');
|
|
39
39
|
require('jose/errors');
|
|
40
40
|
require('../../shared/better-auth.D3mtHEZg.cjs');
|
|
41
41
|
require('@better-auth/utils/binary');
|
|
42
42
|
require('../../shared/better-auth.YUF6P-PB.cjs');
|
|
43
43
|
|
|
44
44
|
function generateBackupCodesFn(options) {
|
|
45
|
-
return Array.from({ length: 10 }).fill(null).map(() => random.generateRandomString(10, "a-z", "0-9", "A-Z")).map((code) => `${code.slice(0, 5)}-${code.slice(5)}`);
|
|
45
|
+
return Array.from({ length: options?.amount ?? 10 }).fill(null).map(() => random.generateRandomString(options?.length ?? 10, "a-z", "0-9", "A-Z")).map((code) => `${code.slice(0, 5)}-${code.slice(5)}`);
|
|
46
46
|
}
|
|
47
47
|
async function generateBackupCodes(secret, options) {
|
|
48
48
|
const key = secret;
|
|
49
|
-
const backupCodes = options?.customBackupCodesGenerate ? options.customBackupCodesGenerate() : generateBackupCodesFn();
|
|
49
|
+
const backupCodes = options?.customBackupCodesGenerate ? options.customBackupCodesGenerate() : generateBackupCodesFn(options);
|
|
50
50
|
const encCodes = await crypto_index.symmetricEncrypt({
|
|
51
51
|
data: JSON.stringify(backupCodes),
|
|
52
52
|
key
|
|
@@ -738,7 +738,7 @@ const twoFactor = (options) => {
|
|
|
738
738
|
body: zod.z.object({
|
|
739
739
|
password: zod.z.string({
|
|
740
740
|
description: "User password"
|
|
741
|
-
})
|
|
741
|
+
})
|
|
742
742
|
}),
|
|
743
743
|
use: [account.sessionMiddleware],
|
|
744
744
|
metadata: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import * as better_call from 'better-call';
|
|
3
|
-
import { U as User, I as InferOptionSchema, d as AuthEndpoint, S as Session, G as GenericEndpointContext, H as HookEndpointContext } from '../../shared/better-auth.
|
|
3
|
+
import { U as User, I as InferOptionSchema, d as AuthEndpoint, S as Session, G as GenericEndpointContext, H as HookEndpointContext } from '../../shared/better-auth.CPKTEzG-.cjs';
|
|
4
4
|
import { L as LiteralString } from '../../shared/better-auth.Bi8FQwDD.cjs';
|
|
5
5
|
import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
6
6
|
import 'kysely';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import * as better_call from 'better-call';
|
|
3
|
-
import { U as User, I as InferOptionSchema, d as AuthEndpoint, S as Session, G as GenericEndpointContext, H as HookEndpointContext } from '../../shared/better-auth.
|
|
3
|
+
import { U as User, I as InferOptionSchema, d as AuthEndpoint, S as Session, G as GenericEndpointContext, H as HookEndpointContext } from '../../shared/better-auth.Ck0xlDsK.mjs';
|
|
4
4
|
import { L as LiteralString } from '../../shared/better-auth.Bi8FQwDD.mjs';
|
|
5
5
|
import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
6
6
|
import 'kysely';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import * as better_call from 'better-call';
|
|
3
|
-
import { U as User, I as InferOptionSchema, d as AuthEndpoint, S as Session, G as GenericEndpointContext, H as HookEndpointContext } from '../../shared/better-auth.
|
|
3
|
+
import { U as User, I as InferOptionSchema, d as AuthEndpoint, S as Session, G as GenericEndpointContext, H as HookEndpointContext } from '../../shared/better-auth.DiHCWsNg.js';
|
|
4
4
|
import { L as LiteralString } from '../../shared/better-auth.Bi8FQwDD.js';
|
|
5
5
|
import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
6
6
|
import 'kysely';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { g as generateRandomString } from '../../shared/better-auth.B4Qoxdgc.mjs';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { a as createAuthEndpoint, s as sessionMiddleware, c as createAuthMiddleware, B as BASE_ERROR_CODES } from '../../shared/better-auth.
|
|
3
|
+
import { a as createAuthEndpoint, s as sessionMiddleware, c as createAuthMiddleware, B as BASE_ERROR_CODES } from '../../shared/better-auth.CFZLHBFT.mjs';
|
|
4
4
|
import { APIError } from 'better-call';
|
|
5
5
|
import { setSessionCookie, deleteSessionCookie } from '../../cookies/index.mjs';
|
|
6
6
|
import { m as mergeSchema } from '../../shared/better-auth.C24Bzw4w.mjs';
|
|
@@ -8,7 +8,7 @@ import '../../shared/better-auth.8zoxzg-F.mjs';
|
|
|
8
8
|
import '../../shared/better-auth.DH3YjMQH.mjs';
|
|
9
9
|
import 'defu';
|
|
10
10
|
import { symmetricEncrypt, symmetricDecrypt } from '../../crypto/index.mjs';
|
|
11
|
-
import { v as verifyTwoFactorMiddleware, T as TRUST_DEVICE_COOKIE_NAME, a as TWO_FACTOR_COOKIE_NAME } from '../../shared/better-auth.
|
|
11
|
+
import { v as verifyTwoFactorMiddleware, T as TRUST_DEVICE_COOKIE_NAME, a as TWO_FACTOR_COOKIE_NAME } from '../../shared/better-auth.CABkkSP8.mjs';
|
|
12
12
|
import { T as TWO_FACTOR_ERROR_CODES } from '../../shared/better-auth.BcoSd9tC.mjs';
|
|
13
13
|
import '@better-auth/utils/hash';
|
|
14
14
|
import '@noble/ciphers/chacha';
|
|
@@ -30,21 +30,21 @@ import '@better-fetch/fetch';
|
|
|
30
30
|
import '../../shared/better-auth.D7syfoJW.mjs';
|
|
31
31
|
import '../../shared/better-auth.CW6D9eSx.mjs';
|
|
32
32
|
import '../../shared/better-auth.DdzSJf-n.mjs';
|
|
33
|
-
import '../../shared/better-auth.
|
|
33
|
+
import '../../shared/better-auth.CbXAPXob.mjs';
|
|
34
34
|
import '../../shared/better-auth.BUPPRXfK.mjs';
|
|
35
35
|
import '../../shared/better-auth.DDEbWX-S.mjs';
|
|
36
|
-
import '../../shared/better-auth.
|
|
36
|
+
import '../../shared/better-auth.VTXNLFMT.mjs';
|
|
37
37
|
import 'jose/errors';
|
|
38
38
|
import '../../shared/better-auth.tB5eU6EY.mjs';
|
|
39
39
|
import '@better-auth/utils/binary';
|
|
40
40
|
import '../../shared/better-auth.OT3XFeFk.mjs';
|
|
41
41
|
|
|
42
42
|
function generateBackupCodesFn(options) {
|
|
43
|
-
return Array.from({ length: 10 }).fill(null).map(() => generateRandomString(10, "a-z", "0-9", "A-Z")).map((code) => `${code.slice(0, 5)}-${code.slice(5)}`);
|
|
43
|
+
return Array.from({ length: options?.amount ?? 10 }).fill(null).map(() => generateRandomString(options?.length ?? 10, "a-z", "0-9", "A-Z")).map((code) => `${code.slice(0, 5)}-${code.slice(5)}`);
|
|
44
44
|
}
|
|
45
45
|
async function generateBackupCodes(secret, options) {
|
|
46
46
|
const key = secret;
|
|
47
|
-
const backupCodes = options?.customBackupCodesGenerate ? options.customBackupCodesGenerate() : generateBackupCodesFn();
|
|
47
|
+
const backupCodes = options?.customBackupCodesGenerate ? options.customBackupCodesGenerate() : generateBackupCodesFn(options);
|
|
48
48
|
const encCodes = await symmetricEncrypt({
|
|
49
49
|
data: JSON.stringify(backupCodes),
|
|
50
50
|
key
|
|
@@ -736,7 +736,7 @@ const twoFactor = (options) => {
|
|
|
736
736
|
body: z.object({
|
|
737
737
|
password: z.string({
|
|
738
738
|
description: "User password"
|
|
739
|
-
})
|
|
739
|
+
})
|
|
740
740
|
}),
|
|
741
741
|
use: [sessionMiddleware],
|
|
742
742
|
metadata: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const zod = require('zod');
|
|
4
|
-
const account = require('../../shared/better-auth.
|
|
4
|
+
const account = require('../../shared/better-auth.GVCiTzec.cjs');
|
|
5
5
|
const betterCall = require('better-call');
|
|
6
6
|
const cookies_index = require('../../cookies/index.cjs');
|
|
7
7
|
const schema$1 = require('../../shared/better-auth.CHyZMcYK.cjs');
|
|
@@ -26,11 +26,11 @@ require('@noble/hashes/utils');
|
|
|
26
26
|
require('../../shared/better-auth.CYeOI8C-.cjs');
|
|
27
27
|
require('@better-auth/utils/random');
|
|
28
28
|
require('../../shared/better-auth.ANpbi45u.cjs');
|
|
29
|
-
require('../../shared/better-auth.
|
|
29
|
+
require('../../shared/better-auth.CHHC_PJT.cjs');
|
|
30
30
|
require('../../shared/better-auth.Bg6iw3ig.cjs');
|
|
31
31
|
require('@better-auth/utils/hmac');
|
|
32
32
|
require('../../shared/better-auth.BMYo0QR-.cjs');
|
|
33
|
-
require('../../shared/better-auth.
|
|
33
|
+
require('../../shared/better-auth.C-R0J0n1.cjs');
|
|
34
34
|
require('jose/errors');
|
|
35
35
|
require('../../shared/better-auth.D3mtHEZg.cjs');
|
|
36
36
|
require('@better-auth/utils/binary');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import * as better_call from 'better-call';
|
|
3
|
-
import { I as InferOptionSchema, H as HookEndpointContext } from '../../shared/better-auth.
|
|
3
|
+
import { I as InferOptionSchema, H as HookEndpointContext } from '../../shared/better-auth.CPKTEzG-.cjs';
|
|
4
4
|
import '../../shared/better-auth.Bi8FQwDD.cjs';
|
|
5
5
|
import 'kysely';
|
|
6
6
|
import '../../shared/better-auth.GFrhA2ZN.cjs';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import * as better_call from 'better-call';
|
|
3
|
-
import { I as InferOptionSchema, H as HookEndpointContext } from '../../shared/better-auth.
|
|
3
|
+
import { I as InferOptionSchema, H as HookEndpointContext } from '../../shared/better-auth.Ck0xlDsK.mjs';
|
|
4
4
|
import '../../shared/better-auth.Bi8FQwDD.mjs';
|
|
5
5
|
import 'kysely';
|
|
6
6
|
import '../../shared/better-auth.Dzvtygs8.mjs';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import * as better_call from 'better-call';
|
|
3
|
-
import { I as InferOptionSchema, H as HookEndpointContext } from '../../shared/better-auth.
|
|
3
|
+
import { I as InferOptionSchema, H as HookEndpointContext } from '../../shared/better-auth.DiHCWsNg.js';
|
|
4
4
|
import '../../shared/better-auth.Bi8FQwDD.js';
|
|
5
5
|
import 'kysely';
|
|
6
6
|
import '../../shared/better-auth.BRpbZ8Wm.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { c as createAuthMiddleware, a as createAuthEndpoint, b as sendVerificationEmailFn, B as BASE_ERROR_CODES } from '../../shared/better-auth.
|
|
2
|
+
import { c as createAuthMiddleware, a as createAuthEndpoint, b as sendVerificationEmailFn, B as BASE_ERROR_CODES } from '../../shared/better-auth.CFZLHBFT.mjs';
|
|
3
3
|
import { APIError } from 'better-call';
|
|
4
4
|
import { setSessionCookie } from '../../cookies/index.mjs';
|
|
5
5
|
import { m as mergeSchema } from '../../shared/better-auth.C24Bzw4w.mjs';
|
|
@@ -24,11 +24,11 @@ import '@noble/hashes/utils';
|
|
|
24
24
|
import '../../shared/better-auth.B4Qoxdgc.mjs';
|
|
25
25
|
import '@better-auth/utils/random';
|
|
26
26
|
import '../../shared/better-auth.DdzSJf-n.mjs';
|
|
27
|
-
import '../../shared/better-auth.
|
|
27
|
+
import '../../shared/better-auth.CbXAPXob.mjs';
|
|
28
28
|
import '../../shared/better-auth.BUPPRXfK.mjs';
|
|
29
29
|
import '@better-auth/utils/hmac';
|
|
30
30
|
import '../../shared/better-auth.DDEbWX-S.mjs';
|
|
31
|
-
import '../../shared/better-auth.
|
|
31
|
+
import '../../shared/better-auth.VTXNLFMT.mjs';
|
|
32
32
|
import 'jose/errors';
|
|
33
33
|
import '../../shared/better-auth.tB5eU6EY.mjs';
|
|
34
34
|
import '@better-auth/utils/binary';
|
|
@@ -478,17 +478,13 @@ const createInternalAdapter = (adapter, ctx) => {
|
|
|
478
478
|
]
|
|
479
479
|
});
|
|
480
480
|
},
|
|
481
|
-
deleteAccount: async (
|
|
481
|
+
deleteAccount: async (accountId) => {
|
|
482
482
|
await adapter.delete({
|
|
483
483
|
model: "account",
|
|
484
484
|
where: [
|
|
485
485
|
{
|
|
486
|
-
field: "
|
|
487
|
-
value:
|
|
488
|
-
},
|
|
489
|
-
{
|
|
490
|
-
field: "userId",
|
|
491
|
-
value: userId
|
|
486
|
+
field: "id",
|
|
487
|
+
value: accountId
|
|
492
488
|
}
|
|
493
489
|
]
|
|
494
490
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const betterCall = require('better-call');
|
|
4
|
-
const account = require('./better-auth.
|
|
4
|
+
const account = require('./better-auth.GVCiTzec.cjs');
|
|
5
5
|
const cookies_index = require('../cookies/index.cjs');
|
|
6
6
|
const zod = require('zod');
|
|
7
7
|
require('./better-auth.CHyZMcYK.cjs');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { APIError } from 'better-call';
|
|
3
|
-
import { c as createAuthMiddleware, g as getSessionFromCtx, a as createAuthEndpoint } from './better-auth.
|
|
3
|
+
import { c as createAuthMiddleware, g as getSessionFromCtx, a as createAuthEndpoint } from './better-auth.CFZLHBFT.mjs';
|
|
4
4
|
import { setSessionCookie, deleteSessionCookie } from '../cookies/index.mjs';
|
|
5
5
|
import { m as mergeSchema } from './better-auth.C24Bzw4w.mjs';
|
|
6
6
|
import './better-auth.8zoxzg-F.mjs';
|
|
@@ -49,7 +49,7 @@ const admin = (options) => {
|
|
|
49
49
|
};
|
|
50
50
|
const adminMiddleware = createAuthMiddleware(async (ctx) => {
|
|
51
51
|
const session = await getSessionFromCtx(ctx);
|
|
52
|
-
if (
|
|
52
|
+
if (!session) {
|
|
53
53
|
throw new APIError("UNAUTHORIZED");
|
|
54
54
|
}
|
|
55
55
|
return {
|
|
@@ -1056,7 +1056,7 @@ const admin = (options) => {
|
|
|
1056
1056
|
message: "invalid permission check. you can only check one resource permission at a time."
|
|
1057
1057
|
});
|
|
1058
1058
|
}
|
|
1059
|
-
const session = ctx
|
|
1059
|
+
const session = await getSessionFromCtx(ctx);
|
|
1060
1060
|
if (!session && (ctx.request || ctx.headers) && !ctx.body.userId && !ctx.body.role) {
|
|
1061
1061
|
throw new APIError("UNAUTHORIZED");
|
|
1062
1062
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const fetch$1 = require('@better-fetch/fetch');
|
|
4
|
-
const url = require('./better-auth.
|
|
4
|
+
const url = require('./better-auth.C-R0J0n1.cjs');
|
|
5
5
|
const nanostores = require('nanostores');
|
|
6
6
|
const query = require('./better-auth.C_Zl7Etp.cjs');
|
|
7
7
|
const parser = require('./better-auth.DhsGZ30Q.cjs');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as zod from 'zod';
|
|
2
2
|
import * as better_call from 'better-call';
|
|
3
|
-
import { G as GenericEndpointContext, I as InferOptionSchema, H as HookEndpointContext, l as AuthContext } from './better-auth.
|
|
3
|
+
import { G as GenericEndpointContext, I as InferOptionSchema, H as HookEndpointContext, l as AuthContext } from './better-auth.CPKTEzG-.cjs';
|
|
4
4
|
import { Statements } from '../plugins/access/index.cjs';
|
|
5
5
|
|
|
6
6
|
declare const apiKeySchema: ({ timeWindow, rateLimitMax, }: {
|
|
@@ -2,7 +2,7 @@ import { AccessControl, Role, Statements } from '../plugins/access/index.mjs';
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import * as better_call from 'better-call';
|
|
4
4
|
import { b as Prettify } from './better-auth.Bi8FQwDD.mjs';
|
|
5
|
-
import { U as User, S as Session, G as GenericEndpointContext } from './better-auth.
|
|
5
|
+
import { U as User, S as Session, G as GenericEndpointContext } from './better-auth.Ck0xlDsK.mjs';
|
|
6
6
|
import { defaultRoles } from '../plugins/organization/access/index.mjs';
|
|
7
7
|
|
|
8
8
|
declare const organizationSchema: z.ZodObject<{
|
|
@@ -21,7 +21,7 @@ function withPath(url, path = "/api/auth") {
|
|
|
21
21
|
path = path.startsWith("/") ? path : `/${path}`;
|
|
22
22
|
return `${url.replace(/\/+$/, "")}${path}`;
|
|
23
23
|
}
|
|
24
|
-
function getBaseURL(url, path) {
|
|
24
|
+
function getBaseURL(url, path, request) {
|
|
25
25
|
if (url) {
|
|
26
26
|
return withPath(url, path);
|
|
27
27
|
}
|
|
@@ -29,6 +29,20 @@ function getBaseURL(url, path) {
|
|
|
29
29
|
if (fromEnv) {
|
|
30
30
|
return withPath(fromEnv, path);
|
|
31
31
|
}
|
|
32
|
+
const fromRequest = request?.headers.get("x-forwarded-host");
|
|
33
|
+
const fromRequestProto = request?.headers.get("x-forwarded-proto");
|
|
34
|
+
if (fromRequest && fromRequestProto) {
|
|
35
|
+
return withPath(`${fromRequestProto}://${fromRequest}`, path);
|
|
36
|
+
}
|
|
37
|
+
if (request) {
|
|
38
|
+
const url2 = getOrigin(request.url);
|
|
39
|
+
if (!url2) {
|
|
40
|
+
throw new index.BetterAuthError(
|
|
41
|
+
"Could not get origin from request. Please provide a valid base URL."
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
return withPath(url2, path);
|
|
45
|
+
}
|
|
32
46
|
if (typeof window !== "undefined" && window.location) {
|
|
33
47
|
return withPath(window.location.origin, path);
|
|
34
48
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { APIError } from 'better-call';
|
|
2
|
-
import { c as createAuthMiddleware, g as getSessionFromCtx } from './better-auth.
|
|
2
|
+
import { c as createAuthMiddleware, g as getSessionFromCtx } from './better-auth.CFZLHBFT.mjs';
|
|
3
3
|
import { setSessionCookie } from '../cookies/index.mjs';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import './better-auth.C24Bzw4w.mjs';
|
|
@@ -3,7 +3,7 @@ import { deleteSessionCookie, setSessionCookie, setCookieCache } from '../cookie
|
|
|
3
3
|
import { createMiddleware, createEndpoint, APIError } from 'better-call';
|
|
4
4
|
import { SocialProviderListEnum, socialProviderList } from '../social-providers/index.mjs';
|
|
5
5
|
import '@better-auth/utils/random';
|
|
6
|
-
import { g as generateState, p as parseState } from './better-auth.
|
|
6
|
+
import { g as generateState, p as parseState } from './better-auth.CbXAPXob.mjs';
|
|
7
7
|
import { a as logger } from './better-auth.DH3YjMQH.mjs';
|
|
8
8
|
import { g as getDate } from './better-auth.CW6D9eSx.mjs';
|
|
9
9
|
import { g as generateId } from './better-auth.BUPPRXfK.mjs';
|
|
@@ -24,7 +24,7 @@ import { createHMAC } from '@better-auth/utils/hmac';
|
|
|
24
24
|
import '@better-fetch/fetch';
|
|
25
25
|
import 'defu';
|
|
26
26
|
import { s as signJWT } from './better-auth.DDEbWX-S.mjs';
|
|
27
|
-
import { b as getHost, c as getProtocol, g as getOrigin } from './better-auth.
|
|
27
|
+
import { b as getHost, c as getProtocol, g as getOrigin } from './better-auth.VTXNLFMT.mjs';
|
|
28
28
|
import { JWTExpired } from 'jose/errors';
|
|
29
29
|
import { s as safeJSONParse } from './better-auth.tB5eU6EY.mjs';
|
|
30
30
|
import { binary } from '@better-auth/utils/binary';
|
|
@@ -176,7 +176,7 @@ const originCheckMiddleware = createAuthMiddleware(async (ctx) => {
|
|
|
176
176
|
const newUserCallbackURL = body?.newUserCallbackURL;
|
|
177
177
|
const trustedOrigins = Array.isArray(context.options.trustedOrigins) ? context.trustedOrigins : [
|
|
178
178
|
...context.trustedOrigins,
|
|
179
|
-
...context.options.trustedOrigins?.(ctx.request) || []
|
|
179
|
+
...await context.options.trustedOrigins?.(ctx.request) || []
|
|
180
180
|
];
|
|
181
181
|
const usesCookies = ctx.headers?.has("cookie");
|
|
182
182
|
const matchesPattern = (url, pattern) => {
|
|
@@ -224,7 +224,7 @@ const originCheck = (getValue) => createAuthMiddleware(async (ctx) => {
|
|
|
224
224
|
context.options.trustedOrigins
|
|
225
225
|
) ? context.trustedOrigins : [
|
|
226
226
|
...context.trustedOrigins,
|
|
227
|
-
...context.options.trustedOrigins?.(ctx.request) || []
|
|
227
|
+
...await context.options.trustedOrigins?.(ctx.request) || []
|
|
228
228
|
];
|
|
229
229
|
const matchesPattern = (url, pattern) => {
|
|
230
230
|
if (url.startsWith("/")) {
|
|
@@ -1632,9 +1632,7 @@ const callbackOAuth = createAuthEndpoint(
|
|
|
1632
1632
|
}
|
|
1633
1633
|
} catch (e) {
|
|
1634
1634
|
c.context.logger.error("INVALID_CALLBACK_REQUEST", e);
|
|
1635
|
-
throw c.redirect(
|
|
1636
|
-
`${c.context.baseURL}/error?error=invalid_callback_request`
|
|
1637
|
-
);
|
|
1635
|
+
throw c.redirect(`${defaultErrorURL}?error=invalid_callback_request`);
|
|
1638
1636
|
}
|
|
1639
1637
|
const { code, error, state, error_description, device_id } = queryOrBody;
|
|
1640
1638
|
if (error) {
|
|
@@ -1655,7 +1653,7 @@ const callbackOAuth = createAuthEndpoint(
|
|
|
1655
1653
|
requestSignUp
|
|
1656
1654
|
} = await parseState(c);
|
|
1657
1655
|
function redirectOnError(error2) {
|
|
1658
|
-
let url = errorURL || callbackURL ||
|
|
1656
|
+
let url = errorURL || callbackURL || defaultErrorURL;
|
|
1659
1657
|
if (url.includes("?")) {
|
|
1660
1658
|
url = `${url}&error=${error2}`;
|
|
1661
1659
|
} else {
|
|
@@ -2575,15 +2573,14 @@ const changeEmail = createAuthEndpoint(
|
|
|
2575
2573
|
message: "Change email is disabled"
|
|
2576
2574
|
});
|
|
2577
2575
|
}
|
|
2578
|
-
|
|
2576
|
+
const newEmail = ctx.body.newEmail.toLowerCase();
|
|
2577
|
+
if (newEmail === ctx.context.session.user.email) {
|
|
2579
2578
|
ctx.context.logger.error("Email is the same");
|
|
2580
2579
|
throw new APIError("BAD_REQUEST", {
|
|
2581
2580
|
message: "Email is the same"
|
|
2582
2581
|
});
|
|
2583
2582
|
}
|
|
2584
|
-
const existingUser = await ctx.context.internalAdapter.findUserByEmail(
|
|
2585
|
-
ctx.body.newEmail
|
|
2586
|
-
);
|
|
2583
|
+
const existingUser = await ctx.context.internalAdapter.findUserByEmail(newEmail);
|
|
2587
2584
|
if (existingUser) {
|
|
2588
2585
|
ctx.context.logger.error("Email already exists");
|
|
2589
2586
|
throw new APIError("BAD_REQUEST", {
|
|
@@ -2591,9 +2588,7 @@ const changeEmail = createAuthEndpoint(
|
|
|
2591
2588
|
});
|
|
2592
2589
|
}
|
|
2593
2590
|
if (ctx.context.session.user.emailVerified !== true) {
|
|
2594
|
-
const existing = await ctx.context.internalAdapter.findUserByEmail(
|
|
2595
|
-
ctx.body.newEmail
|
|
2596
|
-
);
|
|
2591
|
+
const existing = await ctx.context.internalAdapter.findUserByEmail(newEmail);
|
|
2597
2592
|
if (existing) {
|
|
2598
2593
|
throw new APIError("UNPROCESSABLE_ENTITY", {
|
|
2599
2594
|
message: BASE_ERROR_CODES.USER_ALREADY_EXISTS
|
|
@@ -2602,15 +2597,22 @@ const changeEmail = createAuthEndpoint(
|
|
|
2602
2597
|
await ctx.context.internalAdapter.updateUserByEmail(
|
|
2603
2598
|
ctx.context.session.user.email,
|
|
2604
2599
|
{
|
|
2605
|
-
email:
|
|
2600
|
+
email: newEmail
|
|
2606
2601
|
},
|
|
2607
2602
|
ctx
|
|
2608
2603
|
);
|
|
2604
|
+
await setSessionCookie(ctx, {
|
|
2605
|
+
session: ctx.context.session.session,
|
|
2606
|
+
user: {
|
|
2607
|
+
...ctx.context.session.user,
|
|
2608
|
+
email: newEmail
|
|
2609
|
+
}
|
|
2610
|
+
});
|
|
2609
2611
|
if (ctx.context.options.emailVerification?.sendVerificationEmail) {
|
|
2610
2612
|
const token2 = await createEmailVerificationToken(
|
|
2611
2613
|
ctx.context.secret,
|
|
2612
2614
|
ctx.context.session.user.email,
|
|
2613
|
-
|
|
2615
|
+
newEmail,
|
|
2614
2616
|
ctx.context.options.emailVerification?.expiresIn
|
|
2615
2617
|
);
|
|
2616
2618
|
const url2 = `${ctx.context.baseURL}/verify-email?token=${token2}&callbackURL=${ctx.body.callbackURL || "/"}`;
|
|
@@ -2618,7 +2620,7 @@ const changeEmail = createAuthEndpoint(
|
|
|
2618
2620
|
{
|
|
2619
2621
|
user: {
|
|
2620
2622
|
...ctx.context.session.user,
|
|
2621
|
-
email:
|
|
2623
|
+
email: newEmail
|
|
2622
2624
|
},
|
|
2623
2625
|
url: url2,
|
|
2624
2626
|
token: token2
|
|
@@ -2639,14 +2641,14 @@ const changeEmail = createAuthEndpoint(
|
|
|
2639
2641
|
const token = await createEmailVerificationToken(
|
|
2640
2642
|
ctx.context.secret,
|
|
2641
2643
|
ctx.context.session.user.email,
|
|
2642
|
-
|
|
2644
|
+
newEmail,
|
|
2643
2645
|
ctx.context.options.emailVerification?.expiresIn
|
|
2644
2646
|
);
|
|
2645
2647
|
const url = `${ctx.context.baseURL}/verify-email?token=${token}&callbackURL=${ctx.body.callbackURL || "/"}`;
|
|
2646
2648
|
await ctx.context.options.user.changeEmail.sendChangeEmailVerification(
|
|
2647
2649
|
{
|
|
2648
2650
|
user: ctx.context.session.user,
|
|
2649
|
-
newEmail
|
|
2651
|
+
newEmail,
|
|
2650
2652
|
url,
|
|
2651
2653
|
token
|
|
2652
2654
|
},
|
|
@@ -2980,10 +2982,7 @@ const unlinkAccount = createAuthEndpoint(
|
|
|
2980
2982
|
message: BASE_ERROR_CODES.ACCOUNT_NOT_FOUND
|
|
2981
2983
|
});
|
|
2982
2984
|
}
|
|
2983
|
-
await ctx.context.internalAdapter.deleteAccount(
|
|
2984
|
-
ctx.body.providerId,
|
|
2985
|
-
ctx.context.session.user.id
|
|
2986
|
-
);
|
|
2985
|
+
await ctx.context.internalAdapter.deleteAccount(accountExist.id);
|
|
2987
2986
|
return ctx.json({
|
|
2988
2987
|
status: true
|
|
2989
2988
|
});
|