@arex95/vue-core 1.0.9 → 1.1.0

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,22 +1,19 @@
1
+ import { AuthConfig } from "@/types";
1
2
  /**
2
- * Función para configurar los endpoints y las claves de almacenamiento globalmente.
3
- * Permite modificar los valores predeterminados de los endpoints y claves de almacenamiento.
3
+ * Configures authentication settings globally.
4
+ * Allows modifying default endpoints and storage keys.
4
5
  *
5
- * @param {Object} options - Configuración personalizada.
6
- * @param {Object} options.endpoints - Endpoints personalizados para login, refresh y logout.
7
- * @param {Object} options.storageKeys - Claves personalizadas para el almacenamiento de tokens.
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
+ /**
12
+ * Provides authentication utilities.
13
+ *
14
+ * @param {string} [secretKey=getSecretKey()] - Encryption key.
15
+ * @returns {Object} Auth composable methods and properties.
8
16
  */
9
- export declare function configureAuth(options: {
10
- endpoints?: {
11
- login?: string;
12
- refresh?: string;
13
- logout?: string;
14
- };
15
- storageKeys?: {
16
- token?: string;
17
- refreshToken?: string;
18
- };
19
- }): void;
20
17
  export declare function useAuth(secretKey?: string): {
21
18
  jwt: import("vue").ComputedRef<string | null>;
22
19
  refresh_token: import("vue").ComputedRef<string | null>;
@@ -3,7 +3,7 @@ import { AxiosInstance } from 'axios';
3
3
  * Configures the global Axios instance with a base URL.
4
4
  * @param {string} baseURL - The base URL for the Axios instance.
5
5
  */
6
- export declare const configureAxios: (baseURL: string) => void;
6
+ export declare const configAxios: (baseURL: string) => void;
7
7
  /**
8
8
  * Retrieves the configured Axios instance.
9
9
  * @returns {AxiosService} The configured Axios instance.
@@ -1,24 +1,21 @@
1
+ import { EndpointsConfig } from "@/types";
1
2
  /**
2
- * Configura las URLs de los endpoints de autenticación globalmente.
3
- * Esta función congela el objeto para evitar modificaciones posteriores.
3
+ * Configures authentication endpoint URLs globally.
4
+ * This function freezes the object to prevent further modifications.
4
5
  *
5
- * @param {string} loginEndpoint - URL del endpoint para el login.
6
- * @param {string} refreshEndpoint - URL del endpoint para el refresh token.
7
- * @param {string} logoutEndpoint - URL del endpoint para el logout.
6
+ * @param {string} loginEndpoint - URL of the login endpoint.
7
+ * @param {string} refreshEndpoint - URL of the refresh token endpoint.
8
+ * @param {string} logoutEndpoint - URL of the logout endpoint.
8
9
  *
9
- * @returns {void} No retorna nada, pero congela el objeto de configuración de endpoints.
10
+ * @returns {void} Does not return anything but freezes the endpoint configuration object.
10
11
  */
11
- export declare function configureEndpoints(loginEndpoint: string, refreshEndpoint: string, logoutEndpoint: string): void;
12
+ export declare function configEndpoints(loginEndpoint: string, refreshEndpoint: string, logoutEndpoint: string): void;
12
13
  /**
13
- * Obtiene las URLs de los endpoints de autenticación configurados.
14
+ * Retrieves the configured authentication endpoint URLs.
14
15
  *
15
- * @returns {Object} Objeto con las URLs de los endpoints configurados.
16
- * @returns {string} returns.LOGIN - URL del endpoint de login.
17
- * @returns {string} returns.REFRESH - URL del endpoint de refresh token.
18
- * @returns {string} returns.LOGOUT - URL del endpoint de logout.
16
+ * @returns {EndpointsConfig} An object containing the configured authentication endpoints.
17
+ * @property {string} LOGIN - URL of the login endpoint.
18
+ * @property {string} REFRESH - URL of the refresh token endpoint.
19
+ * @property {string} LOGOUT - URL of the logout endpoint.
19
20
  */
20
- export declare function getEndpointsConfig(): {
21
- LOGIN: string;
22
- REFRESH: string;
23
- LOGOUT: string;
24
- };
21
+ export declare function getEndpointsConfig(): EndpointsConfig;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Configures the session identifier for the active browser session.
3
+ * Once configured, it cannot be modified.
4
+ *
5
+ * @param {string} sessionIdParam - The unique session identifier.
6
+ *
7
+ * @returns {void} Does not return anything, but freezes the session configuration.
8
+ */
9
+ export declare function configSession(sessionIdParam: string): void;
10
+ /**
11
+ * Retrieves the current session identifier configuration.
12
+ *
13
+ * @returns {string} The unique session identifier.
14
+ */
15
+ export declare function getSessionConfig(): string;
16
+ /**
17
+ * Generates a new UUID for the current session.
18
+ *
19
+ * @returns {void} Does not return anything, but updates the session identifier.
20
+ */
21
+ export declare function regenerateSessionId(): void;
22
+ /**
23
+ * Retrieves the current session identifier.
24
+ *
25
+ * @returns {string} The unique session identifier.
26
+ */
27
+ export declare function getSessionId(): string;
@@ -1,27 +1,31 @@
1
- interface TokenConfig {
2
- readonly ACCESS_TOKEN: string;
3
- readonly REFRESH_TOKEN: string;
4
- }
1
+ import { TokenConfig } from "@/types";
5
2
  /**
6
- * Configura las claves globales para los tokens de acceso y refresh.
7
- * Una vez establecidas, no pueden ser modificadas.
8
- * @param accessTokenKey - Nombre de la clave del token de acceso.
9
- * @param refreshTokenKey - Nombre de la clave del refresh token.
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
10
  */
11
- export declare function setTokenConfig(accessTokenKey: string, refreshTokenKey: string): void;
11
+ export declare function configTokens(accessTokenKey: string, refreshTokenKey: string): void;
12
12
  /**
13
- * Obtiene la configuración actual de las claves de tokens.
14
- * @returns Configuración de los tokens.
13
+ * Retrieves the current token configuration.
14
+ *
15
+ * @returns {TokenConfig} The configuration of the access and refresh token keys.
15
16
  */
16
17
  export declare function getTokenConfig(): TokenConfig;
17
18
  /**
18
- * Establece la clave secreta para su uso en autenticación.
19
- * @param key - Nueva clave secreta.
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.
20
24
  */
21
25
  export declare function setSecretKey(key: string): void;
22
26
  /**
23
- * Obtiene la clave secreta actual.
24
- * @returns Clave secreta configurada.
27
+ * Retrieves the current secret key.
28
+ *
29
+ * @returns {string} The configured secret key.
25
30
  */
26
31
  export declare function getSecretKey(): string;
27
- export {};
package/dist/index.mjs CHANGED
@@ -2384,61 +2384,69 @@ function inferErrorType(error) {
2384
2384
  return 'error';
2385
2385
  }
2386
2386
 
2387
- let secretKey = '12345678901234567890123456789012';
2387
+ let secretKey = "12345678901234567890123456789012";
2388
2388
  let tokenConfig = Object.freeze({
2389
- ACCESS_TOKEN: 'authToken',
2390
- REFRESH_TOKEN: 'refreshToken',
2389
+ ACCESS_TOKEN: "authToken",
2390
+ REFRESH_TOKEN: "refreshToken",
2391
2391
  });
2392
2392
  /**
2393
- * Configura las claves globales para los tokens de acceso y refresh.
2394
- * Una vez establecidas, no pueden ser modificadas.
2395
- * @param accessTokenKey - Nombre de la clave del token de acceso.
2396
- * @param refreshTokenKey - Nombre de la clave del refresh token.
2393
+ * Configures the global keys for access and refresh tokens.
2394
+ * Once set, they cannot be modified.
2395
+ *
2396
+ * @param {string} accessTokenKey - The name of the access token key.
2397
+ * @param {string} refreshTokenKey - The name of the refresh token key.
2398
+ *
2399
+ * @returns {void} Does not return anything but freezes the token configuration object.
2397
2400
  */
2398
- function setTokenConfig(accessTokenKey, refreshTokenKey) {
2401
+ function configTokens(accessTokenKey, refreshTokenKey) {
2399
2402
  tokenConfig = Object.freeze({
2400
2403
  ACCESS_TOKEN: accessTokenKey,
2401
2404
  REFRESH_TOKEN: refreshTokenKey,
2402
2405
  });
2403
2406
  }
2404
2407
  /**
2405
- * Obtiene la configuración actual de las claves de tokens.
2406
- * @returns Configuración de los tokens.
2408
+ * Retrieves the current token configuration.
2409
+ *
2410
+ * @returns {TokenConfig} The configuration of the access and refresh token keys.
2407
2411
  */
2408
2412
  function getTokenConfig() {
2409
2413
  return tokenConfig;
2410
2414
  }
2411
2415
  /**
2412
- * Establece la clave secreta para su uso en autenticación.
2413
- * @param key - Nueva clave secreta.
2416
+ * Sets the secret key for use in authentication.
2417
+ *
2418
+ * @param {string} key - The new secret key.
2419
+ *
2420
+ * @returns {void} Does not return anything, but updates the secret key.
2414
2421
  */
2415
2422
  function setSecretKey(key) {
2416
2423
  secretKey = key;
2417
2424
  }
2418
2425
  /**
2419
- * Obtiene la clave secreta actual.
2420
- * @returns Clave secreta configurada.
2426
+ * Retrieves the current secret key.
2427
+ *
2428
+ * @returns {string} The configured secret key.
2421
2429
  */
2422
2430
  function getSecretKey() {
2423
2431
  return secretKey;
2424
2432
  }
2425
2433
 
2426
2434
  let endpointsConfig = {
2427
- LOGIN: '/login',
2428
- REFRESH: '/refresh',
2429
- LOGOUT: '/logout',
2435
+ LOGIN: "/login",
2436
+ REFRESH: "/refresh",
2437
+ LOGOUT: "/logout",
2430
2438
  };
2431
2439
  /**
2432
- * Configura las URLs de los endpoints de autenticación globalmente.
2433
- * Esta función congela el objeto para evitar modificaciones posteriores.
2440
+ * Configures authentication endpoint URLs globally.
2441
+ * This function freezes the object to prevent further modifications.
2434
2442
  *
2435
- * @param {string} loginEndpoint - URL del endpoint para el login.
2436
- * @param {string} refreshEndpoint - URL del endpoint para el refresh token.
2437
- * @param {string} logoutEndpoint - URL del endpoint para el logout.
2443
+ * @param {string} loginEndpoint - URL of the login endpoint.
2444
+ * @param {string} refreshEndpoint - URL of the refresh token endpoint.
2445
+ * @param {string} logoutEndpoint - URL of the logout endpoint.
2438
2446
  *
2439
- * @returns {void} No retorna nada, pero congela el objeto de configuración de endpoints.
2447
+ * @returns {void} Does not return anything but freezes the endpoint configuration object.
2440
2448
  */
2441
- function configureEndpoints(loginEndpoint, refreshEndpoint, logoutEndpoint) {
2449
+ function configEndpoints(loginEndpoint, refreshEndpoint, logoutEndpoint) {
2442
2450
  endpointsConfig = Object.freeze({
2443
2451
  LOGIN: loginEndpoint,
2444
2452
  REFRESH: refreshEndpoint,
@@ -2446,12 +2454,12 @@ function configureEndpoints(loginEndpoint, refreshEndpoint, logoutEndpoint) {
2446
2454
  });
2447
2455
  }
2448
2456
  /**
2449
- * Obtiene las URLs de los endpoints de autenticación configurados.
2457
+ * Retrieves the configured authentication endpoint URLs.
2450
2458
  *
2451
- * @returns {Object} Objeto con las URLs de los endpoints configurados.
2452
- * @returns {string} returns.LOGIN - URL del endpoint de login.
2453
- * @returns {string} returns.REFRESH - URL del endpoint de refresh token.
2454
- * @returns {string} returns.LOGOUT - URL del endpoint de logout.
2459
+ * @returns {EndpointsConfig} An object containing the configured authentication endpoints.
2460
+ * @property {string} LOGIN - URL of the login endpoint.
2461
+ * @property {string} REFRESH - URL of the refresh token endpoint.
2462
+ * @property {string} LOGOUT - URL of the logout endpoint.
2455
2463
  */
2456
2464
  function getEndpointsConfig() {
2457
2465
  return endpointsConfig;
@@ -2588,7 +2596,7 @@ let axiosInstance;
2588
2596
  * Configures the global Axios instance with a base URL.
2589
2597
  * @param {string} baseURL - The base URL for the Axios instance.
2590
2598
  */
2591
- const configureAxios = (baseURL) => {
2599
+ const configAxios = (baseURL) => {
2592
2600
  axiosInstance = new AxiosService(baseURL);
2593
2601
  };
2594
2602
  /**
@@ -2979,4 +2987,4 @@ function useSorter(items, criteriaList, selectedCriteria) {
2979
2987
  }).value;
2980
2988
  }
2981
2989
 
2982
- 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, configureAxios, configureEndpoints, 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, 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, registerKeyboardShortcuts, removeAccent, removeClickOutside, removeCustomKeyboardShortcut, removeCustomShortcuts, removeDoubleClickListener, removeEmptyProperties, removeKeyListeners, replaceAll, reverseString, safeGet, screenMap, scrollToTop, setSecretKey, setTokenConfig, simulateKeyPress, stopDetectingKeyHold, stringToBlob, subtractDays, throttle, toCamelCase, toKebabCase, toggleTabNavigation, truncateString, unregisterKeyboardShortcuts, upperFirst, useBreakpoint, useFilter, usePagination, useSorter, useVueQuery, validateAlphanumeric, validateLetters, validateNumbers };
2990
+ 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, configTokens, 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, 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, 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, useBreakpoint, useFilter, usePagination, useSorter, useVueQuery, validateAlphanumeric, validateLetters, validateNumbers };
@@ -0,0 +1,5 @@
1
+ import { TokenConfig, EndpointsConfig } from "@/types";
2
+ export type AuthConfig = {
3
+ endpoints: EndpointsConfig;
4
+ storageKeys: TokenConfig;
5
+ };
@@ -0,0 +1,5 @@
1
+ export type EndpointsConfig = {
2
+ LOGIN: string;
3
+ REFRESH: string;
4
+ LOGOUT: string;
5
+ };
@@ -0,0 +1,3 @@
1
+ export type SessionConfig = {
2
+ SESSION_ID: string;
3
+ };
@@ -0,0 +1,4 @@
1
+ export type TokenConfig = {
2
+ readonly ACCESS_TOKEN: string;
3
+ readonly REFRESH_TOKEN: string;
4
+ };
@@ -1,3 +1,7 @@
1
1
  export * from './AxiosOptionsParameter';
2
2
  export * from './ExtendedQueryOptions';
3
3
  export * from './ErrorType';
4
+ export * from './EndpointsConfig';
5
+ export * from './TokenConfig';
6
+ export * from './AuthConfig';
7
+ export * from './SessionConfig';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arex95/vue-core",
3
- "version": "1.0.9",
3
+ "version": "1.1.0",
4
4
  "description": "Opinionated Vue Core",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -31,28 +31,35 @@
31
31
  "@tanstack/vue-query": ">=5.0.0",
32
32
  "@vueuse/core": ">=12.8.2",
33
33
  "axios": ">=1.6.0",
34
+ "uuid": ">=11.1.0",
34
35
  "vue": ">=3.0.0",
35
36
  "vue-router": ">=4.5.0"
36
37
  },
37
38
  "devDependencies": {
39
+ "@eslint/js": "^9.23.0",
38
40
  "@rollup/plugin-commonjs": "^28.0.3",
39
41
  "@rollup/plugin-json": "^6.1.0",
40
42
  "@rollup/plugin-node-resolve": "^16.0.0",
41
43
  "@rollup/plugin-typescript": "^12.1.2",
42
44
  "@types/crypto-js": "^4.2.2",
43
45
  "@types/node": "^22.13.10",
46
+ "eslint": "^9.23.0",
47
+ "eslint-plugin-vue": "^10.0.0",
48
+ "globals": "^16.0.0",
44
49
  "rollup": "^4.35.0",
45
50
  "ts-node": "^10.9.2",
46
51
  "tslib": "^2.8.1",
47
- "typescript": "^5.8.2"
52
+ "typescript": "^5.8.2",
53
+ "typescript-eslint": "^8.28.0"
48
54
  },
49
55
  "dependencies": {
50
- "crypto-js": "^4.2.0",
51
- "jwt-decode": "^4.0.0",
52
- "vue-router": ">=4.5.0",
53
56
  "@tanstack/vue-query": ">=5.0.0",
54
57
  "@vueuse/core": ">=12.8.2",
55
58
  "axios": ">=1.6.0",
56
- "vue": ">=3.0.0"
59
+ "crypto-js": "^4.2.0",
60
+ "jwt-decode": "^4.0.0",
61
+ "uuid": ">=11.1.0",
62
+ "vue": ">=3.0.0",
63
+ "vue-router": ">=4.5.0"
57
64
  }
58
65
  }