@arex95/vue-core 1.1.12 → 1.1.14

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,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$1 = Object.freeze({
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$1 = Object.freeze({
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$1;
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$1 = {
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$1 = Object.freeze({
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$1;
2467
+ return endpointsConfig;
2468
2468
  }
2469
2469
 
2470
2470
  /**
@@ -2593,13 +2593,13 @@ class AxiosService {
2593
2593
  }
2594
2594
  }
2595
2595
 
2596
- let axiosInstance$1;
2596
+ let axiosInstance;
2597
2597
  /**
2598
2598
  * Configures the global Axios instance with a base URL.
2599
2599
  * @param {string} baseURL - The base URL for the Axios instance.
2600
2600
  */
2601
2601
  const configAxios = (baseURL) => {
2602
- axiosInstance$1 = new AxiosService(baseURL);
2602
+ axiosInstance = new AxiosService(baseURL);
2603
2603
  };
2604
2604
  /**
2605
2605
  * Retrieves the configured Axios instance.
@@ -2607,10 +2607,10 @@ const configAxios = (baseURL) => {
2607
2607
  * @throws Will throw an error if the Axios instance is not configured.
2608
2608
  */
2609
2609
  const getAxiosInstance = () => {
2610
- if (!axiosInstance$1) {
2610
+ if (!axiosInstance) {
2611
2611
  throw new Error('Axios instance not configured. Call configureAxios first.');
2612
2612
  }
2613
- return axiosInstance$1.getAxiosInstance();
2613
+ return axiosInstance.getAxiosInstance();
2614
2614
  };
2615
2615
  /**
2616
2616
  * Creates a new AxiosService instance with custom headers.
@@ -2989,29 +2989,6 @@ function useSorter(items, criteriaList, selectedCriteria) {
2989
2989
  }).value;
2990
2990
  }
2991
2991
 
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
2992
  function ab2hex(buffer) {
3016
2993
  return Array.from(buffer)
3017
2994
  .map((b) => b.toString(16).padStart(2, "0"))
@@ -3120,6 +3097,13 @@ async function getDecryptedValue(key, secretKey, isRememberMe) {
3120
3097
  * @returns {Object} Auth composable methods and properties.
3121
3098
  */
3122
3099
  function useAuth(secretKey = getSecretKey()) {
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,7 +3139,7 @@ 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.token, secretKey, isRememberMe);
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);
3160
3144
  return response;
3161
3145
  }
@@ -3285,4 +3269,4 @@ function getSessionId() {
3285
3269
  return sessionId;
3286
3270
  }
3287
3271
 
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 };
3272
+ 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 };
package/package.json CHANGED
@@ -1,70 +1,68 @@
1
- {
2
- "name": "@arex95/vue-core",
3
- "version": "1.1.12",
4
- "description": "Opinionated Vue Core",
5
- "main": "dist/index.js",
6
- "module": "dist/index.mjs",
7
- "exports": {
8
- "import": "./dist/index.mjs"
9
- },
10
- "types": "dist/index.d.ts",
11
- "type": "module",
12
- "files": [
13
- "dist"
14
- ],
15
- "scripts": {
16
- "build": "rollup -c",
17
- "changelog": "conventional-changelog -p angular -o CHANGELOG.md -r 0",
18
- "release": "npm version patch && npm run changelog && git add CHANGELOG.md package.json package-lock.json && git commit -m \"chore(release): update changelog\" && git push && npm publish --access public"
19
- },
20
- "repository": {
21
- "type": "git",
22
- "url": "https://github.com/Arex95/npm-arex-core.git"
23
- },
24
- "keywords": [
25
- "vue",
26
- "composables",
27
- "core",
28
- "npm"
29
- ],
30
- "author": "Arturo Rafael Serrano Girón",
31
- "license": "MIT",
32
- "peerDependencies": {
33
- "@tanstack/vue-query": ">=5.0.0",
34
- "@vueuse/core": ">=12.8.2",
35
- "axios": ">=1.6.0",
36
- "uuid": ">=11.1.0",
37
- "vue": ">=3.0.0",
38
- "vue-router": ">=4.5.0",
39
- "crypto-js": "^4.2.0",
40
- "jwt-decode": "^4.0.0"
41
- },
42
- "devDependencies": {
43
- "@eslint/js": "^9.23.0",
44
- "@rollup/plugin-commonjs": "^28.0.3",
45
- "@rollup/plugin-json": "^6.1.0",
46
- "@rollup/plugin-node-resolve": "^16.0.0",
47
- "@rollup/plugin-typescript": "^12.1.2",
48
- "@types/crypto-js": "^4.2.2",
49
- "@types/node": "^22.13.10",
50
- "conventional-changelog-cli": "^5.0.0",
51
- "eslint": "^9.23.0",
52
- "eslint-plugin-vue": "^10.0.0",
53
- "globals": "^16.0.0",
54
- "rollup": "^4.35.0",
55
- "ts-node": "^10.9.2",
56
- "tslib": "^2.8.1",
57
- "typescript": "^5.8.2",
58
- "typescript-eslint": "^8.28.0"
59
- },
60
- "dependencies": {
61
- "@tanstack/vue-query": ">=5.0.0",
62
- "@vueuse/core": ">=12.8.2",
63
- "axios": ">=1.6.0",
64
- "crypto-js": "^4.2.0",
65
- "jwt-decode": "^4.0.0",
66
- "uuid": ">=11.1.0",
67
- "vue": ">=3.0.0",
68
- "vue-router": ">=4.5.0"
69
- }
70
- }
1
+ {
2
+ "name": "@arex95/vue-core",
3
+ "version": "1.1.14",
4
+ "description": "Opinionated Vue Core",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "exports": {
8
+ "import": "./dist/index.mjs"
9
+ },
10
+ "types": "dist/index.d.ts",
11
+ "type": "module",
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "scripts": {
16
+ "build": "rollup -c",
17
+ "changelog": "conventional-changelog -p angular -o CHANGELOG.md -r 0",
18
+ "release": "npm version patch && npm run changelog && git add CHANGELOG.md package.json package-lock.json && git commit -m \"chore(release): update changelog\" && git push && npm publish --access public"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/Arex95/npm-arex-core.git"
23
+ },
24
+ "keywords": [
25
+ "vue",
26
+ "composables",
27
+ "core",
28
+ "npm"
29
+ ],
30
+ "author": "Arturo Rafael Serrano Girón",
31
+ "license": "MIT",
32
+ "peerDependencies": {
33
+ "@tanstack/vue-query": ">=5.0.0",
34
+ "@vueuse/core": ">=12.8.2",
35
+ "axios": ">=1.6.0",
36
+ "jwt-decode": "^4.0.0",
37
+ "uuid": ">=11.1.0",
38
+ "vue": ">=3.0.0",
39
+ "vue-router": ">=4.5.0"
40
+ },
41
+ "devDependencies": {
42
+ "@eslint/js": "^9.23.0",
43
+ "@rollup/plugin-commonjs": "^28.0.3",
44
+ "@rollup/plugin-json": "^6.1.0",
45
+ "@rollup/plugin-node-resolve": "^16.0.0",
46
+ "@rollup/plugin-typescript": "^12.1.2",
47
+ "@types/crypto-js": "^4.2.2",
48
+ "@types/node": "^22.13.10",
49
+ "conventional-changelog-cli": "^5.0.0",
50
+ "eslint": "^9.23.0",
51
+ "eslint-plugin-vue": "^10.0.0",
52
+ "globals": "^16.0.0",
53
+ "rollup": "^4.35.0",
54
+ "ts-node": "^10.9.2",
55
+ "tslib": "^2.8.1",
56
+ "typescript": "^5.8.2",
57
+ "typescript-eslint": "^8.28.0"
58
+ },
59
+ "dependencies": {
60
+ "@tanstack/vue-query": ">=5.0.0",
61
+ "@vueuse/core": ">=12.8.2",
62
+ "axios": ">=1.6.0",
63
+ "jwt-decode": "^4.0.0",
64
+ "uuid": ">=11.1.0",
65
+ "vue": ">=3.0.0",
66
+ "vue-router": ">=4.5.0"
67
+ }
68
+ }