Repository navigation
feat(shared): add the join line of the account's signed list - #4103
Conversation
A join line is the one line a machine pastes to join an account: the account service's origin, the list id and an invite's private key. shared/account-list-join.ts writes the line and reads it strictly: one spelling only, checked by writing it again from what was read, and a refusal never repeats any part of the line. JSON test vectors cover the good line and each way a line can be wrong, so another implementation can check itself against them. Nothing in the server or the app calls it yet.
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
Adversarial review: Codex
|
|
Merged through Merged on the maintainer's word, as the first merge through |
## What
Rewrites the "who merges" rules in AGENTS.md for how merging works since
2026-11-18: no standing merge pass; the session that opens a PR merges
it through `pr-merge`, the gate script beside the gh merge guard on the
maintainer's PC.
- **Who merges.** A session merges its own PR once it is ready, with
`pr-merge <PR>`. The script reads GitHub's required checks at the head,
the review threads, the `hold` label, CodeRabbit's review of that head,
`main`'s last finished CI run and the Release runs, merges pinned to the
head and never passes `--admin`.
- **What waits for the maintainer's word.** A release, the README, a UI
change he has not seen, an HTTP/WS contract, a workflow change that
removes or weakens a check, an outside contributor's feature or docs PR,
and a PR he tests himself. The list was in the merge pass's own notes
until now.
- **Holds.** A PR that must not merge yet carries the `hold` label and a
comment saying why. The 20 open PRs the pass held have the label since
today.
- **Threads.** Branch protection now refuses a merge with an unresolved
review thread ("require conversation resolution" is on since today), so
the sentence saying it does not is corrected.
- **Reviews.** Unchanged: a PR touching a sensitive area waits for a
real review. Added: `pr-merge` asks for `--note` naming the reviews in
that case, when CodeRabbit did not review the head, and for an outside
contributor's PR.
## Removed, to decide at review
The two paragraphs on the **local merge gate** (a run in the CI runner
image on this PC, then a merge with `--admin` instead of waiting for
GitHub's checks) are deleted: `pr-merge` has no such path. If that
shortcut should stay, it needs a paragraph of its own and a way into
`pr-merge`.
This PR also sets the default that a session merges its own ready PR
**without asking**, apart from the list above. If the default should be
"only on the maintainer's word", the first bullet changes by one clause.
## Validation
- `bun run check fast`: green (unit: 18,659 pass, 0 fail). Docs only;
nothing else run.
- `pr-merge` merged #4103 today, its first merge; the guard let it
through and logged it.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Fable 5.2 <[email protected]>
…nge key, and keep crypto faults apart (#4116) Follow-up to #4103. Refs #3996 ## Change Fixes what the two reviews of #4103 found in `shared/account-list-join.ts`. Nothing in the app calls this library yet. - A crypto fault is no longer a malformed line: importing the secret and signing the probe are separate steps, and only the runtime's `DataError` on import refuses the secret. Any other WebCrypto error goes up as it came. - A line has a protocol maximum, `JOIN_LINE_MAX_CHARS` = 1024 characters: the fixed members with room for any origin a DNS name spells. The reader refuses a longer paste with the new reason `length` before it decodes or parses any of it. The writer refuses a service too long for such a line (more than 469 characters) before it parses it, exports the key or encodes anything, and also measures the line it built: a shorter origin can still overflow once JSON escapes it (a host may hold `"`). A secret that is not exactly 184 characters is refused before it is decoded. - A secret in its form whose 32-byte private value is 0, or at or above the curve order n, is refused with the new reason `scalar` before any runtime is asked to import it. The writer applies the same check to the key it exports. - Tests: - Every refusal in the file, of the reader and of the writer, is checked: no 12-character window of the payload, each secret, service and list decoded from a line given to the reader, the fixture keys, the key's exported private value `d`, or the service and list given to the writer may show in its name, message, stack or fields, and it carries only its code, name and reason. This covers the `length` and `scalar` refusals too. - The writer refuses a key whose JWK parts are not 32 bytes each in their one spelling (a short or long `d`, an `x` in a second spelling, no `y`, a public key) as `secret`. - Keys whose private value is 1 or n-1, the ends of the valid range, are written, read back to their own public key and sign. The writer's early bound is also tested with a long `http://` service, which it must refuse as `length` before it parses it. - New tests cover the two guards above (no WebCrypto, WebCrypto's own faults). - The writer refuses a key whose export names another type or curve even when its parts are 32 bytes each, so the curve check has a test of its own (a P-384 key was already refused by its 48-byte parts). - The vector test asserts the complete set of 28 names, so a vector removed is a failure. - The writer tests keep the byte-for-byte check against the vector and the protocol layout, but no longer require the runtime's own PKCS8 export: they pass with a runtime that exports another legal form of the same key. That form is built from the key's own `d`, so the tests hold also where the native export already is that form. No vector was added or changed. ## Validation Each new test failed before its fix: - Line bound, reader: `(fail) a line's bounded length > a multi-megabyte line is refused by its length, before any of it is decoded or parsed` - Expected: "length", Received: "secret". After the fix it passes in about 10 ms with no call to `atob` or `JSON.parse`. - Line bound, writer: `(fail) a line's bounded length > the longest line is written and read; one character more is refused by the writer and by the reader` - Expected: "length", Received: "none". - Secret length: `(fail) a line's bounded length > a secret that is not 184 characters is refused before it is decoded` - Expected number of calls: 1, Received number of calls: 2. - Private value: `(fail) the secret's private value > 0 is refused as out of range, before any runtime is asked to import it` - Expected: "scalar", Received: "secret". The tests for n and n+1 failed the same way. - Private value, writer: `(fail) the secret's private value > the writer refuses a key whose private value is out of range` - Expected: "scalar", Received: "none". - Vector names, with `json-escape.json` moved away: `(fail) the vectors of join/ > names: exactly one good line and the refusals the line format defines, none missing` - `- "json-escape",`. The previous assertion passed. - PKCS8 form, with the previous assertion against the runtime's export: `(fail) writing a line > the secret is the good line's fixed bytes around d, x and y, for many keys, whatever form the runtime exports PKCS8 in` - the 67-byte form was expected and the 138-byte line secret received. - Writer bound before export: `(fail) a line's bounded length > a service too long for any line is refused by the writer before the key is exported or anything is encoded` - Expected `exportKey: 0, btoa: 0`, Received `exportKey: 1, btoa: 5`. - Writer bound on the escaped line, against the previous commit of this branch, which checked only the origin's raw length: `(fail) a line's bounded length > an origin that fits the early bound but not once JSON escapes it is refused by the writer, as the reader would` - Expected: "length", Received: "none". The input is `'https://' + 'a'.repeat(455) + '".test'`, a 469-character origin whose line is 1026 characters. Each of these changes to the library, made in a scratch copy, fails a test on this head: - A reader `length` message holding `line.slice(30, 42)`: `(fail) a line's bounded length > a multi-megabyte line is refused by its length, before any of it is decoded or parsed` and `(fail) a line's bounded length > the longest line is written and read; one character more is refused by the writer and by the reader` - `+ "payload at 18",`. - A writer `scalar` message holding `jwk.d.slice(1, 13)`: `(fail) the secret's private value > the writer refuses a key whose private value is out of range` - `+ "d at 0",`. - The writer's key type and curve check removed: `(fail) writing a line > the writer refuses a key of another type or curve even when its parts are 32 bytes each` - Expected `"reason": "secret"`, Received `"reason": "none"`. - The writer's early `length` message holding `service.slice(8, 20)`: `(fail) a line's bounded length > the longest line is written and read; one character more is refused by the writer and by the reader` and `(fail) a line's bounded length > a service too long for any line is refused by the writer before the key is exported or anything is encoded` - `+ "service at 8",`. - The same in the writer's final `length` message: `(fail) a line's bounded length > an origin that fits the early bound but not once JSON escapes it is refused by the writer, as the reader would` - `+ "service at 8",`. - The writer's JWK-part check removed: `(fail) writing a line > the writer refuses a key whose JWK parts are not 32 bytes each in their one spelling` - Expected `"reason": "secret"`, Received `"reason": "none"`. - That check's refusal holding `value.slice(1, 13)` of a short `d`: the same test fails with `+ "d at 1",`. - The reader's `service` message holding `String(service).slice(3, 15)`: the vector tests `service-default-port`, `service-http`, `service-path`, `service-trailing-slash` and `service-uppercase-host` fail with `+ "service 0 at 3",`. - The reader's `list` message holding `String(list).slice(3, 15)`: `(fail) the vectors of join/ > list-not-a-hash` - `+ "list 1 at 3",`. - The writer's origin check moved before its early length check: `(fail) a line's bounded length > a service too long for any line is refused by the writer before it is parsed, the key exported or anything encoded` - Expected `"reason": "length"`, Received `"reason": "service"`. - The range check refusing 1 (`value > 1n`): `(fail) the secret's private value > 1 is in range: a key with it is written, read back to its own public key, and signs`. Checks run on this head: - `bun test shared/account-list-join.test.ts`: 63 pass, 0 fail. - `bun run typecheck`: passed. - `bun run check fast`: exit 0, no test file with a failure. Skipped: `bun run check full`, the browser jobs and the native Windows and macOS runs. This change touches only `shared/account-list-join.ts` and its test, which nothing in the app imports yet.
Change
Adds the join line of the account's signed list as a library: the one line a machine pastes to join an account.
The line carries the account service's origin, the list id and an invite's private key.
writeJoinLinebuilds the line from an extractable P-256 key. Every runtime writes the same bytes.readJoinLinereads a pasted line strictly: one spelling only, proved by writing the line again from what was read.Nothing in the server or the app calls it yet, so no behaviour changes. Refs #3996
Validation
bun test shared/account-list-join.test.ts: 46 pass, 0 fail.bun run typecheck: exit 0.bun run check fast: exit 0.cryptography) agrees with all 28 vectors.