direct-auth 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +486 -2
- package/dist/accounts.d.ts +118 -0
- package/dist/accounts.js +314 -0
- package/dist/apps.d.ts +85 -0
- package/dist/apps.js +449 -0
- package/dist/auth.d.ts +396 -0
- package/dist/auth.js +699 -0
- package/dist/base64.d.ts +20 -0
- package/dist/base64.js +45 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +463 -0
- package/dist/client.d.ts +170 -0
- package/dist/client.js +438 -0
- package/dist/codes.d.ts +81 -0
- package/dist/codes.js +91 -0
- package/dist/crypto.d.ts +11 -0
- package/dist/crypto.js +37 -0
- package/dist/d1.d.ts +2 -0
- package/dist/d1.js +2 -0
- package/dist/db/limits.d.ts +16 -0
- package/dist/db/limits.js +23 -0
- package/dist/db/schema.d.ts +25 -0
- package/dist/db/schema.js +136 -0
- package/dist/db/sql.d.ts +52 -0
- package/dist/db/sql.js +121 -0
- package/dist/dns.d.ts +48 -0
- package/dist/dns.js +133 -0
- package/dist/env.d.ts +39 -0
- package/dist/env.js +169 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +14 -0
- package/dist/init.d.ts +134 -0
- package/dist/init.js +912 -0
- package/dist/jwks.d.ts +18 -0
- package/dist/jwks.js +63 -0
- package/dist/jwt.d.ts +90 -0
- package/dist/jwt.js +99 -0
- package/dist/keys.d.ts +33 -0
- package/dist/keys.js +54 -0
- package/dist/messages.d.ts +26 -0
- package/dist/messages.js +57 -0
- package/dist/migrate-cli.d.ts +82 -0
- package/dist/migrate-cli.js +564 -0
- package/dist/migrate.d.ts +99 -0
- package/dist/migrate.js +396 -0
- package/dist/node.d.ts +16 -0
- package/dist/node.js +63 -0
- package/dist/passkeys.d.ts +126 -0
- package/dist/passkeys.js +383 -0
- package/dist/passwords.d.ts +53 -0
- package/dist/passwords.js +326 -0
- package/dist/pgwire.d.ts +86 -0
- package/dist/pgwire.js +445 -0
- package/dist/phone.d.ts +11 -0
- package/dist/phone.js +18 -0
- package/dist/postgres.d.ts +2 -0
- package/dist/postgres.js +2 -0
- package/dist/providers/apple-revoke.d.ts +55 -0
- package/dist/providers/apple-revoke.js +113 -0
- package/dist/providers/apple.d.ts +28 -0
- package/dist/providers/apple.js +51 -0
- package/dist/providers/github.d.ts +28 -0
- package/dist/providers/github.js +67 -0
- package/dist/providers/google.d.ts +23 -0
- package/dist/providers/google.js +47 -0
- package/dist/providers/identity.d.ts +24 -0
- package/dist/providers/identity.js +3 -0
- package/dist/proxy.d.ts +19 -0
- package/dist/proxy.js +43 -0
- package/dist/records.d.ts +91 -0
- package/dist/records.js +264 -0
- package/dist/scrypt.d.ts +26 -0
- package/dist/scrypt.js +179 -0
- package/dist/senders/aws.d.ts +13 -0
- package/dist/senders/aws.js +47 -0
- package/dist/senders/dev.d.ts +6 -0
- package/dist/senders/dev.js +13 -0
- package/dist/senders/index.d.ts +5 -0
- package/dist/senders/index.js +4 -0
- package/dist/senders/mail.d.ts +26 -0
- package/dist/senders/mail.js +66 -0
- package/dist/senders/sms.d.ts +34 -0
- package/dist/senders/sms.js +69 -0
- package/dist/senders/smtp.d.ts +32 -0
- package/dist/senders/smtp.js +145 -0
- package/dist/senders/types.d.ts +31 -0
- package/dist/senders/types.js +25 -0
- package/dist/server.d.ts +67 -0
- package/dist/server.js +494 -0
- package/dist/sessions.d.ts +74 -0
- package/dist/sessions.js +146 -0
- package/dist/skill.d.ts +25 -0
- package/dist/skill.js +66 -0
- package/dist/sources.d.ts +138 -0
- package/dist/sources.js +931 -0
- package/dist/sqlite.d.ts +2 -0
- package/dist/sqlite.js +2 -0
- package/dist/stores/d1.d.ts +22 -0
- package/dist/stores/d1.js +23 -0
- package/dist/stores/postgres.d.ts +33 -0
- package/dist/stores/postgres.js +71 -0
- package/dist/stores/sqlite.d.ts +27 -0
- package/dist/stores/sqlite.js +55 -0
- package/dist/supabase.d.ts +71 -0
- package/dist/supabase.js +283 -0
- package/dist/tui.d.ts +178 -0
- package/dist/tui.js +537 -0
- package/package.json +90 -4
- package/skills/direct-auth/SKILL.md +101 -0
|
@@ -0,0 +1,564 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `direct-auth migrate`: the four steps on the command line, for a person. Connect (the database URL asked with
|
|
3
|
+
* its password hidden), a dry run (what moves, what needs a hand), the move after a typed yes (the way back written
|
|
4
|
+
* first), and a check that it all arrived; then the next steps for the source. Only counts and masked ids are ever
|
|
5
|
+
* shown: no address, no hash, no URL with its password.
|
|
6
|
+
*/
|
|
7
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
8
|
+
import { gunzipSync } from "node:zlib";
|
|
9
|
+
import { SOURCES, maskId, supabaseRef } from "./migrate.js";
|
|
10
|
+
import { supabasePendingSql } from "./supabase.js";
|
|
11
|
+
import { checkExport, moveParts, parseFirebaseHash } from "./sources.js";
|
|
12
|
+
/** A file as text, gunzipped first when it is gzip (Auth0's export downloads as `.json.gz`). */
|
|
13
|
+
export function readExport(path) {
|
|
14
|
+
const b = readFileSync(path);
|
|
15
|
+
return (b[0] === 0x1f && b[1] === 0x8b ? gunzipSync(b) : b).toString("utf8");
|
|
16
|
+
}
|
|
17
|
+
/** Where each source's sign-ins and sign-ups go off. */
|
|
18
|
+
const OFF = {
|
|
19
|
+
supabase: "Authentication › Sign In / Providers",
|
|
20
|
+
firebase: "Authentication › Settings › User actions, and each provider in Sign-in method",
|
|
21
|
+
clerk: "Configure › Restrictions › Sign-up mode: Restricted",
|
|
22
|
+
auth0: "the connections' Disable Sign Ups",
|
|
23
|
+
authjs: "in the app: the old version's sign-in routes",
|
|
24
|
+
"better-auth": "in the app: disableSignUp, and the old version's routes",
|
|
25
|
+
};
|
|
26
|
+
/** The list of sources, by number. */
|
|
27
|
+
async function pickSource(io) {
|
|
28
|
+
io.say("");
|
|
29
|
+
io.say("Where are the users now?");
|
|
30
|
+
const w = Math.max(...SOURCES.map((s) => s.label.length)) + 3;
|
|
31
|
+
SOURCES.forEach((s, i) => io.say(` ${i + 1} ${s.label.padEnd(w)}${FROM[s.id]?.what ?? ""}`));
|
|
32
|
+
for (;;) {
|
|
33
|
+
const a = (await io.ask(" Number: ")).trim();
|
|
34
|
+
const n = Number(a);
|
|
35
|
+
if (Number.isInteger(n) && n >= 1 && n <= SOURCES.length)
|
|
36
|
+
return SOURCES[n - 1].id;
|
|
37
|
+
const byId = SOURCES.find((s) => s.id === a.toLowerCase());
|
|
38
|
+
if (byId)
|
|
39
|
+
return byId.id;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** A path asked until it is a file that reads as `check` wants; "" when optional and skipped. */
|
|
43
|
+
async function askFile(io, question, read, check, optional = false) {
|
|
44
|
+
for (;;) {
|
|
45
|
+
const path = (await io.ask(` ${question}${optional ? " [Enter: none]" : ""}: `)).trim().replace(/^(['"])(.*)\1$/, "$2");
|
|
46
|
+
if (!path) {
|
|
47
|
+
if (optional)
|
|
48
|
+
return undefined;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (!existsSync(path)) {
|
|
52
|
+
io.say(" No such file.", "bad");
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const text = read(path);
|
|
56
|
+
const problem = check(text);
|
|
57
|
+
if (!problem)
|
|
58
|
+
return { path, text };
|
|
59
|
+
io.say(` ${problem}`, "bad");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/** A file source's inputs: from the flags, or asked (the export checked, a secret hidden). */
|
|
63
|
+
async function askInputs(io, id, o, read) {
|
|
64
|
+
const input = {};
|
|
65
|
+
const given = (path, what, check) => {
|
|
66
|
+
let text;
|
|
67
|
+
try {
|
|
68
|
+
text = read(path);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
io.say(`${what}: no such file (${path}).`, "bad");
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
const problem = check(text);
|
|
75
|
+
if (problem) {
|
|
76
|
+
io.say(`${what}: ${problem}`, "bad");
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
return text;
|
|
80
|
+
};
|
|
81
|
+
const check = (t) => checkExport(id, t);
|
|
82
|
+
if (o.file) {
|
|
83
|
+
input.users = given(o.file, "The export", check);
|
|
84
|
+
if (input.users === undefined)
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
else if (o.yes) {
|
|
88
|
+
io.say("--file is needed with --yes: the export.", "bad");
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
const f = await askFile(io, id === "clerk" ? "The CSV export" : "The export file", read, check);
|
|
93
|
+
input.users = f.text;
|
|
94
|
+
}
|
|
95
|
+
if (id === "auth0") {
|
|
96
|
+
if (o.hashes) {
|
|
97
|
+
input.hashes = given(o.hashes, "The hashes file", (t) => checkExport("auth0-hashes", t));
|
|
98
|
+
if (input.hashes === undefined)
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
else if (!o.yes) {
|
|
102
|
+
io.say(" Auth0 gives the password hashes only through its support. Without them, database users sign in with an email code, and can set a password then.", "dim");
|
|
103
|
+
input.hashes = (await askFile(io, "The hashes file", read, (t) => checkExport("auth0-hashes", t), true))?.text;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (id === "firebase") {
|
|
107
|
+
if (o.hashConfig) {
|
|
108
|
+
const text = given(o.hashConfig, "The hash parameters", (t) => (parseFirebaseHash(t) ? undefined : "no base64_signer_key, base64_salt_separator, rounds and mem_cost in it"));
|
|
109
|
+
if (text === undefined)
|
|
110
|
+
return undefined;
|
|
111
|
+
input.firebase = parseFirebaseHash(text);
|
|
112
|
+
}
|
|
113
|
+
else if (!o.yes) {
|
|
114
|
+
io.say(" The project's password hash parameters (Authentication › Users › ⋮ › Password hash parameters). Without them the passwords stay behind, and those users sign in with an email code.", "dim");
|
|
115
|
+
const key = (await (io.askSecret ?? io.ask)(" base64_signer_key (hidden) [Enter: no passwords]: ")).trim();
|
|
116
|
+
if (key) {
|
|
117
|
+
const firebase = { signerKey: key, saltSeparator: "Bw==", rounds: 8, memCost: 14 };
|
|
118
|
+
firebase.saltSeparator = (await io.ask(" base64_salt_separator [Bw==]: ")).trim() || "Bw==";
|
|
119
|
+
firebase.rounds = Number((await io.ask(" rounds [8]: ")).trim() || 8);
|
|
120
|
+
firebase.memCost = Number((await io.ask(" mem_cost [14]: ")).trim() || 14);
|
|
121
|
+
const ok = parseFirebaseHash(`base64_signer_key: ${firebase.signerKey}\nbase64_salt_separator: ${firebase.saltSeparator}\nrounds: ${firebase.rounds}\nmem_cost: ${firebase.memCost}`);
|
|
122
|
+
if (!ok) {
|
|
123
|
+
io.say(" Those aren't Firebase's parameters (base64 key and separator, rounds 1 to 8, mem_cost 1 to 14).", "bad");
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
input.firebase = ok;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return input;
|
|
131
|
+
}
|
|
132
|
+
/** What each source is, as the list shows it, and where its users come from. */
|
|
133
|
+
export const FROM = {
|
|
134
|
+
supabase: {
|
|
135
|
+
what: "the same database: auth.users",
|
|
136
|
+
where: "Supabase: Project Settings › Database › Connection string (the session pooler, or the direct one).",
|
|
137
|
+
db: "The database where Supabase Auth keeps its users: the direct-auth tables go beside them.",
|
|
138
|
+
},
|
|
139
|
+
firebase: {
|
|
140
|
+
what: "an export file (firebase auth:export)",
|
|
141
|
+
where: "firebase auth:export users.json --format=json --project <id>; the hash parameters: Authentication › Users › ⋮ › Password hash parameters.",
|
|
142
|
+
db: "The Postgres database your server will use: direct-auth's tables are made there.",
|
|
143
|
+
},
|
|
144
|
+
authjs: {
|
|
145
|
+
what: "its tables in your Postgres",
|
|
146
|
+
where: "Auth.js's database adapter tables (users, accounts) in the public schema.",
|
|
147
|
+
db: "The database with Auth.js's tables: direct-auth's go beside them.",
|
|
148
|
+
},
|
|
149
|
+
"better-auth": {
|
|
150
|
+
what: "its tables in your Postgres",
|
|
151
|
+
where: "Better Auth's tables (user, account) in the public schema.",
|
|
152
|
+
db: "The database with Better Auth's tables: direct-auth's go beside them.",
|
|
153
|
+
},
|
|
154
|
+
clerk: {
|
|
155
|
+
what: "the dashboard's CSV export",
|
|
156
|
+
where: "Clerk Dashboard › Settings › User exports (a CSV with the password digests).",
|
|
157
|
+
db: "The Postgres database your server will use: direct-auth's tables are made there.",
|
|
158
|
+
},
|
|
159
|
+
auth0: {
|
|
160
|
+
what: "a bulk export (NDJSON)",
|
|
161
|
+
where: "Auth0: a users export job (format json) with the fields user_id, email, email_verified, name, identities, phone_number, phone_verified, blocked, multifactor, created_at, last_login. Its .json.gz reads as it is. The hashes only through Auth0's support.",
|
|
162
|
+
db: "The Postgres database your server will use: direct-auth's tables are made there.",
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
export async function migrate(io, o) {
|
|
166
|
+
let from = o.from;
|
|
167
|
+
if (!from) {
|
|
168
|
+
if (o.yes) {
|
|
169
|
+
io.say(`--from is needed with --yes: ${SOURCES.map((s) => s.id).join(", ")}.`, "bad");
|
|
170
|
+
return 1;
|
|
171
|
+
}
|
|
172
|
+
from = await pickSource(io);
|
|
173
|
+
}
|
|
174
|
+
const source = SOURCES.find((s) => s.id === from);
|
|
175
|
+
if (!source) {
|
|
176
|
+
io.say(`--from is ${SOURCES.map((s) => s.id).join(", ")}; not ${from}.`, "bad");
|
|
177
|
+
return 1;
|
|
178
|
+
}
|
|
179
|
+
const read = o.readFile ?? readExport;
|
|
180
|
+
const step = (n, title) => {
|
|
181
|
+
io.say("");
|
|
182
|
+
io.say(`${bar(n, 4)} ${title}`);
|
|
183
|
+
};
|
|
184
|
+
// 1. Connect
|
|
185
|
+
step(1, source.kind === "file" ? "The export, and the database" : "Connect");
|
|
186
|
+
const about = FROM[source.id];
|
|
187
|
+
if (about)
|
|
188
|
+
io.say(` ${about.where}`, "dim");
|
|
189
|
+
let input;
|
|
190
|
+
if (source.kind === "file") {
|
|
191
|
+
input = await askInputs(io, source.id, o, read);
|
|
192
|
+
if (!input)
|
|
193
|
+
return 1;
|
|
194
|
+
}
|
|
195
|
+
if (about)
|
|
196
|
+
io.say(` ${about.db}`, "dim");
|
|
197
|
+
const url = o.db || (await askUrl(io));
|
|
198
|
+
if (!url)
|
|
199
|
+
return 1;
|
|
200
|
+
const spin = spinner(io, "Connecting");
|
|
201
|
+
let conn;
|
|
202
|
+
try {
|
|
203
|
+
conn = await o.connect(url);
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
spin.done(`Couldn't connect: ${clean(error, url)}`, "bad");
|
|
207
|
+
return 1;
|
|
208
|
+
}
|
|
209
|
+
spin.done(`✓ Connected to ${conn.shown}`, "ok");
|
|
210
|
+
if (conn.security)
|
|
211
|
+
io.say(` ${conn.security}`, "dim");
|
|
212
|
+
try {
|
|
213
|
+
// 2. Dry run
|
|
214
|
+
step(2, "Dry run: no user moves yet");
|
|
215
|
+
const so = { prefix: o.prefix, keepUnprovenPasswords: o.keepUnprovenPasswords, input };
|
|
216
|
+
let report;
|
|
217
|
+
try {
|
|
218
|
+
report = await source.inspect(conn.query, so);
|
|
219
|
+
}
|
|
220
|
+
catch (error) {
|
|
221
|
+
io.say(`Couldn't read the database: ${clean(error, url)}`, "bad");
|
|
222
|
+
return 1;
|
|
223
|
+
}
|
|
224
|
+
for (const line of reportLines(report))
|
|
225
|
+
io.say(line.text, line.tone);
|
|
226
|
+
if (report.blocked) {
|
|
227
|
+
io.say("");
|
|
228
|
+
io.say(`Can't go ahead: ${report.blocked}`, "bad");
|
|
229
|
+
return 1;
|
|
230
|
+
}
|
|
231
|
+
if (source.id === "supabase") {
|
|
232
|
+
// From here until the move, the server makes nobody: a sign-in now would make a second, empty account.
|
|
233
|
+
try {
|
|
234
|
+
await conn.query(supabasePendingSql({ prefix: o.prefix }));
|
|
235
|
+
io.say("Until the move, direct-auth makes nobody here (503 migration_pending): a note in its meta table, taken out by the move.", "dim");
|
|
236
|
+
}
|
|
237
|
+
catch (error) {
|
|
238
|
+
io.say(`Couldn't leave the note that holds sign-ins until the move: ${clean(error, url)}`, "bad");
|
|
239
|
+
return 1;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
const mfaStop = report.mfa > 0 && !o.withoutMfa;
|
|
243
|
+
if (o.dryRun) {
|
|
244
|
+
io.say("");
|
|
245
|
+
io.say("A dry run (--dry-run): no user was moved. Without it, the move comes next, after a yes.", "note");
|
|
246
|
+
if (mfaStop)
|
|
247
|
+
io.say(`The move will stop at the ${report.mfa} ${report.mfa === 1 ? "user" : "users"} with a second factor unless --without-mfa.`, "note");
|
|
248
|
+
return 0;
|
|
249
|
+
}
|
|
250
|
+
if (mfaStop) {
|
|
251
|
+
io.say("");
|
|
252
|
+
io.say(`Can't go ahead: ${report.mfa} ${report.mfa === 1 ? "user has" : "users have"} a second factor${source.id === "supabase" ? " (auth.mfa_factors)" : ""}, which direct-auth doesn't check: they'd sign in with the first alone. Run again with --without-mfa to move them knowing that.`, "bad");
|
|
253
|
+
return 1;
|
|
254
|
+
}
|
|
255
|
+
// 3. Apply
|
|
256
|
+
step(3, "Move");
|
|
257
|
+
io.say(` First, if it isn't yet: ${source.label}'s sign-ins and sign-ups off${OFF[source.id] ? ` (${OFF[source.id]})` : ""}. A user made there after ${source.kind === "file" ? "the export" : "the move"} is one direct-auth never gets. The app's new version goes to direct-auth after it.`, "note");
|
|
258
|
+
io.say(` One transaction: all of it moves, or nothing does, and it runs once. ${source.label} keeps its users as they are.`);
|
|
259
|
+
if (!o.yes) {
|
|
260
|
+
const typed = (await io.ask(" Type move to go ahead (anything else stops): ")).trim().toLowerCase();
|
|
261
|
+
if (typed !== "move") {
|
|
262
|
+
io.say(" Stopped: nothing changed.", "note");
|
|
263
|
+
return 0;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
// The way back is built from the database as it is now, right before the move, and never over a file there.
|
|
267
|
+
let now;
|
|
268
|
+
try {
|
|
269
|
+
now = await source.inspect(conn.query, so);
|
|
270
|
+
}
|
|
271
|
+
catch (error) {
|
|
272
|
+
io.say(` Couldn't read the database: ${clean(error, url)}`, "bad");
|
|
273
|
+
return 1;
|
|
274
|
+
}
|
|
275
|
+
if (now.blocked) {
|
|
276
|
+
io.say(` Can't go ahead: ${now.blocked}`, "bad");
|
|
277
|
+
return 1;
|
|
278
|
+
}
|
|
279
|
+
const file = o.rollbackFile ?? `direct-auth-rollback-${(o.now?.() ?? new Date()).toISOString().replace(/[:.]/g, "-")}.sql`;
|
|
280
|
+
try {
|
|
281
|
+
writeFileSync(file, source.rollbackSql(now, so), { mode: 0o600, flag: "wx" });
|
|
282
|
+
}
|
|
283
|
+
catch (error) {
|
|
284
|
+
const there = error.code === "EEXIST";
|
|
285
|
+
io.say(` ${there ? `${file} is there already: give another with --rollback (it is never overwritten)` : `Couldn't write ${file}: ${clean(error, url)}`}. Nothing changed.`, "bad");
|
|
286
|
+
return 1;
|
|
287
|
+
}
|
|
288
|
+
io.say(` The way back, written first: ${file}`, "ok");
|
|
289
|
+
const keys = now.fks.length ? `the ${now.fks.length === 1 ? "foreign key" : `${now.fks.length} foreign keys`} back on auth.users, ` : "";
|
|
290
|
+
io.say(` (${keys}${now.existing ? "the moved users taken out of direct-auth's tables" : "direct-auth's tables dropped"}; psql -f it${source.id === "supabase" ? ", or the SQL editor" : ""})`, "dim");
|
|
291
|
+
const moving = spinner(io, "Moving");
|
|
292
|
+
try {
|
|
293
|
+
// In parts, one transaction: the first begins it, the last commits; a part that fails rolls it all back.
|
|
294
|
+
const notices = [];
|
|
295
|
+
try {
|
|
296
|
+
for (const part of moveParts(source.applySql({ ...so, allowMfaLoss: o.withoutMfa })))
|
|
297
|
+
notices.push(...(await conn.query(part)).notices);
|
|
298
|
+
}
|
|
299
|
+
catch (error) {
|
|
300
|
+
await conn.query("rollback").catch(() => { });
|
|
301
|
+
throw error;
|
|
302
|
+
}
|
|
303
|
+
const said = notices.filter((n) => !/already exists|does not exist, skipping/i.test(n));
|
|
304
|
+
moving.done("✓ Moved, in one transaction.", "ok");
|
|
305
|
+
for (const n of said)
|
|
306
|
+
io.say(` ${n}`, "dim");
|
|
307
|
+
}
|
|
308
|
+
catch (error) {
|
|
309
|
+
moving.done(`It failed and nothing changed (the transaction rolled back): ${clean(error, url)}`, "bad");
|
|
310
|
+
return 1;
|
|
311
|
+
}
|
|
312
|
+
// 4. Verify
|
|
313
|
+
step(4, "Check");
|
|
314
|
+
let checks;
|
|
315
|
+
try {
|
|
316
|
+
checks = await source.verify(conn.query, so);
|
|
317
|
+
}
|
|
318
|
+
catch (error) {
|
|
319
|
+
io.say(`Couldn't check: ${clean(error, url)}. The move is done; ${file} goes back.`, "bad");
|
|
320
|
+
return 1;
|
|
321
|
+
}
|
|
322
|
+
for (const line of checkLines(checks))
|
|
323
|
+
io.say(line.text, line.tone);
|
|
324
|
+
const failed = checks.filter((c) => !c.ok);
|
|
325
|
+
if (failed.length) {
|
|
326
|
+
io.say("");
|
|
327
|
+
io.say(`${failed.length === 1 ? "One check" : `${failed.length} checks`} failed: read them before going on. ${file} goes back.`, "bad");
|
|
328
|
+
return 1;
|
|
329
|
+
}
|
|
330
|
+
// Next
|
|
331
|
+
for (const line of nextSteps(source, report, { issuer: o.issuer, ref: source.id === "supabase" ? supabaseRef(url) : undefined, prefix: o.prefix }))
|
|
332
|
+
io.say(line.text, line.tone);
|
|
333
|
+
return 0;
|
|
334
|
+
}
|
|
335
|
+
finally {
|
|
336
|
+
await conn.close().catch(() => { });
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
/** Progress across the steps: done ones filled. */
|
|
340
|
+
export function bar(at, of) {
|
|
341
|
+
return `${"━━━━ ".repeat(at).trimEnd()}${at < of ? " " : ""}${"──── ".repeat(of - at).trimEnd()} ${at} of ${of}`;
|
|
342
|
+
}
|
|
343
|
+
/** The dry run as aligned lines: the counts, then what needs a hand (each by name, with what to do), then notes. */
|
|
344
|
+
export function reportLines(r) {
|
|
345
|
+
const lines = [];
|
|
346
|
+
const width = Math.max(...r.counts.map((c) => c.label.length)) + 2;
|
|
347
|
+
const num = Math.max(...r.counts.map((c) => String(c.count).length));
|
|
348
|
+
for (const c of r.counts) {
|
|
349
|
+
const text = ` ${c.label.padEnd(width)}${String(c.count).padStart(num)}${c.note ? ` ${c.note}` : ""}`;
|
|
350
|
+
lines.push({ text, tone: c.warn && c.count > 0 ? "note" : undefined });
|
|
351
|
+
}
|
|
352
|
+
if (r.existing)
|
|
353
|
+
lines.push({ text: " direct-auth's tables are there already (the server started once): the users go in beside whoever is there.", tone: "dim" });
|
|
354
|
+
const kinds = ["foreign key", "trigger", "function", "policy", "view", "claim"];
|
|
355
|
+
const auto = r.attention.filter((a) => a.automatic);
|
|
356
|
+
const hand = r.attention.filter((a) => !a.automatic);
|
|
357
|
+
if (auto.length) {
|
|
358
|
+
lines.push({ text: "" }, { text: "Done by the move itself:" });
|
|
359
|
+
const w = Math.max(...auto.map((a) => a.name.length)) + 2;
|
|
360
|
+
for (const a of auto)
|
|
361
|
+
lines.push({ text: ` ✓ ${a.name.padEnd(w)}${a.todo}`, tone: "dim" });
|
|
362
|
+
}
|
|
363
|
+
if (hand.length) {
|
|
364
|
+
lines.push({ text: "" }, { text: "Needs a hand, by you, with the move:", tone: "note" });
|
|
365
|
+
for (const kind of kinds) {
|
|
366
|
+
const of = hand.filter((a) => a.kind === kind);
|
|
367
|
+
if (!of.length)
|
|
368
|
+
continue;
|
|
369
|
+
lines.push({ text: ` ${kind === "policy" ? "policies" : `${kind}s`}`, tone: "dim" });
|
|
370
|
+
for (const a of of) {
|
|
371
|
+
lines.push({ text: ` ! ${a.name}`, tone: "note" });
|
|
372
|
+
lines.push({ text: ` ${a.todo}` });
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
if (r.notes.length) {
|
|
377
|
+
lines.push({ text: "" });
|
|
378
|
+
for (const n of r.notes)
|
|
379
|
+
lines.push({ text: ` i ${n}`, tone: "dim" });
|
|
380
|
+
}
|
|
381
|
+
return lines;
|
|
382
|
+
}
|
|
383
|
+
export function checkLines(checks) {
|
|
384
|
+
const width = Math.max(...checks.map((c) => c.label.length)) + 2;
|
|
385
|
+
return checks.map((c) => ({ text: ` ${c.ok ? "✓" : "✗"} ${c.label.padEnd(width)}${c.detail}`, tone: c.ok ? "ok" : "bad" }));
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* What comes after the move, for Supabase: trusting the issuer (the Management API, as the dashboard has no
|
|
389
|
+
* generic OIDC field), the server's env, and each client swapped, with the snippet.
|
|
390
|
+
*/
|
|
391
|
+
export function nextSteps(source, r, o) {
|
|
392
|
+
const issuer = o.issuer ?? "https://auth.example.com/auth";
|
|
393
|
+
const ref = o.ref ?? "<project-ref>";
|
|
394
|
+
const lines = [{ text: "" }, { text: "Next" }];
|
|
395
|
+
const say = (text, tone) => lines.push({ text, tone });
|
|
396
|
+
if (source.id !== "supabase")
|
|
397
|
+
return readerNextSteps(source, r, { issuer, prefix: o.prefix });
|
|
398
|
+
say("");
|
|
399
|
+
say("1. The project trusts direct-auth's tokens (Third-Party Auth): auth.uid(), Storage and Realtime read them.");
|
|
400
|
+
say(` npx direct-auth supabase-trust --project ${ref} --issuer ${issuer}`, "code");
|
|
401
|
+
say(" It needs SUPABASE_ACCESS_TOKEN (Account › Access Tokens), and shows what it sends before it does. By hand:", "dim");
|
|
402
|
+
say(` curl -X POST https://api.supabase.com/v1/projects/${ref}/config/auth/third-party-auth \\`, "code");
|
|
403
|
+
say(' -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" -H "content-type: application/json" \\', "code");
|
|
404
|
+
say(` -d '{"oidc_issuer_url":"${issuer}"}'`, "code");
|
|
405
|
+
say("");
|
|
406
|
+
say("2. The server's env (npx direct-auth init writes it):");
|
|
407
|
+
const env = [["DIRECT_AUTH_ISSUER", issuer]];
|
|
408
|
+
if (o.prefix !== "auth_")
|
|
409
|
+
env.push(["DIRECT_AUTH_TABLE_PREFIX", o.prefix]);
|
|
410
|
+
if (r.has.passwords)
|
|
411
|
+
env.push(["PASSWORDS", "1 the moved bcrypt hashes sign in, and turn into PBKDF2 then"]);
|
|
412
|
+
if (r.has.guests)
|
|
413
|
+
env.push(["GUESTS", "1 the moved anonymous users keep their ids"]);
|
|
414
|
+
if (r.has.passkeys)
|
|
415
|
+
env.push(["PASSKEY_RP_ID", "the rp id Supabase's passkeys used (your site's domain), or they won't sign in"]);
|
|
416
|
+
const w = Math.max(...env.map(([k]) => k.length)) + 2;
|
|
417
|
+
for (const [k, v] of env)
|
|
418
|
+
say(` ${k.padEnd(w)}${v}`, "code");
|
|
419
|
+
say("");
|
|
420
|
+
say("3. The apps' new version: direct-auth's client signs in, and Supabase's client sends its token. Point it at");
|
|
421
|
+
say(" direct-auth only now, after the move.", "dim");
|
|
422
|
+
say(" iOS and macOS (Swift)", "dim");
|
|
423
|
+
say(` let auth = DirectAuth(url: URL(string: "${issuer}")!)`, "code");
|
|
424
|
+
say(" let supabase = SupabaseClient(supabaseURL: url, supabaseKey: anonKey,", "code");
|
|
425
|
+
say(" options: .init(auth: .init(accessToken: { try await auth.accessToken() })))", "code");
|
|
426
|
+
say(" Android (Kotlin)", "dim");
|
|
427
|
+
say(` val auth = DirectAuth(context, "${issuer}")`, "code");
|
|
428
|
+
say(" val supabase = createSupabaseClient(url, anonKey) { accessToken = { auth.accessToken() } }", "code");
|
|
429
|
+
say(" The web", "dim");
|
|
430
|
+
say(` const auth = createAuthClient({ url: "${issuer}" });`, "code");
|
|
431
|
+
say(" const supabase = createClient(url, anonKey, { accessToken: () => auth.accessToken() });", "code");
|
|
432
|
+
if (r.has.guests) {
|
|
433
|
+
say(" Guests: at its first start, before anything else, an app holding Supabase's anonymous session calls", "dim");
|
|
434
|
+
say(" auth.claimGuest(supabaseRefreshToken) once, then forgets the Supabase session: same id, same data.", "dim");
|
|
435
|
+
}
|
|
436
|
+
say("");
|
|
437
|
+
say("4. The hard stop: nobody's Supabase session comes over, so everyone signs in again, as the same user.");
|
|
438
|
+
say(" Release the new version and make it the minimum (older ones are told to update).", "dim");
|
|
439
|
+
say(" Then revoke Supabase's JWT signing key (Project Settings › JWT Keys), or rotate the legacy JWT secret (which", "dim");
|
|
440
|
+
say(" changes the anon and service_role keys: move the apps to the publishable and secret keys first), so the", "dim");
|
|
441
|
+
say(" access tokens it signed stop working at once rather than within the hour.", "dim");
|
|
442
|
+
return lines;
|
|
443
|
+
}
|
|
444
|
+
/** After a move from a service on its own (Firebase, Clerk, Auth0) or tables of the app's (Auth.js, Better Auth). */
|
|
445
|
+
function readerNextSteps(source, r, o) {
|
|
446
|
+
const lines = [{ text: "" }, { text: "Next" }];
|
|
447
|
+
const say = (text, tone) => lines.push({ text, tone });
|
|
448
|
+
say("");
|
|
449
|
+
say("1. The server's env (npx direct-auth init writes it), on this database:");
|
|
450
|
+
const env = [["DIRECT_AUTH_ISSUER", o.issuer]];
|
|
451
|
+
if (o.prefix !== "auth_")
|
|
452
|
+
env.push(["DIRECT_AUTH_TABLE_PREFIX", o.prefix]);
|
|
453
|
+
if (r.has.passwords)
|
|
454
|
+
env.push(["PASSWORDS", "1 the moved hashes sign in, and turn into PBKDF2 then"]);
|
|
455
|
+
if (r.has.guests)
|
|
456
|
+
env.push(["GUESTS", "1 new guests (the moved ones keep their ids and data)"]);
|
|
457
|
+
env.push(["MAIL_SENDER", "email codes: how users without a password get in"]);
|
|
458
|
+
const w = Math.max(...env.map(([k]) => k.length)) + 2;
|
|
459
|
+
for (const [k, v] of env)
|
|
460
|
+
say(` ${k.padEnd(w)}${v}`, "code");
|
|
461
|
+
say(" Sign in with Apple, Google and GitHub with the same app IDs as before: the accounts are matched by them.", "dim");
|
|
462
|
+
if (r.renamed) {
|
|
463
|
+
say("");
|
|
464
|
+
say(`2. ${r.renamed} users have a new id (theirs wasn't a UUID). The old one is in public.${o.prefix}users.source_id:`);
|
|
465
|
+
say(` select id, source_id from public.${o.prefix}users where source_id is not null;`, "code");
|
|
466
|
+
say(" Give the app's own tables the new ids with it before the new version reads them.", "dim");
|
|
467
|
+
}
|
|
468
|
+
say("");
|
|
469
|
+
say(`${r.renamed ? 3 : 2}. The apps' new version: direct-auth's client signs in, and your API checks its tokens.`);
|
|
470
|
+
say(` iOS and Android: DirectAuth(url: "${o.issuer}"); the web: createAuthClient({ url: "${o.issuer}" }).`, "dim");
|
|
471
|
+
say("");
|
|
472
|
+
say(`${r.renamed ? 4 : 3}. The hard stop: nobody's ${source.label} session comes over, so everyone signs in again, as the same user.`);
|
|
473
|
+
say(" Release the new version and make it the minimum (older ones are told to update).", "dim");
|
|
474
|
+
if (r.has.guests)
|
|
475
|
+
say(` Guests have no claim: ${source.label}'s anonymous session doesn't come over, so a guest starts over.`, "dim");
|
|
476
|
+
say(` Keep ${source.label} until then; turn it off after.`, "dim");
|
|
477
|
+
return lines;
|
|
478
|
+
}
|
|
479
|
+
async function askUrl(io) {
|
|
480
|
+
for (;;) {
|
|
481
|
+
const v = (await (io.askSecret ?? io.ask)(" Database URL (postgres://…, hidden as you type): ")).trim();
|
|
482
|
+
if (!v)
|
|
483
|
+
return "";
|
|
484
|
+
try {
|
|
485
|
+
const u = new URL(v);
|
|
486
|
+
if (u.protocol === "postgres:" || u.protocol === "postgresql:")
|
|
487
|
+
return v;
|
|
488
|
+
}
|
|
489
|
+
catch {
|
|
490
|
+
/* asked again */
|
|
491
|
+
}
|
|
492
|
+
io.say(" A postgres://user:password@host:5432/postgres URL.", "bad");
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
/** An error's message without the URL, its password or a whole id in it (Postgres puts the row's key in its detail). */
|
|
496
|
+
function clean(error, url) {
|
|
497
|
+
let m = error instanceof Error ? error.message : String(error);
|
|
498
|
+
try {
|
|
499
|
+
const u = new URL(url);
|
|
500
|
+
for (const secret of [url, decodeURIComponent(u.password), u.password])
|
|
501
|
+
if (secret.length >= 4)
|
|
502
|
+
m = m.split(secret).join("•••••");
|
|
503
|
+
}
|
|
504
|
+
catch {
|
|
505
|
+
/* not a URL */
|
|
506
|
+
}
|
|
507
|
+
return m
|
|
508
|
+
.replace(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi, (id) => maskId(id))
|
|
509
|
+
.replace(/[^\s()'"=]+@[^\s()'"=]+\.[a-z]{2,}/gi, "…@…");
|
|
510
|
+
}
|
|
511
|
+
function spinner(io, text) {
|
|
512
|
+
if (io.spin)
|
|
513
|
+
return io.spin(text);
|
|
514
|
+
io.say(` ${text}…`, "dim");
|
|
515
|
+
return { update: () => { }, done: (line, tone) => io.say(` ${line}`, tone) };
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* `direct-auth supabase-trust`: the project takes direct-auth's tokens, as a Third-Party Auth issuer, through
|
|
519
|
+
* Supabase's Management API (the dashboard lists only Firebase, Auth0, Cognito and Clerk). What is there is read
|
|
520
|
+
* first; the change is shown, and made after a yes. The access token is never printed.
|
|
521
|
+
*/
|
|
522
|
+
export async function trustIssuer(io, o) {
|
|
523
|
+
const f = o.f ?? fetch;
|
|
524
|
+
const token = o.token || (await (io.askSecret ?? io.ask)(" Supabase access token (Account › Access Tokens; hidden): ")).trim();
|
|
525
|
+
if (!token)
|
|
526
|
+
return 1;
|
|
527
|
+
const api = `https://api.supabase.com/v1/projects/${encodeURIComponent(o.project)}/config/auth/third-party-auth`;
|
|
528
|
+
const headers = { authorization: `Bearer ${token}`, "content-type": "application/json" };
|
|
529
|
+
const listed = await f(api, { headers });
|
|
530
|
+
if (!listed.ok) {
|
|
531
|
+
io.say(`Supabase answered ${listed.status} for project ${o.project}: ${listed.status === 401 ? "the access token isn't valid" : listed.status === 404 ? "no such project for this token" : "try again"}.`, "bad");
|
|
532
|
+
return 1;
|
|
533
|
+
}
|
|
534
|
+
const there = (await listed.json());
|
|
535
|
+
if (there.some((t) => t.oidc_issuer_url?.replace(/\/+$/, "") === o.issuer)) {
|
|
536
|
+
io.say(`✓ Project ${o.project} already trusts ${o.issuer}.`, "ok");
|
|
537
|
+
return 0;
|
|
538
|
+
}
|
|
539
|
+
io.say(`Project ${o.project} will trust tokens from ${o.issuer}:`);
|
|
540
|
+
io.say(` POST ${api}`, "dim");
|
|
541
|
+
io.say(` {"oidc_issuer_url":"${o.issuer}"}`, "code");
|
|
542
|
+
io.say(" Supabase reads the issuer's /.well-known/openid-configuration and keys: the server must be up there.", "dim");
|
|
543
|
+
if (!o.yes && !(await yesNo(io, " Go ahead?"))) {
|
|
544
|
+
io.say(" Nothing changed.", "note");
|
|
545
|
+
return 0;
|
|
546
|
+
}
|
|
547
|
+
const r = await f(api, { method: "POST", headers, body: JSON.stringify({ oidc_issuer_url: o.issuer }) });
|
|
548
|
+
if (!r.ok) {
|
|
549
|
+
const text = (await r.text()).split(token).join("…").slice(0, 300);
|
|
550
|
+
io.say(` Supabase said ${r.status}: ${text}`, "bad");
|
|
551
|
+
return 1;
|
|
552
|
+
}
|
|
553
|
+
io.say(` ✓ Done: auth.uid() is the user's id in direct-auth's tokens.`, "ok");
|
|
554
|
+
return 0;
|
|
555
|
+
}
|
|
556
|
+
async function yesNo(io, q) {
|
|
557
|
+
for (;;) {
|
|
558
|
+
const a = (await io.ask(`${q} [y/N] `)).trim().toLowerCase();
|
|
559
|
+
if (a === "" || a === "n" || a === "no")
|
|
560
|
+
return false;
|
|
561
|
+
if (a === "y" || a === "yes")
|
|
562
|
+
return true;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `direct-auth migrate`: users moved from another auth service into direct-auth's tables, once, in the same
|
|
3
|
+
* database. Each source (Supabase Auth; Firebase Auth, Auth.js, Better Auth, Clerk and Auth0, in sources.ts) says four things:
|
|
4
|
+
*
|
|
5
|
+
* inspect what would move and what needs a hand (counts only, never an address)
|
|
6
|
+
* applySql the move, one transaction; it refuses to run a second time
|
|
7
|
+
* rollbackSql the way back, written before applying
|
|
8
|
+
* verify that what should have moved did
|
|
9
|
+
*
|
|
10
|
+
* and the steps after. A new source is one more object in `SOURCES`.
|
|
11
|
+
*/
|
|
12
|
+
import { type SourceInput } from "./sources.ts";
|
|
13
|
+
export type Query = (sql: string) => Promise<{
|
|
14
|
+
rows: Record<string, string | null>[];
|
|
15
|
+
notices: string[];
|
|
16
|
+
}>;
|
|
17
|
+
export interface Count {
|
|
18
|
+
label: string;
|
|
19
|
+
count: number;
|
|
20
|
+
/** What happens to them, when it isn't "they move". */
|
|
21
|
+
note?: string;
|
|
22
|
+
/** Not moving, or moving with something lost: worth reading. */
|
|
23
|
+
warn?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface Attention {
|
|
26
|
+
/** What it is, by name: `public.handle_new_user()`, `public.profiles.id`. */
|
|
27
|
+
name: string;
|
|
28
|
+
kind: "foreign key" | "trigger" | "function" | "policy" | "view" | "claim";
|
|
29
|
+
/** What to do about it, or that nothing needs doing. */
|
|
30
|
+
todo: string;
|
|
31
|
+
/** Moved by the script itself (a foreign key), rather than by hand. */
|
|
32
|
+
automatic?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface ForeignKey {
|
|
35
|
+
table: string;
|
|
36
|
+
column: string;
|
|
37
|
+
constraint: string;
|
|
38
|
+
onDelete: string;
|
|
39
|
+
/** All it says (`pg_get_constraintdef`): on delete, on update, deferrable, as it is now. */
|
|
40
|
+
definition: string;
|
|
41
|
+
/** On a partitioned table: moved on the table (its partitions follow), and never NOT VALID. */
|
|
42
|
+
partitioned?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface Report {
|
|
45
|
+
counts: Count[];
|
|
46
|
+
attention: Attention[];
|
|
47
|
+
notes: string[];
|
|
48
|
+
/** Why it can't go ahead (moved already, or a table of the same name that isn't direct-auth's, say). */
|
|
49
|
+
blocked?: string;
|
|
50
|
+
/** direct-auth's tables are there already (the server started once): the way back keeps them. */
|
|
51
|
+
existing: boolean;
|
|
52
|
+
fks: ForeignKey[];
|
|
53
|
+
/** What the next steps need to know. */
|
|
54
|
+
has: {
|
|
55
|
+
guests: boolean;
|
|
56
|
+
passwords: boolean;
|
|
57
|
+
passkeys: boolean;
|
|
58
|
+
};
|
|
59
|
+
/** Users moving who have a second factor direct-auth won't check: the move needs `--without-mfa`. */
|
|
60
|
+
mfa: number;
|
|
61
|
+
/** Guests moving with a Supabase refresh token to claim their account with. */
|
|
62
|
+
claimable?: number;
|
|
63
|
+
/** Users given a new id (theirs wasn't a UUID): the old one is in `{users}.source_id`. */
|
|
64
|
+
renamed?: number;
|
|
65
|
+
}
|
|
66
|
+
export interface Check {
|
|
67
|
+
label: string;
|
|
68
|
+
ok: boolean;
|
|
69
|
+
detail: string;
|
|
70
|
+
}
|
|
71
|
+
export interface SourceOptions {
|
|
72
|
+
prefix: string;
|
|
73
|
+
/**
|
|
74
|
+
* Unproven addresses' passwords move too (`--keep-unproven-passwords`): Supabase's confirmed the moment they signed
|
|
75
|
+
* up; for the others, a password user's address the service never verified (moved as checked, with the password).
|
|
76
|
+
*/
|
|
77
|
+
keepUnprovenPasswords?: boolean;
|
|
78
|
+
/** What a file source reads (the export's text, Auth0's hashes, Firebase's hash parameters). */
|
|
79
|
+
input?: SourceInput;
|
|
80
|
+
}
|
|
81
|
+
export interface MigrationSource {
|
|
82
|
+
id: string;
|
|
83
|
+
label: string;
|
|
84
|
+
/** Where the users are: the database itself (Supabase, Auth.js, Better Auth), or export files. */
|
|
85
|
+
kind?: "tables" | "file";
|
|
86
|
+
inspect(q: Query, o: SourceOptions): Promise<Report>;
|
|
87
|
+
applySql(o: SourceOptions & {
|
|
88
|
+
allowMfaLoss?: boolean;
|
|
89
|
+
}): string;
|
|
90
|
+
/** Built from a dry run made right before the move, so it puts back what was there then. */
|
|
91
|
+
rollbackSql(report: Report, o: SourceOptions): string;
|
|
92
|
+
verify(q: Query, o: SourceOptions): Promise<Check[]>;
|
|
93
|
+
}
|
|
94
|
+
/** An id with its middle taken out: enough to find it again, not to read it off a screen. */
|
|
95
|
+
export declare const maskId: (id: string) => string;
|
|
96
|
+
export declare const supabaseSource: MigrationSource;
|
|
97
|
+
export declare const SOURCES: readonly MigrationSource[];
|
|
98
|
+
/** The Supabase project's ref, from its database URL (db.<ref>.supabase.co, or the pooler's postgres.<ref> user). */
|
|
99
|
+
export declare function supabaseRef(url: string): string | undefined;
|