otp

package
v1.3.148 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2024 License: GPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const SMSOTPProviderMada = "Mada"
View Source
const SMSOTPProviderMobica = "Mobica"
View Source
const SMSOTPProviderSinch = "Sinch"
View Source
const SMSOTPProviderTwilio = "Twilio"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v1.3.105

type Config struct {
	ClockService     clock.IClock
	SMSConfig        SMSConfig
	MailConfig       MailConfig
	CodeLength       int
	GeneratorService generator.IGenerator
}

type Email added in v1.3.105

type Email struct {
	Email string
}

type EmailConfig added in v1.3.105

type EmailConfig struct {
	From         string
	Subject      string
	TemplateName string
}

type IOTP

type IOTP interface {
	Send(ormService *beeorm.Engine, send Send) (string, error)
	Verify(ormService *beeorm.Engine, verify Verify) (bool, bool, error)
	GetSMSGatewayRegistry() map[string]IOTPSMSGateway
}

type IOTPSMSGateway

type IOTPSMSGateway interface {
	GetName() string
	GetCode() string
	GetPhonePrefixes() []string
	SendOTP(phone *Phone, code string) (string, string, error)
	VerifyOTP(phone *Phone, code, generatedCode string) (string, string, bool, bool, error)
}

type Mada added in v1.0.0

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

func NewMadaSMSOTPProvider added in v1.0.0

func NewMadaSMSOTPProvider(
	username string,
	password string,
	url string,
	sourceName string,
	otpLength int,
	phonePrefixes []string,
	generatorService generator.IGenerator,
) *Mada

func (*Mada) GetCode added in v1.0.0

func (m *Mada) GetCode() string

func (*Mada) GetName added in v1.0.0

func (m *Mada) GetName() string

func (*Mada) GetPhonePrefixes added in v1.0.0

func (m *Mada) GetPhonePrefixes() []string

func (*Mada) SendOTP added in v1.0.0

func (m *Mada) SendOTP(phone *Phone, code string) (string, string, error)

func (*Mada) VerifyOTP added in v1.0.0

func (m *Mada) VerifyOTP(_ *Phone, code, generatedCode string) (string, string, bool, bool, error)

type MailConfig added in v1.3.105

type MailConfig struct {
	Sender mail.ISender
}

type Mobica added in v1.3.93

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

func NewMobicaSMSOTPProvider added in v1.3.93

func NewMobicaSMSOTPProvider(mobicaProvider sms.IProvider) *Mobica

func (*Mobica) GetCode added in v1.3.93

func (m *Mobica) GetCode() string

func (*Mobica) GetName added in v1.3.93

func (m *Mobica) GetName() string

func (*Mobica) GetPhonePrefixes added in v1.3.93

func (m *Mobica) GetPhonePrefixes() []string

func (*Mobica) SendOTP added in v1.3.93

func (m *Mobica) SendOTP(phone *Phone, code string) (string, string, error)

func (*Mobica) VerifyOTP added in v1.3.93

func (m *Mobica) VerifyOTP(_ *Phone, code, generatedCode string) (string, string, bool, bool, error)

type OTP

type OTP struct {
	ClockService               clock.IClock
	GeneratorService           generator.IGenerator
	SMSGatewayPriority         []IOTPSMSGateway
	SMSGatewayName             map[string]IOTPSMSGateway
	SMSGatewayPhonePrefixRegex map[*regexp.Regexp]IOTPSMSGateway
	SMSRetryOTP                bool
	MailSender                 mail.ISender
	CodeLength                 int
}

func NewOTP

func NewOTP(config Config) *OTP

func (*OTP) GetSMSGatewayRegistry added in v1.3.105

func (o *OTP) GetSMSGatewayRegistry() map[string]IOTPSMSGateway

func (*OTP) Send added in v1.3.105

func (o *OTP) Send(ormService *beeorm.Engine, send Send) (string, error)

func (*OTP) Verify added in v1.3.105

func (o *OTP) Verify(ormService *beeorm.Engine, verify Verify) (bool, bool, error)

type Phone

type Phone struct {
	Number  string
	ISO3166 phonenumber.ISO3166
}

type RetryDTO added in v1.1.33

type RetryDTO struct {
	Code               string
	Phone              *Phone
	OTPTrackerEntityID uint64
	Gateway            string
}

type SMSConfig added in v1.3.105

type SMSConfig struct {
	SMSGateways []IOTPSMSGateway
	RetryOTP    bool
}

type Send added in v1.3.105

type Send struct {
	Phone            *Phone
	SMSCustomMessage string
	Email            *Email
	EmailConfig      *EmailConfig
}

type Sinch added in v0.9.91

type Sinch struct {
	AppID           string
	AppSecret       string
	VerificationURL string
}

func NewSinchSMSOTPProvider added in v0.9.91

func NewSinchSMSOTPProvider(appID, appSecret, verificationURL string) *Sinch

func (*Sinch) GetCode added in v0.9.91

func (s *Sinch) GetCode() string

func (*Sinch) GetName added in v0.9.91

func (s *Sinch) GetName() string

func (*Sinch) GetPhonePrefixes added in v1.0.0

func (s *Sinch) GetPhonePrefixes() []string

func (*Sinch) SendOTP added in v0.9.91

func (s *Sinch) SendOTP(phone *Phone, _ string) (string, string, error)

func (*Sinch) VerifyOTP added in v0.9.91

func (s *Sinch) VerifyOTP(phone *Phone, code, _ string) (string, string, bool, bool, error)

type Twilio

type Twilio struct {
	Client          *twilio.RestClient
	VerificationSID string
}

func NewTwilioSMSOTPProvider

func NewTwilioSMSOTPProvider(accountSid, authToken, verificationSid string) *Twilio

func (*Twilio) GetCode

func (t *Twilio) GetCode() string

func (*Twilio) GetName

func (t *Twilio) GetName() string

func (*Twilio) GetPhonePrefixes added in v1.0.0

func (t *Twilio) GetPhonePrefixes() []string

func (*Twilio) SendOTP

func (t *Twilio) SendOTP(phone *Phone, _ string) (string, string, error)

func (*Twilio) VerifyOTP

func (t *Twilio) VerifyOTP(phone *Phone, code, _ string) (string, string, bool, bool, error)

type Verify added in v1.3.105

type Verify struct {
	Phone *Phone
	Email *Email
	Code  string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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