toolroll 0.9.128 → 0.9.129

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 (48) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/accent-colors.js +3 -1
  3. package/dist/approval-authority.js +2 -1
  4. package/dist/assignment.js +55 -2
  5. package/dist/backup.js +6 -0
  6. package/dist/browser/terminal.css +1 -1
  7. package/dist/browser/workspace.css +1 -1
  8. package/dist/central-recovery-stage.js +3 -3
  9. package/dist/companion/access.js +161 -0
  10. package/dist/companion/actions.js +559 -0
  11. package/dist/companion/bonjour.js +45 -0
  12. package/dist/companion/daemon.js +1346 -0
  13. package/dist/companion/direct-server.js +177 -0
  14. package/dist/companion/framing.js +498 -0
  15. package/dist/companion/noise.js +461 -0
  16. package/dist/companion/passkey-gate.js +287 -0
  17. package/dist/companion/paths.js +90 -0
  18. package/dist/companion/reads.js +279 -0
  19. package/dist/companion/relay-auth.js +265 -0
  20. package/dist/companion/relay-server.js +870 -0
  21. package/dist/companion/schema.js +225 -0
  22. package/dist/companion/service.js +580 -0
  23. package/dist/companion/store.js +324 -0
  24. package/dist/companion/webauthn-test-support.js +44 -0
  25. package/dist/companion/webauthn.js +398 -0
  26. package/dist/contracts/console-api.js +18 -0
  27. package/dist/design/kit.css +30 -0
  28. package/dist/local-landing.js +47 -0
  29. package/dist/person-proof.js +5 -1
  30. package/dist/pull-request-flow.js +75 -2
  31. package/dist/qr.js +385 -0
  32. package/dist/release-adapters.js +2 -1
  33. package/dist/restore-retirement.js +2 -0
  34. package/dist/scope.js +67 -4
  35. package/dist/serve.js +31 -4
  36. package/dist/server/pages.js +9 -2
  37. package/dist/server/phone-engine-api.js +59 -0
  38. package/dist/server/route-table.js +11 -0
  39. package/dist/server/settings-phone.js +492 -0
  40. package/dist/server/settings-scripts.js +2 -0
  41. package/dist/server/settings-sections.js +6 -2
  42. package/dist/settings-groups-ui.js +2 -1
  43. package/dist/settings-proofs.js +6 -0
  44. package/dist/store.js +37 -4
  45. package/dist/tailnet.js +42 -0
  46. package/dist/toolroll-update.js +3 -1
  47. package/dist/youiyoux-intake.js +8 -0
  48. package/package.json +7 -2
@@ -0,0 +1,492 @@
1
+ import { createHash } from "node:crypto";
2
+ import { CONSOLE_FORMS, checkResponse, readForm } from "../contracts/console-api.js";
3
+ import { encodeQr } from "../qr.js";
4
+ import { html, joinHtml, postForm } from "../html.js";
5
+ import { authenticateAccount } from "../scope.js";
6
+ import { settingsSubPage } from "../settings-groups-ui.js";
7
+ import { kitSectionForm } from "../settings-kit.js";
8
+ import { refuse, relativeAge, screen } from "./chrome.js";
9
+ import { handlersOf } from "./handler-registry.js";
10
+ import { redirect, respond } from "./http.js";
11
+ import { acts, btn, codeLine, infoLine, note, notice, settingsRecord, settingsSection } from "./kit.js";
12
+ import { cancelPairing, confirmPairing, isPasskeyEnrollmentOpen, listPasskeys, listPhones, openPasskeyEnrollment, pairingView, parsePasskeyWindowMinutes, passkeyWindowMinutes, pathStates, removePhone, renamePhone, revokePasskey, savePasskeyWindow, endPasskeyWindows, startPairing, } from "./phone-engine-api.js";
13
+ import { browserCaller } from "./session.js";
14
+ export const COMPANION_DOCS_URL = "https://github.com/ap9000/toolroll/blob/main/docs/companion-app.md";
15
+ const DEFAULT_RELAY_HOST = "relay.toolroll.dev";
16
+ const PHONE_NAME_MAX = 48;
17
+ const PASSKEY_PROMPTS = [0, 15, 60];
18
+ const promptLabel = (minutes) => minutes === 0 ? "Every approval" : minutes === 15 ? "Once per 15 minutes" : "Once per hour";
19
+ function bindingOf(who) {
20
+ return `${who.name}:${who.session.generation}:${createHash("sha256").update(who.session.csrf).digest("base64url").slice(0, 22)}`;
21
+ }
22
+ function qrFigure(text, label) {
23
+ const code = encodeQr(text, "M");
24
+ const border = 4, dim = code.size + border * 2;
25
+ let path = "";
26
+ for (let y = 0; y < code.size; y++)
27
+ for (let x = 0; x < code.size; x++)
28
+ if (code.dark(x, y))
29
+ path += `M${x + border},${y + border}h1v1h-1z`;
30
+ return html `<figure class="k-phone-qr"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${dim} ${dim}" shape-rendering="crispEdges" role="img" aria-label="${label}"><rect width="${dim}" height="${dim}" fill="#fff"/><path d="${path}" fill="#000"/></svg></figure>`;
31
+ }
32
+ export function spokenCode(code) {
33
+ return code.split("-").map(half => half.split("").join(" ")).join(", ");
34
+ }
35
+ function codeLead(deviceName) {
36
+ return deviceName !== null && deviceName.trim() !== "" && deviceName !== "iPhone" ? `“${deviceName}” should be showing this code:` : "Your iPhone should be showing this code:";
37
+ }
38
+ function pairedOn(iso) {
39
+ const at = new Date(iso);
40
+ return Number.isNaN(at.getTime()) ? iso : at.toLocaleString("en-US", { month: "short", day: "numeric", hour: "2-digit", minute: "2-digit", hourCycle: "h23" });
41
+ }
42
+ const RETIRED_WORDS = {
43
+ removed: "Removed",
44
+ password_changed: "Signed out when your password changed",
45
+ access_changed: "Signed out when your access changed",
46
+ restored: "Signed out when this workspace was restored",
47
+ migration: "Signed out by a Toolroll update",
48
+ contested: "Not paired: another device used the code",
49
+ pairing_failed: "Pairing didn't finish",
50
+ };
51
+ export const PHONE_PAIRING_SCRIPT = `(function(){var first=document.getElementById("phone-pairing");if(!first)return;` +
52
+ `var id=first.getAttribute("data-pairing")||"";var deadline=Date.now()+Number(first.getAttribute("data-left-ms")||0);var done=false,misses=0;` +
53
+ `function root(){return document.getElementById("phone-pairing");}` +
54
+ `function each(sel,fn){var r=root();if(r)Array.prototype.forEach.call(r.querySelectorAll(sel),fn);}` +
55
+ `function show(name){var r=root();if(!r)return;if(name==="scan"&&!r.querySelector('[data-view="scan"]'))name="waiting";` +
56
+ `each("[data-view]",function(v){v.hidden=v.getAttribute("data-view")!==name;});r.setAttribute("data-shown",name);}` +
57
+ `function leave(){if(done)return;done=true;if(location.pathname==="/settings/phone"){history.replaceState(null,"","/settings/phone#phone-pair");location.reload();}else location.replace("/settings/phone#phone-pair");}` +
58
+ `function clock(){if(done)return;var left=Math.max(0,Math.ceil((deadline-Date.now())/1000));var m=Math.floor(left/60),s=left%60;` +
59
+ `var words=left>0?"Expires in "+m+":"+(s<10?"0":"")+s:"This code expired.";each("[data-phone-expires]",function(e){e.textContent=words;});setTimeout(clock,1000);}` +
60
+ `function spell(c){return c.split("-").map(function(h){return h.split("").join(" ");}).join(", ");}` +
61
+ `function lead(n){return n&&n.trim()!==""&&n!=="iPhone"?"\\u201c"+n+"\\u201d should be showing this code:":"Your iPhone should be showing this code:";}` +
62
+ `function apply(v){var s=v&&v.status;` +
63
+ `if(s==="awaiting_scan"||s==="awaiting_ready")return show("scan");` +
64
+ `if(s==="awaiting_confirm"){var c=String(v.confirmCode||"");each("[data-phone-code]",function(e){e.textContent=c;});` +
65
+ `each("[data-phone-code-spoken]",function(e){e.textContent=spell(c);});each("[data-phone-device]",function(e){e.textContent=lead(v.deviceName);});return show("code");}` +
66
+ `if(s==="confirming")return show("confirming");if(s==="finishing")return show("finishing");leave();}` +
67
+ `function poll(){if(done)return;if(document.hidden){setTimeout(poll,1000);return;}` +
68
+ `fetch("/settings/phone/pairings/"+encodeURIComponent(id),{credentials:"same-origin",cache:"no-store",redirect:"manual",headers:{accept:"application/json"}})` +
69
+ `.then(function(r){if(r.status===404||r.type==="opaqueredirect"){leave();return null;}if(!r.ok)throw 0;return r.json();})` +
70
+ `.then(function(v){if(v===null)return;misses=0;apply(v);if(!done)setTimeout(poll,1000);})` +
71
+ `.catch(function(){misses++;if(misses>20)return leave();setTimeout(poll,Math.min(10000,1000*misses));});}` +
72
+ `clock();setTimeout(poll,1000);})();`;
73
+ export function createPhoneSettingsHandlers(runtime, deps) {
74
+ const { store } = runtime;
75
+ const mac = (deps.platform ?? process.platform) === "darwin";
76
+ const thisMac = mac ? "this Mac" : "this computer", ThisMac = mac ? "This Mac" : "This computer";
77
+ const openPairings = new Map();
78
+ const show = (response, status, body, options = {}) => runtime.sendScreen(response, status, screen("Phone", body, {
79
+ chrome: runtime.chromeFor(null, "settings"),
80
+ ...(options.sensitive === true ? { forceSensitive: true } : {}),
81
+ ...(options.script === true ? { functional: { script: PHONE_PAIRING_SCRIPT, fetches: true } } : {}),
82
+ }));
83
+ const passwordHolds = (who, password) => {
84
+ const proved = authenticateAccount(store, who.name, password);
85
+ return proved.ok && proved.role === "approver" && proved.generation === who.session.generation;
86
+ };
87
+ const hasPassword = (who) => store.accountOf(who.name)?.passwordSet === true;
88
+ const passwordProblem = (who) => hasPassword(who) ? "Enter your Toolroll password." : "Set a password to pair a phone.";
89
+ const runBy = (host) => host === DEFAULT_RELAY_HOST ? "run by Toolroll" : "the relay this Toolroll is set up to use (TOOLROLL_RELAY_URL)";
90
+ function directRecord(direct, hostedWorks) {
91
+ const title = `On ${thisMac}'s network`;
92
+ if (direct.state === "off")
93
+ return html ``;
94
+ if (direct.state === "failed") {
95
+ const what = direct.port === null ? "Toolroll couldn't start listening for phones" : `Toolroll couldn't open port ${direct.port}`;
96
+ const error = (direct.error ?? "unknown error").replace(/\.+$/, "");
97
+ const command = html `<code class="k-mono">TOOLROLL_PHONE_PORT=4300 toolroll</code>`;
98
+ return settingsRecord({ title, sub: joinHtml([
99
+ notice(html `Phones can't connect to ${thisMac} directly. ${what}: ${error}.`),
100
+ direct.port === null ? (hostedWorks ? note("Connecting from anywhere still works.") : "")
101
+ : note(html `${hostedWorks ? "Connecting from anywhere still works. To connect directly, quit" : "Quit"} the app using that port, or start Toolroll with ${command}.`),
102
+ ]) });
103
+ }
104
+ const label = (kind) => kind === "tailnet" ? "Tailscale" : "Wi-Fi / Ethernet";
105
+ const at = (address) => direct.port === null || address.includes(":") ? address : `${address}:${direct.port}`;
106
+ const list = direct.addresses.length === 0
107
+ ? note(`${ThisMac} isn't on a network a phone can reach right now. Join Wi-Fi.`)
108
+ : html `<ul class="k-phone-addrs">${direct.addresses.map(one => html `<li><span class="k-phone-addr-k">${label(one.kind)}</span><code class="k-mono">${at(one.address)}</code></li>`)}</ul>`;
109
+ return settingsRecord({ title, sub: joinHtml([
110
+ html `<span>Direct, no relay: on the same Wi-Fi, or anywhere over Tailscale when your phone has it too.</span>`,
111
+ list,
112
+ direct.tailscale === "not_found" ? html `<span class="k-phone-line">Tailscale: not found on ${thisMac}. Optional — <a class="k-link" href="https://tailscale.com/download">get Tailscale</a> to connect directly from anywhere.</span>` : "",
113
+ html `<span class="k-phone-line">${mac ? "If macOS asks whether Toolroll may accept incoming connections, click Allow. " : "If a firewall asks whether Toolroll may accept incoming connections, allow it. "}Phones can't reach ${thisMac} while it's asleep.</span>`,
114
+ ]) });
115
+ }
116
+ function hostedRecord(hosted, configured) {
117
+ if (hosted.state === "off")
118
+ return settingsRecord({ title: "Anywhere else", sub: configured ? `Off. Your phone connects only on ${thisMac}'s network.` : `Off (TOOLROLL_RELAY_URL=off). Your phone connects only on ${thisMac}'s network.` });
119
+ const host = new URL(hosted.relay).host;
120
+ const now = hosted.state === "connected" ? "Connected." : hosted.state === "unreachable" ? html `Can't reach it right now (${hosted.error}); Toolroll keeps trying.` : "Connecting…";
121
+ return settingsRecord({ title: "Anywhere else", sub: joinHtml([
122
+ html `<span>Through ${codeLine(host)}, ${runBy(host)}. End-to-end encrypted: the relay sees when your phone and ${thisMac} connect, never what they send. ${now}</span>`,
123
+ hosted.superseded === true ? notice("Another Toolroll with this workspace's keys is connected to the relay. Phones connecting from anywhere reach that one; stop it, or turn off connecting from anywhere on one of them.") : "",
124
+ ]) });
125
+ }
126
+ function pairingPanel(view, qr) {
127
+ const id = view.pairSessionId;
128
+ const left = Math.max(0, view.expiresAtMs - runtime.clock().getTime());
129
+ const shown = view.status === "awaiting_confirm" ? "code" : view.status === "confirming" ? "confirming" : view.status === "finishing" ? "finishing" : qr !== undefined ? "scan" : "waiting";
130
+ const hidden = (name) => name === shown ? html `` : html ` hidden`;
131
+ const cancel = (label = "Cancel") => postForm("/settings/phone/cancel", html `<button type="submit" class="k-btn k-btn-outline k-btn-sm"><span class="k-face">${label}</span></button>`, { hidden: { pairing: id } });
132
+ const expires = html `<p class="k-note" data-phone-expires>This code works once, for 5 minutes.</p>`;
133
+ const reload = html `<noscript><meta http-equiv="refresh" content="5"></noscript>`;
134
+ const code = view.confirmCode ?? "";
135
+ return html `<div id="phone-pairing" class="k-phone-pairing" data-pairing="${id}" data-left-ms="${left}" data-shown="${shown}">\
136
+ ${qr === undefined ? "" : html `<div data-view="scan"${hidden("scan")}>\
137
+ <ol class="k-phone-steps"><li>Open the Toolroll app on your iPhone and tap <strong>Pair with your Mac</strong>.</li><li>Scan this code. ${ThisMac} then shows a short code to compare.</li></ol>\
138
+ ${qrFigure(qr.payload, "Pairing code for the Toolroll iPhone app")}\
139
+ <details class="k-phone-paste"><summary class="k-note">Can't scan? Copy the pairing code and paste it in the app.</summary><textarea readonly rows="5" aria-label="Pairing code">${qr.payload}</textarea></details>\
140
+ ${expires}${note("Treat this code like your password: anyone who scans it before you can try to pair.")}\
141
+ <noscript><p class="k-note">After you scan it, <a class="k-link" href="/settings/phone#phone-pair">open Settings → Phone</a> to compare codes.</p></noscript>\
142
+ ${acts(cancel())}</div>`}\
143
+ ${qr !== undefined ? "" : html `<div data-view="waiting"${hidden("waiting")}>${shown === "waiting" ? reload : ""}\
144
+ <p class="k-phone-wait" role="status">Waiting for your iPhone to scan the code…</p>${expires}\
145
+ ${note("The QR code is shown only once. If you closed it before scanning, cancel and pair again.")}${acts(cancel())}</div>`}\
146
+ <div data-view="code"${hidden("code")}>\
147
+ <p class="k-note" data-phone-device>${codeLead(view.deviceName)}</p>\
148
+ <p class="k-phone-code"><span aria-hidden="true" data-phone-code>${code}</span><span class="k-sr" data-phone-code-spoken>${spokenCode(code)}</span></p>\
149
+ ${note("Only confirm if your iPhone shows exactly this code. If it doesn't, cancel: someone else may have scanned your QR code.")}${expires}\
150
+ <div class="k-acts">${postForm("/settings/phone/confirm", html `<button type="submit" class="k-btn k-btn-primary k-btn-sm"><span class="k-face">Codes match — pair</span></button>`, { hidden: { pairing: id } })}${cancel()}</div></div>\
151
+ <div data-view="confirming"${hidden("confirming")}>${shown === "confirming" ? reload : ""}<p class="k-phone-wait" role="status">Saving the pairing…</p></div>\
152
+ <div data-view="finishing"${hidden("finishing")}>${shown === "finishing" ? reload : ""}<p class="k-phone-wait" role="status">Finishing on the iPhone…</p>\
153
+ ${note("Keep the Toolroll app open until it says it's paired.")}</div>\
154
+ </div>`;
155
+ }
156
+ function outcomeLine(view) {
157
+ switch (view.status) {
158
+ case "paired": return infoLine("Your iPhone is paired. Open the Toolroll app to see your work.");
159
+ case "cancelled": return infoLine("Pairing cancelled.");
160
+ case "expired": return notice("That pairing code expired. Pair again.");
161
+ case "contested": return notice("Another device used this code, so pairing stopped. Pair again and keep the code to yourself.");
162
+ case "failed": return notice(view.error === null ? "Pairing didn't finish. Pair again." : `Pairing didn't finish: ${view.error} Pair again.`);
163
+ default: return html ``;
164
+ }
165
+ }
166
+ function phoneRecord(phone, now) {
167
+ const seen = phone.lastSeenAt === null ? "never connected" : `last connected ${relativeAge(phone.lastSeenAt, now)}`;
168
+ if (phone.state === "retired") {
169
+ return settingsRecord({ title: html `<span class="k-muted">${phone.name}</span>`, sub: `${RETIRED_WORDS[phone.retiredReason ?? "removed"]} · paired ${pairedOn(phone.pairedAt)}`,
170
+ attrs: { "data-phone": phone.deviceId, "data-phone-state": "retired" } });
171
+ }
172
+ const rename = html `<details class="k-phone-rename"><summary class="k-link">Rename</summary>${postForm("/settings/phone/rename", html `\
173
+ <label class="k-phone-rename-f"><span class="k-sr">New name for ${phone.name}</span><input class="k-input" type="text" name="name" value="${phone.name}" maxlength="${PHONE_NAME_MAX}" required autocomplete="off" spellcheck="false"></label>\
174
+ <button type="submit" class="k-btn k-btn-outline k-btn-sm"><span class="k-face">Save name</span></button>`, { hidden: { device: phone.deviceId } })}</details>`;
175
+ return settingsRecord({
176
+ title: phone.name,
177
+ sub: phone.state === "finishing" ? `Finishing on the iPhone… · paired ${pairedOn(phone.pairedAt)}` : `Paired ${pairedOn(phone.pairedAt)} · ${seen}`,
178
+ attrs: { "data-phone": phone.deviceId, "data-phone-state": phone.state },
179
+ more: joinHtml([rename, kitSectionForm({ proof: "phone-remove", action: "/settings/phone/remove", id: `phone-remove-${phone.deviceId}`, hidden: { device: phone.deviceId },
180
+ save: { label: "Remove", variant: "danger" }, confirm: `Remove ${phone.name}`, body: "" })]),
181
+ });
182
+ }
183
+ function page(who, options = {}) {
184
+ const access = deps.access, on = access.enabled(), service = access.service(), now = runtime.clock();
185
+ const problem = options.problem === undefined ? "" : notice(options.problem);
186
+ const operator = store.isInstanceOperator(who.name);
187
+ const passworded = hasPassword(who);
188
+ const hostedChoice = access.hostedChoice();
189
+ const hostedHost = hostedChoice.ok ? new URL(hostedChoice.url).host : null;
190
+ const paths = service === null ? null : pathStates(service);
191
+ const direct = paths?.direct ?? null, hosted = paths?.hosted ?? { state: "off", superseded: false };
192
+ const directWorks = direct !== null && direct.state === "listening" && direct.addresses.length > 0;
193
+ const hostedWorks = hosted.state === "connected";
194
+ const reachable = on && (directWorks || hostedWorks);
195
+ const hostedBox = (checked) => hostedHost === null ? html `` : html `<label class="k-phone-hosted"><input type="checkbox" name="hosted" value="1"${checked ? html ` checked` : ""}> <span>Also connect from anywhere through ${codeLine(hostedHost)}, ${runBy(hostedHost)}. It's end-to-end encrypted: the relay sees when your phone and ${thisMac} connect, never what they send, and it can't act for you.</span></label>`;
196
+ const notOnStore = note(html `The iPhone app isn't on the App Store yet. <a class="k-link" href="${COMPANION_DOCS_URL}">How to install it</a>`);
197
+ const accessBody = !passworded
198
+ ? joinHtml([notOnStore, infoLine("Set a password to pair a phone. Pairing and removing phones ask for it, so only you can do them."),
199
+ acts(btn("Set a password", { variant: "primary", sm: true, href: "/password/set?next=%2Fsettings%2Fphone" }))])
200
+ : joinHtml([
201
+ notOnStore,
202
+ ...access.problems().map(text => notice(text)),
203
+ on && access.hostedApprovalStale() ? notice(hostedHost === null
204
+ ? `Connecting from anywhere is off on ${thisMac} now (TOOLROLL_RELAY_URL=off).`
205
+ : html `This Toolroll's relay setting changed to ${codeLine(hostedHost)}. Phones connect only on ${thisMac}'s network until you approve the new relay below.`) : "",
206
+ on && direct !== null ? joinHtml([directRecord(direct, hostedWorks), hostedRecord(hosted, hostedHost !== null)]) : "",
207
+ !operator ? note(on ? "Whoever runs this Toolroll turned phone access on." : "Ask whoever runs this Toolroll to turn on phone access.")
208
+ : on ? joinHtml([
209
+ hostedHost === null ? "" : kitSectionForm({ proof: "phone-access", action: "/settings/phone/access", id: "phone-hosted-form", native: true,
210
+ hidden: { act: access.hostedEnabled() ? "hosted-off" : "hosted-on" },
211
+ save: access.hostedEnabled() ? { label: "Stop connecting from anywhere", variant: "outline" } : { label: `Connect from anywhere through ${hostedHost}`, variant: "outline" },
212
+ confirm: access.hostedEnabled() ? "Stop connecting from anywhere" : "Connect from anywhere", body: "" }),
213
+ kitSectionForm({ proof: "phone-access", action: "/settings/phone/access", id: "phone-access-form", native: true,
214
+ hidden: { act: "off" }, save: { label: "Turn off phone access", variant: "danger" }, confirm: "Turn off phone access",
215
+ body: note("Paired phones stay paired but can't connect until you turn it back on.") }),
216
+ ])
217
+ : kitSectionForm({ proof: "phone-access", action: "/settings/phone/access", id: "phone-access-form", native: true,
218
+ hidden: { act: "on" }, save: { label: "Turn on phone access" }, confirm: "Turn on phone access",
219
+ body: joinHtml([
220
+ note(`Your phone connects straight to ${thisMac} on the same Wi-Fi (or over Tailscale).`),
221
+ hostedHost === null ? note(`Connecting from anywhere is off on ${thisMac} (TOOLROLL_RELAY_URL=off).`) : hostedBox(true),
222
+ ]) }),
223
+ ]);
224
+ const accessSection = settingsSection({
225
+ id: "phone-access", title: "iPhone app", state: on ? " · On" : " · Off",
226
+ lead: on ? `Your paired iPhone can see what needs you, read plans, steps and changes, watch agents work, and approve with a passkey.`
227
+ : "Let the Toolroll iPhone app see your work. Nothing is shared until you pair a phone.",
228
+ body: accessBody,
229
+ });
230
+ const binding = bindingOf(who);
231
+ let script = false;
232
+ let pairBody = null;
233
+ if (passworded) {
234
+ const opened = openPairings.get(binding);
235
+ let open = null, restarted = false;
236
+ if (opened !== undefined) {
237
+ open = opened.service === service && service !== null ? pairingView(service, opened.id, binding) : null;
238
+ if (open === null) {
239
+ restarted = opened.service !== service;
240
+ openPairings.delete(binding);
241
+ }
242
+ }
243
+ const live = open !== null && ["awaiting_scan", "awaiting_ready", "awaiting_confirm", "confirming", "finishing"].includes(open.status);
244
+ if (open !== null && live) {
245
+ script = true;
246
+ pairBody = pairingPanel(open, options.qr?.pairSessionId === open.pairSessionId ? options.qr : undefined);
247
+ }
248
+ else {
249
+ if (open !== null)
250
+ openPairings.delete(binding);
251
+ const last = options.problem !== undefined ? "" : open !== null ? outcomeLine(open) : restarted ? notice("Pairing stopped because phone access restarted. Pair again.") : "";
252
+ const why = !on ? note(operator ? "Turn on phone access first." : "Ask whoever runs this Toolroll to turn on phone access.")
253
+ : hosted.state === "starting" && !directWorks ? note(`Connecting to ${new URL(hosted.relay).host}… Reload this page in a moment.`)
254
+ : direct !== null && direct.state === "failed" && !hostedWorks
255
+ ? note(hostedHost !== null && !access.hostedEnabled() ? "Direct connections aren't working (see above). Turn on connecting from anywhere to pair now." : `Direct connections aren't working (see above), so a phone can't reach ${thisMac} yet.`)
256
+ : note(`A phone has no way to reach ${thisMac} yet. Join Wi-Fi${hostedHost !== null ? ", or connect from anywhere" : ""}.`);
257
+ pairBody = joinHtml([
258
+ last,
259
+ reachable
260
+ ? kitSectionForm({ proof: "phone-pair", action: "/settings/phone/pair", id: "phone-pair-form", native: true, save: { label: "Pair an iPhone" },
261
+ confirm: "Pair an iPhone with Toolroll", body: note("You'll get a QR code to scan with the Toolroll app. It works once, for 5 minutes.") })
262
+ : why,
263
+ ]);
264
+ }
265
+ }
266
+ const pairSection = pairBody === null ? "" : settingsSection({ id: "phone-pair", title: "Pair an iPhone", body: pairBody });
267
+ if (options.qr !== undefined) {
268
+ return { body: settingsSubPage("access", "Phone", joinHtml([problem, pairSection]), { lead: "Pair an iPhone with the Toolroll app." }), script };
269
+ }
270
+ const phones = listPhones(store, { accountName: who.name }, now);
271
+ const current = phones.filter(one => one.state !== "retired"), retired = phones.filter(one => one.state === "retired");
272
+ const devices = phones.length === 0 && !passworded ? "" : settingsSection({
273
+ id: "phone-devices", title: "Your phones", state: current.length === 0 ? " · None" : ` · ${current.length}`,
274
+ body: joinHtml([
275
+ current.length === 0 ? note("No phones are paired.") : joinHtml(current.map(phone => phoneRecord(phone, now))),
276
+ retired.length === 0 ? "" : html `<h3 class="k-phone-sub">Removed or signed out in the last 30 days</h3>${joinHtml(retired.map(phone => phoneRecord(phone, now)))}`,
277
+ ]),
278
+ });
279
+ const passkeys = passworded ? listPasskeys(store, who.name) : [];
280
+ const activePasskeys = passkeys.filter(k => k.revokedAt === null);
281
+ const enrollmentOpen = isPasskeyEnrollmentOpen(service, who.name);
282
+ const windowMins = passkeyWindowMinutes(store);
283
+ const passkeyRecord = (k) => settingsRecord({
284
+ title: k.label,
285
+ sub: k.lastUsedAt === null ? `Registered ${pairedOn(k.createdAt)} · not used yet` : `Registered ${pairedOn(k.createdAt)} · last used ${relativeAge(k.lastUsedAt, now)}`,
286
+ attrs: { "data-passkey": k.credentialId },
287
+ more: kitSectionForm({ proof: "phone-passkey-revoke", action: "/settings/phone/passkey/revoke", id: `passkey-revoke-${k.credentialId.slice(0, 12)}`,
288
+ hidden: { credential: k.credentialId }, save: { label: "Revoke passkey", variant: "danger" }, confirm: `Revoke passkey ${k.label}`, body: "" }),
289
+ });
290
+ const alwaysAsks = note("Shipping, landing, protected work and exceptions always ask. Opening the app and confirming with your passkey unlocks approvals for this window.");
291
+ const windowForm = kitSectionForm({
292
+ proof: "phone-passkey-window",
293
+ action: "/settings/phone/passkey/window",
294
+ id: "phone-passkey-window-form",
295
+ native: true,
296
+ save: { label: "Save", variant: "outline" },
297
+ confirm: "Change the passkey prompt",
298
+ body: joinHtml([
299
+ html `<label class="k-field"><span>Passkey prompt</span><select name="window">${joinHtml(PASSKEY_PROMPTS.map(m => html `<option value="${String(m)}"${windowMins === m ? html ` selected` : ""}>${promptLabel(m)}</option>`))}</select></label>`,
300
+ alwaysAsks,
301
+ ]),
302
+ });
303
+ const passkeySection = !passworded || (current.length === 0 && activePasskeys.length === 0) ? "" : settingsSection({
304
+ id: "phone-passkeys",
305
+ title: "Passkey approvals",
306
+ state: activePasskeys.length === 0 ? " · Not set up" : ` · ${activePasskeys.length} active · ${promptLabel(windowMins)}`,
307
+ lead: "Approve plans, accept results, land and ship from your paired iPhone. Each one is confirmed with a passkey and checked on this Mac.",
308
+ body: joinHtml([
309
+ enrollmentOpen
310
+ ? infoLine("Set up is open for 5 minutes. On your paired iPhone, open Settings → Passkey approvals and tap Set up passkey.")
311
+ : on && current.length > 0
312
+ ? kitSectionForm({ proof: "phone-passkey-enable", action: "/settings/phone/passkey/enable", id: "phone-passkey-enable-form", native: true,
313
+ save: { label: activePasskeys.length === 0 ? "Set up a passkey on iPhone" : "Add another passkey", variant: "outline" },
314
+ confirm: "Set up a passkey on iPhone",
315
+ body: note("Gives your paired iPhone 5 minutes to register a passkey for this workspace.") })
316
+ : "",
317
+ activePasskeys.length === 0 ? note("No passkeys registered yet.") : joinHtml(activePasskeys.map(passkeyRecord)),
318
+ operator
319
+ ? settingsRecord({ title: "Passkey prompt", sub: promptLabel(windowMins), more: windowForm })
320
+ : settingsRecord({ title: "Passkey prompt", sub: `${promptLabel(windowMins)} · Whoever runs this Toolroll sets this.`, more: alwaysAsks }),
321
+ ]),
322
+ });
323
+ return { body: settingsSubPage("access", "Phone", joinHtml([problem, accessSection, pairSection, devices, passkeySection]), { lead: "The Toolroll iPhone app: what needs you, in your pocket." }), script };
324
+ }
325
+ const render = (response, status, who, options = {}) => {
326
+ const built = page(who, options);
327
+ return show(response, status, built.body, { script: built.script });
328
+ };
329
+ async function phonePage(ctx) {
330
+ return render(ctx.response, 200, browserCaller(ctx.who));
331
+ }
332
+ async function pairingJson(ctx) {
333
+ const who = browserCaller(ctx.who);
334
+ const id = ctx.url.pathname.slice("/settings/phone/pairings/".length);
335
+ const service = deps.access.service();
336
+ const view = service === null ? null : pairingView(service, id, bindingOf(who));
337
+ if (view === null)
338
+ return respond(ctx.response, 404, "application/json; charset=utf-8", JSON.stringify({ error: "not_found" }));
339
+ return respond(ctx.response, 200, "application/json; charset=utf-8", JSON.stringify(checkResponse("phonePairingView", view)));
340
+ }
341
+ async function accessAct(ctx) {
342
+ const who = browserCaller(ctx.who);
343
+ const body = readForm(ctx.posted, CONSOLE_FORMS.phoneAccess);
344
+ if (body.getAll("password").length > 1 || body.getAll("act").length !== 1)
345
+ return render(ctx.response, 400, who, { problem: "Submit one value for each field." });
346
+ const act = body.get("act");
347
+ if (act !== "on" && act !== "off" && act !== "hosted-on" && act !== "hosted-off")
348
+ return render(ctx.response, 400, who, { problem: "Choose on or off." });
349
+ if (body.getAll("hosted").length > 1)
350
+ return render(ctx.response, 400, who, { problem: "Submit one value for each field." });
351
+ if (!store.isInstanceOperator(who.name))
352
+ return render(ctx.response, 403, who, { problem: "An instance operator turns phone access on or off." });
353
+ if (!passwordHolds(who, body.get("password") ?? ""))
354
+ return render(ctx.response, 403, who, { problem: passwordProblem(who) });
355
+ const change = act === "on" ? { act, hosted: body.get("hosted") === "1" } : { act };
356
+ const applied = await deps.access.change(change, who.name, runtime.clock(), () => store.isInstanceOperator(who.name) && store.accountOf(who.name)?.generation === who.session.generation);
357
+ if (applied === "not_on")
358
+ return render(ctx.response, 409, who, { problem: "Phone access is off now. Turn it on first." });
359
+ if (applied === "not_allowed")
360
+ return render(ctx.response, 403, who, { problem: "An instance operator turns phone access on or off." });
361
+ return redirect(ctx.response, "/settings/phone");
362
+ }
363
+ async function pairAct(ctx) {
364
+ const who = browserCaller(ctx.who);
365
+ const body = readForm(ctx.posted, CONSOLE_FORMS.phonePair);
366
+ if (body.getAll("password").length > 1)
367
+ return render(ctx.response, 400, who, { problem: "Submit one value for each field." });
368
+ if (!passwordHolds(who, body.get("password") ?? ""))
369
+ return render(ctx.response, 403, who, { problem: passwordProblem(who) });
370
+ const service = deps.access.service();
371
+ if (service === null)
372
+ return render(ctx.response, 409, who, { problem: "Turn on phone access first." });
373
+ const binding = bindingOf(who);
374
+ const started = startPairing(service, who.name, binding, who.session.generation);
375
+ if (!started.ok)
376
+ return render(ctx.response, 409, who, { problem: started.error });
377
+ openPairings.set(binding, { id: started.qr.pairSessionId, service });
378
+ const built = page(who, { qr: { payload: JSON.stringify(started.qr), pairSessionId: started.qr.pairSessionId, expiresAtMs: started.expiresAtMs } });
379
+ return show(ctx.response, 200, built.body, { sensitive: true, script: built.script });
380
+ }
381
+ const pairingAct = (op) => async (ctx) => {
382
+ const who = browserCaller(ctx.who);
383
+ const body = readForm(ctx.posted, CONSOLE_FORMS.phonePairing);
384
+ const pairing = body.getAll("pairing").length === 1 ? body.get("pairing") ?? "" : "";
385
+ const binding = bindingOf(who);
386
+ const service = deps.access.service();
387
+ const opened = openPairings.get(binding);
388
+ if (service === null || pairing === "" || opened === undefined || opened.id !== pairing || opened.service !== service) {
389
+ return refuse(ctx.response, who, 409, "That pairing isn't open any more. Pair again.", "/settings/phone");
390
+ }
391
+ if (op === "cancel") {
392
+ cancelPairing(service, pairing, binding);
393
+ return redirect(ctx.response, "/settings/phone#phone-pair");
394
+ }
395
+ const confirmed = await confirmPairing(service, pairing, binding);
396
+ if (!confirmed.ok)
397
+ return render(ctx.response, 409, who, { problem: confirmed.error });
398
+ return redirect(ctx.response, "/settings/phone#phone-pair");
399
+ };
400
+ async function renameAct(ctx) {
401
+ const who = browserCaller(ctx.who);
402
+ const body = readForm(ctx.posted, CONSOLE_FORMS.phoneRename);
403
+ if (body.getAll("device").length !== 1 || body.getAll("name").length !== 1)
404
+ return render(ctx.response, 400, who, { problem: "Submit one value for each field." });
405
+ const name = (body.get("name") ?? "").trim();
406
+ if (name.length === 0 || name.length > PHONE_NAME_MAX)
407
+ return render(ctx.response, 400, who, { problem: `Name the phone in 1 to ${PHONE_NAME_MAX} characters.` });
408
+ if (!renamePhone(store, body.get("device") ?? "", name, who.name))
409
+ return render(ctx.response, 404, who, { problem: "That phone isn't paired." });
410
+ return redirect(ctx.response, "/settings/phone#phone-devices");
411
+ }
412
+ async function removeAct(ctx) {
413
+ const who = browserCaller(ctx.who);
414
+ const body = readForm(ctx.posted, CONSOLE_FORMS.phoneRemove);
415
+ if (body.getAll("password").length > 1 || body.getAll("device").length !== 1)
416
+ return render(ctx.response, 400, who, { problem: "Submit one value for each field." });
417
+ if (!passwordHolds(who, body.get("password") ?? ""))
418
+ return render(ctx.response, 403, who, { problem: passwordProblem(who) });
419
+ if (!removePhone(deps.access.service(), store, body.get("device") ?? "", who.name, runtime.clock()))
420
+ return render(ctx.response, 404, who, { problem: "That phone isn't paired." });
421
+ return redirect(ctx.response, "/settings/phone#phone-devices");
422
+ }
423
+ async function passkeyEnableAct(ctx) {
424
+ const who = browserCaller(ctx.who);
425
+ const body = readForm(ctx.posted, CONSOLE_FORMS.phonePasskeyEnable);
426
+ if (body.getAll("password").length > 1)
427
+ return render(ctx.response, 400, who, { problem: "Submit one value for each field." });
428
+ if (!passwordHolds(who, body.get("password") ?? ""))
429
+ return render(ctx.response, 403, who, { problem: passwordProblem(who) });
430
+ const service = deps.access.service();
431
+ if (service === null)
432
+ return render(ctx.response, 409, who, { problem: "Turn on phone access first." });
433
+ if (openPasskeyEnrollment(service, who.name) === null)
434
+ return render(ctx.response, 409, who, { problem: "Passkey enrollment isn't available right now." });
435
+ return redirect(ctx.response, "/settings/phone#phone-passkeys");
436
+ }
437
+ async function passkeyRevokeAct(ctx) {
438
+ const who = browserCaller(ctx.who);
439
+ const body = readForm(ctx.posted, CONSOLE_FORMS.phonePasskeyRevoke);
440
+ if (body.getAll("password").length > 1 || body.getAll("credential").length !== 1)
441
+ return render(ctx.response, 400, who, { problem: "Submit one value for each field." });
442
+ if (!passwordHolds(who, body.get("password") ?? ""))
443
+ return render(ctx.response, 403, who, { problem: passwordProblem(who) });
444
+ if (!revokePasskey(store, body.get("credential") ?? "", who.name, runtime.clock(), deps.access.service()))
445
+ return render(ctx.response, 404, who, { problem: "That passkey isn't active." });
446
+ return redirect(ctx.response, "/settings/phone#phone-passkeys");
447
+ }
448
+ async function passkeyWindowAct(ctx) {
449
+ const who = browserCaller(ctx.who);
450
+ const body = readForm(ctx.posted, CONSOLE_FORMS.phonePasskeyWindow);
451
+ if (body.getAll("password").length > 1 || body.getAll("window").length !== 1)
452
+ return render(ctx.response, 400, who, { problem: "Submit one value for each field." });
453
+ const wanted = parsePasskeyWindowMinutes(body.get("window"));
454
+ if (wanted === null)
455
+ return render(ctx.response, 400, who, { problem: "Choose Every approval, Once per 15 minutes, or Once per hour." });
456
+ const now = runtime.clock();
457
+ const saved = store.transact(() => {
458
+ if (!store.isInstanceOperator(who.name))
459
+ return "operator";
460
+ if (!passwordHolds(who, body.get("password") ?? ""))
461
+ return "password";
462
+ const before = passkeyWindowMinutes(store);
463
+ if (before === wanted)
464
+ return "same";
465
+ savePasskeyWindow(store, wanted);
466
+ store.recordAction({ at: now.toISOString(), actor: who.name, repo: null, taskId: null, runId: null, action: "passkey prompt changed", outcome: "changed", source: "policy", detail: `${promptLabel(before)} → ${promptLabel(wanted)}` });
467
+ return "changed";
468
+ });
469
+ if (saved === "operator")
470
+ return render(ctx.response, 403, who, { problem: "An instance operator sets the passkey prompt." });
471
+ if (saved === "password")
472
+ return render(ctx.response, 403, who, { problem: passwordProblem(who) });
473
+ if (saved === "changed")
474
+ endPasskeyWindows(deps.access.service());
475
+ return redirect(ctx.response, "/settings/phone#phone-passkeys");
476
+ }
477
+ return {
478
+ registrations: handlersOf("settings", {
479
+ "settings.phone": phonePage,
480
+ "settings.phone-pairing": pairingJson,
481
+ "settings.phone-access": accessAct,
482
+ "settings.phone-pair": pairAct,
483
+ "settings.phone-confirm": pairingAct("confirm"),
484
+ "settings.phone-cancel": pairingAct("cancel"),
485
+ "settings.phone-rename": renameAct,
486
+ "settings.phone-remove": removeAct,
487
+ "settings.phone-passkey-enable": passkeyEnableAct,
488
+ "settings.phone-passkey-revoke": passkeyRevokeAct,
489
+ "settings.phone-passkey-window": passkeyWindowAct,
490
+ }),
491
+ };
492
+ }
@@ -10,6 +10,8 @@ export const SCRIPT_INVENTORY = Object.freeze([
10
10
  { id: "tools", does: "Saves a tool's settings as they change, and switches project", symbol: "TOOLS_PROJECT_SCRIPT", module: "tools-ui.ts", today: "settings.tools", section: "tools", slice: "P4", fetches: false,
11
11
  keep: "kit and connect links lead to the tools change document, which owns the script (round 2, change 4)" },
12
12
  { id: "push", does: "Enrolls this device for alerts (a service worker and a push subscription)", symbol: "pushScriptOf", module: "settings-groups-ui.ts", today: "settings.group-alerts", section: "this-device", slice: "C1", fetches: true },
13
+ { id: "phone-pairing", does: "Follows a phone pairing in progress: swaps the QR for the code to compare, counts down, and reloads on the outcome", symbol: "PHONE_PAIRING_SCRIPT", module: "server/settings-phone.ts", today: "settings.phone", section: "phone-pair", slice: "companion-perfect", fetches: true,
14
+ keep: "the pair POST's sensitive answer carries it too; without JavaScript the page works by reload" },
13
15
  { id: "hub-anchors", does: "Forwards the overview's old #anchors to their group pages", symbol: "HUB_ANCHOR_SCRIPT", module: "settings-groups-ui.ts", today: "settings.page", section: "home", slice: "D", fetches: false,
14
16
  keep: "replaced by the retired-address resolvers once every anchor's page is an area" },
15
17
  ]);
@@ -142,8 +142,12 @@ function appearanceSection() {
142
142
  formRow("Accent", "Buttons, focus and what needs you.", select({ name: "accent", label: "Accent", current: prefs.accent, items: [...ACCENT_CHOICES.map(one => [one.hex, one.id === "ink" ? "Ink (default)" : one.name]), ...(custom === null ? [] : [[custom, `Your own colour (${custom})`]])] })),
143
143
  accentNoteWords === null ? "" : html `<p class="k-note">${accentNoteWords}</p>`,
144
144
  ]) }),
145
- disclose("Use your own colour", kitSectionForm({ proof: "appearance", action: "/settings/appearance", id: "accent-own", gate: true, hidden: { return: back },
146
- body: formRow("Your own colour", "Six hex digits, like #6e56cf.", input({ id: "accent-hex", name: "accent", value: custom ?? "", attrs: { placeholder: "#6e56cf", spellcheck: "false", autocomplete: "off", "aria-label": "Your own colour", pattern: "#?[0-9a-fA-F]{6}", required: true } })) }), custom !== null),
145
+ disclose("Use your own colour", joinHtml([
146
+ kitSectionForm({ proof: "appearance", action: "/settings/appearance", id: "accent-picker", gate: true, hidden: { return: back },
147
+ body: formRow("Colour picker", "Pick any swatch for buttons, focus and what needs you.", html `<input type="color" name="accent" value="${prefs.accent}" aria-label="Pick a colour" style="width:40px;height:36px;padding:2px;border:1px solid var(--so-input-line);border-radius:8px;background:var(--so-paper);cursor:pointer">`) }),
148
+ kitSectionForm({ proof: "appearance", action: "/settings/appearance", id: "accent-own", gate: true, hidden: { return: back },
149
+ body: formRow("Hex code", "Six hex digits, like #3b82f6.", input({ id: "accent-hex", name: "accent", value: custom ?? "", attrs: { placeholder: "#3b82f6", spellcheck: "false", autocomplete: "off", "aria-label": "Your own colour", pattern: "#?[0-9a-fA-F]{6}", required: true } })) }),
150
+ ]), custom !== null),
147
151
  ]),
148
152
  });
149
153
  },
@@ -277,7 +277,7 @@ function telegramTokenSection(facts) {
277
277
  ]) });
278
278
  }
279
279
  function phoneSection(phone) {
280
- return settingsSection({ id: "phone", title: "Phone access", lead: "Open Toolroll itself on your phone, over your own private network.",
280
+ return settingsSection({ id: "phone", title: "Toolroll in your phone's browser", lead: html `Open Toolroll itself in your phone's browser, over your own private network. Or use the <a class="k-link" href="/settings/phone">Toolroll iPhone app</a>.`,
281
281
  body: html `<p class="k-note" data-phone-tailnet>${phone.tailnet === null ? html `Install <a class="k-link" href="https://tailscale.com/download">Tailscale</a> on this computer and your phone, then reload this page for the address.`
282
282
  : phone.tailnet.restart === null ? html `On your phone, open <code class="k-mono">${phone.tailnet.address}</code> and sign in.`
283
283
  : html `Start Toolroll with <code class="k-mono">${phone.tailnet.restart}</code>, then on your phone open <code class="k-mono">${phone.tailnet.address}</code> and sign in.`}</p>` });
@@ -361,6 +361,7 @@ export function accessGroup(facts, flags) {
361
361
  const links = [
362
362
  settingsLink({ href: "/people", title: "People", status: people === null ? "Your own access" : [accessWords({ ...facts, passwordless: null }), people.invites === 0 ? "no open invites" : plural(people.invites, "open invite", "open invites")].join(" · ") }),
363
363
  settingsLink({ href: "/settings/sessions", title: "Sessions and tokens", status: `${plural(facts.access.sessions, "session", "sessions")} signed in · ${plural(facts.access.tokens, "API token", "API tokens")}` }),
364
+ ...(facts.approver ? [settingsLink({ href: "/settings/phone", title: "Phone", status: "The Toolroll iPhone app: pair, rename and remove phones" })] : []),
364
365
  ...(facts.operator && (advancedOn(facts) || facts.sso !== null) ? [
365
366
  settingsLink({ href: "/settings/sign-in", title: "Sign-in with a provider", status: facts.sso === null ? "Not set up: everyone uses a password" : `People sign in with ${facts.sso}` })
366
367
  ] : []),
@@ -80,6 +80,12 @@ export const PROOF_INVENTORY = [
80
80
  { id: "people-invite", action: "Invite someone", routes: ["/people/invite"], form: "peopleInvite", field: "token", proof: "credential", ...CREDENTIAL, role: "any", handlerRole: "an approver", secrets: [], terms: [], reveal: "once" },
81
81
  { id: "runner-register", action: "Register a computer that builds", routes: ["/fleet/runner/register"], form: "runnerRegister", field: "token", proof: "credential", ...CREDENTIAL, role: "any", handlerRole: "an approver, from a browser", secrets: [], terms: ["nonce"], reveal: "once", note: "`token` is the person's own password; `nonce` is the register document's one-use form token (spent before the password is checked: after a refusal, register again from the document); the worker's new token is shown once on the answer and only its hash is kept" },
82
82
  { id: "people-projects", action: "Change a person's projects", routes: ["/people/projects"], form: "peopleProjects", field: "token", proof: "credential", ...CREDENTIAL, role: "operator", secrets: [], terms: ["name"] },
83
+ { id: "phone-access", action: "Turn phone access on or off", routes: ["/settings/phone/access"], form: "phoneAccess", field: "password", proof: "typed-password", ...TYPED, role: "operator", secrets: [], terms: ["act"] },
84
+ { id: "phone-remove", action: "Remove a paired phone", routes: ["/settings/phone/remove"], form: "phoneRemove", field: "password", proof: "typed-password", ...TYPED, role: "approver", secrets: [], terms: ["device"] },
85
+ { id: "phone-pair", action: "Pair an iPhone with Toolroll", routes: ["/settings/phone/pair"], form: "phonePair", field: "password", proof: "typed-password", ...TYPED, role: "approver", secrets: [], terms: [] },
86
+ { id: "phone-passkey-enable", action: "Enable passkey approvals on iPhone", routes: ["/settings/phone/passkey/enable"], form: "phonePasskeyEnable", field: "password", proof: "typed-password", ...TYPED, role: "approver", secrets: [], terms: [] },
87
+ { id: "phone-passkey-revoke", action: "Revoke a phone passkey", routes: ["/settings/phone/passkey/revoke"], form: "phonePasskeyRevoke", field: "password", proof: "typed-password", ...TYPED, role: "approver", secrets: [], terms: ["credential"] },
88
+ { id: "phone-passkey-window", action: "Change the passkey prompt for phone approvals", routes: ["/settings/phone/passkey/window"], form: "phonePasskeyWindow", field: "password", proof: "typed-password", ...TYPED, role: "operator", secrets: [], terms: ["window"] },
83
89
  { id: "telegram-pair", action: "Pair your phone with Telegram", routes: ["/settings/telegram/pair"], form: "telegramPair", field: "password", proof: "typed-password", ...TYPED, role: "approver", secrets: [], terms: [] },
84
90
  { id: "chat-approval-save", action: "Turn on approving from chat", routes: ["/settings/chat-approval/save"], form: "chatApproval", field: "token", proof: "typed-password", ...TYPED, role: "approver", secrets: [], terms: ["nonce", "digest", "scope", "full-access", "cap-usd"] },
85
91
  { id: "push-subscribe", action: "Get alerts on this device", routes: ["/push/subscribe"], form: "pushSubscribe", field: "token", proof: "typed-password", ...TYPED, role: "any", handlerRole: "an approver", secrets: [], terms: ["endpoint", "p256dh", "auth"] },