helper

package
v0.0.0-...-a77dc41 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnalyseMap

func AnalyseMap(mapI interface{}, indent string) []string

AnalyseMap kept finding that different issues use different types so created this routine to scan whole structure and print out key, key.(type), value and value.(type) to help diagnose. Not can always see content if use -verbose 1 as does not try to JSON unmarshall

func DebugCBORCommonPayload

func DebugCBORCommonPayload(payload []byte) []string

DebugCBORCommonPayload display type and values

func PettyIdentCommonPayload

func PettyIdentCommonPayload(dcp *datamodel.DGCCommonPayload) (string, error)

PettyIdentCommonPayload pretty ident

func PrettyIdent

func PrettyIdent(i interface{}) (string, error)

PrettyIdent pretty ident some json

func ReadData

func ReadData(path string) (data []byte, err error)

ReadData read a file and return bytes

Types

type Decoder

type Decoder interface {

	//FromFileQRCode assumes file contains a DGC QR code, reads a decodes. If any errors returns what it has
	//managed to decode so far. Accepts either .png or .jpg
	//DOES not verify
	FromFileQRCode(filename string) (*Output, error)

	//FromQRCodePNGBytes decode starting with a QR code PNG represented as bytes
	//first makes a local PNG image and the decodes to get the HC1: representation
	//if an error returns what it has processed so far
	//DOES not verify
	FromQRCodePNGBytes(pngB []byte) (*Output, error)

	//IsDGCFromQRCodeContents returns true if the card is a digital green card, does no processing
	//looks for HCI code
	IsDGCFromQRCodeContents(qrCodeContents []byte) bool

	//FromQRCodeContents decode from the QR code contents, this starts with HC1
	//Does not verify
	FromQRCodeContents(qrCodeContents []byte) (*Output, error)
}

Decoder methods to decode a EU covid certificate

func NewDecoder

func NewDecoder(debug bool, maxDebug bool) Decoder

NewDecoder make a decoder

type Output

type Output struct {

	//Decoded set to true if the decoding completed ok without any issues
	Decoded bool

	//DecodedQRCode the result of reading the QR code
	DecodedQRCode []byte

	//Base45Decoded the result of base45 decoding the decoded QR code
	Base45Decoded []byte

	//Inflated the result of inflating the base45 decoded qr code
	Inflated []byte

	//COSeCBORTag the message is encoded as a CBOR Tagged Message, this is the TAG from the message.
	//currently only handle COSE_Sign1 which is tag 18 see https://datatracker.ietf.org/doc/html/rfc8152#section-2
	COSeCBORTag uint64

	CBORUnmarshalledI       interface{}
	CBORUnmarshalledPayload []byte //cbor encoded payload
	PayloadI                interface{}
	ProtectedHeader         map[int]interface{} // did not make a COSEHeader as wanted to see what else is inside
	UnProtectedHeader       *datamodel.COSEHeader
	COSESignature           []byte

	//CommonPayload the common payload within the credential
	CommonPayload *datamodel.DGCCommonPayload

	//DiagnoseLines the decoding is multi-step if run into issues then diagnostic info is added here
	DiagnoseLines []string //if trying to learn display here
}

Output the results of decoding

func (*Output) DCC

func (o *Output) DCC() *datamodel.DCC

DCC return the (Digital Covid Certificate) inside the record, if none returns nil

type ValueSetMapper

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

ValueSetMapper maps codes to metadata value sets

func NewValueSetMapper

func NewValueSetMapper(vsDataPath string) (*ValueSetMapper, error)

NewValueSetMapper create and initialize all its internal data

func (*ValueSetMapper) DecodeMA

func (vsm *ValueSetMapper) DecodeMA(code string) *datamodel.ValueSetValue

DecodeMA decode the Marketing authorisation holder or manufacturer, a coded value from the value set vaccine-mah-manf.json

func (*ValueSetMapper) DecodeMP

func (vsm *ValueSetMapper) DecodeMP(code string) *datamodel.ValueSetValue

DecodeMP decode the vaccine product name using A coded value from the value set vaccine-medicinal-product.json

func (*ValueSetMapper) DecodeVP

func (vsm *ValueSetMapper) DecodeVP(code string) *datamodel.ValueSetValue

DecodeVP decode the Type of the vaccine or prophylaxis used from the value set vaccine-prophylaxis.json

Jump to

Keyboard shortcuts

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