did

package
v0.0.0-...-e9052da Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MethodJWK          = "jwk"
	TypeJsonWebKey2020 = "JsonWebKey2020"
)
View Source
const (
	MethodKey = "key"

	TypeEd25519VerificationKey2020        = "Ed25519VerificationKey2020"
	TypeEcdsaSecp256k1VerificationKey2019 = "EcdsaSecp256k1VerificationKey2019"
)
View Source
const (
	MethodWeb = "web"
)

Variables

View Source
var (
	ErrInvalidDID         = errors.New("invalid DID format")
	ErrMethodNotSupported = errors.New("DID method not supported")
	ErrResolutionFailed   = errors.New("DID resolution failed")
)

Functions

This section is empty.

Types

type Doc

type Doc struct {
	ID                 string
	VerificationMethod []VerificationMethod
}

Doc represents a DID Document.

type DocResolution

type DocResolution struct {
	DIDDocument *Doc
}

DocResolution contains the result of resolving a DID.

type JWKVDR

type JWKVDR struct{}

JWKVDR resolves did:jwk DIDs by decoding the JWK from the DID string.

func NewJWKVDR

func NewJWKVDR() *JWKVDR

NewJWKVDR creates a new did:jwk resolver.

func (*JWKVDR) Accept

func (j *JWKVDR) Accept(method string) bool

Accept returns true for the "jwk" method.

func (*JWKVDR) Read

func (j *JWKVDR) Read(didStr string) (*DocResolution, error)

Read resolves a did:jwk DID. Format: did:jwk:<base64url-encoded-jwk> See https://github.com/quartzjer/did-jwk/blob/main/spec.md

type KeyVDR

type KeyVDR struct{}

KeyVDR resolves did:key DIDs by decoding the multibase/multicodec key.

func NewKeyVDR

func NewKeyVDR() *KeyVDR

NewKeyVDR creates a new did:key resolver.

func (*KeyVDR) Accept

func (k *KeyVDR) Accept(method string) bool

Accept returns true for the "key" method.

func (*KeyVDR) Read

func (k *KeyVDR) Read(didStr string) (*DocResolution, error)

Read resolves a did:key DID. Format: did:key:<multibase-encoded-multicodec-key> See https://w3c-ccg.github.io/did-method-key/

type Registry

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

Registry resolves DIDs by delegating to the appropriate VDR.

func NewRegistry

func NewRegistry(opts ...RegistryOpt) *Registry

NewRegistry creates a new DID resolution registry with the given options.

func (*Registry) Resolve

func (r *Registry) Resolve(didStr string) (*DocResolution, error)

Resolve resolves a DID by finding a matching VDR and delegating to it.

type RegistryOpt

type RegistryOpt func(*Registry)

RegistryOpt is a functional option for configuring a Registry.

func WithVDR

func WithVDR(v VDR) RegistryOpt

WithVDR adds a VDR to the registry.

type VDR

type VDR interface {
	// Accept returns true if this resolver handles the given DID method.
	Accept(method string) bool
	// Read resolves a DID and returns the DID document.
	Read(did string) (*DocResolution, error)
}

VDR is the interface for a DID method resolver.

type VerificationMethod

type VerificationMethod struct {
	ID         string
	Type       string
	Controller string
	Value      []byte
	// contains filtered or unexported fields
}

VerificationMethod represents a verification method in a DID document.

func NewVerificationMethodFromBytes

func NewVerificationMethodFromBytes(id, vmType, controller string, value []byte) *VerificationMethod

NewVerificationMethodFromBytes creates a VerificationMethod from raw key bytes.

func NewVerificationMethodFromJWK

func NewVerificationMethodFromJWK(id, vmType, controller string, key jwk.Key) (*VerificationMethod, error)

NewVerificationMethodFromJWK creates a VerificationMethod from a JWK key.

func (*VerificationMethod) JSONWebKey

func (vm *VerificationMethod) JSONWebKey() jwk.Key

JSONWebKey returns the JWK representation of this verification method's key, or nil.

type WebVDR

type WebVDR struct {
	HTTPClient *http.Client
}

WebVDR resolves did:web DIDs by fetching the DID document over HTTPS.

func NewWebVDR

func NewWebVDR() *WebVDR

NewWebVDR creates a new did:web resolver.

func (*WebVDR) Accept

func (w *WebVDR) Accept(method string) bool

Accept returns true for the "web" method.

func (*WebVDR) Read

func (w *WebVDR) Read(didStr string) (*DocResolution, error)

Read resolves a did:web DID by fetching the DID document from the web. See https://w3c-ccg.github.io/did-method-web/

Jump to

Keyboard shortcuts

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