this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

tweak client SDK interfaces

+9 -22
+1 -4
atproto/client/auth_method.go
··· 2 2 3 3 import ( 4 4 "net/http" 5 - 6 - "github.com/bluesky-social/indigo/atproto/syntax" 7 5 ) 8 6 9 7 type AuthMethod interface { 10 - DoWithAuth(httpReq *http.Request, httpClient *http.Client) (*http.Response, error) 11 - AccountDID() syntax.DID 8 + DoWithAuth(req *http.Request, c *http.Client) (*http.Response, error) 12 9 }
+3 -8
atproto/client/refresh_auth.go
··· 24 24 // TODO: 25 25 //func NewRefreshAuth(pdsHost, accountIdentifier, password string) (*RefreshAuth, error) { 26 26 27 - func (a *RefreshAuth) DoWithAuth(httpReq *http.Request, httpClient *http.Client) (*http.Response, error) { 28 - httpReq.Header.Set("Authorization", "Bearer "+a.AccessToken) 27 + func (a *RefreshAuth) DoWithAuth(req *http.Request, c *http.Client) (*http.Response, error) { 28 + req.Header.Set("Authorization", "Bearer "+a.AccessToken) 29 29 // XXX: check response. if it is 403, because access token is expired, then take a lock and do a refresh 30 30 // TODO: when doing a refresh request, copy at least the User-Agent header from httpReq, and re-use httpClient 31 - return httpClient.Do(httpReq) 32 - } 33 - 34 - // Admin bearer token auth does not involve an account DID 35 - func (a *RefreshAuth) AccountDID() syntax.DID { 36 - return a.DID 31 + return c.Do(httpReq) 37 32 } 38 33 39 34 // updates the client with the new auth method
+2 -7
atproto/client/service_auth.go
··· 27 27 } 28 28 } 29 29 30 - func (a *ServiceAuth) DoWithAuth(req *http.Request, httpClient *http.Client) (*http.Response, error) { 30 + func (a *ServiceAuth) DoWithAuth(req *http.Request, c *http.Client) (*http.Response, error) { 31 31 // TODO: detect audience from request headers (atproto-proxy) 32 32 // TODO: extract endpoint (LXM) from request 33 33 34 34 thing := "" 35 35 req.Header.Set("Authorization", "Bearer "+thing) 36 - return httpClient.Do(req) 37 - } 38 - 39 - // Admin bearer token auth does not involve an account DID 40 - func (a *ServiceAuth) AccountDID() syntax.DID { 41 - return a.Issuer 36 + return c.Do(req) 42 37 }
+3 -3
atproto/client/sync_client.go atproto/client/network_client.go
··· 12 12 // API for clients which pull data from the public atproto network. 13 13 // 14 14 // Implementations of this interface might resolve PDS instances for DIDs, and fetch data from there. Or they might talk to an archival relay or other network mirroring service. 15 - type SyncClient interface { 15 + type NetworkClient interface { 16 16 // Fetches record JSON, without verification or validation. A version (CID) can optionally be specified; use empty string to fetch the latest. 17 17 // Returns the record as JSON, and the CID indicated by the server. Does not verify that the data (as CBOR) matches the CID, and does not cryptographically verify a "proof chain" to the record. 18 18 GetRecordJSON(ctx context.Context, aturi syntax.ATURI, version syntax.CID) (*json.RawMessage, *syntax.CID, error) ··· 25 25 GetRepoCAR(ctx context.Context, did syntax.DID, since string) (*io.Reader, error) 26 26 27 27 // Fetches indicated blob. Does not validate the CID. Returns a reader (which calling code is responsible for closing). 28 - GetBlob(ctx context.Context, did syntax.DID, cid syntax.CID) (*io.Reader, error) 29 - CheckAccountStatus(ctx context.Context, did syntax.DID) (*AccountStatus, error) 28 + GetBlob(ctx context.Context, did syntax.DID, cid syntax.CID) (*io.ReadCloser, error) 29 + GetAccountStatus(ctx context.Context, did syntax.DID) (*AccountStatus, error) 30 30 } 31 31 32 32 // XXX: type alias to codegen? or just copy? this is protocol-level