ids

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ids makes the identifiers and secrets Aboard hands out: sortable ids for records, bearer tokens, and short join codes. Randomness comes from a reader the caller supplies, so tests can make them repeatable.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Digest

func Digest(key []byte, secret string) string

Digest returns the keyed SHA-256 digest of a secret. Only digests are stored, so a copy of the database doesn't contain working tokens or join codes.

func NormalizeJoinCode

func NormalizeJoinCode(s string) (string, bool)

NormalizeJoinCode turns what a person typed into the canonical "XXX-XXX" form. It accepts any case, with or without the dash, and reads O as 0 and I or L as 1.

Types

type Generator

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

Generator makes ids, tokens and join codes from one source of randomness.

func New

func New(r io.Reader) *Generator

New returns a Generator reading randomness from r (crypto/rand.Reader in production).

func (*Generator) ID

func (g *Generator) ID(prefix string, now time.Time) (string, error)

ID returns prefix + "_" + a 26-character ULID: 48 bits of milliseconds since the Unix epoch, then 80 random bits, so ids sort by creation time.

func (*Generator) JoinCode

func (g *Generator) JoinCode() (string, error)

JoinCode returns six Crockford base32 characters written as "7Q4-K2M".

func (*Generator) Token

func (g *Generator) Token(kind string) (string, error)

Token returns a bearer token: kind prefix ("abh" for humans, "aba" for agents), "_", and 32 random bytes in URL-safe base64.

Jump to

Keyboard shortcuts

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