delegation

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2023 License: Apache-2.0, MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Archive

func Archive(d Delegation) io.Reader

Types

type Delegation

type Delegation interface {
	ipld.IPLDView
	// Link returns the IPLD link of the root block of the delegation.
	Link() ucan.Link
	// Archive writes the delegation to a Content Addressed aRchive (CAR).
	Archive() io.Reader
	// Issuer is the signer of the UCAN.
	Issuer() ucan.Principal
	// Audience is the principal delegated to.
	Audience() ucan.Principal
	// Version is the spec version the UCAN conforms to.
	Version() ucan.Version
	// Capabilities are claimed abilities that can be performed on a resource.
	Capabilities() []ucan.Capability[any]
	// Expiration is the time in seconds since the Unix epoch that the UCAN
	// becomes invalid.
	Expiration() ucan.UTCUnixTimestamp
	// NotBefore is the time in seconds since the Unix epoch that the UCAN
	// becomes valid.
	NotBefore() ucan.UTCUnixTimestamp
	// Nonce is a randomly generated string to provide a unique UCAN.
	Nonce() ucan.Nonce
	// Facts are arbitrary facts and proofs of knowledge.
	Facts() []ucan.Fact
	// Proofs of delegation.
	Proofs() []ucan.Link
	// Signature of the UCAN issuer.
	Signature() signature.SignatureView
}

Delagation is a materialized view of a UCAN delegation, which can be encoded into a UCAN token and used as proof for an invocation or further delegations.

func Delegate

func Delegate(issuer ucan.Signer, audience ucan.Principal, capabilities []ucan.Capability[ucan.CaveatBuilder], options ...Option) (Delegation, error)

Delegate creates a new signed token with a given `options.issuer`. If expiration is not set it defaults to 30 seconds from now. Returns UCAN in primary IPLD representation.

func Extract

func Extract(b []byte) (Delegation, error)

func NewDelegation

func NewDelegation(root ipld.Block, bs blockstore.BlockReader) Delegation

func NewDelegationView

func NewDelegationView(root ipld.Link, bs blockstore.BlockReader) (Delegation, error)

type Option

type Option func(cfg *delegationConfig) error

Option is an option configuring a UCAN delegation.

func WithExpiration

func WithExpiration(exp uint64) Option

WithExpiration configures the expiration time in UTC seconds since Unix epoch. Set this to -1 for no expiration.

func WithFacts

func WithFacts(fct []ucan.FactBuilder) Option

WithFacts configures the facts for the UCAN.

func WithNonce

func WithNonce(nnc string) Option

WithNonce configures the nonce value for the UCAN.

func WithNotBefore

func WithNotBefore(nbf uint64) Option

WithNotBefore configures the time in UTC seconds since Unix epoch when the UCAN will become valid.

func WithProofs

func WithProofs(prf []Delegation) Option

WithProofs configures the proofs for the UCAN. If the `issuer` of this `Delegation` is not the resource owner / service provider, for the delegated capabilities, the `proofs` must contain valid `Proof`s containing delegations to the `issuer`.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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