OCMAP Pairing Auth
Implement the feature as a thin pairing-code layer on top of OpenClaw's existing signed device identity and trusted-device token flow. Do not invent a second long-lived auth system.
Workflow
- 1. Read
references/protocol.md first. - If working on OpenClaw gateway or Control UI, read
references/server-openclaw.md. - If working on OCMAP or another desktop client, read
references/client-ocmap.md. - Keep server and client aligned on the exact request/response contract before wiring UI.
Required design
- - Generate a short-lived one-time code on the server.
- Also mint a short-lived bootstrap auth value during
pairing.createCode. - Preserve OpenClaw's connect-first rule:
- client must send the bootstrap value during
connect.auth
- complete handshake normally
- only then call
pairing.exchangeCode
- - Bind exchange to a device identity proof:
-
deviceId
-
publicKey
-
signature
-
signedAt
-
nonce
- - On success, mint or reuse the normal OpenClaw trusted-device token path.
- Persist trust on the client outside the renderer/UI process.
- Support revoke on the server and forget-device on the client.
- Return structured error codes instead of generic failures.
Non-negotiable rules
- - Keep pairing codes short-lived: 2-5 minutes.
- Make bootstrap auth values short-lived as well.
- Make codes single-use.
- Rate-limit failed exchange attempts.
- Never expose the long-lived trusted token in renderer/browser UI state.
- Do not require manual approval after a successful code exchange; the code exchange is the approval.
- Do not bypass OpenClaw's existing device token verification model; extend it.
- Do not bypass OpenClaw's connect-first handshake rule just to make pairing work.
OpenClaw implementation checklist
-
pairing.createCode
-
pairing.exchangeCode
-
pairing.revokeDevice
- - Return
code, nonce, and short-lived bootstrap auth from pairing.createCode. - Store pairing-code state separately from generic device pending/paired records.
- Surface Clawpodz pairing UI in its own Control UI tab under Integrations, with recent pairings and trusted desktop clients there.
- Keep generic paired devices / nodes / exec approvals in the Devices tab.
- Add feature-flag or config gating for rollout.
- Return structured failure codes such as:
-
PAIRING_DISABLED
-
CODE_INVALID
-
CODE_EXPIRED
-
CODE_ALREADY_USED
- INLINECODE21
Client implementation checklist
- - Use the returned bootstrap auth during
connect.auth so the client can satisfy the connect-first handshake. - Open the websocket and complete the gateway handshake before attempting pairing exchange.
- Submit the full signed payload;
code + deviceId alone is insufficient. - After exchange, persist the returned trusted-device token in main/backend storage.
- Reconnect using the stored token and transition auth state cleanly.
- Distinguish
UNPAIRED, PAIRING_IN_PROGRESS, PAIRED_CONNECTED, PAIRED_DISCONNECTED, and REVOKED.
Validation
Run this matrix before calling the feature done:
- - Fresh pair with valid code succeeds.
- Reuse same code fails with
CODE_ALREADY_USED. - Expired code fails with
CODE_EXPIRED. - Invalid signature/public key/device mismatch fails with
CODE_INVALID. - Restart client after success reconnects automatically.
- Revoke device on server forces client back to unpaired/revoked flow.
- Gateway restart does not lose trusted device records.
References
- - Server details: INLINECODE32
- Client details: INLINECODE33
- Protocol contract: INLINECODE34
OCMAP 配对认证
在 OpenClaw 现有的签名设备身份和受信任设备令牌流程之上,以薄配对码层的形式实现该功能。不要发明第二个长期存在的认证系统。
工作流程
- 1. 首先阅读 references/protocol.md。
- 如果处理 OpenClaw 网关或控制 UI,请阅读 references/server-openclaw.md。
- 如果处理 OCMAP 或其他桌面客户端,请阅读 references/client-ocmap.md。
- 在连接 UI 之前,确保服务器和客户端在精确的请求/响应契约上保持一致。
必需的设计
- - 在服务器上生成一个短期一次性代码。
- 同时在 pairing.createCode 期间生成一个短期的引导认证值。
- 保留 OpenClaw 的先连接规则:
- 客户端必须在 connect.auth 期间发送引导值
- 正常完成握手
- 然后才能调用 pairing.exchangeCode
- deviceId
- publicKey
- signature
- signedAt
- nonce
- - 成功后,生成或重用正常的 OpenClaw 受信任设备令牌路径。
- 在渲染器/UI 进程之外持久化客户端的信任状态。
- 支持服务器端的撤销和客户端的忘记设备功能。
- 返回结构化的错误代码,而不是通用的失败信息。
不可协商的规则
- - 保持配对码短期有效:2-5 分钟。
- 引导认证值也应是短期的。
- 代码为一次性使用。
- 对失败的交换尝试进行速率限制。
- 切勿在渲染器/浏览器 UI 状态中暴露长期存在的受信任令牌。
- 成功交换代码后不需要手动批准;代码交换本身就是批准。
- 不要绕过 OpenClaw 现有的设备令牌验证模型;而是扩展它。
- 不要为了配对而绕过 OpenClaw 的先连接握手规则。
OpenClaw 实现清单
- pairing.createCode
- pairing.exchangeCode
- pairing.revokeDevice
- - 从 pairing.createCode 返回 code、nonce 和短期引导认证值。
- 将配对码状态与通用设备待定/已配对记录分开存储。
- 在控制 UI 的集成选项卡下展示 Clawpodz 配对 UI,其中包含最近的配对和受信任的桌面客户端。
- 将通用已配对设备/节点/执行批准保留在设备选项卡中。
- 添加功能标志或配置门控以进行逐步推出。
- 返回结构化的失败代码,例如:
- PAIRING_DISABLED
- CODE_INVALID
- CODE_EXPIRED
- CODE
ALREADYUSED
- DEVICE_REVOKED
客户端实现清单
- - 在 connect.auth 期间使用返回的引导认证值,以便客户端能够满足先连接握手的要求。
- 在尝试配对交换之前,打开 WebSocket 并完成网关握手。
- 提交完整的签名负载;仅 code + deviceId 是不够的。
- 交换后,将返回的受信任设备令牌持久化到主/后端存储中。
- 使用存储的令牌重新连接,并干净地转换认证状态。
- 区分 UNPAIRED、PAIRINGINPROGRESS、PAIREDCONNECTED、PAIREDDISCONNECTED 和 REVOKED。
验证
在宣布功能完成之前,运行以下矩阵:
- - 使用有效代码进行全新配对成功。
- 重复使用相同代码失败,返回 CODEALREADYUSED。
- 过期代码失败,返回 CODEEXPIRED。
- 无效签名/公钥/设备不匹配失败,返回 CODEINVALID。
- 成功后重启客户端自动重新连接。
- 在服务器上撤销设备,强制客户端返回未配对/已撤销流程。
- 网关重启不会丢失受信任设备记录。
参考资料
- - 服务器详情:references/server-openclaw.md
- 客户端详情:references/client-ocmap.md
- 协议契约:references/protocol.md