auth/daemon_token.ts view source
"X-Daemon-Token" 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
daemon_token_middleware.ts.
5 declarations
auth/daemon_token.ts view source
"X-Daemon-Token" The X-Daemon-Token header name.
auth/daemon_token.ts view source
ZodString Daemon token format: 43 base64url characters (256 bits).
auth/daemon_token.ts view source
DaemonTokenState 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.
stringprevious_tokenPrevious token, still valid during the race window. null before first rotation.
string | nullrotated_atWhen the last rotation occurred.
Datekeeper_account_idThe account ID of the keeper (resolved at startup, set by on_bootstrap).
string | nullauth/daemon_token.ts view source
(): string 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 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