otc

package
v0.0.0-...-0941746 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

package otc provides alphanumeric One Time Codes that can be used for email-based 2FA, account verification and more.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTokenIsNotValid = errors.New("otc: token is not valid")
)

Functions

func Verify

func Verify(code, token string) bool

Types

type Code

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

func New

func New(length uint16) (code Code, err error)

func (*Code) Code

func (code *Code) Code() string

func (*Code) CodeHTML

func (code *Code) CodeHTML() (ret string)

CodeHTML returns the code wrapped in a <span> and with numbers wrapped in <span style="color: red">

func (*Code) Token

func (code *Code) Token() string

Token returns a token of the form otc.v[N].[XXXX] where [N] is the version number of the token and [XXXX] is Base64URL encoded data The token should be stored in a database or a similar secure place and use it later to verify that a code is valid

type NewCodeOptions

type NewCodeOptions struct {
}

Jump to

Keyboard shortcuts

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