Documentation
¶
Overview ¶
Package head defines the contents to be used in envelope headers.
Index ¶
- Variables
- func StampsHas(provider cbc.Key) validation.Rule
- func WithHead(header *Header) schema.Option
- type CorrectionOptions
- type Header
- func (h *Header) AddLink(l *Link)
- func (h *Header) AddStamp(s *Stamp)
- func (h *Header) Contains(h2 *Header) bool
- func (h *Header) GetStamp(provider cbc.Key) *Stamp
- func (h *Header) Link(key cbc.Key) *Link
- func (h *Header) Stamp(provider cbc.Key) *Stamp
- func (h *Header) Validate() error
- func (h *Header) ValidateWithContext(ctx context.Context) error
- type Link
- type Stamp
Constants ¶
This section is empty.
Variables ¶
var DetectDuplicateLinks = validation.By(detectDuplicateLinks)
DetectDuplicateLinks checks if the list of links contains duplicate keys.
var DetectDuplicateStamps = validation.By(detectDuplicateStamps)
DetectDuplicateStamps checks if the list of stamps contains duplicate provider keys.
Functions ¶
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 ¶
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"` // Links provide URLs to other resources that are related to this envelope // and unlike stamps can be added even in the draft state. Links []*Link `json:"links,omitempty" jsonschema:"title=Links"` // 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"` }
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) AddLink ¶ added in v0.111.0
AddLink will add the link to the header, or update a link with the same key.
func (*Header) AddStamp ¶
AddStamp adds a new stamp to the header. If the stamp already exists, it will be overwritten.
func (*Header) Contains ¶ added in v0.66.1
Contains compares the provided header to ensure that all the fields and properties are contained within the base header. Only a subset of the most important fields are compared.
func (*Header) GetStamp ¶ added in v0.75.0
GetStamp provides the stamp for the given provider or nil. Deprecated: use Stamp instead.
func (*Header) Link ¶ added in v0.111.0
Link provides the link with the matching key in the header, or nil.
type Link ¶ added in v0.111.0
type Link struct { // Key is a unique identifier for the link. Key cbc.Key `json:"key"` // Title of the resource to use when presenting to users. Title string `json:"title,omitempty" jsonschema:"title=Title"` // Description of the resource to use when presenting to users. Description string `json:"description,omitempty" jsonschema:"title=Description"` // Expected MIME type of the link's content. MIME string `json:"mime,omitempty" jsonschema:"title=MIME Type,format=mime"` // URL of the resource. URL string `json:"url" jsonschema:"title=URL,format=uri"` }
Link defines a link between this document and another resource. Much like stamps, links must be defined with a specific key, but do allow for additional data that can help with presentation. It is important that a link once generated cannot be updated, so this is not suitable for dynamic or potentially insecure.
Links have a specific advantage over stamps in that they are also allowed while the envelope is still a draft.
func AppendLink ¶ added in v0.111.0
AppendLink will add the link to the provided list and return the new updated list. If the link already exists, it will be updated.
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 ¶
AddStamp makes it easier to add a new Stamp by replacing a previous entry with a matching Key.
func NormalizeStamps ¶ added in v0.67.10
NormalizeStamps will try to clean the stamps by removing rows with empty providers or values. If empty, the function will return nil.