pnv10n

package
v0.0.0-...-2754675 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package pnv10n provides utility for verifying phone numbers.

pnv10n = phone-number verification.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrVerificationCodeMismatch = errors.New("code mismatch")
	ErrVerificationCodeExpired  = errors.New("code expired")
)

Functions

func ModuleConfigSkeletons

func ModuleConfigSkeletons() map[string]interface{}

func ModuleNames

func ModuleNames() []string

func RegisterModule

func RegisterModule(
	serviceName string,
	module Module,
)

Types

type Config

type Config struct {
	// The default code TTL
	CodeTTLDefault time.Duration `env:"CODE_TTL_DEFAULT"`
	// The maximum number of failed attempts for a verification request
	ConfirmationAttemptsMax int16 `env:"CONFIRMATION_ATTEMPTS_MAX"`
	// For use with SMS Retriever API https://developers.google.com/identity/sms-retriever/overview
	SMSRetrieverAppHash string `env:"SMS_RETRIEVER_APP_HASH"`
	// The SMS delivery service to use.
	SMSDeliveryService string `env:"SMS_DELIVERY_SERVICE,required"`
	// Configurations for modules
	Modules map[string]interface{} `env:",map,squash"`
}

func ConfigFromEnv

func ConfigFromEnv(prefix string, seedCfg *Config) (*Config, error)

func ConfigSkeleton

func ConfigSkeleton() Config

type ConfigurationError

type ConfigurationError struct {
	Err error
}

func (ConfigurationError) Error

func (err ConfigurationError) Error() string

type GatewayError

type GatewayError struct {
	Err error
}

func (GatewayError) Error

func (err GatewayError) Error() string

type InvalidPhoneNumberError

type InvalidPhoneNumberError struct {
	Err error
}

func (InvalidPhoneNumberError) Error

func (err InvalidPhoneNumberError) Error() string

type Module

type Module struct {
	ConfigSkeleton        func() interface{} // returns pointer
	NewSMSDeliveryService func(config interface{}) SMSDeliveryService
}

type PhoneNumberRegionNotSupportedError

type PhoneNumberRegionNotSupportedError struct {
	Err error
}

func (PhoneNumberRegionNotSupportedError) Error

type SMSDeliveryService

type SMSDeliveryService interface {
	SendTextMessage(recipientPhoneNumber, text string) error
}

func NewSMSDeliveryService

func NewSMSDeliveryService(
	serviceName string, config interface{},
) (SMSDeliveryService, error)

type VerificationMethod

type VerificationMethod int
const (
	VerificationMethodUnspecified VerificationMethod = iota
	VerificationMethodNone
	VerificationMethodSMS
)

func VerificationMethodFromString

func VerificationMethodFromString(str string) VerificationMethod

type Verifier

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

func NewVerifier

func NewVerifier(
	appName string,
	db *sqlx.DB,
	config Config,
) *Verifier

func (*Verifier) ConfirmVerification

func (verifier *Verifier) ConfirmVerification(
	callCtx iam.CallContext,
	verificationID int64, code string,
) error

func (*Verifier) GetPhoneNumberByVerificationID

func (verifier *Verifier) GetPhoneNumberByVerificationID(
	verificationID int64,
) (*iam.PhoneNumber, error)

func (*Verifier) GetVerificationCodeByPhoneNumber

func (verifier *Verifier) GetVerificationCodeByPhoneNumber(
	phoneNumber iam.PhoneNumber,
) (code string, err error)

func (*Verifier) StartVerification

func (verifier *Verifier) StartVerification(
	callCtx iam.CallContext,
	phoneNumber iam.PhoneNumber,
	codeTTL time.Duration,
	userPreferredLanguages []language.Tag,
	preferredVerificationMethods []VerificationMethod,
) (id int64, codeExpiry *time.Time, err error)

TODO(exa): make the operations atomic

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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