otp

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2023 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

This section is empty.

Types

type IOTP

type IOTP interface {
	SendSMS(ormService *datalayer.ORM, phone *Phone) (string, error)
	VerifyOTP(ormService *datalayer.ORM, phone *Phone, code string) (bool, bool, error)
	Call(ormService *datalayer.ORM, phone *Phone, customMessage string) (string, error)
	GetGatewayRegistry() map[string]IOTPSMSGateway
}

type IOTPSMSGateway

type IOTPSMSGateway interface {
	GetName() string
	GetCode() string
	GetPhonePrefixes() []string
	SendOTP(phone *Phone, code string) (string, string, error)
	Call(phone *Phone, code string, customMessage 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) Call added in v1.0.0

func (m *Mada) Call(_ *Phone, _ string, _ string) (string, string, error)

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 OTP

type OTP struct {
	GatewayPriority         []IOTPSMSGateway
	GatewayName             map[string]IOTPSMSGateway
	GatewayPhonePrefixRegex map[*regexp.Regexp]IOTPSMSGateway
	RetryOTP                bool
}

func NewOTP

func NewOTP(retryOTP bool, gateways ...IOTPSMSGateway) *OTP

func (*OTP) Call added in v0.9.45

func (o *OTP) Call(ormService *datalayer.ORM, phone *Phone, customMessage string) (string, error)

func (*OTP) GetGatewayRegistry added in v1.1.40

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

func (*OTP) SendSMS

func (o *OTP) SendSMS(ormService *datalayer.ORM, phone *Phone) (string, error)

func (*OTP) VerifyOTP added in v0.9.45

func (o *OTP) VerifyOTP(ormService *datalayer.ORM, phone *Phone, code string) (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 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) Call added in v0.9.91

func (s *Sinch) Call(_ *Phone, _ string, _ string) (string, string, error)

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) Call added in v0.9.45

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

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)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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