@microsoft/omnichannel-chat-widget 1.8.4-main.a98d067 → 1.8.4-main.ab10cbb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/common/facades/FacadeChatSDK.js +235 -9
- package/lib/cjs/common/telemetry/TelemetryConstants.js +9 -0
- package/lib/cjs/components/livechatwidget/LiveChatWidget.js +9 -1
- package/lib/cjs/components/livechatwidget/common/authHelper.js +44 -4
- package/lib/cjs/components/livechatwidget/common/endChat.js +2 -0
- package/lib/cjs/components/livechatwidget/common/startChat.js +31 -14
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +98 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +2 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +24 -7
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +8 -3
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +6 -1
- package/lib/cjs/contexts/createReducer.js +15 -0
- package/lib/cjs/plugins/newMessageEventHandler.js +20 -3
- package/lib/esm/common/facades/FacadeChatSDK.js +236 -10
- package/lib/esm/common/telemetry/TelemetryConstants.js +9 -0
- package/lib/esm/components/livechatwidget/LiveChatWidget.js +9 -1
- package/lib/esm/components/livechatwidget/common/authHelper.js +44 -4
- package/lib/esm/components/livechatwidget/common/endChat.js +2 -0
- package/lib/esm/components/livechatwidget/common/startChat.js +31 -14
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +98 -1
- package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +2 -2
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +21 -5
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +8 -3
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +6 -1
- package/lib/esm/contexts/createReducer.js +15 -0
- package/lib/esm/plugins/newMessageEventHandler.js +20 -3
- package/lib/types/common/facades/FacadeChatSDK.d.ts +29 -0
- package/lib/types/common/facades/types/IFacadeChatSDKInput.d.ts +3 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +9 -2
- package/lib/types/components/livechatwidget/common/authHelper.d.ts +9 -2
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.d.ts +3 -0
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +2 -1
- package/package.json +2 -2
|
@@ -26,6 +26,8 @@ let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
26
26
|
_defineProperty(this, "getAuthToken", void 0);
|
|
27
27
|
_defineProperty(this, "sdkMocked", void 0);
|
|
28
28
|
_defineProperty(this, "disableReauthentication", void 0);
|
|
29
|
+
// Stays true so CASE 1 re-triggers on every startChat to set deferInitialAuth
|
|
30
|
+
_defineProperty(this, "pendingMidAuthUnauthenticatedState", false);
|
|
29
31
|
this.chatSDK = input.chatSDK;
|
|
30
32
|
this.chatConfig = input.chatConfig;
|
|
31
33
|
this.getAuthToken = input.getAuthToken;
|
|
@@ -50,6 +52,12 @@ let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
50
52
|
value: function destroy() {
|
|
51
53
|
this.token = null;
|
|
52
54
|
this.expiration = 0;
|
|
55
|
+
if ((0, _authHelper.isMidAuthEnabled)(this.chatConfig)) {
|
|
56
|
+
this.pendingMidAuthUnauthenticatedState = false;
|
|
57
|
+
this.isAuthenticated = true;
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
59
|
+
this.chatSDK.deferInitialAuth = false;
|
|
60
|
+
}
|
|
53
61
|
}
|
|
54
62
|
}, {
|
|
55
63
|
key: "isTokenSet",
|
|
@@ -214,6 +222,10 @@ let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
214
222
|
message: "Token is valid"
|
|
215
223
|
};
|
|
216
224
|
}
|
|
225
|
+
|
|
226
|
+
// Token missing or expired - need to get a new one via getAuthToken
|
|
227
|
+
// For mid-auth: getAuthToken receives { isMidAuthEnabled: true } so customer implementations
|
|
228
|
+
// can check portal state and return null for logged-out users
|
|
217
229
|
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
218
230
|
Event: _TelemetryConstants.TelemetryEvent.NewTokenValidationStarted,
|
|
219
231
|
Description: "Token validation started."
|
|
@@ -234,6 +246,7 @@ let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
234
246
|
this.token = "";
|
|
235
247
|
this.expiration = 0;
|
|
236
248
|
try {
|
|
249
|
+
var _ring$error, _ring$error2;
|
|
237
250
|
const ring = await (0, _authHelper.handleAuthentication)(this.chatSDK, this.chatConfig, this.getAuthToken);
|
|
238
251
|
if ((ring === null || ring === void 0 ? void 0 : ring.result) === true && ring !== null && ring !== void 0 && ring.token) {
|
|
239
252
|
await this.setToken(ring.token);
|
|
@@ -248,18 +261,35 @@ let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
248
261
|
result: true,
|
|
249
262
|
message: "New Token obtained"
|
|
250
263
|
};
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// Mid-auth: no token available - set pending flag for startChat to handle
|
|
267
|
+
const isEmptyTokenWithoutError = (0, _utils.isNullOrEmptyString)(ring === null || ring === void 0 ? void 0 : ring.token) && ((ring === null || ring === void 0 ? void 0 : ring.result) === true || (ring === null || ring === void 0 ? void 0 : ring.result) === false && !(ring !== null && ring !== void 0 && ring.error));
|
|
268
|
+
if ((0, _authHelper.isMidAuthEnabled)(this.chatConfig) && isEmptyTokenWithoutError) {
|
|
269
|
+
// Clear Facade and SDK token state so API calls use unauthenticated endpoints
|
|
270
|
+
this.token = "";
|
|
271
|
+
this.expiration = 0;
|
|
272
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
273
|
+
this.chatSDK.authenticatedUserToken = null;
|
|
274
|
+
this.pendingMidAuthUnauthenticatedState = true;
|
|
275
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
276
|
+
Event: _TelemetryConstants.TelemetryEvent.NewTokenValidationCompleted,
|
|
277
|
+
Description: "Mid-auth enabled: no token returned; proceeding as unauthenticated"
|
|
257
278
|
});
|
|
258
279
|
return {
|
|
259
|
-
result:
|
|
260
|
-
message:
|
|
280
|
+
result: true,
|
|
281
|
+
message: "Mid-auth: proceeding as unauthenticated"
|
|
261
282
|
};
|
|
262
283
|
}
|
|
284
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.ERROR, {
|
|
285
|
+
Event: _TelemetryConstants.TelemetryEvent.NewTokenValidationFailed,
|
|
286
|
+
Description: (_ring$error = ring.error) === null || _ring$error === void 0 ? void 0 : _ring$error.message,
|
|
287
|
+
ExceptionDetails: ring === null || ring === void 0 ? void 0 : ring.error
|
|
288
|
+
});
|
|
289
|
+
return {
|
|
290
|
+
result: false,
|
|
291
|
+
message: (ring === null || ring === void 0 ? void 0 : (_ring$error2 = ring.error) === null || _ring$error2 === void 0 ? void 0 : _ring$error2.message) || "Failed to get token"
|
|
292
|
+
};
|
|
263
293
|
} catch (e) {
|
|
264
294
|
console.error("Unexpected error while getting token", e);
|
|
265
295
|
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.ERROR, {
|
|
@@ -273,6 +303,155 @@ let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
273
303
|
};
|
|
274
304
|
}
|
|
275
305
|
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Sets unauthenticated state for mid-auth flow.
|
|
309
|
+
* Clears SDK internal state to prevent reconnection to previous authenticated session.
|
|
310
|
+
*/
|
|
311
|
+
}, {
|
|
312
|
+
key: "setMidAuthUnauthenticatedState",
|
|
313
|
+
value: function setMidAuthUnauthenticatedState() {
|
|
314
|
+
var _sdk$chatToken, _sdk$chatToken2;
|
|
315
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
316
|
+
const sdk = this.chatSDK;
|
|
317
|
+
const hadExistingChat = !!((_sdk$chatToken = sdk.chatToken) !== null && _sdk$chatToken !== void 0 && _sdk$chatToken.chatId);
|
|
318
|
+
const previousChatId = (_sdk$chatToken2 = sdk.chatToken) === null || _sdk$chatToken2 === void 0 ? void 0 : _sdk$chatToken2.chatId;
|
|
319
|
+
this.clearAuthState();
|
|
320
|
+
|
|
321
|
+
// Clear SDK internal state for fresh unauthenticated chat
|
|
322
|
+
sdk.chatToken = {};
|
|
323
|
+
sdk.reconnectId = null;
|
|
324
|
+
sdk.requestId = null;
|
|
325
|
+
sdk.sessionId = null;
|
|
326
|
+
sdk.conversation = null;
|
|
327
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
328
|
+
Event: _TelemetryConstants.TelemetryEvent.MidConversationAuthReset,
|
|
329
|
+
Description: hadExistingChat ? "Mid-auth without token: local state cleared" : "Mid-auth: initialized as unauthenticated (no prior chat)",
|
|
330
|
+
Data: hadExistingChat ? {
|
|
331
|
+
previousChatId
|
|
332
|
+
} : undefined
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/** Clears authentication state in both FacadeChatSDK and underlying SDK */
|
|
337
|
+
}, {
|
|
338
|
+
key: "clearAuthState",
|
|
339
|
+
value: function clearAuthState() {
|
|
340
|
+
this.token = "";
|
|
341
|
+
this.expiration = 0;
|
|
342
|
+
this.isAuthenticated = false;
|
|
343
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
344
|
+
this.chatSDK.authenticatedUserToken = null;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Migrates conversation from unauthenticated to authenticated via authenticateChat.
|
|
349
|
+
* Called after startChat() when user has a valid token but the backend conversation
|
|
350
|
+
* was started as unauthenticated.
|
|
351
|
+
*/
|
|
352
|
+
}, {
|
|
353
|
+
key: "migrateConversationToAuthenticated",
|
|
354
|
+
value: async function migrateConversationToAuthenticated() {
|
|
355
|
+
try {
|
|
356
|
+
await this.chatSDK.authenticateChat(this.token, {
|
|
357
|
+
refreshChatToken: true
|
|
358
|
+
});
|
|
359
|
+
this.isAuthenticated = true;
|
|
360
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
361
|
+
Event: _TelemetryConstants.TelemetryEvent.MidConversationAuthSucceeded,
|
|
362
|
+
Description: "Mid-auth: authenticateChat completed, conversation migrated to authenticated"
|
|
363
|
+
});
|
|
364
|
+
} catch (e) {
|
|
365
|
+
// Non-fatal: Chat is already active via startChat, will retry on next reconnect
|
|
366
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.WARN, {
|
|
367
|
+
Event: _TelemetryConstants.TelemetryEvent.MidConversationAuthFailed,
|
|
368
|
+
Description: "Mid-auth: authenticateChat returned error after startChat, chat still active",
|
|
369
|
+
ExceptionDetails: {
|
|
370
|
+
message: e === null || e === void 0 ? void 0 : e.message
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Configures SDK auth state before startChat.
|
|
378
|
+
* CASE 1: Pending unauthenticated (no token) - sets deferInitialAuth=true
|
|
379
|
+
* CASE 2: Authenticated with valid token - sets SDK token and deferInitialAuth based on scenario
|
|
380
|
+
*/
|
|
381
|
+
}, {
|
|
382
|
+
key: "configureMidAuthState",
|
|
383
|
+
value: function configureMidAuthState(isReconnect, wasPreviousSessionAuthenticated) {
|
|
384
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
385
|
+
const sdk = this.chatSDK;
|
|
386
|
+
|
|
387
|
+
// CASE 1: No token available (user not logged in)
|
|
388
|
+
// pendingMidAuthUnauthenticatedState stays true until user logs in (cleared in tokenRing)
|
|
389
|
+
if (this.pendingMidAuthUnauthenticatedState) {
|
|
390
|
+
const shouldClear = this.handlePendingUnauthenticatedState(wasPreviousSessionAuthenticated);
|
|
391
|
+
sdk.deferInitialAuth = true;
|
|
392
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
393
|
+
Event: _TelemetryConstants.TelemetryEvent.MidConversationAuthReset,
|
|
394
|
+
Description: "Mid-auth configureMidAuthState: CASE 1 - unauthenticated, deferInitialAuth=true",
|
|
395
|
+
Data: {
|
|
396
|
+
isReconnect: String(isReconnect),
|
|
397
|
+
wasPreviousSessionAuthenticated: String(wasPreviousSessionAuthenticated),
|
|
398
|
+
shouldClearReconnectParams: String(shouldClear)
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
return {
|
|
402
|
+
shouldClearReconnectParams: shouldClear
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// CASE 2: Authenticated with valid token
|
|
407
|
+
if (this.isTokenSet() && !this.isTokenExpired()) {
|
|
408
|
+
this.handleAuthenticatedState(isReconnect, wasPreviousSessionAuthenticated);
|
|
409
|
+
}
|
|
410
|
+
return {
|
|
411
|
+
shouldClearReconnectParams: false
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* CASE 1 handler: Returns true if reconnect params should be cleared (Auth -> Unauth transition)
|
|
417
|
+
*/
|
|
418
|
+
}, {
|
|
419
|
+
key: "handlePendingUnauthenticatedState",
|
|
420
|
+
value: function handlePendingUnauthenticatedState(wasPreviousSessionAuthenticated) {
|
|
421
|
+
if (wasPreviousSessionAuthenticated) {
|
|
422
|
+
// Auth -> Unauth: user logged out, clear state for fresh chat
|
|
423
|
+
this.setMidAuthUnauthenticatedState();
|
|
424
|
+
return true;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
// Unauth -> Unauth: keep liveChatContext for reconnection
|
|
428
|
+
this.isAuthenticated = false;
|
|
429
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
430
|
+
this.chatSDK.authenticatedUserToken = null;
|
|
431
|
+
return false;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* CASE 2 handler: Sets deferInitialAuth only for reconnects to unauthenticated sessions (need migration).
|
|
436
|
+
* For new chats or reconnects to authenticated sessions, SDK handles auth internally.
|
|
437
|
+
*/
|
|
438
|
+
}, {
|
|
439
|
+
key: "handleAuthenticatedState",
|
|
440
|
+
value: function handleAuthenticatedState(isReconnect, wasPreviousSessionAuthenticated) {
|
|
441
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
442
|
+
const sdk = this.chatSDK;
|
|
443
|
+
sdk.authenticatedUserToken = this.token;
|
|
444
|
+
if (isReconnect && !wasPreviousSessionAuthenticated) {
|
|
445
|
+
sdk.deferInitialAuth = true;
|
|
446
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
447
|
+
Event: _TelemetryConstants.TelemetryEvent.MidConversationAuthSucceeded,
|
|
448
|
+
Description: "Mid-auth handleAuthenticatedState: CASE 2 - reconnect to unauth session, deferInitialAuth=true (migration needed)"
|
|
449
|
+
});
|
|
450
|
+
} else {
|
|
451
|
+
// Reset to prevent inheriting deferInitialAuth=true from a previous unauthenticated chat
|
|
452
|
+
sdk.deferInitialAuth = false;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
276
455
|
}, {
|
|
277
456
|
key: "validateAndExecuteCall",
|
|
278
457
|
value: async function validateAndExecuteCall(functionName, fn) {
|
|
@@ -307,7 +486,53 @@ let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
307
486
|
key: "startChat",
|
|
308
487
|
value: async function startChat() {
|
|
309
488
|
let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
310
|
-
|
|
489
|
+
const midAuthEnabled = (0, _authHelper.isMidAuthEnabled)(this.chatConfig);
|
|
490
|
+
const isReconnect = !!optionalParams.liveChatContext || !!optionalParams.reconnectId;
|
|
491
|
+
const wasPreviousSessionAuthenticated = optionalParams.wasAuthenticated === true;
|
|
492
|
+
return this.validateAndExecuteCall("startChat", async () => {
|
|
493
|
+
if (midAuthEnabled) {
|
|
494
|
+
const {
|
|
495
|
+
shouldClearReconnectParams
|
|
496
|
+
} = this.configureMidAuthState(isReconnect, wasPreviousSessionAuthenticated);
|
|
497
|
+
if (shouldClearReconnectParams) {
|
|
498
|
+
delete optionalParams.liveChatContext;
|
|
499
|
+
delete optionalParams.reconnectId;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
await this.chatSDK.startChat(optionalParams);
|
|
503
|
+
|
|
504
|
+
// Migrate to authenticated if needed (reconnects to unauthenticated sessions only)
|
|
505
|
+
if (midAuthEnabled) {
|
|
506
|
+
const shouldMigrateToAuth = isReconnect && this.isTokenSet() && !this.isTokenExpired() && !wasPreviousSessionAuthenticated;
|
|
507
|
+
if (shouldMigrateToAuth) {
|
|
508
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
509
|
+
Event: _TelemetryConstants.TelemetryEvent.MidConversationAuthSucceeded,
|
|
510
|
+
Description: "Mid-auth startChat: initiating migration to authenticated",
|
|
511
|
+
Data: {
|
|
512
|
+
isReconnect: String(isReconnect),
|
|
513
|
+
wasPreviousSessionAuthenticated: String(wasPreviousSessionAuthenticated)
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
await this.migrateConversationToAuthenticated();
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
// Broadcast final auth state after startChat completes (only on state change)
|
|
521
|
+
if (midAuthEnabled) {
|
|
522
|
+
const isAuthenticatedAfterStart = this.isTokenSet() && !this.isTokenExpired();
|
|
523
|
+
const authStateChanged = !isReconnect || isAuthenticatedAfterStart !== wasPreviousSessionAuthenticated;
|
|
524
|
+
if (authStateChanged) {
|
|
525
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
526
|
+
eventName: isAuthenticatedAfterStart ? _TelemetryConstants.BroadcastEvent.MidConversationAuthSucceeded : _TelemetryConstants.BroadcastEvent.MidConversationAuthReset,
|
|
527
|
+
payload: {
|
|
528
|
+
isAuthenticated: isAuthenticatedAfterStart,
|
|
529
|
+
isStartChatComplete: true,
|
|
530
|
+
isReconnect
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
});
|
|
311
536
|
}
|
|
312
537
|
}, {
|
|
313
538
|
key: "endChat",
|
|
@@ -445,6 +670,7 @@ let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
445
670
|
let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
446
671
|
return this.validateAndExecuteCall("getAgentAvailability", () => this.chatSDK.getAgentAvailability(optionalParams));
|
|
447
672
|
}
|
|
673
|
+
|
|
448
674
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
449
675
|
}, {
|
|
450
676
|
key: "getReconnectableChats",
|
|
@@ -74,6 +74,8 @@ exports.BroadcastEvent = BroadcastEvent;
|
|
|
74
74
|
BroadcastEvent["FMLTrackingCompletedAck"] = "FMLTrackingCompletedAck";
|
|
75
75
|
BroadcastEvent["FMLTrackingCompleted"] = "FMLTrackingCompleted";
|
|
76
76
|
BroadcastEvent["PersistentConversationReset"] = "PersistentConversationReset";
|
|
77
|
+
BroadcastEvent["MidConversationAuthSucceeded"] = "MidConversationAuthSucceeded";
|
|
78
|
+
BroadcastEvent["MidConversationAuthReset"] = "MidConversationAuthReset";
|
|
77
79
|
})(BroadcastEvent || (exports.BroadcastEvent = BroadcastEvent = {}));
|
|
78
80
|
let TelemetryEvent;
|
|
79
81
|
exports.TelemetryEvent = TelemetryEvent;
|
|
@@ -108,6 +110,9 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
108
110
|
TelemetryEvent["CallingSDKInitFailed"] = "CallingSDKInitFailed";
|
|
109
111
|
TelemetryEvent["CallingSDKLoadSuccess"] = "CallingSDKLoadSuccess";
|
|
110
112
|
TelemetryEvent["CallingSDKLoadFailed"] = "CallingSDKLoadFailed";
|
|
113
|
+
TelemetryEvent["MidConversationAuthSucceeded"] = "MidConversationAuthSucceeded";
|
|
114
|
+
TelemetryEvent["MidConversationAuthFailed"] = "MidConversationAuthFailed";
|
|
115
|
+
TelemetryEvent["MidConversationAuthReset"] = "MidConversationAuthReset";
|
|
111
116
|
TelemetryEvent["GetConversationDetailsCallStarted"] = "GetConversationDetailsCallStarted";
|
|
112
117
|
TelemetryEvent["GetConversationDetailsCallFailed"] = "GetConversationDetailsCallFailed";
|
|
113
118
|
TelemetryEvent["EndChatSDKCallFailed"] = "EndChatSDKCallFailed";
|
|
@@ -326,6 +331,8 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
326
331
|
TelemetryEvent["SecureEventBusListenerError"] = "SecureEventBusListenerError";
|
|
327
332
|
TelemetryEvent["SecureEventBusDispatchError"] = "SecureEventBusDispatchError";
|
|
328
333
|
TelemetryEvent["StartChatComplete"] = "StartChatComplete";
|
|
334
|
+
TelemetryEvent["AgentJoinedConversation"] = "AgentJoinedConversation";
|
|
335
|
+
TelemetryEvent["BrowserTabHidden"] = "BrowserTabHidden";
|
|
329
336
|
})(TelemetryEvent || (exports.TelemetryEvent = TelemetryEvent = {}));
|
|
330
337
|
let TelemetryConstants = /*#__PURE__*/function () {
|
|
331
338
|
function TelemetryConstants() {
|
|
@@ -396,6 +403,8 @@ let TelemetryConstants = /*#__PURE__*/function () {
|
|
|
396
403
|
case TelemetryEvent.SecureEventBusUnauthorizedDispatch:
|
|
397
404
|
case TelemetryEvent.SecureEventBusListenerError:
|
|
398
405
|
case TelemetryEvent.SecureEventBusDispatchError:
|
|
406
|
+
case TelemetryEvent.AgentJoinedConversation:
|
|
407
|
+
case TelemetryEvent.BrowserTabHidden:
|
|
399
408
|
return ScenarioType.ACTIONS;
|
|
400
409
|
case TelemetryEvent.StartChatSDKCall:
|
|
401
410
|
case TelemetryEvent.StartChatEventReceived:
|
|
@@ -35,8 +35,16 @@ const LiveChatWidget = props => {
|
|
|
35
35
|
throw new Error("chatConfig is required");
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
// Check configuration flags
|
|
38
39
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
|
-
const
|
|
40
|
+
const hasAuthClientFn = !!((_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && (_props$chatConfig$Liv = _props$chatConfig.LiveChatConfigAuthSettings) !== null && _props$chatConfig$Liv !== void 0 && _props$chatConfig$Liv.msdyn_javascriptclientfunction);
|
|
41
|
+
const persistentChatEnabled = (0, _liveChatConfigUtils.isPersistentChatEnabled)((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Li = _props$chatConfig2.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig2$Li === void 0 ? void 0 : _props$chatConfig2$Li.msdyn_conversationmode);
|
|
42
|
+
|
|
43
|
+
// isAuthenticatedChat determines if FacadeChatSDK should require authentication:
|
|
44
|
+
// REGULAR AUTH FLOW (config-based):
|
|
45
|
+
// - Persistent chat enabled ? always authenticated
|
|
46
|
+
// - Auth settings exist ? authenticated from start
|
|
47
|
+
const isAuthenticatedChat = persistentChatEnabled || hasAuthClientFn;
|
|
40
48
|
if (!facadeChatSDK) {
|
|
41
49
|
var _props$mock;
|
|
42
50
|
setFacadeChatSDK(new _FacadeChatSDK.FacadeChatSDK({
|
|
@@ -3,11 +3,22 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.removeAuthTokenProvider = exports.handleAuthentication = exports.getAuthClientFunction = void 0;
|
|
6
|
+
exports.removeAuthTokenProvider = exports.isMidAuthEnabled = exports.handleAuthentication = exports.getAuthClientFunction = void 0;
|
|
7
7
|
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
8
8
|
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
9
9
|
var _Constants = require("../../../common/Constants");
|
|
10
10
|
var _utils = require("../../../common/utils");
|
|
11
|
+
/**
|
|
12
|
+
* Check if mid-auth is enabled based on chatConfig.
|
|
13
|
+
* Mid-auth flag lives under LiveWSAndLiveChatEngJoin.msdyn_authenticatedsigninoptional.
|
|
14
|
+
*/
|
|
15
|
+
const isMidAuthEnabled = chatConfig => {
|
|
16
|
+
var _chatConfig$LiveWSAnd, _value$toString, _value$toString$call$, _value$toString$call;
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
const value = chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig$LiveWSAnd = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd === void 0 ? void 0 : _chatConfig$LiveWSAnd.msdyn_authenticatedsigninoptional;
|
|
19
|
+
return (value === null || value === void 0 ? void 0 : (_value$toString = value.toString) === null || _value$toString === void 0 ? void 0 : (_value$toString$call$ = (_value$toString$call = _value$toString.call(value)).toLowerCase) === null || _value$toString$call$ === void 0 ? void 0 : _value$toString$call$.call(_value$toString$call)) === "true";
|
|
20
|
+
};
|
|
21
|
+
exports.isMidAuthEnabled = isMidAuthEnabled;
|
|
11
22
|
const getAuthClientFunction = chatConfig => {
|
|
12
23
|
let authClientFunction = undefined;
|
|
13
24
|
if (chatConfig !== null && chatConfig !== void 0 && chatConfig.LiveChatConfigAuthSettings) {
|
|
@@ -19,12 +30,17 @@ const getAuthClientFunction = chatConfig => {
|
|
|
19
30
|
exports.getAuthClientFunction = getAuthClientFunction;
|
|
20
31
|
const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
|
|
21
32
|
var _chatSDK$chatSDKConfi;
|
|
33
|
+
const midAuthEnabled = isMidAuthEnabled(chatConfig);
|
|
22
34
|
const authClientFunction = getAuthClientFunction(chatConfig);
|
|
23
35
|
if (getAuthToken && authClientFunction) {
|
|
24
36
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
25
37
|
Event: _TelemetryConstants.TelemetryEvent.GetAuthTokenCalled
|
|
26
38
|
});
|
|
27
|
-
|
|
39
|
+
|
|
40
|
+
// Only pass isMidAuthEnabled option when mid-auth is enabled.
|
|
41
|
+
const token = midAuthEnabled ? await getAuthToken(authClientFunction, {
|
|
42
|
+
isMidAuthEnabled: midAuthEnabled
|
|
43
|
+
}) : await getAuthToken(authClientFunction);
|
|
28
44
|
if (!(0, _utils.isNullOrEmptyString)(token)) {
|
|
29
45
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
46
|
chatSDK.setAuthTokenProvider(async () => {
|
|
@@ -35,8 +51,21 @@ const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
|
|
|
35
51
|
"token": token
|
|
36
52
|
};
|
|
37
53
|
} else {
|
|
38
|
-
//
|
|
39
|
-
//
|
|
54
|
+
// For mid-auth scenarios, empty token means "user not signed in" - this is expected behavior.
|
|
55
|
+
// Return result: true with empty token so caller can decide to proceed unauthenticated.
|
|
56
|
+
if (midAuthEnabled) {
|
|
57
|
+
// Expected behavior for mid-auth: user not signed in
|
|
58
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
59
|
+
Event: _TelemetryConstants.TelemetryEvent.GetAuthTokenCalled,
|
|
60
|
+
Description: "Mid-auth: token provider returned empty; user not signed in"
|
|
61
|
+
});
|
|
62
|
+
return {
|
|
63
|
+
"result": true,
|
|
64
|
+
"token": null
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// For non-mid-auth scenarios, empty token is an error
|
|
40
69
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
41
70
|
Event: _TelemetryConstants.TelemetryEvent.ReceivedNullOrEmptyToken
|
|
42
71
|
});
|
|
@@ -46,6 +75,17 @@ const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
|
|
|
46
75
|
var _chatSDK$chatSDKConfi2;
|
|
47
76
|
const token = await ((_chatSDK$chatSDKConfi2 = chatSDK.chatSDKConfig) === null || _chatSDK$chatSDKConfi2 === void 0 ? void 0 : _chatSDK$chatSDKConfi2.getAuthToken());
|
|
48
77
|
if ((0, _utils.isNullOrEmptyString)(token)) {
|
|
78
|
+
// For mid-auth scenarios, empty token from SDK's getAuthToken is also expected
|
|
79
|
+
if (midAuthEnabled) {
|
|
80
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
81
|
+
Event: _TelemetryConstants.TelemetryEvent.GetAuthTokenCalled,
|
|
82
|
+
Description: "Mid-auth: SDK getAuthToken returned empty; user not signed in"
|
|
83
|
+
});
|
|
84
|
+
return {
|
|
85
|
+
"result": true,
|
|
86
|
+
"token": null
|
|
87
|
+
};
|
|
88
|
+
}
|
|
49
89
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
50
90
|
Event: _TelemetryConstants.TelemetryEvent.ReceivedNullOrEmptyToken,
|
|
51
91
|
Description: "getAuthToken in chat SDK returns empty string"
|
|
@@ -11,6 +11,7 @@ var _renderSurveyHelpers = require("./renderSurveyHelpers");
|
|
|
11
11
|
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
12
12
|
var _ConversationState = require("../../../contexts/common/ConversationState");
|
|
13
13
|
var _LazyLoadActivity = require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity");
|
|
14
|
+
var _activityMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware");
|
|
14
15
|
var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
|
|
15
16
|
var _NotificationHandler = require("../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler");
|
|
16
17
|
var _NotificationScenarios = require("../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios");
|
|
@@ -249,6 +250,7 @@ const endChat = async (props, facadeChatSDK, state, dispatch, setAdapter, setWeb
|
|
|
249
250
|
|
|
250
251
|
// Call direct reset to ensure LazyLoadHandler gets reset regardless of broadcast timing
|
|
251
252
|
_LazyLoadActivity.LazyLoadHandler.directReset();
|
|
253
|
+
(0, _activityMiddleware.resetActivityMiddlewareCache)();
|
|
252
254
|
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
253
255
|
eventName: _TelemetryConstants.BroadcastEvent.PersistentConversationReset
|
|
254
256
|
});
|
|
@@ -20,6 +20,7 @@ var _createAdapter = require("./createAdapter");
|
|
|
20
20
|
var _newMessageEventHandler = require("../../../plugins/newMessageEventHandler");
|
|
21
21
|
var _FirstMessageTrackerFromBot = require("../../../firstresponselatency/FirstMessageTrackerFromBot");
|
|
22
22
|
var _liveChatConfigUtils = require("./liveChatConfigUtils");
|
|
23
|
+
var _authHelper = require("./authHelper");
|
|
23
24
|
var _setPostChatContextAndLoadSurvey = require("./setPostChatContextAndLoadSurvey");
|
|
24
25
|
var _persistentChatHelper = require("./persistentChatHelper");
|
|
25
26
|
var _updateSessionDataForTelemetry = require("./updateSessionDataForTelemetry");
|
|
@@ -65,7 +66,7 @@ const prepareStartChat = async (props, facadeChatSDK, state, dispatch, setAdapte
|
|
|
65
66
|
exports.prepareStartChat = prepareStartChat;
|
|
66
67
|
const setPreChatAndInitiateChat = async (facadeChatSDK, dispatch, setAdapter, isProactiveChat, proactiveChatEnablePrechatState, state, props) => {
|
|
67
68
|
var _props$preChatSurveyP, _props$preChatSurveyP2, _props$controlProps, _state$domainStates, _state$domainStates$l, _state$domainStates$l2, _state$appStates2;
|
|
68
|
-
//
|
|
69
|
+
// Reset before loading prechat to avoid starting chat with previous requestId
|
|
69
70
|
if ((state === null || state === void 0 ? void 0 : state.appStates.conversationState) === _ConversationState.ConversationState.Closed) {
|
|
70
71
|
// Preventive reset to avoid starting chat with previous requestId which could potentially cause problems
|
|
71
72
|
(0, _endChat.chatSDKStateCleanUp)(facadeChatSDK.getChatSDK());
|
|
@@ -199,7 +200,7 @@ const initStartChat = async (facadeChatSDK, dispatch, setAdapter, state, props,
|
|
|
199
200
|
});
|
|
200
201
|
}
|
|
201
202
|
try {
|
|
202
|
-
var _window$Microsoft, _window$Microsoft$Dyn, _window$Microsoft$Dyn2, _window$Microsoft$Dyn3;
|
|
203
|
+
var _window$Microsoft, _window$Microsoft$Dyn, _window$Microsoft$Dyn2, _window$Microsoft$Dyn3, _state$domainStates8;
|
|
203
204
|
// Set custom context params
|
|
204
205
|
await setCustomContextParams(state, props);
|
|
205
206
|
const defaultOptionalParams = {
|
|
@@ -208,9 +209,25 @@ const initStartChat = async (facadeChatSDK, dispatch, setAdapter, state, props,
|
|
|
208
209
|
portalContactId: (_window$Microsoft = window.Microsoft) === null || _window$Microsoft === void 0 ? void 0 : (_window$Microsoft$Dyn = _window$Microsoft.Dynamic365) === null || _window$Microsoft$Dyn === void 0 ? void 0 : (_window$Microsoft$Dyn2 = _window$Microsoft$Dyn.Portal) === null || _window$Microsoft$Dyn2 === void 0 ? void 0 : (_window$Microsoft$Dyn3 = _window$Microsoft$Dyn2.User) === null || _window$Microsoft$Dyn3 === void 0 ? void 0 : _window$Microsoft$Dyn3.contactId
|
|
209
210
|
};
|
|
210
211
|
const startChatOptionalParams = Object.assign({}, params, optionalParams, defaultOptionalParams);
|
|
212
|
+
|
|
213
|
+
// MID-AUTH: Add wasAuthenticated flag for reconnect scenarios
|
|
214
|
+
// Tells FacadeChatSDK whether the previous session was authenticated
|
|
215
|
+
// Used to detect auth transitions (Auth->Unauth) and decide whether to call authenticateChat
|
|
216
|
+
const midAuthEnabled = (0, _authHelper.isMidAuthEnabled)(state === null || state === void 0 ? void 0 : (_state$domainStates8 = state.domainStates) === null || _state$domainStates8 === void 0 ? void 0 : _state$domainStates8.liveChatConfig);
|
|
217
|
+
if (midAuthEnabled) {
|
|
218
|
+
var _state$appStates4, _persistedState$appSt;
|
|
219
|
+
const isUserAuthenticated = (state === null || state === void 0 ? void 0 : (_state$appStates4 = state.appStates) === null || _state$appStates4 === void 0 ? void 0 : _state$appStates4.isUserAuthenticated) === true || (persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$appSt = persistedState.appStates) === null || _persistedState$appSt === void 0 ? void 0 : _persistedState$appSt.isUserAuthenticated) === true;
|
|
220
|
+
startChatOptionalParams.wasAuthenticated = isUserAuthenticated;
|
|
221
|
+
}
|
|
222
|
+
|
|
211
223
|
// startTime is used to determine if a message is history or new, better to be set before creating the adapter to get bandwidth
|
|
212
224
|
const startTime = new Date().getTime();
|
|
213
225
|
(0, _FirstMessageTrackerFromBot.createTrackingForFirstMessage)();
|
|
226
|
+
|
|
227
|
+
// FacadeChatSDK.startChat() handles:
|
|
228
|
+
// 1. tokenRing() - checks authentication, calls handleAuthentication() if needed
|
|
229
|
+
// 2. Mid-auth: If no token, sets deferInitialAuth=true for unauthenticated flow
|
|
230
|
+
// 3. Mid-auth: On reconnect with valid token, calls authenticateChat to upgrade conversation
|
|
214
231
|
await facadeChatSDK.startChat(startChatOptionalParams);
|
|
215
232
|
(0, _startChatErrorHandler.logStartChatComplete)();
|
|
216
233
|
isStartChatSuccessful = true;
|
|
@@ -298,15 +315,15 @@ const createAdapterAndSubscribe = async (facadeChatSDK, dispatch, setAdapter, st
|
|
|
298
315
|
};
|
|
299
316
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
300
317
|
const canConnectToExistingChat = async (props, facadeChatSDK, state, dispatch, setAdapter) => {
|
|
301
|
-
var _state$
|
|
318
|
+
var _state$appStates5, _persistedState$domai6, _persistedState$appSt2;
|
|
302
319
|
// By pass this function in case of popout chat
|
|
303
|
-
if ((state === null || state === void 0 ? void 0 : (_state$
|
|
320
|
+
if ((state === null || state === void 0 ? void 0 : (_state$appStates5 = state.appStates) === null || _state$appStates5 === void 0 ? void 0 : _state$appStates5.hideStartChatButton) === true) {
|
|
304
321
|
return false;
|
|
305
322
|
}
|
|
306
323
|
const persistedState = (0, _utils.getStateFromCache)((0, _utils.getWidgetCacheIdfromProps)(props));
|
|
307
324
|
|
|
308
325
|
//Connect to only active chat session
|
|
309
|
-
if (persistedState && !(0, _utils.isUndefinedOrEmpty)(persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai6 = persistedState.domainStates) === null || _persistedState$domai6 === void 0 ? void 0 : _persistedState$domai6.liveChatContext) && (persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$
|
|
326
|
+
if (persistedState && !(0, _utils.isUndefinedOrEmpty)(persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai6 = persistedState.domainStates) === null || _persistedState$domai6 === void 0 ? void 0 : _persistedState$domai6.liveChatContext) && (persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$appSt2 = persistedState.appStates) === null || _persistedState$appSt2 === void 0 ? void 0 : _persistedState$appSt2.conversationState) === _ConversationState.ConversationState.Active) {
|
|
310
327
|
var _persistedState$domai7;
|
|
311
328
|
dispatch({
|
|
312
329
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
@@ -323,11 +340,11 @@ const canConnectToExistingChat = async (props, facadeChatSDK, state, dispatch, s
|
|
|
323
340
|
|
|
324
341
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
325
342
|
const setCustomContextParams = async (state, props) => {
|
|
326
|
-
var _state$
|
|
327
|
-
if (state !== null && state !== void 0 && (_state$
|
|
328
|
-
var _state$
|
|
343
|
+
var _state$domainStates9, _persistedState$domai8;
|
|
344
|
+
if (state !== null && state !== void 0 && (_state$domainStates9 = state.domainStates) !== null && _state$domainStates9 !== void 0 && _state$domainStates9.customContext) {
|
|
345
|
+
var _state$domainStates10;
|
|
329
346
|
optionalParams = Object.assign({}, optionalParams, {
|
|
330
|
-
customContext: JSON.parse(JSON.stringify(state === null || state === void 0 ? void 0 : (_state$
|
|
347
|
+
customContext: JSON.parse(JSON.stringify(state === null || state === void 0 ? void 0 : (_state$domainStates10 = state.domainStates) === null || _state$domainStates10 === void 0 ? void 0 : _state$domainStates10.customContext))
|
|
331
348
|
});
|
|
332
349
|
return;
|
|
333
350
|
}
|
|
@@ -360,9 +377,9 @@ const canStartPopoutChat = async props => {
|
|
|
360
377
|
}
|
|
361
378
|
popoutWidgetInstanceId = (0, _utils.getWidgetCacheIdfromProps)(props, true);
|
|
362
379
|
if (!(0, _utils.isNullOrEmptyString)(popoutWidgetInstanceId)) {
|
|
363
|
-
var _persistedState$domai9, _persistedState$
|
|
380
|
+
var _persistedState$domai9, _persistedState$appSt3;
|
|
364
381
|
const persistedState = (0, _utils.getStateFromCache)(popoutWidgetInstanceId);
|
|
365
|
-
if (persistedState && !(0, _utils.isUndefinedOrEmpty)(persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai9 = persistedState.domainStates) === null || _persistedState$domai9 === void 0 ? void 0 : _persistedState$domai9.liveChatContext) && (persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$
|
|
382
|
+
if (persistedState && !(0, _utils.isUndefinedOrEmpty)(persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai9 = persistedState.domainStates) === null || _persistedState$domai9 === void 0 ? void 0 : _persistedState$domai9.liveChatContext) && (persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$appSt3 = persistedState.appStates) === null || _persistedState$appSt3 === void 0 ? void 0 : _persistedState$appSt3.conversationState) === _ConversationState.ConversationState.Active) {
|
|
366
383
|
// Initiate popout chat
|
|
367
384
|
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
368
385
|
eventName: _TelemetryConstants.BroadcastEvent.InitiateStartChatInPopoutMode
|
|
@@ -375,9 +392,9 @@ const canStartPopoutChat = async props => {
|
|
|
375
392
|
|
|
376
393
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
377
394
|
const checkIfConversationStillValid = async (facadeChatSDK, dispatch, state) => {
|
|
378
|
-
var _state$
|
|
379
|
-
const requestIdFromCache = (_state$
|
|
380
|
-
const liveChatContext = state === null || state === void 0 ? void 0 : (_state$
|
|
395
|
+
var _state$domainStates11, _state$domainStates12, _state$domainStates13;
|
|
396
|
+
const requestIdFromCache = (_state$domainStates11 = state.domainStates) === null || _state$domainStates11 === void 0 ? void 0 : (_state$domainStates12 = _state$domainStates11.liveChatContext) === null || _state$domainStates12 === void 0 ? void 0 : _state$domainStates12.requestId;
|
|
397
|
+
const liveChatContext = state === null || state === void 0 ? void 0 : (_state$domainStates13 = state.domainStates) === null || _state$domainStates13 === void 0 ? void 0 : _state$domainStates13.liveChatContext;
|
|
381
398
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
382
399
|
let conversationDetails = undefined;
|
|
383
400
|
// Preserve current requestId
|