Documentation ¶
Index ¶
- Constants
- Variables
- func Dump(o Object, skipKeys ...string) string
- func Normalize(i interface{}) (map[string]interface{}, error)
- func NormalizeData(i interface{}) ([]byte, error)
- func SortHashSlice(h []Hash)
- func Traverse(v Value, f func(string, Value) bool)
- func UnloadReferences(ctx context.Context, obj Object) (result *Object, unloaded []Object, err error)
- func Verify(o Object) error
- type Bool
- type Bytes
- func (v Bytes) Hash() Hash
- func (v Bytes) IsBool() bool
- func (v Bytes) IsBytes() bool
- func (v Bytes) IsFloat() bool
- func (v Bytes) IsInt() bool
- func (v Bytes) IsList() bool
- func (v Bytes) IsMap() bool
- func (v Bytes) IsRef() bool
- func (v Bytes) IsString() bool
- func (v Bytes) PrimitiveHinted() interface{}
- type Certificate
- type CertificateRequest
- type Float
- func (v Float) Hash() Hash
- func (v Float) IsBool() bool
- func (v Float) IsBytes() bool
- func (v Float) IsFloat() bool
- func (v Float) IsInt() bool
- func (v Float) IsList() bool
- func (v Float) IsMap() bool
- func (v Float) IsRef() bool
- func (v Float) IsString() bool
- func (v Float) PrimitiveHinted() interface{}
- type Getter
- type GetterFunc
- type Hash
- type Int
- type List
- func (l List) Append(v Value) List
- func (l List) Get(index int) Value
- func (v List) Hash() Hash
- func (v List) IsBool() bool
- func (v List) IsBytes() bool
- func (v List) IsFloat() bool
- func (v List) IsInt() bool
- func (v List) IsList() bool
- func (v List) IsMap() bool
- func (v List) IsRef() bool
- func (v List) IsString() bool
- func (l List) Iterate(f func(int, Value) bool)
- func (l List) Length() (n int)
- func (l List) PrimitiveHinted() interface{}
- func (l List) Set(path string, v Value) List
- type Map
- func (v Map) Hash() Hash
- func (v Map) IsBool() bool
- func (v Map) IsBytes() bool
- func (m Map) IsEmpty() bool
- func (v Map) IsFloat() bool
- func (v Map) IsInt() bool
- func (v Map) IsList() bool
- func (v Map) IsMap() bool
- func (v Map) IsRef() bool
- func (v Map) IsString() bool
- func (m Map) Iterate(f func(k string, v Value) bool)
- func (m Map) PrimitiveHinted() interface{}
- func (m Map) Set(path string, v Value) Map
- func (m Map) Value(path string) Value
- type Metadata
- type Object
- func (o Object) Get(k string) interface{}
- func (o Object) GetOwner() crypto.PublicKey
- func (o Object) GetParents() []Hash
- func (o Object) GetPolicy() Policy
- func (o Object) GetSignature() Signature
- func (o Object) GetStream() Hash
- func (o Object) GetType() string
- func (o Object) Hash() Hash
- func (o Object) IsEmpty() bool
- func (o Object) Raw() Map
- func (o Object) Set(k string, v interface{}) Object
- func (o Object) SetOwner(owner crypto.PublicKey) Object
- func (o Object) SetParents(hashes []Hash) Object
- func (o Object) SetPolicy(policy Policy) Object
- func (o Object) SetSignature(signature Signature) Object
- func (o Object) SetStream(v Hash) Object
- func (o Object) SetType(v string) Object
- func (o Object) ToMap() map[string]interface{}
- func (o Object) ToObject() Object
- type ParsedType
- type Policy
- type ReadCloser
- type Reader
- type Ref
- type Request
- type Response
- type SchemaObject
- type SchemaProperty
- type Signature
- type String
- func (v String) Hash() Hash
- func (v String) IsBool() bool
- func (v String) IsBytes() bool
- func (v String) IsFloat() bool
- func (v String) IsInt() bool
- func (v String) IsList() bool
- func (v String) IsMap() bool
- func (v String) IsRef() bool
- func (v String) IsString() bool
- func (v String) PrimitiveHinted() interface{}
- type TypeHint
- type Value
Constants ¶
const ( ErrInvalidSigner = errors.Error("signer is does not match owner") ErrMissingSignature = errors.Error("missing signature") ErrCouldNotVerify = errors.Error("could not verify signature") )
const (
// AlgorithmObjectHash for creating ObjectHash+ES256 based signatures
AlgorithmObjectHash = "OH_ES256"
)
const (
ErrNoSignature = errors.Error("object has no signature")
)
const (
ErrReaderDone = errors.Error("reader done")
)
Variables ¶
var ( // ErrInvalidObjectType is returned when the signature being verified // is not an encoded object of type "signature". ErrInvalidObjectType = errors.New("invalid object type") // ErrAlgorithNotImplemented is returned when the algorithm specified // has not been implemented ErrAlgorithNotImplemented = errors.New("algorithm not implemented") )
var (
ErrTimeout = errors.New("timeout")
)
Functions ¶
func Normalize ¶ added in v0.5.0
Normalize maps to get them ready to be used as objects. This is supposed to convert a map's values into something more usable by using the type hints from the key as guide. A lot of what this does is due to the types go's JSON unmarshaller uses when unmarshalling into an `interface{}`. More info about this here: https://golang.org/pkg/encoding/json/#Unmarshal
For example: * `"some-data:d": []float64{1, 2}` becomes `"some-data:d": []byte{1, 2}` * `"some-data:d": "AQI="` becomes `"some-data:d": []byte{1, 2}` * `"some-int:i": float64(7)` becomes `"some-int:i": uint64(7)` * `"some-int:i": "7"` becomes `"some-int:i": uint64(7)`
NOTE: This should work for the most part but needs additional testing.
func NormalizeData ¶ added in v0.5.0
func SortHashSlice ¶ added in v0.11.0
func SortHashSlice(h []Hash)
func UnloadReferences ¶ added in v0.11.0
Types ¶
type Bool ¶ added in v0.10.0
type Bool bool
func (Bool) PrimitiveHinted ¶ added in v0.10.0
func (v Bool) PrimitiveHinted() interface{}
type Bytes ¶ added in v0.10.0
type Bytes []byte
func (Bytes) PrimitiveHinted ¶ added in v0.10.0
func (v Bytes) PrimitiveHinted() interface{}
type Certificate ¶ added in v0.5.0
type Certificate struct { Metadata Metadata Nonce string Created string Expires string // contains filtered or unexported fields }
func NewCertificate ¶ added in v0.5.0
func NewCertificate( subject crypto.PublicKey, issuer crypto.PrivateKey, ) (*Certificate, error)
func NewCertificateSelfSigned ¶ added in v0.11.0
func NewCertificateSelfSigned(k crypto.PrivateKey) (*Certificate, error)
func (*Certificate) FromObject ¶ added in v0.5.0
func (e *Certificate) FromObject(o Object) error
func (Certificate) GetSchema ¶ added in v0.5.0
func (e Certificate) GetSchema() *SchemaObject
func (Certificate) GetType ¶ added in v0.5.0
func (e Certificate) GetType() string
func (Certificate) IsStreamRoot ¶ added in v0.11.0
func (e Certificate) IsStreamRoot() bool
func (Certificate) ToObject ¶ added in v0.5.0
func (e Certificate) ToObject() Object
type CertificateRequest ¶ added in v0.11.0
type CertificateRequest struct { Metadata Metadata ApplicationName string ApplicationDescription string ApplicationURL string Subject string Resources []string Actions []string Nonce string // contains filtered or unexported fields }
func (*CertificateRequest) FromObject ¶ added in v0.11.0
func (e *CertificateRequest) FromObject(o Object) error
func (CertificateRequest) GetSchema ¶ added in v0.11.0
func (e CertificateRequest) GetSchema() *SchemaObject
func (CertificateRequest) GetType ¶ added in v0.11.0
func (e CertificateRequest) GetType() string
func (CertificateRequest) IsStreamRoot ¶ added in v0.11.0
func (e CertificateRequest) IsStreamRoot() bool
func (CertificateRequest) ToObject ¶ added in v0.11.0
func (e CertificateRequest) ToObject() Object
type Float ¶ added in v0.10.0
type Float float64
func (Float) PrimitiveHinted ¶ added in v0.10.0
func (v Float) PrimitiveHinted() interface{}
type GetterFunc ¶ added in v0.11.0
GetterFunc is an adapter to allow the use of ordinary functions as object.Getter
type Int ¶ added in v0.10.0
type Int int64
func (Int) PrimitiveHinted ¶ added in v0.10.0
func (v Int) PrimitiveHinted() interface{}
type List ¶ added in v0.10.0
type List struct {
// contains filtered or unexported fields
}
func (List) PrimitiveHinted ¶ added in v0.10.0
func (l List) PrimitiveHinted() interface{}
type Map ¶ added in v0.10.0
type Map struct {
// contains filtered or unexported fields
}
func (Map) PrimitiveHinted ¶ added in v0.10.0
func (m Map) PrimitiveHinted() interface{}
type Metadata ¶ added in v0.11.0
type Metadata struct { Owner crypto.PublicKey `json:"owner"` Parents []Hash `json:"parents"` Policy Policy `json:"policy"` Signature Signature `json:"_signature"` Stream Hash `json:"stream"` }
Metadata for object
type Object ¶
type Object Map
Object for everything f12n
func Collapse ¶ added in v0.11.0
Collapse the object's immutable values into a single layer in order to reduce its complexity. Most usually used for tests.
func LoadReferences ¶ added in v0.11.0
LoadReferences will look for references in the given object, request the referred objects using the getter, and will replace the references with the actual object before returning the complete
func (Object) GetParents ¶
func (Object) GetSignature ¶
func (Object) SetParents ¶
func (Object) SetSignature ¶
type ParsedType ¶ added in v0.11.0
func ParseType ¶ added in v0.11.0
func ParseType(objectType string) ParsedType
type Policy ¶
type Policy struct { Subjects []string `json:"subjects:as,omitempty" mapstructure:"subjects:as,omitempty"` Resources []string `json:"resources:as,omitempty" mapstructure:"resources:as,omitempty"` Actions []string `json:"actions:as,omitempty" mapstructure:"actions:as,omitempty"` Effect string `json:"effect:s,omitempty" mapstructure:"effect:s,omitempty"` }
Policy for object metadata
type ReadCloser ¶ added in v0.11.0
func FetchWithReferences ¶ added in v0.11.0
func FetchWithReferences( ctx context.Context, getter GetterFunc, objectHash Hash, ) (ReadCloser, error)
FetchWithReferences will look for references in the given object, request the primary object and all referred objects using the getter, and will return them in a lazy loaded result.
func NewReadCloser ¶ added in v0.11.0
func NewReadCloser( ctx context.Context, objects <-chan *Object, errs <-chan error, closer chan<- struct{}, ) ReadCloser
func NewReadCloserFromObjects ¶ added in v0.11.0
func NewReadCloserFromObjects(objects []Object) ReadCloser
NewReadCloserFromObjects is mainly used for testing and mocks that return a Reader, or ReadCloser.
type Ref ¶ added in v0.10.0
type Ref Hash
func (Ref) PrimitiveHinted ¶ added in v0.10.0
func (v Ref) PrimitiveHinted() interface{}
type Request ¶ added in v0.11.0
type Request struct { Metadata Metadata ObjectHash Hash ExcludedNestedObjects bool // contains filtered or unexported fields }
func (*Request) FromObject ¶ added in v0.11.0
func (Request) GetSchema ¶ added in v0.11.0
func (e Request) GetSchema() *SchemaObject
func (Request) IsStreamRoot ¶ added in v0.11.0
type Response ¶ added in v0.11.0
type Response struct { Metadata Metadata ObjectHash *Object // contains filtered or unexported fields }
func (*Response) FromObject ¶ added in v0.11.0
func (Response) GetSchema ¶ added in v0.11.0
func (e Response) GetSchema() *SchemaObject
func (Response) IsStreamRoot ¶ added in v0.11.0
type SchemaObject ¶ added in v0.5.0
type SchemaObject struct { Metadata Metadata Properties []*SchemaProperty // contains filtered or unexported fields }
func (*SchemaObject) FromObject ¶ added in v0.5.0
func (e *SchemaObject) FromObject(o Object) error
func (SchemaObject) GetType ¶ added in v0.5.0
func (e SchemaObject) GetType() string
func (SchemaObject) IsStreamRoot ¶ added in v0.11.0
func (e SchemaObject) IsStreamRoot() bool
func (SchemaObject) ToObject ¶ added in v0.5.0
func (e SchemaObject) ToObject() Object
type SchemaProperty ¶ added in v0.5.0
type SchemaProperty struct { Metadata Metadata Name string Type string Hint string IsRepeated bool IsOptional bool Properties []*SchemaProperty // contains filtered or unexported fields }
func (*SchemaProperty) FromObject ¶ added in v0.5.0
func (e *SchemaProperty) FromObject(o Object) error
func (SchemaProperty) GetType ¶ added in v0.5.0
func (e SchemaProperty) GetType() string
func (SchemaProperty) IsStreamRoot ¶ added in v0.11.0
func (e SchemaProperty) IsStreamRoot() bool
func (SchemaProperty) ToObject ¶ added in v0.5.0
func (e SchemaProperty) ToObject() Object
type Signature ¶ added in v0.5.0
type Signature struct { Signer crypto.PublicKey `json:"signer:s,omitempty" mapstructure:"signer:s,omitempty"` Alg string `json:"alg:s,omitempty" mapstructure:"alg:s,omitempty"` X []byte `json:"x:d,omitempty" mapstructure:"x:d,omitempty"` Certificate *Certificate `json:"certificate:m,omitempty" mapstructure:"certificate:m,omitempty"` }
func NewSignature ¶ added in v0.5.0
func NewSignature( k crypto.PrivateKey, o Object, ) (Signature, error)
NewSignature returns a signature given some bytes and a private key
type String ¶ added in v0.10.0
type String string
func (String) PrimitiveHinted ¶ added in v0.10.0
func (v String) PrimitiveHinted() interface{}
type TypeHint ¶
type TypeHint string
TypeHint are the hints of a member's type
func DeduceTypeHint ¶
func DeduceTypeHint(o interface{}) TypeHint
DeduceTypeHint returns a TypeHint from a given value