@dudousxd/nestjs-telescope
Version:
Laravel Telescope-style observability console for NestJS — core: watchers, recorder, correlation, SQLite store, headless API.
42 lines • 1.61 kB
TypeScript
/** The validated dashboard session attached to a request once a cookie verifies. */
export interface TelescopeSession {
/** Stable user id (the session user's `id`). */
sub: string;
/** Optional display name. */
name?: string;
/** Free-form role strings; the lib does not interpret them. */
roles: string[];
/** Issued-at, epoch milliseconds. */
iat: number;
/** Expiry, epoch milliseconds. */
exp: number;
}
/** The session user a host hook returns to mint a cookie. */
export interface TelescopeSessionUser {
id: string;
name?: string;
roles?: string[];
}
export interface SignOptions {
secret: string;
ttlMs: number;
/** Injectable clock (epoch ms) for deterministic tests. Defaults to `Date.now()`. */
now?: number;
}
export interface VerifyOptions {
secret: string;
/** Injectable clock (epoch ms) for deterministic tests. Defaults to `Date.now()`. */
now?: number;
}
/**
* Sign a session into the cookie value `base64url(payload).base64url(hmac)`.
* Stateless HMAC-SHA256, no store. `node:crypto` only — no JWT dependency.
*/
export declare function signSessionCookie(user: TelescopeSessionUser, options: SignOptions): string;
/**
* Verify a cookie value and return the session, or `null` for anything that's
* tampered, malformed, or expired (past `exp` + a 30s grace). Constant-time
* signature comparison. NEVER throws — any parse failure yields `null`.
*/
export declare function verifySessionCookie(value: string, options: VerifyOptions): TelescopeSession | null;
//# sourceMappingURL=session-cookie.d.ts.map