@clawos-dev/clawd 0.2.416 → 0.2.418

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.cjs +53 -2
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -57076,6 +57076,21 @@ async function authenticate(token, deps) {
57076
57076
  if (result.reason === "WRONG_AUDIENCE") return { ok: false, code: "TOKEN_REVOKED" };
57077
57077
  return { ok: false, code: "BAD_TOKEN" };
57078
57078
  }
57079
+ if (deps.checkPrincipalActive) {
57080
+ let active;
57081
+ try {
57082
+ active = await deps.checkPrincipalActive(result.provider, result.subOwner);
57083
+ } catch (e) {
57084
+ deps.onRevokeCheckFailed?.({
57085
+ provider: result.provider,
57086
+ ownerId: result.subOwner,
57087
+ subDevice: result.subDevice,
57088
+ reason: e.message
57089
+ });
57090
+ active = true;
57091
+ }
57092
+ if (!active) return { ok: false, code: "PRINCIPAL_REVOKED" };
57093
+ }
57079
57094
  return {
57080
57095
  ok: true,
57081
57096
  context: connectGuestContext(result.subDevice, result.subOwner, result.provider, result.displayName)
@@ -59859,6 +59874,16 @@ async function centralUpsertDevice(opts) {
59859
59874
  }
59860
59875
  return { ok: true };
59861
59876
  }
59877
+ async function centralPrincipalStatus(opts) {
59878
+ const query = `provider=${encodeURIComponent(opts.provider)}&ownerId=${encodeURIComponent(opts.ownerId)}`;
59879
+ const body = await centralRequest(opts, `/api/clawd-identity/principal-status?${query}`, {
59880
+ method: "GET"
59881
+ });
59882
+ if (typeof body.active !== "boolean") {
59883
+ throw new CentralClientError("BAD_RESPONSE", "principal-status: missing active flag");
59884
+ }
59885
+ return { active: body.active };
59886
+ }
59862
59887
  async function centralListDevices(opts) {
59863
59888
  const body = await centralRequest(
59864
59889
  opts,
@@ -62287,7 +62312,7 @@ function computeMethodAccess(args) {
62287
62312
  }
62288
62313
 
62289
62314
  // src/version.ts
62290
- var version = "0.2.416".length > 0 ? "0.2.416" : "dev";
62315
+ var version = "0.2.418".length > 0 ? "0.2.418" : "dev";
62291
62316
 
62292
62317
  // src/cli-probe/probe.ts
62293
62318
  var fs65 = __toESM(require("fs"), 1);
@@ -66217,6 +66242,31 @@ async function startDaemon(config) {
66217
66242
  publicKeyPem,
66218
66243
  expectedDeviceId: authFile.deviceId
66219
66244
  });
66245
+ },
66246
+ // 验票第二段(spec 2026-08-28):本地验签只证明"票是中心签的",这一步问中心
66247
+ // "持票人还在职吗"。token 不再过期,撤销全靠它。端点无鉴权——不带本机 ttcJwt,
66248
+ // 否则飞书过期又会牵连互联。
66249
+ checkPrincipalActive: async (provider, ownerId2) => {
66250
+ const r = await centralPrincipalStatus({
66251
+ api: config.clawosApi ?? DEFAULT_CLAWOS_API,
66252
+ provider,
66253
+ ownerId: ownerId2,
66254
+ // 必须短于 AuthGate 的握手 timer(默认 5s,transport/auth.ts)。那个 timer 只看
66255
+ // st.authed、**不看 st.pending**,所以 authenticate 跑太久会被它 1008 关掉——
66256
+ // 那是"连接被关",不是我们要的 fail-open 放行。centralRequest 默认 15s 远超
66257
+ // 预算,这里压到 3s:中心慢时先抛超时 → 走 fail-open → 放行 + warn。
66258
+ timeoutMs: 3e3
66259
+ });
66260
+ return r.active;
66261
+ },
66262
+ // fail-open 的可观测性出口:连接放行了,但撤销状态这次没查到。
66263
+ onRevokeCheckFailed: (f) => {
66264
+ logger.warn("principal revoke check failed (fail-open: connection allowed)", {
66265
+ provider: f.provider,
66266
+ ownerId: f.ownerId,
66267
+ subDevice: f.subDevice,
66268
+ reason: f.reason
66269
+ });
66220
66270
  }
66221
66271
  } : {}
66222
66272
  });
@@ -66229,7 +66279,8 @@ async function startDaemon(config) {
66229
66279
  // owner 路径 constantTimeEqual 防侧信道;guest 路径走 verifyConnectToken (Ed25519).
66230
66280
  expectedToken: resolvedAuthToken,
66231
66281
  // 纯验票(spec 2026-07-22 双向确认建联):guest 入站 = 自包含 connect token
66232
- // **本地验签**(Ed25519 公钥 + aud === 本机 deviceId + 未过期),零网络调用。
66282
+ // 本地验签(Ed25519 公钥 + aud === 本机 deviceId + 未过期)+ 中心撤销查询
66283
+ // (spec 2026-08-28,查不通则 fail-open 放行并 warn)。
66233
66284
  // 反向落库不再挂在验票副作用上——落库唯一路径 = contact:handshake handler。
66234
66285
  authenticate: async (t) => authenticate(t, buildConnectAuthDeps()),
66235
66286
  onAuthed: (h, ctx) => wsServer?.attachClientContext(h.id, ctx),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawos-dev/clawd",
3
- "version": "0.2.416",
3
+ "version": "0.2.418",
4
4
  "description": "Standalone clawd daemon — Claude Code (and future Codex) session server over WebSocket",
5
5
  "type": "module",
6
6
  "license": "MIT",