@tdxvolt/volt-client-grpc 0.20.10 → 0.20.11
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 +45 -155
- package/package.json +1 -1
- package/src/grpc-call.js +7 -8
- package/src/volt-client-internal.js +2 -2
- package/src/volt-client.js +17 -8
- package/src/volt-connection.js +3 -3
- package/src/volt-proto-literals.js +16 -134
package/lib/index.cjs
CHANGED
|
@@ -10,12 +10,12 @@ var debug = require('debug');
|
|
|
10
10
|
var Protobuf = require('protobufjs');
|
|
11
11
|
var camelCase = require('lodash.camelcase');
|
|
12
12
|
var descriptor = require('protobufjs/ext/descriptor/index.js');
|
|
13
|
+
var voltUtility = require('@tdxvolt/volt-utility');
|
|
13
14
|
var EventEmitter = require('events');
|
|
14
15
|
var fs = require('fs');
|
|
15
16
|
var path = require('path');
|
|
16
17
|
var jwt = require('jsonwebtoken');
|
|
17
18
|
var crypto = require('crypto');
|
|
18
|
-
var voltUtility = require('@tdxvolt/volt-utility');
|
|
19
19
|
|
|
20
20
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
21
21
|
|
|
@@ -1266,128 +1266,6 @@ message RemoteResponse {
|
|
|
1266
1266
|
HttpRequest http_request = 5;
|
|
1267
1267
|
}
|
|
1268
1268
|
}
|
|
1269
|
-
`;
|
|
1270
|
-
const spark_api = `syntax = "proto3";
|
|
1271
|
-
|
|
1272
|
-
package tdx.volt_api.volt.v1;
|
|
1273
|
-
|
|
1274
|
-
import "tdx/volt_api/volt/v1/status.proto";
|
|
1275
|
-
|
|
1276
|
-
// The Spark API allows clients to start and communicate with Spark VMs.
|
|
1277
|
-
service SparkAPI {
|
|
1278
|
-
// Start or connect to a spark VM and establish a long-lived communication channel.
|
|
1279
|
-
rpc Spark(stream SparkRequest) returns (stream SparkResponse);
|
|
1280
|
-
|
|
1281
|
-
// Get details of running spark VMs.
|
|
1282
|
-
rpc GetSpark(GetSparkRequest) returns (GetSparkResponse);
|
|
1283
|
-
}
|
|
1284
|
-
|
|
1285
|
-
// Start a resource-hosted spark.
|
|
1286
|
-
// Provenance is determined from the resource owner.
|
|
1287
|
-
message StartSparkResource {
|
|
1288
|
-
// The id of the resource containing the VM byte code.
|
|
1289
|
-
string resource_id = 1;
|
|
1290
|
-
|
|
1291
|
-
// JSON-encoded payload to parameterise the spark.
|
|
1292
|
-
string payload = 2;
|
|
1293
|
-
|
|
1294
|
-
// Envelope signature.
|
|
1295
|
-
string signature = 3;
|
|
1296
|
-
}
|
|
1297
|
-
|
|
1298
|
-
// Start a spark from byte code included in the payload, along with issuer/developer claims and signature.
|
|
1299
|
-
message StartSparkAdhoc {
|
|
1300
|
-
// Ad-hoc byte code of VM to run.
|
|
1301
|
-
bytes byte_code = 1;
|
|
1302
|
-
|
|
1303
|
-
// Verifiable credentials associated with this spark.
|
|
1304
|
-
repeated string credential = 2;
|
|
1305
|
-
|
|
1306
|
-
// Envelope signature.
|
|
1307
|
-
string signature = 3;
|
|
1308
|
-
|
|
1309
|
-
// JSON-encoded payload to parameterise the spark.
|
|
1310
|
-
string payload = 4;
|
|
1311
|
-
}
|
|
1312
|
-
|
|
1313
|
-
// Send commands and payloads to communicate with a running spark.
|
|
1314
|
-
message SparkCommand {
|
|
1315
|
-
// Optional id to associate with this command.
|
|
1316
|
-
// If this is omitted, an id will be assigned and returned in the command acknowledgement.
|
|
1317
|
-
string command_id = 1;
|
|
1318
|
-
|
|
1319
|
-
// The command to send to the spark.
|
|
1320
|
-
string command = 2;
|
|
1321
|
-
|
|
1322
|
-
// The command payload.
|
|
1323
|
-
string payload = 3;
|
|
1324
|
-
|
|
1325
|
-
// Command verifiable credential.
|
|
1326
|
-
string credential = 4;
|
|
1327
|
-
|
|
1328
|
-
// Command signature.
|
|
1329
|
-
string signature = 5;
|
|
1330
|
-
}
|
|
1331
|
-
|
|
1332
|
-
// The request must contain one of the messages indicated below.
|
|
1333
|
-
message SparkRequest {
|
|
1334
|
-
oneof payload {
|
|
1335
|
-
StartSparkResource start_resource = 1;
|
|
1336
|
-
StartSparkAdhoc start_adhoc = 2;
|
|
1337
|
-
SparkCommand command = 3;
|
|
1338
|
-
}
|
|
1339
|
-
}
|
|
1340
|
-
|
|
1341
|
-
// Receive events and payload from a running spark.
|
|
1342
|
-
message SparkData {
|
|
1343
|
-
// The command id to which this data corresponds.
|
|
1344
|
-
string command_id = 1;
|
|
1345
|
-
|
|
1346
|
-
oneof payload {
|
|
1347
|
-
// Acknowledges receipt of a spark command.
|
|
1348
|
-
bool acknowledge = 2;
|
|
1349
|
-
|
|
1350
|
-
// Indicates the command has completed.
|
|
1351
|
-
bool ended = 3;
|
|
1352
|
-
|
|
1353
|
-
// Will contain error details on command failure.
|
|
1354
|
-
string error = 4;
|
|
1355
|
-
|
|
1356
|
-
// Data emitted by a command, usually in stringified JSON format.
|
|
1357
|
-
string data = 5;
|
|
1358
|
-
}
|
|
1359
|
-
}
|
|
1360
|
-
|
|
1361
|
-
// Details of a spark instance.
|
|
1362
|
-
message SparkInstance {
|
|
1363
|
-
// The UUID assigned to the spark instance.
|
|
1364
|
-
string spark_id = 1;
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1367
|
-
// The response will contain one of the messages indicated below.
|
|
1368
|
-
message SparkResponse {
|
|
1369
|
-
oneof payload {
|
|
1370
|
-
// Details of any error that occurred on the call.
|
|
1371
|
-
tdx.volt_api.volt.v1.Status status = 1;
|
|
1372
|
-
|
|
1373
|
-
// Details of the spark instance, sent in response to a start command.
|
|
1374
|
-
SparkInstance spark_instance = 2;
|
|
1375
|
-
|
|
1376
|
-
// Payload data emitted by the spark.
|
|
1377
|
-
SparkData spark_data = 3;
|
|
1378
|
-
}
|
|
1379
|
-
}
|
|
1380
|
-
|
|
1381
|
-
message GetSparkRequest {
|
|
1382
|
-
string spark_id = 1;
|
|
1383
|
-
}
|
|
1384
|
-
|
|
1385
|
-
// One of the following fields will be present in the response.
|
|
1386
|
-
message GetSparkResponse {
|
|
1387
|
-
// Details of any error that occurred on the call.
|
|
1388
|
-
tdx.volt_api.volt.v1.Status status = 1;
|
|
1389
|
-
}
|
|
1390
|
-
|
|
1391
1269
|
`;
|
|
1392
1270
|
const ssi = `syntax = "proto3";
|
|
1393
1271
|
|
|
@@ -1463,12 +1341,11 @@ const ssi_api = `syntax = "proto3";
|
|
|
1463
1341
|
|
|
1464
1342
|
package tdx.volt_api.volt.v1;
|
|
1465
1343
|
|
|
1466
|
-
import "tdx/volt_api/volt/v1/status.proto";
|
|
1467
1344
|
import "tdx/volt_api/volt/v1/ssi.proto";
|
|
1345
|
+
import "tdx/volt_api/volt/v1/status.proto";
|
|
1468
1346
|
|
|
1469
1347
|
service SsiAPI {
|
|
1470
|
-
|
|
1471
|
-
rpc CreateExchangeToken(CreateExchangeTokenRequest) returns (CreateExchangeTokenResponse);
|
|
1348
|
+
rpc CacheEmailCredential(CacheEmailCredentialRequest) returns (CacheEmailCredentialResponse);
|
|
1472
1349
|
|
|
1473
1350
|
// Delete a DID document or all DID documents originating from a given Volt.
|
|
1474
1351
|
// Requires \`volt:delete-did\` API privilege.
|
|
@@ -1499,20 +1376,25 @@ service SsiAPI {
|
|
|
1499
1376
|
rpc SearchDIDRegistry(SearchDIDRegistryRequest) returns (SearchDIDRegistryResponse);
|
|
1500
1377
|
}
|
|
1501
1378
|
|
|
1502
|
-
message
|
|
1503
|
-
|
|
1504
|
-
|
|
1379
|
+
message CacheEmailCredentialRequest {
|
|
1380
|
+
string identity_did = 1;
|
|
1381
|
+
|
|
1382
|
+
string email_address = 2;
|
|
1383
|
+
|
|
1384
|
+
string identity_provider = 3;
|
|
1385
|
+
|
|
1386
|
+
string key_passphrase = 4;
|
|
1505
1387
|
|
|
1506
1388
|
// The time to live for the token, in seconds.
|
|
1507
|
-
uint32 ttl =
|
|
1389
|
+
uint32 ttl = 5;
|
|
1508
1390
|
}
|
|
1509
1391
|
|
|
1510
|
-
message
|
|
1392
|
+
message CacheEmailCredentialResponse {
|
|
1511
1393
|
// Details of any error that occurred on the call.
|
|
1512
1394
|
tdx.volt_api.volt.v1.Status status = 1;
|
|
1513
1395
|
|
|
1514
|
-
// The
|
|
1515
|
-
string
|
|
1396
|
+
// The verifiable credential resource id.
|
|
1397
|
+
string vc_id = 2;
|
|
1516
1398
|
}
|
|
1517
1399
|
|
|
1518
1400
|
message DeleteDIDRequest {
|
|
@@ -2714,7 +2596,7 @@ message AuthenticateRequest {
|
|
|
2714
2596
|
// A human-readable name of the entity requesting to authenticate.
|
|
2715
2597
|
string client_name = 6;
|
|
2716
2598
|
|
|
2717
|
-
// Optional challenge code, hashed using SHA-256 and base64 encoded.
|
|
2599
|
+
// Optional challenge code, hashed using SHA-256 and base64 URL encoded (no padding).
|
|
2718
2600
|
string challenge = 7;
|
|
2719
2601
|
|
|
2720
2602
|
// The host name to add as a SAN to the issued certificate.
|
|
@@ -3730,7 +3612,7 @@ message SubscribeWireResponse {
|
|
|
3730
3612
|
}
|
|
3731
3613
|
|
|
3732
3614
|
`;
|
|
3733
|
-
const voltProtos = [sqlite, sqlite_database_api, sqlite_server_api, proto_db_sync, proxy_api, relay_api, discovery_api, file, file_api, remote,
|
|
3615
|
+
const voltProtos = [sqlite, sqlite_database_api, sqlite_server_api, proto_db_sync, proxy_api, relay_api, discovery_api, file, file_api, remote, ssi, ssi_api, status, sync_api, terminal_api, volt, volt_api, wire_api];
|
|
3734
3616
|
|
|
3735
3617
|
debug__default["default"]("volt-client-grpc:proto-utils");
|
|
3736
3618
|
|
|
@@ -4151,11 +4033,6 @@ class GRPCCall extends EventEmitter__default["default"] {
|
|
|
4151
4033
|
);
|
|
4152
4034
|
|
|
4153
4035
|
this._call.on("data", (streamResponse) => {
|
|
4154
|
-
if (this._ended) {
|
|
4155
|
-
log$5("ignoring data after end on %s", this._methodName);
|
|
4156
|
-
return;
|
|
4157
|
-
}
|
|
4158
|
-
|
|
4159
4036
|
try {
|
|
4160
4037
|
const parsedResponse = _parseResponse.call(
|
|
4161
4038
|
this,
|
|
@@ -4163,6 +4040,13 @@ class GRPCCall extends EventEmitter__default["default"] {
|
|
|
4163
4040
|
this._initialRequest.meta,
|
|
4164
4041
|
streamResponse
|
|
4165
4042
|
);
|
|
4043
|
+
|
|
4044
|
+
if (this._ended && !parsedResponse.ended) {
|
|
4045
|
+
log$5("ignoring data after end on %s", this._methodName);
|
|
4046
|
+
log$5(parsedResponse);
|
|
4047
|
+
return;
|
|
4048
|
+
}
|
|
4049
|
+
|
|
4166
4050
|
if (parsedResponse.key_exchange) {
|
|
4167
4051
|
const peerKey = keyFromPem$2(
|
|
4168
4052
|
parsedResponse.key_exchange.encryption_key
|
|
@@ -4194,9 +4078,6 @@ class GRPCCall extends EventEmitter__default["default"] {
|
|
|
4194
4078
|
} else if (parsedResponse.ended) {
|
|
4195
4079
|
if (parsedResponse.error) {
|
|
4196
4080
|
this.emit("error", new Error(parsedResponse.error));
|
|
4197
|
-
} else {
|
|
4198
|
-
// Not sure this is necessary - we should receive "end" from grpc soon...
|
|
4199
|
-
this.emit("end");
|
|
4200
4081
|
}
|
|
4201
4082
|
} else {
|
|
4202
4083
|
log$5("method id is %s", parsedResponse.methodId);
|
|
@@ -4672,6 +4553,7 @@ function _cleanUp(immediateReconnect) {
|
|
|
4672
4553
|
}
|
|
4673
4554
|
|
|
4674
4555
|
if (this._dying) {
|
|
4556
|
+
log$3("dying - clearing reconnect timer");
|
|
4675
4557
|
clearTimeout(this._reconnectTimer);
|
|
4676
4558
|
} else if (immediateReconnect || (this._autoRetry && !this._reconnectTimer)) {
|
|
4677
4559
|
this._reconnectTimer = setTimeout(
|
|
@@ -4684,6 +4566,7 @@ function _cleanUp(immediateReconnect) {
|
|
|
4684
4566
|
}
|
|
4685
4567
|
|
|
4686
4568
|
if (this.call?.writable) {
|
|
4569
|
+
log$3("ending Connect call");
|
|
4687
4570
|
this.call.end();
|
|
4688
4571
|
}
|
|
4689
4572
|
}
|
|
@@ -4774,9 +4657,7 @@ function _doConnect(connectHello) {
|
|
|
4774
4657
|
});
|
|
4775
4658
|
|
|
4776
4659
|
this.call.on("end", () => {
|
|
4777
|
-
|
|
4778
|
-
this.emit("connected", false);
|
|
4779
|
-
}
|
|
4660
|
+
this.emit("connected", false);
|
|
4780
4661
|
_cleanUp.call(this);
|
|
4781
4662
|
});
|
|
4782
4663
|
|
|
@@ -5106,18 +4987,18 @@ function connectInternal(helloPayload) {
|
|
|
5106
4987
|
this._voltConnection.on("connected", (session) => {
|
|
5107
4988
|
this._session = session;
|
|
5108
4989
|
this._connected = !!session;
|
|
4990
|
+
this.emit("connected", session);
|
|
5109
4991
|
if (!this._connected) {
|
|
5110
4992
|
onDisconnected();
|
|
5111
4993
|
}
|
|
5112
|
-
this.emit("connected", session);
|
|
5113
4994
|
});
|
|
5114
4995
|
|
|
5115
4996
|
this._voltConnection.on("error", (err) => {
|
|
5116
4997
|
// Should auto-reconnect.
|
|
5117
4998
|
log$2("Volt connection error [%s]", err.message);
|
|
5118
4999
|
if (this._connected) {
|
|
5119
|
-
onDisconnected();
|
|
5120
5000
|
this.emit("connected", false);
|
|
5001
|
+
onDisconnected();
|
|
5121
5002
|
}
|
|
5122
5003
|
|
|
5123
5004
|
if (err.message.endsWith("session invalid")) {
|
|
@@ -5546,12 +5427,19 @@ class VoltClient extends EventEmitter__default["default"] {
|
|
|
5546
5427
|
* instead of a DID-based authentication session.
|
|
5547
5428
|
* @param {string} [options.exchangeToken] - optional token to exchange in return for an authenticated session.
|
|
5548
5429
|
* @param {boolean} [options.waitForAuth] - whether to block and poll on 'prompt' authenticate decisions. Default is true.
|
|
5430
|
+
* @param {boolean} [options.noResolve] - whether to skip resolving the Volt configuration. Default is false.
|
|
5549
5431
|
*/
|
|
5550
5432
|
async initialise(config, options = {}) {
|
|
5551
5433
|
log("initialise ", config, options);
|
|
5552
5434
|
|
|
5553
|
-
const {
|
|
5554
|
-
|
|
5435
|
+
const {
|
|
5436
|
+
ownDID,
|
|
5437
|
+
noDID,
|
|
5438
|
+
didRegistryList,
|
|
5439
|
+
exchangeToken,
|
|
5440
|
+
extraConfig,
|
|
5441
|
+
noResolve
|
|
5442
|
+
} = options;
|
|
5555
5443
|
const waitForAuth =
|
|
5556
5444
|
options.waitForAuth === undefined ? true : !!options.waitForAuth;
|
|
5557
5445
|
|
|
@@ -5601,10 +5489,12 @@ class VoltClient extends EventEmitter__default["default"] {
|
|
|
5601
5489
|
throw new Error("client_name property required in config");
|
|
5602
5490
|
}
|
|
5603
5491
|
|
|
5604
|
-
|
|
5605
|
-
this._config.volt
|
|
5606
|
-
|
|
5607
|
-
|
|
5492
|
+
if (!noResolve) {
|
|
5493
|
+
this._config.volt = await voltUtility.resolveVoltConfig(
|
|
5494
|
+
this._config.volt,
|
|
5495
|
+
didRegistryList
|
|
5496
|
+
);
|
|
5497
|
+
}
|
|
5608
5498
|
|
|
5609
5499
|
this._voltConfig = this._config.volt;
|
|
5610
5500
|
|
|
@@ -5667,7 +5557,7 @@ class VoltClient extends EventEmitter__default["default"] {
|
|
|
5667
5557
|
this._credential.saveCache();
|
|
5668
5558
|
}
|
|
5669
5559
|
|
|
5670
|
-
return Promise.resolve(this.
|
|
5560
|
+
return Promise.resolve(this.credential.config);
|
|
5671
5561
|
} catch (err) {
|
|
5672
5562
|
log("failure starting Volt client [%s]", err.message);
|
|
5673
5563
|
throw err;
|
package/package.json
CHANGED
package/src/grpc-call.js
CHANGED
|
@@ -361,11 +361,6 @@ export default class GRPCCall extends EventEmitter {
|
|
|
361
361
|
);
|
|
362
362
|
|
|
363
363
|
this._call.on("data", (streamResponse) => {
|
|
364
|
-
if (this._ended) {
|
|
365
|
-
log("ignoring data after end on %s", this._methodName);
|
|
366
|
-
return;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
364
|
try {
|
|
370
365
|
const parsedResponse = _parseResponse.call(
|
|
371
366
|
this,
|
|
@@ -373,6 +368,13 @@ export default class GRPCCall extends EventEmitter {
|
|
|
373
368
|
this._initialRequest.meta,
|
|
374
369
|
streamResponse
|
|
375
370
|
);
|
|
371
|
+
|
|
372
|
+
if (this._ended && !parsedResponse.ended) {
|
|
373
|
+
log("ignoring data after end on %s", this._methodName);
|
|
374
|
+
log(parsedResponse);
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
|
|
376
378
|
if (parsedResponse.key_exchange) {
|
|
377
379
|
const peerKey = keyFromPem(
|
|
378
380
|
parsedResponse.key_exchange.encryption_key
|
|
@@ -404,9 +406,6 @@ export default class GRPCCall extends EventEmitter {
|
|
|
404
406
|
} else if (parsedResponse.ended) {
|
|
405
407
|
if (parsedResponse.error) {
|
|
406
408
|
this.emit("error", new Error(parsedResponse.error));
|
|
407
|
-
} else {
|
|
408
|
-
// Not sure this is necessary - we should receive "end" from grpc soon...
|
|
409
|
-
this.emit("end");
|
|
410
409
|
}
|
|
411
410
|
} else {
|
|
412
411
|
log("method id is %s", parsedResponse.methodId);
|
|
@@ -265,18 +265,18 @@ export function connectInternal(helloPayload) {
|
|
|
265
265
|
this._voltConnection.on("connected", (session) => {
|
|
266
266
|
this._session = session;
|
|
267
267
|
this._connected = !!session;
|
|
268
|
+
this.emit("connected", session);
|
|
268
269
|
if (!this._connected) {
|
|
269
270
|
onDisconnected();
|
|
270
271
|
}
|
|
271
|
-
this.emit("connected", session);
|
|
272
272
|
});
|
|
273
273
|
|
|
274
274
|
this._voltConnection.on("error", (err) => {
|
|
275
275
|
// Should auto-reconnect.
|
|
276
276
|
log("Volt connection error [%s]", err.message);
|
|
277
277
|
if (this._connected) {
|
|
278
|
-
onDisconnected();
|
|
279
278
|
this.emit("connected", false);
|
|
279
|
+
onDisconnected();
|
|
280
280
|
}
|
|
281
281
|
|
|
282
282
|
if (err.message.endsWith("session invalid")) {
|
package/src/volt-client.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolveVoltConfig } from "@tdxvolt/volt-utility";
|
|
1
2
|
import debug from "debug";
|
|
2
3
|
import EventEmitter from "events";
|
|
3
4
|
import fs from "fs";
|
|
@@ -11,7 +12,6 @@ import {
|
|
|
11
12
|
unaryCallInternal
|
|
12
13
|
} from "./volt-client-internal.js";
|
|
13
14
|
import { VoltCredential } from "./volt-credential.js";
|
|
14
|
-
import { resolveVoltConfig } from "@tdxvolt/volt-utility";
|
|
15
15
|
|
|
16
16
|
const { readFile } = fs.promises;
|
|
17
17
|
const log = debug("volt-client-grpc:volt-client");
|
|
@@ -86,12 +86,19 @@ export class VoltClient extends EventEmitter {
|
|
|
86
86
|
* instead of a DID-based authentication session.
|
|
87
87
|
* @param {string} [options.exchangeToken] - optional token to exchange in return for an authenticated session.
|
|
88
88
|
* @param {boolean} [options.waitForAuth] - whether to block and poll on 'prompt' authenticate decisions. Default is true.
|
|
89
|
+
* @param {boolean} [options.noResolve] - whether to skip resolving the Volt configuration. Default is false.
|
|
89
90
|
*/
|
|
90
91
|
async initialise(config, options = {}) {
|
|
91
92
|
log("initialise ", config, options);
|
|
92
93
|
|
|
93
|
-
const {
|
|
94
|
-
|
|
94
|
+
const {
|
|
95
|
+
ownDID,
|
|
96
|
+
noDID,
|
|
97
|
+
didRegistryList,
|
|
98
|
+
exchangeToken,
|
|
99
|
+
extraConfig,
|
|
100
|
+
noResolve
|
|
101
|
+
} = options;
|
|
95
102
|
const waitForAuth =
|
|
96
103
|
options.waitForAuth === undefined ? true : !!options.waitForAuth;
|
|
97
104
|
|
|
@@ -141,10 +148,12 @@ export class VoltClient extends EventEmitter {
|
|
|
141
148
|
throw new Error("client_name property required in config");
|
|
142
149
|
}
|
|
143
150
|
|
|
144
|
-
|
|
145
|
-
this._config.volt
|
|
146
|
-
|
|
147
|
-
|
|
151
|
+
if (!noResolve) {
|
|
152
|
+
this._config.volt = await resolveVoltConfig(
|
|
153
|
+
this._config.volt,
|
|
154
|
+
didRegistryList
|
|
155
|
+
);
|
|
156
|
+
}
|
|
148
157
|
|
|
149
158
|
this._voltConfig = this._config.volt;
|
|
150
159
|
|
|
@@ -207,7 +216,7 @@ export class VoltClient extends EventEmitter {
|
|
|
207
216
|
this._credential.saveCache();
|
|
208
217
|
}
|
|
209
218
|
|
|
210
|
-
return Promise.resolve(this.
|
|
219
|
+
return Promise.resolve(this.credential.config);
|
|
211
220
|
} catch (err) {
|
|
212
221
|
log("failure starting Volt client [%s]", err.message);
|
|
213
222
|
throw err;
|
package/src/volt-connection.js
CHANGED
|
@@ -20,6 +20,7 @@ function _cleanUp(immediateReconnect) {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
if (this._dying) {
|
|
23
|
+
log("dying - clearing reconnect timer");
|
|
23
24
|
clearTimeout(this._reconnectTimer);
|
|
24
25
|
} else if (immediateReconnect || (this._autoRetry && !this._reconnectTimer)) {
|
|
25
26
|
this._reconnectTimer = setTimeout(
|
|
@@ -32,6 +33,7 @@ function _cleanUp(immediateReconnect) {
|
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
if (this.call?.writable) {
|
|
36
|
+
log("ending Connect call");
|
|
35
37
|
this.call.end();
|
|
36
38
|
}
|
|
37
39
|
}
|
|
@@ -122,9 +124,7 @@ function _doConnect(connectHello) {
|
|
|
122
124
|
});
|
|
123
125
|
|
|
124
126
|
this.call.on("end", () => {
|
|
125
|
-
|
|
126
|
-
this.emit("connected", false);
|
|
127
|
-
}
|
|
127
|
+
this.emit("connected", false);
|
|
128
128
|
_cleanUp.call(this);
|
|
129
129
|
});
|
|
130
130
|
|
|
@@ -718,128 +718,6 @@ message RemoteResponse {
|
|
|
718
718
|
HttpRequest http_request = 5;
|
|
719
719
|
}
|
|
720
720
|
}
|
|
721
|
-
`;
|
|
722
|
-
export const spark_api = `syntax = "proto3";
|
|
723
|
-
|
|
724
|
-
package tdx.volt_api.volt.v1;
|
|
725
|
-
|
|
726
|
-
import "tdx/volt_api/volt/v1/status.proto";
|
|
727
|
-
|
|
728
|
-
// The Spark API allows clients to start and communicate with Spark VMs.
|
|
729
|
-
service SparkAPI {
|
|
730
|
-
// Start or connect to a spark VM and establish a long-lived communication channel.
|
|
731
|
-
rpc Spark(stream SparkRequest) returns (stream SparkResponse);
|
|
732
|
-
|
|
733
|
-
// Get details of running spark VMs.
|
|
734
|
-
rpc GetSpark(GetSparkRequest) returns (GetSparkResponse);
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
// Start a resource-hosted spark.
|
|
738
|
-
// Provenance is determined from the resource owner.
|
|
739
|
-
message StartSparkResource {
|
|
740
|
-
// The id of the resource containing the VM byte code.
|
|
741
|
-
string resource_id = 1;
|
|
742
|
-
|
|
743
|
-
// JSON-encoded payload to parameterise the spark.
|
|
744
|
-
string payload = 2;
|
|
745
|
-
|
|
746
|
-
// Envelope signature.
|
|
747
|
-
string signature = 3;
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
// Start a spark from byte code included in the payload, along with issuer/developer claims and signature.
|
|
751
|
-
message StartSparkAdhoc {
|
|
752
|
-
// Ad-hoc byte code of VM to run.
|
|
753
|
-
bytes byte_code = 1;
|
|
754
|
-
|
|
755
|
-
// Verifiable credentials associated with this spark.
|
|
756
|
-
repeated string credential = 2;
|
|
757
|
-
|
|
758
|
-
// Envelope signature.
|
|
759
|
-
string signature = 3;
|
|
760
|
-
|
|
761
|
-
// JSON-encoded payload to parameterise the spark.
|
|
762
|
-
string payload = 4;
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
// Send commands and payloads to communicate with a running spark.
|
|
766
|
-
message SparkCommand {
|
|
767
|
-
// Optional id to associate with this command.
|
|
768
|
-
// If this is omitted, an id will be assigned and returned in the command acknowledgement.
|
|
769
|
-
string command_id = 1;
|
|
770
|
-
|
|
771
|
-
// The command to send to the spark.
|
|
772
|
-
string command = 2;
|
|
773
|
-
|
|
774
|
-
// The command payload.
|
|
775
|
-
string payload = 3;
|
|
776
|
-
|
|
777
|
-
// Command verifiable credential.
|
|
778
|
-
string credential = 4;
|
|
779
|
-
|
|
780
|
-
// Command signature.
|
|
781
|
-
string signature = 5;
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
// The request must contain one of the messages indicated below.
|
|
785
|
-
message SparkRequest {
|
|
786
|
-
oneof payload {
|
|
787
|
-
StartSparkResource start_resource = 1;
|
|
788
|
-
StartSparkAdhoc start_adhoc = 2;
|
|
789
|
-
SparkCommand command = 3;
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
|
|
793
|
-
// Receive events and payload from a running spark.
|
|
794
|
-
message SparkData {
|
|
795
|
-
// The command id to which this data corresponds.
|
|
796
|
-
string command_id = 1;
|
|
797
|
-
|
|
798
|
-
oneof payload {
|
|
799
|
-
// Acknowledges receipt of a spark command.
|
|
800
|
-
bool acknowledge = 2;
|
|
801
|
-
|
|
802
|
-
// Indicates the command has completed.
|
|
803
|
-
bool ended = 3;
|
|
804
|
-
|
|
805
|
-
// Will contain error details on command failure.
|
|
806
|
-
string error = 4;
|
|
807
|
-
|
|
808
|
-
// Data emitted by a command, usually in stringified JSON format.
|
|
809
|
-
string data = 5;
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
// Details of a spark instance.
|
|
814
|
-
message SparkInstance {
|
|
815
|
-
// The UUID assigned to the spark instance.
|
|
816
|
-
string spark_id = 1;
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
// The response will contain one of the messages indicated below.
|
|
820
|
-
message SparkResponse {
|
|
821
|
-
oneof payload {
|
|
822
|
-
// Details of any error that occurred on the call.
|
|
823
|
-
tdx.volt_api.volt.v1.Status status = 1;
|
|
824
|
-
|
|
825
|
-
// Details of the spark instance, sent in response to a start command.
|
|
826
|
-
SparkInstance spark_instance = 2;
|
|
827
|
-
|
|
828
|
-
// Payload data emitted by the spark.
|
|
829
|
-
SparkData spark_data = 3;
|
|
830
|
-
}
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
message GetSparkRequest {
|
|
834
|
-
string spark_id = 1;
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
// One of the following fields will be present in the response.
|
|
838
|
-
message GetSparkResponse {
|
|
839
|
-
// Details of any error that occurred on the call.
|
|
840
|
-
tdx.volt_api.volt.v1.Status status = 1;
|
|
841
|
-
}
|
|
842
|
-
|
|
843
721
|
`;
|
|
844
722
|
export const ssi = `syntax = "proto3";
|
|
845
723
|
|
|
@@ -915,12 +793,11 @@ export const ssi_api = `syntax = "proto3";
|
|
|
915
793
|
|
|
916
794
|
package tdx.volt_api.volt.v1;
|
|
917
795
|
|
|
918
|
-
import "tdx/volt_api/volt/v1/status.proto";
|
|
919
796
|
import "tdx/volt_api/volt/v1/ssi.proto";
|
|
797
|
+
import "tdx/volt_api/volt/v1/status.proto";
|
|
920
798
|
|
|
921
799
|
service SsiAPI {
|
|
922
|
-
|
|
923
|
-
rpc CreateExchangeToken(CreateExchangeTokenRequest) returns (CreateExchangeTokenResponse);
|
|
800
|
+
rpc CacheEmailCredential(CacheEmailCredentialRequest) returns (CacheEmailCredentialResponse);
|
|
924
801
|
|
|
925
802
|
// Delete a DID document or all DID documents originating from a given Volt.
|
|
926
803
|
// Requires \`volt:delete-did\` API privilege.
|
|
@@ -951,20 +828,25 @@ service SsiAPI {
|
|
|
951
828
|
rpc SearchDIDRegistry(SearchDIDRegistryRequest) returns (SearchDIDRegistryResponse);
|
|
952
829
|
}
|
|
953
830
|
|
|
954
|
-
message
|
|
955
|
-
|
|
956
|
-
|
|
831
|
+
message CacheEmailCredentialRequest {
|
|
832
|
+
string identity_did = 1;
|
|
833
|
+
|
|
834
|
+
string email_address = 2;
|
|
835
|
+
|
|
836
|
+
string identity_provider = 3;
|
|
837
|
+
|
|
838
|
+
string key_passphrase = 4;
|
|
957
839
|
|
|
958
840
|
// The time to live for the token, in seconds.
|
|
959
|
-
uint32 ttl =
|
|
841
|
+
uint32 ttl = 5;
|
|
960
842
|
}
|
|
961
843
|
|
|
962
|
-
message
|
|
844
|
+
message CacheEmailCredentialResponse {
|
|
963
845
|
// Details of any error that occurred on the call.
|
|
964
846
|
tdx.volt_api.volt.v1.Status status = 1;
|
|
965
847
|
|
|
966
|
-
// The
|
|
967
|
-
string
|
|
848
|
+
// The verifiable credential resource id.
|
|
849
|
+
string vc_id = 2;
|
|
968
850
|
}
|
|
969
851
|
|
|
970
852
|
message DeleteDIDRequest {
|
|
@@ -2166,7 +2048,7 @@ message AuthenticateRequest {
|
|
|
2166
2048
|
// A human-readable name of the entity requesting to authenticate.
|
|
2167
2049
|
string client_name = 6;
|
|
2168
2050
|
|
|
2169
|
-
// Optional challenge code, hashed using SHA-256 and base64 encoded.
|
|
2051
|
+
// Optional challenge code, hashed using SHA-256 and base64 URL encoded (no padding).
|
|
2170
2052
|
string challenge = 7;
|
|
2171
2053
|
|
|
2172
2054
|
// The host name to add as a SAN to the issued certificate.
|
|
@@ -3182,4 +3064,4 @@ message SubscribeWireResponse {
|
|
|
3182
3064
|
}
|
|
3183
3065
|
|
|
3184
3066
|
`;
|
|
3185
|
-
export const voltProtos = [sqlite, sqlite_database_api, sqlite_server_api, proto_db_sync, proxy_api, relay_api, discovery_api, file, file_api, remote,
|
|
3067
|
+
export const voltProtos = [sqlite, sqlite_database_api, sqlite_server_api, proto_db_sync, proxy_api, relay_api, discovery_api, file, file_api, remote, ssi, ssi_api, status, sync_api, terminal_api, volt, volt_api, wire_api];
|