@tdxvolt/volt-client-grpc 0.19.10 → 0.20.2

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
@@ -1158,6 +1158,9 @@ message UploadFileResponse {
1158
1158
 
1159
1159
  // Reserved for internal use.
1160
1160
  bool back_off = 2;
1161
+
1162
+ // Indicates the number of blocks that have been received.
1163
+ uint32 ack = 3;
1161
1164
  }
1162
1165
 
1163
1166
  `;
@@ -1452,6 +1455,9 @@ import "tdx/volt_api/volt/v1/status.proto";
1452
1455
  import "tdx/volt_api/volt/v1/ssi.proto";
1453
1456
 
1454
1457
  service SsiAPI {
1458
+ // Get a short-lived, one-time token that can be used to authenticate with the Volt and potentially create verifiable credential(s).
1459
+ rpc CreateExchangeToken(CreateExchangeTokenRequest) returns (CreateExchangeTokenResponse);
1460
+
1455
1461
  // Delete a DID document or all DID documents originating from a given Volt.
1456
1462
  // Requires \`volt:delete-did\` API privilege.
1457
1463
  rpc DeleteDID(DeleteDIDRequest) returns (DeleteDIDResponse);
@@ -1481,6 +1487,22 @@ service SsiAPI {
1481
1487
  rpc SearchDIDRegistry(SearchDIDRegistryRequest) returns (SearchDIDRegistryResponse);
1482
1488
  }
1483
1489
 
1490
+ message CreateExchangeTokenRequest {
1491
+ // The VC template to use to create a verifiable credential.
1492
+ string vc_template = 1;
1493
+
1494
+ // The time to live for the token, in seconds.
1495
+ uint32 ttl = 2;
1496
+ }
1497
+
1498
+ message CreateExchangeTokenResponse {
1499
+ // Details of any error that occurred on the call.
1500
+ tdx.volt_api.volt.v1.Status status = 1;
1501
+
1502
+ // The one-time token.
1503
+ string token = 2;
1504
+ }
1505
+
1484
1506
  message DeleteDIDRequest {
1485
1507
  // Specify an individual DID as the target of the delete operation, or a Volt to delete all DIDs owned by that Volt.
1486
1508
  oneof target {
@@ -1997,10 +2019,10 @@ message VoltParameters {
1997
2019
  // Indicates the Volt will be discoverable by clients using the discovery api.
1998
2020
  bool discoverable = 16;
1999
2021
 
2000
- // Optional challenge code that can be used aid in the process of authenticating clients.
2022
+ // DEPRECATED: Optional challenge code that can be used aid in the process of authenticating clients.
2001
2023
  string authenticate_challenge = 18;
2002
2024
 
2003
- // Indicates that clients must present the correct challenge code in order to be able to authenticate.
2025
+ // DEPRECATED: Indicates that clients must present the correct challenge code in order to be able to authenticate.
2004
2026
  bool require_authenticate_challenge = 19;
2005
2027
 
2006
2028
  // Internal use only.
@@ -2103,6 +2125,9 @@ message VoltParameters {
2103
2125
 
2104
2126
  // The time at which the Volt was started.
2105
2127
  uint64 start_time = 50;
2128
+
2129
+ // If set, enables the agent event pool.
2130
+ bool enable_agent_event_pool = 51;
2106
2131
  }
2107
2132
 
2108
2133
  message VoltEndpoint {
@@ -2554,7 +2579,7 @@ service VoltAPI {
2554
2579
  // The identity will only be retrieved if the authenticated identity has read access to it.
2555
2580
  rpc GetIdentity(GetIdentityRequest) returns (GetIdentityResponse);
2556
2581
 
2557
- // 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.
2582
+ // Gets a one-time token that can be used as a temporary authentication token, for example to create a file download link that expires after a certain time.
2558
2583
  rpc GetOneTimeToken(GetOneTimeTokenRequest) returns (GetOneTimeTokenResponse);
2559
2584
 
2560
2585
  // Retrieve the Volt parameters.
@@ -2664,8 +2689,7 @@ message AuthenticateRequest {
2664
2689
  // A human-readable name of the entity requesting to authenticate.
2665
2690
  string client_name = 6;
2666
2691
 
2667
- // The volt challenge code, signed by the private key component of the \`public_key\` field above, and base64 encoded.
2668
- // This is optional.
2692
+ // Optional challenge code, hashed using SHA-256 and base64 encoded.
2669
2693
  string challenge = 7;
2670
2694
 
2671
2695
  // The host name to add as a SAN to the issued certificate.
@@ -2680,6 +2704,9 @@ message AuthenticateRequest {
2680
2704
 
2681
2705
  // Optional additional name to differentiate between multiple sessions for a given client.
2682
2706
  string session_name = 11;
2707
+
2708
+ // Optional one-time token to exchange for a session.
2709
+ string exchange_token = 12;
2683
2710
  }
2684
2711
 
2685
2712
  message AuthenticateResponse {
@@ -2708,6 +2735,9 @@ message AuthenticateResponse {
2708
2735
 
2709
2736
  // Reserved for internal use.
2710
2737
  int64 decision_time = 8;
2738
+
2739
+ // Any credentials issued to the client as part of the authentication process.
2740
+ repeated string credential = 9;
2711
2741
  }
2712
2742
 
2713
2743
  message CanAccessResourceRequest {
@@ -3400,6 +3430,7 @@ message ResourceAttributeQuery {
3400
3430
  AttributeValue value = 3;
3401
3431
  }
3402
3432
 
3433
+ // Specify one of \`access\` or \`access_list\`.
3403
3434
  message SaveAccessRequest {
3404
3435
  // Omit \`id\` if creating new access.
3405
3436
  Access access = 1;
@@ -4811,6 +4842,11 @@ function issueAuthenticate(authenticateRequest, ttl) {
4811
4842
  authenticateResponse.identity_did;
4812
4843
  }
4813
4844
 
4845
+ this._credential.cache.vc = this._credential.cache.vc || [];
4846
+ for (const credential of authenticateResponse.credential) {
4847
+ this._credential.cache.vc.push(credential);
4848
+ }
4849
+
4814
4850
  this._credential.saveCache();
4815
4851
  break;
4816
4852
  }
@@ -4859,10 +4895,7 @@ function findDIDDocumentService(document, serviceType) {
4859
4895
  return matches;
4860
4896
  }
4861
4897
 
4862
- async function authenticateInternal(
4863
- sessionOnly = false,
4864
- ownDID = false
4865
- ) {
4898
+ async function authenticateInternal(noDID = false, ownDID = false, exchangeToken = "") {
4866
4899
  try {
4867
4900
  if (!this._credential.cache.ca) {
4868
4901
  this._credential.cache.ca = this._voltConfig.ca_pem;
@@ -4893,18 +4926,23 @@ async function authenticateInternal(
4893
4926
  host: this._credential.cache.bindIp
4894
4927
  };
4895
4928
 
4929
+ if (exchangeToken) {
4930
+ log$2("setting request exchange token");
4931
+ authenticateRequest.exchange_token = exchangeToken;
4932
+ } else {
4933
+ log$2("no exchange token in request");
4934
+ }
4935
+
4896
4936
  if (this._credential.cache.challenge_code) {
4897
- authenticateRequest.challenge = signBase64(
4898
- this._credential.cache.key,
4899
- this._credential.cache.challenge_code
4900
- );
4937
+ log$2("setting request challenge code");
4938
+ authenticateRequest.challenge = this._credential.cache.challenge_code;
4901
4939
  } else {
4902
4940
  log$2(
4903
- "****no Volt challenge code available**** => not sending challenge signature"
4941
+ "no challenge code in request"
4904
4942
  );
4905
4943
  }
4906
4944
 
4907
- if (sessionOnly) {
4945
+ if (noDID) {
4908
4946
  // We want to create a session-based authentication based simply on our key, rather than a
4909
4947
  // fully-blown DID-based authentication.
4910
4948
  log$2("creating session-only request");
@@ -5563,7 +5601,8 @@ class VoltCredential {
5563
5601
  }
5564
5602
 
5565
5603
  saveCache() {
5566
- const clone = { ...this._config, credential: { ...this._cryptoCache } };
5604
+ this._config = {...this._config, credential: { ...this._cryptoCache } };
5605
+ const clone = { ...this._config };
5567
5606
  if (this._config.p) {
5568
5607
  // A passphrase option exists => encrypt the key before writing the cache file.
5569
5608
  const key = keyFromPem(this._cryptoCache.key);
@@ -5647,9 +5686,12 @@ class VoltClient extends EventEmitter__default["default"] {
5647
5686
  * configuration from the config file.
5648
5687
  * @param {boolean} [options.ownDID] - whether the Volt should manage the DID - set to
5649
5688
  * true if you want to manage the DID yourself
5689
+ * @param {boolean} [options.noDID] - whether to create a key-based authentication session
5690
+ * instead of a DID-based authentication session.
5691
+ * @param {string} [options.exchangeToken] - optional token to exchange in return for an authenticated session.
5650
5692
  */
5651
5693
  async initialise(config, options = {}) {
5652
- const { ownDID, didRegistryList, extraConfig } = options;
5694
+ const { ownDID, noDID, didRegistryList, extraConfig } = options;
5653
5695
  try {
5654
5696
  if (!config) {
5655
5697
  throw new Error(
@@ -5735,7 +5777,7 @@ class VoltClient extends EventEmitter__default["default"] {
5735
5777
  } else {
5736
5778
  // No certificate present in the cache yet => we need to authenticate.
5737
5779
  try {
5738
- isBound = await authenticateInternal.call(this, false, ownDID);
5780
+ isBound = await authenticateInternal.call(this, noDID, ownDID, exchangeToken);
5739
5781
  } catch (bindErr) {
5740
5782
  if (bindErr.message === "invalid arguments") {
5741
5783
  // This is usually the result of a missing challenge signature or credential.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.19.10",
6
+ "version": "0.20.2",
7
7
  "description": "tdx Volt library for nodejs clients",
8
8
  "type": "module",
9
9
  "exports": {
@@ -33,7 +33,7 @@
33
33
  "author": "toby.ealden@gmail.com",
34
34
  "license": "ISC",
35
35
  "dependencies": {
36
- "@tdxvolt/volt-client-web": "^0.19.9",
36
+ "@tdxvolt/volt-client-web": "^0.20.4",
37
37
  "debug": "^4.1.1",
38
38
  "ip": "^1.1.5",
39
39
  "jsonwebtoken": "^8.5.1",
@@ -42,4 +42,4 @@
42
42
  "protobufjs": "^7.4.0",
43
43
  "uuid": "^8.1.0"
44
44
  }
45
- }
45
+ }
@@ -52,6 +52,11 @@ function issueAuthenticate(authenticateRequest, ttl) {
52
52
  authenticateResponse.identity_did;
53
53
  }
54
54
 
55
+ this._credential.cache.vc = this._credential.cache.vc || [];
56
+ for (const credential of authenticateResponse.credential) {
57
+ this._credential.cache.vc.push(credential);
58
+ }
59
+
55
60
  this._credential.saveCache();
56
61
  break;
57
62
  }
@@ -100,10 +105,7 @@ function findDIDDocumentService(document, serviceType) {
100
105
  return matches;
101
106
  }
102
107
 
103
- export async function authenticateInternal(
104
- sessionOnly = false,
105
- ownDID = false
106
- ) {
108
+ export async function authenticateInternal(noDID = false, ownDID = false, exchangeToken = "") {
107
109
  try {
108
110
  if (!this._credential.cache.ca) {
109
111
  this._credential.cache.ca = this._voltConfig.ca_pem;
@@ -134,18 +136,23 @@ export async function authenticateInternal(
134
136
  host: this._credential.cache.bindIp
135
137
  };
136
138
 
139
+ if (exchangeToken) {
140
+ log("setting request exchange token");
141
+ authenticateRequest.exchange_token = exchangeToken;
142
+ } else {
143
+ log("no exchange token in request");
144
+ }
145
+
137
146
  if (this._credential.cache.challenge_code) {
138
- authenticateRequest.challenge = signBase64(
139
- this._credential.cache.key,
140
- this._credential.cache.challenge_code
141
- );
147
+ log("setting request challenge code");
148
+ authenticateRequest.challenge = this._credential.cache.challenge_code;
142
149
  } else {
143
150
  log(
144
- "****no Volt challenge code available**** => not sending challenge signature"
151
+ "no challenge code in request"
145
152
  );
146
153
  }
147
154
 
148
- if (sessionOnly) {
155
+ if (noDID) {
149
156
  // We want to create a session-based authentication based simply on our key, rather than a
150
157
  // fully-blown DID-based authentication.
151
158
  log("creating session-only request");
@@ -82,9 +82,12 @@ export class VoltClient extends EventEmitter {
82
82
  * configuration from the config file.
83
83
  * @param {boolean} [options.ownDID] - whether the Volt should manage the DID - set to
84
84
  * true if you want to manage the DID yourself
85
+ * @param {boolean} [options.noDID] - whether to create a key-based authentication session
86
+ * instead of a DID-based authentication session.
87
+ * @param {string} [options.exchangeToken] - optional token to exchange in return for an authenticated session.
85
88
  */
86
89
  async initialise(config, options = {}) {
87
- const { ownDID, didRegistryList, extraConfig } = options;
90
+ const { ownDID, noDID, didRegistryList, extraConfig } = options;
88
91
  try {
89
92
  if (!config) {
90
93
  throw new Error(
@@ -170,7 +173,7 @@ export class VoltClient extends EventEmitter {
170
173
  } else {
171
174
  // No certificate present in the cache yet => we need to authenticate.
172
175
  try {
173
- isBound = await authenticateInternal.call(this, false, ownDID);
176
+ isBound = await authenticateInternal.call(this, noDID, ownDID, exchangeToken);
174
177
  } catch (bindErr) {
175
178
  if (bindErr.message === "invalid arguments") {
176
179
  // This is usually the result of a missing challenge signature or credential.
@@ -170,7 +170,8 @@ export class VoltCredential {
170
170
  }
171
171
 
172
172
  saveCache() {
173
- const clone = { ...this._config, credential: { ...this._cryptoCache } };
173
+ this._config = {...this._config, credential: { ...this._cryptoCache } };
174
+ const clone = { ...this._config };
174
175
  if (this._config.p) {
175
176
  // A passphrase option exists => encrypt the key before writing the cache file.
176
177
  const key = keyFromPem(this._cryptoCache.key);
@@ -613,6 +613,9 @@ message UploadFileResponse {
613
613
 
614
614
  // Reserved for internal use.
615
615
  bool back_off = 2;
616
+
617
+ // Indicates the number of blocks that have been received.
618
+ uint32 ack = 3;
616
619
  }
617
620
 
618
621
  `;
@@ -907,6 +910,9 @@ import "tdx/volt_api/volt/v1/status.proto";
907
910
  import "tdx/volt_api/volt/v1/ssi.proto";
908
911
 
909
912
  service SsiAPI {
913
+ // Get a short-lived, one-time token that can be used to authenticate with the Volt and potentially create verifiable credential(s).
914
+ rpc CreateExchangeToken(CreateExchangeTokenRequest) returns (CreateExchangeTokenResponse);
915
+
910
916
  // Delete a DID document or all DID documents originating from a given Volt.
911
917
  // Requires \`volt:delete-did\` API privilege.
912
918
  rpc DeleteDID(DeleteDIDRequest) returns (DeleteDIDResponse);
@@ -936,6 +942,22 @@ service SsiAPI {
936
942
  rpc SearchDIDRegistry(SearchDIDRegistryRequest) returns (SearchDIDRegistryResponse);
937
943
  }
938
944
 
945
+ message CreateExchangeTokenRequest {
946
+ // The VC template to use to create a verifiable credential.
947
+ string vc_template = 1;
948
+
949
+ // The time to live for the token, in seconds.
950
+ uint32 ttl = 2;
951
+ }
952
+
953
+ message CreateExchangeTokenResponse {
954
+ // Details of any error that occurred on the call.
955
+ tdx.volt_api.volt.v1.Status status = 1;
956
+
957
+ // The one-time token.
958
+ string token = 2;
959
+ }
960
+
939
961
  message DeleteDIDRequest {
940
962
  // Specify an individual DID as the target of the delete operation, or a Volt to delete all DIDs owned by that Volt.
941
963
  oneof target {
@@ -1452,10 +1474,10 @@ message VoltParameters {
1452
1474
  // Indicates the Volt will be discoverable by clients using the discovery api.
1453
1475
  bool discoverable = 16;
1454
1476
 
1455
- // Optional challenge code that can be used aid in the process of authenticating clients.
1477
+ // DEPRECATED: Optional challenge code that can be used aid in the process of authenticating clients.
1456
1478
  string authenticate_challenge = 18;
1457
1479
 
1458
- // Indicates that clients must present the correct challenge code in order to be able to authenticate.
1480
+ // DEPRECATED: Indicates that clients must present the correct challenge code in order to be able to authenticate.
1459
1481
  bool require_authenticate_challenge = 19;
1460
1482
 
1461
1483
  // Internal use only.
@@ -1558,6 +1580,9 @@ message VoltParameters {
1558
1580
 
1559
1581
  // The time at which the Volt was started.
1560
1582
  uint64 start_time = 50;
1583
+
1584
+ // If set, enables the agent event pool.
1585
+ bool enable_agent_event_pool = 51;
1561
1586
  }
1562
1587
 
1563
1588
  message VoltEndpoint {
@@ -2009,7 +2034,7 @@ service VoltAPI {
2009
2034
  // The identity will only be retrieved if the authenticated identity has read access to it.
2010
2035
  rpc GetIdentity(GetIdentityRequest) returns (GetIdentityResponse);
2011
2036
 
2012
- // 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.
2037
+ // Gets a one-time token that can be used as a temporary authentication token, for example to create a file download link that expires after a certain time.
2013
2038
  rpc GetOneTimeToken(GetOneTimeTokenRequest) returns (GetOneTimeTokenResponse);
2014
2039
 
2015
2040
  // Retrieve the Volt parameters.
@@ -2119,8 +2144,7 @@ message AuthenticateRequest {
2119
2144
  // A human-readable name of the entity requesting to authenticate.
2120
2145
  string client_name = 6;
2121
2146
 
2122
- // The volt challenge code, signed by the private key component of the \`public_key\` field above, and base64 encoded.
2123
- // This is optional.
2147
+ // Optional challenge code, hashed using SHA-256 and base64 encoded.
2124
2148
  string challenge = 7;
2125
2149
 
2126
2150
  // The host name to add as a SAN to the issued certificate.
@@ -2135,6 +2159,9 @@ message AuthenticateRequest {
2135
2159
 
2136
2160
  // Optional additional name to differentiate between multiple sessions for a given client.
2137
2161
  string session_name = 11;
2162
+
2163
+ // Optional one-time token to exchange for a session.
2164
+ string exchange_token = 12;
2138
2165
  }
2139
2166
 
2140
2167
  message AuthenticateResponse {
@@ -2163,6 +2190,9 @@ message AuthenticateResponse {
2163
2190
 
2164
2191
  // Reserved for internal use.
2165
2192
  int64 decision_time = 8;
2193
+
2194
+ // Any credentials issued to the client as part of the authentication process.
2195
+ repeated string credential = 9;
2166
2196
  }
2167
2197
 
2168
2198
  message CanAccessResourceRequest {
@@ -2855,6 +2885,7 @@ message ResourceAttributeQuery {
2855
2885
  AttributeValue value = 3;
2856
2886
  }
2857
2887
 
2888
+ // Specify one of \`access\` or \`access_list\`.
2858
2889
  message SaveAccessRequest {
2859
2890
  // Omit \`id\` if creating new access.
2860
2891
  Access access = 1;