An SDK to integrate virus and malware scan capabilities into TypeScript applications. Scan files for viruses, trojans, and other kinds of malware with attachmentAV powered by Sophos.
First, install the module.
npm i @widdix/attachmentav-sdk-ts
Second, get an API key by subscribing to the attachmentAV API (SaaS).
Third, send a scan request. Make sure to replace the API_KEY_PLACEHOLDER
placeholder.
import { AttachmentAVApi, Configuration } from './sdk';
import * as fs from 'fs';
const config = new Configuration({
apiKey: '<API_KEY_PLACEHOLDER>'
});
const api = new AttachmentAVApi(config);
async function scanFile() {
const fileBuffer = fs.readFileSync('./demo.txt');
const blob = new Blob([fileBuffer]);
const scanResult = await api.scanSyncBinaryPost({
body: blob
});
console.log('Sync binary scan result:', scanResult);
}
scanFile();
The request returns a scan result similar to the following example.
Sync binary scan result: {
status: 'clean',
finding: undefined,
size: 8100,
realfiletype: 'ASCII text / 8-bit Unicode Transformation Format'
}
attachmentAV offers antivirus for SaaS and cloud platforms. Scan your files and attachments stored in the cloud for viruses, worms, and trojans. attachmentAV detects malware in real-time. Supports Amazon S3, Atlassian, Cloudflare R2, Salesforce, WordPress, and more.
The attachmentAV Virus and Malware Scan API provides a REST API that allows you to integrate malware scans into your application. The solution comes in two variants:
- attachmentAV Virus Scan API (SaaS): Get started quickly with a fully managed service.
- attachmentAV Virus Scan API (self-hosted on AWS): Deploy the production-ready API on AWS.
attachmentAV raises the bar for information security. Our solution is ISO 27001 certified and GDPR compliant. We are establishing, implementing, maintaining, and continually improving an information security management system (ISMS). Sensitive data is encrypted in transit as well as at rest and deleted immediately after processing. More than 1,000 customers trust our malware protection technology.
npm i @widdix/attachmentav-sdk-ts
An active subscription and API key are required. Replace <API_KEY_PLACEHOLDER>
with the API key.
import { AttachmentAVApi, Configuration } from '@widdix/attachmentav-sdk-ts';
const config = new Configuration({
apiKey: '<API_KEY_PLACEHOLDER>',
});
const api = new AttachmentAVApi(config);
When following the setup guide, you specified the ApiKeys
parameter for the CloudFormation stack. Replace <API_KEY_PLACEHOLDER>
with one of those keys.
import { AttachmentAVApi, Configuration } from '@widdix/attachmentav-sdk-ts';
const config = new Configuration({
apiKey: '<API_KEY_PLACEHOLDER>',
basePath: 'https://example.com/api/v1'
});
const api = new AttachmentAVApi(config);
Send a file to the attachmentAV Virus Scan API and process the scan result.
See ScanResult for details.
The maximum file size is 10 MB. The request timeout is 60 seconds.
const fileBuffer = fs.readFileSync('./README.ts');
const blob = new Blob([fileBuffer]);
const scanResult = await api.scanSyncBinaryPost({
body: blob
});
console.log('Sync binary scan result:', scanResult);
Send a URL to the attachmentAV Virus Scan API. attachmentAV will download the file and return the scan result immediately.
See SyncDownloadScanRequest and ScanResult for details.
The maximum file size is 10 MB. The request timeout is 60 seconds.
const scanResult = await api.scanSyncDownloadPost({
syncDownloadScanRequest: {
downloadUrl: 'https://example.com/demo.txt'
}
});
console.log('Sync download scan result:', scanResult);
Send an S3 bucket name and object key to the attachmentAV Virus Scan API. attachmentAV will download the file and return the scan result immediately.
See SyncS3ScanRequest and ScanResult for details.
The maximum file size is 10 MB. The request timeout is 60 seconds.
A bucket policy is required to grant attachmentAV access to private S3 objects.
const scanResult = await api.scanSyncS3Post({
syncS3ScanRequest: {
bucket: 'example-bucket',
key: 'demo.txt',
}
});
console.log('Sync S3 scan result:', scanResult);
Send a URL to the attachmentAV Virus Scan API. attachmentAV will send the scan result to the callback URL. See callback URL for details.
See AsyncDownloadScanRequest for details.
The maximum file size is 5 GB. The request timeout is 29 seconds; the asynchronous scan job is not affected by this limit.
Not supported by attachmentAV Virus Scan API (Self-hosted on AWS) yet. Contact hello@attachmentav.com to let us know, in case you need this feature.
await api.scanAsyncDownloadPost({
asyncDownloadScanRequest: {
downloadUrl: 'https://example.com/demo.txt',
callbackUrl: 'https://example.com/callback'
}
});
console.log('Async download scan request submitted');
Send an S3 bucket name and object key to the attachmentAV Virus Scan API. attachmentAV will send the scan result to the callback URL. See callback URL for details.
See AsyncS3ScanRequest for details.
The maximum file size is 5 GB. The request timeout is 29 seconds; the asynchronous scan job is not affected by this limit.
A bucket policy is required to grant attachmentAV access to private S3 objects.
Not supported by attachmentAV Virus Scan API (Self-hosted on AWS) yet. Contact hello@attachmentav.com to let us know, in case you need this feature.
await api.scanAsyncS3Post({
asyncS3ScanRequest: {
bucket: 'example-bucket',
key: 'demo.txt',
callbackUrl: 'https://example.com/callback'
}
});
console.log('Async S3 scan request submitted');
For more details about the data model, please refer to the following pages.
- AsyncDownloadScanRequest
- AsyncS3ScanRequest
- AttachmentAVApi
- ScanResult
- SyncDownloadScanRequest
- SyncS3ScanRequest
Do you need any help to get started with attachmentAV? hello@attachmentav.com.