dochandler

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: Apache-2.0 Imports: 9 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 *operation.QueuedOperation, protocolGenesisTime uint64) 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, aliases []string, pc protocol.Client, 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(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 OperationProcessor

type OperationProcessor interface {
	Resolve(uniqueSuffix string) (*protocol.ResolutionModel, error)
}

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

Jump to

Keyboard shortcuts

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