@nocios/crudify-ui 5.0.22 → 5.0.26
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/coverage/coverage-final.json +47 -6
- package/coverage/index.html +257 -92
- package/dist/chunk-4AEUOTN2.js +1 -0
- package/dist/{chunk-46CKGJCC.js → chunk-4R472VF6.js} +1 -1
- package/dist/{chunk-6LMZ3PZW.js → chunk-BBA4D4JY.js} +1 -1
- package/dist/{chunk-5GGDNAMR.mjs → chunk-I2GWDIIJ.mjs} +1 -1
- package/dist/{chunk-LZTU56BB.mjs → chunk-WVEMQ7DL.mjs} +1 -1
- package/dist/chunk-Z2GYZNAL.mjs +1 -0
- package/dist/components.js +1 -1
- package/dist/components.mjs +1 -1
- 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-SS8n9MbX.d.mts → index-8iJiQ3bI.d.mts} +43 -30
- package/dist/{index-Dp5wNqtm.d.ts → index-BaP3eAZd.d.ts} +43 -30
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/vitest.config.ts +1 -1
- package/coverage/components/CrudiaAutoGenerate.tsx.html +0 -583
- package/coverage/components/CrudiaFileField.tsx.html +0 -3754
- package/coverage/components/CrudiaMarkdownField.tsx.html +0 -619
- package/coverage/components/CrudifyInitializer.tsx.html +0 -676
- package/coverage/components/CrudifyLogin/context/I18nProvider.tsx.html +0 -397
- package/coverage/components/CrudifyLogin/context/LoginStateProvider.tsx.html +0 -1258
- package/coverage/components/CrudifyLogin/context/index.html +0 -131
- package/coverage/components/CrudifyLogin/hooks/index.html +0 -131
- package/coverage/components/CrudifyLogin/hooks/useCrudifyLogin.ts.html +0 -391
- package/coverage/components/CrudifyLogin/hooks/useTranslationsFromUrl.ts.html +0 -292
- package/coverage/components/CrudifyLogin/utils/cookies.ts.html +0 -97
- package/coverage/components/CrudifyLogin/utils/index.html +0 -131
- package/coverage/components/CrudifyLogin/utils/secureStorage.ts.html +0 -847
- package/coverage/components/GlobalNotificationProvider.tsx.html +0 -781
- package/coverage/components/PublicPolicies/constants.ts.html +0 -127
- package/coverage/components/PublicPolicies/index.html +0 -116
- package/coverage/components/Routing/AuthRoute.tsx.html +0 -235
- package/coverage/components/Routing/ProtectedRoute.tsx.html +0 -334
- package/coverage/components/Routing/index.html +0 -131
- package/coverage/components/SessionLoadingScreen/index.html +0 -116
- package/coverage/components/SessionLoadingScreen/index.tsx.html +0 -388
- package/coverage/components/SessionTimeIndicator/index.html +0 -116
- package/coverage/components/SessionTimeIndicator/index.tsx.html +0 -505
- package/coverage/components/index.html +0 -176
- package/coverage/core/CrudifyInitializationManager.ts.html +0 -1132
- package/coverage/core/SessionManager.ts.html +0 -2341
- package/coverage/core/index.html +0 -131
- package/coverage/hooks/index.html +0 -131
- package/coverage/hooks/useAutoGenerate.ts.html +0 -562
- package/coverage/hooks/useFileUpload.ts.html +0 -3088
- package/coverage/providers/CrudifyThemeProvider.tsx.html +0 -289
- package/coverage/providers/TranslationsProvider.tsx.html +0 -1450
- package/coverage/providers/index.html +0 -131
- package/coverage/services/credentialsEventBus.ts.html +0 -310
- package/coverage/services/crudifyAdminWrapper.ts.html +0 -745
- package/coverage/services/index.html +0 -146
- package/coverage/services/translationService.ts.html +0 -1318
- package/coverage/translations/critical.ts.html +0 -1012
- package/coverage/translations/index.html +0 -116
- package/coverage/utils/authErrorDetector.ts.html +0 -631
- package/coverage/utils/authEventBus.ts.html +0 -445
- package/coverage/utils/configResolver.ts.html +0 -661
- package/coverage/utils/errorHandler.ts.html +0 -1264
- package/coverage/utils/errorTranslation.ts.html +0 -862
- package/coverage/utils/index.html +0 -266
- package/coverage/utils/jwtUtils.ts.html +0 -301
- package/coverage/utils/logger.ts.html +0 -910
- package/coverage/utils/navigationTracker.ts.html +0 -565
- package/coverage/utils/redirectSecurity.ts.html +0 -490
- package/coverage/utils/tokenStorage.ts.html +0 -1438
- package/coverage/utils/webCrypto.ts.html +0 -472
- package/dist/chunk-IKYHYKJB.js +0 -1
- package/dist/chunk-NAAOS7YG.mjs +0 -1
package/dist/components.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk4R472VF6js = require('./chunk-4R472VF6.js');var _chunk4AEUOTN2js = require('./chunk-4AEUOTN2.js');require('./chunk-NSV6ECYO.js');require('./chunk-MFYHD6S5.js');var _react = require('react');var _jsxruntime = require('react/jsx-runtime');function z({showBelowMinutes:f=5,position:m="bottom-right",colorNormal:c="#ed6c02",colorCritical:x="#d32f2f",style:u,className:g}={}){let{isAuthenticated:o,tokens:t}=_chunk4AEUOTN2js.c.call(void 0, ),[i,y]=_react.useState.call(void 0, 0),[h,C]=_react.useState.call(void 0, 100);if(_react.useEffect.call(void 0, ()=>{if(!o||!t)return;let v=setInterval(()=>{let P=Date.now(),p=t.expiresAt-P,w=900*1e3;y(Math.max(0,p)),C(Math.max(0,p/w*100))},1e3);return()=>clearInterval(v)},[o,t]),!o||i<=0)return null;let e=Math.floor(i/6e4),S=Math.floor(i%6e4/1e3);if(e>=f)return null;let s=e<2,a=s?x:c,b={"top-left":{top:"16px",left:"16px"},"top-right":{top:"16px",right:"16px"},"bottom-left":{bottom:"16px",left:"16px"},"bottom-right":{bottom:"16px",right:"16px"}}[m];return _jsxruntime.jsxs.call(void 0, "div",{className:g,style:{position:"fixed",...b,padding:"12px 16px",backgroundColor:"white",borderRadius:"8px",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",minWidth:"200px",zIndex:9999,fontFamily:"system-ui, -apple-system, sans-serif",...u},children:[_jsxruntime.jsxs.call(void 0, "div",{style:{marginBottom:"8px"},children:[_jsxruntime.jsx.call(void 0, "div",{style:{fontSize:"12px",fontWeight:600,color:a,marginBottom:"4px"},children:s?"\u26A0\uFE0F Sesi\xF3n expirando":"\u23F0 Sesi\xF3n por expirar"}),_jsxruntime.jsxs.call(void 0, "div",{style:{fontSize:"14px",color:"#333",fontWeight:500},children:[e,":",S.toString().padStart(2,"0")]})]}),_jsxruntime.jsx.call(void 0, "div",{style:{width:"100%",height:"6px",backgroundColor:"#e0e0e0",borderRadius:"3px",overflow:"hidden"},children:_jsxruntime.jsx.call(void 0, "div",{style:{width:`${h}%`,height:"100%",backgroundColor:a,transition:"width 1s linear"}})})]})}exports.CrudiaAutoGenerate = _chunk4R472VF6js.o; exports.CrudiaFileField = _chunk4R472VF6js.p; exports.CrudiaMarkdownField = _chunk4R472VF6js.q; exports.CrudifyLogin = _chunk4R472VF6js.h; exports.GlobalNotificationProvider = _chunk4AEUOTN2js.d; exports.LoginComponent = _chunk4R472VF6js.m; exports.Policies = _chunk4R472VF6js.l; exports.SessionStatus = _chunk4R472VF6js.n; exports.SessionTimeIndicator = z; exports.UserProfileDisplay = _chunk4R472VF6js.i; exports.useGlobalNotification = _chunk4AEUOTN2js.e;
|
package/dist/components.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as N,i as T,l as M,m as k,n as G,o as L,p as A,q as R}from"./chunk-
|
|
1
|
+
import{h as N,i as T,l as M,m as k,n as G,o as L,p as A,q as R}from"./chunk-WVEMQ7DL.mjs";import{c as d,d as F,e as I}from"./chunk-Z2GYZNAL.mjs";import"./chunk-JAPL7EZJ.mjs";import"./chunk-MGJZTOEM.mjs";import{useEffect as B,useState as l}from"react";import{jsx as r,jsxs as n}from"react/jsx-runtime";function z({showBelowMinutes:f=5,position:m="bottom-right",colorNormal:c="#ed6c02",colorCritical:x="#d32f2f",style:u,className:g}={}){let{isAuthenticated:o,tokens:t}=d(),[i,y]=l(0),[h,C]=l(100);if(B(()=>{if(!o||!t)return;let v=setInterval(()=>{let P=Date.now(),p=t.expiresAt-P,w=900*1e3;y(Math.max(0,p)),C(Math.max(0,p/w*100))},1e3);return()=>clearInterval(v)},[o,t]),!o||i<=0)return null;let e=Math.floor(i/6e4),S=Math.floor(i%6e4/1e3);if(e>=f)return null;let s=e<2,a=s?x:c,b={"top-left":{top:"16px",left:"16px"},"top-right":{top:"16px",right:"16px"},"bottom-left":{bottom:"16px",left:"16px"},"bottom-right":{bottom:"16px",right:"16px"}}[m];return n("div",{className:g,style:{position:"fixed",...b,padding:"12px 16px",backgroundColor:"white",borderRadius:"8px",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",minWidth:"200px",zIndex:9999,fontFamily:"system-ui, -apple-system, sans-serif",...u},children:[n("div",{style:{marginBottom:"8px"},children:[r("div",{style:{fontSize:"12px",fontWeight:600,color:a,marginBottom:"4px"},children:s?"\u26A0\uFE0F Sesi\xF3n expirando":"\u23F0 Sesi\xF3n por expirar"}),n("div",{style:{fontSize:"14px",color:"#333",fontWeight:500},children:[e,":",S.toString().padStart(2,"0")]})]}),r("div",{style:{width:"100%",height:"6px",backgroundColor:"#e0e0e0",borderRadius:"3px",overflow:"hidden"},children:r("div",{style:{width:`${h}%`,height:"100%",backgroundColor:a,transition:"width 1s linear"}})})]})}export{L as CrudiaAutoGenerate,A as CrudiaFileField,R as CrudiaMarkdownField,N as CrudifyLogin,F as GlobalNotificationProvider,k as LoginComponent,M as Policies,G as SessionStatus,z as SessionTimeIndicator,T as UserProfileDisplay,I as useGlobalNotification};
|
package/dist/hooks.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { F as FileItem, v as FileStatus, d as SessionState, n as UseAuthReturn, p as UseDataReturn, s as UseFileUploadOptions, t as UseFileUploadReturn, U as UseSessionOptions, k as UseUserDataOptions, j as UseUserDataReturn, l as UserData, m as useAuth, w as useCrudifyWithNotifications, o as useData, r as useFileUpload, u as useSession, i as useUserData, q as useUserProfile } from './index-
|
|
1
|
+
export { F as FileItem, v as FileStatus, d as SessionState, n as UseAuthReturn, p as UseDataReturn, s as UseFileUploadOptions, t as UseFileUploadReturn, U as UseSessionOptions, k as UseUserDataOptions, j as UseUserDataReturn, l as UserData, m as useAuth, w as useCrudifyWithNotifications, o as useData, r as useFileUpload, u as useSession, i as useUserData, q as useUserProfile } from './index-8iJiQ3bI.mjs';
|
|
2
2
|
export { A as AutoGenerateConfig, d as UseAutoGenerateOptions, U as UseAutoGenerateReturn, c as useAutoGenerate } from './GlobalNotificationProvider-Zq18OkpI.mjs';
|
|
3
3
|
import './api-B4uXiHF0.mjs';
|
|
4
4
|
import 'react/jsx-runtime';
|
package/dist/hooks.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { F as FileItem, v as FileStatus, d as SessionState, n as UseAuthReturn, p as UseDataReturn, s as UseFileUploadOptions, t as UseFileUploadReturn, U as UseSessionOptions, k as UseUserDataOptions, j as UseUserDataReturn, l as UserData, m as useAuth, w as useCrudifyWithNotifications, o as useData, r as useFileUpload, u as useSession, i as useUserData, q as useUserProfile } from './index-
|
|
1
|
+
export { F as FileItem, v as FileStatus, d as SessionState, n as UseAuthReturn, p as UseDataReturn, s as UseFileUploadOptions, t as UseFileUploadReturn, U as UseSessionOptions, k as UseUserDataOptions, j as UseUserDataReturn, l as UserData, m as useAuth, w as useCrudifyWithNotifications, o as useData, r as useFileUpload, u as useSession, i as useUserData, q as useUserProfile } from './index-BaP3eAZd.js';
|
|
2
2
|
export { A as AutoGenerateConfig, d as UseAutoGenerateOptions, U as UseAutoGenerateReturn, c as useAutoGenerate } from './GlobalNotificationProvider-Zq18OkpI.js';
|
|
3
3
|
import './api-B4uXiHF0.js';
|
|
4
4
|
import 'react/jsx-runtime';
|
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 _chunkBBA4D4JYjs = require('./chunk-BBA4D4JY.js');var _chunk4AEUOTN2js = require('./chunk-4AEUOTN2.js');require('./chunk-MFYHD6S5.js');exports.useAuth = _chunkBBA4D4JYjs.b; exports.useAutoGenerate = _chunk4AEUOTN2js.m; exports.useCrudifyWithNotifications = _chunkBBA4D4JYjs.d; exports.useData = _chunkBBA4D4JYjs.c; exports.useFileUpload = _chunk4AEUOTN2js.p; exports.useSession = _chunk4AEUOTN2js.c; exports.useUserData = _chunkBBA4D4JYjs.a; exports.useUserProfile = _chunk4AEUOTN2js.l;
|
package/dist/hooks.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s,b as
|
|
1
|
+
import{a as s,b as p,c as u,d as a}from"./chunk-I2GWDIIJ.mjs";import{c as e,l as t,m as o,p as r}from"./chunk-Z2GYZNAL.mjs";import"./chunk-MGJZTOEM.mjs";export{p as useAuth,o as useAutoGenerate,a as useCrudifyWithNotifications,u as useData,r as useFileUpload,e as useSession,s as useUserData,t as useUserProfile};
|
|
@@ -269,6 +269,13 @@ declare class SessionManager {
|
|
|
269
269
|
private formatError;
|
|
270
270
|
}
|
|
271
271
|
|
|
272
|
+
/**
|
|
273
|
+
* Tipos e interfaces para el hook useSession
|
|
274
|
+
*/
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Estado del hook useSession
|
|
278
|
+
*/
|
|
272
279
|
type SessionState = {
|
|
273
280
|
isAuthenticated: boolean;
|
|
274
281
|
isLoading: boolean;
|
|
@@ -277,6 +284,9 @@ type SessionState = {
|
|
|
277
284
|
tokens: TokenData | null;
|
|
278
285
|
error: string | null;
|
|
279
286
|
};
|
|
287
|
+
/**
|
|
288
|
+
* Opciones de configuración para useSession
|
|
289
|
+
*/
|
|
280
290
|
type UseSessionOptions = {
|
|
281
291
|
autoRestore?: boolean;
|
|
282
292
|
enableLogging?: boolean;
|
|
@@ -289,45 +299,48 @@ type UseSessionOptions = {
|
|
|
289
299
|
publicApiKey?: string;
|
|
290
300
|
env?: "dev" | "stg" | "api" | "prod";
|
|
291
301
|
};
|
|
292
|
-
|
|
302
|
+
/**
|
|
303
|
+
* Retorno completo del hook useSession
|
|
304
|
+
*/
|
|
305
|
+
type UseSessionReturn = SessionState & {
|
|
293
306
|
login: (email: string, password: string) => Promise<LoginResult>;
|
|
294
307
|
logout: () => Promise<void>;
|
|
295
308
|
refreshTokens: () => Promise<boolean>;
|
|
296
309
|
clearError: () => void;
|
|
297
|
-
getTokenInfo: () => Promise<
|
|
298
|
-
isLoggedIn: boolean;
|
|
299
|
-
crudifyTokens: {
|
|
300
|
-
accessToken: string;
|
|
301
|
-
refreshToken: string;
|
|
302
|
-
expiresAt: number;
|
|
303
|
-
refreshExpiresAt: number;
|
|
304
|
-
isExpired: boolean;
|
|
305
|
-
isRefreshExpired: boolean;
|
|
306
|
-
isValid: boolean;
|
|
307
|
-
expiresIn: number;
|
|
308
|
-
willExpireSoon: boolean;
|
|
309
|
-
};
|
|
310
|
-
storageInfo: {
|
|
311
|
-
accessExpired: boolean;
|
|
312
|
-
refreshExpired: boolean;
|
|
313
|
-
accessExpiresIn: number;
|
|
314
|
-
refreshExpiresIn: number;
|
|
315
|
-
} | null;
|
|
316
|
-
hasValidTokens: boolean;
|
|
317
|
-
apiEndpointAdmin: string | undefined;
|
|
318
|
-
apiKeyEndpointAdmin: string | undefined;
|
|
319
|
-
}>;
|
|
310
|
+
getTokenInfo: () => Promise<TokenInfoResult>;
|
|
320
311
|
updateActivity: () => void;
|
|
321
312
|
isExpiringSoon: boolean;
|
|
322
313
|
expiresIn: number;
|
|
323
314
|
refreshExpiresIn: number;
|
|
324
|
-
isAuthenticated: boolean;
|
|
325
|
-
isLoading: boolean;
|
|
326
|
-
isLoggingOut: boolean;
|
|
327
|
-
isInitialized: boolean;
|
|
328
|
-
tokens: TokenData | null;
|
|
329
|
-
error: string | null;
|
|
330
315
|
};
|
|
316
|
+
/**
|
|
317
|
+
* Resultado de getTokenInfo
|
|
318
|
+
*/
|
|
319
|
+
type TokenInfoResult = {
|
|
320
|
+
crudifyTokens: {
|
|
321
|
+
accessToken: string | null;
|
|
322
|
+
refreshToken: string | null;
|
|
323
|
+
expiresAt: number;
|
|
324
|
+
refreshExpiresAt: number;
|
|
325
|
+
expiresIn: number;
|
|
326
|
+
};
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Hook de React para manejo de sesiones con Refresh Token Pattern
|
|
331
|
+
* Proporciona una API simple para manejar autenticación en componentes React
|
|
332
|
+
*
|
|
333
|
+
* @param options - Opciones de configuración del hook
|
|
334
|
+
* @returns Estado de sesión y funciones de control
|
|
335
|
+
*
|
|
336
|
+
* @example
|
|
337
|
+
* ```tsx
|
|
338
|
+
* const { isAuthenticated, login, logout } = useSession({
|
|
339
|
+
* onSessionExpired: () => navigate('/login')
|
|
340
|
+
* });
|
|
341
|
+
* ```
|
|
342
|
+
*/
|
|
343
|
+
declare function useSession(options?: UseSessionOptions): UseSessionReturn;
|
|
331
344
|
|
|
332
345
|
type SessionData = {
|
|
333
346
|
_id: string;
|
|
@@ -269,6 +269,13 @@ declare class SessionManager {
|
|
|
269
269
|
private formatError;
|
|
270
270
|
}
|
|
271
271
|
|
|
272
|
+
/**
|
|
273
|
+
* Tipos e interfaces para el hook useSession
|
|
274
|
+
*/
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Estado del hook useSession
|
|
278
|
+
*/
|
|
272
279
|
type SessionState = {
|
|
273
280
|
isAuthenticated: boolean;
|
|
274
281
|
isLoading: boolean;
|
|
@@ -277,6 +284,9 @@ type SessionState = {
|
|
|
277
284
|
tokens: TokenData | null;
|
|
278
285
|
error: string | null;
|
|
279
286
|
};
|
|
287
|
+
/**
|
|
288
|
+
* Opciones de configuración para useSession
|
|
289
|
+
*/
|
|
280
290
|
type UseSessionOptions = {
|
|
281
291
|
autoRestore?: boolean;
|
|
282
292
|
enableLogging?: boolean;
|
|
@@ -289,45 +299,48 @@ type UseSessionOptions = {
|
|
|
289
299
|
publicApiKey?: string;
|
|
290
300
|
env?: "dev" | "stg" | "api" | "prod";
|
|
291
301
|
};
|
|
292
|
-
|
|
302
|
+
/**
|
|
303
|
+
* Retorno completo del hook useSession
|
|
304
|
+
*/
|
|
305
|
+
type UseSessionReturn = SessionState & {
|
|
293
306
|
login: (email: string, password: string) => Promise<LoginResult>;
|
|
294
307
|
logout: () => Promise<void>;
|
|
295
308
|
refreshTokens: () => Promise<boolean>;
|
|
296
309
|
clearError: () => void;
|
|
297
|
-
getTokenInfo: () => Promise<
|
|
298
|
-
isLoggedIn: boolean;
|
|
299
|
-
crudifyTokens: {
|
|
300
|
-
accessToken: string;
|
|
301
|
-
refreshToken: string;
|
|
302
|
-
expiresAt: number;
|
|
303
|
-
refreshExpiresAt: number;
|
|
304
|
-
isExpired: boolean;
|
|
305
|
-
isRefreshExpired: boolean;
|
|
306
|
-
isValid: boolean;
|
|
307
|
-
expiresIn: number;
|
|
308
|
-
willExpireSoon: boolean;
|
|
309
|
-
};
|
|
310
|
-
storageInfo: {
|
|
311
|
-
accessExpired: boolean;
|
|
312
|
-
refreshExpired: boolean;
|
|
313
|
-
accessExpiresIn: number;
|
|
314
|
-
refreshExpiresIn: number;
|
|
315
|
-
} | null;
|
|
316
|
-
hasValidTokens: boolean;
|
|
317
|
-
apiEndpointAdmin: string | undefined;
|
|
318
|
-
apiKeyEndpointAdmin: string | undefined;
|
|
319
|
-
}>;
|
|
310
|
+
getTokenInfo: () => Promise<TokenInfoResult>;
|
|
320
311
|
updateActivity: () => void;
|
|
321
312
|
isExpiringSoon: boolean;
|
|
322
313
|
expiresIn: number;
|
|
323
314
|
refreshExpiresIn: number;
|
|
324
|
-
isAuthenticated: boolean;
|
|
325
|
-
isLoading: boolean;
|
|
326
|
-
isLoggingOut: boolean;
|
|
327
|
-
isInitialized: boolean;
|
|
328
|
-
tokens: TokenData | null;
|
|
329
|
-
error: string | null;
|
|
330
315
|
};
|
|
316
|
+
/**
|
|
317
|
+
* Resultado de getTokenInfo
|
|
318
|
+
*/
|
|
319
|
+
type TokenInfoResult = {
|
|
320
|
+
crudifyTokens: {
|
|
321
|
+
accessToken: string | null;
|
|
322
|
+
refreshToken: string | null;
|
|
323
|
+
expiresAt: number;
|
|
324
|
+
refreshExpiresAt: number;
|
|
325
|
+
expiresIn: number;
|
|
326
|
+
};
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Hook de React para manejo de sesiones con Refresh Token Pattern
|
|
331
|
+
* Proporciona una API simple para manejar autenticación en componentes React
|
|
332
|
+
*
|
|
333
|
+
* @param options - Opciones de configuración del hook
|
|
334
|
+
* @returns Estado de sesión y funciones de control
|
|
335
|
+
*
|
|
336
|
+
* @example
|
|
337
|
+
* ```tsx
|
|
338
|
+
* const { isAuthenticated, login, logout } = useSession({
|
|
339
|
+
* onSessionExpired: () => navigate('/login')
|
|
340
|
+
* });
|
|
341
|
+
* ```
|
|
342
|
+
*/
|
|
343
|
+
declare function useSession(options?: UseSessionOptions): UseSessionReturn;
|
|
331
344
|
|
|
332
345
|
type SessionData = {
|
|
333
346
|
_id: string;
|
package/dist/index.d.mts
CHANGED
|
@@ -5,7 +5,7 @@ import { d as CrudifyLoginConfig } from './CrudiaMarkdownField-8s252xsM.mjs';
|
|
|
5
5
|
export { B as BoxScreenType, a as CrudiaAutoGenerate, i as CrudiaAutoGenerateProps, b as CrudiaFileField, n as CrudiaFileFieldDeletionHandlers, j as CrudiaFileFieldProps, c as CrudiaMarkdownField, k as CrudiaMarkdownFieldProps, C as CrudifyLogin, e as CrudifyLoginProps, f as CrudifyLoginTranslations, L as LoginComponent, l as POLICY_ACTIONS, m as PREFERRED_POLICY_ORDER, P as Policies, h as PolicyAction, S as SessionStatus, g as UserLoginData, U as UserProfileDisplay } from './CrudiaMarkdownField-8s252xsM.mjs';
|
|
6
6
|
import React, { ReactNode } from 'react';
|
|
7
7
|
export { A as ApiError, C as CrudifyApiResponse, d as CrudifyOperationOptions, e as CrudifyRequestOptions, a as CrudifyTransactionResponse, F as ForgotPasswordRequest, J as JwtPayload, b as LoginRequest, L as LoginResponse, R as ResetPasswordRequest, g as TransactionInput, f as TransactionOperation, T as TransactionResponseData, U as UserProfile, V as ValidateCodeRequest, c as ValidationError } from './api-B4uXiHF0.mjs';
|
|
8
|
-
export { F as FileItem, v as FileStatus, L as LoginResult, N as NotificationOptions, a as SessionConfig, g as SessionDebugInfo, S as SessionManager, e as SessionProvider, h as SessionProviderProps, d as SessionState, c as StorageType, b as TokenData, T as TokenStorage, n as UseAuthReturn, p as UseDataReturn, s as UseFileUploadOptions, t as UseFileUploadReturn, U as UseSessionOptions, k as UseUserDataOptions, j as UseUserDataReturn, l as UserData, m as useAuth, w as useCrudifyWithNotifications, o as useData, r as useFileUpload, u as useSession, f as useSessionContext, i as useUserData, q as useUserProfile } from './index-
|
|
8
|
+
export { F as FileItem, v as FileStatus, L as LoginResult, N as NotificationOptions, a as SessionConfig, g as SessionDebugInfo, S as SessionManager, e as SessionProvider, h as SessionProviderProps, d as SessionState, c as StorageType, b as TokenData, T as TokenStorage, n as UseAuthReturn, p as UseDataReturn, s as UseFileUploadOptions, t as UseFileUploadReturn, U as UseSessionOptions, k as UseUserDataOptions, j as UseUserDataReturn, l as UserData, m as useAuth, w as useCrudifyWithNotifications, o as useData, r as useFileUpload, u as useSession, f as useSessionContext, i as useUserData, q as useUserProfile } from './index-8iJiQ3bI.mjs';
|
|
9
9
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
10
10
|
import { ThemeOptions } from '@mui/material';
|
|
11
11
|
export { A as AutoGenerateConfig, G as GlobalNotificationProvider, a as GlobalNotificationProviderProps, N as Notification, b as NotificationSeverity, d as UseAutoGenerateOptions, U as UseAutoGenerateReturn, c as useAutoGenerate, u as useGlobalNotification } from './GlobalNotificationProvider-Zq18OkpI.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { d as CrudifyLoginConfig } from './CrudiaMarkdownField-Dy2dVkBO.js';
|
|
|
5
5
|
export { B as BoxScreenType, a as CrudiaAutoGenerate, i as CrudiaAutoGenerateProps, b as CrudiaFileField, n as CrudiaFileFieldDeletionHandlers, j as CrudiaFileFieldProps, c as CrudiaMarkdownField, k as CrudiaMarkdownFieldProps, C as CrudifyLogin, e as CrudifyLoginProps, f as CrudifyLoginTranslations, L as LoginComponent, l as POLICY_ACTIONS, m as PREFERRED_POLICY_ORDER, P as Policies, h as PolicyAction, S as SessionStatus, g as UserLoginData, U as UserProfileDisplay } from './CrudiaMarkdownField-Dy2dVkBO.js';
|
|
6
6
|
import React, { ReactNode } from 'react';
|
|
7
7
|
export { A as ApiError, C as CrudifyApiResponse, d as CrudifyOperationOptions, e as CrudifyRequestOptions, a as CrudifyTransactionResponse, F as ForgotPasswordRequest, J as JwtPayload, b as LoginRequest, L as LoginResponse, R as ResetPasswordRequest, g as TransactionInput, f as TransactionOperation, T as TransactionResponseData, U as UserProfile, V as ValidateCodeRequest, c as ValidationError } from './api-B4uXiHF0.js';
|
|
8
|
-
export { F as FileItem, v as FileStatus, L as LoginResult, N as NotificationOptions, a as SessionConfig, g as SessionDebugInfo, S as SessionManager, e as SessionProvider, h as SessionProviderProps, d as SessionState, c as StorageType, b as TokenData, T as TokenStorage, n as UseAuthReturn, p as UseDataReturn, s as UseFileUploadOptions, t as UseFileUploadReturn, U as UseSessionOptions, k as UseUserDataOptions, j as UseUserDataReturn, l as UserData, m as useAuth, w as useCrudifyWithNotifications, o as useData, r as useFileUpload, u as useSession, f as useSessionContext, i as useUserData, q as useUserProfile } from './index-
|
|
8
|
+
export { F as FileItem, v as FileStatus, L as LoginResult, N as NotificationOptions, a as SessionConfig, g as SessionDebugInfo, S as SessionManager, e as SessionProvider, h as SessionProviderProps, d as SessionState, c as StorageType, b as TokenData, T as TokenStorage, n as UseAuthReturn, p as UseDataReturn, s as UseFileUploadOptions, t as UseFileUploadReturn, U as UseSessionOptions, k as UseUserDataOptions, j as UseUserDataReturn, l as UserData, m as useAuth, w as useCrudifyWithNotifications, o as useData, r as useFileUpload, u as useSession, f as useSessionContext, i as useUserData, q as useUserProfile } from './index-BaP3eAZd.js';
|
|
9
9
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
10
10
|
import { ThemeOptions } from '@mui/material';
|
|
11
11
|
export { A as AutoGenerateConfig, G as GlobalNotificationProvider, a as GlobalNotificationProviderProps, N as Notification, b as NotificationSeverity, d as UseAutoGenerateOptions, U as UseAutoGenerateReturn, c as useAutoGenerate, u as useGlobalNotification } from './GlobalNotificationProvider-Zq18OkpI.js';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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]}); }); } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } async function _asyncOptionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }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]}); }); } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } async function _asyncOptionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunk4R472VF6js = require('./chunk-4R472VF6.js');var _chunkBBA4D4JYjs = require('./chunk-BBA4D4JY.js');var _chunk4AEUOTN2js = require('./chunk-4AEUOTN2.js');var _chunk5HFI5CZ5js = require('./chunk-5HFI5CZ5.js');var _chunkNSV6ECYOjs = require('./chunk-NSV6ECYO.js');var _chunkMFYHD6S5js = require('./chunk-MFYHD6S5.js');var _crudifybrowser = require('@nocios/crudify-browser'); var _crudifybrowser2 = _interopRequireDefault(_crudifybrowser); _createStarExport(_crudifybrowser);var _react = require('react');var _material = require('@mui/material');var _jsxruntime = require('react/jsx-runtime');var _e=(e={})=>{try{let r=_chunkMFYHD6S5js.b.call(void 0, "theme");if(r){let o=JSON.parse(decodeURIComponent(r));return{...e,...o}}}catch(r){_chunkMFYHD6S5js.a.warn("Error parsing theme from cookie",r instanceof Error?{errorMessage:r.message}:{message:String(r)})}return e};function Be({children:e,defaultTheme:r={},disableCssBaseline:o=!1}){let t=_react.useMemo.call(void 0, ()=>{let a=_e(r);return _material.createTheme.call(void 0, a)},[r]);return _jsxruntime.jsxs.call(void 0, _material.ThemeProvider,{theme:t,children:[!o&&_jsxruntime.jsx.call(void 0, _material.CssBaseline,{}),e]})}var _reactrouterdom = require('react-router-dom');var We={border:"5px solid rgba(0, 0, 0, 0.1)",borderTopColor:"#3B82F6",borderRadius:"50%",width:"50px",height:"50px",animation:"spin 1s linear infinite"},Je=()=>_jsxruntime.jsx.call(void 0, "style",{children:`
|
|
2
2
|
@keyframes spin {
|
|
3
3
|
0% { transform: rotate(0deg); }
|
|
4
4
|
100% { transform: rotate(360deg); }
|
|
5
5
|
}
|
|
6
|
-
`});function E({stage:e="loading",message:r}){let t=r||{initializing:"Initializing application...","validating-session":"Validating session...",loading:"Loading..."}[e];return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, Je,{}),_jsxruntime.jsxs.call(void 0, "div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100vh",width:"100vw",backgroundColor:"#f0f2f5",fontFamily:'"Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',color:"#333",textAlign:"center",boxSizing:"border-box",padding:"20px",background:"#fff"},children:[_jsxruntime.jsx.call(void 0, "div",{style:We}),_jsxruntime.jsx.call(void 0, "p",{style:{fontSize:"1.25em",fontWeight:"500",marginTop:"24px",color:"#1f2937"},children:t})]})]})}var Ye=/^[a-zA-Z0-9\-_./\?=&%#]+$/,Ze=[/^https?:\/\//i,/^ftp:\/\//i,/^\/\//,/javascript:/i,/data:/i,/vbscript:/i,/about:/i,/\.\.\//,/\.\.\\/,/%2e%2e%2f/i,/%2e%2e%5c/i,/%2f%2f/i,/%5c%5c/i,/[\x00-\x1f\x7f-\x9f]/,/\\/],v= exports.validateInternalRedirect =(e,r="/")=>{if(!e||typeof e!="string")return r;let o=e.trim();if(!o)return r;if(!o.startsWith("/"))return _chunkMFYHD6S5js.a.warn("Open redirect blocked (relative path)",{path:e}),r;if(!Ye.test(o))return _chunkMFYHD6S5js.a.warn("Open redirect blocked (invalid characters)",{path:e}),r;let t=o.toLowerCase();for(let s of Ze)if(s.test(t))return _chunkMFYHD6S5js.a.warn("Open redirect blocked (dangerous pattern)",{path:e}),r;let a=o.split("?")[0].split("/").filter(Boolean);if(a.length===0)return o;for(let s of a)if(s===".."||s.includes(":")||s.length>100)return _chunkMFYHD6S5js.a.warn("Open redirect blocked (suspicious path part)",{part:s}),r;return o},M= exports.extractSafeRedirectFromUrl =(e,r="/")=>{try{let t=(typeof e=="string"?new URLSearchParams(e):e).get("redirect");if(!t)return r;let a=decodeURIComponent(t);return v(a,r)}catch(o){return _chunkMFYHD6S5js.a.warn("Error parsing redirect parameter",o instanceof Error?{errorMessage:o.message}:{message:String(o)}),r}};function F({children:e,loadingComponent:r,loginPath:o="/login"}){let{isAuthenticated:t,isLoading:a,isLoggingOut:s,isInitialized:x,tokens:c,error:f}=_chunkIKYHYKJBjs.j.call(void 0, ),l=_reactrouterdom.useLocation.call(void 0, );if(!x||a&&!s)return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:r||_jsxruntime.jsx.call(void 0, E,{stage:"validating-session"})});let C=t&&_optionalChain([c, 'optionalAccess', _2 => _2.accessToken])&&c.accessToken.length>0;if(f||!t||!C){if(c&&(!c.accessToken||c.accessToken.length===0)&&localStorage.removeItem("crudify_tokens"),s)return _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:o,replace:!0});let R=l.pathname+l.search;if(l.pathname===o||l.pathname.startsWith(o))return _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:o,replace:!0});let P=v(R),T=encodeURIComponent(P);return _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:`${o}?redirect=${T}`,replace:!0})}return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:e})}function D({children:e,redirectTo:r="/"}){let{isAuthenticated:o}=_chunkIKYHYKJBjs.j.call(void 0, ),t=_reactrouterdom.useLocation.call(void 0, );if(o){let a=new URLSearchParams(t.search),s=M(a,r);return _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:s,replace:!0})}return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:e})}var V=_react.createContext.call(void 0, void 0),ir= exports.CrudifyInitializer =({config:e,children:r,fallback:o=null,onInitialized:t,onError:a})=>{let[s,x]=_react.useState.call(void 0, !1),[c,f]=_react.useState.call(void 0, !1),[l,C]=_react.useState.call(void 0, null),R=_react.useRef.call(void 0, !1),P=_react.useRef.call(void 0, !1);_react.useEffect.call(void 0, ()=>{R.current||(_chunkIKYHYKJBjs.o.registerHighPriorityInitializer(),R.current=!0),P.current||(P.current=!0,(async()=>{f(!0),C(null);try{let u=_chunkMFYHD6S5js.c.call(void 0, {publicApiKey:_optionalChain([e, 'optionalAccess', _3 => _3.publicApiKey]),env:_optionalChain([e, 'optionalAccess', _4 => _4.env]),enableDebug:_optionalChain([e, 'optionalAccess', _5 => _5.enableLogging])});if(!u.publicApiKey)throw new Error("Crudify configuration missing. Please provide publicApiKey via props or ensure cookies are set by Lambda.");let I=u.env||"prod";_chunkMFYHD6S5js.a.setEnvironment(I),await _chunkIKYHYKJBjs.o.initialize({priority:"HIGH",publicApiKey:u.publicApiKey,env:u.env||"prod",enableLogging:_optionalChain([e, 'optionalAccess', _6 => _6.enableLogging]),requestedBy:"CrudifyInitializer"}),x(!0),f(!1),t&&t()}catch(u){let I=u instanceof Error?u:new Error(String(u));C(I),f(!1),a&&a(I)}})())},[_optionalChain([e, 'optionalAccess', _7 => _7.publicApiKey]),_optionalChain([e, 'optionalAccess', _8 => _8.env]),_optionalChain([e, 'optionalAccess', _9 => _9.enableLogging]),t,a]);let T={isInitialized:s,isInitializing:c,error:l};return c&&o?_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:o}):(l&&_chunkMFYHD6S5js.a.error("[CrudifyInitializer] Initialization failed",l),_jsxruntime.jsx.call(void 0, V.Provider,{value:T,children:r}))},nr= exports.useCrudifyInitializer =()=>{let e=_react.useContext.call(void 0, V);if(!e)throw new Error("useCrudifyInitializer must be used within CrudifyInitializer");return e};var _crudifyadmin = require('@nocios/crudify-admin'); var _crudifyadmin2 = _interopRequireDefault(_crudifyadmin);var _=!1,y=null,A=null;async function ar(){let r=await _chunkIKYHYKJBjs.b.getInstance().getTokenInfo(),o=_optionalChain([r, 'optionalAccess', _10 => _10.apiEndpointAdmin]),t=_optionalChain([r, 'optionalAccess', _11 => _11.apiKeyEndpointAdmin]);return o&&t?{apiUrl:o,apiKey:t}:_chunkIKYHYKJBjs.f.waitForCredentials()}async function pr(){if(!_)return y||(y=(async()=>{try{let e=_chunkIKYHYKJBjs.b.getInstance(),{apiUrl:r,apiKey:o}=await ar();A=await _asyncOptionalChain([(await e.getTokenInfo()), 'optionalAccess', async _12 => _12.crudifyTokens, 'optionalAccess', async _13 => _13.accessToken])||null,_crudifyadmin2.default.init({url:r,apiKey:o,getAdditionalHeaders:()=>A?{Authorization:`Bearer ${A}`}:{}}),_=!0}catch(e){throw y=null,_chunkMFYHD6S5js.a.error("[crudifyAdminWrapper] Initialization failed",e instanceof Error?e:{message:String(e)}),e}})(),y)}async function n(e){try{await pr();let r=_chunkIKYHYKJBjs.b.getInstance();A=await _asyncOptionalChain([(await r.getTokenInfo()), 'optionalAccess', async _14 => _14.crudifyTokens, 'optionalAccess', async _15 => _15.accessToken])||null;let t=await e(),a=t.errors&&(typeof t.errors=="string"&&t.errors.includes("401")||Array.isArray(t.errors)&&t.errors.some(s=>typeof s=="string"&&s.includes("401")));return!t.success&&a?await r.refreshTokens()?(A=await _asyncOptionalChain([(await r.getTokenInfo()), 'optionalAccess', async _16 => _16.crudifyTokens, 'optionalAccess', async _17 => _17.accessToken])||null,await e()):(_chunkMFYHD6S5js.a.error("[crudifyAdmin] Token refresh failed"),typeof window<"u"&&(window.location.href="/login"),t):t}catch(r){return _chunkMFYHD6S5js.a.error("[crudifyAdmin] Operation error",r instanceof Error?r:{message:String(r)}),{success:!1,errors:r instanceof Error?r.message:"Unknown error"}}}var cr={listModules:()=>n(()=>_crudifyadmin2.default.listModules()),getModule:e=>n(()=>_crudifyadmin2.default.getModule(e)),createModule:e=>n(()=>_crudifyadmin2.default.createModule(e)),editModule:(e,r)=>n(()=>_crudifyadmin2.default.editModule(e,r)),deleteModule:e=>n(()=>_crudifyadmin2.default.deleteModule(e)),activateModule:e=>n(()=>_crudifyadmin2.default.activateModule(e)),deactivateModule:e=>n(()=>_crudifyadmin2.default.deactivateModule(e)),getModuleVersions:e=>n(()=>_crudifyadmin2.default.getModuleVersions(e)),listActions:e=>n(()=>_crudifyadmin2.default.listActions(e)),getAction:e=>n(()=>_crudifyadmin2.default.getAction(e)),createAction:e=>n(()=>_crudifyadmin2.default.createAction(e)),editAction:(e,r)=>n(()=>_crudifyadmin2.default.editAction(e,r)),deleteAction:e=>n(()=>_crudifyadmin2.default.deleteAction(e)),activateAction:e=>n(()=>_crudifyadmin2.default.activateAction(e)),deactivateAction:e=>n(()=>_crudifyadmin2.default.deactivateAction(e)),getActionVersions:e=>n(()=>_crudifyadmin2.default.getActionVersions(e)),getActionsByProfile:e=>n(()=>_crudifyadmin2.default.getActionsByProfile(e)),updateActionsProfiles:e=>n(()=>_crudifyadmin2.default.updateActionsProfiles(e)),calculatePermissions:e=>n(()=>_crudifyadmin2.default.calculatePermissions(e))};exports.AuthRoute = D; exports.CRITICAL_TRANSLATIONS = _chunk46CKGJCCjs.a; exports.CrudiaAutoGenerate = _chunk46CKGJCCjs.o; exports.CrudiaFileField = _chunk46CKGJCCjs.p; exports.CrudiaMarkdownField = _chunk46CKGJCCjs.q; exports.CrudifyInitializationManager = _chunkIKYHYKJBjs.n; exports.CrudifyInitializer = ir; exports.CrudifyLogin = _chunk46CKGJCCjs.h; exports.CrudifyProvider = _chunkIKYHYKJBjs.g; exports.CrudifyThemeProvider = Be; exports.ERROR_CODES = _chunkNSV6ECYOjs.a; exports.ERROR_SEVERITY_MAP = _chunkNSV6ECYOjs.b; exports.GlobalNotificationProvider = _chunkIKYHYKJBjs.d; exports.LoginComponent = _chunk46CKGJCCjs.m; exports.POLICY_ACTIONS = _chunk46CKGJCCjs.j; exports.PREFERRED_POLICY_ORDER = _chunk46CKGJCCjs.k; exports.Policies = _chunk46CKGJCCjs.l; exports.ProtectedRoute = F; exports.SessionDebugInfo = _chunkIKYHYKJBjs.k; exports.SessionLoadingScreen = E; exports.SessionManager = _chunkIKYHYKJBjs.b; exports.SessionProvider = _chunkIKYHYKJBjs.i; exports.SessionStatus = _chunk46CKGJCCjs.n; exports.TokenStorage = _chunkIKYHYKJBjs.a; exports.TranslationService = _chunk46CKGJCCjs.d; exports.TranslationsProvider = _chunk46CKGJCCjs.f; exports.UserProfileDisplay = _chunk46CKGJCCjs.i; exports.createErrorTranslator = _chunkMFYHD6S5js.o; exports.crudify = _crudifybrowser2.default; exports.crudifyAdmin = cr; exports.crudifyInitManager = _chunkIKYHYKJBjs.o; exports.decodeJwtSafely = _chunkMFYHD6S5js.q; exports.extractSafeRedirectFromUrl = M; exports.getCookie = _chunkMFYHD6S5js.b; exports.getCriticalLanguages = _chunk46CKGJCCjs.b; exports.getCriticalTranslations = _chunk46CKGJCCjs.c; exports.getCurrentUserEmail = _chunkMFYHD6S5js.r; exports.getErrorMessage = _chunkNSV6ECYOjs.e; exports.handleCrudifyError = _chunkNSV6ECYOjs.g; exports.isTokenExpired = _chunkMFYHD6S5js.s; exports.logger = _chunkMFYHD6S5js.a; exports.parseApiError = _chunkNSV6ECYOjs.c; exports.parseJavaScriptError = _chunkNSV6ECYOjs.f; exports.parseTransactionError = _chunkNSV6ECYOjs.d; exports.secureLocalStorage = _chunk5HFI5CZ5js.b; exports.secureSessionStorage = _chunk5HFI5CZ5js.a; exports.translateError = _chunkMFYHD6S5js.n; exports.translateErrorCode = _chunkMFYHD6S5js.l; exports.translateErrorCodes = _chunkMFYHD6S5js.m; exports.translationService = _chunk46CKGJCCjs.e; exports.useAuth = _chunk6LMZ3PZWjs.b; exports.useAutoGenerate = _chunkIKYHYKJBjs.m; exports.useCrudify = _chunkIKYHYKJBjs.h; exports.useCrudifyInitializer = nr; exports.useCrudifyWithNotifications = _chunk6LMZ3PZWjs.d; exports.useData = _chunk6LMZ3PZWjs.c; exports.useFileUpload = _chunkIKYHYKJBjs.p; exports.useGlobalNotification = _chunkIKYHYKJBjs.e; exports.useSession = _chunkIKYHYKJBjs.c; exports.useSessionContext = _chunkIKYHYKJBjs.j; exports.useTranslations = _chunk46CKGJCCjs.g; exports.useUserData = _chunk6LMZ3PZWjs.a; exports.useUserProfile = _chunkIKYHYKJBjs.l; exports.validateInternalRedirect = v;
|
|
6
|
+
`});function E({stage:e="loading",message:r}){let t=r||{initializing:"Initializing application...","validating-session":"Validating session...",loading:"Loading..."}[e];return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, Je,{}),_jsxruntime.jsxs.call(void 0, "div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100vh",width:"100vw",backgroundColor:"#f0f2f5",fontFamily:'"Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',color:"#333",textAlign:"center",boxSizing:"border-box",padding:"20px",background:"#fff"},children:[_jsxruntime.jsx.call(void 0, "div",{style:We}),_jsxruntime.jsx.call(void 0, "p",{style:{fontSize:"1.25em",fontWeight:"500",marginTop:"24px",color:"#1f2937"},children:t})]})]})}var Ye=/^[a-zA-Z0-9\-_./\?=&%#]+$/,Ze=[/^https?:\/\//i,/^ftp:\/\//i,/^\/\//,/javascript:/i,/data:/i,/vbscript:/i,/about:/i,/\.\.\//,/\.\.\\/,/%2e%2e%2f/i,/%2e%2e%5c/i,/%2f%2f/i,/%5c%5c/i,/[\x00-\x1f\x7f-\x9f]/,/\\/],v= exports.validateInternalRedirect =(e,r="/")=>{if(!e||typeof e!="string")return r;let o=e.trim();if(!o)return r;if(!o.startsWith("/"))return _chunkMFYHD6S5js.a.warn("Open redirect blocked (relative path)",{path:e}),r;if(!Ye.test(o))return _chunkMFYHD6S5js.a.warn("Open redirect blocked (invalid characters)",{path:e}),r;let t=o.toLowerCase();for(let s of Ze)if(s.test(t))return _chunkMFYHD6S5js.a.warn("Open redirect blocked (dangerous pattern)",{path:e}),r;let a=o.split("?")[0].split("/").filter(Boolean);if(a.length===0)return o;for(let s of a)if(s===".."||s.includes(":")||s.length>100)return _chunkMFYHD6S5js.a.warn("Open redirect blocked (suspicious path part)",{part:s}),r;return o},M= exports.extractSafeRedirectFromUrl =(e,r="/")=>{try{let t=(typeof e=="string"?new URLSearchParams(e):e).get("redirect");if(!t)return r;let a=decodeURIComponent(t);return v(a,r)}catch(o){return _chunkMFYHD6S5js.a.warn("Error parsing redirect parameter",o instanceof Error?{errorMessage:o.message}:{message:String(o)}),r}};function F({children:e,loadingComponent:r,loginPath:o="/login"}){let{isAuthenticated:t,isLoading:a,isLoggingOut:s,isInitialized:x,tokens:c,error:f}=_chunk4AEUOTN2js.j.call(void 0, ),l=_reactrouterdom.useLocation.call(void 0, );if(!x||a&&!s)return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:r||_jsxruntime.jsx.call(void 0, E,{stage:"validating-session"})});let C=t&&_optionalChain([c, 'optionalAccess', _2 => _2.accessToken])&&c.accessToken.length>0;if(f||!t||!C){if(c&&(!c.accessToken||c.accessToken.length===0)&&localStorage.removeItem("crudify_tokens"),s)return _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:o,replace:!0});let R=l.pathname+l.search;if(l.pathname===o||l.pathname.startsWith(o))return _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:o,replace:!0});let P=v(R),T=encodeURIComponent(P);return _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:`${o}?redirect=${T}`,replace:!0})}return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:e})}function D({children:e,redirectTo:r="/"}){let{isAuthenticated:o}=_chunk4AEUOTN2js.j.call(void 0, ),t=_reactrouterdom.useLocation.call(void 0, );if(o){let a=new URLSearchParams(t.search),s=M(a,r);return _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:s,replace:!0})}return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:e})}var V=_react.createContext.call(void 0, void 0),ir= exports.CrudifyInitializer =({config:e,children:r,fallback:o=null,onInitialized:t,onError:a})=>{let[s,x]=_react.useState.call(void 0, !1),[c,f]=_react.useState.call(void 0, !1),[l,C]=_react.useState.call(void 0, null),R=_react.useRef.call(void 0, !1),P=_react.useRef.call(void 0, !1);_react.useEffect.call(void 0, ()=>{R.current||(_chunk4AEUOTN2js.o.registerHighPriorityInitializer(),R.current=!0),P.current||(P.current=!0,(async()=>{f(!0),C(null);try{let u=_chunkMFYHD6S5js.c.call(void 0, {publicApiKey:_optionalChain([e, 'optionalAccess', _3 => _3.publicApiKey]),env:_optionalChain([e, 'optionalAccess', _4 => _4.env]),enableDebug:_optionalChain([e, 'optionalAccess', _5 => _5.enableLogging])});if(!u.publicApiKey)throw new Error("Crudify configuration missing. Please provide publicApiKey via props or ensure cookies are set by Lambda.");let I=u.env||"prod";_chunkMFYHD6S5js.a.setEnvironment(I),await _chunk4AEUOTN2js.o.initialize({priority:"HIGH",publicApiKey:u.publicApiKey,env:u.env||"prod",enableLogging:_optionalChain([e, 'optionalAccess', _6 => _6.enableLogging]),requestedBy:"CrudifyInitializer"}),x(!0),f(!1),t&&t()}catch(u){let I=u instanceof Error?u:new Error(String(u));C(I),f(!1),a&&a(I)}})())},[_optionalChain([e, 'optionalAccess', _7 => _7.publicApiKey]),_optionalChain([e, 'optionalAccess', _8 => _8.env]),_optionalChain([e, 'optionalAccess', _9 => _9.enableLogging]),t,a]);let T={isInitialized:s,isInitializing:c,error:l};return c&&o?_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:o}):(l&&_chunkMFYHD6S5js.a.error("[CrudifyInitializer] Initialization failed",l),_jsxruntime.jsx.call(void 0, V.Provider,{value:T,children:r}))},nr= exports.useCrudifyInitializer =()=>{let e=_react.useContext.call(void 0, V);if(!e)throw new Error("useCrudifyInitializer must be used within CrudifyInitializer");return e};var _crudifyadmin = require('@nocios/crudify-admin'); var _crudifyadmin2 = _interopRequireDefault(_crudifyadmin);var _=!1,y=null,A=null;async function ar(){let r=await _chunk4AEUOTN2js.b.getInstance().getTokenInfo(),o=_optionalChain([r, 'optionalAccess', _10 => _10.apiEndpointAdmin]),t=_optionalChain([r, 'optionalAccess', _11 => _11.apiKeyEndpointAdmin]);return o&&t?{apiUrl:o,apiKey:t}:_chunk4AEUOTN2js.f.waitForCredentials()}async function pr(){if(!_)return y||(y=(async()=>{try{let e=_chunk4AEUOTN2js.b.getInstance(),{apiUrl:r,apiKey:o}=await ar();A=await _asyncOptionalChain([(await e.getTokenInfo()), 'optionalAccess', async _12 => _12.crudifyTokens, 'optionalAccess', async _13 => _13.accessToken])||null,_crudifyadmin2.default.init({url:r,apiKey:o,getAdditionalHeaders:()=>A?{Authorization:`Bearer ${A}`}:{}}),_=!0}catch(e){throw y=null,_chunkMFYHD6S5js.a.error("[crudifyAdminWrapper] Initialization failed",e instanceof Error?e:{message:String(e)}),e}})(),y)}async function n(e){try{await pr();let r=_chunk4AEUOTN2js.b.getInstance();A=await _asyncOptionalChain([(await r.getTokenInfo()), 'optionalAccess', async _14 => _14.crudifyTokens, 'optionalAccess', async _15 => _15.accessToken])||null;let t=await e(),a=t.errors&&(typeof t.errors=="string"&&t.errors.includes("401")||Array.isArray(t.errors)&&t.errors.some(s=>typeof s=="string"&&s.includes("401")));return!t.success&&a?await r.refreshTokens()?(A=await _asyncOptionalChain([(await r.getTokenInfo()), 'optionalAccess', async _16 => _16.crudifyTokens, 'optionalAccess', async _17 => _17.accessToken])||null,await e()):(_chunkMFYHD6S5js.a.error("[crudifyAdmin] Token refresh failed"),typeof window<"u"&&(window.location.href="/login"),t):t}catch(r){return _chunkMFYHD6S5js.a.error("[crudifyAdmin] Operation error",r instanceof Error?r:{message:String(r)}),{success:!1,errors:r instanceof Error?r.message:"Unknown error"}}}var cr={listModules:()=>n(()=>_crudifyadmin2.default.listModules()),getModule:e=>n(()=>_crudifyadmin2.default.getModule(e)),createModule:e=>n(()=>_crudifyadmin2.default.createModule(e)),editModule:(e,r)=>n(()=>_crudifyadmin2.default.editModule(e,r)),deleteModule:e=>n(()=>_crudifyadmin2.default.deleteModule(e)),activateModule:e=>n(()=>_crudifyadmin2.default.activateModule(e)),deactivateModule:e=>n(()=>_crudifyadmin2.default.deactivateModule(e)),getModuleVersions:e=>n(()=>_crudifyadmin2.default.getModuleVersions(e)),listActions:e=>n(()=>_crudifyadmin2.default.listActions(e)),getAction:e=>n(()=>_crudifyadmin2.default.getAction(e)),createAction:e=>n(()=>_crudifyadmin2.default.createAction(e)),editAction:(e,r)=>n(()=>_crudifyadmin2.default.editAction(e,r)),deleteAction:e=>n(()=>_crudifyadmin2.default.deleteAction(e)),activateAction:e=>n(()=>_crudifyadmin2.default.activateAction(e)),deactivateAction:e=>n(()=>_crudifyadmin2.default.deactivateAction(e)),getActionVersions:e=>n(()=>_crudifyadmin2.default.getActionVersions(e)),getActionsByProfile:e=>n(()=>_crudifyadmin2.default.getActionsByProfile(e)),updateActionsProfiles:e=>n(()=>_crudifyadmin2.default.updateActionsProfiles(e)),calculatePermissions:e=>n(()=>_crudifyadmin2.default.calculatePermissions(e))};exports.AuthRoute = D; exports.CRITICAL_TRANSLATIONS = _chunk4R472VF6js.a; exports.CrudiaAutoGenerate = _chunk4R472VF6js.o; exports.CrudiaFileField = _chunk4R472VF6js.p; exports.CrudiaMarkdownField = _chunk4R472VF6js.q; exports.CrudifyInitializationManager = _chunk4AEUOTN2js.n; exports.CrudifyInitializer = ir; exports.CrudifyLogin = _chunk4R472VF6js.h; exports.CrudifyProvider = _chunk4AEUOTN2js.g; exports.CrudifyThemeProvider = Be; exports.ERROR_CODES = _chunkNSV6ECYOjs.a; exports.ERROR_SEVERITY_MAP = _chunkNSV6ECYOjs.b; exports.GlobalNotificationProvider = _chunk4AEUOTN2js.d; exports.LoginComponent = _chunk4R472VF6js.m; exports.POLICY_ACTIONS = _chunk4R472VF6js.j; exports.PREFERRED_POLICY_ORDER = _chunk4R472VF6js.k; exports.Policies = _chunk4R472VF6js.l; exports.ProtectedRoute = F; exports.SessionDebugInfo = _chunk4AEUOTN2js.k; exports.SessionLoadingScreen = E; exports.SessionManager = _chunk4AEUOTN2js.b; exports.SessionProvider = _chunk4AEUOTN2js.i; exports.SessionStatus = _chunk4R472VF6js.n; exports.TokenStorage = _chunk4AEUOTN2js.a; exports.TranslationService = _chunk4R472VF6js.d; exports.TranslationsProvider = _chunk4R472VF6js.f; exports.UserProfileDisplay = _chunk4R472VF6js.i; exports.createErrorTranslator = _chunkMFYHD6S5js.o; exports.crudify = _crudifybrowser2.default; exports.crudifyAdmin = cr; exports.crudifyInitManager = _chunk4AEUOTN2js.o; exports.decodeJwtSafely = _chunkMFYHD6S5js.q; exports.extractSafeRedirectFromUrl = M; exports.getCookie = _chunkMFYHD6S5js.b; exports.getCriticalLanguages = _chunk4R472VF6js.b; exports.getCriticalTranslations = _chunk4R472VF6js.c; exports.getCurrentUserEmail = _chunkMFYHD6S5js.r; exports.getErrorMessage = _chunkNSV6ECYOjs.e; exports.handleCrudifyError = _chunkNSV6ECYOjs.g; exports.isTokenExpired = _chunkMFYHD6S5js.s; exports.logger = _chunkMFYHD6S5js.a; exports.parseApiError = _chunkNSV6ECYOjs.c; exports.parseJavaScriptError = _chunkNSV6ECYOjs.f; exports.parseTransactionError = _chunkNSV6ECYOjs.d; exports.secureLocalStorage = _chunk5HFI5CZ5js.b; exports.secureSessionStorage = _chunk5HFI5CZ5js.a; exports.translateError = _chunkMFYHD6S5js.n; exports.translateErrorCode = _chunkMFYHD6S5js.l; exports.translateErrorCodes = _chunkMFYHD6S5js.m; exports.translationService = _chunk4R472VF6js.e; exports.useAuth = _chunkBBA4D4JYjs.b; exports.useAutoGenerate = _chunk4AEUOTN2js.m; exports.useCrudify = _chunk4AEUOTN2js.h; exports.useCrudifyInitializer = nr; exports.useCrudifyWithNotifications = _chunkBBA4D4JYjs.d; exports.useData = _chunkBBA4D4JYjs.c; exports.useFileUpload = _chunk4AEUOTN2js.p; exports.useGlobalNotification = _chunk4AEUOTN2js.e; exports.useSession = _chunk4AEUOTN2js.c; exports.useSessionContext = _chunk4AEUOTN2js.j; exports.useTranslations = _chunk4R472VF6js.g; exports.useUserData = _chunkBBA4D4JYjs.a; exports.useUserProfile = _chunk4AEUOTN2js.l; exports.validateInternalRedirect = v;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as B,b as H,c as q,d as W,e as J,f as $,g as Y,h as xe,i as Re,j as Pe,k as Ie,l as he,m as Se,n as ve,o as ke,p as ze,q as we}from"./chunk-
|
|
1
|
+
import{a as B,b as H,c as q,d as W,e as J,f as $,g as Y,h as xe,i as Re,j as Pe,k as Ie,l as he,m as Se,n as ve,o as ke,p as ze,q as we}from"./chunk-WVEMQ7DL.mjs";import{a as Le,b as be,c as Ue,d as Ne}from"./chunk-I2GWDIIJ.mjs";import{a as Z,b as m,c as re,d as ne,e as se,f as b,g as ae,h as pe,i as ce,j as g,k as le,l as Ce,m as Te,n as Ee,o as h,p as Me}from"./chunk-Z2GYZNAL.mjs";import{a as Oe,b as Fe}from"./chunk-JNEWPO2J.mjs";import{a as ue,b as de,c as fe,d as me,e as ge,f as ye,g as Ae}from"./chunk-JAPL7EZJ.mjs";import{a as p,b as k,c as L,l as Q,m as X,n as j,o as ee,q as oe,r as te,s as ie}from"./chunk-MGJZTOEM.mjs";import{default as Qr}from"@nocios/crudify-browser";export*from"@nocios/crudify-browser";import{useMemo as De}from"react";import{ThemeProvider as Ge,createTheme as Ke,CssBaseline as Ve}from"@mui/material";import{jsx as He,jsxs as qe}from"react/jsx-runtime";var _e=(e={})=>{try{let r=k("theme");if(r){let o=JSON.parse(decodeURIComponent(r));return{...e,...o}}}catch(r){p.warn("Error parsing theme from cookie",r instanceof Error?{errorMessage:r.message}:{message:String(r)})}return e};function Be({children:e,defaultTheme:r={},disableCssBaseline:o=!1}){let t=De(()=>{let a=_e(r);return Ke(a)},[r]);return qe(Ge,{theme:t,children:[!o&&He(Ve,{}),e]})}import{Navigate as z,useLocation as Qe}from"react-router-dom";import{Fragment as $e,jsx as S,jsxs as U}from"react/jsx-runtime";var We={border:"5px solid rgba(0, 0, 0, 0.1)",borderTopColor:"#3B82F6",borderRadius:"50%",width:"50px",height:"50px",animation:"spin 1s linear infinite"},Je=()=>S("style",{children:`
|
|
2
2
|
@keyframes spin {
|
|
3
3
|
0% { transform: rotate(0deg); }
|
|
4
4
|
100% { transform: rotate(360deg); }
|
package/package.json
CHANGED
package/vitest.config.ts
CHANGED
|
@@ -17,7 +17,7 @@ export default defineConfig({
|
|
|
17
17
|
coverage: {
|
|
18
18
|
provider: "v8",
|
|
19
19
|
reporter: ["text", "json", "html"],
|
|
20
|
-
exclude: ["node_modules/", "src/__tests__/", "dist/", "**/*.d.ts", "**/*.config.*", "**/mockData.ts"],
|
|
20
|
+
exclude: ["node_modules/", "src/__tests__/", "dist/", "**/*.d.ts", "**/*.config.*", "**/mockData.ts", "**/testUtils.tsx", "**/testUtils.ts"],
|
|
21
21
|
},
|
|
22
22
|
},
|
|
23
23
|
resolve: {
|