@browserless.io/browserless 2.4.0 → 2.5.0-beta-2

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 (57) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/bin/browserless.js +17 -127
  3. package/bin/scaffold/README.md +95 -14
  4. package/build/browserless.d.ts +5 -3
  5. package/build/browserless.js +10 -6
  6. package/build/browsers/index.d.ts +5 -3
  7. package/build/browsers/index.js +6 -4
  8. package/build/data/selectors.json +1 -1
  9. package/build/exports.d.ts +1 -0
  10. package/build/exports.js +1 -0
  11. package/build/file-system.d.ts +2 -3
  12. package/build/file-system.js +10 -21
  13. package/build/file-system.spec.js +35 -18
  14. package/build/hooks.d.ts +18 -4
  15. package/build/hooks.js +33 -4
  16. package/build/limiter.d.ts +3 -2
  17. package/build/limiter.js +5 -3
  18. package/build/limiter.spec.js +45 -26
  19. package/build/routes/chrome/http/content.post.body.json +8 -8
  20. package/build/routes/chrome/http/pdf.post.body.json +8 -8
  21. package/build/routes/chrome/http/scrape.post.body.json +8 -8
  22. package/build/routes/chrome/http/screenshot.post.body.json +8 -8
  23. package/build/routes/chromium/http/content.post.body.json +8 -8
  24. package/build/routes/chromium/http/pdf.post.body.json +8 -8
  25. package/build/routes/chromium/http/scrape.post.body.json +8 -8
  26. package/build/routes/chromium/http/screenshot.post.body.json +8 -8
  27. package/build/routes/management/http/metrics-total.get.js +1 -1
  28. package/build/routes/management/http/metrics.get.js +2 -2
  29. package/build/sdk-utils.d.ts +13 -0
  30. package/build/sdk-utils.js +94 -0
  31. package/build/server.d.ts +3 -2
  32. package/build/server.js +6 -4
  33. package/build/types.d.ts +2 -2
  34. package/build/utils.js +6 -10
  35. package/external/after.js +1 -1
  36. package/external/before.js +1 -1
  37. package/external/browser.js +1 -1
  38. package/external/page.js +1 -1
  39. package/package.json +7 -7
  40. package/src/browserless.ts +21 -3
  41. package/src/browsers/index.ts +9 -6
  42. package/src/exports.ts +1 -0
  43. package/src/file-system.spec.ts +43 -18
  44. package/src/file-system.ts +16 -30
  45. package/src/hooks.ts +46 -4
  46. package/src/limiter.spec.ts +82 -112
  47. package/src/limiter.ts +3 -3
  48. package/src/routes/management/http/metrics-total.get.ts +3 -3
  49. package/src/routes/management/http/metrics.get.ts +2 -2
  50. package/src/sdk-utils.ts +136 -0
  51. package/src/server.ts +4 -3
  52. package/src/shared/content.http.ts +0 -1
  53. package/src/types.ts +2 -2
  54. package/src/utils.ts +10 -11
  55. package/static/docs/swagger.json +11 -11
  56. package/static/docs/swagger.min.json +10 -10
  57. package/static/function/client.js +76 -63
@@ -441,14 +441,14 @@
441
441
  "length": {
442
442
  "type": "number"
443
443
  },
444
- "__@toStringTag@130822": {
444
+ "__@toStringTag@108694": {
445
445
  "type": "string",
446
446
  "const": "Uint8Array"
447
447
  }
448
448
  },
449
449
  "required": [
450
450
  "BYTES_PER_ELEMENT",
451
- "__@toStringTag@130822",
451
+ "__@toStringTag@108694",
452
452
  "buffer",
453
453
  "byteLength",
454
454
  "byteOffset",
@@ -483,13 +483,13 @@
483
483
  "byteLength": {
484
484
  "type": "number"
485
485
  },
486
- "__@toStringTag@130822": {
486
+ "__@toStringTag@108694": {
487
487
  "type": "string"
488
488
  }
489
489
  },
490
490
  "additionalProperties": false,
491
491
  "required": [
492
- "__@toStringTag@130822",
492
+ "__@toStringTag@108694",
493
493
  "byteLength"
494
494
  ]
495
495
  },
@@ -499,18 +499,18 @@
499
499
  "byteLength": {
500
500
  "type": "number"
501
501
  },
502
- "__@species@130923": {
502
+ "__@species@108795": {
503
503
  "$ref": "#/definitions/SharedArrayBuffer"
504
504
  },
505
- "__@toStringTag@130822": {
505
+ "__@toStringTag@108694": {
506
506
  "type": "string",
507
507
  "const": "SharedArrayBuffer"
508
508
  }
509
509
  },
510
510
  "additionalProperties": false,
511
511
  "required": [
512
- "__@species@130923",
513
- "__@toStringTag@130822",
512
+ "__@species@108795",
513
+ "__@toStringTag@108694",
514
514
  "byteLength"
515
515
  ]
516
516
  },
@@ -484,14 +484,14 @@
484
484
  "length": {
485
485
  "type": "number"
486
486
  },
487
- "__@toStringTag@97868": {
487
+ "__@toStringTag@119846": {
488
488
  "type": "string",
489
489
  "const": "Uint8Array"
490
490
  }
491
491
  },
492
492
  "required": [
493
493
  "BYTES_PER_ELEMENT",
494
- "__@toStringTag@97868",
494
+ "__@toStringTag@119846",
495
495
  "buffer",
496
496
  "byteLength",
497
497
  "byteOffset",
@@ -526,13 +526,13 @@
526
526
  "byteLength": {
527
527
  "type": "number"
528
528
  },
529
- "__@toStringTag@97868": {
529
+ "__@toStringTag@119846": {
530
530
  "type": "string"
531
531
  }
532
532
  },
533
533
  "additionalProperties": false,
534
534
  "required": [
535
- "__@toStringTag@97868",
535
+ "__@toStringTag@119846",
536
536
  "byteLength"
537
537
  ]
538
538
  },
@@ -542,18 +542,18 @@
542
542
  "byteLength": {
543
543
  "type": "number"
544
544
  },
545
- "__@species@97969": {
545
+ "__@species@119947": {
546
546
  "$ref": "#/definitions/SharedArrayBuffer"
547
547
  },
548
- "__@toStringTag@97868": {
548
+ "__@toStringTag@119846": {
549
549
  "type": "string",
550
550
  "const": "SharedArrayBuffer"
551
551
  }
552
552
  },
553
553
  "additionalProperties": false,
554
554
  "required": [
555
- "__@species@97969",
556
- "__@toStringTag@97868",
555
+ "__@species@119947",
556
+ "__@toStringTag@119846",
557
557
  "byteLength"
558
558
  ]
559
559
  },
@@ -394,14 +394,14 @@
394
394
  "length": {
395
395
  "type": "number"
396
396
  },
397
- "__@toStringTag@119733": {
397
+ "__@toStringTag@130908": {
398
398
  "type": "string",
399
399
  "const": "Uint8Array"
400
400
  }
401
401
  },
402
402
  "required": [
403
403
  "BYTES_PER_ELEMENT",
404
- "__@toStringTag@119733",
404
+ "__@toStringTag@130908",
405
405
  "buffer",
406
406
  "byteLength",
407
407
  "byteOffset",
@@ -436,13 +436,13 @@
436
436
  "byteLength": {
437
437
  "type": "number"
438
438
  },
439
- "__@toStringTag@119733": {
439
+ "__@toStringTag@130908": {
440
440
  "type": "string"
441
441
  }
442
442
  },
443
443
  "additionalProperties": false,
444
444
  "required": [
445
- "__@toStringTag@119733",
445
+ "__@toStringTag@130908",
446
446
  "byteLength"
447
447
  ]
448
448
  },
@@ -452,18 +452,18 @@
452
452
  "byteLength": {
453
453
  "type": "number"
454
454
  },
455
- "__@species@119834": {
455
+ "__@species@131009": {
456
456
  "$ref": "#/definitions/SharedArrayBuffer"
457
457
  },
458
- "__@toStringTag@119733": {
458
+ "__@toStringTag@130908": {
459
459
  "type": "string",
460
460
  "const": "SharedArrayBuffer"
461
461
  }
462
462
  },
463
463
  "additionalProperties": false,
464
464
  "required": [
465
- "__@species@119834",
466
- "__@toStringTag@119733",
465
+ "__@species@131009",
466
+ "__@toStringTag@130908",
467
467
  "byteLength"
468
468
  ]
469
469
  },
@@ -535,14 +535,14 @@
535
535
  "length": {
536
536
  "type": "number"
537
537
  },
538
- "__@toStringTag@195916": {
538
+ "__@toStringTag@217585": {
539
539
  "type": "string",
540
540
  "const": "Uint8Array"
541
541
  }
542
542
  },
543
543
  "required": [
544
544
  "BYTES_PER_ELEMENT",
545
- "__@toStringTag@195916",
545
+ "__@toStringTag@217585",
546
546
  "buffer",
547
547
  "byteLength",
548
548
  "byteOffset",
@@ -577,13 +577,13 @@
577
577
  "byteLength": {
578
578
  "type": "number"
579
579
  },
580
- "__@toStringTag@195916": {
580
+ "__@toStringTag@217585": {
581
581
  "type": "string"
582
582
  }
583
583
  },
584
584
  "additionalProperties": false,
585
585
  "required": [
586
- "__@toStringTag@195916",
586
+ "__@toStringTag@217585",
587
587
  "byteLength"
588
588
  ]
589
589
  },
@@ -593,18 +593,18 @@
593
593
  "byteLength": {
594
594
  "type": "number"
595
595
  },
596
- "__@species@196017": {
596
+ "__@species@217686": {
597
597
  "$ref": "#/definitions/SharedArrayBuffer"
598
598
  },
599
- "__@toStringTag@195916": {
599
+ "__@toStringTag@217585": {
600
600
  "type": "string",
601
601
  "const": "SharedArrayBuffer"
602
602
  }
603
603
  },
604
604
  "additionalProperties": false,
605
605
  "required": [
606
- "__@species@196017",
607
- "__@toStringTag@195916",
606
+ "__@species@217686",
607
+ "__@toStringTag@217585",
608
608
  "byteLength"
609
609
  ]
610
610
  },
@@ -441,14 +441,14 @@
441
441
  "length": {
442
442
  "type": "number"
443
443
  },
444
- "__@toStringTag@228592": {
444
+ "__@toStringTag@228657": {
445
445
  "type": "string",
446
446
  "const": "Uint8Array"
447
447
  }
448
448
  },
449
449
  "required": [
450
450
  "BYTES_PER_ELEMENT",
451
- "__@toStringTag@228592",
451
+ "__@toStringTag@228657",
452
452
  "buffer",
453
453
  "byteLength",
454
454
  "byteOffset",
@@ -483,13 +483,13 @@
483
483
  "byteLength": {
484
484
  "type": "number"
485
485
  },
486
- "__@toStringTag@228592": {
486
+ "__@toStringTag@228657": {
487
487
  "type": "string"
488
488
  }
489
489
  },
490
490
  "additionalProperties": false,
491
491
  "required": [
492
- "__@toStringTag@228592",
492
+ "__@toStringTag@228657",
493
493
  "byteLength"
494
494
  ]
495
495
  },
@@ -499,18 +499,18 @@
499
499
  "byteLength": {
500
500
  "type": "number"
501
501
  },
502
- "__@species@228693": {
502
+ "__@species@228758": {
503
503
  "$ref": "#/definitions/SharedArrayBuffer"
504
504
  },
505
- "__@toStringTag@228592": {
505
+ "__@toStringTag@228657": {
506
506
  "type": "string",
507
507
  "const": "SharedArrayBuffer"
508
508
  }
509
509
  },
510
510
  "additionalProperties": false,
511
511
  "required": [
512
- "__@species@228693",
513
- "__@toStringTag@228592",
512
+ "__@species@228758",
513
+ "__@toStringTag@228657",
514
514
  "byteLength"
515
515
  ]
516
516
  },
@@ -484,14 +484,14 @@
484
484
  "length": {
485
485
  "type": "number"
486
486
  },
487
- "__@toStringTag@239738": {
487
+ "__@toStringTag@239806": {
488
488
  "type": "string",
489
489
  "const": "Uint8Array"
490
490
  }
491
491
  },
492
492
  "required": [
493
493
  "BYTES_PER_ELEMENT",
494
- "__@toStringTag@239738",
494
+ "__@toStringTag@239806",
495
495
  "buffer",
496
496
  "byteLength",
497
497
  "byteOffset",
@@ -526,13 +526,13 @@
526
526
  "byteLength": {
527
527
  "type": "number"
528
528
  },
529
- "__@toStringTag@239738": {
529
+ "__@toStringTag@239806": {
530
530
  "type": "string"
531
531
  }
532
532
  },
533
533
  "additionalProperties": false,
534
534
  "required": [
535
- "__@toStringTag@239738",
535
+ "__@toStringTag@239806",
536
536
  "byteLength"
537
537
  ]
538
538
  },
@@ -542,18 +542,18 @@
542
542
  "byteLength": {
543
543
  "type": "number"
544
544
  },
545
- "__@species@239839": {
545
+ "__@species@239907": {
546
546
  "$ref": "#/definitions/SharedArrayBuffer"
547
547
  },
548
- "__@toStringTag@239738": {
548
+ "__@toStringTag@239806": {
549
549
  "type": "string",
550
550
  "const": "SharedArrayBuffer"
551
551
  }
552
552
  },
553
553
  "additionalProperties": false,
554
554
  "required": [
555
- "__@species@239839",
556
- "__@toStringTag@239738",
555
+ "__@species@239907",
556
+ "__@toStringTag@239806",
557
557
  "byteLength"
558
558
  ]
559
559
  },
@@ -14,7 +14,7 @@ export default class MetricsTotalGetRoute extends HTTPRoute {
14
14
  handler = async (_req, res) => {
15
15
  const fileSystem = this.fileSystem();
16
16
  const config = this.config();
17
- const metrics = (await fileSystem.read(config.getMetricsJSONPath())).map((m) => JSON.parse(m));
17
+ const metrics = (await fileSystem.read(config.getMetricsJSONPath(), false)).map((m) => JSON.parse(m));
18
18
  const availableMetrics = metrics.length;
19
19
  const totals = metrics.reduce((accum, metric) => ({
20
20
  error: accum.error + metric.error,
@@ -6,14 +6,14 @@ export default class MetricsGetRoute extends HTTPRoute {
6
6
  browser = null;
7
7
  concurrency = false;
8
8
  contentTypes = [contentTypes.json];
9
- description = `Gets total metric details from the time the server started.`;
9
+ description = `Returns a list of metric details as far back as possible.`;
10
10
  method = Methods.get;
11
11
  path = HTTPManagementRoutes.metrics;
12
12
  tags = [APITags.management];
13
13
  handler = async (_req, res) => {
14
14
  const fileSystem = this.fileSystem();
15
15
  const config = this.config();
16
- const stats = await fileSystem.read(config.getMetricsJSONPath());
16
+ const stats = await fileSystem.read(config.getMetricsJSONPath(), false);
17
17
  const response = `[${stats.join(',')}]`;
18
18
  return writeResponse(res, 200, response, contentTypes.json);
19
19
  };
@@ -0,0 +1,13 @@
1
+ export declare const getArgSwitches: () => {
2
+ [key: string]: string | true;
3
+ };
4
+ export declare const getSourceFiles: (cwd: string) => Promise<{
5
+ files: string[];
6
+ httpRoutes: string[];
7
+ webSocketRoutes: string[];
8
+ }>;
9
+ export declare const camelCase: (str: string) => string;
10
+ export declare const prompt: (question: string) => Promise<unknown>;
11
+ export declare const installDependencies: (workingDirectory: string) => Promise<void>;
12
+ export declare const buildDockerImage: (cmd: string, projectDir: string) => Promise<void>;
13
+ export declare const buildTypeScript: (buildDir: string, projectDir: string) => Promise<void>;
@@ -0,0 +1,94 @@
1
+ import { createInterface } from 'readline';
2
+ import debug from 'debug';
3
+ import fs from 'fs/promises';
4
+ import path from 'path';
5
+ import { spawn } from 'child_process';
6
+ export const getArgSwitches = () => {
7
+ return process.argv.reduce((accum, arg, idx) => {
8
+ if (!arg.startsWith('--')) {
9
+ return accum;
10
+ }
11
+ if (arg.includes('=')) {
12
+ const [parameter, value] = arg.split('=');
13
+ accum[parameter.replace(/-/gi, '')] = value || true;
14
+ return accum;
15
+ }
16
+ const nextSwitchOrParameter = process.argv[idx + 1];
17
+ const param = arg.replace(/-/gi, '');
18
+ if (typeof nextSwitchOrParameter === 'undefined' ||
19
+ nextSwitchOrParameter?.startsWith('--')) {
20
+ accum[param] = true;
21
+ return accum;
22
+ }
23
+ accum[param] = nextSwitchOrParameter;
24
+ return accum;
25
+ }, {});
26
+ };
27
+ export const getSourceFiles = async (cwd) => {
28
+ const buildDir = path.join(cwd, 'build');
29
+ const files = await fs.readdir(buildDir, { recursive: true });
30
+ const [httpRoutes, webSocketRoutes] = files.reduce(([httpRoutes, webSocketRoutes], file) => {
31
+ const parsed = path.parse(file);
32
+ if (parsed.name.endsWith('http')) {
33
+ httpRoutes.push(path.join(buildDir, file));
34
+ }
35
+ if (parsed.name.endsWith('ws')) {
36
+ webSocketRoutes.push(path.join(buildDir, file));
37
+ }
38
+ return [httpRoutes, webSocketRoutes];
39
+ }, [[], []]);
40
+ return {
41
+ files,
42
+ httpRoutes,
43
+ webSocketRoutes,
44
+ };
45
+ };
46
+ export const camelCase = (str) => str.replace(/-([a-z])/g, (_, w) => w.toUpperCase());
47
+ export const prompt = async (question) => {
48
+ const promptLog = debug('browserless.io:prompt');
49
+ const rl = createInterface({
50
+ input: process.stdin,
51
+ output: process.stdout,
52
+ });
53
+ return new Promise((resolve) => {
54
+ promptLog(question);
55
+ rl.question(' > ', (a) => {
56
+ rl.close();
57
+ resolve(a.trim());
58
+ });
59
+ });
60
+ };
61
+ export const installDependencies = async (workingDirectory) => new Promise((resolve, reject) => {
62
+ spawn('npm', ['i'], {
63
+ cwd: workingDirectory,
64
+ stdio: 'inherit',
65
+ }).once('close', (code) => {
66
+ if (code === 0) {
67
+ return resolve();
68
+ }
69
+ return reject(`Error when installing dependencies, see output for more details`);
70
+ });
71
+ });
72
+ export const buildDockerImage = async (cmd, projectDir) => new Promise((resolve, reject) => {
73
+ const [docker, ...args] = cmd.split(' ');
74
+ spawn(docker, args, {
75
+ cwd: projectDir,
76
+ stdio: 'inherit',
77
+ }).once('close', (code) => {
78
+ if (code === 0) {
79
+ return resolve();
80
+ }
81
+ return reject(`Error when building Docker image, see output for more details`);
82
+ });
83
+ });
84
+ export const buildTypeScript = async (buildDir, projectDir) => new Promise((resolve, reject) => {
85
+ spawn('npx', ['tsc', '--outDir', buildDir], {
86
+ cwd: projectDir,
87
+ stdio: 'inherit',
88
+ }).once('close', (code) => {
89
+ if (code === 0) {
90
+ return resolve();
91
+ }
92
+ return reject(`Error in building TypeScript, see output for more details`);
93
+ });
94
+ });
package/build/server.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  /// <reference types="node" />
6
6
  import * as http from 'http';
7
7
  import * as stream from 'stream';
8
- import { Config, Metrics, Request, Response, Router, Token } from '@browserless.io/browserless';
8
+ import { Config, Hooks, Metrics, Request, Response, Router, Token } from '@browserless.io/browserless';
9
9
  import { EventEmitter } from 'events';
10
10
  export interface HTTPServerOptions {
11
11
  concurrent: number;
@@ -19,12 +19,13 @@ export declare class HTTPServer extends EventEmitter {
19
19
  protected metrics: Metrics;
20
20
  protected token: Token;
21
21
  protected router: Router;
22
+ protected hooks: Hooks;
22
23
  protected server: http.Server;
23
24
  protected port: number;
24
25
  protected host?: string;
25
26
  protected log: import("debug").Debugger;
26
27
  protected verbose: import("debug").Debugger;
27
- constructor(config: Config, metrics: Metrics, token: Token, router: Router);
28
+ constructor(config: Config, metrics: Metrics, token: Token, router: Router, hooks: Hooks);
28
29
  protected onHTTPUnauthorized: (_req: Request, res: Response) => void;
29
30
  protected onWebsocketUnauthorized: (_req: Request, socket: stream.Duplex) => void;
30
31
  start(): Promise<void>;
package/build/server.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as http from 'http';
2
- import { BadRequest, NotFound, Timeout, TooManyRequests, Unauthorized, beforeRequest, contentTypes, convertPathToURL, createLogger, queryParamsToObject, readBody, shimLegacyRequests, writeResponse, } from '@browserless.io/browserless';
2
+ import { BadRequest, NotFound, Timeout, TooManyRequests, Unauthorized, contentTypes, convertPathToURL, createLogger, queryParamsToObject, readBody, shimLegacyRequests, writeResponse, } from '@browserless.io/browserless';
3
3
  import { EventEmitter } from 'events';
4
4
  // @ts-ignore
5
5
  import Enjoi from 'enjoi';
@@ -8,17 +8,19 @@ export class HTTPServer extends EventEmitter {
8
8
  metrics;
9
9
  token;
10
10
  router;
11
+ hooks;
11
12
  server = http.createServer();
12
13
  port;
13
14
  host;
14
15
  log = createLogger('server');
15
16
  verbose = createLogger('server:verbose');
16
- constructor(config, metrics, token, router) {
17
+ constructor(config, metrics, token, router, hooks) {
17
18
  super();
18
19
  this.config = config;
19
20
  this.metrics = metrics;
20
21
  this.token = token;
21
22
  this.router = router;
23
+ this.hooks = hooks;
22
24
  this.host = config.getHost();
23
25
  this.port = config.getPort();
24
26
  this.log(`Server instantiated with host "${this.host}" on port "${this.port}" using token "${this.config.getToken()}"`);
@@ -54,7 +56,7 @@ export class HTTPServer extends EventEmitter {
54
56
  handleRequest = async (request, res) => {
55
57
  this.verbose(`Handling inbound HTTP request on "${request.method}: ${request.url}"`);
56
58
  const req = request;
57
- const proceed = await beforeRequest({ req, res });
59
+ const proceed = await this.hooks.before({ req, res });
58
60
  req.parsed = convertPathToURL(request.url || '', this.config);
59
61
  shimLegacyRequests(req.parsed);
60
62
  if (!proceed)
@@ -168,7 +170,7 @@ export class HTTPServer extends EventEmitter {
168
170
  handleWebSocket = async (request, socket, head) => {
169
171
  this.verbose(`Handling inbound WebSocket request on "${request.url}"`);
170
172
  const req = request;
171
- const proceed = await beforeRequest({ head, req, socket });
173
+ const proceed = await this.hooks.before({ head, req, socket });
172
174
  req.parsed = convertPathToURL(request.url || '', this.config);
173
175
  shimLegacyRequests(req.parsed);
174
176
  if (!proceed)
package/build/types.d.ts CHANGED
@@ -9,12 +9,12 @@ import { HTTPRequest, Page, ResponseForRequest, ScreenshotOptions } from 'puppet
9
9
  export type PathTypes = HTTPRoutes | WebsocketRoutes | HTTPManagementRoutes | string;
10
10
  export interface BeforeRequest {
11
11
  head?: Buffer;
12
- req: Request;
12
+ req: http.IncomingMessage;
13
13
  res?: http.ServerResponse;
14
14
  socket?: stream.Duplex;
15
15
  }
16
16
  export interface AfterResponse {
17
- req: http.IncomingMessage;
17
+ req: Request;
18
18
  start: number;
19
19
  status: 'successful' | 'error' | 'timedout';
20
20
  }
package/build/utils.js CHANGED
@@ -322,15 +322,10 @@ export const availableBrowsers = Promise.all([
322
322
  }
323
323
  return availableBrowsers;
324
324
  });
325
- export const queryParamsToObject = (params) => {
326
- const entries = params.entries();
327
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
328
- const result = {};
329
- for (const [key, value] of entries) {
330
- result[key] = value === '' ? true : jsonOrString(value);
331
- }
332
- return result;
333
- };
325
+ export const queryParamsToObject = (params) => [...params.entries()].reduce((accum, [key, value]) => {
326
+ accum[key] = value;
327
+ return accum;
328
+ }, {});
334
329
  // eslint-disable-next-line @typescript-eslint/no-empty-function
335
330
  const AsyncFunction = Object.getPrototypeOf(async function () { }).constructor;
336
331
  const wrapUserFunction = (fn) => {
@@ -536,7 +531,8 @@ export const encrypt = (text, secret) => {
536
531
  ].join(encryptionSep);
537
532
  };
538
533
  export const decrypt = (encryptedText, secret) => {
539
- const [encrypted, iv] = encryptedText.split(encryptionSep);
534
+ const [encrypted, iv] = encryptedText.toString().split(encryptionSep);
535
+ console.log('>>', encryptedText.toString());
540
536
  if (!iv)
541
537
  throw new ServerError('Bad or invalid encrypted format');
542
538
  const decipher = crypto.createDecipheriv(encryptionAlgo, secret, Buffer.from(iv, 'hex'));
package/external/after.js CHANGED
@@ -1 +1 @@
1
- export default () => true;
1
+ export default async () => {};
@@ -1 +1 @@
1
- export default () => true;
1
+ export default async () => true;
@@ -1 +1 @@
1
- export default () => Promise.resolve(true);
1
+ export default async () => {};
package/external/page.js CHANGED
@@ -1 +1 @@
1
- export default () => Promise.resolve(true);
1
+ export default async () => {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@browserless.io/browserless",
3
- "version": "2.4.0",
3
+ "version": "2.5.0-beta-2",
4
4
  "license": "SSPL",
5
5
  "description": "The browserless platform",
6
6
  "author": "browserless.io",
@@ -29,7 +29,7 @@
29
29
  "install:dev": "npm run install:browsers",
30
30
  "lint": "eslint . --ext .ts --fix",
31
31
  "prepack": "npm run build:dev",
32
- "prettier": "prettier '{src,functions,scripts,bin,external,bin}/**/*.{js,ts,json}' --log-level error --write",
32
+ "prettier": "prettier '{src,functions,scripts,bin,external,.github}/**/*.{js,ts,json,yml,yaml,md}' --log-level error --write",
33
33
  "test": "cross-env DEBUG=quiet mocha",
34
34
  "start": "env-cmd -f .env node build"
35
35
  },
@@ -58,11 +58,11 @@
58
58
  "lighthouse": "^11.1.0",
59
59
  "micromatch": "^4.0.4",
60
60
  "playwright-core": "1.42.1",
61
- "puppeteer-core": "^22.4.0",
61
+ "puppeteer-core": "^22.4.1",
62
62
  "puppeteer-extra": "^3.3.6",
63
63
  "puppeteer-extra-plugin-stealth": "^2.11.2",
64
64
  "queue": "^7.0.0",
65
- "systeminformation": "^5.22.0"
65
+ "systeminformation": "^5.22.1"
66
66
  },
67
67
  "optionalDependencies": {
68
68
  "@types/chai": "^4.3.12",
@@ -71,10 +71,10 @@
71
71
  "@types/http-proxy": "^1.17.14",
72
72
  "@types/micromatch": "^4.0.6",
73
73
  "@types/mocha": "^10.0.6",
74
- "@types/node": "^20.11.25",
74
+ "@types/node": "^20.11.26",
75
75
  "@types/sinon": "^17.0.3",
76
- "@typescript-eslint/eslint-plugin": "^7.1.1",
77
- "@typescript-eslint/parser": "^7.1.1",
76
+ "@typescript-eslint/eslint-plugin": "^7.2.0",
77
+ "@typescript-eslint/parser": "^7.2.0",
78
78
  "assert": "^2.0.0",
79
79
  "chai": "^5.1.0",
80
80
  "cross-env": "^7.0.3",