@dashevo/dapi-grpc 0.23.0-dev.8 → 0.24.0-dev.1
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.
|
@@ -17,6 +17,7 @@ const {
|
|
|
17
17
|
},
|
|
18
18
|
} = require('@dashevo/grpc-common');
|
|
19
19
|
|
|
20
|
+
const { URL } = require('url');
|
|
20
21
|
const {
|
|
21
22
|
org: {
|
|
22
23
|
dash: {
|
|
@@ -55,7 +56,6 @@ const {
|
|
|
55
56
|
} = require('./core_protoc');
|
|
56
57
|
|
|
57
58
|
const getCoreDefinition = require('../../../../lib/getCoreDefinition');
|
|
58
|
-
const stripHostname = require('../../../../lib/utils/stripHostname');
|
|
59
59
|
|
|
60
60
|
const CoreNodeJSClient = getCoreDefinition(0);
|
|
61
61
|
|
|
@@ -65,8 +65,16 @@ class CorePromiseClient {
|
|
|
65
65
|
* @param {?Object} credentials
|
|
66
66
|
* @param {?Object} options
|
|
67
67
|
*/
|
|
68
|
-
constructor(hostname, credentials
|
|
69
|
-
|
|
68
|
+
constructor(hostname, credentials, options = {}) {
|
|
69
|
+
if (credentials !== undefined) {
|
|
70
|
+
throw new Error('"credentials" option is not supported yet');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const url = new URL(hostname);
|
|
74
|
+
const { protocol, host: strippedHostname } = url;
|
|
75
|
+
|
|
76
|
+
// eslint-disable-next-line no-param-reassign
|
|
77
|
+
credentials = protocol === 'https' ? grpc.credentials.createSsl() : grpc.credentials.createInsecure();
|
|
70
78
|
|
|
71
79
|
this.client = new CoreNodeJSClient(strippedHostname, credentials, options);
|
|
72
80
|
|
|
@@ -17,6 +17,7 @@ const {
|
|
|
17
17
|
},
|
|
18
18
|
} = require('@dashevo/grpc-common');
|
|
19
19
|
|
|
20
|
+
const { URL } = require('url');
|
|
20
21
|
const {
|
|
21
22
|
org: {
|
|
22
23
|
dash: {
|
|
@@ -55,7 +56,6 @@ const {
|
|
|
55
56
|
} = require('./platform_protoc');
|
|
56
57
|
|
|
57
58
|
const getPlatformDefinition = require('../../../../lib/getPlatformDefinition');
|
|
58
|
-
const stripHostname = require('../../../../lib/utils/stripHostname');
|
|
59
59
|
|
|
60
60
|
const PlatformNodeJSClient = getPlatformDefinition(0);
|
|
61
61
|
|
|
@@ -65,8 +65,16 @@ class PlatformPromiseClient {
|
|
|
65
65
|
* @param {?Object} credentials
|
|
66
66
|
* @param {?Object} options
|
|
67
67
|
*/
|
|
68
|
-
constructor(hostname, credentials
|
|
69
|
-
|
|
68
|
+
constructor(hostname, credentials, options = {}) {
|
|
69
|
+
if (credentials !== undefined) {
|
|
70
|
+
throw new Error('"credentials" option is not supported yet');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const url = new URL(hostname);
|
|
74
|
+
const { protocol, host: strippedHostname } = url;
|
|
75
|
+
|
|
76
|
+
// eslint-disable-next-line no-param-reassign
|
|
77
|
+
credentials = protocol === 'https' ? grpc.credentials.createSsl() : grpc.credentials.createInsecure();
|
|
70
78
|
|
|
71
79
|
this.client = new PlatformNodeJSClient(strippedHostname, credentials, options);
|
|
72
80
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashevo/dapi-grpc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0-dev.1",
|
|
4
4
|
"description": "DAPI GRPC definition file and generated clients",
|
|
5
5
|
"browser": "browser.js",
|
|
6
6
|
"main": "node.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"homepage": "https://github.com/dashevo/dapi-grpc#readme",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@dashevo/grpc-common": "~0.
|
|
36
|
+
"@dashevo/grpc-common": "~0.24.0-dev.1",
|
|
37
37
|
"@dashevo/protobufjs": "6.10.5",
|
|
38
38
|
"@grpc/grpc-js": "^1.3.7",
|
|
39
39
|
"google-protobuf": "^3.12.2",
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const { URL } = require('url');
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Remove everything except (hostname/ip):port pair
|
|
5
|
-
*
|
|
6
|
-
* @param {string} hostname
|
|
7
|
-
*
|
|
8
|
-
* @returns {string}
|
|
9
|
-
*/
|
|
10
|
-
function stripHostname(hostname) {
|
|
11
|
-
const url = new URL(hostname);
|
|
12
|
-
return url.host;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
module.exports = stripHostname;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
const stripHostname = require('../../../lib/utils/stripHostname');
|
|
2
|
-
|
|
3
|
-
describe('stripHostname', () => {
|
|
4
|
-
let hostname;
|
|
5
|
-
|
|
6
|
-
beforeEach(() => {
|
|
7
|
-
hostname = 'http://ip:3030/';
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('should strip everything and leave only hostname:port pair', () => {
|
|
11
|
-
const result = stripHostname(hostname);
|
|
12
|
-
|
|
13
|
-
expect(result).to.equal('ip:3030');
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('should strip everything and leave only ip:port pair', () => {
|
|
17
|
-
hostname = 'http://127.0.0.1:3030/?some=params';
|
|
18
|
-
|
|
19
|
-
const result = stripHostname(hostname);
|
|
20
|
-
|
|
21
|
-
expect(result).to.equal('127.0.0.1:3030');
|
|
22
|
-
});
|
|
23
|
-
});
|