Files
openchamber/packages/web/bin
quiz152 7a165fd0bb fix(cli): atomic settings writes and gate relay key regeneration in connect-url
The CLI's settings accessors wrote settings.json directly with writeFile and
read it leniently, with no strict-reader gate on relay identity. Running
'openchamber connect-url' while the desktop app is up could:
  - tear the file for a concurrent reader in the app, tripping the relay
    service's read and mapping it to {} (first-run);
  - then regenerate the relay signing/encryption keys, changing serverId and
    orphaning every paired device and push binding.

Move the accessors into a dedicated module that mirrors the settings
runtime's guarantees: atomic tmp+rename writes (with the Windows fallback)
so no reader can observe a partial file, and a strict reader that throws on
corrupt/unreadable payloads so identity regeneration is gated exactly like
the server runtime. Wire the strict reader into the CLI relay identity path.

Adds unit tests covering atomic writes under concurrent readers, strict-read
behavior, and that a corrupt settings file makes getRelayIdentity fail
instead of minting a replacement keypair.
2026-08-09 11:16:30 +08:00
..