vdr

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2020 License: Apache-2.0 Imports: 7 Imported by: 133

Documentation

Index

Constants

View Source
const DIDCommServiceType = "did-communication"

DIDCommServiceType default DID Communication service endpoint type.

View Source
const JSONWebKey2020 = "JsonWebKey2020"

JSONWebKey2020 key type for general encryption key as key agreement, see following discussion: https://github.com/w3c/did-core/issues/240#issuecomment-663230565.

Variables

View Source
var ErrNotFound = errors.New("DID not found")

ErrNotFound is returned when a DID resolver does not find the DID.

Functions

func RetrieveEncryptionKey

func RetrieveEncryptionKey(didKey string, key *PubKey) (*did.VerificationMethod, error)

RetrieveEncryptionKey retrieves an encryption VerificationMethod in JWK format from key.

Types

type CreateDIDOpts

type CreateDIDOpts struct {
	DefaultServiceType     string
	DefaultServiceEndpoint string
	Services               []did.Service
	KeyType                string
	RequestBuilder         func([]byte) (io.Reader, error)
	EncryptionKey          *PubKey
}

CreateDIDOpts holds the options for creating DID.

type DocOpts

type DocOpts func(opts *CreateDIDOpts)

DocOpts is a create DID option.

func WithDefaultServiceEndpoint

func WithDefaultServiceEndpoint(endpoint string) DocOpts

WithDefaultServiceEndpoint service ...

func WithDefaultServiceType

func WithDefaultServiceType(serviceType string) DocOpts

WithDefaultServiceType service type of DID document to be created.

func WithEncryptionKey

func WithEncryptionKey(encryptionKey *PubKey) DocOpts

WithEncryptionKey allows for setting encryption key.

func WithKeyType

func WithKeyType(keyType string) DocOpts

WithKeyType allows for setting key type.

func WithRequestBuilder

func WithRequestBuilder(builder func(payload []byte) (io.Reader, error)) DocOpts

WithRequestBuilder allows to supply request builder which can be used to add headers to request stream to be sent to HTTP binding URL.

func WithServices

func WithServices(services ...did.Service) DocOpts

WithServices allows adding services.

type ModifiedBy

type ModifiedBy struct {
	Key string `json:"key,omitempty"`
	Sig string `json:"sig,omitempty"`
}

ModifiedBy key/signature used to update the DID Document.

type PubKey

type PubKey struct {
	ID    string
	Value []byte
	Type  string
}

PubKey contains public key type and value.

type Registry

type Registry interface {
	Resolve(did string, opts ...ResolveOpts) (*did.Doc, error)
	Store(doc *did.Doc) error
	Create(method string, opts ...DocOpts) (*did.Doc, error)
	Close() error
}

Registry vdr registry.

type ResolveDIDOpts

type ResolveDIDOpts struct {
	HTTPClient  *http.Client
	ResultType  ResultType
	VersionID   interface{}
	VersionTime string
	NoCache     bool
}

ResolveDIDOpts holds the options for did resolve.

type ResolveOpts

type ResolveOpts func(opts *ResolveDIDOpts)

ResolveOpts is a did resolve option.

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) ResolveOpts

WithHTTPClient the HTTP client input option can be used to resolve with a specific http client.

func WithNoCache

func WithNoCache(noCache bool) ResolveOpts

WithNoCache the no-cache input option can be used to turn cache on or off.

func WithResultType

func WithResultType(resultType ResultType) ResolveOpts

WithResultType the result type input option can be used to request a certain type of result.

func WithVersionID

func WithVersionID(versionID interface{}) ResolveOpts

WithVersionID the version id input option can be used to request a specific version of a DID Document.

func WithVersionTime

func WithVersionTime(versionTime time.Time) ResolveOpts

WithVersionTime the version time input option can used to request a specific version of a DID Document.

type ResultType

type ResultType int

ResultType input option can be used to request a certain type of result.

const (
	// DidDocumentResult Request a DID Document as output.
	DidDocumentResult ResultType = iota
	// ResolutionResult Request a DID Resolution Result.
	ResolutionResult
)

type VDR

type VDR interface {
	Read(did string, opts ...ResolveOpts) (*did.Doc, error)
	Store(doc *did.Doc, by *[]ModifiedBy) error
	Build(pubKey *PubKey, opts ...DocOpts) (*did.Doc, error)
	Accept(method string) bool
	Close() error
}

VDR verifiable data registry interface.

Jump to

Keyboard shortcuts

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