@topconsultnpm/sdkui-react 6.21.0-dev3.39 → 6.21.0-dev3.40
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.
|
@@ -24,6 +24,7 @@ interface ITMExceptionBox extends ITMPopup {
|
|
|
24
24
|
exception?: any;
|
|
25
25
|
onClose?: () => void;
|
|
26
26
|
}
|
|
27
|
+
export declare const sanitizeException: (exception: any) => any;
|
|
27
28
|
declare class TMExceptionBoxManager {
|
|
28
29
|
static show({ title, exception, onClose }: ITMExceptionBox): void;
|
|
29
30
|
}
|
|
@@ -23,6 +23,45 @@ export var ButtonNames;
|
|
|
23
23
|
// Dimensioni minime di default per i popup
|
|
24
24
|
const DEFAULT_MIN_WIDTH = 500;
|
|
25
25
|
const DEFAULT_MIN_HEIGHT = 400;
|
|
26
|
+
// filtr password from all errors.
|
|
27
|
+
const SENSITIVE_KEY = 'password';
|
|
28
|
+
const redactSensitiveJsonString = (value) => {
|
|
29
|
+
const trimmed = value.trim();
|
|
30
|
+
const looksLikeJson = (trimmed.startsWith('{') && trimmed.endsWith('}')) || (trimmed.startsWith('[') && trimmed.endsWith(']'));
|
|
31
|
+
if (!looksLikeJson)
|
|
32
|
+
return value;
|
|
33
|
+
try {
|
|
34
|
+
return JSON.stringify(redactSensitiveValue(JSON.parse(value)));
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const redactSensitiveValue = (value) => {
|
|
41
|
+
if (Array.isArray(value))
|
|
42
|
+
return value.map(redactSensitiveValue);
|
|
43
|
+
if (typeof value === 'string')
|
|
44
|
+
return redactSensitiveJsonString(value);
|
|
45
|
+
if (!value || typeof value !== 'object')
|
|
46
|
+
return value;
|
|
47
|
+
const result = {};
|
|
48
|
+
for (const key of Object.keys(value)) {
|
|
49
|
+
result[key] = key.toLowerCase() === SENSITIVE_KEY ? '***' : redactSensitiveValue(value[key]);
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
};
|
|
53
|
+
export const sanitizeException = (exception) => {
|
|
54
|
+
if (exception === null || exception === undefined)
|
|
55
|
+
return exception;
|
|
56
|
+
let plain;
|
|
57
|
+
try {
|
|
58
|
+
plain = JSON.parse(JSON.stringify(exception));
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return exception;
|
|
62
|
+
}
|
|
63
|
+
return redactSensitiveValue(plain);
|
|
64
|
+
};
|
|
26
65
|
const StyledExeptionToolbar = styled.div `
|
|
27
66
|
display: flex;
|
|
28
67
|
flex-direction: row;
|
|
@@ -273,6 +312,7 @@ const TMExceptionBox = ({ resizable = false, exception, title = `${SDK_Globals.a
|
|
|
273
312
|
let dateString = d.getDate() + '/' + d.getMonth() + 1 + '/' + d.getFullYear();
|
|
274
313
|
let timeString = d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds() + ':' + d.getMilliseconds();
|
|
275
314
|
let message = getExceptionMessage(exception);
|
|
315
|
+
const safeException = useMemo(() => sanitizeException(exception), [exception]);
|
|
276
316
|
let deviceType = useDeviceType();
|
|
277
317
|
/**
|
|
278
318
|
* Gestore chiamato quando il popup viene mostrato.
|
|
@@ -304,7 +344,7 @@ const TMExceptionBox = ({ resizable = false, exception, title = `${SDK_Globals.a
|
|
|
304
344
|
};
|
|
305
345
|
const getFullMessage = () => {
|
|
306
346
|
let fullMessage = '';
|
|
307
|
-
fullMessage += `${d}\n${'-' + JSON.stringify(
|
|
347
|
+
fullMessage += `${d}\n${'-' + JSON.stringify(safeException)}\n` + `-${SDK_Globals.appModule}: ${SDK_Globals.appVersion}\n` + `-SDKUI: ${SDK_Globals.sdkuiVersion}\n` + `-SDK: ${SDK_Globals.sdkVersion}\n`;
|
|
308
348
|
return fullMessage.replaceAll('{', '').replaceAll('}', '').replaceAll(`":`, '=').replaceAll(`,"`, '\n').replaceAll(`"`, '');
|
|
309
349
|
};
|
|
310
350
|
const copyToClipBoard = (e) => {
|
|
@@ -331,7 +371,7 @@ const TMExceptionBox = ({ resizable = false, exception, title = `${SDK_Globals.a
|
|
|
331
371
|
const ExceptionToolbar = () => {
|
|
332
372
|
return (_jsxs(StyledExeptionToolbar, { children: [_jsx(TMButton, { color: 'primaryOutline', btnStyle: 'text', onClick: () => copyToClipBoard(getFullMessage()), caption: SDKUI_Localizator.CopyToClipboard, showTooltip: false }), _jsx(TMButton, { btnStyle: 'text', onClick: () => { onClose?.(); setIsVisible(false); }, caption: SDKUI_Localizator.Close, showTooltip: false, color: 'error' })] }));
|
|
333
373
|
};
|
|
334
|
-
return (_jsx(Popup, { ref: popupRef, resizeEnabled: resizable, visible: isVisible, onHidden: () => { onClose?.(); setIsVisible(false); }, onShown: handleShown, showCloseButton: true, width: calcResponsiveSizes(deviceType, '600px', '400px', '350px'), height: '350px', minWidth: minWidth, minHeight: minHeight, maxHeight: '95%', maxWidth: '95%', title: title, children: _jsxs(TMLayoutContainer, { children: [_jsx(TMLayoutItem, { height: 'calc(100% - 50px)', children: _jsxs(TMTabGroup, { validationItems: [], children: [_jsxs(TMTab, { label: SDKUI_Localizator.Error, children: [_jsxs(TabContextContainer, { style: { height: 'calc(100% - 68px )', paddingRight: '40px' }, children: [_jsxs("p", { children: [" ", _jsx("span", { style: { color: TMColors.primary }, children: "Messaggio: " }), " ", message] }), _jsx("div", { style: { display: 'flex', flexDirection: 'column', justifyContent: 'flex-start', alignItems: 'flex-start', gap: '5px', marginTop: '5px' }, children: _jsxs("div", { children: [_jsxs("span", { style: { color: TMColors.primary }, children: [SDKUI_Localizator.Date, " ", SDKUI_Localizator.Time.toLowerCase(), ": "] }), d.toString()] }) })] }), _jsxs(StyledCopyInclipBoardButtonContainer, { children: [" ", _jsx(TMButton, { color: 'primaryOutline', onClick: () => copyToClipBoard(`Date: ${dateString}\nTime: ${timeString}\nMessage: ${message}`), btnStyle: 'toolbar', icon: _jsx(IconCopy, { fontSize: 18 }), caption: SDKUI_Localizator.CopyToClipboard }), " "] })] }), _jsxs(TMTab, { label: SDKUI_Localizator.CompleteError, children: [_jsx(TabContextContainer, { style: { paddingRight: '40px' }, children: JSON.stringify(
|
|
374
|
+
return (_jsx(Popup, { ref: popupRef, resizeEnabled: resizable, visible: isVisible, onHidden: () => { onClose?.(); setIsVisible(false); }, onShown: handleShown, showCloseButton: true, width: calcResponsiveSizes(deviceType, '600px', '400px', '350px'), height: '350px', minWidth: minWidth, minHeight: minHeight, maxHeight: '95%', maxWidth: '95%', title: title, children: _jsxs(TMLayoutContainer, { children: [_jsx(TMLayoutItem, { height: 'calc(100% - 50px)', children: _jsxs(TMTabGroup, { validationItems: [], children: [_jsxs(TMTab, { label: SDKUI_Localizator.Error, children: [_jsxs(TabContextContainer, { style: { height: 'calc(100% - 68px )', paddingRight: '40px' }, children: [_jsxs("p", { children: [" ", _jsx("span", { style: { color: TMColors.primary }, children: "Messaggio: " }), " ", message] }), _jsx("div", { style: { display: 'flex', flexDirection: 'column', justifyContent: 'flex-start', alignItems: 'flex-start', gap: '5px', marginTop: '5px' }, children: _jsxs("div", { children: [_jsxs("span", { style: { color: TMColors.primary }, children: [SDKUI_Localizator.Date, " ", SDKUI_Localizator.Time.toLowerCase(), ": "] }), d.toString()] }) })] }), _jsxs(StyledCopyInclipBoardButtonContainer, { children: [" ", _jsx(TMButton, { color: 'primaryOutline', onClick: () => copyToClipBoard(`Date: ${dateString}\nTime: ${timeString}\nMessage: ${message}`), btnStyle: 'toolbar', icon: _jsx(IconCopy, { fontSize: 18 }), caption: SDKUI_Localizator.CopyToClipboard }), " "] })] }), _jsxs(TMTab, { label: SDKUI_Localizator.CompleteError, children: [_jsx(TabContextContainer, { style: { paddingRight: '40px' }, children: JSON.stringify(safeException).replaceAll('{', '').replaceAll('}', '').split(`,"`).map((t, index) => (_jsxs("div", { style: { padding: '5px', borderBottom: '1px solid rgb(180,180,180)' }, children: ["\u261B", ' ' + (t.toLowerCase().includes('detail') ? (t.replaceAll(`"`, '').replaceAll(`:`, ': ').replaceAll(String.fromCharCode(92), '')) : (t.replaceAll(`"`, '').replaceAll(`:`, ': ')))] }, index))) }), _jsxs(StyledCopyInclipBoardButtonContainer, { children: [" ", _jsx(TMButton, { color: 'primaryOutline', onClick: () => copyToClipBoard(JSON.stringify(safeException).replaceAll('{', '').replaceAll('}', '').replaceAll(',', '\n')), btnStyle: 'toolbar', icon: _jsx(IconCopy, { fontSize: 18 }), caption: SDKUI_Localizator.CopyToClipboard }), " "] })] }), _jsxs(TMTab, { label: SDKUI_Localizator.Details, children: [_jsxs(TabContextContainer, { children: [_jsxs(StyledAppVersionText, { "$color": TMColors.primary, children: [SDK_Globals.appModule, " ", _jsx("span", { style: { fontWeight: 'bold' }, children: SDK_Globals.appVersion })] }), _jsxs(StyledAppVersionText, { "$color": TMColors.tertiary, children: ["SDKUI: ", _jsx("span", { style: { fontWeight: 'bold' }, children: SDK_Globals.sdkuiVersion })] }), _jsxs(StyledAppVersionText, { "$color": TMColors.success, children: ["SDK : ", _jsx("span", { style: { fontWeight: 'bold' }, children: SDK_Globals.sdkVersion })] })] }), _jsxs(StyledCopyInclipBoardButtonContainer, { children: [" ", _jsx(TMButton, { color: 'primaryOutline', onClick: () => copyToClipBoard(`-${SDK_Globals.appModule}: ${SDK_Globals.appVersion}\n` + `-SDKUI: ${SDK_Globals.sdkuiVersion}\n` + `-SDK: ${SDK_Globals.sdkVersion}\n`), btnStyle: 'toolbar', icon: _jsx(IconCopy, { fontSize: 18 }), caption: SDKUI_Localizator.CopyToClipboard }), " "] })] })] }) }), _jsx(TMLayoutItem, { height: '40px', children: _jsx(ExceptionToolbar, {}) })] }) }));
|
|
335
375
|
};
|
|
336
376
|
class TMExceptionBoxManager {
|
|
337
377
|
static show({ title, exception, onClose }) {
|
|
@@ -33,7 +33,7 @@ import { TMColors } from "../../../utils/theme";
|
|
|
33
33
|
import ShowAlert from "../../base/TMAlert";
|
|
34
34
|
import TMButton from "../../base/TMButton";
|
|
35
35
|
import { useDeviceType, DeviceType } from "../../base/TMDeviceProvider";
|
|
36
|
-
import { TMExceptionBoxManager, TMMessageBoxManager, ButtonNames } from "../../base/TMPopUp";
|
|
36
|
+
import { TMExceptionBoxManager, TMMessageBoxManager, ButtonNames, sanitizeException } from "../../base/TMPopUp";
|
|
37
37
|
import TMSpinner from "../../base/TMSpinner";
|
|
38
38
|
import TMTooltip from "../../base/TMTooltip";
|
|
39
39
|
import TMCheckBox from "../../editors/TMCheckBox";
|
|
@@ -522,7 +522,7 @@ const TMLoginForm = (props) => {
|
|
|
522
522
|
return true;
|
|
523
523
|
}
|
|
524
524
|
catch (e) {
|
|
525
|
-
TMExceptionBoxManager.show({ exception: e });
|
|
525
|
+
TMExceptionBoxManager.show({ exception: sanitizeException(e) });
|
|
526
526
|
return false;
|
|
527
527
|
}
|
|
528
528
|
finally {
|
|
@@ -558,7 +558,7 @@ const TMLoginForm = (props) => {
|
|
|
558
558
|
}
|
|
559
559
|
}
|
|
560
560
|
catch (e) {
|
|
561
|
-
TMExceptionBoxManager.show({ exception: e });
|
|
561
|
+
TMExceptionBoxManager.show({ exception: sanitizeException(e) });
|
|
562
562
|
}
|
|
563
563
|
finally {
|
|
564
564
|
TMSpinner.hide();
|