dochandler

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2020 License: Apache-2.0 Imports: 14 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 BatchWriter

type BatchWriter interface {
	Add(operation *batch.OperationInfo) error
}

BatchWriter is an interface to add an operation to the batch

type DocumentHandler

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

DocumentHandler implements document handler

func New

func New(namespace string, protocol protocol.Client, validator DocumentValidator, writer BatchWriter, processor OperationProcessor) *DocumentHandler

New creates a new requestHandler 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(operation *batch.Operation) (*document.ResolutionResult, error)

ProcessOperation validates operation and adds it to the batch

func (*DocumentHandler) Protocol

func (r *DocumentHandler) Protocol() protocol.Client

Protocol returns the protocol provider

func (*DocumentHandler) ResolveDocument

func (r *DocumentHandler) ResolveDocument(idOrInitialDoc 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. DID with initial-state DID parameter (Long-Form DID URIs) did:METHOD:<did-suffix>?initial-state=<create-suffix-data-object>.<create-delta-object>

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

type DocumentValidator

type DocumentValidator interface {
	IsValidOriginalDocument(payload []byte) error
	IsValidPayload(payload []byte) error
	TransformDocument(doc document.Document) (*document.ResolutionResult, error)
}

DocumentValidator is an interface for validating document operations

type OperationProcessor

type OperationProcessor interface {
	Resolve(uniqueSuffix string) (*document.ResolutionResult, error)
}

OperationProcessor is an interface which resolves the document based on the ID

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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