@microsoft/omnichannel-chat-sdk 1.1.1-main.502460d → 1.1.1-main.51d87bb

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,26 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
4
  ## [Unreleased]
5
+ ### Added
6
+ - Add `sendDefaultInitContext` optional parameter to `ChatSDK.startChat()` to automatically populate `browser`, `device`, `originurl` & `os` as default init context on web
7
+ - Add `sendCacheHeaders` as optional paramater to `ChatSDK.initialize()` and `ChatSDK.getLiveChatConfig()`
8
+ - Add `validateAuthChatRecord` call on `ChatSDK.startChat()` with `liveChatContext` for all authenticated chat scenarios
9
+ - Pass `ChatClient` during `ACSAdapter` initialization
10
+ - Pass `multiClient` to `AMSClient` on initialization to support `ChatSDK` multi-client
11
+
12
+ ### Fixed
13
+ - Prevent `AMSFileManager.getFileIds()` & `AMSFileManager.getFileMetadata()` to be triggered on all activities with null checks
14
+ - Add `LiveChatVersion` check on `ChatSDK.updateChatToken()`
15
+ - Use `amsreferences` property instead of `amsReferences` by default
16
+ - Fix attachment download to use MIME types instead of file extensions
17
+ - Remove `fileMetadata` property on messages not containing any attachment
18
+
19
+ ### Changed
20
+ - Uptake [@microsoft/ocsdk@0.3.1](https://www.npmjs.com/package/@microsoft/ocsdk/v/0.3.1)
21
+ - Uptake [acs_webchat-chat-adapter@0.0.35-beta.8](https://unpkg.com/acs_webchat-chat-adapter@0.0.35-beta.8/dist/chat-adapter.js)
22
+ - Uptake [acs_webchat-chat-adapter@0.0.35-beta.9](https://unpkg.com/acs_webchat-chat-adapter@0.0.35-beta.9/dist/chat-adapter.js)
23
+ - Uptake [acs_webchat-chat-adapter@0.0.35-beta.12](https://unpkg.com/acs_webchat-chat-adapter@0.0.35-beta.12/dist/chat-adapter.js)
24
+ - Uptake [@microsoft/omnichannel-amsclient@0.1.2](https://www.npmjs.com/package/@microsoft/omnichannel-amsclient/v/0.1.2)
5
25
 
6
26
  ## [1.1.0] - 2022-04-15
7
27
  ### Added
@@ -20,7 +40,7 @@ All notable changes to this project will be documented in this file.
20
40
  - Add support for separate bot post chat survey feature
21
41
  - Pass `logger` to `acs_webchat-chat-adapter`
22
42
 
23
- ### Fix
43
+ ### Fixed
24
44
  - Add `acs_webchat-chat-adapter` middlewares to format `channelData.tags`
25
45
  - Skip `session init` call on existing conversation
26
46
  - Fix `chat reconnect` not ending the conversation on calling `ChatSDK.endChat()`
package/README.md CHANGED
@@ -1,13 +1,17 @@
1
- # Omnichannel Chat SDK
1
+ # Omnichannel Chat SDK 💬
2
2
 
3
3
  [![npm version](https://badge.fury.io/js/%40microsoft%2Fomnichannel-chat-sdk.svg)](https://badge.fury.io/js/%40microsoft%2Fomnichannel-chat-sdk)
4
4
  [![install size](https://packagephobia.com/badge?p=@microsoft/omnichannel-chat-sdk)](https://packagephobia.com/result?p=@microsoft/omnichannel-chat-sdk)
5
5
  ![Release CI](https://github.com/microsoft/omnichannel-chat-sdk/workflows/Release%20CI/badge.svg)
6
6
  ![npm](https://img.shields.io/npm/dm/@microsoft/omnichannel-chat-sdk)
7
7
 
8
+ > ❗ Chat SDK **v1.1.0** is the minimum version to support the **new** messaging platform. More [here](https://docs.microsoft.com/en-us/dynamics365/customer-service/migrate-acs)
9
+
10
+ > 📢 Try out our new React component library [omnichannel-chat-widget](https://github.com/microsoft/omnichannel-chat-widget) with Chat SDK
11
+
8
12
  Headless Chat SDK to build your own chat widget against Dynamics 365 Omnichannel Services.
9
13
 
10
- Please make sure you have a chat widget configured before using this package or you can follow this [link](https://docs.microsoft.com/en-us/dynamics365/customer-service/configure-live-chat)
14
+ Please make sure you have a chat widget configured before using this package or you can follow this [link](https://docs.microsoft.com/en-us/dynamics365/customer-service/add-chat-widget)
11
15
 
12
16
  ## Table of Contents
13
17
  - [Live Chat Widget vs. Chat SDK](#live-chat-widget-vs-chat-sdk)
@@ -40,6 +44,7 @@ Please make sure you have a chat widget configured before using this package or
40
44
  - [Get Post Chat Survey Context](#get-post-chat-survey-context)
41
45
  - [Common Scenarios](#common-scenarios)
42
46
  - [Using BotFramework-WebChat](#using-botframework-webchat)
47
+ - [Escalation to Voice & Video](#escalation-to-voice--video)
43
48
  - [Pre-Chat Survey](#pre-chat-survey)
44
49
  - [Post-Chat Survey](#post-chat-survey)
45
50
  - [Reconnect to existing Chat](#reconnect-to-existing-chat)
@@ -48,6 +53,7 @@ Please make sure you have a chat widget configured before using this package or
48
53
  - [Chat Reconnect with Authenticated User](#chat-reconnect-with-authenticated-user)
49
54
  - [Chat Reconnect with Unauthenticated User](#chat-reconnect-with-unauthenticated-user)
50
55
  - [Operating Hours](#operating-hours)
56
+ - [Single Sign-on for Bots](/docs/scenarios/SINGLE_SIGN_ON_FOR_BOTS.md)
51
57
  - [Sample Apps](https://github.com/microsoft/omnichannel-chat-sdk-samples)
52
58
  - [Feature Comparisons](#feature-comparisons)
53
59
  - [Telemetry](#telemetry)
@@ -163,7 +169,14 @@ const chatSDKConfig = { // Optional
163
169
  };
164
170
 
165
171
  const chatSDK = new OmnichannelChatSDK.OmnichannelChatSDK(omnichannelConfig, chatSDKConfig);
166
- await chatSDK.initialize();
172
+
173
+ const optionalParams = {
174
+ getLiveChatConfigOptionalParams: {
175
+ sendCacheHeaders: false // Whether to send Cache-Control HTTP header to GetChatConfig call
176
+ }
177
+ };
178
+
179
+ await chatSDK.initialize(optionalParams);
167
180
  ```
168
181
 
169
182
  ### Start Chat
@@ -180,7 +193,8 @@ const customContext = {
180
193
  const optionalParams = {
181
194
  preChatResponse: '', // PreChatSurvey response
182
195
  liveChatContext: {}, // EXISTING chat context data
183
- customContext // Custom Context
196
+ customContext, // Custom Context
197
+ sendDefaultInitContext: true // Send default init context ⚠️ Web only
184
198
  };
185
199
 
186
200
  await chatSDK.startChat(optionalParams);
@@ -10,10 +10,12 @@ import ChatTranscriptBody from "./core/ChatTranscriptBody";
10
10
  import FileMetadata from "@microsoft/omnichannel-amsclient/lib/FileMetadata";
11
11
  import FramedClient from "@microsoft/omnichannel-amsclient/lib/FramedClient";
12
12
  import FramedlessClient from "@microsoft/omnichannel-amsclient/lib/FramedlessClient";
13
+ import GetLiveChatConfigOptionalParams from "./core/GetLiveChatConfigOptionalParams";
13
14
  import IChatToken from "./external/IC3Adapter/IChatToken";
14
15
  import IFileInfo from "@microsoft/omnichannel-ic3core/lib/interfaces/IFileInfo";
15
16
  import IFileMetadata from "@microsoft/omnichannel-ic3core/lib/model/IFileMetadata";
16
17
  import IMessage from "@microsoft/omnichannel-ic3core/lib/model/IMessage";
18
+ import InitializeOptionalParams from "./core/InitializeOptionalParams";
17
19
  import IRawMessage from "@microsoft/omnichannel-ic3core/lib/model/IRawMessage";
18
20
  import IRawThread from "@microsoft/omnichannel-ic3core/lib/interfaces/IRawThread";
19
21
  import LiveChatContext from "./core/LiveChatContext";
@@ -58,7 +60,7 @@ declare class OmnichannelChatSDK {
58
60
  private refreshTokenTimer;
59
61
  constructor(omnichannelConfig: OmnichannelConfig, chatSDKConfig?: ChatSDKConfig);
60
62
  setDebug(flag: boolean): void;
61
- initialize(): Promise<ChatConfig>;
63
+ initialize(optionalParams?: InitializeOptionalParams): Promise<ChatConfig>;
62
64
  getChatReconnectContext(optionalParams?: ChatReconnectOptionalParams): Promise<ChatReconnectContext>;
63
65
  startChat(optionalParams?: StartChatOptionalParams): Promise<void>;
64
66
  endChat(): Promise<void>;
@@ -69,7 +71,7 @@ declare class OmnichannelChatSDK {
69
71
  * @param parse Whether to parse PreChatSurvey to JSON or not.
70
72
  */
71
73
  getPreChatSurvey(parse?: boolean): Promise<any>;
72
- getLiveChatConfig(cached?: boolean): Promise<ChatConfig>;
74
+ getLiveChatConfig(optionalParams?: GetLiveChatConfigOptionalParams): Promise<ChatConfig>;
73
75
  getChatToken(cached?: boolean): Promise<IChatToken>;
74
76
  getCallingToken(): Promise<string>;
75
77
  getMessages(): Promise<IMessage[] | OmnichannelMessage[] | undefined>;
@@ -169,9 +169,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
169
169
  (_f = this.acsAdapterLogger) === null || _f === void 0 ? void 0 : _f.setDebug(flag);
170
170
  (_g = this.callingSdkLogger) === null || _g === void 0 ? void 0 : _g.setDebug(flag);
171
171
  };
172
- OmnichannelChatSDK.prototype.initialize = function () {
172
+ OmnichannelChatSDK.prototype.initialize = function (optionalParams) {
173
+ if (optionalParams === void 0) { optionalParams = {}; }
173
174
  return __awaiter(this, void 0, void 0, function () {
174
- var _a, _b, _c, _d;
175
+ var _a, getLiveChatConfigOptionalParams, _b, _c, _d;
175
176
  return __generator(this, function (_e) {
176
177
  switch (_e.label) {
177
178
  case 0:
@@ -188,7 +189,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
188
189
  return [4 /*yield*/, ocsdk_1.SDKProvider.getSDK(this.omnichannelConfig, {}, this.ocSdkLogger)];
189
190
  case 2:
190
191
  _a.OCClient = _e.sent();
191
- return [4 /*yield*/, this.getChatConfig()];
192
+ getLiveChatConfigOptionalParams = optionalParams.getLiveChatConfigOptionalParams;
193
+ return [4 /*yield*/, this.getChatConfig(getLiveChatConfigOptionalParams || {})];
192
194
  case 3:
193
195
  _e.sent();
194
196
  if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 5];
@@ -196,6 +198,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
196
198
  _b = this;
197
199
  return [4 /*yield*/, omnichannel_amsclient_1.default({
198
200
  framedMode: platform_1.isBrowser(),
201
+ multiClient: true,
199
202
  debug: false,
200
203
  logger: undefined
201
204
  })];
@@ -309,10 +312,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
309
312
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
310
313
  if (optionalParams === void 0) { optionalParams = {}; }
311
314
  return __awaiter(this, void 0, void 0, function () {
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;
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;
313
316
  var _this = this;
314
- return __generator(this, function (_x) {
315
- switch (_x.label) {
317
+ return __generator(this, function (_y) {
318
+ switch (_y.label) {
316
319
  case 0:
317
320
  this.scenarioMarker.startScenario(TelemetryEvent_1.default.StartChat, {
318
321
  RequestId: this.requestId
@@ -322,39 +325,39 @@ var OmnichannelChatSDK = /** @class */ (function () {
322
325
  _t = this;
323
326
  return [4 /*yield*/, this.getIC3Client()];
324
327
  case 1:
325
- _t.IC3Client = _x.sent();
326
- _x.label = 2;
328
+ _t.IC3Client = _y.sent();
329
+ _y.label = 2;
327
330
  case 2:
328
331
  if (this.isChatReconnect && !((_a = this.chatSDKConfig.chatReconnect) === null || _a === void 0 ? void 0 : _a.disable) && !this.isPersistentChat && optionalParams.reconnectId) {
329
332
  this.reconnectId = optionalParams.reconnectId;
330
333
  }
331
334
  if (!(this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable))) return [3 /*break*/, 6];
332
- _x.label = 3;
335
+ _y.label = 3;
333
336
  case 3:
334
- _x.trys.push([3, 5, , 6]);
337
+ _y.trys.push([3, 5, , 6]);
335
338
  reconnectableChatsParams = {
336
339
  authenticatedUserToken: this.authenticatedUserToken
337
340
  };
338
341
  return [4 /*yield*/, this.OCClient.getReconnectableChats(reconnectableChatsParams)];
339
342
  case 4:
340
- reconnectableChatsResponse = _x.sent();
343
+ reconnectableChatsResponse = _y.sent();
341
344
  if (reconnectableChatsResponse && reconnectableChatsResponse.reconnectid) {
342
345
  this.reconnectId = reconnectableChatsResponse.reconnectid;
343
346
  }
344
347
  return [3 /*break*/, 6];
345
348
  case 5:
346
- _u = _x.sent();
349
+ _u = _y.sent();
347
350
  exceptionDetails = {
348
351
  response: "OCClientGetReconnectableChatsFailed"
349
352
  };
350
353
  throw Error(exceptionDetails.response);
351
354
  case 6:
352
- if (!(optionalParams.liveChatContext && !this.reconnectId)) return [3 /*break*/, 8];
355
+ if (!(optionalParams.liveChatContext && Object.keys(optionalParams.liveChatContext).length > 0 && !this.reconnectId)) return [3 /*break*/, 8];
353
356
  this.chatToken = optionalParams.liveChatContext.chatToken || {};
354
357
  this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
355
358
  return [4 /*yield*/, this.getConversationDetails()];
356
359
  case 7:
357
- conversationDetails = _x.sent();
360
+ conversationDetails = _y.sent();
358
361
  if (Object.keys(conversationDetails).length === 0) {
359
362
  exceptionDetails = {
360
363
  response: "InvalidConversation"
@@ -379,14 +382,47 @@ var OmnichannelChatSDK = /** @class */ (function () {
379
382
  console.error("Unable to join conversation that's in '" + conversationDetails.state + "' state");
380
383
  throw Error(exceptionDetails.response);
381
384
  }
382
- _x.label = 8;
385
+ _y.label = 8;
383
386
  case 8:
384
- if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 10];
385
- return [4 /*yield*/, this.getChatToken(false)];
387
+ if (!this.authSettings) return [3 /*break*/, 14];
388
+ if (!!this.authenticatedUserToken) return [3 /*break*/, 10];
389
+ return [4 /*yield*/, this.setAuthTokenProvider(this.chatSDKConfig.getAuthToken)];
386
390
  case 9:
387
- _x.sent();
388
- _x.label = 10;
391
+ _y.sent();
392
+ _y.label = 10;
389
393
  case 10:
394
+ if (!(optionalParams.liveChatContext && Object.keys(optionalParams.liveChatContext).length > 0)) return [3 /*break*/, 14];
395
+ this.chatToken = optionalParams.liveChatContext.chatToken || {};
396
+ this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
397
+ _y.label = 11;
398
+ case 11:
399
+ _y.trys.push([11, 13, , 14]);
400
+ return [4 /*yield*/, this.OCClient.validateAuthChatRecord(this.requestId, {
401
+ authenticatedUserToken: this.authenticatedUserToken,
402
+ chatId: this.chatToken.chatId
403
+ })];
404
+ case 12:
405
+ _y.sent();
406
+ return [3 /*break*/, 14];
407
+ case 13:
408
+ _v = _y.sent();
409
+ exceptionDetails = {
410
+ response: "OCClientValidateAuthChatRecordFailed",
411
+ message: "InvalidAuthChatRecord"
412
+ };
413
+ this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
414
+ RequestId: this.requestId,
415
+ ChatId: this.chatToken.chatId,
416
+ ExceptionDetails: JSON.stringify(exceptionDetails)
417
+ });
418
+ throw Error(exceptionDetails.response);
419
+ case 14:
420
+ if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 16];
421
+ return [4 /*yield*/, this.getChatToken(false)];
422
+ case 15:
423
+ _y.sent();
424
+ _y.label = 16;
425
+ case 16:
390
426
  (_c = this.ic3ClientLogger) === null || _c === void 0 ? void 0 : _c.setChatId(this.chatToken.chatId || '');
391
427
  (_d = this.ocSdkLogger) === null || _d === void 0 ? void 0 : _d.setChatId(this.chatToken.chatId || '');
392
428
  (_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setChatId(this.chatToken.chatId || '');
@@ -420,6 +456,22 @@ var OmnichannelChatSDK = /** @class */ (function () {
420
456
  if (optionalParams.preChatResponse) {
421
457
  sessionInitOptionalParams.initContext.preChatResponse = optionalParams.preChatResponse;
422
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
+ }
423
475
  // Override initContext completely
424
476
  if (optionalParams.initContext) {
425
477
  sessionInitOptionalParams.initContext = optionalParams.initContext;
@@ -427,16 +479,20 @@ var OmnichannelChatSDK = /** @class */ (function () {
427
479
  if (this.authenticatedUserToken) {
428
480
  sessionInitOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
429
481
  }
430
- if (!!optionalParams.liveChatContext) return [3 /*break*/, 14];
431
- _x.label = 11;
432
- case 11:
433
- _x.trys.push([11, 13, , 14]);
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;
488
+ case 17:
489
+ _y.trys.push([17, 19, , 20]);
434
490
  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();
491
+ case 18:
492
+ _y.sent();
493
+ return [3 /*break*/, 20];
494
+ case 19:
495
+ error_3 = _y.sent();
440
496
  exceptionDetails = {
441
497
  response: "OCClientSessionInitFailed"
442
498
  };
@@ -452,27 +508,27 @@ var OmnichannelChatSDK = /** @class */ (function () {
452
508
  ExceptionDetails: JSON.stringify(exceptionDetails)
453
509
  });
454
510
  throw new Error(exceptionDetails.response);
455
- case 14:
456
- if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 25];
511
+ case 20:
512
+ if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 31];
457
513
  chatAdapterConfig = {
458
514
  token: this.chatToken.token,
459
515
  id: this.chatToken.visitorId || 'teamsvisitor',
460
516
  threadId: this.chatToken.chatId,
461
517
  environmentUrl: this.chatToken.acsEndpoint,
462
- pollingInterval: 1000
518
+ pollingInterval: 30000
463
519
  };
464
- _x.label = 15;
465
- case 15:
466
- _x.trys.push([15, 17, , 18]);
520
+ _y.label = 21;
521
+ case 21:
522
+ _y.trys.push([21, 23, , 24]);
467
523
  return [4 /*yield*/, ((_o = this.ACSClient) === null || _o === void 0 ? void 0 : _o.initialize({
468
524
  token: chatAdapterConfig.token,
469
525
  environmentUrl: chatAdapterConfig.environmentUrl
470
526
  }))];
471
- case 16:
472
- _x.sent();
473
- return [3 /*break*/, 18];
474
- case 17:
475
- error_4 = _x.sent();
527
+ case 22:
528
+ _y.sent();
529
+ return [3 /*break*/, 24];
530
+ case 23:
531
+ error_4 = _y.sent();
476
532
  exceptionDetails = {
477
533
  response: "ACSClientInitializeFailed"
478
534
  };
@@ -483,23 +539,23 @@ var OmnichannelChatSDK = /** @class */ (function () {
483
539
  });
484
540
  console.error("OmnichannelChatSDK/startChat/initialize/error " + error_4);
485
541
  return [2 /*return*/, error_4];
486
- case 18:
487
- _x.trys.push([18, 20, , 21]);
488
- _v = this;
542
+ case 24:
543
+ _y.trys.push([24, 26, , 27]);
544
+ _w = this;
489
545
  return [4 /*yield*/, ((_p = this.ACSClient) === null || _p === void 0 ? void 0 : _p.joinConversation({
490
546
  id: chatAdapterConfig.id,
491
547
  threadId: chatAdapterConfig.threadId,
492
548
  pollingInterval: chatAdapterConfig.pollingInterval
493
549
  }))];
494
- case 19:
495
- _v.conversation = (_x.sent());
550
+ case 25:
551
+ _w.conversation = (_y.sent());
496
552
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
497
553
  RequestId: this.requestId,
498
554
  ChatId: this.chatToken.chatId
499
555
  });
500
- return [3 /*break*/, 21];
501
- case 20:
502
- error_5 = _x.sent();
556
+ return [3 /*break*/, 27];
557
+ case 26:
558
+ error_5 = _y.sent();
503
559
  exceptionDetails = {
504
560
  response: "ACSClientJoinConversationFailed"
505
561
  };
@@ -510,16 +566,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
510
566
  });
511
567
  console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_5);
512
568
  throw Error(exceptionDetails.response);
513
- case 21:
514
- _x.trys.push([21, 23, , 24]);
569
+ case 27:
570
+ _y.trys.push([27, 29, , 30]);
515
571
  return [4 /*yield*/, ((_q = this.AMSClient) === null || _q === void 0 ? void 0 : _q.initialize({
516
572
  chatToken: this.chatToken
517
573
  }))];
518
- case 22:
519
- _x.sent();
520
- return [3 /*break*/, 24];
521
- case 23:
522
- error_6 = _x.sent();
574
+ case 28:
575
+ _y.sent();
576
+ return [3 /*break*/, 30];
577
+ case 29:
578
+ error_6 = _y.sent();
523
579
  exceptionDetails = {
524
580
  response: "AMSClientInitializeFailed"
525
581
  };
@@ -529,19 +585,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
529
585
  ExceptionDetails: JSON.stringify(exceptionDetails)
530
586
  });
531
587
  throw Error(exceptionDetails.response);
532
- case 24: return [3 /*break*/, 31];
533
- case 25:
534
- _x.trys.push([25, 27, , 28]);
588
+ case 30: return [3 /*break*/, 37];
589
+ case 31:
590
+ _y.trys.push([31, 33, , 34]);
535
591
  return [4 /*yield*/, this.IC3Client.initialize({
536
592
  token: this.chatToken.token,
537
593
  regionGtms: this.chatToken.regionGTMS,
538
594
  visitor: true
539
595
  })];
540
- case 26:
541
- _x.sent();
542
- return [3 /*break*/, 28];
543
- case 27:
544
- error_7 = _x.sent();
596
+ case 32:
597
+ _y.sent();
598
+ return [3 /*break*/, 34];
599
+ case 33:
600
+ error_7 = _y.sent();
545
601
  exceptionDetails = {
546
602
  response: "IC3ClientInitializeFailed"
547
603
  };
@@ -552,19 +608,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
552
608
  });
553
609
  console.error("OmnichannelChatSDK/startChat/initialize/error " + error_7);
554
610
  return [2 /*return*/, error_7];
555
- case 28:
556
- _x.trys.push([28, 30, , 31]);
557
- _w = this;
611
+ case 34:
612
+ _y.trys.push([34, 36, , 37]);
613
+ _x = this;
558
614
  return [4 /*yield*/, this.IC3Client.joinConversation(this.chatToken.chatId)];
559
- case 29:
560
- _w.conversation = _x.sent();
615
+ case 35:
616
+ _x.conversation = _y.sent();
561
617
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
562
618
  RequestId: this.requestId,
563
619
  ChatId: this.chatToken.chatId
564
620
  });
565
- return [3 /*break*/, 31];
566
- case 30:
567
- error_8 = _x.sent();
621
+ return [3 /*break*/, 37];
622
+ case 36:
623
+ error_8 = _y.sent();
568
624
  exceptionDetails = {
569
625
  response: "IC3ClientJoinConversationFailed"
570
626
  };
@@ -575,7 +631,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
575
631
  });
576
632
  console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_8);
577
633
  return [2 /*return*/, error_8];
578
- case 31:
634
+ case 37:
579
635
  if (this.isPersistentChat && !((_r = this.chatSDKConfig.persistentChat) === null || _r === void 0 ? void 0 : _r.disable)) {
580
636
  this.refreshTokenTimer = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
581
637
  return __generator(this, function (_a) {
@@ -782,14 +838,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
782
838
  });
783
839
  });
784
840
  };
785
- OmnichannelChatSDK.prototype.getLiveChatConfig = function (cached) {
786
- if (cached === void 0) { cached = true; }
841
+ OmnichannelChatSDK.prototype.getLiveChatConfig = function (optionalParams) {
787
842
  return __awaiter(this, void 0, void 0, function () {
788
843
  return __generator(this, function (_a) {
789
- if (cached) {
844
+ if (!optionalParams || optionalParams.useRuntimeCache === true) {
790
845
  return [2 /*return*/, this.liveChatConfig];
791
846
  }
792
- return [2 /*return*/, this.getChatConfig()];
847
+ return [2 /*return*/, this.getChatConfig({ sendCacheHeaders: (optionalParams === null || optionalParams === void 0 ? void 0 : optionalParams.sendCacheHeaders) || false })];
793
848
  });
794
849
  });
795
850
  };
@@ -1333,7 +1388,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
1333
1388
  case 2:
1334
1389
  uploadDocumentResponse = _e.sent();
1335
1390
  fileIdsProperty = {
1336
- amsReferences: JSON.stringify([documentId])
1391
+ amsReferences: JSON.stringify([documentId]),
1392
+ amsreferences: JSON.stringify([documentId])
1337
1393
  };
1338
1394
  fileMetaProperty = {
1339
1395
  amsMetadata: JSON.stringify([{
@@ -1589,17 +1645,17 @@ var OmnichannelChatSDK = /** @class */ (function () {
1589
1645
  ACSAdapter: acsAdapterCDNUrl
1590
1646
  });
1591
1647
  return [4 /*yield*/, WebUtils_1.loadScript(acsAdapterCDNUrl, function () {
1648
+ var _a;
1592
1649
  /* istanbul ignore next */
1593
1650
  _this.debug && console.debug('ACSAdapter loaded!');
1594
1651
  try {
1595
1652
  var ChatAdapter = window.ChatAdapter; // eslint-disable-line @typescript-eslint/no-explicit-any
1596
1653
  var fileManager = new AMSFileManager_1.default(_this.AMSClient, _this.acsAdapterLogger);
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
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
1599
1655
  featuresOption);
1600
1656
  resolve(adapter);
1601
1657
  }
1602
- catch (_a) {
1658
+ catch (_b) {
1603
1659
  throw new Error('Failed to load ACSAdapter');
1604
1660
  }
1605
1661
  }, function () {
@@ -1924,15 +1980,20 @@ var OmnichannelChatSDK = /** @class */ (function () {
1924
1980
  });
1925
1981
  });
1926
1982
  };
1927
- OmnichannelChatSDK.prototype.getChatConfig = function () {
1983
+ OmnichannelChatSDK.prototype.getChatConfig = function (optionalParams) {
1984
+ if (optionalParams === void 0) { optionalParams = {}; }
1928
1985
  return __awaiter(this, void 0, void 0, function () {
1929
- var liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, chatWidgetLanguage, msdyn_localeid, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled, error_18;
1986
+ var sendCacheHeaders, bypassCache, liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, chatWidgetLanguage, msdyn_localeid, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled, error_18;
1930
1987
  return __generator(this, function (_a) {
1931
1988
  switch (_a.label) {
1932
1989
  case 0:
1933
- _a.trys.push([0, 4, , 5]);
1934
- return [4 /*yield*/, this.OCClient.getChatConfig()];
1990
+ sendCacheHeaders = optionalParams.sendCacheHeaders;
1991
+ _a.label = 1;
1935
1992
  case 1:
1993
+ _a.trys.push([1, 5, , 6]);
1994
+ bypassCache = sendCacheHeaders === true;
1995
+ return [4 /*yield*/, this.OCClient.getChatConfig(this.requestId, bypassCache)];
1996
+ case 2:
1936
1997
  liveChatConfig = _a.sent();
1937
1998
  dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin, liveChatVersion = liveChatConfig.LiveChatVersion, chatWidgetLanguage = liveChatConfig.ChatWidgetLanguage;
1938
1999
  msdyn_localeid = chatWidgetLanguage.msdyn_localeid;
@@ -1959,12 +2020,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
1959
2020
  if (isPreChatEnabled && preChatSurvey && preChatSurvey.trim().length > 0) {
1960
2021
  this.preChatSurvey = preChatSurvey;
1961
2022
  }
1962
- if (!this.authSettings) return [3 /*break*/, 3];
2023
+ if (!this.authSettings) return [3 /*break*/, 4];
1963
2024
  return [4 /*yield*/, this.setAuthTokenProvider(this.chatSDKConfig.getAuthToken)];
1964
- case 2:
1965
- _a.sent();
1966
- _a.label = 3;
1967
2025
  case 3:
2026
+ _a.sent();
2027
+ _a.label = 4;
2028
+ case 4:
1968
2029
  if (this.preChatSurvey) {
1969
2030
  /* istanbul ignore next */
1970
2031
  this.debug && console.log('Prechat Survey!');
@@ -1972,11 +2033,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
1972
2033
  this.callingOption = msdyn_callingoptions;
1973
2034
  this.liveChatConfig = liveChatConfig;
1974
2035
  return [2 /*return*/, this.liveChatConfig];
1975
- case 4:
2036
+ case 5:
1976
2037
  error_18 = _a.sent();
1977
2038
  console.error("OmnichannelChatSDK/getChatConfig/error " + error_18);
1978
2039
  return [2 /*return*/, error_18];
1979
- case 5: return [2 /*return*/];
2040
+ case 6: return [2 /*return*/];
1980
2041
  }
1981
2042
  });
1982
2043
  });
@@ -2027,21 +2088,24 @@ var OmnichannelChatSDK = /** @class */ (function () {
2027
2088
  });
2028
2089
  _a.label = 1;
2029
2090
  case 1:
2030
- _a.trys.push([1, 3, , 4]);
2091
+ _a.trys.push([1, 4, , 5]);
2031
2092
  sessionInfo = {
2032
2093
  token: newToken,
2033
2094
  regionGtms: newRegionGTMS,
2034
2095
  visitor: true
2035
2096
  };
2097
+ if (!(this.liveChatVersion === LiveChatVersion_1.default.V1)) return [3 /*break*/, 3];
2036
2098
  return [4 /*yield*/, this.IC3Client.initialize(sessionInfo)];
2037
2099
  case 2:
2038
2100
  _a.sent();
2101
+ _a.label = 3;
2102
+ case 3:
2039
2103
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.UpdateChatToken, {
2040
2104
  RequestId: this.requestId,
2041
2105
  ChatId: this.chatToken.chatId
2042
2106
  });
2043
- return [3 /*break*/, 4];
2044
- case 3:
2107
+ return [3 /*break*/, 5];
2108
+ case 4:
2045
2109
  error_19 = _a.sent();
2046
2110
  exceptionDetails = {
2047
2111
  response: "UpdateChatTokenFailed"
@@ -2052,8 +2116,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
2052
2116
  ExceptionDetails: JSON.stringify(exceptionDetails)
2053
2117
  });
2054
2118
  console.error("OmnichannelChatSDK/updateChatToken/error " + error_19);
2055
- return [3 /*break*/, 4];
2056
- case 4: return [2 /*return*/];
2119
+ return [3 /*break*/, 5];
2120
+ case 5: return [2 /*return*/];
2057
2121
  }
2058
2122
  });
2059
2123
  });