browsermob-proxy-api-client 0.0.3 → 0.0.5
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/README.md +45 -2
- package/dist/index.d.ts +118 -3
- package/dist/index.js +233 -89
- package/dist/index.js.map +1 -1
- package/dist/typings/proxy.d.ts +221 -0
- package/dist/typings/proxy.js +2 -0
- package/dist/typings/proxy.js.map +1 -0
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -1,4 +1,47 @@
|
|
|
1
1
|
# BrowserMob Proxy API Client
|
|
2
|
-
Client library
|
|
2
|
+
Client library for [BrowserMob Proxy] API
|
|
3
3
|
|
|
4
|
-
[
|
|
4
|
+
Refer to [REST API] section of BrowserMob Proxy documentation for detailed information
|
|
5
|
+
|
|
6
|
+
[](https://www.npmjs.org/package/browsermob-proxy-api-client)
|
|
7
|
+
[](https://packagephobia.now.sh/result?p=browsermob-proxy-api-client)
|
|
8
|
+
[](https://bundlephobia.com/package/browsermob-proxy-api-client@latest)
|
|
9
|
+
[](https://npm-stat.com/charts.html?package=browsermob-proxy-api-client)
|
|
10
|
+
[](https://snyk.io/test/npm/browsermob-proxy-api-client)
|
|
11
|
+
|
|
12
|
+
## Installing
|
|
13
|
+
|
|
14
|
+
Using npm:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
$ npm install browsermob-proxy-api-client
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Using yarn:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
$ yarn add browsermob-proxy-api-client
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Example
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import BrowserMobProxyAPIClient from 'browsermob-proxy-api-client';
|
|
30
|
+
|
|
31
|
+
const proxy = new BrowserMobProxyAPIClient('localhost', '8080');
|
|
32
|
+
const port = await proxy.start();
|
|
33
|
+
if (port) {
|
|
34
|
+
try {
|
|
35
|
+
await proxy.startHar(port);
|
|
36
|
+
// exec `curl google.com --proxy localhost:${port}`
|
|
37
|
+
const har = await proxy.getHar(port);
|
|
38
|
+
} catch (e) {
|
|
39
|
+
console.error(e);
|
|
40
|
+
} finally {
|
|
41
|
+
await proxy.stop(port);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
[BrowserMob Proxy]: https://github.com/lightbody/browsermob-proxy
|
|
47
|
+
[REST API]: https://github.com/lightbody/browsermob-proxy#rest-api
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,126 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { RequestOptions } from 'http';
|
|
3
|
+
import { Har } from 'har-format';
|
|
4
|
+
import { BandwidthLimitsResponse, BlacklistItem, NewHarPageArgs, ProxyList, SetBandwidthLimitArgs, SetBlacklistArgs, SetRetryCountArgs, SetRewriteArgs, SetTimeoutsArgs, SetWhitelistArgs, StartHarArgs, StartProxyArgs, WaitArgs } from './typings/proxy';
|
|
5
|
+
declare enum Method {
|
|
6
|
+
GET = "GET",
|
|
7
|
+
POST = "POST",
|
|
8
|
+
PUT = "PUT",
|
|
9
|
+
DELETE = "DELETE"
|
|
10
|
+
}
|
|
11
|
+
export default class BrowserMobProxyAPIClient {
|
|
3
12
|
readonly host: string;
|
|
4
13
|
readonly port: number;
|
|
5
14
|
constructor(host?: string, port?: number);
|
|
6
|
-
|
|
15
|
+
protected httpRequest(options: RequestOptions, payload?: string): Promise<string>;
|
|
16
|
+
protected httpRequestWithArgs(path?: string, method?: Method, args?: Record<string, string | number | boolean>): Promise<string>;
|
|
7
17
|
/***
|
|
8
18
|
* Get a list of ports attached to ProxyServer instances managed by ProxyManager
|
|
9
19
|
*/
|
|
10
20
|
getProxyList(): Promise<ProxyList>;
|
|
21
|
+
/**
|
|
22
|
+
* Creates a new proxy to run requests off of
|
|
23
|
+
*/
|
|
24
|
+
start(args?: StartProxyArgs): Promise<number | null>;
|
|
25
|
+
/**
|
|
26
|
+
* Shuts down the proxy and closes the port.
|
|
27
|
+
*/
|
|
28
|
+
stop(port: number): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Creates a new HAR attached to the proxy
|
|
31
|
+
* returns the HAR content if there was a previous HAR
|
|
32
|
+
*/
|
|
33
|
+
startHar(port: number, args?: StartHarArgs): Promise<Har | undefined>;
|
|
34
|
+
/**
|
|
35
|
+
* Starts a new page on the existing HAR
|
|
36
|
+
*/
|
|
37
|
+
newHarPage(port: number, args?: NewHarPageArgs): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Returns the JSON/HAR content representing all the HTTP traffic passed through the proxy
|
|
40
|
+
* provided you have already created the HAR with this.startHar
|
|
41
|
+
*/
|
|
42
|
+
getHar(port: number): Promise<Har | undefined>;
|
|
43
|
+
/**
|
|
44
|
+
* Get whitelisted items
|
|
45
|
+
*/
|
|
46
|
+
getWhitelist(port: number): Promise<string[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Sets a list of URL patterns to whitelist
|
|
49
|
+
*/
|
|
50
|
+
setWhitelist(port: number, args: SetWhitelistArgs): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Clears all URL patterns from the whitelist
|
|
53
|
+
*/
|
|
54
|
+
clearWhitelist(port: number): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Get blacklisted items
|
|
57
|
+
*/
|
|
58
|
+
getBlacklist(port: number): Promise<BlacklistItem[]>;
|
|
59
|
+
/**
|
|
60
|
+
* Set a URL to blacklist
|
|
61
|
+
*/
|
|
62
|
+
setBlacklist(port: number, args: SetBlacklistArgs): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Clears all URL patterns from the blacklist
|
|
65
|
+
*/
|
|
66
|
+
clearBlacklist(port: number): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Limit the bandwidth through the proxy
|
|
69
|
+
*/
|
|
70
|
+
setBandwidthLimit(port: number, args?: SetBandwidthLimitArgs): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Displays the amount of data remaining to be uploaded/downloaded until the limit is reached
|
|
73
|
+
*/
|
|
74
|
+
getBandwidthLimit(port: number): Promise<BandwidthLimitsResponse>;
|
|
75
|
+
/**
|
|
76
|
+
* Set and override HTTP Request headers
|
|
77
|
+
* Key is a header name (such as "User-Agent") and value is a value of HTTP header (such as "BrowserMob-Agent")
|
|
78
|
+
*/
|
|
79
|
+
setRequestHeaders(port: number, headers: Record<string, string>): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Overrides normal DNS lookups and remaps the given hosts with the associated IP address
|
|
82
|
+
* Key is a host name (such as "example.com") and value is the IP address (such as "1.2.3.4")
|
|
83
|
+
*/
|
|
84
|
+
setHosts(port: number, hosts: Record<string, string>): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Set username and passwords to be sent for requests on a specific domain that are protected by Basic Authentication
|
|
87
|
+
*/
|
|
88
|
+
setBasicAuth(port: number, domain: string, username: string, password: string): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Wait till all request are being made
|
|
91
|
+
*/
|
|
92
|
+
wait(port: number, args: WaitArgs): Promise<unknown>;
|
|
93
|
+
/**
|
|
94
|
+
* Handles different proxy timeouts
|
|
95
|
+
*/
|
|
96
|
+
setTimeouts(port: number, timeouts: SetTimeoutsArgs): Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Redirecting URLs
|
|
99
|
+
*/
|
|
100
|
+
setRewrite(port: number, args: SetRewriteArgs): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Removes all URL redirection rules currently in effect
|
|
103
|
+
*/
|
|
104
|
+
clearRewrites(port: number): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Set retry count
|
|
107
|
+
*/
|
|
108
|
+
setRetryCount(port: number, args: SetRetryCountArgs): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Empties the DNS cache
|
|
111
|
+
*/
|
|
112
|
+
clearDNSCache(port: number): Promise<void>;
|
|
113
|
+
/**
|
|
114
|
+
* Set request interceptor
|
|
115
|
+
* example: await proxy.setRequestInterceptor(port, "request.headers().remove('User-Agent'); request.headers().add('User-Agent', 'My-Custom-User-Agent-String 1.0');");
|
|
116
|
+
* @see https://github.com/lightbody/browsermob-proxy#rest-api-interceptors-with-littleproxy
|
|
117
|
+
*/
|
|
118
|
+
setRequestInterceptor(port: number, interceptor: string): Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* Set response interceptor
|
|
121
|
+
* example: await proxy.setResponseInterceptor(port, "response.headers().remove('User-Agent'); response.headers().add('User-Agent', 'My-Custom-User-Agent-String 1.0');");
|
|
122
|
+
* @see https://github.com/lightbody/browsermob-proxy#rest-api-interceptors-with-littleproxy
|
|
123
|
+
*/
|
|
124
|
+
setResponseInterceptor(port: number, interceptor: string): Promise<void>;
|
|
11
125
|
}
|
|
126
|
+
export {};
|
package/dist/index.js
CHANGED
|
@@ -1,102 +1,246 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
|
-
exports.__esModule = true;
|
|
42
|
-
var http_1 = __importDefault(require("http"));
|
|
43
|
-
var BMPClient = /** @class */ (function () {
|
|
44
|
-
function BMPClient(host, port) {
|
|
45
|
-
if (host === void 0) { host = 'localhost'; }
|
|
46
|
-
if (port === void 0) { port = 8080; }
|
|
1
|
+
import http from 'http';
|
|
2
|
+
var Method;
|
|
3
|
+
(function (Method) {
|
|
4
|
+
Method["GET"] = "GET";
|
|
5
|
+
Method["POST"] = "POST";
|
|
6
|
+
Method["PUT"] = "PUT";
|
|
7
|
+
Method["DELETE"] = "DELETE";
|
|
8
|
+
})(Method || (Method = {}));
|
|
9
|
+
export default class BrowserMobProxyAPIClient {
|
|
10
|
+
constructor(host = 'localhost', port = 8080) {
|
|
47
11
|
this.host = host;
|
|
48
12
|
this.port = port;
|
|
49
13
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
var req = http_1["default"].request({
|
|
62
|
-
path: path,
|
|
63
|
-
method: method,
|
|
64
|
-
host: _this.host,
|
|
65
|
-
port: _this.port,
|
|
66
|
-
headers: headers
|
|
67
|
-
}, function (res) {
|
|
68
|
-
var data = [];
|
|
69
|
-
res.on('data', function (chunk) { return data.push(chunk); });
|
|
70
|
-
res.on('end', function () {
|
|
14
|
+
httpRequest(options, payload = '') {
|
|
15
|
+
return new Promise((resolve, reject) => {
|
|
16
|
+
const req = http.request({
|
|
17
|
+
host: this.host,
|
|
18
|
+
port: this.port,
|
|
19
|
+
...options,
|
|
20
|
+
}, res => {
|
|
21
|
+
const data = [];
|
|
22
|
+
res.on('data', chunk => data.push(chunk));
|
|
23
|
+
res.on('end', () => {
|
|
71
24
|
resolve(data.join());
|
|
72
25
|
});
|
|
73
26
|
});
|
|
74
|
-
req.on('error',
|
|
75
|
-
if (
|
|
76
|
-
|
|
77
|
-
Object.entries(args).forEach(function (arg) { return params_1.set(arg[0], String(arg[1])); });
|
|
78
|
-
req.write(params_1.toString());
|
|
27
|
+
req.on('error', error => reject(error));
|
|
28
|
+
if (payload) {
|
|
29
|
+
req.write(payload);
|
|
79
30
|
}
|
|
80
31
|
req.end();
|
|
81
32
|
});
|
|
82
|
-
}
|
|
33
|
+
}
|
|
34
|
+
httpRequestWithArgs(path = '/', method = Method.GET, args = {}) {
|
|
35
|
+
const headers = {};
|
|
36
|
+
const params = new URLSearchParams();
|
|
37
|
+
if ([Method.POST, Method.PUT].includes(method) && Object.entries(args).length) {
|
|
38
|
+
headers['Content-Type'] = 'application/x-www-form-urlencoded';
|
|
39
|
+
Object.entries(args).forEach(arg => params.set(arg[0], String(arg[1])));
|
|
40
|
+
}
|
|
41
|
+
return this.httpRequest({
|
|
42
|
+
path,
|
|
43
|
+
method,
|
|
44
|
+
headers,
|
|
45
|
+
}, params.toString());
|
|
46
|
+
}
|
|
83
47
|
/***
|
|
84
48
|
* Get a list of ports attached to ProxyServer instances managed by ProxyManager
|
|
85
49
|
*/
|
|
86
|
-
|
|
87
|
-
return
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
50
|
+
async getProxyList() {
|
|
51
|
+
return JSON.parse(await this.httpRequestWithArgs('/proxy', Method.GET));
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Creates a new proxy to run requests off of
|
|
55
|
+
*/
|
|
56
|
+
async start(args = {}) {
|
|
57
|
+
const res = await this.httpRequestWithArgs('/proxy', Method.POST, { ...args });
|
|
58
|
+
const { port } = JSON.parse(res);
|
|
59
|
+
return port || null;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Shuts down the proxy and closes the port.
|
|
63
|
+
*/
|
|
64
|
+
async stop(port) {
|
|
65
|
+
await this.httpRequestWithArgs(`/proxy/${port}`, Method.DELETE);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Creates a new HAR attached to the proxy
|
|
69
|
+
* returns the HAR content if there was a previous HAR
|
|
70
|
+
*/
|
|
71
|
+
async startHar(port, args = {}) {
|
|
72
|
+
const res = await this.httpRequestWithArgs(`/proxy/${port}/har`, Method.PUT, { ...args });
|
|
73
|
+
return res ? JSON.parse(res) : undefined;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Starts a new page on the existing HAR
|
|
77
|
+
*/
|
|
78
|
+
async newHarPage(port, args = {}) {
|
|
79
|
+
await this.httpRequestWithArgs(`/proxy/${port}/har/pageRef`, Method.PUT, { ...args });
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Returns the JSON/HAR content representing all the HTTP traffic passed through the proxy
|
|
83
|
+
* provided you have already created the HAR with this.startHar
|
|
84
|
+
*/
|
|
85
|
+
async getHar(port) {
|
|
86
|
+
const res = await this.httpRequestWithArgs(`/proxy/${port}/har`, Method.GET);
|
|
87
|
+
return res ? JSON.parse(res) : undefined;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Get whitelisted items
|
|
91
|
+
*/
|
|
92
|
+
async getWhitelist(port) {
|
|
93
|
+
return JSON.parse(await this.httpRequestWithArgs(`/proxy/${port}/whitelist`, Method.GET));
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Sets a list of URL patterns to whitelist
|
|
97
|
+
*/
|
|
98
|
+
async setWhitelist(port, args) {
|
|
99
|
+
await this.httpRequestWithArgs(`/proxy/${port}/whitelist`, Method.PUT, { ...args });
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Clears all URL patterns from the whitelist
|
|
103
|
+
*/
|
|
104
|
+
async clearWhitelist(port) {
|
|
105
|
+
await this.httpRequestWithArgs(`/proxy/${port}/whitelist`, Method.DELETE);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Get blacklisted items
|
|
109
|
+
*/
|
|
110
|
+
async getBlacklist(port) {
|
|
111
|
+
return JSON.parse(await this.httpRequestWithArgs(`/proxy/${port}/blacklist`, Method.GET));
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Set a URL to blacklist
|
|
115
|
+
*/
|
|
116
|
+
async setBlacklist(port, args) {
|
|
117
|
+
await this.httpRequestWithArgs(`/proxy/${port}/blacklist`, Method.PUT, { ...args });
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Clears all URL patterns from the blacklist
|
|
121
|
+
*/
|
|
122
|
+
async clearBlacklist(port) {
|
|
123
|
+
await this.httpRequestWithArgs(`/proxy/${port}/blacklist`, Method.DELETE);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Limit the bandwidth through the proxy
|
|
127
|
+
*/
|
|
128
|
+
async setBandwidthLimit(port, args = {}) {
|
|
129
|
+
await this.httpRequestWithArgs(`/proxy/${port}/limit`, Method.PUT, { ...args });
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Displays the amount of data remaining to be uploaded/downloaded until the limit is reached
|
|
133
|
+
*/
|
|
134
|
+
async getBandwidthLimit(port) {
|
|
135
|
+
return JSON.parse(await this.httpRequestWithArgs(`/proxy/${port}/limit`, Method.GET));
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Set and override HTTP Request headers
|
|
139
|
+
* Key is a header name (such as "User-Agent") and value is a value of HTTP header (such as "BrowserMob-Agent")
|
|
140
|
+
*/
|
|
141
|
+
async setRequestHeaders(port, headers) {
|
|
142
|
+
await this.httpRequest({
|
|
143
|
+
path: `/proxy/${port}/headers`,
|
|
144
|
+
method: Method.POST,
|
|
145
|
+
headers: {
|
|
146
|
+
'Content-Type': 'text/plain',
|
|
147
|
+
},
|
|
148
|
+
}, JSON.stringify(headers));
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Overrides normal DNS lookups and remaps the given hosts with the associated IP address
|
|
152
|
+
* Key is a host name (such as "example.com") and value is the IP address (such as "1.2.3.4")
|
|
153
|
+
*/
|
|
154
|
+
async setHosts(port, hosts) {
|
|
155
|
+
await this.httpRequest({
|
|
156
|
+
path: `/proxy/${port}/hosts`,
|
|
157
|
+
method: Method.POST,
|
|
158
|
+
headers: {
|
|
159
|
+
'Content-Type': 'text/plain',
|
|
160
|
+
},
|
|
161
|
+
}, JSON.stringify(hosts));
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Set username and passwords to be sent for requests on a specific domain that are protected by Basic Authentication
|
|
165
|
+
*/
|
|
166
|
+
async setBasicAuth(port, domain, username, password) {
|
|
167
|
+
await this.httpRequest({
|
|
168
|
+
path: `/proxy/${port}/auth/basic/${domain}`,
|
|
169
|
+
method: Method.POST,
|
|
170
|
+
headers: {
|
|
171
|
+
'Content-Type': 'text/plain',
|
|
172
|
+
},
|
|
173
|
+
}, JSON.stringify({ username, password }));
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Wait till all request are being made
|
|
177
|
+
*/
|
|
178
|
+
async wait(port, args) {
|
|
179
|
+
return this.httpRequestWithArgs(`/proxy/${port}/wait`, Method.PUT, { ...args });
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Handles different proxy timeouts
|
|
183
|
+
*/
|
|
184
|
+
async setTimeouts(port, timeouts) {
|
|
185
|
+
await this.httpRequest({
|
|
186
|
+
path: `/proxy/${port}/timeout`,
|
|
187
|
+
method: Method.PUT,
|
|
188
|
+
headers: {
|
|
189
|
+
'Content-Type': 'text/plain',
|
|
190
|
+
},
|
|
191
|
+
}, JSON.stringify(timeouts));
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Redirecting URLs
|
|
195
|
+
*/
|
|
196
|
+
async setRewrite(port, args) {
|
|
197
|
+
await this.httpRequestWithArgs(`/proxy/${port}/rewrite`, Method.PUT, { ...args });
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Removes all URL redirection rules currently in effect
|
|
201
|
+
*/
|
|
202
|
+
async clearRewrites(port) {
|
|
203
|
+
await this.httpRequestWithArgs(`/proxy/${port}/rewrite`, Method.DELETE);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Set retry count
|
|
207
|
+
*/
|
|
208
|
+
async setRetryCount(port, args) {
|
|
209
|
+
await this.httpRequestWithArgs(`/proxy/${port}/retry`, Method.PUT, { ...args });
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Empties the DNS cache
|
|
213
|
+
*/
|
|
214
|
+
async clearDNSCache(port) {
|
|
215
|
+
await this.httpRequestWithArgs(`/proxy/${port}/dns/cache`, Method.DELETE);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Set request interceptor
|
|
219
|
+
* example: await proxy.setRequestInterceptor(port, "request.headers().remove('User-Agent'); request.headers().add('User-Agent', 'My-Custom-User-Agent-String 1.0');");
|
|
220
|
+
* @see https://github.com/lightbody/browsermob-proxy#rest-api-interceptors-with-littleproxy
|
|
221
|
+
*/
|
|
222
|
+
async setRequestInterceptor(port, interceptor) {
|
|
223
|
+
await this.httpRequest({
|
|
224
|
+
path: `/proxy/${port}/filter/request`,
|
|
225
|
+
method: Method.POST,
|
|
226
|
+
headers: {
|
|
227
|
+
'Content-Type': 'text/plain',
|
|
228
|
+
},
|
|
229
|
+
}, interceptor);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Set response interceptor
|
|
233
|
+
* example: await proxy.setResponseInterceptor(port, "response.headers().remove('User-Agent'); response.headers().add('User-Agent', 'My-Custom-User-Agent-String 1.0');");
|
|
234
|
+
* @see https://github.com/lightbody/browsermob-proxy#rest-api-interceptors-with-littleproxy
|
|
235
|
+
*/
|
|
236
|
+
async setResponseInterceptor(port, interceptor) {
|
|
237
|
+
await this.httpRequest({
|
|
238
|
+
path: `/proxy/${port}/filter/response`,
|
|
239
|
+
method: Method.POST,
|
|
240
|
+
headers: {
|
|
241
|
+
'Content-Type': 'text/plain',
|
|
242
|
+
},
|
|
243
|
+
}, interceptor);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
102
246
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAwB,MAAM,MAA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ACP,cAAc,EAAE,YAAY;aAC7B;SACF,EACD,WAAW,CACZ,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
export interface ProxyListItem {
|
|
2
|
+
port: number;
|
|
3
|
+
}
|
|
4
|
+
export interface ProxyList {
|
|
5
|
+
proxyList: ProxyListItem[];
|
|
6
|
+
}
|
|
7
|
+
export interface StartProxyArgs {
|
|
8
|
+
/**
|
|
9
|
+
* The specific port to start the proxy service on.
|
|
10
|
+
* Optional, default is generated and returned in response.
|
|
11
|
+
*/
|
|
12
|
+
port?: number;
|
|
13
|
+
/**
|
|
14
|
+
* The username to use to authenticate with the chained proxy.
|
|
15
|
+
* Optional, default to null.
|
|
16
|
+
*/
|
|
17
|
+
proxyUsername?: string;
|
|
18
|
+
/**
|
|
19
|
+
* The password to use to authenticate with the chained proxy.
|
|
20
|
+
* Optional, default to null.
|
|
21
|
+
*/
|
|
22
|
+
proxyPassword?: string;
|
|
23
|
+
/**
|
|
24
|
+
* If running BrowserMob Proxy in a multi-homed environment,
|
|
25
|
+
* specify a desired bind address. Optional, default to "0.0.0.0".
|
|
26
|
+
*/
|
|
27
|
+
bindAddress?: string;
|
|
28
|
+
/**
|
|
29
|
+
* If running BrowserMob Proxy in a multi-homed environment,
|
|
30
|
+
* specify a desired server bind address. Optional, default to "0.0.0.0".
|
|
31
|
+
*/
|
|
32
|
+
serverBindAddress?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Uses Elliptic Curve Cryptography for certificate impersonation.
|
|
35
|
+
* Optional, default to "false".
|
|
36
|
+
*/
|
|
37
|
+
useEcc?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Disables verification of all upstream servers' SSL certificates.
|
|
40
|
+
* All upstream servers will be trusted,
|
|
41
|
+
* even if they do not present valid certificates
|
|
42
|
+
* signed by certification authorities in the JDK's trust store.
|
|
43
|
+
* Optional, default to "false".
|
|
44
|
+
*/
|
|
45
|
+
trustAllServers?: boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface StartHarArgs {
|
|
48
|
+
/**
|
|
49
|
+
* capture headers or not
|
|
50
|
+
* Optional, default to "false".
|
|
51
|
+
*/
|
|
52
|
+
captureHeaders?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* capture cookies or not
|
|
55
|
+
* Optional, default to "false"
|
|
56
|
+
*/
|
|
57
|
+
captureCookies?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* capture content bodies or not
|
|
60
|
+
* Optional, default to "false"
|
|
61
|
+
*/
|
|
62
|
+
captureContent?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* capture binary content or not
|
|
65
|
+
* Optional, default to "false"
|
|
66
|
+
*/
|
|
67
|
+
captureBinaryContent?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* The string name of The first page ref that should be used in the HAR.
|
|
70
|
+
* Optional, default to "Page 1".
|
|
71
|
+
*/
|
|
72
|
+
initialPageRef?: string;
|
|
73
|
+
/**
|
|
74
|
+
* The title of first HAR page. Optional, default to initialPageRef.
|
|
75
|
+
*/
|
|
76
|
+
initialPageTitle?: string;
|
|
77
|
+
}
|
|
78
|
+
export interface NewHarPageArgs {
|
|
79
|
+
/**
|
|
80
|
+
* The string name of the first page ref that should be used in the HAR.
|
|
81
|
+
* Optional, default to "Page N" where N is the next page number.
|
|
82
|
+
*/
|
|
83
|
+
pageRef?: string;
|
|
84
|
+
/**
|
|
85
|
+
* The title of new HAR page.
|
|
86
|
+
* Optional, default to pageRef.
|
|
87
|
+
*/
|
|
88
|
+
pageTitle?: string;
|
|
89
|
+
}
|
|
90
|
+
export interface SetWhitelistArgs {
|
|
91
|
+
/**
|
|
92
|
+
* A comma separated list of regular expressions
|
|
93
|
+
*/
|
|
94
|
+
regex: string;
|
|
95
|
+
/**
|
|
96
|
+
* The HTTP status code to return for URLs that do not match the whitelist.
|
|
97
|
+
* Optional, default to 200
|
|
98
|
+
*/
|
|
99
|
+
status?: number;
|
|
100
|
+
}
|
|
101
|
+
export interface SetBlacklistArgs {
|
|
102
|
+
/**
|
|
103
|
+
* The blacklist regular expression
|
|
104
|
+
*/
|
|
105
|
+
regex: string;
|
|
106
|
+
/**
|
|
107
|
+
* The HTTP status code to return for URLs that are blacklisted
|
|
108
|
+
*/
|
|
109
|
+
status?: number;
|
|
110
|
+
/**
|
|
111
|
+
* The regular expression for matching HTTP method (GET, POST, PUT, etc).
|
|
112
|
+
* Optional, by default processing all HTTP method.
|
|
113
|
+
*/
|
|
114
|
+
method?: string;
|
|
115
|
+
}
|
|
116
|
+
export interface BlacklistItem {
|
|
117
|
+
urlPattern: string;
|
|
118
|
+
statusCode: number;
|
|
119
|
+
httpMethodPattern: string | null;
|
|
120
|
+
responseCode: number;
|
|
121
|
+
pattern: string;
|
|
122
|
+
method: string | null;
|
|
123
|
+
}
|
|
124
|
+
export interface SetBandwidthLimitArgs {
|
|
125
|
+
/**
|
|
126
|
+
* Sets the downstream bandwidth limit in kbps
|
|
127
|
+
*/
|
|
128
|
+
downstreamKbps?: number;
|
|
129
|
+
/**
|
|
130
|
+
* Sets the upstream bandwidth limit kbps
|
|
131
|
+
* by default unlimited
|
|
132
|
+
*/
|
|
133
|
+
upstreamKbps?: number;
|
|
134
|
+
/**
|
|
135
|
+
* Specifies how many kilobytes in total the client is allowed to download through the proxy
|
|
136
|
+
* by default unlimited
|
|
137
|
+
*/
|
|
138
|
+
downstreamMaxKB?: number;
|
|
139
|
+
/**
|
|
140
|
+
* Specifies how many kilobytes in total the client is allowed to upload through the proxy
|
|
141
|
+
* by default unlimited
|
|
142
|
+
*/
|
|
143
|
+
upstreamMaxKB?: number;
|
|
144
|
+
/**
|
|
145
|
+
* Add the given latency to each HTTP request
|
|
146
|
+
* by default all requests are invoked without latency
|
|
147
|
+
*/
|
|
148
|
+
latency?: number;
|
|
149
|
+
/**
|
|
150
|
+
* A boolean that enable bandwidth limiter.
|
|
151
|
+
* by default to "false", but setting any of the properties above will implicitly enable throttling
|
|
152
|
+
*/
|
|
153
|
+
enable?: boolean;
|
|
154
|
+
/**
|
|
155
|
+
* Specifying what percentage of data sent is payload, e.g. use this to take into account overhead due to tcp/ip
|
|
156
|
+
*/
|
|
157
|
+
payloadPercentage?: number;
|
|
158
|
+
/**
|
|
159
|
+
* The max bits per seconds you want this instance of StreamManager to respect
|
|
160
|
+
*/
|
|
161
|
+
maxBitsPerSecond?: number;
|
|
162
|
+
}
|
|
163
|
+
export interface BandwidthLimitsResponse {
|
|
164
|
+
maxUpstreamKB: number;
|
|
165
|
+
remainingUpstreamKB: number;
|
|
166
|
+
maxDownstreamKB: number;
|
|
167
|
+
remainingDownstreamKB: number;
|
|
168
|
+
}
|
|
169
|
+
export interface SetRewriteArgs {
|
|
170
|
+
/**
|
|
171
|
+
* A matching URL regular expression
|
|
172
|
+
*/
|
|
173
|
+
matchRegex: string;
|
|
174
|
+
/**
|
|
175
|
+
* replacement URL
|
|
176
|
+
*/
|
|
177
|
+
replace: string;
|
|
178
|
+
}
|
|
179
|
+
export interface SetRetryCountArgs {
|
|
180
|
+
/**
|
|
181
|
+
* The number of times a method will be retried.
|
|
182
|
+
*/
|
|
183
|
+
retrycount: number;
|
|
184
|
+
}
|
|
185
|
+
export interface WaitArgs {
|
|
186
|
+
/**
|
|
187
|
+
* Wait till all request are being made
|
|
188
|
+
*/
|
|
189
|
+
quietPeriodInMs: number;
|
|
190
|
+
/**
|
|
191
|
+
* Sets quiet period in milliseconds
|
|
192
|
+
*/
|
|
193
|
+
timeoutInMs: number;
|
|
194
|
+
}
|
|
195
|
+
export interface SetTimeoutsArgs {
|
|
196
|
+
/**
|
|
197
|
+
* Request timeout in milliseconds.
|
|
198
|
+
* A timeout value of -1 is interpreted as infinite timeout.
|
|
199
|
+
* default to "-1".
|
|
200
|
+
*/
|
|
201
|
+
requestTimeout?: number;
|
|
202
|
+
/**
|
|
203
|
+
* Read timeout in milliseconds. Which is the timeout for waiting for data or,
|
|
204
|
+
* put differently, a maximum period inactivity between two consecutive data packets.
|
|
205
|
+
* A timeout value of zero is interpreted as an infinite timeout.
|
|
206
|
+
* default to "60000".
|
|
207
|
+
*/
|
|
208
|
+
readTimeout?: number;
|
|
209
|
+
/**
|
|
210
|
+
* Determines the timeout in milliseconds until a connection is established.
|
|
211
|
+
* A timeout value of zero is interpreted as an infinite timeout.
|
|
212
|
+
* default to "60000".
|
|
213
|
+
*/
|
|
214
|
+
connectionTimeout?: number;
|
|
215
|
+
/**
|
|
216
|
+
* Sets the maximum length of time that records will be stored in this Cache.
|
|
217
|
+
* A nonpositive value disables this feature (that is, sets no limit).
|
|
218
|
+
* default to "0".
|
|
219
|
+
*/
|
|
220
|
+
dnsCacheTimeout?: number;
|
|
221
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../typings/proxy.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "browsermob-proxy-api-client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
"type": "git",
|
|
14
14
|
"url": "git@github.com:raul72/browsermob-proxy-api-client.git"
|
|
15
15
|
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@types/har-format": "^1.2.10"
|
|
18
|
+
},
|
|
16
19
|
"devDependencies": {
|
|
17
20
|
"@microsoft/eslint-formatter-sarif": "2.1.7",
|
|
18
21
|
"@types/node": "^16",
|