@arex95/vue-core 1.0.6 → 1.0.8
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 +29 -0
- package/dist/config/axios/axiosConfig.d.ts +3 -5
- package/dist/config/axios/axiosInstance.d.ts +18 -1
- package/dist/config/global/endpointsConfig.d.ts +24 -0
- package/dist/config/global/index.d.ts +2 -0
- package/dist/config/global/tokenConfig.d.ts +15 -0
- package/dist/config/index.d.ts +1 -0
- package/dist/constants/errorsEnum.d.ts +3 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/index.mjs +2311 -2071
- package/dist/rest/RestStd.d.ts +22 -5
- package/dist/types/ErrorType.d.ts +8 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/utils/errors.d.ts +10 -0
- package/package.json +17 -12
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
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.
|
|
4
|
+
*
|
|
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.
|
|
8
|
+
*/
|
|
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
|
+
export declare function useAuth(secretKey: string): {
|
|
21
|
+
jwt: import("vue").ComputedRef<string | null>;
|
|
22
|
+
refresh_token: import("vue").ComputedRef<string | null>;
|
|
23
|
+
tokenExpiry: import("vue").ComputedRef<number | null>;
|
|
24
|
+
login: (params?: {}) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
25
|
+
refresh: () => Promise<import("axios").AxiosResponse<any, any> | undefined>;
|
|
26
|
+
logout: (params?: {}) => Promise<void>;
|
|
27
|
+
cleanStorage: () => Promise<void>;
|
|
28
|
+
verifyToken: () => Promise<void>;
|
|
29
|
+
};
|
|
@@ -7,11 +7,13 @@ export declare class AxiosService {
|
|
|
7
7
|
private readonly instance;
|
|
8
8
|
private cancelTokenSource;
|
|
9
9
|
private activeRequests;
|
|
10
|
+
private refreshTokenInProgress;
|
|
11
|
+
private readonly refreshTokenUrl;
|
|
10
12
|
/**
|
|
11
13
|
* Initializes the AxiosService instance by creating an Axios instance with default configuration
|
|
12
14
|
* and setting up request and response interceptors.
|
|
13
15
|
*/
|
|
14
|
-
constructor(url: string);
|
|
16
|
+
constructor(url: string, headers?: Record<string, string>);
|
|
15
17
|
/**
|
|
16
18
|
* Initializes request and response interceptors for the Axios instance.
|
|
17
19
|
*/
|
|
@@ -20,10 +22,6 @@ export declare class AxiosService {
|
|
|
20
22
|
* Returns the number of active requests.
|
|
21
23
|
*/
|
|
22
24
|
getActiveRequests(): number;
|
|
23
|
-
/**
|
|
24
|
-
* Handles unauthorized access errors (401).
|
|
25
|
-
*/
|
|
26
|
-
private handleUnauthorized;
|
|
27
25
|
/**
|
|
28
26
|
* Returns the Axios instance with the configured settings and interceptors.
|
|
29
27
|
* @returns {AxiosInstance} The configured Axios instance.
|
|
@@ -1,2 +1,19 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
/**
|
|
3
|
+
* Configures the global Axios instance with a base URL.
|
|
4
|
+
* @param {string} baseURL - The base URL for the Axios instance.
|
|
5
|
+
*/
|
|
1
6
|
export declare const configureAxios: (baseURL: string) => void;
|
|
2
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Retrieves the configured Axios instance.
|
|
9
|
+
* @returns {AxiosService} The configured Axios instance.
|
|
10
|
+
* @throws Will throw an error if the Axios instance is not configured.
|
|
11
|
+
*/
|
|
12
|
+
export declare const getAxiosInstance: () => AxiosInstance;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new AxiosService instance with custom headers.
|
|
15
|
+
* @param {string} baseURL - The base URL for the Axios instance.
|
|
16
|
+
* @param {Record<string, string>} headers - Custom headers to set.
|
|
17
|
+
* @returns {AxiosService} The new AxiosService instance.
|
|
18
|
+
*/
|
|
19
|
+
export declare const createCustomAxiosInstance: (baseURL: string, headers: Record<string, string>) => AxiosInstance;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configura las URLs de los endpoints de autenticación globalmente.
|
|
3
|
+
* Esta función congela el objeto para evitar modificaciones posteriores.
|
|
4
|
+
*
|
|
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.
|
|
8
|
+
*
|
|
9
|
+
* @returns {void} No retorna nada, pero congela el objeto de configuración de endpoints.
|
|
10
|
+
*/
|
|
11
|
+
export declare function configureEndpoints(loginEndpoint: string, refreshEndpoint: string, logoutEndpoint: string): void;
|
|
12
|
+
/**
|
|
13
|
+
* Obtiene las URLs de los endpoints de autenticación configurados.
|
|
14
|
+
*
|
|
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.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getEndpointsConfig(): {
|
|
21
|
+
LOGIN: string;
|
|
22
|
+
REFRESH: string;
|
|
23
|
+
LOGOUT: string;
|
|
24
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Función para configurar las claves globalmente.
|
|
3
|
+
* Esta función congela el objeto para evitar modificaciones posteriores.
|
|
4
|
+
* @param {string} accessTokenKey - Nombre de la clave del token de acceso
|
|
5
|
+
* @param {string} refreshTokenKey - Nombre de la clave del refresh token
|
|
6
|
+
*/
|
|
7
|
+
export declare function configureTokenKeys(accessTokenKey: string, refreshTokenKey: string): void;
|
|
8
|
+
/**
|
|
9
|
+
* Obtiene las claves configuradas para los tokens.
|
|
10
|
+
* El objeto está congelado, por lo que no se puede modificar directamente.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getTokenConfig(): {
|
|
13
|
+
ACCESS_TOKEN: string;
|
|
14
|
+
REFRESH_TOKEN: string;
|
|
15
|
+
};
|
package/dist/config/index.d.ts
CHANGED