resolver

package
v0.0.0-...-f291c22 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2021 License: Apache-2.0 Imports: 2 Imported by: 1

Documentation

Overview

Package resolver implements did resolution functions resolve a did into a did document. It aims to be did spec v1.0 compliant. See https://w3c.github.io/did-core/#did-resolution Copyright 2021 Textile Copyright 2018 ConsenSys AG

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// Get checks the cache for a given did, and if found, returns the previous result.
	Get(parsed *parse.DID, resolve wrappedResolve) (*Document, error)
}

Cache is a simple did document cache.

type Document

type Document struct {
	Context            []string             `json:"@context"` // https://w3id.org/did/v1
	ID                 string               `json:"id"`
	Controller         []string             `json:"controller,omitempty"`
	VerificationMethod []VerificationMethod `json:"verificationMethod,omitempty"`
	Authentication     []VerificationMethod `json:"authentication,omitempty"`
	KeyAgreement       []VerificationMethod `json:"keyAgreement,omitempty"`
	Service            []ServiceEndpoint    `json:"service,omitempty"`
}

Document is a did document that describes a did subject. See https://www.w3.org/TR/did-core/#dfn-did-documents. TODO: Should we include the non-standard publicKey field for compatability reasons? See https://w3c.github.io/did-spec-registries/#publickey

type DocumentMetadata

type DocumentMetadata struct {
	Created     string `json:"created,omitempty"`
	Updated     string `json:"updated,omitempty"`
	Deactivated bool   `json:"deactivated,omitempty"`
	VersionID   string `json:"versionId,omitempty"`
}

DocumentMetadata defines a metadata structure consisting of values relating the resolved did document. See https://w3c.github.io/did-core/#did-document-metadata See https://w3c.github.io/did-spec-registries/#did-document-metadata Created is a string formatted as an XML Datetime normalized to UTC 00:00:00 and without sub-second decimal precision. Updated is a string formatted as an XML Datetime normalized to UTC 00:00:00 and without sub-second decimal precision. Deactivated is a boolean value indicating if the associated did document has been deactivated. VersionID indicates the version of the last update operation for the document version which was resolved.

type Registry

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

Registry is the singleton Resolver registery for resolving dids.

func New

func New(resolvers []Resolver, useCache bool) Registry

New creates and returns a new resolver Registry.

func (Registry) Parse

func (r Registry) Parse(did string) (*parse.DID, error)

Parse parses a did url into a did struct.

func (Registry) Resolve

func (r Registry) Resolve(did string, resolutionOptions *ResolutionOptions) (ResolutionMetadata, *Document, DocumentMetadata, error)

Resolve resolves a did url using a Resolver from its internal registry. Currently, resolutionOptions are ignored, as the defaults to not pertain to the resolve function. See https://w3c.github.io/did-core/#did-resolution-options for details.

type ResolutionMetadata

type ResolutionMetadata struct {
	ContentType string `json:"content-type,omitempty"`
	Error       string `json:"error,omitempty"`
}

ResolutionMetadata defined a metadata structure consisting of values relating to the results of the did resolution process. See https://w3c.github.io/did-core/#did-resolution-metadata See https://w3c.github.io/did-spec-registries/#did-resolution-metadata (possibly outdated) ContentType indicates the media type of the returned did document stream. This property must not be present if the resolve function was called. The error code from the resolution process. This property is required when there is an error in the resolution process. Current common error values include: "invalidDid", "notFound", "representationNotSupported"

type ResolutionOptions

type ResolutionOptions struct {
	// Accept indicates the media type of the caller's preferred representation of the did document.
	// This property must not be used with the resolve function.
	Accept string `json:"accept,omitempty"`
}

ResolutionOptions defines a metadata structure containing properties that may be used to control did resolution. See https://w3c.github.io/did-core/#did-resolution-options See https://w3c.github.io/did-spec-registries/#did-resolution-input-metadata

type Resolver

type Resolver interface {
	// Method returns the method that this resolver is capable of resolving.
	Method() string
	// Resolve is the primary resolution method for the Resolver.
	Resolve(did string, parsed *parse.DID, resolver Resolver) (*Document, error)
}

Resolver defines a basic did resolver implementation.

type ServiceEndpoint

type ServiceEndpoint struct {
	ID              string `json:"id"`
	Type            string `json:"type,omitempty"`
	ServiceEndpoint string `json:"serviceEndpoint,omitempty"`
	Description     string `json:"description,omitempty"`
}

ServiceEndpoint descrives a network address, such as an http url, at which services operate on behalf of a did subject. See https://www.w3.org/TR/did-core/#dfn-service-endpoints

type VerificationMethod

type VerificationMethod struct {
	ID                 string `json:"id,omitempty"`
	Type               string `json:"type,omitempty"`
	Controller         string `json:"controller,omitempty"`
	PublicKeyMultibase string `json:"publicKeyMultibase,omitempty"`
	PublicKey          string `json:"publicKey,omitempty"`
}

VerificationMethod describes how to authenticate or authorize interactions with a did subject. See https://www.w3.org/TR/did-core/#dfn-verification-method.

type VerificationString

type VerificationString string

VerificationString describes how to authenticate or authorize interactions with a did subject. See https://www.w3.org/TR/did-core/#dfn-verification-method. See https://www.w3.org/TR/did-core/#did-url-syntax

Jump to

Keyboard shortcuts

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