@daisy/ace-axe-runner-electron 1.3.7 → 1.4.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/lib/cli.js CHANGED
@@ -72,13 +72,15 @@ app.on('ready', async () => {
72
72
  // show: false,
73
73
  // webPreferences: {
74
74
  // allowRunningInsecureContent: false,
75
- // contextIsolation: false,
76
- // nodeIntegration: true,
75
+ // contextIsolation: true,
76
+ // nodeIntegration: false,
77
77
  // nodeIntegrationInWorker: false,
78
78
  // sandbox: false,
79
79
  // webSecurity: true,
80
80
  // webviewTag: false,
81
- // nativeWindowOpen: false, // The default of nativeWindowOpen is deprecated and will be changing from false to true in Electron 15. See https://github.com/electron/electron/issues/28511
81
+ // enableRemoteModule: false,
82
+ // backgroundThrottling: false,
83
+ // // nativeWindowOpen: false, // The default of nativeWindowOpen is deprecated and will be changing from false to true in Electron 15. See https://github.com/electron/electron/issues/28511
82
84
  // }
83
85
  // }
84
86
  // );
package/lib/index.js CHANGED
@@ -4,10 +4,12 @@ const LOG_DEBUG = false;
4
4
  const ACE_LOG_PREFIX = "[ACE-AXE]";
5
5
 
6
6
  let cliOption_MILLISECONDS_TIMEOUT_EXTENSION = undefined;
7
+ // let cliOption_ACE_DO_NOT_REPORT_MEDIA_RESOURCES = undefined;
7
8
 
8
9
  function createAxeRunner(eventEmmitter, CONCURRENT_INSTANCES) {
9
10
 
10
11
  return {
12
+ // setDoNotReportMedia: function () { cliOption_ACE_DO_NOT_REPORT_MEDIA_RESOURCES = true; },
11
13
  setTimeout: function (ms) {
12
14
  try {
13
15
  cliOption_MILLISECONDS_TIMEOUT_EXTENSION = parseInt(ms, 10);
package/lib/init.js CHANGED
@@ -190,7 +190,12 @@ app.whenReady().then(async () => {
190
190
 
191
191
  sess.setPermissionRequestHandler((wc, permission, callback) => {
192
192
  if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} setPermissionRequestHandler ${wc.getURL()} => ${permission}`);
193
- callback(true);
193
+ callback(false);
194
+ });
195
+
196
+ sess.setPermissionCheckHandler((wc, permission, origin) => {
197
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} setPermissionRequestHandler ${wc ? wc.getURL() : "!WC"} => ${permission} (${origin})`);
198
+ return false;
194
199
  });
195
200
  }
196
201
  });
@@ -326,7 +331,7 @@ function axeRunnerInit(eventEmmitter, CONCURRENT_INSTANCES) {
326
331
  title: "Axe Electron runner",
327
332
  allowRunningInsecureContent: false,
328
333
  backgroundThrottling: false,
329
- contextIsolation: false,
334
+ contextIsolation: true,
330
335
  nodeIntegration: false,
331
336
  nodeIntegrationInWorker: false,
332
337
  sandbox: false,
@@ -343,15 +348,23 @@ function axeRunnerInit(eventEmmitter, CONCURRENT_INSTANCES) {
343
348
  browserWindow.setPosition(0, 0);
344
349
 
345
350
  browserWindow.webContents.session.webRequest.onBeforeRequest({
346
- urls: []
351
+ urls: ['<all_urls>']
347
352
  }, (details, callback) => {
348
- if (details.url && (/^file:\/\//.test(details.url) || /^https?:\/\//.test(details.url)
349
- // && (
350
- // (rootUrl && !details.url.startsWith(rootUrl))
351
- // ||
352
- // (!rootUrl && !/^https?:\/\/127.0.0.1/.test(details.url))
353
- // )
354
- )) {
353
+ if (!details.url || !details.url.startsWith(rootUrl)) {
354
+ // ACE_ELECTRON_HTTP_PROTOCOL acehttps://0.0.0.0
355
+ // if (details.url
356
+ // &&
357
+ // (
358
+ // /^file:\/\//.test(details.url)
359
+ // ||
360
+ // /^https?:\/\//.test(details.url)
361
+ // // && (
362
+ // // (rootUrl && !details.url.startsWith(rootUrl))
363
+ // // ||
364
+ // // (!rootUrl && !/^https?:\/\/127.0.0.1/.test(details.url))
365
+ // // )
366
+ // )
367
+ // ) {
355
368
  if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} onBeforeRequest BLOCK: ${details.url} (${rootUrl})`);
356
369
 
357
370
  // causes ERR_BLOCKED_BY_CLIENT -20 did-fail-load
@@ -527,12 +540,14 @@ function axeRunnerInit(eventEmmitter, CONCURRENT_INSTANCES) {
527
540
  try {
528
541
  await sess.clearStorageData({
529
542
  origin: "*",
530
- quotas: ["temporary", "persistent", "syncable"],
531
- storages: ["appcache", "cookies", "filesystem", "indexdb",
543
+ quotas: ["temporary"],
544
+ storages: [
545
+ // "appcache",
546
+ "cookies", "filesystem", "indexdb",
532
547
  // "localstorage", BLOCKS!?
533
548
  "shadercache",
534
549
  // "websql",
535
- "serviceworkers"]
550
+ "serviceworkers", "cachestorage"]
536
551
  });
537
552
  } catch (err) {
538
553
  if (LOG_DEBUG) console.log(err);
@@ -852,12 +867,13 @@ function startAxeServer(basedir, scripts, scriptContents) {
852
867
  console.log(">>>>>>>>>> URL 2");
853
868
  console.log(ptn);
854
869
  }
855
- const pn = decodeURIComponent(ptn);
870
+ let pn = decodeURIComponent(ptn);
856
871
  if (LOG_DEBUG_URLS) {
857
872
  console.log(">>>>>>>>>> URL 3");
858
873
  console.log(pn);
859
874
  }
860
875
 
876
+ pn = pn.replace(/^[/\\]/, "").replace(/\.\.[/\\]?/g, "DoTDoT");
861
877
  let fileSystemPath = path.join(basedir, pn);
862
878
  if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} filepath to read: ${fileSystemPath}`);
863
879
  if (!fs.existsSync(fileSystemPath)) {
@@ -928,11 +944,12 @@ function startAxeServer(basedir, scripts, scriptContents) {
928
944
  console.log(">>>>>>>>>>- URL 2");
929
945
  console.log(ptn);
930
946
  }
931
- const pn = decodeURIComponent(ptn);
947
+ let pn = decodeURIComponent(ptn);
932
948
  if (LOG_DEBUG_URLS) {
933
949
  console.log(">>>>>>>>>>- URL 3");
934
950
  console.log(pn);
935
951
  }
952
+ pn = pn.replace(/^[/\\]/, "").replace(/\.\.[/\\]?/g, "DoTDoT");
936
953
  let fileSystemPath = path.join(basedir, pn);
937
954
  if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} --filepath to read: ${fileSystemPath}`);
938
955
  if (!fs.existsSync(fileSystemPath)) {
@@ -982,7 +999,8 @@ function startAxeServer(basedir, scripts, scriptContents) {
982
999
 
983
1000
  // // const url = new URL(`https://fake.org${req.url}`);
984
1001
  // // const pathname = url.pathname;
985
- // const pathname = decodeURIComponent(u.pathname);
1002
+ // let pathname = decodeURIComponent(u.pathname);
1003
+ // pathname = pathname.replace(/^[/\\]/, "").replace(/\.\.[/\\]?/g, "DoTDoT");
986
1004
 
987
1005
  // const filePath = path.join(basedir, pathname);
988
1006
  // if (filePathsExpressStaticNotExist[filePath]) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@daisy/ace-axe-runner-electron",
3
- "version": "1.3.7",
3
+ "version": "1.4.0",
4
4
  "engines": {
5
5
  "node": ">=20.0.0",
6
6
  "yarn": "^1.22.0",
@@ -23,12 +23,12 @@
23
23
  "license": "MIT",
24
24
  "main": "lib/index.js",
25
25
  "dependencies": {
26
- "@daisy/ace-cli-shared": "1.3.7",
26
+ "@daisy/ace-cli-shared": "1.4.0",
27
27
  "mime-types": "^2.1.35",
28
28
  "uuid": "^8.3.2"
29
29
  },
30
30
  "devDependencies": {
31
- "electron": "^34.1.0"
31
+ "electron": "^41.1.0"
32
32
  },
33
33
  "publishConfig": {
34
34
  "access": "public"
package/src/cli.js CHANGED
@@ -72,13 +72,15 @@ app.on('ready', async () => {
72
72
  // show: false,
73
73
  // webPreferences: {
74
74
  // allowRunningInsecureContent: false,
75
- // contextIsolation: false,
76
- // nodeIntegration: true,
75
+ // contextIsolation: true,
76
+ // nodeIntegration: false,
77
77
  // nodeIntegrationInWorker: false,
78
78
  // sandbox: false,
79
79
  // webSecurity: true,
80
80
  // webviewTag: false,
81
- // nativeWindowOpen: false, // The default of nativeWindowOpen is deprecated and will be changing from false to true in Electron 15. See https://github.com/electron/electron/issues/28511
81
+ // enableRemoteModule: false,
82
+ // backgroundThrottling: false,
83
+ // // nativeWindowOpen: false, // The default of nativeWindowOpen is deprecated and will be changing from false to true in Electron 15. See https://github.com/electron/electron/issues/28511
82
84
  // }
83
85
  // }
84
86
  // );
package/src/index.js CHANGED
@@ -4,10 +4,12 @@ const LOG_DEBUG = false;
4
4
  const ACE_LOG_PREFIX = "[ACE-AXE]";
5
5
 
6
6
  let cliOption_MILLISECONDS_TIMEOUT_EXTENSION = undefined;
7
+ // let cliOption_ACE_DO_NOT_REPORT_MEDIA_RESOURCES = undefined;
7
8
 
8
9
  function createAxeRunner(eventEmmitter, CONCURRENT_INSTANCES) {
9
10
 
10
11
  return {
12
+ // setDoNotReportMedia: function () { cliOption_ACE_DO_NOT_REPORT_MEDIA_RESOURCES = true; },
11
13
  setTimeout: function (ms) {
12
14
  try {
13
15
  cliOption_MILLISECONDS_TIMEOUT_EXTENSION = parseInt(ms, 10);
package/src/init.js CHANGED
@@ -196,7 +196,12 @@ app.whenReady().then(async () => {
196
196
 
197
197
  sess.setPermissionRequestHandler((wc, permission, callback) => {
198
198
  if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} setPermissionRequestHandler ${wc.getURL()} => ${permission}`);
199
- callback(true);
199
+ callback(false);
200
+ });
201
+
202
+ sess.setPermissionCheckHandler((wc, permission, origin) => {
203
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} setPermissionRequestHandler ${wc ? wc.getURL() : "!WC"} => ${permission} (${origin})`);
204
+ return false;
200
205
  });
201
206
  }
202
207
  });
@@ -332,7 +337,7 @@ function axeRunnerInit(eventEmmitter, CONCURRENT_INSTANCES) {
332
337
  title: "Axe Electron runner",
333
338
  allowRunningInsecureContent: false,
334
339
  backgroundThrottling: false,
335
- contextIsolation: false,
340
+ contextIsolation: true,
336
341
  nodeIntegration: false,
337
342
  nodeIntegrationInWorker: false,
338
343
  sandbox: false,
@@ -348,22 +353,23 @@ function axeRunnerInit(eventEmmitter, CONCURRENT_INSTANCES) {
348
353
  browserWindow.setSize(1024, 768);
349
354
  browserWindow.setPosition(0, 0);
350
355
 
351
- browserWindow.webContents.session.webRequest.onBeforeRequest({
352
- urls: [],
353
- }, (details, callback) => {
354
- if (details.url
355
- &&
356
- (
357
- /^file:\/\//.test(details.url)
358
- ||
359
- /^https?:\/\//.test(details.url)
360
- // && (
361
- // (rootUrl && !details.url.startsWith(rootUrl))
362
- // ||
363
- // (!rootUrl && !/^https?:\/\/127.0.0.1/.test(details.url))
364
- // )
365
- )
366
- ) {
356
+ browserWindow.webContents.session.webRequest.onBeforeRequest({
357
+ urls: ['<all_urls>'],
358
+ }, (details, callback) => {
359
+ if (!details.url || !details.url.startsWith(rootUrl)) { // ACE_ELECTRON_HTTP_PROTOCOL acehttps://0.0.0.0
360
+ // if (details.url
361
+ // &&
362
+ // (
363
+ // /^file:\/\//.test(details.url)
364
+ // ||
365
+ // /^https?:\/\//.test(details.url)
366
+ // // && (
367
+ // // (rootUrl && !details.url.startsWith(rootUrl))
368
+ // // ||
369
+ // // (!rootUrl && !/^https?:\/\/127.0.0.1/.test(details.url))
370
+ // // )
371
+ // )
372
+ // ) {
367
373
  if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} onBeforeRequest BLOCK: ${details.url} (${rootUrl})`);
368
374
 
369
375
  // causes ERR_BLOCKED_BY_CLIENT -20 did-fail-load
@@ -541,11 +547,11 @@ function axeRunnerInit(eventEmmitter, CONCURRENT_INSTANCES) {
541
547
  origin: "*",
542
548
  quotas: [
543
549
  "temporary",
544
- "persistent",
545
- "syncable",
550
+ // "persistent",
551
+ // "syncable",
546
552
  ],
547
553
  storages: [
548
- "appcache",
554
+ // "appcache",
549
555
  "cookies",
550
556
  "filesystem",
551
557
  "indexdb",
@@ -553,6 +559,7 @@ function axeRunnerInit(eventEmmitter, CONCURRENT_INSTANCES) {
553
559
  "shadercache",
554
560
  // "websql",
555
561
  "serviceworkers",
562
+ "cachestorage",
556
563
  ],
557
564
  });
558
565
  } catch (err) {
@@ -877,12 +884,13 @@ function startAxeServer(basedir, scripts, scriptContents) {
877
884
  console.log(">>>>>>>>>> URL 2");
878
885
  console.log(ptn);
879
886
  }
880
- const pn = decodeURIComponent(ptn);
887
+ let pn = decodeURIComponent(ptn);
881
888
  if (LOG_DEBUG_URLS) {
882
889
  console.log(">>>>>>>>>> URL 3");
883
890
  console.log(pn);
884
891
  }
885
892
 
893
+ pn = pn.replace(/^[/\\]/, "").replace(/\.\.[/\\]?/g, "DoTDoT");
886
894
  let fileSystemPath = path.join(basedir, pn);
887
895
  if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} filepath to read: ${fileSystemPath}`);
888
896
  if (!fs.existsSync(fileSystemPath)) {
@@ -953,11 +961,12 @@ function startAxeServer(basedir, scripts, scriptContents) {
953
961
  console.log(">>>>>>>>>>- URL 2");
954
962
  console.log(ptn);
955
963
  }
956
- const pn = decodeURIComponent(ptn);
964
+ let pn = decodeURIComponent(ptn);
957
965
  if (LOG_DEBUG_URLS) {
958
966
  console.log(">>>>>>>>>>- URL 3");
959
967
  console.log(pn);
960
968
  }
969
+ pn = pn.replace(/^[/\\]/, "").replace(/\.\.[/\\]?/g, "DoTDoT");
961
970
  let fileSystemPath = path.join(basedir, pn);
962
971
  if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} --filepath to read: ${fileSystemPath}`);
963
972
  if (!fs.existsSync(fileSystemPath)) {
@@ -1007,7 +1016,8 @@ function startAxeServer(basedir, scripts, scriptContents) {
1007
1016
 
1008
1017
  // // const url = new URL(`https://fake.org${req.url}`);
1009
1018
  // // const pathname = url.pathname;
1010
- // const pathname = decodeURIComponent(u.pathname);
1019
+ // let pathname = decodeURIComponent(u.pathname);
1020
+ // pathname = pathname.replace(/^[/\\]/, "").replace(/\.\.[/\\]?/g, "DoTDoT");
1011
1021
 
1012
1022
  // const filePath = path.join(basedir, pathname);
1013
1023
  // if (filePathsExpressStaticNotExist[filePath]) {