trustping

package
v0.5.9 Latest Latest
Warning

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

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

Documentation

Overview

Package trustping implements the DIDComm Trust Ping Protocol 2.0.

Trust Ping is used to test connectivity and verify that an agent is online and responsive.

Protocol URI: https://didcomm.org/trust-ping/2.0

Message Types

  • ping: Request a response from the receiver
  • ping-response: Response to a ping request

Usage

// Create and send a ping
ping := trustping.NewPing(
	"did:example:alice",
	"did:example:bob",
	trustping.WithResponseRequested(true),
	trustping.WithComment("Hello!"),
)

// Handle a received ping
response, err := trustping.HandlePing(msg)

Index

Constants

View Source
const (
	// Protocol identifier
	ProtocolURI = "https://didcomm.org/trust-ping/2.0"

	// Message types
	TypePing         = ProtocolURI + "/ping"
	TypePingResponse = ProtocolURI + "/ping-response"
)

Variables

This section is empty.

Functions

func HandlePing

func HandlePing(ping *message.Message) (*message.Message, error)

HandlePing processes a ping message and returns a response if requested. Returns nil if no response is needed.

func IsPing

func IsPing(msg *message.Message) bool

IsPing checks if a message is a trust ping.

func IsPingResponse

func IsPingResponse(msg *message.Message) bool

IsPingResponse checks if a message is a trust ping response.

func NewPing

func NewPing(from, to string, opts ...PingOption) (*message.Message, error)

NewPing creates a new trust ping message.

func NewPingResponse

func NewPingResponse(ping *message.Message, comment string) (*message.Message, error)

NewPingResponse creates a response to a ping message.

func ResponseRequested

func ResponseRequested(msg *message.Message) bool

ResponseRequested returns whether a ping expects a response.

Types

type Ping

type Ping struct {
	*message.Message
}

Ping represents a trust ping message.

type PingBody

type PingBody struct {
	// ResponseRequested indicates whether a response is expected.
	// If false, the receiver should not respond.
	ResponseRequested bool `json:"response_requested,omitempty"`

	// Comment is an optional human-readable message.
	Comment string `json:"comment,omitempty"`
}

PingBody contains the body fields for a ping message.

type PingOption

type PingOption func(*pingConfig)

PingOption configures ping creation.

func WithComment

func WithComment(comment string) PingOption

WithComment adds a human-readable comment.

func WithResponseRequested

func WithResponseRequested(requested bool) PingOption

WithResponseRequested sets whether a response is expected.

type PingResponse

type PingResponse struct {
	*message.Message
}

PingResponse represents a trust ping response message.

type PingResponseBody

type PingResponseBody struct {
	// Comment is an optional human-readable message.
	Comment string `json:"comment,omitempty"`
}

PingResponseBody contains the body fields for a ping response.

Jump to

Keyboard shortcuts

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