object

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2021 License: MIT Imports: 13 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
	Deny  EvaluationResult = "deny"
	Allow EvaluationResult = "allow"
)
View Source
const (
	// ErrInvalidObjectType is returned when the signature being verified
	// is not an encoded object of type "signature".
	ErrInvalidObjectType = errors.Error("invalid object type")
	// ErrAlgorithNotImplemented is returned when the algorithm specified
	// has not been implemented
	ErrAlgorithNotImplemented = errors.Error("algorithm not implemented")
)
View Source
const (
	ErrInvalidSigner    = errors.Error("signer does not match owner")
	ErrMissingSignature = errors.Error("missing signature")
	ErrCouldNotVerify   = errors.Error("could not verify signature")
)
View Source
const (
	// AlgorithmObjectHash is the only supported signing algorithm right now.
	AlgorithmObjectHash = "EdDSA"
)
View Source
const (
	ErrReaderDone = errors.Error("reader done")
)
View Source
const RequestType = "nimona.io/Request"
View Source
const ResponseType = "nimona.io/Response"

Variables

This section is empty.

Functions

func Sign added in v0.19.0

func Sign(k crypto.PrivateKey, o *Object) error

Sign an object given a private key, updates the object's metadata in place

func SignDeep added in v0.19.0

func SignDeep(k crypto.PrivateKey, o *Object) error

SignDeep an object and all nested objects we own or have no owner WARNING: THIS _WILL_ CHANGE, DO NOT USE! TODO: not sure which nested objects this should sign. All? Own?

func Traverse added in v0.10.0

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

func Unmarshal added in v0.19.0

func Unmarshal(o *Object, out interface{}) error

Unmarshal an object into a tagged struct

func Verify added in v0.5.0

func Verify(o *Object) error

Verify object TODO should this verify nested objects as well?

Types

type ByteMashaller added in v0.19.0

type ByteMashaller interface {
	MarshalBytes() ([]byte, error)
}

type ByteUnmashaller added in v0.19.0

type ByteUnmashaller interface {
	UnmarshalBytes([]byte) error
}

type EvaluationResult added in v0.17.1

type EvaluationResult string

type Getter added in v0.11.0

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

type GetterFunc added in v0.11.0

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

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

type MapMashaller added in v0.19.0

type MapMashaller interface {
	MarshalMap() (tilde.Map, error)
}

type MapUnmashaller added in v0.19.0

type MapUnmashaller interface {
	UnmarshalMap(tilde.Map) error
}

type Metadata added in v0.11.0

type Metadata struct {
	Owner     did.DID      `nimona:"owner:s"`
	Parents   Parents      `nimona:"parents:m"`
	Policies  Policies     `nimona:"policies:am"`
	Root      tilde.Digest `nimona:"root:r"`
	Sequence  uint64       `nimona:"sequence:u,omitzero"`
	Signature Signature    `nimona:"_signature:m"`
	Timestamp string       `nimona:"timestamp:s"`
}

Metadata for object TODO: add shape TODO: add authors, contributors, license, copyright TODO: add version

type Object

type Object struct {
	Context  tilde.Digest
	Type     string
	Metadata Metadata
	Data     tilde.Map
}

func Copy

func Copy(s *Object) *Object

func Marshal added in v0.19.0

func Marshal(in interface{}) (*Object, error)

func MustMarshal added in v0.19.0

func MustMarshal(in interface{}) *Object

func ReadAll added in v0.11.0

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

ReadAll is a helper method that

func (*Object) Hash

func (o *Object) Hash() tilde.Digest

func (*Object) MarshalJSON added in v0.15.7

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

func (*Object) MarshalMap added in v0.18.0

func (o *Object) MarshalMap() (tilde.Map, error)

func (*Object) UnmarshalJSON added in v0.15.7

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

func (*Object) UnmarshalMap added in v0.18.0

func (o *Object) UnmarshalMap(v tilde.Map) error

type Parents added in v0.18.0

type Parents map[string]tilde.DigestArray

func (Parents) All added in v0.18.0

func (ps Parents) All() []tilde.Digest

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 (Policies) Evaluate added in v0.17.1

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

type Policy

type Policy struct {
	Name      string             `nimona:"name:s"`
	Type      PolicyType         `nimona:"type:s"`
	Subjects  []crypto.PublicKey `nimona:"subjects:as"`
	Resources []string           `nimona:"resources:as"`
	Actions   []PolicyAction     `nimona:"actions:as"`
	Effect    PolicyEffect       `nimona:"effect:s"`
}

Policy for object metadata

func (Policy) Evaluate added in v0.17.1

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

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 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,type=nimona.io/Request"`
	RequestID  string       `nimona:"requestID:s"`
	ObjectHash tilde.Digest `nimona:"objectHash:s"`
}

type Response added in v0.11.0

type Response struct {
	Metadata  Metadata `nimona:"@metadata:m,type=nimona.io/Response"`
	RequestID string   `nimona:"requestID:s"`
	Object    *Object  `nimona:"object:m"`
}

type Signature added in v0.5.0

type Signature struct {
	Delegator did.DID          `nimona:"d:s"`
	Signer    did.DID          `nimona:"s:s"`
	Key       crypto.PublicKey `nimona:"jwk:s"`
	Alg       string           `nimona:"alg:s"`
	X         []byte           `nimona:"x:d"`
	// contains filtered or unexported fields
}

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 (*Signature) IsEmpty added in v0.5.0

func (s *Signature) IsEmpty() bool

type StringMashaller added in v0.19.0

type StringMashaller interface {
	MarshalString() (string, error)
}

type StringUnmashaller added in v0.19.0

type StringUnmashaller interface {
	UnmarshalString(string) error
}

type Typer added in v0.19.0

type Typer interface {
	Type() string
}

Jump to

Keyboard shortcuts

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