stackpress
Version:
Incept is a content management framework.
35 lines (34 loc) • 1.38 kB
TypeScript
import type Request from '@stackpress/ingest/Request';
import type Response from '@stackpress/ingest/Response';
import type { SessionData, SessionPermission, SessionPermissionList } from './types';
export default class SessionServer {
protected static _access: SessionPermissionList;
protected static _expires: number;
protected static _key: string;
protected static _seed: string;
static get access(): SessionPermissionList;
static get seed(): string;
static get key(): string;
static set expires(value: number);
static configure(key: string, seed: string, access: SessionPermissionList): typeof SessionServer;
static authorize(req: Request, res: Response, permits?: SessionPermission[]): boolean;
static create(data: SessionData): string;
static token(req: Request): string | null;
static load(token: string | Request): SessionServer;
readonly token: string;
protected _data?: SessionData | null;
get authorization(): {
token: string;
permits: SessionPermission[];
id: string | number;
name?: string | undefined;
image?: string;
roles: string[];
};
get data(): SessionData | null;
get guest(): boolean;
constructor(token: string);
can(...permits: SessionPermission[]): boolean;
permits(): SessionPermission[];
save(res: Response): this;
}