token

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2025 License: Apache-2.0, MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindTag

func FindTag(node datamodel.Node) (string, error)

FindTag inspect the given token IPLD representation and extract the token tag.

Types

type Info

type Info = envelope.Info

func Inspect

func Inspect(node datamodel.Node) (Info, error)

Inspect inspects the given token IPLD representation and extract some envelope facts.

type Marshaller

type Marshaller interface {
	// ToSealed wraps the token in an envelope, generates the signature, encodes
	// the result to DAG-CBOR and calculates the CID of the resulting binary data.
	ToSealed(privKey crypto.PrivKey) ([]byte, cid.Cid, error)
	// ToSealedWriter is the same as ToSealed but accepts an io.Writer.
	ToSealedWriter(w io.Writer, privKey crypto.PrivKey) (cid.Cid, error)
	// Encode marshals a Token to the format specified by the provided codec.Encoder.
	Encode(privKey crypto.PrivKey, encFn codec.Encoder) ([]byte, error)
	// EncodeWriter is the same as Encode, but accepts an io.Writer.
	EncodeWriter(w io.Writer, privKey crypto.PrivKey, encFn codec.Encoder) error
	// ToDagCbor marshals the Token to the DAG-CBOR format.
	ToDagCbor(privKey crypto.PrivKey) ([]byte, error)
	// ToDagCborWriter is the same as ToDagCbor, but it accepts an io.Writer.
	ToDagCborWriter(w io.Writer, privKey crypto.PrivKey) error
	// ToDagJson marshals the Token to the DAG-JSON format.
	ToDagJson(privKey crypto.PrivKey) ([]byte, error)
	// ToDagJsonWriter is the same as ToDagJson, but it accepts an io.Writer.
	ToDagJsonWriter(w io.Writer, privKey crypto.PrivKey) error
}

type Token

type Token interface {
	Marshaller

	// IsValidNow verifies that the token can be used at the current time, based on expiration or "not before" fields.
	// This does NOT do any other kind of verifications.
	IsValidNow() bool
	// IsValidNow verifies that the token can be used at the given time, based on expiration or "not before" fields.
	// This does NOT do any other kind of verifications.
	IsValidAt(t time.Time) bool
}

func Decode

func Decode(b []byte, decFn codec.Decoder) (Token, error)

Decode unmarshals the input data using the format specified by the provided codec.Decoder into an arbitrary UCAN token. An error is returned if the conversion fails, or if the resulting Token is invalid. Supported and returned types are: - delegation.Token - invocation.Token

func DecodeReader

func DecodeReader(r io.Reader, decFn codec.Decoder) (Token, error)

DecodeReader is the same as Decode, but accept an io.Reader.

func FromDagCbor

func FromDagCbor(b []byte) (Token, error)

FromDagCbor unmarshals an arbitrary DagCbor encoded UCAN token. An error is returned if the conversion fails, or if the resulting Token is invalid. Supported and returned types are: - delegation.Token - invocation.Token

func FromDagCborReader

func FromDagCborReader(r io.Reader) (Token, error)

FromDagCborReader is the same as FromDagCbor, but accept an io.Reader.

func FromDagJson

func FromDagJson(b []byte) (Token, error)

FromDagCbor unmarshals an arbitrary DagJson encoded UCAN token. An error is returned if the conversion fails, or if the resulting Token is invalid. Supported and returned types are: - delegation.Token - invocation.Token

func FromDagJsonReader

func FromDagJsonReader(r io.Reader) (Token, error)

FromDagJsonReader is the same as FromDagJson, but accept an io.Reader.

func FromSealed

func FromSealed(data []byte) (Token, cid.Cid, error)

FromSealed decodes an arbitrary token type from the binary data, verifies that the envelope's signature is correct based on the public key taken from the issuer (iss) field and calculates the CID of the incoming data. Supported and returned types are: - delegation.Token - invocation.Token

func FromSealedReader

func FromSealedReader(r io.Reader) (Token, cid.Cid, error)

FromSealedReader is the same as Unseal but accepts an io.Reader.

Directories

Path Synopsis
Package delegation implements the UCAN delegation specification with an immutable Token type as well as methods to convert the Token to and from the envelope-enclosed, signed and DAG-CBOR-encoded form that should most commonly be used for transport and storage.
Package delegation implements the UCAN delegation specification with an immutable Token type as well as methods to convert the Token to and from the envelope-enclosed, signed and DAG-CBOR-encoded form that should most commonly be used for transport and storage.
delegationtest
Package delegationtest provides a set of pre-built delegation tokens for a variety of test cases.
Package delegationtest provides a set of pre-built delegation tokens for a variety of test cases.
internal
envelope
Package envelope provides functions that convert between wire-format encoding of a [UCAN] token's [Envelope] and the Go type representing a verified [TokenPayload].
Package envelope provides functions that convert between wire-format encoding of a [UCAN] token's [Envelope] and the Go type representing a verified [TokenPayload].
varsig
Package varsig implements the portion of the [varsig specification] that's needed for the UCAN [Envelope].
Package varsig implements the portion of the [varsig specification] that's needed for the UCAN [Envelope].
Package invocation implements the UCAN invocation specification with an immutable Token type as well as methods to convert the Token to and from the envelope-enclosed, signed and DAG-CBOR-encoded form that should most commonly be used for transport and storage.
Package invocation implements the UCAN invocation specification with an immutable Token type as well as methods to convert the Token to and from the envelope-enclosed, signed and DAG-CBOR-encoded form that should most commonly be used for transport and storage.

Jump to

Keyboard shortcuts

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