@attachmentav/virus-scan-sdk-ts

中文文档
0.8.0发布于 2026/07/10MITTypeScriptESM + CJS零依赖近 30 天下载 4472

An SDK to integrate virus and malware scan capabilities into JavaScript / TypeScript applications. Scan files for viruses, trojans, and other kinds of malware with attachmentAV powered by Sophos.

原始使用文档
文档目录19 节
  1. Getting started
  2. What is attachmentAV?
  3. Install SDK
  4. Configure SDK
  5. Configure SDK (SaaS)
  6. Configure SDK (self-hosted on AWS)
  7. Examples
  8. Sync Scan: File
  9. Sync Scan: Download
  10. Sync Scan: S3
  11. Async Scan: Download (callback)
  12. Async Scan: Download (polling)
  13. Async Scan: S3 (callback)
  14. Async Scan: S3 (polling)
  15. List callback failures
  16. Who Am I
  17. Usage
  18. Model
  19. Need help?

attachmentav-sdk-ts

An SDK to integrate virus and malware scan capabilities into JavaScript / TypeScript applications. Scan files for viruses, trojans, and other kinds of malware with attachmentAV powered by Sophos.

Getting started

First, install the module.

npm i @attachmentav/virus-scan-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 and <API_ENDPOINT_PLACEHOLDER> with the API endpoint.

API endpoints (SaaS)

  • https://eu.developer.attachmentav.com/v1/ (Europe)
  • https://us.developer.attachmentav.com/v1/ (United States of America)
  • https://canada.developer.attachmentav.com/v1/ (Canada)
  • https://india.developer.attachmentav.com/v1/ (India)
  • https://australia.developer.attachmentav.com/v1/ (Australia)

API endpoint (Self-hosted on AWS)

When following the setup guide, you specified the ApiKeys parameter for the CloudFormation stack. Replace <API_KEY_PLACEHOLDER> with one of those keys and <API_ENDPOINT_PLACEHOLDER> with the API endpoint.

Example, replace attachmentav.yourcompany.com with the domain name of your attachmentAV API installation: https://attachmentav.yourcompany.com/api/v1.

import { AttachmentAVApi, Configuration } from '@attachmentav/virus-scan-sdk-ts';
import { readFileSync } from 'node:fs';
import { Blob } from 'node:buffer';

const config = new Configuration({
  apiKey: '<API_KEY_PLACEHOLDER>',
  basePath: '<API_ENDPOINT_PLACEHOLDER>'
});

const api = new AttachmentAVApi(config);

const scanResult = await api.scanSyncBinaryPost({
  body: new Blob([readFileSync('/path/to/file')])
});
console.log('Sync binary scan result:', scanResult);

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'
}

What is attachmentAV?

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 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.

Install SDK

npm i @attachmentav/virus-scan-sdk-ts

Configure SDK

Configure SDK (SaaS)

An active subscription and API key are required. Replace <API_KEY_PLACEHOLDER> with the API key and <API_ENDPOINT_PLACEHOLDER> with the API endpoint. The API endpoint (region) must match with the region selected for the subscription. The default is Europe.

  • https://eu.developer.attachmentav.com/v1/ (Europe)
  • https://us.developer.attachmentav.com/v1/ (United States of America)
  • https://canada.developer.attachmentav.com/v1/ (Canada)
  • https://india.developer.attachmentav.com/v1/ (India)
  • https://australia.developer.attachmentav.com/v1/ (Australia)
import { AttachmentAVApi, Configuration } from '@attachmentav/virus-scan-sdk-ts';

const config = new Configuration({
  apiKey: '<API_KEY_PLACEHOLDER>',
  basePath: '<API_ENDPOINT_PLACEHOLDER>'
});

const api = new AttachmentAVApi(config);

Configure SDK (self-hosted on AWS)

When following the setup guide, you specified the ApiKeys parameter for the CloudFormation stack. Replace <API_KEY_PLACEHOLDER> with one of those keys and <API_ENDPOINT_PLACEHOLDER> with the API endpoint.

Example, replace attachmentav.yourcompany.com with the domain name of your attachmentAV API installation: https://attachmentav.yourcompany.com/api/v1.

import { AttachmentAVApi, Configuration } from '@attachmentav/virus-scan-sdk-ts';

const config = new Configuration({
  accessToken: '<API_KEY_PLACEHOLDER>',
  basePath: '<API_ENDPOINT_PLACEHOLDER>'
});

const api = new AttachmentAVApi(config);

Examples

Sync Scan: File

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 scanResult = await api.scanSyncBinaryPost({
  body: new Blob([readFileSync('/path/to/file')])
});
console.log('Sync binary scan result:', scanResult);

Find full example: ts, mjs, cjs

Sync Scan: Download

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://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf'
  }
});
console.log('Sync download scan result:', scanResult);

Find full example: ts, mjs, cjs

Sync Scan: S3

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: '<BUCKET_NAME_PLACEHOLDER>',
    key: '<OBJECT_KEY_PLACEHOLDER>'
  }
});
console.log('Sync S3 scan result:', scanResult);

Find full example: ts, mjs, cjs

Async Scan: Download (callback)

Send a URL to the attachmentAV Virus Scan API. attachmentAV will download the file and send the scan result to the callback.

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 [email protected] to let us know, in case you need this feature.

await api.scanAsyncDownloadPost({
  asyncDownloadScanRequest: {
    downloadUrl: 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf',
    callbackUrl: 'https://api.yourcompany.com/attachmentav/callback'
  }
});
console.log('Async download submitted');

Find full example: ts, mjs, cjs

Async Scan: Download (polling)

Send a URL to the attachmentAV Virus Scan API. attachmentAV will download the file and store the scan result for 24 hours.

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 [email protected] to let us know, in case you need this feature.

const traceId = crypto.randomUUID();

await api.scanAsyncDownloadPost({
  asyncDownloadScanRequest: {
    downloadUrl: 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf',
    traceId
  }
});
console.log('Async download submitted.');

// wait some time...

const scanResult = await api.scanAsyncResultGet({
  traceId
});
console.log('Async download scan result:', scanResult);

Find full example: ts, mjs, cjs

Async Scan: S3 (callback)

Send an S3 bucket name and object key to the attachmentAV Virus Scan API. attachmentAV will download the file and send the scan result to the callback.

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 [email protected] to let us know, in case you need this feature.

await api.scanAsyncS3Post({
  asyncS3ScanRequest: {
    bucket: '<BUCKET_NAME_PLACEHOLDER>',
    key: '<OBJECT_KEY_PLACEHOLDER>',
    callbackUrl: 'https://api.yourcompany.com/attachmentav/callback'
  }
});
console.log('Async S3 submitted');

Find full example: ts, mjs, cjs

Async Scan: S3 (polling)

Send an S3 bucket name and object key to the attachmentAV Virus Scan API. attachmentAV will download the file and store the scan result for 24 hours.

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 [email protected] to let us know, in case you need this feature.

const traceId = crypto.randomUUID();

await api.scanAsyncS3Post({
  asyncS3ScanRequest: {
    bucket: '<BUCKET_NAME_PLACEHOLDER>',
    key: '<OBJECT_KEY_PLACEHOLDER>',
    traceId
  }
});
console.log('Async S3 submitted.');

// wait some time...

const scanResult = await api.scanAsyncResultGet({
  traceId
});
console.log('Async download scan result:', scanResult);

Find full example: ts, mjs, cjs

List callback failures

List callback failures that prevent attachmentAV from invoking the defined callback_url. Sorted by time in descending order (youngest failure is returned first). Callback failures are stored for 30 days.

See CallbackFailures for details.

Not supported by attachmentAV Virus Scan API (Self-hosted on AWS).

const res = await api.callbackFailuresGet({
  callbackUrl: 'https://api.yourcompany.com/attachmentav/callback'
});
console.log('Callback failures', res);

Find full example: ts, mjs, cjs

Who Am I

Get information about yourself.

See Whoami for details.

Not supported by attachmentAV Virus Scan API (Self-hosted on AWS).

const res = await api.whoamiGet();
console.log('Who am I?', res);

Find full example: ts, mjs, cjs

Usage

Get remaining credits and quota.

See Usage for details.

Not supported by attachmentAV Virus Scan API (Self-hosted on AWS).

const res = await api.usageGet();
console.log('Usage', res);

Find full example: ts, mjs, cjs

Model

For more details about the data model, please refer to the following pages.

Need help?

Do you need any help to get started with attachmentAV? [email protected].

版本与发布记录

@attachmentav/virus-scan-sdk-ts 共发布 8 个版本,首次发布于 2025/07/21;过去 12 个月发布了 2 个版本。

版本发布日期距今
0.8.0latest2026/07/103 个月前
0.7.02025/12/1810 个月前
0.6.02025/10/301 年前
0.5.02025/10/241 年前
0.4.02025/09/261.1 年前
0.3.02025/09/261.1 年前

关于 @attachmentav/virus-scan-sdk-ts 的常见问题

@attachmentav/virus-scan-sdk-ts 是什么?

An SDK to integrate virus and malware scan capabilities into JavaScript / TypeScript applications. Scan files for viruses, trojans, and other kinds of malware with attachmentAV powered by Sophos.

如何安装 @attachmentav/virus-scan-sdk-ts?

在项目目录运行 npm install @attachmentav/virus-scan-sdk-ts,或使用 pnpm add / yarn add / bun add。

@attachmentav/virus-scan-sdk-ts 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@attachmentav/virus-scan-sdk-ts 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@attachmentav/virus-scan-sdk-ts 可以商用吗?

@attachmentav/virus-scan-sdk-ts 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@attachmentav/virus-scan-sdk-ts 的下载量有多少?

根据 npm 官方下载统计,@attachmentav/virus-scan-sdk-ts 在 2026/10/07 – 2026/11/05 这 30 天内被下载 4,472 次,日均约 149 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@attachmentav/virus-scan-sdk-ts 还在维护吗?

最新版本 0.8.0 发布于 2026/07/10(3 个月前);至今共发布 8 个版本,其中过去 12 个月发布了 2 个;首次发布于 2025/07/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。