Skip to content

Commit 9a34009

Browse files
authored
Merge pull request #490 from tiagosiebler/webpack
chore(v2.13.20): bump webpack & nanoid modules, update webpack config
2 parents 4d474a0 + 77d3103 commit 9a34009

File tree

8 files changed

+358
-369
lines changed

8 files changed

+358
-369
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ testfile.ts
1010
privaterepotracker
1111
restClientRegex.ts
1212
.DS_Store
13+
dist

package-lock.json

Lines changed: 307 additions & 315 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "binance",
3-
"version": "2.13.19",
3+
"version": "2.13.20",
44
"description": "Node.js & JavaScript SDK for Binance REST APIs & WebSockets, with TypeScript & end-to-end tests.",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",
@@ -47,10 +47,9 @@
4747
"typescript": "^4.7.4"
4848
},
4949
"optionalDependencies": {
50-
"https-proxy-agent": "^6.1.0",
5150
"source-map-loader": "^2.0.0",
5251
"ts-loader": "^8.0.11",
53-
"webpack": "^5.4.0"
52+
"webpack": "^5.97.1"
5453
},
5554
"keywords": [
5655
"binance",

src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export * from './types/shared';
88
export * from './types/spot';
99
export * from './types/websockets';
1010
export * from './usdm-client';
11-
export * from './util/proxy';
1211
export * from './util/requestUtils';
1312
export * from './util/typeGuards';
1413
export * from './util/WsStore';

src/util/proxy.ts

Lines changed: 0 additions & 40 deletions
This file was deleted.

test/proxy.util.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,42 @@ export function getTestProxy(): AxiosRequestConfig {
2424
},
2525
};
2626
}
27+
28+
/**
29+
* Returns an axios & websocket compatible proxy config using brightdata credentials
30+
*/
31+
export function getHttpsProxyAgent(
32+
host: string,
33+
port: string | number,
34+
user: string,
35+
pass: string,
36+
): AxiosRequestConfig | undefined {
37+
try {
38+
// Optional dependency that might be missing
39+
const { HttpsProxyAgent } = require('https-proxy-agent');
40+
41+
const url = `https://${user}:${pass}@${host}:${port}`;
42+
return new HttpsProxyAgent(url);
43+
} catch (e) {
44+
const msg = `Failed to prepare https proxy config - proxy agent dependency not installed`;
45+
console.error(new Date(), msg, e);
46+
throw new Error(msg);
47+
}
48+
}
49+
50+
export function getWsProxyAgent(
51+
host: string,
52+
port: string | number,
53+
user: string,
54+
pass: string,
55+
): any {
56+
try {
57+
const { SocksProxyAgent } = require('socks-proxy-agent');
58+
const url = `socks://${user}:${pass}@${host}:${port}`;
59+
return new SocksProxyAgent(url);
60+
} catch (e) {
61+
const msg = `Failed to prepare WS proxy config - proxy agent dependency not installed`;
62+
console.error(new Date(), msg, e);
63+
throw new Error(msg);
64+
}
65+
}

test/spot/private.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import {
2-
MainClient,
3-
NewSpotOrderParams,
4-
getHttpsProxyAgent,
5-
} from '../../src/index';
1+
import { MainClient, NewSpotOrderParams } from '../../src/index';
62
import { getTestProxy } from '../proxy.util';
73

84
describe('Private Spot REST API Endpoints', () => {

webpack/webpack.config.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ function generateConfig(name) {
3333

3434
{
3535
test: /\.m?js$/,
36-
exclude: /(node_modules|bower_components|samples|lib|test|coverage)/,
36+
exclude: [
37+
/(node_modules|bower_components|samples|lib|test|coverage)/,
38+
'/lib/util/proxy.js'
39+
],
3740
use: {
3841
loader: 'babel-loader',
3942
options: {
@@ -46,13 +49,13 @@ function generateConfig(name) {
4649
}
4750
}
4851
]
49-
}
52+
},
5053
};
5154

5255
config.plugins = [
53-
new webpack.DefinePlugin({
54-
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
55-
}),
56+
// new webpack.DefinePlugin({
57+
// 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
58+
// }),
5659
// new BundleAnalyzerPlugin({
5760
// defaultSizes: 'stat',
5861
// analyzerMode: 'static',

0 commit comments

Comments
 (0)