@tdxvolt/volt-client-grpc 0.11.3 → 0.11.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/lib/index.cjs +17 -9
- package/package.json +2 -1
- package/src/grpc-call.js +9 -1
- package/src/grpc-utils.js +1 -1
- package/src/volt-client-internal.js +5 -5
- package/src/volt-client.js +2 -2
package/lib/index.cjs
CHANGED
|
@@ -241,7 +241,7 @@ function createClient(
|
|
|
241
241
|
) {
|
|
242
242
|
let grpcCredentials;
|
|
243
243
|
if (credentials) {
|
|
244
|
-
const ca = credentials.config?.relay?.ca_pem || credentials.cache.ca;
|
|
244
|
+
const ca = credentials.config?.volt?.relay?.ca_pem || credentials.cache.ca;
|
|
245
245
|
const cert = credentials.cache.cloud_cert || credentials.cache.cert;
|
|
246
246
|
const { key } = credentials.cache;
|
|
247
247
|
|
|
@@ -987,7 +987,15 @@ class GRPCCall extends EventEmitter__default["default"] {
|
|
|
987
987
|
streamResponse,
|
|
988
988
|
);
|
|
989
989
|
if (parsedResponse.payload) {
|
|
990
|
-
|
|
990
|
+
// Interpret a non-empty status message as an error.
|
|
991
|
+
if (parsedResponse.payload?.status?.message) {
|
|
992
|
+
this.emit(
|
|
993
|
+
"error",
|
|
994
|
+
new Error(parsedResponse.payload.status.message),
|
|
995
|
+
);
|
|
996
|
+
} else {
|
|
997
|
+
this.emit("data", parsedResponse.payload);
|
|
998
|
+
}
|
|
991
999
|
} else if (parsedResponse.ended) {
|
|
992
1000
|
if (parsedResponse.error) {
|
|
993
1001
|
this.emit("error", new Error(parsedResponse.error));
|
|
@@ -1368,9 +1376,9 @@ async function bindInternal() {
|
|
|
1368
1376
|
}
|
|
1369
1377
|
|
|
1370
1378
|
// For remote connections, add our cloud-issued certificate as an additional credential.
|
|
1371
|
-
if (this.
|
|
1379
|
+
if (this._voltConfig?.relay?.ca_pem && this._credential.cache.cloud_cert) {
|
|
1372
1380
|
bindRequest.x509_credential = bindRequest.x509_credential.concat(
|
|
1373
|
-
this._credential.cache.cloud_cert + this.
|
|
1381
|
+
this._credential.cache.cloud_cert + this._voltConfig.relay.ca_pem,
|
|
1374
1382
|
);
|
|
1375
1383
|
}
|
|
1376
1384
|
|
|
@@ -1461,7 +1469,7 @@ function connectInternal() {
|
|
|
1461
1469
|
function getVoltAPIClientInternal() {
|
|
1462
1470
|
if (!this._cachedClient) {
|
|
1463
1471
|
const serviceAddress = this.isRemote
|
|
1464
|
-
? this.
|
|
1472
|
+
? this._voltConfig.relay.address
|
|
1465
1473
|
: this._voltConfig.address;
|
|
1466
1474
|
log$1("creating cached VoltAPI service client on %s", serviceAddress);
|
|
1467
1475
|
let serviceDescriptors = {};
|
|
@@ -1476,8 +1484,8 @@ function getVoltAPIClientInternal() {
|
|
|
1476
1484
|
serviceAddress,
|
|
1477
1485
|
this._credential,
|
|
1478
1486
|
this.isRemote && !this.isVoltRelay,
|
|
1479
|
-
this.
|
|
1480
|
-
this.
|
|
1487
|
+
this._voltConfig?.relay?.cloud ? this._voltConfig.id : "",
|
|
1488
|
+
this._voltConfig?.relay?.cloud ? this._voltConfig.id : "",
|
|
1481
1489
|
);
|
|
1482
1490
|
}
|
|
1483
1491
|
|
|
@@ -1819,11 +1827,11 @@ class VoltClient extends EventEmitter__default["default"] {
|
|
|
1819
1827
|
}
|
|
1820
1828
|
|
|
1821
1829
|
get isRemote() {
|
|
1822
|
-
return !!(this.
|
|
1830
|
+
return !!(this._voltConfig?.relay && this._voltConfig.id);
|
|
1823
1831
|
}
|
|
1824
1832
|
|
|
1825
1833
|
get isVoltRelay() {
|
|
1826
|
-
return this.isRemote && !this.
|
|
1834
|
+
return this.isRemote && !this._voltConfig?.relay.cloud;
|
|
1827
1835
|
}
|
|
1828
1836
|
|
|
1829
1837
|
connect() {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.11.
|
|
6
|
+
"version": "0.11.5",
|
|
7
7
|
"description": "tdx Volt library for nodejs clients",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"exports": {
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"@grpc/proto-loader": "^0.6.4",
|
|
40
40
|
"bent": "^7.3.12",
|
|
41
41
|
"bs58": "^4.0.1",
|
|
42
|
+
"builtin-modules": "^3.3.0",
|
|
42
43
|
"debug": "^4.1.1",
|
|
43
44
|
"ip": "^1.1.5",
|
|
44
45
|
"jsonwebtoken": "^8.5.1",
|
package/src/grpc-call.js
CHANGED
|
@@ -203,7 +203,15 @@ export default class GRPCCall extends EventEmitter {
|
|
|
203
203
|
streamResponse,
|
|
204
204
|
);
|
|
205
205
|
if (parsedResponse.payload) {
|
|
206
|
-
|
|
206
|
+
// Interpret a non-empty status message as an error.
|
|
207
|
+
if (parsedResponse.payload?.status?.message) {
|
|
208
|
+
this.emit(
|
|
209
|
+
"error",
|
|
210
|
+
new Error(parsedResponse.payload.status.message),
|
|
211
|
+
);
|
|
212
|
+
} else {
|
|
213
|
+
this.emit("data", parsedResponse.payload);
|
|
214
|
+
}
|
|
207
215
|
} else if (parsedResponse.ended) {
|
|
208
216
|
if (parsedResponse.error) {
|
|
209
217
|
this.emit("error", new Error(parsedResponse.error));
|
package/src/grpc-utils.js
CHANGED
|
@@ -20,7 +20,7 @@ export function createClient(
|
|
|
20
20
|
) {
|
|
21
21
|
let grpcCredentials;
|
|
22
22
|
if (credentials) {
|
|
23
|
-
const ca = credentials.config?.relay?.ca_pem || credentials.cache.ca;
|
|
23
|
+
const ca = credentials.config?.volt?.relay?.ca_pem || credentials.cache.ca;
|
|
24
24
|
const cert = credentials.cache.cloud_cert || credentials.cache.cert;
|
|
25
25
|
const { key } = credentials.cache;
|
|
26
26
|
|
|
@@ -150,9 +150,9 @@ export async function bindInternal() {
|
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
// For remote connections, add our cloud-issued certificate as an additional credential.
|
|
153
|
-
if (this.
|
|
153
|
+
if (this._voltConfig?.relay?.ca_pem && this._credential.cache.cloud_cert) {
|
|
154
154
|
bindRequest.x509_credential = bindRequest.x509_credential.concat(
|
|
155
|
-
this._credential.cache.cloud_cert + this.
|
|
155
|
+
this._credential.cache.cloud_cert + this._voltConfig.relay.ca_pem,
|
|
156
156
|
);
|
|
157
157
|
}
|
|
158
158
|
|
|
@@ -243,7 +243,7 @@ export function connectInternal() {
|
|
|
243
243
|
export function getVoltAPIClientInternal() {
|
|
244
244
|
if (!this._cachedClient) {
|
|
245
245
|
const serviceAddress = this.isRemote
|
|
246
|
-
? this.
|
|
246
|
+
? this._voltConfig.relay.address
|
|
247
247
|
: this._voltConfig.address;
|
|
248
248
|
log("creating cached VoltAPI service client on %s", serviceAddress);
|
|
249
249
|
let serviceDescriptors = {};
|
|
@@ -258,8 +258,8 @@ export function getVoltAPIClientInternal() {
|
|
|
258
258
|
serviceAddress,
|
|
259
259
|
this._credential,
|
|
260
260
|
this.isRemote && !this.isVoltRelay,
|
|
261
|
-
this.
|
|
262
|
-
this.
|
|
261
|
+
this._voltConfig?.relay?.cloud ? this._voltConfig.id : "",
|
|
262
|
+
this._voltConfig?.relay?.cloud ? this._voltConfig.id : "",
|
|
263
263
|
);
|
|
264
264
|
}
|
|
265
265
|
|
package/src/volt-client.js
CHANGED
|
@@ -258,11 +258,11 @@ export class VoltClient extends EventEmitter {
|
|
|
258
258
|
}
|
|
259
259
|
|
|
260
260
|
get isRemote() {
|
|
261
|
-
return !!(this.
|
|
261
|
+
return !!(this._voltConfig?.relay && this._voltConfig.id);
|
|
262
262
|
}
|
|
263
263
|
|
|
264
264
|
get isVoltRelay() {
|
|
265
|
-
return this.isRemote && !this.
|
|
265
|
+
return this.isRemote && !this._voltConfig?.relay.cloud;
|
|
266
266
|
}
|
|
267
267
|
|
|
268
268
|
connect() {
|