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
- func DecodeFromBase64(encoded string) (*message.Message, error)
- func DecodeFromJSON(jsonBytes []byte) (*message.Message, error)
- func DecodeFromURL(invURL string) (*message.Message, error)
- func EncodeAsJSON(inv *message.Message) (string, error)
- func EncodeAsURL(inv *message.Message, baseURL string) (string, error)
- func IsInvitation(msg *message.Message) bool
- func NewInvitation(from string, opts ...InvitationOption) (*message.Message, error)
- type Invitation
- type InvitationBody
- type InvitationOption
- func WithAccept(mediaTypes ...string) InvitationOption
- func WithAttachments(attachments ...message.Attachment) InvitationOption
- func WithGoal(goal string) InvitationOption
- func WithGoalCode(code string) InvitationOption
- func WithHandshakeProtocols(protocols ...string) InvitationOption
- func WithLabel(label string) InvitationOption
Constants ¶
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 ¶
DecodeFromBase64 decodes an invitation from a base64url-encoded string.
func DecodeFromJSON ¶
DecodeFromJSON decodes an invitation from JSON bytes.
func DecodeFromURL ¶
DecodeFromURL decodes an invitation from a URL containing an _oob parameter.
func EncodeAsJSON ¶
EncodeAsJSON encodes an invitation as a JSON string.
func EncodeAsURL ¶
EncodeAsURL encodes an invitation as a URL with an _oob query parameter. The baseURL should be the endpoint where invitations are handled.
func IsInvitation ¶
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 ¶
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).