@browserless.io/browserless 2.24.0-beta-2 → 2.24.0-beta-4

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/build/config.d.ts CHANGED
@@ -91,7 +91,7 @@ export declare class Config extends EventEmitter {
91
91
  * do AES encoding for saving things to disk and generating
92
92
  * secure links.
93
93
  */
94
- getAESKey(): Buffer;
94
+ getAESKey(): Buffer<ArrayBuffer>;
95
95
  getMetricsJSONPath(): string;
96
96
  setPwVersions(versions: {
97
97
  [key: string]: string;
package/build/http.d.ts CHANGED
@@ -151,6 +151,7 @@ export declare enum HTTPRoutes {
151
151
  export declare enum HTTPManagementRoutes {
152
152
  active = "/active?(/)",
153
153
  config = "/config?(/)",
154
+ meta = "/meta?(/)",
154
155
  metrics = "/metrics?(/)",
155
156
  metricsTotal = "/metrics/total?(/)",
156
157
  pressure = "/pressure?(/)",
package/build/http.js CHANGED
@@ -117,6 +117,7 @@ export var HTTPManagementRoutes;
117
117
  (function (HTTPManagementRoutes) {
118
118
  HTTPManagementRoutes["active"] = "/active?(/)";
119
119
  HTTPManagementRoutes["config"] = "/config?(/)";
120
+ HTTPManagementRoutes["meta"] = "/meta?(/)";
120
121
  HTTPManagementRoutes["metrics"] = "/metrics?(/)";
121
122
  HTTPManagementRoutes["metricsTotal"] = "/metrics/total?(/)";
122
123
  HTTPManagementRoutes["pressure"] = "/pressure?(/)";
@@ -438,14 +438,14 @@
438
438
  "length": {
439
439
  "type": "number"
440
440
  },
441
- "__@toStringTag@14497": {
441
+ "__@toStringTag@14520": {
442
442
  "type": "string",
443
443
  "const": "Uint8Array"
444
444
  }
445
445
  },
446
446
  "required": [
447
447
  "BYTES_PER_ELEMENT",
448
- "__@toStringTag@14497",
448
+ "__@toStringTag@14520",
449
449
  "buffer",
450
450
  "byteLength",
451
451
  "byteOffset",
@@ -480,13 +480,13 @@
480
480
  "byteLength": {
481
481
  "type": "number"
482
482
  },
483
- "__@toStringTag@14497": {
483
+ "__@toStringTag@14520": {
484
484
  "type": "string"
485
485
  }
486
486
  },
487
487
  "additionalProperties": false,
488
488
  "required": [
489
- "__@toStringTag@14497",
489
+ "__@toStringTag@14520",
490
490
  "byteLength"
491
491
  ]
492
492
  },
@@ -496,18 +496,18 @@
496
496
  "byteLength": {
497
497
  "type": "number"
498
498
  },
499
- "__@species@14535": {
499
+ "__@species@14558": {
500
500
  "$ref": "#/definitions/SharedArrayBuffer"
501
501
  },
502
- "__@toStringTag@14497": {
502
+ "__@toStringTag@14520": {
503
503
  "type": "string",
504
504
  "const": "SharedArrayBuffer"
505
505
  }
506
506
  },
507
507
  "additionalProperties": false,
508
508
  "required": [
509
- "__@species@14535",
510
- "__@toStringTag@14497",
509
+ "__@species@14558",
510
+ "__@toStringTag@14520",
511
511
  "byteLength"
512
512
  ]
513
513
  },
@@ -583,14 +583,14 @@
583
583
  "length": {
584
584
  "type": "number"
585
585
  },
586
- "__@toStringTag@129779": {
586
+ "__@toStringTag@115575": {
587
587
  "type": "string",
588
588
  "const": "Uint8Array"
589
589
  }
590
590
  },
591
591
  "required": [
592
592
  "BYTES_PER_ELEMENT",
593
- "__@toStringTag@129779",
593
+ "__@toStringTag@115575",
594
594
  "buffer",
595
595
  "byteLength",
596
596
  "byteOffset",
@@ -625,13 +625,13 @@
625
625
  "byteLength": {
626
626
  "type": "number"
627
627
  },
628
- "__@toStringTag@129779": {
628
+ "__@toStringTag@115575": {
629
629
  "type": "string"
630
630
  }
631
631
  },
632
632
  "additionalProperties": false,
633
633
  "required": [
634
- "__@toStringTag@129779",
634
+ "__@toStringTag@115575",
635
635
  "byteLength"
636
636
  ]
637
637
  },
@@ -641,18 +641,18 @@
641
641
  "byteLength": {
642
642
  "type": "number"
643
643
  },
644
- "__@species@129817": {
644
+ "__@species@115613": {
645
645
  "$ref": "#/definitions/SharedArrayBuffer"
646
646
  },
647
- "__@toStringTag@129779": {
647
+ "__@toStringTag@115575": {
648
648
  "type": "string",
649
649
  "const": "SharedArrayBuffer"
650
650
  }
651
651
  },
652
652
  "additionalProperties": false,
653
653
  "required": [
654
- "__@species@129817",
655
- "__@toStringTag@129779",
654
+ "__@species@115613",
655
+ "__@toStringTag@115575",
656
656
  "byteLength"
657
657
  ]
658
658
  },
@@ -485,14 +485,14 @@
485
485
  "length": {
486
486
  "type": "number"
487
487
  },
488
- "__@toStringTag@144367": {
488
+ "__@toStringTag@144808": {
489
489
  "type": "string",
490
490
  "const": "Uint8Array"
491
491
  }
492
492
  },
493
493
  "required": [
494
494
  "BYTES_PER_ELEMENT",
495
- "__@toStringTag@144367",
495
+ "__@toStringTag@144808",
496
496
  "buffer",
497
497
  "byteLength",
498
498
  "byteOffset",
@@ -527,13 +527,13 @@
527
527
  "byteLength": {
528
528
  "type": "number"
529
529
  },
530
- "__@toStringTag@144367": {
530
+ "__@toStringTag@144808": {
531
531
  "type": "string"
532
532
  }
533
533
  },
534
534
  "additionalProperties": false,
535
535
  "required": [
536
- "__@toStringTag@144367",
536
+ "__@toStringTag@144808",
537
537
  "byteLength"
538
538
  ]
539
539
  },
@@ -543,18 +543,18 @@
543
543
  "byteLength": {
544
544
  "type": "number"
545
545
  },
546
- "__@species@144405": {
546
+ "__@species@144846": {
547
547
  "$ref": "#/definitions/SharedArrayBuffer"
548
548
  },
549
- "__@toStringTag@144367": {
549
+ "__@toStringTag@144808": {
550
550
  "type": "string",
551
551
  "const": "SharedArrayBuffer"
552
552
  }
553
553
  },
554
554
  "additionalProperties": false,
555
555
  "required": [
556
- "__@species@144405",
557
- "__@toStringTag@144367",
556
+ "__@species@144846",
557
+ "__@toStringTag@144808",
558
558
  "byteLength"
559
559
  ]
560
560
  },
@@ -528,14 +528,14 @@
528
528
  "length": {
529
529
  "type": "number"
530
530
  },
531
- "__@toStringTag@159032": {
531
+ "__@toStringTag@130197": {
532
532
  "type": "string",
533
533
  "const": "Uint8Array"
534
534
  }
535
535
  },
536
536
  "required": [
537
537
  "BYTES_PER_ELEMENT",
538
- "__@toStringTag@159032",
538
+ "__@toStringTag@130197",
539
539
  "buffer",
540
540
  "byteLength",
541
541
  "byteOffset",
@@ -570,13 +570,13 @@
570
570
  "byteLength": {
571
571
  "type": "number"
572
572
  },
573
- "__@toStringTag@159032": {
573
+ "__@toStringTag@130197": {
574
574
  "type": "string"
575
575
  }
576
576
  },
577
577
  "additionalProperties": false,
578
578
  "required": [
579
- "__@toStringTag@159032",
579
+ "__@toStringTag@130197",
580
580
  "byteLength"
581
581
  ]
582
582
  },
@@ -586,18 +586,18 @@
586
586
  "byteLength": {
587
587
  "type": "number"
588
588
  },
589
- "__@species@159070": {
589
+ "__@species@130235": {
590
590
  "$ref": "#/definitions/SharedArrayBuffer"
591
591
  },
592
- "__@toStringTag@159032": {
592
+ "__@toStringTag@130197": {
593
593
  "type": "string",
594
594
  "const": "SharedArrayBuffer"
595
595
  }
596
596
  },
597
597
  "additionalProperties": false,
598
598
  "required": [
599
- "__@species@159070",
600
- "__@toStringTag@159032",
599
+ "__@species@130235",
600
+ "__@toStringTag@130197",
601
601
  "byteLength"
602
602
  ]
603
603
  },
@@ -438,14 +438,14 @@
438
438
  "length": {
439
439
  "type": "number"
440
440
  },
441
- "__@toStringTag@187970": {
441
+ "__@toStringTag@173883": {
442
442
  "type": "string",
443
443
  "const": "Uint8Array"
444
444
  }
445
445
  },
446
446
  "required": [
447
447
  "BYTES_PER_ELEMENT",
448
- "__@toStringTag@187970",
448
+ "__@toStringTag@173883",
449
449
  "buffer",
450
450
  "byteLength",
451
451
  "byteOffset",
@@ -480,13 +480,13 @@
480
480
  "byteLength": {
481
481
  "type": "number"
482
482
  },
483
- "__@toStringTag@187970": {
483
+ "__@toStringTag@173883": {
484
484
  "type": "string"
485
485
  }
486
486
  },
487
487
  "additionalProperties": false,
488
488
  "required": [
489
- "__@toStringTag@187970",
489
+ "__@toStringTag@173883",
490
490
  "byteLength"
491
491
  ]
492
492
  },
@@ -496,18 +496,18 @@
496
496
  "byteLength": {
497
497
  "type": "number"
498
498
  },
499
- "__@species@188008": {
499
+ "__@species@173921": {
500
500
  "$ref": "#/definitions/SharedArrayBuffer"
501
501
  },
502
- "__@toStringTag@187970": {
502
+ "__@toStringTag@173883": {
503
503
  "type": "string",
504
504
  "const": "SharedArrayBuffer"
505
505
  }
506
506
  },
507
507
  "additionalProperties": false,
508
508
  "required": [
509
- "__@species@188008",
510
- "__@toStringTag@187970",
509
+ "__@species@173921",
510
+ "__@toStringTag@173883",
511
511
  "byteLength"
512
512
  ]
513
513
  },
@@ -583,14 +583,14 @@
583
583
  "length": {
584
584
  "type": "number"
585
585
  },
586
- "__@toStringTag@260090": {
586
+ "__@toStringTag@260481": {
587
587
  "type": "string",
588
588
  "const": "Uint8Array"
589
589
  }
590
590
  },
591
591
  "required": [
592
592
  "BYTES_PER_ELEMENT",
593
- "__@toStringTag@260090",
593
+ "__@toStringTag@260481",
594
594
  "buffer",
595
595
  "byteLength",
596
596
  "byteOffset",
@@ -625,13 +625,13 @@
625
625
  "byteLength": {
626
626
  "type": "number"
627
627
  },
628
- "__@toStringTag@260090": {
628
+ "__@toStringTag@260481": {
629
629
  "type": "string"
630
630
  }
631
631
  },
632
632
  "additionalProperties": false,
633
633
  "required": [
634
- "__@toStringTag@260090",
634
+ "__@toStringTag@260481",
635
635
  "byteLength"
636
636
  ]
637
637
  },
@@ -641,18 +641,18 @@
641
641
  "byteLength": {
642
642
  "type": "number"
643
643
  },
644
- "__@species@260128": {
644
+ "__@species@260519": {
645
645
  "$ref": "#/definitions/SharedArrayBuffer"
646
646
  },
647
- "__@toStringTag@260090": {
647
+ "__@toStringTag@260481": {
648
648
  "type": "string",
649
649
  "const": "SharedArrayBuffer"
650
650
  }
651
651
  },
652
652
  "additionalProperties": false,
653
653
  "required": [
654
- "__@species@260128",
655
- "__@toStringTag@260090",
654
+ "__@species@260519",
655
+ "__@toStringTag@260481",
656
656
  "byteLength"
657
657
  ]
658
658
  },
@@ -485,14 +485,14 @@
485
485
  "length": {
486
486
  "type": "number"
487
487
  },
488
- "__@toStringTag@289088": {
488
+ "__@toStringTag@289525": {
489
489
  "type": "string",
490
490
  "const": "Uint8Array"
491
491
  }
492
492
  },
493
493
  "required": [
494
494
  "BYTES_PER_ELEMENT",
495
- "__@toStringTag@289088",
495
+ "__@toStringTag@289525",
496
496
  "buffer",
497
497
  "byteLength",
498
498
  "byteOffset",
@@ -527,13 +527,13 @@
527
527
  "byteLength": {
528
528
  "type": "number"
529
529
  },
530
- "__@toStringTag@289088": {
530
+ "__@toStringTag@289525": {
531
531
  "type": "string"
532
532
  }
533
533
  },
534
534
  "additionalProperties": false,
535
535
  "required": [
536
- "__@toStringTag@289088",
536
+ "__@toStringTag@289525",
537
537
  "byteLength"
538
538
  ]
539
539
  },
@@ -543,18 +543,18 @@
543
543
  "byteLength": {
544
544
  "type": "number"
545
545
  },
546
- "__@species@289126": {
546
+ "__@species@289563": {
547
547
  "$ref": "#/definitions/SharedArrayBuffer"
548
548
  },
549
- "__@toStringTag@289088": {
549
+ "__@toStringTag@289525": {
550
550
  "type": "string",
551
551
  "const": "SharedArrayBuffer"
552
552
  }
553
553
  },
554
554
  "additionalProperties": false,
555
555
  "required": [
556
- "__@species@289126",
557
- "__@toStringTag@289088",
556
+ "__@species@289563",
557
+ "__@toStringTag@289525",
558
558
  "byteLength"
559
559
  ]
560
560
  },
@@ -528,14 +528,14 @@
528
528
  "length": {
529
529
  "type": "number"
530
530
  },
531
- "__@toStringTag@318112": {
531
+ "__@toStringTag@304210": {
532
532
  "type": "string",
533
533
  "const": "Uint8Array"
534
534
  }
535
535
  },
536
536
  "required": [
537
537
  "BYTES_PER_ELEMENT",
538
- "__@toStringTag@318112",
538
+ "__@toStringTag@304210",
539
539
  "buffer",
540
540
  "byteLength",
541
541
  "byteOffset",
@@ -570,13 +570,13 @@
570
570
  "byteLength": {
571
571
  "type": "number"
572
572
  },
573
- "__@toStringTag@318112": {
573
+ "__@toStringTag@304210": {
574
574
  "type": "string"
575
575
  }
576
576
  },
577
577
  "additionalProperties": false,
578
578
  "required": [
579
- "__@toStringTag@318112",
579
+ "__@toStringTag@304210",
580
580
  "byteLength"
581
581
  ]
582
582
  },
@@ -586,18 +586,18 @@
586
586
  "byteLength": {
587
587
  "type": "number"
588
588
  },
589
- "__@species@318150": {
589
+ "__@species@304248": {
590
590
  "$ref": "#/definitions/SharedArrayBuffer"
591
591
  },
592
- "__@toStringTag@318112": {
592
+ "__@toStringTag@304210": {
593
593
  "type": "string",
594
594
  "const": "SharedArrayBuffer"
595
595
  }
596
596
  },
597
597
  "additionalProperties": false,
598
598
  "required": [
599
- "__@species@318150",
600
- "__@toStringTag@318112",
599
+ "__@species@304248",
600
+ "__@toStringTag@304210",
601
601
  "byteLength"
602
602
  ]
603
603
  },
@@ -0,0 +1,41 @@
1
+ import { APITags, HTTPManagementRoutes, HTTPRoute, Methods, Request, contentTypes } from '@browserless.io/browserless';
2
+ import { ServerResponse } from 'http';
3
+ export interface ResponseSchema {
4
+ /**
5
+ * The semantic version of the Browserless API
6
+ */
7
+ version: string;
8
+ /**
9
+ * The version of Chromium installed, or null if not installed
10
+ */
11
+ chromium: string | null;
12
+ /**
13
+ * The version of Webkit installed, or null if not installed
14
+ */
15
+ webkit: string | null;
16
+ /**
17
+ * The version of Firefox installed, or null if not installed
18
+ */
19
+ firefox: string | null;
20
+ /**
21
+ * The supported version(s) of puppeteer
22
+ */
23
+ playwright: string[];
24
+ /**
25
+ * The supported version(s) of playwright
26
+ */
27
+ puppeteer: string[];
28
+ }
29
+ export default class MetaGetRoute extends HTTPRoute {
30
+ name: string;
31
+ accepts: contentTypes[];
32
+ auth: boolean;
33
+ browser: null;
34
+ concurrency: boolean;
35
+ contentTypes: contentTypes[];
36
+ description: string;
37
+ method: Methods;
38
+ path: HTTPManagementRoutes;
39
+ tags: APITags[];
40
+ handler(_req: Request, res: ServerResponse): Promise<void>;
41
+ }
@@ -0,0 +1,40 @@
1
+ import { APITags, BrowserlessRoutes, ChromiumCDP, FirefoxPlaywright, HTTPManagementRoutes, HTTPRoute, Methods, WebKitPlaywright, availableBrowsers, contentTypes, jsonResponse, } from '@browserless.io/browserless';
2
+ import { createRequire } from 'module';
3
+ const semverReg = /(\*|\^|>|=|<|~)/gi;
4
+ const require = createRequire(import.meta.url);
5
+ const blessPackageJSON = require('../../../../package.json');
6
+ const { browsers } = require('../../../../node_modules/playwright-core/browsers.json');
7
+ const chromium = browsers.find((b) => b.name === 'chromium').browserVersion;
8
+ const firefox = browsers.find((b) => b.name === 'firefox').browserVersion;
9
+ const webkit = browsers.find((b) => b.name === 'webkit').browserVersion;
10
+ const playwrightCore = blessPackageJSON.dependencies['playwright-core'].replace(semverReg, '');
11
+ const puppeteer = blessPackageJSON.dependencies['puppeteer-core'].replace(semverReg, '');
12
+ const playwright = Object.entries(blessPackageJSON.playwrightVersions)
13
+ .map(([, v]) => blessPackageJSON.dependencies[v])
14
+ .filter((_) => !!_)
15
+ .map((v) => v.match(/[0-9.]+/g).join(''))
16
+ .concat(playwrightCore);
17
+ export default class MetaGetRoute extends HTTPRoute {
18
+ name = BrowserlessRoutes.MetaGetRoute;
19
+ accepts = [contentTypes.any];
20
+ auth = true;
21
+ browser = null;
22
+ concurrency = false;
23
+ contentTypes = [contentTypes.json];
24
+ description = `Returns a JSON payload of the current system versions, including the core API version.`;
25
+ method = Methods.get;
26
+ path = HTTPManagementRoutes.meta;
27
+ tags = [APITags.management];
28
+ async handler(_req, res) {
29
+ const installedBrowsers = await availableBrowsers;
30
+ const response = {
31
+ version: blessPackageJSON.version,
32
+ chromium: installedBrowsers.includes(ChromiumCDP) ? chromium : null,
33
+ firefox: installedBrowsers.includes(FirefoxPlaywright) ? firefox : null,
34
+ webkit: installedBrowsers.includes(WebKitPlaywright) ? webkit : null,
35
+ playwright: [...new Set(playwright)],
36
+ puppeteer: [puppeteer],
37
+ };
38
+ return jsonResponse(res, 200, response);
39
+ }
40
+ }
@@ -0,0 +1,54 @@
1
+ {
2
+ "type": "object",
3
+ "properties": {
4
+ "version": {
5
+ "description": "The semantic version of the Browserless API",
6
+ "type": "string"
7
+ },
8
+ "chromium": {
9
+ "description": "The version of Chromium installed, or null if not installed",
10
+ "type": [
11
+ "null",
12
+ "string"
13
+ ]
14
+ },
15
+ "webkit": {
16
+ "description": "The version of Webkit installed, or null if not installed",
17
+ "type": [
18
+ "null",
19
+ "string"
20
+ ]
21
+ },
22
+ "firefox": {
23
+ "description": "The version of Firefox installed, or null if not installed",
24
+ "type": [
25
+ "null",
26
+ "string"
27
+ ]
28
+ },
29
+ "playwright": {
30
+ "description": "The supported version(s) of puppeteer",
31
+ "type": "array",
32
+ "items": {
33
+ "type": "string"
34
+ }
35
+ },
36
+ "puppeteer": {
37
+ "description": "The supported version(s) of playwright",
38
+ "type": "array",
39
+ "items": {
40
+ "type": "string"
41
+ }
42
+ }
43
+ },
44
+ "additionalProperties": false,
45
+ "required": [
46
+ "chromium",
47
+ "firefox",
48
+ "playwright",
49
+ "puppeteer",
50
+ "version",
51
+ "webkit"
52
+ ],
53
+ "$schema": "http://json-schema.org/draft-07/schema#"
54
+ }
@@ -17,6 +17,13 @@ describe('Management APIs', function () {
17
17
  expect(res.status).to.equal(200);
18
18
  });
19
19
  });
20
+ it('allows requests to /meta', async () => {
21
+ await start();
22
+ await fetch('http://localhost:3000/meta?token=6R0W53R135510').then(async (res) => {
23
+ expect(res.headers.get('content-type')).to.equal('application/json; charset=UTF-8');
24
+ expect(res.status).to.equal(200);
25
+ });
26
+ });
20
27
  it('allows requests to /metrics', async () => {
21
28
  await start();
22
29
  await fetch('http://localhost:3000/metrics?token=6R0W53R135510').then(async (res) => {
@@ -1,4 +1,4 @@
1
- import { BadRequest, HTTPRoutes, contentTypes, convertIfBase64, exists, getTokenFromRequest, id, makeExternalURL, mimeTypes, } from '@browserless.io/browserless';
1
+ import { BadRequest, HTTPRoutes, ServerError, contentTypes, convertIfBase64, exists, getTokenFromRequest, id, makeExternalURL, mimeTypes, } from '@browserless.io/browserless';
2
2
  import fs from 'fs';
3
3
  import path from 'path';
4
4
  export default (config, logger, options = {}) => async (req, browser) => {
@@ -17,7 +17,7 @@ export default (config, logger, options = {}) => async (req, browser) => {
17
17
  const code = convertIfBase64(rawCode);
18
18
  const browserWSEndpoint = browser.publicWSEndpoint(getTokenFromRequest(req) ?? '');
19
19
  if (!browserWSEndpoint) {
20
- throw new Error(`No browser endpoint was found, is the browser running?`);
20
+ throw new ServerError(`No browser endpoint was found, is the browser running?`);
21
21
  }
22
22
  const functionCodeJS = `browserless-function-${id()}.js`;
23
23
  const page = (await browser.newPage());
package/build/types.d.ts CHANGED
@@ -520,6 +520,7 @@ export declare const BrowserlessWebKitRoutes: {
520
520
  export declare const BrowserlessManagementRoutes: {
521
521
  ActiveGetRoute: string;
522
522
  ConfigGetRoute: string;
523
+ MetaGetRoute: string;
523
524
  MetricsGetRoute: string;
524
525
  MetricsTotalGetRoute: string;
525
526
  PressureGetRoute: string;
@@ -529,6 +530,7 @@ export declare const BrowserlessManagementRoutes: {
529
530
  export declare const BrowserlessRoutes: {
530
531
  ActiveGetRoute: string;
531
532
  ConfigGetRoute: string;
533
+ MetaGetRoute: string;
532
534
  MetricsGetRoute: string;
533
535
  MetricsTotalGetRoute: string;
534
536
  PressureGetRoute: string;
package/build/types.js CHANGED
@@ -190,6 +190,7 @@ export const BrowserlessWebKitRoutes = {
190
190
  export const BrowserlessManagementRoutes = {
191
191
  ActiveGetRoute: 'ActiveGetRoute',
192
192
  ConfigGetRoute: 'ConfigGetRoute',
193
+ MetaGetRoute: 'MetaGetRoute',
193
194
  MetricsGetRoute: 'MetricsGetRoute',
194
195
  MetricsTotalGetRoute: 'MetricsTotalGetRoute',
195
196
  PressureGetRoute: 'PressureGetRoute',