backend

package
v0.0.0-...-32f009b Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2018 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

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

func NewBackend

func NewBackend(trans Transport, km *km.KeyManager, signedPreKeyStorage db.SignedPreKeyStorage) (*Backend, error)

func (*Backend) AddRequestHandler

func (b *Backend) AddRequestHandler(handler RequestHandler)

Add request handler that will be executed

func (*Backend) Close

func (b *Backend) Close() error

func (*Backend) FetchPreKeyBundle

func (b *Backend) FetchPreKeyBundle(userIDPubKey ed25519.PublicKey) (x3dh.PreKeyBundle, error)

fetch pre key bundle from backend

func (*Backend) FetchSignedPreKey

func (b *Backend) FetchSignedPreKey(userIdPubKey ed25519.PublicKey) (preKey.PreKey, error)

fetch signed pre key of person

func (*Backend) SubmitMessages

func (b *Backend) SubmitMessages(messages []*bpb.ChatMessage) error

submit messages

type PreKeyBundle

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

func PreKeyBundleFromProto

func PreKeyBundleFromProto(pubKey ed25519.PublicKey, protoPreKeyBundle *bpb.BackendMessage_PreKeyBundle) (*PreKeyBundle, error)

func (*PreKeyBundle) IdentityKey

func (b *PreKeyBundle) IdentityKey() x3dh.PublicKey

func (*PreKeyBundle) OneTimePreKey

func (b *PreKeyBundle) OneTimePreKey() *x3dh.PublicKey

func (*PreKeyBundle) SignedPreKey

func (b *PreKeyBundle) SignedPreKey() x3dh.PublicKey

func (*PreKeyBundle) ValidSignature

func (b *PreKeyBundle) ValidSignature() (bool, error)

type RequestHandler

type RequestHandler func(req *bpb.BackendMessage_Request) (*bpb.BackendMessage_Response, error)

IMPORTANT - the returned error will be send to the backend. Make sure it only return an error message that doesn't have private information

type ServerConfig

type ServerConfig struct {
	WebSocketUrl string
	BearerToken  string
}

type Transport

type Transport interface {
	// will be called by the backend to send a message
	Send(msg *bpb.BackendMessage) error
	// will return the next message from the transport
	NextMessage() (*bpb.BackendMessage, error)
	// close the transport
	Close() error
}

type WSTransport

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

func NewWSTransport

func NewWSTransport(endpoint, bearerToken string, km *keyManager.KeyManager) *WSTransport

func (*WSTransport) Close

func (t *WSTransport) Close() error

func (*WSTransport) NextMessage

func (t *WSTransport) NextMessage() (*bpb.BackendMessage, error)

func (*WSTransport) Send

func (t *WSTransport) Send(msg *bpb.BackendMessage) error

Jump to

Keyboard shortcuts

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