browser-commander 0.26.2 → 0.26.3

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.26.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 796ebd8: Accept dedicated macOS application profiles under `~/Library/Application Support` by separating Safari import discovery roots from protected browser data paths. Safari, Technology Preview and Chrome default profiles remain protected.
8
+
3
9
  ## 0.26.2
4
10
 
5
11
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser-commander",
3
- "version": "0.26.2",
3
+ "version": "0.26.3",
4
4
  "description": "Universal browser automation library that supports Playwright, Puppeteer, and Selenium with a unified API",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -141,6 +141,19 @@ export function resolveBrowserRoots(name, options = {}) {
141
141
  return resolveTemplates(templates, options);
142
142
  }
143
143
 
144
+ /**
145
+ * Browser-owned paths forbidden as automation profiles. Import discovery may
146
+ * search broader locations; use explicit protection roots when declared.
147
+ */
148
+ export function resolveBrowserProtectionRoots(name, options = {}) {
149
+ const source = normalizeBrowserSource(name);
150
+ const roots = source.protectionRoots ?? source.roots;
151
+ return resolveTemplates(
152
+ roots?.[options.platform ?? process.platform] ?? [],
153
+ options
154
+ );
155
+ }
156
+
144
157
  function resolveTemplates(
145
158
  templates,
146
159
  {
@@ -764,6 +764,13 @@
764
764
  "{home}/Library"
765
765
  ]
766
766
  },
767
+ "protectionRoots": {
768
+ "darwin": [
769
+ "{home}/Library/Safari",
770
+ "{home}/Library/Containers/com.apple.Safari",
771
+ "{home}/Library/Cookies"
772
+ ]
773
+ },
767
774
  "default": {
768
775
  "darwin": ["com.apple.safari"]
769
776
  },
@@ -781,6 +788,12 @@
781
788
  "{home}/Library/Safari Technology Preview"
782
789
  ]
783
790
  },
791
+ "protectionRoots": {
792
+ "darwin": [
793
+ "{home}/Library/Safari Technology Preview",
794
+ "{home}/Library/Containers/com.apple.SafariTechnologyPreview"
795
+ ]
796
+ },
784
797
  "default": {
785
798
  "darwin": ["com.apple.safaritechnologypreview"]
786
799
  },
@@ -2,7 +2,7 @@ import { constants } from 'node:fs';
2
2
  import { physicalPath } from './browser-profile-files.js';
3
3
  import {
4
4
  BROWSER_SOURCES,
5
- resolveBrowserRoots,
5
+ resolveBrowserProtectionRoots,
6
6
  resolveBrowserExecutables,
7
7
  } from './browser-sources.js';
8
8
  import { access } from 'node:fs/promises';
@@ -46,7 +46,7 @@ export function knownDefaultUserDataDirs({
46
46
  environment = process.env,
47
47
  } = {}) {
48
48
  return BROWSER_SOURCES.flatMap((browser) =>
49
- resolveBrowserRoots(browser.id, {
49
+ resolveBrowserProtectionRoots(browser.id, {
50
50
  platform,
51
51
  homeDir,
52
52
  environment,
@@ -6,6 +6,7 @@ import { useTempDirectories } from '../../helpers/temp-directory.js';
6
6
  import {
7
7
  BROWSER_SOURCES,
8
8
  resolveBrowserRoots,
9
+ resolveBrowserProtectionRoots,
9
10
  } from '../../../src/browser/browser-sources.js';
10
11
  import {
11
12
  assertDedicatedUserDataDir,
@@ -13,8 +14,51 @@ import {
13
14
  } from '../../../src/browser/system-browser.js';
14
15
 
15
16
  const temporary = useTempDirectories('bc-catalogue-protection-');
17
+ const macOSOptions = {
18
+ platform: 'darwin',
19
+ homeDir: '/users/test',
20
+ environment: {},
21
+ };
16
22
 
17
23
  describe('catalogue launch and protection (#121)', () => {
24
+ it('accepts dedicated macOS application profiles under Library (#132)', () => {
25
+ const options = macOSOptions;
26
+ for (const directory of [
27
+ 'Library/Application Support/package-registry-manager/browser-profile',
28
+ 'Library/Safari-backup/profile',
29
+ 'Library/Cookies-backup/profile',
30
+ 'Library/Containers/com.apple.Safari-helper/profile',
31
+ ]) {
32
+ assert.doesNotThrow(() =>
33
+ assertDedicatedUserDataDir(
34
+ path.posix.join(options.homeDir, directory),
35
+ options
36
+ )
37
+ );
38
+ }
39
+ });
40
+
41
+ it('protects Safari stores and Chrome profiles on macOS (#132)', () => {
42
+ const options = macOSOptions;
43
+ for (const directory of [
44
+ 'Library/Safari',
45
+ 'Library/Cookies',
46
+ 'Library/Containers/com.apple.Safari',
47
+ 'Library/Safari Technology Preview',
48
+ 'Library/Containers/com.apple.SafariTechnologyPreview',
49
+ 'Library/Application Support/Google/Chrome/Default',
50
+ ]) {
51
+ const root = path.posix.join(options.homeDir, directory);
52
+ for (const requested of [root, path.posix.join(root, 'new-profile')]) {
53
+ assert.throws(
54
+ () => assertDedicatedUserDataDir(requested, options),
55
+ /dedicated.*default profile/,
56
+ requested
57
+ );
58
+ }
59
+ }
60
+ });
61
+
18
62
  it('protects a new profile beneath a symlink to a default root', async () => {
19
63
  const homeDir = await temporary();
20
64
  const options = { homeDir, environment: {} };
@@ -47,7 +91,7 @@ describe('catalogue launch and protection (#121)', () => {
47
91
  }
48
92
  });
49
93
 
50
- it('protects every catalogue root and descendant profile on every OS', () => {
94
+ it('protects every catalogue protection root and descendant profile on every OS', () => {
51
95
  for (const platform of ['linux', 'darwin', 'win32']) {
52
96
  const options = {
53
97
  platform,
@@ -55,7 +99,11 @@ describe('catalogue launch and protection (#121)', () => {
55
99
  environment: {},
56
100
  };
57
101
  for (const browser of BROWSER_SOURCES) {
58
- for (const root of resolveBrowserRoots(browser.id, options)) {
102
+ const roots = resolveBrowserProtectionRoots(browser.id, options);
103
+ if (!browser.protectionRoots) {
104
+ assert.deepEqual(roots, resolveBrowserRoots(browser.id, options));
105
+ }
106
+ for (const root of roots) {
59
107
  assert.throws(
60
108
  () => assertDedicatedUserDataDir(root, options),
61
109
  /dedicated.*default profile/,