shapewall 0.6.0 → 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 +252 -0
- package/README.md +39 -2
- package/THIRD_PARTY.md +15 -0
- package/dist/agent/package-lock.json +594 -2
- package/dist/client/assets/{BoardChat-DdwBcb2N.js → BoardChat-WS8mAIW6.js} +1 -1
- package/dist/client/assets/{BuzzDialog-DpUcnU6S.js → BuzzDialog-B-Mlr6wF.js} +1 -1
- package/dist/client/assets/{ChecksPanel-CngYV4yz.js → ChecksPanel-Dx1ZLBR6.js} +1 -1
- package/dist/client/assets/{History-CD0saQA5.js → History-sXhmpcvs.js} +1 -1
- package/dist/client/assets/{LocalSettings-MZy2baig.js → LocalSettings-CtGzz9F3.js} +1 -1
- package/dist/client/assets/{Management-CSvZ-SHO.js → Management-CGHe8Wt9.js} +1 -1
- package/dist/client/assets/{QuickConnect-foLh2QUm.js → QuickConnect-DEk84E4A.js} +1 -1
- package/dist/client/assets/{ShareDialog-DPWDftoL.js → ShareDialog-CGGx-AYK.js} +1 -1
- package/dist/client/assets/{app-update-dialog-CtiXpTRD.js → app-update-dialog-_bVp8hnC.js} +1 -1
- package/dist/client/assets/{circle-x-CteRBtXC.js → circle-x-BWoHA1QY.js} +1 -1
- package/dist/client/assets/index-Bm-Xd3YN.js +37 -0
- package/dist/client/assets/index-C7Ostk3K.css +2 -0
- package/dist/client/assets/{play-BjRNIGSf.js → play-BzQ3tRTv.js} +1 -1
- package/dist/client/assets/{refresh-cw-r_tZiFfB.js → refresh-cw-BYBMyDKT.js} +1 -1
- package/dist/client/assets/{ui-zQpn-PdL.js → ui-CAY6myRA.js} +1 -1
- package/dist/client/build-info.json +1 -1
- package/dist/client/index.html +3 -3
- package/dist/client/sw.js +2 -2
- package/dist/console/assets/LocalAccountsApp-CWRguRRL.js +1 -0
- package/dist/console/assets/LocalConsole--I2SaIpr.js +2 -0
- package/dist/console/assets/LocalUsage-BmpCZ36k.js +1 -0
- package/dist/console/assets/app-update-dialog-B8M9plaT.js +1 -0
- package/dist/console/assets/app-version-muKrQqbL.js +1 -0
- package/dist/console/assets/console-CrhTsPbz.css +2 -0
- package/dist/console/assets/console-DxapQ9oS.js +11 -0
- package/dist/console/assets/local-agents-CoqD4dSN.js +6 -0
- package/dist/console/assets/minus-DDQ0ydcM.js +1 -0
- package/dist/console/assets/tailnet-C5Flwl_d.js +2 -0
- package/dist/console/assets/theme-DCd0qh4l.js +1 -0
- package/dist/console/assets/ui-Bry1mnCY.js +41 -0
- package/dist/console/assets/usage-CIPWnHaS.css +1 -0
- package/dist/console/assets/usage-CqVjMb7m.js +5 -0
- package/dist/console/assets/usage-D1G0GgE3.js +56 -0
- package/dist/console/build-info.json +1 -1
- package/dist/console/console.html +8 -2
- package/docs/agent-hardening.md +31 -17
- package/docs/agents.md +35 -0
- package/docs/architecture.md +10 -4
- package/docs/deployment.md +39 -17
- package/docs/design-system.md +56 -7
- package/docs/hosted.md +1004 -43
- package/docs/images/board-overview.png +0 -0
- package/docs/images/journeys.png +0 -0
- package/docs/images/live-comment.png +0 -0
- package/docs/images/phone-comment.png +0 -0
- package/docs/images/phone-overview.png +0 -0
- package/docs/images/variant.png +0 -0
- package/docs/where-to-run.md +82 -1
- package/package.json +6 -1
- package/src/agent/backends/acp.js +224 -26
- package/src/agent/routes.js +21 -0
- package/src/agent/usage-log.js +251 -0
- package/src/cli/args.js +24 -0
- package/src/cli/help.js +37 -2
- package/src/cli/init.js +2 -1
- package/src/cli/serve.js +20 -5
- package/src/cli.js +8 -0
- package/src/hosted/access-cli.js +99 -1
- package/src/hosted/activity-core.js +232 -0
- package/src/hosted/activity.js +375 -0
- package/src/hosted/admin.js +80 -13
- package/src/hosted/agent-approvals.js +2 -2
- package/src/hosted/agent-routes.js +3 -3
- package/src/hosted/agents.js +11 -4
- package/src/hosted/app.js +89 -7
- package/src/hosted/auth-routes.js +156 -15
- package/src/hosted/auth.js +123 -20
- package/src/hosted/board-routes.js +3 -3
- package/src/hosted/chat-frames.js +5 -15
- package/src/hosted/chat-permissions.js +12 -0
- package/src/hosted/chat-routes.js +8 -8
- package/src/hosted/chat-store.js +20 -3
- package/src/hosted/comment-files.js +5 -2
- package/src/hosted/console-routes.js +111 -34
- package/src/hosted/db.js +130 -0
- package/src/hosted/device-routes.js +25 -3
- package/src/hosted/device.js +23 -4
- package/src/hosted/guards.js +337 -27
- package/src/hosted/http.js +6 -3
- package/src/hosted/membership.js +13 -2
- package/src/hosted/operator-access.js +418 -0
- package/src/hosted/operator.js +106 -2
- package/src/hosted/ops-cli.js +238 -3
- package/src/hosted/pages.js +2 -0
- package/src/hosted/passkey-policy.js +75 -0
- package/src/hosted/permissions.js +14 -6
- package/src/hosted/presence.js +14 -2
- package/src/hosted/projects.js +2 -1
- package/src/hosted/public.js +4 -4
- package/src/hosted/ratelimit.js +6 -0
- package/src/hosted/retention.js +18 -2
- package/src/hosted/server.js +123 -11
- package/src/hosted/shares.js +2 -2
- package/src/hosted/step-up-settings.js +68 -0
- package/src/hosted/step-up.js +135 -0
- package/src/hosted/tailnet-identity.js +24 -0
- package/src/hosted/tailnet-routes.js +342 -0
- package/src/hosted/tailnet.js +220 -0
- package/src/hosted/tailscale.js +75 -9
- package/src/hosted/tenancy.js +48 -1
- package/src/hosted/token-api.js +2 -2
- package/src/hosted/tokens.js +9 -2
- package/src/hosted/usage-core.js +624 -0
- package/src/hosted/usage-layout.js +724 -0
- package/src/hosted/usage-routes.js +375 -0
- package/src/hosted/usage-shape.js +256 -0
- package/src/hosted/usage.js +641 -0
- package/src/remote/agent-connect.js +37 -1
- package/src/remote/agent-link.js +2 -0
- package/src/remote/login.js +33 -8
- package/src/remote/share.js +1 -1
- package/src/remote/tailnet-cli.js +547 -0
- package/src/server/app.js +15 -0
- package/src/server/pairing-routes.js +34 -5
- package/src/server/tailscale.js +97 -4
- package/src/tailnet-proof.js +766 -0
- package/dist/client/assets/index-Cxz1UVcV.css +0 -2
- package/dist/client/assets/index-uUZVBYUS.js +0 -37
- package/dist/console/assets/LocalAccountsApp-DIdy1KnN.js +0 -1
- package/dist/console/assets/LocalConsole-DfcQztF-.js +0 -1
- package/dist/console/assets/app-update-dialog-ttl9lF5A.js +0 -1
- package/dist/console/assets/console-OqAjD0kV.js +0 -55
- package/dist/console/assets/console-kvjrAArQ.css +0 -2
package/src/server/tailscale.js
CHANGED
|
@@ -3,6 +3,18 @@ import os from 'node:os'
|
|
|
3
3
|
import { execFile } from 'node:child_process'
|
|
4
4
|
import { promisify } from 'node:util'
|
|
5
5
|
import { absoluteProgram } from '../which.js'
|
|
6
|
+
import {
|
|
7
|
+
createTailnetGate,
|
|
8
|
+
machineFacts,
|
|
9
|
+
newServeSecret,
|
|
10
|
+
procPeerProof,
|
|
11
|
+
proofSelfTest,
|
|
12
|
+
selfFromStatus,
|
|
13
|
+
serveProblem,
|
|
14
|
+
serveTarget,
|
|
15
|
+
tailscaledProblem,
|
|
16
|
+
whoisAnswer,
|
|
17
|
+
} from '../tailnet-proof.js'
|
|
6
18
|
const execute = promisify(execFile)
|
|
7
19
|
|
|
8
20
|
export function lanAccess(value, { interfaces = os.networkInterfaces(), hostname = os.hostname() } = {}) {
|
|
@@ -38,6 +50,10 @@ export async function tailscaleAccess({
|
|
|
38
50
|
env = process.env,
|
|
39
51
|
run = execute,
|
|
40
52
|
command = absoluteProgram('tailscale', env),
|
|
53
|
+
// The identity proof's parts (tests): the peer check and what the machine says about tailscaled.
|
|
54
|
+
proof = procPeerProof(),
|
|
55
|
+
facts = machineFacts,
|
|
56
|
+
log = () => {},
|
|
41
57
|
} = {}) {
|
|
42
58
|
if (!command) throw new Error('Tailscale is not installed. Install it, sign in, then run serve --tailscale again.')
|
|
43
59
|
const call = async (args) => {
|
|
@@ -61,24 +77,101 @@ export async function tailscaleAccess({
|
|
|
61
77
|
if (configs(config).some((entry) => entry.TCP?.[port] || Object.keys(entry.Web || {}).some((key) => key.endsWith(`:${port}`))))
|
|
62
78
|
throw new Error(`Tailscale port ${port} is already configured. Choose another --port; Shapewall will not replace it.`)
|
|
63
79
|
let ownerLogin = null
|
|
80
|
+
let ownerUserId = null
|
|
64
81
|
if (!noIdentity) {
|
|
65
82
|
const who = JSON.parse(await call(['whois', '--json', status.TailscaleIPs[0]]))
|
|
66
83
|
// Tagged/shared nodes without a user never grant identity access.
|
|
67
84
|
ownerLogin = who.Node?.Tags?.length ? null : who.UserProfile?.LoginName || null
|
|
85
|
+
// Tailscale's own id of the owner: a device is the owner's by that, not by a login that reads the same.
|
|
86
|
+
ownerUserId = ownerLogin ? whoisAnswer(JSON.stringify(who))?.userId || null : null
|
|
68
87
|
}
|
|
69
|
-
|
|
88
|
+
// The owner's other devices are let in by their tailnet identity only when
|
|
89
|
+
// a request can be proven to come through the serve entry made here: the
|
|
90
|
+
// same proof as the hosted server's tailnet sign-in (src/tailnet-proof.js:
|
|
91
|
+
// a secret path in the entry, the owner of the connection's other end,
|
|
92
|
+
// tailscaled's own whois, and a tailscaled that can be believed). Where it
|
|
93
|
+
// cannot be proven the board still serves: every other device pairs.
|
|
94
|
+
let identityOff = null
|
|
95
|
+
// This node: a request that comes from this machine itself is never the owner by identity
|
|
96
|
+
// (any local program can ask tailscaled for the serve URL; src/tailnet-proof.js).
|
|
97
|
+
let here = selfFromStatus(status)
|
|
98
|
+
if (ownerLogin)
|
|
99
|
+
identityOff =
|
|
100
|
+
proof.problem?.() ||
|
|
101
|
+
tailscaledProblem(status, await facts()) ||
|
|
102
|
+
(here ? null : 'tailscale status does not say which node this machine is')
|
|
103
|
+
const secret = ownerLogin && !identityOff ? newServeSecret() : null
|
|
104
|
+
const target = secret ? serveTarget(port, secret) : `http://127.0.0.1:${port}`
|
|
105
|
+
const whois = async (address) => {
|
|
106
|
+
try {
|
|
107
|
+
return whoisAnswer(
|
|
108
|
+
(await run(command, ['whois', '--json', address], { cwd: os.tmpdir(), env, timeout: 10000, maxBuffer: 1024 * 1024, shell: false }))
|
|
109
|
+
.stdout,
|
|
110
|
+
)
|
|
111
|
+
} catch {
|
|
112
|
+
return null
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const gate = secret ? createTailnetGate({ secret, proof, whois, self: () => here, log }) : null
|
|
116
|
+
const verify = async () => {
|
|
117
|
+
try {
|
|
118
|
+
const now = JSON.parse(await call(['status', '--json']))
|
|
119
|
+
const config = JSON.parse((await call(['serve', 'status', '--json'])) || '{}')
|
|
120
|
+
here = selfFromStatus(now)
|
|
121
|
+
return (
|
|
122
|
+
tailscaledProblem(now, await facts()) ||
|
|
123
|
+
(here ? null : 'tailscale status does not say which node this machine is') ||
|
|
124
|
+
serveProblem(config, { dnsName: host, httpsPort: port, localPort: port, target })
|
|
125
|
+
)
|
|
126
|
+
} catch {
|
|
127
|
+
here = null
|
|
128
|
+
return 'tailscale status could not be read'
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const args = ['serve', '--bg', `--https=${port}`, target]
|
|
70
132
|
let started = false
|
|
133
|
+
let timer = null
|
|
71
134
|
return {
|
|
72
135
|
host,
|
|
73
136
|
ownerLogin,
|
|
137
|
+
ownerUserId,
|
|
74
138
|
noIdentity,
|
|
139
|
+
// null: no identity proof (pairing only); else admit(req, res) and identityOf(req).
|
|
140
|
+
gate,
|
|
141
|
+
identityOff,
|
|
75
142
|
url: `https://${host}${port === 443 ? '' : `:${port}`}/`,
|
|
76
|
-
|
|
77
|
-
|
|
143
|
+
// What `--tailscale=print` shows: never the secret.
|
|
144
|
+
command: `tailscale serve --bg --https=${port} http://127.0.0.1:${port}${secret ? '/_ts/<a secret made at each start>' : ''}`,
|
|
145
|
+
// `server`: the listening board server, for the proof's self test.
|
|
146
|
+
async start(server = null, { watchMs = 30_000 } = {}) {
|
|
147
|
+
// A self test that failed stays failed: the peer check does not work on this machine, and nothing
|
|
148
|
+
// the watch below can see changes that. Identity stays off until the board is started again.
|
|
149
|
+
let failedSelfTest = null
|
|
150
|
+
if (gate && server) {
|
|
151
|
+
failedSelfTest = await proofSelfTest(server, proof)
|
|
152
|
+
if (failedSelfTest) {
|
|
153
|
+
gate.suspend(failedSelfTest)
|
|
154
|
+
log('Tailscale identity is off (pairing still works): ' + failedSelfTest + '.')
|
|
155
|
+
}
|
|
156
|
+
}
|
|
78
157
|
await call(args)
|
|
79
158
|
started = true
|
|
159
|
+
if (!gate) return
|
|
160
|
+
// The entry must stay the only way to the port, and tailscaled one that
|
|
161
|
+
// can be believed: checked now and every half minute; nobody is let in
|
|
162
|
+
// by identity while it is not so.
|
|
163
|
+
const watch = async () => {
|
|
164
|
+
const problem = failedSelfTest || (await verify())
|
|
165
|
+
if (problem && !gate.suspended()) log(`Tailscale identity is suspended (pairing still works): ${problem}.`)
|
|
166
|
+
if (problem) gate.suspend(problem)
|
|
167
|
+
else if (gate.suspended()) gate.resume()
|
|
168
|
+
}
|
|
169
|
+
if (!gate.suspended()) await watch()
|
|
170
|
+
timer = watchMs ? setInterval(() => watch().catch(() => {}), watchMs) : null
|
|
171
|
+
timer?.unref()
|
|
80
172
|
},
|
|
81
173
|
async stop() {
|
|
174
|
+
if (timer) clearInterval(timer)
|
|
82
175
|
if (!started) return
|
|
83
176
|
started = false
|
|
84
177
|
// Remove only our port, and only while it still points at our target.
|
|
@@ -89,7 +182,7 @@ export async function tailscaleAccess({
|
|
|
89
182
|
!Object.keys(current.Foreground || {}).length &&
|
|
90
183
|
handlers &&
|
|
91
184
|
Object.keys(handlers).length === 1 &&
|
|
92
|
-
handlers['/']?.Proxy ===
|
|
185
|
+
handlers['/']?.Proxy === target
|
|
93
186
|
)
|
|
94
187
|
await call(['serve', `--https=${port}`, 'off'])
|
|
95
188
|
},
|