pi-durable-bot 0.6.1 → 0.7.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 +20 -2
- package/dist/agent/resources.js +12 -1
- package/dist/agent/resources.js.map +1 -1
- package/dist/bot/bot.js +54 -5
- package/dist/bot/bot.js.map +1 -1
- package/dist/bot/prompt.js +13 -3
- package/dist/bot/prompt.js.map +1 -1
- package/dist/channels/discord/index.js +202 -20
- package/dist/channels/discord/index.js.map +1 -1
- package/dist/channels/slack/index.js +314 -16
- package/dist/channels/slack/index.js.map +1 -1
- package/dist/channels/telegram/index.js +21 -2
- package/dist/channels/telegram/index.js.map +1 -1
- package/dist/cli/agent.js +20 -1
- package/dist/cli/agent.js.map +1 -1
- package/dist/cli/commands.js +28 -4
- package/dist/cli/commands.js.map +1 -1
- package/dist/cli/pages.js +44 -0
- package/dist/cli/pages.js.map +1 -0
- package/dist/core/channel.js +4 -1
- package/dist/core/channel.js.map +1 -1
- package/dist/core/env-file.js +23 -6
- package/dist/core/env-file.js.map +1 -1
- package/dist/core/forms.js +16 -0
- package/dist/core/forms.js.map +1 -0
- package/dist/gateway/errors.js +3 -0
- package/dist/gateway/errors.js.map +1 -1
- package/dist/gateway/forms.js +99 -0
- package/dist/gateway/forms.js.map +1 -0
- package/dist/gateway/gateway.js +23 -1
- package/dist/gateway/gateway.js.map +1 -1
- package/dist/gateway/log.js +7 -5
- package/dist/gateway/log.js.map +1 -1
- package/dist/gateway/waker.js +23 -8
- package/dist/gateway/waker.js.map +1 -1
- package/dist/main.js +7 -1
- package/dist/main.js.map +1 -1
- package/dist/pages/cloudflared.js +149 -0
- package/dist/pages/cloudflared.js.map +1 -0
- package/dist/pages/files.js +244 -0
- package/dist/pages/files.js.map +1 -0
- package/dist/pages/host.js +268 -0
- package/dist/pages/host.js.map +1 -0
- package/dist/pages/secret-page.js +71 -0
- package/dist/pages/secret-page.js.map +1 -0
- package/dist/pages/server.js +305 -0
- package/dist/pages/server.js.map +1 -0
- package/dist/pages/settings.js +71 -0
- package/dist/pages/settings.js.map +1 -0
- package/dist/pages/store.js +492 -0
- package/dist/pages/store.js.map +1 -0
- package/dist/pages/tunnel.js +271 -0
- package/dist/pages/tunnel.js.map +1 -0
- package/kit/pots.css +473 -0
- package/kit/pots.js +627 -0
- package/package.json +3 -2
- package/{docs/channels/discord.md → skills/discord-channel/SKILL.md} +55 -2
- package/skills/pages/SKILL.md +242 -0
- package/skills/slack-channel/SKILL.md +126 -0
- package/skills/telegram-channel/SKILL.md +89 -0
- package/docs/channels/slack.md +0 -70
- package/docs/channels/telegram.md +0 -50
- /package/{docs/channels → skills/slack-channel}/slack-app-manifest.yaml +0 -0
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { createServer } from "node:http";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { ensureCloudflared } from "./cloudflared.js";
|
|
4
|
+
import { readSettings, writeSetting } from "./settings.js";
|
|
5
|
+
import { PageRequests } from "./server.js";
|
|
6
|
+
import { PAGE_DAYS } from "./store.js";
|
|
7
|
+
import { QuickTunnel, stopLeftoverTunnel } from "./tunnel.js";
|
|
8
|
+
// The page server of a gateway: one per POTS_HOME, for every bot. Its port is chosen once and kept in settings.json; its
|
|
9
|
+
// public address is settings.json's publicUrl, or else a Cloudflare Quick Tunnel that starts at the first link.
|
|
10
|
+
/** kit/ of this package, next to src/ or dist/. */
|
|
11
|
+
const KIT_DIR = fileURLToPath(new URL("../../kit/", import.meta.url));
|
|
12
|
+
/** How often the server tries its port again while it cannot listen. */
|
|
13
|
+
const RETRY_MS = 30_000;
|
|
14
|
+
const DAY_MS = 86_400_000;
|
|
15
|
+
/** The facts the agent passes on when a link goes through a Quick Tunnel. */
|
|
16
|
+
export const QUICK_TUNNEL_NOTE = "This link goes through a Cloudflare Quick Tunnel: its address changes when Pots restarts, Cloudflare can see the page's content, and Cloudflare says Quick Tunnels are for testing and development.";
|
|
17
|
+
export const QUICK_TUNNEL_SECRET_NOTE = "This link goes through a Cloudflare Quick Tunnel: its address changes when Pots restarts, Cloudflare can see what is typed on the page, and Cloudflare says Quick Tunnels are for testing and development.";
|
|
18
|
+
const iso = (ms) => (ms === null ? null : new Date(ms).toISOString());
|
|
19
|
+
export class PageHost {
|
|
20
|
+
#options;
|
|
21
|
+
#bots = new Map();
|
|
22
|
+
#requests;
|
|
23
|
+
#server;
|
|
24
|
+
#port;
|
|
25
|
+
#problem;
|
|
26
|
+
#retry;
|
|
27
|
+
#tunnel;
|
|
28
|
+
#stopped = false;
|
|
29
|
+
constructor(options) {
|
|
30
|
+
this.#options = options;
|
|
31
|
+
this.#requests = new PageRequests({
|
|
32
|
+
bots: () => this.#bots.values(),
|
|
33
|
+
quickTunnel: () => this.#quickTunnel(),
|
|
34
|
+
kitDir: options.kitDir ?? KIT_DIR,
|
|
35
|
+
print: options.print,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
get port() {
|
|
39
|
+
return this.#port;
|
|
40
|
+
}
|
|
41
|
+
/** Listen on the kept port, or choose one and keep it. A port that is taken is reported, and tried again now and then. */
|
|
42
|
+
async start() {
|
|
43
|
+
// A tunnel a crashed gateway left would make the kept port public again, at its old address.
|
|
44
|
+
stopLeftoverTunnel(this.#options.home, this.#options.print);
|
|
45
|
+
await this.#listen();
|
|
46
|
+
if (!this.#server)
|
|
47
|
+
this.#retry = setInterval(() => void this.#listen(), RETRY_MS).unref();
|
|
48
|
+
}
|
|
49
|
+
async stop() {
|
|
50
|
+
this.#stopped = true;
|
|
51
|
+
clearInterval(this.#retry);
|
|
52
|
+
await this.#tunnel?.stop();
|
|
53
|
+
const server = this.#server;
|
|
54
|
+
this.#server = undefined;
|
|
55
|
+
if (server) {
|
|
56
|
+
server.closeAllConnections();
|
|
57
|
+
await new Promise((resolve) => server.close(() => resolve()));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
register(bot) {
|
|
61
|
+
this.#bots.set(bot.id, bot);
|
|
62
|
+
}
|
|
63
|
+
unregister(id) {
|
|
64
|
+
this.#bots.delete(id);
|
|
65
|
+
this.#requests.forget(id);
|
|
66
|
+
}
|
|
67
|
+
async #listen() {
|
|
68
|
+
if (this.#server || this.#stopped)
|
|
69
|
+
return;
|
|
70
|
+
const file = this.#options.settingsFile;
|
|
71
|
+
let port;
|
|
72
|
+
try {
|
|
73
|
+
port = readSettings(file).pagePort;
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
return this.#report(error instanceof Error ? error.message : String(error));
|
|
77
|
+
}
|
|
78
|
+
const server = createServer(this.#requests.handle);
|
|
79
|
+
try {
|
|
80
|
+
await new Promise((resolve, reject) => {
|
|
81
|
+
server.once("error", reject);
|
|
82
|
+
server.listen(port ?? 0, "127.0.0.1", () => resolve());
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
const code = error.code;
|
|
87
|
+
return this.#report(code === "EADDRINUSE" || code === "EACCES"
|
|
88
|
+
? `port ${port} (pagePort in ${file}) is taken by another program, so pages are not served; free it, or set another pagePort there and restart Pots (a Funnel or proxy that points at the old port must change too)`
|
|
89
|
+
: `the page server could not listen on 127.0.0.1:${port ?? 0}: ${error instanceof Error ? error.message : String(error)}`);
|
|
90
|
+
}
|
|
91
|
+
const chosen = server.address().port;
|
|
92
|
+
if (port === undefined) {
|
|
93
|
+
try {
|
|
94
|
+
await writeSetting("pagePort", chosen, file);
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
server.close();
|
|
98
|
+
return this.#report(`could not keep the page server's port in ${file}: ${error instanceof Error ? error.message : String(error)}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
this.#server = server;
|
|
102
|
+
this.#port = chosen;
|
|
103
|
+
this.#problem = undefined;
|
|
104
|
+
clearInterval(this.#retry);
|
|
105
|
+
this.#options.print("page server started", { port: chosen });
|
|
106
|
+
}
|
|
107
|
+
#report(problem) {
|
|
108
|
+
if (this.#problem !== problem)
|
|
109
|
+
this.#options.print("page server not running", { problem });
|
|
110
|
+
this.#problem = problem;
|
|
111
|
+
}
|
|
112
|
+
#quickTunnel() {
|
|
113
|
+
try {
|
|
114
|
+
return readSettings(this.#options.settingsFile).publicUrl === undefined;
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The public address links use now. With publicUrl in settings.json, that one, and a Quick Tunnel that still runs is
|
|
122
|
+
* stopped. Without it, the Quick Tunnel's address; start: start it if it does not run and wait for its address.
|
|
123
|
+
*/
|
|
124
|
+
async #address(start) {
|
|
125
|
+
const settings = readSettings(this.#options.settingsFile);
|
|
126
|
+
if (settings.publicUrl) {
|
|
127
|
+
if (this.#tunnel) {
|
|
128
|
+
const tunnel = this.#tunnel;
|
|
129
|
+
this.#tunnel = undefined;
|
|
130
|
+
await tunnel.stop();
|
|
131
|
+
this.#options.print("quick tunnel stopped: settings.json has a publicUrl");
|
|
132
|
+
}
|
|
133
|
+
return { base: settings.publicUrl, via: "public-url" };
|
|
134
|
+
}
|
|
135
|
+
if (!start)
|
|
136
|
+
return { ...(this.#tunnel?.address ? { base: this.#tunnel.address } : {}), via: "quick-tunnel" };
|
|
137
|
+
if (this.#port === undefined)
|
|
138
|
+
throw new Error(`the page server is not running: ${this.#problem ?? "it is starting"}`);
|
|
139
|
+
this.#tunnel ??= new QuickTunnel({
|
|
140
|
+
target: `http://127.0.0.1:${this.#port}`,
|
|
141
|
+
home: this.#options.home,
|
|
142
|
+
program: this.#options.cloudflared ?? (async () => [await ensureCloudflared(this.#options.binDir, { print: this.#options.print })]),
|
|
143
|
+
print: this.#options.print,
|
|
144
|
+
...this.#options.tunnel,
|
|
145
|
+
});
|
|
146
|
+
return { base: await this.#tunnel.ensure(), via: "quick-tunnel" };
|
|
147
|
+
}
|
|
148
|
+
#ready() {
|
|
149
|
+
if (this.#port === undefined)
|
|
150
|
+
throw new Error(`the page server is not running: ${this.#problem ?? "it is starting"}`);
|
|
151
|
+
}
|
|
152
|
+
/** pots page link: a new link to a page, written before it is given out. */
|
|
153
|
+
async link(bot, page, person) {
|
|
154
|
+
this.#ready();
|
|
155
|
+
const made = await bot.createLink(page, person);
|
|
156
|
+
let address;
|
|
157
|
+
try {
|
|
158
|
+
address = await this.#address(true);
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
await bot.revoke(made.id);
|
|
162
|
+
throw error;
|
|
163
|
+
}
|
|
164
|
+
return { link: made.id, url: `${address.base}/p/${made.token}/`, via: address.via, ...(address.via === "quick-tunnel" ? { note: QUICK_TUNNEL_NOTE } : {}) };
|
|
165
|
+
}
|
|
166
|
+
/** pots page secret: a password link for one submission, open for an hour. */
|
|
167
|
+
async secret(bot, input) {
|
|
168
|
+
this.#ready();
|
|
169
|
+
const made = await bot.createSecretLink(input);
|
|
170
|
+
let address;
|
|
171
|
+
try {
|
|
172
|
+
address = await this.#address(true);
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
await bot.revoke(made.id);
|
|
176
|
+
throw error;
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
link: made.id,
|
|
180
|
+
url: `${address.base}/s/${made.token}`,
|
|
181
|
+
expires: new Date(made.expiresAt).toISOString(),
|
|
182
|
+
via: address.via,
|
|
183
|
+
...(address.via === "quick-tunnel" ? { note: QUICK_TUNNEL_SECRET_NOTE } : {}),
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
/** pots page unlink: by link ID or by URL. */
|
|
187
|
+
async unlink(bot, link) {
|
|
188
|
+
const token = /\/(?:p|s)\/([A-Za-z0-9_-]{16,128})(?:\/|$)/.exec(link)?.[1];
|
|
189
|
+
const revoked = await bot.revoke(token ?? link.trim());
|
|
190
|
+
if (!revoked)
|
|
191
|
+
throw new Error(`there is no link ${JSON.stringify(link)} of this bot (pots page list shows them)`);
|
|
192
|
+
return `Unlinked ${revoked}.`;
|
|
193
|
+
}
|
|
194
|
+
/** pots page list: the bot's pages and links, with their URLs at the address links use now. */
|
|
195
|
+
async list(bot) {
|
|
196
|
+
const listing = await bot.list();
|
|
197
|
+
let address = { via: "quick-tunnel" };
|
|
198
|
+
let problem;
|
|
199
|
+
try {
|
|
200
|
+
address = await this.#address(false);
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
problem = error instanceof Error ? error.message : String(error);
|
|
204
|
+
}
|
|
205
|
+
const url = (path) => (address.base ? `${address.base}${path}` : null);
|
|
206
|
+
return {
|
|
207
|
+
via: address.via,
|
|
208
|
+
address: address.base ?? null,
|
|
209
|
+
...(address.base ? {} : { addressNote: problem ?? "no Quick Tunnel runs now; the next pots page link or pots page secret starts one, and these links work again at its address" }),
|
|
210
|
+
pages: listing.pages.map((page) => ({
|
|
211
|
+
page: page.page,
|
|
212
|
+
kept: page.kept,
|
|
213
|
+
version: page.version,
|
|
214
|
+
lastOpened: iso(page.lastOpened),
|
|
215
|
+
lastChanged: iso(page.lastChanged),
|
|
216
|
+
deleteAfter: page.kept || page.lastChanged === null ? null : iso(Math.max(page.lastOpened ?? 0, page.lastChanged) + PAGE_DAYS * DAY_MS),
|
|
217
|
+
links: page.links.map((link) => ({ link: link.link, url: url(`/p/${link.token}/`), for: link.for, created: iso(link.created) })),
|
|
218
|
+
})),
|
|
219
|
+
secretLinks: listing.secretLinks.map((link) => ({
|
|
220
|
+
link: link.link,
|
|
221
|
+
url: url(`/s/${link.token}`),
|
|
222
|
+
file: link.file,
|
|
223
|
+
keys: link.keys,
|
|
224
|
+
for: link.for,
|
|
225
|
+
created: iso(link.created),
|
|
226
|
+
expires: iso(link.expires),
|
|
227
|
+
state: link.state,
|
|
228
|
+
})),
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
/** For pots status. */
|
|
232
|
+
status() {
|
|
233
|
+
let via;
|
|
234
|
+
let address;
|
|
235
|
+
let problem = this.#problem;
|
|
236
|
+
try {
|
|
237
|
+
const publicUrl = readSettings(this.#options.settingsFile).publicUrl;
|
|
238
|
+
via = publicUrl ? "public-url" : "quick-tunnel";
|
|
239
|
+
address = publicUrl ?? this.#tunnel?.address;
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
problem ??= error instanceof Error ? error.message : String(error);
|
|
243
|
+
}
|
|
244
|
+
return {
|
|
245
|
+
...(this.#port === undefined ? {} : { port: this.#port }),
|
|
246
|
+
listening: this.#server !== undefined,
|
|
247
|
+
...(problem ? { problem } : {}),
|
|
248
|
+
...(via ? { via } : {}),
|
|
249
|
+
...(address ? { address } : {}),
|
|
250
|
+
...(this.#tunnel ? { tunnel: this.#tunnel.status() } : {}),
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
/** One line for pots status. */
|
|
255
|
+
export function describePageServer(status, keptPort) {
|
|
256
|
+
if (!status)
|
|
257
|
+
return `pages: not running${keptPort === undefined ? "" : ` (port ${keptPort})`}`;
|
|
258
|
+
if (!status.listening)
|
|
259
|
+
return `pages: not served: ${status.problem ?? "starting"}`;
|
|
260
|
+
const port = `port ${status.port}`;
|
|
261
|
+
if (status.problem)
|
|
262
|
+
return `pages: ${port}; ${status.problem}`;
|
|
263
|
+
if (status.address)
|
|
264
|
+
return `pages: ${port}, ${status.address} (${status.via})`;
|
|
265
|
+
const tunnel = status.tunnel?.error ? `; ${status.tunnel.error}` : "";
|
|
266
|
+
return `pages: ${port}, no public address yet (quick-tunnel: it starts at the first pots page link${tunnel})`;
|
|
267
|
+
}
|
|
268
|
+
//# sourceMappingURL=host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.js","sourceRoot":"","sources":["../../src/pages/host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,iBAAiB,EAAE,MAAM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E,CAAC;IACnF,MAAM,IAAI,GAAG,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;IACnC,IAAI,MAAM,CAAC,OAAO;QAAE,OAAO,UAAU,IAAI,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC;IAC/D,IAAI,MAAM,CAAC,OAAO;QAAE,OAAO,UAAU,IAAI,KAAK,MAAM,CAAC,OAAO,KAAK,MAAM,CAAC,GAAG,GAAG,CAAC;IAC/E,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACtE,OAAO,UAAU,IAAI,+EAA+E,MAAM,GAAG,CAAC;AAChH,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// The password page: Pots's own HTML, never the bot's. A plain form and no script, so it works in the strictest sandbox.
|
|
2
|
+
/**
|
|
3
|
+
* The headers that keep the password page apart from the bot's pages, which share its address: the browser gives it an
|
|
4
|
+
* origin of its own (sandbox without allow-same-origin), so a bot page's script cannot read what is typed; nothing loads
|
|
5
|
+
* from anywhere, no script runs, and no page can frame it.
|
|
6
|
+
*/
|
|
7
|
+
export const SECRET_PAGE_HEADERS = {
|
|
8
|
+
"content-security-policy": "sandbox allow-forms; default-src 'none'; style-src 'unsafe-inline'; frame-ancestors 'none'; base-uri 'none'",
|
|
9
|
+
"x-frame-options": "DENY",
|
|
10
|
+
"cross-origin-opener-policy": "same-origin",
|
|
11
|
+
"cache-control": "no-store",
|
|
12
|
+
};
|
|
13
|
+
const escape = (text) => text.replace(/[&<>"']/g, (char) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[char]);
|
|
14
|
+
const STYLE = `
|
|
15
|
+
:root { color-scheme: light dark; --fg: #1d2321; --muted: #5b6662; --line: #d5dbd8; --bg: #f7f8f7; --card: #fff; --accent: #1f7a70; --warn-bg: #fff6e0; --warn-fg: #6b4a00; }
|
|
16
|
+
@media (prefers-color-scheme: dark) { :root { --fg: #e8ecea; --muted: #a3aeaa; --line: #3a4441; --bg: #141917; --card: #1d2421; --accent: #4fb3a6; --warn-bg: #3a2f12; --warn-fg: #f3d58a; } }
|
|
17
|
+
* { box-sizing: border-box; }
|
|
18
|
+
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--fg); background: var(--bg); }
|
|
19
|
+
main { max-width: 34rem; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
|
|
20
|
+
h1 { font-size: 1.3rem; line-height: 1.3; margin: 0 0 1rem; }
|
|
21
|
+
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1.25rem; }
|
|
22
|
+
.text { white-space: pre-wrap; margin: 0 0 1rem; }
|
|
23
|
+
label { display: block; font-weight: 600; margin: 1rem 0 0.35rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.95rem; word-break: break-all; }
|
|
24
|
+
input { width: 100%; font: inherit; padding: 0.7rem 0.8rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); }
|
|
25
|
+
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
|
|
26
|
+
button { margin-top: 1.25rem; width: 100%; font: inherit; font-weight: 600; padding: 0.8rem; border: 0; border-radius: 8px; background: var(--accent); color: #fff; }
|
|
27
|
+
.facts { color: var(--muted); font-size: 0.9rem; margin: 1rem 0 0; }
|
|
28
|
+
.warn { background: var(--warn-bg); color: var(--warn-fg); border-radius: 8px; padding: 0.75rem 0.9rem; font-size: 0.9rem; margin: 1rem 0 0; }
|
|
29
|
+
.problem { color: #b3261e; font-weight: 600; margin: 0 0 0.5rem; }
|
|
30
|
+
`;
|
|
31
|
+
function page(title, body) {
|
|
32
|
+
return `<!doctype html>
|
|
33
|
+
<html lang="en">
|
|
34
|
+
<head>
|
|
35
|
+
<meta charset="utf-8">
|
|
36
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
37
|
+
<meta name="referrer" content="no-referrer">
|
|
38
|
+
<meta name="robots" content="noindex">
|
|
39
|
+
<title>${escape(title)}</title>
|
|
40
|
+
<style>${STYLE}</style>
|
|
41
|
+
</head>
|
|
42
|
+
<body><main>${body}</main></body>
|
|
43
|
+
</html>
|
|
44
|
+
`;
|
|
45
|
+
}
|
|
46
|
+
/** What the person sees while the link is open: one masked field per key, and the facts about where the values go. */
|
|
47
|
+
export function renderSecretForm(link, botName, options) {
|
|
48
|
+
const minutes = Math.max(1, Math.ceil((link.expiresAt - options.now) / 60_000));
|
|
49
|
+
const fields = link.keys
|
|
50
|
+
.map((key, index) => `<label for="k${index}">${escape(key)}</label><input id="k${index}" name="${escape(key)}" type="password" required autocomplete="off" autocapitalize="off" autocorrect="off" spellcheck="false">`)
|
|
51
|
+
.join("\n");
|
|
52
|
+
const warn = options.quickTunnel
|
|
53
|
+
? `<p class="warn">This page reaches ${escape(botName)} through a Cloudflare Quick Tunnel, so Cloudflare can see what you type here. For a private connection, ask ${escape(botName)} to set up Tailscale Funnel first.</p>`
|
|
54
|
+
: "";
|
|
55
|
+
return page(`${botName} asks for ${link.keys.length === 1 ? "a secret" : "secrets"}`, `<h1>${escape(botName)} asks for ${link.keys.length === 1 ? "a secret value" : `${link.keys.length} secret values`}</h1>
|
|
56
|
+
<div class="card">
|
|
57
|
+
${options.problem ? `<p class="problem">${escape(options.problem)}</p>` : ""}${link.text ? `<p class="text">${escape(link.text)}</p>` : ""}
|
|
58
|
+
<form method="post" accept-charset="utf-8" autocomplete="off">
|
|
59
|
+
${fields}
|
|
60
|
+
<button type="submit">Save (this link works once)</button>
|
|
61
|
+
</form>
|
|
62
|
+
<p class="facts">What you type goes only to the file ${escape(link.file)} in the secrets folder on ${escape(botName)}'s computer. It does not go into the chat. ${escape(botName)} is told which keys came, not their values. This link expires in about ${minutes} minute${minutes === 1 ? "" : "s"}.</p>
|
|
63
|
+
${warn}
|
|
64
|
+
</div>`);
|
|
65
|
+
}
|
|
66
|
+
export const renderSecretSaved = (link, botName) => page("Saved", `<h1>Saved</h1><div class="card"><p>${escape(link.keys.join(", "))} ${link.keys.length === 1 ? "was" : "were"} written to ${escape(link.file)}. ${escape(botName)} was told which keys came, not their values. You can close this page.</p></div>`);
|
|
67
|
+
export const renderSecretUsed = () => page("Link already used", `<h1>This link was already used</h1><div class="card"><p>Each password link works once. Ask for a new link if you need to change a value.</p></div>`);
|
|
68
|
+
export const renderSecretExpired = () => page("Link expired", `<h1>This link expired</h1><div class="card"><p>A password link works for one hour. Ask for a new link.</p></div>`);
|
|
69
|
+
export const renderNotFound = () => page("Not found", `<h1>Not found</h1><div class="card"><p>This link does not exist, or it was taken back.</p></div>`);
|
|
70
|
+
export const renderFailed = (reason) => page("Not saved", `<h1>Not saved</h1><div class="card"><p>${escape(reason)}</p><p>Try again in a moment.</p></div>`);
|
|
71
|
+
//# sourceMappingURL=secret-page.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret-page.js","sourceRoot":"","sources":["../../src/pages/secret-page.ts"],"names":[],"mappings":"AAEA,yHAAyH;AAEzH;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,yBAAyB,EAAE,6GAA6G;IACxI,iBAAiB,EAAE,MAAM;IACzB,4BAA4B,EAAE,aAAa;IAC3C,eAAe,EAAE,UAAU;CACnB,CAAC;AAEX,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC,IAAI,CAAE,CAAC,CAAC;AAEtJ,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;CAgBb,CAAC;AAEF,SAAS,IAAI,CAA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