discovery

package
v6.2.12 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: GPL-3.0 Imports: 50 Imported by: 0

Documentation

Overview

Package discovery is a generated GoMock package.

Index

Constants

View Source
const ModuleName = "Discovery"

Variables

View Source
var ErrDIDMethodsNotSupported = errors.New("DID methods not supported")

ErrDIDMethodsNotSupported indicates that a received VP does not match the supported DID Methods of the service.

View Source
var ErrInvalidPresentation = errors.New("presentation is invalid for registration")

ErrInvalidPresentation is returned when a client tries to register a Verifiable Presentation that is invalid.

View Source
var ErrNoSupportedDIDMethods = errors.New("subject has no (active) DIDs matching the service")

ErrNoSupportedDIDMethods indicates that the client cannot create a VP for a subject because it has no (active) DID matching the supported DID Methods of the service.

View Source
var ErrPresentationAlreadyExists = errors.New("presentation already exists")

ErrPresentationAlreadyExists is returned when a presentation is added to the discovery service, but a presentation with this ID already exists.

View Source
var ErrPresentationRegistrationFailed = errors.New("registration of Verifiable Presentation on remote Discovery Service failed")

ErrPresentationRegistrationFailed indicates registration of a presentation on a remote Discovery Service failed.

View Source
var ErrServiceNotFound = errors.New("discovery service not found")

ErrServiceNotFound is returned when a service (ID) is not found in the discovery service.

Functions

This section is empty.

Types

type Client

type Client interface {
	// Search searches for presentations which credential(s) match the given query.
	// Query parameters are formatted as simple JSON paths, e.g. "issuer" or "credentialSubject.name".
	// It returns an ErrServiceNotFound if the service invalid/unknown.
	Search(serviceID string, query map[string]string) ([]SearchResult, error)

	// ActivateServiceForSubject causes a subject to be registered for a Discovery Service.
	// Registration of all DIDs of the subject will be attempted immediately, and automatically refreshed.
	// If the function is called again for the same service/DID combination, it will try to refresh the registration.
	// parameters are added as credentialSubject to a DiscoveryRegistrationCredential holder credential.
	// It returns an ErrServiceNotFound or didsubject.ErrSubjectNotFound if the service or subject is invalid/unknown.
	ActivateServiceForSubject(ctx context.Context, serviceID, subjectID string, parameters map[string]interface{}) error

	// DeactivateServiceForSubject stops registration of a subject on a Discovery Service.
	// It also tries to remove all active registrations of the subject from the Discovery Service.
	// If removal of one or more active registration fails a ErrPresentationRegistrationFailed may be returned. The failed registrations will be removed when they expire.
	// It returns an ErrServiceNotFound or didsubject.ErrSubjectNotFound if the service or subject is invalid/unknown.
	DeactivateServiceForSubject(ctx context.Context, serviceID, subjectID string) error

	// Services returns the list of services that are registered on this client.
	Services() []ServiceDefinition

	// GetServiceActivation returns the activation status of a subject on a Discovery Service.
	// The boolean indicates whether the subject is activated on the Discovery Service (ActivateServiceForSubject() has been called).
	// It also returns the Verifiable Presentations for all DIDs of the subject that are registered on the Discovery Service, if any.
	// It returns an ErrServiceNotFound or didsubject.ErrSubjectNotFound if the service or subject is invalid/unknown.
	// It returns a RegistrationRefreshError with additional information if the last refresh of the service failed (activation status and VPs are still returned).
	// The time of the last error is added in the error message.
	GetServiceActivation(ctx context.Context, serviceID, subjectID string) (bool, []vc.VerifiablePresentation, error)
}

Client defines the API for Discovery Clients.

type ClientConfig

type ClientConfig struct {
	// RefreshInterval specifies how often the client should refresh the Discovery Services.
	RefreshInterval time.Duration `koanf:"refreshinterval"`
	// RefreshIntervalOld is deprecated, use RefreshInterval instead. It's there for backwards compatibility; remove in v7.
	RefreshIntervalOld time.Duration `koanf:"refresh_interval"`
}

ClientConfig holds the config for the client

type Config

type Config struct {
	Server      ServerConfig             `koanf:"server"`
	Client      ClientConfig             `koanf:"client"`
	Definitions ServiceDefinitionsConfig `koanf:"definitions"`
}

Config holds the config of the module

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default configuration.

type MockClient

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

MockClient is a mock of Client interface.

func NewMockClient

func NewMockClient(ctrl *gomock.Controller) *MockClient

NewMockClient creates a new mock instance.

func (*MockClient) ActivateServiceForSubject

func (m *MockClient) ActivateServiceForSubject(ctx context.Context, serviceID, subjectID string, parameters map[string]any) error

ActivateServiceForSubject mocks base method.

func (*MockClient) DeactivateServiceForSubject

func (m *MockClient) DeactivateServiceForSubject(ctx context.Context, serviceID, subjectID string) error

DeactivateServiceForSubject mocks base method.

func (*MockClient) EXPECT

func (m *MockClient) EXPECT() *MockClientMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockClient) GetServiceActivation

func (m *MockClient) GetServiceActivation(ctx context.Context, serviceID, subjectID string) (bool, []vc.VerifiablePresentation, error)

GetServiceActivation mocks base method.

func (*MockClient) Search

func (m *MockClient) Search(serviceID string, query map[string]string) ([]SearchResult, error)

Search mocks base method.

func (*MockClient) Services

func (m *MockClient) Services() []ServiceDefinition

Services mocks base method.

type MockClientMockRecorder

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

MockClientMockRecorder is the mock recorder for MockClient.

func (*MockClientMockRecorder) ActivateServiceForSubject

func (mr *MockClientMockRecorder) ActivateServiceForSubject(ctx, serviceID, subjectID, parameters any) *gomock.Call

ActivateServiceForSubject indicates an expected call of ActivateServiceForSubject.

func (*MockClientMockRecorder) DeactivateServiceForSubject

func (mr *MockClientMockRecorder) DeactivateServiceForSubject(ctx, serviceID, subjectID any) *gomock.Call

DeactivateServiceForSubject indicates an expected call of DeactivateServiceForSubject.

func (*MockClientMockRecorder) GetServiceActivation

func (mr *MockClientMockRecorder) GetServiceActivation(ctx, serviceID, subjectID any) *gomock.Call

GetServiceActivation indicates an expected call of GetServiceActivation.

func (*MockClientMockRecorder) Search

func (mr *MockClientMockRecorder) Search(serviceID, query any) *gomock.Call

Search indicates an expected call of Search.

func (*MockClientMockRecorder) Services

func (mr *MockClientMockRecorder) Services() *gomock.Call

Services indicates an expected call of Services.

type MockServer

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

MockServer is a mock of Server interface.

func NewMockServer

func NewMockServer(ctrl *gomock.Controller) *MockServer

NewMockServer creates a new mock instance.

func (*MockServer) EXPECT

func (m *MockServer) EXPECT() *MockServerMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockServer) Get

func (m *MockServer) Get(arg0 context.Context, serviceID string, startAfter int) (map[string]vc.VerifiablePresentation, string, int, error)

Get mocks base method.

func (*MockServer) Register

func (m *MockServer) Register(arg0 context.Context, serviceID string, presentation vc.VerifiablePresentation) error

Register mocks base method.

type MockServerMockRecorder

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

MockServerMockRecorder is the mock recorder for MockServer.

func (*MockServerMockRecorder) Get

func (mr *MockServerMockRecorder) Get(arg0, serviceID, startAfter any) *gomock.Call

Get indicates an expected call of Get.

func (*MockServerMockRecorder) Register

func (mr *MockServerMockRecorder) Register(arg0, serviceID, presentation any) *gomock.Call

Register indicates an expected call of Register.

type Module

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

Module is the main entry point for discovery services.

func New

func New(storageInstance storage.Engine, vcrInstance vcr.VCR, subjectManager didsubject.Manager, didResolver resolver.DIDResolver) *Module

New creates a new Module.

func (*Module) ActivateServiceForSubject

func (m *Module) ActivateServiceForSubject(ctx context.Context, serviceID, subjectID string, parameters map[string]interface{}) error

ActivateServiceForSubject is a Discovery Client function that activates a service for a subject. See interface.go for more information.

func (*Module) Config

func (m *Module) Config() interface{}

func (*Module) Configure

func (m *Module) Configure(serverConfig core.ServerConfig) error

func (*Module) DeactivateServiceForSubject

func (m *Module) DeactivateServiceForSubject(ctx context.Context, serviceID, subjectID string) error

DeactivateServiceForSubject is a Discovery Client function that deactivates a service for a subject. See interface.go for more information.

func (*Module) Get

func (m *Module) Get(context context.Context, serviceID string, startAfter int) (map[string]vc.VerifiablePresentation, string, int, error)

Get is a Discovery Server function that retrieves the presentations for the given service, starting at timestamp+1. See interface.go for more information.

func (*Module) GetServiceActivation

func (m *Module) GetServiceActivation(ctx context.Context, serviceID, subjectID string) (bool, []vc.VerifiablePresentation, error)

GetServiceActivation is a Discovery Client function that retrieves the activation status of a service for a subject. See interface.go for more information.

func (*Module) Name

func (m *Module) Name() string

func (*Module) Register

func (m *Module) Register(context context.Context, serviceID string, presentation vc.VerifiablePresentation) error

Register is a Discovery Server function that registers a presentation on the given Discovery Service. See interface.go for more information.

func (*Module) Search

func (m *Module) Search(serviceID string, query map[string]string) ([]SearchResult, error)

Search is a Discovery Client function that searches for presentations which credential(s) match the given query. See interface.go for more information.

func (*Module) Services

func (m *Module) Services() []ServiceDefinition

func (*Module) Shutdown

func (m *Module) Shutdown() error

func (*Module) Start

func (m *Module) Start() error

type RegistrationRefreshError

type RegistrationRefreshError struct {
	Underlying error
}

RegistrationRefreshError is returned from GetServiceRefreshError.

func (RegistrationRefreshError) Error

func (r RegistrationRefreshError) Error() string

type SQLBool

type SQLBool bool

func (SQLBool) Bool

func (b SQLBool) Bool() bool

func (*SQLBool) Scan

func (b *SQLBool) Scan(value interface{}) error

func (SQLBool) Value

func (b SQLBool) Value() (driver.Value, error)

type SearchResult

type SearchResult struct {
	// Presentation is the Verifiable Presentation that was matched.
	Presentation vc.VerifiablePresentation `json:"vp"`
	// Fields is a map of Input Descriptor Constraint Fields from the Discovery Service's Presentation Definition.
	// The keys are the Input Descriptor IDs mapped to the values from the credential(s) inside the Presentation.
	// It only includes constraint fields that have an ID.
	Fields map[string]interface{} `json:"fields"`
	// Parameters is a map of parameters that were used during registration.
	Parameters map[string]interface{} `json:"registrationParameters"`
}

SearchResult is a single result of a search operation.

type Server

type Server interface {
	// Register registers a presentation on the given Discovery Service.
	// If the presentation is not valid, or it does not conform to the Service ServiceDefinition, it returns an error.
	// If the node is not configured as server for the given serviceID, the call will be forwarded to the configured server.
	Register(context context.Context, serviceID string, presentation vc.VerifiablePresentation) error
	// Get retrieves the presentations for the given service, starting from the given timestamp.
	// If the node is not configured as server for the given serviceID, the call will be forwarded to the configured server.
	Get(context context.Context, serviceID string, startAfter int) (map[string]vc.VerifiablePresentation, string, int, error)
}

Server defines the API for Discovery Servers.

type ServerConfig

type ServerConfig struct {
	// IDs specifies the IDs of the Discovery Services the server serves.
	IDs []string `koanf:"ids"`
}

ServerConfig holds the config for the server

type ServiceDefinition

type ServiceDefinition struct {
	// ID is the unique identifier of the use case.
	ID string `json:"id"`
	// DIDMethods is a list of DID methods that are supported by the use case.
	// If empty, all methods are supported.
	DIDMethods []string `json:"did_methods,omitempty"`
	// Endpoint is the endpoint where the use case list is served.
	Endpoint string `json:"endpoint"`
	// PresentationDefinition specifies the Presentation ServiceDefinition submissions to the list must conform to,
	// according to the Presentation Exchange specification.
	PresentationDefinition pe.PresentationDefinition `json:"presentation_definition"`
	// PresentationMaxValidity specifies how long submitted presentations are allowed to be valid (in seconds).
	PresentationMaxValidity int `json:"presentation_max_validity"`
}

ServiceDefinition holds the definition of a service.

func ParseServiceDefinition

func ParseServiceDefinition(data []byte) (*ServiceDefinition, error)

ParseServiceDefinition validates the input against the JSON schema for service definitions. If the input is valid, it is parsed and returned as a ServiceDefinition.

type ServiceDefinitionsConfig

type ServiceDefinitionsConfig struct {
	Directory string `koanf:"directory"`
}

ServiceDefinitionsConfig holds the config for loading Service Definitions.

type XForwardedHostContextKey

type XForwardedHostContextKey struct{}

XForwardedHostContextKey is the context key for the X-Forwarded-Host header.

Directories

Path Synopsis
api
server
Package server provides primitives to interact with the openapi HTTP API.
Package server provides primitives to interact with the openapi HTTP API.
server/client
Package client is a generated GoMock package.
Package client is a generated GoMock package.
v1
Package v1 provides primitives to interact with the openapi HTTP API.
Package v1 provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

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