@twin.org/crypto-cli 0.0.2-next.9 → 0.0.3-next.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.
package/bin/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  // Copyright 2024 IOTA Stiftung.
3
3
  // SPDX-License-Identifier: Apache-2.0.
4
- import { CLI } from '../dist/esm/index.mjs';
4
+ import { CLI } from '../dist/es/index.js';
5
5
 
6
6
  const cli = new CLI();
7
7
  const result = await cli.run(process.argv);
package/dist/es/cli.js ADDED
@@ -0,0 +1,40 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import path from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { CLIBase } from "@twin.org/cli-core";
6
+ import { buildCommandAddress } from "./commands/address.js";
7
+ import { buildCommandMnemonic } from "./commands/mnemonic.js";
8
+ /**
9
+ * The main entry point for the CLI.
10
+ */
11
+ export class CLI extends CLIBase {
12
+ /**
13
+ * Run the app.
14
+ * @param argv The process arguments.
15
+ * @param localesDirectory The directory for the locales, default to relative to the script.
16
+ * @param options Additional options.
17
+ * @param options.overrideOutputWidth Override the output width.
18
+ * @returns The exit code.
19
+ */
20
+ async run(argv, localesDirectory, options) {
21
+ return this.execute({
22
+ title: "TWIN Crypto",
23
+ appName: "twin-crypto",
24
+ version: "0.0.3-next.2", // x-release-please-version
25
+ icon: "🌍",
26
+ supportsEnvFiles: true,
27
+ overrideOutputWidth: options?.overrideOutputWidth,
28
+ showDevToolWarning: true
29
+ }, localesDirectory ?? path.join(path.dirname(fileURLToPath(import.meta.url)), "../locales"), argv);
30
+ }
31
+ /**
32
+ * Get the commands for the CLI.
33
+ * @param program The main program to add the commands to.
34
+ * @internal
35
+ */
36
+ getCommands(program) {
37
+ return [buildCommandMnemonic(), buildCommandAddress()];
38
+ }
39
+ }
40
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;GAEG;AACH,MAAM,OAAO,GAAI,SAAQ,OAAO;IAC/B;;;;;;;OAOG;IACI,KAAK,CAAC,GAAG,CACf,IAAc,EACd,gBAAyB,EACzB,OAA0C;QAE1C,OAAO,IAAI,CAAC,OAAO,CAClB;YACC,KAAK,EAAE,aAAa;YACpB,OAAO,EAAE,aAAa;YACtB,OAAO,EAAE,cAAc,EAAE,2BAA2B;YACpD,IAAI,EAAE,IAAI;YACV,gBAAgB,EAAE,IAAI;YACtB,mBAAmB,EAAE,OAAO,EAAE,mBAAmB;YACjD,kBAAkB,EAAE,IAAI;SACxB,EACD,gBAAgB,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC,EACzF,IAAI,CACJ,CAAC;IACH,CAAC;IAED;;;;OAIG;IACO,WAAW,CAAC,OAAgB;QACrC,OAAO,CAAC,oBAAoB,EAAE,EAAE,mBAAmB,EAAE,CAAC,CAAC;IACxD,CAAC;CACD","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { CLIBase } from \"@twin.org/cli-core\";\nimport type { Command } from \"commander\";\nimport { buildCommandAddress } from \"./commands/address.js\";\nimport { buildCommandMnemonic } from \"./commands/mnemonic.js\";\n\n/**\n * The main entry point for the CLI.\n */\nexport class CLI extends CLIBase {\n\t/**\n\t * Run the app.\n\t * @param argv The process arguments.\n\t * @param localesDirectory The directory for the locales, default to relative to the script.\n\t * @param options Additional options.\n\t * @param options.overrideOutputWidth Override the output width.\n\t * @returns The exit code.\n\t */\n\tpublic async run(\n\t\targv: string[],\n\t\tlocalesDirectory?: string,\n\t\toptions?: { overrideOutputWidth?: number }\n\t): Promise<number> {\n\t\treturn this.execute(\n\t\t\t{\n\t\t\t\ttitle: \"TWIN Crypto\",\n\t\t\t\tappName: \"twin-crypto\",\n\t\t\t\tversion: \"0.0.3-next.2\", // x-release-please-version\n\t\t\t\ticon: \"🌍\",\n\t\t\t\tsupportsEnvFiles: true,\n\t\t\t\toverrideOutputWidth: options?.overrideOutputWidth,\n\t\t\t\tshowDevToolWarning: true\n\t\t\t},\n\t\t\tlocalesDirectory ?? path.join(path.dirname(fileURLToPath(import.meta.url)), \"../locales\"),\n\t\t\targv\n\t\t);\n\t}\n\n\t/**\n\t * Get the commands for the CLI.\n\t * @param program The main program to add the commands to.\n\t * @internal\n\t */\n\tprotected getCommands(program: Command): Command[] {\n\t\treturn [buildCommandMnemonic(), buildCommandAddress()];\n\t}\n}\n"]}
@@ -1,17 +1,14 @@
1
- import path from 'node:path';
2
- import { fileURLToPath } from 'node:url';
3
- import { CLIOptions, CLIParam, CLIDisplay, CLIUtils, CLIBase } from '@twin.org/cli-core';
4
- import { I18n, Converter, Is } from '@twin.org/core';
5
- import { Bip44, KeyType, Bip39 } from '@twin.org/crypto';
6
- import { Command, Option } from 'commander';
7
-
8
1
  // Copyright 2024 IOTA Stiftung.
9
2
  // SPDX-License-Identifier: Apache-2.0.
3
+ import { CLIDisplay, CLIOptions, CLIParam, CLIUtils } from "@twin.org/cli-core";
4
+ import { Converter, I18n, Is } from "@twin.org/core";
5
+ import { Bip44, KeyType } from "@twin.org/crypto";
6
+ import { Command, Option } from "commander";
10
7
  /**
11
8
  * Build the address command to be consumed by the CLI.
12
9
  * @returns The command.
13
10
  */
14
- function buildCommandAddress() {
11
+ export function buildCommandAddress() {
15
12
  const command = new Command();
16
13
  command
17
14
  .name("address")
@@ -49,7 +46,7 @@ function buildCommandAddress() {
49
46
  * @param opts.keyType The key type for the address.
50
47
  * @param opts.keyFormat The output format of the key.
51
48
  */
52
- async function actionCommandAddress(opts) {
49
+ export async function actionCommandAddress(opts) {
53
50
  const seed = CLIParam.hexBase64("seed", opts.seed);
54
51
  const start = CLIParam.integer("start", opts.start, false);
55
52
  const count = CLIParam.integer("count", opts.count, false, 1, 100);
@@ -101,98 +98,4 @@ async function actionCommandAddress(opts) {
101
98
  }
102
99
  CLIDisplay.done();
103
100
  }
104
-
105
- // Copyright 2024 IOTA Stiftung.
106
- // SPDX-License-Identifier: Apache-2.0.
107
- /**
108
- * Build the mnemonic command to be consumed by the CLI.
109
- * @returns The command.
110
- */
111
- function buildCommandMnemonic() {
112
- const command = new Command();
113
- command
114
- .name("mnemonic")
115
- .summary(I18n.formatMessage("commands.mnemonic.summary"))
116
- .description(I18n.formatMessage("commands.mnemonic.description"))
117
- .addOption(new Option(I18n.formatMessage("commands.mnemonic.options.strength.param"), I18n.formatMessage("commands.mnemonic.options.strength.description"))
118
- .choices(["128", "256"])
119
- .default("256"))
120
- .addOption(new Option(I18n.formatMessage("commands.mnemonic.options.seed-format.param"), I18n.formatMessage("commands.mnemonic.options.seed-format.description"))
121
- .choices(["hex", "base64"])
122
- .default("hex"))
123
- .addOption(new Option(I18n.formatMessage("commands.mnemonic.options.env-prefix.param"), I18n.formatMessage("commands.mnemonic.options.env-prefix.description")));
124
- CLIOptions.output(command, {
125
- noConsole: true,
126
- json: true,
127
- env: true,
128
- mergeJson: true,
129
- mergeEnv: true
130
- });
131
- command.action(actionCommandMnemonic);
132
- return command;
133
- }
134
- /**
135
- * Action the mnemonic command.
136
- * @param opts The options for the command.
137
- * @param opts.strength The mnemonic strength.
138
- * @param opts.seedFormat The output format of the seed.
139
- */
140
- async function actionCommandMnemonic(opts) {
141
- const strength = CLIParam.integer("strength", opts.strength, false, 128, 256);
142
- const mnemonic = Bip39.randomMnemonic(strength);
143
- const seed = Bip39.mnemonicToSeed(mnemonic);
144
- const envPrefix = Is.stringValue(opts.envPrefix) ? opts.envPrefix : "";
145
- const seedFormatted = opts.seedFormat === "hex" ? Converter.bytesToHex(seed, true) : Converter.bytesToBase64(seed);
146
- if (opts.console) {
147
- CLIDisplay.value(I18n.formatMessage("commands.mnemonic.labels.mnemonic"), mnemonic);
148
- CLIDisplay.value(I18n.formatMessage("commands.mnemonic.labels.seed"), seedFormatted);
149
- if (Is.stringValue(opts.envPrefix)) {
150
- CLIDisplay.value(I18n.formatMessage("commands.mnemonic.labels.envPrefix"), envPrefix);
151
- }
152
- CLIDisplay.break();
153
- }
154
- if (Is.stringValue(opts?.json)) {
155
- await CLIUtils.writeJsonFile(opts.json, { mnemonic, seed: seedFormatted }, opts.mergeJson);
156
- }
157
- if (Is.stringValue(opts?.env)) {
158
- await CLIUtils.writeEnvFile(opts.env, [`${envPrefix}MNEMONIC="${mnemonic}"`, `${envPrefix}SEED="${seedFormatted}"`], opts.mergeEnv);
159
- }
160
- CLIDisplay.done();
161
- }
162
-
163
- // Copyright 2024 IOTA Stiftung.
164
- // SPDX-License-Identifier: Apache-2.0.
165
- /**
166
- * The main entry point for the CLI.
167
- */
168
- class CLI extends CLIBase {
169
- /**
170
- * Run the app.
171
- * @param argv The process arguments.
172
- * @param localesDirectory The directory for the locales, default to relative to the script.
173
- * @param options Additional options.
174
- * @param options.overrideOutputWidth Override the output width.
175
- * @returns The exit code.
176
- */
177
- async run(argv, localesDirectory, options) {
178
- return this.execute({
179
- title: "TWIN Crypto",
180
- appName: "twin-crypto",
181
- version: "0.0.2-next.9", // x-release-please-version
182
- icon: "🌍",
183
- supportsEnvFiles: true,
184
- overrideOutputWidth: options?.overrideOutputWidth,
185
- showDevToolWarning: true
186
- }, localesDirectory ?? path.join(path.dirname(fileURLToPath(import.meta.url)), "../locales"), argv);
187
- }
188
- /**
189
- * Get the commands for the CLI.
190
- * @param program The main program to add the commands to.
191
- * @internal
192
- */
193
- getCommands(program) {
194
- return [buildCommandMnemonic(), buildCommandAddress()];
195
- }
196
- }
197
-
198
- export { CLI, actionCommandAddress, actionCommandMnemonic, buildCommandAddress, buildCommandMnemonic };
101
+ //# sourceMappingURL=address.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address.js","sourceRoot":"","sources":["../../../src/commands/address.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,UAAU,EACV,UAAU,EACV,QAAQ,EACR,QAAQ,EAER,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAE5C;;;GAGG;AACH,MAAM,UAAU,mBAAmB;IAClC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAC9B,OAAO;SACL,IAAI,CAAC,SAAS,CAAC;SACf,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,0BAA0B,CAAC,CAAC;SACvD,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,8BAA8B,CAAC,CAAC;SAC/D,cAAc,CACd,IAAI,CAAC,aAAa,CAAC,qCAAqC,CAAC,EACzD,IAAI,CAAC,aAAa,CAAC,2CAA2C,CAAC,CAC/D;SACA,MAAM,CACN,IAAI,CAAC,aAAa,CAAC,sCAAsC,CAAC,EAC1D,IAAI,CAAC,aAAa,CAAC,4CAA4C,CAAC,EAChE,GAAG,CACH;SACA,MAAM,CACN,IAAI,CAAC,aAAa,CAAC,sCAAsC,CAAC,EAC1D,IAAI,CAAC,aAAa,CAAC,4CAA4C,CAAC,EAChE,IAAI,CAC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ttype CliOutputOptions\n} from \"@twin.org/cli-core\";\nimport { Converter, I18n, Is } from \"@twin.org/core\";\nimport { Bip44, KeyType } from \"@twin.org/crypto\";\nimport { Command, Option } from \"commander\";\n\n/**\n * Build the address command to be consumed by the CLI.\n * @returns The command.\n */\nexport function buildCommandAddress(): Command {\n\tconst command = new Command();\n\tcommand\n\t\t.name(\"address\")\n\t\t.summary(I18n.formatMessage(\"commands.address.summary\"))\n\t\t.description(I18n.formatMessage(\"commands.address.description\"))\n\t\t.requiredOption(\n\t\t\tI18n.formatMessage(\"commands.address.options.seed.param\"),\n\t\t\tI18n.formatMessage(\"commands.address.options.seed.description\")\n\t\t)\n\t\t.option(\n\t\t\tI18n.formatMessage(\"commands.address.options.start.param\"),\n\t\t\tI18n.formatMessage(\"commands.address.options.start.description\"),\n\t\t\t\"0\"\n\t\t)\n\t\t.option(\n\t\t\tI18n.formatMessage(\"commands.address.options.count.param\"),\n\t\t\tI18n.formatMessage(\"commands.address.options.count.description\"),\n\t\t\t\"10\"\n\t\t)\n\t\t.option(\n\t\t\tI18n.formatMessage(\"commands.address.options.account.param\"),\n\t\t\tI18n.formatMessage(\"commands.address.options.account.description\"),\n\t\t\t\"0\"\n\t\t)\n\t\t.option(\n\t\t\tI18n.formatMessage(\"commands.address.options.coin.param\"),\n\t\t\tI18n.formatMessage(\"commands.address.options.coin.description\"),\n\t\t\t\"4218\"\n\t\t)\n\t\t.addOption(\n\t\t\tnew Option(\n\t\t\t\tI18n.formatMessage(\"commands.address.options.key-type.param\"),\n\t\t\t\tI18n.formatMessage(\"commands.address.options.key-type.description\")\n\t\t\t)\n\t\t\t\t.choices([\"Ed25519\", \"Secp256k1\"])\n\t\t\t\t.default(\"Ed25519\")\n\t\t)\n\t\t.addOption(\n\t\t\tnew Option(\n\t\t\t\tI18n.formatMessage(\"commands.address.options.key-format.param\"),\n\t\t\t\tI18n.formatMessage(\"commands.address.options.key-format.description\")\n\t\t\t)\n\t\t\t\t.choices([\"hex\", \"base64\"])\n\t\t\t\t.default(\"hex\")\n\t\t);\n\n\tCLIOptions.output(command, {\n\t\tnoConsole: true,\n\t\tjson: true,\n\t\tenv: true,\n\t\tmergeJson: true,\n\t\tmergeEnv: true\n\t});\n\n\tcommand.action(actionCommandAddress);\n\n\treturn command;\n}\n\n/**\n * Action the address command.\n * @param opts The options for the command.\n * @param opts.seed The seed for generating the addresses.\n * @param opts.start The start index for the address generation.\n * @param opts.count The number of addresses to generate.\n * @param opts.account The account index for the address generation.\n * @param opts.coin The coin type for the address.\n * @param opts.keyType The key type for the address.\n * @param opts.keyFormat The output format of the key.\n */\nexport async function actionCommandAddress(\n\topts: {\n\t\tseed: string;\n\t\tstart: string;\n\t\tcount: string;\n\t\taccount: string;\n\t\tcoin: string;\n\t\tkeyType: \"Ed25519\" | \"Secp256k1\";\n\t\tkeyFormat: \"hex\" | \"base64\";\n\t} & CliOutputOptions\n): Promise<void> {\n\tconst seed: Uint8Array = CLIParam.hexBase64(\"seed\", opts.seed);\n\n\tconst start = CLIParam.integer(\"start\", opts.start, false);\n\tconst count = CLIParam.integer(\"count\", opts.count, false, 1, 100);\n\tconst account = CLIParam.integer(\"account\", opts.account, false);\n\tconst coin = CLIParam.integer(\"coin\", opts.coin, false);\n\tconst keyType = opts.keyType;\n\tconst keyFormat = opts.keyFormat;\n\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"commands.address.labels.seed\"),\n\t\tkeyFormat === \"hex\" ? Converter.bytesToHex(seed, true) : Converter.bytesToBase64(seed)\n\t);\n\tCLIDisplay.value(I18n.formatMessage(\"commands.address.labels.start\"), start);\n\tCLIDisplay.value(I18n.formatMessage(\"commands.address.labels.count\"), count);\n\tCLIDisplay.value(I18n.formatMessage(\"commands.address.labels.account\"), account);\n\tCLIDisplay.value(I18n.formatMessage(\"commands.address.labels.coin\"), coin);\n\tCLIDisplay.value(I18n.formatMessage(\"commands.address.labels.key-type\"), keyType);\n\tCLIDisplay.value(I18n.formatMessage(\"commands.address.labels.key-format\"), keyFormat);\n\tCLIDisplay.break();\n\n\tCLIDisplay.task(I18n.formatMessage(\"commands.address.progress.generatingAddresses\"));\n\tCLIDisplay.break();\n\n\tconst addressDictionary: {\n\t\t[index: number]: { address: string; privateKey: string; publicKey: string };\n\t} = {};\n\n\tfor (let i = start; i < start + count; i++) {\n\t\tconst addressKeyPair = Bip44.address(\n\t\t\tseed,\n\t\t\tkeyType === \"Ed25519\" ? KeyType.Ed25519 : KeyType.Secp256k1,\n\t\t\tcoin,\n\t\t\taccount,\n\t\t\tfalse,\n\t\t\ti\n\t\t);\n\n\t\taddressDictionary[i] = {\n\t\t\taddress: addressKeyPair.address,\n\t\t\tprivateKey:\n\t\t\t\tkeyFormat === \"hex\"\n\t\t\t\t\t? Converter.bytesToHex(addressKeyPair.privateKey, true)\n\t\t\t\t\t: Converter.bytesToBase64(addressKeyPair.privateKey),\n\t\t\tpublicKey:\n\t\t\t\tkeyFormat === \"hex\"\n\t\t\t\t\t? Converter.bytesToHex(addressKeyPair.publicKey, true)\n\t\t\t\t\t: Converter.bytesToBase64(addressKeyPair.publicKey)\n\t\t};\n\n\t\tif (opts.console) {\n\t\t\tCLIDisplay.value(I18n.formatMessage(\"commands.address.labels.index\"), i);\n\t\t\tCLIDisplay.value(\n\t\t\t\tI18n.formatMessage(\"commands.address.labels.address\"),\n\t\t\t\taddressDictionary[i].address\n\t\t\t);\n\t\t\tCLIDisplay.value(\n\t\t\t\tI18n.formatMessage(\"commands.address.labels.private-key\"),\n\t\t\t\taddressDictionary[i].privateKey\n\t\t\t);\n\t\t\tCLIDisplay.value(\n\t\t\t\tI18n.formatMessage(\"commands.address.labels.public-key\"),\n\t\t\t\taddressDictionary[i].publicKey\n\t\t\t);\n\t\t\tCLIDisplay.break();\n\t\t}\n\t}\n\n\tif (Is.stringValue(opts?.json)) {\n\t\tawait CLIUtils.writeJsonFile(opts.json, { addresses: addressDictionary }, opts.mergeJson);\n\t}\n\tif (Is.stringValue(opts?.env)) {\n\t\tconst output = [];\n\t\tfor (const addressIndex in addressDictionary) {\n\t\t\toutput.push(`ADDRESS_${addressIndex}=\"${addressDictionary[addressIndex].address}\"`);\n\t\t\toutput.push(\n\t\t\t\t`ADDRESS_${addressIndex}_PRIVATE_KEY=\"${addressDictionary[addressIndex].privateKey}\"`\n\t\t\t);\n\t\t\toutput.push(\n\t\t\t\t`ADDRESS_${addressIndex}_PUBLIC_KEY=\"${addressDictionary[addressIndex].publicKey}\"`\n\t\t\t);\n\t\t}\n\t\tawait CLIUtils.writeEnvFile(opts.env, output, opts.mergeEnv);\n\t}\n\n\tCLIDisplay.done();\n}\n"]}
@@ -0,0 +1,62 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { CLIDisplay, CLIOptions, CLIParam, CLIUtils } from "@twin.org/cli-core";
4
+ import { Converter, I18n, Is } from "@twin.org/core";
5
+ import { Bip39 } from "@twin.org/crypto";
6
+ import { Command, Option } from "commander";
7
+ /**
8
+ * Build the mnemonic command to be consumed by the CLI.
9
+ * @returns The command.
10
+ */
11
+ export function buildCommandMnemonic() {
12
+ const command = new Command();
13
+ command
14
+ .name("mnemonic")
15
+ .summary(I18n.formatMessage("commands.mnemonic.summary"))
16
+ .description(I18n.formatMessage("commands.mnemonic.description"))
17
+ .addOption(new Option(I18n.formatMessage("commands.mnemonic.options.strength.param"), I18n.formatMessage("commands.mnemonic.options.strength.description"))
18
+ .choices(["128", "256"])
19
+ .default("256"))
20
+ .addOption(new Option(I18n.formatMessage("commands.mnemonic.options.seed-format.param"), I18n.formatMessage("commands.mnemonic.options.seed-format.description"))
21
+ .choices(["hex", "base64"])
22
+ .default("hex"))
23
+ .addOption(new Option(I18n.formatMessage("commands.mnemonic.options.env-prefix.param"), I18n.formatMessage("commands.mnemonic.options.env-prefix.description")));
24
+ CLIOptions.output(command, {
25
+ noConsole: true,
26
+ json: true,
27
+ env: true,
28
+ mergeJson: true,
29
+ mergeEnv: true
30
+ });
31
+ command.action(actionCommandMnemonic);
32
+ return command;
33
+ }
34
+ /**
35
+ * Action the mnemonic command.
36
+ * @param opts The options for the command.
37
+ * @param opts.strength The mnemonic strength.
38
+ * @param opts.seedFormat The output format of the seed.
39
+ */
40
+ export async function actionCommandMnemonic(opts) {
41
+ const strength = CLIParam.integer("strength", opts.strength, false, 128, 256);
42
+ const mnemonic = Bip39.randomMnemonic(strength);
43
+ const seed = Bip39.mnemonicToSeed(mnemonic);
44
+ const envPrefix = Is.stringValue(opts.envPrefix) ? opts.envPrefix : "";
45
+ const seedFormatted = opts.seedFormat === "hex" ? Converter.bytesToHex(seed, true) : Converter.bytesToBase64(seed);
46
+ if (opts.console) {
47
+ CLIDisplay.value(I18n.formatMessage("commands.mnemonic.labels.mnemonic"), mnemonic);
48
+ CLIDisplay.value(I18n.formatMessage("commands.mnemonic.labels.seed"), seedFormatted);
49
+ if (Is.stringValue(opts.envPrefix)) {
50
+ CLIDisplay.value(I18n.formatMessage("commands.mnemonic.labels.envPrefix"), envPrefix);
51
+ }
52
+ CLIDisplay.break();
53
+ }
54
+ if (Is.stringValue(opts?.json)) {
55
+ await CLIUtils.writeJsonFile(opts.json, { mnemonic, seed: seedFormatted }, opts.mergeJson);
56
+ }
57
+ if (Is.stringValue(opts?.env)) {
58
+ await CLIUtils.writeEnvFile(opts.env, [`${envPrefix}MNEMONIC="${mnemonic}"`, `${envPrefix}SEED="${seedFormatted}"`], opts.mergeEnv);
59
+ }
60
+ CLIDisplay.done();
61
+ }
62
+ //# sourceMappingURL=mnemonic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mnemonic.js","sourceRoot":"","sources":["../../../src/commands/mnemonic.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,UAAU,EACV,UAAU,EACV,QAAQ,EACR,QAAQ,EAER,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,gBAAgB,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EAAE,aAAa,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAC5F,CAAC;IACD,IAAI,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;QAC/B,MAAM,QAAQ,CAAC,YAAY,CAC1B,IAAI,CAAC,GAAG,EACR,CAAC,GAAG,SAAS,aAAa,QAAQ,GAAG,EAAE,GAAG,SAAS,SAAS,aAAa,GAAG,CAAC,EAC7E,IAAI,CAAC,QAAQ,CACb,CAAC;IACH,CAAC;IAED,UAAU,CAAC,IAAI,EAAE,CAAC;AACnB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tCLIDisplay,\n\tCLIOptions,\n\tCLIParam,\n\tCLIUtils,\n\ttype CliOutputOptions\n} from \"@twin.org/cli-core\";\nimport { Converter, I18n, Is } from \"@twin.org/core\";\nimport { Bip39 } from \"@twin.org/crypto\";\nimport { Command, Option } from \"commander\";\n\n/**\n * Build the mnemonic command to be consumed by the CLI.\n * @returns The command.\n */\nexport function buildCommandMnemonic(): Command {\n\tconst command = new Command();\n\tcommand\n\t\t.name(\"mnemonic\")\n\t\t.summary(I18n.formatMessage(\"commands.mnemonic.summary\"))\n\t\t.description(I18n.formatMessage(\"commands.mnemonic.description\"))\n\t\t.addOption(\n\t\t\tnew Option(\n\t\t\t\tI18n.formatMessage(\"commands.mnemonic.options.strength.param\"),\n\t\t\t\tI18n.formatMessage(\"commands.mnemonic.options.strength.description\")\n\t\t\t)\n\t\t\t\t.choices([\"128\", \"256\"])\n\t\t\t\t.default(\"256\")\n\t\t)\n\t\t.addOption(\n\t\t\tnew Option(\n\t\t\t\tI18n.formatMessage(\"commands.mnemonic.options.seed-format.param\"),\n\t\t\t\tI18n.formatMessage(\"commands.mnemonic.options.seed-format.description\")\n\t\t\t)\n\t\t\t\t.choices([\"hex\", \"base64\"])\n\t\t\t\t.default(\"hex\")\n\t\t)\n\t\t.addOption(\n\t\t\tnew Option(\n\t\t\t\tI18n.formatMessage(\"commands.mnemonic.options.env-prefix.param\"),\n\t\t\t\tI18n.formatMessage(\"commands.mnemonic.options.env-prefix.description\")\n\t\t\t)\n\t\t);\n\n\tCLIOptions.output(command, {\n\t\tnoConsole: true,\n\t\tjson: true,\n\t\tenv: true,\n\t\tmergeJson: true,\n\t\tmergeEnv: true\n\t});\n\n\tcommand.action(actionCommandMnemonic);\n\n\treturn command;\n}\n\n/**\n * Action the mnemonic command.\n * @param opts The options for the command.\n * @param opts.strength The mnemonic strength.\n * @param opts.seedFormat The output format of the seed.\n */\nexport async function actionCommandMnemonic(\n\topts: {\n\t\tstrength: string;\n\t\tseedFormat: \"hex\" | \"base64\";\n\t\tenvPrefix?: string;\n\t} & CliOutputOptions\n): Promise<void> {\n\tconst strength = CLIParam.integer(\"strength\", opts.strength, false, 128, 256);\n\n\tconst mnemonic = Bip39.randomMnemonic(strength);\n\tconst seed = Bip39.mnemonicToSeed(mnemonic);\n\tconst envPrefix = Is.stringValue(opts.envPrefix) ? opts.envPrefix : \"\";\n\n\tconst seedFormatted =\n\t\topts.seedFormat === \"hex\" ? Converter.bytesToHex(seed, true) : Converter.bytesToBase64(seed);\n\n\tif (opts.console) {\n\t\tCLIDisplay.value(I18n.formatMessage(\"commands.mnemonic.labels.mnemonic\"), mnemonic);\n\t\tCLIDisplay.value(I18n.formatMessage(\"commands.mnemonic.labels.seed\"), seedFormatted);\n\t\tif (Is.stringValue(opts.envPrefix)) {\n\t\t\tCLIDisplay.value(I18n.formatMessage(\"commands.mnemonic.labels.envPrefix\"), envPrefix);\n\t\t}\n\t\tCLIDisplay.break();\n\t}\n\n\tif (Is.stringValue(opts?.json)) {\n\t\tawait CLIUtils.writeJsonFile(opts.json, { mnemonic, seed: seedFormatted }, opts.mergeJson);\n\t}\n\tif (Is.stringValue(opts?.env)) {\n\t\tawait CLIUtils.writeEnvFile(\n\t\t\topts.env,\n\t\t\t[`${envPrefix}MNEMONIC=\"${mnemonic}\"`, `${envPrefix}SEED=\"${seedFormatted}\"`],\n\t\t\topts.mergeEnv\n\t\t);\n\t}\n\n\tCLIDisplay.done();\n}\n"]}
@@ -0,0 +1,6 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export * from "./cli.js";
4
+ export * from "./commands/address.js";
5
+ export * from "./commands/mnemonic.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,UAAU,CAAC;AACzB,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./cli.js\";\nexport * from \"./commands/address.js\";\nexport * from \"./commands/mnemonic.js\";\n"]}
@@ -6,14 +6,8 @@
6
6
  "optionInvalidHex": "The \"{option}\" does not appear to be hex. \"{value}\"",
7
7
  "optionInvalidBase64": "The \"{option}\" does not appear to be base64. \"{value}\"",
8
8
  "optionInvalidHexBase64": "The \"{option}\" does not appear to be hex or base64. \"{value}\"",
9
- "optionInvalidBech32": "The \"{option}\" does not appear to be bech32. \"{value}\"",
10
9
  "optionMinValue": "The \"{option}\" option must be greater than or equal to {minValue}, it is {value}.",
11
10
  "optionMaxValue": "The \"{option}\" option must be less than or equal to {maxValue}, it is {value}."
12
- },
13
- "address": {
14
- "seedMissingEnv": "The seed does not appear to be hex or base64, assuming it is an environment variable, but there is no environment variable with the name \"{env}\" set.",
15
- "seedInvalidEnv": "The seed does not appear to be hex or base64, assuming it is an environment variable, but there the environment variable is neither hex or base64. \"{envValue}\"",
16
- "seedInvalidFormat": "The seed does not appear to be hex, base64 or an environment variable. \"{seed}\""
17
11
  }
18
12
  },
19
13
  "validation": {
@@ -55,8 +49,13 @@
55
49
  "beUrl": "{fieldName} must be a correctly formatted url",
56
50
  "beJSON": "{fieldName} must be correctly formatted JSON",
57
51
  "beEmail": "{fieldName} must be a correctly formatted e-mail address",
58
- "failed": "Validation failed",
59
- "failedObject": "Validation of \"{objectName}\" failed"
52
+ "minLengthRequired": "The value length should be at least {minLength}, it is {actualLength}",
53
+ "maxLengthRequired": "The value length should be at most {maxLength}, it is {actualLength}",
54
+ "repeatedCharacters": "The value should not contain repeated characters in sequence",
55
+ "atLeastOneLowerCase": "The value should contain at least one lowercase character",
56
+ "atLeastOneUpperCase": "The value should contain at least one uppercase character",
57
+ "atLeastOneNumber": "The value should contain at least one number",
58
+ "atLeastOneSpecialChar": "The value should contain at least one symbol"
60
59
  },
61
60
  "guard": {
62
61
  "undefined": "Property \"{property}\" must be defined, it is \"{value}\"",
@@ -89,9 +88,7 @@
89
88
  "url": "Property \"{property}\" must be a Url formatted string, it is \"{value}\"",
90
89
  "email": "Property \"{property}\" must be string in e-mail format, it is \"{value}\"",
91
90
  "length32Multiple": "Property \"{property}\" should be a multiple of 32, it is {value}",
92
- "lengthEntropy": "Property \"{property}\" should be a multiple of 4, >=16 and <= 32, it is {value}",
93
- "length3Multiple": "Property \"{property}\" should be a multiple of 3, it is {value}",
94
- "greaterThan0": "Property \"{property}\" must be greater than zero, it is {value}"
91
+ "lengthEntropy": "Property \"{property}\" should be a multiple of 4, >=16 and <= 32, it is {value}"
95
92
  },
96
93
  "objectHelper": {
97
94
  "failedBytesToJSON": "Failed converting bytes to JSON",
@@ -107,7 +104,7 @@
107
104
  "noGet": "The requested {typeName} \"{name}\" does not exist in the factory"
108
105
  },
109
106
  "bitString": {
110
- "outOfRange": "The index should be >= 0 and less than the length of the bit string"
107
+ "outOfRange": "The index should be >= 0 and less than the length of the bit string, the index is \"{index}\" and the number of bit is \"{numberBits}\""
111
108
  },
112
109
  "base32": {
113
110
  "invalidCharacter": "Data contains a character \"{invalidCharacter}\" which is not in the charset"
@@ -121,10 +118,6 @@
121
118
  "jsonHelper": {
122
119
  "failedPatch": "Failed to patch the JSON object, patch index \"{index}\" failed"
123
120
  },
124
- "bip39": {
125
- "missingMnemonicWord": "The mnemonic contains a word not in the wordlist, \"{value}\"",
126
- "checksumMismatch": "The checksum does not match \"{newChecksum}\" != \"{checksumBits}\""
127
- },
128
121
  "ed25519": {
129
122
  "privateKeyLength": "The private key length is incorrect, it should be \"{requiredSize}\" but is \"{actualSize}\"",
130
123
  "publicKeyLength": "The public key length is incorrect, it should be \"{requiredSize}\" but is \"{actualSize}\""
@@ -133,13 +126,6 @@
133
126
  "privateKeyLength": "The private key length is incorrect, it should be \"{requiredSize}\" but is \"{actualSize}\"",
134
127
  "publicKeyLength": "The public key length is incorrect, it should be \"{requiredSize}\" but is \"{actualSize}\""
135
128
  },
136
- "x25519": {
137
- "invalidPublicKey": "Invalid Ed25519 Public Key"
138
- },
139
- "blake2b": {
140
- "outputLength64": "The output length should be between 1 and 64, it is \"{outputLength}\"",
141
- "keyLength64": "The key length should be between 1 and 64, it is \"{keyLength}\""
142
- },
143
129
  "sha512": {
144
130
  "bitSize": "Only 224, 256, 384 or 512 bits are supported, it is \"{bitSize}\""
145
131
  },
@@ -162,26 +148,11 @@
162
148
  "lowerUpper": "The address my use either lowercase or uppercase, \"{bech32}\"",
163
149
  "dataTooShort": "The address does not contain enough data to decode, \"{bech32}\""
164
150
  },
165
- "pbkdf2": {
166
- "keyTooLong": "The requested key length \"{keyLength}\" is too long, based on the \"{macLength}\""
167
- },
168
- "chaCha20Poly1305": {
169
- "noAadWithData": "You can not set the aad when there is already data",
170
- "noAuthTag": "Can not finalise when the auth tag is not set",
171
- "authenticationFailed": "The data could not be authenticated",
172
- "authTagDecrypting": "Can not get the auth tag when decrypting",
173
- "authTagEncrypting": "Can not set the auth tag when encrypting",
174
- "noAuthTagSet": "The auth tag has not been set"
175
- },
176
151
  "bip44": {
177
152
  "unsupportedKeyType": "The key type \"{keyType}\" is not supported"
178
153
  },
179
154
  "slip0010": {
180
155
  "invalidSeed": "The seed is invalid \"{seed}\""
181
- },
182
- "rsa": {
183
- "noPrivateKey": "Private key is required for this operation",
184
- "invalidKeySize": "Invalid RSA key size"
185
156
  }
186
157
  },
187
158
  "warn": {
@@ -241,7 +212,8 @@
241
212
  "alreadyExistsError": "Already Exists",
242
213
  "notImplementedError": "Not Implemented",
243
214
  "validationError": "Validation",
244
- "unprocessableError": "Unprocessable"
215
+ "unprocessableError": "Unprocessable",
216
+ "unauthorizedError": "Unauthorized"
245
217
  },
246
218
  "validation": {
247
219
  "defaultFieldName": "The field"
@@ -259,27 +231,11 @@
259
231
  "param": "--seed-format '<'format'>'",
260
232
  "description": "The format to output the seed."
261
233
  },
262
- "no-console": {
263
- "param": "--no-console",
264
- "description": "Hides the mnemonic and seed in the console."
265
- },
266
- "json": {
267
- "param": "--json '<'filename'>'",
268
- "description": "Creates a JSON file containing the mnemonic and seed."
269
- },
270
- "env": {
271
- "param": "--env '<'filename'>'",
272
- "description": "Creates an env file containing the mnemonic and seed."
273
- },
274
234
  "env-prefix": {
275
235
  "param": "--env-prefix '<'prefix'>'",
276
236
  "description": "Prefixes the env variables with the value."
277
237
  }
278
238
  },
279
- "progress": {
280
- "writingJsonFile": "Writing JSON file",
281
- "writingEnvFile": "Writing env file"
282
- },
283
239
  "labels": {
284
240
  "mnemonic": "Mnemonic",
285
241
  "seed": "Seed",
@@ -1,3 +1,3 @@
1
- export * from "./cli";
2
- export * from "./commands/address";
3
- export * from "./commands/mnemonic";
1
+ export * from "./cli.js";
2
+ export * from "./commands/address.js";
3
+ export * from "./commands/mnemonic.js";
package/docs/changelog.md CHANGED
@@ -1,5 +1,340 @@
1
1
  # @twin.org/crypto-cli - Changelog
2
2
 
3
+ ## [0.0.3-next.2](https://github.com/twinfoundation/framework/compare/crypto-cli-v0.0.3-next.1...crypto-cli-v0.0.3-next.2) (2025-11-12)
4
+
5
+
6
+ ### Miscellaneous Chores
7
+
8
+ * **crypto-cli:** Synchronize repo versions
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/cli-core bumped from 0.0.3-next.1 to 0.0.3-next.2
16
+ * @twin.org/core bumped from 0.0.3-next.1 to 0.0.3-next.2
17
+ * @twin.org/crypto bumped from 0.0.3-next.1 to 0.0.3-next.2
18
+ * @twin.org/nameof bumped from 0.0.3-next.1 to 0.0.3-next.2
19
+ * devDependencies
20
+ * @twin.org/merge-locales bumped from 0.0.3-next.1 to 0.0.3-next.2
21
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.1 to 0.0.3-next.2
22
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.1 to 0.0.3-next.2
23
+ * @twin.org/validate-locales bumped from 0.0.3-next.1 to 0.0.3-next.2
24
+
25
+ ## [0.0.3-next.1](https://github.com/twinfoundation/framework/compare/crypto-cli-v0.0.3-next.0...crypto-cli-v0.0.3-next.1) (2025-11-10)
26
+
27
+
28
+ ### Features
29
+
30
+ * add context id features ([#206](https://github.com/twinfoundation/framework/issues/206)) ([ef0d4ee](https://github.com/twinfoundation/framework/commit/ef0d4ee11a4f5fc6cc6f52a4958ce905c04ee13b))
31
+ * add guards arrayEndsWith and arrayStartsWith ([95d875e](https://github.com/twinfoundation/framework/commit/95d875ec8ccb4713c145fdde941d4cfedcec2ed3))
32
+ * add version type ([ae50cd9](https://github.com/twinfoundation/framework/commit/ae50cd99d342ed8eeb55290a52e9fed80a2af99e))
33
+ * eslint migration to flat config ([74427d7](https://github.com/twinfoundation/framework/commit/74427d78d342167f7850e49ab87269326355befe))
34
+ * locales validation ([#197](https://github.com/twinfoundation/framework/issues/197)) ([55fdadb](https://github.com/twinfoundation/framework/commit/55fdadb13595ce0047f787bd1d4135d429a99f12))
35
+ * relocate core packages from tools ([bcab8f3](https://github.com/twinfoundation/framework/commit/bcab8f3160442ea4fcaf442947462504f3d6a17d))
36
+ * remove version type ([553aa55](https://github.com/twinfoundation/framework/commit/553aa55bd79b8f930155035e522af2b0f6e3d0c8))
37
+ * update dependencies ([f3bd015](https://github.com/twinfoundation/framework/commit/f3bd015efd169196b7e0335f5cab876ba6ca1d75))
38
+ * use cause instead of inner for errors ([1f4acc4](https://github.com/twinfoundation/framework/commit/1f4acc4d7a6b71a134d9547da9bf40de1e1e49da))
39
+ * use new shared store mechanism ([#131](https://github.com/twinfoundation/framework/issues/131)) ([934385b](https://github.com/twinfoundation/framework/commit/934385b2fbaf9f5c00a505ebf9d093bd5a425f55))
40
+
41
+
42
+ ### Bug Fixes
43
+
44
+ * crypto CLI address output to JSON ([0398604](https://github.com/twinfoundation/framework/commit/0398604c5ad7673eddf1ee7bed7fafa94f3526f8))
45
+ * crypto CLI address output to JSON ([3397bfb](https://github.com/twinfoundation/framework/commit/3397bfbdde6be5dcb40b490009891e14338e2af7))
46
+ * remove bech32 from crypto-cli ([892aa5f](https://github.com/twinfoundation/framework/commit/892aa5f746a4bc806f2dada3611c03fadcfe5a7b))
47
+
48
+
49
+ ### Dependencies
50
+
51
+ * The following workspace dependencies were updated
52
+ * dependencies
53
+ * @twin.org/cli-core bumped from 0.0.3-next.0 to 0.0.3-next.1
54
+ * @twin.org/core bumped from 0.0.3-next.0 to 0.0.3-next.1
55
+ * @twin.org/crypto bumped from 0.0.3-next.0 to 0.0.3-next.1
56
+ * @twin.org/nameof bumped from 0.0.3-next.0 to 0.0.3-next.1
57
+ * devDependencies
58
+ * @twin.org/merge-locales bumped from 0.0.3-next.0 to 0.0.3-next.1
59
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.0 to 0.0.3-next.1
60
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.0 to 0.0.3-next.1
61
+ * @twin.org/validate-locales bumped from 0.0.3-next.0 to 0.0.3-next.1
62
+
63
+ ## [0.0.2-next.22](https://github.com/twinfoundation/framework/compare/crypto-cli-v0.0.2-next.21...crypto-cli-v0.0.2-next.22) (2025-10-10)
64
+
65
+
66
+ ### Miscellaneous Chores
67
+
68
+ * **crypto-cli:** Synchronize repo versions
69
+
70
+
71
+ ### Dependencies
72
+
73
+ * The following workspace dependencies were updated
74
+ * dependencies
75
+ * @twin.org/cli-core bumped from 0.0.2-next.21 to 0.0.2-next.22
76
+ * @twin.org/core bumped from 0.0.2-next.21 to 0.0.2-next.22
77
+ * @twin.org/crypto bumped from 0.0.2-next.21 to 0.0.2-next.22
78
+ * @twin.org/nameof bumped from 0.0.2-next.21 to 0.0.2-next.22
79
+ * devDependencies
80
+ * @twin.org/merge-locales bumped from 0.0.2-next.21 to 0.0.2-next.22
81
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.21 to 0.0.2-next.22
82
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.21 to 0.0.2-next.22
83
+ * @twin.org/validate-locales bumped from 0.0.2-next.21 to 0.0.2-next.22
84
+
85
+ ## [0.0.2-next.21](https://github.com/twinfoundation/framework/compare/crypto-cli-v0.0.2-next.20...crypto-cli-v0.0.2-next.21) (2025-10-09)
86
+
87
+
88
+ ### Features
89
+
90
+ * locales validation ([#197](https://github.com/twinfoundation/framework/issues/197)) ([55fdadb](https://github.com/twinfoundation/framework/commit/55fdadb13595ce0047f787bd1d4135d429a99f12))
91
+
92
+
93
+ ### Dependencies
94
+
95
+ * The following workspace dependencies were updated
96
+ * dependencies
97
+ * @twin.org/cli-core bumped from 0.0.2-next.20 to 0.0.2-next.21
98
+ * @twin.org/core bumped from 0.0.2-next.20 to 0.0.2-next.21
99
+ * @twin.org/crypto bumped from 0.0.2-next.20 to 0.0.2-next.21
100
+ * @twin.org/nameof bumped from 0.0.2-next.20 to 0.0.2-next.21
101
+ * devDependencies
102
+ * @twin.org/merge-locales bumped from 0.0.2-next.20 to 0.0.2-next.21
103
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.20 to 0.0.2-next.21
104
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.20 to 0.0.2-next.21
105
+ * @twin.org/validate-locales bumped from 0.0.2-next.20 to 0.0.2-next.21
106
+
107
+ ## [0.0.2-next.20](https://github.com/twinfoundation/framework/compare/crypto-cli-v0.0.2-next.19...crypto-cli-v0.0.2-next.20) (2025-10-02)
108
+
109
+
110
+ ### Miscellaneous Chores
111
+
112
+ * **crypto-cli:** Synchronize repo versions
113
+
114
+
115
+ ### Dependencies
116
+
117
+ * The following workspace dependencies were updated
118
+ * dependencies
119
+ * @twin.org/cli-core bumped from 0.0.2-next.19 to 0.0.2-next.20
120
+ * @twin.org/core bumped from 0.0.2-next.19 to 0.0.2-next.20
121
+ * @twin.org/crypto bumped from 0.0.2-next.19 to 0.0.2-next.20
122
+ * @twin.org/nameof bumped from 0.0.2-next.19 to 0.0.2-next.20
123
+ * devDependencies
124
+ * @twin.org/merge-locales bumped from 0.0.2-next.19 to 0.0.2-next.20
125
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.19 to 0.0.2-next.20
126
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.19 to 0.0.2-next.20
127
+
128
+ ## [0.0.2-next.19](https://github.com/twinfoundation/framework/compare/crypto-cli-v0.0.2-next.18...crypto-cli-v0.0.2-next.19) (2025-09-30)
129
+
130
+
131
+ ### Miscellaneous Chores
132
+
133
+ * **crypto-cli:** Synchronize repo versions
134
+
135
+
136
+ ### Dependencies
137
+
138
+ * The following workspace dependencies were updated
139
+ * dependencies
140
+ * @twin.org/cli-core bumped from 0.0.2-next.18 to 0.0.2-next.19
141
+ * @twin.org/core bumped from 0.0.2-next.18 to 0.0.2-next.19
142
+ * @twin.org/crypto bumped from 0.0.2-next.18 to 0.0.2-next.19
143
+ * @twin.org/nameof bumped from 0.0.2-next.18 to 0.0.2-next.19
144
+ * devDependencies
145
+ * @twin.org/merge-locales bumped from 0.0.2-next.18 to 0.0.2-next.19
146
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.18 to 0.0.2-next.19
147
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.18 to 0.0.2-next.19
148
+
149
+ ## [0.0.2-next.18](https://github.com/twinfoundation/framework/compare/crypto-cli-v0.0.2-next.17...crypto-cli-v0.0.2-next.18) (2025-09-29)
150
+
151
+
152
+ ### Miscellaneous Chores
153
+
154
+ * **crypto-cli:** Synchronize repo versions
155
+
156
+
157
+ ### Dependencies
158
+
159
+ * The following workspace dependencies were updated
160
+ * dependencies
161
+ * @twin.org/cli-core bumped from 0.0.2-next.17 to 0.0.2-next.18
162
+ * @twin.org/core bumped from 0.0.2-next.17 to 0.0.2-next.18
163
+ * @twin.org/crypto bumped from 0.0.2-next.17 to 0.0.2-next.18
164
+ * @twin.org/nameof bumped from 0.0.2-next.17 to 0.0.2-next.18
165
+ * devDependencies
166
+ * @twin.org/merge-locales bumped from 0.0.2-next.17 to 0.0.2-next.18
167
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.17 to 0.0.2-next.18
168
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.17 to 0.0.2-next.18
169
+
170
+ ## [0.0.2-next.17](https://github.com/twinfoundation/framework/compare/crypto-cli-v0.0.2-next.16...crypto-cli-v0.0.2-next.17) (2025-09-29)
171
+
172
+
173
+ ### Miscellaneous Chores
174
+
175
+ * **crypto-cli:** Synchronize repo versions
176
+
177
+
178
+ ### Dependencies
179
+
180
+ * The following workspace dependencies were updated
181
+ * dependencies
182
+ * @twin.org/cli-core bumped from 0.0.2-next.16 to 0.0.2-next.17
183
+ * @twin.org/core bumped from 0.0.2-next.16 to 0.0.2-next.17
184
+ * @twin.org/crypto bumped from 0.0.2-next.16 to 0.0.2-next.17
185
+ * @twin.org/nameof bumped from 0.0.2-next.16 to 0.0.2-next.17
186
+ * devDependencies
187
+ * @twin.org/merge-locales bumped from 0.0.2-next.16 to 0.0.2-next.17
188
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.16 to 0.0.2-next.17
189
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.16 to 0.0.2-next.17
190
+
191
+ ## [0.0.2-next.16](https://github.com/twinfoundation/framework/compare/crypto-cli-v0.0.2-next.15...crypto-cli-v0.0.2-next.16) (2025-09-28)
192
+
193
+
194
+ ### Miscellaneous Chores
195
+
196
+ * **crypto-cli:** Synchronize repo versions
197
+
198
+
199
+ ### Dependencies
200
+
201
+ * The following workspace dependencies were updated
202
+ * dependencies
203
+ * @twin.org/cli-core bumped from 0.0.2-next.15 to 0.0.2-next.16
204
+ * @twin.org/core bumped from 0.0.2-next.15 to 0.0.2-next.16
205
+ * @twin.org/crypto bumped from 0.0.2-next.15 to 0.0.2-next.16
206
+ * @twin.org/nameof bumped from 0.0.2-next.15 to 0.0.2-next.16
207
+ * devDependencies
208
+ * @twin.org/merge-locales bumped from 0.0.2-next.15 to 0.0.2-next.16
209
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.15 to 0.0.2-next.16
210
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.15 to 0.0.2-next.16
211
+
212
+ ## [0.0.2-next.15](https://github.com/twinfoundation/framework/compare/crypto-cli-v0.0.2-next.14...crypto-cli-v0.0.2-next.15) (2025-09-22)
213
+
214
+
215
+ ### Miscellaneous Chores
216
+
217
+ * **crypto-cli:** Synchronize repo versions
218
+
219
+
220
+ ### Dependencies
221
+
222
+ * The following workspace dependencies were updated
223
+ * dependencies
224
+ * @twin.org/cli-core bumped from 0.0.2-next.14 to 0.0.2-next.15
225
+ * @twin.org/core bumped from 0.0.2-next.14 to 0.0.2-next.15
226
+ * @twin.org/crypto bumped from 0.0.2-next.14 to 0.0.2-next.15
227
+ * @twin.org/nameof bumped from 0.0.2-next.14 to 0.0.2-next.15
228
+ * devDependencies
229
+ * @twin.org/merge-locales bumped from 0.0.2-next.14 to 0.0.2-next.15
230
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.14 to 0.0.2-next.15
231
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.14 to 0.0.2-next.15
232
+
233
+ ## [0.0.2-next.14](https://github.com/twinfoundation/framework/compare/crypto-cli-v0.0.2-next.13...crypto-cli-v0.0.2-next.14) (2025-09-22)
234
+
235
+
236
+ ### Miscellaneous Chores
237
+
238
+ * **crypto-cli:** Synchronize repo versions
239
+
240
+
241
+ ### Dependencies
242
+
243
+ * The following workspace dependencies were updated
244
+ * dependencies
245
+ * @twin.org/cli-core bumped from 0.0.2-next.13 to 0.0.2-next.14
246
+ * @twin.org/core bumped from 0.0.2-next.13 to 0.0.2-next.14
247
+ * @twin.org/crypto bumped from 0.0.2-next.13 to 0.0.2-next.14
248
+ * @twin.org/nameof bumped from 0.0.2-next.13 to 0.0.2-next.14
249
+ * devDependencies
250
+ * @twin.org/merge-locales bumped from 0.0.2-next.13 to 0.0.2-next.14
251
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.13 to 0.0.2-next.14
252
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.13 to 0.0.2-next.14
253
+
254
+ ## [0.0.2-next.13](https://github.com/twinfoundation/framework/compare/crypto-cli-v0.0.2-next.12...crypto-cli-v0.0.2-next.13) (2025-09-22)
255
+
256
+
257
+ ### Miscellaneous Chores
258
+
259
+ * **crypto-cli:** Synchronize repo versions
260
+
261
+
262
+ ### Dependencies
263
+
264
+ * The following workspace dependencies were updated
265
+ * dependencies
266
+ * @twin.org/cli-core bumped from 0.0.2-next.12 to 0.0.2-next.13
267
+ * @twin.org/core bumped from 0.0.2-next.12 to 0.0.2-next.13
268
+ * @twin.org/crypto bumped from 0.0.2-next.12 to 0.0.2-next.13
269
+ * @twin.org/nameof bumped from 0.0.2-next.12 to 0.0.2-next.13
270
+ * devDependencies
271
+ * @twin.org/merge-locales bumped from 0.0.2-next.12 to 0.0.2-next.13
272
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.12 to 0.0.2-next.13
273
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.12 to 0.0.2-next.13
274
+
275
+ ## [0.0.2-next.12](https://github.com/twinfoundation/framework/compare/crypto-cli-v0.0.2-next.11...crypto-cli-v0.0.2-next.12) (2025-09-15)
276
+
277
+
278
+ ### Miscellaneous Chores
279
+
280
+ * **crypto-cli:** Synchronize repo versions
281
+
282
+
283
+ ### Dependencies
284
+
285
+ * The following workspace dependencies were updated
286
+ * dependencies
287
+ * @twin.org/cli-core bumped from 0.0.2-next.11 to 0.0.2-next.12
288
+ * @twin.org/core bumped from 0.0.2-next.11 to 0.0.2-next.12
289
+ * @twin.org/crypto bumped from 0.0.2-next.11 to 0.0.2-next.12
290
+ * @twin.org/nameof bumped from 0.0.2-next.11 to 0.0.2-next.12
291
+ * devDependencies
292
+ * @twin.org/merge-locales bumped from 0.0.2-next.11 to 0.0.2-next.12
293
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.11 to 0.0.2-next.12
294
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.11 to 0.0.2-next.12
295
+
296
+ ## [0.0.2-next.11](https://github.com/twinfoundation/framework/compare/crypto-cli-v0.0.2-next.10...crypto-cli-v0.0.2-next.11) (2025-09-15)
297
+
298
+
299
+ ### Miscellaneous Chores
300
+
301
+ * **crypto-cli:** Synchronize repo versions
302
+
303
+
304
+ ### Dependencies
305
+
306
+ * The following workspace dependencies were updated
307
+ * dependencies
308
+ * @twin.org/cli-core bumped from 0.0.2-next.10 to 0.0.2-next.11
309
+ * @twin.org/core bumped from 0.0.2-next.10 to 0.0.2-next.11
310
+ * @twin.org/crypto bumped from 0.0.2-next.10 to 0.0.2-next.11
311
+ * @twin.org/nameof bumped from 0.0.2-next.10 to 0.0.2-next.11
312
+ * devDependencies
313
+ * @twin.org/merge-locales bumped from 0.0.2-next.10 to 0.0.2-next.11
314
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.10 to 0.0.2-next.11
315
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.10 to 0.0.2-next.11
316
+
317
+ ## [0.0.2-next.10](https://github.com/twinfoundation/framework/compare/crypto-cli-v0.0.2-next.9...crypto-cli-v0.0.2-next.10) (2025-09-11)
318
+
319
+
320
+ ### Miscellaneous Chores
321
+
322
+ * **crypto-cli:** Synchronize repo versions
323
+
324
+
325
+ ### Dependencies
326
+
327
+ * The following workspace dependencies were updated
328
+ * dependencies
329
+ * @twin.org/cli-core bumped from 0.0.2-next.9 to 0.0.2-next.10
330
+ * @twin.org/core bumped from 0.0.2-next.9 to 0.0.2-next.10
331
+ * @twin.org/crypto bumped from 0.0.2-next.9 to 0.0.2-next.10
332
+ * @twin.org/nameof bumped from 0.0.2-next.9 to 0.0.2-next.10
333
+ * devDependencies
334
+ * @twin.org/merge-locales bumped from 0.0.2-next.9 to 0.0.2-next.10
335
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.9 to 0.0.2-next.10
336
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.9 to 0.0.2-next.10
337
+
3
338
  ## [0.0.2-next.9](https://github.com/twinfoundation/framework/compare/crypto-cli-v0.0.2-next.8...crypto-cli-v0.0.2-next.9) (2025-09-08)
4
339
 
5
340
 
package/locales/en.json CHANGED
@@ -1,13 +1,4 @@
1
1
  {
2
- "error": {
3
- "commands": {
4
- "address": {
5
- "seedMissingEnv": "The seed does not appear to be hex or base64, assuming it is an environment variable, but there is no environment variable with the name \"{env}\" set.",
6
- "seedInvalidEnv": "The seed does not appear to be hex or base64, assuming it is an environment variable, but there the environment variable is neither hex or base64. \"{envValue}\"",
7
- "seedInvalidFormat": "The seed does not appear to be hex, base64 or an environment variable. \"{seed}\""
8
- }
9
- }
10
- },
11
2
  "commands": {
12
3
  "mnemonic": {
13
4
  "summary": "Create a mnemonic.",
@@ -21,27 +12,11 @@
21
12
  "param": "--seed-format '<'format'>'",
22
13
  "description": "The format to output the seed."
23
14
  },
24
- "no-console": {
25
- "param": "--no-console",
26
- "description": "Hides the mnemonic and seed in the console."
27
- },
28
- "json": {
29
- "param": "--json '<'filename'>'",
30
- "description": "Creates a JSON file containing the mnemonic and seed."
31
- },
32
- "env": {
33
- "param": "--env '<'filename'>'",
34
- "description": "Creates an env file containing the mnemonic and seed."
35
- },
36
15
  "env-prefix": {
37
16
  "param": "--env-prefix '<'prefix'>'",
38
17
  "description": "Prefixes the env variables with the value."
39
18
  }
40
19
  },
41
- "progress": {
42
- "writingJsonFile": "Writing JSON file",
43
- "writingEnvFile": "Writing env file"
44
- },
45
20
  "labels": {
46
21
  "mnemonic": "Mnemonic",
47
22
  "seed": "Seed",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/crypto-cli",
3
- "version": "0.0.2-next.9",
3
+ "version": "0.0.3-next.2",
4
4
  "description": "A command line interface for interacting with the crypto tools",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,26 +14,24 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/cli-core": "0.0.2-next.9",
18
- "@twin.org/core": "0.0.2-next.9",
19
- "@twin.org/crypto": "0.0.2-next.9",
20
- "@twin.org/nameof": "0.0.2-next.9",
21
- "commander": "14.0.0"
17
+ "@twin.org/cli-core": "0.0.3-next.2",
18
+ "@twin.org/core": "0.0.3-next.2",
19
+ "@twin.org/crypto": "0.0.3-next.2",
20
+ "@twin.org/nameof": "0.0.3-next.2",
21
+ "commander": "14.0.2"
22
22
  },
23
- "main": "./dist/cjs/index.cjs",
24
- "module": "./dist/esm/index.mjs",
23
+ "main": "./dist/es/index.js",
25
24
  "types": "./dist/types/index.d.ts",
26
25
  "exports": {
27
26
  ".": {
28
27
  "types": "./dist/types/index.d.ts",
29
- "require": "./dist/cjs/index.cjs",
30
- "import": "./dist/esm/index.mjs"
28
+ "import": "./dist/es/index.js",
29
+ "default": "./dist/es/index.js"
31
30
  }
32
31
  },
33
32
  "files": [
34
33
  "bin",
35
- "dist/cjs",
36
- "dist/esm",
34
+ "dist/es",
37
35
  "dist/locales",
38
36
  "dist/types",
39
37
  "locales",
@@ -41,5 +39,20 @@
41
39
  ],
42
40
  "bin": {
43
41
  "twin-crypto": "bin/index.js"
44
- }
42
+ },
43
+ "keywords": [
44
+ "twin",
45
+ "trade",
46
+ "iota",
47
+ "framework",
48
+ "blockchain",
49
+ "cryptography",
50
+ "encryption",
51
+ "hashing",
52
+ "security"
53
+ ],
54
+ "bugs": {
55
+ "url": "git+https://github.com/twinfoundation/framework/issues"
56
+ },
57
+ "homepage": "https://twindev.org"
45
58
  }
@@ -1,205 +0,0 @@
1
- 'use strict';
2
-
3
- var path = require('node:path');
4
- var node_url = require('node:url');
5
- var cliCore = require('@twin.org/cli-core');
6
- var core = require('@twin.org/core');
7
- var crypto = require('@twin.org/crypto');
8
- var commander = require('commander');
9
-
10
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
11
- // Copyright 2024 IOTA Stiftung.
12
- // SPDX-License-Identifier: Apache-2.0.
13
- /**
14
- * Build the address command to be consumed by the CLI.
15
- * @returns The command.
16
- */
17
- function buildCommandAddress() {
18
- const command = new commander.Command();
19
- command
20
- .name("address")
21
- .summary(core.I18n.formatMessage("commands.address.summary"))
22
- .description(core.I18n.formatMessage("commands.address.description"))
23
- .requiredOption(core.I18n.formatMessage("commands.address.options.seed.param"), core.I18n.formatMessage("commands.address.options.seed.description"))
24
- .option(core.I18n.formatMessage("commands.address.options.start.param"), core.I18n.formatMessage("commands.address.options.start.description"), "0")
25
- .option(core.I18n.formatMessage("commands.address.options.count.param"), core.I18n.formatMessage("commands.address.options.count.description"), "10")
26
- .option(core.I18n.formatMessage("commands.address.options.account.param"), core.I18n.formatMessage("commands.address.options.account.description"), "0")
27
- .option(core.I18n.formatMessage("commands.address.options.coin.param"), core.I18n.formatMessage("commands.address.options.coin.description"), "4218")
28
- .addOption(new commander.Option(core.I18n.formatMessage("commands.address.options.key-type.param"), core.I18n.formatMessage("commands.address.options.key-type.description"))
29
- .choices(["Ed25519", "Secp256k1"])
30
- .default("Ed25519"))
31
- .addOption(new commander.Option(core.I18n.formatMessage("commands.address.options.key-format.param"), core.I18n.formatMessage("commands.address.options.key-format.description"))
32
- .choices(["hex", "base64"])
33
- .default("hex"));
34
- cliCore.CLIOptions.output(command, {
35
- noConsole: true,
36
- json: true,
37
- env: true,
38
- mergeJson: true,
39
- mergeEnv: true
40
- });
41
- command.action(actionCommandAddress);
42
- return command;
43
- }
44
- /**
45
- * Action the address command.
46
- * @param opts The options for the command.
47
- * @param opts.seed The seed for generating the addresses.
48
- * @param opts.start The start index for the address generation.
49
- * @param opts.count The number of addresses to generate.
50
- * @param opts.account The account index for the address generation.
51
- * @param opts.coin The coin type for the address.
52
- * @param opts.keyType The key type for the address.
53
- * @param opts.keyFormat The output format of the key.
54
- */
55
- async function actionCommandAddress(opts) {
56
- const seed = cliCore.CLIParam.hexBase64("seed", opts.seed);
57
- const start = cliCore.CLIParam.integer("start", opts.start, false);
58
- const count = cliCore.CLIParam.integer("count", opts.count, false, 1, 100);
59
- const account = cliCore.CLIParam.integer("account", opts.account, false);
60
- const coin = cliCore.CLIParam.integer("coin", opts.coin, false);
61
- const keyType = opts.keyType;
62
- const keyFormat = opts.keyFormat;
63
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.address.labels.seed"), keyFormat === "hex" ? core.Converter.bytesToHex(seed, true) : core.Converter.bytesToBase64(seed));
64
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.address.labels.start"), start);
65
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.address.labels.count"), count);
66
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.address.labels.account"), account);
67
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.address.labels.coin"), coin);
68
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.address.labels.key-type"), keyType);
69
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.address.labels.key-format"), keyFormat);
70
- cliCore.CLIDisplay.break();
71
- cliCore.CLIDisplay.task(core.I18n.formatMessage("commands.address.progress.generatingAddresses"));
72
- cliCore.CLIDisplay.break();
73
- const addressDictionary = {};
74
- for (let i = start; i < start + count; i++) {
75
- const addressKeyPair = crypto.Bip44.address(seed, keyType === "Ed25519" ? crypto.KeyType.Ed25519 : crypto.KeyType.Secp256k1, coin, account, false, i);
76
- addressDictionary[i] = {
77
- address: addressKeyPair.address,
78
- privateKey: keyFormat === "hex"
79
- ? core.Converter.bytesToHex(addressKeyPair.privateKey, true)
80
- : core.Converter.bytesToBase64(addressKeyPair.privateKey),
81
- publicKey: keyFormat === "hex"
82
- ? core.Converter.bytesToHex(addressKeyPair.publicKey, true)
83
- : core.Converter.bytesToBase64(addressKeyPair.publicKey)
84
- };
85
- if (opts.console) {
86
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.address.labels.index"), i);
87
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.address.labels.address"), addressDictionary[i].address);
88
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.address.labels.private-key"), addressDictionary[i].privateKey);
89
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.address.labels.public-key"), addressDictionary[i].publicKey);
90
- cliCore.CLIDisplay.break();
91
- }
92
- }
93
- if (core.Is.stringValue(opts?.json)) {
94
- await cliCore.CLIUtils.writeJsonFile(opts.json, { addresses: addressDictionary }, opts.mergeJson);
95
- }
96
- if (core.Is.stringValue(opts?.env)) {
97
- const output = [];
98
- for (const addressIndex in addressDictionary) {
99
- output.push(`ADDRESS_${addressIndex}="${addressDictionary[addressIndex].address}"`);
100
- output.push(`ADDRESS_${addressIndex}_PRIVATE_KEY="${addressDictionary[addressIndex].privateKey}"`);
101
- output.push(`ADDRESS_${addressIndex}_PUBLIC_KEY="${addressDictionary[addressIndex].publicKey}"`);
102
- }
103
- await cliCore.CLIUtils.writeEnvFile(opts.env, output, opts.mergeEnv);
104
- }
105
- cliCore.CLIDisplay.done();
106
- }
107
-
108
- // Copyright 2024 IOTA Stiftung.
109
- // SPDX-License-Identifier: Apache-2.0.
110
- /**
111
- * Build the mnemonic command to be consumed by the CLI.
112
- * @returns The command.
113
- */
114
- function buildCommandMnemonic() {
115
- const command = new commander.Command();
116
- command
117
- .name("mnemonic")
118
- .summary(core.I18n.formatMessage("commands.mnemonic.summary"))
119
- .description(core.I18n.formatMessage("commands.mnemonic.description"))
120
- .addOption(new commander.Option(core.I18n.formatMessage("commands.mnemonic.options.strength.param"), core.I18n.formatMessage("commands.mnemonic.options.strength.description"))
121
- .choices(["128", "256"])
122
- .default("256"))
123
- .addOption(new commander.Option(core.I18n.formatMessage("commands.mnemonic.options.seed-format.param"), core.I18n.formatMessage("commands.mnemonic.options.seed-format.description"))
124
- .choices(["hex", "base64"])
125
- .default("hex"))
126
- .addOption(new commander.Option(core.I18n.formatMessage("commands.mnemonic.options.env-prefix.param"), core.I18n.formatMessage("commands.mnemonic.options.env-prefix.description")));
127
- cliCore.CLIOptions.output(command, {
128
- noConsole: true,
129
- json: true,
130
- env: true,
131
- mergeJson: true,
132
- mergeEnv: true
133
- });
134
- command.action(actionCommandMnemonic);
135
- return command;
136
- }
137
- /**
138
- * Action the mnemonic command.
139
- * @param opts The options for the command.
140
- * @param opts.strength The mnemonic strength.
141
- * @param opts.seedFormat The output format of the seed.
142
- */
143
- async function actionCommandMnemonic(opts) {
144
- const strength = cliCore.CLIParam.integer("strength", opts.strength, false, 128, 256);
145
- const mnemonic = crypto.Bip39.randomMnemonic(strength);
146
- const seed = crypto.Bip39.mnemonicToSeed(mnemonic);
147
- const envPrefix = core.Is.stringValue(opts.envPrefix) ? opts.envPrefix : "";
148
- const seedFormatted = opts.seedFormat === "hex" ? core.Converter.bytesToHex(seed, true) : core.Converter.bytesToBase64(seed);
149
- if (opts.console) {
150
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.mnemonic.labels.mnemonic"), mnemonic);
151
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.mnemonic.labels.seed"), seedFormatted);
152
- if (core.Is.stringValue(opts.envPrefix)) {
153
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.mnemonic.labels.envPrefix"), envPrefix);
154
- }
155
- cliCore.CLIDisplay.break();
156
- }
157
- if (core.Is.stringValue(opts?.json)) {
158
- await cliCore.CLIUtils.writeJsonFile(opts.json, { mnemonic, seed: seedFormatted }, opts.mergeJson);
159
- }
160
- if (core.Is.stringValue(opts?.env)) {
161
- await cliCore.CLIUtils.writeEnvFile(opts.env, [`${envPrefix}MNEMONIC="${mnemonic}"`, `${envPrefix}SEED="${seedFormatted}"`], opts.mergeEnv);
162
- }
163
- cliCore.CLIDisplay.done();
164
- }
165
-
166
- // Copyright 2024 IOTA Stiftung.
167
- // SPDX-License-Identifier: Apache-2.0.
168
- /**
169
- * The main entry point for the CLI.
170
- */
171
- class CLI extends cliCore.CLIBase {
172
- /**
173
- * Run the app.
174
- * @param argv The process arguments.
175
- * @param localesDirectory The directory for the locales, default to relative to the script.
176
- * @param options Additional options.
177
- * @param options.overrideOutputWidth Override the output width.
178
- * @returns The exit code.
179
- */
180
- async run(argv, localesDirectory, options) {
181
- return this.execute({
182
- title: "TWIN Crypto",
183
- appName: "twin-crypto",
184
- version: "0.0.2-next.9", // x-release-please-version
185
- icon: "🌍",
186
- supportsEnvFiles: true,
187
- overrideOutputWidth: options?.overrideOutputWidth,
188
- showDevToolWarning: true
189
- }, localesDirectory ?? path.join(path.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)))), "../locales"), argv);
190
- }
191
- /**
192
- * Get the commands for the CLI.
193
- * @param program The main program to add the commands to.
194
- * @internal
195
- */
196
- getCommands(program) {
197
- return [buildCommandMnemonic(), buildCommandAddress()];
198
- }
199
- }
200
-
201
- exports.CLI = CLI;
202
- exports.actionCommandAddress = actionCommandAddress;
203
- exports.actionCommandMnemonic = actionCommandMnemonic;
204
- exports.buildCommandAddress = buildCommandAddress;
205
- exports.buildCommandMnemonic = buildCommandMnemonic;