chore(repo): initialize WebDrop monorepo

Signed-off-by: JustMe <mr.toing@outlook.com>
This commit is contained in:
justme committed 2026-10-02 00:59:22 +08:00
commit 53768a195d
39 files changed
+9063

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
# 协议测试向量
`vectors.json` 是协议的**可执行规格**:固定输入、固定输出,覆盖密钥派生、令牌、IV、AAD、padding、帧密文、条目分帧、设备名、链接、日志记录,以及 17 个必须被拒绝的负例。
## 为什么有三套实现
| 实现 | 密码学来源 | 位置 |
|---|---|---|
| **生成器(参照)** | `node:crypto` | `generate.mjs`,故意不引用任何项目代码 |
| 服务端 | .NET 的 `HKDF` / `AesGcm` / `SHA256` | `server/tests/WebDrop.Core.Tests/VectorTests.cs` |
| 客户端 | 浏览器的 WebCrypto | `packages/core/test/vectors.test.ts` |
三套互不相干的实现逐字节一致,才说明 `docs/protocol.md` 没有歧义。以后接入 CLI 或其他语言的客户端,同样必须通过这批向量。
## 使用
```bash
node test-vectors/generate.mjs # 重新生成 vectors.json
node test-vectors/generate.mjs --check # 只校验磁盘上的文件是最新的(CI 用)
```
输出完全确定(没有随机数、没有时间),可以放心提交。**改协议时的顺序**:先改 `docs/protocol.md`,再改 `generate.mjs` 并重新生成,最后让服务端和 `@webdrop/core` 的测试重新变绿。
设备名向量使用了固定 IV,仅为让输出确定;真实实现必须使用随机 IV。