@warlock.js/devtools 5.56.0 → 5.58.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 +31 -0
- package/README.md +3 -0
- package/cjs/{auth-DzU0gHDG.cjs → auth-DV2GA1A9.cjs} +33 -403
- package/cjs/auth-DV2GA1A9.cjs.map +1 -0
- package/cjs/{boot-BQi0Etor.cjs → boot-CyeHPFtk.cjs} +14 -12
- package/cjs/boot-CyeHPFtk.cjs.map +1 -0
- package/cjs/{capture-CqIiaznN.cjs → capture-DcyBhdqw.cjs} +3 -3
- package/cjs/{capture-CqIiaznN.cjs.map → capture-DcyBhdqw.cjs.map} +1 -1
- package/cjs/{cascade-store-pHjKeSFm.cjs → cascade-store-DEGxAFDI.cjs} +141 -4
- package/cjs/cascade-store-DEGxAFDI.cjs.map +1 -0
- package/cjs/{contracts-CVmplkNb.cjs → contracts-CDuY-ahl.cjs} +6 -2
- package/cjs/{contracts-CVmplkNb.cjs.map → contracts-CDuY-ahl.cjs.map} +1 -1
- package/cjs/{errors-CyZp5yS-.cjs → errors-DEqdWaqm.cjs} +3 -1
- package/cjs/{errors-CyZp5yS-.cjs.map → errors-DEqdWaqm.cjs.map} +1 -1
- package/cjs/helpers-7k_Q-abk.cjs +436 -0
- package/cjs/helpers-7k_Q-abk.cjs.map +1 -0
- package/cjs/{histogram-BaI-PnCv.cjs → histogram-BRV5eHcp.cjs} +2 -2
- package/cjs/{histogram-BaI-PnCv.cjs.map → histogram-BRV5eHcp.cjs.map} +1 -1
- package/cjs/{http-CabcUwBx.cjs → http-XNLYU2vS.cjs} +517 -28
- package/cjs/http-XNLYU2vS.cjs.map +1 -0
- package/cjs/index.cjs +2 -1
- package/cjs/{insights-BKtqxdnP.cjs → insights-BBZnUpWO.cjs} +4 -3
- package/cjs/{insights-BKtqxdnP.cjs.map → insights-BBZnUpWO.cjs.map} +1 -1
- package/cjs/{migrations-w7GMsrQw.cjs → migrations-DTTzCNpR.cjs} +38 -3
- package/cjs/migrations-DTTzCNpR.cjs.map +1 -0
- package/cjs/{options-CWqFC5__.cjs → options-CHhmQJic.cjs} +16 -4
- package/cjs/options-CHhmQJic.cjs.map +1 -0
- package/cjs/{panels-B0dAfGbJ.cjs → panels-CHd20RK5.cjs} +97 -10
- package/cjs/panels-CHd20RK5.cjs.map +1 -0
- package/cjs/production/index.cjs +4 -4
- package/cjs/{server-B6xdeKS8.cjs → server-C8JfggQU.cjs} +5 -4
- package/cjs/server-C8JfggQU.cjs.map +1 -0
- package/cjs/{src-Ce-3Lniv.cjs → src-DjOUdhKc.cjs} +96 -10
- package/cjs/src-DjOUdhKc.cjs.map +1 -0
- package/cjs/{store-aq207T8v.cjs → store-C06KO_A1.cjs} +2 -2
- package/cjs/{stream-route-BGJa-zQu.cjs → stream-route-D4k-sJvW.cjs} +70 -9
- package/cjs/stream-route-D4k-sJvW.cjs.map +1 -0
- package/esm/devtools-connector.d.mts.map +1 -1
- package/esm/devtools-connector.mjs +10 -3
- package/esm/devtools-connector.mjs.map +1 -1
- package/esm/index.d.mts +4 -3
- package/esm/index.mjs +2 -1
- package/esm/panel-errors.mjs +33 -0
- package/esm/panel-errors.mjs.map +1 -0
- 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 +96 -9
- package/esm/panels.mjs.map +1 -1
- package/esm/production/auth/service.mjs +4 -2
- package/esm/production/auth/service.mjs.map +1 -1
- package/esm/production/boot.mjs +4 -2
- package/esm/production/boot.mjs.map +1 -1
- package/esm/production/contracts.d.mts +68 -2
- package/esm/production/contracts.d.mts.map +1 -1
- package/esm/production/contracts.mjs +5 -1
- package/esm/production/contracts.mjs.map +1 -1
- package/esm/production/errors.mjs +2 -0
- package/esm/production/errors.mjs.map +1 -1
- package/esm/production/http/access.mjs +6 -2
- package/esm/production/http/access.mjs.map +1 -1
- package/esm/production/http/constants.mjs +7 -1
- package/esm/production/http/constants.mjs.map +1 -1
- package/esm/production/http/context.mjs.map +1 -1
- package/esm/production/http/cookie.mjs +23 -2
- package/esm/production/http/cookie.mjs.map +1 -1
- package/esm/production/http/mount.mjs +25 -3
- package/esm/production/http/mount.mjs.map +1 -1
- package/esm/production/http/share-session.mjs +114 -0
- package/esm/production/http/share-session.mjs.map +1 -0
- package/esm/production/http/share.mjs +339 -0
- package/esm/production/http/share.mjs.map +1 -0
- package/esm/production/index.d.mts +2 -2
- package/esm/production/insights/writer.mjs +2 -1
- package/esm/production/insights/writer.mjs.map +1 -1
- package/esm/production/options.d.mts +5 -0
- package/esm/production/options.d.mts.map +1 -1
- package/esm/production/options.mjs +14 -2
- package/esm/production/options.mjs.map +1 -1
- package/esm/production/store/cascade-store.mjs +49 -2
- package/esm/production/store/cascade-store.mjs.map +1 -1
- package/esm/production/store/mapping.mjs +29 -1
- package/esm/production/store/mapping.mjs.map +1 -1
- package/esm/production/store/memory-store.mjs +62 -0
- package/esm/production/store/memory-store.mjs.map +1 -1
- package/esm/production/store/migrations.d.mts +2 -1
- package/esm/production/store/migrations.d.mts.map +1 -1
- package/esm/production/store/migrations.mjs +5 -2
- package/esm/production/store/migrations.mjs.map +1 -1
- package/esm/production/store/models/index.mjs +3 -1
- package/esm/production/store/models/share.migration.mjs +27 -0
- package/esm/production/store/models/share.migration.mjs.map +1 -0
- package/esm/production/store/models/share.model.mjs +13 -0
- package/esm/production/store/models/share.model.mjs.map +1 -0
- package/esm/server/panel-files.mjs +35 -0
- package/esm/server/panel-files.mjs.map +1 -0
- package/esm/server/panel-routes.mjs +27 -7
- package/esm/server/panel-routes.mjs.map +1 -1
- package/esm/server/session-routes.mjs +2 -1
- package/esm/server/session-routes.mjs.map +1 -1
- package/esm/types.d.mts +87 -4
- package/esm/types.d.mts.map +1 -1
- package/llms-full.txt +41 -4
- package/package.json +8 -8
- package/skills/SKILL.md +41 -4
- package/ui/dashboard/assets/app.css +1 -1
- package/ui/dashboard/assets/app.js +16 -16
- package/ui/dashboard/build-info.json +10 -10
- package/ui/dashboard/index.html +1 -0
- package/ui/panels/processes.js +12 -3
- package/cjs/auth-DzU0gHDG.cjs.map +0 -1
- package/cjs/boot-BQi0Etor.cjs.map +0 -1
- package/cjs/cascade-store-pHjKeSFm.cjs.map +0 -1
- package/cjs/http-CabcUwBx.cjs.map +0 -1
- package/cjs/migrations-w7GMsrQw.cjs.map +0 -1
- package/cjs/options-CWqFC5__.cjs.map +0 -1
- package/cjs/panels-B0dAfGbJ.cjs.map +0 -1
- package/cjs/server-B6xdeKS8.cjs.map +0 -1
- package/cjs/src-Ce-3Lniv.cjs.map +0 -1
- package/cjs/stream-route-BGJa-zQu.cjs.map +0 -1
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
let node_crypto = require("node:crypto");
|
|
2
|
+
|
|
3
|
+
//#region ../../packages/devtools/src/production/auth/common-passwords.ts
|
|
4
|
+
/**
|
|
5
|
+
* Passwords the monitor refuses (compared lower-cased). Short entries are
|
|
6
|
+
* left out: the length rule already refuses them.
|
|
7
|
+
*/
|
|
8
|
+
const COMMON_PASSWORDS = /* @__PURE__ */ new Set([
|
|
9
|
+
"password",
|
|
10
|
+
"password1",
|
|
11
|
+
"password12",
|
|
12
|
+
"password123",
|
|
13
|
+
"password1234",
|
|
14
|
+
"passw0rd",
|
|
15
|
+
"p@ssw0rd",
|
|
16
|
+
"p@ssword",
|
|
17
|
+
"password!",
|
|
18
|
+
"password1!",
|
|
19
|
+
"password2",
|
|
20
|
+
"password3",
|
|
21
|
+
"password01",
|
|
22
|
+
"password11",
|
|
23
|
+
"password99",
|
|
24
|
+
"pa55word",
|
|
25
|
+
"pa$$word",
|
|
26
|
+
"12345678",
|
|
27
|
+
"123456789",
|
|
28
|
+
"1234567890",
|
|
29
|
+
"12345678910",
|
|
30
|
+
"123123123",
|
|
31
|
+
"1234qwer",
|
|
32
|
+
"1q2w3e4r",
|
|
33
|
+
"1q2w3e4r5t",
|
|
34
|
+
"1q2w3e4r5t6y",
|
|
35
|
+
"1qaz2wsx",
|
|
36
|
+
"1qaz2wsx3edc",
|
|
37
|
+
"1qazxsw2",
|
|
38
|
+
"qwertyui",
|
|
39
|
+
"qwertyuiop",
|
|
40
|
+
"qwerty123",
|
|
41
|
+
"qwerty1234",
|
|
42
|
+
"qwerty12",
|
|
43
|
+
"qwertyuio",
|
|
44
|
+
"qwerty123456",
|
|
45
|
+
"qwerty12345",
|
|
46
|
+
"asdfghjk",
|
|
47
|
+
"asdfghjkl",
|
|
48
|
+
"asdfgh123",
|
|
49
|
+
"zxcvbnm1",
|
|
50
|
+
"zxcvbnmasd",
|
|
51
|
+
"zxcvbnm123",
|
|
52
|
+
"abcd1234",
|
|
53
|
+
"abcd12345",
|
|
54
|
+
"abc12345",
|
|
55
|
+
"abc123456",
|
|
56
|
+
"abcdefgh",
|
|
57
|
+
"abcdefg1",
|
|
58
|
+
"abcdefgh1",
|
|
59
|
+
"abcdefghi",
|
|
60
|
+
"iloveyou",
|
|
61
|
+
"iloveyou1",
|
|
62
|
+
"iloveyou2",
|
|
63
|
+
"iloveyou123",
|
|
64
|
+
"letmein1",
|
|
65
|
+
"letmein123",
|
|
66
|
+
"letmein12",
|
|
67
|
+
"welcome1",
|
|
68
|
+
"welcome12",
|
|
69
|
+
"welcome123",
|
|
70
|
+
"welcome01",
|
|
71
|
+
"welcome2",
|
|
72
|
+
"monkey123",
|
|
73
|
+
"monkey12",
|
|
74
|
+
"dragon123",
|
|
75
|
+
"dragon12",
|
|
76
|
+
"master123",
|
|
77
|
+
"master12",
|
|
78
|
+
"shadow123",
|
|
79
|
+
"shadow12",
|
|
80
|
+
"sunshine",
|
|
81
|
+
"sunshine1",
|
|
82
|
+
"sunshine123",
|
|
83
|
+
"princess",
|
|
84
|
+
"princess1",
|
|
85
|
+
"princess123",
|
|
86
|
+
"football",
|
|
87
|
+
"football1",
|
|
88
|
+
"football123",
|
|
89
|
+
"baseball",
|
|
90
|
+
"baseball1",
|
|
91
|
+
"baseball123",
|
|
92
|
+
"basketball",
|
|
93
|
+
"soccer123",
|
|
94
|
+
"hockey123",
|
|
95
|
+
"superman",
|
|
96
|
+
"superman1",
|
|
97
|
+
"superman123",
|
|
98
|
+
"batman123",
|
|
99
|
+
"batman12",
|
|
100
|
+
"spiderman",
|
|
101
|
+
"spiderman1",
|
|
102
|
+
"trustno1",
|
|
103
|
+
"trustno123",
|
|
104
|
+
"trustnoone",
|
|
105
|
+
"whatever",
|
|
106
|
+
"whatever1",
|
|
107
|
+
"whatever123",
|
|
108
|
+
"freedom1",
|
|
109
|
+
"freedom123",
|
|
110
|
+
"starwars",
|
|
111
|
+
"starwars1",
|
|
112
|
+
"starwars123",
|
|
113
|
+
"pokemon1",
|
|
114
|
+
"pokemon123",
|
|
115
|
+
"charlie1",
|
|
116
|
+
"charlie123",
|
|
117
|
+
"michael1",
|
|
118
|
+
"michael123",
|
|
119
|
+
"jessica1",
|
|
120
|
+
"jessica123",
|
|
121
|
+
"jennifer",
|
|
122
|
+
"jennifer1",
|
|
123
|
+
"daniel123",
|
|
124
|
+
"daniel12",
|
|
125
|
+
"thomas123",
|
|
126
|
+
"hunter123",
|
|
127
|
+
"hunter12",
|
|
128
|
+
"hunter2hunter2",
|
|
129
|
+
"hello123",
|
|
130
|
+
"hello1234",
|
|
131
|
+
"hello12345",
|
|
132
|
+
"helloworld",
|
|
133
|
+
"helloworld1",
|
|
134
|
+
"hello@123",
|
|
135
|
+
"admin123",
|
|
136
|
+
"admin1234",
|
|
137
|
+
"admin12345",
|
|
138
|
+
"admin@123",
|
|
139
|
+
"admin@1234",
|
|
140
|
+
"administrator",
|
|
141
|
+
"administrator1",
|
|
142
|
+
"adminadmin",
|
|
143
|
+
"adminadmin1",
|
|
144
|
+
"admin2020",
|
|
145
|
+
"admin2021",
|
|
146
|
+
"admin2022",
|
|
147
|
+
"admin2023",
|
|
148
|
+
"admin2024",
|
|
149
|
+
"admin2025",
|
|
150
|
+
"admin2026",
|
|
151
|
+
"root1234",
|
|
152
|
+
"root12345",
|
|
153
|
+
"toor1234",
|
|
154
|
+
"test1234",
|
|
155
|
+
"test12345",
|
|
156
|
+
"test123456",
|
|
157
|
+
"testtest",
|
|
158
|
+
"testing123",
|
|
159
|
+
"testing1",
|
|
160
|
+
"guest123",
|
|
161
|
+
"guest1234",
|
|
162
|
+
"changeme",
|
|
163
|
+
"changeme1",
|
|
164
|
+
"changeme123",
|
|
165
|
+
"change123",
|
|
166
|
+
"default1",
|
|
167
|
+
"default123",
|
|
168
|
+
"secret123",
|
|
169
|
+
"secret1234",
|
|
170
|
+
"secretpassword",
|
|
171
|
+
"mypassword",
|
|
172
|
+
"mypassword1",
|
|
173
|
+
"mypassword123",
|
|
174
|
+
"mypass123",
|
|
175
|
+
"mysecret1",
|
|
176
|
+
"login123",
|
|
177
|
+
"login1234",
|
|
178
|
+
"access123",
|
|
179
|
+
"access14",
|
|
180
|
+
"qazwsxedc",
|
|
181
|
+
"qazwsx123",
|
|
182
|
+
"qazxswedc",
|
|
183
|
+
"qweasdzxc",
|
|
184
|
+
"qweasd123",
|
|
185
|
+
"qweqweqwe",
|
|
186
|
+
"asdasdasd",
|
|
187
|
+
"asdasd123",
|
|
188
|
+
"zaq12wsx",
|
|
189
|
+
"zaq1zaq1",
|
|
190
|
+
"zaq1xsw2",
|
|
191
|
+
"aaaaaaaa",
|
|
192
|
+
"aaaaaaa1",
|
|
193
|
+
"11111111",
|
|
194
|
+
"111111111",
|
|
195
|
+
"1111111111",
|
|
196
|
+
"00000000",
|
|
197
|
+
"000000000",
|
|
198
|
+
"0000000000",
|
|
199
|
+
"12341234",
|
|
200
|
+
"12121212",
|
|
201
|
+
"11223344",
|
|
202
|
+
"1122334455",
|
|
203
|
+
"123321123",
|
|
204
|
+
"12344321",
|
|
205
|
+
"123456789a",
|
|
206
|
+
"123456abc",
|
|
207
|
+
"1234567a",
|
|
208
|
+
"1234abcd",
|
|
209
|
+
"987654321",
|
|
210
|
+
"9876543210",
|
|
211
|
+
"98765432",
|
|
212
|
+
"88888888",
|
|
213
|
+
"66666666",
|
|
214
|
+
"55555555",
|
|
215
|
+
"77777777",
|
|
216
|
+
"99999999",
|
|
217
|
+
"22222222",
|
|
218
|
+
"33333333",
|
|
219
|
+
"44444444",
|
|
220
|
+
"pass1234",
|
|
221
|
+
"pass12345",
|
|
222
|
+
"pass123456",
|
|
223
|
+
"passpass",
|
|
224
|
+
"passpass1",
|
|
225
|
+
"pass@123",
|
|
226
|
+
"pass@1234",
|
|
227
|
+
"mustang1",
|
|
228
|
+
"mustang123",
|
|
229
|
+
"ranger123",
|
|
230
|
+
"harley123",
|
|
231
|
+
"ferrari1",
|
|
232
|
+
"porsche1",
|
|
233
|
+
"computer",
|
|
234
|
+
"computer1",
|
|
235
|
+
"computer123",
|
|
236
|
+
"internet",
|
|
237
|
+
"internet1",
|
|
238
|
+
"internet123",
|
|
239
|
+
"windows1",
|
|
240
|
+
"windows123",
|
|
241
|
+
"microsoft",
|
|
242
|
+
"linux123",
|
|
243
|
+
"ubuntu123",
|
|
244
|
+
"google123",
|
|
245
|
+
"google12",
|
|
246
|
+
"facebook",
|
|
247
|
+
"facebook1",
|
|
248
|
+
"facebook123",
|
|
249
|
+
"twitter1",
|
|
250
|
+
"youtube1",
|
|
251
|
+
"instagram",
|
|
252
|
+
"samsung1",
|
|
253
|
+
"samsung123",
|
|
254
|
+
"iphone123",
|
|
255
|
+
"android1",
|
|
256
|
+
"android123",
|
|
257
|
+
"liverpool",
|
|
258
|
+
"liverpool1",
|
|
259
|
+
"manchester",
|
|
260
|
+
"chelsea1",
|
|
261
|
+
"arsenal1",
|
|
262
|
+
"barcelona",
|
|
263
|
+
"realmadrid1",
|
|
264
|
+
"cheese123",
|
|
265
|
+
"chocolate",
|
|
266
|
+
"chocolate1",
|
|
267
|
+
"cookie123",
|
|
268
|
+
"banana123",
|
|
269
|
+
"butterfly",
|
|
270
|
+
"butterfly1",
|
|
271
|
+
"flower123",
|
|
272
|
+
"rainbow1",
|
|
273
|
+
"rainbow123",
|
|
274
|
+
"summer123",
|
|
275
|
+
"summer2024",
|
|
276
|
+
"summer2025",
|
|
277
|
+
"winter123",
|
|
278
|
+
"winter2024",
|
|
279
|
+
"winter2025",
|
|
280
|
+
"spring123",
|
|
281
|
+
"autumn123",
|
|
282
|
+
"january1",
|
|
283
|
+
"february1",
|
|
284
|
+
"december1",
|
|
285
|
+
"qwerty@123",
|
|
286
|
+
"abc@12345",
|
|
287
|
+
"p@55w0rd",
|
|
288
|
+
"p@$$w0rd",
|
|
289
|
+
"passw0rd1",
|
|
290
|
+
"passw0rd!",
|
|
291
|
+
"warlock123",
|
|
292
|
+
"warlock1",
|
|
293
|
+
"devtools",
|
|
294
|
+
"devtools1",
|
|
295
|
+
"devtools123",
|
|
296
|
+
"monitor123",
|
|
297
|
+
"monitor1",
|
|
298
|
+
"dashboard",
|
|
299
|
+
"dashboard1",
|
|
300
|
+
"dashboard123"
|
|
301
|
+
]);
|
|
302
|
+
|
|
303
|
+
//#endregion
|
|
304
|
+
//#region ../../packages/devtools/src/production/auth/helpers.ts
|
|
305
|
+
const MIN_PASSWORD_LENGTH = 8;
|
|
306
|
+
const MAX_PASSWORD_BYTES = 72;
|
|
307
|
+
/** The alphabet of recovery codes and references: no 0, 1, 8, 9, I, L, O. */
|
|
308
|
+
const CODE_ALPHABET = "ABCDEFGHJKMNPQRSTUVWXYZ23456789";
|
|
309
|
+
/** Letters and digits that cannot be mistaken for each other. */
|
|
310
|
+
const TEMPORARY_ALPHABET = "ABCDEFGHJKMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz23456789";
|
|
311
|
+
/**
|
|
312
|
+
* The password rules: at least 8 characters, at most 72 bytes (UTF-8), not in
|
|
313
|
+
* the built-in common list (compared lower-cased), not equal to the email
|
|
314
|
+
* (lower-cased). Returns the failing rule's error code, or `null`.
|
|
315
|
+
*/
|
|
316
|
+
function checkPasswordPolicy(password, email) {
|
|
317
|
+
if (typeof password !== "string" || [...password].length < MIN_PASSWORD_LENGTH) return "auth.password-too-short";
|
|
318
|
+
if (Buffer.byteLength(password, "utf8") > MAX_PASSWORD_BYTES) return "auth.password-too-long";
|
|
319
|
+
const lower = password.toLowerCase();
|
|
320
|
+
if (COMMON_PASSWORDS.has(lower)) return "auth.password-common";
|
|
321
|
+
if (email !== null && lower === email.trim().toLowerCase()) return "auth.password-same-as-email";
|
|
322
|
+
return null;
|
|
323
|
+
}
|
|
324
|
+
/** 32 random bytes, base64url (43 characters): session, CSRF and invite tokens. */
|
|
325
|
+
function generateToken() {
|
|
326
|
+
return (0, node_crypto.randomBytes)(32).toString("base64url");
|
|
327
|
+
}
|
|
328
|
+
/** SHA-256 hex of a token: what the store keeps. */
|
|
329
|
+
function hashToken(token) {
|
|
330
|
+
return (0, node_crypto.createHash)("sha256").update(token).digest("hex");
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* A random temporary password for `warlock devtools:reset-admin`: 20
|
|
334
|
+
* characters from an unambiguous alphabet, passes `checkPasswordPolicy`.
|
|
335
|
+
*/
|
|
336
|
+
function generateTemporaryPassword() {
|
|
337
|
+
for (;;) {
|
|
338
|
+
let password = "";
|
|
339
|
+
for (let index = 0; index < 20; index++) password += TEMPORARY_ALPHABET[(0, node_crypto.randomInt)(54)];
|
|
340
|
+
if (checkPasswordPolicy(password, null) === null) return password;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
/** Compares two strings in constant time (both are hashed first, so lengths do not leak). */
|
|
344
|
+
function safeEqual(a, b) {
|
|
345
|
+
const left = (0, node_crypto.createHash)("sha256").update(String(a)).digest();
|
|
346
|
+
const right = (0, node_crypto.createHash)("sha256").update(String(b)).digest();
|
|
347
|
+
return (0, node_crypto.timingSafeEqual)(left, right);
|
|
348
|
+
}
|
|
349
|
+
/** Emails are compared trimmed and lower-cased. */
|
|
350
|
+
function normalizeEmail(email) {
|
|
351
|
+
return typeof email === "string" ? email.trim().toLowerCase() : "";
|
|
352
|
+
}
|
|
353
|
+
/** A deliberately plain shape check; the invite flow is the real proof of ownership. */
|
|
354
|
+
function isPlausibleEmail(email) {
|
|
355
|
+
return email.length <= 254 && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
|
|
356
|
+
}
|
|
357
|
+
/** One recovery code, `xxxxx-xxxxx` from the unambiguous alphabet. */
|
|
358
|
+
function generateRecoveryCode() {
|
|
359
|
+
let code = "";
|
|
360
|
+
for (let index = 0; index < 10; index++) {
|
|
361
|
+
if (index === 5) code += "-";
|
|
362
|
+
code += CODE_ALPHABET[(0, node_crypto.randomInt)(31)];
|
|
363
|
+
}
|
|
364
|
+
return code;
|
|
365
|
+
}
|
|
366
|
+
/** The form a recovery code is hashed in: upper case, letters and digits only. */
|
|
367
|
+
function normalizeRecoveryCode(code) {
|
|
368
|
+
return String(code).toUpperCase().replace(/[^A-Z0-9]/g, "");
|
|
369
|
+
}
|
|
370
|
+
/** SHA-256 hex of a normalized recovery code. */
|
|
371
|
+
function hashRecoveryCode(code) {
|
|
372
|
+
return hashToken(normalizeRecoveryCode(code));
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
//#endregion
|
|
376
|
+
Object.defineProperty(exports, "checkPasswordPolicy", {
|
|
377
|
+
enumerable: true,
|
|
378
|
+
get: function () {
|
|
379
|
+
return checkPasswordPolicy;
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
Object.defineProperty(exports, "generateRecoveryCode", {
|
|
383
|
+
enumerable: true,
|
|
384
|
+
get: function () {
|
|
385
|
+
return generateRecoveryCode;
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
Object.defineProperty(exports, "generateTemporaryPassword", {
|
|
389
|
+
enumerable: true,
|
|
390
|
+
get: function () {
|
|
391
|
+
return generateTemporaryPassword;
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
Object.defineProperty(exports, "generateToken", {
|
|
395
|
+
enumerable: true,
|
|
396
|
+
get: function () {
|
|
397
|
+
return generateToken;
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
Object.defineProperty(exports, "hashRecoveryCode", {
|
|
401
|
+
enumerable: true,
|
|
402
|
+
get: function () {
|
|
403
|
+
return hashRecoveryCode;
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
Object.defineProperty(exports, "hashToken", {
|
|
407
|
+
enumerable: true,
|
|
408
|
+
get: function () {
|
|
409
|
+
return hashToken;
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
Object.defineProperty(exports, "isPlausibleEmail", {
|
|
413
|
+
enumerable: true,
|
|
414
|
+
get: function () {
|
|
415
|
+
return isPlausibleEmail;
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
Object.defineProperty(exports, "normalizeEmail", {
|
|
419
|
+
enumerable: true,
|
|
420
|
+
get: function () {
|
|
421
|
+
return normalizeEmail;
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
Object.defineProperty(exports, "normalizeRecoveryCode", {
|
|
425
|
+
enumerable: true,
|
|
426
|
+
get: function () {
|
|
427
|
+
return normalizeRecoveryCode;
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
Object.defineProperty(exports, "safeEqual", {
|
|
431
|
+
enumerable: true,
|
|
432
|
+
get: function () {
|
|
433
|
+
return safeEqual;
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
//# sourceMappingURL=helpers-7k_Q-abk.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers-7k_Q-abk.cjs","names":["randomBytes","createHash","randomInt","timingSafeEqual"],"sources":["../../../../../../../packages/devtools/src/production/auth/common-passwords.ts","../../../../../../../packages/devtools/src/production/auth/helpers.ts"],"sourcesContent":["/**\n * Passwords the monitor refuses (compared lower-cased). Short entries are\n * left out: the length rule already refuses them.\n */\nexport const COMMON_PASSWORDS: ReadonlySet<string> = new Set([\n \"password\",\n \"password1\",\n \"password12\",\n \"password123\",\n \"password1234\",\n \"passw0rd\",\n \"p@ssw0rd\",\n \"p@ssword\",\n \"password!\",\n \"password1!\",\n \"password2\",\n \"password3\",\n \"password01\",\n \"password11\",\n \"password99\",\n \"pa55word\",\n \"pa$$word\",\n \"12345678\",\n \"123456789\",\n \"1234567890\",\n \"12345678910\",\n \"123123123\",\n \"1234qwer\",\n \"1q2w3e4r\",\n \"1q2w3e4r5t\",\n \"1q2w3e4r5t6y\",\n \"1qaz2wsx\",\n \"1qaz2wsx3edc\",\n \"1qazxsw2\",\n \"qwertyui\",\n \"qwertyuiop\",\n \"qwerty123\",\n \"qwerty1234\",\n \"qwerty12\",\n \"qwertyuio\",\n \"qwerty123456\",\n \"qwerty12345\",\n \"asdfghjk\",\n \"asdfghjkl\",\n \"asdfgh123\",\n \"zxcvbnm1\",\n \"zxcvbnmasd\",\n \"zxcvbnm123\",\n \"abcd1234\",\n \"abcd12345\",\n \"abc12345\",\n \"abc123456\",\n \"abcdefgh\",\n \"abcdefg1\",\n \"abcdefgh1\",\n \"abcdefghi\",\n \"iloveyou\",\n \"iloveyou1\",\n \"iloveyou2\",\n \"iloveyou123\",\n \"letmein1\",\n \"letmein123\",\n \"letmein12\",\n \"welcome1\",\n \"welcome12\",\n \"welcome123\",\n \"welcome01\",\n \"welcome2\",\n \"monkey123\",\n \"monkey12\",\n \"dragon123\",\n \"dragon12\",\n \"master123\",\n \"master12\",\n \"shadow123\",\n \"shadow12\",\n \"sunshine\",\n \"sunshine1\",\n \"sunshine123\",\n \"princess\",\n \"princess1\",\n \"princess123\",\n \"football\",\n \"football1\",\n \"football123\",\n \"baseball\",\n \"baseball1\",\n \"baseball123\",\n \"basketball\",\n \"soccer123\",\n \"hockey123\",\n \"superman\",\n \"superman1\",\n \"superman123\",\n \"batman123\",\n \"batman12\",\n \"spiderman\",\n \"spiderman1\",\n \"trustno1\",\n \"trustno123\",\n \"trustnoone\",\n \"whatever\",\n \"whatever1\",\n \"whatever123\",\n \"freedom1\",\n \"freedom123\",\n \"starwars\",\n \"starwars1\",\n \"starwars123\",\n \"pokemon1\",\n \"pokemon123\",\n \"charlie1\",\n \"charlie123\",\n \"michael1\",\n \"michael123\",\n \"jessica1\",\n \"jessica123\",\n \"jennifer\",\n \"jennifer1\",\n \"daniel123\",\n \"daniel12\",\n \"thomas123\",\n \"hunter123\",\n \"hunter12\",\n \"hunter2hunter2\",\n \"hello123\",\n \"hello1234\",\n \"hello12345\",\n \"helloworld\",\n \"helloworld1\",\n \"hello@123\",\n \"admin123\",\n \"admin1234\",\n \"admin12345\",\n \"admin@123\",\n \"admin@1234\",\n \"administrator\",\n \"administrator1\",\n \"adminadmin\",\n \"adminadmin1\",\n \"admin2020\",\n \"admin2021\",\n \"admin2022\",\n \"admin2023\",\n \"admin2024\",\n \"admin2025\",\n \"admin2026\",\n \"root1234\",\n \"root12345\",\n \"toor1234\",\n \"test1234\",\n \"test12345\",\n \"test123456\",\n \"testtest\",\n \"testing123\",\n \"testing1\",\n \"guest123\",\n \"guest1234\",\n \"changeme\",\n \"changeme1\",\n \"changeme123\",\n \"change123\",\n \"default1\",\n \"default123\",\n \"secret123\",\n \"secret1234\",\n \"secretpassword\",\n \"mypassword\",\n \"mypassword1\",\n \"mypassword123\",\n \"mypass123\",\n \"mysecret1\",\n \"login123\",\n \"login1234\",\n \"access123\",\n \"access14\",\n \"qazwsxedc\",\n \"qazwsx123\",\n \"qazxswedc\",\n \"qweasdzxc\",\n \"qweasd123\",\n \"qweqweqwe\",\n \"asdasdasd\",\n \"asdasd123\",\n \"zaq12wsx\",\n \"zaq1zaq1\",\n \"zaq1xsw2\",\n \"aaaaaaaa\",\n \"aaaaaaa1\",\n \"11111111\",\n \"111111111\",\n \"1111111111\",\n \"00000000\",\n \"000000000\",\n \"0000000000\",\n \"12341234\",\n \"12121212\",\n \"11223344\",\n \"1122334455\",\n \"123321123\",\n \"12344321\",\n \"123456789a\",\n \"123456abc\",\n \"1234567a\",\n \"1234abcd\",\n \"987654321\",\n \"9876543210\",\n \"98765432\",\n \"88888888\",\n \"66666666\",\n \"55555555\",\n \"77777777\",\n \"99999999\",\n \"22222222\",\n \"33333333\",\n \"44444444\",\n \"pass1234\",\n \"pass12345\",\n \"pass123456\",\n \"passpass\",\n \"passpass1\",\n \"pass@123\",\n \"pass@1234\",\n \"mustang1\",\n \"mustang123\",\n \"ranger123\",\n \"harley123\",\n \"ferrari1\",\n \"porsche1\",\n \"computer\",\n \"computer1\",\n \"computer123\",\n \"internet\",\n \"internet1\",\n \"internet123\",\n \"windows1\",\n \"windows123\",\n \"microsoft\",\n \"linux123\",\n \"ubuntu123\",\n \"google123\",\n \"google12\",\n \"facebook\",\n \"facebook1\",\n \"facebook123\",\n \"twitter1\",\n \"youtube1\",\n \"instagram\",\n \"samsung1\",\n \"samsung123\",\n \"iphone123\",\n \"android1\",\n \"android123\",\n \"liverpool\",\n \"liverpool1\",\n \"manchester\",\n \"chelsea1\",\n \"arsenal1\",\n \"barcelona\",\n \"realmadrid1\",\n \"cheese123\",\n \"chocolate\",\n \"chocolate1\",\n \"cookie123\",\n \"banana123\",\n \"butterfly\",\n \"butterfly1\",\n \"flower123\",\n \"rainbow1\",\n \"rainbow123\",\n \"summer123\",\n \"summer2024\",\n \"summer2025\",\n \"winter123\",\n \"winter2024\",\n \"winter2025\",\n \"spring123\",\n \"autumn123\",\n \"january1\",\n \"february1\",\n \"december1\",\n \"qwerty@123\",\n \"abc@12345\",\n \"p@55w0rd\",\n \"p@$$w0rd\",\n \"passw0rd1\",\n \"passw0rd!\",\n \"warlock123\",\n \"warlock1\",\n \"devtools\",\n \"devtools1\",\n \"devtools123\",\n \"monitor123\",\n \"monitor1\",\n \"dashboard\",\n \"dashboard1\",\n \"dashboard123\",\n]);\n","import { createHash, randomBytes, randomInt, timingSafeEqual } from \"node:crypto\";\nimport type { DevtoolsErrorCode } from \"../contracts\";\nimport { COMMON_PASSWORDS } from \"./common-passwords\";\n\nconst MIN_PASSWORD_LENGTH = 8;\nconst MAX_PASSWORD_BYTES = 72;\n\n/** The alphabet of recovery codes and references: no 0, 1, 8, 9, I, L, O. */\nconst CODE_ALPHABET = \"ABCDEFGHJKMNPQRSTUVWXYZ23456789\";\n\n/** Letters and digits that cannot be mistaken for each other. */\nconst TEMPORARY_ALPHABET = \"ABCDEFGHJKMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz23456789\";\n\n/**\n * The password rules: at least 8 characters, at most 72 bytes (UTF-8), not in\n * the built-in common list (compared lower-cased), not equal to the email\n * (lower-cased). Returns the failing rule's error code, or `null`.\n */\nexport function checkPasswordPolicy(\n password: string,\n email: string | null,\n): DevtoolsErrorCode | null {\n if (typeof password !== \"string\" || [...password].length < MIN_PASSWORD_LENGTH) {\n return \"auth.password-too-short\";\n }\n\n if (Buffer.byteLength(password, \"utf8\") > MAX_PASSWORD_BYTES) return \"auth.password-too-long\";\n\n const lower = password.toLowerCase();\n\n if (COMMON_PASSWORDS.has(lower)) return \"auth.password-common\";\n\n if (email !== null && lower === email.trim().toLowerCase()) return \"auth.password-same-as-email\";\n\n return null;\n}\n\n/** 32 random bytes, base64url (43 characters): session, CSRF and invite tokens. */\nexport function generateToken(): string {\n return randomBytes(32).toString(\"base64url\");\n}\n\n/** SHA-256 hex of a token: what the store keeps. */\nexport function hashToken(token: string): string {\n return createHash(\"sha256\").update(token).digest(\"hex\");\n}\n\n/**\n * A random temporary password for `warlock devtools:reset-admin`: 20\n * characters from an unambiguous alphabet, passes `checkPasswordPolicy`.\n */\nexport function generateTemporaryPassword(): string {\n for (;;) {\n let password = \"\";\n\n for (let index = 0; index < 20; index++) {\n password += TEMPORARY_ALPHABET[randomInt(TEMPORARY_ALPHABET.length)];\n }\n\n if (checkPasswordPolicy(password, null) === null) return password;\n }\n}\n\n/** Compares two strings in constant time (both are hashed first, so lengths do not leak). */\nexport function safeEqual(a: string, b: string): boolean {\n const left = createHash(\"sha256\").update(String(a)).digest();\n const right = createHash(\"sha256\").update(String(b)).digest();\n\n return timingSafeEqual(left, right);\n}\n\n/** Emails are compared trimmed and lower-cased. */\nexport function normalizeEmail(email: unknown): string {\n return typeof email === \"string\" ? email.trim().toLowerCase() : \"\";\n}\n\n/** A deliberately plain shape check; the invite flow is the real proof of ownership. */\nexport function isPlausibleEmail(email: string): boolean {\n return email.length <= 254 && /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(email);\n}\n\n/** One recovery code, `xxxxx-xxxxx` from the unambiguous alphabet. */\nexport function generateRecoveryCode(): string {\n let code = \"\";\n\n for (let index = 0; index < 10; index++) {\n if (index === 5) code += \"-\";\n\n code += CODE_ALPHABET[randomInt(CODE_ALPHABET.length)];\n }\n\n return code;\n}\n\n/** The form a recovery code is hashed in: upper case, letters and digits only. */\nexport function normalizeRecoveryCode(code: string): string {\n return String(code)\n .toUpperCase()\n .replace(/[^A-Z0-9]/g, \"\");\n}\n\n/** SHA-256 hex of a normalized recovery code. */\nexport function hashRecoveryCode(code: string): string {\n return hashToken(normalizeRecoveryCode(code));\n}\n"],"mappings":";;;;;;;AAIA,MAAa,mCAAwC,IAAI,IAAI;CAC3D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;;;ACrSD,MAAM,sBAAsB;AAC5B,MAAM,qBAAqB;;AAG3B,MAAM,gBAAgB;;AAGtB,MAAM,qBAAqB;;;;;;AAO3B,SAAgB,oBACd,UACA,OAC0B;CAC1B,IAAI,OAAO,aAAa,YAAY,CAAC,GAAG,QAAQ,CAAC,CAAC,SAAS,qBACzD,OAAO;CAGT,IAAI,OAAO,WAAW,UAAU,MAAM,IAAI,oBAAoB,OAAO;CAErE,MAAM,QAAQ,SAAS,YAAY;CAEnC,IAAI,iBAAiB,IAAI,KAAK,GAAG,OAAO;CAExC,IAAI,UAAU,QAAQ,UAAU,MAAM,KAAK,CAAC,CAAC,YAAY,GAAG,OAAO;CAEnE,OAAO;AACT;;AAGA,SAAgB,gBAAwB;CACtC,WAAOA,yBAAY,EAAE,CAAC,CAAC,SAAS,WAAW;AAC7C;;AAGA,SAAgB,UAAU,OAAuB;CAC/C,WAAOC,wBAAW,QAAQ,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO,KAAK;AACxD;;;;;AAMA,SAAgB,4BAAoC;CAClD,SAAS;EACP,IAAI,WAAW;EAEf,KAAK,IAAI,QAAQ,GAAG,QAAQ,IAAI,SAC9B,YAAY,uBAAmBC,uBAAU,EAAyB;EAGpE,IAAI,oBAAoB,UAAU,IAAI,MAAM,MAAM,OAAO;CAC3D;AACF;;AAGA,SAAgB,UAAU,GAAW,GAAoB;CACvD,MAAM,WAAOD,wBAAW,QAAQ,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO;CAC3D,MAAM,YAAQA,wBAAW,QAAQ,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO;CAE5D,WAAOE,6BAAgB,MAAM,KAAK;AACpC;;AAGA,SAAgB,eAAe,OAAwB;CACrD,OAAO,OAAO,UAAU,WAAW,MAAM,KAAK,CAAC,CAAC,YAAY,IAAI;AAClE;;AAGA,SAAgB,iBAAiB,OAAwB;CACvD,OAAO,MAAM,UAAU,OAAO,6BAA6B,KAAK,KAAK;AACvE;;AAGA,SAAgB,uBAA+B;CAC7C,IAAI,OAAO;CAEX,KAAK,IAAI,QAAQ,GAAG,QAAQ,IAAI,SAAS;EACvC,IAAI,UAAU,GAAG,QAAQ;EAEzB,QAAQ,kBAAcD,uBAAU,EAAoB;CACtD;CAEA,OAAO;AACT;;AAGA,SAAgB,sBAAsB,MAAsB;CAC1D,OAAO,OAAO,IAAI,CAAC,CAChB,YAAY,CAAC,CACb,QAAQ,cAAc,EAAE;AAC7B;;AAGA,SAAgB,iBAAiB,MAAsB;CACrD,OAAO,UAAU,sBAAsB,IAAI,CAAC;AAC9C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_contracts = require("./contracts-
|
|
1
|
+
const require_contracts = require("./contracts-CDuY-ahl.cjs");
|
|
2
2
|
let node_crypto = require("node:crypto");
|
|
3
3
|
|
|
4
4
|
//#region ../../packages/devtools/src/production/stats/histogram.ts
|
|
@@ -99,4 +99,4 @@ Object.defineProperty(exports, "shortId", {
|
|
|
99
99
|
return shortId;
|
|
100
100
|
}
|
|
101
101
|
});
|
|
102
|
-
//# sourceMappingURL=histogram-
|
|
102
|
+
//# sourceMappingURL=histogram-BRV5eHcp.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"histogram-
|
|
1
|
+
{"version":3,"file":"histogram-BRV5eHcp.cjs","names":["DEVTOOLS_LATENCY_BUCKETS_MS","createHash"],"sources":["../../../../../../../packages/devtools/src/production/stats/histogram.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { DEVTOOLS_LATENCY_BUCKETS_MS, type DevtoolsHistogram } from \"../contracts\";\n\n/** An empty histogram over `DEVTOOLS_LATENCY_BUCKETS_MS`. */\nexport function createHistogram(): DevtoolsHistogram {\n return {\n counts: new Array<number>(DEVTOOLS_LATENCY_BUCKETS_MS.length + 1).fill(0),\n count: 0,\n sumMs: 0,\n maxMs: 0,\n };\n}\n\n/** The bucket index a duration falls in. */\nexport function bucketIndex(durationMs: number): number {\n for (let index = 0; index < DEVTOOLS_LATENCY_BUCKETS_MS.length; index++) {\n if (durationMs <= (DEVTOOLS_LATENCY_BUCKETS_MS[index] as number)) return index;\n }\n\n return DEVTOOLS_LATENCY_BUCKETS_MS.length;\n}\n\n/** Adds one duration to `histogram` in place. A negative or non-finite value counts as 0. */\nexport function recordDuration(histogram: DevtoolsHistogram, durationMs: number): void {\n const value = Number.isFinite(durationMs) && durationMs > 0 ? durationMs : 0;\n const index = bucketIndex(value);\n\n histogram.counts[index] = (histogram.counts[index] ?? 0) + 1;\n histogram.count += 1;\n histogram.sumMs += value;\n\n if (value > histogram.maxMs) histogram.maxMs = value;\n}\n\n/** The sum of several histograms (exact: they share the bucket bounds). */\nexport function mergeHistograms(histograms: readonly DevtoolsHistogram[]): DevtoolsHistogram {\n const merged = createHistogram();\n\n for (const histogram of histograms) {\n for (let index = 0; index < merged.counts.length; index++) {\n merged.counts[index] = (merged.counts[index] ?? 0) + (histogram.counts[index] ?? 0);\n }\n\n merged.count += histogram.count;\n merged.sumMs += histogram.sumMs;\n\n if (histogram.maxMs > merged.maxMs) merged.maxMs = histogram.maxMs;\n }\n\n return merged;\n}\n\n/**\n * The `q` quantile (0–1) of a histogram: the upper bound of the bucket that\n * holds it, capped at the largest value seen. 0 for an empty histogram.\n */\nexport function histogramQuantile(histogram: DevtoolsHistogram, q: number): number {\n if (histogram.count === 0) return 0;\n\n const rank = Math.max(1, Math.ceil(Math.min(Math.max(q, 0), 1) * histogram.count));\n let seen = 0;\n\n for (let index = 0; index < histogram.counts.length; index++) {\n seen += histogram.counts[index] ?? 0;\n\n if (seen >= rank) {\n const bound = DEVTOOLS_LATENCY_BUCKETS_MS[index];\n\n return bound === undefined ? histogram.maxMs : Math.min(bound, histogram.maxMs);\n }\n }\n\n return histogram.maxMs;\n}\n\n/** The mean duration, 0 for an empty histogram. */\nexport function histogramMean(histogram: DevtoolsHistogram): number {\n return histogram.count === 0 ? 0 : histogram.sumMs / histogram.count;\n}\n\n/** The first 16 hex characters of SHA-256: the id of a query shape or an error fingerprint. */\nexport function shortId(value: string): string {\n return createHash(\"sha256\").update(value).digest(\"hex\").slice(0, 16);\n}\n"],"mappings":";;;;;AAIA,SAAgB,kBAAqC;CACnD,OAAO;EACL,QAAQ,IAAI,MAAcA,8CAA4B,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC;EACxE,OAAO;EACP,OAAO;EACP,OAAO;CACT;AACF;;AAGA,SAAgB,YAAY,YAA4B;CACtD,KAAK,IAAI,QAAQ,GAAG,QAAQA,8CAA4B,QAAQ,SAC9D,IAAI,cAAeA,8CAA4B,QAAmB,OAAO;CAG3E,OAAOA,8CAA4B;AACrC;;AAGA,SAAgB,eAAe,WAA8B,YAA0B;CACrF,MAAM,QAAQ,OAAO,SAAS,UAAU,KAAK,aAAa,IAAI,aAAa;CAC3E,MAAM,QAAQ,YAAY,KAAK;CAE/B,UAAU,OAAO,UAAU,UAAU,OAAO,UAAU,KAAK;CAC3D,UAAU,SAAS;CACnB,UAAU,SAAS;CAEnB,IAAI,QAAQ,UAAU,OAAO,UAAU,QAAQ;AACjD;;AAGA,SAAgB,gBAAgB,YAA6D;CAC3F,MAAM,SAAS,gBAAgB;CAE/B,KAAK,MAAM,aAAa,YAAY;EAClC,KAAK,IAAI,QAAQ,GAAG,QAAQ,OAAO,OAAO,QAAQ,SAChD,OAAO,OAAO,UAAU,OAAO,OAAO,UAAU,MAAM,UAAU,OAAO,UAAU;EAGnF,OAAO,SAAS,UAAU;EAC1B,OAAO,SAAS,UAAU;EAE1B,IAAI,UAAU,QAAQ,OAAO,OAAO,OAAO,QAAQ,UAAU;CAC/D;CAEA,OAAO;AACT;;;;;AAMA,SAAgB,kBAAkB,WAA8B,GAAmB;CACjF,IAAI,UAAU,UAAU,GAAG,OAAO;CAElC,MAAM,OAAO,KAAK,IAAI,GAAG,KAAK,KAAK,KAAK,IAAI,KAAK,IAAI,GAAG,CAAC,GAAG,CAAC,IAAI,UAAU,KAAK,CAAC;CACjF,IAAI,OAAO;CAEX,KAAK,IAAI,QAAQ,GAAG,QAAQ,UAAU,OAAO,QAAQ,SAAS;EAC5D,QAAQ,UAAU,OAAO,UAAU;EAEnC,IAAI,QAAQ,MAAM;GAChB,MAAM,QAAQA,8CAA4B;GAE1C,OAAO,UAAU,SAAY,UAAU,QAAQ,KAAK,IAAI,OAAO,UAAU,KAAK;EAChF;CACF;CAEA,OAAO,UAAU;AACnB;;AAGA,SAAgB,cAAc,WAAsC;CAClE,OAAO,UAAU,UAAU,IAAI,IAAI,UAAU,QAAQ,UAAU;AACjE;;AAGA,SAAgB,QAAQ,OAAuB;CAC7C,WAAOC,wBAAW,QAAQ,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,GAAG,EAAE;AACrE"}
|