did

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DIDFragementDelimiter = "#"
)

Variables

View Source
var (
	ErrUnsupportedDIDKey = errors.New("unsupported did key")

	// ErrNoVerificationMethodId occurs when a did verification method id is empty
	ErrNoVerificationMethodId = errors.New("did verification method id is not set")
)

Functions

func WithWebGetter

func WithWebGetter(webGetter didWebGetter) didwebOption

WithWebGetter sets the web getter, that gets the did document from the web

Types

type DIDPublicKeyProvider

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

func NewDIDPublicKeyProvider

func NewDIDPublicKeyProvider(cs *dtcose.CoseSign1Message, didWeb *Didweb) *DIDPublicKeyProvider

NewDIDPublicKeyProvider returns a provider which fetches a did web key To customize the key fetch (or for testing purposes), provide a non-nil didWeb. Otherwise one is created for you.

func (*DIDPublicKeyProvider) DidWeb

func (p *DIDPublicKeyProvider) DidWeb() (*Didweb, error)

func (*DIDPublicKeyProvider) PublicKey

func (p *DIDPublicKeyProvider) PublicKey() (crypto.PublicKey, cose.Algorithm, error)

type Did

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

did is a Decentralised Identity (DID) https://www.w3.org/TR/did-core/

func NewDid

func NewDid(didURL string) (*Did, error)

NewDid returns did given the did URL

in the form found: https://www.w3.org/TR/did-core/#did-url-syntax

e.g. "did:web:sample.issuer:user:alice#key123"

type Didweb

type Didweb struct {
	*Did
	// contains filtered or unexported fields
}

didweb is the did web method implementation:

https://w3c-ccg.github.io/did-method-web/

func NewDidWeb

func NewDidWeb(didURL string, opts ...didwebOption) (*Didweb, error)

NewDidWeb creates a new DID web

func (*Didweb) PublicKey

func (d *Didweb) PublicKey() (crypto.PublicKey, error)

publicKey gets the public key from the did

func (*Didweb) URL

func (d *Didweb) URL() (*url.URL, error)

URL attempts to take the didVerify's did

and converts it into a url
e.g. "https://sample.issuer/user/alice/did.json"

NOTE: the did has to have method web

type Document

type Document struct {
	ID                 string               `json:"id"`
	Context            []string             `json:"@context,omitempty"`
	Controller         []string             `json:"controller,omitempty"`
	VerificationMethod []VerificationMethod `json:"verificationMethod,omitempty"`
}

Document represents a DID Document as specified by the DID Core specification (https://www.w3.org/TR/did-core/).

type ErrDiDKeyNotFound

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

ErrDiDKeyNotFound occurs when a did document does not contain the given key in the verification method list

func (*ErrDiDKeyNotFound) Error

func (e *ErrDiDKeyNotFound) Error() string

Error implements the error interface

type ErrMalformedDIDId

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

ErrMalformedDIDId occurs when a did id is not in the expected format, expected format is host:{path} e.g. `example.com:path:to:resource`

func (*ErrMalformedDIDId) Error

func (e *ErrMalformedDIDId) Error() string

Error implements the error interface

type ErrUnsupportedDIDMethod

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

ErrUnsupportedDIDMethod occurs when a did url has an unsupported method, e.g. `did:foobar`

func (*ErrUnsupportedDIDMethod) Error

func (e *ErrUnsupportedDIDMethod) Error() string

Error implements the error interface

type VerificationMethod

type VerificationMethod struct {
	ID              string                 `json:"id"`
	Type            string                 `json:"type,omitempty"`
	Controller      string                 `json:"controller,omitempty"`
	PublicKeyBase58 string                 `json:"publicKeyBase58,omitempty"`
	PublicKeyJwk    map[string]interface{} `json:"publicKeyJwk,omitempty"`
}

VerificationMethod represents a DID Verification Method as specified by the DID Core specification (https://www.w3.org/TR/did-core/#verification-methods).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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