| 1 | // Package auth verifies Nostr request proofs without deciding host access. |
| 2 | // It supports NIP-98 HTTP request proofs, NIP-42 relay challenges, BUD-11 |
| 3 | // Blossom authorization and GRASP-08 repository proofs. Successful proof |
| 4 | // verification identifies a signer; callers must separately authorize that |
| 5 | // signer and apply resource, tenant, storage and hosting policy. |
| 6 | // |
| 7 | // Construct validators and challenge managers with their constructors. A nil |
| 8 | // clock uses time.Now. Their replay and challenge stores are in memory and |
| 9 | // scoped to each instance; reuse an instance across requests that share a |
| 10 | // replay boundary. The stores are protected for concurrent use. They do not |
| 11 | // persist across restarts or coordinate across processes. |
| 12 | // |
| 13 | // NIP-98 proofs are single-use within the one-minute replay window. Their URL |
| 14 | // binding preserves path escaping, port and query while ignoring scheme and |
| 15 | // hostname case. Methods compare case-insensitively. A nonempty body requires |
| 16 | // the matching payload hash. NIP-42 challenges are single-use and expire after |
| 17 | // one minute; relay URLs match exactly. Blossom proofs are reusable until |
| 18 | // their expiration and cannot be issued in the future. GRASP-08 GET proofs |
| 19 | // are reusable for supported Smart HTTP requests beneath the signed repository |
| 20 | // root, within the existing one-minute timestamp skew. Unlike NIP-98, GRASP-08 |
| 21 | // requires an uppercase GET method and returns a uniform authentication error. |
| 22 | // |
| 23 | // Payload validation after streaming does not consume the proof again. It |
| 24 | // must follow request authentication and does not replace host authorization. |
| 25 | package auth |