@noodleseed/one 0.16.0 → 0.17.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 (275) hide show
  1. package/dist/cli.d.ts.map +1 -1
  2. package/dist/cli.js +49 -5
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/apps-ops.d.ts +17 -0
  5. package/dist/commands/apps-ops.d.ts.map +1 -0
  6. package/dist/commands/apps-ops.js +285 -0
  7. package/dist/commands/apps-ops.js.map +1 -0
  8. package/dist/commands/archive-ops.js +2 -2
  9. package/dist/commands/archive-ops.js.map +1 -1
  10. package/dist/commands/catalog-data-config.d.ts +9 -0
  11. package/dist/commands/catalog-data-config.d.ts.map +1 -0
  12. package/dist/commands/catalog-data-config.js +67 -0
  13. package/dist/commands/catalog-data-config.js.map +1 -0
  14. package/dist/commands/catalog-data-core.d.ts +13 -0
  15. package/dist/commands/catalog-data-core.d.ts.map +1 -0
  16. package/dist/commands/catalog-data-core.js +354 -0
  17. package/dist/commands/catalog-data-core.js.map +1 -0
  18. package/dist/commands/catalog-data-resources.d.ts +8 -0
  19. package/dist/commands/catalog-data-resources.d.ts.map +1 -0
  20. package/dist/commands/catalog-data-resources.js +506 -0
  21. package/dist/commands/catalog-data-resources.js.map +1 -0
  22. package/dist/commands/catalog-dispatch.d.ts +15 -0
  23. package/dist/commands/catalog-dispatch.d.ts.map +1 -0
  24. package/dist/commands/catalog-dispatch.js +95 -0
  25. package/dist/commands/catalog-dispatch.js.map +1 -0
  26. package/dist/commands/catalog-render.d.ts +28 -0
  27. package/dist/commands/catalog-render.d.ts.map +1 -0
  28. package/dist/commands/catalog-render.js +142 -0
  29. package/dist/commands/catalog-render.js.map +1 -0
  30. package/dist/commands/catalog-types.d.ts +46 -0
  31. package/dist/commands/catalog-types.d.ts.map +1 -0
  32. package/dist/commands/catalog-types.js +7 -0
  33. package/dist/commands/catalog-types.js.map +1 -0
  34. package/dist/commands/catalog.d.ts +30 -0
  35. package/dist/commands/catalog.d.ts.map +1 -0
  36. package/dist/commands/catalog.js +108 -0
  37. package/dist/commands/catalog.js.map +1 -0
  38. package/dist/commands/commands-ops.d.ts +2 -0
  39. package/dist/commands/commands-ops.d.ts.map +1 -0
  40. package/dist/commands/commands-ops.js +19 -0
  41. package/dist/commands/commands-ops.js.map +1 -0
  42. package/dist/commands/deploy-ops.d.ts +45 -3
  43. package/dist/commands/deploy-ops.d.ts.map +1 -1
  44. package/dist/commands/deploy-ops.js +200 -227
  45. package/dist/commands/deploy-ops.js.map +1 -1
  46. package/dist/commands/deploy-status-ops.d.ts +13 -0
  47. package/dist/commands/deploy-status-ops.d.ts.map +1 -0
  48. package/dist/commands/deploy-status-ops.js +252 -0
  49. package/dist/commands/deploy-status-ops.js.map +1 -0
  50. package/dist/commands/deployments-ops.d.ts +30 -0
  51. package/dist/commands/deployments-ops.d.ts.map +1 -0
  52. package/dist/commands/deployments-ops.js +248 -0
  53. package/dist/commands/deployments-ops.js.map +1 -0
  54. package/dist/commands/envs-ops.d.ts +8 -0
  55. package/dist/commands/envs-ops.d.ts.map +1 -0
  56. package/dist/commands/envs-ops.js +240 -0
  57. package/dist/commands/envs-ops.js.map +1 -0
  58. package/dist/commands/github-ops.d.ts +15 -0
  59. package/dist/commands/github-ops.d.ts.map +1 -0
  60. package/dist/commands/github-ops.js +296 -0
  61. package/dist/commands/github-ops.js.map +1 -0
  62. package/dist/commands/github-shared.d.ts +60 -0
  63. package/dist/commands/github-shared.d.ts.map +1 -0
  64. package/dist/commands/github-shared.js +175 -0
  65. package/dist/commands/github-shared.js.map +1 -0
  66. package/dist/commands/org-admin.d.ts.map +1 -1
  67. package/dist/commands/org-admin.js +223 -43
  68. package/dist/commands/org-admin.js.map +1 -1
  69. package/dist/commands/output.d.ts +35 -0
  70. package/dist/commands/output.d.ts.map +1 -0
  71. package/dist/commands/output.js +34 -0
  72. package/dist/commands/output.js.map +1 -0
  73. package/dist/commands/resource-shared.d.ts +132 -0
  74. package/dist/commands/resource-shared.d.ts.map +1 -0
  75. package/dist/commands/resource-shared.js +159 -0
  76. package/dist/commands/resource-shared.js.map +1 -0
  77. package/dist/commands/session.d.ts +6 -9
  78. package/dist/commands/session.d.ts.map +1 -1
  79. package/dist/commands/session.js +42 -116
  80. package/dist/commands/session.js.map +1 -1
  81. package/dist/commands/shared.d.ts.map +1 -1
  82. package/dist/commands/shared.js +3 -91
  83. package/dist/commands/shared.js.map +1 -1
  84. package/dist/commands/target-picker.d.ts +44 -0
  85. package/dist/commands/target-picker.d.ts.map +1 -0
  86. package/dist/commands/target-picker.js +88 -0
  87. package/dist/commands/target-picker.js.map +1 -0
  88. package/dist/commands/update-ops.js +1 -1
  89. package/dist/diagnostics.d.ts +5 -0
  90. package/dist/diagnostics.d.ts.map +1 -1
  91. package/dist/diagnostics.js +1 -1
  92. package/dist/diagnostics.js.map +1 -1
  93. package/dist/doctor.d.ts.map +1 -1
  94. package/dist/doctor.js +33 -0
  95. package/dist/doctor.js.map +1 -1
  96. package/dist/fire.d.ts +94 -0
  97. package/dist/fire.d.ts.map +1 -0
  98. package/dist/fire.js +418 -0
  99. package/dist/fire.js.map +1 -0
  100. package/dist/flavor.d.ts +19 -0
  101. package/dist/flavor.d.ts.map +1 -0
  102. package/dist/flavor.js +95 -0
  103. package/dist/flavor.js.map +1 -0
  104. package/dist/project.js +2 -2
  105. package/dist/prompts.d.ts.map +1 -1
  106. package/dist/prompts.js +30 -17
  107. package/dist/prompts.js.map +1 -1
  108. package/dist/relative-time.d.ts +8 -0
  109. package/dist/relative-time.d.ts.map +1 -0
  110. package/dist/relative-time.js +29 -0
  111. package/dist/relative-time.js.map +1 -0
  112. package/dist/table.d.ts +47 -0
  113. package/dist/table.d.ts.map +1 -0
  114. package/dist/table.js +152 -0
  115. package/dist/table.js.map +1 -0
  116. package/dist/update-binary.js +1 -1
  117. package/dist/update-check.d.ts +1 -1
  118. package/dist/update-check.js +1 -1
  119. package/dist/update.js +1 -1
  120. package/dist/watch.d.ts +52 -0
  121. package/dist/watch.d.ts.map +1 -0
  122. package/dist/watch.js +177 -0
  123. package/dist/watch.js.map +1 -0
  124. package/node_modules/@noodle-borg/agent-kit/dist/curated/command-groups.d.ts.map +1 -1
  125. package/node_modules/@noodle-borg/agent-kit/dist/curated/command-groups.js +23 -1
  126. package/node_modules/@noodle-borg/agent-kit/dist/curated/command-groups.js.map +1 -1
  127. package/node_modules/@noodle-borg/agent-kit/dist/generated/surface.d.ts.map +1 -1
  128. package/node_modules/@noodle-borg/agent-kit/dist/generated/surface.js +5 -0
  129. package/node_modules/@noodle-borg/agent-kit/dist/generated/surface.js.map +1 -1
  130. package/node_modules/@noodle-borg/agent-kit/package.json +1 -1
  131. package/node_modules/@noodle-borg/authoring/dist/connectors.js +14 -0
  132. package/node_modules/@noodle-borg/authoring/dist/connectors.js.map +1 -1
  133. package/node_modules/@noodle-borg/connector-defs/dist/compile.js +9 -0
  134. package/node_modules/@noodle-borg/connector-defs/dist/compile.js.map +1 -1
  135. package/node_modules/@noodle-borg/openapi-import/dist/index.d.ts.map +1 -1
  136. package/node_modules/@noodle-borg/openapi-import/dist/index.js +3 -1
  137. package/node_modules/@noodle-borg/openapi-import/dist/index.js.map +1 -1
  138. package/node_modules/@noodle-borg/service/dist/github/app-client.d.ts +49 -0
  139. package/node_modules/@noodle-borg/service/dist/github/app-client.d.ts.map +1 -0
  140. package/node_modules/@noodle-borg/service/dist/github/app-client.js +23 -0
  141. package/node_modules/@noodle-borg/service/dist/github/app-client.js.map +1 -0
  142. package/node_modules/@noodle-borg/service/dist/github/install-nonce.d.ts +23 -0
  143. package/node_modules/@noodle-borg/service/dist/github/install-nonce.d.ts.map +1 -0
  144. package/node_modules/@noodle-borg/service/dist/github/install-nonce.js +57 -0
  145. package/node_modules/@noodle-borg/service/dist/github/install-nonce.js.map +1 -0
  146. package/node_modules/@noodle-borg/service/dist/github/pending-installations.d.ts +31 -0
  147. package/node_modules/@noodle-borg/service/dist/github/pending-installations.d.ts.map +1 -0
  148. package/node_modules/@noodle-borg/service/dist/github/pending-installations.js +34 -0
  149. package/node_modules/@noodle-borg/service/dist/github/pending-installations.js.map +1 -0
  150. package/node_modules/@noodle-borg/service/dist/index.d.ts +7 -1
  151. package/node_modules/@noodle-borg/service/dist/index.d.ts.map +1 -1
  152. package/node_modules/@noodle-borg/service/dist/index.js +7 -1
  153. package/node_modules/@noodle-borg/service/dist/index.js.map +1 -1
  154. package/node_modules/@noodle-borg/service/dist/options.d.ts +28 -1
  155. package/node_modules/@noodle-borg/service/dist/options.d.ts.map +1 -1
  156. package/node_modules/@noodle-borg/service/dist/registry-state.d.ts +28 -7
  157. package/node_modules/@noodle-borg/service/dist/registry-state.d.ts.map +1 -1
  158. package/node_modules/@noodle-borg/service/dist/registry-state.js +116 -3
  159. package/node_modules/@noodle-borg/service/dist/registry-state.js.map +1 -1
  160. package/node_modules/@noodle-borg/service/dist/registry.d.ts +14 -1
  161. package/node_modules/@noodle-borg/service/dist/registry.d.ts.map +1 -1
  162. package/node_modules/@noodle-borg/service/dist/registry.js +20 -45
  163. package/node_modules/@noodle-borg/service/dist/registry.js.map +1 -1
  164. package/node_modules/@noodle-borg/service/dist/routes/analytics-dispatch.d.ts +23 -0
  165. package/node_modules/@noodle-borg/service/dist/routes/analytics-dispatch.d.ts.map +1 -0
  166. package/node_modules/@noodle-borg/service/dist/routes/analytics-dispatch.js +53 -0
  167. package/node_modules/@noodle-borg/service/dist/routes/analytics-dispatch.js.map +1 -0
  168. package/node_modules/@noodle-borg/service/dist/routes/apps.d.ts +24 -0
  169. package/node_modules/@noodle-borg/service/dist/routes/apps.d.ts.map +1 -0
  170. package/node_modules/@noodle-borg/service/dist/routes/apps.js +72 -0
  171. package/node_modules/@noodle-borg/service/dist/routes/apps.js.map +1 -0
  172. package/node_modules/@noodle-borg/service/dist/routes/contracts.d.ts +316 -0
  173. package/node_modules/@noodle-borg/service/dist/routes/contracts.d.ts.map +1 -0
  174. package/node_modules/@noodle-borg/service/dist/routes/contracts.js +152 -0
  175. package/node_modules/@noodle-borg/service/dist/routes/contracts.js.map +1 -0
  176. package/node_modules/@noodle-borg/service/dist/routes/deployments.d.ts +12 -1
  177. package/node_modules/@noodle-borg/service/dist/routes/deployments.d.ts.map +1 -1
  178. package/node_modules/@noodle-borg/service/dist/routes/deployments.js +31 -2
  179. package/node_modules/@noodle-borg/service/dist/routes/deployments.js.map +1 -1
  180. package/node_modules/@noodle-borg/service/dist/routes/endpoint-enrichment.d.ts +17 -0
  181. package/node_modules/@noodle-borg/service/dist/routes/endpoint-enrichment.d.ts.map +1 -0
  182. package/node_modules/@noodle-borg/service/dist/routes/endpoint-enrichment.js +15 -0
  183. package/node_modules/@noodle-borg/service/dist/routes/endpoint-enrichment.js.map +1 -0
  184. package/node_modules/@noodle-borg/service/dist/routes/envs.d.ts +22 -0
  185. package/node_modules/@noodle-borg/service/dist/routes/envs.d.ts.map +1 -0
  186. package/node_modules/@noodle-borg/service/dist/routes/envs.js +46 -0
  187. package/node_modules/@noodle-borg/service/dist/routes/envs.js.map +1 -0
  188. package/node_modules/@noodle-borg/service/dist/routes/github-connection.d.ts +29 -0
  189. package/node_modules/@noodle-borg/service/dist/routes/github-connection.d.ts.map +1 -0
  190. package/node_modules/@noodle-borg/service/dist/routes/github-connection.js +202 -0
  191. package/node_modules/@noodle-borg/service/dist/routes/github-connection.js.map +1 -0
  192. package/node_modules/@noodle-borg/service/dist/routes/github-dispatch.d.ts +29 -0
  193. package/node_modules/@noodle-borg/service/dist/routes/github-dispatch.d.ts.map +1 -0
  194. package/node_modules/@noodle-borg/service/dist/routes/github-dispatch.js +60 -0
  195. package/node_modules/@noodle-borg/service/dist/routes/github-dispatch.js.map +1 -0
  196. package/node_modules/@noodle-borg/service/dist/routes/github-setup.d.ts +28 -0
  197. package/node_modules/@noodle-borg/service/dist/routes/github-setup.d.ts.map +1 -0
  198. package/node_modules/@noodle-borg/service/dist/routes/github-setup.js +80 -0
  199. package/node_modules/@noodle-borg/service/dist/routes/github-setup.js.map +1 -0
  200. package/node_modules/@noodle-borg/service/dist/routes/org-admin.d.ts +5 -0
  201. package/node_modules/@noodle-borg/service/dist/routes/org-admin.d.ts.map +1 -1
  202. package/node_modules/@noodle-borg/service/dist/routes/org-admin.js +13 -1
  203. package/node_modules/@noodle-borg/service/dist/routes/org-admin.js.map +1 -1
  204. package/node_modules/@noodle-borg/service/dist/routes/paths.d.ts +44 -0
  205. package/node_modules/@noodle-borg/service/dist/routes/paths.d.ts.map +1 -1
  206. package/node_modules/@noodle-borg/service/dist/routes/paths.js +116 -1
  207. package/node_modules/@noodle-borg/service/dist/routes/paths.js.map +1 -1
  208. package/node_modules/@noodle-borg/service/dist/routes/resource-read-dispatch.d.ts +33 -0
  209. package/node_modules/@noodle-borg/service/dist/routes/resource-read-dispatch.d.ts.map +1 -0
  210. package/node_modules/@noodle-borg/service/dist/routes/resource-read-dispatch.js +69 -0
  211. package/node_modules/@noodle-borg/service/dist/routes/resource-read-dispatch.js.map +1 -0
  212. package/node_modules/@noodle-borg/service/dist/service.d.ts.map +1 -1
  213. package/node_modules/@noodle-borg/service/dist/service.js +60 -45
  214. package/node_modules/@noodle-borg/service/dist/service.js.map +1 -1
  215. package/node_modules/@noodle-borg/service/dist/store/control-plane.d.ts +1 -0
  216. package/node_modules/@noodle-borg/service/dist/store/control-plane.d.ts.map +1 -1
  217. package/node_modules/@noodle-borg/service/dist/store/control-plane.js +3 -0
  218. package/node_modules/@noodle-borg/service/dist/store/control-plane.js.map +1 -1
  219. package/node_modules/@noodle-borg/service/dist/store/github-connections-json-file.d.ts +23 -0
  220. package/node_modules/@noodle-borg/service/dist/store/github-connections-json-file.d.ts.map +1 -0
  221. package/node_modules/@noodle-borg/service/dist/store/github-connections-json-file.js +137 -0
  222. package/node_modules/@noodle-borg/service/dist/store/github-connections-json-file.js.map +1 -0
  223. package/node_modules/@noodle-borg/service/dist/store/github-connections.d.ts +30 -0
  224. package/node_modules/@noodle-borg/service/dist/store/github-connections.d.ts.map +1 -0
  225. package/node_modules/@noodle-borg/service/dist/store/github-connections.js +116 -0
  226. package/node_modules/@noodle-borg/service/dist/store/github-connections.js.map +1 -0
  227. package/node_modules/@noodle-borg/service/dist/store/in-memory.d.ts +32 -0
  228. package/node_modules/@noodle-borg/service/dist/store/in-memory.d.ts.map +1 -0
  229. package/node_modules/@noodle-borg/service/dist/store/in-memory.js +169 -0
  230. package/node_modules/@noodle-borg/service/dist/store/in-memory.js.map +1 -0
  231. package/node_modules/@noodle-borg/service/dist/store/json-file.d.ts +14 -1
  232. package/node_modules/@noodle-borg/service/dist/store/json-file.d.ts.map +1 -1
  233. package/node_modules/@noodle-borg/service/dist/store/json-file.js +54 -1
  234. package/node_modules/@noodle-borg/service/dist/store/json-file.js.map +1 -1
  235. package/node_modules/@noodle-borg/service/dist/store/postgres-apps.d.ts +11 -0
  236. package/node_modules/@noodle-borg/service/dist/store/postgres-apps.d.ts.map +1 -0
  237. package/node_modules/@noodle-borg/service/dist/store/postgres-apps.js +31 -0
  238. package/node_modules/@noodle-borg/service/dist/store/postgres-apps.js.map +1 -0
  239. package/node_modules/@noodle-borg/service/dist/store/postgres-config.d.ts +21 -0
  240. package/node_modules/@noodle-borg/service/dist/store/postgres-config.d.ts.map +1 -0
  241. package/node_modules/@noodle-borg/service/dist/store/postgres-config.js +80 -0
  242. package/node_modules/@noodle-borg/service/dist/store/postgres-config.js.map +1 -0
  243. package/node_modules/@noodle-borg/service/dist/store/postgres-control-plane.d.ts +1 -0
  244. package/node_modules/@noodle-borg/service/dist/store/postgres-control-plane.d.ts.map +1 -1
  245. package/node_modules/@noodle-borg/service/dist/store/postgres-control-plane.js +6 -0
  246. package/node_modules/@noodle-borg/service/dist/store/postgres-control-plane.js.map +1 -1
  247. package/node_modules/@noodle-borg/service/dist/store/postgres-envs.d.ts +7 -0
  248. package/node_modules/@noodle-borg/service/dist/store/postgres-envs.d.ts.map +1 -0
  249. package/node_modules/@noodle-borg/service/dist/store/postgres-envs.js +34 -0
  250. package/node_modules/@noodle-borg/service/dist/store/postgres-envs.js.map +1 -0
  251. package/node_modules/@noodle-borg/service/dist/store/postgres-github.d.ts +12 -0
  252. package/node_modules/@noodle-borg/service/dist/store/postgres-github.d.ts.map +1 -0
  253. package/node_modules/@noodle-borg/service/dist/store/postgres-github.js +125 -0
  254. package/node_modules/@noodle-borg/service/dist/store/postgres-github.js.map +1 -0
  255. package/node_modules/@noodle-borg/service/dist/store/postgres-schema.d.ts.map +1 -1
  256. package/node_modules/@noodle-borg/service/dist/store/postgres-schema.js +36 -0
  257. package/node_modules/@noodle-borg/service/dist/store/postgres-schema.js.map +1 -1
  258. package/node_modules/@noodle-borg/service/dist/store/postgres.d.ts +25 -2
  259. package/node_modules/@noodle-borg/service/dist/store/postgres.d.ts.map +1 -1
  260. package/node_modules/@noodle-borg/service/dist/store/postgres.js +56 -75
  261. package/node_modules/@noodle-borg/service/dist/store/postgres.js.map +1 -1
  262. package/node_modules/@noodle-borg/service/dist/store/records.d.ts +56 -3
  263. package/node_modules/@noodle-borg/service/dist/store/records.d.ts.map +1 -1
  264. package/node_modules/@noodle-borg/service/dist/store/records.js +158 -0
  265. package/node_modules/@noodle-borg/service/dist/store/records.js.map +1 -1
  266. package/node_modules/@noodle-borg/service/dist/store/validate.d.ts +2 -0
  267. package/node_modules/@noodle-borg/service/dist/store/validate.d.ts.map +1 -1
  268. package/node_modules/@noodle-borg/service/dist/store/validate.js +7 -0
  269. package/node_modules/@noodle-borg/service/dist/store/validate.js.map +1 -1
  270. package/node_modules/@noodle-borg/service/dist/store.d.ts +161 -17
  271. package/node_modules/@noodle-borg/service/dist/store.d.ts.map +1 -1
  272. package/node_modules/@noodle-borg/service/dist/store.js +8 -118
  273. package/node_modules/@noodle-borg/service/dist/store.js.map +1 -1
  274. package/node_modules/@noodle-borg/service/package.json +2 -1
  275. package/package.json +2 -2
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The `envs` resource read routes: `GET /v1/orgs/{org}/apps/{app}/envs` (list) and
3
+ * `GET /v1/orgs/{org}/apps/{app}/envs/{env}` (inspect). Membership-gated exactly like the `apps`
4
+ * routes (`authorizeTenantControl`); the response payload is `.parse()`d through the Zod contracts
5
+ * (`./contracts.js`) before it goes on the wire, so the shape can never drift from what's declared
6
+ * there. Contract-parse failures return 500 via `sendContract` (our bug, not the caller's); store
7
+ * lookups keep 400. No pagination — env counts per app are small.
8
+ */
9
+ import type { IncomingMessage, ServerResponse } from 'node:http';
10
+ import type { DeployAuthGate } from '../auth/deploy-gate.js';
11
+ import type { ServerRegistry } from '../registry.js';
12
+ import type { ControlPlaneStore } from '../store.js';
13
+ export declare function handleEnvs(req: IncomingMessage, res: ServerResponse, registry: ServerRegistry, gate: DeployAuthGate, controlPlane: ControlPlaneStore, ref: {
14
+ org: string;
15
+ app: string;
16
+ }, url: URL, endpointBase: string): Promise<void>;
17
+ export declare function handleEnv(req: IncomingMessage, res: ServerResponse, registry: ServerRegistry, gate: DeployAuthGate, controlPlane: ControlPlaneStore, ref: {
18
+ org: string;
19
+ app: string;
20
+ env: string;
21
+ }, endpointBase: string): Promise<void>;
22
+ //# sourceMappingURL=envs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"envs.d.ts","sourceRoot":"","sources":["../../src/routes/envs.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAMrD,wBAAsB,UAAU,CAC9B,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAE,cAAc,EACpB,YAAY,EAAE,iBAAiB,EAC/B,GAAG,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EACjC,GAAG,EAAE,GAAG,EACR,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC,CAsBf;AAED,wBAAsB,SAAS,CAC7B,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAE,cAAc,EACpB,YAAY,EAAE,iBAAiB,EAC/B,GAAG,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EAC9C,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC,CAYf"}
@@ -0,0 +1,46 @@
1
+ import { sendJson } from '../http-util.js';
2
+ import { sendContract } from './apps.js';
3
+ import { EnvResponseSchema, EnvsListResponseSchema } from './contracts.js';
4
+ import { authorizeTenantControl } from './control-plane.js';
5
+ import { envWithEndpointUrl } from './endpoint-enrichment.js';
6
+ export async function handleEnvs(req, res, registry, gate, controlPlane, ref, url, endpointBase) {
7
+ const identity = await authorizeTenantControl(req, res, gate, controlPlane, ref.org);
8
+ if (identity === false)
9
+ return;
10
+ const includeArchived = url.searchParams.get('archived') === 'true';
11
+ let envs;
12
+ try {
13
+ // Distinguish "app has no envs yet" (200, empty list) from "app does not exist" (404) — the same
14
+ // way `handleApp` treats a missing `getApp` result as not-found.
15
+ const app = await registry.getApp(ref.org, ref.app);
16
+ if (app === undefined)
17
+ return sendJson(res, 404, { error: 'not found' });
18
+ envs = await registry.listEnvironments(ref.org, ref.app, {
19
+ ...(includeArchived ? { includeArchived: true } : {}),
20
+ });
21
+ }
22
+ catch (error) {
23
+ return sendJson(res, 400, { error: error.message });
24
+ }
25
+ return sendContract(res, () => EnvsListResponseSchema.parse({
26
+ ok: true,
27
+ data: { envs: envs.map((env) => envWithEndpointUrl(env, endpointBase)) },
28
+ }));
29
+ }
30
+ export async function handleEnv(req, res, registry, gate, controlPlane, ref, endpointBase) {
31
+ const identity = await authorizeTenantControl(req, res, gate, controlPlane, ref.org);
32
+ if (identity === false)
33
+ return;
34
+ let env;
35
+ try {
36
+ env = await registry.getEnvironment(ref.org, ref.app, ref.env);
37
+ }
38
+ catch (error) {
39
+ return sendJson(res, 400, { error: error.message });
40
+ }
41
+ if (env === undefined)
42
+ return sendJson(res, 404, { error: 'not found' });
43
+ const enriched = envWithEndpointUrl(env, endpointBase);
44
+ return sendContract(res, () => EnvResponseSchema.parse({ ok: true, data: enriched }));
45
+ }
46
+ //# sourceMappingURL=envs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"envs.js","sourceRoot":"","sources":["../../src/routes/envs.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,GAAoB,EACpB,GAAmB,EACnB,QAAwB,EACxB,IAAoB,EACpB,YAA+B,EAC/B,GAAiC,EACjC,GAAQ,EACR,YAAoB;IAEpB,MAAM,QAAQ,GAAG,MAAM,sBAAsB,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IACrF,IAAI,QAAQ,KAAK,KAAK;QAAE,OAAO;IAC/B,MAAM,eAAe,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,MAAM,CAAC;IACpE,IAAI,IAA6D,CAAC;IAClE,IAAI,CAAC;QACH,iGAAiG;QACjG,iEAAiE;QACjE,MAAM,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AAG,MAAM,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IACjE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,KAAK,EAAG,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;IACjE,CAAC;IACD,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC;IACzE,MAAM,QAAQ,GAAG,kBAAkB,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IACvD,OAAO,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;AACxF,CAAC"}
@@ -0,0 +1,29 @@
1
+ import type { IncomingMessage, ServerResponse } from 'node:http';
2
+ import type { DeployAuthGate } from '../auth/deploy-gate.js';
3
+ import type { GitHubAppClient, GithubAppConfig } from '../github/app-client.js';
4
+ import type { PendingGithubInstallationStore } from '../github/pending-installations.js';
5
+ import type { AuditSink } from '../store/audit.js';
6
+ import type { ControlPlaneStore, GithubConnectionStore } from '../store.js';
7
+ export interface GithubConnectionRouteRef {
8
+ readonly org: string;
9
+ readonly app: string;
10
+ }
11
+ export declare function handleGithubConnection(req: IncomingMessage, res: ServerResponse, gate: DeployAuthGate, controlPlane: ControlPlaneStore, store: GithubConnectionStore, client: GitHubAppClient | undefined, githubApp: GithubAppConfig | undefined, maxBody: number, ref: GithubConnectionRouteRef, audit: AuditSink): Promise<void>;
12
+ /**
13
+ * `GET /v1/github/install-url` — authenticated (any identity, membership is checked later at claim/connect
14
+ * time); `?org=`/`?app=` name the target. Returns GitHub's installations/new URL plus an HMAC-signed,
15
+ * 10-minute `state` nonce binding `{subject, org, app, issuedAt}` so a later `claim` can only be completed
16
+ * by the same caller for the same org/app. 409 when the GitHub App is not configured.
17
+ */
18
+ export declare function handleGithubInstallUrl(req: IncomingMessage, res: ServerResponse, gate: DeployAuthGate, githubApp: GithubAppConfig | undefined, url: URL): Promise<void>;
19
+ /**
20
+ * `POST /v1/github/installations/claim` — verifies the `state` nonce (signature, expiry, and that the
21
+ * caller is the same subject who requested it), then requires the caller to be an org OWNER of the
22
+ * nonce's bound org before returning the installation's repositories for the client to pick from. Any
23
+ * nonce problem (tampered, expired, foreign subject) is a 403 with no state change. The installationId
24
+ * is derived EXCLUSIVELY from the pending store entry GitHub's setup redirect landed for this state —
25
+ * never from the request body — so a caller can only ever enumerate the installation they themselves
26
+ * just installed, not an arbitrary tenant's (409 when the redirect hasn't landed).
27
+ */
28
+ export declare function handleGithubInstallationClaim(req: IncomingMessage, res: ServerResponse, gate: DeployAuthGate, controlPlane: ControlPlaneStore, client: GitHubAppClient | undefined, githubApp: GithubAppConfig | undefined, pendingStore: PendingGithubInstallationStore, maxBody: number): Promise<void>;
29
+ //# sourceMappingURL=github-connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github-connection.d.ts","sourceRoot":"","sources":["../../src/routes/github-connection.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAMhF,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,oCAAoC,CAAC;AAEzF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAM5E,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,cAAc,EACpB,YAAY,EAAE,iBAAiB,EAC/B,KAAK,EAAE,qBAAqB,EAC5B,MAAM,EAAE,eAAe,GAAG,SAAS,EACnC,SAAS,EAAE,eAAe,GAAG,SAAS,EACtC,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,wBAAwB,EAC7B,KAAK,EAAE,SAAS,GACf,OAAO,CAAC,IAAI,CAAC,CAOf;AA0ID;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,cAAc,EACpB,SAAS,EAAE,eAAe,GAAG,SAAS,EACtC,GAAG,EAAE,GAAG,GACP,OAAO,CAAC,IAAI,CAAC,CA0Bf;AAED;;;;;;;;GAQG;AACH,wBAAsB,6BAA6B,CACjD,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,cAAc,EACpB,YAAY,EAAE,iBAAiB,EAC/B,MAAM,EAAE,eAAe,GAAG,SAAS,EACnC,SAAS,EAAE,eAAe,GAAG,SAAS,EACtC,YAAY,EAAE,8BAA8B,EAC5C,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CA2Bf"}
@@ -0,0 +1,202 @@
1
+ /**
2
+ * GHD-1 GitHub repository connection routes: `GET`/`POST`/`DELETE
3
+ * /v1/orgs/{org}/apps/{app}/github/connection`, plus the installation hand-off
4
+ * `GET /v1/github/install-url` and `POST /v1/github/installations/claim`. Membership rules mirror the
5
+ * org-admin routes exactly (`authorizeTenantControl` for member reads, `canManageMembers` for owner-only
6
+ * writes) — this file is the security review point for GHD-1.2. The server NEVER trusts caller-supplied
7
+ * repo metadata: `POST .../connection` always re-derives `ownerLogin`/`repoName`/`defaultBranch` from the
8
+ * {@link GitHubAppClient}, and no route here ever persists a token.
9
+ */
10
+ import { randomUUID } from 'node:crypto';
11
+ import { resolveGithubStateSecret, signInstallNonce, verifyInstallNonce, } from '../github/install-nonce.js';
12
+ import { readJsonBody, sendForbidden, sendJson } from '../http-util.js';
13
+ import { sendContract } from './apps.js';
14
+ import { GithubConnectionResponseSchema, GithubInstallUrlResponseSchema } from './contracts.js';
15
+ import { authorizeControlPlane, authorizeTenantControl } from './control-plane.js';
16
+ import { canManageMembers } from './org-admin.js';
17
+ export async function handleGithubConnection(req, res, gate, controlPlane, store, client, githubApp, maxBody, ref, audit) {
18
+ if (req.method === 'GET')
19
+ return handleGet(req, res, gate, controlPlane, store, ref);
20
+ if (req.method === 'POST') {
21
+ return handlePost(req, res, gate, controlPlane, store, client, githubApp, maxBody, ref, audit);
22
+ }
23
+ if (req.method === 'DELETE')
24
+ return handleDelete(req, res, gate, controlPlane, store, ref, audit);
25
+ return sendJson(res, 404, { error: 'not found' });
26
+ }
27
+ /** `GET .../github/connection` — org MEMBER read; 404 when no connection is enabled. */
28
+ async function handleGet(req, res, gate, controlPlane, store, ref) {
29
+ const identity = await authorizeTenantControl(req, res, gate, controlPlane, ref.org);
30
+ if (identity === false)
31
+ return;
32
+ const record = await store.getRepoConnection(ref.org, ref.app);
33
+ if (record === undefined)
34
+ return sendJson(res, 404, { error: 'not found' });
35
+ return sendContract(res, () => GithubConnectionResponseSchema.parse({ ok: true, data: record }));
36
+ }
37
+ /**
38
+ * `POST .../github/connection` — org OWNER only. Verifies the installation exists AND the repository
39
+ * belongs to it via the {@link GitHubAppClient} before writing anything (a mismatch is a 400 with no
40
+ * state change); fills `ownerLogin`/`repoName`/`defaultBranch` from the client, never from the request
41
+ * body. Uniqueness conflicts (same app already connected to a different repo, or vice versa) are a 409.
42
+ */
43
+ async function handlePost(req, res, gate, controlPlane, store, client, githubApp, maxBody, ref, audit) {
44
+ const identity = await authorizeControlPlane(req, res, gate, { requireIdentity: true });
45
+ if (identity === false)
46
+ return;
47
+ if (!(await canManageMembers(controlPlane, ref.org, identity)))
48
+ return sendForbidden(res, 'forbidden');
49
+ if (githubApp?.appSlug === undefined) {
50
+ return sendJson(res, 409, { error: 'the GitHub App is not configured for this service' });
51
+ }
52
+ if (client === undefined) {
53
+ return sendJson(res, 409, {
54
+ error: 'the GitHub App client is not configured for this service',
55
+ });
56
+ }
57
+ const body = await readJsonBody(req, maxBody);
58
+ if (!body.ok)
59
+ return sendJson(res, body.status, { error: body.error });
60
+ const parsed = body.value;
61
+ if (!isPositiveInteger(parsed.installationId)) {
62
+ return sendJson(res, 400, { error: '"installationId" must be a positive integer' });
63
+ }
64
+ if (!isPositiveInteger(parsed.githubRepositoryId)) {
65
+ return sendJson(res, 400, { error: '"githubRepositoryId" must be a positive integer' });
66
+ }
67
+ if (parsed.repoRoot !== undefined && typeof parsed.repoRoot !== 'string') {
68
+ return sendJson(res, 400, { error: '"repoRoot" must be a string' });
69
+ }
70
+ const installationId = parsed.installationId;
71
+ const githubRepositoryId = parsed.githubRepositoryId;
72
+ const repoRoot = typeof parsed.repoRoot === 'string' ? parsed.repoRoot : undefined;
73
+ const installation = await client.getInstallation(installationId);
74
+ if (installation === undefined) {
75
+ return sendJson(res, 400, { error: `installation ${installationId} not found` });
76
+ }
77
+ const repositories = await client.listInstallationRepositories(installationId);
78
+ const repository = repositories.find((candidate) => candidate.id === githubRepositoryId);
79
+ if (repository === undefined) {
80
+ return sendJson(res, 400, {
81
+ error: `repository ${githubRepositoryId} does not belong to installation ${installationId}`,
82
+ });
83
+ }
84
+ const result = await store.upsertRepoConnection({
85
+ githubRepositoryId,
86
+ installationId,
87
+ ownerLogin: installation.accountLogin,
88
+ repoName: repository.fullName,
89
+ defaultBranch: repository.defaultBranch,
90
+ ...(repoRoot !== undefined ? { repoRoot } : {}),
91
+ orgSlug: ref.org,
92
+ appSlug: ref.app,
93
+ createdBySubject: identity.subject,
94
+ });
95
+ if (!result.ok)
96
+ return sendJson(res, 409, { error: result.error.message });
97
+ await audit.emit({
98
+ eventType: 'github.connection.connected',
99
+ org: ref.org,
100
+ app: ref.app,
101
+ decision: 'allow',
102
+ status: 200,
103
+ actorSubject: identity.subject,
104
+ ...(identity.email !== undefined ? { actorEmail: identity.email } : {}),
105
+ details: { githubRepositoryId, installationId },
106
+ });
107
+ return sendContract(res, () => GithubConnectionResponseSchema.parse({ ok: true, data: result.record }));
108
+ }
109
+ /** `DELETE .../github/connection` — org OWNER only; idempotent disable. */
110
+ async function handleDelete(req, res, gate, controlPlane, store, ref, audit) {
111
+ const identity = await authorizeControlPlane(req, res, gate, { requireIdentity: true });
112
+ if (identity === false)
113
+ return;
114
+ if (!(await canManageMembers(controlPlane, ref.org, identity)))
115
+ return sendForbidden(res, 'forbidden');
116
+ const disabled = await store.disableRepoConnection(ref.org, ref.app);
117
+ if (disabled) {
118
+ await audit.emit({
119
+ eventType: 'github.connection.disabled',
120
+ org: ref.org,
121
+ app: ref.app,
122
+ decision: 'allow',
123
+ status: 200,
124
+ actorSubject: identity.subject,
125
+ ...(identity.email !== undefined ? { actorEmail: identity.email } : {}),
126
+ details: {},
127
+ });
128
+ }
129
+ return sendJson(res, 200, { ok: true, data: { disabled } });
130
+ }
131
+ /**
132
+ * `GET /v1/github/install-url` — authenticated (any identity, membership is checked later at claim/connect
133
+ * time); `?org=`/`?app=` name the target. Returns GitHub's installations/new URL plus an HMAC-signed,
134
+ * 10-minute `state` nonce binding `{subject, org, app, issuedAt}` so a later `claim` can only be completed
135
+ * by the same caller for the same org/app. 409 when the GitHub App is not configured.
136
+ */
137
+ export async function handleGithubInstallUrl(req, res, gate, githubApp, url) {
138
+ const identity = await authorizeControlPlane(req, res, gate, { requireIdentity: true });
139
+ if (identity === false)
140
+ return;
141
+ if (githubApp?.appSlug === undefined) {
142
+ return sendJson(res, 409, { error: 'the GitHub App is not configured for this service' });
143
+ }
144
+ const orgParam = url.searchParams.get('org');
145
+ const appParam = url.searchParams.get('app');
146
+ if (orgParam === null || appParam === null) {
147
+ return sendJson(res, 400, { error: '"org" and "app" query parameters are required' });
148
+ }
149
+ const secret = resolveGithubStateSecret(githubApp.webhookSecret);
150
+ const state = signInstallNonce({
151
+ nonceId: randomUUID(),
152
+ subject: identity.subject,
153
+ org: orgParam,
154
+ app: appParam,
155
+ issuedAt: Date.now(),
156
+ }, secret);
157
+ const installUrl = `https://github.com/apps/${encodeURIComponent(githubApp.appSlug)}/installations/new?state=${encodeURIComponent(state)}`;
158
+ return sendContract(res, () => GithubInstallUrlResponseSchema.parse({ ok: true, data: { installUrl, state } }));
159
+ }
160
+ /**
161
+ * `POST /v1/github/installations/claim` — verifies the `state` nonce (signature, expiry, and that the
162
+ * caller is the same subject who requested it), then requires the caller to be an org OWNER of the
163
+ * nonce's bound org before returning the installation's repositories for the client to pick from. Any
164
+ * nonce problem (tampered, expired, foreign subject) is a 403 with no state change. The installationId
165
+ * is derived EXCLUSIVELY from the pending store entry GitHub's setup redirect landed for this state —
166
+ * never from the request body — so a caller can only ever enumerate the installation they themselves
167
+ * just installed, not an arbitrary tenant's (409 when the redirect hasn't landed).
168
+ */
169
+ export async function handleGithubInstallationClaim(req, res, gate, controlPlane, client, githubApp, pendingStore, maxBody) {
170
+ const identity = await authorizeControlPlane(req, res, gate, { requireIdentity: true });
171
+ if (identity === false)
172
+ return;
173
+ const body = await readJsonBody(req, maxBody);
174
+ if (!body.ok)
175
+ return sendJson(res, body.status, { error: body.error });
176
+ const parsed = body.value;
177
+ if (typeof parsed.state !== 'string')
178
+ return sendJson(res, 400, { error: '"state" must be a string' });
179
+ const secret = resolveGithubStateSecret(githubApp?.webhookSecret);
180
+ const verification = verifyInstallNonce(parsed.state, secret);
181
+ if (!verification.ok || verification.payload.subject !== identity.subject) {
182
+ return sendForbidden(res, 'invalid or expired state');
183
+ }
184
+ if (!(await canManageMembers(controlPlane, verification.payload.org, identity))) {
185
+ return sendForbidden(res, 'forbidden');
186
+ }
187
+ if (client === undefined) {
188
+ return sendJson(res, 409, {
189
+ error: 'the GitHub App client is not configured for this service',
190
+ });
191
+ }
192
+ const installationId = pendingStore.get(parsed.state);
193
+ if (installationId === undefined) {
194
+ return sendJson(res, 409, { error: 'the GitHub installation has not landed yet' });
195
+ }
196
+ const repositories = await client.listInstallationRepositories(installationId);
197
+ return sendJson(res, 200, { ok: true, data: { installationId, repositories } });
198
+ }
199
+ function isPositiveInteger(value) {
200
+ return typeof value === 'number' && Number.isInteger(value) && value > 0;
201
+ }
202
+ //# sourceMappingURL=github-connection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github-connection.js","sourceRoot":"","sources":["../../src/routes/github-connection.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIzC,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAGxE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,8BAA8B,EAAE,8BAA8B,EAAE,MAAM,gBAAgB,CAAC;AAChG,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAOlD,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,GAAoB,EACpB,GAAmB,EACnB,IAAoB,EACpB,YAA+B,EAC/B,KAA4B,EAC5B,MAAmC,EACnC,SAAsC,EACtC,OAAe,EACf,GAA6B,EAC7B,KAAgB;IAEhB,IAAI,GAAG,CAAC,MAAM,KAAK,KAAK;QAAE,OAAO,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;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zC,CAAC;IACD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE;YACxB,KAAK,EAAE,0DAA0D;SAClE,CAAC,CAAC;IACL,CAAC;IACD,MAAM,cAAc,GAAG,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACtD,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;QACjC,OAAO,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,4CAA4C,EAAE,CAAC,CAAC;IACrF,CAAC;IACD,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,4BAA4B,CAAC,cAAc,CAAC,CAAC;IAC/E,OAAO,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,cAAc,EAAE,YAAY,EAAE,EAAE,CAAC,CAAC;AAClF,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAc;IACvC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC;AAC3E,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Dispatch for the GHD-1 GitHub connection routes. Extracted the same way as
3
+ * `resource-read-dispatch.ts`/`analytics-dispatch.ts` so `service.ts` stays a thin composition root
4
+ * under the size gate.
5
+ */
6
+ import type { IncomingMessage, ServerResponse } from 'node:http';
7
+ import type { TlsPosture } from '@noodle-borg/transport-http';
8
+ import type { DeployAuthGate } from '../auth/deploy-gate.js';
9
+ import type { GitHubAppClient, GithubAppConfig } from '../github/app-client.js';
10
+ import type { PendingGithubInstallationStore } from '../github/pending-installations.js';
11
+ import type { AuditSink } from '../store/audit.js';
12
+ import type { ControlPlaneStore, GithubConnectionStore } from '../store.js';
13
+ export interface GithubDispatchDeps {
14
+ readonly gate: DeployAuthGate;
15
+ readonly controlPlane: ControlPlaneStore;
16
+ readonly githubConnectionStore: GithubConnectionStore;
17
+ readonly githubAppClient: GitHubAppClient | undefined;
18
+ readonly githubApp: GithubAppConfig | undefined;
19
+ readonly pendingGithubInstallationStore: PendingGithubInstallationStore;
20
+ readonly audit: AuditSink;
21
+ readonly maxBody: number;
22
+ readonly applySecurityHeaders: (res: ServerResponse, tls: TlsPosture) => void;
23
+ readonly enforceHttps: (req: IncomingMessage, res: ServerResponse, tls: TlsPosture) => boolean;
24
+ readonly sendJson: (res: ServerResponse, status: number, body: unknown) => void;
25
+ readonly tls: TlsPosture;
26
+ }
27
+ /** Try the GHD-1 GitHub routes; returns true when the request was handled (or a guard ended it). */
28
+ export declare function dispatchGithubRoutes(req: IncomingMessage, res: ServerResponse, url: URL, deps: GithubDispatchDeps): boolean;
29
+ //# sourceMappingURL=github-dispatch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github-dispatch.d.ts","sourceRoot":"","sources":["../../src/routes/github-dispatch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,oCAAoC,CAAC;AACzF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAe5E,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,YAAY,EAAE,iBAAiB,CAAC;IACzC,QAAQ,CAAC,qBAAqB,EAAE,qBAAqB,CAAC;IACtD,QAAQ,CAAC,eAAe,EAAE,eAAe,GAAG,SAAS,CAAC;IACtD,QAAQ,CAAC,SAAS,EAAE,eAAe,GAAG,SAAS,CAAC;IAChD,QAAQ,CAAC,8BAA8B,EAAE,8BAA8B,CAAC;IACxE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,oBAAoB,EAAE,CAAC,GAAG,EAAE,cAAc,EAAE,GAAG,EAAE,UAAU,KAAK,IAAI,CAAC;IAC9E,QAAQ,CAAC,YAAY,EAAE,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,cAAc,EAAE,GAAG,EAAE,UAAU,KAAK,OAAO,CAAC;IAC/F,QAAQ,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAChF,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;CAC1B;AAED,oGAAoG;AACpG,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAiFT"}
@@ -0,0 +1,60 @@
1
+ import { handleGithubConnection, handleGithubInstallationClaim, handleGithubInstallUrl, } from './github-connection.js';
2
+ import { handleGithubInstallationPending, handleGithubSetup } from './github-setup.js';
3
+ import { isGithubInstallationClaimPath, isGithubInstallationPendingPath, isGithubInstallUrlPath, isGithubSetupPath, parseGithubConnectionPath, } from './paths.js';
4
+ /** Try the GHD-1 GitHub routes; returns true when the request was handled (or a guard ended it). */
5
+ export function dispatchGithubRoutes(req, res, url, deps) {
6
+ const { applySecurityHeaders, enforceHttps, sendJson, tls } = deps;
7
+ const connectionRef = parseGithubConnectionPath(url.pathname);
8
+ if (connectionRef !== undefined &&
9
+ (req.method === 'GET' || req.method === 'POST' || req.method === 'DELETE')) {
10
+ applySecurityHeaders(res, tls);
11
+ if (enforceHttps(req, res, tls))
12
+ return true;
13
+ handleGithubConnection(req, res, deps.gate, deps.controlPlane, deps.githubConnectionStore, deps.githubAppClient, deps.githubApp, deps.maxBody, connectionRef, deps.audit).catch(() => {
14
+ if (!res.headersSent)
15
+ sendJson(res, 500, { error: 'internal error' });
16
+ });
17
+ return true;
18
+ }
19
+ if (isGithubInstallUrlPath(url.pathname) && req.method === 'GET') {
20
+ applySecurityHeaders(res, tls);
21
+ if (enforceHttps(req, res, tls))
22
+ return true;
23
+ handleGithubInstallUrl(req, res, deps.gate, deps.githubApp, url).catch(() => {
24
+ if (!res.headersSent)
25
+ sendJson(res, 500, { error: 'internal error' });
26
+ });
27
+ return true;
28
+ }
29
+ if (isGithubInstallationClaimPath(url.pathname) && req.method === 'POST') {
30
+ applySecurityHeaders(res, tls);
31
+ if (enforceHttps(req, res, tls))
32
+ return true;
33
+ handleGithubInstallationClaim(req, res, deps.gate, deps.controlPlane, deps.githubAppClient, deps.githubApp, deps.pendingGithubInstallationStore, deps.maxBody).catch(() => {
34
+ if (!res.headersSent)
35
+ sendJson(res, 500, { error: 'internal error' });
36
+ });
37
+ return true;
38
+ }
39
+ // GHD-1.4 CLI hand-off: the GitHub App's Setup URL landing + the CLI's install poll. See
40
+ // `github-setup.ts` for why these two small routes exist.
41
+ if (isGithubSetupPath(url.pathname) && req.method === 'GET') {
42
+ applySecurityHeaders(res, tls);
43
+ if (enforceHttps(req, res, tls))
44
+ return true;
45
+ handleGithubSetup(req, res, deps.pendingGithubInstallationStore, deps.githubApp, url);
46
+ return true;
47
+ }
48
+ if (isGithubInstallationPendingPath(url.pathname) && req.method === 'GET') {
49
+ applySecurityHeaders(res, tls);
50
+ if (enforceHttps(req, res, tls))
51
+ return true;
52
+ handleGithubInstallationPending(req, res, deps.gate, deps.controlPlane, deps.pendingGithubInstallationStore, deps.githubApp, url).catch(() => {
53
+ if (!res.headersSent)
54
+ sendJson(res, 500, { error: 'internal error' });
55
+ });
56
+ return true;
57
+ }
58
+ return false;
59
+ }
60
+ //# sourceMappingURL=github-dispatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github-dispatch.js","sourceRoot":"","sources":["../../src/routes/github-dispatch.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,sBAAsB,EACtB,6BAA6B,EAC7B,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,+BAA+B,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACvF,OAAO,EACL,6BAA6B,EAC7B,+BAA+B,EAC/B,sBAAsB,EACtB,iBAAiB,EACjB,yBAAyB,GAC1B,MAAM,YAAY,CAAC;AAiBpB,oGAAoG;AACpG,MAAM,UAAU,oBAAoB,CAClC,GAAoB,EACpB,GAAmB,EACnB,GAAQ,EACR,IAAwB;IAExB,MAAM,EAAE,oBAAoB,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAEnE,MAAM,aAAa,GAAG,yBAAyB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9D,IACE,aAAa,KAAK,SAAS;QAC3B,CAAC,GAAG,CAAC,MAAM,KAAK,KAAK,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM,IAAI,GAAG,CAAC,MAAM,KAAK,QAAQ,CAAC,EAC1E,CAAC;QACD,oBAAoB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAC/B,IAAI,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;YAAE,OAAO,IAAI,CAAC;QAC7C,sBAAsB,CACpB,GAAG,EACH,GAAG,EACH,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,qBAAqB,EAC1B,IAAI,CAAC,eAAe,EACpB,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,OAAO,EACZ,aAAa,EAC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AACf,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * GHD-1.4 CLI hand-off routes: `GET /v1/github/setup` lands GitHub's post-install browser redirect (the
3
+ * GitHub App's configured Setup URL — an operator-side, one-time App-settings field, not a code path) and
4
+ * `GET /v1/github/installations/pending` lets the polling CLI discover the installationId it stashed. See
5
+ * `../github/pending-installations.ts` for the storage rationale. Neither route touches the durable
6
+ * `GithubConnectionStore` — connecting still requires the owner-gated `POST .../github/connection`
7
+ * (`github-connection.ts`) once the CLI has picked a repository via `installations/claim`.
8
+ */
9
+ import type { IncomingMessage, ServerResponse } from 'node:http';
10
+ import type { DeployAuthGate } from '../auth/deploy-gate.js';
11
+ import type { GithubAppConfig } from '../github/app-client.js';
12
+ import type { PendingGithubInstallationStore } from '../github/pending-installations.js';
13
+ import type { ControlPlaneStore } from '../store.js';
14
+ /**
15
+ * `GET /v1/github/setup?installation_id=...&state=...` — the GitHub App's Setup URL. Unauthenticated by
16
+ * necessity: GitHub's redirect is a bare browser GET with no bearer token, so the signed `state` nonce is
17
+ * the only protection. A tampered/expired/malformed state or a missing/non-numeric `installation_id` is
18
+ * rejected before anything is stored — no partial/garbage pending entry is ever written.
19
+ */
20
+ export declare function handleGithubSetup(_req: IncomingMessage, res: ServerResponse, pendingStore: PendingGithubInstallationStore, githubApp: GithubAppConfig | undefined, url: URL): void;
21
+ /**
22
+ * `GET /v1/github/installations/pending?state=...` — the CLI's poll target. Requires the same signed-in
23
+ * subject who requested `install-url` (nonce subject match, mirroring `installations/claim`) and org
24
+ * membership on the nonce's bound org; 404 until the setup redirect has landed, 200 with
25
+ * `{installationId}` after.
26
+ */
27
+ export declare function handleGithubInstallationPending(req: IncomingMessage, res: ServerResponse, gate: DeployAuthGate, controlPlane: ControlPlaneStore, pendingStore: PendingGithubInstallationStore, githubApp: GithubAppConfig | undefined, url: URL): Promise<void>;
28
+ //# sourceMappingURL=github-setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github-setup.d.ts","sourceRoot":"","sources":["../../src/routes/github-setup.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,oCAAoC,CAAC;AAEzF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAuBrD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,eAAe,EACrB,GAAG,EAAE,cAAc,EACnB,YAAY,EAAE,8BAA8B,EAC5C,SAAS,EAAE,eAAe,GAAG,SAAS,EACtC,GAAG,EAAE,GAAG,GACP,IAAI,CAeN;AAED;;;;;GAKG;AACH,wBAAsB,+BAA+B,CACnD,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,cAAc,EACpB,YAAY,EAAE,iBAAiB,EAC/B,YAAY,EAAE,8BAA8B,EAC5C,SAAS,EAAE,eAAe,GAAG,SAAS,EACtC,GAAG,EAAE,GAAG,GACP,OAAO,CAAC,IAAI,CAAC,CA8Bf"}
@@ -0,0 +1,80 @@
1
+ import { resolveGithubStateSecret, verifyInstallNonce } from '../github/install-nonce.js';
2
+ import { sendForbidden, sendJson } from '../http-util.js';
3
+ import { authorizeControlPlane } from './control-plane.js';
4
+ const SETUP_OK_HTML = '<!doctype html><html><head><meta charset="utf-8"><title>Noodle Seed</title></head>' +
5
+ '<body style="font-family:system-ui,sans-serif;padding:2rem"><p>GitHub installation received. ' +
6
+ 'You can return to your terminal.</p></body></html>';
7
+ const SETUP_ERROR_HTML = '<!doctype html><html><head><meta charset="utf-8"><title>Noodle Seed</title></head>' +
8
+ '<body style="font-family:system-ui,sans-serif;padding:2rem"><p>This installation link is invalid or ' +
9
+ 'has expired. Return to your terminal and run <code>noodle github connect</code> again.</p></body></html>';
10
+ function sendHtml(res, status, html) {
11
+ res.writeHead(status, { 'content-type': 'text/html; charset=utf-8' });
12
+ res.end(html);
13
+ }
14
+ function parsePositiveInt(value) {
15
+ if (value === null)
16
+ return undefined;
17
+ const n = Number(value);
18
+ return Number.isInteger(n) && n > 0 ? n : undefined;
19
+ }
20
+ /**
21
+ * `GET /v1/github/setup?installation_id=...&state=...` — the GitHub App's Setup URL. Unauthenticated by
22
+ * necessity: GitHub's redirect is a bare browser GET with no bearer token, so the signed `state` nonce is
23
+ * the only protection. A tampered/expired/malformed state or a missing/non-numeric `installation_id` is
24
+ * rejected before anything is stored — no partial/garbage pending entry is ever written.
25
+ */
26
+ export function handleGithubSetup(_req, res, pendingStore, githubApp, url) {
27
+ const state = url.searchParams.get('state');
28
+ const installationId = parsePositiveInt(url.searchParams.get('installation_id'));
29
+ if (state === null || installationId === undefined) {
30
+ sendHtml(res, 400, SETUP_ERROR_HTML);
31
+ return;
32
+ }
33
+ const secret = resolveGithubStateSecret(githubApp?.webhookSecret);
34
+ const verification = verifyInstallNonce(state, secret);
35
+ if (!verification.ok) {
36
+ sendHtml(res, 400, SETUP_ERROR_HTML);
37
+ return;
38
+ }
39
+ pendingStore.put(state, installationId);
40
+ sendHtml(res, 200, SETUP_OK_HTML);
41
+ }
42
+ /**
43
+ * `GET /v1/github/installations/pending?state=...` — the CLI's poll target. Requires the same signed-in
44
+ * subject who requested `install-url` (nonce subject match, mirroring `installations/claim`) and org
45
+ * membership on the nonce's bound org; 404 until the setup redirect has landed, 200 with
46
+ * `{installationId}` after.
47
+ */
48
+ export async function handleGithubInstallationPending(req, res, gate, controlPlane, pendingStore, githubApp, url) {
49
+ const identity = await authorizeControlPlane(req, res, gate, { requireIdentity: true });
50
+ if (identity === false)
51
+ return;
52
+ const state = url.searchParams.get('state');
53
+ if (state === null) {
54
+ sendJson(res, 400, { error: '"state" query parameter is required' });
55
+ return;
56
+ }
57
+ const secret = resolveGithubStateSecret(githubApp?.webhookSecret);
58
+ const verification = verifyInstallNonce(state, secret);
59
+ if (!verification.ok || verification.payload.subject !== identity.subject) {
60
+ sendForbidden(res, 'invalid or expired state');
61
+ return;
62
+ }
63
+ if (!identity.superAdmin) {
64
+ const member = await controlPlane.isOrgMember({
65
+ org: verification.payload.org,
66
+ subject: identity.subject,
67
+ });
68
+ if (!member) {
69
+ sendForbidden(res, 'forbidden');
70
+ return;
71
+ }
72
+ }
73
+ const installationId = pendingStore.get(state);
74
+ if (installationId === undefined) {
75
+ sendJson(res, 404, { error: 'installation not landed yet' });
76
+ return;
77
+ }
78
+ sendJson(res, 200, { ok: true, data: { installationId } });
79
+ }
80
+ //# sourceMappingURL=github-setup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github-setup.js","sourceRoot":"","sources":["../../src/routes/github-setup.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAE1F,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,MAAM,aAAa,GACjB,oFAAoF;IACpF,+FAA+F;IAC/F,oDAAoD,CAAC;AACvD,MAAM,gBAAgB,GACpB,oFAAoF;IACpF,sGAAsG;IACtG,0GAA0G,CAAC;AAE7G,SAAS,QAAQ,CAAC,GAAmB,EAAE,MAAc,EAAE,IAAY;IACjE,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,cAAc,EAAE,0BAA0B,EAAE,CAAC,CAAC;IACtE,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAoB;IAC5C,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IACrC,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,C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AAE,IAAI,EAAE,IAAI,EAAE,EAAE,cAAc,EAAE,EAAE,CAAC,CAAC;AAC7D,CAAC"}
@@ -14,6 +14,11 @@ export declare function handleOrgs(req: IncomingMessage, res: ServerResponse, ga
14
14
  export declare function handleOrgUpdate(req: IncomingMessage, res: ServerResponse, gate: DeployAuthGate, controlPlane: ControlPlaneStore, maxBody: number, ref: {
15
15
  org: string;
16
16
  }, audit: AuditSink): Promise<void>;
17
+ /** `GET /v1/orgs/{org}` — org inspect. Membership-gated like the deployments/apps routes; 404 when
18
+ * the org does not exist (a super-admin can reach any slug, so this is the reachable 404 case). */
19
+ export declare function handleOrgInspect(req: IncomingMessage, res: ServerResponse, gate: DeployAuthGate, controlPlane: ControlPlaneStore, ref: {
20
+ org: string;
21
+ }): Promise<void>;
17
22
  export declare function handleMembers(req: IncomingMessage, res: ServerResponse, gate: DeployAuthGate, controlPlane: ControlPlaneStore, maxBody: number, ref: {
18
23
  org: string;
19
24
  subject?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"org-admin.d.ts","sourceRoot":"","sources":["../../src/routes/org-admin.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGnF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EACL,KAAK,iBAAiB,EAEtB,KAAK,OAAO,EAEb,MAAM,aAAa,CAAC;AAOrB,wBAAsB,UAAU,CAC9B,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,cAAc,EACpB,YAAY,EAAE,iBAAiB,EAC/B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CAsCf;AAED,0GAA0G;AAC1G,wBAAsB,eAAe,CACnC,GAAG,EAAE,eAAe,EACpB,GA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EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC;CACtC"}
@@ -1,7 +1,8 @@
1
1
  import { readJsonBody, sendForbidden, sendJson } from '../http-util.js';
2
2
  import { hashToken, randomToken } from '../oauth/tokens.js';
3
3
  import { validateOrgRole, } from '../store.js';
4
- import { authorizeControlPlane } from './control-plane.js';
4
+ import { OrgSummarySchema } from './contracts.js';
5
+ import { authorizeControlPlane, authorizeTenantControl } from './control-plane.js';
5
6
  const ORG_INVITATION_TTL_MS = 7 * 24 * 60 * 60 * 1000;
6
7
  const MAX_ORG_DISPLAY_NAME_LENGTH = 200;
7
8
  export async function handleOrgs(req, res, gate, controlPlane, maxBody) {
@@ -74,6 +75,17 @@ export async function handleOrgUpdate(req, res, gate, controlPlane, maxBody, ref
74
75
  return sendJson(res, 400, { error: error.message });
75
76
  }
76
77
  }
78
+ /** `GET /v1/orgs/{org}` — org inspect. Membership-gated like the deployments/apps routes; 404 when
79
+ * the org does not exist (a super-admin can reach any slug, so this is the reachable 404 case). */
80
+ export async function handleOrgInspect(req, res, gate, controlPlane, ref) {
81
+ const identity = await authorizeTenantControl(req, res, gate, controlPlane, ref.org);
82
+ if (identity === false)
83
+ return;
84
+ const org = await controlPlane.getOrg(ref.org);
85
+ if (org === undefined)
86
+ return sendJson(res, 404, { error: 'not found' });
87
+ return sendJson(res, 200, { ok: true, data: OrgSummarySchema.parse(org) });
88
+ }
77
89
  export async function handleMembers(req, res, gate, controlPlane, maxBody, ref, audit) {
78
90
  const identity = await authorizeControlPlane(req, res, gate, { requireIdentity: true });
79
91
  if (identity === false)