dochandler

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2021 License: Apache-2.0 Imports: 10 Imported by: 8

Documentation

Overview

Package dochandler performs document operation processing and document resolution.

During operation processing it will use configured validator to validate document operation and then it will call batch writer to add it to the batch.

Document resolution is based on ID or encoded original document. 1) ID - the latest document will be returned if found.

2) Encoded original document - The encoded document is hashed using the current supported hashing algorithm to compute ID, after which the resolution is done against the computed ID. If a document cannot be found, the supplied document is used directly to generate and return a resolved document. In this case the supplied document is subject to the same validation as an original document in a create operation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DocumentHandler

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

DocumentHandler implements document handler.

func New

func New(namespace string, aliases []string, pc protocol.Client, writer batchWriter, processor operationProcessor, opts ...Option) *DocumentHandler

New creates a new document handler with the context.

func (*DocumentHandler) Namespace

func (r *DocumentHandler) Namespace() string

Namespace returns the namespace of the document handler.

func (*DocumentHandler) ProcessOperation

func (r *DocumentHandler) ProcessOperation(operationBuffer []byte, protocolGenesisTime uint64) (*document.ResolutionResult, error)

ProcessOperation validates operation and adds it to the batch.

func (*DocumentHandler) ResolveDocument

func (r *DocumentHandler) ResolveDocument(shortOrLongFormDID string) (*document.ResolutionResult, error)

ResolveDocument fetches the latest DID Document of a DID. Two forms of string can be passed in the URI:

1. Standard DID format: did:METHOD:<did-suffix>

2. Long Form DID format: did:METHOD:<did-suffix>:Base64url(JCS({suffix-data-object, delta-object}))

Standard resolution is performed if the DID is found to be registered on the anchoring system. If the DID Document cannot be found, the <suffix-data-object> and <delta-object> are used to generate and return resolved DID Document. In this case the supplied delta and suffix objects are subject to the same validation as during processing create operation.

type Option added in v0.7.0

type Option func(opts *DocumentHandler)

Option is an option for document handler.

func WithDomain added in v0.7.0

func WithDomain(domain string) Option

WithDomain sets optional domain hint for unpublished/interim documents.

func WithLabel added in v0.7.0

func WithLabel(label string) Option

WithLabel sets optional label for unpublished/interim documents.

func WithUnpublishedOperationStore added in v0.7.0

func WithUnpublishedOperationStore(store unpublishedOperationStore, operationTypes []operation.Type) Option

WithUnpublishedOperationStore stores unpublished operation into unpublished operation store.

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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