dochandler

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2023 License: Apache-2.0 Imports: 11 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

func GetCreateResult added in v1.0.0

func GetCreateResult(op *operation.Operation, pv protocol.Version) (*protocol.ResolutionModel, error)

func GetHint added in v1.0.0

func GetHint(id, namespace, suffix string) (string, error)

GetHint returns hint from id.

func GetTransformationInfoForPublished added in v1.0.0

func GetTransformationInfoForPublished(namespace, id, suffix string,
	internalResult *protocol.ResolutionModel) protocol.TransformationInfo

GetTransformationInfoForPublished will create transformation info object for published document.

func GetTransformationInfoForUnpublished added in v1.0.0

func GetTransformationInfoForUnpublished(namespace, domain, label, suffix, createRequestJCS string) protocol.TransformationInfo

GetTransformationInfoForUnpublished will create transformation info object for unpublished document.

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,
	metrics metricsProvider, 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, protocolVersion uint64) (*document.ResolutionResult, error)

ProcessOperation validates operation and adds it to the batch.

func (*DocumentHandler) ResolveDocument

func (r *DocumentHandler) ResolveDocument(shortOrLongFormDID string,
	opts ...document.ResolutionOption) (*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 WithOperationDecorator added in v1.0.0

func WithOperationDecorator(decorator operationDecorator) Option

WithOperationDecorator sets an optional operation decorator (used for additional business validation/pre-processing).

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