@knora/core
Version:
Knora ui module: core
69 lines (68 loc) • 1.84 kB
TypeScript
import { KnoraApiConfig, KnoraApiConnection } from '@knora/api';
/**
* Currently logged-in user information
*/
export 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 knoraApiConnection;
private knoraApiConfig;
/**
* max session time in milliseconds
* default value (24h): 86400000
*
*/
readonly MAX_SESSION_TIME: number;
constructor(knoraApiConnection: KnoraApiConnection, knoraApiConfig: KnoraApiConfig);
/**
* set the session by using the json web token (jwt) and the user object;
* it will be used in the login process
*
* @param jwt
* @param username
*/
setSession(jwt: string, identifier: string, identifierType: 'email' | 'username'): void;
/**
* 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.
*
* @returns boolean
*/
validateSession(): boolean;
/**
* update the session storage
* @param jwt
* @param username
*
* @returns boolean
*/
updateSession(jwt: string, username: string): boolean;
/**
* Destroy session by removing the session from local storage
*
*/
destroySession(): void;
/**
* Update the knora-api-config and knora-api-connection of @knora/api
*
* @param {string} jwt?
*/
private updateKnoraApiConnection;
/**
* Convert a timestamp in a number
* @returns number
*/
private setTimestamp;
}