otp

package
v0.0.0-...-e31961d Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2022 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeLength4 = 4
	CodeLength6 = 6
)

legnth of code for otp

View Source
const (
	ThresholdOTPResend   int = 3
	ThresholdOTPValidate int = 10
)

list of otp threshold

View Source
const (
	OTPKeyExpiry = time.Hour * 24

	// expire time for otp
	ExpiryTimeDefault = time.Minute * 4

	// the default time for expiring otp is 90 seconds
	ResendTimeDefault        = time.Second * 90
	ResendTimeAfterThreshold = time.Minute * 30
	// the maximum time for otp exiry is 1 day
	ResendTimeMax = time.Hour * 24
)

list of expiry time

Variables

View Source
var (
	ErrCodeLengthInvalid          = errors.New("otp: code length is invalid")
	ErrOTPInvalid                 = errors.New("otp: password invalid")
	ErrOTPExpired                 = errors.New("otp: otp already expired")
	ErrOTPReachResendMaxAttempt   = errors.New("otp: reach maximum resend attempt")
	ErrOTPReachValidateMaxAttempt = errors.New("otp: reach maximum validate attempt, too many wrong password")
	ErrOTPNotResendable           = errors.New("otp: not resendable")
)

list of otp errors

Functions

This section is empty.

Types

type CodeLength

type CodeLength int

CodeLength type

func (CodeLength) Validate

func (clength CodeLength) Validate() error

Validate code length

type OTP

type OTP struct {
	UniqueID     string            `json:"unique_id"`
	Action       authentity.Action `json:"action"`
	Code         string            `json:"code"`
	CreatedAt    time.Time         `json:"created_at"`
	ExpiryTime   time.Duration     `json:"expiry_time"`
	ExpiredAt    time.Time         `json:"expired_at"`
	ResendTime   time.Duration     `json:"resend_time"`
	ResendableAt time.Time         `json:"resendable_at"`
}

OTP struct

func (OTP) IsResendable

func (otp OTP) IsResendable() (bool, error)

IsResendable return whether otp is resendable or not

Jump to

Keyboard shortcuts

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