import { KnoraApiConnection } from '@dasch-swiss/dsp-js'; import { Observable } from 'rxjs'; /** * information about the current user */ interface CurrentUser { name: string; jwt?: string; lang: string; sysAdmin: boolean; projectAdmin: string[]; } /** * Session with id (= login timestamp) and inforamtion about logged-in user */ export interface Session { id: number; user: CurrentUser; } export declare class SessionService { private _dspApiConnection; /** * max session time in milliseconds * default value (24h): 86400000 * */ readonly MAX_SESSION_TIME: number; constructor(_dspApiConnection: KnoraApiConnection); /** * get session information from localstorage */ getSession(): Session | null; /** * set session by using the json web token (jwt) and the user object; * it will be used in the login process * * @param jwt Json Web Token * @param identifier email address or username * @param identifierType 'email' or 'username' */ setSession(jwt: string, identifier: string, identifierType: 'email' | 'username'): Observable; /** * Validate intern session and check knora api credentials if necessary. * If a json web token exists, it doesn't mean that the knora api credentials are still valid. * */ isSessionValid(): Observable; /** * Destroy session by removing the session from local storage * */ destroySession(): void; /** * Returns a timestamp represented in seconds * */ private _setTimestamp; /** * Store session in local storage * @param response response from getUser method call * @param jwt JSON web token string */ private _storeSessionInLocalStorage; /** * Updates the id of the current session in the local storage * @param credentials response from getCredentials method call * @param session the current session * @param timestamp timestamp in form of a number */ private _updateSessionId; } export {};