decorator

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: Apache-2.0 Imports: 11 Imported by: 54

Documentation

Index

Constants

View Source
const (
	// TransportReturnRouteNone return route option none.
	TransportReturnRouteNone = "none"

	// TransportReturnRouteAll return route option all.
	TransportReturnRouteAll = "all"

	// TransportReturnRouteThread return route option thread.
	TransportReturnRouteThread = "thread"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment added in v0.1.2

type Attachment struct {
	// ID is a JSON-LD construct that uniquely identifies attached content within the scope of a given message.
	// Recommended on appended attachment descriptors. Possible but generally unused on embedded attachment descriptors.
	// Never required if no references to the attachment exist; if omitted, then there is no way
	// to refer to the attachment later in the thread, in error messages, and so forth.
	// Because @id is used to compose URIs, it is recommended that this name be brief and avoid spaces
	// and other characters that require URI escaping.
	ID string `json:"@id,omitempty"`
	// Description is an optional human-readable description of the content.
	Description string `json:"description,omitempty"`
	// FileName is a hint about the name that might be used if this attachment is persisted as a file.
	// It is not required, and need not be unique. If this field is present and mime-type is not,
	// the extension on the filename may be used to infer a MIME type.
	FileName string `json:"filename,omitempty"`
	// MimeType describes the MIME type of the attached content. Optional but recommended.
	MimeType string `json:"mime-type,omitempty"`
	// LastModTime is a hint about when the content in this attachment was last modified.
	LastModTime time.Time `json:"lastmod_time,omitempty"`
	// ByteCount is an optional, and mostly relevant when content is included by reference instead of by value.
	// Lets the receiver guess how expensive it will be, in time, bandwidth, and storage, to fully fetch the attachment.
	ByteCount int64 `json:"byte_count,omitempty"`
	// Data is a JSON object that gives access to the actual content of the attachment.
	Data AttachmentData `json:"data,omitempty"`
}

Attachment is intended to provide the possibility to include files, links or even JSON payload to the message. To find out more please visit https://github.com/hyperledger/aries-rfcs/tree/master/concepts/0017-attachments

func GenericAttachmentsToV1 added in v0.1.8

func GenericAttachmentsToV1(attachments []GenericAttachment) []Attachment

GenericAttachmentsToV1 converts a slice of GenericAttachment to a slice of Attachment.

type AttachmentData added in v0.1.2

type AttachmentData struct {
	// Sha256 is a hash of the content. Optional. Used as an integrity check if content is inlined.
	// if content is only referenced, then including this field makes the content tamper-evident.
	// This may be redundant, if the content is stored in an inherently immutable container like
	// content-addressable storage. This may also be undesirable, if dynamic content at a specified
	// link is beneficial. Including a hash without including a way to fetch the content via link
	// is a form of proof of existence.
	Sha256 string `json:"sha256,omitempty"`
	// Links is a list of zero or more locations at which the content may be fetched.
	Links []string `json:"links,omitempty"`
	// Base64 encoded data, when representing arbitrary content inline instead of via links. Optional.
	Base64 string `json:"base64,omitempty"`
	// JSON is a directly embedded JSON data, when representing content inline instead of via links,
	// and when the content is natively conveyable as JSON. Optional.
	JSON interface{} `json:"json,omitempty"`
	// JWS is a JSON web signature over the encoded data, in detached format.
	JWS json.RawMessage `json:"jws,omitempty"`
}

AttachmentData contains attachment payload.

func (*AttachmentData) Fetch added in v0.1.3

func (d *AttachmentData) Fetch() ([]byte, error)

Fetch this attachment's contents.

func (*AttachmentData) Sign added in v0.1.7

func (d *AttachmentData) Sign(c crypto.Crypto, kh, pub interface{}, pubBytes []byte) error

Sign signs the base64 payload of the AttachmentData, and adds the signature to the attachment.

func (*AttachmentData) Verify added in v0.1.7

func (d *AttachmentData) Verify(c crypto.Crypto, keyManager kms.KeyManager) error

Verify verifies the signature on the attachment data.

type AttachmentV2 added in v0.1.7

type AttachmentV2 struct {
	// ID is a JSON-LD construct that uniquely identifies attached content within the scope of a given message.
	// Recommended on appended attachment descriptors. Possible but generally unused on embedded attachment descriptors.
	// Never required if no references to the attachment exist; if omitted, then there is no way
	// to refer to the attachment later in the thread, in error messages, and so forth.
	// Because @id is used to compose URIs, it is recommended that this name be brief and avoid spaces
	// and other characters that require URI escaping.
	ID string `json:"id,omitempty"`
	// Description is an optional human-readable description of the content.
	Description string `json:"description,omitempty"`
	// FileName is a hint about the name that might be used if this attachment is persisted as a file.
	// It is not required, and need not be unique. If this field is present and mime-type is not,
	// the extension on the filename may be used to infer a MIME type.
	FileName string `json:"filename,omitempty"`
	// MediaType describes the MIME type of the attached content. Optional but recommended.
	MediaType string `json:"media_type,omitempty"`
	// LastModTime is a hint about when the content in this attachment was last modified.
	LastModTime time.Time `json:"lastmod_time,omitempty"`
	// ByteCount is an optional, and mostly relevant when content is included by reference instead of by value.
	// Lets the receiver guess how expensive it will be, in time, bandwidth, and storage, to fully fetch the attachment.
	ByteCount int64 `json:"byte_count,omitempty"`
	// Data is a JSON object that gives access to the actual content of the attachment.
	Data AttachmentData `json:"data,omitempty"`
	// Format describes the format of the attachment if the media_type is not sufficient.
	Format string `json:"format,omitempty"`
}

AttachmentV2 is intended to provide the possibility to include files, links or even JSON payload to the message. To find out more please visit https://identity.foundation/didcomm-messaging/spec/#attachments

func GenericAttachmentsToV2 added in v0.1.8

func GenericAttachmentsToV2(attachments []GenericAttachment) []AttachmentV2

GenericAttachmentsToV2 converts a slice of GenericAttachment to a slice of AttachmentV2.

type GenericAttachment added in v0.1.8

type GenericAttachment struct {
	// ID is the attachment ID..
	ID string `json:"id,omitempty"`
	// Description is an optional human-readable description of the content.
	Description string `json:"description,omitempty"`
	// FileName is a hint about the name that might be used if this attachment is persisted as a file.
	// It is not required, and need not be unique. If this field is present and mime-type is not,
	// the extension on the filename may be used to infer a MIME type.
	FileName string `json:"filename,omitempty"`
	// MediaType describes the MIME type of the attached content in a DIDComm v2 attachment. Optional but recommended.
	MediaType string `json:"media_type,omitempty"`
	// LastModTime is a hint about when the content in this attachment was last modified.
	LastModTime time.Time `json:"lastmod_time,omitempty"`
	// ByteCount is an optional, and mostly relevant when content is included by reference instead of by value.
	// Lets the receiver guess how expensive it will be, in time, bandwidth, and storage, to fully fetch the attachment.
	ByteCount int64 `json:"byte_count,omitempty"`
	// Data is a JSON object that gives access to the actual content of the attachment.
	Data AttachmentData `json:"data,omitempty"`
	// Format describes the format of the attachment if the media_type is not sufficient, in a DIDComm v2 attachment.
	Format string `json:"format,omitempty"`
	// contains filtered or unexported fields
}

GenericAttachment is used to work with DIDComm attachments that can be either DIDComm v1 or DIDComm v2.

func V1AttachmentsToGeneric added in v0.1.8

func V1AttachmentsToGeneric(attachments []Attachment) []GenericAttachment

V1AttachmentsToGeneric converts a slice of Attachment to a slice of GenericAttachment.

func V2AttachmentsToGeneric added in v0.1.8

func V2AttachmentsToGeneric(attachments []AttachmentV2) []GenericAttachment

V2AttachmentsToGeneric converts a slice of AttachmentV2 to a slice of GenericAttachment.

func (*GenericAttachment) AsV1 added in v0.1.8

func (ga *GenericAttachment) AsV1() Attachment

AsV1 returns the attachment as a DIDComm v1 attachment.

func (*GenericAttachment) AsV2 added in v0.1.8

func (ga *GenericAttachment) AsV2() AttachmentV2

AsV2 returns the attachment as a DIDComm v2 attachment.

func (*GenericAttachment) Version added in v0.1.8

func (ga *GenericAttachment) Version() Version

Version returns the DIDComm version of this attachment.

type ReturnRoute added in v0.1.1

type ReturnRoute struct {
	Value string `json:"~return_route,omitempty"`
}

ReturnRoute works with Transport decorator. Acceptable values - "none", "all" or "thread".

type Thread

type Thread struct {
	ID             string         `json:"thid,omitempty"`
	PID            string         `json:"pthid,omitempty"`
	SenderOrder    int            `json:"sender_order,omitempty"`
	ReceivedOrders map[string]int `json:"received_orders,omitempty"`
}

Thread thread data.

type Timing

type Timing struct {
	ExpiresTime time.Time `json:"expires_time,omitempty"`
}

Timing keeps expiration time.

type Transport added in v0.1.1

type Transport struct {
	ReturnRoute *ReturnRoute `json:"~transport,omitempty"`
}

Transport transport decorator https://github.com/hyperledger/aries-rfcs/tree/master/features/0092-transport-return-route

type Version added in v0.1.8

type Version string

Version represents DIDComm protocol version.

const (
	DIDCommV1  Version = "v1"
	DIDCommV2  Version = "v2"
	AnyVersion Version = "any"
)

DIDComm versions.

type WebRedirect added in v0.1.8

type WebRedirect struct {
	// Status of the operation,
	// Refer https://github.com/hyperledger/aries-rfcs/blob/main/features/0015-acks/README.md#ack-status.
	Status string `json:"status,omitempty"`
	// URL to which recipient of this message is being requested to redirect.
	URL string `json:"url,omitempty"`
}

WebRedirect decorator for passing web redirect info to ask recipient of the message to redirect after completion of flow.

Jump to

Keyboard shortcuts

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