bastipnt/passmgr
GitHub: bastipnt/passmgr
一个基于OPAQUE协议的全栈跨平台密码管理器,服务器零知识认证用户身份,保险库密钥完全在客户端加解密。
Stars: 0 | Forks: 0
# passmgr
一个基于 **OPAQUE** 零知识认证的全栈、跨平台密码管理器。TypeScript 单体仓库,使用 pnpm + Turborepo。
[](./LICENSE)
---
## 它是什么
一个使用 [OPAQUE](https://datatracker.ietf.org/doc/draft-irtf-cfrg-opaque/)(非对称 PAKE)的密码管理器,服务器永远不会看到你的明文密码——注册时不会,登录时不会,甚至在传输过程中也不会。保险库密钥在客户端封装,并以加密形式存储在服务器上。
### 密钥层次结构
```
password ──Argon2id──► passwordKEK ──encrypt──► vaultKey
recoveryKey ──HKDF──► recoveryKEK ──encrypt──► vaultKey (backup wrap)
sessionKey ──HKDF──► sessionSecret ──HKDF(+salt)──► authKey (HMAC request signing)
```
电子邮件经过加密(XChaCha20-Poly1305)存储,并通过服务器密钥的 HMAC 建立索引——绝不存储为明文。
## 当前已实现的功能
- **Web 客户端**:注册、登录、保险库列表/查看/添加/编辑/删除、实时记录同步。
- **服务器**:端到端 OPAQUE 流程、HMAC 签名的请求认证、Redis 会话存储、重放防护(5 分钟时间戳窗口)。
- **测试**:Vitest 单元测试 + 集成测试、Playwright 端到端测试(注册/登录)、针对 crypto / store / server-auth / client 包的 Stryker 突变测试。
## 尚未实现的功能
- **Web**:无闲置锁定、无密码找回 UI、关闭标签页时不会自动重新锁定。
- **移动端**:仅有认证流程。暂无保险库、记录或生物识别解锁。
- **服务器**:无速率限制、部分签名验证边界情况仍待处理。
完整计划请参见 [路线图.md](./roadmap.md)。
## 技术栈
| 层 | 技术 |
| -------- | ------------------------------------------------------------------ |
| Web | React 19, Vite (rolldown-vite), Tailwind v4, wouter, tRPC 客户端 |
| 移动端 | React Native 0.83, Expo 55, Tamagui, NativeWind |
| 服务器 | Fastify 5, tRPC 11, Bun 运行时, Drizzle ORM (1.0 beta) |
| 数据 | PostgreSQL 17, Redis 7 |
| 加密 | `@cloudflare/opaque-ts`, `@noble/hashes`, `@noble/ciphers` |
| 工具链 | pnpm 10 工作空间, Turborepo, OXLint, Prettier, Lefthook, commitlint |
## 仓库结构
```
apps/
web/ React 19 + Vite web client
mobile/ React Native + Expo client (auth-only for now)
server/ Fastify + tRPC backend, runs on Bun
packages/
client/ Shared React hooks (useLogin, useRegistration) + tRPC client + secrets store
crypto/ All cryptographic primitives
db/ Drizzle schema + migrations (PostgreSQL)
schema/ Zod schemas shared between client and server
store/ Frontend data store + sync logic
tokens/ Design tokens (colors, spacing)
types/ Shared TypeScript types
typescript-config/ Shared tsconfig base files
ui/ Shared web component library (shadcn-based)
ui-native/ Mobile component library (Tamagui-based)
util/ Base64 / string encoding helpers
```
## 快速开始
你需要:Node 18+、pnpm 10、Docker(用于 PostgreSQL + Redis),以及可选的 Bun(服务器运行时)。
```
pnpm install
# 启动 Postgres + Redis
pnpm db:up
# 运行 migrations
pnpm db:migrate
# 以 watch mode 启动所有
pnpm dev
```
### 必需的环境变量
服务器(`apps/server/.env`):
| 变量 | 说明 |
| --------------------- | ---------------------------------------------------------------------------------- |
| `DATABASE_URL` | PostgreSQL 连接字符串 |
| `REDIS_HOST` | 例如 `localhost` |
| `REDIS_PORT` | 例如 `6379` |
| `OPAQUE_SERVER_SETUP` | base64 编码的 OPAQUE 服务器设置。**必须保持稳定**——轮换会使所有用户失效。 |
数据库包(`packages/db/.env`):
| 变量 | 说明 |
| -------------- | ------------------------------ |
| `DATABASE_URL` | 同上,供 Drizzle 使用 |
### 常用脚本
```
pnpm dev # all apps in watch mode
pnpm build # build everything via turbo
pnpm lint # OXLint, type-aware
pnpm typecheck # tsc across the monorepo
pnpm test # Vitest unit tests
pnpm test:integration # integration suites
pnpm e2e # Playwright
pnpm format # Prettier
pnpm db:generate # Drizzle migration generation
pnpm db:migrate # Drizzle migration apply
```
各应用:
```
pnpm --filter web dev
pnpm --filter server dev
pnpm --filter mobile start
```
## 各应用文档
- [apps/web/README.md](./apps/web/README.md)
- [apps/mobile/README.md](./apps/mobile/README.md)
- [apps/server/README.md](./apps/server/README.md)
## 安全
**请勿为安全问题提交公开 issue。** 请参阅 [SECURITY.md](./SECURITY.md) 了解私下披露的途径。
加密栈**尚未经过审计**。
## 许可证
[AGPL-3.0-only](./LICENSE)。你可以自由地自行托管和修改;如果你以网络服务形式运行修改版本,则必须依照同一许可证发布源代码。
标签:AGPL v3, Argon2id, Expo, HKDF, HMAC, OPAQUE, Playwright, pnpm, React, React Native, Redis, Stryker, Syscalls, Tailwind CSS, tRPC, Turborepo, TypeScript, Vite, Vitest, XChaCha20-Poly1305, 会话管理, 全栈, 加密认证, 安全, 安全插件, 实时同步, 密码学, 密码管理器, 开源, 手动系统调用, 特征检测, 自动化攻击, 超时处理, 隐私, 零知识证明