processor

package
v1.3.1-nbo-0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2023 License: Apache-2.0, MIT Imports: 5 Imported by: 0

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 CoreClaimOptions

type CoreClaimOptions struct {
	RevNonce              uint64 `json:"revNonce"`
	Version               uint32 `json:"version"`
	SubjectPosition       string `json:"subjectPosition"`
	MerklizedRootPosition string `json:"merklizedRootPosition"`
	Updatable             bool   `json:"updatable"`
	MerklizerOpts         []merklize.MerklizeOption
}

CoreClaimOptions is params for core claim parsing

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(ctx context.Context, credential verifiable.W3CCredential, credentialType string, jsonSchemaBytes []byte, options *CoreClaimOptions) (*core.Claim, error)
	ParseSlots(credential verifiable.W3CCredential, schemaBytes []byte) (ParsedSlots, error)
	GetFieldSlotIndex(field string, schema []byte) (int, error)
}

Parser is an interface to parse claim slots

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) ParseClaim

func (s *Processor) ParseClaim(ctx context.Context, credential verifiable.W3CCredential, credentialType string, jsonSchemaBytes []byte, opts *CoreClaimOptions) (*core.Claim, error)

ParseClaim will serialize input data to index and value fields.

func (*Processor) ParseSlots

func (s *Processor) ParseSlots(credential verifiable.W3CCredential, 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.

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
}

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