token

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2025 License: AGPL-3.0-or-later Imports: 10 Imported by: 0

Documentation

Overview

Package token provides functionality to generate, hash, and compare cryptographically secure tokens.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTokenExpired is returned when the token has expired.
	ErrTokenExpired = errors.New("token expired")
)

Functions

func Matches added in v0.0.15

func Matches(token domain.Token, rawToken RawToken) (bool, error)

Matches checks if the given raw token matches the hashed token in the TokenRecord.

func New added in v0.0.15

func New(rawToken RawToken, expiresAt time.Time) (domain.Token, error)

New creates a new TokenRecord by hashing the raw token using scrypt, and returning the TokenRecord.

Types

type RawToken

type RawToken []byte

RawToken represents a raw token as a byte slice.

func GenerateRawToken added in v0.0.15

func GenerateRawToken(keyLen int) (RawToken, error)

GenerateRawToken generates a random token of the specified byte length.

Jump to

Keyboard shortcuts

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