@microsoft/omnichannel-chat-sdk 1.9.6 → 1.9.7-main.2a56ce4
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/lib/OmnichannelChatSDK.d.ts +128 -128
- package/lib/OmnichannelChatSDK.js +2610 -2609
- package/lib/OmnichannelChatSDK.js.map +1 -1
- package/lib/api/createVoiceVideoCalling.d.ts +53 -53
- package/lib/api/createVoiceVideoCalling.js +462 -462
- package/lib/config/ocSDKConfiguration.d.ts +7 -7
- package/lib/config/ocSDKConfiguration.js +9 -9
- package/lib/config/settings.d.ts +7 -6
- package/lib/config/settings.js +15 -13
- package/lib/config/settings.js.map +1 -1
- package/lib/core/AuthSettings.d.ts +5 -5
- package/lib/core/AuthSettings.js +2 -2
- package/lib/core/AxiosErrorCodes.d.ts +4 -4
- package/lib/core/AxiosErrorCodes.js +7 -7
- package/lib/core/CallingOptionsOptionSetNumber.d.ts +6 -6
- package/lib/core/CallingOptionsOptionSetNumber.js +9 -9
- package/lib/core/ChatConfig.d.ts +10 -10
- package/lib/core/ChatConfig.js +2 -2
- package/lib/core/ChatReconnectContext.d.ts +4 -4
- package/lib/core/ChatReconnectContext.js +2 -2
- package/lib/core/ChatReconnectOptionalParams.d.ts +3 -3
- package/lib/core/ChatReconnectOptionalParams.js +2 -2
- package/lib/core/ChatSDKConfig.d.ts +38 -38
- package/lib/core/ChatSDKConfig.js +2 -2
- package/lib/core/ChatSDKError.d.ts +64 -64
- package/lib/core/ChatSDKError.js +73 -73
- package/lib/core/ChatSDKExceptionDetails.d.ts +13 -13
- package/lib/core/ChatSDKExceptionDetails.js +2 -2
- package/lib/core/ChatTranscriptBody.d.ts +5 -5
- package/lib/core/ChatTranscriptBody.js +2 -2
- package/lib/core/ConversationMode.d.ts +5 -5
- package/lib/core/ConversationMode.js +8 -8
- package/lib/core/EmailLiveChatTranscriptOptionalParams.d.ts +4 -4
- package/lib/core/EmailLiveChatTranscriptOptionalParams.js +2 -2
- package/lib/core/GetAgentAvailabilityOptionalParams.d.ts +13 -13
- package/lib/core/GetAgentAvailabilityOptionalParams.js +2 -2
- package/lib/core/GetChatTokenOptionalParams.d.ts +3 -3
- package/lib/core/GetChatTokenOptionalParams.js +2 -2
- package/lib/core/GetConversationDetailsOptionalParams.d.ts +4 -4
- package/lib/core/GetConversationDetailsOptionalParams.js +2 -2
- package/lib/core/GetLiveChatConfigOptionalParams.d.ts +5 -5
- package/lib/core/GetLiveChatConfigOptionalParams.js +2 -2
- package/lib/core/GetLiveChatTranscriptOptionalParams.d.ts +4 -4
- package/lib/core/GetLiveChatTranscriptOptionalParams.js +2 -2
- package/lib/core/InitializeOptionalParams.d.ts +6 -6
- package/lib/core/InitializeOptionalParams.js +2 -2
- package/lib/core/LiveChatContext.d.ts +14 -14
- package/lib/core/LiveChatContext.js +2 -2
- package/lib/core/LiveChatVersion.d.ts +5 -5
- package/lib/core/LiveChatVersion.js +8 -8
- package/lib/core/LiveWorkItemDetails.d.ts +8 -8
- package/lib/core/LiveWorkItemDetails.js +2 -2
- package/lib/core/LiveWorkItemState.d.ts +8 -8
- package/lib/core/LiveWorkItemState.js +11 -11
- package/lib/core/OmnichannelConfig.d.ts +5 -5
- package/lib/core/OmnichannelConfig.js +2 -2
- package/lib/core/OmnichannelErrorCodes.d.ts +4 -4
- package/lib/core/OmnichannelErrorCodes.js +7 -7
- package/lib/core/PostChatContext.d.ts +8 -8
- package/lib/core/PostChatContext.js +2 -2
- package/lib/core/SetAuthTokenProviderOptionalParams.d.ts +3 -3
- package/lib/core/SetAuthTokenProviderOptionalParams.js +2 -2
- package/lib/core/StartChatOptionalParams.d.ts +18 -18
- package/lib/core/StartChatOptionalParams.js +2 -2
- package/lib/core/messaging/ACSChatMessageType.d.ts +7 -7
- package/lib/core/messaging/ACSChatMessageType.js +10 -10
- package/lib/core/messaging/ACSClient.d.ts +45 -45
- package/lib/core/messaging/ACSClient.js +612 -612
- package/lib/core/messaging/ACSClientConfig.d.ts +5 -5
- package/lib/core/messaging/ACSClientConfig.js +2 -2
- package/lib/core/messaging/ACSParticipantDisplayName.d.ts +6 -6
- package/lib/core/messaging/ACSParticipantDisplayName.js +9 -9
- package/lib/core/messaging/ACSSessionInfo.d.ts +5 -5
- package/lib/core/messaging/ACSSessionInfo.js +2 -2
- package/lib/core/messaging/ChatAdapterConfig.d.ts +8 -8
- package/lib/core/messaging/ChatAdapterConfig.js +2 -2
- package/lib/core/messaging/ChatAdapterOptionalParams.d.ts +24 -24
- package/lib/core/messaging/ChatAdapterOptionalParams.js +2 -2
- package/lib/core/messaging/ChatAdapterProtocols.d.ts +6 -6
- package/lib/core/messaging/ChatAdapterProtocols.js +10 -10
- package/lib/core/messaging/ChatSDKMessage.d.ts +6 -6
- package/lib/core/messaging/ChatSDKMessage.js +2 -2
- package/lib/core/messaging/IC3Config.d.ts +4 -4
- package/lib/core/messaging/IC3Config.js +2 -2
- package/lib/core/messaging/MessageTags.d.ts +3 -3
- package/lib/core/messaging/MessageTags.js +6 -6
- package/lib/core/messaging/OmnichannelMessage.d.ts +64 -64
- package/lib/core/messaging/OmnichannelMessage.js +51 -51
- package/lib/core/messaging/OnNewMessageOptionalParams.d.ts +3 -3
- package/lib/core/messaging/OnNewMessageOptionalParams.js +2 -2
- package/lib/external/ACSAdapter/AMSFileManager.d.ts +76 -76
- package/lib/external/ACSAdapter/AMSFileManager.js +394 -394
- package/lib/external/ACSAdapter/AMSFileScanner.d.ts +36 -36
- package/lib/external/ACSAdapter/AMSFileScanner.js +275 -275
- package/lib/external/ACSAdapter/activityUtils.d.ts +9 -9
- package/lib/external/ACSAdapter/activityUtils.js +79 -79
- package/lib/external/ACSAdapter/createChannelDataEgressMiddleware.d.ts +5 -5
- package/lib/external/ACSAdapter/createChannelDataEgressMiddleware.js +33 -33
- package/lib/external/ACSAdapter/createFileScanIngressMiddleware.d.ts +2 -2
- package/lib/external/ACSAdapter/createFileScanIngressMiddleware.js +95 -95
- package/lib/external/ACSAdapter/createFormatEgressTagsMiddleware.d.ts +2 -2
- package/lib/external/ACSAdapter/createFormatEgressTagsMiddleware.js +30 -30
- package/lib/external/ACSAdapter/createFormatIngressTagsMiddleware.d.ts +2 -2
- package/lib/external/ACSAdapter/createFormatIngressTagsMiddleware.js +24 -24
- package/lib/external/CallingSDK/ICallingSDKLogData.d.ts +7 -7
- package/lib/external/CallingSDK/ICallingSDKLogData.js +2 -2
- package/lib/external/IC3Adapter/IChatToken.d.ts +11 -11
- package/lib/external/IC3Adapter/IChatToken.js +3 -3
- package/lib/external/IC3Adapter/IIC3AdapterOptions.d.ts +22 -22
- package/lib/external/IC3Adapter/IIC3AdapterOptions.js +2 -2
- package/lib/external/IC3Adapter/INotification.d.ts +6 -6
- package/lib/external/IC3Adapter/INotification.js +2 -2
- package/lib/external/IC3Adapter/Notification.d.ts +7 -7
- package/lib/external/IC3Adapter/Notification.js +14 -14
- package/lib/external/IC3Client/IIC3SDKLogData.d.ts +9 -9
- package/lib/external/IC3Client/IIC3SDKLogData.js +2 -2
- package/lib/external/OCSDK/IOCSDKLogData.d.ts +14 -14
- package/lib/external/OCSDK/IOCSDKLogData.js +2 -2
- package/lib/index.d.ts +25 -25
- package/lib/index.js +34 -34
- package/lib/telemetry/AriaTelemetry.d.ts +40 -40
- package/lib/telemetry/AriaTelemetry.js +539 -539
- package/lib/telemetry/EUDomainNames.d.ts +2 -2
- package/lib/telemetry/EUDomainNames.js +16 -16
- package/lib/telemetry/EventMarker.d.ts +3 -3
- package/lib/telemetry/EventMarker.js +12 -12
- package/lib/telemetry/GCCDomainPatterns.d.ts +2 -2
- package/lib/telemetry/GCCDomainPatterns.js +7 -7
- package/lib/telemetry/LogLevel.d.ts +8 -8
- package/lib/telemetry/LogLevel.js +11 -11
- package/lib/telemetry/ScenarioMarker.d.ts +21 -21
- package/lib/telemetry/ScenarioMarker.js +82 -82
- package/lib/telemetry/ScenarioType.d.ts +11 -11
- package/lib/telemetry/ScenarioType.js +14 -14
- package/lib/telemetry/StopWatch.d.ts +6 -6
- package/lib/telemetry/StopWatch.js +14 -14
- package/lib/telemetry/TelemetryEvent.d.ts +46 -46
- package/lib/telemetry/TelemetryEvent.js +49 -49
- package/lib/telemetry/retrieveCollectorUri.d.ts +2 -2
- package/lib/telemetry/retrieveCollectorUri.js +25 -25
- package/lib/tsconfig.tsbuildinfo +1917 -1968
- package/lib/utils/AMSClientLoadStates.d.ts +6 -6
- package/lib/utils/AMSClientLoadStates.js +11 -11
- package/lib/utils/CoreServicesUtils.d.ts +7 -7
- package/lib/utils/CoreServicesUtils.js +39 -39
- package/lib/utils/WebUtils.d.ts +10 -10
- package/lib/utils/WebUtils.js +128 -128
- package/lib/utils/chatAdapterCreators.d.ts +20 -20
- package/lib/utils/chatAdapterCreators.js +208 -208
- package/lib/utils/createOcSDKConfiguration.d.ts +4 -4
- package/lib/utils/createOcSDKConfiguration.js +22 -22
- package/lib/utils/createOmnichannelMessage.d.ts +11 -11
- package/lib/utils/createOmnichannelMessage.js +77 -77
- package/lib/utils/createTelemetry.d.ts +3 -3
- package/lib/utils/createTelemetry.js +9 -9
- package/lib/utils/exceptionSuppressors.d.ts +29 -29
- package/lib/utils/exceptionSuppressors.js +49 -49
- package/lib/utils/exceptionThrowers.d.ts +119 -119
- package/lib/utils/exceptionThrowers.js +137 -137
- package/lib/utils/internalUtils.d.ts +4 -4
- package/lib/utils/internalUtils.js +16 -16
- package/lib/utils/libraries.d.ts +12 -12
- package/lib/utils/libraries.js +34 -34
- package/lib/utils/locale.d.ts +4 -4
- package/lib/utils/locale.js +60 -60
- package/lib/utils/location.d.ts +7 -7
- package/lib/utils/location.js +95 -95
- package/lib/utils/loggerUtils.d.ts +15 -15
- package/lib/utils/loggerUtils.js +55 -55
- package/lib/utils/loggers.d.ts +111 -111
- package/lib/utils/loggers.js +501 -501
- package/lib/utils/parsers.d.ts +6 -6
- package/lib/utils/parsers.js +10 -10
- package/lib/utils/platform.d.ts +9 -9
- package/lib/utils/platform.js +11 -11
- package/lib/utils/setOcUserAgent.d.ts +2 -2
- package/lib/utils/setOcUserAgent.js +21 -21
- package/lib/utils/sleep.d.ts +2 -2
- package/lib/utils/sleep.js +4 -4
- package/lib/utils/urlResolvers.d.ts +10 -10
- package/lib/utils/urlResolvers.js +64 -64
- package/lib/utils/utilities.d.ts +5 -5
- package/lib/utils/utilities.js +36 -36
- package/lib/validators/OmnichannelConfigValidator.d.ts +3 -3
- package/lib/validators/OmnichannelConfigValidator.js +28 -28
- package/lib/validators/SDKConfigValidators.d.ts +5 -5
- package/lib/validators/SDKConfigValidators.js +48 -48
- package/package.json +1 -1
- package/lib/commands/throwUnsupportedLiveChatVersionFailureIfApplicable.d.ts +0 -3
- package/lib/commands/throwUnsupportedLiveChatVersionFailureIfApplicable.js +0 -14
- package/lib/commands/throwUnsupportedLiveChatVersionFailureIfApplicable.js.map +0 -1
- package/lib/utils/fillMobilePlatformData.d.ts +0 -2
- package/lib/utils/fillMobilePlatformData.js +0 -44
- package/lib/utils/fillMobilePlatformData.js.map +0 -1
- package/lib/utils/fillPlatformData.browser.d.ts +0 -2
- package/lib/utils/fillPlatformData.browser.js +0 -8
- package/lib/utils/fillPlatformData.browser.js.map +0 -1
- package/lib/utils/fillPlatformData.d.ts +0 -2
- package/lib/utils/fillPlatformData.js +0 -8
- package/lib/utils/fillPlatformData.js.map +0 -1
- package/lib/utils/fillWebPlatformData.d.ts +0 -2
- package/lib/utils/fillWebPlatformData.js +0 -21
- package/lib/utils/fillWebPlatformData.js.map +0 -1
@@ -1,36 +1,36 @@
|
|
1
|
-
import FileMetadata from "@microsoft/omnichannel-amsclient/lib/FileMetadata";
|
2
|
-
import FramedClient from "@microsoft/omnichannel-amsclient/lib/FramedClient";
|
3
|
-
interface FileScanResponse {
|
4
|
-
status: string;
|
5
|
-
}
|
6
|
-
interface FileScanResult {
|
7
|
-
fileMetadata: FileMetadata;
|
8
|
-
scan: FileScanResponse;
|
9
|
-
next?: any;
|
10
|
-
activity?: any;
|
11
|
-
}
|
12
|
-
interface AMSFileScannerOptions {
|
13
|
-
pollingInterval?: number;
|
14
|
-
scanStatusRetrievalDelay?: number;
|
15
|
-
}
|
16
|
-
declare class AMSFileScanner {
|
17
|
-
amsClient: FramedClient;
|
18
|
-
scanResults: Map<string, FileScanResult> | null;
|
19
|
-
private shouldQueueScan;
|
20
|
-
private test;
|
21
|
-
private options;
|
22
|
-
constructor(amsClient: FramedClient, options?: AMSFileScannerOptions);
|
23
|
-
queueScan(): Promise<void>;
|
24
|
-
retrieveFileScanResult(id: string): FileScanResult | undefined;
|
25
|
-
addOrUpdateFile(id: string, fileMetadata: FileMetadata, scan: FileScanResponse): void;
|
26
|
-
addNext(id: string, next: Function): void;
|
27
|
-
addActivity(id: string, activity: any): void;
|
28
|
-
scanFileCallback(scanResult: FileScanResult, id: string): Promise<void>;
|
29
|
-
scanFiles(): Promise<void>;
|
30
|
-
end(): void;
|
31
|
-
private retrieveFileBlob;
|
32
|
-
private addAttachmentToActivity;
|
33
|
-
renderAttachmentActivity(scanResult: FileScanResult, view_location: any): Promise<void>;
|
34
|
-
renderMalwareActivity(scanResult: FileScanResult): Promise<void>;
|
35
|
-
}
|
36
|
-
export default AMSFileScanner;
|
1
|
+
import FileMetadata from "@microsoft/omnichannel-amsclient/lib/FileMetadata";
|
2
|
+
import FramedClient from "@microsoft/omnichannel-amsclient/lib/FramedClient";
|
3
|
+
interface FileScanResponse {
|
4
|
+
status: string;
|
5
|
+
}
|
6
|
+
interface FileScanResult {
|
7
|
+
fileMetadata: FileMetadata;
|
8
|
+
scan: FileScanResponse;
|
9
|
+
next?: any;
|
10
|
+
activity?: any;
|
11
|
+
}
|
12
|
+
interface AMSFileScannerOptions {
|
13
|
+
pollingInterval?: number;
|
14
|
+
scanStatusRetrievalDelay?: number;
|
15
|
+
}
|
16
|
+
declare class AMSFileScanner {
|
17
|
+
amsClient: FramedClient;
|
18
|
+
scanResults: Map<string, FileScanResult> | null;
|
19
|
+
private shouldQueueScan;
|
20
|
+
private test;
|
21
|
+
private options;
|
22
|
+
constructor(amsClient: FramedClient, options?: AMSFileScannerOptions);
|
23
|
+
queueScan(): Promise<void>;
|
24
|
+
retrieveFileScanResult(id: string): FileScanResult | undefined;
|
25
|
+
addOrUpdateFile(id: string, fileMetadata: FileMetadata, scan: FileScanResponse): void;
|
26
|
+
addNext(id: string, next: Function): void;
|
27
|
+
addActivity(id: string, activity: any): void;
|
28
|
+
scanFileCallback(scanResult: FileScanResult, id: string): Promise<void>;
|
29
|
+
scanFiles(): Promise<void>;
|
30
|
+
end(): void;
|
31
|
+
private retrieveFileBlob;
|
32
|
+
private addAttachmentToActivity;
|
33
|
+
renderAttachmentActivity(scanResult: FileScanResult, view_location: any): Promise<void>;
|
34
|
+
renderMalwareActivity(scanResult: FileScanResult): Promise<void>;
|
35
|
+
}
|
36
|
+
export default AMSFileScanner;
|
@@ -1,276 +1,276 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
3
|
-
__assign = Object.assign || function(t) {
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5
|
-
s = arguments[i];
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
7
|
-
t[p] = s[p];
|
8
|
-
}
|
9
|
-
return t;
|
10
|
-
};
|
11
|
-
return __assign.apply(this, arguments);
|
12
|
-
};
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
20
|
-
});
|
21
|
-
};
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
26
|
-
function step(op) {
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
28
|
-
while (_) try {
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
31
|
-
switch (op[0]) {
|
32
|
-
case 0: case 1: t = op; break;
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
36
|
-
default:
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
41
|
-
if (t[2]) _.ops.pop();
|
42
|
-
_.trys.pop(); continue;
|
43
|
-
}
|
44
|
-
op = body.call(thisArg, _);
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
47
|
-
}
|
48
|
-
};
|
49
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
50
|
-
var WebUtils_1 = require("../../utils/WebUtils");
|
51
|
-
var AMSFileManager_1 = require("./AMSFileManager");
|
52
|
-
var activityUtils_1 = require("./activityUtils");
|
53
|
-
var defaultScanPollingInterval = 7 * 1000;
|
54
|
-
var defaultScanStatusRetrievalDelay = 1000;
|
55
|
-
var AMSFileScanner = /** @class */ (function () {
|
56
|
-
function AMSFileScanner(amsClient, options) {
|
57
|
-
if (options === void 0) { options = {}; }
|
58
|
-
this.scanResults = null;
|
59
|
-
this.amsClient = amsClient;
|
60
|
-
this.scanResults = new Map();
|
61
|
-
this.shouldQueueScan = false;
|
62
|
-
this.test = false;
|
63
|
-
this.options = options;
|
64
|
-
this.queueScan();
|
65
|
-
}
|
66
|
-
AMSFileScanner.prototype.queueScan = function () {
|
67
|
-
var _a;
|
68
|
-
return __awaiter(this, void 0, void 0, function () {
|
69
|
-
var e_1, _b;
|
70
|
-
return __generator(this, function (_c) {
|
71
|
-
switch (_c.label) {
|
72
|
-
case 0:
|
73
|
-
this.shouldQueueScan = true;
|
74
|
-
_c.label = 1;
|
75
|
-
case 1:
|
76
|
-
_c.trys.push([1, 3, 4, 8]);
|
77
|
-
return [4 /*yield*/, this.scanFiles()];
|
78
|
-
case 2:
|
79
|
-
_c.sent();
|
80
|
-
return [3 /*break*/, 8];
|
81
|
-
case 3:
|
82
|
-
e_1 = _c.sent();
|
83
|
-
console.error(e_1);
|
84
|
-
return [3 /*break*/, 8];
|
85
|
-
case 4: return [4 /*yield*/, WebUtils_1.default.sleep(((_a = this.options) === null || _a === void 0 ? void 0 : _a.pollingInterval) || defaultScanPollingInterval)];
|
86
|
-
case 5:
|
87
|
-
_c.sent();
|
88
|
-
_b = this.shouldQueueScan && !this.test;
|
89
|
-
if (!_b) return [3 /*break*/, 7];
|
90
|
-
return [4 /*yield*/, this.queueScan()];
|
91
|
-
case 6:
|
92
|
-
_b = (_c.sent());
|
93
|
-
_c.label = 7;
|
94
|
-
case 7:
|
95
|
-
_b;
|
96
|
-
return [7 /*endfinally*/];
|
97
|
-
case 8: return [2 /*return*/];
|
98
|
-
}
|
99
|
-
});
|
100
|
-
});
|
101
|
-
};
|
102
|
-
AMSFileScanner.prototype.retrieveFileScanResult = function (id) {
|
103
|
-
var _a;
|
104
|
-
return (_a = this.scanResults) === null || _a === void 0 ? void 0 : _a.get(id);
|
105
|
-
};
|
106
|
-
AMSFileScanner.prototype.addOrUpdateFile = function (id, fileMetadata, scan) {
|
107
|
-
var _a;
|
108
|
-
var scanResult = this.retrieveFileScanResult(id);
|
109
|
-
(_a = this.scanResults) === null || _a === void 0 ? void 0 : _a.set(id, __assign(__assign({}, (scanResult || {})), { fileMetadata: fileMetadata,
|
110
|
-
scan: scan }));
|
111
|
-
};
|
112
|
-
AMSFileScanner.prototype.addNext = function (id, next) {
|
113
|
-
var _a, _b;
|
114
|
-
var scanResult = (_a = this.scanResults) === null || _a === void 0 ? void 0 : _a.get(id);
|
115
|
-
if (scanResult) {
|
116
|
-
(_b = this.scanResults) === null || _b === void 0 ? void 0 : _b.set(id, __assign(__assign({}, scanResult), { next: next }));
|
117
|
-
}
|
118
|
-
};
|
119
|
-
AMSFileScanner.prototype.addActivity = function (id, activity) {
|
120
|
-
var _a, _b;
|
121
|
-
var scanResult = (_a = this.scanResults) === null || _a === void 0 ? void 0 : _a.get(id);
|
122
|
-
if (scanResult) {
|
123
|
-
(_b = this.scanResults) === null || _b === void 0 ? void 0 : _b.set(id, __assign(__assign({}, scanResult), { activity: activity }));
|
124
|
-
}
|
125
|
-
};
|
126
|
-
AMSFileScanner.prototype.scanFileCallback = function (scanResult, id) {
|
127
|
-
var _a;
|
128
|
-
return __awaiter(this, void 0, void 0, function () {
|
129
|
-
var fileMetadata, next, activity, scan, response, view_location, scan_1, e_2;
|
130
|
-
return __generator(this, function (_b) {
|
131
|
-
switch (_b.label) {
|
132
|
-
case 0:
|
133
|
-
fileMetadata = scanResult.fileMetadata, next = scanResult.next, activity = scanResult.activity, scan = scanResult.scan;
|
134
|
-
if (!((scan === null || scan === void 0 ? void 0 : scan.status) === AMSFileManager_1.AMSViewScanStatus.INPROGRESS)) return [3 /*break*/, 10];
|
135
|
-
_b.label = 1;
|
136
|
-
case 1:
|
137
|
-
_b.trys.push([1, 7, , 8]);
|
138
|
-
return [4 /*yield*/, this.amsClient.getViewStatus(fileMetadata)];
|
139
|
-
case 2:
|
140
|
-
response = _b.sent();
|
141
|
-
view_location = response.view_location, scan_1 = response.scan;
|
142
|
-
this.addOrUpdateFile(id, scanResult.fileMetadata, scan_1);
|
143
|
-
if (!(scan_1.status === AMSFileManager_1.AMSViewScanStatus.PASSED && next && activity)) return [3 /*break*/, 4];
|
144
|
-
return [4 /*yield*/, this.renderAttachmentActivity(scanResult, view_location)];
|
145
|
-
case 3:
|
146
|
-
_b.sent();
|
147
|
-
_b.label = 4;
|
148
|
-
case 4:
|
149
|
-
if (!(scan_1.status === AMSFileManager_1.AMSViewScanStatus.MALWARE && next && activity)) return [3 /*break*/, 6];
|
150
|
-
return [4 /*yield*/, this.renderMalwareActivity(scanResult)];
|
151
|
-
case 5:
|
152
|
-
_b.sent();
|
153
|
-
_b.label = 6;
|
154
|
-
case 6: return [3 /*break*/, 8];
|
155
|
-
case 7:
|
156
|
-
e_2 = _b.sent();
|
157
|
-
console.error(e_2);
|
158
|
-
return [3 /*break*/, 8];
|
159
|
-
case 8: return [4 /*yield*/, WebUtils_1.default.sleep(((_a = this.options) === null || _a === void 0 ? void 0 : _a.scanStatusRetrievalDelay) || defaultScanStatusRetrievalDelay)];
|
160
|
-
case 9:
|
161
|
-
_b.sent();
|
162
|
-
_b.label = 10;
|
163
|
-
case 10: return [2 /*return*/];
|
164
|
-
}
|
165
|
-
});
|
166
|
-
});
|
167
|
-
};
|
168
|
-
AMSFileScanner.prototype.scanFiles = function () {
|
169
|
-
var _this = this;
|
170
|
-
// eslint-disable-next-line no-async-promise-executor
|
171
|
-
return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
|
172
|
-
var _this = this;
|
173
|
-
var _a;
|
174
|
-
return __generator(this, function (_b) {
|
175
|
-
(_a = this.scanResults) === null || _a === void 0 ? void 0 : _a.forEach(function (scanResult, id) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
176
|
-
switch (_a.label) {
|
177
|
-
case 0: return [4 /*yield*/, this.scanFileCallback(scanResult, id)];
|
178
|
-
case 1:
|
179
|
-
_a.sent();
|
180
|
-
return [2 /*return*/];
|
181
|
-
}
|
182
|
-
}); }); });
|
183
|
-
resolve();
|
184
|
-
return [2 /*return*/];
|
185
|
-
});
|
186
|
-
}); });
|
187
|
-
};
|
188
|
-
AMSFileScanner.prototype.end = function () {
|
189
|
-
this.shouldQueueScan = false;
|
190
|
-
};
|
191
|
-
AMSFileScanner.prototype.retrieveFileBlob = function (fileMetadata, view_location) {
|
192
|
-
return __awaiter(this, void 0, void 0, function () {
|
193
|
-
var blob, error_1;
|
194
|
-
return __generator(this, function (_a) {
|
195
|
-
switch (_a.label) {
|
196
|
-
case 0:
|
197
|
-
_a.trys.push([0, 2, , 3]);
|
198
|
-
return [4 /*yield*/, this.amsClient.getView(fileMetadata, view_location)];
|
199
|
-
case 1:
|
200
|
-
blob = _a.sent(); // eslint-disable-line @typescript-eslint/no-explicit-any
|
201
|
-
return [3 /*break*/, 3];
|
202
|
-
case 2:
|
203
|
-
error_1 = _a.sent();
|
204
|
-
console.error(error_1);
|
205
|
-
return [3 /*break*/, 3];
|
206
|
-
case 3: return [2 /*return*/, blob];
|
207
|
-
}
|
208
|
-
});
|
209
|
-
});
|
210
|
-
};
|
211
|
-
AMSFileScanner.prototype.addAttachmentToActivity = function (activity, file) {
|
212
|
-
return __awaiter(this, void 0, void 0, function () {
|
213
|
-
var attachmentData, attachmentSizes, index;
|
214
|
-
return __generator(this, function (_a) {
|
215
|
-
switch (_a.label) {
|
216
|
-
case 0: return [4 /*yield*/, activityUtils_1.default.getAttachments([file])];
|
217
|
-
case 1:
|
218
|
-
attachmentData = _a.sent();
|
219
|
-
return [4 /*yield*/, activityUtils_1.default.getAttachmentSizes([file])];
|
220
|
-
case 2:
|
221
|
-
attachmentSizes = _a.sent();
|
222
|
-
index = activity.attachments.findIndex(function (attachment) { return (attachment.name === file.name); });
|
223
|
-
activity.attachments[index] = attachmentData[0];
|
224
|
-
activity.channelData.attachmentSizes[index] = attachmentSizes[0];
|
225
|
-
return [2 /*return*/];
|
226
|
-
}
|
227
|
-
});
|
228
|
-
});
|
229
|
-
};
|
230
|
-
AMSFileScanner.prototype.renderAttachmentActivity = function (scanResult, view_location) {
|
231
|
-
return __awaiter(this, void 0, void 0, function () {
|
232
|
-
var fileMetadata, next, activity, blob, file, index, hasMultipleAttachments, amsreferences, fileIds;
|
233
|
-
var _this = this;
|
234
|
-
return __generator(this, function (_a) {
|
235
|
-
switch (_a.label) {
|
236
|
-
case 0:
|
237
|
-
fileMetadata = scanResult.fileMetadata, next = scanResult.next, activity = scanResult.activity;
|
238
|
-
return [4 /*yield*/, this.retrieveFileBlob(fileMetadata, view_location)];
|
239
|
-
case 1:
|
240
|
-
blob = _a.sent();
|
241
|
-
file = new File([blob], fileMetadata.name, { type: fileMetadata.type });
|
242
|
-
return [4 /*yield*/, this.addAttachmentToActivity(activity, file)];
|
243
|
-
case 2:
|
244
|
-
_a.sent();
|
245
|
-
index = activity.attachments.findIndex(function (attachment) { return (attachment.name === file.name); });
|
246
|
-
activity.channelData.fileScan[index] = { status: AMSFileManager_1.AMSViewScanStatus.PASSED };
|
247
|
-
hasMultipleAttachments = index > 0;
|
248
|
-
if (hasMultipleAttachments) {
|
249
|
-
amsreferences = activity.channelData.metadata.amsreferences;
|
250
|
-
fileIds = JSON.parse(amsreferences);
|
251
|
-
fileIds.forEach(function (fileId) {
|
252
|
-
_this.addActivity(fileId, activity);
|
253
|
-
});
|
254
|
-
}
|
255
|
-
next(activity); // Send updated activity to webchat
|
256
|
-
return [2 /*return*/];
|
257
|
-
}
|
258
|
-
});
|
259
|
-
});
|
260
|
-
};
|
261
|
-
AMSFileScanner.prototype.renderMalwareActivity = function (scanResult) {
|
262
|
-
return __awaiter(this, void 0, void 0, function () {
|
263
|
-
var fileMetadata, next, activity, index;
|
264
|
-
return __generator(this, function (_a) {
|
265
|
-
fileMetadata = scanResult.fileMetadata, next = scanResult.next, activity = scanResult.activity;
|
266
|
-
index = activity.attachments.findIndex(function (attachment) { return (attachment.name === fileMetadata.name); });
|
267
|
-
activity.channelData.fileScan[index] = { status: AMSFileManager_1.AMSViewScanStatus.MALWARE };
|
268
|
-
next(activity);
|
269
|
-
return [2 /*return*/];
|
270
|
-
});
|
271
|
-
});
|
272
|
-
};
|
273
|
-
return AMSFileScanner;
|
274
|
-
}());
|
275
|
-
exports.default = AMSFileScanner;
|
1
|
+
"use strict";
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
3
|
+
__assign = Object.assign || function(t) {
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5
|
+
s = arguments[i];
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
7
|
+
t[p] = s[p];
|
8
|
+
}
|
9
|
+
return t;
|
10
|
+
};
|
11
|
+
return __assign.apply(this, arguments);
|
12
|
+
};
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
20
|
+
});
|
21
|
+
};
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
26
|
+
function step(op) {
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
28
|
+
while (_) try {
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
31
|
+
switch (op[0]) {
|
32
|
+
case 0: case 1: t = op; break;
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
36
|
+
default:
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
41
|
+
if (t[2]) _.ops.pop();
|
42
|
+
_.trys.pop(); continue;
|
43
|
+
}
|
44
|
+
op = body.call(thisArg, _);
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
47
|
+
}
|
48
|
+
};
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
50
|
+
var WebUtils_1 = require("../../utils/WebUtils");
|
51
|
+
var AMSFileManager_1 = require("./AMSFileManager");
|
52
|
+
var activityUtils_1 = require("./activityUtils");
|
53
|
+
var defaultScanPollingInterval = 7 * 1000;
|
54
|
+
var defaultScanStatusRetrievalDelay = 1000;
|
55
|
+
var AMSFileScanner = /** @class */ (function () {
|
56
|
+
function AMSFileScanner(amsClient, options) {
|
57
|
+
if (options === void 0) { options = {}; }
|
58
|
+
this.scanResults = null;
|
59
|
+
this.amsClient = amsClient;
|
60
|
+
this.scanResults = new Map();
|
61
|
+
this.shouldQueueScan = false;
|
62
|
+
this.test = false;
|
63
|
+
this.options = options;
|
64
|
+
this.queueScan();
|
65
|
+
}
|
66
|
+
AMSFileScanner.prototype.queueScan = function () {
|
67
|
+
var _a;
|
68
|
+
return __awaiter(this, void 0, void 0, function () {
|
69
|
+
var e_1, _b;
|
70
|
+
return __generator(this, function (_c) {
|
71
|
+
switch (_c.label) {
|
72
|
+
case 0:
|
73
|
+
this.shouldQueueScan = true;
|
74
|
+
_c.label = 1;
|
75
|
+
case 1:
|
76
|
+
_c.trys.push([1, 3, 4, 8]);
|
77
|
+
return [4 /*yield*/, this.scanFiles()];
|
78
|
+
case 2:
|
79
|
+
_c.sent();
|
80
|
+
return [3 /*break*/, 8];
|
81
|
+
case 3:
|
82
|
+
e_1 = _c.sent();
|
83
|
+
console.error(e_1);
|
84
|
+
return [3 /*break*/, 8];
|
85
|
+
case 4: return [4 /*yield*/, WebUtils_1.default.sleep(((_a = this.options) === null || _a === void 0 ? void 0 : _a.pollingInterval) || defaultScanPollingInterval)];
|
86
|
+
case 5:
|
87
|
+
_c.sent();
|
88
|
+
_b = this.shouldQueueScan && !this.test;
|
89
|
+
if (!_b) return [3 /*break*/, 7];
|
90
|
+
return [4 /*yield*/, this.queueScan()];
|
91
|
+
case 6:
|
92
|
+
_b = (_c.sent());
|
93
|
+
_c.label = 7;
|
94
|
+
case 7:
|
95
|
+
_b;
|
96
|
+
return [7 /*endfinally*/];
|
97
|
+
case 8: return [2 /*return*/];
|
98
|
+
}
|
99
|
+
});
|
100
|
+
});
|
101
|
+
};
|
102
|
+
AMSFileScanner.prototype.retrieveFileScanResult = function (id) {
|
103
|
+
var _a;
|
104
|
+
return (_a = this.scanResults) === null || _a === void 0 ? void 0 : _a.get(id);
|
105
|
+
};
|
106
|
+
AMSFileScanner.prototype.addOrUpdateFile = function (id, fileMetadata, scan) {
|
107
|
+
var _a;
|
108
|
+
var scanResult = this.retrieveFileScanResult(id);
|
109
|
+
(_a = this.scanResults) === null || _a === void 0 ? void 0 : _a.set(id, __assign(__assign({}, (scanResult || {})), { fileMetadata: fileMetadata,
|
110
|
+
scan: scan }));
|
111
|
+
};
|
112
|
+
AMSFileScanner.prototype.addNext = function (id, next) {
|
113
|
+
var _a, _b;
|
114
|
+
var scanResult = (_a = this.scanResults) === null || _a === void 0 ? void 0 : _a.get(id);
|
115
|
+
if (scanResult) {
|
116
|
+
(_b = this.scanResults) === null || _b === void 0 ? void 0 : _b.set(id, __assign(__assign({}, scanResult), { next: next }));
|
117
|
+
}
|
118
|
+
};
|
119
|
+
AMSFileScanner.prototype.addActivity = function (id, activity) {
|
120
|
+
var _a, _b;
|
121
|
+
var scanResult = (_a = this.scanResults) === null || _a === void 0 ? void 0 : _a.get(id);
|
122
|
+
if (scanResult) {
|
123
|
+
(_b = this.scanResults) === null || _b === void 0 ? void 0 : _b.set(id, __assign(__assign({}, scanResult), { activity: activity }));
|
124
|
+
}
|
125
|
+
};
|
126
|
+
AMSFileScanner.prototype.scanFileCallback = function (scanResult, id) {
|
127
|
+
var _a;
|
128
|
+
return __awaiter(this, void 0, void 0, function () {
|
129
|
+
var fileMetadata, next, activity, scan, response, view_location, scan_1, e_2;
|
130
|
+
return __generator(this, function (_b) {
|
131
|
+
switch (_b.label) {
|
132
|
+
case 0:
|
133
|
+
fileMetadata = scanResult.fileMetadata, next = scanResult.next, activity = scanResult.activity, scan = scanResult.scan;
|
134
|
+
if (!((scan === null || scan === void 0 ? void 0 : scan.status) === AMSFileManager_1.AMSViewScanStatus.INPROGRESS)) return [3 /*break*/, 10];
|
135
|
+
_b.label = 1;
|
136
|
+
case 1:
|
137
|
+
_b.trys.push([1, 7, , 8]);
|
138
|
+
return [4 /*yield*/, this.amsClient.getViewStatus(fileMetadata)];
|
139
|
+
case 2:
|
140
|
+
response = _b.sent();
|
141
|
+
view_location = response.view_location, scan_1 = response.scan;
|
142
|
+
this.addOrUpdateFile(id, scanResult.fileMetadata, scan_1);
|
143
|
+
if (!(scan_1.status === AMSFileManager_1.AMSViewScanStatus.PASSED && next && activity)) return [3 /*break*/, 4];
|
144
|
+
return [4 /*yield*/, this.renderAttachmentActivity(scanResult, view_location)];
|
145
|
+
case 3:
|
146
|
+
_b.sent();
|
147
|
+
_b.label = 4;
|
148
|
+
case 4:
|
149
|
+
if (!(scan_1.status === AMSFileManager_1.AMSViewScanStatus.MALWARE && next && activity)) return [3 /*break*/, 6];
|
150
|
+
return [4 /*yield*/, this.renderMalwareActivity(scanResult)];
|
151
|
+
case 5:
|
152
|
+
_b.sent();
|
153
|
+
_b.label = 6;
|
154
|
+
case 6: return [3 /*break*/, 8];
|
155
|
+
case 7:
|
156
|
+
e_2 = _b.sent();
|
157
|
+
console.error(e_2);
|
158
|
+
return [3 /*break*/, 8];
|
159
|
+
case 8: return [4 /*yield*/, WebUtils_1.default.sleep(((_a = this.options) === null || _a === void 0 ? void 0 : _a.scanStatusRetrievalDelay) || defaultScanStatusRetrievalDelay)];
|
160
|
+
case 9:
|
161
|
+
_b.sent();
|
162
|
+
_b.label = 10;
|
163
|
+
case 10: return [2 /*return*/];
|
164
|
+
}
|
165
|
+
});
|
166
|
+
});
|
167
|
+
};
|
168
|
+
AMSFileScanner.prototype.scanFiles = function () {
|
169
|
+
var _this = this;
|
170
|
+
// eslint-disable-next-line no-async-promise-executor
|
171
|
+
return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
|
172
|
+
var _this = this;
|
173
|
+
var _a;
|
174
|
+
return __generator(this, function (_b) {
|
175
|
+
(_a = this.scanResults) === null || _a === void 0 ? void 0 : _a.forEach(function (scanResult, id) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
176
|
+
switch (_a.label) {
|
177
|
+
case 0: return [4 /*yield*/, this.scanFileCallback(scanResult, id)];
|
178
|
+
case 1:
|
179
|
+
_a.sent();
|
180
|
+
return [2 /*return*/];
|
181
|
+
}
|
182
|
+
}); }); });
|
183
|
+
resolve();
|
184
|
+
return [2 /*return*/];
|
185
|
+
});
|
186
|
+
}); });
|
187
|
+
};
|
188
|
+
AMSFileScanner.prototype.end = function () {
|
189
|
+
this.shouldQueueScan = false;
|
190
|
+
};
|
191
|
+
AMSFileScanner.prototype.retrieveFileBlob = function (fileMetadata, view_location) {
|
192
|
+
return __awaiter(this, void 0, void 0, function () {
|
193
|
+
var blob, error_1;
|
194
|
+
return __generator(this, function (_a) {
|
195
|
+
switch (_a.label) {
|
196
|
+
case 0:
|
197
|
+
_a.trys.push([0, 2, , 3]);
|
198
|
+
return [4 /*yield*/, this.amsClient.getView(fileMetadata, view_location)];
|
199
|
+
case 1:
|
200
|
+
blob = _a.sent(); // eslint-disable-line @typescript-eslint/no-explicit-any
|
201
|
+
return [3 /*break*/, 3];
|
202
|
+
case 2:
|
203
|
+
error_1 = _a.sent();
|
204
|
+
console.error(error_1);
|
205
|
+
return [3 /*break*/, 3];
|
206
|
+
case 3: return [2 /*return*/, blob];
|
207
|
+
}
|
208
|
+
});
|
209
|
+
});
|
210
|
+
};
|
211
|
+
AMSFileScanner.prototype.addAttachmentToActivity = function (activity, file) {
|
212
|
+
return __awaiter(this, void 0, void 0, function () {
|
213
|
+
var attachmentData, attachmentSizes, index;
|
214
|
+
return __generator(this, function (_a) {
|
215
|
+
switch (_a.label) {
|
216
|
+
case 0: return [4 /*yield*/, activityUtils_1.default.getAttachments([file])];
|
217
|
+
case 1:
|
218
|
+
attachmentData = _a.sent();
|
219
|
+
return [4 /*yield*/, activityUtils_1.default.getAttachmentSizes([file])];
|
220
|
+
case 2:
|
221
|
+
attachmentSizes = _a.sent();
|
222
|
+
index = activity.attachments.findIndex(function (attachment) { return (attachment.name === file.name); });
|
223
|
+
activity.attachments[index] = attachmentData[0];
|
224
|
+
activity.channelData.attachmentSizes[index] = attachmentSizes[0];
|
225
|
+
return [2 /*return*/];
|
226
|
+
}
|
227
|
+
});
|
228
|
+
});
|
229
|
+
};
|
230
|
+
AMSFileScanner.prototype.renderAttachmentActivity = function (scanResult, view_location) {
|
231
|
+
return __awaiter(this, void 0, void 0, function () {
|
232
|
+
var fileMetadata, next, activity, blob, file, index, hasMultipleAttachments, amsreferences, fileIds;
|
233
|
+
var _this = this;
|
234
|
+
return __generator(this, function (_a) {
|
235
|
+
switch (_a.label) {
|
236
|
+
case 0:
|
237
|
+
fileMetadata = scanResult.fileMetadata, next = scanResult.next, activity = scanResult.activity;
|
238
|
+
return [4 /*yield*/, this.retrieveFileBlob(fileMetadata, view_location)];
|
239
|
+
case 1:
|
240
|
+
blob = _a.sent();
|
241
|
+
file = new File([blob], fileMetadata.name, { type: fileMetadata.type });
|
242
|
+
return [4 /*yield*/, this.addAttachmentToActivity(activity, file)];
|
243
|
+
case 2:
|
244
|
+
_a.sent();
|
245
|
+
index = activity.attachments.findIndex(function (attachment) { return (attachment.name === file.name); });
|
246
|
+
activity.channelData.fileScan[index] = { status: AMSFileManager_1.AMSViewScanStatus.PASSED };
|
247
|
+
hasMultipleAttachments = index > 0;
|
248
|
+
if (hasMultipleAttachments) {
|
249
|
+
amsreferences = activity.channelData.metadata.amsreferences;
|
250
|
+
fileIds = JSON.parse(amsreferences);
|
251
|
+
fileIds.forEach(function (fileId) {
|
252
|
+
_this.addActivity(fileId, activity);
|
253
|
+
});
|
254
|
+
}
|
255
|
+
next(activity); // Send updated activity to webchat
|
256
|
+
return [2 /*return*/];
|
257
|
+
}
|
258
|
+
});
|
259
|
+
});
|
260
|
+
};
|
261
|
+
AMSFileScanner.prototype.renderMalwareActivity = function (scanResult) {
|
262
|
+
return __awaiter(this, void 0, void 0, function () {
|
263
|
+
var fileMetadata, next, activity, index;
|
264
|
+
return __generator(this, function (_a) {
|
265
|
+
fileMetadata = scanResult.fileMetadata, next = scanResult.next, activity = scanResult.activity;
|
266
|
+
index = activity.attachments.findIndex(function (attachment) { return (attachment.name === fileMetadata.name); });
|
267
|
+
activity.channelData.fileScan[index] = { status: AMSFileManager_1.AMSViewScanStatus.MALWARE };
|
268
|
+
next(activity);
|
269
|
+
return [2 /*return*/];
|
270
|
+
});
|
271
|
+
});
|
272
|
+
};
|
273
|
+
return AMSFileScanner;
|
274
|
+
}());
|
275
|
+
exports.default = AMSFileScanner;
|
276
276
|
//# sourceMappingURL=AMSFileScanner.js.map
|
@@ -1,9 +1,9 @@
|
|
1
|
-
export declare const getDataURL: (file: File) => Promise<string | ArrayBuffer>;
|
2
|
-
export declare const getAttachments: (files: File[]) => Promise<Array<any>>;
|
3
|
-
export declare const getAttachmentSizes: (files: File[]) => number[];
|
4
|
-
declare const _default: {
|
5
|
-
getDataURL: (file: File) => Promise<string | ArrayBuffer>;
|
6
|
-
getAttachments: (files: File[]) => Promise<any[]>;
|
7
|
-
getAttachmentSizes: (files: File[]) => number[];
|
8
|
-
};
|
9
|
-
export default _default;
|
1
|
+
export declare const getDataURL: (file: File) => Promise<string | ArrayBuffer>;
|
2
|
+
export declare const getAttachments: (files: File[]) => Promise<Array<any>>;
|
3
|
+
export declare const getAttachmentSizes: (files: File[]) => number[];
|
4
|
+
declare const _default: {
|
5
|
+
getDataURL: (file: File) => Promise<string | ArrayBuffer>;
|
6
|
+
getAttachments: (files: File[]) => Promise<any[]>;
|
7
|
+
getAttachmentSizes: (files: File[]) => number[];
|
8
|
+
};
|
9
|
+
export default _default;
|