object

package
v0.17.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2021 License: MIT Imports: 20 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// Policy types
	SignaturePolicy PolicyType = "signature"

	// Policy actions
	ReadAction PolicyAction = "read"

	// Policy effects
	AllowEffect PolicyEffect = "allow"
	DenyEffect  PolicyEffect = "deny"

	// Policy Evaluation results
	ExplicitDeny  EvaluationResult = "ExplicitDeny"
	ImplicitDeny  EvaluationResult = "ImplicitDeny"
	ExplicitAllow EvaluationResult = "ExplicitAllow"
)
View Source
const (
	ErrInvalidSigner    = errors.Error("signer is does not match owner")
	ErrMissingSignature = errors.Error("missing signature")
	ErrCouldNotVerify   = errors.Error("could not verify signature")
)
View Source
const (
	// AlgorithmObjectCID for creating ObjectCID+ES256 based signatures
	AlgorithmObjectCID = "OH_ES256"
)
View Source
const (
	EmptyCID = CID("")
)
View Source
const (
	ErrReaderDone = errors.Error("reader done")
)
View Source
const (
	ErrSourceNotSupported = errors.Error("encoding source not supported")
)

Variables

View Source
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")
)
View Source
var (
	ErrTimeout = errors.New("timeout")
)

Functions

func FromBoolArray added in v0.15.7

func FromBoolArray(s BoolArray) []bool

func FromCIDArray added in v0.17.0

func FromCIDArray(s CIDArray) []string

func FromDataArray added in v0.15.7

func FromDataArray(s DataArray) [][]byte

func FromFloatArray added in v0.15.7

func FromFloatArray(s FloatArray) []float64

func FromIntArray added in v0.15.7

func FromIntArray(s IntArray) []int64

func FromStringArray added in v0.15.7

func FromStringArray(s StringArray) []string

func FromUintArray added in v0.15.7

func FromUintArray(s UintArray) []uint64

func Traverse added in v0.10.0

func Traverse(v interface{}, f func(string, interface{}) bool)

func UnloadReferences added in v0.11.0

func UnloadReferences(
	ctx context.Context,
	obj *Object,
) (
	result *Object,
	unloaded []*Object,
	err error,
)

func Verify added in v0.5.0

func Verify(o *Object) error

Verify object TODO should this verify nested objects as well?

Types

type ArrayValue added in v0.15.7

type ArrayValue interface {
	Value
	Len() int
	Range(func(int, Value) bool)
	// contains filtered or unexported methods
}

type Bool added in v0.10.0

type Bool bool

basic types

func (Bool) Hint added in v0.15.7

func (v Bool) Hint() Hint

func (*Bool) UnmarshalJSON added in v0.15.7

func (v *Bool) UnmarshalJSON(b []byte) error

type BoolArray added in v0.15.7

type BoolArray []Bool

array types

func ToBoolArray added in v0.15.7

func ToBoolArray(s []bool) BoolArray

func (BoolArray) Hint added in v0.15.7

func (v BoolArray) Hint() Hint

func (BoolArray) Len added in v0.15.7

func (v BoolArray) Len() int

func (BoolArray) Range added in v0.15.7

func (v BoolArray) Range(f func(int, Value) bool)

type CID added in v0.17.0

type CID string

func GetReferences added in v0.11.0

func GetReferences(o *Object) []CID

func NewCID added in v0.17.0

func NewCID(o *Object) (CID, error)

func SortCIDs added in v0.17.0

func SortCIDs(a []CID) []CID

SortCIDs sorts a slice of CIDs in increasing order, and also returns it. The return part is mostly for allowing this to be used as a helper method in tests.

func (CID) Hint added in v0.17.0

func (v CID) Hint() Hint

func (CID) IsEmpty added in v0.17.0

func (h CID) IsEmpty() bool

func (CID) String added in v0.17.0

func (h CID) String() string

type CIDArray added in v0.17.0

type CIDArray []CID

func ToCIDArray added in v0.17.0

func ToCIDArray(s []string) CIDArray

func (CIDArray) Hint added in v0.17.0

func (v CIDArray) Hint() Hint

func (CIDArray) Len added in v0.17.0

func (v CIDArray) Len() int

func (CIDArray) Range added in v0.17.0

func (v CIDArray) Range(f func(int, Value) bool)

type CIDSlice added in v0.17.0

type CIDSlice []CID

func (CIDSlice) Len added in v0.17.0

func (p CIDSlice) Len() int

func (CIDSlice) Less added in v0.17.0

func (p CIDSlice) Less(i, j int) bool

func (CIDSlice) Sort added in v0.17.0

func (p CIDSlice) Sort()

func (CIDSlice) Swap added in v0.17.0

func (p CIDSlice) Swap(i, j int)

type Certificate added in v0.5.0

type Certificate struct {
	Metadata Metadata `nimona:"metadata:m,omitempty"`
	Nonce    string
	Created  string
	Expires  string
}

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) ToObject added in v0.5.0

func (e Certificate) ToObject() *Object

func (*Certificate) Type added in v0.12.0

func (e *Certificate) Type() string

type CertificateRequest added in v0.11.0

type CertificateRequest struct {
	Metadata               Metadata `nimona:"metadata:m,omitempty"`
	ApplicationName        string
	ApplicationDescription string
	ApplicationURL         string
	Subject                string
	Resources              []string
	Actions                []string
	Nonce                  string
}

func (*CertificateRequest) FromObject added in v0.11.0

func (e *CertificateRequest) FromObject(o *Object) error

func (CertificateRequest) ToObject added in v0.11.0

func (e CertificateRequest) ToObject() *Object

func (*CertificateRequest) Type added in v0.12.0

func (e *CertificateRequest) Type() string

type Data added in v0.15.7

type Data []byte

func (Data) Hint added in v0.15.7

func (v Data) Hint() Hint

func (*Data) UnmarshalJSON added in v0.15.7

func (v *Data) UnmarshalJSON(b []byte) error

type DataArray added in v0.15.7

type DataArray []Data

func ToDataArray added in v0.15.7

func ToDataArray(s [][]byte) DataArray

func (DataArray) Hint added in v0.15.7

func (v DataArray) Hint() Hint

func (DataArray) Len added in v0.15.7

func (v DataArray) Len() int

func (DataArray) Range added in v0.15.7

func (v DataArray) Range(f func(int, Value) bool)

type EvaluationResult added in v0.17.1

type EvaluationResult string

type Float added in v0.10.0

type Float float64

func (Float) Hint added in v0.15.7

func (v Float) Hint() Hint

func (*Float) UnmarshalJSON added in v0.15.7

func (v *Float) UnmarshalJSON(b []byte) error

type FloatArray added in v0.15.7

type FloatArray []Float

func ToFloatArray added in v0.15.7

func ToFloatArray(s []float64) FloatArray

func (FloatArray) Hint added in v0.15.7

func (v FloatArray) Hint() Hint

func (FloatArray) Len added in v0.15.7

func (v FloatArray) Len() int

func (FloatArray) Range added in v0.15.7

func (v FloatArray) Range(f func(int, Value) bool)

type Getter added in v0.11.0

type Getter interface {
	Get(
		context.Context,
		CID,
	) (*Object, error)
}

type GetterFunc added in v0.11.0

type GetterFunc func(
	context.Context,
	CID,
) (*Object, error)

GetterFunc is an adapter to allow the use of ordinary functions as object.Getter

type Hint added in v0.15.7

type Hint string
const (
	// basic hints
	BoolHint   Hint = "b"
	DataHint   Hint = "d"
	FloatHint  Hint = "f"
	IntHint    Hint = "i"
	MapHint    Hint = "m"
	ObjectHint Hint = "o"
	StringHint Hint = "s"
	UintHint   Hint = "u"
	CIDHint    Hint = "r"
	// array hints
	BoolArrayHint   Hint = "ab"
	DataArrayHint   Hint = "ad"
	FloatArrayHint  Hint = "af"
	IntArrayHint    Hint = "ai"
	MapArrayHint    Hint = "am"
	ObjectArrayHint Hint = "ao"
	StringArrayHint Hint = "as"
	UintArrayHint   Hint = "au"
	CIDArrayHint    Hint = "ar"
)

type Int added in v0.10.0

type Int int64

func (Int) Hint added in v0.15.7

func (v Int) Hint() Hint

func (*Int) UnmarshalJSON added in v0.15.7

func (v *Int) UnmarshalJSON(b []byte) error

type IntArray added in v0.15.7

type IntArray []Int

func ToIntArray added in v0.15.7

func ToIntArray(s []int64) IntArray

func (IntArray) Hint added in v0.15.7

func (v IntArray) Hint() Hint

func (IntArray) Len added in v0.15.7

func (v IntArray) Len() int

func (IntArray) Range added in v0.15.7

func (v IntArray) Range(f func(int, Value) bool)

type Map added in v0.10.0

type Map map[string]Value

func (Map) Hint added in v0.15.7

func (v Map) Hint() Hint

func (Map) MarshalJSON added in v0.15.7

func (v Map) MarshalJSON() ([]byte, error)

func (Map) UnmarshalJSON added in v0.15.7

func (v Map) UnmarshalJSON(b []byte) error

type MapArray added in v0.15.7

type MapArray []Map

func (MapArray) Hint added in v0.15.7

func (v MapArray) Hint() Hint

func (MapArray) Len added in v0.15.7

func (v MapArray) Len() int

func (MapArray) Range added in v0.15.7

func (v MapArray) Range(f func(int, Value) bool)

type Metadata added in v0.11.0

type Metadata struct {
	Owner     crypto.PublicKey
	Datetime  string
	Parents   []CID
	Policies  Policies
	Stream    CID
	Signature Signature
}

Metadata for object

func MetadataFromMap added in v0.15.7

func MetadataFromMap(s Map) Metadata

func (Metadata) Map added in v0.15.7

func (m Metadata) Map() Map

type Object

type Object struct {
	Type     string
	Metadata Metadata
	Data     Map
}

Object

func Copy

func Copy(s *Object) *Object

func FromMap

func FromMap(m Map) *Object

func LoadReferences added in v0.11.0

func LoadReferences(
	ctx context.Context,
	objectCID CID,
	getter GetterFunc,
) (*Object, error)

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 ReadAll added in v0.11.0

func ReadAll(r Reader) ([]*Object, error)

ReadAll is a helper method that

func (*Object) CID added in v0.17.0

func (o *Object) CID() CID

func (Object) Hint added in v0.15.7

func (v Object) Hint() Hint

func (Object) Map added in v0.15.7

func (o Object) Map() Map

func (Object) MarshalJSON added in v0.15.7

func (o Object) MarshalJSON() ([]byte, error)

func (Object) ToMap

func (o Object) ToMap() Map

func (*Object) UnmarshalJSON added in v0.15.7

func (o *Object) UnmarshalJSON(b []byte) error

type ObjectArray added in v0.15.7

type ObjectArray []*Object // nolint: golint

func (ObjectArray) Hint added in v0.15.7

func (v ObjectArray) Hint() Hint

func (ObjectArray) Len added in v0.15.7

func (v ObjectArray) Len() int

func (ObjectArray) Range added in v0.15.7

func (v ObjectArray) Range(f func(int, Value) bool)

type ParsedType added in v0.11.0

type ParsedType struct {
	PrimaryType string
	Namespace   string
	Object      string
}

func ParseType added in v0.11.0

func ParseType(objectType string) ParsedType

type Policies added in v0.17.1

type Policies []Policy

Policies

func PoliciesFromValue added in v0.17.1

func PoliciesFromValue(a MapArray) Policies

func (Policies) Evaluate added in v0.17.1

func (ps Policies) Evaluate(
	subject crypto.PublicKey,
	resource string,
	action PolicyAction,
) EvaluationResult

func (Policies) Value added in v0.17.1

func (ps Policies) Value() MapArray

type Policy

type Policy struct {
	Type      PolicyType
	Subjects  []crypto.PublicKey
	Resources []string
	Actions   []PolicyAction
	Effect    PolicyEffect
}

Policy for object metadata

func PolicyFromMap added in v0.15.7

func PolicyFromMap(m Map) Policy

func (Policy) Evaluate added in v0.17.1

func (p Policy) Evaluate(
	subject crypto.PublicKey,
	resource string,
	action PolicyAction,
) EvaluationResult

func (Policy) Map added in v0.15.7

func (p Policy) Map() Map

type PolicyAction added in v0.17.1

type PolicyAction string

type PolicyEffect added in v0.17.1

type PolicyEffect string

type PolicyType

type PolicyType string

type ReadCloser added in v0.11.0

type ReadCloser interface {
	Read() (*Object, error)
	Close()
}

func FetchWithReferences added in v0.11.0

func FetchWithReferences(
	ctx context.Context,
	getter GetterFunc,
	objectCID CID,
) (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 Reader added in v0.11.0

type Reader interface {
	Read() (*Object, error)
}

type Request added in v0.11.0

type Request struct {
	Metadata  Metadata `nimona:"metadata:m,omitempty"`
	RequestID string
	ObjectCID CID
}

func (*Request) FromObject added in v0.11.0

func (e *Request) FromObject(o *Object) error

func (Request) ToObject added in v0.11.0

func (e Request) ToObject() *Object

func (*Request) Type added in v0.12.0

func (e *Request) Type() string

type Response added in v0.11.0

type Response struct {
	Metadata  Metadata `nimona:"metadata:m,omitempty"`
	RequestID string
	Object    *Object
}

func (*Response) FromObject added in v0.11.0

func (e *Response) FromObject(o *Object) error

func (Response) ToObject added in v0.11.0

func (e Response) ToObject() *Object

func (*Response) Type added in v0.12.0

func (e *Response) Type() string

type Signature added in v0.5.0

type Signature struct {
	Signer      crypto.PublicKey `nimona:"signer:s,omitempty"`
	Alg         string           `nimona:"alg:s,omitempty"`
	X           []byte           `nimona:"x:d,omitempty"`
	Certificate *Certificate     `nimona:"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

func SignatureFromMap added in v0.15.7

func SignatureFromMap(m Map) Signature

func (Signature) IsEmpty added in v0.5.0

func (s Signature) IsEmpty() bool

func (Signature) Map added in v0.15.7

func (s Signature) Map() Map

type String added in v0.10.0

type String string

func (String) Hint added in v0.15.7

func (v String) Hint() Hint

type StringArray added in v0.15.7

type StringArray []String

func ToStringArray added in v0.15.7

func ToStringArray(s []string) StringArray

func (StringArray) Hint added in v0.15.7

func (v StringArray) Hint() Hint

func (StringArray) Len added in v0.15.7

func (v StringArray) Len() int

func (StringArray) Range added in v0.15.7

func (v StringArray) Range(f func(int, Value) bool)

type Typed added in v0.12.0

type Typed interface {
	Type() string
}

type Uint added in v0.15.7

type Uint uint64

func (Uint) Hint added in v0.15.7

func (v Uint) Hint() Hint

func (*Uint) UnmarshalJSON added in v0.15.7

func (v *Uint) UnmarshalJSON(b []byte) error

type UintArray added in v0.15.7

type UintArray []Uint

func ToUintArray added in v0.15.7

func ToUintArray(s []uint64) UintArray

func (UintArray) Hint added in v0.15.7

func (v UintArray) Hint() Hint

func (UintArray) Len added in v0.15.7

func (v UintArray) Len() int

func (UintArray) Range added in v0.15.7

func (v UintArray) Range(f func(int, Value) bool)

type Value added in v0.10.0

type Value interface {
	Hint() Hint
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL