Documentation
¶
Overview ¶
Package head defines the contents to be used in envelope headers.
Index ¶
Constants ¶
const ( LinkCategoryKeyFormat cbc.Key = "format" LinkCategoryKeyPortal cbc.Key = "portal" LinkCategoryKeyRequest cbc.Key = "request" LinkCategoryKeyResponse cbc.Key = "response" LinkCategoryKeyAgreement cbc.Key = "agreement" LinkCategoryKeyVerification cbc.Key = "verification" LinkCategoryKeyAttachment cbc.Key = "attachment" )
Link category keys defined for use inside link categories.
Variables ¶
var DetectDuplicateLinks = is.FuncError("no duplicate links", detectDuplicateLinks)
DetectDuplicateLinks checks if the list of links contains duplicate category and key pairs.
var DetectDuplicateStamps = is.FuncError("no duplicate stamps", detectDuplicateStamps)
DetectDuplicateStamps checks if the list of stamps contains duplicate provider keys.
var LinkCategoryDefs = []*cbc.Definition{ { Key: LinkCategoryKeyFormat, Name: i18n.NewString("Format"), Desc: i18n.NewString(here.Doc(` Alternative formats of the same document, such as PDF, HTML, or XML. `)), }, { Key: LinkCategoryKeyPortal, Name: i18n.NewString("Portal"), Desc: i18n.NewString(here.Doc(` Websites that provide access to alternative versions of this document or request modifications. May also allow access to other or previous business documents. `)), }, { Key: LinkCategoryKeyRequest, Name: i18n.NewString("Request"), Desc: i18n.NewString(here.Doc(` Documents related to requests submitted to other systems. `)), }, { Key: LinkCategoryKeyResponse, Name: i18n.NewString("Response"), Desc: i18n.NewString(here.Doc(` Response documents sent from third party systems often in reply to requests. `)), }, { Key: LinkCategoryKeyAgreement, Name: i18n.NewString("Agreement"), Desc: i18n.NewString(here.Doc(` Contracts or agreements related to this document. `)), }, { Key: LinkCategoryKeyVerification, Name: i18n.NewString("Verification"), Desc: i18n.NewString(here.Doc(` Evidence or verification documents that can be used to validate the authenticity of this document. `)), }, { Key: LinkCategoryKeyAttachment, Name: i18n.NewString("Attachment"), Desc: i18n.NewString(here.Doc(` General attachments for related information such as spread sheets, letters, presentations, specifications, etc. `)), }, }
LinkCategoryDefs provides the definitions for link categories.
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 category and 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.
type Link ¶ added in v0.111.0
type Link struct {
uuid.Identify
// Category helps classify the link according to a fixed list. This is optional
// but highly recommended as it helps receivers better understand the purpose
// of the link and potentially how it should be presented.
Category cbc.Key `json:"category,omitempty" jsonschema:"title=Category"`
// Key is a unique identifier for the link within the header and category
// if provided.
Key cbc.Key `json:"key"`
// Code used to identify the contents of the link.
Code cbc.Code `json:"code,omitempty" jsonschema:"title=Code"`
// 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 when the content is a file. Can only
// be one of the allowed types defined by EN 16931-1:2017 plus XML itself.
MIME string `json:"mime,omitempty" jsonschema:"title=MIME Type,format=mime"`
// Digest is used to verify the integrity of the destination document
// when downloaded from the URL.
Digest *dsig.Digest `json:"digest,omitempty" jsonschema:"title=Digest"`
// URL of the resource.
URL string `json:"url" jsonschema:"title=URL,format=uri"`
// Meta contains additional metadata about the link.
Meta cbc.Meta `json:"meta,omitempty" jsonschema:"title=Metadata"`
}
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 URLs.
Links have a specific advantage over stamps in that they are also allowed while the envelope has not yet been signed.
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.
func LinkByCategoryAndKey ¶ added in v0.306.0
LinkByCategoryAndKey finds the link with the given category and key from the provided list. Category may be empty.
func (Link) JSONSchemaExtend ¶ added in v0.306.0
func (Link) JSONSchemaExtend(js *jsonschema.Schema)
JSONSchemaExtend implements the jsonschema.Extender interface for Link and adds extra category details to the schema.
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.
type StampsHasRule ¶ added in v0.400.0
type StampsHasRule struct {
// contains filtered or unexported fields
}
StampsHasRule is a combined rules.Test and validation.Rule that checks if a specific stamp provider is present in a list of stamps.
func StampsHas ¶ added in v0.114.0
func StampsHas(provider cbc.Key) *StampsHasRule
StampsHas provides a validation rule that checks if a list of stamps includes one for the given provider.
func (*StampsHasRule) Check ¶ added in v0.400.0
func (r *StampsHasRule) Check(value any) bool
Check returns true if the stamp with the given provider is present.
func (*StampsHasRule) String ¶ added in v0.400.0
func (r *StampsHasRule) String() string
func (*StampsHasRule) Validate ¶ added in v0.400.0
func (r *StampsHasRule) Validate(value any) error
Validate returns an error if the stamp with the given provider is absent.