@browserless.io/browserless 2.3.0 → 2.4.0-beta-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 +6 -0
- package/bin/browserless.js +2 -0
- package/bin/scaffold/README.md +26 -1
- package/build/browserless.d.ts +6 -2
- package/build/browserless.js +23 -4
- package/build/browsers/chromium.cdp.d.ts +1 -5
- package/build/browsers/chromium.cdp.js +5 -115
- package/build/browsers/chromium.playwright.d.ts +1 -3
- package/build/browsers/chromium.playwright.js +1 -6
- package/build/browsers/firefox.playwright.d.ts +1 -3
- package/build/browsers/firefox.playwright.js +1 -6
- package/build/browsers/index.d.ts +5 -1
- package/build/browsers/index.js +6 -5
- package/build/browsers/webkit.playwright.d.ts +1 -3
- package/build/browsers/webkit.playwright.js +1 -6
- package/build/config.d.ts +9 -0
- package/build/config.js +11 -0
- package/build/constants.d.ts +0 -1
- package/build/constants.js +0 -1
- package/build/data/selectors.json +1 -1
- package/build/file-system.d.ts +12 -1
- package/build/file-system.js +14 -1
- package/build/http.d.ts +0 -7
- package/build/limiter.d.ts +9 -0
- package/build/limiter.js +11 -0
- package/build/metrics.d.ts +12 -1
- package/build/metrics.js +13 -1
- package/build/monitoring.d.ts +12 -1
- package/build/monitoring.js +14 -1
- package/build/router.d.ts +12 -2
- package/build/router.js +16 -6
- package/build/routes/chrome/http/content.post.body.json +8 -8
- package/build/routes/chrome/http/content.post.query.json +0 -4
- package/build/routes/chrome/http/download.post.query.json +0 -4
- package/build/routes/chrome/http/function.post.query.json +0 -4
- package/build/routes/chrome/http/pdf.post.body.json +8 -8
- package/build/routes/chrome/http/pdf.post.query.json +0 -4
- package/build/routes/chrome/http/performance.post.query.json +0 -4
- package/build/routes/chrome/http/scrape.post.body.json +8 -8
- package/build/routes/chrome/http/scrape.post.query.json +0 -4
- package/build/routes/chrome/http/screenshot.post.body.json +8 -8
- package/build/routes/chrome/http/screenshot.post.query.json +0 -4
- package/build/routes/chrome/tests/function.spec.js +32 -0
- package/build/routes/chrome/ws/browser.query.json +0 -4
- package/build/routes/chrome/ws/cdp.query.json +0 -4
- package/build/routes/chrome/ws/page.query.json +0 -4
- package/build/routes/chrome/ws/playwright.query.json +0 -4
- package/build/routes/chromium/http/content.post.body.json +8 -8
- package/build/routes/chromium/http/content.post.query.json +0 -4
- package/build/routes/chromium/http/download.post.query.json +0 -4
- package/build/routes/chromium/http/function.post.query.json +0 -4
- package/build/routes/chromium/http/pdf.post.body.json +8 -8
- package/build/routes/chromium/http/pdf.post.query.json +0 -4
- package/build/routes/chromium/http/performance.post.query.json +0 -4
- package/build/routes/chromium/http/scrape.post.body.json +8 -8
- package/build/routes/chromium/http/scrape.post.query.json +0 -4
- package/build/routes/chromium/http/screenshot.post.body.json +8 -8
- package/build/routes/chromium/http/screenshot.post.query.json +0 -4
- package/build/routes/chromium/ws/browser.query.json +0 -4
- package/build/routes/chromium/ws/cdp.query.json +0 -4
- package/build/routes/chromium/ws/page.query.json +0 -4
- package/build/routes/chromium/ws/playwright.query.json +0 -4
- package/build/routes/firefox/ws/playwright.query.json +0 -4
- package/build/routes/management/http/static.get.js +17 -11
- package/build/routes/webkit/ws/playwright.query.json +0 -4
- package/build/server.d.ts +8 -3
- package/build/server.js +15 -13
- package/build/token.d.ts +12 -1
- package/build/token.js +14 -1
- package/build/types.d.ts +9 -12
- package/build/types.js +10 -1
- package/build/webhooks.d.ts +12 -1
- package/build/webhooks.js +14 -1
- package/extensions/.gitkeep +0 -0
- package/package.json +5 -5
- package/src/browserless.ts +24 -2
- package/src/browsers/chromium.cdp.ts +10 -157
- package/src/browsers/chromium.playwright.ts +0 -8
- package/src/browsers/firefox.playwright.ts +0 -8
- package/src/browsers/index.ts +7 -6
- package/src/browsers/webkit.playwright.ts +0 -8
- package/src/config.ts +13 -0
- package/src/constants.ts +0 -1
- package/src/file-system.ts +16 -1
- package/src/http.ts +0 -8
- package/src/limiter.ts +13 -0
- package/src/metrics.ts +16 -1
- package/src/monitoring.ts +18 -2
- package/src/router.ts +20 -9
- package/src/routes/chrome/tests/function.spec.ts +35 -0
- package/src/routes/management/http/static.get.ts +25 -15
- package/src/server.ts +18 -16
- package/src/token.ts +18 -2
- package/src/types.ts +9 -13
- package/src/webhooks.ts +18 -2
- package/static/docs/swagger.json +10 -186
- package/static/docs/swagger.min.json +9 -185
- package/extensions/screencast/background.js +0 -143
- package/extensions/screencast/content_script.js +0 -18
- package/extensions/screencast/manifest.json +0 -19
|
@@ -16,10 +16,6 @@
|
|
|
16
16
|
"description": "Whether or nor to load ad-blocking extensions for the session.\nThis currently uses uBlock Origin and may cause certain sites\nto not load properly.",
|
|
17
17
|
"type": "boolean"
|
|
18
18
|
},
|
|
19
|
-
"record": {
|
|
20
|
-
"description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
|
|
21
|
-
"type": "boolean"
|
|
22
|
-
},
|
|
23
19
|
"timeout": {
|
|
24
20
|
"description": "Override the system-level timeout for this request.\nAccepts a value in milliseconds.",
|
|
25
21
|
"type": "number"
|
|
@@ -16,10 +16,6 @@
|
|
|
16
16
|
"description": "Whether or nor to load ad-blocking extensions for the session.\nThis currently uses uBlock Origin and may cause certain sites\nto not load properly.",
|
|
17
17
|
"type": "boolean"
|
|
18
18
|
},
|
|
19
|
-
"record": {
|
|
20
|
-
"description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
|
|
21
|
-
"type": "boolean"
|
|
22
|
-
},
|
|
23
19
|
"timeout": {
|
|
24
20
|
"description": "Override the system-level timeout for this request.\nAccepts a value in milliseconds.",
|
|
25
21
|
"type": "number"
|
|
@@ -394,14 +394,14 @@
|
|
|
394
394
|
"length": {
|
|
395
395
|
"type": "number"
|
|
396
396
|
},
|
|
397
|
-
"__@toStringTag@
|
|
397
|
+
"__@toStringTag@141676": {
|
|
398
398
|
"type": "string",
|
|
399
399
|
"const": "Uint8Array"
|
|
400
400
|
}
|
|
401
401
|
},
|
|
402
402
|
"required": [
|
|
403
403
|
"BYTES_PER_ELEMENT",
|
|
404
|
-
"__@toStringTag@
|
|
404
|
+
"__@toStringTag@141676",
|
|
405
405
|
"buffer",
|
|
406
406
|
"byteLength",
|
|
407
407
|
"byteOffset",
|
|
@@ -436,13 +436,13 @@
|
|
|
436
436
|
"byteLength": {
|
|
437
437
|
"type": "number"
|
|
438
438
|
},
|
|
439
|
-
"__@toStringTag@
|
|
439
|
+
"__@toStringTag@141676": {
|
|
440
440
|
"type": "string"
|
|
441
441
|
}
|
|
442
442
|
},
|
|
443
443
|
"additionalProperties": false,
|
|
444
444
|
"required": [
|
|
445
|
-
"__@toStringTag@
|
|
445
|
+
"__@toStringTag@141676",
|
|
446
446
|
"byteLength"
|
|
447
447
|
]
|
|
448
448
|
},
|
|
@@ -452,18 +452,18 @@
|
|
|
452
452
|
"byteLength": {
|
|
453
453
|
"type": "number"
|
|
454
454
|
},
|
|
455
|
-
"__@species@
|
|
455
|
+
"__@species@141777": {
|
|
456
456
|
"$ref": "#/definitions/SharedArrayBuffer"
|
|
457
457
|
},
|
|
458
|
-
"__@toStringTag@
|
|
458
|
+
"__@toStringTag@141676": {
|
|
459
459
|
"type": "string",
|
|
460
460
|
"const": "SharedArrayBuffer"
|
|
461
461
|
}
|
|
462
462
|
},
|
|
463
463
|
"additionalProperties": false,
|
|
464
464
|
"required": [
|
|
465
|
-
"__@species@
|
|
466
|
-
"__@toStringTag@
|
|
465
|
+
"__@species@141777",
|
|
466
|
+
"__@toStringTag@141676",
|
|
467
467
|
"byteLength"
|
|
468
468
|
]
|
|
469
469
|
},
|
|
@@ -16,10 +16,6 @@
|
|
|
16
16
|
}
|
|
17
17
|
]
|
|
18
18
|
},
|
|
19
|
-
"record": {
|
|
20
|
-
"description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
|
|
21
|
-
"type": "boolean"
|
|
22
|
-
},
|
|
23
19
|
"timeout": {
|
|
24
20
|
"description": "Override the system-level timeout for this request.\nAccepts a value in milliseconds.",
|
|
25
21
|
"type": "number"
|
|
@@ -16,10 +16,6 @@
|
|
|
16
16
|
"description": "Whether or nor to load ad-blocking extensions for the session.\nThis currently uses uBlock Origin and may cause certain sites\nto not load properly.",
|
|
17
17
|
"type": "boolean"
|
|
18
18
|
},
|
|
19
|
-
"record": {
|
|
20
|
-
"description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
|
|
21
|
-
"type": "boolean"
|
|
22
|
-
},
|
|
23
19
|
"timeout": {
|
|
24
20
|
"description": "Override the system-level timeout for this request.\nAccepts a value in milliseconds.",
|
|
25
21
|
"type": "number"
|
|
@@ -16,10 +16,6 @@
|
|
|
16
16
|
"description": "Whether or nor to load ad-blocking extensions for the session.\nThis currently uses uBlock Origin and may cause certain sites\nto not load properly.",
|
|
17
17
|
"type": "boolean"
|
|
18
18
|
},
|
|
19
|
-
"record": {
|
|
20
|
-
"description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
|
|
21
|
-
"type": "boolean"
|
|
22
|
-
},
|
|
23
19
|
"timeout": {
|
|
24
20
|
"description": "Override the system-level timeout for this request.\nAccepts a value in milliseconds.",
|
|
25
21
|
"type": "number"
|
|
@@ -538,14 +538,14 @@
|
|
|
538
538
|
"length": {
|
|
539
539
|
"type": "number"
|
|
540
540
|
},
|
|
541
|
-
"__@toStringTag@
|
|
541
|
+
"__@toStringTag@206722": {
|
|
542
542
|
"type": "string",
|
|
543
543
|
"const": "Uint8Array"
|
|
544
544
|
}
|
|
545
545
|
},
|
|
546
546
|
"required": [
|
|
547
547
|
"BYTES_PER_ELEMENT",
|
|
548
|
-
"__@toStringTag@
|
|
548
|
+
"__@toStringTag@206722",
|
|
549
549
|
"buffer",
|
|
550
550
|
"byteLength",
|
|
551
551
|
"byteOffset",
|
|
@@ -580,13 +580,13 @@
|
|
|
580
580
|
"byteLength": {
|
|
581
581
|
"type": "number"
|
|
582
582
|
},
|
|
583
|
-
"__@toStringTag@
|
|
583
|
+
"__@toStringTag@206722": {
|
|
584
584
|
"type": "string"
|
|
585
585
|
}
|
|
586
586
|
},
|
|
587
587
|
"additionalProperties": false,
|
|
588
588
|
"required": [
|
|
589
|
-
"__@toStringTag@
|
|
589
|
+
"__@toStringTag@206722",
|
|
590
590
|
"byteLength"
|
|
591
591
|
]
|
|
592
592
|
},
|
|
@@ -596,18 +596,18 @@
|
|
|
596
596
|
"byteLength": {
|
|
597
597
|
"type": "number"
|
|
598
598
|
},
|
|
599
|
-
"__@species@
|
|
599
|
+
"__@species@206823": {
|
|
600
600
|
"$ref": "#/definitions/SharedArrayBuffer"
|
|
601
601
|
},
|
|
602
|
-
"__@toStringTag@
|
|
602
|
+
"__@toStringTag@206722": {
|
|
603
603
|
"type": "string",
|
|
604
604
|
"const": "SharedArrayBuffer"
|
|
605
605
|
}
|
|
606
606
|
},
|
|
607
607
|
"additionalProperties": false,
|
|
608
608
|
"required": [
|
|
609
|
-
"__@species@
|
|
610
|
-
"__@toStringTag@
|
|
609
|
+
"__@species@206823",
|
|
610
|
+
"__@toStringTag@206722",
|
|
611
611
|
"byteLength"
|
|
612
612
|
]
|
|
613
613
|
},
|
|
@@ -16,10 +16,6 @@
|
|
|
16
16
|
"description": "Whether or nor to load ad-blocking extensions for the session.\nThis currently uses uBlock Origin and may cause certain sites\nto not load properly.",
|
|
17
17
|
"type": "boolean"
|
|
18
18
|
},
|
|
19
|
-
"record": {
|
|
20
|
-
"description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
|
|
21
|
-
"type": "boolean"
|
|
22
|
-
},
|
|
23
19
|
"timeout": {
|
|
24
20
|
"description": "Override the system-level timeout for this request.\nAccepts a value in milliseconds.",
|
|
25
21
|
"type": "number"
|
|
@@ -16,10 +16,6 @@
|
|
|
16
16
|
"description": "Whether or nor to load ad-blocking extensions for the session.\nThis currently uses uBlock Origin and may cause certain sites\nto not load properly.",
|
|
17
17
|
"type": "boolean"
|
|
18
18
|
},
|
|
19
|
-
"record": {
|
|
20
|
-
"description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
|
|
21
|
-
"type": "boolean"
|
|
22
|
-
},
|
|
23
19
|
"timeout": {
|
|
24
20
|
"description": "Override the system-level timeout for this request.\nAccepts a value in milliseconds.",
|
|
25
21
|
"type": "number"
|
|
@@ -441,14 +441,14 @@
|
|
|
441
441
|
"length": {
|
|
442
442
|
"type": "number"
|
|
443
443
|
},
|
|
444
|
-
"__@toStringTag@
|
|
444
|
+
"__@toStringTag@217791": {
|
|
445
445
|
"type": "string",
|
|
446
446
|
"const": "Uint8Array"
|
|
447
447
|
}
|
|
448
448
|
},
|
|
449
449
|
"required": [
|
|
450
450
|
"BYTES_PER_ELEMENT",
|
|
451
|
-
"__@toStringTag@
|
|
451
|
+
"__@toStringTag@217791",
|
|
452
452
|
"buffer",
|
|
453
453
|
"byteLength",
|
|
454
454
|
"byteOffset",
|
|
@@ -483,13 +483,13 @@
|
|
|
483
483
|
"byteLength": {
|
|
484
484
|
"type": "number"
|
|
485
485
|
},
|
|
486
|
-
"__@toStringTag@
|
|
486
|
+
"__@toStringTag@217791": {
|
|
487
487
|
"type": "string"
|
|
488
488
|
}
|
|
489
489
|
},
|
|
490
490
|
"additionalProperties": false,
|
|
491
491
|
"required": [
|
|
492
|
-
"__@toStringTag@
|
|
492
|
+
"__@toStringTag@217791",
|
|
493
493
|
"byteLength"
|
|
494
494
|
]
|
|
495
495
|
},
|
|
@@ -499,18 +499,18 @@
|
|
|
499
499
|
"byteLength": {
|
|
500
500
|
"type": "number"
|
|
501
501
|
},
|
|
502
|
-
"__@species@
|
|
502
|
+
"__@species@217892": {
|
|
503
503
|
"$ref": "#/definitions/SharedArrayBuffer"
|
|
504
504
|
},
|
|
505
|
-
"__@toStringTag@
|
|
505
|
+
"__@toStringTag@217791": {
|
|
506
506
|
"type": "string",
|
|
507
507
|
"const": "SharedArrayBuffer"
|
|
508
508
|
}
|
|
509
509
|
},
|
|
510
510
|
"additionalProperties": false,
|
|
511
511
|
"required": [
|
|
512
|
-
"__@species@
|
|
513
|
-
"__@toStringTag@
|
|
512
|
+
"__@species@217892",
|
|
513
|
+
"__@toStringTag@217791",
|
|
514
514
|
"byteLength"
|
|
515
515
|
]
|
|
516
516
|
},
|
|
@@ -16,10 +16,6 @@
|
|
|
16
16
|
}
|
|
17
17
|
]
|
|
18
18
|
},
|
|
19
|
-
"record": {
|
|
20
|
-
"description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
|
|
21
|
-
"type": "boolean"
|
|
22
|
-
},
|
|
23
19
|
"timeout": {
|
|
24
20
|
"description": "Override the system-level timeout for this request.\nAccepts a value in milliseconds.",
|
|
25
21
|
"type": "number"
|
|
@@ -484,14 +484,14 @@
|
|
|
484
484
|
"length": {
|
|
485
485
|
"type": "number"
|
|
486
486
|
},
|
|
487
|
-
"__@toStringTag@
|
|
487
|
+
"__@toStringTag@239740": {
|
|
488
488
|
"type": "string",
|
|
489
489
|
"const": "Uint8Array"
|
|
490
490
|
}
|
|
491
491
|
},
|
|
492
492
|
"required": [
|
|
493
493
|
"BYTES_PER_ELEMENT",
|
|
494
|
-
"__@toStringTag@
|
|
494
|
+
"__@toStringTag@239740",
|
|
495
495
|
"buffer",
|
|
496
496
|
"byteLength",
|
|
497
497
|
"byteOffset",
|
|
@@ -526,13 +526,13 @@
|
|
|
526
526
|
"byteLength": {
|
|
527
527
|
"type": "number"
|
|
528
528
|
},
|
|
529
|
-
"__@toStringTag@
|
|
529
|
+
"__@toStringTag@239740": {
|
|
530
530
|
"type": "string"
|
|
531
531
|
}
|
|
532
532
|
},
|
|
533
533
|
"additionalProperties": false,
|
|
534
534
|
"required": [
|
|
535
|
-
"__@toStringTag@
|
|
535
|
+
"__@toStringTag@239740",
|
|
536
536
|
"byteLength"
|
|
537
537
|
]
|
|
538
538
|
},
|
|
@@ -542,18 +542,18 @@
|
|
|
542
542
|
"byteLength": {
|
|
543
543
|
"type": "number"
|
|
544
544
|
},
|
|
545
|
-
"__@species@
|
|
545
|
+
"__@species@239841": {
|
|
546
546
|
"$ref": "#/definitions/SharedArrayBuffer"
|
|
547
547
|
},
|
|
548
|
-
"__@toStringTag@
|
|
548
|
+
"__@toStringTag@239740": {
|
|
549
549
|
"type": "string",
|
|
550
550
|
"const": "SharedArrayBuffer"
|
|
551
551
|
}
|
|
552
552
|
},
|
|
553
553
|
"additionalProperties": false,
|
|
554
554
|
"required": [
|
|
555
|
-
"__@species@
|
|
556
|
-
"__@toStringTag@
|
|
555
|
+
"__@species@239841",
|
|
556
|
+
"__@toStringTag@239740",
|
|
557
557
|
"byteLength"
|
|
558
558
|
]
|
|
559
559
|
},
|
|
@@ -16,10 +16,6 @@
|
|
|
16
16
|
"description": "Whether or nor to load ad-blocking extensions for the session.\nThis currently uses uBlock Origin and may cause certain sites\nto not load properly.",
|
|
17
17
|
"type": "boolean"
|
|
18
18
|
},
|
|
19
|
-
"record": {
|
|
20
|
-
"description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
|
|
21
|
-
"type": "boolean"
|
|
22
|
-
},
|
|
23
19
|
"timeout": {
|
|
24
20
|
"description": "Override the system-level timeout for this request.\nAccepts a value in milliseconds.",
|
|
25
21
|
"type": "number"
|
|
@@ -16,10 +16,6 @@
|
|
|
16
16
|
"description": "Whether or nor to load ad-blocking extensions for the session.\nThis currently uses uBlock Origin and may cause certain sites\nto not load properly.",
|
|
17
17
|
"type": "boolean"
|
|
18
18
|
},
|
|
19
|
-
"record": {
|
|
20
|
-
"description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
|
|
21
|
-
"type": "boolean"
|
|
22
|
-
},
|
|
23
19
|
"timeout": {
|
|
24
20
|
"description": "Override the system-level timeout for this request.\nAccepts a value in milliseconds.",
|
|
25
21
|
"type": "number"
|
|
@@ -16,10 +16,6 @@
|
|
|
16
16
|
"description": "Whether or nor to load ad-blocking extensions for the session.\nThis currently uses uBlock Origin and may cause certain sites\nto not load properly.",
|
|
17
17
|
"type": "boolean"
|
|
18
18
|
},
|
|
19
|
-
"record": {
|
|
20
|
-
"description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
|
|
21
|
-
"type": "boolean"
|
|
22
|
-
},
|
|
23
19
|
"timeout": {
|
|
24
20
|
"description": "Override the system-level timeout for this request.\nAccepts a value in milliseconds.",
|
|
25
21
|
"type": "number"
|
|
@@ -16,10 +16,6 @@
|
|
|
16
16
|
"description": "Whether or nor to load ad-blocking extensions for the session.\nThis currently uses uBlock Origin and may cause certain sites\nto not load properly.",
|
|
17
17
|
"type": "boolean"
|
|
18
18
|
},
|
|
19
|
-
"record": {
|
|
20
|
-
"description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
|
|
21
|
-
"type": "boolean"
|
|
22
|
-
},
|
|
23
19
|
"timeout": {
|
|
24
20
|
"description": "Override the system-level timeout for this request.\nAccepts a value in milliseconds.",
|
|
25
21
|
"type": "number"
|
|
@@ -16,10 +16,6 @@
|
|
|
16
16
|
"description": "Whether or nor to load ad-blocking extensions for the session.\nThis currently uses uBlock Origin and may cause certain sites\nto not load properly.",
|
|
17
17
|
"type": "boolean"
|
|
18
18
|
},
|
|
19
|
-
"record": {
|
|
20
|
-
"description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
|
|
21
|
-
"type": "boolean"
|
|
22
|
-
},
|
|
23
19
|
"timeout": {
|
|
24
20
|
"description": "Override the system-level timeout for this request.\nAccepts a value in milliseconds.",
|
|
25
21
|
"type": "number"
|
|
@@ -80,10 +80,6 @@
|
|
|
80
80
|
"description": "Whether or nor to load ad-blocking extensions for the session.\nThis currently uses uBlock Origin and may cause certain sites\nto not load properly.",
|
|
81
81
|
"type": "boolean"
|
|
82
82
|
},
|
|
83
|
-
"record": {
|
|
84
|
-
"description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
|
|
85
|
-
"type": "boolean"
|
|
86
|
-
},
|
|
87
83
|
"timeout": {
|
|
88
84
|
"description": "Override the system-level timeout for this request.\nAccepts a value in milliseconds.",
|
|
89
85
|
"type": "number"
|
|
@@ -38,26 +38,32 @@ export default class StaticGetRoute extends HTTPRoute {
|
|
|
38
38
|
return streamFile(verbose, res, fileCache.path, fileCache.contentType);
|
|
39
39
|
}
|
|
40
40
|
const config = this.config();
|
|
41
|
+
const sdkDir = this.staticSDKDir();
|
|
41
42
|
const file = path.join(config.getStatic(), pathname);
|
|
42
43
|
const indexFile = path.join(file, 'index.html');
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
const locations = [file, indexFile];
|
|
45
|
+
if (sdkDir) {
|
|
46
|
+
const sdkPath = path.join(sdkDir, pathname);
|
|
47
|
+
locations.push(...[sdkPath, path.join(sdkPath, 'index.html')]);
|
|
48
|
+
}
|
|
49
|
+
const foundFilePaths = (await Promise.all(locations.map((l) => fileExists(l).then((e) => (e ? l : undefined))))).filter((_) => !!_);
|
|
50
|
+
if (!foundFilePaths.length) {
|
|
48
51
|
throw new NotFound(`No route or file found for resource ${req.method}: ${pathname}`);
|
|
49
52
|
}
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
if (foundFilePaths.length > 1) {
|
|
54
|
+
debug(`Multiple files found for request to "${pathname}". Only the first file is served, so please name your files uniquely.`);
|
|
55
|
+
}
|
|
56
|
+
const [foundFilePath] = foundFilePaths;
|
|
57
|
+
verbose(`Found new file "${foundFilePath}", caching path and serving`);
|
|
58
|
+
const contentType = mimeTypes.get(path.extname(foundFilePath));
|
|
52
59
|
if (contentType) {
|
|
53
60
|
res.setHeader('Content-Type', contentType);
|
|
54
61
|
}
|
|
55
|
-
// Cache the
|
|
56
|
-
// do stat checks again when requests come back
|
|
62
|
+
// Cache the file as being found so we don't have to call 'stat'
|
|
57
63
|
pathMap.set(pathname, {
|
|
58
64
|
contentType,
|
|
59
|
-
path:
|
|
65
|
+
path: foundFilePath,
|
|
60
66
|
});
|
|
61
|
-
return streamFile(verbose, res,
|
|
67
|
+
return streamFile(verbose, res, foundFilePath, contentType);
|
|
62
68
|
};
|
|
63
69
|
}
|
|
@@ -16,10 +16,6 @@
|
|
|
16
16
|
"description": "Whether or nor to load ad-blocking extensions for the session.\nThis currently uses uBlock Origin and may cause certain sites\nto not load properly.",
|
|
17
17
|
"type": "boolean"
|
|
18
18
|
},
|
|
19
|
-
"record": {
|
|
20
|
-
"description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
|
|
21
|
-
"type": "boolean"
|
|
22
|
-
},
|
|
23
19
|
"timeout": {
|
|
24
20
|
"description": "Override the system-level timeout for this request.\nAccepts a value in milliseconds.",
|
|
25
21
|
"type": "number"
|
package/build/server.d.ts
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
/// <reference types="debug" />
|
|
3
3
|
/// <reference types="node" />
|
|
4
4
|
/// <reference types="node" />
|
|
5
|
+
/// <reference types="node" />
|
|
5
6
|
import * as http from 'http';
|
|
6
7
|
import * as stream from 'stream';
|
|
7
8
|
import { Config, Metrics, Request, Response, Router, Token } from '@browserless.io/browserless';
|
|
9
|
+
import { EventEmitter } from 'events';
|
|
8
10
|
export interface HTTPServerOptions {
|
|
9
11
|
concurrent: number;
|
|
10
12
|
host: string;
|
|
@@ -12,7 +14,7 @@ export interface HTTPServerOptions {
|
|
|
12
14
|
queued: number;
|
|
13
15
|
timeout: number;
|
|
14
16
|
}
|
|
15
|
-
export declare class HTTPServer {
|
|
17
|
+
export declare class HTTPServer extends EventEmitter {
|
|
16
18
|
protected config: Config;
|
|
17
19
|
protected metrics: Metrics;
|
|
18
20
|
protected token: Token;
|
|
@@ -26,8 +28,11 @@ export declare class HTTPServer {
|
|
|
26
28
|
protected onHTTPUnauthorized: (_req: Request, res: Response) => void;
|
|
27
29
|
protected onWebsocketUnauthorized: (_req: Request, socket: stream.Duplex) => void;
|
|
28
30
|
start(): Promise<void>;
|
|
29
|
-
stop(): Promise<void>;
|
|
30
|
-
protected tearDown(): void;
|
|
31
31
|
protected handleRequest: (request: http.IncomingMessage, res: http.ServerResponse) => Promise<void | http.ServerResponse<http.IncomingMessage>>;
|
|
32
32
|
protected handleWebSocket: (request: http.IncomingMessage, socket: stream.Duplex, head: Buffer) => Promise<void>;
|
|
33
|
+
shutdown(): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Left blank for downstream SDK modules to optionally implement.
|
|
36
|
+
*/
|
|
37
|
+
stop: () => void;
|
|
33
38
|
}
|
package/build/server.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as http from 'http';
|
|
2
2
|
import { BadRequest, NotFound, Timeout, TooManyRequests, Unauthorized, beforeRequest, contentTypes, convertPathToURL, createLogger, queryParamsToObject, readBody, shimLegacyRequests, writeResponse, } from '@browserless.io/browserless';
|
|
3
|
+
import { EventEmitter } from 'events';
|
|
3
4
|
// @ts-ignore
|
|
4
5
|
import Enjoi from 'enjoi';
|
|
5
|
-
export class HTTPServer {
|
|
6
|
+
export class HTTPServer extends EventEmitter {
|
|
6
7
|
config;
|
|
7
8
|
metrics;
|
|
8
9
|
token;
|
|
@@ -13,6 +14,7 @@ export class HTTPServer {
|
|
|
13
14
|
log = createLogger('server');
|
|
14
15
|
verbose = createLogger('server:verbose');
|
|
15
16
|
constructor(config, metrics, token, router) {
|
|
17
|
+
super();
|
|
16
18
|
this.config = config;
|
|
17
19
|
this.metrics = metrics;
|
|
18
20
|
this.token = token;
|
|
@@ -49,18 +51,6 @@ export class HTTPServer {
|
|
|
49
51
|
});
|
|
50
52
|
});
|
|
51
53
|
}
|
|
52
|
-
async stop() {
|
|
53
|
-
this.log(`HTTP Server is shutting down`);
|
|
54
|
-
await new Promise((r) => this.server.close(r));
|
|
55
|
-
await Promise.all([this.tearDown(), this.router.teardown()]);
|
|
56
|
-
this.log(`HTTP Server shutdown complete`);
|
|
57
|
-
}
|
|
58
|
-
tearDown() {
|
|
59
|
-
this.log(`Tearing down all listeners and internal routes`);
|
|
60
|
-
this.server && this.server.removeAllListeners();
|
|
61
|
-
// @ts-ignore garbage collect this reference
|
|
62
|
-
this.server = null;
|
|
63
|
-
}
|
|
64
54
|
handleRequest = async (request, res) => {
|
|
65
55
|
this.verbose(`Handling inbound HTTP request on "${request.method}: ${request.url}"`);
|
|
66
56
|
const req = request;
|
|
@@ -241,4 +231,16 @@ export class HTTPServer {
|
|
|
241
231
|
this.log(`No matching WebSocket route handler for "${req.parsed.href}"`);
|
|
242
232
|
return writeResponse(socket, 404, 'Not Found');
|
|
243
233
|
};
|
|
234
|
+
async shutdown() {
|
|
235
|
+
this.log(`HTTP Server is shutting down`);
|
|
236
|
+
await new Promise((r) => this.server.close(r));
|
|
237
|
+
this.server && this.server.removeAllListeners();
|
|
238
|
+
// @ts-ignore garbage collect this reference
|
|
239
|
+
this.server = null;
|
|
240
|
+
this.log(`HTTP Server shutdown complete`);
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Left blank for downstream SDK modules to optionally implement.
|
|
244
|
+
*/
|
|
245
|
+
stop = () => { };
|
|
244
246
|
}
|
package/build/token.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { BrowserHTTPRoute, BrowserWebsocketRoute, Config, HTTPRoute, Request, WebSocketRoute } from '@browserless.io/browserless';
|
|
2
|
-
|
|
3
|
+
import { EventEmitter } from 'events';
|
|
4
|
+
export declare class Token extends EventEmitter {
|
|
3
5
|
protected config: Config;
|
|
4
6
|
constructor(config: Config);
|
|
5
7
|
isAuthorized: (req: Request, route: BrowserHTTPRoute | BrowserWebsocketRoute | HTTPRoute | WebSocketRoute) => Promise<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* Implement any browserless-core-specific shutdown logic here.
|
|
10
|
+
* Calls the empty-SDK stop method for downstream implementations.
|
|
11
|
+
*/
|
|
12
|
+
shutdown: () => Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Left blank for downstream SDK modules to optionally implement.
|
|
15
|
+
*/
|
|
16
|
+
stop: () => void;
|
|
6
17
|
}
|
package/build/token.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { getTokenFromRequest, } from '@browserless.io/browserless';
|
|
2
|
-
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
export class Token extends EventEmitter {
|
|
3
4
|
config;
|
|
4
5
|
constructor(config) {
|
|
6
|
+
super();
|
|
5
7
|
this.config = config;
|
|
6
8
|
}
|
|
7
9
|
isAuthorized = async (req, route) => {
|
|
@@ -18,4 +20,15 @@ export class Token {
|
|
|
18
20
|
}
|
|
19
21
|
return (Array.isArray(token) ? token : [token]).includes(requestToken);
|
|
20
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* Implement any browserless-core-specific shutdown logic here.
|
|
25
|
+
* Calls the empty-SDK stop method for downstream implementations.
|
|
26
|
+
*/
|
|
27
|
+
shutdown = async () => {
|
|
28
|
+
await this.stop();
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Left blank for downstream SDK modules to optionally implement.
|
|
32
|
+
*/
|
|
33
|
+
stop = () => { };
|
|
21
34
|
}
|
package/build/types.d.ts
CHANGED
|
@@ -55,7 +55,8 @@ declare abstract class Route {
|
|
|
55
55
|
protected _debug: Browserless['debug'];
|
|
56
56
|
protected _metrics: Browserless['metrics'];
|
|
57
57
|
protected _monitoring: Browserless['monitoring'];
|
|
58
|
-
|
|
58
|
+
protected _staticSDKDir: Browserless['staticSDKDir'];
|
|
59
|
+
constructor(_browserManager: Browserless['browserManager'], _config: Browserless['config'], _fileSystem: Browserless['fileSystem'], _debug: Browserless['debug'], _metrics: Browserless['metrics'], _monitoring: Browserless['monitoring'], _staticSDKDir: Browserless['staticSDKDir']);
|
|
59
60
|
/**
|
|
60
61
|
* A unique name to identify this route. Used in downstream
|
|
61
62
|
* SDKs to potentially remove or disable.
|
|
@@ -134,6 +135,13 @@ declare abstract class Route {
|
|
|
134
135
|
* @returns Monitor
|
|
135
136
|
*/
|
|
136
137
|
monitoring: () => import("@browserless.io/browserless").Monitoring;
|
|
138
|
+
/**
|
|
139
|
+
* When running in an SDK environment, this returns the fully-qualified
|
|
140
|
+
* directory of that static directory. When "null" then no SDK directory
|
|
141
|
+
* has been set.
|
|
142
|
+
* @returns {string | null} The full path location of the SDK's static directory
|
|
143
|
+
*/
|
|
144
|
+
staticSDKDir: () => string | null;
|
|
137
145
|
/**
|
|
138
146
|
* The HTTP path that this route handles, eg '/my-route' OR an
|
|
139
147
|
* array of paths that this route can handle.
|
|
@@ -354,17 +362,6 @@ export interface InBoundRequest {
|
|
|
354
362
|
url: string;
|
|
355
363
|
}
|
|
356
364
|
export declare const debugScreenshotOpts: ScreenshotOptions;
|
|
357
|
-
declare global {
|
|
358
|
-
interface Window {
|
|
359
|
-
browserless: BrowserlessEmbeddedAPI;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
export interface BrowserlessEmbeddedAPI {
|
|
363
|
-
getRecording: () => Promise<string>;
|
|
364
|
-
liveUrl: () => string;
|
|
365
|
-
saveRecording: () => Promise<boolean>;
|
|
366
|
-
startRecording: () => void;
|
|
367
|
-
}
|
|
368
365
|
/**
|
|
369
366
|
* When bestAttempt is set to true, browserless attempt to proceed
|
|
370
367
|
* when "awaited" events fail or timeout. This includes things like
|