@atlasauth/cli 0.7.0 → 0.8.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/CHANGELOG.md +13 -0
- package/dist/args.d.ts +28 -0
- package/dist/args.js +10 -0
- package/dist/args.js.map +1 -1
- package/dist/commands/config.d.ts +41 -1
- package/dist/commands/config.js +115 -26
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/import-better-auth.d.ts +3 -0
- package/dist/commands/import-better-auth.js +164 -0
- package/dist/commands/import-better-auth.js.map +1 -0
- package/dist/commands/import.js +7 -0
- package/dist/commands/import.js.map +1 -1
- package/dist/commands/migrate.js +40 -1
- package/dist/commands/migrate.js.map +1 -1
- package/dist/context.d.ts +8 -0
- package/dist/context.js.map +1 -1
- package/dist/help.d.ts +1 -1
- package/dist/help.js +44 -1
- package/dist/help.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/migrate/better-auth/integration.d.ts +59 -0
- package/dist/migrate/better-auth/integration.js +81 -0
- package/dist/migrate/better-auth/integration.js.map +1 -0
- package/dist/migrate/better-auth/orchestrator.d.ts +43 -0
- package/dist/migrate/better-auth/orchestrator.js +525 -0
- package/dist/migrate/better-auth/orchestrator.js.map +1 -0
- package/dist/migrate/better-auth/output.d.ts +20 -0
- package/dist/migrate/better-auth/output.js +146 -0
- package/dist/migrate/better-auth/output.js.map +1 -0
- package/dist/migrate/better-auth/translate.d.ts +77 -0
- package/dist/migrate/better-auth/translate.js +1989 -0
- package/dist/migrate/better-auth/translate.js.map +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.importBetterAuthBundle = importBetterAuthBundle;
|
|
4
|
+
const backend_1 = require("@atlasauth/backend");
|
|
5
|
+
const args_1 = require("../args");
|
|
6
|
+
const errors_1 = require("../errors");
|
|
7
|
+
const output_1 = require("../output");
|
|
8
|
+
const project_1 = require("../project");
|
|
9
|
+
const shared_1 = require("./shared");
|
|
10
|
+
function parseOptions(ctx, raw) {
|
|
11
|
+
if (!raw)
|
|
12
|
+
return undefined;
|
|
13
|
+
const text = raw.startsWith('@') ? ctx.readFile(raw.slice(1)) : raw;
|
|
14
|
+
try {
|
|
15
|
+
const v = JSON.parse(text);
|
|
16
|
+
if (!v || typeof v !== 'object' || Array.isArray(v))
|
|
17
|
+
throw new Error('not an object');
|
|
18
|
+
return v;
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
throw new errors_1.CliError('--options must be a JSON object, or @<file> holding one.');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function printReport(ctx, imp) {
|
|
25
|
+
const out = (s) => ctx.io.out(s);
|
|
26
|
+
const r = imp.report;
|
|
27
|
+
if (!r)
|
|
28
|
+
return;
|
|
29
|
+
out('Dry run (nothing imported yet):');
|
|
30
|
+
for (const m of r.models) {
|
|
31
|
+
out(` ${m.label.padEnd(44)} ${String(m.found).padStart(6)} found ${String(m.will_create).padStart(6)} new ${String(m.will_update).padStart(6)} existing ${String(m.will_skip).padStart(6)} skipped`);
|
|
32
|
+
}
|
|
33
|
+
if (r.conflicts_total) {
|
|
34
|
+
out(`Conflicts with existing Atlas data: ${r.conflicts_total}`);
|
|
35
|
+
for (const c of r.conflicts.slice(0, 10))
|
|
36
|
+
out(` [${c.resolution}] ${c.model} ${c.row_id ?? ''}: ${c.message}`);
|
|
37
|
+
}
|
|
38
|
+
for (const a of r.action_items)
|
|
39
|
+
out(`${a.severity === 'required' ? 'REQUIRED' : a.severity === 'recommended' ? 'todo' : 'note'}: ${a.message} (${a.count}${a.items.length ? `: ${a.items.slice(0, 5).join(', ')}` : ''})`);
|
|
40
|
+
for (const w of r.warnings)
|
|
41
|
+
out(`warning: ${w}`);
|
|
42
|
+
if (r.skipped_total) {
|
|
43
|
+
out(`Skipped rows: ${r.skipped_total}`);
|
|
44
|
+
for (const [code, n] of Object.entries(r.skipped_by_code))
|
|
45
|
+
out(` ${code}: ${n}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function printResult(ctx, imp) {
|
|
49
|
+
const r = imp.result;
|
|
50
|
+
if (!r)
|
|
51
|
+
return;
|
|
52
|
+
ctx.io.out(`Imported (import ${imp.id}):`);
|
|
53
|
+
for (const m of r.models) {
|
|
54
|
+
ctx.io.out(` ${m.label.padEnd(44)} ${m.created} created, ${m.updated + m.unchanged} existing, ${m.skipped} skipped, ${m.failed} failed`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async function poll(ctx, http, imp, json) {
|
|
58
|
+
const sleep = ctx.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
59
|
+
let last = -1;
|
|
60
|
+
while (['analyzing', 'queued', 'applying'].includes(imp.status)) {
|
|
61
|
+
await sleep(2000);
|
|
62
|
+
imp = await http.get(`/v1/better_auth_imports/${encodeURIComponent(imp.id)}`);
|
|
63
|
+
const pct = imp.progress?.percent ?? -1;
|
|
64
|
+
if (!json && pct !== last && imp.progress)
|
|
65
|
+
ctx.io.err(` ${imp.status}: ${imp.progress.processed}/${imp.progress.total} (${pct}%)`);
|
|
66
|
+
last = pct;
|
|
67
|
+
}
|
|
68
|
+
return imp;
|
|
69
|
+
}
|
|
70
|
+
async function importBetterAuthBundle(ctx, args) {
|
|
71
|
+
const json = (0, shared_1.wantsJson)(args.values);
|
|
72
|
+
const auth = (0, shared_1.resolveAuth)(ctx, args.values);
|
|
73
|
+
const http = (0, project_1.httpFor)(ctx, { secretKey: auth.secretKey, apiUrl: auth.apiUrl });
|
|
74
|
+
const bundle = (0, args_1.str)(args.values, 'bundle');
|
|
75
|
+
const existing = (0, args_1.str)(args.values, 'import');
|
|
76
|
+
const options = parseOptions(ctx, (0, args_1.str)(args.values, 'options'));
|
|
77
|
+
if (!bundle && !existing) {
|
|
78
|
+
const key = await http.get('/v1/better_auth_imports/public_key');
|
|
79
|
+
if (json)
|
|
80
|
+
(0, output_1.printJson)(ctx.io, key);
|
|
81
|
+
else {
|
|
82
|
+
ctx.io.out(`Import key ${key.kid} (fingerprint ${key.fingerprint}).`);
|
|
83
|
+
ctx.io.out('In your Better Auth app, run:');
|
|
84
|
+
ctx.io.out(` npx atlas-better-auth-export --out better-auth.atlas-bundle --public-key ${key.compact}`);
|
|
85
|
+
ctx.io.out('then:');
|
|
86
|
+
ctx.io.out(' atlas import --from better-auth --bundle better-auth.atlas-bundle');
|
|
87
|
+
}
|
|
88
|
+
return 0;
|
|
89
|
+
}
|
|
90
|
+
let imp;
|
|
91
|
+
if (bundle) {
|
|
92
|
+
const text = ctx.readFile(bundle);
|
|
93
|
+
const parts = (0, backend_1.splitBundleParts)(text);
|
|
94
|
+
if (parts.length === 0)
|
|
95
|
+
throw new errors_1.CliError(`${bundle} is empty.`);
|
|
96
|
+
imp = await http.post('/v1/better_auth_imports', options ? { options } : {});
|
|
97
|
+
for (let i = 0; i < parts.length; i++) {
|
|
98
|
+
await http.put(`/v1/better_auth_imports/${encodeURIComponent(imp.id)}/parts/${i + 1}`, { data: parts[i] });
|
|
99
|
+
if (!json)
|
|
100
|
+
ctx.io.err(` uploaded part ${i + 1}/${parts.length}`);
|
|
101
|
+
}
|
|
102
|
+
imp = await http.post(`/v1/better_auth_imports/${encodeURIComponent(imp.id)}/finalize`, {});
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
imp = await http.get(`/v1/better_auth_imports/${encodeURIComponent(existing)}`);
|
|
106
|
+
if (imp.status === 'uploading') {
|
|
107
|
+
imp = await http.post(`/v1/better_auth_imports/${encodeURIComponent(imp.id)}/finalize`, {});
|
|
108
|
+
}
|
|
109
|
+
else if (options && ['ready', 'failed', 'completed'].includes(imp.status)) {
|
|
110
|
+
imp = await http.post(`/v1/better_auth_imports/${encodeURIComponent(imp.id)}/dry_run`, { options });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
imp = await poll(ctx, http, imp, json);
|
|
114
|
+
if (imp.status === 'invalid' || (imp.status === 'failed' && !imp.analyzed_at)) {
|
|
115
|
+
if (json)
|
|
116
|
+
(0, output_1.printJson)(ctx.io, imp);
|
|
117
|
+
throw new errors_1.CliError(`Atlas could not read the bundle: ${imp.error?.message ?? imp.status} (${imp.error?.code ?? imp.status}).`);
|
|
118
|
+
}
|
|
119
|
+
if (imp.status === 'completed' && !options) {
|
|
120
|
+
if (json)
|
|
121
|
+
(0, output_1.printJson)(ctx.io, imp);
|
|
122
|
+
else {
|
|
123
|
+
ctx.io.out(`Import ${imp.id} is already complete.`);
|
|
124
|
+
printResult(ctx, imp);
|
|
125
|
+
}
|
|
126
|
+
return 0;
|
|
127
|
+
}
|
|
128
|
+
if (!json)
|
|
129
|
+
printReport(ctx, imp);
|
|
130
|
+
if (args.values['dry-run']) {
|
|
131
|
+
if (json)
|
|
132
|
+
(0, output_1.printJson)(ctx.io, imp);
|
|
133
|
+
else
|
|
134
|
+
ctx.io.out(`Nothing was imported. Apply it with: atlas import --from better-auth --import ${imp.id}`);
|
|
135
|
+
return 0;
|
|
136
|
+
}
|
|
137
|
+
const conflicts = imp.report?.conflicts_total ?? 0;
|
|
138
|
+
if (conflicts > 0 && !args.values['confirm-conflicts']) {
|
|
139
|
+
if (json)
|
|
140
|
+
(0, output_1.printJson)(ctx.io, imp);
|
|
141
|
+
throw new errors_1.CliError(`The dry run found ${conflicts} conflict(s). Review them, then re-run with --import ${imp.id} --confirm-conflicts.`);
|
|
142
|
+
}
|
|
143
|
+
if (!args.values.yes && !json) {
|
|
144
|
+
const answer = (await ctx.prompt.text(`Import into Atlas now? [y/N] `)).trim().toLowerCase();
|
|
145
|
+
if (answer !== 'y' && answer !== 'yes') {
|
|
146
|
+
ctx.io.out(`Not applied. Apply later with: atlas import --from better-auth --import ${imp.id}`);
|
|
147
|
+
return 0;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
imp = await http.post(`/v1/better_auth_imports/${encodeURIComponent(imp.id)}/apply`, conflicts > 0 ? { confirm_conflicts: true } : {});
|
|
151
|
+
imp = await poll(ctx, http, imp, json);
|
|
152
|
+
if (json)
|
|
153
|
+
(0, output_1.printJson)(ctx.io, imp);
|
|
154
|
+
else
|
|
155
|
+
printResult(ctx, imp);
|
|
156
|
+
if (imp.status !== 'completed') {
|
|
157
|
+
throw new errors_1.CliError(`The import stopped (${imp.error?.message ?? imp.status}). Run the same command with --import ${imp.id} to resume.`);
|
|
158
|
+
}
|
|
159
|
+
const failed = imp.progress?.failed ?? 0;
|
|
160
|
+
if (!json)
|
|
161
|
+
ctx.io.out(`Done. Next: turn on the session bridge so signed-in users stay signed in, then switch your app's SDK to Atlas.`);
|
|
162
|
+
return failed > 0 ? 2 : 0;
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=import-better-auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-better-auth.js","sourceRoot":"","sources":["../../src/commands/import-better-auth.ts"],"names":[],"mappings":";;AAkFA,wDAmFC;AArKD,gDAAuG;AACvG,kCAA+C;AAE/C,sCAAqC;AACrC,sCAAsC;AACtC,wCAAqC;AACrC,qCAAkD;AAsBlD,SAAS,YAAY,CAAC,GAAe,EAAE,GAAuB;IAC5D,IAAI,CAAC,GAAG;QAAE,OAAO,SAAS,CAAC;IAC3B,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IACpE,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAY,CAAC;QACtC,IAAI,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;YAAE,MAAM,IAAI,KAA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AAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACzJ,GAAG,GAAG,MAAM,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;IACvC,IAAI,IAAI;QAAE,IAAA,kBAAS,EAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;;QAC5B,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC3B,IAAI,GAAG,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;QAC/B,MAAM,IAAI,iBAAQ,CAAC,uBAAuB,GAAG,CAAC,KAAK,EAAE,OAAO,IAAI,GAAG,CAAC,MAAM,yCAAyC,GAAG,CAAC,EAAE,aAAa,CAAC,CAAC;IAC1I,CAAC;IACD,MAAM,MAAM,GAAG,GAAG,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC,CAAC;IACzC,IAAI,CAAC,IAAI;QAAE,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,gHAAgH,CAAC,CAAC;IACxI,OAAO,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5B,CAAC"}
|
package/dist/commands/import.js
CHANGED
|
@@ -9,11 +9,18 @@ const output_1 = require("../output");
|
|
|
9
9
|
const project_1 = require("../project");
|
|
10
10
|
const vendors_1 = require("../import/vendors");
|
|
11
11
|
const shared_1 = require("./shared");
|
|
12
|
+
const import_better_auth_1 = require("./import-better-auth");
|
|
12
13
|
async function importUsers(ctx, args) {
|
|
13
14
|
const vendor = (0, args_1.str)(args.values, 'from');
|
|
14
15
|
if (!vendor || !vendors_1.VENDORS.includes(vendor)) {
|
|
15
16
|
throw new errors_1.CliError(`import needs --from <${vendors_1.VENDORS.join('|')}>.`);
|
|
16
17
|
}
|
|
18
|
+
// Better Auth: the sealed bundle from `npx atlas-better-auth-export` carries
|
|
19
|
+
// every model (passwords, two-factor, passkeys, orgs, API keys, sessions…);
|
|
20
|
+
// the table-JSON path below stays for exports made without it.
|
|
21
|
+
if (vendor === 'better-auth' && ((0, args_1.str)(args.values, 'bundle') || (0, args_1.str)(args.values, 'import') || !args.positionals[1])) {
|
|
22
|
+
return (0, import_better_auth_1.importBetterAuthBundle)(ctx, args);
|
|
23
|
+
}
|
|
17
24
|
const file = args.positionals[1];
|
|
18
25
|
if (!file)
|
|
19
26
|
throw new errors_1.CliError(`import needs the export file: atlas import --from ${vendor} <file>`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import.js","sourceRoot":"","sources":["../../src/commands/import.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"import.js","sourceRoot":"","sources":["../../src/commands/import.ts"],"names":[],"mappings":";;AAgDA,kCAqGC;AArJD,6CAAyC;AACzC,qCAAkE;AAClE,kCAA+C;AAE/C,sCAAqC;AACrC,sCAAsC;AACtC,wCAAqC;AACrC,+CAA4G;AAC5G,qCAAkD;AAClD,6DAA8D;AAuCvD,KAAK,UAAU,WAAW,CAAC,GAAe,EAAE,IAAgB;IACjE,MAAM,MAAM,GAAG,IAAA,UAAG,EAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAuB,CAAC;IAC9D,IAAI,CAAC,MAAM,IAAI,CAAE,iBAA6B,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAChE,MAAM,IAAI,iBAAQ,CAAC,wBAAwB,iBAAO,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACpE,CAAC;IACD,6EAA6E;IAC7E,4EAA4E;IAC5E,+DAA+D;IAC/D,IAAI,MAAM,KAAK,aAAa,IAAI,CAAC,IAAA,UAAG,EAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,IAAA,UAAG,EAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACnH,OAAO,IAAA,2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IAAI,CAAC,EAAE,CAAC,CAAC;IACjH,CAAC;IACD,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClC,CAAC;AAED,qDAAqD;AACrD,SAAS,MAAM,CAAC,GAAc;IAC5B,OAAO,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,aAAa,EAAE,YAAY,EAAE,GAAG,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;AAC1I,CAAC"}
|
package/dist/commands/migrate.js
CHANGED
|
@@ -8,6 +8,10 @@ const args_1 = require("../args");
|
|
|
8
8
|
const errors_1 = require("../errors");
|
|
9
9
|
const output_1 = require("../output");
|
|
10
10
|
const shared_1 = require("./shared");
|
|
11
|
+
const config_1 = require("./config");
|
|
12
|
+
const orchestrator_1 = require("../migrate/better-auth/orchestrator");
|
|
13
|
+
const output_2 = require("../migrate/better-auth/output");
|
|
14
|
+
const translate_1 = require("../migrate/better-auth/translate");
|
|
11
15
|
/**
|
|
12
16
|
* `atlas migrate code --from <vendor> [path]` — rewrite an app's auth code onto
|
|
13
17
|
* Atlas (Clerk, Auth.js/NextAuth, Supabase Auth, Auth0, Better Auth).
|
|
@@ -19,8 +23,13 @@ const shared_1 = require("./shared");
|
|
|
19
23
|
*/
|
|
20
24
|
async function migrate(ctx, args) {
|
|
21
25
|
const sub = args.positionals[1];
|
|
26
|
+
if (sub === 'better-auth') {
|
|
27
|
+
if (args.positionals[2] === 'config')
|
|
28
|
+
return betterAuthConfig(ctx, args, args.positionals[3]);
|
|
29
|
+
return (0, orchestrator_1.migrateBetterAuth)(ctx, args, args.positionals[2]);
|
|
30
|
+
}
|
|
22
31
|
if (sub !== 'code') {
|
|
23
|
-
throw new errors_1.CliError(sub ? `Unknown subcommand 'migrate ${sub}'. Try: code.` : 'migrate needs a subcommand: code.');
|
|
32
|
+
throw new errors_1.CliError(sub ? `Unknown subcommand 'migrate ${sub}'. Try: code, better-auth.` : 'migrate needs a subcommand: code, better-auth.');
|
|
24
33
|
}
|
|
25
34
|
const raw = (0, args_1.str)(args.values, 'from');
|
|
26
35
|
const vendor = (0, upgrade_1.resolveVendor)(raw);
|
|
@@ -62,4 +71,34 @@ async function migrate(ctx, args) {
|
|
|
62
71
|
ctx.io.out(line);
|
|
63
72
|
return 0;
|
|
64
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* `atlas migrate better-auth config [path]` — offline: read the app's Better Auth
|
|
76
|
+
* setup statically and write the Atlas config-as-code files plus the report.
|
|
77
|
+
* Needs no login; nothing is sent anywhere.
|
|
78
|
+
*/
|
|
79
|
+
async function betterAuthConfig(ctx, args, pathArg) {
|
|
80
|
+
const target = (0, node_path_1.resolve)(pathArg ?? process.cwd());
|
|
81
|
+
if (!(0, node_fs_1.existsSync)(target))
|
|
82
|
+
throw new errors_1.CliError(`Path not found: ${target}`);
|
|
83
|
+
const entry = (0, args_1.str)(args.values, 'entry');
|
|
84
|
+
const analysis = (0, upgrade_1.analyzeBetterAuth)(target, entry ? { entry } : {});
|
|
85
|
+
if (!analysis.instances.length) {
|
|
86
|
+
throw new errors_1.CliError(`No betterAuth({...}) call found under ${target}. Point at the app folder, or pass --entry <file>.`);
|
|
87
|
+
}
|
|
88
|
+
const translation = (0, translate_1.translateBetterAuth)(analysis);
|
|
89
|
+
const format = (0, config_1.resolveFormat)(args.values);
|
|
90
|
+
const root = (0, node_fs_1.statSync)(target).isDirectory() ? target : (0, node_path_1.dirname)(target);
|
|
91
|
+
const dir = (0, node_path_1.resolve)(root, (0, args_1.str)(args.values, 'dir') ?? 'atlas-migrate/config');
|
|
92
|
+
const written = (0, output_2.writeTranslation)(translation, dir, format);
|
|
93
|
+
if ((0, shared_1.wantsJson)(args.values)) {
|
|
94
|
+
(0, output_1.printJson)(ctx.io, { ...(0, output_2.reportJson)(translation), config_dir: dir, files: written });
|
|
95
|
+
return 0;
|
|
96
|
+
}
|
|
97
|
+
for (const line of (0, output_2.summaryLines)(translation, dir, written))
|
|
98
|
+
ctx.io.out(line);
|
|
99
|
+
ctx.io.out('');
|
|
100
|
+
ctx.io.out(`Review the files, then apply them with: atlas config import --dir ${dir} --dry-run`);
|
|
101
|
+
ctx.io.out('Or run the whole program: atlas migrate better-auth');
|
|
102
|
+
return 0;
|
|
103
|
+
}
|
|
65
104
|
//# sourceMappingURL=migrate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../src/commands/migrate.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../src/commands/migrate.ts"],"names":[],"mappings":";;AAsBA,0BAoDC;AA1ED,qCAA+C;AAC/C,yCAA6C;AAC7C,gDAAmI;AACnI,kCAA+C;AAE/C,sCAAqC;AACrC,sCAAsC;AACtC,qCAAqC;AACrC,qCAAyC;AACzC,sEAAwE;AACxE,0DAA2F;AAC3F,gEAAuE;AAEvE;;;;;;;;GAQG;AACI,KAAK,UAAU,OAAO,CAAC,GAAe,EAAE,IAAgB;IAC7D,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAChC,IAAI,GAAG,KAAK,aAAa,EAAE,CAAC;QAC1B,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,QAAQ;YAAE,OAAO,gBAAgB,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9F,OAAO,IAAA,gCAAiB,EAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,CAAC;IACD,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;QACnB,MAAM,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E,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;QACnF,OAAO,CAAC,CAAC;IACX,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,IAAA,qBAAY,EAAC,WAAW,EAAE,GAAG,EAAE,OAAO,CAAC;QAAE,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC7E,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACf,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,qEAAqE,GAAG,YAAY,CAAC,CAAC;IACjG,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,qDAAqD,CAAC,CAAC;IAClE,OAAO,CAAC,CAAC;AACX,CAAC"}
|
package/dist/context.d.ts
CHANGED
|
@@ -49,6 +49,14 @@ export interface RunContext {
|
|
|
49
49
|
fetch?: typeof fetch;
|
|
50
50
|
/** Wait between polls (`--wait`). Optional; defaults to a real timer. */
|
|
51
51
|
sleep?: (ms: number) => Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Run a program with inherited stdio and return its exit code (`atlas migrate
|
|
54
|
+
* better-auth --run-export` runs the exporter in the app). Optional; defaults
|
|
55
|
+
* to a real child process.
|
|
56
|
+
*/
|
|
57
|
+
exec?: (cmd: string, args: string[], opts: {
|
|
58
|
+
cwd: string;
|
|
59
|
+
}) => Promise<number>;
|
|
52
60
|
}
|
|
53
61
|
/**
|
|
54
62
|
* The production context, with any piece overridable. Tests call this with a
|
package/dist/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";;AAgEA,wCAWC;AA3ED,qCAAuC;AACvC,gDAAyE;AACzE,qCAAgF;AAChF,+CAAkE;AAClE,6BAA0C;AAC1C,qCAA0D;AAsD1D;;;;GAIG;AACH,SAAgB,cAAc,CAAC,YAAiC,EAAE;IAChE,OAAO;QACL,EAAE,EAAE,IAAA,cAAS,GAAE;QACf,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,MAAM,EAAE,IAAI,wBAAe,CAAC,IAAA,0BAAiB,GAAE,CAAC;QAChD,MAAM,EAAE,IAAA,wBAAe,GAAE;QACzB,UAAU,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,IAAA,2BAAiB,EAAC,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;QAC/E,QAAQ,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,IAAA,8BAAgB,EAAC,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;QAC5E,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,sBAAY,EAAC,IAAI,EAAE,MAAM,CAAC;QAC9C,GAAG,SAAS;KACb,CAAC;AACJ,CAAC"}
|
package/dist/help.d.ts
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
* out of the handlers so the dispatch code stays about control flow and the
|
|
4
4
|
* copy can be read (and kept consistent) in one place.
|
|
5
5
|
*/
|
|
6
|
-
export declare const TOP_HELP = "atlas \u2014 manage an Atlas instance from the terminal\n\nUsage: atlas <command> [subcommand] [arguments] [options]\n\nCommands:\n login Authenticate and store a profile credential\n logout Remove a stored profile credential\n whoami Show the active profile and instance\n users list|get|create|delete\n orgs list|get|members\n api-keys list|create|revoke\n webhooks list|create\n sessions revoke\n config export|import Config-as-code: round-trip the instance's config\n actions list|deploy|test|logs|gallery|show|install|installs|update|publish\n init Create or complete an app's setup (idempotent); secrets to 0600 files\n preflight Check an instance's setup; non-zero exit on errors (for CI)\n env Print deploy variables: public values + secret file paths\n client rotate Rotate an OAuth client secret straight into its file\n referrals connect|backfill|status\n Connect a referral platform, backfill, check the connection\n import --from <vendor> <file>\n Move users from Auth0, Clerk, Supabase, Firebase, Cognito,\n Auth.js, WorkOS or Better Auth (resumable; --dry-run first)\n migrate code --from <vendor> [path]\n Rewrite an app's auth code onto Atlas (Clerk, Auth.js,\n Supabase, Auth0, Better Auth); a dry run with a diff unless --yes\n info [path] Print the environment for a support ticket (versions, SDKs,\n instance, API latency, preflight); secrets redacted\n mcp install Add the Atlas MCP server (docs search) to Cursor, Claude Code,\n Codex or VS Code\n\nGlobal options:\n --profile <name> Use a named profile (default: active, else \"default\")\n --json Emit raw JSON instead of a human table\n --limit <n> Page size for list commands that paginate\n --starting-after <cursor> Pagination cursor (from a prior page's hint)\n -h, --help Show this help, or help for a command\n -v, --version Print the version\n\nEnvironment overrides:\n ATLAS_SECRET_KEY Secret key to use instead of the stored one\n ATLAS_API_URL API URL to use instead of the stored one\n ATLAS_PLATFORM_KEY Platform key (psk_) for atlas init\n REFERALLY_BASE_URL Referalli base URL for atlas referrals connect\n REFERALLY_API_KEY Referalli merchant key for atlas referrals connect (never stored)\n\nSecrets: a command that receives a secret writes it to a 0600 file under\n~/.config/<product>/ and prints only the path. --print-secret prints it instead.\n\nRun 'atlas <command> --help' for command-specific help.";
|
|
6
|
+
export declare const TOP_HELP = "atlas \u2014 manage an Atlas instance from the terminal\n\nUsage: atlas <command> [subcommand] [arguments] [options]\n\nCommands:\n login Authenticate and store a profile credential\n logout Remove a stored profile credential\n whoami Show the active profile and instance\n users list|get|create|delete\n orgs list|get|members\n api-keys list|create|revoke\n webhooks list|create\n sessions revoke\n config export|import Config-as-code: round-trip the instance's config\n actions list|deploy|test|logs|gallery|show|install|installs|update|publish\n init Create or complete an app's setup (idempotent); secrets to 0600 files\n preflight Check an instance's setup; non-zero exit on errors (for CI)\n env Print deploy variables: public values + secret file paths\n client rotate Rotate an OAuth client secret straight into its file\n referrals connect|backfill|status\n Connect a referral platform, backfill, check the connection\n import --from <vendor> <file>\n Move users from Auth0, Clerk, Supabase, Firebase, Cognito,\n Auth.js, WorkOS or Better Auth (resumable; --dry-run first)\n migrate code --from <vendor> [path]\n Rewrite an app's auth code onto Atlas (Clerk, Auth.js,\n Supabase, Auth0, Better Auth); a dry run with a diff unless --yes\n migrate better-auth [path] Move a Better Auth app to Atlas end to end: config, users,\n sessions and code, resumable (--dry-run, --resume, --yes)\n migrate better-auth config [path]\n Translate the app's betterAuth({...}) options into Atlas\n config files plus a report (offline)\n info [path] Print the environment for a support ticket (versions, SDKs,\n instance, API latency, preflight); secrets redacted\n mcp install Add the Atlas MCP server (docs search) to Cursor, Claude Code,\n Codex or VS Code\n\nGlobal options:\n --profile <name> Use a named profile (default: active, else \"default\")\n --json Emit raw JSON instead of a human table\n --limit <n> Page size for list commands that paginate\n --starting-after <cursor> Pagination cursor (from a prior page's hint)\n -h, --help Show this help, or help for a command\n -v, --version Print the version\n\nEnvironment overrides:\n ATLAS_SECRET_KEY Secret key to use instead of the stored one\n ATLAS_API_URL API URL to use instead of the stored one\n ATLAS_PLATFORM_KEY Platform key (psk_) for atlas init\n REFERALLY_BASE_URL Referalli base URL for atlas referrals connect\n REFERALLY_API_KEY Referalli merchant key for atlas referrals connect (never stored)\n\nSecrets: a command that receives a secret writes it to a 0600 file under\n~/.config/<product>/ and prints only the path. --print-secret prints it instead.\n\nRun 'atlas <command> --help' for command-specific help.";
|
|
7
7
|
/** Per-command help, keyed by the resource word. */
|
|
8
8
|
export declare const COMMAND_HELP: Record<string, string>;
|
package/dist/help.js
CHANGED
|
@@ -33,6 +33,11 @@ Commands:
|
|
|
33
33
|
migrate code --from <vendor> [path]
|
|
34
34
|
Rewrite an app's auth code onto Atlas (Clerk, Auth.js,
|
|
35
35
|
Supabase, Auth0, Better Auth); a dry run with a diff unless --yes
|
|
36
|
+
migrate better-auth [path] Move a Better Auth app to Atlas end to end: config, users,
|
|
37
|
+
sessions and code, resumable (--dry-run, --resume, --yes)
|
|
38
|
+
migrate better-auth config [path]
|
|
39
|
+
Translate the app's betterAuth({...}) options into Atlas
|
|
40
|
+
config files plus a report (offline)
|
|
36
41
|
info [path] Print the environment for a support ticket (versions, SDKs,
|
|
37
42
|
instance, API latency, preflight); secrets redacted
|
|
38
43
|
mcp install Add the Atlas MCP server (docs search) to Cursor, Claude Code,
|
|
@@ -59,10 +64,38 @@ Secrets: a command that receives a secret writes it to a 0600 file under
|
|
|
59
64
|
Run 'atlas <command> --help' for command-specific help.`;
|
|
60
65
|
/** Per-command help, keyed by the resource word. */
|
|
61
66
|
exports.COMMAND_HELP = {
|
|
62
|
-
migrate: `atlas migrate
|
|
67
|
+
migrate: `atlas migrate — move an app's auth onto Atlas
|
|
63
68
|
|
|
64
69
|
Usage:
|
|
65
70
|
atlas migrate code --from <vendor> [path] [--yes] [--json]
|
|
71
|
+
atlas migrate better-auth config [path] [--dir <dir>] [--format json|yaml] [--entry <file>] [--json]
|
|
72
|
+
atlas migrate better-auth [path] [--dry-run] [--yes] [--resume] [--force] [--json]
|
|
73
|
+
[--dir <dir>] [--state-file <file>] [--entry <file>] [--bundle <file>] [--run-export]
|
|
74
|
+
[--confirm-conflicts] [--bridge-days <n>] [--skip <step,...>]
|
|
75
|
+
|
|
76
|
+
migrate better-auth config reads your betterAuth({...}) setup statically (it
|
|
77
|
+
follows imports and resolves env vars by NAME, never their values) and writes
|
|
78
|
+
Atlas config-as-code files (the 'atlas config import' format) plus
|
|
79
|
+
better-auth-report.md: what maps 1:1, what maps with a difference, and what
|
|
80
|
+
needs a manual step, each with file:line. Default --dir: atlas-migrate/config.
|
|
81
|
+
|
|
82
|
+
migrate better-auth runs the whole program, checkpointing each step in
|
|
83
|
+
atlas-migrate/state.json (--state-file):
|
|
84
|
+
preflight instance and key, CLI version, the betterAuth() call
|
|
85
|
+
translate the config files and report (as above)
|
|
86
|
+
apply review the diff, confirm, push the config (env placeholders are
|
|
87
|
+
filled from the environment and the app's .env files)
|
|
88
|
+
export run the exporter in the app (prints the command; --run-export runs it)
|
|
89
|
+
import upload the bundle, dry-run report, confirm, import (conflicts with
|
|
90
|
+
existing Atlas users need --confirm-conflicts; a stopped import resumes)
|
|
91
|
+
bridge accept Better Auth sessions for --bridge-days (default 30): no forced logout
|
|
92
|
+
code atlas migrate code --from better-auth, after a confirmation
|
|
93
|
+
verify counts, preflight and a sign-in checklist
|
|
94
|
+
--dry-run walks every step without changing the instance or the code. --yes
|
|
95
|
+
answers every confirmation. --resume continues a stopped run. --json prints the
|
|
96
|
+
step summary (with --json and no --yes it stops at the first confirmation).
|
|
97
|
+
|
|
98
|
+
Code rewrite (migrate code):
|
|
66
99
|
|
|
67
100
|
Vendors:
|
|
68
101
|
clerk @clerk/* SDKs
|
|
@@ -100,6 +133,9 @@ reported, not fatal. Anything shaped like a secret is redacted.`,
|
|
|
100
133
|
|
|
101
134
|
Usage:
|
|
102
135
|
atlas import --from <vendor> <export-file> [--dry-run]
|
|
136
|
+
atlas import --from better-auth --bundle <file> [--dry-run] [--yes]
|
|
137
|
+
atlas import --from better-auth --import <id> [--confirm-conflicts]
|
|
138
|
+
atlas import --from better-auth (prints the import key and export command)
|
|
103
139
|
|
|
104
140
|
Vendors and the file each one reads:
|
|
105
141
|
auth0 the user export job (NDJSON/JSON); --hashes <file> merges the password export
|
|
@@ -120,6 +156,13 @@ Options:
|
|
|
120
156
|
--create-orgs Create organizations that memberships name but that do not exist yet
|
|
121
157
|
--json Machine-readable summary
|
|
122
158
|
|
|
159
|
+
Better Auth bundle (npx atlas-better-auth-export --out <file> --public-key <key>):
|
|
160
|
+
--bundle <file> Upload the sealed bundle, show the dry run, then apply
|
|
161
|
+
--import <id> Continue an uploaded import (apply it, or resume a failed one)
|
|
162
|
+
--confirm-conflicts Apply although the dry run found conflicts with existing users
|
|
163
|
+
--options <json|@file> Import options, e.g. '{"import_sessions":false}'
|
|
164
|
+
--yes Apply without asking
|
|
165
|
+
|
|
123
166
|
Batches are sent with upsert, so a resumed or repeated run never duplicates a
|
|
124
167
|
user or a membership. Exit code 2 means some rows were reported as issues.`,
|
|
125
168
|
mcp: `atlas mcp — connect AI coding agents to Atlas
|
package/dist/help.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.js","sourceRoot":"","sources":["../src/help.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEU,QAAA,QAAQ,GAAG
|
|
1
|
+
{"version":3,"file":"help.js","sourceRoot":"","sources":["../src/help.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEU,QAAA,QAAQ,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wDAuDgC,CAAC;AAEzD,oDAAoD;AACvC,QAAA,YAAY,GAA2B;IAClD,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8CAqDmC;IAC5C,IAAI,EAAE;;;;;;;;;;gEAUwD;IAC9D,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2EAmCiE;IACzE,GAAG,EAAE;;;;;;;;;;;;;;;+CAewC;IAC7C,SAAS,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yEAmC4D;IAEvE,KAAK,EAAE;;;;;;mCAM0B;IAEjC,MAAM,EAAE;;uCAE6B;IAErC,MAAM,EAAE;;gDAEsC;IAE9C,KAAK,EAAE;;;;;;wCAM+B;IAEtC,IAAI,EAAE;;;;;uCAK+B;IAErC,UAAU,EAAE;;;;;;8CAMgC;IAE5C,QAAQ,EAAE;;;;;;0EAM8D;IAExE,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;yEA4BiE;IAEvE,SAAS,EAAE;;;;;;oDAMuC;IAElD,GAAG,EAAE;;;;;;;qDAO8C;IAEnD,MAAM,EAAE;;;;;;;;wDAQ8C;IAEtD,QAAQ,EAAE;;;8CAGkC;IAE5C,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;8EAoBoE;IAC5E,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;qEA0B0D;CACpE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -25,3 +25,7 @@ export { preflight, envCommand, client } from './commands/project-commands';
|
|
|
25
25
|
export { referrals } from './commands/referrals';
|
|
26
26
|
export { writeSecretFile, readEnvFile, parseDotenv, renderDotenv, productDir, deliverSecret, } from './secrets';
|
|
27
27
|
export { readManifest, writeManifest, manifestPath, type ProjectManifest, type ProjectInstance, type InstanceEnv, } from './project';
|
|
28
|
+
export { migrate } from './commands/migrate';
|
|
29
|
+
export { planConfigImport, type ConfigPlan, type PlannedChange } from './commands/config';
|
|
30
|
+
export { translateBetterAuth, type Translation, type ReportEntry, type ConfigDocument } from './migrate/better-auth/translate';
|
|
31
|
+
export { migrateBetterAuth, STEPS as BETTER_AUTH_MIGRATION_STEPS } from './migrate/better-auth/orchestrator';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.manifestPath = exports.writeManifest = exports.readManifest = exports.deliverSecret = exports.productDir = exports.renderDotenv = exports.parseDotenv = exports.readEnvFile = exports.writeSecretFile = exports.referrals = exports.client = exports.envCommand = exports.preflight = exports.init = exports.actions = exports.config = exports.sessions = exports.webhooks = exports.apiKeys = exports.orgs = exports.users = exports.whoami = exports.logout = exports.login = exports.getVersion = exports.defaultPrompter = exports.defaultConfigPath = exports.MemoryConfigStore = exports.FileConfigStore = exports.captureIO = exports.defaultIO = exports.CliError = exports.isNotFound = exports.createConfigHttp = exports.defaultContext = exports.run = void 0;
|
|
3
|
+
exports.BETTER_AUTH_MIGRATION_STEPS = exports.migrateBetterAuth = exports.translateBetterAuth = exports.planConfigImport = exports.migrate = exports.manifestPath = exports.writeManifest = exports.readManifest = exports.deliverSecret = exports.productDir = exports.renderDotenv = exports.parseDotenv = exports.readEnvFile = exports.writeSecretFile = exports.referrals = exports.client = exports.envCommand = exports.preflight = exports.init = exports.actions = exports.config = exports.sessions = exports.webhooks = exports.apiKeys = exports.orgs = exports.users = exports.whoami = exports.logout = exports.login = exports.getVersion = exports.defaultPrompter = exports.defaultConfigPath = exports.MemoryConfigStore = exports.FileConfigStore = exports.captureIO = exports.defaultIO = exports.CliError = exports.isNotFound = exports.createConfigHttp = exports.defaultContext = exports.run = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Library surface of `@atlasauth/cli`. The package ships a bin (`atlas`), but
|
|
6
6
|
* exporting the pieces lets the handlers be unit-tested with injected deps and
|
|
@@ -65,4 +65,13 @@ var project_1 = require("./project");
|
|
|
65
65
|
Object.defineProperty(exports, "readManifest", { enumerable: true, get: function () { return project_1.readManifest; } });
|
|
66
66
|
Object.defineProperty(exports, "writeManifest", { enumerable: true, get: function () { return project_1.writeManifest; } });
|
|
67
67
|
Object.defineProperty(exports, "manifestPath", { enumerable: true, get: function () { return project_1.manifestPath; } });
|
|
68
|
+
var migrate_1 = require("./commands/migrate");
|
|
69
|
+
Object.defineProperty(exports, "migrate", { enumerable: true, get: function () { return migrate_1.migrate; } });
|
|
70
|
+
var config_3 = require("./commands/config");
|
|
71
|
+
Object.defineProperty(exports, "planConfigImport", { enumerable: true, get: function () { return config_3.planConfigImport; } });
|
|
72
|
+
var translate_1 = require("./migrate/better-auth/translate");
|
|
73
|
+
Object.defineProperty(exports, "translateBetterAuth", { enumerable: true, get: function () { return translate_1.translateBetterAuth; } });
|
|
74
|
+
var orchestrator_1 = require("./migrate/better-auth/orchestrator");
|
|
75
|
+
Object.defineProperty(exports, "migrateBetterAuth", { enumerable: true, get: function () { return orchestrator_1.migrateBetterAuth; } });
|
|
76
|
+
Object.defineProperty(exports, "BETTER_AUTH_MIGRATION_STEPS", { enumerable: true, get: function () { return orchestrator_1.STEPS; } });
|
|
68
77
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,6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AAA;AACV,wGAAA,aAAa,OAAA;AAEf,qCAOmB;AANjB,uGAAA,YAAY,OAAA;AACZ,wGAAA,aAAa,OAAA;AACb,uGAAA,YAAY,OAAA;AAKd,8CAA6C;AAApC,kGAAA,OAAO,OAAA;AAChB,4CAA0F;AAAjF,0GAAA,gBAAgB,OAAA;AACzB,6DAA+H;AAAtH,gHAAA,mBAAmB,OAAA;AAC5B,mEAA6G;AAApG,iHAAA,iBAAiB,OAAA;AAAE,2HAAA,KAAK,OAA+B"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type BetterAuthImport, type BetterAuthImportOptions } from '@atlasauth/backend';
|
|
2
|
+
import type { ConfigHttp } from '../../config-http';
|
|
3
|
+
/**
|
|
4
|
+
* Every call the Better Auth migration makes into the import and session-bridge
|
|
5
|
+
* APIs lives in this one module:
|
|
6
|
+
*
|
|
7
|
+
* - the export/import pair: the `@atlasauth/better-auth-migrate` exporter seals
|
|
8
|
+
* a bundle to the instance's import key (`GET /v1/better_auth_imports/public_key`),
|
|
9
|
+
* which is uploaded in line-split parts, finalized (which runs the dry run)
|
|
10
|
+
* and applied under `/v1/better_auth_imports`, and
|
|
11
|
+
* - the session bridge (`/v1/migrations/better_auth/bridge`), which lets a live
|
|
12
|
+
* Better Auth session become an Atlas session during the cutover window.
|
|
13
|
+
*/
|
|
14
|
+
/** The exporter's documented command line. */
|
|
15
|
+
export declare const EXPORTER_BIN = "atlas-better-auth-export";
|
|
16
|
+
export declare const EXPORTER_PACKAGE = "@atlasauth/better-auth-migrate";
|
|
17
|
+
/** `publicKey` is the key's compact `kid:public_key` form. */
|
|
18
|
+
export declare function exporterCommand(opts: {
|
|
19
|
+
out: string;
|
|
20
|
+
publicKey: string;
|
|
21
|
+
}): {
|
|
22
|
+
cmd: string;
|
|
23
|
+
args: string[];
|
|
24
|
+
display: string;
|
|
25
|
+
};
|
|
26
|
+
/** The import key the exporter seals the bundle to (the private half stays with Atlas), as `kid:public_key`. */
|
|
27
|
+
export declare function getImportPublicKey(http: ConfigHttp): Promise<string>;
|
|
28
|
+
export type ImportJob = BetterAuthImport;
|
|
29
|
+
/** Statuses an import rests in; anything else is still being worked on. */
|
|
30
|
+
export declare const RESTING_STATUSES: readonly string[];
|
|
31
|
+
/**
|
|
32
|
+
* Upload a sealed bundle: create the import, send it in line-split parts of at
|
|
33
|
+
* most 8 MiB, then finalize (which checks the parts and the key and runs the
|
|
34
|
+
* dry run; a large bundle comes back `analyzing` and finishes in the background).
|
|
35
|
+
*/
|
|
36
|
+
export declare function uploadBundle(http: ConfigHttp, opts: {
|
|
37
|
+
bundle: string;
|
|
38
|
+
options?: BetterAuthImportOptions;
|
|
39
|
+
onPart?: (n: number, of: number) => void;
|
|
40
|
+
}): Promise<ImportJob>;
|
|
41
|
+
export declare function getImport(http: ConfigHttp, id: string): Promise<ImportJob>;
|
|
42
|
+
/** Finalize an import whose upload finished but was never finalized. */
|
|
43
|
+
export declare function finalizeImport(http: ConfigHttp, id: string): Promise<ImportJob>;
|
|
44
|
+
/** Apply a dry-run-ready import, or resume a failed one from where it stopped. */
|
|
45
|
+
export declare function applyImport(http: ConfigHttp, id: string, opts: {
|
|
46
|
+
confirmConflicts: boolean;
|
|
47
|
+
}): Promise<ImportJob>;
|
|
48
|
+
export interface BridgeSettings {
|
|
49
|
+
/** Better Auth's `advanced.cookiePrefix` (default `better-auth`). */
|
|
50
|
+
cookiePrefix: string;
|
|
51
|
+
/** When the bridge stops accepting Better Auth sessions (epoch ms). */
|
|
52
|
+
endsAt: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Turn the Better Auth session bridge on for a window. The old app's Better
|
|
56
|
+
* Auth secret is stored write-only so Atlas can check the cookie signature
|
|
57
|
+
* (the live fallback to the old app stays off unless set up separately).
|
|
58
|
+
*/
|
|
59
|
+
export declare function enableSessionBridge(http: ConfigHttp, settings: BridgeSettings, secret: string): Promise<void>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RESTING_STATUSES = exports.EXPORTER_PACKAGE = exports.EXPORTER_BIN = void 0;
|
|
4
|
+
exports.exporterCommand = exporterCommand;
|
|
5
|
+
exports.getImportPublicKey = getImportPublicKey;
|
|
6
|
+
exports.uploadBundle = uploadBundle;
|
|
7
|
+
exports.getImport = getImport;
|
|
8
|
+
exports.finalizeImport = finalizeImport;
|
|
9
|
+
exports.applyImport = applyImport;
|
|
10
|
+
exports.enableSessionBridge = enableSessionBridge;
|
|
11
|
+
const backend_1 = require("@atlasauth/backend");
|
|
12
|
+
/**
|
|
13
|
+
* Every call the Better Auth migration makes into the import and session-bridge
|
|
14
|
+
* APIs lives in this one module:
|
|
15
|
+
*
|
|
16
|
+
* - the export/import pair: the `@atlasauth/better-auth-migrate` exporter seals
|
|
17
|
+
* a bundle to the instance's import key (`GET /v1/better_auth_imports/public_key`),
|
|
18
|
+
* which is uploaded in line-split parts, finalized (which runs the dry run)
|
|
19
|
+
* and applied under `/v1/better_auth_imports`, and
|
|
20
|
+
* - the session bridge (`/v1/migrations/better_auth/bridge`), which lets a live
|
|
21
|
+
* Better Auth session become an Atlas session during the cutover window.
|
|
22
|
+
*/
|
|
23
|
+
/** The exporter's documented command line. */
|
|
24
|
+
exports.EXPORTER_BIN = 'atlas-better-auth-export';
|
|
25
|
+
exports.EXPORTER_PACKAGE = '@atlasauth/better-auth-migrate';
|
|
26
|
+
/** `publicKey` is the key's compact `kid:public_key` form. */
|
|
27
|
+
function exporterCommand(opts) {
|
|
28
|
+
const args = ['--yes', exports.EXPORTER_BIN, '--out', opts.out, '--public-key', opts.publicKey];
|
|
29
|
+
return { cmd: 'npx', args, display: `npx ${exports.EXPORTER_BIN} --out ${opts.out} --public-key ${opts.publicKey}` };
|
|
30
|
+
}
|
|
31
|
+
/** The import key the exporter seals the bundle to (the private half stays with Atlas), as `kid:public_key`. */
|
|
32
|
+
async function getImportPublicKey(http) {
|
|
33
|
+
const key = await http.get('/v1/better_auth_imports/public_key');
|
|
34
|
+
if (!key?.compact)
|
|
35
|
+
throw new Error('The instance did not return an import key.');
|
|
36
|
+
return key.compact;
|
|
37
|
+
}
|
|
38
|
+
/** Statuses an import rests in; anything else is still being worked on. */
|
|
39
|
+
exports.RESTING_STATUSES = ['uploading', 'ready', 'invalid', 'completed', 'failed'];
|
|
40
|
+
const importPath = (id, sub = '') => `/v1/better_auth_imports/${encodeURIComponent(id)}${sub}`;
|
|
41
|
+
/**
|
|
42
|
+
* Upload a sealed bundle: create the import, send it in line-split parts of at
|
|
43
|
+
* most 8 MiB, then finalize (which checks the parts and the key and runs the
|
|
44
|
+
* dry run; a large bundle comes back `analyzing` and finishes in the background).
|
|
45
|
+
*/
|
|
46
|
+
async function uploadBundle(http, opts) {
|
|
47
|
+
const parts = (0, backend_1.splitBundleParts)(opts.bundle);
|
|
48
|
+
if (parts.length === 0)
|
|
49
|
+
throw new Error('The bundle is empty.');
|
|
50
|
+
const created = await http.post('/v1/better_auth_imports', opts.options ? { options: opts.options } : {});
|
|
51
|
+
for (let i = 0; i < parts.length; i++) {
|
|
52
|
+
await http.put(importPath(created.id, `/parts/${i + 1}`), { data: parts[i] });
|
|
53
|
+
opts.onPart?.(i + 1, parts.length);
|
|
54
|
+
}
|
|
55
|
+
return http.post(importPath(created.id, '/finalize'), {});
|
|
56
|
+
}
|
|
57
|
+
async function getImport(http, id) {
|
|
58
|
+
return http.get(importPath(id));
|
|
59
|
+
}
|
|
60
|
+
/** Finalize an import whose upload finished but was never finalized. */
|
|
61
|
+
async function finalizeImport(http, id) {
|
|
62
|
+
return http.post(importPath(id, '/finalize'), {});
|
|
63
|
+
}
|
|
64
|
+
/** Apply a dry-run-ready import, or resume a failed one from where it stopped. */
|
|
65
|
+
async function applyImport(http, id, opts) {
|
|
66
|
+
return http.post(importPath(id, '/apply'), opts.confirmConflicts ? { confirm_conflicts: true } : {});
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Turn the Better Auth session bridge on for a window. The old app's Better
|
|
70
|
+
* Auth secret is stored write-only so Atlas can check the cookie signature
|
|
71
|
+
* (the live fallback to the old app stays off unless set up separately).
|
|
72
|
+
*/
|
|
73
|
+
async function enableSessionBridge(http, settings, secret) {
|
|
74
|
+
await http.put('/v1/migrations/better_auth/bridge', {
|
|
75
|
+
enabled: true,
|
|
76
|
+
ends_at: settings.endsAt,
|
|
77
|
+
cookie_prefix: settings.cookiePrefix,
|
|
78
|
+
live_fallback: { secret },
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=integration.js.map
|