auth

package
v0.0.0-...-5d712d2 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package auth provides some interfaces, implementations and utility function for telegram.UserAuthenticator.

Index

Constants

This section is empty.

Variables

View Source
var ErrSignUpIsNotExpected = errors.New("signup call is not expected")

ErrSignUpIsNotExpected is returned, when sign up request from Telegram server is not expected.

Functions

func Build

func Build(cred Credentials, ask Ask) tgauth.UserAuthenticator

Build creates new UserAuthenticator.

Types

type Ask

type Ask interface {
	tgauth.CodeAuthenticator
	SignUpFlow
}

Ask represents parts of auth flow which requires user interaction.

func BuildAsk

func BuildAsk(code tgauth.CodeAuthenticator, signUp SignUpFlow) Ask

BuildAsk creates new Ask.

type AutoAccept

type AutoAccept struct{}

AutoAccept is noop implementation of AcceptTermsOfService call.

func (AutoAccept) AcceptTermsOfService

func (AutoAccept) AcceptTermsOfService(ctx context.Context, tos tg.HelpTermsOfService) error

AcceptTermsOfService partly implements SignUpFlow.

type Credentials

type Credentials interface {
	Phone(ctx context.Context) (string, error)
	Password(ctx context.Context) (string, error)
}

Credentials represents Telegram user credentials.

type SignUpFlow

type SignUpFlow interface {
	AcceptTermsOfService(ctx context.Context, tos tg.HelpTermsOfService) error
	SignUp(ctx context.Context) (tgauth.UserInfo, error)
}

SignUpFlow is abstraction for user signup setup.

func ConstantSignUp

func ConstantSignUp(info tgauth.UserInfo) SignUpFlow

ConstantSignUp creates new SignUpFlow using given User info.

func NoSignUp

func NoSignUp() SignUpFlow

NoSignUp creates new SignUpFlow which returns ErrSignUpIsNotExpected.

Directories

Path Synopsis
Package dialog contains GUI dialog Telegram authenticator.
Package dialog contains GUI dialog Telegram authenticator.
Package kv contains wrapper implementations over generic KV storage.
Package kv contains wrapper implementations over generic KV storage.
Package localization contains localization helpers for terminal and dialog authenticator.
Package localization contains localization helpers for terminal and dialog authenticator.
Package terminal contains authenticator implementation using terminal.
Package terminal contains authenticator implementation using terminal.

Jump to

Keyboard shortcuts

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