@nocios/crudify-ui 4.0.94 → 4.0.96
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/{index-DxFMT2hN.d.ts → LoginComponent-saSn0o5x.d.mts} +0 -1
- package/dist/{index-CY6Qkw3q.d.mts → LoginComponent-saSn0o5x.d.ts} +0 -1
- package/dist/chunk-ATAGEVFK.js +1 -0
- package/dist/chunk-HMJY3MMZ.mjs +1 -0
- package/dist/{chunk-5PZJJNHP.mjs → chunk-JYDCSNNQ.mjs} +1 -1
- package/dist/{chunk-3SLGRD36.js → chunk-LP5NJV2P.js} +1 -1
- package/dist/chunk-MMYGRMGB.mjs +1 -0
- package/dist/chunk-RHG74IMW.js +1 -0
- package/dist/{chunk-Q7FTH5JW.js → chunk-WG3ZXCPF.js} +1 -1
- package/dist/{chunk-5INZZQD6.mjs → chunk-Y72XFXMI.mjs} +1 -1
- package/dist/components.d.mts +22 -2
- package/dist/components.d.ts +22 -2
- package/dist/components.js +1 -1
- package/dist/components.mjs +1 -1
- package/dist/errorTranslation-CBbQYNWR.d.ts +124 -0
- package/dist/errorTranslation-DqdgLEUy.d.mts +124 -0
- package/dist/hooks.d.mts +1 -1
- package/dist/hooks.d.ts +1 -1
- package/dist/hooks.js +1 -1
- package/dist/hooks.mjs +1 -1
- package/dist/{index-BoWx_rFw.d.mts → index-CUbUeMMS.d.mts} +7 -2
- package/dist/{index-CQttyYlB.d.ts → index-DZdMugLk.d.ts} +7 -2
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/utils.d.mts +49 -118
- package/dist/utils.d.ts +49 -118
- package/dist/utils.js +1 -1
- package/dist/utils.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-2OSNNNID.js +0 -1
- package/dist/chunk-6EBMA4HZ.js +0 -1
- package/dist/chunk-VVXZWBHL.mjs +0 -1
- package/dist/chunk-YS3C7YG5.mjs +0 -1
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { J as JwtPayload } from './api-Djqihi4n.mjs';
|
|
2
|
+
|
|
3
|
+
interface JWTPayload extends JwtPayload {
|
|
4
|
+
"cognito:username"?: string;
|
|
5
|
+
}
|
|
6
|
+
declare const decodeJwtSafely: (token: string) => JWTPayload | null;
|
|
7
|
+
declare const getCurrentUserEmail: () => string | null;
|
|
8
|
+
declare const isTokenExpired: (token: string) => boolean;
|
|
9
|
+
|
|
10
|
+
declare const getCookie: (name: string) => string | null;
|
|
11
|
+
|
|
12
|
+
declare class SecureStorage {
|
|
13
|
+
private readonly encryptionKey;
|
|
14
|
+
private readonly storage;
|
|
15
|
+
constructor(storageType?: "localStorage" | "sessionStorage");
|
|
16
|
+
private generateEncryptionKey;
|
|
17
|
+
setItem(key: string, value: string, expiryMinutes?: number): void;
|
|
18
|
+
getItem(key: string): string | null;
|
|
19
|
+
removeItem(key: string): void;
|
|
20
|
+
setToken(token: string): void;
|
|
21
|
+
getToken(): string | null;
|
|
22
|
+
}
|
|
23
|
+
declare const secureSessionStorage: SecureStorage;
|
|
24
|
+
declare const secureLocalStorage: SecureStorage;
|
|
25
|
+
|
|
26
|
+
declare const ERROR_CODES: {
|
|
27
|
+
readonly INVALID_CREDENTIALS: "INVALID_CREDENTIALS";
|
|
28
|
+
readonly UNAUTHORIZED: "UNAUTHORIZED";
|
|
29
|
+
readonly INVALID_API_KEY: "INVALID_API_KEY";
|
|
30
|
+
readonly USER_NOT_FOUND: "USER_NOT_FOUND";
|
|
31
|
+
readonly USER_NOT_ACTIVE: "USER_NOT_ACTIVE";
|
|
32
|
+
readonly NO_PERMISSION: "NO_PERMISSION";
|
|
33
|
+
readonly ITEM_NOT_FOUND: "ITEM_NOT_FOUND";
|
|
34
|
+
readonly NOT_FOUND: "NOT_FOUND";
|
|
35
|
+
readonly IN_USE: "IN_USE";
|
|
36
|
+
readonly FIELD_ERROR: "FIELD_ERROR";
|
|
37
|
+
readonly BAD_REQUEST: "BAD_REQUEST";
|
|
38
|
+
readonly INVALID_EMAIL: "INVALID_EMAIL";
|
|
39
|
+
readonly INVALID_CODE: "INVALID_CODE";
|
|
40
|
+
readonly INTERNAL_SERVER_ERROR: "INTERNAL_SERVER_ERROR";
|
|
41
|
+
readonly DATABASE_CONNECTION_ERROR: "DATABASE_CONNECTION_ERROR";
|
|
42
|
+
readonly INVALID_CONFIGURATION: "INVALID_CONFIGURATION";
|
|
43
|
+
readonly UNKNOWN_OPERATION: "UNKNOWN_OPERATION";
|
|
44
|
+
readonly TOO_MANY_REQUESTS: "TOO_MANY_REQUESTS";
|
|
45
|
+
readonly NETWORK_ERROR: "NETWORK_ERROR";
|
|
46
|
+
readonly TIMEOUT_ERROR: "TIMEOUT_ERROR";
|
|
47
|
+
};
|
|
48
|
+
type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];
|
|
49
|
+
type ErrorSeverity = "info" | "warning" | "error" | "critical";
|
|
50
|
+
declare const ERROR_SEVERITY_MAP: Record<ErrorCode, ErrorSeverity>;
|
|
51
|
+
interface ParsedError {
|
|
52
|
+
code: ErrorCode;
|
|
53
|
+
message: string;
|
|
54
|
+
severity: ErrorSeverity;
|
|
55
|
+
field?: string;
|
|
56
|
+
details?: Record<string, unknown>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Parse a Crudify API response and extract standardized error information
|
|
60
|
+
*/
|
|
61
|
+
declare function parseApiError(response: unknown): ParsedError[];
|
|
62
|
+
/**
|
|
63
|
+
* Parse transaction response errors
|
|
64
|
+
*/
|
|
65
|
+
declare function parseTransactionError(response: unknown): ParsedError[];
|
|
66
|
+
/**
|
|
67
|
+
* Get a human-readable error message for an error code
|
|
68
|
+
*/
|
|
69
|
+
declare function getErrorMessage(code: ErrorCode): string;
|
|
70
|
+
/**
|
|
71
|
+
* Handle JavaScript/Network errors and convert to ParsedError
|
|
72
|
+
*/
|
|
73
|
+
declare function parseJavaScriptError(error: unknown): ParsedError;
|
|
74
|
+
/**
|
|
75
|
+
* Universal error handler that can process any type of error from Crudify APIs
|
|
76
|
+
*/
|
|
77
|
+
declare function handleCrudifyError(error: unknown): ParsedError[];
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Utilidad robusta para traducir códigos de error con fallbacks inteligentes
|
|
81
|
+
* Busca en múltiples namespaces y devuelve la traducción más específica disponible
|
|
82
|
+
*/
|
|
83
|
+
interface ErrorTranslationConfig {
|
|
84
|
+
/** Función de traducción de i18next */
|
|
85
|
+
translateFn: (key: string) => string;
|
|
86
|
+
/** Idioma actual (opcional, para logging) */
|
|
87
|
+
currentLanguage?: string;
|
|
88
|
+
/** Habilitar logs de debug */
|
|
89
|
+
enableDebug?: boolean;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Traduce un código de error usando jerarquía de fallbacks
|
|
93
|
+
*/
|
|
94
|
+
declare function translateErrorCode(errorCode: string, config: ErrorTranslationConfig): string;
|
|
95
|
+
/**
|
|
96
|
+
* Traduce múltiples códigos de error
|
|
97
|
+
*/
|
|
98
|
+
declare function translateErrorCodes(errorCodes: string[], config: ErrorTranslationConfig): string[];
|
|
99
|
+
/**
|
|
100
|
+
* Traduce un error completo (código + mensaje personalizado)
|
|
101
|
+
*/
|
|
102
|
+
declare function translateError(error: {
|
|
103
|
+
code: string;
|
|
104
|
+
message?: string;
|
|
105
|
+
field?: string;
|
|
106
|
+
}, config: ErrorTranslationConfig): string;
|
|
107
|
+
/**
|
|
108
|
+
* Hook para usar en componentes React con i18next
|
|
109
|
+
*/
|
|
110
|
+
declare function createErrorTranslator(translateFn: (key: string) => string, options?: {
|
|
111
|
+
currentLanguage?: string;
|
|
112
|
+
enableDebug?: boolean;
|
|
113
|
+
}): {
|
|
114
|
+
translateErrorCode: (code: string) => string;
|
|
115
|
+
translateErrorCodes: (codes: string[]) => string[];
|
|
116
|
+
translateError: (error: {
|
|
117
|
+
code: string;
|
|
118
|
+
message?: string;
|
|
119
|
+
field?: string;
|
|
120
|
+
}) => string;
|
|
121
|
+
translateApiError: (apiResponse: any) => string;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export { ERROR_CODES as E, type ParsedError as P, getCookie as a, secureLocalStorage as b, parseTransactionError as c, decodeJwtSafely as d, parseJavaScriptError as e, getErrorMessage as f, getCurrentUserEmail as g, handleCrudifyError as h, isTokenExpired as i, ERROR_SEVERITY_MAP as j, type ErrorCode as k, type ErrorSeverity as l, translateErrorCodes as m, translateError as n, createErrorTranslator as o, parseApiError as p, type ErrorTranslationConfig as q, secureSessionStorage as s, translateErrorCode as t };
|
package/dist/hooks.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { d as SessionState, j as UseAuthReturn, l as UseDataReturn, U as UseSessionOptions, g as UseUserDataOptions, f as UseUserDataReturn, h as UserData, i as useAuth, n as useCrudifyWithNotifications, k as useData, u as useSession, e as useUserData, m as useUserProfile } from './index-
|
|
1
|
+
export { d as SessionState, j as UseAuthReturn, l as UseDataReturn, U as UseSessionOptions, g as UseUserDataOptions, f as UseUserDataReturn, h as UserData, i as useAuth, n as useCrudifyWithNotifications, k as useData, u as useSession, e as useUserData, m as useUserProfile } from './index-CUbUeMMS.mjs';
|
|
2
2
|
import './api-Djqihi4n.mjs';
|
|
3
3
|
import './GlobalNotificationProvider-C3iWgM1z.mjs';
|
|
4
4
|
import 'react';
|
package/dist/hooks.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { d as SessionState, j as UseAuthReturn, l as UseDataReturn, U as UseSessionOptions, g as UseUserDataOptions, f as UseUserDataReturn, h as UserData, i as useAuth, n as useCrudifyWithNotifications, k as useData, u as useSession, e as useUserData, m as useUserProfile } from './index-
|
|
1
|
+
export { d as SessionState, j as UseAuthReturn, l as UseDataReturn, U as UseSessionOptions, g as UseUserDataOptions, f as UseUserDataReturn, h as UserData, i as useAuth, n as useCrudifyWithNotifications, k as useData, u as useSession, e as useUserData, m as useUserProfile } from './index-DZdMugLk.js';
|
|
2
2
|
import './api-Djqihi4n.js';
|
|
3
3
|
import './GlobalNotificationProvider-C3iWgM1z.js';
|
|
4
4
|
import 'react';
|
package/dist/hooks.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkLP5NJV2Pjs = require('./chunk-LP5NJV2P.js');var _chunkRHG74IMWjs = require('./chunk-RHG74IMW.js');require('./chunk-ATAGEVFK.js');exports.useAuth = _chunkLP5NJV2Pjs.b; exports.useCrudifyWithNotifications = _chunkLP5NJV2Pjs.d; exports.useData = _chunkLP5NJV2Pjs.c; exports.useSession = _chunkRHG74IMWjs.c; exports.useUserData = _chunkLP5NJV2Pjs.a; exports.useUserProfile = _chunkRHG74IMWjs.j;
|
package/dist/hooks.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s,b as r,c as o,d as a}from"./chunk-
|
|
1
|
+
import{a as s,b as r,c as o,d as a}from"./chunk-Y72XFXMI.mjs";import{c as e,j as t}from"./chunk-MMYGRMGB.mjs";import"./chunk-HMJY3MMZ.mjs";export{r as useAuth,a as useCrudifyWithNotifications,o as useData,e as useSession,s as useUserData,t as useUserProfile};
|
|
@@ -75,6 +75,11 @@ declare class TokenStorage {
|
|
|
75
75
|
* Actualizar solo el access token (después de refresh)
|
|
76
76
|
*/
|
|
77
77
|
static updateAccessToken(newAccessToken: string, newExpiresAt: number): void;
|
|
78
|
+
/**
|
|
79
|
+
* ✅ FASE 4.2: Suscribirse a cambios de tokens entre tabs
|
|
80
|
+
* Permite sincronizar logout/login entre múltiples tabs/ventanas
|
|
81
|
+
*/
|
|
82
|
+
static subscribeToChanges(callback: (tokens: TokenData | null) => void): () => void;
|
|
78
83
|
}
|
|
79
84
|
|
|
80
85
|
type SessionConfig = {
|
|
@@ -151,11 +156,11 @@ declare class SessionManager {
|
|
|
151
156
|
*/
|
|
152
157
|
refreshTokens(): Promise<boolean>;
|
|
153
158
|
/**
|
|
154
|
-
* Configurar interceptor de respuesta
|
|
159
|
+
* ✅ FASE 3.3: Configurar interceptor de respuesta con Event Bus
|
|
155
160
|
*/
|
|
156
161
|
setupResponseInterceptor(): void;
|
|
157
162
|
/**
|
|
158
|
-
* Detectar errores de autorización en todos los formatos posibles
|
|
163
|
+
* ✅ FASE 3.1: Detectar errores de autorización en todos los formatos posibles (mejorado)
|
|
159
164
|
*/
|
|
160
165
|
private detectAuthorizationError;
|
|
161
166
|
/**
|
|
@@ -75,6 +75,11 @@ declare class TokenStorage {
|
|
|
75
75
|
* Actualizar solo el access token (después de refresh)
|
|
76
76
|
*/
|
|
77
77
|
static updateAccessToken(newAccessToken: string, newExpiresAt: number): void;
|
|
78
|
+
/**
|
|
79
|
+
* ✅ FASE 4.2: Suscribirse a cambios de tokens entre tabs
|
|
80
|
+
* Permite sincronizar logout/login entre múltiples tabs/ventanas
|
|
81
|
+
*/
|
|
82
|
+
static subscribeToChanges(callback: (tokens: TokenData | null) => void): () => void;
|
|
78
83
|
}
|
|
79
84
|
|
|
80
85
|
type SessionConfig = {
|
|
@@ -151,11 +156,11 @@ declare class SessionManager {
|
|
|
151
156
|
*/
|
|
152
157
|
refreshTokens(): Promise<boolean>;
|
|
153
158
|
/**
|
|
154
|
-
* Configurar interceptor de respuesta
|
|
159
|
+
* ✅ FASE 3.3: Configurar interceptor de respuesta con Event Bus
|
|
155
160
|
*/
|
|
156
161
|
setupResponseInterceptor(): void;
|
|
157
162
|
/**
|
|
158
|
-
* Detectar errores de autorización en todos los formatos posibles
|
|
163
|
+
* ✅ FASE 3.1: Detectar errores de autorización en todos los formatos posibles (mejorado)
|
|
159
164
|
*/
|
|
160
165
|
private detectAuthorizationError;
|
|
161
166
|
/**
|
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export * from '@nocios/crudify-browser';
|
|
2
2
|
export { default as crudify } from '@nocios/crudify-browser';
|
|
3
|
-
export { B as BoxScreenType, C as CrudifyLogin, d as CrudifyLoginConfig, e as CrudifyLoginProps, f as CrudifyLoginTranslations, L as LoginComponent, a as POLICY_ACTIONS, b as PREFERRED_POLICY_ORDER, P as Policies, c as PolicyAction, S as SessionStatus, g as UserLoginData, U as UserProfileDisplay } from './
|
|
3
|
+
export { B as BoxScreenType, C as CrudifyLogin, d as CrudifyLoginConfig, e as CrudifyLoginProps, f as CrudifyLoginTranslations, L as LoginComponent, a as POLICY_ACTIONS, b as PREFERRED_POLICY_ORDER, P as Policies, c as PolicyAction, S as SessionStatus, g as UserLoginData, U as UserProfileDisplay } from './LoginComponent-saSn0o5x.mjs';
|
|
4
4
|
export { A as ApiError, C as CrudifyApiResponse, a as CrudifyTransactionResponse, F as ForgotPasswordRequest, J as JwtPayload, b as LoginRequest, L as LoginResponse, R as ResetPasswordRequest, T as TransactionResponseData, U as UserProfile, V as ValidateCodeRequest, c as ValidationError } from './api-Djqihi4n.mjs';
|
|
5
|
-
import { U as UseSessionOptions, T as TokenData, L as LoginResult } from './index-
|
|
6
|
-
export { a as SessionConfig, S as SessionManager, d as SessionState, c as StorageType, b as TokenStorage, j as UseAuthReturn, l as UseDataReturn, g as UseUserDataOptions, f as UseUserDataReturn, h as UserData, i as useAuth, n as useCrudifyWithNotifications, k as useData, u as useSession, e as useUserData, m as useUserProfile } from './index-
|
|
5
|
+
import { U as UseSessionOptions, T as TokenData, L as LoginResult } from './index-CUbUeMMS.mjs';
|
|
6
|
+
export { a as SessionConfig, S as SessionManager, d as SessionState, c as StorageType, b as TokenStorage, j as UseAuthReturn, l as UseDataReturn, g as UseUserDataOptions, f as UseUserDataReturn, h as UserData, i as useAuth, n as useCrudifyWithNotifications, k as useData, u as useSession, e as useUserData, m as useUserProfile } from './index-CUbUeMMS.mjs';
|
|
7
7
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
8
8
|
import { ReactNode } from 'react';
|
|
9
|
-
export { ERROR_CODES, ERROR_SEVERITY_MAP, ErrorCode, ErrorSeverity, ErrorTranslationConfig, ParsedError, createErrorTranslator, decodeJwtSafely, getCookie, getCurrentUserEmail, getErrorMessage, handleCrudifyError, isTokenExpired, parseApiError, parseJavaScriptError, parseTransactionError, secureLocalStorage, secureSessionStorage, translateError, translateErrorCode, translateErrorCodes } from './
|
|
9
|
+
export { E as ERROR_CODES, j as ERROR_SEVERITY_MAP, k as ErrorCode, l as ErrorSeverity, q as ErrorTranslationConfig, P as ParsedError, o as createErrorTranslator, d as decodeJwtSafely, a as getCookie, g as getCurrentUserEmail, f as getErrorMessage, h as handleCrudifyError, i as isTokenExpired, p as parseApiError, e as parseJavaScriptError, c as parseTransactionError, b as secureLocalStorage, s as secureSessionStorage, n as translateError, t as translateErrorCode, m as translateErrorCodes } from './errorTranslation-DqdgLEUy.mjs';
|
|
10
10
|
export { G as GlobalNotificationProvider, a as GlobalNotificationProviderProps, N as Notification, b as NotificationSeverity, u as useGlobalNotification } from './GlobalNotificationProvider-C3iWgM1z.mjs';
|
|
11
11
|
|
|
12
12
|
type SessionData = {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export * from '@nocios/crudify-browser';
|
|
2
2
|
export { default as crudify } from '@nocios/crudify-browser';
|
|
3
|
-
export { B as BoxScreenType, C as CrudifyLogin, d as CrudifyLoginConfig, e as CrudifyLoginProps, f as CrudifyLoginTranslations, L as LoginComponent, a as POLICY_ACTIONS, b as PREFERRED_POLICY_ORDER, P as Policies, c as PolicyAction, S as SessionStatus, g as UserLoginData, U as UserProfileDisplay } from './
|
|
3
|
+
export { B as BoxScreenType, C as CrudifyLogin, d as CrudifyLoginConfig, e as CrudifyLoginProps, f as CrudifyLoginTranslations, L as LoginComponent, a as POLICY_ACTIONS, b as PREFERRED_POLICY_ORDER, P as Policies, c as PolicyAction, S as SessionStatus, g as UserLoginData, U as UserProfileDisplay } from './LoginComponent-saSn0o5x.js';
|
|
4
4
|
export { A as ApiError, C as CrudifyApiResponse, a as CrudifyTransactionResponse, F as ForgotPasswordRequest, J as JwtPayload, b as LoginRequest, L as LoginResponse, R as ResetPasswordRequest, T as TransactionResponseData, U as UserProfile, V as ValidateCodeRequest, c as ValidationError } from './api-Djqihi4n.js';
|
|
5
|
-
import { U as UseSessionOptions, T as TokenData, L as LoginResult } from './index-
|
|
6
|
-
export { a as SessionConfig, S as SessionManager, d as SessionState, c as StorageType, b as TokenStorage, j as UseAuthReturn, l as UseDataReturn, g as UseUserDataOptions, f as UseUserDataReturn, h as UserData, i as useAuth, n as useCrudifyWithNotifications, k as useData, u as useSession, e as useUserData, m as useUserProfile } from './index-
|
|
5
|
+
import { U as UseSessionOptions, T as TokenData, L as LoginResult } from './index-DZdMugLk.js';
|
|
6
|
+
export { a as SessionConfig, S as SessionManager, d as SessionState, c as StorageType, b as TokenStorage, j as UseAuthReturn, l as UseDataReturn, g as UseUserDataOptions, f as UseUserDataReturn, h as UserData, i as useAuth, n as useCrudifyWithNotifications, k as useData, u as useSession, e as useUserData, m as useUserProfile } from './index-DZdMugLk.js';
|
|
7
7
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
8
8
|
import { ReactNode } from 'react';
|
|
9
|
-
export { ERROR_CODES, ERROR_SEVERITY_MAP, ErrorCode, ErrorSeverity, ErrorTranslationConfig, ParsedError, createErrorTranslator, decodeJwtSafely, getCookie, getCurrentUserEmail, getErrorMessage, handleCrudifyError, isTokenExpired, parseApiError, parseJavaScriptError, parseTransactionError, secureLocalStorage, secureSessionStorage, translateError, translateErrorCode, translateErrorCodes } from './
|
|
9
|
+
export { E as ERROR_CODES, j as ERROR_SEVERITY_MAP, k as ErrorCode, l as ErrorSeverity, q as ErrorTranslationConfig, P as ParsedError, o as createErrorTranslator, d as decodeJwtSafely, a as getCookie, g as getCurrentUserEmail, f as getErrorMessage, h as handleCrudifyError, i as isTokenExpired, p as parseApiError, e as parseJavaScriptError, c as parseTransactionError, b as secureLocalStorage, s as secureSessionStorage, n as translateError, t as translateErrorCode, m as translateErrorCodes } from './errorTranslation-CBbQYNWR.js';
|
|
10
10
|
export { G as GlobalNotificationProvider, a as GlobalNotificationProviderProps, N as Notification, b as NotificationSeverity, u as useGlobalNotification } from './GlobalNotificationProvider-C3iWgM1z.js';
|
|
11
11
|
|
|
12
12
|
type SessionData = {
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); }var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); }var _chunkWG3ZXCPFjs = require('./chunk-WG3ZXCPF.js');var _chunkLP5NJV2Pjs = require('./chunk-LP5NJV2P.js');var _chunkRHG74IMWjs = require('./chunk-RHG74IMW.js');var _chunkNNY4A73Vjs = require('./chunk-NNY4A73V.js');var _chunkYIIUEOXCjs = require('./chunk-YIIUEOXC.js');var _chunkATAGEVFKjs = require('./chunk-ATAGEVFK.js');var _crudifybrowser = require('@nocios/crudify-browser'); var _crudifybrowser2 = _interopRequireDefault(_crudifybrowser); _createStarExport(_crudifybrowser);exports.CrudifyLogin = _chunkWG3ZXCPFjs.a; exports.ERROR_CODES = _chunkYIIUEOXCjs.a; exports.ERROR_SEVERITY_MAP = _chunkYIIUEOXCjs.b; exports.GlobalNotificationProvider = _chunkRHG74IMWjs.d; exports.LoginComponent = _chunkWG3ZXCPFjs.f; exports.POLICY_ACTIONS = _chunkWG3ZXCPFjs.c; exports.PREFERRED_POLICY_ORDER = _chunkWG3ZXCPFjs.d; exports.Policies = _chunkWG3ZXCPFjs.e; exports.ProtectedRoute = _chunkRHG74IMWjs.h; exports.SessionDebugInfo = _chunkRHG74IMWjs.i; exports.SessionManager = _chunkRHG74IMWjs.b; exports.SessionProvider = _chunkRHG74IMWjs.f; exports.SessionStatus = _chunkWG3ZXCPFjs.g; exports.TokenStorage = _chunkRHG74IMWjs.a; exports.UserProfileDisplay = _chunkWG3ZXCPFjs.b; exports.createErrorTranslator = _chunkATAGEVFKjs.e; exports.crudify = _crudifybrowser2.default; exports.decodeJwtSafely = _chunkATAGEVFKjs.g; exports.getCookie = _chunkATAGEVFKjs.a; exports.getCurrentUserEmail = _chunkATAGEVFKjs.h; exports.getErrorMessage = _chunkYIIUEOXCjs.e; exports.handleCrudifyError = _chunkYIIUEOXCjs.g; exports.isTokenExpired = _chunkATAGEVFKjs.i; exports.parseApiError = _chunkYIIUEOXCjs.c; exports.parseJavaScriptError = _chunkYIIUEOXCjs.f; exports.parseTransactionError = _chunkYIIUEOXCjs.d; exports.secureLocalStorage = _chunkNNY4A73Vjs.b; exports.secureSessionStorage = _chunkNNY4A73Vjs.a; exports.translateError = _chunkATAGEVFKjs.d; exports.translateErrorCode = _chunkATAGEVFKjs.b; exports.translateErrorCodes = _chunkATAGEVFKjs.c; exports.useAuth = _chunkLP5NJV2Pjs.b; exports.useCrudifyWithNotifications = _chunkLP5NJV2Pjs.d; exports.useData = _chunkLP5NJV2Pjs.c; exports.useGlobalNotification = _chunkRHG74IMWjs.e; exports.useSession = _chunkRHG74IMWjs.c; exports.useSessionContext = _chunkRHG74IMWjs.g; exports.useUserData = _chunkLP5NJV2Pjs.a; exports.useUserProfile = _chunkRHG74IMWjs.j;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as U,b as L,c as v,d as O,e as h,f as k,g as A}from"./chunk-
|
|
1
|
+
import{a as U,b as L,c as v,d as O,e as h,f as k,g as A}from"./chunk-JYDCSNNQ.mjs";import{a as N,b,c as _,d as w}from"./chunk-Y72XFXMI.mjs";import{a as r,b as a,c as n,d as m,e as l,f as x,g as d,h as y,i as c,j as T}from"./chunk-MMYGRMGB.mjs";import{a as I,b as q}from"./chunk-T2CPA46I.mjs";import{a as S,b as P,c as R,d as g,e as E,f as C,g as D}from"./chunk-BJ6PIVZR.mjs";import{a as o,b as e,c as t,d as s,e as i,g as p,h as f,i as u}from"./chunk-HMJY3MMZ.mjs";import{default as J}from"@nocios/crudify-browser";export*from"@nocios/crudify-browser";export{U as CrudifyLogin,S as ERROR_CODES,P as ERROR_SEVERITY_MAP,m as GlobalNotificationProvider,k as LoginComponent,v as POLICY_ACTIONS,O as PREFERRED_POLICY_ORDER,h as Policies,y as ProtectedRoute,c as SessionDebugInfo,a as SessionManager,x as SessionProvider,A as SessionStatus,r as TokenStorage,L as UserProfileDisplay,i as createErrorTranslator,J as crudify,p as decodeJwtSafely,o as getCookie,f as getCurrentUserEmail,E as getErrorMessage,D as handleCrudifyError,u as isTokenExpired,R as parseApiError,C as parseJavaScriptError,g as parseTransactionError,q as secureLocalStorage,I as secureSessionStorage,s as translateError,e as translateErrorCode,t as translateErrorCodes,b as useAuth,w as useCrudifyWithNotifications,_ as useData,l as useGlobalNotification,n as useSession,d as useSessionContext,N as useUserData,T as useUserProfile};
|
package/dist/utils.d.mts
CHANGED
|
@@ -1,124 +1,55 @@
|
|
|
1
|
-
|
|
1
|
+
export { E as ERROR_CODES, j as ERROR_SEVERITY_MAP, k as ErrorCode, l as ErrorSeverity, q as ErrorTranslationConfig, P as ParsedError, o as createErrorTranslator, d as decodeJwtSafely, a as getCookie, g as getCurrentUserEmail, f as getErrorMessage, h as handleCrudifyError, i as isTokenExpired, p as parseApiError, e as parseJavaScriptError, c as parseTransactionError, b as secureLocalStorage, s as secureSessionStorage, n as translateError, t as translateErrorCode, m as translateErrorCodes } from './errorTranslation-DqdgLEUy.mjs';
|
|
2
|
+
import './api-Djqihi4n.mjs';
|
|
2
3
|
|
|
3
|
-
interface JWTPayload extends JwtPayload {
|
|
4
|
-
"cognito:username"?: string;
|
|
5
|
-
}
|
|
6
|
-
declare const decodeJwtSafely: (token: string) => JWTPayload | null;
|
|
7
|
-
declare const getCurrentUserEmail: () => string | null;
|
|
8
|
-
declare const isTokenExpired: (token: string) => boolean;
|
|
9
|
-
|
|
10
|
-
declare const getCookie: (name: string) => string | null;
|
|
11
|
-
|
|
12
|
-
declare class SecureStorage {
|
|
13
|
-
private readonly encryptionKey;
|
|
14
|
-
private readonly storage;
|
|
15
|
-
constructor(storageType?: "localStorage" | "sessionStorage");
|
|
16
|
-
private generateEncryptionKey;
|
|
17
|
-
setItem(key: string, value: string, expiryMinutes?: number): void;
|
|
18
|
-
getItem(key: string): string | null;
|
|
19
|
-
removeItem(key: string): void;
|
|
20
|
-
setToken(token: string): void;
|
|
21
|
-
getToken(): string | null;
|
|
22
|
-
}
|
|
23
|
-
declare const secureSessionStorage: SecureStorage;
|
|
24
|
-
declare const secureLocalStorage: SecureStorage;
|
|
25
|
-
|
|
26
|
-
declare const ERROR_CODES: {
|
|
27
|
-
readonly INVALID_CREDENTIALS: "INVALID_CREDENTIALS";
|
|
28
|
-
readonly UNAUTHORIZED: "UNAUTHORIZED";
|
|
29
|
-
readonly INVALID_API_KEY: "INVALID_API_KEY";
|
|
30
|
-
readonly USER_NOT_FOUND: "USER_NOT_FOUND";
|
|
31
|
-
readonly USER_NOT_ACTIVE: "USER_NOT_ACTIVE";
|
|
32
|
-
readonly NO_PERMISSION: "NO_PERMISSION";
|
|
33
|
-
readonly ITEM_NOT_FOUND: "ITEM_NOT_FOUND";
|
|
34
|
-
readonly NOT_FOUND: "NOT_FOUND";
|
|
35
|
-
readonly IN_USE: "IN_USE";
|
|
36
|
-
readonly FIELD_ERROR: "FIELD_ERROR";
|
|
37
|
-
readonly BAD_REQUEST: "BAD_REQUEST";
|
|
38
|
-
readonly INVALID_EMAIL: "INVALID_EMAIL";
|
|
39
|
-
readonly INVALID_CODE: "INVALID_CODE";
|
|
40
|
-
readonly INTERNAL_SERVER_ERROR: "INTERNAL_SERVER_ERROR";
|
|
41
|
-
readonly DATABASE_CONNECTION_ERROR: "DATABASE_CONNECTION_ERROR";
|
|
42
|
-
readonly INVALID_CONFIGURATION: "INVALID_CONFIGURATION";
|
|
43
|
-
readonly UNKNOWN_OPERATION: "UNKNOWN_OPERATION";
|
|
44
|
-
readonly TOO_MANY_REQUESTS: "TOO_MANY_REQUESTS";
|
|
45
|
-
readonly NETWORK_ERROR: "NETWORK_ERROR";
|
|
46
|
-
readonly TIMEOUT_ERROR: "TIMEOUT_ERROR";
|
|
47
|
-
};
|
|
48
|
-
type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];
|
|
49
|
-
type ErrorSeverity = "info" | "warning" | "error" | "critical";
|
|
50
|
-
declare const ERROR_SEVERITY_MAP: Record<ErrorCode, ErrorSeverity>;
|
|
51
|
-
interface ParsedError {
|
|
52
|
-
code: ErrorCode;
|
|
53
|
-
message: string;
|
|
54
|
-
severity: ErrorSeverity;
|
|
55
|
-
field?: string;
|
|
56
|
-
details?: Record<string, unknown>;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Parse a Crudify API response and extract standardized error information
|
|
60
|
-
*/
|
|
61
|
-
declare function parseApiError(response: unknown): ParsedError[];
|
|
62
|
-
/**
|
|
63
|
-
* Parse transaction response errors
|
|
64
|
-
*/
|
|
65
|
-
declare function parseTransactionError(response: unknown): ParsedError[];
|
|
66
|
-
/**
|
|
67
|
-
* Get a human-readable error message for an error code
|
|
68
|
-
*/
|
|
69
|
-
declare function getErrorMessage(code: ErrorCode): string;
|
|
70
|
-
/**
|
|
71
|
-
* Handle JavaScript/Network errors and convert to ParsedError
|
|
72
|
-
*/
|
|
73
|
-
declare function parseJavaScriptError(error: unknown): ParsedError;
|
|
74
4
|
/**
|
|
75
|
-
*
|
|
5
|
+
* Event Bus para coordinar acciones de autenticación
|
|
6
|
+
* Previene race conditions y asegura respuesta única a errores
|
|
7
|
+
*
|
|
8
|
+
* Uso:
|
|
9
|
+
* - Emitir eventos cuando hay errores de autenticación
|
|
10
|
+
* - Suscribirse para recibir notificaciones de eventos
|
|
11
|
+
* - Debounce automático para evitar múltiples disparos
|
|
76
12
|
*/
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Utilidad robusta para traducir códigos de error con fallbacks inteligentes
|
|
81
|
-
* Busca en múltiples namespaces y devuelve la traducción más específica disponible
|
|
82
|
-
*/
|
|
83
|
-
interface ErrorTranslationConfig {
|
|
84
|
-
/** Función de traducción de i18next */
|
|
85
|
-
translateFn: (key: string) => string;
|
|
86
|
-
/** Idioma actual (opcional, para logging) */
|
|
87
|
-
currentLanguage?: string;
|
|
88
|
-
/** Habilitar logs de debug */
|
|
89
|
-
enableDebug?: boolean;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Traduce un código de error usando jerarquía de fallbacks
|
|
93
|
-
*/
|
|
94
|
-
declare function translateErrorCode(errorCode: string, config: ErrorTranslationConfig): string;
|
|
95
|
-
/**
|
|
96
|
-
* Traduce múltiples códigos de error
|
|
97
|
-
*/
|
|
98
|
-
declare function translateErrorCodes(errorCodes: string[], config: ErrorTranslationConfig): string[];
|
|
99
|
-
/**
|
|
100
|
-
* Traduce un error completo (código + mensaje personalizado)
|
|
101
|
-
*/
|
|
102
|
-
declare function translateError(error: {
|
|
103
|
-
code: string;
|
|
13
|
+
type AuthEventType = "SESSION_EXPIRED" | "TOKEN_REFRESH_FAILED" | "UNAUTHORIZED";
|
|
14
|
+
type AuthEventDetails = {
|
|
104
15
|
message?: string;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
enableDebug?: boolean;
|
|
113
|
-
}): {
|
|
114
|
-
translateErrorCode: (code: string) => string;
|
|
115
|
-
translateErrorCodes: (codes: string[]) => string[];
|
|
116
|
-
translateError: (error: {
|
|
117
|
-
code: string;
|
|
118
|
-
message?: string;
|
|
119
|
-
field?: string;
|
|
120
|
-
}) => string;
|
|
121
|
-
translateApiError: (apiResponse: any) => string;
|
|
16
|
+
error?: any;
|
|
17
|
+
source?: string;
|
|
18
|
+
};
|
|
19
|
+
type AuthEvent = {
|
|
20
|
+
type: AuthEventType;
|
|
21
|
+
details?: AuthEventDetails;
|
|
22
|
+
timestamp: number;
|
|
122
23
|
};
|
|
24
|
+
type AuthEventListener = (event: AuthEvent) => void;
|
|
25
|
+
declare class AuthEventBus {
|
|
26
|
+
private static instance;
|
|
27
|
+
private listeners;
|
|
28
|
+
private isHandlingAuthError;
|
|
29
|
+
private lastErrorTime;
|
|
30
|
+
private lastEventType;
|
|
31
|
+
private readonly DEBOUNCE_TIME;
|
|
32
|
+
private constructor();
|
|
33
|
+
static getInstance(): AuthEventBus;
|
|
34
|
+
/**
|
|
35
|
+
* Emitir evento de error de autenticación
|
|
36
|
+
* Con debounce para evitar múltiples disparos
|
|
37
|
+
*/
|
|
38
|
+
emit(type: AuthEventType, details?: AuthEventDetails): void;
|
|
39
|
+
/**
|
|
40
|
+
* Suscribirse a eventos de autenticación
|
|
41
|
+
* @returns Función de cleanup para desuscribirse
|
|
42
|
+
*/
|
|
43
|
+
subscribe(listener: AuthEventListener): () => void;
|
|
44
|
+
/**
|
|
45
|
+
* Limpiar todos los listeners
|
|
46
|
+
*/
|
|
47
|
+
clear(): void;
|
|
48
|
+
/**
|
|
49
|
+
* Verificar si hay un evento siendo manejado
|
|
50
|
+
*/
|
|
51
|
+
isHandling(): boolean;
|
|
52
|
+
}
|
|
53
|
+
declare const authEventBus: AuthEventBus;
|
|
123
54
|
|
|
124
|
-
export {
|
|
55
|
+
export { type AuthEvent, type AuthEventDetails, type AuthEventType, authEventBus };
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,124 +1,55 @@
|
|
|
1
|
-
|
|
1
|
+
export { E as ERROR_CODES, j as ERROR_SEVERITY_MAP, k as ErrorCode, l as ErrorSeverity, q as ErrorTranslationConfig, P as ParsedError, o as createErrorTranslator, d as decodeJwtSafely, a as getCookie, g as getCurrentUserEmail, f as getErrorMessage, h as handleCrudifyError, i as isTokenExpired, p as parseApiError, e as parseJavaScriptError, c as parseTransactionError, b as secureLocalStorage, s as secureSessionStorage, n as translateError, t as translateErrorCode, m as translateErrorCodes } from './errorTranslation-CBbQYNWR.js';
|
|
2
|
+
import './api-Djqihi4n.js';
|
|
2
3
|
|
|
3
|
-
interface JWTPayload extends JwtPayload {
|
|
4
|
-
"cognito:username"?: string;
|
|
5
|
-
}
|
|
6
|
-
declare const decodeJwtSafely: (token: string) => JWTPayload | null;
|
|
7
|
-
declare const getCurrentUserEmail: () => string | null;
|
|
8
|
-
declare const isTokenExpired: (token: string) => boolean;
|
|
9
|
-
|
|
10
|
-
declare const getCookie: (name: string) => string | null;
|
|
11
|
-
|
|
12
|
-
declare class SecureStorage {
|
|
13
|
-
private readonly encryptionKey;
|
|
14
|
-
private readonly storage;
|
|
15
|
-
constructor(storageType?: "localStorage" | "sessionStorage");
|
|
16
|
-
private generateEncryptionKey;
|
|
17
|
-
setItem(key: string, value: string, expiryMinutes?: number): void;
|
|
18
|
-
getItem(key: string): string | null;
|
|
19
|
-
removeItem(key: string): void;
|
|
20
|
-
setToken(token: string): void;
|
|
21
|
-
getToken(): string | null;
|
|
22
|
-
}
|
|
23
|
-
declare const secureSessionStorage: SecureStorage;
|
|
24
|
-
declare const secureLocalStorage: SecureStorage;
|
|
25
|
-
|
|
26
|
-
declare const ERROR_CODES: {
|
|
27
|
-
readonly INVALID_CREDENTIALS: "INVALID_CREDENTIALS";
|
|
28
|
-
readonly UNAUTHORIZED: "UNAUTHORIZED";
|
|
29
|
-
readonly INVALID_API_KEY: "INVALID_API_KEY";
|
|
30
|
-
readonly USER_NOT_FOUND: "USER_NOT_FOUND";
|
|
31
|
-
readonly USER_NOT_ACTIVE: "USER_NOT_ACTIVE";
|
|
32
|
-
readonly NO_PERMISSION: "NO_PERMISSION";
|
|
33
|
-
readonly ITEM_NOT_FOUND: "ITEM_NOT_FOUND";
|
|
34
|
-
readonly NOT_FOUND: "NOT_FOUND";
|
|
35
|
-
readonly IN_USE: "IN_USE";
|
|
36
|
-
readonly FIELD_ERROR: "FIELD_ERROR";
|
|
37
|
-
readonly BAD_REQUEST: "BAD_REQUEST";
|
|
38
|
-
readonly INVALID_EMAIL: "INVALID_EMAIL";
|
|
39
|
-
readonly INVALID_CODE: "INVALID_CODE";
|
|
40
|
-
readonly INTERNAL_SERVER_ERROR: "INTERNAL_SERVER_ERROR";
|
|
41
|
-
readonly DATABASE_CONNECTION_ERROR: "DATABASE_CONNECTION_ERROR";
|
|
42
|
-
readonly INVALID_CONFIGURATION: "INVALID_CONFIGURATION";
|
|
43
|
-
readonly UNKNOWN_OPERATION: "UNKNOWN_OPERATION";
|
|
44
|
-
readonly TOO_MANY_REQUESTS: "TOO_MANY_REQUESTS";
|
|
45
|
-
readonly NETWORK_ERROR: "NETWORK_ERROR";
|
|
46
|
-
readonly TIMEOUT_ERROR: "TIMEOUT_ERROR";
|
|
47
|
-
};
|
|
48
|
-
type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];
|
|
49
|
-
type ErrorSeverity = "info" | "warning" | "error" | "critical";
|
|
50
|
-
declare const ERROR_SEVERITY_MAP: Record<ErrorCode, ErrorSeverity>;
|
|
51
|
-
interface ParsedError {
|
|
52
|
-
code: ErrorCode;
|
|
53
|
-
message: string;
|
|
54
|
-
severity: ErrorSeverity;
|
|
55
|
-
field?: string;
|
|
56
|
-
details?: Record<string, unknown>;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Parse a Crudify API response and extract standardized error information
|
|
60
|
-
*/
|
|
61
|
-
declare function parseApiError(response: unknown): ParsedError[];
|
|
62
|
-
/**
|
|
63
|
-
* Parse transaction response errors
|
|
64
|
-
*/
|
|
65
|
-
declare function parseTransactionError(response: unknown): ParsedError[];
|
|
66
|
-
/**
|
|
67
|
-
* Get a human-readable error message for an error code
|
|
68
|
-
*/
|
|
69
|
-
declare function getErrorMessage(code: ErrorCode): string;
|
|
70
|
-
/**
|
|
71
|
-
* Handle JavaScript/Network errors and convert to ParsedError
|
|
72
|
-
*/
|
|
73
|
-
declare function parseJavaScriptError(error: unknown): ParsedError;
|
|
74
4
|
/**
|
|
75
|
-
*
|
|
5
|
+
* Event Bus para coordinar acciones de autenticación
|
|
6
|
+
* Previene race conditions y asegura respuesta única a errores
|
|
7
|
+
*
|
|
8
|
+
* Uso:
|
|
9
|
+
* - Emitir eventos cuando hay errores de autenticación
|
|
10
|
+
* - Suscribirse para recibir notificaciones de eventos
|
|
11
|
+
* - Debounce automático para evitar múltiples disparos
|
|
76
12
|
*/
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Utilidad robusta para traducir códigos de error con fallbacks inteligentes
|
|
81
|
-
* Busca en múltiples namespaces y devuelve la traducción más específica disponible
|
|
82
|
-
*/
|
|
83
|
-
interface ErrorTranslationConfig {
|
|
84
|
-
/** Función de traducción de i18next */
|
|
85
|
-
translateFn: (key: string) => string;
|
|
86
|
-
/** Idioma actual (opcional, para logging) */
|
|
87
|
-
currentLanguage?: string;
|
|
88
|
-
/** Habilitar logs de debug */
|
|
89
|
-
enableDebug?: boolean;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Traduce un código de error usando jerarquía de fallbacks
|
|
93
|
-
*/
|
|
94
|
-
declare function translateErrorCode(errorCode: string, config: ErrorTranslationConfig): string;
|
|
95
|
-
/**
|
|
96
|
-
* Traduce múltiples códigos de error
|
|
97
|
-
*/
|
|
98
|
-
declare function translateErrorCodes(errorCodes: string[], config: ErrorTranslationConfig): string[];
|
|
99
|
-
/**
|
|
100
|
-
* Traduce un error completo (código + mensaje personalizado)
|
|
101
|
-
*/
|
|
102
|
-
declare function translateError(error: {
|
|
103
|
-
code: string;
|
|
13
|
+
type AuthEventType = "SESSION_EXPIRED" | "TOKEN_REFRESH_FAILED" | "UNAUTHORIZED";
|
|
14
|
+
type AuthEventDetails = {
|
|
104
15
|
message?: string;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
enableDebug?: boolean;
|
|
113
|
-
}): {
|
|
114
|
-
translateErrorCode: (code: string) => string;
|
|
115
|
-
translateErrorCodes: (codes: string[]) => string[];
|
|
116
|
-
translateError: (error: {
|
|
117
|
-
code: string;
|
|
118
|
-
message?: string;
|
|
119
|
-
field?: string;
|
|
120
|
-
}) => string;
|
|
121
|
-
translateApiError: (apiResponse: any) => string;
|
|
16
|
+
error?: any;
|
|
17
|
+
source?: string;
|
|
18
|
+
};
|
|
19
|
+
type AuthEvent = {
|
|
20
|
+
type: AuthEventType;
|
|
21
|
+
details?: AuthEventDetails;
|
|
22
|
+
timestamp: number;
|
|
122
23
|
};
|
|
24
|
+
type AuthEventListener = (event: AuthEvent) => void;
|
|
25
|
+
declare class AuthEventBus {
|
|
26
|
+
private static instance;
|
|
27
|
+
private listeners;
|
|
28
|
+
private isHandlingAuthError;
|
|
29
|
+
private lastErrorTime;
|
|
30
|
+
private lastEventType;
|
|
31
|
+
private readonly DEBOUNCE_TIME;
|
|
32
|
+
private constructor();
|
|
33
|
+
static getInstance(): AuthEventBus;
|
|
34
|
+
/**
|
|
35
|
+
* Emitir evento de error de autenticación
|
|
36
|
+
* Con debounce para evitar múltiples disparos
|
|
37
|
+
*/
|
|
38
|
+
emit(type: AuthEventType, details?: AuthEventDetails): void;
|
|
39
|
+
/**
|
|
40
|
+
* Suscribirse a eventos de autenticación
|
|
41
|
+
* @returns Función de cleanup para desuscribirse
|
|
42
|
+
*/
|
|
43
|
+
subscribe(listener: AuthEventListener): () => void;
|
|
44
|
+
/**
|
|
45
|
+
* Limpiar todos los listeners
|
|
46
|
+
*/
|
|
47
|
+
clear(): void;
|
|
48
|
+
/**
|
|
49
|
+
* Verificar si hay un evento siendo manejado
|
|
50
|
+
*/
|
|
51
|
+
isHandling(): boolean;
|
|
52
|
+
}
|
|
53
|
+
declare const authEventBus: AuthEventBus;
|
|
123
54
|
|
|
124
|
-
export {
|
|
55
|
+
export { type AuthEvent, type AuthEventDetails, type AuthEventType, authEventBus };
|
package/dist/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkNNY4A73Vjs = require('./chunk-NNY4A73V.js');var _chunkYIIUEOXCjs = require('./chunk-YIIUEOXC.js');var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkNNY4A73Vjs = require('./chunk-NNY4A73V.js');var _chunkYIIUEOXCjs = require('./chunk-YIIUEOXC.js');var _chunkATAGEVFKjs = require('./chunk-ATAGEVFK.js');exports.ERROR_CODES = _chunkYIIUEOXCjs.a; exports.ERROR_SEVERITY_MAP = _chunkYIIUEOXCjs.b; exports.authEventBus = _chunkATAGEVFKjs.f; exports.createErrorTranslator = _chunkATAGEVFKjs.e; exports.decodeJwtSafely = _chunkATAGEVFKjs.g; exports.getCookie = _chunkATAGEVFKjs.a; exports.getCurrentUserEmail = _chunkATAGEVFKjs.h; exports.getErrorMessage = _chunkYIIUEOXCjs.e; exports.handleCrudifyError = _chunkYIIUEOXCjs.g; exports.isTokenExpired = _chunkATAGEVFKjs.i; exports.parseApiError = _chunkYIIUEOXCjs.c; exports.parseJavaScriptError = _chunkYIIUEOXCjs.f; exports.parseTransactionError = _chunkYIIUEOXCjs.d; exports.secureLocalStorage = _chunkNNY4A73Vjs.b; exports.secureSessionStorage = _chunkNNY4A73Vjs.a; exports.translateError = _chunkATAGEVFKjs.d; exports.translateErrorCode = _chunkATAGEVFKjs.b; exports.translateErrorCodes = _chunkATAGEVFKjs.c;
|
package/dist/utils.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as C,b as S}from"./chunk-T2CPA46I.mjs";import{a as
|
|
1
|
+
import{a as C,b as S}from"./chunk-T2CPA46I.mjs";import{a as i,b as f,c as l,d as u,e as d,f as m,g as x}from"./chunk-BJ6PIVZR.mjs";import{a as r,b as e,c as o,d as t,e as a,f as E,g as s,h as n,i as p}from"./chunk-HMJY3MMZ.mjs";export{i as ERROR_CODES,f as ERROR_SEVERITY_MAP,E as authEventBus,a as createErrorTranslator,s as decodeJwtSafely,r as getCookie,n as getCurrentUserEmail,d as getErrorMessage,x as handleCrudifyError,p as isTokenExpired,l as parseApiError,m as parseJavaScriptError,u as parseTransactionError,S as secureLocalStorage,C as secureSessionStorage,t as translateError,e as translateErrorCode,o as translateErrorCodes};
|