dv-browser 2.5.4 → 3.0.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 (2) hide show
  1. package/index.js +12 -5
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -9,7 +9,6 @@ let DvBrowser = function (_config) {
9
9
  timeout: 15,
10
10
  connectTimeout: 5,
11
11
  httpProxy: null,
12
- httpProxyUserPwd: null,
13
12
  allowRedirect: true,
14
13
  userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36',
15
14
  accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
@@ -18,6 +17,8 @@ let DvBrowser = function (_config) {
18
17
  connection: 'close',
19
18
  proxyConnection: 'close',
20
19
  xhr: false,
20
+ origin: null,
21
+ authBasic: null,
21
22
  authBearer: null,
22
23
  noDeflate: false,
23
24
  }, _config);
@@ -90,6 +91,12 @@ let DvBrowser = function (_config) {
90
91
  if (options.xhr) {
91
92
  headers.push('X-Requested-With: XMLHttpRequest');
92
93
  }
94
+ if (options.origin) {
95
+ headers.push('Origin: ' + options.origin);
96
+ }
97
+ if (options.authBasic) {
98
+ headers.push('Authorization: Basic ' + (new Buffer(options.authBasic)).toString('base64'));
99
+ }
93
100
  if (options.authBearer) {
94
101
  headers.push('Authorization: Bearer ' + options.authBearer);
95
102
  }
@@ -129,10 +136,10 @@ let DvBrowser = function (_config) {
129
136
  if (!options.noDeflate) {
130
137
  curl.setOpt(Curl.option.ACCEPT_ENCODING, 'gzip');
131
138
  }
132
- if (options.httpProxy) {
133
- curl.setOpt(Curl.option.PROXY, options.httpProxy);
134
- if (options.httpProxyUserPwd) {
135
- curl.setOpt(Curl.option.PROXYUSERPWD, options.httpProxyUserPwd);
139
+ if (options?.httpProxy?.address && options?.httpProxy?.port) {
140
+ curl.setOpt(Curl.option.PROXY, options.httpProxy.address + ':' + options.httpProxy.port);
141
+ if (options.httpProxy.auth) {
142
+ curl.setOpt(Curl.option.PROXYUSERPWD, options.httpProxy.auth);
136
143
  }
137
144
  }
138
145
  curl.on('header', handleHeader);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dv-browser",
3
- "version": "2.5.4",
3
+ "version": "3.0.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {