iden3comm

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: Apache-2.0, MIT Imports: 6 Imported by: 3

README

iden3comm

Golang implementation of iden3comm protocol

Contributing

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as below, without any additional terms or conditions.

License

© 2023 0kims Association

This project is licensed under either of

at your option.

Documentation

Overview

Package iden3comm defines core structures and intefaces for the messaging protocol

Index

Constants

View Source
const Iden3Protocol = "https://iden3-communication.io/"

Iden3Protocol is a const for protocol definition

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicMessage

type BasicMessage struct {
	ID       string          `json:"id"`
	Typ      MediaType       `json:"typ,omitempty"`
	Type     ProtocolMessage `json:"type"`
	ThreadID string          `json:"thid,omitempty"`
	Body     json.RawMessage `json:"body,omitempty"`

	From string `json:"from,omitempty"`
	To   string `json:"to,omitempty"`
}

BasicMessage is structure for message with unknown body format

type MediaType

type MediaType string

MediaType is media type for iden3comm messages

type PackageManager

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

PackageManager is a registry of packers for iden3comm protocol

func NewPackageManager

func NewPackageManager() *PackageManager

NewPackageManager return new packager

func (*PackageManager) GetMediaType

func (r *PackageManager) GetMediaType(envelope []byte) (MediaType, error)

GetMediaType returns MediaType of envelope

func (*PackageManager) Pack

func (r *PackageManager) Pack(mediaType MediaType, payload []byte, params PackerParams) ([]byte, error)

Pack performs packing of message with a given mediatype

func (*PackageManager) RegisterPackers

func (r *PackageManager) RegisterPackers(packers ...Packer) error

RegisterPackers adds new packers to packageManager

func (*PackageManager) TrimDoubleQuoutes

func (r *PackageManager) TrimDoubleQuoutes(msg []byte) []byte

TrimDoubleQuoutes removes double quotes from message

func (*PackageManager) Unpack

func (r *PackageManager) Unpack(envelope []byte) (*BasicMessage, MediaType, error)

Unpack returns iden3 message method from envelope if it's not valid or can't be decrypted error is returned

func (*PackageManager) UnpackWithType

func (r *PackageManager) UnpackWithType(mediaType MediaType, envelope []byte) (*BasicMessage, error)

UnpackWithType unpack envelop with target media type.

type Packer

type Packer interface {
	// Pack a payload of type ContentType in an Iden3 compliant format using the packer identity
	Pack(payload []byte, params PackerParams) ([]byte, error)
	// Unpack an envelope in Iden3 compliant format.
	Unpack(envelope []byte) (*BasicMessage, error)
	// MediaType returns content type of message
	MediaType() MediaType
}

Packer converts message to encrypted or encoded form

type PackerParams

type PackerParams interface {
	Params()
}

PackerParams mock interface for packer params

type ProtocolMessage

type ProtocolMessage string

ProtocolMessage is IDEN3Comm message

Directories

Path Synopsis
Package mock defines mocks for protocol testing
Package mock defines mocks for protocol testing
Package packers defines core 3 protocol packers: anoncrypt, plain and zkp
Package packers defines core 3 protocol packers: anoncrypt, plain and zkp
Package protocol defines core protocol messages
Package protocol defines core protocol messages

Jump to

Keyboard shortcuts

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