# atp AT Protocol boilerplate for Go, extracted from [arabica.social](https://tangled.org/arabica.social/arabica). Covers OAuth flows, PDS client operations, real-time event consumption, session storage, and HTTP middleware. For integration testing against an ephemeral in-process PDS, see [chrysalis](https://tangled.org/pdewey.com/chrysalis). ## Installation ```sh go get tangled.org/pdewey.com/atp@latest ``` ## Packages ### Root (`atp`) Core types and clients for the AT Protocol. - `Client` -- authenticated PDS client for CRUD operations on a user's repository (`CreateRecord`, `GetRecord`, `ListRecords`, `PutRecord`, `DeleteRecord`, `UploadBlob`, `GetBlob`). - `OAuthApp` -- manages the OAuth flow: login (browser-based and CLI), callback handling, session resumption, and logout. Supports public and localhost (development) client modes. - `PublicClient` -- unauthenticated access to public atproto APIs (handle resolution, profiles, record reads) with SSRF protection. - Helpers for AT-URI parsing/building, scope construction, and error handling. ### `jetstream` WebSocket consumer for the [Jetstream](https://docs.bsky.app/blog/jetstream) relay. Reconnects with exponential backoff, rotates endpoints, optionally decompresses zstd, and persists cursors for resuming after restarts. ### `middleware` Cookie-based AT Protocol auth middleware. Validates sessions against the OAuth store and injects the authenticated DID into the request context. Also serves the OAuth client metadata endpoint. ### `store/bolt` and `store/sqlite` Two `oauth.ClientAuthStore` implementations for persisting OAuth sessions and auth request state: - bolt: BoltDB-backed. - sqlite: SQLite-backed with automatic schema migration and expired request cleanup. ### `tracing` OpenTelemetry span helpers for AT Protocol operations (PDS calls, database operations, HTTP handlers). Sets up an OTLP HTTP exporter and returns no-op spans when there is no active trace context.