@tdxvolt/volt-client-grpc 0.20.4 → 0.20.8
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 +118 -36
- package/package.json +2 -2
- package/src/volt-client-internal.js +48 -29
- package/src/volt-client.js +28 -2
- package/src/volt-proto-literals.js +42 -5
package/lib/index.cjs
CHANGED
|
@@ -1088,8 +1088,14 @@ message GetFileDescendantsRequest {
|
|
|
1088
1088
|
// Optional - only match descendants of the given kind.
|
|
1089
1089
|
string extension = 3;
|
|
1090
1090
|
|
|
1091
|
+
// Optional - restrict to folders only.bool
|
|
1092
|
+
bool folders_only = 4;
|
|
1093
|
+
|
|
1091
1094
|
// Optional - can be used to determine if a resource is a descendant.
|
|
1092
1095
|
string descendant_id = 5;
|
|
1096
|
+
|
|
1097
|
+
// Optional - include hidden files and directories.
|
|
1098
|
+
bool include_hidden = 6;
|
|
1093
1099
|
}
|
|
1094
1100
|
|
|
1095
1101
|
message GetFileDescendantsResponse {
|
|
@@ -1420,10 +1426,13 @@ message DIDRegistryUpdate {
|
|
|
1420
1426
|
}
|
|
1421
1427
|
|
|
1422
1428
|
message VerifiablePresentation {
|
|
1423
|
-
//
|
|
1429
|
+
// DEPRECATED - use 'credential'
|
|
1424
1430
|
string credential_json = 1;
|
|
1425
1431
|
|
|
1426
|
-
//
|
|
1432
|
+
// Array of credential JSON.
|
|
1433
|
+
repeated string credential = 3;
|
|
1434
|
+
|
|
1435
|
+
// A signature of the credential JSON. The signature should be that of the credential holder over the concatenation of the contents of the \`credential\` array.
|
|
1427
1436
|
string signature = 2;
|
|
1428
1437
|
}
|
|
1429
1438
|
|
|
@@ -1587,7 +1596,7 @@ message ParseCredentialResponse {
|
|
|
1587
1596
|
tdx.volt_api.volt.v1.Status status = 1;
|
|
1588
1597
|
|
|
1589
1598
|
// The parsed credential details.
|
|
1590
|
-
VerifiableCredential verifiable_credential = 2;
|
|
1599
|
+
repeated VerifiableCredential verifiable_credential = 2;
|
|
1591
1600
|
}
|
|
1592
1601
|
|
|
1593
1602
|
message ResolveDIDRequest {
|
|
@@ -2128,6 +2137,15 @@ message VoltParameters {
|
|
|
2128
2137
|
|
|
2129
2138
|
// If set, enables the agent event pool.
|
|
2130
2139
|
bool enable_agent_event_pool = 51;
|
|
2140
|
+
|
|
2141
|
+
// Optional owner email addresses.
|
|
2142
|
+
repeated string owner_email = 52;
|
|
2143
|
+
|
|
2144
|
+
// Optional owner email identity providers.
|
|
2145
|
+
repeated string identity_provider = 53;
|
|
2146
|
+
|
|
2147
|
+
// If set, exposes a resource that gives the Volt owner read-only access the file system.
|
|
2148
|
+
bool enable_owner_file_system_access = 54;
|
|
2131
2149
|
}
|
|
2132
2150
|
|
|
2133
2151
|
message VoltEndpoint {
|
|
@@ -2492,6 +2510,9 @@ message SessionCredential {
|
|
|
2492
2510
|
|
|
2493
2511
|
// More type-specific data stored with the credential.
|
|
2494
2512
|
string extra_2 = 16;
|
|
2513
|
+
|
|
2514
|
+
// The verification status of the credential.
|
|
2515
|
+
string status = 17;
|
|
2495
2516
|
}
|
|
2496
2517
|
|
|
2497
2518
|
message Session {
|
|
@@ -2515,7 +2536,6 @@ message Session {
|
|
|
2515
2536
|
|
|
2516
2537
|
SessionStatus status = 10;
|
|
2517
2538
|
}
|
|
2518
|
-
|
|
2519
2539
|
`;
|
|
2520
2540
|
const volt_api = `syntax = "proto3";
|
|
2521
2541
|
|
|
@@ -2526,7 +2546,7 @@ import "tdx/volt_api/volt/v1/remote.proto";
|
|
|
2526
2546
|
import "tdx/volt_api/volt/v1/ssi.proto";
|
|
2527
2547
|
import "tdx/volt_api/volt/v1/volt.proto";
|
|
2528
2548
|
|
|
2529
|
-
// The top-level volt management service.
|
|
2549
|
+
// The top-level volt management service.
|
|
2530
2550
|
// With the exception of \`Authenticate\`, all RPCs on this service must submit either a valid client certificate signed by the volt CA, or a signed JWT.
|
|
2531
2551
|
// A client certificate can be obtained from the \`Authenticate\` method.
|
|
2532
2552
|
// All methods include a \`tdx.volt_api.volt.v1.Status\` in the response. If the status contains a non-OK error code the client should assume the remainder of the message is invalid, unless otherwise indicated in the response documentation.
|
|
@@ -2886,9 +2906,19 @@ message ConnectResource {
|
|
|
2886
2906
|
Resource resource = 2;
|
|
2887
2907
|
}
|
|
2888
2908
|
|
|
2909
|
+
enum ConnectAuthRequestType {
|
|
2910
|
+
CONNECT_AUTH_REQUEST_TYPE_UNKNOWN = 0;
|
|
2911
|
+
CONNECT_AUTH_REQUEST_TYPE_NEW_SESSION = 1;
|
|
2912
|
+
CONNECT_AUTH_REQUEST_TYPE_UPDATE_SESSION = 2;
|
|
2913
|
+
CONNECT_AUTH_REQUEST_TYPE_DELETE_SESSION = 3;
|
|
2914
|
+
CONNECT_AUTH_REQUEST_TYPE_SIGN_REQUEST = 4;
|
|
2915
|
+
}
|
|
2916
|
+
|
|
2889
2917
|
message ConnectAuthRequest {
|
|
2890
2918
|
Session session = 1;
|
|
2891
2919
|
|
|
2920
|
+
ConnectAuthRequestType request_type = 2;
|
|
2921
|
+
|
|
2892
2922
|
string context = 5;
|
|
2893
2923
|
|
|
2894
2924
|
string challenge = 6;
|
|
@@ -3298,6 +3328,8 @@ message GetSessionsRequest {
|
|
|
3298
3328
|
string identity_name = 3;
|
|
3299
3329
|
|
|
3300
3330
|
SessionStatus status = 4;
|
|
3331
|
+
|
|
3332
|
+
string identity_email_id = 5;
|
|
3301
3333
|
}
|
|
3302
3334
|
|
|
3303
3335
|
message GetSessionsResponse {
|
|
@@ -3538,6 +3570,11 @@ message SaveSessionResponse {
|
|
|
3538
3570
|
}
|
|
3539
3571
|
|
|
3540
3572
|
message SetPolicyRequest {
|
|
3573
|
+
// The id of the policy to set.
|
|
3574
|
+
// Should be either 00000000-0000-0000-0000-000000000000 or 00000000-0000-0000-0000-000000000001 for the first or last custom policy respectively.
|
|
3575
|
+
string id = 2;
|
|
3576
|
+
|
|
3577
|
+
// The custom policy to set in JSON format.
|
|
3541
3578
|
string custom_policy = 1;
|
|
3542
3579
|
}
|
|
3543
3580
|
|
|
@@ -4822,13 +4859,18 @@ function issueAuthenticate(authenticateRequest, ttl) {
|
|
|
4822
4859
|
return Promise.reject(new Error(authenticateResponse.status.message));
|
|
4823
4860
|
} else {
|
|
4824
4861
|
switch (authenticateResponse.decision) {
|
|
4825
|
-
case "POLICY_DECISION_PERMIT":
|
|
4862
|
+
case "POLICY_DECISION_PERMIT":
|
|
4863
|
+
case "POLICY_DECISION_PROMPT":
|
|
4864
|
+
case "POLICY_DECISION_PENDING": {
|
|
4826
4865
|
//
|
|
4827
|
-
// The request status is
|
|
4866
|
+
// The request status is not deny => cache the bind response info.
|
|
4828
4867
|
//
|
|
4868
|
+
log$2("decision is %s", authenticateResponse.decision);
|
|
4829
4869
|
|
|
4830
4870
|
// This is the certificate assigned to us by the volt.
|
|
4831
|
-
|
|
4871
|
+
if (authenticateResponse.cert) {
|
|
4872
|
+
this._credential.cache.cert = authenticateResponse.cert;
|
|
4873
|
+
}
|
|
4832
4874
|
|
|
4833
4875
|
// This is the signing CA used by the volt.
|
|
4834
4876
|
this._credential.cache.ca = authenticateResponse.chain;
|
|
@@ -4842,11 +4884,20 @@ function issueAuthenticate(authenticateRequest, ttl) {
|
|
|
4842
4884
|
authenticateResponse.identity_did;
|
|
4843
4885
|
}
|
|
4844
4886
|
|
|
4887
|
+
// Maintain a unique list of verifiable credentials.
|
|
4888
|
+
const uniqueVCs = new Map();
|
|
4845
4889
|
this._credential.cache.vc = this._credential.cache.vc || [];
|
|
4890
|
+
for (const existingVC of this._credential.cache.vc) {
|
|
4891
|
+
uniqueVCs.set(existingVC.id, existingVC);
|
|
4892
|
+
}
|
|
4893
|
+
|
|
4846
4894
|
for (const credential of authenticateResponse.credential) {
|
|
4847
|
-
|
|
4895
|
+
const vc = JSON.parse(credential);
|
|
4896
|
+
uniqueVCs.set(vc.id, vc);
|
|
4848
4897
|
}
|
|
4849
4898
|
|
|
4899
|
+
this._credential.cache.vc = Array.from(uniqueVCs.values());
|
|
4900
|
+
|
|
4850
4901
|
this._credential.saveCache();
|
|
4851
4902
|
break;
|
|
4852
4903
|
}
|
|
@@ -4854,25 +4905,6 @@ function issueAuthenticate(authenticateRequest, ttl) {
|
|
|
4854
4905
|
log$2(">>>>>>>>>>>>>>> access request is DENIED <<<<<<<<<<<<<<<<<<<");
|
|
4855
4906
|
break;
|
|
4856
4907
|
}
|
|
4857
|
-
case "POLICY_DECISION_PROMPT":
|
|
4858
|
-
case "POLICY_DECISION_PENDING": {
|
|
4859
|
-
log$2("access pending approval - waiting...");
|
|
4860
|
-
|
|
4861
|
-
// This is the signing CA used by the volt.
|
|
4862
|
-
this._credential.cache.ca = authenticateResponse.chain;
|
|
4863
|
-
|
|
4864
|
-
// The session id is assigned by the volt.
|
|
4865
|
-
this._credential.cache.session_id = authenticateResponse.session_id;
|
|
4866
|
-
|
|
4867
|
-
if (!this._credential.cache.identity_did) {
|
|
4868
|
-
// Identity DID has been assigned by the volt.
|
|
4869
|
-
this._credential.cache.identity_did =
|
|
4870
|
-
authenticateResponse.identity_did;
|
|
4871
|
-
}
|
|
4872
|
-
|
|
4873
|
-
this._credential.saveCache();
|
|
4874
|
-
break;
|
|
4875
|
-
}
|
|
4876
4908
|
default:
|
|
4877
4909
|
log$2(
|
|
4878
4910
|
"ignoring unknown bind descision %s",
|
|
@@ -4895,7 +4927,12 @@ function findDIDDocumentService(document, serviceType) {
|
|
|
4895
4927
|
return matches;
|
|
4896
4928
|
}
|
|
4897
4929
|
|
|
4898
|
-
async function authenticateInternal(
|
|
4930
|
+
async function authenticateInternal(
|
|
4931
|
+
noDID = false,
|
|
4932
|
+
ownDID = false,
|
|
4933
|
+
exchangeToken = "",
|
|
4934
|
+
waitForPermit = true
|
|
4935
|
+
) {
|
|
4899
4936
|
try {
|
|
4900
4937
|
if (!this._credential.cache.ca) {
|
|
4901
4938
|
this._credential.cache.ca = this._voltConfig.ca_pem;
|
|
@@ -4926,6 +4963,27 @@ async function authenticateInternal(noDID = false, ownDID = false, exchangeToken
|
|
|
4926
4963
|
host: this._credential.cache.bindIp
|
|
4927
4964
|
};
|
|
4928
4965
|
|
|
4966
|
+
if (this._credential.cache.vc?.length > 0) {
|
|
4967
|
+
const presentation = {
|
|
4968
|
+
credential: []
|
|
4969
|
+
};
|
|
4970
|
+
|
|
4971
|
+
let presentationData = "";
|
|
4972
|
+
for (let credential of this._credential.cache.vc) {
|
|
4973
|
+
const vc = JSON.stringify(credential, null, 2);
|
|
4974
|
+
log$2(vc);
|
|
4975
|
+
presentation.credential.push(vc);
|
|
4976
|
+
presentationData += vc;
|
|
4977
|
+
}
|
|
4978
|
+
|
|
4979
|
+
presentation.signature = signBase64(
|
|
4980
|
+
this._credential.cache.key,
|
|
4981
|
+
presentationData
|
|
4982
|
+
);
|
|
4983
|
+
|
|
4984
|
+
authenticateRequest.verifiable_presentation = [presentation];
|
|
4985
|
+
}
|
|
4986
|
+
|
|
4929
4987
|
if (exchangeToken) {
|
|
4930
4988
|
log$2("setting request exchange token");
|
|
4931
4989
|
authenticateRequest.exchange_token = exchangeToken;
|
|
@@ -4937,9 +4995,7 @@ async function authenticateInternal(noDID = false, ownDID = false, exchangeToken
|
|
|
4937
4995
|
log$2("setting request challenge code");
|
|
4938
4996
|
authenticateRequest.challenge = this._credential.cache.challenge_code;
|
|
4939
4997
|
} else {
|
|
4940
|
-
log$2(
|
|
4941
|
-
"no challenge code in request"
|
|
4942
|
-
);
|
|
4998
|
+
log$2("no challenge code in request");
|
|
4943
4999
|
}
|
|
4944
5000
|
|
|
4945
5001
|
if (noDID) {
|
|
@@ -5017,8 +5073,8 @@ async function authenticateInternal(noDID = false, ownDID = false, exchangeToken
|
|
|
5017
5073
|
);
|
|
5018
5074
|
log$2("authenticate decision: %s", decision);
|
|
5019
5075
|
} while (
|
|
5020
|
-
decision === "
|
|
5021
|
-
decision === "
|
|
5076
|
+
decision === "POLICY_DECISION_PENDING" ||
|
|
5077
|
+
(waitForPermit && decision === "POLICY_DECISION_PROMPT")
|
|
5022
5078
|
);
|
|
5023
5079
|
|
|
5024
5080
|
return decision === "POLICY_DECISION_PERMIT";
|
|
@@ -5689,9 +5745,14 @@ class VoltClient extends EventEmitter__default["default"] {
|
|
|
5689
5745
|
* @param {boolean} [options.noDID] - whether to create a key-based authentication session
|
|
5690
5746
|
* instead of a DID-based authentication session.
|
|
5691
5747
|
* @param {string} [options.exchangeToken] - optional token to exchange in return for an authenticated session.
|
|
5748
|
+
* @param {boolean} [options.waitForAuth] - whether to block and poll on 'prompt' authenticate decisions. Default is true.
|
|
5692
5749
|
*/
|
|
5693
5750
|
async initialise(config, options = {}) {
|
|
5694
|
-
const { ownDID, noDID, didRegistryList, exchangeToken, extraConfig } =
|
|
5751
|
+
const { ownDID, noDID, didRegistryList, exchangeToken, extraConfig } =
|
|
5752
|
+
options;
|
|
5753
|
+
const waitForAuth =
|
|
5754
|
+
options.waitForAuth === undefined ? true : !!options.waitForAuth;
|
|
5755
|
+
|
|
5695
5756
|
try {
|
|
5696
5757
|
if (!config) {
|
|
5697
5758
|
throw new Error(
|
|
@@ -5777,7 +5838,13 @@ class VoltClient extends EventEmitter__default["default"] {
|
|
|
5777
5838
|
} else {
|
|
5778
5839
|
// No certificate present in the cache yet => we need to authenticate.
|
|
5779
5840
|
try {
|
|
5780
|
-
isBound = await authenticateInternal.call(
|
|
5841
|
+
isBound = await authenticateInternal.call(
|
|
5842
|
+
this,
|
|
5843
|
+
noDID,
|
|
5844
|
+
ownDID,
|
|
5845
|
+
exchangeToken,
|
|
5846
|
+
waitForAuth
|
|
5847
|
+
);
|
|
5781
5848
|
} catch (bindErr) {
|
|
5782
5849
|
if (bindErr.message === "invalid arguments") {
|
|
5783
5850
|
// This is usually the result of a missing challenge signature or credential.
|
|
@@ -6214,6 +6281,21 @@ class VoltClient extends EventEmitter__default["default"] {
|
|
|
6214
6281
|
return call.start(grpcClient, request);
|
|
6215
6282
|
}
|
|
6216
6283
|
|
|
6284
|
+
/**
|
|
6285
|
+
* TerminalAPI
|
|
6286
|
+
*/
|
|
6287
|
+
CommandStream(request, service) {
|
|
6288
|
+
const grpcClient = this.getVoltAPIClient();
|
|
6289
|
+
|
|
6290
|
+
const commandStreamCall = new GRPCCall(
|
|
6291
|
+
this,
|
|
6292
|
+
"CommandStream",
|
|
6293
|
+
"METHOD_TYPE_BIDI",
|
|
6294
|
+
service
|
|
6295
|
+
);
|
|
6296
|
+
return commandStreamCall.start(grpcClient, request);
|
|
6297
|
+
}
|
|
6298
|
+
|
|
6217
6299
|
/**
|
|
6218
6300
|
* WireAPI
|
|
6219
6301
|
*/
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.20.
|
|
6
|
+
"version": "0.20.8",
|
|
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.20.
|
|
36
|
+
"@tdxvolt/volt-client-web": "^0.20.8",
|
|
37
37
|
"debug": "^4.1.1",
|
|
38
38
|
"ip": "^1.1.5",
|
|
39
39
|
"jsonwebtoken": "^8.5.1",
|
|
@@ -32,13 +32,18 @@ function issueAuthenticate(authenticateRequest, ttl) {
|
|
|
32
32
|
return Promise.reject(new Error(authenticateResponse.status.message));
|
|
33
33
|
} else {
|
|
34
34
|
switch (authenticateResponse.decision) {
|
|
35
|
-
case "POLICY_DECISION_PERMIT":
|
|
35
|
+
case "POLICY_DECISION_PERMIT":
|
|
36
|
+
case "POLICY_DECISION_PROMPT":
|
|
37
|
+
case "POLICY_DECISION_PENDING": {
|
|
36
38
|
//
|
|
37
|
-
// The request status is
|
|
39
|
+
// The request status is not deny => cache the bind response info.
|
|
38
40
|
//
|
|
41
|
+
log("decision is %s", authenticateResponse.decision);
|
|
39
42
|
|
|
40
43
|
// This is the certificate assigned to us by the volt.
|
|
41
|
-
|
|
44
|
+
if (authenticateResponse.cert) {
|
|
45
|
+
this._credential.cache.cert = authenticateResponse.cert;
|
|
46
|
+
}
|
|
42
47
|
|
|
43
48
|
// This is the signing CA used by the volt.
|
|
44
49
|
this._credential.cache.ca = authenticateResponse.chain;
|
|
@@ -52,11 +57,20 @@ function issueAuthenticate(authenticateRequest, ttl) {
|
|
|
52
57
|
authenticateResponse.identity_did;
|
|
53
58
|
}
|
|
54
59
|
|
|
60
|
+
// Maintain a unique list of verifiable credentials.
|
|
61
|
+
const uniqueVCs = new Map();
|
|
55
62
|
this._credential.cache.vc = this._credential.cache.vc || [];
|
|
63
|
+
for (const existingVC of this._credential.cache.vc) {
|
|
64
|
+
uniqueVCs.set(existingVC.id, existingVC);
|
|
65
|
+
}
|
|
66
|
+
|
|
56
67
|
for (const credential of authenticateResponse.credential) {
|
|
57
|
-
|
|
68
|
+
const vc = JSON.parse(credential);
|
|
69
|
+
uniqueVCs.set(vc.id, vc);
|
|
58
70
|
}
|
|
59
71
|
|
|
72
|
+
this._credential.cache.vc = Array.from(uniqueVCs.values());
|
|
73
|
+
|
|
60
74
|
this._credential.saveCache();
|
|
61
75
|
break;
|
|
62
76
|
}
|
|
@@ -64,25 +78,6 @@ function issueAuthenticate(authenticateRequest, ttl) {
|
|
|
64
78
|
log(">>>>>>>>>>>>>>> access request is DENIED <<<<<<<<<<<<<<<<<<<");
|
|
65
79
|
break;
|
|
66
80
|
}
|
|
67
|
-
case "POLICY_DECISION_PROMPT":
|
|
68
|
-
case "POLICY_DECISION_PENDING": {
|
|
69
|
-
log("access pending approval - waiting...");
|
|
70
|
-
|
|
71
|
-
// This is the signing CA used by the volt.
|
|
72
|
-
this._credential.cache.ca = authenticateResponse.chain;
|
|
73
|
-
|
|
74
|
-
// The session id is assigned by the volt.
|
|
75
|
-
this._credential.cache.session_id = authenticateResponse.session_id;
|
|
76
|
-
|
|
77
|
-
if (!this._credential.cache.identity_did) {
|
|
78
|
-
// Identity DID has been assigned by the volt.
|
|
79
|
-
this._credential.cache.identity_did =
|
|
80
|
-
authenticateResponse.identity_did;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
this._credential.saveCache();
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
81
|
default:
|
|
87
82
|
log(
|
|
88
83
|
"ignoring unknown bind descision %s",
|
|
@@ -105,7 +100,12 @@ function findDIDDocumentService(document, serviceType) {
|
|
|
105
100
|
return matches;
|
|
106
101
|
}
|
|
107
102
|
|
|
108
|
-
export async function authenticateInternal(
|
|
103
|
+
export async function authenticateInternal(
|
|
104
|
+
noDID = false,
|
|
105
|
+
ownDID = false,
|
|
106
|
+
exchangeToken = "",
|
|
107
|
+
waitForPermit = true
|
|
108
|
+
) {
|
|
109
109
|
try {
|
|
110
110
|
if (!this._credential.cache.ca) {
|
|
111
111
|
this._credential.cache.ca = this._voltConfig.ca_pem;
|
|
@@ -136,6 +136,27 @@ export async function authenticateInternal(noDID = false, ownDID = false, exchan
|
|
|
136
136
|
host: this._credential.cache.bindIp
|
|
137
137
|
};
|
|
138
138
|
|
|
139
|
+
if (this._credential.cache.vc?.length > 0) {
|
|
140
|
+
const presentation = {
|
|
141
|
+
credential: []
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
let presentationData = "";
|
|
145
|
+
for (let credential of this._credential.cache.vc) {
|
|
146
|
+
const vc = JSON.stringify(credential, null, 2);
|
|
147
|
+
log(vc);
|
|
148
|
+
presentation.credential.push(vc);
|
|
149
|
+
presentationData += vc;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
presentation.signature = signBase64(
|
|
153
|
+
this._credential.cache.key,
|
|
154
|
+
presentationData
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
authenticateRequest.verifiable_presentation = [presentation];
|
|
158
|
+
}
|
|
159
|
+
|
|
139
160
|
if (exchangeToken) {
|
|
140
161
|
log("setting request exchange token");
|
|
141
162
|
authenticateRequest.exchange_token = exchangeToken;
|
|
@@ -147,9 +168,7 @@ export async function authenticateInternal(noDID = false, ownDID = false, exchan
|
|
|
147
168
|
log("setting request challenge code");
|
|
148
169
|
authenticateRequest.challenge = this._credential.cache.challenge_code;
|
|
149
170
|
} else {
|
|
150
|
-
log(
|
|
151
|
-
"no challenge code in request"
|
|
152
|
-
);
|
|
171
|
+
log("no challenge code in request");
|
|
153
172
|
}
|
|
154
173
|
|
|
155
174
|
if (noDID) {
|
|
@@ -227,8 +246,8 @@ export async function authenticateInternal(noDID = false, ownDID = false, exchan
|
|
|
227
246
|
);
|
|
228
247
|
log("authenticate decision: %s", decision);
|
|
229
248
|
} while (
|
|
230
|
-
decision === "
|
|
231
|
-
decision === "
|
|
249
|
+
decision === "POLICY_DECISION_PENDING" ||
|
|
250
|
+
(waitForPermit && decision === "POLICY_DECISION_PROMPT")
|
|
232
251
|
);
|
|
233
252
|
|
|
234
253
|
return decision === "POLICY_DECISION_PERMIT";
|
package/src/volt-client.js
CHANGED
|
@@ -85,9 +85,14 @@ export class VoltClient extends EventEmitter {
|
|
|
85
85
|
* @param {boolean} [options.noDID] - whether to create a key-based authentication session
|
|
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
|
+
* @param {boolean} [options.waitForAuth] - whether to block and poll on 'prompt' authenticate decisions. Default is true.
|
|
88
89
|
*/
|
|
89
90
|
async initialise(config, options = {}) {
|
|
90
|
-
const { ownDID, noDID, didRegistryList, exchangeToken, extraConfig } =
|
|
91
|
+
const { ownDID, noDID, didRegistryList, exchangeToken, extraConfig } =
|
|
92
|
+
options;
|
|
93
|
+
const waitForAuth =
|
|
94
|
+
options.waitForAuth === undefined ? true : !!options.waitForAuth;
|
|
95
|
+
|
|
91
96
|
try {
|
|
92
97
|
if (!config) {
|
|
93
98
|
throw new Error(
|
|
@@ -173,7 +178,13 @@ export class VoltClient extends EventEmitter {
|
|
|
173
178
|
} else {
|
|
174
179
|
// No certificate present in the cache yet => we need to authenticate.
|
|
175
180
|
try {
|
|
176
|
-
isBound = await authenticateInternal.call(
|
|
181
|
+
isBound = await authenticateInternal.call(
|
|
182
|
+
this,
|
|
183
|
+
noDID,
|
|
184
|
+
ownDID,
|
|
185
|
+
exchangeToken,
|
|
186
|
+
waitForAuth
|
|
187
|
+
);
|
|
177
188
|
} catch (bindErr) {
|
|
178
189
|
if (bindErr.message === "invalid arguments") {
|
|
179
190
|
// This is usually the result of a missing challenge signature or credential.
|
|
@@ -612,6 +623,21 @@ export class VoltClient extends EventEmitter {
|
|
|
612
623
|
return call.start(grpcClient, request);
|
|
613
624
|
}
|
|
614
625
|
|
|
626
|
+
/**
|
|
627
|
+
* TerminalAPI
|
|
628
|
+
*/
|
|
629
|
+
CommandStream(request, service) {
|
|
630
|
+
const grpcClient = this.getVoltAPIClient();
|
|
631
|
+
|
|
632
|
+
const commandStreamCall = new GRPCCall(
|
|
633
|
+
this,
|
|
634
|
+
"CommandStream",
|
|
635
|
+
"METHOD_TYPE_BIDI",
|
|
636
|
+
service
|
|
637
|
+
);
|
|
638
|
+
return commandStreamCall.start(grpcClient, request);
|
|
639
|
+
}
|
|
640
|
+
|
|
615
641
|
/**
|
|
616
642
|
* WireAPI
|
|
617
643
|
*/
|
|
@@ -543,8 +543,14 @@ message GetFileDescendantsRequest {
|
|
|
543
543
|
// Optional - only match descendants of the given kind.
|
|
544
544
|
string extension = 3;
|
|
545
545
|
|
|
546
|
+
// Optional - restrict to folders only.bool
|
|
547
|
+
bool folders_only = 4;
|
|
548
|
+
|
|
546
549
|
// Optional - can be used to determine if a resource is a descendant.
|
|
547
550
|
string descendant_id = 5;
|
|
551
|
+
|
|
552
|
+
// Optional - include hidden files and directories.
|
|
553
|
+
bool include_hidden = 6;
|
|
548
554
|
}
|
|
549
555
|
|
|
550
556
|
message GetFileDescendantsResponse {
|
|
@@ -875,10 +881,13 @@ message DIDRegistryUpdate {
|
|
|
875
881
|
}
|
|
876
882
|
|
|
877
883
|
message VerifiablePresentation {
|
|
878
|
-
//
|
|
884
|
+
// DEPRECATED - use 'credential'
|
|
879
885
|
string credential_json = 1;
|
|
880
886
|
|
|
881
|
-
//
|
|
887
|
+
// Array of credential JSON.
|
|
888
|
+
repeated string credential = 3;
|
|
889
|
+
|
|
890
|
+
// A signature of the credential JSON. The signature should be that of the credential holder over the concatenation of the contents of the \`credential\` array.
|
|
882
891
|
string signature = 2;
|
|
883
892
|
}
|
|
884
893
|
|
|
@@ -1042,7 +1051,7 @@ message ParseCredentialResponse {
|
|
|
1042
1051
|
tdx.volt_api.volt.v1.Status status = 1;
|
|
1043
1052
|
|
|
1044
1053
|
// The parsed credential details.
|
|
1045
|
-
VerifiableCredential verifiable_credential = 2;
|
|
1054
|
+
repeated VerifiableCredential verifiable_credential = 2;
|
|
1046
1055
|
}
|
|
1047
1056
|
|
|
1048
1057
|
message ResolveDIDRequest {
|
|
@@ -1583,6 +1592,15 @@ message VoltParameters {
|
|
|
1583
1592
|
|
|
1584
1593
|
// If set, enables the agent event pool.
|
|
1585
1594
|
bool enable_agent_event_pool = 51;
|
|
1595
|
+
|
|
1596
|
+
// Optional owner email addresses.
|
|
1597
|
+
repeated string owner_email = 52;
|
|
1598
|
+
|
|
1599
|
+
// Optional owner email identity providers.
|
|
1600
|
+
repeated string identity_provider = 53;
|
|
1601
|
+
|
|
1602
|
+
// If set, exposes a resource that gives the Volt owner read-only access the file system.
|
|
1603
|
+
bool enable_owner_file_system_access = 54;
|
|
1586
1604
|
}
|
|
1587
1605
|
|
|
1588
1606
|
message VoltEndpoint {
|
|
@@ -1947,6 +1965,9 @@ message SessionCredential {
|
|
|
1947
1965
|
|
|
1948
1966
|
// More type-specific data stored with the credential.
|
|
1949
1967
|
string extra_2 = 16;
|
|
1968
|
+
|
|
1969
|
+
// The verification status of the credential.
|
|
1970
|
+
string status = 17;
|
|
1950
1971
|
}
|
|
1951
1972
|
|
|
1952
1973
|
message Session {
|
|
@@ -1970,7 +1991,6 @@ message Session {
|
|
|
1970
1991
|
|
|
1971
1992
|
SessionStatus status = 10;
|
|
1972
1993
|
}
|
|
1973
|
-
|
|
1974
1994
|
`;
|
|
1975
1995
|
export const volt_api = `syntax = "proto3";
|
|
1976
1996
|
|
|
@@ -1981,7 +2001,7 @@ import "tdx/volt_api/volt/v1/remote.proto";
|
|
|
1981
2001
|
import "tdx/volt_api/volt/v1/ssi.proto";
|
|
1982
2002
|
import "tdx/volt_api/volt/v1/volt.proto";
|
|
1983
2003
|
|
|
1984
|
-
// The top-level volt management service.
|
|
2004
|
+
// The top-level volt management service.
|
|
1985
2005
|
// With the exception of \`Authenticate\`, all RPCs on this service must submit either a valid client certificate signed by the volt CA, or a signed JWT.
|
|
1986
2006
|
// A client certificate can be obtained from the \`Authenticate\` method.
|
|
1987
2007
|
// All methods include a \`tdx.volt_api.volt.v1.Status\` in the response. If the status contains a non-OK error code the client should assume the remainder of the message is invalid, unless otherwise indicated in the response documentation.
|
|
@@ -2341,9 +2361,19 @@ message ConnectResource {
|
|
|
2341
2361
|
Resource resource = 2;
|
|
2342
2362
|
}
|
|
2343
2363
|
|
|
2364
|
+
enum ConnectAuthRequestType {
|
|
2365
|
+
CONNECT_AUTH_REQUEST_TYPE_UNKNOWN = 0;
|
|
2366
|
+
CONNECT_AUTH_REQUEST_TYPE_NEW_SESSION = 1;
|
|
2367
|
+
CONNECT_AUTH_REQUEST_TYPE_UPDATE_SESSION = 2;
|
|
2368
|
+
CONNECT_AUTH_REQUEST_TYPE_DELETE_SESSION = 3;
|
|
2369
|
+
CONNECT_AUTH_REQUEST_TYPE_SIGN_REQUEST = 4;
|
|
2370
|
+
}
|
|
2371
|
+
|
|
2344
2372
|
message ConnectAuthRequest {
|
|
2345
2373
|
Session session = 1;
|
|
2346
2374
|
|
|
2375
|
+
ConnectAuthRequestType request_type = 2;
|
|
2376
|
+
|
|
2347
2377
|
string context = 5;
|
|
2348
2378
|
|
|
2349
2379
|
string challenge = 6;
|
|
@@ -2753,6 +2783,8 @@ message GetSessionsRequest {
|
|
|
2753
2783
|
string identity_name = 3;
|
|
2754
2784
|
|
|
2755
2785
|
SessionStatus status = 4;
|
|
2786
|
+
|
|
2787
|
+
string identity_email_id = 5;
|
|
2756
2788
|
}
|
|
2757
2789
|
|
|
2758
2790
|
message GetSessionsResponse {
|
|
@@ -2993,6 +3025,11 @@ message SaveSessionResponse {
|
|
|
2993
3025
|
}
|
|
2994
3026
|
|
|
2995
3027
|
message SetPolicyRequest {
|
|
3028
|
+
// The id of the policy to set.
|
|
3029
|
+
// Should be either 00000000-0000-0000-0000-000000000000 or 00000000-0000-0000-0000-000000000001 for the first or last custom policy respectively.
|
|
3030
|
+
string id = 2;
|
|
3031
|
+
|
|
3032
|
+
// The custom policy to set in JSON format.
|
|
2996
3033
|
string custom_policy = 1;
|
|
2997
3034
|
}
|
|
2998
3035
|
|