auth 1.6.26 → 1.6.28

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 CHANGED
@@ -1,5 +1,6 @@
1
1
  import { DBAdapter, DBAdapter as DBAdapter$1 } from "@better-auth/core/db/adapter";
2
2
  import { BetterAuthOptions } from "@better-auth/core";
3
+
3
4
  //#region src/generators/types.d.ts
4
5
  interface SchemaGeneratorResult {
5
6
  code?: string;
package/dist/index.mjs CHANGED
@@ -1522,7 +1522,7 @@ function filterPublicEnv(publicPrefix, privatePrefix) {
1522
1522
  return Object.fromEntries(Object.entries(process.env).filter(([k]) => k.startsWith(publicPrefix) && (privatePrefix === "" || !k.startsWith(privatePrefix))));
1523
1523
  }
1524
1524
  const validIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
1525
- const reserved = /* @__PURE__ */ new Set([
1525
+ const reserved = new Set([
1526
1526
  "do",
1527
1527
  "if",
1528
1528
  "in",
@@ -1742,7 +1742,7 @@ function resolveWithMatchers(specifier, matchers) {
1742
1742
  * a jiti-side preprocessor artifact observed in the AST; revisit on jiti
1743
1743
  * major version bumps (the regression suite catches a rename but not the why).
1744
1744
  */
1745
- const LOADER_IDENTIFIERS = /* @__PURE__ */ new Set([
1745
+ const LOADER_IDENTIFIERS = new Set([
1746
1746
  "require",
1747
1747
  "import",
1748
1748
  "jitiImport"
@@ -2697,6 +2697,9 @@ function installDependencies({ dependencies, packageManager, cwd, type = "prod",
2697
2697
  });
2698
2698
  }
2699
2699
  //#endregion
2700
+ //#region src/version.ts
2701
+ const cliVersion = "1.6.28";
2702
+ //#endregion
2700
2703
  //#region src/commands/init/configs/frameworks.config.ts
2701
2704
  const FRAMEWORKS = [
2702
2705
  {
@@ -5164,12 +5167,11 @@ const getAuthPluginsCode = async ({ plugins, options = {}, installDependency })
5164
5167
  const getArguments = await getArgumentsPrompt(options, plugins, "auth");
5165
5168
  const pluginsCode = [];
5166
5169
  for (const plugin of plugins) {
5167
- const argumentsCode = await buildArgumentsCode(plugin.auth.arguments, getArguments, plugin.auth.function);
5168
- const args = convertArgumentsCodeToStringArray(argumentsCode);
5170
+ const args = convertArgumentsCodeToStringArray(await buildArgumentsCode(plugin.auth.arguments, getArguments, plugin.auth.function));
5169
5171
  removeTrailingUndefined(args);
5170
5172
  pluginsCode.push(`${plugin.auth.function}(${args.join(", ")})`);
5171
- const dependencies = /* @__PURE__ */ new Set([...plugin.dependencies || [], ...plugin.auth.dependencies || []]);
5172
- const devDependencies = /* @__PURE__ */ new Set([...plugin.devDependencies || [], ...plugin.auth.devDependencies || []]);
5173
+ const dependencies = new Set([...plugin.dependencies || [], ...plugin.auth.dependencies || []]);
5174
+ const devDependencies = new Set([...plugin.devDependencies || [], ...plugin.auth.devDependencies || []]);
5173
5175
  if (dependencies.size > 0) await installDependency([...dependencies]);
5174
5176
  if (devDependencies.size > 0) await installDependency([...devDependencies], "dev");
5175
5177
  }
@@ -5183,12 +5185,11 @@ const getAuthClientPluginsCode = async ({ plugins, options = {}, installDependen
5183
5185
  const pluginsCode = [];
5184
5186
  for (const plugin of pluginsWithClient) {
5185
5187
  if (!plugin.authClient) continue;
5186
- const argumentsCode = await buildArgumentsCode(plugin.authClient.arguments, getArguments, plugin.authClient.function);
5187
- const args = convertArgumentsCodeToStringArray(argumentsCode);
5188
+ const args = convertArgumentsCodeToStringArray(await buildArgumentsCode(plugin.authClient.arguments, getArguments, plugin.authClient.function));
5188
5189
  removeTrailingUndefined(args);
5189
5190
  pluginsCode.push(`${plugin.authClient.function}(${args.join(", ")})`);
5190
- const dependencies = /* @__PURE__ */ new Set([...plugin.dependencies || [], ...plugin.authClient.dependencies || []]);
5191
- const devDependencies = /* @__PURE__ */ new Set([...plugin.devDependencies || [], ...plugin.authClient.devDependencies || []]);
5191
+ const dependencies = new Set([...plugin.dependencies || [], ...plugin.authClient.dependencies || []]);
5192
+ const devDependencies = new Set([...plugin.devDependencies || [], ...plugin.authClient.devDependencies || []]);
5192
5193
  if (dependencies.size > 0) await installDependency([...dependencies]);
5193
5194
  if (devDependencies.size > 0) await installDependency([...devDependencies], "dev");
5194
5195
  }
@@ -6361,10 +6362,9 @@ export const auth = betterAuth({
6361
6362
  }
6362
6363
  databaseChoice = dbChoice || null;
6363
6364
  if (databaseChoice === "yes") {
6364
- const availableORMs = getAvailableORMs();
6365
6365
  const selectedOption = await select({
6366
6366
  message: `Select the database you want to use:`,
6367
- options: availableORMs.map((opt) => ({
6367
+ options: getAvailableORMs().map((opt) => ({
6368
6368
  value: opt.adapter || opt.value,
6369
6369
  label: opt.label
6370
6370
  }))
@@ -6398,10 +6398,9 @@ export const auth = betterAuth({
6398
6398
  database = sqliteVariants;
6399
6399
  } else if (isDirectAdapter(selectedOption)) database = selectedOption;
6400
6400
  else {
6401
- const availableDialects = getDialectsForORM(selectedOption);
6402
6401
  const selectedDialect = await select({
6403
6402
  message: `Select the database dialect:`,
6404
- options: availableDialects.map((d) => ({
6403
+ options: getDialectsForORM(selectedOption).map((d) => ({
6405
6404
  value: d.adapter,
6406
6405
  label: d.label
6407
6406
  }))
@@ -6419,7 +6418,7 @@ export const auth = betterAuth({
6419
6418
  const { shouldInstallDeps } = await prompts({
6420
6419
  type: "confirm",
6421
6420
  name: "shouldInstallDeps",
6422
- message: `Would you like to install the following dependencies: ${[.../* @__PURE__ */ new Set([...databaseConfig.dependencies, ...databaseConfig.devDependencies || []])].map((x) => chalk.cyan(x)).join(", ")}?`,
6421
+ message: `Would you like to install the following dependencies: ${[...new Set([...databaseConfig.dependencies, ...databaseConfig.devDependencies || []])].map((x) => chalk.cyan(x)).join(", ")}?`,
6423
6422
  initial: true
6424
6423
  });
6425
6424
  if (isCancel(shouldInstallDeps)) {
@@ -7202,22 +7201,11 @@ const generateSecret = new Command("secret").action(() => {
7202
7201
  ${chalk.gray("# Auth Secret") + chalk.green(`\nBETTER_AUTH_SECRET=${secret}`)}`);
7203
7202
  });
7204
7203
  //#endregion
7205
- //#region src/utils/fetch-latest-version.ts
7206
- async function fetchLatestVersion(packageName) {
7207
- const encoded = packageName.startsWith("@") ? `@${encodeURIComponent(packageName.slice(1))}` : encodeURIComponent(packageName);
7208
- try {
7209
- const response = await fetch(`https://registry.npmjs.org/${encoded}/latest`);
7210
- if (!response.ok) return null;
7211
- return (await response.json()).version ?? null;
7212
- } catch {
7213
- return null;
7214
- }
7215
- }
7216
- //#endregion
7217
7204
  //#region src/commands/upgrade.ts
7218
7205
  function isBetterAuthPackage(name) {
7219
7206
  return name === "better-auth" || name.startsWith("@better-auth/");
7220
7207
  }
7208
+ /** @internal */
7221
7209
  async function upgradeAction(opts) {
7222
7210
  const options = z.object({
7223
7211
  cwd: z.string(),
@@ -7253,22 +7241,13 @@ async function upgradeAction(opts) {
7253
7241
  return;
7254
7242
  }
7255
7243
  const spinner = yoctoSpinner({ text: "checking for updates..." }).start();
7256
- const results = await Promise.allSettled(candidates.map(async (c) => {
7257
- const latest = await fetchLatestVersion(c.name);
7258
- return {
7259
- ...c,
7260
- latest
7261
- };
7262
- }));
7263
7244
  const upgrades = [];
7264
- for (const result of results) {
7265
- if (result.status !== "fulfilled" || !result.value.latest) continue;
7266
- const { name, current, latest, depType } = result.value;
7267
- const coerced = semver.coerce(current);
7268
- if (coerced && semver.lt(coerced, latest)) upgrades.push({
7245
+ for (const { name, current, depType } of candidates) {
7246
+ const currentVersion = semver.minVersion(current);
7247
+ if (currentVersion && semver.lt(currentVersion, cliVersion)) upgrades.push({
7269
7248
  name,
7270
7249
  current,
7271
- latest,
7250
+ target: cliVersion,
7272
7251
  depType
7273
7252
  });
7274
7253
  }
@@ -7278,7 +7257,7 @@ async function upgradeAction(opts) {
7278
7257
  return;
7279
7258
  }
7280
7259
  console.log(`\nThe following packages can be upgraded:\n`);
7281
- for (const u of upgrades) console.log(` ${chalk.cyan(u.name)} ${chalk.gray(u.current)} ${chalk.white("→")} ${chalk.green(u.latest)}`);
7260
+ for (const u of upgrades) console.log(` ${chalk.cyan(u.name)} ${chalk.gray(u.current)} ${chalk.white("→")} ${chalk.green(u.target)}`);
7282
7261
  console.log();
7283
7262
  let confirmed = options.yes;
7284
7263
  if (!confirmed) confirmed = (await prompts({
@@ -7292,8 +7271,8 @@ async function upgradeAction(opts) {
7292
7271
  return;
7293
7272
  }
7294
7273
  const { packageManager } = await detectPackageManager(cwd, packageJson);
7295
- const prodUpgrades = upgrades.filter((u) => u.depType === "prod").map((u) => `${u.name}@${u.latest}`);
7296
- const devUpgrades = upgrades.filter((u) => u.depType === "dev").map((u) => `${u.name}@${u.latest}`);
7274
+ const prodUpgrades = upgrades.filter((u) => u.depType === "prod").map((u) => `${u.name}@${u.target}`);
7275
+ const devUpgrades = upgrades.filter((u) => u.depType === "dev").map((u) => `${u.name}@${u.target}`);
7297
7276
  const installSpinner = yoctoSpinner({ text: "installing updates..." }).start();
7298
7277
  try {
7299
7278
  if (prodUpgrades.length > 0) await installDependencies({
@@ -7316,19 +7295,13 @@ async function upgradeAction(opts) {
7316
7295
  process.exit(1);
7317
7296
  }
7318
7297
  }
7319
- 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);
7298
+ const upgrade = new Command("upgrade").description("Upgrade better-auth packages to the running CLI version").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);
7320
7299
  //#endregion
7321
7300
  //#region src/index.ts
7322
7301
  process.on("SIGINT", () => process.exit(0));
7323
7302
  process.on("SIGTERM", () => process.exit(0));
7324
- let cliVersion = "1.1.2";
7325
7303
  async function main() {
7326
7304
  const program = new Command("better-auth");
7327
- let packageInfo = {};
7328
- try {
7329
- packageInfo = await getPackageInfo();
7330
- cliVersion = packageInfo.version || "1.1.2";
7331
- } catch {}
7332
7305
  program.addCommand(ai).addCommand(init).addCommand(migrate).addCommand(generate).addCommand(generateSecret).addCommand(info).addCommand(login).addCommand(logout).addCommand(mcp).addCommand(upgrade).version(cliVersion).description("Better Auth CLI").action(() => program.help());
7333
7306
  program.parse();
7334
7307
  }
@@ -7337,4 +7310,4 @@ main().catch((error) => {
7337
7310
  process.exit(1);
7338
7311
  });
7339
7312
  //#endregion
7340
- export { cliVersion };
7313
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auth",
3
- "version": "1.6.26",
3
+ "version": "1.6.28",
4
4
  "description": "The CLI for Better Auth",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -60,9 +60,9 @@
60
60
  "semver": "^7.7.4",
61
61
  "yocto-spinner": "^0.2.3",
62
62
  "zod": "^4.3.6",
63
- "@better-auth/core": "1.6.26",
64
- "@better-auth/telemetry": "1.6.26",
65
- "better-auth": "1.6.26"
63
+ "@better-auth/core": "1.6.28",
64
+ "@better-auth/telemetry": "1.6.28",
65
+ "better-auth": "1.6.28"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@types/better-sqlite3": "^7.6.13",
@@ -71,11 +71,11 @@
71
71
  "better-sqlite3": "^12.6.2",
72
72
  "jiti": "^2.6.1",
73
73
  "memfs": "^4.56.10",
74
- "tsdown": "0.22.7",
74
+ "tsdown": "0.21.10",
75
75
  "tsx": "^4.21.0",
76
76
  "type-fest": "^5.4.4",
77
77
  "typescript": "^6.0.3",
78
- "@better-auth/passkey": "1.6.26"
78
+ "@better-auth/passkey": "1.6.28"
79
79
  },
80
80
  "scripts": {
81
81
  "build": "tsdown",
package/dist/index.d.mts DELETED
@@ -1,5 +0,0 @@
1
- import "dotenv/config";
2
- //#region src/index.d.ts
3
- declare let cliVersion: string;
4
- //#endregion
5
- export { cliVersion };