token

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

Index

Constants

View Source
const (
	SecretSize = crypto.KeySize256
	HashSize   = crypto.KeySize256
)

Variables

View Source
var (
	ErrTokenIsNotValid = errors.New("token is not valid")
	ErrDataIsTooLong   = errors.New("data is too long")
)

Functions

This section is empty.

Types

type Token

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

func FromIdAndHash

func FromIdAndHash(prefix string, id guid.GUID, hash []byte) (token Token, err error)

FromIdAndHash creates a new token from an ID and a Hash it means that the token needs to be refreshed with `Refresh` before being able to use it as we din't have the secret, and thus cannot convert it to a valid string

func New

func New(prefix string) (token Token, err error)

func NewWithID

func NewWithID(prefix string, id guid.GUID) (token Token, err error)

func Parse

func Parse(prefix, input string) (token Token, err error)

func (*Token) Hash

func (token *Token) Hash() []byte

func (*Token) ID

func (token *Token) ID() guid.GUID

func (*Token) Refresh

func (token *Token) Refresh() (err error)

func (*Token) Secret

func (token *Token) Secret() []byte

func (*Token) String

func (token *Token) String() string

func (*Token) Verify

func (token *Token) Verify(hash []byte) (err error)

Jump to

Keyboard shortcuts

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