processor

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2022 License: AGPL-3.0 Imports: 4 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrSlotsOverflow thrown on claim slot overflow
	ErrSlotsOverflow = errors.New("slots overflow")
)

Functions

This section is empty.

Types

type Opt

type Opt func(opts *Processor)

Opt returns configuration options for processor suite

func WithParser

func WithParser(s Parser) Opt

WithParser return new options

func WithSchemaLoader

func WithSchemaLoader(s SchemaLoader) Opt

WithSchemaLoader return new options

func WithValidator

func WithValidator(s Validator) Opt

WithValidator return new options

type ParsedSlots

type ParsedSlots struct {
	IndexA, IndexB []byte
	ValueA, ValueB []byte
}

ParsedSlots is struct that represents iden3 claim specification

type Parser

type Parser interface {
	ParseClaim(credentialBytes *verifiable.Iden3Credential, schemaBytes []byte) (*core.Claim, error)
	ParseSlots(data, schema []byte) (ParsedSlots, error)
	GetFieldSlotIndex(field string, schema []byte) (int, error)
}

Parser is an interface to parse claim slots

type ParsingStrategy

type ParsingStrategy int

ParsingStrategy is used for parser to know how to fill claim slots

const (
	// OneFieldPerSlotStrategy is strategy when one field corresponds exactly to the one slot
	OneFieldPerSlotStrategy ParsingStrategy = iota + 1

	// SlotFullfilmentStrategy is strategy when field putting in the claim slot sequentially
	SlotFullfilmentStrategy
)

type Processor

type Processor struct {
	Validator    Validator
	SchemaLoader SchemaLoader
	Parser       Parser
}

Processor is set of tool for claim processing

func InitProcessorOptions

func InitProcessorOptions(processor *Processor, opts ...Opt) *Processor

InitProcessorOptions initializes processor with options.

func (*Processor) GetFieldSlotIndex

func (s *Processor) GetFieldSlotIndex(field string, schema []byte) (int, error)

GetFieldSlotIndex returns index of slot for specified field according to schema

func (*Processor) Load

func (s *Processor) Load(ctx context.Context) (schema []byte, extension string, err error)

Load will load a schema by given url.

func (*Processor) ParseSlots

func (s *Processor) ParseSlots(data, schema []byte) (ParsedSlots, error)

ParseSlots will serialize input data to index and value fields.

func (*Processor) ValidateData

func (s *Processor) ValidateData(data, schema []byte) error

ValidateData will validate a claim content by given schema.

func (*Processor) ValidateDocument

func (s *Processor) ValidateDocument(data, schema []byte) error

ValidateDocument will validate a document content by given schema.

type SchemaLoader

type SchemaLoader interface {
	Load(ctx context.Context) (schema []byte, extension string, err error)
}

SchemaLoader is interface to load schema

type Validator

type Validator interface {
	ValidateData(data, schema []byte) error
	ValidateDocument(doc, schema []byte) error
}

Validator is interface to validate data and documents

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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