litepaseo 0.9.2 → 0.10.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 -0
- package/dist/server/cli.mjs +88 -45
- package/dist/server/{worker-Cq2Lf-Zo.mjs → worker-BaZ4l9qs.mjs} +3716 -3217
- package/dist/web/assets/ChangesPanel-DwGaEASF.js +2 -0
- package/dist/web/assets/ChangesPanel-DwGaEASF.js.br +0 -0
- package/dist/web/assets/ChangesPanel-DwGaEASF.js.gz +0 -0
- package/dist/web/assets/CodeBlockNode-DxXVSRz7.js +3 -0
- package/dist/web/assets/CodeBlockNode-DxXVSRz7.js.br +0 -0
- package/dist/web/assets/CodeBlockNode-DxXVSRz7.js.gz +0 -0
- package/dist/web/assets/ConversationSearch-C6rI4eKl.css +1 -0
- package/dist/web/assets/ConversationSearch-C6rI4eKl.css.br +0 -0
- package/dist/web/assets/ConversationSearch-C6rI4eKl.css.gz +0 -0
- package/dist/web/assets/ConversationSearch-DwDKf1dl.js +1 -0
- package/dist/web/assets/ConversationSearch-DwDKf1dl.js.br +0 -0
- package/dist/web/assets/ConversationSearch-DwDKf1dl.js.gz +0 -0
- package/dist/web/assets/FileViewer-CGGHa7cJ.js +2 -0
- package/dist/web/assets/FileViewer-CGGHa7cJ.js.br +0 -0
- package/dist/web/assets/FileViewer-CGGHa7cJ.js.gz +0 -0
- package/dist/web/assets/FileViewer-DK0Fgglf.css +1 -0
- package/dist/web/assets/FileViewer-DK0Fgglf.css.br +0 -0
- package/dist/web/assets/FileViewer-DK0Fgglf.css.gz +0 -0
- package/dist/web/assets/FilesPanel-DmPAJwih.css +1 -0
- package/dist/web/assets/FilesPanel-DmPAJwih.css.br +0 -0
- package/dist/web/assets/FilesPanel-DmPAJwih.css.gz +0 -0
- package/dist/web/assets/FilesPanel-RAjksMEu.js +1 -0
- package/dist/web/assets/FilesPanel-RAjksMEu.js.br +0 -0
- package/dist/web/assets/FilesPanel-RAjksMEu.js.gz +0 -0
- package/dist/web/assets/HostSettings--0Jl-MlL.css +1 -0
- package/dist/web/assets/HostSettings--0Jl-MlL.css.br +0 -0
- package/dist/web/assets/HostSettings--0Jl-MlL.css.gz +0 -0
- package/dist/web/assets/HostSettings-BZ1-4iFu.js +5 -0
- package/dist/web/assets/HostSettings-BZ1-4iFu.js.br +0 -0
- package/dist/web/assets/HostSettings-BZ1-4iFu.js.gz +0 -0
- package/dist/web/assets/KanbanPage-CbKUloyg.js +1 -0
- package/dist/web/assets/KanbanPage-CbKUloyg.js.br +0 -0
- package/dist/web/assets/KanbanPage-CbKUloyg.js.gz +0 -0
- package/dist/web/assets/{MarkdownMessage-DbSS5ULZ.js → MarkdownMessage-DBmeBhJ-.js} +13 -13
- package/dist/web/assets/MarkdownMessage-DBmeBhJ-.js.br +0 -0
- package/dist/web/assets/MarkdownMessage-DBmeBhJ-.js.gz +0 -0
- package/dist/web/assets/{PreCodeBlock-B-6jTSFa.js → PreCodeBlock-DO2IaZYy.js} +1 -1
- package/dist/web/assets/{PreCodeBlock.vue_vue_type_style_index_0_lang-CunCuyah.js → PreCodeBlock.vue_vue_type_style_index_0_lang-163mjX6u.js} +1 -1
- package/dist/web/assets/PreCodeBlock.vue_vue_type_style_index_0_lang-163mjX6u.js.br +0 -0
- package/dist/web/assets/PreCodeBlock.vue_vue_type_style_index_0_lang-163mjX6u.js.gz +0 -0
- package/dist/web/assets/{SubagentsPanel-iAwY_tlt.css → SubagentsPanel-BwR5tVCn.css} +1 -1
- package/dist/web/assets/SubagentsPanel-BwR5tVCn.css.br +0 -0
- package/dist/web/assets/SubagentsPanel-BwR5tVCn.css.gz +0 -0
- package/dist/web/assets/SubagentsPanel-CZmbSXw8.js +1 -0
- package/dist/web/assets/SubagentsPanel-CZmbSXw8.js.br +0 -0
- package/dist/web/assets/SubagentsPanel-CZmbSXw8.js.gz +0 -0
- package/dist/web/assets/TerminalPanel-B9CM91-N.js +3 -0
- package/dist/web/assets/TerminalPanel-B9CM91-N.js.br +0 -0
- package/dist/web/assets/TerminalPanel-B9CM91-N.js.gz +0 -0
- package/dist/web/assets/{TerminalPanel-BzfVCEVB.css → TerminalPanel-CgwrWov9.css} +1 -1
- package/dist/web/assets/TerminalPanel-CgwrWov9.css.br +0 -0
- package/dist/web/assets/TerminalPanel-CgwrWov9.css.gz +0 -0
- package/dist/web/assets/Tooltip-DlLPEjKA.js +1 -0
- package/dist/web/assets/Tooltip-DlLPEjKA.js.br +0 -0
- package/dist/web/assets/Tooltip-DlLPEjKA.js.gz +0 -0
- package/dist/web/assets/index-DLDmaAcb.css +1 -0
- package/dist/web/assets/index-DLDmaAcb.css.br +0 -0
- package/dist/web/assets/index-DLDmaAcb.css.gz +0 -0
- package/dist/web/assets/index-DtyN_9Jk.js +35 -0
- package/dist/web/assets/index-DtyN_9Jk.js.br +0 -0
- package/dist/web/assets/index-DtyN_9Jk.js.gz +0 -0
- package/dist/web/assets/index10--uzu8R8L.js +6 -0
- package/dist/web/assets/index10--uzu8R8L.js.br +0 -0
- package/dist/web/assets/index10--uzu8R8L.js.gz +0 -0
- package/dist/web/assets/index3-Cz2x76PB.js +1 -0
- package/dist/web/assets/index4-Btrr4RLY.js +1 -0
- package/dist/web/assets/{index5-Bp-1tRh4.js → index5-Dl0mOQin.js} +1 -1
- package/dist/web/assets/index5-Dl0mOQin.js.br +0 -0
- package/dist/web/assets/index5-Dl0mOQin.js.gz +0 -0
- package/dist/web/assets/{index6-B8l4-gzx.js → index6-BwF5NLGg.js} +1 -1
- package/dist/web/assets/index6-BwF5NLGg.js.br +0 -0
- package/dist/web/assets/index6-BwF5NLGg.js.gz +0 -0
- package/dist/web/assets/index7-CHg4mDfW.js +2 -0
- package/dist/web/assets/index7-CHg4mDfW.js.br +0 -0
- package/dist/web/assets/index7-CHg4mDfW.js.gz +0 -0
- package/dist/web/assets/index8-CN9u-91M.js +2 -0
- package/dist/web/assets/index8-CN9u-91M.js.br +0 -0
- package/dist/web/assets/index8-CN9u-91M.js.gz +0 -0
- package/dist/web/assets/{index9-B_ZyF9x1.js → index9-jEPOF8GE.js} +1 -1
- package/dist/web/assets/index9-jEPOF8GE.js.br +0 -0
- package/dist/web/assets/index9-jEPOF8GE.js.gz +0 -0
- package/dist/web/assets/{vue.runtime.esm-bundler-4XjPOHMM.js → vue.runtime.esm-bundler-DmQNwI70.js} +1 -1
- package/dist/web/assets/vue.runtime.esm-bundler-DmQNwI70.js.br +0 -0
- package/dist/web/assets/{vue.runtime.esm-bundler-4XjPOHMM.js.gz → vue.runtime.esm-bundler-DmQNwI70.js.gz} +0 -0
- package/dist/web/index.html +8 -6
- package/dist/web/index.html.br +0 -0
- package/dist/web/index.html.gz +0 -0
- package/dist/web/sw.js +9 -2
- package/dist/web/sw.js.br +0 -0
- package/dist/web/sw.js.gz +0 -0
- package/package.json +1 -1
- package/dist/web/assets/ChangesPanel-BXtRMTqp.js +0 -2
- package/dist/web/assets/ChangesPanel-BXtRMTqp.js.br +0 -0
- package/dist/web/assets/ChangesPanel-BXtRMTqp.js.gz +0 -0
- package/dist/web/assets/CodeBlockNode-B9X7WZtj.js +0 -3
- package/dist/web/assets/CodeBlockNode-B9X7WZtj.js.br +0 -0
- package/dist/web/assets/CodeBlockNode-B9X7WZtj.js.gz +0 -0
- package/dist/web/assets/ConversationSearch-BD_oQkce.css +0 -1
- package/dist/web/assets/ConversationSearch-DgRoYzWP.js +0 -1
- package/dist/web/assets/ConversationSearch-DgRoYzWP.js.br +0 -0
- package/dist/web/assets/ConversationSearch-DgRoYzWP.js.gz +0 -0
- package/dist/web/assets/FileViewer-B-N8t-A2.js +0 -2
- package/dist/web/assets/FileViewer-B-N8t-A2.js.br +0 -0
- package/dist/web/assets/FileViewer-B-N8t-A2.js.gz +0 -0
- package/dist/web/assets/FileViewer-D0xXViyr.css +0 -1
- package/dist/web/assets/FileViewer-D0xXViyr.css.br +0 -0
- package/dist/web/assets/FileViewer-D0xXViyr.css.gz +0 -0
- package/dist/web/assets/FilesPanel-B0AM9mBQ.css +0 -1
- package/dist/web/assets/FilesPanel-B0AM9mBQ.css.br +0 -0
- package/dist/web/assets/FilesPanel-B0AM9mBQ.css.gz +0 -0
- package/dist/web/assets/FilesPanel-By85fwCy.js +0 -1
- package/dist/web/assets/FilesPanel-By85fwCy.js.br +0 -0
- package/dist/web/assets/FilesPanel-By85fwCy.js.gz +0 -0
- package/dist/web/assets/HostSettings-Bzv1FBbL.js +0 -5
- package/dist/web/assets/HostSettings-Bzv1FBbL.js.br +0 -0
- package/dist/web/assets/HostSettings-Bzv1FBbL.js.gz +0 -0
- package/dist/web/assets/HostSettings-DmJrFVbt.css +0 -1
- package/dist/web/assets/HostSettings-DmJrFVbt.css.br +0 -0
- package/dist/web/assets/HostSettings-DmJrFVbt.css.gz +0 -0
- package/dist/web/assets/MarkdownMessage-DbSS5ULZ.js.br +0 -0
- package/dist/web/assets/MarkdownMessage-DbSS5ULZ.js.gz +0 -0
- package/dist/web/assets/PreCodeBlock.vue_vue_type_style_index_0_lang-CunCuyah.js.br +0 -0
- package/dist/web/assets/PreCodeBlock.vue_vue_type_style_index_0_lang-CunCuyah.js.gz +0 -0
- package/dist/web/assets/SubagentsPanel-CdZce3Xr.js +0 -1
- package/dist/web/assets/SubagentsPanel-CdZce3Xr.js.br +0 -0
- package/dist/web/assets/SubagentsPanel-CdZce3Xr.js.gz +0 -0
- package/dist/web/assets/SubagentsPanel-iAwY_tlt.css.br +0 -0
- package/dist/web/assets/SubagentsPanel-iAwY_tlt.css.gz +0 -0
- package/dist/web/assets/TerminalPanel-BzfVCEVB.css.br +0 -0
- package/dist/web/assets/TerminalPanel-BzfVCEVB.css.gz +0 -0
- package/dist/web/assets/TerminalPanel-iBK2wpI0.js +0 -3
- package/dist/web/assets/TerminalPanel-iBK2wpI0.js.br +0 -0
- package/dist/web/assets/TerminalPanel-iBK2wpI0.js.gz +0 -0
- package/dist/web/assets/Tooltip-DLPAOJ1c.js +0 -1
- package/dist/web/assets/Tooltip-DLPAOJ1c.js.br +0 -0
- package/dist/web/assets/Tooltip-DLPAOJ1c.js.gz +0 -0
- package/dist/web/assets/index-CwWokVo4.css +0 -1
- package/dist/web/assets/index-CwWokVo4.css.br +0 -0
- package/dist/web/assets/index-CwWokVo4.css.gz +0 -0
- package/dist/web/assets/index-DV5BdS_U.js +0 -35
- package/dist/web/assets/index-DV5BdS_U.js.br +0 -0
- package/dist/web/assets/index-DV5BdS_U.js.gz +0 -0
- package/dist/web/assets/index10-DgcnbLc5.js +0 -6
- package/dist/web/assets/index10-DgcnbLc5.js.br +0 -0
- package/dist/web/assets/index10-DgcnbLc5.js.gz +0 -0
- package/dist/web/assets/index3-BdNVIlGK.js +0 -1
- package/dist/web/assets/index4-DnuPr-1i.js +0 -1
- package/dist/web/assets/index5-Bp-1tRh4.js.br +0 -0
- package/dist/web/assets/index5-Bp-1tRh4.js.gz +0 -0
- package/dist/web/assets/index6-B8l4-gzx.js.br +0 -0
- package/dist/web/assets/index6-B8l4-gzx.js.gz +0 -0
- package/dist/web/assets/index7-CIxLf3CP.js +0 -2
- package/dist/web/assets/index7-CIxLf3CP.js.br +0 -0
- package/dist/web/assets/index7-CIxLf3CP.js.gz +0 -0
- package/dist/web/assets/index8-CnHhIOzI.js +0 -2
- package/dist/web/assets/index8-CnHhIOzI.js.br +0 -0
- package/dist/web/assets/index8-CnHhIOzI.js.gz +0 -0
- package/dist/web/assets/index9-B_ZyF9x1.js.br +0 -0
- package/dist/web/assets/index9-B_ZyF9x1.js.gz +0 -0
- package/dist/web/assets/vue.runtime.esm-bundler-4XjPOHMM.js.br +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.10.0
|
|
4
|
+
|
|
5
|
+
- Security hardening:
|
|
6
|
+
- Tie stored voice-input API keys to their transcription service's origin so changing the base URL requires entering a key again, and reject credentials, query strings, or fragments in the base URL.
|
|
7
|
+
- Block local, private, and link-local addresses (including across DNS lookups, redirects, and page `<link>` tags) when importing project icons by URL.
|
|
8
|
+
- Prune expired sign-in rate-limit entries so a flood of clients cannot permanently lock new logins into the shared overflow bucket, and trust forwarding headers only from loopback proxies.
|
|
9
|
+
- Guard WebSocket upgrade URL parsing against malformed targets, restrict service-worker notification clicks to same-origin URLs, and protect emitted links/images in the fallback Markdown renderer from formatting corruption.
|
|
10
|
+
- Stability, concurrency & resource cleanup:
|
|
11
|
+
- Fix materialized message images on macOS (where `/tmp` and `tmpdir()` resolve through `/private`), and add a UUIDv4 fallback so plain-HTTP LAN connections work without `crypto.randomUUID`.
|
|
12
|
+
- Fix KeepAlive conversation switching so a late load from a backgrounded conversation never marks the newly opened conversation as read, and fix the tab/app waiting badge tracking the wrong store.
|
|
13
|
+
- Fix race conditions across the terminal (input batches stay with the terminal they were typed into), file browser, file viewer, agent controls, attachment retries, and schedule editor (editing a schedule no longer resets a non-default model).
|
|
14
|
+
- Add byte-based backpressure and cleanup to SSE streams, graceful shutdown and preview-window cancellation to push notifications, a timeout and lower memory footprint to the server send queue, and full cleanup of message images, pins, and queued messages when removing a host.
|
|
15
|
+
- Fix subagent event retry loops, HostMirror paged-snapshot overwrites, TimelineView catch-up edge cases, and frontend menu/KeepAlive listener leaks.
|
|
16
|
+
- UI, accessibility & mobile polish:
|
|
17
|
+
- Replace native browser `confirm()` prompts with a theme-aware confirmation dialog and shared keyboard/focus-trap handling across dialogs and menus.
|
|
18
|
+
- Eliminate theme flash on load with a CSP-hashed inline script, sync the PWA `theme-color` with the active sidebar color, and raise faint/warning text contrast to meet WCAG AA.
|
|
19
|
+
- Fix styling in conversation search, composer notices, and header panel active states; improve mobile touch targets, landscape safe areas, and narrow header layout.
|
|
20
|
+
- Codebase modularization:
|
|
21
|
+
- Split the server (`app.ts`), web shell (`App.vue`, `HostSettings.vue`), and stylesheet (`style.css`) into focused modules, lazy-loading the Kanban board and shrinking both the main JS and CSS bundles.
|
|
22
|
+
|
|
3
23
|
## 0.9.2
|
|
4
24
|
|
|
5
25
|
- Open conversations with a plain request instead of the live stream. On an iPhone web app behind a Cloudflare Tunnel, the stream's first 16 KB arrived at once but the rest of a conversation was held back until the stream's next heartbeat, about 20 seconds later. A plain response has an end, so nothing waits for more data. The live stream then resumes from those rows and carries only what changes. Servers or proxies that do not offer the new request (`GET …/timeline/latest`) still get the rows from the stream, as before.
|
package/dist/server/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { appendFileSync, chmodSync, closeSync, constants, copyFileSync, cpSync, existsSync, ftruncateSync, lstatSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
|
|
2
|
+
import { appendFileSync, chmodSync, closeSync, constants, copyFileSync, cpSync, existsSync, fstatSync, ftruncateSync, lstatSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
|
|
3
3
|
import { createHash, createHmac, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
|
|
4
4
|
import { execFileSync, fork, spawn } from "node:child_process";
|
|
5
5
|
import { dirname, join, resolve } from "node:path";
|
|
@@ -8,7 +8,7 @@ import { DatabaseSync } from "node:sqlite";
|
|
|
8
8
|
import { homedir } from "node:os";
|
|
9
9
|
import { fileURLToPath } from "node:url";
|
|
10
10
|
// src/server/version.ts
|
|
11
|
-
const VERSION = "0.
|
|
11
|
+
const VERSION = "0.10.0";
|
|
12
12
|
// src/server/rotating-log.ts
|
|
13
13
|
/** One writer (the supervisor); bounded active file plus numbered archives. */
|
|
14
14
|
var RotatingLog = class {
|
|
@@ -214,11 +214,13 @@ function manageService(action, options, run = (file, args) => execFileSync(file,
|
|
|
214
214
|
"--now",
|
|
215
215
|
definition.name
|
|
216
216
|
]);
|
|
217
|
-
else
|
|
218
|
-
"
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
217
|
+
else try {
|
|
218
|
+
run("launchctl", [
|
|
219
|
+
"bootout",
|
|
220
|
+
`gui/${options.uid}`,
|
|
221
|
+
definition.path
|
|
222
|
+
]);
|
|
223
|
+
} catch {}
|
|
222
224
|
unlinkSync(definition.path);
|
|
223
225
|
if (options.platform === "linux") run("systemctl", ["--user", "daemon-reload"]);
|
|
224
226
|
return "Autostart removed; application data is preserved.";
|
|
@@ -483,6 +485,26 @@ var Store = class {
|
|
|
483
485
|
if (value === null) this.db.prepare("DELETE FROM settings WHERE key=?").run(key);
|
|
484
486
|
else this.db.prepare("INSERT INTO settings VALUES(?,?) ON CONFLICT(key) DO UPDATE SET value=excluded.value").run(key, value);
|
|
485
487
|
}
|
|
488
|
+
/** Settings whose key starts with `prefix`, as [key, value] pairs. */
|
|
489
|
+
settingsWithPrefix(prefix) {
|
|
490
|
+
return this.db.prepare("SELECT key,value FROM settings WHERE substr(key,1,length(?))=?").all(prefix, prefix).map((row) => [String(row.key), String(row.value)]);
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Runs `fn` in one write transaction (BEGIN IMMEDIATE), rolled back if it throws. Inside an
|
|
494
|
+
* open transaction it simply joins it: the outermost caller commits or rolls back.
|
|
495
|
+
*/
|
|
496
|
+
transaction(fn) {
|
|
497
|
+
if (this.db.isTransaction) return fn();
|
|
498
|
+
this.db.exec("BEGIN IMMEDIATE");
|
|
499
|
+
try {
|
|
500
|
+
const result = fn();
|
|
501
|
+
this.db.exec("COMMIT");
|
|
502
|
+
return result;
|
|
503
|
+
} catch (error) {
|
|
504
|
+
this.db.exec("ROLLBACK");
|
|
505
|
+
throw error;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
486
508
|
/** Compare-and-set, for single-use values such as the last accepted TOTP step. */
|
|
487
509
|
advanceSetting(key, value) {
|
|
488
510
|
if (value <= Number(this.setting(key) ?? -1)) return false;
|
|
@@ -835,6 +857,8 @@ function tokenFile(path) {
|
|
|
835
857
|
}
|
|
836
858
|
};
|
|
837
859
|
}
|
|
860
|
+
/** Distinct clients whose failures are tracked separately (bounds memory under a flood). */
|
|
861
|
+
const MAX_TRACKED_CLIENTS = 1e4;
|
|
838
862
|
/**
|
|
839
863
|
* Login and sessions. A browser signs in once, with the access token and, when enabled, an authenticator code,
|
|
840
864
|
* and receives an opaque session secret (stored only as a hash). Sessions are listed and
|
|
@@ -856,17 +880,10 @@ var Auth = class {
|
|
|
856
880
|
this.token = typeof token === "string" ? () => token : token;
|
|
857
881
|
const saved = store.setting("totp_login_limit");
|
|
858
882
|
if (saved) this.global = JSON.parse(saved);
|
|
859
|
-
if (store.setting("auth_policy") !== "token-plus-totp-v1") {
|
|
860
|
-
store.
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
store.setSetting("auth_policy", "token-plus-totp-v1");
|
|
864
|
-
store.db.exec("COMMIT");
|
|
865
|
-
} catch (error) {
|
|
866
|
-
store.db.exec("ROLLBACK");
|
|
867
|
-
throw error;
|
|
868
|
-
}
|
|
869
|
-
}
|
|
883
|
+
if (store.setting("auth_policy") !== "token-plus-totp-v1") store.transaction(() => {
|
|
884
|
+
if (this.totpEnabled()) store.revokeSessions();
|
|
885
|
+
store.setSetting("auth_policy", "token-plus-totp-v1");
|
|
886
|
+
});
|
|
870
887
|
}
|
|
871
888
|
totpEnabled() {
|
|
872
889
|
return this.store.setting("totp_secret") !== null;
|
|
@@ -994,18 +1011,13 @@ var Auth = class {
|
|
|
994
1011
|
if (!pending || pending.sessionId !== sessionId || pending.expires < now) return false;
|
|
995
1012
|
const step = matchTotp(base32Decode(pending.secret), code, now);
|
|
996
1013
|
if (step === null) return false;
|
|
997
|
-
this.store.
|
|
998
|
-
try {
|
|
1014
|
+
this.store.transaction(() => {
|
|
999
1015
|
this.store.setSetting("totp_secret", pending.secret);
|
|
1000
1016
|
this.store.setSetting("totp_last_step", String(step));
|
|
1001
1017
|
this.store.db.prepare("DELETE FROM push_subscriptions WHERE session_id<>?").run(sessionId);
|
|
1002
1018
|
this.store.db.prepare("DELETE FROM sessions WHERE id<>?").run(sessionId);
|
|
1003
1019
|
this.resetCodeLimit();
|
|
1004
|
-
|
|
1005
|
-
} catch (error) {
|
|
1006
|
-
this.store.db.exec("ROLLBACK");
|
|
1007
|
-
throw error;
|
|
1008
|
-
}
|
|
1020
|
+
});
|
|
1009
1021
|
this.pendingTotp = null;
|
|
1010
1022
|
return true;
|
|
1011
1023
|
}
|
|
@@ -1029,11 +1041,20 @@ var Auth = class {
|
|
|
1029
1041
|
};
|
|
1030
1042
|
this.store.setSetting("totp_login_limit", JSON.stringify(this.global));
|
|
1031
1043
|
}
|
|
1044
|
+
/**
|
|
1045
|
+
* The key a client's failures are counted under. Past MAX_TRACKED_CLIENTS distinct clients the
|
|
1046
|
+
* rest share one "overflow" entry, but only after expired entries are dropped: otherwise a
|
|
1047
|
+
* burst of clients long gone would push every new client into the shared lockout for good.
|
|
1048
|
+
*/
|
|
1049
|
+
slot(map, client, now) {
|
|
1050
|
+
if (map.has(client) || map.size < MAX_TRACKED_CLIENTS) return client;
|
|
1051
|
+
for (const [key, entry] of map) if (entry.reset <= now) map.delete(key);
|
|
1052
|
+
return map.size < MAX_TRACKED_CLIENTS ? client : "overflow";
|
|
1053
|
+
}
|
|
1032
1054
|
limited(client, usesCode, now) {
|
|
1033
1055
|
if (usesCode && this.global.reset > now && this.global.count >= MAX_CODE_FAILURES_GLOBAL) return Math.ceil((this.global.reset - now) / 1e3);
|
|
1034
1056
|
const map = usesCode ? this.codeFailures : this.tokenFailures;
|
|
1035
|
-
|
|
1036
|
-
const entry = map.get(client);
|
|
1057
|
+
const entry = map.get(this.slot(map, client, now));
|
|
1037
1058
|
const max = usesCode ? MAX_CODE_FAILURES_PER_CLIENT : MAX_TOKEN_FAILURES_PER_CLIENT;
|
|
1038
1059
|
if (entry && entry.reset > now && entry.count >= max) return Math.ceil((entry.reset - now) / 1e3);
|
|
1039
1060
|
return 0;
|
|
@@ -1049,7 +1070,7 @@ var Auth = class {
|
|
|
1049
1070
|
this.store.setSetting("totp_login_limit", JSON.stringify(this.global));
|
|
1050
1071
|
}
|
|
1051
1072
|
const map = usesCode ? this.codeFailures : this.tokenFailures;
|
|
1052
|
-
|
|
1073
|
+
client = this.slot(map, client, now);
|
|
1053
1074
|
let entry = map.get(client);
|
|
1054
1075
|
if (!entry || entry.reset <= now) map.set(client, entry = {
|
|
1055
1076
|
count: 0,
|
|
@@ -1106,18 +1127,25 @@ function setConfig(store, key, value) {
|
|
|
1106
1127
|
}
|
|
1107
1128
|
store.setSetting(settingName(key), value);
|
|
1108
1129
|
}
|
|
1109
|
-
/**
|
|
1130
|
+
/**
|
|
1131
|
+
* The value in effect for each key: environment, then saved configuration, then the default.
|
|
1132
|
+
* Throws when an environment override is invalid.
|
|
1133
|
+
*/
|
|
1110
1134
|
function effectiveConfig(store, env) {
|
|
1111
1135
|
const entries = configKeys.map((key) => {
|
|
1112
1136
|
const { env: name, fallback } = CONFIG_KEYS[key];
|
|
1113
1137
|
const saved = store.setting(settingName(key));
|
|
1114
1138
|
const fromEnv = env[name];
|
|
1115
|
-
if (fromEnv !== void 0 && fromEnv !== "")
|
|
1116
|
-
key
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1139
|
+
if (fromEnv !== void 0 && fromEnv !== "") {
|
|
1140
|
+
const problem = CONFIG_KEYS[key].check(fromEnv);
|
|
1141
|
+
if (problem) throw new Error(`${name}=${JSON.stringify(fromEnv)} is not valid. ${problem}`);
|
|
1142
|
+
return {
|
|
1143
|
+
key,
|
|
1144
|
+
value: fromEnv,
|
|
1145
|
+
source: "environment",
|
|
1146
|
+
saved
|
|
1147
|
+
};
|
|
1148
|
+
}
|
|
1121
1149
|
if (saved !== null) return {
|
|
1122
1150
|
key,
|
|
1123
1151
|
value: saved,
|
|
@@ -1564,25 +1592,40 @@ async function showStatus(paths, args) {
|
|
|
1564
1592
|
else console.log(`${out.dim("○")} LitePaseo is not running\n ${out.dim("Start it with: litepaseo start")}`);
|
|
1565
1593
|
if (!state) process.exitCode = NOT_RUNNING;
|
|
1566
1594
|
}
|
|
1595
|
+
/** A log file's text, or nothing when it does not exist (yet, or any more after a rotation). */
|
|
1596
|
+
function readIfPresent(path) {
|
|
1597
|
+
try {
|
|
1598
|
+
return readFileSync(path, "utf8");
|
|
1599
|
+
} catch (error) {
|
|
1600
|
+
if (error.code === "ENOENT") return "";
|
|
1601
|
+
throw error;
|
|
1602
|
+
}
|
|
1603
|
+
}
|
|
1567
1604
|
async function logs(paths, args) {
|
|
1568
1605
|
const count = args.flags.lines === void 0 ? 100 : Number(args.flags.lines);
|
|
1569
1606
|
if (!Number.isInteger(count) || count < 0) throw new UsageError("--lines needs a whole number.");
|
|
1570
|
-
let text =
|
|
1571
|
-
if (text.split("\n").length <= count
|
|
1607
|
+
let text = readIfPresent(paths.log);
|
|
1608
|
+
if (text.split("\n").length <= count) text = readIfPresent(paths.log + ".1") + text;
|
|
1572
1609
|
const tail = lastLines(text, count);
|
|
1573
1610
|
if (tail) process.stdout.write(tail.endsWith("\n") ? tail : tail + "\n");
|
|
1574
1611
|
else if (!args.flags.follow) console.log(out.dim(`No logs yet in ${paths.log}`));
|
|
1575
1612
|
if (!args.flags.follow) return;
|
|
1576
|
-
|
|
1577
|
-
let
|
|
1613
|
+
const start = statSync(paths.log, { throwIfNoEntry: false });
|
|
1614
|
+
let position = start?.size ?? 0;
|
|
1615
|
+
let inode = start?.ino ?? 0;
|
|
1578
1616
|
for (;;) {
|
|
1579
1617
|
await sleep(500);
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1618
|
+
let fd;
|
|
1619
|
+
try {
|
|
1620
|
+
fd = openSync(paths.log, "r");
|
|
1621
|
+
} catch (error) {
|
|
1622
|
+
if (error.code === "ENOENT") continue;
|
|
1623
|
+
throw error;
|
|
1624
|
+
}
|
|
1585
1625
|
try {
|
|
1626
|
+
const info = fstatSync(fd);
|
|
1627
|
+
if (info.ino !== inode || info.size < position) [position, inode] = [0, info.ino];
|
|
1628
|
+
if (info.size === position) continue;
|
|
1586
1629
|
const chunk = Buffer.alloc(info.size - position);
|
|
1587
1630
|
const read = readSync(fd, chunk, 0, chunk.length, position);
|
|
1588
1631
|
process.stdout.write(chunk.subarray(0, read));
|
|
@@ -1721,7 +1764,7 @@ async function run() {
|
|
|
1721
1764
|
if (name === "--help" || name === "-h") return console.log(mainHelp(VERSION, displayDirectory(), out));
|
|
1722
1765
|
if (name === "worker") {
|
|
1723
1766
|
const paths = await dataDirectory();
|
|
1724
|
-
const { runWorker } = await import("./worker-
|
|
1767
|
+
const { runWorker } = await import("./worker-BaZ4l9qs.mjs");
|
|
1725
1768
|
return runWorker(paths.directory, fileURLToPath(new URL("../web/", import.meta.url)));
|
|
1726
1769
|
}
|
|
1727
1770
|
const command = findCommand(name);
|