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
- func IsDisclose(msg *message.Message) bool
- func IsQuery(msg *message.Message) bool
- func NewDisclose(query *message.Message, features []Feature) (*message.Message, error)
- func NewQuery(from, to string, opts ...QueryOption) (*message.Message, error)
- type DiscloseBody
- type Feature
- type ProtocolRegistry
- type Query
- type QueryBody
- type QueryOption
Constants ¶
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 ¶
IsDisclose checks if a message is a discover-features disclosure.
func NewDisclose ¶
NewDisclose creates a disclose response 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 ¶
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.
type QueryOption ¶
type QueryOption func(*queryConfig)
QueryOption configures query creation.
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.