@browserless.io/browserless 2.4.0-beta-3 → 2.5.0-beta-1

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 (58) hide show
  1. package/CHANGELOG.md +15 -1
  2. package/bin/browserless.js +17 -127
  3. package/bin/scaffold/README.md +95 -14
  4. package/build/browserless.d.ts +4 -2
  5. package/build/browserless.js +11 -8
  6. package/build/browsers/index.d.ts +3 -2
  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 +9 -4
  15. package/build/hooks.js +26 -8
  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 -11
  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 -11
  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/shared/content.http.js +1 -1
  34. package/build/shared/pdf.http.d.ts +0 -1
  35. package/build/shared/pdf.http.js +1 -1
  36. package/build/shared/screenshot.http.js +1 -1
  37. package/build/types.d.ts +3 -3
  38. package/build/utils.js +2 -1
  39. package/package.json +10 -10
  40. package/src/browserless.ts +22 -5
  41. package/src/browsers/index.ts +7 -5
  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 +32 -8
  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 +4 -4
  53. package/src/shared/pdf.http.ts +4 -5
  54. package/src/shared/screenshot.http.ts +4 -4
  55. package/src/utils.ts +2 -1
  56. package/static/docs/swagger.json +11 -17
  57. package/static/docs/swagger.min.json +10 -16
  58. package/static/function/client.js +76 -63
@@ -441,14 +441,14 @@
441
441
  "length": {
442
442
  "type": "number"
443
443
  },
444
- "__@toStringTag@108664": {
444
+ "__@toStringTag@130859": {
445
445
  "type": "string",
446
446
  "const": "Uint8Array"
447
447
  }
448
448
  },
449
449
  "required": [
450
450
  "BYTES_PER_ELEMENT",
451
- "__@toStringTag@108664",
451
+ "__@toStringTag@130859",
452
452
  "buffer",
453
453
  "byteLength",
454
454
  "byteOffset",
@@ -483,13 +483,13 @@
483
483
  "byteLength": {
484
484
  "type": "number"
485
485
  },
486
- "__@toStringTag@108664": {
486
+ "__@toStringTag@130859": {
487
487
  "type": "string"
488
488
  }
489
489
  },
490
490
  "additionalProperties": false,
491
491
  "required": [
492
- "__@toStringTag@108664",
492
+ "__@toStringTag@130859",
493
493
  "byteLength"
494
494
  ]
495
495
  },
@@ -499,18 +499,18 @@
499
499
  "byteLength": {
500
500
  "type": "number"
501
501
  },
502
- "__@species@108765": {
502
+ "__@species@130960": {
503
503
  "$ref": "#/definitions/SharedArrayBuffer"
504
504
  },
505
- "__@toStringTag@108664": {
505
+ "__@toStringTag@130859": {
506
506
  "type": "string",
507
507
  "const": "SharedArrayBuffer"
508
508
  }
509
509
  },
510
510
  "additionalProperties": false,
511
511
  "required": [
512
- "__@species@108765",
513
- "__@toStringTag@108664",
512
+ "__@species@130960",
513
+ "__@toStringTag@130859",
514
514
  "byteLength"
515
515
  ]
516
516
  },
@@ -484,14 +484,14 @@
484
484
  "length": {
485
485
  "type": "number"
486
486
  },
487
- "__@toStringTag@119813": {
487
+ "__@toStringTag@108705": {
488
488
  "type": "string",
489
489
  "const": "Uint8Array"
490
490
  }
491
491
  },
492
492
  "required": [
493
493
  "BYTES_PER_ELEMENT",
494
- "__@toStringTag@119813",
494
+ "__@toStringTag@108705",
495
495
  "buffer",
496
496
  "byteLength",
497
497
  "byteOffset",
@@ -526,13 +526,13 @@
526
526
  "byteLength": {
527
527
  "type": "number"
528
528
  },
529
- "__@toStringTag@119813": {
529
+ "__@toStringTag@108705": {
530
530
  "type": "string"
531
531
  }
532
532
  },
533
533
  "additionalProperties": false,
534
534
  "required": [
535
- "__@toStringTag@119813",
535
+ "__@toStringTag@108705",
536
536
  "byteLength"
537
537
  ]
538
538
  },
@@ -542,18 +542,18 @@
542
542
  "byteLength": {
543
543
  "type": "number"
544
544
  },
545
- "__@species@119914": {
545
+ "__@species@108806": {
546
546
  "$ref": "#/definitions/SharedArrayBuffer"
547
547
  },
548
- "__@toStringTag@119813": {
548
+ "__@toStringTag@108705": {
549
549
  "type": "string",
550
550
  "const": "SharedArrayBuffer"
551
551
  }
552
552
  },
553
553
  "additionalProperties": false,
554
554
  "required": [
555
- "__@species@119914",
556
- "__@toStringTag@119813",
555
+ "__@species@108806",
556
+ "__@toStringTag@108705",
557
557
  "byteLength"
558
558
  ]
559
559
  },
@@ -394,14 +394,14 @@
394
394
  "length": {
395
395
  "type": "number"
396
396
  },
397
- "__@toStringTag@141676": {
397
+ "__@toStringTag@119767": {
398
398
  "type": "string",
399
399
  "const": "Uint8Array"
400
400
  }
401
401
  },
402
402
  "required": [
403
403
  "BYTES_PER_ELEMENT",
404
- "__@toStringTag@141676",
404
+ "__@toStringTag@119767",
405
405
  "buffer",
406
406
  "byteLength",
407
407
  "byteOffset",
@@ -436,13 +436,13 @@
436
436
  "byteLength": {
437
437
  "type": "number"
438
438
  },
439
- "__@toStringTag@141676": {
439
+ "__@toStringTag@119767": {
440
440
  "type": "string"
441
441
  }
442
442
  },
443
443
  "additionalProperties": false,
444
444
  "required": [
445
- "__@toStringTag@141676",
445
+ "__@toStringTag@119767",
446
446
  "byteLength"
447
447
  ]
448
448
  },
@@ -452,18 +452,18 @@
452
452
  "byteLength": {
453
453
  "type": "number"
454
454
  },
455
- "__@species@141777": {
455
+ "__@species@119868": {
456
456
  "$ref": "#/definitions/SharedArrayBuffer"
457
457
  },
458
- "__@toStringTag@141676": {
458
+ "__@toStringTag@119767": {
459
459
  "type": "string",
460
460
  "const": "SharedArrayBuffer"
461
461
  }
462
462
  },
463
463
  "additionalProperties": false,
464
464
  "required": [
465
- "__@species@141777",
466
- "__@toStringTag@141676",
465
+ "__@species@119868",
466
+ "__@toStringTag@119767",
467
467
  "byteLength"
468
468
  ]
469
469
  },
@@ -20,9 +20,6 @@
20
20
  "description": "When bestAttempt is set to true, browserless attempt to proceed\nwhen \"awaited\" events fail or timeout. This includes things like\ngoto, waitForSelector, and more.",
21
21
  "type": "boolean"
22
22
  },
23
- "blockModals": {
24
- "type": "boolean"
25
- },
26
23
  "cookies": {
27
24
  "type": "array",
28
25
  "items": {
@@ -538,14 +535,14 @@
538
535
  "length": {
539
536
  "type": "number"
540
537
  },
541
- "__@toStringTag@206722": {
538
+ "__@toStringTag@206779": {
542
539
  "type": "string",
543
540
  "const": "Uint8Array"
544
541
  }
545
542
  },
546
543
  "required": [
547
544
  "BYTES_PER_ELEMENT",
548
- "__@toStringTag@206722",
545
+ "__@toStringTag@206779",
549
546
  "buffer",
550
547
  "byteLength",
551
548
  "byteOffset",
@@ -580,13 +577,13 @@
580
577
  "byteLength": {
581
578
  "type": "number"
582
579
  },
583
- "__@toStringTag@206722": {
580
+ "__@toStringTag@206779": {
584
581
  "type": "string"
585
582
  }
586
583
  },
587
584
  "additionalProperties": false,
588
585
  "required": [
589
- "__@toStringTag@206722",
586
+ "__@toStringTag@206779",
590
587
  "byteLength"
591
588
  ]
592
589
  },
@@ -596,18 +593,18 @@
596
593
  "byteLength": {
597
594
  "type": "number"
598
595
  },
599
- "__@species@206823": {
596
+ "__@species@206880": {
600
597
  "$ref": "#/definitions/SharedArrayBuffer"
601
598
  },
602
- "__@toStringTag@206722": {
599
+ "__@toStringTag@206779": {
603
600
  "type": "string",
604
601
  "const": "SharedArrayBuffer"
605
602
  }
606
603
  },
607
604
  "additionalProperties": false,
608
605
  "required": [
609
- "__@species@206823",
610
- "__@toStringTag@206722",
606
+ "__@species@206880",
607
+ "__@toStringTag@206779",
611
608
  "byteLength"
612
609
  ]
613
610
  },
@@ -441,14 +441,14 @@
441
441
  "length": {
442
442
  "type": "number"
443
443
  },
444
- "__@toStringTag@217791": {
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@217791",
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@217791": {
486
+ "__@toStringTag@228657": {
487
487
  "type": "string"
488
488
  }
489
489
  },
490
490
  "additionalProperties": false,
491
491
  "required": [
492
- "__@toStringTag@217791",
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@217892": {
502
+ "__@species@228758": {
503
503
  "$ref": "#/definitions/SharedArrayBuffer"
504
504
  },
505
- "__@toStringTag@217791": {
505
+ "__@toStringTag@228657": {
506
506
  "type": "string",
507
507
  "const": "SharedArrayBuffer"
508
508
  }
509
509
  },
510
510
  "additionalProperties": false,
511
511
  "required": [
512
- "__@species@217892",
513
- "__@toStringTag@217791",
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@239740": {
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@239740",
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@239740": {
529
+ "__@toStringTag@239806": {
530
530
  "type": "string"
531
531
  }
532
532
  },
533
533
  "additionalProperties": false,
534
534
  "required": [
535
- "__@toStringTag@239740",
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@239841": {
545
+ "__@species@239907": {
546
546
  "$ref": "#/definitions/SharedArrayBuffer"
547
547
  },
548
- "__@toStringTag@239740": {
548
+ "__@toStringTag@239806": {
549
549
  "type": "string",
550
550
  "const": "SharedArrayBuffer"
551
551
  }
552
552
  },
553
553
  "additionalProperties": false,
554
554
  "required": [
555
- "__@species@239841",
556
- "__@toStringTag@239740",
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)
@@ -62,6 +62,7 @@ export default class ChromiumContentPostRoute extends BrowserHTTPRoute {
62
62
  return req.continue();
63
63
  });
64
64
  }
65
+ const gotoResponse = await gotoCall(content, gotoOptions).catch(bestAttemptCatch(bestAttempt));
65
66
  if (addStyleTag.length) {
66
67
  for (const tag in addStyleTag) {
67
68
  await page.addStyleTag(addStyleTag[tag]);
@@ -72,7 +73,6 @@ export default class ChromiumContentPostRoute extends BrowserHTTPRoute {
72
73
  await page.addScriptTag(addScriptTag[tag]);
73
74
  }
74
75
  }
75
- const gotoResponse = await gotoCall(content, gotoOptions).catch(bestAttemptCatch(bestAttempt));
76
76
  if (waitForTimeout) {
77
77
  await sleep(waitForTimeout).catch(bestAttemptCatch(bestAttempt));
78
78
  }
@@ -7,7 +7,6 @@ export interface BodySchema {
7
7
  addStyleTag?: Array<Parameters<Page['addStyleTag']>[0]>;
8
8
  authenticate?: Parameters<Page['authenticate']>[0];
9
9
  bestAttempt?: bestAttempt;
10
- blockModals?: boolean;
11
10
  cookies?: Array<Parameters<Page['setCookie']>[0]>;
12
11
  emulateMediaType?: Parameters<Page['emulateMediaType']>[0];
13
12
  gotoOptions?: Parameters<Page['goto']>[1];
@@ -69,6 +69,7 @@ export default class ChromiumPDFPostRoute extends BrowserHTTPRoute {
69
69
  return req.continue();
70
70
  });
71
71
  }
72
+ const gotoResponse = await gotoCall(content, gotoOptions).catch(bestAttemptCatch(bestAttempt));
72
73
  if (addStyleTag.length) {
73
74
  for (const tag in addStyleTag) {
74
75
  await page.addStyleTag(addStyleTag[tag]);
@@ -79,7 +80,6 @@ export default class ChromiumPDFPostRoute extends BrowserHTTPRoute {
79
80
  await page.addScriptTag(addScriptTag[tag]);
80
81
  }
81
82
  }
82
- const gotoResponse = await gotoCall(content, gotoOptions).catch(bestAttemptCatch(bestAttempt));
83
83
  if (waitForTimeout) {
84
84
  await sleep(waitForTimeout).catch(bestAttemptCatch(bestAttempt));
85
85
  }
@@ -70,6 +70,7 @@ export default class ScreenshotPost extends BrowserHTTPRoute {
70
70
  return req.continue();
71
71
  });
72
72
  }
73
+ const gotoResponse = await gotoCall(content, gotoOptions).catch(bestAttemptCatch(bestAttempt));
73
74
  if (addStyleTag.length) {
74
75
  for (const tag in addStyleTag) {
75
76
  await page.addStyleTag(addStyleTag[tag]);
@@ -80,7 +81,6 @@ export default class ScreenshotPost extends BrowserHTTPRoute {
80
81
  await page.addScriptTag(addScriptTag[tag]);
81
82
  }
82
83
  }
83
- const gotoResponse = await gotoCall(content, gotoOptions).catch(bestAttemptCatch(bestAttempt));
84
84
  if (waitForTimeout) {
85
85
  await sleep(waitForTimeout).catch(bestAttemptCatch(bestAttempt));
86
86
  }
package/build/types.d.ts CHANGED
@@ -100,7 +100,7 @@ declare abstract class Route {
100
100
  * and injected by browserless after initialization.
101
101
  * @returns BrowserManager
102
102
  */
103
- browserManager: () => import("@browserless.io/browserless").BrowserManager;
103
+ browserManager: () => import("src/browsers").BrowserManager;
104
104
  /**
105
105
  * Helper function that loads the config module. Defined and injected by
106
106
  * browserless after initialization.
@@ -120,7 +120,7 @@ declare abstract class Route {
120
120
  * browserless after initialization.
121
121
  * @returns FileSystem
122
122
  */
123
- fileSystem: () => import("@browserless.io/browserless").FileSystem;
123
+ fileSystem: () => import("src/file-system").FileSystem;
124
124
  /**
125
125
  * Helper function that loads the metrics module for
126
126
  * collecting and aggregating statistics. Defined and injected by
@@ -134,7 +134,7 @@ declare abstract class Route {
134
134
  * browserless after initialization.
135
135
  * @returns Monitor
136
136
  */
137
- monitoring: () => import("@browserless.io/browserless").Monitoring;
137
+ monitoring: () => import("src/monitoring").Monitoring;
138
138
  /**
139
139
  * When running in an SDK environment, this returns the fully-qualified
140
140
  * directory of that static directory. When "null" then no SDK directory
package/build/utils.js CHANGED
@@ -536,7 +536,8 @@ export const encrypt = (text, secret) => {
536
536
  ].join(encryptionSep);
537
537
  };
538
538
  export const decrypt = (encryptedText, secret) => {
539
- const [encrypted, iv] = encryptedText.split(encryptionSep);
539
+ const [encrypted, iv] = encryptedText.toString().split(encryptionSep);
540
+ console.log('>>', encryptedText.toString());
540
541
  if (!iv)
541
542
  throw new ServerError('Bad or invalid encrypted format');
542
543
  const decipher = crypto.createDecipheriv(encryptionAlgo, secret, Buffer.from(iv, 'hex'));