Skip to content

feat(shared): add the join line of the account's signed list - #4103

Merged
devswha merged 1 commit into
mainfrom
feat/account-list-join
Nov 18, 2026
Merged

devswha merged 1 commit into
mainfrom
feat/account-list-join

Conversation

@devswha

@devswha devswha commented Nov 18, 2026

Copy link
Copy Markdown
Owner

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.

  • writeJoinLine builds the line from an extractable P-256 key. Every runtime writes the same bytes.
  • readJoinLine reads a pasted line strictly: one spelling only, proved by writing the line again from what was read.
  • A refusal gives a reason and never repeats any part of the line.
  • 28 JSON test vectors (one good line, 27 refusals) let another implementation check itself against the same cases.

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.
  • An independent reader written separately (Python, cryptography) agrees with all 28 vectors.
  • Size: 30 files, 395 lines of code and 455 lines of vectors.

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.
@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • New Features
    • Added support for creating and reading secure account-list join links, with validation of service addresses, list identifiers, and invite keys.
  • Bug Fixes
    • Invalid or noncanonical join links are now rejected with clear errors.
  • Tests
    • Added coverage for valid joins, malformed inputs, invalid service addresses, key mismatches, and unavailable cryptography support.

Adds a shared API that writes and reads canonical ovis-join:1: lines. The reader validates line structure, service and list fields, and the embedded P-256 key. Tests and JSON vectors cover valid lines, malformed inputs, and refusal behavior.

Changes: Join-line format and validation

Layer / File(s) Summary
Join-line encoding and key round trips
shared/account-list-join.ts, shared/account-list-join.test.ts, shared/account-list-vectors/join/join-line.json
Adds the writer and reader for canonical join lines. Tests cover valid P-256 key round trips and compare output with the valid vector.
Canonical line and field validation
shared/account-list-join.test.ts, shared/account-list-vectors/join/*
Tests and vectors cover malformed prefixes, base64url, JSON, versions, object members, service origins, and list identifiers.
Secret validation and refusal behavior
shared/account-list-join.test.ts, shared/account-list-vectors/join/*
Tests and vectors cover fixed-form PKCS8 secrets, key curve and public-point checks, missing WebCrypto, and refusal-error contents.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Possibly related issues

  • devswha/ovis#3996: The issue describes the shared signed-list library’s join-line reader and writer as a planned piece.

Possibly related PRs

  • devswha/ovis#3997: This PR imports isListHash and verifySignature from the account-list entry module introduced by #3997.
Merge Risk: Minimal · up to 02a1b

This adds a standalone shared reader and writer for account join lines that nothing calls yet, so no existing behavior changes. No merge-blocking issue was found, and one speculative edge case about unusual private-key encodings remains unconfirmed.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a new shared library that writes and reads the join line for an account's signed list. It is specific and matches the summary and objectives. It is short and uses the …
Description check Passed The description follows the template's two sections, Change and Validation. The Change section explains the library, the strict reading rules, the refusal behavior, and the 28 test vectors. The Valida…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: a new shared library that writes and reads the join line for an account's signed list. It is specific and matches the summary and objectives. It is short and uses the conventional feat(scope) form.

Full details: Description check

Explanation

The description follows the template's two sections, Change and Validation. The Change section explains the library, the strict reading rules, the refusal behavior, and the 28 test vectors. The Validation section lists the test, typecheck, and fast-check commands with results and a cross-implementation check. It does not mention the changelog step from the template's contributing note or the contract-test coverage. Those items are not required for this non-HTTP library change.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 4954078 and 02a1b06.

Files selected for processing: 30

  • shared/account-list-join.test.ts
  • shared/account-list-join.ts
  • shared/account-list-vectors/join/join-line.json
  • shared/account-list-vectors/join/json-escape.json
  • shared/account-list-vectors/join/json-not-an-object.json
  • shared/account-list-vectors/join/json-not-utf8.json
  • shared/account-list-vectors/join/json-white-space.json
  • shared/account-list-vectors/join/line-no-prefix.json
  • shared/account-list-vectors/join/line-outside-alphabet.json
  • shared/account-list-vectors/join/line-padded.json
  • shared/account-list-vectors/join/line-prefix-version-2.json
  • shared/account-list-vectors/join/line-second-spelling.json
  • shared/account-list-vectors/join/list-not-a-hash.json
  • shared/account-list-vectors/join/member-extra.json
  • shared/account-list-vectors/join/member-missing.json
  • shared/account-list-vectors/join/member-twice.json
  • shared/account-list-vectors/join/members-other-order.json
  • shared/account-list-vectors/join/secret-139-bytes.json
  • shared/account-list-vectors/join/secret-no-public-key.json
  • shared/account-list-vectors/join/secret-not-base64url.json
  • shared/account-list-vectors/join/secret-other-curve.json
  • shared/account-list-vectors/join/secret-other-point.json
  • shared/account-list-vectors/join/service-default-port.json
  • shared/account-list-vectors/join/service-http.json
  • shared/account-list-vectors/join/service-path.json
  • shared/account-list-vectors/join/service-trailing-slash.json
  • shared/account-list-vectors/join/service-uppercase-host.json
  • shared/account-list-vectors/join/v-1-0.json
  • shared/account-list-vectors/join/v-2.json
  • shared/account-list-vectors/join/v-string.json

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@devswha

devswha commented Nov 18, 2026

Copy link
Copy Markdown
Owner Author

Adversarial review: Codex gpt-6.2-astra, read-only, on head 02a1b0697

No high finding. Nothing calls this library yet, so none of these blocks the merge; they are for the follow-up that wires it in (#3996).

  1. Medium — The reader decodes an unbounded paste. A prefixed line with a multi-megabyte base64url payload goes through decoding and re-encoding before the reader checks whether it contains JSON. The same happens to an oversized secret before its 138-byte length check. This puts CPU and memory use under the paste’s control. Define a protocol maximum, enforce it before decoding, apply the corresponding limit in the writer, and check that secret is exactly 184 characters before decoding it. account-list-join.ts:145 · account-list-join.ts:129

  2. Medium — Private-scalar canonicality depends on the crypto provider. A correctly framed secret whose 32-byte private scalar is outside the P-256 range passes secretForm and reaches WebCrypto. Rewriting the JSON preserves those original bytes. The signing probe checks the key the provider imported, so a provider that reduces the scalar modulo the group order could accept a second encoding of the same key. I verified the missing range check in source. Acceptance of such an alias on a particular runtime remains unverified. Apply the neighboring 1 ≤ d < n check to d in both reader and writer, and add a boundary vector. account-list-join.ts:132 · account-list-entry.ts:303

  3. Medium — An unavailable crypto algorithm is reported as a bad invite. With the known-good vector, I made subtle.sign reject with NotSupportedError. The reader returned line_malformed / secret. The writer gave the same refusal when exportKey reported NotSupportedError for the valid fixture key. Preserve a fixed, input-free runtime fault for unsupported operations and narrow the malformed-key catches to errors that identify invalid input. account-list-join.ts:119 · account-list-join.ts:169

  4. Low — The redaction test would pass if an error disclosed the private scalar. I checked its predicate against the base64url-encoded d from the test key. It detected that value in 0 of 27 refusal cases. The test looks for the start of the PKCS8 wrapper and samples substrings of the outer line. Assert the exact allowed message and error fields for each refusal reason. I found no actual disclosure in the tested refusals. account-list-join.test.ts:207

  5. Low — Three vectors can disappear silently. Removing json-escape, json-not-utf8, or json-not-an-object also removes its generated test, and the inventory assertion still passes. Assert the complete set of 28 names. All nine refusal reasons currently have vectors. account-list-join.test.ts:40

  6. Low — The writer tests require Bun’s native PKCS8 layout. A Bun version that exports the same valid key in another legal PKCS8 form would fail these tests even if the writer still emits the exact protocol bytes. Keep the byte-for-byte fixed-vector check and the fresh-key round trip. Remove the assertions tying success to Bun’s native export. account-list-join.test.ts:63 · account-list-join.test.ts:84

Checked and correct. All 46 focused tests passed on Bun 1.4.2. Node 24.18.0 matched all 28 vector outcomes. For ten fresh keys exchanged between Bun and Node, both writers produced identical lines. Returned keys were sign-only, and WebCrypto refused JWK and PKCS8 export. The exact-own-member check rejects extra keys including __proto__. Rewriting catches duplicate members, alternate ordering, JSON escapes, and whitespace. The shipped origin, base64url, wrong-curve, and mismatched-point vectors had the expected outcomes.

The checkout was clean and detached at the requested commit. I found no production caller. I checked the supplied description against the local commit and diff. Browser and Worker runtimes and the full repository suite were not run.

@devswha
devswha merged commit 3cce36f into main Nov 18, 2026
24 checks passed
@devswha

devswha commented Nov 18, 2026

Copy link
Copy Markdown
Owner Author

Merged through pr-merge at head 02a1b0697. Seen before the merge was asked for: required checks green, no unresolved thread, no conflict, no hold, main not red, no release in progress. CodeRabbit reviewed this head.

Merged on the maintainer's word, as the first merge through pr-merge. Independent review of this head: Codex gpt-6.2-astra, read-only: no high finding; its three mediums and three lows are in the comment above, for the follow-up that wires the library in.

@devswha
devswha deleted the feat/account-list-join branch November 18, 2026 05:38
devswha added a commit that referenced this pull request Nov 18, 2026
## 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]>
devswha added a commit that referenced this pull request Nov 18, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant