SessionManager
SessionManager provides stateless HMAC-SHA256 token generation and validation
for SWAIG function call authentication. Tokens encode a call ID, function name,
expiry, and nonce, signed with a shared secret. It also supports per-session
metadata storage with automatic cleanup.
Constructor
tokenExpirySecs
Token validity duration in seconds.
secretKey
HMAC signing secret. A random 32-byte key is generated if omitted.
Methods
Return or generate a session identifier.
Generate a signed token binding a function to a call ID.
Alias for generateToken.
Validate a token against expected call ID and function name.
Alias for validateToken with reordered parameters.
Decode token components without validating the signature.
Retrieve metadata for a session.
Merge metadata into a session.
Remove expired session metadata entries.
Delete all metadata for a session.