@arex95/vue-core 1.1.10 → 1.1.12
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.
- package/dist/composables/auth/index.d.ts +1 -0
- package/dist/composables/auth/useAuth.d.ts +3 -2
- package/dist/composables/index.d.ts +1 -0
- package/dist/composables/monitoring/useApiActivity.d.ts +2 -2
- package/dist/config/global/index.d.ts +2 -1
- package/dist/config/global/tokensConfig.d.ts +31 -0
- package/dist/index.mjs +312 -14
- package/dist/types/AuthConfig.d.ts +2 -2
- package/dist/types/TokenConfig.d.ts +1 -1
- package/package.json +4 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./useAuth";
|
|
@@ -15,8 +15,9 @@ export declare function configureAuth(options: AuthConfig): void;
|
|
|
15
15
|
* @returns {Object} Auth composable methods and properties.
|
|
16
16
|
*/
|
|
17
17
|
export declare function useAuth(secretKey?: string): {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
isAuthenticated: import("vue").ComputedRef<boolean>;
|
|
19
|
+
jwt: import("vue").Ref<string | null, string | null>;
|
|
20
|
+
refresh_token: import("vue").Ref<string | null, string | null>;
|
|
20
21
|
tokenExpiry: import("vue").ComputedRef<number | null>;
|
|
21
22
|
login: (params: {} | undefined, isRememberMe: boolean) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
22
23
|
refresh: () => Promise<import("axios").AxiosResponse<any, any> | undefined>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare function useApiActivity(sessionTimeoutMin: number, checkIntervalSec: number): {
|
|
2
|
-
pause: import("@vueuse/
|
|
3
|
-
resume: import("@vueuse/
|
|
2
|
+
pause: import("@vueuse/core").Fn;
|
|
3
|
+
resume: import("@vueuse/core").Fn;
|
|
4
4
|
updateTimestamp: () => void;
|
|
5
5
|
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { TokensConfig } from "@/types";
|
|
2
|
+
/**
|
|
3
|
+
* Configures the global keys for access and refresh tokens.
|
|
4
|
+
* Once set, they cannot be modified.
|
|
5
|
+
*
|
|
6
|
+
* @param {string} accessTokenKey - The name of the access token key.
|
|
7
|
+
* @param {string} refreshTokenKey - The name of the refresh token key.
|
|
8
|
+
*
|
|
9
|
+
* @returns {void} Does not return anything but freezes the token configuration object.
|
|
10
|
+
*/
|
|
11
|
+
export declare function configTokenKeys(accessTokenKey: string, refreshTokenKey: string): void;
|
|
12
|
+
/**
|
|
13
|
+
* Retrieves the current token configuration.
|
|
14
|
+
*
|
|
15
|
+
* @returns {TokensConfig} The configuration of the access and refresh token keys.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getTokenConfig(): TokensConfig;
|
|
18
|
+
/**
|
|
19
|
+
* Sets the secret key for use in authentication.
|
|
20
|
+
*
|
|
21
|
+
* @param {string} key - The new secret key.
|
|
22
|
+
*
|
|
23
|
+
* @returns {void} Does not return anything, but updates the secret key.
|
|
24
|
+
*/
|
|
25
|
+
export declare function setSecretKey(key: string): void;
|
|
26
|
+
/**
|
|
27
|
+
* Retrieves the current secret key.
|
|
28
|
+
*
|
|
29
|
+
* @returns {string} The configured secret key.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getSecretKey(): string;
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { useTimeoutFn, useBreakpoints, breakpointsTailwind, useWindowSize } from '@vueuse/core';
|
|
1
|
+
import { useTimeoutFn, useBreakpoints, breakpointsTailwind, useWindowSize, computedAsync } from '@vueuse/core';
|
|
2
2
|
import axios from 'axios';
|
|
3
3
|
import { useRouter } from 'vue-router';
|
|
4
4
|
import { useQuery } from '@tanstack/vue-query';
|
|
5
5
|
import { ref, watch, onServerPrefetch, onMounted, computed } from 'vue';
|
|
6
|
+
import { jwtDecode } from 'jwt-decode';
|
|
7
|
+
import { v4 } from 'uuid';
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Creates and downloads a file from Blob data.
|
|
@@ -2385,7 +2387,7 @@ function inferErrorType(error) {
|
|
|
2385
2387
|
}
|
|
2386
2388
|
|
|
2387
2389
|
let secretKey = "12345678901234567890123456789012";
|
|
2388
|
-
let
|
|
2390
|
+
let tokensConfig$1 = Object.freeze({
|
|
2389
2391
|
ACCESS_TOKEN: "authToken",
|
|
2390
2392
|
REFRESH_TOKEN: "refreshToken",
|
|
2391
2393
|
});
|
|
@@ -2398,8 +2400,8 @@ let tokenConfig = Object.freeze({
|
|
|
2398
2400
|
*
|
|
2399
2401
|
* @returns {void} Does not return anything but freezes the token configuration object.
|
|
2400
2402
|
*/
|
|
2401
|
-
function
|
|
2402
|
-
|
|
2403
|
+
function configTokenKeys(accessTokenKey, refreshTokenKey) {
|
|
2404
|
+
tokensConfig$1 = Object.freeze({
|
|
2403
2405
|
ACCESS_TOKEN: accessTokenKey,
|
|
2404
2406
|
REFRESH_TOKEN: refreshTokenKey,
|
|
2405
2407
|
});
|
|
@@ -2407,10 +2409,10 @@ function configTokens(accessTokenKey, refreshTokenKey) {
|
|
|
2407
2409
|
/**
|
|
2408
2410
|
* Retrieves the current token configuration.
|
|
2409
2411
|
*
|
|
2410
|
-
* @returns {
|
|
2412
|
+
* @returns {TokensConfig} The configuration of the access and refresh token keys.
|
|
2411
2413
|
*/
|
|
2412
2414
|
function getTokenConfig() {
|
|
2413
|
-
return
|
|
2415
|
+
return tokensConfig$1;
|
|
2414
2416
|
}
|
|
2415
2417
|
/**
|
|
2416
2418
|
* Sets the secret key for use in authentication.
|
|
@@ -2431,7 +2433,7 @@ function getSecretKey() {
|
|
|
2431
2433
|
return secretKey;
|
|
2432
2434
|
}
|
|
2433
2435
|
|
|
2434
|
-
let endpointsConfig = {
|
|
2436
|
+
let endpointsConfig$1 = {
|
|
2435
2437
|
LOGIN: "/login",
|
|
2436
2438
|
REFRESH: "/refresh",
|
|
2437
2439
|
LOGOUT: "/logout",
|
|
@@ -2447,7 +2449,7 @@ let endpointsConfig = {
|
|
|
2447
2449
|
* @returns {void} Does not return anything but freezes the endpoint configuration object.
|
|
2448
2450
|
*/
|
|
2449
2451
|
function configEndpoints(loginEndpoint, refreshEndpoint, logoutEndpoint) {
|
|
2450
|
-
endpointsConfig = Object.freeze({
|
|
2452
|
+
endpointsConfig$1 = Object.freeze({
|
|
2451
2453
|
LOGIN: loginEndpoint,
|
|
2452
2454
|
REFRESH: refreshEndpoint,
|
|
2453
2455
|
LOGOUT: logoutEndpoint,
|
|
@@ -2462,7 +2464,7 @@ function configEndpoints(loginEndpoint, refreshEndpoint, logoutEndpoint) {
|
|
|
2462
2464
|
* @property {string} LOGOUT - URL of the logout endpoint.
|
|
2463
2465
|
*/
|
|
2464
2466
|
function getEndpointsConfig() {
|
|
2465
|
-
return endpointsConfig;
|
|
2467
|
+
return endpointsConfig$1;
|
|
2466
2468
|
}
|
|
2467
2469
|
|
|
2468
2470
|
/**
|
|
@@ -2591,13 +2593,13 @@ class AxiosService {
|
|
|
2591
2593
|
}
|
|
2592
2594
|
}
|
|
2593
2595
|
|
|
2594
|
-
let axiosInstance;
|
|
2596
|
+
let axiosInstance$1;
|
|
2595
2597
|
/**
|
|
2596
2598
|
* Configures the global Axios instance with a base URL.
|
|
2597
2599
|
* @param {string} baseURL - The base URL for the Axios instance.
|
|
2598
2600
|
*/
|
|
2599
2601
|
const configAxios = (baseURL) => {
|
|
2600
|
-
axiosInstance = new AxiosService(baseURL);
|
|
2602
|
+
axiosInstance$1 = new AxiosService(baseURL);
|
|
2601
2603
|
};
|
|
2602
2604
|
/**
|
|
2603
2605
|
* Retrieves the configured Axios instance.
|
|
@@ -2605,10 +2607,10 @@ const configAxios = (baseURL) => {
|
|
|
2605
2607
|
* @throws Will throw an error if the Axios instance is not configured.
|
|
2606
2608
|
*/
|
|
2607
2609
|
const getAxiosInstance = () => {
|
|
2608
|
-
if (!axiosInstance) {
|
|
2610
|
+
if (!axiosInstance$1) {
|
|
2609
2611
|
throw new Error('Axios instance not configured. Call configureAxios first.');
|
|
2610
2612
|
}
|
|
2611
|
-
return axiosInstance.getAxiosInstance();
|
|
2613
|
+
return axiosInstance$1.getAxiosInstance();
|
|
2612
2614
|
};
|
|
2613
2615
|
/**
|
|
2614
2616
|
* Creates a new AxiosService instance with custom headers.
|
|
@@ -2987,4 +2989,300 @@ function useSorter(items, criteriaList, selectedCriteria) {
|
|
|
2987
2989
|
}).value;
|
|
2988
2990
|
}
|
|
2989
2991
|
|
|
2990
|
-
|
|
2992
|
+
const axiosInstance = getAxiosInstance();
|
|
2993
|
+
const tokensConfig = getTokenConfig();
|
|
2994
|
+
const endpointsConfig = getEndpointsConfig();
|
|
2995
|
+
const config = {
|
|
2996
|
+
endpoints: endpointsConfig,
|
|
2997
|
+
storageKeys: tokensConfig,
|
|
2998
|
+
};
|
|
2999
|
+
/**
|
|
3000
|
+
* Configures authentication settings globally.
|
|
3001
|
+
* Allows modifying default endpoints and storage keys.
|
|
3002
|
+
*
|
|
3003
|
+
* @param {Object} options - Custom configuration options.
|
|
3004
|
+
* @param {Object} [options.endpoints] - Custom endpoints for login, refresh, and logout.
|
|
3005
|
+
* @param {Object} [options.storageKeys] - Custom storage keys for tokens.
|
|
3006
|
+
*/
|
|
3007
|
+
function configureAuth(options) {
|
|
3008
|
+
if (options.endpoints) {
|
|
3009
|
+
config.endpoints = { ...config.endpoints, ...options.endpoints };
|
|
3010
|
+
}
|
|
3011
|
+
if (options.storageKeys) {
|
|
3012
|
+
config.storageKeys = { ...config.storageKeys, ...options.storageKeys };
|
|
3013
|
+
}
|
|
3014
|
+
}
|
|
3015
|
+
function ab2hex(buffer) {
|
|
3016
|
+
return Array.from(buffer)
|
|
3017
|
+
.map((b) => b.toString(16).padStart(2, "0"))
|
|
3018
|
+
.join("");
|
|
3019
|
+
}
|
|
3020
|
+
function hex2ab(hex) {
|
|
3021
|
+
return new Uint8Array(hex.match(/.{1,2}/g).map((byte) => parseInt(byte, 16)));
|
|
3022
|
+
}
|
|
3023
|
+
async function importKey(secretKey) {
|
|
3024
|
+
const encoder = new TextEncoder();
|
|
3025
|
+
const keyMaterial = await crypto.subtle.digest("SHA-256", encoder.encode(secretKey));
|
|
3026
|
+
return await crypto.subtle.importKey("raw", keyMaterial, { name: "AES-CBC", length: 256 }, false, ["encrypt", "decrypt"]);
|
|
3027
|
+
}
|
|
3028
|
+
/**
|
|
3029
|
+
* Encrypts a value using AES-256 CBC encryption with Web Cryptography API.
|
|
3030
|
+
* The IV is generated randomly for each encryption and prepended to the ciphertext.
|
|
3031
|
+
*
|
|
3032
|
+
* @param {string} value - The value to encrypt.
|
|
3033
|
+
* @param {string} secretKey - The encryption key string.
|
|
3034
|
+
* @returns {Promise<string>} A promise that resolves to the encrypted string (hex IV + hex ciphertext).
|
|
3035
|
+
*/
|
|
3036
|
+
const encrypt = async (value, secretKey) => {
|
|
3037
|
+
const key = await importKey(secretKey);
|
|
3038
|
+
const textEncoder = new TextEncoder();
|
|
3039
|
+
const data = textEncoder.encode(value);
|
|
3040
|
+
const iv = crypto.getRandomValues(new Uint8Array(16));
|
|
3041
|
+
const encryptedContentBuffer = await crypto.subtle.encrypt({ name: "AES-CBC", iv: iv }, key, data);
|
|
3042
|
+
const encryptedContentUint8 = new Uint8Array(encryptedContentBuffer);
|
|
3043
|
+
return ab2hex(iv) + ab2hex(encryptedContentUint8);
|
|
3044
|
+
};
|
|
3045
|
+
/**
|
|
3046
|
+
* Decrypts an AES-256 CBC encrypted value using Web Cryptography API.
|
|
3047
|
+
* The IV is extracted from the beginning of the encrypted string.
|
|
3048
|
+
*
|
|
3049
|
+
* @param {string} value - The encrypted string (hex IV + hex ciphertext).
|
|
3050
|
+
* @param {string} secretKey - The decryption key string.
|
|
3051
|
+
* @returns {Promise<string>} A promise that resolves to the decrypted string.
|
|
3052
|
+
*/
|
|
3053
|
+
const decrypt = async (value, secretKey) => {
|
|
3054
|
+
const key = await importKey(secretKey);
|
|
3055
|
+
const iv = hex2ab(value.substring(0, 32));
|
|
3056
|
+
const encryptedData = hex2ab(value.substring(32));
|
|
3057
|
+
const decryptedContent = await crypto.subtle.decrypt({ name: "AES-CBC", iv: iv }, key, encryptedData);
|
|
3058
|
+
return new TextDecoder().decode(decryptedContent);
|
|
3059
|
+
};
|
|
3060
|
+
/**
|
|
3061
|
+
* Stores an encrypted value in sessionStorage or localStorage.
|
|
3062
|
+
*
|
|
3063
|
+
* @param {string} key - Storage key.
|
|
3064
|
+
* @param {string} value - Value to store.
|
|
3065
|
+
* @param {string} secretKey - Encryption key.
|
|
3066
|
+
* @param {boolean} isRememberMe - Whether to store in localStorage.
|
|
3067
|
+
* @param {number} [attempt=0] - Retry attempt count.
|
|
3068
|
+
* @returns {Promise<void>}
|
|
3069
|
+
*/
|
|
3070
|
+
const storeEncryptedItem = async (key, value, secretKey, isRememberMe, attempt = 0) => {
|
|
3071
|
+
const storage = isRememberMe ? localStorage : sessionStorage;
|
|
3072
|
+
if (typeof window !== "undefined" && storage) {
|
|
3073
|
+
try {
|
|
3074
|
+
const encryptedValue = await encrypt(value, secretKey);
|
|
3075
|
+
storage.setItem(key, encryptedValue);
|
|
3076
|
+
return;
|
|
3077
|
+
}
|
|
3078
|
+
catch (error) {
|
|
3079
|
+
handleError(error, false);
|
|
3080
|
+
if (attempt < 5) {
|
|
3081
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
3082
|
+
return await storeEncryptedItem(key, value, secretKey, isRememberMe, attempt + 1);
|
|
3083
|
+
}
|
|
3084
|
+
throw new Error(`Storage not available for key ${key} after multiple attempts`);
|
|
3085
|
+
}
|
|
3086
|
+
}
|
|
3087
|
+
else {
|
|
3088
|
+
if (attempt < 5) {
|
|
3089
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
3090
|
+
return await storeEncryptedItem(key, value, secretKey, isRememberMe, attempt + 1);
|
|
3091
|
+
}
|
|
3092
|
+
throw new Error(`Storage not available for key ${key} after multiple attempts`);
|
|
3093
|
+
}
|
|
3094
|
+
};
|
|
3095
|
+
/**
|
|
3096
|
+
* Retrieves and decrypts a stored value.
|
|
3097
|
+
*
|
|
3098
|
+
* @param {string} key - Storage key.
|
|
3099
|
+
* @param {string} secretKey - Decryption key.
|
|
3100
|
+
* @param {boolean} isRememberMe - Whether to retrieve from localStorage.
|
|
3101
|
+
* @returns {Promise<string|null>} The decrypted value or null.
|
|
3102
|
+
*/
|
|
3103
|
+
async function getDecryptedValue(key, secretKey, isRememberMe) {
|
|
3104
|
+
const storage = sessionStorage;
|
|
3105
|
+
try {
|
|
3106
|
+
const value = storage.getItem(key);
|
|
3107
|
+
if (!value)
|
|
3108
|
+
return null;
|
|
3109
|
+
return await decrypt(value, secretKey);
|
|
3110
|
+
}
|
|
3111
|
+
catch (error) {
|
|
3112
|
+
handleError(error, false);
|
|
3113
|
+
return null;
|
|
3114
|
+
}
|
|
3115
|
+
}
|
|
3116
|
+
/**
|
|
3117
|
+
* Provides authentication utilities.
|
|
3118
|
+
*
|
|
3119
|
+
* @param {string} [secretKey=getSecretKey()] - Encryption key.
|
|
3120
|
+
* @returns {Object} Auth composable methods and properties.
|
|
3121
|
+
*/
|
|
3122
|
+
function useAuth(secretKey = getSecretKey()) {
|
|
3123
|
+
const jwt = computedAsync(async () => await getDecryptedValue(config.storageKeys.ACCESS_TOKEN, secretKey), null);
|
|
3124
|
+
const refresh_token = computedAsync(async () => await getDecryptedValue(config.storageKeys.REFRESH_TOKEN, secretKey), null);
|
|
3125
|
+
/**
|
|
3126
|
+
* Computes token expiration timestamp.
|
|
3127
|
+
*/
|
|
3128
|
+
const tokenExpiry = computed(() => {
|
|
3129
|
+
if (!jwt.value)
|
|
3130
|
+
return null;
|
|
3131
|
+
try {
|
|
3132
|
+
const decoded = jwtDecode(jwt.value);
|
|
3133
|
+
return decoded.exp ? decoded.exp * 1000 : null;
|
|
3134
|
+
}
|
|
3135
|
+
catch (error) {
|
|
3136
|
+
handleError(error, false);
|
|
3137
|
+
return null;
|
|
3138
|
+
}
|
|
3139
|
+
});
|
|
3140
|
+
/**
|
|
3141
|
+
* Checks if the user is authenticated.
|
|
3142
|
+
*/
|
|
3143
|
+
const isAuthenticated = computed(() => {
|
|
3144
|
+
if (!jwt.value || jwt.value.length === 0) {
|
|
3145
|
+
return false;
|
|
3146
|
+
}
|
|
3147
|
+
if (tokenExpiry.value === null) {
|
|
3148
|
+
return false;
|
|
3149
|
+
}
|
|
3150
|
+
return tokenExpiry.value > Date.now();
|
|
3151
|
+
});
|
|
3152
|
+
/**
|
|
3153
|
+
* Handles user login.
|
|
3154
|
+
*/
|
|
3155
|
+
const login = async (params = {}, isRememberMe) => {
|
|
3156
|
+
try {
|
|
3157
|
+
const response = await axiosInstance.post(config.endpoints.LOGIN, params);
|
|
3158
|
+
await storeEncryptedItem(config.storageKeys.ACCESS_TOKEN, response.data.token, secretKey, isRememberMe);
|
|
3159
|
+
await storeEncryptedItem(config.storageKeys.REFRESH_TOKEN, response.data.refresh_token, secretKey, isRememberMe);
|
|
3160
|
+
return response;
|
|
3161
|
+
}
|
|
3162
|
+
catch (error) {
|
|
3163
|
+
handleError(error, false);
|
|
3164
|
+
throw error;
|
|
3165
|
+
}
|
|
3166
|
+
};
|
|
3167
|
+
/**
|
|
3168
|
+
* Refreshes authentication token.
|
|
3169
|
+
*/
|
|
3170
|
+
const refresh = async () => {
|
|
3171
|
+
try {
|
|
3172
|
+
const response = await axiosInstance.post(config.endpoints.REFRESH, {});
|
|
3173
|
+
await storeEncryptedItem(config.storageKeys.ACCESS_TOKEN, response.data.token, secretKey, false);
|
|
3174
|
+
await storeEncryptedItem(config.storageKeys.REFRESH_TOKEN, response.data.refresh_token, secretKey, false);
|
|
3175
|
+
return response;
|
|
3176
|
+
}
|
|
3177
|
+
catch (error) {
|
|
3178
|
+
handleError(error, false);
|
|
3179
|
+
await logout();
|
|
3180
|
+
}
|
|
3181
|
+
};
|
|
3182
|
+
/**
|
|
3183
|
+
* Logs out the user.
|
|
3184
|
+
*/
|
|
3185
|
+
const logout = async (params = {}) => {
|
|
3186
|
+
try {
|
|
3187
|
+
await axiosInstance.post(config.endpoints.LOGOUT, params);
|
|
3188
|
+
}
|
|
3189
|
+
catch (error) {
|
|
3190
|
+
handleError(error, false);
|
|
3191
|
+
}
|
|
3192
|
+
finally {
|
|
3193
|
+
await cleanStorage();
|
|
3194
|
+
location.reload();
|
|
3195
|
+
}
|
|
3196
|
+
};
|
|
3197
|
+
/**
|
|
3198
|
+
* Clears stored authentication data.
|
|
3199
|
+
*/
|
|
3200
|
+
const cleanStorage = async () => {
|
|
3201
|
+
Object.keys(config.storageKeys).forEach((key) => {
|
|
3202
|
+
sessionStorage.removeItem(config.storageKeys[key]);
|
|
3203
|
+
localStorage.removeItem(config.storageKeys[key]);
|
|
3204
|
+
});
|
|
3205
|
+
};
|
|
3206
|
+
/**
|
|
3207
|
+
* Verifies token validity.
|
|
3208
|
+
*/
|
|
3209
|
+
const verifyToken = async () => {
|
|
3210
|
+
if (!jwt.value) {
|
|
3211
|
+
handleError("TOKEN_MISSING: No valid token found", true, "/auth-error", "query");
|
|
3212
|
+
await cleanStorage();
|
|
3213
|
+
throw new Error("TOKEN_MISSING: No valid token found");
|
|
3214
|
+
}
|
|
3215
|
+
try {
|
|
3216
|
+
const decoded = jwtDecode(jwt.value);
|
|
3217
|
+
if (decoded.exp ? decoded.exp * 1000 < Date.now() : false) {
|
|
3218
|
+
handleError("TOKEN_EXPIRED", false);
|
|
3219
|
+
await refresh();
|
|
3220
|
+
}
|
|
3221
|
+
}
|
|
3222
|
+
catch (error) {
|
|
3223
|
+
let errorMessage = "TOKEN_INVALID: Token verification failed";
|
|
3224
|
+
if (error instanceof Error) {
|
|
3225
|
+
errorMessage = `${errorMessage} - ${error.message}`;
|
|
3226
|
+
}
|
|
3227
|
+
handleError(errorMessage, true, "/auth-error", "query");
|
|
3228
|
+
await cleanStorage();
|
|
3229
|
+
throw new Error(errorMessage);
|
|
3230
|
+
}
|
|
3231
|
+
};
|
|
3232
|
+
return {
|
|
3233
|
+
isAuthenticated,
|
|
3234
|
+
jwt,
|
|
3235
|
+
refresh_token,
|
|
3236
|
+
tokenExpiry,
|
|
3237
|
+
login,
|
|
3238
|
+
refresh,
|
|
3239
|
+
logout,
|
|
3240
|
+
cleanStorage,
|
|
3241
|
+
verifyToken,
|
|
3242
|
+
};
|
|
3243
|
+
}
|
|
3244
|
+
|
|
3245
|
+
let sessionId = v4();
|
|
3246
|
+
let sessionConfig = Object.freeze({
|
|
3247
|
+
SESSION_ID: sessionId,
|
|
3248
|
+
});
|
|
3249
|
+
/**
|
|
3250
|
+
* Configures the session identifier for the active browser session.
|
|
3251
|
+
* Once configured, it cannot be modified.
|
|
3252
|
+
*
|
|
3253
|
+
* @param {string} sessionIdParam - The unique session identifier.
|
|
3254
|
+
*
|
|
3255
|
+
* @returns {void} Does not return anything, but freezes the session configuration.
|
|
3256
|
+
*/
|
|
3257
|
+
function configSession(sessionIdParam) {
|
|
3258
|
+
sessionConfig = Object.freeze({
|
|
3259
|
+
SESSION_ID: sessionIdParam,
|
|
3260
|
+
});
|
|
3261
|
+
}
|
|
3262
|
+
/**
|
|
3263
|
+
* Retrieves the current session identifier configuration.
|
|
3264
|
+
*
|
|
3265
|
+
* @returns {string} The unique session identifier.
|
|
3266
|
+
*/
|
|
3267
|
+
function getSessionConfig() {
|
|
3268
|
+
return sessionConfig.SESSION_ID;
|
|
3269
|
+
}
|
|
3270
|
+
/**
|
|
3271
|
+
* Generates a new UUID for the current session.
|
|
3272
|
+
*
|
|
3273
|
+
* @returns {void} Does not return anything, but updates the session identifier.
|
|
3274
|
+
*/
|
|
3275
|
+
function regenerateSessionId() {
|
|
3276
|
+
sessionId = v4();
|
|
3277
|
+
configSession(sessionId);
|
|
3278
|
+
}
|
|
3279
|
+
/**
|
|
3280
|
+
* Retrieves the current session identifier.
|
|
3281
|
+
*
|
|
3282
|
+
* @returns {string} The unique session identifier.
|
|
3283
|
+
*/
|
|
3284
|
+
function getSessionId() {
|
|
3285
|
+
return sessionId;
|
|
3286
|
+
}
|
|
3287
|
+
|
|
3288
|
+
export { AppTypes, ArchiveTypes, AudioTypes, AxiosService, ContentTypeEnum, DocumentTypes, ERROR_MESSAGES, ERROR_STYLES, ErrorEnum, ErrorMessages, ErrorStyles, ExceptionEnum, FontTypes, ImageTypes, KeyCodeEnum, OtherTypes, RestStd, ScreenBreakpoint, ScreenSize, StorageKeyEnum, StorageTypeEnum, TextTypes, VideoTypes, addCustomKeyboardShortcut, addDays, addDoubleClickListener, addKeyListener, ageAtDate, axiosFetch, blobToFormData, bufferToBlob, calculateAge, clickOutside, compareObject, configAxios, configEndpoints, configSession, configTokenKeys, configureAuth, copyToClipboard, countWords, createCustomAxiosInstance, createFetch, createKeyMap, customShortcut, daysBetween, daysToNextBirthday, debounce, debounceAsync, debounceAsyncValidator, debounceAsyncWithImmediate, debounceLeading, debounceLeadingTrailing, debounceTrailing, deepClone, deepEqual, deepMerge, detectKeyHold, disableCopy, disableF12Key, disableMouseButtons, disableRightClick, disableSpecificKeys, downloadBlob, enableMouseButtons, enableRightClick, enableSpecificKeys, exportToCSV, exportToExcel, exportToJSON, exportToText, exportToXML, filterObjectByKeys, flattenObject, formDataToObject, formatDate, generateRandomString, getAxiosInstance, getEndOfMonth, getEndpointsConfig, getObjectDifferences, getObjectKeys, getQueryParam, getSecretKey, getSessionConfig, getSessionId, getStartOfMonth, getTokenConfig, hasNestedProperties, 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, regenerateSessionId, registerKeyboardShortcuts, removeAccent, removeClickOutside, removeCustomKeyboardShortcut, removeCustomShortcuts, removeDoubleClickListener, removeEmptyProperties, removeKeyListeners, replaceAll, reverseString, safeGet, screenMap, scrollToTop, setSecretKey, simulateKeyPress, stopDetectingKeyHold, stringToBlob, subtractDays, throttle, toCamelCase, toKebabCase, toggleTabNavigation, truncateString, unregisterKeyboardShortcuts, upperFirst, useAuth, useBreakpoint, useFilter, usePagination, useSorter, useVueQuery, validateAlphanumeric, validateLetters, validateNumbers };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arex95/vue-core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.12",
|
|
4
4
|
"description": "Opinionated Vue Core",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -35,7 +35,9 @@
|
|
|
35
35
|
"axios": ">=1.6.0",
|
|
36
36
|
"uuid": ">=11.1.0",
|
|
37
37
|
"vue": ">=3.0.0",
|
|
38
|
-
"vue-router": ">=4.5.0"
|
|
38
|
+
"vue-router": ">=4.5.0",
|
|
39
|
+
"crypto-js": "^4.2.0",
|
|
40
|
+
"jwt-decode": "^4.0.0"
|
|
39
41
|
},
|
|
40
42
|
"devDependencies": {
|
|
41
43
|
"@eslint/js": "^9.23.0",
|