Documentation
¶
Index ¶
- Constants
- Variables
- func ConfigDirectory(plcHost, version string) identity.Directory
- func CreateRecord(ctx context.Context, client *atclient.APIClient, collection string, ...) (uri, cid string, err error)
- func DeleteRecord(ctx context.Context, client *atclient.APIClient, did, collection, rkey string) error
- func ExtractRkey(uri string) string
- func GetRecord(ctx context.Context, client *atclient.APIClient, did, collection, rkey string) (map[string]any, string, error)
- func LoadAuthClient(ctx context.Context, plcHost, version string) (*atclient.APIClient, error)
- func Login(ctx context.Context, username, password, pdsHost, plcHost, version string) (*atclient.APIClient, error)
- func LoginOrLoad(ctx context.Context, username, password, plcHost, version string) (*atclient.APIClient, error)
- func PersistAuthSession(sess *AuthSession) error
- func PutRecord(ctx context.Context, client *atclient.APIClient, did, collection, rkey string, ...) (string, error)
- func WipeAuthSession() error
- type AuthSession
- type BacklinkCounts
- type BacklinksResponse
- type BacklinksSummary
- type LinkingRecord
- type RecordEntry
Constants ¶
const ( CollectionActivity = "org.hypercerts.claim.activity" CollectionContributorInfo = "org.hypercerts.claim.contributorInformation" CollectionMeasurement = "org.hypercerts.claim.measurement" CollectionAttachment = "org.hypercerts.claim.attachment" CollectionCollection = "org.hypercerts.claim.collection" CollectionEvaluation = "org.hypercerts.claim.evaluation" CollectionRights = "org.hypercerts.claim.rights" CollectionFundingReceipt = "org.hypercerts.funding.receipt" CollectionWorkScopeTag = "org.hypercerts.helper.workScopeTag" CollectionLocation = "app.certified.location" )
ATProto collection NSIDs for Hypercerts record types.
const ConstellationBase = "https://constellation.microcosm.blue"
Variables ¶
var ErrNoAuthSession = errors.New("no auth session found")
ErrNoAuthSession is returned when no auth session file is found.
Functions ¶
func ConfigDirectory ¶
ConfigDirectory returns an identity directory configured with PLC host and user agent.
func CreateRecord ¶
func CreateRecord(ctx context.Context, client *atclient.APIClient, collection string, record map[string]any) (uri, cid string, err error)
CreateRecord creates a new record in the given collection. Always sets Validate: false for custom unpublished lexicons.
func DeleteRecord ¶
func DeleteRecord(ctx context.Context, client *atclient.APIClient, did, collection, rkey string) error
DeleteRecord deletes a record by DID, collection, and record key.
func ExtractRkey ¶
ExtractRkey extracts the record key (last segment) from an AT-URI.
func GetRecord ¶
func GetRecord(ctx context.Context, client *atclient.APIClient, did, collection, rkey string) (map[string]any, string, error)
GetRecord fetches a single record by DID, collection, and record key. Returns the record value, CID, and error.
func LoadAuthClient ¶
LoadAuthClient loads an auth client from the saved session.
func Login ¶
func Login(ctx context.Context, username, password, pdsHost, plcHost, version string) (*atclient.APIClient, error)
Login authenticates with a PDS using username and password.
func LoginOrLoad ¶
func LoginOrLoad(ctx context.Context, username, password, plcHost, version string) (*atclient.APIClient, error)
LoginOrLoad checks for username/password first, then falls back to loading a saved session.
func PersistAuthSession ¶
func PersistAuthSession(sess *AuthSession) error
PersistAuthSession saves the auth session to XDG state directory.
Types ¶
type AuthSession ¶
type AuthSession struct {
DID syntax.DID `json:"did"`
PDS string `json:"pds"`
Handle string `json:"handle"`
Password string `json:"password"`
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
}
AuthSession stores the authentication state. WARNING: The app password is stored in plaintext at ~/.local/state/hc/auth-session.json with 0600 permissions. This is required for automatic token refresh. Users should use ATProto app passwords (not their main password). TODO: Consider OS keychain integration for password storage.
func LoadAuthSessionFile ¶
func LoadAuthSessionFile() (*AuthSession, error)
LoadAuthSessionFile loads the auth session from XDG state directory.
type BacklinkCounts ¶
BacklinkCounts is the count of records and distinct DIDs for a specific collection+path.
type BacklinksResponse ¶
type BacklinksResponse struct {
Total int `json:"total"`
Cursor *string `json:"cursor"`
LinkingRecords []LinkingRecord `json:"linking_records"`
}
BacklinksResponse is the response from /links (paginated).
func GetBacklinks ¶
func GetBacklinks(ctx context.Context, target, collection, path string, cursor string, limit int) (*BacklinksResponse, error)
GetBacklinks returns a paginated list of records linking to the target for a specific collection and path.
type BacklinksSummary ¶
type BacklinksSummary struct {
Links map[string]map[string]BacklinkCounts `json:"links"`
}
BacklinksSummary is the response from /links/all.
func GetAllBacklinks ¶
func GetAllBacklinks(ctx context.Context, target string) (*BacklinksSummary, error)
GetAllBacklinks returns a summary of all records linking to the target (DID or AT-URI).
type LinkingRecord ¶
type LinkingRecord struct {
DID string `json:"did"`
Collection string `json:"collection"`
Rkey string `json:"rkey"`
}
LinkingRecord is a single record that links to the target.
func GetAllBacklinkRecords ¶
func GetAllBacklinkRecords(ctx context.Context, target, collection, path string) ([]LinkingRecord, error)
GetAllBacklinkRecords fetches all linking records for a target+collection+path, handling pagination.
type RecordEntry ¶
RecordEntry represents a single record from a listing.
func ListAllRecords ¶
func ListAllRecords(ctx context.Context, client *atclient.APIClient, did, collection string) ([]RecordEntry, error)
ListAllRecords fetches all records in a collection with cursor-based pagination.