oob

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package oob implements the DIDComm Out-of-Band Protocol 2.0.

Out-of-Band is used to share out-of-band invitations that can bootstrap DIDComm connections through other channels like QR codes, URLs, or email.

Protocol URI: https://didcomm.org/out-of-band/2.0

Message Types

  • invitation: An invitation to connect or interact

Usage

// Create an invitation
inv := oob.NewInvitation(
	"did:example:alice",
	oob.WithGoal("To establish a secure connection"),
	oob.WithAccept(didcomm.MediaTypeEncrypted),
)

// Encode for transport
url, _ := oob.EncodeAsURL(inv, "https://example.com")
qr, _ := oob.EncodeAsJSON(inv)

// Decode a received invitation
inv, _ := oob.DecodeFromURL(url)

Index

Constants

View Source
const (
	// Protocol identifier
	ProtocolURI = "https://didcomm.org/out-of-band/2.0"

	// Message types
	TypeInvitation = ProtocolURI + "/invitation"

	// URL parameter name
	OOBQueryParam = "_oob"
)

Variables

This section is empty.

Functions

func DecodeFromBase64

func DecodeFromBase64(encoded string) (*message.Message, error)

DecodeFromBase64 decodes an invitation from a base64url-encoded string.

func DecodeFromJSON

func DecodeFromJSON(jsonBytes []byte) (*message.Message, error)

DecodeFromJSON decodes an invitation from JSON bytes.

func DecodeFromURL

func DecodeFromURL(invURL string) (*message.Message, error)

DecodeFromURL decodes an invitation from a URL containing an _oob parameter.

func EncodeAsJSON

func EncodeAsJSON(inv *message.Message) (string, error)

EncodeAsJSON encodes an invitation as a JSON string.

func EncodeAsURL

func EncodeAsURL(inv *message.Message, baseURL string) (string, error)

EncodeAsURL encodes an invitation as a URL with an _oob query parameter. The baseURL should be the endpoint where invitations are handled.

func IsInvitation

func IsInvitation(msg *message.Message) bool

IsInvitation checks if a message is an out-of-band invitation.

func NewInvitation

func NewInvitation(from string, opts ...InvitationOption) (*message.Message, error)

NewInvitation creates a new out-of-band invitation.

Types

type Invitation

type Invitation struct {
	*message.Message
}

Invitation represents an out-of-band invitation message.

type InvitationBody

type InvitationBody struct {
	// GoalCode is a machine-readable code describing the goal.
	GoalCode string `json:"goal_code,omitempty"`

	// Goal is a human-readable description of the goal.
	Goal string `json:"goal,omitempty"`

	// Accept is a list of media types the sender accepts.
	Accept []string `json:"accept,omitempty"`

	// Handshake protocols the sender supports.
	HandshakeProtocols []string `json:"handshake_protocols,omitempty"`
}

InvitationBody contains the body fields for an invitation.

func GetInvitationBody

func GetInvitationBody(inv *message.Message) (*InvitationBody, error)

GetInvitationBody extracts the body from an invitation message.

type InvitationOption

type InvitationOption func(*invitationConfig)

InvitationOption configures invitation creation.

func WithAccept

func WithAccept(mediaTypes ...string) InvitationOption

WithAccept sets the accepted media types.

func WithAttachments

func WithAttachments(attachments ...message.Attachment) InvitationOption

WithAttachments adds attachments to the invitation.

func WithGoal

func WithGoal(goal string) InvitationOption

WithGoal sets the human-readable goal description.

func WithGoalCode

func WithGoalCode(code string) InvitationOption

WithGoalCode sets the machine-readable goal code.

func WithHandshakeProtocols

func WithHandshakeProtocols(protocols ...string) InvitationOption

WithHandshakeProtocols sets the supported handshake protocols.

func WithLabel

func WithLabel(label string) InvitationOption

WithLabel sets a label for the invitation (used in from header).

Jump to

Keyboard shortcuts

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