Documentation ¶
Index ¶
- func DigestJSON(payload any) ([]byte, error)
- func Sign(digester Digester, bearerDID did.BearerDID) (string, error)
- func Validate(dataType DataType, input []byte, opts ...ValidateOption) error
- func VerifyDigest(expectedDigest string, payload any) error
- func VerifySignature(digester Digester, signature string) (*jws.Decoded, error)
- type DataType
- type Digester
- type MessageMetadata
- type ResourceMetadata
- type ValidateOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DigestJSON ¶ added in v0.7.0
DigestJSON generates a SHA-256 hash of the canonicalized input payload.
func Validate ¶
func Validate(dataType DataType, input []byte, opts ...ValidateOption) error
Validate validates the input provided in two phases:
- Validate the general structure of the resource or message based on the Type.
- Validate the specific structure of the resource or message based on the Kind.
A Kind can be optionally specified in order to fail early if the input's Kind does match what was provided. This is useful when the Kind is known ahead of time. If the Kind is not specified, validation will proceed to phase 2 using metadata.kind.
Note ¶
Kind-specific schemas are lazily loaded the first time they are needed and then cached for future use.
func VerifyDigest ¶ added in v0.7.0
VerifyDigest verifies that the digest of a given payload matches the expected digest.
Types ¶
type DataType ¶
type DataType string
DataType represents the type of data being validated e.g. resource or message
type MessageMetadata ¶ added in v0.7.0
type MessageMetadata struct { From string `json:"from"` To string `json:"to"` Kind string `json:"kind"` ID string `json:"id"` ExchangeID string `json:"exchangeId"` CreatedAt string `json:"createdAt"` ExternalID string `json:"externalId,omitempty"` Protocol string `json:"protocol"` }
MessageMetadata represents the metadata of a message e.g. RFQ, quote etc.
type ResourceMetadata ¶
type ResourceMetadata struct { From string `json:"from"` Kind string `json:"kind"` ID string `json:"id"` CreatedAt string `json:"createdAt"` UpdatedAt string `json:"updatedAt,omitempty"` Protocol string `json:"protocol"` }
ResourceMetadata represents the metadata of a resource e.g. offering, balance etc.
type ValidateOption ¶
type ValidateOption func(*validateOptions)
ValidateOption is a function that sets an option for the Validate function
func WithKind ¶
func WithKind(kind string) ValidateOption
WithKind sets the kind option for the Validate function