work in progress

This commit is contained in:
2026-08-16 22:00:08 +02:00
parent a914ef1ec4
commit 3c11a88a33
60 changed files with 4487 additions and 41 deletions
+26
View File
@@ -0,0 +1,26 @@
import * as esbuild from 'esbuild';
import { cpSync, mkdirSync, existsSync } from 'node:fs';
const outdir = 'dist';
mkdirSync(outdir, { recursive: true });
await esbuild.build({
entryPoints: {
background: 'src/background/index.ts',
popup: 'src/popup/popup.ts',
},
bundle: true,
format: 'esm',
target: 'chrome120',
outdir,
logLevel: 'info',
});
cpSync('manifest.json', `${outdir}/manifest.json`);
cpSync('src/popup/popup.html', `${outdir}/popup.html`);
cpSync('src/popup/popup.css', `${outdir}/popup.css`);
if (existsSync('icons')) {
cpSync('icons', `${outdir}/icons`, { recursive: true });
}
console.log(`Built -> ${outdir}/`);
+25 -11
View File
@@ -106,18 +106,14 @@ machine. The popup reflects the state of the currently active tab.
- `phase_3` — run key derived; PIN displayed with a countdown derived from
`pin_ttl`. Awaiting user confirmation on the popup. On TTL expiry: transition
to `run_error / pin_timeout`.
- `phase_4` — user confirmed PIN; awaiting encrypted credential from relay.
- `phase_4` — user confirmed PIN (`POST /run/relay/:runId/confirm` sent to
unlock the companion, interfaces.md's "PIN confirmation" — fire-and-forget;
this transition itself is the extension's own real local gate and doesn't
wait on that call); awaiting encrypted credential from relay.
- `delivered` — credential decrypted and handed to the JS SDK; transitions
automatically to `idle` after brief display.
- `run_error` — run failed or aborted at any phase; reason and class
held for display. Three classes:
*Security-class* (extension notifies backend; user sees explicit security
warning; no retry offered):
- `alpha_hash_mismatch` — key bundle received from backend does not match the
commitment in the QR; indicates tampering between extension and backend.
- `pin_mismatch` — run keys diverged; should not occur if all prior
verifications passed.
held for display. Two classes currently apply to the extension:
*Timeout / user class* (expected; user offered retry):
- `ttl_exhausted` — QR auto-refreshes used up; user must manually retry.
@@ -130,6 +126,21 @@ machine. The popup reflects the state of the currently active tab.
- `relay_timeout` — no message received from relay within expected window.
- `relay_error` — relay returned an error or malformed response.
A *Security-class* (extension notifies backend; user sees an explicit
security warning; no retry offered) also exists in the shared
`RunErrorReason` vocabulary — `gui.md`'s "Security warning — mid-run"
template is built for it — but the extension has no member of it today.
`alpha_hash_mismatch` and `pin_mismatch` were listed here in an earlier
draft; both turned out to be companion-only detections copied across by
sharing one `RunErrorReason` enum with `mobile/claude.md` (see that
file's near-identical wording) — the extension never receives a second,
independent value to compare against its own alpha_hash or PIN, so
neither is actually detectable on this side. A human comparing the two
devices' screens and declining to confirm is exactly what `user_abort`
already covers. `bundle_consumed` (see the design note below) is the one
concrete candidate for a real extension-side security-class reason, if
the server is ever extended to push it over the relay.
### Transitions
```
@@ -163,8 +174,9 @@ phase_2
phase_3
→ phase_4 (user confirms PIN)
→ run_error/pin_timeout (pin_ttl expired)
→ run_error/pin_mismatch (security: run keys diverged)
→ run_error/user_abort (user rejects or cancels)
→ run_error/user_abort (user rejects or cancels — the mechanism
for a PIN the user sees not matching;
see the run_error note above)
phase_4
→ delivered (credential received; GCM auth passes)
@@ -341,6 +353,8 @@ The extension communicates with the backend over HTTPS. Endpoints used:
- Open and maintain a WebSocket connection to `/run/relay/:runId` for
incoming relay messages (kem_ciphertext in Phase 2, encrypted credential in
Phase 4).
- Post PIN confirmation to `/run/relay/:runId/confirm` (phase_3 → phase_4,
unlocks the companion — interfaces.md's "PIN confirmation").
- Query account status for a domain (site verification, step 3).
- Report security-class errors to `/security/report`.
+18 -6
View File
@@ -64,7 +64,12 @@ Dark mode follows the user's OS/browser theme (`prefers-color-scheme`).
requirement, not a nice-to-have, since older scanners are the ones most
likely to reject reversed polarity.
- Display size 190×190px in the card body.
- Display size 260×260px — fills the card body's content width edge to
edge (300px popup − 20px padding × 2), so the QR's outer edge lines up
with the countdown bar below it. No margin beyond that shared 20px card
padding; a smaller fixed size (190px, tried initially) left extra
whitespace around the code and made it read as unnecessarily dense for
its size.
- Caption: "Scan with the companion app."
- Countdown bound to `qr_ttl`.
@@ -132,11 +137,18 @@ which are ambient page state rather than part of an active run — nothing to
retry or dismiss; it persists until the cert or page changes.
**Security warning — mid-run** — same red badge and "Security warning"
heading, but with a single **Dismiss** button. Used for `run_error`
security-class reasons (`alpha_hash_mismatch`, `pin_mismatch`), which
interrupt something the user started. Dismiss uses the outlined/ghost button
style, never the filled accent button — nothing about a blocked state should
visually read as "the expected path," the way Confirm does in phase 3.
heading, but with a single **Dismiss** button. Built for a `run_error`
security-class reason that interrupts something the user started, the same
way `cert_invalid`'s security variant interrupts before one starts. No
concrete extension-side reason uses this template today — `claude.md`'s
`run_error` note explains why `alpha_hash_mismatch`/`pin_mismatch` (this
template's original motivating examples) turned out to be companion-only
detections; `bundle_consumed` is the one real candidate, if the server is
ever extended to signal it. The template stays ready either way: the popup
code renders any `errorClass: 'security'` reason through it generically.
Dismiss uses the outlined/ghost button style, never the filled accent
button — nothing about a blocked state should visually read as "the
expected path," the way Confirm does in phase 3.
**Placeholder copy — needs a plain-language pass.** The reason strings used
while designing this ("relay timed out," "run has been stopped and
Binary file not shown.

After

Width:  |  Height:  |  Size: 686 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

+28
View File
@@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCb0SsqFKFIHxUZ
ts1WnIMzlSisNs+d8ZnAmmyYboY1ATtfkQM3mgQRUMqm6VgBhX6bz6sYgBs/Ilsc
SflPDWhhHNGy6VQz4IpM79F9uxAW5jhc47QccGCZZ43UrlvVg7gwjPKN5eShi0bB
qL/BHRdDZ6YBwkV3LCl1HW6xSiHTZYGwM3nLklSqFlHwE5TyCCoEBUmw2GA51Wy0
MpGCusC1JpNaz1k18RTfxDQrILGwiKg9c0ICFsIkUyQPhNNeGTlTwPLgNgJBZiyw
OJy22X8hQjB7lePJkMBauvpvGKR0Pmz2stdKpisa9/RoAY6d4Ykj35F2S9ixR+Nh
dF0OcE/fAgMBAAECggEAEz44JCCbcR+9kwkQv43hZNZv88y/w+lu1pV7rIZBzCap
zCSe5BgA6+6GsymwNQflL0hCAMBEHSjuCEaueRqBIIqBmfnXl0yMvUcEyo/2mGK4
OpM4eXv7bMFC3S2R/oLKQDINUS7qFx/vOMLRY6pnEWup2cpsmnTOwz2Y9QuLCo3r
cdRybLfj36mUDevxhT5Qa8xh6JNBv5ljgv2L2lOfZUHzCTpvkklVWnMXsidwOo+1
9Or43QE/ATFcmX1DzvhYenL8IvnBNTSxsmoyIC8bL+6Sd5CF6aK5R6qBeHG2OY4N
vjVy1vfliOwwpmtJlrvo1Lu2CHnpjqtnbV4FBY6RmQKBgQDbrVJ3C1vBZ5P+NXi3
R6u9VyNR8n+6EhR3AO+01TzT7wWOlLKDRSdiID0S6L8SV6Qd5Q8QO6qi0FhkafI5
6E1HDZbGFaN6LdKaip51n2OP7Wcgiu8cIA6+3BmA1t/XSz/odSyVg+aZHkjPxjS2
Dks2TFfVEPeFUrWlcnXIfSIDpQKBgQC1lLoOV9it/ZAt5QKF/h8jBwB30DuftReE
II+Zvif+8ZZ4rjI79zDNH6WYYR8CQNMQf5qYBiRiz9cZFvK+hc6UG8bhpqeyUFnG
qMNkKBHIeeGAiY9mq4XFvpJXVKpqRE2KSS+ZxHgCDoLKbRCgyVvdWVeidBzbUQDb
vcEG+ZdeMwKBgBpUYNDx5JJ+xqcuY4ScK4JrIkmdJh/4MMm+q/xhnoPMXz8ipW7E
aB8DvC47BUO+i2Yl4TNR43bWP/HxHN5B8Jk2kL63MzveqCJrwOhaLUW/759f557Y
XMwVd10Q5A1a8JL9EFXvVEE/9vwoRoMXnX4pklFwUiqBqlHlMSbRkLUdAoGADm37
OxiQB4OW6Y7BXJSNNONhjiPmGRLzA3Ty9GzAEOpx4rU1GL7UCfjx1+If7LXqD+2U
A3C5g4CwvzWrpKhNekeazmPH/8uS1s6ieFsWzq+g0+4ajzYiM0yppHb98+PppYub
VMTgJImyqxNvttdJjZWD+Uzw3hzZzJyPslYzSTECgYEAu4ecu1DAXUVria/nXEyh
/jqRjDRk20Gur/s9/ZgphcdjG8km8pR2xmGjzcBIT3ScDCe3EQaqNgekG2gyd+dr
g8fXq+VqGIpqgy2shTfa7I8UCbhegRagACq57r5ld7JneOIuSTxLaIRkrtOQIxcQ
LLVPG9JN3MGtp2t+Qb1S1SI=
-----END PRIVATE KEY-----
+31
View File
@@ -0,0 +1,31 @@
{
"manifest_version": 3,
"name": "LOCQR (dev)",
"version": "0.1.0",
"description": "LOCQR browser extension — development build.",
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAm9ErKhShSB8VGbbNVpyDM5UorDbPnfGZwJpsmG6GNQE7X5EDN5oEEVDKpulYAYV+m8+rGIAbPyJbHEn5Tw1oYRzRsulUM+CKTO/RfbsQFuY4XOO0HHBgmWeN1K5b1YO4MIzyjeXkoYtGwai/wR0XQ2emAcJFdywpdR1usUoh02WBsDN5y5JUqhZR8BOU8ggqBAVJsNhgOdVstDKRgrrAtSaTWs9ZNfEU38Q0KyCxsIioPXNCAhbCJFMkD4TTXhk5U8Dy4DYCQWYssDicttl/IUIwe5XjyZDAWrr6bxikdD5s9rLXSqYrGvf0aAGOneGJI9+RdkvYsUfjYXRdDnBP3wIDAQAB",
"background": {
"service_worker": "background.js",
"type": "module"
},
"action": {
"default_popup": "popup.html",
"default_icon": {
"16": "icons/icon-16.png",
"32": "icons/icon-32.png",
"48": "icons/icon-48.png",
"128": "icons/icon-128.png"
}
},
"icons": {
"16": "icons/icon-16.png",
"32": "icons/icon-32.png",
"48": "icons/icon-48.png",
"128": "icons/icon-128.png"
},
"externally_connectable": {
"matches": ["https://test.locqr.dev/*"]
},
"host_permissions": ["https://api.locqr.dev:3000/*"],
"permissions": ["storage", "tabs", "alarms"]
}
+984
View File
@@ -0,0 +1,984 @@
{
"name": "locqr-extension",
"version": "0.1.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "locqr-extension",
"version": "0.1.0",
"dependencies": {
"@noble/curves": "^2.3.0",
"@noble/post-quantum": "0.6.1",
"canonicalize": "3.0.0",
"qrcode": "^1.5.4"
},
"devDependencies": {
"@types/chrome": "^0.0.280",
"@types/qrcode": "^1.5.6",
"esbuild": "^0.28.0",
"typescript": "^5.6.0"
}
},
"node_modules/@esbuild/aix-ppc64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.2.tgz",
"integrity": "sha512-XExcO+dvLKvVtNTibSTBej1NCAbaGhWn9Ww1ZPx80qsahhPFe/8jgWP0IchNe0F3HwkU7n8ejhH8bjonqht8mQ==",
"cpu": [
"ppc64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"aix"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/android-arm": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.2.tgz",
"integrity": "sha512-kXXoiPVVGQcnIYGOeaovwOURpniDBpSq4A03qkQ+BMQqtGG6HYap3xne9C1O1yo4TR3qxlCX5IqqmX6fFo2Lqg==",
"cpu": [
"arm"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/android-arm64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.2.tgz",
"integrity": "sha512-5YfKeeI8qWfBZIX+u2xZC3Zlb3Os/gLS2sbEKM+I4ZOcsWmHS2WLysCcQZDAFRslDUU5Oiq44gf6PYN1vGwG5A==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/android-x64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.2.tgz",
"integrity": "sha512-O387ite7SzUyCcy3JQX4P4bLtEA7bLLkx+esve5JHnyYfNTxcVpXZo9jhdB0lTKN44gztELTdU7nS8Nr16Fs1Q==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/darwin-arm64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.2.tgz",
"integrity": "sha512-n4KqkOQrraxHJcgjM1RvwbigfQKIKJVpM7xp+KsxiyUSrRdIXnt73VhrPAx0fV44hgfmIVKjxMN9J1t5jySVkw==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/darwin-x64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.2.tgz",
"integrity": "sha512-uq6suIWYP37qzGddBKPw5QEQPi6HiLGsO7UmkpfyaYNQ3D+rN6w6WfwH+nuqcGXWvawGwxOEroO4YGnFh95azw==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/freebsd-arm64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.2.tgz",
"integrity": "sha512-n+I0BTSRIoy+d6RPKnEVwql5UwBJolytvY4mAOIEJorKlqgPII8ix6slVVrfZ5Tnj7glIZvloylbB/EJPMWEXw==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"freebsd"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/freebsd-x64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.2.tgz",
"integrity": "sha512-78XJTJkvPs0kz2w61301PJjXl4g7q3JqiYMZ/M/yVI73EHBrCRTgkhu9oqG7vPqq+a/yadEW8aD+agKlk5xrmg==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"freebsd"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/linux-arm": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.2.tgz",
"integrity": "sha512-XlDnu2q5yoqems+xay6wSAcg9DDD7K9RLKZEBOMZm3ckNpJBvOX20tSfby8KfrrhINDyv9V2YVZKY/SpoGJI8w==",
"cpu": [
"arm"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/linux-arm64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.2.tgz",
"integrity": "sha512-pW4AC0P3it8c7do9MVM4p51FzHzdM/TZrerurgRcHJ2WTa1VQ1CIq18xncfpBJw4ojkiZZrKW2yIBWBP92j6Ug==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/linux-ia32": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.2.tgz",
"integrity": "sha512-CYbnj78HsIeA+DhgUKgFCfvNsTHFhMMrinUrMZpDXJXKN8T3XViTZ/+wtHeVxEWY8ewSzTFN+nRmSwO2tZaLUQ==",
"cpu": [
"ia32"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/linux-loong64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.2.tgz",
"integrity": "sha512-buwkd8nsph4R+ajRvw0qM5Hja/TXQow3ptzWO2EbG/cqcIkHloRrdlBtQlshyYGTNFvfkfJ5tpPLVkY4DtsPfQ==",
"cpu": [
"loong64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/linux-mips64el": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.2.tgz",
"integrity": "sha512-ZVykbDyk7519VwiNb9Lcj9m8XM6v5V9uKPvrEMkkEedVewf+0itkhahp4HDpgERXhwLRpWFypsGbG/J8s0QjJA==",
"cpu": [
"mips64el"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/linux-ppc64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.2.tgz",
"integrity": "sha512-CAXl+Dtd9UUuJd8pKKdwh6MLm3MUMiqMPmhZ3tTSXPqfyQ3vDl6R5hZdZ/kYojK4ofXtdfSv1tFq8XzWx3heNQ==",
"cpu": [
"ppc64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/linux-riscv64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.2.tgz",
"integrity": "sha512-GeXCej4IQtU1B+QlDV8W/RRvbzI3O/Stss+/bCXv4lZls5WGRtu2a+3JkA3i4qIUlMXpcHebWpF8AkJhATowuA==",
"cpu": [
"riscv64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/linux-s390x": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.2.tgz",
"integrity": "sha512-3H1weTYZPxt/WOhByszQZybS9w5lKzUn1FDMsgEChbHWQwHYQQRfBxgCcZvPhjHfKyJjIievvMmEUawJrdY9Dg==",
"cpu": [
"s390x"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/linux-x64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.2.tgz",
"integrity": "sha512-4xTZr1FUmSoQW4XIWmit3tzQrUTZM+N3P0XV8xROKYF50XfI7xeO90+1bZvNwxIufQ9hDQVRJH5YhgPVF8A/HQ==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/netbsd-arm64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.2.tgz",
"integrity": "sha512-sSATRjPeDBg3pdgHoQfoYBob11Kk1FGa9lui5RIHZCoCkJa9QKlvl3/vKz2usCmYYjs7ymJR/2Nnsqe+Hjt5nw==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"netbsd"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/netbsd-x64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.2.tgz",
"integrity": "sha512-lqnzCV+mM0gIADaKihiCg6ifgfU2L3h5E33rNQBN1Y4MaVGnzryzmvvf7UHxprpQdE8hpqLolJ9Rl+SkIRDpyw==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"netbsd"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/openbsd-arm64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.2.tgz",
"integrity": "sha512-AL2qJILH7lNjrDmCQDvdxMfAUIv8KMNZOvrwAQ8i8//ntL9FflhOyMJ8OZSMBb8/AWXe3/5v5S20y3zCoZWKoQ==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"openbsd"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/openbsd-x64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.2.tgz",
"integrity": "sha512-QtiuPytchRyC4rwUKhexJdQKvDuZ6hWloi3igqPQNUJCS1/v9EiO3UTOXR6A3FoMo4fnAKbWJdqaIwhOzh8qEw==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"openbsd"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/openharmony-arm64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.2.tgz",
"integrity": "sha512-WkhYDmpTjLvGlScA1rwjRUmhl4k8oXR3cIbtqWmELgU/dFeHHlEllxDvdWcNJV9rbzCexB5vz8gtNewWLgCT7Q==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"openharmony"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/sunos-x64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.2.tgz",
"integrity": "sha512-GPMSkTOtMnv2U2F8gxe4Io6qmVs+YKyp832Etqqxr0hFngmXQ3rzwytelm3GIn7T4VviRUlf3sOgBOiTdvaf7g==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"sunos"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/win32-arm64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.2.tgz",
"integrity": "sha512-PIhhEkE9uPBleRBrQEJpUn7MBnibZzbGzYWPmY3x+YoVg/95zbjB4CxPPOQ8l5tYYM4mMaCthF8/1DIfBQQyWQ==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/win32-ia32": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.2.tgz",
"integrity": "sha512-YmJbfTlvU7Sdn9BB+4PRES4oB6pxgS37MAONj+hBr/cpXS1aBPKXxNnDbu+QCWPj0o9dgyxeq79g6c5P8KeuYA==",
"cpu": [
"ia32"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/win32-x64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.2.tgz",
"integrity": "sha512-5ebpxr3nWMzrL/rnUI755Jkuee0bHL/Gq0WTF9lvcpv73wAp5eu8MfBUgWK9bhWvZjj7yX8etf/8tI8Ney695g==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@noble/ciphers": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/@noble/ciphers/-/ciphers-2.2.0.tgz",
"integrity": "sha512-Z6pjIZ/8IJcCGzb2S/0Px5J81yij85xASuk1teLNeg75bfT07MV3a/O2Mtn1I2se43k3lkVEcFaR10N4cgQcZA==",
"license": "MIT",
"engines": {
"node": ">= 20.19.0"
},
"funding": {
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/@noble/curves": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/@noble/curves/-/curves-2.3.0.tgz",
"integrity": "sha512-v7cY+4oWYPQszRj6ZFGzTVL7uP2TaLo1xMhWHzYC5wj0ZhOXQ5x+sBre8rF3hi8cAoi0bh1qXoovoOkdFtvqEg==",
"license": "MIT",
"dependencies": {
"@noble/hashes": "2.3.0"
},
"engines": {
"node": ">= 20.19.0"
},
"funding": {
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/@noble/curves/node_modules/@noble/hashes": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-2.3.0.tgz",
"integrity": "sha512-oN+QwyX7VSHotibwubG3kpzbwKrfnyR6OOO+3Nk/53ADL7FmgHHz4TgrbaYKvvOw09u6QTx0oiH1cNCIOuN0CQ==",
"license": "MIT",
"engines": {
"node": ">= 20.19.0"
},
"funding": {
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/@noble/hashes": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-2.2.0.tgz",
"integrity": "sha512-IYqDGiTXab6FniAgnSdZwgWbomxpy9FtYvLKs7wCUs2a8RkITG+DFGO1DM9cr+E3/RgADRpFjrKVaJ1z6sjtEg==",
"license": "MIT",
"engines": {
"node": ">= 20.19.0"
},
"funding": {
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/@noble/post-quantum": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/@noble/post-quantum/-/post-quantum-0.6.1.tgz",
"integrity": "sha512-+pormrDZwjRw05U8ADK4JpHejo87+gBd+muRBB/ozztH5yhDLMDF4jHQWN3NQQAsu1zBNPWTG0ZwVI0CR29H0A==",
"license": "MIT",
"dependencies": {
"@noble/ciphers": "~2.2.0",
"@noble/curves": "~2.2.0",
"@noble/hashes": "~2.2.0"
},
"engines": {
"node": ">= 20.19.0"
},
"funding": {
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/@noble/post-quantum/node_modules/@noble/curves": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/@noble/curves/-/curves-2.2.0.tgz",
"integrity": "sha512-T/BoHgFXirb0ENSPBquzX0rcjXeM6Lo892a2jlYJkqk83LqZx0l1Of7DzlKJ6jkpvMrkHSnAcgb5JegL8SeIkQ==",
"license": "MIT",
"dependencies": {
"@noble/hashes": "2.2.0"
},
"engines": {
"node": ">= 20.19.0"
},
"funding": {
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/@types/chrome": {
"version": "0.0.280",
"resolved": "https://registry.npmjs.org/@types/chrome/-/chrome-0.0.280.tgz",
"integrity": "sha512-AotSmZrL9bcZDDmSI1D9dE7PGbhOur5L0cKxXd7IqbVizQWCY4gcvupPUVsQ4FfDj3V2tt/iOpomT9EY0s+w1g==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/filesystem": "*",
"@types/har-format": "*"
}
},
"node_modules/@types/filesystem": {
"version": "0.0.36",
"resolved": "https://registry.npmjs.org/@types/filesystem/-/filesystem-0.0.36.tgz",
"integrity": "sha512-vPDXOZuannb9FZdxgHnqSwAG/jvdGM8Wq+6N4D/d80z+D4HWH+bItqsZaVRQykAn6WEVeEkLm2oQigyHtgb0RA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/filewriter": "*"
}
},
"node_modules/@types/filewriter": {
"version": "0.0.33",
"resolved": "https://registry.npmjs.org/@types/filewriter/-/filewriter-0.0.33.tgz",
"integrity": "sha512-xFU8ZXTw4gd358lb2jw25nxY9QAgqn2+bKKjKOYfNCzN4DKCFetK7sPtrlpg66Ywe3vWY9FNxprZawAh9wfJ3g==",
"dev": true,
"license": "MIT"
},
"node_modules/@types/har-format": {
"version": "1.2.16",
"resolved": "https://registry.npmjs.org/@types/har-format/-/har-format-1.2.16.tgz",
"integrity": "sha512-fluxdy7ryD3MV6h8pTfTYpy/xQzCFC7m89nOH9y94cNqJ1mDIDPut7MnRHI3F6qRmh/cT2fUjG1MLdCNb4hE9A==",
"dev": true,
"license": "MIT"
},
"node_modules/@types/node": {
"version": "26.2.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-26.2.0.tgz",
"integrity": "sha512-5IviulTZeRNp2vAJ514cc/HUlY5nZ9fCbq9DMyC52BrhFZACo3nI0R7qBxhQmo/d27NFe96ur/b7Wwxklda+kg==",
"dev": true,
"license": "MIT",
"dependencies": {
"undici-types": "~8.3.0"
}
},
"node_modules/@types/qrcode": {
"version": "1.5.6",
"resolved": "https://registry.npmjs.org/@types/qrcode/-/qrcode-1.5.6.tgz",
"integrity": "sha512-te7NQcV2BOvdj2b1hCAHzAoMNuj65kNBMz0KBaxM6c3VGBOhU0dURQKOtH8CFNI/dsKkwlv32p26qYQTWoB5bw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/ansi-regex": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"license": "MIT",
"dependencies": {
"color-convert": "^2.0.1"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/camelcase": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",
"integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==",
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/canonicalize": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/canonicalize/-/canonicalize-3.0.0.tgz",
"integrity": "sha512-yYLfHyDMIXRyRqsKBRLX023riFLpXY2YOfdtqKXZRZy9qsfOJ9U+4F9YZL7MEzL5+ziN2x2nlBvY/Voi3EBljA==",
"license": "Apache-2.0",
"bin": {
"canonicalize": "bin/canonicalize.js"
},
"engines": {
"node": ">=18"
}
},
"node_modules/cliui": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz",
"integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==",
"license": "ISC",
"dependencies": {
"string-width": "^4.2.0",
"strip-ansi": "^6.0.0",
"wrap-ansi": "^6.2.0"
}
},
"node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"license": "MIT",
"dependencies": {
"color-name": "~1.1.4"
},
"engines": {
"node": ">=7.0.0"
}
},
"node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"license": "MIT"
},
"node_modules/decamelize": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
"integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==",
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/dijkstrajs": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.3.tgz",
"integrity": "sha512-qiSlmBq9+BCdCA/L46dw8Uy93mloxsPSbwnm5yrKn2vMPiy8KyAskTF6zuV/j5BMsmOGZDPs7KjU+mjb670kfA==",
"license": "MIT"
},
"node_modules/emoji-regex": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
"license": "MIT"
},
"node_modules/esbuild": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.2.tgz",
"integrity": "sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA==",
"dev": true,
"hasInstallScript": true,
"license": "MIT",
"bin": {
"esbuild": "bin/esbuild"
},
"engines": {
"node": ">=18"
},
"optionalDependencies": {
"@esbuild/aix-ppc64": "0.28.2",
"@esbuild/android-arm": "0.28.2",
"@esbuild/android-arm64": "0.28.2",
"@esbuild/android-x64": "0.28.2",
"@esbuild/darwin-arm64": "0.28.2",
"@esbuild/darwin-x64": "0.28.2",
"@esbuild/freebsd-arm64": "0.28.2",
"@esbuild/freebsd-x64": "0.28.2",
"@esbuild/linux-arm": "0.28.2",
"@esbuild/linux-arm64": "0.28.2",
"@esbuild/linux-ia32": "0.28.2",
"@esbuild/linux-loong64": "0.28.2",
"@esbuild/linux-mips64el": "0.28.2",
"@esbuild/linux-ppc64": "0.28.2",
"@esbuild/linux-riscv64": "0.28.2",
"@esbuild/linux-s390x": "0.28.2",
"@esbuild/linux-x64": "0.28.2",
"@esbuild/netbsd-arm64": "0.28.2",
"@esbuild/netbsd-x64": "0.28.2",
"@esbuild/openbsd-arm64": "0.28.2",
"@esbuild/openbsd-x64": "0.28.2",
"@esbuild/openharmony-arm64": "0.28.2",
"@esbuild/sunos-x64": "0.28.2",
"@esbuild/win32-arm64": "0.28.2",
"@esbuild/win32-ia32": "0.28.2",
"@esbuild/win32-x64": "0.28.2"
}
},
"node_modules/find-up": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",
"integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",
"license": "MIT",
"dependencies": {
"locate-path": "^5.0.0",
"path-exists": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/get-caller-file": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
"license": "ISC",
"engines": {
"node": "6.* || 8.* || >= 10.*"
}
},
"node_modules/is-fullwidth-code-point": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
"integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/locate-path": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
"integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",
"license": "MIT",
"dependencies": {
"p-locate": "^4.1.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/p-limit": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",
"integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
"license": "MIT",
"dependencies": {
"p-try": "^2.0.0"
},
"engines": {
"node": ">=6"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/p-locate": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",
"integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",
"license": "MIT",
"dependencies": {
"p-limit": "^2.2.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/p-try": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
"integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==",
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/path-exists": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
"integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/pngjs": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/pngjs/-/pngjs-5.0.0.tgz",
"integrity": "sha512-40QW5YalBNfQo5yRYmiw7Yz6TKKVr3h6970B2YE+3fQpsWcrbj1PzJgxeJ19DRQjhMbKPIuMY8rFaXc8moolVw==",
"license": "MIT",
"engines": {
"node": ">=10.13.0"
}
},
"node_modules/qrcode": {
"version": "1.5.4",
"resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.5.4.tgz",
"integrity": "sha512-1ca71Zgiu6ORjHqFBDpnSMTR2ReToX4l1Au1VFLyVeBTFavzQnv5JxMFr3ukHVKpSrSA2MCk0lNJSykjUfz7Zg==",
"license": "MIT",
"dependencies": {
"dijkstrajs": "^1.0.1",
"pngjs": "^5.0.0",
"yargs": "^15.3.1"
},
"bin": {
"qrcode": "bin/qrcode"
},
"engines": {
"node": ">=10.13.0"
}
},
"node_modules/require-directory": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
"integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==",
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/require-main-filename": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz",
"integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==",
"license": "ISC"
},
"node_modules/set-blocking": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz",
"integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==",
"license": "ISC"
},
"node_modules/string-width": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
"license": "MIT",
"dependencies": {
"emoji-regex": "^8.0.0",
"is-fullwidth-code-point": "^3.0.0",
"strip-ansi": "^6.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/strip-ansi": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
"license": "MIT",
"dependencies": {
"ansi-regex": "^5.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/typescript": {
"version": "5.9.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
"dev": true,
"license": "Apache-2.0",
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=14.17"
}
},
"node_modules/undici-types": {
"version": "8.3.0",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.3.0.tgz",
"integrity": "sha512-j375ScV60dom+YkPFIfTLcOiPxkN/buHz5GobjLhixFuANaNs3C9l4GmrWqejgXWJ7BbJcFYpTEUkS1Ge8bpZQ==",
"dev": true,
"license": "MIT"
},
"node_modules/which-module": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz",
"integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==",
"license": "ISC"
},
"node_modules/wrap-ansi": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz",
"integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==",
"license": "MIT",
"dependencies": {
"ansi-styles": "^4.0.0",
"string-width": "^4.1.0",
"strip-ansi": "^6.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/y18n": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz",
"integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==",
"license": "ISC"
},
"node_modules/yargs": {
"version": "15.4.1",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz",
"integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==",
"license": "MIT",
"dependencies": {
"cliui": "^6.0.0",
"decamelize": "^1.2.0",
"find-up": "^4.1.0",
"get-caller-file": "^2.0.1",
"require-directory": "^2.1.1",
"require-main-filename": "^2.0.0",
"set-blocking": "^2.0.0",
"string-width": "^4.2.0",
"which-module": "^2.0.0",
"y18n": "^4.0.0",
"yargs-parser": "^18.1.2"
},
"engines": {
"node": ">=8"
}
},
"node_modules/yargs-parser": {
"version": "18.1.3",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz",
"integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==",
"license": "ISC",
"dependencies": {
"camelcase": "^5.0.0",
"decamelize": "^1.2.0"
},
"engines": {
"node": ">=6"
}
}
}
}
+22
View File
@@ -0,0 +1,22 @@
{
"name": "locqr-extension",
"private": true,
"version": "0.1.0",
"description": "LOCQR browser extension (Manifest V3). See claude.md / gui.md.",
"type": "module",
"scripts": {
"build": "node build.js"
},
"dependencies": {
"@noble/curves": "^2.3.0",
"@noble/post-quantum": "0.6.1",
"canonicalize": "3.0.0",
"qrcode": "^1.5.4"
},
"devDependencies": {
"@types/chrome": "^0.0.280",
"@types/qrcode": "^1.5.6",
"esbuild": "^0.28.0",
"typescript": "^5.6.0"
}
}
+100
View File
@@ -0,0 +1,100 @@
// Backend calls the service worker makes directly (extension/claude.md,
// "Backend API surface"). `host_permissions` in manifest.json grants these
// fetch() calls cross-origin access without needing CORS headers from the
// server.
import type { RunBundleUploadRequest, RunBundleUploadResponse } from '../types.js';
const API_BASE = 'https://api.locqr.dev:3000';
export type DomainStatus = 'valid' | 'rejected' | 'suspended';
export interface DomainStatusResult {
reachable: true;
status: DomainStatus;
}
export interface DomainUnreachable {
reachable: false;
}
export interface BundleUploaded {
ok: true;
response: RunBundleUploadResponse;
}
export interface BundleUploadFailed {
ok: false;
}
/** POST /run/bundle, Phase 1 (interfaces.md, "Run bundle upload"). */
export async function uploadRunBundle(request: RunBundleUploadRequest): Promise<BundleUploaded | BundleUploadFailed> {
try {
const response = await fetch(`${API_BASE}/run/bundle`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(request),
});
if (!response.ok) {
return { ok: false };
}
return { ok: true, response: (await response.json()) as RunBundleUploadResponse };
} catch {
return { ok: false };
}
}
/**
* PIN confirmation handshake (interfaces.md, "PIN confirmation") — tells the
* companion it's cleared to proceed past its own local pin_display gate.
* Best-effort, same as reportSecurityError: a failed POST here doesn't
* block this side's own phase_4 transition (that's already fully gated
* locally), it just means the companion never gets unlocked and the run
* times out via pin_timeout — logged so that failure mode is diagnosable.
*/
export async function postPinConfirmation(runId: string): Promise<void> {
try {
const response = await fetch(`${API_BASE}/run/relay/${runId}/confirm`, { method: 'POST' });
if (!response.ok) {
console.error(`[locqr] pin confirmation post rejected: ${response.status}`);
}
} catch (err) {
console.error('[locqr] pin confirmation post failed:', err);
}
}
export async function queryDomainStatus(domain: string): Promise<DomainStatusResult | DomainUnreachable> {
try {
const response = await fetch(`${API_BASE}/domain/status?domain=${encodeURIComponent(domain)}`);
if (!response.ok) {
return { reachable: false };
}
const body = (await response.json()) as { status: DomainStatus };
return { reachable: true, status: body.status };
} catch {
return { reachable: false };
}
}
/**
* Security-class errors are reported immediately (extension/claude.md,
* "Error escalation"). `runId` is omitted for pre-run cert errors, per
* interfaces.md — there is no run yet at the verification stage.
*/
export async function reportSecurityError(errorType: string): Promise<void> {
try {
const response = await fetch(`${API_BASE}/security/report`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ error_type: errorType, timestamp: Math.floor(Date.now() / 1000) }),
});
if (!response.ok) {
console.error(`[locqr] security report rejected: ${response.status}`);
}
} catch (err) {
// Best-effort — a failed security report must not block the user-facing
// outcome, which is already determined by this point. Still logged:
// silently swallowing this with no trace at all makes it undebuggable.
console.error('[locqr] security report failed to send:', err);
}
}
+110
View File
@@ -0,0 +1,110 @@
// Run-flow cryptography (crypto.md, extension/claude.md "Cryptographic
// responsibilities"). Pure functions — no chrome.* APIs — so they're usable
// unchanged from the companion test harness (scripts/) for cross-checking,
// and testable in isolation.
import { x25519 } from '@noble/curves/ed25519.js';
import { ml_kem768 } from '@noble/post-quantum/ml-kem.js';
export interface X25519Keypair {
secretKey: Uint8Array;
publicKey: Uint8Array;
}
export interface MlKem768Keypair {
secretKey: Uint8Array;
publicKey: Uint8Array;
}
export function generateX25519Keypair(): X25519Keypair {
return x25519.keygen();
}
export function generateMlKem768Keypair(): MlKem768Keypair {
return ml_kem768.keygen();
}
export function x25519SharedSecret(secretKey: Uint8Array, peerPublicKey: Uint8Array): Uint8Array {
return x25519.getSharedSecret(secretKey, peerPublicKey);
}
export function mlKem768Encapsulate(publicKey: Uint8Array): { cipherText: Uint8Array; sharedSecret: Uint8Array } {
return ml_kem768.encapsulate(publicKey);
}
export function mlKem768Decapsulate(cipherText: Uint8Array, secretKey: Uint8Array): Uint8Array {
return ml_kem768.decapsulate(cipherText, secretKey);
}
function concat(...parts: Uint8Array[]): Uint8Array {
const total = parts.reduce((sum, p) => sum + p.length, 0);
const out = new Uint8Array(total);
let offset = 0;
for (const part of parts) {
out.set(part, offset);
offset += part.length;
}
return out;
}
/**
* alpha_hash = SHA-256(x25519_pub || kem_pub) — classical precedes
* post-quantum per crypto.md's normative hybrid-construction-ordering rule.
*/
export async function alphaHash(x25519Pub: Uint8Array, kemPub: Uint8Array): Promise<Uint8Array> {
const digest = await crypto.subtle.digest('SHA-256', concat(x25519Pub, kemPub) as BufferSource);
return new Uint8Array(digest);
}
async function hkdfSha256(ikm: Uint8Array, salt: Uint8Array, info: string, lengthBytes: number): Promise<Uint8Array> {
const key = await crypto.subtle.importKey('raw', ikm as BufferSource, 'HKDF', false, ['deriveBits']);
const bits = await crypto.subtle.deriveBits(
{ name: 'HKDF', hash: 'SHA-256', salt: salt as BufferSource, info: new TextEncoder().encode(info) },
key,
lengthBytes * 8,
);
return new Uint8Array(bits);
}
/**
* run_key = HKDF-SHA256(ikm = x25519_shared || kem_shared_secret,
* salt = runId_utf8, info = "locqr-run-key-v1", length = 32) — crypto.md.
*/
export async function deriveRunKey(x25519Shared: Uint8Array, kemSharedSecret: Uint8Array, runId: string): Promise<Uint8Array> {
const ikm = concat(x25519Shared, kemSharedSecret);
const salt = new TextEncoder().encode(runId);
return hkdfSha256(ikm, salt, 'locqr-run-key-v1', 32);
}
/**
* PIN = HKDF-SHA256(ikm=run_key, salt=[], info="locqr-pin-v1", length=4)
* (mobile/claude.md — not restated in crypto.md itself), interpreted as a
* big-endian uint32, mod 1,000,000, zero-padded to 6 digits. Both the
* extension and the companion (here, the test harness) must implement this
* identically or the two sides' PINs will never match.
*/
export async function derivePin(runKey: Uint8Array): Promise<string> {
const bits = await hkdfSha256(runKey, new Uint8Array(0), 'locqr-pin-v1', 4);
const value = new DataView(bits.buffer, bits.byteOffset, bits.byteLength).getUint32(0, false);
return (value % 1_000_000).toString().padStart(6, '0');
}
export interface Credential {
username: string;
password: string;
}
/**
* Wire framing (interfaces.md): nonce[12] || ciphertext[N] || tag[16].
* WebCrypto's AES-GCM expects ciphertext+tag concatenated as one buffer
* (tag last, tagLength defaults to 128 bits) — which is exactly this wire
* format already, once the nonce is split off. No manual tag separation
* needed.
*/
export async function decryptCredential(runKey: Uint8Array, payload: Uint8Array): Promise<Credential> {
const nonce = payload.slice(0, 12);
const ciphertextAndTag = payload.slice(12);
const key = await crypto.subtle.importKey('raw', runKey as BufferSource, 'AES-GCM', false, ['decrypt']);
const plaintext = await crypto.subtle.decrypt({ name: 'AES-GCM', iv: nonce as BufferSource }, key, ciphertextAndTag as BufferSource);
return JSON.parse(new TextDecoder().decode(plaintext)) as Credential;
}
+198
View File
@@ -0,0 +1,198 @@
// LOCQR extension — background service worker.
//
// Covers both the verification-state machine (extension/claude.md: cert
// check, idle/error popup states) and, as of this slice, the run flow
// (idle -> phase_1..4 -> delivered) defined in run.ts. This file wires
// external SDK Port messages and internal popup actions to those two
// state machines; the actual run logic lives in run.ts.
import { queryDomainStatus, reportSecurityError } from './api.js';
import { abortRun, cleanupRun, confirmPin, dismissRunError, startRun } from './run.js';
import { registerSdkPort, unregisterSdkPort } from './sdk-ports.js';
import { clearTabState, getTabState, setTabState } from './state.js';
import { verifyRegistrationCert } from './verify.js';
import type { CertInvalidReason, PopupActionMessage, SdkMessage, TabState, VerificationMessage } from '../types.js';
/** Every state past initial verification carries the origin/features an active or just-ended run needs. */
function originAndFeatures(state: TabState): { origin: string; features: string[] } | undefined {
switch (state.kind) {
case 'unverified':
case 'not_registered':
case 'cert_invalid':
case 'account_error':
return undefined;
default:
return { origin: state.origin, features: state.features };
}
}
const OPERATIONAL_ERROR_TO_REASON: Record<Exclude<CertInvalidReason, 'domain_mismatch' | 'signature_invalid' | 'malformed'>, string> =
{
insecure_origin: 'insecure_origin',
expired: 'expired',
not_yet_valid: 'not_yet_valid',
};
const SECURITY_ERROR_TYPE: Record<'domain_mismatch' | 'signature_invalid' | 'malformed', string> = {
domain_mismatch: 'domain_mismatch',
signature_invalid: 'cert_signature_invalid',
malformed: 'cert_malformed',
};
function tabIdOf(port: chrome.runtime.Port): number | undefined {
return port.sender?.tab?.id;
}
async function handleInit(port: chrome.runtime.Port, tabId: number, originUrl: string, cert: string | undefined): Promise<void> {
if (!cert) {
await setTabState(tabId, { kind: 'not_registered' });
respond(port, { type: 'verification', status: 'error', error: { code: 'NOT_REGISTERED' } });
return;
}
const result = verifyRegistrationCert(cert, originUrl);
if (!result.ok) {
const state: TabState = { kind: 'cert_invalid', reason: result.reason, security: result.security };
await setTabState(tabId, state);
if (result.security) {
const errorType = SECURITY_ERROR_TYPE[result.reason as keyof typeof SECURITY_ERROR_TYPE];
await reportSecurityError(errorType);
}
respond(port, {
type: 'verification',
status: 'error',
error: { code: 'CERT_INVALID', reason: result.reason, security: result.security },
});
return;
}
const domainStatus = await queryDomainStatus(result.domain);
if (!domainStatus.reachable) {
await setTabState(tabId, { kind: 'account_error', reason: 'unreachable' });
respond(port, {
type: 'verification',
status: 'error',
error: { code: 'ACCOUNT_ERROR', reason: 'unreachable' },
});
return;
}
if (domainStatus.status !== 'valid') {
await setTabState(tabId, { kind: 'account_error', reason: 'rejected' });
respond(port, {
type: 'verification',
status: 'error',
error: { code: 'ACCOUNT_ERROR', reason: 'rejected' },
});
return;
}
await setTabState(tabId, { kind: 'idle', origin: result.domain, features: result.features });
respond(port, { type: 'verification', status: 'valid', features: result.features });
}
function respond(port: chrome.runtime.Port, message: VerificationMessage): void {
try {
port.postMessage(message);
} catch {
// Port may already be disconnected (page navigated away mid-verification).
}
}
/** SDK `request_credential` — only valid from `idle` per claude.md's transition table. */
async function handleRequestCredential(tabId: number, windowId: number | undefined): Promise<void> {
const state = await getTabState(tabId);
if (state.kind !== 'idle') return;
// Nothing else makes the popup actually appear for an SDK-triggered run
// (unlike the popup's own start_run action, where it's already open).
// Best-effort: openPopup() can reject if the window isn't focused: the
// run still proceeds either way, the user just has to open it manually.
try {
await chrome.action.openPopup(windowId === undefined ? undefined : { windowId });
} catch {
// ignored — see above
}
await startRun(tabId, state.origin, state.features);
}
/** SDK `abort` — valid from any active run phase; a no-op outside one. */
async function handleAbort(tabId: number): Promise<void> {
const oaf = originAndFeatures(await getTabState(tabId));
if (!oaf) return;
await abortRun(tabId, oaf.origin, oaf.features);
}
chrome.runtime.onConnectExternal.addListener((port) => {
const tabId = tabIdOf(port);
const originUrl = port.sender?.tab?.url;
const windowId = port.sender?.tab?.windowId;
if (tabId === undefined || !originUrl) {
port.disconnect();
return;
}
registerSdkPort(tabId, port);
port.onDisconnect.addListener(() => unregisterSdkPort(tabId, port));
void setTabState(tabId, { kind: 'unverified' });
port.onMessage.addListener((raw: unknown) => {
const message = raw as SdkMessage;
if (message.type === 'init') {
void handleInit(port, tabId, originUrl, message.cert);
} else if (message.type === 'request_credential') {
void handleRequestCredential(tabId, windowId);
} else if (message.type === 'abort') {
void handleAbort(tabId);
}
});
});
/**
* Internal popup actions (extension/claude.md's UI action column) — a
* same-extension chrome.runtime.sendMessage channel, distinct from the
* external SDK Port above. `retry` re-enters phase_1 from a dismissable
* run_error (claude.md: security-class errors don't offer retry, but this
* slice only wires user_abort, which does).
*/
chrome.runtime.onMessage.addListener((raw: unknown) => {
const message = raw as PopupActionMessage;
if (message.type !== 'popup_action') return;
void handlePopupAction(message);
});
async function handlePopupAction(message: PopupActionMessage): Promise<void> {
const { tabId, action } = message;
const state = await getTabState(tabId);
switch (action) {
case 'start_run':
if (state.kind === 'idle') await startRun(tabId, state.origin, state.features);
return;
case 'confirm_pin':
if (state.kind === 'phase_3') await confirmPin(tabId, state.origin, state.features);
return;
case 'abort': {
const oaf = originAndFeatures(state);
if (oaf) await abortRun(tabId, oaf.origin, oaf.features);
return;
}
case 'retry':
if (state.kind === 'run_error') await startRun(tabId, state.origin, state.features);
return;
case 'dismiss':
if (state.kind === 'run_error') await dismissRunError(tabId, state.origin, state.features);
return;
}
}
chrome.tabs.onRemoved.addListener((tabId) => {
cleanupRun(tabId);
void clearTabState(tabId);
});
+44
View File
@@ -0,0 +1,44 @@
// WebSocket relay connection (interfaces.md, "Relay messages" — "Backend ->
// Extension (WebSocket push)"). Opened after Phase 1 completes, closed on
// run end. Confirmed working from the MV3 service worker context via the
// Step 0 spike (crypto.md) — this is that finding becoming real code.
import type { RelayMessage } from '../types.js';
const API_WS_BASE = 'wss://api.locqr.dev:3000';
const socketsByTab = new Map<number, WebSocket>();
export interface RelayHandlers {
onKemCiphertext: (payloadB64: string) => void;
onCredential: (payloadB64: string) => void;
}
export function openRelay(tabId: number, runId: string, handlers: RelayHandlers): void {
closeRelay(tabId); // at most one active run per tab
const ws = new WebSocket(`${API_WS_BASE}/run/relay/${runId}`);
socketsByTab.set(tabId, ws);
ws.addEventListener('message', (event) => {
let message: RelayMessage;
try {
message = JSON.parse(event.data as string) as RelayMessage;
} catch {
return; // malformed relay message — ignored, not a protocol error worth surfacing
}
if (message.type === 'kem_ciphertext') {
handlers.onKemCiphertext(message.payload_b64);
} else if (message.type === 'credential') {
handlers.onCredential(message.payload_b64);
}
});
}
export function closeRelay(tabId: number): void {
const existing = socketsByTab.get(tabId);
if (existing) {
existing.close();
socketsByTab.delete(tabId);
}
}
+34
View File
@@ -0,0 +1,34 @@
// In-memory-only store for a run's actual key material — never written to
// chrome.storage.session or anywhere else (extension/claude.md's Data
// storage table lists these separately from general per-tab state, and the
// security invariants are explicit: private key material never leaves the
// service worker). Lost on service worker suspension, same as
// extension/claude.md documents for ephemeral keypairs and the run key —
// an in-flight run doesn't survive that, and isn't expected to.
import type { MlKem768Keypair, X25519Keypair } from './crypto.js';
export interface RunSecrets {
runId: string;
x25519: X25519Keypair;
kem: MlKem768Keypair;
runKey?: Uint8Array; // set once the key exchange completes (phase_2 -> phase_3)
qrTtlSeconds: number;
maxAutoRefresh: number;
pinTtlSeconds: number;
autoRefreshRemaining: number; // claude.md: "the extension tracks auto_refresh_remaining"
}
const secretsByTab = new Map<number, RunSecrets>();
export function setRunSecrets(tabId: number, secrets: RunSecrets): void {
secretsByTab.set(tabId, secrets);
}
export function getRunSecrets(tabId: number): RunSecrets | undefined {
return secretsByTab.get(tabId);
}
export function clearRunSecrets(tabId: number): void {
secretsByTab.delete(tabId);
}
+269
View File
@@ -0,0 +1,269 @@
// Run state machine (extension/claude.md's run states). Scope: the happy
// path (phase_1 -> phase_2 -> phase_3 -> phase_4 -> delivered), user_abort,
// QR auto-refresh / ttl_exhausted, and pin_timeout. Still deferred:
// backend_unreachable/relay_error are only wired for the two call sites
// below, not every conceivable network failure point.
import { base64UrlDecode, base64UrlEncode } from '../base64url.js';
import type { RunErrorClass, RunErrorReason } from '../types.js';
import { postPinConfirmation, uploadRunBundle } from './api.js';
import {
decryptCredential,
deriveRunKey,
derivePin,
generateMlKem768Keypair,
generateX25519Keypair,
mlKem768Decapsulate,
x25519SharedSecret,
} from './crypto.js';
import { closeRelay, openRelay } from './relay.js';
import { clearRunSecrets, getRunSecrets, setRunSecrets, type RunSecrets } from './run-secrets.js';
import { sendToSdk } from './sdk-ports.js';
import { getTabState, setTabState } from './state.js';
// ML-KEM-768 ciphertext (crypto.md's reference table) and the companion's
// ephemeral X25519 pubkey are both fixed-size — interfaces.md's
// kem_ciphertext relay payload is a fixed-offset split, not length-prefixed.
const X25519_PUBKEY_BYTES = 32;
const DELIVERED_DISPLAY_MS = 2000;
// chrome.alarms, not setTimeout: a service worker can be suspended between
// events, which would silently drop a pending setTimeout. Alarms survive
// that (extension/claude.md's timers are load-bearing security/UX
// deadlines, not decorative). Named per-tab, one of each kind at a time —
// scheduling always clears any prior alarm of the same kind first.
const QR_ALARM_PREFIX = 'locqr-qr-ttl';
const PIN_ALARM_PREFIX = 'locqr-pin-ttl';
function qrAlarmName(tabId: number): string {
return `${QR_ALARM_PREFIX}:${tabId}`;
}
function pinAlarmName(tabId: number): string {
return `${PIN_ALARM_PREFIX}:${tabId}`;
}
function scheduleQrTtlAlarm(tabId: number, qrTtlSeconds: number): void {
const name = qrAlarmName(tabId);
chrome.alarms.clear(name);
chrome.alarms.create(name, { delayInMinutes: qrTtlSeconds / 60 });
}
function schedulePinTtlAlarm(tabId: number, pinTtlSeconds: number): void {
const name = pinAlarmName(tabId);
chrome.alarms.clear(name);
chrome.alarms.create(name, { delayInMinutes: pinTtlSeconds / 60 });
}
function clearRunAlarms(tabId: number): void {
chrome.alarms.clear(qrAlarmName(tabId));
chrome.alarms.clear(pinAlarmName(tabId));
}
export async function startRun(tabId: number, origin: string, features: string[]): Promise<void> {
await setTabState(tabId, { kind: 'phase_1', origin, features });
const runId = crypto.randomUUID();
const ok = await uploadBundleAndDisplayQr(tabId, origin, features, runId);
if (!ok) {
await failRun(tabId, origin, features, 'backend_unreachable', 'network');
return;
}
// "run:started | Phase 1 complete; QR displayed" (sdk/claude.md) — fires
// here; phase_1 itself has no dedicated SDK event.
sendToSdk(tabId, { type: 'run_started' });
openRelay(tabId, runId, {
onKemCiphertext: (payloadB64) => {
void handleKemCiphertext(tabId, origin, features, payloadB64);
},
onCredential: (payloadB64) => {
void handleCredential(tabId, origin, features, payloadB64);
},
});
}
/**
* Generates a fresh ephemeral keypair, uploads it under `runId`, and shows
* the resulting QR — the whole of Phase 1's work. Used both for the
* initial phase_1 -> phase_2 transition and for each QR auto-refresh
* (claude.md: "new keypairs are generated, a new key bundle is uploaded,
* and a new QR is displayed automatically... the old key bundle is
* abandoned and will expire server-side"). Reuses `runId` across refreshes
* — the server's key bundle store is keyed by runId and a re-`put` cleanly
* overwrites the old bundle, so the relay WebSocket (also keyed by runId,
* opened once in startRun) never needs to be reopened.
*/
async function uploadBundleAndDisplayQr(tabId: number, origin: string, features: string[], runId: string): Promise<boolean> {
const x25519Keys = generateX25519Keypair();
const kemKeys = generateMlKem768Keypair();
const uploadResult = await uploadRunBundle({
runId,
origin,
x25519_pubkey: base64UrlEncode(x25519Keys.publicKey),
kem_pubkey: base64UrlEncode(kemKeys.publicKey),
});
if (!uploadResult.ok) return false;
const { signed_token: qrContent, qr_ttl: qrTtlSeconds, max_auto_refresh: maxAutoRefresh, pin_ttl: pinTtlSeconds } = uploadResult.response;
const existing = getRunSecrets(tabId);
const secrets: RunSecrets = {
runId,
x25519: x25519Keys,
kem: kemKeys,
qrTtlSeconds,
maxAutoRefresh,
pinTtlSeconds,
autoRefreshRemaining: existing?.autoRefreshRemaining ?? maxAutoRefresh,
};
setRunSecrets(tabId, secrets);
await setTabState(tabId, { kind: 'phase_2', origin, features, qrContent, qrTtlSeconds, phaseStartedAt: Date.now() });
scheduleQrTtlAlarm(tabId, qrTtlSeconds);
return true;
}
/** qr_ttl expired (claude.md's phase_2 transitions). */
async function handleQrTtlExpiry(tabId: number): Promise<void> {
const state = await getTabState(tabId);
if (state.kind !== 'phase_2') return; // stale alarm — run already moved on
const secrets = getRunSecrets(tabId);
if (!secrets) return;
if (secrets.autoRefreshRemaining <= 0) {
await failRun(tabId, state.origin, state.features, 'ttl_exhausted', 'timeout_user');
return;
}
setRunSecrets(tabId, { ...secrets, autoRefreshRemaining: secrets.autoRefreshRemaining - 1 });
const ok = await uploadBundleAndDisplayQr(tabId, state.origin, state.features, secrets.runId);
if (!ok) {
await failRun(tabId, state.origin, state.features, 'backend_unreachable', 'network');
}
}
/** pin_ttl expired (claude.md's phase_3 transitions). */
async function handlePinTtlExpiry(tabId: number): Promise<void> {
const state = await getTabState(tabId);
if (state.kind !== 'phase_3') return; // stale alarm — user already confirmed or aborted
await failRun(tabId, state.origin, state.features, 'pin_timeout', 'timeout_user');
}
chrome.alarms.onAlarm.addListener((alarm) => {
const [prefix, tabIdStr] = alarm.name.split(':');
const tabId = Number(tabIdStr);
if (prefix === QR_ALARM_PREFIX) void handleQrTtlExpiry(tabId);
else if (prefix === PIN_ALARM_PREFIX) void handlePinTtlExpiry(tabId);
});
async function handleKemCiphertext(tabId: number, origin: string, features: string[], payloadB64: string): Promise<void> {
const secrets = getRunSecrets(tabId);
if (!secrets) return; // run already ended (aborted/errored) — message arrived too late
// interfaces.md: "kem_ciphertext is valid only in phase_2 ... Messages of
// the wrong type are discarded." The companion proceeds independently of
// the extension's own pace once it reaches pin_display (mobile/claude.md),
// so a stray/duplicate message here is a real possibility, not just theory.
const state = await getTabState(tabId);
if (state.kind !== 'phase_2') return;
const bytes = base64UrlDecode(payloadB64);
const companionX25519Pub = bytes.slice(0, X25519_PUBKEY_BYTES);
const kemCiphertext = bytes.slice(X25519_PUBKEY_BYTES);
const x25519Shared = x25519SharedSecret(secrets.x25519.secretKey, companionX25519Pub);
const kemSharedSecret = mlKem768Decapsulate(kemCiphertext, secrets.kem.secretKey);
const runKey = await deriveRunKey(x25519Shared, kemSharedSecret, secrets.runId);
const pin = await derivePin(runKey);
setRunSecrets(tabId, { ...secrets, runKey });
chrome.alarms.clear(qrAlarmName(tabId));
schedulePinTtlAlarm(tabId, secrets.pinTtlSeconds);
await setTabState(tabId, { kind: 'phase_3', origin, features, pin, pinTtlSeconds: secrets.pinTtlSeconds, phaseStartedAt: Date.now() });
}
/** Decrypts and delivers a credential — only ever called once the user has confirmed the PIN. */
async function processCredential(tabId: number, origin: string, features: string[], payloadB64: string): Promise<void> {
const secrets = getRunSecrets(tabId);
if (!secrets?.runKey) return; // run already ended
let credential;
try {
credential = await decryptCredential(secrets.runKey, base64UrlDecode(payloadB64));
} catch {
await failRun(tabId, origin, features, 'relay_error', 'network'); // GCM auth failure — interfaces.md
return;
}
closeRelay(tabId);
clearRunSecrets(tabId);
await setTabState(tabId, { kind: 'delivered', origin, features });
sendToSdk(tabId, { type: 'run_delivered', credential });
setTimeout(() => {
void setTabState(tabId, { kind: 'idle', origin, features });
}, DELIVERED_DISPLAY_MS);
}
async function handleCredential(tabId: number, origin: string, features: string[], payloadB64: string): Promise<void> {
const secrets = getRunSecrets(tabId);
if (!secrets?.runKey) return; // run already ended, or kem_ciphertext hasn't landed yet
// interfaces.md: "credential [is valid] only in phase_4" — deliberately
// absolute. A credential that arrives before the user's own Confirm
// click is discarded, never held for later use — the alternative (queue
// it, apply it whenever confirm eventually happens) would decouple
// "the user confirmed" from "what they're confirming was actually
// waited on," which is exactly the invariant this gate exists to keep.
// If Confirm's click isn't reaching the background reliably, that's the
// bug to fix directly, not something to route around here.
const state = await getTabState(tabId);
if (state.kind !== 'phase_4') return;
await processCredential(tabId, origin, features, payloadB64);
}
/** Popup action: user tapped Confirm on the PIN screen (phase_3 -> phase_4). */
export async function confirmPin(tabId: number, origin: string, features: string[]): Promise<void> {
chrome.alarms.clear(pinAlarmName(tabId));
await setTabState(tabId, { kind: 'phase_4', origin, features });
// Unlocks the companion, which is gated on this arriving before it will
// proceed past its own local pin_display (interfaces.md, "PIN
// confirmation"). Fire-and-forget: this side's own phase_4 transition
// above is already the real local gate and doesn't depend on this call.
const runId = getRunSecrets(tabId)?.runId;
if (runId) void postPinConfirmation(runId);
}
/** Popup action: user tapped Abort at any run phase, or the SDK sent `abort`. */
export async function abortRun(tabId: number, origin: string, features: string[]): Promise<void> {
await failRun(tabId, origin, features, 'user_abort', 'timeout_user');
}
/** Popup action: user dismissed a run_error screen — clears back to idle. */
export async function dismissRunError(tabId: number, origin: string, features: string[]): Promise<void> {
await setTabState(tabId, { kind: 'idle', origin, features });
}
/** Tab closed mid-run (index.ts's chrome.tabs.onRemoved) — release everything a run held. */
export function cleanupRun(tabId: number): void {
closeRelay(tabId);
clearRunSecrets(tabId);
clearRunAlarms(tabId);
}
async function failRun(
tabId: number,
origin: string,
features: string[],
reason: RunErrorReason,
errorClass: RunErrorClass,
): Promise<void> {
closeRelay(tabId);
clearRunSecrets(tabId);
clearRunAlarms(tabId);
await setTabState(tabId, { kind: 'run_error', origin, features, reason, errorClass });
sendToSdk(tabId, { type: 'run_error', error: { code: 'RUN_FAILED', reason, security: errorClass === 'security' } });
}
+37
View File
@@ -0,0 +1,37 @@
// Tracks each tab's active SDK Port so the run state machine can push
// unsolicited lifecycle events (run_started, run_delivered, run_error) at
// arbitrary later times — not just as an immediate reply to a message, the
// way the verification slice's respond() was used.
import type { ExtensionToSdkMessage } from '../types.js';
const portsByTab = new Map<number, chrome.runtime.Port>();
export function registerSdkPort(tabId: number, port: chrome.runtime.Port): void {
portsByTab.set(tabId, port);
}
export function unregisterSdkPort(tabId: number, port: chrome.runtime.Port): void {
// Only clear if this is still the current port — a stale disconnect
// event for an old port must not clobber a newer connection.
if (portsByTab.get(tabId) === port) {
portsByTab.delete(tabId);
}
}
export function sendToSdk(tabId: number, message: ExtensionToSdkMessage): void {
const port = portsByTab.get(tabId);
if (!port) {
// Was silent before — logged now because a lost run_delivered/run_error
// is otherwise indistinguishable from "the site never called init()."
// A likely cause: the service worker was suspended and restarted
// between connect and now, which drops this in-memory Map.
console.warn(`[locqr] sendToSdk(${message.type}): no SDK port registered for tab ${tabId}`);
return;
}
try {
port.postMessage(message);
} catch (err) {
console.warn(`[locqr] sendToSdk(${message.type}): postMessage failed`, err);
}
}
+25
View File
@@ -0,0 +1,25 @@
// Per-tab verification state, held in chrome.storage.session
// (extension/claude.md, "Data storage": "Site verification result |
// chrome.storage.session | Browser session") — survives service worker
// suspension, cleared when the browser closes. Never chrome.storage.local:
// nothing here is meant to outlive the browser session.
import type { TabState } from '../types.js';
function storageKey(tabId: number): string {
return `tabState:${tabId}`;
}
export async function getTabState(tabId: number): Promise<TabState> {
const key = storageKey(tabId);
const stored = await chrome.storage.session.get(key);
return (stored[key] as TabState | undefined) ?? { kind: 'unverified' };
}
export async function setTabState(tabId: number, state: TabState): Promise<void> {
await chrome.storage.session.set({ [storageKey(tabId)]: state });
}
export async function clearTabState(tabId: number): Promise<void> {
await chrome.storage.session.remove(storageKey(tabId));
}
+111
View File
@@ -0,0 +1,111 @@
// Registration certificate verification — interfaces.md, "Registration
// certificate" / "Extension verification steps". Five checks, in the
// documented order; the first one to fail determines the outcome.
import { ml_dsa44 } from '@noble/post-quantum/ml-dsa.js';
import canonicalize from 'canonicalize';
import { base64UrlDecode } from '../base64url.js';
import { BACKEND_PUBLIC_KEY_B64 } from '../constants.js';
import type { CertInvalidReason } from '../types.js';
export interface CertVerified {
ok: true;
domain: string;
features: string[];
}
export interface CertRejected {
ok: false;
reason: CertInvalidReason;
security: boolean; // true for security-class reasons (extension/claude.md)
}
export type CertVerificationResult = CertVerified | CertRejected;
const SECURITY_CLASS_REASONS: ReadonlySet<CertInvalidReason> = new Set(['domain_mismatch', 'signature_invalid', 'malformed']);
function rejected(reason: CertInvalidReason): CertRejected {
return { ok: false, reason, security: SECURITY_CLASS_REASONS.has(reason) };
}
/**
* @param cert base64url-encoded envelope string, as passed to `locqr.init({ cert })`.
* @param originUrl the real page URL, read from `sender.tab.url` — never
* trust a URL supplied by the page itself.
*/
export function verifyRegistrationCert(cert: string, originUrl: string): CertVerificationResult {
// Step 1: HTTPS is checked before any cert logic runs at all — "no
// certificate is inspected, no backend call is made" (extension/claude.md).
//
// In practice this branch is currently unreachable through the SDK's
// Port: manifest.json's externally_connectable.matches is https-only
// (`https://test.locqr.dev/*`), so Chrome refuses the connection at the
// platform level before any `init` message can arrive — confirmed
// empirically (a plain-HTTP page's chrome.runtime.connect() never
// reaches the service worker at all; the SDK sees NOT_INSTALLED, not
// CERT_INVALID/insecure_origin). Kept anyway as real defense-in-depth
// per extension/claude.md's documented intent — e.g. if the match
// pattern were ever loosened to cover both schemes, this is what would
// still catch it.
let origin: URL;
try {
origin = new URL(originUrl);
} catch {
return rejected('malformed');
}
if (origin.protocol !== 'https:') {
return rejected('insecure_origin');
}
// Step 2: decode and parse the envelope.
let envelope: Record<string, unknown>;
try {
const bytes = base64UrlDecode(cert);
envelope = JSON.parse(new TextDecoder().decode(bytes));
} catch {
return rejected('malformed');
}
const { sig, ...payload } = envelope;
if (
typeof sig !== 'string' ||
typeof payload.v !== 'number' ||
typeof payload.domain !== 'string' ||
typeof payload.issued_at !== 'number' ||
typeof payload.expires_at !== 'number' ||
!Array.isArray(payload.features)
) {
return rejected('malformed');
}
// Step 3: signature, over the JCS-canonicalized payload (sig excluded).
let signatureValid: boolean;
try {
const canonical = canonicalize(payload);
const message = new TextEncoder().encode(canonical as string);
const signature = base64UrlDecode(sig);
const publicKey = base64UrlDecode(BACKEND_PUBLIC_KEY_B64);
signatureValid = ml_dsa44.verify(signature, message, publicKey);
} catch {
return rejected('malformed');
}
if (!signatureValid) {
return rejected('signature_invalid');
}
// Step 4: validity window.
const now = Math.floor(Date.now() / 1000);
if (now < payload.issued_at) {
return rejected('not_yet_valid');
}
if (now > payload.expires_at) {
return rejected('expired');
}
// Step 5: domain match. Subdomains are not implicitly covered.
if (payload.domain !== origin.hostname) {
return rejected('domain_mismatch');
}
return { ok: true, domain: payload.domain, features: payload.features as string[] };
}
+26
View File
@@ -0,0 +1,26 @@
// base64url (RFC 4648 §5), no padding — interfaces.md's shared conventions,
// "shared conventions" table.
//
// Padding must be restored before atob() — an unpadded string silently
// mis-decodes its tail rather than throwing (found the hard way during the
// Step 0 spike: a truncated cert string decoded to valid-looking base64 but
// corrupted JSON, with no error until JSON.parse on the *decoded* result).
export function base64UrlDecode(s: string): Uint8Array {
const unpadded = s.replace(/-/g, '+').replace(/_/g, '/');
const padded = unpadded + '='.repeat((4 - (unpadded.length % 4)) % 4);
const binary = atob(padded);
const bytes = new Uint8Array(binary.length);
for (let i = 0; i < binary.length; i++) {
bytes[i] = binary.charCodeAt(i);
}
return bytes;
}
export function base64UrlEncode(bytes: Uint8Array): string {
let binary = '';
for (const byte of bytes) {
binary += String.fromCharCode(byte);
}
return btoa(binary).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
}
+15
View File
@@ -0,0 +1,15 @@
// Compile-time pinned constants (extension/claude.md). Any key material
// received at runtime that does not match these is rejected before
// verification runs. Real dev values from dev/keys/ — hand-set for this
// slice; scripts/setup-dev.js's constant-patching automation is a
// documented fast-follow once this pattern is proven (see dev.md).
//
// Regenerating dev keys requires updating both of these and rebuilding.
/** ML-DSA-44 — verifies domain registration certificates (crypto.md). */
export const BACKEND_PUBLIC_KEY_B64 =
'VkwMOKMIP1wRds9rvkfothm_h_YVMND-nZW2hhGlhTrkapzOcmV2WkhELuGdDnzb7dn40I89r1nh53s3NOXRHK9Cg0SoWmh3KvDCOCrZcy67lizJ2YfNbc6-8mwRzmSWzBUt2nw3eqjoxYHWsDj4RT_OYBO7iExgzdumQkXxox8-QxHdg6lrFzDjtmyf3xNlI85x2WXHqISh9QZ8Hh7RzHuL9kJ0_n8jkP83SJYU0priPyPmxYjG7sjzikXNRsoW4nYmRhkY4LuD1ygzuHS3ZV90pjN_Id8ttLEUT3RAdMvlk_mUiG4le3oxwrhoypfeOECq80olooMcrnZJSD_m3PyDbuxIPstVrrQraLp-IgHNPameWATyr22c_-AI2qtdK6aVWVb-W9D7x8hooEQV2TQLXzKSxzpwpcey3-T1PWb0cwICCjq3MbBA9yCcwqeCjCG-FY2Vu4HQCIWPyJDB-5RAjVmyKntNX4v1ska7aXlNYj5mUYY5vSQRYfW4oY7eSARoeLpueEkoEPeKgRAFK0_MqafkDLgXTVx9ZGYN0QTQwfwTjoPi3BRHcJDMsILvD65E9jrKx6Bc5aaPlux9naMGSwRtKRIteEjfqKXcZ8Dtm-MGbNNoAiDHqkqsROa-DST9WNOY57SHZF2uXc7ZbXixXbcuj6lN_vrB0pl1BaiNQzoxciePbgvocUNQHa9Jqhs-D5NIdrK4BGaBItYoeD2WdynfMnE9wttXDin5LJyU5zqQksWhxYIM4LPd4I2_Fiqpw8EdYuIgipfwWZiTDjDu9SsLt9kwkyjADdVTWYiB_AvNPqmniJyTTYJNhPWxbZ2fLDRsRNNq55pZf2PhRQiaBX_-6KKVUgir3DfJf7WFS9FnDYLtBRwc7cobagmtwH6QMzN2uEuqpTmyNBP6N7_2SD6LBvBlQ1f9qdQMb63q_waoPJ76OQOOQa1qQ3wfFCaGbZm1N_61uGpxPENLv2ZczBIRiViPcpPDHxDLGy4nYlDQ7Uk3yhD-urFGO63LnHrG69dDDrMc38-xT6Aaq5J6tx7qp20Ggao5O-gJckHKkfCsFNllelu_BmZIqRjrBR6tJYeZBKFuFO34BaUlxoG8AYk9eza5lsJzgjobL89Ngn9r-GqeRSMEBZw-YIwIx8Bn-yy3PCZcROkXqCSXlJ-9cc7z2dcbMg1Sg0nWGW_i73CGoGSl2eLjVJBpTWfnWvDPVLL6EjlPlfSlguw1xlQkxpW2f6MdAdpA9kwew389x058NLrgig2gIRL0Xu565zaC6KVUUd3cf-isnpByffZbKRn1kTspJaXTUXIV_0g_qJ12qaiK5LKqbQ77TJ16cheC5z_h6Ig5hoBXCgEplmYKE5rbBkvqjeSpWemciQx6kMySUygNjOmYAzTk5atOgYUgw5aLx2d_9AYDq4zu0MczLOiVzfLIe2Qon3Ng2BtzPx0PJMqnI9elxdAmDVJNkew3RuQE_vuJbBL2Dw0jYDzkYBuCcLLSUmbshfe6P8IJwjT115DDxzRXK634EHkh1fNWLcAa4GtyGywHXlM4IrwrsENHSGbpG5ONp4vJBCgackRjuQhBRZXLmOqmTj27n_OiUqH2VKIm4ZyFWeBBaXXeXEyhjtUsN16CkaaNFciuCwmcYO-v95g2TK9-lw9wHOF9TQfq3US4iSO48RNMX8H-yLgq_6iSvgD2hU_V-oKeui0UoXEZiI-42Dv3fm5XCvgknubie78x3JdDm8CXQw';
/** Ed25519 — verifies key exchange tokens (crypto.md). Not used by this slice's
* verification-only logic; compiled in now since claude.md pins both together. */
export const ED25519_PUBLIC_KEY_B64 = 'Z9ppr33AB5gznf-mQU2F9Y3E-MEoNcGHtmlh7rzaTh4';
+196
View File
@@ -0,0 +1,196 @@
/* Design tokens from gui.md — same values used throughout the mockups
built and approved earlier (QR/PIN, error/security, status, ambient). */
:root {
--card-bg: #ffffff;
--card-border: rgba(15, 23, 42, 0.08);
--text-primary: #0f172a;
--text-secondary: #667085;
--text-tertiary: #94a3b8;
--accent: #2f6fed;
--accent-hover: #2559c9;
--accent-tint: #e9f0fe;
--accent-track: #e2e8f0;
--box-border: #d7dce4;
--box-bg: #f8fafc;
--divider: rgba(15, 23, 42, 0.07);
--ghost-hover: rgba(15, 23, 42, 0.04);
--btn-border: #d7dce4;
--neutral-badge: #94a3b8;
--neutral-tint: #eef1f4;
--inactive-badge: #cbd5e1;
--inactive-tint: #f4f6f8;
--amber: #f59e0b;
--amber-tint: #fef3e2;
--red: #dc2626;
--red-tint: #fdecec;
--green: #16a34a;
--green-tint: #e8f6ec;
}
@media (prefers-color-scheme: dark) {
:root {
--card-bg: #12161f;
--card-border: rgba(255, 255, 255, 0.08);
--text-primary: #f1f5f9;
--text-secondary: #94a3b8;
--text-tertiary: #64748b;
--accent: #5b8bff;
--accent-hover: #7fa2ff;
--accent-tint: rgba(91, 139, 255, 0.14);
--accent-track: #232a38;
--box-border: #2a3140;
--box-bg: #171c26;
--divider: rgba(255, 255, 255, 0.08);
--ghost-hover: rgba(255, 255, 255, 0.06);
--btn-border: #2a3140;
--neutral-badge: #64748b;
--neutral-tint: rgba(100, 116, 139, 0.16);
--inactive-badge: #475569;
--inactive-tint: rgba(71, 85, 105, 0.16);
--amber: #fbbf24;
--amber-tint: rgba(251, 191, 36, 0.12);
--red: #ef4444;
--red-tint: rgba(239, 68, 68, 0.12);
--green: #22c55e;
--green-tint: rgba(34, 197, 94, 0.14);
}
}
* { box-sizing: border-box; }
html, body {
margin: 0;
width: 300px;
}
body {
background: var(--card-bg);
color: var(--text-primary);
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}
.card-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 14px 16px;
border-bottom: 1px solid var(--divider);
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand .mark { width: 20px; height: 20px; border-radius: 6px; background: var(--accent); }
.brand .word { font-weight: 700; font-size: 14.5px; letter-spacing: -0.01em; color: var(--text-primary); }
.origin { font-size: 12.5px; color: var(--text-tertiary); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-body {
padding: 28px 20px 22px;
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
/* Chrome sizes a popup's window once, from its content height at first
paint, and does not reliably resize it as innerHTML later changes
(confirmed the hard way: a popup opened during a short state like
idle stayed that size through phase_2/3, leaving the real buttons
below the window's actual clickable bounds — clicking them landed
"outside" the popup and closed it). Sized for phase_2's QR screen
(the tallest: 260px canvas + countdown + caption + action ≈ 416px),
so every state gets the same window size regardless of which one is
showing when the popup first opens. */
min-height: 420px;
justify-content: center;
}
.status-badge {
width: 48px;
height: 48px;
border-radius: 13px;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 16px;
flex-shrink: 0;
}
.status-badge svg { width: 22px; height: 22px; }
.pulse { animation: locqr-pulse 1.6s ease-in-out infinite; }
@keyframes locqr-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.spinner { animation: locqr-spin 1.1s linear infinite; }
@keyframes locqr-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
.pulse, .spinner { animation: none; }
}
.status-heading { font-size: 14.5px; font-weight: 650; color: var(--text-primary); margin-bottom: 6px; }
.status-heading.security { color: var(--red); }
.status-body { font-size: 12.5px; line-height: 1.55; color: var(--text-secondary); max-width: 230px; }
.actions { width: 100%; margin-top: 20px; display: flex; flex-direction: column; gap: 8px; }
.btn-primary {
width: 100%;
padding: 10px 0;
border: none;
border-radius: 10px;
background: var(--accent);
color: #fff;
font-size: 14px;
font-weight: 600;
cursor: pointer;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.btn-ghost {
width: 100%;
padding: 8px 0;
border: none;
background: none;
color: var(--text-secondary);
font-size: 13px;
font-weight: 600;
cursor: pointer;
border-radius: 8px;
}
.btn-ghost:hover { background: var(--ghost-hover); }
.status-note { font-size: 12.5px; color: var(--text-tertiary); margin-top: 14px; }
.ring-spinner {
width: 22px;
height: 22px;
border: 2.4px solid var(--accent-tint);
border-top-color: var(--accent);
border-radius: 50%;
}
.countdown-bar {
width: 100%;
height: 4px;
border-radius: 999px;
background: var(--accent-track);
overflow: hidden;
margin: 16px 0 14px;
}
.countdown-fill {
height: 100%;
width: 100%;
background: var(--accent);
border-radius: 999px;
transition: width 0.2s linear;
}
.qr-canvas { width: 260px; height: 260px; display: block; }
.pin-groups { display: flex; gap: 18px; }
.pin-group { display: flex; gap: 6px; }
.pin-digit {
width: 42px;
height: 50px;
border: 1.5px solid var(--box-border);
background: var(--box-bg);
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
font-family: "SF Mono", "Menlo", "Consolas", monospace;
font-size: 21px;
font-weight: 650;
color: var(--text-primary);
}
+19
View File
@@ -0,0 +1,19 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>locqr</title>
<link rel="stylesheet" href="popup.css" />
</head>
<body>
<div class="card-header">
<div class="brand">
<div class="mark"></div>
<div class="word">locqr</div>
</div>
<div class="origin" id="origin"></div>
</div>
<div class="card-body" id="body"></div>
<script type="module" src="popup.js"></script>
</body>
</html>
+356
View File
@@ -0,0 +1,356 @@
// Popup UI — renders the active tab's verification and run state. Markup/CSS
// ported from the gui.md mockups built and approved earlier this session
// (ambient, error/security, status, QR/PIN screens).
import { create as createQrCode } from 'qrcode';
import { getTabState } from '../background/state.js';
import type { CertInvalidReason, PopupActionKind, PopupActionMessage, RunErrorClass, RunErrorReason, TabState } from '../types.js';
interface ActionSpec {
label: string;
kind: PopupActionKind;
style: 'primary' | 'ghost';
}
interface Content {
badgeClass: string; // tint background var
iconColor: string; // stroke/fill color var
glyph: 'dot' | 'dash' | 'check' | 'exclaim' | 'shield' | 'spinner';
pulse?: boolean;
heading: string;
headingSecurity?: boolean;
body: string;
note?: string;
actions?: ActionSpec[];
}
function originText(url: string | undefined): string {
if (!url) return '';
try {
return new URL(url).hostname;
} catch {
return '';
}
}
const RUN_ERROR_COPY: Record<RunErrorReason, { heading: string; body: string }> = {
ttl_exhausted: { heading: 'Code expired', body: 'This sign-in code expired before it was used.' },
pin_timeout: { heading: 'Timed out', body: "The code wasn't confirmed in time, so this sign-in attempt was cancelled." },
user_abort: { heading: 'Sign-in cancelled', body: 'You cancelled this sign-in attempt.' },
backend_unreachable: {
heading: "Can't reach LOCQR",
body: "We couldn't reach the LOCQR server. Check your connection and try again.",
},
relay_timeout: { heading: 'No response', body: "Your phone didn't respond in time." },
relay_error: { heading: 'Something went wrong', body: "We couldn't finish signing you in. Please try again." },
};
function runErrorContent(reason: RunErrorReason, errorClass: RunErrorClass): Content {
const { heading, body } = RUN_ERROR_COPY[reason];
if (errorClass === 'security') {
return {
badgeClass: 'red-tint',
iconColor: 'red',
glyph: 'shield',
heading,
headingSecurity: true,
body,
actions: [{ label: 'Dismiss', kind: 'dismiss', style: 'ghost' }],
};
}
return {
badgeClass: 'amber-tint',
iconColor: 'amber',
glyph: 'exclaim',
heading,
body,
actions: [
{ label: 'Retry', kind: 'retry', style: 'primary' },
{ label: 'Dismiss', kind: 'dismiss', style: 'ghost' },
],
};
}
function contentFor(state: TabState, origin: string): Content {
switch (state.kind) {
case 'unverified':
return {
badgeClass: 'neutral-tint',
iconColor: 'neutral-badge',
glyph: 'dot',
pulse: true,
heading: 'Checking…',
body: 'Looking for LOCQR sign-in support on this page.',
};
case 'not_registered':
return {
badgeClass: 'inactive-tint',
iconColor: 'inactive-badge',
glyph: 'dash',
heading: 'Not available here',
body: origin ? `${origin} hasn't set up sign-in with LOCQR.` : "This site hasn't set up sign-in with LOCQR.",
};
case 'idle':
return {
badgeClass: 'accent-tint',
iconColor: 'accent',
glyph: 'check',
heading: 'Ready to sign in',
body: `${state.origin} supports secure sign-in with LOCQR.`,
actions: [{ label: 'Sign in', kind: 'start_run', style: 'primary' }],
};
case 'account_error':
return state.reason === 'unreachable'
? {
badgeClass: 'amber-tint',
iconColor: 'amber',
glyph: 'exclaim',
heading: "Can't reach LOCQR",
body: "We couldn't reach the LOCQR server. Check your connection and try again.",
}
: {
badgeClass: 'amber-tint',
iconColor: 'amber',
glyph: 'exclaim',
heading: 'Account inactive',
body: 'Sign-in is currently unavailable for this site.',
};
case 'cert_invalid':
return certInvalidContent(state.reason, state.security, origin);
case 'phase_1':
return {
badgeClass: 'accent-tint',
iconColor: 'accent',
glyph: 'spinner',
heading: 'Connecting…',
body: 'Setting up a secure connection to your phone.',
actions: [{ label: 'Cancel', kind: 'abort', style: 'ghost' }],
};
case 'phase_4':
return {
badgeClass: 'accent-tint',
iconColor: 'accent',
glyph: 'spinner',
heading: 'Almost done…',
body: 'Waiting for your phone to finish sending your sign-in details.',
actions: [{ label: 'Cancel', kind: 'abort', style: 'ghost' }],
};
case 'delivered':
return {
badgeClass: 'green-tint',
iconColor: 'green',
glyph: 'check',
heading: 'Signed in',
body: `You're securely signed in to ${state.origin}.`,
note: 'Closing automatically…',
};
case 'run_error':
return runErrorContent(state.reason, state.errorClass);
case 'phase_2':
case 'phase_3':
// Rendered by their own dedicated templates in render() — never
// reaches the generic status content builder.
throw new Error(`contentFor called for ${state.kind}, which has its own template`);
}
}
function certInvalidContent(reason: CertInvalidReason, security: boolean, origin: string): Content {
if (security) {
const body: Record<string, string> = {
domain_mismatch: "This page's certificate doesn't match its domain. This site may be impersonating a registered LOCQR site.",
signature_invalid: "This site's LOCQR certificate failed a signature check.",
malformed: "This site's LOCQR certificate could not be read.",
};
return {
badgeClass: 'red-tint',
iconColor: 'red',
glyph: 'shield',
heading: 'Security warning',
headingSecurity: true,
body: body[reason] ?? "This site's LOCQR certificate failed a security check.",
};
}
const copy: Record<string, { heading: string; body: string }> = {
insecure_origin: { heading: "Connection isn't secure", body: 'LOCQR requires a secure (https) connection.' },
expired: { heading: 'Certificate expired', body: "This site's LOCQR certificate needs to be renewed by its owner." },
not_yet_valid: { heading: 'Certificate not active yet', body: "This site's LOCQR certificate isn't valid yet." },
};
const { heading, body } = copy[reason] ?? {
heading: 'Certificate error',
body: origin ? `${origin}'s LOCQR certificate has a problem.` : 'This site’s LOCQR certificate has a problem.',
};
return { badgeClass: 'amber-tint', iconColor: 'amber', glyph: 'exclaim', heading, body };
}
const GLYPHS: Record<Exclude<Content['glyph'], 'spinner'>, (color: string) => string> = {
dot: (c) => `<svg viewBox="0 0 24 24" fill="none" stroke="var(--${c})" stroke-width="2.4" stroke-linecap="round"><circle cx="12" cy="12" r="2.6" fill="var(--${c})" stroke="none"/></svg>`,
dash: (c) => `<svg viewBox="0 0 24 24" fill="none" stroke="var(--${c})" stroke-width="2.4" stroke-linecap="round"><line x1="7" y1="12" x2="17" y2="12"/></svg>`,
check: (c) => `<svg viewBox="0 0 24 24" fill="none" stroke="var(--${c})" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 12 9 17 20 6"/></svg>`,
exclaim: (c) => `<svg viewBox="0 0 24 24" fill="none" stroke="var(--${c})" stroke-width="2.2" stroke-linecap="round"><line x1="12" y1="7" x2="12" y2="13.5"/><circle cx="12" cy="17" r="0.6" fill="var(--${c})" stroke="none"/></svg>`,
shield: (c) => `<svg viewBox="0 0 24 24" fill="none" stroke="var(--${c})" stroke-width="1.8" stroke-linejoin="round"><path d="M12 3.5 19 6.3v5.2c0 4.4-3 7.6-7 8.9-4-1.3-7-4.5-7-8.9V6.3z"/><line x1="12" y1="9" x2="12" y2="13" stroke-width="2" stroke-linecap="round"/><circle cx="12" cy="15.6" r="0.6" fill="var(--${c})" stroke="none"/></svg>`,
};
function badgeHtml(c: Content): string {
const inner = c.glyph === 'spinner' ? `<div class="ring-spinner spinner"></div>` : GLYPHS[c.glyph](c.iconColor);
return `<div class="status-badge ${c.pulse ? 'pulse' : ''}" style="background: var(--${c.badgeClass})">${inner}</div>`;
}
function actionsHtml(actions: ActionSpec[] | undefined): string {
if (!actions?.length) return '';
const buttons = actions
.map((a) => `<button class="${a.style === 'primary' ? 'btn-primary' : 'btn-ghost'}" data-action="${a.kind}">${a.label}</button>`)
.join('');
return `<div class="actions">${buttons}</div>`;
}
function qrScreenHtml(): string {
return `
<canvas id="qr-canvas" class="qr-canvas"></canvas>
<div class="countdown-bar"><div class="countdown-fill" id="countdown-fill"></div></div>
<div class="status-body">Scan with the companion app.</div>
<div class="actions"><button class="btn-ghost" data-action="abort">Abort</button></div>
`;
}
function pinScreenHtml(pin: string): string {
const digit = (d: string) => `<div class="pin-digit">${d}</div>`;
const digits = pin.split('');
return `
<div class="pin-groups">
<div class="pin-group">${digits.slice(0, 3).map(digit).join('')}</div>
<div class="pin-group">${digits.slice(3, 6).map(digit).join('')}</div>
</div>
<div class="countdown-bar"><div class="countdown-fill" id="countdown-fill"></div></div>
<div class="status-body">Confirm this code matches your companion app.</div>
<div class="actions">
<button class="btn-primary" data-action="confirm_pin">Confirm</button>
<button class="btn-ghost" data-action="abort">Abort</button>
</div>
`;
}
/**
* Draws the raw QR module matrix onto a canvas by hand (gui.md: not the
* qrcode package's own renderer) so the light/dark colorways can differ in
* quiet-zone treatment — the dark colorway uses the card's own padding as
* its margin instead of baking one into the raster (gui.md, "Phase 2 — QR").
*/
function renderQr(canvas: HTMLCanvasElement, content: string): void {
const isDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
const qr = createQrCode(content, { errorCorrectionLevel: 'M' });
const size = qr.modules.size;
const data = qr.modules.data;
// Fills the card body's actual content width (300px popup − 20px
// padding × 2) so the QR's outer edge lines up with the countdown bar's
// edge below it — no extra margin beyond the shared 20px card padding.
const displayPx = 260;
const marginModules = isDark ? 0 : 4;
const modulePx = displayPx / (size + marginModules * 2);
canvas.width = displayPx;
canvas.height = displayPx;
const ctx = canvas.getContext('2d');
if (!ctx) return;
ctx.fillStyle = isDark ? getComputedStyle(document.documentElement).getPropertyValue('--card-bg').trim() : '#ffffff';
ctx.fillRect(0, 0, displayPx, displayPx);
ctx.fillStyle = isDark ? '#ffffff' : '#1a1a1a';
for (let row = 0; row < size; row++) {
for (let col = 0; col < size; col++) {
if (!data[row * size + col]) continue;
const x = (col + marginModules) * modulePx;
const y = (row + marginModules) * modulePx;
ctx.fillRect(x, y, Math.ceil(modulePx), Math.ceil(modulePx));
}
}
}
let countdownTimer: ReturnType<typeof setInterval> | undefined;
function stopCountdown(): void {
if (countdownTimer !== undefined) {
clearInterval(countdownTimer);
countdownTimer = undefined;
}
}
/** Countdown bar fill — driven by the server-issued TTL, never a local default (claude.md). */
function startCountdown(phaseStartedAt: number, ttlSeconds: number): void {
const fill = document.getElementById('countdown-fill');
if (!fill) return;
const update = () => {
const elapsedSeconds = (Date.now() - phaseStartedAt) / 1000;
const remaining = Math.max(0, Math.min(1, 1 - elapsedSeconds / ttlSeconds));
fill.style.width = `${remaining * 100}%`;
if (remaining <= 0) stopCountdown();
};
update();
countdownTimer = setInterval(update, 200);
}
function sendPopupAction(tabId: number | undefined, action: PopupActionKind): void {
if (tabId === undefined) return;
const message: PopupActionMessage = { type: 'popup_action', tabId, action };
void chrome.runtime.sendMessage(message);
}
function wireActions(tabId: number | undefined): void {
document.querySelectorAll<HTMLButtonElement>('#body button[data-action]').forEach((btn) => {
const action = btn.dataset.action as PopupActionKind;
btn.addEventListener('click', () => sendPopupAction(tabId, action));
});
}
function render(state: TabState, origin: string, tabId: number | undefined): void {
document.getElementById('origin')!.textContent = origin;
stopCountdown();
const body = document.getElementById('body')!;
if (state.kind === 'phase_2') {
body.innerHTML = qrScreenHtml();
renderQr(document.getElementById('qr-canvas') as HTMLCanvasElement, state.qrContent);
startCountdown(state.phaseStartedAt, state.qrTtlSeconds);
wireActions(tabId);
return;
}
if (state.kind === 'phase_3') {
body.innerHTML = pinScreenHtml(state.pin);
startCountdown(state.phaseStartedAt, state.pinTtlSeconds);
wireActions(tabId);
return;
}
const c = contentFor(state, origin);
body.innerHTML = `
${badgeHtml(c)}
<div class="status-heading${c.headingSecurity ? ' security' : ''}">${c.heading}</div>
<div class="status-body">${c.body}</div>
${actionsHtml(c.actions)}
${c.note ? `<div class="status-note">${c.note}</div>` : ''}
`;
wireActions(tabId);
}
async function activeTab(): Promise<chrome.tabs.Tab | undefined> {
const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
return tab;
}
async function refresh(): Promise<void> {
const tab = await activeTab();
const origin = originText(tab?.url);
const state = tab?.id === undefined ? ({ kind: 'unverified' } as const) : await getTabState(tab.id);
render(state, origin, tab?.id);
}
chrome.storage.onChanged.addListener((_changes, areaName) => {
if (areaName === 'session') void refresh();
});
void refresh();
+158
View File
@@ -0,0 +1,158 @@
// Shared types. Port message shapes mirror interfaces.md exactly — including
// its naming note: Port `type` values are snake_case; the SDK translates
// these into the colon-separated `locqr.on()` event names. This file is the
// extension side only, so it stays in the Port's own snake_case vocabulary.
export type LocqrErrorCode = 'NOT_INSTALLED' | 'NOT_REGISTERED' | 'CERT_INVALID' | 'ACCOUNT_ERROR' | 'RUN_FAILED';
export interface LocqrError {
code: LocqrErrorCode;
reason?: string;
security?: boolean;
}
// --- SDK -> Extension ---
export interface InitMessage {
type: 'init';
cert?: string;
}
export interface RequestCredentialMessage {
type: 'request_credential';
}
export interface AbortMessage {
type: 'abort';
}
export type SdkMessage = InitMessage | RequestCredentialMessage | AbortMessage;
// --- Extension -> SDK ---
export interface VerificationValidMessage {
type: 'verification';
status: 'valid';
features: string[];
}
export interface VerificationErrorMessage {
type: 'verification';
status: 'error';
error: LocqrError;
}
export type VerificationMessage = VerificationValidMessage | VerificationErrorMessage;
// --- Run lifecycle events, extension -> SDK (unsolicited) ---
export interface Credential {
username: string;
password: string;
}
export interface RunStartedMessage {
type: 'run_started';
}
export interface RunDeliveredMessage {
type: 'run_delivered';
credential: Credential;
}
export interface RunErrorEventMessage {
type: 'run_error';
error: LocqrError;
}
export type ExtensionToSdkMessage = VerificationMessage | RunStartedMessage | RunDeliveredMessage | RunErrorEventMessage;
// --- Popup -> Background (internal chrome.runtime.sendMessage, distinct
// from the external SDK Port — these never cross to the page). ---
export type PopupActionKind = 'start_run' | 'confirm_pin' | 'abort' | 'retry' | 'dismiss';
export interface PopupActionMessage {
type: 'popup_action';
tabId: number;
action: PopupActionKind;
}
// --- Relay messages (interfaces.md, "Relay messages") ---
export interface RelayKemCiphertextMessage {
type: 'kem_ciphertext';
payload_b64: string;
}
export interface RelayCredentialMessage {
type: 'credential';
payload_b64: string;
}
export type RelayMessage = RelayKemCiphertextMessage | RelayCredentialMessage;
// --- Run bundle upload (interfaces.md, "Run bundle upload") ---
export interface RunBundleUploadRequest {
runId: string;
origin: string;
x25519_pubkey: string;
kem_pubkey: string;
}
export interface RunBundleUploadResponse {
signed_token: string;
qr_ttl: number;
max_auto_refresh: number;
pin_ttl: number;
}
// --- Per-tab state (extension/claude.md's state model) ---
export type CertInvalidReason =
| 'insecure_origin'
| 'malformed'
| 'signature_invalid'
| 'domain_mismatch'
| 'expired'
| 'not_yet_valid';
export type AccountErrorReason = 'rejected' | 'unreachable';
/**
* Per extension/claude.md's `run_error` classes — `alpha_hash_mismatch` and
* `pin_mismatch` deliberately excluded (companion-only detections, see that
* file's `run_error` note). Only `user_abort` is wired up by any code path
* in this slice; the rest are real and specified but deferred to a
* follow-up hardening pass (see gui.md's "Open / not yet specified" — same
* pattern).
*/
export type RunErrorReason = 'ttl_exhausted' | 'pin_timeout' | 'user_abort' | 'backend_unreachable' | 'relay_timeout' | 'relay_error';
export type RunErrorClass = 'security' | 'timeout_user' | 'network';
/**
* This union (run-phase variants included) is stored in chrome.storage.session
* for popup reactivity, same mechanism as the verification states — but it
* only ever carries display-safe data: QR content and PIN digits are
* already what's shown on screen / scanned by a camera, not secret. The
* actual keypairs, shared secrets, and run key are a *different* thing —
* they live only in background/run-secrets.ts's in-memory map and are never
* serialized anywhere, matching the security invariant that private key
* material never leaves the service worker (extension/claude.md's Data
* storage table lists these separately from "Per-tab state machine state"
* for exactly this reason).
*/
export type TabState =
| { kind: 'unverified' }
| { kind: 'not_registered' }
| { kind: 'cert_invalid'; reason: CertInvalidReason; security: boolean }
| { kind: 'account_error'; reason: AccountErrorReason }
| { kind: 'idle'; origin: string; features: string[] }
| { kind: 'phase_1'; origin: string; features: string[] }
| { kind: 'phase_2'; origin: string; features: string[]; qrContent: string; qrTtlSeconds: number; phaseStartedAt: number }
| { kind: 'phase_3'; origin: string; features: string[]; pin: string; pinTtlSeconds: number; phaseStartedAt: number }
| { kind: 'phase_4'; origin: string; features: string[] }
| { kind: 'delivered'; origin: string; features: string[] }
| { kind: 'run_error'; origin: string; features: string[]; reason: RunErrorReason; errorClass: RunErrorClass };
+14
View File
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"target": "ES2022",
"lib": ["ES2022", "WebWorker", "DOM"],
"module": "ESNext",
"moduleResolution": "Bundler",
"strict": true,
"noUncheckedIndexedAccess": true,
"skipLibCheck": true,
"types": ["chrome"],
"noEmit": true
},
"include": ["src"]
}