@tdxvolt/volt-client-grpc 0.19.10 → 0.20.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.
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 {
@@ -3400,6 +3427,7 @@ message ResourceAttributeQuery {
3400
3427
  AttributeValue value = 3;
3401
3428
  }
3402
3429
 
3430
+ // Specify one of \`access\` or \`access_list\`.
3403
3431
  message SaveAccessRequest {
3404
3432
  // Omit \`id\` if creating new access.
3405
3433
  Access access = 1;
@@ -4859,10 +4887,7 @@ function findDIDDocumentService(document, serviceType) {
4859
4887
  return matches;
4860
4888
  }
4861
4889
 
4862
- async function authenticateInternal(
4863
- sessionOnly = false,
4864
- ownDID = false
4865
- ) {
4890
+ async function authenticateInternal(noDID = false, ownDID = false) {
4866
4891
  try {
4867
4892
  if (!this._credential.cache.ca) {
4868
4893
  this._credential.cache.ca = this._voltConfig.ca_pem;
@@ -4894,17 +4919,14 @@ async function authenticateInternal(
4894
4919
  };
4895
4920
 
4896
4921
  if (this._credential.cache.challenge_code) {
4897
- authenticateRequest.challenge = signBase64(
4898
- this._credential.cache.key,
4899
- this._credential.cache.challenge_code
4900
- );
4922
+ authenticateRequest.challenge = this._credential.cache.challenge_code;
4901
4923
  } else {
4902
4924
  log$2(
4903
- "****no Volt challenge code available**** => not sending challenge signature"
4925
+ "****challenge code NOT available**** => not sending challenge signature"
4904
4926
  );
4905
4927
  }
4906
4928
 
4907
- if (sessionOnly) {
4929
+ if (noDID) {
4908
4930
  // We want to create a session-based authentication based simply on our key, rather than a
4909
4931
  // fully-blown DID-based authentication.
4910
4932
  log$2("creating session-only request");
@@ -5563,7 +5585,8 @@ class VoltCredential {
5563
5585
  }
5564
5586
 
5565
5587
  saveCache() {
5566
- const clone = { ...this._config, credential: { ...this._cryptoCache } };
5588
+ this._config = {...this._config, credential: { ...this._cryptoCache } };
5589
+ const clone = { ...this._config };
5567
5590
  if (this._config.p) {
5568
5591
  // A passphrase option exists => encrypt the key before writing the cache file.
5569
5592
  const key = keyFromPem(this._cryptoCache.key);
@@ -5647,9 +5670,11 @@ class VoltClient extends EventEmitter__default["default"] {
5647
5670
  * configuration from the config file.
5648
5671
  * @param {boolean} [options.ownDID] - whether the Volt should manage the DID - set to
5649
5672
  * true if you want to manage the DID yourself
5673
+ * @param {boolean} [options.noDID] - whether to create a key-based authentication session
5674
+ * instead of a DID-based authentication session.
5650
5675
  */
5651
5676
  async initialise(config, options = {}) {
5652
- const { ownDID, didRegistryList, extraConfig } = options;
5677
+ const { ownDID, noDID, didRegistryList, extraConfig } = options;
5653
5678
  try {
5654
5679
  if (!config) {
5655
5680
  throw new Error(
@@ -5735,7 +5760,7 @@ class VoltClient extends EventEmitter__default["default"] {
5735
5760
  } else {
5736
5761
  // No certificate present in the cache yet => we need to authenticate.
5737
5762
  try {
5738
- isBound = await authenticateInternal.call(this, false, ownDID);
5763
+ isBound = await authenticateInternal.call(this, noDID, ownDID);
5739
5764
  } catch (bindErr) {
5740
5765
  if (bindErr.message === "invalid arguments") {
5741
5766
  // 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.1",
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
+ }
@@ -100,10 +100,7 @@ function findDIDDocumentService(document, serviceType) {
100
100
  return matches;
101
101
  }
102
102
 
103
- export async function authenticateInternal(
104
- sessionOnly = false,
105
- ownDID = false
106
- ) {
103
+ export async function authenticateInternal(noDID = false, ownDID = false) {
107
104
  try {
108
105
  if (!this._credential.cache.ca) {
109
106
  this._credential.cache.ca = this._voltConfig.ca_pem;
@@ -135,17 +132,14 @@ export async function authenticateInternal(
135
132
  };
136
133
 
137
134
  if (this._credential.cache.challenge_code) {
138
- authenticateRequest.challenge = signBase64(
139
- this._credential.cache.key,
140
- this._credential.cache.challenge_code
141
- );
135
+ authenticateRequest.challenge = this._credential.cache.challenge_code;
142
136
  } else {
143
137
  log(
144
- "****no Volt challenge code available**** => not sending challenge signature"
138
+ "****challenge code NOT available**** => not sending challenge signature"
145
139
  );
146
140
  }
147
141
 
148
- if (sessionOnly) {
142
+ if (noDID) {
149
143
  // We want to create a session-based authentication based simply on our key, rather than a
150
144
  // fully-blown DID-based authentication.
151
145
  log("creating session-only request");
@@ -82,9 +82,11 @@ 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.
85
87
  */
86
88
  async initialise(config, options = {}) {
87
- const { ownDID, didRegistryList, extraConfig } = options;
89
+ const { ownDID, noDID, didRegistryList, extraConfig } = options;
88
90
  try {
89
91
  if (!config) {
90
92
  throw new Error(
@@ -170,7 +172,7 @@ export class VoltClient extends EventEmitter {
170
172
  } else {
171
173
  // No certificate present in the cache yet => we need to authenticate.
172
174
  try {
173
- isBound = await authenticateInternal.call(this, false, ownDID);
175
+ isBound = await authenticateInternal.call(this, noDID, ownDID);
174
176
  } catch (bindErr) {
175
177
  if (bindErr.message === "invalid arguments") {
176
178
  // 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 {
@@ -2855,6 +2882,7 @@ message ResourceAttributeQuery {
2855
2882
  AttributeValue value = 3;
2856
2883
  }
2857
2884
 
2885
+ // Specify one of \`access\` or \`access_list\`.
2858
2886
  message SaveAccessRequest {
2859
2887
  // Omit \`id\` if creating new access.
2860
2888
  Access access = 1;