token

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 8 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

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalid = errors.New("token: invalid")

ErrInvalid is a single opaque error so callers cannot distinguish failure reasons.

Functions

This section is empty.

Types

type Claims

type Claims struct {
	ContextID string `json:"-"`             // filled in by Verify from the request, never serialized
	Sub       string `json:"sub"`           // agent role bound to this token
	Owner     bool   `json:"own,omitempty"` // true only for the creator token (may issue participant tokens / close)
	Ver       int    `json:"ver"`
	Exp       int64  `json:"exp"`
}

Claims is the token body, kept intentionally small to minimize token length. The context id and audience are NOT stored here; they are folded into the MAC input instead, so the token stays bound to one context without carrying the id.

type Manager

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

Manager signs with cur and verifies against cur then prev (for zero-downtime rotation).

func New

func New(cur, prev []byte, ttlHours int) *Manager

New builds a Manager. prev may be nil.

func (*Manager) Sign

func (m *Manager) Sign(contextID, sub string, owner bool, ver int) (string, error)

Sign returns "payload.mac" for a token bound to (contextID, sub, owner, ver). contextID is folded into the MAC, not stored in the payload.

func (*Manager) Verify

func (m *Manager) Verify(contextID, tok string) (Claims, error)

Verify checks the signature (cur or prev) and expiry for a token presented against contextID; it returns the claims with ContextID filled in.

Jump to

Keyboard shortcuts

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