Expand description
v1.4.93 G2 (CLAUDE.md C4 audit): RepullAuthCode broker auth_code self-heal.
Triggered when broker auth_code expires (typical 30-day window) or
kAuthNoValidCid (20029); avoids requiring a daemon restart.
v1.4.93 G2 (CLAUDE.md C4 audit): 实装 POST /authority/repull_auth_code,
对齐 C++ FTLogin auth_impl.cpp:715-754 RepullAuthCode +
auth_impl.cpp:3308-3376 ParseRepullAuthCodeResponse。
§触发场景
- broker auth_code 过期:[
super::BrokerAuthCode::invalid_time] 在认证 响应里给的 expiry。daemon 长跑(典型 30 天)触发,原本 broker channel 失效不 self-heal、必须重启 daemon —— 本 fn 让bridge拉新 auth_code 重做broker_authHTTP + CMD 1001 重登 broker, 避免重启。 - broker
kAuthNoValidCid(error_code=20029):C++ 在ParseRepullAuthCodeResponse见此码会ClearBrokerAccountInfo然后重新 走整 RepullAuthCode 流程 —— 本 fn 仅做“拉新 auth_code“那一步,ClearBrokerAccountInfo等价物(清 cipher / customer_id)由 caller 决定 要不要做(v1.4.93 不主动清,v1.4.94+ 视真机行为再决定)。
§协议层 (对齐 C++)
POST https://{auth_domain}/authority/repull_auth_code
body = {
"uid": <u64>, // 当前账户 uid
"device_id": "<16-hex>", // 设备 ID (持久化)
"web_sig": "<str>", // /authority/ 响应里 web_sig_new (持久化)
"broker_id": <i32> // 单 broker
}Response result 单 broker:
{ "result": { "uid":<u64>, "broker_id":<i32>, "auth_code":"<str>",
"invalid_time":<u64> } }错误响应 result 缺失,error.error_code 给具体错码。
error_code=20029 (kAuthNoValidCid) 是特定可识别状态。
§Failure fallback
web_sig空(v1.4.92 凭据 / device-verify shell 没此字段)→ caller 跳过 repull,fallback 走 platform refresh(重 POST /authority/)然后再 retry- HTTP 失败 / web_sig 过期 → caller log + 不重试本轮 → 等下次 broker reconnect 触发或 platform refresh
§CLAUDE.md pitfalls 关联
- #34 Agent 调研结论 ≠ 真机正确性: 本实装基于 C++ 源码
auth_impl.cpp完整对照, 但 backend 实际 wire (是否 reject ‘web_sig over-frequent refresh’, error_code 准确含义) 仍需真机 verify - #42 Backend-semantic 风险: error_code=20029 是否真触发 + repull 后 的 broker channel 重建是否 work, 需真机
- #45 Silent-success: 函数返
Ok(BrokerAuthCode)必须基于响应result.auth_code+invalid_time都非空, 否则返 Err
Constants§
- ERROR_
CODE_ NO_ VALID_ CID - C++
kAuthNoValidCid错码(broker cid 失效)。当 backend 返此码时, 调用方应当清 broker cipher cache + 触发 broker channel 重建(C++ 行为ClearBrokerAccountInfo)。本 fn 不做副作用,只透传给 caller 决定。
Functions§
- repull_
auth_ code - 请求新的 broker auth_code,对齐 C++
RepullAuthCode.