@microsoft/omnichannel-chat-sdk 1.10.2 → 1.10.3-main.fdb5a09

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/README.md CHANGED
@@ -263,10 +263,13 @@ await chatSDK.endChat();
263
263
  It gets the Pre-Chat Survey from Live Chat Config. Pre-Chat Survey is in Adaptive Card format.
264
264
 
265
265
  `Option 1`
266
+
266
267
  ```ts
267
268
  const preChatSurvey = await getPreChatSurvey(); // Adaptive Cards JSON payload data
268
269
  ```
270
+
269
271
  `Option 2`
272
+
270
273
  ```ts
271
274
  const parseToJSON = false;
272
275
  const preChatSurvey = await getPreChatSurvey(parseToJSON); // Adaptive Cards payload data as string
@@ -291,9 +294,22 @@ const liveChatContext = await chatSDK.getCurrentLiveChatContext();
291
294
  ### Get Data Masking Rules
292
295
 
293
296
  It gets the active data masking rules from Live Chat Config.
297
+ Returned type is defined as :
298
+
299
+ ```ts
300
+
301
+ type MaskingRule = {
302
+ id: string;
303
+ regex: string;
304
+ }
305
+
306
+ type MaskingRules = {
307
+ rules: MaskingRule[];
308
+ }
309
+ ```
294
310
 
295
311
  ```ts
296
- const dataMaskingRules = await chatSDK.getDataMaskingRules();
312
+ const dataMaskingRules : MaskingRules = await chatSDK.getDataMaskingRules();
297
313
  ```
298
314
 
299
315
  ### Get Chat Reconnect Context
@@ -1,4 +1,6 @@
1
1
  import ACSClient from "./core/messaging/ACSClient";
2
+ import { VoiceVideoCallingOptionalParams } from "./types/config";
3
+ import { ChatAdapter, GetAgentAvailabilityResponse, GetCurrentLiveChatContextResponse, GetLiveChatTranscriptResponse, GetMessagesResponse, GetPreChatSurveyResponse, GetVoiceVideoCallingResponse, MaskingRules, UploadFileAttachmentResponse } from "./types/response";
2
4
  import { ParticipantsRemovedEvent } from '@azure/communication-signaling';
3
5
  import ChatAdapterOptionalParams from "./core/messaging/ChatAdapterOptionalParams";
4
6
  import ChatConfig from "./core/ChatConfig";
@@ -20,15 +22,12 @@ import GetLiveChatTranscriptOptionalParams from "./core/GetLiveChatTranscriptOpt
20
22
  import IChatToken from "./external/IC3Adapter/IChatToken";
21
23
  import IFileInfo from "@microsoft/omnichannel-ic3core/lib/interfaces/IFileInfo";
22
24
  import IFileMetadata from "@microsoft/omnichannel-ic3core/lib/model/IFileMetadata";
23
- import IMessage from "@microsoft/omnichannel-ic3core/lib/model/IMessage";
24
- import IRawMessage from "@microsoft/omnichannel-ic3core/lib/model/IRawMessage";
25
25
  import IRawThread from "@microsoft/omnichannel-ic3core/lib/interfaces/IRawThread";
26
26
  import InitializeOptionalParams from "./core/InitializeOptionalParams";
27
- import LiveChatContext from "./core/LiveChatContext";
28
27
  import LiveWorkItemDetails from "./core/LiveWorkItemDetails";
29
28
  import OmnichannelConfig from "./core/OmnichannelConfig";
30
- import OmnichannelMessage from "./core/messaging/OmnichannelMessage";
31
29
  import OnNewMessageOptionalParams from "./core/messaging/OnNewMessageOptionalParams";
30
+ import PostChatContext from "./core/PostChatContext";
32
31
  import StartChatOptionalParams from "./core/StartChatOptionalParams";
33
32
  declare class OmnichannelChatSDK {
34
33
  private debug;
@@ -70,6 +69,8 @@ declare class OmnichannelChatSDK {
70
69
  private reconnectId;
71
70
  private refreshTokenTimer;
72
71
  private AMSClientLoadCurrentState;
72
+ private isMaskingDisabled;
73
+ private maskingCharacter;
73
74
  constructor(omnichannelConfig: OmnichannelConfig, chatSDKConfig?: ChatSDKConfig);
74
75
  setDebug(flag: boolean): void;
75
76
  private retryLoadAMSClient;
@@ -92,35 +93,44 @@ declare class OmnichannelChatSDK {
92
93
  startChat(optionalParams?: StartChatOptionalParams): Promise<void>;
93
94
  private closeChat;
94
95
  endChat(endChatOptionalParams?: EndChatOptionalParams): Promise<void>;
95
- getCurrentLiveChatContext(): Promise<LiveChatContext | {}>;
96
+ getCurrentLiveChatContext(): Promise<GetCurrentLiveChatContextResponse>;
96
97
  getConversationDetails(optionalParams?: GetConversationDetailsOptionalParams): Promise<LiveWorkItemDetails>;
97
98
  /**
98
99
  * Gets PreChat Survey.
99
100
  * @param parse Whether to parse PreChatSurvey to JSON or not.
100
101
  */
101
- getPreChatSurvey(parse?: boolean): Promise<any>;
102
+ getPreChatSurvey(parse?: boolean): Promise<GetPreChatSurveyResponse>;
102
103
  getLiveChatConfig(optionalParams?: GetLiveChatConfigOptionalParams): Promise<ChatConfig>;
103
104
  getChatToken(cached?: boolean, optionalParams?: GetChatTokenOptionalParams): Promise<IChatToken>;
104
105
  getCallingToken(): Promise<string>;
105
- getMessages(): Promise<IMessage[] | OmnichannelMessage[] | undefined>;
106
- getDataMaskingRules(): Promise<any>;
106
+ getMessages(): Promise<GetMessagesResponse>;
107
+ getDataMaskingRules(): Promise<MaskingRules>;
108
+ private transformMessage;
107
109
  sendMessage(message: ChatSDKMessage): Promise<void>;
108
110
  onNewMessage(onNewMessageCallback: CallableFunction, optionalParams?: OnNewMessageOptionalParams | unknown): Promise<void>;
109
111
  sendTypingEvent(): Promise<void>;
110
112
  onTypingEvent(onTypingEventCallback: CallableFunction): Promise<void>;
111
113
  onAgentEndSession(onAgentEndSessionCallback: (message: IRawThread | ParticipantsRemovedEvent) => void): Promise<void>;
112
- uploadFileAttachment(fileInfo: IFileInfo | File): Promise<IRawMessage | OmnichannelMessage>;
114
+ uploadFileAttachment(fileInfo: IFileInfo | File): Promise<UploadFileAttachmentResponse>;
113
115
  downloadFileAttachment(fileMetadata: FileMetadata | IFileMetadata): Promise<Blob>;
114
- emailLiveChatTranscript(body: ChatTranscriptBody, optionalParams?: EmailLiveChatTranscriptOptionaParams): Promise<any>;
115
- getLiveChatTranscript(optionalParams?: GetLiveChatTranscriptOptionalParams): Promise<any>;
116
- createChatAdapter(optionalParams?: ChatAdapterOptionalParams): Promise<unknown>;
116
+ emailLiveChatTranscript(body: ChatTranscriptBody, optionalParams?: EmailLiveChatTranscriptOptionaParams): Promise<void>;
117
+ getLiveChatTranscript(optionalParams?: GetLiveChatTranscriptOptionalParams): Promise<GetLiveChatTranscriptResponse>;
118
+ createChatAdapter(optionalParams?: ChatAdapterOptionalParams): Promise<ChatAdapter>;
117
119
  isVoiceVideoCallingEnabled(): boolean;
118
- getVoiceVideoCalling(params?: any): Promise<any>;
119
- getPostChatSurveyContext(): Promise<any>;
120
- getAgentAvailability(optionalParams?: GetAgentAvailabilityOptionalParams): Promise<any>;
120
+ getVoiceVideoCalling(voiceVideoCallingOptionalParams?: VoiceVideoCallingOptionalParams): Promise<GetVoiceVideoCallingResponse>;
121
+ getPostChatSurveyContext(): Promise<PostChatContext>;
122
+ getAgentAvailability(optionalParams?: GetAgentAvailabilityOptionalParams): Promise<GetAgentAvailabilityResponse>;
121
123
  private populateInitChatOptionalParam;
122
124
  private getIC3Client;
125
+ private setPrechatConfigurations;
126
+ private setDataMaskingConfiguration;
127
+ private setAuthSettingConfig;
128
+ private setPersistentChatConfiguration;
129
+ private setLocaleIdConfiguration;
130
+ private setCallingOptionConfiguration;
131
+ private setLiveChatVersionConfiguration;
123
132
  private getChatConfig;
133
+ private buildConfigurations;
124
134
  private resolveIC3ClientUrl;
125
135
  private resolveChatAdapterUrl;
126
136
  private updateChatToken;
@@ -115,6 +115,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
115
115
  this.unqServicesOrgUrl = null;
116
116
  this.coreServicesOrgUrl = null;
117
117
  this.dynamicsLocationCode = null;
118
+ this.dataMaskingRules = { rules: [] };
118
119
  this.authSettings = null;
119
120
  this.authenticatedUserToken = null;
120
121
  this.conversation = null;
@@ -131,6 +132,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
131
132
  this.reconnectId = null;
132
133
  this.refreshTokenTimer = null;
133
134
  this.AMSClientLoadCurrentState = AMSClientLoadStates_1.AMSClientLoadStates.NOT_LOADED;
135
+ this.isMaskingDisabled = false;
136
+ this.maskingCharacter = "#";
134
137
  this.populateInitChatOptionalParam = function (requestOptionalParams, optionalParams, telemetryEvent) {
135
138
  requestOptionalParams.initContext.locale = (0, locale_1.getLocaleStringFromId)(_this.localeId);
136
139
  if (optionalParams === null || optionalParams === void 0 ? void 0 : optionalParams.customContext) {
@@ -198,7 +201,6 @@ var OmnichannelChatSDK = /** @class */ (function () {
198
201
  this.requestId = (0, ocsdk_1.uuidv4)();
199
202
  this.chatToken = {};
200
203
  this.liveChatConfig = {};
201
- this.dataMaskingRules = {};
202
204
  this.authSettings = null;
203
205
  this.preChatSurvey = null;
204
206
  this.telemetry = (0, createTelemetry_1.default)(this.debug);
@@ -226,6 +228,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
226
228
  if ((_g = this.chatSDKConfig.telemetry) === null || _g === void 0 ? void 0 : _g.ariaTelemetryKey) {
227
229
  this.telemetry.initialize(this.chatSDKConfig.telemetry.ariaTelemetryKey);
228
230
  }
231
+ if (this.chatSDKConfig.dataMasking) {
232
+ this.isMaskingDisabled = this.chatSDKConfig.dataMasking.disable;
233
+ this.maskingCharacter = this.chatSDKConfig.dataMasking.maskingCharacter;
234
+ }
229
235
  loggerUtils_1.default.setRequestId(this.requestId, this.ocSdkLogger, this.acsClientLogger, this.acsAdapterLogger, this.callingSdkLogger, this.amsClientLogger, this.ic3ClientLogger);
230
236
  }
231
237
  /* istanbul ignore next */
@@ -1368,31 +1374,36 @@ var OmnichannelChatSDK = /** @class */ (function () {
1368
1374
  });
1369
1375
  });
1370
1376
  };
1377
+ OmnichannelChatSDK.prototype.transformMessage = function (message) {
1378
+ if (this.isMaskingDisabled) {
1379
+ return message;
1380
+ }
1381
+ var content = message.content;
1382
+ var match;
1383
+ for (var _i = 0, _a = this.dataMaskingRules.rules; _i < _a.length; _i++) {
1384
+ var maskingRule = _a[_i];
1385
+ var regex = new RegExp(maskingRule.regex, 'g');
1386
+ while ((match = regex.exec(content)) !== null) {
1387
+ var replaceStr = match[0].replace(/./g, this.maskingCharacter);
1388
+ content = content.replace(match[0], replaceStr);
1389
+ }
1390
+ match = null;
1391
+ }
1392
+ message.content = content;
1393
+ return message;
1394
+ };
1371
1395
  OmnichannelChatSDK.prototype.sendMessage = function (message) {
1372
1396
  return __awaiter(this, void 0, void 0, function () {
1373
- var _a, disable, maskingCharacter, content, _i, _b, maskingRule, regex, match, replaceStr, sendMessageRequest, error_14, messageToSend, _c;
1374
- var _d;
1375
- return __generator(this, function (_e) {
1376
- switch (_e.label) {
1397
+ var sendMessageRequest, error_14, messageToSend, _a;
1398
+ var _b;
1399
+ return __generator(this, function (_c) {
1400
+ switch (_c.label) {
1377
1401
  case 0:
1378
1402
  this.scenarioMarker.startScenario(TelemetryEvent_1.default.SendMessages, {
1379
1403
  RequestId: this.requestId,
1380
1404
  ChatId: this.chatToken.chatId
1381
1405
  });
1382
- _a = this.chatSDKConfig.dataMasking, disable = _a.disable, maskingCharacter = _a.maskingCharacter;
1383
- content = message.content;
1384
- if (Object.keys(this.dataMaskingRules).length > 0 && !disable) {
1385
- for (_i = 0, _b = Object.values(this.dataMaskingRules); _i < _b.length; _i++) {
1386
- maskingRule = _b[_i];
1387
- regex = new RegExp(maskingRule, 'g');
1388
- match = void 0;
1389
- while (match = regex.exec(content)) { // eslint-disable-line no-cond-assign
1390
- replaceStr = match[0].replace(/./g, maskingCharacter);
1391
- content = content.replace(match[0], replaceStr);
1392
- }
1393
- }
1394
- }
1395
- message.content = content;
1406
+ this.transformMessage(message);
1396
1407
  if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 5];
1397
1408
  sendMessageRequest = {
1398
1409
  content: message.content,
@@ -1404,19 +1415,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
1404
1415
  if (message.metadata) {
1405
1416
  sendMessageRequest.metadata = __assign(__assign({}, sendMessageRequest.metadata), message.metadata);
1406
1417
  }
1407
- _e.label = 1;
1418
+ _c.label = 1;
1408
1419
  case 1:
1409
- _e.trys.push([1, 3, , 4]);
1410
- return [4 /*yield*/, ((_d = this.conversation) === null || _d === void 0 ? void 0 : _d.sendMessage(sendMessageRequest))];
1420
+ _c.trys.push([1, 3, , 4]);
1421
+ return [4 /*yield*/, ((_b = this.conversation) === null || _b === void 0 ? void 0 : _b.sendMessage(sendMessageRequest))];
1411
1422
  case 2:
1412
- _e.sent();
1423
+ _c.sent();
1413
1424
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.SendMessages, {
1414
1425
  RequestId: this.requestId,
1415
1426
  ChatId: this.chatToken.chatId
1416
1427
  });
1417
1428
  return [3 /*break*/, 4];
1418
1429
  case 3:
1419
- error_14 = _e.sent();
1430
+ error_14 = _c.sent();
1420
1431
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.SendMessages, {
1421
1432
  RequestId: this.requestId,
1422
1433
  ChatId: this.chatToken.chatId
@@ -1444,19 +1455,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
1444
1455
  if (message.timestamp) {
1445
1456
  messageToSend.timestamp = message.timestamp;
1446
1457
  }
1447
- _e.label = 6;
1458
+ _c.label = 6;
1448
1459
  case 6:
1449
- _e.trys.push([6, 8, , 9]);
1460
+ _c.trys.push([6, 8, , 9]);
1450
1461
  return [4 /*yield*/, this.conversation.sendMessage(messageToSend)];
1451
1462
  case 7:
1452
- _e.sent();
1463
+ _c.sent();
1453
1464
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.SendMessages, {
1454
1465
  RequestId: this.requestId,
1455
1466
  ChatId: this.chatToken.chatId
1456
1467
  });
1457
1468
  return [3 /*break*/, 9];
1458
1469
  case 8:
1459
- _c = _e.sent();
1470
+ _a = _c.sent();
1460
1471
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.SendMessages, {
1461
1472
  RequestId: this.requestId,
1462
1473
  ChatId: this.chatToken.chatId
@@ -1935,7 +1946,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1935
1946
  };
1936
1947
  OmnichannelChatSDK.prototype.emailLiveChatTranscript = function (body_1) {
1937
1948
  return __awaiter(this, arguments, void 0, function (body, optionalParams) {
1938
- var emailTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, emailRequestBody, emailResponse, error_20;
1949
+ var emailTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, emailRequestBody, error_20;
1939
1950
  var _a;
1940
1951
  if (optionalParams === void 0) { optionalParams = {}; }
1941
1952
  return __generator(this, function (_b) {
@@ -1973,7 +1984,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1973
1984
  };
1974
1985
  return [4 /*yield*/, this.OCClient.emailTranscript(requestId, chatToken.token, emailRequestBody, emailTranscriptOptionalParams)];
1975
1986
  case 2:
1976
- emailResponse = _b.sent();
1987
+ _b.sent();
1977
1988
  if (this.sessionId) {
1978
1989
  this.OCClient.sessionId = this.sessionId;
1979
1990
  }
@@ -1981,7 +1992,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1981
1992
  RequestId: requestId,
1982
1993
  ChatId: chatId
1983
1994
  });
1984
- return [2 /*return*/, emailResponse];
1995
+ return [3 /*break*/, 4];
1985
1996
  case 3:
1986
1997
  error_20 = _b.sent();
1987
1998
  console.error("OmnichannelChatSDK/emailLiveChatTranscript/error: ".concat(error_20));
@@ -2086,10 +2097,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
2086
2097
  return this.callingOption.toString() !== CallingOptionsOptionSetNumber_1.default.NoCalling.toString();
2087
2098
  };
2088
2099
  OmnichannelChatSDK.prototype.getVoiceVideoCalling = function () {
2089
- return __awaiter(this, arguments, void 0, function (params) {
2100
+ return __awaiter(this, arguments, void 0, function (voiceVideoCallingOptionalParams) {
2090
2101
  var message, message, chatConfig, liveWSAndLiveChatEngJoin, msdyn_widgetsnippet, widgetSnippetSourceRegex, result;
2091
2102
  var _this = this;
2092
- if (params === void 0) { params = {}; }
2103
+ if (voiceVideoCallingOptionalParams === void 0) { voiceVideoCallingOptionalParams = {}; }
2093
2104
  return __generator(this, function (_a) {
2094
2105
  switch (_a.label) {
2095
2106
  case 0:
@@ -2130,7 +2141,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2130
2141
  switch (_a.label) {
2131
2142
  case 0:
2132
2143
  this.debug && console.debug("".concat(LiveChatWidgetLibCDNUrl, " loaded!"));
2133
- return [4 /*yield*/, (0, createVoiceVideoCalling_1.default)(__assign(__assign({}, params), defaultParams))];
2144
+ return [4 /*yield*/, (0, createVoiceVideoCalling_1.default)(__assign(__assign({}, voiceVideoCallingOptionalParams), defaultParams))];
2134
2145
  case 1:
2135
2146
  VoiceVideoCalling = _a.sent();
2136
2147
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetVoiceVideoCalling);
@@ -2435,9 +2446,102 @@ var OmnichannelChatSDK = /** @class */ (function () {
2435
2446
  });
2436
2447
  });
2437
2448
  };
2449
+ OmnichannelChatSDK.prototype.setPrechatConfigurations = function (liveWSAndLiveChatEngJoin) {
2450
+ return __awaiter(this, void 0, void 0, function () {
2451
+ var isPreChatEnabled;
2452
+ return __generator(this, function (_a) {
2453
+ isPreChatEnabled = (0, parsers_1.parseLowerCaseString)(liveWSAndLiveChatEngJoin.msdyn_prechatenabled) === "true";
2454
+ if (isPreChatEnabled && liveWSAndLiveChatEngJoin.PreChatSurvey && liveWSAndLiveChatEngJoin.PreChatSurvey.trim().length > 0) {
2455
+ this.preChatSurvey = liveWSAndLiveChatEngJoin.PreChatSurvey;
2456
+ /* istanbul ignore next */
2457
+ this.debug && console.log('Prechat Survey!');
2458
+ }
2459
+ return [2 /*return*/];
2460
+ });
2461
+ });
2462
+ };
2463
+ OmnichannelChatSDK.prototype.setDataMaskingConfiguration = function (dataMaskingConfig) {
2464
+ return __awaiter(this, void 0, void 0, function () {
2465
+ var _i, _a, _b, key, value;
2466
+ return __generator(this, function (_c) {
2467
+ if (dataMaskingConfig.setting.msdyn_maskforcustomer) {
2468
+ if (dataMaskingConfig.dataMaskingRules) {
2469
+ for (_i = 0, _a = Object.entries(dataMaskingConfig.dataMaskingRules); _i < _a.length; _i++) {
2470
+ _b = _a[_i], key = _b[0], value = _b[1];
2471
+ this.dataMaskingRules.rules.push({
2472
+ id: key,
2473
+ regex: value
2474
+ });
2475
+ }
2476
+ }
2477
+ }
2478
+ return [2 /*return*/];
2479
+ });
2480
+ });
2481
+ };
2482
+ OmnichannelChatSDK.prototype.setAuthSettingConfig = function (authSettings) {
2483
+ return __awaiter(this, void 0, void 0, function () {
2484
+ return __generator(this, function (_a) {
2485
+ switch (_a.label) {
2486
+ case 0:
2487
+ if (authSettings) {
2488
+ this.authSettings = authSettings;
2489
+ }
2490
+ if (!(this.authSettings && this.chatSDKConfig.getAuthToken)) return [3 /*break*/, 2];
2491
+ return [4 /*yield*/, this.setAuthTokenProvider(this.chatSDKConfig.getAuthToken, { throwError: false })];
2492
+ case 1:
2493
+ _a.sent(); // throwError set to 'false` for backward compatibility
2494
+ _a.label = 2;
2495
+ case 2: return [2 /*return*/];
2496
+ }
2497
+ });
2498
+ });
2499
+ };
2500
+ OmnichannelChatSDK.prototype.setPersistentChatConfiguration = function (liveWSAndLiveChatEngJoin) {
2501
+ return __awaiter(this, void 0, void 0, function () {
2502
+ var isChatReconnectEnabled;
2503
+ var _a;
2504
+ return __generator(this, function (_b) {
2505
+ isChatReconnectEnabled = (0, parsers_1.parseLowerCaseString)(liveWSAndLiveChatEngJoin.msdyn_enablechatreconnect) === "true";
2506
+ if (((_a = liveWSAndLiveChatEngJoin.msdyn_conversationmode) === null || _a === void 0 ? void 0 : _a.toString()) === ConversationMode_1.default.PersistentChat.toString()) {
2507
+ this.isPersistentChat = true;
2508
+ }
2509
+ if (isChatReconnectEnabled && !this.isPersistentChat) {
2510
+ this.isChatReconnect = true;
2511
+ }
2512
+ return [2 /*return*/];
2513
+ });
2514
+ });
2515
+ };
2516
+ OmnichannelChatSDK.prototype.setLocaleIdConfiguration = function (chatWidgetLanguage) {
2517
+ return __awaiter(this, void 0, void 0, function () {
2518
+ return __generator(this, function (_a) {
2519
+ this.localeId = chatWidgetLanguage.msdyn_localeid || locale_1.defaultLocaleId;
2520
+ return [2 /*return*/];
2521
+ });
2522
+ });
2523
+ };
2524
+ OmnichannelChatSDK.prototype.setCallingOptionConfiguration = function (liveWSAndLiveChatEngJoin) {
2525
+ return __awaiter(this, void 0, void 0, function () {
2526
+ var msdyn_callingoptions;
2527
+ return __generator(this, function (_a) {
2528
+ msdyn_callingoptions = liveWSAndLiveChatEngJoin.msdyn_callingoptions;
2529
+ this.callingOption = (msdyn_callingoptions === null || msdyn_callingoptions === void 0 ? void 0 : msdyn_callingoptions.trim().length) > 0 ? Number(msdyn_callingoptions) : CallingOptionsOptionSetNumber_1.default.NoCalling;
2530
+ return [2 /*return*/];
2531
+ });
2532
+ });
2533
+ };
2534
+ OmnichannelChatSDK.prototype.setLiveChatVersionConfiguration = function (liveChatVersion) {
2535
+ return __awaiter(this, void 0, void 0, function () {
2536
+ return __generator(this, function (_a) {
2537
+ this.liveChatVersion = liveChatVersion || LiveChatVersion_1.default.V2;
2538
+ return [2 /*return*/];
2539
+ });
2540
+ });
2541
+ };
2438
2542
  OmnichannelChatSDK.prototype.getChatConfig = function () {
2439
2543
  return __awaiter(this, arguments, void 0, function (optionalParams) {
2440
- var sendCacheHeaders, bypassCache, liveChatConfig, error_22, _a, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, chatWidgetLanguage, msdyn_localeid, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled;
2544
+ var sendCacheHeaders, bypassCache, liveChatConfig, error_22, _a;
2441
2545
  var _b, _c;
2442
2546
  if (optionalParams === void 0) { optionalParams = {}; }
2443
2547
  return __generator(this, function (_d) {
@@ -2451,7 +2555,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
2451
2555
  return [4 /*yield*/, this.OCClient.getChatConfig(this.requestId, bypassCache)];
2452
2556
  case 2:
2453
2557
  liveChatConfig = _d.sent();
2454
- return [3 /*break*/, 8];
2558
+ this.liveChatConfig = liveChatConfig;
2559
+ this.buildConfigurations(liveChatConfig);
2560
+ /* istanbul ignore next */
2561
+ this.debug && console.log("[OmnichannelChatSDK][getChatConfig][liveChatVersion] ".concat(this.liveChatVersion));
2562
+ return [2 /*return*/, this.liveChatConfig];
2455
2563
  case 3:
2456
2564
  error_22 = _d.sent();
2457
2565
  if (!(0, internalUtils_1.isCoreServicesOrgUrlDNSError)(error_22, this.coreServicesOrgUrl, this.dynamicsLocationCode)) return [3 /*break*/, 6];
@@ -2471,49 +2579,30 @@ var OmnichannelChatSDK = /** @class */ (function () {
2471
2579
  }
2472
2580
  throw error_22; // Bubble up error by default to throw ChatConfigRetrievalFailure
2473
2581
  case 7: return [3 /*break*/, 8];
2474
- case 8:
2475
- dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin, liveChatVersion = liveChatConfig.LiveChatVersion, chatWidgetLanguage = liveChatConfig.ChatWidgetLanguage;
2476
- msdyn_localeid = chatWidgetLanguage.msdyn_localeid;
2477
- this.localeId = msdyn_localeid || locale_1.defaultLocaleId;
2478
- this.liveChatVersion = liveChatVersion || LiveChatVersion_1.default.V2;
2479
- /* istanbul ignore next */
2480
- this.debug && console.log("[OmnichannelChatSDK][getChatConfig][liveChatVersion] ".concat(this.liveChatVersion));
2481
- setting = dataMaskingConfig.setting;
2482
- if (setting.msdyn_maskforcustomer) {
2483
- this.dataMaskingRules = dataMaskingConfig.dataMaskingRules;
2484
- }
2485
- if (authSettings) {
2486
- this.authSettings = authSettings;
2487
- }
2488
- preChatSurvey = liveWSAndLiveChatEngJoin.PreChatSurvey, msdyn_prechatenabled = liveWSAndLiveChatEngJoin.msdyn_prechatenabled, msdyn_callingoptions = liveWSAndLiveChatEngJoin.msdyn_callingoptions, msdyn_conversationmode = liveWSAndLiveChatEngJoin.msdyn_conversationmode, msdyn_enablechatreconnect = liveWSAndLiveChatEngJoin.msdyn_enablechatreconnect;
2489
- isPreChatEnabled = (0, parsers_1.parseLowerCaseString)(msdyn_prechatenabled) === "true";
2490
- isChatReconnectEnabled = (0, parsers_1.parseLowerCaseString)(msdyn_enablechatreconnect) === "true";
2491
- if ((msdyn_conversationmode === null || msdyn_conversationmode === void 0 ? void 0 : msdyn_conversationmode.toString()) === ConversationMode_1.default.PersistentChat.toString()) {
2492
- this.isPersistentChat = true;
2493
- }
2494
- if (isChatReconnectEnabled && !this.isPersistentChat) {
2495
- this.isChatReconnect = true;
2496
- }
2497
- if (isPreChatEnabled && preChatSurvey && preChatSurvey.trim().length > 0) {
2498
- this.preChatSurvey = preChatSurvey;
2499
- }
2500
- if (!(this.authSettings && this.chatSDKConfig.getAuthToken)) return [3 /*break*/, 10];
2501
- return [4 /*yield*/, this.setAuthTokenProvider(this.chatSDKConfig.getAuthToken, { throwError: false })];
2502
- case 9:
2503
- _d.sent(); // throwError set to 'false` for backward compatibility
2504
- _d.label = 10;
2505
- case 10:
2506
- if (this.preChatSurvey) {
2507
- /* istanbul ignore next */
2508
- this.debug && console.log('Prechat Survey!');
2509
- }
2510
- this.callingOption = msdyn_callingoptions;
2511
- this.liveChatConfig = liveChatConfig;
2512
- return [2 /*return*/, this.liveChatConfig];
2582
+ case 8: return [2 /*return*/, this.liveChatConfig];
2513
2583
  }
2514
2584
  });
2515
2585
  });
2516
2586
  };
2587
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2588
+ OmnichannelChatSDK.prototype.buildConfigurations = function (liveChatConfig) {
2589
+ return __awaiter(this, void 0, void 0, function () {
2590
+ var dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, chatWidgetLanguage;
2591
+ return __generator(this, function (_a) {
2592
+ dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin, liveChatVersion = liveChatConfig.LiveChatVersion, chatWidgetLanguage = liveChatConfig.ChatWidgetLanguage;
2593
+ Promise.all([
2594
+ this.setDataMaskingConfiguration(dataMaskingConfig),
2595
+ this.setPrechatConfigurations(liveWSAndLiveChatEngJoin),
2596
+ this.setAuthSettingConfig(authSettings),
2597
+ this.setPersistentChatConfiguration(liveWSAndLiveChatEngJoin),
2598
+ this.setCallingOptionConfiguration(liveWSAndLiveChatEngJoin),
2599
+ this.setLocaleIdConfiguration(chatWidgetLanguage),
2600
+ this.setLiveChatVersionConfiguration(liveChatVersion)
2601
+ ]);
2602
+ return [2 /*return*/];
2603
+ });
2604
+ });
2605
+ };
2517
2606
  OmnichannelChatSDK.prototype.resolveIC3ClientUrl = function () {
2518
2607
  return urlResolvers_1.default.resolveIC3ClientUrl(this.chatSDKConfig);
2519
2608
  };