@microsoft/omnichannel-chat-sdk 1.0.1-main.fa78d5f → 1.1.1-main.4abcbae

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 (61) hide show
  1. package/CHANGELOG.md +21 -3
  2. package/README.md +87 -59
  3. package/lib/OmnichannelChatSDK.d.ts +6 -4
  4. package/lib/OmnichannelChatSDK.js +302 -302
  5. package/lib/OmnichannelChatSDK.js.map +1 -1
  6. package/lib/api/createVoiceVideoCalling.js +6 -2
  7. package/lib/api/createVoiceVideoCalling.js.map +1 -1
  8. package/lib/config/settings.d.ts +1 -1
  9. package/lib/config/settings.js +1 -1
  10. package/lib/core/ChatConfig.d.ts +4 -0
  11. package/lib/core/ChatSDKExceptionDetails.d.ts +5 -0
  12. package/lib/core/ChatSDKExceptionDetails.js +3 -0
  13. package/lib/core/ChatSDKExceptionDetails.js.map +1 -0
  14. package/lib/core/ChatTranscriptBody.d.ts +1 -1
  15. package/lib/core/LiveWorkItemDetails.d.ts +2 -0
  16. package/lib/core/OmnichannelErrorCodes.d.ts +4 -0
  17. package/lib/core/OmnichannelErrorCodes.js +8 -0
  18. package/lib/core/OmnichannelErrorCodes.js.map +1 -0
  19. package/lib/core/PostChatContext.d.ts +1 -0
  20. package/lib/core/messaging/ChatAdapterOptionalParams.d.ts +14 -0
  21. package/lib/core/messaging/ChatAdapterOptionalParams.js +3 -0
  22. package/lib/core/messaging/ChatAdapterOptionalParams.js.map +1 -0
  23. package/lib/core/messaging/MessageTags.d.ts +2 -0
  24. package/lib/core/messaging/MessageTags.js +4 -2
  25. package/lib/core/messaging/MessageTags.js.map +1 -1
  26. package/lib/external/ACSAdapter/createChannelDataEgressMiddleware.d.ts +5 -0
  27. package/lib/external/ACSAdapter/createChannelDataEgressMiddleware.js +34 -0
  28. package/lib/external/ACSAdapter/createChannelDataEgressMiddleware.js.map +1 -0
  29. package/lib/external/CallingSDK/ICallingSDKLogData.d.ts +7 -0
  30. package/lib/external/CallingSDK/ICallingSDKLogData.js +3 -0
  31. package/lib/external/CallingSDK/ICallingSDKLogData.js.map +1 -0
  32. package/lib/external/IC3Adapter/IIC3AdapterOptions.d.ts +12 -0
  33. package/lib/index.d.ts +7 -6
  34. package/lib/index.js +13 -8
  35. package/lib/index.js.map +1 -1
  36. package/lib/telemetry/AriaTelemetry.d.ts +1 -0
  37. package/lib/telemetry/AriaTelemetry.js +55 -0
  38. package/lib/telemetry/AriaTelemetry.js.map +1 -1
  39. package/lib/telemetry/ScenarioMarker.d.ts +2 -0
  40. package/lib/telemetry/ScenarioMarker.js +7 -3
  41. package/lib/telemetry/ScenarioMarker.js.map +1 -1
  42. package/lib/telemetry/ScenarioType.d.ts +1 -0
  43. package/lib/telemetry/ScenarioType.js +1 -0
  44. package/lib/telemetry/ScenarioType.js.map +1 -1
  45. package/lib/telemetry/TelemetryEvent.d.ts +1 -3
  46. package/lib/telemetry/TelemetryEvent.js +0 -2
  47. package/lib/telemetry/TelemetryEvent.js.map +1 -1
  48. package/lib/tsconfig.tsbuildinfo +158 -63
  49. package/lib/utils/WebUtils.d.ts +3 -1
  50. package/lib/utils/WebUtils.js +8 -2
  51. package/lib/utils/WebUtils.js.map +1 -1
  52. package/lib/utils/libraries.d.ts +1 -3
  53. package/lib/utils/libraries.js +2 -11
  54. package/lib/utils/libraries.js.map +1 -1
  55. package/lib/utils/locale.d.ts +2 -0
  56. package/lib/utils/locale.js +5 -3
  57. package/lib/utils/locale.js.map +1 -1
  58. package/lib/utils/loggers.d.ts +26 -1
  59. package/lib/utils/loggers.js +94 -2
  60. package/lib/utils/loggers.js.map +1 -1
  61. package/package.json +1 -1
@@ -58,7 +58,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
58
58
  var loggers_1 = require("./utils/loggers");
59
59
  var ACSClient_1 = require("./core/messaging/ACSClient");
60
60
  var ocsdk_1 = require("@microsoft/ocsdk");
61
- var libraries_1 = require("./utils/libraries");
61
+ var locale_1 = require("./utils/locale");
62
+ var WebUtils_1 = require("./utils/WebUtils");
62
63
  var platform_1 = require("./utils/platform");
63
64
  var SDKConfigValidators_1 = require("./validators/SDKConfigValidators");
64
65
  var ACSParticipantDisplayName_1 = require("./core/messaging/ACSParticipantDisplayName");
@@ -66,8 +67,6 @@ var AMSFileManager_1 = require("./external/ACSAdapter/AMSFileManager");
66
67
  var CallingOptionsOptionSetNumber_1 = require("./core/CallingOptionsOptionSetNumber");
67
68
  var ChatAdapterProtocols_1 = require("./core/messaging/ChatAdapterProtocols");
68
69
  var ConversationMode_1 = require("./core/ConversationMode");
69
- var createFormatEgressTagsMiddleware_1 = require("./external/ACSAdapter/createFormatEgressTagsMiddleware");
70
- var createFormatIngressTagsMiddleware_1 = require("./external/ACSAdapter/createFormatIngressTagsMiddleware");
71
70
  var DeliveryMode_1 = require("@microsoft/omnichannel-ic3core/lib/model/DeliveryMode");
72
71
  var FileSharingProtocolType_1 = require("@microsoft/omnichannel-ic3core/lib/model/FileSharingProtocolType");
73
72
  var HostType_1 = require("@microsoft/omnichannel-ic3core/lib/interfaces/HostType");
@@ -76,23 +75,26 @@ var LiveChatVersion_1 = require("./core/LiveChatVersion");
76
75
  var LiveWorkItemState_1 = require("./core/LiveWorkItemState");
77
76
  var MessageContentType_1 = require("@microsoft/omnichannel-ic3core/lib/model/MessageContentType");
78
77
  var MessageType_1 = require("@microsoft/omnichannel-ic3core/lib/model/MessageType");
78
+ var OmnichannelErrorCodes_1 = require("./core/OmnichannelErrorCodes");
79
79
  var PersonType_1 = require("@microsoft/omnichannel-ic3core/lib/model/PersonType");
80
80
  var ProtocoleType_1 = require("@microsoft/omnichannel-ic3core/lib/interfaces/ProtocoleType");
81
81
  var ScenarioMarker_1 = require("./telemetry/ScenarioMarker");
82
82
  var TelemetryEvent_1 = require("./telemetry/TelemetryEvent");
83
83
  var omnichannel_amsclient_1 = require("@microsoft/omnichannel-amsclient");
84
+ var createChannelDataEgressMiddleware_1 = require("./external/ACSAdapter/createChannelDataEgressMiddleware");
85
+ var createFormatEgressTagsMiddleware_1 = require("./external/ACSAdapter/createFormatEgressTagsMiddleware");
86
+ var createFormatIngressTagsMiddleware_1 = require("./external/ACSAdapter/createFormatIngressTagsMiddleware");
84
87
  var createOmnichannelMessage_1 = require("./utils/createOmnichannelMessage");
85
88
  var createTelemetry_1 = require("./utils/createTelemetry");
86
89
  var createVoiceVideoCalling_1 = require("./api/createVoiceVideoCalling");
87
90
  var MessageTags_1 = require("./core/messaging/MessageTags");
88
- var locale_1 = require("./utils/locale");
89
91
  var utilities_1 = require("./utils/utilities");
90
- var WebUtils_1 = require("./utils/WebUtils");
92
+ var libraries_1 = require("./utils/libraries");
91
93
  var OmnichannelConfigValidator_1 = require("./validators/OmnichannelConfigValidator");
92
94
  var OmnichannelChatSDK = /** @class */ (function () {
93
95
  function OmnichannelChatSDK(omnichannelConfig, chatSDKConfig) {
94
96
  if (chatSDKConfig === void 0) { chatSDKConfig = SDKConfigValidators_1.defaultChatSDKConfig; }
95
- var _a, _b, _c, _d, _e, _f, _g;
97
+ var _a, _b, _c, _d, _e, _f, _g, _h;
96
98
  this.ACSClient = null;
97
99
  this.AMSClient = null;
98
100
  this.authSettings = null;
@@ -104,16 +106,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
104
106
  this.ocSdkLogger = null;
105
107
  this.acsClientLogger = null;
106
108
  this.acsAdapterLogger = null;
109
+ this.callingSdkLogger = null;
107
110
  this.isPersistentChat = false;
108
111
  this.isChatReconnect = false;
109
112
  this.reconnectId = null;
110
113
  this.refreshTokenTimer = null;
111
114
  this.debug = false;
115
+ this.runtimeId = ocsdk_1.uuidv4();
112
116
  this.omnichannelConfig = omnichannelConfig;
113
117
  this.chatSDKConfig = __assign(__assign({}, SDKConfigValidators_1.defaultChatSDKConfig), chatSDKConfig // overrides
114
118
  );
115
119
  this.isInitialized = false;
116
120
  this.liveChatVersion = LiveChatVersion_1.default.V1;
121
+ this.localeId = locale_1.defaultLocaleId;
117
122
  this.requestId = ocsdk_1.uuidv4();
118
123
  this.chatToken = {};
119
124
  this.liveChatConfig = {};
@@ -126,11 +131,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
126
131
  this.ocSdkLogger = loggers_1.createOCSDKLogger(this.omnichannelConfig);
127
132
  this.acsClientLogger = loggers_1.createACSClientLogger(this.omnichannelConfig);
128
133
  this.acsAdapterLogger = loggers_1.createACSAdapterLogger(this.omnichannelConfig);
134
+ this.callingSdkLogger = loggers_1.createCallingSDKLogger(this.omnichannelConfig);
129
135
  this.scenarioMarker.useTelemetry(this.telemetry);
130
136
  this.ic3ClientLogger.useTelemetry(this.telemetry);
131
137
  this.ocSdkLogger.useTelemetry(this.telemetry);
132
138
  this.acsClientLogger.useTelemetry(this.telemetry);
133
139
  this.acsAdapterLogger.useTelemetry(this.telemetry);
140
+ this.callingSdkLogger.useTelemetry(this.telemetry);
141
+ this.scenarioMarker.setRuntimeId(this.runtimeId);
142
+ this.ic3ClientLogger.setRuntimeId(this.runtimeId);
143
+ this.ocSdkLogger.setRuntimeId(this.runtimeId);
144
+ this.acsClientLogger.setRuntimeId(this.runtimeId);
145
+ this.acsAdapterLogger.setRuntimeId(this.runtimeId);
146
+ this.callingSdkLogger.setRuntimeId(this.runtimeId);
134
147
  OmnichannelConfigValidator_1.default(omnichannelConfig);
135
148
  SDKConfigValidators_1.default(chatSDKConfig);
136
149
  ((_a = this.chatSDKConfig.telemetry) === null || _a === void 0 ? void 0 : _a.disable) && ((_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.disable());
@@ -141,10 +154,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
141
154
  (_e = this.ocSdkLogger) === null || _e === void 0 ? void 0 : _e.setRequestId(this.requestId);
142
155
  (_f = this.acsClientLogger) === null || _f === void 0 ? void 0 : _f.setRequestId(this.requestId);
143
156
  (_g = this.acsAdapterLogger) === null || _g === void 0 ? void 0 : _g.setRequestId(this.requestId);
157
+ (_h = this.callingSdkLogger) === null || _h === void 0 ? void 0 : _h.setRequestId(this.requestId);
144
158
  }
145
159
  /* istanbul ignore next */
146
160
  OmnichannelChatSDK.prototype.setDebug = function (flag) {
147
- var _a, _b, _c, _d, _e, _f;
161
+ var _a, _b, _c, _d, _e, _f, _g;
148
162
  this.debug = flag;
149
163
  (_a = this.AMSClient) === null || _a === void 0 ? void 0 : _a.setDebug(flag);
150
164
  (_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.setDebug(flag);
@@ -153,6 +167,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
153
167
  (_d = this.ocSdkLogger) === null || _d === void 0 ? void 0 : _d.setDebug(flag);
154
168
  (_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setDebug(flag);
155
169
  (_f = this.acsAdapterLogger) === null || _f === void 0 ? void 0 : _f.setDebug(flag);
170
+ (_g = this.callingSdkLogger) === null || _g === void 0 ? void 0 : _g.setDebug(flag);
156
171
  };
157
172
  OmnichannelChatSDK.prototype.initialize = function () {
158
173
  return __awaiter(this, void 0, void 0, function () {
@@ -291,47 +306,55 @@ var OmnichannelChatSDK = /** @class */ (function () {
291
306
  });
292
307
  };
293
308
  OmnichannelChatSDK.prototype.startChat = function (optionalParams) {
294
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
309
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
295
310
  if (optionalParams === void 0) { optionalParams = {}; }
296
311
  return __awaiter(this, void 0, void 0, function () {
297
- var reconnectableChatsParams, reconnectableChatsResponse, _p, exceptionDetails, conversationDetails, exceptionDetails, exceptionDetails, sessionInitOptionalParams, error_3, exceptionDetails, chatAdapterConfig, error_4, exceptionDetails, _q, error_5, exceptionDetails, error_6, exceptionDetails, error_7, exceptionDetails, _r, error_8, exceptionDetails;
312
+ var shouldReinitIC3Client, _t, reconnectableChatsParams, reconnectableChatsResponse, _u, exceptionDetails, conversationDetails, exceptionDetails, exceptionDetails, sessionInitOptionalParams, error_3, exceptionDetails, chatAdapterConfig, error_4, exceptionDetails, _v, error_5, exceptionDetails, error_6, exceptionDetails, error_7, exceptionDetails, _w, error_8, exceptionDetails;
298
313
  var _this = this;
299
- return __generator(this, function (_s) {
300
- switch (_s.label) {
314
+ return __generator(this, function (_x) {
315
+ switch (_x.label) {
301
316
  case 0:
302
317
  this.scenarioMarker.startScenario(TelemetryEvent_1.default.StartChat, {
303
318
  RequestId: this.requestId
304
319
  });
320
+ shouldReinitIC3Client = !platform_1.default.isNode() && !platform_1.default.isReactNative() && !this.IC3Client && this.liveChatVersion === LiveChatVersion_1.default.V1;
321
+ if (!shouldReinitIC3Client) return [3 /*break*/, 2];
322
+ _t = this;
323
+ return [4 /*yield*/, this.getIC3Client()];
324
+ case 1:
325
+ _t.IC3Client = _x.sent();
326
+ _x.label = 2;
327
+ case 2:
305
328
  if (this.isChatReconnect && !((_a = this.chatSDKConfig.chatReconnect) === null || _a === void 0 ? void 0 : _a.disable) && !this.isPersistentChat && optionalParams.reconnectId) {
306
329
  this.reconnectId = optionalParams.reconnectId;
307
330
  }
308
- if (!(this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable))) return [3 /*break*/, 4];
309
- _s.label = 1;
310
- case 1:
311
- _s.trys.push([1, 3, , 4]);
331
+ if (!(this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable))) return [3 /*break*/, 6];
332
+ _x.label = 3;
333
+ case 3:
334
+ _x.trys.push([3, 5, , 6]);
312
335
  reconnectableChatsParams = {
313
336
  authenticatedUserToken: this.authenticatedUserToken
314
337
  };
315
338
  return [4 /*yield*/, this.OCClient.getReconnectableChats(reconnectableChatsParams)];
316
- case 2:
317
- reconnectableChatsResponse = _s.sent();
339
+ case 4:
340
+ reconnectableChatsResponse = _x.sent();
318
341
  if (reconnectableChatsResponse && reconnectableChatsResponse.reconnectid) {
319
342
  this.reconnectId = reconnectableChatsResponse.reconnectid;
320
343
  }
321
- return [3 /*break*/, 4];
322
- case 3:
323
- _p = _s.sent();
344
+ return [3 /*break*/, 6];
345
+ case 5:
346
+ _u = _x.sent();
324
347
  exceptionDetails = {
325
348
  response: "OCClientGetReconnectableChatsFailed"
326
349
  };
327
350
  throw Error(exceptionDetails.response);
328
- case 4:
329
- if (!(optionalParams.liveChatContext && !this.isPersistentChat && !this.isChatReconnect)) return [3 /*break*/, 6];
351
+ case 6:
352
+ if (!(optionalParams.liveChatContext && !this.reconnectId)) return [3 /*break*/, 8];
330
353
  this.chatToken = optionalParams.liveChatContext.chatToken || {};
331
354
  this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
332
355
  return [4 /*yield*/, this.getConversationDetails()];
333
- case 5:
334
- conversationDetails = _s.sent();
356
+ case 7:
357
+ conversationDetails = _x.sent();
335
358
  if (Object.keys(conversationDetails).length === 0) {
336
359
  exceptionDetails = {
337
360
  response: "InvalidConversation"
@@ -356,25 +379,27 @@ var OmnichannelChatSDK = /** @class */ (function () {
356
379
  console.error("Unable to join conversation that's in '" + conversationDetails.state + "' state");
357
380
  throw Error(exceptionDetails.response);
358
381
  }
359
- _s.label = 6;
360
- case 6:
361
- if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 8];
362
- return [4 /*yield*/, this.getChatToken(false)];
363
- case 7:
364
- _s.sent();
365
- _s.label = 8;
382
+ _x.label = 8;
366
383
  case 8:
384
+ if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 10];
385
+ return [4 /*yield*/, this.getChatToken(false)];
386
+ case 9:
387
+ _x.sent();
388
+ _x.label = 10;
389
+ case 10:
367
390
  (_c = this.ic3ClientLogger) === null || _c === void 0 ? void 0 : _c.setChatId(this.chatToken.chatId || '');
368
391
  (_d = this.ocSdkLogger) === null || _d === void 0 ? void 0 : _d.setChatId(this.chatToken.chatId || '');
369
392
  (_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setChatId(this.chatToken.chatId || '');
370
393
  (_f = this.acsAdapterLogger) === null || _f === void 0 ? void 0 : _f.setChatId(this.chatToken.chatId || '');
394
+ (_g = this.callingSdkLogger) === null || _g === void 0 ? void 0 : _g.setChatId(this.chatToken.chatId || '');
371
395
  sessionInitOptionalParams = {
372
396
  initContext: {}
373
397
  };
374
- if (this.isPersistentChat && !((_g = this.chatSDKConfig.persistentChat) === null || _g === void 0 ? void 0 : _g.disable)) {
398
+ sessionInitOptionalParams.initContext.locale = locale_1.getLocaleStringFromId(this.localeId);
399
+ if (this.isPersistentChat && !((_h = this.chatSDKConfig.persistentChat) === null || _h === void 0 ? void 0 : _h.disable)) {
375
400
  sessionInitOptionalParams.reconnectId = this.reconnectId;
376
401
  }
377
- if (this.isChatReconnect && !((_h = this.chatSDKConfig.chatReconnect) === null || _h === void 0 ? void 0 : _h.disable) && !this.isPersistentChat) {
402
+ if (this.isChatReconnect && !((_j = this.chatSDKConfig.chatReconnect) === null || _j === void 0 ? void 0 : _j.disable) && !this.isPersistentChat) {
378
403
  sessionInitOptionalParams.reconnectId = this.reconnectId;
379
404
  }
380
405
  if (optionalParams.customContext) {
@@ -402,27 +427,33 @@ var OmnichannelChatSDK = /** @class */ (function () {
402
427
  if (this.authenticatedUserToken) {
403
428
  sessionInitOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
404
429
  }
405
- _s.label = 9;
406
- case 9:
407
- _s.trys.push([9, 11, , 12]);
408
- return [4 /*yield*/, this.OCClient.sessionInit(this.requestId, sessionInitOptionalParams)];
409
- case 10:
410
- _s.sent();
411
- return [3 /*break*/, 12];
430
+ if (!!optionalParams.liveChatContext) return [3 /*break*/, 14];
431
+ _x.label = 11;
412
432
  case 11:
413
- error_3 = _s.sent();
433
+ _x.trys.push([11, 13, , 14]);
434
+ return [4 /*yield*/, this.OCClient.sessionInit(this.requestId, sessionInitOptionalParams)];
435
+ case 12:
436
+ _x.sent();
437
+ return [3 /*break*/, 14];
438
+ case 13:
439
+ error_3 = _x.sent();
414
440
  exceptionDetails = {
415
441
  response: "OCClientSessionInitFailed"
416
442
  };
443
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
444
+ if (((_k = error_3) === null || _k === void 0 ? void 0 : _k.isAxiosError) && ((_m = (_l = error_3.response) === null || _l === void 0 ? void 0 : _l.headers) === null || _m === void 0 ? void 0 : _m.errorcode.toString()) === OmnichannelErrorCodes_1.default.WidgetUseOutsideOperatingHour.toString()) {
445
+ exceptionDetails.response = OmnichannelErrorCodes_1.default[OmnichannelErrorCodes_1.default.WidgetUseOutsideOperatingHour].toString();
446
+ exceptionDetails.message = 'Widget used outside of operating hours';
447
+ console.error(exceptionDetails.message);
448
+ }
417
449
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
418
450
  RequestId: this.requestId,
419
451
  ChatId: this.chatToken.chatId,
420
452
  ExceptionDetails: JSON.stringify(exceptionDetails)
421
453
  });
422
- console.error("OmnichannelChatSDK/startChat/sessionInit/error " + error_3);
423
- return [2 /*return*/, error_3];
424
- case 12:
425
- if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 23];
454
+ throw new Error(exceptionDetails.response);
455
+ case 14:
456
+ if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 25];
426
457
  chatAdapterConfig = {
427
458
  token: this.chatToken.token,
428
459
  id: this.chatToken.visitorId || 'teamsvisitor',
@@ -430,18 +461,18 @@ var OmnichannelChatSDK = /** @class */ (function () {
430
461
  environmentUrl: this.chatToken.acsEndpoint,
431
462
  pollingInterval: 1000
432
463
  };
433
- _s.label = 13;
434
- case 13:
435
- _s.trys.push([13, 15, , 16]);
436
- return [4 /*yield*/, ((_j = this.ACSClient) === null || _j === void 0 ? void 0 : _j.initialize({
464
+ _x.label = 15;
465
+ case 15:
466
+ _x.trys.push([15, 17, , 18]);
467
+ return [4 /*yield*/, ((_o = this.ACSClient) === null || _o === void 0 ? void 0 : _o.initialize({
437
468
  token: chatAdapterConfig.token,
438
469
  environmentUrl: chatAdapterConfig.environmentUrl
439
470
  }))];
440
- case 14:
441
- _s.sent();
442
- return [3 /*break*/, 16];
443
- case 15:
444
- error_4 = _s.sent();
471
+ case 16:
472
+ _x.sent();
473
+ return [3 /*break*/, 18];
474
+ case 17:
475
+ error_4 = _x.sent();
445
476
  exceptionDetails = {
446
477
  response: "ACSClientInitializeFailed"
447
478
  };
@@ -452,23 +483,23 @@ var OmnichannelChatSDK = /** @class */ (function () {
452
483
  });
453
484
  console.error("OmnichannelChatSDK/startChat/initialize/error " + error_4);
454
485
  return [2 /*return*/, error_4];
455
- case 16:
456
- _s.trys.push([16, 18, , 19]);
457
- _q = this;
458
- return [4 /*yield*/, ((_k = this.ACSClient) === null || _k === void 0 ? void 0 : _k.joinConversation({
486
+ case 18:
487
+ _x.trys.push([18, 20, , 21]);
488
+ _v = this;
489
+ return [4 /*yield*/, ((_p = this.ACSClient) === null || _p === void 0 ? void 0 : _p.joinConversation({
459
490
  id: chatAdapterConfig.id,
460
491
  threadId: chatAdapterConfig.threadId,
461
492
  pollingInterval: chatAdapterConfig.pollingInterval
462
493
  }))];
463
- case 17:
464
- _q.conversation = (_s.sent());
494
+ case 19:
495
+ _v.conversation = (_x.sent());
465
496
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
466
497
  RequestId: this.requestId,
467
498
  ChatId: this.chatToken.chatId
468
499
  });
469
- return [3 /*break*/, 19];
470
- case 18:
471
- error_5 = _s.sent();
500
+ return [3 /*break*/, 21];
501
+ case 20:
502
+ error_5 = _x.sent();
472
503
  exceptionDetails = {
473
504
  response: "ACSClientJoinConversationFailed"
474
505
  };
@@ -479,16 +510,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
479
510
  });
480
511
  console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_5);
481
512
  throw Error(exceptionDetails.response);
482
- case 19:
483
- _s.trys.push([19, 21, , 22]);
484
- return [4 /*yield*/, ((_l = this.AMSClient) === null || _l === void 0 ? void 0 : _l.initialize({
513
+ case 21:
514
+ _x.trys.push([21, 23, , 24]);
515
+ return [4 /*yield*/, ((_q = this.AMSClient) === null || _q === void 0 ? void 0 : _q.initialize({
485
516
  chatToken: this.chatToken
486
517
  }))];
487
- case 20:
488
- _s.sent();
489
- return [3 /*break*/, 22];
490
- case 21:
491
- error_6 = _s.sent();
518
+ case 22:
519
+ _x.sent();
520
+ return [3 /*break*/, 24];
521
+ case 23:
522
+ error_6 = _x.sent();
492
523
  exceptionDetails = {
493
524
  response: "AMSClientInitializeFailed"
494
525
  };
@@ -498,19 +529,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
498
529
  ExceptionDetails: JSON.stringify(exceptionDetails)
499
530
  });
500
531
  throw Error(exceptionDetails.response);
501
- case 22: return [3 /*break*/, 29];
502
- case 23:
503
- _s.trys.push([23, 25, , 26]);
532
+ case 24: return [3 /*break*/, 31];
533
+ case 25:
534
+ _x.trys.push([25, 27, , 28]);
504
535
  return [4 /*yield*/, this.IC3Client.initialize({
505
536
  token: this.chatToken.token,
506
537
  regionGtms: this.chatToken.regionGTMS,
507
538
  visitor: true
508
539
  })];
509
- case 24:
510
- _s.sent();
511
- return [3 /*break*/, 26];
512
- case 25:
513
- error_7 = _s.sent();
540
+ case 26:
541
+ _x.sent();
542
+ return [3 /*break*/, 28];
543
+ case 27:
544
+ error_7 = _x.sent();
514
545
  exceptionDetails = {
515
546
  response: "IC3ClientInitializeFailed"
516
547
  };
@@ -521,19 +552,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
521
552
  });
522
553
  console.error("OmnichannelChatSDK/startChat/initialize/error " + error_7);
523
554
  return [2 /*return*/, error_7];
524
- case 26:
525
- _s.trys.push([26, 28, , 29]);
526
- _r = this;
555
+ case 28:
556
+ _x.trys.push([28, 30, , 31]);
557
+ _w = this;
527
558
  return [4 /*yield*/, this.IC3Client.joinConversation(this.chatToken.chatId)];
528
- case 27:
529
- _r.conversation = _s.sent();
559
+ case 29:
560
+ _w.conversation = _x.sent();
530
561
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
531
562
  RequestId: this.requestId,
532
563
  ChatId: this.chatToken.chatId
533
564
  });
534
- return [3 /*break*/, 29];
535
- case 28:
536
- error_8 = _s.sent();
565
+ return [3 /*break*/, 31];
566
+ case 30:
567
+ error_8 = _x.sent();
537
568
  exceptionDetails = {
538
569
  response: "IC3ClientJoinConversationFailed"
539
570
  };
@@ -544,8 +575,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
544
575
  });
545
576
  console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_8);
546
577
  return [2 /*return*/, error_8];
547
- case 29:
548
- if (this.isPersistentChat && !((_m = this.chatSDKConfig.persistentChat) === null || _m === void 0 ? void 0 : _m.disable)) {
578
+ case 31:
579
+ if (this.isPersistentChat && !((_r = this.chatSDKConfig.persistentChat) === null || _r === void 0 ? void 0 : _r.disable)) {
549
580
  this.refreshTokenTimer = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
550
581
  return __generator(this, function (_a) {
551
582
  switch (_a.label) {
@@ -556,7 +587,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
556
587
  return [2 /*return*/];
557
588
  }
558
589
  });
559
- }); }, (_o = this.chatSDKConfig.persistentChat) === null || _o === void 0 ? void 0 : _o.tokenUpdateTime);
590
+ }); }, (_s = this.chatSDKConfig.persistentChat) === null || _s === void 0 ? void 0 : _s.tokenUpdateTime);
560
591
  }
561
592
  return [2 /*return*/];
562
593
  }
@@ -564,11 +595,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
564
595
  });
565
596
  };
566
597
  OmnichannelChatSDK.prototype.endChat = function () {
567
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
598
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
568
599
  return __awaiter(this, void 0, void 0, function () {
569
600
  var sessionCloseOptionalParams, isReconnectChat, isChatReconnect, error_9, exceptionDetails;
570
- return __generator(this, function (_m) {
571
- switch (_m.label) {
601
+ return __generator(this, function (_p) {
602
+ switch (_p.label) {
572
603
  case 0:
573
604
  this.scenarioMarker.startScenario(TelemetryEvent_1.default.EndChat, {
574
605
  RequestId: this.requestId,
@@ -582,17 +613,18 @@ var OmnichannelChatSDK = /** @class */ (function () {
582
613
  }
583
614
  if (this.isChatReconnect && !((_b = this.chatSDKConfig.chatReconnect) === null || _b === void 0 ? void 0 : _b.disable) && !this.isPersistentChat) {
584
615
  isChatReconnect = this.reconnectId !== null ? true : false;
616
+ this.requestId = isChatReconnect ? this.reconnectId : this.requestId; // Chat Reconnect session to close
585
617
  sessionCloseOptionalParams.isReconnectChat = isChatReconnect;
586
618
  }
587
619
  if (this.authenticatedUserToken) {
588
620
  sessionCloseOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
589
621
  }
590
- _m.label = 1;
622
+ _p.label = 1;
591
623
  case 1:
592
- _m.trys.push([1, 3, , 4]);
624
+ _p.trys.push([1, 3, , 4]);
593
625
  return [4 /*yield*/, this.OCClient.sessionClose(this.requestId, sessionCloseOptionalParams)];
594
626
  case 2:
595
- _m.sent();
627
+ _p.sent();
596
628
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.EndChat, {
597
629
  RequestId: this.requestId,
598
630
  ChatId: this.chatToken.chatId
@@ -602,6 +634,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
602
634
  this.requestId = ocsdk_1.uuidv4();
603
635
  this.chatToken = {};
604
636
  this.reconnectId = null;
637
+ if (this.IC3Client) {
638
+ this.IC3Client.dispose();
639
+ !platform_1.default.isNode() && !platform_1.default.isReactNative() && WebUtils_1.removeElementById(this.IC3Client.id);
640
+ this.IC3Client = null;
641
+ }
605
642
  (_d = this.ic3ClientLogger) === null || _d === void 0 ? void 0 : _d.setRequestId(this.requestId);
606
643
  (_e = this.ic3ClientLogger) === null || _e === void 0 ? void 0 : _e.setChatId('');
607
644
  (_f = this.ocSdkLogger) === null || _f === void 0 ? void 0 : _f.setRequestId(this.requestId);
@@ -610,9 +647,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
610
647
  (_j = this.acsClientLogger) === null || _j === void 0 ? void 0 : _j.setChatId('');
611
648
  (_k = this.acsAdapterLogger) === null || _k === void 0 ? void 0 : _k.setRequestId(this.requestId);
612
649
  (_l = this.acsAdapterLogger) === null || _l === void 0 ? void 0 : _l.setChatId('');
650
+ (_m = this.callingSdkLogger) === null || _m === void 0 ? void 0 : _m.setRequestId(this.requestId);
651
+ (_o = this.callingSdkLogger) === null || _o === void 0 ? void 0 : _o.setChatId('');
613
652
  return [3 /*break*/, 4];
614
653
  case 3:
615
- error_9 = _m.sent();
654
+ error_9 = _p.sent();
616
655
  exceptionDetails = {
617
656
  response: "OCClientSessionCloseFailed"
618
657
  };
@@ -663,23 +702,33 @@ var OmnichannelChatSDK = /** @class */ (function () {
663
702
  });
664
703
  };
665
704
  OmnichannelChatSDK.prototype.getConversationDetails = function () {
666
- var _a, _b;
705
+ var _a, _b, _c, _d;
667
706
  return __awaiter(this, void 0, void 0, function () {
668
- var lwiDetails, state, conversationId, agentAcceptedOn, liveWorkItemDetails, error_10;
669
- return __generator(this, function (_c) {
670
- switch (_c.label) {
707
+ var getLWIDetailsOptionalParams, lwiDetails, state, conversationId, agentAcceptedOn, canRenderPostChat, participantType, liveWorkItemDetails, error_10;
708
+ return __generator(this, function (_e) {
709
+ switch (_e.label) {
671
710
  case 0:
672
711
  this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetConversationDetails, {
673
712
  RequestId: this.requestId,
674
713
  ChatId: ((_a = this.chatToken) === null || _a === void 0 ? void 0 : _a.chatId) || '',
675
714
  });
676
- _c.label = 1;
715
+ getLWIDetailsOptionalParams = {};
716
+ if (this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable) && this.reconnectId) {
717
+ getLWIDetailsOptionalParams.reconnectId = this.reconnectId;
718
+ }
719
+ if (this.isChatReconnect && !((_c = this.chatSDKConfig.chatReconnect) === null || _c === void 0 ? void 0 : _c.disable) && !this.isPersistentChat && this.reconnectId) {
720
+ getLWIDetailsOptionalParams.reconnectId = this.reconnectId;
721
+ }
722
+ if (this.authenticatedUserToken) {
723
+ getLWIDetailsOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
724
+ }
725
+ _e.label = 1;
677
726
  case 1:
678
- _c.trys.push([1, 3, , 4]);
679
- return [4 /*yield*/, this.OCClient.getLWIDetails(this.requestId)];
727
+ _e.trys.push([1, 3, , 4]);
728
+ return [4 /*yield*/, this.OCClient.getLWIDetails(this.requestId, getLWIDetailsOptionalParams)];
680
729
  case 2:
681
- lwiDetails = _c.sent();
682
- state = lwiDetails.State, conversationId = lwiDetails.ConversationId, agentAcceptedOn = lwiDetails.AgentAcceptedOn;
730
+ lwiDetails = _e.sent();
731
+ state = lwiDetails.State, conversationId = lwiDetails.ConversationId, agentAcceptedOn = lwiDetails.AgentAcceptedOn, canRenderPostChat = lwiDetails.CanRenderPostChat, participantType = lwiDetails.ParticipantType;
683
732
  liveWorkItemDetails = {
684
733
  state: state,
685
734
  conversationId: conversationId
@@ -687,13 +736,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
687
736
  if (agentAcceptedOn) {
688
737
  liveWorkItemDetails.agentAcceptedOn = agentAcceptedOn;
689
738
  }
739
+ if (canRenderPostChat) {
740
+ liveWorkItemDetails.canRenderPostChat = canRenderPostChat;
741
+ }
742
+ if (participantType) {
743
+ liveWorkItemDetails.participantType = participantType;
744
+ }
690
745
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetConversationDetails, {
691
746
  RequestId: this.requestId,
692
- ChatId: ((_b = this.chatToken) === null || _b === void 0 ? void 0 : _b.chatId) || '',
747
+ ChatId: ((_d = this.chatToken) === null || _d === void 0 ? void 0 : _d.chatId) || '',
693
748
  });
694
749
  return [2 /*return*/, liveWorkItemDetails];
695
750
  case 3:
696
- error_10 = _c.sent();
751
+ error_10 = _e.sent();
697
752
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetConversationDetails, {
698
753
  RequestId: this.requestId,
699
754
  ChatId: this.chatToken.chatId || '',
@@ -1449,7 +1504,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1449
1504
  ChatId: this.chatToken.chatId,
1450
1505
  EmailAddress: body.emailAddress,
1451
1506
  DefaultAttachmentMessage: body.attachmentMessage,
1452
- CustomerLocale: body.locale
1507
+ CustomerLocale: body.locale || locale_1.getLocaleStringFromId(this.localeId)
1453
1508
  };
1454
1509
  emailResponse = this.OCClient.emailTranscript(this.requestId, this.chatToken.token, emailRequestBody, emailTranscriptOptionalParams);
1455
1510
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.EmailLiveChatTranscript, {
@@ -1499,36 +1554,36 @@ var OmnichannelChatSDK = /** @class */ (function () {
1499
1554
  });
1500
1555
  });
1501
1556
  };
1502
- OmnichannelChatSDK.prototype.createChatAdapter = function (protocol) {
1503
- if (protocol === void 0) { protocol = null; }
1557
+ OmnichannelChatSDK.prototype.createChatAdapter = function (optionalParams) {
1558
+ if (optionalParams === void 0) { optionalParams = {}; }
1504
1559
  return __awaiter(this, void 0, void 0, function () {
1505
- var supportedChatAdapterProtocols;
1560
+ var protocol, supportedChatAdapterProtocols;
1506
1561
  var _this = this;
1507
1562
  return __generator(this, function (_a) {
1508
1563
  if (platform_1.default.isNode() || platform_1.default.isReactNative()) {
1509
1564
  return [2 /*return*/, Promise.reject('ChatAdapter is only supported on browser')];
1510
1565
  }
1566
+ protocol = optionalParams.protocol;
1511
1567
  supportedChatAdapterProtocols = [ChatAdapterProtocols_1.default.ACS, ChatAdapterProtocols_1.default.IC3];
1512
1568
  if (protocol && !supportedChatAdapterProtocols.includes(protocol)) {
1513
1569
  return [2 /*return*/, Promise.reject("ChatAdapter for protocol " + protocol + " currently not supported")];
1514
1570
  }
1515
1571
  if (protocol === ChatAdapterProtocols_1.default.ACS || this.liveChatVersion === LiveChatVersion_1.default.V2) {
1516
1572
  return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
1517
- var egressMiddlewares, ingressMiddlewares, featuresOption, acsAdapterCDNUrl;
1573
+ var options, defaultEgressMiddlewares, defaultIngressMiddlewares, egressMiddleware, ingressMiddleware, featuresOption, acsAdapterCDNUrl;
1518
1574
  var _this = this;
1519
1575
  var _a;
1520
1576
  return __generator(this, function (_b) {
1521
1577
  switch (_b.label) {
1522
1578
  case 0:
1523
- egressMiddlewares = [createFormatEgressTagsMiddleware_1.default()];
1524
- ingressMiddlewares = [createFormatIngressTagsMiddleware_1.default()];
1525
- featuresOption = {
1526
- enableAdaptiveCards: true,
1527
- enableThreadMemberUpdateNotification: true,
1528
- enableLeaveThreadOnWindowClosed: false,
1529
- egressMiddleware: egressMiddlewares,
1530
- ingressMiddleware: ingressMiddlewares
1531
- };
1579
+ options = optionalParams.ACSAdapter ? optionalParams.ACSAdapter.options : {};
1580
+ defaultEgressMiddlewares = [createChannelDataEgressMiddleware_1.default({ widgetId: this.omnichannelConfig.widgetId }), createFormatEgressTagsMiddleware_1.default()];
1581
+ defaultIngressMiddlewares = [createFormatIngressTagsMiddleware_1.default()];
1582
+ egressMiddleware = (options === null || options === void 0 ? void 0 : options.egressMiddleware) ? __spreadArrays(options.egressMiddleware, defaultEgressMiddlewares) : __spreadArrays(defaultEgressMiddlewares);
1583
+ ingressMiddleware = (options === null || options === void 0 ? void 0 : options.ingressMiddleware) ? __spreadArrays(options.egressMiddleware, defaultIngressMiddlewares) : __spreadArrays(defaultIngressMiddlewares);
1584
+ featuresOption = __assign(__assign({ enableAdaptiveCards: true, enableThreadMemberUpdateNotification: true, enableLeaveThreadOnWindowClosed: false }, options), { // overrides
1585
+ ingressMiddleware: ingressMiddleware,
1586
+ egressMiddleware: egressMiddleware });
1532
1587
  acsAdapterCDNUrl = this.resolveChatAdapterUrl(protocol || ChatAdapterProtocols_1.default.ACS);
1533
1588
  (_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
1534
1589
  ACSAdapter: acsAdapterCDNUrl
@@ -1539,7 +1594,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
1539
1594
  try {
1540
1595
  var ChatAdapter = window.ChatAdapter; // eslint-disable-line @typescript-eslint/no-explicit-any
1541
1596
  var fileManager = new AMSFileManager_1.default(_this.AMSClient, _this.acsAdapterLogger);
1542
- var adapter = ChatAdapter.createACSAdapter(_this.chatToken.token, _this.chatToken.visitorId || 'teamsvisitor', _this.chatToken.chatId, _this.chatToken.acsEndpoint, fileManager, 1000, ACSParticipantDisplayName_1.default.Customer, undefined, undefined, // logger
1597
+ var adapter = ChatAdapter.createACSAdapter(_this.chatToken.token, _this.chatToken.visitorId || 'teamsvisitor', _this.chatToken.chatId, _this.chatToken.acsEndpoint, fileManager, ACSParticipantDisplayName_1.default.Customer, undefined, // chatClient
1598
+ _this.acsAdapterLogger, // logger
1543
1599
  featuresOption);
1544
1600
  resolve(adapter);
1545
1601
  }
@@ -1558,12 +1614,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
1558
1614
  }
1559
1615
  else if (protocol === ChatAdapterProtocols_1.default.IC3 || this.liveChatVersion === LiveChatVersion_1.default.V1) {
1560
1616
  return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
1561
- var ic3AdapterCDNUrl;
1617
+ var options, ic3AdapterCDNUrl;
1562
1618
  var _this = this;
1563
1619
  var _a;
1564
1620
  return __generator(this, function (_b) {
1565
1621
  switch (_b.label) {
1566
1622
  case 0:
1623
+ options = optionalParams.IC3Adapter ? optionalParams.IC3Adapter.options : {};
1567
1624
  ic3AdapterCDNUrl = this.resolveChatAdapterUrl(protocol || ChatAdapterProtocols_1.default.IC3);
1568
1625
  (_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
1569
1626
  IC3Adapter: ic3AdapterCDNUrl
@@ -1572,17 +1629,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
1572
1629
  return [4 /*yield*/, WebUtils_1.loadScript(ic3AdapterCDNUrl, function () {
1573
1630
  /* istanbul ignore next */
1574
1631
  _this.debug && console.debug('IC3Adapter loaded!');
1575
- var adapterConfig = {
1576
- chatToken: _this.chatToken,
1577
- userDisplayName: 'Customer',
1578
- userId: 'teamsvisitor',
1579
- sdkURL: _this.resolveIC3ClientUrl(),
1580
- sdk: _this.IC3Client
1581
- };
1632
+ var adapterConfig = __assign({ chatToken: _this.chatToken, userDisplayName: 'Customer', userId: _this.chatToken.visitorId || 'teamsvisitor', sdkURL: _this.resolveIC3ClientUrl(), sdk: _this.IC3Client }, options // overrides
1633
+ );
1582
1634
  var adapter = new window.Microsoft.BotFramework.WebChat.IC3Adapter(adapterConfig);
1583
1635
  adapter.logger = _this.ic3ClientLogger;
1584
- // Keep iframe communication alive to reuse the same IC3Client instance
1585
- window.Microsoft.BotFramework.WebChat.IC3SDKProvider.disposeSdk = function () { }; // eslint-disable-line @typescript-eslint/no-empty-function
1586
1636
  _this.scenarioMarker.completeScenario(TelemetryEvent_1.default.CreateIC3Adapter);
1587
1637
  resolve(adapter);
1588
1638
  }, function () {
@@ -1603,16 +1653,31 @@ var OmnichannelChatSDK = /** @class */ (function () {
1603
1653
  OmnichannelChatSDK.prototype.getVoiceVideoCalling = function (params) {
1604
1654
  if (params === void 0) { params = {}; }
1605
1655
  return __awaiter(this, void 0, void 0, function () {
1606
- var chatConfig, liveWSAndLiveChatEngJoin, msdyn_widgetsnippet, widgetSnippetSourceRegex, result;
1656
+ var exceptionDetails, exceptionDetails, chatConfig, liveWSAndLiveChatEngJoin, msdyn_widgetsnippet, widgetSnippetSourceRegex, result;
1607
1657
  var _this = this;
1608
1658
  return __generator(this, function (_a) {
1609
1659
  switch (_a.label) {
1610
1660
  case 0:
1661
+ this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetVoiceVideoCalling);
1611
1662
  if (platform_1.default.isNode() || platform_1.default.isReactNative()) {
1612
- return [2 /*return*/, Promise.reject('VoiceVideoCalling is only supported on browser')];
1663
+ exceptionDetails = {
1664
+ response: "UnsupportedPlatform",
1665
+ message: "VoiceVideoCalling is only supported on browser"
1666
+ };
1667
+ this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetVoiceVideoCalling, {
1668
+ ExceptionDetails: JSON.stringify(exceptionDetails)
1669
+ });
1670
+ throw new Error(exceptionDetails.response);
1613
1671
  }
1614
1672
  if (this.callingOption.toString() === CallingOptionsOptionSetNumber_1.default.NoCalling.toString()) {
1615
- return [2 /*return*/, Promise.reject('Voice and video call is not enabled')];
1673
+ exceptionDetails = {
1674
+ response: "FeatureDisabled",
1675
+ message: "Voice and video call is not enabled"
1676
+ };
1677
+ this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetVoiceVideoCalling, {
1678
+ ExceptionDetails: JSON.stringify(exceptionDetails)
1679
+ });
1680
+ throw new Error(exceptionDetails.response);
1616
1681
  }
1617
1682
  return [4 /*yield*/, this.getChatConfig()];
1618
1683
  case 1:
@@ -1622,25 +1687,27 @@ var OmnichannelChatSDK = /** @class */ (function () {
1622
1687
  widgetSnippetSourceRegex = new RegExp("src=\"(https:\\/\\/[\\w-.]+)[\\w-.\\/]+\"");
1623
1688
  result = msdyn_widgetsnippet.match(widgetSnippetSourceRegex);
1624
1689
  if (result && result.length) {
1625
- return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
1626
- var LiveChatWidgetLibCDNUrl;
1690
+ return [2 /*return*/, new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
1691
+ var LiveChatWidgetLibCDNUrl, defaultParams;
1627
1692
  var _this = this;
1628
1693
  var _a;
1629
1694
  return __generator(this, function (_b) {
1630
1695
  switch (_b.label) {
1631
1696
  case 0:
1632
- this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetVoiceVideoCalling);
1633
1697
  LiveChatWidgetLibCDNUrl = result[1] + "/livechatwidget/WebChatControl/lib/CallingBundle.js";
1634
1698
  (_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
1635
1699
  VoiceVideoCalling: LiveChatWidgetLibCDNUrl
1636
1700
  });
1701
+ defaultParams = {
1702
+ logger: this.callingSdkLogger
1703
+ };
1637
1704
  return [4 /*yield*/, WebUtils_1.loadScript(LiveChatWidgetLibCDNUrl, function () { return __awaiter(_this, void 0, void 0, function () {
1638
1705
  var VoiceVideoCalling;
1639
1706
  return __generator(this, function (_a) {
1640
1707
  switch (_a.label) {
1641
1708
  case 0:
1642
1709
  this.debug && console.debug(LiveChatWidgetLibCDNUrl + " loaded!");
1643
- return [4 /*yield*/, createVoiceVideoCalling_1.default(params)];
1710
+ return [4 /*yield*/, createVoiceVideoCalling_1.default(__assign(__assign({}, params), defaultParams))];
1644
1711
  case 1:
1645
1712
  VoiceVideoCalling = _a.sent();
1646
1713
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetVoiceVideoCalling);
@@ -1653,13 +1720,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
1653
1720
  var exceptionDetails;
1654
1721
  return __generator(this, function (_a) {
1655
1722
  exceptionDetails = {
1656
- response: "VoiceVideoCallingLoadFailed"
1723
+ response: "VoiceVideoCallingLoadFailed",
1724
+ message: "Failed to load VoiceVideoCalling"
1657
1725
  };
1658
1726
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetVoiceVideoCalling, {
1659
1727
  ExceptionDetails: JSON.stringify(exceptionDetails)
1660
1728
  });
1661
- reject('Failed to load VoiceVideoCalling');
1662
- return [2 /*return*/];
1729
+ throw new Error(exceptionDetails.response);
1663
1730
  });
1664
1731
  }); })];
1665
1732
  case 1:
@@ -1676,7 +1743,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1676
1743
  };
1677
1744
  OmnichannelChatSDK.prototype.getPostChatSurveyContext = function () {
1678
1745
  return __awaiter(this, void 0, void 0, function () {
1679
- var conversationId, chatConfig, liveWSAndLiveChatEngJoin, chatWidgetLanguage, msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier, postConversationSurveyOwnerId, msdyn_localeid, localeId, liveWorkItemDetails, participantJoined, surveyInviteLinkRequest, optionalParams, surveyInviteLinkResponse, surveyInviteLink, formsProLocale, postChatContext, ex_1;
1746
+ var conversationId, chatConfig, liveWSAndLiveChatEngJoin, msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier, msfp_botsourcesurveyidentifier, postConversationSurveyOwnerId, postConversationBotSurveyOwnerId, liveWorkItemDetails, participantJoined, participantType, surveyInviteLinkRequest, optionalParams, ownerId, surveyInviteLinkResponse, surveyInviteLink, formsProLocale, postChatContext, ex_1;
1680
1747
  return __generator(this, function (_a) {
1681
1748
  switch (_a.label) {
1682
1749
  case 0:
@@ -1687,20 +1754,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
1687
1754
  case 1:
1688
1755
  _a.trys.push([1, 6, , 7]);
1689
1756
  chatConfig = this.liveChatConfig;
1690
- liveWSAndLiveChatEngJoin = chatConfig.LiveWSAndLiveChatEngJoin, chatWidgetLanguage = chatConfig.ChatWidgetLanguage;
1691
- msdyn_postconversationsurveyenable = liveWSAndLiveChatEngJoin.msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier = liveWSAndLiveChatEngJoin.msfp_sourcesurveyidentifier, postConversationSurveyOwnerId = liveWSAndLiveChatEngJoin.postConversationSurveyOwnerId;
1692
- msdyn_localeid = chatWidgetLanguage.msdyn_localeid;
1693
- localeId = msdyn_localeid !== null && msdyn_localeid !== void 0 ? msdyn_localeid : "1033";
1694
- if (!msdyn_postconversationsurveyenable) return [3 /*break*/, 4];
1695
- return [4 /*yield*/, this.OCClient.getLWIDetails(this.requestId)];
1757
+ liveWSAndLiveChatEngJoin = chatConfig.LiveWSAndLiveChatEngJoin;
1758
+ msdyn_postconversationsurveyenable = liveWSAndLiveChatEngJoin.msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier = liveWSAndLiveChatEngJoin.msfp_sourcesurveyidentifier, msfp_botsourcesurveyidentifier = liveWSAndLiveChatEngJoin.msfp_botsourcesurveyidentifier, postConversationSurveyOwnerId = liveWSAndLiveChatEngJoin.postConversationSurveyOwnerId, postConversationBotSurveyOwnerId = liveWSAndLiveChatEngJoin.postConversationBotSurveyOwnerId;
1759
+ if (!(msdyn_postconversationsurveyenable === "true")) return [3 /*break*/, 4];
1760
+ return [4 /*yield*/, this.getConversationDetails()];
1696
1761
  case 2:
1697
1762
  liveWorkItemDetails = _a.sent();
1698
- participantJoined = (liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.CanRenderPostChat) && (liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.CanRenderPostChat) === "True";
1699
- conversationId = liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.ConversationId;
1763
+ participantJoined = (liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.canRenderPostChat) === "True";
1764
+ participantType = liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.participantType;
1765
+ conversationId = liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.conversationId;
1700
1766
  surveyInviteLinkRequest = {
1701
- "FormId": msfp_sourcesurveyidentifier,
1767
+ "FormId": participantType === "Bot" ? msfp_botsourcesurveyidentifier : msfp_sourcesurveyidentifier,
1702
1768
  "ConversationId": conversationId,
1703
- "OCLocaleCode": locale_1.getLocaleStringFromId(localeId)
1769
+ "OCLocaleCode": locale_1.getLocaleStringFromId(this.localeId)
1704
1770
  };
1705
1771
  optionalParams = {
1706
1772
  "requestId": this.requestId
@@ -1708,7 +1774,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
1708
1774
  if (this.authenticatedUserToken) {
1709
1775
  optionalParams.authenticatedUserToken = this.authenticatedUserToken;
1710
1776
  }
1711
- return [4 /*yield*/, this.OCClient.getSurveyInviteLink(postConversationSurveyOwnerId, surveyInviteLinkRequest)];
1777
+ ownerId = participantType === "Bot" ? postConversationBotSurveyOwnerId : postConversationSurveyOwnerId;
1778
+ return [4 /*yield*/, this.OCClient.getSurveyInviteLink(ownerId, surveyInviteLinkRequest, optionalParams)];
1712
1779
  case 3:
1713
1780
  surveyInviteLinkResponse = _a.sent();
1714
1781
  surveyInviteLink = void 0, formsProLocale = void 0;
@@ -1729,6 +1796,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1729
1796
  }
1730
1797
  postChatContext = {
1731
1798
  participantJoined: participantJoined,
1799
+ participantType: participantType,
1732
1800
  surveyInviteLink: surveyInviteLink,
1733
1801
  formsProLocale: formsProLocale
1734
1802
  };
@@ -1753,7 +1821,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1753
1821
  case 6:
1754
1822
  ex_1 = _a.sent();
1755
1823
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
1756
- ConversationId: conversationId,
1824
+ ConversationId: conversationId !== null && conversationId !== void 0 ? conversationId : "",
1757
1825
  RequestId: this.requestId,
1758
1826
  ExceptionDetails: JSON.stringify(ex_1)
1759
1827
  });
@@ -1763,102 +1831,6 @@ var OmnichannelChatSDK = /** @class */ (function () {
1763
1831
  });
1764
1832
  });
1765
1833
  };
1766
- OmnichannelChatSDK.prototype.initializePostChatRenderer = function () {
1767
- return __awaiter(this, void 0, void 0, function () {
1768
- var msfpEmbedScript, elm, scriptNodes, styleNodes, i, node, tmpNode, tmpNode, i, node, tmpNode;
1769
- return __generator(this, function (_a) {
1770
- if (!platform_1.isBrowser()) {
1771
- return [2 /*return*/, Promise.reject("In-line rendering is only supported on web browsers")];
1772
- }
1773
- this.scenarioMarker.startScenario(TelemetryEvent_1.default.InitializePostChatRenderer, {
1774
- RequestId: this.requestId
1775
- });
1776
- try {
1777
- msfpEmbedScript = libraries_1.getMsfpEmbedScript();
1778
- elm = document.createElement('div');
1779
- elm.innerHTML = msfpEmbedScript;
1780
- scriptNodes = elm.getElementsByTagName('script');
1781
- styleNodes = elm.getElementsByTagName('link');
1782
- for (i = 0; i < scriptNodes.length; i++) {
1783
- node = scriptNodes[i];
1784
- if (node.src) {
1785
- tmpNode = document.createElement('script');
1786
- tmpNode.type = node.type;
1787
- tmpNode.src = node.src;
1788
- tmpNode.async = false;
1789
- if (!window.document.head.contains(tmpNode)) {
1790
- document.getElementsByTagName('head')[0].appendChild(tmpNode);
1791
- }
1792
- }
1793
- if (node.innerHTML) {
1794
- tmpNode = document.createElement('script');
1795
- tmpNode.innerHTML = node.innerHTML;
1796
- tmpNode.async = false;
1797
- if (!window.document.head.contains(tmpNode)) {
1798
- window.document.head.appendChild(tmpNode);
1799
- }
1800
- }
1801
- }
1802
- for (i = 0; i < styleNodes.length; i++) {
1803
- node = styleNodes[i];
1804
- if (node.href) {
1805
- tmpNode = document.createElement('link');
1806
- tmpNode.type = node.type;
1807
- tmpNode.rel = node.rel;
1808
- tmpNode.href = node.href;
1809
- if (!window.document.head.contains(tmpNode)) {
1810
- document.getElementsByTagName('head')[0].appendChild(tmpNode);
1811
- }
1812
- }
1813
- }
1814
- }
1815
- catch (ex) {
1816
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.InitializePostChatRenderer, {
1817
- RequestId: this.requestId,
1818
- ExceptionDetails: JSON.stringify(ex)
1819
- });
1820
- return [2 /*return*/, Promise.reject("Error occurred when initializer post chat renderer. " + JSON.stringify(ex))];
1821
- }
1822
- return [2 /*return*/];
1823
- });
1824
- });
1825
- };
1826
- OmnichannelChatSDK.prototype.renderPostChatSurvey = function (containerId, postChatContext) {
1827
- return __awaiter(this, void 0, void 0, function () {
1828
- var ex_2;
1829
- return __generator(this, function (_a) {
1830
- switch (_a.label) {
1831
- case 0:
1832
- if (!platform_1.isBrowser()) {
1833
- return [2 /*return*/, Promise.reject("In-line rendering is only supported on web browsers")];
1834
- }
1835
- this.scenarioMarker.startScenario(TelemetryEvent_1.default.RenderPostChatSurvey, {
1836
- RequestId: this.requestId
1837
- });
1838
- _a.label = 1;
1839
- case 1:
1840
- _a.trys.push([1, 3, , 4]);
1841
- if (!postChatContext) {
1842
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.RenderPostChatSurvey, {
1843
- RequestId: this.requestId,
1844
- ExceptionDetails: "Post Chat Context is null."
1845
- });
1846
- return [2 /*return*/, Promise.reject("Post Chat Context is null.")];
1847
- }
1848
- return [4 /*yield*/, renderSurvey(containerId, postChatContext === null || postChatContext === void 0 ? void 0 : postChatContext.surveyInviteLink, "", "", postChatContext === null || postChatContext === void 0 ? void 0 : postChatContext.formsProLocale)];
1849
- case 2: return [2 /*return*/, _a.sent()];
1850
- case 3:
1851
- ex_2 = _a.sent();
1852
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.RenderPostChatSurvey, {
1853
- RequestId: this.requestId,
1854
- ExceptionDetails: JSON.stringify(ex_2)
1855
- });
1856
- return [2 /*return*/, Promise.reject("Error occurred when rendering post chat survey. " + JSON.stringify(ex_2))];
1857
- case 4: return [2 /*return*/];
1858
- }
1859
- });
1860
- });
1861
- };
1862
1834
  OmnichannelChatSDK.prototype.getIC3Client = function () {
1863
1835
  return __awaiter(this, void 0, void 0, function () {
1864
1836
  var IC3Client;
@@ -1885,7 +1857,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1885
1857
  this.debug && console.debug('IC3Client');
1886
1858
  // Use IC3Client if browser is detected
1887
1859
  return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
1888
- var ic3ClientCDNUrl;
1860
+ var ic3ClientCDNUrl, IC3Client;
1889
1861
  var _this = this;
1890
1862
  var _a;
1891
1863
  return __generator(this, function (_b) {
@@ -1896,6 +1868,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
1896
1868
  IC3Client: ic3ClientCDNUrl
1897
1869
  });
1898
1870
  this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetIC3Client);
1871
+ if (!this.IC3SDKProvider) return [3 /*break*/, 2];
1872
+ return [4 /*yield*/, this.IC3SDKProvider.getSDK({
1873
+ hostType: HostType_1.default.IFrame,
1874
+ protocolType: ProtocoleType_1.default.IC3V1SDK,
1875
+ logger: this.ic3ClientLogger // eslint-disable-line @typescript-eslint/no-explicit-any
1876
+ })];
1877
+ case 1:
1878
+ IC3Client = _b.sent();
1879
+ return [2 /*return*/, resolve(IC3Client)];
1880
+ case 2:
1899
1881
  window.addEventListener("ic3:sdk:load", function () { return __awaiter(_this, void 0, void 0, function () {
1900
1882
  var ic3sdk, IC3SDKProvider, IC3Client;
1901
1883
  return __generator(this, function (_a) {
@@ -1932,7 +1914,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1932
1914
  });
1933
1915
  reject('Failed to load IC3Client');
1934
1916
  })];
1935
- case 1:
1917
+ case 3:
1936
1918
  _b.sent();
1937
1919
  return [2 /*return*/];
1938
1920
  }
@@ -1944,15 +1926,17 @@ var OmnichannelChatSDK = /** @class */ (function () {
1944
1926
  };
1945
1927
  OmnichannelChatSDK.prototype.getChatConfig = function () {
1946
1928
  return __awaiter(this, void 0, void 0, function () {
1947
- var liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled, token, exceptionDetails, _a, exceptionDetails, exceptionDetails, error_18;
1948
- return __generator(this, function (_b) {
1949
- switch (_b.label) {
1929
+ var liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, chatWidgetLanguage, msdyn_localeid, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled, error_18;
1930
+ return __generator(this, function (_a) {
1931
+ switch (_a.label) {
1950
1932
  case 0:
1951
- _b.trys.push([0, 8, , 9]);
1933
+ _a.trys.push([0, 4, , 5]);
1952
1934
  return [4 /*yield*/, this.OCClient.getChatConfig()];
1953
1935
  case 1:
1954
- liveChatConfig = _b.sent();
1955
- dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin, liveChatVersion = liveChatConfig.LiveChatVersion;
1936
+ liveChatConfig = _a.sent();
1937
+ dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin, liveChatVersion = liveChatConfig.LiveChatVersion, chatWidgetLanguage = liveChatConfig.ChatWidgetLanguage;
1938
+ msdyn_localeid = chatWidgetLanguage.msdyn_localeid;
1939
+ this.localeId = msdyn_localeid || locale_1.defaultLocaleId;
1956
1940
  this.liveChatVersion = liveChatVersion || LiveChatVersion_1.default.V1;
1957
1941
  /* istanbul ignore next */
1958
1942
  this.debug && console.log("[OmnichannelChatSDK][getChatConfig][liveChatVersion] " + this.liveChatVersion);
@@ -1975,47 +1959,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
1975
1959
  if (isPreChatEnabled && preChatSurvey && preChatSurvey.trim().length > 0) {
1976
1960
  this.preChatSurvey = preChatSurvey;
1977
1961
  }
1978
- if (!this.authSettings) return [3 /*break*/, 7];
1979
- this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetAuthToken);
1980
- if (!this.chatSDKConfig.getAuthToken) return [3 /*break*/, 6];
1981
- _b.label = 2;
1962
+ if (!this.authSettings) return [3 /*break*/, 3];
1963
+ return [4 /*yield*/, this.setAuthTokenProvider(this.chatSDKConfig.getAuthToken)];
1982
1964
  case 2:
1983
- _b.trys.push([2, 4, , 5]);
1984
- return [4 /*yield*/, this.chatSDKConfig.getAuthToken()];
1965
+ _a.sent();
1966
+ _a.label = 3;
1985
1967
  case 3:
1986
- token = _b.sent();
1987
- if (token) {
1988
- this.authenticatedUserToken = token;
1989
- this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetAuthToken);
1990
- }
1991
- else {
1992
- exceptionDetails = {
1993
- response: "UndefinedAuthToken"
1994
- };
1995
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
1996
- ExceptionDetails: JSON.stringify(exceptionDetails)
1997
- });
1998
- }
1999
- return [3 /*break*/, 5];
2000
- case 4:
2001
- _a = _b.sent();
2002
- exceptionDetails = {
2003
- response: "GetAuthTokenFailed"
2004
- };
2005
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
2006
- ExceptionDetails: JSON.stringify(exceptionDetails)
2007
- });
2008
- return [3 /*break*/, 5];
2009
- case 5: return [3 /*break*/, 7];
2010
- case 6:
2011
- exceptionDetails = {
2012
- response: "GetAuthTokenNotFound"
2013
- };
2014
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
2015
- ExceptionDetails: JSON.stringify(exceptionDetails)
2016
- });
2017
- _b.label = 7;
2018
- case 7:
2019
1968
  if (this.preChatSurvey) {
2020
1969
  /* istanbul ignore next */
2021
1970
  this.debug && console.log('Prechat Survey!');
@@ -2023,11 +1972,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
2023
1972
  this.callingOption = msdyn_callingoptions;
2024
1973
  this.liveChatConfig = liveChatConfig;
2025
1974
  return [2 /*return*/, this.liveChatConfig];
2026
- case 8:
2027
- error_18 = _b.sent();
1975
+ case 4:
1976
+ error_18 = _a.sent();
2028
1977
  console.error("OmnichannelChatSDK/getChatConfig/error " + error_18);
2029
1978
  return [2 /*return*/, error_18];
2030
- case 9: return [2 /*return*/];
1979
+ case 5: return [2 /*return*/];
2031
1980
  }
2032
1981
  });
2033
1982
  });
@@ -2109,6 +2058,57 @@ var OmnichannelChatSDK = /** @class */ (function () {
2109
2058
  });
2110
2059
  });
2111
2060
  };
2061
+ OmnichannelChatSDK.prototype.setAuthTokenProvider = function (provider) {
2062
+ return __awaiter(this, void 0, void 0, function () {
2063
+ var token, exceptionDetails, _a, exceptionDetails, exceptionDetails;
2064
+ return __generator(this, function (_b) {
2065
+ switch (_b.label) {
2066
+ case 0:
2067
+ this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetAuthToken);
2068
+ this.chatSDKConfig.getAuthToken = provider;
2069
+ if (!this.chatSDKConfig.getAuthToken) return [3 /*break*/, 5];
2070
+ _b.label = 1;
2071
+ case 1:
2072
+ _b.trys.push([1, 3, , 4]);
2073
+ return [4 /*yield*/, this.chatSDKConfig.getAuthToken()];
2074
+ case 2:
2075
+ token = _b.sent();
2076
+ if (token) {
2077
+ this.authenticatedUserToken = token;
2078
+ this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetAuthToken);
2079
+ }
2080
+ else {
2081
+ exceptionDetails = {
2082
+ response: "UndefinedAuthToken"
2083
+ };
2084
+ this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
2085
+ ExceptionDetails: JSON.stringify(exceptionDetails)
2086
+ });
2087
+ }
2088
+ return [3 /*break*/, 4];
2089
+ case 3:
2090
+ _a = _b.sent();
2091
+ exceptionDetails = {
2092
+ response: "GetAuthTokenFailed"
2093
+ };
2094
+ this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
2095
+ ExceptionDetails: JSON.stringify(exceptionDetails)
2096
+ });
2097
+ return [3 /*break*/, 4];
2098
+ case 4: return [3 /*break*/, 6];
2099
+ case 5:
2100
+ exceptionDetails = {
2101
+ response: "GetAuthTokenNotFound"
2102
+ };
2103
+ this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
2104
+ ExceptionDetails: JSON.stringify(exceptionDetails)
2105
+ });
2106
+ _b.label = 6;
2107
+ case 6: return [2 /*return*/];
2108
+ }
2109
+ });
2110
+ });
2111
+ };
2112
2112
  return OmnichannelChatSDK;
2113
2113
  }());
2114
2114
  exports.default = OmnichannelChatSDK;