# @attachmentav/virus-scan-sdk-ts 中文文档

规范地址：https://npmcn.com/package/%40attachmentav/virus-scan-sdk-ts/

版本：0\.8\.0
npm 元数据更新时间：2026-07-09T19:46:50.574Z
中文译文更新时间：2026-11-07T04:01:33.135Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40attachmentav/virus-scan-sdk-ts
原文对照：https://npmcn.com/package/%40attachmentav/virus-scan-sdk-ts/?lang=original
项目主页：https://github.com/widdix/attachmentav-sdk-ts#readme
源码仓库：https://github.com/widdix/attachmentav-sdk-ts

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：326 kB，9 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：0 个
- 首次发布：2025-07-21T09:25:35.472Z
- 最新版本发布：2026-07-09T19:46:50.366Z
- 近 30 天下载量：4472（2026-10-07 至 2026-11-05，npm 官方下载统计）
- 已发布版本数：8（近 12 个月 2 个）

## 中文简介

一个SDK将病毒和恶意软件扫描能力整合到JavaScript / TypeScript应用中. 扫描由索福斯提供附件AV的病毒,trojans等恶意软件的文件.

## 安装

```sh
npm install @attachmentav/virus-scan-sdk-ts
```

也可以使用：`pnpm add @attachmentav/virus-scan-sdk-ts`、`yarn add @attachmentav/virus-scan-sdk-ts`、`bun add @attachmentav/virus-scan-sdk-ts`

## README

# 附 件 - sdk - ts

一个SDK将病毒和恶意软件扫描能力整合到JavaScript / TypeScript应用中. 扫描病毒、trojans和其他恶意软件的文件 [附录AV](https://attachmentav.com/) 由索福斯提供动力.

## 开始

首先,安装模块.

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

第二,通过 [订阅附件AV API( SaaS)](https://attachmentav.com/subscribe/api/)。 。 。 .

第三,发送扫描请求。 确保替换 `<API_KEY_PLACEHOLDER>` 占位符和 `<API_ENDPOINT_PLACEHOLDER>` 与 API 结尾.

**API 终点( SaaS)**

-   `https://eu.developer.attachmentav.com/v1/` (欧洲)
-   `https://us.developer.attachmentav.com/v1/` (美利坚合众国)
-   `https://canada.developer.attachmentav.com/v1/` (加拿大)
-   `https://india.developer.attachmentav.com/v1/` (印度)
-   `https://australia.developer.attachmentav.com/v1/` (澳大利亚)

**API 端点(自动托管在 AWS 上)**

当遵循设置指南时,您指定了 `ApiKeys` cloudFormation 堆栈的参数。 替换 `<API_KEY_PLACEHOLDER>` 拿着一把钥匙 `<API_ENDPOINT_PLACEHOLDER>` 与 API 结尾.

示例,替换 `attachmentav.yourcompany.com` 带有您的域名 [附件AV API 安装](https://attachmentav.com/help/virus-malware-scan-api-aws/developer/definition.html#domain-name)数字 : `https://attachmentav.yourcompany.com/api/v1`。 。 。 .

```javascript
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);
```

请求返回一个类似于以下示例的扫描结果 .

```
Sync binary scan result: {
  status: 'clean',
  finding: undefined,
  size: 8100,
  realfiletype: 'ASCII text / 8-bit Unicode Transformation Format'
}
```

## 什么是附件AV吗?

[附录AV](https://attachmentav.com/) 为SaaS和云平台提供抗病毒. 扫描云中储存的病毒、蠕虫和特洛伊生物的文件和附件。 附件AV实时检测恶意软件. 支持Amazon S3, Atlassian, Cloudflare R2, Salesforce, WordPress 等.

这个 [附件AV 病毒和恶意软件扫描 API](https://attachmentav.com/solution/virus-malware-scan-api/) 提供 REST API 允许您将恶意软件扫描整合到您的应用程序中。 溶液分为两种:

-   [附件AV 病毒扫描 API (SaaS)](https://attachmentav.com/help/virus-malware-scan-api/setup-guide/):快速启动全管服务.
-   [附件AV病毒扫描API(自发托管于AWS)](https://attachmentav.com/help/virus-malware-scan-api-aws/setup-guide/)在AWS上部署生产准备的API.

附件AV提高了信息安全栏。 我们的解决办法是ISO 27001认证和符合GDPR。 我们正在建立、执行、维持并不断改进信息安全管理系统。 敏感数据在过境和休息时加密,处理后立即删除。 1000多名客户信任我们的恶意软件保护技术.

## 安装 SDK

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

## 配置 SDK

### 配置 SDK (SaaS)

一个 [活动订阅和 API 密钥](https://attachmentav.com/help/virus-malware-scan-api/setup-guide/#api-key) 需要这样做。 替换 `<API_KEY_PLACEHOLDER>` 带有 API 密钥和 `<API_ENDPOINT_PLACEHOLDER>` 与 API 结尾。 API端点(区域)必须与选择订阅的区域相匹配. 默认是 `Europe`。 。 。 .

-   `https://eu.developer.attachmentav.com/v1/` (欧洲)
-   `https://us.developer.attachmentav.com/v1/` (美利坚合众国)
-   `https://canada.developer.attachmentav.com/v1/` (加拿大)
-   `https://india.developer.attachmentav.com/v1/` (印度)
-   `https://australia.developer.attachmentav.com/v1/` (澳大利亚)

```javascript
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);
```

### 配置 SDK( 自动托管在 AWS 上)

当遵循设置指南时,您指定了 `ApiKeys` cloudFormation 堆栈的参数。 替换 `<API_KEY_PLACEHOLDER>` 拿着一把钥匙 `<API_ENDPOINT_PLACEHOLDER>` 与 API 结尾.

示例,替换 `attachmentav.yourcompany.com` 带有您的域名 [附件AV API 安装](https://attachmentav.com/help/virus-malware-scan-api-aws/developer/definition.html#domain-name)数字 : `https://attachmentav.yourcompany.com/api/v1`。 。 。 .

```javascript
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);
```

## 实例

### 同步扫描: 文件

向附件AV病毒扫描API发送文件并处理扫描结果.

见 [扫描结果](https://npmcn.com/package/%40attachmentav/virus-scan-sdk-ts/sdk/models/ScanResult.ts) 详细情况.

最大文件大小为10 MB. 请求超时为60秒.

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

查找完整的示例 : [吨数](https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/sync-binary.ts), (中文(简体) ), [数字](https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/sync-binary.mjs), (中文(简体) ), [(单位:千美元)](https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/sync-binary.cjs)

### 同步扫描: 下载

发送 URL 到附件AV 病毒扫描 API 。 附件AV将下载文件并立即返回扫描结果.

见 [同步下载扫描请求](https://npmcn.com/package/%40attachmentav/virus-scan-sdk-ts/sdk/models/SyncDownloadScanRequest.ts) 财务报告和审定财务报表 [扫描结果](https://npmcn.com/package/%40attachmentav/virus-scan-sdk-ts/sdk/models/ScanResult.ts) 详细情况.

最大文件大小为10 MB. 请求超时为60秒.

```javascript
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);
```

查找完整的示例 : [吨数](https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/sync-download.ts), (中文(简体) ), [数字](https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/sync-download.mjs), (中文(简体) ), [(单位:千美元)](https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/sync-download.cjs)

### 同步扫描: S3

发送附件AV病毒扫描API的 S3 桶名和对象密钥 。 附件AV将下载文件并立即返回扫描结果.

见 [同步 S3 扫描请求](https://npmcn.com/package/%40attachmentav/virus-scan-sdk-ts/sdk/models/SyncS3ScanRequest.ts) 财务报告和审定财务报表 [扫描结果](https://npmcn.com/package/%40attachmentav/virus-scan-sdk-ts/sdk/models/ScanResult.ts) 详细情况.

最大文件大小为10 MB. 请求超时为60秒.

> A 类 [桶政策](https://attachmentav.com/help/virus-malware-scan-api/setup-guide/#s3-bucket-policy) 需要允许附件AV访问私人S3对象.

```javascript
const scanResult = await api.scanSyncS3Post({
  syncS3ScanRequest: {
    bucket: '<BUCKET_NAME_PLACEHOLDER>',
    key: '<OBJECT_KEY_PLACEHOLDER>'
  }
});
console.log('Sync S3 scan result:', scanResult);
```

查找完整的示例 : [吨数](https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/sync-s3.ts), (中文(简体) ), [数字](https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/sync-s3.mjs), (中文(简体) ), [(单位:千美元)](https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/sync-s3.cjs)

### Async 扫描: 下载( 回调)

发送 URL 到附件AV 病毒扫描 API 。 附件AV将下载文件,并将扫描结果发送给 [回调](https://attachmentav.com/help/virus-malware-scan-api/developer/definition.html#callback)。 。 。 .

见 [自动下载请求](https://npmcn.com/package/%40attachmentav/virus-scan-sdk-ts/sdk/models/AsyncDownloadScanRequest.ts) 详细情况.

最大文件大小为5 GB. 请求超时为29秒;同步扫描任务不受此限制的影响.

> 尚未获得附件AV病毒扫描API(自发托管于AWS)的支持. 联系人 [你好@attachmentav.com](https://npmcn.com/package/%40attachmentav/virus-scan-sdk-ts/hello@attachmentav.com) 告诉我们,如果你需要这个特征.

```javascript
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');
```

查找完整的示例 : [吨数](https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/async-download.ts), (中文(简体) ), [数字](https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/async-download.mjs), (中文(简体) ), [(单位:千美元)](https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/async-download.cjs)

### Async 扫描: 下载 (波浪)

发送 URL 到附件AV 病毒扫描 API 。 附件AV将下载文件并存储扫描结果24小时.

见 [自动下载请求](https://npmcn.com/package/%40attachmentav/virus-scan-sdk-ts/sdk/models/AsyncDownloadScanRequest.ts) 详细情况.

最大文件大小为5 GB. 请求超时为29秒;同步扫描任务不受此限制的影响.

> 尚未获得附件AV病毒扫描API(自发托管于AWS)的支持. 联系人 [你好@attachmentav.com](https://npmcn.com/package/%40attachmentav/virus-scan-sdk-ts/hello@attachmentav.com) 告诉我们,如果你需要这个特征.

```javascript
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);
```

查找完整的示例 : [吨数](https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/async-download-polling.ts), (中文(简体) ), [数字](https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/async-download-polling.mjs), (中文(简体) ), [(单位:千美元)](https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/async-download-polling.cjs)

### Async 扫描: S3( 回调)

发送附件AV病毒扫描API的 S3 桶名和对象密钥 。 附件AV将下载文件,并将扫描结果发送给 [回调](https://attachmentav.com/help/virus-malware-scan-api/developer/definition.html#callback)。 。 。 .

见 [AsyncS3 扫描请求](https://npmcn.com/package/%40attachmentav/virus-scan-sdk-ts/sdk/models/AsyncS3ScanRequest.ts) 详细情况.

最大文件大小为5 GB. 请求超时为29秒;同步扫描任务不受此限制的影响.

> A 类 [桶政策](https://attachmentav.com/help/virus-malware-scan-api/setup-guide/#s3-bucket-policy) 需要允许附件AV访问私人S3对象.

> 尚未获得附件AV病毒扫描API(自发托管于AWS)的支持. 联系人 [你好@attachmentav.com](https://npmcn.com/package/%40attachmentav/virus-scan-sdk-ts/hello@attachmentav.com) 告诉我们,如果你需要这个特征.

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

查找完整的示例 : [吨数](https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/async-s3.ts), (中文(简体) ), [数字](https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/async-s3.mjs), (中文(简体) ), [(单位:千美元)](https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/async-s3.cjs)

### Async 扫描: S3(波浪)

发送附件AV病毒扫描API的 S3 桶名和对象密钥 。 附件AV将下载文件并存储扫描结果24小时.

见 [AsyncS3 扫描请求](https://npmcn.com/package/%40attachmentav/virus-scan-sdk-ts/sdk/models/AsyncS3ScanRequest.ts) 详细情况.

最大文件大小为5 GB. 请求超时为29秒;同步扫描任务不受此限制的影响.

> A 类 [桶政策](https://attachmentav.com/help/virus-malware-scan-api/setup-guide/#s3-bucket-policy) 需要允许附件AV访问私人S3对象.

> 尚未获得附件AV病毒扫描API(自发托管于AWS)的支持. 联系人 [你好@attachmentav.com](https://npmcn.com/package/%40attachmentav/virus-scan-sdk-ts/hello@attachmentav.com) 告诉我们,如果你需要这个特征.

```javascript
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);
```

查找完整的示例 : [吨数](https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/async-s3-polling.ts), (中文(简体) ), [数字](https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/async-s3-polling.mjs), (中文(简体) ), [(单位:千美元)](https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/async-s3-polling.cjs)

### 列出召回失败

列出回调失败, 防止附件AV 引用定义的回调 url 。 按时间顺序排列( 最小的失败先返回) 。 回调失败被存储了30天.

见 [召回失败](https://npmcn.com/package/%40attachmentav/virus-scan-sdk-ts/sdk/models/CallbackFailures.ts) 详细情况.

> 不由附件AV病毒扫描API(自发托管于AWS)支持.

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

查找完整的示例 : [吨数](https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/callback-failures.ts), (中文(简体) ), [数字](https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/callback-failures.mjs), (中文(简体) ), [(单位:千美元)](https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/callback-failures.cjs)

### 我是谁

获取关于自己的信息.

见 [呜](https://npmcn.com/package/%40attachmentav/virus-scan-sdk-ts/sdk/models/Whoami.ts) 详细情况.

> 不由附件AV病毒扫描API(自发托管于AWS)支持.

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

查找完整的示例 : [吨数](https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/whoami.ts), (中文(简体) ), [数字](https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/whoami.mjs), (中文(简体) ), [(单位:千美元)](https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/whoami.cjs)

### 使用量

获得剩余的信贷和配额.

见 [使用量](https://npmcn.com/package/%40attachmentav/virus-scan-sdk-ts/sdk/models/Usage.ts) 详细情况.

> 不由附件AV病毒扫描API(自发托管于AWS)支持.

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

查找完整的示例 : [吨数](https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/usage.ts), (中文(简体) ), [数字](https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/usage.mjs), (中文(简体) ), [(单位:千美元)](https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/usage.cjs)

## 型号

关于数据模型的更详细情况,请参看下页.

-   [自动下载请求](https://npmcn.com/package/%40attachmentav/virus-scan-sdk-ts/sdk/models/AsyncDownloadScanRequest.ts)
-   [AsyncS3 扫描请求](https://npmcn.com/package/%40attachmentav/virus-scan-sdk-ts/sdk/models/AsyncS3ScanRequest.ts)
-   [扫描结果](https://npmcn.com/package/%40attachmentav/virus-scan-sdk-ts/sdk/models/ScanResult.ts)
-   [同步下载扫描请求](https://npmcn.com/package/%40attachmentav/virus-scan-sdk-ts/sdk/models/SyncDownloadScanRequest.ts)
-   [同步 S3 扫描请求](https://npmcn.com/package/%40attachmentav/virus-scan-sdk-ts/sdk/models/SyncS3ScanRequest.ts)
-   [使用量](https://npmcn.com/package/%40attachmentav/virus-scan-sdk-ts/sdk/models/Usage.ts)
-   [呜](https://npmcn.com/package/%40attachmentav/virus-scan-sdk-ts/sdk/models/Whoami.ts)
-   [附录](https://npmcn.com/package/%40attachmentav/virus-scan-sdk-ts/sdk/apis/AttachmentAVApi.ts)

## 需要帮忙吗?

需要帮忙吗? [你好@attachmentav.com](mailto:hello@attachmentav.com)。 。 。 .

## 常见问题

### @attachmentav/virus-scan-sdk-ts 是什么？

一个SDK将病毒和恶意软件扫描能力整合到JavaScript / TypeScript应用中\. 扫描由索福斯提供附件AV的病毒,trojans等恶意软件的文件\.

### 如何安装 @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 和提交记录判断。

