Documentation
¶
Overview ¶
Package aa provides Go functions to access the Authenticated Attributes API.
Index ¶
- Variables
- func AddRelationship(cid, relType, relationType, relCid string) error
- func AppendAttestation(cid, attr string, val any) error
- func GetAttestationRaw(cid, attr string, opts GetAttOpts) ([]byte, error)
- func GetAttestations(cid string) (map[string]*AttEntry, error)
- func GetCIDs() ([]string, error)
- func IndexListQuery(attr string) ([]string, error)
- func IndexMatchQuery(attr, val, valType string) ([]string, error)
- func SetAttestations(cid string, index bool, kvs []PostKV) error
- type AttEntry
- type CborCID
- type GetAttOpts
- type PostKV
Constants ¶
This section is empty.
Variables ¶
var ( ErrNeedsKey = errors.New("needs encryption key") ErrNotFound = errors.New("requested item not found") )
Functions ¶
func AddRelationship ¶
AddRelationship adds a relationship to the database.
relType must be either "children" or "parents".
relationType is the adjective to use, like "related".
See AA docs for details: https://github.com/starlinglab/authenticated-attributes/blob/main/docs/http.md#post-relcid
func AppendAttestation ¶
AppendAttestation appends to an array stored at attr.
See https://github.com/starlinglab/authenticated-attributes/blob/main/docs/http.md#post-ccidattr
func GetAttestationRaw ¶
func GetAttestationRaw(cid, attr string, opts GetAttOpts) ([]byte, error)
GetAttestationRaw returns the raw bytes for the attribute from AA.
If an encryption key was needed (to decrypt value for sig verify) but not provided a ErrNeedsKey is returned. ErrNotFound is returned if the CID-attribute pair doesn't exist in the database.
func GetAttestations ¶
GetAttestations returns all attestations for the provided CID from AA.
func IndexListQuery ¶
IndexListQuery queries the AA index for any values that have been indexed for the given attribute.
func IndexMatchQuery ¶
IndexMatchQuery queries the AA index for any CIDs with the provided attribute-value pair. See the API docs for more information: https://github.com/starlinglab/authenticated-attributes/blob/main/docs/http.md#get-i
Types ¶
type AttEntry ¶
type AttEntry struct {
Signature struct {
PubKey [32]byte
Sig [64]byte
Msg CborCID
}
Timestamp struct {
OTS struct {
Proof []byte
Upgraded bool
Msg CborCID
}
}
Attestation struct {
CID CborCID
Value any
Encrypted bool
Timestamp time.Time
}
Version string
}
Attestation as stored in the database in DAG-CBOR. See https://github.com/starlinglab/authenticated-attributes/blob/main/docs/database.md#schema
This does not encode into the same CBOR it was decoded from, but that's okay as encoding this struct should be not required anywhere.
func GetAttestation ¶
func GetAttestation(cid, attr string, opts GetAttOpts) (*AttEntry, error)
GetAttestation returns the attestation for the provided attribute from AA.
If an encryption key was needed (to decrypt value for sig verify) but not provided a ErrNeedsKey is returned. ErrNotFound is returned if the CID-attribute pair doesn't exist in the database.
The Format fields of `opts` is ignored.
type CborCID ¶
type CborCID []byte
CborCID is a CIDv1 as it is encoded in the DAG-CBOR format.
This is not the same as just the bytes of a CIDv1. See https://ipld.io/specs/codecs/dag-cbor/spec/#links and https://github.com/ipld/cid-cbor
func NewCborCID ¶
NewCborCID takes in a base32 CIDv1 and returns a CborCID, valid for encoding CIDs in DAG-CBOR.
The input CID string is not fully validated and so it is possible for this function to output invalid values.
func (CborCID) MarshalJSON ¶
MarshalJSON fulfills the json.Marshaler interface.
It looks like CID(bafy...) which indicates that the value was originally stored in binary rather than a native JSON or string encoding.