Documentation
¶
Overview ¶
Package auth provides some interfaces, implementations and utility function for telegram.UserAuthenticator.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrSignUpIsNotExpected = xerrors.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) telegram.UserAuthenticator
Build creates new UserAuthenticator.
Types ¶
type Ask ¶
type Ask interface { telegram.CodeAuthenticator SignUpFlow }
Ask represents parts of auth flow which requires user interaction.
func BuildAsk ¶
func BuildAsk(code telegram.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 CredentialNotFoundError ¶
type CredentialNotFoundError struct {
Which CredentialType
}
CredentialNotFoundError should be returned, when credential not found.
func (*CredentialNotFoundError) Error ¶
func (c *CredentialNotFoundError) Error() string
func (CredentialNotFoundError) Is ¶
func (CredentialNotFoundError) Is(err error) bool
type CredentialType ¶
type CredentialType string
CredentialType represents user credential type.
const ( Phone CredentialType = "phone" Password CredentialType = "password" Code CredentialType = "code" Info CredentialType = "userinfo" )
func (CredentialType) String ¶
func (c CredentialType) String() string
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) (telegram.UserInfo, error) }
SignUpFlow is abstraction for user signup setup.
func ConstantSignUp ¶
func ConstantSignUp(info telegram.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 terminal contains authenticator implementation using terminal.
|
Package terminal contains authenticator implementation using terminal. |
Package vault contains gotd secret storage implementations using Hashicorp Vault.
|
Package vault contains gotd secret storage implementations using Hashicorp Vault. |