# @getanthill/sec 中文文档

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

版本：0\.7\.0
npm 元数据更新时间：2024-11-15T09:43:26.685Z
中文译文更新时间：2026-11-16T08:52:16.732Z
软件包许可：MIT

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

原始 npm 页面：https://www.npmjs.com/package/%40getanthill/sec
原文对照：https://npmcn.com/package/%40getanthill/sec/?lang=original
项目主页：https://gitlab.com/getanthill/sec#readme
源码仓库：https://gitlab.com/getanthill/sec

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

- 包体积（解压后）：570 kB，59 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：3 个
- 首次发布：2020-11-03T09:51:44.986Z
- 最新版本发布：2024-01-15T19:48:22.377Z
- 近 30 天下载量：2248（2026-10-17 至 2026-11-15，npm 官方下载统计）
- 已发布版本数：10（近 12 个月 0 个）

## 中文简介

Anthill项目安全包

## 安装

```sh
npm install @getanthill/sec
```

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

## README

# `getanthill` 安全层

[![pipeline](https://gitlab.com/getanthill/sec/badges/master/pipeline.svg)](https://gitlab.com/getanthill/sec/-/commits/master) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=getanthill%2Fsec&metric=alert_status)](https://sonarcloud.io/dashboard?id=getanthill%2Fsec)

[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=getanthill%2Fsec&metric=coverage)](https://sonarcloud.io/dashboard?id=getanthill%2Fsec) [![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=getanthill%2Fsec&metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=getanthill%2Fsec) [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=getanthill%2Fsec&metric=security_rating)](https://sonarcloud.io/dashboard?id=getanthill%2Fsec)

## 开始

首先,你需要安装软件包:

```shell
npm install -S @getanthill/sec
```

然后,你的客户可以跟随步骤 注册或签入 然后激活 MFA 验证.

```typescript
// 1. Signin part:
const tokens = auth.getTokens(email, password);

// 2. MFA Setup part: (only on registration)
// Master key generation #keep-it-secret-keep-it-safe
const masterKey = otp.generateMasterKey();
// Secret key generation from Master key
const secretKey = otp.generateSecretFromMaster(masterKey);

// Validate MFA:
const isValid = otp.verify('123456', secretKey);

// Create the store:
const store = new Store(tokens.encryption, secretKey);

// Manage your data as always:
store.data = { hello: 'world' }; // Always encrypted data
```

## 路线图

-   [x] 默认执行此处描述的数据隐私安全层 : [https://hacks.mozilla.org/2018/11/firefox-sync-privacy/ 页面存档备份,存于互联网档案馆](https://hacks.mozilla.org/2018/11/firefox-sync-privacy/)
-   [x] 执行 TOTP
-   [ ] 执行 QRCode 生成部分

## 常见问题

### @getanthill/sec 是什么？

Anthill项目安全包

### 如何安装 @getanthill/sec？

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

### @getanthill/sec 支持 TypeScript 吗？

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

### @getanthill/sec 支持 ESM 还是 CommonJS？

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

### @getanthill/sec 可以商用吗？

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

### @getanthill/sec 的下载量有多少？

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

### @getanthill/sec 还在维护吗？

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

