feat/oficina-id-native-a
Human
Oficina ID native, slice A, the Home half (spec docs/superpowers/specs/2026-11-14-oficina-id-native.md, §3–§5, §7 step 1, §9 teams, §10, §13). Cut from main 979dac4; main e03a01a (the connect work) merged in, with handoff repinned to it. Fable reviewed cdad4ed: APPROVE AFTER FIXES. The fixes and Paul's 2026-11-14 rulings are on this branch. Not deployed, not merged.
What it adds
- Grants and the device-key proof (§3).
home_id_grants(identity migration 0004).Authorization: OficinaID <token>plusOficina-Proof. The replay table is persistent and holds each jti 61 s. Each grant gets 120 calls a minute and each person 300. The table holds 250,000 rows and refuses everything when full. Every answer carriesDate, and a 401 carriesnow. Lifetimes: 90 days idle, 365 days absolute, 20 live grants per person (LRU). An ended grant keeps its device key for 365 days. - Email code (§4).
code/start,code/resendandcode/verify, with every limit in the spec's table held in persistent buckets. The returning-key exemption is decided by end_reason. Live starts are capped per IP bucket, and a full table answers 503full. Native and web share one email budget. The address is sealed undernative.code, and Keymail addresses get a code in slice A. On an account with a passkey, verify returns{factor:["passkey"], pending}. - Native passkeys (§5).
passkey/beginandpasskey/finish, verified against Home's existing WebAuthn config (RP id.oficina.works). Also the static/.well-known/apple-app-site-association: five App IDs, webcredentials only. assert(§7). It mapsaudby exact origin and refuses the operator consumer. Home sets the nonce withhandoff.NativeNonce. It callsmintPolicy, which is empty and now also called by/authorize.- Revocation (§3, §10).
signout. "Sign out all devices" (Paul, 2026-11-14) ends every grant and every Home browser session of the person, the pressing browser's included. On id., the grants, every session of the person, half-finished sign-ins and a per-person mark (the press time) are written in one transaction. The browser then carries a signed receipt across ("Finishing signing out of oficina.works…"). That receipt is an assertion for the directory whose nonce is derived from its own jti (oficina-id/signout-all/v1). Atoficina.works/auth/signed-out-all, the directory ends every directory session of the person (browser and native), records the mark and burns the jti in one transaction, then lands on "All devices are signed out". This browser's directory cookie is cleared only if it is that person's. The directory refuses any assertion issued at or before the mark, at its browser finish and its native exchange, so one minted in the 120 s before the press buys nothing. id. consumes no assertions, so its mark guards grants instead: none created at or before it authenticates. Recovery replacement ends every grant. A first web passkey enrolment ends every grant that has no passkey. - Directory (§9).
POST oficina.works/native/oficina-iduses connect's NativeExchange request/answer shape and handoff'sNativeChallenge/NativeNonce,Store.VerifyandStore.Reserve.GET /api/native/teams([]for none).POST /native/signout.GET /help/teams, the zero-teams help page. A native directory session reaches only the teams list and its own sign-out. On every other route its cookie is stripped before the session middleware runs, andteamFresh/directoryFreshnever count it as fresh (Fable's finding 1). - Gates (§13) as tests.
native_*_test.goanddirectory_native_test.go, plus gate 9 over the native routes (TestNoContentInLogsNative).
Additions to the spec (keep or drop)
passkey/beginis limited to 60 per IP and 300 per network (IPv4 /24, IPv6 /48) per 15 minutes. Paul: keep.- One live native challenge per device key: a new begin replaces the last. Native challenges may hold at most 5,000 of the 10,000 shared ceremony rows, so the web door always keeps half.
- Code starts are also limited to 1,000 per network per day.
- Each person gets 300 proof calls a minute across all their grants.
Residual of "Sign out all devices"
- The hop between the two stores is not atomic. id. and oficina.works are separate databases. If the browser never completes the hop (closed tab, refused receipt), id. and the apps are signed out but oficina.works sessions run to their own expiry. The failure page says so and offers "Sign in and try again".
- Team-app instances (connect) do not read the mark yet. An assertion for a team instance minted in the 120 s before the press can still be exchanged there; they rely on the assertion's 120 s life. Follow-up for connect (slice C).
- App pages already open in a browser (a Docs tab, say) keep their instance session until it ends. A native app that stays offline keeps its team sessions for up to 7 days. The page copy says exactly this.
Residual denial of service (fail-closed caps)
- Buckets: 500,000 rows. A start writes about 5 rows, one of them a day long. Filling the table takes on the order of 100,000 starts in a day from more than 100 distinct /48s (or /24s). That locks out new native code starts only, for up to a day. Existing starts still verify, and passkeys and the web are unaffected.
- Replay: 250,000 rows of 61 s. Filling it takes about 830 accounts calling at the per-person cap, each behind a verified mailbox.
- Ceremonies. A native flood can take only the native half, and is bounded per IP and per network.
Wire notes (flagged: the spec was silent or ambiguous)
- All base64 is base64url without padding.
device_keyis the 65-byte uncompressed P-256 point (87 chars). The grant token, start and pending are 32 random bytes (43 chars). - The proof payload is exactly
{v,htm,htu,iat,jti,bh}, with any key order and no unknown members. It is signed with rastrillocrypto.Signunderoficina-id/native-proof/v1over the payload bytes as received.htuishttps://id.oficina.works+ path, with no query.bhis base64url(SHA-256(body)).jtiis 16–64 chars of[A-Za-z0-9_-]. - 401.
{"error":"grant_ended","now":…}means the grant is gone: unknown, revoked, signed out, expired, replaced, or ended by an enrolment.{"error":"proof_rejected","now":…}covers everything else. The client wipes the identity only ongrant_ended. - 429.
{"error":"daily_limit"}is used only when the per-address daily wrong-code cap for new devices blocks a start or a verify. Every other 429 israte_limited(verify-resend timing addsresend_after). - Pre-grant calls.
code/start {email, device_key, platform}.code/resend {start}.code/verify {start, code}.passkey/begin {device_key, platform, pending?}: with a pending, the key must be that start's key.passkey/finish {id, clientDataJSON, authenticatorData, signature, device_key, platform?, userHandle?}: device_key must be the challenge's bound key, and platform and userHandle are ignored. Every one of these is signed by that key. - Answers.
202 {start, resend_after: 30}(seconds).200 {grant, identity_id, auth_time}(unix seconds).200 {challenge, rp_id, credentials}.200 {assertion}. Other errors are{error}:request,email,code(400, wrong code),expired(410, the start or pending is gone),full/mail/unavailable(503),browser(403),audience(400),policy(403). platformmust be one ofmacos,ios,ipados.- Native nonce. challenge = SHA-256 of the verifier's base64url string. nonce = base64url(SHA-256("oficina-id/native/v1\0" ‖ the 32 challenge bytes)[:16]). Vector:
AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8→6oZqdX5MOLq_qBJ8vppAnT4fk6AP8UiP9zX8-Rev_9A→ZVVVj2zbBfhkAIwAOKNylg. - Directory exchange. It answers
{state}:ok(with name, value, expires_at = 7 days, and target echoed),invalid400,failed401,unavailable503. It never answers 403unknownor 409choose.teamsneeds ahome-assertion-nativedirectory session. - Keys. identityid, the code MACs and the native blinds are HKDF-SHA256 subkeys of HOMEPEPPER with distinct labels
oficina-id/{identity-id,native-code,native-address,native-ip,native-bucket}/v1; Paul accepted this. Pepper rotation changes every identity_id, kills every code in flight, and resets the native buckets: the same non-rotatable constraint the people index already has. Grants survive, because they are hashed with plain SHA-256.
Deferred or not here
A2 (several identities, Devices page, Keymail sheet). B (native recovery and enrolment; endPasskeylessGrants already takes the enrolling grant as its exception). C–E. Classification is skipped at code/start. Pre-existing, not fixed: the walked gate 9 logs to a discarded logger.
Commits
14
Discussions
1
1 open
Tasks
9/9
done
Discussions 1 open
Tasks 9/9 done
- Schema: grants, replay, starts, pending, buckets (identity 0004) Done
- Grant + device-key proof, replay table, per-grant rate limit, Date/now Done
- Email code start/resend/verify with every §4 limit Done
- Native passkey begin/finish + apple-app-site-association Done
- assert with shared mintPolicy + native nonce Done
Activity
- paul@keymail.dev pushed 29be2e7 Close the gap between the sign-out-all mark and a directory sign-in
- paul@keymail.dev pushed 5281e03 Merge remote-tracking branch 'origin/main' into feat/oficina-id-native-a
- paul@keymail.dev pushed 74381e5 Sign out all devices: marks, duplicate cookies, honest copy
- paul@keymail.dev pushed 6365328 Run the native tests in parallel; give CI a 20-minute budget
- paul@keymail.dev pushed 0f45af8 Use handoff's native derivation and Reserve; trim slow tests
- paul@keymail.dev pushed 398f6df Merge remote-tracking branch 'origin/main' into feat/oficina-id-native-a
- paul@keymail.dev pushed f3b8d1b Sign out all devices ends browser sessions; Fable's review fixes
- claude agent, operated by paul@keymail.dev opened Review: Oficina ID native slice A, Home half
- paul@keymail.dev pushed cdad4ed Align the native wire with the Swift client and connect
- paul@keymail.dev pushed 73e9d5d Directory exchange speaks connect's NativeExchange answers
- paul@keymail.dev pushed 7acd230 Gate 9 reaches the native endpoints
- paul@keymail.dev pushed ca1f32a Oficina ID native: directory exchange, teams and the zero-teams help
- paul@keymail.dev pushed 507810f Oficina ID native: revocation and Sign out all devices
- paul@keymail.dev pushed c632875 Oficina ID native: passkey sign-in and the association file
- paul@keymail.dev pushed b001884 Oficina ID native: grants, device-key proof, email codes, assert
- claude agent, operated by paul@keymail.dev opened Wire notes + review request
- claude agent, operated by paul@keymail.dev opened §13 Home gates as tests; make ci green
- claude agent, operated by paul@keymail.dev opened Directory: native exchange, /api/native/teams, zero-teams help
- claude agent, operated by paul@keymail.dev opened signout, Sign out all devices, replacement and first-enrolment revocation
- claude agent, operated by paul@keymail.dev opened assert with shared mintPolicy + native nonce
- claude agent, operated by paul@keymail.dev opened Native passkey begin/finish + apple-app-site-association
- claude agent, operated by paul@keymail.dev opened Email code start/resend/verify with every §4 limit
- claude agent, operated by paul@keymail.dev opened Grant + device-key proof, replay table, per-grant rate limit, Date/now
- claude agent, operated by paul@keymail.dev opened Schema: grants, replay, starts, pending, buckets (identity 0004)