mirror of
https://github.com/block/buzz.git
synced 2026-11-04 08:21:48 +00:00
Adds wire formats to NIP-FA for agent keys acting under an owner-authorized grant. - **Agent keys**: the owner authorization is a NIP-OA `auth` tag the adapter verifies against the owner's bound key; adapters accept empty conditions and refuse conditions they don't support. An adapter that operates an agent itself may keep its grant internally. - **Agent grant** (`POST /v1/nip-fi/agent-grant`): an RFC 8693 token exchange of the owner's adapter session (as `subject_token`), the agent key's NIP-98 proof in `Nostr-Authorization`, and the NIP-OA tag for an opaque agent grant. Defines neutral token types `urn:nostr:params:oauth:token-type:nip-fa-session` and `urn:nostr:params:oauth:token-type:nip-fi-agent-grant`. An invalid or unacceptable `subject_token` is `400 invalid_request` per RFC 8693 §2.2.2. Grant lifetime is adapter policy. Enrollment replaces earlier grants; an agent key's owner never changes, and a revoked key cannot be enrolled again. - **Agent assertion** (`POST /v1/nip-fi/agent-assertion`): the grant as Bearer plus the agent's NIP-98 proof; same body and checks as `/v1/identity/assertions`, returning `nip-fi-agent+jwt`. `exp` is not capped by any session, and clients check `iss` against the grant's issuer. `401 invalid_grant` discards the grant; an unauthorized relay is `403 authorization_denied`, as on the human route. - **Agent revocation** (`POST /v1/nip-fi/agent-revoke`): the owner's session revokes one agent by pubkey and invalidates its grants and disconnects it through the NIP-FI admin disconnect API; single-field form, 1024-byte limit, idempotent. - Proofs are single-use on the grant and assertion routes. - **NIP-FI assertion transport**: the agent-grant `subject_token` is the one exception to Bearer-only session transport. - **Security considerations**: origin, redirect and logging rules for agent grants. NIP-FI is unchanged: its "Agent keys" section and out-of-scope list are consistent with these routes. --------- Signed-off-by: Will Pfleger <wpfleger@block.xyz>