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 Verify(o Object) error
- type Certificate
- type Hash
- type Object
- func (o Object) AddSignature(vs ...Signature) Object
- func (o Object) Get(k string) interface{}
- func (o Object) GetOwners() []crypto.PublicKey
- func (o Object) GetParents() []Hash
- func (o Object) GetPolicy() Policy
- func (o Object) GetSignatures() []Signature
- func (o Object) GetStream() Hash
- func (o Object) GetType() string
- func (o Object) IsEmpty() bool
- func (o Object) Raw() immutable.Map
- func (o Object) Set(k string, v interface{}) Object
- func (o Object) SetOwners(owners []crypto.PublicKey) Object
- func (o Object) SetParents(hashes []Hash) Object
- func (o Object) SetPolicy(policy Policy) 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 Policy
- type SchemaObject
- type SchemaProperty
- type Signature
- type TypeHint
Constants ¶
const (
// AlgorithmObjectHash for creating ObjectHash+ES256 based signatures
AlgorithmObjectHash = "OH_ES256"
)
const ( // ErrCouldNotVerify is returned when the signature doesn't matches the // given key ErrCouldNotVerify = errors.Error("could not verify signature") )
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") )
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
Types ¶
type Certificate ¶ added in v0.5.0
type Certificate struct { Stream Hash Parents []Hash Owners []crypto.PublicKey Policy Policy Signatures []Signature Subject crypto.PublicKey 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
func NewSelfSignedCertificate ¶ added in v0.5.0
func NewSelfSignedCertificate(k crypto.PrivateKey) *Certificate
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) ToObject ¶ added in v0.5.0
func (e Certificate) ToObject() Object
type Hash ¶
type Hash string
func HashFromBytes ¶ added in v0.5.0
type Object ¶
Object for everything f12n
func (Object) AddSignature ¶ added in v0.5.1
func (Object) GetParents ¶
func (Object) GetSignatures ¶ added in v0.5.1
func (Object) SetParents ¶
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
type SchemaObject ¶ added in v0.5.0
type SchemaObject struct { Stream Hash Parents []Hash Owners []crypto.PublicKey Policy Policy Signatures []Signature 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) ToObject ¶ added in v0.5.0
func (e SchemaObject) ToObject() Object
type SchemaProperty ¶ added in v0.5.0
type SchemaProperty struct { Stream Hash Parents []Hash Owners []crypto.PublicKey Policy Policy Signatures []Signature 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) 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"` }
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