@arex95/vue-core 1.1.29 → 1.1.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { AuthParams, AuthResponse, AuthTokenPaths } from "@/types";
|
|
2
|
-
import { SessionPreference } from "@config/global/sessionConfig";
|
|
1
|
+
import { AuthParams, AuthResponse, AuthTokenPaths, SessionPreference } from "@/types";
|
|
3
2
|
/**
|
|
4
3
|
* @typedef {object} AuthHook
|
|
5
4
|
* @property {function(): Promise<number | null>} getTokenExpiry - Retrieves the expiration time of the current token in milliseconds.
|
|
@@ -9,7 +8,7 @@ import { SessionPreference } from "@config/global/sessionConfig";
|
|
|
9
8
|
* @property {(tokenPaths?: AuthTokenPaths) => Promise<AuthResponse>} refresh - Refreshes authentication tokens.
|
|
10
9
|
* @property {function(): Promise<boolean>} verifyAuth - Verifies the validity and expiration of the current authentication token.
|
|
11
10
|
* @property {(preference: SessionPreference) => void} setSessionPersistencePreference - Sets the user's preferred storage for authentication data.
|
|
12
|
-
* @property {function(): SessionPreference}
|
|
11
|
+
* @property {function(): SessionPreference} getSessionPersistence - Retrieves the user's current preferred storage for authentication data.
|
|
13
12
|
*/
|
|
14
13
|
/**
|
|
15
14
|
* Custom hook for authentication logic, including login, logout, token management, and session preference.
|
|
@@ -1,49 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
import { SessionPreference, SessionConfigObject, SessionConfig } from "@/types/SessionConfig";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
interface SessionConfigObject {
|
|
6
|
-
/** The unique session identifier. */
|
|
7
|
-
sessionId?: string;
|
|
8
|
-
/** The storage preference: 'local' for localStorage, 'session' for sessionStorage. */
|
|
9
|
-
persistencePreference?: SessionPreference;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Loads the session configuration from storage (local or session).
|
|
13
|
-
* This should be called once when the application initializes.
|
|
14
|
-
*/
|
|
15
|
-
export declare function loadSessionConfigFromStorage(): Promise<void>;
|
|
16
|
-
/**
|
|
17
|
-
* Configures the session identifier and/or the data persistence preference for the active browser session.
|
|
18
|
-
* Once configured, the session ID cannot be modified. The persistence preference can be updated.
|
|
3
|
+
* Configures the session identifier and/or data persistence preference
|
|
4
|
+
* for the active browser session.
|
|
19
5
|
*
|
|
20
|
-
*
|
|
6
|
+
* This function is asynchronous because it will always attempt to load the current configuration
|
|
7
|
+
* before applying changes and then saving them.
|
|
21
8
|
*
|
|
22
|
-
* @
|
|
9
|
+
* @param {SessionConfigObject} config - An object containing the unique session identifier and/or
|
|
10
|
+
* the persistence preference.
|
|
11
|
+
* @returns {Promise<void>} A promise that resolves when the session has been configured and saved.
|
|
23
12
|
*/
|
|
24
|
-
export declare function configSession(config: SessionConfigObject): void
|
|
13
|
+
export declare function configSession(config: SessionConfigObject): Promise<void>;
|
|
25
14
|
/**
|
|
26
|
-
* Retrieves the current session identifier
|
|
15
|
+
* Retrieves the current session identifier.
|
|
16
|
+
* Always attempts to load the configuration from storage. If it fails, it uses the internal state.
|
|
27
17
|
*
|
|
28
|
-
* @returns {string}
|
|
18
|
+
* @returns {Promise<string>} A promise that resolves with the unique session identifier.
|
|
29
19
|
*/
|
|
30
|
-
export declare function
|
|
20
|
+
export declare function getSessionId(): Promise<string>;
|
|
31
21
|
/**
|
|
32
22
|
* Retrieves the current data persistence preference.
|
|
23
|
+
* Always attempts to load the configuration from storage. If it fails, it uses the internal state.
|
|
33
24
|
*
|
|
34
|
-
* @returns {SessionPreference}
|
|
25
|
+
* @returns {Promise<SessionPreference>} A promise that resolves with the configured persistence preference ('local' or 'session').
|
|
35
26
|
*/
|
|
36
|
-
export declare function
|
|
27
|
+
export declare function getSessionPersistence(): Promise<SessionPreference>;
|
|
37
28
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* @returns {void} Does not return anything, but updates the session identifier.
|
|
41
|
-
*/
|
|
42
|
-
export declare function regenerateSessionId(): void;
|
|
43
|
-
/**
|
|
44
|
-
* Retrieves the current session identifier.
|
|
29
|
+
* Retrieves the complete session configuration.
|
|
30
|
+
* Always attempts to load the configuration from storage. If it fails, it uses the internal state.
|
|
45
31
|
*
|
|
46
|
-
* @returns {
|
|
32
|
+
* @returns {Promise<SessionConfig>} A promise that resolves with the session configuration object.
|
|
47
33
|
*/
|
|
48
|
-
export declare function
|
|
49
|
-
export {};
|
|
34
|
+
export declare function getSessionConfig(): Promise<SessionConfig>;
|
package/dist/index.mjs
CHANGED
|
@@ -933,106 +933,109 @@ function getAppKey() {
|
|
|
933
933
|
return appKey;
|
|
934
934
|
}
|
|
935
935
|
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
936
|
+
const SESSION_KEY = "session_config_";
|
|
937
|
+
const internalSessionState = {
|
|
938
|
+
sessionId: v4(),
|
|
939
|
+
persistencePreference: "session",
|
|
940
|
+
};
|
|
941
|
+
let _sessionConfig = Object.freeze({
|
|
942
|
+
SESSION_ID: internalSessionState.sessionId,
|
|
943
|
+
PERSISTENCE: internalSessionState.persistencePreference,
|
|
939
944
|
});
|
|
940
|
-
let persistencePreference = "session";
|
|
941
945
|
/**
|
|
942
|
-
*
|
|
943
|
-
*
|
|
946
|
+
* Updates the immutable `_sessionConfig` object with the current state of `internalSessionState`
|
|
947
|
+
* and freezes it.
|
|
944
948
|
*/
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
const parsedConfig = JSON.parse(storedConfig);
|
|
951
|
-
sessionConfig = Object.freeze({
|
|
952
|
-
...sessionConfig,
|
|
953
|
-
...parsedConfig,
|
|
954
|
-
});
|
|
955
|
-
if (parsedConfig.SESSION_ID) {
|
|
956
|
-
sessionId = parsedConfig.SESSION_ID;
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
|
-
catch (error) {
|
|
960
|
-
console.error("Error parsing stored session config:", error);
|
|
961
|
-
regenerateSessionId();
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
|
-
else {
|
|
965
|
-
regenerateSessionId();
|
|
966
|
-
}
|
|
967
|
-
await saveSessionConfigToStorage();
|
|
949
|
+
function updateSessionConfig() {
|
|
950
|
+
_sessionConfig = Object.freeze({
|
|
951
|
+
SESSION_ID: internalSessionState.sessionId,
|
|
952
|
+
PERSISTENCE: internalSessionState.persistencePreference,
|
|
953
|
+
});
|
|
968
954
|
}
|
|
969
955
|
/**
|
|
970
956
|
* Saves the current session configuration to local or session storage.
|
|
957
|
+
* @returns {Promise<void>} A promise that resolves when the session configuration has been saved.
|
|
971
958
|
*/
|
|
972
|
-
async function
|
|
973
|
-
const isPersistent = persistencePreference === "local";
|
|
959
|
+
async function saveSessionConfig() {
|
|
960
|
+
const isPersistent = internalSessionState.persistencePreference === "local";
|
|
974
961
|
try {
|
|
975
|
-
await storeEncryptedItem(
|
|
962
|
+
await storeEncryptedItem(SESSION_KEY, JSON.stringify(_sessionConfig), getAppKey(), isPersistent);
|
|
976
963
|
}
|
|
977
964
|
catch (error) {
|
|
978
|
-
console.error("Error saving session
|
|
965
|
+
console.error("Error saving session configuration to storage:", error);
|
|
979
966
|
}
|
|
980
967
|
}
|
|
981
968
|
/**
|
|
982
|
-
*
|
|
983
|
-
*
|
|
984
|
-
*
|
|
985
|
-
* @param {SessionConfigObject} config - An object containing the unique session identifier and/or persistence preference.
|
|
969
|
+
* Attempts to load the configuration from storage.
|
|
970
|
+
* If it fails or is not found, `internalSessionState` will retain its current values (initial or last configured).
|
|
971
|
+
* Then, it updates `_sessionConfig`.
|
|
986
972
|
*
|
|
987
|
-
* @returns {void}
|
|
988
|
-
*/
|
|
989
|
-
function
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
973
|
+
* @returns {Promise<void>} A promise that resolves when the state has been loaded and updated.
|
|
974
|
+
*/
|
|
975
|
+
async function loadSessionConfig() {
|
|
976
|
+
try {
|
|
977
|
+
const storedConfig = await getDecryptedItem(SESSION_KEY, getAppKey(), true);
|
|
978
|
+
if (storedConfig) {
|
|
979
|
+
const parsedConfig = JSON.parse(storedConfig);
|
|
980
|
+
internalSessionState.sessionId = parsedConfig.SESSION_ID;
|
|
981
|
+
internalSessionState.persistencePreference = parsedConfig.PERSISTENCE;
|
|
982
|
+
updateSessionConfig();
|
|
983
|
+
}
|
|
997
984
|
}
|
|
998
|
-
|
|
999
|
-
|
|
985
|
+
catch (error) {
|
|
986
|
+
console.warn(`Error loading or parsing from storage`, error);
|
|
1000
987
|
}
|
|
1001
|
-
sessionConfig = Object.freeze(updatedConfig);
|
|
1002
|
-
saveSessionConfigToStorage();
|
|
1003
988
|
}
|
|
1004
989
|
/**
|
|
1005
|
-
*
|
|
990
|
+
* Configures the session identifier and/or data persistence preference
|
|
991
|
+
* for the active browser session.
|
|
1006
992
|
*
|
|
1007
|
-
*
|
|
993
|
+
* This function is asynchronous because it will always attempt to load the current configuration
|
|
994
|
+
* before applying changes and then saving them.
|
|
995
|
+
*
|
|
996
|
+
* @param {SessionConfigObject} config - An object containing the unique session identifier and/or
|
|
997
|
+
* the persistence preference.
|
|
998
|
+
* @returns {Promise<void>} A promise that resolves when the session has been configured and saved.
|
|
1008
999
|
*/
|
|
1009
|
-
function
|
|
1010
|
-
|
|
1000
|
+
async function configSession(config) {
|
|
1001
|
+
if (config.sessionId) {
|
|
1002
|
+
internalSessionState.sessionId = config.sessionId;
|
|
1003
|
+
}
|
|
1004
|
+
if (config.persistencePreference) {
|
|
1005
|
+
internalSessionState.persistencePreference = config.persistencePreference;
|
|
1006
|
+
}
|
|
1007
|
+
updateSessionConfig();
|
|
1008
|
+
await saveSessionConfig();
|
|
1011
1009
|
}
|
|
1012
1010
|
/**
|
|
1013
|
-
* Retrieves the current
|
|
1011
|
+
* Retrieves the current session identifier.
|
|
1012
|
+
* Always attempts to load the configuration from storage. If it fails, it uses the internal state.
|
|
1014
1013
|
*
|
|
1015
|
-
* @returns {
|
|
1014
|
+
* @returns {Promise<string>} A promise that resolves with the unique session identifier.
|
|
1016
1015
|
*/
|
|
1017
|
-
function
|
|
1018
|
-
|
|
1016
|
+
async function getSessionId() {
|
|
1017
|
+
await loadSessionConfig();
|
|
1018
|
+
return _sessionConfig.SESSION_ID;
|
|
1019
1019
|
}
|
|
1020
1020
|
/**
|
|
1021
|
-
*
|
|
1021
|
+
* Retrieves the current data persistence preference.
|
|
1022
|
+
* Always attempts to load the configuration from storage. If it fails, it uses the internal state.
|
|
1022
1023
|
*
|
|
1023
|
-
* @returns {
|
|
1024
|
+
* @returns {Promise<SessionPreference>} A promise that resolves with the configured persistence preference ('local' or 'session').
|
|
1024
1025
|
*/
|
|
1025
|
-
function
|
|
1026
|
-
|
|
1027
|
-
|
|
1026
|
+
async function getSessionPersistence() {
|
|
1027
|
+
await loadSessionConfig();
|
|
1028
|
+
return _sessionConfig.PERSISTENCE;
|
|
1028
1029
|
}
|
|
1029
1030
|
/**
|
|
1030
|
-
* Retrieves the
|
|
1031
|
+
* Retrieves the complete session configuration.
|
|
1032
|
+
* Always attempts to load the configuration from storage. If it fails, it uses the internal state.
|
|
1031
1033
|
*
|
|
1032
|
-
* @returns {
|
|
1034
|
+
* @returns {Promise<SessionConfig>} A promise that resolves with the session configuration object.
|
|
1033
1035
|
*/
|
|
1034
|
-
function
|
|
1035
|
-
|
|
1036
|
+
async function getSessionConfig() {
|
|
1037
|
+
await loadSessionConfig();
|
|
1038
|
+
return _sessionConfig;
|
|
1036
1039
|
}
|
|
1037
1040
|
|
|
1038
1041
|
/**
|
|
@@ -2765,44 +2768,42 @@ const storeAuthRefreshToken = async (token, secretKey, preference) => {
|
|
|
2765
2768
|
* Verifies the validity and expiration of the current authentication token.
|
|
2766
2769
|
* If the token is missing, invalid, or expired, appropriate errors are thrown and credentials are cleaned.
|
|
2767
2770
|
*
|
|
2768
|
-
* @param {string} secretKey - The secret key used for token decryption.
|
|
2769
|
-
* @param {SessionPreference} preference - The current session persistence preference.
|
|
2770
2771
|
* @returns {Promise<boolean>} True if the token is valid and unexpired.
|
|
2771
2772
|
* @throws {Error} "TOKEN_MISSING" if no token is found, "TOKEN_EXPIRED" if the token has expired,
|
|
2772
2773
|
* "TOKEN_INVALID" if the token format is invalid.
|
|
2773
2774
|
*/
|
|
2774
2775
|
const verifyAuth = async () => {
|
|
2775
|
-
const
|
|
2776
|
+
const sessionPersistence = await getSessionPersistence();
|
|
2777
|
+
const handleAuthError = async (message, shouldClean = true) => {
|
|
2778
|
+
handleError(message, false);
|
|
2779
|
+
if (shouldClean) {
|
|
2780
|
+
await cleanCredentials(sessionPersistence);
|
|
2781
|
+
}
|
|
2782
|
+
return false;
|
|
2783
|
+
};
|
|
2776
2784
|
try {
|
|
2777
|
-
const token = await getAuthToken(getAppKey(),
|
|
2785
|
+
const token = await getAuthToken(getAppKey(), sessionPersistence);
|
|
2778
2786
|
if (!token) {
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2787
|
+
return await handleAuthError("TOKEN_MISSING: No valid token found");
|
|
2788
|
+
}
|
|
2789
|
+
let decoded;
|
|
2790
|
+
try {
|
|
2791
|
+
decoded = jwtDecode(token);
|
|
2792
|
+
}
|
|
2793
|
+
catch (decodeError) {
|
|
2794
|
+
return await handleAuthError("TOKEN_INVALID: Invalid token format");
|
|
2782
2795
|
}
|
|
2783
|
-
const decoded = jwtDecode(token);
|
|
2784
2796
|
const currentTime = Date.now() / 1000;
|
|
2785
2797
|
if (typeof decoded.exp !== "number") {
|
|
2786
|
-
|
|
2787
|
-
await cleanCredentials(preference);
|
|
2788
|
-
return false;
|
|
2798
|
+
return await handleAuthError("TOKEN_INVALID: Invalid expiration format");
|
|
2789
2799
|
}
|
|
2790
2800
|
if (decoded.exp <= currentTime) {
|
|
2791
|
-
|
|
2792
|
-
await cleanCredentials(preference);
|
|
2793
|
-
return false;
|
|
2801
|
+
return await handleAuthError("TOKEN_EXPIRED: Token is expired");
|
|
2794
2802
|
}
|
|
2795
2803
|
return true;
|
|
2796
2804
|
}
|
|
2797
2805
|
catch (error) {
|
|
2798
|
-
|
|
2799
|
-
handleError("TOKEN_INVALID: Invalid token format", false);
|
|
2800
|
-
await cleanCredentials(preference);
|
|
2801
|
-
return false;
|
|
2802
|
-
}
|
|
2803
|
-
handleError("AUTH_ERROR: An unexpected error occurred", false);
|
|
2804
|
-
await cleanCredentials(preference);
|
|
2805
|
-
return false;
|
|
2806
|
+
return await handleAuthError("AUTH_ERROR: An unexpected error occurred", true);
|
|
2806
2807
|
}
|
|
2807
2808
|
};
|
|
2808
2809
|
|
|
@@ -3366,7 +3367,7 @@ function useSorter(items, criteriaList, selectedCriteria) {
|
|
|
3366
3367
|
* @property {(tokenPaths?: AuthTokenPaths) => Promise<AuthResponse>} refresh - Refreshes authentication tokens.
|
|
3367
3368
|
* @property {function(): Promise<boolean>} verifyAuth - Verifies the validity and expiration of the current authentication token.
|
|
3368
3369
|
* @property {(preference: SessionPreference) => void} setSessionPersistencePreference - Sets the user's preferred storage for authentication data.
|
|
3369
|
-
* @property {function(): SessionPreference}
|
|
3370
|
+
* @property {function(): SessionPreference} getSessionPersistence - Retrieves the user's current preferred storage for authentication data.
|
|
3370
3371
|
*/
|
|
3371
3372
|
/**
|
|
3372
3373
|
* Custom hook for authentication logic, including login, logout, token management, and session preference.
|
|
@@ -3377,7 +3378,6 @@ function useSorter(items, criteriaList, selectedCriteria) {
|
|
|
3377
3378
|
function useAuth(secretKey = getAppKey()) {
|
|
3378
3379
|
const axiosInstance = getAxiosInstance();
|
|
3379
3380
|
const endpoints = getEndpointsConfig();
|
|
3380
|
-
const currentPersistencePreference = getSessionPersistencePreference();
|
|
3381
3381
|
/**
|
|
3382
3382
|
* Logs out the user by making a POST request to the logout endpoint,
|
|
3383
3383
|
* cleaning all stored credentials, and reloading the page.
|
|
@@ -3394,7 +3394,7 @@ function useAuth(secretKey = getAppKey()) {
|
|
|
3394
3394
|
handleError(error, false);
|
|
3395
3395
|
}
|
|
3396
3396
|
finally {
|
|
3397
|
-
await cleanCredentials(
|
|
3397
|
+
await cleanCredentials(await getSessionPersistence());
|
|
3398
3398
|
window.location.reload();
|
|
3399
3399
|
}
|
|
3400
3400
|
};
|
|
@@ -3450,7 +3450,7 @@ function useAuth(secretKey = getAppKey()) {
|
|
|
3450
3450
|
*/
|
|
3451
3451
|
const refresh = async (tokenPaths) => {
|
|
3452
3452
|
try {
|
|
3453
|
-
const refreshTokenFromStorage = await getAuthRefreshToken(secretKey,
|
|
3453
|
+
const refreshTokenFromStorage = await getAuthRefreshToken(secretKey, await getSessionPersistence());
|
|
3454
3454
|
if (!refreshTokenFromStorage) {
|
|
3455
3455
|
throw new Error("TOKEN_MISSING: No refresh token found in storage.");
|
|
3456
3456
|
}
|
|
@@ -3472,8 +3472,8 @@ function useAuth(secretKey = getAppKey()) {
|
|
|
3472
3472
|
typeof refreshTokenAfterRefresh !== "string") {
|
|
3473
3473
|
throw new Error(`REFRESH_ERROR: Refresh token not found or invalid at path '${refreshTokenPath}' in refresh response.`);
|
|
3474
3474
|
}
|
|
3475
|
-
await storeAuthToken(accessTokenAfterRefresh, secretKey,
|
|
3476
|
-
await storeAuthRefreshToken(refreshTokenAfterRefresh, secretKey,
|
|
3475
|
+
await storeAuthToken(accessTokenAfterRefresh, secretKey, await getSessionPersistence());
|
|
3476
|
+
await storeAuthRefreshToken(refreshTokenAfterRefresh, secretKey, await getSessionPersistence());
|
|
3477
3477
|
return data;
|
|
3478
3478
|
}
|
|
3479
3479
|
catch (error) {
|
|
@@ -3524,4 +3524,4 @@ const ArexVueCore = {
|
|
|
3524
3524
|
},
|
|
3525
3525
|
};
|
|
3526
3526
|
|
|
3527
|
-
export { AppTypes, ArchiveTypes, ArexVueCore, AudioTypes, AxiosService, ContentTypeEnum, DocumentTypes, ERROR_MESSAGES, ERROR_STYLES, ErrorEnum, ErrorMessages, ErrorStyles, ExceptionEnum, FontTypes, ImageTypes, KeyCodeEnum, OtherTypes, RestStd, ScreenBreakpoint, ScreenSize, StorageKeyEnum, StorageTypeEnum, TextTypes, VideoTypes, ab2hex, addCustomKeyboardShortcut, addDays, addDoubleClickListener, addKeyListener, ageAtDate, axiosFetch, blobToFormData, bufferToBlob, calculateAge, cleanCredentials, clickOutside, compareObject, configAppKey, configAxios, configEndpoints, configSession, configTokenKeys, copyToClipboard, countWords, createCustomAxiosInstance, createFetch, createKeyMap, customShortcut, daysBetween, daysToNextBirthday, debounce, debounceAsync, debounceAsyncValidator, debounceAsyncWithImmediate, debounceLeading, debounceLeadingTrailing, debounceTrailing, decrypt, deepClone, deepEqual, deepMerge, detectKeyHold, disableCopy, disableF12Key, disableMouseButtons, disableRightClick, disableSpecificKeys, downloadBlob, enableMouseButtons, enableRightClick, enableSpecificKeys, encrypt, exportToCSV, exportToExcel, exportToJSON, exportToText, exportToXML, filterObjectByKeys, flattenObject, formDataToObject, formatDate, generateRandomString, getAppKey, getAuthRefreshToken, getAuthToken, getAxiosInstance, getDecryptedItem, getEndOfMonth, getEndpointsConfig, getObjectDifferences, getObjectKeys, getQueryParam, getSessionConfig, getSessionId,
|
|
3527
|
+
export { AppTypes, ArchiveTypes, ArexVueCore, AudioTypes, AxiosService, ContentTypeEnum, DocumentTypes, ERROR_MESSAGES, ERROR_STYLES, ErrorEnum, ErrorMessages, ErrorStyles, ExceptionEnum, FontTypes, ImageTypes, KeyCodeEnum, OtherTypes, RestStd, ScreenBreakpoint, ScreenSize, StorageKeyEnum, StorageTypeEnum, TextTypes, VideoTypes, ab2hex, addCustomKeyboardShortcut, addDays, addDoubleClickListener, addKeyListener, ageAtDate, axiosFetch, blobToFormData, bufferToBlob, calculateAge, cleanCredentials, clickOutside, compareObject, configAppKey, configAxios, configEndpoints, configSession, configTokenKeys, copyToClipboard, countWords, createCustomAxiosInstance, createFetch, createKeyMap, customShortcut, daysBetween, daysToNextBirthday, debounce, debounceAsync, debounceAsyncValidator, debounceAsyncWithImmediate, debounceLeading, debounceLeadingTrailing, debounceTrailing, decrypt, deepClone, deepEqual, deepMerge, detectKeyHold, disableCopy, disableF12Key, disableMouseButtons, disableRightClick, disableSpecificKeys, downloadBlob, enableMouseButtons, enableRightClick, enableSpecificKeys, encrypt, exportToCSV, exportToExcel, exportToJSON, exportToText, exportToXML, filterObjectByKeys, flattenObject, formDataToObject, formatDate, generateRandomString, getAppKey, getAuthRefreshToken, getAuthToken, getAxiosInstance, getDecryptedItem, getEndOfMonth, getEndpointsConfig, getObjectDifferences, getObjectKeys, getQueryParam, getSessionConfig, getSessionId, getSessionPersistence, getStartOfMonth, getTokenConfig, handleError, hasNestedProperties, hex2ab, importKey, isEmptyObject, isLeapYear, isStrongPassword, isValidAge, isValidCreditCard, isValidDate, isValidEmail, isValidExpiryDate, isValidHexColor, isValidHexColorAlpha, isValidHexNumber, isValidIP, isValidPhoneNumber, isValidSSN, isValidTime, isValidURL, isValidUsername, isValidZIP, lowerFirst, objectToFormData, objectToFormDataEnhanced, objectToQueryString, openWindow, parseDate, proxyToPlainObject, readFileAsDataURL, readFileAsText, registerKeyboardShortcuts, removeAccent, removeClickOutside, removeCustomKeyboardShortcut, removeCustomShortcuts, removeDoubleClickListener, removeEmptyProperties, removeKeyListeners, replaceAll, reverseString, safeGet, screenMap, scrollToTop, simulateKeyPress, stopDetectingKeyHold, storeAuthRefreshToken, storeAuthToken, storeEncryptedItem, stringToBlob, subtractDays, throttle, toCamelCase, toKebabCase, toggleTabNavigation, truncateString, unregisterKeyboardShortcuts, upperFirst, useAuth, useBreakpoint, useFilter, usePagination, useSorter, useVueQuery, validateAlphanumeric, validateLetters, validateNumbers, verifyAuth };
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
export type SessionPreference = "local" | "session";
|
|
1
2
|
export type SessionConfig = {
|
|
2
3
|
SESSION_ID: string;
|
|
4
|
+
PERSISTENCE: SessionPreference;
|
|
3
5
|
};
|
|
6
|
+
export interface InternalSessionState {
|
|
7
|
+
sessionId: string;
|
|
8
|
+
persistencePreference: SessionPreference;
|
|
9
|
+
}
|
|
10
|
+
export interface SessionConfigObject {
|
|
11
|
+
sessionId?: string;
|
|
12
|
+
persistencePreference?: SessionPreference;
|
|
13
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SessionPreference } from "
|
|
1
|
+
import { SessionPreference } from "@/types/SessionConfig";
|
|
2
2
|
/**
|
|
3
3
|
* Clears all stored authentication data (access and refresh tokens)
|
|
4
4
|
* from either sessionStorage or localStorage based on the provided preference.
|
|
@@ -49,8 +49,6 @@ export declare const storeAuthRefreshToken: (token: string, secretKey: string, p
|
|
|
49
49
|
* Verifies the validity and expiration of the current authentication token.
|
|
50
50
|
* If the token is missing, invalid, or expired, appropriate errors are thrown and credentials are cleaned.
|
|
51
51
|
*
|
|
52
|
-
* @param {string} secretKey - The secret key used for token decryption.
|
|
53
|
-
* @param {SessionPreference} preference - The current session persistence preference.
|
|
54
52
|
* @returns {Promise<boolean>} True if the token is valid and unexpired.
|
|
55
53
|
* @throws {Error} "TOKEN_MISSING" if no token is found, "TOKEN_EXPIRED" if the token has expired,
|
|
56
54
|
* "TOKEN_INVALID" if the token format is invalid.
|