@warlock.js/devtools 5.55.0 → 5.57.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.
- package/CHANGELOG.md +52 -0
- package/README.md +26 -13
- package/cjs/ai-source-DTpxumMA.cjs +381 -0
- package/cjs/ai-source-DTpxumMA.cjs.map +1 -0
- package/cjs/auth-DzU0gHDG.cjs +1655 -0
- package/cjs/auth-DzU0gHDG.cjs.map +1 -0
- package/cjs/boot-Dy5OqgTM.cjs +138 -0
- package/cjs/boot-Dy5OqgTM.cjs.map +1 -0
- package/cjs/capture-CqIiaznN.cjs +1342 -0
- package/cjs/capture-CqIiaznN.cjs.map +1 -0
- package/cjs/cascade-store-pHjKeSFm.cjs +863 -0
- package/cjs/cascade-store-pHjKeSFm.cjs.map +1 -0
- package/cjs/collector-CJbQbzzK.cjs +271 -0
- package/cjs/collector-CJbQbzzK.cjs.map +1 -0
- package/cjs/contracts-CVmplkNb.cjs +112 -0
- package/cjs/contracts-CVmplkNb.cjs.map +1 -0
- package/cjs/current-request-id-BoJJb3y7.cjs +37 -0
- package/cjs/current-request-id-BoJJb3y7.cjs.map +1 -0
- package/cjs/errors-CyZp5yS-.cjs +177 -0
- package/cjs/errors-CyZp5yS-.cjs.map +1 -0
- package/cjs/histogram-BaI-PnCv.cjs +102 -0
- package/cjs/histogram-BaI-PnCv.cjs.map +1 -0
- package/cjs/http-DCfXQvw-.cjs +870 -0
- package/cjs/http-DCfXQvw-.cjs.map +1 -0
- package/cjs/index.cjs +2 -1
- package/cjs/insights-BKtqxdnP.cjs +811 -0
- package/cjs/insights-BKtqxdnP.cjs.map +1 -0
- package/cjs/ip-DbNhPOzi.cjs +153 -0
- package/cjs/ip-DbNhPOzi.cjs.map +1 -0
- package/cjs/migrations-w7GMsrQw.cjs +297 -0
- package/cjs/migrations-w7GMsrQw.cjs.map +1 -0
- package/cjs/openapi-CC7OAUc6.cjs +52 -0
- package/cjs/openapi-CC7OAUc6.cjs.map +1 -0
- package/cjs/options-CWqFC5__.cjs +181 -0
- package/cjs/options-CWqFC5__.cjs.map +1 -0
- package/cjs/panels-Rcmeitu3.cjs +318 -0
- package/cjs/panels-Rcmeitu3.cjs.map +1 -0
- package/cjs/process-panel-DEOnLxoT.cjs +48 -0
- package/cjs/process-panel-DEOnLxoT.cjs.map +1 -0
- package/cjs/production/index.cjs +238 -0
- package/cjs/production/index.cjs.map +1 -0
- package/cjs/rolldown-runtime-Zuuoy_Rh.cjs +52 -0
- package/cjs/server-ykxsOwob.cjs +184 -0
- package/cjs/server-ykxsOwob.cjs.map +1 -0
- package/cjs/{src-Xwm3Eel9.cjs → src-UPtTCI2j.cjs} +210 -293
- package/cjs/src-UPtTCI2j.cjs.map +1 -0
- package/cjs/store-aq207T8v.cjs +9 -0
- package/cjs/stream-route-CJTABkUy.cjs +875 -0
- package/cjs/stream-route-CJTABkUy.cjs.map +1 -0
- package/esm/devtools-connector.d.mts +16 -13
- package/esm/devtools-connector.d.mts.map +1 -1
- package/esm/devtools-connector.mjs +127 -18
- package/esm/devtools-connector.mjs.map +1 -1
- package/esm/index.d.mts +4 -2
- package/esm/index.mjs +2 -1
- package/esm/options.mjs +2 -1
- package/esm/options.mjs.map +1 -1
- package/esm/panel-tokens.d.mts +13 -0
- package/esm/panel-tokens.d.mts.map +1 -0
- package/esm/panel-tokens.mjs +45 -0
- package/esm/panel-tokens.mjs.map +1 -0
- package/esm/panels.mjs +73 -8
- package/esm/panels.mjs.map +1 -1
- package/esm/production/auth/common-passwords.mjs +303 -0
- package/esm/production/auth/common-passwords.mjs.map +1 -0
- package/esm/production/auth/default-crypto.mjs +19 -0
- package/esm/production/auth/default-crypto.mjs.map +1 -0
- package/esm/production/auth/helpers.mjs +77 -0
- package/esm/production/auth/helpers.mjs.map +1 -0
- package/esm/production/auth/index.mjs +6 -0
- package/esm/production/auth/passkeys.mjs +96 -0
- package/esm/production/auth/passkeys.mjs.map +1 -0
- package/esm/production/auth/service.mjs +1166 -0
- package/esm/production/auth/service.mjs.map +1 -0
- package/esm/production/boot.mjs +138 -0
- package/esm/production/boot.mjs.map +1 -0
- package/esm/production/capture/dev-stats.mjs +83 -0
- package/esm/production/capture/dev-stats.mjs.map +1 -0
- package/esm/production/capture/engine.mjs +442 -0
- package/esm/production/capture/engine.mjs.map +1 -0
- package/esm/production/capture/explain.mjs +271 -0
- package/esm/production/capture/explain.mjs.map +1 -0
- package/esm/production/capture/filter.mjs +24 -0
- package/esm/production/capture/filter.mjs.map +1 -0
- package/esm/production/capture/index.mjs +7 -0
- package/esm/production/capture/production-capture.mjs +134 -0
- package/esm/production/capture/production-capture.mjs.map +1 -0
- package/esm/production/capture/redact.mjs +109 -0
- package/esm/production/capture/redact.mjs.map +1 -0
- package/esm/production/capture/stats-stores.mjs +300 -0
- package/esm/production/capture/stats-stores.mjs.map +1 -0
- package/esm/production/cli/actions.mjs +151 -0
- package/esm/production/cli/actions.mjs.map +1 -0
- package/esm/production/cli/index.d.mts +17 -0
- package/esm/production/cli/index.d.mts.map +1 -0
- package/esm/production/cli/index.mjs +86 -0
- package/esm/production/cli/index.mjs.map +1 -0
- package/esm/production/contracts.d.mts +592 -0
- package/esm/production/contracts.d.mts.map +1 -0
- package/esm/production/contracts.mjs +95 -0
- package/esm/production/contracts.mjs.map +1 -0
- package/esm/production/errors.d.mts +31 -0
- package/esm/production/errors.d.mts.map +1 -0
- package/esm/production/errors.mjs +142 -0
- package/esm/production/errors.mjs.map +1 -0
- package/esm/production/http/access.mjs +124 -0
- package/esm/production/http/access.mjs.map +1 -0
- package/esm/production/http/auth-routes.mjs +280 -0
- package/esm/production/http/auth-routes.mjs.map +1 -0
- package/esm/production/http/client.mjs +57 -0
- package/esm/production/http/client.mjs.map +1 -0
- package/esm/production/http/constants.mjs +11 -0
- package/esm/production/http/constants.mjs.map +1 -0
- package/esm/production/http/context.mjs +14 -0
- package/esm/production/http/context.mjs.map +1 -0
- package/esm/production/http/cookie.mjs +39 -0
- package/esm/production/http/cookie.mjs.map +1 -0
- package/esm/production/http/headers.mjs +25 -0
- package/esm/production/http/headers.mjs.map +1 -0
- package/esm/production/http/index.mjs +10 -0
- package/esm/production/http/ip.mjs +130 -0
- package/esm/production/http/ip.mjs.map +1 -0
- package/esm/production/http/mount.mjs +300 -0
- package/esm/production/http/mount.mjs.map +1 -0
- package/esm/production/http/state.mjs +54 -0
- package/esm/production/http/state.mjs.map +1 -0
- package/esm/production/index.d.mts +6 -0
- package/esm/production/index.mjs +5 -0
- package/esm/production/insights/cap-report.mjs +67 -0
- package/esm/production/insights/cap-report.mjs.map +1 -0
- package/esm/production/insights/health.mjs +88 -0
- package/esm/production/insights/health.mjs.map +1 -0
- package/esm/production/insights/index.mjs +10 -0
- package/esm/production/insights/insights.mjs +167 -0
- package/esm/production/insights/insights.mjs.map +1 -0
- package/esm/production/insights/instance.mjs +24 -0
- package/esm/production/insights/instance.mjs.map +1 -0
- package/esm/production/insights/jobs.mjs +100 -0
- package/esm/production/insights/jobs.mjs.map +1 -0
- package/esm/production/insights/reporter.mjs +59 -0
- package/esm/production/insights/reporter.mjs.map +1 -0
- package/esm/production/insights/resources.mjs +139 -0
- package/esm/production/insights/resources.mjs.map +1 -0
- package/esm/production/insights/writer.mjs +72 -0
- package/esm/production/insights/writer.mjs.map +1 -0
- package/esm/production/openapi.mjs +52 -0
- package/esm/production/openapi.mjs.map +1 -0
- package/esm/production/options.d.mts +60 -0
- package/esm/production/options.d.mts.map +1 -0
- package/esm/production/options.mjs +170 -0
- package/esm/production/options.mjs.map +1 -0
- package/esm/production/stats/histogram.mjs +67 -0
- package/esm/production/stats/histogram.mjs.map +1 -0
- package/esm/production/stats/merge.mjs +106 -0
- package/esm/production/stats/merge.mjs.map +1 -0
- package/esm/production/store/cascade-store.mjs +322 -0
- package/esm/production/store/cascade-store.mjs.map +1 -0
- package/esm/production/store/index.mjs +5 -0
- package/esm/production/store/mapping.mjs +258 -0
- package/esm/production/store/mapping.mjs.map +1 -0
- package/esm/production/store/memory-store.mjs +291 -0
- package/esm/production/store/memory-store.mjs.map +1 -0
- package/esm/production/store/migrations.d.mts +11 -0
- package/esm/production/store/migrations.d.mts.map +1 -0
- package/esm/production/store/migrations.mjs +29 -0
- package/esm/production/store/migrations.mjs.map +1 -0
- package/esm/production/store/models/account.migration.mjs +34 -0
- package/esm/production/store/models/account.migration.mjs.map +1 -0
- package/esm/production/store/models/account.model.mjs +13 -0
- package/esm/production/store/models/account.model.mjs.map +1 -0
- package/esm/production/store/models/audit.migration.mjs +30 -0
- package/esm/production/store/models/audit.migration.mjs.map +1 -0
- package/esm/production/store/models/audit.model.mjs +13 -0
- package/esm/production/store/models/audit.model.mjs.map +1 -0
- package/esm/production/store/models/base.mjs +27 -0
- package/esm/production/store/models/base.mjs.map +1 -0
- package/esm/production/store/models/index.mjs +17 -0
- package/esm/production/store/models/invite.migration.mjs +26 -0
- package/esm/production/store/models/invite.migration.mjs.map +1 -0
- package/esm/production/store/models/invite.model.mjs +13 -0
- package/esm/production/store/models/invite.model.mjs.map +1 -0
- package/esm/production/store/models/report.migration.mjs +20 -0
- package/esm/production/store/models/report.migration.mjs.map +1 -0
- package/esm/production/store/models/report.model.mjs +13 -0
- package/esm/production/store/models/report.model.mjs.map +1 -0
- package/esm/production/store/models/sample.migration.mjs +25 -0
- package/esm/production/store/models/sample.migration.mjs.map +1 -0
- package/esm/production/store/models/sample.model.mjs +13 -0
- package/esm/production/store/models/sample.model.mjs.map +1 -0
- package/esm/production/store/models/session.migration.mjs +31 -0
- package/esm/production/store/models/session.migration.mjs.map +1 -0
- package/esm/production/store/models/session.model.mjs +13 -0
- package/esm/production/store/models/session.model.mjs.map +1 -0
- package/esm/production/store/models/state.migration.mjs +26 -0
- package/esm/production/store/models/state.migration.mjs.map +1 -0
- package/esm/production/store/models/state.model.mjs +13 -0
- package/esm/production/store/models/state.model.mjs.map +1 -0
- package/esm/query-shape.mjs +14 -1
- package/esm/query-shape.mjs.map +1 -1
- package/esm/server/explain-route.mjs +26 -1
- package/esm/server/explain-route.mjs.map +1 -1
- package/esm/server/index.mjs +9 -4
- package/esm/server/index.mjs.map +1 -1
- package/esm/server/insights-routes.mjs +62 -0
- package/esm/server/insights-routes.mjs.map +1 -0
- package/esm/server/log-routes.mjs +32 -5
- package/esm/server/log-routes.mjs.map +1 -1
- package/esm/server/openapi-routes.mjs +3 -2
- package/esm/server/openapi-routes.mjs.map +1 -1
- package/esm/server/requests-routes.mjs +125 -0
- package/esm/server/requests-routes.mjs.map +1 -1
- package/esm/server/session-routes.mjs +42 -0
- package/esm/server/session-routes.mjs.map +1 -0
- package/esm/server/stream-route.mjs +81 -11
- package/esm/server/stream-route.mjs.map +1 -1
- package/esm/server/ui-assets.mjs +34 -25
- package/esm/server/ui-assets.mjs.map +1 -1
- package/esm/sources/log-source.mjs +14 -1
- package/esm/sources/log-source.mjs.map +1 -1
- package/esm/types.d.mts +208 -3
- package/esm/types.d.mts.map +1 -1
- package/esm/ui-root.mjs +9 -4
- package/esm/ui-root.mjs.map +1 -1
- package/llms-full.txt +166 -21
- package/llms.txt +2 -2
- package/package.json +32 -8
- package/skills/SKILL.md +166 -21
- package/ui/dashboard/assets/app.css +3 -0
- package/ui/dashboard/assets/app.js +50 -0
- package/ui/dashboard/build-info.json +21 -0
- package/ui/dashboard/index.html +16 -0
- package/ui/panels/processes.js +12 -3
- package/cjs/ai-source-Dz_3tlZ5.cjs +0 -703
- package/cjs/ai-source-Dz_3tlZ5.cjs.map +0 -1
- package/cjs/server-B11ShQYE.cjs +0 -628
- package/cjs/server-B11ShQYE.cjs.map +0 -1
- package/cjs/src-Xwm3Eel9.cjs.map +0 -1
- package/ui/app.css +0 -376
- package/ui/app.js +0 -1158
- package/ui/index.html +0 -28
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { BlockList, isIP } from "node:net";
|
|
2
|
+
|
|
3
|
+
//#region ../../packages/devtools/src/production/http/ip.ts
|
|
4
|
+
/** The IPv4 ranges `"private"` stands for (private networks and link-local). */
|
|
5
|
+
const PRIVATE_V4 = [
|
|
6
|
+
["10.0.0.0", 8],
|
|
7
|
+
["172.16.0.0", 12],
|
|
8
|
+
["192.168.0.0", 16],
|
|
9
|
+
["169.254.0.0", 16]
|
|
10
|
+
];
|
|
11
|
+
/** The IPv6 ranges `"private"` stands for (unique local and link-local). */
|
|
12
|
+
const PRIVATE_V6 = [["fc00::", 7], ["fe80::", 10]];
|
|
13
|
+
const MAPPED_PREFIX = /^::ffff:(\d{1,3}(?:\.\d{1,3}){3})$/i;
|
|
14
|
+
/**
|
|
15
|
+
* An address in its plain form: an IPv4-mapped IPv6 address (`::ffff:1.2.3.4`)
|
|
16
|
+
* becomes `1.2.3.4`, a zone id (`fe80::1%eth0`) is dropped, and the letters of
|
|
17
|
+
* an IPv6 address are lower case. Anything that is not an IP is returned
|
|
18
|
+
* unchanged.
|
|
19
|
+
*/
|
|
20
|
+
function normalizeIp(address) {
|
|
21
|
+
const value = address.trim();
|
|
22
|
+
const zone = value.indexOf("%");
|
|
23
|
+
const bare = zone === -1 ? value : value.slice(0, zone);
|
|
24
|
+
const mapped = MAPPED_PREFIX.exec(bare);
|
|
25
|
+
if (mapped?.[1] !== void 0 && isIP(mapped[1]) === 4) return mapped[1];
|
|
26
|
+
return isIP(bare) === 6 ? bare.toLowerCase() : bare;
|
|
27
|
+
}
|
|
28
|
+
/** Splits `a.b.c.d/24` into its address and prefix length, or `null` when it is not a CIDR. */
|
|
29
|
+
function parseCidr(entry) {
|
|
30
|
+
const slash = entry.indexOf("/");
|
|
31
|
+
if (slash === -1) return null;
|
|
32
|
+
const address = normalizeIp(entry.slice(0, slash));
|
|
33
|
+
const text = entry.slice(slash + 1);
|
|
34
|
+
const family = isIP(address);
|
|
35
|
+
if (family === 0 || !/^\d{1,3}$/.test(text)) return null;
|
|
36
|
+
const prefix = Number(text);
|
|
37
|
+
if (family !== 4 && family !== 6) return null;
|
|
38
|
+
return prefix <= (family === 4 ? 32 : 128) ? {
|
|
39
|
+
address,
|
|
40
|
+
prefix,
|
|
41
|
+
family
|
|
42
|
+
} : null;
|
|
43
|
+
}
|
|
44
|
+
/** Whether `entry` is an IP, a CIDR range, `"loopback"` or `"private"`. */
|
|
45
|
+
function isValidNetworkEntry(entry) {
|
|
46
|
+
if (typeof entry !== "string") return false;
|
|
47
|
+
if (entry === "loopback" || entry === "private") return true;
|
|
48
|
+
return isIP(normalizeIp(entry)) !== 0 || parseCidr(entry) !== null;
|
|
49
|
+
}
|
|
50
|
+
const compiled = /* @__PURE__ */ new WeakMap();
|
|
51
|
+
function compile(entries) {
|
|
52
|
+
const cached = compiled.get(entries);
|
|
53
|
+
if (cached) return cached;
|
|
54
|
+
const list = new BlockList();
|
|
55
|
+
for (const entry of entries) {
|
|
56
|
+
if (entry === "loopback") {
|
|
57
|
+
list.addSubnet("127.0.0.0", 8, "ipv4");
|
|
58
|
+
list.addAddress("::1", "ipv6");
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (entry === "private") {
|
|
62
|
+
for (const [address, prefix] of PRIVATE_V4) list.addSubnet(address, prefix, "ipv4");
|
|
63
|
+
for (const [address, prefix] of PRIVATE_V6) list.addSubnet(address, prefix, "ipv6");
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const cidr = parseCidr(entry);
|
|
67
|
+
if (cidr) {
|
|
68
|
+
list.addSubnet(cidr.address, cidr.prefix, cidr.family === 4 ? "ipv4" : "ipv6");
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const address = normalizeIp(entry);
|
|
72
|
+
const family = isIP(address);
|
|
73
|
+
if (family !== 0) list.addAddress(address, family === 4 ? "ipv4" : "ipv6");
|
|
74
|
+
}
|
|
75
|
+
compiled.set(entries, list);
|
|
76
|
+
return list;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Whether `address` matches an entry: an IP, a CIDR, `"loopback"` or
|
|
80
|
+
* `"private"` (10/8, 172.16/12, 192.168/16, 169.254/16, fc00::/7, fe80::/10).
|
|
81
|
+
* IPv4-mapped IPv6 addresses are unwrapped on both sides.
|
|
82
|
+
*/
|
|
83
|
+
function ipMatches(address, entries) {
|
|
84
|
+
if (entries.length === 0) return false;
|
|
85
|
+
const ip = normalizeIp(address);
|
|
86
|
+
const family = isIP(ip);
|
|
87
|
+
if (family === 0) return false;
|
|
88
|
+
return compile(entries).check(ip, family === 4 ? "ipv4" : "ipv6");
|
|
89
|
+
}
|
|
90
|
+
/** The eight 16-bit groups of an IPv6 address, or `null` when it is not one. */
|
|
91
|
+
function ipv6Groups(address) {
|
|
92
|
+
if (isIP(address) !== 6) return null;
|
|
93
|
+
const text = address.replace(/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/, (_, a, b, c, d) => `${(Number(a) << 8 | Number(b)).toString(16)}:${(Number(c) << 8 | Number(d)).toString(16)}`);
|
|
94
|
+
const parse = (part) => part === "" ? [] : part.split(":").map((group) => parseInt(group, 16));
|
|
95
|
+
const [head = "", rest] = text.split("::");
|
|
96
|
+
const left = parse(head);
|
|
97
|
+
const right = rest === void 0 ? [] : parse(rest);
|
|
98
|
+
const zeros = Array.from({ length: Math.max(0, 8 - left.length - right.length) }, () => 0);
|
|
99
|
+
return [
|
|
100
|
+
...left,
|
|
101
|
+
...zeros,
|
|
102
|
+
...right
|
|
103
|
+
];
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The client an address counts as for the sign-in rate limits. An IPv4
|
|
107
|
+
* address counts as itself (an IPv4-mapped IPv6 address as its IPv4 address),
|
|
108
|
+
* an IPv6 address by its /64 network, because one host is usually given a
|
|
109
|
+
* whole /64 and can change the rest at will. Anything else is returned as is.
|
|
110
|
+
*/
|
|
111
|
+
function rateLimitClient(address) {
|
|
112
|
+
const ip = normalizeIp(address);
|
|
113
|
+
const groups = ipv6Groups(ip);
|
|
114
|
+
if (groups === null) return ip;
|
|
115
|
+
if (groups.slice(0, 5).every((group) => group === 0) && groups[5] === 65535) {
|
|
116
|
+
const high = groups[6] ?? 0;
|
|
117
|
+
const low = groups[7] ?? 0;
|
|
118
|
+
return [
|
|
119
|
+
high >> 8,
|
|
120
|
+
high & 255,
|
|
121
|
+
low >> 8,
|
|
122
|
+
low & 255
|
|
123
|
+
].join(".");
|
|
124
|
+
}
|
|
125
|
+
return `${groups.slice(0, 4).map((group) => group.toString(16)).join(":")}::/64`;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
//#endregion
|
|
129
|
+
export { ipMatches, isValidNetworkEntry, normalizeIp, rateLimitClient };
|
|
130
|
+
//# sourceMappingURL=ip.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ip.mjs","names":[],"sources":["../../../../../../../../../packages/devtools/src/production/http/ip.ts"],"sourcesContent":["import { BlockList, isIP } from \"node:net\";\n\n/** The IPv4 ranges `\"private\"` stands for (private networks and link-local). */\nconst PRIVATE_V4: readonly (readonly [string, number])[] = [\n [\"10.0.0.0\", 8],\n [\"172.16.0.0\", 12],\n [\"192.168.0.0\", 16],\n [\"169.254.0.0\", 16],\n];\n\n/** The IPv6 ranges `\"private\"` stands for (unique local and link-local). */\nconst PRIVATE_V6: readonly (readonly [string, number])[] = [\n [\"fc00::\", 7],\n [\"fe80::\", 10],\n];\n\nconst MAPPED_PREFIX = /^::ffff:(\\d{1,3}(?:\\.\\d{1,3}){3})$/i;\n\n/**\n * An address in its plain form: an IPv4-mapped IPv6 address (`::ffff:1.2.3.4`)\n * becomes `1.2.3.4`, a zone id (`fe80::1%eth0`) is dropped, and the letters of\n * an IPv6 address are lower case. Anything that is not an IP is returned\n * unchanged.\n */\nexport function normalizeIp(address: string): string {\n const value = address.trim();\n const zone = value.indexOf(\"%\");\n const bare = zone === -1 ? value : value.slice(0, zone);\n const mapped = MAPPED_PREFIX.exec(bare);\n\n if (mapped?.[1] !== undefined && isIP(mapped[1]) === 4) return mapped[1];\n\n return isIP(bare) === 6 ? bare.toLowerCase() : bare;\n}\n\n/** Splits `a.b.c.d/24` into its address and prefix length, or `null` when it is not a CIDR. */\nfunction parseCidr(entry: string): { address: string; prefix: number; family: 4 | 6 } | null {\n const slash = entry.indexOf(\"/\");\n\n if (slash === -1) return null;\n\n const address = normalizeIp(entry.slice(0, slash));\n const text = entry.slice(slash + 1);\n const family = isIP(address);\n\n if (family === 0 || !/^\\d{1,3}$/.test(text)) return null;\n\n const prefix = Number(text);\n\n if (family !== 4 && family !== 6) return null;\n\n return prefix <= (family === 4 ? 32 : 128) ? { address, prefix, family } : null;\n}\n\n/** Whether `entry` is an IP, a CIDR range, `\"loopback\"` or `\"private\"`. */\nexport function isValidNetworkEntry(entry: unknown): entry is string {\n if (typeof entry !== \"string\") return false;\n if (entry === \"loopback\" || entry === \"private\") return true;\n\n return isIP(normalizeIp(entry)) !== 0 || parseCidr(entry) !== null;\n}\n\nconst compiled = new WeakMap<readonly string[], BlockList>();\n\nfunction compile(entries: readonly string[]): BlockList {\n const cached = compiled.get(entries);\n\n if (cached) return cached;\n\n const list = new BlockList();\n\n for (const entry of entries) {\n if (entry === \"loopback\") {\n list.addSubnet(\"127.0.0.0\", 8, \"ipv4\");\n list.addAddress(\"::1\", \"ipv6\");\n continue;\n }\n\n if (entry === \"private\") {\n for (const [address, prefix] of PRIVATE_V4) list.addSubnet(address, prefix, \"ipv4\");\n for (const [address, prefix] of PRIVATE_V6) list.addSubnet(address, prefix, \"ipv6\");\n continue;\n }\n\n const cidr = parseCidr(entry);\n\n if (cidr) {\n list.addSubnet(cidr.address, cidr.prefix, cidr.family === 4 ? \"ipv4\" : \"ipv6\");\n continue;\n }\n\n const address = normalizeIp(entry);\n const family = isIP(address);\n\n if (family !== 0) list.addAddress(address, family === 4 ? \"ipv4\" : \"ipv6\");\n }\n\n compiled.set(entries, list);\n\n return list;\n}\n\n/**\n * Whether `address` matches an entry: an IP, a CIDR, `\"loopback\"` or\n * `\"private\"` (10/8, 172.16/12, 192.168/16, 169.254/16, fc00::/7, fe80::/10).\n * IPv4-mapped IPv6 addresses are unwrapped on both sides.\n */\nexport function ipMatches(address: string, entries: readonly string[]): boolean {\n if (entries.length === 0) return false;\n\n const ip = normalizeIp(address);\n const family = isIP(ip);\n\n if (family === 0) return false;\n\n return compile(entries).check(ip, family === 4 ? \"ipv4\" : \"ipv6\");\n}\n\n/** The eight 16-bit groups of an IPv6 address, or `null` when it is not one. */\nfunction ipv6Groups(address: string): number[] | null {\n if (isIP(address) !== 6) return null;\n\n // A trailing dotted IPv4 part (`::ffff:1.2.3.4`, `64:ff9b::1.2.3.4`) becomes two hex groups.\n const text = address.replace(\n /(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$/,\n (_, a, b, c, d) =>\n `${((Number(a) << 8) | Number(b)).toString(16)}:${((Number(c) << 8) | Number(d)).toString(16)}`,\n );\n const parse = (part: string) =>\n part === \"\" ? [] : part.split(\":\").map((group) => parseInt(group, 16));\n const [head = \"\", rest] = text.split(\"::\");\n const left = parse(head);\n const right = rest === undefined ? [] : parse(rest);\n const zeros = Array.from({ length: Math.max(0, 8 - left.length - right.length) }, () => 0);\n\n return [...left, ...zeros, ...right];\n}\n\n/**\n * The client an address counts as for the sign-in rate limits. An IPv4\n * address counts as itself (an IPv4-mapped IPv6 address as its IPv4 address),\n * an IPv6 address by its /64 network, because one host is usually given a\n * whole /64 and can change the rest at will. Anything else is returned as is.\n */\nexport function rateLimitClient(address: string): string {\n const ip = normalizeIp(address);\n const groups = ipv6Groups(ip);\n\n if (groups === null) return ip;\n\n // ::ffff:a.b.c.d written any other way (0:0:0:0:0:ffff:…, hex groups).\n if (groups.slice(0, 5).every((group) => group === 0) && groups[5] === 0xffff) {\n const high = groups[6] ?? 0;\n const low = groups[7] ?? 0;\n\n return [high >> 8, high & 0xff, low >> 8, low & 0xff].join(\".\");\n }\n\n return `${groups\n .slice(0, 4)\n .map((group) => group.toString(16))\n .join(\":\")}::/64`;\n}\n"],"mappings":";;;;AAGA,MAAM,aAAqD;CACzD,CAAC,YAAY,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,MAAM,SAAS,SACb,SAAS,KAAK,CAAC,IAAI,KAAK,MAAM,GAAG,CAAC,CAAC,KAAK,UAAU,SAAS,OAAO,EAAE,CAAC;CACvE,MAAM,CAAC,OAAO,IAAI,QAAQ,KAAK,MAAM,IAAI;CACzC,MAAM,OAAO,MAAM,IAAI;CACvB,MAAM,QAAQ,SAAS,SAAY,CAAC,IAAI,MAAM,IAAI;CAClD,MAAM,QAAQ,MAAM,KAAK,EAAE,QAAQ,KAAK,IAAI,GAAG,IAAI,KAAK,SAAS,MAAM,MAAM,EAAE,SAAS,CAAC;CAEzF,OAAO;EAAC,GAAG;EAAM,GAAG;EAAO,GAAG;CAAK;AACrC;;;;;;;AAQA,SAAgB,gBAAgB,SAAyB;CACvD,MAAM,KAAK,YAAY,OAAO;CAC9B,MAAM,SAAS,WAAW,EAAE;CAE5B,IAAI,WAAW,MAAM,OAAO;CAG5B,IAAI,OAAO,MAAM,GAAG,CAAC,CAAC,CAAC,OAAO,UAAU,UAAU,CAAC,KAAK,OAAO,OAAO,OAAQ;EAC5E,MAAM,OAAO,OAAO,MAAM;EAC1B,MAAM,MAAM,OAAO,MAAM;EAEzB,OAAO;GAAC,QAAQ;GAAG,OAAO;GAAM,OAAO;GAAG,MAAM;EAAI,CAAC,CAAC,KAAK,GAAG;CAChE;CAEA,OAAO,GAAG,OACP,MAAM,GAAG,CAAC,CAAC,CACX,KAAK,UAAU,MAAM,SAAS,EAAE,CAAC,CAAC,CAClC,KAAK,GAAG,EAAE;AACf"}
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { listPanelInfos } from "../../panels.mjs";
|
|
2
|
+
import { DEVTOOLS_ERROR_MESSAGES, DevtoolsApiError, createErrorRef } from "../errors.mjs";
|
|
3
|
+
import { ipMatches } from "./ip.mjs";
|
|
4
|
+
import { createAccessLookup, productionRouteAccess } from "./access.mjs";
|
|
5
|
+
import { resolveClient } from "./client.mjs";
|
|
6
|
+
import { DEVTOOLS_CSRF_HEADER } from "./constants.mjs";
|
|
7
|
+
import { devtoolsRequestContext, setDevtoolsRequestContext } from "./context.mjs";
|
|
8
|
+
import { readCookie, sessionCookieName } from "./cookie.mjs";
|
|
9
|
+
import { registerAiRoutes } from "../../server/ai-routes.mjs";
|
|
10
|
+
import { registerShapeExplainRoute } from "../../server/explain-route.mjs";
|
|
11
|
+
import { registerInsightsRoutes } from "../../server/insights-routes.mjs";
|
|
12
|
+
import { registerLogRoutes } from "../../server/log-routes.mjs";
|
|
13
|
+
import { registerMailRoutes } from "../../server/mail-routes.mjs";
|
|
14
|
+
import { registerUiAssets } from "../../server/ui-assets.mjs";
|
|
15
|
+
import { registerOpenApiRoutes } from "../../server/openapi-routes.mjs";
|
|
16
|
+
import { registerPanelRoutes } from "../../server/panel-routes.mjs";
|
|
17
|
+
import { registerRequestsRoutes } from "../../server/requests-routes.mjs";
|
|
18
|
+
import { registerRouteRoutes } from "../../server/route-routes.mjs";
|
|
19
|
+
import { registerStreamRoute } from "../../server/stream-route.mjs";
|
|
20
|
+
import { registerAuthRoutes } from "./auth-routes.mjs";
|
|
21
|
+
import { DASHBOARD_CSP, DASHBOARD_HEADERS, DOCS_CSP } from "./headers.mjs";
|
|
22
|
+
import { createHash } from "node:crypto";
|
|
23
|
+
|
|
24
|
+
//#region ../../packages/devtools/src/production/http/mount.ts
|
|
25
|
+
/** Open live streams a session may hold, and an instance may serve. */
|
|
26
|
+
const MAX_STREAMS_PER_SESSION = 3;
|
|
27
|
+
const MAX_STREAMS_PER_INSTANCE = 50;
|
|
28
|
+
const MAX_USER_AGENT = 200;
|
|
29
|
+
/** Methods that never change state. */
|
|
30
|
+
const SAFE_METHODS = /* @__PURE__ */ new Set([
|
|
31
|
+
"GET",
|
|
32
|
+
"HEAD",
|
|
33
|
+
"OPTIONS"
|
|
34
|
+
]);
|
|
35
|
+
/** The routes of the opt-in API documentation pages (they keep a CSP of their own). */
|
|
36
|
+
const DOCS_PATTERNS = /* @__PURE__ */ new Set(["/docs", "/docs/swagger"]);
|
|
37
|
+
/** The mail preview's HTML: framed by the dashboard, with a policy of its own. */
|
|
38
|
+
const MAIL_HTML_PATTERN = "/api/mails/:id/html";
|
|
39
|
+
/** Which tab a route belongs to: a route of a tab that is off answers the uniform 404. */
|
|
40
|
+
const TAB_OF_ROUTE = [
|
|
41
|
+
["/api/resources", "resources"],
|
|
42
|
+
["/api/queries", "queries"],
|
|
43
|
+
["/api/routes/stats", "routes"],
|
|
44
|
+
["/api/routes", "routes"],
|
|
45
|
+
["/api/health", "health"],
|
|
46
|
+
["/api/errors", "errors"],
|
|
47
|
+
["/api/jobs", "jobs"],
|
|
48
|
+
["/api/logs", "logs"],
|
|
49
|
+
["/api/requests", "requests"],
|
|
50
|
+
["/api/mails", "mail"],
|
|
51
|
+
["/api/ai/agent-runs", "agents"],
|
|
52
|
+
["/api/ai", "ai"],
|
|
53
|
+
["/api/openapi.json", "api"],
|
|
54
|
+
["/api/postman.json", "api"],
|
|
55
|
+
["/docs", "api"]
|
|
56
|
+
];
|
|
57
|
+
function tabOf(pattern) {
|
|
58
|
+
return TAB_OF_ROUTE.find(([prefix]) => pattern === prefix || pattern.startsWith(`${prefix}/`))?.[1];
|
|
59
|
+
}
|
|
60
|
+
function tokenHash(token) {
|
|
61
|
+
return createHash("sha256").update(token).digest("hex");
|
|
62
|
+
}
|
|
63
|
+
/** Requests that were answered with the uniform 404: they get none of the dashboard's headers. */
|
|
64
|
+
const uniformNotFound = /* @__PURE__ */ new WeakSet();
|
|
65
|
+
/**
|
|
66
|
+
* The origin the browser must send for an unsafe request: `production.origin`,
|
|
67
|
+
* else the scheme and host the request was addressed to.
|
|
68
|
+
*/
|
|
69
|
+
function originAllowed(request, expected) {
|
|
70
|
+
const origin = request.headers.origin;
|
|
71
|
+
const site = request.headers["sec-fetch-site"];
|
|
72
|
+
if (site !== void 0 && site !== "same-origin") return false;
|
|
73
|
+
if (origin !== void 0) return origin.toLowerCase() === expected.toLowerCase();
|
|
74
|
+
return site === "same-origin";
|
|
75
|
+
}
|
|
76
|
+
function hasBody(request) {
|
|
77
|
+
const length = request.headers["content-length"];
|
|
78
|
+
return length !== void 0 && length !== "0" || request.headers["transfer-encoding"] !== void 0;
|
|
79
|
+
}
|
|
80
|
+
function isJson(request) {
|
|
81
|
+
return /^application\/json\s*(;|$)/i.test(request.headers["content-type"] ?? "");
|
|
82
|
+
}
|
|
83
|
+
function sessionAccessOk(access, stage) {
|
|
84
|
+
if (stage === "active") return true;
|
|
85
|
+
return access.type === "pending" && access.stages.includes(stage);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Mounts the production monitor under `production.path` in one encapsulated
|
|
89
|
+
* Fastify context: the gate (uniform 404, HTTPS, allowed IPs, open state),
|
|
90
|
+
* session and role checks from the access table, CSRF and origin checks,
|
|
91
|
+
* security headers and CORS stripping, the auth/account/admin routes, and
|
|
92
|
+
* the shared data routes of the enabled tabs.
|
|
93
|
+
*/
|
|
94
|
+
function mountProductionDevtools(server, deps) {
|
|
95
|
+
const { production, auth, state, store } = deps;
|
|
96
|
+
const prefix = production.path;
|
|
97
|
+
const cookieName = sessionCookieName(production.requireHttps);
|
|
98
|
+
const enabledTabs = new Set(deps.builtInPanels);
|
|
99
|
+
const lookup = createAccessLookup(productionRouteAccess(deps.panels.map((panel) => panel.id)));
|
|
100
|
+
const streamsPerSession = /* @__PURE__ */ new Map();
|
|
101
|
+
let streamsInstance = 0;
|
|
102
|
+
let lastWarningAt = 0;
|
|
103
|
+
const warn = (message) => {
|
|
104
|
+
const now = Date.now();
|
|
105
|
+
if (now - lastWarningAt < 6e4) return;
|
|
106
|
+
lastWarningAt = now;
|
|
107
|
+
deps.warn?.(message);
|
|
108
|
+
};
|
|
109
|
+
const notFound = (request, reply) => {
|
|
110
|
+
uniformNotFound.add(request);
|
|
111
|
+
reply.callNotFound();
|
|
112
|
+
return reply;
|
|
113
|
+
};
|
|
114
|
+
const streamSession = async (request) => {
|
|
115
|
+
const authenticated = devtoolsRequestContext(request)?.authenticated;
|
|
116
|
+
if (!authenticated) throw new Error("A dashboard stream was opened without a session.");
|
|
117
|
+
const sessionId = authenticated.session.id;
|
|
118
|
+
const token = readCookie(request.headers.cookie, cookieName);
|
|
119
|
+
const open = streamsPerSession.get(sessionId) ?? 0;
|
|
120
|
+
if (open >= MAX_STREAMS_PER_SESSION || streamsInstance >= MAX_STREAMS_PER_INSTANCE) throw new DevtoolsApiError("stream.too-many");
|
|
121
|
+
streamsPerSession.set(sessionId, open + 1);
|
|
122
|
+
streamsInstance += 1;
|
|
123
|
+
let released = false;
|
|
124
|
+
return {
|
|
125
|
+
role: authenticated.account.role,
|
|
126
|
+
logLevels: production.logLevels,
|
|
127
|
+
headers: DASHBOARD_HEADERS,
|
|
128
|
+
async revalidate() {
|
|
129
|
+
if (token === void 0 || !await state.isOpen()) return false;
|
|
130
|
+
const session = await store.sessions.findByTokenHash(tokenHash(token));
|
|
131
|
+
const now = Date.now();
|
|
132
|
+
if (session === null || session.stage !== "active" || now >= session.expiresAt || now - session.lastSeenAt >= production.session.idleMinutes * 6e4) return false;
|
|
133
|
+
return await store.accounts.findById(session.accountId) !== null;
|
|
134
|
+
},
|
|
135
|
+
release() {
|
|
136
|
+
if (released) return;
|
|
137
|
+
released = true;
|
|
138
|
+
streamsInstance -= 1;
|
|
139
|
+
const left = (streamsPerSession.get(sessionId) ?? 1) - 1;
|
|
140
|
+
if (left <= 0) streamsPerSession.delete(sessionId);
|
|
141
|
+
else streamsPerSession.set(sessionId, left);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
const routes = {
|
|
146
|
+
...deps.routes,
|
|
147
|
+
mode: "production",
|
|
148
|
+
isDevelopment: () => false,
|
|
149
|
+
instance: deps.instance,
|
|
150
|
+
insights: deps.insights,
|
|
151
|
+
collector: deps.routes.collector ?? deps.capture.collector,
|
|
152
|
+
requests: deps.routes.requests ?? deps.capture.requests,
|
|
153
|
+
explainShape: deps.routes.explainShape ?? ((shapeId) => deps.capture.explain(shapeId)),
|
|
154
|
+
builtInPanels: deps.builtInPanels,
|
|
155
|
+
streamSession
|
|
156
|
+
};
|
|
157
|
+
server.register(async (instance) => {
|
|
158
|
+
instance.addHook("onRequest", async (request, reply) => {
|
|
159
|
+
let open;
|
|
160
|
+
try {
|
|
161
|
+
open = await state.isOpen();
|
|
162
|
+
} catch (error) {
|
|
163
|
+
warn(`The devtools dashboard state could not be read and the dashboard is closed: ${error instanceof Error ? error.message : String(error)}`);
|
|
164
|
+
open = false;
|
|
165
|
+
}
|
|
166
|
+
if (!open) return notFound(request, reply);
|
|
167
|
+
const client = resolveClient(request, production.trustedProxies);
|
|
168
|
+
if (production.requireHttps && client.proto !== "https") return notFound(request, reply);
|
|
169
|
+
if (production.allowedIps.length > 0 && !ipMatches(client.ip, production.allowedIps)) return notFound(request, reply);
|
|
170
|
+
const userAgent = request.headers["user-agent"];
|
|
171
|
+
const expectedOrigin = production.origin ?? `${client.proto}://${client.host}`;
|
|
172
|
+
const meta = {
|
|
173
|
+
ip: client.ip,
|
|
174
|
+
userAgent: typeof userAgent === "string" ? userAgent.slice(0, MAX_USER_AGENT) : null,
|
|
175
|
+
origin: expectedOrigin,
|
|
176
|
+
hostname: client.hostname
|
|
177
|
+
};
|
|
178
|
+
const routeUrl = request.routeOptions.url ?? "";
|
|
179
|
+
const relative = routeUrl.startsWith(prefix) ? routeUrl.slice(prefix.length) : routeUrl;
|
|
180
|
+
const pattern = relative === "" ? "/" : relative;
|
|
181
|
+
const method = request.method;
|
|
182
|
+
const sent = request.originalUrl ?? request.raw.url ?? "";
|
|
183
|
+
if (sent.split("?")[0] === prefix) {
|
|
184
|
+
setDevtoolsRequestContext(request, {
|
|
185
|
+
client,
|
|
186
|
+
meta,
|
|
187
|
+
rule: void 0,
|
|
188
|
+
pattern,
|
|
189
|
+
authenticated: null
|
|
190
|
+
});
|
|
191
|
+
if (method !== "GET" && method !== "HEAD") return notFound(request, reply);
|
|
192
|
+
const search = sent.includes("?") ? `?${sent.split("?").slice(1).join("?")}` : "";
|
|
193
|
+
return reply.redirect(`${prefix}/${search}`, 308);
|
|
194
|
+
}
|
|
195
|
+
const tab = tabOf(pattern);
|
|
196
|
+
if (tab !== void 0 && !enabledTabs.has(tab)) return notFound(request, reply);
|
|
197
|
+
const rule = lookup(method, pattern);
|
|
198
|
+
const access = rule?.access ?? { type: "admin" };
|
|
199
|
+
let authenticated = null;
|
|
200
|
+
if (access.type !== "public") {
|
|
201
|
+
try {
|
|
202
|
+
authenticated = await auth.authenticate(readCookie(request.headers.cookie, cookieName));
|
|
203
|
+
} catch (error) {
|
|
204
|
+
warn(`The devtools session could not be checked and the request was refused: ${error instanceof Error ? error.message : String(error)}`);
|
|
205
|
+
return notFound(request, reply);
|
|
206
|
+
}
|
|
207
|
+
if (authenticated === null || !sessionAccessOk(access, authenticated.stage)) return notFound(request, reply);
|
|
208
|
+
if (access.type === "admin" && authenticated.account.role !== "admin") {
|
|
209
|
+
setDevtoolsRequestContext(request, {
|
|
210
|
+
client,
|
|
211
|
+
meta,
|
|
212
|
+
rule,
|
|
213
|
+
pattern,
|
|
214
|
+
authenticated
|
|
215
|
+
});
|
|
216
|
+
throw new DevtoolsApiError("role.forbidden");
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
setDevtoolsRequestContext(request, {
|
|
220
|
+
client,
|
|
221
|
+
meta,
|
|
222
|
+
rule,
|
|
223
|
+
pattern,
|
|
224
|
+
authenticated
|
|
225
|
+
});
|
|
226
|
+
if (SAFE_METHODS.has(method)) return;
|
|
227
|
+
if (!originAllowed(request, expectedOrigin)) {
|
|
228
|
+
if (authenticated === null) return notFound(request, reply);
|
|
229
|
+
throw new DevtoolsApiError("csrf.invalid");
|
|
230
|
+
}
|
|
231
|
+
if (hasBody(request) && !isJson(request)) throw new DevtoolsApiError("input.invalid");
|
|
232
|
+
if (authenticated !== null) {
|
|
233
|
+
const header = request.headers[DEVTOOLS_CSRF_HEADER];
|
|
234
|
+
if (!auth.verifyCsrf(authenticated, Array.isArray(header) ? header[0] : header)) throw new DevtoolsApiError("csrf.invalid");
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
instance.addHook("onSend", async (request, reply, payload) => {
|
|
238
|
+
if (uniformNotFound.has(request)) return payload;
|
|
239
|
+
for (const name of Object.keys(reply.getHeaders())) if (name.startsWith("access-control-")) reply.removeHeader(name);
|
|
240
|
+
reply.headers(DASHBOARD_HEADERS);
|
|
241
|
+
const pattern = devtoolsRequestContext(request)?.pattern ?? "";
|
|
242
|
+
if (pattern === MAIL_HTML_PATTERN) {
|
|
243
|
+
reply.header("X-Frame-Options", "SAMEORIGIN");
|
|
244
|
+
return payload;
|
|
245
|
+
}
|
|
246
|
+
if (DOCS_PATTERNS.has(pattern)) reply.header("X-Frame-Options", "SAMEORIGIN");
|
|
247
|
+
if (String(reply.getHeader("content-type") ?? "").startsWith("text/html")) reply.header("Content-Security-Policy", DOCS_PATTERNS.has(pattern) ? DOCS_CSP : DASHBOARD_CSP);
|
|
248
|
+
return payload;
|
|
249
|
+
});
|
|
250
|
+
instance.addHook("onResponse", async (request, reply) => {
|
|
251
|
+
const context = devtoolsRequestContext(request);
|
|
252
|
+
const type = context?.rule?.audit;
|
|
253
|
+
if (!context || !type || reply.statusCode < 200 || reply.statusCode > 299) return;
|
|
254
|
+
const params = request.params ?? {};
|
|
255
|
+
const detail = type === "explain.run" ? { shapeId: params.shapeId ?? null } : type === "panel.action" ? {
|
|
256
|
+
panel: context.pattern.split("/")[2] ?? null,
|
|
257
|
+
method: request.method,
|
|
258
|
+
route: context.pattern
|
|
259
|
+
} : {};
|
|
260
|
+
await auth.audit(type, {
|
|
261
|
+
auth: context.authenticated,
|
|
262
|
+
meta: context.meta,
|
|
263
|
+
detail
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
instance.setErrorHandler((error, request, reply) => {
|
|
267
|
+
if (error instanceof DevtoolsApiError) return reply.code(error.statusCode).send(error.toBody());
|
|
268
|
+
const status = error.statusCode;
|
|
269
|
+
if (status !== void 0 && status >= 400 && status < 500) return reply.code(status).send(error.code?.startsWith("FST_ERR_") ? new DevtoolsApiError("input.invalid").toBody() : { error: error.message });
|
|
270
|
+
const ref = createErrorRef();
|
|
271
|
+
deps.warn?.(`Devtools dashboard error ${ref} on ${request.method} ${devtoolsRequestContext(request)?.pattern ?? "(dashboard route)"}: ${error.message}`);
|
|
272
|
+
request.log.error({
|
|
273
|
+
ref,
|
|
274
|
+
err: error
|
|
275
|
+
}, "devtools dashboard error");
|
|
276
|
+
return reply.code(500).send({
|
|
277
|
+
error: DEVTOOLS_ERROR_MESSAGES["server.error"],
|
|
278
|
+
code: "server.error",
|
|
279
|
+
ref
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
registerUiAssets(instance, { notFound });
|
|
283
|
+
registerAuthRoutes(instance, deps);
|
|
284
|
+
instance.get("/api/panels", async () => listPanelInfos(deps.panels, deps.builtInPanels));
|
|
285
|
+
registerRequestsRoutes(instance, routes);
|
|
286
|
+
registerRouteRoutes(instance, routes);
|
|
287
|
+
registerInsightsRoutes(instance, routes);
|
|
288
|
+
registerLogRoutes(instance, routes);
|
|
289
|
+
registerShapeExplainRoute(instance, routes);
|
|
290
|
+
registerPanelRoutes(instance, deps.panels);
|
|
291
|
+
if (enabledTabs.has("mail")) registerMailRoutes(instance, routes);
|
|
292
|
+
if (enabledTabs.has("ai") || enabledTabs.has("agents")) registerAiRoutes(instance, routes);
|
|
293
|
+
if (enabledTabs.has("api")) registerOpenApiRoutes(instance, routes);
|
|
294
|
+
registerStreamRoute(instance, routes);
|
|
295
|
+
}, { prefix });
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
//#endregion
|
|
299
|
+
export { mountProductionDevtools };
|
|
300
|
+
//# sourceMappingURL=mount.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount.mjs","names":[],"sources":["../../../../../../../../../packages/devtools/src/production/http/mount.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport type { FastifyInstance, FastifyReply, FastifyRequest } from \"fastify\";\nimport { listPanelInfos } from \"../../panels\";\nimport { registerAiRoutes } from \"../../server/ai-routes\";\nimport { registerShapeExplainRoute } from \"../../server/explain-route\";\nimport { registerInsightsRoutes } from \"../../server/insights-routes\";\nimport { registerLogRoutes } from \"../../server/log-routes\";\nimport { registerMailRoutes } from \"../../server/mail-routes\";\nimport { registerOpenApiRoutes } from \"../../server/openapi-routes\";\nimport { registerPanelRoutes } from \"../../server/panel-routes\";\nimport { registerRequestsRoutes } from \"../../server/requests-routes\";\nimport { registerRouteRoutes } from \"../../server/route-routes\";\nimport { registerStreamRoute } from \"../../server/stream-route\";\nimport type { DevtoolsStreamSession, MountDevtoolsRoutesDeps } from \"../../server/types\";\nimport { registerUiAssets } from \"../../server/ui-assets\";\nimport type { DevtoolsAuthenticated, DevtoolsRequestMeta } from \"../auth/types\";\nimport { DevtoolsApiError, createErrorRef, DEVTOOLS_ERROR_MESSAGES } from \"../errors\";\nimport { createAccessLookup, productionRouteAccess } from \"./access\";\nimport { registerAuthRoutes } from \"./auth-routes\";\nimport { resolveClient } from \"./client\";\nimport { setDevtoolsRequestContext, devtoolsRequestContext } from \"./context\";\nimport { readCookie, sessionCookieName } from \"./cookie\";\nimport { DASHBOARD_CSP, DASHBOARD_HEADERS, DOCS_CSP } from \"./headers\";\nimport { DEVTOOLS_CSRF_HEADER } from \"./constants\";\nimport { ipMatches } from \"./ip\";\nimport type { DevtoolsRouteAccess, MountProductionDevtoolsDeps } from \"./types\";\n\n/** Open live streams a session may hold, and an instance may serve. */\nconst MAX_STREAMS_PER_SESSION = 3;\nconst MAX_STREAMS_PER_INSTANCE = 50;\n\nconst MAX_USER_AGENT = 200;\n\n/** Methods that never change state. */\nconst SAFE_METHODS = new Set([\"GET\", \"HEAD\", \"OPTIONS\"]);\n\n/** The routes of the opt-in API documentation pages (they keep a CSP of their own). */\nconst DOCS_PATTERNS = new Set([\"/docs\", \"/docs/swagger\"]);\n\n/** The mail preview's HTML: framed by the dashboard, with a policy of its own. */\nconst MAIL_HTML_PATTERN = \"/api/mails/:id/html\";\n\n/** Which tab a route belongs to: a route of a tab that is off answers the uniform 404. */\nconst TAB_OF_ROUTE: readonly (readonly [prefix: string, tab: string])[] = [\n [\"/api/resources\", \"resources\"],\n [\"/api/queries\", \"queries\"],\n [\"/api/routes/stats\", \"routes\"],\n [\"/api/routes\", \"routes\"],\n [\"/api/health\", \"health\"],\n [\"/api/errors\", \"errors\"],\n [\"/api/jobs\", \"jobs\"],\n [\"/api/logs\", \"logs\"],\n [\"/api/requests\", \"requests\"],\n [\"/api/mails\", \"mail\"],\n [\"/api/ai/agent-runs\", \"agents\"],\n [\"/api/ai\", \"ai\"],\n [\"/api/openapi.json\", \"api\"],\n [\"/api/postman.json\", \"api\"],\n [\"/docs\", \"api\"],\n];\n\nfunction tabOf(pattern: string): string | undefined {\n return TAB_OF_ROUTE.find(\n ([prefix]) => pattern === prefix || pattern.startsWith(`${prefix}/`),\n )?.[1];\n}\n\nfunction tokenHash(token: string): string {\n return createHash(\"sha256\").update(token).digest(\"hex\");\n}\n\n/** Requests that were answered with the uniform 404: they get none of the dashboard's headers. */\nconst uniformNotFound = new WeakSet<FastifyRequest>();\n\n/**\n * The origin the browser must send for an unsafe request: `production.origin`,\n * else the scheme and host the request was addressed to.\n */\nfunction originAllowed(request: FastifyRequest, expected: string): boolean {\n const origin = request.headers.origin;\n const site = request.headers[\"sec-fetch-site\"];\n\n if (site !== undefined && site !== \"same-origin\") return false;\n\n if (origin !== undefined) return origin.toLowerCase() === expected.toLowerCase();\n\n // No Origin header: a same-origin fetch from an older browser. Accept it only with the fetch metadata that proves it.\n return site === \"same-origin\";\n}\n\nfunction hasBody(request: FastifyRequest): boolean {\n const length = request.headers[\"content-length\"];\n\n return (\n (length !== undefined && length !== \"0\") || request.headers[\"transfer-encoding\"] !== undefined\n );\n}\n\nfunction isJson(request: FastifyRequest): boolean {\n return /^application\\/json\\s*(;|$)/i.test(request.headers[\"content-type\"] ?? \"\");\n}\n\nfunction sessionAccessOk(\n access: Exclude<DevtoolsRouteAccess, { type: \"public\" }>,\n stage: string,\n): boolean {\n if (stage === \"active\") return true;\n\n return access.type === \"pending\" && (access.stages as readonly string[]).includes(stage);\n}\n\n/**\n * Mounts the production monitor under `production.path` in one encapsulated\n * Fastify context: the gate (uniform 404, HTTPS, allowed IPs, open state),\n * session and role checks from the access table, CSRF and origin checks,\n * security headers and CORS stripping, the auth/account/admin routes, and\n * the shared data routes of the enabled tabs.\n */\nexport function mountProductionDevtools(\n server: FastifyInstance,\n deps: MountProductionDevtoolsDeps,\n): void {\n const { production, auth, state, store } = deps;\n const prefix = production.path;\n const cookieName = sessionCookieName(production.requireHttps);\n const enabledTabs = new Set(deps.builtInPanels);\n const lookup = createAccessLookup(productionRouteAccess(deps.panels.map((panel) => panel.id)));\n const streamsPerSession = new Map<string, number>();\n let streamsInstance = 0;\n let lastWarningAt = 0;\n\n const warn = (message: string): void => {\n // At most one line a minute: a database outage must not flood the log.\n const now = Date.now();\n\n if (now - lastWarningAt < 60_000) return;\n\n lastWarningAt = now;\n deps.warn?.(message);\n };\n\n const notFound = (request: FastifyRequest, reply: FastifyReply): FastifyReply => {\n uniformNotFound.add(request);\n\n // The app's own not-found handler answers, so the reply is the one any unknown URL gets.\n reply.callNotFound();\n\n // Returning the reply is what stops an async hook's lifecycle.\n return reply;\n };\n\n const streamSession = async (request: FastifyRequest): Promise<DevtoolsStreamSession> => {\n const authenticated = devtoolsRequestContext(request)?.authenticated;\n\n if (!authenticated) throw new Error(\"A dashboard stream was opened without a session.\");\n\n const sessionId = authenticated.session.id;\n const token = readCookie(request.headers.cookie, cookieName);\n const open = streamsPerSession.get(sessionId) ?? 0;\n\n if (open >= MAX_STREAMS_PER_SESSION || streamsInstance >= MAX_STREAMS_PER_INSTANCE) {\n throw new DevtoolsApiError(\"stream.too-many\");\n }\n\n streamsPerSession.set(sessionId, open + 1);\n streamsInstance += 1;\n\n let released = false;\n\n return {\n role: authenticated.account.role,\n logLevels: production.logLevels,\n headers: DASHBOARD_HEADERS,\n // Reads the session without touching `lastSeenAt`: a stream left open must not keep the session alive.\n async revalidate() {\n if (token === undefined || !(await state.isOpen())) return false;\n\n const session = await store.sessions.findByTokenHash(tokenHash(token));\n const now = Date.now();\n\n if (\n session === null ||\n session.stage !== \"active\" ||\n now >= session.expiresAt ||\n now - session.lastSeenAt >= production.session.idleMinutes * 60_000\n ) {\n return false;\n }\n\n return (await store.accounts.findById(session.accountId)) !== null;\n },\n release() {\n if (released) return;\n\n released = true;\n streamsInstance -= 1;\n\n const left = (streamsPerSession.get(sessionId) ?? 1) - 1;\n\n if (left <= 0) streamsPerSession.delete(sessionId);\n else streamsPerSession.set(sessionId, left);\n },\n };\n };\n\n // The route deps the shared route files read: the development deps, completed.\n const routes: MountDevtoolsRoutesDeps = {\n ...deps.routes,\n mode: \"production\",\n isDevelopment: () => false,\n instance: deps.instance,\n insights: deps.insights,\n collector: deps.routes.collector ?? deps.capture.collector,\n requests: deps.routes.requests ?? deps.capture.requests,\n explainShape: deps.routes.explainShape ?? ((shapeId) => deps.capture.explain(shapeId)),\n builtInPanels: deps.builtInPanels,\n streamSession,\n };\n\n server.register(\n async (instance) => {\n // ---- The gate -------------------------------------------------------\n instance.addHook(\"onRequest\", async (request, reply) => {\n let open: boolean;\n\n try {\n open = await state.isOpen();\n } catch (error) {\n // Fail closed: when the state cannot be read the dashboard does not answer.\n warn(\n `The devtools dashboard state could not be read and the dashboard is closed: ${error instanceof Error ? error.message : String(error)}`,\n );\n open = false;\n }\n\n if (!open) return notFound(request, reply);\n\n const client = resolveClient(request, production.trustedProxies);\n\n if (production.requireHttps && client.proto !== \"https\") return notFound(request, reply);\n\n if (production.allowedIps.length > 0 && !ipMatches(client.ip, production.allowedIps)) {\n return notFound(request, reply);\n }\n\n const userAgent = request.headers[\"user-agent\"];\n const expectedOrigin = production.origin ?? `${client.proto}://${client.host}`;\n const meta: DevtoolsRequestMeta = {\n ip: client.ip,\n userAgent: typeof userAgent === \"string\" ? userAgent.slice(0, MAX_USER_AGENT) : null,\n origin: expectedOrigin,\n hostname: client.hostname,\n };\n\n const routeUrl = request.routeOptions.url ?? \"\";\n const relative = routeUrl.startsWith(prefix) ? routeUrl.slice(prefix.length) : routeUrl;\n // The shell is registered once for both `<path>` and `<path>/`.\n const pattern = relative === \"\" ? \"/\" : relative;\n const method = request.method;\n\n // The bare path (no trailing slash) redirects to the shell's address. The\n // address as sent: core's server drops a trailing slash before routing,\n // so the rewritten URL of `<path>/` is the bare path too.\n const sent = request.originalUrl ?? request.raw.url ?? \"\";\n\n if (sent.split(\"?\")[0] === prefix) {\n setDevtoolsRequestContext(request, {\n client,\n meta,\n rule: undefined,\n pattern,\n authenticated: null,\n });\n\n if (method !== \"GET\" && method !== \"HEAD\") return notFound(request, reply);\n\n const search = sent.includes(\"?\") ? `?${sent.split(\"?\").slice(1).join(\"?\")}` : \"\";\n\n return reply.redirect(`${prefix}/${search}`, 308);\n }\n\n const tab = tabOf(pattern);\n\n if (tab !== undefined && !enabledTabs.has(tab)) return notFound(request, reply);\n\n const rule = lookup(method, pattern);\n const access: DevtoolsRouteAccess = rule?.access ?? { type: \"admin\" };\n let authenticated: DevtoolsAuthenticated | null = null;\n\n if (access.type !== \"public\") {\n try {\n authenticated = await auth.authenticate(readCookie(request.headers.cookie, cookieName));\n } catch (error) {\n warn(\n `The devtools session could not be checked and the request was refused: ${error instanceof Error ? error.message : String(error)}`,\n );\n\n return notFound(request, reply);\n }\n\n if (authenticated === null || !sessionAccessOk(access, authenticated.stage)) {\n return notFound(request, reply);\n }\n\n if (access.type === \"admin\" && authenticated.account.role !== \"admin\") {\n setDevtoolsRequestContext(request, { client, meta, rule, pattern, authenticated });\n throw new DevtoolsApiError(\"role.forbidden\");\n }\n }\n\n setDevtoolsRequestContext(request, { client, meta, rule, pattern, authenticated });\n\n if (SAFE_METHODS.has(method)) return;\n\n if (!originAllowed(request, expectedOrigin)) {\n if (authenticated === null) return notFound(request, reply);\n\n throw new DevtoolsApiError(\"csrf.invalid\");\n }\n\n if (hasBody(request) && !isJson(request)) throw new DevtoolsApiError(\"input.invalid\");\n\n if (authenticated !== null) {\n const header = request.headers[DEVTOOLS_CSRF_HEADER];\n\n if (!auth.verifyCsrf(authenticated, Array.isArray(header) ? header[0] : header)) {\n throw new DevtoolsApiError(\"csrf.invalid\");\n }\n }\n });\n\n // ---- Headers --------------------------------------------------------\n instance.addHook(\"onSend\", async (request, reply, payload) => {\n // The uniform 404 must look like any other 404 of the app.\n if (uniformNotFound.has(request)) return payload;\n\n for (const name of Object.keys(reply.getHeaders())) {\n if (name.startsWith(\"access-control-\")) reply.removeHeader(name);\n }\n\n reply.headers(DASHBOARD_HEADERS);\n\n const pattern = devtoolsRequestContext(request)?.pattern ?? \"\";\n\n // The mail preview is the one page the dashboard frames, from its own origin, and it sends its own policy.\n if (pattern === MAIL_HTML_PATTERN) {\n reply.header(\"X-Frame-Options\", \"SAMEORIGIN\");\n\n return payload;\n }\n\n // The API docs pages are shown in a frame by the dashboard's API tab.\n if (DOCS_PATTERNS.has(pattern)) reply.header(\"X-Frame-Options\", \"SAMEORIGIN\");\n\n // Always the dashboard's policy: the app's own (core's security headers set one on every response) is not\n // written for this page and must not replace it.\n if (String(reply.getHeader(\"content-type\") ?? \"\").startsWith(\"text/html\")) {\n reply.header(\n \"Content-Security-Policy\",\n DOCS_PATTERNS.has(pattern) ? DOCS_CSP : DASHBOARD_CSP,\n );\n }\n\n return payload;\n });\n\n // ---- Audit ----------------------------------------------------------\n instance.addHook(\"onResponse\", async (request, reply) => {\n const context = devtoolsRequestContext(request);\n const type = context?.rule?.audit;\n\n if (!context || !type || reply.statusCode < 200 || reply.statusCode > 299) return;\n\n const params = (request.params ?? {}) as Record<string, string | undefined>;\n const detail: Record<string, string | number | boolean | null> =\n type === \"explain.run\"\n ? { shapeId: params.shapeId ?? null }\n : type === \"panel.action\"\n ? {\n panel: context.pattern.split(\"/\")[2] ?? null,\n method: request.method,\n route: context.pattern,\n }\n : {};\n\n await auth.audit(type, { auth: context.authenticated, meta: context.meta, detail });\n });\n\n // ---- Errors ---------------------------------------------------------\n instance.setErrorHandler(\n (error: Error & { statusCode?: number; code?: string }, request, reply) => {\n if (error instanceof DevtoolsApiError) {\n return reply.code(error.statusCode).send(error.toBody());\n }\n\n const status = error.statusCode;\n\n // The request itself was wrong (bad JSON, too large): say so in the dashboard's own shape.\n if (status !== undefined && status >= 400 && status < 500) {\n return reply\n .code(status)\n .send(\n error.code?.startsWith(\"FST_ERR_\")\n ? new DevtoolsApiError(\"input.invalid\").toBody()\n : { error: error.message },\n );\n }\n\n const ref = createErrorRef();\n\n // Never rate limited: the reference the browser shows must always be findable in the log. The route is\n // written relative to the dashboard path, which never reaches the log.\n deps.warn?.(\n `Devtools dashboard error ${ref} on ${request.method} ${devtoolsRequestContext(request)?.pattern ?? \"(dashboard route)\"}: ${error.message}`,\n );\n request.log.error({ ref, err: error }, \"devtools dashboard error\");\n\n return reply.code(500).send({\n error: DEVTOOLS_ERROR_MESSAGES[\"server.error\"],\n code: \"server.error\",\n ref,\n });\n },\n );\n\n // ---- Routes ---------------------------------------------------------\n registerUiAssets(instance, { notFound });\n registerAuthRoutes(instance, deps);\n\n instance.get(\"/api/panels\", async () => listPanelInfos(deps.panels, deps.builtInPanels));\n\n registerRequestsRoutes(instance, routes);\n registerRouteRoutes(instance, routes);\n registerInsightsRoutes(instance, routes);\n registerLogRoutes(instance, routes);\n registerShapeExplainRoute(instance, routes);\n registerPanelRoutes(instance, deps.panels);\n\n if (enabledTabs.has(\"mail\")) registerMailRoutes(instance, routes);\n if (enabledTabs.has(\"ai\") || enabledTabs.has(\"agents\")) registerAiRoutes(instance, routes);\n if (enabledTabs.has(\"api\")) registerOpenApiRoutes(instance, routes);\n\n registerStreamRoute(instance, routes);\n },\n { prefix },\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAA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AQ,OAAO,GAAG,uBAAuB,OAAO,CAAC,EAAE,WAAW,oBAAoB,IAAI,MAAM,SACpI;GACA,QAAQ,IAAI,MAAM;IAAE;IAAK,KAAK;GAAM,GAAG,0BAA0B;GAEjE,OAAO,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK;IAC1B,OAAO,wBAAwB;IAC/B,MAAM;IACN;GACF,CAAC;EACH,CACF;EAGA,iBAAiB,UAAU,EAAE,SAAS,CAAC;EACvC,mBAAmB,UAAU,IAAI;EAEjC,SAAS,IAAI,eAAe,YAAY,eAAe,KAAK,QAAQ,KAAK,aAAa,CAAC;EAEvF,uBAAuB,UAAU,MAAM;EACvC,oBAAoB,UAAU,MAAM;EACpC,uBAAuB,UAAU,MAAM;EACvC,kBAAkB,UAAU,MAAM;EAClC,0BAA0B,UAAU,MAAM;EAC1C,oBAAoB,UAAU,KAAK,MAAM;EAEzC,IAAI,YAAY,IAAI,MAAM,GAAG,mBAAmB,UAAU,MAAM;EAChE,IAAI,YAAY,IAAI,IAAI,KAAK,YAAY,IAAI,QAAQ,GAAG,iBAAiB,UAAU,MAAM;EACzF,IAAI,YAAY,IAAI,KAAK,GAAG,sBAAsB,UAAU,MAAM;EAElE,oBAAoB,UAAU,MAAM;CACtC,GACA,EAAE,OAAO,CACX;AACF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
|
|
3
|
+
//#region ../../packages/devtools/src/production/http/state.ts
|
|
4
|
+
/** SHA-256 hex of a dashboard path: what `disabledPathHash` holds. */
|
|
5
|
+
function hashDashboardPath(path) {
|
|
6
|
+
return createHash("sha256").update(path).digest("hex");
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The open/closed state with a `ttlMs` cache (default 5000). Open means the
|
|
10
|
+
* dashboard is not disabled for this path and not locked. A failed read is
|
|
11
|
+
* not cached and rejects, so the caller can fail closed.
|
|
12
|
+
*/
|
|
13
|
+
function createDashboardState(store, path, options = {}) {
|
|
14
|
+
const ttlMs = options.ttlMs ?? 5e3;
|
|
15
|
+
const now = options.now ?? Date.now;
|
|
16
|
+
const pathHash = hashDashboardPath(path);
|
|
17
|
+
let cached = null;
|
|
18
|
+
let pending = null;
|
|
19
|
+
let generation = 0;
|
|
20
|
+
const read = async () => {
|
|
21
|
+
const started = generation;
|
|
22
|
+
const state = await store.state.read();
|
|
23
|
+
const at = now();
|
|
24
|
+
const disabled = state.disabled && state.disabledPathHash === pathHash;
|
|
25
|
+
const locked = state.lockedUntil !== null && state.lockedUntil > at;
|
|
26
|
+
const open = !disabled && !locked;
|
|
27
|
+
if (started === generation) cached = {
|
|
28
|
+
open,
|
|
29
|
+
at
|
|
30
|
+
};
|
|
31
|
+
return open;
|
|
32
|
+
};
|
|
33
|
+
return {
|
|
34
|
+
async isOpen() {
|
|
35
|
+
if (cached !== null && now() - cached.at < ttlMs) return cached.open;
|
|
36
|
+
if (pending === null) {
|
|
37
|
+
const current = read().finally(() => {
|
|
38
|
+
if (pending === current) pending = null;
|
|
39
|
+
});
|
|
40
|
+
pending = current;
|
|
41
|
+
}
|
|
42
|
+
return pending;
|
|
43
|
+
},
|
|
44
|
+
invalidate() {
|
|
45
|
+
generation += 1;
|
|
46
|
+
cached = null;
|
|
47
|
+
pending = null;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
export { createDashboardState, hashDashboardPath };
|
|
54
|
+
//# sourceMappingURL=state.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.mjs","names":[],"sources":["../../../../../../../../../packages/devtools/src/production/http/state.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport type { DevtoolsStore } from \"../store/types\";\nimport type { DevtoolsDashboardState } from \"./types\";\n\n/** SHA-256 hex of a dashboard path: what `disabledPathHash` holds. */\nexport function hashDashboardPath(path: string): string {\n return createHash(\"sha256\").update(path).digest(\"hex\");\n}\n\n/**\n * The open/closed state with a `ttlMs` cache (default 5000). Open means the\n * dashboard is not disabled for this path and not locked. A failed read is\n * not cached and rejects, so the caller can fail closed.\n */\nexport function createDashboardState(\n store: DevtoolsStore,\n path: string,\n options: { ttlMs?: number; now?: () => number } = {},\n): DevtoolsDashboardState {\n const ttlMs = options.ttlMs ?? 5000;\n const now = options.now ?? Date.now;\n const pathHash = hashDashboardPath(path);\n let cached: { open: boolean; at: number } | null = null;\n let pending: Promise<boolean> | null = null;\n let generation = 0;\n\n const read = async (): Promise<boolean> => {\n const started = generation;\n const state = await store.state.read();\n const at = now();\n const disabled = state.disabled && state.disabledPathHash === pathHash;\n const locked = state.lockedUntil !== null && state.lockedUntil > at;\n const open = !disabled && !locked;\n\n if (started === generation) cached = { open, at };\n\n return open;\n };\n\n return {\n async isOpen() {\n if (cached !== null && now() - cached.at < ttlMs) return cached.open;\n\n if (pending === null) {\n const current = read().finally(() => {\n if (pending === current) pending = null;\n });\n\n pending = current;\n }\n\n return pending;\n },\n invalidate() {\n generation += 1;\n cached = null;\n pending = null;\n },\n };\n}\n"],"mappings":";;;;AAKA,SAAgB,kBAAkB,MAAsB;CACtD,OAAO,WAAW,QAAQ,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,KAAK;AACvD;;;;;;AAOA,SAAgB,qBACd,OACA,MACA,UAAkD,CAAC,GAC3B;CACxB,MAAM,QAAQ,QAAQ,SAAS;CAC/B,MAAM,MAAM,QAAQ,OAAO,KAAK;CAChC,MAAM,WAAW,kBAAkB,IAAI;CACvC,IAAI,SAA+C;CACnD,IAAI,UAAmC;CACvC,IAAI,aAAa;CAEjB,MAAM,OAAO,YAA8B;EACzC,MAAM,UAAU;EAChB,MAAM,QAAQ,MAAM,MAAM,MAAM,KAAK;EACrC,MAAM,KAAK,IAAI;EACf,MAAM,WAAW,MAAM,YAAY,MAAM,qBAAqB;EAC9D,MAAM,SAAS,MAAM,gBAAgB,QAAQ,MAAM,cAAc;EACjE,MAAM,OAAO,CAAC,YAAY,CAAC;EAE3B,IAAI,YAAY,YAAY,SAAS;GAAE;GAAM;EAAG;EAEhD,OAAO;CACT;CAEA,OAAO;EACL,MAAM,SAAS;GACb,IAAI,WAAW,QAAQ,IAAI,IAAI,OAAO,KAAK,OAAO,OAAO,OAAO;GAEhE,IAAI,YAAY,MAAM;IACpB,MAAM,UAAU,KAAK,CAAC,CAAC,cAAc;KACnC,IAAI,YAAY,SAAS,UAAU;IACrC,CAAC;IAED,UAAU;GACZ;GAEA,OAAO;EACT;EACA,aAAa;GACX,cAAc;GACd,SAAS;GACT,UAAU;EACZ;CACF;AACF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DEVTOOLS_BUILT_IN_PANELS, DEVTOOLS_FAILURE_AUDIT_TYPES, DEVTOOLS_LATENCY_BUCKETS_MS, DevtoolsAccountView, DevtoolsApiErrorBody, DevtoolsAuditEntry, DevtoolsAuditType, DevtoolsAuthStepResult, DevtoolsBuiltInPanelId, DevtoolsCaptureCounters, DevtoolsCreatedInvite, DevtoolsErrorCode, DevtoolsErrorGroup, DevtoolsErrorsView, DevtoolsExplainResult, DevtoolsHealthReport, DevtoolsHealthView, DevtoolsHistogram, DevtoolsInstanceInfo, DevtoolsInstanceReport, DevtoolsInstancesView, DevtoolsInviteView, DevtoolsJobsReport, DevtoolsJobsView, DevtoolsLogRow, DevtoolsLoginInput, DevtoolsLogsView, DevtoolsMode, DevtoolsPanelInfo, DevtoolsPasswordSource, DevtoolsQueryShapeRow, DevtoolsQueryShapeStats, DevtoolsQueryStatsView, DevtoolsRecoveryCodes, DevtoolsReportLogEntry, DevtoolsResourcePoint, DevtoolsResourceSnapshot, DevtoolsResourcesView, DevtoolsRole, DevtoolsRoutePhaseStats, DevtoolsRouteStats, DevtoolsRouteStatsRow, DevtoolsRouteStatsView, DevtoolsSampleDetail, DevtoolsSampleQuery, DevtoolsSampleSummary, DevtoolsScheduleInfo, DevtoolsSessionInfo, DevtoolsSessionStage, DevtoolsSessionView, DevtoolsTotpEnrolment, DevtoolsUserListView } from "./contracts.mjs";
|
|
2
|
+
import { registerDevtoolsCommands } from "./cli/index.mjs";
|
|
3
|
+
import { DEVTOOLS_CONFIG_CODES, DevtoolsConfigCode, DevtoolsProductionConfigError } from "./errors.mjs";
|
|
4
|
+
import { devtoolsMigrations } from "./store/migrations.mjs";
|
|
5
|
+
import { ResolvedDevtoolsProductionOptions } from "./options.mjs";
|
|
6
|
+
export { type DEVTOOLS_BUILT_IN_PANELS, DEVTOOLS_CONFIG_CODES, type DEVTOOLS_FAILURE_AUDIT_TYPES, type DEVTOOLS_LATENCY_BUCKETS_MS, type DevtoolsAccountView, type DevtoolsApiErrorBody, type DevtoolsAuditEntry, type DevtoolsAuditType, type DevtoolsAuthStepResult, type DevtoolsBuiltInPanelId, type DevtoolsCaptureCounters, type DevtoolsConfigCode, type DevtoolsCreatedInvite, type DevtoolsErrorCode, type DevtoolsErrorGroup, type DevtoolsErrorsView, type DevtoolsExplainResult, type DevtoolsHealthReport, type DevtoolsHealthView, type DevtoolsHistogram, type DevtoolsInstanceInfo, type DevtoolsInstanceReport, type DevtoolsInstancesView, type DevtoolsInviteView, type DevtoolsJobsReport, type DevtoolsJobsView, type DevtoolsLogRow, type DevtoolsLoginInput, type DevtoolsLogsView, type DevtoolsMode, type DevtoolsPanelInfo, type DevtoolsPasswordSource, DevtoolsProductionConfigError, type DevtoolsQueryShapeRow, type DevtoolsQueryShapeStats, type DevtoolsQueryStatsView, type DevtoolsRecoveryCodes, type DevtoolsReportLogEntry, type DevtoolsResourcePoint, type DevtoolsResourceSnapshot, type DevtoolsResourcesView, type DevtoolsRole, type DevtoolsRoutePhaseStats, type DevtoolsRouteStats, type DevtoolsRouteStatsRow, type DevtoolsRouteStatsView, type DevtoolsSampleDetail, type DevtoolsSampleQuery, type DevtoolsSampleSummary, type DevtoolsScheduleInfo, type DevtoolsSessionInfo, type DevtoolsSessionStage, type DevtoolsSessionView, type DevtoolsTotpEnrolment, type DevtoolsUserListView, type ResolvedDevtoolsProductionOptions, devtoolsMigrations, registerDevtoolsCommands };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DEVTOOLS_CONFIG_CODES, DevtoolsProductionConfigError } from "./errors.mjs";
|
|
2
|
+
import { registerDevtoolsCommands } from "./cli/index.mjs";
|
|
3
|
+
import { devtoolsMigrations } from "./store/migrations.mjs";
|
|
4
|
+
|
|
5
|
+
export { DEVTOOLS_CONFIG_CODES, DevtoolsProductionConfigError, devtoolsMigrations, registerDevtoolsCommands };
|