feat: advance yonexus authentication handshake

This commit is contained in:
nav
2026-04-08 22:04:56 +00:00
parent 02d158eacd
commit 739a1ee094
4 changed files with 31 additions and 3 deletions

View File

@@ -605,6 +605,9 @@
## Phase 7 — Authentication 主流程
### YNX-0701 固化 proof 构造与签名规范
**状态**
- [x] 已完成2026-04-08
**目标**
- 明确签名输入,避免 Server / Client 不一致
@@ -616,9 +619,18 @@
**验收标准**
- 同一输入在 Client 与 Server 上验证一致
**已完成内容**
- 已新增 `Yonexus.Protocol/src/auth.ts`固化认证共享常量nonce 长度、时间漂移窗口、attempt window、recent nonce window
- 已实现 `createAuthRequestSigningInput()` / `extractAuthRequestSigningInput()`,统一以稳定 JSON 序列化 `{ secret, nonce, timestamp }` 作为签名输入
- 已补充 `isValidAuthNonce()``isTimestampFresh()`,把 nonce 与时间窗口校验规则从文档落到共享代码
- 已从 `Yonexus.Protocol/src/index.ts` 导出认证辅助模块,供 Client / Server 复用
---
### YNX-0702 实现 Client auth_request
**状态**
- [x] 已完成2026-04-08
**目标**
- Client 能基于本地 secret 与私钥发起认证
@@ -632,9 +644,18 @@
- 报文字段完整
- nonce 格式符合协议要求
**已完成内容**
- Client runtime 已在收到 `hello_ack(auth_required)``pair_success` 后自动发起 `auth_request`
- 已复用本地 `secret` + Ed25519 私钥生成签名,并发送 `identifier` / `nonce` / `proofTimestamp` / `signature` / `publicKey`
- 已把 transport 状态补齐为 `authenticating -> authenticated`,并在 `auth_success` 后落盘 `authenticatedAt`
- 已处理 `auth_failed` / `re_pair_required` 的最小状态回退逻辑
---
### YNX-0703 实现 Server 认证校验
**状态**
- [x] 已完成2026-04-08
**目标**
- Server 能验证 auth_request 真伪
@@ -652,6 +673,13 @@
- 正确认证返回 `auth_success`
- 各类失败返回对应 `auth_failed`
**已完成内容**
- Server runtime 已接入 `auth_request` builtin 处理并校验 allowlist / paired 状态 / publicKey 一致性
- 已复用共享签名输入规范与 Ed25519 验签逻辑,验证客户端签名
- 已实现 timestamp freshness、nonce 格式、recent nonce collision、10s attempt window 的最小校验
- 正常认证会更新 `lastAuthenticatedAt` / `lastHeartbeatAt` / liveness 状态,并返回 `auth_success`
- 遇到 nonce collision 或 rate limit 时会触发 `re_pair_required`,清理旧 secret 与安全窗口
---
### YNX-0704 实现 re_pair_required 机制