@microsoft/omnichannel-chat-sdk 1.1.0 → 1.1.1-main.063303c
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 +15 -1
- package/README.md +532 -382
- package/lib/OmnichannelChatSDK.d.ts +4 -2
- package/lib/OmnichannelChatSDK.js +155 -93
- package/lib/OmnichannelChatSDK.js.map +1 -1
- package/lib/config/settings.d.ts +1 -1
- package/lib/config/settings.js +1 -1
- package/lib/core/GetLiveChatConfigOptionalParams.d.ts +5 -0
- package/lib/core/GetLiveChatConfigOptionalParams.js +3 -0
- package/lib/core/GetLiveChatConfigOptionalParams.js.map +1 -0
- package/lib/core/InitializeOptionalParams.d.ts +5 -0
- package/lib/core/InitializeOptionalParams.js +3 -0
- package/lib/core/InitializeOptionalParams.js.map +1 -0
- package/lib/core/StartChatOptionalParams.d.ts +1 -0
- package/lib/core/messaging/ACSClient.d.ts +1 -0
- package/lib/core/messaging/ACSClient.js +3 -0
- package/lib/core/messaging/ACSClient.js.map +1 -1
- package/lib/external/ACSAdapter/AMSFileManager.js +12 -0
- package/lib/external/ACSAdapter/AMSFileManager.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +49 -17
- package/package.json +2 -2
@@ -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(
|
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
|
-
|
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];
|
@@ -309,10 +311,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
309
311
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
310
312
|
if (optionalParams === void 0) { optionalParams = {}; }
|
311
313
|
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,
|
314
|
+
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
315
|
var _this = this;
|
314
|
-
return __generator(this, function (
|
315
|
-
switch (
|
316
|
+
return __generator(this, function (_y) {
|
317
|
+
switch (_y.label) {
|
316
318
|
case 0:
|
317
319
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.StartChat, {
|
318
320
|
RequestId: this.requestId
|
@@ -322,39 +324,39 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
322
324
|
_t = this;
|
323
325
|
return [4 /*yield*/, this.getIC3Client()];
|
324
326
|
case 1:
|
325
|
-
_t.IC3Client =
|
326
|
-
|
327
|
+
_t.IC3Client = _y.sent();
|
328
|
+
_y.label = 2;
|
327
329
|
case 2:
|
328
330
|
if (this.isChatReconnect && !((_a = this.chatSDKConfig.chatReconnect) === null || _a === void 0 ? void 0 : _a.disable) && !this.isPersistentChat && optionalParams.reconnectId) {
|
329
331
|
this.reconnectId = optionalParams.reconnectId;
|
330
332
|
}
|
331
333
|
if (!(this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable))) return [3 /*break*/, 6];
|
332
|
-
|
334
|
+
_y.label = 3;
|
333
335
|
case 3:
|
334
|
-
|
336
|
+
_y.trys.push([3, 5, , 6]);
|
335
337
|
reconnectableChatsParams = {
|
336
338
|
authenticatedUserToken: this.authenticatedUserToken
|
337
339
|
};
|
338
340
|
return [4 /*yield*/, this.OCClient.getReconnectableChats(reconnectableChatsParams)];
|
339
341
|
case 4:
|
340
|
-
reconnectableChatsResponse =
|
342
|
+
reconnectableChatsResponse = _y.sent();
|
341
343
|
if (reconnectableChatsResponse && reconnectableChatsResponse.reconnectid) {
|
342
344
|
this.reconnectId = reconnectableChatsResponse.reconnectid;
|
343
345
|
}
|
344
346
|
return [3 /*break*/, 6];
|
345
347
|
case 5:
|
346
|
-
_u =
|
348
|
+
_u = _y.sent();
|
347
349
|
exceptionDetails = {
|
348
350
|
response: "OCClientGetReconnectableChatsFailed"
|
349
351
|
};
|
350
352
|
throw Error(exceptionDetails.response);
|
351
353
|
case 6:
|
352
|
-
if (!(optionalParams.liveChatContext && !this.reconnectId)) return [3 /*break*/, 8];
|
354
|
+
if (!(optionalParams.liveChatContext && Object.keys(optionalParams.liveChatContext).length > 0 && !this.reconnectId)) return [3 /*break*/, 8];
|
353
355
|
this.chatToken = optionalParams.liveChatContext.chatToken || {};
|
354
356
|
this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
|
355
357
|
return [4 /*yield*/, this.getConversationDetails()];
|
356
358
|
case 7:
|
357
|
-
conversationDetails =
|
359
|
+
conversationDetails = _y.sent();
|
358
360
|
if (Object.keys(conversationDetails).length === 0) {
|
359
361
|
exceptionDetails = {
|
360
362
|
response: "InvalidConversation"
|
@@ -379,14 +381,47 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
379
381
|
console.error("Unable to join conversation that's in '" + conversationDetails.state + "' state");
|
380
382
|
throw Error(exceptionDetails.response);
|
381
383
|
}
|
382
|
-
|
384
|
+
_y.label = 8;
|
383
385
|
case 8:
|
384
|
-
if (!
|
385
|
-
return [
|
386
|
+
if (!this.authSettings) return [3 /*break*/, 14];
|
387
|
+
if (!!this.authenticatedUserToken) return [3 /*break*/, 10];
|
388
|
+
return [4 /*yield*/, this.setAuthTokenProvider(this.chatSDKConfig.getAuthToken)];
|
386
389
|
case 9:
|
387
|
-
|
388
|
-
|
390
|
+
_y.sent();
|
391
|
+
_y.label = 10;
|
389
392
|
case 10:
|
393
|
+
if (!(optionalParams.liveChatContext && Object.keys(optionalParams.liveChatContext).length > 0)) return [3 /*break*/, 14];
|
394
|
+
this.chatToken = optionalParams.liveChatContext.chatToken || {};
|
395
|
+
this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
|
396
|
+
_y.label = 11;
|
397
|
+
case 11:
|
398
|
+
_y.trys.push([11, 13, , 14]);
|
399
|
+
return [4 /*yield*/, this.OCClient.validateAuthChatRecord(this.requestId, {
|
400
|
+
authenticatedUserToken: this.authenticatedUserToken,
|
401
|
+
chatId: this.chatToken.chatId
|
402
|
+
})];
|
403
|
+
case 12:
|
404
|
+
_y.sent();
|
405
|
+
return [3 /*break*/, 14];
|
406
|
+
case 13:
|
407
|
+
_v = _y.sent();
|
408
|
+
exceptionDetails = {
|
409
|
+
response: "OCClientValidateAuthChatRecordFailed",
|
410
|
+
message: "InvalidAuthChatRecord"
|
411
|
+
};
|
412
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
|
413
|
+
RequestId: this.requestId,
|
414
|
+
ChatId: this.chatToken.chatId,
|
415
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
416
|
+
});
|
417
|
+
throw Error(exceptionDetails.response);
|
418
|
+
case 14:
|
419
|
+
if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 16];
|
420
|
+
return [4 /*yield*/, this.getChatToken(false)];
|
421
|
+
case 15:
|
422
|
+
_y.sent();
|
423
|
+
_y.label = 16;
|
424
|
+
case 16:
|
390
425
|
(_c = this.ic3ClientLogger) === null || _c === void 0 ? void 0 : _c.setChatId(this.chatToken.chatId || '');
|
391
426
|
(_d = this.ocSdkLogger) === null || _d === void 0 ? void 0 : _d.setChatId(this.chatToken.chatId || '');
|
392
427
|
(_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setChatId(this.chatToken.chatId || '');
|
@@ -420,6 +455,22 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
420
455
|
if (optionalParams.preChatResponse) {
|
421
456
|
sessionInitOptionalParams.initContext.preChatResponse = optionalParams.preChatResponse;
|
422
457
|
}
|
458
|
+
if (optionalParams.sendDefaultInitContext) {
|
459
|
+
if (platform_1.default.isNode() || platform_1.default.isReactNative()) {
|
460
|
+
exceptionDetails = {
|
461
|
+
response: "UnsupportedPlatform",
|
462
|
+
message: "sendDefaultInitContext is only supported on browser"
|
463
|
+
};
|
464
|
+
console.error(exceptionDetails.message);
|
465
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
|
466
|
+
RequestId: this.requestId,
|
467
|
+
ChatId: this.chatToken.chatId,
|
468
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
469
|
+
});
|
470
|
+
throw new Error(exceptionDetails.response);
|
471
|
+
}
|
472
|
+
sessionInitOptionalParams.getContext = true;
|
473
|
+
}
|
423
474
|
// Override initContext completely
|
424
475
|
if (optionalParams.initContext) {
|
425
476
|
sessionInitOptionalParams.initContext = optionalParams.initContext;
|
@@ -427,16 +478,20 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
427
478
|
if (this.authenticatedUserToken) {
|
428
479
|
sessionInitOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
429
480
|
}
|
430
|
-
if (
|
431
|
-
|
432
|
-
|
433
|
-
|
481
|
+
if (this.chatToken.chatId) {
|
482
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
483
|
+
sessionInitOptionalParams.initContext.chatId = this.chatToken.chatId;
|
484
|
+
}
|
485
|
+
if (!!optionalParams.liveChatContext) return [3 /*break*/, 20];
|
486
|
+
_y.label = 17;
|
487
|
+
case 17:
|
488
|
+
_y.trys.push([17, 19, , 20]);
|
434
489
|
return [4 /*yield*/, this.OCClient.sessionInit(this.requestId, sessionInitOptionalParams)];
|
435
|
-
case
|
436
|
-
|
437
|
-
return [3 /*break*/,
|
438
|
-
case
|
439
|
-
error_3 =
|
490
|
+
case 18:
|
491
|
+
_y.sent();
|
492
|
+
return [3 /*break*/, 20];
|
493
|
+
case 19:
|
494
|
+
error_3 = _y.sent();
|
440
495
|
exceptionDetails = {
|
441
496
|
response: "OCClientSessionInitFailed"
|
442
497
|
};
|
@@ -452,27 +507,27 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
452
507
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
453
508
|
});
|
454
509
|
throw new Error(exceptionDetails.response);
|
455
|
-
case
|
456
|
-
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/,
|
510
|
+
case 20:
|
511
|
+
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 31];
|
457
512
|
chatAdapterConfig = {
|
458
513
|
token: this.chatToken.token,
|
459
514
|
id: this.chatToken.visitorId || 'teamsvisitor',
|
460
515
|
threadId: this.chatToken.chatId,
|
461
516
|
environmentUrl: this.chatToken.acsEndpoint,
|
462
|
-
pollingInterval:
|
517
|
+
pollingInterval: 30000
|
463
518
|
};
|
464
|
-
|
465
|
-
case
|
466
|
-
|
519
|
+
_y.label = 21;
|
520
|
+
case 21:
|
521
|
+
_y.trys.push([21, 23, , 24]);
|
467
522
|
return [4 /*yield*/, ((_o = this.ACSClient) === null || _o === void 0 ? void 0 : _o.initialize({
|
468
523
|
token: chatAdapterConfig.token,
|
469
524
|
environmentUrl: chatAdapterConfig.environmentUrl
|
470
525
|
}))];
|
471
|
-
case
|
472
|
-
|
473
|
-
return [3 /*break*/,
|
474
|
-
case
|
475
|
-
error_4 =
|
526
|
+
case 22:
|
527
|
+
_y.sent();
|
528
|
+
return [3 /*break*/, 24];
|
529
|
+
case 23:
|
530
|
+
error_4 = _y.sent();
|
476
531
|
exceptionDetails = {
|
477
532
|
response: "ACSClientInitializeFailed"
|
478
533
|
};
|
@@ -483,23 +538,23 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
483
538
|
});
|
484
539
|
console.error("OmnichannelChatSDK/startChat/initialize/error " + error_4);
|
485
540
|
return [2 /*return*/, error_4];
|
486
|
-
case
|
487
|
-
|
488
|
-
|
541
|
+
case 24:
|
542
|
+
_y.trys.push([24, 26, , 27]);
|
543
|
+
_w = this;
|
489
544
|
return [4 /*yield*/, ((_p = this.ACSClient) === null || _p === void 0 ? void 0 : _p.joinConversation({
|
490
545
|
id: chatAdapterConfig.id,
|
491
546
|
threadId: chatAdapterConfig.threadId,
|
492
547
|
pollingInterval: chatAdapterConfig.pollingInterval
|
493
548
|
}))];
|
494
|
-
case
|
495
|
-
|
549
|
+
case 25:
|
550
|
+
_w.conversation = (_y.sent());
|
496
551
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
|
497
552
|
RequestId: this.requestId,
|
498
553
|
ChatId: this.chatToken.chatId
|
499
554
|
});
|
500
|
-
return [3 /*break*/,
|
501
|
-
case
|
502
|
-
error_5 =
|
555
|
+
return [3 /*break*/, 27];
|
556
|
+
case 26:
|
557
|
+
error_5 = _y.sent();
|
503
558
|
exceptionDetails = {
|
504
559
|
response: "ACSClientJoinConversationFailed"
|
505
560
|
};
|
@@ -510,16 +565,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
510
565
|
});
|
511
566
|
console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_5);
|
512
567
|
throw Error(exceptionDetails.response);
|
513
|
-
case
|
514
|
-
|
568
|
+
case 27:
|
569
|
+
_y.trys.push([27, 29, , 30]);
|
515
570
|
return [4 /*yield*/, ((_q = this.AMSClient) === null || _q === void 0 ? void 0 : _q.initialize({
|
516
571
|
chatToken: this.chatToken
|
517
572
|
}))];
|
518
|
-
case
|
519
|
-
|
520
|
-
return [3 /*break*/,
|
521
|
-
case
|
522
|
-
error_6 =
|
573
|
+
case 28:
|
574
|
+
_y.sent();
|
575
|
+
return [3 /*break*/, 30];
|
576
|
+
case 29:
|
577
|
+
error_6 = _y.sent();
|
523
578
|
exceptionDetails = {
|
524
579
|
response: "AMSClientInitializeFailed"
|
525
580
|
};
|
@@ -529,19 +584,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
529
584
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
530
585
|
});
|
531
586
|
throw Error(exceptionDetails.response);
|
532
|
-
case
|
533
|
-
case
|
534
|
-
|
587
|
+
case 30: return [3 /*break*/, 37];
|
588
|
+
case 31:
|
589
|
+
_y.trys.push([31, 33, , 34]);
|
535
590
|
return [4 /*yield*/, this.IC3Client.initialize({
|
536
591
|
token: this.chatToken.token,
|
537
592
|
regionGtms: this.chatToken.regionGTMS,
|
538
593
|
visitor: true
|
539
594
|
})];
|
540
|
-
case
|
541
|
-
|
542
|
-
return [3 /*break*/,
|
543
|
-
case
|
544
|
-
error_7 =
|
595
|
+
case 32:
|
596
|
+
_y.sent();
|
597
|
+
return [3 /*break*/, 34];
|
598
|
+
case 33:
|
599
|
+
error_7 = _y.sent();
|
545
600
|
exceptionDetails = {
|
546
601
|
response: "IC3ClientInitializeFailed"
|
547
602
|
};
|
@@ -552,19 +607,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
552
607
|
});
|
553
608
|
console.error("OmnichannelChatSDK/startChat/initialize/error " + error_7);
|
554
609
|
return [2 /*return*/, error_7];
|
555
|
-
case
|
556
|
-
|
557
|
-
|
610
|
+
case 34:
|
611
|
+
_y.trys.push([34, 36, , 37]);
|
612
|
+
_x = this;
|
558
613
|
return [4 /*yield*/, this.IC3Client.joinConversation(this.chatToken.chatId)];
|
559
|
-
case
|
560
|
-
|
614
|
+
case 35:
|
615
|
+
_x.conversation = _y.sent();
|
561
616
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
|
562
617
|
RequestId: this.requestId,
|
563
618
|
ChatId: this.chatToken.chatId
|
564
619
|
});
|
565
|
-
return [3 /*break*/,
|
566
|
-
case
|
567
|
-
error_8 =
|
620
|
+
return [3 /*break*/, 37];
|
621
|
+
case 36:
|
622
|
+
error_8 = _y.sent();
|
568
623
|
exceptionDetails = {
|
569
624
|
response: "IC3ClientJoinConversationFailed"
|
570
625
|
};
|
@@ -575,7 +630,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
575
630
|
});
|
576
631
|
console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_8);
|
577
632
|
return [2 /*return*/, error_8];
|
578
|
-
case
|
633
|
+
case 37:
|
579
634
|
if (this.isPersistentChat && !((_r = this.chatSDKConfig.persistentChat) === null || _r === void 0 ? void 0 : _r.disable)) {
|
580
635
|
this.refreshTokenTimer = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
581
636
|
return __generator(this, function (_a) {
|
@@ -782,14 +837,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
782
837
|
});
|
783
838
|
});
|
784
839
|
};
|
785
|
-
OmnichannelChatSDK.prototype.getLiveChatConfig = function (
|
786
|
-
if (cached === void 0) { cached = true; }
|
840
|
+
OmnichannelChatSDK.prototype.getLiveChatConfig = function (optionalParams) {
|
787
841
|
return __awaiter(this, void 0, void 0, function () {
|
788
842
|
return __generator(this, function (_a) {
|
789
|
-
if (
|
843
|
+
if (!optionalParams || optionalParams.useRuntimeCache === true) {
|
790
844
|
return [2 /*return*/, this.liveChatConfig];
|
791
845
|
}
|
792
|
-
return [2 /*return*/, this.getChatConfig()];
|
846
|
+
return [2 /*return*/, this.getChatConfig({ sendCacheHeaders: (optionalParams === null || optionalParams === void 0 ? void 0 : optionalParams.sendCacheHeaders) || false })];
|
793
847
|
});
|
794
848
|
});
|
795
849
|
};
|
@@ -1589,17 +1643,17 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1589
1643
|
ACSAdapter: acsAdapterCDNUrl
|
1590
1644
|
});
|
1591
1645
|
return [4 /*yield*/, WebUtils_1.loadScript(acsAdapterCDNUrl, function () {
|
1646
|
+
var _a;
|
1592
1647
|
/* istanbul ignore next */
|
1593
1648
|
_this.debug && console.debug('ACSAdapter loaded!');
|
1594
1649
|
try {
|
1595
1650
|
var ChatAdapter = window.ChatAdapter; // eslint-disable-line @typescript-eslint/no-explicit-any
|
1596
1651
|
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,
|
1598
|
-
_this.acsAdapterLogger, // logger
|
1652
|
+
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
1653
|
featuresOption);
|
1600
1654
|
resolve(adapter);
|
1601
1655
|
}
|
1602
|
-
catch (
|
1656
|
+
catch (_b) {
|
1603
1657
|
throw new Error('Failed to load ACSAdapter');
|
1604
1658
|
}
|
1605
1659
|
}, function () {
|
@@ -1924,15 +1978,20 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1924
1978
|
});
|
1925
1979
|
});
|
1926
1980
|
};
|
1927
|
-
OmnichannelChatSDK.prototype.getChatConfig = function () {
|
1981
|
+
OmnichannelChatSDK.prototype.getChatConfig = function (optionalParams) {
|
1982
|
+
if (optionalParams === void 0) { optionalParams = {}; }
|
1928
1983
|
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;
|
1984
|
+
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
1985
|
return __generator(this, function (_a) {
|
1931
1986
|
switch (_a.label) {
|
1932
1987
|
case 0:
|
1933
|
-
|
1934
|
-
|
1988
|
+
sendCacheHeaders = optionalParams.sendCacheHeaders;
|
1989
|
+
_a.label = 1;
|
1935
1990
|
case 1:
|
1991
|
+
_a.trys.push([1, 5, , 6]);
|
1992
|
+
bypassCache = sendCacheHeaders === true;
|
1993
|
+
return [4 /*yield*/, this.OCClient.getChatConfig(this.requestId, bypassCache)];
|
1994
|
+
case 2:
|
1936
1995
|
liveChatConfig = _a.sent();
|
1937
1996
|
dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin, liveChatVersion = liveChatConfig.LiveChatVersion, chatWidgetLanguage = liveChatConfig.ChatWidgetLanguage;
|
1938
1997
|
msdyn_localeid = chatWidgetLanguage.msdyn_localeid;
|
@@ -1959,12 +2018,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1959
2018
|
if (isPreChatEnabled && preChatSurvey && preChatSurvey.trim().length > 0) {
|
1960
2019
|
this.preChatSurvey = preChatSurvey;
|
1961
2020
|
}
|
1962
|
-
if (!this.authSettings) return [3 /*break*/,
|
2021
|
+
if (!this.authSettings) return [3 /*break*/, 4];
|
1963
2022
|
return [4 /*yield*/, this.setAuthTokenProvider(this.chatSDKConfig.getAuthToken)];
|
1964
|
-
case 2:
|
1965
|
-
_a.sent();
|
1966
|
-
_a.label = 3;
|
1967
2023
|
case 3:
|
2024
|
+
_a.sent();
|
2025
|
+
_a.label = 4;
|
2026
|
+
case 4:
|
1968
2027
|
if (this.preChatSurvey) {
|
1969
2028
|
/* istanbul ignore next */
|
1970
2029
|
this.debug && console.log('Prechat Survey!');
|
@@ -1972,11 +2031,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1972
2031
|
this.callingOption = msdyn_callingoptions;
|
1973
2032
|
this.liveChatConfig = liveChatConfig;
|
1974
2033
|
return [2 /*return*/, this.liveChatConfig];
|
1975
|
-
case
|
2034
|
+
case 5:
|
1976
2035
|
error_18 = _a.sent();
|
1977
2036
|
console.error("OmnichannelChatSDK/getChatConfig/error " + error_18);
|
1978
2037
|
return [2 /*return*/, error_18];
|
1979
|
-
case
|
2038
|
+
case 6: return [2 /*return*/];
|
1980
2039
|
}
|
1981
2040
|
});
|
1982
2041
|
});
|
@@ -2027,21 +2086,24 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2027
2086
|
});
|
2028
2087
|
_a.label = 1;
|
2029
2088
|
case 1:
|
2030
|
-
_a.trys.push([1,
|
2089
|
+
_a.trys.push([1, 4, , 5]);
|
2031
2090
|
sessionInfo = {
|
2032
2091
|
token: newToken,
|
2033
2092
|
regionGtms: newRegionGTMS,
|
2034
2093
|
visitor: true
|
2035
2094
|
};
|
2095
|
+
if (!(this.liveChatVersion === LiveChatVersion_1.default.V1)) return [3 /*break*/, 3];
|
2036
2096
|
return [4 /*yield*/, this.IC3Client.initialize(sessionInfo)];
|
2037
2097
|
case 2:
|
2038
2098
|
_a.sent();
|
2099
|
+
_a.label = 3;
|
2100
|
+
case 3:
|
2039
2101
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.UpdateChatToken, {
|
2040
2102
|
RequestId: this.requestId,
|
2041
2103
|
ChatId: this.chatToken.chatId
|
2042
2104
|
});
|
2043
|
-
return [3 /*break*/,
|
2044
|
-
case
|
2105
|
+
return [3 /*break*/, 5];
|
2106
|
+
case 4:
|
2045
2107
|
error_19 = _a.sent();
|
2046
2108
|
exceptionDetails = {
|
2047
2109
|
response: "UpdateChatTokenFailed"
|
@@ -2052,8 +2114,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2052
2114
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
2053
2115
|
});
|
2054
2116
|
console.error("OmnichannelChatSDK/updateChatToken/error " + error_19);
|
2055
|
-
return [3 /*break*/,
|
2056
|
-
case
|
2117
|
+
return [3 /*break*/, 5];
|
2118
|
+
case 5: return [2 /*return*/];
|
2057
2119
|
}
|
2058
2120
|
});
|
2059
2121
|
});
|