delegation

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: Apache-2.0, MIT Imports: 20 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Archive

func Archive(d Delegation) io.Reader

func Format

func Format(dlg Delegation) (string, error)

Types

type Delegation

type Delegation interface {
	ipld.View
	ucan.UCAN
	// Data returns the UCAN view of the delegation.
	Data() ucan.View
	// 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
	// Attach a block to the delegation DAG so it will be included in the block
	// iterator. You should only attach blocks that are referenced from
	// `Capabilities` or `Facts`.
	Attach(block block.Block) error
}

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[C ucan.CaveatBuilder](issuer ucan.Signer, audience ucan.Principal, capabilities []ucan.Capability[C], 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, error)

func NewDelegationView

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

func Parse

func Parse(input string) (Delegation, error)

type Option

type Option func(cfg *delegationConfig) error

Option is an option configuring a UCAN delegation.

func WithExpiration

func WithExpiration(exp int) Option

WithExpiration configures the expiration time in UTC seconds since Unix epoch.

func WithFacts

func WithFacts(fct []ucan.FactBuilder) Option

WithFacts configures the facts for the UCAN.

func WithNoExpiration

func WithNoExpiration() Option

WithNoExpiration configures the UCAN to never expire.

WARNING: this will cause the delegation to be valid FOREVER, unless revoked.

func WithNonce

func WithNonce(nnc string) Option

WithNonce configures the nonce value for the UCAN.

func WithNotBefore

func WithNotBefore(nbf int) Option

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

func WithProof

func WithProof(prf ...Proof) Option

WithProof configures the proof(s) 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`.

type Proof

type Proof struct {
	// contains filtered or unexported fields
}

func FromDelegation

func FromDelegation(delegation Delegation) Proof
func FromLink(link ucan.Link) Proof

func (Proof) Delegation

func (p Proof) Delegation() (Delegation, bool)
func (p Proof) Link() ucan.Link

type Proofs

type Proofs []Proof

func NewProofsView

func NewProofsView(links []ipld.Link, bs blockstore.BlockReader) Proofs

func (Proofs) WriteInto

func (proofs Proofs) WriteInto(bs blockstore.BlockWriter) ([]ipld.Link, error)

WriteInto writes a set of proofs, some of which may be full delegations to a blockstore

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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