decklight 0.8.1 → 0.9.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.
Files changed (133) hide show
  1. package/PLATFORM.md +666 -0
  2. package/README.md +224 -150
  3. package/SPEC.md +732 -886
  4. package/cli/agent-review.mjs +245 -0
  5. package/cli/agents.mjs +25 -5
  6. package/cli/associate.mjs +12 -12
  7. package/cli/audit.mjs +42 -10
  8. package/cli/banner.mjs +41 -17
  9. package/cli/bundle-audio.mjs +183 -0
  10. package/cli/bundle.mjs +383 -31
  11. package/cli/cast.mjs +7 -7
  12. package/cli/check.mjs +961 -0
  13. package/cli/clone-deck.mjs +179 -0
  14. package/cli/commands.mjs +345 -0
  15. package/cli/comments.mjs +64 -18
  16. package/cli/commit-flow.mjs +44 -19
  17. package/cli/commit-message.mjs +51 -74
  18. package/cli/commit-split.mjs +601 -0
  19. package/cli/deck-refs.mjs +59 -0
  20. package/cli/deck-routes.mjs +67 -0
  21. package/cli/deckfile.mjs +3 -5
  22. package/cli/decklight.mjs +68 -289
  23. package/cli/design-system-deps.mjs +209 -0
  24. package/cli/design-system-edit.mjs +194 -0
  25. package/cli/design-system-refs.mjs +409 -0
  26. package/cli/design-system.mjs +429 -0
  27. package/cli/doctor.mjs +115 -0
  28. package/cli/edit-git.mjs +353 -0
  29. package/cli/edit-handover.mjs +445 -0
  30. package/cli/edit-look.mjs +388 -0
  31. package/cli/edit-slides.mjs +683 -0
  32. package/cli/edit.mjs +2126 -842
  33. package/cli/enhance.mjs +483 -0
  34. package/cli/extension.mjs +10 -10
  35. package/cli/font-refs.mjs +273 -0
  36. package/cli/font.mjs +246 -0
  37. package/cli/git-tree.mjs +1 -1
  38. package/cli/git.mjs +65 -11
  39. package/cli/import.mjs +56 -10
  40. package/cli/init.mjs +400 -234
  41. package/cli/library.mjs +127 -0
  42. package/cli/loader.mjs +3 -1
  43. package/cli/marketplace.mjs +215 -21
  44. package/cli/narrate.mjs +176 -0
  45. package/cli/open-browser.mjs +63 -0
  46. package/cli/open.mjs +943 -0
  47. package/cli/pdf.mjs +41 -13
  48. package/cli/pkg.mjs +44 -2
  49. package/cli/plugin.mjs +43 -41
  50. package/cli/port-conflict.mjs +53 -23
  51. package/cli/pptx-export.mjs +57 -24
  52. package/cli/publish.mjs +8 -4
  53. package/cli/qr.mjs +1 -1
  54. package/cli/record.mjs +14 -12
  55. package/cli/remote.mjs +11 -11
  56. package/cli/restore.mjs +11 -4
  57. package/cli/review-ref.mjs +125 -0
  58. package/cli/review-remote.mjs +92 -48
  59. package/cli/review-routes.mjs +254 -0
  60. package/cli/review-store.mjs +47 -7
  61. package/cli/review-submit.mjs +47 -57
  62. package/cli/runtime-link.mjs +560 -0
  63. package/cli/serve.mjs +235 -44
  64. package/cli/setup.mjs +112 -0
  65. package/cli/sign.mjs +1 -1
  66. package/cli/skill-content.mjs +190 -33
  67. package/cli/skills.mjs +107 -24
  68. package/cli/start.mjs +110 -0
  69. package/cli/supervise.mjs +6 -6
  70. package/cli/theme-refs.mjs +515 -0
  71. package/cli/theme.mjs +181 -137
  72. package/cli/trust.mjs +83 -0
  73. package/cli/units.mjs +39 -42
  74. package/cli/update-check.mjs +1 -5
  75. package/cli/upgrade.mjs +194 -28
  76. package/cli/upstream.mjs +4 -3
  77. package/cli/util.mjs +4 -4
  78. package/cli/wizard.mjs +6 -6
  79. package/dist/build-info.json +1 -1
  80. package/dist/decklight.css +1126 -49
  81. package/dist/decklight.js +212 -115
  82. package/dist/decklight.js.map +4 -4
  83. package/docs/GLOSSARY.md +141 -0
  84. package/docs/architecture.svg +17 -17
  85. package/package.json +4 -2
  86. package/themes/README.md +9 -8
  87. package/themes/reveal-solarized.css +10 -0
  88. package/tools/args.mjs +20 -0
  89. package/tools/atomic-write.mjs +48 -0
  90. package/tools/brand-palette.mjs +717 -0
  91. package/tools/bridge.mjs +1 -1
  92. package/tools/build-groups.mjs +42 -0
  93. package/tools/color.mjs +48 -0
  94. package/tools/deck-html.mjs +396 -11
  95. package/tools/design-system-format.mjs +753 -0
  96. package/tools/elevenlabs-tts.mjs +110 -17
  97. package/tools/exec.mjs +1 -1
  98. package/tools/extension-check.mjs +31 -7
  99. package/tools/font-format.mjs +190 -0
  100. package/tools/font-stacks.mjs +24 -0
  101. package/tools/gemini-tts.mjs +3 -0
  102. package/tools/lipsync-config.mjs +103 -0
  103. package/tools/lipsync-engines.mjs +205 -2
  104. package/tools/lipsync-server.mjs +264 -41
  105. package/tools/lipsync.mjs +37 -18
  106. package/tools/local-voice.mjs +32 -42
  107. package/tools/narration-manifest.mjs +196 -0
  108. package/tools/narration-synth.mjs +416 -0
  109. package/tools/pptx.mjs +776 -19
  110. package/tools/publish-targets.mjs +1 -1
  111. package/tools/publish-voices.mjs +3 -3
  112. package/tools/recording-impact.mjs +7 -3
  113. package/tools/render-theme.mjs +33 -0
  114. package/tools/review-anchor.mjs +28 -12
  115. package/tools/semver.mjs +40 -0
  116. package/tools/sentences.mjs +180 -0
  117. package/tools/shot.mjs +14 -7
  118. package/tools/site-voices.mjs +232 -0
  119. package/tools/template-theme.mjs +1 -1
  120. package/tools/test-impact.mjs +17 -10
  121. package/tools/theme-check.mjs +30 -3
  122. package/tools/tts-cache.mjs +4 -3
  123. package/tools/tts-engines.mjs +38 -20
  124. package/tools/tts-setup.mjs +7 -7
  125. package/tools/video-options.mjs +34 -0
  126. package/tools/video.mjs +461 -48
  127. package/tools/voiceover-server.mjs +185 -104
  128. package/tools/voiceover.mjs +119 -261
  129. package/tools/zip.mjs +1 -1
  130. package/cli/dev.mjs +0 -623
  131. package/cli/present.mjs +0 -853
  132. package/cli/review.mjs +0 -361
  133. package/tools/publish-site-voices.mjs +0 -75
package/cli/present.mjs DELETED
@@ -1,853 +0,0 @@
1
- // Copyright 2026 Gilles Philippart
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- /**
5
- * `decklight present <deck>` — play a deck you did not author.
6
- *
7
- * The asymmetry this answers (MARKETPLACE.md WHY): a plugin runs on the
8
- * machine of the person who chose to install it, but a DECK travels — emailed,
9
- * published, presented — so anything inlined into one runs in front of an
10
- * audience that installed nothing and consented to nothing. Opening someone
11
- * else's deck straight off the filesystem gives that content `file://` origin
12
- * and no policy at all.
13
- *
14
- * Serving it over localhost instead buys the one thing a file cannot have: a
15
- * `Content-Security-Policy` **HTTP header**, which the document cannot
16
- * override. A `<meta>` CSP inside the deck is worth nothing here — an attacker
17
- * who can edit the payload edits the meta tag in the same pass.
18
- *
19
- * This module registers exactly one capability: GET a file under the deck's
20
- * directory. There is no `/edit/*` route to refuse, because none is ever
21
- * registered (#168 split `cli/serve.mjs` out of `cli/edit.mjs` for precisely
22
- * this), and nothing here writes to disk.
23
- *
24
- * Three things now ride on that one capability, in the order they run: the
25
- * ingredients label names what the file will execute (PRESENT#AUDIT), strict
26
- * mode removes what it could not account for on the way out (PRESENT#STRICT),
27
- * and the CSP header bounds whatever is left.
28
- */
29
-
30
- import { createServer } from 'node:http';
31
- import { existsSync, readFileSync } from 'node:fs';
32
- import { resolve, sep, basename, dirname } from 'node:path';
33
- import { randomBytes } from 'node:crypto';
34
- import { argReader, isMain } from '../tools/args.mjs';
35
- import { allowRemote, lanAddress, staticFiles, sseChannel, listenTakingOverIfNeeded, withHeaders, isOwnOrigin } from './serve.mjs';
36
- import { createRemoteRelay } from './remote.mjs';
37
- import { corsHeaders, readBody } from '../tools/bridge.mjs';
38
-
39
- // The phone is a different origin from the deck (a LAN address, not localhost),
40
- // so the remote's own endpoints need CORS. Nothing else here does — the deck is
41
- // same-origin with the server that serves it.
42
- const CORS = corsHeaders();
43
- import { auditDeck, formatLabel, stripUnaccounted } from './audit.mjs';
44
- import { loadLibrary, injectChrome } from './plugin.mjs';
45
- import { verifyFile, verifyBytes, formatSignature, isVerified, UNSIGNED, TAMPERED, VERIFIED } from './sign.mjs';
46
- import {
47
- SAFE_CONFIG, canPull, checkUpstream, resolveInterval, resolveUpstream, runGit, upstreamSuppressed,
48
- } from './upstream.mjs';
49
- import { oneline } from './git.mjs';
50
- import { isContainer, readContainer, formatManifest } from './deckfile.mjs';
51
-
52
- /**
53
- * The policy, and honestly what it is worth.
54
- *
55
- * `script-src` has to carry `'unsafe-inline'`: a bundled deck IS inline script
56
- * (the runtime is inlined by `decklight bundle`) and even a source deck calls
57
- * `Decklight.init()` from an inline block. So this header does NOT stop a deck
58
- * from running script — that is what PRESENT#AUDIT names and PRESENT#STRICT
59
- * strips, and claiming otherwise here would manufacture confidence the
60
- * mechanism cannot back.
61
- *
62
- * What it does stop is what a hostile deck would want to DO with that script:
63
- * `default-src 'none'` denies every fetch destination not listed below,
64
- * `object-src` kills plugin embedding, `base-uri` stops relative-URL
65
- * hijacking, and `form-action 'none'` means a credential form pasted into a
66
- * deck has nowhere to post. Exfiltration is narrowed to `https:` rather than
67
- * closed, because that is where SPEC'd narration lives (below).
68
- *
69
- * Each opening is a SPEC'd feature, not a convenience:
70
- * - `media-src https:` — a recorded track's `dir` may be an absolute URL, and
71
- * background video stays external by design (PRESENTING). `blob:` is the
72
- * stitched/`createObjectURL` audio path.
73
- * - `connect-src https:` — manifest tracks fetch `manifest.signed.json` from a
74
- * bucket; a presigned URL's origin is not knowable ahead of time, so it
75
- * cannot be pinned to an allowlist here.
76
- * - `frame-src`/`frame-ancestors 'self'` — the theme picker, the slide finder
77
- * and the speaker view all boot the deck into same-origin iframes. `'none'`
78
- * would break the picker preview; `'self'` still refuses embedding by
79
- * another site.
80
- * - `style-src 'unsafe-inline'` — themes are inline `<style data-theme>`
81
- * blocks and the engine writes inline custom properties (`--pin-y`).
82
- *
83
- * Deliberately absent: the local TTS/lipsync bridges (`127.0.0.1:8787/8789`).
84
- * Live synthesis is an authoring-path engine, and MARKETPLACE.md ENGINES is
85
- * explicit that engines never come up outside author mode — a deck you were
86
- * emailed asking to reach a local service is the shape of a probe. Recorded
87
- * narration needs no bridge and is unaffected.
88
- */
89
- export const CSP = [
90
- "default-src 'none'",
91
- "script-src 'self' 'unsafe-inline'",
92
- "style-src 'self' 'unsafe-inline'",
93
- "img-src 'self' data: blob: https:",
94
- "media-src 'self' data: blob: https:",
95
- "font-src 'self' data:",
96
- "connect-src 'self' https:",
97
- "frame-src 'self'",
98
- "frame-ancestors 'self'",
99
- "base-uri 'none'",
100
- "form-action 'none'",
101
- "object-src 'none'",
102
- ].join('; ');
103
-
104
- /**
105
- * Serve files under `root` over http://127.0.0.1 with this module's CSP on
106
- * EVERY response, for the render tools (`tools/shot.mjs`, `tools/video.mjs`).
107
- *
108
- * It is `present`'s serving core with the audit/strict/remote/edit surface
109
- * stripped off: `withHeaders` for the policy, `staticFiles` for a
110
- * traversal-guarded GET, an ephemeral loopback port. A deck screenshotted or
111
- * filmed BEFORE anyone presents it therefore runs under the same policy
112
- * `present` gives it — instead of over `file://` with
113
- * `--allow-file-access-from-files`, the flag that let a deck's own JS read any
114
- * local file it could name and ship it anywhere (#229). An http origin cannot
115
- * read `file://` at all, and the CSP bounds where the rest can reach; a read is
116
- * confined to what `staticFiles` will serve under `root`.
117
- *
118
- * `html` rewrites the text of every text/html response on its way out (shot
119
- * injects its driver and `--theme` link there, in memory — no temp file). The
120
- * server must be driven with an ASYNC Chrome (execFile, not execFileSync): a
121
- * synchronous child blocks the event loop, and this in-process server would
122
- * never answer the browser it launched.
123
- *
124
- * Returns `{ origin, close }` — `origin` is `http://127.0.0.1:<port>`, `close`
125
- * resolves when the listener is shut.
126
- */
127
- export async function serveForRender(root, { html = null } = {}) {
128
- const files = staticFiles(root, { html });
129
-
130
- /**
131
- * Fast-forward, then re-read, re-audit and RE-PRINT.
132
- *
133
- * SPEC's condition on live reload under `present` is exactly this: never new
134
- * bytes under the old verdict. So the label the presenter can see always
135
- * describes the bytes being served, and the two move together.
136
- */
137
- async function doPull() {
138
- // Re-checked against a FRESH fetch rather than trusted from the cached
139
- // status: what was true ten minutes ago is not a licence to check out now.
140
- const fresh = await refreshUpstream();
141
- const allowed = canPull(fresh, { offered: pullArmed });
142
- if (!allowed.ok) return { ok: false, ...allowed, http: allowed.state === 'dirty' ? 409 : 409 };
143
-
144
- const from = (await runGit(['rev-parse', '--short', 'HEAD'], { cwd: upstream.repoRoot })).stdout;
145
- console.log(` upstream: PULL requested by the deck — fast-forward only, onto ${upstream.upstream}`);
146
- const merged = await runGit([...SAFE_CONFIG, '-c', `core.hooksPath=${upstream.repoRoot}/.git/decklight-no-hooks`,
147
- 'merge', '--ff-only', '--no-verify', '@{upstream}'], { cwd: upstream.repoRoot, timeoutMs: 20000 });
148
- if (!merged.ok) {
149
- const why = oneline(merged.stderr || merged.err);
150
- console.log(` upstream: the fast-forward was refused — ${why}`);
151
- return { ok: false, state: 'not-fast-forward', message: why };
152
- }
153
- const to = (await runGit(['rev-parse', '--short', 'HEAD'], { cwd: upstream.repoRoot })).stdout;
154
-
155
- // An upstream commit must never blank somebody's talk.
156
- if (!existsSync(deckPath)) {
157
- console.log(` upstream: fast-forwarded ${from} → ${to}, but the deck is gone from that commit`);
158
- console.log(' still serving the bytes the label above describes');
159
- return { ok: false, state: 'deck-gone', to, message: 'the deck is not in that commit — still serving the old bytes' };
160
- }
161
-
162
- const before = deck.payload;
163
- const next = readAndAudit();
164
- if (next.payload.equals(before)) {
165
- console.log(` upstream: fast-forwarded ${from} → ${to} — the deck itself is unchanged`);
166
- await refreshUpstream();
167
- return { ok: true, state: 'pulled', from, to, deck: 'unchanged', reload: false, message: `fast-forwarded to ${to} — the deck is unchanged` };
168
- }
169
-
170
- // STRICT RATCHETS: a pull may turn it on and can never turn it off. A deck
171
- // that could clear its own strict flag by pulling could disarm the one
172
- // mitigation present applies without being asked.
173
- const wasStrict = deck.strict;
174
- deck = { ...next, strict: next.strict || wasStrict };
175
- const degraded = (next.report.counts.unaccounted > 0 || next.report.counts.handlers > 0)
176
- && !(report.counts.unaccounted > 0 || report.counts.handlers > 0);
177
-
178
- console.log(` upstream: fast-forwarded ${from} → ${to}`);
179
- console.log(' the deck file changed — re-read and re-audited; the label below replaces the one above');
180
- for (const line of formatLabel(deck.report)) console.log(line);
181
- console.log(formatSignature(deck.signature));
182
- if (deck.strict) {
183
- console.log(wasStrict && !next.strict
184
- ? ' still serving strict — a pull cannot turn it off'
185
- : ' serving strict — what could not be accounted for is stripped');
186
- }
187
- console.log(' the label above describes what the audience gets when the deck is reloaded');
188
- await refreshUpstream();
189
- return {
190
- ok: true, state: 'pulled', from, to, deck: 'changed',
191
- strict: deck.strict, degraded,
192
- findings: { unaccounted: deck.report.counts.unaccounted, handlers: deck.report.counts.handlers },
193
- // A degraded deck does NOT reload itself: the swap executes nothing (the
194
- // browser is still showing the old DOM), so the reload can wait for a
195
- // second confirmation that names what was found.
196
- reload: !degraded,
197
- message: degraded
198
- ? `the updated deck runs ${deck.report.counts.unaccounted} unaccounted script block(s) and `
199
- + `${deck.report.counts.handlers} inline handler(s) — they are stripped. Reload to show it`
200
- : `fast-forwarded to ${to}`,
201
- };
202
- }
203
-
204
- const server = createServer(withHeaders({ 'content-security-policy': CSP }, (req, res) => {
205
- let url;
206
- try { url = new URL(req.url, 'http://127.0.0.1'); }
207
- catch { res.writeHead(400); res.end('bad request'); return; }
208
- if (files(req, res, url)) return;
209
- res.writeHead(405); res.end('method not allowed');
210
- }));
211
- const port = await listenTakingOverIfNeeded(server, 0, '127.0.0.1');
212
- return {
213
- origin: `http://127.0.0.1:${port}`,
214
- close: () => new Promise((r) => server.close(r)),
215
- };
216
- }
217
-
218
- const USAGE = `usage: decklight present <deck.html|deck.decklight> [--port 8790] [--strict]
219
- [--root <dir>] [--remote] [--host <addr>] [--check]
220
- [--no-plugins]
221
-
222
- plays a deck read-only over localhost — the safe way to open one you did not
223
- author. Serves ONLY GET, only under the deck's own directory — refusing
224
- dotfiles and every file type a deck cannot use — and writes nothing.
225
-
226
- A .decklight container (bundle --deck) is unwrapped in memory and treated
227
- exactly like the deck it wraps: same audit, same policy, same strict rule. Its
228
- signature is verified and its manifest is printed as what it is — the
229
- container's own claim about itself, next to the one thing that was checked.
230
- The manifest's origin (repo and commit) is never printed: the signature
231
- covers the deck alone, so even on a verified container the origin is whatever
232
- the packer wrote, and a provenance line nobody vouches for does not belong
233
- one skim away from a verified identity. It stays in the manifest for tooling
234
- to read.
235
-
236
- --port N port to bind; a taken port offers to take over that session
237
- (on a TTY) or moves on to the next free one [8790]
238
- --strict serve with every script block that is not the runtime removed,
239
- along with every inline on*= handler, javascript: URL and srcdoc
240
- document. The removal happens on the way out — the file on disk
241
- is never touched. Turns itself on when the label finds something.
242
- --root D serve D instead of the deck's directory, for a SOURCE deck that
243
- reaches up for its runtime (demo/talk.html loading
244
- ../dist/decklight.js). The deck must live under D, and everything
245
- under D that passes the dotfile and file-type rules becomes
246
- fetchable by the deck's own script — which is why widening the
247
- root is a flag you type, never something the cwd decides.
248
- --remote also listen on the LAN for the phone remote. Off this machine ONLY
249
- /remote/* answers, and only with the per-run token the printed URL
250
- and its QR carry — the deck itself, and every file beside it, stay
251
- unreachable from the LAN whether or not this flag is passed.
252
- --host A the address --remote binds [0.0.0.0]
253
- --check print the ingredients label and exit — no server. Exits non-zero
254
- if the deck runs any script that is not the runtime — a block or
255
- an executable attribute — so CI can gate on a deck before it is
256
- forwarded or published.
257
- --no-plugins present without your own chrome, whatever is installed.
258
- --upstream-every N minutes between upstream checks; 0 turns the check off [10]
259
- --no-upstream never look at the upstream — no git, no network
260
- --upstream-pull register the update control the deck's H overlay drives.
261
- OFF by default: with it on, any script in the deck can
262
- fast-forward the clone the deck was served from.
263
-
264
- Your presenter plugins (decklight plugin) are layered on at serve time from
265
- ~/.decklight/plugins/ — a timer, a teleprompter, a confidence monitor. They
266
- are YOURS: the deck on disk is untouched, nothing is written into it, and the
267
- same file presented on a machine without them is identical slides and no
268
- warning. Each one renders inside a sandboxed frame with an opaque origin, so
269
- it draws chrome and cannot reach the slides — a plugin that asks for slide
270
- content is refused by name, because a deck has to stay a deterministic
271
- artifact or two people presenting the same file present different decks.
272
-
273
- A plugin is never part of the ingredients label: the label counts what is in
274
- the file, the chrome is listed under it as what it is. Loading one registers
275
- no route and does not widen the policy below by a single source.
276
-
277
- Every start prints the ingredients label: which runtime is embedded and
278
- whether its bytes are the ones this install ships, how many inert data blocks
279
- the runtime will read, and — named, with line numbers — every script block
280
- that will execute and is NOT accounted for, plus every executable attribute
281
- (an inline on*= handler, a javascript: or data:text/html URL, an inline
282
- srcdoc document — the vectors 'unsafe-inline' below would otherwise let run
283
- unnamed). It is an inventory, not a verdict:
284
- there is no "safe" here, because the scan is a heuristic over a file someone
285
- may have edited and a green check would promise more than it can keep.
286
-
287
- A deck with a detached signature beside it (talk.html.sig) is verified BEFORE
288
- it renders, and the terminal names who signed it — an identity you can judge,
289
- not a check mark. Sigstore keyless, so there are no keys: the certificate was
290
- minted for one signature against the signer's OIDC identity and expired
291
- minutes later; the transparency log is what keeps it checkable. A deck with no
292
- sidecar is not an alarm — most decks are unsigned, and treating that as a
293
- finding would train you to ignore the one that matters. Verifying needs the
294
- sigstore client and the network; when it cannot be done here, that is said as
295
- its own state and never as a pass.
296
-
297
- When the label finds an unaccounted block — or a signature does not verify,
298
- or cannot be checked here — strict mode turns ITSELF on and says so in the
299
- terminal. It does not ask, and there is no --force to turn it
300
- back off: ten minutes before a talk is the worst possible moment for a
301
- refusal, and an escape hatch would be reached for exactly then — so the deck
302
- always plays, and the part nobody can account for is the part that doesn't.
303
- Removed blocks are named in the terminal, never on the audience's screen.
304
-
305
- What survives strict is what a deck needs to render itself: the runtime, the
306
- Decklight.init call, JSON data blocks and templates. Builds, layouts, themes,
307
- charts and background media are markup, CSS and attributes — never at risk. A
308
- clean deck under --strict is byte-identical to the same deck without it.
309
-
310
- There is no editing surface: the /edit/* routes are not registered at all, so
311
- a POST to one is as unknown as a POST to anything else. That is also why the
312
- phone remote lives here rather than on the author server — getting a clicker
313
- should not mean running write endpoints against your deck while you are on
314
- stage and not looking at it.
315
-
316
- Every response carries this Content-Security-Policy as an HTTP header, which
317
- the deck cannot override the way it could a <meta> tag:
318
-
319
- ${CSP.replace(/; /g, ';\n ')}
320
-
321
- Recorded narration from a bucket and external background video still play —
322
- that is what the https: sources in media-src/connect-src are for. Live voice
323
- does not: synthesis needs the local bridge, which is an authoring-mode engine
324
- and is deliberately not reachable from here.
325
-
326
- Read the policy honestly: script-src carries 'unsafe-inline' because a
327
- bundled deck IS inline script, so this does not stop a deck from running
328
- code. It stops that code from reaching anywhere it shouldn't.`;
329
-
330
- // `client` is the sigstore client — injectable for the same reason as
331
- // `bundleMain`'s: `undefined` means "go load the real one", an explicit stub
332
- // lets a test drive the verification states without the network.
333
- /**
334
- * A refusal that says which command refused. Every other command names itself
335
- * — `decklight bundle: deck not found: …` — and present's three refusals did
336
- * not, so a bare `deck not found:` in a terminal running several tools was the
337
- * one message that could not be traced back to what printed it.
338
- */
339
- const fail = (msg) => { console.error(`decklight present: ${msg}`); return 1; };
340
-
341
- export async function presentMain(args, { client } = {}) {
342
- const positional = args.filter((a) => !a.startsWith('-'));
343
- if (args.includes('--help') || args.includes('-h') || !positional.length) {
344
- console.log(USAGE);
345
- return 0;
346
- }
347
- const { opt } = argReader(args);
348
- const port = Number(opt('--port', 8790));
349
-
350
- // --remote widens the LISTENER and nothing else (PRESENT#REMOTE). The point
351
- // of moving the phone remote here is that getting a clicker should not mean
352
- // running an editing server against your deck while you are on stage and not
353
- // looking at it — so this server still registers no /edit/* route, and the
354
- // only paths a caller off this machine can reach are /remote/*, with the
355
- // per-run token. allowRemote is the same classifier the author server uses;
356
- // one implementation, tested once.
357
- const remote = args.includes('--remote') || opt('--host') !== undefined;
358
- const host = remote ? opt('--host', '0.0.0.0') : '127.0.0.1';
359
- const token = remote ? randomBytes(16).toString('base64url') : null;
360
-
361
- const deckPath = resolve(process.cwd(), positional[0]);
362
- if (!existsSync(deckPath)) return fail(`deck not found: ${deckPath}`);
363
- // A .decklight is the same deck with its signature and manifest stapled on
364
- // (DECK_FILE), so it is unwrapped here and everything below treats it exactly
365
- // like the HTML it wraps — same audit, same CSP, same strict rule. Nothing is
366
- // written to unwrap it: the payload is a slice of the bytes already read.
367
- let container = null;
368
- if (isContainer(deckPath)) {
369
- try { container = readContainer(deckPath); } catch (e) { return fail(e.message); }
370
- }
371
- const payload = container ? container.payload : readFileSync(deckPath);
372
-
373
- // The audit runs because it is the only way in (PRESENT): a standalone
374
- // `verify` is a step people skip, so folding it into the command you already
375
- // use to present means it runs every time, at no extra effort.
376
- const report = auditDeck(payload.toString('utf8'));
377
-
378
- // The signature, if the deck came with one (INTEGRITY#SIGNING). Costs nothing
379
- // when there is no sidecar — the common case returns without touching the
380
- // network — and the audit above runs either way, because the two answer
381
- // different questions: a signature says WHO vouched for these bytes, the label
382
- // says what the bytes will do. A signed deck can still run something nobody
383
- // should, and the label is what would name it.
384
- let signature;
385
- if (container) {
386
- signature = container.signature
387
- ? await verifyBytes(container.payload, container.signature, { client })
388
- : { state: TAMPERED, reason: 'the container carries no signature' };
389
- // The manifest is the container's own label. When it does not describe the
390
- // deck it is stapled to, something rewrote one half — which is the same
391
- // conclusion as a signature that does not verify, so it is the same state.
392
- if (!container.digestOk && signature.state === VERIFIED) {
393
- signature = { state: TAMPERED, reason: 'the manifest digest does not match the payload' };
394
- }
395
- } else {
396
- signature = await verifyFile(deckPath, { client });
397
- }
398
-
399
- if (args.includes('--check')) {
400
- for (const line of formatLabel(report, { indent: '' })) console.log(line);
401
- if (container) console.log(formatManifest(container.manifest, { indent: '' }));
402
- if (signature.state !== UNSIGNED) console.log(formatSignature(signature, { indent: '' }));
403
- // Non-zero means "this deck executes something I could not account for", or
404
- // "it carries a signature I could not stand behind" — not "this deck is
405
- // malicious", which is a call no exit code should make. `unchecked` counts:
406
- // a gate that passes when it could not evaluate the claim is not a gate.
407
- return report.counts.unaccounted || report.counts.handlers
408
- || (signature.state !== UNSIGNED && !isVerified(signature)) ? 1 : 0;
409
- }
410
-
411
- // The served root is the deck's OWN directory, never the cwd. Everything
412
- // under the root is fetchable by the deck's own script same-origin, and with
413
- // `connect-src https:` open below, fetchable means exfiltratable — so a root
414
- // inherited from wherever the command happened to run (a project checkout,
415
- // $HOME via file association) would hand a hostile deck whatever lived
416
- // there. A deck handed to you is a bundled single file with no external refs
417
- // at all; its directory is exactly the exposure you accepted by opening it.
418
- //
419
- // A SOURCE deck's assets are not always siblings — `demo/showcase.html`
420
- // reaches up for `../dist/decklight.js` — and rooting at the deck's
421
- // directory would 403 the engine and serve a page that never boots. That is
422
- // what `--root` is for: the same wider exposure, but chosen by a flag you
423
- // typed, and printed at startup so it is never silent.
424
- const rootArg = opt('--root');
425
- const root = rootArg ? resolve(process.cwd(), rootArg) : dirname(deckPath);
426
- if (!deckPath.startsWith(root + sep)) {
427
- return fail('deck must live under --root');
428
- }
429
- const deckUrl = '/' + deckPath.slice(root.length + 1).split(sep).join('/');
430
-
431
- // Strict is not a mode you opt into after reading the label — it is what the
432
- // label DOES when it finds something (PRESENT#STRICT). The alternative
433
- // designs both fail at the same moment: refusing to serve leaves someone with
434
- // no talk ten minutes before they give it, and offering a --force turns the
435
- // finding into a prompt that will be clicked through precisely then. Playing
436
- // the deck without the part nobody could account for is the only option that
437
- // is still the right one under time pressure, so it is the automatic one.
438
- //
439
- // A signature that does not verify feeds the SAME path (INTEGRITY#SIGNING):
440
- // signing adds a source of failure, not a new behaviour. There is deliberately
441
- // no third state where a bad signature means something else — one degrade is
442
- // one thing to understand at the moment you have no time to understand two.
443
- const unverified = signature.state !== UNSIGNED && !isVerified(signature);
444
- // MUTABLE from here, because a pull may replace all of it (PRESENT#UPSTREAM).
445
- // SPEC's condition on live reload is that the audit re-runs and the verdict is
446
- // re-printed — never new bytes under the old label — so the bytes, the label,
447
- // the signature and `strict` move together or not at all.
448
- /** Read the deck, audit it, and decide strict — the startup block, reusable. */
449
- function readAndAudit() {
450
- const bytes = isContainer(deckPath) ? readContainer(deckPath).payload : readFileSync(deckPath);
451
- const rep = auditDeck(bytes.toString('utf8'));
452
- // The signature is NOT re-verified here: it is a sidecar for the file as
453
- // published, verifying it costs the network, and a pull that changed the
454
- // deck has already invalidated whatever the old one attested. The state is
455
- // carried forward and the label says what it says.
456
- return {
457
- payload: bytes,
458
- report: rep,
459
- signature,
460
- strict: args.includes('--strict') || rep.counts.unaccounted > 0 || rep.counts.handlers > 0,
461
- };
462
- }
463
-
464
- let deck = {
465
- payload,
466
- report,
467
- signature,
468
- strict: args.includes('--strict') || report.counts.unaccounted > 0
469
- || report.counts.handlers > 0 || unverified,
470
- };
471
- const strict = deck.strict;
472
-
473
- // The rewrite covers every html response, not only the deck: strict that
474
- // stopped at one file would be walked around by a second page under the same
475
- // root, and the deck can reach one — the theme picker, the slide finder and
476
- // the speaker view all boot documents into same-origin iframes.
477
- // The presenter's own chrome (PRESENT#PLUGINS) — a timer, a teleprompter,
478
- // a confidence monitor. It is loaded from ~/.decklight/plugins/, which is
479
- // the presenter's library and not the deck's: the installer is the
480
- // risk-bearer and nothing here travels, which is the same trust model that
481
- // makes a build-time transform defensible (MARKETPLACE.md EXTENSIONS).
482
- //
483
- // Two orderings below are load-bearing rather than incidental:
484
- // - it loads AFTER `auditDeck` has read the bytes, so a plugin is never
485
- // counted as an unaccounted script block in the ingredients label. The
486
- // label describes the file; a plugin is not in the file.
487
- // - it injects AFTER `stripUnaccounted`, so strict mode never strips the
488
- // chrome as if the deck had smuggled it in.
489
- // With an empty library `injectChrome` returns its input, so this whole
490
- // paragraph is a no-op and `present` is byte-for-byte the command it was.
491
- const chrome = args.includes('--no-plugins') ? { plugins: [], refused: [] } : loadLibrary();
492
- // Consulted per request rather than decided once: after a pull, `strict` may
493
- // have RATCHETED ON, and the bytes served have to follow the verdict printed
494
- // for them.
495
- const strip = (text) => (deck.strict ? stripUnaccounted(text).html : text);
496
-
497
- // Only the deck gets chrome. Every OTHER html file under the root still gets
498
- // the strict rewrite — strict that stopped at one file would be walked
499
- // around by a second page under the same root, and the deck can reach one
500
- // (the theme picker, the slide finder and the speaker view all boot
501
- // documents into same-origin iframes). Those same iframes are why the chrome
502
- // is deck-only: presenter chrome belongs to the document the presenter is
503
- // looking at, and the shim removes itself if it finds it is framed anyway.
504
- // Always a function now: `strip` is decided per call, so a pull that turns
505
- // strict ON must not find the rewrite path was compiled away at startup.
506
- const rewrite = (text, file) => {
507
- const out = strip(text);
508
- return file === deckPath ? injectChrome(out, chrome.plugins) : out;
509
- };
510
- // No `index` here: "/" is the deck, and the deck is answered from memory
511
- // before this handler is consulted — a fallthrough should 404, not reopen
512
- // the disk read this route exists to avoid.
513
- const files = staticFiles(root, { html: rewrite, knownTypesOnly: true });
514
-
515
- // The deck itself is served from MEMORY — container and plain HTML alike —
516
- // from the bytes the audit read and the signature covered. The label, the
517
- // signature verdict and `strict` were all decided against those bytes at
518
- // startup and printed as a verdict; re-reading the file per request would
519
- // let a deck edited on disk AFTER that moment ride out under it (#235). For
520
- // a container this also avoids the one write this command does not make —
521
- // unpacking to a temp file that would sit somewhere after the talk, which is
522
- // precisely the file nobody meant to keep. Everything else about the
523
- // response is identical to any other file under the root: same strict
524
- // rewrite, same policy header, same GET-only server around it. If live
525
- // reload of the deck under `present` is ever wanted, it must re-run the
526
- // audit and re-print the verdict — never silently serve new bytes.
527
- const servePayload = (req, res) => {
528
- if (req.method !== 'GET') return false;
529
- const body = rewrite
530
- ? Buffer.from(rewrite(deck.payload.toString('utf8'), deckPath), 'utf8')
531
- : deck.payload;
532
- res.writeHead(200, { 'content-type': 'text/html; charset=utf-8', 'cache-control': 'no-cache' });
533
- res.end(body);
534
- return true;
535
- };
536
-
537
- // Is this URL the deck? Matched on the RESOLVED path, exactly as staticFiles
538
- // would resolve it, so a percent-encoded spelling of the same file cannot
539
- // slip past this route into the per-request disk read below it.
540
- const isDeck = (url) => {
541
- if (url.pathname === '/') return true;
542
- let rel;
543
- try { rel = decodeURIComponent(url.pathname); } catch { return false; }
544
- return resolve(root, '.' + rel) === deckPath;
545
- };
546
-
547
- // Two one-way channels, kept apart on purpose. `decks` is what a deck served
548
- // by this server subscribes to, and the ONLY event it ever carries is
549
- // `remote` — no `reload`, no `agent`, because neither exists here and a
550
- // presenting server that could tell a deck to reload would be an editing
551
- // server with the writes left out. The phone's own stream lives in the relay.
552
- const decks = sseChannel();
553
- let actualPort = null;
554
- const relay = createRemoteRelay({
555
- deckName: basename(deckPath),
556
- token,
557
- remoteUrl: () => `http://${lanAddress() ?? host}:${actualPort}/remote?t=${token}`,
558
- relayToDeck: (event, data) => decks.broadcast(event, data),
559
- deckCount: () => decks.size,
560
- CORS,
561
- });
562
-
563
- // The CSP is set once, out here, for EVERY response this server writes —
564
- // the deck and its assets, but also the 403/404/405 pages, the control-
565
- // channel JSON and SSE, and the remote controller. Every body below is a
566
- // fixed string or first-party content, so no uncovered response was
567
- // exploitable — but "every response carries the header" is only worth
568
- // stating if it holds by construction, not by each writeHead remembering.
569
-
570
- /**
571
- * Fast-forward, then re-read, re-audit and RE-PRINT.
572
- *
573
- * SPEC's condition on live reload under `present` is exactly this: never new
574
- * bytes under the old verdict. So the label the presenter can see always
575
- * describes the bytes being served, and the two move together.
576
- */
577
- async function doPull() {
578
- // Re-checked against a FRESH fetch rather than trusted from the cached
579
- // status: what was true ten minutes ago is not a licence to check out now.
580
- const fresh = await refreshUpstream();
581
- const allowed = canPull(fresh, { offered: pullArmed });
582
- if (!allowed.ok) return { ok: false, ...allowed, http: allowed.state === 'dirty' ? 409 : 409 };
583
-
584
- const from = (await runGit(['rev-parse', '--short', 'HEAD'], { cwd: upstream.repoRoot })).stdout;
585
- console.log(` upstream: PULL requested by the deck — fast-forward only, onto ${upstream.upstream}`);
586
- const merged = await runGit([...SAFE_CONFIG, '-c', `core.hooksPath=${upstream.repoRoot}/.git/decklight-no-hooks`,
587
- 'merge', '--ff-only', '--no-verify', '@{upstream}'], { cwd: upstream.repoRoot, timeoutMs: 20000 });
588
- if (!merged.ok) {
589
- const why = oneline(merged.stderr || merged.err);
590
- console.log(` upstream: the fast-forward was refused — ${why}`);
591
- return { ok: false, state: 'not-fast-forward', message: why };
592
- }
593
- const to = (await runGit(['rev-parse', '--short', 'HEAD'], { cwd: upstream.repoRoot })).stdout;
594
-
595
- // An upstream commit must never blank somebody's talk.
596
- if (!existsSync(deckPath)) {
597
- console.log(` upstream: fast-forwarded ${from} → ${to}, but the deck is gone from that commit`);
598
- console.log(' still serving the bytes the label above describes');
599
- return { ok: false, state: 'deck-gone', to, message: 'the deck is not in that commit — still serving the old bytes' };
600
- }
601
-
602
- const before = deck.payload;
603
- const next = readAndAudit();
604
- if (next.payload.equals(before)) {
605
- console.log(` upstream: fast-forwarded ${from} → ${to} — the deck itself is unchanged`);
606
- await refreshUpstream();
607
- return { ok: true, state: 'pulled', from, to, deck: 'unchanged', reload: false, message: `fast-forwarded to ${to} — the deck is unchanged` };
608
- }
609
-
610
- // STRICT RATCHETS: a pull may turn it on and can never turn it off. A deck
611
- // that could clear its own strict flag by pulling could disarm the one
612
- // mitigation present applies without being asked.
613
- const wasStrict = deck.strict;
614
- deck = { ...next, strict: next.strict || wasStrict };
615
- const degraded = (next.report.counts.unaccounted > 0 || next.report.counts.handlers > 0)
616
- && !(report.counts.unaccounted > 0 || report.counts.handlers > 0);
617
-
618
- console.log(` upstream: fast-forwarded ${from} → ${to}`);
619
- console.log(' the deck file changed — re-read and re-audited; the label below replaces the one above');
620
- for (const line of formatLabel(deck.report)) console.log(line);
621
- console.log(formatSignature(deck.signature));
622
- if (deck.strict) {
623
- console.log(wasStrict && !next.strict
624
- ? ' still serving strict — a pull cannot turn it off'
625
- : ' serving strict — what could not be accounted for is stripped');
626
- }
627
- console.log(' the label above describes what the audience gets when the deck is reloaded');
628
- await refreshUpstream();
629
- return {
630
- ok: true, state: 'pulled', from, to, deck: 'changed',
631
- strict: deck.strict, degraded,
632
- findings: { unaccounted: deck.report.counts.unaccounted, handlers: deck.report.counts.handlers },
633
- // A degraded deck does NOT reload itself: the swap executes nothing (the
634
- // browser is still showing the old DOM), so the reload can wait for a
635
- // second confirmation that names what was found.
636
- reload: !degraded,
637
- message: degraded
638
- ? `the updated deck runs ${deck.report.counts.unaccounted} unaccounted script block(s) and `
639
- + `${deck.report.counts.handlers} inline handler(s) — they are stripped. Reload to show it`
640
- : `fast-forwarded to ${to}`,
641
- };
642
- }
643
-
644
- // ── the upstream check (PRESENT#UPSTREAM) ─────────────────────────────────
645
- const suppressed = upstreamSuppressed({ args, env: process.env });
646
- const upstreamCtx = suppressed ? { state: 'disabled' } : await resolveUpstream(deckPath);
647
- // Absent unless the deck is a tracked file in a clone with an upstream. This
648
- // is the whole safety argument: a deck you were emailed is a single file and
649
- // never reaches any of it.
650
- const upstream = upstreamCtx.state === 'ok' ? upstreamCtx : null;
651
- // The PULL is a second, explicit opt-in. Server-side there is no way to tell
652
- // "the presenter clicked" from "a script in the deck called fetch()" — a
653
- // page's own script is indistinguishable from its user — so the capability is
654
- // "a deck served from a clone can update itself from that clone's upstream",
655
- // which is a thing someone should have typed rather than something the cwd
656
- // decided. And never with --remote: a phone must not move somebody's repo.
657
- const pullArmed = Boolean(upstream) && args.includes('--upstream-pull') && !token;
658
- let upstreamStatus = upstream
659
- ? { state: 'unchecked', branch: upstream.branch, upstream: upstream.upstream, message: 'not checked yet' }
660
- : { state: upstreamCtx.state, message: suppressed || null };
661
- let checking = null;
662
- const intervalMs = resolveInterval(args);
663
- let lastReported = null;
664
- const pullOffer = () => (pullArmed
665
- ? { offered: true }
666
- : { offered: false, reason: !upstream ? upstreamCtx.state : token ? '--remote is on' : 'start with --upstream-pull' });
667
-
668
- async function refreshUpstream() {
669
- if (!upstream) return upstreamStatus;
670
- // Single-flight: a script in a loop must not spawn a hundred fetches.
671
- if (!checking) {
672
- checking = checkUpstream(upstream).then((s) => { upstreamStatus = s; checking = null; return s; });
673
- }
674
- return checking;
675
- }
676
-
677
- const server = createServer(withHeaders({ 'content-security-policy': CSP }, (req, res) => {
678
- // Loopback always; off-loopback only /remote/* carrying the per-run token,
679
- // and only when --remote asked for a listener at all. Every other path is
680
- // refused off this machine unconditionally — flag or no flag, token or no
681
- // token — which is why the static files and the deck itself cannot be
682
- // reached from the LAN even while the remote can.
683
- if (!allowRemote(req, token)) {
684
- res.writeHead(403);
685
- res.end('forbidden: this deck is served to this machine only; off it, only /remote/* answers, with the session token');
686
- return;
687
- }
688
- let url;
689
- try { url = new URL(req.url, 'http://127.0.0.1'); } catch { res.writeHead(400); res.end('bad request'); return; }
690
- // The deck's own path answers from the audited bytes (servePayload above).
691
- // For a container that also means the URL a person sees is the file they
692
- // double-clicked — serving the raw archive bytes there would hand a
693
- // browser something it cannot render.
694
- if (isDeck(url)) {
695
- if (servePayload(req, res)) return;
696
- res.writeHead(405); res.end('method not allowed'); return;
697
- }
698
- // staticFiles answers GET (200/403/404) and declines everything else. A
699
- // POST to /edit/notes lands here exactly like a POST to /anything — there
700
- // is no route to have refused it, which is the point of the ticket.
701
- // The presenting control channel. `/present/ping` is how a deck discovers
702
- // it is being presented rather than authored, and the answer deliberately
703
- // carries no agent roster and no edit capability — there is nothing here to
704
- // report about editing, because there is nothing here that edits.
705
- if (req.method === 'GET' && url.pathname === '/present/ping') {
706
- res.writeHead(200, { ...CORS, 'content-type': 'application/json', 'cache-control': 'no-cache' });
707
- res.end(JSON.stringify({ ok: true, name: basename(deckPath), remote: !!token, present: true }));
708
- return;
709
- }
710
- if (req.method === 'GET' && url.pathname === '/present/events') { decks.add(req, res, CORS); return; }
711
- // ── the upstream (PRESENT#UPSTREAM) ─────────────────────────────────
712
- // REGISTERED ONLY when the deck is a tracked file in a clone whose branch
713
- // tracks something. On a deck you were emailed these are not refused, they
714
- // do not exist — a POST lands on the same 405 as a POST to anything else,
715
- // which is the argument the module header already makes about /edit/*.
716
- //
717
- // No CORS on either: /present/ping and /present/events carry it because the
718
- // phone's origin differs, and the phone has no business here in either
719
- // direction.
720
- if (upstream && req.method === 'GET' && url.pathname === '/present/upstream') {
721
- res.writeHead(200, { 'content-type': 'application/json', 'cache-control': 'no-cache' });
722
- res.end(JSON.stringify({ ok: true, ...upstreamStatus, pull: pullOffer() }));
723
- return;
724
- }
725
- if (upstream && req.method === 'POST' && url.pathname === '/present/upstream/check') {
726
- if (!isOwnOrigin(req, actualPort)) { res.writeHead(403); res.end('forbidden'); return; }
727
- refreshUpstream().then(() => {
728
- res.writeHead(200, { 'content-type': 'application/json' });
729
- res.end(JSON.stringify({ ok: true, ...upstreamStatus, pull: pullOffer() }));
730
- });
731
- return;
732
- }
733
- if (pullArmed && req.method === 'POST' && url.pathname === '/present/upstream/pull') {
734
- // The strict gate, not allowEditRequest: `null` is a sandboxed plugin
735
- // frame's origin, and presenter chrome must not be able to fast-forward
736
- // the presenter's repository.
737
- if (!isOwnOrigin(req, actualPort)) { res.writeHead(403); res.end('forbidden'); return; }
738
- // The body is never read. Not validated — READ. No field of the request
739
- // reaches git or the filesystem; the repository, the branch and
740
- // `@{upstream}` are all constants resolved before the server existed.
741
- doPull().then((out) => {
742
- res.writeHead(out.ok ? 200 : (out.http ?? 409), { 'content-type': 'application/json' });
743
- res.end(JSON.stringify(out));
744
- });
745
- return;
746
- }
747
- // The phone remote: controller, QR, readout channel. These are the only
748
- // paths allowRemote let through from off this machine, and not one of them
749
- // writes anything — the phone asks the deck to move, it never edits.
750
- let body = '';
751
- if (req.method === 'POST') {
752
- // bridge.mjs's reader with the cap this route has always had: the phone
753
- // remote is the one path reachable from off this machine, and a body
754
- // past 4 KB is a probe, not a request — the socket is destroyed and the
755
- // E2BIG never becomes a response
756
- readBody(req, { max: 4096 }).then((bytes) => {
757
- body = bytes.toString();
758
- try {
759
- if (relay.handle(req, res, url, body)) return;
760
- } catch {
761
- res.writeHead(400, { ...CORS, 'content-type': 'application/json' });
762
- res.end(JSON.stringify({ ok: false, error: 'bad payload' }));
763
- return;
764
- }
765
- res.writeHead(405);
766
- res.end('method not allowed');
767
- }).catch(() => { /* E2BIG: destroyed above; anything else: the socket is gone */ });
768
- return;
769
- }
770
- if (relay.handle(req, res, url, '')) return;
771
- if (files(req, res, url)) return;
772
- res.writeHead(405);
773
- res.end('method not allowed');
774
- }));
775
-
776
- const actual = await listenTakingOverIfNeeded(server, port, host);
777
- actualPort = actual;
778
- console.log(`decklight present on http://127.0.0.1:${actual}${deckUrl} — read-only, CSP enforced. Ctrl-C stops`);
779
- console.log(` serving ${root} — ${rootArg ? '--root as given' : "the deck's own directory"};`
780
- + ' dotfiles and non-deck file types refused; no /edit/* routes, nothing is written');
781
- if (token) {
782
- console.log(` remote: listening on ${host} — http://${lanAddress() ?? host}:${actual}/remote?t=${token}`);
783
- console.log(' off this machine ONLY /remote/* answers, with that token — the deck itself does not');
784
- }
785
- // Before the first slide renders, not after — the point is to be able to
786
- // decide not to open it.
787
- for (const line of formatLabel(report)) console.log(line);
788
- if (container) console.log(formatManifest(container.manifest));
789
- console.log(formatSignature(signature));
790
- // The upstream, said once at startup and then only when it CHANGES. `up to
791
- // date` every ten minutes for an hour is noise that trains people to stop
792
- // reading the terminal — which is where the ingredients label lives.
793
- if (upstream) {
794
- console.log(` upstream: tracking ${upstream.upstream} — ${intervalMs ? `checking every ${intervalMs / 60000} min` : 'checked when asked'}`
795
- + (pullArmed ? ', update control ON (--upstream-pull)' : ''));
796
- if (!pullArmed && args.includes('--upstream-pull') && token) {
797
- console.log(' upstream: --remote is on — the update control is off; pull from your own terminal');
798
- }
799
- } else if (suppressed) {
800
- console.log(` upstream: not checked — ${suppressed}`);
801
- }
802
-
803
- // Kicked AFTER the last startup line and never awaited: nothing about this
804
- // can delay the server coming up or hang a talk on a registry that is down —
805
- // the cli/update-check.mjs contract, applied to a different remote.
806
- if (upstream) {
807
- const tick = () => refreshUpstream().then((st) => {
808
- if (st.state !== lastReported) {
809
- lastReported = st.state;
810
- console.log(` upstream: ${st.message}`);
811
- }
812
- }).catch(() => {});
813
- tick();
814
- // unref'd so a Ctrl-C exits now rather than after an in-flight fetch.
815
- // `--upstream-every 0` keeps the manual check and drops only the timer.
816
- if (intervalMs > 0) setInterval(tick, intervalMs).unref();
817
- }
818
- // Reported UNDER the label and never inside it. The label is an inventory of
819
- // the file; a plugin is not in the file, and folding one into those counts
820
- // would make the label start describing things the deck does not contain —
821
- // which is exactly the honesty the label exists for. Naming which plugins
822
- // read the speaker notes is the other half of `needs: ["notes"]` being a
823
- // declaration rather than a silent grant.
824
- for (const p of chrome.plugins) {
825
- console.log(` chrome: ${p.name} (${p.slot}) — yours, not in the deck`
826
- + `${p.needs.includes('notes') ? '; reads your speaker notes' : ''}`);
827
- }
828
- for (const r of chrome.refused) {
829
- console.log(` chrome: ${r.name} REFUSED — not loaded, the deck plays without it`);
830
- console.log(` ${r.reason.replace(/\n/g, '\n ')}`);
831
- }
832
- // Here and nowhere else. The audience is looking at the deck; a banner on the
833
- // page would tell them something they cannot act on, about a file they did
834
- // not choose to open, in the middle of someone's talk.
835
- if (strict) {
836
- const n = report.counts.unaccounted, h = report.counts.handlers;
837
- if (unverified) console.log(' the signature did not verify — serving strict');
838
- const removed = [
839
- n ? `${n} unaccounted script block${n === 1 ? '' : 's'}` : '',
840
- h ? `${h} executable attribute${h === 1 ? '' : 's'}` : '',
841
- ].filter(Boolean).join(' and ');
842
- console.log(removed
843
- ? ` ${removed} stripped — serving strict. The file on disk is untouched`
844
- : ` nothing to strip — this deck is served exactly as ${container ? 'the container carries it' : 'it was read from disk'}`);
845
- }
846
-
847
- const stop = () => { server.close(); process.exit(0); };
848
- process.on('SIGINT', stop);
849
- process.on('SIGTERM', stop);
850
- return 0;
851
- }
852
-
853
- if (isMain(import.meta.url)) process.exitCode = await presentMain(process.argv.slice(2));