@nmshd/connector-tui 2.13.1 → 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.
@@ -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);
@@ -16,7 +16,7 @@ export class ConnectorTUI extends ConnectorTUIBaseWithMixins {
16
16
  if (!connectorVersionInfo)
17
17
  return;
18
18
  await this.#showStartupMessage(connectorVersionInfo);
19
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, no-constant-condition
19
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
20
20
  while (true) {
21
21
  const activeIdentityDeletionProcess = this.isDebugMode() ? await this.identityDeletionProcessEndpoint.getActiveIdentityDeletionProcess() : undefined;
22
22
  if (activeIdentityDeletionProcess?.isSuccess && activeIdentityDeletionProcess.result.status === "Approved") {
@@ -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("6.")) {
51
- console.log(`This TUI is made for enmeshed V6 connectors (starting with version 6.0.0 of the connector). Current version: ${connectorVersionInfo.version}`);
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;
@@ -1,4 +1,4 @@
1
- import { ConnectorRelationshipStatus, } from "@nmshd/connector-sdk";
1
+ import { RelationshipStatus } from "@nmshd/connector-sdk";
2
2
  import { DateTime } from "luxon";
3
3
  import prompts from "prompts";
4
4
  import { IdentityDeletionProcessEndpoint } from "./IdentityDeletionProcessEndpoint.js";
@@ -17,7 +17,7 @@ export class ConnectorTUIBase {
17
17
  }
18
18
  async selectRelationship(prompt, ...status) {
19
19
  if (status.length === 0)
20
- status.push(ConnectorRelationshipStatus.Active);
20
+ status.push(RelationshipStatus.Active);
21
21
  const choices = await this.getRelationshipChoices(status, true);
22
22
  if (!choices)
23
23
  return;
@@ -26,7 +26,7 @@ export class ConnectorTUIBase {
26
26
  }
27
27
  async selectRelationships(prompt, ...status) {
28
28
  if (status.length === 0)
29
- status.push(ConnectorRelationshipStatus.Active);
29
+ status.push(RelationshipStatus.Active);
30
30
  const choices = await this.getRelationshipChoices(status, false);
31
31
  if (!choices)
32
32
  return;
@@ -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);
@@ -1,4 +1,4 @@
1
- import { ConnectorRelationshipStatus } from "@nmshd/connector-sdk";
1
+ import { RelationshipStatus } from "@nmshd/connector-sdk";
2
2
  import prompts from "prompts";
3
3
  export function AddAcceptPendingRelationships(Base) {
4
4
  return class AcceptPendingRelationships extends Base {
@@ -15,7 +15,7 @@ export function AddAcceptPendingRelationships(Base) {
15
15
  if (result.sync) {
16
16
  await this.connectorClient.account.sync();
17
17
  }
18
- const pendingRelationships = (await this.connectorClient.relationships.getRelationships({ status: ConnectorRelationshipStatus.Pending })).result;
18
+ const pendingRelationships = (await this.connectorClient.relationships.getRelationships({ status: RelationshipStatus.Pending })).result;
19
19
  for (const relationship of pendingRelationships) {
20
20
  console.log(`Accepting relationship ${relationship.id}`);
21
21
  await this.connectorClient.relationships.acceptRelationship(relationship.id);
@@ -1,4 +1,4 @@
1
- import { ConnectorRequestStatus } from "@nmshd/connector-sdk";
1
+ import { LocalRequestStatus } from "@nmshd/connector-sdk";
2
2
  import { DateTime } from "luxon";
3
3
  import prompts from "prompts";
4
4
  export function AddAcceptPendingRequests(Base) {
@@ -16,9 +16,7 @@ export function AddAcceptPendingRequests(Base) {
16
16
  if (result.sync) {
17
17
  await this.connectorClient.account.sync();
18
18
  }
19
- const pendingRequests = (await this.connectorClient.incomingRequests.getRequests({
20
- status: ConnectorRequestStatus.ManualDecisionRequired,
21
- })).result;
19
+ const pendingRequests = (await this.connectorClient.incomingRequests.getRequests({ status: LocalRequestStatus.ManualDecisionRequired })).result;
22
20
  for (const request of pendingRequests) {
23
21
  const title = request.content.title ? `title ${request.content.title}` : "no title";
24
22
  console.log(`Trying to accept request ${request.id} with ${title}...`);
@@ -1,4 +1,4 @@
1
- import { ConnectorRelationshipStatus } from "@nmshd/connector-sdk";
1
+ import { RelationshipStatus } from "@nmshd/connector-sdk";
2
2
  export function AddDecomposeRelationship(Base) {
3
3
  return class DecomposeRelationship extends Base {
4
4
  constructor(...args) {
@@ -7,7 +7,7 @@ export function AddDecomposeRelationship(Base) {
7
7
  }
8
8
  async decomposeRelationship() {
9
9
  await this.connectorClient.account.sync();
10
- const relationship = await this.selectRelationship("Select relationship to decompose", ConnectorRelationshipStatus.Terminated, ConnectorRelationshipStatus.DeletionProposed);
10
+ const relationship = await this.selectRelationship("Select relationship to decompose", RelationshipStatus.Terminated, RelationshipStatus.DeletionProposed);
11
11
  if (!relationship)
12
12
  return;
13
13
  console.log(`Decomposing relationship ${relationship.id}`);
@@ -1,4 +1,4 @@
1
- import { ConnectorRelationshipStatus } from "@nmshd/connector-sdk";
1
+ import { RelationshipStatus } from "@nmshd/connector-sdk";
2
2
  export function AddGetAttributesOfRelationship(Base) {
3
3
  return class GetAttributesOfRelationship extends Base {
4
4
  constructor(...args) {
@@ -6,7 +6,7 @@ export function AddGetAttributesOfRelationship(Base) {
6
6
  this.choices.push({ title: "Get Attributes Of Relationship", value: this.getAttributesOfRelationship });
7
7
  }
8
8
  async getAttributesOfRelationship() {
9
- const relationship = await this.selectRelationship("From which relationship do you want to get the attributes?", ConnectorRelationshipStatus.Active, ConnectorRelationshipStatus.Pending, ConnectorRelationshipStatus.Terminated, ConnectorRelationshipStatus.DeletionProposed);
9
+ const relationship = await this.selectRelationship("From which relationship do you want to get the attributes?", RelationshipStatus.Active, RelationshipStatus.Pending, RelationshipStatus.Terminated, RelationshipStatus.DeletionProposed);
10
10
  if (!relationship)
11
11
  return console.log("No recipient selected");
12
12
  const attributeResult = await this.connectorClient.relationships.getAttributesForRelationship(relationship.id);
@@ -12,7 +12,7 @@ export function AddSendRequestByMessage(Base) {
12
12
  return console.log("No recipient selected");
13
13
  const peer = recipient.peer;
14
14
  const requestItems = [];
15
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition,no-constant-condition
15
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
16
16
  while (true) {
17
17
  const whatRequest = await prompts({
18
18
  message: "What kind of request do you want to send?",
@@ -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 decision?",
537
+ message: "Do you want to require a manual interaction?",
546
538
  type: "confirm",
547
- name: "requireManualDecision",
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
- requireManualDecision: result.requireManualDecision,
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
- const result = await prompts({
910
- name: "requireManualDecision",
911
- message: "Do you want to require a manual decision?",
912
- initial: false,
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.getValidAttributes({
93
- content: {
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() {
@@ -1,4 +1,4 @@
1
- import { ConnectorRelationshipStatus } from "@nmshd/connector-sdk";
1
+ import { RelationshipStatus } from "@nmshd/connector-sdk";
2
2
  export function AddTerminateRelationship(Base) {
3
3
  return class TerminateRelationship extends Base {
4
4
  constructor(...args) {
@@ -7,7 +7,7 @@ export function AddTerminateRelationship(Base) {
7
7
  }
8
8
  async terminateRelationship() {
9
9
  await this.connectorClient.account.sync();
10
- const relationship = await this.selectRelationship("Select relationship to terminate", ConnectorRelationshipStatus.Active);
10
+ const relationship = await this.selectRelationship("Select relationship to terminate", RelationshipStatus.Active);
11
11
  if (!relationship)
12
12
  return;
13
13
  console.log(`Terminating relationship ${relationship.id}`);
package/package.json CHANGED
@@ -28,34 +28,34 @@
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": "^6.29.0",
32
- "axios": "^1.9.0",
31
+ "@nmshd/connector-sdk": "^7.0.0-alpha.20",
32
+ "axios": "^1.11.0",
33
33
  "chalk": "^5.4.1",
34
- "dotenv": "^16.5.0",
35
- "luxon": "^3.6.1",
34
+ "dotenv": "^17.2.1",
35
+ "luxon": "^3.7.1",
36
36
  "prompts": "^2.4.2",
37
37
  "qrcode-terminal": "^0.12.0",
38
38
  "yargs": "^18.0.0"
39
39
  },
40
40
  "devDependencies": {
41
- "@js-soft/eslint-config-ts": "^1.6.14",
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.15.29",
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",
48
- "eslint": "^8.57.1",
49
- "prettier": "^3.5.3",
48
+ "eslint": "^9.31.0",
49
+ "prettier": "^3.6.2",
50
50
  "ts-node": "^10.9.2",
51
51
  "typescript": "^5.8.3"
52
52
  },
53
53
  "engines": {
54
- "node": ">=22.16.0"
54
+ "node": ">=22.17.1"
55
55
  },
56
56
  "publishConfig": {
57
57
  "access": "public",
58
58
  "provenance": true
59
59
  },
60
- "version": "2.13.1"
60
+ "version": "3.0.0-alpha.1"
61
61
  }
package/src/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  // custom type definitions because `tsc` does not support private and protected members for anonymous classes
2
2
  export declare class ConnectorTUI {
3
- static create(baseUrl: string, apiKey: string): Promise<ConnectorTUI>
4
- run(): Promise<void>
3
+ public static create(baseUrl: string, apiKey: string): Promise<ConnectorTUI>
4
+ public run(): Promise<void>
5
5
  }