better-auth 1.4.4 → 1.4.5
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/{adapter-factory-CXEYdBBi.mjs → adapter-factory-HF3JB9cT.mjs} +2 -0
- package/dist/adapters/drizzle-adapter/index.mjs +1 -1
- package/dist/adapters/index.d.mts +4 -5
- package/dist/adapters/index.mjs +1 -1
- package/dist/adapters/kysely-adapter/index.d.mts +1 -1
- package/dist/adapters/kysely-adapter/index.mjs +2 -2
- package/dist/adapters/memory-adapter/index.mjs +1 -1
- package/dist/adapters/mongodb-adapter/index.mjs +3 -3
- package/dist/adapters/prisma-adapter/index.mjs +1 -1
- package/dist/{admin-ChOe8fFj.mjs → admin-D-OMdNIc.mjs} +4 -4
- package/dist/{anonymous-DBicc9SO.mjs → anonymous-DxoIOUPc.mjs} +4 -4
- package/dist/api/index.d.mts +4 -5
- package/dist/api/index.mjs +6 -6
- package/dist/{api-wsWZUpFT.mjs → api-CkmycQ2x.mjs} +7 -11
- package/dist/auth/minimal.d.mts +4 -5
- package/dist/auth/minimal.mjs +7 -7
- package/dist/{auth-DXfj7XiL.mjs → auth-DfR8_5w3.mjs} +3 -3
- package/dist/{base-mEQHMRJA.mjs → base-CiRMFqet.mjs} +28 -7
- package/dist/{bearer-B4-NdmpH.mjs → bearer-C6RSCXv_.mjs} +1 -1
- package/dist/{chunk-09eW3CcW.mjs → chunk-DbI2OXuS.mjs} +27 -12
- package/dist/client/index.d.mts +203 -6
- package/dist/client/lynx/index.d.mts +17 -18
- package/dist/client/plugins/index.d.mts +64 -48
- package/dist/client/plugins/index.mjs +115 -55
- package/dist/client/react/index.d.mts +19 -20
- package/dist/client/solid/index.d.mts +4 -5
- package/dist/client/svelte/index.d.mts +19 -20
- package/dist/client/vue/index.d.mts +19 -20
- package/dist/cookies/index.d.mts +5 -6
- package/dist/cookies/index.mjs +2 -2
- package/dist/{cookies-LjbrTFKV.mjs → cookies-D72PbWdz.mjs} +3 -116
- package/dist/{custom-session-4erbuJfY.mjs → custom-session-CaUbM_of.mjs} +1 -1
- package/dist/db/index.d.mts +4 -5
- package/dist/db/index.mjs +3 -3
- package/dist/{device-authorization-yVgyPi_0.mjs → device-authorization-9_f1Up5D.mjs} +3 -3
- package/dist/{dialect-BLBufKXb.mjs → dialect-D9ZUZA4J.mjs} +2 -2
- package/dist/{email-otp-D6woCHRq.mjs → email-otp-CiznqFUN.mjs} +4 -4
- package/dist/{esm-CBBLYnb5.mjs → esm-BXhcK_bt.mjs} +1 -1
- package/dist/{generic-oauth-BTtAU7in.mjs → generic-oauth-BGbWWUh9.mjs} +5 -5
- package/dist/{get-migration-o_lo2MLQ.mjs → get-migration-Bf0TuCzm.mjs} +6 -5
- package/dist/{haveibeenpwned-B5S9uuFy.mjs → haveibeenpwned-BSsFUFTi.mjs} +1 -1
- package/dist/{index-BuNASjEf.d.mts → index-0IRW2A1b.d.mts} +10 -10
- package/dist/{index-CV3hEtFH.d.mts → index-B64ouu9a.d.mts} +6 -6
- package/dist/{index-DETqmYvI.d.mts → index-BMrJpdkv.d.mts} +4 -4
- package/dist/{index-WwQ9F45s.d.mts → index-BaZax_le.d.mts} +4 -4
- package/dist/{index-350W2hrg.d.mts → index-Bv2nWTrZ.d.mts} +3 -3
- package/dist/{index-BoR939hQ.d.mts → index-CCnWzVSV.d.mts} +15 -15
- package/dist/{index-wrlRoL03.d.mts → index-CMfXEnyA.d.mts} +8 -8
- package/dist/{index-DWd5qAaC.d.mts → index-COnelCGa.d.mts} +31 -221
- package/dist/{index-DXL5vulH.d.mts → index-CWcnHbjn.d.mts} +2 -2
- package/dist/{index-Cm5c91sb.d.mts → index-CmcoO98i.d.mts} +6 -6
- package/dist/{index-C5xbT-Cx.d.mts → index-D2CJIZCI.d.mts} +6 -6
- package/dist/{index-BfjFtIUC.d.mts → index-DLNLFTLS.d.mts} +10 -10
- package/dist/{index-BOtKlm5J.d.mts → index-DSwTw61P.d.mts} +8 -8
- package/dist/{index-BD3MotBi.d.mts → index-DUa0239y.d.mts} +6 -6
- package/dist/{index-9RDgFbER.d.mts → index-Dk2q2Dnr.d.mts} +4 -4
- package/dist/{index-BkdIUROL.d.mts → index-DoUxtZgO.d.mts} +2 -2
- package/dist/{index-BAvIVa4m.d.mts → index-Drqkvf7w.d.mts} +618 -24
- package/dist/{index-03KERutE.d.mts → index-F8qM450o.d.mts} +399 -381
- package/dist/{index-CCQg0zp2.d.mts → index-FTghQK8_.d.mts} +1 -1
- package/dist/{index-CQ838xsV.d.mts → index-alnYeOxT.d.mts} +12 -12
- package/dist/{index-BdIxVQ3I.d.mts → index-cgrDi8bR.d.mts} +13 -13
- package/dist/{index-DlUBRPjP.d.mts → index-rnNTrfA7.d.mts} +1 -1
- package/dist/{index-Cfsq3lFR.d.mts → index-t-jeKL1G.d.mts} +10 -10
- package/dist/index.d.mts +5 -6
- package/dist/index.mjs +8 -8
- package/dist/integrations/next-js.d.mts +4 -4
- package/dist/integrations/next-js.mjs +2 -2
- package/dist/integrations/node.d.mts +5 -6
- package/dist/integrations/svelte-kit.d.mts +6 -7
- package/dist/integrations/svelte-kit.mjs +2 -2
- package/dist/integrations/tanstack-start.d.mts +4 -4
- package/dist/integrations/tanstack-start.mjs +2 -2
- package/dist/{jwt-CmfDcrfW.mjs → jwt-Ar1sciI2.mjs} +3 -3
- package/dist/{magic-link-CSrEbHwK.mjs → magic-link-QdHvtdfs.mjs} +2 -2
- package/dist/{multi-session-BuTG67p5.mjs → multi-session-CbEYz_wJ.mjs} +3 -3
- package/dist/{oauth-proxy-WECTpvAZ.mjs → oauth-proxy-Dz1E1SVN.mjs} +2 -2
- package/dist/oauth2/index.d.mts +4 -5
- package/dist/oauth2/index.mjs +6 -6
- package/dist/{oidc-provider-CEkCuG6W.mjs → oidc-provider-B9SsN23J.mjs} +5 -5
- package/dist/{one-tap-CqV3TH5p.mjs → one-tap-Bz8Q39Od.mjs} +2 -2
- package/dist/one-time-token-C8YQxf38.mjs +64 -0
- package/dist/{open-api-DbDA6v0K.mjs → open-api-DZG02vyi.mjs} +1 -1
- package/dist/{organization-CKc8kY3i.mjs → organization-BdJSRNgM.mjs} +27 -8
- package/dist/{phone-number-D0u-F6ra.mjs → phone-number-wU9XYnr8.mjs} +3 -3
- package/dist/plugins/access/index.d.mts +2 -2
- package/dist/plugins/admin/access/index.d.mts +25 -25
- package/dist/plugins/admin/index.d.mts +25 -25
- package/dist/plugins/admin/index.mjs +7 -7
- package/dist/plugins/anonymous/index.d.mts +5 -6
- package/dist/plugins/anonymous/index.mjs +7 -7
- package/dist/plugins/bearer/index.d.mts +1 -1
- package/dist/plugins/bearer/index.mjs +3 -3
- package/dist/plugins/captcha/index.d.mts +1 -1
- package/dist/plugins/custom-session/index.d.mts +5 -6
- package/dist/plugins/custom-session/index.mjs +7 -7
- package/dist/plugins/device-authorization/index.d.mts +1 -1
- package/dist/plugins/device-authorization/index.mjs +6 -6
- package/dist/plugins/email-otp/index.d.mts +1 -1
- package/dist/plugins/email-otp/index.mjs +7 -7
- package/dist/plugins/generic-oauth/index.d.mts +6 -7
- package/dist/plugins/generic-oauth/index.mjs +7 -7
- package/dist/plugins/haveibeenpwned/index.d.mts +1 -1
- package/dist/plugins/haveibeenpwned/index.mjs +7 -7
- package/dist/plugins/index.d.mts +26 -26
- package/dist/plugins/index.mjs +28 -27
- package/dist/plugins/jwt/index.d.mts +5 -6
- package/dist/plugins/jwt/index.mjs +7 -7
- package/dist/plugins/magic-link/index.d.mts +1 -1
- package/dist/plugins/magic-link/index.mjs +7 -7
- package/dist/plugins/multi-session/index.d.mts +2 -2
- package/dist/plugins/multi-session/index.mjs +7 -7
- package/dist/plugins/oauth-proxy/index.d.mts +1 -1
- package/dist/plugins/oauth-proxy/index.mjs +7 -7
- package/dist/plugins/oidc-provider/index.d.mts +25 -25
- package/dist/plugins/oidc-provider/index.mjs +8 -8
- package/dist/plugins/one-tap/index.d.mts +1 -1
- package/dist/plugins/one-tap/index.mjs +7 -7
- package/dist/plugins/one-time-token/index.d.mts +6 -7
- package/dist/plugins/one-time-token/index.mjs +7 -37
- package/dist/plugins/open-api/index.d.mts +2 -2
- package/dist/plugins/open-api/index.mjs +7 -7
- package/dist/plugins/organization/access/index.d.mts +25 -25
- package/dist/plugins/organization/index.d.mts +25 -25
- package/dist/plugins/organization/index.mjs +7 -7
- package/dist/plugins/phone-number/index.d.mts +5 -6
- package/dist/plugins/phone-number/index.mjs +7 -7
- package/dist/plugins/siwe/index.d.mts +5 -6
- package/dist/plugins/siwe/index.mjs +7 -7
- package/dist/plugins/two-factor/index.d.mts +6 -7
- package/dist/plugins/two-factor/index.mjs +7 -7
- package/dist/plugins/username/index.d.mts +3 -3
- package/dist/plugins/username/index.mjs +7 -7
- package/dist/{plugins-_pIFWaaP.mjs → plugins-DgSTpOzm.mjs} +10 -62
- package/dist/{plugins-B2LAIIX7.d.mts → plugins-Dmw3tk5H.d.mts} +1 -1
- package/dist/{promise-C8akqYkI.mjs → promise-B1BZ0y5h.mjs} +2 -1
- package/dist/{schema-CgMdD0f9.mjs → schema-Bb7wzeK_.mjs} +4 -1
- package/dist/{session-hq_qEU9r.mjs → session-AaRl3_x-.mjs} +2 -2
- package/dist/{siwe-GVR3AWvP.mjs → siwe-D81Y4fkp.mjs} +3 -3
- package/dist/test-utils/index.d.mts +1166 -1167
- package/dist/test-utils/index.mjs +34 -33
- package/dist/{two-factor-B0IhIxyD.mjs → two-factor-BDQvVILL.mjs} +3 -3
- package/dist/types/index.d.mts +5 -6
- package/dist/{username-BYDdvBSF.mjs → username-C_wmkXwt.mjs} +3 -3
- package/package.json +10 -15
- /package/dist/{bun-sqlite-dialect-4d24xHgm.mjs → bun-sqlite-dialect-C3P_ISb5.mjs} +0 -0
- /package/dist/{helper-BTuR6T4N.d.mts → helper-DFzV6jvx.d.mts} +0 -0
- /package/dist/{node-sqlite-dialect-7hOpXgTN.mjs → node-sqlite-dialect-D6w8Ekdz.mjs} +0 -0
- /package/dist/{types-C4QTth8-.d.mts → types-CEepZ-RG.d.mts} +0 -0
|
@@ -227,6 +227,7 @@ const createAdapterFactory = ({ adapter: customAdapter, config: cfg }) => (optio
|
|
|
227
227
|
if (fieldAttributes.references?.field === "id" && useNumberId) if (Array.isArray(newValue)) newValue = newValue.map((x) => x !== null ? Number(x) : null);
|
|
228
228
|
else newValue = newValue !== null ? Number(newValue) : null;
|
|
229
229
|
else if (config.supportsJSON === false && typeof newValue === "object" && fieldAttributes.type === "json") newValue = JSON.stringify(newValue);
|
|
230
|
+
else if (config.supportsJSON === false && Array.isArray(newValue) && (fieldAttributes.type === "string[]" || fieldAttributes.type === "number[]")) newValue = JSON.stringify(newValue);
|
|
230
231
|
else if (config.supportsDates === false && newValue instanceof Date && fieldAttributes.type === "date") newValue = newValue.toISOString();
|
|
231
232
|
else if (config.supportsBooleans === false && typeof newValue === "boolean") newValue = newValue ? 1 : 0;
|
|
232
233
|
if (config.customTransformInput) newValue = config.customTransformInput({
|
|
@@ -261,6 +262,7 @@ const createAdapterFactory = ({ adapter: customAdapter, config: cfg }) => (optio
|
|
|
261
262
|
if (originalKey === "id" || field.references?.field === "id") {
|
|
262
263
|
if (typeof newValue !== "undefined" && newValue !== null) newValue = String(newValue);
|
|
263
264
|
} else if (config.supportsJSON === false && typeof newValue === "string" && field.type === "json") newValue = safeJSONParse(newValue);
|
|
265
|
+
else if (config.supportsJSON === false && typeof newValue === "string" && (field.type === "string[]" || field.type === "number[]")) newValue = safeJSONParse(newValue);
|
|
264
266
|
else if (config.supportsDates === false && typeof newValue === "string" && field.type === "date") newValue = new Date(newValue);
|
|
265
267
|
else if (config.supportsBooleans === false && typeof newValue === "number" && field.type === "boolean") newValue = newValue === 1;
|
|
266
268
|
if (config.customTransformOutput) newValue = config.customTransformOutput({
|
|
@@ -3,7 +3,7 @@ import "../../utils-db7gNqd-.mjs";
|
|
|
3
3
|
import "../../crypto-CFUhAR9W.mjs";
|
|
4
4
|
import "../../misc-BwNc0MKr.mjs";
|
|
5
5
|
import "../../json-CnHxKYpj.mjs";
|
|
6
|
-
import { t as createAdapterFactory } from "../../adapter-factory-
|
|
6
|
+
import { t as createAdapterFactory } from "../../adapter-factory-HF3JB9cT.mjs";
|
|
7
7
|
import { logger } from "@better-auth/core/env";
|
|
8
8
|
import { BetterAuthError } from "@better-auth/core/error";
|
|
9
9
|
import { and, asc, count, desc, eq, gt, gte, inArray, like, lt, lte, ne, notInArray, or, sql } from "drizzle-orm";
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../types-
|
|
3
|
-
import { u as Prettify } from "../helper-
|
|
4
|
-
import "../
|
|
5
|
-
import "../plugins-B2LAIIX7.mjs";
|
|
1
|
+
import { Bt as Where$1, Pt as AdapterSchemaCreation, zt as TransactionAdapter } from "../index-COnelCGa.mjs";
|
|
2
|
+
import "../types-CEepZ-RG.mjs";
|
|
3
|
+
import { u as Prettify } from "../helper-DFzV6jvx.mjs";
|
|
4
|
+
import "../plugins-Dmw3tk5H.mjs";
|
|
6
5
|
import { BetterAuthOptions } from "@better-auth/core";
|
|
7
6
|
import * as _better_auth_core_db23 from "@better-auth/core/db";
|
|
8
7
|
import { BetterAuthDBSchema, DBFieldAttribute } from "@better-auth/core/db";
|
package/dist/adapters/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import "../utils-db7gNqd-.mjs";
|
|
|
3
3
|
import "../crypto-CFUhAR9W.mjs";
|
|
4
4
|
import "../misc-BwNc0MKr.mjs";
|
|
5
5
|
import "../json-CnHxKYpj.mjs";
|
|
6
|
-
import { n as initGetFieldAttributes, r as initGetIdField, t as createAdapterFactory } from "../adapter-factory-
|
|
6
|
+
import { n as initGetFieldAttributes, r as initGetIdField, t as createAdapterFactory } from "../adapter-factory-HF3JB9cT.mjs";
|
|
7
7
|
|
|
8
8
|
export * from "@better-auth/core/db/adapter"
|
|
9
9
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as KyselyDatabaseType } from "../../types-
|
|
1
|
+
import { t as KyselyDatabaseType } from "../../types-CEepZ-RG.mjs";
|
|
2
2
|
import { BetterAuthOptions } from "@better-auth/core";
|
|
3
3
|
import { Kysely } from "kysely";
|
|
4
4
|
import { DBAdapter, DBAdapterDebugLogOption } from "@better-auth/core/db/adapter";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { n as getKyselyDatabaseType, t as createKyselyAdapter } from "../../dialect-
|
|
1
|
+
import { n as getKyselyDatabaseType, t as createKyselyAdapter } from "../../dialect-D9ZUZA4J.mjs";
|
|
2
2
|
import "../../get-model-name-D4DUV7S2.mjs";
|
|
3
3
|
import "../../utils-db7gNqd-.mjs";
|
|
4
4
|
import "../../crypto-CFUhAR9W.mjs";
|
|
5
5
|
import "../../misc-BwNc0MKr.mjs";
|
|
6
6
|
import "../../json-CnHxKYpj.mjs";
|
|
7
|
-
import { t as createAdapterFactory } from "../../adapter-factory-
|
|
7
|
+
import { t as createAdapterFactory } from "../../adapter-factory-HF3JB9cT.mjs";
|
|
8
8
|
import { sql } from "kysely";
|
|
9
9
|
|
|
10
10
|
//#region src/adapters/kysely-adapter/kysely-adapter.ts
|
|
@@ -3,7 +3,7 @@ import "../../utils-db7gNqd-.mjs";
|
|
|
3
3
|
import "../../crypto-CFUhAR9W.mjs";
|
|
4
4
|
import "../../misc-BwNc0MKr.mjs";
|
|
5
5
|
import "../../json-CnHxKYpj.mjs";
|
|
6
|
-
import { t as createAdapterFactory } from "../../adapter-factory-
|
|
6
|
+
import { t as createAdapterFactory } from "../../adapter-factory-HF3JB9cT.mjs";
|
|
7
7
|
import { logger } from "@better-auth/core/env";
|
|
8
8
|
|
|
9
9
|
//#region src/adapters/memory-adapter/memory-adapter.ts
|
|
@@ -3,7 +3,7 @@ import "../../utils-db7gNqd-.mjs";
|
|
|
3
3
|
import "../../crypto-CFUhAR9W.mjs";
|
|
4
4
|
import "../../misc-BwNc0MKr.mjs";
|
|
5
5
|
import "../../json-CnHxKYpj.mjs";
|
|
6
|
-
import { t as createAdapterFactory } from "../../adapter-factory-
|
|
6
|
+
import { t as createAdapterFactory } from "../../adapter-factory-HF3JB9cT.mjs";
|
|
7
7
|
import { ObjectId } from "mongodb";
|
|
8
8
|
|
|
9
9
|
//#region src/adapters/mongodb-adapter/mongodb-adapter.ts
|
|
@@ -30,9 +30,9 @@ const mongodbAdapter = (db, config) => {
|
|
|
30
30
|
return v;
|
|
31
31
|
}
|
|
32
32
|
if (v instanceof ObjectId) return v;
|
|
33
|
-
throw new Error("Invalid id value,
|
|
33
|
+
throw new Error("Invalid id value, received: " + JSON.stringify(v));
|
|
34
34
|
});
|
|
35
|
-
throw new Error("Invalid id value,
|
|
35
|
+
throw new Error("Invalid id value, received: " + JSON.stringify(value));
|
|
36
36
|
}
|
|
37
37
|
try {
|
|
38
38
|
return new ObjectId(value);
|
|
@@ -3,7 +3,7 @@ import "../../utils-db7gNqd-.mjs";
|
|
|
3
3
|
import "../../crypto-CFUhAR9W.mjs";
|
|
4
4
|
import "../../misc-BwNc0MKr.mjs";
|
|
5
5
|
import "../../json-CnHxKYpj.mjs";
|
|
6
|
-
import { t as createAdapterFactory } from "../../adapter-factory-
|
|
6
|
+
import { t as createAdapterFactory } from "../../adapter-factory-HF3JB9cT.mjs";
|
|
7
7
|
import { BetterAuthError } from "@better-auth/core/error";
|
|
8
8
|
|
|
9
9
|
//#region src/adapters/prisma-adapter/prisma-adapter.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
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-
|
|
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
5
|
import { t as hasPermission } from "./has-permission-qCjQqGds.mjs";
|
|
6
6
|
import { t as getEndpointResponse } from "./plugin-helper-zFdFWLgL.mjs";
|
|
7
7
|
import { BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as generateId } from "./utils-db7gNqd-.mjs";
|
|
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-
|
|
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,6 +1,5 @@
|
|
|
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-
|
|
2
|
-
import "../types-
|
|
3
|
-
import "../helper-
|
|
4
|
-
import "../
|
|
5
|
-
import "../plugins-B2LAIIX7.mjs";
|
|
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-COnelCGa.mjs";
|
|
2
|
+
import "../types-CEepZ-RG.mjs";
|
|
3
|
+
import "../helper-DFzV6jvx.mjs";
|
|
4
|
+
import "../plugins-Dmw3tk5H.mjs";
|
|
6
5
|
export { APIError, AuthEndpoint, AuthMiddleware, 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 };
|
package/dist/api/index.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import "../dialect-
|
|
1
|
+
import "../dialect-D9ZUZA4J.mjs";
|
|
2
2
|
import "../get-model-name-D4DUV7S2.mjs";
|
|
3
|
-
import "../get-migration-
|
|
3
|
+
import "../get-migration-Bf0TuCzm.mjs";
|
|
4
4
|
import { a as getOAuthState } from "../utils-db7gNqd-.mjs";
|
|
5
5
|
import "../crypto-CFUhAR9W.mjs";
|
|
6
6
|
import "../misc-BwNc0MKr.mjs";
|
|
7
|
-
import "../schema-
|
|
7
|
+
import "../schema-Bb7wzeK_.mjs";
|
|
8
8
|
import { t as getIp } from "../get-request-ip-D6st-mto.mjs";
|
|
9
9
|
import "../json-CnHxKYpj.mjs";
|
|
10
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-
|
|
12
|
-
import "../cookies-
|
|
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-
|
|
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";
|
|
14
14
|
|
|
15
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,11 +1,11 @@
|
|
|
1
1
|
import { i as parseState, n as HIDE_METADATA, r as generateState, t as generateId } from "./utils-db7gNqd-.mjs";
|
|
2
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-
|
|
3
|
+
import { c as parseUserInput, l as parseUserOutput, u as getDate } from "./schema-Bb7wzeK_.mjs";
|
|
4
4
|
import { t as getIp } from "./get-request-ip-D6st-mto.mjs";
|
|
5
5
|
import { t as safeJSONParse } from "./json-CnHxKYpj.mjs";
|
|
6
6
|
import { i as getProtocol, n as getHost, r as getOrigin } from "./url-CB8xCwz-.mjs";
|
|
7
|
-
import { c as setSessionCookie,
|
|
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-
|
|
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";
|
|
9
9
|
import { hasRequestState, runWithEndpointContext, runWithRequestState, runWithTransaction } from "@better-auth/core/context";
|
|
10
10
|
import { isDevelopment, isProduction, logger, shouldPublishLog } from "@better-auth/core/env";
|
|
11
11
|
import { BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
@@ -1803,13 +1803,12 @@ function redirectCallback(ctx, callbackURL, query) {
|
|
|
1803
1803
|
}
|
|
1804
1804
|
const requestPasswordReset = createAuthEndpoint("/request-password-reset", {
|
|
1805
1805
|
method: "POST",
|
|
1806
|
-
operationId: "forgetPassword",
|
|
1807
1806
|
body: z.object({
|
|
1808
1807
|
email: z.email().meta({ description: "The email address of the user to send a password reset email to" }),
|
|
1809
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()
|
|
1810
1809
|
}),
|
|
1811
1810
|
metadata: { openapi: {
|
|
1812
|
-
operationId: "
|
|
1811
|
+
operationId: "requestPasswordReset",
|
|
1813
1812
|
description: "Send a password reset email to the user",
|
|
1814
1813
|
responses: { "200": {
|
|
1815
1814
|
description: "Success",
|
|
@@ -1851,11 +1850,7 @@ const requestPasswordReset = createAuthEndpoint("/request-password-reset", {
|
|
|
1851
1850
|
});
|
|
1852
1851
|
const callbackURL = redirectTo ? encodeURIComponent(redirectTo) : "";
|
|
1853
1852
|
const url = `${ctx.context.baseURL}/reset-password/${verificationToken}?callbackURL=${callbackURL}`;
|
|
1854
|
-
|
|
1855
|
-
* We send the email in the background to prevent timing attacks.
|
|
1856
|
-
* This is to ensure that the response time is consistent regardless of whether the email was sent or not.
|
|
1857
|
-
*/
|
|
1858
|
-
ctx.context.options.emailAndPassword.sendResetPassword({
|
|
1853
|
+
await ctx.context.options.emailAndPassword.sendResetPassword({
|
|
1859
1854
|
user: user.user,
|
|
1860
1855
|
url,
|
|
1861
1856
|
token: verificationToken
|
|
@@ -2446,7 +2441,8 @@ const updateUser = () => createAuthEndpoint("/update-user", {
|
|
|
2446
2441
|
},
|
|
2447
2442
|
image: {
|
|
2448
2443
|
type: "string",
|
|
2449
|
-
description: "The image of the user"
|
|
2444
|
+
description: "The image of the user",
|
|
2445
|
+
nullable: true
|
|
2450
2446
|
}
|
|
2451
2447
|
}
|
|
2452
2448
|
} } } },
|
package/dist/auth/minimal.d.mts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { o as Auth } from "../index-
|
|
2
|
-
import "../types-
|
|
3
|
-
import "../helper-
|
|
4
|
-
import "../
|
|
5
|
-
import "../plugins-B2LAIIX7.mjs";
|
|
1
|
+
import { o as Auth } from "../index-COnelCGa.mjs";
|
|
2
|
+
import "../types-CEepZ-RG.mjs";
|
|
3
|
+
import "../helper-DFzV6jvx.mjs";
|
|
4
|
+
import "../plugins-Dmw3tk5H.mjs";
|
|
6
5
|
import { BetterAuthOptions } from "@better-auth/core";
|
|
7
6
|
|
|
8
7
|
//#region src/auth/minimal.d.ts
|
package/dist/auth/minimal.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import "../dialect-
|
|
1
|
+
import "../dialect-D9ZUZA4J.mjs";
|
|
2
2
|
import "../get-model-name-D4DUV7S2.mjs";
|
|
3
|
-
import { d as getBaseAdapter } from "../get-migration-
|
|
3
|
+
import { d as getBaseAdapter } from "../get-migration-Bf0TuCzm.mjs";
|
|
4
4
|
import "../utils-db7gNqd-.mjs";
|
|
5
5
|
import "../crypto-CFUhAR9W.mjs";
|
|
6
6
|
import "../misc-BwNc0MKr.mjs";
|
|
7
|
-
import "../schema-
|
|
7
|
+
import "../schema-Bb7wzeK_.mjs";
|
|
8
8
|
import "../get-request-ip-D6st-mto.mjs";
|
|
9
9
|
import "../json-CnHxKYpj.mjs";
|
|
10
10
|
import "../url-CB8xCwz-.mjs";
|
|
11
|
-
import "../api-
|
|
12
|
-
import "../cookies-
|
|
13
|
-
import "../session-
|
|
14
|
-
import { n as createAuthContext, t as createBetterAuth } from "../base-
|
|
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
15
|
import "../password-BFQK0cLg.mjs";
|
|
16
16
|
import { BetterAuthError } from "@better-auth/core/error";
|
|
17
17
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as getKyselyDatabaseType } from "./dialect-
|
|
2
|
-
import { t as getMigrations, u as getAdapter } from "./get-migration-
|
|
3
|
-
import { n as createAuthContext, t as createBetterAuth } from "./base-
|
|
1
|
+
import { n as getKyselyDatabaseType } from "./dialect-D9ZUZA4J.mjs";
|
|
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,10 +1,10 @@
|
|
|
1
1
|
import { a as getAuthTables } from "./get-model-name-D4DUV7S2.mjs";
|
|
2
|
-
import { a as createInternalAdapter } from "./get-migration-
|
|
2
|
+
import { a as createInternalAdapter } from "./get-migration-Bf0TuCzm.mjs";
|
|
3
3
|
import { t as generateId } from "./utils-db7gNqd-.mjs";
|
|
4
4
|
import { a as verifyPassword, i as hashPassword } from "./crypto-CFUhAR9W.mjs";
|
|
5
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-
|
|
7
|
-
import { i as getCookies, t as createCookieGetter } from "./cookies-
|
|
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
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";
|
|
@@ -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
|