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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/CHANGELOG.md +17 -1
  2. package/bin/browserless.js +1 -1
  3. package/build/browsers/browsers.playwright.d.ts +1 -0
  4. package/build/browsers/browsers.playwright.js +3 -0
  5. package/build/browsers/index.d.ts +2 -1
  6. package/build/browsers/index.js +28 -7
  7. package/build/http.d.ts +5 -0
  8. package/build/http.js +1 -0
  9. package/build/routes/chrome/http/content.post.body.json +35 -10
  10. package/build/routes/chrome/http/content.post.query.json +4 -0
  11. package/build/routes/chrome/http/download.post.query.json +4 -0
  12. package/build/routes/chrome/http/function.post.query.json +4 -0
  13. package/build/routes/chrome/http/pdf.post.body.json +35 -10
  14. package/build/routes/chrome/http/pdf.post.query.json +4 -0
  15. package/build/routes/chrome/http/performance.post.query.json +4 -0
  16. package/build/routes/chrome/http/scrape.post.body.json +35 -10
  17. package/build/routes/chrome/http/scrape.post.query.json +4 -0
  18. package/build/routes/chrome/http/scrape.post.response.json +26 -1
  19. package/build/routes/chrome/http/screenshot.post.body.json +35 -10
  20. package/build/routes/chrome/http/screenshot.post.query.json +4 -0
  21. package/build/routes/chrome/tests/kill-sessions.spec.d.ts +1 -0
  22. package/build/routes/chrome/tests/kill-sessions.spec.js +80 -0
  23. package/build/routes/chrome/ws/browser.query.json +4 -0
  24. package/build/routes/chrome/ws/cdp.query.json +4 -0
  25. package/build/routes/chrome/ws/page.query.json +4 -0
  26. package/build/routes/chrome/ws/playwright.query.json +4 -0
  27. package/build/routes/chromium/http/content.post.body.json +35 -10
  28. package/build/routes/chromium/http/content.post.query.json +4 -0
  29. package/build/routes/chromium/http/download.post.query.json +4 -0
  30. package/build/routes/chromium/http/function.post.query.json +4 -0
  31. package/build/routes/chromium/http/pdf.post.body.json +35 -10
  32. package/build/routes/chromium/http/pdf.post.query.json +4 -0
  33. package/build/routes/chromium/http/performance.post.query.json +4 -0
  34. package/build/routes/chromium/http/scrape.post.body.json +35 -10
  35. package/build/routes/chromium/http/scrape.post.query.json +4 -0
  36. package/build/routes/chromium/http/scrape.post.response.json +26 -1
  37. package/build/routes/chromium/http/screenshot.post.body.json +35 -10
  38. package/build/routes/chromium/http/screenshot.post.query.json +4 -0
  39. package/build/routes/chromium/tests/kill-sessions.spec.d.ts +1 -0
  40. package/build/routes/chromium/tests/kill-sessions.spec.js +80 -0
  41. package/build/routes/chromium/tests/websocket.spec.js +23 -0
  42. package/build/routes/chromium/ws/browser.query.json +4 -0
  43. package/build/routes/chromium/ws/cdp.query.json +4 -0
  44. package/build/routes/chromium/ws/page.query.json +4 -0
  45. package/build/routes/chromium/ws/playwright.query.json +4 -0
  46. package/build/routes/firefox/tests/kill-sessions.spec.d.ts +1 -0
  47. package/build/routes/firefox/tests/kill-sessions.spec.js +72 -0
  48. package/build/routes/firefox/ws/playwright.query.json +4 -0
  49. package/build/routes/management/http/kill.get.d.ts +21 -0
  50. package/build/routes/management/http/kill.get.js +19 -0
  51. package/build/routes/management/http/kill.get.query.json +193 -0
  52. package/build/routes/management/http/meta.get.js +3 -2
  53. package/build/routes/management/http/sessions.get.query.json +1 -0
  54. package/build/routes/management/tests/management.spec.js +12 -0
  55. package/build/routes/webkit/tests/kill-sessions.spec.d.ts +1 -0
  56. package/build/routes/webkit/tests/kill-sessions.spec.js +72 -0
  57. package/build/routes/webkit/ws/playwright.query.json +4 -0
  58. package/build/types.d.ts +2 -0
  59. package/build/types.js +1 -0
  60. package/build/utils.d.ts +1 -1
  61. package/build/utils.js +1 -10
  62. package/package.json +5 -5
  63. package/src/browsers/browsers.playwright.ts +3 -0
  64. package/src/browsers/index.ts +33 -12
  65. package/src/http.ts +6 -0
  66. package/src/routes/chrome/tests/kill-sessions.spec.ts +99 -0
  67. package/src/routes/chromium/tests/kill-sessions.spec.ts +99 -0
  68. package/src/routes/chromium/tests/websocket.spec.ts +29 -0
  69. package/src/routes/firefox/tests/kill-sessions.spec.ts +99 -0
  70. package/src/routes/management/http/kill.get.ts +40 -0
  71. package/src/routes/management/http/meta.get.ts +12 -10
  72. package/src/routes/management/tests/management.spec.ts +19 -0
  73. package/src/routes/webkit/tests/kill-sessions.spec.ts +99 -0
  74. package/src/types.ts +1 -0
  75. package/src/utils.ts +2 -11
  76. package/static/docs/swagger.json +384 -15
  77. package/static/docs/swagger.min.json +383 -14
  78. package/static/function/client.js +954 -845
  79. package/static/function/index.html +954 -845
@@ -253,7 +253,7 @@
253
253
  ]
254
254
  },
255
255
  "CookieParam": {
256
- "description": "Cookie parameter object",
256
+ "description": "Cookie parameter object used to set cookies in the page-level cookies\nAPI.",
257
257
  "type": "object",
258
258
  "properties": {
259
259
  "name": {
@@ -321,7 +321,14 @@
321
321
  },
322
322
  "partitionKey": {
323
323
  "description": "Cookie partition key. In Chrome, it matches the top-level site the\npartitioned cookie is available in. In Firefox, it matches the\nsource origin\n(https://w3c.github.io/webdriver-bidi/#type-storage-PartitionKey).",
324
- "type": "string"
324
+ "anyOf": [
325
+ {
326
+ "$ref": "#/definitions/CookiePartitionKey"
327
+ },
328
+ {
329
+ "type": "string"
330
+ }
331
+ ]
325
332
  }
326
333
  },
327
334
  "additionalProperties": false,
@@ -330,6 +337,24 @@
330
337
  "value"
331
338
  ]
332
339
  },
340
+ "CookiePartitionKey": {
341
+ "description": "Represents a cookie partition key in Chrome.",
342
+ "type": "object",
343
+ "properties": {
344
+ "sourceOrigin": {
345
+ "description": "The site of the top-level URL the browser was visiting at the start of the request\nto the endpoint that set the cookie.\n\nIn Chrome, maps to the CDP's `topLevelSite` partition key.",
346
+ "type": "string"
347
+ },
348
+ "hasCrossSiteAncestor": {
349
+ "description": "Indicates if the cookie has any ancestors that are cross-site to\nthe topLevelSite.\n\nSupported only in Chrome.",
350
+ "type": "boolean"
351
+ }
352
+ },
353
+ "additionalProperties": false,
354
+ "required": [
355
+ "sourceOrigin"
356
+ ]
357
+ },
333
358
  "GoToOptions": {
334
359
  "type": "object",
335
360
  "properties": {
@@ -528,14 +553,14 @@
528
553
  "length": {
529
554
  "type": "number"
530
555
  },
531
- "__@toStringTag@304210": {
556
+ "__@toStringTag@304014": {
532
557
  "type": "string",
533
558
  "const": "Uint8Array"
534
559
  }
535
560
  },
536
561
  "required": [
537
562
  "BYTES_PER_ELEMENT",
538
- "__@toStringTag@304210",
563
+ "__@toStringTag@304014",
539
564
  "buffer",
540
565
  "byteLength",
541
566
  "byteOffset",
@@ -570,13 +595,13 @@
570
595
  "byteLength": {
571
596
  "type": "number"
572
597
  },
573
- "__@toStringTag@304210": {
598
+ "__@toStringTag@304014": {
574
599
  "type": "string"
575
600
  }
576
601
  },
577
602
  "additionalProperties": false,
578
603
  "required": [
579
- "__@toStringTag@304210",
604
+ "__@toStringTag@304014",
580
605
  "byteLength"
581
606
  ]
582
607
  },
@@ -586,18 +611,18 @@
586
611
  "byteLength": {
587
612
  "type": "number"
588
613
  },
589
- "__@species@304248": {
614
+ "__@species@304052": {
590
615
  "$ref": "#/definitions/SharedArrayBuffer"
591
616
  },
592
- "__@toStringTag@304210": {
617
+ "__@toStringTag@304014": {
593
618
  "type": "string",
594
619
  "const": "SharedArrayBuffer"
595
620
  }
596
621
  },
597
622
  "additionalProperties": false,
598
623
  "required": [
599
- "__@species@304248",
600
- "__@toStringTag@304210",
624
+ "__@species@304052",
625
+ "__@toStringTag@304014",
601
626
  "byteLength"
602
627
  ]
603
628
  },
@@ -23,6 +23,10 @@
23
23
  "token": {
24
24
  "description": "The authorization token",
25
25
  "type": "string"
26
+ },
27
+ "trackingId": {
28
+ "description": "Custom session identifier",
29
+ "type": "string"
26
30
  }
27
31
  },
28
32
  "additionalProperties": false,
@@ -0,0 +1,80 @@
1
+ import { Browserless, Config, Metrics } from '@browserless.io/browserless';
2
+ import { expect } from 'chai';
3
+ import puppeteer from 'puppeteer-core';
4
+ describe('/kill API', function () {
5
+ let browserless;
6
+ const start = ({ config = new Config(), metrics = new Metrics(), } = {}) => {
7
+ config.setToken('6R0W53R135510');
8
+ browserless = new Browserless({ config, metrics });
9
+ return browserless.start();
10
+ };
11
+ afterEach(async () => {
12
+ await browserless.stop();
13
+ });
14
+ it('Kill all sessions', async () => {
15
+ await start();
16
+ const browser1 = await puppeteer.connect({
17
+ browserWSEndpoint: `ws://localhost:3000/chromium?token=6R0W53R135510`,
18
+ });
19
+ const browser2 = await puppeteer.connect({
20
+ browserWSEndpoint: `ws://localhost:3000/chromium?token=6R0W53R135510`,
21
+ });
22
+ await fetch('http://localhost:3000/kill/all?token=6R0W53R135510').then(async (res) => {
23
+ expect(res.status).to.equal(204);
24
+ });
25
+ let errorThrown1;
26
+ try {
27
+ await browser1.newPage();
28
+ }
29
+ catch (e) {
30
+ errorThrown1 = e;
31
+ }
32
+ let errorThrown2;
33
+ try {
34
+ await browser2.newPage();
35
+ }
36
+ catch (e) {
37
+ errorThrown2 = e;
38
+ }
39
+ expect(errorThrown1.message).contains('closed');
40
+ expect(errorThrown2.message).contains('closed');
41
+ });
42
+ it('Kill session by browserId', async () => {
43
+ await start();
44
+ const browser = await puppeteer.connect({
45
+ browserWSEndpoint: `ws://localhost:3000/chromium?token=6R0W53R135510`,
46
+ });
47
+ await fetch('http://localhost:3000/sessions?token=6R0W53R135510').then(async (res) => {
48
+ const sessions = await res.json();
49
+ const browserId = sessions[0].browserId;
50
+ await fetch(`http://localhost:3000/kill/${browserId}?token=6R0W53R135510`).then(async (res) => {
51
+ expect(res.status).to.equal(204);
52
+ });
53
+ });
54
+ let errorThrown;
55
+ try {
56
+ await browser.newPage();
57
+ }
58
+ catch (e) {
59
+ errorThrown = e;
60
+ }
61
+ expect(errorThrown.message).contains('closed');
62
+ });
63
+ it('Kill session by trackingId', async () => {
64
+ await start();
65
+ const browser = await puppeteer.connect({
66
+ browserWSEndpoint: `ws://localhost:3000/chromium?token=6R0W53R135510&trackingId=session-1`,
67
+ });
68
+ await fetch('http://localhost:3000/kill/session-1?token=6R0W53R135510').then(async (res) => {
69
+ expect(res.status).to.equal(204);
70
+ });
71
+ let errorThrown;
72
+ try {
73
+ await browser.newPage();
74
+ }
75
+ catch (e) {
76
+ errorThrown = e;
77
+ }
78
+ expect(errorThrown.message).contains('closed');
79
+ });
80
+ });
@@ -386,4 +386,27 @@ describe('Chromium WebSocket API', function () {
386
386
  });
387
387
  await browser.disconnect();
388
388
  });
389
+ it('Throws an error while creating a session with invalid trackingId', async () => {
390
+ await start();
391
+ const didError = await puppeteer
392
+ .connect({
393
+ browserWSEndpoint: `ws://localhost:3000/chromium?trackingId=all`,
394
+ })
395
+ .then(() => false)
396
+ .catch(() => true);
397
+ expect(didError).to.be.true;
398
+ });
399
+ it('Throws an error while creating a session with duplicated trackingId', async () => {
400
+ await start();
401
+ await puppeteer.connect({
402
+ browserWSEndpoint: `ws://localhost:3000/chromium?trackingId=duplicated`,
403
+ });
404
+ const didError = await puppeteer
405
+ .connect({
406
+ browserWSEndpoint: `ws://localhost:3000/chromium?trackingId=duplicated`,
407
+ })
408
+ .then(() => false)
409
+ .catch(() => true);
410
+ expect(didError).to.be.true;
411
+ });
389
412
  });
@@ -23,6 +23,10 @@
23
23
  "token": {
24
24
  "description": "The authorization token",
25
25
  "type": "string"
26
+ },
27
+ "trackingId": {
28
+ "description": "Custom session identifier",
29
+ "type": "string"
26
30
  }
27
31
  },
28
32
  "additionalProperties": false,
@@ -23,6 +23,10 @@
23
23
  "token": {
24
24
  "description": "The authorization token",
25
25
  "type": "string"
26
+ },
27
+ "trackingId": {
28
+ "description": "Custom session identifier",
29
+ "type": "string"
26
30
  }
27
31
  },
28
32
  "additionalProperties": false,
@@ -23,6 +23,10 @@
23
23
  "token": {
24
24
  "description": "The authorization token",
25
25
  "type": "string"
26
+ },
27
+ "trackingId": {
28
+ "description": "Custom session identifier",
29
+ "type": "string"
26
30
  }
27
31
  },
28
32
  "additionalProperties": false,
@@ -23,6 +23,10 @@
23
23
  "token": {
24
24
  "description": "The authorization token",
25
25
  "type": "string"
26
+ },
27
+ "trackingId": {
28
+ "description": "Custom session identifier",
29
+ "type": "string"
26
30
  }
27
31
  },
28
32
  "additionalProperties": false,
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,72 @@
1
+ import { Browserless, Config, Metrics } from '@browserless.io/browserless';
2
+ import { expect } from 'chai';
3
+ import { firefox } from 'playwright-core';
4
+ describe('/kill API firefox', function () {
5
+ let browserless;
6
+ const start = ({ config = new Config(), metrics = new Metrics(), } = {}) => {
7
+ config.setToken('browserless');
8
+ browserless = new Browserless({ config, metrics });
9
+ return browserless.start();
10
+ };
11
+ afterEach(async () => {
12
+ await browserless.stop();
13
+ });
14
+ it('Kill all sessions', async () => {
15
+ await start();
16
+ const browser1 = await firefox.connect(`ws://localhost:3000/playwright/firefox?token=browserless`);
17
+ const browser2 = await firefox.connect(`ws://localhost:3000/playwright/firefox?token=browserless`);
18
+ await fetch('http://localhost:3000/kill/all?token=browserless').then(async (res) => {
19
+ expect(res.status).to.equal(204);
20
+ });
21
+ let errorThrown1;
22
+ try {
23
+ await browser1.newPage();
24
+ }
25
+ catch (e) {
26
+ errorThrown1 = e;
27
+ }
28
+ let errorThrown2;
29
+ try {
30
+ await browser2.newPage();
31
+ }
32
+ catch (e) {
33
+ errorThrown2 = e;
34
+ }
35
+ expect(errorThrown1.message).contains('closed');
36
+ expect(errorThrown2.message).contains('closed');
37
+ });
38
+ it('Kill session by browserId', async () => {
39
+ await start();
40
+ const browser = await firefox.connect(`ws://localhost:3000/playwright/firefox?token=browserless`);
41
+ await fetch('http://localhost:3000/sessions?token=browserless').then(async (res) => {
42
+ const sessions = await res.json();
43
+ const browserId = sessions[0].browserId;
44
+ await fetch(`http://localhost:3000/kill/${browserId}?token=browserless`).then(async (res) => {
45
+ expect(res.status).to.equal(204);
46
+ });
47
+ });
48
+ let errorThrown;
49
+ try {
50
+ await browser.newPage();
51
+ }
52
+ catch (e) {
53
+ errorThrown = e;
54
+ }
55
+ expect(errorThrown.message).contains('closed');
56
+ });
57
+ it('Kill session by trackingId', async () => {
58
+ await start();
59
+ const browser = await firefox.connect(`ws://localhost:3000/playwright/firefox?token=browserless&trackingId=session-1`);
60
+ await fetch('http://localhost:3000/kill/session-1?token=browserless').then(async (res) => {
61
+ expect(res.status).to.equal(204);
62
+ });
63
+ let errorThrown;
64
+ try {
65
+ await browser.newPage();
66
+ }
67
+ catch (e) {
68
+ errorThrown = e;
69
+ }
70
+ expect(errorThrown.message).contains('closed');
71
+ });
72
+ });
@@ -87,6 +87,10 @@
87
87
  "token": {
88
88
  "description": "The authorization token",
89
89
  "type": "string"
90
+ },
91
+ "trackingId": {
92
+ "description": "Custom session identifier",
93
+ "type": "string"
90
94
  }
91
95
  },
92
96
  "additionalProperties": false,
@@ -0,0 +1,21 @@
1
+ import { APITags, HTTPManagementRoutes, HTTPRoute, Methods, Request, SystemQueryParameters, contentTypes } from '@browserless.io/browserless';
2
+ import { ServerResponse } from 'http';
3
+ export type ResponseSchema = string;
4
+ export interface QuerySchema extends SystemQueryParameters {
5
+ token: string;
6
+ browserId?: string;
7
+ trackingId?: string;
8
+ }
9
+ export default class KillGetRoute extends HTTPRoute {
10
+ name: string;
11
+ accepts: contentTypes[];
12
+ auth: boolean;
13
+ browser: null;
14
+ concurrency: boolean;
15
+ contentTypes: contentTypes[];
16
+ description: string;
17
+ method: Methods;
18
+ path: HTTPManagementRoutes;
19
+ tags: APITags[];
20
+ handler(req: Request, res: ServerResponse): Promise<void>;
21
+ }
@@ -0,0 +1,19 @@
1
+ import { APITags, BrowserlessRoutes, HTTPManagementRoutes, HTTPRoute, Methods, contentTypes, writeResponse, } from '@browserless.io/browserless';
2
+ export default class KillGetRoute extends HTTPRoute {
3
+ name = BrowserlessRoutes.KillGetRoute;
4
+ accepts = [contentTypes.any];
5
+ auth = true;
6
+ browser = null;
7
+ concurrency = false;
8
+ contentTypes = [contentTypes.json];
9
+ description = `Kill running sessions based on BrowserId or TrackingId.`;
10
+ method = Methods.get;
11
+ path = HTTPManagementRoutes.kill;
12
+ tags = [APITags.management];
13
+ async handler(req, res) {
14
+ const target = req.parsed.pathname.split('/')[2];
15
+ const browserManager = this.browserManager();
16
+ await browserManager.killSessions(target);
17
+ return writeResponse(res, 204, '');
18
+ }
19
+ }
@@ -0,0 +1,193 @@
1
+ {
2
+ "type": "object",
3
+ "properties": {
4
+ "token": {
5
+ "description": "The authorization token",
6
+ "type": "string"
7
+ },
8
+ "browserId": {
9
+ "type": "string"
10
+ },
11
+ "trackingId": {
12
+ "description": "Custom session identifier",
13
+ "type": "string"
14
+ },
15
+ "blockAds": {
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
+ "type": "boolean"
18
+ },
19
+ "launch": {
20
+ "description": "Launch options, which can be either an object\nof puppeteer.launch options or playwright.launchServer\noptions, depending on the API. Must be either JSON\nobject, or a base64-encoded JSON object.",
21
+ "anyOf": [
22
+ {
23
+ "$ref": "#/definitions/CDPLaunchOptions"
24
+ },
25
+ {
26
+ "$ref": "#/definitions/BrowserServerOptions"
27
+ },
28
+ {
29
+ "type": "string"
30
+ }
31
+ ]
32
+ },
33
+ "timeout": {
34
+ "description": "Override the system-level timeout for this request.\nAccepts a value in milliseconds.",
35
+ "type": "number"
36
+ }
37
+ },
38
+ "additionalProperties": false,
39
+ "required": [
40
+ "token"
41
+ ],
42
+ "definitions": {
43
+ "CDPLaunchOptions": {
44
+ "type": "object",
45
+ "properties": {
46
+ "args": {
47
+ "type": "array",
48
+ "items": {
49
+ "type": "string"
50
+ }
51
+ },
52
+ "defaultViewport": {
53
+ "type": "object",
54
+ "properties": {
55
+ "deviceScaleFactor": {
56
+ "type": "number"
57
+ },
58
+ "hasTouch": {
59
+ "type": "boolean"
60
+ },
61
+ "height": {
62
+ "type": "number"
63
+ },
64
+ "isLandscape": {
65
+ "type": "boolean"
66
+ },
67
+ "isMobile": {
68
+ "type": "boolean"
69
+ },
70
+ "width": {
71
+ "type": "number"
72
+ }
73
+ },
74
+ "additionalProperties": false,
75
+ "required": [
76
+ "height",
77
+ "width"
78
+ ]
79
+ },
80
+ "devtools": {
81
+ "type": "boolean"
82
+ },
83
+ "dumpio": {
84
+ "type": "boolean"
85
+ },
86
+ "headless": {
87
+ "enum": [
88
+ false,
89
+ "shell",
90
+ true
91
+ ]
92
+ },
93
+ "ignoreDefaultArgs": {
94
+ "anyOf": [
95
+ {
96
+ "type": "array",
97
+ "items": {
98
+ "type": "string"
99
+ }
100
+ },
101
+ {
102
+ "type": "boolean"
103
+ }
104
+ ]
105
+ },
106
+ "ignoreHTTPSErrors": {
107
+ "type": "boolean"
108
+ },
109
+ "slowMo": {
110
+ "type": "number"
111
+ },
112
+ "stealth": {
113
+ "type": "boolean"
114
+ },
115
+ "timeout": {
116
+ "type": "number"
117
+ },
118
+ "userDataDir": {
119
+ "type": "string"
120
+ },
121
+ "waitForInitialPage": {
122
+ "type": "boolean"
123
+ }
124
+ },
125
+ "additionalProperties": false
126
+ },
127
+ "BrowserServerOptions": {
128
+ "type": "object",
129
+ "properties": {
130
+ "args": {
131
+ "type": "array",
132
+ "items": {
133
+ "type": "string"
134
+ }
135
+ },
136
+ "chromiumSandbox": {
137
+ "type": "boolean"
138
+ },
139
+ "devtools": {
140
+ "type": "boolean"
141
+ },
142
+ "downloadsPath": {
143
+ "type": "string"
144
+ },
145
+ "headless": {
146
+ "type": "boolean"
147
+ },
148
+ "ignoreDefaultArgs": {
149
+ "anyOf": [
150
+ {
151
+ "type": "array",
152
+ "items": {
153
+ "type": "string"
154
+ }
155
+ },
156
+ {
157
+ "type": "boolean"
158
+ }
159
+ ]
160
+ },
161
+ "proxy": {
162
+ "type": "object",
163
+ "properties": {
164
+ "bypass": {
165
+ "type": "string"
166
+ },
167
+ "password": {
168
+ "type": "string"
169
+ },
170
+ "server": {
171
+ "type": "string"
172
+ },
173
+ "username": {
174
+ "type": "string"
175
+ }
176
+ },
177
+ "additionalProperties": false,
178
+ "required": [
179
+ "server"
180
+ ]
181
+ },
182
+ "timeout": {
183
+ "type": "number"
184
+ },
185
+ "tracesDir": {
186
+ "type": "string"
187
+ }
188
+ },
189
+ "additionalProperties": false
190
+ }
191
+ },
192
+ "$schema": "http://json-schema.org/draft-07/schema#"
193
+ }
@@ -1,9 +1,10 @@
1
1
  import { APITags, BrowserlessRoutes, ChromiumCDP, FirefoxPlaywright, HTTPManagementRoutes, HTTPRoute, Methods, WebKitPlaywright, availableBrowsers, contentTypes, jsonResponse, } from '@browserless.io/browserless';
2
2
  import { createRequire } from 'module';
3
+ import path from 'path';
3
4
  const semverReg = /(\*|\^|>|=|<|~)/gi;
4
5
  const require = createRequire(import.meta.url);
5
- const blessPackageJSON = require('../../../../package.json');
6
- const { browsers } = require('../../../../node_modules/playwright-core/browsers.json');
6
+ const blessPackageJSON = require(path.join(process.cwd(), 'package.json'));
7
+ const { browsers } = require(path.join(process.cwd(), 'node_modules', 'playwright-core', 'browsers.json'));
7
8
  const chromium = browsers.find((b) => b.name === 'chromium').browserVersion;
8
9
  const firefox = browsers.find((b) => b.name === 'firefox').browserVersion;
9
10
  const webkit = browsers.find((b) => b.name === 'webkit').browserVersion;
@@ -6,6 +6,7 @@
6
6
  "type": "string"
7
7
  },
8
8
  "trackingId": {
9
+ "description": "Custom session identifier",
9
10
  "type": "string"
10
11
  },
11
12
  "blockAds": {
@@ -68,4 +68,16 @@ describe('Management APIs', function () {
68
68
  expect(res.status).to.equal(204);
69
69
  });
70
70
  });
71
+ it('allows requests to /kill', async () => {
72
+ await start();
73
+ await fetch('http://localhost:3000/kill/all?token=6R0W53R135510').then(async (res) => {
74
+ expect(res.status).to.equal(204);
75
+ });
76
+ });
77
+ it('Throws an error trying to kill invalid session', async () => {
78
+ await start();
79
+ await fetch(`http://localhost:3000/kill/invalid-session?token=6R0W53R135510`).then(async (res) => {
80
+ expect(res.status).to.equal(404);
81
+ });
82
+ });
71
83
  });
@@ -0,0 +1 @@
1
+ export {};