@suveren/gateway 0.8.7 → 0.10.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 (856) hide show
  1. package/README.md +33 -1
  2. package/bin/suveren-gateway.js +363 -9
  3. package/content/integrations/erp.json +184 -0
  4. package/content/integrations/index.json +2 -1
  5. package/dist/control-plane/index.mjs +835 -118
  6. package/dist/mcp-server/http.mjs +876 -193
  7. package/dist/ui/assets/{index-tzStUGuj.js → index-B1qNl7zo.js} +21 -21
  8. package/dist/ui/index.html +1 -1
  9. package/lib/as-pairing.mjs +77 -0
  10. package/lib/config.d.mts +37 -0
  11. package/lib/config.mjs +198 -0
  12. package/node_modules/@hap/core/dist/index.d.mts +33 -2
  13. package/node_modules/@hap/core/dist/index.d.ts +33 -2
  14. package/node_modules/@hap/core/dist/index.js +26 -2
  15. package/node_modules/@hap/core/dist/index.mjs +25 -2
  16. package/node_modules/@hap/core/package.json +1 -1
  17. package/node_modules/@hap/core/src/gatekeeper.ts +36 -2
  18. package/node_modules/@hap/core/src/types.ts +21 -1
  19. package/node_modules/@hono/node-server/README.md +21 -10
  20. package/node_modules/@hono/node-server/dist/early-hints.cjs +1 -1
  21. package/node_modules/@hono/node-server/dist/early-hints.mjs +1 -1
  22. package/node_modules/@hono/node-server/dist/index.cjs +41 -19
  23. package/node_modules/@hono/node-server/dist/index.mjs +42 -20
  24. package/node_modules/@hono/node-server/dist/serve-static.cjs +1 -0
  25. package/node_modules/@hono/node-server/dist/serve-static.d.cts +2 -1
  26. package/node_modules/@hono/node-server/dist/serve-static.d.mts +2 -1
  27. package/node_modules/@hono/node-server/dist/serve-static.mjs +1 -0
  28. package/node_modules/@hono/node-server/package.json +3 -2
  29. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth-extensions.d.ts +43 -2
  30. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth-extensions.d.ts.map +1 -1
  31. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth-extensions.js +26 -5
  32. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth-extensions.js.map +1 -1
  33. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth.d.ts +11 -0
  34. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth.d.ts.map +1 -1
  35. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth.js +96 -14
  36. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth.js.map +1 -1
  37. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/simpleClientCredentials.d.ts +1 -0
  38. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/simpleClientCredentials.d.ts.map +1 -1
  39. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/simpleClientCredentials.js +11 -2
  40. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/simpleClientCredentials.js.map +1 -1
  41. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/server/demoInMemoryOAuthProvider.d.ts +2 -0
  42. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/server/demoInMemoryOAuthProvider.d.ts.map +1 -1
  43. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/auth/providers/proxyProvider.d.ts.map +1 -1
  44. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/auth/providers/proxyProvider.js +6 -3
  45. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/auth/providers/proxyProvider.js.map +1 -1
  46. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/auth.d.ts +3 -0
  47. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/auth.d.ts.map +1 -1
  48. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/auth.js +12 -2
  49. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/auth.js.map +1 -1
  50. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth-extensions.d.ts +43 -2
  51. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth-extensions.d.ts.map +1 -1
  52. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth-extensions.js +26 -5
  53. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth-extensions.js.map +1 -1
  54. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth.d.ts +11 -0
  55. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth.d.ts.map +1 -1
  56. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth.js +96 -14
  57. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth.js.map +1 -1
  58. package/node_modules/@modelcontextprotocol/sdk/dist/esm/examples/client/simpleClientCredentials.d.ts +1 -0
  59. package/node_modules/@modelcontextprotocol/sdk/dist/esm/examples/client/simpleClientCredentials.d.ts.map +1 -1
  60. package/node_modules/@modelcontextprotocol/sdk/dist/esm/examples/client/simpleClientCredentials.js +11 -2
  61. package/node_modules/@modelcontextprotocol/sdk/dist/esm/examples/client/simpleClientCredentials.js.map +1 -1
  62. package/node_modules/@modelcontextprotocol/sdk/dist/esm/examples/server/demoInMemoryOAuthProvider.d.ts +2 -0
  63. package/node_modules/@modelcontextprotocol/sdk/dist/esm/examples/server/demoInMemoryOAuthProvider.d.ts.map +1 -1
  64. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/auth/providers/proxyProvider.d.ts.map +1 -1
  65. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/auth/providers/proxyProvider.js +6 -3
  66. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/auth/providers/proxyProvider.js.map +1 -1
  67. package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth.d.ts +3 -0
  68. package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth.d.ts.map +1 -1
  69. package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth.js +12 -2
  70. package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth.js.map +1 -1
  71. package/node_modules/@modelcontextprotocol/sdk/package.json +1 -1
  72. package/node_modules/@types/node/README.md +1 -1
  73. package/node_modules/@types/node/crypto.d.ts +2 -2
  74. package/node_modules/@types/node/dgram.d.ts +1 -1
  75. package/node_modules/@types/node/package.json +2 -2
  76. package/node_modules/hono/dist/_virtual/_rolldown/runtime.js +13 -0
  77. package/node_modules/hono/dist/adapter/aws-lambda/conninfo.js +42 -23
  78. package/node_modules/hono/dist/adapter/aws-lambda/handler.js +318 -344
  79. package/node_modules/hono/dist/adapter/aws-lambda/index.js +2 -8
  80. package/node_modules/hono/dist/adapter/aws-lambda/types.js +1 -0
  81. package/node_modules/hono/dist/adapter/bun/conninfo.js +20 -25
  82. package/node_modules/hono/dist/adapter/bun/index.js +3 -13
  83. package/node_modules/hono/dist/adapter/bun/serve-static.js +27 -27
  84. package/node_modules/hono/dist/adapter/bun/server.js +11 -5
  85. package/node_modules/hono/dist/adapter/bun/ssg.js +25 -15
  86. package/node_modules/hono/dist/adapter/bun/websocket.js +61 -68
  87. package/node_modules/hono/dist/adapter/cloudflare-pages/conninfo.js +24 -9
  88. package/node_modules/hono/dist/adapter/cloudflare-pages/handler.js +59 -62
  89. package/node_modules/hono/dist/adapter/cloudflare-pages/index.js +2 -8
  90. package/node_modules/hono/dist/adapter/cloudflare-workers/conninfo.js +7 -9
  91. package/node_modules/hono/dist/adapter/cloudflare-workers/index.js +3 -8
  92. package/node_modules/hono/dist/adapter/cloudflare-workers/serve-static-module.js +5 -6
  93. package/node_modules/hono/dist/adapter/cloudflare-workers/serve-static.js +26 -20
  94. package/node_modules/hono/dist/adapter/cloudflare-workers/utils.js +21 -34
  95. package/node_modules/hono/dist/adapter/cloudflare-workers/websocket.js +31 -39
  96. package/node_modules/hono/dist/adapter/deno/conninfo.js +16 -13
  97. package/node_modules/hono/dist/adapter/deno/deno.d.js +1 -0
  98. package/node_modules/hono/dist/adapter/deno/index.js +3 -10
  99. package/node_modules/hono/dist/adapter/deno/serve-static.js +33 -38
  100. package/node_modules/hono/dist/adapter/deno/ssg.js +27 -16
  101. package/node_modules/hono/dist/adapter/deno/websocket.js +30 -30
  102. package/node_modules/hono/dist/adapter/lambda-edge/conninfo.js +7 -9
  103. package/node_modules/hono/dist/adapter/lambda-edge/handler.js +102 -101
  104. package/node_modules/hono/dist/adapter/lambda-edge/index.js +2 -6
  105. package/node_modules/hono/dist/adapter/netlify/conninfo.js +24 -9
  106. package/node_modules/hono/dist/adapter/netlify/handler.js +10 -8
  107. package/node_modules/hono/dist/adapter/netlify/index.js +3 -2
  108. package/node_modules/hono/dist/adapter/netlify/mod.js +2 -6
  109. package/node_modules/hono/dist/adapter/service-worker/handler.js +15 -19
  110. package/node_modules/hono/dist/adapter/service-worker/index.js +23 -7
  111. package/node_modules/hono/dist/adapter/service-worker/types.js +1 -0
  112. package/node_modules/hono/dist/adapter/vercel/conninfo.js +7 -10
  113. package/node_modules/hono/dist/adapter/vercel/handler.js +8 -6
  114. package/node_modules/hono/dist/adapter/vercel/index.js +2 -6
  115. package/node_modules/hono/dist/cjs/_virtual/_rolldown/runtime.js +33 -0
  116. package/node_modules/hono/dist/cjs/adapter/aws-lambda/conninfo.js +42 -44
  117. package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +326 -373
  118. package/node_modules/hono/dist/cjs/adapter/aws-lambda/index.js +7 -34
  119. package/node_modules/hono/dist/cjs/adapter/aws-lambda/types.js +0 -15
  120. package/node_modules/hono/dist/cjs/adapter/bun/conninfo.js +21 -47
  121. package/node_modules/hono/dist/cjs/adapter/bun/index.js +14 -45
  122. package/node_modules/hono/dist/cjs/adapter/bun/serve-static.js +29 -50
  123. package/node_modules/hono/dist/cjs/adapter/bun/server.js +11 -26
  124. package/node_modules/hono/dist/cjs/adapter/bun/ssg.js +24 -35
  125. package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +63 -91
  126. package/node_modules/hono/dist/cjs/adapter/cloudflare-pages/conninfo.js +25 -31
  127. package/node_modules/hono/dist/cjs/adapter/cloudflare-pages/handler.js +61 -85
  128. package/node_modules/hono/dist/cjs/adapter/cloudflare-pages/index.js +7 -34
  129. package/node_modules/hono/dist/cjs/adapter/cloudflare-workers/conninfo.js +8 -31
  130. package/node_modules/hono/dist/cjs/adapter/cloudflare-workers/index.js +7 -33
  131. package/node_modules/hono/dist/cjs/adapter/cloudflare-workers/serve-static-module.js +7 -29
  132. package/node_modules/hono/dist/cjs/adapter/cloudflare-workers/serve-static.js +27 -42
  133. package/node_modules/hono/dist/cjs/adapter/cloudflare-workers/utils.js +21 -55
  134. package/node_modules/hono/dist/cjs/adapter/cloudflare-workers/websocket.js +33 -62
  135. package/node_modules/hono/dist/cjs/adapter/deno/conninfo.js +16 -34
  136. package/node_modules/hono/dist/cjs/adapter/deno/index.js +10 -38
  137. package/node_modules/hono/dist/cjs/adapter/deno/serve-static.js +33 -59
  138. package/node_modules/hono/dist/cjs/adapter/deno/ssg.js +27 -37
  139. package/node_modules/hono/dist/cjs/adapter/deno/websocket.js +32 -53
  140. package/node_modules/hono/dist/cjs/adapter/lambda-edge/conninfo.js +8 -31
  141. package/node_modules/hono/dist/cjs/adapter/lambda-edge/handler.js +102 -130
  142. package/node_modules/hono/dist/cjs/adapter/lambda-edge/index.js +5 -30
  143. package/node_modules/hono/dist/cjs/adapter/netlify/conninfo.js +25 -31
  144. package/node_modules/hono/dist/cjs/adapter/netlify/handler.js +10 -29
  145. package/node_modules/hono/dist/cjs/adapter/netlify/index.js +5 -21
  146. package/node_modules/hono/dist/cjs/adapter/netlify/mod.js +5 -30
  147. package/node_modules/hono/dist/cjs/adapter/service-worker/handler.js +16 -41
  148. package/node_modules/hono/dist/cjs/adapter/service-worker/index.js +25 -30
  149. package/node_modules/hono/dist/cjs/adapter/service-worker/types.js +0 -15
  150. package/node_modules/hono/dist/cjs/adapter/vercel/conninfo.js +8 -32
  151. package/node_modules/hono/dist/cjs/adapter/vercel/handler.js +8 -27
  152. package/node_modules/hono/dist/cjs/adapter/vercel/index.js +5 -30
  153. package/node_modules/hono/dist/cjs/client/client.js +139 -212
  154. package/node_modules/hono/dist/cjs/client/fetch-result-please.js +62 -80
  155. package/node_modules/hono/dist/cjs/client/index.js +7 -32
  156. package/node_modules/hono/dist/cjs/client/types.js +0 -15
  157. package/node_modules/hono/dist/cjs/client/utils.js +54 -92
  158. package/node_modules/hono/dist/cjs/compose.js +49 -66
  159. package/node_modules/hono/dist/cjs/context.js +379 -450
  160. package/node_modules/hono/dist/cjs/helper/accepts/accepts.js +47 -72
  161. package/node_modules/hono/dist/cjs/helper/accepts/index.js +3 -27
  162. package/node_modules/hono/dist/cjs/helper/adapter/index.js +33 -73
  163. package/node_modules/hono/dist/cjs/helper/conninfo/index.js +0 -15
  164. package/node_modules/hono/dist/cjs/helper/conninfo/types.js +0 -15
  165. package/node_modules/hono/dist/cjs/helper/cookie/index.js +75 -116
  166. package/node_modules/hono/dist/cjs/helper/css/common.js +165 -244
  167. package/node_modules/hono/dist/cjs/helper/css/index.js +136 -151
  168. package/node_modules/hono/dist/cjs/helper/dev/index.js +45 -71
  169. package/node_modules/hono/dist/cjs/helper/factory/index.js +30 -51
  170. package/node_modules/hono/dist/cjs/helper/html/index.js +32 -62
  171. package/node_modules/hono/dist/cjs/helper/proxy/index.js +113 -106
  172. package/node_modules/hono/dist/cjs/helper/route/index.js +123 -66
  173. package/node_modules/hono/dist/cjs/helper/ssg/index.js +19 -43
  174. package/node_modules/hono/dist/cjs/helper/ssg/middleware.js +56 -64
  175. package/node_modules/hono/dist/cjs/helper/ssg/plugins.js +55 -57
  176. package/node_modules/hono/dist/cjs/helper/ssg/ssg.js +196 -296
  177. package/node_modules/hono/dist/cjs/helper/ssg/utils.js +47 -90
  178. package/node_modules/hono/dist/cjs/helper/streaming/index.js +8 -35
  179. package/node_modules/hono/dist/cjs/helper/streaming/sse.js +53 -85
  180. package/node_modules/hono/dist/cjs/helper/streaming/stream.js +23 -53
  181. package/node_modules/hono/dist/cjs/helper/streaming/text.js +10 -32
  182. package/node_modules/hono/dist/cjs/helper/streaming/utils.js +13 -32
  183. package/node_modules/hono/dist/cjs/helper/testing/index.js +16 -31
  184. package/node_modules/hono/dist/cjs/helper/websocket/index.js +51 -76
  185. package/node_modules/hono/dist/cjs/hono-base.js +345 -403
  186. package/node_modules/hono/dist/cjs/hono.js +28 -42
  187. package/node_modules/hono/dist/cjs/http-exception.js +55 -56
  188. package/node_modules/hono/dist/cjs/index.js +22 -30
  189. package/node_modules/hono/dist/cjs/jsx/base.js +237 -366
  190. package/node_modules/hono/dist/cjs/jsx/children.js +16 -41
  191. package/node_modules/hono/dist/cjs/jsx/components.js +119 -192
  192. package/node_modules/hono/dist/cjs/jsx/constants.js +15 -42
  193. package/node_modules/hono/dist/cjs/jsx/context.js +144 -162
  194. package/node_modules/hono/dist/cjs/jsx/dom/client.js +49 -69
  195. package/node_modules/hono/dist/cjs/jsx/dom/components.js +23 -52
  196. package/node_modules/hono/dist/cjs/jsx/dom/context.js +39 -67
  197. package/node_modules/hono/dist/cjs/jsx/dom/css.js +143 -158
  198. package/node_modules/hono/dist/cjs/jsx/dom/hooks/index.js +55 -64
  199. package/node_modules/hono/dist/cjs/jsx/dom/index.js +114 -173
  200. package/node_modules/hono/dist/cjs/jsx/dom/intrinsic-element/components.js +282 -375
  201. package/node_modules/hono/dist/cjs/jsx/dom/jsx-dev-runtime.js +14 -49
  202. package/node_modules/hono/dist/cjs/jsx/dom/jsx-runtime.js +5 -32
  203. package/node_modules/hono/dist/cjs/jsx/dom/render.js +469 -623
  204. package/node_modules/hono/dist/cjs/jsx/dom/server.js +37 -64
  205. package/node_modules/hono/dist/cjs/jsx/dom/utils.js +7 -30
  206. package/node_modules/hono/dist/cjs/jsx/hooks/index.js +225 -318
  207. package/node_modules/hono/dist/cjs/jsx/index.js +86 -135
  208. package/node_modules/hono/dist/cjs/jsx/intrinsic-element/common.js +20 -43
  209. package/node_modules/hono/dist/cjs/jsx/intrinsic-element/components.js +117 -168
  210. package/node_modules/hono/dist/cjs/jsx/intrinsic-elements.js +0 -15
  211. package/node_modules/hono/dist/cjs/jsx/jsx-dev-runtime.js +14 -39
  212. package/node_modules/hono/dist/cjs/jsx/jsx-runtime.js +34 -68
  213. package/node_modules/hono/dist/cjs/jsx/streaming.js +123 -166
  214. package/node_modules/hono/dist/cjs/jsx/types.js +0 -15
  215. package/node_modules/hono/dist/cjs/jsx/utils.js +91 -175
  216. package/node_modules/hono/dist/cjs/middleware/basic-auth/index.js +98 -86
  217. package/node_modules/hono/dist/cjs/middleware/bearer-auth/index.js +92 -109
  218. package/node_modules/hono/dist/cjs/middleware/body-limit/index.js +66 -72
  219. package/node_modules/hono/dist/cjs/middleware/cache/index.js +153 -199
  220. package/node_modules/hono/dist/cjs/middleware/combine/index.js +135 -95
  221. package/node_modules/hono/dist/cjs/middleware/compress/index.js +73 -88
  222. package/node_modules/hono/dist/cjs/middleware/context-storage/index.js +49 -41
  223. package/node_modules/hono/dist/cjs/middleware/cors/index.js +107 -107
  224. package/node_modules/hono/dist/cjs/middleware/csrf/index.js +101 -72
  225. package/node_modules/hono/dist/cjs/middleware/etag/digest.js +58 -97
  226. package/node_modules/hono/dist/cjs/middleware/etag/index.js +71 -91
  227. package/node_modules/hono/dist/cjs/middleware/ip-restriction/index.js +161 -169
  228. package/node_modules/hono/dist/cjs/middleware/jsx-renderer/index.js +99 -77
  229. package/node_modules/hono/dist/cjs/middleware/jwk/index.js +3 -27
  230. package/node_modules/hono/dist/cjs/middleware/jwk/jwk.js +118 -135
  231. package/node_modules/hono/dist/cjs/middleware/jwt/index.js +9 -38
  232. package/node_modules/hono/dist/cjs/middleware/jwt/jwt.js +120 -141
  233. package/node_modules/hono/dist/cjs/middleware/language/index.js +7 -35
  234. package/node_modules/hono/dist/cjs/middleware/language/language.js +184 -182
  235. package/node_modules/hono/dist/cjs/middleware/logger/index.js +41 -62
  236. package/node_modules/hono/dist/cjs/middleware/method-not-allowed/index.js +82 -88
  237. package/node_modules/hono/dist/cjs/middleware/method-override/index.js +101 -102
  238. package/node_modules/hono/dist/cjs/middleware/powered-by/index.js +23 -30
  239. package/node_modules/hono/dist/cjs/middleware/pretty-json/index.js +38 -42
  240. package/node_modules/hono/dist/cjs/middleware/request-id/index.js +3 -27
  241. package/node_modules/hono/dist/cjs/middleware/request-id/request-id.js +34 -42
  242. package/node_modules/hono/dist/cjs/middleware/secure-headers/index.js +4 -29
  243. package/node_modules/hono/dist/cjs/middleware/secure-headers/permissions-policy.js +0 -15
  244. package/node_modules/hono/dist/cjs/middleware/secure-headers/secure-headers.js +142 -174
  245. package/node_modules/hono/dist/cjs/middleware/serve-static/index.js +56 -93
  246. package/node_modules/hono/dist/cjs/middleware/serve-static/path.js +15 -38
  247. package/node_modules/hono/dist/cjs/middleware/timeout/index.js +40 -45
  248. package/node_modules/hono/dist/cjs/middleware/timing/index.js +7 -35
  249. package/node_modules/hono/dist/cjs/middleware/timing/timing.js +177 -118
  250. package/node_modules/hono/dist/cjs/middleware/trailing-slash/index.js +85 -58
  251. package/node_modules/hono/dist/cjs/preset/quick.js +18 -37
  252. package/node_modules/hono/dist/cjs/preset/tiny.js +15 -33
  253. package/node_modules/hono/dist/cjs/request/constants.js +5 -27
  254. package/node_modules/hono/dist/cjs/request.js +334 -346
  255. package/node_modules/hono/dist/cjs/router/linear-router/index.js +3 -27
  256. package/node_modules/hono/dist/cjs/router/linear-router/router.js +95 -143
  257. package/node_modules/hono/dist/cjs/router/pattern-router/index.js +3 -27
  258. package/node_modules/hono/dist/cjs/router/pattern-router/router.js +41 -63
  259. package/node_modules/hono/dist/cjs/router/reg-exp-router/index.js +7 -34
  260. package/node_modules/hono/dist/cjs/router/reg-exp-router/matcher.js +18 -45
  261. package/node_modules/hono/dist/cjs/router/reg-exp-router/node.js +91 -135
  262. package/node_modules/hono/dist/cjs/router/reg-exp-router/prepared-router.js +92 -161
  263. package/node_modules/hono/dist/cjs/router/reg-exp-router/router.js +98 -147
  264. package/node_modules/hono/dist/cjs/router/reg-exp-router/trie.js +73 -89
  265. package/node_modules/hono/dist/cjs/router/smart-router/index.js +3 -27
  266. package/node_modules/hono/dist/cjs/router/smart-router/router.js +49 -79
  267. package/node_modules/hono/dist/cjs/router/trie-router/index.js +3 -27
  268. package/node_modules/hono/dist/cjs/router/trie-router/node.js +134 -186
  269. package/node_modules/hono/dist/cjs/router/trie-router/router.js +15 -39
  270. package/node_modules/hono/dist/cjs/router/utils.js +5 -27
  271. package/node_modules/hono/dist/cjs/router.js +37 -37
  272. package/node_modules/hono/dist/cjs/types.js +5 -28
  273. package/node_modules/hono/dist/cjs/utils/accept.js +177 -225
  274. package/node_modules/hono/dist/cjs/utils/basic-auth.js +16 -40
  275. package/node_modules/hono/dist/cjs/utils/body.js +84 -110
  276. package/node_modules/hono/dist/cjs/utils/buffer.js +43 -91
  277. package/node_modules/hono/dist/cjs/utils/color.js +35 -44
  278. package/node_modules/hono/dist/cjs/utils/compress.js +11 -26
  279. package/node_modules/hono/dist/cjs/utils/concurrent.js +29 -59
  280. package/node_modules/hono/dist/cjs/utils/constants.js +7 -26
  281. package/node_modules/hono/dist/cjs/utils/cookie.js +107 -177
  282. package/node_modules/hono/dist/cjs/utils/crypto.js +30 -61
  283. package/node_modules/hono/dist/cjs/utils/encode.js +31 -48
  284. package/node_modules/hono/dist/cjs/utils/filepath.js +23 -54
  285. package/node_modules/hono/dist/cjs/utils/handler.js +11 -33
  286. package/node_modules/hono/dist/cjs/utils/headers.js +0 -15
  287. package/node_modules/hono/dist/cjs/utils/html.js +96 -137
  288. package/node_modules/hono/dist/cjs/utils/http-status.js +0 -15
  289. package/node_modules/hono/dist/cjs/utils/ipaddr.js +213 -286
  290. package/node_modules/hono/dist/cjs/utils/jwt/index.js +14 -27
  291. package/node_modules/hono/dist/cjs/utils/jwt/jwa.js +25 -42
  292. package/node_modules/hono/dist/cjs/utils/jwt/jws.js +119 -199
  293. package/node_modules/hono/dist/cjs/utils/jwt/jwt.js +122 -206
  294. package/node_modules/hono/dist/cjs/utils/jwt/types.js +122 -159
  295. package/node_modules/hono/dist/cjs/utils/jwt/utf8.js +9 -28
  296. package/node_modules/hono/dist/cjs/utils/mime.js +75 -101
  297. package/node_modules/hono/dist/cjs/utils/stream.js +88 -111
  298. package/node_modules/hono/dist/cjs/utils/types.js +0 -15
  299. package/node_modules/hono/dist/cjs/utils/url.js +185 -234
  300. package/node_modules/hono/dist/cjs/validator/index.js +3 -27
  301. package/node_modules/hono/dist/cjs/validator/utils.js +0 -15
  302. package/node_modules/hono/dist/cjs/validator/validator.js +60 -103
  303. package/node_modules/hono/dist/client/client.js +138 -197
  304. package/node_modules/hono/dist/client/fetch-result-please.js +59 -56
  305. package/node_modules/hono/dist/client/index.js +3 -7
  306. package/node_modules/hono/dist/client/types.js +1 -0
  307. package/node_modules/hono/dist/client/utils.js +51 -68
  308. package/node_modules/hono/dist/compose.js +49 -45
  309. package/node_modules/hono/dist/context.js +376 -426
  310. package/node_modules/hono/dist/helper/accepts/accepts.js +47 -51
  311. package/node_modules/hono/dist/helper/accepts/index.js +1 -4
  312. package/node_modules/hono/dist/helper/adapter/index.js +33 -52
  313. package/node_modules/hono/dist/helper/conninfo/index.js +1 -0
  314. package/node_modules/hono/dist/helper/conninfo/types.js +1 -0
  315. package/node_modules/hono/dist/helper/cookie/index.js +74 -94
  316. package/node_modules/hono/dist/helper/css/common.js +167 -225
  317. package/node_modules/hono/dist/helper/css/index.js +132 -137
  318. package/node_modules/hono/dist/helper/dev/index.js +44 -49
  319. package/node_modules/hono/dist/helper/factory/index.js +27 -27
  320. package/node_modules/hono/dist/helper/html/index.js +30 -39
  321. package/node_modules/hono/dist/helper/proxy/index.js +116 -88
  322. package/node_modules/hono/dist/helper/route/index.js +121 -43
  323. package/node_modules/hono/dist/helper/ssg/index.js +3 -18
  324. package/node_modules/hono/dist/helper/ssg/middleware.js +53 -40
  325. package/node_modules/hono/dist/helper/ssg/plugins.js +55 -36
  326. package/node_modules/hono/dist/helper/ssg/ssg.js +198 -283
  327. package/node_modules/hono/dist/helper/ssg/utils.js +53 -75
  328. package/node_modules/hono/dist/helper/streaming/index.js +2 -8
  329. package/node_modules/hono/dist/helper/streaming/sse.js +50 -61
  330. package/node_modules/hono/dist/helper/streaming/stream.js +22 -31
  331. package/node_modules/hono/dist/helper/streaming/text.js +9 -10
  332. package/node_modules/hono/dist/helper/streaming/utils.js +9 -12
  333. package/node_modules/hono/dist/helper/testing/index.js +16 -10
  334. package/node_modules/hono/dist/helper/websocket/index.js +49 -53
  335. package/node_modules/hono/dist/hono-base.js +342 -379
  336. package/node_modules/hono/dist/hono.js +27 -20
  337. package/node_modules/hono/dist/http-exception.js +53 -33
  338. package/node_modules/hono/dist/index.js +19 -6
  339. package/node_modules/hono/dist/jsx/base.js +231 -340
  340. package/node_modules/hono/dist/jsx/children.js +16 -20
  341. package/node_modules/hono/dist/jsx/components.js +118 -170
  342. package/node_modules/hono/dist/jsx/constants.js +9 -15
  343. package/node_modules/hono/dist/jsx/context.js +153 -150
  344. package/node_modules/hono/dist/jsx/dom/client.js +45 -48
  345. package/node_modules/hono/dist/jsx/dom/components.js +21 -29
  346. package/node_modules/hono/dist/jsx/dom/context.js +37 -44
  347. package/node_modules/hono/dist/jsx/dom/css.js +142 -147
  348. package/node_modules/hono/dist/jsx/dom/hooks/index.js +52 -40
  349. package/node_modules/hono/dist/jsx/dom/index.js +71 -134
  350. package/node_modules/hono/dist/jsx/dom/intrinsic-element/components.js +275 -359
  351. package/node_modules/hono/dist/jsx/dom/jsx-dev-runtime.js +14 -18
  352. package/node_modules/hono/dist/jsx/dom/jsx-runtime.js +2 -8
  353. package/node_modules/hono/dist/jsx/dom/render.js +492 -631
  354. package/node_modules/hono/dist/jsx/dom/server.js +32 -32
  355. package/node_modules/hono/dist/jsx/dom/utils.js +6 -8
  356. package/node_modules/hono/dist/jsx/hooks/index.js +236 -308
  357. package/node_modules/hono/dist/jsx/index.js +45 -98
  358. package/node_modules/hono/dist/jsx/intrinsic-element/common.js +20 -22
  359. package/node_modules/hono/dist/jsx/intrinsic-element/components.js +113 -154
  360. package/node_modules/hono/dist/jsx/intrinsic-elements.js +1 -0
  361. package/node_modules/hono/dist/jsx/jsx-dev-runtime.js +12 -16
  362. package/node_modules/hono/dist/jsx/jsx-runtime.js +29 -42
  363. package/node_modules/hono/dist/jsx/streaming.js +120 -142
  364. package/node_modules/hono/dist/jsx/types.js +1 -0
  365. package/node_modules/hono/dist/jsx/utils.js +105 -168
  366. package/node_modules/hono/dist/middleware/basic-auth/index.js +96 -63
  367. package/node_modules/hono/dist/middleware/bearer-auth/index.js +93 -89
  368. package/node_modules/hono/dist/middleware/body-limit/index.js +66 -51
  369. package/node_modules/hono/dist/middleware/cache/index.js +165 -190
  370. package/node_modules/hono/dist/middleware/combine/index.js +134 -73
  371. package/node_modules/hono/dist/middleware/compress/index.js +75 -69
  372. package/node_modules/hono/dist/middleware/context-storage/index.js +49 -19
  373. package/node_modules/hono/dist/middleware/cors/index.js +107 -86
  374. package/node_modules/hono/dist/middleware/csrf/index.js +103 -53
  375. package/node_modules/hono/dist/middleware/etag/digest.js +59 -77
  376. package/node_modules/hono/dist/middleware/etag/index.js +71 -70
  377. package/node_modules/hono/dist/middleware/ip-restriction/index.js +163 -158
  378. package/node_modules/hono/dist/middleware/jsx-renderer/index.js +97 -54
  379. package/node_modules/hono/dist/middleware/jwk/index.js +1 -4
  380. package/node_modules/hono/dist/middleware/jwk/jwk.js +116 -112
  381. package/node_modules/hono/dist/middleware/jwt/index.js +2 -10
  382. package/node_modules/hono/dist/middleware/jwt/jwt.js +114 -114
  383. package/node_modules/hono/dist/middleware/language/index.js +2 -15
  384. package/node_modules/hono/dist/middleware/language/language.js +180 -157
  385. package/node_modules/hono/dist/middleware/logger/index.js +43 -37
  386. package/node_modules/hono/dist/middleware/method-not-allowed/index.js +81 -66
  387. package/node_modules/hono/dist/middleware/method-override/index.js +101 -81
  388. package/node_modules/hono/dist/middleware/powered-by/index.js +23 -9
  389. package/node_modules/hono/dist/middleware/pretty-json/index.js +39 -22
  390. package/node_modules/hono/dist/middleware/request-id/index.js +1 -4
  391. package/node_modules/hono/dist/middleware/request-id/request-id.js +33 -20
  392. package/node_modules/hono/dist/middleware/secure-headers/index.js +1 -5
  393. package/node_modules/hono/dist/middleware/secure-headers/permissions-policy.js +1 -0
  394. package/node_modules/hono/dist/middleware/secure-headers/secure-headers.js +144 -155
  395. package/node_modules/hono/dist/middleware/serve-static/index.js +56 -72
  396. package/node_modules/hono/dist/middleware/serve-static/path.js +15 -17
  397. package/node_modules/hono/dist/middleware/timeout/index.js +40 -23
  398. package/node_modules/hono/dist/middleware/timing/index.js +2 -9
  399. package/node_modules/hono/dist/middleware/timing/timing.js +177 -97
  400. package/node_modules/hono/dist/middleware/trailing-slash/index.js +85 -37
  401. package/node_modules/hono/dist/preset/quick.js +17 -15
  402. package/node_modules/hono/dist/preset/tiny.js +14 -11
  403. package/node_modules/hono/dist/request/constants.js +4 -5
  404. package/node_modules/hono/dist/request.js +328 -319
  405. package/node_modules/hono/dist/router/linear-router/index.js +1 -4
  406. package/node_modules/hono/dist/router/linear-router/router.js +93 -120
  407. package/node_modules/hono/dist/router/pattern-router/index.js +1 -4
  408. package/node_modules/hono/dist/router/pattern-router/router.js +39 -40
  409. package/node_modules/hono/dist/router/reg-exp-router/index.js +1 -7
  410. package/node_modules/hono/dist/router/reg-exp-router/matcher.js +17 -23
  411. package/node_modules/hono/dist/router/reg-exp-router/node.js +87 -110
  412. package/node_modules/hono/dist/router/reg-exp-router/prepared-router.js +89 -137
  413. package/node_modules/hono/dist/router/reg-exp-router/router.js +92 -129
  414. package/node_modules/hono/dist/router/reg-exp-router/trie.js +69 -64
  415. package/node_modules/hono/dist/router/smart-router/index.js +1 -4
  416. package/node_modules/hono/dist/router/smart-router/router.js +46 -55
  417. package/node_modules/hono/dist/router/trie-router/index.js +1 -4
  418. package/node_modules/hono/dist/router/trie-router/node.js +131 -162
  419. package/node_modules/hono/dist/router/trie-router/router.js +11 -14
  420. package/node_modules/hono/dist/router/utils.js +4 -5
  421. package/node_modules/hono/dist/router.js +35 -14
  422. package/node_modules/hono/dist/types/adapter/aws-lambda/conninfo.d.ts +4 -1
  423. package/node_modules/hono/dist/types/adapter/aws-lambda/handler.d.ts +150 -104
  424. package/node_modules/hono/dist/types/adapter/aws-lambda/index.d.ts +4 -8
  425. package/node_modules/hono/dist/types/adapter/aws-lambda/types.d.ts +152 -122
  426. package/node_modules/hono/dist/types/adapter/bun/conninfo.d.ts +4 -1
  427. package/node_modules/hono/dist/types/adapter/bun/index.d.ts +6 -10
  428. package/node_modules/hono/dist/types/adapter/bun/serve-static.d.ts +7 -2
  429. package/node_modules/hono/dist/types/adapter/bun/server.d.ts +4 -5
  430. package/node_modules/hono/dist/types/adapter/bun/ssg.d.ts +5 -1
  431. package/node_modules/hono/dist/types/adapter/bun/websocket.d.ts +31 -16
  432. package/node_modules/hono/dist/types/adapter/cloudflare-pages/conninfo.d.ts +4 -1
  433. package/node_modules/hono/dist/types/adapter/cloudflare-pages/handler.d.ts +29 -17
  434. package/node_modules/hono/dist/types/adapter/cloudflare-pages/index.d.ts +3 -7
  435. package/node_modules/hono/dist/types/adapter/cloudflare-workers/conninfo.d.ts +6 -1
  436. package/node_modules/hono/dist/types/adapter/cloudflare-workers/index.d.ts +4 -7
  437. package/node_modules/hono/dist/types/adapter/cloudflare-workers/serve-static-module.d.ts +5 -2
  438. package/node_modules/hono/dist/types/adapter/cloudflare-workers/serve-static.d.ts +10 -5
  439. package/node_modules/hono/dist/types/adapter/cloudflare-workers/utils.d.ts +10 -2
  440. package/node_modules/hono/dist/types/adapter/cloudflare-workers/websocket.d.ts +6 -1
  441. package/node_modules/hono/dist/types/adapter/deno/conninfo.d.ts +4 -1
  442. package/node_modules/hono/dist/types/adapter/deno/deno.d.ts +1 -0
  443. package/node_modules/hono/dist/types/adapter/deno/index.d.ts +5 -8
  444. package/node_modules/hono/dist/types/adapter/deno/serve-static.d.ts +7 -2
  445. package/node_modules/hono/dist/types/adapter/deno/ssg.d.ts +5 -1
  446. package/node_modules/hono/dist/types/adapter/deno/websocket.d.ts +6 -1
  447. package/node_modules/hono/dist/types/adapter/lambda-edge/conninfo.d.ts +6 -1
  448. package/node_modules/hono/dist/types/adapter/lambda-edge/handler.d.ts +83 -57
  449. package/node_modules/hono/dist/types/adapter/lambda-edge/index.d.ts +3 -7
  450. package/node_modules/hono/dist/types/adapter/netlify/conninfo.d.ts +4 -1
  451. package/node_modules/hono/dist/types/adapter/netlify/handler.d.ts +6 -1
  452. package/node_modules/hono/dist/types/adapter/netlify/index.d.ts +3 -5
  453. package/node_modules/hono/dist/types/adapter/netlify/mod.d.ts +3 -2
  454. package/node_modules/hono/dist/types/adapter/service-worker/handler.d.ts +9 -7
  455. package/node_modules/hono/dist/types/adapter/service-worker/index.d.ts +7 -9
  456. package/node_modules/hono/dist/types/adapter/service-worker/types.d.ts +12 -7
  457. package/node_modules/hono/dist/types/adapter/vercel/conninfo.d.ts +6 -1
  458. package/node_modules/hono/dist/types/adapter/vercel/handler.d.ts +6 -1
  459. package/node_modules/hono/dist/types/adapter/vercel/index.d.ts +3 -6
  460. package/node_modules/hono/dist/types/client/client.d.ts +5 -3
  461. package/node_modules/hono/dist/types/client/fetch-result-please.d.ts +21 -19
  462. package/node_modules/hono/dist/types/client/index.d.ts +5 -7
  463. package/node_modules/hono/dist/types/client/types.d.ts +134 -159
  464. package/node_modules/hono/dist/types/client/utils.d.ts +6 -4
  465. package/node_modules/hono/dist/types/compose.d.ts +4 -2
  466. package/node_modules/hono/dist/types/context.d.ts +335 -335
  467. package/node_modules/hono/dist/types/helper/accepts/accepts.d.ts +11 -9
  468. package/node_modules/hono/dist/types/helper/accepts/index.d.ts +2 -5
  469. package/node_modules/hono/dist/types/helper/adapter/index.d.ts +4 -6
  470. package/node_modules/hono/dist/types/helper/conninfo/index.d.ts +2 -5
  471. package/node_modules/hono/dist/types/helper/conninfo/types.d.ts +25 -23
  472. package/node_modules/hono/dist/types/helper/cookie/index.d.ts +10 -12
  473. package/node_modules/hono/dist/types/helper/css/common.d.ts +11 -9
  474. package/node_modules/hono/dist/types/helper/css/index.d.ts +26 -28
  475. package/node_modules/hono/dist/types/helper/dev/index.d.ts +10 -12
  476. package/node_modules/hono/dist/types/helper/factory/index.d.ts +26 -73
  477. package/node_modules/hono/dist/types/helper/html/index.d.ts +4 -7
  478. package/node_modules/hono/dist/types/helper/proxy/index.d.ts +19 -21
  479. package/node_modules/hono/dist/types/helper/route/index.d.ts +4 -2
  480. package/node_modules/hono/dist/types/helper/ssg/index.d.ts +4 -7
  481. package/node_modules/hono/dist/types/helper/ssg/middleware.d.ts +8 -6
  482. package/node_modules/hono/dist/types/helper/ssg/plugins.d.ts +3 -1
  483. package/node_modules/hono/dist/types/helper/ssg/ssg.d.ts +38 -36
  484. package/node_modules/hono/dist/types/helper/ssg/utils.d.ts +5 -3
  485. package/node_modules/hono/dist/types/helper/streaming/index.d.ts +4 -8
  486. package/node_modules/hono/dist/types/helper/streaming/sse.d.ts +10 -8
  487. package/node_modules/hono/dist/types/helper/streaming/stream.d.ts +4 -2
  488. package/node_modules/hono/dist/types/helper/streaming/text.d.ts +4 -2
  489. package/node_modules/hono/dist/types/helper/streaming/utils.d.ts +2 -0
  490. package/node_modules/hono/dist/types/helper/testing/index.d.ts +7 -9
  491. package/node_modules/hono/dist/types/helper/websocket/index.d.ts +30 -33
  492. package/node_modules/hono/dist/types/hono-base.d.ts +208 -210
  493. package/node_modules/hono/dist/types/hono.d.ts +11 -10
  494. package/node_modules/hono/dist/types/http-exception.d.ts +20 -22
  495. package/node_modules/hono/dist/types/index.d.ts +6 -37
  496. package/node_modules/hono/dist/types/jsx/base.d.ts +36 -34
  497. package/node_modules/hono/dist/types/jsx/children.d.ts +8 -6
  498. package/node_modules/hono/dist/types/jsx/components.d.ts +8 -5
  499. package/node_modules/hono/dist/types/jsx/constants.d.ts +2 -0
  500. package/node_modules/hono/dist/types/jsx/context.d.ts +9 -6
  501. package/node_modules/hono/dist/types/jsx/dom/client.d.ts +9 -10
  502. package/node_modules/hono/dist/types/jsx/dom/components.d.ts +9 -6
  503. package/node_modules/hono/dist/types/jsx/dom/context.d.ts +3 -1
  504. package/node_modules/hono/dist/types/jsx/dom/css.d.ts +27 -30
  505. package/node_modules/hono/dist/types/jsx/dom/hooks/index.d.ts +11 -12
  506. package/node_modules/hono/dist/types/jsx/dom/index.d.ts +79 -83
  507. package/node_modules/hono/dist/types/jsx/dom/intrinsic-element/components.d.ts +9 -5
  508. package/node_modules/hono/dist/types/jsx/dom/jsx-dev-runtime.d.ts +4 -6
  509. package/node_modules/hono/dist/types/jsx/dom/jsx-runtime.d.ts +3 -7
  510. package/node_modules/hono/dist/types/jsx/dom/render.d.ts +32 -50
  511. package/node_modules/hono/dist/types/jsx/dom/server.d.ts +87 -85
  512. package/node_modules/hono/dist/types/jsx/dom/utils.d.ts +2 -0
  513. package/node_modules/hono/dist/types/jsx/hooks/index.d.ts +16 -16
  514. package/node_modules/hono/dist/types/jsx/index.d.ts +71 -73
  515. package/node_modules/hono/dist/types/jsx/intrinsic-element/common.d.ts +3 -1
  516. package/node_modules/hono/dist/types/jsx/intrinsic-element/components.d.ts +7 -4
  517. package/node_modules/hono/dist/types/jsx/intrinsic-elements.d.ts +708 -708
  518. package/node_modules/hono/dist/types/jsx/jsx-dev-runtime.d.ts +4 -7
  519. package/node_modules/hono/dist/types/jsx/jsx-runtime.d.ts +7 -10
  520. package/node_modules/hono/dist/types/jsx/streaming.d.ts +9 -10
  521. package/node_modules/hono/dist/types/jsx/types.d.ts +12 -13
  522. package/node_modules/hono/dist/types/jsx/utils.d.ts +2 -0
  523. package/node_modules/hono/dist/types/middleware/basic-auth/index.d.ts +17 -19
  524. package/node_modules/hono/dist/types/middleware/bearer-auth/index.d.ts +46 -48
  525. package/node_modules/hono/dist/types/middleware/body-limit/index.d.ts +6 -8
  526. package/node_modules/hono/dist/types/middleware/cache/index.d.ts +13 -15
  527. package/node_modules/hono/dist/types/middleware/combine/index.d.ts +4 -6
  528. package/node_modules/hono/dist/types/middleware/compress/index.d.ts +9 -10
  529. package/node_modules/hono/dist/types/middleware/context-storage/index.d.ts +4 -6
  530. package/node_modules/hono/dist/types/middleware/cors/index.d.ts +10 -12
  531. package/node_modules/hono/dist/types/middleware/csrf/index.d.ts +6 -8
  532. package/node_modules/hono/dist/types/middleware/etag/digest.d.ts +2 -0
  533. package/node_modules/hono/dist/types/middleware/etag/index.d.ts +6 -8
  534. package/node_modules/hono/dist/types/middleware/ip-restriction/index.d.ts +11 -12
  535. package/node_modules/hono/dist/types/middleware/jsx-renderer/index.d.ts +11 -11
  536. package/node_modules/hono/dist/types/middleware/jwk/index.d.ts +2 -1
  537. package/node_modules/hono/dist/types/middleware/jwk/jwk.d.ts +20 -23
  538. package/node_modules/hono/dist/types/middleware/jwt/index.d.ts +7 -6
  539. package/node_modules/hono/dist/types/middleware/jwt/jwt.d.ts +28 -30
  540. package/node_modules/hono/dist/types/middleware/language/index.d.ts +6 -5
  541. package/node_modules/hono/dist/types/middleware/language/language.d.ts +42 -44
  542. package/node_modules/hono/dist/types/middleware/logger/index.d.ts +3 -5
  543. package/node_modules/hono/dist/types/middleware/method-not-allowed/index.d.ts +7 -9
  544. package/node_modules/hono/dist/types/middleware/method-override/index.d.ts +14 -16
  545. package/node_modules/hono/dist/types/middleware/powered-by/index.d.ts +8 -10
  546. package/node_modules/hono/dist/types/middleware/pretty-json/index.d.ts +18 -20
  547. package/node_modules/hono/dist/types/middleware/request-id/index.d.ts +6 -5
  548. package/node_modules/hono/dist/types/middleware/request-id/request-id.d.ts +9 -11
  549. package/node_modules/hono/dist/types/middleware/secure-headers/index.d.ts +6 -6
  550. package/node_modules/hono/dist/types/middleware/secure-headers/permissions-policy.d.ts +2 -0
  551. package/node_modules/hono/dist/types/middleware/secure-headers/secure-headers.d.ts +55 -57
  552. package/node_modules/hono/dist/types/middleware/serve-static/index.d.ts +24 -24
  553. package/node_modules/hono/dist/types/middleware/serve-static/path.d.ts +2 -0
  554. package/node_modules/hono/dist/types/middleware/timeout/index.d.ts +5 -7
  555. package/node_modules/hono/dist/types/middleware/timing/index.d.ts +6 -5
  556. package/node_modules/hono/dist/types/middleware/timing/timing.d.ts +17 -20
  557. package/node_modules/hono/dist/types/middleware/trailing-slash/index.d.ts +35 -37
  558. package/node_modules/hono/dist/types/preset/quick.d.ts +6 -9
  559. package/node_modules/hono/dist/types/preset/tiny.d.ts +6 -9
  560. package/node_modules/hono/dist/types/request/constants.d.ts +2 -0
  561. package/node_modules/hono/dist/types/request.d.ts +288 -286
  562. package/node_modules/hono/dist/types/router/linear-router/index.d.ts +2 -5
  563. package/node_modules/hono/dist/types/router/linear-router/router.d.ts +7 -5
  564. package/node_modules/hono/dist/types/router/pattern-router/index.d.ts +2 -5
  565. package/node_modules/hono/dist/types/router/pattern-router/router.d.ts +7 -5
  566. package/node_modules/hono/dist/types/router/reg-exp-router/index.d.ts +3 -6
  567. package/node_modules/hono/dist/types/router/reg-exp-router/matcher.d.ts +3 -1
  568. package/node_modules/hono/dist/types/router/reg-exp-router/node.d.ts +6 -4
  569. package/node_modules/hono/dist/types/router/reg-exp-router/prepared-router.d.ts +11 -10
  570. package/node_modules/hono/dist/types/router/reg-exp-router/router.d.ts +10 -9
  571. package/node_modules/hono/dist/types/router/reg-exp-router/trie.d.ts +7 -5
  572. package/node_modules/hono/dist/types/router/smart-router/index.d.ts +2 -5
  573. package/node_modules/hono/dist/types/router/smart-router/router.d.ts +11 -9
  574. package/node_modules/hono/dist/types/router/trie-router/index.d.ts +2 -5
  575. package/node_modules/hono/dist/types/router/trie-router/node.d.ts +6 -4
  576. package/node_modules/hono/dist/types/router/trie-router/router.d.ts +7 -5
  577. package/node_modules/hono/dist/types/router/utils.d.ts +2 -0
  578. package/node_modules/hono/dist/types/router.d.ts +23 -22
  579. package/node_modules/hono/dist/types/types.d.ts +146 -505
  580. package/node_modules/hono/dist/types/utils/accept.d.ts +5 -3
  581. package/node_modules/hono/dist/types/utils/basic-auth.d.ts +4 -2
  582. package/node_modules/hono/dist/types/utils/body.d.ts +46 -50
  583. package/node_modules/hono/dist/types/utils/buffer.d.ts +7 -5
  584. package/node_modules/hono/dist/types/utils/color.d.ts +2 -0
  585. package/node_modules/hono/dist/types/utils/compress.d.ts +2 -0
  586. package/node_modules/hono/dist/types/utils/concurrent.d.ts +6 -4
  587. package/node_modules/hono/dist/types/utils/constants.d.ts +2 -0
  588. package/node_modules/hono/dist/types/utils/cookie.d.ts +20 -18
  589. package/node_modules/hono/dist/types/utils/crypto.d.ts +5 -7
  590. package/node_modules/hono/dist/types/utils/encode.d.ts +2 -0
  591. package/node_modules/hono/dist/types/utils/filepath.d.ts +5 -3
  592. package/node_modules/hono/dist/types/utils/handler.d.ts +2 -0
  593. package/node_modules/hono/dist/types/utils/headers.d.ts +2 -0
  594. package/node_modules/hono/dist/types/utils/html.d.ts +11 -9
  595. package/node_modules/hono/dist/types/utils/http-status.d.ts +2 -0
  596. package/node_modules/hono/dist/types/utils/ipaddr.d.ts +4 -6
  597. package/node_modules/hono/dist/types/utils/jwt/index.d.ts +18 -12
  598. package/node_modules/hono/dist/types/utils/jwt/jwa.d.ts +15 -13
  599. package/node_modules/hono/dist/types/utils/jwt/jws.d.ts +4 -7
  600. package/node_modules/hono/dist/types/utils/jwt/jwt.d.ts +26 -29
  601. package/node_modules/hono/dist/types/utils/jwt/types.d.ts +48 -45
  602. package/node_modules/hono/dist/types/utils/jwt/utf8.d.ts +2 -0
  603. package/node_modules/hono/dist/types/utils/mime.d.ts +60 -57
  604. package/node_modules/hono/dist/types/utils/stream.d.ts +27 -25
  605. package/node_modules/hono/dist/types/utils/types.d.ts +14 -26
  606. package/node_modules/hono/dist/types/utils/url.d.ts +2 -0
  607. package/node_modules/hono/dist/types/validator/index.d.ts +3 -7
  608. package/node_modules/hono/dist/types/validator/utils.d.ts +6 -8
  609. package/node_modules/hono/dist/types/validator/validator.d.ts +11 -9
  610. package/node_modules/hono/dist/types.js +4 -6
  611. package/node_modules/hono/dist/utils/accept.js +185 -212
  612. package/node_modules/hono/dist/utils/basic-auth.js +18 -21
  613. package/node_modules/hono/dist/utils/body.js +87 -92
  614. package/node_modules/hono/dist/utils/buffer.js +44 -71
  615. package/node_modules/hono/dist/utils/color.js +33 -21
  616. package/node_modules/hono/dist/utils/compress.js +11 -5
  617. package/node_modules/hono/dist/utils/concurrent.js +29 -38
  618. package/node_modules/hono/dist/utils/constants.js +7 -5
  619. package/node_modules/hono/dist/utils/cookie.js +114 -163
  620. package/node_modules/hono/dist/utils/crypto.js +30 -40
  621. package/node_modules/hono/dist/utils/encode.js +30 -26
  622. package/node_modules/hono/dist/utils/filepath.js +23 -33
  623. package/node_modules/hono/dist/utils/handler.js +10 -11
  624. package/node_modules/hono/dist/utils/headers.js +1 -0
  625. package/node_modules/hono/dist/utils/html.js +97 -117
  626. package/node_modules/hono/dist/utils/http-status.js +1 -0
  627. package/node_modules/hono/dist/utils/ipaddr.js +227 -279
  628. package/node_modules/hono/dist/utils/jwt/index.js +12 -4
  629. package/node_modules/hono/dist/utils/jwt/jwa.js +24 -20
  630. package/node_modules/hono/dist/utils/jwt/jws.js +115 -174
  631. package/node_modules/hono/dist/utils/jwt/jwt.js +120 -198
  632. package/node_modules/hono/dist/utils/jwt/types.js +79 -95
  633. package/node_modules/hono/dist/utils/jwt/utf8.js +9 -7
  634. package/node_modules/hono/dist/utils/mime.js +74 -79
  635. package/node_modules/hono/dist/utils/stream.js +86 -88
  636. package/node_modules/hono/dist/utils/types.js +1 -0
  637. package/node_modules/hono/dist/utils/url.js +187 -215
  638. package/node_modules/hono/dist/validator/index.js +1 -4
  639. package/node_modules/hono/dist/validator/utils.js +1 -0
  640. package/node_modules/hono/dist/validator/validator.js +61 -83
  641. package/node_modules/hono/package.json +27 -27
  642. package/node_modules/undici/LICENSE +21 -0
  643. package/node_modules/undici/README.md +741 -0
  644. package/node_modules/undici/docs/docs/api/Agent.md +84 -0
  645. package/node_modules/undici/docs/docs/api/BalancedPool.md +99 -0
  646. package/node_modules/undici/docs/docs/api/CacheStorage.md +30 -0
  647. package/node_modules/undici/docs/docs/api/CacheStore.md +164 -0
  648. package/node_modules/undici/docs/docs/api/Client.md +288 -0
  649. package/node_modules/undici/docs/docs/api/ClientStats.md +27 -0
  650. package/node_modules/undici/docs/docs/api/Connector.md +115 -0
  651. package/node_modules/undici/docs/docs/api/ContentType.md +57 -0
  652. package/node_modules/undici/docs/docs/api/Cookies.md +128 -0
  653. package/node_modules/undici/docs/docs/api/Debug.md +62 -0
  654. package/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +317 -0
  655. package/node_modules/undici/docs/docs/api/Dispatcher.md +1393 -0
  656. package/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +159 -0
  657. package/node_modules/undici/docs/docs/api/Errors.md +49 -0
  658. package/node_modules/undici/docs/docs/api/EventSource.md +45 -0
  659. package/node_modules/undici/docs/docs/api/Fetch.md +60 -0
  660. package/node_modules/undici/docs/docs/api/GlobalInstallation.md +139 -0
  661. package/node_modules/undici/docs/docs/api/H2CClient.md +263 -0
  662. package/node_modules/undici/docs/docs/api/MockAgent.md +603 -0
  663. package/node_modules/undici/docs/docs/api/MockCallHistory.md +197 -0
  664. package/node_modules/undici/docs/docs/api/MockCallHistoryLog.md +43 -0
  665. package/node_modules/undici/docs/docs/api/MockClient.md +81 -0
  666. package/node_modules/undici/docs/docs/api/MockErrors.md +12 -0
  667. package/node_modules/undici/docs/docs/api/MockPool.md +555 -0
  668. package/node_modules/undici/docs/docs/api/Pool.md +84 -0
  669. package/node_modules/undici/docs/docs/api/PoolStats.md +35 -0
  670. package/node_modules/undici/docs/docs/api/ProxyAgent.md +229 -0
  671. package/node_modules/undici/docs/docs/api/RedirectHandler.md +93 -0
  672. package/node_modules/undici/docs/docs/api/RetryAgent.md +50 -0
  673. package/node_modules/undici/docs/docs/api/RetryHandler.md +118 -0
  674. package/node_modules/undici/docs/docs/api/RoundRobinPool.md +145 -0
  675. package/node_modules/undici/docs/docs/api/SnapshotAgent.md +616 -0
  676. package/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +275 -0
  677. package/node_modules/undici/docs/docs/api/Util.md +25 -0
  678. package/node_modules/undici/docs/docs/api/WebSocket.md +141 -0
  679. package/node_modules/undici/docs/docs/api/api-lifecycle.md +91 -0
  680. package/node_modules/undici/docs/docs/best-practices/client-certificate.md +64 -0
  681. package/node_modules/undici/docs/docs/best-practices/crawling.md +58 -0
  682. package/node_modules/undici/docs/docs/best-practices/mocking-request.md +190 -0
  683. package/node_modules/undici/docs/docs/best-practices/proxy.md +127 -0
  684. package/node_modules/undici/docs/docs/best-practices/undici-vs-builtin-fetch.md +224 -0
  685. package/node_modules/undici/docs/docs/best-practices/writing-tests.md +63 -0
  686. package/node_modules/undici/index-fetch.js +65 -0
  687. package/node_modules/undici/index.d.ts +3 -0
  688. package/node_modules/undici/index.js +234 -0
  689. package/node_modules/undici/lib/api/abort-signal.js +59 -0
  690. package/node_modules/undici/lib/api/api-connect.js +110 -0
  691. package/node_modules/undici/lib/api/api-pipeline.js +252 -0
  692. package/node_modules/undici/lib/api/api-request.js +214 -0
  693. package/node_modules/undici/lib/api/api-stream.js +209 -0
  694. package/node_modules/undici/lib/api/api-upgrade.js +111 -0
  695. package/node_modules/undici/lib/api/index.js +7 -0
  696. package/node_modules/undici/lib/api/readable.js +580 -0
  697. package/node_modules/undici/lib/cache/memory-cache-store.js +279 -0
  698. package/node_modules/undici/lib/cache/sqlite-cache-store.js +467 -0
  699. package/node_modules/undici/lib/core/connect.js +153 -0
  700. package/node_modules/undici/lib/core/constants.js +143 -0
  701. package/node_modules/undici/lib/core/diagnostics.js +227 -0
  702. package/node_modules/undici/lib/core/errors.js +477 -0
  703. package/node_modules/undici/lib/core/request.js +485 -0
  704. package/node_modules/undici/lib/core/socks5-client.js +422 -0
  705. package/node_modules/undici/lib/core/socks5-utils.js +212 -0
  706. package/node_modules/undici/lib/core/symbols.js +75 -0
  707. package/node_modules/undici/lib/core/tree.js +160 -0
  708. package/node_modules/undici/lib/core/util.js +992 -0
  709. package/node_modules/undici/lib/dispatcher/agent.js +158 -0
  710. package/node_modules/undici/lib/dispatcher/balanced-pool.js +221 -0
  711. package/node_modules/undici/lib/dispatcher/client-h1.js +1746 -0
  712. package/node_modules/undici/lib/dispatcher/client-h2.js +1060 -0
  713. package/node_modules/undici/lib/dispatcher/client.js +668 -0
  714. package/node_modules/undici/lib/dispatcher/dispatcher-base.js +184 -0
  715. package/node_modules/undici/lib/dispatcher/dispatcher.js +48 -0
  716. package/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +146 -0
  717. package/node_modules/undici/lib/dispatcher/fixed-queue.js +135 -0
  718. package/node_modules/undici/lib/dispatcher/h2c-client.js +51 -0
  719. package/node_modules/undici/lib/dispatcher/pool-base.js +214 -0
  720. package/node_modules/undici/lib/dispatcher/pool.js +118 -0
  721. package/node_modules/undici/lib/dispatcher/proxy-agent.js +319 -0
  722. package/node_modules/undici/lib/dispatcher/retry-agent.js +35 -0
  723. package/node_modules/undici/lib/dispatcher/round-robin-pool.js +137 -0
  724. package/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +260 -0
  725. package/node_modules/undici/lib/encoding/index.js +33 -0
  726. package/node_modules/undici/lib/global.js +59 -0
  727. package/node_modules/undici/lib/handler/cache-handler.js +776 -0
  728. package/node_modules/undici/lib/handler/cache-revalidation-handler.js +124 -0
  729. package/node_modules/undici/lib/handler/decorator-handler.js +67 -0
  730. package/node_modules/undici/lib/handler/deduplication-handler.js +460 -0
  731. package/node_modules/undici/lib/handler/redirect-handler.js +238 -0
  732. package/node_modules/undici/lib/handler/retry-handler.js +504 -0
  733. package/node_modules/undici/lib/handler/unwrap-handler.js +106 -0
  734. package/node_modules/undici/lib/handler/wrap-handler.js +105 -0
  735. package/node_modules/undici/lib/interceptor/cache.js +621 -0
  736. package/node_modules/undici/lib/interceptor/decompress.js +551 -0
  737. package/node_modules/undici/lib/interceptor/deduplicate.js +117 -0
  738. package/node_modules/undici/lib/interceptor/dns.js +571 -0
  739. package/node_modules/undici/lib/interceptor/dump.js +99 -0
  740. package/node_modules/undici/lib/interceptor/redirect.js +21 -0
  741. package/node_modules/undici/lib/interceptor/response-error.js +95 -0
  742. package/node_modules/undici/lib/interceptor/retry.js +19 -0
  743. package/node_modules/undici/lib/llhttp/.gitkeep +0 -0
  744. package/node_modules/undici/lib/llhttp/constants.d.ts +195 -0
  745. package/node_modules/undici/lib/llhttp/constants.js +531 -0
  746. package/node_modules/undici/lib/llhttp/llhttp-wasm.js +15 -0
  747. package/node_modules/undici/lib/llhttp/llhttp_simd-wasm.js +15 -0
  748. package/node_modules/undici/lib/llhttp/utils.d.ts +2 -0
  749. package/node_modules/undici/lib/llhttp/utils.js +12 -0
  750. package/node_modules/undici/lib/mock/mock-agent.js +232 -0
  751. package/node_modules/undici/lib/mock/mock-call-history.js +248 -0
  752. package/node_modules/undici/lib/mock/mock-client.js +68 -0
  753. package/node_modules/undici/lib/mock/mock-errors.js +29 -0
  754. package/node_modules/undici/lib/mock/mock-interceptor.js +209 -0
  755. package/node_modules/undici/lib/mock/mock-pool.js +68 -0
  756. package/node_modules/undici/lib/mock/mock-symbols.js +32 -0
  757. package/node_modules/undici/lib/mock/mock-utils.js +486 -0
  758. package/node_modules/undici/lib/mock/pending-interceptors-formatter.js +43 -0
  759. package/node_modules/undici/lib/mock/snapshot-agent.js +353 -0
  760. package/node_modules/undici/lib/mock/snapshot-recorder.js +588 -0
  761. package/node_modules/undici/lib/mock/snapshot-utils.js +158 -0
  762. package/node_modules/undici/lib/util/cache.js +676 -0
  763. package/node_modules/undici/lib/util/date.js +670 -0
  764. package/node_modules/undici/lib/util/promise.js +28 -0
  765. package/node_modules/undici/lib/util/runtime-features.js +124 -0
  766. package/node_modules/undici/lib/util/stats.js +32 -0
  767. package/node_modules/undici/lib/util/timers.js +425 -0
  768. package/node_modules/undici/lib/web/cache/cache.js +864 -0
  769. package/node_modules/undici/lib/web/cache/cachestorage.js +152 -0
  770. package/node_modules/undici/lib/web/cache/util.js +45 -0
  771. package/node_modules/undici/lib/web/cookies/constants.js +12 -0
  772. package/node_modules/undici/lib/web/cookies/index.js +199 -0
  773. package/node_modules/undici/lib/web/cookies/parse.js +314 -0
  774. package/node_modules/undici/lib/web/cookies/util.js +352 -0
  775. package/node_modules/undici/lib/web/eventsource/eventsource-stream.js +494 -0
  776. package/node_modules/undici/lib/web/eventsource/eventsource.js +501 -0
  777. package/node_modules/undici/lib/web/eventsource/util.js +29 -0
  778. package/node_modules/undici/lib/web/fetch/LICENSE +21 -0
  779. package/node_modules/undici/lib/web/fetch/body.js +509 -0
  780. package/node_modules/undici/lib/web/fetch/constants.js +131 -0
  781. package/node_modules/undici/lib/web/fetch/data-url.js +596 -0
  782. package/node_modules/undici/lib/web/fetch/formdata-parser.js +586 -0
  783. package/node_modules/undici/lib/web/fetch/formdata.js +259 -0
  784. package/node_modules/undici/lib/web/fetch/global.js +40 -0
  785. package/node_modules/undici/lib/web/fetch/headers.js +719 -0
  786. package/node_modules/undici/lib/web/fetch/index.js +2413 -0
  787. package/node_modules/undici/lib/web/fetch/request.js +1115 -0
  788. package/node_modules/undici/lib/web/fetch/response.js +641 -0
  789. package/node_modules/undici/lib/web/fetch/util.js +1522 -0
  790. package/node_modules/undici/lib/web/infra/index.js +229 -0
  791. package/node_modules/undici/lib/web/subresource-integrity/Readme.md +9 -0
  792. package/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +307 -0
  793. package/node_modules/undici/lib/web/webidl/index.js +1006 -0
  794. package/node_modules/undici/lib/web/websocket/connection.js +339 -0
  795. package/node_modules/undici/lib/web/websocket/constants.js +126 -0
  796. package/node_modules/undici/lib/web/websocket/events.js +331 -0
  797. package/node_modules/undici/lib/web/websocket/frame.js +133 -0
  798. package/node_modules/undici/lib/web/websocket/permessage-deflate.js +105 -0
  799. package/node_modules/undici/lib/web/websocket/receiver.js +507 -0
  800. package/node_modules/undici/lib/web/websocket/sender.js +109 -0
  801. package/node_modules/undici/lib/web/websocket/stream/websocketerror.js +104 -0
  802. package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +496 -0
  803. package/node_modules/undici/lib/web/websocket/util.js +347 -0
  804. package/node_modules/undici/lib/web/websocket/websocket.js +758 -0
  805. package/node_modules/undici/package.json +152 -0
  806. package/node_modules/undici/scripts/strip-comments.js +10 -0
  807. package/node_modules/undici/types/README.md +6 -0
  808. package/node_modules/undici/types/agent.d.ts +32 -0
  809. package/node_modules/undici/types/api.d.ts +43 -0
  810. package/node_modules/undici/types/balanced-pool.d.ts +30 -0
  811. package/node_modules/undici/types/cache-interceptor.d.ts +179 -0
  812. package/node_modules/undici/types/cache.d.ts +36 -0
  813. package/node_modules/undici/types/client-stats.d.ts +15 -0
  814. package/node_modules/undici/types/client.d.ts +139 -0
  815. package/node_modules/undici/types/connector.d.ts +36 -0
  816. package/node_modules/undici/types/content-type.d.ts +21 -0
  817. package/node_modules/undici/types/cookies.d.ts +30 -0
  818. package/node_modules/undici/types/diagnostics-channel.d.ts +74 -0
  819. package/node_modules/undici/types/dispatcher.d.ts +275 -0
  820. package/node_modules/undici/types/env-http-proxy-agent.d.ts +22 -0
  821. package/node_modules/undici/types/errors.d.ts +177 -0
  822. package/node_modules/undici/types/eventsource.d.ts +66 -0
  823. package/node_modules/undici/types/fetch.d.ts +231 -0
  824. package/node_modules/undici/types/formdata.d.ts +114 -0
  825. package/node_modules/undici/types/global-dispatcher.d.ts +9 -0
  826. package/node_modules/undici/types/global-origin.d.ts +7 -0
  827. package/node_modules/undici/types/h2c-client.d.ts +73 -0
  828. package/node_modules/undici/types/handlers.d.ts +14 -0
  829. package/node_modules/undici/types/header.d.ts +160 -0
  830. package/node_modules/undici/types/index.d.ts +91 -0
  831. package/node_modules/undici/types/interceptors.d.ts +82 -0
  832. package/node_modules/undici/types/mock-agent.d.ts +68 -0
  833. package/node_modules/undici/types/mock-call-history.d.ts +111 -0
  834. package/node_modules/undici/types/mock-client.d.ts +27 -0
  835. package/node_modules/undici/types/mock-errors.d.ts +12 -0
  836. package/node_modules/undici/types/mock-interceptor.d.ts +94 -0
  837. package/node_modules/undici/types/mock-pool.d.ts +27 -0
  838. package/node_modules/undici/types/patch.d.ts +29 -0
  839. package/node_modules/undici/types/pool-stats.d.ts +19 -0
  840. package/node_modules/undici/types/pool.d.ts +41 -0
  841. package/node_modules/undici/types/proxy-agent.d.ts +29 -0
  842. package/node_modules/undici/types/readable.d.ts +68 -0
  843. package/node_modules/undici/types/retry-agent.d.ts +8 -0
  844. package/node_modules/undici/types/retry-handler.d.ts +125 -0
  845. package/node_modules/undici/types/round-robin-pool.d.ts +41 -0
  846. package/node_modules/undici/types/snapshot-agent.d.ts +109 -0
  847. package/node_modules/undici/types/socks5-proxy-agent.d.ts +25 -0
  848. package/node_modules/undici/types/util.d.ts +18 -0
  849. package/node_modules/undici/types/utility.d.ts +7 -0
  850. package/node_modules/undici/types/webidl.d.ts +347 -0
  851. package/node_modules/undici/types/websocket.d.ts +188 -0
  852. package/package.json +5 -3
  853. package/profiles/README.md +20 -0
  854. package/profiles/index.json +2 -1
  855. package/profiles/sales/0.1.profile.json +252 -0
  856. package/server.js +99 -0
@@ -4,9 +4,9 @@ import {
4
4
  } from "./chunk-3BNWN6VP.mjs";
5
5
 
6
6
  // src/index.ts
7
- import { randomBytes as randomBytes2 } from "crypto";
8
- import { existsSync as existsSync7, readFileSync as readFileSync8, renameSync as renameSync2 } from "fs";
9
- import { dirname as dirname6, join as join9 } from "path";
7
+ import { randomBytes as randomBytes3 } from "crypto";
8
+ import { existsSync as existsSync9, readFileSync as readFileSync11, renameSync as renameSync2 } from "fs";
9
+ import { dirname as dirname8, join as join11 } from "path";
10
10
  import { homedir as homedir7 } from "os";
11
11
  import express from "express";
12
12
  import { createProxyMiddleware } from "http-proxy-middleware";
@@ -110,6 +110,31 @@ var Vault = class {
110
110
  this.clearKey();
111
111
  this.lockedReason = "expired";
112
112
  }
113
+ /** Lock because the live Authority Server key no longer matches the one
114
+ * pinned at pairing — see as-pairing.ts / gatekeeper.ts. Mirrors
115
+ * lockExpired() exactly; the only difference callers care about is WHY. */
116
+ lockAsKeyMismatch() {
117
+ this.clearKey();
118
+ this.lockedReason = "as-key-mismatch";
119
+ }
120
+ /** Lock because a pin-tls-enforced connection to the Authority Server
121
+ * presented a certificate whose public key doesn't match the one pinned
122
+ * at pairing — see as-tls-pin.ts. Mirrors lockAsKeyMismatch() exactly. */
123
+ lockAsTlsMismatch() {
124
+ this.clearKey();
125
+ this.lockedReason = "as-tls-mismatch";
126
+ }
127
+ /**
128
+ * Boot-time only: record that the gateway starts locked because the
129
+ * resolved Authority Server URL differs from the one it was last paired
130
+ * with. Deliberately does NOT call clearKey() — the vault always boots
131
+ * locked already (nothing has been unlocked yet in this process), so there
132
+ * is no session to end; this only attaches the reason so /health and the
133
+ * locked-agent notice can explain it instead of defaulting to "restart".
134
+ */
135
+ markBootLockedAsUrlChanged() {
136
+ this.lockedReason = "as-url-changed";
137
+ }
113
138
  /** What locked the vault, if known. `null` covers both "still unlocked"
114
139
  * and the default boot-locked case — callers that care about the
115
140
  * difference should check `isUnlocked()` first. */
@@ -300,10 +325,11 @@ async function configure(sessionCookie, vaultKeyHex) {
300
325
  clearTimeout(timeout);
301
326
  }
302
327
  }
303
- async function unconfigureSession() {
328
+ async function unconfigureSession(reason) {
304
329
  const res = await fetch(`${MCP_BASE}/internal/clear-session`, {
305
330
  method: "POST",
306
- headers: internalHeaders()
331
+ headers: internalHeaders(),
332
+ body: JSON.stringify({ reason })
307
333
  });
308
334
  if (!res.ok) {
309
335
  throw new Error(`MCP clear-session failed: ${res.status}`);
@@ -465,6 +491,13 @@ async function getEnrichedAuthorizations() {
465
491
  if (!res.ok) throw new Error("Failed to fetch authorizations");
466
492
  return res.json();
467
493
  }
494
+ async function getSkippedCommitments() {
495
+ const res = await fetch(`${MCP_BASE}/internal/skipped-commitments`, {
496
+ headers: internalHeaders()
497
+ });
498
+ if (!res.ok) throw new Error("Failed to fetch skipped commitments");
499
+ return res.json();
500
+ }
468
501
  async function getLocalEvidence() {
469
502
  const res = await fetch(`${MCP_BASE}/internal/evidence`, {
470
503
  headers: internalHeaders()
@@ -634,10 +667,510 @@ function clientVersionHeaders() {
634
667
  };
635
668
  }
636
669
 
670
+ // src/lib/as-pairing.ts
671
+ import { createHash as createHash2 } from "crypto";
672
+ import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync3, unlinkSync, writeFileSync as writeFileSync2 } from "fs";
673
+ import { dirname as dirname2, join as join3 } from "path";
674
+ function pairingPath(dataDir) {
675
+ return join3(dataDir, "as-pairing.json");
676
+ }
677
+ function readPairing(dataDir) {
678
+ const path = pairingPath(dataDir);
679
+ if (!existsSync2(path)) return null;
680
+ try {
681
+ const data = JSON.parse(readFileSync3(path, "utf-8"));
682
+ if (typeof data.asUrl !== "string" || typeof data.publicKeyHex !== "string") return null;
683
+ return {
684
+ asUrl: data.asUrl,
685
+ publicKeyHex: data.publicKeyHex,
686
+ pairedAt: data.pairedAt ?? "",
687
+ ...typeof data.tlsSpkiPinHex === "string" ? { tlsSpkiPinHex: data.tlsSpkiPinHex } : {}
688
+ };
689
+ } catch {
690
+ return null;
691
+ }
692
+ }
693
+ function writePairing(dataDir, asUrl, publicKeyHex, opts = {}) {
694
+ const pairing = {
695
+ asUrl,
696
+ publicKeyHex,
697
+ pairedAt: (/* @__PURE__ */ new Date()).toISOString(),
698
+ ...opts.tlsSpkiPinHex ? { tlsSpkiPinHex: opts.tlsSpkiPinHex } : {}
699
+ };
700
+ const path = pairingPath(dataDir);
701
+ mkdirSync2(dirname2(path), { recursive: true, mode: 448 });
702
+ writeFileSync2(path, JSON.stringify(pairing, null, 2), { encoding: "utf-8", mode: 384 });
703
+ return pairing;
704
+ }
705
+ function recordTlsPin(dataDir, asUrl, tlsSpkiPinHex) {
706
+ const existing = readPairing(dataDir);
707
+ if (!existing || existing.asUrl !== asUrl) return;
708
+ const path = pairingPath(dataDir);
709
+ writeFileSync2(
710
+ path,
711
+ JSON.stringify({ ...existing, tlsSpkiPinHex }, null, 2),
712
+ { encoding: "utf-8", mode: 384 }
713
+ );
714
+ }
715
+ function clearPairing(dataDir) {
716
+ const path = pairingPath(dataDir);
717
+ try {
718
+ if (existsSync2(path)) unlinkSync(path);
719
+ } catch {
720
+ }
721
+ }
722
+ function fingerprintOf(publicKeyHex) {
723
+ const raw = Buffer.from(publicKeyHex, "hex");
724
+ const digest = createHash2("sha256").update(raw).digest("hex").toUpperCase();
725
+ return digest.match(/.{1,4}/g)?.join(":") ?? digest;
726
+ }
727
+
728
+ // src/lib/as-challenge.ts
729
+ import { createPublicKey, randomBytes as randomBytes2, verify as cryptoVerify } from "crypto";
730
+ import { canonicalize } from "@hap/core";
731
+
732
+ // src/lib/as-tls-pin.ts
733
+ import { createHash as createHash3 } from "crypto";
734
+ import { checkServerIdentity as defaultCheckServerIdentity, rootCertificates } from "tls";
735
+ import { Agent as HttpsAgent } from "https";
736
+ import { readFileSync as readFileSync4 } from "fs";
737
+ import { Agent, fetch as undiciFetch } from "undici";
738
+ function effectiveCa() {
739
+ const path = process.env.NODE_EXTRA_CA_CERTS;
740
+ if (!path) return void 0;
741
+ try {
742
+ return [...rootCertificates, readFileSync4(path, "utf-8")];
743
+ } catch {
744
+ return void 0;
745
+ }
746
+ }
747
+ var PIN_CHECK_ERROR_CODE = "EAS_TLS_PIN_CHECK";
748
+ function taggedCheckError(err) {
749
+ err.code = PIN_CHECK_ERROR_CODE;
750
+ return err;
751
+ }
752
+ function isPinCheckError(err) {
753
+ let cur = err;
754
+ for (let i = 0; i < 5 && cur; i++) {
755
+ if (cur instanceof Error && cur.code === PIN_CHECK_ERROR_CODE) return true;
756
+ cur = cur instanceof Error ? cur.cause : void 0;
757
+ }
758
+ return false;
759
+ }
760
+ var AsTlsMismatchError = class extends Error {
761
+ constructor(message) {
762
+ super(message);
763
+ this.name = "AsTlsMismatchError";
764
+ }
765
+ };
766
+ function spkiSha256Hex(cert) {
767
+ if (!cert.pubkey) {
768
+ throw new Error("peer certificate carries no pubkey (expected the detailed certificate object)");
769
+ }
770
+ return createHash3("sha256").update(cert.pubkey).digest("hex");
771
+ }
772
+ function formatPinFingerprint(hex) {
773
+ const upper = hex.toUpperCase();
774
+ return upper.match(/.{1,4}/g)?.join(":") ?? upper;
775
+ }
776
+ function pinnedCheckServerIdentity(pinnedSpkiHex) {
777
+ const wantHex = pinnedSpkiHex.toLowerCase();
778
+ return (hostname, cert) => {
779
+ const defaultErr = defaultCheckServerIdentity(hostname, cert);
780
+ if (defaultErr) return taggedCheckError(defaultErr);
781
+ let actualHex;
782
+ try {
783
+ actualHex = spkiSha256Hex(cert);
784
+ } catch (err) {
785
+ return taggedCheckError(new Error(
786
+ `could not read the server certificate's public key to check the TLS pin \u2014 ${err instanceof Error ? err.message : String(err)}`
787
+ ));
788
+ }
789
+ if (actualHex !== wantHex) {
790
+ return taggedCheckError(new Error(
791
+ `TLS certificate pin mismatch for ${hostname}: expected SPKI sha256 ${formatPinFingerprint(wantHex)}, got ${formatPinFingerprint(actualHex)}.`
792
+ ));
793
+ }
794
+ return void 0;
795
+ };
796
+ }
797
+ function buildPinnedDispatcher(pinnedSpkiHex) {
798
+ return new Agent({
799
+ connect: {
800
+ ca: effectiveCa(),
801
+ checkServerIdentity: pinnedCheckServerIdentity(pinnedSpkiHex)
802
+ }
803
+ });
804
+ }
805
+ function buildCapturingDispatcher() {
806
+ let captured;
807
+ const dispatcher = new Agent({
808
+ connect: {
809
+ ca: effectiveCa(),
810
+ checkServerIdentity: (hostname, cert) => {
811
+ captured = cert;
812
+ const defaultErr = defaultCheckServerIdentity(hostname, cert);
813
+ return defaultErr ? taggedCheckError(defaultErr) : void 0;
814
+ }
815
+ }
816
+ });
817
+ return { dispatcher, getCapturedCert: () => captured };
818
+ }
819
+ function buildPinnedHttpsAgent(getPinning) {
820
+ return new HttpsAgent({
821
+ checkServerIdentity: (hostname, cert) => {
822
+ const pinning = getPinning();
823
+ if (!pinning.enforce) return defaultCheckServerIdentity(hostname, cert);
824
+ if (!pinning.pinnedSpkiHex) {
825
+ return taggedCheckError(new Error(
826
+ `pin-tls is on but no certificate is pinned yet for ${hostname} \u2014 sign in again to establish it (re-pairing required).`
827
+ ));
828
+ }
829
+ return pinnedCheckServerIdentity(pinning.pinnedSpkiHex)(hostname, cert);
830
+ },
831
+ ca: effectiveCa()
832
+ });
833
+ }
834
+ async function fetchAs(url, init, pinning) {
835
+ if (!pinning.enforce && !pinning.capture) {
836
+ const res2 = await fetch(url, init);
837
+ return { res: res2 };
838
+ }
839
+ if (pinning.enforce && !pinning.capture && !pinning.pinnedSpkiHex) {
840
+ throw new AsTlsMismatchError(
841
+ `pin-tls is on but no certificate is pinned yet for ${url} \u2014 sign in again to establish it (re-pairing required).`
842
+ );
843
+ }
844
+ if (pinning.pinnedSpkiHex && (pinning.enforce || !pinning.capture)) {
845
+ const dispatcher2 = buildPinnedDispatcher(pinning.pinnedSpkiHex);
846
+ try {
847
+ const res2 = await undiciFetch(url, { ...init, dispatcher: dispatcher2 });
848
+ return { res: res2 };
849
+ } catch (err) {
850
+ if (!isPinCheckError(err)) throw err;
851
+ throw new AsTlsMismatchError(
852
+ `TLS pin check failed for ${url} \u2014 ${describeFetchError(err)}. Refusing the connection; the API key / session cookie were never sent. If the Authority Server's certificate changed intentionally (a new key, not just renewal), an operator must clear the pairing and sign in again to re-pin it.`
853
+ );
854
+ }
855
+ }
856
+ const { dispatcher, getCapturedCert } = buildCapturingDispatcher();
857
+ let res;
858
+ try {
859
+ res = await undiciFetch(url, { ...init, dispatcher });
860
+ } catch (err) {
861
+ if (!isPinCheckError(err)) throw err;
862
+ throw new AsTlsMismatchError(
863
+ `could not verify the Authority Server at ${url} while establishing its TLS pin \u2014 ${describeFetchError(err)}.`
864
+ );
865
+ }
866
+ const cert = getCapturedCert();
867
+ return { res, capturedSpkiHex: cert ? spkiSha256Hex(cert) : void 0 };
868
+ }
869
+ function describeFetchError(err) {
870
+ if (err instanceof Error) {
871
+ const cause = err.cause;
872
+ if (cause instanceof Error) return cause.message;
873
+ return err.message;
874
+ }
875
+ return String(err);
876
+ }
877
+
878
+ // src/lib/as-challenge.ts
879
+ var AsChallengeUnreachableError = class extends Error {
880
+ constructor(message) {
881
+ super(message);
882
+ this.name = "AsChallengeUnreachableError";
883
+ }
884
+ };
885
+ var AsChallengeInvalidError = class extends Error {
886
+ constructor(message) {
887
+ super(message);
888
+ this.name = "AsChallengeInvalidError";
889
+ }
890
+ };
891
+ var CHALLENGE_MAX_SKEW_SECONDS = 300;
892
+ var CHALLENGE_TYPE = "hap-as-challenge";
893
+ var CHALLENGE_DOMAIN_PREFIX = "hap-as-challenge\0";
894
+ function challengeSigningBytes(unsigned) {
895
+ return Buffer.concat([
896
+ Buffer.from(CHALLENGE_DOMAIN_PREFIX, "utf-8"),
897
+ Buffer.from(canonicalize({ typ: unsigned.typ, nonce: unsigned.nonce, issuedAt: unsigned.issuedAt }), "utf-8")
898
+ ]);
899
+ }
900
+ function publicKeyFromHex(publicKeyHex) {
901
+ const raw = Buffer.from(publicKeyHex, "hex");
902
+ return createPublicKey({ key: { kty: "OKP", crv: "Ed25519", x: raw.toString("base64url") }, format: "jwk" });
903
+ }
904
+ function verifyChallengeSignature(publicKeyHex, unsigned, signature) {
905
+ try {
906
+ const base64 = signature.replace(/-/g, "+").replace(/_/g, "/");
907
+ const padding = base64.length % 4 === 0 ? "" : "=".repeat(4 - base64.length % 4);
908
+ const sigBytes = Buffer.from(base64 + padding, "base64");
909
+ const key = publicKeyFromHex(publicKeyHex);
910
+ return cryptoVerify(null, challengeSigningBytes(unsigned), key, sigBytes);
911
+ } catch {
912
+ return false;
913
+ }
914
+ }
915
+ async function verifyAsHoldsKey(asUrl, publicKeyHex, pinning = { enforce: false, capture: true }) {
916
+ const nonce = randomBytes2(32).toString("base64url");
917
+ let res;
918
+ let capturedSpkiHex;
919
+ try {
920
+ const result = await fetchAs(
921
+ `${asUrl}/api/as/challenge`,
922
+ {
923
+ method: "POST",
924
+ headers: { "Content-Type": "application/json" },
925
+ body: JSON.stringify({ nonce }),
926
+ signal: AbortSignal.timeout(5e3)
927
+ },
928
+ pinning
929
+ );
930
+ res = result.res;
931
+ capturedSpkiHex = result.capturedSpkiHex;
932
+ } catch (err) {
933
+ if (err instanceof AsTlsMismatchError) throw err;
934
+ throw new AsChallengeUnreachableError(
935
+ `could not reach the Authority Server at ${asUrl} to verify it holds its signing key \u2014 ${err instanceof Error ? err.message : String(err)}`
936
+ );
937
+ }
938
+ if (!res.ok) {
939
+ throw new AsChallengeUnreachableError(
940
+ `the Authority Server at ${asUrl} answered its signing-key challenge with HTTP ${res.status}`
941
+ );
942
+ }
943
+ const body = await res.json().catch(() => null);
944
+ if (!body) {
945
+ throw new AsChallengeUnreachableError(
946
+ `the Authority Server at ${asUrl} returned a malformed response to its signing-key challenge`
947
+ );
948
+ }
949
+ if (body.typ !== CHALLENGE_TYPE) {
950
+ throw new AsChallengeInvalidError(
951
+ `the challenge response carries the wrong type ("${String(body.typ)}", expected "${CHALLENGE_TYPE}")`
952
+ );
953
+ }
954
+ if (body.nonce !== nonce) {
955
+ throw new AsChallengeInvalidError(
956
+ "the challenge response echoes a different nonce than the one sent"
957
+ );
958
+ }
959
+ if (typeof body.issuedAt !== "number" || !Number.isFinite(body.issuedAt)) {
960
+ throw new AsChallengeInvalidError("the challenge response carries no valid issuedAt");
961
+ }
962
+ const skew = Math.abs(Math.floor(Date.now() / 1e3) - body.issuedAt);
963
+ if (skew > CHALLENGE_MAX_SKEW_SECONDS) {
964
+ throw new AsChallengeInvalidError(
965
+ `the challenge response is timestamped ${skew}s away from now, beyond the ${CHALLENGE_MAX_SKEW_SECONDS}s tolerance`
966
+ );
967
+ }
968
+ if (typeof body.signature !== "string" || !body.signature) {
969
+ throw new AsChallengeInvalidError("the challenge response carries no signature");
970
+ }
971
+ if (!verifyChallengeSignature(publicKeyHex, { typ: body.typ, nonce: body.nonce, issuedAt: body.issuedAt }, body.signature)) {
972
+ throw new AsChallengeInvalidError(
973
+ "the challenge signature does not verify under the key being checked \u2014 this is exactly what the challenge exists to catch: something answered the request but does not hold the matching private key."
974
+ );
975
+ }
976
+ return { capturedTlsSpkiHex: capturedSpkiHex };
977
+ }
978
+
979
+ // src/lib/as-config.ts
980
+ import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync5, writeFileSync as writeFileSync3 } from "fs";
981
+ import { dirname as dirname3, join as join4 } from "path";
982
+ var DEFAULT_AS_URL = "https://www.suveren.ai";
983
+ function configPath(dataDir) {
984
+ return join4(dataDir, "config.json");
985
+ }
986
+ function readAsConfigStrict(dataDir) {
987
+ const path = configPath(dataDir);
988
+ if (!existsSync3(path)) return {};
989
+ let data;
990
+ try {
991
+ data = JSON.parse(readFileSync5(path, "utf-8"));
992
+ } catch (err) {
993
+ throw new Error(
994
+ `Could not parse ${path}: ${err instanceof Error ? err.message : String(err)}`
995
+ );
996
+ }
997
+ const out = {};
998
+ if (typeof data.asUrl === "string") out.asUrl = data.asUrl;
999
+ if (typeof data.caFile === "string") out.caFile = data.caFile;
1000
+ if (typeof data.pinTls === "boolean") out.pinTls = data.pinTls;
1001
+ if (typeof data.pinTlsExpectedFingerprint === "string") out.pinTlsExpectedFingerprint = data.pinTlsExpectedFingerprint;
1002
+ return out;
1003
+ }
1004
+ function readAsConfig(dataDir) {
1005
+ const path = configPath(dataDir);
1006
+ if (!existsSync3(path)) return {};
1007
+ try {
1008
+ const data = JSON.parse(readFileSync5(path, "utf-8"));
1009
+ const out = {};
1010
+ if (typeof data.asUrl === "string") out.asUrl = data.asUrl;
1011
+ if (typeof data.caFile === "string") out.caFile = data.caFile;
1012
+ if (typeof data.pinTls === "boolean") out.pinTls = data.pinTls;
1013
+ if (typeof data.pinTlsExpectedFingerprint === "string") out.pinTlsExpectedFingerprint = data.pinTlsExpectedFingerprint;
1014
+ return out;
1015
+ } catch {
1016
+ return {};
1017
+ }
1018
+ }
1019
+ function writeAsConfig(dataDir, patch) {
1020
+ const merged = { ...readAsConfig(dataDir), ...patch };
1021
+ const path = configPath(dataDir);
1022
+ mkdirSync3(dirname3(path), { recursive: true, mode: 448 });
1023
+ writeFileSync3(path, JSON.stringify(merged, null, 2), { encoding: "utf-8", mode: 384 });
1024
+ return merged;
1025
+ }
1026
+ function validateAsUrl(candidate) {
1027
+ const trimmed = candidate.trim();
1028
+ if (!trimmed) return { ok: false, error: "The Authority Server URL is empty." };
1029
+ let parsed;
1030
+ try {
1031
+ parsed = new URL(trimmed);
1032
+ } catch {
1033
+ return { ok: false, error: `"${trimmed}" is not a valid URL.` };
1034
+ }
1035
+ const isLocalHttp = parsed.protocol === "http:" && (parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1");
1036
+ if (parsed.protocol !== "https:" && !isLocalHttp) {
1037
+ return {
1038
+ ok: false,
1039
+ error: `"${trimmed}" must use https:// (http:// is only allowed for http://localhost or http://127.0.0.1).`
1040
+ };
1041
+ }
1042
+ let normalized = `${parsed.origin}${parsed.pathname}${parsed.search}${parsed.hash}`;
1043
+ if (normalized.endsWith("/") && normalized !== `${parsed.origin}/`) {
1044
+ normalized = normalized.slice(0, -1);
1045
+ } else if (normalized === `${parsed.origin}/`) {
1046
+ normalized = parsed.origin;
1047
+ }
1048
+ return { ok: true, url: normalized };
1049
+ }
1050
+ function resolveAsUrl(dataDir, flag) {
1051
+ if (flag) {
1052
+ const v = validateAsUrl(flag);
1053
+ if (!v.ok) throw new Error(`Invalid --as-url: ${v.error}`);
1054
+ return v.url;
1055
+ }
1056
+ const envUrl = process.env.SUVEREN_AS_URL;
1057
+ if (envUrl) {
1058
+ const v = validateAsUrl(envUrl);
1059
+ if (!v.ok) throw new Error(`Invalid SUVEREN_AS_URL: ${v.error}`);
1060
+ return v.url;
1061
+ }
1062
+ const saved = readAsConfigStrict(dataDir).asUrl;
1063
+ if (saved) {
1064
+ const v = validateAsUrl(saved);
1065
+ if (!v.ok) throw new Error(`Invalid saved as-url "${saved}" in ${dataDir}/config.json: ${v.error}`);
1066
+ return v.url;
1067
+ }
1068
+ return DEFAULT_AS_URL;
1069
+ }
1070
+ function resolvePinTls(dataDir) {
1071
+ return readAsConfig(dataDir).pinTls === true;
1072
+ }
1073
+ function validatePinTlsForUrl(pinTls, asUrl) {
1074
+ if (!pinTls) return;
1075
+ if (!asUrl.startsWith("https:")) {
1076
+ throw new Error(
1077
+ `config.json sets "pinTls": true, but the Authority Server URL (${asUrl}) is not https:// \u2014 there is no TLS certificate to pin. Fix the saved as-url, or turn pin-tls off: \`suveren-gateway config set pin-tls off\`.`
1078
+ );
1079
+ }
1080
+ }
1081
+ function resolvePinTlsExpectedFingerprint(dataDir) {
1082
+ return readAsConfig(dataDir).pinTlsExpectedFingerprint;
1083
+ }
1084
+ function clearPinTlsExpectedFingerprint(dataDir) {
1085
+ if (readAsConfig(dataDir).pinTlsExpectedFingerprint === void 0) return;
1086
+ writeAsConfig(dataDir, { pinTlsExpectedFingerprint: void 0 });
1087
+ }
1088
+
637
1089
  // src/routes/auth.ts
638
- var SP_URL = process.env.SUVEREN_AS_URL ?? "https://www.suveren.ai";
639
- function createAuthRouter(vault2, logoutAuth, loginRateLimit2, onSessionEstablished) {
1090
+ var DEFAULT_SP_URL = process.env.SUVEREN_AS_URL ?? "https://www.suveren.ai";
1091
+ async function fetchAsPublicKey(asUrl) {
1092
+ try {
1093
+ const res = await fetch(`${asUrl}/api/as/pubkey`, { signal: AbortSignal.timeout(5e3) });
1094
+ if (!res.ok) {
1095
+ return {
1096
+ ok: false,
1097
+ message: `Could not reach the Authority Server at ${asUrl} to read its signing key (HTTP ${res.status}). Refusing to sign in.`
1098
+ };
1099
+ }
1100
+ const body = await res.json().catch(() => null);
1101
+ if (!body || typeof body.publicKey !== "string" || !body.publicKey) {
1102
+ return {
1103
+ ok: false,
1104
+ message: `The Authority Server at ${asUrl} returned a malformed signing key. Refusing to sign in.`
1105
+ };
1106
+ }
1107
+ return { ok: true, publicKeyHex: body.publicKey };
1108
+ } catch (err) {
1109
+ return {
1110
+ ok: false,
1111
+ message: `Could not reach the Authority Server at ${asUrl} to read its signing key \u2014 ${err instanceof Error ? err.message : String(err)}. Refusing to sign in.`
1112
+ };
1113
+ }
1114
+ }
1115
+ async function checkAsKeyBeforeLogin(asUrl, dataDir) {
1116
+ const existing = readPairing(dataDir);
1117
+ const pinnedKey = existing && existing.asUrl === asUrl ? existing.publicKeyHex : void 0;
1118
+ const existingTlsPin = (existing && existing.asUrl === asUrl ? existing.tlsSpkiPinHex : void 0) ?? resolvePinTlsExpectedFingerprint(dataDir);
1119
+ let candidateKey;
1120
+ if (pinnedKey) {
1121
+ candidateKey = pinnedKey;
1122
+ } else {
1123
+ const fetched = await fetchAsPublicKey(asUrl);
1124
+ if (!fetched.ok) {
1125
+ return { ok: false, error: "as_unreachable", message: fetched.message };
1126
+ }
1127
+ candidateKey = fetched.publicKeyHex;
1128
+ }
1129
+ const pinning = {
1130
+ enforce: resolvePinTls(dataDir),
1131
+ pinnedSpkiHex: existingTlsPin,
1132
+ capture: true
1133
+ };
1134
+ let capturedTlsSpkiHex;
1135
+ try {
1136
+ const result = await verifyAsHoldsKey(asUrl, candidateKey, pinning);
1137
+ capturedTlsSpkiHex = result.capturedTlsSpkiHex;
1138
+ } catch (err) {
1139
+ if (err instanceof AsTlsMismatchError) {
1140
+ return { ok: false, error: "as_tls_mismatch", message: err.message };
1141
+ }
1142
+ if (err instanceof AsChallengeUnreachableError) {
1143
+ return { ok: false, error: "as_unverified", message: `${err.message}. Refusing to sign in.` };
1144
+ }
1145
+ if (err instanceof AsChallengeInvalidError) {
1146
+ if (pinnedKey) {
1147
+ return {
1148
+ ok: false,
1149
+ error: "as_key_mismatch",
1150
+ message: `The Authority Server at ${asUrl} does not match the one pinned when this gateway last signed in (pinned fingerprint ${fingerprintOf(pinnedKey)}) \u2014 its signing-key challenge did not verify (${err.message}). Refusing to sign in. If the AS's key changed intentionally, an operator must clear the old pairing before signing in again.`
1151
+ };
1152
+ }
1153
+ return {
1154
+ ok: false,
1155
+ error: "as_unverified",
1156
+ message: `The Authority Server at ${asUrl} could not prove it holds the signing key it presented \u2014 ${err.message}. Refusing to sign in.`
1157
+ };
1158
+ }
1159
+ throw err;
1160
+ }
1161
+ return {
1162
+ ok: true,
1163
+ publicKeyHex: candidateKey,
1164
+ // A fresh capture (always present for https, unless pin-tls is on and
1165
+ // an existing pin was enforced instead — see fetchAs) wins; otherwise
1166
+ // whatever was already on file carries through unchanged.
1167
+ tlsSpkiPinHex: capturedTlsSpkiHex ?? existingTlsPin
1168
+ };
1169
+ }
1170
+ function createAuthRouter(vault2, logoutAuth, loginRateLimit2, onSessionEstablished, pairing, lockAsTlsMismatch2 = () => {
1171
+ }) {
640
1172
  const router = Router();
1173
+ const SP_URL2 = pairing?.asUrl ?? DEFAULT_SP_URL;
641
1174
  router.post("/login", loginRateLimit2, async (req, res) => {
642
1175
  const apiKey = req.headers["x-api-key"] || req.body?.apiKey;
643
1176
  const confirmWipe = req.body?.confirmWipe === true;
@@ -646,22 +1179,65 @@ function createAuthRouter(vault2, logoutAuth, loginRateLimit2, onSessionEstablis
646
1179
  return;
647
1180
  }
648
1181
  try {
649
- const spRes = await fetch(`${SP_URL}/api/auth/session`, {
650
- method: "POST",
651
- headers: {
652
- "Content-Type": "application/json",
653
- "X-API-Key": apiKey,
654
- // The AS grants a 30-day gateway session ONLY to a login that
655
- // identifies itself this way; without it, a 24-hour browser
656
- // session (see doc at the top of this file).
657
- ...clientVersionHeaders()
1182
+ let keyCheck = null;
1183
+ if (pairing) {
1184
+ keyCheck = await checkAsKeyBeforeLogin(pairing.asUrl, pairing.dataDir);
1185
+ if (!keyCheck.ok) {
1186
+ const status = keyCheck.error === "as_key_mismatch" || keyCheck.error === "as_tls_mismatch" ? 409 : 502;
1187
+ res.status(status).json({
1188
+ error: keyCheck.error,
1189
+ message: keyCheck.message
1190
+ });
1191
+ return;
658
1192
  }
659
- });
1193
+ }
1194
+ const sessionPinning = {
1195
+ enforce: Boolean(pairing && resolvePinTls(pairing.dataDir)),
1196
+ pinnedSpkiHex: keyCheck?.tlsSpkiPinHex
1197
+ };
1198
+ let spRes;
1199
+ try {
1200
+ const result = await fetchAs(
1201
+ `${SP_URL2}/api/auth/session`,
1202
+ {
1203
+ method: "POST",
1204
+ headers: {
1205
+ "Content-Type": "application/json",
1206
+ "X-API-Key": apiKey,
1207
+ // The AS grants a 30-day gateway session ONLY to a login that
1208
+ // identifies itself this way; without it, a 24-hour browser
1209
+ // session (see doc at the top of this file).
1210
+ ...clientVersionHeaders()
1211
+ }
1212
+ },
1213
+ sessionPinning
1214
+ );
1215
+ spRes = result.res;
1216
+ } catch (err) {
1217
+ if (err instanceof AsTlsMismatchError) {
1218
+ res.status(409).json({ error: "as_tls_mismatch", message: err.message });
1219
+ return;
1220
+ }
1221
+ throw err;
1222
+ }
660
1223
  if (!spRes.ok) {
661
1224
  const err = await spRes.json().catch(() => ({ error: "Invalid API key" }));
662
1225
  res.status(spRes.status).json(err);
663
1226
  return;
664
1227
  }
1228
+ if (pairing && keyCheck?.publicKeyHex) {
1229
+ const existing = readPairing(pairing.dataDir);
1230
+ if (!existing || existing.asUrl !== pairing.asUrl) {
1231
+ writePairing(pairing.dataDir, pairing.asUrl, keyCheck.publicKeyHex, {
1232
+ tlsSpkiPinHex: keyCheck.tlsSpkiPinHex
1233
+ });
1234
+ console.error(`[Control Plane] Paired with Authority Server ${pairing.asUrl} (fingerprint ${fingerprintOf(keyCheck.publicKeyHex)})`);
1235
+ } else if (keyCheck.tlsSpkiPinHex && keyCheck.tlsSpkiPinHex !== existing.tlsSpkiPinHex) {
1236
+ recordTlsPin(pairing.dataDir, pairing.asUrl, keyCheck.tlsSpkiPinHex);
1237
+ console.error(`[Control Plane] TLS pin for Authority Server ${pairing.asUrl} captured/updated.`);
1238
+ }
1239
+ clearPinTlsExpectedFingerprint(pairing.dataDir);
1240
+ }
665
1241
  const data = await spRes.json();
666
1242
  const setCookieHeaders = spRes.headers.getSetCookie?.() ?? [];
667
1243
  const sessionCookie = setCookieHeaders.join("; ");
@@ -708,10 +1284,11 @@ function createAuthRouter(vault2, logoutAuth, loginRateLimit2, onSessionEstablis
708
1284
  const kp = await loadOrGenerateKeyPair(vault2);
709
1285
  const localPubkeyB64 = Buffer.from(kp.publicKey).toString("base64");
710
1286
  const spCookie = vault2.getSpCookie();
711
- const meKeyRes = await fetch(`${SP_URL}/api/users/me/pubkey`, {
712
- headers: spCookie ? { Cookie: spCookie } : {},
713
- signal: AbortSignal.timeout(5e3)
714
- });
1287
+ const { res: meKeyRes } = await fetchAs(
1288
+ `${SP_URL2}/api/users/me/pubkey`,
1289
+ { headers: spCookie ? { Cookie: spCookie } : {}, signal: AbortSignal.timeout(5e3) },
1290
+ sessionPinning
1291
+ );
715
1292
  let needsUpdate = false;
716
1293
  if (meKeyRes.status === 404) {
717
1294
  needsUpdate = true;
@@ -720,15 +1297,19 @@ function createAuthRouter(vault2, logoutAuth, loginRateLimit2, onSessionEstablis
720
1297
  needsUpdate = meKeyData.pubkey !== localPubkeyB64;
721
1298
  }
722
1299
  if (needsUpdate) {
723
- const putRes = await fetch(`${SP_URL}/api/users/me/pubkey`, {
724
- method: "PUT",
725
- headers: {
726
- "Content-Type": "application/json",
727
- ...spCookie ? { Cookie: spCookie } : {}
1300
+ const { res: putRes } = await fetchAs(
1301
+ `${SP_URL2}/api/users/me/pubkey`,
1302
+ {
1303
+ method: "PUT",
1304
+ headers: {
1305
+ "Content-Type": "application/json",
1306
+ ...spCookie ? { Cookie: spCookie } : {}
1307
+ },
1308
+ body: JSON.stringify({ pubkey: localPubkeyB64 }),
1309
+ signal: AbortSignal.timeout(5e3)
728
1310
  },
729
- body: JSON.stringify({ pubkey: localPubkeyB64 }),
730
- signal: AbortSignal.timeout(5e3)
731
- });
1311
+ sessionPinning
1312
+ );
732
1313
  if (!putRes.ok) {
733
1314
  console.error(`[Control Plane] E2EE pubkey registration failed: ${putRes.status}`);
734
1315
  } else {
@@ -738,7 +1319,12 @@ function createAuthRouter(vault2, logoutAuth, loginRateLimit2, onSessionEstablis
738
1319
  console.error("[Control Plane] E2EE pubkey already up to date");
739
1320
  }
740
1321
  } catch (err) {
741
- console.error("[Control Plane] E2EE pubkey auto-register failed:", err);
1322
+ if (err instanceof AsTlsMismatchError) {
1323
+ console.error("[Control Plane] E2EE pubkey auto-register aborted \u2014 TLS pin mismatch:", err.message);
1324
+ lockAsTlsMismatch2();
1325
+ } else {
1326
+ console.error("[Control Plane] E2EE pubkey auto-register failed:", err);
1327
+ }
742
1328
  }
743
1329
  for (const credId of vault2.listCredentials()) {
744
1330
  try {
@@ -775,12 +1361,20 @@ function createAuthRouter(vault2, logoutAuth, loginRateLimit2, onSessionEstablis
775
1361
  router.post("/logout", logoutAuth, async (_req, res) => {
776
1362
  const cookie = vault2.getSpCookie();
777
1363
  vault2.clearKey();
1364
+ const logoutPinning = pairing ? { enforce: resolvePinTls(pairing.dataDir), pinnedSpkiHex: readPairing(pairing.dataDir)?.tlsSpkiPinHex } : { enforce: false };
778
1365
  await Promise.allSettled([
779
1366
  unconfigureSession(),
780
- cookie ? fetch(`${SP_URL}/api/auth/logout`, {
781
- method: "POST",
782
- headers: { cookie, ...clientVersionHeaders() },
783
- redirect: "manual"
1367
+ cookie ? fetchAs(
1368
+ `${SP_URL2}/api/auth/logout`,
1369
+ { method: "POST", headers: { cookie, ...clientVersionHeaders() }, redirect: "manual" },
1370
+ logoutPinning
1371
+ ).catch((err) => {
1372
+ if (err instanceof AsTlsMismatchError) {
1373
+ console.error("[Control Plane] Logout: TLS pin mismatch talking to the Authority Server \u2014 local sign-out still applied:", err.message);
1374
+ lockAsTlsMismatch2();
1375
+ } else {
1376
+ throw err;
1377
+ }
784
1378
  }) : Promise.resolve()
785
1379
  ]);
786
1380
  res.json({ ok: true });
@@ -1392,18 +1986,18 @@ async function testAIConnectivity(config) {
1392
1986
  }
1393
1987
 
1394
1988
  // src/lib/agent-brief-store.ts
1395
- import { existsSync as existsSync2, readFileSync as readFileSync3 } from "fs";
1989
+ import { existsSync as existsSync4, readFileSync as readFileSync6 } from "fs";
1396
1990
  import { homedir as homedir2 } from "os";
1397
- import { join as join3 } from "path";
1991
+ import { join as join5 } from "path";
1398
1992
  var AGENT_CONTEXT_MAX_BYTES = 16 * 1024;
1399
1993
  function agentBriefPath() {
1400
- const dataDir = process.env.SUVEREN_DATA_DIR ?? join3(homedir2(), ".suveren");
1401
- return join3(dataDir, "context.md");
1994
+ const dataDir = process.env.SUVEREN_DATA_DIR ?? join5(homedir2(), ".suveren");
1995
+ return join5(dataDir, "context.md");
1402
1996
  }
1403
1997
  function readAgentBrief() {
1404
1998
  const filePath = agentBriefPath();
1405
- if (!existsSync2(filePath)) return "";
1406
- return readFileSync3(filePath, "utf-8");
1999
+ if (!existsSync4(filePath)) return "";
2000
+ return readFileSync6(filePath, "utf-8");
1407
2001
  }
1408
2002
 
1409
2003
  // src/routes/ai.ts
@@ -1767,28 +2361,28 @@ function createMCPRouter() {
1767
2361
  // src/routes/autostart.ts
1768
2362
  import { Router as Router6 } from "express";
1769
2363
  import { execFile } from "child_process";
1770
- import { existsSync as existsSync3 } from "fs";
2364
+ import { existsSync as existsSync5 } from "fs";
1771
2365
  import { dirname as pathDirname, resolve } from "path";
1772
2366
  import { fileURLToPath } from "url";
1773
2367
  import { promisify } from "util";
1774
2368
  var run = promisify(execFile);
1775
2369
  var SUPPORTED = /* @__PURE__ */ new Set(["darwin", "win32", "linux"]);
1776
2370
  var MODULE_DIR = pathDirname(fileURLToPath(import.meta.url));
1777
- function findCli(dirname7 = MODULE_DIR) {
2371
+ function findCli(dirname9 = MODULE_DIR) {
1778
2372
  const candidates = [
1779
2373
  // Bundled (the shipped layout): dist/control-plane → dist → root → bin
1780
- resolve(dirname7, "..", "..", "bin", "suveren-gateway.js"),
2374
+ resolve(dirname9, "..", "..", "bin", "suveren-gateway.js"),
1781
2375
  // Bundled, were the routes/ directory ever preserved.
1782
- resolve(dirname7, "..", "..", "..", "bin", "suveren-gateway.js"),
2376
+ resolve(dirname9, "..", "..", "..", "bin", "suveren-gateway.js"),
1783
2377
  // Dev, running from source: the repo's own bundle directory.
1784
- resolve(dirname7, "..", "..", "..", "..", "bundle", "bin", "suveren-gateway.js"),
1785
- resolve(dirname7, "..", "..", "..", "..", "..", "bundle", "bin", "suveren-gateway.js")
2378
+ resolve(dirname9, "..", "..", "..", "..", "bundle", "bin", "suveren-gateway.js"),
2379
+ resolve(dirname9, "..", "..", "..", "..", "..", "bundle", "bin", "suveren-gateway.js")
1786
2380
  // Deliberately NO process.cwd() fallback: it makes the result depend on
1787
2381
  // where the process happened to be launched from, so the same install
1788
2382
  // resolves differently between a shell and a login service — and it would
1789
2383
  // mask a genuinely missing CLI whenever the cwd happened to be the repo.
1790
2384
  ];
1791
- return candidates.find(existsSync3) ?? null;
2385
+ return candidates.find(existsSync5) ?? null;
1792
2386
  }
1793
2387
  async function cli(args) {
1794
2388
  const bin = findCli();
@@ -1869,17 +2463,17 @@ function createAutostartRouter() {
1869
2463
  import { spawn, spawnSync } from "child_process";
1870
2464
 
1871
2465
  // src/lib/notifier-icon.ts
1872
- import { writeFileSync as writeFileSync2, mkdirSync as mkdirSync2, existsSync as existsSync4 } from "fs";
2466
+ import { writeFileSync as writeFileSync4, mkdirSync as mkdirSync4, existsSync as existsSync6 } from "fs";
1873
2467
  import { homedir as homedir3 } from "os";
1874
- import { join as join4, dirname as dirname2 } from "path";
2468
+ import { join as join6, dirname as dirname4 } from "path";
1875
2469
  var ICON_BASE64 = "iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAACXBIWXMAACxLAAAsSwGlPZapAAAaEElEQVR42u2deXxNV9fH7/O2z/vHk+HmJoIoQQxpBtVPi+LTIWZqeDQ6V0tRFUWIeagSRAheyasxVNUsWtRQSquoMTRi9mgJooZWhBqaSIX97nWa9CVN4ubes8/Z55zf+ny+H1rknrv3Wr+zh7XXttmMaY94e3vXdDgcL3JifHx8ZnE2cvbw/z7MyeBc5eRxGABukFfgS+RT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876
2470
  function ensureNotifierIcon(dataDir) {
1877
2471
  try {
1878
- const dir = dataDir ?? process.env.SUVEREN_DATA_DIR ?? join4(homedir3(), ".suveren");
1879
- const path = join4(dir, "notifier-icon.png");
1880
- if (!existsSync4(path)) {
1881
- mkdirSync2(dirname2(path), { recursive: true });
1882
- writeFileSync2(path, Buffer.from(ICON_BASE64, "base64"));
2472
+ const dir = dataDir ?? process.env.SUVEREN_DATA_DIR ?? join6(homedir3(), ".suveren");
2473
+ const path = join6(dir, "notifier-icon.png");
2474
+ if (!existsSync6(path)) {
2475
+ mkdirSync4(dirname4(path), { recursive: true });
2476
+ writeFileSync4(path, Buffer.from(ICON_BASE64, "base64"));
1883
2477
  }
1884
2478
  return path;
1885
2479
  } catch {
@@ -2081,24 +2675,24 @@ import { Router as Router9 } from "express";
2081
2675
 
2082
2676
  // src/routes/approved-intents.ts
2083
2677
  import { Router as Router8 } from "express";
2084
- import { readFileSync as readFileSync4, writeFileSync as writeFileSync3, existsSync as existsSync5, mkdirSync as mkdirSync3 } from "fs";
2678
+ import { readFileSync as readFileSync7, writeFileSync as writeFileSync5, existsSync as existsSync7, mkdirSync as mkdirSync5 } from "fs";
2085
2679
  import { homedir as homedir4 } from "os";
2086
- import { join as join5 } from "path";
2087
- var SUVEREN_DATA_DIR = process.env.SUVEREN_DATA_DIR ?? join5(homedir4(), ".suveren");
2088
- var FILE_PATH = join5(SUVEREN_DATA_DIR, "approved-intents.enc.json");
2680
+ import { join as join7 } from "path";
2681
+ var SUVEREN_DATA_DIR = process.env.SUVEREN_DATA_DIR ?? join7(homedir4(), ".suveren");
2682
+ var FILE_PATH = join7(SUVEREN_DATA_DIR, "approved-intents.enc.json");
2089
2683
  function readFile() {
2090
- if (!existsSync5(FILE_PATH)) {
2684
+ if (!existsSync7(FILE_PATH)) {
2091
2685
  return { version: 1, entries: {} };
2092
2686
  }
2093
2687
  try {
2094
- return JSON.parse(readFileSync4(FILE_PATH, "utf-8"));
2688
+ return JSON.parse(readFileSync7(FILE_PATH, "utf-8"));
2095
2689
  } catch {
2096
2690
  return { version: 1, entries: {} };
2097
2691
  }
2098
2692
  }
2099
2693
  function writeFile(data) {
2100
- mkdirSync3(SUVEREN_DATA_DIR, { recursive: true });
2101
- writeFileSync3(FILE_PATH, JSON.stringify(data, null, 2), "utf-8");
2694
+ mkdirSync5(SUVEREN_DATA_DIR, { recursive: true });
2695
+ writeFileSync5(FILE_PATH, JSON.stringify(data, null, 2), "utf-8");
2102
2696
  }
2103
2697
  function readApprovedIntents(vault2) {
2104
2698
  const file = readFile();
@@ -2147,7 +2741,7 @@ function createApprovedIntentsRouter(vault2) {
2147
2741
 
2148
2742
  // src/routes/evidence-export.ts
2149
2743
  var AS_FETCH_TIMEOUT_MS = 2e4;
2150
- function createEvidenceExportRouter(spUrl, vault2) {
2744
+ function createEvidenceExportRouter(spUrl, vault2, dataDir, lockAsTlsMismatch2) {
2151
2745
  const router = Router9();
2152
2746
  const getSpCookie = () => vault2.getSpCookie();
2153
2747
  router.get("/", async (_req, res) => {
@@ -2167,17 +2761,29 @@ function createEvidenceExportRouter(spUrl, vault2) {
2167
2761
  const controller = new AbortController();
2168
2762
  const timeout = setTimeout(() => controller.abort(), AS_FETCH_TIMEOUT_MS);
2169
2763
  try {
2170
- const asRes = await fetch(`${spUrl}/api/receipts/export`, {
2171
- headers: { Cookie: cookie },
2172
- signal: controller.signal
2173
- });
2764
+ const pin = readPairing(dataDir);
2765
+ const { res: asRes } = await fetchAs(
2766
+ `${spUrl}/api/receipts/export`,
2767
+ { headers: { Cookie: cookie }, signal: controller.signal },
2768
+ {
2769
+ enforce: resolvePinTls(dataDir),
2770
+ pinnedSpkiHex: pin && pin.asUrl === spUrl ? pin.tlsSpkiPinHex : void 0
2771
+ // Never capture here — only the sign-in challenge establishes or
2772
+ // refreshes a pin (as-challenge.ts).
2773
+ }
2774
+ );
2174
2775
  if (asRes.ok) {
2175
2776
  authorityServer = await asRes.json();
2176
2777
  } else {
2177
2778
  asError = `Authority Server export failed: ${asRes.status}`;
2178
2779
  }
2179
2780
  } catch (err) {
2180
- asError = `Authority Server unreachable: ${err instanceof Error ? err.message : String(err)}`;
2781
+ if (err instanceof AsTlsMismatchError) {
2782
+ lockAsTlsMismatch2();
2783
+ asError = err.message;
2784
+ } else {
2785
+ asError = `Authority Server unreachable: ${err instanceof Error ? err.message : String(err)}`;
2786
+ }
2181
2787
  } finally {
2182
2788
  clearTimeout(timeout);
2183
2789
  }
@@ -2363,7 +2969,7 @@ function createDecryptIntentRouter(vault2) {
2363
2969
 
2364
2970
  // src/lib/update-checker.ts
2365
2971
  import { execSync } from "child_process";
2366
- import { dirname as dirname3 } from "path";
2972
+ import { dirname as dirname5 } from "path";
2367
2973
  import { fileURLToPath as fileURLToPath2 } from "url";
2368
2974
  var GHCR_IMAGE = "suverenai/suveren-gateway";
2369
2975
  var NPM_PACKAGE = "@suveren/gateway";
@@ -2429,7 +3035,7 @@ function compareSemver(a, b) {
2429
3035
  return 0;
2430
3036
  }
2431
3037
  function checkDev() {
2432
- const cwd = dirname3(fileURLToPath2(import.meta.url));
3038
+ const cwd = dirname5(fileURLToPath2(import.meta.url));
2433
3039
  try {
2434
3040
  execSync("git fetch origin --quiet", { cwd, stdio: "ignore", timeout: 15e3 });
2435
3041
  const out = execSync("git rev-list HEAD..origin/main --count", {
@@ -2502,19 +3108,19 @@ data: ${data}
2502
3108
  import { Router as Router12 } from "express";
2503
3109
 
2504
3110
  // src/lib/gateway-settings.ts
2505
- import { readFileSync as readFileSync5, writeFileSync as writeFileSync4, mkdirSync as mkdirSync4 } from "fs";
3111
+ import { readFileSync as readFileSync8, writeFileSync as writeFileSync6, mkdirSync as mkdirSync6 } from "fs";
2506
3112
  import { homedir as homedir5 } from "os";
2507
- import { join as join6, dirname as dirname4 } from "path";
3113
+ import { join as join8, dirname as dirname6 } from "path";
2508
3114
  var DEFAULT_SETTINGS = {
2509
3115
  desktopNotifications: true
2510
3116
  };
2511
3117
  function settingsPath(dataDir) {
2512
- const dir = dataDir ?? process.env.SUVEREN_DATA_DIR ?? join6(homedir5(), ".suveren");
2513
- return join6(dir, "settings.json");
3118
+ const dir = dataDir ?? process.env.SUVEREN_DATA_DIR ?? join8(homedir5(), ".suveren");
3119
+ return join8(dir, "settings.json");
2514
3120
  }
2515
3121
  function readSettings(dataDir) {
2516
3122
  try {
2517
- const raw = JSON.parse(readFileSync5(settingsPath(dataDir), "utf8"));
3123
+ const raw = JSON.parse(readFileSync8(settingsPath(dataDir), "utf8"));
2518
3124
  return {
2519
3125
  desktopNotifications: typeof raw.desktopNotifications === "boolean" ? raw.desktopNotifications : DEFAULT_SETTINGS.desktopNotifications
2520
3126
  };
@@ -2528,8 +3134,8 @@ function writeSettings(patch, dataDir) {
2528
3134
  ...typeof patch.desktopNotifications === "boolean" ? { desktopNotifications: patch.desktopNotifications } : {}
2529
3135
  };
2530
3136
  const path = settingsPath(dataDir);
2531
- mkdirSync4(dirname4(path), { recursive: true });
2532
- writeFileSync4(path, JSON.stringify(next, null, 2) + "\n", "utf8");
3137
+ mkdirSync6(dirname6(path), { recursive: true });
3138
+ writeFileSync6(path, JSON.stringify(next, null, 2) + "\n", "utf8");
2533
3139
  return next;
2534
3140
  }
2535
3141
 
@@ -2561,20 +3167,20 @@ function createGatewaySettingsRouter() {
2561
3167
  import { Router as Router13 } from "express";
2562
3168
 
2563
3169
  // src/lib/archived-mandates-store.ts
2564
- import { readFileSync as readFileSync6, writeFileSync as writeFileSync5, mkdirSync as mkdirSync5, renameSync } from "fs";
3170
+ import { readFileSync as readFileSync9, writeFileSync as writeFileSync7, mkdirSync as mkdirSync7, renameSync } from "fs";
2565
3171
  import { homedir as homedir6 } from "os";
2566
- import { join as join7, dirname as dirname5 } from "path";
3172
+ import { join as join9, dirname as dirname7 } from "path";
2567
3173
  var ID_PATTERN = /^[A-Za-z0-9_.:-]{1,200}$/;
2568
3174
  function isValidMandateId(id) {
2569
3175
  return typeof id === "string" && ID_PATTERN.test(id);
2570
3176
  }
2571
3177
  function storePath(dataDir) {
2572
- const dir = dataDir ?? process.env.SUVEREN_DATA_DIR ?? join7(homedir6(), ".suveren");
2573
- return join7(dir, "archived-mandates.json");
3178
+ const dir = dataDir ?? process.env.SUVEREN_DATA_DIR ?? join9(homedir6(), ".suveren");
3179
+ return join9(dir, "archived-mandates.json");
2574
3180
  }
2575
3181
  function readArchived(dataDir) {
2576
3182
  try {
2577
- const raw = JSON.parse(readFileSync6(storePath(dataDir), "utf8"));
3183
+ const raw = JSON.parse(readFileSync9(storePath(dataDir), "utf8"));
2578
3184
  if (!Array.isArray(raw.archived)) return [];
2579
3185
  return [...new Set(raw.archived.filter(isValidMandateId))];
2580
3186
  } catch {
@@ -2584,9 +3190,9 @@ function readArchived(dataDir) {
2584
3190
  function writeArchived(ids, dataDir) {
2585
3191
  const next = [...new Set(ids.filter(isValidMandateId))].sort();
2586
3192
  const path = storePath(dataDir);
2587
- mkdirSync5(dirname5(path), { recursive: true });
3193
+ mkdirSync7(dirname7(path), { recursive: true });
2588
3194
  const tmp = `${path}.tmp`;
2589
- writeFileSync5(tmp, JSON.stringify({ archived: next }, null, 2) + "\n", "utf8");
3195
+ writeFileSync7(tmp, JSON.stringify({ archived: next }, null, 2) + "\n", "utf8");
2590
3196
  renameSync(tmp, path);
2591
3197
  return next;
2592
3198
  }
@@ -2627,6 +3233,8 @@ import { Router as Router14 } from "express";
2627
3233
  import { timingSafeEqual as timingSafeEqual2 } from "crypto";
2628
3234
  var ALLOWED = ["proposal-added", "action-approval-needed"];
2629
3235
  var SESSION_EXPIRED = "session-expired";
3236
+ var AS_KEY_MISMATCH = "as-key-mismatch";
3237
+ var AS_TLS_MISMATCH = "as-tls-mismatch";
2630
3238
  function secretMatches(provided, expected) {
2631
3239
  if (!expected) return false;
2632
3240
  if (!provided) return false;
@@ -2635,7 +3243,7 @@ function secretMatches(provided, expected) {
2635
3243
  if (a.length !== b.length) return false;
2636
3244
  return timingSafeEqual2(a, b);
2637
3245
  }
2638
- function createInternalEventsRouter(getSecret, onSessionExpired) {
3246
+ function createInternalEventsRouter(getSecret, onSessionExpired, onAsKeyMismatch, onAsTlsMismatch) {
2639
3247
  const router = Router14();
2640
3248
  router.post("/event", (req, res) => {
2641
3249
  if (!secretMatches(req.headers["x-internal-secret"], getSecret())) {
@@ -2648,6 +3256,16 @@ function createInternalEventsRouter(getSecret, onSessionExpired) {
2648
3256
  res.json({ ok: true });
2649
3257
  return;
2650
3258
  }
3259
+ if (type === AS_KEY_MISMATCH) {
3260
+ onAsKeyMismatch?.();
3261
+ res.json({ ok: true });
3262
+ return;
3263
+ }
3264
+ if (type === AS_TLS_MISMATCH) {
3265
+ onAsTlsMismatch?.();
3266
+ res.json({ ok: true });
3267
+ return;
3268
+ }
2651
3269
  if (typeof type !== "string" || !ALLOWED.includes(type)) {
2652
3270
  res.status(400).json({ error: "Unsupported event type" });
2653
3271
  return;
@@ -2746,6 +3364,8 @@ function startNotificationDispatcher(opts = {}) {
2746
3364
 
2747
3365
  // src/lib/session-lock.ts
2748
3366
  var SESSION_LOCKED_MESSAGE = "Your sign-in ended after 30 days or was revoked. Sign in again.";
3367
+ var AS_KEY_MISMATCH_MESSAGE = "The Authority Server presented a signing key that does not match the one pinned at pairing. Sign in again to review.";
3368
+ var AS_TLS_MISMATCH_MESSAGE = "A connection to the Authority Server presented a TLS certificate that does not match the one pinned at pairing. The connection was refused before anything was sent. If the certificate changed intentionally (a new key, not just renewal), clear the pairing and sign in again to re-pin it.";
2749
3369
  function createSessionLock(deps) {
2750
3370
  const { vault: vault2, port: port2 } = deps;
2751
3371
  const notifyFn = deps.notifyFn ?? notify;
@@ -2763,6 +3383,40 @@ function createSessionLock(deps) {
2763
3383
  notifyFn(title, message, process.platform, url);
2764
3384
  };
2765
3385
  }
3386
+ function createAsKeyMismatchLock(deps) {
3387
+ const { vault: vault2, port: port2 } = deps;
3388
+ const notifyFn = deps.notifyFn ?? notify;
3389
+ const unconfigureSessionFn = deps.unconfigureSessionFn ?? unconfigureSession;
3390
+ const emit = deps.emit ?? eventBus.emit.bind(eventBus);
3391
+ return function lockOnAsKeyMismatch() {
3392
+ if (!vault2.isUnlocked()) return;
3393
+ vault2.lockAsKeyMismatch();
3394
+ console.error("[Control Plane] Authority Server key mismatch \u2014 gateway LOCKED");
3395
+ void unconfigureSessionFn("as-key-mismatch").catch((err) => {
3396
+ console.error("[Control Plane] Failed to push cleared session to MCP:", err);
3397
+ });
3398
+ emit("session-locked", { reason: "as-key-mismatch", message: AS_KEY_MISMATCH_MESSAGE });
3399
+ const { title, url } = sessionExpiredNotification(port2);
3400
+ notifyFn(title, AS_KEY_MISMATCH_MESSAGE, process.platform, url);
3401
+ };
3402
+ }
3403
+ function createAsTlsMismatchLock(deps) {
3404
+ const { vault: vault2, port: port2 } = deps;
3405
+ const notifyFn = deps.notifyFn ?? notify;
3406
+ const unconfigureSessionFn = deps.unconfigureSessionFn ?? unconfigureSession;
3407
+ const emit = deps.emit ?? eventBus.emit.bind(eventBus);
3408
+ return function lockOnAsTlsMismatch() {
3409
+ if (!vault2.isUnlocked()) return;
3410
+ vault2.lockAsTlsMismatch();
3411
+ console.error("[Control Plane] Authority Server TLS pin mismatch \u2014 gateway LOCKED");
3412
+ void unconfigureSessionFn("as-tls-mismatch").catch((err) => {
3413
+ console.error("[Control Plane] Failed to push cleared session to MCP:", err);
3414
+ });
3415
+ emit("session-locked", { reason: "as-tls-mismatch", message: AS_TLS_MISMATCH_MESSAGE });
3416
+ const { title, url } = sessionExpiredNotification(port2);
3417
+ notifyFn(title, AS_TLS_MISMATCH_MESSAGE, process.platform, url);
3418
+ };
3419
+ }
2766
3420
 
2767
3421
  // src/lib/session-expiry-scheduler.ts
2768
3422
  var MAX_TIMEOUT_MS = 2147483647;
@@ -2832,17 +3486,17 @@ function buildSessionHealth(vault2) {
2832
3486
  }
2833
3487
 
2834
3488
  // src/lib/denials-reader.ts
2835
- import { existsSync as existsSync6, readFileSync as readFileSync7 } from "fs";
2836
- import { join as join8 } from "path";
3489
+ import { existsSync as existsSync8, readFileSync as readFileSync10 } from "fs";
3490
+ import { join as join10 } from "path";
2837
3491
  function loadDenials(dataDir, decrypt) {
2838
- const encPath = join8(dataDir, "denials.enc.json");
2839
- const plainPath = join8(dataDir, "denials.json");
2840
- if (existsSync6(encPath)) {
2841
- const { blob } = JSON.parse(readFileSync7(encPath, "utf-8"));
3492
+ const encPath = join10(dataDir, "denials.enc.json");
3493
+ const plainPath = join10(dataDir, "denials.json");
3494
+ if (existsSync8(encPath)) {
3495
+ const { blob } = JSON.parse(readFileSync10(encPath, "utf-8"));
2842
3496
  return JSON.parse(decrypt(blob)).records ?? [];
2843
3497
  }
2844
- if (existsSync6(plainPath)) {
2845
- return JSON.parse(readFileSync7(plainPath, "utf-8")).records ?? [];
3498
+ if (existsSync8(plainPath)) {
3499
+ return JSON.parse(readFileSync10(plainPath, "utf-8")).records ?? [];
2846
3500
  }
2847
3501
  return [];
2848
3502
  }
@@ -2859,9 +3513,9 @@ function selectDenials(records, opts = {}) {
2859
3513
  // src/index.ts
2860
3514
  (function migrateDataDir() {
2861
3515
  if (process.env.SUVEREN_DATA_DIR) return;
2862
- const oldDir = join9(homedir7(), ".hap");
2863
- const newDir = join9(homedir7(), ".suveren");
2864
- if (!existsSync7(newDir) && existsSync7(oldDir)) {
3516
+ const oldDir = join11(homedir7(), ".hap");
3517
+ const newDir = join11(homedir7(), ".suveren");
3518
+ if (!existsSync9(newDir) && existsSync9(oldDir)) {
2865
3519
  try {
2866
3520
  renameSync2(oldDir, newDir);
2867
3521
  console.error(`[Control Plane] Migrated data directory: ${oldDir} \u2192 ${newDir}`);
@@ -2871,12 +3525,24 @@ function selectDenials(records, opts = {}) {
2871
3525
  }
2872
3526
  }
2873
3527
  })();
2874
- var SP_URL2 = process.env.SUVEREN_AS_URL ?? "https://www.suveren.ai";
3528
+ var DATA_DIR = process.env.SUVEREN_DATA_DIR ?? join11(homedir7(), ".suveren");
3529
+ var SP_URL = resolveAsUrl(DATA_DIR);
3530
+ validatePinTlsForUrl(resolvePinTls(DATA_DIR), SP_URL);
2875
3531
  var port = parseInt(process.env.SUVEREN_CP_PORT ?? "3402", 10);
2876
3532
  var HAP_MODE = process.env.HAP_MODE ?? "personal";
2877
- var UI_DIST = process.env.HAP_UI_DIST ?? join9(import.meta.dirname ?? __dirname, "../../ui/dist");
2878
- var vault = new Vault();
2879
- var internalSecret2 = process.env.SUVEREN_INTERNAL_SECRET ?? randomBytes2(32).toString("hex");
3533
+ var UI_DIST = process.env.HAP_UI_DIST ?? join11(import.meta.dirname ?? __dirname, "../../ui/dist");
3534
+ var vault = new Vault(DATA_DIR);
3535
+ (function repairIfAsUrlChanged() {
3536
+ const pairing = readPairing(DATA_DIR);
3537
+ if (pairing && pairing.asUrl !== SP_URL) {
3538
+ console.error(
3539
+ `[Control Plane] Authority Server changed (${pairing.asUrl} \u2192 ${SP_URL}) \u2014 clearing the old pairing. Sign in again to re-pair.`
3540
+ );
3541
+ clearPairing(DATA_DIR);
3542
+ vault.markBootLockedAsUrlChanged();
3543
+ }
3544
+ })();
3545
+ var internalSecret2 = process.env.SUVEREN_INTERNAL_SECRET ?? randomBytes3(32).toString("hex");
2880
3546
  setInternalSecret(internalSecret2);
2881
3547
  var app = express();
2882
3548
  var jsonParser = express.json();
@@ -2899,6 +3565,8 @@ function loginRateLimit(req, res, next) {
2899
3565
  next();
2900
3566
  }
2901
3567
  var lockExpiredSession = createSessionLock({ vault, port });
3568
+ var lockAsKeyMismatch = createAsKeyMismatchLock({ vault, port });
3569
+ var lockAsTlsMismatch = createAsTlsMismatchLock({ vault, port });
2902
3570
  var sessionExpiryScheduler = new SessionExpiryScheduler(
2903
3571
  () => vault.getSessionExpiresAt(),
2904
3572
  lockExpiredSession
@@ -2907,7 +3575,8 @@ app.use("/auth", jsonParser, createAuthRouter(
2907
3575
  vault,
2908
3576
  requireAuth(vault),
2909
3577
  loginRateLimit,
2910
- () => sessionExpiryScheduler.reschedule()
3578
+ () => sessionExpiryScheduler.reschedule(),
3579
+ { asUrl: SP_URL, dataDir: DATA_DIR }
2911
3580
  ));
2912
3581
  function resolveOrigin(req) {
2913
3582
  const fwdHost = req.get("x-forwarded-host");
@@ -3114,7 +3783,7 @@ app.get("/auth/oauth/:integrationId/health", authGuard, async (req, res) => {
3114
3783
  }
3115
3784
  });
3116
3785
  app.get("/events", requireAllowedHost, requireAuthQueryOrHeader(vault), createEventsHandler());
3117
- app.use("/internal", jsonParser, createInternalEventsRouter(() => internalSecret2, lockExpiredSession));
3786
+ app.use("/internal", jsonParser, createInternalEventsRouter(() => internalSecret2, lockExpiredSession, lockAsKeyMismatch, lockAsTlsMismatch));
3118
3787
  app.use("/vault", jsonParser, authGuard, createVaultRouter(vault));
3119
3788
  app.use("/ai", jsonParser, authGuard, createAIRouter(vault));
3120
3789
  app.use("/ai-prompts", jsonParser, authGuard, createAIPromptsRouter());
@@ -3123,7 +3792,7 @@ app.use("/autostart", jsonParser, authGuard, createAutostartRouter());
3123
3792
  app.use("/api/gateway-settings", jsonParser, authGuard, createGatewaySettingsRouter());
3124
3793
  app.use("/api/archived-mandates", jsonParser, authGuard, createArchivedMandatesRouter());
3125
3794
  app.use("/api/encrypt-intent", jsonParser, authGuard, createEncryptIntentRouter());
3126
- app.use("/api/evidence-export", authGuard, createEvidenceExportRouter(SP_URL2, vault));
3795
+ app.use("/api/evidence-export", authGuard, createEvidenceExportRouter(SP_URL, vault, DATA_DIR, lockAsTlsMismatch));
3127
3796
  app.use("/api/evidence", authGuard, createEvidenceRouter());
3128
3797
  app.use("/api/decrypt-intent", jsonParser, authGuard, createDecryptIntentRouter(vault));
3129
3798
  app.use("/api/approved-intents", jsonParser, authGuard, createApprovedIntentsRouter(vault));
@@ -3253,9 +3922,34 @@ app.get("/active-authorizations", authGuard, async (_req, res) => {
3253
3922
  res.status(500).json({ error: "Failed to fetch authorizations from MCP server" });
3254
3923
  }
3255
3924
  });
3925
+ app.get("/skipped-commitments", authGuard, async (_req, res) => {
3926
+ try {
3927
+ const data = await getSkippedCommitments();
3928
+ res.json(data);
3929
+ } catch (err) {
3930
+ console.error("[Control Plane] Skipped-commitments retrieval error:", err);
3931
+ res.status(500).json({ error: "Failed to fetch skipped commitments from MCP server" });
3932
+ }
3933
+ });
3934
+ app.get("/as-pairing", authGuard, (_req, res) => {
3935
+ const pairing = readPairing(DATA_DIR);
3936
+ const paired = pairing !== null && pairing.asUrl === SP_URL;
3937
+ res.json({
3938
+ asUrl: SP_URL,
3939
+ paired,
3940
+ fingerprint: paired ? fingerprintOf(pairing.publicKeyHex) : null,
3941
+ pairedAt: paired ? pairing.pairedAt : null,
3942
+ // Opt-in TLS pinning (`config set pin-tls on`) — see as-tls-pin.ts.
3943
+ // `tlsPinFingerprint` uses the SAME display convention as the signing
3944
+ // key (formatPinFingerprint mirrors fingerprintOf's grouping), applied
3945
+ // to the already-computed SPKI digest rather than re-hashing a key.
3946
+ pinTlsEnabled: resolvePinTls(DATA_DIR),
3947
+ tlsPinFingerprint: paired && pairing.tlsSpkiPinHex ? formatPinFingerprint(pairing.tlsSpkiPinHex) : null
3948
+ });
3949
+ });
3256
3950
  app.get("/denials", authGuard, (req, res) => {
3257
3951
  try {
3258
- const dataDir = process.env.SUVEREN_DATA_DIR ?? join9(homedir7(), ".suveren");
3952
+ const dataDir = process.env.SUVEREN_DATA_DIR ?? join11(homedir7(), ".suveren");
3259
3953
  const all = loadDenials(dataDir, (blob) => vault.decrypt(blob));
3260
3954
  const since = Number(req.query.since);
3261
3955
  const limit = Number(req.query.limit);
@@ -3306,11 +4000,11 @@ app.put("/agent-brief/context", jsonParser, authGuard, async (req, res) => {
3306
4000
  res.status(413).json({ error: `Context exceeds ${AGENT_CONTEXT_MAX_BYTES}-byte cap` });
3307
4001
  return;
3308
4002
  }
3309
- const { mkdirSync: mkdirSync6, writeFileSync: writeFileSync6, renameSync: renameSync3 } = await import("fs");
4003
+ const { mkdirSync: mkdirSync8, writeFileSync: writeFileSync8, renameSync: renameSync3 } = await import("fs");
3310
4004
  const filePath = agentBriefPath();
3311
- mkdirSync6(dirname6(filePath), { recursive: true });
4005
+ mkdirSync8(dirname8(filePath), { recursive: true });
3312
4006
  const tmpPath = `${filePath}.tmp`;
3313
- writeFileSync6(tmpPath, content, "utf-8");
4007
+ writeFileSync8(tmpPath, content, "utf-8");
3314
4008
  renameSync3(tmpPath, filePath);
3315
4009
  res.json({ ok: true });
3316
4010
  } catch (err) {
@@ -3319,11 +4013,19 @@ app.put("/agent-brief/context", jsonParser, authGuard, async (req, res) => {
3319
4013
  }
3320
4014
  });
3321
4015
  app.use("/api", authGuard);
4016
+ var pinnedProxyAgent = SP_URL.startsWith("https:") ? buildPinnedHttpsAgent(() => {
4017
+ const pin = readPairing(DATA_DIR);
4018
+ return {
4019
+ enforce: resolvePinTls(DATA_DIR),
4020
+ pinnedSpkiHex: pin && pin.asUrl === SP_URL ? pin.tlsSpkiPinHex : void 0
4021
+ };
4022
+ }) : void 0;
3322
4023
  app.use(
3323
4024
  createProxyMiddleware({
3324
- target: SP_URL2,
4025
+ target: SP_URL,
3325
4026
  changeOrigin: true,
3326
4027
  pathFilter: "/api",
4028
+ ...pinnedProxyAgent ? { agent: pinnedProxyAgent } : {},
3327
4029
  on: {
3328
4030
  proxyReq: (proxyReq) => {
3329
4031
  const cookie = vault.getSpCookie();
@@ -3331,6 +4033,21 @@ app.use(
3331
4033
  proxyReq.setHeader("Cookie", cookie);
3332
4034
  }
3333
4035
  },
4036
+ // A pin check failure means the connection never completed its TLS
4037
+ // handshake — nothing (not even this call's own cookie) reached the
4038
+ // network. Lock the gateway with the real reason, loudly; an ordinary
4039
+ // network error (AS outage) is NOT a pin failure (see isPinCheckError
4040
+ // / as-tls-pin.ts's module doc comment on outage misclassification)
4041
+ // and falls through to http-proxy-middleware's default error handling.
4042
+ error: (err, _req, res) => {
4043
+ if (!isPinCheckError(err)) return;
4044
+ console.error("[Control Plane] /api proxy: TLS pin mismatch \u2014 gateway LOCKED:", err.message);
4045
+ lockAsTlsMismatch();
4046
+ if (res && "writeHead" in res && !res.headersSent) {
4047
+ res.writeHead(502, { "Content-Type": "application/json" });
4048
+ res.end(JSON.stringify({ error: "as_tls_mismatch", message: err.message }));
4049
+ }
4050
+ },
3334
4051
  proxyRes: (proxyRes, req) => {
3335
4052
  const status = proxyRes.statusCode ?? 0;
3336
4053
  if (status === 401 && vault.isUnlocked()) {
@@ -3363,13 +4080,13 @@ app.use(
3363
4080
  })
3364
4081
  );
3365
4082
  function detectInstallMethod() {
3366
- if (existsSync7("/.dockerenv")) return "docker";
4083
+ if (existsSync9("/.dockerenv")) return "docker";
3367
4084
  const dir = import.meta.dirname ?? __dirname;
3368
4085
  if (dir.includes("/node_modules/@suveren/gateway/")) return "npm";
3369
4086
  let cursor = dir;
3370
4087
  for (let i = 0; i < 8; i++) {
3371
- if (existsSync7(join9(cursor, ".git"))) return "dev";
3372
- const parent = dirname6(cursor);
4088
+ if (existsSync9(join11(cursor, ".git"))) return "dev";
4089
+ const parent = dirname8(cursor);
3373
4090
  if (parent === cursor) break;
3374
4091
  cursor = parent;
3375
4092
  }
@@ -3381,10 +4098,10 @@ function detectRunningVersion() {
3381
4098
  return process.env.HAP_BUILD_SHA ?? "dev";
3382
4099
  }
3383
4100
  const dir = import.meta.dirname ?? __dirname;
3384
- const bundlePkg = join9(dir, "..", "..", "package.json");
3385
- if (existsSync7(bundlePkg)) {
4101
+ const bundlePkg = join11(dir, "..", "..", "package.json");
4102
+ if (existsSync9(bundlePkg)) {
3386
4103
  try {
3387
- const pkg = JSON.parse(readFileSync8(bundlePkg, "utf8"));
4104
+ const pkg = JSON.parse(readFileSync11(bundlePkg, "utf8"));
3388
4105
  if (pkg.name === "@suveren/gateway" && typeof pkg.version === "string") {
3389
4106
  return pkg.version;
3390
4107
  }
@@ -3406,14 +4123,14 @@ app.get("/health", async (req, res) => {
3406
4123
  latestVersion: update.latestVersion,
3407
4124
  updateAvailable: update.updateAvailable,
3408
4125
  installMethod: INSTALL_METHOD,
3409
- spUrl: SP_URL2,
4126
+ spUrl: SP_URL,
3410
4127
  session: buildSessionHealth(vault),
3411
4128
  security: {
3412
4129
  note: "Gateway secures tool execution. Agent host isolation is the user's responsibility."
3413
4130
  }
3414
4131
  });
3415
4132
  });
3416
- if (existsSync7(UI_DIST)) {
4133
+ if (existsSync9(UI_DIST)) {
3417
4134
  app.use(express.static(UI_DIST, {
3418
4135
  setHeaders: (res, filePath) => {
3419
4136
  if (filePath.endsWith("index.html")) {
@@ -3423,7 +4140,7 @@ if (existsSync7(UI_DIST)) {
3423
4140
  }));
3424
4141
  app.get("*", (_req, res) => {
3425
4142
  res.setHeader("Cache-Control", "no-store, must-revalidate");
3426
- res.sendFile(join9(UI_DIST, "index.html"));
4143
+ res.sendFile(join11(UI_DIST, "index.html"));
3427
4144
  });
3428
4145
  } else {
3429
4146
  app.get("/", (_req, res) => {
@@ -3441,7 +4158,7 @@ app.listen(port, "0.0.0.0", () => {
3441
4158
  }
3442
4159
  startNotificationDispatcher({ url: `http://localhost:${port}` });
3443
4160
  sessionExpiryScheduler.start();
3444
- console.error(`[Control Plane] SP proxy: ${SP_URL2}`);
4161
+ console.error(`[Control Plane] SP proxy: ${SP_URL}`);
3445
4162
  console.error(`[Control Plane] UI dist: ${UI_DIST}`);
3446
4163
  console.error(`[Control Plane] Internal secret: configured`);
3447
4164
  console.error(`[Control Plane] MCP server: ${MCP_BASE}`);