stackpress
Version:
Incept is a content management framework.
35 lines (34 loc) • 1.44 kB
TypeScript
import type Request from '@stackpress/ingest/Request';
import type Response from '@stackpress/ingest/Response';
import type { SessionData, SessionPermission, SessionPermissionList } from './types.js';
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 authorize(req: Request, res: Response, permits?: SessionPermission[]): Promise<boolean>;
static configure(key: string, seed: string, access: SessionPermissionList): typeof SessionServer;
static create(data: SessionData): Promise<string>;
static token(req: Request): string | null;
static load(token: string | Request): SessionServer;
readonly token: string;
protected _data?: SessionData | null;
constructor(token: string);
authorization(): Promise<{
token: string;
permits: SessionPermission[];
id: string | number;
name?: string | undefined;
image?: string;
roles: string[];
}>;
data(): Promise<SessionData | null>;
guest(): Promise<boolean>;
can(...permits: SessionPermission[]): Promise<boolean>;
permits(): Promise<SessionPermission[]>;
save(res: Response): this;
}