Skip to content

Signing requests

A connected app signs each request to an operation under /v1 with HTTP Message Signatures (RFC 9421) and its Ed25519 key. The signature covers the method and the full URL, so a signed request cannot be replayed against another path or query, and it covers a digest of the content, so the body cannot be changed.

Use a library that implements RFC 9421 to build the signature base; the service itself verifies with http-message-sig and httpbis-digest-headers.

Header Value
Content-Digest Only when the request has content: the SHA-256 of the bytes sent, as RFC 9530 writes it: sha-256=:<base64>:.
VoidFS-Account The account’s user ID, 64 lowercase hex characters. Absent while the app’s approval is pending.
VoidFS-Generation The account generation the app was approved under, 32 lowercase hex characters. Absent while the approval is pending.
User-Agent voidfs-cli/<major.minor.patch>, the app’s version. The service refuses a version below its minimum with the problem client-outdated.
Signature-Input The covered components and the signature parameters, under the label sig.
Signature The Ed25519 signature over the signature base, under the label sig: sig=:<base64>:.

The user ID and the generation come from the approval.

The signature covers exactly these components, in this order:

  1. @method
  2. @target-uri, the URL the request is sent to, with its origin and its query. limit, cursor and filters travel in the query, so they are signed.
  3. content-digest, when the request has content
  4. voidfs-account and voidfs-generation, once the app is approved
  5. user-agent

A signature that covers more, fewer or reordered components is refused. A 401 lists the components its operation expects in Accept-Signature.

The service compares Content-Digest with the bytes it received and requires the sha-256 member: a field that holds only another algorithm is refused. A request without content sends no Content-Digest.

Parameter Value
created When the app signed, in Unix seconds: a whole number, not negative and not after expires.
expires When the signature ends, in Unix seconds: a whole number, at most 60 seconds after created, not in the past and not more than 60 seconds ahead of the service’s time.
nonce The request ID: 32 lowercase hex characters (16 random bytes, not all zero).
alg "ed25519"
keyid The app ID, 64 lowercase hex characters.

A signature lives for 60 seconds at most. The service refuses one that has expired, one that declares a longer life, and one whose expires lies more than 60 seconds ahead of its own clock, so the app’s clock has to be close to the service’s. Replies carry a Date header to compare against.

A request ID is used once. The service remembers each nonce for its app (for a pending app, for its approval) until the signature expires, and refuses a second request with the same one in that time, even a byte-identical one. Sign a retry again, with a new nonce.

This is the rename message of the repository’s connected-app test vector (packages/crypto/core/tests/vectors/connected-app-vectors.json). The Rust core that signs for the CLI, the TypeScript library and the service all agree on its bytes, and you can check your own implementation against it.

The app renames itself. Its app ID is b3c39e4a90f6113318459b5ca1a1cea14ff03c79f236054ed75a15c7acbb9b92 and its Ed25519 public key is d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a. The vector’s private key is the first test key of RFC 8032, so it is public: never use it for anything else.

The request sends this JSON, with no space or line break in it:

{"name":"Laptop CLI"}

The SHA-256 of those bytes, in base64, is the Content-Digest header:

Content-Digest: sha-256=:i6RSvrllf2Zcw0N/WcNVHXjdjhDM+Gr6D6RcaE+j6V0=:

One line for each covered component, then @signature-params. The lines are joined with a line feed, and the last one has none after it. Here created is 1800000000 and expires is 1800000055, 55 seconds later.

"@method": PATCH
"@target-uri": https://api.voidfs.com/v1/connected-apps/b3c39e4a90f6113318459b5ca1a1cea14ff03c79f236054ed75a15c7acbb9b92
"content-digest": sha-256=:i6RSvrllf2Zcw0N/WcNVHXjdjhDM+Gr6D6RcaE+j6V0=:
"voidfs-account": 04f8996da763b7a969b1028ee3007569eaf3a635486ddab211d512c85b9df8fb
"voidfs-generation": 0123456789abcdef0123456789abcdef
"user-agent": voidfs-cli/1.2.3
"@signature-params": ("@method" "@target-uri" "content-digest" "voidfs-account" "voidfs-generation" "user-agent");created=1800000000;expires=1800000055;nonce="00112233445566778899aabbccddeeff";alg="ed25519";keyid="b3c39e4a90f6113318459b5ca1a1cea14ff03c79f236054ed75a15c7acbb9b92"

The app signs the bytes of the signature base with its Ed25519 private key and sends the signature in base64. Signature-Input repeats the last line of the base under the label sig.

PATCH /v1/connected-apps/b3c39e4a90f6113318459b5ca1a1cea14ff03c79f236054ed75a15c7acbb9b92 HTTP/1.1
Host: api.voidfs.com
Content-Type: application/json
Content-Length: 21
Content-Digest: sha-256=:i6RSvrllf2Zcw0N/WcNVHXjdjhDM+Gr6D6RcaE+j6V0=:
VoidFS-Account: 04f8996da763b7a969b1028ee3007569eaf3a635486ddab211d512c85b9df8fb
VoidFS-Generation: 0123456789abcdef0123456789abcdef
User-Agent: voidfs-cli/1.2.3
Signature-Input: sig=("@method" "@target-uri" "content-digest" "voidfs-account" "voidfs-generation" "user-agent");created=1800000000;expires=1800000055;nonce="00112233445566778899aabbccddeeff";alg="ed25519";keyid="b3c39e4a90f6113318459b5ca1a1cea14ff03c79f236054ed75a15c7acbb9b92"
Signature: sig=:655CDrFMIdEAcYCTawjIODLGD6EQ+FkIvMlkbHUSp1N0yc1eO2GLxQXvMxwjGj5+M99Z5G1pMS/Dnb3L6rtsAA==:
{"name":"Laptop CLI"}

This Node.js program verifies the signature above with the vector’s public key and prints true:

import { createPublicKey, verify } from "node:crypto";
const signatureBase = [
"\"@method\": PATCH",
"\"@target-uri\": https://api.voidfs.com/v1/connected-apps/b3c39e4a90f6113318459b5ca1a1cea14ff03c79f236054ed75a15c7acbb9b92",
"\"content-digest\": sha-256=:i6RSvrllf2Zcw0N/WcNVHXjdjhDM+Gr6D6RcaE+j6V0=:",
"\"voidfs-account\": 04f8996da763b7a969b1028ee3007569eaf3a635486ddab211d512c85b9df8fb",
"\"voidfs-generation\": 0123456789abcdef0123456789abcdef",
"\"user-agent\": voidfs-cli/1.2.3",
"\"@signature-params\": (\"@method\" \"@target-uri\" \"content-digest\" \"voidfs-account\" \"voidfs-generation\" \"user-agent\");created=1800000000;expires=1800000055;nonce=\"00112233445566778899aabbccddeeff\";alg=\"ed25519\";keyid=\"b3c39e4a90f6113318459b5ca1a1cea14ff03c79f236054ed75a15c7acbb9b92\""
].join("\n");
const signature = "655CDrFMIdEAcYCTawjIODLGD6EQ+FkIvMlkbHUSp1N0yc1eO2GLxQXvMxwjGj5+M99Z5G1pMS/Dnb3L6rtsAA==";
// An Ed25519 public key in SPKI form: a fixed 12-byte prefix, then the 32 bytes of the key.
const publicKey = createPublicKey({
key: Buffer.concat([
Buffer.from("302a300506032b6570032100", "hex"),
Buffer.from("d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a", "hex"),
]),
format: "der",
type: "spki",
});
console.log(
verify(null, Buffer.from(signatureBase), publicKey, Buffer.from(signature, "base64")),
);

The same file holds a request with a query (list-page), which shows the query inside @target-uri, and the two requests a pending app sends (register and approval), which carry no account.

Reply Meaning
401 connected-app-unavailable The signature, its parameters, the digest or a covered field is wrong; the request ID was used before; or the app is unknown, revoked or expired. The service does not say which.
400 client-outdated The version in User-Agent is below the service’s minimum.
400 conflicting-credentials The request also carried a cookie or an Authorization header.
403 forbidden A connected app may not use this operation. The service can answer this before it checks the signature.