@suveren/gateway 0.8.6 → 0.9.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 (670) hide show
  1. package/bin/suveren-gateway.js +165 -9
  2. package/dist/control-plane/index.mjs +546 -87
  3. package/dist/mcp-server/http.mjs +727 -187
  4. package/dist/ui/assets/index-CIiOCgjJ.js +110 -0
  5. package/dist/ui/icons/apple-touch-icon.png +0 -0
  6. package/dist/ui/icons/icon-192.png +0 -0
  7. package/dist/ui/icons/icon-512.png +0 -0
  8. package/dist/ui/icons/icon-maskable-512.png +0 -0
  9. package/dist/ui/index.html +7 -1
  10. package/dist/ui/manifest.webmanifest +15 -0
  11. package/lib/config.d.mts +37 -0
  12. package/lib/config.mjs +150 -0
  13. package/node_modules/@hap/core/dist/index.d.mts +33 -2
  14. package/node_modules/@hap/core/dist/index.d.ts +33 -2
  15. package/node_modules/@hap/core/dist/index.js +26 -2
  16. package/node_modules/@hap/core/dist/index.mjs +25 -2
  17. package/node_modules/@hap/core/package.json +1 -1
  18. package/node_modules/@hap/core/src/gatekeeper.ts +36 -2
  19. package/node_modules/@hap/core/src/types.ts +21 -1
  20. package/node_modules/@hono/node-server/README.md +21 -10
  21. package/node_modules/@hono/node-server/dist/early-hints.cjs +1 -1
  22. package/node_modules/@hono/node-server/dist/early-hints.mjs +1 -1
  23. package/node_modules/@hono/node-server/dist/index.cjs +41 -19
  24. package/node_modules/@hono/node-server/dist/index.mjs +42 -20
  25. package/node_modules/@hono/node-server/dist/serve-static.cjs +1 -0
  26. package/node_modules/@hono/node-server/dist/serve-static.d.cts +2 -1
  27. package/node_modules/@hono/node-server/dist/serve-static.d.mts +2 -1
  28. package/node_modules/@hono/node-server/dist/serve-static.mjs +1 -0
  29. package/node_modules/@hono/node-server/package.json +3 -2
  30. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth-extensions.d.ts +43 -2
  31. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth-extensions.d.ts.map +1 -1
  32. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth-extensions.js +26 -5
  33. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth-extensions.js.map +1 -1
  34. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth.d.ts +26 -4
  35. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth.d.ts.map +1 -1
  36. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth.js +118 -17
  37. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth.js.map +1 -1
  38. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/simpleClientCredentials.d.ts +1 -0
  39. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/simpleClientCredentials.d.ts.map +1 -1
  40. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/simpleClientCredentials.js +11 -2
  41. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/client/simpleClientCredentials.js.map +1 -1
  42. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/server/demoInMemoryOAuthProvider.d.ts +2 -0
  43. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/examples/server/demoInMemoryOAuthProvider.d.ts.map +1 -1
  44. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/auth/providers/proxyProvider.d.ts.map +1 -1
  45. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/auth/providers/proxyProvider.js +6 -3
  46. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/auth/providers/proxyProvider.js.map +1 -1
  47. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/express.d.ts.map +1 -1
  48. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/express.js +3 -1
  49. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/express.js.map +1 -1
  50. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/requestBody.d.ts +25 -0
  51. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/requestBody.d.ts.map +1 -0
  52. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/requestBody.js +64 -0
  53. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/requestBody.js.map +1 -0
  54. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/webStandardStreamableHttp.d.ts +10 -1
  55. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/webStandardStreamableHttp.d.ts.map +1 -1
  56. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/webStandardStreamableHttp.js +13 -1
  57. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/webStandardStreamableHttp.js.map +1 -1
  58. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/auth.d.ts +3 -0
  59. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/auth.d.ts.map +1 -1
  60. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/auth.js +12 -2
  61. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/auth.js.map +1 -1
  62. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth-extensions.d.ts +43 -2
  63. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth-extensions.d.ts.map +1 -1
  64. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth-extensions.js +26 -5
  65. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth-extensions.js.map +1 -1
  66. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth.d.ts +26 -4
  67. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth.d.ts.map +1 -1
  68. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth.js +118 -17
  69. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth.js.map +1 -1
  70. package/node_modules/@modelcontextprotocol/sdk/dist/esm/examples/client/simpleClientCredentials.d.ts +1 -0
  71. package/node_modules/@modelcontextprotocol/sdk/dist/esm/examples/client/simpleClientCredentials.d.ts.map +1 -1
  72. package/node_modules/@modelcontextprotocol/sdk/dist/esm/examples/client/simpleClientCredentials.js +11 -2
  73. package/node_modules/@modelcontextprotocol/sdk/dist/esm/examples/client/simpleClientCredentials.js.map +1 -1
  74. package/node_modules/@modelcontextprotocol/sdk/dist/esm/examples/server/demoInMemoryOAuthProvider.d.ts +2 -0
  75. package/node_modules/@modelcontextprotocol/sdk/dist/esm/examples/server/demoInMemoryOAuthProvider.d.ts.map +1 -1
  76. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/auth/providers/proxyProvider.d.ts.map +1 -1
  77. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/auth/providers/proxyProvider.js +6 -3
  78. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/auth/providers/proxyProvider.js.map +1 -1
  79. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/express.d.ts.map +1 -1
  80. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/express.js +3 -1
  81. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/express.js.map +1 -1
  82. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/requestBody.d.ts +25 -0
  83. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/requestBody.d.ts.map +1 -0
  84. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/requestBody.js +58 -0
  85. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/requestBody.js.map +1 -0
  86. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.d.ts +10 -1
  87. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.d.ts.map +1 -1
  88. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js +13 -1
  89. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js.map +1 -1
  90. package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth.d.ts +3 -0
  91. package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth.d.ts.map +1 -1
  92. package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth.js +12 -2
  93. package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth.js.map +1 -1
  94. package/node_modules/@modelcontextprotocol/sdk/package.json +1 -1
  95. package/node_modules/@types/node/README.md +1 -1
  96. package/node_modules/@types/node/crypto.d.ts +2 -2
  97. package/node_modules/@types/node/dgram.d.ts +1 -1
  98. package/node_modules/@types/node/package.json +2 -2
  99. package/node_modules/hono/dist/_virtual/_rolldown/runtime.js +13 -0
  100. package/node_modules/hono/dist/adapter/aws-lambda/conninfo.js +42 -23
  101. package/node_modules/hono/dist/adapter/aws-lambda/handler.js +318 -341
  102. package/node_modules/hono/dist/adapter/aws-lambda/index.js +2 -8
  103. package/node_modules/hono/dist/adapter/aws-lambda/types.js +1 -0
  104. package/node_modules/hono/dist/adapter/bun/conninfo.js +20 -25
  105. package/node_modules/hono/dist/adapter/bun/index.js +3 -13
  106. package/node_modules/hono/dist/adapter/bun/serve-static.js +27 -27
  107. package/node_modules/hono/dist/adapter/bun/server.js +11 -5
  108. package/node_modules/hono/dist/adapter/bun/ssg.js +25 -15
  109. package/node_modules/hono/dist/adapter/bun/websocket.js +61 -68
  110. package/node_modules/hono/dist/adapter/cloudflare-pages/conninfo.js +24 -9
  111. package/node_modules/hono/dist/adapter/cloudflare-pages/handler.js +59 -62
  112. package/node_modules/hono/dist/adapter/cloudflare-pages/index.js +2 -8
  113. package/node_modules/hono/dist/adapter/cloudflare-workers/conninfo.js +7 -9
  114. package/node_modules/hono/dist/adapter/cloudflare-workers/index.js +3 -8
  115. package/node_modules/hono/dist/adapter/cloudflare-workers/serve-static-module.js +5 -6
  116. package/node_modules/hono/dist/adapter/cloudflare-workers/serve-static.js +26 -20
  117. package/node_modules/hono/dist/adapter/cloudflare-workers/utils.js +21 -34
  118. package/node_modules/hono/dist/adapter/cloudflare-workers/websocket.js +31 -39
  119. package/node_modules/hono/dist/adapter/deno/conninfo.js +16 -13
  120. package/node_modules/hono/dist/adapter/deno/deno.d.js +1 -0
  121. package/node_modules/hono/dist/adapter/deno/index.js +3 -10
  122. package/node_modules/hono/dist/adapter/deno/serve-static.js +33 -38
  123. package/node_modules/hono/dist/adapter/deno/ssg.js +27 -16
  124. package/node_modules/hono/dist/adapter/deno/websocket.js +30 -30
  125. package/node_modules/hono/dist/adapter/lambda-edge/conninfo.js +7 -9
  126. package/node_modules/hono/dist/adapter/lambda-edge/handler.js +102 -87
  127. package/node_modules/hono/dist/adapter/lambda-edge/index.js +2 -6
  128. package/node_modules/hono/dist/adapter/netlify/conninfo.js +24 -9
  129. package/node_modules/hono/dist/adapter/netlify/handler.js +10 -8
  130. package/node_modules/hono/dist/adapter/netlify/index.js +3 -2
  131. package/node_modules/hono/dist/adapter/netlify/mod.js +2 -6
  132. package/node_modules/hono/dist/adapter/service-worker/handler.js +15 -19
  133. package/node_modules/hono/dist/adapter/service-worker/index.js +23 -7
  134. package/node_modules/hono/dist/adapter/service-worker/types.js +1 -0
  135. package/node_modules/hono/dist/adapter/vercel/conninfo.js +7 -10
  136. package/node_modules/hono/dist/adapter/vercel/handler.js +8 -6
  137. package/node_modules/hono/dist/adapter/vercel/index.js +2 -6
  138. package/node_modules/hono/dist/cjs/_virtual/_rolldown/runtime.js +33 -0
  139. package/node_modules/hono/dist/cjs/adapter/aws-lambda/conninfo.js +42 -44
  140. package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +326 -370
  141. package/node_modules/hono/dist/cjs/adapter/aws-lambda/index.js +7 -34
  142. package/node_modules/hono/dist/cjs/adapter/aws-lambda/types.js +0 -15
  143. package/node_modules/hono/dist/cjs/adapter/bun/conninfo.js +21 -47
  144. package/node_modules/hono/dist/cjs/adapter/bun/index.js +14 -45
  145. package/node_modules/hono/dist/cjs/adapter/bun/serve-static.js +29 -50
  146. package/node_modules/hono/dist/cjs/adapter/bun/server.js +11 -26
  147. package/node_modules/hono/dist/cjs/adapter/bun/ssg.js +24 -35
  148. package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +63 -91
  149. package/node_modules/hono/dist/cjs/adapter/cloudflare-pages/conninfo.js +25 -31
  150. package/node_modules/hono/dist/cjs/adapter/cloudflare-pages/handler.js +61 -85
  151. package/node_modules/hono/dist/cjs/adapter/cloudflare-pages/index.js +7 -34
  152. package/node_modules/hono/dist/cjs/adapter/cloudflare-workers/conninfo.js +8 -31
  153. package/node_modules/hono/dist/cjs/adapter/cloudflare-workers/index.js +7 -33
  154. package/node_modules/hono/dist/cjs/adapter/cloudflare-workers/serve-static-module.js +7 -29
  155. package/node_modules/hono/dist/cjs/adapter/cloudflare-workers/serve-static.js +27 -42
  156. package/node_modules/hono/dist/cjs/adapter/cloudflare-workers/utils.js +21 -55
  157. package/node_modules/hono/dist/cjs/adapter/cloudflare-workers/websocket.js +33 -62
  158. package/node_modules/hono/dist/cjs/adapter/deno/conninfo.js +16 -34
  159. package/node_modules/hono/dist/cjs/adapter/deno/index.js +10 -38
  160. package/node_modules/hono/dist/cjs/adapter/deno/serve-static.js +33 -59
  161. package/node_modules/hono/dist/cjs/adapter/deno/ssg.js +27 -37
  162. package/node_modules/hono/dist/cjs/adapter/deno/websocket.js +32 -53
  163. package/node_modules/hono/dist/cjs/adapter/lambda-edge/conninfo.js +8 -31
  164. package/node_modules/hono/dist/cjs/adapter/lambda-edge/handler.js +105 -119
  165. package/node_modules/hono/dist/cjs/adapter/lambda-edge/index.js +5 -30
  166. package/node_modules/hono/dist/cjs/adapter/netlify/conninfo.js +25 -31
  167. package/node_modules/hono/dist/cjs/adapter/netlify/handler.js +10 -29
  168. package/node_modules/hono/dist/cjs/adapter/netlify/index.js +5 -21
  169. package/node_modules/hono/dist/cjs/adapter/netlify/mod.js +5 -30
  170. package/node_modules/hono/dist/cjs/adapter/service-worker/handler.js +16 -41
  171. package/node_modules/hono/dist/cjs/adapter/service-worker/index.js +25 -30
  172. package/node_modules/hono/dist/cjs/adapter/service-worker/types.js +0 -15
  173. package/node_modules/hono/dist/cjs/adapter/vercel/conninfo.js +8 -32
  174. package/node_modules/hono/dist/cjs/adapter/vercel/handler.js +8 -27
  175. package/node_modules/hono/dist/cjs/adapter/vercel/index.js +5 -30
  176. package/node_modules/hono/dist/cjs/client/client.js +139 -212
  177. package/node_modules/hono/dist/cjs/client/fetch-result-please.js +62 -80
  178. package/node_modules/hono/dist/cjs/client/index.js +7 -32
  179. package/node_modules/hono/dist/cjs/client/types.js +0 -15
  180. package/node_modules/hono/dist/cjs/client/utils.js +54 -92
  181. package/node_modules/hono/dist/cjs/compose.js +49 -66
  182. package/node_modules/hono/dist/cjs/context.js +379 -450
  183. package/node_modules/hono/dist/cjs/helper/accepts/accepts.js +47 -70
  184. package/node_modules/hono/dist/cjs/helper/accepts/index.js +3 -27
  185. package/node_modules/hono/dist/cjs/helper/adapter/index.js +33 -73
  186. package/node_modules/hono/dist/cjs/helper/conninfo/index.js +0 -15
  187. package/node_modules/hono/dist/cjs/helper/conninfo/types.js +0 -15
  188. package/node_modules/hono/dist/cjs/helper/cookie/index.js +75 -116
  189. package/node_modules/hono/dist/cjs/helper/css/common.js +165 -244
  190. package/node_modules/hono/dist/cjs/helper/css/index.js +136 -151
  191. package/node_modules/hono/dist/cjs/helper/dev/index.js +45 -71
  192. package/node_modules/hono/dist/cjs/helper/factory/index.js +30 -51
  193. package/node_modules/hono/dist/cjs/helper/html/index.js +32 -62
  194. package/node_modules/hono/dist/cjs/helper/proxy/index.js +113 -106
  195. package/node_modules/hono/dist/cjs/helper/route/index.js +123 -66
  196. package/node_modules/hono/dist/cjs/helper/ssg/index.js +19 -43
  197. package/node_modules/hono/dist/cjs/helper/ssg/middleware.js +56 -64
  198. package/node_modules/hono/dist/cjs/helper/ssg/plugins.js +55 -57
  199. package/node_modules/hono/dist/cjs/helper/ssg/ssg.js +196 -296
  200. package/node_modules/hono/dist/cjs/helper/ssg/utils.js +47 -90
  201. package/node_modules/hono/dist/cjs/helper/streaming/index.js +8 -35
  202. package/node_modules/hono/dist/cjs/helper/streaming/sse.js +53 -85
  203. package/node_modules/hono/dist/cjs/helper/streaming/stream.js +23 -53
  204. package/node_modules/hono/dist/cjs/helper/streaming/text.js +10 -32
  205. package/node_modules/hono/dist/cjs/helper/streaming/utils.js +13 -32
  206. package/node_modules/hono/dist/cjs/helper/testing/index.js +16 -31
  207. package/node_modules/hono/dist/cjs/helper/websocket/index.js +51 -76
  208. package/node_modules/hono/dist/cjs/hono-base.js +345 -403
  209. package/node_modules/hono/dist/cjs/hono.js +28 -42
  210. package/node_modules/hono/dist/cjs/http-exception.js +55 -56
  211. package/node_modules/hono/dist/cjs/index.js +22 -30
  212. package/node_modules/hono/dist/cjs/jsx/base.js +237 -366
  213. package/node_modules/hono/dist/cjs/jsx/children.js +16 -41
  214. package/node_modules/hono/dist/cjs/jsx/components.js +119 -192
  215. package/node_modules/hono/dist/cjs/jsx/constants.js +15 -42
  216. package/node_modules/hono/dist/cjs/jsx/context.js +144 -162
  217. package/node_modules/hono/dist/cjs/jsx/dom/client.js +49 -69
  218. package/node_modules/hono/dist/cjs/jsx/dom/components.js +23 -52
  219. package/node_modules/hono/dist/cjs/jsx/dom/context.js +39 -67
  220. package/node_modules/hono/dist/cjs/jsx/dom/css.js +143 -158
  221. package/node_modules/hono/dist/cjs/jsx/dom/hooks/index.js +55 -64
  222. package/node_modules/hono/dist/cjs/jsx/dom/index.js +114 -173
  223. package/node_modules/hono/dist/cjs/jsx/dom/intrinsic-element/components.js +282 -375
  224. package/node_modules/hono/dist/cjs/jsx/dom/jsx-dev-runtime.js +14 -49
  225. package/node_modules/hono/dist/cjs/jsx/dom/jsx-runtime.js +5 -32
  226. package/node_modules/hono/dist/cjs/jsx/dom/render.js +469 -623
  227. package/node_modules/hono/dist/cjs/jsx/dom/server.js +37 -64
  228. package/node_modules/hono/dist/cjs/jsx/dom/utils.js +7 -30
  229. package/node_modules/hono/dist/cjs/jsx/hooks/index.js +225 -318
  230. package/node_modules/hono/dist/cjs/jsx/index.js +86 -135
  231. package/node_modules/hono/dist/cjs/jsx/intrinsic-element/common.js +20 -43
  232. package/node_modules/hono/dist/cjs/jsx/intrinsic-element/components.js +117 -168
  233. package/node_modules/hono/dist/cjs/jsx/intrinsic-elements.js +0 -15
  234. package/node_modules/hono/dist/cjs/jsx/jsx-dev-runtime.js +14 -39
  235. package/node_modules/hono/dist/cjs/jsx/jsx-runtime.js +34 -68
  236. package/node_modules/hono/dist/cjs/jsx/streaming.js +123 -166
  237. package/node_modules/hono/dist/cjs/jsx/types.js +0 -15
  238. package/node_modules/hono/dist/cjs/jsx/utils.js +91 -175
  239. package/node_modules/hono/dist/cjs/middleware/basic-auth/index.js +98 -86
  240. package/node_modules/hono/dist/cjs/middleware/bearer-auth/index.js +92 -109
  241. package/node_modules/hono/dist/cjs/middleware/body-limit/index.js +66 -72
  242. package/node_modules/hono/dist/cjs/middleware/cache/index.js +153 -199
  243. package/node_modules/hono/dist/cjs/middleware/combine/index.js +135 -95
  244. package/node_modules/hono/dist/cjs/middleware/compress/index.js +73 -88
  245. package/node_modules/hono/dist/cjs/middleware/context-storage/index.js +49 -41
  246. package/node_modules/hono/dist/cjs/middleware/cors/index.js +107 -107
  247. package/node_modules/hono/dist/cjs/middleware/csrf/index.js +101 -72
  248. package/node_modules/hono/dist/cjs/middleware/etag/digest.js +58 -97
  249. package/node_modules/hono/dist/cjs/middleware/etag/index.js +71 -91
  250. package/node_modules/hono/dist/cjs/middleware/ip-restriction/index.js +161 -169
  251. package/node_modules/hono/dist/cjs/middleware/jsx-renderer/index.js +99 -77
  252. package/node_modules/hono/dist/cjs/middleware/jwk/index.js +3 -27
  253. package/node_modules/hono/dist/cjs/middleware/jwk/jwk.js +118 -135
  254. package/node_modules/hono/dist/cjs/middleware/jwt/index.js +9 -38
  255. package/node_modules/hono/dist/cjs/middleware/jwt/jwt.js +120 -141
  256. package/node_modules/hono/dist/cjs/middleware/language/index.js +7 -35
  257. package/node_modules/hono/dist/cjs/middleware/language/language.js +184 -182
  258. package/node_modules/hono/dist/cjs/middleware/logger/index.js +41 -62
  259. package/node_modules/hono/dist/cjs/middleware/method-not-allowed/index.js +82 -88
  260. package/node_modules/hono/dist/cjs/middleware/method-override/index.js +101 -102
  261. package/node_modules/hono/dist/cjs/middleware/powered-by/index.js +23 -30
  262. package/node_modules/hono/dist/cjs/middleware/pretty-json/index.js +38 -36
  263. package/node_modules/hono/dist/cjs/middleware/request-id/index.js +3 -27
  264. package/node_modules/hono/dist/cjs/middleware/request-id/request-id.js +34 -42
  265. package/node_modules/hono/dist/cjs/middleware/secure-headers/index.js +4 -29
  266. package/node_modules/hono/dist/cjs/middleware/secure-headers/permissions-policy.js +0 -15
  267. package/node_modules/hono/dist/cjs/middleware/secure-headers/secure-headers.js +142 -174
  268. package/node_modules/hono/dist/cjs/middleware/serve-static/index.js +56 -93
  269. package/node_modules/hono/dist/cjs/middleware/serve-static/path.js +15 -38
  270. package/node_modules/hono/dist/cjs/middleware/timeout/index.js +40 -45
  271. package/node_modules/hono/dist/cjs/middleware/timing/index.js +7 -35
  272. package/node_modules/hono/dist/cjs/middleware/timing/timing.js +177 -118
  273. package/node_modules/hono/dist/cjs/middleware/trailing-slash/index.js +85 -58
  274. package/node_modules/hono/dist/cjs/preset/quick.js +18 -37
  275. package/node_modules/hono/dist/cjs/preset/tiny.js +15 -33
  276. package/node_modules/hono/dist/cjs/request/constants.js +5 -27
  277. package/node_modules/hono/dist/cjs/request.js +334 -346
  278. package/node_modules/hono/dist/cjs/router/linear-router/index.js +3 -27
  279. package/node_modules/hono/dist/cjs/router/linear-router/router.js +95 -143
  280. package/node_modules/hono/dist/cjs/router/pattern-router/index.js +3 -27
  281. package/node_modules/hono/dist/cjs/router/pattern-router/router.js +41 -63
  282. package/node_modules/hono/dist/cjs/router/reg-exp-router/index.js +7 -34
  283. package/node_modules/hono/dist/cjs/router/reg-exp-router/matcher.js +18 -45
  284. package/node_modules/hono/dist/cjs/router/reg-exp-router/node.js +91 -135
  285. package/node_modules/hono/dist/cjs/router/reg-exp-router/prepared-router.js +92 -161
  286. package/node_modules/hono/dist/cjs/router/reg-exp-router/router.js +98 -147
  287. package/node_modules/hono/dist/cjs/router/reg-exp-router/trie.js +73 -89
  288. package/node_modules/hono/dist/cjs/router/smart-router/index.js +3 -27
  289. package/node_modules/hono/dist/cjs/router/smart-router/router.js +49 -79
  290. package/node_modules/hono/dist/cjs/router/trie-router/index.js +3 -27
  291. package/node_modules/hono/dist/cjs/router/trie-router/node.js +134 -186
  292. package/node_modules/hono/dist/cjs/router/trie-router/router.js +15 -39
  293. package/node_modules/hono/dist/cjs/router/utils.js +5 -27
  294. package/node_modules/hono/dist/cjs/router.js +37 -37
  295. package/node_modules/hono/dist/cjs/types.js +5 -28
  296. package/node_modules/hono/dist/cjs/utils/accept.js +177 -225
  297. package/node_modules/hono/dist/cjs/utils/basic-auth.js +16 -40
  298. package/node_modules/hono/dist/cjs/utils/body.js +84 -110
  299. package/node_modules/hono/dist/cjs/utils/buffer.js +43 -91
  300. package/node_modules/hono/dist/cjs/utils/color.js +35 -44
  301. package/node_modules/hono/dist/cjs/utils/compress.js +11 -26
  302. package/node_modules/hono/dist/cjs/utils/concurrent.js +29 -59
  303. package/node_modules/hono/dist/cjs/utils/constants.js +7 -26
  304. package/node_modules/hono/dist/cjs/utils/cookie.js +107 -177
  305. package/node_modules/hono/dist/cjs/utils/crypto.js +30 -61
  306. package/node_modules/hono/dist/cjs/utils/encode.js +31 -48
  307. package/node_modules/hono/dist/cjs/utils/filepath.js +23 -54
  308. package/node_modules/hono/dist/cjs/utils/handler.js +11 -33
  309. package/node_modules/hono/dist/cjs/utils/headers.js +0 -15
  310. package/node_modules/hono/dist/cjs/utils/html.js +96 -137
  311. package/node_modules/hono/dist/cjs/utils/http-status.js +0 -15
  312. package/node_modules/hono/dist/cjs/utils/ipaddr.js +213 -286
  313. package/node_modules/hono/dist/cjs/utils/jwt/index.js +14 -27
  314. package/node_modules/hono/dist/cjs/utils/jwt/jwa.js +25 -42
  315. package/node_modules/hono/dist/cjs/utils/jwt/jws.js +119 -199
  316. package/node_modules/hono/dist/cjs/utils/jwt/jwt.js +122 -205
  317. package/node_modules/hono/dist/cjs/utils/jwt/types.js +122 -159
  318. package/node_modules/hono/dist/cjs/utils/jwt/utf8.js +9 -28
  319. package/node_modules/hono/dist/cjs/utils/mime.js +75 -101
  320. package/node_modules/hono/dist/cjs/utils/stream.js +88 -111
  321. package/node_modules/hono/dist/cjs/utils/types.js +0 -15
  322. package/node_modules/hono/dist/cjs/utils/url.js +185 -234
  323. package/node_modules/hono/dist/cjs/validator/index.js +3 -27
  324. package/node_modules/hono/dist/cjs/validator/utils.js +0 -15
  325. package/node_modules/hono/dist/cjs/validator/validator.js +60 -103
  326. package/node_modules/hono/dist/client/client.js +138 -197
  327. package/node_modules/hono/dist/client/fetch-result-please.js +59 -56
  328. package/node_modules/hono/dist/client/index.js +3 -7
  329. package/node_modules/hono/dist/client/types.js +1 -0
  330. package/node_modules/hono/dist/client/utils.js +51 -68
  331. package/node_modules/hono/dist/compose.js +49 -45
  332. package/node_modules/hono/dist/context.js +376 -426
  333. package/node_modules/hono/dist/helper/accepts/accepts.js +47 -49
  334. package/node_modules/hono/dist/helper/accepts/index.js +1 -4
  335. package/node_modules/hono/dist/helper/adapter/index.js +33 -52
  336. package/node_modules/hono/dist/helper/conninfo/index.js +1 -0
  337. package/node_modules/hono/dist/helper/conninfo/types.js +1 -0
  338. package/node_modules/hono/dist/helper/cookie/index.js +74 -94
  339. package/node_modules/hono/dist/helper/css/common.js +167 -225
  340. package/node_modules/hono/dist/helper/css/index.js +132 -137
  341. package/node_modules/hono/dist/helper/dev/index.js +44 -49
  342. package/node_modules/hono/dist/helper/factory/index.js +27 -27
  343. package/node_modules/hono/dist/helper/html/index.js +30 -39
  344. package/node_modules/hono/dist/helper/proxy/index.js +116 -88
  345. package/node_modules/hono/dist/helper/route/index.js +121 -43
  346. package/node_modules/hono/dist/helper/ssg/index.js +3 -18
  347. package/node_modules/hono/dist/helper/ssg/middleware.js +53 -40
  348. package/node_modules/hono/dist/helper/ssg/plugins.js +55 -36
  349. package/node_modules/hono/dist/helper/ssg/ssg.js +198 -283
  350. package/node_modules/hono/dist/helper/ssg/utils.js +53 -75
  351. package/node_modules/hono/dist/helper/streaming/index.js +2 -8
  352. package/node_modules/hono/dist/helper/streaming/sse.js +50 -61
  353. package/node_modules/hono/dist/helper/streaming/stream.js +22 -31
  354. package/node_modules/hono/dist/helper/streaming/text.js +9 -10
  355. package/node_modules/hono/dist/helper/streaming/utils.js +9 -12
  356. package/node_modules/hono/dist/helper/testing/index.js +16 -10
  357. package/node_modules/hono/dist/helper/websocket/index.js +49 -53
  358. package/node_modules/hono/dist/hono-base.js +342 -379
  359. package/node_modules/hono/dist/hono.js +27 -20
  360. package/node_modules/hono/dist/http-exception.js +53 -33
  361. package/node_modules/hono/dist/index.js +19 -6
  362. package/node_modules/hono/dist/jsx/base.js +231 -340
  363. package/node_modules/hono/dist/jsx/children.js +16 -20
  364. package/node_modules/hono/dist/jsx/components.js +118 -170
  365. package/node_modules/hono/dist/jsx/constants.js +9 -15
  366. package/node_modules/hono/dist/jsx/context.js +153 -150
  367. package/node_modules/hono/dist/jsx/dom/client.js +45 -48
  368. package/node_modules/hono/dist/jsx/dom/components.js +21 -29
  369. package/node_modules/hono/dist/jsx/dom/context.js +37 -44
  370. package/node_modules/hono/dist/jsx/dom/css.js +142 -147
  371. package/node_modules/hono/dist/jsx/dom/hooks/index.js +52 -40
  372. package/node_modules/hono/dist/jsx/dom/index.js +71 -134
  373. package/node_modules/hono/dist/jsx/dom/intrinsic-element/components.js +275 -359
  374. package/node_modules/hono/dist/jsx/dom/jsx-dev-runtime.js +14 -18
  375. package/node_modules/hono/dist/jsx/dom/jsx-runtime.js +2 -8
  376. package/node_modules/hono/dist/jsx/dom/render.js +492 -631
  377. package/node_modules/hono/dist/jsx/dom/server.js +32 -32
  378. package/node_modules/hono/dist/jsx/dom/utils.js +6 -8
  379. package/node_modules/hono/dist/jsx/hooks/index.js +236 -308
  380. package/node_modules/hono/dist/jsx/index.js +45 -98
  381. package/node_modules/hono/dist/jsx/intrinsic-element/common.js +20 -22
  382. package/node_modules/hono/dist/jsx/intrinsic-element/components.js +113 -154
  383. package/node_modules/hono/dist/jsx/intrinsic-elements.js +1 -0
  384. package/node_modules/hono/dist/jsx/jsx-dev-runtime.js +12 -16
  385. package/node_modules/hono/dist/jsx/jsx-runtime.js +29 -42
  386. package/node_modules/hono/dist/jsx/streaming.js +120 -142
  387. package/node_modules/hono/dist/jsx/types.js +1 -0
  388. package/node_modules/hono/dist/jsx/utils.js +105 -168
  389. package/node_modules/hono/dist/middleware/basic-auth/index.js +96 -63
  390. package/node_modules/hono/dist/middleware/bearer-auth/index.js +93 -89
  391. package/node_modules/hono/dist/middleware/body-limit/index.js +66 -51
  392. package/node_modules/hono/dist/middleware/cache/index.js +165 -190
  393. package/node_modules/hono/dist/middleware/combine/index.js +134 -73
  394. package/node_modules/hono/dist/middleware/compress/index.js +75 -69
  395. package/node_modules/hono/dist/middleware/context-storage/index.js +49 -19
  396. package/node_modules/hono/dist/middleware/cors/index.js +107 -86
  397. package/node_modules/hono/dist/middleware/csrf/index.js +103 -53
  398. package/node_modules/hono/dist/middleware/etag/digest.js +59 -77
  399. package/node_modules/hono/dist/middleware/etag/index.js +71 -70
  400. package/node_modules/hono/dist/middleware/ip-restriction/index.js +163 -158
  401. package/node_modules/hono/dist/middleware/jsx-renderer/index.js +97 -54
  402. package/node_modules/hono/dist/middleware/jwk/index.js +1 -4
  403. package/node_modules/hono/dist/middleware/jwk/jwk.js +116 -112
  404. package/node_modules/hono/dist/middleware/jwt/index.js +2 -10
  405. package/node_modules/hono/dist/middleware/jwt/jwt.js +114 -114
  406. package/node_modules/hono/dist/middleware/language/index.js +2 -15
  407. package/node_modules/hono/dist/middleware/language/language.js +180 -157
  408. package/node_modules/hono/dist/middleware/logger/index.js +43 -37
  409. package/node_modules/hono/dist/middleware/method-not-allowed/index.js +81 -66
  410. package/node_modules/hono/dist/middleware/method-override/index.js +101 -81
  411. package/node_modules/hono/dist/middleware/powered-by/index.js +23 -9
  412. package/node_modules/hono/dist/middleware/pretty-json/index.js +39 -16
  413. package/node_modules/hono/dist/middleware/request-id/index.js +1 -4
  414. package/node_modules/hono/dist/middleware/request-id/request-id.js +33 -20
  415. package/node_modules/hono/dist/middleware/secure-headers/index.js +1 -5
  416. package/node_modules/hono/dist/middleware/secure-headers/permissions-policy.js +1 -0
  417. package/node_modules/hono/dist/middleware/secure-headers/secure-headers.js +144 -155
  418. package/node_modules/hono/dist/middleware/serve-static/index.js +56 -72
  419. package/node_modules/hono/dist/middleware/serve-static/path.js +15 -17
  420. package/node_modules/hono/dist/middleware/timeout/index.js +40 -23
  421. package/node_modules/hono/dist/middleware/timing/index.js +2 -9
  422. package/node_modules/hono/dist/middleware/timing/timing.js +177 -97
  423. package/node_modules/hono/dist/middleware/trailing-slash/index.js +85 -37
  424. package/node_modules/hono/dist/preset/quick.js +17 -15
  425. package/node_modules/hono/dist/preset/tiny.js +14 -11
  426. package/node_modules/hono/dist/request/constants.js +4 -5
  427. package/node_modules/hono/dist/request.js +328 -319
  428. package/node_modules/hono/dist/router/linear-router/index.js +1 -4
  429. package/node_modules/hono/dist/router/linear-router/router.js +93 -120
  430. package/node_modules/hono/dist/router/pattern-router/index.js +1 -4
  431. package/node_modules/hono/dist/router/pattern-router/router.js +39 -40
  432. package/node_modules/hono/dist/router/reg-exp-router/index.js +1 -7
  433. package/node_modules/hono/dist/router/reg-exp-router/matcher.js +17 -23
  434. package/node_modules/hono/dist/router/reg-exp-router/node.js +87 -110
  435. package/node_modules/hono/dist/router/reg-exp-router/prepared-router.js +89 -137
  436. package/node_modules/hono/dist/router/reg-exp-router/router.js +92 -129
  437. package/node_modules/hono/dist/router/reg-exp-router/trie.js +69 -64
  438. package/node_modules/hono/dist/router/smart-router/index.js +1 -4
  439. package/node_modules/hono/dist/router/smart-router/router.js +46 -55
  440. package/node_modules/hono/dist/router/trie-router/index.js +1 -4
  441. package/node_modules/hono/dist/router/trie-router/node.js +131 -162
  442. package/node_modules/hono/dist/router/trie-router/router.js +11 -14
  443. package/node_modules/hono/dist/router/utils.js +4 -5
  444. package/node_modules/hono/dist/router.js +35 -14
  445. package/node_modules/hono/dist/types/adapter/aws-lambda/conninfo.d.ts +4 -1
  446. package/node_modules/hono/dist/types/adapter/aws-lambda/handler.d.ts +150 -104
  447. package/node_modules/hono/dist/types/adapter/aws-lambda/index.d.ts +4 -8
  448. package/node_modules/hono/dist/types/adapter/aws-lambda/types.d.ts +152 -122
  449. package/node_modules/hono/dist/types/adapter/bun/conninfo.d.ts +4 -1
  450. package/node_modules/hono/dist/types/adapter/bun/index.d.ts +6 -10
  451. package/node_modules/hono/dist/types/adapter/bun/serve-static.d.ts +7 -2
  452. package/node_modules/hono/dist/types/adapter/bun/server.d.ts +4 -5
  453. package/node_modules/hono/dist/types/adapter/bun/ssg.d.ts +5 -1
  454. package/node_modules/hono/dist/types/adapter/bun/websocket.d.ts +31 -16
  455. package/node_modules/hono/dist/types/adapter/cloudflare-pages/conninfo.d.ts +4 -1
  456. package/node_modules/hono/dist/types/adapter/cloudflare-pages/handler.d.ts +29 -17
  457. package/node_modules/hono/dist/types/adapter/cloudflare-pages/index.d.ts +3 -7
  458. package/node_modules/hono/dist/types/adapter/cloudflare-workers/conninfo.d.ts +6 -1
  459. package/node_modules/hono/dist/types/adapter/cloudflare-workers/index.d.ts +4 -7
  460. package/node_modules/hono/dist/types/adapter/cloudflare-workers/serve-static-module.d.ts +5 -2
  461. package/node_modules/hono/dist/types/adapter/cloudflare-workers/serve-static.d.ts +10 -5
  462. package/node_modules/hono/dist/types/adapter/cloudflare-workers/utils.d.ts +10 -2
  463. package/node_modules/hono/dist/types/adapter/cloudflare-workers/websocket.d.ts +6 -1
  464. package/node_modules/hono/dist/types/adapter/deno/conninfo.d.ts +4 -1
  465. package/node_modules/hono/dist/types/adapter/deno/deno.d.ts +1 -0
  466. package/node_modules/hono/dist/types/adapter/deno/index.d.ts +5 -8
  467. package/node_modules/hono/dist/types/adapter/deno/serve-static.d.ts +7 -2
  468. package/node_modules/hono/dist/types/adapter/deno/ssg.d.ts +5 -1
  469. package/node_modules/hono/dist/types/adapter/deno/websocket.d.ts +6 -1
  470. package/node_modules/hono/dist/types/adapter/lambda-edge/conninfo.d.ts +6 -1
  471. package/node_modules/hono/dist/types/adapter/lambda-edge/handler.d.ts +83 -57
  472. package/node_modules/hono/dist/types/adapter/lambda-edge/index.d.ts +3 -7
  473. package/node_modules/hono/dist/types/adapter/netlify/conninfo.d.ts +4 -1
  474. package/node_modules/hono/dist/types/adapter/netlify/handler.d.ts +6 -1
  475. package/node_modules/hono/dist/types/adapter/netlify/index.d.ts +3 -5
  476. package/node_modules/hono/dist/types/adapter/netlify/mod.d.ts +3 -2
  477. package/node_modules/hono/dist/types/adapter/service-worker/handler.d.ts +9 -7
  478. package/node_modules/hono/dist/types/adapter/service-worker/index.d.ts +7 -9
  479. package/node_modules/hono/dist/types/adapter/service-worker/types.d.ts +12 -7
  480. package/node_modules/hono/dist/types/adapter/vercel/conninfo.d.ts +6 -1
  481. package/node_modules/hono/dist/types/adapter/vercel/handler.d.ts +6 -1
  482. package/node_modules/hono/dist/types/adapter/vercel/index.d.ts +3 -6
  483. package/node_modules/hono/dist/types/client/client.d.ts +5 -3
  484. package/node_modules/hono/dist/types/client/fetch-result-please.d.ts +21 -19
  485. package/node_modules/hono/dist/types/client/index.d.ts +5 -7
  486. package/node_modules/hono/dist/types/client/types.d.ts +134 -159
  487. package/node_modules/hono/dist/types/client/utils.d.ts +6 -4
  488. package/node_modules/hono/dist/types/compose.d.ts +4 -2
  489. package/node_modules/hono/dist/types/context.d.ts +335 -335
  490. package/node_modules/hono/dist/types/helper/accepts/accepts.d.ts +11 -9
  491. package/node_modules/hono/dist/types/helper/accepts/index.d.ts +2 -5
  492. package/node_modules/hono/dist/types/helper/adapter/index.d.ts +4 -6
  493. package/node_modules/hono/dist/types/helper/conninfo/index.d.ts +2 -5
  494. package/node_modules/hono/dist/types/helper/conninfo/types.d.ts +25 -23
  495. package/node_modules/hono/dist/types/helper/cookie/index.d.ts +10 -12
  496. package/node_modules/hono/dist/types/helper/css/common.d.ts +11 -9
  497. package/node_modules/hono/dist/types/helper/css/index.d.ts +26 -28
  498. package/node_modules/hono/dist/types/helper/dev/index.d.ts +10 -12
  499. package/node_modules/hono/dist/types/helper/factory/index.d.ts +26 -73
  500. package/node_modules/hono/dist/types/helper/html/index.d.ts +4 -7
  501. package/node_modules/hono/dist/types/helper/proxy/index.d.ts +19 -21
  502. package/node_modules/hono/dist/types/helper/route/index.d.ts +4 -2
  503. package/node_modules/hono/dist/types/helper/ssg/index.d.ts +4 -7
  504. package/node_modules/hono/dist/types/helper/ssg/middleware.d.ts +8 -6
  505. package/node_modules/hono/dist/types/helper/ssg/plugins.d.ts +3 -1
  506. package/node_modules/hono/dist/types/helper/ssg/ssg.d.ts +38 -36
  507. package/node_modules/hono/dist/types/helper/ssg/utils.d.ts +5 -3
  508. package/node_modules/hono/dist/types/helper/streaming/index.d.ts +4 -8
  509. package/node_modules/hono/dist/types/helper/streaming/sse.d.ts +10 -8
  510. package/node_modules/hono/dist/types/helper/streaming/stream.d.ts +4 -2
  511. package/node_modules/hono/dist/types/helper/streaming/text.d.ts +4 -2
  512. package/node_modules/hono/dist/types/helper/streaming/utils.d.ts +2 -0
  513. package/node_modules/hono/dist/types/helper/testing/index.d.ts +7 -9
  514. package/node_modules/hono/dist/types/helper/websocket/index.d.ts +30 -33
  515. package/node_modules/hono/dist/types/hono-base.d.ts +208 -210
  516. package/node_modules/hono/dist/types/hono.d.ts +11 -10
  517. package/node_modules/hono/dist/types/http-exception.d.ts +20 -22
  518. package/node_modules/hono/dist/types/index.d.ts +6 -37
  519. package/node_modules/hono/dist/types/jsx/base.d.ts +36 -34
  520. package/node_modules/hono/dist/types/jsx/children.d.ts +8 -6
  521. package/node_modules/hono/dist/types/jsx/components.d.ts +8 -5
  522. package/node_modules/hono/dist/types/jsx/constants.d.ts +2 -0
  523. package/node_modules/hono/dist/types/jsx/context.d.ts +9 -6
  524. package/node_modules/hono/dist/types/jsx/dom/client.d.ts +9 -10
  525. package/node_modules/hono/dist/types/jsx/dom/components.d.ts +9 -6
  526. package/node_modules/hono/dist/types/jsx/dom/context.d.ts +3 -1
  527. package/node_modules/hono/dist/types/jsx/dom/css.d.ts +27 -30
  528. package/node_modules/hono/dist/types/jsx/dom/hooks/index.d.ts +11 -12
  529. package/node_modules/hono/dist/types/jsx/dom/index.d.ts +79 -83
  530. package/node_modules/hono/dist/types/jsx/dom/intrinsic-element/components.d.ts +9 -5
  531. package/node_modules/hono/dist/types/jsx/dom/jsx-dev-runtime.d.ts +4 -6
  532. package/node_modules/hono/dist/types/jsx/dom/jsx-runtime.d.ts +3 -7
  533. package/node_modules/hono/dist/types/jsx/dom/render.d.ts +32 -50
  534. package/node_modules/hono/dist/types/jsx/dom/server.d.ts +87 -85
  535. package/node_modules/hono/dist/types/jsx/dom/utils.d.ts +2 -0
  536. package/node_modules/hono/dist/types/jsx/hooks/index.d.ts +16 -16
  537. package/node_modules/hono/dist/types/jsx/index.d.ts +71 -73
  538. package/node_modules/hono/dist/types/jsx/intrinsic-element/common.d.ts +3 -1
  539. package/node_modules/hono/dist/types/jsx/intrinsic-element/components.d.ts +7 -4
  540. package/node_modules/hono/dist/types/jsx/intrinsic-elements.d.ts +708 -708
  541. package/node_modules/hono/dist/types/jsx/jsx-dev-runtime.d.ts +4 -7
  542. package/node_modules/hono/dist/types/jsx/jsx-runtime.d.ts +7 -10
  543. package/node_modules/hono/dist/types/jsx/streaming.d.ts +9 -10
  544. package/node_modules/hono/dist/types/jsx/types.d.ts +12 -13
  545. package/node_modules/hono/dist/types/jsx/utils.d.ts +2 -0
  546. package/node_modules/hono/dist/types/middleware/basic-auth/index.d.ts +17 -19
  547. package/node_modules/hono/dist/types/middleware/bearer-auth/index.d.ts +46 -48
  548. package/node_modules/hono/dist/types/middleware/body-limit/index.d.ts +6 -8
  549. package/node_modules/hono/dist/types/middleware/cache/index.d.ts +13 -15
  550. package/node_modules/hono/dist/types/middleware/combine/index.d.ts +4 -6
  551. package/node_modules/hono/dist/types/middleware/compress/index.d.ts +9 -10
  552. package/node_modules/hono/dist/types/middleware/context-storage/index.d.ts +4 -6
  553. package/node_modules/hono/dist/types/middleware/cors/index.d.ts +10 -12
  554. package/node_modules/hono/dist/types/middleware/csrf/index.d.ts +6 -8
  555. package/node_modules/hono/dist/types/middleware/etag/digest.d.ts +2 -0
  556. package/node_modules/hono/dist/types/middleware/etag/index.d.ts +6 -8
  557. package/node_modules/hono/dist/types/middleware/ip-restriction/index.d.ts +11 -12
  558. package/node_modules/hono/dist/types/middleware/jsx-renderer/index.d.ts +11 -11
  559. package/node_modules/hono/dist/types/middleware/jwk/index.d.ts +2 -1
  560. package/node_modules/hono/dist/types/middleware/jwk/jwk.d.ts +20 -23
  561. package/node_modules/hono/dist/types/middleware/jwt/index.d.ts +7 -6
  562. package/node_modules/hono/dist/types/middleware/jwt/jwt.d.ts +28 -30
  563. package/node_modules/hono/dist/types/middleware/language/index.d.ts +6 -5
  564. package/node_modules/hono/dist/types/middleware/language/language.d.ts +42 -44
  565. package/node_modules/hono/dist/types/middleware/logger/index.d.ts +3 -5
  566. package/node_modules/hono/dist/types/middleware/method-not-allowed/index.d.ts +7 -9
  567. package/node_modules/hono/dist/types/middleware/method-override/index.d.ts +14 -16
  568. package/node_modules/hono/dist/types/middleware/powered-by/index.d.ts +8 -10
  569. package/node_modules/hono/dist/types/middleware/pretty-json/index.d.ts +18 -20
  570. package/node_modules/hono/dist/types/middleware/request-id/index.d.ts +6 -5
  571. package/node_modules/hono/dist/types/middleware/request-id/request-id.d.ts +9 -11
  572. package/node_modules/hono/dist/types/middleware/secure-headers/index.d.ts +6 -6
  573. package/node_modules/hono/dist/types/middleware/secure-headers/permissions-policy.d.ts +2 -0
  574. package/node_modules/hono/dist/types/middleware/secure-headers/secure-headers.d.ts +55 -57
  575. package/node_modules/hono/dist/types/middleware/serve-static/index.d.ts +24 -24
  576. package/node_modules/hono/dist/types/middleware/serve-static/path.d.ts +2 -0
  577. package/node_modules/hono/dist/types/middleware/timeout/index.d.ts +5 -7
  578. package/node_modules/hono/dist/types/middleware/timing/index.d.ts +6 -5
  579. package/node_modules/hono/dist/types/middleware/timing/timing.d.ts +17 -20
  580. package/node_modules/hono/dist/types/middleware/trailing-slash/index.d.ts +35 -37
  581. package/node_modules/hono/dist/types/preset/quick.d.ts +6 -9
  582. package/node_modules/hono/dist/types/preset/tiny.d.ts +6 -9
  583. package/node_modules/hono/dist/types/request/constants.d.ts +2 -0
  584. package/node_modules/hono/dist/types/request.d.ts +288 -286
  585. package/node_modules/hono/dist/types/router/linear-router/index.d.ts +2 -5
  586. package/node_modules/hono/dist/types/router/linear-router/router.d.ts +7 -5
  587. package/node_modules/hono/dist/types/router/pattern-router/index.d.ts +2 -5
  588. package/node_modules/hono/dist/types/router/pattern-router/router.d.ts +7 -5
  589. package/node_modules/hono/dist/types/router/reg-exp-router/index.d.ts +3 -6
  590. package/node_modules/hono/dist/types/router/reg-exp-router/matcher.d.ts +3 -1
  591. package/node_modules/hono/dist/types/router/reg-exp-router/node.d.ts +6 -4
  592. package/node_modules/hono/dist/types/router/reg-exp-router/prepared-router.d.ts +11 -10
  593. package/node_modules/hono/dist/types/router/reg-exp-router/router.d.ts +10 -9
  594. package/node_modules/hono/dist/types/router/reg-exp-router/trie.d.ts +7 -5
  595. package/node_modules/hono/dist/types/router/smart-router/index.d.ts +2 -5
  596. package/node_modules/hono/dist/types/router/smart-router/router.d.ts +11 -9
  597. package/node_modules/hono/dist/types/router/trie-router/index.d.ts +2 -5
  598. package/node_modules/hono/dist/types/router/trie-router/node.d.ts +6 -4
  599. package/node_modules/hono/dist/types/router/trie-router/router.d.ts +7 -5
  600. package/node_modules/hono/dist/types/router/utils.d.ts +2 -0
  601. package/node_modules/hono/dist/types/router.d.ts +23 -22
  602. package/node_modules/hono/dist/types/types.d.ts +146 -505
  603. package/node_modules/hono/dist/types/utils/accept.d.ts +5 -3
  604. package/node_modules/hono/dist/types/utils/basic-auth.d.ts +4 -2
  605. package/node_modules/hono/dist/types/utils/body.d.ts +46 -50
  606. package/node_modules/hono/dist/types/utils/buffer.d.ts +7 -5
  607. package/node_modules/hono/dist/types/utils/color.d.ts +2 -0
  608. package/node_modules/hono/dist/types/utils/compress.d.ts +2 -0
  609. package/node_modules/hono/dist/types/utils/concurrent.d.ts +6 -4
  610. package/node_modules/hono/dist/types/utils/constants.d.ts +2 -0
  611. package/node_modules/hono/dist/types/utils/cookie.d.ts +20 -18
  612. package/node_modules/hono/dist/types/utils/crypto.d.ts +5 -7
  613. package/node_modules/hono/dist/types/utils/encode.d.ts +2 -0
  614. package/node_modules/hono/dist/types/utils/filepath.d.ts +5 -3
  615. package/node_modules/hono/dist/types/utils/handler.d.ts +2 -0
  616. package/node_modules/hono/dist/types/utils/headers.d.ts +2 -0
  617. package/node_modules/hono/dist/types/utils/html.d.ts +11 -9
  618. package/node_modules/hono/dist/types/utils/http-status.d.ts +2 -0
  619. package/node_modules/hono/dist/types/utils/ipaddr.d.ts +4 -6
  620. package/node_modules/hono/dist/types/utils/jwt/index.d.ts +18 -12
  621. package/node_modules/hono/dist/types/utils/jwt/jwa.d.ts +15 -13
  622. package/node_modules/hono/dist/types/utils/jwt/jws.d.ts +4 -7
  623. package/node_modules/hono/dist/types/utils/jwt/jwt.d.ts +26 -29
  624. package/node_modules/hono/dist/types/utils/jwt/types.d.ts +48 -45
  625. package/node_modules/hono/dist/types/utils/jwt/utf8.d.ts +2 -0
  626. package/node_modules/hono/dist/types/utils/mime.d.ts +60 -57
  627. package/node_modules/hono/dist/types/utils/stream.d.ts +27 -25
  628. package/node_modules/hono/dist/types/utils/types.d.ts +14 -26
  629. package/node_modules/hono/dist/types/utils/url.d.ts +2 -0
  630. package/node_modules/hono/dist/types/validator/index.d.ts +3 -7
  631. package/node_modules/hono/dist/types/validator/utils.d.ts +6 -8
  632. package/node_modules/hono/dist/types/validator/validator.d.ts +11 -9
  633. package/node_modules/hono/dist/types.js +4 -6
  634. package/node_modules/hono/dist/utils/accept.js +185 -212
  635. package/node_modules/hono/dist/utils/basic-auth.js +18 -21
  636. package/node_modules/hono/dist/utils/body.js +87 -92
  637. package/node_modules/hono/dist/utils/buffer.js +44 -71
  638. package/node_modules/hono/dist/utils/color.js +33 -21
  639. package/node_modules/hono/dist/utils/compress.js +11 -5
  640. package/node_modules/hono/dist/utils/concurrent.js +29 -38
  641. package/node_modules/hono/dist/utils/constants.js +7 -5
  642. package/node_modules/hono/dist/utils/cookie.js +114 -163
  643. package/node_modules/hono/dist/utils/crypto.js +30 -40
  644. package/node_modules/hono/dist/utils/encode.js +30 -26
  645. package/node_modules/hono/dist/utils/filepath.js +23 -33
  646. package/node_modules/hono/dist/utils/handler.js +10 -11
  647. package/node_modules/hono/dist/utils/headers.js +1 -0
  648. package/node_modules/hono/dist/utils/html.js +97 -117
  649. package/node_modules/hono/dist/utils/http-status.js +1 -0
  650. package/node_modules/hono/dist/utils/ipaddr.js +227 -279
  651. package/node_modules/hono/dist/utils/jwt/index.js +12 -4
  652. package/node_modules/hono/dist/utils/jwt/jwa.js +24 -20
  653. package/node_modules/hono/dist/utils/jwt/jws.js +115 -174
  654. package/node_modules/hono/dist/utils/jwt/jwt.js +120 -197
  655. package/node_modules/hono/dist/utils/jwt/types.js +79 -95
  656. package/node_modules/hono/dist/utils/jwt/utf8.js +9 -7
  657. package/node_modules/hono/dist/utils/mime.js +74 -79
  658. package/node_modules/hono/dist/utils/stream.js +86 -88
  659. package/node_modules/hono/dist/utils/types.js +1 -0
  660. package/node_modules/hono/dist/utils/url.js +187 -215
  661. package/node_modules/hono/dist/validator/index.js +1 -4
  662. package/node_modules/hono/dist/validator/utils.js +1 -0
  663. package/node_modules/hono/dist/validator/validator.js +61 -83
  664. package/node_modules/hono/package.json +27 -27
  665. package/package.json +2 -2
  666. package/profiles/README.md +20 -0
  667. package/profiles/index.json +2 -1
  668. package/profiles/sales/0.1.profile.json +252 -0
  669. package/server.js +99 -0
  670. package/dist/ui/assets/index-DWpjjPIf.js +0 -110
@@ -5,8 +5,8 @@ import {
5
5
 
6
6
  // src/index.ts
7
7
  import { randomBytes as randomBytes2 } from "crypto";
8
- import { existsSync as existsSync7, readFileSync as readFileSync7, renameSync as renameSync2 } from "fs";
9
- import { dirname as dirname6, join as join8 } from "path";
8
+ import { existsSync as existsSync9, readFileSync as readFileSync10, 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";
@@ -33,6 +33,15 @@ var Vault = class {
33
33
  spSessionCookie = null;
34
34
  unsealedBy = null;
35
35
  dataDir;
36
+ /**
37
+ * When the AS session (captured at login into `spSessionCookie`) is due to
38
+ * end — unix seconds, from the login response's `sessionExpiresAt`. Held in
39
+ * memory only, exactly like the vault key and the cookie: never written to
40
+ * disk, gone the moment the process restarts or the vault locks.
41
+ */
42
+ spSessionExpiresAt = null;
43
+ /** Set by lockExpired(); cleared by any fresh unseal (a new login). */
44
+ lockedReason = null;
36
45
  constructor(dataDir) {
37
46
  this.dataDir = dataDir ?? process.env.SUVEREN_DATA_DIR ?? join(homedir(), ".suveren");
38
47
  }
@@ -59,6 +68,7 @@ var Vault = class {
59
68
  async unseal(provider) {
60
69
  this.vaultKey = await provider.deriveKey(this.ensureSalt());
61
70
  this.unsealedBy = provider.id;
71
+ this.lockedReason = null;
62
72
  }
63
73
  /**
64
74
  * Unlock from the user's API key. Also records the key's hash so subsequent
@@ -86,6 +96,51 @@ var Vault = class {
86
96
  this.apiKeyHash = null;
87
97
  this.spSessionCookie = null;
88
98
  this.unsealedBy = null;
99
+ this.spSessionExpiresAt = null;
100
+ this.lockedReason = null;
101
+ }
102
+ /**
103
+ * Lock because the AS session ended — a 401 surfaced it, or the scheduled
104
+ * expiry arrived. Distinct from logout/clearKey() only in that it records
105
+ * WHY, so the next `/health` call and the next locked-tool notice can say
106
+ * something better than "boots locked by design" when that is not what
107
+ * happened.
108
+ */
109
+ lockExpired() {
110
+ this.clearKey();
111
+ this.lockedReason = "expired";
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
+ /**
121
+ * Boot-time only: record that the gateway starts locked because the
122
+ * resolved Authority Server URL differs from the one it was last paired
123
+ * with. Deliberately does NOT call clearKey() — the vault always boots
124
+ * locked already (nothing has been unlocked yet in this process), so there
125
+ * is no session to end; this only attaches the reason so /health and the
126
+ * locked-agent notice can explain it instead of defaulting to "restart".
127
+ */
128
+ markBootLockedAsUrlChanged() {
129
+ this.lockedReason = "as-url-changed";
130
+ }
131
+ /** What locked the vault, if known. `null` covers both "still unlocked"
132
+ * and the default boot-locked case — callers that care about the
133
+ * difference should check `isUnlocked()` first. */
134
+ getLockedReason() {
135
+ return this.lockedReason;
136
+ }
137
+ /** unix seconds the current AS session is due to end, or null (locked, or
138
+ * the AS didn't report one — a pre-30-day-rollout server). Never persisted. */
139
+ setSessionExpiresAt(expiresAt) {
140
+ this.spSessionExpiresAt = expiresAt;
141
+ }
142
+ getSessionExpiresAt() {
143
+ return this.spSessionExpiresAt;
89
144
  }
90
145
  /**
91
146
  * Check if the vault was created by a different API key.
@@ -263,6 +318,16 @@ async function configure(sessionCookie, vaultKeyHex) {
263
318
  clearTimeout(timeout);
264
319
  }
265
320
  }
321
+ async function unconfigureSession(reason) {
322
+ const res = await fetch(`${MCP_BASE}/internal/clear-session`, {
323
+ method: "POST",
324
+ headers: internalHeaders(),
325
+ body: JSON.stringify({ reason })
326
+ });
327
+ if (!res.ok) {
328
+ throw new Error(`MCP clear-session failed: ${res.status}`);
329
+ }
330
+ }
266
331
  async function pushGateContent(data) {
267
332
  const res = await fetch(`${MCP_BASE}/internal/gate-content`, {
268
333
  method: "POST",
@@ -419,6 +484,13 @@ async function getEnrichedAuthorizations() {
419
484
  if (!res.ok) throw new Error("Failed to fetch authorizations");
420
485
  return res.json();
421
486
  }
487
+ async function getSkippedCommitments() {
488
+ const res = await fetch(`${MCP_BASE}/internal/skipped-commitments`, {
489
+ headers: internalHeaders()
490
+ });
491
+ if (!res.ok) throw new Error("Failed to fetch skipped commitments");
492
+ return res.json();
493
+ }
422
494
  async function getLocalEvidence() {
423
495
  const res = await fetch(`${MCP_BASE}/internal/evidence`, {
424
496
  headers: internalHeaders()
@@ -552,10 +624,122 @@ async function loadOrGenerateKeyPair(vault2) {
552
624
  return kp;
553
625
  }
554
626
 
627
+ // src/lib/client-version.ts
628
+ import { readFileSync as readFileSync2 } from "fs";
629
+ import { join as join2 } from "path";
630
+ var UNKNOWN = "unknown";
631
+ function readJson(path) {
632
+ try {
633
+ return JSON.parse(readFileSync2(path, "utf8"));
634
+ } catch {
635
+ return null;
636
+ }
637
+ }
638
+ function detectGatewayVersion() {
639
+ const override = process.env.SUVEREN_GATEWAY_VERSION;
640
+ if (override) return override;
641
+ const start = import.meta.dirname ?? process.cwd();
642
+ let dir = start;
643
+ for (let up = 0; up < 6; up++) {
644
+ const pkg = readJson(join2(dir, "package.json"));
645
+ const name = pkg?.name;
646
+ const version = pkg?.version;
647
+ if (typeof version === "string" && (name === "@suveren/gateway" || name === "suveren-gateway")) {
648
+ return version;
649
+ }
650
+ const parent = join2(dir, "..");
651
+ if (parent === dir) break;
652
+ dir = parent;
653
+ }
654
+ return process.env.HAP_BUILD_SHA ?? UNKNOWN;
655
+ }
656
+ var GATEWAY_VERSION = detectGatewayVersion();
657
+ function clientVersionHeaders() {
658
+ return {
659
+ "x-suveren-gateway-version": GATEWAY_VERSION
660
+ };
661
+ }
662
+
663
+ // src/lib/as-pairing.ts
664
+ import { createHash as createHash2 } from "crypto";
665
+ import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync3, unlinkSync, writeFileSync as writeFileSync2 } from "fs";
666
+ import { dirname as dirname2, join as join3 } from "path";
667
+ function pairingPath(dataDir) {
668
+ return join3(dataDir, "as-pairing.json");
669
+ }
670
+ function readPairing(dataDir) {
671
+ const path = pairingPath(dataDir);
672
+ if (!existsSync2(path)) return null;
673
+ try {
674
+ const data = JSON.parse(readFileSync3(path, "utf-8"));
675
+ if (typeof data.asUrl !== "string" || typeof data.publicKeyHex !== "string") return null;
676
+ return { asUrl: data.asUrl, publicKeyHex: data.publicKeyHex, pairedAt: data.pairedAt ?? "" };
677
+ } catch {
678
+ return null;
679
+ }
680
+ }
681
+ function writePairing(dataDir, asUrl, publicKeyHex) {
682
+ const pairing = { asUrl, publicKeyHex, pairedAt: (/* @__PURE__ */ new Date()).toISOString() };
683
+ const path = pairingPath(dataDir);
684
+ mkdirSync2(dirname2(path), { recursive: true, mode: 448 });
685
+ writeFileSync2(path, JSON.stringify(pairing, null, 2), { encoding: "utf-8", mode: 384 });
686
+ return pairing;
687
+ }
688
+ function clearPairing(dataDir) {
689
+ const path = pairingPath(dataDir);
690
+ try {
691
+ if (existsSync2(path)) unlinkSync(path);
692
+ } catch {
693
+ }
694
+ }
695
+ function fingerprintOf(publicKeyHex) {
696
+ const raw = Buffer.from(publicKeyHex, "hex");
697
+ const digest = createHash2("sha256").update(raw).digest("hex").toUpperCase();
698
+ return digest.match(/.{1,4}/g)?.join(":") ?? digest;
699
+ }
700
+
555
701
  // src/routes/auth.ts
556
- var SP_URL = process.env.SUVEREN_AS_URL ?? "https://www.suveren.ai";
557
- function createAuthRouter(vault2, logoutAuth, loginRateLimit2) {
702
+ var DEFAULT_SP_URL = process.env.SUVEREN_AS_URL ?? "https://www.suveren.ai";
703
+ async function checkAsKeyBeforeLogin(asUrl, dataDir) {
704
+ let publicKeyHex;
705
+ try {
706
+ const res = await fetch(`${asUrl}/api/as/pubkey`, { signal: AbortSignal.timeout(5e3) });
707
+ if (!res.ok) {
708
+ return {
709
+ ok: false,
710
+ error: "as_unreachable",
711
+ message: `Could not reach the Authority Server at ${asUrl} to verify its signing key (HTTP ${res.status}). Refusing to sign in.`
712
+ };
713
+ }
714
+ const body = await res.json().catch(() => null);
715
+ if (!body || typeof body.publicKey !== "string" || !body.publicKey) {
716
+ return {
717
+ ok: false,
718
+ error: "as_unreachable",
719
+ message: `The Authority Server at ${asUrl} returned a malformed signing key. Refusing to sign in.`
720
+ };
721
+ }
722
+ publicKeyHex = body.publicKey;
723
+ } catch (err) {
724
+ return {
725
+ ok: false,
726
+ error: "as_unreachable",
727
+ message: `Could not reach the Authority Server at ${asUrl} to verify its signing key \u2014 ${err instanceof Error ? err.message : String(err)}. Refusing to sign in.`
728
+ };
729
+ }
730
+ const existing = readPairing(dataDir);
731
+ if (existing && existing.asUrl === asUrl && existing.publicKeyHex !== publicKeyHex) {
732
+ return {
733
+ ok: false,
734
+ error: "as_key_mismatch",
735
+ message: `The Authority Server at ${asUrl} presented a signing key that does not match the one pinned when this gateway last signed in (pinned fingerprint ${fingerprintOf(existing.publicKeyHex)}, now seeing ${fingerprintOf(publicKeyHex)}). Refusing to sign in. If the AS's key changed intentionally, an operator must clear the old pairing before signing in again.`
736
+ };
737
+ }
738
+ return { ok: true, publicKeyHex };
739
+ }
740
+ function createAuthRouter(vault2, logoutAuth, loginRateLimit2, onSessionEstablished, pairing) {
558
741
  const router = Router();
742
+ const SP_URL2 = pairing?.asUrl ?? DEFAULT_SP_URL;
559
743
  router.post("/login", loginRateLimit2, async (req, res) => {
560
744
  const apiKey = req.headers["x-api-key"] || req.body?.apiKey;
561
745
  const confirmWipe = req.body?.confirmWipe === true;
@@ -564,11 +748,26 @@ function createAuthRouter(vault2, logoutAuth, loginRateLimit2) {
564
748
  return;
565
749
  }
566
750
  try {
567
- const spRes = await fetch(`${SP_URL}/api/auth/session`, {
751
+ let keyCheck = null;
752
+ if (pairing) {
753
+ keyCheck = await checkAsKeyBeforeLogin(pairing.asUrl, pairing.dataDir);
754
+ if (!keyCheck.ok) {
755
+ res.status(keyCheck.error === "as_key_mismatch" ? 409 : 502).json({
756
+ error: keyCheck.error,
757
+ message: keyCheck.message
758
+ });
759
+ return;
760
+ }
761
+ }
762
+ const spRes = await fetch(`${SP_URL2}/api/auth/session`, {
568
763
  method: "POST",
569
764
  headers: {
570
765
  "Content-Type": "application/json",
571
- "X-API-Key": apiKey
766
+ "X-API-Key": apiKey,
767
+ // The AS grants a 30-day gateway session ONLY to a login that
768
+ // identifies itself this way; without it, a 24-hour browser
769
+ // session (see doc at the top of this file).
770
+ ...clientVersionHeaders()
572
771
  }
573
772
  });
574
773
  if (!spRes.ok) {
@@ -576,6 +775,14 @@ function createAuthRouter(vault2, logoutAuth, loginRateLimit2) {
576
775
  res.status(spRes.status).json(err);
577
776
  return;
578
777
  }
778
+ if (pairing && keyCheck?.publicKeyHex) {
779
+ const existing = readPairing(pairing.dataDir);
780
+ if (!existing || existing.asUrl !== pairing.asUrl) {
781
+ writePairing(pairing.dataDir, pairing.asUrl, keyCheck.publicKeyHex);
782
+ console.error(`[Control Plane] Paired with Authority Server ${pairing.asUrl} (fingerprint ${fingerprintOf(keyCheck.publicKeyHex)})`);
783
+ }
784
+ }
785
+ const data = await spRes.json();
579
786
  const setCookieHeaders = spRes.headers.getSetCookie?.() ?? [];
580
787
  const sessionCookie = setCookieHeaders.join("; ");
581
788
  vault2.setSpCookie(sessionCookie);
@@ -605,6 +812,9 @@ function createAuthRouter(vault2, logoutAuth, loginRateLimit2) {
605
812
  vault2.wipe();
606
813
  await vault2.deriveAndSetKey(apiKey);
607
814
  }
815
+ const sessionExpiresAt = typeof data.sessionExpiresAt === "number" ? data.sessionExpiresAt : null;
816
+ vault2.setSessionExpiresAt(sessionExpiresAt);
817
+ onSessionEstablished?.();
608
818
  if (sessionCookie) {
609
819
  try {
610
820
  await configure(sessionCookie, vault2.getVaultKeyHex());
@@ -612,14 +822,13 @@ function createAuthRouter(vault2, logoutAuth, loginRateLimit2) {
612
822
  console.error("[Control Plane] Failed to configure MCP:", err);
613
823
  }
614
824
  }
615
- const data = await spRes.json();
616
825
  res.json(data);
617
826
  (async () => {
618
827
  try {
619
828
  const kp = await loadOrGenerateKeyPair(vault2);
620
829
  const localPubkeyB64 = Buffer.from(kp.publicKey).toString("base64");
621
830
  const spCookie = vault2.getSpCookie();
622
- const meKeyRes = await fetch(`${SP_URL}/api/users/me/pubkey`, {
831
+ const meKeyRes = await fetch(`${SP_URL2}/api/users/me/pubkey`, {
623
832
  headers: spCookie ? { Cookie: spCookie } : {},
624
833
  signal: AbortSignal.timeout(5e3)
625
834
  });
@@ -631,7 +840,7 @@ function createAuthRouter(vault2, logoutAuth, loginRateLimit2) {
631
840
  needsUpdate = meKeyData.pubkey !== localPubkeyB64;
632
841
  }
633
842
  if (needsUpdate) {
634
- const putRes = await fetch(`${SP_URL}/api/users/me/pubkey`, {
843
+ const putRes = await fetch(`${SP_URL2}/api/users/me/pubkey`, {
635
844
  method: "PUT",
636
845
  headers: {
637
846
  "Content-Type": "application/json",
@@ -684,7 +893,16 @@ function createAuthRouter(vault2, logoutAuth, loginRateLimit2) {
684
893
  }
685
894
  });
686
895
  router.post("/logout", logoutAuth, async (_req, res) => {
896
+ const cookie = vault2.getSpCookie();
687
897
  vault2.clearKey();
898
+ await Promise.allSettled([
899
+ unconfigureSession(),
900
+ cookie ? fetch(`${SP_URL2}/api/auth/logout`, {
901
+ method: "POST",
902
+ headers: { cookie, ...clientVersionHeaders() },
903
+ redirect: "manual"
904
+ }) : Promise.resolve()
905
+ ]);
688
906
  res.json({ ok: true });
689
907
  });
690
908
  return router;
@@ -1294,18 +1512,18 @@ async function testAIConnectivity(config) {
1294
1512
  }
1295
1513
 
1296
1514
  // src/lib/agent-brief-store.ts
1297
- import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
1515
+ import { existsSync as existsSync3, readFileSync as readFileSync4 } from "fs";
1298
1516
  import { homedir as homedir2 } from "os";
1299
- import { join as join2 } from "path";
1517
+ import { join as join4 } from "path";
1300
1518
  var AGENT_CONTEXT_MAX_BYTES = 16 * 1024;
1301
1519
  function agentBriefPath() {
1302
- const dataDir = process.env.SUVEREN_DATA_DIR ?? join2(homedir2(), ".suveren");
1303
- return join2(dataDir, "context.md");
1520
+ const dataDir = process.env.SUVEREN_DATA_DIR ?? join4(homedir2(), ".suveren");
1521
+ return join4(dataDir, "context.md");
1304
1522
  }
1305
1523
  function readAgentBrief() {
1306
1524
  const filePath = agentBriefPath();
1307
- if (!existsSync2(filePath)) return "";
1308
- return readFileSync2(filePath, "utf-8");
1525
+ if (!existsSync3(filePath)) return "";
1526
+ return readFileSync4(filePath, "utf-8");
1309
1527
  }
1310
1528
 
1311
1529
  // src/routes/ai.ts
@@ -1669,28 +1887,28 @@ function createMCPRouter() {
1669
1887
  // src/routes/autostart.ts
1670
1888
  import { Router as Router6 } from "express";
1671
1889
  import { execFile } from "child_process";
1672
- import { existsSync as existsSync3 } from "fs";
1890
+ import { existsSync as existsSync4 } from "fs";
1673
1891
  import { dirname as pathDirname, resolve } from "path";
1674
1892
  import { fileURLToPath } from "url";
1675
1893
  import { promisify } from "util";
1676
1894
  var run = promisify(execFile);
1677
1895
  var SUPPORTED = /* @__PURE__ */ new Set(["darwin", "win32", "linux"]);
1678
1896
  var MODULE_DIR = pathDirname(fileURLToPath(import.meta.url));
1679
- function findCli(dirname7 = MODULE_DIR) {
1897
+ function findCli(dirname9 = MODULE_DIR) {
1680
1898
  const candidates = [
1681
1899
  // Bundled (the shipped layout): dist/control-plane → dist → root → bin
1682
- resolve(dirname7, "..", "..", "bin", "suveren-gateway.js"),
1900
+ resolve(dirname9, "..", "..", "bin", "suveren-gateway.js"),
1683
1901
  // Bundled, were the routes/ directory ever preserved.
1684
- resolve(dirname7, "..", "..", "..", "bin", "suveren-gateway.js"),
1902
+ resolve(dirname9, "..", "..", "..", "bin", "suveren-gateway.js"),
1685
1903
  // Dev, running from source: the repo's own bundle directory.
1686
- resolve(dirname7, "..", "..", "..", "..", "bundle", "bin", "suveren-gateway.js"),
1687
- resolve(dirname7, "..", "..", "..", "..", "..", "bundle", "bin", "suveren-gateway.js")
1904
+ resolve(dirname9, "..", "..", "..", "..", "bundle", "bin", "suveren-gateway.js"),
1905
+ resolve(dirname9, "..", "..", "..", "..", "..", "bundle", "bin", "suveren-gateway.js")
1688
1906
  // Deliberately NO process.cwd() fallback: it makes the result depend on
1689
1907
  // where the process happened to be launched from, so the same install
1690
1908
  // resolves differently between a shell and a login service — and it would
1691
1909
  // mask a genuinely missing CLI whenever the cwd happened to be the repo.
1692
1910
  ];
1693
- return candidates.find(existsSync3) ?? null;
1911
+ return candidates.find(existsSync4) ?? null;
1694
1912
  }
1695
1913
  async function cli(args) {
1696
1914
  const bin = findCli();
@@ -1771,17 +1989,17 @@ function createAutostartRouter() {
1771
1989
  import { spawn, spawnSync } from "child_process";
1772
1990
 
1773
1991
  // src/lib/notifier-icon.ts
1774
- import { writeFileSync as writeFileSync2, mkdirSync as mkdirSync2, existsSync as existsSync4 } from "fs";
1992
+ import { writeFileSync as writeFileSync3, mkdirSync as mkdirSync3, existsSync as existsSync5 } from "fs";
1775
1993
  import { homedir as homedir3 } from "os";
1776
- import { join as join3, dirname as dirname2 } from "path";
1994
+ import { join as join5, dirname as dirname3 } from "path";
1777
1995
  var ICON_BASE64 = "iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAACXBIWXMAACxLAAAsSwGlPZapAAAaEElEQVR42u2deXxNV9fH7/O2z/vHk+HmJoIoQQxpBtVPi+LTIWZqeDQ6V0tRFUWIeagSRAheyasxVNUsWtRQSquoMTRi9mgJooZWhBqaSIX97nWa9CVN4ubes8/Z55zf+ny+H1rknrv3Wr+zh7XXttmMaY94e3vXdDgcL3JifHx8ZnE2cvbw/z7MyeBc5eRxGABukFfgS+RTh8nHCnxtFvke+S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ierIcon(dataDir) {
1779
1997
  try {
1780
- const dir = dataDir ?? process.env.SUVEREN_DATA_DIR ?? join3(homedir3(), ".suveren");
1781
- const path = join3(dir, "notifier-icon.png");
1782
- if (!existsSync4(path)) {
1783
- mkdirSync2(dirname2(path), { recursive: true });
1784
- writeFileSync2(path, Buffer.from(ICON_BASE64, "base64"));
1998
+ const dir = dataDir ?? process.env.SUVEREN_DATA_DIR ?? join5(homedir3(), ".suveren");
1999
+ const path = join5(dir, "notifier-icon.png");
2000
+ if (!existsSync5(path)) {
2001
+ mkdirSync3(dirname3(path), { recursive: true });
2002
+ writeFileSync3(path, Buffer.from(ICON_BASE64, "base64"));
1785
2003
  }
1786
2004
  return path;
1787
2005
  } catch {
@@ -1861,6 +2079,14 @@ function lockedNotification(port2) {
1861
2079
  url
1862
2080
  };
1863
2081
  }
2082
+ function sessionExpiredNotification(port2) {
2083
+ const url = `http://localhost:${port2}`;
2084
+ return {
2085
+ title: "Suveren Gateway locked",
2086
+ message: "Your sign-in has ended. Sign in again so your agents can act.",
2087
+ url
2088
+ };
2089
+ }
1864
2090
  var terminalNotifierCache = null;
1865
2091
  function hasTerminalNotifier() {
1866
2092
  if (terminalNotifierCache !== null) return terminalNotifierCache;
@@ -1975,24 +2201,24 @@ import { Router as Router9 } from "express";
1975
2201
 
1976
2202
  // src/routes/approved-intents.ts
1977
2203
  import { Router as Router8 } from "express";
1978
- import { readFileSync as readFileSync3, writeFileSync as writeFileSync3, existsSync as existsSync5, mkdirSync as mkdirSync3 } from "fs";
2204
+ import { readFileSync as readFileSync5, writeFileSync as writeFileSync4, existsSync as existsSync6, mkdirSync as mkdirSync4 } from "fs";
1979
2205
  import { homedir as homedir4 } from "os";
1980
- import { join as join4 } from "path";
1981
- var SUVEREN_DATA_DIR = process.env.SUVEREN_DATA_DIR ?? join4(homedir4(), ".suveren");
1982
- var FILE_PATH = join4(SUVEREN_DATA_DIR, "approved-intents.enc.json");
2206
+ import { join as join6 } from "path";
2207
+ var SUVEREN_DATA_DIR = process.env.SUVEREN_DATA_DIR ?? join6(homedir4(), ".suveren");
2208
+ var FILE_PATH = join6(SUVEREN_DATA_DIR, "approved-intents.enc.json");
1983
2209
  function readFile() {
1984
- if (!existsSync5(FILE_PATH)) {
2210
+ if (!existsSync6(FILE_PATH)) {
1985
2211
  return { version: 1, entries: {} };
1986
2212
  }
1987
2213
  try {
1988
- return JSON.parse(readFileSync3(FILE_PATH, "utf-8"));
2214
+ return JSON.parse(readFileSync5(FILE_PATH, "utf-8"));
1989
2215
  } catch {
1990
2216
  return { version: 1, entries: {} };
1991
2217
  }
1992
2218
  }
1993
2219
  function writeFile(data) {
1994
- mkdirSync3(SUVEREN_DATA_DIR, { recursive: true });
1995
- writeFileSync3(FILE_PATH, JSON.stringify(data, null, 2), "utf-8");
2220
+ mkdirSync4(SUVEREN_DATA_DIR, { recursive: true });
2221
+ writeFileSync4(FILE_PATH, JSON.stringify(data, null, 2), "utf-8");
1996
2222
  }
1997
2223
  function readApprovedIntents(vault2) {
1998
2224
  const file = readFile();
@@ -2257,7 +2483,7 @@ function createDecryptIntentRouter(vault2) {
2257
2483
 
2258
2484
  // src/lib/update-checker.ts
2259
2485
  import { execSync } from "child_process";
2260
- import { dirname as dirname3 } from "path";
2486
+ import { dirname as dirname4 } from "path";
2261
2487
  import { fileURLToPath as fileURLToPath2 } from "url";
2262
2488
  var GHCR_IMAGE = "suverenai/suveren-gateway";
2263
2489
  var NPM_PACKAGE = "@suveren/gateway";
@@ -2323,7 +2549,7 @@ function compareSemver(a, b) {
2323
2549
  return 0;
2324
2550
  }
2325
2551
  function checkDev() {
2326
- const cwd = dirname3(fileURLToPath2(import.meta.url));
2552
+ const cwd = dirname4(fileURLToPath2(import.meta.url));
2327
2553
  try {
2328
2554
  execSync("git fetch origin --quiet", { cwd, stdio: "ignore", timeout: 15e3 });
2329
2555
  const out = execSync("git rev-list HEAD..origin/main --count", {
@@ -2367,6 +2593,7 @@ function startUpdateChecker(method, version) {
2367
2593
 
2368
2594
  // src/routes/events.ts
2369
2595
  var KEEPALIVE_INTERVAL_MS = 25e3;
2596
+ var PAYLOAD_ALLOWED = /* @__PURE__ */ new Set(["session-locked"]);
2370
2597
  function createEventsHandler() {
2371
2598
  return function eventsHandler(_req, res) {
2372
2599
  res.setHeader("Content-Type", "text/event-stream");
@@ -2375,8 +2602,9 @@ function createEventsHandler() {
2375
2602
  res.setHeader("X-Accel-Buffering", "no");
2376
2603
  res.flushHeaders();
2377
2604
  const unsubscribe = eventBus.subscribe((event) => {
2605
+ const data = PAYLOAD_ALLOWED.has(event.type) ? JSON.stringify(event.payload ?? null) : "null";
2378
2606
  res.write(`event: ${event.type}
2379
- data: null
2607
+ data: ${data}
2380
2608
 
2381
2609
  `);
2382
2610
  });
@@ -2394,19 +2622,19 @@ data: null
2394
2622
  import { Router as Router12 } from "express";
2395
2623
 
2396
2624
  // src/lib/gateway-settings.ts
2397
- import { readFileSync as readFileSync4, writeFileSync as writeFileSync4, mkdirSync as mkdirSync4 } from "fs";
2625
+ import { readFileSync as readFileSync6, writeFileSync as writeFileSync5, mkdirSync as mkdirSync5 } from "fs";
2398
2626
  import { homedir as homedir5 } from "os";
2399
- import { join as join5, dirname as dirname4 } from "path";
2627
+ import { join as join7, dirname as dirname5 } from "path";
2400
2628
  var DEFAULT_SETTINGS = {
2401
2629
  desktopNotifications: true
2402
2630
  };
2403
2631
  function settingsPath(dataDir) {
2404
- const dir = dataDir ?? process.env.SUVEREN_DATA_DIR ?? join5(homedir5(), ".suveren");
2405
- return join5(dir, "settings.json");
2632
+ const dir = dataDir ?? process.env.SUVEREN_DATA_DIR ?? join7(homedir5(), ".suveren");
2633
+ return join7(dir, "settings.json");
2406
2634
  }
2407
2635
  function readSettings(dataDir) {
2408
2636
  try {
2409
- const raw = JSON.parse(readFileSync4(settingsPath(dataDir), "utf8"));
2637
+ const raw = JSON.parse(readFileSync6(settingsPath(dataDir), "utf8"));
2410
2638
  return {
2411
2639
  desktopNotifications: typeof raw.desktopNotifications === "boolean" ? raw.desktopNotifications : DEFAULT_SETTINGS.desktopNotifications
2412
2640
  };
@@ -2420,8 +2648,8 @@ function writeSettings(patch, dataDir) {
2420
2648
  ...typeof patch.desktopNotifications === "boolean" ? { desktopNotifications: patch.desktopNotifications } : {}
2421
2649
  };
2422
2650
  const path = settingsPath(dataDir);
2423
- mkdirSync4(dirname4(path), { recursive: true });
2424
- writeFileSync4(path, JSON.stringify(next, null, 2) + "\n", "utf8");
2651
+ mkdirSync5(dirname5(path), { recursive: true });
2652
+ writeFileSync5(path, JSON.stringify(next, null, 2) + "\n", "utf8");
2425
2653
  return next;
2426
2654
  }
2427
2655
 
@@ -2453,20 +2681,20 @@ function createGatewaySettingsRouter() {
2453
2681
  import { Router as Router13 } from "express";
2454
2682
 
2455
2683
  // src/lib/archived-mandates-store.ts
2456
- import { readFileSync as readFileSync5, writeFileSync as writeFileSync5, mkdirSync as mkdirSync5, renameSync } from "fs";
2684
+ import { readFileSync as readFileSync7, writeFileSync as writeFileSync6, mkdirSync as mkdirSync6, renameSync } from "fs";
2457
2685
  import { homedir as homedir6 } from "os";
2458
- import { join as join6, dirname as dirname5 } from "path";
2686
+ import { join as join8, dirname as dirname6 } from "path";
2459
2687
  var ID_PATTERN = /^[A-Za-z0-9_.:-]{1,200}$/;
2460
2688
  function isValidMandateId(id) {
2461
2689
  return typeof id === "string" && ID_PATTERN.test(id);
2462
2690
  }
2463
2691
  function storePath(dataDir) {
2464
- const dir = dataDir ?? process.env.SUVEREN_DATA_DIR ?? join6(homedir6(), ".suveren");
2465
- return join6(dir, "archived-mandates.json");
2692
+ const dir = dataDir ?? process.env.SUVEREN_DATA_DIR ?? join8(homedir6(), ".suveren");
2693
+ return join8(dir, "archived-mandates.json");
2466
2694
  }
2467
2695
  function readArchived(dataDir) {
2468
2696
  try {
2469
- const raw = JSON.parse(readFileSync5(storePath(dataDir), "utf8"));
2697
+ const raw = JSON.parse(readFileSync7(storePath(dataDir), "utf8"));
2470
2698
  if (!Array.isArray(raw.archived)) return [];
2471
2699
  return [...new Set(raw.archived.filter(isValidMandateId))];
2472
2700
  } catch {
@@ -2476,9 +2704,9 @@ function readArchived(dataDir) {
2476
2704
  function writeArchived(ids, dataDir) {
2477
2705
  const next = [...new Set(ids.filter(isValidMandateId))].sort();
2478
2706
  const path = storePath(dataDir);
2479
- mkdirSync5(dirname5(path), { recursive: true });
2707
+ mkdirSync6(dirname6(path), { recursive: true });
2480
2708
  const tmp = `${path}.tmp`;
2481
- writeFileSync5(tmp, JSON.stringify({ archived: next }, null, 2) + "\n", "utf8");
2709
+ writeFileSync6(tmp, JSON.stringify({ archived: next }, null, 2) + "\n", "utf8");
2482
2710
  renameSync(tmp, path);
2483
2711
  return next;
2484
2712
  }
@@ -2518,6 +2746,8 @@ function createArchivedMandatesRouter(dataDir) {
2518
2746
  import { Router as Router14 } from "express";
2519
2747
  import { timingSafeEqual as timingSafeEqual2 } from "crypto";
2520
2748
  var ALLOWED = ["proposal-added", "action-approval-needed"];
2749
+ var SESSION_EXPIRED = "session-expired";
2750
+ var AS_KEY_MISMATCH = "as-key-mismatch";
2521
2751
  function secretMatches(provided, expected) {
2522
2752
  if (!expected) return false;
2523
2753
  if (!provided) return false;
@@ -2526,7 +2756,7 @@ function secretMatches(provided, expected) {
2526
2756
  if (a.length !== b.length) return false;
2527
2757
  return timingSafeEqual2(a, b);
2528
2758
  }
2529
- function createInternalEventsRouter(getSecret) {
2759
+ function createInternalEventsRouter(getSecret, onSessionExpired, onAsKeyMismatch) {
2530
2760
  const router = Router14();
2531
2761
  router.post("/event", (req, res) => {
2532
2762
  if (!secretMatches(req.headers["x-internal-secret"], getSecret())) {
@@ -2534,6 +2764,16 @@ function createInternalEventsRouter(getSecret) {
2534
2764
  return;
2535
2765
  }
2536
2766
  const type = (req.body ?? {}).type;
2767
+ if (type === SESSION_EXPIRED) {
2768
+ onSessionExpired?.();
2769
+ res.json({ ok: true });
2770
+ return;
2771
+ }
2772
+ if (type === AS_KEY_MISMATCH) {
2773
+ onAsKeyMismatch?.();
2774
+ res.json({ ok: true });
2775
+ return;
2776
+ }
2537
2777
  if (typeof type !== "string" || !ALLOWED.includes(type)) {
2538
2778
  res.status(400).json({ error: "Unsupported event type" });
2539
2779
  return;
@@ -2630,18 +2870,123 @@ function startNotificationDispatcher(opts = {}) {
2630
2870
  return new NotificationDispatcher(opts).start();
2631
2871
  }
2632
2872
 
2873
+ // src/lib/session-lock.ts
2874
+ var SESSION_LOCKED_MESSAGE = "Your sign-in ended after 30 days or was revoked. Sign in again.";
2875
+ 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.";
2876
+ function createSessionLock(deps) {
2877
+ const { vault: vault2, port: port2 } = deps;
2878
+ const notifyFn = deps.notifyFn ?? notify;
2879
+ const unconfigureSessionFn = deps.unconfigureSessionFn ?? unconfigureSession;
2880
+ const emit = deps.emit ?? eventBus.emit.bind(eventBus);
2881
+ return function lockExpiredSession2() {
2882
+ if (!vault2.isUnlocked()) return;
2883
+ vault2.lockExpired();
2884
+ console.error("[Control Plane] Authority Server session ended \u2014 gateway LOCKED");
2885
+ void unconfigureSessionFn().catch((err) => {
2886
+ console.error("[Control Plane] Failed to push cleared session to MCP:", err);
2887
+ });
2888
+ emit("session-locked", { reason: "expired", message: SESSION_LOCKED_MESSAGE });
2889
+ const { title, message, url } = sessionExpiredNotification(port2);
2890
+ notifyFn(title, message, process.platform, url);
2891
+ };
2892
+ }
2893
+ function createAsKeyMismatchLock(deps) {
2894
+ const { vault: vault2, port: port2 } = deps;
2895
+ const notifyFn = deps.notifyFn ?? notify;
2896
+ const unconfigureSessionFn = deps.unconfigureSessionFn ?? unconfigureSession;
2897
+ const emit = deps.emit ?? eventBus.emit.bind(eventBus);
2898
+ return function lockOnAsKeyMismatch() {
2899
+ if (!vault2.isUnlocked()) return;
2900
+ vault2.lockAsKeyMismatch();
2901
+ console.error("[Control Plane] Authority Server key mismatch \u2014 gateway LOCKED");
2902
+ void unconfigureSessionFn("as-key-mismatch").catch((err) => {
2903
+ console.error("[Control Plane] Failed to push cleared session to MCP:", err);
2904
+ });
2905
+ emit("session-locked", { reason: "as-key-mismatch", message: AS_KEY_MISMATCH_MESSAGE });
2906
+ const { title, url } = sessionExpiredNotification(port2);
2907
+ notifyFn(title, AS_KEY_MISMATCH_MESSAGE, process.platform, url);
2908
+ };
2909
+ }
2910
+
2911
+ // src/lib/session-expiry-scheduler.ts
2912
+ var MAX_TIMEOUT_MS = 2147483647;
2913
+ var SessionExpiryScheduler = class {
2914
+ constructor(getExpiresAt, onExpired, opts = {}) {
2915
+ this.getExpiresAt = getExpiresAt;
2916
+ this.onExpired = onExpired;
2917
+ this.now = opts.now ?? Date.now;
2918
+ this.setTimeoutFn = opts.setTimeoutFn ?? setTimeout;
2919
+ this.clearTimeoutFn = opts.clearTimeoutFn ?? clearTimeout;
2920
+ this.setIntervalFn = opts.setIntervalFn ?? setInterval;
2921
+ this.clearIntervalFn = opts.clearIntervalFn ?? clearInterval;
2922
+ this.coarseIntervalMs = opts.coarseIntervalMs ?? 5 * 6e4;
2923
+ }
2924
+ preciseTimer = null;
2925
+ coarseTimer = null;
2926
+ now;
2927
+ setTimeoutFn;
2928
+ clearTimeoutFn;
2929
+ setIntervalFn;
2930
+ clearIntervalFn;
2931
+ coarseIntervalMs;
2932
+ /** Start the coarse safety-net interval and arm the precise timer. */
2933
+ start() {
2934
+ if (this.coarseTimer) return;
2935
+ this.coarseTimer = this.setIntervalFn(() => this.check(), this.coarseIntervalMs);
2936
+ this.reschedule();
2937
+ }
2938
+ stop() {
2939
+ if (this.preciseTimer) this.clearTimeoutFn(this.preciseTimer);
2940
+ if (this.coarseTimer) this.clearIntervalFn(this.coarseTimer);
2941
+ this.preciseTimer = null;
2942
+ this.coarseTimer = null;
2943
+ }
2944
+ /** Call whenever `sessionExpiresAt` changes — a login (new value) or a
2945
+ * lock (now null, via getExpiresAt) — to re-arm the precise timer. */
2946
+ reschedule() {
2947
+ if (this.preciseTimer) {
2948
+ this.clearTimeoutFn(this.preciseTimer);
2949
+ this.preciseTimer = null;
2950
+ }
2951
+ const exp = this.getExpiresAt();
2952
+ if (exp === null) return;
2953
+ const delayMs = Math.max(0, exp * 1e3 - this.now());
2954
+ if (delayMs > MAX_TIMEOUT_MS) {
2955
+ this.preciseTimer = this.setTimeoutFn(() => this.reschedule(), MAX_TIMEOUT_MS);
2956
+ return;
2957
+ }
2958
+ this.preciseTimer = this.setTimeoutFn(() => this.check(), delayMs);
2959
+ }
2960
+ /** Idempotent: only fires onExpired when the expiry has actually arrived. */
2961
+ check() {
2962
+ const exp = this.getExpiresAt();
2963
+ if (exp !== null && this.now() >= exp * 1e3) this.onExpired();
2964
+ }
2965
+ };
2966
+
2967
+ // src/lib/session-health.ts
2968
+ function buildSessionHealth(vault2) {
2969
+ const unlocked = vault2.isUnlocked();
2970
+ const lockedReason = vault2.getLockedReason();
2971
+ return {
2972
+ state: unlocked ? "active" : "locked",
2973
+ expiresAt: unlocked ? vault2.getSessionExpiresAt() : null,
2974
+ ...lockedReason ? { lockedReason } : {}
2975
+ };
2976
+ }
2977
+
2633
2978
  // src/lib/denials-reader.ts
2634
- import { existsSync as existsSync6, readFileSync as readFileSync6 } from "fs";
2635
- import { join as join7 } from "path";
2979
+ import { existsSync as existsSync7, readFileSync as readFileSync8 } from "fs";
2980
+ import { join as join9 } from "path";
2636
2981
  function loadDenials(dataDir, decrypt) {
2637
- const encPath = join7(dataDir, "denials.enc.json");
2638
- const plainPath = join7(dataDir, "denials.json");
2639
- if (existsSync6(encPath)) {
2640
- const { blob } = JSON.parse(readFileSync6(encPath, "utf-8"));
2982
+ const encPath = join9(dataDir, "denials.enc.json");
2983
+ const plainPath = join9(dataDir, "denials.json");
2984
+ if (existsSync7(encPath)) {
2985
+ const { blob } = JSON.parse(readFileSync8(encPath, "utf-8"));
2641
2986
  return JSON.parse(decrypt(blob)).records ?? [];
2642
2987
  }
2643
- if (existsSync6(plainPath)) {
2644
- return JSON.parse(readFileSync6(plainPath, "utf-8")).records ?? [];
2988
+ if (existsSync7(plainPath)) {
2989
+ return JSON.parse(readFileSync8(plainPath, "utf-8")).records ?? [];
2645
2990
  }
2646
2991
  return [];
2647
2992
  }
@@ -2655,12 +3000,80 @@ function selectDenials(records, opts = {}) {
2655
3000
  return { count, records: out };
2656
3001
  }
2657
3002
 
3003
+ // src/lib/as-config.ts
3004
+ import { existsSync as existsSync8, mkdirSync as mkdirSync7, readFileSync as readFileSync9, writeFileSync as writeFileSync7 } from "fs";
3005
+ import { dirname as dirname7, join as join10 } from "path";
3006
+ var DEFAULT_AS_URL = "https://www.suveren.ai";
3007
+ function configPath(dataDir) {
3008
+ return join10(dataDir, "config.json");
3009
+ }
3010
+ function readAsConfigStrict(dataDir) {
3011
+ const path = configPath(dataDir);
3012
+ if (!existsSync8(path)) return {};
3013
+ let data;
3014
+ try {
3015
+ data = JSON.parse(readFileSync9(path, "utf-8"));
3016
+ } catch (err) {
3017
+ throw new Error(
3018
+ `Could not parse ${path}: ${err instanceof Error ? err.message : String(err)}`
3019
+ );
3020
+ }
3021
+ const out = {};
3022
+ if (typeof data.asUrl === "string") out.asUrl = data.asUrl;
3023
+ if (typeof data.caFile === "string") out.caFile = data.caFile;
3024
+ return out;
3025
+ }
3026
+ function validateAsUrl(candidate) {
3027
+ const trimmed = candidate.trim();
3028
+ if (!trimmed) return { ok: false, error: "The Authority Server URL is empty." };
3029
+ let parsed;
3030
+ try {
3031
+ parsed = new URL(trimmed);
3032
+ } catch {
3033
+ return { ok: false, error: `"${trimmed}" is not a valid URL.` };
3034
+ }
3035
+ const isLocalHttp = parsed.protocol === "http:" && (parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1");
3036
+ if (parsed.protocol !== "https:" && !isLocalHttp) {
3037
+ return {
3038
+ ok: false,
3039
+ error: `"${trimmed}" must use https:// (http:// is only allowed for http://localhost or http://127.0.0.1).`
3040
+ };
3041
+ }
3042
+ let normalized = `${parsed.origin}${parsed.pathname}${parsed.search}${parsed.hash}`;
3043
+ if (normalized.endsWith("/") && normalized !== `${parsed.origin}/`) {
3044
+ normalized = normalized.slice(0, -1);
3045
+ } else if (normalized === `${parsed.origin}/`) {
3046
+ normalized = parsed.origin;
3047
+ }
3048
+ return { ok: true, url: normalized };
3049
+ }
3050
+ function resolveAsUrl(dataDir, flag) {
3051
+ if (flag) {
3052
+ const v = validateAsUrl(flag);
3053
+ if (!v.ok) throw new Error(`Invalid --as-url: ${v.error}`);
3054
+ return v.url;
3055
+ }
3056
+ const envUrl = process.env.SUVEREN_AS_URL;
3057
+ if (envUrl) {
3058
+ const v = validateAsUrl(envUrl);
3059
+ if (!v.ok) throw new Error(`Invalid SUVEREN_AS_URL: ${v.error}`);
3060
+ return v.url;
3061
+ }
3062
+ const saved = readAsConfigStrict(dataDir).asUrl;
3063
+ if (saved) {
3064
+ const v = validateAsUrl(saved);
3065
+ if (!v.ok) throw new Error(`Invalid saved as-url "${saved}" in ${dataDir}/config.json: ${v.error}`);
3066
+ return v.url;
3067
+ }
3068
+ return DEFAULT_AS_URL;
3069
+ }
3070
+
2658
3071
  // src/index.ts
2659
3072
  (function migrateDataDir() {
2660
3073
  if (process.env.SUVEREN_DATA_DIR) return;
2661
- const oldDir = join8(homedir7(), ".hap");
2662
- const newDir = join8(homedir7(), ".suveren");
2663
- if (!existsSync7(newDir) && existsSync7(oldDir)) {
3074
+ const oldDir = join11(homedir7(), ".hap");
3075
+ const newDir = join11(homedir7(), ".suveren");
3076
+ if (!existsSync9(newDir) && existsSync9(oldDir)) {
2664
3077
  try {
2665
3078
  renameSync2(oldDir, newDir);
2666
3079
  console.error(`[Control Plane] Migrated data directory: ${oldDir} \u2192 ${newDir}`);
@@ -2670,11 +3083,22 @@ function selectDenials(records, opts = {}) {
2670
3083
  }
2671
3084
  }
2672
3085
  })();
2673
- var SP_URL2 = process.env.SUVEREN_AS_URL ?? "https://www.suveren.ai";
3086
+ var DATA_DIR = process.env.SUVEREN_DATA_DIR ?? join11(homedir7(), ".suveren");
3087
+ var SP_URL = resolveAsUrl(DATA_DIR);
2674
3088
  var port = parseInt(process.env.SUVEREN_CP_PORT ?? "3402", 10);
2675
3089
  var HAP_MODE = process.env.HAP_MODE ?? "personal";
2676
- var UI_DIST = process.env.HAP_UI_DIST ?? join8(import.meta.dirname ?? __dirname, "../../ui/dist");
2677
- var vault = new Vault();
3090
+ var UI_DIST = process.env.HAP_UI_DIST ?? join11(import.meta.dirname ?? __dirname, "../../ui/dist");
3091
+ var vault = new Vault(DATA_DIR);
3092
+ (function repairIfAsUrlChanged() {
3093
+ const pairing = readPairing(DATA_DIR);
3094
+ if (pairing && pairing.asUrl !== SP_URL) {
3095
+ console.error(
3096
+ `[Control Plane] Authority Server changed (${pairing.asUrl} \u2192 ${SP_URL}) \u2014 clearing the old pairing. Sign in again to re-pair.`
3097
+ );
3098
+ clearPairing(DATA_DIR);
3099
+ vault.markBootLockedAsUrlChanged();
3100
+ }
3101
+ })();
2678
3102
  var internalSecret2 = process.env.SUVEREN_INTERNAL_SECRET ?? randomBytes2(32).toString("hex");
2679
3103
  setInternalSecret(internalSecret2);
2680
3104
  var app = express();
@@ -2697,7 +3121,19 @@ function loginRateLimit(req, res, next) {
2697
3121
  }
2698
3122
  next();
2699
3123
  }
2700
- app.use("/auth", jsonParser, createAuthRouter(vault, requireAuth(vault), loginRateLimit));
3124
+ var lockExpiredSession = createSessionLock({ vault, port });
3125
+ var lockAsKeyMismatch = createAsKeyMismatchLock({ vault, port });
3126
+ var sessionExpiryScheduler = new SessionExpiryScheduler(
3127
+ () => vault.getSessionExpiresAt(),
3128
+ lockExpiredSession
3129
+ );
3130
+ app.use("/auth", jsonParser, createAuthRouter(
3131
+ vault,
3132
+ requireAuth(vault),
3133
+ loginRateLimit,
3134
+ () => sessionExpiryScheduler.reschedule(),
3135
+ { asUrl: SP_URL, dataDir: DATA_DIR }
3136
+ ));
2701
3137
  function resolveOrigin(req) {
2702
3138
  const fwdHost = req.get("x-forwarded-host");
2703
3139
  if (fwdHost) return `${req.protocol}://${fwdHost}`;
@@ -2903,7 +3339,7 @@ app.get("/auth/oauth/:integrationId/health", authGuard, async (req, res) => {
2903
3339
  }
2904
3340
  });
2905
3341
  app.get("/events", requireAllowedHost, requireAuthQueryOrHeader(vault), createEventsHandler());
2906
- app.use("/internal", jsonParser, createInternalEventsRouter(() => internalSecret2));
3342
+ app.use("/internal", jsonParser, createInternalEventsRouter(() => internalSecret2, lockExpiredSession, lockAsKeyMismatch));
2907
3343
  app.use("/vault", jsonParser, authGuard, createVaultRouter(vault));
2908
3344
  app.use("/ai", jsonParser, authGuard, createAIRouter(vault));
2909
3345
  app.use("/ai-prompts", jsonParser, authGuard, createAIPromptsRouter());
@@ -2912,7 +3348,7 @@ app.use("/autostart", jsonParser, authGuard, createAutostartRouter());
2912
3348
  app.use("/api/gateway-settings", jsonParser, authGuard, createGatewaySettingsRouter());
2913
3349
  app.use("/api/archived-mandates", jsonParser, authGuard, createArchivedMandatesRouter());
2914
3350
  app.use("/api/encrypt-intent", jsonParser, authGuard, createEncryptIntentRouter());
2915
- app.use("/api/evidence-export", authGuard, createEvidenceExportRouter(SP_URL2, vault));
3351
+ app.use("/api/evidence-export", authGuard, createEvidenceExportRouter(SP_URL, vault));
2916
3352
  app.use("/api/evidence", authGuard, createEvidenceRouter());
2917
3353
  app.use("/api/decrypt-intent", jsonParser, authGuard, createDecryptIntentRouter(vault));
2918
3354
  app.use("/api/approved-intents", jsonParser, authGuard, createApprovedIntentsRouter(vault));
@@ -3042,9 +3478,27 @@ app.get("/active-authorizations", authGuard, async (_req, res) => {
3042
3478
  res.status(500).json({ error: "Failed to fetch authorizations from MCP server" });
3043
3479
  }
3044
3480
  });
3481
+ app.get("/skipped-commitments", authGuard, async (_req, res) => {
3482
+ try {
3483
+ const data = await getSkippedCommitments();
3484
+ res.json(data);
3485
+ } catch (err) {
3486
+ console.error("[Control Plane] Skipped-commitments retrieval error:", err);
3487
+ res.status(500).json({ error: "Failed to fetch skipped commitments from MCP server" });
3488
+ }
3489
+ });
3490
+ app.get("/as-pairing", authGuard, (_req, res) => {
3491
+ const pairing = readPairing(DATA_DIR);
3492
+ res.json({
3493
+ asUrl: SP_URL,
3494
+ paired: pairing !== null && pairing.asUrl === SP_URL,
3495
+ fingerprint: pairing && pairing.asUrl === SP_URL ? fingerprintOf(pairing.publicKeyHex) : null,
3496
+ pairedAt: pairing && pairing.asUrl === SP_URL ? pairing.pairedAt : null
3497
+ });
3498
+ });
3045
3499
  app.get("/denials", authGuard, (req, res) => {
3046
3500
  try {
3047
- const dataDir = process.env.SUVEREN_DATA_DIR ?? join8(homedir7(), ".suveren");
3501
+ const dataDir = process.env.SUVEREN_DATA_DIR ?? join11(homedir7(), ".suveren");
3048
3502
  const all = loadDenials(dataDir, (blob) => vault.decrypt(blob));
3049
3503
  const since = Number(req.query.since);
3050
3504
  const limit = Number(req.query.limit);
@@ -3095,11 +3549,11 @@ app.put("/agent-brief/context", jsonParser, authGuard, async (req, res) => {
3095
3549
  res.status(413).json({ error: `Context exceeds ${AGENT_CONTEXT_MAX_BYTES}-byte cap` });
3096
3550
  return;
3097
3551
  }
3098
- const { mkdirSync: mkdirSync6, writeFileSync: writeFileSync6, renameSync: renameSync3 } = await import("fs");
3552
+ const { mkdirSync: mkdirSync8, writeFileSync: writeFileSync8, renameSync: renameSync3 } = await import("fs");
3099
3553
  const filePath = agentBriefPath();
3100
- mkdirSync6(dirname6(filePath), { recursive: true });
3554
+ mkdirSync8(dirname8(filePath), { recursive: true });
3101
3555
  const tmpPath = `${filePath}.tmp`;
3102
- writeFileSync6(tmpPath, content, "utf-8");
3556
+ writeFileSync8(tmpPath, content, "utf-8");
3103
3557
  renameSync3(tmpPath, filePath);
3104
3558
  res.json({ ok: true });
3105
3559
  } catch (err) {
@@ -3110,7 +3564,7 @@ app.put("/agent-brief/context", jsonParser, authGuard, async (req, res) => {
3110
3564
  app.use("/api", authGuard);
3111
3565
  app.use(
3112
3566
  createProxyMiddleware({
3113
- target: SP_URL2,
3567
+ target: SP_URL,
3114
3568
  changeOrigin: true,
3115
3569
  pathFilter: "/api",
3116
3570
  on: {
@@ -3122,6 +3576,9 @@ app.use(
3122
3576
  },
3123
3577
  proxyRes: (proxyRes, req) => {
3124
3578
  const status = proxyRes.statusCode ?? 0;
3579
+ if (status === 401 && vault.isUnlocked()) {
3580
+ lockExpiredSession();
3581
+ }
3125
3582
  if (status < 200 || status >= 300) return;
3126
3583
  const method = req.method?.toUpperCase();
3127
3584
  const url = req.url ?? "";
@@ -3149,13 +3606,13 @@ app.use(
3149
3606
  })
3150
3607
  );
3151
3608
  function detectInstallMethod() {
3152
- if (existsSync7("/.dockerenv")) return "docker";
3609
+ if (existsSync9("/.dockerenv")) return "docker";
3153
3610
  const dir = import.meta.dirname ?? __dirname;
3154
3611
  if (dir.includes("/node_modules/@suveren/gateway/")) return "npm";
3155
3612
  let cursor = dir;
3156
3613
  for (let i = 0; i < 8; i++) {
3157
- if (existsSync7(join8(cursor, ".git"))) return "dev";
3158
- const parent = dirname6(cursor);
3614
+ if (existsSync9(join11(cursor, ".git"))) return "dev";
3615
+ const parent = dirname8(cursor);
3159
3616
  if (parent === cursor) break;
3160
3617
  cursor = parent;
3161
3618
  }
@@ -3167,10 +3624,10 @@ function detectRunningVersion() {
3167
3624
  return process.env.HAP_BUILD_SHA ?? "dev";
3168
3625
  }
3169
3626
  const dir = import.meta.dirname ?? __dirname;
3170
- const bundlePkg = join8(dir, "..", "..", "package.json");
3171
- if (existsSync7(bundlePkg)) {
3627
+ const bundlePkg = join11(dir, "..", "..", "package.json");
3628
+ if (existsSync9(bundlePkg)) {
3172
3629
  try {
3173
- const pkg = JSON.parse(readFileSync7(bundlePkg, "utf8"));
3630
+ const pkg = JSON.parse(readFileSync10(bundlePkg, "utf8"));
3174
3631
  if (pkg.name === "@suveren/gateway" && typeof pkg.version === "string") {
3175
3632
  return pkg.version;
3176
3633
  }
@@ -3192,13 +3649,14 @@ app.get("/health", async (req, res) => {
3192
3649
  latestVersion: update.latestVersion,
3193
3650
  updateAvailable: update.updateAvailable,
3194
3651
  installMethod: INSTALL_METHOD,
3195
- spUrl: SP_URL2,
3652
+ spUrl: SP_URL,
3653
+ session: buildSessionHealth(vault),
3196
3654
  security: {
3197
3655
  note: "Gateway secures tool execution. Agent host isolation is the user's responsibility."
3198
3656
  }
3199
3657
  });
3200
3658
  });
3201
- if (existsSync7(UI_DIST)) {
3659
+ if (existsSync9(UI_DIST)) {
3202
3660
  app.use(express.static(UI_DIST, {
3203
3661
  setHeaders: (res, filePath) => {
3204
3662
  if (filePath.endsWith("index.html")) {
@@ -3208,7 +3666,7 @@ if (existsSync7(UI_DIST)) {
3208
3666
  }));
3209
3667
  app.get("*", (_req, res) => {
3210
3668
  res.setHeader("Cache-Control", "no-store, must-revalidate");
3211
- res.sendFile(join8(UI_DIST, "index.html"));
3669
+ res.sendFile(join11(UI_DIST, "index.html"));
3212
3670
  });
3213
3671
  } else {
3214
3672
  app.get("/", (_req, res) => {
@@ -3225,7 +3683,8 @@ app.listen(port, "0.0.0.0", () => {
3225
3683
  notify(title, message, process.platform, url);
3226
3684
  }
3227
3685
  startNotificationDispatcher({ url: `http://localhost:${port}` });
3228
- console.error(`[Control Plane] SP proxy: ${SP_URL2}`);
3686
+ sessionExpiryScheduler.start();
3687
+ console.error(`[Control Plane] SP proxy: ${SP_URL}`);
3229
3688
  console.error(`[Control Plane] UI dist: ${UI_DIST}`);
3230
3689
  console.error(`[Control Plane] Internal secret: configured`);
3231
3690
  console.error(`[Control Plane] MCP server: ${MCP_BASE}`);