From 903399247010bfff10d55177a9f1195f8717b710 Mon Sep 17 00:00:00 2001 From: Thomas Rademaker Date: Sat, 7 Feb 2026 18:31:45 -0500 Subject: [PATCH] updated readme --- README.md | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1fe7296..c5b7a72 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ CoreATProtocol is designed to be protocol-agnostic within the AT Protocol ecosys - **Modern Swift Concurrency** - Built with Swift 6.2 using async/await and actors for thread-safe operations - **Global Actor Isolation** - Uses `@APActor` for consistent thread safety across all AT Protocol operations - **Flexible Network Routing** - Generic `NetworkRouter` that works with any endpoint conforming to `EndpointType` +- **ATProto OAuth** - First-party OAuth client with DPoP, PAR, issuer validation, and identity resolution (handle or DID) - **Automatic Token Management** - Built-in support for JWT access/refresh token handling with automatic retry on expiration - **Multiple Parameter Encodings** - URL, JSON, and combined encoding strategies for request parameters - **AT Protocol Error Handling** - Typed error responses matching AT Protocol error specifications @@ -19,7 +20,7 @@ CoreATProtocol is designed to be protocol-agnostic within the AT Protocol ecosys ## Requirements - Swift 6.2+ -- iOS 26.0+ / macOS 26.0+ / watchOS 26.0+ / tvOS 26.0+ / Mac Catalyst 26.0+ +- iOS 17.0+ / macOS 14.0+ / watchOS 11.0+ / tvOS 17.0+ / Mac Catalyst 17.0+ ## Installation @@ -70,6 +71,34 @@ await updateTokens(access: newAccessToken, refresh: newRefreshToken) await update(hostURL: "https://different-pds.example") ``` +### OAuth Authentication + +Use `ATProtoOAuth` for OAuth login flows: + +```swift +import CoreATProtocol + +let oauth = await ATProtoOAuth( + config: .init( + clientMetadataURL: "https://example.com/client-metadata.json", + redirectURI: "com.example.app:/oauth/callback" + ), + storage: .init( + retrieveLogin: { nil }, + storeLogin: { _ in }, + retrievePrivateKey: { nil }, + storePrivateKey: { _ in } + ) +) + +let result = try await oauth.authenticate(identifier: "alice.bsky.social") { authURL, _ in + // Present authURL to the user and return callback URL. + fatalError("Implement user-auth callback handling") +} + +await setup(hostURL: result.pdsEndpoint, accessJWT: result.accessToken, refreshJWT: result.refreshToken) +``` + ### Defining Endpoints Create endpoints by conforming to `EndpointType`: -- 2.51.2