-39
atproto/client/network_client.go
-39
atproto/client/network_client.go
···
1
-
package client
2
-
3
-
import (
4
-
"context"
5
-
"encoding/json"
6
-
"errors"
7
-
"io"
8
-
9
-
"github.com/bluesky-social/indigo/atproto/syntax"
10
-
)
11
-
12
-
// API for clients which pull data from the public atproto network.
13
-
//
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 NetworkClient interface {
16
-
// Fetches record JSON, without verification or validation. A version (CID) can optionally be specified; use empty string to fetch the latest.
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
-
GetRecordJSON(ctx context.Context, aturi syntax.ATURI, version syntax.CID) (*json.RawMessage, *syntax.CID, error)
19
-
20
-
// Fetches the indicated record as CBOR, and authenticates it by checking both the cryptographic signature and Merkle Tree hashes from the current repo revision. A version (CID) can optionally be specified; use empty string to fetch the latest.
21
-
// Returns the record as CBOR; the CID of the validated record, and the repo commit revision.
22
-
VerifyRecordCBOR(ctx context.Context, aturi syntax.ATURI, version syntax.CID) (*[]byte, *syntax.CID, string, error)
23
-
24
-
// Fetches repo export (CAR file). Optionally attempts to fetch only the diff "since" an earlier repo revision.
25
-
GetRepoCAR(ctx context.Context, did syntax.DID, since string) (*io.Reader, error)
26
-
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.ReadCloser, error)
29
-
GetAccountStatus(ctx context.Context, did syntax.DID) (*AccountStatus, error)
30
-
}
31
-
32
-
// XXX: type alias to codegen? or just copy? this is protocol-level
33
-
type AccountStatus struct {
34
-
}
35
-
36
-
func VerifyBlobCID(blob []byte, cid syntax.CID) error {
37
-
// XXX: compute hash, check against provided CID
38
-
return errors.New("Not Implemented")
39
-
}