@microsoft/omnichannel-chat-widget 0.1.0-main.cde77ea → 0.1.0-main.d48dae2

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 (21) hide show
  1. package/lib/cjs/common/telemetry/TelemetryConstants.js +2 -0
  2. package/lib/cjs/components/livechatwidget/common/createAdapter.js +1 -0
  3. package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +2 -5
  4. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +23 -15
  5. package/lib/cjs/components/livechatwidget/common/startChat.js +37 -10
  6. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +5 -5
  7. package/lib/esm/common/telemetry/TelemetryConstants.js +2 -0
  8. package/lib/esm/components/livechatwidget/common/createAdapter.js +1 -0
  9. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +2 -5
  10. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +24 -17
  11. package/lib/esm/components/livechatwidget/common/startChat.js +39 -13
  12. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +5 -5
  13. package/lib/types/common/telemetry/TelemetryConstants.d.ts +2 -0
  14. package/lib/types/common/utils.d.ts +1 -1
  15. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +4 -4
  16. package/lib/types/components/livechatwidget/common/startChat.d.ts +3 -3
  17. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +1 -2
  18. package/package.json +2 -2
  19. package/lib/cjs/components/livechatwidget/interfaces/IAuthProps.js +0 -1
  20. package/lib/esm/components/livechatwidget/interfaces/IAuthProps.js +0 -1
  21. package/lib/types/components/livechatwidget/interfaces/IAuthProps.d.ts +0 -4
@@ -143,6 +143,8 @@ exports.TelemetryEvent = TelemetryEvent;
143
143
  TelemetryEvent["SuppressBotMagicCodeFailed"] = "SuppressBotMagicCodeFailed";
144
144
  TelemetryEvent["GetConversationDetailsException"] = "GetConversationDetailsException";
145
145
  TelemetryEvent["BrowserUnloadEventStarted"] = "BrowserUnloadEventStarted";
146
+ TelemetryEvent["GetAuthTokenCalled"] = "GetAuthTokenCalled";
147
+ TelemetryEvent["ReceivedNullOrEmptyToken"] = "ReceivedNullOrEmptyToken";
146
148
  TelemetryEvent["ProcessingHTMLTextMiddlewareFailed"] = "ProcessingHTMLTextMiddlewareFailed";
147
149
  TelemetryEvent["ProcessingSanitizationMiddlewareFailed"] = "ProcessingSanitizationMiddlewareFailed";
148
150
  TelemetryEvent["FormatTagsMiddlewareJSONStringifyFailed"] = "FormatTagsMiddlewareJSONStringifyFailed";
@@ -40,6 +40,7 @@ const createAdapter = async chatSDK => {
40
40
 
41
41
  if (chatSDK.isMockModeOn !== true) {
42
42
  adapter = new _ChatAdapterShim.ChatAdapterShim(adapter);
43
+ return adapter.chatAdapter;
43
44
  }
44
45
 
45
46
  return adapter;
@@ -1704,10 +1704,7 @@ const dummyDefaultProps = {
1704
1704
  fwdUrl: ""
1705
1705
  }
1706
1706
  },
1707
- authProps: {
1708
- authClientFunction: undefined,
1709
- setAuthTokenProviderToChatSdk: undefined
1710
- },
1711
- telemetryConfig: undefined
1707
+ telemetryConfig: undefined,
1708
+ getAuthToken: undefined
1712
1709
  };
1713
1710
  exports.dummyDefaultProps = dummyDefaultProps;
@@ -44,9 +44,17 @@ const getChatReconnectContext = async (chatSDK, reconnectId) => {
44
44
  exports.getChatReconnectContext = getChatReconnectContext;
45
45
 
46
46
  const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
47
- var _props$reconnectChatP, _props$authProps;
47
+ var _props$chatConfig, _props$reconnectChatP;
48
48
 
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
49
+ let authClientFunction = undefined;
50
+
51
+ if ((_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && _props$chatConfig.LiveChatConfigAuthSettings) {
52
+ var _props$chatConfig2, _props$chatConfig2$Li;
53
+
54
+ authClientFunction = ((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Li = _props$chatConfig2.LiveChatConfigAuthSettings) === null || _props$chatConfig2$Li === void 0 ? void 0 : _props$chatConfig2$Li.msdyn_javascriptclientfunction) ?? undefined;
55
+ }
56
+
57
+ if ((_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.isReconnectEnabled && authClientFunction // TODO: Implement this after storage is in place
50
58
 
51
59
  /* && !isLoadWithState() */
52
60
  ) {
@@ -63,31 +71,31 @@ const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
63
71
 
64
72
  exports.getReconnectIdForAuthenticatedChat = getReconnectIdForAuthenticatedChat;
65
73
 
66
- const handleUnauthenticatedReconnectChat = async (chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat, redirectInSameWindow) => {
74
+ const handleUnauthenticatedReconnectChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat, redirectInSameWindow) => {
67
75
  const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
68
76
 
69
77
  if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
70
- await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, authProps, dispatch, setAdapter, initStartChat, redirectInSameWindow);
78
+ await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, redirectInSameWindow);
71
79
  } else {
72
- await setReconnectIdAndStartChat(chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat);
80
+ await setReconnectIdAndStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat);
73
81
  }
74
82
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
75
83
 
76
84
 
77
85
  exports.handleUnauthenticatedReconnectChat = handleUnauthenticatedReconnectChat;
78
86
 
79
- const startUnauthenticatedReconnectChat = async (chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat) => {
87
+ const startUnauthenticatedReconnectChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat) => {
80
88
  const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
81
89
 
82
90
  if (!shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
83
- await setReconnectIdAndStartChat(chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat);
91
+ await setReconnectIdAndStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat);
84
92
  }
85
93
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
86
94
 
87
95
 
88
96
  exports.startUnauthenticatedReconnectChat = startUnauthenticatedReconnectChat;
89
97
 
90
- const setReconnectIdAndStartChat = async (chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat) => {
98
+ const setReconnectIdAndStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat) => {
91
99
  const startUnauthenticatedReconnectChat = {
92
100
  eventName: _TelemetryConstants.BroadcastEvent.StartUnauthenticatedReconnectChat
93
101
  };
@@ -105,7 +113,7 @@ const setReconnectIdAndStartChat = async (chatSDK, authProps, dispatch, setAdapt
105
113
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
106
114
  payload: _ConversationState.ConversationState.Loading
107
115
  });
108
- await initStartChat(chatSDK, authProps, dispatch, setAdapter, optionalParams);
116
+ await initStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, optionalParams);
109
117
  };
110
118
 
111
119
  const redirectPage = (redirectURL, redirectInSameWindow) => {
@@ -128,7 +136,7 @@ const shouldRedirectOrStartNewChat = reconnectAvailabilityResponse => {
128
136
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
129
137
 
130
138
 
131
- const startNewChatEmptyRedirectionUrl = async (chatSDK, authProps, dispatch, setAdapter, initStartChat) => {
139
+ const startNewChatEmptyRedirectionUrl = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat) => {
132
140
  const startUnauthenticatedReconnectChat = {
133
141
  eventName: _TelemetryConstants.BroadcastEvent.StartUnauthenticatedReconnectChat
134
142
  };
@@ -153,26 +161,26 @@ const startNewChatEmptyRedirectionUrl = async (chatSDK, authProps, dispatch, set
153
161
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
154
162
  payload: _ConversationState.ConversationState.Loading
155
163
  });
156
- await initStartChat(chatSDK, authProps, dispatch, setAdapter);
164
+ await initStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter);
157
165
  }
158
166
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
159
167
 
160
168
 
161
- const handleRedirectUnauthenticatedReconnectChat = async (chatSDK, authProps, dispatch, setAdapter, initStartChat, reconnectId, redirectInSameWindow) => {
169
+ const handleRedirectUnauthenticatedReconnectChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, reconnectId, redirectInSameWindow) => {
162
170
  const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
163
171
 
164
172
  if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
165
- await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, authProps, dispatch, setAdapter, initStartChat, redirectInSameWindow);
173
+ await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, redirectInSameWindow);
166
174
  }
167
175
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
168
176
 
169
177
 
170
178
  exports.handleRedirectUnauthenticatedReconnectChat = handleRedirectUnauthenticatedReconnectChat;
171
179
 
172
- const redirectOrStartNewChat = async (reconnectAvailabilityResponse, chatSDK, authProps, dispatch, setAdapter, initStartChat, redirectInSameWindow) => {
180
+ const redirectOrStartNewChat = async (reconnectAvailabilityResponse, chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, redirectInSameWindow) => {
173
181
  if (reconnectAvailabilityResponse.redirectURL) {
174
182
  redirectPage(reconnectAvailabilityResponse.redirectURL, redirectInSameWindow);
175
183
  } else {
176
- await startNewChatEmptyRedirectionUrl(chatSDK, authProps, dispatch, setAdapter, initStartChat);
184
+ await startNewChatEmptyRedirectionUrl(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat);
177
185
  }
178
186
  };
@@ -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, 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);
55
+ await (0, _reconnectChatHelper.handleRedirectUnauthenticatedReconnectChat)(chatSDK, props.chatConfig, props.getAuthToken, 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, props.authProps, dispatch, setAdapter, isProactiveChat, isPreChatEnabledInProactiveChat);
80
+ setPreChatAndInitiateChat(chatSDK, props.chatConfig, props.getAuthToken, 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, authProps, dispatch, setAdapter, isProactiveChat, proactiveChatEnablePrechatState) => {
86
+ const setPreChatAndInitiateChat = async (chatSDK, chatConfig, getAuthToken, 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,43 @@ const setPreChatAndInitiateChat = async (chatSDK, authProps, dispatch, setAdapte
106
106
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
107
107
  payload: _ConversationState.ConversationState.Loading
108
108
  });
109
- await initStartChat(chatSDK, authProps, dispatch, setAdapter);
109
+ await initStartChat(chatSDK, chatConfig, getAuthToken, 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, authProps, dispatch, setAdapter, params, persistedState) => {
115
+ const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
116
+ if (getAuthToken) {
117
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
118
+ Event: _TelemetryConstants.TelemetryEvent.GetAuthTokenCalled
119
+ });
120
+
121
+ let authClientFunction = undefined;
122
+
123
+ if (chatConfig !== null && chatConfig !== void 0 && chatConfig.LiveChatConfigAuthSettings) {
124
+ var _chatConfig$LiveChatC;
125
+
126
+ authClientFunction = (chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig$LiveChatC = chatConfig.LiveChatConfigAuthSettings) === null || _chatConfig$LiveChatC === void 0 ? void 0 : _chatConfig$LiveChatC.msdyn_javascriptclientfunction) ?? undefined;
127
+ }
128
+
129
+ const token = await getAuthToken(authClientFunction);
130
+
131
+ if (!(0, _utils.isNullOrEmptyString)(token)) {
132
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
133
+ chatSDK.setAuthTokenProvider(async () => {
134
+ return token;
135
+ });
136
+ } else {
137
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
138
+ Event: _TelemetryConstants.TelemetryEvent.ReceivedNullOrEmptyToken
139
+ });
140
+ }
141
+ }
142
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
143
+
144
+
145
+ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, params, persistedState) => {
116
146
  try {
117
147
  var _newAdapter$activity$, _TelemetryTimers$Widg;
118
148
 
@@ -141,10 +171,7 @@ const initStartChat = async (chatSDK, authProps, dispatch, setAdapter, params, p
141
171
 
142
172
  optionalParams = Object.assign({}, params, optionalParams); // set auth token to chat sdk before start chat
143
173
 
144
- if (authProps && authProps.setAuthTokenProviderToChatSdk) {
145
- await authProps.setAuthTokenProviderToChatSdk(chatSDK, authProps.authClientFunction);
146
- }
147
-
174
+ await handleAuthentication(chatSDK, chatConfig, getAuthToken);
148
175
  await chatSDK.startChat(optionalParams);
149
176
  isStartChatSuccessful = true;
150
177
  } catch (error) {
@@ -256,7 +283,7 @@ const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdap
256
283
  const optionalParams = {
257
284
  liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai7 = persistedState.domainStates) === null || _persistedState$domai7 === void 0 ? void 0 : _persistedState$domai7.liveChatContext
258
285
  };
259
- await initStartChat(chatSDK, props.authProps, dispatch, setAdapter, optionalParams, persistedState);
286
+ await initStartChat(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter, optionalParams, persistedState);
260
287
  return true;
261
288
  } else {
262
289
  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, props.authProps, dispatch, setAdapter, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, _startChat.initStartChat);
188
+ (0, _reconnectChatHelper.startUnauthenticatedReconnectChat)(chatSDK, props.chatConfig, props.getAuthToken, 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, props.authProps, dispatch, setAdapter, optionalParams);
205
+ (0, _startChat.initStartChat)(chatSDK, props.chatConfig, props.getAuthToken, 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, 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);
228
+ (0, _reconnectChatHelper.handleUnauthenticatedReconnectChat)(chatSDK, props.chatConfig, props.getAuthToken, 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, props.authProps, dispatch, setAdapter);
247
+ (0, _startChat.setPreChatAndInitiateChat)(chatSDK, props.chatConfig, props.getAuthToken, 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, props.authProps, dispatch, setAdapter, optionalParams, persistedState);
456
+ const initStartChatRelay = (optionalParams, persistedState) => (0, _startChat.initStartChat)(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter, optionalParams, persistedState);
457
457
 
458
458
  const confirmationPaneProps = (0, _initConfirmationPropsComposer.initConfirmationPropsComposer)(props);
459
459
  return /*#__PURE__*/_react2.default.createElement(Composer, _extends({}, webChatProps, {
@@ -131,6 +131,8 @@ export let TelemetryEvent;
131
131
  TelemetryEvent["SuppressBotMagicCodeFailed"] = "SuppressBotMagicCodeFailed";
132
132
  TelemetryEvent["GetConversationDetailsException"] = "GetConversationDetailsException";
133
133
  TelemetryEvent["BrowserUnloadEventStarted"] = "BrowserUnloadEventStarted";
134
+ TelemetryEvent["GetAuthTokenCalled"] = "GetAuthTokenCalled";
135
+ TelemetryEvent["ReceivedNullOrEmptyToken"] = "ReceivedNullOrEmptyToken";
134
136
  TelemetryEvent["ProcessingHTMLTextMiddlewareFailed"] = "ProcessingHTMLTextMiddlewareFailed";
135
137
  TelemetryEvent["ProcessingSanitizationMiddlewareFailed"] = "ProcessingSanitizationMiddlewareFailed";
136
138
  TelemetryEvent["FormatTagsMiddlewareJSONStringifyFailed"] = "FormatTagsMiddlewareJSONStringifyFailed";
@@ -28,6 +28,7 @@ export const createAdapter = async chatSDK => {
28
28
 
29
29
  if (chatSDK.isMockModeOn !== true) {
30
30
  adapter = new ChatAdapterShim(adapter);
31
+ return adapter.chatAdapter;
31
32
  }
32
33
 
33
34
  return adapter;
@@ -1683,9 +1683,6 @@ export const dummyDefaultProps = {
1683
1683
  fwdUrl: ""
1684
1684
  }
1685
1685
  },
1686
- authProps: {
1687
- authClientFunction: undefined,
1688
- setAuthTokenProviderToChatSdk: undefined
1689
- },
1690
- telemetryConfig: undefined
1686
+ telemetryConfig: undefined,
1687
+ getAuthToken: undefined
1691
1688
  };
@@ -3,9 +3,8 @@ 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";
6
+ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
7
 
8
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
8
  const getChatReconnectContext = async (chatSDK, reconnectId) => {
10
9
  try {
11
10
  if (reconnectId) {
@@ -30,9 +29,17 @@ const getChatReconnectContext = async (chatSDK, reconnectId) => {
30
29
 
31
30
 
32
31
  const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
33
- var _props$reconnectChatP, _props$authProps;
32
+ var _props$chatConfig, _props$reconnectChatP;
34
33
 
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
34
+ let authClientFunction = undefined;
35
+
36
+ if ((_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && _props$chatConfig.LiveChatConfigAuthSettings) {
37
+ var _props$chatConfig2, _props$chatConfig2$Li;
38
+
39
+ authClientFunction = ((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Li = _props$chatConfig2.LiveChatConfigAuthSettings) === null || _props$chatConfig2$Li === void 0 ? void 0 : _props$chatConfig2$Li.msdyn_javascriptclientfunction) ?? undefined;
40
+ }
41
+
42
+ if ((_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.isReconnectEnabled && authClientFunction // TODO: Implement this after storage is in place
36
43
 
37
44
  /* && !isLoadWithState() */
38
45
  ) {
@@ -47,27 +54,27 @@ const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
47
54
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
55
 
49
56
 
50
- const handleUnauthenticatedReconnectChat = async (chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat, redirectInSameWindow) => {
57
+ const handleUnauthenticatedReconnectChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat, redirectInSameWindow) => {
51
58
  const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
52
59
 
53
60
  if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
54
- await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, authProps, dispatch, setAdapter, initStartChat, redirectInSameWindow);
61
+ await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, redirectInSameWindow);
55
62
  } else {
56
- await setReconnectIdAndStartChat(chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat);
63
+ await setReconnectIdAndStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat);
57
64
  }
58
65
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
59
66
 
60
67
 
61
- const startUnauthenticatedReconnectChat = async (chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat) => {
68
+ const startUnauthenticatedReconnectChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat) => {
62
69
  const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
63
70
 
64
71
  if (!shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
65
- await setReconnectIdAndStartChat(chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat);
72
+ await setReconnectIdAndStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat);
66
73
  }
67
74
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
68
75
 
69
76
 
70
- const setReconnectIdAndStartChat = async (chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat) => {
77
+ const setReconnectIdAndStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat) => {
71
78
  const startUnauthenticatedReconnectChat = {
72
79
  eventName: BroadcastEvent.StartUnauthenticatedReconnectChat
73
80
  };
@@ -83,7 +90,7 @@ const setReconnectIdAndStartChat = async (chatSDK, authProps, dispatch, setAdapt
83
90
  type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
84
91
  payload: ConversationState.Loading
85
92
  });
86
- await initStartChat(chatSDK, authProps, dispatch, setAdapter, optionalParams);
93
+ await initStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, optionalParams);
87
94
  };
88
95
 
89
96
  const redirectPage = (redirectURL, redirectInSameWindow) => {
@@ -105,7 +112,7 @@ const shouldRedirectOrStartNewChat = reconnectAvailabilityResponse => {
105
112
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
106
113
 
107
114
 
108
- const startNewChatEmptyRedirectionUrl = async (chatSDK, authProps, dispatch, setAdapter, initStartChat) => {
115
+ const startNewChatEmptyRedirectionUrl = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat) => {
109
116
  const startUnauthenticatedReconnectChat = {
110
117
  eventName: BroadcastEvent.StartUnauthenticatedReconnectChat
111
118
  };
@@ -128,25 +135,25 @@ const startNewChatEmptyRedirectionUrl = async (chatSDK, authProps, dispatch, set
128
135
  type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
129
136
  payload: ConversationState.Loading
130
137
  });
131
- await initStartChat(chatSDK, authProps, dispatch, setAdapter);
138
+ await initStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter);
132
139
  }
133
140
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
134
141
 
135
142
 
136
- const handleRedirectUnauthenticatedReconnectChat = async (chatSDK, authProps, dispatch, setAdapter, initStartChat, reconnectId, redirectInSameWindow) => {
143
+ const handleRedirectUnauthenticatedReconnectChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, reconnectId, redirectInSameWindow) => {
137
144
  const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
138
145
 
139
146
  if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
140
- await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, authProps, dispatch, setAdapter, initStartChat, redirectInSameWindow);
147
+ await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, redirectInSameWindow);
141
148
  }
142
149
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
143
150
 
144
151
 
145
- const redirectOrStartNewChat = async (reconnectAvailabilityResponse, chatSDK, authProps, dispatch, setAdapter, initStartChat, redirectInSameWindow) => {
152
+ const redirectOrStartNewChat = async (reconnectAvailabilityResponse, chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, redirectInSameWindow) => {
146
153
  if (reconnectAvailabilityResponse.redirectURL) {
147
154
  redirectPage(reconnectAvailabilityResponse.redirectURL, redirectInSameWindow);
148
155
  } else {
149
- await startNewChatEmptyRedirectionUrl(chatSDK, authProps, dispatch, setAdapter, initStartChat);
156
+ await startNewChatEmptyRedirectionUrl(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat);
150
157
  }
151
158
  };
152
159
 
@@ -8,12 +8,12 @@ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
8
8
  import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
9
9
  import { createAdapter } from "./createAdapter";
10
10
  import { createOnNewAdapterActivityHandler } from "../../../plugins/newMessageEventHandler";
11
- import { createTimer, getStateFromCache, isUndefinedOrEmpty } from "../../../common/utils";
11
+ import { createTimer, getStateFromCache, isNullOrEmptyString, isUndefinedOrEmpty } from "../../../common/utils";
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";
16
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
+ import { BroadcastService } from "@microsoft/omnichannel-chat-components"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+
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, 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);
33
+ await handleRedirectUnauthenticatedReconnectChat(chatSDK, props.chatConfig, props.getAuthToken, 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, props.authProps, dispatch, setAdapter, isProactiveChat, isPreChatEnabledInProactiveChat);
58
+ setPreChatAndInitiateChat(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter, isProactiveChat, isPreChatEnabledInProactiveChat);
59
59
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
60
60
 
61
61
 
62
- const setPreChatAndInitiateChat = async (chatSDK, authProps, dispatch, setAdapter, isProactiveChat, proactiveChatEnablePrechatState) => {
62
+ const setPreChatAndInitiateChat = async (chatSDK, chatConfig, getAuthToken, 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,40 @@ const setPreChatAndInitiateChat = async (chatSDK, authProps, dispatch, setAdapte
82
82
  type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
83
83
  payload: ConversationState.Loading
84
84
  });
85
- await initStartChat(chatSDK, authProps, dispatch, setAdapter);
85
+ await initStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter);
86
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
87
+
88
+
89
+ const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
90
+ if (getAuthToken) {
91
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
92
+ Event: TelemetryEvent.GetAuthTokenCalled
93
+ });
94
+ let authClientFunction = undefined;
95
+
96
+ if (chatConfig !== null && chatConfig !== void 0 && chatConfig.LiveChatConfigAuthSettings) {
97
+ var _chatConfig$LiveChatC;
98
+
99
+ authClientFunction = (chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig$LiveChatC = chatConfig.LiveChatConfigAuthSettings) === null || _chatConfig$LiveChatC === void 0 ? void 0 : _chatConfig$LiveChatC.msdyn_javascriptclientfunction) ?? undefined;
100
+ }
101
+
102
+ const token = await getAuthToken(authClientFunction);
103
+
104
+ if (!isNullOrEmptyString(token)) {
105
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
106
+ chatSDK.setAuthTokenProvider(async () => {
107
+ return token;
108
+ });
109
+ } else {
110
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
111
+ Event: TelemetryEvent.ReceivedNullOrEmptyToken
112
+ });
113
+ }
114
+ }
86
115
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
87
116
 
88
117
 
89
- const initStartChat = async (chatSDK, authProps, dispatch, setAdapter, params, persistedState) => {
118
+ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, params, persistedState) => {
90
119
  try {
91
120
  var _newAdapter$activity$, _TelemetryTimers$Widg;
92
121
 
@@ -113,10 +142,7 @@ const initStartChat = async (chatSDK, authProps, dispatch, setAdapter, params, p
113
142
 
114
143
  optionalParams = Object.assign({}, params, optionalParams); // set auth token to chat sdk before start chat
115
144
 
116
- if (authProps && authProps.setAuthTokenProviderToChatSdk) {
117
- await authProps.setAuthTokenProviderToChatSdk(chatSDK, authProps.authClientFunction);
118
- }
119
-
145
+ await handleAuthentication(chatSDK, chatConfig, getAuthToken);
120
146
  await chatSDK.startChat(optionalParams);
121
147
  isStartChatSuccessful = true;
122
148
  } catch (error) {
@@ -223,7 +249,7 @@ const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdap
223
249
  const optionalParams = {
224
250
  liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai7 = persistedState.domainStates) === null || _persistedState$domai7 === void 0 ? void 0 : _persistedState$domai7.liveChatContext
225
251
  };
226
- await initStartChat(chatSDK, props.authProps, dispatch, setAdapter, optionalParams, persistedState);
252
+ await initStartChat(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter, optionalParams, persistedState);
227
253
  return true;
228
254
  } else {
229
255
  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, props.authProps, dispatch, setAdapter, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, initStartChat);
133
+ startUnauthenticatedReconnectChat(chatSDK, props.chatConfig, props.getAuthToken, 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, props.authProps, dispatch, setAdapter, optionalParams);
150
+ initStartChat(chatSDK, props.chatConfig, props.getAuthToken, 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, 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);
173
+ handleUnauthenticatedReconnectChat(chatSDK, props.chatConfig, props.getAuthToken, 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, props.authProps, dispatch, setAdapter);
190
+ setPreChatAndInitiateChat(chatSDK, props.chatConfig, props.getAuthToken, 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, props.authProps, dispatch, setAdapter, optionalParams, persistedState);
384
+ const initStartChatRelay = (optionalParams, persistedState) => initStartChat(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter, optionalParams, persistedState);
385
385
 
386
386
  const confirmationPaneProps = initConfirmationPropsComposer(props);
387
387
  return /*#__PURE__*/React.createElement(Composer, _extends({}, webChatProps, {
@@ -121,6 +121,8 @@ export declare enum TelemetryEvent {
121
121
  SuppressBotMagicCodeFailed = "SuppressBotMagicCodeFailed",
122
122
  GetConversationDetailsException = "GetConversationDetailsException",
123
123
  BrowserUnloadEventStarted = "BrowserUnloadEventStarted",
124
+ GetAuthTokenCalled = "GetAuthTokenCalled",
125
+ ReceivedNullOrEmptyToken = "ReceivedNullOrEmptyToken",
124
126
  ProcessingHTMLTextMiddlewareFailed = "ProcessingHTMLTextMiddlewareFailed",
125
127
  ProcessingSanitizationMiddlewareFailed = "ProcessingSanitizationMiddlewareFailed",
126
128
  FormatTagsMiddlewareJSONStringifyFailed = "FormatTagsMiddlewareJSONStringifyFailed",
@@ -18,7 +18,7 @@ export declare const extractPreChatSurveyResponseValues: (preChatSurvey: string,
18
18
  value: string;
19
19
  }[]) => {};
20
20
  export declare const isNullOrUndefined: (obj: any) => boolean;
21
- export declare const isNullOrEmptyString: (s: string) => boolean;
21
+ export declare const isNullOrEmptyString: (s: string | null) => boolean;
22
22
  export declare const newGuid: () => string;
23
23
  export declare const createTimer: () => ITimer;
24
24
  export declare const getDomain: (hostValue: any) => string;
@@ -1,11 +1,11 @@
1
1
  import "regenerator-runtime/runtime";
2
+ import ChatConfig from "@microsoft/omnichannel-chat-sdk/lib/core/ChatConfig";
2
3
  import { Dispatch } from "react";
3
4
  import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetAction";
4
5
  import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
5
- import { IAuthProps } from "../interfaces/IAuthProps";
6
6
  declare const getChatReconnectContext: (chatSDK: any, reconnectId?: string) => Promise<any>;
7
7
  declare const getReconnectIdForAuthenticatedChat: (props: ILiveChatWidgetProps, chatSDK: any) => Promise<string | undefined>;
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>;
8
+ declare const handleUnauthenticatedReconnectChat: (chatSDK: any, chatConfig: ChatConfig | undefined, getAuthToken: ((authClientFunction?: string) => Promise<string | null>) | undefined, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, reconnectId: string, initStartChat: any, redirectInSameWindow: boolean | undefined) => Promise<void>;
9
+ declare const startUnauthenticatedReconnectChat: (chatSDK: any, chatConfig: ChatConfig | undefined, getAuthToken: ((authClientFunction?: string) => Promise<string | null>) | undefined, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, reconnectId: string, initStartChat: any) => Promise<void>;
10
+ declare const handleRedirectUnauthenticatedReconnectChat: (chatSDK: any, chatConfig: ChatConfig | undefined, getAuthToken: ((authClientFunction?: string) => Promise<string | null>) | undefined, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, initStartChat: any, reconnectId: string, redirectInSameWindow: boolean | undefined) => Promise<void>;
11
11
  export { getChatReconnectContext, getReconnectIdForAuthenticatedChat, handleUnauthenticatedReconnectChat, startUnauthenticatedReconnectChat, handleRedirectUnauthenticatedReconnectChat };
@@ -1,9 +1,9 @@
1
+ import ChatConfig from "@microsoft/omnichannel-chat-sdk/lib/core/ChatConfig";
1
2
  import { Dispatch } from "react";
2
3
  import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetAction";
3
4
  import { ILiveChatWidgetContext } from "../../../contexts/common/ILiveChatWidgetContext";
4
5
  import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
5
- import { IAuthProps } from "../interfaces/IAuthProps";
6
6
  declare const prepareStartChat: (props: ILiveChatWidgetProps, chatSDK: any, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: 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>;
7
+ declare const setPreChatAndInitiateChat: (chatSDK: any, chatConfig: ChatConfig | undefined, getAuthToken: ((authClientFunction?: string) => Promise<string | null>) | undefined, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, isProactiveChat?: boolean | false, proactiveChatEnablePrechatState?: boolean | false) => Promise<void>;
8
+ declare const initStartChat: (chatSDK: any, chatConfig: ChatConfig | undefined, getAuthToken: ((authClientFunction?: string) => Promise<string | null>) | undefined, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, params?: any, persistedState?: any) => Promise<void>;
9
9
  export { prepareStartChat, initStartChat, setPreChatAndInitiateChat };
@@ -21,7 +21,6 @@ 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";
25
24
  export interface ILiveChatWidgetProps {
26
25
  audioNotificationProps?: IAudioNotificationProps;
27
26
  callingContainerProps?: ICallingContainerProps;
@@ -50,5 +49,5 @@ export interface ILiveChatWidgetProps {
50
49
  webChatContainerProps?: IWebChatContainerStatefulProps;
51
50
  liveChatContextFromCache?: ILiveChatWidgetContext;
52
51
  contextDataStore?: IContextDataStore;
53
- authProps?: IAuthProps;
52
+ getAuthToken?: (authClientFunction?: string) => Promise<string | null>;
54
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/omnichannel-chat-widget",
3
- "version": "0.1.0-main.cde77ea",
3
+ "version": "0.1.0-main.d48dae2",
4
4
  "description": "Microsoft Omnichannel Chat Widget",
5
5
  "main": "lib/cjs/index.js",
6
6
  "types": "lib/types/index.d.ts",
@@ -74,7 +74,7 @@
74
74
  },
75
75
  "dependencies": {
76
76
  "@fluentui/react": "^8.49.1",
77
- "@microsoft/omnichannel-chat-components": "0.1.0-main.b59a07c",
77
+ "@microsoft/omnichannel-chat-components": "0.1.0-main.7a911ca",
78
78
  "@microsoft/omnichannel-chat-sdk": "1.0.1-main.077d17c",
79
79
  "abort-controller-es5": "^2.0.1",
80
80
  "dompurify": "^2.3.4",
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,4 +0,0 @@
1
- export interface IAuthProps {
2
- authClientFunction?: string;
3
- setAuthTokenProviderToChatSdk?: (chatSDK: any, authClientFunction?: string) => Promise<void>;
4
- }