@cybedefend/vibedefend 1.5.0 → 1.7.0

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 (264) hide show
  1. package/README.md +71 -2
  2. package/dist/api/gateway-request.js +49 -0
  3. package/dist/api/gateway-request.js.map +1 -0
  4. package/dist/api/projects.js +67 -0
  5. package/dist/api/projects.js.map +1 -1
  6. package/dist/api/repository-link.js +157 -0
  7. package/dist/api/repository-link.js.map +1 -0
  8. package/dist/auth/auth-store.js +107 -25
  9. package/dist/auth/auth-store.js.map +1 -1
  10. package/dist/auth/auth.js +21 -0
  11. package/dist/auth/auth.js.map +1 -1
  12. package/dist/clients/cursor.js +5 -1
  13. package/dist/clients/cursor.js.map +1 -1
  14. package/dist/clients/vscode.js +38 -29
  15. package/dist/clients/vscode.js.map +1 -1
  16. package/dist/commands/mcp/allow.js +219 -0
  17. package/dist/commands/mcp/allow.js.map +1 -0
  18. package/dist/commands/mcp/connect.js +337 -0
  19. package/dist/commands/mcp/connect.js.map +1 -0
  20. package/dist/commands/mcp/index.js +170 -0
  21. package/dist/commands/mcp/index.js.map +1 -0
  22. package/dist/commands/mcp/proxy.js +320 -0
  23. package/dist/commands/mcp/proxy.js.map +1 -0
  24. package/dist/commands/mcp/scan.js +349 -0
  25. package/dist/commands/mcp/scan.js.map +1 -0
  26. package/dist/commands/mcp/sync.js +215 -0
  27. package/dist/commands/mcp/sync.js.map +1 -0
  28. package/dist/config.js +6 -0
  29. package/dist/config.js.map +1 -1
  30. package/dist/diagnostics.js +78 -12
  31. package/dist/diagnostics.js.map +1 -1
  32. package/dist/doctor.js +19 -0
  33. package/dist/doctor.js.map +1 -1
  34. package/dist/guards-evaluator/analysis-types.js +27 -0
  35. package/dist/guards-evaluator/analysis-types.js.map +1 -0
  36. package/dist/guards-evaluator/command-analysis.js +572 -0
  37. package/dist/guards-evaluator/command-analysis.js.map +1 -0
  38. package/dist/guards-evaluator/command-view.js +586 -0
  39. package/dist/guards-evaluator/command-view.js.map +1 -0
  40. package/dist/guards-evaluator/env.js +11 -0
  41. package/dist/guards-evaluator/env.js.map +1 -0
  42. package/dist/guards-evaluator/evaluate.js +91 -41
  43. package/dist/guards-evaluator/evaluate.js.map +1 -1
  44. package/dist/guards-evaluator/index.js +2 -1
  45. package/dist/guards-evaluator/index.js.map +1 -1
  46. package/dist/guards-evaluator/inline-code.js +259 -0
  47. package/dist/guards-evaluator/inline-code.js.map +1 -0
  48. package/dist/guards-evaluator/normalize.js +716 -0
  49. package/dist/guards-evaluator/normalize.js.map +1 -0
  50. package/dist/guards-evaluator/preprocess.js +13 -5
  51. package/dist/guards-evaluator/preprocess.js.map +1 -1
  52. package/dist/guards-evaluator/redact.js +19 -0
  53. package/dist/guards-evaluator/redact.js.map +1 -1
  54. package/dist/guards-evaluator/regex.js +25 -3
  55. package/dist/guards-evaluator/regex.js.map +1 -1
  56. package/dist/guards-evaluator/safe-commands.js +155 -0
  57. package/dist/guards-evaluator/safe-commands.js.map +1 -0
  58. package/dist/guards-evaluator/triage.js +315 -0
  59. package/dist/guards-evaluator/triage.js.map +1 -0
  60. package/dist/hook-runner.js +24679 -5079
  61. package/dist/hooks/install.js +38 -0
  62. package/dist/hooks/install.js.map +1 -1
  63. package/dist/hooks/runtime/config.js +38 -0
  64. package/dist/hooks/runtime/config.js.map +1 -1
  65. package/dist/hooks/runtime/emit.js +94 -61
  66. package/dist/hooks/runtime/emit.js.map +1 -1
  67. package/dist/hooks/runtime/fetch-rules.js +22 -7
  68. package/dist/hooks/runtime/fetch-rules.js.map +1 -1
  69. package/dist/hooks/runtime/gateway-http-error.js +34 -0
  70. package/dist/hooks/runtime/gateway-http-error.js.map +1 -0
  71. package/dist/hooks/runtime/guard-rules-cache.js +139 -17
  72. package/dist/hooks/runtime/guard-rules-cache.js.map +1 -1
  73. package/dist/hooks/runtime/guard-violations-buffer.js +321 -48
  74. package/dist/hooks/runtime/guard-violations-buffer.js.map +1 -1
  75. package/dist/hooks/runtime/judge-cache.js +6 -0
  76. package/dist/hooks/runtime/judge-cache.js.map +1 -1
  77. package/dist/hooks/runtime/judge-triage.js +193 -0
  78. package/dist/hooks/runtime/judge-triage.js.map +1 -0
  79. package/dist/hooks/runtime/judge.js +7 -1
  80. package/dist/hooks/runtime/judge.js.map +1 -1
  81. package/dist/hooks/runtime/pre-compact.js +12 -6
  82. package/dist/hooks/runtime/pre-compact.js.map +1 -1
  83. package/dist/hooks/runtime/resolve.js +90 -8
  84. package/dist/hooks/runtime/resolve.js.map +1 -1
  85. package/dist/hooks/runtime/retry-policy.js +57 -0
  86. package/dist/hooks/runtime/retry-policy.js.map +1 -0
  87. package/dist/hooks/runtime/review-sessions.js +74 -0
  88. package/dist/hooks/runtime/review-sessions.js.map +1 -0
  89. package/dist/hooks/runtime/script-resolve.js +695 -0
  90. package/dist/hooks/runtime/script-resolve.js.map +1 -0
  91. package/dist/hooks/runtime/session-activation.js +5 -1
  92. package/dist/hooks/runtime/session-activation.js.map +1 -1
  93. package/dist/hooks/runtime/session-review.js +163 -45
  94. package/dist/hooks/runtime/session-review.js.map +1 -1
  95. package/dist/hooks/runtime/session-start.js +2 -1
  96. package/dist/hooks/runtime/session-start.js.map +1 -1
  97. package/dist/hooks/runtime/session-writes.js +232 -0
  98. package/dist/hooks/runtime/session-writes.js.map +1 -0
  99. package/dist/hooks/runtime/sniff.js +26 -7
  100. package/dist/hooks/runtime/sniff.js.map +1 -1
  101. package/dist/hooks/runtime/target-resolve.js +336 -0
  102. package/dist/hooks/runtime/target-resolve.js.map +1 -0
  103. package/dist/hooks/runtime/unmapped-tools.js +93 -0
  104. package/dist/hooks/runtime/unmapped-tools.js.map +1 -0
  105. package/dist/hooks/runtime/usage-block.js +4 -0
  106. package/dist/hooks/runtime/usage-block.js.map +1 -1
  107. package/dist/hooks/runtime/user-prompt-submit.js +2 -1
  108. package/dist/hooks/runtime/user-prompt-submit.js.map +1 -1
  109. package/dist/hooks/runtime/wire-text.js +41 -0
  110. package/dist/hooks/runtime/wire-text.js.map +1 -0
  111. package/dist/hooks/runtime/work-dir.js +84 -0
  112. package/dist/hooks/runtime/work-dir.js.map +1 -0
  113. package/dist/index.js +45 -12
  114. package/dist/index.js.map +1 -1
  115. package/dist/install.js +174 -11
  116. package/dist/install.js.map +1 -1
  117. package/dist/link.js +74 -48
  118. package/dist/link.js.map +1 -1
  119. package/dist/login.js +77 -11
  120. package/dist/login.js.map +1 -1
  121. package/dist/mcp/auth/agent-sign-ins.js +174 -0
  122. package/dist/mcp/auth/agent-sign-ins.js.map +1 -0
  123. package/dist/mcp/auth/callback.js +200 -0
  124. package/dist/mcp/auth/callback.js.map +1 -0
  125. package/dist/mcp/auth/connect.js +392 -0
  126. package/dist/mcp/auth/connect.js.map +1 -0
  127. package/dist/mcp/auth/discovery.js +399 -0
  128. package/dist/mcp/auth/discovery.js.map +1 -0
  129. package/dist/mcp/auth/oauth.js +326 -0
  130. package/dist/mcp/auth/oauth.js.map +1 -0
  131. package/dist/mcp/auth/probe.js +128 -0
  132. package/dist/mcp/auth/probe.js.map +1 -0
  133. package/dist/mcp/auth/secrets.js +446 -0
  134. package/dist/mcp/auth/secrets.js.map +1 -0
  135. package/dist/mcp/auth/store.js +260 -0
  136. package/dist/mcp/auth/store.js.map +1 -0
  137. package/dist/mcp/auth/tokenSource.js +55 -0
  138. package/dist/mcp/auth/tokenSource.js.map +1 -0
  139. package/dist/mcp/config/atomicWrite.js +98 -0
  140. package/dist/mcp/config/atomicWrite.js.map +1 -0
  141. package/dist/mcp/config/clients.js +171 -0
  142. package/dist/mcp/config/clients.js.map +1 -0
  143. package/dist/mcp/config/cybedefend-servers.js +48 -0
  144. package/dist/mcp/config/cybedefend-servers.js.map +1 -0
  145. package/dist/mcp/config/discover.js +114 -0
  146. package/dist/mcp/config/discover.js.map +1 -0
  147. package/dist/mcp/config/hook.js +123 -0
  148. package/dist/mcp/config/hook.js.map +1 -0
  149. package/dist/mcp/config/index.js +11 -0
  150. package/dist/mcp/config/index.js.map +1 -0
  151. package/dist/mcp/config/install.js +132 -0
  152. package/dist/mcp/config/install.js.map +1 -0
  153. package/dist/mcp/config/installed.js +37 -0
  154. package/dist/mcp/config/installed.js.map +1 -0
  155. package/dist/mcp/config/jsonEdit.js +119 -0
  156. package/dist/mcp/config/jsonEdit.js.map +1 -0
  157. package/dist/mcp/config/lock.js +102 -0
  158. package/dist/mcp/config/lock.js.map +1 -0
  159. package/dist/mcp/config/proxyBinary.js +211 -0
  160. package/dist/mcp/config/proxyBinary.js.map +1 -0
  161. package/dist/mcp/config/rewrite.js +388 -0
  162. package/dist/mcp/config/rewrite.js.map +1 -0
  163. package/dist/mcp/config/types.js +34 -0
  164. package/dist/mcp/config/types.js.map +1 -0
  165. package/dist/mcp/proxy/audit.js +83 -0
  166. package/dist/mcp/proxy/audit.js.map +1 -0
  167. package/dist/mcp/proxy/authInterceptor.js +119 -0
  168. package/dist/mcp/proxy/authInterceptor.js.map +1 -0
  169. package/dist/mcp/proxy/expand.js +93 -0
  170. package/dist/mcp/proxy/expand.js.map +1 -0
  171. package/dist/mcp/proxy/inject.js +412 -0
  172. package/dist/mcp/proxy/inject.js.map +1 -0
  173. package/dist/mcp/proxy/intercept.js +63 -0
  174. package/dist/mcp/proxy/intercept.js.map +1 -0
  175. package/dist/mcp/proxy/jsonrpc.js +153 -0
  176. package/dist/mcp/proxy/jsonrpc.js.map +1 -0
  177. package/dist/mcp/proxy/log.js +109 -0
  178. package/dist/mcp/proxy/log.js.map +1 -0
  179. package/dist/mcp/proxy/paths.js +57 -0
  180. package/dist/mcp/proxy/paths.js.map +1 -0
  181. package/dist/mcp/proxy/proxy.js +520 -0
  182. package/dist/mcp/proxy/proxy.js.map +1 -0
  183. package/dist/mcp/proxy/serverCheckTimer.js +75 -0
  184. package/dist/mcp/proxy/serverCheckTimer.js.map +1 -0
  185. package/dist/mcp/proxy/sessionLifecycle.js +29 -0
  186. package/dist/mcp/proxy/sessionLifecycle.js.map +1 -0
  187. package/dist/mcp/proxy/spec.js +203 -0
  188. package/dist/mcp/proxy/spec.js.map +1 -0
  189. package/dist/mcp/proxy/sse.js +77 -0
  190. package/dist/mcp/proxy/sse.js.map +1 -0
  191. package/dist/mcp/proxy/upstream.js +2 -0
  192. package/dist/mcp/proxy/upstream.js.map +1 -0
  193. package/dist/mcp/proxy/upstreamHttp.js +499 -0
  194. package/dist/mcp/proxy/upstreamHttp.js.map +1 -0
  195. package/dist/mcp/proxy/upstreamStdio.js +188 -0
  196. package/dist/mcp/proxy/upstreamStdio.js.map +1 -0
  197. package/dist/mcp/proxy/upstreams.js +143 -0
  198. package/dist/mcp/proxy/upstreams.js.map +1 -0
  199. package/dist/mcp/proxy/verifyInterceptor.js +718 -0
  200. package/dist/mcp/proxy/verifyInterceptor.js.map +1 -0
  201. package/dist/mcp/proxy/windowsCommand.js +99 -0
  202. package/dist/mcp/proxy/windowsCommand.js.map +1 -0
  203. package/dist/mcp/report/buffer.js +351 -0
  204. package/dist/mcp/report/buffer.js.map +1 -0
  205. package/dist/mcp/report/coalesce.js +165 -0
  206. package/dist/mcp/report/coalesce.js.map +1 -0
  207. package/dist/mcp/report/constants.js +51 -0
  208. package/dist/mcp/report/constants.js.map +1 -0
  209. package/dist/mcp/report/project.js +83 -0
  210. package/dist/mcp/report/project.js.map +1 -0
  211. package/dist/mcp/report/reporter.js +443 -0
  212. package/dist/mcp/report/reporter.js.map +1 -0
  213. package/dist/mcp/report/types.js +3 -0
  214. package/dist/mcp/report/types.js.map +1 -0
  215. package/dist/mcp/report/validate.js +179 -0
  216. package/dist/mcp/report/validate.js.map +1 -0
  217. package/dist/mcp/scan/args.js +228 -0
  218. package/dist/mcp/scan/args.js.map +1 -0
  219. package/dist/mcp/scan/results.js +253 -0
  220. package/dist/mcp/scan/results.js.map +1 -0
  221. package/dist/mcp/scan/types.js +40 -0
  222. package/dist/mcp/scan/types.js.map +1 -0
  223. package/dist/mcp/verify/api.js +514 -0
  224. package/dist/mcp/verify/api.js.map +1 -0
  225. package/dist/mcp/verify/backend.js +143 -0
  226. package/dist/mcp/verify/backend.js.map +1 -0
  227. package/dist/mcp/verify/cache.js +200 -0
  228. package/dist/mcp/verify/cache.js.map +1 -0
  229. package/dist/mcp/verify/contract-errors.js +198 -0
  230. package/dist/mcp/verify/contract-errors.js.map +1 -0
  231. package/dist/mcp/verify/digest.js +91 -0
  232. package/dist/mcp/verify/digest.js.map +1 -0
  233. package/dist/mcp/verify/factory.js +56 -0
  234. package/dist/mcp/verify/factory.js.map +1 -0
  235. package/dist/mcp/verify/identity.js +286 -0
  236. package/dist/mcp/verify/identity.js.map +1 -0
  237. package/dist/mcp/verify/policy-store.js +63 -0
  238. package/dist/mcp/verify/policy-store.js.map +1 -0
  239. package/dist/mcp/verify/policy.js +160 -0
  240. package/dist/mcp/verify/policy.js.map +1 -0
  241. package/dist/mcp/verify/pool.js +27 -0
  242. package/dist/mcp/verify/pool.js.map +1 -0
  243. package/dist/mcp/verify/token-refresh.js +44 -0
  244. package/dist/mcp/verify/token-refresh.js.map +1 -0
  245. package/dist/mcp/verify/token.js +67 -0
  246. package/dist/mcp/verify/token.js.map +1 -0
  247. package/dist/mcp/verify/verifier.js +1166 -0
  248. package/dist/mcp/verify/verifier.js.map +1 -0
  249. package/dist/org-gate.js +1 -1
  250. package/dist/org-gate.js.map +1 -1
  251. package/dist/org.js +146 -0
  252. package/dist/org.js.map +1 -0
  253. package/dist/project-create.js +129 -0
  254. package/dist/project-create.js.map +1 -0
  255. package/dist/prompts.js +21 -0
  256. package/dist/prompts.js.map +1 -1
  257. package/dist/re2.wasm +0 -0
  258. package/dist/status.js +61 -0
  259. package/dist/status.js.map +1 -1
  260. package/dist/uninstall.js +49 -4
  261. package/dist/uninstall.js.map +1 -1
  262. package/dist/utils.js +62 -6
  263. package/dist/utils.js.map +1 -1
  264. package/package.json +10 -3
@@ -0,0 +1,514 @@
1
+ /**
2
+ * Client for the ORG-SCOPED backend routes of the MCP verifier.
3
+ *
4
+ * The response envelopes are read from the real gateway controllers
5
+ * (`gateway-service/src/modules/mcp-verify/mcp-org-verify.controller.ts`,
6
+ * `organization/mcp-org-policy.controller.ts`), not inferred from a spec:
7
+ *
8
+ * POST /mcp/organization/:id/servers/check -> `{ success, data: { policy, results }, message }`
9
+ * POST /mcp/organization/:id/tools/verify -> `{ success, data: { policy, verdicts }, message }`
10
+ * GET /mcp/organization/:id/policy -> `{ success, data: { mode, strictIssuer }, message }`
11
+ *
12
+ * The organization is in the PATH, so the backend checks membership before
13
+ * anything else, and the organization's policy is applied SERVER-SIDE: every
14
+ * verdict and every result carries the `action` the client executes, and the
15
+ * envelope carries the `policy` it was decided under. The deprecated
16
+ * user-scoped routes (`/mcp/tools/verify`, `/mcp/servers/check`) are never
17
+ * called by this binary: they return a verdict without an action, and a
18
+ * client that turned a verdict into a decision by reading a mode out of its
19
+ * own environment is exactly what the org-scoped line removes.
20
+ *
21
+ * Invariants held by this module:
22
+ * - `known: false` on a tool verdict means "not verified", never "nothing to
23
+ * report". It is carried as an explicit boolean all the way to the caller.
24
+ * - An `action` this binary cannot read — absent, or out of vocabulary — is
25
+ * `pending`, NEVER `allow`. Nothing opens a door nobody decided to open.
26
+ * - A response without a readable `policy` throws: the deprecated envelope
27
+ * is not this contract, and reading it as one would decide on nothing.
28
+ * - An untrusted `apiBase` is refused BEFORE any network call
29
+ * (`isTrustedApiBase`, applied on the real request path of both functions).
30
+ * - A `401` triggers EXACTLY one token refresh and one retry, never a loop
31
+ * (`requestWithAuthRetry`).
32
+ * - The backend refuses more than 500 tools / 200 servers per request
33
+ * (`VerifyToolsBodyDto`, `CheckMcpServersBodyDto` on the gateway side).
34
+ * This client splits into batches instead of letting the caller hit
35
+ * `INVALID_ARGUMENT`, and declares the split through `onBatchSplit`.
36
+ * - A response missing an expected field (`data.results`, `data.verdicts`)
37
+ * throws, never a silence that would read as "empty, nothing to report".
38
+ * - No token ever leaves this module inside an error message.
39
+ */
40
+ import { resolveTokenWithRefresh } from '../../hooks/runtime/resolve.js';
41
+ import { GatewayHttpError } from '../../hooks/runtime/gateway-http-error.js';
42
+ import { parseRetryAfter } from '../../hooks/runtime/retry-policy.js';
43
+ import { REPORT_HTTP_TIMEOUT_MS } from '../report/constants.js';
44
+ import { DIGEST_VERSION } from './digest.js';
45
+ import { isContractErrorStatus } from './contract-errors.js';
46
+ import { isPolicyMode, isServerAction } from './policy.js';
47
+ import { isTrustedApiBase, } from '../../hooks/runtime/trusted-api-base.js';
48
+ const DEFAULT_TIMEOUT_MS = 10_000;
49
+ // ─── Failure taxonomy ───────────────────────────────────────────────────────
50
+ /**
51
+ * Any non-2xx from the backend.
52
+ *
53
+ * Carries the STATUS and the ROUTE, because the caller's decision depends on
54
+ * both and re-parsing a message to recover them is how that decision starts
55
+ * being made on prose.
56
+ */
57
+ export class McpBackendError extends Error {
58
+ route;
59
+ status;
60
+ constructor(route, status, message) {
61
+ super(message ?? `/mcp/organization/:organizationId/${route} failed with HTTP ${status}`);
62
+ this.route = route;
63
+ this.status = status;
64
+ this.name = 'McpBackendError';
65
+ }
66
+ }
67
+ /**
68
+ * The backend ANSWERED, and refused what we sent: 400, 409, 422 — and, on the
69
+ * org-scoped routes, 403 (not a member of that organization) and 404 (no such
70
+ * organization).
71
+ *
72
+ * ⚠️ This is not an outage, and the difference is the whole point. An outage
73
+ * is fail-open — the tool list goes through, the verdict is `pending`, the
74
+ * agent is told nothing, because the user can do nothing about it. A contract
75
+ * refusal filed the same way says "we will retry and it will work", when
76
+ * retrying cannot help: the request that was refused is the request we would
77
+ * send again.
78
+ *
79
+ * Left as `pending`, a client that has stopped verifying ANYTHING looks
80
+ * exactly like a client waiting on a slow backend — for as long as nobody
81
+ * looks.
82
+ */
83
+ export class McpContractError extends McpBackendError {
84
+ constructor(route, status, message) {
85
+ super(route, status, message);
86
+ this.name = 'McpContractError';
87
+ }
88
+ }
89
+ /**
90
+ * `409 DIGEST_VERSION_UNSUPPORTED` — the backend cannot compute the digest
91
+ * formula this binary uses.
92
+ *
93
+ * Its own class because its remedy is its own: every digest we send is
94
+ * unmatchable, so nothing can be verified until one side is upgraded, and the
95
+ * `supported` list is the only actionable thing in the whole exchange.
96
+ */
97
+ export class DigestVersionUnsupportedError extends McpContractError {
98
+ code;
99
+ supported;
100
+ constructor(route, code, supported, message) {
101
+ super(route, 409, message);
102
+ this.code = code;
103
+ this.supported = supported;
104
+ this.name = 'DigestVersionUnsupportedError';
105
+ }
106
+ }
107
+ /** `{ error: { code, supported } }`, when the backend sent one. */
108
+ function errorEnvelope(body) {
109
+ if (!body || typeof body !== 'object')
110
+ return {};
111
+ const error = body.error;
112
+ if (!error || typeof error !== 'object')
113
+ return {};
114
+ const shape = error;
115
+ return {
116
+ code: typeof shape.code === 'string' ? shape.code : undefined,
117
+ supported: Array.isArray(shape.supported)
118
+ ? shape.supported.filter((value) => typeof value === 'string')
119
+ : undefined,
120
+ };
121
+ }
122
+ /**
123
+ * Turns a non-2xx into the right kind of error.
124
+ *
125
+ * The body is read ONLY to name the refusal. A body that is not JSON, or that
126
+ * carries no `error.code`, still produces a contract error when the status
127
+ * says so: a server being terse does not make its refusal an outage.
128
+ *
129
+ * ⚠️ Nothing from the request — token, headers, payload — goes into the
130
+ * message. A contract error is precisely what ends up in a log.
131
+ */
132
+ async function backendError(res, route, requestLabel) {
133
+ const label = `${requestLabel} failed with HTTP ${res.status}`;
134
+ if (!isContractErrorStatus(res.status))
135
+ return new McpBackendError(route, res.status, label);
136
+ let body;
137
+ try {
138
+ body = await res.json();
139
+ }
140
+ catch {
141
+ body = undefined;
142
+ }
143
+ const { code, supported } = errorEnvelope(body);
144
+ if (res.status === 409 && code === 'DIGEST_VERSION_UNSUPPORTED') {
145
+ const list = supported ?? [];
146
+ return new DigestVersionUnsupportedError(route, code, list, `${label}: this backend cannot compute digest version "${DIGEST_VERSION}"` +
147
+ (list.length > 0 ? `; it supports ${list.join(', ')}` : ''));
148
+ }
149
+ return new McpContractError(route, res.status, code ? `${label} (${code})` : label);
150
+ }
151
+ /**
152
+ * Mirrors `VerifyToolsBodyDto` (`ArrayMaxSize(500)`) on the gateway. A request
153
+ * over this bound is refused as `INVALID_ARGUMENT`; we split client-side.
154
+ */
155
+ export const MAX_TOOLS_PER_REQUEST = 500;
156
+ /**
157
+ * Mirrors `CheckMcpServersBodyDto`'s own `MAX_SERVERS_PER_REQUEST` (200), a
158
+ * different bound than {@link MAX_TOOLS_PER_REQUEST}.
159
+ */
160
+ export const MAX_SERVERS_PER_REQUEST = 200;
161
+ /**
162
+ * Gate every outbound call behind the same origin allowlist that protects the
163
+ * hooks (`isTrustedApiBase`, `src/hooks/runtime/trusted-api-base.ts`). Throws,
164
+ * never a silent `false`-shaped result: a rejected apiBase has no valid
165
+ * representation in any of the return types below, so failing the promise is
166
+ * the only way to guarantee it cannot be mistaken for "checked, nothing to
167
+ * report".
168
+ */
169
+ /**
170
+ * We refused to call, and the backend has nothing to do with it.
171
+ *
172
+ * ⚠️ Its own class because the caller was filing it as "backend unreachable,
173
+ * fail-open" — the same words an outage produces. A user whose region is
174
+ * mis-declared then goes and checks their network, their VPN and the
175
+ * backend's health, for a local configuration problem with a one-line fix.
176
+ * The direction is right (fail-open either way); the DIAGNOSIS was wrong, and
177
+ * a wrong diagnosis costs more than a missing one.
178
+ */
179
+ export class UntrustedApiBaseError extends Error {
180
+ apiBase;
181
+ constructor(apiBase) {
182
+ super(`refusing to call the CybeDefend gateway: the origin of "${apiBase}" is not in the ` +
183
+ 'trusted allowlist. Declare it in ~/.cybedefend/regions.json, which is the ' +
184
+ 'documented escape hatch for an internal or local cluster.');
185
+ this.apiBase = apiBase;
186
+ this.name = 'UntrustedApiBaseError';
187
+ }
188
+ }
189
+ function assertTrustedApiBase(apiBase, opts) {
190
+ if (!isTrustedApiBase(apiBase, opts.trustDeps)) {
191
+ throw new UntrustedApiBaseError(apiBase);
192
+ }
193
+ }
194
+ /**
195
+ * Run `attempt(ctx.token)`. On a `401`, ask {@link McpApiOpts.resolveTokenFn}
196
+ * for a fresh token and retry EXACTLY ONCE with it, never a loop. If no
197
+ * fresher token is available, or the retry ALSO comes back `401`, the second
198
+ * response (or the first, if there was no retry) is returned as-is: the
199
+ * caller's own `!res.ok` handling turns it into a thrown error, same as any
200
+ * other non-2xx status.
201
+ */
202
+ async function requestWithAuthRetry(ctx, opts, attempt) {
203
+ const res = await attempt(ctx.token);
204
+ if (res.status !== 401)
205
+ return res;
206
+ const resolveTokenFn = opts.resolveTokenFn ?? resolveTokenWithRefresh;
207
+ const refreshed = await resolveTokenFn(ctx.mcpName);
208
+ if (!refreshed)
209
+ return res;
210
+ return attempt(refreshed); // the ONE retry; its outcome is final either way
211
+ }
212
+ /** Split `items` into batches of at most `size`. Never yields an empty batch. */
213
+ function chunk(items, size) {
214
+ if (items.length === 0)
215
+ return [];
216
+ if (items.length <= size)
217
+ return [items.slice()];
218
+ const batches = [];
219
+ for (let i = 0; i < items.length; i += size)
220
+ batches.push(items.slice(i, i + size));
221
+ return batches;
222
+ }
223
+ /**
224
+ * A silent split would be indistinguishable from a machine that never needed
225
+ * one, so the split is always declared, through `opts.onBatchSplit` rather
226
+ * than a direct write to `stderr`.
227
+ */
228
+ function declareSplit(route, total, batches, cap, opts) {
229
+ opts.onBatchSplit?.(route, total, batches, cap);
230
+ }
231
+ async function parseJsonBody(res, label) {
232
+ try {
233
+ return await res.json();
234
+ }
235
+ catch {
236
+ throw new Error(`${label}: response body is not valid JSON`);
237
+ }
238
+ }
239
+ /**
240
+ * Unwrap the gateway's `{ success, data, message }` envelope down to `data`,
241
+ * and ONLY `data`. `body` and `body.data` are both rejected as insufficient.
242
+ */
243
+ function unwrapEnvelope(body, label) {
244
+ if (!body || typeof body !== 'object') {
245
+ throw new Error(`${label}: response is not a JSON object`);
246
+ }
247
+ const root = body;
248
+ if (root.success !== true) {
249
+ throw new Error(`${label}: response missing \`success: true\``);
250
+ }
251
+ const data = root.data;
252
+ if (!data || typeof data !== 'object') {
253
+ throw new Error(`${label}: response missing \`data\``);
254
+ }
255
+ return data;
256
+ }
257
+ /** A named field that MUST be an array: `data.results` / `data.verdicts`. */
258
+ function extractArray(data, field, label) {
259
+ const value = data[field];
260
+ if (!Array.isArray(value)) {
261
+ throw new Error(`${label}: response missing \`data.${field}\` array`);
262
+ }
263
+ return value;
264
+ }
265
+ /**
266
+ * `{ mode, strictIssuer }`, or a throw. Strict on purpose: a policy is what
267
+ * every action in the response was decided under, and a response without
268
+ * one is the deprecated envelope — reading it as this contract would decide
269
+ * on nothing. A mode out of vocabulary is refused rather than widened.
270
+ */
271
+ function parseOrgPolicy(raw, label) {
272
+ const shape = raw && typeof raw === 'object' ? raw : undefined;
273
+ if (!shape || !isPolicyMode(shape.mode) || typeof shape.strictIssuer !== 'boolean') {
274
+ throw new Error(`${label}: response missing a readable \`policy\` ({ mode, strictIssuer })`);
275
+ }
276
+ return { mode: shape.mode, strictIssuer: shape.strictIssuer };
277
+ }
278
+ /**
279
+ * The action to execute, or `pending` when the backend sent none we can read.
280
+ * `pending` and not `allow`: an unreadable decision is no decision.
281
+ */
282
+ function parseAction(raw) {
283
+ return isServerAction(raw) ? raw : 'pending';
284
+ }
285
+ /** The org-scoped path of a route. The id goes in the PATH, encoded. */
286
+ function orgRoute(ctx, suffix) {
287
+ return `${ctx.apiBase}/mcp/organization/${encodeURIComponent(ctx.organizationId)}/${suffix}`;
288
+ }
289
+ // ═══════════════════════════════════════════════════════════════════════════
290
+ // POST /mcp/organization/:organizationId/servers/check
291
+ // ═══════════════════════════════════════════════════════════════════════════
292
+ const SERVERS_CHECK_LABEL = 'POST /mcp/organization/:organizationId/servers/check';
293
+ function toMcpServerCheckInput(raw) {
294
+ const r = (raw ?? {});
295
+ return {
296
+ url: typeof r.url === 'string' ? r.url : undefined,
297
+ purl: typeof r.purl === 'string' ? r.purl : undefined,
298
+ serverKey: typeof r.serverKey === 'string' ? r.serverKey : undefined,
299
+ };
300
+ }
301
+ function toAdvisory(raw) {
302
+ const a = (raw ?? {});
303
+ return {
304
+ id: typeof a.id === 'string' ? a.id : '',
305
+ category: typeof a.category === 'string' ? a.category : '',
306
+ severity: typeof a.severity === 'string' ? a.severity : '',
307
+ summary: typeof a.summary === 'string' ? a.summary : '',
308
+ source: typeof a.source === 'string' ? a.source : '',
309
+ };
310
+ }
311
+ function toServerCheckResult(raw) {
312
+ const r = (raw ?? {});
313
+ const advisories = Array.isArray(r.advisories) ? r.advisories : [];
314
+ return {
315
+ input: toMcpServerCheckInput(r.input),
316
+ advisories: advisories.map(toAdvisory),
317
+ mirrored: Boolean(r.mirrored),
318
+ action: parseAction(r.action),
319
+ blockedBy: r.blockedBy === 'organization' ? 'organization' : null,
320
+ };
321
+ }
322
+ async function checkMcpServersOnce(ctx, servers, opts) {
323
+ const f = opts.fetchImpl ?? globalThis.fetch;
324
+ const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
325
+ const url = orgRoute(ctx, 'servers/check');
326
+ const attempt = (token) => f(url, {
327
+ method: 'POST',
328
+ headers: {
329
+ Authorization: `Bearer ${token}`,
330
+ 'Content-Type': 'application/json',
331
+ },
332
+ body: JSON.stringify({ digestVersion: DIGEST_VERSION, servers }),
333
+ signal: AbortSignal.timeout(timeoutMs),
334
+ });
335
+ const res = await requestWithAuthRetry(ctx, opts, attempt);
336
+ if (!res.ok) {
337
+ throw await backendError(res, 'servers/check', SERVERS_CHECK_LABEL);
338
+ }
339
+ const body = await parseJsonBody(res, SERVERS_CHECK_LABEL);
340
+ const data = unwrapEnvelope(body, SERVERS_CHECK_LABEL);
341
+ const policy = parseOrgPolicy(data.policy, SERVERS_CHECK_LABEL);
342
+ const results = extractArray(data, 'results', SERVERS_CHECK_LABEL);
343
+ return { policy, results: results.map(toServerCheckResult) };
344
+ }
345
+ /**
346
+ * Checks a list of MCP server coordinates against the backend's advisory
347
+ * lookup + registry mirror.
348
+ *
349
+ * The gateway refuses more than {@link MAX_SERVERS_PER_REQUEST} servers in a
350
+ * single request (`CheckMcpServersBodyDto`): larger inputs are split into
351
+ * sequential batches here and the split is declared through `onBatchSplit`.
352
+ */
353
+ export async function checkMcpServers(ctx, servers, opts = {}) {
354
+ assertTrustedApiBase(ctx.apiBase, opts);
355
+ if (servers.length === 0)
356
+ return { policy: null, results: [] };
357
+ const batches = chunk(servers, MAX_SERVERS_PER_REQUEST);
358
+ if (batches.length > 1) {
359
+ declareSplit(SERVERS_CHECK_LABEL, servers.length, batches.length, MAX_SERVERS_PER_REQUEST, opts);
360
+ }
361
+ // One organization, one policy: every batch answers with the same one, and
362
+ // the last is as fresh as any.
363
+ let policy = null;
364
+ const results = [];
365
+ for (const batch of batches) {
366
+ const answer = await checkMcpServersOnce(ctx, batch, opts);
367
+ policy = answer.policy;
368
+ results.push(...answer.results);
369
+ }
370
+ return { policy, results };
371
+ }
372
+ // ═══════════════════════════════════════════════════════════════════════════
373
+ // POST /mcp/organization/:organizationId/tools/verify
374
+ // ═══════════════════════════════════════════════════════════════════════════
375
+ const TOOLS_VERIFY_LABEL = 'POST /mcp/organization/:organizationId/tools/verify';
376
+ /**
377
+ * CLOSED vocabulary of the tool verdicts THIS client knows how to interpret.
378
+ *
379
+ * `verdict` stays typed `string` in {@link ToolVerdict}: the backend is free
380
+ * to emit a value this binary does not know, and that is precisely the case
381
+ * that must be NAMED rather than collapsed. The list below says what this
382
+ * client can DO, not what the backend is allowed to say.
383
+ */
384
+ export const KNOWN_TOOL_VERDICTS = ['CLEAN', 'SUSPICIOUS', 'MALICIOUS'];
385
+ /** `true` only for a verdict this binary knows how to interpret. */
386
+ export function isKnownToolVerdict(verdict) {
387
+ return KNOWN_TOOL_VERDICTS.includes(verdict);
388
+ }
389
+ function toToolVerdict(raw) {
390
+ const v = (raw ?? {});
391
+ return {
392
+ digest: typeof v.digest === 'string' ? v.digest : '',
393
+ known: Boolean(v.known),
394
+ verdict: typeof v.verdict === 'string' ? v.verdict : '',
395
+ category: typeof v.category === 'string' ? v.category : '',
396
+ severity: typeof v.severity === 'string' ? v.severity : '',
397
+ reason: typeof v.reason === 'string' ? v.reason : '',
398
+ action: parseAction(v.action),
399
+ };
400
+ }
401
+ async function verifyMcpToolsOnce(ctx, tools, opts) {
402
+ const f = opts.fetchImpl ?? globalThis.fetch;
403
+ const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
404
+ const url = orgRoute(ctx, 'tools/verify');
405
+ const attempt = (token) => f(url, {
406
+ method: 'POST',
407
+ headers: {
408
+ Authorization: `Bearer ${token}`,
409
+ 'Content-Type': 'application/json',
410
+ },
411
+ body: JSON.stringify({ digestVersion: DIGEST_VERSION, tools }),
412
+ signal: AbortSignal.timeout(timeoutMs),
413
+ });
414
+ const res = await requestWithAuthRetry(ctx, opts, attempt);
415
+ if (!res.ok) {
416
+ throw await backendError(res, 'tools/verify', TOOLS_VERIFY_LABEL);
417
+ }
418
+ const body = await parseJsonBody(res, TOOLS_VERIFY_LABEL);
419
+ const data = unwrapEnvelope(body, TOOLS_VERIFY_LABEL);
420
+ const policy = parseOrgPolicy(data.policy, TOOLS_VERIFY_LABEL);
421
+ const verdicts = extractArray(data, 'verdicts', TOOLS_VERIFY_LABEL);
422
+ return { policy, verdicts: verdicts.map(toToolVerdict) };
423
+ }
424
+ /**
425
+ * Verifies a list of MCP tool submissions by digest, judging the ones that
426
+ * carry a `definition`.
427
+ *
428
+ * The gateway refuses more than {@link MAX_TOOLS_PER_REQUEST} tools in a
429
+ * single request (`VerifyToolsBodyDto`, `ArrayMaxSize(500)`): larger inputs
430
+ * are split into sequential batches here and the split is declared through
431
+ * `onBatchSplit`.
432
+ */
433
+ export async function verifyMcpTools(ctx, submissions, opts = {}) {
434
+ assertTrustedApiBase(ctx.apiBase, opts);
435
+ if (submissions.length === 0)
436
+ return { policy: null, verdicts: [] };
437
+ const batches = chunk(submissions, MAX_TOOLS_PER_REQUEST);
438
+ if (batches.length > 1) {
439
+ declareSplit(TOOLS_VERIFY_LABEL, submissions.length, batches.length, MAX_TOOLS_PER_REQUEST, opts);
440
+ }
441
+ let policy = null;
442
+ const verdicts = [];
443
+ for (const batch of batches) {
444
+ const answer = await verifyMcpToolsOnce(ctx, batch, opts);
445
+ policy = answer.policy;
446
+ verdicts.push(...answer.verdicts);
447
+ }
448
+ return { policy, verdicts };
449
+ }
450
+ // ═══════════════════════════════════════════════════════════════════════════
451
+ // GET /mcp/organization/:organizationId/policy
452
+ // ═══════════════════════════════════════════════════════════════════════════
453
+ const POLICY_LABEL = 'GET /mcp/organization/:organizationId/policy';
454
+ /**
455
+ * Reads the organization's policy on its own.
456
+ *
457
+ * Not needed to APPLY it — every verify/check response already carries the
458
+ * policy its actions were decided under — but it is how the policy is shown
459
+ * (`vibedefend status`, `vibedefend org`), how `connect` learns
460
+ * `strictIssuer` before any OAuth discovery, and how a verifier refreshes
461
+ * what it knows before a decision that only the cache will answer.
462
+ */
463
+ export async function getOrgPolicy(ctx, opts = {}) {
464
+ assertTrustedApiBase(ctx.apiBase, opts);
465
+ const f = opts.fetchImpl ?? globalThis.fetch;
466
+ const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
467
+ const url = orgRoute(ctx, 'policy');
468
+ const attempt = (token) => f(url, {
469
+ method: 'GET',
470
+ headers: { Authorization: `Bearer ${token}` },
471
+ signal: AbortSignal.timeout(timeoutMs),
472
+ });
473
+ const res = await requestWithAuthRetry(ctx, opts, attempt);
474
+ if (!res.ok) {
475
+ throw await backendError(res, 'policy', POLICY_LABEL);
476
+ }
477
+ const body = await parseJsonBody(res, POLICY_LABEL);
478
+ return parseOrgPolicy(unwrapEnvelope(body, POLICY_LABEL), POLICY_LABEL);
479
+ }
480
+ // ═══════════════════════════════════════════════════════════════════════════
481
+ // POST /mcp/organization/:organizationId/reports
482
+ // ═══════════════════════════════════════════════════════════════════════════
483
+ const REPORTS_LABEL = 'POST /mcp/organization/:organizationId/reports';
484
+ /**
485
+ * Sends one call report (inventory + events). Answers 204.
486
+ *
487
+ * A refusal is a `GatewayHttpError`, never a `McpContractError`: a report the
488
+ * backend does not take (VibeDefend off, an older gateway) says nothing about
489
+ * the verification contract and must not be filed as one. The report buffer
490
+ * decides what to do with the status.
491
+ */
492
+ export async function postMcpReport(ctx, body, opts = {}) {
493
+ assertTrustedApiBase(ctx.apiBase, opts);
494
+ const f = opts.fetchImpl ?? globalThis.fetch;
495
+ const url = orgRoute(ctx, 'reports');
496
+ const payload = JSON.stringify(body);
497
+ const attempt = (token) => f(url, {
498
+ method: 'POST',
499
+ headers: {
500
+ Authorization: `Bearer ${token}`,
501
+ 'Content-Type': 'application/json',
502
+ },
503
+ body: payload,
504
+ signal: AbortSignal.timeout(opts.timeoutMs ?? REPORT_HTTP_TIMEOUT_MS),
505
+ });
506
+ const res = await requestWithAuthRetry(ctx, opts, attempt);
507
+ if (!res.ok) {
508
+ const retryAfterMs = parseRetryAfter(res.headers?.get('retry-after') ?? null);
509
+ throw new GatewayHttpError(res.status, `${REPORTS_LABEL} failed with HTTP ${res.status}`, {
510
+ retryAfterMs,
511
+ });
512
+ }
513
+ }
514
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/mcp/verify/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAsB,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,cAAc,EAAqC,MAAM,aAAa,CAAC;AAC9F,OAAO,EACL,gBAAgB,GAEjB,MAAM,yCAAyC,CAAC;AAEjD,MAAM,kBAAkB,GAAG,MAAM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