auth 1.5.5 → 1.5.7-beta.1
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.mjs +4 -9
- package/dist/api.mjs.map +1 -1
- package/dist/index.mjs +647 -140
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -1,39 +1,582 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from "commander";
|
|
3
|
+
import { exec, execSync, spawn } from "node:child_process";
|
|
3
4
|
import * as fs$2 from "node:fs";
|
|
4
5
|
import fs, { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
5
|
-
import
|
|
6
|
+
import * as os$1 from "node:os";
|
|
7
|
+
import os from "node:os";
|
|
6
8
|
import * as path$1 from "node:path";
|
|
7
9
|
import path, { join } from "node:path";
|
|
8
|
-
import { createTelemetry, getTelemetryAuthConfig } from "@better-auth/telemetry";
|
|
9
|
-
import { getAdapter } from "better-auth/db/adapter";
|
|
10
10
|
import chalk from "chalk";
|
|
11
11
|
import prompts from "prompts";
|
|
12
12
|
import yoctoSpinner from "yocto-spinner";
|
|
13
|
-
import
|
|
13
|
+
import fs$1 from "node:fs/promises";
|
|
14
|
+
import { createTelemetry, getTelemetryAuthConfig } from "@better-auth/telemetry";
|
|
15
|
+
import { getAdapter } from "better-auth/db/adapter";
|
|
16
|
+
import * as z from "zod";
|
|
14
17
|
import { initGetFieldName, initGetModelName } from "better-auth/adapters";
|
|
15
18
|
import { getAuthTables } from "better-auth/db";
|
|
16
19
|
import prettier, { format } from "prettier";
|
|
17
20
|
import { getMigrations } from "better-auth/db/migration";
|
|
18
21
|
import { capitalizeFirstLetter } from "@better-auth/core/utils/string";
|
|
19
22
|
import { produceSchema } from "@mrleebo/prisma-ast";
|
|
20
|
-
import { exec, execSync, spawn } from "node:child_process";
|
|
21
23
|
import Crypto from "node:crypto";
|
|
22
24
|
import babelPresetReact from "@babel/preset-react";
|
|
23
25
|
import babelPresetTypeScript from "@babel/preset-typescript";
|
|
24
26
|
import { BetterAuthError } from "@better-auth/core/error";
|
|
25
27
|
import { loadConfig } from "c12";
|
|
26
28
|
import { getTsconfig, parseTsconfig } from "get-tsconfig";
|
|
27
|
-
import * as os$1 from "node:os";
|
|
28
|
-
import os from "node:os";
|
|
29
29
|
import open from "open";
|
|
30
|
-
import z from "zod";
|
|
31
30
|
import { env } from "@better-auth/core/env";
|
|
32
31
|
import { log } from "@clack/prompts";
|
|
33
32
|
import { base64 } from "@better-auth/utils/base64";
|
|
34
33
|
import * as semver from "semver";
|
|
35
34
|
import "dotenv/config";
|
|
35
|
+
//#region src/commands/ai.ts
|
|
36
|
+
const PROTOCOL_URL = "https://agent-auth-protocol.com";
|
|
37
|
+
const AGENT_CLI_PKG = "@auth/agent-cli";
|
|
38
|
+
const AGENT_PLUGIN_PKG = "@better-auth/agent-auth";
|
|
39
|
+
const DEFAULT_REGISTRY = "https://agent-auth.directory";
|
|
40
|
+
const SKILLS_REPO = "better-auth/agent-auth";
|
|
41
|
+
function cancelled() {
|
|
42
|
+
console.log(chalk.yellow("\n✋ Setup cancelled."));
|
|
43
|
+
process.exit(0);
|
|
44
|
+
}
|
|
45
|
+
function check(value) {
|
|
46
|
+
if (value === void 0 || value === null) cancelled();
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
async function aiAction() {
|
|
50
|
+
console.log("\n" + [
|
|
51
|
+
` ██ ████`,
|
|
52
|
+
` ████ ██ ${chalk.bold("Agent Auth")} ${chalk.dim("Setup")}`,
|
|
53
|
+
` ██ ████ ${chalk.gray("AI agent authentication & capability-based authorization.")}`
|
|
54
|
+
].join("\n"));
|
|
55
|
+
console.log();
|
|
56
|
+
const { setup } = await prompts({
|
|
57
|
+
type: "select",
|
|
58
|
+
name: "setup",
|
|
59
|
+
message: "What would you like to do?",
|
|
60
|
+
choices: [{
|
|
61
|
+
title: "Integrate Agent Auth client",
|
|
62
|
+
value: "client",
|
|
63
|
+
description: "MCP server, CLI, or SDK for your agents"
|
|
64
|
+
}, {
|
|
65
|
+
title: "Create an Agent Auth server",
|
|
66
|
+
value: "server",
|
|
67
|
+
description: "expose capabilities from your service to AI agents"
|
|
68
|
+
}]
|
|
69
|
+
});
|
|
70
|
+
check(setup);
|
|
71
|
+
if (setup === "client") await setupClient();
|
|
72
|
+
else await setupServerSelection();
|
|
73
|
+
}
|
|
74
|
+
async function setupClient() {
|
|
75
|
+
const { method } = await prompts({
|
|
76
|
+
type: "select",
|
|
77
|
+
name: "method",
|
|
78
|
+
message: "How do you want to integrate?",
|
|
79
|
+
choices: [{
|
|
80
|
+
title: "MCP Server",
|
|
81
|
+
value: "mcp",
|
|
82
|
+
description: "for AI tools — Claude, Cursor, Windsurf, etc."
|
|
83
|
+
}, {
|
|
84
|
+
title: "CLI",
|
|
85
|
+
value: "cli",
|
|
86
|
+
description: "command-line tool for agent workflows"
|
|
87
|
+
}]
|
|
88
|
+
});
|
|
89
|
+
check(method);
|
|
90
|
+
if (method === "mcp") await setupMcp();
|
|
91
|
+
else await setupCli();
|
|
92
|
+
}
|
|
93
|
+
async function setupServerSelection() {
|
|
94
|
+
const { implementation } = await prompts({
|
|
95
|
+
type: "select",
|
|
96
|
+
name: "implementation",
|
|
97
|
+
message: "Choose an implementation",
|
|
98
|
+
choices: [{
|
|
99
|
+
title: "Better Auth + Agent Auth",
|
|
100
|
+
value: "better-auth",
|
|
101
|
+
description: "TypeScript"
|
|
102
|
+
}]
|
|
103
|
+
});
|
|
104
|
+
check(implementation);
|
|
105
|
+
await setupServer();
|
|
106
|
+
}
|
|
107
|
+
async function setupMcp() {
|
|
108
|
+
const { tool } = await prompts({
|
|
109
|
+
type: "select",
|
|
110
|
+
name: "tool",
|
|
111
|
+
message: "Which AI tool?",
|
|
112
|
+
choices: [
|
|
113
|
+
{
|
|
114
|
+
title: "Cursor",
|
|
115
|
+
value: "cursor"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
title: "Claude Code",
|
|
119
|
+
value: "claude-code"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
title: "Claude Desktop",
|
|
123
|
+
value: "claude-desktop"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
title: "Windsurf",
|
|
127
|
+
value: "windsurf"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
title: "VS Code / Copilot",
|
|
131
|
+
value: "vscode"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
title: "Open Code",
|
|
135
|
+
value: "opencode"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
title: "Other",
|
|
139
|
+
value: "other"
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
});
|
|
143
|
+
check(tool);
|
|
144
|
+
let scope = "global";
|
|
145
|
+
if (tool === "cursor" || tool === "vscode") {
|
|
146
|
+
const { s } = await prompts({
|
|
147
|
+
type: "select",
|
|
148
|
+
name: "s",
|
|
149
|
+
message: "Where should it be configured?",
|
|
150
|
+
choices: [{
|
|
151
|
+
title: "This project",
|
|
152
|
+
value: "project",
|
|
153
|
+
description: tool === "cursor" ? ".cursor/mcp.json" : ".vscode/mcp.json"
|
|
154
|
+
}, {
|
|
155
|
+
title: "Global (all projects)",
|
|
156
|
+
value: "global",
|
|
157
|
+
description: tool === "cursor" ? "~/.cursor/mcp.json" : "user settings"
|
|
158
|
+
}]
|
|
159
|
+
});
|
|
160
|
+
check(s);
|
|
161
|
+
scope = s;
|
|
162
|
+
}
|
|
163
|
+
const { registryUrl } = await prompts({
|
|
164
|
+
type: "text",
|
|
165
|
+
name: "registryUrl",
|
|
166
|
+
message: "Registry URL",
|
|
167
|
+
initial: DEFAULT_REGISTRY
|
|
168
|
+
});
|
|
169
|
+
const mcpArgs = buildMcpArgs(registryUrl?.trim() || DEFAULT_REGISTRY);
|
|
170
|
+
if (tool === "claude-code") await setupClaudeCode(mcpArgs);
|
|
171
|
+
else if (tool === "opencode") await setupOpenCode(mcpArgs);
|
|
172
|
+
else if (tool === "other") showJsonConfig({
|
|
173
|
+
command: "npx",
|
|
174
|
+
args: mcpArgs
|
|
175
|
+
});
|
|
176
|
+
else await writeMcpConfigInteractive(tool, scope, mcpArgs);
|
|
177
|
+
await offerSkillInstall("agent-auth-mcp");
|
|
178
|
+
showNextSteps([`${chalk.cyan("Docs")} ${PROTOCOL_URL}/docs/integrate-client`, `${chalk.cyan("GitHub")} https://github.com/better-auth/agent-auth`]);
|
|
179
|
+
console.log(chalk.green("\n✔ ") + chalk.bold("Done! ") + "Restart your AI tool to connect.\n");
|
|
180
|
+
}
|
|
181
|
+
async function setupClaudeCode(args) {
|
|
182
|
+
const { scope } = await prompts({
|
|
183
|
+
type: "select",
|
|
184
|
+
name: "scope",
|
|
185
|
+
message: "Where should it be configured?",
|
|
186
|
+
choices: [{
|
|
187
|
+
title: "This project",
|
|
188
|
+
value: "project",
|
|
189
|
+
description: "--scope project"
|
|
190
|
+
}, {
|
|
191
|
+
title: "Global (all projects)",
|
|
192
|
+
value: "user",
|
|
193
|
+
description: "--scope user"
|
|
194
|
+
}]
|
|
195
|
+
});
|
|
196
|
+
check(scope);
|
|
197
|
+
const cmd = [
|
|
198
|
+
"claude",
|
|
199
|
+
"mcp",
|
|
200
|
+
"add",
|
|
201
|
+
"agent-auth",
|
|
202
|
+
"--scope",
|
|
203
|
+
scope,
|
|
204
|
+
"--",
|
|
205
|
+
"npx",
|
|
206
|
+
...args
|
|
207
|
+
].join(" ");
|
|
208
|
+
console.log(chalk.bold.white("\nRun this command:"));
|
|
209
|
+
console.log(chalk.cyan(` ${cmd}\n`));
|
|
210
|
+
const { run } = await prompts({
|
|
211
|
+
type: "confirm",
|
|
212
|
+
name: "run",
|
|
213
|
+
message: "Run it now?",
|
|
214
|
+
initial: true
|
|
215
|
+
});
|
|
216
|
+
if (run) {
|
|
217
|
+
const s = yoctoSpinner({
|
|
218
|
+
text: "Adding MCP server to Claude Code…",
|
|
219
|
+
color: "white"
|
|
220
|
+
});
|
|
221
|
+
s.start();
|
|
222
|
+
try {
|
|
223
|
+
execSync(cmd, { stdio: "pipe" });
|
|
224
|
+
s.success("Added to Claude Code.");
|
|
225
|
+
} catch {
|
|
226
|
+
s.stop();
|
|
227
|
+
console.log(chalk.yellow("⚠ Could not run the command automatically."));
|
|
228
|
+
console.log(chalk.gray(" Run the command above manually."));
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
async function setupOpenCode(args) {
|
|
233
|
+
const configPath = path$1.join(process.cwd(), "opencode.json");
|
|
234
|
+
const display = "opencode.json";
|
|
235
|
+
const openCodeEntry = {
|
|
236
|
+
type: "stdio",
|
|
237
|
+
command: "npx",
|
|
238
|
+
args,
|
|
239
|
+
enabled: true
|
|
240
|
+
};
|
|
241
|
+
const { write } = await prompts({
|
|
242
|
+
type: "confirm",
|
|
243
|
+
name: "write",
|
|
244
|
+
message: `Write config to ${chalk.cyan(display)}?`,
|
|
245
|
+
initial: true
|
|
246
|
+
});
|
|
247
|
+
if (write) {
|
|
248
|
+
writeOpenCodeConfig(configPath, openCodeEntry);
|
|
249
|
+
console.log(chalk.green(`\n✓ Written to ${display}`));
|
|
250
|
+
} else {
|
|
251
|
+
const json = JSON.stringify({
|
|
252
|
+
$schema: "https://opencode.ai/config.json",
|
|
253
|
+
mcp: { "agent-auth": openCodeEntry }
|
|
254
|
+
}, null, 2);
|
|
255
|
+
console.log(chalk.bold.white("\nAdd to your opencode.json:\n"));
|
|
256
|
+
console.log(json.split("\n").map((line) => chalk.cyan(` ${line}`)).join("\n"));
|
|
257
|
+
console.log();
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
function writeOpenCodeConfig(configPath, entry) {
|
|
261
|
+
let config = {};
|
|
262
|
+
if (fs$2.existsSync(configPath)) try {
|
|
263
|
+
config = JSON.parse(fs$2.readFileSync(configPath, "utf-8"));
|
|
264
|
+
} catch {}
|
|
265
|
+
const mcp = config.mcp ?? {};
|
|
266
|
+
mcp["agent-auth"] = entry;
|
|
267
|
+
config.$schema = "https://opencode.ai/config.json";
|
|
268
|
+
config.mcp = mcp;
|
|
269
|
+
fs$2.writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n");
|
|
270
|
+
}
|
|
271
|
+
async function writeMcpConfigInteractive(tool, scope, args) {
|
|
272
|
+
const entry = {
|
|
273
|
+
command: "npx",
|
|
274
|
+
args
|
|
275
|
+
};
|
|
276
|
+
const configPath = getMcpConfigPath(tool, scope);
|
|
277
|
+
if (!configPath) {
|
|
278
|
+
showJsonConfig(entry);
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
const display = displayPath(configPath, scope);
|
|
282
|
+
const { write } = await prompts({
|
|
283
|
+
type: "confirm",
|
|
284
|
+
name: "write",
|
|
285
|
+
message: `Write config to ${chalk.cyan(display)}?`,
|
|
286
|
+
initial: true
|
|
287
|
+
});
|
|
288
|
+
if (write) {
|
|
289
|
+
writeMcpConfig(configPath, entry);
|
|
290
|
+
console.log(chalk.green(`\n✓ Written to ${display}`));
|
|
291
|
+
} else showJsonConfig(entry);
|
|
292
|
+
}
|
|
293
|
+
async function setupCli() {
|
|
294
|
+
const { installCli } = await prompts({
|
|
295
|
+
type: "confirm",
|
|
296
|
+
name: "installCli",
|
|
297
|
+
message: `Install ${chalk.cyan(AGENT_CLI_PKG)} globally?`,
|
|
298
|
+
initial: true
|
|
299
|
+
});
|
|
300
|
+
if (installCli) {
|
|
301
|
+
const s = yoctoSpinner({
|
|
302
|
+
text: `Installing ${AGENT_CLI_PKG}…`,
|
|
303
|
+
color: "white"
|
|
304
|
+
});
|
|
305
|
+
s.start();
|
|
306
|
+
try {
|
|
307
|
+
execSync(`npm install -g ${AGENT_CLI_PKG}`, { stdio: "pipe" });
|
|
308
|
+
s.success(`${AGENT_CLI_PKG} installed globally.`);
|
|
309
|
+
} catch {
|
|
310
|
+
s.stop();
|
|
311
|
+
console.log(chalk.yellow("⚠ Could not install automatically. Run manually:"));
|
|
312
|
+
console.log(chalk.cyan(` npm install -g ${AGENT_CLI_PKG}\n`));
|
|
313
|
+
}
|
|
314
|
+
} else console.log(chalk.dim(`\n To install later: npm install -g ${AGENT_CLI_PKG}\n`));
|
|
315
|
+
await offerSkillInstall("agent-auth-cli");
|
|
316
|
+
console.log(chalk.bold.white("\nUsage:"));
|
|
317
|
+
console.log(chalk.gray(" # Discover a provider"));
|
|
318
|
+
console.log(chalk.cyan(" auth-agent discover https://api.example.com"));
|
|
319
|
+
console.log(chalk.gray("\n # Search the registry for providers"));
|
|
320
|
+
console.log(chalk.cyan(` auth-agent search "send email"`));
|
|
321
|
+
console.log(chalk.gray("\n # Connect an agent with capabilities"));
|
|
322
|
+
console.log(chalk.cyan(" auth-agent connect --provider <url> --capabilities <cap1> <cap2>"));
|
|
323
|
+
console.log(chalk.gray("\n # Execute a capability"));
|
|
324
|
+
console.log(chalk.cyan(` auth-agent execute <agent-id> <capability> --args '{"key":"value"}'`));
|
|
325
|
+
console.log(chalk.gray("\n # Run as MCP server"));
|
|
326
|
+
console.log(chalk.cyan(` auth-agent mcp`));
|
|
327
|
+
showNextSteps([`${chalk.cyan("Docs")} ${PROTOCOL_URL}/docs/integrate-client`, `${chalk.cyan("GitHub")} https://github.com/better-auth/agent-auth`]);
|
|
328
|
+
console.log(chalk.green("\n✔ ") + chalk.bold("Ready. ") + "Run auth-agent --help to see all commands.\n");
|
|
329
|
+
}
|
|
330
|
+
async function setupServer() {
|
|
331
|
+
const { source } = await prompts({
|
|
332
|
+
type: "select",
|
|
333
|
+
name: "source",
|
|
334
|
+
message: "How do you want to define capabilities?",
|
|
335
|
+
choices: [
|
|
336
|
+
{
|
|
337
|
+
title: "Default",
|
|
338
|
+
value: "manual",
|
|
339
|
+
description: "define capabilities in code"
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
title: "From an OpenAPI spec",
|
|
343
|
+
value: "openapi",
|
|
344
|
+
description: "derive capabilities from an OpenAPI document"
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
title: "From an MCP server",
|
|
348
|
+
value: "mcp",
|
|
349
|
+
description: "proxy an existing MCP server's tools"
|
|
350
|
+
}
|
|
351
|
+
]
|
|
352
|
+
});
|
|
353
|
+
check(source);
|
|
354
|
+
const { name } = await prompts({
|
|
355
|
+
type: "text",
|
|
356
|
+
name: "name",
|
|
357
|
+
message: "What's your service called?",
|
|
358
|
+
validate: (v) => v?.trim() ? true : "Name is required."
|
|
359
|
+
});
|
|
360
|
+
check(name);
|
|
361
|
+
const { description } = await prompts({
|
|
362
|
+
type: "text",
|
|
363
|
+
name: "description",
|
|
364
|
+
message: `Short description ${chalk.dim("(press Enter to skip)")}`
|
|
365
|
+
});
|
|
366
|
+
const desc = description?.trim() || void 0;
|
|
367
|
+
let sourceUrl;
|
|
368
|
+
if (source === "openapi") {
|
|
369
|
+
const { url } = await prompts({
|
|
370
|
+
type: "text",
|
|
371
|
+
name: "url",
|
|
372
|
+
message: `OpenAPI spec URL ${chalk.dim("(e.g. https://api.example.com/openapi.json)")}`,
|
|
373
|
+
validate: (v) => v?.trim() ? true : "URL is required."
|
|
374
|
+
});
|
|
375
|
+
check(url);
|
|
376
|
+
sourceUrl = url.trim();
|
|
377
|
+
} else if (source === "mcp") {
|
|
378
|
+
const { url } = await prompts({
|
|
379
|
+
type: "text",
|
|
380
|
+
name: "url",
|
|
381
|
+
message: `MCP server URL ${chalk.dim("(e.g. https://api.example.com/mcp)")}`,
|
|
382
|
+
validate: (v) => v?.trim() ? true : "URL is required."
|
|
383
|
+
});
|
|
384
|
+
check(url);
|
|
385
|
+
sourceUrl = url.trim();
|
|
386
|
+
}
|
|
387
|
+
const code = generateServerCode(name.trim(), desc, source, sourceUrl);
|
|
388
|
+
const { write } = await prompts({
|
|
389
|
+
type: "confirm",
|
|
390
|
+
name: "write",
|
|
391
|
+
message: "Generate an auth config file?",
|
|
392
|
+
initial: true
|
|
393
|
+
});
|
|
394
|
+
if (write) {
|
|
395
|
+
const { filePath } = await prompts({
|
|
396
|
+
type: "text",
|
|
397
|
+
name: "filePath",
|
|
398
|
+
message: "File path",
|
|
399
|
+
initial: "lib/auth.ts"
|
|
400
|
+
});
|
|
401
|
+
const target = filePath?.trim() || "lib/auth.ts";
|
|
402
|
+
if (fs$2.existsSync(target)) {
|
|
403
|
+
const { overwrite } = await prompts({
|
|
404
|
+
type: "confirm",
|
|
405
|
+
name: "overwrite",
|
|
406
|
+
message: `${chalk.yellow(target)} already exists. Overwrite?`,
|
|
407
|
+
initial: false
|
|
408
|
+
});
|
|
409
|
+
if (!overwrite) {
|
|
410
|
+
showCodeBlock(code, "auth config");
|
|
411
|
+
showServerOutro();
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
const dir = path$1.dirname(target);
|
|
416
|
+
if (dir && dir !== "." && !fs$2.existsSync(dir)) fs$2.mkdirSync(dir, { recursive: true });
|
|
417
|
+
fs$2.writeFileSync(target, code);
|
|
418
|
+
console.log(chalk.green(`\n✓ Created ${target}`));
|
|
419
|
+
} else showCodeBlock(code, "auth config");
|
|
420
|
+
showServerOutro();
|
|
421
|
+
}
|
|
422
|
+
function generateServerCode(name, description, source, sourceUrl) {
|
|
423
|
+
const descLine = description ? `\n\t\t\tproviderDescription: ${JSON.stringify(description)},` : "";
|
|
424
|
+
if (source === "openapi" && sourceUrl) return `import { betterAuth } from "better-auth";
|
|
425
|
+
import { agentAuth } from "${AGENT_PLUGIN_PKG}";
|
|
426
|
+
import { createFromOpenAPI } from "${AGENT_PLUGIN_PKG}/openapi";
|
|
427
|
+
|
|
428
|
+
const spec = await fetch(${JSON.stringify(sourceUrl)}).then(r => r.json());
|
|
429
|
+
|
|
430
|
+
const openapi = createFromOpenAPI(spec, {
|
|
431
|
+
\tbaseUrl: ${JSON.stringify(sourceUrl.replace(/\/openapi\.json$|\/openapi\.yaml$|\/swagger\.json$|\/docs\/openapi$/, ""))},
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
export const auth = betterAuth({
|
|
435
|
+
\tplugins: [
|
|
436
|
+
\t\tagentAuth({
|
|
437
|
+
\t\t\tproviderName: ${JSON.stringify(name)},${descLine}
|
|
438
|
+
\t\t\t...openapi,
|
|
439
|
+
\t\t}),
|
|
440
|
+
\t],
|
|
441
|
+
});
|
|
442
|
+
`;
|
|
443
|
+
if (source === "mcp" && sourceUrl) return `import { betterAuth } from "better-auth";
|
|
444
|
+
import { agentAuth } from "${AGENT_PLUGIN_PKG}";
|
|
445
|
+
|
|
446
|
+
export const auth = betterAuth({
|
|
447
|
+
\tplugins: [
|
|
448
|
+
\t\tagentAuth({
|
|
449
|
+
\t\t\tproviderName: ${JSON.stringify(name)},${descLine}
|
|
450
|
+
\t\t\tmcpServer: ${JSON.stringify(sourceUrl)},
|
|
451
|
+
\t\t}),
|
|
452
|
+
\t],
|
|
453
|
+
});
|
|
454
|
+
`;
|
|
455
|
+
return `import { betterAuth } from "better-auth";
|
|
456
|
+
import { agentAuth } from "${AGENT_PLUGIN_PKG}";
|
|
36
457
|
|
|
458
|
+
export const auth = betterAuth({
|
|
459
|
+
\tplugins: [
|
|
460
|
+
\t\tagentAuth({
|
|
461
|
+
\t\t\tproviderName: ${JSON.stringify(name)},${descLine}
|
|
462
|
+
\t\t\tcapabilities: [
|
|
463
|
+
\t\t\t\t{
|
|
464
|
+
\t\t\t\t\tname: "example",
|
|
465
|
+
\t\t\t\t\tdescription: "An example capability — replace with your own",
|
|
466
|
+
\t\t\t\t\tinput: {
|
|
467
|
+
\t\t\t\t\t\ttype: "object",
|
|
468
|
+
\t\t\t\t\t\tproperties: {
|
|
469
|
+
\t\t\t\t\t\t\tmessage: { type: "string", description: "Input message" },
|
|
470
|
+
\t\t\t\t\t\t},
|
|
471
|
+
\t\t\t\t\t},
|
|
472
|
+
\t\t\t\t},
|
|
473
|
+
\t\t\t],
|
|
474
|
+
\t\t\tasync onExecute({ capability, arguments: args }) {
|
|
475
|
+
\t\t\t\tswitch (capability) {
|
|
476
|
+
\t\t\t\t\tcase "example":
|
|
477
|
+
\t\t\t\t\t\treturn { message: \`Hello from \${(args as Record<string, string>).message}\` };
|
|
478
|
+
\t\t\t\t\tdefault:
|
|
479
|
+
\t\t\t\t\t\tthrow new Error(\`Unknown capability: \${capability}\`);
|
|
480
|
+
\t\t\t\t}
|
|
481
|
+
\t\t\t},
|
|
482
|
+
\t\t}),
|
|
483
|
+
\t],
|
|
484
|
+
});
|
|
485
|
+
`;
|
|
486
|
+
}
|
|
487
|
+
function showServerOutro() {
|
|
488
|
+
console.log(chalk.bold.white("\nNext steps:\n"));
|
|
489
|
+
console.log(chalk.white(" 1. Install dependencies:"));
|
|
490
|
+
console.log(chalk.cyan(` npm install better-auth ${AGENT_PLUGIN_PKG}\n`));
|
|
491
|
+
console.log(chalk.white(" 2. Configure your database:"));
|
|
492
|
+
console.log(chalk.gray(" Better Auth needs a database to store agents, hosts, and grants."));
|
|
493
|
+
console.log(chalk.cyan(" https://www.better-auth.com/docs/concepts/database\n"));
|
|
494
|
+
console.log(chalk.white(" 3. Run database migrations:"));
|
|
495
|
+
console.log(chalk.cyan(" npx auth migrate\n"));
|
|
496
|
+
console.log(chalk.white(" 4. Expose the discovery endpoint at your app root:"));
|
|
497
|
+
console.log(chalk.gray(" GET /.well-known/agent-configuration"));
|
|
498
|
+
console.log(chalk.gray(" → return auth.api.getAgentConfiguration({ headers })\n"));
|
|
499
|
+
console.log(` ${chalk.cyan("Docs")} ${PROTOCOL_URL}/docs/build-server`);
|
|
500
|
+
console.log(` ${chalk.cyan("GitHub")} https://github.com/better-auth/agent-auth`);
|
|
501
|
+
console.log(chalk.green("\n✔ ") + chalk.bold("Server scaffolded. ") + "Follow the steps above to finish setup.\n");
|
|
502
|
+
}
|
|
503
|
+
async function offerSkillInstall(skillName) {
|
|
504
|
+
const { installSkill } = await prompts({
|
|
505
|
+
type: "confirm",
|
|
506
|
+
name: "installSkill",
|
|
507
|
+
message: `Install the ${chalk.cyan(skillName)} skill for your coding agents?`,
|
|
508
|
+
initial: true
|
|
509
|
+
});
|
|
510
|
+
if (!installSkill) return;
|
|
511
|
+
const cmd = `npx -y skills add ${SKILLS_REPO} --skill ${skillName}`;
|
|
512
|
+
const s = yoctoSpinner({
|
|
513
|
+
text: `Installing ${skillName} skill…`,
|
|
514
|
+
color: "white"
|
|
515
|
+
});
|
|
516
|
+
s.start();
|
|
517
|
+
try {
|
|
518
|
+
execSync(cmd, { stdio: "pipe" });
|
|
519
|
+
s.success(`${skillName} skill installed.`);
|
|
520
|
+
} catch {
|
|
521
|
+
s.stop();
|
|
522
|
+
console.log(chalk.yellow("⚠ Could not install automatically. Run manually:"));
|
|
523
|
+
console.log(chalk.cyan(` ${cmd}\n`));
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
function buildMcpArgs(registry) {
|
|
527
|
+
const args = [
|
|
528
|
+
"-y",
|
|
529
|
+
AGENT_CLI_PKG,
|
|
530
|
+
"mcp"
|
|
531
|
+
];
|
|
532
|
+
if (registry && registry !== DEFAULT_REGISTRY) args.push("--registry-url", registry);
|
|
533
|
+
return args;
|
|
534
|
+
}
|
|
535
|
+
function getMcpConfigPath(tool, scope) {
|
|
536
|
+
const home = os$1.homedir();
|
|
537
|
+
switch (tool) {
|
|
538
|
+
case "cursor": return scope === "global" ? path$1.join(home, ".cursor", "mcp.json") : path$1.join(process.cwd(), ".cursor", "mcp.json");
|
|
539
|
+
case "claude-desktop":
|
|
540
|
+
if (process.platform === "win32") return path$1.join(process.env.APPDATA || home, "Claude", "claude_desktop_config.json");
|
|
541
|
+
if (process.platform === "darwin") return path$1.join(home, "Library", "Application Support", "Claude", "claude_desktop_config.json");
|
|
542
|
+
return path$1.join(home, ".config", "Claude", "claude_desktop_config.json");
|
|
543
|
+
case "windsurf": return path$1.join(home, ".codeium", "windsurf", "mcp_config.json");
|
|
544
|
+
case "vscode": return scope === "global" ? null : path$1.join(process.cwd(), ".vscode", "mcp.json");
|
|
545
|
+
default: return null;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
function writeMcpConfig(configPath, entry) {
|
|
549
|
+
let config = {};
|
|
550
|
+
if (fs$2.existsSync(configPath)) try {
|
|
551
|
+
config = JSON.parse(fs$2.readFileSync(configPath, "utf-8"));
|
|
552
|
+
} catch {}
|
|
553
|
+
const servers = config.mcpServers ?? {};
|
|
554
|
+
servers["agent-auth"] = entry;
|
|
555
|
+
config.mcpServers = servers;
|
|
556
|
+
const dir = path$1.dirname(configPath);
|
|
557
|
+
if (!fs$2.existsSync(dir)) fs$2.mkdirSync(dir, { recursive: true });
|
|
558
|
+
fs$2.writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n");
|
|
559
|
+
}
|
|
560
|
+
function displayPath(filePath, scope) {
|
|
561
|
+
if (scope === "project") return path$1.relative(process.cwd(), filePath) || filePath;
|
|
562
|
+
return filePath.replace(os$1.homedir(), "~");
|
|
563
|
+
}
|
|
564
|
+
function showJsonConfig(entry) {
|
|
565
|
+
const json = JSON.stringify({ mcpServers: { "agent-auth": entry } }, null, 2);
|
|
566
|
+
console.log(chalk.bold.white("\nAdd to your MCP configuration:\n"));
|
|
567
|
+
console.log(json.split("\n").map((line) => chalk.cyan(` ${line}`)).join("\n"));
|
|
568
|
+
console.log();
|
|
569
|
+
}
|
|
570
|
+
function showCodeBlock(code, title) {
|
|
571
|
+
console.log(chalk.bold.white(`\n${title}:\n`));
|
|
572
|
+
console.log(code.split("\n").map((line) => chalk.dim(` ${line}`)).join("\n"));
|
|
573
|
+
}
|
|
574
|
+
function showNextSteps(lines) {
|
|
575
|
+
console.log(chalk.bold.white("\nLearn more:\n"));
|
|
576
|
+
for (const line of lines) console.log(` ${line}`);
|
|
577
|
+
}
|
|
578
|
+
const ai = new Command("ai").description("Interactive setup for Agent Auth — AI agent authentication").action(aiAction);
|
|
579
|
+
//#endregion
|
|
37
580
|
//#region src/generators/drizzle.ts
|
|
38
581
|
function convertToSnakeCase(str, camelCase) {
|
|
39
582
|
if (camelCase) return str;
|
|
@@ -165,7 +708,7 @@ const generateDrizzleSchema = async ({ options, file, adapter }) => {
|
|
|
165
708
|
if (attr.onUpdate && attr.type === "date") {
|
|
166
709
|
if (typeof attr.onUpdate === "function") type += `.$onUpdate(${attr.onUpdate})`;
|
|
167
710
|
}
|
|
168
|
-
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({
|
|
169
712
|
model: attr.references.model,
|
|
170
713
|
field: attr.references.field
|
|
171
714
|
})}, { onDelete: '${attr.references.onDelete || "cascade"}' })` : ""}`;
|
|
@@ -322,7 +865,6 @@ function generateImport({ databaseType, tables, options }) {
|
|
|
322
865
|
if (hasUniqueIndexes) coreImports.push("uniqueIndex");
|
|
323
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`;
|
|
324
867
|
}
|
|
325
|
-
|
|
326
868
|
//#endregion
|
|
327
869
|
//#region src/generators/kysely.ts
|
|
328
870
|
const generateKyselySchema = async ({ options, file }) => {
|
|
@@ -333,7 +875,6 @@ const generateKyselySchema = async ({ options, file }) => {
|
|
|
333
875
|
fileName: file || `./better-auth_migrations/${(/* @__PURE__ */ new Date()).toISOString().replace(/:/g, "-")}.sql`
|
|
334
876
|
};
|
|
335
877
|
};
|
|
336
|
-
|
|
337
878
|
//#endregion
|
|
338
879
|
//#region src/utils/helper.ts
|
|
339
880
|
async function tryCatch(promise) {
|
|
@@ -365,7 +906,6 @@ const spawnCommand = (cmd, cwd = process.cwd()) => new Promise((resolve, reject)
|
|
|
365
906
|
});
|
|
366
907
|
child.on("error", reject);
|
|
367
908
|
});
|
|
368
|
-
|
|
369
909
|
//#endregion
|
|
370
910
|
//#region src/utils/get-package-info.ts
|
|
371
911
|
function getPackageInfo(cwd) {
|
|
@@ -437,7 +977,6 @@ async function findMonorepoRoot(startDir) {
|
|
|
437
977
|
}
|
|
438
978
|
return null;
|
|
439
979
|
}
|
|
440
|
-
|
|
441
980
|
//#endregion
|
|
442
981
|
//#region src/generators/prisma.ts
|
|
443
982
|
const generatePrismaSchema = async ({ adapter, options, file }) => {
|
|
@@ -547,7 +1086,7 @@ const generatePrismaSchema = async ({ adapter, options, file }) => {
|
|
|
547
1086
|
type: "number"
|
|
548
1087
|
}) : getType({
|
|
549
1088
|
isBigint: attr?.bigint || false,
|
|
550
|
-
isOptional:
|
|
1089
|
+
isOptional: attr?.required === false,
|
|
551
1090
|
type: attr.references?.field === "id" ? useNumberId ? "number" : "string" : attr.type
|
|
552
1091
|
}));
|
|
553
1092
|
if (field === "id") {
|
|
@@ -609,7 +1148,7 @@ const generatePrismaSchema = async ({ adapter, options, file }) => {
|
|
|
609
1148
|
model: attr.references.model,
|
|
610
1149
|
field: attr.references.field
|
|
611
1150
|
})}], onDelete: ${action})`;
|
|
612
|
-
builder.model(modelName).field(referencedCustomModelName.toLowerCase(), `${capitalizeFirstLetter(referencedCustomModelName)}${
|
|
1151
|
+
builder.model(modelName).field(referencedCustomModelName.toLowerCase(), `${capitalizeFirstLetter(referencedCustomModelName)}${attr.required === false ? "?" : ""}`).attribute(relationField);
|
|
613
1152
|
}
|
|
614
1153
|
if (!attr.unique && !attr.references && provider === "mysql" && attr.type === "string") builder.model(modelName).field(fieldName).attribute("db.Text");
|
|
615
1154
|
}
|
|
@@ -674,7 +1213,6 @@ const getNewPrisma = (provider, cwd) => {
|
|
|
674
1213
|
url = ${provider === "sqlite" ? `"file:./dev.db"` : `env("DATABASE_URL")`}
|
|
675
1214
|
}`;
|
|
676
1215
|
};
|
|
677
|
-
|
|
678
1216
|
//#endregion
|
|
679
1217
|
//#region src/generators/index.ts
|
|
680
1218
|
const adapters = {
|
|
@@ -693,7 +1231,6 @@ const generateSchema = (opts) => {
|
|
|
693
1231
|
}));
|
|
694
1232
|
throw new Error(`${adapter.id} is not supported. If it is a custom adapter, please request the maintainer to implement createSchema`);
|
|
695
1233
|
};
|
|
696
|
-
|
|
697
1234
|
//#endregion
|
|
698
1235
|
//#region src/utils/add-cloudflare-modules.ts
|
|
699
1236
|
const createModule = () => {
|
|
@@ -768,7 +1305,6 @@ function addCloudflareModules(aliases, _cwd) {
|
|
|
768
1305
|
if (!aliases["cloudflare:workers"]) aliases["cloudflare:workers"] = CLOUDFLARE_STUB_MODULE;
|
|
769
1306
|
if (!aliases["cloudflare:test"]) aliases["cloudflare:test"] = CLOUDFLARE_STUB_MODULE;
|
|
770
1307
|
}
|
|
771
|
-
|
|
772
1308
|
//#endregion
|
|
773
1309
|
//#region src/utils/add-svelte-kit-env-modules.ts
|
|
774
1310
|
/**
|
|
@@ -919,7 +1455,6 @@ const reserved = new Set([
|
|
|
919
1455
|
"implements",
|
|
920
1456
|
"instanceof"
|
|
921
1457
|
]);
|
|
922
|
-
|
|
923
1458
|
//#endregion
|
|
924
1459
|
//#region src/utils/get-config.ts
|
|
925
1460
|
let possiblePaths$1 = [
|
|
@@ -1096,7 +1631,6 @@ async function getConfig({ cwd, configPath, shouldThrowOnError = false }) {
|
|
|
1096
1631
|
process.exit(1);
|
|
1097
1632
|
}
|
|
1098
1633
|
}
|
|
1099
|
-
|
|
1100
1634
|
//#endregion
|
|
1101
1635
|
//#region src/commands/generate.ts
|
|
1102
1636
|
function createMockAdapter$1(adapterId, dialect) {
|
|
@@ -1143,14 +1677,14 @@ function createMockAdapter$1(adapterId, dialect) {
|
|
|
1143
1677
|
};
|
|
1144
1678
|
}
|
|
1145
1679
|
async function generateAction(opts) {
|
|
1146
|
-
const options = z
|
|
1147
|
-
cwd: z
|
|
1148
|
-
config: z
|
|
1149
|
-
output: z
|
|
1150
|
-
adapter: z
|
|
1151
|
-
dialect: z
|
|
1152
|
-
y: z
|
|
1153
|
-
yes: z
|
|
1680
|
+
const options = z.object({
|
|
1681
|
+
cwd: z.string(),
|
|
1682
|
+
config: z.string().optional(),
|
|
1683
|
+
output: z.string().optional(),
|
|
1684
|
+
adapter: z.string().optional(),
|
|
1685
|
+
dialect: z.string().optional(),
|
|
1686
|
+
y: z.boolean().optional(),
|
|
1687
|
+
yes: z.boolean().optional()
|
|
1154
1688
|
}).parse(opts);
|
|
1155
1689
|
const cwd = path.resolve(options.cwd);
|
|
1156
1690
|
if (!existsSync(cwd)) {
|
|
@@ -1270,7 +1804,6 @@ async function generateAction(opts) {
|
|
|
1270
1804
|
process.exit(0);
|
|
1271
1805
|
}
|
|
1272
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);
|
|
1273
|
-
|
|
1274
1807
|
//#endregion
|
|
1275
1808
|
//#region src/commands/info.ts
|
|
1276
1809
|
function getSystemInfo() {
|
|
@@ -1633,7 +2166,6 @@ ${JSON.stringify(betterAuthInfo, null, 2)}
|
|
|
1633
2166
|
}
|
|
1634
2167
|
}
|
|
1635
2168
|
});
|
|
1636
|
-
|
|
1637
2169
|
//#endregion
|
|
1638
2170
|
//#region src/utils/check-package-managers.ts
|
|
1639
2171
|
async function checkPackageManagers() {
|
|
@@ -1723,7 +2255,6 @@ async function getVersion(pkgManager) {
|
|
|
1723
2255
|
});
|
|
1724
2256
|
});
|
|
1725
2257
|
}
|
|
1726
|
-
|
|
1727
2258
|
//#endregion
|
|
1728
2259
|
//#region src/utils/config-paths.ts
|
|
1729
2260
|
let possiblePaths = [
|
|
@@ -1784,7 +2315,6 @@ _possibleClientConfigPaths = [
|
|
|
1784
2315
|
..._possibleClientConfigPaths.map((it) => `app/${it}`)
|
|
1785
2316
|
];
|
|
1786
2317
|
const possibleClientConfigPaths = _possibleClientConfigPaths;
|
|
1787
|
-
|
|
1788
2318
|
//#endregion
|
|
1789
2319
|
//#region src/utils/install-dependencies.ts
|
|
1790
2320
|
const flagsMap = {
|
|
@@ -1851,7 +2381,6 @@ function installDependencies({ dependencies, packageManager, cwd, type = "prod",
|
|
|
1851
2381
|
});
|
|
1852
2382
|
});
|
|
1853
2383
|
}
|
|
1854
|
-
|
|
1855
2384
|
//#endregion
|
|
1856
2385
|
//#region src/commands/init/configs/frameworks.config.ts
|
|
1857
2386
|
const FRAMEWORKS = [
|
|
@@ -2056,7 +2585,6 @@ export const Route = createFileRoute('/api/auth/$')({
|
|
|
2056
2585
|
configPaths: ["nitro.config.ts"]
|
|
2057
2586
|
}
|
|
2058
2587
|
];
|
|
2059
|
-
|
|
2060
2588
|
//#endregion
|
|
2061
2589
|
//#region src/commands/init/configs/social-providers.config.ts
|
|
2062
2590
|
const SOCIAL_PROVIDERS = [
|
|
@@ -2341,13 +2869,11 @@ const SOCIAL_PROVIDER_CONFIGS = {
|
|
|
2341
2869
|
envVar: "ZOOM_CLIENT_SECRET"
|
|
2342
2870
|
}] }
|
|
2343
2871
|
};
|
|
2344
|
-
|
|
2345
2872
|
//#endregion
|
|
2346
2873
|
//#region src/commands/init/utility/format.ts
|
|
2347
2874
|
const formatCode = async (code) => {
|
|
2348
2875
|
return await format(code, { parser: "typescript" });
|
|
2349
2876
|
};
|
|
2350
|
-
|
|
2351
2877
|
//#endregion
|
|
2352
2878
|
//#region src/commands/init/utility/imports.ts
|
|
2353
2879
|
/**
|
|
@@ -2403,7 +2929,6 @@ const groupImports = (imports) => {
|
|
|
2403
2929
|
return a.path.localeCompare(b.path);
|
|
2404
2930
|
});
|
|
2405
2931
|
};
|
|
2406
|
-
|
|
2407
2932
|
//#endregion
|
|
2408
2933
|
//#region src/commands/init/configs/temp-plugins.config.ts
|
|
2409
2934
|
const tempPluginsConfig = {
|
|
@@ -2426,7 +2951,7 @@ const tempPluginsConfig = {
|
|
|
2426
2951
|
argument: {
|
|
2427
2952
|
index: 0,
|
|
2428
2953
|
isProperty: "issuer",
|
|
2429
|
-
schema: z
|
|
2954
|
+
schema: z.coerce.string().optional()
|
|
2430
2955
|
}
|
|
2431
2956
|
},
|
|
2432
2957
|
{
|
|
@@ -2438,7 +2963,7 @@ const tempPluginsConfig = {
|
|
|
2438
2963
|
argument: {
|
|
2439
2964
|
index: 0,
|
|
2440
2965
|
isProperty: "skipVerificationOnEnable",
|
|
2441
|
-
schema: z
|
|
2966
|
+
schema: z.coerce.boolean().optional()
|
|
2442
2967
|
}
|
|
2443
2968
|
},
|
|
2444
2969
|
{
|
|
@@ -2455,7 +2980,7 @@ const tempPluginsConfig = {
|
|
|
2455
2980
|
argument: {
|
|
2456
2981
|
index: 0,
|
|
2457
2982
|
isProperty: "digits",
|
|
2458
|
-
schema: z
|
|
2983
|
+
schema: z.coerce.number().positive().optional()
|
|
2459
2984
|
}
|
|
2460
2985
|
}, {
|
|
2461
2986
|
flag: "totp-otp-period",
|
|
@@ -2466,7 +2991,7 @@ const tempPluginsConfig = {
|
|
|
2466
2991
|
argument: {
|
|
2467
2992
|
index: 0,
|
|
2468
2993
|
isProperty: "period",
|
|
2469
|
-
schema: z
|
|
2994
|
+
schema: z.coerce.number().positive().optional()
|
|
2470
2995
|
}
|
|
2471
2996
|
}],
|
|
2472
2997
|
argument: {
|
|
@@ -2488,7 +3013,7 @@ const tempPluginsConfig = {
|
|
|
2488
3013
|
argument: {
|
|
2489
3014
|
index: 0,
|
|
2490
3015
|
isProperty: "period",
|
|
2491
|
-
schema: z
|
|
3016
|
+
schema: z.coerce.number().positive().optional()
|
|
2492
3017
|
}
|
|
2493
3018
|
}, {
|
|
2494
3019
|
flag: "otp-store-otp",
|
|
@@ -2513,7 +3038,7 @@ const tempPluginsConfig = {
|
|
|
2513
3038
|
argument: {
|
|
2514
3039
|
index: 0,
|
|
2515
3040
|
isProperty: "storeOTP",
|
|
2516
|
-
schema: z
|
|
3041
|
+
schema: z.enum([
|
|
2517
3042
|
"plain",
|
|
2518
3043
|
"encrypted",
|
|
2519
3044
|
"hashed"
|
|
@@ -2538,7 +3063,7 @@ const tempPluginsConfig = {
|
|
|
2538
3063
|
argument: {
|
|
2539
3064
|
index: 0,
|
|
2540
3065
|
isProperty: "amount",
|
|
2541
|
-
schema: z
|
|
3066
|
+
schema: z.coerce.number().positive().optional()
|
|
2542
3067
|
}
|
|
2543
3068
|
}, {
|
|
2544
3069
|
flag: "backup-code-length",
|
|
@@ -2549,7 +3074,7 @@ const tempPluginsConfig = {
|
|
|
2549
3074
|
argument: {
|
|
2550
3075
|
index: 0,
|
|
2551
3076
|
isProperty: "length",
|
|
2552
|
-
schema: z
|
|
3077
|
+
schema: z.coerce.number().positive().optional()
|
|
2553
3078
|
}
|
|
2554
3079
|
}],
|
|
2555
3080
|
argument: {
|
|
@@ -2574,7 +3099,7 @@ const tempPluginsConfig = {
|
|
|
2574
3099
|
argument: {
|
|
2575
3100
|
index: 0,
|
|
2576
3101
|
isProperty: "twoFactorTable",
|
|
2577
|
-
schema: z
|
|
3102
|
+
schema: z.coerce.string().optional()
|
|
2578
3103
|
}
|
|
2579
3104
|
}]
|
|
2580
3105
|
}
|
|
@@ -2608,7 +3133,7 @@ const tempPluginsConfig = {
|
|
|
2608
3133
|
argument: {
|
|
2609
3134
|
index: 0,
|
|
2610
3135
|
isProperty: "maxUsernameLength",
|
|
2611
|
-
schema: z
|
|
3136
|
+
schema: z.coerce.number().min(0).positive().optional()
|
|
2612
3137
|
}
|
|
2613
3138
|
},
|
|
2614
3139
|
{
|
|
@@ -2620,7 +3145,7 @@ const tempPluginsConfig = {
|
|
|
2620
3145
|
argument: {
|
|
2621
3146
|
index: 0,
|
|
2622
3147
|
isProperty: "minUsernameLength",
|
|
2623
|
-
schema: z
|
|
3148
|
+
schema: z.coerce.number().min(0).positive().optional()
|
|
2624
3149
|
}
|
|
2625
3150
|
},
|
|
2626
3151
|
{
|
|
@@ -2643,7 +3168,7 @@ const tempPluginsConfig = {
|
|
|
2643
3168
|
argument: {
|
|
2644
3169
|
index: 0,
|
|
2645
3170
|
isProperty: "username",
|
|
2646
|
-
schema: z
|
|
3171
|
+
schema: z.enum(["pre-normalization", "post-normalization"]).optional()
|
|
2647
3172
|
}
|
|
2648
3173
|
}, {
|
|
2649
3174
|
flag: "username-validation-order-display-username",
|
|
@@ -2661,7 +3186,7 @@ const tempPluginsConfig = {
|
|
|
2661
3186
|
argument: {
|
|
2662
3187
|
index: 0,
|
|
2663
3188
|
isProperty: "displayUsername",
|
|
2664
|
-
schema: z
|
|
3189
|
+
schema: z.enum(["pre-normalization", "post-normalization"]).optional()
|
|
2665
3190
|
}
|
|
2666
3191
|
}],
|
|
2667
3192
|
argument: {
|
|
@@ -2700,7 +3225,7 @@ const tempPluginsConfig = {
|
|
|
2700
3225
|
argument: {
|
|
2701
3226
|
index: 0,
|
|
2702
3227
|
isProperty: "expiresIn",
|
|
2703
|
-
schema: z
|
|
3228
|
+
schema: z.coerce.number().optional()
|
|
2704
3229
|
}
|
|
2705
3230
|
},
|
|
2706
3231
|
{
|
|
@@ -2715,7 +3240,7 @@ const tempPluginsConfig = {
|
|
|
2715
3240
|
argument: {
|
|
2716
3241
|
index: 0,
|
|
2717
3242
|
isProperty: "sendMagicLink",
|
|
2718
|
-
schema: z
|
|
3243
|
+
schema: z.coerce.string()
|
|
2719
3244
|
}
|
|
2720
3245
|
},
|
|
2721
3246
|
{
|
|
@@ -2732,7 +3257,7 @@ const tempPluginsConfig = {
|
|
|
2732
3257
|
argument: {
|
|
2733
3258
|
index: 0,
|
|
2734
3259
|
isProperty: "window",
|
|
2735
|
-
schema: z
|
|
3260
|
+
schema: z.coerce.number().optional()
|
|
2736
3261
|
}
|
|
2737
3262
|
}, {
|
|
2738
3263
|
flag: "magic-link-rate-limit-max",
|
|
@@ -2744,7 +3269,7 @@ const tempPluginsConfig = {
|
|
|
2744
3269
|
argument: {
|
|
2745
3270
|
index: 0,
|
|
2746
3271
|
isProperty: "max",
|
|
2747
|
-
schema: z
|
|
3272
|
+
schema: z.coerce.number().optional()
|
|
2748
3273
|
}
|
|
2749
3274
|
}],
|
|
2750
3275
|
argument: {
|
|
@@ -2768,7 +3293,7 @@ const tempPluginsConfig = {
|
|
|
2768
3293
|
argument: {
|
|
2769
3294
|
index: 0,
|
|
2770
3295
|
isProperty: "storeToken",
|
|
2771
|
-
schema: z
|
|
3296
|
+
schema: z.enum(["plain", "hashed"]).optional()
|
|
2772
3297
|
}
|
|
2773
3298
|
}
|
|
2774
3299
|
]
|
|
@@ -2804,7 +3329,7 @@ const tempPluginsConfig = {
|
|
|
2804
3329
|
argument: {
|
|
2805
3330
|
index: 0,
|
|
2806
3331
|
isProperty: "sendVerificationOTP",
|
|
2807
|
-
schema: z
|
|
3332
|
+
schema: z.coerce.string()
|
|
2808
3333
|
}
|
|
2809
3334
|
},
|
|
2810
3335
|
{
|
|
@@ -2817,7 +3342,7 @@ const tempPluginsConfig = {
|
|
|
2817
3342
|
argument: {
|
|
2818
3343
|
index: 0,
|
|
2819
3344
|
isProperty: "otpLength",
|
|
2820
|
-
schema: z
|
|
3345
|
+
schema: z.coerce.number().optional()
|
|
2821
3346
|
}
|
|
2822
3347
|
},
|
|
2823
3348
|
{
|
|
@@ -2830,7 +3355,7 @@ const tempPluginsConfig = {
|
|
|
2830
3355
|
argument: {
|
|
2831
3356
|
index: 0,
|
|
2832
3357
|
isProperty: "expiresIn",
|
|
2833
|
-
schema: z
|
|
3358
|
+
schema: z.coerce.number().optional()
|
|
2834
3359
|
}
|
|
2835
3360
|
},
|
|
2836
3361
|
{
|
|
@@ -2843,7 +3368,7 @@ const tempPluginsConfig = {
|
|
|
2843
3368
|
argument: {
|
|
2844
3369
|
index: 0,
|
|
2845
3370
|
isProperty: "sendVerificationOnSignUp",
|
|
2846
|
-
schema: z
|
|
3371
|
+
schema: z.coerce.boolean().optional()
|
|
2847
3372
|
}
|
|
2848
3373
|
},
|
|
2849
3374
|
{
|
|
@@ -2856,7 +3381,7 @@ const tempPluginsConfig = {
|
|
|
2856
3381
|
argument: {
|
|
2857
3382
|
index: 0,
|
|
2858
3383
|
isProperty: "disableSignUp",
|
|
2859
|
-
schema: z
|
|
3384
|
+
schema: z.coerce.boolean().optional()
|
|
2860
3385
|
}
|
|
2861
3386
|
},
|
|
2862
3387
|
{
|
|
@@ -2869,7 +3394,7 @@ const tempPluginsConfig = {
|
|
|
2869
3394
|
argument: {
|
|
2870
3395
|
index: 0,
|
|
2871
3396
|
isProperty: "allowedAttempts",
|
|
2872
|
-
schema: z
|
|
3397
|
+
schema: z.coerce.number().optional()
|
|
2873
3398
|
}
|
|
2874
3399
|
},
|
|
2875
3400
|
{
|
|
@@ -2895,7 +3420,7 @@ const tempPluginsConfig = {
|
|
|
2895
3420
|
argument: {
|
|
2896
3421
|
index: 0,
|
|
2897
3422
|
isProperty: "storeOTP",
|
|
2898
|
-
schema: z
|
|
3423
|
+
schema: z.enum([
|
|
2899
3424
|
"plain",
|
|
2900
3425
|
"encrypted",
|
|
2901
3426
|
"hashed"
|
|
@@ -2912,7 +3437,7 @@ const tempPluginsConfig = {
|
|
|
2912
3437
|
argument: {
|
|
2913
3438
|
index: 0,
|
|
2914
3439
|
isProperty: "overrideDefaultEmailVerification",
|
|
2915
|
-
schema: z
|
|
3440
|
+
schema: z.coerce.boolean().optional()
|
|
2916
3441
|
}
|
|
2917
3442
|
}
|
|
2918
3443
|
]
|
|
@@ -3039,7 +3564,7 @@ const tempPluginsConfig = {
|
|
|
3039
3564
|
argument: {
|
|
3040
3565
|
index: 0,
|
|
3041
3566
|
isProperty: "defaultRole",
|
|
3042
|
-
schema: z
|
|
3567
|
+
schema: z.coerce.string().optional()
|
|
3043
3568
|
}
|
|
3044
3569
|
}, {
|
|
3045
3570
|
flag: "admin-roles",
|
|
@@ -3050,7 +3575,7 @@ const tempPluginsConfig = {
|
|
|
3050
3575
|
argument: {
|
|
3051
3576
|
index: 0,
|
|
3052
3577
|
isProperty: "adminRoles",
|
|
3053
|
-
schema: z
|
|
3578
|
+
schema: z.array(z.string()).optional()
|
|
3054
3579
|
}
|
|
3055
3580
|
}]
|
|
3056
3581
|
},
|
|
@@ -3082,7 +3607,7 @@ const tempPluginsConfig = {
|
|
|
3082
3607
|
argument: {
|
|
3083
3608
|
index: 0,
|
|
3084
3609
|
isProperty: "apiKeyHeaders",
|
|
3085
|
-
schema: z
|
|
3610
|
+
schema: z.coerce.string().optional()
|
|
3086
3611
|
}
|
|
3087
3612
|
},
|
|
3088
3613
|
{
|
|
@@ -3095,7 +3620,7 @@ const tempPluginsConfig = {
|
|
|
3095
3620
|
argument: {
|
|
3096
3621
|
index: 0,
|
|
3097
3622
|
isProperty: "defaultKeyLength",
|
|
3098
|
-
schema: z
|
|
3623
|
+
schema: z.coerce.number().positive().optional()
|
|
3099
3624
|
}
|
|
3100
3625
|
},
|
|
3101
3626
|
{
|
|
@@ -3107,7 +3632,7 @@ const tempPluginsConfig = {
|
|
|
3107
3632
|
argument: {
|
|
3108
3633
|
index: 0,
|
|
3109
3634
|
isProperty: "disableKeyHashing",
|
|
3110
|
-
schema: z
|
|
3635
|
+
schema: z.coerce.boolean().optional()
|
|
3111
3636
|
}
|
|
3112
3637
|
},
|
|
3113
3638
|
{
|
|
@@ -3119,7 +3644,7 @@ const tempPluginsConfig = {
|
|
|
3119
3644
|
argument: {
|
|
3120
3645
|
index: 0,
|
|
3121
3646
|
isProperty: "enableMetadata",
|
|
3122
|
-
schema: z
|
|
3647
|
+
schema: z.coerce.boolean().optional()
|
|
3123
3648
|
}
|
|
3124
3649
|
},
|
|
3125
3650
|
{
|
|
@@ -3131,7 +3656,7 @@ const tempPluginsConfig = {
|
|
|
3131
3656
|
argument: {
|
|
3132
3657
|
index: 0,
|
|
3133
3658
|
isProperty: "enableSessionForAPIKeys",
|
|
3134
|
-
schema: z
|
|
3659
|
+
schema: z.coerce.boolean().optional()
|
|
3135
3660
|
}
|
|
3136
3661
|
}
|
|
3137
3662
|
]
|
|
@@ -3163,7 +3688,7 @@ const tempPluginsConfig = {
|
|
|
3163
3688
|
argument: {
|
|
3164
3689
|
index: 0,
|
|
3165
3690
|
isProperty: "requireSignature",
|
|
3166
|
-
schema: z
|
|
3691
|
+
schema: z.coerce.boolean().optional()
|
|
3167
3692
|
}
|
|
3168
3693
|
}]
|
|
3169
3694
|
},
|
|
@@ -3204,7 +3729,7 @@ const tempPluginsConfig = {
|
|
|
3204
3729
|
argument: {
|
|
3205
3730
|
index: 0,
|
|
3206
3731
|
isProperty: "provider",
|
|
3207
|
-
schema: z
|
|
3732
|
+
schema: z.enum([
|
|
3208
3733
|
"google-recaptcha",
|
|
3209
3734
|
"cloudflare-turnstile",
|
|
3210
3735
|
"hcaptcha",
|
|
@@ -3219,7 +3744,7 @@ const tempPluginsConfig = {
|
|
|
3219
3744
|
argument: {
|
|
3220
3745
|
index: 0,
|
|
3221
3746
|
isProperty: "secretKey",
|
|
3222
|
-
schema: z
|
|
3747
|
+
schema: z.coerce.string()
|
|
3223
3748
|
}
|
|
3224
3749
|
},
|
|
3225
3750
|
{
|
|
@@ -3230,7 +3755,7 @@ const tempPluginsConfig = {
|
|
|
3230
3755
|
argument: {
|
|
3231
3756
|
index: 0,
|
|
3232
3757
|
isProperty: "siteKey",
|
|
3233
|
-
schema: z
|
|
3758
|
+
schema: z.coerce.string().optional()
|
|
3234
3759
|
}
|
|
3235
3760
|
},
|
|
3236
3761
|
{
|
|
@@ -3243,7 +3768,7 @@ const tempPluginsConfig = {
|
|
|
3243
3768
|
argument: {
|
|
3244
3769
|
index: 0,
|
|
3245
3770
|
isProperty: "minScore",
|
|
3246
|
-
schema: z
|
|
3771
|
+
schema: z.coerce.number().min(0).max(1).optional()
|
|
3247
3772
|
}
|
|
3248
3773
|
}
|
|
3249
3774
|
]
|
|
@@ -3268,7 +3793,7 @@ const tempPluginsConfig = {
|
|
|
3268
3793
|
argument: {
|
|
3269
3794
|
index: 0,
|
|
3270
3795
|
isProperty: "shouldMutateListDeviceSessionsEndpoint",
|
|
3271
|
-
schema: z
|
|
3796
|
+
schema: z.coerce.boolean().optional()
|
|
3272
3797
|
}
|
|
3273
3798
|
}]
|
|
3274
3799
|
},
|
|
@@ -3300,7 +3825,7 @@ const tempPluginsConfig = {
|
|
|
3300
3825
|
argument: {
|
|
3301
3826
|
index: 0,
|
|
3302
3827
|
isProperty: "expiresIn",
|
|
3303
|
-
schema: z
|
|
3828
|
+
schema: z.coerce.string().optional()
|
|
3304
3829
|
}
|
|
3305
3830
|
},
|
|
3306
3831
|
{
|
|
@@ -3312,7 +3837,7 @@ const tempPluginsConfig = {
|
|
|
3312
3837
|
argument: {
|
|
3313
3838
|
index: 0,
|
|
3314
3839
|
isProperty: "interval",
|
|
3315
|
-
schema: z
|
|
3840
|
+
schema: z.coerce.string().optional()
|
|
3316
3841
|
}
|
|
3317
3842
|
},
|
|
3318
3843
|
{
|
|
@@ -3325,7 +3850,7 @@ const tempPluginsConfig = {
|
|
|
3325
3850
|
argument: {
|
|
3326
3851
|
index: 0,
|
|
3327
3852
|
isProperty: "deviceCodeLength",
|
|
3328
|
-
schema: z
|
|
3853
|
+
schema: z.coerce.number().positive().optional()
|
|
3329
3854
|
}
|
|
3330
3855
|
},
|
|
3331
3856
|
{
|
|
@@ -3338,7 +3863,7 @@ const tempPluginsConfig = {
|
|
|
3338
3863
|
argument: {
|
|
3339
3864
|
index: 0,
|
|
3340
3865
|
isProperty: "userCodeLength",
|
|
3341
|
-
schema: z
|
|
3866
|
+
schema: z.coerce.number().positive().optional()
|
|
3342
3867
|
}
|
|
3343
3868
|
}
|
|
3344
3869
|
]
|
|
@@ -3369,7 +3894,7 @@ const tempPluginsConfig = {
|
|
|
3369
3894
|
argument: {
|
|
3370
3895
|
index: 0,
|
|
3371
3896
|
isProperty: "customPasswordCompromisedMessage",
|
|
3372
|
-
schema: z
|
|
3897
|
+
schema: z.coerce.string().optional()
|
|
3373
3898
|
}
|
|
3374
3899
|
}]
|
|
3375
3900
|
},
|
|
@@ -3393,7 +3918,7 @@ const tempPluginsConfig = {
|
|
|
3393
3918
|
argument: {
|
|
3394
3919
|
index: 0,
|
|
3395
3920
|
isProperty: "disableSettingJwtHeader",
|
|
3396
|
-
schema: z
|
|
3921
|
+
schema: z.coerce.boolean().optional()
|
|
3397
3922
|
}
|
|
3398
3923
|
}]
|
|
3399
3924
|
},
|
|
@@ -3425,7 +3950,7 @@ const tempPluginsConfig = {
|
|
|
3425
3950
|
argument: {
|
|
3426
3951
|
index: 0,
|
|
3427
3952
|
isProperty: "cookieName",
|
|
3428
|
-
schema: z
|
|
3953
|
+
schema: z.coerce.string().optional()
|
|
3429
3954
|
}
|
|
3430
3955
|
},
|
|
3431
3956
|
{
|
|
@@ -3438,7 +3963,7 @@ const tempPluginsConfig = {
|
|
|
3438
3963
|
argument: {
|
|
3439
3964
|
index: 0,
|
|
3440
3965
|
isProperty: "maxAge",
|
|
3441
|
-
schema: z
|
|
3966
|
+
schema: z.coerce.number().positive().optional()
|
|
3442
3967
|
}
|
|
3443
3968
|
},
|
|
3444
3969
|
{
|
|
@@ -3450,7 +3975,7 @@ const tempPluginsConfig = {
|
|
|
3450
3975
|
argument: {
|
|
3451
3976
|
index: 0,
|
|
3452
3977
|
isProperty: "storeInDatabase",
|
|
3453
|
-
schema: z
|
|
3978
|
+
schema: z.coerce.boolean().optional()
|
|
3454
3979
|
}
|
|
3455
3980
|
}
|
|
3456
3981
|
]
|
|
@@ -3480,7 +4005,7 @@ const tempPluginsConfig = {
|
|
|
3480
4005
|
argument: {
|
|
3481
4006
|
index: 0,
|
|
3482
4007
|
isProperty: "loginPage",
|
|
3483
|
-
schema: z
|
|
4008
|
+
schema: z.coerce.string()
|
|
3484
4009
|
}
|
|
3485
4010
|
}, {
|
|
3486
4011
|
flag: "mcp-resource",
|
|
@@ -3490,7 +4015,7 @@ const tempPluginsConfig = {
|
|
|
3490
4015
|
argument: {
|
|
3491
4016
|
index: 0,
|
|
3492
4017
|
isProperty: "resource",
|
|
3493
|
-
schema: z
|
|
4018
|
+
schema: z.coerce.string().optional()
|
|
3494
4019
|
}
|
|
3495
4020
|
}]
|
|
3496
4021
|
},
|
|
@@ -3515,7 +4040,7 @@ const tempPluginsConfig = {
|
|
|
3515
4040
|
argument: {
|
|
3516
4041
|
index: 0,
|
|
3517
4042
|
isProperty: "maximumSessions",
|
|
3518
|
-
schema: z
|
|
4043
|
+
schema: z.coerce.number().positive().optional()
|
|
3519
4044
|
}
|
|
3520
4045
|
}]
|
|
3521
4046
|
},
|
|
@@ -3545,7 +4070,7 @@ const tempPluginsConfig = {
|
|
|
3545
4070
|
argument: {
|
|
3546
4071
|
index: 0,
|
|
3547
4072
|
isProperty: "currentURL",
|
|
3548
|
-
schema: z
|
|
4073
|
+
schema: z.coerce.string().optional()
|
|
3549
4074
|
}
|
|
3550
4075
|
}, {
|
|
3551
4076
|
flag: "oauth-proxy-production-url",
|
|
@@ -3555,7 +4080,7 @@ const tempPluginsConfig = {
|
|
|
3555
4080
|
argument: {
|
|
3556
4081
|
index: 0,
|
|
3557
4082
|
isProperty: "productionURL",
|
|
3558
|
-
schema: z
|
|
4083
|
+
schema: z.coerce.string().optional()
|
|
3559
4084
|
}
|
|
3560
4085
|
}]
|
|
3561
4086
|
},
|
|
@@ -3579,7 +4104,7 @@ const tempPluginsConfig = {
|
|
|
3579
4104
|
argument: {
|
|
3580
4105
|
index: 0,
|
|
3581
4106
|
isProperty: "disableSignup",
|
|
3582
|
-
schema: z
|
|
4107
|
+
schema: z.coerce.boolean().optional()
|
|
3583
4108
|
}
|
|
3584
4109
|
}, {
|
|
3585
4110
|
flag: "one-tap-client-id",
|
|
@@ -3589,7 +4114,7 @@ const tempPluginsConfig = {
|
|
|
3589
4114
|
argument: {
|
|
3590
4115
|
index: 0,
|
|
3591
4116
|
isProperty: "clientId",
|
|
3592
|
-
schema: z
|
|
4117
|
+
schema: z.coerce.string().optional()
|
|
3593
4118
|
}
|
|
3594
4119
|
}]
|
|
3595
4120
|
},
|
|
@@ -3622,7 +4147,7 @@ const tempPluginsConfig = {
|
|
|
3622
4147
|
argument: {
|
|
3623
4148
|
index: 0,
|
|
3624
4149
|
isProperty: "expiresIn",
|
|
3625
|
-
schema: z
|
|
4150
|
+
schema: z.coerce.number().positive().optional()
|
|
3626
4151
|
}
|
|
3627
4152
|
},
|
|
3628
4153
|
{
|
|
@@ -3634,7 +4159,7 @@ const tempPluginsConfig = {
|
|
|
3634
4159
|
argument: {
|
|
3635
4160
|
index: 0,
|
|
3636
4161
|
isProperty: "disableClientRequest",
|
|
3637
|
-
schema: z
|
|
4162
|
+
schema: z.coerce.boolean().optional()
|
|
3638
4163
|
}
|
|
3639
4164
|
},
|
|
3640
4165
|
{
|
|
@@ -3653,7 +4178,7 @@ const tempPluginsConfig = {
|
|
|
3653
4178
|
argument: {
|
|
3654
4179
|
index: 0,
|
|
3655
4180
|
isProperty: "storeToken",
|
|
3656
|
-
schema: z
|
|
4181
|
+
schema: z.enum(["plain", "hashed"]).optional()
|
|
3657
4182
|
}
|
|
3658
4183
|
}
|
|
3659
4184
|
]
|
|
@@ -3686,7 +4211,7 @@ const tempPluginsConfig = {
|
|
|
3686
4211
|
argument: {
|
|
3687
4212
|
index: 0,
|
|
3688
4213
|
isProperty: "path",
|
|
3689
|
-
schema: z
|
|
4214
|
+
schema: z.coerce.string().optional()
|
|
3690
4215
|
}
|
|
3691
4216
|
},
|
|
3692
4217
|
{
|
|
@@ -3698,7 +4223,7 @@ const tempPluginsConfig = {
|
|
|
3698
4223
|
argument: {
|
|
3699
4224
|
index: 0,
|
|
3700
4225
|
isProperty: "disableDefaultReference",
|
|
3701
|
-
schema: z
|
|
4226
|
+
schema: z.coerce.boolean().optional()
|
|
3702
4227
|
}
|
|
3703
4228
|
},
|
|
3704
4229
|
{
|
|
@@ -3760,7 +4285,7 @@ const tempPluginsConfig = {
|
|
|
3760
4285
|
argument: {
|
|
3761
4286
|
index: 0,
|
|
3762
4287
|
isProperty: "theme",
|
|
3763
|
-
schema: z
|
|
4288
|
+
schema: z.enum([
|
|
3764
4289
|
"alternate",
|
|
3765
4290
|
"default",
|
|
3766
4291
|
"moon",
|
|
@@ -3799,7 +4324,7 @@ const tempPluginsConfig = {
|
|
|
3799
4324
|
argument: {
|
|
3800
4325
|
index: 0,
|
|
3801
4326
|
isProperty: "allowUserToCreateOrganization",
|
|
3802
|
-
schema: z
|
|
4327
|
+
schema: z.coerce.boolean().optional()
|
|
3803
4328
|
}
|
|
3804
4329
|
},
|
|
3805
4330
|
{
|
|
@@ -3811,7 +4336,7 @@ const tempPluginsConfig = {
|
|
|
3811
4336
|
argument: {
|
|
3812
4337
|
index: 0,
|
|
3813
4338
|
isProperty: "creatorRole",
|
|
3814
|
-
schema: z
|
|
4339
|
+
schema: z.coerce.string().optional()
|
|
3815
4340
|
}
|
|
3816
4341
|
},
|
|
3817
4342
|
{
|
|
@@ -3824,7 +4349,7 @@ const tempPluginsConfig = {
|
|
|
3824
4349
|
argument: {
|
|
3825
4350
|
index: 0,
|
|
3826
4351
|
isProperty: "membershipLimit",
|
|
3827
|
-
schema: z
|
|
4352
|
+
schema: z.coerce.number().positive().optional()
|
|
3828
4353
|
}
|
|
3829
4354
|
}
|
|
3830
4355
|
]
|
|
@@ -3855,7 +4380,7 @@ const tempPluginsConfig = {
|
|
|
3855
4380
|
argument: {
|
|
3856
4381
|
index: 0,
|
|
3857
4382
|
isProperty: "domain",
|
|
3858
|
-
schema: z
|
|
4383
|
+
schema: z.coerce.string()
|
|
3859
4384
|
}
|
|
3860
4385
|
},
|
|
3861
4386
|
{
|
|
@@ -3866,7 +4391,7 @@ const tempPluginsConfig = {
|
|
|
3866
4391
|
argument: {
|
|
3867
4392
|
index: 0,
|
|
3868
4393
|
isProperty: "emailDomainName",
|
|
3869
|
-
schema: z
|
|
4394
|
+
schema: z.coerce.string().optional()
|
|
3870
4395
|
}
|
|
3871
4396
|
},
|
|
3872
4397
|
{
|
|
@@ -3878,7 +4403,7 @@ const tempPluginsConfig = {
|
|
|
3878
4403
|
argument: {
|
|
3879
4404
|
index: 0,
|
|
3880
4405
|
isProperty: "anonymous",
|
|
3881
|
-
schema: z
|
|
4406
|
+
schema: z.coerce.boolean().optional()
|
|
3882
4407
|
}
|
|
3883
4408
|
}
|
|
3884
4409
|
]
|
|
@@ -3933,7 +4458,7 @@ const tempPluginsConfig = {
|
|
|
3933
4458
|
argument: {
|
|
3934
4459
|
index: 0,
|
|
3935
4460
|
isProperty: "defaultOverrideUserInfo",
|
|
3936
|
-
schema: z
|
|
4461
|
+
schema: z.coerce.boolean().optional()
|
|
3937
4462
|
}
|
|
3938
4463
|
},
|
|
3939
4464
|
{
|
|
@@ -3946,7 +4471,7 @@ const tempPluginsConfig = {
|
|
|
3946
4471
|
argument: {
|
|
3947
4472
|
index: 0,
|
|
3948
4473
|
isProperty: "disableImplicitSignUp",
|
|
3949
|
-
schema: z
|
|
4474
|
+
schema: z.coerce.boolean().optional()
|
|
3950
4475
|
}
|
|
3951
4476
|
},
|
|
3952
4477
|
{
|
|
@@ -3960,7 +4485,7 @@ const tempPluginsConfig = {
|
|
|
3960
4485
|
argument: {
|
|
3961
4486
|
index: 0,
|
|
3962
4487
|
isProperty: "providersLimit",
|
|
3963
|
-
schema: z
|
|
4488
|
+
schema: z.coerce.number().int().positive().optional()
|
|
3964
4489
|
}
|
|
3965
4490
|
},
|
|
3966
4491
|
{
|
|
@@ -3973,7 +4498,7 @@ const tempPluginsConfig = {
|
|
|
3973
4498
|
argument: {
|
|
3974
4499
|
index: 0,
|
|
3975
4500
|
isProperty: "trustEmailVerified",
|
|
3976
|
-
schema: z
|
|
4501
|
+
schema: z.coerce.boolean().optional()
|
|
3977
4502
|
}
|
|
3978
4503
|
},
|
|
3979
4504
|
{
|
|
@@ -3984,7 +4509,7 @@ const tempPluginsConfig = {
|
|
|
3984
4509
|
argument: {
|
|
3985
4510
|
index: 0,
|
|
3986
4511
|
isProperty: "domainVerification",
|
|
3987
|
-
schema: z
|
|
4512
|
+
schema: z.object({ enabled: z.coerce.boolean().optional() }).optional()
|
|
3988
4513
|
},
|
|
3989
4514
|
isNestedObject: [{
|
|
3990
4515
|
flag: "sso-domain-verification-enabled",
|
|
@@ -3996,7 +4521,7 @@ const tempPluginsConfig = {
|
|
|
3996
4521
|
argument: {
|
|
3997
4522
|
index: 0,
|
|
3998
4523
|
isProperty: "enabled",
|
|
3999
|
-
schema: z
|
|
4524
|
+
schema: z.coerce.boolean().optional()
|
|
4000
4525
|
}
|
|
4001
4526
|
}]
|
|
4002
4527
|
}
|
|
@@ -4017,7 +4542,7 @@ const tempPluginsConfig = {
|
|
|
4017
4542
|
argument: {
|
|
4018
4543
|
index: 0,
|
|
4019
4544
|
isProperty: "domainVerification",
|
|
4020
|
-
schema: z
|
|
4545
|
+
schema: z.object({ enabled: z.coerce.boolean().optional() }).optional()
|
|
4021
4546
|
},
|
|
4022
4547
|
isNestedObject: [{
|
|
4023
4548
|
flag: "sso-client-domain-verification-enabled",
|
|
@@ -4029,7 +4554,7 @@ const tempPluginsConfig = {
|
|
|
4029
4554
|
argument: {
|
|
4030
4555
|
index: 0,
|
|
4031
4556
|
isProperty: "enabled",
|
|
4032
|
-
schema: z
|
|
4557
|
+
schema: z.coerce.boolean().optional()
|
|
4033
4558
|
}
|
|
4034
4559
|
}]
|
|
4035
4560
|
}]
|
|
@@ -4074,7 +4599,6 @@ const tempPluginsConfig = {
|
|
|
4074
4599
|
}
|
|
4075
4600
|
}
|
|
4076
4601
|
};
|
|
4077
|
-
|
|
4078
4602
|
//#endregion
|
|
4079
4603
|
//#region src/commands/init/utility/prompt.ts
|
|
4080
4604
|
const getFlagVariable = (flag) => {
|
|
@@ -4181,7 +4705,6 @@ const getArgumentsPrompt = async (options, plugins, target) => {
|
|
|
4181
4705
|
return arg.isRequired && arg.defaultValue !== void 0 ? arg.defaultValue : void 0;
|
|
4182
4706
|
};
|
|
4183
4707
|
};
|
|
4184
|
-
|
|
4185
4708
|
//#endregion
|
|
4186
4709
|
//#region src/commands/init/utility/plugin.ts
|
|
4187
4710
|
const getPluginConfigs = (plugins) => {
|
|
@@ -4354,7 +4877,6 @@ const getAuthClientPluginsCode = async ({ plugins, options = {}, installDependen
|
|
|
4354
4877
|
}
|
|
4355
4878
|
return (await formatCode(`[${pluginsCode.join(", ")}]`)).trim().slice(0, -1);
|
|
4356
4879
|
};
|
|
4357
|
-
|
|
4358
4880
|
//#endregion
|
|
4359
4881
|
//#region src/commands/init/utility/auth-config.ts
|
|
4360
4882
|
const generateInnerAuthConfigCode = async ({ database, plugins, appName, baseURL, emailAndPassword, socialProviders, options, installDependency }) => {
|
|
@@ -4417,7 +4939,6 @@ const getDatabaseCode$1 = (database) => {
|
|
|
4417
4939
|
if (!database) return void 0;
|
|
4418
4940
|
return database.code({});
|
|
4419
4941
|
};
|
|
4420
|
-
|
|
4421
4942
|
//#endregion
|
|
4422
4943
|
//#region src/commands/init/configs/databases.config.ts
|
|
4423
4944
|
const prismaCode = ({ provider, additionalOptions }) => {
|
|
@@ -4808,7 +5329,6 @@ const databasesConfig = [
|
|
|
4808
5329
|
dependencies: ["mongodb"]
|
|
4809
5330
|
}
|
|
4810
5331
|
];
|
|
4811
|
-
|
|
4812
5332
|
//#endregion
|
|
4813
5333
|
//#region src/commands/init/utility/database.ts
|
|
4814
5334
|
const getDatabaseCode = (adapter) => {
|
|
@@ -4938,7 +5458,6 @@ const getDialectsForORM = (orm) => {
|
|
|
4938
5458
|
}
|
|
4939
5459
|
return dialects.sort((a, b) => a.value.localeCompare(b.value));
|
|
4940
5460
|
};
|
|
4941
|
-
|
|
4942
5461
|
//#endregion
|
|
4943
5462
|
//#region src/commands/init/generate-auth.ts
|
|
4944
5463
|
const generateAuthConfigCode = async ({ plugins: pluginsConfig, database: databaseConfig, appName, baseURL, emailAndPassword, socialProviders, installDependency, options }) => {
|
|
@@ -4984,7 +5503,6 @@ const generateAuthConfigCode = async ({ plugins: pluginsConfig, database: databa
|
|
|
4984
5503
|
segmentedCode.exports
|
|
4985
5504
|
].join("\n"));
|
|
4986
5505
|
};
|
|
4987
|
-
|
|
4988
5506
|
//#endregion
|
|
4989
5507
|
//#region src/commands/init/utility/auth-client-config.ts
|
|
4990
5508
|
const generateInnerAuthClientConfigCode = async ({ plugins, options, installDependency }) => {
|
|
@@ -5000,7 +5518,6 @@ const generateInnerAuthClientConfigCode = async ({ plugins, options, installDepe
|
|
|
5000
5518
|
}
|
|
5001
5519
|
return stringCode;
|
|
5002
5520
|
};
|
|
5003
|
-
|
|
5004
5521
|
//#endregion
|
|
5005
5522
|
//#region src/commands/init/generate-auth-client.ts
|
|
5006
5523
|
const generateAuthClientConfigCode = async ({ plugins: pluginsConfig, database: databaseConfig, framework, options, installDependency }) => {
|
|
@@ -5040,7 +5557,6 @@ const generateAuthClientConfigCode = async ({ plugins: pluginsConfig, database:
|
|
|
5040
5557
|
segmentedCode.exports
|
|
5041
5558
|
].join("\n"));
|
|
5042
5559
|
};
|
|
5043
|
-
|
|
5044
5560
|
//#endregion
|
|
5045
5561
|
//#region src/commands/init/utility/env.ts
|
|
5046
5562
|
const getEnvFiles = async (cwd) => {
|
|
@@ -5086,7 +5602,6 @@ const createEnvFile = async (cwd, envVariables) => {
|
|
|
5086
5602
|
const envFile = path.join(cwd, ".env");
|
|
5087
5603
|
await fs$1.writeFile(envFile, envVariables.join("\n"), "utf-8");
|
|
5088
5604
|
};
|
|
5089
|
-
|
|
5090
5605
|
//#endregion
|
|
5091
5606
|
//#region src/commands/init/utility/framework.ts
|
|
5092
5607
|
async function detectFramework(cwd, packageJson) {
|
|
@@ -5111,7 +5626,6 @@ const fileStrategy = ({ cwd }) => {
|
|
|
5111
5626
|
}
|
|
5112
5627
|
return null;
|
|
5113
5628
|
};
|
|
5114
|
-
|
|
5115
5629
|
//#endregion
|
|
5116
5630
|
//#region src/commands/init/index.ts
|
|
5117
5631
|
const confirm = async (options) => {
|
|
@@ -6086,7 +6600,6 @@ const initActionOptionsSchema = z.object({
|
|
|
6086
6600
|
packageManager: z.enum(PACKAGE_MANAGER).optional(),
|
|
6087
6601
|
...pluginArgumentOptionsSchema
|
|
6088
6602
|
});
|
|
6089
|
-
|
|
6090
6603
|
//#endregion
|
|
6091
6604
|
//#region src/commands/login.ts
|
|
6092
6605
|
async function loginAction() {
|
|
@@ -6109,7 +6622,6 @@ async function logoutAction() {
|
|
|
6109
6622
|
process.exit(0);
|
|
6110
6623
|
}
|
|
6111
6624
|
const logout = new Command("logout").description("Logout from Better Auth Infrastructure").action(logoutAction);
|
|
6112
|
-
|
|
6113
6625
|
//#endregion
|
|
6114
6626
|
//#region src/commands/mcp.ts
|
|
6115
6627
|
const REMOTE_MCP_URL = "https://mcp.inkeep.com/better-auth/mcp";
|
|
@@ -6240,16 +6752,15 @@ function showAllOptions() {
|
|
|
6240
6752
|
console.log();
|
|
6241
6753
|
}
|
|
6242
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);
|
|
6243
|
-
|
|
6244
6755
|
//#endregion
|
|
6245
6756
|
//#region src/commands/migrate.ts
|
|
6246
6757
|
/** @internal */
|
|
6247
6758
|
async function migrateAction(opts) {
|
|
6248
|
-
const options = z
|
|
6249
|
-
cwd: z
|
|
6250
|
-
config: z
|
|
6251
|
-
y: z
|
|
6252
|
-
yes: z
|
|
6759
|
+
const options = z.object({
|
|
6760
|
+
cwd: z.string(),
|
|
6761
|
+
config: z.string().optional(),
|
|
6762
|
+
y: z.boolean().optional(),
|
|
6763
|
+
yes: z.boolean().optional()
|
|
6253
6764
|
}).parse(opts);
|
|
6254
6765
|
const cwd = path.resolve(options.cwd);
|
|
6255
6766
|
if (!existsSync(cwd)) {
|
|
@@ -6370,7 +6881,6 @@ async function migrateAction(opts) {
|
|
|
6370
6881
|
process.exit(0);
|
|
6371
6882
|
}
|
|
6372
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);
|
|
6373
|
-
|
|
6374
6884
|
//#endregion
|
|
6375
6885
|
//#region src/commands/secret.ts
|
|
6376
6886
|
const generateSecret = new Command("secret").action(() => {
|
|
@@ -6381,7 +6891,6 @@ ${chalk.gray("# Auth Secret") + chalk.green(`\nBETTER_AUTH_SECRET=${secret}`)}`)
|
|
|
6381
6891
|
const generateSecretHash = () => {
|
|
6382
6892
|
return Crypto.randomBytes(32).toString("hex");
|
|
6383
6893
|
};
|
|
6384
|
-
|
|
6385
6894
|
//#endregion
|
|
6386
6895
|
//#region src/utils/fetch-latest-version.ts
|
|
6387
6896
|
async function fetchLatestVersion(packageName) {
|
|
@@ -6394,16 +6903,15 @@ async function fetchLatestVersion(packageName) {
|
|
|
6394
6903
|
return null;
|
|
6395
6904
|
}
|
|
6396
6905
|
}
|
|
6397
|
-
|
|
6398
6906
|
//#endregion
|
|
6399
6907
|
//#region src/commands/upgrade.ts
|
|
6400
6908
|
function isBetterAuthPackage(name) {
|
|
6401
6909
|
return name === "better-auth" || name.startsWith("@better-auth/");
|
|
6402
6910
|
}
|
|
6403
6911
|
async function upgradeAction(opts) {
|
|
6404
|
-
const options = z
|
|
6405
|
-
cwd: z
|
|
6406
|
-
yes: z
|
|
6912
|
+
const options = z.object({
|
|
6913
|
+
cwd: z.string(),
|
|
6914
|
+
yes: z.boolean().optional()
|
|
6407
6915
|
}).parse(opts);
|
|
6408
6916
|
const cwd = path.resolve(options.cwd);
|
|
6409
6917
|
if (!existsSync(cwd)) {
|
|
@@ -6499,7 +7007,6 @@ async function upgradeAction(opts) {
|
|
|
6499
7007
|
}
|
|
6500
7008
|
}
|
|
6501
7009
|
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);
|
|
6502
|
-
|
|
6503
7010
|
//#endregion
|
|
6504
7011
|
//#region src/index.ts
|
|
6505
7012
|
process.on("SIGINT", () => process.exit(0));
|
|
@@ -6512,14 +7019,14 @@ async function main() {
|
|
|
6512
7019
|
packageInfo = await getPackageInfo();
|
|
6513
7020
|
cliVersion = packageInfo.version || "1.1.2";
|
|
6514
7021
|
} catch {}
|
|
6515
|
-
program.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());
|
|
7022
|
+
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());
|
|
6516
7023
|
program.parse();
|
|
6517
7024
|
}
|
|
6518
7025
|
main().catch((error) => {
|
|
6519
7026
|
console.error("Error running Better Auth CLI:", error);
|
|
6520
7027
|
process.exit(1);
|
|
6521
7028
|
});
|
|
6522
|
-
|
|
6523
7029
|
//#endregion
|
|
6524
7030
|
export { cliVersion };
|
|
7031
|
+
|
|
6525
7032
|
//# sourceMappingURL=index.mjs.map
|