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
package/dist/tui.d.ts
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `direct-auth init` on a terminal: a welcome, a checklist of the ways to sign in, a screen for each one chosen and
|
|
3
|
+
* one for what was written. Only when stdin and stderr are both a terminal; a pipe or a test gets the plain questions.
|
|
4
|
+
*
|
|
5
|
+
* The screens with keys (the welcome, the checklist, where the server runs) run in raw mode and are over before the
|
|
6
|
+
* line reader the questions use is made, so a key is read by one or the other, never both. Whatever happens, the
|
|
7
|
+
* terminal is given back as it was: raw mode off, the cursor shown.
|
|
8
|
+
*
|
|
9
|
+
* The parts that decide (`checklist`, `press`, `pick`) and draw (`welcomeScreen`, `providersScreen`, …) are pure,
|
|
10
|
+
* and tested as such; `Terminal` is the little that touches the terminal.
|
|
11
|
+
*/
|
|
12
|
+
import { type Key } from "node:readline";
|
|
13
|
+
import { type Host, type Provider } from "./init.ts";
|
|
14
|
+
import { type App } from "./apps.ts";
|
|
15
|
+
export type { Key };
|
|
16
|
+
export interface Style {
|
|
17
|
+
bold(text: string): string;
|
|
18
|
+
dim(text: string): string;
|
|
19
|
+
/** The wizard's own colour: titles, the cursor, the keys to press. */
|
|
20
|
+
accent(text: string): string;
|
|
21
|
+
/** Done, taken, checked. */
|
|
22
|
+
ok(text: string): string;
|
|
23
|
+
/** Worth a look: a provider already configured, a hint. */
|
|
24
|
+
note(text: string): string;
|
|
25
|
+
/** Refused, missing, wrong. */
|
|
26
|
+
bad(text: string): string;
|
|
27
|
+
/** Code to paste, set apart from the words around it. */
|
|
28
|
+
code(text: string): string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The terminal's own sixteen colours (cyan, green, yellow, red), so they follow its theme, light or dark; nothing at
|
|
32
|
+
* all when colour is off (NO_COLOR).
|
|
33
|
+
*/
|
|
34
|
+
export declare function style(color: boolean): Style;
|
|
35
|
+
/** Whitebear's bear, drawn from its logo in quarter blocks: the ears, the eyes running down to the cheeks, the nose, the split muzzle. */
|
|
36
|
+
export declare const BEAR: string[];
|
|
37
|
+
/**
|
|
38
|
+
* The welcome when the answers are piped in on a terminal (`cat answers | direct-auth init`): the bear, and what
|
|
39
|
+
* this does beside it. The wizard has its own screen.
|
|
40
|
+
*/
|
|
41
|
+
export declare function banner(color: boolean): string;
|
|
42
|
+
/** The wizard's first screen: what direct-auth is, what this does, the license. The bear only where there's room. */
|
|
43
|
+
export declare function welcomeScreen(color: boolean, columns?: number): string;
|
|
44
|
+
export interface Item {
|
|
45
|
+
id: string;
|
|
46
|
+
label: string;
|
|
47
|
+
detail: string;
|
|
48
|
+
/** Shown beside it; a disabled item can't be reached or checked. */
|
|
49
|
+
note?: string;
|
|
50
|
+
disabled?: boolean;
|
|
51
|
+
checked: boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface Checklist {
|
|
54
|
+
items: readonly Item[];
|
|
55
|
+
cursor: number;
|
|
56
|
+
/** A word for the person after a key that did nothing (Enter with none checked). */
|
|
57
|
+
hint?: string;
|
|
58
|
+
/** Enter with nothing checked goes on, with nothing: for a list that is an offer, not a choice to make. */
|
|
59
|
+
allowNone?: boolean;
|
|
60
|
+
}
|
|
61
|
+
export type Outcome = "confirm" | "quit" | "interrupt";
|
|
62
|
+
/** A list with the cursor on its first item that can be checked. */
|
|
63
|
+
export declare function checklist(items: readonly Item[]): Checklist;
|
|
64
|
+
/** What a key does to the list: moves the cursor (past what is disabled, round the ends), checks, confirms, quits. */
|
|
65
|
+
export declare function press(state: Checklist, key: Key): {
|
|
66
|
+
state: Checklist;
|
|
67
|
+
done?: Outcome;
|
|
68
|
+
};
|
|
69
|
+
export declare function checked(state: Checklist): string[];
|
|
70
|
+
/** The ways to sign in, as the checklist shows them. */
|
|
71
|
+
export declare const PROVIDERS: readonly {
|
|
72
|
+
id: Provider;
|
|
73
|
+
label: string;
|
|
74
|
+
detail: string;
|
|
75
|
+
}[];
|
|
76
|
+
/** The checklist to start from: nothing checked, what the env file has marked as configured. */
|
|
77
|
+
export declare function providerItems(configured: readonly Provider[]): Item[];
|
|
78
|
+
export declare function providersScreen(state: Checklist, color: boolean, envFile: string, columns?: number): string;
|
|
79
|
+
/**
|
|
80
|
+
* The header of one step's questions: its name, "step 2 of 4" and a bar of the steps, done ones filled. The server's
|
|
81
|
+
* step is the first of them all.
|
|
82
|
+
*/
|
|
83
|
+
export declare function stepScreen(step: Provider | "server", n: number, of: number, color: boolean): string;
|
|
84
|
+
/**
|
|
85
|
+
* The header of the last screen: the server and each provider set up, with a word on each, in columns; those left
|
|
86
|
+
* out after settings that didn't work, crossed.
|
|
87
|
+
*/
|
|
88
|
+
export declare function summaryScreen(set: readonly Provider[], left: readonly Provider[], color: boolean, details?: Partial<Record<Provider | "server", string>>): string;
|
|
89
|
+
export interface Option {
|
|
90
|
+
id: string;
|
|
91
|
+
label: string;
|
|
92
|
+
detail: string;
|
|
93
|
+
/** Shown beside it, as worth a look: "found here". */
|
|
94
|
+
note?: string;
|
|
95
|
+
}
|
|
96
|
+
export interface Choice {
|
|
97
|
+
options: readonly Option[];
|
|
98
|
+
cursor: number;
|
|
99
|
+
}
|
|
100
|
+
/** The options with the cursor on the one given, or the first. */
|
|
101
|
+
export declare function choice(options: readonly Option[], selected?: string): Choice;
|
|
102
|
+
/** What a key does to a choice: moves (round the ends), picks by its number, confirms, quits. */
|
|
103
|
+
export declare function pick(state: Choice, key: Key): {
|
|
104
|
+
state: Choice;
|
|
105
|
+
done?: Outcome;
|
|
106
|
+
};
|
|
107
|
+
export declare function chosen(state: Choice): string;
|
|
108
|
+
/** Where the server runs, the one this folder looks like (a supabase/ or wrangler file) marked and chosen. */
|
|
109
|
+
export declare function hostOptions(here?: Host): Option[];
|
|
110
|
+
export declare function hostScreen(state: Choice, color: boolean, envFile: string): string;
|
|
111
|
+
/** The apps as a checklist, all checked: they were found, so most likely wanted; the folder and what told, in columns. */
|
|
112
|
+
export declare function appItems(apps: readonly App[]): Item[];
|
|
113
|
+
export declare function appsScreen(state: Checklist, color: boolean, columns?: number): string;
|
|
114
|
+
/** The header of the questions after the checklist (the issuer's URL): the apps they go into. */
|
|
115
|
+
export declare function appsHeader(apps: readonly App[], color: boolean): string;
|
|
116
|
+
/**
|
|
117
|
+
* A spinner on one line, redrawn in place, until `done` writes its last line; the text cut to the terminal's
|
|
118
|
+
* width so it never wraps. Without colour the frames still turn (they're characters, not colour).
|
|
119
|
+
*/
|
|
120
|
+
export declare function spin(out: NodeJS.WriteStream, text: string, color: boolean): {
|
|
121
|
+
update(t: string): void;
|
|
122
|
+
done(line: string, tone?: "ok" | "note" | "bad" | "dim" | "code"): void;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* A line wrapped at words to `width`, each piece under the line's own indent (and a list's "1. " or "! " beside it).
|
|
126
|
+
* A word longer than the width (a URL, a command) stays whole on a line of its own.
|
|
127
|
+
*/
|
|
128
|
+
export declare function wrap(line: string, width: number): string[];
|
|
129
|
+
/** Escape codes and nothing else: what the screen reads as text. */
|
|
130
|
+
export declare function plain(text: string): string;
|
|
131
|
+
/**
|
|
132
|
+
* Raw mode for the screens that take keys, and the terminal given back on every way out: `restore()` when done, and
|
|
133
|
+
* on exit, an uncaught error, SIGINT or SIGTERM.
|
|
134
|
+
*/
|
|
135
|
+
export declare class Terminal {
|
|
136
|
+
#private;
|
|
137
|
+
readonly input: NodeJS.ReadStream;
|
|
138
|
+
readonly output: NodeJS.WriteStream;
|
|
139
|
+
constructor(input: NodeJS.ReadStream, output: NodeJS.WriteStream);
|
|
140
|
+
get columns(): number;
|
|
141
|
+
/** Keys one at a time, in raw mode, the cursor hidden. */
|
|
142
|
+
keys(): void;
|
|
143
|
+
key(): Promise<Key>;
|
|
144
|
+
/** The screen cleared and drawn anew; again with the same function when the window changes size. */
|
|
145
|
+
draw(screen: () => string): void;
|
|
146
|
+
/**
|
|
147
|
+
* Back to lines: raw mode off, the cursor shown, stdin paused until the line reader takes it. Keys typed ahead
|
|
148
|
+
* (with the Enter that ended the checklist, a paste) wait for `replay()`.
|
|
149
|
+
*/
|
|
150
|
+
lines(): void;
|
|
151
|
+
/** The keys typed ahead, handed to the line reader that now listens for them (readline takes keypress events). */
|
|
152
|
+
replay(): void;
|
|
153
|
+
/** A screen's worth of text, cleared first, outside raw mode (a step's header, the summary). */
|
|
154
|
+
clear(text: string): void;
|
|
155
|
+
/** The terminal as it was. Safe to call more than once. */
|
|
156
|
+
restore(): void;
|
|
157
|
+
/** Done with it: the terminal back, and the handlers off the process. */
|
|
158
|
+
close(): void;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* The welcome and the checklist. The providers checked, or how it was left: "quit" (q, Esc) or "interrupt" (Ctrl-C).
|
|
162
|
+
* Raw mode is over when it returns.
|
|
163
|
+
*/
|
|
164
|
+
export declare function chooseProviders(term: Terminal, o: {
|
|
165
|
+
color: boolean;
|
|
166
|
+
envFile: string;
|
|
167
|
+
configured: readonly Provider[];
|
|
168
|
+
}): Promise<Provider[] | "quit" | "interrupt">;
|
|
169
|
+
/** Where the server runs, on its own screen; raw mode is over when it returns. */
|
|
170
|
+
export declare function chooseHost(term: Terminal, o: {
|
|
171
|
+
color: boolean;
|
|
172
|
+
envFile: string;
|
|
173
|
+
here?: Host;
|
|
174
|
+
}): Promise<Host | "quit" | "interrupt">;
|
|
175
|
+
/** The apps to add the client to, from those found; none is an answer too. Raw mode is over when it returns. */
|
|
176
|
+
export declare function chooseApps(term: Terminal, apps: readonly App[], o: {
|
|
177
|
+
color: boolean;
|
|
178
|
+
}): Promise<App[] | "quit" | "interrupt">;
|