verifiable

package
v0.0.0-...-99ca00c Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTokenNotAuthenticated = errors.New("token: value could not be authenticated")

ErrTokenNotAuthenticated is raised when you try to validate a non compliant value.

Functions

func Token

func Token(source UUIDGeneratorFunc, secretKey []byte) token.Generator

Types

type Extractor

type Extractor[T any] interface {
	Extract(t string) (T, error)
}

Extractor describes content extractor for wrapped values.

type GenerateOption

type GenerateOption func(*generateOption)

GenerateOption is used to set up the token generation process.

func WithTokenPrefix

func WithTokenPrefix(value string) GenerateOption

WithTokenPrefix prepends the given prefix to the token generation so that it will be covered by the checksum.

Prefix must match [a-z0-9-]+ regular expression (lowercase kebab case).

type Generator

type Generator interface {
	Generate(...GenerateOption) (string, error)
}

Generator describes token generator contract.

func UUIDGenerator

func UUIDGenerator(source UUIDGeneratorFunc, secretKey []byte) Generator

UUIDGenerator wraps the returned UUID byte array from the given source to provide additional integrity protection to the content.

The secret key is used to derive a unique secret used to seal the UUID value.

type UUIDGeneratorFunc

type UUIDGeneratorFunc func() ([16]byte, error)

UUIDGeneratorFunc represents the contract used to feed the wrapper with a pre-generated UUID. This is used to pass the UUID byte array coming from your favorite generator.

func StaticUUIDSource

func StaticUUIDSource(in [16]byte) UUIDGeneratorFunc

StaticUUIDSource is used to set a static UUID byte array content.

func UUIDv4Source

func UUIDv4Source() UUIDGeneratorFunc

UUIDv4Source generates an UUIDv4 based byte array.

func UUIDv7Source

func UUIDv7Source() UUIDGeneratorFunc

UUIDv7Source generates an UUIDv7 based byte array.

type VerifiableGenerator

type VerifiableGenerator interface {
	Generator
	Verifier
}

type VerifiableUUIDExtractor

type VerifiableUUIDExtractor interface {
	Verifier
	Extractor[[]byte]
}

VerifiableUUIDExtractor extends the Verifier to add content extraction helper.

func UUIDVerifier

func UUIDVerifier(secretKey []byte) VerifiableUUIDExtractor

UUIDVerifier verifies a wrapped UUID signature.

type Verifier

type Verifier interface {
	Verify(t string) error
}

Verifier describes token verification contract.

Jump to

Keyboard shortcuts

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