@warlock.js/devtools 5.55.0 → 5.56.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 (234) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +26 -13
  3. package/cjs/ai-source-DTpxumMA.cjs +381 -0
  4. package/cjs/ai-source-DTpxumMA.cjs.map +1 -0
  5. package/cjs/auth-DzU0gHDG.cjs +1655 -0
  6. package/cjs/auth-DzU0gHDG.cjs.map +1 -0
  7. package/cjs/boot-BQi0Etor.cjs +138 -0
  8. package/cjs/boot-BQi0Etor.cjs.map +1 -0
  9. package/cjs/capture-CqIiaznN.cjs +1342 -0
  10. package/cjs/capture-CqIiaznN.cjs.map +1 -0
  11. package/cjs/cascade-store-pHjKeSFm.cjs +863 -0
  12. package/cjs/cascade-store-pHjKeSFm.cjs.map +1 -0
  13. package/cjs/collector-CJbQbzzK.cjs +271 -0
  14. package/cjs/collector-CJbQbzzK.cjs.map +1 -0
  15. package/cjs/contracts-CVmplkNb.cjs +112 -0
  16. package/cjs/contracts-CVmplkNb.cjs.map +1 -0
  17. package/cjs/current-request-id-BoJJb3y7.cjs +37 -0
  18. package/cjs/current-request-id-BoJJb3y7.cjs.map +1 -0
  19. package/cjs/errors-CyZp5yS-.cjs +177 -0
  20. package/cjs/errors-CyZp5yS-.cjs.map +1 -0
  21. package/cjs/histogram-BaI-PnCv.cjs +102 -0
  22. package/cjs/histogram-BaI-PnCv.cjs.map +1 -0
  23. package/cjs/http-CabcUwBx.cjs +870 -0
  24. package/cjs/http-CabcUwBx.cjs.map +1 -0
  25. package/cjs/index.cjs +1 -1
  26. package/cjs/insights-BKtqxdnP.cjs +811 -0
  27. package/cjs/insights-BKtqxdnP.cjs.map +1 -0
  28. package/cjs/ip-DbNhPOzi.cjs +153 -0
  29. package/cjs/ip-DbNhPOzi.cjs.map +1 -0
  30. package/cjs/migrations-w7GMsrQw.cjs +297 -0
  31. package/cjs/migrations-w7GMsrQw.cjs.map +1 -0
  32. package/cjs/openapi-CC7OAUc6.cjs +52 -0
  33. package/cjs/openapi-CC7OAUc6.cjs.map +1 -0
  34. package/cjs/options-CWqFC5__.cjs +181 -0
  35. package/cjs/options-CWqFC5__.cjs.map +1 -0
  36. package/cjs/panels-B0dAfGbJ.cjs +298 -0
  37. package/cjs/panels-B0dAfGbJ.cjs.map +1 -0
  38. package/cjs/process-panel-DEOnLxoT.cjs +48 -0
  39. package/cjs/process-panel-DEOnLxoT.cjs.map +1 -0
  40. package/cjs/production/index.cjs +238 -0
  41. package/cjs/production/index.cjs.map +1 -0
  42. package/cjs/rolldown-runtime-Zuuoy_Rh.cjs +52 -0
  43. package/cjs/server-B6xdeKS8.cjs +184 -0
  44. package/cjs/server-B6xdeKS8.cjs.map +1 -0
  45. package/cjs/{src-Xwm3Eel9.cjs → src-Ce-3Lniv.cjs} +163 -295
  46. package/cjs/src-Ce-3Lniv.cjs.map +1 -0
  47. package/cjs/store-aq207T8v.cjs +9 -0
  48. package/cjs/stream-route-BGJa-zQu.cjs +875 -0
  49. package/cjs/stream-route-BGJa-zQu.cjs.map +1 -0
  50. package/esm/devtools-connector.d.mts +16 -13
  51. package/esm/devtools-connector.d.mts.map +1 -1
  52. package/esm/devtools-connector.mjs +127 -18
  53. package/esm/devtools-connector.mjs.map +1 -1
  54. package/esm/index.d.mts +3 -2
  55. package/esm/options.mjs +2 -1
  56. package/esm/options.mjs.map +1 -1
  57. package/esm/panels.mjs +50 -5
  58. package/esm/panels.mjs.map +1 -1
  59. package/esm/production/auth/common-passwords.mjs +303 -0
  60. package/esm/production/auth/common-passwords.mjs.map +1 -0
  61. package/esm/production/auth/default-crypto.mjs +19 -0
  62. package/esm/production/auth/default-crypto.mjs.map +1 -0
  63. package/esm/production/auth/helpers.mjs +77 -0
  64. package/esm/production/auth/helpers.mjs.map +1 -0
  65. package/esm/production/auth/index.mjs +6 -0
  66. package/esm/production/auth/passkeys.mjs +96 -0
  67. package/esm/production/auth/passkeys.mjs.map +1 -0
  68. package/esm/production/auth/service.mjs +1166 -0
  69. package/esm/production/auth/service.mjs.map +1 -0
  70. package/esm/production/boot.mjs +138 -0
  71. package/esm/production/boot.mjs.map +1 -0
  72. package/esm/production/capture/dev-stats.mjs +83 -0
  73. package/esm/production/capture/dev-stats.mjs.map +1 -0
  74. package/esm/production/capture/engine.mjs +442 -0
  75. package/esm/production/capture/engine.mjs.map +1 -0
  76. package/esm/production/capture/explain.mjs +271 -0
  77. package/esm/production/capture/explain.mjs.map +1 -0
  78. package/esm/production/capture/filter.mjs +24 -0
  79. package/esm/production/capture/filter.mjs.map +1 -0
  80. package/esm/production/capture/index.mjs +7 -0
  81. package/esm/production/capture/production-capture.mjs +134 -0
  82. package/esm/production/capture/production-capture.mjs.map +1 -0
  83. package/esm/production/capture/redact.mjs +109 -0
  84. package/esm/production/capture/redact.mjs.map +1 -0
  85. package/esm/production/capture/stats-stores.mjs +300 -0
  86. package/esm/production/capture/stats-stores.mjs.map +1 -0
  87. package/esm/production/cli/actions.mjs +151 -0
  88. package/esm/production/cli/actions.mjs.map +1 -0
  89. package/esm/production/cli/index.d.mts +17 -0
  90. package/esm/production/cli/index.d.mts.map +1 -0
  91. package/esm/production/cli/index.mjs +86 -0
  92. package/esm/production/cli/index.mjs.map +1 -0
  93. package/esm/production/contracts.d.mts +592 -0
  94. package/esm/production/contracts.d.mts.map +1 -0
  95. package/esm/production/contracts.mjs +95 -0
  96. package/esm/production/contracts.mjs.map +1 -0
  97. package/esm/production/errors.d.mts +31 -0
  98. package/esm/production/errors.d.mts.map +1 -0
  99. package/esm/production/errors.mjs +142 -0
  100. package/esm/production/errors.mjs.map +1 -0
  101. package/esm/production/http/access.mjs +124 -0
  102. package/esm/production/http/access.mjs.map +1 -0
  103. package/esm/production/http/auth-routes.mjs +280 -0
  104. package/esm/production/http/auth-routes.mjs.map +1 -0
  105. package/esm/production/http/client.mjs +57 -0
  106. package/esm/production/http/client.mjs.map +1 -0
  107. package/esm/production/http/constants.mjs +11 -0
  108. package/esm/production/http/constants.mjs.map +1 -0
  109. package/esm/production/http/context.mjs +14 -0
  110. package/esm/production/http/context.mjs.map +1 -0
  111. package/esm/production/http/cookie.mjs +39 -0
  112. package/esm/production/http/cookie.mjs.map +1 -0
  113. package/esm/production/http/headers.mjs +25 -0
  114. package/esm/production/http/headers.mjs.map +1 -0
  115. package/esm/production/http/index.mjs +10 -0
  116. package/esm/production/http/ip.mjs +130 -0
  117. package/esm/production/http/ip.mjs.map +1 -0
  118. package/esm/production/http/mount.mjs +300 -0
  119. package/esm/production/http/mount.mjs.map +1 -0
  120. package/esm/production/http/state.mjs +54 -0
  121. package/esm/production/http/state.mjs.map +1 -0
  122. package/esm/production/index.d.mts +6 -0
  123. package/esm/production/index.mjs +5 -0
  124. package/esm/production/insights/cap-report.mjs +67 -0
  125. package/esm/production/insights/cap-report.mjs.map +1 -0
  126. package/esm/production/insights/health.mjs +88 -0
  127. package/esm/production/insights/health.mjs.map +1 -0
  128. package/esm/production/insights/index.mjs +10 -0
  129. package/esm/production/insights/insights.mjs +167 -0
  130. package/esm/production/insights/insights.mjs.map +1 -0
  131. package/esm/production/insights/instance.mjs +24 -0
  132. package/esm/production/insights/instance.mjs.map +1 -0
  133. package/esm/production/insights/jobs.mjs +100 -0
  134. package/esm/production/insights/jobs.mjs.map +1 -0
  135. package/esm/production/insights/reporter.mjs +59 -0
  136. package/esm/production/insights/reporter.mjs.map +1 -0
  137. package/esm/production/insights/resources.mjs +139 -0
  138. package/esm/production/insights/resources.mjs.map +1 -0
  139. package/esm/production/insights/writer.mjs +72 -0
  140. package/esm/production/insights/writer.mjs.map +1 -0
  141. package/esm/production/openapi.mjs +52 -0
  142. package/esm/production/openapi.mjs.map +1 -0
  143. package/esm/production/options.d.mts +60 -0
  144. package/esm/production/options.d.mts.map +1 -0
  145. package/esm/production/options.mjs +170 -0
  146. package/esm/production/options.mjs.map +1 -0
  147. package/esm/production/stats/histogram.mjs +67 -0
  148. package/esm/production/stats/histogram.mjs.map +1 -0
  149. package/esm/production/stats/merge.mjs +106 -0
  150. package/esm/production/stats/merge.mjs.map +1 -0
  151. package/esm/production/store/cascade-store.mjs +322 -0
  152. package/esm/production/store/cascade-store.mjs.map +1 -0
  153. package/esm/production/store/index.mjs +5 -0
  154. package/esm/production/store/mapping.mjs +258 -0
  155. package/esm/production/store/mapping.mjs.map +1 -0
  156. package/esm/production/store/memory-store.mjs +291 -0
  157. package/esm/production/store/memory-store.mjs.map +1 -0
  158. package/esm/production/store/migrations.d.mts +11 -0
  159. package/esm/production/store/migrations.d.mts.map +1 -0
  160. package/esm/production/store/migrations.mjs +29 -0
  161. package/esm/production/store/migrations.mjs.map +1 -0
  162. package/esm/production/store/models/account.migration.mjs +34 -0
  163. package/esm/production/store/models/account.migration.mjs.map +1 -0
  164. package/esm/production/store/models/account.model.mjs +13 -0
  165. package/esm/production/store/models/account.model.mjs.map +1 -0
  166. package/esm/production/store/models/audit.migration.mjs +30 -0
  167. package/esm/production/store/models/audit.migration.mjs.map +1 -0
  168. package/esm/production/store/models/audit.model.mjs +13 -0
  169. package/esm/production/store/models/audit.model.mjs.map +1 -0
  170. package/esm/production/store/models/base.mjs +27 -0
  171. package/esm/production/store/models/base.mjs.map +1 -0
  172. package/esm/production/store/models/index.mjs +17 -0
  173. package/esm/production/store/models/invite.migration.mjs +26 -0
  174. package/esm/production/store/models/invite.migration.mjs.map +1 -0
  175. package/esm/production/store/models/invite.model.mjs +13 -0
  176. package/esm/production/store/models/invite.model.mjs.map +1 -0
  177. package/esm/production/store/models/report.migration.mjs +20 -0
  178. package/esm/production/store/models/report.migration.mjs.map +1 -0
  179. package/esm/production/store/models/report.model.mjs +13 -0
  180. package/esm/production/store/models/report.model.mjs.map +1 -0
  181. package/esm/production/store/models/sample.migration.mjs +25 -0
  182. package/esm/production/store/models/sample.migration.mjs.map +1 -0
  183. package/esm/production/store/models/sample.model.mjs +13 -0
  184. package/esm/production/store/models/sample.model.mjs.map +1 -0
  185. package/esm/production/store/models/session.migration.mjs +31 -0
  186. package/esm/production/store/models/session.migration.mjs.map +1 -0
  187. package/esm/production/store/models/session.model.mjs +13 -0
  188. package/esm/production/store/models/session.model.mjs.map +1 -0
  189. package/esm/production/store/models/state.migration.mjs +26 -0
  190. package/esm/production/store/models/state.migration.mjs.map +1 -0
  191. package/esm/production/store/models/state.model.mjs +13 -0
  192. package/esm/production/store/models/state.model.mjs.map +1 -0
  193. package/esm/query-shape.mjs +14 -1
  194. package/esm/query-shape.mjs.map +1 -1
  195. package/esm/server/explain-route.mjs +26 -1
  196. package/esm/server/explain-route.mjs.map +1 -1
  197. package/esm/server/index.mjs +9 -4
  198. package/esm/server/index.mjs.map +1 -1
  199. package/esm/server/insights-routes.mjs +62 -0
  200. package/esm/server/insights-routes.mjs.map +1 -0
  201. package/esm/server/log-routes.mjs +32 -5
  202. package/esm/server/log-routes.mjs.map +1 -1
  203. package/esm/server/openapi-routes.mjs +3 -2
  204. package/esm/server/openapi-routes.mjs.map +1 -1
  205. package/esm/server/requests-routes.mjs +125 -0
  206. package/esm/server/requests-routes.mjs.map +1 -1
  207. package/esm/server/session-routes.mjs +42 -0
  208. package/esm/server/session-routes.mjs.map +1 -0
  209. package/esm/server/stream-route.mjs +81 -11
  210. package/esm/server/stream-route.mjs.map +1 -1
  211. package/esm/server/ui-assets.mjs +34 -25
  212. package/esm/server/ui-assets.mjs.map +1 -1
  213. package/esm/sources/log-source.mjs +14 -1
  214. package/esm/sources/log-source.mjs.map +1 -1
  215. package/esm/types.d.mts +202 -1
  216. package/esm/types.d.mts.map +1 -1
  217. package/esm/ui-root.mjs +9 -4
  218. package/esm/ui-root.mjs.map +1 -1
  219. package/llms-full.txt +159 -21
  220. package/llms.txt +2 -2
  221. package/package.json +32 -8
  222. package/skills/SKILL.md +159 -21
  223. package/ui/dashboard/assets/app.css +3 -0
  224. package/ui/dashboard/assets/app.js +50 -0
  225. package/ui/dashboard/build-info.json +21 -0
  226. package/ui/dashboard/index.html +15 -0
  227. package/cjs/ai-source-Dz_3tlZ5.cjs +0 -703
  228. package/cjs/ai-source-Dz_3tlZ5.cjs.map +0 -1
  229. package/cjs/server-B11ShQYE.cjs +0 -628
  230. package/cjs/server-B11ShQYE.cjs.map +0 -1
  231. package/cjs/src-Xwm3Eel9.cjs.map +0 -1
  232. package/ui/app.css +0 -376
  233. package/ui/app.js +0 -1158
  234. package/ui/index.html +0 -28
@@ -0,0 +1,48 @@
1
+ const require_rolldown_runtime = require("./rolldown-runtime-Zuuoy_Rh.cjs");
2
+ const require_ai_source = require("./ai-source-DTpxumMA.cjs");
3
+ let node_path = require("node:path");
4
+ node_path = require_rolldown_runtime.__toESM(node_path, 1);
5
+
6
+ //#region ../../packages/devtools/src/process-panel.ts
7
+ /** Load app-owned generated registration only when devtools boots in development. */
8
+ async function loadProcessPanel() {
9
+ const core = await import("@warlock.js/core");
10
+ if (!("srcPath" in core)) return void 0;
11
+ const { srcPath } = core;
12
+ const { existsSync } = await import("node:fs");
13
+ const { pathToFileURL } = await import("node:url");
14
+ const file = srcPath("app/processes/devtools.ts");
15
+ if (!existsSync(file)) return void 0;
16
+ return (await import(pathToFileURL(file).href)).processPanel;
17
+ }
18
+ /**
19
+ * The built-in **Processes** tab, registered like any other panel:
20
+ * `GET <path>/api/processes` lists the app's supervised processes (an empty
21
+ * list without a registration) and `ui/panels/processes.js` renders them.
22
+ */
23
+ function processesDevtoolsPanel(processPanel) {
24
+ return {
25
+ id: "processes",
26
+ title: "Processes",
27
+ view: node_path.default.join(require_ai_source.resolveUiRoot(), "panels", "processes.js"),
28
+ routes: [{
29
+ path: "",
30
+ handler: async () => processPanel ? await processPanel.list() : []
31
+ }]
32
+ };
33
+ }
34
+
35
+ //#endregion
36
+ Object.defineProperty(exports, "loadProcessPanel", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return loadProcessPanel;
40
+ }
41
+ });
42
+ Object.defineProperty(exports, "processesDevtoolsPanel", {
43
+ enumerable: true,
44
+ get: function () {
45
+ return processesDevtoolsPanel;
46
+ }
47
+ });
48
+ //# sourceMappingURL=process-panel-DEOnLxoT.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process-panel-DEOnLxoT.cjs","names":["path","resolveUiRoot"],"sources":["../../../../../../../packages/devtools/src/process-panel.ts"],"sourcesContent":["import path from \"node:path\";\nimport type { DevtoolsPanel } from \"./types\";\nimport { resolveUiRoot } from \"./ui-root\";\n\n/** Structural contract keeps process supervision an optional application feature. */\nexport type ProcessPanel = { list(): Promise<readonly unknown[]> };\n\n/** Load app-owned generated registration only when devtools boots in development. */\nexport async function loadProcessPanel(): Promise<ProcessPanel | undefined> {\n const core = await import(\"@warlock.js/core\");\n if (!(\"srcPath\" in core)) return undefined;\n const { srcPath } = core;\n const { existsSync } = await import(\"node:fs\");\n const { pathToFileURL } = await import(\"node:url\");\n const file = srcPath(\"app/processes/devtools.ts\");\n if (!existsSync(file)) return undefined;\n const module: { processPanel?: ProcessPanel } = await import(pathToFileURL(file).href);\n return module.processPanel;\n}\n\n/**\n * The built-in **Processes** tab, registered like any other panel:\n * `GET <path>/api/processes` lists the app's supervised processes (an empty\n * list without a registration) and `ui/panels/processes.js` renders them.\n */\nexport function processesDevtoolsPanel(processPanel?: ProcessPanel): DevtoolsPanel {\n return {\n id: \"processes\",\n title: \"Processes\",\n view: path.join(resolveUiRoot(), \"panels\", \"processes.js\"),\n routes: [{ path: \"\", handler: async () => (processPanel ? await processPanel.list() : []) }],\n };\n}\n"],"mappings":";;;;;;;AAQA,eAAsB,mBAAsD;CAC1E,MAAM,OAAO,MAAM,OAAO;CAC1B,IAAI,EAAE,aAAa,OAAO,OAAO;CACjC,MAAM,EAAE,YAAY;CACpB,MAAM,EAAE,eAAe,MAAM,OAAO;CACpC,MAAM,EAAE,kBAAkB,MAAM,OAAO;CACvC,MAAM,OAAO,QAAQ,2BAA2B;CAChD,IAAI,CAAC,WAAW,IAAI,GAAG,OAAO;CAE9B,QAAO,MAD+C,OAAO,cAAc,IAAI,CAAC,CAAC,MACpE,CAAC;AAChB;;;;;;AAOA,SAAgB,uBAAuB,cAA4C;CACjF,OAAO;EACL,IAAI;EACJ,OAAO;EACP,MAAMA,kBAAK,KAAKC,gCAAc,GAAG,UAAU,cAAc;EACzD,QAAQ,CAAC;GAAE,MAAM;GAAI,SAAS,YAAa,eAAe,MAAM,aAAa,KAAK,IAAI,CAAC;EAAG,CAAC;CAC7F;AACF"}
@@ -0,0 +1,238 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_errors = require("../errors-CyZp5yS-.cjs");
3
+ const require_migrations = require("../migrations-w7GMsrQw.cjs");
4
+ let _warlock_js_core = require("@warlock.js/core");
5
+
6
+ //#region ../../packages/devtools/src/production/cli/actions.ts
7
+ /** The `ip` value of every audit entry a command writes. */
8
+ const CLI_AUDIT_IP = "cli";
9
+ const MAX_WRITE_ATTEMPTS = 5;
10
+ /** Tells the owner what to do when the database cannot be used. Returns the exit code (1). */
11
+ function reportStoreError(io, error) {
12
+ if (error instanceof require_errors.DevtoolsProductionConfigError) {
13
+ io.err(error.message);
14
+ return 1;
15
+ }
16
+ const detail = error instanceof Error ? error.message : String(error);
17
+ io.err(`Could not use the database: ${detail}. Check that the database is reachable and its settings are correct, then run the command again. If the tables are missing: ${require_errors.DEVTOOLS_CONFIG_CODES.DT008}`);
18
+ return 1;
19
+ }
20
+ /**
21
+ * `warlock devtools:enable`: clears the disable flag and the global lock and
22
+ * stops earlier failures from counting. Returns the exit code.
23
+ */
24
+ async function runEnable(context) {
25
+ const { store, now, io } = context;
26
+ try {
27
+ await store.verify();
28
+ for (let attempt = 0; attempt < MAX_WRITE_ATTEMPTS; attempt++) {
29
+ const state = await store.state.read();
30
+ const at = now();
31
+ if (!await store.state.update(state.version, {
32
+ disabled: false,
33
+ disabledPathHash: null,
34
+ lockedUntil: null,
35
+ failuresResetAt: at
36
+ })) continue;
37
+ await store.audit.append({
38
+ at,
39
+ type: "dashboard.enabled",
40
+ accountId: null,
41
+ email: null,
42
+ ip: "cli",
43
+ userAgent: null,
44
+ detail: {
45
+ wasDisabled: state.disabled,
46
+ wasLocked: state.lockedUntil !== null && state.lockedUntil > at
47
+ },
48
+ ref: require_errors.createErrorRef()
49
+ });
50
+ io.out([
51
+ "The devtools dashboard is enabled.",
52
+ state.disabled ? "- The disable switch is cleared." : "- The disable switch was not set.",
53
+ state.lockedUntil !== null && state.lockedUntil > at ? "- The global lock is cleared." : "- The dashboard was not locked.",
54
+ "- Earlier failed sign-ins no longer count toward the limits."
55
+ ].join("\n"));
56
+ return 0;
57
+ }
58
+ io.err("Another process kept changing the dashboard state, so nothing was saved. Run `warlock devtools:enable` again.");
59
+ return 1;
60
+ } catch (error) {
61
+ return reportStoreError(io, error);
62
+ }
63
+ }
64
+ /** Normalises the `--email` option or `DEVTOOLS_ADMIN_EMAIL`. Returns `null` when there is none. */
65
+ function resolveAdminEmail(option, env) {
66
+ const email = (typeof option === "string" && option.trim() !== "" ? option : env.DEVTOOLS_ADMIN_EMAIL)?.trim().toLowerCase() ?? "";
67
+ return email === "" ? null : email;
68
+ }
69
+ /**
70
+ * `warlock devtools:reset-admin`: creates the admin account or resets it to a
71
+ * printed temporary password, without second factors, and signs it out
72
+ * everywhere. Returns the exit code.
73
+ */
74
+ async function runResetAdmin(context, email) {
75
+ const { store, now, io, generatePassword, hashPassword } = context;
76
+ if (email === null || !email.includes("@")) {
77
+ io.err(email === null ? "No email was given. Run `warlock devtools:reset-admin --email <email>`, or set DEVTOOLS_ADMIN_EMAIL." : `"${email}" is not an email address. Run \`warlock devtools:reset-admin --email <email>\` with a valid address.`);
78
+ return 1;
79
+ }
80
+ try {
81
+ await store.verify();
82
+ const password = generatePassword();
83
+ const passwordHash = await hashPassword(password);
84
+ for (let attempt = 0; attempt < MAX_WRITE_ATTEMPTS; attempt++) {
85
+ const at = now();
86
+ const existing = await store.accounts.findByEmail(email);
87
+ const account = existing ? await store.accounts.update(existing.id, existing.version, {
88
+ role: "admin",
89
+ passwordHash,
90
+ passwordSource: "reset",
91
+ mustChangePassword: true,
92
+ totpSecret: null,
93
+ totpEnabledAt: null,
94
+ totpLastStep: null,
95
+ recoveryCodes: [],
96
+ passkeys: [],
97
+ failuresResetAt: at
98
+ }) : await createAdmin(store, email, passwordHash, at);
99
+ if (!account) continue;
100
+ const signedOut = await store.sessions.removeForAccount(account.id);
101
+ await store.audit.append({
102
+ at,
103
+ type: "admin.reset",
104
+ accountId: account.id,
105
+ email,
106
+ ip: "cli",
107
+ userAgent: null,
108
+ detail: {
109
+ created: existing === null,
110
+ sessionsRemoved: signedOut
111
+ },
112
+ ref: require_errors.createErrorRef()
113
+ });
114
+ io.out([
115
+ existing ? `The admin account ${email} was reset.` : `The admin account ${email} was created.`,
116
+ `Temporary password: ${password}`,
117
+ "Sign in with it; the dashboard asks for a new password and a second factor.",
118
+ signedOut > 0 ? `${signedOut} open session(s) were signed out.` : "The account had no open sessions."
119
+ ].join("\n"));
120
+ return 0;
121
+ }
122
+ io.err(`Another process kept changing the account ${email}, so nothing was saved. Run the command again.`);
123
+ return 1;
124
+ } catch (error) {
125
+ return reportStoreError(io, error);
126
+ }
127
+ }
128
+ /** Creates the account; `null` when another process created it first (the caller retries as a reset). */
129
+ async function createAdmin(store, email, passwordHash, at) {
130
+ try {
131
+ return await store.accounts.create({
132
+ email,
133
+ role: "admin",
134
+ passwordHash,
135
+ passwordSource: "reset",
136
+ mustChangePassword: true,
137
+ totpSecret: null,
138
+ totpEnabledAt: null,
139
+ totpLastStep: null,
140
+ recoveryCodes: [],
141
+ passkeys: [],
142
+ failuresResetAt: at,
143
+ lastLoginAt: null,
144
+ createdBy: null
145
+ });
146
+ } catch (error) {
147
+ if (error instanceof require_errors.DevtoolsStoreConflictError) return null;
148
+ throw error;
149
+ }
150
+ }
151
+
152
+ //#endregion
153
+ //#region ../../packages/devtools/src/production/cli/index.ts
154
+ /** The same boot as `warlock migrate`: the app's config and the database connection, no HTTP server. */
155
+ const PRELOAD = {
156
+ config: true,
157
+ warlockConfig: true,
158
+ bootstrap: true,
159
+ connectors: ["database"]
160
+ };
161
+ /** Print with the stream's own write, so a boot that moves `console.log` never mixes into the answer. */
162
+ const io = {
163
+ out: (line) => void process.stdout.write(`${line}\n`),
164
+ err: (line) => void process.stderr.write(`${line}\n`)
165
+ };
166
+ /** Exit with `code` once stdout and stderr are flushed (a non-zero code only; 0 lets the CLI finish). */
167
+ async function exitWith(code) {
168
+ if (code === 0) return;
169
+ process.exitCode = code;
170
+ await Promise.race([Promise.all([process.stdout, process.stderr].map((stream) => new Promise((resolve) => stream.write("", () => resolve())))), new Promise((resolve) => setTimeout(resolve, 500).unref())]);
171
+ process.exit(code);
172
+ }
173
+ /** The store of the app's database, or the exit code of the error that stopped it. */
174
+ async function openStore() {
175
+ try {
176
+ const { createCascadeStore } = await Promise.resolve().then(() => require("../cascade-store-pHjKeSFm.cjs"));
177
+ return { store: await createCascadeStore() };
178
+ } catch (error) {
179
+ return { code: reportStoreError(io, error) };
180
+ }
181
+ }
182
+ /**
183
+ * `warlock devtools:enable` and `warlock devtools:reset-admin`, for
184
+ * `warlock.config.ts > cli.commands`. Both connect to the database only
185
+ * (no HTTP server) and write an audit entry with `ip: "cli"`.
186
+ *
187
+ * - `devtools:enable`: clears the disable flag and the global lock, and sets
188
+ * `failuresResetAt` so earlier failures stop counting.
189
+ * - `devtools:reset-admin [--email <email>]` (default `DEVTOOLS_ADMIN_EMAIL`):
190
+ * creates or resets that account as an admin with a printed temporary
191
+ * password (must be changed at sign-in), clears its second factors and
192
+ * recovery codes, unlocks it, and signs out its sessions.
193
+ */
194
+ function registerDevtoolsCommands() {
195
+ return [(0, _warlock_js_core.command)({
196
+ name: "devtools:enable",
197
+ description: "Turn the production devtools dashboard back on: clears the disable switch, the global lock and the failure counters",
198
+ preload: PRELOAD,
199
+ action: async () => {
200
+ const opened = await openStore();
201
+ if (!opened.store) return exitWith(opened.code);
202
+ await exitWith(await runEnable({
203
+ store: opened.store,
204
+ now: Date.now,
205
+ io
206
+ }));
207
+ }
208
+ }), (0, _warlock_js_core.command)({
209
+ name: "devtools:reset-admin",
210
+ description: "Create or reset a devtools admin account with a printed temporary password (no second factor, signed out everywhere)",
211
+ preload: PRELOAD,
212
+ action: async ({ options }) => {
213
+ const email = resolveAdminEmail(options.email, process.env);
214
+ const opened = await openStore();
215
+ if (!opened.store) return exitWith(opened.code);
216
+ const [{ hashPassword }, { generateTemporaryPassword }] = await Promise.all([import("@warlock.js/core"), Promise.resolve().then(() => require("../auth-DzU0gHDG.cjs"))]);
217
+ await exitWith(await runResetAdmin({
218
+ store: opened.store,
219
+ now: Date.now,
220
+ io,
221
+ generatePassword: generateTemporaryPassword,
222
+ hashPassword
223
+ }, email));
224
+ },
225
+ options: [{
226
+ text: "--email, -e",
227
+ description: "The admin email (default: DEVTOOLS_ADMIN_EMAIL)",
228
+ type: "string"
229
+ }]
230
+ })];
231
+ }
232
+
233
+ //#endregion
234
+ exports.DEVTOOLS_CONFIG_CODES = require_errors.DEVTOOLS_CONFIG_CODES;
235
+ exports.DevtoolsProductionConfigError = require_errors.DevtoolsProductionConfigError;
236
+ exports.devtoolsMigrations = require_migrations.devtoolsMigrations;
237
+ exports.registerDevtoolsCommands = registerDevtoolsCommands;
238
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["DevtoolsProductionConfigError","DEVTOOLS_CONFIG_CODES","createErrorRef","DevtoolsStoreConflictError","command"],"sources":["../../../../../../../../packages/devtools/src/production/cli/actions.ts","../../../../../../../../packages/devtools/src/production/cli/index.ts"],"sourcesContent":["import {\n DEVTOOLS_CONFIG_CODES,\n DevtoolsProductionConfigError,\n DevtoolsStoreConflictError,\n createErrorRef,\n} from \"../errors\";\nimport type { DevtoolsAccountRecord, DevtoolsStore } from \"../store/types\";\n\n/** Where the commands print. */\nexport type CliOutput = {\n out(line: string): void;\n err(line: string): void;\n};\n\n/** What a command needs; specs pass a memory store, a fixed clock and fakes. */\nexport type DevtoolsCliContext = {\n store: DevtoolsStore;\n now: () => number;\n io: CliOutput;\n};\n\nexport type ResetAdminContext = DevtoolsCliContext & {\n /** Returns a new random password (`generateTemporaryPassword()`). */\n generatePassword: () => string;\n /** Core's `hashPassword`. */\n hashPassword: (password: string) => Promise<string>;\n};\n\n/** The `ip` value of every audit entry a command writes. */\nexport const CLI_AUDIT_IP = \"cli\";\n\nconst MAX_WRITE_ATTEMPTS = 5;\n\n/** Tells the owner what to do when the database cannot be used. Returns the exit code (1). */\nexport function reportStoreError(io: CliOutput, error: unknown): number {\n if (error instanceof DevtoolsProductionConfigError) {\n io.err(error.message);\n\n return 1;\n }\n\n const detail = error instanceof Error ? error.message : String(error);\n\n io.err(\n `Could not use the database: ${detail}. Check that the database is reachable and its settings are correct, then run the command again. ` +\n `If the tables are missing: ${DEVTOOLS_CONFIG_CODES.DT008}`,\n );\n\n return 1;\n}\n\n/**\n * `warlock devtools:enable`: clears the disable flag and the global lock and\n * stops earlier failures from counting. Returns the exit code.\n */\nexport async function runEnable(context: DevtoolsCliContext): Promise<number> {\n const { store, now, io } = context;\n\n try {\n await store.verify();\n\n for (let attempt = 0; attempt < MAX_WRITE_ATTEMPTS; attempt++) {\n const state = await store.state.read();\n const at = now();\n const updated = await store.state.update(state.version, {\n disabled: false,\n disabledPathHash: null,\n lockedUntil: null,\n failuresResetAt: at,\n });\n\n if (!updated) continue;\n\n await store.audit.append({\n at,\n type: \"dashboard.enabled\",\n accountId: null,\n email: null,\n ip: CLI_AUDIT_IP,\n userAgent: null,\n detail: {\n wasDisabled: state.disabled,\n wasLocked: state.lockedUntil !== null && state.lockedUntil > at,\n },\n ref: createErrorRef(),\n });\n\n io.out(\n [\n \"The devtools dashboard is enabled.\",\n state.disabled ? \"- The disable switch is cleared.\" : \"- The disable switch was not set.\",\n state.lockedUntil !== null && state.lockedUntil > at\n ? \"- The global lock is cleared.\"\n : \"- The dashboard was not locked.\",\n \"- Earlier failed sign-ins no longer count toward the limits.\",\n ].join(\"\\n\"),\n );\n\n return 0;\n }\n\n io.err(\n \"Another process kept changing the dashboard state, so nothing was saved. Run `warlock devtools:enable` again.\",\n );\n\n return 1;\n } catch (error) {\n return reportStoreError(io, error);\n }\n}\n\n/** Normalises the `--email` option or `DEVTOOLS_ADMIN_EMAIL`. Returns `null` when there is none. */\nexport function resolveAdminEmail(\n option: unknown,\n env: Record<string, string | undefined>,\n): string | null {\n const raw =\n typeof option === \"string\" && option.trim() !== \"\" ? option : env.DEVTOOLS_ADMIN_EMAIL;\n const email = raw?.trim().toLowerCase() ?? \"\";\n\n return email === \"\" ? null : email;\n}\n\n/**\n * `warlock devtools:reset-admin`: creates the admin account or resets it to a\n * printed temporary password, without second factors, and signs it out\n * everywhere. Returns the exit code.\n */\nexport async function runResetAdmin(\n context: ResetAdminContext,\n email: string | null,\n): Promise<number> {\n const { store, now, io, generatePassword, hashPassword } = context;\n\n if (email === null || !email.includes(\"@\")) {\n io.err(\n email === null\n ? \"No email was given. Run `warlock devtools:reset-admin --email <email>`, or set DEVTOOLS_ADMIN_EMAIL.\"\n : `\"${email}\" is not an email address. Run \\`warlock devtools:reset-admin --email <email>\\` with a valid address.`,\n );\n\n return 1;\n }\n\n try {\n await store.verify();\n\n const password = generatePassword();\n const passwordHash = await hashPassword(password);\n\n for (let attempt = 0; attempt < MAX_WRITE_ATTEMPTS; attempt++) {\n const at = now();\n const existing = await store.accounts.findByEmail(email);\n const account = existing\n ? await store.accounts.update(existing.id, existing.version, {\n role: \"admin\",\n passwordHash,\n passwordSource: \"reset\",\n mustChangePassword: true,\n totpSecret: null,\n totpEnabledAt: null,\n totpLastStep: null,\n recoveryCodes: [],\n passkeys: [],\n failuresResetAt: at,\n })\n : await createAdmin(store, email, passwordHash, at);\n\n if (!account) continue;\n\n const signedOut = await store.sessions.removeForAccount(account.id);\n\n await store.audit.append({\n at,\n type: \"admin.reset\",\n accountId: account.id,\n email,\n ip: CLI_AUDIT_IP,\n userAgent: null,\n detail: { created: existing === null, sessionsRemoved: signedOut },\n ref: createErrorRef(),\n });\n\n io.out(\n [\n existing\n ? `The admin account ${email} was reset.`\n : `The admin account ${email} was created.`,\n `Temporary password: ${password}`,\n \"Sign in with it; the dashboard asks for a new password and a second factor.\",\n signedOut > 0\n ? `${signedOut} open session(s) were signed out.`\n : \"The account had no open sessions.\",\n ].join(\"\\n\"),\n );\n\n return 0;\n }\n\n io.err(\n `Another process kept changing the account ${email}, so nothing was saved. Run the command again.`,\n );\n\n return 1;\n } catch (error) {\n return reportStoreError(io, error);\n }\n}\n\n/** Creates the account; `null` when another process created it first (the caller retries as a reset). */\nasync function createAdmin(\n store: DevtoolsStore,\n email: string,\n passwordHash: string,\n at: number,\n): Promise<DevtoolsAccountRecord | null> {\n try {\n return await store.accounts.create({\n email,\n role: \"admin\",\n passwordHash,\n passwordSource: \"reset\",\n mustChangePassword: true,\n totpSecret: null,\n totpEnabledAt: null,\n totpLastStep: null,\n recoveryCodes: [],\n passkeys: [],\n failuresResetAt: at,\n lastLoginAt: null,\n createdBy: null,\n });\n } catch (error) {\n if (error instanceof DevtoolsStoreConflictError) return null;\n\n throw error;\n }\n}\n","import { command, type CLICommand, type CLICommandPreload } from \"@warlock.js/core\";\nimport { reportStoreError, runEnable, runResetAdmin, resolveAdminEmail } from \"./actions\";\nimport type { CliOutput } from \"./actions\";\n\n/** The same boot as `warlock migrate`: the app's config and the database connection, no HTTP server. */\nconst PRELOAD: CLICommandPreload = {\n config: true,\n warlockConfig: true,\n bootstrap: true,\n connectors: [\"database\"],\n};\n\n/** Print with the stream's own write, so a boot that moves `console.log` never mixes into the answer. */\nconst io: CliOutput = {\n out: (line) => void process.stdout.write(`${line}\\n`),\n err: (line) => void process.stderr.write(`${line}\\n`),\n};\n\n/** Exit with `code` once stdout and stderr are flushed (a non-zero code only; 0 lets the CLI finish). */\nasync function exitWith(code: number): Promise<void> {\n if (code === 0) return;\n\n process.exitCode = code;\n\n await Promise.race([\n Promise.all(\n [process.stdout, process.stderr].map(\n (stream) => new Promise<void>((resolve) => stream.write(\"\", () => resolve())),\n ),\n ),\n new Promise<void>((resolve) => setTimeout(resolve, 500).unref()),\n ]);\n\n process.exit(code);\n}\n\n/** The store of the app's database, or the exit code of the error that stopped it. */\nasync function openStore() {\n try {\n const { createCascadeStore } = await import(\"../store/cascade-store\");\n\n return { store: await createCascadeStore() };\n } catch (error) {\n return { code: reportStoreError(io, error) };\n }\n}\n\n/**\n * `warlock devtools:enable` and `warlock devtools:reset-admin`, for\n * `warlock.config.ts > cli.commands`. Both connect to the database only\n * (no HTTP server) and write an audit entry with `ip: \"cli\"`.\n *\n * - `devtools:enable`: clears the disable flag and the global lock, and sets\n * `failuresResetAt` so earlier failures stop counting.\n * - `devtools:reset-admin [--email <email>]` (default `DEVTOOLS_ADMIN_EMAIL`):\n * creates or resets that account as an admin with a printed temporary\n * password (must be changed at sign-in), clears its second factors and\n * recovery codes, unlocks it, and signs out its sessions.\n */\nexport function registerDevtoolsCommands(): CLICommand[] {\n const enable = command({\n name: \"devtools:enable\",\n description:\n \"Turn the production devtools dashboard back on: clears the disable switch, the global lock and the failure counters\",\n preload: PRELOAD,\n action: async () => {\n const opened = await openStore();\n\n if (!opened.store) return exitWith(opened.code);\n\n await exitWith(await runEnable({ store: opened.store, now: Date.now, io }));\n },\n });\n\n const resetAdmin = command({\n name: \"devtools:reset-admin\",\n description:\n \"Create or reset a devtools admin account with a printed temporary password (no second factor, signed out everywhere)\",\n preload: PRELOAD,\n action: async ({ options }) => {\n const email = resolveAdminEmail(options.email, process.env);\n const opened = await openStore();\n\n if (!opened.store) return exitWith(opened.code);\n\n const [{ hashPassword }, { generateTemporaryPassword }] = await Promise.all([\n import(\"@warlock.js/core\"),\n import(\"../auth\"),\n ]);\n\n await exitWith(\n await runResetAdmin(\n {\n store: opened.store,\n now: Date.now,\n io,\n generatePassword: generateTemporaryPassword,\n hashPassword,\n },\n email,\n ),\n );\n },\n options: [\n {\n text: \"--email, -e\",\n description: \"The admin email (default: D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cA,SAAgB,2BAAyC;CAqDvD,OAAO,KApDQC,0BAAQ;EACrB,MAAM;EACN,aACE;EACF,SAAS;EACT,QAAQ,YAAY;GAClB,MAAM,SAAS,MAAM,UAAU;GAE/B,IAAI,CAAC,OAAO,OAAO,OAAO,SAAS,OAAO,IAAI;GAE9C,MAAM,SAAS,MAAM,UAAU;IAAE,OAAO,OAAO;IAAO,KAAK,KAAK;IAAK;GAAG,CAAC,CAAC;EAC5E;CACF,CAwCa,OAtCMA,0BAAQ;EACzB,MAAM;EACN,aACE;EACF,SAAS;EACT,QAAQ,OAAO,EAAE,cAAc;GAC7B,MAAM,QAAQ,kBAAkB,QAAQ,OAAO,QAAQ,GAAG;GAC1D,MAAM,SAAS,MAAM,UAAU;GAE/B,IAAI,CAAC,OAAO,OAAO,OAAO,SAAS,OAAO,IAAI;GAE9C,MAAM,CAAC,EAAE,gBAAgB,EAAE,+BAA+B,MAAM,QAAQ,IAAI,CAC1E,OAAO,0DACP,wBACF,CAAC;GAED,MAAM,SACJ,MAAM,cACJ;IACE,OAAO,OAAO;IACd,KAAK,KAAK;IACV;IACA,kBAAkB;IAClB;GACF,GACA,KACF,CACF;EACF;EACA,SAAS,CACP;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR,CACF;CACF,CAEyB,CAAC;AAC5B"}
@@ -0,0 +1,52 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __exportAll = (all, no_symbols) => {
9
+ let target = {};
10
+ for (var name in all) {
11
+ __defProp(target, name, {
12
+ get: all[name],
13
+ enumerable: true
14
+ });
15
+ }
16
+ if (!no_symbols) {
17
+ __defProp(target, Symbol.toStringTag, { value: "Module" });
18
+ }
19
+ return target;
20
+ };
21
+ var __copyProps = (to, from, except, desc) => {
22
+ if (from && typeof from === "object" || typeof from === "function") {
23
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
24
+ key = keys[i];
25
+ if (!__hasOwnProp.call(to, key) && key !== except) {
26
+ __defProp(to, key, {
27
+ get: ((k) => from[k]).bind(null, key),
28
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
29
+ });
30
+ }
31
+ }
32
+ }
33
+ return to;
34
+ };
35
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
36
+ value: mod,
37
+ enumerable: true
38
+ }) : target, mod));
39
+
40
+ //#endregion
41
+ Object.defineProperty(exports, "__exportAll", {
42
+ enumerable: true,
43
+ get: function () {
44
+ return __exportAll;
45
+ }
46
+ });
47
+ Object.defineProperty(exports, "__toESM", {
48
+ enumerable: true,
49
+ get: function () {
50
+ return __toESM;
51
+ }
52
+ });
@@ -0,0 +1,184 @@
1
+ const require_panels = require("./panels-B0dAfGbJ.cjs");
2
+ const require_process_panel = require("./process-panel-DEOnLxoT.cjs");
3
+ const require_stream_route = require("./stream-route-BGJa-zQu.cjs");
4
+
5
+ //#region ../../packages/devtools/src/server/background-routes.ts
6
+ /** Registers the route that returns work recorded outside any request. */
7
+ function registerBackgroundRoutes(server, deps) {
8
+ server.get("/api/background", async () => deps.collector.getBackground());
9
+ }
10
+
11
+ //#endregion
12
+ //#region ../../packages/devtools/src/server/guard.ts
13
+ const LOOPBACK_ADDRESSES = /* @__PURE__ */ new Set([
14
+ "127.0.0.1",
15
+ "::1",
16
+ "::ffff:127.0.0.1"
17
+ ]);
18
+ /** Host names that always reach this machine, so DNS cannot be pointed at them. */
19
+ const LOOPBACK_HOSTS = /* @__PURE__ */ new Set([
20
+ "localhost",
21
+ "127.0.0.1",
22
+ "[::1]"
23
+ ]);
24
+ /** Headers a proxy or tunnel adds; their presence means the loopback peer is not the visitor. */
25
+ const PROXY_HEADERS = [
26
+ "x-forwarded-for",
27
+ "x-forwarded-host",
28
+ "x-real-ip",
29
+ "forwarded"
30
+ ];
31
+ /** At most this many distinct refusals are logged per boot. */
32
+ const MAX_WARNINGS = 20;
33
+ /**
34
+ * Whether `address` is a loopback address. Deliberately reads
35
+ * `request.socket.remoteAddress` rather than `request.ip`, which honours
36
+ * `X-Forwarded-For` when the app trusts a proxy — a header any client can
37
+ * set.
38
+ */
39
+ function isLoopbackAddress(address) {
40
+ return address !== void 0 && LOOPBACK_ADDRESSES.has(address);
41
+ }
42
+ /** The lower-cased host name of a `Host` header value, without its port (`[::1]` keeps its brackets). */
43
+ function hostnameOf(host) {
44
+ const value = host.trim().toLowerCase();
45
+ if (value.startsWith("[")) {
46
+ const end = value.indexOf("]");
47
+ return end === -1 ? "" : value.slice(0, end + 1);
48
+ }
49
+ const colon = value.indexOf(":");
50
+ const name = colon === -1 ? value : value.slice(0, colon);
51
+ return name.endsWith(".") ? name.slice(0, -1) : name;
52
+ }
53
+ /**
54
+ * Whether `hostname` is a loopback name or one of `allowedHosts`. An entry
55
+ * starting with `.` matches that domain and every subdomain of it.
56
+ */
57
+ function isAllowedDevtoolsHost(hostname, allowedHosts = []) {
58
+ if (!hostname) return false;
59
+ if (LOOPBACK_HOSTS.has(hostname) || hostname.endsWith(".localhost")) return true;
60
+ return allowedHosts.some((entry) => {
61
+ const allowed = entry.trim().toLowerCase();
62
+ if (allowed.startsWith(".")) return hostname === allowed.slice(1) || hostname.endsWith(allowed);
63
+ return hostname === allowed;
64
+ });
65
+ }
66
+ /** The `Origin` header's host name, `""` for `null` or an unparsable value. */
67
+ function originHostname(origin) {
68
+ try {
69
+ return new URL(origin).hostname.toLowerCase();
70
+ } catch {
71
+ return "";
72
+ }
73
+ }
74
+ /**
75
+ * Why `request` must be refused, or `undefined` when it may be served.
76
+ * `"not-local"` is the silent case (production, or a remote socket). Beyond a
77
+ * loopback socket, the request must be ADDRESSED to a loopback (or allowed)
78
+ * host, come from such an origin, and not have passed through a proxy: a page
79
+ * whose domain was re-pointed at 127.0.0.1, or a tunnel, also arrives on a
80
+ * loopback socket.
81
+ */
82
+ function refusalReason(request, deps) {
83
+ if (!deps.isDevelopment() || !isLoopbackAddress(request.socket.remoteAddress)) return "not-local";
84
+ const allowedHosts = deps.options.allowedHosts ?? [];
85
+ const host = hostnameOf(request.headers.host ?? "");
86
+ if (!isAllowedDevtoolsHost(host, allowedHosts)) return `Devtools refused a request for host "${host}". Open the dashboard on localhost, or add the host to the devtools "allowedHosts" option.`;
87
+ const origin = request.headers.origin;
88
+ if (origin !== void 0 && !isAllowedDevtoolsHost(originHostname(origin), allowedHosts)) return `Devtools refused a request from origin "${origin}". Only pages served from localhost or a host in the devtools "allowedHosts" option may call the dashboard.`;
89
+ if (!deps.options.allowProxied && PROXY_HEADERS.some((name) => request.headers[name] !== void 0)) return "Devtools refused a proxied request (it carries a forwarding header). Open the dashboard directly on localhost, or set the devtools \"allowProxied\" option for a local proxy nobody else can reach.";
90
+ }
91
+ /**
92
+ * Registers the dev-only, local-only guard as an `onRequest` hook on
93
+ * `server`. Callers must register this inside an encapsulated Fastify
94
+ * context (a plugin/prefix) so the hook never reaches routes outside the
95
+ * dashboard.
96
+ */
97
+ function registerDevtoolsGuard(server, deps) {
98
+ const warned = /* @__PURE__ */ new Set();
99
+ server.addHook("onRequest", async (request, reply) => {
100
+ const reason = refusalReason(request, deps);
101
+ if (reason === void 0) return;
102
+ if (reason !== "not-local" && !warned.has(reason) && warned.size < MAX_WARNINGS) {
103
+ warned.add(reason);
104
+ deps.warn?.(reason);
105
+ }
106
+ return reply.code(404).send();
107
+ });
108
+ }
109
+
110
+ //#endregion
111
+ //#region ../../packages/devtools/src/server/session-routes.ts
112
+ /**
113
+ * The session view of the development dashboard: there are no accounts, the
114
+ * loopback guard is the access control, and the visitor is an admin.
115
+ */
116
+ function developmentSessionView(deps) {
117
+ return {
118
+ mode: "development",
119
+ stage: "active",
120
+ account: null,
121
+ role: "admin",
122
+ csrf: null,
123
+ expiresAt: null,
124
+ instance: deps.instance ?? null,
125
+ methods: null
126
+ };
127
+ }
128
+ /** The tabs `GET api/panels` lists: the built-in tabs in `deps.builtInPanels` (default all), then the package panels. */
129
+ function panelInfos(deps, panels) {
130
+ return require_panels.listPanelInfos(panels, deps.builtInPanels);
131
+ }
132
+ /**
133
+ * Registers `GET /api/auth/session` (the development view: signed in as an
134
+ * admin, no accounts) and `GET /api/panels`, so the same dashboard shell
135
+ * works in both modes. Production answers these from its own mount.
136
+ */
137
+ function registerSessionRoutes(server, deps, panels) {
138
+ server.get("/api/auth/session", async (_request, reply) => {
139
+ reply.header("Cache-Control", "no-store");
140
+ return developmentSessionView(deps);
141
+ });
142
+ server.get("/api/panels", async (_request, reply) => {
143
+ reply.header("Cache-Control", "no-store");
144
+ return panelInfos(deps, panels);
145
+ });
146
+ }
147
+
148
+ //#endregion
149
+ //#region ../../packages/devtools/src/server/index.ts
150
+ /**
151
+ * Mounts the devtools dashboard and its API under `deps.options.path` on
152
+ * `server`. Every route is registered inside a single encapsulated Fastify
153
+ * context so the dev-only, loopback-only guard never reaches the app's
154
+ * other routes — the registered panels' data routes and files included.
155
+ *
156
+ * Throws before mounting anything when a panel is invalid or reuses an id.
157
+ */
158
+ function mountDevtoolsRoutes(server, deps) {
159
+ const panels = require_panels.checkDevtoolsPanels([require_process_panel.processesDevtoolsPanel(deps.processPanel), ...deps.panels ?? []]);
160
+ server.register(async (instance) => {
161
+ registerDevtoolsGuard(instance, deps);
162
+ instance.setErrorHandler((error, _request, reply) => {
163
+ reply.code(error.statusCode ?? 500).send({ error: error.message });
164
+ });
165
+ require_stream_route.registerUiAssets(instance);
166
+ registerSessionRoutes(instance, deps, panels);
167
+ require_stream_route.registerRequestsRoutes(instance, deps);
168
+ require_stream_route.registerAiRoutes(instance, deps);
169
+ registerBackgroundRoutes(instance, deps);
170
+ require_stream_route.registerMailRoutes(instance, deps);
171
+ require_stream_route.registerLogRoutes(instance, deps);
172
+ require_stream_route.registerRouteRoutes(instance, deps);
173
+ require_stream_route.registerPanelRoutes(instance, panels);
174
+ require_stream_route.registerOpenApiRoutes(instance, deps);
175
+ require_stream_route.registerExplainRoute(instance, deps);
176
+ require_stream_route.registerShapeExplainRoute(instance, deps);
177
+ if (deps.insights) require_stream_route.registerInsightsRoutes(instance, deps);
178
+ require_stream_route.registerStreamRoute(instance, deps);
179
+ }, { prefix: deps.options.path });
180
+ }
181
+
182
+ //#endregion
183
+ exports.mountDevtoolsRoutes = mountDevtoolsRoutes;
184
+ //# sourceMappingURL=server-B6xdeKS8.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-B6xdeKS8.cjs","names":["listPanelInfos","checkDevtoolsPanels","processesDevtoolsPanel"],"sources":["../../../../../../../packages/devtools/src/server/background-routes.ts","../../../../../../../packages/devtools/src/server/guard.ts","../../../../../../../packages/devtools/src/server/session-routes.ts","../../../../../../../packages/devtools/src/server/index.ts"],"sourcesContent":["import type { FastifyInstance } from \"fastify\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\n\n/** Registers the route that returns work recorded outside any request. */\nexport function registerBackgroundRoutes(\n server: FastifyInstance,\n deps: MountDevtoolsRoutesDeps,\n): void {\n server.get(\"/api/background\", async () => deps.collector.getBackground());\n}\n","import type { FastifyInstance, FastifyReply, FastifyRequest } from \"fastify\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\n\nconst LOOPBACK_ADDRESSES = new Set([\"127.0.0.1\", \"::1\", \"::ffff:127.0.0.1\"]);\n\n/** Host names that always reach this machine, so DNS cannot be pointed at them. */\nconst LOOPBACK_HOSTS = new Set([\"localhost\", \"127.0.0.1\", \"[::1]\"]);\n\n/** Headers a proxy or tunnel adds; their presence means the loopback peer is not the visitor. */\nconst PROXY_HEADERS = [\"x-forwarded-for\", \"x-forwarded-host\", \"x-real-ip\", \"forwarded\"] as const;\n\n/** At most this many distinct refusals are logged per boot. */\nconst MAX_WARNINGS = 20;\n\n/**\n * Whether `address` is a loopback address. Deliberately reads\n * `request.socket.remoteAddress` rather than `request.ip`, which honours\n * `X-Forwarded-For` when the app trusts a proxy — a header any client can\n * set.\n */\nfunction isLoopbackAddress(address: string | undefined): boolean {\n return address !== undefined && LOOPBACK_ADDRESSES.has(address);\n}\n\n/** The lower-cased host name of a `Host` header value, without its port (`[::1]` keeps its brackets). */\nexport function hostnameOf(host: string): string {\n const value = host.trim().toLowerCase();\n\n if (value.startsWith(\"[\")) {\n const end = value.indexOf(\"]\");\n\n return end === -1 ? \"\" : value.slice(0, end + 1);\n }\n\n const colon = value.indexOf(\":\");\n const name = colon === -1 ? value : value.slice(0, colon);\n\n return name.endsWith(\".\") ? name.slice(0, -1) : name;\n}\n\n/**\n * Whether `hostname` is a loopback name or one of `allowedHosts`. An entry\n * starting with `.` matches that domain and every subdomain of it.\n */\nexport function isAllowedDevtoolsHost(\n hostname: string,\n allowedHosts: readonly string[] = [],\n): boolean {\n if (!hostname) return false;\n if (LOOPBACK_HOSTS.has(hostname) || hostname.endsWith(\".localhost\")) return true;\n\n return allowedHosts.some((entry) => {\n const allowed = entry.trim().toLowerCase();\n\n if (allowed.startsWith(\".\")) {\n return hostname === allowed.slice(1) || hostname.endsWith(allowed);\n }\n\n return hostname === allowed;\n });\n}\n\n/** The `Origin` header's host name, `\"\"` for `null` or an unparsable value. */\nfunction originHostname(origin: string): string {\n try {\n return new URL(origin).hostname.toLowerCase();\n } catch {\n return \"\";\n }\n}\n\n/**\n * Why `request` must be refused, or `undefined` when it may be served.\n * `\"not-local\"` is the silent case (production, or a remote socket). Beyond a\n * loopback socket, the request must be ADDRESSED to a loopback (or allowed)\n * host, come from such an origin, and not have passed through a proxy: a page\n * whose domain was re-pointed at 127.0.0.1, or a tunnel, also arrives on a\n * loopback socket.\n */\nfunction refusalReason(request: FastifyRequest, deps: MountDevtoolsRoutesDeps): string | undefined {\n if (!deps.isDevelopment() || !isLoopbackAddress(request.socket.remoteAddress)) {\n return \"not-local\";\n }\n\n const allowedHosts = deps.options.allowedHosts ?? [];\n const host = hostnameOf(request.headers.host ?? \"\");\n\n if (!isAllowedDevtoolsHost(host, allowedHosts)) {\n return `Devtools refused a request for host \"${host}\". Open the dashboard on localhost, or add the host to the devtools \"allowedHosts\" option.`;\n }\n\n const origin = request.headers.origin;\n\n if (origin !== undefined && !isAllowedDevtoolsHost(originHostname(origin), allowedHosts)) {\n return `Devtools refused a request from origin \"${origin}\". Only pages served from localhost or a host in the devtools \"allowedHosts\" option may call the dashboard.`;\n }\n\n if (\n !deps.options.allowProxied &&\n PROXY_HEADERS.some((name) => request.headers[name] !== undefined)\n ) {\n return 'Devtools refused a proxied request (it carries a forwarding header). Open the dashboard directly on localhost, or set the devtools \"allowProxied\" option for a local proxy nobody else can reach.';\n }\n\n return undefined;\n}\n\n/**\n * Registers the dev-only, local-only guard as an `onRequest` hook on\n * `server`. Callers must register this inside an encapsulated Fastify\n * context (a plugin/prefix) so the hook never reaches routes outside the\n * dashboard.\n */\nexport function registerDevtoolsGuard(\n server: FastifyInstance,\n deps: MountDevtoolsRoutesDeps,\n): void {\n // One terminal line per distinct refusal, so a misconfigured host is\n // explained once without flooding the log on every poll.\n const warned = new Set<string>();\n\n server.addHook(\"onRequest\", async (request: FastifyRequest, reply: FastifyReply) => {\n const reason = refusalReason(request, deps);\n\n if (reason === undefined) return;\n\n if (reason !== \"not-local\" && !warned.has(reason) && warned.size < MAX_WARNINGS) {\n warned.add(reason);\n deps.warn?.(reason);\n }\n\n // Returning the reply is what stops the lifecycle in an async hook;\n // without it Fastify still runs the handler after the 404 is sent.\n return reply.code(404).send();\n });\n}\n","import type { FastifyInstance } from \"fastify\";\nimport { listPanelInfos, type MountedDevtoolsPanel } from \"../panels\";\nimport type { DevtoolsPanelInfo, DevtoolsSessionView } from \"../production/contracts\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\n\n/**\n * The session view of the development dashboard: there are no accounts, the\n * loopback guard is the access control, and the visitor is an admin.\n */\nexport function developmentSessionView(deps: MountDevtoolsRoutesDeps): DevtoolsSessionView {\n return {\n mode: \"development\",\n stage: \"active\",\n account: null,\n role: \"admin\",\n csrf: null,\n expiresAt: null,\n instance: deps.instance ?? null,\n methods: null,\n };\n}\n\n/** The tabs `GET api/panels` lists: the built-in tabs in `deps.builtInPanels` (default all), then the package panels. */\nexport function panelInfos(\n deps: MountDevtoolsRoutesDeps,\n panels: readonly Pick<MountedDevtoolsPanel, \"id\" | \"title\">[],\n): DevtoolsPanelInfo[] {\n return listPanelInfos(panels, deps.builtInPanels);\n}\n\n/**\n * Registers `GET /api/auth/session` (the development view: signed in as an\n * admin, no accounts) and `GET /api/panels`, so the same dashboard shell\n * works in both modes. Production answers these from its own mount.\n */\nexport function registerSessionRoutes(\n server: FastifyInstance,\n deps: MountDevtoolsRoutesDeps,\n panels: readonly MountedDevtoolsPanel[],\n): void {\n server.get(\"/api/auth/session\", async (_request, reply) => {\n reply.header(\"Cache-Control\", \"no-store\");\n\n return developmentSessionView(deps);\n });\n\n server.get(\"/api/panels\", async (_request, reply) => {\n reply.header(\"Cache-Control\", \"no-store\");\n\n return panelInfos(deps, panels);\n });\n}\n","import type { FastifyError, FastifyInstance } from \"fastify\";\nimport { checkDevtoolsPanels } from \"../panels\";\nimport { processesDevtoolsPanel } from \"../process-panel\";\nimport { registerAiRoutes } from \"./ai-routes\";\nimport { registerBackgroundRoutes } from \"./background-routes\";\nimport { registerExplainRoute, registerShapeExplainRoute } from \"./explain-route\";\nimport { registerInsightsRoutes } from \"./insights-routes\";\nimport { registerDevtoolsGuard } from \"./guard\";\nimport { registerLogRoutes } from \"./log-routes\";\nimport { registerMailRoutes } from \"./mail-routes\";\nimport { registerOpenApiRoutes } from \"./openapi-routes\";\nimport { registerPanelRoutes } from \"./panel-routes\";\nimport { registerRequestsRoutes } from \"./requests-routes\";\nimport { registerRouteRoutes } from \"./route-routes\";\nimport { registerSessionRoutes } from \"./session-routes\";\nimport { registerStreamRoute } from \"./stream-route\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\nimport { registerUiAssets } from \"./ui-assets\";\n\nexport type { DevtoolsRequestLogSource, DevtoolsRouteRow, MountDevtoolsRoutesDeps } from \"./types\";\n\n/**\n * Mounts the devtools dashboard and its API under `deps.options.path` on\n * `server`. Every route is registered inside a single encapsulated Fastify\n * context so the dev-only, loopback-only guard never reaches the app's\n * other routes — the registered panels' data routes and files included.\n *\n * Throws before mounting anything when a panel is invalid or reuses an id.\n */\nexport function mountDevtoolsRoutes(server: FastifyInstance, deps: MountDevtoolsRoutesDeps): void {\n const panels = checkDevtoolsPanels([\n processesDevtoolsPanel(deps.processPanel),\n ...(deps.panels ?? []),\n ]);\n\n server.register(\n async (instance) => {\n registerDevtoolsGuard(instance, deps);\n\n instance.setErrorHandler((error: FastifyError, _request, reply) => {\n reply.code(error.statusCode ?? 500).send({ error: error.message });\n });\n\n registerUiAssets(instance);\n registerSessionRoutes(instance, deps, panels);\n registerRequestsRoutes(instance, deps);\n registerAiRoutes(instance, deps);\n registerBackgroundRoutes(instance, deps);\n registerMailRoutes(instance, deps);\n registerLogRoutes(instance, deps);\n registerRouteRoutes(instance, deps);\n registerPanelRoutes(instance, panels);\n registerOpenApiRoutes(instance, deps);\n registerExplainRoute(instance, deps);\n registerShapeExplainRoute(instance, deps);\n if (deps.insights) registerInsightsRoutes(instance, deps);\n registerStreamRoute(instance, deps);\n },\n { prefix: deps.options.path },\n );\n}\n"],"mappings":";;;;;;AAIA,SAAgB,yBACd,QACA,MACM;CACN,OAAO,IAAI,mBAAmB,YAAY,KAAK,UAAU,cAAc,CAAC;AAC1E;;;;ACNA,MAAM,qCAAqB,IAAI,IAAI;CAAC;CAAa;CAAO;AAAkB,CAAC;;AAG3E,MAAM,iCAAiB,IAAI,IAAI;CAAC;CAAa;CAAa;AAAO,CAAC;;AAGlE,MAAM,gBAAgB;CAAC;CAAmB;CAAoB;CAAa;AAAW;;A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