~ knotless Search/
↑↓ move↵ open⇧↵ all results

grain.social/grain

photography-focused photo sharing platform

grain.social
1 collaborator
0
2

The next grain.social and the apps take HUD 0.31.0, their tokens bound to a key

Merged
Merged chadtmiller.com asked to merge into main from grain.social/grain:hud/0.31.0

What changes

The next grain.social and the iOS and Android apps take HUD 0.31.0 (just hud-version 0.31.0): next/package.json and its lock, ios/HUD/Package.swift and ios/Package.resolved, android/gradle/libs.versions.toml, the app file's "hud": ">=0.31.0" and the $schema of the app file, the views and the parts.

The apps' sign-ins are bound to a key on the device. 0.31.0's HUDKit and hudkit make a P-256 key per account (the Secure Enclave, the Android Keystore) and send a DPoP proof with every request carrying HUD's tokens, so the session's refresh token is no longer rotated. Grain's two calls change with the kits' API: iOS passes its SignInRequest to AccountSession.start(request, tokens:handle:ended:) (ios/Grain/Shell.swift), so the key made with the request stays with the account; Android passes its store's keys to auth.exchange(code, request, store.keys) (android/.../Shell.kt). An account signed in before this gets its key at its next renewal, without signing in again.

The web's sessions are bound too. @hud/shell's Sessions derives one key from SESSION_SECRET and the grain-next salt, so every server of the app holds it and nothing new is configured; next/src/lib/server/hud.ts is unchanged.

An account is let go only when HUD says its grant is no good (invalid_grant, invalid_client, unauthorized_client), on the web and in both apps: HUD unreached, restarting, a proxy's refusal or a proof refused fails that renewal and keeps the session.

Why

The iOS app (Grain/101) signed its user out on 2026-11-30 at 03:07 UTC: a refresh hud-grain answered at 02:31 never reached the app (suspended with it in flight), and the next refresh, with the token the app kept, was taken by HUD as a replayed one and ended the session. The web lost both of a browser's accounts the same way on 2026-12-01 at 01:32 UTC, a page that refreshed them abandoned before its cookie arrived. HUD 0.31.0 answers a lost rotation's token again for bearer clients (at://did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.pull/3n3itkfwwqzbb) and binds its own clients' tokens to a key (at://did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.pull/3n3ivjsetb6du), so their refresh tokens are not rotated at all: RFC 9700 §4.14.2's sender-constrained tokens in place of rotation.

How it was checked

  • The kits' signatures read at HUD's Release 0.31.0 (8bcb4947): Grain calls no other API that changed (AccountSession.restore, kept, KeystoreSessionStore, HUDClient(base:session:) and Sessions as before).
  • HUD's own checks at the release: HUDKit's tests (258), hudkit's, the web shell's (ssr.mjs with a fake HUD checking every proof), the server's under its coverage gate, and both e2e suites.
  • Nothing built here (AGENTS.md): next, next-image and android are left to the checks. The iOS app builds only on a Mac: not built yet.

Shortcomings

  • hud-grain must run 0.31.0 before this deploys. It runs 0.29.0, and the app file now says >=0.31.0, which an older HUD refuses. Move it (hetzner-infra, services/hud) first.
  • Not tried on a device. The Secure Enclave and Android Keystore paths, and the upgrade of a kept sign-in to a bound one, ran in unit tests alone (the simulator has no enclave; Robolectric no Keystore). Before builds ship: on a TestFlight and an internal Android build against next.grain.social, upgrade over a kept sign-in (hud-grain should log one rotating refresh, then DPoP calls), sign in fresh, background over an hour, set the clock 10 minutes off, sign out.
  • Any app build cut after this merges carries DPoP.

Review

The two call sites in ios/Grain/Shell.swift and android/app/src/main/java/social/grain/Shell.kt; the rest is the version bump.

Approved

This moves next/, the iOS app and the Android app to HUD 0.31.0. It also changes the two sign-in call sites so each account's key is kept with its tokens. I found nothing that must change.

  • Version bump: it is consistent across package.json and its lock, Package.swift, Package.resolved, libs.versions.toml, the app file's hud and the $schema of the app file, views and parts. I read only the first diff lines of the views; the rest of that diff is the same one-line $schema change in each file.
  • iOS: request is the SignInRequest already in scope in signIn, and the same value is passed to exchange(... for: request). AccountSession.start(request, tokens:handle:ended:) fits that.
  • Android: store is the KeystoreSessionStore that AccountSession.restore uses, so auth.exchange(code, request, store.keys) makes the key in the store the account later restores from. I could not check the call against hudkit's signatures from here. I am relying on your note that you read them at the 0.31.0 release.
  • Checks: check passed. next, next-image, android and test were still running or queued when I looked, so I can't say they pass. Nothing changed that e2e or lexicons cover, and both were skipped.

Before this ships, deploy hud-grain 0.31.0 first, since the app file now needs >=0.31.0. Also try the key paths on a real device, as the body already says.

Merged as 5618047