auth 1.5.6 → 1.6.0-beta.0
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/api.d.mts +1 -2
- package/dist/api.mjs +3 -10
- package/dist/index.mjs +10 -53
- package/package.json +8 -12
- package/dist/api.mjs.map +0 -1
- package/dist/index.mjs.map +0 -1
package/dist/api.d.mts
CHANGED
|
@@ -41,5 +41,4 @@ declare const generateKyselySchema: SchemaGenerator;
|
|
|
41
41
|
//#region src/generators/prisma.d.ts
|
|
42
42
|
declare const generatePrismaSchema: SchemaGenerator;
|
|
43
43
|
//#endregion
|
|
44
|
-
export { type DBAdapter, type SchemaGenerator, type SchemaGeneratorResult, adapters, generateDrizzleSchema, generateKyselySchema, generatePrismaSchema, generateSchema };
|
|
45
|
-
//# sourceMappingURL=api.d.mts.map
|
|
44
|
+
export { type DBAdapter, type SchemaGenerator, type SchemaGeneratorResult, adapters, generateDrizzleSchema, generateKyselySchema, generatePrismaSchema, generateSchema };
|
package/dist/api.mjs
CHANGED
|
@@ -7,7 +7,6 @@ import fs from "node:fs/promises";
|
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import { capitalizeFirstLetter } from "@better-auth/core/utils/string";
|
|
9
9
|
import { produceSchema } from "@mrleebo/prisma-ast";
|
|
10
|
-
|
|
11
10
|
//#region src/generators/drizzle.ts
|
|
12
11
|
function convertToSnakeCase(str, camelCase) {
|
|
13
12
|
if (camelCase) return str;
|
|
@@ -139,7 +138,7 @@ const generateDrizzleSchema = async ({ options, file, adapter }) => {
|
|
|
139
138
|
if (attr.onUpdate && attr.type === "date") {
|
|
140
139
|
if (typeof attr.onUpdate === "function") type += `.$onUpdate(${attr.onUpdate})`;
|
|
141
140
|
}
|
|
142
|
-
return `${fieldName}: ${type}${attr.required ? ".notNull()" : ""}${attr.unique ? ".unique()" : ""}${attr.references ? `.references(()=> ${getModelName(attr.references.model)}.${getFieldName({
|
|
141
|
+
return `${fieldName}: ${type}${attr.required !== false ? ".notNull()" : ""}${attr.unique ? ".unique()" : ""}${attr.references ? `.references(()=> ${getModelName(attr.references.model)}.${getFieldName({
|
|
143
142
|
model: attr.references.model,
|
|
144
143
|
field: attr.references.field
|
|
145
144
|
})}, { onDelete: '${attr.references.onDelete || "cascade"}' })` : ""}`;
|
|
@@ -296,7 +295,6 @@ function generateImport({ databaseType, tables, options }) {
|
|
|
296
295
|
if (hasUniqueIndexes) coreImports.push("uniqueIndex");
|
|
297
296
|
return `${rootImports.length > 0 ? `import { ${rootImports.join(", ")} } from "drizzle-orm";\n` : ""}import { ${coreImports.map((x) => x.trim()).filter((x) => x !== "").join(", ")} } from "drizzle-orm/${databaseType}-core";\n`;
|
|
298
297
|
}
|
|
299
|
-
|
|
300
298
|
//#endregion
|
|
301
299
|
//#region src/generators/kysely.ts
|
|
302
300
|
const generateKyselySchema = async ({ options, file }) => {
|
|
@@ -307,7 +305,6 @@ const generateKyselySchema = async ({ options, file }) => {
|
|
|
307
305
|
fileName: file || `./better-auth_migrations/${(/* @__PURE__ */ new Date()).toISOString().replace(/:/g, "-")}.sql`
|
|
308
306
|
};
|
|
309
307
|
};
|
|
310
|
-
|
|
311
308
|
//#endregion
|
|
312
309
|
//#region src/utils/get-package-info.ts
|
|
313
310
|
function getPackageInfo(cwd) {
|
|
@@ -325,7 +322,6 @@ function getPrismaVersion(cwd) {
|
|
|
325
322
|
return null;
|
|
326
323
|
}
|
|
327
324
|
}
|
|
328
|
-
|
|
329
325
|
//#endregion
|
|
330
326
|
//#region src/generators/prisma.ts
|
|
331
327
|
const generatePrismaSchema = async ({ adapter, options, file }) => {
|
|
@@ -435,7 +431,7 @@ const generatePrismaSchema = async ({ adapter, options, file }) => {
|
|
|
435
431
|
type: "number"
|
|
436
432
|
}) : getType({
|
|
437
433
|
isBigint: attr?.bigint || false,
|
|
438
|
-
isOptional:
|
|
434
|
+
isOptional: attr?.required === false,
|
|
439
435
|
type: attr.references?.field === "id" ? useNumberId ? "number" : "string" : attr.type
|
|
440
436
|
}));
|
|
441
437
|
if (field === "id") {
|
|
@@ -497,7 +493,7 @@ const generatePrismaSchema = async ({ adapter, options, file }) => {
|
|
|
497
493
|
model: attr.references.model,
|
|
498
494
|
field: attr.references.field
|
|
499
495
|
})}], onDelete: ${action})`;
|
|
500
|
-
builder.model(modelName).field(referencedCustomModelName.toLowerCase(), `${capitalizeFirstLetter(referencedCustomModelName)}${
|
|
496
|
+
builder.model(modelName).field(referencedCustomModelName.toLowerCase(), `${capitalizeFirstLetter(referencedCustomModelName)}${attr.required === false ? "?" : ""}`).attribute(relationField);
|
|
501
497
|
}
|
|
502
498
|
if (!attr.unique && !attr.references && provider === "mysql" && attr.type === "string") builder.model(modelName).field(fieldName).attribute("db.Text");
|
|
503
499
|
}
|
|
@@ -562,7 +558,6 @@ const getNewPrisma = (provider, cwd) => {
|
|
|
562
558
|
url = ${provider === "sqlite" ? `"file:./dev.db"` : `env("DATABASE_URL")`}
|
|
563
559
|
}`;
|
|
564
560
|
};
|
|
565
|
-
|
|
566
561
|
//#endregion
|
|
567
562
|
//#region src/generators/index.ts
|
|
568
563
|
const adapters = {
|
|
@@ -581,7 +576,5 @@ const generateSchema = (opts) => {
|
|
|
581
576
|
}));
|
|
582
577
|
throw new Error(`${adapter.id} is not supported. If it is a custom adapter, please request the maintainer to implement createSchema`);
|
|
583
578
|
};
|
|
584
|
-
|
|
585
579
|
//#endregion
|
|
586
580
|
export { adapters, generateDrizzleSchema, generateKyselySchema, generatePrismaSchema, generateSchema };
|
|
587
|
-
//# sourceMappingURL=api.mjs.map
|
package/dist/index.mjs
CHANGED
|
@@ -32,7 +32,6 @@ import { log } from "@clack/prompts";
|
|
|
32
32
|
import { base64 } from "@better-auth/utils/base64";
|
|
33
33
|
import * as semver from "semver";
|
|
34
34
|
import "dotenv/config";
|
|
35
|
-
|
|
36
35
|
//#region src/commands/ai.ts
|
|
37
36
|
const PROTOCOL_URL = "https://agent-auth-protocol.com";
|
|
38
37
|
const AGENT_CLI_PKG = "@auth/agent-cli";
|
|
@@ -577,7 +576,6 @@ function showNextSteps(lines) {
|
|
|
577
576
|
for (const line of lines) console.log(` ${line}`);
|
|
578
577
|
}
|
|
579
578
|
const ai = new Command("ai").description("Interactive setup for Agent Auth — AI agent authentication").action(aiAction);
|
|
580
|
-
|
|
581
579
|
//#endregion
|
|
582
580
|
//#region src/generators/drizzle.ts
|
|
583
581
|
function convertToSnakeCase(str, camelCase) {
|
|
@@ -710,7 +708,7 @@ const generateDrizzleSchema = async ({ options, file, adapter }) => {
|
|
|
710
708
|
if (attr.onUpdate && attr.type === "date") {
|
|
711
709
|
if (typeof attr.onUpdate === "function") type += `.$onUpdate(${attr.onUpdate})`;
|
|
712
710
|
}
|
|
713
|
-
return `${fieldName}: ${type}${attr.required ? ".notNull()" : ""}${attr.unique ? ".unique()" : ""}${attr.references ? `.references(()=> ${getModelName(attr.references.model)}.${getFieldName({
|
|
711
|
+
return `${fieldName}: ${type}${attr.required !== false ? ".notNull()" : ""}${attr.unique ? ".unique()" : ""}${attr.references ? `.references(()=> ${getModelName(attr.references.model)}.${getFieldName({
|
|
714
712
|
model: attr.references.model,
|
|
715
713
|
field: attr.references.field
|
|
716
714
|
})}, { onDelete: '${attr.references.onDelete || "cascade"}' })` : ""}`;
|
|
@@ -867,7 +865,6 @@ function generateImport({ databaseType, tables, options }) {
|
|
|
867
865
|
if (hasUniqueIndexes) coreImports.push("uniqueIndex");
|
|
868
866
|
return `${rootImports.length > 0 ? `import { ${rootImports.join(", ")} } from "drizzle-orm";\n` : ""}import { ${coreImports.map((x) => x.trim()).filter((x) => x !== "").join(", ")} } from "drizzle-orm/${databaseType}-core";\n`;
|
|
869
867
|
}
|
|
870
|
-
|
|
871
868
|
//#endregion
|
|
872
869
|
//#region src/generators/kysely.ts
|
|
873
870
|
const generateKyselySchema = async ({ options, file }) => {
|
|
@@ -878,7 +875,6 @@ const generateKyselySchema = async ({ options, file }) => {
|
|
|
878
875
|
fileName: file || `./better-auth_migrations/${(/* @__PURE__ */ new Date()).toISOString().replace(/:/g, "-")}.sql`
|
|
879
876
|
};
|
|
880
877
|
};
|
|
881
|
-
|
|
882
878
|
//#endregion
|
|
883
879
|
//#region src/utils/helper.ts
|
|
884
880
|
async function tryCatch(promise) {
|
|
@@ -894,7 +890,7 @@ async function tryCatch(promise) {
|
|
|
894
890
|
};
|
|
895
891
|
}
|
|
896
892
|
}
|
|
897
|
-
const generateSecretHash
|
|
893
|
+
const generateSecretHash = () => {
|
|
898
894
|
return Crypto.randomBytes(16).toString("hex");
|
|
899
895
|
};
|
|
900
896
|
const spawnCommand = (cmd, cwd = process.cwd()) => new Promise((resolve, reject) => {
|
|
@@ -910,7 +906,6 @@ const spawnCommand = (cmd, cwd = process.cwd()) => new Promise((resolve, reject)
|
|
|
910
906
|
});
|
|
911
907
|
child.on("error", reject);
|
|
912
908
|
});
|
|
913
|
-
|
|
914
909
|
//#endregion
|
|
915
910
|
//#region src/utils/get-package-info.ts
|
|
916
911
|
function getPackageInfo(cwd) {
|
|
@@ -982,7 +977,6 @@ async function findMonorepoRoot(startDir) {
|
|
|
982
977
|
}
|
|
983
978
|
return null;
|
|
984
979
|
}
|
|
985
|
-
|
|
986
980
|
//#endregion
|
|
987
981
|
//#region src/generators/prisma.ts
|
|
988
982
|
const generatePrismaSchema = async ({ adapter, options, file }) => {
|
|
@@ -1092,7 +1086,7 @@ const generatePrismaSchema = async ({ adapter, options, file }) => {
|
|
|
1092
1086
|
type: "number"
|
|
1093
1087
|
}) : getType({
|
|
1094
1088
|
isBigint: attr?.bigint || false,
|
|
1095
|
-
isOptional:
|
|
1089
|
+
isOptional: attr?.required === false,
|
|
1096
1090
|
type: attr.references?.field === "id" ? useNumberId ? "number" : "string" : attr.type
|
|
1097
1091
|
}));
|
|
1098
1092
|
if (field === "id") {
|
|
@@ -1154,7 +1148,7 @@ const generatePrismaSchema = async ({ adapter, options, file }) => {
|
|
|
1154
1148
|
model: attr.references.model,
|
|
1155
1149
|
field: attr.references.field
|
|
1156
1150
|
})}], onDelete: ${action})`;
|
|
1157
|
-
builder.model(modelName).field(referencedCustomModelName.toLowerCase(), `${capitalizeFirstLetter(referencedCustomModelName)}${
|
|
1151
|
+
builder.model(modelName).field(referencedCustomModelName.toLowerCase(), `${capitalizeFirstLetter(referencedCustomModelName)}${attr.required === false ? "?" : ""}`).attribute(relationField);
|
|
1158
1152
|
}
|
|
1159
1153
|
if (!attr.unique && !attr.references && provider === "mysql" && attr.type === "string") builder.model(modelName).field(fieldName).attribute("db.Text");
|
|
1160
1154
|
}
|
|
@@ -1219,7 +1213,6 @@ const getNewPrisma = (provider, cwd) => {
|
|
|
1219
1213
|
url = ${provider === "sqlite" ? `"file:./dev.db"` : `env("DATABASE_URL")`}
|
|
1220
1214
|
}`;
|
|
1221
1215
|
};
|
|
1222
|
-
|
|
1223
1216
|
//#endregion
|
|
1224
1217
|
//#region src/generators/index.ts
|
|
1225
1218
|
const adapters = {
|
|
@@ -1238,7 +1231,6 @@ const generateSchema = (opts) => {
|
|
|
1238
1231
|
}));
|
|
1239
1232
|
throw new Error(`${adapter.id} is not supported. If it is a custom adapter, please request the maintainer to implement createSchema`);
|
|
1240
1233
|
};
|
|
1241
|
-
|
|
1242
1234
|
//#endregion
|
|
1243
1235
|
//#region src/utils/add-cloudflare-modules.ts
|
|
1244
1236
|
const createModule = () => {
|
|
@@ -1313,7 +1305,6 @@ function addCloudflareModules(aliases, _cwd) {
|
|
|
1313
1305
|
if (!aliases["cloudflare:workers"]) aliases["cloudflare:workers"] = CLOUDFLARE_STUB_MODULE;
|
|
1314
1306
|
if (!aliases["cloudflare:test"]) aliases["cloudflare:test"] = CLOUDFLARE_STUB_MODULE;
|
|
1315
1307
|
}
|
|
1316
|
-
|
|
1317
1308
|
//#endregion
|
|
1318
1309
|
//#region src/utils/add-svelte-kit-env-modules.ts
|
|
1319
1310
|
/**
|
|
@@ -1464,7 +1455,6 @@ const reserved = new Set([
|
|
|
1464
1455
|
"implements",
|
|
1465
1456
|
"instanceof"
|
|
1466
1457
|
]);
|
|
1467
|
-
|
|
1468
1458
|
//#endregion
|
|
1469
1459
|
//#region src/utils/get-config.ts
|
|
1470
1460
|
let possiblePaths$1 = [
|
|
@@ -1641,7 +1631,6 @@ async function getConfig({ cwd, configPath, shouldThrowOnError = false }) {
|
|
|
1641
1631
|
process.exit(1);
|
|
1642
1632
|
}
|
|
1643
1633
|
}
|
|
1644
|
-
|
|
1645
1634
|
//#endregion
|
|
1646
1635
|
//#region src/commands/generate.ts
|
|
1647
1636
|
function createMockAdapter$1(adapterId, dialect) {
|
|
@@ -1815,7 +1804,6 @@ async function generateAction(opts) {
|
|
|
1815
1804
|
process.exit(0);
|
|
1816
1805
|
}
|
|
1817
1806
|
const generate = new Command("generate").option("-c, --cwd <cwd>", "the working directory. defaults to the current directory.", process.cwd()).option("--config <config>", "the path to the configuration file. defaults to the first configuration file found.").option("--output <output>", "the file to output to the generated schema").option("--adapter <adapter>", "specify the adapter type (e.g., prisma, drizzle, kysely) without requiring a configured adapter").option("--dialect <dialect>", "specify the database dialect/provider (e.g., postgresql, mysql, sqlite). For drizzle, postgresql maps to 'pg'").option("-y, --yes", "automatically answer yes to all prompts", false).option("--y", "(deprecated) same as --yes", false).action(generateAction);
|
|
1818
|
-
|
|
1819
1807
|
//#endregion
|
|
1820
1808
|
//#region src/commands/info.ts
|
|
1821
1809
|
function getSystemInfo() {
|
|
@@ -2178,7 +2166,6 @@ ${JSON.stringify(betterAuthInfo, null, 2)}
|
|
|
2178
2166
|
}
|
|
2179
2167
|
}
|
|
2180
2168
|
});
|
|
2181
|
-
|
|
2182
2169
|
//#endregion
|
|
2183
2170
|
//#region src/utils/check-package-managers.ts
|
|
2184
2171
|
async function checkPackageManagers() {
|
|
@@ -2268,7 +2255,6 @@ async function getVersion(pkgManager) {
|
|
|
2268
2255
|
});
|
|
2269
2256
|
});
|
|
2270
2257
|
}
|
|
2271
|
-
|
|
2272
2258
|
//#endregion
|
|
2273
2259
|
//#region src/utils/config-paths.ts
|
|
2274
2260
|
let possiblePaths = [
|
|
@@ -2329,7 +2315,6 @@ _possibleClientConfigPaths = [
|
|
|
2329
2315
|
..._possibleClientConfigPaths.map((it) => `app/${it}`)
|
|
2330
2316
|
];
|
|
2331
2317
|
const possibleClientConfigPaths = _possibleClientConfigPaths;
|
|
2332
|
-
|
|
2333
2318
|
//#endregion
|
|
2334
2319
|
//#region src/utils/install-dependencies.ts
|
|
2335
2320
|
const flagsMap = {
|
|
@@ -2396,7 +2381,6 @@ function installDependencies({ dependencies, packageManager, cwd, type = "prod",
|
|
|
2396
2381
|
});
|
|
2397
2382
|
});
|
|
2398
2383
|
}
|
|
2399
|
-
|
|
2400
2384
|
//#endregion
|
|
2401
2385
|
//#region src/commands/init/configs/frameworks.config.ts
|
|
2402
2386
|
const FRAMEWORKS = [
|
|
@@ -2601,7 +2585,6 @@ export const Route = createFileRoute('/api/auth/$')({
|
|
|
2601
2585
|
configPaths: ["nitro.config.ts"]
|
|
2602
2586
|
}
|
|
2603
2587
|
];
|
|
2604
|
-
|
|
2605
2588
|
//#endregion
|
|
2606
2589
|
//#region src/commands/init/configs/social-providers.config.ts
|
|
2607
2590
|
const SOCIAL_PROVIDERS = [
|
|
@@ -2886,13 +2869,11 @@ const SOCIAL_PROVIDER_CONFIGS = {
|
|
|
2886
2869
|
envVar: "ZOOM_CLIENT_SECRET"
|
|
2887
2870
|
}] }
|
|
2888
2871
|
};
|
|
2889
|
-
|
|
2890
2872
|
//#endregion
|
|
2891
2873
|
//#region src/commands/init/utility/format.ts
|
|
2892
2874
|
const formatCode = async (code) => {
|
|
2893
2875
|
return await format(code, { parser: "typescript" });
|
|
2894
2876
|
};
|
|
2895
|
-
|
|
2896
2877
|
//#endregion
|
|
2897
2878
|
//#region src/commands/init/utility/imports.ts
|
|
2898
2879
|
/**
|
|
@@ -2948,7 +2929,6 @@ const groupImports = (imports) => {
|
|
|
2948
2929
|
return a.path.localeCompare(b.path);
|
|
2949
2930
|
});
|
|
2950
2931
|
};
|
|
2951
|
-
|
|
2952
2932
|
//#endregion
|
|
2953
2933
|
//#region src/commands/init/configs/temp-plugins.config.ts
|
|
2954
2934
|
const tempPluginsConfig = {
|
|
@@ -4619,7 +4599,6 @@ const tempPluginsConfig = {
|
|
|
4619
4599
|
}
|
|
4620
4600
|
}
|
|
4621
4601
|
};
|
|
4622
|
-
|
|
4623
4602
|
//#endregion
|
|
4624
4603
|
//#region src/commands/init/utility/prompt.ts
|
|
4625
4604
|
const getFlagVariable = (flag) => {
|
|
@@ -4726,7 +4705,6 @@ const getArgumentsPrompt = async (options, plugins, target) => {
|
|
|
4726
4705
|
return arg.isRequired && arg.defaultValue !== void 0 ? arg.defaultValue : void 0;
|
|
4727
4706
|
};
|
|
4728
4707
|
};
|
|
4729
|
-
|
|
4730
4708
|
//#endregion
|
|
4731
4709
|
//#region src/commands/init/utility/plugin.ts
|
|
4732
4710
|
const getPluginConfigs = (plugins) => {
|
|
@@ -4899,7 +4877,6 @@ const getAuthClientPluginsCode = async ({ plugins, options = {}, installDependen
|
|
|
4899
4877
|
}
|
|
4900
4878
|
return (await formatCode(`[${pluginsCode.join(", ")}]`)).trim().slice(0, -1);
|
|
4901
4879
|
};
|
|
4902
|
-
|
|
4903
4880
|
//#endregion
|
|
4904
4881
|
//#region src/commands/init/utility/auth-config.ts
|
|
4905
4882
|
const generateInnerAuthConfigCode = async ({ database, plugins, appName, baseURL, emailAndPassword, socialProviders, options, installDependency }) => {
|
|
@@ -4962,7 +4939,6 @@ const getDatabaseCode$1 = (database) => {
|
|
|
4962
4939
|
if (!database) return void 0;
|
|
4963
4940
|
return database.code({});
|
|
4964
4941
|
};
|
|
4965
|
-
|
|
4966
4942
|
//#endregion
|
|
4967
4943
|
//#region src/commands/init/configs/databases.config.ts
|
|
4968
4944
|
const prismaCode = ({ provider, additionalOptions }) => {
|
|
@@ -5353,7 +5329,6 @@ const databasesConfig = [
|
|
|
5353
5329
|
dependencies: ["mongodb"]
|
|
5354
5330
|
}
|
|
5355
5331
|
];
|
|
5356
|
-
|
|
5357
5332
|
//#endregion
|
|
5358
5333
|
//#region src/commands/init/utility/database.ts
|
|
5359
5334
|
const getDatabaseCode = (adapter) => {
|
|
@@ -5483,7 +5458,6 @@ const getDialectsForORM = (orm) => {
|
|
|
5483
5458
|
}
|
|
5484
5459
|
return dialects.sort((a, b) => a.value.localeCompare(b.value));
|
|
5485
5460
|
};
|
|
5486
|
-
|
|
5487
5461
|
//#endregion
|
|
5488
5462
|
//#region src/commands/init/generate-auth.ts
|
|
5489
5463
|
const generateAuthConfigCode = async ({ plugins: pluginsConfig, database: databaseConfig, appName, baseURL, emailAndPassword, socialProviders, installDependency, options }) => {
|
|
@@ -5529,7 +5503,6 @@ const generateAuthConfigCode = async ({ plugins: pluginsConfig, database: databa
|
|
|
5529
5503
|
segmentedCode.exports
|
|
5530
5504
|
].join("\n"));
|
|
5531
5505
|
};
|
|
5532
|
-
|
|
5533
5506
|
//#endregion
|
|
5534
5507
|
//#region src/commands/init/utility/auth-client-config.ts
|
|
5535
5508
|
const generateInnerAuthClientConfigCode = async ({ plugins, options, installDependency }) => {
|
|
@@ -5545,7 +5518,6 @@ const generateInnerAuthClientConfigCode = async ({ plugins, options, installDepe
|
|
|
5545
5518
|
}
|
|
5546
5519
|
return stringCode;
|
|
5547
5520
|
};
|
|
5548
|
-
|
|
5549
5521
|
//#endregion
|
|
5550
5522
|
//#region src/commands/init/generate-auth-client.ts
|
|
5551
5523
|
const generateAuthClientConfigCode = async ({ plugins: pluginsConfig, database: databaseConfig, framework, options, installDependency }) => {
|
|
@@ -5585,7 +5557,6 @@ const generateAuthClientConfigCode = async ({ plugins: pluginsConfig, database:
|
|
|
5585
5557
|
segmentedCode.exports
|
|
5586
5558
|
].join("\n"));
|
|
5587
5559
|
};
|
|
5588
|
-
|
|
5589
5560
|
//#endregion
|
|
5590
5561
|
//#region src/commands/init/utility/env.ts
|
|
5591
5562
|
const getEnvFiles = async (cwd) => {
|
|
@@ -5631,7 +5602,6 @@ const createEnvFile = async (cwd, envVariables) => {
|
|
|
5631
5602
|
const envFile = path.join(cwd, ".env");
|
|
5632
5603
|
await fs$1.writeFile(envFile, envVariables.join("\n"), "utf-8");
|
|
5633
5604
|
};
|
|
5634
|
-
|
|
5635
5605
|
//#endregion
|
|
5636
5606
|
//#region src/commands/init/utility/framework.ts
|
|
5637
5607
|
async function detectFramework(cwd, packageJson) {
|
|
@@ -5656,7 +5626,6 @@ const fileStrategy = ({ cwd }) => {
|
|
|
5656
5626
|
}
|
|
5657
5627
|
return null;
|
|
5658
5628
|
};
|
|
5659
|
-
|
|
5660
5629
|
//#endregion
|
|
5661
5630
|
//#region src/commands/init/index.ts
|
|
5662
5631
|
const confirm = async (options) => {
|
|
@@ -5900,7 +5869,7 @@ async function initAction(opts) {
|
|
|
5900
5869
|
cancel("✋ Operation cancelled.");
|
|
5901
5870
|
process.exit(0);
|
|
5902
5871
|
}
|
|
5903
|
-
const envs = [`BETTER_AUTH_SECRET="${providedSecret || generateSecretHash
|
|
5872
|
+
const envs = [`BETTER_AUTH_SECRET="${providedSecret || generateSecretHash()}"`, `BETTER_AUTH_URL="${providedURL}"`];
|
|
5904
5873
|
envFiles.set(".env", envs);
|
|
5905
5874
|
filesToWrite.push(() => createEnvFile(cwd, envs));
|
|
5906
5875
|
}
|
|
@@ -5928,7 +5897,7 @@ async function initAction(opts) {
|
|
|
5928
5897
|
cancel("✋ Operation cancelled.");
|
|
5929
5898
|
process.exit(0);
|
|
5930
5899
|
}
|
|
5931
|
-
envs.push(`BETTER_AUTH_SECRET="${providedSecret || generateSecretHash
|
|
5900
|
+
envs.push(`BETTER_AUTH_SECRET="${providedSecret || generateSecretHash()}"`);
|
|
5932
5901
|
} else if (v === "BETTER_AUTH_URL") {
|
|
5933
5902
|
const { providedURL } = await prompts({
|
|
5934
5903
|
type: "text",
|
|
@@ -5959,7 +5928,7 @@ async function initAction(opts) {
|
|
|
5959
5928
|
process.exit(0);
|
|
5960
5929
|
}
|
|
5961
5930
|
if (filesToUpdate) {
|
|
5962
|
-
const secretHash = generateSecretHash
|
|
5931
|
+
const secretHash = generateSecretHash();
|
|
5963
5932
|
for (const file of filesToUpdate) {
|
|
5964
5933
|
const envs = missingEnvVars.find((x) => x.file === file).var.map((v) => {
|
|
5965
5934
|
if (v === "BETTER_AUTH_SECRET") return `BETTER_AUTH_SECRET="${secretHash}"`;
|
|
@@ -6631,7 +6600,6 @@ const initActionOptionsSchema = z.object({
|
|
|
6631
6600
|
packageManager: z.enum(PACKAGE_MANAGER).optional(),
|
|
6632
6601
|
...pluginArgumentOptionsSchema
|
|
6633
6602
|
});
|
|
6634
|
-
|
|
6635
6603
|
//#endregion
|
|
6636
6604
|
//#region src/commands/login.ts
|
|
6637
6605
|
async function loginAction() {
|
|
@@ -6654,10 +6622,9 @@ async function logoutAction() {
|
|
|
6654
6622
|
process.exit(0);
|
|
6655
6623
|
}
|
|
6656
6624
|
const logout = new Command("logout").description("Logout from Better Auth Infrastructure").action(logoutAction);
|
|
6657
|
-
|
|
6658
6625
|
//#endregion
|
|
6659
6626
|
//#region src/commands/mcp.ts
|
|
6660
|
-
const REMOTE_MCP_URL = "https://mcp.
|
|
6627
|
+
const REMOTE_MCP_URL = "https://mcp.better-auth.com/mcp";
|
|
6661
6628
|
async function mcpAction(options) {
|
|
6662
6629
|
if (options.cursor) await handleCursorAction();
|
|
6663
6630
|
else if (options.claudeCode) handleClaudeCodeAction();
|
|
@@ -6785,7 +6752,6 @@ function showAllOptions() {
|
|
|
6785
6752
|
console.log();
|
|
6786
6753
|
}
|
|
6787
6754
|
const mcp = new Command("mcp").description("Add Better Auth MCP server to MCP Clients").option("--cursor", "Automatically open Cursor with the MCP configuration").option("--claude-code", "Show Claude Code MCP configuration command").option("--open-code", "Show Open Code MCP configuration").option("--manual", "Show manual MCP configuration for mcp.json").action(mcpAction);
|
|
6788
|
-
|
|
6789
6755
|
//#endregion
|
|
6790
6756
|
//#region src/commands/migrate.ts
|
|
6791
6757
|
/** @internal */
|
|
@@ -6915,18 +6881,13 @@ async function migrateAction(opts) {
|
|
|
6915
6881
|
process.exit(0);
|
|
6916
6882
|
}
|
|
6917
6883
|
const migrate = new Command("migrate").option("-c, --cwd <cwd>", "the working directory. defaults to the current directory.", process.cwd()).option("--config <config>", "the path to the configuration file. defaults to the first configuration file found.").option("-y, --yes", "automatically accept and run migrations without prompting", false).option("--y", "(deprecated) same as --yes", false).action(migrateAction);
|
|
6918
|
-
|
|
6919
6884
|
//#endregion
|
|
6920
6885
|
//#region src/commands/secret.ts
|
|
6921
6886
|
const generateSecret = new Command("secret").action(() => {
|
|
6922
|
-
const secret =
|
|
6923
|
-
console.log(`\nAdd the following to your .env file:
|
|
6887
|
+
const secret = Crypto.randomBytes(32).toString("hex");
|
|
6888
|
+
console.log(`\nAdd the following to your .env file:
|
|
6924
6889
|
${chalk.gray("# Auth Secret") + chalk.green(`\nBETTER_AUTH_SECRET=${secret}`)}`);
|
|
6925
6890
|
});
|
|
6926
|
-
const generateSecretHash = () => {
|
|
6927
|
-
return Crypto.randomBytes(32).toString("hex");
|
|
6928
|
-
};
|
|
6929
|
-
|
|
6930
6891
|
//#endregion
|
|
6931
6892
|
//#region src/utils/fetch-latest-version.ts
|
|
6932
6893
|
async function fetchLatestVersion(packageName) {
|
|
@@ -6939,7 +6900,6 @@ async function fetchLatestVersion(packageName) {
|
|
|
6939
6900
|
return null;
|
|
6940
6901
|
}
|
|
6941
6902
|
}
|
|
6942
|
-
|
|
6943
6903
|
//#endregion
|
|
6944
6904
|
//#region src/commands/upgrade.ts
|
|
6945
6905
|
function isBetterAuthPackage(name) {
|
|
@@ -7044,7 +7004,6 @@ async function upgradeAction(opts) {
|
|
|
7044
7004
|
}
|
|
7045
7005
|
}
|
|
7046
7006
|
const upgrade = new Command("upgrade").description("Upgrade better-auth packages to their latest versions").option("-c, --cwd <cwd>", "the working directory. defaults to the current directory.", process.cwd()).option("-y, --yes", "automatically accept and upgrade without prompting", false).action(upgradeAction);
|
|
7047
|
-
|
|
7048
7007
|
//#endregion
|
|
7049
7008
|
//#region src/index.ts
|
|
7050
7009
|
process.on("SIGINT", () => process.exit(0));
|
|
@@ -7064,7 +7023,5 @@ main().catch((error) => {
|
|
|
7064
7023
|
console.error("Error running Better Auth CLI:", error);
|
|
7065
7024
|
process.exit(1);
|
|
7066
7025
|
});
|
|
7067
|
-
|
|
7068
7026
|
//#endregion
|
|
7069
7027
|
export { cliVersion };
|
|
7070
|
-
//# sourceMappingURL=index.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "auth",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0-beta.0",
|
|
4
4
|
"description": "The CLI for Better Auth",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,27 +46,23 @@
|
|
|
46
46
|
"@babel/core": "^7.29.0",
|
|
47
47
|
"@babel/preset-react": "^7.28.5",
|
|
48
48
|
"@babel/preset-typescript": "^7.28.5",
|
|
49
|
-
"@better-auth/utils": "0.
|
|
49
|
+
"@better-auth/utils": "0.4.0",
|
|
50
50
|
"@clack/prompts": "^0.11.0",
|
|
51
51
|
"@mrleebo/prisma-ast": "^0.13.1",
|
|
52
|
-
"@prisma/client": "^7.4.1",
|
|
53
|
-
"@types/pg": "^8.16.0",
|
|
54
52
|
"c12": "^3.3.3",
|
|
55
53
|
"chalk": "^5.6.2",
|
|
56
54
|
"commander": "^12.1.0",
|
|
57
55
|
"dotenv": "^17.3.1",
|
|
58
|
-
"drizzle-orm": "^0.41.0",
|
|
59
56
|
"get-tsconfig": "^4.13.6",
|
|
60
57
|
"open": "^10.2.0",
|
|
61
|
-
"pg": "^8.19.0",
|
|
62
58
|
"prettier": "^3.8.1",
|
|
63
59
|
"prompts": "^2.4.2",
|
|
64
60
|
"semver": "^7.7.4",
|
|
65
61
|
"yocto-spinner": "^0.2.3",
|
|
66
62
|
"zod": "^4.3.6",
|
|
67
|
-
"@better-auth/core": "1.
|
|
68
|
-
"better-auth": "1.
|
|
69
|
-
"
|
|
63
|
+
"@better-auth/core": "1.6.0-beta.0",
|
|
64
|
+
"@better-auth/telemetry": "1.6.0-beta.0",
|
|
65
|
+
"better-auth": "1.6.0-beta.0"
|
|
70
66
|
},
|
|
71
67
|
"devDependencies": {
|
|
72
68
|
"@types/better-sqlite3": "^7.6.13",
|
|
@@ -75,17 +71,17 @@
|
|
|
75
71
|
"better-sqlite3": "^12.6.2",
|
|
76
72
|
"jiti": "^2.6.1",
|
|
77
73
|
"memfs": "^4.56.10",
|
|
78
|
-
"tsdown": "0.21.
|
|
74
|
+
"tsdown": "0.21.1",
|
|
79
75
|
"tsx": "^4.21.0",
|
|
80
76
|
"type-fest": "^5.4.4",
|
|
81
77
|
"typescript": "^5.9.3",
|
|
82
|
-
"@better-auth/passkey": "1.
|
|
78
|
+
"@better-auth/passkey": "1.6.0-beta.0"
|
|
83
79
|
},
|
|
84
80
|
"scripts": {
|
|
85
81
|
"build": "tsdown",
|
|
86
82
|
"dev": "tsx ./src/index.ts",
|
|
87
83
|
"start": "node ./dist/index.mjs",
|
|
88
|
-
"lint:package": "publint run --strict",
|
|
84
|
+
"lint:package": "publint run --strict --pack false",
|
|
89
85
|
"lint:types": "attw --profile esm-only --pack .",
|
|
90
86
|
"typecheck": "tsc --project tsconfig.json",
|
|
91
87
|
"test": "vitest",
|