@vforsh/argus 0.1.9 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/argus.js +577 -157
  3. package/dist/bin.js +2 -0
  4. package/dist/bin.js.map +1 -1
  5. package/dist/cli/register/registerAuth.d.ts +3 -0
  6. package/dist/cli/register/registerAuth.d.ts.map +1 -0
  7. package/dist/cli/register/registerAuth.js +29 -0
  8. package/dist/cli/register/registerAuth.js.map +1 -0
  9. package/dist/commands/auth.d.ts +22 -0
  10. package/dist/commands/auth.d.ts.map +1 -0
  11. package/dist/commands/auth.js +168 -0
  12. package/dist/commands/auth.js.map +1 -0
  13. package/dist/commands/start.d.ts.map +1 -1
  14. package/dist/commands/start.js +1 -0
  15. package/dist/commands/start.js.map +1 -1
  16. package/dist/commands/watcherNativeHost.d.ts.map +1 -1
  17. package/dist/commands/watcherNativeHost.js +1 -0
  18. package/dist/commands/watcherNativeHost.js.map +1 -1
  19. package/dist/commands/watcherStart.d.ts.map +1 -1
  20. package/dist/commands/watcherStart.js +1 -0
  21. package/dist/commands/watcherStart.js.map +1 -1
  22. package/package.json +3 -2
  23. package/dist/commands/contexts.d.ts +0 -7
  24. package/dist/commands/contexts.d.ts.map +0 -1
  25. package/dist/commands/contexts.js +0 -54
  26. package/dist/commands/contexts.js.map +0 -1
  27. package/dist/commands/domDiff.d.ts +0 -43
  28. package/dist/commands/domDiff.d.ts.map +0 -1
  29. package/dist/commands/domDiff.js +0 -279
  30. package/dist/commands/domDiff.js.map +0 -1
  31. package/dist/commands/domSubmit.d.ts +0 -10
  32. package/dist/commands/domSubmit.d.ts.map +0 -1
  33. package/dist/commands/domSubmit.js +0 -78
  34. package/dist/commands/domSubmit.js.map +0 -1
  35. package/dist/commands/extension/attach.d.ts +0 -8
  36. package/dist/commands/extension/attach.d.ts.map +0 -1
  37. package/dist/commands/extension/attach.js +0 -171
  38. package/dist/commands/extension/attach.js.map +0 -1
  39. package/dist/commands/extension/detach.d.ts +0 -6
  40. package/dist/commands/extension/detach.d.ts.map +0 -1
  41. package/dist/commands/extension/detach.js +0 -132
  42. package/dist/commands/extension/detach.js.map +0 -1
  43. package/dist/commands/extension/targets.d.ts +0 -13
  44. package/dist/commands/extension/targets.d.ts.map +0 -1
  45. package/dist/commands/extension/targets.js +0 -77
  46. package/dist/commands/extension/targets.js.map +0 -1
  47. package/dist/commands/frames.d.ts +0 -7
  48. package/dist/commands/frames.d.ts.map +0 -1
  49. package/dist/commands/frames.js +0 -90
  50. package/dist/commands/frames.js.map +0 -1
  51. package/dist/frame/frameSelector.d.ts +0 -14
  52. package/dist/frame/frameSelector.d.ts.map +0 -1
  53. package/dist/frame/frameSelector.js +0 -31
  54. package/dist/frame/frameSelector.js.map +0 -1
  55. package/dist/output/domDiff.d.ts +0 -14
  56. package/dist/output/domDiff.d.ts.map +0 -1
  57. package/dist/output/domDiff.js +0 -151
  58. package/dist/output/domDiff.js.map +0 -1
  59. package/dist/throttle/networkPresets.d.ts +0 -6
  60. package/dist/throttle/networkPresets.d.ts.map +0 -1
  61. package/dist/throttle/networkPresets.js +0 -24
  62. package/dist/throttle/networkPresets.js.map +0 -1
package/dist/argus.js CHANGED
@@ -5,29 +5,15 @@ var __getProtoOf = Object.getPrototypeOf;
5
5
  var __defProp = Object.defineProperty;
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- function __accessProp(key) {
9
- return this[key];
10
- }
11
- var __toESMCache_node;
12
- var __toESMCache_esm;
13
8
  var __toESM = (mod, isNodeMode, target) => {
14
- var canCache = mod != null && typeof mod === "object";
15
- if (canCache) {
16
- var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
17
- var cached = cache.get(mod);
18
- if (cached)
19
- return cached;
20
- }
21
9
  target = mod != null ? __create(__getProtoOf(mod)) : {};
22
10
  const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
23
11
  for (let key of __getOwnPropNames(mod))
24
12
  if (!__hasOwnProp.call(to, key))
25
13
  __defProp(to, key, {
26
- get: __accessProp.bind(mod, key),
14
+ get: () => mod[key],
27
15
  enumerable: true
28
16
  });
29
- if (canCache)
30
- cache.set(mod, to);
31
17
  return to;
32
18
  };
33
19
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
@@ -2595,6 +2581,31 @@ var findTextPatternMatch = (line, pattern) => {
2595
2581
  length: Math.max(1, matched[0]?.length ?? 0)
2596
2582
  };
2597
2583
  };
2584
+ // ../argus-core/dist/auth/cookies.js
2585
+ var TRACKING_COOKIE_PATTERNS = [/^_ga/i, /^_gid$/i, /^_ym/i, /^_fbp$/i, /^_hj/i, /^amplitude/i, /^mp_/i];
2586
+ var normalizeCookieDomainFilter = (domain) => {
2587
+ if (!domain) {
2588
+ return null;
2589
+ }
2590
+ const normalized = normalizeCookieDomain(domain);
2591
+ return normalized || null;
2592
+ };
2593
+ var matchesCookieDomain = (cookieDomain, domain) => {
2594
+ if (!domain) {
2595
+ return true;
2596
+ }
2597
+ const normalizedDomain = normalizeCookieDomain(cookieDomain);
2598
+ return normalizedDomain === domain || normalizedDomain.endsWith(`.${domain}`);
2599
+ };
2600
+ var getOriginHost = (origin) => {
2601
+ try {
2602
+ return new URL(origin).hostname;
2603
+ } catch {
2604
+ return null;
2605
+ }
2606
+ };
2607
+ var isTrackingCookieName = (name) => TRACKING_COOKIE_PATTERNS.some((pattern) => pattern.test(name));
2608
+ var normalizeCookieDomain = (domain) => domain.trim().toLowerCase().replace(/^\./, "");
2598
2609
  // dist/registry.js
2599
2610
  var loadRegistry = async () => {
2600
2611
  const { registry: registry2, warnings } = await readRegistry();
@@ -4156,6 +4167,10 @@ class NetBuffer {
4156
4167
  const filtered = this.events.filter((event) => event.id > after && matchesFilters2(event, filters));
4157
4168
  return filtered.slice(0, limit);
4158
4169
  }
4170
+ list(filters, limit = this.maxSize) {
4171
+ const filtered = this.events.filter((event) => matchesFilters2(event, filters));
4172
+ return filtered.slice(0, limit);
4173
+ }
4159
4174
  waitForAfter(after, filters, limit, timeoutMs) {
4160
4175
  const immediate = this.listAfter(after, filters, limit);
4161
4176
  if (immediate.length > 0) {
@@ -4501,6 +4516,77 @@ var handle5 = async (_req, res, url, ctx) => {
4501
4516
  respondJson(res, response);
4502
4517
  };
4503
4518
 
4519
+ // ../argus-watcher/dist/cdp/auth.js
4520
+ var inspectAuthCookies = async (session, options) => {
4521
+ const [origin, cookies2] = await Promise.all([capturePageOrigin(session), readCookies(session, options.includeValues === true)]);
4522
+ const normalizedDomain = normalizeCookieDomainFilter(options.domain);
4523
+ return {
4524
+ ok: true,
4525
+ origin,
4526
+ cookies: cookies2.filter((cookie) => matchesCookieDomain(cookie.domain, normalizedDomain))
4527
+ };
4528
+ };
4529
+ var readCookies = async (session, includeValues) => {
4530
+ const payload = await session.sendAndWait("Network.getCookies", {}, { timeoutMs: 5000 });
4531
+ const cookies2 = payload.cookies ?? [];
4532
+ return cookies2.map((cookie) => normalizeCookie(cookie, includeValues)).sort(compareCookies);
4533
+ };
4534
+ var normalizeCookie = (cookie, includeValues) => {
4535
+ const value = cookie.value ?? null;
4536
+ return {
4537
+ name: cookie.name ?? "",
4538
+ domain: cookie.domain ?? "",
4539
+ path: cookie.path ?? "/",
4540
+ value: includeValues ? value : undefined,
4541
+ valuePreview: value != null ? previewSecret(value) : null,
4542
+ secure: cookie.secure === true,
4543
+ httpOnly: cookie.httpOnly === true,
4544
+ session: cookie.session === true,
4545
+ expires: typeof cookie.expires === "number" && Number.isFinite(cookie.expires) ? cookie.expires : null,
4546
+ sameSite: cookie.sameSite ?? null
4547
+ };
4548
+ };
4549
+ var capturePageOrigin = async (session) => {
4550
+ const payload = await session.sendAndWait("Runtime.evaluate", {
4551
+ expression: `(() => {
4552
+ try {
4553
+ return new URL(location.href).origin
4554
+ } catch {
4555
+ throw new Error('Cannot determine origin: page is on a non-http URL (e.g., about:blank)')
4556
+ }
4557
+ })()`,
4558
+ awaitPromise: false,
4559
+ returnByValue: true
4560
+ }, { timeoutMs: 5000 });
4561
+ if (payload.exceptionDetails) {
4562
+ throw new Error(payload.exceptionDetails.exception?.description ?? payload.exceptionDetails.text ?? "Failed to inspect page auth cookies");
4563
+ }
4564
+ return String(payload.result?.value ?? "");
4565
+ };
4566
+ var previewSecret = (value) => {
4567
+ if (value.length <= 8) {
4568
+ return "*".repeat(value.length);
4569
+ }
4570
+ return `${value.slice(0, 4)}...${value.slice(-4)}`;
4571
+ };
4572
+ var compareCookies = (a, b) => a.domain.localeCompare(b.domain) || a.path.localeCompare(b.path) || a.name.localeCompare(b.name);
4573
+
4574
+ // ../argus-watcher/dist/http/routes/getAuthCookies.js
4575
+ var handle6 = async (_req, res, url, ctx) => {
4576
+ const domain = normalizeQueryValue2(url.searchParams.get("domain"));
4577
+ const includeValues = url.searchParams.get("includeValues") === "true";
4578
+ emitRequest(ctx, res, "auth/cookies", { domain, includeValues });
4579
+ try {
4580
+ const response = await inspectAuthCookies(ctx.cdpSession, {
4581
+ domain: domain ?? undefined,
4582
+ includeValues
4583
+ });
4584
+ respondJson(res, response);
4585
+ } catch (error) {
4586
+ respondError(res, error);
4587
+ }
4588
+ };
4589
+
4504
4590
  // ../argus-watcher/dist/cdp/remoteObject.js
4505
4591
  var serializeRemoteObjects = async (values, cdp) => {
4506
4592
  if (!cdp) {
@@ -4667,7 +4753,7 @@ var shouldMaterializeByValue = (record) => {
4667
4753
  };
4668
4754
 
4669
4755
  // ../argus-watcher/dist/http/routes/postEval.js
4670
- var handle6 = async (req, res, _url, ctx) => {
4756
+ var handle7 = async (req, res, _url, ctx) => {
4671
4757
  const payload = await readJsonBody(req, res);
4672
4758
  if (!payload) {
4673
4759
  return;
@@ -4691,7 +4777,7 @@ var handle6 = async (req, res, _url, ctx) => {
4691
4777
  };
4692
4778
 
4693
4779
  // ../argus-watcher/dist/http/routes/postTraceStart.js
4694
- var handle7 = async (req, res, _url, ctx) => {
4780
+ var handle8 = async (req, res, _url, ctx) => {
4695
4781
  const payload = await readJsonBody(req, res);
4696
4782
  if (!payload) {
4697
4783
  return;
@@ -4706,7 +4792,7 @@ var handle7 = async (req, res, _url, ctx) => {
4706
4792
  };
4707
4793
 
4708
4794
  // ../argus-watcher/dist/http/routes/postTraceStop.js
4709
- var handle8 = async (req, res, _url, ctx) => {
4795
+ var handle9 = async (req, res, _url, ctx) => {
4710
4796
  const payload = await readJsonBody(req, res);
4711
4797
  if (!payload) {
4712
4798
  return;
@@ -4721,7 +4807,7 @@ var handle8 = async (req, res, _url, ctx) => {
4721
4807
  };
4722
4808
 
4723
4809
  // ../argus-watcher/dist/http/routes/postScreenshot.js
4724
- var handle9 = async (req, res, _url, ctx) => {
4810
+ var handle10 = async (req, res, _url, ctx) => {
4725
4811
  const payload = await readJsonBody(req, res);
4726
4812
  if (!payload) {
4727
4813
  return;
@@ -4976,7 +5062,7 @@ var countNodes = (nodes) => {
4976
5062
  };
4977
5063
 
4978
5064
  // ../argus-watcher/dist/http/routes/postSnapshot.js
4979
- var handle10 = async (req, res, _url, ctx) => {
5065
+ var handle11 = async (req, res, _url, ctx) => {
4980
5066
  const payload = await readJsonBody(req, res);
4981
5067
  if (!payload) {
4982
5068
  return;
@@ -5001,7 +5087,7 @@ var handle10 = async (req, res, _url, ctx) => {
5001
5087
  };
5002
5088
 
5003
5089
  // ../argus-watcher/dist/http/routes/postCodeList.js
5004
- var handle11 = async (req, res, _url, ctx) => {
5090
+ var handle12 = async (req, res, _url, ctx) => {
5005
5091
  const payload = await readJsonBody(req, res);
5006
5092
  if (!payload) {
5007
5093
  return;
@@ -5019,7 +5105,7 @@ var handle11 = async (req, res, _url, ctx) => {
5019
5105
  };
5020
5106
 
5021
5107
  // ../argus-watcher/dist/http/routes/postCodeRead.js
5022
- var handle12 = async (req, res, _url, ctx) => {
5108
+ var handle13 = async (req, res, _url, ctx) => {
5023
5109
  const payload = await readJsonBody(req, res);
5024
5110
  if (!payload) {
5025
5111
  return;
@@ -5047,7 +5133,7 @@ var handle12 = async (req, res, _url, ctx) => {
5047
5133
  };
5048
5134
 
5049
5135
  // ../argus-watcher/dist/http/routes/postCodeGrep.js
5050
- var handle13 = async (req, res, _url, ctx) => {
5136
+ var handle14 = async (req, res, _url, ctx) => {
5051
5137
  const payload = await readJsonBody(req, res);
5052
5138
  if (!payload) {
5053
5139
  return;
@@ -5505,7 +5591,7 @@ var fillResolvedNodes = async (session, nodeIds, value) => {
5505
5591
  return nodeIds.length;
5506
5592
  };
5507
5593
  // ../argus-watcher/dist/http/routes/postDomTree.js
5508
- var handle14 = async (req, res, _url, ctx) => {
5594
+ var handle15 = async (req, res, _url, ctx) => {
5509
5595
  const payload = await readJsonBody(req, res);
5510
5596
  if (!payload) {
5511
5597
  return;
@@ -5542,7 +5628,7 @@ var handle14 = async (req, res, _url, ctx) => {
5542
5628
  };
5543
5629
 
5544
5630
  // ../argus-watcher/dist/http/routes/postDomInfo.js
5545
- var handle15 = async (req, res, _url, ctx) => {
5631
+ var handle16 = async (req, res, _url, ctx) => {
5546
5632
  const payload = await readJsonBody(req, res);
5547
5633
  if (!payload) {
5548
5634
  return;
@@ -5767,7 +5853,7 @@ var createNotInteractableError = (message) => {
5767
5853
  };
5768
5854
 
5769
5855
  // ../argus-watcher/dist/http/routes/postDomHover.js
5770
- var handle16 = async (req, res, _url, ctx) => {
5856
+ var handle17 = async (req, res, _url, ctx) => {
5771
5857
  const payload = await readJsonBody(req, res);
5772
5858
  if (!payload) {
5773
5859
  return;
@@ -5804,7 +5890,7 @@ var handle16 = async (req, res, _url, ctx) => {
5804
5890
  };
5805
5891
 
5806
5892
  // ../argus-watcher/dist/http/routes/postDomClick.js
5807
- var handle17 = async (req, res, _url, ctx) => {
5893
+ var handle18 = async (req, res, _url, ctx) => {
5808
5894
  const payload = await readJsonBody(req, res);
5809
5895
  if (!payload) {
5810
5896
  return;
@@ -5998,7 +6084,7 @@ var dispatchKeydown = async (session, options) => {
5998
6084
  };
5999
6085
 
6000
6086
  // ../argus-watcher/dist/http/routes/postDomKeydown.js
6001
- var handle18 = async (req, res, _url, ctx) => {
6087
+ var handle19 = async (req, res, _url, ctx) => {
6002
6088
  const payload = await readJsonBody(req, res);
6003
6089
  if (!payload) {
6004
6090
  return;
@@ -6030,7 +6116,7 @@ var handle18 = async (req, res, _url, ctx) => {
6030
6116
  };
6031
6117
 
6032
6118
  // ../argus-watcher/dist/http/routes/postDomAdd.js
6033
- var handle19 = async (req, res, _url, ctx) => {
6119
+ var handle20 = async (req, res, _url, ctx) => {
6034
6120
  const payload = await readJsonBody(req, res);
6035
6121
  if (!payload) {
6036
6122
  return;
@@ -6123,7 +6209,7 @@ var selectDomAddNodeIds = (allNodeIds, options) => {
6123
6209
  };
6124
6210
 
6125
6211
  // ../argus-watcher/dist/http/routes/postDomRemove.js
6126
- var handle20 = async (req, res, _url, ctx) => {
6212
+ var handle21 = async (req, res, _url, ctx) => {
6127
6213
  const payload = await readJsonBody(req, res);
6128
6214
  if (!payload) {
6129
6215
  return;
@@ -6159,7 +6245,7 @@ var handle20 = async (req, res, _url, ctx) => {
6159
6245
  };
6160
6246
 
6161
6247
  // ../argus-watcher/dist/http/routes/postDomModify.js
6162
- var handle21 = async (req, res, _url, ctx) => {
6248
+ var handle22 = async (req, res, _url, ctx) => {
6163
6249
  const payload = await readJsonBody(req, res);
6164
6250
  if (!payload) {
6165
6251
  return;
@@ -6201,7 +6287,7 @@ var handle21 = async (req, res, _url, ctx) => {
6201
6287
  };
6202
6288
 
6203
6289
  // ../argus-watcher/dist/http/routes/postDomSetFile.js
6204
- var handle22 = async (req, res, _url, ctx) => {
6290
+ var handle23 = async (req, res, _url, ctx) => {
6205
6291
  const payload = await readJsonBody(req, res);
6206
6292
  if (!payload) {
6207
6293
  return;
@@ -6254,7 +6340,7 @@ var handle22 = async (req, res, _url, ctx) => {
6254
6340
  };
6255
6341
 
6256
6342
  // ../argus-watcher/dist/http/routes/postDomFocus.js
6257
- var handle23 = async (req, res, _url, ctx) => {
6343
+ var handle24 = async (req, res, _url, ctx) => {
6258
6344
  const payload = await readJsonBody(req, res);
6259
6345
  if (!payload) {
6260
6346
  return;
@@ -6291,7 +6377,7 @@ var handle23 = async (req, res, _url, ctx) => {
6291
6377
  };
6292
6378
 
6293
6379
  // ../argus-watcher/dist/http/routes/postDomFill.js
6294
- var handle24 = async (req, res, _url, ctx) => {
6380
+ var handle25 = async (req, res, _url, ctx) => {
6295
6381
  const payload = await readJsonBody(req, res);
6296
6382
  if (!payload) {
6297
6383
  return;
@@ -6344,7 +6430,7 @@ var handle24 = async (req, res, _url, ctx) => {
6344
6430
  };
6345
6431
 
6346
6432
  // ../argus-watcher/dist/http/routes/postDomScroll.js
6347
- var handle25 = async (req, res, _url, ctx) => {
6433
+ var handle26 = async (req, res, _url, ctx) => {
6348
6434
  const payload = await readJsonBody(req, res);
6349
6435
  if (!payload) {
6350
6436
  return;
@@ -6413,7 +6499,7 @@ var getViewportSize = async (session) => {
6413
6499
  };
6414
6500
 
6415
6501
  // ../argus-watcher/dist/http/routes/postDomScrollTo.js
6416
- var handle26 = async (req, res, _url, ctx) => {
6502
+ var handle27 = async (req, res, _url, ctx) => {
6417
6503
  const payload = await readJsonBody(req, res);
6418
6504
  if (!payload) {
6419
6505
  return;
@@ -6472,14 +6558,14 @@ var handle26 = async (req, res, _url, ctx) => {
6472
6558
  };
6473
6559
 
6474
6560
  // ../argus-watcher/dist/http/routes/getEmulation.js
6475
- var handle27 = (_req, res, _url, ctx) => {
6561
+ var handle28 = (_req, res, _url, ctx) => {
6476
6562
  emitRequest(ctx, res, "emulation");
6477
6563
  const status = ctx.emulationController.getStatus({ attached: ctx.getCdpStatus().attached });
6478
6564
  respondJson(res, status);
6479
6565
  };
6480
6566
 
6481
6567
  // ../argus-watcher/dist/http/routes/postEmulation.js
6482
- var handle28 = async (req, res, _url, ctx) => {
6568
+ var handle29 = async (req, res, _url, ctx) => {
6483
6569
  const payload = await readJsonBody(req, res);
6484
6570
  if (!payload) {
6485
6571
  return;
@@ -6542,14 +6628,14 @@ var handle28 = async (req, res, _url, ctx) => {
6542
6628
  };
6543
6629
 
6544
6630
  // ../argus-watcher/dist/http/routes/getThrottle.js
6545
- var handle29 = (_req, res, _url, ctx) => {
6631
+ var handle30 = (_req, res, _url, ctx) => {
6546
6632
  emitRequest(ctx, res, "throttle");
6547
6633
  const status = ctx.throttleController.getStatus({ attached: ctx.getCdpStatus().attached });
6548
6634
  respondJson(res, status);
6549
6635
  };
6550
6636
 
6551
6637
  // ../argus-watcher/dist/http/routes/postThrottle.js
6552
- var handle30 = async (req, res, _url, ctx) => {
6638
+ var handle31 = async (req, res, _url, ctx) => {
6553
6639
  const payload = await readJsonBody(req, res);
6554
6640
  if (!payload) {
6555
6641
  return;
@@ -6647,7 +6733,7 @@ var buildActionCode = (action, key, value) => {
6647
6733
  };
6648
6734
 
6649
6735
  // ../argus-watcher/dist/http/routes/postStorageLocal.js
6650
- var handle31 = async (req, res, _url, ctx) => {
6736
+ var handle32 = async (req, res, _url, ctx) => {
6651
6737
  const payload = await readJsonBody(req, res);
6652
6738
  if (!payload) {
6653
6739
  return;
@@ -6672,7 +6758,7 @@ var handle31 = async (req, res, _url, ctx) => {
6672
6758
  };
6673
6759
 
6674
6760
  // ../argus-watcher/dist/http/routes/postReload.js
6675
- var handle32 = async (req, res, _url, ctx) => {
6761
+ var handle33 = async (req, res, _url, ctx) => {
6676
6762
  const payload = await readJsonBody(req, res);
6677
6763
  if (!payload) {
6678
6764
  return;
@@ -6690,7 +6776,7 @@ var handle32 = async (req, res, _url, ctx) => {
6690
6776
  };
6691
6777
 
6692
6778
  // ../argus-watcher/dist/http/routes/postShutdown.js
6693
- var handle33 = (_req, res, _url, ctx) => {
6779
+ var handle34 = (_req, res, _url, ctx) => {
6694
6780
  emitRequest(ctx, res, "shutdown");
6695
6781
  const response = { ok: true };
6696
6782
  respondJson(res, response);
@@ -6702,7 +6788,7 @@ var handle33 = (_req, res, _url, ctx) => {
6702
6788
  };
6703
6789
 
6704
6790
  // ../argus-watcher/dist/http/routes/getTargets.js
6705
- var handle34 = async (_req, res, _url, ctx) => {
6791
+ var handle35 = async (_req, res, _url, ctx) => {
6706
6792
  if (!ctx.sourceHandle?.listTargets) {
6707
6793
  return respondJson(res, { ok: false, error: { message: "Not available", code: "not_available" } }, 400);
6708
6794
  }
@@ -6716,7 +6802,7 @@ var handle34 = async (_req, res, _url, ctx) => {
6716
6802
  };
6717
6803
 
6718
6804
  // ../argus-watcher/dist/http/routes/postAttach.js
6719
- var handle35 = async (req, res, _url, ctx) => {
6805
+ var handle36 = async (req, res, _url, ctx) => {
6720
6806
  if (!ctx.sourceHandle?.attachTarget) {
6721
6807
  return respondJson(res, { ok: false, error: { message: "Not available", code: "not_available" } }, 400);
6722
6808
  }
@@ -6738,7 +6824,7 @@ var handle35 = async (req, res, _url, ctx) => {
6738
6824
  };
6739
6825
 
6740
6826
  // ../argus-watcher/dist/http/routes/postDetach.js
6741
- var handle36 = async (req, res, _url, ctx) => {
6827
+ var handle37 = async (req, res, _url, ctx) => {
6742
6828
  if (!ctx.sourceHandle?.detachTarget) {
6743
6829
  return respondJson(res, { ok: false, error: { message: "Not available", code: "not_available" } }, 400);
6744
6830
  }
@@ -6766,37 +6852,38 @@ var routes = {
6766
6852
  "GET /tail": { handler: handle3 },
6767
6853
  "GET /net": { handler: handle4 },
6768
6854
  "GET /net/tail": { handler: handle5 },
6769
- "POST /eval": { handler: handle6 },
6770
- "POST /trace/start": { handler: handle7 },
6771
- "POST /trace/stop": { handler: handle8 },
6772
- "POST /screenshot": { handler: handle9 },
6773
- "POST /snapshot": { handler: handle10 },
6774
- "POST /code/list": { handler: handle11 },
6775
- "POST /code/read": { handler: handle12 },
6776
- "POST /code/grep": { handler: handle13 },
6777
- "POST /dom/tree": { handler: handle14 },
6778
- "POST /dom/info": { handler: handle15 },
6779
- "POST /dom/hover": { handler: handle16 },
6780
- "POST /dom/click": { handler: handle17 },
6781
- "POST /dom/keydown": { handler: handle18 },
6782
- "POST /dom/add": { handler: handle19 },
6783
- "POST /dom/remove": { handler: handle20 },
6784
- "POST /dom/modify": { handler: handle21 },
6785
- "POST /dom/set-file": { handler: handle22 },
6786
- "POST /dom/focus": { handler: handle23 },
6787
- "POST /dom/fill": { handler: handle24 },
6788
- "POST /dom/scroll": { handler: handle25 },
6789
- "POST /dom/scroll-to": { handler: handle26 },
6790
- "GET /emulation": { handler: handle27 },
6791
- "POST /emulation": { handler: handle28 },
6792
- "GET /throttle": { handler: handle29 },
6793
- "POST /throttle": { handler: handle30 },
6794
- "POST /storage/local": { handler: handle31 },
6795
- "POST /reload": { handler: handle32 },
6796
- "POST /shutdown": { handler: handle33 },
6797
- "GET /targets": { handler: handle34, extensionOnly: true },
6798
- "POST /attach": { handler: handle35, extensionOnly: true },
6799
- "POST /detach": { handler: handle36, extensionOnly: true }
6855
+ "GET /auth/cookies": { handler: handle6 },
6856
+ "POST /eval": { handler: handle7 },
6857
+ "POST /trace/start": { handler: handle8 },
6858
+ "POST /trace/stop": { handler: handle9 },
6859
+ "POST /screenshot": { handler: handle10 },
6860
+ "POST /snapshot": { handler: handle11 },
6861
+ "POST /code/list": { handler: handle12 },
6862
+ "POST /code/read": { handler: handle13 },
6863
+ "POST /code/grep": { handler: handle14 },
6864
+ "POST /dom/tree": { handler: handle15 },
6865
+ "POST /dom/info": { handler: handle16 },
6866
+ "POST /dom/hover": { handler: handle17 },
6867
+ "POST /dom/click": { handler: handle18 },
6868
+ "POST /dom/keydown": { handler: handle19 },
6869
+ "POST /dom/add": { handler: handle20 },
6870
+ "POST /dom/remove": { handler: handle21 },
6871
+ "POST /dom/modify": { handler: handle22 },
6872
+ "POST /dom/set-file": { handler: handle23 },
6873
+ "POST /dom/focus": { handler: handle24 },
6874
+ "POST /dom/fill": { handler: handle25 },
6875
+ "POST /dom/scroll": { handler: handle26 },
6876
+ "POST /dom/scroll-to": { handler: handle27 },
6877
+ "GET /emulation": { handler: handle28 },
6878
+ "POST /emulation": { handler: handle29 },
6879
+ "GET /throttle": { handler: handle30 },
6880
+ "POST /throttle": { handler: handle31 },
6881
+ "POST /storage/local": { handler: handle32 },
6882
+ "POST /reload": { handler: handle33 },
6883
+ "POST /shutdown": { handler: handle34 },
6884
+ "GET /targets": { handler: handle35, extensionOnly: true },
6885
+ "POST /attach": { handler: handle36, extensionOnly: true },
6886
+ "POST /detach": { handler: handle37, extensionOnly: true }
6800
6887
  };
6801
6888
  var dispatch = (req, res, url, ctx) => {
6802
6889
  const entry = routes[`${req.method} ${url.pathname}`];
@@ -7198,6 +7285,17 @@ var compileRule = (pattern) => {
7198
7285
 
7199
7286
  // ../argus-watcher/dist/cdp/redaction.js
7200
7287
  var SENSITIVE_KEYS = new Set(["token", "access_token", "auth", "authorization", "code", "password", "pass"]);
7288
+ var AUTH_HEADER_NAMES = new Set([
7289
+ "authorization",
7290
+ "cookie",
7291
+ "x-api-key",
7292
+ "x-auth-token",
7293
+ "x-csrf-token",
7294
+ "x-csrftoken",
7295
+ "x-xsrf-token",
7296
+ "csrf-token",
7297
+ "xsrf-token"
7298
+ ]);
7201
7299
  var redactUrl = (value) => {
7202
7300
  if (!value) {
7203
7301
  return value;
@@ -7229,6 +7327,76 @@ var redactUrl = (value) => {
7229
7327
  url.search = search ? `?${search}` : "";
7230
7328
  return url.toString();
7231
7329
  };
7330
+ var pickCapturedAuthHeaders = (headers) => {
7331
+ if (!headers) {
7332
+ return;
7333
+ }
7334
+ const captured = {};
7335
+ for (const [name, rawValue] of Object.entries(headers)) {
7336
+ const normalizedName = name.trim().toLowerCase();
7337
+ if (!normalizedName || !AUTH_HEADER_NAMES.has(normalizedName)) {
7338
+ continue;
7339
+ }
7340
+ const value = normalizeHeaderValue(rawValue);
7341
+ if (!value) {
7342
+ continue;
7343
+ }
7344
+ captured[normalizedName] = redactHeaderValue(normalizedName, value);
7345
+ }
7346
+ return Object.keys(captured).length > 0 ? captured : undefined;
7347
+ };
7348
+ var mergeCapturedAuthHeaders = (current, incoming) => {
7349
+ if (!current) {
7350
+ return incoming;
7351
+ }
7352
+ if (!incoming) {
7353
+ return current;
7354
+ }
7355
+ return { ...current, ...incoming };
7356
+ };
7357
+ var normalizeHeaderValue = (value) => {
7358
+ if (typeof value === "string") {
7359
+ const trimmed = value.trim();
7360
+ return trimmed || null;
7361
+ }
7362
+ if (typeof value === "number" || typeof value === "boolean") {
7363
+ return String(value);
7364
+ }
7365
+ if (Array.isArray(value)) {
7366
+ const joined = value.map((item) => normalizeHeaderValue(item)).filter((item) => Boolean(item)).join(", ");
7367
+ return joined || null;
7368
+ }
7369
+ return null;
7370
+ };
7371
+ var redactHeaderValue = (name, value) => {
7372
+ if (name === "authorization") {
7373
+ return redactAuthorizationHeader(value);
7374
+ }
7375
+ if (name === "cookie") {
7376
+ return redactCookieHeader(value);
7377
+ }
7378
+ return redactToken(value);
7379
+ };
7380
+ var redactAuthorizationHeader = (value) => {
7381
+ const match = value.match(/^([A-Za-z]+)\s+(.+)$/);
7382
+ if (!match) {
7383
+ return redactToken(value);
7384
+ }
7385
+ return `${match[1]} ${redactToken(match[2])}`;
7386
+ };
7387
+ var redactCookieHeader = (value) => {
7388
+ const parts = value.split(";").map((entry) => entry.trim()).filter(Boolean).map((entry) => {
7389
+ const [name] = entry.split("=");
7390
+ return name ? `${name}=<redacted>` : null;
7391
+ }).filter((entry) => Boolean(entry));
7392
+ return parts.join("; ");
7393
+ };
7394
+ var redactToken = (value) => {
7395
+ if (value.length <= 8) {
7396
+ return "*".repeat(value.length);
7397
+ }
7398
+ return `${value.slice(0, 4)}...${value.slice(-4)}`;
7399
+ };
7232
7400
 
7233
7401
  // ../argus-watcher/dist/cdp/networkCapture.js
7234
7402
  var createNetworkCapture = (options) => {
@@ -7242,6 +7410,7 @@ var createNetworkCapture = (options) => {
7242
7410
  requestId,
7243
7411
  url: "",
7244
7412
  method: "GET",
7413
+ requestHeaders: undefined,
7245
7414
  resourceType: null,
7246
7415
  status: null,
7247
7416
  encodedDataLength: null,
@@ -7264,6 +7433,7 @@ var createNetworkCapture = (options) => {
7264
7433
  requestId: record.requestId,
7265
7434
  url: redactUrl(record.url),
7266
7435
  method: record.method,
7436
+ requestHeaders: record.requestHeaders,
7267
7437
  resourceType: record.resourceType,
7268
7438
  status: record.status,
7269
7439
  encodedDataLength: record.encodedDataLength,
@@ -7281,9 +7451,19 @@ var createNetworkCapture = (options) => {
7281
7451
  const entry = getOrCreate(requestId);
7282
7452
  entry.url = payload.request?.url ?? entry.url;
7283
7453
  entry.method = payload.request?.method ?? entry.method;
7454
+ entry.requestHeaders = mergeCapturedAuthHeaders(entry.requestHeaders, pickCapturedAuthHeaders(payload.request?.headers));
7284
7455
  entry.resourceType = payload.type ?? entry.resourceType;
7285
7456
  entry.startTime = typeof payload.timestamp === "number" ? payload.timestamp : entry.startTime;
7286
7457
  });
7458
+ options.session.onEvent("Network.requestWillBeSentExtraInfo", (params) => {
7459
+ const payload = params;
7460
+ const requestId = payload.requestId;
7461
+ if (!requestId) {
7462
+ return;
7463
+ }
7464
+ const entry = getOrCreate(requestId);
7465
+ entry.requestHeaders = mergeCapturedAuthHeaders(entry.requestHeaders, pickCapturedAuthHeaders(payload.headers));
7466
+ });
7287
7467
  options.session.onEvent("Network.responseReceived", (params) => {
7288
7468
  const payload = params;
7289
7469
  const requestId = payload.requestId;
@@ -7292,6 +7472,7 @@ var createNetworkCapture = (options) => {
7292
7472
  }
7293
7473
  const entry = getOrCreate(requestId);
7294
7474
  entry.status = typeof payload.response?.status === "number" ? payload.response.status : entry.status;
7475
+ entry.requestHeaders = mergeCapturedAuthHeaders(entry.requestHeaders, pickCapturedAuthHeaders(payload.response?.requestHeaders));
7295
7476
  entry.resourceType = payload.type ?? entry.resourceType;
7296
7477
  });
7297
7478
  options.session.onEvent("Network.loadingFinished", (params) => {
@@ -9735,7 +9916,7 @@ class SessionManager {
9735
9916
  const enabledDomains = new Set;
9736
9917
  const tabHandlers = new Map;
9737
9918
  this.eventHandlers.set(tabId, tabHandlers);
9738
- const handle37 = {
9919
+ const handle38 = {
9739
9920
  isAttached: () => this.sessions.has(tabId),
9740
9921
  sendAndWait: async (method, params, options) => {
9741
9922
  if (!this.sessions.has(tabId)) {
@@ -9780,7 +9961,7 @@ class SessionManager {
9780
9961
  attachedAt: Date.now(),
9781
9962
  topFrameId: message.topFrameId ?? null,
9782
9963
  frames: message.frames ?? [],
9783
- handle: handle37,
9964
+ handle: handle38,
9784
9965
  enabledDomains
9785
9966
  };
9786
9967
  this.sessions.set(tabId, session);
@@ -10067,6 +10248,7 @@ var createExtensionSource = (options) => {
10067
10248
  let currentSession = null;
10068
10249
  let stopping = false;
10069
10250
  const frameStateByTabId = new Map;
10251
+ const delegatingSessions = new Set;
10070
10252
  const getCurrentExtensionSession = () => {
10071
10253
  if (!currentSession) {
10072
10254
  throw createNotAttachedError();
@@ -10077,6 +10259,7 @@ var createExtensionSource = (options) => {
10077
10259
  onAttach: (session) => {
10078
10260
  console.error(`[ExtensionSource] Tab attached: ${session.tabId} - ${session.url}`);
10079
10261
  currentSession = session;
10262
+ rebindDelegatingSessions();
10080
10263
  seedFrameState(session);
10081
10264
  bootstrapAttachedSession(session);
10082
10265
  },
@@ -10085,6 +10268,7 @@ var createExtensionSource = (options) => {
10085
10268
  if (currentSession?.tabId === tabId) {
10086
10269
  currentSession = null;
10087
10270
  }
10271
+ rebindDelegatingSessions();
10088
10272
  frameStateByTabId.delete(tabId);
10089
10273
  emitStatus(null, reason);
10090
10274
  events.onDetach?.(reason);
@@ -10129,6 +10313,7 @@ var createExtensionSource = (options) => {
10129
10313
  });
10130
10314
  const stop = async () => {
10131
10315
  stopping = true;
10316
+ disposeDelegatingSessions();
10132
10317
  messaging.stop();
10133
10318
  };
10134
10319
  const listTargets = async () => {
@@ -10184,6 +10369,16 @@ var createExtensionSource = (options) => {
10184
10369
  pid: hostInfo.watcherPid
10185
10370
  });
10186
10371
  }
10372
+ function rebindDelegatingSessions() {
10373
+ for (const controller of delegatingSessions) {
10374
+ controller.rebind();
10375
+ }
10376
+ }
10377
+ function disposeDelegatingSessions() {
10378
+ for (const controller of delegatingSessions) {
10379
+ controller.dispose();
10380
+ }
10381
+ }
10187
10382
  async function bootstrapAttachedSession(session) {
10188
10383
  try {
10189
10384
  registerSessionEventHandlers(session);
@@ -10472,6 +10667,31 @@ var createExtensionSource = (options) => {
10472
10667
  }
10473
10668
  }
10474
10669
  function createDelegatingSession(config) {
10670
+ const subscriptions = new Set;
10671
+ const rebindSubscriptions = () => {
10672
+ for (const subscription of subscriptions) {
10673
+ subscription.unbind();
10674
+ if (!currentSession) {
10675
+ continue;
10676
+ }
10677
+ subscription.off = currentSession.handle.onEvent(subscription.method, subscription.handler);
10678
+ }
10679
+ };
10680
+ const disposeSubscriptions = () => {
10681
+ for (const subscription of subscriptions) {
10682
+ subscription.unbind();
10683
+ }
10684
+ subscriptions.clear();
10685
+ };
10686
+ const controller = {
10687
+ rebind: rebindSubscriptions,
10688
+ dispose: () => {
10689
+ disposeSubscriptions();
10690
+ delegatingSessions.delete(controller);
10691
+ }
10692
+ };
10693
+ delegatingSessions.add(controller);
10694
+ controller.rebind();
10475
10695
  return {
10476
10696
  isAttached: () => currentSession?.handle.isAttached() ?? false,
10477
10697
  sendAndWait: async (method, params, options2) => {
@@ -10482,10 +10702,13 @@ var createExtensionSource = (options) => {
10482
10702
  return session.handle.sendAndWait(method, nextParams, nextOptions);
10483
10703
  },
10484
10704
  onEvent: (method, handler) => {
10485
- if (!currentSession) {
10486
- return () => {};
10487
- }
10488
- return currentSession.handle.onEvent(method, handler);
10705
+ const subscription = createDelegatingEventSubscription(method, handler);
10706
+ subscriptions.add(subscription);
10707
+ controller.rebind();
10708
+ return () => {
10709
+ subscription.unbind();
10710
+ subscriptions.delete(subscription);
10711
+ };
10489
10712
  },
10490
10713
  getTargetContext: config.getTargetContext
10491
10714
  };
@@ -10499,6 +10722,15 @@ var tabToTarget = (tab) => ({
10499
10722
  faviconUrl: tab.faviconUrl,
10500
10723
  attached: tab.attached
10501
10724
  });
10725
+ var createDelegatingEventSubscription = (method, handler) => ({
10726
+ method,
10727
+ handler,
10728
+ off: null,
10729
+ unbind() {
10730
+ this.off?.();
10731
+ this.off = null;
10732
+ }
10733
+ });
10502
10734
 
10503
10735
  // ../argus-watcher/dist/index.js
10504
10736
  var startWatcher = async (options) => {
@@ -10520,7 +10752,7 @@ var startWatcher = async (options) => {
10520
10752
  const logsDir = path7.join(artifactsBaseDir, "logs");
10521
10753
  const includeTimestamps = options.artifacts?.logs?.includeTimestamps ?? false;
10522
10754
  const maxFiles = resolveMaxFiles(options.artifacts?.logs?.maxFiles);
10523
- const netEnabled = sourceMode === "cdp" && options.net?.enabled === true;
10755
+ const netEnabled = options.net?.enabled === true;
10524
10756
  const pageConsoleLogging = options.pageConsoleLogging ?? "minimal";
10525
10757
  const events = new Emittery;
10526
10758
  const buffer = new LogBuffer(bufferSize);
@@ -10672,6 +10904,37 @@ var startWatcher = async (options) => {
10672
10904
  console.warn(`[Watcher] Failed to run inject script for watcher ${record.id}: ${formatError4(error)}`);
10673
10905
  }
10674
10906
  };
10907
+ const handleSourceLog = (event) => {
10908
+ buffer.add(event);
10909
+ fileLogger?.writeEvent(event);
10910
+ };
10911
+ const handlePageNavigation = (info) => {
10912
+ fileLogger?.rotate(info);
10913
+ onIndicatorNavigation(getIndicatorSession(), info);
10914
+ runtimeEditor?.reset();
10915
+ };
10916
+ const handlePageIntl = (info) => {
10917
+ fileLogger?.setPageIntl(info);
10918
+ };
10919
+ const handleSourceAttach = async (session, target) => {
10920
+ runtimeEditor?.rebind();
10921
+ await emulationController.onAttach(session);
10922
+ await throttleController.onAttach(session);
10923
+ await networkCapture?.onAttached();
10924
+ onIndicatorAttach(session, target);
10925
+ await maybeInjectOnAttach(session, target);
10926
+ };
10927
+ const handleTargetChanged = (session, target) => {
10928
+ onIndicatorAttach(session, target);
10929
+ };
10930
+ const handleSourceDetach = (reason) => {
10931
+ runtimeEditor?.rebind();
10932
+ networkCapture?.onDetached();
10933
+ indicatorController?.onDetach();
10934
+ if (reason != null) {
10935
+ traceRecorder.onDetached(reason);
10936
+ }
10937
+ };
10675
10938
  let sourceHandle;
10676
10939
  let networkCapture = null;
10677
10940
  let traceRecorder;
@@ -10680,33 +10943,15 @@ var startWatcher = async (options) => {
10680
10943
  if (sourceMode === "extension") {
10681
10944
  sourceHandle = createExtensionSource({
10682
10945
  events: {
10683
- onLog: (event) => {
10684
- buffer.add(event);
10685
- fileLogger?.writeEvent(event);
10686
- },
10946
+ onLog: handleSourceLog,
10687
10947
  onStatus: updateCdpStatus,
10688
- onPageNavigation: (info) => {
10689
- fileLogger?.rotate(info);
10690
- onIndicatorNavigation(getIndicatorSession(), info);
10691
- runtimeEditor?.reset();
10692
- },
10948
+ onPageNavigation: handlePageNavigation,
10693
10949
  onPageLoad: onIndicatorLoad,
10694
- onPageIntl: (info) => {
10695
- fileLogger?.setPageIntl(info);
10696
- },
10697
- onAttach: async (session, target) => {
10698
- runtimeEditor?.rebind();
10699
- await emulationController.onAttach(session);
10700
- await throttleController.onAttach(session);
10701
- onIndicatorAttach(session, target);
10702
- await maybeInjectOnAttach(session, target);
10703
- },
10704
- onTargetChanged: (session, target) => {
10705
- onIndicatorAttach(session, target);
10706
- },
10950
+ onPageIntl: handlePageIntl,
10951
+ onAttach: handleSourceAttach,
10952
+ onTargetChanged: handleTargetChanged,
10707
10953
  onDetach: () => {
10708
- runtimeEditor?.rebind();
10709
- indicatorController?.onDetach();
10954
+ handleSourceDetach();
10710
10955
  }
10711
10956
  },
10712
10957
  watcherId,
@@ -10715,6 +10960,7 @@ var startWatcher = async (options) => {
10715
10960
  ignoreMatcher: ignoreMatcher ? (url) => ignoreMatcher.matches(url) : null,
10716
10961
  stripUrlPrefixes: stripUrlPrefixes2
10717
10962
  });
10963
+ networkCapture = netBuffer ? createNetworkCapture({ session: sourceHandle.pageSession ?? sourceHandle.session, buffer: netBuffer }) : null;
10718
10964
  traceRecorder = createTraceRecorder({ session: sourceHandle.session, artifactsDir: artifactsBaseDir });
10719
10965
  screenshotter = createScreenshotter({ session: sourceHandle.session, artifactsDir: artifactsBaseDir });
10720
10966
  runtimeEditor = createRuntimeEditor(sourceHandle.session);
@@ -10728,33 +10974,14 @@ var startWatcher = async (options) => {
10728
10974
  match: options.match,
10729
10975
  sessionHandle,
10730
10976
  events: {
10731
- onLog: (event) => {
10732
- buffer.add(event);
10733
- fileLogger?.writeEvent(event);
10734
- },
10977
+ onLog: handleSourceLog,
10735
10978
  onStatus: updateCdpStatus,
10736
- onPageNavigation: (info) => {
10737
- fileLogger?.rotate(info);
10738
- onIndicatorNavigation(sessionHandle.session, info);
10739
- runtimeEditor?.reset();
10740
- },
10979
+ onPageNavigation: handlePageNavigation,
10741
10980
  onPageLoad: onIndicatorLoad,
10742
- onPageIntl: (info) => {
10743
- fileLogger?.setPageIntl(info);
10744
- },
10745
- onAttach: async (session, target) => {
10746
- runtimeEditor?.rebind();
10747
- await emulationController.onAttach(session);
10748
- await throttleController.onAttach(session);
10749
- await networkCapture?.onAttached();
10750
- onIndicatorAttach(session, target);
10751
- await maybeInjectOnAttach(session, target);
10752
- },
10981
+ onPageIntl: handlePageIntl,
10982
+ onAttach: handleSourceAttach,
10753
10983
  onDetach: (reason) => {
10754
- runtimeEditor?.rebind();
10755
- networkCapture?.onDetached();
10756
- traceRecorder.onDetached(reason);
10757
- indicatorController?.onDetach();
10984
+ handleSourceDetach(reason);
10758
10985
  }
10759
10986
  },
10760
10987
  watcherId,
@@ -11396,15 +11623,16 @@ var runStart = async (options) => {
11396
11623
  artifactsBaseDir = resolvePath(trimmed);
11397
11624
  }
11398
11625
  const inject = await resolveInjectScript(options.inject, output);
11399
- let handle37;
11626
+ let handle38;
11400
11627
  try {
11401
- handle37 = await startWatcher({
11628
+ handle38 = await startWatcher({
11402
11629
  id: watcherId,
11403
11630
  source: "cdp",
11404
11631
  match: Object.keys(match).length > 0 ? match : undefined,
11405
11632
  chrome: { host: chrome.cdpHost, port: chrome.cdpPort },
11406
11633
  host: "127.0.0.1",
11407
11634
  port: 0,
11635
+ net: { enabled: true },
11408
11636
  pageIndicator: options.pageIndicator === false ? { enabled: false } : { enabled: true },
11409
11637
  artifacts: artifactsBaseDir ? { base: artifactsBaseDir } : undefined,
11410
11638
  pageConsoleLogging: options.pageConsoleLogging,
@@ -11418,7 +11646,7 @@ var runStart = async (options) => {
11418
11646
  }
11419
11647
  const shutdown = async () => {
11420
11648
  try {
11421
- await handle37.close();
11649
+ await handle38.close();
11422
11650
  } catch {}
11423
11651
  await chrome.closeGracefully();
11424
11652
  };
@@ -11434,23 +11662,23 @@ var runStart = async (options) => {
11434
11662
  rmSync2(chrome.userDataDir, { recursive: true, force: true });
11435
11663
  } catch {}
11436
11664
  }
11437
- handle37.close().then(() => process.exit(0));
11665
+ handle38.close().then(() => process.exit(0));
11438
11666
  });
11439
- handle37.events.on("cdpAttached", ({ target }) => {
11667
+ handle38.events.on("cdpAttached", ({ target }) => {
11440
11668
  const typeInfo = target?.type ? ` (type: ${target.type})` : "";
11441
11669
  output.writeHuman(`[${watcherId}] CDP attached: ${target?.title} (${target?.url})${typeInfo}`);
11442
11670
  });
11443
- handle37.events.on("cdpDetached", ({ reason, target }) => {
11671
+ handle38.events.on("cdpDetached", ({ reason, target }) => {
11444
11672
  output.writeHuman(`[${watcherId}] CDP detached: ${reason} (last target: ${target?.title})`);
11445
11673
  });
11446
11674
  const result = {
11447
- id: handle37.watcher.id,
11675
+ id: handle38.watcher.id,
11448
11676
  chromePid: chrome.chrome.pid,
11449
11677
  cdpHost: chrome.cdpHost,
11450
11678
  cdpPort: chrome.cdpPort,
11451
- watcherHost: handle37.watcher.host,
11452
- watcherPort: handle37.watcher.port,
11453
- watcherPid: handle37.watcher.pid
11679
+ watcherHost: handle38.watcher.host,
11680
+ watcherPort: handle38.watcher.port,
11681
+ watcherPid: handle38.watcher.pid
11454
11682
  };
11455
11683
  if (options.json) {
11456
11684
  output.writeJson(result);
@@ -12271,15 +12499,16 @@ var runWatcherStart = async (options) => {
12271
12499
  if (options.parent?.trim()) {
12272
12500
  match.parent = options.parent.trim();
12273
12501
  }
12274
- let handle37;
12502
+ let handle38;
12275
12503
  try {
12276
- handle37 = await startWatcher({
12504
+ handle38 = await startWatcher({
12277
12505
  id: watcherId,
12278
12506
  source: sourceMode,
12279
12507
  match: sourceMode === "cdp" && Object.keys(match).length > 0 ? match : undefined,
12280
12508
  chrome: sourceMode === "cdp" ? { host: chromeHost, port: chromePort } : undefined,
12281
12509
  host: "127.0.0.1",
12282
12510
  port: 0,
12511
+ net: { enabled: true },
12283
12512
  pageIndicator: options.pageIndicator === false ? { enabled: false } : { enabled: true },
12284
12513
  artifacts: artifactsBaseDir ? { base: artifactsBaseDir } : undefined,
12285
12514
  pageConsoleLogging: options.pageConsoleLogging,
@@ -12291,10 +12520,10 @@ var runWatcherStart = async (options) => {
12291
12520
  return;
12292
12521
  }
12293
12522
  const result = {
12294
- id: handle37.watcher.id,
12295
- host: handle37.watcher.host,
12296
- port: handle37.watcher.port,
12297
- pid: handle37.watcher.pid,
12523
+ id: handle38.watcher.id,
12524
+ host: handle38.watcher.host,
12525
+ port: handle38.watcher.port,
12526
+ pid: handle38.watcher.pid,
12298
12527
  source: sourceMode,
12299
12528
  matchUrl: match.url,
12300
12529
  matchType: match.type,
@@ -12307,7 +12536,7 @@ var runWatcherStart = async (options) => {
12307
12536
  };
12308
12537
  const cleanup = async () => {
12309
12538
  try {
12310
- await handle37.close();
12539
+ await handle38.close();
12311
12540
  } catch {}
12312
12541
  };
12313
12542
  process.on("SIGINT", () => {
@@ -12316,12 +12545,12 @@ var runWatcherStart = async (options) => {
12316
12545
  process.on("SIGTERM", () => {
12317
12546
  cleanup().then(() => process.exit(0));
12318
12547
  });
12319
- handle37.events.on("cdpAttached", ({ target }) => {
12548
+ handle38.events.on("cdpAttached", ({ target }) => {
12320
12549
  const typeInfo = target?.type ? ` (type: ${target.type})` : "";
12321
- output.writeHuman(`[${handle37.watcher.id}] CDP attached: ${target?.title} (${target?.url})${typeInfo}`);
12550
+ output.writeHuman(`[${handle38.watcher.id}] CDP attached: ${target?.title} (${target?.url})${typeInfo}`);
12322
12551
  });
12323
- handle37.events.on("cdpDetached", ({ reason, target }) => {
12324
- output.writeHuman(`[${handle37.watcher.id}] CDP detached: ${reason} (last target: ${target?.title})`);
12552
+ handle38.events.on("cdpDetached", ({ reason, target }) => {
12553
+ output.writeHuman(`[${handle38.watcher.id}] CDP detached: ${reason} (last target: ${target?.title})`);
12325
12554
  });
12326
12555
  if (options.json) {
12327
12556
  output.writeJson(result);
@@ -12533,23 +12762,24 @@ var checkWatcherReachable = async (watcher) => {
12533
12762
  // dist/commands/watcherNativeHost.js
12534
12763
  var runWatcherNativeHost = async (options) => {
12535
12764
  const watcherId = options.id?.trim() || "extension";
12536
- let handle37;
12765
+ let handle38;
12537
12766
  try {
12538
- handle37 = await startWatcher({
12767
+ handle38 = await startWatcher({
12539
12768
  id: watcherId,
12540
12769
  source: "extension",
12541
12770
  host: "127.0.0.1",
12542
12771
  port: 0,
12772
+ net: { enabled: true },
12543
12773
  pageIndicator: { enabled: true }
12544
12774
  });
12545
12775
  } catch (error) {
12546
12776
  console.error(`Failed to start watcher: ${error instanceof Error ? error.message : error}`);
12547
12777
  process.exit(1);
12548
12778
  }
12549
- console.error(`[NativeHost] Watcher started: id=${handle37.watcher.id} port=${handle37.watcher.port}`);
12779
+ console.error(`[NativeHost] Watcher started: id=${handle38.watcher.id} port=${handle38.watcher.port}`);
12550
12780
  const cleanup = async () => {
12551
12781
  try {
12552
- await handle37.close();
12782
+ await handle38.close();
12553
12783
  } catch {}
12554
12784
  };
12555
12785
  process.on("SIGINT", () => {
@@ -13701,6 +13931,195 @@ Examples:
13701
13931
  });
13702
13932
  }
13703
13933
 
13934
+ // dist/commands/auth.js
13935
+ import { writeFile } from "node:fs/promises";
13936
+ var COOKIE_EXPORT_FORMATS = new Set(["netscape", "json", "header"]);
13937
+ var runAuthCookies = async (id, options) => {
13938
+ const output = createOutput(options);
13939
+ const includeValues = options.showValues === true;
13940
+ const response = await fetchAuthCookies(id, { domain: options.domain, includeValues }, output);
13941
+ if (!response) {
13942
+ return;
13943
+ }
13944
+ const cookies2 = filterCookies(response.origin, response.cookies, options);
13945
+ if (options.json) {
13946
+ output.writeJson({ ...response, cookies: cookies2 });
13947
+ return;
13948
+ }
13949
+ if (cookies2.length === 0) {
13950
+ output.writeHuman("No cookies matched.");
13951
+ return;
13952
+ }
13953
+ for (const cookie of cookies2) {
13954
+ output.writeHuman(formatCookieLine(cookie, includeValues));
13955
+ }
13956
+ };
13957
+ var runAuthExportCookies = async (id, options) => {
13958
+ const output = createOutput({});
13959
+ const format = normalizeExportFormat(options.format);
13960
+ if (!format) {
13961
+ output.writeWarn(`Invalid --format value: ${options.format}. Expected one of: netscape, json, header.`);
13962
+ process.exitCode = 2;
13963
+ return;
13964
+ }
13965
+ const response = await fetchAuthCookies(id, { domain: options.domain, includeValues: true }, output);
13966
+ if (!response) {
13967
+ return;
13968
+ }
13969
+ const serialized = serializeCookies(filterCookies(response.origin, response.cookies, options), format);
13970
+ await writeOutput(serialized, options.out);
13971
+ };
13972
+ var fetchAuthCookies = async (id, input, output) => {
13973
+ const result = await requestWatcherJson({
13974
+ id,
13975
+ path: "/auth/cookies",
13976
+ query: buildCookieQuery(input),
13977
+ timeoutMs: 1e4
13978
+ });
13979
+ if (!result.ok) {
13980
+ writeRequestError(result, output);
13981
+ return null;
13982
+ }
13983
+ return result.data;
13984
+ };
13985
+ var buildCookieQuery = (input) => {
13986
+ const params = new URLSearchParams;
13987
+ if (input.domain?.trim()) {
13988
+ params.set("domain", input.domain.trim());
13989
+ }
13990
+ if (input.includeValues) {
13991
+ params.set("includeValues", "true");
13992
+ }
13993
+ return params;
13994
+ };
13995
+ var filterCookies = (origin, cookies2, options) => {
13996
+ const originHost = options.forOrigin ? getOriginHost(origin) : null;
13997
+ return cookies2.filter((cookie) => matchesCookieFilters(cookie, originHost, options));
13998
+ };
13999
+ var matchesCookieFilters = (cookie, originHost, options) => {
14000
+ if (options.sessionOnly && !cookie.session) {
14001
+ return false;
14002
+ }
14003
+ if (options.httpOnly && !cookie.httpOnly) {
14004
+ return false;
14005
+ }
14006
+ if (options.secure && !cookie.secure) {
14007
+ return false;
14008
+ }
14009
+ if (originHost && !matchesCookieDomain(cookie.domain, originHost)) {
14010
+ return false;
14011
+ }
14012
+ if (options.excludeTracking && isTrackingCookieName(cookie.name)) {
14013
+ return false;
14014
+ }
14015
+ return true;
14016
+ };
14017
+ var formatCookieLine = (cookie, showValues) => {
14018
+ const flags = [formatExpiryFlag(cookie), cookie.httpOnly ? "httpOnly" : null, cookie.secure ? "secure" : null, formatSameSiteFlag(cookie)].filter(Boolean).join(",");
14019
+ const value = resolveCookieValue(cookie, showValues);
14020
+ const flagSuffix = flags ? ` [${flags}]` : "";
14021
+ const valueSuffix = value ? ` ${value}` : "";
14022
+ return `${cookie.name} ${cookie.domain}${cookie.path}${flagSuffix}${valueSuffix}`.trim();
14023
+ };
14024
+ var formatExpiryFlag = (cookie) => {
14025
+ if (cookie.session) {
14026
+ return "session";
14027
+ }
14028
+ if (cookie.expires != null) {
14029
+ return `exp=${Math.trunc(cookie.expires)}`;
14030
+ }
14031
+ return null;
14032
+ };
14033
+ var formatSameSiteFlag = (cookie) => {
14034
+ if (!cookie.sameSite) {
14035
+ return null;
14036
+ }
14037
+ return `sameSite=${cookie.sameSite}`;
14038
+ };
14039
+ var resolveCookieValue = (cookie, showValues) => {
14040
+ if (showValues && cookie.value != null) {
14041
+ return cookie.value;
14042
+ }
14043
+ return cookie.valuePreview ?? "";
14044
+ };
14045
+ var normalizeExportFormat = (format) => {
14046
+ if (!format)
14047
+ return "netscape";
14048
+ if (!COOKIE_EXPORT_FORMATS.has(format)) {
14049
+ return null;
14050
+ }
14051
+ switch (format) {
14052
+ case "netscape":
14053
+ case "json":
14054
+ case "header":
14055
+ return format;
14056
+ default:
14057
+ return null;
14058
+ }
14059
+ };
14060
+ var formatCookiesAsNetscape = (cookies2) => {
14061
+ const lines = ["# Netscape HTTP Cookie File", "# This file was generated by Argus.", ""];
14062
+ for (const cookie of cookies2) {
14063
+ lines.push([
14064
+ formatNetscapeDomain(cookie),
14065
+ cookie.domain.startsWith(".") ? "TRUE" : "FALSE",
14066
+ cookie.path,
14067
+ cookie.secure ? "TRUE" : "FALSE",
14068
+ String(cookie.session ? 0 : Math.max(0, Math.trunc(cookie.expires ?? 0))),
14069
+ cookie.name,
14070
+ cookie.value ?? ""
14071
+ ].join("\t"));
14072
+ }
14073
+ return lines.join(`
14074
+ `);
14075
+ };
14076
+ var formatNetscapeDomain = (cookie) => cookie.httpOnly ? `#HttpOnly_${cookie.domain}` : cookie.domain;
14077
+ var formatCookiesAsHeader = (cookies2) => `Cookie: ${cookies2.map((cookie) => `${cookie.name}=${cookie.value ?? ""}`).join("; ")}`;
14078
+ var serializeCookies = (cookies2, format) => {
14079
+ switch (format) {
14080
+ case "netscape":
14081
+ return formatCookiesAsNetscape(cookies2);
14082
+ case "json":
14083
+ return JSON.stringify(cookies2, null, 2);
14084
+ case "header":
14085
+ return formatCookiesAsHeader(cookies2);
14086
+ }
14087
+ };
14088
+ var writeOutput = async (content, outPath) => {
14089
+ const withTrailingNewline = content.endsWith(`
14090
+ `) ? content : `${content}
14091
+ `;
14092
+ if (outPath) {
14093
+ await writeFile(outPath, withTrailingNewline, "utf8");
14094
+ return;
14095
+ }
14096
+ process.stdout.write(withTrailingNewline);
14097
+ };
14098
+
14099
+ // dist/cli/register/registerAuth.js
14100
+ function registerAuth(program2) {
14101
+ const auth = program2.command("auth").description("List and export browser auth cookies");
14102
+ addCookieScopeOptions(auth.command("cookies"), "Only include first-party cookies for the attached page origin").argument("[id]", "Watcher id").description("List cookies for the attached page").option("--domain <domain>", "Filter cookies by domain suffix").option("--session-only", "Show only session cookies").option("--http-only", "Show only HttpOnly cookies").option("--secure", "Show only Secure cookies").option("--show-values", "Reveal raw cookie values instead of previews").option("--json", "Output JSON for automation").addHelpText("after", `
14103
+ Examples:
14104
+ $ argus auth cookies app
14105
+ $ argus auth cookies app --for-origin --exclude-tracking
14106
+ $ argus auth cookies app --domain example.com
14107
+ $ argus auth cookies app --session-only --show-values
14108
+ `).action(async (id, options) => {
14109
+ await runAuthCookies(id, options);
14110
+ });
14111
+ addCookieScopeOptions(auth.command("export-cookies"), "Only include first-party cookies for the attached page origin").argument("[id]", "Watcher id").description("Export cookies for companion CLIs and HTTP clients").option("--format <format>", "Export format: netscape (default), json, or header").option("--domain <domain>", "Filter cookies by domain suffix").option("--out <path>", "Write the export to a file instead of stdout").addHelpText("after", `
14112
+ Examples:
14113
+ $ argus auth export-cookies app --format netscape
14114
+ $ argus auth export-cookies app --for-origin --exclude-tracking
14115
+ $ argus auth export-cookies app --format header
14116
+ $ argus auth export-cookies app --out cookies.txt
14117
+ `).action(async (id, options) => {
14118
+ await runAuthExportCookies(id, options);
14119
+ });
14120
+ }
14121
+ var addCookieScopeOptions = (command, forOriginDescription) => command.option("--for-origin", forOriginDescription).option("--exclude-tracking", "Hide common analytics/tracking cookies such as _ga and _ym");
14122
+
13704
14123
  // dist/eval/evalClient.js
13705
14124
  var evalOnce = async (input) => {
13706
14125
  const url = `http://${input.watcher.host}:${input.watcher.port}/eval`;
@@ -39007,6 +39426,7 @@ registerWatcher(program2);
39007
39426
  registerPage(program2);
39008
39427
  registerLogs(program2);
39009
39428
  registerNet(program2);
39429
+ registerAuth(program2);
39010
39430
  registerEval(program2);
39011
39431
  registerCode(program2);
39012
39432
  registerDom(program2);