@twin.org/identity-cli 0.0.1-next.3 → 0.0.1-next.6

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.
@@ -557,8 +557,6 @@ function buildCommandVerifiableCredentialCreate() {
557
557
  .requiredOption(core.I18n.formatMessage("commands.verifiable-credential-create.options.id.param"), core.I18n.formatMessage("commands.verifiable-credential-create.options.id.description"))
558
558
  .requiredOption(core.I18n.formatMessage("commands.verifiable-credential-create.options.private-key.param"), core.I18n.formatMessage("commands.verifiable-credential-create.options.private-key.description"))
559
559
  .option(core.I18n.formatMessage("commands.verifiable-credential-create.options.credential-id.param"), core.I18n.formatMessage("commands.verifiable-credential-create.options.credential-id.description"))
560
- .option(core.I18n.formatMessage("commands.verifiable-credential-create.options.types.param"), core.I18n.formatMessage("commands.verifiable-credential-create.options.types.description"))
561
- .option(core.I18n.formatMessage("commands.verifiable-credential-create.options.contexts.param"), core.I18n.formatMessage("commands.verifiable-credential-create.options.contexts.description"))
562
560
  .requiredOption(core.I18n.formatMessage("commands.verifiable-credential-create.options.subject-json.param"), core.I18n.formatMessage("commands.verifiable-credential-create.options.subject-json.description"))
563
561
  .option(core.I18n.formatMessage("commands.verifiable-credential-create.options.revocation-index.param"), core.I18n.formatMessage("commands.verifiable-credential-create.options.revocation-index.description"));
564
562
  cliCore.CLIOptions.output(command, {
@@ -579,35 +577,19 @@ function buildCommandVerifiableCredentialCreate() {
579
577
  * @param opts.id The id of the verification method to use for the credential.
580
578
  * @param opts.privateKey The private key for the verification method.
581
579
  * @param opts.credentialId The id of the credential.
582
- * @param opts.types The types for the credential.
583
580
  * @param opts.subjectJson The JSON data for the subject.
584
- * @param opts.contexts The contexts for the credential.
585
581
  * @param opts.revocationIndex The revocation index for the credential.
586
582
  * @param opts.node The node URL.
587
583
  */
588
584
  async function actionCommandVerifiableCredentialCreate(opts) {
589
- if (!core.Is.undefined(opts.types)) {
590
- core.Guards.arrayValue("commands", "types", opts.types);
591
- }
592
- if (!core.Is.undefined(opts.contexts)) {
593
- core.Guards.arrayValue("commands", "contexts", opts.contexts);
594
- }
595
585
  const id = cliCore.CLIParam.stringValue("id", opts.id);
596
586
  const privateKey = cliCore.CLIParam.hexBase64("private-key", opts.privateKey);
597
587
  const credentialId = cliCore.CLIParam.stringValue("credential-id", opts.credentialId);
598
- const types = opts.types;
599
- const contexts = opts.contexts;
600
588
  const subjectJson = path.resolve(cliCore.CLIParam.stringValue("subject-json", opts.subjectJson));
601
589
  const revocationIndex = core.Coerce.number(opts.revocationIndex);
602
590
  const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
603
591
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.verifiable-credential-create.labels.verificationMethodId"), id);
604
592
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.verifiable-credential-create.labels.credentialId"), credentialId);
605
- if (core.Is.arrayValue(types)) {
606
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.verifiable-credential-create.labels.types"), types.join(","));
607
- }
608
- if (core.Is.arrayValue(contexts)) {
609
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.verifiable-credential-create.labels.contexts"), contexts.join(","));
610
- }
611
593
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.verifiable-credential-create.labels.subjectJson"), subjectJson);
612
594
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.verifiable-credential-create.labels.revocationIndex"), revocationIndex);
613
595
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
@@ -642,7 +624,7 @@ async function actionCommandVerifiableCredentialCreate(opts) {
642
624
  cliCore.CLIDisplay.task(core.I18n.formatMessage("commands.verifiable-credential-create.progress.creatingVerifiableCredential"));
643
625
  cliCore.CLIDisplay.break();
644
626
  cliCore.CLIDisplay.spinnerStart();
645
- const verifiableCredential = await iotaIdentityConnector.createVerifiableCredential(localIdentity, id, credentialId, types, jsonData, contexts, revocationIndex);
627
+ const verifiableCredential = await iotaIdentityConnector.createVerifiableCredential(localIdentity, id, credentialId, jsonData, revocationIndex);
646
628
  cliCore.CLIDisplay.spinnerStop();
647
629
  if (opts.console) {
648
630
  cliCore.CLIDisplay.section(core.I18n.formatMessage("commands.verifiable-credential-create.labels.verifiableCredential"));
@@ -1072,15 +1054,18 @@ class CLI extends cliCore.CLIBase {
1072
1054
  * Run the app.
1073
1055
  * @param argv The process arguments.
1074
1056
  * @param localesDirectory The directory for the locales, default to relative to the script.
1057
+ * @param options Additional options for the CLI.
1058
+ * @param options.overrideOutputWidth The override output width.
1075
1059
  * @returns The exit code.
1076
1060
  */
1077
- async run(argv, localesDirectory) {
1061
+ async run(argv, localesDirectory, options) {
1078
1062
  return this.execute({
1079
1063
  title: "TWIN Identity",
1080
1064
  appName: "twin-identity",
1081
1065
  version: "0.0.3-next.18",
1082
1066
  icon: "🌍",
1083
- supportsEnvFiles: true
1067
+ supportsEnvFiles: true,
1068
+ overrideOutputWidth: options?.overrideOutputWidth
1084
1069
  }, localesDirectory ?? path.join(path.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)))), "../locales"), argv);
1085
1070
  }
1086
1071
  /**
@@ -3,7 +3,7 @@ import { fileURLToPath } from 'node:url';
3
3
  import { CLIOptions, CLIParam, CLIDisplay, CLIUtils, CLIBase } from '@twin.org/cli-core';
4
4
  import { buildCommandMnemonic, buildCommandAddress } from '@twin.org/crypto-cli';
5
5
  import { buildCommandFaucet, buildCommandTransfer } from '@twin.org/wallet-cli';
6
- import { I18n, Converter, Is, StringHelper, Guards, Coerce, GeneralError } from '@twin.org/core';
6
+ import { I18n, Converter, Is, StringHelper, Coerce, GeneralError } from '@twin.org/core';
7
7
  import { IotaIdentityConnector, IotaIdentityUtils } from '@twin.org/identity-connector-iota';
8
8
  import { VaultConnectorFactory, VaultKeyType } from '@twin.org/vault-models';
9
9
  import { IotaWalletConnector } from '@twin.org/wallet-connector-iota';
@@ -554,8 +554,6 @@ function buildCommandVerifiableCredentialCreate() {
554
554
  .requiredOption(I18n.formatMessage("commands.verifiable-credential-create.options.id.param"), I18n.formatMessage("commands.verifiable-credential-create.options.id.description"))
555
555
  .requiredOption(I18n.formatMessage("commands.verifiable-credential-create.options.private-key.param"), I18n.formatMessage("commands.verifiable-credential-create.options.private-key.description"))
556
556
  .option(I18n.formatMessage("commands.verifiable-credential-create.options.credential-id.param"), I18n.formatMessage("commands.verifiable-credential-create.options.credential-id.description"))
557
- .option(I18n.formatMessage("commands.verifiable-credential-create.options.types.param"), I18n.formatMessage("commands.verifiable-credential-create.options.types.description"))
558
- .option(I18n.formatMessage("commands.verifiable-credential-create.options.contexts.param"), I18n.formatMessage("commands.verifiable-credential-create.options.contexts.description"))
559
557
  .requiredOption(I18n.formatMessage("commands.verifiable-credential-create.options.subject-json.param"), I18n.formatMessage("commands.verifiable-credential-create.options.subject-json.description"))
560
558
  .option(I18n.formatMessage("commands.verifiable-credential-create.options.revocation-index.param"), I18n.formatMessage("commands.verifiable-credential-create.options.revocation-index.description"));
561
559
  CLIOptions.output(command, {
@@ -576,35 +574,19 @@ function buildCommandVerifiableCredentialCreate() {
576
574
  * @param opts.id The id of the verification method to use for the credential.
577
575
  * @param opts.privateKey The private key for the verification method.
578
576
  * @param opts.credentialId The id of the credential.
579
- * @param opts.types The types for the credential.
580
577
  * @param opts.subjectJson The JSON data for the subject.
581
- * @param opts.contexts The contexts for the credential.
582
578
  * @param opts.revocationIndex The revocation index for the credential.
583
579
  * @param opts.node The node URL.
584
580
  */
585
581
  async function actionCommandVerifiableCredentialCreate(opts) {
586
- if (!Is.undefined(opts.types)) {
587
- Guards.arrayValue("commands", "types", opts.types);
588
- }
589
- if (!Is.undefined(opts.contexts)) {
590
- Guards.arrayValue("commands", "contexts", opts.contexts);
591
- }
592
582
  const id = CLIParam.stringValue("id", opts.id);
593
583
  const privateKey = CLIParam.hexBase64("private-key", opts.privateKey);
594
584
  const credentialId = CLIParam.stringValue("credential-id", opts.credentialId);
595
- const types = opts.types;
596
- const contexts = opts.contexts;
597
585
  const subjectJson = path.resolve(CLIParam.stringValue("subject-json", opts.subjectJson));
598
586
  const revocationIndex = Coerce.number(opts.revocationIndex);
599
587
  const nodeEndpoint = CLIParam.url("node", opts.node);
600
588
  CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-create.labels.verificationMethodId"), id);
601
589
  CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-create.labels.credentialId"), credentialId);
602
- if (Is.arrayValue(types)) {
603
- CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-create.labels.types"), types.join(","));
604
- }
605
- if (Is.arrayValue(contexts)) {
606
- CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-create.labels.contexts"), contexts.join(","));
607
- }
608
590
  CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-create.labels.subjectJson"), subjectJson);
609
591
  CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-create.labels.revocationIndex"), revocationIndex);
610
592
  CLIDisplay.value(I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
@@ -639,7 +621,7 @@ async function actionCommandVerifiableCredentialCreate(opts) {
639
621
  CLIDisplay.task(I18n.formatMessage("commands.verifiable-credential-create.progress.creatingVerifiableCredential"));
640
622
  CLIDisplay.break();
641
623
  CLIDisplay.spinnerStart();
642
- const verifiableCredential = await iotaIdentityConnector.createVerifiableCredential(localIdentity, id, credentialId, types, jsonData, contexts, revocationIndex);
624
+ const verifiableCredential = await iotaIdentityConnector.createVerifiableCredential(localIdentity, id, credentialId, jsonData, revocationIndex);
643
625
  CLIDisplay.spinnerStop();
644
626
  if (opts.console) {
645
627
  CLIDisplay.section(I18n.formatMessage("commands.verifiable-credential-create.labels.verifiableCredential"));
@@ -1069,15 +1051,18 @@ class CLI extends CLIBase {
1069
1051
  * Run the app.
1070
1052
  * @param argv The process arguments.
1071
1053
  * @param localesDirectory The directory for the locales, default to relative to the script.
1054
+ * @param options Additional options for the CLI.
1055
+ * @param options.overrideOutputWidth The override output width.
1072
1056
  * @returns The exit code.
1073
1057
  */
1074
- async run(argv, localesDirectory) {
1058
+ async run(argv, localesDirectory, options) {
1075
1059
  return this.execute({
1076
1060
  title: "TWIN Identity",
1077
1061
  appName: "twin-identity",
1078
1062
  version: "0.0.3-next.18",
1079
1063
  icon: "🌍",
1080
- supportsEnvFiles: true
1064
+ supportsEnvFiles: true,
1065
+ overrideOutputWidth: options?.overrideOutputWidth
1081
1066
  }, localesDirectory ?? path.join(path.dirname(fileURLToPath(import.meta.url)), "../locales"), argv);
1082
1067
  }
1083
1068
  /**
@@ -389,17 +389,9 @@
389
389
  "param": "--credential-id '<'credential-id'>'",
390
390
  "description": "The credential id which uniquely identifies the credential."
391
391
  },
392
- "types": {
393
- "param": "--types [types...]",
394
- "description": "The list of types to include in the verifiable credential."
395
- },
396
392
  "subject-json": {
397
393
  "param": "--subject-json '<'subject-json'>'",
398
- "description": "A JSON file to read which includes the data for the verifiable credential."
399
- },
400
- "contexts": {
401
- "param": "--contexts [contexts...]",
402
- "description": "The list of contexts to include in the verifiable credential."
394
+ "description": "A JSON-LD file to read which includes the data for the verifiable credential."
403
395
  },
404
396
  "revocation-index": {
405
397
  "param": "--revocation-index '<'revocation-index'>'",
@@ -413,8 +405,6 @@
413
405
  "labels": {
414
406
  "verificationMethodId": "Verification Method Id",
415
407
  "credentialId": "Credential Id",
416
- "types": "Types",
417
- "contexts": "Contexts",
418
408
  "subjectJson": "Subject JSON",
419
409
  "revocationIndex": "Revocation Index",
420
410
  "verifiableCredential": "Verifiable Credential"
@@ -586,6 +576,10 @@
586
576
  "env": {
587
577
  "param": "--env '<'filename'>'",
588
578
  "description": "Creates an env file containing the mnemonic and seed."
579
+ },
580
+ "env-prefix": {
581
+ "param": "--env-prefix '<'prefix'>'",
582
+ "description": "Prefixes the env variables with the value."
589
583
  }
590
584
  },
591
585
  "progress": {
@@ -594,7 +588,8 @@
594
588
  },
595
589
  "labels": {
596
590
  "mnemonic": "Mnemonic",
597
- "seed": "Seed"
591
+ "seed": "Seed",
592
+ "envPrefix": "Env Prefix"
598
593
  }
599
594
  },
600
595
  "address": {
@@ -763,6 +758,14 @@
763
758
  }
764
759
  }
765
760
  },
761
+ "jsonLdProcessor": {
762
+ "compact": "The JSON-LD compaction failed",
763
+ "expand": "The JSON-LD expansion failed",
764
+ "invalidUrl": "The JSON-LD processing failed to retrieve from the following url \"{url}\""
765
+ },
766
+ "errorMessages": {
767
+ "fetch": "Fetch"
768
+ },
766
769
  "identityRole": {
767
770
  "organization": "Organization",
768
771
  "user": "User",
@@ -773,12 +776,5 @@
773
776
  "rejected": "Rejected",
774
777
  "issued": "Issued",
775
778
  "revoked": "Revoked"
776
- },
777
- "errorMessages": {
778
- "fetch": "Fetch"
779
- },
780
- "jsonLdHelper": {
781
- "compact": "The JSON-LD compaction failed",
782
- "expand": "The JSON-LD expansion failed"
783
779
  }
784
780
  }
@@ -7,7 +7,11 @@ export declare class CLI extends CLIBase {
7
7
  * Run the app.
8
8
  * @param argv The process arguments.
9
9
  * @param localesDirectory The directory for the locales, default to relative to the script.
10
+ * @param options Additional options for the CLI.
11
+ * @param options.overrideOutputWidth The override output width.
10
12
  * @returns The exit code.
11
13
  */
12
- run(argv: string[], localesDirectory?: string): Promise<number>;
14
+ run(argv: string[], localesDirectory?: string, options?: {
15
+ overrideOutputWidth?: number;
16
+ }): Promise<number>;
13
17
  }
@@ -11,9 +11,7 @@ export declare function buildCommandVerifiableCredentialCreate(): Command;
11
11
  * @param opts.id The id of the verification method to use for the credential.
12
12
  * @param opts.privateKey The private key for the verification method.
13
13
  * @param opts.credentialId The id of the credential.
14
- * @param opts.types The types for the credential.
15
14
  * @param opts.subjectJson The JSON data for the subject.
16
- * @param opts.contexts The contexts for the credential.
17
15
  * @param opts.revocationIndex The revocation index for the credential.
18
16
  * @param opts.node The node URL.
19
17
  */
@@ -21,9 +19,7 @@ export declare function actionCommandVerifiableCredentialCreate(opts: {
21
19
  id: string;
22
20
  privateKey: string;
23
21
  credentialId?: string;
24
- types?: string[];
25
22
  subjectJson: string;
26
- contexts?: string[];
27
23
  revocationIndex?: string;
28
24
  node: string;
29
25
  } & CliOutputOptions): Promise<void>;
package/docs/changelog.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # @twin.org/identity-cli - Changelog
2
2
 
3
- ## v0.0.1-next.3
3
+ ## v0.0.1-next.6
4
4
 
5
5
  - Initial Release
package/docs/examples.md CHANGED
@@ -1,17 +1,18 @@
1
1
  # @twin.org/identity-cli - Examples
2
2
 
3
- ## Command Line Tool
3
+ ## Running
4
4
 
5
- First install the tool with the following script.
5
+ To install and run the CLI locally use the following commands:
6
6
 
7
7
  ```shell
8
- npm install @twin.org/identity-cli
8
+ npm install @twin.org/identity-cli -g
9
+ twin-identity
9
10
  ```
10
11
 
11
- Running the tool with no commands will provide help for all the commands. By issuing the following command you should see the result.
12
+ or run directly using NPX:
12
13
 
13
14
  ```shell
14
- twin-identity
15
+ npx "@twin.org/identity-cli"
15
16
  ```
16
17
 
17
18
  Output
@@ -24,7 +24,7 @@ The main entry point for the CLI.
24
24
 
25
25
  ### run()
26
26
 
27
- > **run**(`argv`, `localesDirectory`?): `Promise`\<`number`\>
27
+ > **run**(`argv`, `localesDirectory`?, `options`?): `Promise`\<`number`\>
28
28
 
29
29
  Run the app.
30
30
 
@@ -38,6 +38,14 @@ The process arguments.
38
38
 
39
39
  The directory for the locales, default to relative to the script.
40
40
 
41
+ • **options?**
42
+
43
+ Additional options for the CLI.
44
+
45
+ • **options.overrideOutputWidth?**: `number`
46
+
47
+ The override output width.
48
+
41
49
  #### Returns
42
50
 
43
51
  `Promise`\<`number`\>
package/locales/en.json CHANGED
@@ -164,17 +164,9 @@
164
164
  "param": "--credential-id '<'credential-id'>'",
165
165
  "description": "The credential id which uniquely identifies the credential."
166
166
  },
167
- "types": {
168
- "param": "--types [types...]",
169
- "description": "The list of types to include in the verifiable credential."
170
- },
171
167
  "subject-json": {
172
168
  "param": "--subject-json '<'subject-json'>'",
173
- "description": "A JSON file to read which includes the data for the verifiable credential."
174
- },
175
- "contexts": {
176
- "param": "--contexts [contexts...]",
177
- "description": "The list of contexts to include in the verifiable credential."
169
+ "description": "A JSON-LD file to read which includes the data for the verifiable credential."
178
170
  },
179
171
  "revocation-index": {
180
172
  "param": "--revocation-index '<'revocation-index'>'",
@@ -188,8 +180,6 @@
188
180
  "labels": {
189
181
  "verificationMethodId": "Verification Method Id",
190
182
  "credentialId": "Credential Id",
191
- "types": "Types",
192
- "contexts": "Contexts",
193
183
  "subjectJson": "Subject JSON",
194
184
  "revocationIndex": "Revocation Index",
195
185
  "verifiableCredential": "Verifiable Credential"
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@twin.org/identity-cli",
3
- "version": "0.0.1-next.3",
3
+ "version": "0.0.1-next.6",
4
4
  "description": "A command line interface for interacting with the identity connectors",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/twinfoundation/identity.git",
8
- "directory": "packages/identity-cli"
8
+ "directory": "apps/identity-cli"
9
9
  },
10
10
  "author": "martyn.janes@iota.org",
11
11
  "license": "Apache-2.0",
@@ -13,29 +13,17 @@
13
13
  "engines": {
14
14
  "node": ">=20.0.0"
15
15
  },
16
- "scripts": {
17
- "clean": "rimraf dist coverage",
18
- "build": "tspc",
19
- "merge-locales": "merge-locales",
20
- "test": "vitest --run --config ./vitest.config.ts --no-cache",
21
- "coverage": "vitest --run --coverage --config ./vitest.config.ts --no-cache",
22
- "bundle:esm": "rollup --config rollup.config.mjs --environment MODULE:esm",
23
- "bundle:cjs": "rollup --config rollup.config.mjs --environment MODULE:cjs",
24
- "bundle": "npm run bundle:esm && npm run bundle:cjs",
25
- "docs:clean": "rimraf docs/reference",
26
- "docs:generate": "typedoc",
27
- "docs": "npm run docs:clean && npm run docs:generate",
28
- "dist": "npm run clean && npm run build && npm run merge-locales && npm run test && npm run bundle && npm run docs"
29
- },
30
16
  "dependencies": {
17
+ "@iota/sdk-wasm": "1.1.3",
18
+ "@twin.org/cli-core": "next",
31
19
  "@twin.org/core": "next",
32
20
  "@twin.org/crypto": "next",
33
- "@twin.org/cli-core": "next",
34
21
  "@twin.org/crypto-cli": "next",
22
+ "@twin.org/data-json-ld": "next",
35
23
  "@twin.org/entity": "next",
36
24
  "@twin.org/entity-storage-connector-memory": "next",
37
- "@twin.org/identity-models": "0.0.1-next.3",
38
- "@twin.org/identity-connector-iota": "0.0.1-next.3",
25
+ "@twin.org/identity-connector-iota": "0.0.1-next.6",
26
+ "@twin.org/identity-models": "0.0.1-next.6",
39
27
  "@twin.org/nameof": "next",
40
28
  "@twin.org/standards-w3c-did": "next",
41
29
  "@twin.org/vault-connector-entity-storage": "next",
@@ -43,24 +31,8 @@
43
31
  "@twin.org/wallet-cli": "next",
44
32
  "@twin.org/wallet-connector-iota": "next",
45
33
  "@twin.org/wallet-models": "next",
46
- "@iota/sdk-wasm": "1.1.3",
47
34
  "commander": "12.1.0"
48
35
  },
49
- "devDependencies": {
50
- "@twin.org/merge-locales": "next",
51
- "@twin.org/nameof-transformer": "next",
52
- "@types/node": "22.5.5",
53
- "@vitest/coverage-v8": "2.1.1",
54
- "copyfiles": "2.4.1",
55
- "rimraf": "6.0.1",
56
- "rollup": "4.22.0",
57
- "rollup-plugin-typescript2": "0.36.0",
58
- "ts-patch": "3.2.1",
59
- "typedoc": "0.26.7",
60
- "typedoc-plugin-markdown": "4.2.7",
61
- "typescript": "5.6.2",
62
- "vitest": "2.1.1"
63
- },
64
36
  "main": "./dist/cjs/index.cjs",
65
37
  "module": "./dist/esm/index.mjs",
66
38
  "types": "./dist/types/index.d.ts",