otpauth

package
v0.0.0-...-5eebb81 Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package otpauth implements encoding and decoding functionality for the otpauth URI scheme, defined by google (https://github.com/google/google-authenticator/wiki/Key-Uri-Format).

Index

Constants

View Source
const (
	TOTP = "totp"
	HOTP = "hotp"
)

Variables

View Source
var (
	ErrUnsupportedURIScheme     = errors.New("unsupported uri scheme")
	ErrUnsupportedOTPAlgorithm  = errors.New("unsupported otp algorithm")
	ErrInvalidSecretEncoding    = errors.New("invalid secret encoding")
	ErrUnsupportedHashAlgorithm = errors.New("unsupported hash algorithm")
	ErrNoCounterPresent         = errors.New("no counter present")
)

Functions

func ToURI

func ToURI(algorithm otp.Algorithm, accountName string, opts ...EncoderOption) string

Types

type AlgorithmParameters

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

func FromURI

func FromURI(value string) (*AlgorithmParameters, error)

func (*AlgorithmParameters) AccountName

func (d *AlgorithmParameters) AccountName() string

func (*AlgorithmParameters) Algorithm

func (d *AlgorithmParameters) Algorithm() otp.Algorithm

func (*AlgorithmParameters) Counter

func (d *AlgorithmParameters) Counter() int64

func (*AlgorithmParameters) Issuer

func (d *AlgorithmParameters) Issuer() string

func (*AlgorithmParameters) Key

func (d *AlgorithmParameters) Key() []byte

func (*AlgorithmParameters) Type

func (d *AlgorithmParameters) Type() Type

type Encoder

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

func NewEncoder

func NewEncoder(alg otp.Algorithm, accountName string, opts ...EncoderOption) *Encoder

func (*Encoder) Encode

func (e *Encoder) Encode() string

type EncoderOption

type EncoderOption func(enc *exporter)

func WithCounter

func WithCounter(counter int64) EncoderOption

func WithIssuer

func WithIssuer(issuer string) EncoderOption

type Type

type Type string

Jump to

Keyboard shortcuts

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