@microsoft/omnichannel-chat-sdk 1.0.1-main.c6dccf8 → 1.0.1-main.d9ac478
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 +17 -3
- package/README.md +41 -20
- package/lib/OmnichannelChatSDK.d.ts +5 -4
- package/lib/OmnichannelChatSDK.js +225 -259
- package/lib/OmnichannelChatSDK.js.map +1 -1
- package/lib/config/settings.d.ts +1 -1
- package/lib/config/settings.js +1 -1
- package/lib/config/settings.js.map +1 -1
- package/lib/core/ChatConfig.d.ts +3 -0
- package/lib/core/messaging/ACSClient.js +1 -1
- package/lib/core/messaging/ACSClient.js.map +1 -1
- package/lib/core/messaging/ChatAdapterOptionalParams.d.ts +14 -0
- package/lib/core/messaging/ChatAdapterOptionalParams.js +3 -0
- package/lib/core/messaging/ChatAdapterOptionalParams.js.map +1 -0
- package/lib/external/ACSAdapter/createFormatEgressTagsMiddleware.d.ts +2 -0
- package/lib/external/ACSAdapter/createFormatEgressTagsMiddleware.js +31 -0
- package/lib/external/ACSAdapter/createFormatEgressTagsMiddleware.js.map +1 -0
- package/lib/external/ACSAdapter/createFormatIngressTagsMiddleware.d.ts +2 -0
- package/lib/external/ACSAdapter/createFormatIngressTagsMiddleware.js +25 -0
- package/lib/external/ACSAdapter/createFormatIngressTagsMiddleware.js.map +1 -0
- package/lib/external/IC3Adapter/IIC3AdapterOptions.d.ts +12 -0
- package/lib/telemetry/AriaTelemetry.js +5 -0
- package/lib/telemetry/AriaTelemetry.js.map +1 -1
- package/lib/telemetry/ScenarioMarker.d.ts +2 -0
- package/lib/telemetry/ScenarioMarker.js +7 -3
- package/lib/telemetry/ScenarioMarker.js.map +1 -1
- package/lib/telemetry/TelemetryEvent.d.ts +1 -3
- package/lib/telemetry/TelemetryEvent.js +0 -2
- package/lib/telemetry/TelemetryEvent.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +813 -1089
- package/lib/utils/WebUtils.d.ts +3 -1
- package/lib/utils/WebUtils.js +8 -2
- package/lib/utils/WebUtils.js.map +1 -1
- package/lib/utils/libraries.d.ts +1 -3
- package/lib/utils/libraries.js +2 -11
- package/lib/utils/libraries.js.map +1 -1
- package/lib/utils/locale.d.ts +1 -0
- package/lib/utils/locale.js +2 -1
- package/lib/utils/locale.js.map +1 -1
- package/lib/utils/loggers.d.ts +8 -0
- package/lib/utils/loggers.js +24 -0
- package/lib/utils/loggers.js.map +1 -1
- package/package.json +2 -2
@@ -58,7 +58,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
58
58
|
var loggers_1 = require("./utils/loggers");
|
59
59
|
var ACSClient_1 = require("./core/messaging/ACSClient");
|
60
60
|
var ocsdk_1 = require("@microsoft/ocsdk");
|
61
|
-
var libraries_1 = require("./utils/libraries");
|
62
61
|
var platform_1 = require("./utils/platform");
|
63
62
|
var SDKConfigValidators_1 = require("./validators/SDKConfigValidators");
|
64
63
|
var ACSParticipantDisplayName_1 = require("./core/messaging/ACSParticipantDisplayName");
|
@@ -66,6 +65,8 @@ var AMSFileManager_1 = require("./external/ACSAdapter/AMSFileManager");
|
|
66
65
|
var CallingOptionsOptionSetNumber_1 = require("./core/CallingOptionsOptionSetNumber");
|
67
66
|
var ChatAdapterProtocols_1 = require("./core/messaging/ChatAdapterProtocols");
|
68
67
|
var ConversationMode_1 = require("./core/ConversationMode");
|
68
|
+
var createFormatEgressTagsMiddleware_1 = require("./external/ACSAdapter/createFormatEgressTagsMiddleware");
|
69
|
+
var createFormatIngressTagsMiddleware_1 = require("./external/ACSAdapter/createFormatIngressTagsMiddleware");
|
69
70
|
var DeliveryMode_1 = require("@microsoft/omnichannel-ic3core/lib/model/DeliveryMode");
|
70
71
|
var FileSharingProtocolType_1 = require("@microsoft/omnichannel-ic3core/lib/model/FileSharingProtocolType");
|
71
72
|
var HostType_1 = require("@microsoft/omnichannel-ic3core/lib/interfaces/HostType");
|
@@ -85,6 +86,7 @@ var createVoiceVideoCalling_1 = require("./api/createVoiceVideoCalling");
|
|
85
86
|
var MessageTags_1 = require("./core/messaging/MessageTags");
|
86
87
|
var locale_1 = require("./utils/locale");
|
87
88
|
var utilities_1 = require("./utils/utilities");
|
89
|
+
var libraries_1 = require("./utils/libraries");
|
88
90
|
var WebUtils_1 = require("./utils/WebUtils");
|
89
91
|
var OmnichannelConfigValidator_1 = require("./validators/OmnichannelConfigValidator");
|
90
92
|
var OmnichannelChatSDK = /** @class */ (function () {
|
@@ -107,11 +109,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
107
109
|
this.reconnectId = null;
|
108
110
|
this.refreshTokenTimer = null;
|
109
111
|
this.debug = false;
|
112
|
+
this.runtimeId = ocsdk_1.uuidv4();
|
110
113
|
this.omnichannelConfig = omnichannelConfig;
|
111
114
|
this.chatSDKConfig = __assign(__assign({}, SDKConfigValidators_1.defaultChatSDKConfig), chatSDKConfig // overrides
|
112
115
|
);
|
113
116
|
this.isInitialized = false;
|
114
117
|
this.liveChatVersion = LiveChatVersion_1.default.V1;
|
118
|
+
this.localeId = locale_1.defaultLocaleId;
|
115
119
|
this.requestId = ocsdk_1.uuidv4();
|
116
120
|
this.chatToken = {};
|
117
121
|
this.liveChatConfig = {};
|
@@ -129,6 +133,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
129
133
|
this.ocSdkLogger.useTelemetry(this.telemetry);
|
130
134
|
this.acsClientLogger.useTelemetry(this.telemetry);
|
131
135
|
this.acsAdapterLogger.useTelemetry(this.telemetry);
|
136
|
+
this.scenarioMarker.setRuntimeId(this.runtimeId);
|
137
|
+
this.ic3ClientLogger.setRuntimeId(this.runtimeId);
|
138
|
+
this.ocSdkLogger.setRuntimeId(this.runtimeId);
|
139
|
+
this.acsClientLogger.setRuntimeId(this.runtimeId);
|
140
|
+
this.acsAdapterLogger.setRuntimeId(this.runtimeId);
|
132
141
|
OmnichannelConfigValidator_1.default(omnichannelConfig);
|
133
142
|
SDKConfigValidators_1.default(chatSDKConfig);
|
134
143
|
((_a = this.chatSDKConfig.telemetry) === null || _a === void 0 ? void 0 : _a.disable) && ((_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.disable());
|
@@ -292,44 +301,52 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
292
301
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
293
302
|
if (optionalParams === void 0) { optionalParams = {}; }
|
294
303
|
return __awaiter(this, void 0, void 0, function () {
|
295
|
-
var reconnectableChatsParams, reconnectableChatsResponse,
|
304
|
+
var shouldReinitIC3Client, _p, reconnectableChatsParams, reconnectableChatsResponse, _q, exceptionDetails, conversationDetails, exceptionDetails, exceptionDetails, sessionInitOptionalParams, error_3, exceptionDetails, chatAdapterConfig, error_4, exceptionDetails, _r, error_5, exceptionDetails, error_6, exceptionDetails, error_7, exceptionDetails, _s, error_8, exceptionDetails;
|
296
305
|
var _this = this;
|
297
|
-
return __generator(this, function (
|
298
|
-
switch (
|
306
|
+
return __generator(this, function (_t) {
|
307
|
+
switch (_t.label) {
|
299
308
|
case 0:
|
300
309
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.StartChat, {
|
301
310
|
RequestId: this.requestId
|
302
311
|
});
|
312
|
+
shouldReinitIC3Client = !platform_1.default.isNode() && !platform_1.default.isReactNative() && !this.IC3Client && this.liveChatVersion === LiveChatVersion_1.default.V1;
|
313
|
+
if (!shouldReinitIC3Client) return [3 /*break*/, 2];
|
314
|
+
_p = this;
|
315
|
+
return [4 /*yield*/, this.getIC3Client()];
|
316
|
+
case 1:
|
317
|
+
_p.IC3Client = _t.sent();
|
318
|
+
_t.label = 2;
|
319
|
+
case 2:
|
303
320
|
if (this.isChatReconnect && !((_a = this.chatSDKConfig.chatReconnect) === null || _a === void 0 ? void 0 : _a.disable) && !this.isPersistentChat && optionalParams.reconnectId) {
|
304
321
|
this.reconnectId = optionalParams.reconnectId;
|
305
322
|
}
|
306
|
-
if (!(this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable))) return [3 /*break*/,
|
307
|
-
|
308
|
-
case
|
309
|
-
|
323
|
+
if (!(this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable))) return [3 /*break*/, 6];
|
324
|
+
_t.label = 3;
|
325
|
+
case 3:
|
326
|
+
_t.trys.push([3, 5, , 6]);
|
310
327
|
reconnectableChatsParams = {
|
311
328
|
authenticatedUserToken: this.authenticatedUserToken
|
312
329
|
};
|
313
330
|
return [4 /*yield*/, this.OCClient.getReconnectableChats(reconnectableChatsParams)];
|
314
|
-
case
|
315
|
-
reconnectableChatsResponse =
|
331
|
+
case 4:
|
332
|
+
reconnectableChatsResponse = _t.sent();
|
316
333
|
if (reconnectableChatsResponse && reconnectableChatsResponse.reconnectid) {
|
317
334
|
this.reconnectId = reconnectableChatsResponse.reconnectid;
|
318
335
|
}
|
319
|
-
return [3 /*break*/,
|
320
|
-
case
|
321
|
-
|
336
|
+
return [3 /*break*/, 6];
|
337
|
+
case 5:
|
338
|
+
_q = _t.sent();
|
322
339
|
exceptionDetails = {
|
323
340
|
response: "OCClientGetReconnectableChatsFailed"
|
324
341
|
};
|
325
342
|
throw Error(exceptionDetails.response);
|
326
|
-
case
|
327
|
-
if (!(optionalParams.liveChatContext && !this.
|
343
|
+
case 6:
|
344
|
+
if (!(optionalParams.liveChatContext && !this.reconnectId)) return [3 /*break*/, 8];
|
328
345
|
this.chatToken = optionalParams.liveChatContext.chatToken || {};
|
329
346
|
this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
|
330
347
|
return [4 /*yield*/, this.getConversationDetails()];
|
331
|
-
case
|
332
|
-
conversationDetails =
|
348
|
+
case 7:
|
349
|
+
conversationDetails = _t.sent();
|
333
350
|
if (Object.keys(conversationDetails).length === 0) {
|
334
351
|
exceptionDetails = {
|
335
352
|
response: "InvalidConversation"
|
@@ -354,14 +371,14 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
354
371
|
console.error("Unable to join conversation that's in '" + conversationDetails.state + "' state");
|
355
372
|
throw Error(exceptionDetails.response);
|
356
373
|
}
|
357
|
-
|
358
|
-
case 6:
|
359
|
-
if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 8];
|
360
|
-
return [4 /*yield*/, this.getChatToken(false)];
|
361
|
-
case 7:
|
362
|
-
_s.sent();
|
363
|
-
_s.label = 8;
|
374
|
+
_t.label = 8;
|
364
375
|
case 8:
|
376
|
+
if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 10];
|
377
|
+
return [4 /*yield*/, this.getChatToken(false)];
|
378
|
+
case 9:
|
379
|
+
_t.sent();
|
380
|
+
_t.label = 10;
|
381
|
+
case 10:
|
365
382
|
(_c = this.ic3ClientLogger) === null || _c === void 0 ? void 0 : _c.setChatId(this.chatToken.chatId || '');
|
366
383
|
(_d = this.ocSdkLogger) === null || _d === void 0 ? void 0 : _d.setChatId(this.chatToken.chatId || '');
|
367
384
|
(_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setChatId(this.chatToken.chatId || '');
|
@@ -369,6 +386,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
369
386
|
sessionInitOptionalParams = {
|
370
387
|
initContext: {}
|
371
388
|
};
|
389
|
+
sessionInitOptionalParams.initContext.locale = locale_1.getLocaleStringFromId(this.localeId);
|
372
390
|
if (this.isPersistentChat && !((_g = this.chatSDKConfig.persistentChat) === null || _g === void 0 ? void 0 : _g.disable)) {
|
373
391
|
sessionInitOptionalParams.reconnectId = this.reconnectId;
|
374
392
|
}
|
@@ -400,15 +418,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
400
418
|
if (this.authenticatedUserToken) {
|
401
419
|
sessionInitOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
402
420
|
}
|
403
|
-
|
404
|
-
|
405
|
-
_s.trys.push([9, 11, , 12]);
|
406
|
-
return [4 /*yield*/, this.OCClient.sessionInit(this.requestId, sessionInitOptionalParams)];
|
407
|
-
case 10:
|
408
|
-
_s.sent();
|
409
|
-
return [3 /*break*/, 12];
|
421
|
+
if (!!optionalParams.liveChatContext) return [3 /*break*/, 14];
|
422
|
+
_t.label = 11;
|
410
423
|
case 11:
|
411
|
-
|
424
|
+
_t.trys.push([11, 13, , 14]);
|
425
|
+
return [4 /*yield*/, this.OCClient.sessionInit(this.requestId, sessionInitOptionalParams)];
|
426
|
+
case 12:
|
427
|
+
_t.sent();
|
428
|
+
return [3 /*break*/, 14];
|
429
|
+
case 13:
|
430
|
+
error_3 = _t.sent();
|
412
431
|
exceptionDetails = {
|
413
432
|
response: "OCClientSessionInitFailed"
|
414
433
|
};
|
@@ -418,9 +437,9 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
418
437
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
419
438
|
});
|
420
439
|
console.error("OmnichannelChatSDK/startChat/sessionInit/error " + error_3);
|
421
|
-
|
422
|
-
case
|
423
|
-
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/,
|
440
|
+
throw error_3;
|
441
|
+
case 14:
|
442
|
+
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 25];
|
424
443
|
chatAdapterConfig = {
|
425
444
|
token: this.chatToken.token,
|
426
445
|
id: this.chatToken.visitorId || 'teamsvisitor',
|
@@ -428,18 +447,18 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
428
447
|
environmentUrl: this.chatToken.acsEndpoint,
|
429
448
|
pollingInterval: 1000
|
430
449
|
};
|
431
|
-
|
432
|
-
case
|
433
|
-
|
450
|
+
_t.label = 15;
|
451
|
+
case 15:
|
452
|
+
_t.trys.push([15, 17, , 18]);
|
434
453
|
return [4 /*yield*/, ((_j = this.ACSClient) === null || _j === void 0 ? void 0 : _j.initialize({
|
435
454
|
token: chatAdapterConfig.token,
|
436
455
|
environmentUrl: chatAdapterConfig.environmentUrl
|
437
456
|
}))];
|
438
|
-
case
|
439
|
-
|
440
|
-
return [3 /*break*/,
|
441
|
-
case
|
442
|
-
error_4 =
|
457
|
+
case 16:
|
458
|
+
_t.sent();
|
459
|
+
return [3 /*break*/, 18];
|
460
|
+
case 17:
|
461
|
+
error_4 = _t.sent();
|
443
462
|
exceptionDetails = {
|
444
463
|
response: "ACSClientInitializeFailed"
|
445
464
|
};
|
@@ -450,23 +469,23 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
450
469
|
});
|
451
470
|
console.error("OmnichannelChatSDK/startChat/initialize/error " + error_4);
|
452
471
|
return [2 /*return*/, error_4];
|
453
|
-
case
|
454
|
-
|
455
|
-
|
472
|
+
case 18:
|
473
|
+
_t.trys.push([18, 20, , 21]);
|
474
|
+
_r = this;
|
456
475
|
return [4 /*yield*/, ((_k = this.ACSClient) === null || _k === void 0 ? void 0 : _k.joinConversation({
|
457
476
|
id: chatAdapterConfig.id,
|
458
477
|
threadId: chatAdapterConfig.threadId,
|
459
478
|
pollingInterval: chatAdapterConfig.pollingInterval
|
460
479
|
}))];
|
461
|
-
case
|
462
|
-
|
480
|
+
case 19:
|
481
|
+
_r.conversation = (_t.sent());
|
463
482
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
|
464
483
|
RequestId: this.requestId,
|
465
484
|
ChatId: this.chatToken.chatId
|
466
485
|
});
|
467
|
-
return [3 /*break*/,
|
468
|
-
case
|
469
|
-
error_5 =
|
486
|
+
return [3 /*break*/, 21];
|
487
|
+
case 20:
|
488
|
+
error_5 = _t.sent();
|
470
489
|
exceptionDetails = {
|
471
490
|
response: "ACSClientJoinConversationFailed"
|
472
491
|
};
|
@@ -477,16 +496,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
477
496
|
});
|
478
497
|
console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_5);
|
479
498
|
throw Error(exceptionDetails.response);
|
480
|
-
case
|
481
|
-
|
499
|
+
case 21:
|
500
|
+
_t.trys.push([21, 23, , 24]);
|
482
501
|
return [4 /*yield*/, ((_l = this.AMSClient) === null || _l === void 0 ? void 0 : _l.initialize({
|
483
502
|
chatToken: this.chatToken
|
484
503
|
}))];
|
485
|
-
case
|
486
|
-
|
487
|
-
return [3 /*break*/,
|
488
|
-
case
|
489
|
-
error_6 =
|
504
|
+
case 22:
|
505
|
+
_t.sent();
|
506
|
+
return [3 /*break*/, 24];
|
507
|
+
case 23:
|
508
|
+
error_6 = _t.sent();
|
490
509
|
exceptionDetails = {
|
491
510
|
response: "AMSClientInitializeFailed"
|
492
511
|
};
|
@@ -496,19 +515,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
496
515
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
497
516
|
});
|
498
517
|
throw Error(exceptionDetails.response);
|
499
|
-
case
|
500
|
-
case
|
501
|
-
|
518
|
+
case 24: return [3 /*break*/, 31];
|
519
|
+
case 25:
|
520
|
+
_t.trys.push([25, 27, , 28]);
|
502
521
|
return [4 /*yield*/, this.IC3Client.initialize({
|
503
522
|
token: this.chatToken.token,
|
504
523
|
regionGtms: this.chatToken.regionGTMS,
|
505
524
|
visitor: true
|
506
525
|
})];
|
507
|
-
case
|
508
|
-
|
509
|
-
return [3 /*break*/,
|
510
|
-
case
|
511
|
-
error_7 =
|
526
|
+
case 26:
|
527
|
+
_t.sent();
|
528
|
+
return [3 /*break*/, 28];
|
529
|
+
case 27:
|
530
|
+
error_7 = _t.sent();
|
512
531
|
exceptionDetails = {
|
513
532
|
response: "IC3ClientInitializeFailed"
|
514
533
|
};
|
@@ -519,19 +538,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
519
538
|
});
|
520
539
|
console.error("OmnichannelChatSDK/startChat/initialize/error " + error_7);
|
521
540
|
return [2 /*return*/, error_7];
|
522
|
-
case
|
523
|
-
|
524
|
-
|
541
|
+
case 28:
|
542
|
+
_t.trys.push([28, 30, , 31]);
|
543
|
+
_s = this;
|
525
544
|
return [4 /*yield*/, this.IC3Client.joinConversation(this.chatToken.chatId)];
|
526
|
-
case
|
527
|
-
|
545
|
+
case 29:
|
546
|
+
_s.conversation = _t.sent();
|
528
547
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
|
529
548
|
RequestId: this.requestId,
|
530
549
|
ChatId: this.chatToken.chatId
|
531
550
|
});
|
532
|
-
return [3 /*break*/,
|
533
|
-
case
|
534
|
-
error_8 =
|
551
|
+
return [3 /*break*/, 31];
|
552
|
+
case 30:
|
553
|
+
error_8 = _t.sent();
|
535
554
|
exceptionDetails = {
|
536
555
|
response: "IC3ClientJoinConversationFailed"
|
537
556
|
};
|
@@ -542,7 +561,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
542
561
|
});
|
543
562
|
console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_8);
|
544
563
|
return [2 /*return*/, error_8];
|
545
|
-
case
|
564
|
+
case 31:
|
546
565
|
if (this.isPersistentChat && !((_m = this.chatSDKConfig.persistentChat) === null || _m === void 0 ? void 0 : _m.disable)) {
|
547
566
|
this.refreshTokenTimer = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
548
567
|
return __generator(this, function (_a) {
|
@@ -580,6 +599,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
580
599
|
}
|
581
600
|
if (this.isChatReconnect && !((_b = this.chatSDKConfig.chatReconnect) === null || _b === void 0 ? void 0 : _b.disable) && !this.isPersistentChat) {
|
582
601
|
isChatReconnect = this.reconnectId !== null ? true : false;
|
602
|
+
this.requestId = isChatReconnect ? this.reconnectId : this.requestId; // Chat Reconnect session to close
|
583
603
|
sessionCloseOptionalParams.isReconnectChat = isChatReconnect;
|
584
604
|
}
|
585
605
|
if (this.authenticatedUserToken) {
|
@@ -600,6 +620,9 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
600
620
|
this.requestId = ocsdk_1.uuidv4();
|
601
621
|
this.chatToken = {};
|
602
622
|
this.reconnectId = null;
|
623
|
+
this.IC3Client.dispose();
|
624
|
+
!platform_1.default.isNode() && !platform_1.default.isReactNative() && WebUtils_1.removeElementById(this.IC3Client.id);
|
625
|
+
this.IC3Client = null;
|
603
626
|
(_d = this.ic3ClientLogger) === null || _d === void 0 ? void 0 : _d.setRequestId(this.requestId);
|
604
627
|
(_e = this.ic3ClientLogger) === null || _e === void 0 ? void 0 : _e.setChatId('');
|
605
628
|
(_f = this.ocSdkLogger) === null || _f === void 0 ? void 0 : _f.setRequestId(this.requestId);
|
@@ -661,22 +684,32 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
661
684
|
});
|
662
685
|
};
|
663
686
|
OmnichannelChatSDK.prototype.getConversationDetails = function () {
|
664
|
-
var _a, _b;
|
687
|
+
var _a, _b, _c, _d;
|
665
688
|
return __awaiter(this, void 0, void 0, function () {
|
666
|
-
var lwiDetails, state, conversationId, agentAcceptedOn, liveWorkItemDetails, error_10;
|
667
|
-
return __generator(this, function (
|
668
|
-
switch (
|
689
|
+
var getLWIDetailsOptionalParams, lwiDetails, state, conversationId, agentAcceptedOn, liveWorkItemDetails, error_10;
|
690
|
+
return __generator(this, function (_e) {
|
691
|
+
switch (_e.label) {
|
669
692
|
case 0:
|
670
693
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetConversationDetails, {
|
671
694
|
RequestId: this.requestId,
|
672
695
|
ChatId: ((_a = this.chatToken) === null || _a === void 0 ? void 0 : _a.chatId) || '',
|
673
696
|
});
|
674
|
-
|
697
|
+
getLWIDetailsOptionalParams = {};
|
698
|
+
if (this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable) && this.reconnectId) {
|
699
|
+
getLWIDetailsOptionalParams.reconnectId = this.reconnectId;
|
700
|
+
}
|
701
|
+
if (this.isChatReconnect && !((_c = this.chatSDKConfig.chatReconnect) === null || _c === void 0 ? void 0 : _c.disable) && !this.isPersistentChat && this.reconnectId) {
|
702
|
+
getLWIDetailsOptionalParams.reconnectId = this.reconnectId;
|
703
|
+
}
|
704
|
+
if (this.authenticatedUserToken) {
|
705
|
+
getLWIDetailsOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
706
|
+
}
|
707
|
+
_e.label = 1;
|
675
708
|
case 1:
|
676
|
-
|
677
|
-
return [4 /*yield*/, this.OCClient.getLWIDetails(this.requestId)];
|
709
|
+
_e.trys.push([1, 3, , 4]);
|
710
|
+
return [4 /*yield*/, this.OCClient.getLWIDetails(this.requestId, getLWIDetailsOptionalParams)];
|
678
711
|
case 2:
|
679
|
-
lwiDetails =
|
712
|
+
lwiDetails = _e.sent();
|
680
713
|
state = lwiDetails.State, conversationId = lwiDetails.ConversationId, agentAcceptedOn = lwiDetails.AgentAcceptedOn;
|
681
714
|
liveWorkItemDetails = {
|
682
715
|
state: state,
|
@@ -687,11 +720,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
687
720
|
}
|
688
721
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetConversationDetails, {
|
689
722
|
RequestId: this.requestId,
|
690
|
-
ChatId: ((
|
723
|
+
ChatId: ((_d = this.chatToken) === null || _d === void 0 ? void 0 : _d.chatId) || '',
|
691
724
|
});
|
692
725
|
return [2 /*return*/, liveWorkItemDetails];
|
693
726
|
case 3:
|
694
|
-
error_10 =
|
727
|
+
error_10 = _e.sent();
|
695
728
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetConversationDetails, {
|
696
729
|
RequestId: this.requestId,
|
697
730
|
ChatId: this.chatToken.chatId || '',
|
@@ -897,6 +930,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
897
930
|
sendMessageRequest = {
|
898
931
|
content: message.content,
|
899
932
|
};
|
933
|
+
sendMessageRequest.metadata = {
|
934
|
+
widgetId: this.omnichannelConfig.widgetId,
|
935
|
+
clientMessageId: Date.now().toString()
|
936
|
+
};
|
937
|
+
if (message.metadata) {
|
938
|
+
sendMessageRequest.metadata = __assign(__assign({}, sendMessageRequest.metadata), message.metadata);
|
939
|
+
}
|
900
940
|
_e.label = 1;
|
901
941
|
case 1:
|
902
942
|
_e.trys.push([1, 3, , 4]);
|
@@ -1279,7 +1319,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1279
1319
|
};
|
1280
1320
|
sendMessageRequest = {
|
1281
1321
|
content: '',
|
1282
|
-
metadata: __assign(__assign({}, fileIdsProperty), fileMetaProperty)
|
1322
|
+
metadata: __assign(__assign({ widgetId: this.omnichannelConfig.widgetId, clientMessageId: Date.now().toString() }, fileIdsProperty), fileMetaProperty)
|
1283
1323
|
};
|
1284
1324
|
messageToSend = {
|
1285
1325
|
content: "",
|
@@ -1440,7 +1480,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1440
1480
|
ChatId: this.chatToken.chatId,
|
1441
1481
|
EmailAddress: body.emailAddress,
|
1442
1482
|
DefaultAttachmentMessage: body.attachmentMessage,
|
1443
|
-
CustomerLocale: body.locale
|
1483
|
+
CustomerLocale: body.locale || locale_1.getLocaleStringFromId(this.localeId)
|
1444
1484
|
};
|
1445
1485
|
emailResponse = this.OCClient.emailTranscript(this.requestId, this.chatToken.token, emailRequestBody, emailTranscriptOptionalParams);
|
1446
1486
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.EmailLiveChatTranscript, {
|
@@ -1490,32 +1530,33 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1490
1530
|
});
|
1491
1531
|
});
|
1492
1532
|
};
|
1493
|
-
OmnichannelChatSDK.prototype.createChatAdapter = function (
|
1494
|
-
if (
|
1533
|
+
OmnichannelChatSDK.prototype.createChatAdapter = function (optionalParams) {
|
1534
|
+
if (optionalParams === void 0) { optionalParams = {}; }
|
1495
1535
|
return __awaiter(this, void 0, void 0, function () {
|
1496
|
-
var supportedChatAdapterProtocols;
|
1536
|
+
var protocol, supportedChatAdapterProtocols;
|
1497
1537
|
var _this = this;
|
1498
1538
|
return __generator(this, function (_a) {
|
1499
1539
|
if (platform_1.default.isNode() || platform_1.default.isReactNative()) {
|
1500
1540
|
return [2 /*return*/, Promise.reject('ChatAdapter is only supported on browser')];
|
1501
1541
|
}
|
1542
|
+
protocol = optionalParams.protocol;
|
1502
1543
|
supportedChatAdapterProtocols = [ChatAdapterProtocols_1.default.ACS, ChatAdapterProtocols_1.default.IC3];
|
1503
1544
|
if (protocol && !supportedChatAdapterProtocols.includes(protocol)) {
|
1504
1545
|
return [2 /*return*/, Promise.reject("ChatAdapter for protocol " + protocol + " currently not supported")];
|
1505
1546
|
}
|
1506
1547
|
if (protocol === ChatAdapterProtocols_1.default.ACS || this.liveChatVersion === LiveChatVersion_1.default.V2) {
|
1507
1548
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
1508
|
-
var featuresOption, acsAdapterCDNUrl;
|
1549
|
+
var options, egressMiddlewares, ingressMiddlewares, featuresOption, acsAdapterCDNUrl;
|
1509
1550
|
var _this = this;
|
1510
1551
|
var _a;
|
1511
1552
|
return __generator(this, function (_b) {
|
1512
1553
|
switch (_b.label) {
|
1513
1554
|
case 0:
|
1514
|
-
|
1515
|
-
|
1516
|
-
|
1517
|
-
|
1518
|
-
|
1555
|
+
options = optionalParams.ACSAdapter ? optionalParams.ACSAdapter.options : {};
|
1556
|
+
egressMiddlewares = [createFormatEgressTagsMiddleware_1.default()];
|
1557
|
+
ingressMiddlewares = [createFormatIngressTagsMiddleware_1.default()];
|
1558
|
+
featuresOption = __assign({ enableAdaptiveCards: true, enableThreadMemberUpdateNotification: true, enableLeaveThreadOnWindowClosed: false, egressMiddleware: egressMiddlewares, ingressMiddleware: ingressMiddlewares }, options // overrides
|
1559
|
+
);
|
1519
1560
|
acsAdapterCDNUrl = this.resolveChatAdapterUrl(protocol || ChatAdapterProtocols_1.default.ACS);
|
1520
1561
|
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
|
1521
1562
|
ACSAdapter: acsAdapterCDNUrl
|
@@ -1526,7 +1567,9 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1526
1567
|
try {
|
1527
1568
|
var ChatAdapter = window.ChatAdapter; // eslint-disable-line @typescript-eslint/no-explicit-any
|
1528
1569
|
var fileManager = new AMSFileManager_1.default(_this.AMSClient, _this.acsAdapterLogger);
|
1529
|
-
var adapter = ChatAdapter.createACSAdapter(_this.chatToken.token, _this.chatToken.visitorId || 'teamsvisitor', _this.chatToken.chatId, _this.chatToken.acsEndpoint, fileManager, 1000, ACSParticipantDisplayName_1.default.Customer, undefined,
|
1570
|
+
var adapter = ChatAdapter.createACSAdapter(_this.chatToken.token, _this.chatToken.visitorId || 'teamsvisitor', _this.chatToken.chatId, _this.chatToken.acsEndpoint, fileManager, 1000, ACSParticipantDisplayName_1.default.Customer, undefined, // chatClient
|
1571
|
+
undefined, // logger
|
1572
|
+
featuresOption);
|
1530
1573
|
resolve(adapter);
|
1531
1574
|
}
|
1532
1575
|
catch (_a) {
|
@@ -1544,12 +1587,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1544
1587
|
}
|
1545
1588
|
else if (protocol === ChatAdapterProtocols_1.default.IC3 || this.liveChatVersion === LiveChatVersion_1.default.V1) {
|
1546
1589
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
1547
|
-
var ic3AdapterCDNUrl;
|
1590
|
+
var options, ic3AdapterCDNUrl;
|
1548
1591
|
var _this = this;
|
1549
1592
|
var _a;
|
1550
1593
|
return __generator(this, function (_b) {
|
1551
1594
|
switch (_b.label) {
|
1552
1595
|
case 0:
|
1596
|
+
options = optionalParams.IC3Adapter ? optionalParams.IC3Adapter.options : {};
|
1553
1597
|
ic3AdapterCDNUrl = this.resolveChatAdapterUrl(protocol || ChatAdapterProtocols_1.default.IC3);
|
1554
1598
|
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
|
1555
1599
|
IC3Adapter: ic3AdapterCDNUrl
|
@@ -1558,17 +1602,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1558
1602
|
return [4 /*yield*/, WebUtils_1.loadScript(ic3AdapterCDNUrl, function () {
|
1559
1603
|
/* istanbul ignore next */
|
1560
1604
|
_this.debug && console.debug('IC3Adapter loaded!');
|
1561
|
-
var adapterConfig = {
|
1562
|
-
|
1563
|
-
userDisplayName: 'Customer',
|
1564
|
-
userId: 'teamsvisitor',
|
1565
|
-
sdkURL: _this.resolveIC3ClientUrl(),
|
1566
|
-
sdk: _this.IC3Client
|
1567
|
-
};
|
1605
|
+
var adapterConfig = __assign({ chatToken: _this.chatToken, userDisplayName: 'Customer', userId: _this.chatToken.visitorId || 'teamsvisitor', sdkURL: _this.resolveIC3ClientUrl(), sdk: _this.IC3Client }, options // overrides
|
1606
|
+
);
|
1568
1607
|
var adapter = new window.Microsoft.BotFramework.WebChat.IC3Adapter(adapterConfig);
|
1569
1608
|
adapter.logger = _this.ic3ClientLogger;
|
1570
|
-
// Keep iframe communication alive to reuse the same IC3Client instance
|
1571
|
-
window.Microsoft.BotFramework.WebChat.IC3SDKProvider.disposeSdk = function () { }; // eslint-disable-line @typescript-eslint/no-empty-function
|
1572
1609
|
_this.scenarioMarker.completeScenario(TelemetryEvent_1.default.CreateIC3Adapter);
|
1573
1610
|
resolve(adapter);
|
1574
1611
|
}, function () {
|
@@ -1662,7 +1699,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1662
1699
|
};
|
1663
1700
|
OmnichannelChatSDK.prototype.getPostChatSurveyContext = function () {
|
1664
1701
|
return __awaiter(this, void 0, void 0, function () {
|
1665
|
-
var conversationId,
|
1702
|
+
var conversationId, liveWSAndLiveChatEngJoin, msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier, postConversationSurveyOwnerId, liveWorkItemDetails, participantJoined, surveyInviteLinkRequest, optionalParams, surveyInviteLinkResponse, surveyInviteLink, formsProLocale, postChatContext, ex_1;
|
1666
1703
|
return __generator(this, function (_a) {
|
1667
1704
|
switch (_a.label) {
|
1668
1705
|
case 0:
|
@@ -1672,11 +1709,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1672
1709
|
_a.label = 1;
|
1673
1710
|
case 1:
|
1674
1711
|
_a.trys.push([1, 6, , 7]);
|
1675
|
-
|
1676
|
-
liveWSAndLiveChatEngJoin = chatConfig.LiveWSAndLiveChatEngJoin, chatWidgetLanguage = chatConfig.ChatWidgetLanguage;
|
1712
|
+
liveWSAndLiveChatEngJoin = this.liveChatConfig.LiveWSAndLiveChatEngJoin;
|
1677
1713
|
msdyn_postconversationsurveyenable = liveWSAndLiveChatEngJoin.msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier = liveWSAndLiveChatEngJoin.msfp_sourcesurveyidentifier, postConversationSurveyOwnerId = liveWSAndLiveChatEngJoin.postConversationSurveyOwnerId;
|
1678
|
-
msdyn_localeid = chatWidgetLanguage.msdyn_localeid;
|
1679
|
-
localeId = msdyn_localeid !== null && msdyn_localeid !== void 0 ? msdyn_localeid : "1033";
|
1680
1714
|
if (!msdyn_postconversationsurveyenable) return [3 /*break*/, 4];
|
1681
1715
|
return [4 /*yield*/, this.OCClient.getLWIDetails(this.requestId)];
|
1682
1716
|
case 2:
|
@@ -1686,7 +1720,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1686
1720
|
surveyInviteLinkRequest = {
|
1687
1721
|
"FormId": msfp_sourcesurveyidentifier,
|
1688
1722
|
"ConversationId": conversationId,
|
1689
|
-
"OCLocaleCode": locale_1.getLocaleStringFromId(localeId)
|
1723
|
+
"OCLocaleCode": locale_1.getLocaleStringFromId(this.localeId) || locale_1.getLocaleStringFromId(locale_1.defaultLocaleId)
|
1690
1724
|
};
|
1691
1725
|
optionalParams = {
|
1692
1726
|
"requestId": this.requestId
|
@@ -1749,102 +1783,6 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1749
1783
|
});
|
1750
1784
|
});
|
1751
1785
|
};
|
1752
|
-
OmnichannelChatSDK.prototype.initializePostChatRenderer = function () {
|
1753
|
-
return __awaiter(this, void 0, void 0, function () {
|
1754
|
-
var msfpEmbedScript, elm, scriptNodes, styleNodes, i, node, tmpNode, tmpNode, i, node, tmpNode;
|
1755
|
-
return __generator(this, function (_a) {
|
1756
|
-
if (!platform_1.isBrowser()) {
|
1757
|
-
return [2 /*return*/, Promise.reject("In-line rendering is only supported on web browsers")];
|
1758
|
-
}
|
1759
|
-
this.scenarioMarker.startScenario(TelemetryEvent_1.default.InitializePostChatRenderer, {
|
1760
|
-
RequestId: this.requestId
|
1761
|
-
});
|
1762
|
-
try {
|
1763
|
-
msfpEmbedScript = libraries_1.getMsfpEmbedScript();
|
1764
|
-
elm = document.createElement('div');
|
1765
|
-
elm.innerHTML = msfpEmbedScript;
|
1766
|
-
scriptNodes = elm.getElementsByTagName('script');
|
1767
|
-
styleNodes = elm.getElementsByTagName('link');
|
1768
|
-
for (i = 0; i < scriptNodes.length; i++) {
|
1769
|
-
node = scriptNodes[i];
|
1770
|
-
if (node.src) {
|
1771
|
-
tmpNode = document.createElement('script');
|
1772
|
-
tmpNode.type = node.type;
|
1773
|
-
tmpNode.src = node.src;
|
1774
|
-
tmpNode.async = false;
|
1775
|
-
if (!window.document.head.contains(tmpNode)) {
|
1776
|
-
document.getElementsByTagName('head')[0].appendChild(tmpNode);
|
1777
|
-
}
|
1778
|
-
}
|
1779
|
-
if (node.innerHTML) {
|
1780
|
-
tmpNode = document.createElement('script');
|
1781
|
-
tmpNode.innerHTML = node.innerHTML;
|
1782
|
-
tmpNode.async = false;
|
1783
|
-
if (!window.document.head.contains(tmpNode)) {
|
1784
|
-
window.document.head.appendChild(tmpNode);
|
1785
|
-
}
|
1786
|
-
}
|
1787
|
-
}
|
1788
|
-
for (i = 0; i < styleNodes.length; i++) {
|
1789
|
-
node = styleNodes[i];
|
1790
|
-
if (node.href) {
|
1791
|
-
tmpNode = document.createElement('link');
|
1792
|
-
tmpNode.type = node.type;
|
1793
|
-
tmpNode.rel = node.rel;
|
1794
|
-
tmpNode.href = node.href;
|
1795
|
-
if (!window.document.head.contains(tmpNode)) {
|
1796
|
-
document.getElementsByTagName('head')[0].appendChild(tmpNode);
|
1797
|
-
}
|
1798
|
-
}
|
1799
|
-
}
|
1800
|
-
}
|
1801
|
-
catch (ex) {
|
1802
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.InitializePostChatRenderer, {
|
1803
|
-
RequestId: this.requestId,
|
1804
|
-
ExceptionDetails: JSON.stringify(ex)
|
1805
|
-
});
|
1806
|
-
return [2 /*return*/, Promise.reject("Error occurred when initializer post chat renderer. " + JSON.stringify(ex))];
|
1807
|
-
}
|
1808
|
-
return [2 /*return*/];
|
1809
|
-
});
|
1810
|
-
});
|
1811
|
-
};
|
1812
|
-
OmnichannelChatSDK.prototype.renderPostChatSurvey = function (containerId, postChatContext) {
|
1813
|
-
return __awaiter(this, void 0, void 0, function () {
|
1814
|
-
var ex_2;
|
1815
|
-
return __generator(this, function (_a) {
|
1816
|
-
switch (_a.label) {
|
1817
|
-
case 0:
|
1818
|
-
if (!platform_1.isBrowser()) {
|
1819
|
-
return [2 /*return*/, Promise.reject("In-line rendering is only supported on web browsers")];
|
1820
|
-
}
|
1821
|
-
this.scenarioMarker.startScenario(TelemetryEvent_1.default.RenderPostChatSurvey, {
|
1822
|
-
RequestId: this.requestId
|
1823
|
-
});
|
1824
|
-
_a.label = 1;
|
1825
|
-
case 1:
|
1826
|
-
_a.trys.push([1, 3, , 4]);
|
1827
|
-
if (!postChatContext) {
|
1828
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.RenderPostChatSurvey, {
|
1829
|
-
RequestId: this.requestId,
|
1830
|
-
ExceptionDetails: "Post Chat Context is null."
|
1831
|
-
});
|
1832
|
-
return [2 /*return*/, Promise.reject("Post Chat Context is null.")];
|
1833
|
-
}
|
1834
|
-
return [4 /*yield*/, renderSurvey(containerId, postChatContext === null || postChatContext === void 0 ? void 0 : postChatContext.surveyInviteLink, "", "", postChatContext === null || postChatContext === void 0 ? void 0 : postChatContext.formsProLocale)];
|
1835
|
-
case 2: return [2 /*return*/, _a.sent()];
|
1836
|
-
case 3:
|
1837
|
-
ex_2 = _a.sent();
|
1838
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.RenderPostChatSurvey, {
|
1839
|
-
RequestId: this.requestId,
|
1840
|
-
ExceptionDetails: JSON.stringify(ex_2)
|
1841
|
-
});
|
1842
|
-
return [2 /*return*/, Promise.reject("Error occurred when rendering post chat survey. " + JSON.stringify(ex_2))];
|
1843
|
-
case 4: return [2 /*return*/];
|
1844
|
-
}
|
1845
|
-
});
|
1846
|
-
});
|
1847
|
-
};
|
1848
1786
|
OmnichannelChatSDK.prototype.getIC3Client = function () {
|
1849
1787
|
return __awaiter(this, void 0, void 0, function () {
|
1850
1788
|
var IC3Client;
|
@@ -1871,7 +1809,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1871
1809
|
this.debug && console.debug('IC3Client');
|
1872
1810
|
// Use IC3Client if browser is detected
|
1873
1811
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
1874
|
-
var ic3ClientCDNUrl;
|
1812
|
+
var ic3ClientCDNUrl, IC3Client;
|
1875
1813
|
var _this = this;
|
1876
1814
|
var _a;
|
1877
1815
|
return __generator(this, function (_b) {
|
@@ -1882,6 +1820,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1882
1820
|
IC3Client: ic3ClientCDNUrl
|
1883
1821
|
});
|
1884
1822
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetIC3Client);
|
1823
|
+
if (!this.IC3SDKProvider) return [3 /*break*/, 2];
|
1824
|
+
return [4 /*yield*/, this.IC3SDKProvider.getSDK({
|
1825
|
+
hostType: HostType_1.default.IFrame,
|
1826
|
+
protocolType: ProtocoleType_1.default.IC3V1SDK,
|
1827
|
+
logger: this.ic3ClientLogger // eslint-disable-line @typescript-eslint/no-explicit-any
|
1828
|
+
})];
|
1829
|
+
case 1:
|
1830
|
+
IC3Client = _b.sent();
|
1831
|
+
return [2 /*return*/, resolve(IC3Client)];
|
1832
|
+
case 2:
|
1885
1833
|
window.addEventListener("ic3:sdk:load", function () { return __awaiter(_this, void 0, void 0, function () {
|
1886
1834
|
var ic3sdk, IC3SDKProvider, IC3Client;
|
1887
1835
|
return __generator(this, function (_a) {
|
@@ -1918,7 +1866,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1918
1866
|
});
|
1919
1867
|
reject('Failed to load IC3Client');
|
1920
1868
|
})];
|
1921
|
-
case
|
1869
|
+
case 3:
|
1922
1870
|
_b.sent();
|
1923
1871
|
return [2 /*return*/];
|
1924
1872
|
}
|
@@ -1930,15 +1878,17 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1930
1878
|
};
|
1931
1879
|
OmnichannelChatSDK.prototype.getChatConfig = function () {
|
1932
1880
|
return __awaiter(this, void 0, void 0, function () {
|
1933
|
-
var liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled,
|
1934
|
-
return __generator(this, function (
|
1935
|
-
switch (
|
1881
|
+
var liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, chatWidgetLanguage, msdyn_localeid, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled, error_18;
|
1882
|
+
return __generator(this, function (_a) {
|
1883
|
+
switch (_a.label) {
|
1936
1884
|
case 0:
|
1937
|
-
|
1885
|
+
_a.trys.push([0, 4, , 5]);
|
1938
1886
|
return [4 /*yield*/, this.OCClient.getChatConfig()];
|
1939
1887
|
case 1:
|
1940
|
-
liveChatConfig =
|
1941
|
-
dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin, liveChatVersion = liveChatConfig.LiveChatVersion;
|
1888
|
+
liveChatConfig = _a.sent();
|
1889
|
+
dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin, liveChatVersion = liveChatConfig.LiveChatVersion, chatWidgetLanguage = liveChatConfig.ChatWidgetLanguage;
|
1890
|
+
msdyn_localeid = chatWidgetLanguage.msdyn_localeid;
|
1891
|
+
this.localeId = msdyn_localeid || locale_1.defaultLocaleId;
|
1942
1892
|
this.liveChatVersion = liveChatVersion || LiveChatVersion_1.default.V1;
|
1943
1893
|
/* istanbul ignore next */
|
1944
1894
|
this.debug && console.log("[OmnichannelChatSDK][getChatConfig][liveChatVersion] " + this.liveChatVersion);
|
@@ -1961,47 +1911,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1961
1911
|
if (isPreChatEnabled && preChatSurvey && preChatSurvey.trim().length > 0) {
|
1962
1912
|
this.preChatSurvey = preChatSurvey;
|
1963
1913
|
}
|
1964
|
-
if (!this.authSettings) return [3 /*break*/,
|
1965
|
-
this.
|
1966
|
-
if (!this.chatSDKConfig.getAuthToken) return [3 /*break*/, 6];
|
1967
|
-
_b.label = 2;
|
1914
|
+
if (!this.authSettings) return [3 /*break*/, 3];
|
1915
|
+
return [4 /*yield*/, this.setAuthTokenProvider(this.chatSDKConfig.getAuthToken)];
|
1968
1916
|
case 2:
|
1969
|
-
|
1970
|
-
|
1917
|
+
_a.sent();
|
1918
|
+
_a.label = 3;
|
1971
1919
|
case 3:
|
1972
|
-
token = _b.sent();
|
1973
|
-
if (token) {
|
1974
|
-
this.authenticatedUserToken = token;
|
1975
|
-
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetAuthToken);
|
1976
|
-
}
|
1977
|
-
else {
|
1978
|
-
exceptionDetails = {
|
1979
|
-
response: "UndefinedAuthToken"
|
1980
|
-
};
|
1981
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
1982
|
-
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1983
|
-
});
|
1984
|
-
}
|
1985
|
-
return [3 /*break*/, 5];
|
1986
|
-
case 4:
|
1987
|
-
_a = _b.sent();
|
1988
|
-
exceptionDetails = {
|
1989
|
-
response: "GetAuthTokenFailed"
|
1990
|
-
};
|
1991
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
1992
|
-
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1993
|
-
});
|
1994
|
-
return [3 /*break*/, 5];
|
1995
|
-
case 5: return [3 /*break*/, 7];
|
1996
|
-
case 6:
|
1997
|
-
exceptionDetails = {
|
1998
|
-
response: "GetAuthTokenNotFound"
|
1999
|
-
};
|
2000
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
2001
|
-
ExceptionDetails: JSON.stringify(exceptionDetails)
|
2002
|
-
});
|
2003
|
-
_b.label = 7;
|
2004
|
-
case 7:
|
2005
1920
|
if (this.preChatSurvey) {
|
2006
1921
|
/* istanbul ignore next */
|
2007
1922
|
this.debug && console.log('Prechat Survey!');
|
@@ -2009,11 +1924,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2009
1924
|
this.callingOption = msdyn_callingoptions;
|
2010
1925
|
this.liveChatConfig = liveChatConfig;
|
2011
1926
|
return [2 /*return*/, this.liveChatConfig];
|
2012
|
-
case
|
2013
|
-
error_18 =
|
1927
|
+
case 4:
|
1928
|
+
error_18 = _a.sent();
|
2014
1929
|
console.error("OmnichannelChatSDK/getChatConfig/error " + error_18);
|
2015
1930
|
return [2 /*return*/, error_18];
|
2016
|
-
case
|
1931
|
+
case 5: return [2 /*return*/];
|
2017
1932
|
}
|
2018
1933
|
});
|
2019
1934
|
});
|
@@ -2095,6 +2010,57 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2095
2010
|
});
|
2096
2011
|
});
|
2097
2012
|
};
|
2013
|
+
OmnichannelChatSDK.prototype.setAuthTokenProvider = function (provider) {
|
2014
|
+
return __awaiter(this, void 0, void 0, function () {
|
2015
|
+
var token, exceptionDetails, _a, exceptionDetails, exceptionDetails;
|
2016
|
+
return __generator(this, function (_b) {
|
2017
|
+
switch (_b.label) {
|
2018
|
+
case 0:
|
2019
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetAuthToken);
|
2020
|
+
this.chatSDKConfig.getAuthToken = provider;
|
2021
|
+
if (!this.chatSDKConfig.getAuthToken) return [3 /*break*/, 5];
|
2022
|
+
_b.label = 1;
|
2023
|
+
case 1:
|
2024
|
+
_b.trys.push([1, 3, , 4]);
|
2025
|
+
return [4 /*yield*/, this.chatSDKConfig.getAuthToken()];
|
2026
|
+
case 2:
|
2027
|
+
token = _b.sent();
|
2028
|
+
if (token) {
|
2029
|
+
this.authenticatedUserToken = token;
|
2030
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetAuthToken);
|
2031
|
+
}
|
2032
|
+
else {
|
2033
|
+
exceptionDetails = {
|
2034
|
+
response: "UndefinedAuthToken"
|
2035
|
+
};
|
2036
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
2037
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
2038
|
+
});
|
2039
|
+
}
|
2040
|
+
return [3 /*break*/, 4];
|
2041
|
+
case 3:
|
2042
|
+
_a = _b.sent();
|
2043
|
+
exceptionDetails = {
|
2044
|
+
response: "GetAuthTokenFailed"
|
2045
|
+
};
|
2046
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
2047
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
2048
|
+
});
|
2049
|
+
return [3 /*break*/, 4];
|
2050
|
+
case 4: return [3 /*break*/, 6];
|
2051
|
+
case 5:
|
2052
|
+
exceptionDetails = {
|
2053
|
+
response: "GetAuthTokenNotFound"
|
2054
|
+
};
|
2055
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
2056
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
2057
|
+
});
|
2058
|
+
_b.label = 6;
|
2059
|
+
case 6: return [2 /*return*/];
|
2060
|
+
}
|
2061
|
+
});
|
2062
|
+
});
|
2063
|
+
};
|
2098
2064
|
return OmnichannelChatSDK;
|
2099
2065
|
}());
|
2100
2066
|
exports.default = OmnichannelChatSDK;
|