UNPKG

@deepkit/framework

Version:

34 lines (33 loc) 1.23 kB
/** * This is the default session object, that can be used in your application. * * If you want to receive the Session object you can simply use this Session class as dependency injection token. * However, this will always create a new session (creating a session id + store it in the session storage). * If you simply want to check whether a session exists (user has a valid authenticaton token/cookie), use * SessionHandler. * * If you need more fields, you can create your own Session class. Make sure to * annotate all fields using `@t` of @deepkit/type, since the whole object is serialized * in a session storage (either memory, local file system, or external databases like redis/mysql/etc). */ export declare class Session { readonly id: string; readonly username?: string | undefined; data: { [name: string]: any; }; createdAt: Date; groups: string[]; constructor(id: string, username?: string | undefined); isAnonymous(): boolean; } /** * */ export declare class SessionHandler { protected session?: Session; setSession(session: Session | undefined): void; hasSession(): boolean; getSessionOrUndefined(): Session | undefined; getSession(): Session; }