@microsoft/omnichannel-chat-sdk 1.2.0 → 1.2.1-main.2590ee2

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 (52) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +16 -1
  3. package/lib/OmnichannelChatSDK.d.ts +5 -1
  4. package/lib/OmnichannelChatSDK.js +231 -247
  5. package/lib/OmnichannelChatSDK.js.map +1 -1
  6. package/lib/config/settings.d.ts +2 -1
  7. package/lib/config/settings.js +3 -1
  8. package/lib/config/settings.js.map +1 -1
  9. package/lib/core/ChatSDKErrors.d.ts +6 -0
  10. package/lib/core/ChatSDKErrors.js +10 -0
  11. package/lib/core/ChatSDKErrors.js.map +1 -0
  12. package/lib/core/ChatSDKExceptionDetails.d.ts +1 -0
  13. package/lib/core/GetAgentAvailabilityOptionalParams.d.ts +13 -0
  14. package/lib/core/GetAgentAvailabilityOptionalParams.js +3 -0
  15. package/lib/core/GetAgentAvailabilityOptionalParams.js.map +1 -0
  16. package/lib/core/StartChatOptionalParams.d.ts +4 -0
  17. package/lib/core/messaging/ACSClient.js +5 -0
  18. package/lib/core/messaging/ACSClient.js.map +1 -1
  19. package/lib/core/messaging/ChatAdapterConfig.d.ts +2 -0
  20. package/lib/core/messaging/ChatAdapterOptionalParams.d.ts +5 -0
  21. package/lib/telemetry/AriaTelemetry.d.ts +2 -0
  22. package/lib/telemetry/AriaTelemetry.js +49 -0
  23. package/lib/telemetry/AriaTelemetry.js.map +1 -1
  24. package/lib/telemetry/ScenarioType.d.ts +1 -0
  25. package/lib/telemetry/ScenarioType.js +1 -0
  26. package/lib/telemetry/ScenarioType.js.map +1 -1
  27. package/lib/telemetry/TelemetryEvent.d.ts +4 -1
  28. package/lib/telemetry/TelemetryEvent.js +3 -0
  29. package/lib/telemetry/TelemetryEvent.js.map +1 -1
  30. package/lib/tsconfig.tsbuildinfo +315 -168
  31. package/lib/utils/WebUtils.d.ts +2 -2
  32. package/lib/utils/WebUtils.js +30 -4
  33. package/lib/utils/WebUtils.js.map +1 -1
  34. package/lib/utils/chatAdapterCreators.d.ts +20 -0
  35. package/lib/utils/chatAdapterCreators.js +230 -0
  36. package/lib/utils/chatAdapterCreators.js.map +1 -0
  37. package/lib/utils/libraries.d.ts +3 -1
  38. package/lib/utils/libraries.js +9 -2
  39. package/lib/utils/libraries.js.map +1 -1
  40. package/lib/utils/location.d.ts +7 -0
  41. package/lib/utils/location.js +96 -0
  42. package/lib/utils/location.js.map +1 -0
  43. package/lib/utils/loggers.d.ts +16 -0
  44. package/lib/utils/loggers.js +69 -1
  45. package/lib/utils/loggers.js.map +1 -1
  46. package/lib/utils/sleep.d.ts +2 -0
  47. package/lib/utils/sleep.js +5 -0
  48. package/lib/utils/sleep.js.map +1 -0
  49. package/lib/utils/urlResolvers.d.ts +10 -0
  50. package/lib/utils/urlResolvers.js +65 -0
  51. package/lib/utils/urlResolvers.js.map +1 -0
  52. package/package.json +3 -3
@@ -58,6 +58,7 @@ 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 chatAdapterCreators_1 = require("./utils/chatAdapterCreators");
61
62
  var locale_1 = require("./utils/locale");
62
63
  var WebUtils_1 = require("./utils/WebUtils");
63
64
  var platform_1 = require("./utils/platform");
@@ -66,6 +67,7 @@ var ACSParticipantDisplayName_1 = require("./core/messaging/ACSParticipantDispla
66
67
  var AMSFileManager_1 = require("./external/ACSAdapter/AMSFileManager");
67
68
  var CallingOptionsOptionSetNumber_1 = require("./core/CallingOptionsOptionSetNumber");
68
69
  var ChatAdapterProtocols_1 = require("./core/messaging/ChatAdapterProtocols");
70
+ var ChatSDKErrors_1 = require("./core/ChatSDKErrors");
69
71
  var ConversationMode_1 = require("./core/ConversationMode");
70
72
  var DeliveryMode_1 = require("@microsoft/omnichannel-ic3core/lib/model/DeliveryMode");
71
73
  var FileSharingProtocolType_1 = require("@microsoft/omnichannel-ic3core/lib/model/FileSharingProtocolType");
@@ -81,20 +83,19 @@ var ProtocoleType_1 = require("@microsoft/omnichannel-ic3core/lib/interfaces/Pro
81
83
  var ScenarioMarker_1 = require("./telemetry/ScenarioMarker");
82
84
  var TelemetryEvent_1 = require("./telemetry/TelemetryEvent");
83
85
  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");
87
86
  var createOmnichannelMessage_1 = require("./utils/createOmnichannelMessage");
88
87
  var createTelemetry_1 = require("./utils/createTelemetry");
89
88
  var createVoiceVideoCalling_1 = require("./api/createVoiceVideoCalling");
90
89
  var MessageTags_1 = require("./core/messaging/MessageTags");
90
+ var location_1 = require("./utils/location");
91
91
  var utilities_1 = require("./utils/utilities");
92
- var libraries_1 = require("./utils/libraries");
92
+ var urlResolvers_1 = require("./utils/urlResolvers");
93
93
  var OmnichannelConfigValidator_1 = require("./validators/OmnichannelConfigValidator");
94
94
  var OmnichannelChatSDK = /** @class */ (function () {
95
95
  function OmnichannelChatSDK(omnichannelConfig, chatSDKConfig) {
96
+ var _this = this;
96
97
  if (chatSDKConfig === void 0) { chatSDKConfig = SDKConfigValidators_1.defaultChatSDKConfig; }
97
- var _a, _b, _c, _d, _e, _f, _g, _h;
98
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
98
99
  this.ACSClient = null;
99
100
  this.AMSClient = null;
100
101
  this.authSettings = null;
@@ -107,10 +108,63 @@ var OmnichannelChatSDK = /** @class */ (function () {
107
108
  this.acsClientLogger = null;
108
109
  this.acsAdapterLogger = null;
109
110
  this.callingSdkLogger = null;
111
+ this.amsClientLogger = null;
110
112
  this.isPersistentChat = false;
111
113
  this.isChatReconnect = false;
112
114
  this.reconnectId = null;
113
115
  this.refreshTokenTimer = null;
116
+ this.populateInitChatOptionalParam = function (requestOptionalParams, optionalParams) {
117
+ requestOptionalParams.initContext.locale = locale_1.getLocaleStringFromId(_this.localeId);
118
+ if (optionalParams.customContext) {
119
+ requestOptionalParams.initContext.customContextData = optionalParams.customContext; // eslint-disable-line @typescript-eslint/no-explicit-any
120
+ }
121
+ if (optionalParams.browser) {
122
+ requestOptionalParams.initContext.browser = optionalParams.browser;
123
+ }
124
+ if (optionalParams.os) {
125
+ requestOptionalParams.initContext.os = optionalParams.os;
126
+ }
127
+ if (optionalParams.locale) {
128
+ requestOptionalParams.initContext.locale = optionalParams.locale;
129
+ }
130
+ if (optionalParams.device) {
131
+ requestOptionalParams.initContext.device = optionalParams.device;
132
+ }
133
+ if (optionalParams.preChatResponse) {
134
+ requestOptionalParams.initContext.preChatResponse = optionalParams.preChatResponse;
135
+ }
136
+ if (optionalParams.portalContactId) {
137
+ requestOptionalParams.initContext.portalcontactid = optionalParams.portalContactId;
138
+ }
139
+ if (optionalParams.sendDefaultInitContext) {
140
+ if (platform_1.default.isNode() || platform_1.default.isReactNative()) {
141
+ var exceptionDetails = {
142
+ response: ChatSDKErrors_1.default.UnsupportedPlatform,
143
+ message: "sendDefaultInitContext is only supported on browser"
144
+ };
145
+ console.error(exceptionDetails.message);
146
+ _this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAgentAvailability, {
147
+ RequestId: _this.requestId,
148
+ ChatId: _this.chatToken.chatId,
149
+ ExceptionDetails: JSON.stringify(exceptionDetails)
150
+ });
151
+ throw new Error(exceptionDetails.response);
152
+ }
153
+ requestOptionalParams.getContext = true;
154
+ }
155
+ // Override initContext completely
156
+ if (optionalParams.initContext) {
157
+ requestOptionalParams.initContext = optionalParams.initContext;
158
+ }
159
+ if (_this.authenticatedUserToken) {
160
+ requestOptionalParams.authenticatedUserToken = _this.authenticatedUserToken;
161
+ }
162
+ if (_this.chatToken.chatId) {
163
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
164
+ requestOptionalParams.initContext.chatId = _this.chatToken.chatId;
165
+ }
166
+ return requestOptionalParams;
167
+ };
114
168
  this.debug = false;
115
169
  this.runtimeId = ocsdk_1.uuidv4();
116
170
  this.omnichannelConfig = omnichannelConfig;
@@ -132,18 +186,21 @@ var OmnichannelChatSDK = /** @class */ (function () {
132
186
  this.acsClientLogger = loggers_1.createACSClientLogger(this.omnichannelConfig);
133
187
  this.acsAdapterLogger = loggers_1.createACSAdapterLogger(this.omnichannelConfig);
134
188
  this.callingSdkLogger = loggers_1.createCallingSDKLogger(this.omnichannelConfig);
189
+ this.amsClientLogger = loggers_1.createAMSClientLogger(this.omnichannelConfig);
135
190
  this.scenarioMarker.useTelemetry(this.telemetry);
136
191
  this.ic3ClientLogger.useTelemetry(this.telemetry);
137
192
  this.ocSdkLogger.useTelemetry(this.telemetry);
138
193
  this.acsClientLogger.useTelemetry(this.telemetry);
139
194
  this.acsAdapterLogger.useTelemetry(this.telemetry);
140
195
  this.callingSdkLogger.useTelemetry(this.telemetry);
196
+ this.amsClientLogger.useTelemetry(this.telemetry);
141
197
  this.scenarioMarker.setRuntimeId(this.runtimeId);
142
198
  this.ic3ClientLogger.setRuntimeId(this.runtimeId);
143
199
  this.ocSdkLogger.setRuntimeId(this.runtimeId);
144
200
  this.acsClientLogger.setRuntimeId(this.runtimeId);
145
201
  this.acsAdapterLogger.setRuntimeId(this.runtimeId);
146
202
  this.callingSdkLogger.setRuntimeId(this.runtimeId);
203
+ this.amsClientLogger.setRuntimeId(this.runtimeId);
147
204
  OmnichannelConfigValidator_1.default(omnichannelConfig);
148
205
  SDKConfigValidators_1.default(chatSDKConfig);
149
206
  ((_a = this.chatSDKConfig.telemetry) === null || _a === void 0 ? void 0 : _a.disable) && ((_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.disable());
@@ -155,10 +212,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
155
212
  (_f = this.acsClientLogger) === null || _f === void 0 ? void 0 : _f.setRequestId(this.requestId);
156
213
  (_g = this.acsAdapterLogger) === null || _g === void 0 ? void 0 : _g.setRequestId(this.requestId);
157
214
  (_h = this.callingSdkLogger) === null || _h === void 0 ? void 0 : _h.setRequestId(this.requestId);
215
+ (_j = this.amsClientLogger) === null || _j === void 0 ? void 0 : _j.setRequestId(this.requestId);
158
216
  }
159
217
  /* istanbul ignore next */
160
218
  OmnichannelChatSDK.prototype.setDebug = function (flag) {
161
- var _a, _b, _c, _d, _e, _f, _g;
219
+ var _a, _b, _c, _d, _e, _f, _g, _h;
162
220
  this.debug = flag;
163
221
  (_a = this.AMSClient) === null || _a === void 0 ? void 0 : _a.setDebug(flag);
164
222
  (_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.setDebug(flag);
@@ -168,6 +226,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
168
226
  (_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setDebug(flag);
169
227
  (_f = this.acsAdapterLogger) === null || _f === void 0 ? void 0 : _f.setDebug(flag);
170
228
  (_g = this.callingSdkLogger) === null || _g === void 0 ? void 0 : _g.setDebug(flag);
229
+ (_h = this.amsClientLogger) === null || _h === void 0 ? void 0 : _h.setDebug(flag);
171
230
  };
172
231
  OmnichannelChatSDK.prototype.initialize = function (optionalParams) {
173
232
  if (optionalParams === void 0) { optionalParams = {}; }
@@ -200,7 +259,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
200
259
  framedMode: platform_1.isBrowser(),
201
260
  multiClient: true,
202
261
  debug: false,
203
- logger: undefined
262
+ logger: this.amsClientLogger
204
263
  })];
205
264
  case 4:
206
265
  _b.AMSClient = _e.sent();
@@ -309,44 +368,44 @@ var OmnichannelChatSDK = /** @class */ (function () {
309
368
  });
310
369
  };
311
370
  OmnichannelChatSDK.prototype.startChat = function (optionalParams) {
312
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
371
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
313
372
  if (optionalParams === void 0) { optionalParams = {}; }
314
373
  return __awaiter(this, void 0, void 0, function () {
315
- var shouldReinitIC3Client, _t, reconnectableChatsParams, reconnectableChatsResponse, _u, exceptionDetails, conversationDetails, exceptionDetails, exceptionDetails, _v, exceptionDetails, sessionInitOptionalParams, exceptionDetails, error_3, exceptionDetails, chatAdapterConfig, error_4, exceptionDetails, _w, error_5, exceptionDetails, error_6, exceptionDetails, error_7, exceptionDetails, _x, error_8, exceptionDetails;
374
+ var shouldReinitIC3Client, _w, reconnectableChatsParams, reconnectableChatsResponse, _x, exceptionDetails, conversationDetails, exceptionDetails, exceptionDetails, _y, exceptionDetails, sessionInitOptionalParams, location_2, error_3, exceptionDetails, chatAdapterConfig, error_4, exceptionDetails, _z, error_5, exceptionDetails, error_6, exceptionDetails, error_7, exceptionDetails, _0, error_8, exceptionDetails;
316
375
  var _this = this;
317
- return __generator(this, function (_y) {
318
- switch (_y.label) {
376
+ return __generator(this, function (_1) {
377
+ switch (_1.label) {
319
378
  case 0:
320
379
  this.scenarioMarker.startScenario(TelemetryEvent_1.default.StartChat, {
321
380
  RequestId: this.requestId
322
381
  });
323
382
  shouldReinitIC3Client = !platform_1.default.isNode() && !platform_1.default.isReactNative() && !this.IC3Client && this.liveChatVersion === LiveChatVersion_1.default.V1;
324
383
  if (!shouldReinitIC3Client) return [3 /*break*/, 2];
325
- _t = this;
384
+ _w = this;
326
385
  return [4 /*yield*/, this.getIC3Client()];
327
386
  case 1:
328
- _t.IC3Client = _y.sent();
329
- _y.label = 2;
387
+ _w.IC3Client = _1.sent();
388
+ _1.label = 2;
330
389
  case 2:
331
390
  if (this.isChatReconnect && !((_a = this.chatSDKConfig.chatReconnect) === null || _a === void 0 ? void 0 : _a.disable) && !this.isPersistentChat && optionalParams.reconnectId) {
332
391
  this.reconnectId = optionalParams.reconnectId;
333
392
  }
334
393
  if (!(this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable))) return [3 /*break*/, 6];
335
- _y.label = 3;
394
+ _1.label = 3;
336
395
  case 3:
337
- _y.trys.push([3, 5, , 6]);
396
+ _1.trys.push([3, 5, , 6]);
338
397
  reconnectableChatsParams = {
339
398
  authenticatedUserToken: this.authenticatedUserToken
340
399
  };
341
400
  return [4 /*yield*/, this.OCClient.getReconnectableChats(reconnectableChatsParams)];
342
401
  case 4:
343
- reconnectableChatsResponse = _y.sent();
402
+ reconnectableChatsResponse = _1.sent();
344
403
  if (reconnectableChatsResponse && reconnectableChatsResponse.reconnectid) {
345
404
  this.reconnectId = reconnectableChatsResponse.reconnectid;
346
405
  }
347
406
  return [3 /*break*/, 6];
348
407
  case 5:
349
- _u = _y.sent();
408
+ _x = _1.sent();
350
409
  exceptionDetails = {
351
410
  response: "OCClientGetReconnectableChatsFailed"
352
411
  };
@@ -357,7 +416,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
357
416
  this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
358
417
  return [4 /*yield*/, this.getConversationDetails()];
359
418
  case 7:
360
- conversationDetails = _y.sent();
419
+ conversationDetails = _1.sent();
361
420
  if (Object.keys(conversationDetails).length === 0) {
362
421
  exceptionDetails = {
363
422
  response: "InvalidConversation"
@@ -382,30 +441,30 @@ var OmnichannelChatSDK = /** @class */ (function () {
382
441
  console.error("Unable to join conversation that's in '" + conversationDetails.state + "' state");
383
442
  throw Error(exceptionDetails.response);
384
443
  }
385
- _y.label = 8;
444
+ _1.label = 8;
386
445
  case 8:
387
446
  if (!this.authSettings) return [3 /*break*/, 14];
388
447
  if (!!this.authenticatedUserToken) return [3 /*break*/, 10];
389
448
  return [4 /*yield*/, this.setAuthTokenProvider(this.chatSDKConfig.getAuthToken)];
390
449
  case 9:
391
- _y.sent();
392
- _y.label = 10;
450
+ _1.sent();
451
+ _1.label = 10;
393
452
  case 10:
394
453
  if (!(optionalParams.liveChatContext && Object.keys(optionalParams.liveChatContext).length > 0)) return [3 /*break*/, 14];
395
454
  this.chatToken = optionalParams.liveChatContext.chatToken || {};
396
455
  this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
397
- _y.label = 11;
456
+ _1.label = 11;
398
457
  case 11:
399
- _y.trys.push([11, 13, , 14]);
458
+ _1.trys.push([11, 13, , 14]);
400
459
  return [4 /*yield*/, this.OCClient.validateAuthChatRecord(this.requestId, {
401
460
  authenticatedUserToken: this.authenticatedUserToken,
402
461
  chatId: this.chatToken.chatId
403
462
  })];
404
463
  case 12:
405
- _y.sent();
464
+ _1.sent();
406
465
  return [3 /*break*/, 14];
407
466
  case 13:
408
- _v = _y.sent();
467
+ _y = _1.sent();
409
468
  exceptionDetails = {
410
469
  response: "OCClientValidateAuthChatRecordFailed",
411
470
  message: "InvalidAuthChatRecord"
@@ -420,84 +479,49 @@ var OmnichannelChatSDK = /** @class */ (function () {
420
479
  if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 16];
421
480
  return [4 /*yield*/, this.getChatToken(false)];
422
481
  case 15:
423
- _y.sent();
424
- _y.label = 16;
482
+ _1.sent();
483
+ _1.label = 16;
425
484
  case 16:
426
485
  (_c = this.ic3ClientLogger) === null || _c === void 0 ? void 0 : _c.setChatId(this.chatToken.chatId || '');
427
486
  (_d = this.ocSdkLogger) === null || _d === void 0 ? void 0 : _d.setChatId(this.chatToken.chatId || '');
428
487
  (_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setChatId(this.chatToken.chatId || '');
429
488
  (_f = this.acsAdapterLogger) === null || _f === void 0 ? void 0 : _f.setChatId(this.chatToken.chatId || '');
430
489
  (_g = this.callingSdkLogger) === null || _g === void 0 ? void 0 : _g.setChatId(this.chatToken.chatId || '');
490
+ (_h = this.amsClientLogger) === null || _h === void 0 ? void 0 : _h.setChatId(this.chatToken.chatId || '');
431
491
  sessionInitOptionalParams = {
432
492
  initContext: {}
433
493
  };
434
- sessionInitOptionalParams.initContext.locale = locale_1.getLocaleStringFromId(this.localeId);
435
- if (this.isPersistentChat && !((_h = this.chatSDKConfig.persistentChat) === null || _h === void 0 ? void 0 : _h.disable)) {
494
+ sessionInitOptionalParams = this.populateInitChatOptionalParam(sessionInitOptionalParams, optionalParams);
495
+ sessionInitOptionalParams.initContext.isProactiveChat = !!optionalParams.isProactiveChat;
496
+ if (this.isPersistentChat && !((_j = this.chatSDKConfig.persistentChat) === null || _j === void 0 ? void 0 : _j.disable)) {
436
497
  sessionInitOptionalParams.reconnectId = this.reconnectId;
437
498
  }
438
- if (this.isChatReconnect && !((_j = this.chatSDKConfig.chatReconnect) === null || _j === void 0 ? void 0 : _j.disable) && !this.isPersistentChat) {
499
+ else if (this.isChatReconnect && !((_k = this.chatSDKConfig.chatReconnect) === null || _k === void 0 ? void 0 : _k.disable) && !this.isPersistentChat) {
439
500
  sessionInitOptionalParams.reconnectId = this.reconnectId;
440
501
  }
441
- if (optionalParams.customContext) {
442
- sessionInitOptionalParams.initContext.customContextData = optionalParams.customContext; // eslint-disable-line @typescript-eslint/no-explicit-any
443
- }
444
- if (optionalParams.browser) {
445
- sessionInitOptionalParams.initContext.browser = optionalParams.browser;
446
- }
447
- if (optionalParams.os) {
448
- sessionInitOptionalParams.initContext.os = optionalParams.os;
449
- }
450
- if (optionalParams.locale) {
451
- sessionInitOptionalParams.initContext.locale = optionalParams.locale;
452
- }
453
- if (optionalParams.device) {
454
- sessionInitOptionalParams.initContext.device = optionalParams.device;
455
- }
456
- if (optionalParams.preChatResponse) {
457
- sessionInitOptionalParams.initContext.preChatResponse = optionalParams.preChatResponse;
458
- }
459
- if (optionalParams.sendDefaultInitContext) {
460
- if (platform_1.default.isNode() || platform_1.default.isReactNative()) {
461
- exceptionDetails = {
462
- response: "UnsupportedPlatform",
463
- message: "sendDefaultInitContext is only supported on browser"
464
- };
465
- console.error(exceptionDetails.message);
466
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
467
- RequestId: this.requestId,
468
- ChatId: this.chatToken.chatId,
469
- ExceptionDetails: JSON.stringify(exceptionDetails)
470
- });
471
- throw new Error(exceptionDetails.response);
472
- }
473
- sessionInitOptionalParams.getContext = true;
474
- }
475
- // Override initContext completely
476
- if (optionalParams.initContext) {
477
- sessionInitOptionalParams.initContext = optionalParams.initContext;
478
- }
479
- if (this.authenticatedUserToken) {
480
- sessionInitOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
481
- }
482
- if (this.chatToken.chatId) {
483
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
484
- sessionInitOptionalParams.initContext.chatId = this.chatToken.chatId;
485
- }
486
- if (!!optionalParams.liveChatContext) return [3 /*break*/, 20];
487
- _y.label = 17;
502
+ if (!(((_m = (_l = this.liveChatConfig) === null || _l === void 0 ? void 0 : _l.LiveWSAndLiveChatEngJoin) === null || _m === void 0 ? void 0 : _m.msdyn_requestvisitorlocation) === "true")) return [3 /*break*/, 18];
503
+ return [4 /*yield*/, location_1.getLocationInfo(this.scenarioMarker, this.chatToken.chatId, this.requestId)];
488
504
  case 17:
489
- _y.trys.push([17, 19, , 20]);
490
- return [4 /*yield*/, this.OCClient.sessionInit(this.requestId, sessionInitOptionalParams)];
505
+ location_2 = _1.sent();
506
+ sessionInitOptionalParams.initContext.latitude = location_2.latitude;
507
+ sessionInitOptionalParams.initContext.longitude = location_2.longitude;
508
+ _1.label = 18;
491
509
  case 18:
492
- _y.sent();
493
- return [3 /*break*/, 20];
510
+ if (!!optionalParams.liveChatContext) return [3 /*break*/, 22];
511
+ _1.label = 19;
494
512
  case 19:
495
- error_3 = _y.sent();
513
+ _1.trys.push([19, 21, , 22]);
514
+ return [4 /*yield*/, this.OCClient.sessionInit(this.requestId, sessionInitOptionalParams)];
515
+ case 20:
516
+ _1.sent();
517
+ return [3 /*break*/, 22];
518
+ case 21:
519
+ error_3 = _1.sent();
496
520
  exceptionDetails = {
497
521
  response: "OCClientSessionInitFailed"
498
522
  };
499
523
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
500
- 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()) {
524
+ if (((_o = error_3) === null || _o === void 0 ? void 0 : _o.isAxiosError) && ((_q = (_p = error_3.response) === null || _p === void 0 ? void 0 : _p.headers) === null || _q === void 0 ? void 0 : _q.errorcode.toString()) === OmnichannelErrorCodes_1.default.WidgetUseOutsideOperatingHour.toString()) {
501
525
  exceptionDetails.response = OmnichannelErrorCodes_1.default[OmnichannelErrorCodes_1.default.WidgetUseOutsideOperatingHour].toString();
502
526
  exceptionDetails.message = 'Widget used outside of operating hours';
503
527
  console.error(exceptionDetails.message);
@@ -508,8 +532,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
508
532
  ExceptionDetails: JSON.stringify(exceptionDetails)
509
533
  });
510
534
  throw new Error(exceptionDetails.response);
511
- case 20:
512
- if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 31];
535
+ case 22:
536
+ if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 33];
513
537
  chatAdapterConfig = {
514
538
  token: this.chatToken.token,
515
539
  id: this.chatToken.visitorId || 'teamsvisitor',
@@ -517,18 +541,18 @@ var OmnichannelChatSDK = /** @class */ (function () {
517
541
  environmentUrl: this.chatToken.acsEndpoint,
518
542
  pollingInterval: 30000
519
543
  };
520
- _y.label = 21;
521
- case 21:
522
- _y.trys.push([21, 23, , 24]);
523
- return [4 /*yield*/, ((_o = this.ACSClient) === null || _o === void 0 ? void 0 : _o.initialize({
544
+ _1.label = 23;
545
+ case 23:
546
+ _1.trys.push([23, 25, , 26]);
547
+ return [4 /*yield*/, ((_r = this.ACSClient) === null || _r === void 0 ? void 0 : _r.initialize({
524
548
  token: chatAdapterConfig.token,
525
549
  environmentUrl: chatAdapterConfig.environmentUrl
526
550
  }))];
527
- case 22:
528
- _y.sent();
529
- return [3 /*break*/, 24];
530
- case 23:
531
- error_4 = _y.sent();
551
+ case 24:
552
+ _1.sent();
553
+ return [3 /*break*/, 26];
554
+ case 25:
555
+ error_4 = _1.sent();
532
556
  exceptionDetails = {
533
557
  response: "ACSClientInitializeFailed"
534
558
  };
@@ -539,23 +563,23 @@ var OmnichannelChatSDK = /** @class */ (function () {
539
563
  });
540
564
  console.error("OmnichannelChatSDK/startChat/initialize/error " + error_4);
541
565
  return [2 /*return*/, error_4];
542
- case 24:
543
- _y.trys.push([24, 26, , 27]);
544
- _w = this;
545
- return [4 /*yield*/, ((_p = this.ACSClient) === null || _p === void 0 ? void 0 : _p.joinConversation({
566
+ case 26:
567
+ _1.trys.push([26, 28, , 29]);
568
+ _z = this;
569
+ return [4 /*yield*/, ((_s = this.ACSClient) === null || _s === void 0 ? void 0 : _s.joinConversation({
546
570
  id: chatAdapterConfig.id,
547
571
  threadId: chatAdapterConfig.threadId,
548
572
  pollingInterval: chatAdapterConfig.pollingInterval
549
573
  }))];
550
- case 25:
551
- _w.conversation = (_y.sent());
574
+ case 27:
575
+ _z.conversation = (_1.sent());
552
576
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
553
577
  RequestId: this.requestId,
554
578
  ChatId: this.chatToken.chatId
555
579
  });
556
- return [3 /*break*/, 27];
557
- case 26:
558
- error_5 = _y.sent();
580
+ return [3 /*break*/, 29];
581
+ case 28:
582
+ error_5 = _1.sent();
559
583
  exceptionDetails = {
560
584
  response: "ACSClientJoinConversationFailed"
561
585
  };
@@ -566,16 +590,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
566
590
  });
567
591
  console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_5);
568
592
  throw Error(exceptionDetails.response);
569
- case 27:
570
- _y.trys.push([27, 29, , 30]);
571
- return [4 /*yield*/, ((_q = this.AMSClient) === null || _q === void 0 ? void 0 : _q.initialize({
593
+ case 29:
594
+ _1.trys.push([29, 31, , 32]);
595
+ return [4 /*yield*/, ((_t = this.AMSClient) === null || _t === void 0 ? void 0 : _t.initialize({
572
596
  chatToken: this.chatToken
573
597
  }))];
574
- case 28:
575
- _y.sent();
576
- return [3 /*break*/, 30];
577
- case 29:
578
- error_6 = _y.sent();
598
+ case 30:
599
+ _1.sent();
600
+ return [3 /*break*/, 32];
601
+ case 31:
602
+ error_6 = _1.sent();
579
603
  exceptionDetails = {
580
604
  response: "AMSClientInitializeFailed"
581
605
  };
@@ -585,19 +609,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
585
609
  ExceptionDetails: JSON.stringify(exceptionDetails)
586
610
  });
587
611
  throw Error(exceptionDetails.response);
588
- case 30: return [3 /*break*/, 37];
589
- case 31:
590
- _y.trys.push([31, 33, , 34]);
612
+ case 32: return [3 /*break*/, 39];
613
+ case 33:
614
+ _1.trys.push([33, 35, , 36]);
591
615
  return [4 /*yield*/, this.IC3Client.initialize({
592
616
  token: this.chatToken.token,
593
617
  regionGtms: this.chatToken.regionGTMS,
594
618
  visitor: true
595
619
  })];
596
- case 32:
597
- _y.sent();
598
- return [3 /*break*/, 34];
599
- case 33:
600
- error_7 = _y.sent();
620
+ case 34:
621
+ _1.sent();
622
+ return [3 /*break*/, 36];
623
+ case 35:
624
+ error_7 = _1.sent();
601
625
  exceptionDetails = {
602
626
  response: "IC3ClientInitializeFailed"
603
627
  };
@@ -608,19 +632,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
608
632
  });
609
633
  console.error("OmnichannelChatSDK/startChat/initialize/error " + error_7);
610
634
  return [2 /*return*/, error_7];
611
- case 34:
612
- _y.trys.push([34, 36, , 37]);
613
- _x = this;
635
+ case 36:
636
+ _1.trys.push([36, 38, , 39]);
637
+ _0 = this;
614
638
  return [4 /*yield*/, this.IC3Client.joinConversation(this.chatToken.chatId)];
615
- case 35:
616
- _x.conversation = _y.sent();
639
+ case 37:
640
+ _0.conversation = _1.sent();
617
641
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
618
642
  RequestId: this.requestId,
619
643
  ChatId: this.chatToken.chatId
620
644
  });
621
- return [3 /*break*/, 37];
622
- case 36:
623
- error_8 = _y.sent();
645
+ return [3 /*break*/, 39];
646
+ case 38:
647
+ error_8 = _1.sent();
624
648
  exceptionDetails = {
625
649
  response: "IC3ClientJoinConversationFailed"
626
650
  };
@@ -631,8 +655,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
631
655
  });
632
656
  console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_8);
633
657
  return [2 /*return*/, error_8];
634
- case 37:
635
- if (this.isPersistentChat && !((_r = this.chatSDKConfig.persistentChat) === null || _r === void 0 ? void 0 : _r.disable)) {
658
+ case 39:
659
+ if (this.isPersistentChat && !((_u = this.chatSDKConfig.persistentChat) === null || _u === void 0 ? void 0 : _u.disable)) {
636
660
  this.refreshTokenTimer = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
637
661
  return __generator(this, function (_a) {
638
662
  switch (_a.label) {
@@ -643,7 +667,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
643
667
  return [2 /*return*/];
644
668
  }
645
669
  });
646
- }); }, (_s = this.chatSDKConfig.persistentChat) === null || _s === void 0 ? void 0 : _s.tokenUpdateTime);
670
+ }); }, (_v = this.chatSDKConfig.persistentChat) === null || _v === void 0 ? void 0 : _v.tokenUpdateTime);
647
671
  }
648
672
  return [2 /*return*/];
649
673
  }
@@ -651,11 +675,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
651
675
  });
652
676
  };
653
677
  OmnichannelChatSDK.prototype.endChat = function () {
654
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
678
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
655
679
  return __awaiter(this, void 0, void 0, function () {
656
680
  var sessionCloseOptionalParams, isReconnectChat, isChatReconnect, error_9, exceptionDetails;
657
- return __generator(this, function (_p) {
658
- switch (_p.label) {
681
+ return __generator(this, function (_r) {
682
+ switch (_r.label) {
659
683
  case 0:
660
684
  this.scenarioMarker.startScenario(TelemetryEvent_1.default.EndChat, {
661
685
  RequestId: this.requestId,
@@ -675,12 +699,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
675
699
  if (this.authenticatedUserToken) {
676
700
  sessionCloseOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
677
701
  }
678
- _p.label = 1;
702
+ _r.label = 1;
679
703
  case 1:
680
- _p.trys.push([1, 3, , 4]);
704
+ _r.trys.push([1, 3, , 4]);
681
705
  return [4 /*yield*/, this.OCClient.sessionClose(this.requestId, sessionCloseOptionalParams)];
682
706
  case 2:
683
- _p.sent();
707
+ _r.sent();
684
708
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.EndChat, {
685
709
  RequestId: this.requestId,
686
710
  ChatId: this.chatToken.chatId
@@ -705,9 +729,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
705
729
  (_l = this.acsAdapterLogger) === null || _l === void 0 ? void 0 : _l.setChatId('');
706
730
  (_m = this.callingSdkLogger) === null || _m === void 0 ? void 0 : _m.setRequestId(this.requestId);
707
731
  (_o = this.callingSdkLogger) === null || _o === void 0 ? void 0 : _o.setChatId('');
732
+ (_p = this.amsClientLogger) === null || _p === void 0 ? void 0 : _p.setRequestId(this.requestId);
733
+ (_q = this.amsClientLogger) === null || _q === void 0 ? void 0 : _q.setChatId('');
708
734
  return [3 /*break*/, 4];
709
735
  case 3:
710
- error_9 = _p.sent();
736
+ error_9 = _r.sent();
711
737
  exceptionDetails = {
712
738
  response: "OCClientSessionCloseFailed"
713
739
  };
@@ -1611,96 +1637,28 @@ var OmnichannelChatSDK = /** @class */ (function () {
1611
1637
  });
1612
1638
  };
1613
1639
  OmnichannelChatSDK.prototype.createChatAdapter = function (optionalParams) {
1640
+ var _a;
1614
1641
  if (optionalParams === void 0) { optionalParams = {}; }
1615
1642
  return __awaiter(this, void 0, void 0, function () {
1616
- var protocol, supportedChatAdapterProtocols;
1617
- var _this = this;
1618
- return __generator(this, function (_a) {
1643
+ var protocol, supportedChatAdapterProtocols, fileManager;
1644
+ return __generator(this, function (_b) {
1619
1645
  if (platform_1.default.isNode() || platform_1.default.isReactNative()) {
1620
1646
  return [2 /*return*/, Promise.reject('ChatAdapter is only supported on browser')];
1621
1647
  }
1622
1648
  protocol = optionalParams.protocol;
1623
- supportedChatAdapterProtocols = [ChatAdapterProtocols_1.default.ACS, ChatAdapterProtocols_1.default.IC3];
1649
+ supportedChatAdapterProtocols = [ChatAdapterProtocols_1.default.ACS, ChatAdapterProtocols_1.default.IC3, ChatAdapterProtocols_1.default.DirectLine];
1624
1650
  if (protocol && !supportedChatAdapterProtocols.includes(protocol)) {
1625
1651
  return [2 /*return*/, Promise.reject("ChatAdapter for protocol " + protocol + " currently not supported")];
1626
1652
  }
1627
- if (protocol === ChatAdapterProtocols_1.default.ACS || this.liveChatVersion === LiveChatVersion_1.default.V2) {
1628
- return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
1629
- var options, defaultEgressMiddlewares, defaultIngressMiddlewares, egressMiddleware, ingressMiddleware, featuresOption, acsAdapterCDNUrl;
1630
- var _this = this;
1631
- var _a;
1632
- return __generator(this, function (_b) {
1633
- switch (_b.label) {
1634
- case 0:
1635
- options = optionalParams.ACSAdapter ? optionalParams.ACSAdapter.options : {};
1636
- defaultEgressMiddlewares = [createChannelDataEgressMiddleware_1.default({ widgetId: this.omnichannelConfig.widgetId }), createFormatEgressTagsMiddleware_1.default()];
1637
- defaultIngressMiddlewares = [createFormatIngressTagsMiddleware_1.default()];
1638
- egressMiddleware = (options === null || options === void 0 ? void 0 : options.egressMiddleware) ? __spreadArrays(options.egressMiddleware, defaultEgressMiddlewares) : __spreadArrays(defaultEgressMiddlewares);
1639
- ingressMiddleware = (options === null || options === void 0 ? void 0 : options.ingressMiddleware) ? __spreadArrays(options.egressMiddleware, defaultIngressMiddlewares) : __spreadArrays(defaultIngressMiddlewares);
1640
- featuresOption = __assign(__assign({ enableAdaptiveCards: true, enableThreadMemberUpdateNotification: true, enableLeaveThreadOnWindowClosed: false }, options), { // overrides
1641
- ingressMiddleware: ingressMiddleware,
1642
- egressMiddleware: egressMiddleware });
1643
- acsAdapterCDNUrl = this.resolveChatAdapterUrl(protocol || ChatAdapterProtocols_1.default.ACS);
1644
- (_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
1645
- ACSAdapter: acsAdapterCDNUrl
1646
- });
1647
- return [4 /*yield*/, WebUtils_1.loadScript(acsAdapterCDNUrl, function () {
1648
- var _a;
1649
- /* istanbul ignore next */
1650
- _this.debug && console.debug('ACSAdapter loaded!');
1651
- try {
1652
- var ChatAdapter = window.ChatAdapter; // eslint-disable-line @typescript-eslint/no-explicit-any
1653
- var fileManager = new AMSFileManager_1.default(_this.AMSClient, _this.acsAdapterLogger);
1654
- var adapter = ChatAdapter.createACSAdapter(_this.chatToken.token, _this.chatToken.visitorId || 'teamsvisitor', _this.chatToken.chatId, _this.chatToken.acsEndpoint, fileManager, 30000, ACSParticipantDisplayName_1.default.Customer, (_a = _this.ACSClient) === null || _a === void 0 ? void 0 : _a.getChatClient(), _this.acsAdapterLogger, // logger
1655
- featuresOption);
1656
- resolve(adapter);
1657
- }
1658
- catch (_b) {
1659
- throw new Error('Failed to load ACSAdapter');
1660
- }
1661
- }, function () {
1662
- reject('Failed to load ACSADapter');
1663
- })];
1664
- case 1:
1665
- _b.sent();
1666
- return [2 /*return*/];
1667
- }
1668
- });
1669
- }); })];
1653
+ if (protocol === ChatAdapterProtocols_1.default.DirectLine) {
1654
+ return [2 /*return*/, chatAdapterCreators_1.createDirectLine(optionalParams, this.chatSDKConfig, this.liveChatVersion, ChatAdapterProtocols_1.default.DirectLine, this.telemetry, this.scenarioMarker)];
1655
+ }
1656
+ else if (protocol === ChatAdapterProtocols_1.default.ACS || this.liveChatVersion === LiveChatVersion_1.default.V2) {
1657
+ fileManager = new AMSFileManager_1.default(this.AMSClient, this.acsAdapterLogger);
1658
+ return [2 /*return*/, chatAdapterCreators_1.createACSAdapter(optionalParams, this.chatSDKConfig, this.liveChatVersion, ChatAdapterProtocols_1.default.ACS, this.telemetry, this.scenarioMarker, this.omnichannelConfig, this.chatToken, fileManager, (_a = this.ACSClient) === null || _a === void 0 ? void 0 : _a.getChatClient(), this.acsAdapterLogger)];
1670
1659
  }
1671
1660
  else if (protocol === ChatAdapterProtocols_1.default.IC3 || this.liveChatVersion === LiveChatVersion_1.default.V1) {
1672
- return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
1673
- var options, ic3AdapterCDNUrl;
1674
- var _this = this;
1675
- var _a;
1676
- return __generator(this, function (_b) {
1677
- switch (_b.label) {
1678
- case 0:
1679
- options = optionalParams.IC3Adapter ? optionalParams.IC3Adapter.options : {};
1680
- ic3AdapterCDNUrl = this.resolveChatAdapterUrl(protocol || ChatAdapterProtocols_1.default.IC3);
1681
- (_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
1682
- IC3Adapter: ic3AdapterCDNUrl
1683
- });
1684
- this.scenarioMarker.startScenario(TelemetryEvent_1.default.CreateIC3Adapter);
1685
- return [4 /*yield*/, WebUtils_1.loadScript(ic3AdapterCDNUrl, function () {
1686
- /* istanbul ignore next */
1687
- _this.debug && console.debug('IC3Adapter loaded!');
1688
- var adapterConfig = __assign({ chatToken: _this.chatToken, userDisplayName: 'Customer', userId: _this.chatToken.visitorId || 'teamsvisitor', sdkURL: _this.resolveIC3ClientUrl(), sdk: _this.IC3Client }, options // overrides
1689
- );
1690
- var adapter = new window.Microsoft.BotFramework.WebChat.IC3Adapter(adapterConfig);
1691
- adapter.logger = _this.ic3ClientLogger;
1692
- _this.scenarioMarker.completeScenario(TelemetryEvent_1.default.CreateIC3Adapter);
1693
- resolve(adapter);
1694
- }, function () {
1695
- _this.scenarioMarker.failScenario(TelemetryEvent_1.default.CreateIC3Adapter);
1696
- reject('Failed to load IC3Adapter');
1697
- })];
1698
- case 1:
1699
- _b.sent();
1700
- return [2 /*return*/];
1701
- }
1702
- });
1703
- }); })];
1661
+ return [2 /*return*/, chatAdapterCreators_1.createIC3Adapter(optionalParams, this.chatSDKConfig, this.liveChatVersion, ChatAdapterProtocols_1.default.IC3, this.telemetry, this.scenarioMarker, this.chatToken, this.IC3Client, this.ic3ClientLogger)];
1704
1662
  }
1705
1663
  return [2 /*return*/, Promise.reject("ChatAdapter for protocol " + protocol + " currently not supported")];
1706
1664
  });
@@ -1887,6 +1845,60 @@ var OmnichannelChatSDK = /** @class */ (function () {
1887
1845
  });
1888
1846
  });
1889
1847
  };
1848
+ OmnichannelChatSDK.prototype.getAgentAvailability = function (optionalParams) {
1849
+ if (optionalParams === void 0) { optionalParams = {}; }
1850
+ return __awaiter(this, void 0, void 0, function () {
1851
+ var reportError, getAgentAvailabilityOptionalParams, response, e_1;
1852
+ var _this = this;
1853
+ return __generator(this, function (_a) {
1854
+ switch (_a.label) {
1855
+ case 0:
1856
+ reportError = function (response, message, chatId) {
1857
+ if (chatId === void 0) { chatId = ""; }
1858
+ var exceptionDetails = {
1859
+ response: response,
1860
+ message: message
1861
+ };
1862
+ _this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAgentAvailability, {
1863
+ RequestId: _this.requestId,
1864
+ ExceptionDetails: JSON.stringify(exceptionDetails),
1865
+ ChatId: chatId
1866
+ });
1867
+ throw new Error(exceptionDetails.message);
1868
+ };
1869
+ this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetAgentAvailability, {
1870
+ RequestId: this.requestId
1871
+ });
1872
+ if (!this.authSettings) {
1873
+ reportError("Unsupported", "GetAgentAvailability is supported only for authenticated live chat widget.");
1874
+ }
1875
+ if (!this.authenticatedUserToken) {
1876
+ reportError("UndefinedAuthToken", "Missing AuthToken for GetAgentAvailability.");
1877
+ }
1878
+ if (this.conversation) {
1879
+ reportError("InvalidOperation", "GetAgentAvailability can only be called before a chat has started.", this.chatToken.chatId);
1880
+ }
1881
+ getAgentAvailabilityOptionalParams = {
1882
+ initContext: {}
1883
+ };
1884
+ getAgentAvailabilityOptionalParams = this.populateInitChatOptionalParam(getAgentAvailabilityOptionalParams, optionalParams);
1885
+ _a.label = 1;
1886
+ case 1:
1887
+ _a.trys.push([1, 3, , 4]);
1888
+ return [4 /*yield*/, this.OCClient.getAgentAvailability(this.requestId, getAgentAvailabilityOptionalParams)];
1889
+ case 2:
1890
+ response = _a.sent();
1891
+ return [2 /*return*/, response];
1892
+ case 3:
1893
+ e_1 = _a.sent();
1894
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1895
+ reportError("GetAgentAvailabilityFailed", e_1.message);
1896
+ return [3 /*break*/, 4];
1897
+ case 4: return [2 /*return*/];
1898
+ }
1899
+ });
1900
+ });
1901
+ };
1890
1902
  OmnichannelChatSDK.prototype.getIC3Client = function () {
1891
1903
  return __awaiter(this, void 0, void 0, function () {
1892
1904
  var IC3Client;
@@ -2043,38 +2055,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
2043
2055
  });
2044
2056
  };
2045
2057
  OmnichannelChatSDK.prototype.resolveIC3ClientUrl = function () {
2046
- if (this.chatSDKConfig.ic3Config && 'ic3ClientCDNUrl' in this.chatSDKConfig.ic3Config) {
2047
- return this.chatSDKConfig.ic3Config.ic3ClientCDNUrl;
2048
- }
2049
- if (this.chatSDKConfig.ic3Config && 'ic3ClientVersion' in this.chatSDKConfig.ic3Config) {
2050
- return libraries_1.default.getIC3ClientCDNUrl(this.chatSDKConfig.ic3Config.ic3ClientVersion);
2051
- }
2052
- return libraries_1.default.getIC3ClientCDNUrl();
2058
+ return urlResolvers_1.default.resolveIC3ClientUrl(this.chatSDKConfig);
2053
2059
  };
2054
2060
  OmnichannelChatSDK.prototype.resolveChatAdapterUrl = function (protocol) {
2055
- var supportedChatAdapterProtocols = [ChatAdapterProtocols_1.default.ACS, ChatAdapterProtocols_1.default.IC3];
2056
- if (protocol && !supportedChatAdapterProtocols.includes(protocol)) {
2057
- throw new Error("ChatAdapter for protocol " + protocol + " currently not supported");
2058
- }
2059
- if (protocol === ChatAdapterProtocols_1.default.ACS || this.liveChatVersion === LiveChatVersion_1.default.V2) {
2060
- if (this.chatSDKConfig.chatAdapterConfig && 'webChatACSAdapterCDNUrl' in this.chatSDKConfig.chatAdapterConfig) {
2061
- return this.chatSDKConfig.chatAdapterConfig.webChatACSAdapterCDNUrl;
2062
- }
2063
- if (this.chatSDKConfig.chatAdapterConfig && 'webChatACSAdapterVersion' in this.chatSDKConfig.chatAdapterConfig) {
2064
- return libraries_1.default.getACSAdapterCDNUrl(this.chatSDKConfig.chatAdapterConfig.webChatACSAdapterVersion);
2065
- }
2066
- return libraries_1.default.getACSAdapterCDNUrl();
2067
- }
2068
- else if (protocol === ChatAdapterProtocols_1.default.IC3 || this.liveChatVersion === LiveChatVersion_1.default.V1) {
2069
- if (this.chatSDKConfig.chatAdapterConfig && 'webChatIC3AdapterCDNUrl' in this.chatSDKConfig.chatAdapterConfig) {
2070
- return this.chatSDKConfig.chatAdapterConfig.webChatIC3AdapterCDNUrl;
2071
- }
2072
- if (this.chatSDKConfig.chatAdapterConfig && 'webChatIC3AdapterVersion' in this.chatSDKConfig.chatAdapterConfig) {
2073
- return libraries_1.default.getIC3AdapterCDNUrl(this.chatSDKConfig.chatAdapterConfig.webChatIC3AdapterVersion);
2074
- }
2075
- return libraries_1.default.getIC3AdapterCDNUrl();
2076
- }
2077
- return '';
2061
+ return urlResolvers_1.default.resolveChatAdapterUrl(this.chatSDKConfig, this.liveChatVersion, protocol);
2078
2062
  };
2079
2063
  OmnichannelChatSDK.prototype.updateChatToken = function (newToken, newRegionGTMS) {
2080
2064
  return __awaiter(this, void 0, void 0, function () {