@microsoft/omnichannel-chat-sdk 1.0.1-main.fa78d5f → 1.1.1-main.211b61c
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 +31 -4
- package/README.md +482 -306
- package/lib/OmnichannelChatSDK.d.ts +10 -6
- package/lib/OmnichannelChatSDK.js +333 -311
- package/lib/OmnichannelChatSDK.js.map +1 -1
- package/lib/api/createVoiceVideoCalling.js +6 -2
- package/lib/api/createVoiceVideoCalling.js.map +1 -1
- package/lib/config/settings.d.ts +1 -1
- package/lib/config/settings.js +1 -1
- package/lib/core/ChatConfig.d.ts +4 -0
- package/lib/core/ChatSDKExceptionDetails.d.ts +5 -0
- package/lib/core/ChatSDKExceptionDetails.js +3 -0
- package/lib/core/ChatSDKExceptionDetails.js.map +1 -0
- package/lib/core/ChatTranscriptBody.d.ts +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/LiveWorkItemDetails.d.ts +2 -0
- package/lib/core/OmnichannelErrorCodes.d.ts +4 -0
- package/lib/core/OmnichannelErrorCodes.js +8 -0
- package/lib/core/OmnichannelErrorCodes.js.map +1 -0
- package/lib/core/PostChatContext.d.ts +1 -0
- package/lib/core/StartChatOptionalParams.d.ts +1 -0
- 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/core/messaging/MessageTags.d.ts +2 -0
- package/lib/core/messaging/MessageTags.js +4 -2
- package/lib/core/messaging/MessageTags.js.map +1 -1
- package/lib/external/ACSAdapter/AMSFileManager.js +12 -0
- package/lib/external/ACSAdapter/AMSFileManager.js.map +1 -1
- package/lib/external/ACSAdapter/createChannelDataEgressMiddleware.d.ts +5 -0
- package/lib/external/ACSAdapter/createChannelDataEgressMiddleware.js +34 -0
- package/lib/external/ACSAdapter/createChannelDataEgressMiddleware.js.map +1 -0
- package/lib/external/CallingSDK/ICallingSDKLogData.d.ts +7 -0
- package/lib/external/CallingSDK/ICallingSDKLogData.js +3 -0
- package/lib/external/CallingSDK/ICallingSDKLogData.js.map +1 -0
- package/lib/external/IC3Adapter/IIC3AdapterOptions.d.ts +12 -0
- package/lib/index.d.ts +7 -6
- package/lib/index.js +13 -8
- package/lib/index.js.map +1 -1
- package/lib/telemetry/AriaTelemetry.d.ts +1 -0
- package/lib/telemetry/AriaTelemetry.js +55 -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/ScenarioType.d.ts +1 -0
- package/lib/telemetry/ScenarioType.js +1 -0
- package/lib/telemetry/ScenarioType.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 +201 -74
- 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 +2 -0
- package/lib/utils/locale.js +5 -3
- package/lib/utils/locale.js.map +1 -1
- package/lib/utils/loggers.d.ts +26 -1
- package/lib/utils/loggers.js +94 -2
- package/lib/utils/loggers.js.map +1 -1
- package/package.json +2 -2
@@ -58,7 +58,8 @@ 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
|
61
|
+
var locale_1 = require("./utils/locale");
|
62
|
+
var WebUtils_1 = require("./utils/WebUtils");
|
62
63
|
var platform_1 = require("./utils/platform");
|
63
64
|
var SDKConfigValidators_1 = require("./validators/SDKConfigValidators");
|
64
65
|
var ACSParticipantDisplayName_1 = require("./core/messaging/ACSParticipantDisplayName");
|
@@ -66,8 +67,6 @@ var AMSFileManager_1 = require("./external/ACSAdapter/AMSFileManager");
|
|
66
67
|
var CallingOptionsOptionSetNumber_1 = require("./core/CallingOptionsOptionSetNumber");
|
67
68
|
var ChatAdapterProtocols_1 = require("./core/messaging/ChatAdapterProtocols");
|
68
69
|
var ConversationMode_1 = require("./core/ConversationMode");
|
69
|
-
var createFormatEgressTagsMiddleware_1 = require("./external/ACSAdapter/createFormatEgressTagsMiddleware");
|
70
|
-
var createFormatIngressTagsMiddleware_1 = require("./external/ACSAdapter/createFormatIngressTagsMiddleware");
|
71
70
|
var DeliveryMode_1 = require("@microsoft/omnichannel-ic3core/lib/model/DeliveryMode");
|
72
71
|
var FileSharingProtocolType_1 = require("@microsoft/omnichannel-ic3core/lib/model/FileSharingProtocolType");
|
73
72
|
var HostType_1 = require("@microsoft/omnichannel-ic3core/lib/interfaces/HostType");
|
@@ -76,23 +75,26 @@ var LiveChatVersion_1 = require("./core/LiveChatVersion");
|
|
76
75
|
var LiveWorkItemState_1 = require("./core/LiveWorkItemState");
|
77
76
|
var MessageContentType_1 = require("@microsoft/omnichannel-ic3core/lib/model/MessageContentType");
|
78
77
|
var MessageType_1 = require("@microsoft/omnichannel-ic3core/lib/model/MessageType");
|
78
|
+
var OmnichannelErrorCodes_1 = require("./core/OmnichannelErrorCodes");
|
79
79
|
var PersonType_1 = require("@microsoft/omnichannel-ic3core/lib/model/PersonType");
|
80
80
|
var ProtocoleType_1 = require("@microsoft/omnichannel-ic3core/lib/interfaces/ProtocoleType");
|
81
81
|
var ScenarioMarker_1 = require("./telemetry/ScenarioMarker");
|
82
82
|
var TelemetryEvent_1 = require("./telemetry/TelemetryEvent");
|
83
83
|
var omnichannel_amsclient_1 = require("@microsoft/omnichannel-amsclient");
|
84
|
+
var createChannelDataEgressMiddleware_1 = require("./external/ACSAdapter/createChannelDataEgressMiddleware");
|
85
|
+
var createFormatEgressTagsMiddleware_1 = require("./external/ACSAdapter/createFormatEgressTagsMiddleware");
|
86
|
+
var createFormatIngressTagsMiddleware_1 = require("./external/ACSAdapter/createFormatIngressTagsMiddleware");
|
84
87
|
var createOmnichannelMessage_1 = require("./utils/createOmnichannelMessage");
|
85
88
|
var createTelemetry_1 = require("./utils/createTelemetry");
|
86
89
|
var createVoiceVideoCalling_1 = require("./api/createVoiceVideoCalling");
|
87
90
|
var MessageTags_1 = require("./core/messaging/MessageTags");
|
88
|
-
var locale_1 = require("./utils/locale");
|
89
91
|
var utilities_1 = require("./utils/utilities");
|
90
|
-
var
|
92
|
+
var libraries_1 = require("./utils/libraries");
|
91
93
|
var OmnichannelConfigValidator_1 = require("./validators/OmnichannelConfigValidator");
|
92
94
|
var OmnichannelChatSDK = /** @class */ (function () {
|
93
95
|
function OmnichannelChatSDK(omnichannelConfig, chatSDKConfig) {
|
94
96
|
if (chatSDKConfig === void 0) { chatSDKConfig = SDKConfigValidators_1.defaultChatSDKConfig; }
|
95
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
97
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
96
98
|
this.ACSClient = null;
|
97
99
|
this.AMSClient = null;
|
98
100
|
this.authSettings = null;
|
@@ -104,16 +106,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
104
106
|
this.ocSdkLogger = null;
|
105
107
|
this.acsClientLogger = null;
|
106
108
|
this.acsAdapterLogger = null;
|
109
|
+
this.callingSdkLogger = null;
|
107
110
|
this.isPersistentChat = false;
|
108
111
|
this.isChatReconnect = false;
|
109
112
|
this.reconnectId = null;
|
110
113
|
this.refreshTokenTimer = null;
|
111
114
|
this.debug = false;
|
115
|
+
this.runtimeId = ocsdk_1.uuidv4();
|
112
116
|
this.omnichannelConfig = omnichannelConfig;
|
113
117
|
this.chatSDKConfig = __assign(__assign({}, SDKConfigValidators_1.defaultChatSDKConfig), chatSDKConfig // overrides
|
114
118
|
);
|
115
119
|
this.isInitialized = false;
|
116
120
|
this.liveChatVersion = LiveChatVersion_1.default.V1;
|
121
|
+
this.localeId = locale_1.defaultLocaleId;
|
117
122
|
this.requestId = ocsdk_1.uuidv4();
|
118
123
|
this.chatToken = {};
|
119
124
|
this.liveChatConfig = {};
|
@@ -126,11 +131,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
126
131
|
this.ocSdkLogger = loggers_1.createOCSDKLogger(this.omnichannelConfig);
|
127
132
|
this.acsClientLogger = loggers_1.createACSClientLogger(this.omnichannelConfig);
|
128
133
|
this.acsAdapterLogger = loggers_1.createACSAdapterLogger(this.omnichannelConfig);
|
134
|
+
this.callingSdkLogger = loggers_1.createCallingSDKLogger(this.omnichannelConfig);
|
129
135
|
this.scenarioMarker.useTelemetry(this.telemetry);
|
130
136
|
this.ic3ClientLogger.useTelemetry(this.telemetry);
|
131
137
|
this.ocSdkLogger.useTelemetry(this.telemetry);
|
132
138
|
this.acsClientLogger.useTelemetry(this.telemetry);
|
133
139
|
this.acsAdapterLogger.useTelemetry(this.telemetry);
|
140
|
+
this.callingSdkLogger.useTelemetry(this.telemetry);
|
141
|
+
this.scenarioMarker.setRuntimeId(this.runtimeId);
|
142
|
+
this.ic3ClientLogger.setRuntimeId(this.runtimeId);
|
143
|
+
this.ocSdkLogger.setRuntimeId(this.runtimeId);
|
144
|
+
this.acsClientLogger.setRuntimeId(this.runtimeId);
|
145
|
+
this.acsAdapterLogger.setRuntimeId(this.runtimeId);
|
146
|
+
this.callingSdkLogger.setRuntimeId(this.runtimeId);
|
134
147
|
OmnichannelConfigValidator_1.default(omnichannelConfig);
|
135
148
|
SDKConfigValidators_1.default(chatSDKConfig);
|
136
149
|
((_a = this.chatSDKConfig.telemetry) === null || _a === void 0 ? void 0 : _a.disable) && ((_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.disable());
|
@@ -141,10 +154,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
141
154
|
(_e = this.ocSdkLogger) === null || _e === void 0 ? void 0 : _e.setRequestId(this.requestId);
|
142
155
|
(_f = this.acsClientLogger) === null || _f === void 0 ? void 0 : _f.setRequestId(this.requestId);
|
143
156
|
(_g = this.acsAdapterLogger) === null || _g === void 0 ? void 0 : _g.setRequestId(this.requestId);
|
157
|
+
(_h = this.callingSdkLogger) === null || _h === void 0 ? void 0 : _h.setRequestId(this.requestId);
|
144
158
|
}
|
145
159
|
/* istanbul ignore next */
|
146
160
|
OmnichannelChatSDK.prototype.setDebug = function (flag) {
|
147
|
-
var _a, _b, _c, _d, _e, _f;
|
161
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
148
162
|
this.debug = flag;
|
149
163
|
(_a = this.AMSClient) === null || _a === void 0 ? void 0 : _a.setDebug(flag);
|
150
164
|
(_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.setDebug(flag);
|
@@ -153,10 +167,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
153
167
|
(_d = this.ocSdkLogger) === null || _d === void 0 ? void 0 : _d.setDebug(flag);
|
154
168
|
(_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setDebug(flag);
|
155
169
|
(_f = this.acsAdapterLogger) === null || _f === void 0 ? void 0 : _f.setDebug(flag);
|
170
|
+
(_g = this.callingSdkLogger) === null || _g === void 0 ? void 0 : _g.setDebug(flag);
|
156
171
|
};
|
157
|
-
OmnichannelChatSDK.prototype.initialize = function () {
|
172
|
+
OmnichannelChatSDK.prototype.initialize = function (optionalParams) {
|
173
|
+
if (optionalParams === void 0) { optionalParams = {}; }
|
158
174
|
return __awaiter(this, void 0, void 0, function () {
|
159
|
-
var _a, _b, _c, _d;
|
175
|
+
var _a, getLiveChatConfigOptionalParams, _b, _c, _d;
|
160
176
|
return __generator(this, function (_e) {
|
161
177
|
switch (_e.label) {
|
162
178
|
case 0:
|
@@ -173,7 +189,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
173
189
|
return [4 /*yield*/, ocsdk_1.SDKProvider.getSDK(this.omnichannelConfig, {}, this.ocSdkLogger)];
|
174
190
|
case 2:
|
175
191
|
_a.OCClient = _e.sent();
|
176
|
-
|
192
|
+
getLiveChatConfigOptionalParams = optionalParams.getLiveChatConfigOptionalParams;
|
193
|
+
return [4 /*yield*/, this.getChatConfig(getLiveChatConfigOptionalParams || {})];
|
177
194
|
case 3:
|
178
195
|
_e.sent();
|
179
196
|
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 5];
|
@@ -291,47 +308,55 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
291
308
|
});
|
292
309
|
};
|
293
310
|
OmnichannelChatSDK.prototype.startChat = function (optionalParams) {
|
294
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
311
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
295
312
|
if (optionalParams === void 0) { optionalParams = {}; }
|
296
313
|
return __awaiter(this, void 0, void 0, function () {
|
297
|
-
var reconnectableChatsParams, reconnectableChatsResponse,
|
314
|
+
var shouldReinitIC3Client, _t, reconnectableChatsParams, reconnectableChatsResponse, _u, exceptionDetails, conversationDetails, exceptionDetails, exceptionDetails, sessionInitOptionalParams, exceptionDetails, error_3, exceptionDetails, chatAdapterConfig, error_4, exceptionDetails, _v, error_5, exceptionDetails, error_6, exceptionDetails, error_7, exceptionDetails, _w, error_8, exceptionDetails;
|
298
315
|
var _this = this;
|
299
|
-
return __generator(this, function (
|
300
|
-
switch (
|
316
|
+
return __generator(this, function (_x) {
|
317
|
+
switch (_x.label) {
|
301
318
|
case 0:
|
302
319
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.StartChat, {
|
303
320
|
RequestId: this.requestId
|
304
321
|
});
|
322
|
+
shouldReinitIC3Client = !platform_1.default.isNode() && !platform_1.default.isReactNative() && !this.IC3Client && this.liveChatVersion === LiveChatVersion_1.default.V1;
|
323
|
+
if (!shouldReinitIC3Client) return [3 /*break*/, 2];
|
324
|
+
_t = this;
|
325
|
+
return [4 /*yield*/, this.getIC3Client()];
|
326
|
+
case 1:
|
327
|
+
_t.IC3Client = _x.sent();
|
328
|
+
_x.label = 2;
|
329
|
+
case 2:
|
305
330
|
if (this.isChatReconnect && !((_a = this.chatSDKConfig.chatReconnect) === null || _a === void 0 ? void 0 : _a.disable) && !this.isPersistentChat && optionalParams.reconnectId) {
|
306
331
|
this.reconnectId = optionalParams.reconnectId;
|
307
332
|
}
|
308
|
-
if (!(this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable))) return [3 /*break*/,
|
309
|
-
|
310
|
-
case
|
311
|
-
|
333
|
+
if (!(this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable))) return [3 /*break*/, 6];
|
334
|
+
_x.label = 3;
|
335
|
+
case 3:
|
336
|
+
_x.trys.push([3, 5, , 6]);
|
312
337
|
reconnectableChatsParams = {
|
313
338
|
authenticatedUserToken: this.authenticatedUserToken
|
314
339
|
};
|
315
340
|
return [4 /*yield*/, this.OCClient.getReconnectableChats(reconnectableChatsParams)];
|
316
|
-
case
|
317
|
-
reconnectableChatsResponse =
|
341
|
+
case 4:
|
342
|
+
reconnectableChatsResponse = _x.sent();
|
318
343
|
if (reconnectableChatsResponse && reconnectableChatsResponse.reconnectid) {
|
319
344
|
this.reconnectId = reconnectableChatsResponse.reconnectid;
|
320
345
|
}
|
321
|
-
return [3 /*break*/,
|
322
|
-
case
|
323
|
-
|
346
|
+
return [3 /*break*/, 6];
|
347
|
+
case 5:
|
348
|
+
_u = _x.sent();
|
324
349
|
exceptionDetails = {
|
325
350
|
response: "OCClientGetReconnectableChatsFailed"
|
326
351
|
};
|
327
352
|
throw Error(exceptionDetails.response);
|
328
|
-
case
|
329
|
-
if (!(optionalParams.liveChatContext && !this.
|
353
|
+
case 6:
|
354
|
+
if (!(optionalParams.liveChatContext && !this.reconnectId)) return [3 /*break*/, 8];
|
330
355
|
this.chatToken = optionalParams.liveChatContext.chatToken || {};
|
331
356
|
this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
|
332
357
|
return [4 /*yield*/, this.getConversationDetails()];
|
333
|
-
case
|
334
|
-
conversationDetails =
|
358
|
+
case 7:
|
359
|
+
conversationDetails = _x.sent();
|
335
360
|
if (Object.keys(conversationDetails).length === 0) {
|
336
361
|
exceptionDetails = {
|
337
362
|
response: "InvalidConversation"
|
@@ -356,25 +381,27 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
356
381
|
console.error("Unable to join conversation that's in '" + conversationDetails.state + "' state");
|
357
382
|
throw Error(exceptionDetails.response);
|
358
383
|
}
|
359
|
-
|
360
|
-
case 6:
|
361
|
-
if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 8];
|
362
|
-
return [4 /*yield*/, this.getChatToken(false)];
|
363
|
-
case 7:
|
364
|
-
_s.sent();
|
365
|
-
_s.label = 8;
|
384
|
+
_x.label = 8;
|
366
385
|
case 8:
|
386
|
+
if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 10];
|
387
|
+
return [4 /*yield*/, this.getChatToken(false)];
|
388
|
+
case 9:
|
389
|
+
_x.sent();
|
390
|
+
_x.label = 10;
|
391
|
+
case 10:
|
367
392
|
(_c = this.ic3ClientLogger) === null || _c === void 0 ? void 0 : _c.setChatId(this.chatToken.chatId || '');
|
368
393
|
(_d = this.ocSdkLogger) === null || _d === void 0 ? void 0 : _d.setChatId(this.chatToken.chatId || '');
|
369
394
|
(_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setChatId(this.chatToken.chatId || '');
|
370
395
|
(_f = this.acsAdapterLogger) === null || _f === void 0 ? void 0 : _f.setChatId(this.chatToken.chatId || '');
|
396
|
+
(_g = this.callingSdkLogger) === null || _g === void 0 ? void 0 : _g.setChatId(this.chatToken.chatId || '');
|
371
397
|
sessionInitOptionalParams = {
|
372
398
|
initContext: {}
|
373
399
|
};
|
374
|
-
|
400
|
+
sessionInitOptionalParams.initContext.locale = locale_1.getLocaleStringFromId(this.localeId);
|
401
|
+
if (this.isPersistentChat && !((_h = this.chatSDKConfig.persistentChat) === null || _h === void 0 ? void 0 : _h.disable)) {
|
375
402
|
sessionInitOptionalParams.reconnectId = this.reconnectId;
|
376
403
|
}
|
377
|
-
if (this.isChatReconnect && !((
|
404
|
+
if (this.isChatReconnect && !((_j = this.chatSDKConfig.chatReconnect) === null || _j === void 0 ? void 0 : _j.disable) && !this.isPersistentChat) {
|
378
405
|
sessionInitOptionalParams.reconnectId = this.reconnectId;
|
379
406
|
}
|
380
407
|
if (optionalParams.customContext) {
|
@@ -395,6 +422,22 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
395
422
|
if (optionalParams.preChatResponse) {
|
396
423
|
sessionInitOptionalParams.initContext.preChatResponse = optionalParams.preChatResponse;
|
397
424
|
}
|
425
|
+
if (optionalParams.sendDefaultInitContext) {
|
426
|
+
if (platform_1.default.isNode() || platform_1.default.isReactNative()) {
|
427
|
+
exceptionDetails = {
|
428
|
+
response: "UnsupportedPlatform",
|
429
|
+
message: "sendDefaultInitContext is only supported on browser"
|
430
|
+
};
|
431
|
+
console.error(exceptionDetails.message);
|
432
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
|
433
|
+
RequestId: this.requestId,
|
434
|
+
ChatId: this.chatToken.chatId,
|
435
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
436
|
+
});
|
437
|
+
throw new Error(exceptionDetails.response);
|
438
|
+
}
|
439
|
+
sessionInitOptionalParams.getContext = true;
|
440
|
+
}
|
398
441
|
// Override initContext completely
|
399
442
|
if (optionalParams.initContext) {
|
400
443
|
sessionInitOptionalParams.initContext = optionalParams.initContext;
|
@@ -402,27 +445,33 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
402
445
|
if (this.authenticatedUserToken) {
|
403
446
|
sessionInitOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
404
447
|
}
|
405
|
-
|
406
|
-
|
407
|
-
_s.trys.push([9, 11, , 12]);
|
408
|
-
return [4 /*yield*/, this.OCClient.sessionInit(this.requestId, sessionInitOptionalParams)];
|
409
|
-
case 10:
|
410
|
-
_s.sent();
|
411
|
-
return [3 /*break*/, 12];
|
448
|
+
if (!!optionalParams.liveChatContext) return [3 /*break*/, 14];
|
449
|
+
_x.label = 11;
|
412
450
|
case 11:
|
413
|
-
|
451
|
+
_x.trys.push([11, 13, , 14]);
|
452
|
+
return [4 /*yield*/, this.OCClient.sessionInit(this.requestId, sessionInitOptionalParams)];
|
453
|
+
case 12:
|
454
|
+
_x.sent();
|
455
|
+
return [3 /*break*/, 14];
|
456
|
+
case 13:
|
457
|
+
error_3 = _x.sent();
|
414
458
|
exceptionDetails = {
|
415
459
|
response: "OCClientSessionInitFailed"
|
416
460
|
};
|
461
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
462
|
+
if (((_k = error_3) === null || _k === void 0 ? void 0 : _k.isAxiosError) && ((_m = (_l = error_3.response) === null || _l === void 0 ? void 0 : _l.headers) === null || _m === void 0 ? void 0 : _m.errorcode.toString()) === OmnichannelErrorCodes_1.default.WidgetUseOutsideOperatingHour.toString()) {
|
463
|
+
exceptionDetails.response = OmnichannelErrorCodes_1.default[OmnichannelErrorCodes_1.default.WidgetUseOutsideOperatingHour].toString();
|
464
|
+
exceptionDetails.message = 'Widget used outside of operating hours';
|
465
|
+
console.error(exceptionDetails.message);
|
466
|
+
}
|
417
467
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
|
418
468
|
RequestId: this.requestId,
|
419
469
|
ChatId: this.chatToken.chatId,
|
420
470
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
421
471
|
});
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 23];
|
472
|
+
throw new Error(exceptionDetails.response);
|
473
|
+
case 14:
|
474
|
+
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 25];
|
426
475
|
chatAdapterConfig = {
|
427
476
|
token: this.chatToken.token,
|
428
477
|
id: this.chatToken.visitorId || 'teamsvisitor',
|
@@ -430,18 +479,18 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
430
479
|
environmentUrl: this.chatToken.acsEndpoint,
|
431
480
|
pollingInterval: 1000
|
432
481
|
};
|
433
|
-
|
434
|
-
case
|
435
|
-
|
436
|
-
return [4 /*yield*/, ((
|
482
|
+
_x.label = 15;
|
483
|
+
case 15:
|
484
|
+
_x.trys.push([15, 17, , 18]);
|
485
|
+
return [4 /*yield*/, ((_o = this.ACSClient) === null || _o === void 0 ? void 0 : _o.initialize({
|
437
486
|
token: chatAdapterConfig.token,
|
438
487
|
environmentUrl: chatAdapterConfig.environmentUrl
|
439
488
|
}))];
|
440
|
-
case
|
441
|
-
|
442
|
-
return [3 /*break*/,
|
443
|
-
case
|
444
|
-
error_4 =
|
489
|
+
case 16:
|
490
|
+
_x.sent();
|
491
|
+
return [3 /*break*/, 18];
|
492
|
+
case 17:
|
493
|
+
error_4 = _x.sent();
|
445
494
|
exceptionDetails = {
|
446
495
|
response: "ACSClientInitializeFailed"
|
447
496
|
};
|
@@ -452,23 +501,23 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
452
501
|
});
|
453
502
|
console.error("OmnichannelChatSDK/startChat/initialize/error " + error_4);
|
454
503
|
return [2 /*return*/, error_4];
|
455
|
-
case
|
456
|
-
|
457
|
-
|
458
|
-
return [4 /*yield*/, ((
|
504
|
+
case 18:
|
505
|
+
_x.trys.push([18, 20, , 21]);
|
506
|
+
_v = this;
|
507
|
+
return [4 /*yield*/, ((_p = this.ACSClient) === null || _p === void 0 ? void 0 : _p.joinConversation({
|
459
508
|
id: chatAdapterConfig.id,
|
460
509
|
threadId: chatAdapterConfig.threadId,
|
461
510
|
pollingInterval: chatAdapterConfig.pollingInterval
|
462
511
|
}))];
|
463
|
-
case
|
464
|
-
|
512
|
+
case 19:
|
513
|
+
_v.conversation = (_x.sent());
|
465
514
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
|
466
515
|
RequestId: this.requestId,
|
467
516
|
ChatId: this.chatToken.chatId
|
468
517
|
});
|
469
|
-
return [3 /*break*/,
|
470
|
-
case
|
471
|
-
error_5 =
|
518
|
+
return [3 /*break*/, 21];
|
519
|
+
case 20:
|
520
|
+
error_5 = _x.sent();
|
472
521
|
exceptionDetails = {
|
473
522
|
response: "ACSClientJoinConversationFailed"
|
474
523
|
};
|
@@ -479,16 +528,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
479
528
|
});
|
480
529
|
console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_5);
|
481
530
|
throw Error(exceptionDetails.response);
|
482
|
-
case
|
483
|
-
|
484
|
-
return [4 /*yield*/, ((
|
531
|
+
case 21:
|
532
|
+
_x.trys.push([21, 23, , 24]);
|
533
|
+
return [4 /*yield*/, ((_q = this.AMSClient) === null || _q === void 0 ? void 0 : _q.initialize({
|
485
534
|
chatToken: this.chatToken
|
486
535
|
}))];
|
487
|
-
case
|
488
|
-
|
489
|
-
return [3 /*break*/,
|
490
|
-
case
|
491
|
-
error_6 =
|
536
|
+
case 22:
|
537
|
+
_x.sent();
|
538
|
+
return [3 /*break*/, 24];
|
539
|
+
case 23:
|
540
|
+
error_6 = _x.sent();
|
492
541
|
exceptionDetails = {
|
493
542
|
response: "AMSClientInitializeFailed"
|
494
543
|
};
|
@@ -498,19 +547,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
498
547
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
499
548
|
});
|
500
549
|
throw Error(exceptionDetails.response);
|
501
|
-
case
|
502
|
-
case
|
503
|
-
|
550
|
+
case 24: return [3 /*break*/, 31];
|
551
|
+
case 25:
|
552
|
+
_x.trys.push([25, 27, , 28]);
|
504
553
|
return [4 /*yield*/, this.IC3Client.initialize({
|
505
554
|
token: this.chatToken.token,
|
506
555
|
regionGtms: this.chatToken.regionGTMS,
|
507
556
|
visitor: true
|
508
557
|
})];
|
509
|
-
case
|
510
|
-
|
511
|
-
return [3 /*break*/,
|
512
|
-
case
|
513
|
-
error_7 =
|
558
|
+
case 26:
|
559
|
+
_x.sent();
|
560
|
+
return [3 /*break*/, 28];
|
561
|
+
case 27:
|
562
|
+
error_7 = _x.sent();
|
514
563
|
exceptionDetails = {
|
515
564
|
response: "IC3ClientInitializeFailed"
|
516
565
|
};
|
@@ -521,19 +570,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
521
570
|
});
|
522
571
|
console.error("OmnichannelChatSDK/startChat/initialize/error " + error_7);
|
523
572
|
return [2 /*return*/, error_7];
|
524
|
-
case
|
525
|
-
|
526
|
-
|
573
|
+
case 28:
|
574
|
+
_x.trys.push([28, 30, , 31]);
|
575
|
+
_w = this;
|
527
576
|
return [4 /*yield*/, this.IC3Client.joinConversation(this.chatToken.chatId)];
|
528
|
-
case
|
529
|
-
|
577
|
+
case 29:
|
578
|
+
_w.conversation = _x.sent();
|
530
579
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
|
531
580
|
RequestId: this.requestId,
|
532
581
|
ChatId: this.chatToken.chatId
|
533
582
|
});
|
534
|
-
return [3 /*break*/,
|
535
|
-
case
|
536
|
-
error_8 =
|
583
|
+
return [3 /*break*/, 31];
|
584
|
+
case 30:
|
585
|
+
error_8 = _x.sent();
|
537
586
|
exceptionDetails = {
|
538
587
|
response: "IC3ClientJoinConversationFailed"
|
539
588
|
};
|
@@ -544,8 +593,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
544
593
|
});
|
545
594
|
console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_8);
|
546
595
|
return [2 /*return*/, error_8];
|
547
|
-
case
|
548
|
-
if (this.isPersistentChat && !((
|
596
|
+
case 31:
|
597
|
+
if (this.isPersistentChat && !((_r = this.chatSDKConfig.persistentChat) === null || _r === void 0 ? void 0 : _r.disable)) {
|
549
598
|
this.refreshTokenTimer = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
550
599
|
return __generator(this, function (_a) {
|
551
600
|
switch (_a.label) {
|
@@ -556,7 +605,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
556
605
|
return [2 /*return*/];
|
557
606
|
}
|
558
607
|
});
|
559
|
-
}); }, (
|
608
|
+
}); }, (_s = this.chatSDKConfig.persistentChat) === null || _s === void 0 ? void 0 : _s.tokenUpdateTime);
|
560
609
|
}
|
561
610
|
return [2 /*return*/];
|
562
611
|
}
|
@@ -564,11 +613,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
564
613
|
});
|
565
614
|
};
|
566
615
|
OmnichannelChatSDK.prototype.endChat = function () {
|
567
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
616
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
568
617
|
return __awaiter(this, void 0, void 0, function () {
|
569
618
|
var sessionCloseOptionalParams, isReconnectChat, isChatReconnect, error_9, exceptionDetails;
|
570
|
-
return __generator(this, function (
|
571
|
-
switch (
|
619
|
+
return __generator(this, function (_p) {
|
620
|
+
switch (_p.label) {
|
572
621
|
case 0:
|
573
622
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.EndChat, {
|
574
623
|
RequestId: this.requestId,
|
@@ -582,17 +631,18 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
582
631
|
}
|
583
632
|
if (this.isChatReconnect && !((_b = this.chatSDKConfig.chatReconnect) === null || _b === void 0 ? void 0 : _b.disable) && !this.isPersistentChat) {
|
584
633
|
isChatReconnect = this.reconnectId !== null ? true : false;
|
634
|
+
this.requestId = isChatReconnect ? this.reconnectId : this.requestId; // Chat Reconnect session to close
|
585
635
|
sessionCloseOptionalParams.isReconnectChat = isChatReconnect;
|
586
636
|
}
|
587
637
|
if (this.authenticatedUserToken) {
|
588
638
|
sessionCloseOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
589
639
|
}
|
590
|
-
|
640
|
+
_p.label = 1;
|
591
641
|
case 1:
|
592
|
-
|
642
|
+
_p.trys.push([1, 3, , 4]);
|
593
643
|
return [4 /*yield*/, this.OCClient.sessionClose(this.requestId, sessionCloseOptionalParams)];
|
594
644
|
case 2:
|
595
|
-
|
645
|
+
_p.sent();
|
596
646
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.EndChat, {
|
597
647
|
RequestId: this.requestId,
|
598
648
|
ChatId: this.chatToken.chatId
|
@@ -602,6 +652,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
602
652
|
this.requestId = ocsdk_1.uuidv4();
|
603
653
|
this.chatToken = {};
|
604
654
|
this.reconnectId = null;
|
655
|
+
if (this.IC3Client) {
|
656
|
+
this.IC3Client.dispose();
|
657
|
+
!platform_1.default.isNode() && !platform_1.default.isReactNative() && WebUtils_1.removeElementById(this.IC3Client.id);
|
658
|
+
this.IC3Client = null;
|
659
|
+
}
|
605
660
|
(_d = this.ic3ClientLogger) === null || _d === void 0 ? void 0 : _d.setRequestId(this.requestId);
|
606
661
|
(_e = this.ic3ClientLogger) === null || _e === void 0 ? void 0 : _e.setChatId('');
|
607
662
|
(_f = this.ocSdkLogger) === null || _f === void 0 ? void 0 : _f.setRequestId(this.requestId);
|
@@ -610,9 +665,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
610
665
|
(_j = this.acsClientLogger) === null || _j === void 0 ? void 0 : _j.setChatId('');
|
611
666
|
(_k = this.acsAdapterLogger) === null || _k === void 0 ? void 0 : _k.setRequestId(this.requestId);
|
612
667
|
(_l = this.acsAdapterLogger) === null || _l === void 0 ? void 0 : _l.setChatId('');
|
668
|
+
(_m = this.callingSdkLogger) === null || _m === void 0 ? void 0 : _m.setRequestId(this.requestId);
|
669
|
+
(_o = this.callingSdkLogger) === null || _o === void 0 ? void 0 : _o.setChatId('');
|
613
670
|
return [3 /*break*/, 4];
|
614
671
|
case 3:
|
615
|
-
error_9 =
|
672
|
+
error_9 = _p.sent();
|
616
673
|
exceptionDetails = {
|
617
674
|
response: "OCClientSessionCloseFailed"
|
618
675
|
};
|
@@ -663,23 +720,33 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
663
720
|
});
|
664
721
|
};
|
665
722
|
OmnichannelChatSDK.prototype.getConversationDetails = function () {
|
666
|
-
var _a, _b;
|
723
|
+
var _a, _b, _c, _d;
|
667
724
|
return __awaiter(this, void 0, void 0, function () {
|
668
|
-
var lwiDetails, state, conversationId, agentAcceptedOn, liveWorkItemDetails, error_10;
|
669
|
-
return __generator(this, function (
|
670
|
-
switch (
|
725
|
+
var getLWIDetailsOptionalParams, lwiDetails, state, conversationId, agentAcceptedOn, canRenderPostChat, participantType, liveWorkItemDetails, error_10;
|
726
|
+
return __generator(this, function (_e) {
|
727
|
+
switch (_e.label) {
|
671
728
|
case 0:
|
672
729
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetConversationDetails, {
|
673
730
|
RequestId: this.requestId,
|
674
731
|
ChatId: ((_a = this.chatToken) === null || _a === void 0 ? void 0 : _a.chatId) || '',
|
675
732
|
});
|
676
|
-
|
733
|
+
getLWIDetailsOptionalParams = {};
|
734
|
+
if (this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable) && this.reconnectId) {
|
735
|
+
getLWIDetailsOptionalParams.reconnectId = this.reconnectId;
|
736
|
+
}
|
737
|
+
if (this.isChatReconnect && !((_c = this.chatSDKConfig.chatReconnect) === null || _c === void 0 ? void 0 : _c.disable) && !this.isPersistentChat && this.reconnectId) {
|
738
|
+
getLWIDetailsOptionalParams.reconnectId = this.reconnectId;
|
739
|
+
}
|
740
|
+
if (this.authenticatedUserToken) {
|
741
|
+
getLWIDetailsOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
742
|
+
}
|
743
|
+
_e.label = 1;
|
677
744
|
case 1:
|
678
|
-
|
679
|
-
return [4 /*yield*/, this.OCClient.getLWIDetails(this.requestId)];
|
745
|
+
_e.trys.push([1, 3, , 4]);
|
746
|
+
return [4 /*yield*/, this.OCClient.getLWIDetails(this.requestId, getLWIDetailsOptionalParams)];
|
680
747
|
case 2:
|
681
|
-
lwiDetails =
|
682
|
-
state = lwiDetails.State, conversationId = lwiDetails.ConversationId, agentAcceptedOn = lwiDetails.AgentAcceptedOn;
|
748
|
+
lwiDetails = _e.sent();
|
749
|
+
state = lwiDetails.State, conversationId = lwiDetails.ConversationId, agentAcceptedOn = lwiDetails.AgentAcceptedOn, canRenderPostChat = lwiDetails.CanRenderPostChat, participantType = lwiDetails.ParticipantType;
|
683
750
|
liveWorkItemDetails = {
|
684
751
|
state: state,
|
685
752
|
conversationId: conversationId
|
@@ -687,13 +754,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
687
754
|
if (agentAcceptedOn) {
|
688
755
|
liveWorkItemDetails.agentAcceptedOn = agentAcceptedOn;
|
689
756
|
}
|
757
|
+
if (canRenderPostChat) {
|
758
|
+
liveWorkItemDetails.canRenderPostChat = canRenderPostChat;
|
759
|
+
}
|
760
|
+
if (participantType) {
|
761
|
+
liveWorkItemDetails.participantType = participantType;
|
762
|
+
}
|
690
763
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetConversationDetails, {
|
691
764
|
RequestId: this.requestId,
|
692
|
-
ChatId: ((
|
765
|
+
ChatId: ((_d = this.chatToken) === null || _d === void 0 ? void 0 : _d.chatId) || '',
|
693
766
|
});
|
694
767
|
return [2 /*return*/, liveWorkItemDetails];
|
695
768
|
case 3:
|
696
|
-
error_10 =
|
769
|
+
error_10 = _e.sent();
|
697
770
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetConversationDetails, {
|
698
771
|
RequestId: this.requestId,
|
699
772
|
ChatId: this.chatToken.chatId || '',
|
@@ -727,14 +800,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
727
800
|
});
|
728
801
|
});
|
729
802
|
};
|
730
|
-
OmnichannelChatSDK.prototype.getLiveChatConfig = function (
|
731
|
-
if (cached === void 0) { cached = true; }
|
803
|
+
OmnichannelChatSDK.prototype.getLiveChatConfig = function (optionalParams) {
|
732
804
|
return __awaiter(this, void 0, void 0, function () {
|
733
805
|
return __generator(this, function (_a) {
|
734
|
-
if (
|
806
|
+
if (!optionalParams || optionalParams.useRuntimeCache === true) {
|
735
807
|
return [2 /*return*/, this.liveChatConfig];
|
736
808
|
}
|
737
|
-
return [2 /*return*/, this.getChatConfig()];
|
809
|
+
return [2 /*return*/, this.getChatConfig({ sendCacheHeaders: (optionalParams === null || optionalParams === void 0 ? void 0 : optionalParams.sendCacheHeaders) || false })];
|
738
810
|
});
|
739
811
|
});
|
740
812
|
};
|
@@ -1449,7 +1521,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1449
1521
|
ChatId: this.chatToken.chatId,
|
1450
1522
|
EmailAddress: body.emailAddress,
|
1451
1523
|
DefaultAttachmentMessage: body.attachmentMessage,
|
1452
|
-
CustomerLocale: body.locale
|
1524
|
+
CustomerLocale: body.locale || locale_1.getLocaleStringFromId(this.localeId)
|
1453
1525
|
};
|
1454
1526
|
emailResponse = this.OCClient.emailTranscript(this.requestId, this.chatToken.token, emailRequestBody, emailTranscriptOptionalParams);
|
1455
1527
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.EmailLiveChatTranscript, {
|
@@ -1499,36 +1571,36 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1499
1571
|
});
|
1500
1572
|
});
|
1501
1573
|
};
|
1502
|
-
OmnichannelChatSDK.prototype.createChatAdapter = function (
|
1503
|
-
if (
|
1574
|
+
OmnichannelChatSDK.prototype.createChatAdapter = function (optionalParams) {
|
1575
|
+
if (optionalParams === void 0) { optionalParams = {}; }
|
1504
1576
|
return __awaiter(this, void 0, void 0, function () {
|
1505
|
-
var supportedChatAdapterProtocols;
|
1577
|
+
var protocol, supportedChatAdapterProtocols;
|
1506
1578
|
var _this = this;
|
1507
1579
|
return __generator(this, function (_a) {
|
1508
1580
|
if (platform_1.default.isNode() || platform_1.default.isReactNative()) {
|
1509
1581
|
return [2 /*return*/, Promise.reject('ChatAdapter is only supported on browser')];
|
1510
1582
|
}
|
1583
|
+
protocol = optionalParams.protocol;
|
1511
1584
|
supportedChatAdapterProtocols = [ChatAdapterProtocols_1.default.ACS, ChatAdapterProtocols_1.default.IC3];
|
1512
1585
|
if (protocol && !supportedChatAdapterProtocols.includes(protocol)) {
|
1513
1586
|
return [2 /*return*/, Promise.reject("ChatAdapter for protocol " + protocol + " currently not supported")];
|
1514
1587
|
}
|
1515
1588
|
if (protocol === ChatAdapterProtocols_1.default.ACS || this.liveChatVersion === LiveChatVersion_1.default.V2) {
|
1516
1589
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
1517
|
-
var
|
1590
|
+
var options, defaultEgressMiddlewares, defaultIngressMiddlewares, egressMiddleware, ingressMiddleware, featuresOption, acsAdapterCDNUrl;
|
1518
1591
|
var _this = this;
|
1519
1592
|
var _a;
|
1520
1593
|
return __generator(this, function (_b) {
|
1521
1594
|
switch (_b.label) {
|
1522
1595
|
case 0:
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
1530
|
-
|
1531
|
-
};
|
1596
|
+
options = optionalParams.ACSAdapter ? optionalParams.ACSAdapter.options : {};
|
1597
|
+
defaultEgressMiddlewares = [createChannelDataEgressMiddleware_1.default({ widgetId: this.omnichannelConfig.widgetId }), createFormatEgressTagsMiddleware_1.default()];
|
1598
|
+
defaultIngressMiddlewares = [createFormatIngressTagsMiddleware_1.default()];
|
1599
|
+
egressMiddleware = (options === null || options === void 0 ? void 0 : options.egressMiddleware) ? __spreadArrays(options.egressMiddleware, defaultEgressMiddlewares) : __spreadArrays(defaultEgressMiddlewares);
|
1600
|
+
ingressMiddleware = (options === null || options === void 0 ? void 0 : options.ingressMiddleware) ? __spreadArrays(options.egressMiddleware, defaultIngressMiddlewares) : __spreadArrays(defaultIngressMiddlewares);
|
1601
|
+
featuresOption = __assign(__assign({ enableAdaptiveCards: true, enableThreadMemberUpdateNotification: true, enableLeaveThreadOnWindowClosed: false }, options), { // overrides
|
1602
|
+
ingressMiddleware: ingressMiddleware,
|
1603
|
+
egressMiddleware: egressMiddleware });
|
1532
1604
|
acsAdapterCDNUrl = this.resolveChatAdapterUrl(protocol || ChatAdapterProtocols_1.default.ACS);
|
1533
1605
|
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
|
1534
1606
|
ACSAdapter: acsAdapterCDNUrl
|
@@ -1539,7 +1611,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1539
1611
|
try {
|
1540
1612
|
var ChatAdapter = window.ChatAdapter; // eslint-disable-line @typescript-eslint/no-explicit-any
|
1541
1613
|
var fileManager = new AMSFileManager_1.default(_this.AMSClient, _this.acsAdapterLogger);
|
1542
|
-
var adapter = ChatAdapter.createACSAdapter(_this.chatToken.token, _this.chatToken.visitorId || 'teamsvisitor', _this.chatToken.chatId, _this.chatToken.acsEndpoint, fileManager,
|
1614
|
+
var adapter = ChatAdapter.createACSAdapter(_this.chatToken.token, _this.chatToken.visitorId || 'teamsvisitor', _this.chatToken.chatId, _this.chatToken.acsEndpoint, fileManager, ACSParticipantDisplayName_1.default.Customer, undefined, // chatClient
|
1615
|
+
_this.acsAdapterLogger, // logger
|
1543
1616
|
featuresOption);
|
1544
1617
|
resolve(adapter);
|
1545
1618
|
}
|
@@ -1558,12 +1631,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1558
1631
|
}
|
1559
1632
|
else if (protocol === ChatAdapterProtocols_1.default.IC3 || this.liveChatVersion === LiveChatVersion_1.default.V1) {
|
1560
1633
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
1561
|
-
var ic3AdapterCDNUrl;
|
1634
|
+
var options, ic3AdapterCDNUrl;
|
1562
1635
|
var _this = this;
|
1563
1636
|
var _a;
|
1564
1637
|
return __generator(this, function (_b) {
|
1565
1638
|
switch (_b.label) {
|
1566
1639
|
case 0:
|
1640
|
+
options = optionalParams.IC3Adapter ? optionalParams.IC3Adapter.options : {};
|
1567
1641
|
ic3AdapterCDNUrl = this.resolveChatAdapterUrl(protocol || ChatAdapterProtocols_1.default.IC3);
|
1568
1642
|
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
|
1569
1643
|
IC3Adapter: ic3AdapterCDNUrl
|
@@ -1572,17 +1646,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1572
1646
|
return [4 /*yield*/, WebUtils_1.loadScript(ic3AdapterCDNUrl, function () {
|
1573
1647
|
/* istanbul ignore next */
|
1574
1648
|
_this.debug && console.debug('IC3Adapter loaded!');
|
1575
|
-
var adapterConfig = {
|
1576
|
-
|
1577
|
-
userDisplayName: 'Customer',
|
1578
|
-
userId: 'teamsvisitor',
|
1579
|
-
sdkURL: _this.resolveIC3ClientUrl(),
|
1580
|
-
sdk: _this.IC3Client
|
1581
|
-
};
|
1649
|
+
var adapterConfig = __assign({ chatToken: _this.chatToken, userDisplayName: 'Customer', userId: _this.chatToken.visitorId || 'teamsvisitor', sdkURL: _this.resolveIC3ClientUrl(), sdk: _this.IC3Client }, options // overrides
|
1650
|
+
);
|
1582
1651
|
var adapter = new window.Microsoft.BotFramework.WebChat.IC3Adapter(adapterConfig);
|
1583
1652
|
adapter.logger = _this.ic3ClientLogger;
|
1584
|
-
// Keep iframe communication alive to reuse the same IC3Client instance
|
1585
|
-
window.Microsoft.BotFramework.WebChat.IC3SDKProvider.disposeSdk = function () { }; // eslint-disable-line @typescript-eslint/no-empty-function
|
1586
1653
|
_this.scenarioMarker.completeScenario(TelemetryEvent_1.default.CreateIC3Adapter);
|
1587
1654
|
resolve(adapter);
|
1588
1655
|
}, function () {
|
@@ -1603,16 +1670,31 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1603
1670
|
OmnichannelChatSDK.prototype.getVoiceVideoCalling = function (params) {
|
1604
1671
|
if (params === void 0) { params = {}; }
|
1605
1672
|
return __awaiter(this, void 0, void 0, function () {
|
1606
|
-
var chatConfig, liveWSAndLiveChatEngJoin, msdyn_widgetsnippet, widgetSnippetSourceRegex, result;
|
1673
|
+
var exceptionDetails, exceptionDetails, chatConfig, liveWSAndLiveChatEngJoin, msdyn_widgetsnippet, widgetSnippetSourceRegex, result;
|
1607
1674
|
var _this = this;
|
1608
1675
|
return __generator(this, function (_a) {
|
1609
1676
|
switch (_a.label) {
|
1610
1677
|
case 0:
|
1678
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetVoiceVideoCalling);
|
1611
1679
|
if (platform_1.default.isNode() || platform_1.default.isReactNative()) {
|
1612
|
-
|
1680
|
+
exceptionDetails = {
|
1681
|
+
response: "UnsupportedPlatform",
|
1682
|
+
message: "VoiceVideoCalling is only supported on browser"
|
1683
|
+
};
|
1684
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetVoiceVideoCalling, {
|
1685
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1686
|
+
});
|
1687
|
+
throw new Error(exceptionDetails.response);
|
1613
1688
|
}
|
1614
1689
|
if (this.callingOption.toString() === CallingOptionsOptionSetNumber_1.default.NoCalling.toString()) {
|
1615
|
-
|
1690
|
+
exceptionDetails = {
|
1691
|
+
response: "FeatureDisabled",
|
1692
|
+
message: "Voice and video call is not enabled"
|
1693
|
+
};
|
1694
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetVoiceVideoCalling, {
|
1695
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1696
|
+
});
|
1697
|
+
throw new Error(exceptionDetails.response);
|
1616
1698
|
}
|
1617
1699
|
return [4 /*yield*/, this.getChatConfig()];
|
1618
1700
|
case 1:
|
@@ -1622,25 +1704,27 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1622
1704
|
widgetSnippetSourceRegex = new RegExp("src=\"(https:\\/\\/[\\w-.]+)[\\w-.\\/]+\"");
|
1623
1705
|
result = msdyn_widgetsnippet.match(widgetSnippetSourceRegex);
|
1624
1706
|
if (result && result.length) {
|
1625
|
-
return [2 /*return*/, new Promise(function (resolve
|
1626
|
-
var LiveChatWidgetLibCDNUrl;
|
1707
|
+
return [2 /*return*/, new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
|
1708
|
+
var LiveChatWidgetLibCDNUrl, defaultParams;
|
1627
1709
|
var _this = this;
|
1628
1710
|
var _a;
|
1629
1711
|
return __generator(this, function (_b) {
|
1630
1712
|
switch (_b.label) {
|
1631
1713
|
case 0:
|
1632
|
-
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetVoiceVideoCalling);
|
1633
1714
|
LiveChatWidgetLibCDNUrl = result[1] + "/livechatwidget/WebChatControl/lib/CallingBundle.js";
|
1634
1715
|
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
|
1635
1716
|
VoiceVideoCalling: LiveChatWidgetLibCDNUrl
|
1636
1717
|
});
|
1718
|
+
defaultParams = {
|
1719
|
+
logger: this.callingSdkLogger
|
1720
|
+
};
|
1637
1721
|
return [4 /*yield*/, WebUtils_1.loadScript(LiveChatWidgetLibCDNUrl, function () { return __awaiter(_this, void 0, void 0, function () {
|
1638
1722
|
var VoiceVideoCalling;
|
1639
1723
|
return __generator(this, function (_a) {
|
1640
1724
|
switch (_a.label) {
|
1641
1725
|
case 0:
|
1642
1726
|
this.debug && console.debug(LiveChatWidgetLibCDNUrl + " loaded!");
|
1643
|
-
return [4 /*yield*/, createVoiceVideoCalling_1.default(params)];
|
1727
|
+
return [4 /*yield*/, createVoiceVideoCalling_1.default(__assign(__assign({}, params), defaultParams))];
|
1644
1728
|
case 1:
|
1645
1729
|
VoiceVideoCalling = _a.sent();
|
1646
1730
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetVoiceVideoCalling);
|
@@ -1653,13 +1737,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1653
1737
|
var exceptionDetails;
|
1654
1738
|
return __generator(this, function (_a) {
|
1655
1739
|
exceptionDetails = {
|
1656
|
-
response: "VoiceVideoCallingLoadFailed"
|
1740
|
+
response: "VoiceVideoCallingLoadFailed",
|
1741
|
+
message: "Failed to load VoiceVideoCalling"
|
1657
1742
|
};
|
1658
1743
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetVoiceVideoCalling, {
|
1659
1744
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1660
1745
|
});
|
1661
|
-
|
1662
|
-
return [2 /*return*/];
|
1746
|
+
throw new Error(exceptionDetails.response);
|
1663
1747
|
});
|
1664
1748
|
}); })];
|
1665
1749
|
case 1:
|
@@ -1676,7 +1760,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1676
1760
|
};
|
1677
1761
|
OmnichannelChatSDK.prototype.getPostChatSurveyContext = function () {
|
1678
1762
|
return __awaiter(this, void 0, void 0, function () {
|
1679
|
-
var conversationId, chatConfig, liveWSAndLiveChatEngJoin,
|
1763
|
+
var conversationId, chatConfig, liveWSAndLiveChatEngJoin, msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier, msfp_botsourcesurveyidentifier, postConversationSurveyOwnerId, postConversationBotSurveyOwnerId, liveWorkItemDetails, participantJoined, participantType, surveyInviteLinkRequest, optionalParams, ownerId, surveyInviteLinkResponse, surveyInviteLink, formsProLocale, postChatContext, ex_1;
|
1680
1764
|
return __generator(this, function (_a) {
|
1681
1765
|
switch (_a.label) {
|
1682
1766
|
case 0:
|
@@ -1687,20 +1771,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1687
1771
|
case 1:
|
1688
1772
|
_a.trys.push([1, 6, , 7]);
|
1689
1773
|
chatConfig = this.liveChatConfig;
|
1690
|
-
liveWSAndLiveChatEngJoin = chatConfig.LiveWSAndLiveChatEngJoin
|
1691
|
-
msdyn_postconversationsurveyenable = liveWSAndLiveChatEngJoin.msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier = liveWSAndLiveChatEngJoin.msfp_sourcesurveyidentifier, postConversationSurveyOwnerId = liveWSAndLiveChatEngJoin.postConversationSurveyOwnerId;
|
1692
|
-
|
1693
|
-
|
1694
|
-
if (!msdyn_postconversationsurveyenable) return [3 /*break*/, 4];
|
1695
|
-
return [4 /*yield*/, this.OCClient.getLWIDetails(this.requestId)];
|
1774
|
+
liveWSAndLiveChatEngJoin = chatConfig.LiveWSAndLiveChatEngJoin;
|
1775
|
+
msdyn_postconversationsurveyenable = liveWSAndLiveChatEngJoin.msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier = liveWSAndLiveChatEngJoin.msfp_sourcesurveyidentifier, msfp_botsourcesurveyidentifier = liveWSAndLiveChatEngJoin.msfp_botsourcesurveyidentifier, postConversationSurveyOwnerId = liveWSAndLiveChatEngJoin.postConversationSurveyOwnerId, postConversationBotSurveyOwnerId = liveWSAndLiveChatEngJoin.postConversationBotSurveyOwnerId;
|
1776
|
+
if (!(msdyn_postconversationsurveyenable === "true")) return [3 /*break*/, 4];
|
1777
|
+
return [4 /*yield*/, this.getConversationDetails()];
|
1696
1778
|
case 2:
|
1697
1779
|
liveWorkItemDetails = _a.sent();
|
1698
|
-
participantJoined = (liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.
|
1699
|
-
|
1780
|
+
participantJoined = (liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.canRenderPostChat) === "True";
|
1781
|
+
participantType = liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.participantType;
|
1782
|
+
conversationId = liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.conversationId;
|
1700
1783
|
surveyInviteLinkRequest = {
|
1701
|
-
"FormId": msfp_sourcesurveyidentifier,
|
1784
|
+
"FormId": participantType === "Bot" ? msfp_botsourcesurveyidentifier : msfp_sourcesurveyidentifier,
|
1702
1785
|
"ConversationId": conversationId,
|
1703
|
-
"OCLocaleCode": locale_1.getLocaleStringFromId(localeId)
|
1786
|
+
"OCLocaleCode": locale_1.getLocaleStringFromId(this.localeId)
|
1704
1787
|
};
|
1705
1788
|
optionalParams = {
|
1706
1789
|
"requestId": this.requestId
|
@@ -1708,7 +1791,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1708
1791
|
if (this.authenticatedUserToken) {
|
1709
1792
|
optionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
1710
1793
|
}
|
1711
|
-
|
1794
|
+
ownerId = participantType === "Bot" ? postConversationBotSurveyOwnerId : postConversationSurveyOwnerId;
|
1795
|
+
return [4 /*yield*/, this.OCClient.getSurveyInviteLink(ownerId, surveyInviteLinkRequest, optionalParams)];
|
1712
1796
|
case 3:
|
1713
1797
|
surveyInviteLinkResponse = _a.sent();
|
1714
1798
|
surveyInviteLink = void 0, formsProLocale = void 0;
|
@@ -1729,6 +1813,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1729
1813
|
}
|
1730
1814
|
postChatContext = {
|
1731
1815
|
participantJoined: participantJoined,
|
1816
|
+
participantType: participantType,
|
1732
1817
|
surveyInviteLink: surveyInviteLink,
|
1733
1818
|
formsProLocale: formsProLocale
|
1734
1819
|
};
|
@@ -1753,7 +1838,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1753
1838
|
case 6:
|
1754
1839
|
ex_1 = _a.sent();
|
1755
1840
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
|
1756
|
-
ConversationId: conversationId,
|
1841
|
+
ConversationId: conversationId !== null && conversationId !== void 0 ? conversationId : "",
|
1757
1842
|
RequestId: this.requestId,
|
1758
1843
|
ExceptionDetails: JSON.stringify(ex_1)
|
1759
1844
|
});
|
@@ -1763,102 +1848,6 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1763
1848
|
});
|
1764
1849
|
});
|
1765
1850
|
};
|
1766
|
-
OmnichannelChatSDK.prototype.initializePostChatRenderer = function () {
|
1767
|
-
return __awaiter(this, void 0, void 0, function () {
|
1768
|
-
var msfpEmbedScript, elm, scriptNodes, styleNodes, i, node, tmpNode, tmpNode, i, node, tmpNode;
|
1769
|
-
return __generator(this, function (_a) {
|
1770
|
-
if (!platform_1.isBrowser()) {
|
1771
|
-
return [2 /*return*/, Promise.reject("In-line rendering is only supported on web browsers")];
|
1772
|
-
}
|
1773
|
-
this.scenarioMarker.startScenario(TelemetryEvent_1.default.InitializePostChatRenderer, {
|
1774
|
-
RequestId: this.requestId
|
1775
|
-
});
|
1776
|
-
try {
|
1777
|
-
msfpEmbedScript = libraries_1.getMsfpEmbedScript();
|
1778
|
-
elm = document.createElement('div');
|
1779
|
-
elm.innerHTML = msfpEmbedScript;
|
1780
|
-
scriptNodes = elm.getElementsByTagName('script');
|
1781
|
-
styleNodes = elm.getElementsByTagName('link');
|
1782
|
-
for (i = 0; i < scriptNodes.length; i++) {
|
1783
|
-
node = scriptNodes[i];
|
1784
|
-
if (node.src) {
|
1785
|
-
tmpNode = document.createElement('script');
|
1786
|
-
tmpNode.type = node.type;
|
1787
|
-
tmpNode.src = node.src;
|
1788
|
-
tmpNode.async = false;
|
1789
|
-
if (!window.document.head.contains(tmpNode)) {
|
1790
|
-
document.getElementsByTagName('head')[0].appendChild(tmpNode);
|
1791
|
-
}
|
1792
|
-
}
|
1793
|
-
if (node.innerHTML) {
|
1794
|
-
tmpNode = document.createElement('script');
|
1795
|
-
tmpNode.innerHTML = node.innerHTML;
|
1796
|
-
tmpNode.async = false;
|
1797
|
-
if (!window.document.head.contains(tmpNode)) {
|
1798
|
-
window.document.head.appendChild(tmpNode);
|
1799
|
-
}
|
1800
|
-
}
|
1801
|
-
}
|
1802
|
-
for (i = 0; i < styleNodes.length; i++) {
|
1803
|
-
node = styleNodes[i];
|
1804
|
-
if (node.href) {
|
1805
|
-
tmpNode = document.createElement('link');
|
1806
|
-
tmpNode.type = node.type;
|
1807
|
-
tmpNode.rel = node.rel;
|
1808
|
-
tmpNode.href = node.href;
|
1809
|
-
if (!window.document.head.contains(tmpNode)) {
|
1810
|
-
document.getElementsByTagName('head')[0].appendChild(tmpNode);
|
1811
|
-
}
|
1812
|
-
}
|
1813
|
-
}
|
1814
|
-
}
|
1815
|
-
catch (ex) {
|
1816
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.InitializePostChatRenderer, {
|
1817
|
-
RequestId: this.requestId,
|
1818
|
-
ExceptionDetails: JSON.stringify(ex)
|
1819
|
-
});
|
1820
|
-
return [2 /*return*/, Promise.reject("Error occurred when initializer post chat renderer. " + JSON.stringify(ex))];
|
1821
|
-
}
|
1822
|
-
return [2 /*return*/];
|
1823
|
-
});
|
1824
|
-
});
|
1825
|
-
};
|
1826
|
-
OmnichannelChatSDK.prototype.renderPostChatSurvey = function (containerId, postChatContext) {
|
1827
|
-
return __awaiter(this, void 0, void 0, function () {
|
1828
|
-
var ex_2;
|
1829
|
-
return __generator(this, function (_a) {
|
1830
|
-
switch (_a.label) {
|
1831
|
-
case 0:
|
1832
|
-
if (!platform_1.isBrowser()) {
|
1833
|
-
return [2 /*return*/, Promise.reject("In-line rendering is only supported on web browsers")];
|
1834
|
-
}
|
1835
|
-
this.scenarioMarker.startScenario(TelemetryEvent_1.default.RenderPostChatSurvey, {
|
1836
|
-
RequestId: this.requestId
|
1837
|
-
});
|
1838
|
-
_a.label = 1;
|
1839
|
-
case 1:
|
1840
|
-
_a.trys.push([1, 3, , 4]);
|
1841
|
-
if (!postChatContext) {
|
1842
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.RenderPostChatSurvey, {
|
1843
|
-
RequestId: this.requestId,
|
1844
|
-
ExceptionDetails: "Post Chat Context is null."
|
1845
|
-
});
|
1846
|
-
return [2 /*return*/, Promise.reject("Post Chat Context is null.")];
|
1847
|
-
}
|
1848
|
-
return [4 /*yield*/, renderSurvey(containerId, postChatContext === null || postChatContext === void 0 ? void 0 : postChatContext.surveyInviteLink, "", "", postChatContext === null || postChatContext === void 0 ? void 0 : postChatContext.formsProLocale)];
|
1849
|
-
case 2: return [2 /*return*/, _a.sent()];
|
1850
|
-
case 3:
|
1851
|
-
ex_2 = _a.sent();
|
1852
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.RenderPostChatSurvey, {
|
1853
|
-
RequestId: this.requestId,
|
1854
|
-
ExceptionDetails: JSON.stringify(ex_2)
|
1855
|
-
});
|
1856
|
-
return [2 /*return*/, Promise.reject("Error occurred when rendering post chat survey. " + JSON.stringify(ex_2))];
|
1857
|
-
case 4: return [2 /*return*/];
|
1858
|
-
}
|
1859
|
-
});
|
1860
|
-
});
|
1861
|
-
};
|
1862
1851
|
OmnichannelChatSDK.prototype.getIC3Client = function () {
|
1863
1852
|
return __awaiter(this, void 0, void 0, function () {
|
1864
1853
|
var IC3Client;
|
@@ -1885,7 +1874,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1885
1874
|
this.debug && console.debug('IC3Client');
|
1886
1875
|
// Use IC3Client if browser is detected
|
1887
1876
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
1888
|
-
var ic3ClientCDNUrl;
|
1877
|
+
var ic3ClientCDNUrl, IC3Client;
|
1889
1878
|
var _this = this;
|
1890
1879
|
var _a;
|
1891
1880
|
return __generator(this, function (_b) {
|
@@ -1896,6 +1885,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1896
1885
|
IC3Client: ic3ClientCDNUrl
|
1897
1886
|
});
|
1898
1887
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetIC3Client);
|
1888
|
+
if (!this.IC3SDKProvider) return [3 /*break*/, 2];
|
1889
|
+
return [4 /*yield*/, this.IC3SDKProvider.getSDK({
|
1890
|
+
hostType: HostType_1.default.IFrame,
|
1891
|
+
protocolType: ProtocoleType_1.default.IC3V1SDK,
|
1892
|
+
logger: this.ic3ClientLogger // eslint-disable-line @typescript-eslint/no-explicit-any
|
1893
|
+
})];
|
1894
|
+
case 1:
|
1895
|
+
IC3Client = _b.sent();
|
1896
|
+
return [2 /*return*/, resolve(IC3Client)];
|
1897
|
+
case 2:
|
1899
1898
|
window.addEventListener("ic3:sdk:load", function () { return __awaiter(_this, void 0, void 0, function () {
|
1900
1899
|
var ic3sdk, IC3SDKProvider, IC3Client;
|
1901
1900
|
return __generator(this, function (_a) {
|
@@ -1932,7 +1931,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1932
1931
|
});
|
1933
1932
|
reject('Failed to load IC3Client');
|
1934
1933
|
})];
|
1935
|
-
case
|
1934
|
+
case 3:
|
1936
1935
|
_b.sent();
|
1937
1936
|
return [2 /*return*/];
|
1938
1937
|
}
|
@@ -1942,17 +1941,24 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1942
1941
|
});
|
1943
1942
|
});
|
1944
1943
|
};
|
1945
|
-
OmnichannelChatSDK.prototype.getChatConfig = function () {
|
1944
|
+
OmnichannelChatSDK.prototype.getChatConfig = function (optionalParams) {
|
1945
|
+
if (optionalParams === void 0) { optionalParams = {}; }
|
1946
1946
|
return __awaiter(this, void 0, void 0, function () {
|
1947
|
-
var liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled,
|
1948
|
-
return __generator(this, function (
|
1949
|
-
switch (
|
1947
|
+
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;
|
1948
|
+
return __generator(this, function (_a) {
|
1949
|
+
switch (_a.label) {
|
1950
1950
|
case 0:
|
1951
|
-
|
1952
|
-
|
1951
|
+
sendCacheHeaders = optionalParams.sendCacheHeaders;
|
1952
|
+
_a.label = 1;
|
1953
1953
|
case 1:
|
1954
|
-
|
1955
|
-
|
1954
|
+
_a.trys.push([1, 5, , 6]);
|
1955
|
+
bypassCache = sendCacheHeaders === true;
|
1956
|
+
return [4 /*yield*/, this.OCClient.getChatConfig(this.requestId, bypassCache)];
|
1957
|
+
case 2:
|
1958
|
+
liveChatConfig = _a.sent();
|
1959
|
+
dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin, liveChatVersion = liveChatConfig.LiveChatVersion, chatWidgetLanguage = liveChatConfig.ChatWidgetLanguage;
|
1960
|
+
msdyn_localeid = chatWidgetLanguage.msdyn_localeid;
|
1961
|
+
this.localeId = msdyn_localeid || locale_1.defaultLocaleId;
|
1956
1962
|
this.liveChatVersion = liveChatVersion || LiveChatVersion_1.default.V1;
|
1957
1963
|
/* istanbul ignore next */
|
1958
1964
|
this.debug && console.log("[OmnichannelChatSDK][getChatConfig][liveChatVersion] " + this.liveChatVersion);
|
@@ -1975,47 +1981,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1975
1981
|
if (isPreChatEnabled && preChatSurvey && preChatSurvey.trim().length > 0) {
|
1976
1982
|
this.preChatSurvey = preChatSurvey;
|
1977
1983
|
}
|
1978
|
-
if (!this.authSettings) return [3 /*break*/,
|
1979
|
-
this.
|
1980
|
-
if (!this.chatSDKConfig.getAuthToken) return [3 /*break*/, 6];
|
1981
|
-
_b.label = 2;
|
1982
|
-
case 2:
|
1983
|
-
_b.trys.push([2, 4, , 5]);
|
1984
|
-
return [4 /*yield*/, this.chatSDKConfig.getAuthToken()];
|
1984
|
+
if (!this.authSettings) return [3 /*break*/, 4];
|
1985
|
+
return [4 /*yield*/, this.setAuthTokenProvider(this.chatSDKConfig.getAuthToken)];
|
1985
1986
|
case 3:
|
1986
|
-
|
1987
|
-
|
1988
|
-
this.authenticatedUserToken = token;
|
1989
|
-
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetAuthToken);
|
1990
|
-
}
|
1991
|
-
else {
|
1992
|
-
exceptionDetails = {
|
1993
|
-
response: "UndefinedAuthToken"
|
1994
|
-
};
|
1995
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
1996
|
-
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1997
|
-
});
|
1998
|
-
}
|
1999
|
-
return [3 /*break*/, 5];
|
1987
|
+
_a.sent();
|
1988
|
+
_a.label = 4;
|
2000
1989
|
case 4:
|
2001
|
-
_a = _b.sent();
|
2002
|
-
exceptionDetails = {
|
2003
|
-
response: "GetAuthTokenFailed"
|
2004
|
-
};
|
2005
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
2006
|
-
ExceptionDetails: JSON.stringify(exceptionDetails)
|
2007
|
-
});
|
2008
|
-
return [3 /*break*/, 5];
|
2009
|
-
case 5: return [3 /*break*/, 7];
|
2010
|
-
case 6:
|
2011
|
-
exceptionDetails = {
|
2012
|
-
response: "GetAuthTokenNotFound"
|
2013
|
-
};
|
2014
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
2015
|
-
ExceptionDetails: JSON.stringify(exceptionDetails)
|
2016
|
-
});
|
2017
|
-
_b.label = 7;
|
2018
|
-
case 7:
|
2019
1990
|
if (this.preChatSurvey) {
|
2020
1991
|
/* istanbul ignore next */
|
2021
1992
|
this.debug && console.log('Prechat Survey!');
|
@@ -2023,11 +1994,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2023
1994
|
this.callingOption = msdyn_callingoptions;
|
2024
1995
|
this.liveChatConfig = liveChatConfig;
|
2025
1996
|
return [2 /*return*/, this.liveChatConfig];
|
2026
|
-
case
|
2027
|
-
error_18 =
|
1997
|
+
case 5:
|
1998
|
+
error_18 = _a.sent();
|
2028
1999
|
console.error("OmnichannelChatSDK/getChatConfig/error " + error_18);
|
2029
2000
|
return [2 /*return*/, error_18];
|
2030
|
-
case
|
2001
|
+
case 6: return [2 /*return*/];
|
2031
2002
|
}
|
2032
2003
|
});
|
2033
2004
|
});
|
@@ -2109,6 +2080,57 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2109
2080
|
});
|
2110
2081
|
});
|
2111
2082
|
};
|
2083
|
+
OmnichannelChatSDK.prototype.setAuthTokenProvider = function (provider) {
|
2084
|
+
return __awaiter(this, void 0, void 0, function () {
|
2085
|
+
var token, exceptionDetails, _a, exceptionDetails, exceptionDetails;
|
2086
|
+
return __generator(this, function (_b) {
|
2087
|
+
switch (_b.label) {
|
2088
|
+
case 0:
|
2089
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetAuthToken);
|
2090
|
+
this.chatSDKConfig.getAuthToken = provider;
|
2091
|
+
if (!this.chatSDKConfig.getAuthToken) return [3 /*break*/, 5];
|
2092
|
+
_b.label = 1;
|
2093
|
+
case 1:
|
2094
|
+
_b.trys.push([1, 3, , 4]);
|
2095
|
+
return [4 /*yield*/, this.chatSDKConfig.getAuthToken()];
|
2096
|
+
case 2:
|
2097
|
+
token = _b.sent();
|
2098
|
+
if (token) {
|
2099
|
+
this.authenticatedUserToken = token;
|
2100
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetAuthToken);
|
2101
|
+
}
|
2102
|
+
else {
|
2103
|
+
exceptionDetails = {
|
2104
|
+
response: "UndefinedAuthToken"
|
2105
|
+
};
|
2106
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
2107
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
2108
|
+
});
|
2109
|
+
}
|
2110
|
+
return [3 /*break*/, 4];
|
2111
|
+
case 3:
|
2112
|
+
_a = _b.sent();
|
2113
|
+
exceptionDetails = {
|
2114
|
+
response: "GetAuthTokenFailed"
|
2115
|
+
};
|
2116
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
2117
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
2118
|
+
});
|
2119
|
+
return [3 /*break*/, 4];
|
2120
|
+
case 4: return [3 /*break*/, 6];
|
2121
|
+
case 5:
|
2122
|
+
exceptionDetails = {
|
2123
|
+
response: "GetAuthTokenNotFound"
|
2124
|
+
};
|
2125
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
2126
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
2127
|
+
});
|
2128
|
+
_b.label = 6;
|
2129
|
+
case 6: return [2 /*return*/];
|
2130
|
+
}
|
2131
|
+
});
|
2132
|
+
});
|
2133
|
+
};
|
2112
2134
|
return OmnichannelChatSDK;
|
2113
2135
|
}());
|
2114
2136
|
exports.default = OmnichannelChatSDK;
|