# @enzoic/enzoic 中文文档

规范地址：https://npmcn.com/package/%40enzoic/enzoic/

版本：3\.1\.0
npm 元数据更新时间：2025-04-07T04:51:53.975Z
中文译文更新时间：2026-11-13T19:09:35.214Z
软件包许可：MIT

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

原始 npm 页面：https://www.npmjs.com/package/%40enzoic/enzoic
原文对照：https://npmcn.com/package/%40enzoic/enzoic/?lang=original
项目主页：https://github.com/Enzoic/enzoic-javascript-client#readme
源码仓库：https://github.com/Enzoic/enzoic-javascript-client

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

- 包体积（解压后）：157 kB，10 个文件
- 模块格式：CommonJS
- TypeScript 类型：未声明
- 运行依赖：7 个
- 首次发布：2019-06-29T03:14:08.012Z
- 最新版本发布：2025-04-07T04:51:53.784Z
- 近 30 天下载量：4619（2026-10-14 至 2026-11-12，npm 官方下载统计）
- 已发布版本数：11（近 12 个月 0 个）

## 中文简介

Enzoic API 的 JavaScript 库

## 安装

```sh
npm install @enzoic/enzoic
```

也可以使用：`pnpm add @enzoic/enzoic`、`yarn add @enzoic/enzoic`、`bun add @enzoic/enzoic`

## README

# Enzoic JavaScript 客户端库

> :警告:在3.0.0版本中,Enzoic JavaScript库已切换到使用承诺而不是回调. 这是一个破解的更改,需要更新使用此库之前版本的代码 .

## 技选

这项研究涉及以下专题:

-   [安装](https://npmcn.com/package/%40enzoic/enzoic/#readme-installation)
-   [API 概览](https://npmcn.com/package/%40enzoic/enzoic/#readme-api-overview)
-   [恩佐克构造器](https://npmcn.com/package/%40enzoic/enzoic/#readme-the-enzoic-constructor)
-   [密码 API 示例](https://npmcn.com/package/%40enzoic/enzoic/#readme-passwords-api-examples)
-   [证书 API 示例](https://npmcn.com/package/%40enzoic/enzoic/#readme-credentials-api-examples)
-   [API 实例](https://npmcn.com/package/%40enzoic/enzoic/#readme-exposures-api-examples)
-   [用户 API 的违反监控](https://npmcn.com/package/%40enzoic/enzoic/#readme-breach-monitoring-by-user-api-examples)
-   [域名API的违反监控](https://npmcn.com/package/%40enzoic/enzoic/#readme-breach-monitoring-by-domain-api-examples)

## 安装

```sh
$ npm install @enzoic/enzoic
```

## API 概览

下面是一些简单的示例代码,可以显示API的用法.

```js
const Enzoic = require('enzoic');

// Create a new Enzoic instance - this is our primary interface for making API calls
const enzoic = new Enzoic(YOUR_API_KEY, YOUR_API_SECRET);

// Check whether a specific set of credentials are compromised
const credsCompromised = await enzoic.checkCredentials('test@enzoic.com', 'password-to-test'); 

if (credsCompromised === true) {
    console.log('Credentials are compromised');
}
else {
    console.log('Credentials are not compromised');
}
```

下文以参考格式提供更多信息.

## 恩佐克构造器

使用API的第一步是将Enzoic客户端与API密钥以及您在Enzoic签注上发布的秘密进行即时化.

```js
const Enzoic = require('enzoic');

const enzoic = new Enzoic(YOUR_API_KEY, YOUR_API_SECRET);
```

如果您被指示使用替代的 API 主机, 您可以调用超载的构造器, 并通过您得到的主机 .

```js
const Enzoic = require('enzoic');

const enzoic = new Enzoic(YOUR_API_KEY, YOUR_API_SECRET, "api-alt.enzoic.com");
```

## 密码 API 示例

见 [https://docs.enzoic.com/enzoic-api-developer-documentation/api-reference/passwords-api 互联网档案馆的存檔,存档日期2013-12-22](https://docs.enzoic.com/enzoic-api-developer-documentation/api-reference/passwords-api)

```js
// Check whether a password has been compromised
const passwordCompromised = await enzoic.checkPassword('password-to-test');

if (passwordCompromised === true) {
    console.log('Password is compromised');
}
else {
    console.log('Password is not compromised');
}
```

## 证书 API 示例

见 [https://docs.enzoic.com/enzoic-api-developer-documentation/api-reference/creditis-api 页面存档备份,存于互联网档案馆](https://docs.enzoic.com/enzoic-api-developer-documentation/api-reference/credentials-api)

```js
// Check whether a specific set of credentials are compromised
const credsCompromised = await enzoic.checkCredentials('test@enzoic.com', 'password-to-test'); 

if (credsCompromised === true) {
    console.log('Credentials are compromised');
}
else {
    console.log('Credentials are not compromised');
}

// Enhanced version of checkCredentials offering more control over performance.
// The call introduces an options object parameter, which supports the following settings:
//
// lastCheckDate: 
// The timestamp for the last check you performed for this user.
// If the date/time you provide for the last check is greater than the timestamp Enzoic has for the last
// breach affecting this user, the check will not be performed.  This can be used to substantially increase performance.
//
// excludeHashAlgorithms: 
// An array of PasswordTypes to ignore when calculating hashes for the credentials check.   
// By excluding computationally expensive PasswordTypes, such as BCrypt, it is possible to balance the performance of this
// call against security.
//
const credsCompromised = await enzoic.checkCredentialsEx('test@enzoic.com', 'password-to-test', 
    {
        lastCheckDate: new Date('2016-12-10T02:05:03.000Z'), 
        excludeHashAlgorithms: [8, 11, 12] // see https://docs.enzoic.com/enzoic-api-developer-documentation/api-reference/password-hash-algorithms 
    });

if (credsCompromised === true) {
    console.log('Credentials are compromised');
}
else {
    console.log('Credentials are not compromised');
}

// get all passwords Enzoic has for the specified user 
// returns results per 
// https://docs.enzoic.com/enzoic-api-developer-documentation/api-reference/credentials-api/cleartext-credentials-api
const userPasswordsResponse = await enzoic.getUserPasswords("eicar_0@enzoic.com");

// print user passwords
for (let i = 0; i < userPasswordsResponse.passwords.length; i++) {
    console.log('Password: ' + userPasswordsResponse.passwords[i].Password + '\n');
}
```

## API 实例

见 [https://docs.enzoic.com/enzoic-api-developer-documentation/api-reference/exposures-api 互联网档案馆的存檔,存档日期2013-12-22](https://docs.enzoic.com/enzoic-api-developer-documentation/api-reference/exposures-api)

```js
// get all exposures for the given user
const exposuresForUser = await enzoic.getExposuresForUser('test@enzoic.com');
console.log(exposuresForUser.exposures.count + ' exposures found for test@enzoic.com');
    
// now get the full details for the first exposure returned in the list
const exposureDetails = await enzoic.getExposureDetails(result.exposures[0]);
console.log('First exposure for test@enzoic.com was ' + exposureDetails.title);

// get all exposures for a given domain - second parameter indicates whether to include exposure details in results
// returns paged results per 
// https://docs.enzoic.com/enzoic-api-developer-documentation/api-reference/exposures-api/get-exposures-for-a-domain
const exposuresForDomain = enzoic.getExposuresForDomainEx('enzoic.com', true, 20, null);
console.log(exposuresForDomain.count + ' exposures found for enzoic.com');

// print first page of results
for (let i = 0; i < exposuresForDomain.exposures.length; i++) {
    console.log('Exposure: ' + exposuresForDomain.exposures.title + '\n');
}

// if pagingToken present, get next page of results
if (exposuresForDomain.pagingToken) {
    const secondPageResults = await enzoic.getExposuresForDomainEx('enzoic.com', true, 20, exposuresForDomain.pagingToken);
    // ...process second page of results, etc.
}

// get all users exposed for a given domain
// returns paged results per 
// https://docs.enzoic.com/enzoic-api-developer-documentation/api-reference/exposures-api/get-exposures-for-all-email-addresses-in-a-domain
const exposedUsers = await enzoic.getExposedUsersForDomain('enzoic.com', 20, null);

// print first page of results
for (let i = 0; i < exposedUsers.users.length; i++) {
   console.log('Exposed User: ' + exposedUsers.users[i].username + '\n');
}

// if pagingToken present, get next page of results
if (exposedUsers.pagingToken) {
    const secondPageResults = await enzoic.getExposedUsersForDomain('enzoic.com', 20, exposedUsers.pagingToken); 
    // ...process second page of results, etc.
}
```

## 用户 API 的违反监控

见 [https://docs.enzoic.com/enzoic-api-developer-documentation/api-reference/breach-survey-api/brefer-survey-by-user 页面存档备份,存于互联网档案馆 (简体中文)](https://docs.enzoic.com/enzoic-api-developer-documentation/api-reference/breach-monitoring-api/breach-monitoring-by-user)

```js
// a couple of email addresses - note: these will get hashed before submission to the Enzoic API
const arrUsernames = [
    'eicar_0@enzoic.com', 
    'eicar_1@enzoic.com'
];

// subscribe for alerts for these users
const addResponse = await enzoic.addUserAlertSubscriptions(arrUsernames);

console.log('New subscriptions added: ' + addResponse.added + '\n' + 
    'Subscriptions already existing: ' + addResponse.alreadyExisted);

// delete subscriptions for these users
const deleteResponse = await enzoic.deleteUserAlertSubscriptions(arrUsernames);

console.log('Subscriptions deleted: ' + deleteResponse.deleted + '\n' + 
    'Subscriptions not found: ' + deleteResponse.notFound);

// check whether a user is already subscribed
const subscribed = await enzoic.isUserSubscribedForAlerts(arrUsernames[0]);

if (subscribed === true) {
   console.log('User already subscribed');
}
else {
   console.log('User not already subscribed');
}    

// get all users subscribed for alerts on this account 
// returns paged results per 
// https://docs.enzoic.com/enzoic-api-developer-documentation/api-reference/breach-monitoring-api/breach-monitoring-by-user#retrieve-current-breach-alert-subscriptions
const subscriptionsResponse = await enzoic.getUserAlertSubscriptions(4 /* page size */, null /* paging token - null on first call */);

// print first page of results
for (let i = 0; i < subscriptionsResponse.usernameHashes.length; i++) {
   console.log('Username Hash: ' + subscriptionsResponse.usernameHashes[i] + '\n');
}

// if pagingToken present, get next page of results
if (subscriptionsResponse.pagingToken) {
    const secondPageResponse = await enzoic.getUserAlertSubscriptions(4, subscriptionsResponse.pagingToken);
    // ...process second page of results, etc.
}
```

## 域名API的违反监控

见 [https://docs.enzoic.com/enzoic-api-developer-documentation/api-reference/breach-survey-api/breference-survey-by-domain 页面存档备份,存于互联网档案馆](https://docs.enzoic.com/enzoic-api-developer-documentation/api-reference/breach-monitoring-api/breach-monitoring-by-domain)

```js
// test domains for alert subscriptions
const arrDomains = [
    'testdomain1.com', 
    'testdomain2.com' 
];

// subscribe for alerts for these domains
const addDomainsResponse = await enzoic.addDomainAlertSubscriptions(arrDomains); 

console.log('New subscriptions added: ' + addDomainsResponse.added + '\n' + 
    'Subscriptions already existing: ' + addDomainsResponse.alreadyExisted);

// delete subscriptions for these domains
const deleteDomainsResponse = await enzoic.deleteDomainAlertSubscriptions(arrDomains);

console.log('Subscriptions deleted: ' + deleteDomainsResponse.deleted + '\n' + 
    'Subscriptions not found: ' + deleteDomainsResponse.notFound);

// check whether a domain is already subscribed
const domainSubscribed = await enzoic.isDomainSubscribedForAlerts(arrDomains[0]); 

if (subscribed === true) {
   console.log('Domain already subscribed');
}
else {
   console.log('Domain not already subscribed');
}    

// get all users subscribed for alerts on this account 
// returns pages results per 
// https://docs.enzoic.com/enzoic-api-developer-documentation/api-reference/breach-monitoring-api/breach-monitoring-by-domain#retrieve-current-breach-alert-subscriptions
const domainSubsResponse = await enzoic.getDomainAlertSubscriptions(4 /* page size */, null /* paging token - null on first call */);

// print first page of results
for (let i = 0; i < domainSubsResponse.domains.length; i++) {
   console.log('Domain: ' + domainSubsResponse.domains[i] + '\n');
}

// if pagingToken present, get next page of results
if (domainSubsResponse.pagingToken) {
    const secondPageResponse = await enzoic.getDomainAlertSubscriptions(4, domainSubsResponse.pagingToken);
    // ...process second page of results, etc.
}
```

## 常见问题

### @enzoic/enzoic 是什么？

Enzoic API 的 JavaScript 库

### 如何安装 @enzoic/enzoic？

在项目目录运行 npm install @enzoic/enzoic，或使用 pnpm add / yarn add / bun add。

### @enzoic/enzoic 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/enzoic\_\_enzoic 是否存在。

### @enzoic/enzoic 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @enzoic/enzoic 可以商用吗？

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

### @enzoic/enzoic 的下载量有多少？

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

### @enzoic/enzoic 还在维护吗？

最新版本 3\.1\.0 发布于 2025/04/07（1\.6 年前）；至今共发布 11 个版本，其中过去 12 个月发布了 0 个；首次发布于 2019/06/29。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

