@microsoft/omnichannel-chat-widget 1.8.1-main.20b15cc → 1.8.1-main.4fb8cb5

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.
Files changed (38) hide show
  1. package/lib/cjs/common/telemetry/TelemetryConstants.js +4 -0
  2. package/lib/cjs/common/telemetry/TelemetryManager.js +4 -4
  3. package/lib/cjs/common/telemetry/loggers/appInsightsLogger.js +4 -5
  4. package/lib/cjs/common/utils/xssUtils.js +79 -0
  5. package/lib/cjs/common/utils.js +3 -0
  6. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +7 -3
  7. package/lib/cjs/components/errorboundary/ErrorBoundary.js +68 -0
  8. package/lib/cjs/components/livechatwidget/LiveChatWidget.js +12 -2
  9. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +4 -0
  10. package/lib/cjs/components/livechatwidget/common/startChat.js +1 -7
  11. package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +30 -1
  12. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +31 -19
  13. package/lib/cjs/components/ooohpanestateful/OOOHPaneStateful.js +23 -2
  14. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +14 -5
  15. package/lib/cjs/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.js +1 -0
  16. package/lib/esm/common/telemetry/TelemetryConstants.js +4 -0
  17. package/lib/esm/common/telemetry/TelemetryManager.js +4 -4
  18. package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +4 -5
  19. package/lib/esm/common/utils/xssUtils.js +72 -0
  20. package/lib/esm/common/utils.js +3 -0
  21. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +7 -3
  22. package/lib/esm/components/errorboundary/ErrorBoundary.js +59 -0
  23. package/lib/esm/components/livechatwidget/LiveChatWidget.js +13 -3
  24. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +4 -0
  25. package/lib/esm/components/livechatwidget/common/startChat.js +1 -7
  26. package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +28 -0
  27. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +31 -19
  28. package/lib/esm/components/ooohpanestateful/OOOHPaneStateful.js +23 -2
  29. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +14 -5
  30. package/lib/esm/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.js +1 -0
  31. package/lib/types/common/telemetry/TelemetryConstants.d.ts +4 -0
  32. package/lib/types/common/telemetry/loggers/appInsightsLogger.d.ts +1 -1
  33. package/lib/types/common/utils/xssUtils.d.ts +29 -0
  34. package/lib/types/components/errorboundary/ErrorBoundary.d.ts +14 -0
  35. package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +1 -0
  36. package/lib/types/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.d.ts +2 -1
  37. package/lib/types/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.d.ts +1 -0
  38. package/package.json +2 -2
@@ -9,13 +9,14 @@ import { defaultGeneralPostChatSurveyPaneStyleProps } from "./common/defaultStyl
9
9
  import { findAllFocusableElement } from "../../common/utils";
10
10
  import useChatContextStore from "../../hooks/useChatContextStore";
11
11
  import isValidSurveyUrl from "./common/isValidSurveyUrl";
12
- const generateSurveyInviteLink = function (surveyInviteLink, isEmbed, locale, compact) {
13
- let showMultiLingual = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
12
+ const generateSurveyInviteLink = function (surveyInviteLink, isEmbed, locale, compact, customerVoiceSurveyCorrelationId) {
13
+ let showMultiLingual = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
14
14
  const surveyLinkParams = new URLSearchParams({
15
15
  embed: isEmbed.toString(),
16
16
  compact: (compact ?? true).toString(),
17
17
  lang: locale ?? "en-us",
18
- showmultilingual: (showMultiLingual ?? false).toString()
18
+ showmultilingual: (showMultiLingual ?? false).toString(),
19
+ cvResponsePageRequestId: customerVoiceSurveyCorrelationId
19
20
  });
20
21
  return `${surveyInviteLink}&${surveyLinkParams.toString()}`;
21
22
  };
@@ -31,9 +32,9 @@ export const PostChatSurveyPaneStateful = props => {
31
32
  // Bot survey enabled
32
33
  state.appStates.postChatParticipantType === ParticipantType.Bot) {
33
34
  // Only Bot has engaged
34
- surveyInviteLink = generateSurveyInviteLink(state.domainStates.postChatContext.botSurveyInviteLink, surveyMode, state.domainStates.postChatContext.botFormsProLocale, props.isCustomerVoiceSurveyCompact ?? true);
35
+ surveyInviteLink = generateSurveyInviteLink(state.domainStates.postChatContext.botSurveyInviteLink, surveyMode, state.domainStates.postChatContext.botFormsProLocale, props.isCustomerVoiceSurveyCompact ?? true, props.customerVoiceSurveyCorrelationId || "");
35
36
  } else {
36
- surveyInviteLink = generateSurveyInviteLink(state.domainStates.postChatContext.surveyInviteLink, surveyMode, state.domainStates.postChatContext.formsProLocale, props.isCustomerVoiceSurveyCompact ?? true);
37
+ surveyInviteLink = generateSurveyInviteLink(state.domainStates.postChatContext.surveyInviteLink, surveyMode, state.domainStates.postChatContext.formsProLocale, props.isCustomerVoiceSurveyCompact ?? true, props.customerVoiceSurveyCorrelationId || "");
37
38
  }
38
39
  if (props.copilotSurveyContext) {
39
40
  surveyInviteLink = `${surveyInviteLink}&mcs_additionalcontext=${JSON.stringify(props.copilotSurveyContext)}`;
@@ -96,6 +97,14 @@ export const PostChatSurveyPaneStateful = props => {
96
97
  message: "Customer Voice form response error."
97
98
  }
98
99
  });
100
+ } else if (typeof data === "string" && data.startsWith(CustomerVoiceEvents.FormsError)) {
101
+ TelemetryHelper.logActionEventToAllTelemetry(LogLevel.ERROR, {
102
+ Event: TelemetryEvent.CustomerVoiceFormsError,
103
+ Description: "Customer Voice failed to load with forms error.",
104
+ ExceptionDetails: {
105
+ message: `Customer Voice forms error details: ${data}`
106
+ }
107
+ });
99
108
  }
100
109
  });
101
110
  }, []);
@@ -3,4 +3,5 @@ export let CustomerVoiceEvents;
3
3
  CustomerVoiceEvents["ResponsePageLoaded"] = "ResponsePageLoaded";
4
4
  CustomerVoiceEvents["FormResponseSubmitted"] = "FormResponseSubmitted";
5
5
  CustomerVoiceEvents["FormResponseError"] = "FormResponseError";
6
+ CustomerVoiceEvents["FormsError"] = "FormsError";
6
7
  })(CustomerVoiceEvents || (CustomerVoiceEvents = {}));
@@ -94,6 +94,8 @@ export declare enum TelemetryEvent {
94
94
  DisconnectEndChatSDKCallFailed = "DisconnectEndChatSDKCallFailed",
95
95
  GetChatReconnectContextSDKCallStarted = "GetChatReconnectContextSDKCallStarted",
96
96
  GetChatReconnectContextSDKCallFailed = "GetChatReconnectContextSDKCallFailed",
97
+ CheckContactIdError = "checkContactIdError",
98
+ GetChatReconnectContextSDKCallSucceeded = "GetChatReconnectContextSDKCallSucceeded",
97
99
  ParseAdaptiveCardFailed = "ParseAdaptiveCardFailed",
98
100
  ClientDataStoreProviderFailed = "ClientDataStoreProviderFailed",
99
101
  InMemoryDataStoreFailed = "InMemoryDataStoreFailed",
@@ -161,6 +163,7 @@ export declare enum TelemetryEvent {
161
163
  CustomerVoiceResponsePageLoaded = "CustomerVoiceResponsePageLoaded",
162
164
  CustomerVoiceFormResponseSubmitted = "CustomerVoiceFormResponseSubmitted",
163
165
  CustomerVoiceFormResponseError = "CustomerVoiceFormResponseError",
166
+ CustomerVoiceFormsError = "CustomerVoiceFormsError",
164
167
  BotAuthActivityEmptySasUrl = "BotAuthActivityEmptySasUrl",
165
168
  SetBotAuthProviderFetchConfig = "SetBotAuthProviderFetchConfig",
166
169
  SetBotAuthProviderHideCard = "SetBotAuthProviderHideCard",
@@ -238,6 +241,7 @@ export declare enum TelemetryEvent {
238
241
  UXNotificationPaneCompleted = "UXNotificationPaneCompleted",
239
242
  UXOutOfOfficeHoursPaneStart = "UXOutOfOfficeHoursPaneStart",
240
243
  UXOutOfOfficeHoursPaneCompleted = "UXOutOfOfficeHoursPaneCompleted",
244
+ XSSTextDetected = "XSSTextDetected",
241
245
  UXPostChatLoadingPaneStart = "UXPostChatLoadingPaneStart",
242
246
  UXPostChatLoadingPaneCompleted = "UXPostChatLoadingPaneCompleted",
243
247
  UXPrechatPaneStart = "UXPrechatPaneStart",
@@ -4,7 +4,7 @@ declare global {
4
4
  appInsights?: any;
5
5
  }
6
6
  }
7
- export declare const appInsightsLogger: (appInsightsKey: string, disableCookiesUsage: boolean) => IChatSDKLogger;
7
+ export declare const appInsightsLogger: (appInsightsKey: string) => IChatSDKLogger;
8
8
  export interface ICustomProperties {
9
9
  [key: string]: any;
10
10
  }
@@ -0,0 +1,29 @@
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
+ };
@@ -0,0 +1,14 @@
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;
@@ -4,3 +4,4 @@ import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetA
4
4
  import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
5
5
  export declare const handleStartChatError: (dispatch: Dispatch<ILiveChatWidgetAction>, facadeChatSDK: FacadeChatSDK, props: ILiveChatWidgetProps | undefined, ex: any, isStartChatSuccessful: boolean) => void;
6
6
  export declare const logWidgetLoadComplete: (additionalMessage?: string) => void;
7
+ export declare const logWidgetLoadWithUnexpectedError: (ex: any) => void;
@@ -1,5 +1,6 @@
1
1
  export declare enum CustomerVoiceEvents {
2
2
  ResponsePageLoaded = "ResponsePageLoaded",
3
3
  FormResponseSubmitted = "FormResponseSubmitted",
4
- FormResponseError = "FormResponseError"
4
+ FormResponseError = "FormResponseError",
5
+ FormsError = "FormsError"
5
6
  }
@@ -2,4 +2,5 @@ import { IPostChatSurveyPaneProps } from "@microsoft/omnichannel-chat-components
2
2
  export interface IPostChatSurveyPaneStatefulProps extends IPostChatSurveyPaneProps {
3
3
  isCustomerVoiceSurveyCompact?: boolean;
4
4
  copilotSurveyContext?: Record<string, string>;
5
+ customerVoiceSurveyCorrelationId?: string;
5
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/omnichannel-chat-widget",
3
- "version": "1.8.1-main.20b15cc",
3
+ "version": "1.8.1-main.4fb8cb5",
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.1",
90
+ "@microsoft/omnichannel-chat-sdk": "^1.11.2",
91
91
  "@opentelemetry/api": "^1.9.0",
92
92
  "abort-controller": "^3",
93
93
  "abort-controller-es5": "^2.0.1",