better-auth 1.4.4-beta.2 → 1.4.4-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{access-Bue6UE97.mjs → access-h-uttVNZ.mjs} +1 -1
- package/dist/{access-Cr_p-YVH.mjs → access-vPNO48H4.mjs} +1 -1
- package/dist/{adapter-factory-oT7pVV1b.mjs → adapter-factory-CXEYdBBi.mjs} +2 -2
- package/dist/adapters/drizzle-adapter/index.mjs +5 -6
- package/dist/adapters/index.d.mts +1 -1
- package/dist/adapters/index.mjs +5 -6
- package/dist/adapters/kysely-adapter/index.mjs +5 -6
- package/dist/adapters/memory-adapter/index.mjs +5 -6
- package/dist/adapters/mongodb-adapter/index.mjs +7 -8
- package/dist/adapters/prisma-adapter/index.mjs +5 -6
- package/dist/adapters/test.mjs +3 -4
- package/dist/{admin-C0d5dk6O.mjs → admin-D-OMdNIc.mjs} +6 -6
- package/dist/{anonymous-B5kAEMza.mjs → anonymous-DxoIOUPc.mjs} +5 -5
- package/dist/api/index.d.mts +1 -1
- package/dist/api/index.mjs +11 -12
- package/dist/{api-q2sbQ7PT.mjs → api-CkmycQ2x.mjs} +28 -50
- package/dist/auth/minimal.d.mts +1 -1
- package/dist/auth/minimal.mjs +13 -14
- package/dist/{auth-DtQf_JUg.mjs → auth-DfR8_5w3.mjs} +2 -2
- package/dist/{base-CPOjsixh.mjs → base-CiRMFqet.mjs} +32 -11
- package/dist/{bearer-Bb8KNDdJ.mjs → bearer-C6RSCXv_.mjs} +1 -1
- package/dist/{captcha-Dnh5mC7N.mjs → captcha-Dbvurc2Z.mjs} +1 -1
- package/dist/{chunk-09eW3CcW.mjs → chunk-DbI2OXuS.mjs} +27 -12
- package/dist/client/index.d.mts +1 -1
- package/dist/client/index.mjs +5 -5
- package/dist/client/lynx/index.d.mts +16 -22
- package/dist/client/lynx/index.mjs +3 -3
- package/dist/client/plugins/index.d.mts +60 -44
- package/dist/client/plugins/index.mjs +126 -66
- package/dist/client/react/index.d.mts +16 -22
- package/dist/client/react/index.mjs +3 -3
- package/dist/client/solid/index.d.mts +14 -20
- package/dist/client/solid/index.mjs +4 -4
- package/dist/client/svelte/index.d.mts +16 -22
- package/dist/client/svelte/index.mjs +4 -4
- package/dist/client/vue/index.d.mts +16 -22
- package/dist/client/vue/index.mjs +4 -4
- package/dist/{client-BK3DQpQu.mjs → client-BN9e9KX1.mjs} +2 -2
- package/dist/cookies/index.d.mts +2 -2
- package/dist/cookies/index.mjs +5 -5
- package/dist/{cookies-D_dksn7B.mjs → cookies-D72PbWdz.mjs} +42 -125
- package/dist/crypto/index.mjs +1 -2
- package/dist/{crypto-BQxYXGGX.mjs → crypto-CFUhAR9W.mjs} +93 -1
- package/dist/{custom-session-fyHQcwKB.mjs → custom-session-CaUbM_of.mjs} +2 -2
- package/dist/db/index.d.mts +1 -1
- package/dist/db/index.mjs +7 -8
- package/dist/{device-authorization-F9dLozvK.mjs → device-authorization-9_f1Up5D.mjs} +4 -4
- package/dist/{email-otp-wYPJyq8c.mjs → email-otp-CiznqFUN.mjs} +6 -6
- package/dist/{esm-DPWELC5I.mjs → esm-BXhcK_bt.mjs} +1 -1
- package/dist/{generic-oauth-BlH-OSQN.mjs → generic-oauth-BGbWWUh9.mjs} +5 -5
- package/dist/{get-migration-wMpq_Lmw.mjs → get-migration-Bf0TuCzm.mjs} +11 -7
- package/dist/{has-permission-DN8I_Icv.mjs → has-permission-qCjQqGds.mjs} +1 -1
- package/dist/{haveibeenpwned-v0bNR9PL.mjs → haveibeenpwned-BSsFUFTi.mjs} +1 -1
- package/dist/{index-C-qjuMK3.d.mts → index-0xgBgtem.d.mts} +3 -3
- package/dist/{index-BDwnO3gz.d.mts → index-BGKXL3Av.d.mts} +2 -9
- package/dist/{index-DiT4DbMC.d.mts → index-BVJL9NCo.d.mts} +6 -6
- package/dist/{index-DcYTqy8J.d.mts → index-B_1KAoYv.d.mts} +4 -4
- package/dist/{index-DmC6Ctb-.d.mts → index-BkD9iyuk.d.mts} +8 -8
- package/dist/{index-BbsJ-RVs.d.mts → index-Br01_oSy.d.mts} +7 -7
- package/dist/{index-DljejjCu.d.mts → index-BsRgjUAv.d.mts} +6 -6
- package/dist/{index-J1rkw6JT.d.mts → index-CGBSkAO7.d.mts} +10 -10
- package/dist/{index-BTk-wfTL.d.mts → index-CJ4w3OzO.d.mts} +180 -184
- package/dist/{index-B52PH6jU.d.mts → index-CL-QZ1hb.d.mts} +10 -10
- package/dist/{index-DJFTvRYn.d.mts → index-COEqRbac.d.mts} +14 -14
- package/dist/{index-5t2DAD0k.d.mts → index-CnSDnpiK.d.mts} +15 -15
- package/dist/{index-C8eCoB52.d.mts → index-CujXvEf8.d.mts} +390 -372
- package/dist/{index-UXC1tbRT.d.mts → index-DAPxdOKi.d.mts} +616 -22
- package/dist/{index-CfCxrifw.d.mts → index-DgwGZQ6M.d.mts} +10 -10
- package/dist/{index-C40qLrfj.d.mts → index-DqkPFN8B.d.mts} +3 -3
- package/dist/{index-_MGUkN9y.d.mts → index-DrEnqtuQ.d.mts} +6 -6
- package/dist/{index-d52kDVAg.d.mts → index-Dy2g8XKv.d.mts} +6 -6
- package/dist/{index-CBe2rvyJ.d.mts → index-Hid3pW0N.d.mts} +10 -10
- package/dist/{index-DaaVQEvX.d.mts → index-K2ZMxFny.d.mts} +2 -2
- package/dist/{index-Bn1R6aVZ.d.mts → index-WXoTnrFA.d.mts} +2 -2
- package/dist/{index-CrYIJeWc.d.mts → index-wHdZCXFM.d.mts} +3 -3
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +15 -16
- package/dist/integrations/next-js.d.mts +4 -4
- package/dist/integrations/next-js.mjs +5 -5
- package/dist/integrations/node.d.mts +2 -2
- package/dist/integrations/svelte-kit.d.mts +3 -3
- package/dist/integrations/svelte-kit.mjs +5 -5
- package/dist/integrations/tanstack-start.d.mts +4 -4
- package/dist/integrations/tanstack-start.mjs +5 -5
- package/dist/{jwt-BcNc-TEx.mjs → jwt-Ar1sciI2.mjs} +4 -4
- package/dist/{magic-link-B1zZrjdu.mjs → magic-link-QdHvtdfs.mjs} +3 -3
- package/dist/{multi-session-C855V4lg.mjs → multi-session-CbEYz_wJ.mjs} +3 -3
- package/dist/{oauth-proxy-CSxVQ45y.mjs → oauth-proxy-Dz1E1SVN.mjs} +5 -5
- package/dist/oauth2/index.d.mts +1 -1
- package/dist/oauth2/index.mjs +11 -12
- package/dist/{oidc-provider-Dx4WDdQk.mjs → oidc-provider-B9SsN23J.mjs} +6 -6
- package/dist/{one-tap-CPlglews.mjs → one-tap-Bz8Q39Od.mjs} +2 -2
- package/dist/one-time-token-C8YQxf38.mjs +64 -0
- package/dist/{open-api-C33sH63J.mjs → open-api-DZG02vyi.mjs} +5 -2
- package/dist/{organization-BsVZQpxC.mjs → organization-BdJSRNgM.mjs} +31 -12
- package/dist/{phone-number-DIG4Jnsx.mjs → phone-number-wU9XYnr8.mjs} +4 -4
- package/dist/plugins/access/index.mjs +1 -1
- package/dist/plugins/admin/access/index.d.mts +21 -21
- package/dist/plugins/admin/access/index.mjs +2 -2
- package/dist/plugins/admin/index.d.mts +21 -21
- package/dist/plugins/admin/index.mjs +16 -17
- package/dist/plugins/anonymous/index.d.mts +2 -2
- package/dist/plugins/anonymous/index.mjs +12 -13
- package/dist/plugins/bearer/index.d.mts +1 -1
- package/dist/plugins/bearer/index.mjs +6 -6
- package/dist/plugins/captcha/index.d.mts +1 -1
- package/dist/plugins/captcha/index.mjs +2 -2
- package/dist/plugins/custom-session/index.d.mts +2 -2
- package/dist/plugins/custom-session/index.mjs +13 -14
- package/dist/plugins/device-authorization/index.d.mts +1 -1
- package/dist/plugins/device-authorization/index.mjs +11 -12
- package/dist/plugins/email-otp/index.d.mts +1 -1
- package/dist/plugins/email-otp/index.mjs +13 -14
- package/dist/plugins/generic-oauth/index.d.mts +3 -3
- package/dist/plugins/generic-oauth/index.mjs +12 -13
- package/dist/plugins/haveibeenpwned/index.d.mts +1 -1
- package/dist/plugins/haveibeenpwned/index.mjs +12 -13
- package/dist/plugins/index.d.mts +22 -22
- package/dist/plugins/index.mjs +43 -43
- package/dist/plugins/jwt/index.d.mts +2 -2
- package/dist/plugins/jwt/index.mjs +12 -13
- package/dist/plugins/magic-link/index.d.mts +1 -1
- package/dist/plugins/magic-link/index.mjs +12 -13
- package/dist/plugins/multi-session/index.d.mts +2 -2
- package/dist/plugins/multi-session/index.mjs +12 -13
- package/dist/plugins/oauth-proxy/index.d.mts +1 -1
- package/dist/plugins/oauth-proxy/index.mjs +13 -14
- package/dist/plugins/oidc-provider/index.d.mts +21 -21
- package/dist/plugins/oidc-provider/index.mjs +13 -14
- package/dist/plugins/one-tap/index.d.mts +1 -1
- package/dist/plugins/one-tap/index.mjs +12 -13
- package/dist/plugins/one-time-token/index.d.mts +3 -3
- package/dist/plugins/one-time-token/index.mjs +12 -43
- package/dist/plugins/open-api/index.d.mts +1 -1
- package/dist/plugins/open-api/index.mjs +12 -13
- package/dist/plugins/organization/access/index.d.mts +21 -21
- package/dist/plugins/organization/access/index.mjs +2 -2
- package/dist/plugins/organization/index.d.mts +21 -21
- package/dist/plugins/organization/index.mjs +16 -17
- package/dist/plugins/phone-number/index.d.mts +2 -2
- package/dist/plugins/phone-number/index.mjs +12 -13
- package/dist/plugins/siwe/index.d.mts +2 -2
- package/dist/plugins/siwe/index.mjs +12 -13
- package/dist/plugins/two-factor/index.d.mts +3 -3
- package/dist/plugins/two-factor/index.mjs +14 -15
- package/dist/plugins/username/index.d.mts +1 -1
- package/dist/plugins/username/index.mjs +12 -13
- package/dist/{plugins-Bgc_0YsW.mjs → plugins-DgSTpOzm.mjs} +16 -68
- package/dist/{promise-C9ABpfHK.mjs → promise-B1BZ0y5h.mjs} +2 -1
- package/dist/{proxy-BM5uXHJk.mjs → proxy-DplNCOES.mjs} +3 -10
- package/dist/{schema-CSB7dlK0.mjs → schema-Bb7wzeK_.mjs} +4 -1
- package/dist/{session-CgfX4vv1.mjs → session-AaRl3_x-.mjs} +4 -4
- package/dist/{siwe-D4lyacqA.mjs → siwe-D81Y4fkp.mjs} +4 -4
- package/dist/test-utils/index.d.mts +26 -32
- package/dist/test-utils/index.mjs +51 -51
- package/dist/{two-factor-1QPLscVk.mjs → two-factor-BDQvVILL.mjs} +6 -6
- package/dist/types/index.d.mts +1 -1
- package/dist/types/index.mjs +1 -1
- package/dist/{username-CxPDW9ty.mjs → username-C_wmkXwt.mjs} +3 -3
- package/dist/{utils-DBbaShi0.mjs → utils-db7gNqd-.mjs} +1 -1
- package/package.json +10 -15
- package/dist/jwt-DzuIBp7t.mjs +0 -94
- /package/dist/{access-DXuPG0DH.mjs → access-Dx8TLKnw.mjs} +0 -0
- /package/dist/{client-CZZjjkJj.mjs → client-CMPEe5-e.mjs} +0 -0
- /package/dist/{get-request-ip-RYTz2Uba.mjs → get-request-ip-D6st-mto.mjs} +0 -0
- /package/dist/{json-_HMgPUVh.mjs → json-CnHxKYpj.mjs} +0 -0
- /package/dist/{misc-D8A8FGv2.mjs → misc-BwNc0MKr.mjs} +0 -0
- /package/dist/{parser-kwbb5q_C.mjs → parser-pHp5yoAv.mjs} +0 -0
- /package/dist/{password-DBH2q5D6.mjs → password-BFQK0cLg.mjs} +0 -0
- /package/dist/{permission-ouQCO-51.mjs → permission-JwliMugl.mjs} +0 -0
- /package/dist/{plugin-helper-CA_Vvnl9.mjs → plugin-helper-zFdFWLgL.mjs} +0 -0
- /package/dist/{types-BPNyg47E.mjs → types-BOTDmeLz.mjs} +0 -0
- /package/dist/{url-BLNRhCPO.mjs → url-CB8xCwz-.mjs} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as getAuthTables, i as initGetDefaultModelName, n as initGetFieldName, r as initGetDefaultFieldName, t as initGetModelName } from "./get-model-name-D4DUV7S2.mjs";
|
|
2
|
-
import { t as generateId } from "./utils-
|
|
3
|
-
import { t as safeJSONParse } from "./json-
|
|
2
|
+
import { t as generateId } from "./utils-db7gNqd-.mjs";
|
|
3
|
+
import { t as safeJSONParse } from "./json-CnHxKYpj.mjs";
|
|
4
4
|
import { TTY_COLORS, getColorDepth, logger } from "@better-auth/core/env";
|
|
5
5
|
import { BetterAuthError } from "@better-auth/core/error";
|
|
6
6
|
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import "../../get-model-name-D4DUV7S2.mjs";
|
|
2
|
-
import "../../utils-
|
|
3
|
-
import "../../crypto-
|
|
4
|
-
import "../../
|
|
5
|
-
import "../../
|
|
6
|
-
import "../../
|
|
7
|
-
import { t as createAdapterFactory } from "../../adapter-factory-oT7pVV1b.mjs";
|
|
2
|
+
import "../../utils-db7gNqd-.mjs";
|
|
3
|
+
import "../../crypto-CFUhAR9W.mjs";
|
|
4
|
+
import "../../misc-BwNc0MKr.mjs";
|
|
5
|
+
import "../../json-CnHxKYpj.mjs";
|
|
6
|
+
import { t as createAdapterFactory } from "../../adapter-factory-CXEYdBBi.mjs";
|
|
8
7
|
import { logger } from "@better-auth/core/env";
|
|
9
8
|
import { BetterAuthError } from "@better-auth/core/error";
|
|
10
9
|
import { and, asc, count, desc, eq, gt, gte, inArray, like, lt, lte, ne, notInArray, or, sql } from "drizzle-orm";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $t as AdapterSchemaCreation, an as Where$1, in as TransactionAdapter } from "../index-
|
|
1
|
+
import { $t as AdapterSchemaCreation, an as Where$1, in as TransactionAdapter } from "../index-CJ4w3OzO.mjs";
|
|
2
2
|
import "../types-CEepZ-RG.mjs";
|
|
3
3
|
import { u as Prettify } from "../helper-DFzV6jvx.mjs";
|
|
4
4
|
import "../index-D8MBzSjs.mjs";
|
package/dist/adapters/index.mjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { i as initGetDefaultModelName, n as initGetFieldName, r as initGetDefaultFieldName, t as initGetModelName } from "../get-model-name-D4DUV7S2.mjs";
|
|
2
|
-
import "../utils-
|
|
3
|
-
import "../crypto-
|
|
4
|
-
import "../
|
|
5
|
-
import "../
|
|
6
|
-
import "../
|
|
7
|
-
import { n as initGetFieldAttributes, r as initGetIdField, t as createAdapterFactory } from "../adapter-factory-oT7pVV1b.mjs";
|
|
2
|
+
import "../utils-db7gNqd-.mjs";
|
|
3
|
+
import "../crypto-CFUhAR9W.mjs";
|
|
4
|
+
import "../misc-BwNc0MKr.mjs";
|
|
5
|
+
import "../json-CnHxKYpj.mjs";
|
|
6
|
+
import { n as initGetFieldAttributes, r as initGetIdField, t as createAdapterFactory } from "../adapter-factory-CXEYdBBi.mjs";
|
|
8
7
|
|
|
9
8
|
export * from "@better-auth/core/db/adapter"
|
|
10
9
|
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { n as getKyselyDatabaseType, t as createKyselyAdapter } from "../../dialect-D9ZUZA4J.mjs";
|
|
2
2
|
import "../../get-model-name-D4DUV7S2.mjs";
|
|
3
|
-
import "../../utils-
|
|
4
|
-
import "../../crypto-
|
|
5
|
-
import "../../
|
|
6
|
-
import "../../
|
|
7
|
-
import "../../
|
|
8
|
-
import { t as createAdapterFactory } from "../../adapter-factory-oT7pVV1b.mjs";
|
|
3
|
+
import "../../utils-db7gNqd-.mjs";
|
|
4
|
+
import "../../crypto-CFUhAR9W.mjs";
|
|
5
|
+
import "../../misc-BwNc0MKr.mjs";
|
|
6
|
+
import "../../json-CnHxKYpj.mjs";
|
|
7
|
+
import { t as createAdapterFactory } from "../../adapter-factory-CXEYdBBi.mjs";
|
|
9
8
|
import { sql } from "kysely";
|
|
10
9
|
|
|
11
10
|
//#region src/adapters/kysely-adapter/kysely-adapter.ts
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import "../../get-model-name-D4DUV7S2.mjs";
|
|
2
|
-
import "../../utils-
|
|
3
|
-
import "../../crypto-
|
|
4
|
-
import "../../
|
|
5
|
-
import "../../
|
|
6
|
-
import "../../
|
|
7
|
-
import { t as createAdapterFactory } from "../../adapter-factory-oT7pVV1b.mjs";
|
|
2
|
+
import "../../utils-db7gNqd-.mjs";
|
|
3
|
+
import "../../crypto-CFUhAR9W.mjs";
|
|
4
|
+
import "../../misc-BwNc0MKr.mjs";
|
|
5
|
+
import "../../json-CnHxKYpj.mjs";
|
|
6
|
+
import { t as createAdapterFactory } from "../../adapter-factory-CXEYdBBi.mjs";
|
|
8
7
|
import { logger } from "@better-auth/core/env";
|
|
9
8
|
|
|
10
9
|
//#region src/adapters/memory-adapter/memory-adapter.ts
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import "../../get-model-name-D4DUV7S2.mjs";
|
|
2
|
-
import "../../utils-
|
|
3
|
-
import "../../crypto-
|
|
4
|
-
import "../../
|
|
5
|
-
import "../../
|
|
6
|
-
import "../../
|
|
7
|
-
import { t as createAdapterFactory } from "../../adapter-factory-oT7pVV1b.mjs";
|
|
2
|
+
import "../../utils-db7gNqd-.mjs";
|
|
3
|
+
import "../../crypto-CFUhAR9W.mjs";
|
|
4
|
+
import "../../misc-BwNc0MKr.mjs";
|
|
5
|
+
import "../../json-CnHxKYpj.mjs";
|
|
6
|
+
import { t as createAdapterFactory } from "../../adapter-factory-CXEYdBBi.mjs";
|
|
8
7
|
import { ObjectId } from "mongodb";
|
|
9
8
|
|
|
10
9
|
//#region src/adapters/mongodb-adapter/mongodb-adapter.ts
|
|
@@ -31,9 +30,9 @@ const mongodbAdapter = (db, config) => {
|
|
|
31
30
|
return v;
|
|
32
31
|
}
|
|
33
32
|
if (v instanceof ObjectId) return v;
|
|
34
|
-
throw new Error("Invalid id value,
|
|
33
|
+
throw new Error("Invalid id value, received: " + JSON.stringify(v));
|
|
35
34
|
});
|
|
36
|
-
throw new Error("Invalid id value,
|
|
35
|
+
throw new Error("Invalid id value, received: " + JSON.stringify(value));
|
|
37
36
|
}
|
|
38
37
|
try {
|
|
39
38
|
return new ObjectId(value);
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import "../../get-model-name-D4DUV7S2.mjs";
|
|
2
|
-
import "../../utils-
|
|
3
|
-
import "../../crypto-
|
|
4
|
-
import "../../
|
|
5
|
-
import "../../
|
|
6
|
-
import "../../
|
|
7
|
-
import { t as createAdapterFactory } from "../../adapter-factory-oT7pVV1b.mjs";
|
|
2
|
+
import "../../utils-db7gNqd-.mjs";
|
|
3
|
+
import "../../crypto-CFUhAR9W.mjs";
|
|
4
|
+
import "../../misc-BwNc0MKr.mjs";
|
|
5
|
+
import "../../json-CnHxKYpj.mjs";
|
|
6
|
+
import { t as createAdapterFactory } from "../../adapter-factory-CXEYdBBi.mjs";
|
|
8
7
|
import { BetterAuthError } from "@better-auth/core/error";
|
|
9
8
|
|
|
10
9
|
//#region src/adapters/prisma-adapter/prisma-adapter.ts
|
package/dist/adapters/test.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { t as generateId } from "../utils-
|
|
2
|
-
import "../crypto-
|
|
3
|
-
import "../
|
|
4
|
-
import "../misc-D8A8FGv2.mjs";
|
|
1
|
+
import { t as generateId } from "../utils-db7gNqd-.mjs";
|
|
2
|
+
import "../crypto-CFUhAR9W.mjs";
|
|
3
|
+
import "../misc-BwNc0MKr.mjs";
|
|
5
4
|
import { beforeAll, describe, expect, test } from "vitest";
|
|
6
5
|
|
|
7
6
|
//#region src/adapters/test.ts
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { l as parseUserOutput, t as mergeSchema, u as getDate } from "./schema-
|
|
2
|
-
import { t as APIError } from "./api-
|
|
3
|
-
import { c as setSessionCookie, n as deleteSessionCookie } from "./cookies-
|
|
4
|
-
import { r as getSessionFromCtx } from "./session-
|
|
5
|
-
import { t as hasPermission } from "./has-permission-
|
|
6
|
-
import { t as getEndpointResponse } from "./plugin-helper-
|
|
1
|
+
import { l as parseUserOutput, t as mergeSchema, u as getDate } from "./schema-Bb7wzeK_.mjs";
|
|
2
|
+
import { t as APIError } from "./api-CkmycQ2x.mjs";
|
|
3
|
+
import { c as setSessionCookie, n as deleteSessionCookie } from "./cookies-D72PbWdz.mjs";
|
|
4
|
+
import { r as getSessionFromCtx } from "./session-AaRl3_x-.mjs";
|
|
5
|
+
import { t as hasPermission } from "./has-permission-qCjQqGds.mjs";
|
|
6
|
+
import { t as getEndpointResponse } from "./plugin-helper-zFdFWLgL.mjs";
|
|
7
7
|
import { BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
8
8
|
import { defineErrorCodes } from "@better-auth/core/utils";
|
|
9
9
|
import * as z from "zod";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as generateId } from "./utils-
|
|
2
|
-
import { t as mergeSchema } from "./schema-
|
|
3
|
-
import { t as APIError } from "./api-
|
|
4
|
-
import { c as setSessionCookie, l as parseSetCookieHeader } from "./cookies-
|
|
5
|
-
import { r as getSessionFromCtx } from "./session-
|
|
1
|
+
import { t as generateId } from "./utils-db7gNqd-.mjs";
|
|
2
|
+
import { t as mergeSchema } from "./schema-Bb7wzeK_.mjs";
|
|
3
|
+
import { t as APIError } from "./api-CkmycQ2x.mjs";
|
|
4
|
+
import { c as setSessionCookie, l as parseSetCookieHeader } from "./cookies-D72PbWdz.mjs";
|
|
5
|
+
import { r as getSessionFromCtx } from "./session-AaRl3_x-.mjs";
|
|
6
6
|
import { defineErrorCodes } from "@better-auth/core/utils";
|
|
7
7
|
import * as z from "zod";
|
|
8
8
|
import { createAuthEndpoint, createAuthMiddleware } from "@better-auth/core/api";
|
package/dist/api/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as createEmailVerificationToken, A as deleteUser, B as getSessionFromCtx, C as createAuthEndpoint, D as router, E as optionsMiddleware, F as signOut, G as revokeSessions, H as requestOnlySessionMiddleware, I as signInEmail, J as requestPasswordReset, K as sensitiveSessionMiddleware, L as signInSocial, M as setPassword, N as updateUser, O as changeEmail, P as signUpEmail, Q as error, R as freshSessionMiddleware, S as checkEndpointConflicts, T as getEndpoints, U as revokeOtherSessions, V as listSessions, W as revokeSession, X as resetPassword, Y as requestPasswordResetCallback, Z as ok, at as getAccessToken, b as AuthEndpoint, ct as refreshToken, dt as originCheckMiddleware, et as sendVerificationEmail, ft as getOAuthState, it as accountInfo, j as deleteUserCallback, k as changePassword, lt as unlinkAccount, nt as verifyEmail, ot as linkSocialAccount, pt as getIp, q as sessionMiddleware, rt as callbackOAuth, st as listUserAccounts, tt as sendVerificationEmailFn, ut as originCheck, w as createAuthMiddleware, x as AuthMiddleware, y as APIError, z as getSession } from "../index-
|
|
1
|
+
import { $ as createEmailVerificationToken, A as deleteUser, B as getSessionFromCtx, C as createAuthEndpoint, D as router, E as optionsMiddleware, F as signOut, G as revokeSessions, H as requestOnlySessionMiddleware, I as signInEmail, J as requestPasswordReset, K as sensitiveSessionMiddleware, L as signInSocial, M as setPassword, N as updateUser, O as changeEmail, P as signUpEmail, Q as error, R as freshSessionMiddleware, S as checkEndpointConflicts, T as getEndpoints, U as revokeOtherSessions, V as listSessions, W as revokeSession, X as resetPassword, Y as requestPasswordResetCallback, Z as ok, at as getAccessToken, b as AuthEndpoint, ct as refreshToken, dt as originCheckMiddleware, et as sendVerificationEmail, ft as getOAuthState, it as accountInfo, j as deleteUserCallback, k as changePassword, lt as unlinkAccount, nt as verifyEmail, ot as linkSocialAccount, pt as getIp, q as sessionMiddleware, rt as callbackOAuth, st as listUserAccounts, tt as sendVerificationEmailFn, ut as originCheck, w as createAuthMiddleware, x as AuthMiddleware, y as APIError, z as getSession } from "../index-CJ4w3OzO.mjs";
|
|
2
2
|
import "../types-CEepZ-RG.mjs";
|
|
3
3
|
import "../helper-DFzV6jvx.mjs";
|
|
4
4
|
import "../index-D8MBzSjs.mjs";
|
package/dist/api/index.mjs
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import "../dialect-D9ZUZA4J.mjs";
|
|
2
2
|
import "../get-model-name-D4DUV7S2.mjs";
|
|
3
|
-
import "../get-migration-
|
|
4
|
-
import { a as getOAuthState } from "../utils-
|
|
5
|
-
import "../crypto-
|
|
6
|
-
import "../
|
|
7
|
-
import "../
|
|
8
|
-
import "../
|
|
9
|
-
import
|
|
10
|
-
import "../
|
|
11
|
-
import "../
|
|
12
|
-
import
|
|
13
|
-
import "../
|
|
14
|
-
import { a as requestOnlySessionMiddleware, c as revokeSessions, i as listSessions, l as sensitiveSessionMiddleware, n as getSession, o as revokeOtherSessions, r as getSessionFromCtx, s as revokeSession, t as freshSessionMiddleware, u as sessionMiddleware } from "../session-CgfX4vv1.mjs";
|
|
3
|
+
import "../get-migration-Bf0TuCzm.mjs";
|
|
4
|
+
import { a as getOAuthState } from "../utils-db7gNqd-.mjs";
|
|
5
|
+
import "../crypto-CFUhAR9W.mjs";
|
|
6
|
+
import "../misc-BwNc0MKr.mjs";
|
|
7
|
+
import "../schema-Bb7wzeK_.mjs";
|
|
8
|
+
import { t as getIp } from "../get-request-ip-D6st-mto.mjs";
|
|
9
|
+
import "../json-CnHxKYpj.mjs";
|
|
10
|
+
import "../url-CB8xCwz-.mjs";
|
|
11
|
+
import { A as getAccessToken, C as createEmailVerificationToken, D as callbackOAuth, E as verifyEmail, L as originCheck, M as listUserAccounts, N as refreshToken, P as unlinkAccount, R as originCheckMiddleware, S as error, T as sendVerificationEmailFn, _ as signInSocial, a as getEndpoints, b as resetPassword, c as changeEmail, d as deleteUserCallback, f as setPassword, g as signInEmail, h as signOut, i as createAuthMiddleware, j as linkSocialAccount, k as accountInfo, l as changePassword, m as signUpEmail, n as checkEndpointConflicts, o as optionsMiddleware, p as updateUser, r as createAuthEndpoint, s as router, t as APIError, u as deleteUser, v as requestPasswordReset, w as sendVerificationEmail, x as ok, y as requestPasswordResetCallback } from "../api-CkmycQ2x.mjs";
|
|
12
|
+
import "../cookies-D72PbWdz.mjs";
|
|
13
|
+
import { a as requestOnlySessionMiddleware, c as revokeSessions, i as listSessions, l as sensitiveSessionMiddleware, n as getSession, o as revokeOtherSessions, r as getSessionFromCtx, s as revokeSession, t as freshSessionMiddleware, u as sessionMiddleware } from "../session-AaRl3_x-.mjs";
|
|
15
14
|
|
|
16
15
|
export { APIError, accountInfo, callbackOAuth, changeEmail, changePassword, checkEndpointConflicts, createAuthEndpoint, createAuthMiddleware, createEmailVerificationToken, deleteUser, deleteUserCallback, error, freshSessionMiddleware, getAccessToken, getEndpoints, getIp, getOAuthState, getSession, getSessionFromCtx, linkSocialAccount, listSessions, listUserAccounts, ok, optionsMiddleware, originCheck, originCheckMiddleware, refreshToken, requestOnlySessionMiddleware, requestPasswordReset, requestPasswordResetCallback, resetPassword, revokeOtherSessions, revokeSession, revokeSessions, router, sendVerificationEmail, sendVerificationEmailFn, sensitiveSessionMiddleware, sessionMiddleware, setPassword, signInEmail, signInSocial, signOut, signUpEmail, unlinkAccount, updateUser, verifyEmail };
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { i as parseState, n as HIDE_METADATA, r as generateState, t as generateId } from "./utils-
|
|
2
|
-
import { n as symmetricEncrypt, r as generateRandomString, t as symmetricDecrypt } from "./crypto-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { t as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { c as
|
|
9
|
-
import { c as revokeSessions, i as listSessions, l as sensitiveSessionMiddleware, n as getSession, o as revokeOtherSessions, r as getSessionFromCtx, s as revokeSession, t as freshSessionMiddleware, u as sessionMiddleware } from "./session-CgfX4vv1.mjs";
|
|
1
|
+
import { i as parseState, n as HIDE_METADATA, r as generateState, t as generateId } from "./utils-db7gNqd-.mjs";
|
|
2
|
+
import { n as symmetricEncrypt, o as signJWT, r as generateRandomString, t as symmetricDecrypt } from "./crypto-CFUhAR9W.mjs";
|
|
3
|
+
import { c as parseUserInput, l as parseUserOutput, u as getDate } from "./schema-Bb7wzeK_.mjs";
|
|
4
|
+
import { t as getIp } from "./get-request-ip-D6st-mto.mjs";
|
|
5
|
+
import { t as safeJSONParse } from "./json-CnHxKYpj.mjs";
|
|
6
|
+
import { i as getProtocol, n as getHost, r as getOrigin } from "./url-CB8xCwz-.mjs";
|
|
7
|
+
import { c as setSessionCookie, f as getAccountCookie, h as setAccountCookie, n as deleteSessionCookie } from "./cookies-D72PbWdz.mjs";
|
|
8
|
+
import { c as revokeSessions, i as listSessions, l as sensitiveSessionMiddleware, n as getSession, o as revokeOtherSessions, r as getSessionFromCtx, s as revokeSession, t as freshSessionMiddleware, u as sessionMiddleware } from "./session-AaRl3_x-.mjs";
|
|
10
9
|
import { hasRequestState, runWithEndpointContext, runWithRequestState, runWithTransaction } from "@better-auth/core/context";
|
|
11
10
|
import { isDevelopment, isProduction, logger, shouldPublishLog } from "@better-auth/core/env";
|
|
12
11
|
import { BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
@@ -616,9 +615,7 @@ const getAccessToken = createAuthEndpoint("/get-access-token", {
|
|
|
616
615
|
let resolvedUserId = session?.user?.id || userId;
|
|
617
616
|
if (!resolvedUserId) throw ctx.error("UNAUTHORIZED");
|
|
618
617
|
if (!ctx.context.socialProviders.find((p) => p.id === providerId)) throw new APIError("BAD_REQUEST", { message: `Provider ${providerId} is not supported.` });
|
|
619
|
-
const
|
|
620
|
-
const accountDataCookie = await ctx.getSignedCookie(accountDataCookieName, ctx.context.secret);
|
|
621
|
-
const accountData = accountDataCookie ? safeJSONParse(accountDataCookie) : null;
|
|
618
|
+
const accountData = await getAccountCookie(ctx);
|
|
622
619
|
let account = void 0;
|
|
623
620
|
if (accountData && providerId === accountData.providerId && (!accountId || accountData.id === accountId)) account = accountData;
|
|
624
621
|
else account = (await ctx.context.internalAdapter.findAccounts(resolvedUserId)).find((acc) => accountId ? acc.id === accountId && acc.providerId === providerId : acc.providerId === providerId);
|
|
@@ -637,7 +634,7 @@ const getAccessToken = createAuthEndpoint("/get-access-token", {
|
|
|
637
634
|
refreshToken: await setTokenUtil(newTokens.refreshToken, ctx.context),
|
|
638
635
|
refreshTokenExpiresAt: newTokens.refreshTokenExpiresAt
|
|
639
636
|
});
|
|
640
|
-
if (ctx.context.options.account?.storeAccountCookie && updatedAccount) await ctx
|
|
637
|
+
if (ctx.context.options.account?.storeAccountCookie && updatedAccount) await setAccountCookie(ctx, updatedAccount);
|
|
641
638
|
}
|
|
642
639
|
const tokens = {
|
|
643
640
|
accessToken: newTokens?.accessToken ?? await decryptOAuthToken(account.accessToken ?? "", ctx.context),
|
|
@@ -696,10 +693,8 @@ const refreshToken = createAuthEndpoint("/refresh-token", {
|
|
|
696
693
|
const provider = ctx.context.socialProviders.find((p) => p.id === providerId);
|
|
697
694
|
if (!provider) throw new APIError("BAD_REQUEST", { message: `Provider ${providerId} not found.` });
|
|
698
695
|
if (!provider.refreshAccessToken) throw new APIError("BAD_REQUEST", { message: `Provider ${providerId} does not support token refreshing.` });
|
|
699
|
-
const accountDataCookieName = ctx.context.authCookies.accountData.name;
|
|
700
|
-
const accountDataCookie = await ctx.getSignedCookie(accountDataCookieName, ctx.context.secret);
|
|
701
696
|
let account = void 0;
|
|
702
|
-
const accountData =
|
|
697
|
+
const accountData = await getAccountCookie(ctx);
|
|
703
698
|
if (accountData && (!providerId || providerId === accountData?.providerId)) account = accountData;
|
|
704
699
|
else account = (await ctx.context.internalAdapter.findAccounts(resolvedUserId)).find((acc) => accountId ? acc.id === accountId && acc.providerId === providerId : acc.providerId === providerId);
|
|
705
700
|
if (!account) throw new APIError("BAD_REQUEST", { message: "Account not found" });
|
|
@@ -722,18 +717,15 @@ const refreshToken = createAuthEndpoint("/refresh-token", {
|
|
|
722
717
|
};
|
|
723
718
|
await ctx.context.internalAdapter.updateAccount(account.id, updateData);
|
|
724
719
|
}
|
|
725
|
-
if (accountData && providerId === accountData.providerId && ctx.context.options.account?.storeAccountCookie) {
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
};
|
|
735
|
-
await ctx.setSignedCookie(accountDataCookieName, JSON.stringify(updateData), ctx.context.secret, ctx.context.authCookies.accountData.options);
|
|
736
|
-
}
|
|
720
|
+
if (accountData && providerId === accountData.providerId && ctx.context.options.account?.storeAccountCookie) await setAccountCookie(ctx, {
|
|
721
|
+
...accountData,
|
|
722
|
+
accessToken: await setTokenUtil(tokens.accessToken, ctx.context),
|
|
723
|
+
refreshToken: await setTokenUtil(tokens.refreshToken, ctx.context),
|
|
724
|
+
accessTokenExpiresAt: tokens.accessTokenExpiresAt,
|
|
725
|
+
refreshTokenExpiresAt: tokens.refreshTokenExpiresAt,
|
|
726
|
+
scope: tokens.scopes?.join(",") || accountData.scope,
|
|
727
|
+
idToken: tokens.idToken || accountData.idToken
|
|
728
|
+
});
|
|
737
729
|
return ctx.json({
|
|
738
730
|
accessToken: tokens.accessToken,
|
|
739
731
|
refreshToken: tokens.refreshToken,
|
|
@@ -790,12 +782,8 @@ const accountInfo = createAuthEndpoint("/account-info", {
|
|
|
790
782
|
let account = void 0;
|
|
791
783
|
if (!providedAccountId) {
|
|
792
784
|
if (ctx.context.options.account?.storeAccountCookie) {
|
|
793
|
-
const
|
|
794
|
-
|
|
795
|
-
if (accountCookie) {
|
|
796
|
-
const accountData = safeJSONParse(accountCookie);
|
|
797
|
-
if (accountData) account = accountData;
|
|
798
|
-
}
|
|
785
|
+
const accountData = await getAccountCookie(ctx);
|
|
786
|
+
if (accountData) account = accountData;
|
|
799
787
|
}
|
|
800
788
|
} else {
|
|
801
789
|
const accountData = await ctx.context.internalAdapter.findAccount(providedAccountId);
|
|
@@ -872,10 +860,7 @@ async function handleOAuthUserInfo(c, { userInfo, account, callbackURL, disableS
|
|
|
872
860
|
refreshTokenExpiresAt: account.refreshTokenExpiresAt,
|
|
873
861
|
scope: account.scope
|
|
874
862
|
}).filter(([_, value]) => value !== void 0));
|
|
875
|
-
if (c.context.options.account?.storeAccountCookie)
|
|
876
|
-
const accountDataCookie = c.context.authCookies.accountData;
|
|
877
|
-
await c.setSignedCookie(accountDataCookie.name, JSON.stringify(updateData), c.context.secret, accountDataCookie.options);
|
|
878
|
-
}
|
|
863
|
+
if (c.context.options.account?.storeAccountCookie) await setAccountCookie(c, updateData);
|
|
879
864
|
if (Object.keys(updateData).length > 0) await c.context.internalAdapter.updateAccount(hasBeenLinked.id, updateData);
|
|
880
865
|
}
|
|
881
866
|
if (userInfo.emailVerified && !dbUser.user.emailVerified && userInfo.email.toLowerCase() === dbUser.user.email) await c.context.internalAdapter.updateUser(dbUser.user.id, { emailVerified: true });
|
|
@@ -911,10 +896,7 @@ async function handleOAuthUserInfo(c, { userInfo, account, callbackURL, disableS
|
|
|
911
896
|
email: userInfo.email.toLowerCase()
|
|
912
897
|
}, accountData);
|
|
913
898
|
user = createdUser;
|
|
914
|
-
if (c.context.options.account?.storeAccountCookie)
|
|
915
|
-
const accountDataCookie = c.context.authCookies.accountData;
|
|
916
|
-
await c.setSignedCookie(accountDataCookie.name, JSON.stringify(createdAccount), c.context.secret, accountDataCookie.options);
|
|
917
|
-
}
|
|
899
|
+
if (c.context.options.account?.storeAccountCookie) await setAccountCookie(c, createdAccount);
|
|
918
900
|
if (!userInfo.emailVerified && user && c.context.options.emailVerification?.sendOnSignUp) {
|
|
919
901
|
const token = await createEmailVerificationToken(c.context.secret, user.email, void 0, c.context.options.emailVerification?.expiresIn);
|
|
920
902
|
const url = `${c.context.baseURL}/verify-email?token=${token}&callbackURL=${callbackURL}`;
|
|
@@ -1821,13 +1803,12 @@ function redirectCallback(ctx, callbackURL, query) {
|
|
|
1821
1803
|
}
|
|
1822
1804
|
const requestPasswordReset = createAuthEndpoint("/request-password-reset", {
|
|
1823
1805
|
method: "POST",
|
|
1824
|
-
operationId: "forgetPassword",
|
|
1825
1806
|
body: z.object({
|
|
1826
1807
|
email: z.email().meta({ description: "The email address of the user to send a password reset email to" }),
|
|
1827
1808
|
redirectTo: z.string().meta({ description: "The URL to redirect the user to reset their password. If the token isn't valid or expired, it'll be redirected with a query parameter `?error=INVALID_TOKEN`. If the token is valid, it'll be redirected with a query parameter `?token=VALID_TOKEN" }).optional()
|
|
1828
1809
|
}),
|
|
1829
1810
|
metadata: { openapi: {
|
|
1830
|
-
operationId: "
|
|
1811
|
+
operationId: "requestPasswordReset",
|
|
1831
1812
|
description: "Send a password reset email to the user",
|
|
1832
1813
|
responses: { "200": {
|
|
1833
1814
|
description: "Success",
|
|
@@ -1869,11 +1850,7 @@ const requestPasswordReset = createAuthEndpoint("/request-password-reset", {
|
|
|
1869
1850
|
});
|
|
1870
1851
|
const callbackURL = redirectTo ? encodeURIComponent(redirectTo) : "";
|
|
1871
1852
|
const url = `${ctx.context.baseURL}/reset-password/${verificationToken}?callbackURL=${callbackURL}`;
|
|
1872
|
-
|
|
1873
|
-
* We send the email in the background to prevent timing attacks.
|
|
1874
|
-
* This is to ensure that the response time is consistent regardless of whether the email was sent or not.
|
|
1875
|
-
*/
|
|
1876
|
-
ctx.context.options.emailAndPassword.sendResetPassword({
|
|
1853
|
+
await ctx.context.options.emailAndPassword.sendResetPassword({
|
|
1877
1854
|
user: user.user,
|
|
1878
1855
|
url,
|
|
1879
1856
|
token: verificationToken
|
|
@@ -2464,7 +2441,8 @@ const updateUser = () => createAuthEndpoint("/update-user", {
|
|
|
2464
2441
|
},
|
|
2465
2442
|
image: {
|
|
2466
2443
|
type: "string",
|
|
2467
|
-
description: "The image of the user"
|
|
2444
|
+
description: "The image of the user",
|
|
2445
|
+
nullable: true
|
|
2468
2446
|
}
|
|
2469
2447
|
}
|
|
2470
2448
|
} } } },
|
package/dist/auth/minimal.d.mts
CHANGED
package/dist/auth/minimal.mjs
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import "../dialect-D9ZUZA4J.mjs";
|
|
2
2
|
import "../get-model-name-D4DUV7S2.mjs";
|
|
3
|
-
import { d as getBaseAdapter } from "../get-migration-
|
|
4
|
-
import "../utils-
|
|
5
|
-
import "../crypto-
|
|
6
|
-
import "../
|
|
7
|
-
import "../
|
|
8
|
-
import "../
|
|
9
|
-
import "../
|
|
10
|
-
import "../
|
|
11
|
-
import "../
|
|
12
|
-
import "../
|
|
13
|
-
import "../
|
|
14
|
-
import "../
|
|
15
|
-
import
|
|
16
|
-
import "../password-DBH2q5D6.mjs";
|
|
3
|
+
import { d as getBaseAdapter } from "../get-migration-Bf0TuCzm.mjs";
|
|
4
|
+
import "../utils-db7gNqd-.mjs";
|
|
5
|
+
import "../crypto-CFUhAR9W.mjs";
|
|
6
|
+
import "../misc-BwNc0MKr.mjs";
|
|
7
|
+
import "../schema-Bb7wzeK_.mjs";
|
|
8
|
+
import "../get-request-ip-D6st-mto.mjs";
|
|
9
|
+
import "../json-CnHxKYpj.mjs";
|
|
10
|
+
import "../url-CB8xCwz-.mjs";
|
|
11
|
+
import "../api-CkmycQ2x.mjs";
|
|
12
|
+
import "../cookies-D72PbWdz.mjs";
|
|
13
|
+
import "../session-AaRl3_x-.mjs";
|
|
14
|
+
import { n as createAuthContext, t as createBetterAuth } from "../base-CiRMFqet.mjs";
|
|
15
|
+
import "../password-BFQK0cLg.mjs";
|
|
17
16
|
import { BetterAuthError } from "@better-auth/core/error";
|
|
18
17
|
|
|
19
18
|
//#region src/context/init-minimal.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as getKyselyDatabaseType } from "./dialect-D9ZUZA4J.mjs";
|
|
2
|
-
import { t as getMigrations, u as getAdapter } from "./get-migration-
|
|
3
|
-
import { n as createAuthContext, t as createBetterAuth } from "./base-
|
|
2
|
+
import { t as getMigrations, u as getAdapter } from "./get-migration-Bf0TuCzm.mjs";
|
|
3
|
+
import { n as createAuthContext, t as createBetterAuth } from "./base-CiRMFqet.mjs";
|
|
4
4
|
import { BetterAuthError } from "@better-auth/core/error";
|
|
5
5
|
|
|
6
6
|
//#region src/context/init.ts
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { a as getAuthTables } from "./get-model-name-D4DUV7S2.mjs";
|
|
2
|
-
import { a as createInternalAdapter } from "./get-migration-
|
|
3
|
-
import { t as generateId } from "./utils-
|
|
4
|
-
import { a as verifyPassword, i as hashPassword } from "./crypto-
|
|
5
|
-
import { r as getOrigin, t as getBaseURL } from "./url-
|
|
6
|
-
import { a as getEndpoints, n as checkEndpointConflicts, s as router } from "./api-
|
|
7
|
-
import { i as getCookies, t as createCookieGetter } from "./cookies-
|
|
8
|
-
import { t as checkPassword } from "./password-
|
|
2
|
+
import { a as createInternalAdapter } from "./get-migration-Bf0TuCzm.mjs";
|
|
3
|
+
import { t as generateId } from "./utils-db7gNqd-.mjs";
|
|
4
|
+
import { a as verifyPassword, i as hashPassword } from "./crypto-CFUhAR9W.mjs";
|
|
5
|
+
import { r as getOrigin, t as getBaseURL } from "./url-CB8xCwz-.mjs";
|
|
6
|
+
import { a as getEndpoints, n as checkEndpointConflicts, s as router } from "./api-CkmycQ2x.mjs";
|
|
7
|
+
import { i as getCookies, t as createCookieGetter } from "./cookies-D72PbWdz.mjs";
|
|
8
|
+
import { t as checkPassword } from "./password-BFQK0cLg.mjs";
|
|
9
9
|
import { runWithAdapter } from "@better-auth/core/context";
|
|
10
10
|
import { createLogger, env, isProduction, isTest } from "@better-auth/core/env";
|
|
11
11
|
import { BASE_ERROR_CODES, BetterAuthError } from "@better-auth/core/error";
|
|
@@ -14,7 +14,7 @@ import { createTelemetry } from "@better-auth/telemetry";
|
|
|
14
14
|
import defu$1, { defu } from "defu";
|
|
15
15
|
|
|
16
16
|
//#region src/utils/constants.ts
|
|
17
|
-
const DEFAULT_SECRET = "better-auth-secret-
|
|
17
|
+
const DEFAULT_SECRET = "better-auth-secret-12345678901234567890";
|
|
18
18
|
|
|
19
19
|
//#endregion
|
|
20
20
|
//#region src/utils/is-promise.ts
|
|
@@ -74,6 +74,29 @@ function getTrustedOrigins(options) {
|
|
|
74
74
|
|
|
75
75
|
//#endregion
|
|
76
76
|
//#region src/context/create-context.ts
|
|
77
|
+
/**
|
|
78
|
+
* Estimates the entropy of a string in bits.
|
|
79
|
+
* This is a simple approximation that helps detect low-entropy secrets.
|
|
80
|
+
*/
|
|
81
|
+
function estimateEntropy(str) {
|
|
82
|
+
const unique = new Set(str).size;
|
|
83
|
+
if (unique === 0) return 0;
|
|
84
|
+
return Math.log2(Math.pow(unique, str.length));
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Validates that the secret meets minimum security requirements.
|
|
88
|
+
* Throws BetterAuthError if the secret is invalid.
|
|
89
|
+
* Skips validation for DEFAULT_SECRET in test environments only.
|
|
90
|
+
* Only throws for DEFAULT_SECRET in production environment.
|
|
91
|
+
*/
|
|
92
|
+
function validateSecret(secret, logger$1) {
|
|
93
|
+
const isDefaultSecret = secret === DEFAULT_SECRET;
|
|
94
|
+
if (isTest()) return;
|
|
95
|
+
if (isDefaultSecret && isProduction) throw new BetterAuthError("You are using the default secret. Please set `BETTER_AUTH_SECRET` in your environment variables or pass `secret` in your auth config.");
|
|
96
|
+
if (!secret) throw new BetterAuthError("BETTER_AUTH_SECRET is missing. Set it in your environment or pass `secret` to betterAuth({ secret }).");
|
|
97
|
+
if (secret.length < 32) throw new BetterAuthError(`Invalid BETTER_AUTH_SECRET: must be at least 32 characters long for adequate security. Generate one with \`npx @better-auth/cli secret\` or \`openssl rand -base64 32\`.`);
|
|
98
|
+
if (estimateEntropy(secret) < 120) logger$1.warn("[better-auth] Warning: your BETTER_AUTH_SECRET appears low-entropy. Use a randomly generated secret for production.");
|
|
99
|
+
}
|
|
77
100
|
async function createAuthContext(adapter, options, getDatabaseType) {
|
|
78
101
|
if (!options.database) options = defu$1(options, {
|
|
79
102
|
session: { cookieCache: {
|
|
@@ -91,9 +114,7 @@ async function createAuthContext(adapter, options, getDatabaseType) {
|
|
|
91
114
|
const logger$1 = createLogger(options.logger);
|
|
92
115
|
const baseURL = getBaseURL(options.baseURL, options.basePath);
|
|
93
116
|
const secret = options.secret || env.BETTER_AUTH_SECRET || env.AUTH_SECRET || DEFAULT_SECRET;
|
|
94
|
-
|
|
95
|
-
if (isProduction) logger$1.error("You are using the default secret. Please set `BETTER_AUTH_SECRET` in your environment variables or pass `secret` in your auth config.");
|
|
96
|
-
}
|
|
117
|
+
validateSecret(secret, logger$1);
|
|
97
118
|
options = {
|
|
98
119
|
...options,
|
|
99
120
|
secret,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as parseSetCookieHeader } from "./cookies-
|
|
1
|
+
import { l as parseSetCookieHeader } from "./cookies-D72PbWdz.mjs";
|
|
2
2
|
import { serializeSignedCookie } from "better-call";
|
|
3
3
|
import { createAuthMiddleware } from "@better-auth/core/api";
|
|
4
4
|
import { createHMAC } from "@better-auth/utils/hmac";
|
|
@@ -10,25 +10,40 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
|
10
10
|
var __commonJS = (cb, mod) => function() {
|
|
11
11
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
12
|
};
|
|
13
|
-
var __export = (all) => {
|
|
13
|
+
var __export = (all, symbols) => {
|
|
14
14
|
let target = {};
|
|
15
|
-
for (var name in all)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
for (var name in all) {
|
|
16
|
+
__defProp(target, name, {
|
|
17
|
+
get: all[name],
|
|
18
|
+
enumerable: true
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
if (symbols) {
|
|
22
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
23
|
+
}
|
|
19
24
|
return target;
|
|
20
25
|
};
|
|
21
26
|
var __copyProps = (to, from, except, desc) => {
|
|
22
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
28
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
29
|
+
key = keys[i];
|
|
30
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
31
|
+
__defProp(to, key, {
|
|
32
|
+
get: ((k) => from[k]).bind(null, key),
|
|
33
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
28
37
|
}
|
|
29
38
|
return to;
|
|
30
39
|
};
|
|
31
|
-
var __reExport = (target, mod, secondTarget
|
|
40
|
+
var __reExport = (target, mod, secondTarget, symbols) => {
|
|
41
|
+
if (symbols) {
|
|
42
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
43
|
+
secondTarget && __defProp(secondTarget, Symbol.toStringTag, { value: "Module" });
|
|
44
|
+
}
|
|
45
|
+
__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default");
|
|
46
|
+
};
|
|
32
47
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
33
48
|
value: mod,
|
|
34
49
|
enumerable: true
|
package/dist/client/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { At as BroadcastMessage, Ct as OnlineManager, Dt as kFocusManager, Et as FocusManager, Mt as kBroadcastChannel, Ot as BroadcastChannel, St as OnlineListener, Tt as FocusListener, _n as InferSessionFromClient, _t as AuthClient, bn as SessionQueryParams, bt as createSessionRefreshManager, cn as BetterAuthClientPlugin, dn as ClientStore, fn as InferActions, gn as InferPluginsFromClient, gt as Primitive, hn as InferErrorCodes, ht as InferPlugin, jt as getGlobalBroadcastChannel, kt as BroadcastListener, ln as ClientAtomListener, mn as InferClientAPI, mt as InferAuth, on as AtomListener, pn as InferAdditionalFromClient, sn as BetterAuthClientOptions, un as ClientOptions, vn as InferUserFromClient, vt as createAuthClient, wt as kOnlineManager, xn as Store, xt as useAuthQuery, yn as IsSignal, yt as SessionRefreshOptions } from "../index-
|
|
1
|
+
import { At as BroadcastMessage, Ct as OnlineManager, Dt as kFocusManager, Et as FocusManager, Mt as kBroadcastChannel, Ot as BroadcastChannel, St as OnlineListener, Tt as FocusListener, _n as InferSessionFromClient, _t as AuthClient, bn as SessionQueryParams, bt as createSessionRefreshManager, cn as BetterAuthClientPlugin, dn as ClientStore, fn as InferActions, gn as InferPluginsFromClient, gt as Primitive, hn as InferErrorCodes, ht as InferPlugin, jt as getGlobalBroadcastChannel, kt as BroadcastListener, ln as ClientAtomListener, mn as InferClientAPI, mt as InferAuth, on as AtomListener, pn as InferAdditionalFromClient, sn as BetterAuthClientOptions, un as ClientOptions, vn as InferUserFromClient, vt as createAuthClient, wt as kOnlineManager, xn as Store, xt as useAuthQuery, yn as IsSignal, yt as SessionRefreshOptions } from "../index-CJ4w3OzO.mjs";
|
|
2
2
|
import "../types-CEepZ-RG.mjs";
|
|
3
3
|
import { a as LiteralNumber, c as OmitId, d as PrettifyDeep, g as WithoutEmpty, h as UnionToIntersection, i as HasRequiredKeys, l as PreserveJSDoc, m as StripEmptyObjects, n as DeepPartial, o as LiteralString, p as RequiredKeysOf, r as Expand, s as LiteralUnion, t as Awaitable, u as Prettify } from "../helper-DFzV6jvx.mjs";
|
|
4
4
|
import { a as Role, c as Subset, i as AccessControl, n as createAccessControl, o as Statements, r as role, s as SubArray, t as AuthorizeResponse } from "../index-D8MBzSjs.mjs";
|
package/dist/client/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "../misc-
|
|
2
|
-
import "../url-
|
|
3
|
-
import { a as kOnlineManager, c as kBroadcastChannel, i as useAuthQuery, o as kFocusManager, r as createSessionRefreshManager, s as getGlobalBroadcastChannel } from "../proxy-
|
|
4
|
-
import "../parser-
|
|
5
|
-
import { n as InferPlugin, r as createAuthClient, t as InferAuth } from "../client-
|
|
1
|
+
import "../misc-BwNc0MKr.mjs";
|
|
2
|
+
import "../url-CB8xCwz-.mjs";
|
|
3
|
+
import { a as kOnlineManager, c as kBroadcastChannel, i as useAuthQuery, o as kFocusManager, r as createSessionRefreshManager, s as getGlobalBroadcastChannel } from "../proxy-DplNCOES.mjs";
|
|
4
|
+
import "../parser-pHp5yoAv.mjs";
|
|
5
|
+
import { n as InferPlugin, r as createAuthClient, t as InferAuth } from "../client-BN9e9KX1.mjs";
|
|
6
6
|
|
|
7
7
|
export { InferAuth, InferPlugin, createAuthClient, createSessionRefreshManager, getGlobalBroadcastChannel, kBroadcastChannel, kFocusManager, kOnlineManager, useAuthQuery };
|