@nmshd/connector-tui 0.1.3 → 0.2.0

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.
@@ -30,6 +30,10 @@ export function AddSendRequestByMessage(Base) {
30
30
  title: "CreateRelationshipAttributeRequestItem",
31
31
  value: this.createCreateRelationshipAttributeRequestItem.bind(this),
32
32
  },
33
+ {
34
+ title: "CreateRelationshipAttributeRequestItem with Boolean value",
35
+ value: this.createCreateRelationshipAttributeRequestItemWithBooleanValue.bind(this),
36
+ },
33
37
  {
34
38
  title: "CreateIdentityAttributeRequestItem",
35
39
  value: this.createCreateIdentityAttributeRequestItem.bind(this),
@@ -290,6 +294,44 @@ export function AddSendRequestByMessage(Base) {
290
294
  };
291
295
  return requestItem;
292
296
  }
297
+ async createCreateRelationshipAttributeRequestItemWithBooleanValue() {
298
+ const result = await prompts([
299
+ {
300
+ message: "What's the title of the RelationshipAttribute you would like to create?",
301
+ type: "text",
302
+ name: "title",
303
+ initial: "Title of RelationshipAttribute",
304
+ },
305
+ {
306
+ message: "What's the key of the RelationshipAttribute you would like to create?",
307
+ type: "text",
308
+ name: "key",
309
+ initial: "Key of RelationshipAttribute",
310
+ },
311
+ {
312
+ message: "What's the value of your Boolean Attribute?",
313
+ type: "toggle",
314
+ name: "value",
315
+ },
316
+ ]);
317
+ const requestItem = {
318
+ "@type": "CreateAttributeRequestItem",
319
+ mustBeAccepted: true,
320
+ attribute: {
321
+ "@type": "RelationshipAttribute",
322
+ owner: "",
323
+ key: result.key,
324
+ confidentiality: "public",
325
+ isTechnical: true,
326
+ value: {
327
+ "@type": "ProprietaryBoolean",
328
+ value: result.value,
329
+ title: result.title,
330
+ },
331
+ },
332
+ };
333
+ return requestItem;
334
+ }
293
335
  async createCreateIdentityAttributeRequestItem(peer) {
294
336
  const result = await prompts([
295
337
  {
@@ -303,27 +345,21 @@ export function AddSendRequestByMessage(Base) {
303
345
  name: "value",
304
346
  },
305
347
  ]);
306
- return await this.connectorClient.outgoingRequests.createRequest({
307
- peer,
308
- content: {
309
- items: [
310
- {
311
- "@type": "CreateAttributeRequestItem",
312
- mustBeAccepted: true,
313
- attribute: {
314
- "@type": "IdentityAttribute",
315
- owner: peer,
316
- value: {
317
- "@type": result.valueType,
318
- value: result.value,
319
- },
320
- },
321
- },
322
- ],
348
+ const requestItem = {
349
+ "@type": "CreateAttributeRequestItem",
350
+ mustBeAccepted: true,
351
+ attribute: {
352
+ "@type": "IdentityAttribute",
353
+ owner: peer,
354
+ value: {
355
+ "@type": result.valueType,
356
+ value: result.value,
357
+ },
323
358
  },
324
- });
359
+ };
360
+ return requestItem;
325
361
  }
326
- async createConsentRequestItem(peer) {
362
+ async createConsentRequestItem() {
327
363
  const result = await prompts([
328
364
  {
329
365
  message: "What's the consent the peer should agree to?",
@@ -343,22 +379,16 @@ export function AddSendRequestByMessage(Base) {
343
379
  ]);
344
380
  const responseMetadata = result.consentKey ? { consentKey: result.consentKey } : undefined;
345
381
  const link = result.link ? result.link : undefined;
346
- return await this.connectorClient.outgoingRequests.createRequest({
347
- peer,
348
- content: {
349
- items: [
350
- {
351
- "@type": "ConsentRequestItem",
352
- mustBeAccepted: true,
353
- consent: result.consent,
354
- link,
355
- responseMetadata,
356
- },
357
- ],
358
- },
359
- });
382
+ const requestItem = {
383
+ "@type": "ConsentRequestItem",
384
+ mustBeAccepted: true,
385
+ consent: result.consent,
386
+ link,
387
+ responseMetadata,
388
+ };
389
+ return requestItem;
360
390
  }
361
- async createAuthenticationRequestItem(peer) {
391
+ async createAuthenticationRequestItem() {
362
392
  const result = await prompts([
363
393
  {
364
394
  message: "Enter a title of the authentication",
@@ -372,19 +402,13 @@ export function AddSendRequestByMessage(Base) {
372
402
  },
373
403
  ]);
374
404
  const responseMetadata = result.authenticationToken ? { authenticationToken: result.authenticationToken } : undefined;
375
- return await this.connectorClient.outgoingRequests.createRequest({
376
- peer,
377
- content: {
378
- items: [
379
- {
380
- "@type": "AuthenticationRequestItem",
381
- mustBeAccepted: true,
382
- title: result.title,
383
- responseMetadata,
384
- },
385
- ],
386
- },
387
- });
405
+ const requestItem = {
406
+ "@type": "AuthenticationRequestItem",
407
+ mustBeAccepted: true,
408
+ title: result.title,
409
+ responseMetadata,
410
+ };
411
+ return requestItem;
388
412
  }
389
413
  };
390
414
  }
@@ -101,7 +101,7 @@ export function AddShareRequestByTemplate(Base) {
101
101
  });
102
102
  const templateId = template.result.id;
103
103
  const tokenResponse = await this.connectorClient.relationshipTemplates.createTokenForOwnRelationshipTemplate(templateId);
104
- const url = `nmshd://qr#${tokenResponse.result.truncatedReference}`;
104
+ const url = `nmshd://tr#${tokenResponse.result.truncatedReference}`;
105
105
  console.log(url);
106
106
  qrcode.generate(url, { small: true });
107
107
  }
@@ -0,0 +1,21 @@
1
+ import { DateTime } from "luxon";
2
+ import qrcode from "qrcode-terminal";
3
+ export function AddCreateAndShowTemplate(Base) {
4
+ return class CreateAndShowTemplate extends Base {
5
+ constructor(...args) {
6
+ super(...args);
7
+ this.choices.push({ title: "Create And Show Template", value: this.createAndShowTemplate });
8
+ }
9
+ async createAndShowTemplate() {
10
+ const template = await this.connectorClient.relationshipTemplates.createOwnRelationshipTemplate({
11
+ content: {},
12
+ expiresAt: DateTime.now().plus({ days: 2 }).toISO(),
13
+ });
14
+ const templateId = template.result.id;
15
+ const tokenResponse = await this.connectorClient.relationshipTemplates.createTokenForOwnRelationshipTemplate(templateId);
16
+ const url = `nmshd://tr#${tokenResponse.result.truncatedReference}`;
17
+ console.log(url);
18
+ qrcode.generate(url, { small: true });
19
+ }
20
+ };
21
+ }
@@ -48,7 +48,7 @@ export function AddUploadFile(Base) {
48
48
  initial: true,
49
49
  });
50
50
  if (render.yesno) {
51
- const url = `nmshd://qr#${uploadedFile.result.truncatedReference}`;
51
+ const url = `nmshd://tr#${uploadedFile.result.truncatedReference}`;
52
52
  console.log(url);
53
53
  qrcode.generate(url, { small: true });
54
54
  }
@@ -6,25 +6,12 @@ import { AddGetAttributesOfRelationship } from "./AddGetAttributesOfRelationship
6
6
  import { AddSendMail } from "./AddSendMail";
7
7
  import { AddSendRequestByMessage } from "./AddSendRequestByMessage";
8
8
  import { AddShareRequestByTemplate } from "./AddShareRequestByTemplate";
9
+ import { AddCreateAndShowTemplate } from "./AddShowTemplate";
9
10
  import { AddSync } from "./AddSync";
10
11
  import { AddUploadFile } from "./AddUploadFile";
11
12
  export class ConnectorTUIBaseWithMixins
12
13
  //
13
- extends AddExit(
14
+ extends AddExit(AddCreateAndShowTemplate(AddAcceptPendingRelationships(AddAcceptPendingRequests(AddGetAttributesOfRelationship(AddSendMail(AddSendRequestByMessage(AddShareRequestByTemplate(AddSync(AddUploadFile(
14
15
  //
15
- AddAcceptPendingRelationships(AddAcceptPendingRequests(
16
- //
17
- AddGetAttributesOfRelationship(
18
- //
19
- AddSendMail(
20
- //
21
- AddSendRequestByMessage(
22
- //
23
- AddShareRequestByTemplate(
24
- //
25
- AddSync(
26
- //
27
- AddUploadFile(
28
- //
29
- ConnectorTUIBase))))))))) {
16
+ ConnectorTUIBase)))))))))) {
30
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nmshd/connector-tui",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "repository": "github:nmshd/connector-tui",
5
5
  "license": "MIT",
6
6
  "author": "j&s-soft GmbH",
@@ -24,26 +24,26 @@
24
24
  "test": "echo 'no test specified'"
25
25
  },
26
26
  "dependencies": {
27
- "@nmshd/connector-sdk": "^2.1.4",
28
- "chalk": "^5.2.0",
29
- "dotenv": "^16.0.3",
30
- "luxon": "^3.2.1",
27
+ "@nmshd/connector-sdk": "^2.2.0",
28
+ "chalk": "^5.3.0",
29
+ "dotenv": "^16.3.1",
30
+ "luxon": "^3.4.0",
31
31
  "prompts": "^2.4.2",
32
32
  "qrcode-terminal": "^0.12.0",
33
- "yargs": "^17.6.2"
33
+ "yargs": "^17.7.2"
34
34
  },
35
35
  "devDependencies": {
36
- "@js-soft/eslint-config-ts": "^1.6.2",
36
+ "@js-soft/eslint-config-ts": "^1.6.3",
37
37
  "@js-soft/license-check": "^1.0.6",
38
- "@types/luxon": "^3.2.0",
39
- "@types/node": "^18.11.18",
40
- "@types/prompts": "^2.4.2",
38
+ "@types/luxon": "^3.3.1",
39
+ "@types/node": "^20.5.0",
40
+ "@types/prompts": "^2.4.4",
41
41
  "@types/qrcode-terminal": "^0.12.0",
42
- "@types/yargs": "^17.0.20",
43
- "eslint": "^8.33.0",
44
- "prettier": "^2.8.3",
42
+ "@types/yargs": "^17.0.24",
43
+ "eslint": "^8.47.0",
44
+ "prettier": "^3.0.1",
45
45
  "ts-node": "^10.9.1",
46
- "typescript": "^4.9.4"
46
+ "typescript": "^5.1.6"
47
47
  },
48
48
  "publishConfig": {
49
49
  "access": "public"