discoverfeatures

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: 4 Imported by: 0

Documentation

Overview

Package discoverfeatures implements the DIDComm Discover Features Protocol 2.0.

Discover Features is used to query another agent about the protocols and features it supports.

Protocol URI: https://didcomm.org/discover-features/2.0

Message Types

  • queries: Query supported features
  • disclose: Response with supported features

Usage

// Create a query for all protocols
query := discoverfeatures.NewQuery(
	"did:example:alice",
	"did:example:bob",
	discoverfeatures.QueryProtocols("*"),
)

// Handle a query and respond
disclose, _ := discoverfeatures.HandleQuery(query, supportedProtocols)

Index

Constants

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

	// Message types
	TypeQueries  = ProtocolURI + "/queries"
	TypeDisclose = ProtocolURI + "/disclose"

	// Feature types
	FeatureTypeProtocol   = "protocol"
	FeatureTypeGoalCode   = "goal-code"
	FeatureTypeHeader     = "header"
	FeatureTypeAttachment = "attachment"
)

Variables

This section is empty.

Functions

func IsDisclose

func IsDisclose(msg *message.Message) bool

IsDisclose checks if a message is a discover-features disclosure.

func IsQuery

func IsQuery(msg *message.Message) bool

IsQuery checks if a message is a discover-features query.

func NewDisclose

func NewDisclose(query *message.Message, features []Feature) (*message.Message, error)

NewDisclose creates a disclose response message.

func NewQuery

func NewQuery(from, to string, opts ...QueryOption) (*message.Message, error)

NewQuery creates a new feature discovery query message.

Types

type DiscloseBody

type DiscloseBody struct {
	Disclosures []Feature `json:"disclosures"`
}

DiscloseBody contains the body of a disclose message.

func GetDiscloseBody

func GetDiscloseBody(msg *message.Message) (*DiscloseBody, error)

GetDiscloseBody extracts the disclosures from a disclose message.

type Feature

type Feature struct {
	// FeatureType is the type of feature
	FeatureType string `json:"feature-type"`

	// ID is the feature identifier (e.g., protocol URI)
	ID string `json:"id"`

	// Roles supported for this feature (for protocols)
	Roles []string `json:"roles,omitempty"`
}

Feature represents a disclosed feature.

type ProtocolRegistry

type ProtocolRegistry struct {
	// contains filtered or unexported fields
}

ProtocolRegistry holds information about supported protocols.

func NewProtocolRegistry

func NewProtocolRegistry() *ProtocolRegistry

NewProtocolRegistry creates a new protocol registry.

func (*ProtocolRegistry) HandleQuery

func (r *ProtocolRegistry) HandleQuery(query *message.Message) (*message.Message, error)

HandleQuery processes a query and returns matching features.

func (*ProtocolRegistry) RegisterGoalCode

func (r *ProtocolRegistry) RegisterGoalCode(code string)

RegisterGoalCode registers a supported goal code.

func (*ProtocolRegistry) RegisterProtocol

func (r *ProtocolRegistry) RegisterProtocol(uri string, roles ...string)

RegisterProtocol registers a supported protocol.

type Query

type Query struct {
	// FeatureType is the type of feature being queried (protocol, goal-code, etc.)
	FeatureType string `json:"feature-type"`

	// Match is the pattern to match (supports wildcards)
	Match string `json:"match,omitempty"`
}

Query represents a feature discovery query.

type QueryBody

type QueryBody struct {
	Queries []Query `json:"queries"`
}

QueryBody contains the body of a queries message.

func GetQueryBody

func GetQueryBody(msg *message.Message) (*QueryBody, error)

GetQueryBody extracts the queries from a query message.

type QueryOption

type QueryOption func(*queryConfig)

QueryOption configures query creation.

func AddQuery

func AddQuery(featureType, match string) QueryOption

AddQuery adds a custom query.

func QueryGoalCodes

func QueryGoalCodes(pattern string) QueryOption

QueryGoalCodes adds a goal-code query with the given pattern.

func QueryProtocols

func QueryProtocols(pattern string) QueryOption

QueryProtocols adds a protocol query with the given pattern.

Jump to

Keyboard shortcuts

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