Documentation ¶
Index ¶
- Constants
- func Validate(did string) error
- type AllowAllTenants
- type Authorization
- type AuthorizationDelegatedGrant
- type AuthorizationOwner
- type B
- type Blob
- type Cache
- type DID
- type DataCid
- type DataStore
- type DelegatedGrant
- type DelegatedGrantDescriptor
- type Descriptor
- type Did
- type DidMethodResolver
- type DidResolutionResult
- type DidResolver
- type Dwn
- type DwnConfig
- type DwnError
- type EqualFilter
- type Event
- type EventLog
- type EventLogCursor
- type F
- type Filter
- type FilterValue
- type GT
- type GTE
- type GeneralJws
- type HandlerRequest
- type I
- type IndexableKeyValues
- type IndexableValue
- type LT
- type LTE
- type MemoryCache
- type MemoryDatastore
- func (m *MemoryDatastore) Associate(Tenant, MessageCid, DataCid) (dataCid DataCid, dataSize int64, err error)
- func (m *MemoryDatastore) Clear() (err error)
- func (*MemoryDatastore) Close() error
- func (m *MemoryDatastore) Delete(Tenant, MessageCid, DataCid) (err error)
- func (m *MemoryDatastore) Get(Tenant, MessageCid, DataCid) (dataCid DataCid, dataSize int64, dataStream io.Reader, err error)
- func (*MemoryDatastore) Open() error
- func (m *MemoryDatastore) Put(tenant Tenant, messageCid MessageCid, dataCid DataCid, dataStream io.Reader) (resultCid DataCid, dataSize int64, err error)
- type MemoryEventLog
- func (*MemoryEventLog) Append(Tenant, MessageCid, IndexableKeyValues) (err error)
- func (l *MemoryEventLog) Clear() error
- func (*MemoryEventLog) Close() error
- func (*MemoryEventLog) DeleteEventsByCid(Tenant, []MessageCid) error
- func (*MemoryEventLog) GetEvents(Tenant) ([]string, error)
- func (*MemoryEventLog) Open() error
- func (*MemoryEventLog) QueryEvents(Tenant, []Filter, EventLogCursor) ([]string, error)
- type MemoryMessageStore
- func (m *MemoryMessageStore) Clear() (err error)
- func (*MemoryMessageStore) Close() error
- func (*MemoryMessageStore) Delete(Tenant, MessageCid) (err error)
- func (*MemoryMessageStore) Get(Tenant, MessageCid) (msg interface{}, err error)
- func (*MemoryMessageStore) Open() error
- func (*MemoryMessageStore) Put(Tenant, interface{}, IndexableKeyValues) (err error)
- func (*MemoryMessageStore) Query(tenant Tenant, filters []Filter, sort MessageSort, pagination Pagination) (err error)
- type Message
- type MessageCid
- type MessageHandler
- type MessageSort
- type MessageStore
- type MessagesGet
- type MethodHandler
- type OneOfFilter
- type Pagination
- type PermissionsGrant
- type PlainAuthorization
- type RangeFilter
- type RangeValue
- type RawDwnMessage
- type RecordsRead
- type RecordsWrite
- type S
- type ServiceEndpoint
- type Signature
- type SortDirection
- type StaticDidResolver
- type Status
- type StoredMessage
- type Tenant
- type TenantGate
- type UnionMessageReply
Constants ¶
const ( DidNotString = "DidNotString" DidNotValid = "DidNotValid" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AllowAllTenants ¶
type AllowAllTenants struct{}
type Authorization ¶
type Authorization interface {
// contains filtered or unexported methods
}
type AuthorizationDelegatedGrant ¶
type AuthorizationDelegatedGrant struct { Signature GeneralJws `json:"signature"` AuthorDelegatedGrant *DelegatedGrant `json:"authorDelegatedGrant"` }
func (*AuthorizationDelegatedGrant) Author ¶
func (m *AuthorizationDelegatedGrant) Author() string
type AuthorizationOwner ¶
type AuthorizationOwner struct { Signature GeneralJws `json:"signature"` OwnerSignature GeneralJws `json:"ownerSignature"` AuthorDelegatedGrant *DelegatedGrant `json:"authorDelegatedGrant,omitempty"` OwnerDelegatedGrant *DelegatedGrant `json:"ownerDelegatedGrant,omitempty"` }
type Cache ¶
type Cache interface { Get(key string) (DidResolutionResult, bool) Set(key string, value DidResolutionResult) }
Cache interface
type DataStore ¶
type DataStore interface { Open() error Close() error // Put a data blob into the data store. The DataCID is calculated from the // dataStream, and returned. If it doesn't match dataCid input, // an error results, and nothing is written. Put(tenant Tenant, messageCid MessageCid, dataCid DataCid, dataStream io.Reader) (resultCid DataCid, dataSize int64, err error) Get(Tenant, MessageCid, DataCid) (dataCid DataCid, dataSize int64, dataStream io.Reader, err error) Associate(Tenant, MessageCid, DataCid) (dataCid DataCid, dataSize int64, err error) Delete(Tenant, MessageCid, DataCid) (err error) // Test purposes Clear() (err error) }
func NewMemoryDatastore ¶
func NewMemoryDatastore() DataStore
type DelegatedGrant ¶
type DelegatedGrant struct { // Authorization -> Signature --- ?? Authorization PlainAuthorization `json:"authorization"` Descriptor DelegatedGrantDescriptor `json:"descriptor"` }
type Descriptor ¶
type Descriptor struct { // Required Interface string Method string DataCid DataCid DataSize int64 DateCreated string MessageTimestamp string DataFormat string Recipient DID Protocol string ProtocolPath string Schema string Tags map[string]interface{} ParentId MessageCid Published bool DatePublished string }
type Did ¶
type Did struct{}
func (*Did) GetMethodName ¶
GetMethodName gets the method name from a DID. ie. did:<method-name>:<method-specific-id>
func (*Did) GetMethodSpecificId ¶
GetMethodSpecificId gets the method specific ID segment of a DID. ie. did:<method-name>:<method-specific-id>
type DidMethodResolver ¶
type DidMethodResolver interface { Method() string Resolve(did string) (DidResolutionResult, error) }
DidMethodResolver interface
type DidResolutionResult ¶
type DidResolutionResult struct { DidDocument interface{} DidResolutionMetadata struct { Error string } }
DidResolutionResult struct
func FetchDidDocument ¶
func FetchDidDocument(url string) (DidResolutionResult, error)
FetchDidDocument fetches a DID document from a URL
func ParseDidDocument ¶
func ParseDidDocument(filePath string) (DidResolutionResult, error)
ParseDidDocument parses a DID document from a JSON file
type DidResolver ¶
type DidResolver struct {
// contains filtered or unexported fields
}
DidResolver struct
func NewDidResolver ¶
func NewDidResolver(resolvers []DidMethodResolver, cache Cache) *DidResolver
func NewStaticDidResolver ¶
func NewStaticDidResolver(didjson string) *DidResolver
func (*DidResolver) Resolve ¶
func (r *DidResolver) Resolve(did string) (DidResolutionResult, error)
func (*DidResolver) ResolveFromFile ¶
func (r *DidResolver) ResolveFromFile(filePath string) (DidResolutionResult, error)
func (*DidResolver) ResolveFromURL ¶
func (r *DidResolver) ResolveFromURL(url string) (DidResolutionResult, error)
type Dwn ¶
type Dwn struct {
// contains filtered or unexported fields
}
func (*Dwn) ProcessMessage ¶
type DwnConfig ¶
type DwnConfig struct { DidResolver *DidResolver TenantGate TenantGate MessageStore MessageStore DataStore DataStore EventLog EventLog BlockstoreLocation string // Add this field }
Update the DwnConfig struct
type EqualFilter ¶
type EqualFilter struct {
EqualTo IndexableValue
}
type EventLog ¶
type EventLog interface { Open() error Close() error Append(Tenant, MessageCid, IndexableKeyValues) (err error) GetEvents(Tenant) ([]string, error) QueryEvents(Tenant, []Filter, EventLogCursor) ([]string, error) DeleteEventsByCid(Tenant, []MessageCid) error // Test purposes Clear() error }
func NewMemoryEventLog ¶
func NewMemoryEventLog() EventLog
type EventLogCursor ¶
type EventLogCursor string
type Filter ¶
type Filter interface { // The property this filter is for Property() string Value() FilterValue }
A filter applies a given FilterValue to a given property.
type FilterValue ¶
type FilterValue interface {
// contains filtered or unexported methods
}
A Filter compares either:
- equality (exactly matches an indexable value)
- one of a list of equality
- a range filter, which is an operator and a RangeValue. The range value is a subset of indexable values: it's numbers and strings only.
type GTE ¶
type GTE struct {
GTE RangeValue
}
type GeneralJws ¶
type HandlerRequest ¶
type IndexableKeyValues ¶
type IndexableKeyValues map[string]IndexableValue
The storage calls take a map of string keys to values.
type IndexableValue ¶
type IndexableValue interface {
// contains filtered or unexported methods
}
Indexable values are string | number | boolean, but Go doesn't have 'sum' types or unions. This is the best alternative according to https://www.jerf.org/iri/post/2917/
type LT ¶
type LT struct {
LT RangeValue
}
type LTE ¶
type LTE struct {
LTE RangeValue
}
type MemoryCache ¶
type MemoryCache struct {
// contains filtered or unexported fields
}
MemoryCache struct
func NewMemoryCache ¶
func NewMemoryCache(expiry time.Duration) *MemoryCache
func (*MemoryCache) Get ¶
func (c *MemoryCache) Get(key string) (DidResolutionResult, bool)
func (*MemoryCache) Set ¶
func (c *MemoryCache) Set(key string, value DidResolutionResult)
type MemoryDatastore ¶
type MemoryDatastore struct {
// contains filtered or unexported fields
}
DataStore MemoryDatastore implements the DataStore interface using in-memory storage
func (*MemoryDatastore) Associate ¶
func (m *MemoryDatastore) Associate(Tenant, MessageCid, DataCid) (dataCid DataCid, dataSize int64, err error)
func (*MemoryDatastore) Clear ¶
func (m *MemoryDatastore) Clear() (err error)
func (*MemoryDatastore) Close ¶
func (*MemoryDatastore) Close() error
func (*MemoryDatastore) Delete ¶
func (m *MemoryDatastore) Delete(Tenant, MessageCid, DataCid) (err error)
func (*MemoryDatastore) Get ¶
func (m *MemoryDatastore) Get(Tenant, MessageCid, DataCid) (dataCid DataCid, dataSize int64, dataStream io.Reader, err error)
func (*MemoryDatastore) Open ¶
func (*MemoryDatastore) Open() error
type MemoryEventLog ¶
type MemoryEventLog struct {
// contains filtered or unexported fields
}
func (*MemoryEventLog) Append ¶
func (*MemoryEventLog) Append(Tenant, MessageCid, IndexableKeyValues) (err error)
func (*MemoryEventLog) Close ¶
func (*MemoryEventLog) Close() error
func (*MemoryEventLog) DeleteEventsByCid ¶
func (*MemoryEventLog) DeleteEventsByCid(Tenant, []MessageCid) error
func (*MemoryEventLog) Open ¶
func (*MemoryEventLog) Open() error
func (*MemoryEventLog) QueryEvents ¶
func (*MemoryEventLog) QueryEvents(Tenant, []Filter, EventLogCursor) ([]string, error)
type MemoryMessageStore ¶
type MemoryMessageStore struct {
// contains filtered or unexported fields
}
func (*MemoryMessageStore) Close ¶
func (*MemoryMessageStore) Close() error
func (*MemoryMessageStore) Delete ¶
func (*MemoryMessageStore) Delete(Tenant, MessageCid) (err error)
func (*MemoryMessageStore) Get ¶
func (*MemoryMessageStore) Get(Tenant, MessageCid) (msg interface{}, err error)
func (*MemoryMessageStore) Open ¶
func (*MemoryMessageStore) Open() error
func (*MemoryMessageStore) Put ¶
func (*MemoryMessageStore) Put(Tenant, interface{}, IndexableKeyValues) (err error)
func (*MemoryMessageStore) Query ¶
func (*MemoryMessageStore) Query(tenant Tenant, filters []Filter, sort MessageSort, pagination Pagination) (err error)
type MessageCid ¶
type MessageCid string
type MessageSort ¶
type MessageSort struct { DateCreated SortDirection DatePublished SortDirection MessageTimestamp SortDirection }
type MessageStore ¶
type MessageStore interface { // interface[} -> DwnMessage Put(Tenant, interface{}, IndexableKeyValues) (err error) Get(Tenant, MessageCid) (msg interface{}, err error) Query(tenant Tenant, filters []Filter, sort MessageSort, pagination Pagination) (err error) Delete(Tenant, MessageCid) (err error) // Test purposes Clear() (err error) Open() error Close() error }
func NewMemoryMessageStore ¶
func NewMemoryMessageStore() MessageStore
type MessagesGet ¶
type MessagesGet struct { Authorization PlainAuthorization `json:"authorization"` Descriptor struct { Interface string // const==Messages Method string // const==Get MessageTimestamp string MessageCids []string `json:"messageCids,omitempty"` } `json:"descriptor"` }
type MethodHandler ¶
type MethodHandler interface {
Handle(request *HandlerRequest) (UnionMessageReply, error)
}
type OneOfFilter ¶
type OneOfFilter struct {
OneOf []EqualFilter
}
type Pagination ¶
type PermissionsGrant ¶
type PermissionsGrant struct { }
type PlainAuthorization ¶
type PlainAuthorization struct {
Signature GeneralJws `json:"signature"`
}
func (*PlainAuthorization) Author ¶
func (m *PlainAuthorization) Author() string
type RangeFilter ¶
type RangeFilter interface { RangeValue() RangeValue // contains filtered or unexported methods }
A Range Filter is one of: - GT (some value) - LT (some value) - GTE (some value) - LTE (some value)
The value is a subset of indexable values, since you can't do a meaningful comparison on booleans.
type RangeValue ¶
type RangeValue interface {
// contains filtered or unexported methods
}
A range value is: `string | number` numbers are either float64 or int64.
type RawDwnMessage ¶
type RawDwnMessage map[string]interface{}
A Raw Dwn message is just a parsed JSON placeholder.
type RecordsRead ¶
type RecordsRead struct { Authorization AuthorizationDelegatedGrant `json:"authorization"` Descriptor struct { Interface string Method string // iso timestamp MessageTimestamp string // TODO make this properly typed. Filter map[string]interface{} } `json:"descriptor"` }
type RecordsWrite ¶
type RecordsWrite struct { // These three are required RecordId string `json:"recordId"` Authorization AuthorizationOwner `json:"authorization"` Descriptor Descriptor `json:"descriptor"` ContextId string `json:"contextId,omitempty"` Attestation GeneralJws `json:"attestation,omitempty"` Encryption struct { Algorithm string `json:"algorithm"` InitializationVector string `json:"initializationVector"` KeyEncryption []struct { RootKeyId string // string-based enum of: // dataFormats | protocolContext | protocolPath | schemas DerivationScheme string DerivedPublicKey map[string]interface{} Algorithm string EncryptedKey string InitializationVector string EmphemeralPublicKey map[string]interface{} MessageAuthenticationCode string } `json:"keyEncryption"` } `json:"encryption"` }
func (*RecordsWrite) Handle ¶
func (message *RecordsWrite) Handle(dwn *Dwn) error
type ServiceEndpoint ¶
type SortDirection ¶
type SortDirection int
Sort options
const ( // these values are from query-types.ts Descending SortDirection = -1 Ascending SortDirection = 1 )
type StaticDidResolver ¶
type StaticDidResolver struct {
// contains filtered or unexported fields
}
DID Resolver for test purposes
func (StaticDidResolver) Method ¶
func (o StaticDidResolver) Method() string
func (StaticDidResolver) Resolve ¶
func (o StaticDidResolver) Resolve(did string) (DidResolutionResult, error)
type StoredMessage ¶
type StoredMessage struct { Authorization map[string]interface{} Descriptor map[string]interface{} }
What are we storing in the MessageStore? What's in the DwnMessage?
type TenantGate ¶
func NewAllowAllTenantGate ¶
func NewAllowAllTenantGate() TenantGate
type UnionMessageReply ¶
type UnionMessageReply struct {
Status Status
}