Skip to content

feat(api): sign requests to the API of /dev/null - #22

Merged
jubianchi merged 5 commits into
mainfrom
feat/signed-requests
Oct 20, 2026
Merged

jubianchi merged 5 commits into
mainfrom
feat/signed-requests

Conversation

@jubianchi

Copy link
Copy Markdown
Owner

First of a stack of pull requests moving the log from the session cookie to the signed API of /dev/null (dev-null-sh/dev-null.sh#130), whose device approval dev-null-sh/dev-null.sh#585 proposes for terminals.

Changes

  • hooks/infrastructure/: builds the message a request is signed with (timestamp, nonce, method, path and query as sent, raw body)
  • hooks/device-key.sh: creates the ed25519 key of the device and signs a message read on stdin with ssh-keygen (SSHSIG, devnull-api namespace); the private key comes in DEVNULL_KEY, never as an argument, and lives in a 0600 file only while ssh-keygen reads it
  • hooks/infrastructure/device-key.ts: runs the script through $.process.run and checks what it prints
  • hooks/infrastructure/api.ts: reads /api/v1 on dev-null.sh with signed requests; it reads only (commits go through the official script alone), and tells an unapproved device and a rate limit from the other refusals
  • Documents the principles of the signed API

Not yet

The state module (deviceKeyOf/apiOf, store key deviceKey) and the sign-in come with a later pull request: nothing reads the API yet.

Tests

  • tests/device_key_test.sh checks the signatures with the real ssh-keygen, as /dev/null does, in CI and under the bash 3.2 of macOS
  • Unit tests for the message, the key adapter and the API client

🤖 Generated with Claude Code

https://claude.ai/code/session_01Fh4vxQUEH5yYphfgVatQKF

/dev/null's signed API (dev-null-sh/dev-null.sh#130) checks an SSHSIG of
the timestamp, the nonce, the method, the path and query as sent, and the
raw body, one a line. The nonce is 32 hexadecimal digits, drawn here from
16 random bytes the caller gives, so that tests stay deterministic.

First step towards reading the log through the API instead of the cookie.

🤖 Généré avec Claude Code
/dev/null identifies a device of the signed API by the fingerprint of
the ed25519 key its requests are signed with, an SSHSIG in the
devnull-api namespace. hooks/device-key.sh creates such a key and signs
a message read on stdin with ssh-keygen, the only tool the host offers
for it.

The private key comes in DEVNULL_KEY, never as an argument other
processes could read, and lives in a file of its own, 0600, only while
ssh-keygen reads it. tests/device_key_test.sh checks the signatures with
the real ssh-keygen, as /dev/null does, and runs in CI and under the
bash 3.2 of macOS.

🤖 Généré avec Claude Code
hooks/infrastructure/device-key.ts runs hooks/device-key.sh through the
host's process runner to create the key of the device and to sign a
message with it. It checks what the script prints: an ed25519 public
key, a SHA256 fingerprint as /dev/null stores it, an OpenSSH private
key, and a signature in base64 on one line.

The private key goes in the environment of the script and the message
on its stdin; the arguments name the command only.

🤖 Généré avec Claude Code
hooks/infrastructure/api.ts reads /api/v1 on dev-null.sh, each request
signed as /dev/null checks it: X-Devnull-Timestamp in seconds, a nonce
of its own and the SSHSIG of the message in X-SSH-Signature. It refuses
a path it would not send as it signed it, or outside the API.

It reads only: the API also takes commits, which the plugin sends
through the official script alone. It tells a device that is not
approved yet, and a limit of requests with how long to wait, from the
other refusals.

🤖 Généré avec Claude Code
The API of /dev/null takes commits, deletions and follows from an
approved device: the plugin reads it only, as it reads the web app,
since commits go through the official script alone.

The private key of the device is a secret like the session cookie: the
plugin creates it, keeps it in its store and hands it to ssh-keygen
only, through its environment; only signatures leave, for dev-null.sh.

🤖 Généré avec Claude Code
@jubianchi
jubianchi marked this pull request as ready for review October 20, 2026 07:44
@jubianchi
jubianchi merged commit db5cb17 into main Oct 20, 2026
8 checks passed
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