···11+package netclient
22+33+import (
44+ "context"
55+ "encoding/json"
66+ "errors"
77+ "io"
88+99+ "github.com/bluesky-social/indigo/atproto/syntax"
1010+)
1111+1212+// API for clients which pull data from the public atproto network.
1313+//
1414+// 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.
1515+type NetworkClient interface {
1616+ // Fetches record JSON, without verification or validation. A version (CID) can optionally be specified; use empty string to fetch the latest.
1717+ // 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.
1818+ GetRecordJSON(ctx context.Context, aturi syntax.ATURI, version syntax.CID) (*json.RawMessage, *syntax.CID, error)
1919+2020+ // 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.
2121+ // Returns the record as CBOR; the CID of the validated record, and the repo commit revision.
2222+ VerifyRecordCBOR(ctx context.Context, aturi syntax.ATURI, version syntax.CID) (*[]byte, *syntax.CID, string, error)
2323+2424+ // Fetches repo export (CAR file). Optionally attempts to fetch only the diff "since" an earlier repo revision.
2525+ GetRepoCAR(ctx context.Context, did syntax.DID, since string) (*io.Reader, error)
2626+2727+ // Fetches indicated blob. Does not validate the CID. Returns a reader (which calling code is responsible for closing).
2828+ GetBlob(ctx context.Context, did syntax.DID, cid syntax.CID) (*io.ReadCloser, error)
2929+ GetAccountStatus(ctx context.Context, did syntax.DID) (*AccountStatus, error)
3030+}
3131+3232+// XXX: type alias to codegen? or just copy? this is protocol-level
3333+type AccountStatus struct {
3434+}
3535+3636+func VerifyBlobCID(blob []byte, cid syntax.CID) error {
3737+ // XXX: compute hash, check against provided CID
3838+ return errors.New("Not Implemented")
3939+}