townmouse 0.2.1 → 0.4.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 +72 -2
- package/DESIGN.md +26 -42
- package/README.md +286 -54
- package/SECURITY.md +3 -0
- package/TOWNMOUSE.md +1 -1
- package/bin/townmouse +2 -2
- package/docs/PACKAGING.md +104 -8
- package/docs/browser-workspace.md +62 -9
- package/docs/panes.md +199 -9
- package/native/TownmouseApp.swift +5 -5
- package/npm-shrinkwrap.json +1282 -0
- package/package.json +11 -7
- package/public/browser-picture.mjs +159 -0
- package/public/features/app-version.mjs +35 -0
- package/public/features/autosave.mjs +5 -1
- package/public/features/multi-window-sync.mjs +3 -1
- package/public/features/osc-bridge.mjs +8 -3
- package/public/features/session-manager.mjs +202 -100
- package/public/features/status-metrics.mjs +23 -0
- package/public/features/tab-reorder.mjs +8 -0
- package/public/features/window-title.mjs +10 -3
- package/public/index.html +617 -78
- package/public/input-guard.mjs +10 -2
- package/public/panes.css +189 -13
- package/public/panes.html +4 -1
- package/public/panes.mjs +667 -109
- package/public/workspace.css +198 -24
- package/public/workspace.mjs +346 -106
- package/scripts/install-service.sh +97 -63
- package/scripts/panes +134 -5
- package/scripts/retire-legacy-service.sh +76 -0
- package/scripts/{t1.sh → townmouse.sh} +60 -21
- package/scripts/uninstall-service.sh +31 -15
- package/src/agent-guide.js +72 -3
- package/src/attachments.js +2 -2
- package/src/browser-dom.js +5 -2
- package/src/browser-workspace.js +549 -62
- package/src/owner-page.js +43 -0
- package/src/request-boundary.js +1 -1
- package/src/server.js +588 -128
- package/src/workspace-panes.js +423 -91
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// The owner's page proves itself before either bootstrap route hands over an
|
|
4
|
+
// owner key. The proof is two things a browser does and an ordinary program
|
|
5
|
+
// does not: the page was reached by a navigation (which is what mints the
|
|
6
|
+
// owner cookie, in server.js), and the request is the page's own (a browser
|
|
7
|
+
// marks it Sec-Fetch-Site: same-origin). A program that sets those details on
|
|
8
|
+
// purpose is not told apart from the page: nothing that only looks at an HTTP
|
|
9
|
+
// request can do that. So this closes the ordinary path, says plainly why a
|
|
10
|
+
// request was refused, and makes no further claim.
|
|
11
|
+
|
|
12
|
+
const AGENT_HINT = 'An agent uses the workspace token it already holds: `panes state` lists every pane and what you have on it, and `panes pane request <pane-id> --level control --message "why"` asks the owner for one of theirs.';
|
|
13
|
+
const TOO_OLD = 'Chrome 76, Safari 16.4 or Firefox 90, each or later';
|
|
14
|
+
|
|
15
|
+
function refusal(status, code, error) {
|
|
16
|
+
return { status, body: { error, code } };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The refusal for a request that may not be given an owner key, or null when
|
|
21
|
+
* the request is the owner's page's own. Each message starts with the words
|
|
22
|
+
* the terminal surface's page already recognises as an owner-session failure.
|
|
23
|
+
*/
|
|
24
|
+
function ownerPageRefusal(req) {
|
|
25
|
+
if (req.get('Authorization')) {
|
|
26
|
+
return refusal(403, 'AGENT_TOKEN', `Owner page required. An agent token is never given the owner's key. ${AGENT_HINT}`);
|
|
27
|
+
}
|
|
28
|
+
const site = req.get('Sec-Fetch-Site');
|
|
29
|
+
if (!req.isOwner) {
|
|
30
|
+
// A browser marks every request with Sec-Fetch-Site. A request without it
|
|
31
|
+
// is either a program or a browser too old to identify its own requests.
|
|
32
|
+
const fromABrowser = site !== undefined;
|
|
33
|
+
return refusal(403, 'OWNER_PAGE_REQUIRED', fromABrowser
|
|
34
|
+
? `Owner page required. The owner's key is handed only to the owner's page, and this request did not come from one opened in a browser during this server run. A person seeing this in a browser should reload the page. ${AGENT_HINT}`
|
|
35
|
+
: `Owner page required. The owner's key is handed only to the owner's page, opened in a browser, and this request did not come from one. ${AGENT_HINT} A person seeing this in a browser has one too old to identify its own requests: ${TOO_OLD}.`);
|
|
36
|
+
}
|
|
37
|
+
if (site !== 'same-origin') {
|
|
38
|
+
return refusal(403, 'NOT_FROM_OWNER_PAGE', `Owner page required. The owner's key is handed only to a request made by the owner's own page (Sec-Fetch-Site: same-origin), and this one was not, so it was refused. A person seeing this in a browser should reload the page, and if it persists update the browser. ${AGENT_HINT}`);
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
module.exports = { ownerPageRefusal };
|
package/src/request-boundary.js
CHANGED
|
@@ -4,7 +4,7 @@ const LOOPBACK_HOSTS = new Set(['localhost', '127.0.0.1', '[::1]']);
|
|
|
4
4
|
|
|
5
5
|
// A container is published on a host port that need not equal the port inside
|
|
6
6
|
// it, so an exact `host:port` match would refuse every request (including
|
|
7
|
-
// /health) for `-p 127.0.0.1:8080:
|
|
7
|
+
// /health) for `-p 127.0.0.1:8080:11002`. The loopback *hostname* is what makes
|
|
8
8
|
// a request local; the port is the publisher's choice. When an Origin is
|
|
9
9
|
// present it must still match the Host exactly and pass the origin checks
|
|
10
10
|
// below, so a page on another local port cannot drive this server.
|