@microsoft/omnichannel-chat-widget 0.1.0-main.8e79cb8 → 0.1.0-main.a72fbb6

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 (87) hide show
  1. package/README.md +32 -0
  2. package/lib/cjs/common/Constants.js +14 -0
  3. package/lib/cjs/common/telemetry/TelemetryConstants.js +18 -2
  4. package/lib/cjs/common/utils.js +49 -3
  5. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +19 -3
  6. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
  7. package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +10 -1
  8. package/lib/cjs/components/headerstateful/HeaderStateful.js +2 -2
  9. package/lib/cjs/components/livechatwidget/common/createMarkdown.js +31 -30
  10. package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +11 -2
  11. package/lib/cjs/components/livechatwidget/common/endChat.js +52 -20
  12. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +16 -3
  13. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +15 -15
  14. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
  15. package/lib/cjs/components/livechatwidget/common/startChat.js +124 -84
  16. package/lib/cjs/components/livechatwidget/interfaces/IAuthProps.js +1 -0
  17. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +172 -89
  18. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +4 -8
  19. package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -1
  20. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +80 -0
  21. package/lib/cjs/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
  22. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +14 -0
  23. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
  24. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +52 -0
  25. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +98 -0
  26. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +117 -0
  27. package/lib/cjs/contexts/common/ConversationState.js +3 -2
  28. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +2 -0
  29. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +2 -2
  30. package/lib/cjs/contexts/createReducer.js +8 -0
  31. package/lib/cjs/controller/componentController.js +3 -3
  32. package/lib/esm/common/Constants.js +14 -0
  33. package/lib/esm/common/telemetry/TelemetryConstants.js +18 -2
  34. package/lib/esm/common/utils.js +37 -1
  35. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +21 -6
  36. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
  37. package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -2
  38. package/lib/esm/components/headerstateful/HeaderStateful.js +2 -2
  39. package/lib/esm/components/livechatwidget/common/createMarkdown.js +31 -30
  40. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +11 -2
  41. package/lib/esm/components/livechatwidget/common/endChat.js +53 -20
  42. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +15 -5
  43. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +17 -16
  44. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
  45. package/lib/esm/components/livechatwidget/common/startChat.js +125 -86
  46. package/lib/esm/components/livechatwidget/interfaces/IAuthProps.js +1 -0
  47. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +168 -91
  48. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -8
  49. package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -1
  50. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +72 -0
  51. package/lib/esm/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
  52. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +5 -0
  53. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
  54. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +41 -0
  55. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +94 -0
  56. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +107 -0
  57. package/lib/esm/contexts/common/ConversationState.js +3 -2
  58. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +2 -0
  59. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +2 -2
  60. package/lib/esm/contexts/createReducer.js +8 -0
  61. package/lib/esm/controller/componentController.js +3 -3
  62. package/lib/types/common/Constants.d.ts +7 -0
  63. package/lib/types/common/interfaces/IContextDataStore.d.ts +1 -1
  64. package/lib/types/common/telemetry/TelemetryConstants.d.ts +18 -3
  65. package/lib/types/common/telemetry/TelemetryHelper.d.ts +1 -1
  66. package/lib/types/common/utils.d.ts +3 -0
  67. package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.d.ts +1 -1
  68. package/lib/types/components/livechatwidget/common/endChat.d.ts +1 -1
  69. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +5 -4
  70. package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +1 -1
  71. package/lib/types/components/livechatwidget/common/startChat.d.ts +4 -2
  72. package/lib/types/components/livechatwidget/common/startProactiveChat.d.ts +1 -1
  73. package/lib/types/components/livechatwidget/interfaces/IAuthProps.d.ts +4 -0
  74. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +2 -0
  75. package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +0 -1
  76. package/lib/types/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.d.ts +4 -0
  77. package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +2 -0
  78. package/lib/types/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.d.ts +3 -0
  79. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +1 -1
  80. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.d.ts +1 -1
  81. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.d.ts +2 -0
  82. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.d.ts +1 -0
  83. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.d.ts +5 -0
  84. package/lib/types/contexts/common/ConversationState.d.ts +3 -2
  85. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -1
  86. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +3 -1
  87. package/package.json +2 -2
@@ -54,6 +54,16 @@ const handleSystemMessage = (next, args, card, systemMessageStyleProps) => {
54
54
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
55
55
 
56
56
 
57
+ const isTagIncluded = (card, tag) => {
58
+ return isDataTagsPresent(card) && card.activity.channelData.tags.includes(tag);
59
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
60
+
61
+
62
+ const isDataTagsPresent = card => {
63
+ return card && card.activity && card.activity.channelData && card.activity.channelData.tags && card.activity.channelData.tags.length > 0;
64
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
65
+
66
+
57
67
  export const createActivityMiddleware = (systemMessageStyleProps, userMessageStyleProps) => () => next => function () {
58
68
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
59
69
  args[_key] = arguments[_key];
@@ -62,7 +72,7 @@ export const createActivityMiddleware = (systemMessageStyleProps, userMessageSty
62
72
  const [card] = args;
63
73
 
64
74
  if (card.activity) {
65
- var _card$activity$from, _card$activity$channe4, _card$activity$channe5;
75
+ var _card$activity$from;
66
76
 
67
77
  if (((_card$activity$from = card.activity.from) === null || _card$activity$from === void 0 ? void 0 : _card$activity$from.role) === DirectLineSenderRole.Channel) {
68
78
  var _card$activity$channe3;
@@ -77,7 +87,11 @@ export const createActivityMiddleware = (systemMessageStyleProps, userMessageSty
77
87
  return () => false;
78
88
  }
79
89
 
80
- if ((_card$activity$channe4 = card.activity.channelData) !== null && _card$activity$channe4 !== void 0 && (_card$activity$channe5 = _card$activity$channe4.tags) !== null && _card$activity$channe5 !== void 0 && _card$activity$channe5.includes(Constants.systemMessageTag)) {
90
+ if (isTagIncluded(card, Constants.hiddenTag)) {
91
+ return () => false;
92
+ }
93
+
94
+ if (isTagIncluded(card, Constants.systemMessageTag)) {
81
95
  return handleSystemMessage(next, args, card, systemMessageStyleProps);
82
96
  } else if (card.activity.text && card.activity.type === DirectLineActivityType.Message) {
83
97
  if (!card.activity.channelData.isHtmlEncoded && card.activity.channelId === Constants.webchatChannelId) {
@@ -0,0 +1,41 @@
1
+ import { BotMagicCodeStore } from "../../BotMagicCodeStore";
2
+ var CardActionType;
3
+
4
+ (function (CardActionType) {
5
+ CardActionType["OpenUrl"] = "openUrl";
6
+ CardActionType["SignIn"] = "signin";
7
+ })(CardActionType || (CardActionType = {}));
8
+
9
+ const validCardActionTypes = [CardActionType.OpenUrl, CardActionType.SignIn];
10
+ const botOauthUrlRegex = /[\S]+.botframework.com\/api\/oauth\/signin\?signin=([\S]+)/;
11
+ export const createCardActionMiddleware = botMagicCodeConfig => {
12
+ const cardActionMiddleware = () => next => function () {
13
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
14
+ args[_key] = arguments[_key];
15
+ }
16
+
17
+ // eslint-disable-line @typescript-eslint/no-explicit-any
18
+ const [card] = args;
19
+
20
+ if (card.cardAction && validCardActionTypes.indexOf(card.cardAction.type) >= 0 && card.cardAction.value) {
21
+ // Override signin url only if fwdUrl is valid & feature is enabled
22
+ if ((botMagicCodeConfig === null || botMagicCodeConfig === void 0 ? void 0 : botMagicCodeConfig.disabled) === true && botMagicCodeConfig !== null && botMagicCodeConfig !== void 0 && botMagicCodeConfig.fwdUrl) {
23
+ const baseUrl = window.location.origin;
24
+ const result = botOauthUrlRegex.exec(card.cardAction.value);
25
+
26
+ if (result) {
27
+ BotMagicCodeStore.botOAuthSignInId = `${result[1]}`;
28
+ } // fwdUrl must be on the same domain as the chat widget
29
+
30
+
31
+ if (botMagicCodeConfig !== null && botMagicCodeConfig !== void 0 && botMagicCodeConfig.fwdUrl.startsWith(baseUrl)) {
32
+ card.cardAction.value += `&fwdUrl=${botMagicCodeConfig.fwdUrl}`;
33
+ }
34
+ }
35
+ }
36
+
37
+ return next(...args);
38
+ };
39
+
40
+ return cardActionMiddleware;
41
+ };
@@ -0,0 +1,94 @@
1
+ import "@testing-library/jest-dom/extend-expect";
2
+ import { createCardActionMiddleware } from "./cardActionMiddleware";
3
+ describe("cardActionMiddleware test", () => {
4
+ it("createCardActionMiddleware() with undefined botMagicCodeConfig should not change the sign in card url", () => {
5
+ const next = args => args; // eslint-disable-line @typescript-eslint/no-explicit-any
6
+
7
+
8
+ const signInUrl = "https://token.botframework.com/api/oauth/signin?signin=[signin]";
9
+ const args = {
10
+ cardAction: {
11
+ type: "signin",
12
+ value: signInUrl
13
+ }
14
+ };
15
+ const results = createCardActionMiddleware(undefined)()(next)(args);
16
+ expect(signInUrl).toEqual(results.cardAction.value);
17
+ });
18
+ it("createCardActionMiddleware() with botMagicCode enabled should not change the sign in card url", () => {
19
+ const botMagicCodeConfig = {
20
+ disabled: false
21
+ };
22
+
23
+ const next = args => args; // eslint-disable-line @typescript-eslint/no-explicit-any
24
+
25
+
26
+ const signInUrl = "https://token.botframework.com/api/oauth/signin?signin=[signin]";
27
+ const args = {
28
+ cardAction: {
29
+ type: "signin",
30
+ value: signInUrl
31
+ }
32
+ };
33
+ const results = createCardActionMiddleware(botMagicCodeConfig)()(next)(args);
34
+ expect(args.cardAction.value).toEqual(results.cardAction.value);
35
+ });
36
+ it("createCardActionMiddleware() with botMagicCode disabled & no fwdUrl should not change the sign in card url", () => {
37
+ const botMagicCodeConfig = {
38
+ disabled: true
39
+ };
40
+
41
+ const next = args => args; // eslint-disable-line @typescript-eslint/no-explicit-any
42
+
43
+
44
+ const signInUrl = "https://token.botframework.com/api/oauth/signin?signin=[signin]";
45
+ const args = {
46
+ cardAction: {
47
+ type: "signin",
48
+ value: signInUrl
49
+ }
50
+ };
51
+ const results = createCardActionMiddleware(botMagicCodeConfig)()(next)(args);
52
+ expect(args.cardAction.value).toEqual(results.cardAction.value);
53
+ });
54
+ it("createCardActionMiddleware() with botMagicCode disabled & fwdUrl should append the fwdUrl in the sign in card url", () => {
55
+ const botMagicCodeConfig = {
56
+ disabled: true,
57
+ fwdUrl: "http://localhost/forwarder.html"
58
+ };
59
+
60
+ const next = args => args; // eslint-disable-line @typescript-eslint/no-explicit-any
61
+
62
+
63
+ const signInUrl = "https://token.botframework.com/api/oauth/signin?signin=[signin]";
64
+ const args = {
65
+ cardAction: {
66
+ type: "signin",
67
+ value: signInUrl
68
+ }
69
+ };
70
+ const results = createCardActionMiddleware(botMagicCodeConfig)()(next)(args);
71
+ expect(signInUrl === results.cardAction.value).toBe(false);
72
+ expect(results.cardAction.value === `${signInUrl}&fwdUrl=${botMagicCodeConfig.fwdUrl}`).toBe(true);
73
+ });
74
+ it("createCardActionMiddleware() should not append fwdUrl if fwdUrl & sign in card url are not in the same domain", () => {
75
+ const botMagicCodeConfig = {
76
+ disabled: true,
77
+ fwdUrl: "https://localhost/forwarder.html"
78
+ };
79
+
80
+ const next = args => args; // eslint-disable-line @typescript-eslint/no-explicit-any
81
+
82
+
83
+ const signInUrl = "https://token.botframework.com/api/oauth/signin?signin=[signin]";
84
+ const args = {
85
+ cardAction: {
86
+ type: "signin",
87
+ value: signInUrl
88
+ }
89
+ };
90
+ const results = createCardActionMiddleware(botMagicCodeConfig)()(next)(args);
91
+ expect(signInUrl === results.cardAction.value).toBe(true);
92
+ expect(results.cardAction.value === `${signInUrl}&fwdUrl=${botMagicCodeConfig.fwdUrl}`).toBe(false);
93
+ });
94
+ });
@@ -0,0 +1,107 @@
1
+ import { WebChatActionType } from "../../enums/WebChatActionType";
2
+ import { Constants } from "../../../../../common/Constants"; // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
3
+
4
+ const createMessageTimeStampMiddleware = _ref => {
5
+ let {
6
+ dispatch
7
+ } = _ref;
8
+ return next => action => {
9
+ if (isApplicable(action)) {
10
+ return next(evaluateTagsAndOverrideTimeStamp(action));
11
+ }
12
+
13
+ return next(action);
14
+ };
15
+ };
16
+
17
+ const isApplicable = action => {
18
+ return action.type === WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY && isPVAConversation(action) && isPayloadValid(action) && isValidChannel(action);
19
+ };
20
+
21
+ const isPayloadValid = action => {
22
+ var _action$payload;
23
+
24
+ return action === null || action === void 0 ? void 0 : (_action$payload = action.payload) === null || _action$payload === void 0 ? void 0 : _action$payload.activity;
25
+ };
26
+
27
+ const isValidChannel = action => {
28
+ var _action$payload2, _action$payload2$acti;
29
+
30
+ return (action === null || action === void 0 ? void 0 : (_action$payload2 = action.payload) === null || _action$payload2 === void 0 ? void 0 : (_action$payload2$acti = _action$payload2.activity) === null || _action$payload2$acti === void 0 ? void 0 : _action$payload2$acti.channelId) === Constants.acsChannel;
31
+ };
32
+
33
+ const isPVAConversation = action => {
34
+ return !isTagIncluded(action, Constants.systemMessageTag) && !isTagIncluded(action, Constants.publicMessageTag) && !isRoleUserOn(action);
35
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
+
37
+
38
+ const isTagIncluded = (action, tag) => {
39
+ return isDataTagsPresent(action) && action.payload.activity.channelData.tags.includes(tag);
40
+ };
41
+
42
+ const isRoleUserOn = action => {
43
+ var _action$payload3, _action$payload3$acti, _action$payload3$acti2;
44
+
45
+ return (action === null || action === void 0 ? void 0 : (_action$payload3 = action.payload) === null || _action$payload3 === void 0 ? void 0 : (_action$payload3$acti = _action$payload3.activity) === null || _action$payload3$acti === void 0 ? void 0 : (_action$payload3$acti2 = _action$payload3$acti.from) === null || _action$payload3$acti2 === void 0 ? void 0 : _action$payload3$acti2.role) === Constants.userMessageTag;
46
+ };
47
+
48
+ const overrideTimeStamp = (timestampOriginal, timeStampNew) => {
49
+ return isTimestampValid(timeStampNew) ? timeStampNew : timestampOriginal;
50
+ };
51
+
52
+ const isTimestampValid = timeStamp => {
53
+ const regex = /(\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])(T)(\d{2})(:{1})(\d{2})(:{1})(\d{2})(.\d+)([Z]{1}))/;
54
+ return regex.test(timeStamp);
55
+ };
56
+
57
+ const isDataTagsPresent = action => {
58
+ var _action$payload4, _action$payload4$acti, _action$payload4$acti2;
59
+
60
+ return (action === null || action === void 0 ? void 0 : (_action$payload4 = action.payload) === null || _action$payload4 === void 0 ? void 0 : (_action$payload4$acti = _action$payload4.activity) === null || _action$payload4$acti === void 0 ? void 0 : (_action$payload4$acti2 = _action$payload4$acti.channelData) === null || _action$payload4$acti2 === void 0 ? void 0 : _action$payload4$acti2.tags) && action.payload.activity.channelData.tags.length > 0;
61
+ };
62
+
63
+ const evaluateTagsAndOverrideTimeStamp = action => {
64
+ const tagValue = tagLookup(action, Constants.prefixTimestampTag);
65
+
66
+ if (tagValue) {
67
+ const newTimestamp = extractTimeStamp(tagValue);
68
+ action.payload.activity.timestamp = overrideTimeStamp(action.payload.activity.timestamp, newTimestamp);
69
+ }
70
+
71
+ return action;
72
+ };
73
+
74
+ const extractTimeStamp = timeStamp => {
75
+ if (timeStamp && timeStamp.length > 0) {
76
+ const ts = timeStamp.split(Constants.prefixTimestampTag);
77
+
78
+ if (ts && ts.length > 1) {
79
+ return ts[1];
80
+ }
81
+ }
82
+
83
+ return timeStamp;
84
+ };
85
+
86
+ const tagLookup = (action, tag) => {
87
+ if (!isDataTagsPresent(action)) {
88
+ return null;
89
+ }
90
+
91
+ const tags = action.payload.activity.channelData.tags;
92
+ let value;
93
+
94
+ if (tags && tags.length > 0) {
95
+ for (let i = 0; i < tags.length; i++) {
96
+ value = tags[i];
97
+
98
+ if (value && value.indexOf(tag) > -1) {
99
+ return value;
100
+ }
101
+ }
102
+ }
103
+
104
+ return null;
105
+ };
106
+
107
+ export default createMessageTimeStampMiddleware;
@@ -8,6 +8,7 @@ export let ConversationState;
8
8
  ConversationState[ConversationState["ProactiveChat"] = 4] = "ProactiveChat";
9
9
  ConversationState[ConversationState["Active"] = 5] = "Active";
10
10
  ConversationState[ConversationState["InActive"] = 6] = "InActive";
11
- ConversationState[ConversationState["Postchat"] = 7] = "Postchat";
12
- ConversationState[ConversationState["Closed"] = 8] = "Closed";
11
+ ConversationState[ConversationState["PostchatLoading"] = 7] = "PostchatLoading";
12
+ ConversationState[ConversationState["Postchat"] = 8] = "Postchat";
13
+ ConversationState[ConversationState["Closed"] = 9] = "Closed";
13
14
  })(ConversationState || (ConversationState = {}));
@@ -32,4 +32,6 @@ export let LiveChatWidgetActionType;
32
32
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATION_ENDED_BY_AGENT"] = 28] = "SET_CONVERSATION_ENDED_BY_AGENT";
33
33
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_STATE"] = 29] = "SET_WIDGET_STATE";
34
34
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_LIVE_CHAT_CONTEXT"] = 30] = "SET_LIVE_CHAT_CONTEXT";
35
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_BOT_OAUTH_SIGNIN_ID"] = 31] = "SET_BOT_OAUTH_SIGNIN_ID";
36
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_SIZE"] = 32] = "SET_WIDGET_SIZE";
35
37
  })(LiveChatWidgetActionType || (LiveChatWidgetActionType = {}));
@@ -19,14 +19,14 @@ export const getLiveChatWidgetContextInitialState = props => {
19
19
  telemetryInternalData: {},
20
20
  globalDir: "ltr",
21
21
  liveChatContext: undefined,
22
- customContext: undefined
22
+ customContext: undefined,
23
+ widgetSize: undefined
23
24
  },
24
25
  appStates: {
25
26
  conversationState: ConversationState.Closed,
26
27
  isMinimized: false,
27
28
  previousElementOnFocusBeforeModalOpen: null,
28
29
  outsideOperatingHours: false,
29
- shouldShowPostChat: false,
30
30
  preChatResponseEmail: "",
31
31
  isAudioMuted: null,
32
32
  newMessage: false,
@@ -227,6 +227,14 @@ export const createReducer = () => {
227
227
  }
228
228
  };
229
229
 
230
+ case LiveChatWidgetActionType.SET_WIDGET_SIZE:
231
+ return { ...state,
232
+ domainStates: { ...state.domainStates,
233
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
234
+ widgetSize: action.payload
235
+ }
236
+ };
237
+
230
238
  default:
231
239
  return state;
232
240
  }
@@ -1,6 +1,6 @@
1
1
  import { ConversationState } from "../contexts/common/ConversationState";
2
2
  export const shouldShowChatButton = state => {
3
- return state.appStates.isMinimized || state.appStates.conversationState === ConversationState.Closed;
3
+ return (state.appStates.isMinimized || state.appStates.conversationState === ConversationState.Closed) && state.appStates.skipChatButtonRendering == false; // Do not show chat button in case of popout
4
4
  };
5
5
  export const shouldShowProactiveChatPane = state => {
6
6
  return !state.appStates.isMinimized && state.appStates.conversationState === ConversationState.ProactiveChat;
@@ -18,13 +18,13 @@ export const shouldShowWebChatContainer = state => {
18
18
  return state.appStates.conversationState === ConversationState.Active || state.appStates.conversationState === ConversationState.InActive;
19
19
  };
20
20
  export const shouldShowLoadingPane = state => {
21
- return !state.appStates.isMinimized && !state.appStates.shouldShowPostChat && state.appStates.conversationState === ConversationState.Loading;
21
+ return !state.appStates.isMinimized && state.appStates.conversationState === ConversationState.Loading;
22
22
  };
23
23
  export const shouldShowReconnectChatPane = state => {
24
24
  return !state.appStates.isMinimized && state.appStates.conversationState === ConversationState.ReconnectChat;
25
25
  };
26
26
  export const shouldShowPostChatLoadingPane = state => {
27
- return !state.appStates.isMinimized && state.appStates.shouldShowPostChat && state.appStates.conversationState === ConversationState.Loading;
27
+ return !state.appStates.isMinimized && state.appStates.conversationState === ConversationState.PostchatLoading;
28
28
  };
29
29
  export const shouldShowOutOfOfficeHoursPane = state => {
30
30
  return !state.appStates.isMinimized && state.appStates.conversationState === ConversationState.OutOfOffice;
@@ -1,4 +1,6 @@
1
1
  export declare class Constants {
2
+ static readonly magicCodeBroadcastChannel = "MagicCodeChannel";
3
+ static readonly magicCodeResponseBroadcastChannel = "MagicCodeResponseChannel";
2
4
  static readonly systemMessageTag = "system";
3
5
  static readonly userMessageTag = "user";
4
6
  static readonly historyMessageTag = "history";
@@ -32,6 +34,10 @@ export declare class Constants {
32
34
  static readonly queuePositionMessageTag = "queueposition";
33
35
  static readonly averageWaitTimeMessageTag = "averagewaittime";
34
36
  static readonly message = "message";
37
+ static readonly hiddenTag = "Hidden";
38
+ static readonly prefixTimestampTag = "ServerMessageTimestamp_";
39
+ static readonly acsChannel = "ACS_CHANNEL";
40
+ static readonly publicMessageTag = "public";
35
41
  static readonly supportedAdaptiveCardContentTypes: Array<string>;
36
42
  static readonly maxUploadFileSize = "500000";
37
43
  static readonly imageRegex: RegExp;
@@ -70,6 +76,7 @@ export declare class Constants {
70
76
  static readonly internetConnectionTestUrl = "https://ocsdk-prod.azureedge.net/public/connecttest.txt";
71
77
  static readonly internetConnectionTestUrlText = "Omnichannel Connect Test";
72
78
  static readonly ChatWidgetStateChangedPrefix = "ChatWidgetStateChanged";
79
+ static readonly PostChatLoadingDurationInMs = 2000;
73
80
  }
74
81
  export declare const Regex: {
75
82
  new (): {};
@@ -10,5 +10,5 @@ export interface IContextDataStore {
10
10
  /**
11
11
  * removeData: Remove data from data store by key
12
12
  */
13
- removeData?: (key: string) => void;
13
+ removeData: (key: string, type: string) => void;
14
14
  }
@@ -19,19 +19,29 @@ export declare enum LogLevel {
19
19
  }
20
20
  export declare enum BroadcastEvent {
21
21
  LoadPostChatSurvey = "LoadPostChatSurvey",
22
- EndChat = "ChatEnded",
22
+ ChatEnded = "ChatEnded",
23
23
  NewMessageNotification = "NewMessageNotification",
24
24
  UnreadMessageCount = "UnreadMessageCount",
25
+ StartProactiveChat = "StartProactiveChat",
25
26
  ProactiveChatStartChat = "ProactiveChatStartChat",
26
27
  ProactiveChatStartPopoutChat = "ProactiveChatStartPopoutChat",
28
+ ProactiveChatIsInPopoutMode = "ProactiveChatIsInPopoutMode",
29
+ ResetProactiveChatParams = "ResetProactiveChatParams",
27
30
  InvalidAdaptiveCardFormat = "InvalidAdaptiveCardFormat",
28
31
  NewMessageSent = "NewMessageSent",
29
32
  NewMessageReceived = "NewMessageReceived",
30
33
  RedirectPageRequest = "RedirectPageRequest",
34
+ StartChat = "StartChat",
31
35
  StartChatSkippingChatButtonRendering = "StartChatSkippingChatButtonRendering",
32
36
  StartUnauthenticatedReconnectChat = "StartUnauthenticatedReconnectChat",
37
+ InitiateEndChat = "InitiateEndChat",
33
38
  SetCustomContext = "SetCustomContext",
34
- ChatRetrievedFromCache = "ChatRetrievedFromCache"
39
+ ChatRetrievedFromCache = "ChatRetrievedFromCache",
40
+ MaximizeChat = "MaximizeChat",
41
+ ChatInitiated = "ChatInitiated",
42
+ CloseChat = "CloseChat",
43
+ InitiateEndChatOnBrowserUnload = "InitiateEndChatOnBrowserUnload",
44
+ ClosePopoutWindow = "ClosePopoutWindow"
35
45
  }
36
46
  export declare enum TelemetryEvent {
37
47
  CallAdded = "CallAdded",
@@ -80,8 +90,9 @@ export declare enum TelemetryEvent {
80
90
  PrechatSubmitted = "PrechatSubmitted",
81
91
  StartChatSDKCall = "StartChatCall",
82
92
  StartChatEventRecevied = "StartChatEventReceived",
83
- EndChatSDKCall = "EndChatCall",
93
+ EndChatSDKCall = "EndChatSDKCall",
84
94
  EndChatEventReceived = "EndChatEventReceived",
95
+ WindowClosed = "WindowClosed",
85
96
  OnNewMessageFailed = "OnNewMessageFailed",
86
97
  OnNewMessageAudioNotificationFailed = "OnNewMessageAudioNotificationFailed",
87
98
  DownloadTranscriptResponseNullOrUndefined = "DownloadTranscriptResponseNullOrUndefined",
@@ -106,6 +117,10 @@ export declare enum TelemetryEvent {
106
117
  EmailTranscriptButtonClicked = "EmailTranscriptButtonClicked",
107
118
  EmailTranscriptCancelButtonClicked = "EmailTranscriptCancelButtonClicked",
108
119
  AudioToggleButtonClicked = "AudioToggleButtonClicked",
120
+ SuppressBotMagicCodeSucceeded = "SuppressBotMagicCodeSucceeded",
121
+ SuppressBotMagicCodeFailed = "SuppressBotMagicCodeFailed",
122
+ GetConversationDetailsException = "GetConversationDetailsException",
123
+ BrowserUnloadEventStarted = "BrowserUnloadEventStarted",
109
124
  ProcessingHTMLTextMiddlewareFailed = "ProcessingHTMLTextMiddlewareFailed",
110
125
  ProcessingSanitizationMiddlewareFailed = "ProcessingSanitizationMiddlewareFailed",
111
126
  FormatTagsMiddlewareJSONStringifyFailed = "FormatTagsMiddlewareJSONStringifyFailed",
@@ -31,7 +31,7 @@ export declare class TelemetryHelper {
31
31
  static addWidgetDataToTelemetry(telemetryConfig: ITelemetryConfig, telemetryInternalData: IInternalTelemetryData): IInternalTelemetryData;
32
32
  static addSessionDataToTelemetry(chatSession: LiveChatContext, telemetryInternalData: IInternalTelemetryData): IInternalTelemetryData;
33
33
  static addConversationDataToTelemetry(liveWorkItem: LiveWorkItemDetails, telemetryInternalData: IInternalTelemetryData): IInternalTelemetryData;
34
- static logCallingEvent: (logLevel: LogLevel, payload: TelemetryEventWrapper, callId?: string | undefined) => void;
34
+ static logCallingEvent: (logLevel: LogLevel, payload: TelemetryEventWrapper, callId?: string) => void;
35
35
  static logLoadingEvent: (logLevel: LogLevel, payload: TelemetryEventWrapper) => void;
36
36
  static logActionEvent: (logLevel: LogLevel, payload: TelemetryEventWrapper) => void;
37
37
  static logSDKEvent: (logLevel: LogLevel, payload: TelemetryEventWrapper) => void;
@@ -24,3 +24,6 @@ export declare const createTimer: () => ITimer;
24
24
  export declare const getDomain: (hostValue: any) => string;
25
25
  export declare const getWidgetCacheId: (orgId: string, widgetId: string) => string;
26
26
  export declare const getWidgetEndChatEventName: (orgId: string, widgetId: string) => string;
27
+ export declare const getStateFromCache: (orgId: string, widgetId: string) => any;
28
+ export declare const isUndefinedOrEmpty: (object: any) => boolean;
29
+ export declare const addDelayInMs: (ms: number) => Promise<void>;
@@ -1 +1 @@
1
- export declare const downloadTranscript: (chatSDK: any, renderMarkDown?: ((transcriptContent: string) => string) | undefined, bannerMessageOnError?: string | undefined, attachmentMessage?: string | undefined) => Promise<void>;
1
+ export declare const downloadTranscript: (chatSDK: any, renderMarkDown?: ((transcriptContent: string) => string) | undefined, bannerMessageOnError?: string, attachmentMessage?: string) => Promise<void>;
@@ -3,5 +3,5 @@ import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetA
3
3
  import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
4
4
  import { ILiveChatWidgetContext } from "../../../contexts/common/ILiveChatWidgetContext";
5
5
  declare const prepareEndChat: (props: ILiveChatWidgetProps, chatSDK: any, setAdapter: any, setWebChatStyles: any, dispatch: Dispatch<ILiveChatWidgetAction>, adapter: any, state: ILiveChatWidgetContext) => Promise<void>;
6
- declare const endChat: (props: ILiveChatWidgetProps, chatSDK: any, setAdapter: any, setWebChatStyles: any, dispatch: Dispatch<ILiveChatWidgetAction>, adapter: any, skipEndChatSDK?: boolean | undefined, skipCloseChat?: boolean | undefined, postMessageToOtherTab?: boolean | undefined) => Promise<void>;
6
+ declare const endChat: (props: ILiveChatWidgetProps, chatSDK: any, setAdapter: any, setWebChatStyles: any, dispatch: Dispatch<ILiveChatWidgetAction>, adapter: any, skipEndChatSDK?: boolean, skipCloseChat?: boolean, postMessageToOtherTab?: boolean) => Promise<void>;
7
7
  export { prepareEndChat, endChat };
@@ -2,9 +2,10 @@ import "regenerator-runtime/runtime";
2
2
  import { Dispatch } from "react";
3
3
  import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetAction";
4
4
  import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
5
- declare const getChatReconnectContext: (chatSDK: any, reconnectId?: string | undefined) => Promise<any>;
5
+ import { IAuthProps } from "../interfaces/IAuthProps";
6
+ declare const getChatReconnectContext: (chatSDK: any, reconnectId?: string) => Promise<any>;
6
7
  declare const getReconnectIdForAuthenticatedChat: (props: ILiveChatWidgetProps, chatSDK: any) => Promise<string | undefined>;
7
- declare const handleUnauthenticatedReconnectChat: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, reconnectId: string, initStartChat: any, redirectInSameWindow: boolean | undefined) => Promise<void>;
8
- declare const startUnauthenticatedReconnectChat: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, reconnectId: string, initStartChat: any) => Promise<void>;
9
- declare const handleRedirectUnauthenticatedReconnectChat: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, initStartChat: any, reconnectId: string, redirectInSameWindow: boolean | undefined) => Promise<void>;
8
+ declare const handleUnauthenticatedReconnectChat: (chatSDK: any, authProps: IAuthProps | undefined, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, reconnectId: string, initStartChat: any, redirectInSameWindow: boolean | undefined) => Promise<void>;
9
+ declare const startUnauthenticatedReconnectChat: (chatSDK: any, authProps: IAuthProps | undefined, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, reconnectId: string, initStartChat: any) => Promise<void>;
10
+ declare const handleRedirectUnauthenticatedReconnectChat: (chatSDK: any, authProps: IAuthProps | undefined, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, initStartChat: any, reconnectId: string, redirectInSameWindow: boolean | undefined) => Promise<void>;
10
11
  export { getChatReconnectContext, getReconnectIdForAuthenticatedChat, handleUnauthenticatedReconnectChat, startUnauthenticatedReconnectChat, handleRedirectUnauthenticatedReconnectChat };
@@ -1,3 +1,3 @@
1
1
  import { Dispatch } from "react";
2
2
  import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetAction";
3
- export declare const setPostChatContextAndLoadSurvey: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>, persistedChat?: boolean | undefined) => Promise<void>;
3
+ export declare const setPostChatContextAndLoadSurvey: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>, persistedChat?: boolean) => Promise<void>;
@@ -2,6 +2,8 @@ import { Dispatch } from "react";
2
2
  import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetAction";
3
3
  import { ILiveChatWidgetContext } from "../../../contexts/common/ILiveChatWidgetContext";
4
4
  import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
5
+ import { IAuthProps } from "../interfaces/IAuthProps";
5
6
  declare const prepareStartChat: (props: ILiveChatWidgetProps, chatSDK: any, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any) => Promise<void>;
6
- declare const initStartChat: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, params?: any, persistedState?: any) => Promise<void>;
7
- export { prepareStartChat, initStartChat };
7
+ declare const setPreChatAndInitiateChat: (chatSDK: any, authProps: IAuthProps | undefined, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, isProactiveChat?: boolean | false, proactiveChatEnablePrechatState?: boolean | false) => Promise<void>;
8
+ declare const initStartChat: (chatSDK: any, authProps: IAuthProps | undefined, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, params?: any, persistedState?: any) => Promise<void>;
9
+ export { prepareStartChat, initStartChat, setPreChatAndInitiateChat };
@@ -1,4 +1,4 @@
1
1
  import { Dispatch } from "react";
2
2
  import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetAction";
3
3
  import { IProactiveChatNotificationConfig } from "../../proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig";
4
- export declare const startProactiveChat: (dispatch: Dispatch<ILiveChatWidgetAction>, notificationConfig?: IProactiveChatNotificationConfig | undefined, enablePreChat?: boolean | undefined, inNewWindow?: boolean | undefined) => void;
4
+ export declare const startProactiveChat: (dispatch: Dispatch<ILiveChatWidgetAction>, notificationConfig?: IProactiveChatNotificationConfig, enablePreChat?: boolean, inNewWindow?: boolean) => void;
@@ -0,0 +1,4 @@
1
+ export interface IAuthProps {
2
+ authClientFunction?: string;
3
+ setAuthTokenProviderToChatSdk?: (chatSDK: any, authClientFunction?: string) => Promise<void>;
4
+ }
@@ -21,6 +21,7 @@ import { IWebChatContainerStatefulProps } from "../../webchatcontainerstateful/i
21
21
  import { OmnichannelChatSDK } from "@microsoft/omnichannel-chat-sdk";
22
22
  import { ILiveChatWidgetContext } from "../../../contexts/common/ILiveChatWidgetContext";
23
23
  import { IContextDataStore } from "../../../common/interfaces/IContextDataStore";
24
+ import { IAuthProps } from "./IAuthProps";
24
25
  export interface ILiveChatWidgetProps {
25
26
  audioNotificationProps?: IAudioNotificationProps;
26
27
  callingContainerProps?: ICallingContainerProps;
@@ -49,4 +50,5 @@ export interface ILiveChatWidgetProps {
49
50
  webChatContainerProps?: IWebChatContainerStatefulProps;
50
51
  liveChatContextFromCache?: ILiveChatWidgetContext;
51
52
  contextDataStore?: IContextDataStore;
53
+ authProps?: IAuthProps;
52
54
  }
@@ -1,6 +1,5 @@
1
1
  import { IReconnectChatPaneProps } from "@microsoft/omnichannel-chat-components/lib/types/components/reconnectchatpane/interfaces/IReconnectChatPaneProps";
2
2
  export interface IReconnectChatPaneStatefulProps extends IReconnectChatPaneProps {
3
- authClientFunction?: string;
4
3
  isReconnectEnabled?: boolean;
5
4
  reconnectId?: string;
6
5
  redirectInSameWindow?: boolean;
@@ -0,0 +1,4 @@
1
+ export interface IBotMagicCodeConfig {
2
+ disabled?: boolean;
3
+ fwdUrl?: string;
4
+ }
@@ -1,3 +1,4 @@
1
+ import { IBotMagicCodeConfig } from "./IBotMagicCodeConfig";
1
2
  import { ILiveChatWidgetLocalizedTexts } from "../../../contexts/common/ILiveChatWidgetLocalizedTexts";
2
3
  import { IRenderingMiddlewareProps } from "./IRenderingMiddlewareProps";
3
4
  import { IStyle } from "@fluentui/react";
@@ -13,4 +14,5 @@ export interface IWebChatContainerStatefulProps {
13
14
  storeMiddlewares?: any[];
14
15
  renderingMiddlewareProps?: IRenderingMiddlewareProps;
15
16
  localizedTexts?: ILiveChatWidgetLocalizedTexts;
17
+ botMagicCode?: IBotMagicCodeConfig;
16
18
  }
@@ -0,0 +1,3 @@
1
+ export declare class BotMagicCodeStore {
2
+ static botOAuthSignInId: string;
3
+ }
@@ -7,4 +7,4 @@
7
7
  * 3. Decodes certain html characters that came through from chat services
8
8
  ******/
9
9
  import React from "react";
10
- export declare const createActivityMiddleware: (systemMessageStyleProps?: React.CSSProperties | undefined, userMessageStyleProps?: React.CSSProperties | undefined) => () => (next: any) => (...args: any) => any;
10
+ export declare const createActivityMiddleware: (systemMessageStyleProps?: React.CSSProperties, userMessageStyleProps?: React.CSSProperties) => () => (next: any) => (...args: any) => any;
@@ -5,4 +5,4 @@
5
5
  * 1. Renders the first two letters of the sender as the profile pic
6
6
  ******/
7
7
  import React from "react";
8
- export declare const createAvatarMiddleware: (avatarStyleProps?: React.CSSProperties | undefined, avatarTextStyleProps?: React.CSSProperties | undefined) => () => (next: any) => (args_0: any) => false | (() => JSX.Element);
8
+ export declare const createAvatarMiddleware: (avatarStyleProps?: React.CSSProperties, avatarTextStyleProps?: React.CSSProperties) => () => (next: any) => (args_0: any) => false | (() => JSX.Element);
@@ -0,0 +1,2 @@
1
+ import { IBotMagicCodeConfig } from "../../../interfaces/IBotMagicCodeConfig";
2
+ export declare const createCardActionMiddleware: (botMagicCodeConfig: IBotMagicCodeConfig | undefined) => () => (next: any) => (...args: any) => any;
@@ -0,0 +1,5 @@
1
+ import { IWebChatAction } from "../../../interfaces/IWebChatAction";
2
+ declare const createMessageTimeStampMiddleware: ({ dispatch }: {
3
+ dispatch: any;
4
+ }) => (next: any) => (action: IWebChatAction) => any;
5
+ export default createMessageTimeStampMiddleware;
@@ -6,6 +6,7 @@ export declare enum ConversationState {
6
6
  ProactiveChat = 4,
7
7
  Active = 5,
8
8
  InActive = 6,
9
- Postchat = 7,
10
- Closed = 8
9
+ PostchatLoading = 7,
10
+ Postchat = 8,
11
+ Closed = 9
11
12
  }