@nmshd/connector-tui 2.15.0 → 3.0.0-alpha.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.
@@ -1,12 +1,12 @@
1
+ import { ApiKeyAuthenticator, ConnectorClient } from "@nmshd/connector-sdk";
1
2
  import chalk from "chalk";
2
3
  import { readFile } from "fs/promises";
3
4
  import { DateTime } from "luxon";
4
5
  import prompts from "prompts";
5
- import { ConnectorClient } from "./client/ConnectorClient.js";
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 = new ConnectorClient({ 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);
@@ -18,7 +18,7 @@ export class ConnectorTUI extends ConnectorTUIBaseWithMixins {
18
18
  await this.#showStartupMessage(connectorVersionInfo);
19
19
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
20
20
  while (true) {
21
- const activeIdentityDeletionProcess = this.isDebugMode() ? await this.connectorClient.identityDeletionProcess.getActiveIdentityDeletionProcess() : undefined;
21
+ const activeIdentityDeletionProcess = this.isDebugMode() ? await this.identityDeletionProcessEndpoint.getActiveIdentityDeletionProcess() : undefined;
22
22
  if (activeIdentityDeletionProcess?.isSuccess && activeIdentityDeletionProcess.result.status === "Approved") {
23
23
  const gracePeriodEndsAtDateTime = DateTime.fromISO(activeIdentityDeletionProcess.result.gracePeriodEndsAt);
24
24
  if (gracePeriodEndsAtDateTime.diffNow().milliseconds < 0) {
@@ -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,16 +1,19 @@
1
1
  import { RelationshipStatus } from "@nmshd/connector-sdk";
2
2
  import { DateTime } from "luxon";
3
3
  import prompts from "prompts";
4
+ import { IdentityDeletionProcessEndpoint } from "./IdentityDeletionProcessEndpoint.js";
4
5
  export class ConnectorTUIBase {
5
6
  connectorClient;
6
7
  connectorAddress;
7
8
  support;
8
9
  choices = [];
9
10
  choicesInDeletion = [];
11
+ identityDeletionProcessEndpoint;
10
12
  constructor(connectorClient, connectorAddress, support) {
11
13
  this.connectorClient = connectorClient;
12
14
  this.connectorAddress = connectorAddress;
13
15
  this.support = support;
16
+ this.identityDeletionProcessEndpoint = new IdentityDeletionProcessEndpoint(this.connectorClient.account["httpClient"]);
14
17
  }
15
18
  async selectRelationship(prompt, ...status) {
16
19
  if (status.length === 0)
@@ -93,7 +96,7 @@ export class ConnectorTUIBase {
93
96
  return files.map((f) => this.renderFile(f));
94
97
  }
95
98
  renderFile(file) {
96
- return { title: file.title, value: file };
99
+ return { title: file.title ?? file.filename, value: file };
97
100
  }
98
101
  async selectAttribute(prompt, query) {
99
102
  const choices = await this.getAttributeChoices(query);
@@ -1,4 +1,4 @@
1
- import { Endpoint } from "@nmshd/connector-sdk";
1
+ import { Endpoint } from "@nmshd/connector-sdk/dist/endpoints/Endpoint.js";
2
2
  export var IdentityDeletionProcessStatus;
3
3
  (function (IdentityDeletionProcessStatus) {
4
4
  IdentityDeletionProcessStatus["WaitingForApproval"] = "WaitingForApproval";
@@ -13,7 +13,7 @@ export function AddIdentityDeletionProcess(Base) {
13
13
  }
14
14
  async identityDeletionProcess() {
15
15
  const choices = [];
16
- const activeIdentityDeletionProcess = await this.connectorClient.identityDeletionProcess.getActiveIdentityDeletionProcess();
16
+ const activeIdentityDeletionProcess = await this.identityDeletionProcessEndpoint.getActiveIdentityDeletionProcess();
17
17
  if (activeIdentityDeletionProcess.isSuccess) {
18
18
  choices.push({ title: "Show IdentityDeletionProcess", value: "Show" });
19
19
  if (activeIdentityDeletionProcess.result.status === "Approved") {
@@ -49,12 +49,12 @@ export function AddIdentityDeletionProcess(Base) {
49
49
  });
50
50
  const oneSecondInDays = 1 / (24 * 60 * 60);
51
51
  const lengthOfGracePeriodInDays = confirmation["IdentityDeletionProcess grace period"] ? oneSecondInDays : undefined;
52
- const identityDeletionProcess = (await this.connectorClient.identityDeletionProcess.initiateIdentityDeletionProcess(lengthOfGracePeriodInDays)).result;
52
+ const identityDeletionProcess = (await this.identityDeletionProcessEndpoint.initiateIdentityDeletionProcess(lengthOfGracePeriodInDays)).result;
53
53
  console.log("Identity Deletion Process initiated.");
54
54
  this.showIdentityDeletionProcesses(identityDeletionProcess);
55
55
  }
56
56
  async cancelIdentityDeletionProcess() {
57
- const identityDeletionProcess = (await this.connectorClient.identityDeletionProcess.cancelIdentityDeletionProcess()).result;
57
+ const identityDeletionProcess = (await this.identityDeletionProcessEndpoint.cancelIdentityDeletionProcess()).result;
58
58
  console.log("Identity Deletion Process canceled.");
59
59
  this.showIdentityDeletionProcesses(identityDeletionProcess);
60
60
  }
@@ -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),
@@ -283,15 +275,6 @@ export function AddSendRequestByMessage(Base) {
283
275
  type: "text",
284
276
  name: "valueType",
285
277
  },
286
- {
287
- message: "Type in the comma separated tags the fallback attribute should have",
288
- type: "text",
289
- format: (value) => value
290
- .split(",")
291
- .map((tag) => tag.trim())
292
- .filter((tag) => tag.length > 0),
293
- name: "tags",
294
- },
295
278
  ]);
296
279
  const requestItem = {
297
280
  "@type": "ReadAttributeRequestItem",
@@ -301,7 +284,6 @@ export function AddSendRequestByMessage(Base) {
301
284
  queryString: result.queryString,
302
285
  attributeCreationHints: {
303
286
  valueType: result.valueType,
304
- tags: result.tags.length > 0 ? result.tags : undefined,
305
287
  },
306
288
  },
307
289
  };
@@ -413,15 +395,6 @@ export function AddSendRequestByMessage(Base) {
413
395
  type: "text",
414
396
  name: "value",
415
397
  },
416
- {
417
- message: "Type in the comma separated tags your proposed attribute or created attributes should have",
418
- type: "text",
419
- format: (value) => value
420
- .split(",")
421
- .map((tag) => tag.trim())
422
- .filter((tag) => tag.length > 0),
423
- name: "tags",
424
- },
425
398
  ]);
426
399
  const requestItem = {
427
400
  "@type": "ProposeAttributeRequestItem",
@@ -429,10 +402,6 @@ export function AddSendRequestByMessage(Base) {
429
402
  query: {
430
403
  "@type": "IQLQuery",
431
404
  queryString: result.queryString,
432
- attributeCreationHints: {
433
- valueType: result.attributeType,
434
- tags: result.tags.length > 0 ? result.tags : undefined,
435
- },
436
405
  },
437
406
  attribute: {
438
407
  "@type": "IdentityAttribute",
@@ -441,7 +410,6 @@ export function AddSendRequestByMessage(Base) {
441
410
  "@type": result.attributeType,
442
411
  value: result.value,
443
412
  },
444
- tags: result.tags.length > 0 ? result.tags : undefined,
445
413
  },
446
414
  };
447
415
  return requestItem;
@@ -579,9 +547,9 @@ export function AddSendRequestByMessage(Base) {
579
547
  initial: true,
580
548
  },
581
549
  {
582
- message: "Do you want to require a manual decision?",
550
+ message: "Do you want to require a manual interaction?",
583
551
  type: "confirm",
584
- name: "requireManualDecision",
552
+ name: "requiresInteraction",
585
553
  initial: false,
586
554
  },
587
555
  {
@@ -606,7 +574,7 @@ export function AddSendRequestByMessage(Base) {
606
574
  const requestItem = {
607
575
  "@type": "ConsentRequestItem",
608
576
  mustBeAccepted: result.mustBeAccepted,
609
- requireManualDecision: result.requireManualDecision,
577
+ requiresInteraction: result.requiresInteraction,
610
578
  consent: result.consent,
611
579
  description: result.description,
612
580
  link: result.link,
@@ -615,24 +583,6 @@ export function AddSendRequestByMessage(Base) {
615
583
  };
616
584
  return requestItem;
617
585
  }
618
- async createRegisterAttributeListenerRequestItem() {
619
- const result = await prompts([
620
- {
621
- message: "What's the attribute type you would like to query?",
622
- type: "text",
623
- name: "attributeType",
624
- },
625
- ]);
626
- const requestItem = {
627
- "@type": "RegisterAttributeListenerRequestItem",
628
- mustBeAccepted: true,
629
- query: {
630
- "@type": "IdentityAttributeQuery",
631
- valueType: result.attributeType,
632
- },
633
- };
634
- return requestItem;
635
- }
636
586
  async createAuthenticationRequestItem() {
637
587
  const result = await prompts([
638
588
  {
@@ -911,21 +861,6 @@ export function AddSendRequestByMessage(Base) {
911
861
  };
912
862
  return requestItem;
913
863
  }
914
- async createFreeTextRequestItem() {
915
- const result = await prompts([
916
- {
917
- message: "Enter a free text",
918
- type: "text",
919
- name: "freeText",
920
- },
921
- ]);
922
- const requestItem = {
923
- "@type": "FreeTextRequestItem",
924
- mustBeAccepted: true,
925
- freeText: result.freeText,
926
- };
927
- return requestItem;
928
- }
929
864
  async createShareAttributeRequestItem() {
930
865
  const query = { content: { "@type": "IdentityAttribute", owner: this.connectorAddress }, shareInfo: { peer: "!" }, succeededBy: "!" };
931
866
  const attribute = await this.selectAttribute("Which Attribute would you like to share?", query);
@@ -943,16 +878,13 @@ export function AddSendRequestByMessage(Base) {
943
878
  const file = await this.selectFile("The ownership of which File do you want to transfer?");
944
879
  if (!file)
945
880
  return;
946
- const result = await prompts({
947
- name: "requireManualDecision",
948
- message: "Do you want to require a manual decision?",
949
- initial: false,
950
- type: "confirm",
951
- });
881
+ if (!file.ownershipToken) {
882
+ console.log("The selected file does not have an ownership token, so it cannot be transferred.");
883
+ return;
884
+ }
952
885
  const requestItem = {
953
886
  "@type": "TransferFileOwnershipRequestItem",
954
887
  mustBeAccepted: true,
955
- requireManualDecision: result.requireManualDecision,
956
888
  fileReference: file.reference.truncated,
957
889
  ownershipToken: file.ownershipToken,
958
890
  };
@@ -93,14 +93,7 @@ export function AddShareRequestByTemplate(Base) {
93
93
  const displayNameWithValue = response.result.find((attr) => attr.content.value["@type"] === "DisplayName" && attr.content.value.value === displayName);
94
94
  if (displayNameWithValue)
95
95
  return displayNameWithValue;
96
- const createAttributeResponse = await this.connectorClient.attributes.createRepositoryAttribute({
97
- content: {
98
- value: {
99
- "@type": "DisplayName",
100
- value: displayName,
101
- },
102
- },
103
- });
96
+ const createAttributeResponse = await this.connectorClient.attributes.createRepositoryAttribute({ content: { value: { "@type": "DisplayName", value: displayName } } });
104
97
  return createAttributeResponse.result;
105
98
  }
106
99
  async createPasswordProtection() {
package/package.json CHANGED
@@ -28,7 +28,7 @@
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.36.4",
31
+ "@nmshd/connector-sdk": "^7.0.0-alpha.24",
32
32
  "axios": "^1.11.0",
33
33
  "chalk": "^5.6.0",
34
34
  "dotenv": "^17.2.1",
@@ -51,11 +51,11 @@
51
51
  "typescript": "^5.9.2"
52
52
  },
53
53
  "engines": {
54
- "node": ">=22.19.0"
54
+ "node": ">=22.18.0"
55
55
  },
56
56
  "publishConfig": {
57
57
  "access": "public",
58
58
  "provenance": true
59
59
  },
60
- "version": "2.15.0"
60
+ "version": "3.0.0-alpha.2"
61
61
  }
@@ -1,9 +0,0 @@
1
- import { ConnectorClient as BaseConnectorClient } from "@nmshd/connector-sdk";
2
- import { IdentityDeletionProcessEndpoint } from "./IdentityDeletionProcessEndpoint.js";
3
- export class ConnectorClient extends BaseConnectorClient {
4
- identityDeletionProcess;
5
- constructor(config) {
6
- super(config);
7
- this.identityDeletionProcess = new IdentityDeletionProcessEndpoint(this.axiosInstance);
8
- }
9
- }