head

package
v0.57.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2023 License: Apache-2.0 Imports: 8 Imported by: 7

Documentation

Overview

Package head defines the contents to be used in envelope headers.

Index

Constants

This section is empty.

Variables

View Source
var DetectDuplicateStamps = validation.By(duplicateDuplicateStamps)

DetectDuplicateStamps checks if the list of stamps contains duplicate provider keys.

Functions

func WithHead

func WithHead(header *Header) schema.Option

WithHead ensures the original envelope's header is included in the set of correction options. If the head.CorrectionOptions is not defined in the options, this will be ignored.

Types

type CorrectionOptions

type CorrectionOptions struct {
	Head *Header `json:"-"` // copy of the original document header
}

CorrectionOptions is used to define base correction options that can be shared between documents.

type Header struct {
	// Unique UUIDv1 identifier for the envelope.
	UUID uuid.UUID `json:"uuid" jsonschema:"title=UUID"`

	// Digest of the canonical JSON body.
	Digest *dsig.Digest `json:"dig" jsonschema:"title=Digest"`

	// Seals of approval from other organisations that can only be added to
	// non-draft envelopes.
	Stamps []*Stamp `json:"stamps,omitempty" jsonschema:"title=Stamps"`

	// Set of labels that describe but have no influence on the data.
	Tags []string `json:"tags,omitempty" jsonschema:"title=Tags"`

	// Additional semi-structured information about this envelope.
	Meta cbc.Meta `json:"meta,omitempty" jsonschema:"title=Meta"`

	// Any information that may be relevant to other humans about this envelope
	Notes string `json:"notes,omitempty" jsonschema:"title=Notes"`

	// When true, implies that this document should not be considered final. Digital signatures are optional.
	Draft bool `json:"draft,omitempty" jsonschema:"title=Draft"`
}

Header defines the metadata of the body. The header is used as the payload for the JSON Web Signatures, so we want this to be as compact as possible.

func NewHeader

func NewHeader() *Header

NewHeader creates a new header and automatically assigns a UUIDv1.

func (*Header) AddStamp

func (h *Header) AddStamp(s *Stamp)

AddStamp adds a new stamp to the header. If the stamp already exists, it will be overwritten.

func (*Header) Validate

func (h *Header) Validate() error

Validate checks that the header contains the basic information we need to function.

func (*Header) ValidateWithContext

func (h *Header) ValidateWithContext(ctx context.Context) error

ValidateWithContext checks that the header contains the basic information we need to function.

type Stamp

type Stamp struct {
	// Identity of the agency used to create the stamp usually defined by each region.
	Provider cbc.Key `json:"prv" jsonschema:"title=Provider"`
	// The serialized stamp value generated for or by the external agency
	Value string `json:"val" jsonschema:"title=Value"`
}

Stamp defines an official seal of approval from a third party like a governmental agency or intermediary and should thus be included in any official envelopes.

func AddStamp

func AddStamp(in []*Stamp, s *Stamp) []*Stamp

AddStamp makes it easier to add a new Stamp by replacing a previous entry with a matching Key.

func (*Stamp) In

func (s *Stamp) In(ss []*Stamp) bool

In checks if the stamp is in the list of stamps.

func (*Stamp) Validate

func (s *Stamp) Validate() error

Validate checks that the header contains the basic information we need to function.

Jump to

Keyboard shortcuts

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