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.
Files changed (110) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +486 -2
  3. package/dist/accounts.d.ts +118 -0
  4. package/dist/accounts.js +314 -0
  5. package/dist/apps.d.ts +85 -0
  6. package/dist/apps.js +449 -0
  7. package/dist/auth.d.ts +396 -0
  8. package/dist/auth.js +699 -0
  9. package/dist/base64.d.ts +20 -0
  10. package/dist/base64.js +45 -0
  11. package/dist/cli.d.ts +2 -0
  12. package/dist/cli.js +463 -0
  13. package/dist/client.d.ts +170 -0
  14. package/dist/client.js +438 -0
  15. package/dist/codes.d.ts +81 -0
  16. package/dist/codes.js +91 -0
  17. package/dist/crypto.d.ts +11 -0
  18. package/dist/crypto.js +37 -0
  19. package/dist/d1.d.ts +2 -0
  20. package/dist/d1.js +2 -0
  21. package/dist/db/limits.d.ts +16 -0
  22. package/dist/db/limits.js +23 -0
  23. package/dist/db/schema.d.ts +25 -0
  24. package/dist/db/schema.js +136 -0
  25. package/dist/db/sql.d.ts +52 -0
  26. package/dist/db/sql.js +121 -0
  27. package/dist/dns.d.ts +48 -0
  28. package/dist/dns.js +133 -0
  29. package/dist/env.d.ts +39 -0
  30. package/dist/env.js +169 -0
  31. package/dist/index.d.ts +19 -0
  32. package/dist/index.js +14 -0
  33. package/dist/init.d.ts +134 -0
  34. package/dist/init.js +912 -0
  35. package/dist/jwks.d.ts +18 -0
  36. package/dist/jwks.js +63 -0
  37. package/dist/jwt.d.ts +90 -0
  38. package/dist/jwt.js +99 -0
  39. package/dist/keys.d.ts +33 -0
  40. package/dist/keys.js +54 -0
  41. package/dist/messages.d.ts +26 -0
  42. package/dist/messages.js +57 -0
  43. package/dist/migrate-cli.d.ts +82 -0
  44. package/dist/migrate-cli.js +564 -0
  45. package/dist/migrate.d.ts +99 -0
  46. package/dist/migrate.js +396 -0
  47. package/dist/node.d.ts +16 -0
  48. package/dist/node.js +63 -0
  49. package/dist/passkeys.d.ts +126 -0
  50. package/dist/passkeys.js +383 -0
  51. package/dist/passwords.d.ts +53 -0
  52. package/dist/passwords.js +326 -0
  53. package/dist/pgwire.d.ts +86 -0
  54. package/dist/pgwire.js +445 -0
  55. package/dist/phone.d.ts +11 -0
  56. package/dist/phone.js +18 -0
  57. package/dist/postgres.d.ts +2 -0
  58. package/dist/postgres.js +2 -0
  59. package/dist/providers/apple-revoke.d.ts +55 -0
  60. package/dist/providers/apple-revoke.js +113 -0
  61. package/dist/providers/apple.d.ts +28 -0
  62. package/dist/providers/apple.js +51 -0
  63. package/dist/providers/github.d.ts +28 -0
  64. package/dist/providers/github.js +67 -0
  65. package/dist/providers/google.d.ts +23 -0
  66. package/dist/providers/google.js +47 -0
  67. package/dist/providers/identity.d.ts +24 -0
  68. package/dist/providers/identity.js +3 -0
  69. package/dist/proxy.d.ts +19 -0
  70. package/dist/proxy.js +43 -0
  71. package/dist/records.d.ts +91 -0
  72. package/dist/records.js +264 -0
  73. package/dist/scrypt.d.ts +26 -0
  74. package/dist/scrypt.js +179 -0
  75. package/dist/senders/aws.d.ts +13 -0
  76. package/dist/senders/aws.js +47 -0
  77. package/dist/senders/dev.d.ts +6 -0
  78. package/dist/senders/dev.js +13 -0
  79. package/dist/senders/index.d.ts +5 -0
  80. package/dist/senders/index.js +4 -0
  81. package/dist/senders/mail.d.ts +26 -0
  82. package/dist/senders/mail.js +66 -0
  83. package/dist/senders/sms.d.ts +34 -0
  84. package/dist/senders/sms.js +69 -0
  85. package/dist/senders/smtp.d.ts +32 -0
  86. package/dist/senders/smtp.js +145 -0
  87. package/dist/senders/types.d.ts +31 -0
  88. package/dist/senders/types.js +25 -0
  89. package/dist/server.d.ts +67 -0
  90. package/dist/server.js +494 -0
  91. package/dist/sessions.d.ts +74 -0
  92. package/dist/sessions.js +146 -0
  93. package/dist/skill.d.ts +25 -0
  94. package/dist/skill.js +66 -0
  95. package/dist/sources.d.ts +138 -0
  96. package/dist/sources.js +931 -0
  97. package/dist/sqlite.d.ts +2 -0
  98. package/dist/sqlite.js +2 -0
  99. package/dist/stores/d1.d.ts +22 -0
  100. package/dist/stores/d1.js +23 -0
  101. package/dist/stores/postgres.d.ts +33 -0
  102. package/dist/stores/postgres.js +71 -0
  103. package/dist/stores/sqlite.d.ts +27 -0
  104. package/dist/stores/sqlite.js +55 -0
  105. package/dist/supabase.d.ts +71 -0
  106. package/dist/supabase.js +283 -0
  107. package/dist/tui.d.ts +178 -0
  108. package/dist/tui.js +537 -0
  109. package/package.json +90 -4
  110. package/skills/direct-auth/SKILL.md +101 -0
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Sessions: a short access token anyone can check with the published keys (an ES256 JWT, an hour), and a refresh
3
+ * token only this server can use, kept hashed, replaced at each use. A refresh token used again later (copied off a
4
+ * device and used by someone else, or the device's own old copy) ends the whole session. Within a few seconds of its
5
+ * first use it answers the same new token again: two tabs, or a browser restoring several, racing to refresh with one
6
+ * token all end up with the one session.
7
+ *
8
+ * The access token is what Supabase (as a third-party issuer), Hasura, PostgREST or any API reads: `sub` is the
9
+ * user's id, `role` is `authenticated`, `aud` is the audience given (`authenticated` by default, as Supabase expects).
10
+ */
11
+ import { hmac, hmacKey, randomToken, sha256 } from "./crypto.js";
12
+ import { utf8 } from "./base64.js";
13
+ import { num } from "./db/sql.js";
14
+ import { signJwt, verifyJwt } from "./jwt.js";
15
+ import { staticJwks } from "./jwks.js";
16
+ const DAY = 86_400_000;
17
+ const RESERVED = new Set(["iss", "sub", "aud", "exp", "iat", "nbf", "jti", "sid", "role", "is_anonymous"]);
18
+ export async function accessToken(keys, o, user, sessionId, now = Date.now()) {
19
+ const ttl = o.accessTtl ?? 3600;
20
+ const iat = Math.floor(now / 1000);
21
+ const extra = Object.fromEntries(Object.entries((await o.claims?.(user)) ?? {}).filter(([k]) => !RESERVED.has(k)));
22
+ const claims = {
23
+ ...extra,
24
+ iss: o.issuer,
25
+ sub: user.id,
26
+ aud: o.audience ?? "authenticated",
27
+ iat,
28
+ exp: iat + ttl,
29
+ sid: sessionId,
30
+ role: "authenticated",
31
+ // Supabase's own claim for a guest, so policies written for its anonymous sign-ins read the same.
32
+ is_anonymous: user.isGuest,
33
+ ...(user.email ? { email: user.email } : {}),
34
+ ...(user.phone ? { phone: user.phone } : {}),
35
+ };
36
+ const token = await signJwt({ alg: "ES256", kid: keys.signer.kid, typ: "JWT" }, claims, keys.signer.key);
37
+ return { token, expiresIn: ttl };
38
+ }
39
+ export async function createSession(sql, keys, o, user, userAgent, now = Date.now()) {
40
+ const sessionId = crypto.randomUUID();
41
+ const refresh = randomToken();
42
+ await sql.batch([
43
+ [
44
+ `insert into {sessions} (id, user_id, created_at, refreshed_at, expires_at, user_agent) values (?, ?, ?, ?, ?, ?)`,
45
+ [sessionId, user.id, now, now, now + (o.maxDays ?? 365) * DAY, userAgent?.slice(0, 300) ?? null],
46
+ ],
47
+ [`insert into {refresh} (hash, session_id, created_at) values (?, ?, ?)`, [await sha256(refresh), sessionId, now]],
48
+ ]);
49
+ const access = await accessToken(keys, o, user, sessionId, now);
50
+ return { accessToken: access.token, refreshToken: refresh, expiresIn: access.expiresIn, tokenType: "Bearer", sessionId };
51
+ }
52
+ const successorKeys = new WeakMap();
53
+ const successorKey = (keys) => {
54
+ let k = successorKeys.get(keys);
55
+ if (!k)
56
+ successorKeys.set(keys, (k = hmacKey(utf8(`direct-auth refresh ${keys.secret}`))));
57
+ return k;
58
+ };
59
+ export async function refreshSession(sql, keys, o, refreshToken, getUser, now = Date.now()) {
60
+ const hash = await sha256(refreshToken);
61
+ const [row] = await sql.all(`select r.session_id, r.used_at, r.uses, s.user_id, s.refreshed_at, s.expires_at, s.revoked_at
62
+ from {refresh} r join {sessions} s on s.id = r.session_id where r.hash = ?`, [hash]);
63
+ if (!row)
64
+ return { ok: false, reason: "invalid_token" };
65
+ const idle = (o.idleDays ?? 60) * DAY;
66
+ if (row.revoked_at !== null || num(row.expires_at) < now || num(row.refreshed_at) + idle < now) {
67
+ return { ok: false, reason: "session_ended" };
68
+ }
69
+ // A used token works again within a few seconds (requests of one app, or tabs, racing), answering the same new token,
70
+ // and never later: a use after that is someone else's copy, and ends the session.
71
+ const grace = (o.reuseGrace ?? 10) * 1000;
72
+ if (row.used_at !== null && num(row.used_at) + grace < now) {
73
+ await revokeSession(sql, row.session_id, now);
74
+ return { ok: false, reason: "token_reused" };
75
+ }
76
+ const { changes: taken } = await sql.run(`update {refresh} set uses = uses + 1, used_at = coalesce(used_at, ?) where hash = ? and (used_at is null or used_at >= ?)`, [now, hash, now - grace]);
77
+ if (!taken) {
78
+ // Gone since it was read (its session ended meanwhile): not a reuse.
79
+ const [still] = await sql.all(`select 1 as x from {refresh} where hash = ?`, [hash]);
80
+ if (!still)
81
+ return { ok: false, reason: "invalid_token" };
82
+ await revokeSession(sql, row.session_id, now);
83
+ return { ok: false, reason: "token_reused" };
84
+ }
85
+ const user = await getUser(row.user_id);
86
+ if (!user)
87
+ return { ok: false, reason: "session_ended" };
88
+ // The next token follows from this one under a key only the server has, so every racing request gets the same.
89
+ const next = await hmac(await successorKey(keys), refreshToken);
90
+ await sql.batch([
91
+ [`insert into {refresh} (hash, session_id, created_at) values (?, ?, ?) on conflict (hash) do nothing`, [await sha256(next), row.session_id, now]],
92
+ [`update {sessions} set refreshed_at = ? where id = ?`, [now, row.session_id]],
93
+ // Tokens used long ago are only needed to spot a reuse; a day later they go.
94
+ [`delete from {refresh} where session_id = ? and used_at is not null and used_at < ?`, [row.session_id, now - DAY]],
95
+ ]);
96
+ const access = await accessToken(keys, o, user, row.session_id, now);
97
+ return { ok: true, tokens: { accessToken: access.token, refreshToken: next, expiresIn: access.expiresIn, tokenType: "Bearer", sessionId: row.session_id } };
98
+ }
99
+ /** The live session a refresh token belongs to, and whether that token is its current one (not used yet). */
100
+ export async function sessionOfRefresh(sql, refreshToken, now = Date.now()) {
101
+ const [row] = await sql.all(`select r.session_id, s.user_id, r.used_at from {refresh} r join {sessions} s on s.id = r.session_id
102
+ where r.hash = ? and s.revoked_at is null and s.expires_at >= ?`, [await sha256(refreshToken), now]);
103
+ return row ? { sessionId: row.session_id, userId: row.user_id, current: row.used_at === null } : null;
104
+ }
105
+ export async function revokeSession(sql, sessionId, now = Date.now()) {
106
+ await sql.batch([
107
+ [`update {sessions} set revoked_at = coalesce(revoked_at, ?) where id = ?`, [now, sessionId]],
108
+ [`delete from {refresh} where session_id = ?`, [sessionId]],
109
+ ]);
110
+ }
111
+ export async function revokeUserSessions(sql, userId, now = Date.now()) {
112
+ await sql.batch([
113
+ [`update {sessions} set revoked_at = coalesce(revoked_at, ?) where user_id = ?`, [now, userId]],
114
+ [`delete from {refresh} where session_id in (select id from {sessions} where user_id = ?)`, [userId]],
115
+ ]);
116
+ }
117
+ /** Ends every session of the user but `keep` (a new password signs the other devices out). */
118
+ export async function revokeOtherSessions(sql, userId, keep, now = Date.now()) {
119
+ await sql.batch([
120
+ [`delete from {refresh} where session_id in (select id from {sessions} where user_id = ? and id <> ?)`, [userId, keep ?? ""]],
121
+ [`update {sessions} set revoked_at = coalesce(revoked_at, ?) where user_id = ? and id <> ?`, [now, userId, keep ?? ""]],
122
+ ]);
123
+ }
124
+ /** Checks an access token this server signed: for an API that runs beside it. Others check it with the JWKS. */
125
+ export async function checkAccessToken(keys, o, token, now = Date.now()) {
126
+ const jwks = staticJwks(keys.public);
127
+ return verifyJwt(token, {
128
+ key: (kid, alg) => jwks.key(kid, alg),
129
+ issuer: o.issuer,
130
+ audience: o.audience ?? "authenticated",
131
+ algorithms: ["ES256"],
132
+ now,
133
+ leeway: 5,
134
+ });
135
+ }
136
+ export async function listSessions(sql, userId, now = Date.now()) {
137
+ const rows = await sql.all(`select id, created_at, refreshed_at, user_agent from {sessions}
138
+ where user_id = ? and revoked_at is null and expires_at > ? order by refreshed_at desc`, [userId, now]);
139
+ return rows.map((r) => ({ id: r.id, createdAt: num(r.created_at), refreshedAt: num(r.refreshed_at), userAgent: r.user_agent }));
140
+ }
141
+ /** A session that is still on: not signed out, not past its end, its user still there. Null otherwise. */
142
+ export async function liveSession(sql, sessionId, now = Date.now()) {
143
+ const [row] = await sql.all(`select s.user_id, s.created_at from {sessions} s join {users} u on u.id = s.user_id
144
+ where s.id = ? and s.revoked_at is null and s.expires_at > ?`, [sessionId, now]);
145
+ return row ? { userId: row.user_id, createdAt: num(row.created_at) } : null;
146
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * `direct-auth skill`: the coding agents' skill this package ships (skills/direct-auth) copied into the project, where
3
+ * Claude Code looks for skills (.claude/skills/direct-auth), or another agent's folder (`--dir .agents/skills`). A
4
+ * copy there that differs (edited, or an older version's) is replaced only after a yes. `app` and `init` offer it as
5
+ * their last step.
6
+ */
7
+ import { type InitIO } from "./init.ts";
8
+ /** The skill as the package has it: one folder up from src/ and dist/ alike. */
9
+ export declare const SKILL_SOURCE: string;
10
+ /** Where Claude Code reads a project's skills. */
11
+ export declare const SKILL_HOME = ".claude/skills";
12
+ export interface SkillOptions {
13
+ /** The project's folder. */
14
+ cwd: string;
15
+ /** The skills folder, relative to `cwd` or absolute: `.claude/skills` unless told. */
16
+ dir?: string;
17
+ /** The skill to copy: the package's unless told (a test). */
18
+ source?: string;
19
+ }
20
+ /** Whether the skill is in `target`: not at all, the same as the package's, or different. */
21
+ export declare function skillState(source: string, target: string): "missing" | "same" | "different";
22
+ /** The skill copied in: asks before replacing a copy that differs; says where it went. */
23
+ export declare function installSkill(io: Pick<InitIO, "ask" | "say">, o: SkillOptions): Promise<number>;
24
+ /** The last step of `app` and `init`: the skill offered (yes unless told), or nothing said when it is there already. */
25
+ export declare function offerSkill(io: Pick<InitIO, "ask" | "say">, o: SkillOptions): Promise<void>;
package/dist/skill.js ADDED
@@ -0,0 +1,66 @@
1
+ /**
2
+ * `direct-auth skill`: the coding agents' skill this package ships (skills/direct-auth) copied into the project, where
3
+ * Claude Code looks for skills (.claude/skills/direct-auth), or another agent's folder (`--dir .agents/skills`). A
4
+ * copy there that differs (edited, or an older version's) is replaced only after a yes. `app` and `init` offer it as
5
+ * their last step.
6
+ */
7
+ import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
8
+ import { dirname, join, relative } from "node:path";
9
+ import { fileURLToPath } from "node:url";
10
+ import { yes } from "./init.js";
11
+ /** The skill as the package has it: one folder up from src/ and dist/ alike. */
12
+ export const SKILL_SOURCE = fileURLToPath(new URL("../skills/direct-auth/", import.meta.url));
13
+ /** Where Claude Code reads a project's skills. */
14
+ export const SKILL_HOME = ".claude/skills";
15
+ /** Every file under `dir`, as paths relative to it. */
16
+ function files(dir, under = "") {
17
+ return readdirSync(join(dir, under), { withFileTypes: true }).flatMap((e) => e.isDirectory() ? files(dir, join(under, e.name)) : e.isFile() ? [join(under, e.name)] : []);
18
+ }
19
+ /** Whether the skill is in `target`: not at all, the same as the package's, or different. */
20
+ export function skillState(source, target) {
21
+ if (!existsSync(join(target, "SKILL.md")))
22
+ return "missing";
23
+ const same = files(source).every((f) => existsSync(join(target, f)) && readFileSync(join(target, f)).equals(readFileSync(join(source, f))));
24
+ return same ? "same" : "different";
25
+ }
26
+ /** The skill copied in: asks before replacing a copy that differs; says where it went. */
27
+ export async function installSkill(io, o) {
28
+ const source = o.source ?? SKILL_SOURCE;
29
+ const target = join(o.cwd, o.dir ?? SKILL_HOME, "direct-auth");
30
+ const shown = relative(o.cwd, target) || ".";
31
+ const state = skillState(source, target);
32
+ if (state === "same") {
33
+ io.say(` ✓ ${shown}/SKILL.md is there already, this version's.`, "ok");
34
+ return 0;
35
+ }
36
+ if (state === "different") {
37
+ io.say(` ${shown}/SKILL.md isn't this version's (edited, or older).`, "note");
38
+ if (!(await yes(io, " Replace it?", false))) {
39
+ io.say(" Left as it is.", "dim");
40
+ return 0;
41
+ }
42
+ }
43
+ for (const f of files(source)) {
44
+ mkdirSync(dirname(join(target, f)), { recursive: true });
45
+ writeFileSync(join(target, f), readFileSync(join(source, f)));
46
+ }
47
+ io.say(` ✓ The skill is in ${shown}/SKILL.md.`, "ok");
48
+ if (o.dir === undefined) {
49
+ io.say(" Claude Code reads it when a task calls for it.", "dim");
50
+ io.say(" Another agent's folder: npx direct-auth skill --dir .agents/skills", "dim");
51
+ }
52
+ else
53
+ io.say(` An agent that reads skills from ${o.dir} finds it there.`, "dim");
54
+ return 0;
55
+ }
56
+ /** The last step of `app` and `init`: the skill offered (yes unless told), or nothing said when it is there already. */
57
+ export async function offerSkill(io, o) {
58
+ const target = join(o.cwd, o.dir ?? SKILL_HOME, "direct-auth");
59
+ const state = skillState(o.source ?? SKILL_SOURCE, target);
60
+ if (state === "same")
61
+ return;
62
+ io.say("");
63
+ if (state === "missing" && !(await yes(io, `The direct-auth skill for coding agents, in ${relative(o.cwd, target)}/?`, true)))
64
+ return;
65
+ await installSkill(io, o);
66
+ }
@@ -0,0 +1,138 @@
1
+ /**
2
+ * The other sources of `direct-auth migrate`: Firebase Auth, Clerk and Auth0 from their export files, Auth.js and
3
+ * Better Auth from their tables in the same Postgres database. Each is only a reader: it turns what the service kept
4
+ * into `Account`s, one shape for all, and one writer moves those into direct-auth's tables, once, in one transaction.
5
+ *
6
+ * What a reader keeps: an address or number only once the service had checked it (a password goes with a checked
7
+ * address), Apple, Google and GitHub accounts by their subject, anonymous users as guests (with no claim: their
8
+ * sessions don't come over), and the password hashes direct-auth can check (bcrypt, Firebase's and Better Auth's
9
+ * scrypt), each made PBKDF2 at its first sign-in. An id that isn't a UUID gets a new one, and the old id stays in
10
+ * `{users}.source_id`, for the app's own tables.
11
+ */
12
+ import type { Attention, Count, MigrationSource, Query, Report, SourceOptions } from "./migrate.ts";
13
+ export type Provider = "apple" | "google" | "github";
14
+ /** One user, as every reader gives it. */
15
+ export interface Account {
16
+ /** The id the service had. */
17
+ sourceId: string;
18
+ /** The id here: the service's when it is a UUID, a new one otherwise. */
19
+ id: string;
20
+ createdAt: number;
21
+ lastSignInAt?: number;
22
+ /** Checked addresses, the account's own first. */
23
+ emails: string[];
24
+ /** Checked numbers in E.164, the account's own first. */
25
+ phones: string[];
26
+ name?: string;
27
+ picture?: string;
28
+ guest?: boolean;
29
+ /** The hash as direct-auth keeps it (bcrypt as it is, `$fbscrypt$…`, `$bascrypt$…`). */
30
+ password?: string;
31
+ identities: {
32
+ provider: Provider;
33
+ subject: string;
34
+ email?: string;
35
+ }[];
36
+ /** A second factor at the source: direct-auth doesn't check one, so the move needs `--without-mfa`. */
37
+ mfa?: boolean;
38
+ }
39
+ export interface Reading {
40
+ accounts: Account[];
41
+ /** The source's own counts: what stays behind and why. */
42
+ counts: Count[];
43
+ notes: string[];
44
+ attention: Attention[];
45
+ /** How many the source has in all, before any is left out. */
46
+ total: number;
47
+ }
48
+ /** Firebase's password hash parameters (Authentication › Users › ⋮ › Password hash parameters). */
49
+ export interface FirebaseHash {
50
+ signerKey: string;
51
+ saltSeparator: string;
52
+ rounds: number;
53
+ memCost: number;
54
+ }
55
+ /** What a file source reads: the export's text, and the extras each takes. */
56
+ export interface SourceInput {
57
+ users?: string;
58
+ /** Auth0: the password hashes file. */
59
+ hashes?: string;
60
+ firebase?: FirebaseHash;
61
+ }
62
+ export interface Reader {
63
+ id: string;
64
+ label: string;
65
+ /** Where the users are: export files, or tables in the database. */
66
+ kind: "file" | "tables";
67
+ read(q: Query, o: SourceOptions): Promise<Reading>;
68
+ }
69
+ export declare function cleanEmail(v: unknown): string | undefined;
70
+ export declare function cleanPhone(v: unknown): string | undefined;
71
+ export declare function readFirebase(json: string, hash: FirebaseHash | undefined, o?: {
72
+ keepUnprovenPasswords?: boolean;
73
+ now?: number;
74
+ }): Reading;
75
+ /** RFC 4180 CSV: quoted fields, doubled quotes, line breaks inside quotes; a line starting with # is a comment. */
76
+ export declare function parseCsv(input: string): Record<string, string>[];
77
+ /**
78
+ * Clerk's dashboard export (Settings › User exports): `id, first_name, last_name, username, primary_email_address,
79
+ * primary_phone_number, verified_email_addresses, unverified_email_addresses, verified_phone_numbers,
80
+ * unverified_phone_numbers, totp_secret, password_digest, password_hasher, created_at`, several values in a cell
81
+ * split by `|`; bcrypt digests `$2a$` (made by Clerk) or `$2b$` (imported). It has no Google, Apple or GitHub
82
+ * accounts: those users get in with that provider again, which joins the account by its verified address. Nor does
83
+ * it say who is banned: a banned user moves like any other.
84
+ */
85
+ export declare function readClerk(csv: string, o?: {
86
+ now?: number;
87
+ }): Reading;
88
+ /**
89
+ * Auth0's bulk export (`POST /api/v2/jobs/users-exports`, format json: NDJSON) with `user_id, email, email_verified,
90
+ * phone_number, phone_verified, name, picture, blocked, created_at, last_login, identities[{ provider, connection,
91
+ * user_id }]`. Auth0 gives no hashes in it: database users move without a password and sign in with an email code
92
+ * (and can set a password then). A hashes file from Auth0's support (one JSON object per line, or an array, each
93
+ * with the user's id or email and a bcrypt `passwordHash` / `password_hash`) moves theirs.
94
+ */
95
+ export declare function readAuth0(ndjson: string, hashes: string | undefined, o?: {
96
+ keepUnprovenPasswords?: boolean;
97
+ now?: number;
98
+ }): Reading;
99
+ /**
100
+ * Auth.js's database adapters: `users` (or `user`, `User`) with `id, name, email, emailVerified, image`, and
101
+ * `accounts` (`account`, `Account`) with `userId, provider, providerAccountId`, camelCase or snake_case. Verification
102
+ * tokens are ignored. Auth.js keeps no passwords (its credentials provider is the app's own code).
103
+ */
104
+ export declare const authjsReader: Reader;
105
+ /**
106
+ * Better Auth: `user` with `id, name, email, emailVerified, image, createdAt` (and `isAnonymous`, `phoneNumber`,
107
+ * `phoneNumberVerified` from its plugins), `account` with `userId, providerId, accountId, password`: providerId
108
+ * `credential` is a password (its scrypt hash, `salt:key`), apple, google and github the providers' accounts.
109
+ */
110
+ export declare const betterAuthReader: Reader;
111
+ export declare const firebaseReader: Reader;
112
+ export declare const clerkReader: Reader;
113
+ export declare const auth0Reader: Reader;
114
+ /**
115
+ * Firebase's hash parameters as the console shows them (`hash_config { algorithm: SCRYPT, base64_signer_key: …,
116
+ * base64_salt_separator: …, rounds: 8, mem_cost: 14 }`), or as JSON with those names; null when they aren't there.
117
+ */
118
+ export declare function parseFirebaseHash(t: string): FirebaseHash | null;
119
+ /** Whether `text` reads as the export `id` takes: undefined when it does, what's wrong otherwise. */
120
+ export declare function checkExport(id: string, text: string): string | undefined;
121
+ /** The move as the parts migrate sends one after another (see `BATCH`). */
122
+ export declare const moveParts: (sql: string) => string[];
123
+ /** The move, one transaction, refused a second time (`source_moved` in `{meta}`). */
124
+ export declare function accountsMoveSql(accounts: readonly Account[], o: {
125
+ prefix: string;
126
+ source: string;
127
+ now?: number;
128
+ }): string;
129
+ /** The way back: the moved users out (or direct-auth's tables dropped, when the move made them). */
130
+ export declare function accountsRollbackSql(existing: boolean, o: {
131
+ prefix: string;
132
+ source: string;
133
+ }): string;
134
+ /** What the dry run says: the reader's reading, counted the same way for every source. */
135
+ export declare function readingReport(r: Reading, existing: boolean, label: string): Report;
136
+ /** A source made from a reader: the same four steps as Supabase's. */
137
+ export declare function readerSource(reader: Reader): MigrationSource;
138
+ export declare const READERS: readonly Reader[];