@nmshd/connector-tui 2.13.2 → 3.0.0-alpha.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/dist/ConnectorTUI.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConnectorClient } from "@nmshd/connector-sdk";
|
|
1
|
+
import { ApiKeyAuthenticator, ConnectorClient } from "@nmshd/connector-sdk";
|
|
2
2
|
import chalk from "chalk";
|
|
3
3
|
import { readFile } from "fs/promises";
|
|
4
4
|
import { DateTime } from "luxon";
|
|
@@ -6,7 +6,7 @@ import prompts from "prompts";
|
|
|
6
6
|
import { ConnectorTUIBaseWithMixins } from "./mixins/index.js";
|
|
7
7
|
export class ConnectorTUI extends ConnectorTUIBaseWithMixins {
|
|
8
8
|
static async create(baseUrl, apiKey) {
|
|
9
|
-
const client = ConnectorClient.create({ baseUrl, apiKey });
|
|
9
|
+
const client = ConnectorClient.create({ baseUrl, authenticator: new ApiKeyAuthenticator(apiKey) });
|
|
10
10
|
const address = (await client.account.getIdentityInfo()).result.address;
|
|
11
11
|
const support = await client.monitoring.getSupport();
|
|
12
12
|
return new ConnectorTUI(client, address, support);
|
|
@@ -47,8 +47,8 @@ export class ConnectorTUI extends ConnectorTUIBaseWithMixins {
|
|
|
47
47
|
// allow connector in debugging mode to be used
|
|
48
48
|
if (connectorVersionInfo.version === "{{version}}")
|
|
49
49
|
return connectorVersionInfo;
|
|
50
|
-
if (!connectorVersionInfo.version.startsWith("
|
|
51
|
-
console.log(`This TUI is made for enmeshed
|
|
50
|
+
if (!connectorVersionInfo.version.startsWith("7.")) {
|
|
51
|
+
console.log(`This TUI is made for enmeshed V7 connectors (starting with version 7.0.0 of the connector). Current version: ${connectorVersionInfo.version}`);
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
54
|
return connectorVersionInfo;
|
package/dist/ConnectorTUIBase.js
CHANGED
|
@@ -96,7 +96,7 @@ export class ConnectorTUIBase {
|
|
|
96
96
|
return files.map((f) => this.renderFile(f));
|
|
97
97
|
}
|
|
98
98
|
renderFile(file) {
|
|
99
|
-
return { title: file.title, value: file };
|
|
99
|
+
return { title: file.title ?? file.filename, value: file };
|
|
100
100
|
}
|
|
101
101
|
async selectAttribute(prompt, query) {
|
|
102
102
|
const choices = await this.getAttributeChoices(query);
|
|
@@ -55,10 +55,6 @@ export function AddSendRequestByMessage(Base) {
|
|
|
55
55
|
title: "ConsentRequestItem",
|
|
56
56
|
value: this.createConsentRequestItem.bind(this),
|
|
57
57
|
},
|
|
58
|
-
{
|
|
59
|
-
title: "RegisterAttributeListenerRequestItem",
|
|
60
|
-
value: this.createRegisterAttributeListenerRequestItem.bind(this),
|
|
61
|
-
},
|
|
62
58
|
{
|
|
63
59
|
title: "AuthenticationRequestItem",
|
|
64
60
|
value: this.createAuthenticationRequestItem.bind(this),
|
|
@@ -67,10 +63,6 @@ export function AddSendRequestByMessage(Base) {
|
|
|
67
63
|
title: "FormFieldRequestItem",
|
|
68
64
|
value: this.createFormFieldRequestItem.bind(this),
|
|
69
65
|
},
|
|
70
|
-
{
|
|
71
|
-
title: "FreeTextRequestItem",
|
|
72
|
-
value: this.createFreeTextRequestItem.bind(this),
|
|
73
|
-
},
|
|
74
66
|
{
|
|
75
67
|
title: "ShareAttributeRequestItem",
|
|
76
68
|
value: this.createShareAttributeRequestItem.bind(this),
|
|
@@ -542,9 +534,9 @@ export function AddSendRequestByMessage(Base) {
|
|
|
542
534
|
initial: true,
|
|
543
535
|
},
|
|
544
536
|
{
|
|
545
|
-
message: "Do you want to require a manual
|
|
537
|
+
message: "Do you want to require a manual interaction?",
|
|
546
538
|
type: "confirm",
|
|
547
|
-
name: "
|
|
539
|
+
name: "requiresInteraction",
|
|
548
540
|
initial: false,
|
|
549
541
|
},
|
|
550
542
|
{
|
|
@@ -569,7 +561,7 @@ export function AddSendRequestByMessage(Base) {
|
|
|
569
561
|
const requestItem = {
|
|
570
562
|
"@type": "ConsentRequestItem",
|
|
571
563
|
mustBeAccepted: result.mustBeAccepted,
|
|
572
|
-
|
|
564
|
+
requiresInteraction: result.requiresInteraction,
|
|
573
565
|
consent: result.consent,
|
|
574
566
|
description: result.description,
|
|
575
567
|
link: result.link,
|
|
@@ -578,24 +570,6 @@ export function AddSendRequestByMessage(Base) {
|
|
|
578
570
|
};
|
|
579
571
|
return requestItem;
|
|
580
572
|
}
|
|
581
|
-
async createRegisterAttributeListenerRequestItem() {
|
|
582
|
-
const result = await prompts([
|
|
583
|
-
{
|
|
584
|
-
message: "What's the attribute type you would like to query?",
|
|
585
|
-
type: "text",
|
|
586
|
-
name: "attributeType",
|
|
587
|
-
},
|
|
588
|
-
]);
|
|
589
|
-
const requestItem = {
|
|
590
|
-
"@type": "RegisterAttributeListenerRequestItem",
|
|
591
|
-
mustBeAccepted: true,
|
|
592
|
-
query: {
|
|
593
|
-
"@type": "IdentityAttributeQuery",
|
|
594
|
-
valueType: result.attributeType,
|
|
595
|
-
},
|
|
596
|
-
};
|
|
597
|
-
return requestItem;
|
|
598
|
-
}
|
|
599
573
|
async createAuthenticationRequestItem() {
|
|
600
574
|
const result = await prompts([
|
|
601
575
|
{
|
|
@@ -874,21 +848,6 @@ export function AddSendRequestByMessage(Base) {
|
|
|
874
848
|
};
|
|
875
849
|
return requestItem;
|
|
876
850
|
}
|
|
877
|
-
async createFreeTextRequestItem() {
|
|
878
|
-
const result = await prompts([
|
|
879
|
-
{
|
|
880
|
-
message: "Enter a free text",
|
|
881
|
-
type: "text",
|
|
882
|
-
name: "freeText",
|
|
883
|
-
},
|
|
884
|
-
]);
|
|
885
|
-
const requestItem = {
|
|
886
|
-
"@type": "FreeTextRequestItem",
|
|
887
|
-
mustBeAccepted: true,
|
|
888
|
-
freeText: result.freeText,
|
|
889
|
-
};
|
|
890
|
-
return requestItem;
|
|
891
|
-
}
|
|
892
851
|
async createShareAttributeRequestItem() {
|
|
893
852
|
const query = { content: { "@type": "IdentityAttribute", owner: this.connectorAddress }, shareInfo: { peer: "!" }, succeededBy: "!" };
|
|
894
853
|
const attribute = await this.selectAttribute("Which Attribute would you like to share?", query);
|
|
@@ -906,16 +865,13 @@ export function AddSendRequestByMessage(Base) {
|
|
|
906
865
|
const file = await this.selectFile("The ownership of which File do you want to transfer?");
|
|
907
866
|
if (!file)
|
|
908
867
|
return;
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
type: "confirm",
|
|
914
|
-
});
|
|
868
|
+
if (!file.ownershipToken) {
|
|
869
|
+
console.log("The selected file does not have an ownership token, so it cannot be transferred.");
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
915
872
|
const requestItem = {
|
|
916
873
|
"@type": "TransferFileOwnershipRequestItem",
|
|
917
874
|
mustBeAccepted: true,
|
|
918
|
-
requireManualDecision: result.requireManualDecision,
|
|
919
875
|
fileReference: file.reference.truncated,
|
|
920
876
|
ownershipToken: file.ownershipToken,
|
|
921
877
|
};
|
|
@@ -89,28 +89,10 @@ export function AddShareRequestByTemplate(Base) {
|
|
|
89
89
|
await this.createQRCodeForRelationshipTemplate(onNewRelationship, onExistingRelationship, name, passwordProtection);
|
|
90
90
|
}
|
|
91
91
|
async getOrCreateConnectorDisplayName(displayName) {
|
|
92
|
-
const response = await this.connectorClient.attributes.
|
|
93
|
-
|
|
94
|
-
owner: this.connectorAddress,
|
|
95
|
-
value: {
|
|
96
|
-
"@type": "DisplayName",
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
shareInfo: {
|
|
100
|
-
peer: "!",
|
|
101
|
-
},
|
|
102
|
-
});
|
|
103
|
-
if (response.result.length > 0) {
|
|
92
|
+
const response = await this.connectorClient.attributes.getOwnRepositoryAttributes({ "content.value.@type": "DisplayName" });
|
|
93
|
+
if (response.result.length > 0)
|
|
104
94
|
return response.result[0];
|
|
105
|
-
}
|
|
106
|
-
const createAttributeResponse = await this.connectorClient.attributes.createRepositoryAttribute({
|
|
107
|
-
content: {
|
|
108
|
-
value: {
|
|
109
|
-
"@type": "DisplayName",
|
|
110
|
-
value: displayName,
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
});
|
|
95
|
+
const createAttributeResponse = await this.connectorClient.attributes.createRepositoryAttribute({ content: { value: { "@type": "DisplayName", value: displayName } } });
|
|
114
96
|
return createAttributeResponse.result;
|
|
115
97
|
}
|
|
116
98
|
async createPasswordProtection() {
|
package/package.json
CHANGED
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"watch": "node --watch --import 'data:text/javascript,import { register } from \"node:module\"; import { pathToFileURL } from \"node:url\"; register(\"ts-node/esm\", pathToFileURL(\"./\"));' src/run.ts"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@nmshd/connector-sdk": "^
|
|
32
|
-
"axios": "^1.
|
|
31
|
+
"@nmshd/connector-sdk": "^7.0.0-alpha.20",
|
|
32
|
+
"axios": "^1.11.0",
|
|
33
33
|
"chalk": "^5.4.1",
|
|
34
|
-
"dotenv": "^17.2.
|
|
34
|
+
"dotenv": "^17.2.1",
|
|
35
35
|
"luxon": "^3.7.1",
|
|
36
36
|
"prompts": "^2.4.2",
|
|
37
37
|
"qrcode-terminal": "^0.12.0",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@js-soft/eslint-config-ts": "^2.0.1",
|
|
42
42
|
"@js-soft/license-check": "^1.0.9",
|
|
43
43
|
"@types/luxon": "^3.6.2",
|
|
44
|
-
"@types/node": "^22.16.
|
|
44
|
+
"@types/node": "^22.16.5",
|
|
45
45
|
"@types/prompts": "^2.4.9",
|
|
46
46
|
"@types/qrcode-terminal": "^0.12.2",
|
|
47
47
|
"@types/yargs": "^17.0.33",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"access": "public",
|
|
58
58
|
"provenance": true
|
|
59
59
|
},
|
|
60
|
-
"version": "
|
|
60
|
+
"version": "3.0.0-alpha.1"
|
|
61
61
|
}
|