browser-debugger-cli 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/.claude/skills/bdg/SKILL.md +1 -1
  2. package/dist/commands/cdp.js +1 -0
  3. package/dist/commands/cleanup.js +3 -0
  4. package/dist/commands/dom/eval.d.ts +2 -1
  5. package/dist/commands/dom/eval.js +6 -21
  6. package/dist/commands/dom/helpers/evalResult.d.ts +36 -0
  7. package/dist/commands/dom/helpers/evalResult.js +59 -0
  8. package/dist/commands/helpJson.d.ts +1 -1
  9. package/dist/commands/helpJson.js +3 -3
  10. package/dist/commands/helpTopic.js +10 -4
  11. package/dist/commands/network/har.js +18 -14
  12. package/dist/commands/optionBehaviors.js +8 -3
  13. package/dist/commands/shared/optionTypes.d.ts +1 -0
  14. package/dist/commands/shared/outputFile.d.ts +2 -1
  15. package/dist/commands/shared/outputFile.js +7 -4
  16. package/dist/commands/status.js +3 -1
  17. package/dist/commands/stop.js +2 -1
  18. package/dist/connection/launcher/flagsBuilder.d.ts +46 -0
  19. package/dist/connection/launcher/flagsBuilder.js +107 -23
  20. package/dist/connection/launcher.d.ts +1 -1
  21. package/dist/connection/launcher.js +1 -2
  22. package/dist/constants.d.ts +2 -4
  23. package/dist/constants.js +2 -4
  24. package/dist/daemon/launcher.d.ts +17 -3
  25. package/dist/daemon/launcher.js +37 -7
  26. package/dist/daemon/session/commandRegistry.js +2 -2
  27. package/dist/daemon.js +8107 -7962
  28. package/dist/errors/messages.d.ts +23 -0
  29. package/dist/errors/messages.js +86 -6
  30. package/dist/index.js +555 -166
  31. package/dist/ipc/client.d.ts +6 -1
  32. package/dist/ipc/client.js +11 -2
  33. package/dist/ipc/protocol/commands.d.ts +4 -0
  34. package/dist/ipc/transport/index.d.ts +6 -0
  35. package/dist/ipc/transport/index.js +16 -1
  36. package/dist/runtime/dom/elementInfo.d.ts +7 -0
  37. package/dist/runtime/dom/elementInfo.js +8 -1
  38. package/dist/runtime/dom/evalHelpers.d.ts +24 -4
  39. package/dist/runtime/dom/evalHelpers.js +40 -12
  40. package/dist/runtime/dom/frames.d.ts +2 -1
  41. package/dist/runtime/dom/frames.js +3 -1
  42. package/dist/runtime/page/emulation.js +6 -5
  43. package/dist/runtime/page/userAgent.d.ts +86 -2
  44. package/dist/runtime/page/userAgent.js +154 -33
  45. package/dist/session/paths.d.ts +38 -3
  46. package/dist/session/paths.js +154 -7
  47. package/dist/session/portClaims.d.ts +0 -8
  48. package/dist/session/portClaims.js +1 -22
  49. package/dist/session/sessionList.d.ts +5 -1
  50. package/dist/session/sessionList.js +5 -1
  51. package/dist/telemetry/har/builder.d.ts +12 -1
  52. package/dist/telemetry/har/builder.js +10 -2
  53. package/dist/telemetry/har/sanitize.d.ts +24 -0
  54. package/dist/telemetry/har/sanitize.js +138 -0
  55. package/dist/telemetry/har/sanitizeBody.d.ts +38 -0
  56. package/dist/telemetry/har/sanitizeBody.js +168 -0
  57. package/dist/ui/formatters/sessions.d.ts +3 -2
  58. package/dist/ui/formatters/sessions.js +10 -3
  59. package/dist/ui/messages/chrome.d.ts +14 -6
  60. package/dist/ui/messages/chrome.js +52 -12
  61. package/dist/ui/messages/networkMessages.d.ts +26 -0
  62. package/dist/ui/messages/networkMessages.js +21 -0
  63. package/dist/ui/messages/session.d.ts +8 -0
  64. package/dist/ui/messages/session.js +10 -0
  65. package/dist/utils/atomicFile.d.ts +2 -1
  66. package/dist/utils/atomicFile.js +5 -2
  67. package/dist/utils/directories.d.ts +41 -0
  68. package/dist/utils/directories.js +48 -0
  69. package/package.json +1 -1
@@ -31,4 +31,45 @@ export declare function directoryProblem(dir: string): DirectoryProblem | null;
31
31
  * file on the path), `EACCES` (not writable), or the `mkdir` error
32
32
  */
33
33
  export declare function makeDirectory(dir: string, mode?: number): void;
34
+ /**
35
+ * Kind of untrusted directory: a symlink, not a directory, another user's,
36
+ * a shared sticky directory such as `/tmp` (others may create entries in
37
+ * it), or writable by others
38
+ */
39
+ export type DirTrustKind = 'symlink' | 'not-directory' | 'owner' | 'shared' | 'writable';
40
+ /** Why a directory cannot be trusted */
41
+ export interface DirTrustProblem {
42
+ /** e.g. `owned by uid 1001`, `writable by others (mode 777)` */
43
+ reason: string;
44
+ kind: DirTrustKind;
45
+ }
46
+ /** Options of {@link dirTrustProblem} */
47
+ export interface DirTrustOptions {
48
+ /**
49
+ * Accept a directory its group may write to (only others' write access is
50
+ * refused): under umask 002, common with per-user groups, directories are
51
+ * created 0775 and the group holds only the user
52
+ */
53
+ allowGroupWrite?: boolean;
54
+ }
55
+ /**
56
+ * Whether a path is a directory the current user can trust: a real directory
57
+ * (not a symlink), owned by the user, not writable by group or others (by
58
+ * others only, with `allowGroupWrite`).
59
+ *
60
+ * @param dir - Existing path
61
+ * @param options - What else to accept
62
+ * @returns Why it cannot be trusted, or null if it can
63
+ * @throws Error from `lstat` (e.g. `ENOENT` for a missing path)
64
+ */
65
+ export declare function dirTrustProblem(dir: string, options?: DirTrustOptions): DirTrustProblem | null;
66
+ /**
67
+ * Strict form of {@link dirTrustProblem}: not a symlink, owned by the user,
68
+ * not writable by group or others.
69
+ *
70
+ * @param dir - Existing path
71
+ * @returns Why it cannot be trusted, or null if it can
72
+ * @throws Error from `lstat` (e.g. `ENOENT` for a missing path)
73
+ */
74
+ export declare function untrustedDirReason(dir: string): string | null;
34
75
  //# sourceMappingURL=directories.d.ts.map
@@ -85,4 +85,52 @@ export function makeDirectory(dir, mode) {
85
85
  }
86
86
  fs.mkdirSync(dir, { recursive: true, ...(mode !== undefined && { mode }) });
87
87
  }
88
+ /** Permission bits that let group or others write */
89
+ const GROUP_OTHER_WRITE = 0o022;
90
+ /** Permission bit that lets others (not the group) write */
91
+ const OTHER_WRITE = 0o002;
92
+ /** Sticky bit: a shared directory like `/tmp` where only owners remove their entries */
93
+ const STICKY = 0o1000;
94
+ /**
95
+ * Whether a path is a directory the current user can trust: a real directory
96
+ * (not a symlink), owned by the user, not writable by group or others (by
97
+ * others only, with `allowGroupWrite`).
98
+ *
99
+ * @param dir - Existing path
100
+ * @param options - What else to accept
101
+ * @returns Why it cannot be trusted, or null if it can
102
+ * @throws Error from `lstat` (e.g. `ENOENT` for a missing path)
103
+ */
104
+ export function dirTrustProblem(dir, options = {}) {
105
+ const stat = fs.lstatSync(dir);
106
+ const problem = (reason, kind) => ({ reason, kind });
107
+ if (stat.isSymbolicLink())
108
+ return problem('it is a symbolic link', 'symlink');
109
+ if (!stat.isDirectory())
110
+ return problem('not a directory', 'not-directory');
111
+ const uid = process.getuid?.();
112
+ if (uid !== undefined && stat.uid !== uid)
113
+ return problem(`owned by uid ${stat.uid}`, 'owner');
114
+ if (process.platform === 'win32')
115
+ return null;
116
+ const writeBits = options.allowGroupWrite ? OTHER_WRITE : GROUP_OTHER_WRITE;
117
+ if ((stat.mode & writeBits) === 0)
118
+ return null;
119
+ const mode = (stat.mode & 0o7777).toString(8);
120
+ if ((stat.mode & STICKY) !== 0 && (stat.mode & OTHER_WRITE) !== 0) {
121
+ return problem(`a shared sticky directory (mode ${mode})`, 'shared');
122
+ }
123
+ return problem(`writable by others (mode ${mode})`, 'writable');
124
+ }
125
+ /**
126
+ * Strict form of {@link dirTrustProblem}: not a symlink, owned by the user,
127
+ * not writable by group or others.
128
+ *
129
+ * @param dir - Existing path
130
+ * @returns Why it cannot be trusted, or null if it can
131
+ * @throws Error from `lstat` (e.g. `ENOENT` for a missing path)
132
+ */
133
+ export function untrustedDirReason(dir) {
134
+ return dirTrustProblem(dir)?.reason ?? null;
135
+ }
88
136
  //# sourceMappingURL=directories.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser-debugger-cli",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "description": "DevTools telemetry in your terminal. For humans and agents. Direct WebSocket to Chrome's debugging port.",
5
5
  "type": "module",
6
6
  "bin": {