@tdxvolt/volt-client-grpc 0.16.0-beta.12 → 0.16.0-beta.13

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 CHANGED
@@ -4,10 +4,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var lodash = require('lodash');
6
6
  var ip = require('ip');
7
+ var voltClientWeb = require('@tdxvolt/volt-client-web');
7
8
  var debug = require('debug');
8
9
  var EventEmitter = require('events');
9
10
  var fs = require('fs');
10
- var voltClientWeb = require('@tdxvolt/volt-client-web');
11
11
  var path = require('path');
12
12
  var protoLoader = require('@grpc/proto-loader');
13
13
  var url = require('url');
@@ -17,8 +17,27 @@ var uuid = require('uuid');
17
17
 
18
18
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
19
19
 
20
+ function _interopNamespace(e) {
21
+ if (e && e.__esModule) return e;
22
+ var n = Object.create(null);
23
+ if (e) {
24
+ Object.keys(e).forEach(function (k) {
25
+ if (k !== 'default') {
26
+ var d = Object.getOwnPropertyDescriptor(e, k);
27
+ Object.defineProperty(n, k, d.get ? d : {
28
+ enumerable: true,
29
+ get: function () { return e[k]; }
30
+ });
31
+ }
32
+ });
33
+ }
34
+ n["default"] = e;
35
+ return Object.freeze(n);
36
+ }
37
+
20
38
  var lodash__default = /*#__PURE__*/_interopDefaultLegacy(lodash);
21
39
  var ip__default = /*#__PURE__*/_interopDefaultLegacy(ip);
40
+ var voltClientWeb__namespace = /*#__PURE__*/_interopNamespace(voltClientWeb);
22
41
  var debug__default = /*#__PURE__*/_interopDefaultLegacy(debug);
23
42
  var EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter);
24
43
  var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
@@ -152,7 +171,8 @@ var utils = /*#__PURE__*/Object.freeze({
152
171
  __proto__: null,
153
172
  createSecureContextOptions: createSecureContextOptions,
154
173
  getServiceAddress: getServiceAddress,
155
- getDIDResolutionURL: getDIDResolutionURL
174
+ getDIDResolutionURL: getDIDResolutionURL,
175
+ crypto: voltClientWeb__namespace
156
176
  });
157
177
 
158
178
  /* eslint-disable no-underscore-dangle */
@@ -428,7 +448,7 @@ class VoltCredential {
428
448
  throw new Error("failed to decrypt key - check passphrase");
429
449
  }
430
450
 
431
- this._cryptoCache.key = voltClientWeb.privateKeyToPem(decrypted);
451
+ this._cryptoCache.key = voltClientWeb.privateKeyToPem(decrypted.privateKey);
432
452
  }
433
453
 
434
454
  if (this._voltConfig.ca_pem) {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.16.0-beta.12",
6
+ "version": "0.16.0-beta.13",
7
7
  "description": "tdx Volt library for nodejs clients",
8
8
  "type": "module",
9
9
  "exports": {
@@ -273,6 +273,9 @@ message VoltParameters {
273
273
 
274
274
  // If set, enables the terminal API.
275
275
  bool enable_terminal = 49;
276
+
277
+ // The time at which the Volt was started.
278
+ uint64 start_time = 50;
276
279
  }
277
280
 
278
281
  message VoltEndpoint {
@@ -548,37 +551,34 @@ message Access {
548
551
  string identity_did = 6;
549
552
 
550
553
  // The JSON path array for looking up verifiable credentials.
551
- string credential_lookup = 9;
554
+ string credential_lookup = 7;
552
555
  }
553
556
 
554
557
  // A human-readable short identifier of the subject.
555
- string identity_name = 7;
558
+ string identity_name = 8;
556
559
 
557
560
  // The kind of identity.
558
- repeated string identity_kind = 8;
559
-
560
- string issuer_id = 10;
561
-
562
- string issuer_name = 11;
563
-
564
- repeated string issuer_kind = 12;
561
+ repeated string identity_kind = 9;
565
562
 
566
563
  // Requested access.
567
- string access = 13;
564
+ string access = 10;
565
+
566
+ // Optional extra data.
567
+ string extra = 11;
568
568
 
569
569
  // Assigned decision.
570
- PolicyDecision decision = 14;
570
+ PolicyDecision decision = 12;
571
571
 
572
- bool recursive = 15;
572
+ bool recursive = 13;
573
573
 
574
574
  // Time at which the request was made.
575
- int64 request_time = 16;
575
+ int64 request_time = 14;
576
576
 
577
577
  // Time at which the decision was taken.
578
- int64 decision_time = 17;
578
+ int64 decision_time = 15;
579
579
 
580
580
  // Counter of number times this access was requested.
581
- uint32 request_count = 18;
581
+ uint32 request_count = 16;
582
582
  }
583
583
 
584
584
  enum SessionStatus {
@@ -37,9 +37,6 @@ service VoltAPI {
37
37
  // n.b. Copy resources between Volts is not supported by this API. This is achieved by creating an API instance for the source and target Volts, getting the resource from the source and creating it on the target.
38
38
  rpc CopyResource(CopyResourceRequest) returns (CopyResourceResponse);
39
39
 
40
- // This is a work in progress - do not use.
41
- rpc CreateVerifiableCredentialSession(CreateVerifiableCredentialSessionRequest) returns (CreateVerifiableCredentialSessionResponse);
42
-
43
40
  // Remove a custom access rule, such as a file share.
44
41
  rpc DeleteAccess(DeleteAccessRequest) returns (DeleteAccessResponse);
45
42
 
@@ -63,9 +60,8 @@ service VoltAPI {
63
60
  // The identity will only be retrieved if the authenticated identity has read access to it.
64
61
  rpc GetIdentity(GetIdentityRequest) returns (GetIdentityResponse);
65
62
 
66
- // NOT YET IMPLEMENTED.
67
- // Gets a credential for the currently authenticated client, signed by the volt CA.
68
- rpc GetIdentityToken(GetIdentityTokenRequest) returns (GetIdentityTokenResponse);
63
+ // Gets a one-time token that can be used as a temporary authentication token, for example create an file download link that expires after a certain time.
64
+ rpc GetOneTimeToken(GetOneTimeTokenRequest) returns (GetOneTimeTokenResponse);
69
65
 
70
66
  // Retrieve the Volt parameters.
71
67
  // This is a privileged API call and requires Volt root access.
@@ -104,9 +100,18 @@ service VoltAPI {
104
100
  // Create or update an access rule.
105
101
  rpc SaveAccess(SaveAccessRequest) returns (SaveAccessResponse);
106
102
 
103
+ // Create or update a static file HTTP server.
104
+ rpc SaveHttpFileServer(SaveResourceRequest) returns (SaveResourceResponse);
105
+
106
+ // Create or update an HTTP REST API server.
107
+ rpc SaveHttpApiServer(SaveResourceRequest) returns (SaveResourceResponse);
108
+
107
109
  // Create or update an identity.
108
110
  rpc SaveIdentity(SaveIdentityRequest) returns (SaveIdentityResponse);
109
111
 
112
+ // Create or update a mirrored link resource.
113
+ rpc SaveMirroredLink(SaveResourceRequest) returns (SaveResourceResponse);
114
+
110
115
  // Update Volt parameters.
111
116
  // This is a privileged call that requires Volt root access.
112
117
  rpc SaveParameters(SaveParametersRequest) returns (SaveParametersResponse);
@@ -114,6 +119,9 @@ service VoltAPI {
114
119
  // Create or update resource in this volt.
115
120
  rpc SaveResource(SaveResourceRequest) returns (SaveResourceResponse);
116
121
 
122
+ // Create or update a symbolic link resource.
123
+ rpc SaveSymbolicLink(SaveResourceRequest) returns (SaveResourceResponse);
124
+
117
125
  // Save a session.
118
126
  rpc SaveSession(SaveSessionRequest) returns (SaveSessionResponse);
119
127
 
@@ -231,9 +239,6 @@ message CanAccessResourceResponse {
231
239
  // The identity subject that the access relates to.
232
240
  string identity_did = 2;
233
241
 
234
- // Optional identity that issued the access.
235
- string issuer_id = 3;
236
-
237
242
  // The resource the access relates to.
238
243
  string resource_id = 4;
239
244
 
@@ -259,46 +264,48 @@ message CheckCompatibilityResponse {
259
264
 
260
265
  // All fields in this message are optional, send an empty message if necessary.
261
266
  message ConnectHello {
262
- // Optionally specify the calling address of the peer.
263
- // Not currently in use.
267
+ // Optionally specify the grpc server address of the client. Only used if the client is a Volt (or service).
264
268
  string address = 1;
265
269
 
266
270
  // Set to automatically make **all** services owned by the calling identity online.
267
- bool online_services = 2;
271
+ bool online_services = 3;
268
272
 
269
273
  // Set to receive notification of resource events.
270
- bool subscribe_resource_events = 3;
274
+ bool subscribe_resource_events = 4;
271
275
 
272
276
  // Set this if you are connecting to a relay, i.e. the Volt you are sending to this message is a relay.
273
277
  // This indicates that you are happy to receive method invocations from clients of the Relay.
274
278
  // This will usually be set to the `id` of your Volt, but in theory any client could receive remote invocation requests in this way.
275
- string relay_id = 4;
279
+ string relay_id = 5;
276
280
 
277
281
  // A friendly name to present to Relay clients.
278
- string relay_name = 5;
282
+ string relay_name = 6;
279
283
 
280
- string relay_description = 6;
284
+ string relay_description = 7;
281
285
 
282
286
  // The certificate authority to present to Relay clients.
283
- string relay_ca_pem = 7;
287
+ string relay_ca_pem = 8;
284
288
 
285
289
  // Set to indicate the connection is discoverable to other Relay clients.
286
- bool relay_discoverable = 8;
290
+ bool relay_discoverable = 9;
291
+
292
+ // Optionally specify the address of the HTTP server to use for HTTP proxying. If set, a relay will forward HTTP requests to this address from the subdomain that matches the client's DID.
293
+ string relay_http_address = 10;
287
294
 
288
295
  // Set to receive notification of authentication requests.
289
- bool subscribe_auth_requests = 9;
296
+ bool subscribe_auth_requests = 11;
290
297
 
291
298
  // Set to indicate the connection will accept method invocation requests.
292
- bool accept_invocation = 10;
299
+ bool accept_invocation = 12;
293
300
 
294
301
  // Set to subscribe to DID registry updates from the peer.
295
- bool subscribe_did_registry_updates = 11;
302
+ bool subscribe_did_registry_updates = 13;
296
303
 
297
304
  // The interval at which the client will send ping requests to the target.
298
- uint32 ping_interval = 12;
305
+ uint32 ping_interval = 14;
299
306
 
300
307
  // The current time on the client.
301
- uint64 timestamp = 13;
308
+ uint64 timestamp = 15;
302
309
  }
303
310
 
304
311
  message ConnectAcknowledge {
@@ -452,15 +459,6 @@ message CopyResourceResponse {
452
459
  tdx.volt_api.volt.v1.Status status = 1;
453
460
  }
454
461
 
455
- message CreateVerifiableCredentialSessionRequest {
456
- string presentation = 1;
457
- }
458
-
459
- message CreateVerifiableCredentialSessionResponse {
460
- tdx.volt_api.volt.v1.Status status = 1;
461
- string session_id = 2;
462
- }
463
-
464
462
  message DeleteAccessRequest {
465
463
  // The id of the access rule to delete.
466
464
  string id = 1;
@@ -521,9 +519,6 @@ message GetAccessRequest {
521
519
  // The identity id that is the subject of the access rule. If omitted, all identities will be considered.
522
520
  string identity_did = 2;
523
521
 
524
- // The issuer of the access rule. If omitted, all issuers will be considered.
525
- string issuer_id = 3;
526
-
527
522
  // The type of access to retrieve, if omitted all access will be considered.
528
523
  string access = 4;
529
524
 
@@ -575,17 +570,16 @@ message GetIdentityResponse {
575
570
  Identity identity = 2;
576
571
  }
577
572
 
578
- message GetIdentityTokenRequest {
579
- // The token TTL, in seconds.
573
+ message GetOneTimeTokenRequest {
574
+ // Optional token TTL, in seconds. Default is 10 seconds.
580
575
  int32 ttl = 1;
581
-
582
- // The intended token audience - usually the common name of the target volt
583
- // CA.
584
- string audience = 2;
585
576
  }
586
577
 
587
- message GetIdentityTokenResponse {
578
+ message GetOneTimeTokenResponse {
579
+ // Details of any error that occurred on the call.
588
580
  tdx.volt_api.volt.v1.Status status = 1;
581
+
582
+ // The one-time token.
589
583
  string token = 2;
590
584
  }
591
585
 
@@ -878,9 +872,6 @@ message RequestAccessResponse {
878
872
  // The identity attempting access.
879
873
  string identity_did = 3;
880
874
 
881
- // The identity of the issuer of the access.
882
- string issuer_id = 4;
883
-
884
875
  // Requested access.
885
876
  string access = 5;
886
877
 
package/src/utils.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import ip from "ip";
2
2
  import _ from "lodash";
3
+ export * as crypto from "@tdxvolt/volt-client-web";
3
4
 
4
5
  import { constants } from "./constants.js";
5
6
 
@@ -41,7 +41,7 @@ export class VoltCredential {
41
41
  throw new Error("failed to decrypt key - check passphrase");
42
42
  }
43
43
 
44
- this._cryptoCache.key = privateKeyToPem(decrypted);
44
+ this._cryptoCache.key = privateKeyToPem(decrypted.privateKey);
45
45
  }
46
46
 
47
47
  if (this._voltConfig.ca_pem) {