App grants: one secret sealed to an external app (key hub phase 1) (#286)
Some checks failed
CI / build (push) Has been cancelled
Deploy to dev2 / deploy (push) Has been cancelled
test / test (push) Has been cancelled

* App grants: hand one secret to an external app, sealed to its per-user inbox

Phase 1 of the CoinPay <-> logicsrc key hub (spec: claude.ai/artifact/LAZgAiqWqeLQ14uJ5JpdKb).

- /grant consent page: logicsrc fetches the request manifest from the app's
  own origin over TLS (/.well-known/logicsrc-grant/<nonce>), public hosts
  only, so the page shows a verified origin, not a claimed name
- The browser decrypts with the identity key (as the vault page does) and
  seals with @profullstack/sealed-secrets to the app's inbox; the server
  stores ciphertext + metadata only (app_grant_requests, app_grants)
- Signed Standard Webhooks to the app: grant.delivered / updated / revoked
- Signing keys (wallet, seed, SSH) are refused for apps
- rotate-keys re-seals the new value to every app grant on the old
  fingerprint (resealAppGrants); /apps lists and revokes grants

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* App grants: re-check the webhook host is public on every delivery

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Anthony Ettinger 2026-11-11 05:16:37 -08:00 • committed by GitHub
parent 64eb42e2c1
commit bbf640abeb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 974 additions and 4 deletions

View file

@ -0,0 +1,46 @@
-- App grants: a person hands one named secret to an external app (meshhook,
-- smshub, ...), sealed in their browser to that app's per-user inbox key.
-- The server stores ciphertext and metadata only, never a value.
--
-- A request is created from a manifest logicsrc fetched itself from the app's
-- origin over TLS (/.well-known/logicsrc-grant/<nonce>), so the consent page
-- shows a verified origin, not a name the app claimed.
CREATE TABLE IF NOT EXISTS app_grant_requests (
id TEXT PRIMARY KEY,
origin TEXT NOT NULL,
nonce TEXT NOT NULL,
app_name TEXT NOT NULL,
manifest TEXT NOT NULL,
user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
status TEXT NOT NULL,
created_at INTEGER NOT NULL,
expires_at INTEGER NOT NULL,
decided_at INTEGER,
UNIQUE (origin, nonce)
);
CREATE TABLE IF NOT EXISTS app_grants (
id TEXT PRIMARY KEY,
request_id TEXT NOT NULL REFERENCES app_grant_requests(id) ON DELETE CASCADE,
user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
origin TEXT NOT NULL,
app_name TEXT NOT NULL,
key_name TEXT NOT NULL,
vault_id TEXT NOT NULL,
source_name TEXT NOT NULL,
fingerprint TEXT NOT NULL,
recipient TEXT NOT NULL,
recipient_fingerprint TEXT NOT NULL,
webhook_url TEXT NOT NULL,
webhook_secret TEXT NOT NULL,
status TEXT NOT NULL,
created_at INTEGER NOT NULL,
revoked_at INTEGER,
last_delivered_at INTEGER,
last_error TEXT
);
CREATE INDEX IF NOT EXISTS idx_app_grants_user ON app_grants(user_id);
CREATE INDEX IF NOT EXISTS idx_app_grants_fingerprint ON app_grants(fingerprint);
CREATE INDEX IF NOT EXISTS idx_app_grants_vault ON app_grants(vault_id);