Documentation
¶
Overview ¶
various DID method resolvers.
This package provides: - A DIDResolver interface for pluggable DID method implementations - A GenericDIDRegistry that wraps DID resolvers in a TrustRegistry interface - Built-in support for the did:key method
The implementation follows the W3C DID Core specification: https://www.w3.org/TR/did-core/
Index ¶
- type DIDDocument
- type DIDKeyResolver
- type DIDResolver
- type GenericDIDRegistry
- func (r *GenericDIDRegistry) Evaluate(ctx context.Context, req *authzen.EvaluationRequest) (*authzen.EvaluationResponse, error)
- func (r *GenericDIDRegistry) Healthy() bool
- func (r *GenericDIDRegistry) Info() registry.RegistryInfo
- func (r *GenericDIDRegistry) Refresh(ctx context.Context) error
- func (r *GenericDIDRegistry) RegisterResolver(resolver DIDResolver)
- func (r *GenericDIDRegistry) SupportedResourceTypes() []string
- func (r *GenericDIDRegistry) SupportsResolutionOnly() bool
- type GenericDIDRegistryConfig
- type VerificationMethod
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DIDDocument ¶
type DIDDocument struct {
Context interface{} `json:"@context,omitempty"`
ID string `json:"id"`
Controller interface{} `json:"controller,omitempty"`
VerificationMethod []VerificationMethod `json:"verificationMethod,omitempty"`
Authentication interface{} `json:"authentication,omitempty"`
AssertionMethod interface{} `json:"assertionMethod,omitempty"`
KeyAgreement interface{} `json:"keyAgreement,omitempty"`
Service interface{} `json:"service,omitempty"`
}
DIDDocument represents a W3C DID Document. See https://www.w3.org/TR/did-core/#did-documents
type DIDKeyResolver ¶
type DIDKeyResolver struct{}
DIDKeyResolver implements the did:key method. See https://w3c-ccg.github.io/did-method-key/
func NewDIDKeyResolver ¶
func NewDIDKeyResolver() *DIDKeyResolver
NewDIDKeyResolver creates a new did:key resolver.
func (*DIDKeyResolver) Method ¶
func (r *DIDKeyResolver) Method() string
Method returns "key" as this resolver handles did:key DIDs.
func (*DIDKeyResolver) Resolve ¶
func (r *DIDKeyResolver) Resolve(ctx context.Context, did string) (*DIDDocument, error)
Resolve resolves a did:key identifier to a DID document. The did:key method encodes the public key directly in the DID.
type DIDResolver ¶
type DIDResolver interface {
// Resolve resolves a DID to a DID document.
Resolve(ctx context.Context, did string) (*DIDDocument, error)
// Method returns the DID method this resolver handles (e.g., "key", "web").
Method() string
}
DIDResolver defines the interface for resolving DIDs to DID documents.
type GenericDIDRegistry ¶
type GenericDIDRegistry struct {
// contains filtered or unexported fields
}
GenericDIDRegistry provides a TrustRegistry implementation that uses pluggable DID resolvers to support multiple DID methods.
func NewGenericDIDRegistry ¶
func NewGenericDIDRegistry(config GenericDIDRegistryConfig) *GenericDIDRegistry
NewGenericDIDRegistry creates a new GenericDIDRegistry.
func NewGenericDIDRegistryWithKeyMethod ¶
func NewGenericDIDRegistryWithKeyMethod(config GenericDIDRegistryConfig) *GenericDIDRegistry
NewGenericDIDRegistryWithKeyMethod creates a GenericDIDRegistry with the did:key resolver registered.
func (*GenericDIDRegistry) Evaluate ¶
func (r *GenericDIDRegistry) Evaluate(ctx context.Context, req *authzen.EvaluationRequest) (*authzen.EvaluationResponse, error)
Evaluate implements TrustRegistry.Evaluate by resolving DIDs and validating key bindings.
func (*GenericDIDRegistry) Healthy ¶
func (r *GenericDIDRegistry) Healthy() bool
Healthy returns true if the registry is operational.
func (*GenericDIDRegistry) Info ¶
func (r *GenericDIDRegistry) Info() registry.RegistryInfo
Info returns metadata about this registry.
func (*GenericDIDRegistry) Refresh ¶
func (r *GenericDIDRegistry) Refresh(ctx context.Context) error
Refresh is a no-op for DID resolution.
func (*GenericDIDRegistry) RegisterResolver ¶
func (r *GenericDIDRegistry) RegisterResolver(resolver DIDResolver)
RegisterResolver registers a DID resolver for a specific DID method.
func (*GenericDIDRegistry) SupportedResourceTypes ¶
func (r *GenericDIDRegistry) SupportedResourceTypes() []string
SupportedResourceTypes returns the resource types this registry can handle.
func (*GenericDIDRegistry) SupportsResolutionOnly ¶
func (r *GenericDIDRegistry) SupportsResolutionOnly() bool
SupportsResolutionOnly returns true as DID resolution supports resolution-only requests.
type GenericDIDRegistryConfig ¶
type GenericDIDRegistryConfig struct {
Description string `json:"description,omitempty"`
}
GenericDIDRegistryConfig holds configuration for the GenericDIDRegistry.
type VerificationMethod ¶
type VerificationMethod struct {
ID string `json:"id"`
Type string `json:"type"`
Controller string `json:"controller"`
PublicKeyJwk map[string]interface{} `json:"publicKeyJwk,omitempty"`
PublicKeyMultibase string `json:"publicKeyMultibase,omitempty"`
}
VerificationMethod represents a verification method in a DID document.