@aciiverse/fetcii
Version:
Simple fetch module primary designed for the aciifx backend
51 lines (50 loc) • 1.56 kB
TypeScript
export declare namespace users {
interface UserDataType {
[key: string]: any;
}
interface SaveDataType {
accessToken: string;
userData: UserDataType;
tokenExp: Date;
}
/**
* @method saves the login data and the token in the local storage
* @param {SaveData} data includes `accessToken`: auth token; `userData`; `token_expire`: date when the token expires
* @author Flowtastisch
* @memberof Aciiverse
* @date 31.08.24
*/
function saveData(data: SaveDataType): void;
/**
* @method gets the user data
* @returns {users.UserData | undefined} the userdata object
* @author Flowtastisch
* @memberof Aciiverse
* @date 31.08.24
*/
function getData(): UserDataType | undefined;
/**
* @method gets the auth token
* @returns {string} auth token
* @author Flowtastisch
* @memberof Aciiverse
* @date 31.08.24
*/
function getToken(): string | undefined;
/**
* @method logouts the user
* @author Flowtastisch
* @memberof Aciiverse
* @date 31.08.24
*/
function deleteData(): void;
/**
* @method check if the token is valid -> standard: logout if token is expired
* @param [deleteDataIfUnvalid=true] optional param: if `not set`: `true`
* @returns {boolean} `true`: token expired & `false`: token valid
* @author Flowtastisch
* @memberof Aciiverse
* @date 31.08.24
*/
function checkTokenExpired(deleteDataIfUnvalid?: boolean): boolean;
}