@arex95/vue-core 1.1.13 → 1.1.15
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/useAuth.d.ts +0 -10
- package/dist/index.mjs +15 -30
- package/package.json +1 -1
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
import { AuthConfig } from "@/types";
|
|
2
|
-
/**
|
|
3
|
-
* Configures authentication settings globally.
|
|
4
|
-
* Allows modifying default endpoints and storage keys.
|
|
5
|
-
*
|
|
6
|
-
* @param {Object} options - Custom configuration options.
|
|
7
|
-
* @param {Object} [options.endpoints] - Custom endpoints for login, refresh, and logout.
|
|
8
|
-
* @param {Object} [options.storageKeys] - Custom storage keys for tokens.
|
|
9
|
-
*/
|
|
10
|
-
export declare function configureAuth(options: AuthConfig): void;
|
|
11
1
|
/**
|
|
12
2
|
* Provides authentication utilities.
|
|
13
3
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -2387,7 +2387,7 @@ function inferErrorType(error) {
|
|
|
2387
2387
|
}
|
|
2388
2388
|
|
|
2389
2389
|
let secretKey = "12345678901234567890123456789012";
|
|
2390
|
-
let tokensConfig
|
|
2390
|
+
let tokensConfig = Object.freeze({
|
|
2391
2391
|
ACCESS_TOKEN: "authToken",
|
|
2392
2392
|
REFRESH_TOKEN: "refreshToken",
|
|
2393
2393
|
});
|
|
@@ -2401,7 +2401,7 @@ let tokensConfig$1 = Object.freeze({
|
|
|
2401
2401
|
* @returns {void} Does not return anything but freezes the token configuration object.
|
|
2402
2402
|
*/
|
|
2403
2403
|
function configTokenKeys(accessTokenKey, refreshTokenKey) {
|
|
2404
|
-
tokensConfig
|
|
2404
|
+
tokensConfig = Object.freeze({
|
|
2405
2405
|
ACCESS_TOKEN: accessTokenKey,
|
|
2406
2406
|
REFRESH_TOKEN: refreshTokenKey,
|
|
2407
2407
|
});
|
|
@@ -2412,7 +2412,7 @@ function configTokenKeys(accessTokenKey, refreshTokenKey) {
|
|
|
2412
2412
|
* @returns {TokensConfig} The configuration of the access and refresh token keys.
|
|
2413
2413
|
*/
|
|
2414
2414
|
function getTokenConfig() {
|
|
2415
|
-
return tokensConfig
|
|
2415
|
+
return tokensConfig;
|
|
2416
2416
|
}
|
|
2417
2417
|
/**
|
|
2418
2418
|
* Sets the secret key for use in authentication.
|
|
@@ -2433,7 +2433,7 @@ function getSecretKey() {
|
|
|
2433
2433
|
return secretKey;
|
|
2434
2434
|
}
|
|
2435
2435
|
|
|
2436
|
-
let endpointsConfig
|
|
2436
|
+
let endpointsConfig = {
|
|
2437
2437
|
LOGIN: "/login",
|
|
2438
2438
|
REFRESH: "/refresh",
|
|
2439
2439
|
LOGOUT: "/logout",
|
|
@@ -2449,7 +2449,7 @@ let endpointsConfig$1 = {
|
|
|
2449
2449
|
* @returns {void} Does not return anything but freezes the endpoint configuration object.
|
|
2450
2450
|
*/
|
|
2451
2451
|
function configEndpoints(loginEndpoint, refreshEndpoint, logoutEndpoint) {
|
|
2452
|
-
endpointsConfig
|
|
2452
|
+
endpointsConfig = Object.freeze({
|
|
2453
2453
|
LOGIN: loginEndpoint,
|
|
2454
2454
|
REFRESH: refreshEndpoint,
|
|
2455
2455
|
LOGOUT: logoutEndpoint,
|
|
@@ -2464,7 +2464,7 @@ function configEndpoints(loginEndpoint, refreshEndpoint, logoutEndpoint) {
|
|
|
2464
2464
|
* @property {string} LOGOUT - URL of the logout endpoint.
|
|
2465
2465
|
*/
|
|
2466
2466
|
function getEndpointsConfig() {
|
|
2467
|
-
return endpointsConfig
|
|
2467
|
+
return endpointsConfig;
|
|
2468
2468
|
}
|
|
2469
2469
|
|
|
2470
2470
|
/**
|
|
@@ -2989,28 +2989,6 @@ function useSorter(items, criteriaList, selectedCriteria) {
|
|
|
2989
2989
|
}).value;
|
|
2990
2990
|
}
|
|
2991
2991
|
|
|
2992
|
-
const tokensConfig = getTokenConfig();
|
|
2993
|
-
const endpointsConfig = getEndpointsConfig();
|
|
2994
|
-
const config = {
|
|
2995
|
-
endpoints: endpointsConfig,
|
|
2996
|
-
storageKeys: tokensConfig,
|
|
2997
|
-
};
|
|
2998
|
-
/**
|
|
2999
|
-
* Configures authentication settings globally.
|
|
3000
|
-
* Allows modifying default endpoints and storage keys.
|
|
3001
|
-
*
|
|
3002
|
-
* @param {Object} options - Custom configuration options.
|
|
3003
|
-
* @param {Object} [options.endpoints] - Custom endpoints for login, refresh, and logout.
|
|
3004
|
-
* @param {Object} [options.storageKeys] - Custom storage keys for tokens.
|
|
3005
|
-
*/
|
|
3006
|
-
function configureAuth(options) {
|
|
3007
|
-
if (options.endpoints) {
|
|
3008
|
-
config.endpoints = { ...config.endpoints, ...options.endpoints };
|
|
3009
|
-
}
|
|
3010
|
-
if (options.storageKeys) {
|
|
3011
|
-
config.storageKeys = { ...config.storageKeys, ...options.storageKeys };
|
|
3012
|
-
}
|
|
3013
|
-
}
|
|
3014
2992
|
function ab2hex(buffer) {
|
|
3015
2993
|
return Array.from(buffer)
|
|
3016
2994
|
.map((b) => b.toString(16).padStart(2, "0"))
|
|
@@ -3120,6 +3098,12 @@ async function getDecryptedValue(key, secretKey, isRememberMe) {
|
|
|
3120
3098
|
*/
|
|
3121
3099
|
function useAuth(secretKey = getSecretKey()) {
|
|
3122
3100
|
const axiosInstance = getAxiosInstance();
|
|
3101
|
+
const tokensConfig = getTokenConfig();
|
|
3102
|
+
const endpointsConfig = getEndpointsConfig();
|
|
3103
|
+
const config = {
|
|
3104
|
+
endpoints: endpointsConfig,
|
|
3105
|
+
storageKeys: tokensConfig,
|
|
3106
|
+
};
|
|
3123
3107
|
const jwt = computedAsync(async () => await getDecryptedValue(config.storageKeys.ACCESS_TOKEN, secretKey), null);
|
|
3124
3108
|
const refresh_token = computedAsync(async () => await getDecryptedValue(config.storageKeys.REFRESH_TOKEN, secretKey), null);
|
|
3125
3109
|
/**
|
|
@@ -3155,8 +3139,9 @@ function useAuth(secretKey = getSecretKey()) {
|
|
|
3155
3139
|
const login = async (params = {}, isRememberMe) => {
|
|
3156
3140
|
try {
|
|
3157
3141
|
const response = await axiosInstance.post(config.endpoints.LOGIN, params);
|
|
3158
|
-
await storeEncryptedItem(config.storageKeys.ACCESS_TOKEN, response.data.
|
|
3142
|
+
await storeEncryptedItem(config.storageKeys.ACCESS_TOKEN, response.data.access_token, secretKey, isRememberMe);
|
|
3159
3143
|
await storeEncryptedItem(config.storageKeys.REFRESH_TOKEN, response.data.refresh_token, secretKey, isRememberMe);
|
|
3144
|
+
await jwt.value;
|
|
3160
3145
|
return response;
|
|
3161
3146
|
}
|
|
3162
3147
|
catch (error) {
|
|
@@ -3285,4 +3270,4 @@ function getSessionId() {
|
|
|
3285
3270
|
return sessionId;
|
|
3286
3271
|
}
|
|
3287
3272
|
|
|
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,
|
|
3273
|
+
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, 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 };
|