@microsoft/omnichannel-chat-widget 1.8.1-main.3ee330c → 1.8.1-main.565f247
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/lib/cjs/common/facades/FacadeChatSDK.js +0 -42
- package/lib/cjs/common/telemetry/TelemetryConstants.js +0 -4
- package/lib/cjs/common/telemetry/TelemetryManager.js +2 -2
- package/lib/cjs/common/utils.js +0 -3
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +3 -7
- package/lib/cjs/components/livechatwidget/LiveChatWidget.js +4 -15
- package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +1 -1
- package/lib/cjs/components/livechatwidget/common/persistentChatHelper.js +5 -12
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +0 -4
- package/lib/cjs/components/livechatwidget/common/startChat.js +2 -2
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +1 -30
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +19 -31
- package/lib/cjs/components/ooohpanestateful/OOOHPaneStateful.js +2 -23
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +5 -14
- package/lib/cjs/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.js +0 -1
- package/lib/esm/common/facades/FacadeChatSDK.js +0 -42
- package/lib/esm/common/telemetry/TelemetryConstants.js +0 -4
- package/lib/esm/common/telemetry/TelemetryManager.js +2 -2
- package/lib/esm/common/utils.js +0 -3
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +3 -7
- package/lib/esm/components/livechatwidget/LiveChatWidget.js +5 -16
- package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +1 -1
- package/lib/esm/components/livechatwidget/common/persistentChatHelper.js +5 -12
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +0 -4
- package/lib/esm/components/livechatwidget/common/startChat.js +2 -2
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +0 -28
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +19 -31
- package/lib/esm/components/ooohpanestateful/OOOHPaneStateful.js +2 -23
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +5 -14
- package/lib/esm/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.js +0 -1
- package/lib/types/common/facades/FacadeChatSDK.d.ts +0 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +0 -4
- package/lib/types/components/livechatwidget/common/liveChatConfigUtils.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/persistentChatHelper.d.ts +1 -2
- package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +0 -1
- package/lib/types/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.d.ts +1 -2
- package/lib/types/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.d.ts +0 -1
- package/package.json +2 -2
- package/lib/cjs/common/utils/xssUtils.js +0 -79
- package/lib/cjs/components/errorboundary/ErrorBoundary.js +0 -68
- package/lib/esm/common/utils/xssUtils.js +0 -72
- package/lib/esm/components/errorboundary/ErrorBoundary.js +0 -59
- package/lib/types/common/utils/xssUtils.d.ts +0 -29
- package/lib/types/components/errorboundary/ErrorBoundary.d.ts +0 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/omnichannel-chat-widget",
|
|
3
|
-
"version": "1.8.1-main.
|
|
3
|
+
"version": "1.8.1-main.565f247",
|
|
4
4
|
"description": "Microsoft Omnichannel Chat Widget",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"types": "lib/types/index.d.ts",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"@azure/core-tracing": "^1.2.0",
|
|
88
88
|
"@microsoft/applicationinsights-web": "^3.3.6",
|
|
89
89
|
"@microsoft/omnichannel-chat-components": "1.1.12",
|
|
90
|
-
"@microsoft/omnichannel-chat-sdk": "^1.11.
|
|
90
|
+
"@microsoft/omnichannel-chat-sdk": "^1.11.1",
|
|
91
91
|
"@opentelemetry/api": "^1.9.0",
|
|
92
92
|
"abort-controller": "^3",
|
|
93
93
|
"abort-controller-es5": "^2.0.1",
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.detectAndCleanXSS = void 0;
|
|
7
|
-
var _dompurify = _interopRequireDefault(require("dompurify"));
|
|
8
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
-
/**
|
|
10
|
-
* Detects potential Cross-Site Scripting (XSS) attacks in text input and sanitizes the content.
|
|
11
|
-
*
|
|
12
|
-
* This function performs comprehensive XSS detection using pattern matching for common attack vectors
|
|
13
|
-
* and then sanitizes the input using DOMPurify with strict configuration. It's designed to protect
|
|
14
|
-
* against various XSS techniques including script injection, event handler injection, style-based
|
|
15
|
-
* attacks, and encoded payloads.
|
|
16
|
-
*
|
|
17
|
-
* Security patterns detected:
|
|
18
|
-
* - JavaScript protocol URLs (javascript:)
|
|
19
|
-
* - HTML event handlers (onmouseover, onclick, etc.)
|
|
20
|
-
* - Script tags (<script>)
|
|
21
|
-
* - CSS expression() functions
|
|
22
|
-
* - CSS url() functions
|
|
23
|
-
* - Position-based CSS attacks (position: fixed/absolute)
|
|
24
|
-
* - VBScript protocol URLs
|
|
25
|
-
* - Data URLs with HTML content
|
|
26
|
-
* - Fragment identifiers with escaped quotes
|
|
27
|
-
* - HTML entity-encoded angle brackets
|
|
28
|
-
*
|
|
29
|
-
* @param text - The input text to be analyzed and sanitized
|
|
30
|
-
* @returns An object containing:
|
|
31
|
-
* - cleanText: The sanitized version of the input text with all HTML tags and attributes removed
|
|
32
|
-
* - isXSSDetected: Boolean flag indicating whether potential XSS patterns were found in the original text
|
|
33
|
-
*/
|
|
34
|
-
const detectAndCleanXSS = text => {
|
|
35
|
-
// Comprehensive array of regular expressions to detect common XSS attack patterns
|
|
36
|
-
const xssPatterns = [/javascript\s*:/gi,
|
|
37
|
-
// JavaScript protocol URLs (with optional spaces)
|
|
38
|
-
/vbscript\s*:/gi,
|
|
39
|
-
// VBScript protocol URLs (with optional spaces)
|
|
40
|
-
/on\w+\s*=/gi,
|
|
41
|
-
// HTML event handlers (onmouseover, onclick, onload, etc.)
|
|
42
|
-
/<\s*script/gi,
|
|
43
|
-
// Script tag opening (with optional spaces)
|
|
44
|
-
/expression\s*\(/gi,
|
|
45
|
-
// CSS expression() function (IE-specific)
|
|
46
|
-
/url\s*\(/gi,
|
|
47
|
-
// CSS url() function
|
|
48
|
-
/style\s*=.*position\s*:\s*fixed/gi,
|
|
49
|
-
// CSS position fixed attacks
|
|
50
|
-
/style\s*=.*position\s*:\s*absolute/gi,
|
|
51
|
-
// CSS position absolute attacks
|
|
52
|
-
/data\s*:\s*text\s*\/\s*html/gi,
|
|
53
|
-
// Data URLs containing HTML
|
|
54
|
-
/#.*\\"/gi,
|
|
55
|
-
// Fragment identifiers with escaped quotes
|
|
56
|
-
/>.*</gi // HTML entity-encoded angle brackets indicating tag structure
|
|
57
|
-
];
|
|
58
|
-
|
|
59
|
-
// Check if any XSS patterns are detected in the input text
|
|
60
|
-
const isXSSDetected = xssPatterns.some(pattern => pattern.test(text));
|
|
61
|
-
|
|
62
|
-
// Clean the text using DOMPurify with strict config
|
|
63
|
-
const cleanText = _dompurify.default.sanitize(text, {
|
|
64
|
-
ALLOWED_TAGS: [],
|
|
65
|
-
// No HTML tags allowed in title
|
|
66
|
-
ALLOWED_ATTR: [],
|
|
67
|
-
KEEP_CONTENT: true,
|
|
68
|
-
// Keep text content
|
|
69
|
-
ALLOW_DATA_ATTR: false,
|
|
70
|
-
ALLOW_UNKNOWN_PROTOCOLS: false,
|
|
71
|
-
SANITIZE_DOM: true,
|
|
72
|
-
FORCE_BODY: false
|
|
73
|
-
});
|
|
74
|
-
return {
|
|
75
|
-
cleanText,
|
|
76
|
-
isXSSDetected
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
exports.detectAndCleanXSS = detectAndCleanXSS;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
9
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
10
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
12
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
14
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
15
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
16
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
17
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
18
|
-
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
19
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
20
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
21
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
22
|
-
const RenderChildrenFunction = _ref => {
|
|
23
|
-
let {
|
|
24
|
-
children
|
|
25
|
-
} = _ref;
|
|
26
|
-
return typeof children === 'function' ? children() : children;
|
|
27
|
-
};
|
|
28
|
-
let ErrorBoundary = /*#__PURE__*/function (_Component) {
|
|
29
|
-
_inherits(ErrorBoundary, _Component);
|
|
30
|
-
var _super = _createSuper(ErrorBoundary);
|
|
31
|
-
function ErrorBoundary(props) {
|
|
32
|
-
var _this;
|
|
33
|
-
_classCallCheck(this, ErrorBoundary);
|
|
34
|
-
_this = _super.call(this, props);
|
|
35
|
-
_this.state = {
|
|
36
|
-
hasError: false
|
|
37
|
-
};
|
|
38
|
-
return _this;
|
|
39
|
-
}
|
|
40
|
-
_createClass(ErrorBoundary, [{
|
|
41
|
-
key: "componentDidCatch",
|
|
42
|
-
value: function componentDidCatch(error) {
|
|
43
|
-
const {
|
|
44
|
-
onError
|
|
45
|
-
} = this.props;
|
|
46
|
-
this.setState({
|
|
47
|
-
hasError: true
|
|
48
|
-
});
|
|
49
|
-
if (onError) {
|
|
50
|
-
onError(error);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}, {
|
|
54
|
-
key: "render",
|
|
55
|
-
value: function render() {
|
|
56
|
-
const {
|
|
57
|
-
children
|
|
58
|
-
} = this.props;
|
|
59
|
-
const {
|
|
60
|
-
hasError
|
|
61
|
-
} = this.state;
|
|
62
|
-
return !hasError && /*#__PURE__*/_react.default.createElement(RenderChildrenFunction, null, children);
|
|
63
|
-
}
|
|
64
|
-
}]);
|
|
65
|
-
return ErrorBoundary;
|
|
66
|
-
}(_react.Component);
|
|
67
|
-
var _default = ErrorBoundary;
|
|
68
|
-
exports.default = _default;
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import DOMPurify from "dompurify";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Detects potential Cross-Site Scripting (XSS) attacks in text input and sanitizes the content.
|
|
5
|
-
*
|
|
6
|
-
* This function performs comprehensive XSS detection using pattern matching for common attack vectors
|
|
7
|
-
* and then sanitizes the input using DOMPurify with strict configuration. It's designed to protect
|
|
8
|
-
* against various XSS techniques including script injection, event handler injection, style-based
|
|
9
|
-
* attacks, and encoded payloads.
|
|
10
|
-
*
|
|
11
|
-
* Security patterns detected:
|
|
12
|
-
* - JavaScript protocol URLs (javascript:)
|
|
13
|
-
* - HTML event handlers (onmouseover, onclick, etc.)
|
|
14
|
-
* - Script tags (<script>)
|
|
15
|
-
* - CSS expression() functions
|
|
16
|
-
* - CSS url() functions
|
|
17
|
-
* - Position-based CSS attacks (position: fixed/absolute)
|
|
18
|
-
* - VBScript protocol URLs
|
|
19
|
-
* - Data URLs with HTML content
|
|
20
|
-
* - Fragment identifiers with escaped quotes
|
|
21
|
-
* - HTML entity-encoded angle brackets
|
|
22
|
-
*
|
|
23
|
-
* @param text - The input text to be analyzed and sanitized
|
|
24
|
-
* @returns An object containing:
|
|
25
|
-
* - cleanText: The sanitized version of the input text with all HTML tags and attributes removed
|
|
26
|
-
* - isXSSDetected: Boolean flag indicating whether potential XSS patterns were found in the original text
|
|
27
|
-
*/
|
|
28
|
-
export const detectAndCleanXSS = text => {
|
|
29
|
-
// Comprehensive array of regular expressions to detect common XSS attack patterns
|
|
30
|
-
const xssPatterns = [/javascript\s*:/gi,
|
|
31
|
-
// JavaScript protocol URLs (with optional spaces)
|
|
32
|
-
/vbscript\s*:/gi,
|
|
33
|
-
// VBScript protocol URLs (with optional spaces)
|
|
34
|
-
/on\w+\s*=/gi,
|
|
35
|
-
// HTML event handlers (onmouseover, onclick, onload, etc.)
|
|
36
|
-
/<\s*script/gi,
|
|
37
|
-
// Script tag opening (with optional spaces)
|
|
38
|
-
/expression\s*\(/gi,
|
|
39
|
-
// CSS expression() function (IE-specific)
|
|
40
|
-
/url\s*\(/gi,
|
|
41
|
-
// CSS url() function
|
|
42
|
-
/style\s*=.*position\s*:\s*fixed/gi,
|
|
43
|
-
// CSS position fixed attacks
|
|
44
|
-
/style\s*=.*position\s*:\s*absolute/gi,
|
|
45
|
-
// CSS position absolute attacks
|
|
46
|
-
/data\s*:\s*text\s*\/\s*html/gi,
|
|
47
|
-
// Data URLs containing HTML
|
|
48
|
-
/#.*\\"/gi,
|
|
49
|
-
// Fragment identifiers with escaped quotes
|
|
50
|
-
/>.*</gi // HTML entity-encoded angle brackets indicating tag structure
|
|
51
|
-
];
|
|
52
|
-
|
|
53
|
-
// Check if any XSS patterns are detected in the input text
|
|
54
|
-
const isXSSDetected = xssPatterns.some(pattern => pattern.test(text));
|
|
55
|
-
|
|
56
|
-
// Clean the text using DOMPurify with strict config
|
|
57
|
-
const cleanText = DOMPurify.sanitize(text, {
|
|
58
|
-
ALLOWED_TAGS: [],
|
|
59
|
-
// No HTML tags allowed in title
|
|
60
|
-
ALLOWED_ATTR: [],
|
|
61
|
-
KEEP_CONTENT: true,
|
|
62
|
-
// Keep text content
|
|
63
|
-
ALLOW_DATA_ATTR: false,
|
|
64
|
-
ALLOW_UNKNOWN_PROTOCOLS: false,
|
|
65
|
-
SANITIZE_DOM: true,
|
|
66
|
-
FORCE_BODY: false
|
|
67
|
-
});
|
|
68
|
-
return {
|
|
69
|
-
cleanText,
|
|
70
|
-
isXSSDetected
|
|
71
|
-
};
|
|
72
|
-
};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
3
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
4
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
5
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
6
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
7
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
8
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
9
|
-
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
10
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
11
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
12
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
13
|
-
import React, { Component } from 'react';
|
|
14
|
-
const RenderChildrenFunction = _ref => {
|
|
15
|
-
let {
|
|
16
|
-
children
|
|
17
|
-
} = _ref;
|
|
18
|
-
return typeof children === 'function' ? children() : children;
|
|
19
|
-
};
|
|
20
|
-
let ErrorBoundary = /*#__PURE__*/function (_Component) {
|
|
21
|
-
_inherits(ErrorBoundary, _Component);
|
|
22
|
-
var _super = _createSuper(ErrorBoundary);
|
|
23
|
-
function ErrorBoundary(props) {
|
|
24
|
-
var _this;
|
|
25
|
-
_classCallCheck(this, ErrorBoundary);
|
|
26
|
-
_this = _super.call(this, props);
|
|
27
|
-
_this.state = {
|
|
28
|
-
hasError: false
|
|
29
|
-
};
|
|
30
|
-
return _this;
|
|
31
|
-
}
|
|
32
|
-
_createClass(ErrorBoundary, [{
|
|
33
|
-
key: "componentDidCatch",
|
|
34
|
-
value: function componentDidCatch(error) {
|
|
35
|
-
const {
|
|
36
|
-
onError
|
|
37
|
-
} = this.props;
|
|
38
|
-
this.setState({
|
|
39
|
-
hasError: true
|
|
40
|
-
});
|
|
41
|
-
if (onError) {
|
|
42
|
-
onError(error);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}, {
|
|
46
|
-
key: "render",
|
|
47
|
-
value: function render() {
|
|
48
|
-
const {
|
|
49
|
-
children
|
|
50
|
-
} = this.props;
|
|
51
|
-
const {
|
|
52
|
-
hasError
|
|
53
|
-
} = this.state;
|
|
54
|
-
return !hasError && /*#__PURE__*/React.createElement(RenderChildrenFunction, null, children);
|
|
55
|
-
}
|
|
56
|
-
}]);
|
|
57
|
-
return ErrorBoundary;
|
|
58
|
-
}(Component);
|
|
59
|
-
export default ErrorBoundary;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Detects potential Cross-Site Scripting (XSS) attacks in text input and sanitizes the content.
|
|
3
|
-
*
|
|
4
|
-
* This function performs comprehensive XSS detection using pattern matching for common attack vectors
|
|
5
|
-
* and then sanitizes the input using DOMPurify with strict configuration. It's designed to protect
|
|
6
|
-
* against various XSS techniques including script injection, event handler injection, style-based
|
|
7
|
-
* attacks, and encoded payloads.
|
|
8
|
-
*
|
|
9
|
-
* Security patterns detected:
|
|
10
|
-
* - JavaScript protocol URLs (javascript:)
|
|
11
|
-
* - HTML event handlers (onmouseover, onclick, etc.)
|
|
12
|
-
* - Script tags (<script>)
|
|
13
|
-
* - CSS expression() functions
|
|
14
|
-
* - CSS url() functions
|
|
15
|
-
* - Position-based CSS attacks (position: fixed/absolute)
|
|
16
|
-
* - VBScript protocol URLs
|
|
17
|
-
* - Data URLs with HTML content
|
|
18
|
-
* - Fragment identifiers with escaped quotes
|
|
19
|
-
* - HTML entity-encoded angle brackets
|
|
20
|
-
*
|
|
21
|
-
* @param text - The input text to be analyzed and sanitized
|
|
22
|
-
* @returns An object containing:
|
|
23
|
-
* - cleanText: The sanitized version of the input text with all HTML tags and attributes removed
|
|
24
|
-
* - isXSSDetected: Boolean flag indicating whether potential XSS patterns were found in the original text
|
|
25
|
-
*/
|
|
26
|
-
export declare const detectAndCleanXSS: (text: string) => {
|
|
27
|
-
cleanText: string;
|
|
28
|
-
isXSSDetected: boolean;
|
|
29
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React, { Component } from 'react';
|
|
2
|
-
interface ErrorBoundaryProps {
|
|
3
|
-
children: React.ReactNode | (() => React.ReactNode);
|
|
4
|
-
onError?: (error: Error) => void;
|
|
5
|
-
}
|
|
6
|
-
interface ErrorBoundaryState {
|
|
7
|
-
hasError: boolean;
|
|
8
|
-
}
|
|
9
|
-
declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
10
|
-
constructor(props: ErrorBoundaryProps);
|
|
11
|
-
componentDidCatch(error: Error): void;
|
|
12
|
-
render(): false | React.JSX.Element;
|
|
13
|
-
}
|
|
14
|
-
export default ErrorBoundary;
|