@microsoft/omnichannel-chat-widget 0.1.0-main.a60f242 → 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 (20) hide show
  1. package/lib/cjs/components/livechatwidget/common/createMarkdown.js +31 -30
  2. package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +4 -1
  3. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +1 -2
  4. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +15 -15
  5. package/lib/cjs/components/livechatwidget/common/startChat.js +12 -7
  6. package/lib/cjs/components/livechatwidget/interfaces/IAuthProps.js +1 -0
  7. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +5 -5
  8. package/lib/esm/components/livechatwidget/common/createMarkdown.js +31 -30
  9. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +4 -1
  10. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +1 -2
  11. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +17 -16
  12. package/lib/esm/components/livechatwidget/common/startChat.js +14 -9
  13. package/lib/esm/components/livechatwidget/interfaces/IAuthProps.js +1 -0
  14. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +5 -5
  15. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +4 -3
  16. package/lib/types/components/livechatwidget/common/startChat.d.ts +3 -2
  17. package/lib/types/components/livechatwidget/interfaces/IAuthProps.d.ts +4 -0
  18. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +2 -0
  19. package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +0 -1
  20. package/package.json +1 -1
@@ -26,26 +26,40 @@ const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineMarkdown
26
26
  breaks: !disableNewLineMarkdownSupport
27
27
  }); // ToDo: Commenting below usage of plugin until deferred bug is resolved: https://github.com/mayashavin/markdown-it-slack/issues/1
28
28
  // markdown.use(MarkdownSlack);
29
- // Markdown override for open link in new tab
30
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, quotes
29
+ } else {
30
+ markdown = new _markdownIt.default(_Constants.Constants.Zero, {
31
+ html: true,
32
+ linkify: true,
33
+ breaks: !disableNewLineMarkdownSupport
34
+ });
35
+ markdown.enable(["entity", // Rule to process html entity - {, ¯, "
36
+ "linkify", // Rule to replace link-like texts with link nodes
37
+ "html_block", // Rule to process html blocks and paragraphs
38
+ "html_inline", // Rule to process html tags
39
+ "newline" // Rule to proceess '\n'
40
+ ]);
41
+ } // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
42
 
32
- markdown.use(_markdownItForInline.default, "url_new_win", "link_open", function (tokens, idx, env) {
33
- const targetAttrIndex = tokens[idx].attrIndex(_Constants.Constants.Target); // Put a transparent pixel instead of the "open in new window" icon, so developers can easily modify the icon in CSS.
34
43
 
35
- const TRANSPARENT_GIF = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
44
+ markdown.use(_markdownItForInline.default, "url_new_win", "link_open", function (tokens, idx, env) {
45
+ const targetAttrIndex = tokens[idx].attrIndex(_Constants.Constants.Target); // Put a transparent pixel instead of the "open in new window" icon, so developers can easily modify the icon in CSS.
36
46
 
37
- if (~targetAttrIndex) {
38
- tokens[idx].attrs[targetAttrIndex][1] = _Constants.Constants.Blank;
39
- } else {
40
- tokens[idx].attrPush([_Constants.Constants.Target, _Constants.Constants.Blank]);
41
- }
47
+ const TRANSPARENT_GIF = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
48
+
49
+ if (~targetAttrIndex) {
50
+ tokens[idx].attrs[targetAttrIndex][1] = _Constants.Constants.Blank;
51
+ } else {
52
+ tokens[idx].attrPush([_Constants.Constants.Target, _Constants.Constants.Blank]);
53
+ }
54
+
55
+ const relAttrIndex = tokens[idx].attrIndex(_Constants.Constants.TargetRelationship);
42
56
 
43
- const relAttrIndex = tokens[idx].attrIndex(_Constants.Constants.TargetRelationship);
57
+ if (~relAttrIndex) {
58
+ tokens[idx].attrs[relAttrIndex][1] = _Constants.Constants.TargetRelationshipAttributes;
59
+ } else {
60
+ tokens[idx].attrPush([_Constants.Constants.TargetRelationship, _Constants.Constants.TargetRelationshipAttributes]);
44
61
 
45
- if (~relAttrIndex) {
46
- tokens[idx].attrs[relAttrIndex][1] = _Constants.Constants.TargetRelationshipAttributes;
47
- } else {
48
- tokens[idx].attrPush([_Constants.Constants.TargetRelationship, _Constants.Constants.TargetRelationshipAttributes]);
62
+ if (!disableMarkdownMessageFormatting) {
49
63
  tokens[idx].attrPush([_Constants.Constants.Title, _defaultMarkdownLocalizedTexts.defaultMarkdownLocalizedTexts.MARKDOWN_EXTERNAL_LINK_ALT]); // eslint-disable-next-line quotes
50
64
 
51
65
  const iconTokens = markdown.parseInline(`![${_defaultMarkdownLocalizedTexts.defaultMarkdownLocalizedTexts.MARKDOWN_EXTERNAL_LINK_ALT}](${TRANSPARENT_GIF})`, env)[0].children;
@@ -55,21 +69,8 @@ const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineMarkdown
55
69
  tokens.splice(idx + 2, 0, ...iconTokens);
56
70
  }
57
71
  }
58
- });
59
- } else {
60
- markdown = new _markdownIt.default(_Constants.Constants.Zero, {
61
- html: true,
62
- linkify: true,
63
- breaks: !disableNewLineMarkdownSupport
64
- });
65
- markdown.enable(["entity", // Rule to process html entity - {, ¯, "
66
- "linkify", // Rule to replace link-like texts with link nodes
67
- "html_block", // Rule to process html blocks and paragraphs
68
- "html_inline", // Rule to process html tags
69
- "newline" // Rule to proceess '\n'
70
- ]);
71
- }
72
-
72
+ }
73
+ });
73
74
  return markdown;
74
75
  };
75
76
 
@@ -1434,7 +1434,6 @@ const dummyDefaultProps = {
1434
1434
  startNewChatButtonClassName: undefined
1435
1435
  }
1436
1436
  },
1437
- authClientFunction: undefined,
1438
1437
  isReconnectEnabled: undefined,
1439
1438
  reconnectId: undefined,
1440
1439
  redirectInSameWindow: undefined
@@ -1705,6 +1704,10 @@ const dummyDefaultProps = {
1705
1704
  fwdUrl: ""
1706
1705
  }
1707
1706
  },
1707
+ authProps: {
1708
+ authClientFunction: undefined,
1709
+ setAuthTokenProviderToChatSdk: undefined
1710
+ },
1708
1711
  telemetryConfig: undefined
1709
1712
  };
1710
1713
  exports.dummyDefaultProps = dummyDefaultProps;
@@ -105,10 +105,9 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
105
105
  });
106
106
  }
107
107
 
108
- _WebChatStoreLoader.WebChatStoreLoader.store = null;
109
-
110
108
  if (isPostChatEnabled === "true") {
111
109
  if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
110
+ _WebChatStoreLoader.WebChatStoreLoader.store = null;
112
111
  dispatch({
113
112
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
114
113
  payload: _ConversationState.ConversationState.PostchatLoading
@@ -44,9 +44,9 @@ const getChatReconnectContext = async (chatSDK, reconnectId) => {
44
44
  exports.getChatReconnectContext = getChatReconnectContext;
45
45
 
46
46
  const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
47
- var _props$reconnectChatP, _props$reconnectChatP2;
47
+ var _props$reconnectChatP, _props$authProps;
48
48
 
49
- if ((_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.isReconnectEnabled && (_props$reconnectChatP2 = props.reconnectChatPaneProps) !== null && _props$reconnectChatP2 !== void 0 && _props$reconnectChatP2.authClientFunction // TODO: Implement this after storage is in place
49
+ if ((_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.isReconnectEnabled && (_props$authProps = props.authProps) !== null && _props$authProps !== void 0 && _props$authProps.authClientFunction // TODO: Implement this after storage is in place
50
50
 
51
51
  /* && !isLoadWithState() */
52
52
  ) {
@@ -63,31 +63,31 @@ const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
63
63
 
64
64
  exports.getReconnectIdForAuthenticatedChat = getReconnectIdForAuthenticatedChat;
65
65
 
66
- const handleUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat, redirectInSameWindow) => {
66
+ const handleUnauthenticatedReconnectChat = async (chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat, redirectInSameWindow) => {
67
67
  const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
68
68
 
69
69
  if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
70
- await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow);
70
+ await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, authProps, dispatch, setAdapter, initStartChat, redirectInSameWindow);
71
71
  } else {
72
- await setReconnectIdAndStartChat(chatSDK, dispatch, setAdapter, reconnectId, initStartChat);
72
+ await setReconnectIdAndStartChat(chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat);
73
73
  }
74
74
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
75
75
 
76
76
 
77
77
  exports.handleUnauthenticatedReconnectChat = handleUnauthenticatedReconnectChat;
78
78
 
79
- const startUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat) => {
79
+ const startUnauthenticatedReconnectChat = async (chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat) => {
80
80
  const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
81
81
 
82
82
  if (!shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
83
- await setReconnectIdAndStartChat(chatSDK, dispatch, setAdapter, reconnectId, initStartChat);
83
+ await setReconnectIdAndStartChat(chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat);
84
84
  }
85
85
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
86
86
 
87
87
 
88
88
  exports.startUnauthenticatedReconnectChat = startUnauthenticatedReconnectChat;
89
89
 
90
- const setReconnectIdAndStartChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat) => {
90
+ const setReconnectIdAndStartChat = async (chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat) => {
91
91
  const startUnauthenticatedReconnectChat = {
92
92
  eventName: _TelemetryConstants.BroadcastEvent.StartUnauthenticatedReconnectChat
93
93
  };
@@ -105,7 +105,7 @@ const setReconnectIdAndStartChat = async (chatSDK, dispatch, setAdapter, reconne
105
105
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
106
106
  payload: _ConversationState.ConversationState.Loading
107
107
  });
108
- await initStartChat(chatSDK, dispatch, setAdapter, optionalParams);
108
+ await initStartChat(chatSDK, authProps, dispatch, setAdapter, optionalParams);
109
109
  };
110
110
 
111
111
  const redirectPage = (redirectURL, redirectInSameWindow) => {
@@ -128,7 +128,7 @@ const shouldRedirectOrStartNewChat = reconnectAvailabilityResponse => {
128
128
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
129
129
 
130
130
 
131
- const startNewChatEmptyRedirectionUrl = async (chatSDK, dispatch, setAdapter, initStartChat) => {
131
+ const startNewChatEmptyRedirectionUrl = async (chatSDK, authProps, dispatch, setAdapter, initStartChat) => {
132
132
  const startUnauthenticatedReconnectChat = {
133
133
  eventName: _TelemetryConstants.BroadcastEvent.StartUnauthenticatedReconnectChat
134
134
  };
@@ -153,26 +153,26 @@ const startNewChatEmptyRedirectionUrl = async (chatSDK, dispatch, setAdapter, in
153
153
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
154
154
  payload: _ConversationState.ConversationState.Loading
155
155
  });
156
- await initStartChat(chatSDK, dispatch, setAdapter);
156
+ await initStartChat(chatSDK, authProps, dispatch, setAdapter);
157
157
  }
158
158
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
159
159
 
160
160
 
161
- const handleRedirectUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, initStartChat, reconnectId, redirectInSameWindow) => {
161
+ const handleRedirectUnauthenticatedReconnectChat = async (chatSDK, authProps, dispatch, setAdapter, initStartChat, reconnectId, redirectInSameWindow) => {
162
162
  const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
163
163
 
164
164
  if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
165
- await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow);
165
+ await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, authProps, dispatch, setAdapter, initStartChat, redirectInSameWindow);
166
166
  }
167
167
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
168
168
 
169
169
 
170
170
  exports.handleRedirectUnauthenticatedReconnectChat = handleRedirectUnauthenticatedReconnectChat;
171
171
 
172
- const redirectOrStartNewChat = async (reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow) => {
172
+ const redirectOrStartNewChat = async (reconnectAvailabilityResponse, chatSDK, authProps, dispatch, setAdapter, initStartChat, redirectInSameWindow) => {
173
173
  if (reconnectAvailabilityResponse.redirectURL) {
174
174
  redirectPage(reconnectAvailabilityResponse.redirectURL, redirectInSameWindow);
175
175
  } else {
176
- await startNewChatEmptyRedirectionUrl(chatSDK, dispatch, setAdapter, initStartChat);
176
+ await startNewChatEmptyRedirectionUrl(chatSDK, authProps, dispatch, setAdapter, initStartChat);
177
177
  }
178
178
  };
@@ -52,7 +52,7 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
52
52
  if ((_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.reconnectId) {
53
53
  var _props$reconnectChatP2, _props$reconnectChatP3;
54
54
 
55
- await (0, _reconnectChatHelper.handleRedirectUnauthenticatedReconnectChat)(chatSDK, dispatch, setAdapter, initStartChat, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, (_props$reconnectChatP3 = props.reconnectChatPaneProps) === null || _props$reconnectChatP3 === void 0 ? void 0 : _props$reconnectChatP3.redirectInSameWindow);
55
+ await (0, _reconnectChatHelper.handleRedirectUnauthenticatedReconnectChat)(chatSDK, props.authProps, dispatch, setAdapter, initStartChat, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, (_props$reconnectChatP3 = props.reconnectChatPaneProps) === null || _props$reconnectChatP3 === void 0 ? void 0 : _props$reconnectChatP3.redirectInSameWindow);
56
56
  return;
57
57
  } // Getting reconnectId for authenticated chat
58
58
 
@@ -77,13 +77,13 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
77
77
  const isProactiveChat = state.appStates.conversationState === _ConversationState.ConversationState.ProactiveChat;
78
78
  const isPreChatEnabledInProactiveChat = state.appStates.proactiveChatStates.proactiveChatEnablePrechat; //Setting PreChat and intiate chat
79
79
 
80
- setPreChatAndInitiateChat(chatSDK, dispatch, setAdapter, isProactiveChat, isPreChatEnabledInProactiveChat);
80
+ setPreChatAndInitiateChat(chatSDK, props.authProps, dispatch, setAdapter, isProactiveChat, isPreChatEnabledInProactiveChat);
81
81
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
82
82
 
83
83
 
84
84
  exports.prepareStartChat = prepareStartChat;
85
85
 
86
- const setPreChatAndInitiateChat = async (chatSDK, dispatch, setAdapter, isProactiveChat, proactiveChatEnablePrechatState) => {
86
+ const setPreChatAndInitiateChat = async (chatSDK, authProps, dispatch, setAdapter, isProactiveChat, proactiveChatEnablePrechatState) => {
87
87
  // Getting prechat Survey Context
88
88
  const parseToJson = false;
89
89
  const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
@@ -106,13 +106,13 @@ const setPreChatAndInitiateChat = async (chatSDK, dispatch, setAdapter, isProact
106
106
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
107
107
  payload: _ConversationState.ConversationState.Loading
108
108
  });
109
- await initStartChat(chatSDK, dispatch, setAdapter);
109
+ await initStartChat(chatSDK, authProps, dispatch, setAdapter);
110
110
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
111
111
 
112
112
 
113
113
  exports.setPreChatAndInitiateChat = setPreChatAndInitiateChat;
114
114
 
115
- const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedState) => {
115
+ const initStartChat = async (chatSDK, authProps, dispatch, setAdapter, params, persistedState) => {
116
116
  try {
117
117
  var _newAdapter$activity$, _TelemetryTimers$Widg;
118
118
 
@@ -139,7 +139,12 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedSta
139
139
  }); // Set optional params
140
140
 
141
141
 
142
- optionalParams = Object.assign({}, params, optionalParams);
142
+ optionalParams = Object.assign({}, params, optionalParams); // set auth token to chat sdk before start chat
143
+
144
+ if (authProps && authProps.setAuthTokenProviderToChatSdk) {
145
+ await authProps.setAuthTokenProviderToChatSdk(chatSDK, authProps.authClientFunction);
146
+ }
147
+
143
148
  await chatSDK.startChat(optionalParams);
144
149
  isStartChatSuccessful = true;
145
150
  } catch (error) {
@@ -251,7 +256,7 @@ const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdap
251
256
  const optionalParams = {
252
257
  liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai7 = persistedState.domainStates) === null || _persistedState$domai7 === void 0 ? void 0 : _persistedState$domai7.liveChatContext
253
258
  };
254
- await initStartChat(chatSDK, dispatch, setAdapter, optionalParams, persistedState);
259
+ await initStartChat(chatSDK, props.authProps, dispatch, setAdapter, optionalParams, persistedState);
255
260
  return true;
256
261
  } else {
257
262
  return false;
@@ -185,7 +185,7 @@ const LiveChatWidgetStateful = props => {
185
185
  if (!((_props$controlProps4 = props.controlProps) !== null && _props$controlProps4 !== void 0 && _props$controlProps4.skipChatButtonRendering) && (_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.reconnectId) {
186
186
  var _props$reconnectChatP2;
187
187
 
188
- (0, _reconnectChatHelper.startUnauthenticatedReconnectChat)(chatSDK, dispatch, setAdapter, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, _startChat.initStartChat);
188
+ (0, _reconnectChatHelper.startUnauthenticatedReconnectChat)(chatSDK, props.authProps, dispatch, setAdapter, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, _startChat.initStartChat);
189
189
  return;
190
190
  } // Check if auth settings enabled, do not connect to existing chat from cache during refresh/re-load
191
191
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -202,7 +202,7 @@ const LiveChatWidgetStateful = props => {
202
202
  const optionalParams = {
203
203
  liveChatContext: (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.liveChatContext
204
204
  };
205
- (0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter, optionalParams);
205
+ (0, _startChat.initStartChat)(chatSDK, props.authProps, dispatch, setAdapter, optionalParams);
206
206
  return;
207
207
  }
208
208
  } // All other case should show start chat button, skipChatButtonRendering will take care of it own
@@ -225,7 +225,7 @@ const LiveChatWidgetStateful = props => {
225
225
  if ((_props$reconnectChatP3 = props.reconnectChatPaneProps) !== null && _props$reconnectChatP3 !== void 0 && _props$reconnectChatP3.reconnectId && !state.appStates.reconnectId) {
226
226
  var _props$reconnectChatP4, _props$reconnectChatP5;
227
227
 
228
- (0, _reconnectChatHelper.handleUnauthenticatedReconnectChat)(chatSDK, dispatch, setAdapter, (_props$reconnectChatP4 = props.reconnectChatPaneProps) === null || _props$reconnectChatP4 === void 0 ? void 0 : _props$reconnectChatP4.reconnectId, _startChat.initStartChat, (_props$reconnectChatP5 = props.reconnectChatPaneProps) === null || _props$reconnectChatP5 === void 0 ? void 0 : _props$reconnectChatP5.redirectInSameWindow);
228
+ (0, _reconnectChatHelper.handleUnauthenticatedReconnectChat)(chatSDK, props.authProps, dispatch, setAdapter, (_props$reconnectChatP4 = props.reconnectChatPaneProps) === null || _props$reconnectChatP4 === void 0 ? void 0 : _props$reconnectChatP4.reconnectId, _startChat.initStartChat, (_props$reconnectChatP5 = props.reconnectChatPaneProps) === null || _props$reconnectChatP5 === void 0 ? void 0 : _props$reconnectChatP5.redirectInSameWindow);
229
229
  } else {
230
230
  (0, _reconnectChatHelper.getReconnectIdForAuthenticatedChat)(props, chatSDK).then(authReconnectId => {
231
231
  if (authReconnectId && !state.appStates.reconnectId) {
@@ -244,7 +244,7 @@ const LiveChatWidgetStateful = props => {
244
244
 
245
245
  _omnichannelChatComponents.BroadcastService.postMessage(chatStartedSkippingChatButtonRendering);
246
246
 
247
- (0, _startChat.setPreChatAndInitiateChat)(chatSDK, dispatch, setAdapter);
247
+ (0, _startChat.setPreChatAndInitiateChat)(chatSDK, props.authProps, dispatch, setAdapter);
248
248
  }
249
249
  });
250
250
  }
@@ -453,7 +453,7 @@ const LiveChatWidgetStateful = props => {
453
453
  const prepareStartChatRelay = () => (0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter); // eslint-disable-next-line @typescript-eslint/no-explicit-any
454
454
 
455
455
 
456
- const initStartChatRelay = (optionalParams, persistedState) => (0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter, optionalParams, persistedState);
456
+ const initStartChatRelay = (optionalParams, persistedState) => (0, _startChat.initStartChat)(chatSDK, props.authProps, dispatch, setAdapter, optionalParams, persistedState);
457
457
 
458
458
  const confirmationPaneProps = (0, _initConfirmationPropsComposer.initConfirmationPropsComposer)(props);
459
459
  return /*#__PURE__*/_react2.default.createElement(Composer, _extends({}, webChatProps, {
@@ -13,26 +13,40 @@ export const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineM
13
13
  breaks: !disableNewLineMarkdownSupport
14
14
  }); // ToDo: Commenting below usage of plugin until deferred bug is resolved: https://github.com/mayashavin/markdown-it-slack/issues/1
15
15
  // markdown.use(MarkdownSlack);
16
- // Markdown override for open link in new tab
17
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, quotes
16
+ } else {
17
+ markdown = new MarkdownIt(Constants.Zero, {
18
+ html: true,
19
+ linkify: true,
20
+ breaks: !disableNewLineMarkdownSupport
21
+ });
22
+ markdown.enable(["entity", // Rule to process html entity - {, ¯, "
23
+ "linkify", // Rule to replace link-like texts with link nodes
24
+ "html_block", // Rule to process html blocks and paragraphs
25
+ "html_inline", // Rule to process html tags
26
+ "newline" // Rule to proceess '\n'
27
+ ]);
28
+ } // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
29
 
19
- markdown.use(MarkdownItForInline, "url_new_win", "link_open", function (tokens, idx, env) {
20
- const targetAttrIndex = tokens[idx].attrIndex(Constants.Target); // Put a transparent pixel instead of the "open in new window" icon, so developers can easily modify the icon in CSS.
21
30
 
22
- const TRANSPARENT_GIF = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
31
+ markdown.use(MarkdownItForInline, "url_new_win", "link_open", function (tokens, idx, env) {
32
+ const targetAttrIndex = tokens[idx].attrIndex(Constants.Target); // Put a transparent pixel instead of the "open in new window" icon, so developers can easily modify the icon in CSS.
23
33
 
24
- if (~targetAttrIndex) {
25
- tokens[idx].attrs[targetAttrIndex][1] = Constants.Blank;
26
- } else {
27
- tokens[idx].attrPush([Constants.Target, Constants.Blank]);
28
- }
34
+ const TRANSPARENT_GIF = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
35
+
36
+ if (~targetAttrIndex) {
37
+ tokens[idx].attrs[targetAttrIndex][1] = Constants.Blank;
38
+ } else {
39
+ tokens[idx].attrPush([Constants.Target, Constants.Blank]);
40
+ }
41
+
42
+ const relAttrIndex = tokens[idx].attrIndex(Constants.TargetRelationship);
29
43
 
30
- const relAttrIndex = tokens[idx].attrIndex(Constants.TargetRelationship);
44
+ if (~relAttrIndex) {
45
+ tokens[idx].attrs[relAttrIndex][1] = Constants.TargetRelationshipAttributes;
46
+ } else {
47
+ tokens[idx].attrPush([Constants.TargetRelationship, Constants.TargetRelationshipAttributes]);
31
48
 
32
- if (~relAttrIndex) {
33
- tokens[idx].attrs[relAttrIndex][1] = Constants.TargetRelationshipAttributes;
34
- } else {
35
- tokens[idx].attrPush([Constants.TargetRelationship, Constants.TargetRelationshipAttributes]);
49
+ if (!disableMarkdownMessageFormatting) {
36
50
  tokens[idx].attrPush([Constants.Title, defaultMarkdownLocalizedTexts.MARKDOWN_EXTERNAL_LINK_ALT]); // eslint-disable-next-line quotes
37
51
 
38
52
  const iconTokens = markdown.parseInline(`![${defaultMarkdownLocalizedTexts.MARKDOWN_EXTERNAL_LINK_ALT}](${TRANSPARENT_GIF})`, env)[0].children;
@@ -42,20 +56,7 @@ export const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineM
42
56
  tokens.splice(idx + 2, 0, ...iconTokens);
43
57
  }
44
58
  }
45
- });
46
- } else {
47
- markdown = new MarkdownIt(Constants.Zero, {
48
- html: true,
49
- linkify: true,
50
- breaks: !disableNewLineMarkdownSupport
51
- });
52
- markdown.enable(["entity", // Rule to process html entity - {, ¯, "
53
- "linkify", // Rule to replace link-like texts with link nodes
54
- "html_block", // Rule to process html blocks and paragraphs
55
- "html_inline", // Rule to process html tags
56
- "newline" // Rule to proceess '\n'
57
- ]);
58
- }
59
-
59
+ }
60
+ });
60
61
  return markdown;
61
62
  };
@@ -1413,7 +1413,6 @@ export const dummyDefaultProps = {
1413
1413
  startNewChatButtonClassName: undefined
1414
1414
  }
1415
1415
  },
1416
- authClientFunction: undefined,
1417
1416
  isReconnectEnabled: undefined,
1418
1417
  reconnectId: undefined,
1419
1418
  redirectInSameWindow: undefined
@@ -1684,5 +1683,9 @@ export const dummyDefaultProps = {
1684
1683
  fwdUrl: ""
1685
1684
  }
1686
1685
  },
1686
+ authProps: {
1687
+ authClientFunction: undefined,
1688
+ setAuthTokenProviderToChatSdk: undefined
1689
+ },
1687
1690
  telemetryConfig: undefined
1688
1691
  };
@@ -64,10 +64,9 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
64
64
  });
65
65
  }
66
66
 
67
- WebChatStoreLoader.store = null;
68
-
69
67
  if (isPostChatEnabled === "true") {
70
68
  if (postChatSurveyMode === PostChatSurveyMode.Embed) {
69
+ WebChatStoreLoader.store = null;
71
70
  dispatch({
72
71
  type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
73
72
  payload: ConversationState.PostchatLoading
@@ -3,8 +3,9 @@ import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/teleme
3
3
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
4
4
  import { ConversationState } from "../../../contexts/common/ConversationState";
5
5
  import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
6
- import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
+ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
7
7
 
8
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
9
  const getChatReconnectContext = async (chatSDK, reconnectId) => {
9
10
  try {
10
11
  if (reconnectId) {
@@ -29,9 +30,9 @@ const getChatReconnectContext = async (chatSDK, reconnectId) => {
29
30
 
30
31
 
31
32
  const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
32
- var _props$reconnectChatP, _props$reconnectChatP2;
33
+ var _props$reconnectChatP, _props$authProps;
33
34
 
34
- if ((_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.isReconnectEnabled && (_props$reconnectChatP2 = props.reconnectChatPaneProps) !== null && _props$reconnectChatP2 !== void 0 && _props$reconnectChatP2.authClientFunction // TODO: Implement this after storage is in place
35
+ if ((_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.isReconnectEnabled && (_props$authProps = props.authProps) !== null && _props$authProps !== void 0 && _props$authProps.authClientFunction // TODO: Implement this after storage is in place
35
36
 
36
37
  /* && !isLoadWithState() */
37
38
  ) {
@@ -46,27 +47,27 @@ const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
46
47
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
48
 
48
49
 
49
- const handleUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat, redirectInSameWindow) => {
50
+ const handleUnauthenticatedReconnectChat = async (chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat, redirectInSameWindow) => {
50
51
  const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
51
52
 
52
53
  if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
53
- await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow);
54
+ await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, authProps, dispatch, setAdapter, initStartChat, redirectInSameWindow);
54
55
  } else {
55
- await setReconnectIdAndStartChat(chatSDK, dispatch, setAdapter, reconnectId, initStartChat);
56
+ await setReconnectIdAndStartChat(chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat);
56
57
  }
57
58
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
58
59
 
59
60
 
60
- const startUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat) => {
61
+ const startUnauthenticatedReconnectChat = async (chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat) => {
61
62
  const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
62
63
 
63
64
  if (!shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
64
- await setReconnectIdAndStartChat(chatSDK, dispatch, setAdapter, reconnectId, initStartChat);
65
+ await setReconnectIdAndStartChat(chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat);
65
66
  }
66
67
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
67
68
 
68
69
 
69
- const setReconnectIdAndStartChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat) => {
70
+ const setReconnectIdAndStartChat = async (chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat) => {
70
71
  const startUnauthenticatedReconnectChat = {
71
72
  eventName: BroadcastEvent.StartUnauthenticatedReconnectChat
72
73
  };
@@ -82,7 +83,7 @@ const setReconnectIdAndStartChat = async (chatSDK, dispatch, setAdapter, reconne
82
83
  type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
83
84
  payload: ConversationState.Loading
84
85
  });
85
- await initStartChat(chatSDK, dispatch, setAdapter, optionalParams);
86
+ await initStartChat(chatSDK, authProps, dispatch, setAdapter, optionalParams);
86
87
  };
87
88
 
88
89
  const redirectPage = (redirectURL, redirectInSameWindow) => {
@@ -104,7 +105,7 @@ const shouldRedirectOrStartNewChat = reconnectAvailabilityResponse => {
104
105
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
105
106
 
106
107
 
107
- const startNewChatEmptyRedirectionUrl = async (chatSDK, dispatch, setAdapter, initStartChat) => {
108
+ const startNewChatEmptyRedirectionUrl = async (chatSDK, authProps, dispatch, setAdapter, initStartChat) => {
108
109
  const startUnauthenticatedReconnectChat = {
109
110
  eventName: BroadcastEvent.StartUnauthenticatedReconnectChat
110
111
  };
@@ -127,25 +128,25 @@ const startNewChatEmptyRedirectionUrl = async (chatSDK, dispatch, setAdapter, in
127
128
  type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
128
129
  payload: ConversationState.Loading
129
130
  });
130
- await initStartChat(chatSDK, dispatch, setAdapter);
131
+ await initStartChat(chatSDK, authProps, dispatch, setAdapter);
131
132
  }
132
133
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
133
134
 
134
135
 
135
- const handleRedirectUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, initStartChat, reconnectId, redirectInSameWindow) => {
136
+ const handleRedirectUnauthenticatedReconnectChat = async (chatSDK, authProps, dispatch, setAdapter, initStartChat, reconnectId, redirectInSameWindow) => {
136
137
  const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
137
138
 
138
139
  if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
139
- await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow);
140
+ await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, authProps, dispatch, setAdapter, initStartChat, redirectInSameWindow);
140
141
  }
141
142
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
142
143
 
143
144
 
144
- const redirectOrStartNewChat = async (reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow) => {
145
+ const redirectOrStartNewChat = async (reconnectAvailabilityResponse, chatSDK, authProps, dispatch, setAdapter, initStartChat, redirectInSameWindow) => {
145
146
  if (reconnectAvailabilityResponse.redirectURL) {
146
147
  redirectPage(reconnectAvailabilityResponse.redirectURL, redirectInSameWindow);
147
148
  } else {
148
- await startNewChatEmptyRedirectionUrl(chatSDK, dispatch, setAdapter, initStartChat);
149
+ await startNewChatEmptyRedirectionUrl(chatSDK, authProps, dispatch, setAdapter, initStartChat);
149
150
  }
150
151
  };
151
152
 
@@ -12,8 +12,8 @@ import { createTimer, getStateFromCache, isUndefinedOrEmpty } from "../../../com
12
12
  import { getReconnectIdForAuthenticatedChat, handleRedirectUnauthenticatedReconnectChat } from "./reconnectChatHelper";
13
13
  import { setPostChatContextAndLoadSurvey } from "./setPostChatContextAndLoadSurvey";
14
14
  import { updateSessionDataForTelemetry } from "./updateSessionDataForTelemetry";
15
- import { BroadcastService } from "@microsoft/omnichannel-chat-components"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
-
15
+ import { BroadcastService } from "@microsoft/omnichannel-chat-components";
16
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
17
  let optionalParams = {}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
18
 
19
19
  const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) => {
@@ -30,7 +30,7 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
30
30
  if ((_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.reconnectId) {
31
31
  var _props$reconnectChatP2, _props$reconnectChatP3;
32
32
 
33
- await handleRedirectUnauthenticatedReconnectChat(chatSDK, dispatch, setAdapter, initStartChat, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, (_props$reconnectChatP3 = props.reconnectChatPaneProps) === null || _props$reconnectChatP3 === void 0 ? void 0 : _props$reconnectChatP3.redirectInSameWindow);
33
+ await handleRedirectUnauthenticatedReconnectChat(chatSDK, props.authProps, dispatch, setAdapter, initStartChat, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, (_props$reconnectChatP3 = props.reconnectChatPaneProps) === null || _props$reconnectChatP3 === void 0 ? void 0 : _props$reconnectChatP3.redirectInSameWindow);
34
34
  return;
35
35
  } // Getting reconnectId for authenticated chat
36
36
 
@@ -55,11 +55,11 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
55
55
  const isProactiveChat = state.appStates.conversationState === ConversationState.ProactiveChat;
56
56
  const isPreChatEnabledInProactiveChat = state.appStates.proactiveChatStates.proactiveChatEnablePrechat; //Setting PreChat and intiate chat
57
57
 
58
- setPreChatAndInitiateChat(chatSDK, dispatch, setAdapter, isProactiveChat, isPreChatEnabledInProactiveChat);
58
+ setPreChatAndInitiateChat(chatSDK, props.authProps, dispatch, setAdapter, isProactiveChat, isPreChatEnabledInProactiveChat);
59
59
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
60
60
 
61
61
 
62
- const setPreChatAndInitiateChat = async (chatSDK, dispatch, setAdapter, isProactiveChat, proactiveChatEnablePrechatState) => {
62
+ const setPreChatAndInitiateChat = async (chatSDK, authProps, dispatch, setAdapter, isProactiveChat, proactiveChatEnablePrechatState) => {
63
63
  // Getting prechat Survey Context
64
64
  const parseToJson = false;
65
65
  const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
@@ -82,11 +82,11 @@ const setPreChatAndInitiateChat = async (chatSDK, dispatch, setAdapter, isProact
82
82
  type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
83
83
  payload: ConversationState.Loading
84
84
  });
85
- await initStartChat(chatSDK, dispatch, setAdapter);
85
+ await initStartChat(chatSDK, authProps, dispatch, setAdapter);
86
86
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
87
87
 
88
88
 
89
- const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedState) => {
89
+ const initStartChat = async (chatSDK, authProps, dispatch, setAdapter, params, persistedState) => {
90
90
  try {
91
91
  var _newAdapter$activity$, _TelemetryTimers$Widg;
92
92
 
@@ -111,7 +111,12 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedSta
111
111
  Event: TelemetryEvent.StartChatSDKCall
112
112
  }); // Set optional params
113
113
 
114
- optionalParams = Object.assign({}, params, optionalParams);
114
+ optionalParams = Object.assign({}, params, optionalParams); // set auth token to chat sdk before start chat
115
+
116
+ if (authProps && authProps.setAuthTokenProviderToChatSdk) {
117
+ await authProps.setAuthTokenProviderToChatSdk(chatSDK, authProps.authClientFunction);
118
+ }
119
+
115
120
  await chatSDK.startChat(optionalParams);
116
121
  isStartChatSuccessful = true;
117
122
  } catch (error) {
@@ -218,7 +223,7 @@ const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdap
218
223
  const optionalParams = {
219
224
  liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai7 = persistedState.domainStates) === null || _persistedState$domai7 === void 0 ? void 0 : _persistedState$domai7.liveChatContext
220
225
  };
221
- await initStartChat(chatSDK, dispatch, setAdapter, optionalParams, persistedState);
226
+ await initStartChat(chatSDK, props.authProps, dispatch, setAdapter, optionalParams, persistedState);
222
227
  return true;
223
228
  } else {
224
229
  return false;
@@ -130,7 +130,7 @@ export const LiveChatWidgetStateful = props => {
130
130
  if (!((_props$controlProps4 = props.controlProps) !== null && _props$controlProps4 !== void 0 && _props$controlProps4.skipChatButtonRendering) && (_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.reconnectId) {
131
131
  var _props$reconnectChatP2;
132
132
 
133
- startUnauthenticatedReconnectChat(chatSDK, dispatch, setAdapter, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, initStartChat);
133
+ startUnauthenticatedReconnectChat(chatSDK, props.authProps, dispatch, setAdapter, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, initStartChat);
134
134
  return;
135
135
  } // Check if auth settings enabled, do not connect to existing chat from cache during refresh/re-load
136
136
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -147,7 +147,7 @@ export const LiveChatWidgetStateful = props => {
147
147
  const optionalParams = {
148
148
  liveChatContext: (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.liveChatContext
149
149
  };
150
- initStartChat(chatSDK, dispatch, setAdapter, optionalParams);
150
+ initStartChat(chatSDK, props.authProps, dispatch, setAdapter, optionalParams);
151
151
  return;
152
152
  }
153
153
  } // All other case should show start chat button, skipChatButtonRendering will take care of it own
@@ -170,7 +170,7 @@ export const LiveChatWidgetStateful = props => {
170
170
  if ((_props$reconnectChatP3 = props.reconnectChatPaneProps) !== null && _props$reconnectChatP3 !== void 0 && _props$reconnectChatP3.reconnectId && !state.appStates.reconnectId) {
171
171
  var _props$reconnectChatP4, _props$reconnectChatP5;
172
172
 
173
- handleUnauthenticatedReconnectChat(chatSDK, dispatch, setAdapter, (_props$reconnectChatP4 = props.reconnectChatPaneProps) === null || _props$reconnectChatP4 === void 0 ? void 0 : _props$reconnectChatP4.reconnectId, initStartChat, (_props$reconnectChatP5 = props.reconnectChatPaneProps) === null || _props$reconnectChatP5 === void 0 ? void 0 : _props$reconnectChatP5.redirectInSameWindow);
173
+ handleUnauthenticatedReconnectChat(chatSDK, props.authProps, dispatch, setAdapter, (_props$reconnectChatP4 = props.reconnectChatPaneProps) === null || _props$reconnectChatP4 === void 0 ? void 0 : _props$reconnectChatP4.reconnectId, initStartChat, (_props$reconnectChatP5 = props.reconnectChatPaneProps) === null || _props$reconnectChatP5 === void 0 ? void 0 : _props$reconnectChatP5.redirectInSameWindow);
174
174
  } else {
175
175
  getReconnectIdForAuthenticatedChat(props, chatSDK).then(authReconnectId => {
176
176
  if (authReconnectId && !state.appStates.reconnectId) {
@@ -187,7 +187,7 @@ export const LiveChatWidgetStateful = props => {
187
187
  eventName: BroadcastEvent.StartChatSkippingChatButtonRendering
188
188
  };
189
189
  BroadcastService.postMessage(chatStartedSkippingChatButtonRendering);
190
- setPreChatAndInitiateChat(chatSDK, dispatch, setAdapter);
190
+ setPreChatAndInitiateChat(chatSDK, props.authProps, dispatch, setAdapter);
191
191
  }
192
192
  });
193
193
  }
@@ -381,7 +381,7 @@ export const LiveChatWidgetStateful = props => {
381
381
  const prepareStartChatRelay = () => prepareStartChat(props, chatSDK, state, dispatch, setAdapter); // eslint-disable-next-line @typescript-eslint/no-explicit-any
382
382
 
383
383
 
384
- const initStartChatRelay = (optionalParams, persistedState) => initStartChat(chatSDK, dispatch, setAdapter, optionalParams, persistedState);
384
+ const initStartChatRelay = (optionalParams, persistedState) => initStartChat(chatSDK, props.authProps, dispatch, setAdapter, optionalParams, persistedState);
385
385
 
386
386
  const confirmationPaneProps = initConfirmationPropsComposer(props);
387
387
  return /*#__PURE__*/React.createElement(Composer, _extends({}, webChatProps, {
@@ -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
+ import { IAuthProps } from "../interfaces/IAuthProps";
5
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 };
@@ -2,7 +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 setPreChatAndInitiateChat: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, isProactiveChat?: boolean | false, proactiveChatEnablePrechatState?: boolean | false) => Promise<void>;
7
- declare const initStartChat: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, params?: any, persistedState?: any) => Promise<void>;
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>;
8
9
  export { prepareStartChat, initStartChat, setPreChatAndInitiateChat };
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/omnichannel-chat-widget",
3
- "version": "0.1.0-main.a60f242",
3
+ "version": "0.1.0-main.a72fbb6",
4
4
  "description": "Microsoft Omnichannel Chat Widget",
5
5
  "main": "lib/cjs/index.js",
6
6
  "types": "lib/types/index.d.ts",