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 AuthAttrInstance
- func (a *AuthAttrInstance) AddRelationship(cid, relType, relationType, relCid string) error
- func (a *AuthAttrInstance) AppendAttestation(cid, attr string, val any) error
- func (a *AuthAttrInstance) GetAttestation(cid, attr string, opts GetAttOpts) (*AttEntry, error)
- func (a *AuthAttrInstance) GetAttestationRaw(cid, attr string, opts GetAttOpts) ([]byte, error)
- func (a *AuthAttrInstance) GetAttestations(cid string) (map[string]*AttEntry, error)
- func (a *AuthAttrInstance) GetCIDs() ([]string, error)
- func (a *AuthAttrInstance) IndexListQuery(attr string) ([]string, error)
- func (a *AuthAttrInstance) IndexMatchQuery(attr, val, valType string) ([]string, error)
- func (a *AuthAttrInstance) SetAttestations(cid string, index bool, kvs []PostKV) error
- 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-v1relcid
func AppendAttestation ¶
AppendAttestation appends to an array stored at attr.
See https://github.com/starlinglab/authenticated-attributes/blob/main/docs/http.md#post-v1ccidattr
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-v1i
Types ¶
type AttEntry ¶
type AttEntry struct { Signature struct { PubKey []byte `json:"pubKey"` Sig []byte `json:"sig"` Msg CborCID `json:"msg"` } `json:"signature"` Timestamp struct { OTS struct { Proof []byte `json:"proof"` Upgraded bool `json:"upgraded"` Msg CborCID `json:"msg"` } `json:"ots"` } `json:"timestamp"` Attestation struct { CID CborCID `json:"CID"` Value any `json:"value"` Attribute string `json:"attribute"` Encrypted bool `json:"encrypted"` Timestamp time.Time `json:"timestamp"` } `json:"attestation"` Version string `json:"version"` }
Attestation as stored in the database in DAG-CBOR. See https://github.com/starlinglab/authenticated-attributes/blob/main/docs/database.md#schema
This may not encode into the same CBOR it was decoded from, but that's okay as that should not be 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 AuthAttrInstance ¶
type AuthAttrInstance struct { Url string Jwt string Mock bool // No network requests go through if true }
func GetAAInstanceFromConfig ¶
func GetAAInstanceFromConfig() *AuthAttrInstance
func (*AuthAttrInstance) AddRelationship ¶
func (a *AuthAttrInstance) AddRelationship(cid, relType, relationType, relCid string) error
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-v1relcid
func (*AuthAttrInstance) AppendAttestation ¶
func (a *AuthAttrInstance) AppendAttestation(cid, attr string, val any) error
AppendAttestation appends to an array stored at attr.
See https://github.com/starlinglab/authenticated-attributes/blob/main/docs/http.md#post-v1ccidattr
func (*AuthAttrInstance) GetAttestation ¶
func (a *AuthAttrInstance) 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.
func (*AuthAttrInstance) GetAttestationRaw ¶
func (a *AuthAttrInstance) 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 (*AuthAttrInstance) GetAttestations ¶
func (a *AuthAttrInstance) GetAttestations(cid string) (map[string]*AttEntry, error)
GetAttestations returns all attestations for the provided CID from AA.
func (*AuthAttrInstance) GetCIDs ¶
func (a *AuthAttrInstance) GetCIDs() ([]string, error)
GetCIDs returns a slice of all the CIDs stored in the database, as strings.
func (*AuthAttrInstance) IndexListQuery ¶
func (a *AuthAttrInstance) IndexListQuery(attr string) ([]string, error)
IndexListQuery queries the AA index for any values that have been indexed for the given attribute.
func (*AuthAttrInstance) IndexMatchQuery ¶
func (a *AuthAttrInstance) IndexMatchQuery(attr, val, valType string) ([]string, error)
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-v1i
func (*AuthAttrInstance) SetAttestations ¶
func (a *AuthAttrInstance) SetAttestations(cid string, index bool, kvs []PostKV) error
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.