auth/daemon_token.ts view source
"X-Daemon-Token" import {DAEMON_TOKEN_HEADER} from '@fuzdev/fuz_app/auth/daemon_token.js'; The X-Daemon-Token header name.
Daemon token primitives — schema, generation, and validation.
Pure auth operations with no I/O or state management. The middleware, rotation, and persistence logic lives in auth/daemon_token_middleware.ts.
5 declarations
auth/daemon_token.ts view source
"X-Daemon-Token" import {DAEMON_TOKEN_HEADER} from '@fuzdev/fuz_app/auth/daemon_token.js'; The X-Daemon-Token header name.
auth/daemon_token.ts view source
ZodString import type {DaemonToken} from '@fuzdev/fuz_app/auth/daemon_token.js'; Daemon token format: 43 base64url characters (256 bits).
auth/daemon_token.ts view source
DaemonTokenState import type {DaemonTokenState} from '@fuzdev/fuz_app/auth/daemon_token.js'; Mutable runtime state for daemon token rotation.
This is runtime state (not AppDeps or *Options) — it changes during
operation. Created at server startup, passed to the middleware factory.
current_tokenCurrent valid token.
type string
previous_tokenPrevious token, still valid during the race window. null before first rotation.
type string | null
rotated_atWhen the last rotation occurred.
type Date
keeper_account_idThe account ID of the keeper (resolved at startup, set by on_bootstrap).
type string | null
auth/daemon_token.ts view source
(): string import {generate_daemon_token} from '@fuzdev/fuz_app/auth/daemon_token.js'; Generate a new daemon token (256-bit random, base64url).
string a 43-character base64url string
auth/daemon_token.ts view source
(provided: string, state: DaemonTokenState): boolean import {validate_daemon_token} from '@fuzdev/fuz_app/auth/daemon_token.js'; Validate a daemon token against the current state.
Accepts both the current and previous token (2-token race window). Uses timing-safe comparison.
providedthe token from the X-Daemon-Token header
stringstatethe daemon token state
boolean true if the token is valid