core

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxNameLength = 128
	MinNameLength = 1
)

Name validation constraints

Variables

View Source
var (
	ErrInvalidHash  = errors.New("invalid hash format")
	ErrInvalidToken = errors.New("invalid token format")
	ErrHashMismatch = errors.New("token does not match hash")
)

Functions

func BuildToken

func BuildToken(lookup, secret string) string

BuildToken constructs a token string from its components. Format: eph_<lookup>_<secret>

func GenerateTokenSecret

func GenerateTokenSecret(length int) (string, error)

GenerateTokenSecret generates a cryptographically secure random hex string.

func HashToken

func HashToken(token string) (string, error)

HashToken creates an argon2id hash of the token with a random salt. Returns the hash in PHC string format: $argon2id$v=19$m=65536,t=1,p=4$<salt>$<hash>

func IsValidNameChar

func IsValidNameChar(r rune, isFirst bool) bool

IsValidNameChar returns true if the rune is valid in a name. For the first character, only ASCII letters and digits are allowed. For subsequent characters, dots, underscores, and hyphens are also allowed.

func ParseToken

func ParseToken(token string) (lookup, secret string, err error)

ParseToken extracts components from a token string. Returns lookup key and secret.

func ValidateName added in v0.0.5

func ValidateName(name string) error

ValidateName validates a namespace or repository name.

func ValidateNameInput

func ValidateNameInput(runes []rune, currentText string) bool

ValidateNameInput validates a sequence of runes being added to an existing name. Returns true if all runes are valid for their position in the resulting string.

func VerifyToken

func VerifyToken(token, encodedHash string) error

VerifyToken checks if a token matches an argon2id hash. Returns nil if the token matches, ErrHashMismatch if it doesn't.

Types

This section is empty.

Jump to

Keyboard shortcuts

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