Main coves client
1# Implementation Plan: atproto_oauth_flutter
2
3## Overview
41:1 port of `@atproto/oauth-client` from TypeScript to Dart/Flutter
5
6**Source:** `/home/bretton/Code/atproto/packages/oauth/oauth-client/`
7**Target:** `/home/bretton/Code/coves_flutter/packages/atproto_oauth_flutter/`
8
9## Implementation Chunks
10
11### Chunk 1: Foundation Layer ✅
12**Files to port:**
13- `src/constants.ts` → `lib/src/constants.dart`
14- `src/types.ts` → `lib/src/types.dart`
15- `src/errors/*.ts` → `lib/src/errors/*.dart`
16- `src/util.ts` → `lib/src/util.dart`
17
18**Dependencies:** None (pure types and utilities)
19**Estimated LOC:** ~300 lines
20
21### Chunk 2: Crypto & DPoP Layer
22**Files to port:**
23- `src/runtime-implementation.ts` → `lib/src/runtime/runtime_implementation.dart`
24- `src/runtime.ts` → `lib/src/runtime/runtime.dart`
25- `src/fetch-dpop.ts` → `lib/src/dpop/fetch_dpop.dart`
26- `src/lock.ts` → `lib/src/utils/lock.dart`
27
28**Dependencies:** Chunk 1 (types, errors)
29**Dart packages:** `crypto`, `pointycastle`, `convert`
30**Estimated LOC:** ~500 lines
31
32### Chunk 3: Identity Resolution
33**Files to port:**
34- `src/identity-resolver.ts` → `lib/src/identity/identity_resolver.dart`
35
36**Dependencies:** Chunk 1, Chunk 2
37**Estimated LOC:** ~200 lines
38
39### Chunk 4: OAuth Protocol Layer
40**Files to port:**
41- `src/oauth-authorization-server-metadata-resolver.ts` → `lib/src/oauth/authorization_server_metadata_resolver.dart`
42- `src/oauth-protected-resource-metadata-resolver.ts` → `lib/src/oauth/protected_resource_metadata_resolver.dart`
43- `src/oauth-resolver.ts` → `lib/src/oauth/oauth_resolver.dart`
44- `src/oauth-client-auth.ts` → `lib/src/oauth/client_auth.dart`
45- `src/validate-client-metadata.ts` → `lib/src/oauth/validate_client_metadata.dart`
46- `src/oauth-callback-error.ts` → `lib/src/errors/oauth_callback_error.dart`
47- `src/oauth-resolver-error.ts` → `lib/src/errors/oauth_resolver_error.dart`
48- `src/oauth-response-error.ts` → `lib/src/errors/oauth_response_error.dart`
49
50**Dependencies:** Chunk 1, Chunk 2, Chunk 3
51**Estimated LOC:** ~800 lines
52
53### Chunk 5: Session Management
54**Files to port:**
55- `src/session-getter.ts` → `lib/src/session/session_getter.dart`
56- `src/state-store.ts` → `lib/src/session/state_store.dart`
57- `src/oauth-session.ts` → `lib/src/session/oauth_session.dart`
58
59**Dependencies:** Chunk 1, Chunk 2
60**Estimated LOC:** ~400 lines
61
62### Chunk 6: Core OAuth Client
63**Files to port:**
64- `src/oauth-server-agent.ts` → `lib/src/client/oauth_server_agent.dart`
65- `src/oauth-server-factory.ts` → `lib/src/client/oauth_server_factory.dart`
66- `src/oauth-client.ts` → `lib/src/client/oauth_client.dart`
67
68**Dependencies:** All previous chunks
69**Estimated LOC:** ~700 lines
70
71### Chunk 7: Flutter Platform Layer (NEW)
72**Files to create:**
73- `lib/src/platform/flutter_stores.dart` - Secure storage implementations
74- `lib/src/platform/flutter_runtime.dart` - Flutter crypto implementations
75- `lib/src/platform/flutter_oauth_client.dart` - Flutter-specific client
76- `lib/atproto_oauth_flutter.dart` - Main export file
77
78**Dependencies:** All previous chunks, Flutter packages
79**Estimated LOC:** ~300 lines
80
81## Agent Execution Plan
82
83Each chunk will be implemented by a sub-agent with:
841. **Implementation Agent** - Ports TypeScript to Dart
852. **Review Agent** - Reviews for bugs, best practices, API compatibility
86
87## Success Criteria
88
89- [ ] All TypeScript files ported to Dart
90- [ ] API matches Expo package (same method signatures)
91- [ ] Zero compilation errors
92- [ ] Proper decentralization (PDS discovery works)
93- [ ] Works with bretton.dev (custom PDS)
94
95## Testing Plan
96
97After all chunks complete:
981. Unit tests for each module
992. Integration test with bretton.dev
1003. Integration test with bsky.social
1014. Session persistence test
1025. Token refresh test