hub

package
v0.0.0-...-84b55d0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NotAuthorizedErr     = errors.New("not authorized")
	AlreadyAuthorizedErr = errors.New("already authorized")
)

Functions

This section is empty.

Types

type Hub

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

func NewHub

func NewHub(opts Opts) *Hub

func (*Hub) AppHash

func (h *Hub) AppHash() string

func (*Hub) AppID

func (h *Hub) AppID() int

func (*Hub) AuthPutCode

func (h *Hub) AuthPutCode(ctx context.Context, user store.User, phone, code string) (need2fa bool, err error)

func (*Hub) AuthPutPass2FA

func (h *Hub) AuthPutPass2FA(ctx context.Context, user store.User, phone, pass2fa string) error

func (*Hub) AuthStart

func (h *Hub) AuthStart(ctx context.Context, user store.User, phone string) error

func (*Hub) Run

func (h *Hub) Run(ctx context.Context) error

func (*Hub) SendReport

func (h *Hub) SendReport(ctx context.Context, user store.User, phone, url, msg string) (store.Report, error)

type Opts

type Opts struct {
	Context     context.Context
	DB          store.Store
	Logger      *zap.Logger
	PublicKey   *rsa.PublicKey
	AppHash     string
	DeviceModel string
	AppVersion  string
	DCOption    struct {
		IPAddress string
		ID        int
		Port      int
	}
	ClientTTL time.Duration
	AppID     int
}

type ResolveURLErr

type ResolveURLErr struct {
	Err error
	URL string
}

func (*ResolveURLErr) Error

func (r *ResolveURLErr) Error() string

type StoreSession

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

func NewStoreSession

func NewStoreSession(user store.User, phone string, db UserStore) *StoreSession

func (*StoreSession) LoadSession

func (s *StoreSession) LoadSession(_ context.Context) ([]byte, error)

LoadSession loads session from store

func (*StoreSession) StoreSession

func (s *StoreSession) StoreSession(ctx context.Context, data []byte) error

StoreSession stores session to store

type UserStore

type UserStore interface {
	GetUser(id int64) (store.User, error)
	PutUser(user store.User) error
}

Jump to

Keyboard shortcuts

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