dagjose

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package dagjose is an implementation of the IPLD codec.

Data that is encoded using the dag-jose multicodec is guaranteed to be a CBOR encoding of the general serialization of either a JWE or a JWS. In order to access this information using go-ipld-prime we need two things:

* We need to register an encoder and a encoder which will be used by the cidlink package to decode the raw data into the IPLD data model

* An implementation of ipld.NodeAssembler which knows how to interpret the IPLD data into some concrete go data type which implements ipld.Node

The first of these points is handled by importing this package. There is a side effecting operation in the module initialiation which registers the encoder and decoder with go-ipld-prime.

The latter point is provided by the dagjose.DagJOSE data type. This type represents the union of the dagjose.DagJWS and dagjose.DagJWE types. Typically you will use dagjose.LoadJOSE(..) to load a dagjose.DagJOSE object, then you will use DagJOSE.AsJWS and DagJOSE.AsJWE to determine whether you have a JWS or JWE object respectively.

This package does not provide any direct access to the fields of the JWS and JWE objects, instead each kind of JOSE object has a GeneralJSONSerialization method which can be used to obtain the general json serialization to be passed to third party libraries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBuilder

func NewBuilder() ipld.NodeBuilder

Returns an instance of the DagJOSENodeBuilder which can be passed to ipld.Link.Load and will build a dagjose.DagJOSE object. This should only be neccesary in reasonably advanced situations, most of the time you should be able to use dagjose.LoadJOSE

Types

type DagJOSE

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

This is a union of the DagJWE and DagJWS types. Typically you will want to use AsJWE and AsJWS to get a concrete JOSE object.

func (*DagJOSE) AsJWE

func (d *DagJOSE) AsJWE() *DagJWE

If this jose object is a JWE then this will return a DagJWE, if it is a JWS then AsJWE will return nil

func (*DagJOSE) AsJWS

func (d *DagJOSE) AsJWS() *DagJWS

If this jose object is a JWS then this will return a DagJWS, if it is a JWE then AsJWS will return nil

func (*DagJOSE) AsNode

func (d *DagJOSE) AsNode() ipld.Node

type DagJOSENodePrototype

type DagJOSENodePrototype struct{}

func (*DagJOSENodePrototype) NewBuilder

func (d *DagJOSENodePrototype) NewBuilder() ipld.NodeBuilder

type DagJWE

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

func ParseJWE

func ParseJWE(jsonStr []byte) (*DagJWE, error)

Given a JSON string reresenting a JWE in either general or compact serialization this will return a DagJWE

func (*DagJWE) AsJOSE

func (d *DagJWE) AsJOSE() *DagJOSE

Returns a DagJOSE object that implements ipld.Node and can be passed to ipld related infrastructure

func (*DagJWE) FlattenedSerialization

func (d *DagJWE) FlattenedSerialization() ([]byte, error)

Return the flattened json serialization of this JWE

func (*DagJWE) GeneralJSONSerialization

func (d *DagJWE) GeneralJSONSerialization() []byte

Return the general json serialization of this JWE

type DagJWS

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

func ParseJWS

func ParseJWS(jsonStr []byte) (*DagJWS, error)

Given a JSON string reresenting a JWS in either general or compact serialization this will return a DagJWS

func (*DagJWS) AsJOSE

func (d *DagJWS) AsJOSE() *DagJOSE

Returns a DagJOSE object that implements ipld.Node and can be passed to ipld related infrastructure

func (*DagJWS) FlattenedSerialization

func (d *DagJWS) FlattenedSerialization() ([]byte, error)

Return the flattened json serialization of this JWS

func (*DagJWS) GeneralJSONSerialization

func (d *DagJWS) GeneralJSONSerialization() []byte

Return the general json serialization of this JWS

func (d *DagJWS) PayloadLink() ipld.Link

Jump to

Keyboard shortcuts

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