@twin.org/crypto-cli 0.0.1-next.3
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/LICENSE +201 -0
- package/README.md +21 -0
- package/bin/index.js +8 -0
- package/dist/cjs/index.cjs +200 -0
- package/dist/esm/index.mjs +193 -0
- package/dist/locales/en.json +312 -0
- package/dist/types/cli.d.ts +13 -0
- package/dist/types/commands/address.d.ts +29 -0
- package/dist/types/commands/mnemonic.d.ts +17 -0
- package/dist/types/index.d.ts +3 -0
- package/docs/changelog.md +5 -0
- package/docs/examples.md +258 -0
- package/docs/reference/classes/CLI.md +99 -0
- package/docs/reference/functions/actionCommandAddress.md +15 -0
- package/docs/reference/functions/actionCommandMnemonic.md +15 -0
- package/docs/reference/functions/buildCommandAddress.md +11 -0
- package/docs/reference/functions/buildCommandMnemonic.md +11 -0
- package/docs/reference/index.md +12 -0
- package/locales/en.json +102 -0
- package/package.json +74 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Class: CLI
|
|
2
|
+
|
|
3
|
+
The main entry point for the CLI.
|
|
4
|
+
|
|
5
|
+
## Extends
|
|
6
|
+
|
|
7
|
+
- `CLIBase`
|
|
8
|
+
|
|
9
|
+
## Constructors
|
|
10
|
+
|
|
11
|
+
### new CLI()
|
|
12
|
+
|
|
13
|
+
> **new CLI**(): [`CLI`](CLI.md)
|
|
14
|
+
|
|
15
|
+
#### Returns
|
|
16
|
+
|
|
17
|
+
[`CLI`](CLI.md)
|
|
18
|
+
|
|
19
|
+
#### Inherited from
|
|
20
|
+
|
|
21
|
+
`CLIBase.constructor`
|
|
22
|
+
|
|
23
|
+
## Methods
|
|
24
|
+
|
|
25
|
+
### execute()
|
|
26
|
+
|
|
27
|
+
> **execute**(`options`, `localesDirectory`, `argv`): `Promise`\<`number`\>
|
|
28
|
+
|
|
29
|
+
Execute the command line processing.
|
|
30
|
+
|
|
31
|
+
#### Parameters
|
|
32
|
+
|
|
33
|
+
• **options**: `ICliOptions`
|
|
34
|
+
|
|
35
|
+
The options for the CLI.
|
|
36
|
+
|
|
37
|
+
• **localesDirectory**: `string`
|
|
38
|
+
|
|
39
|
+
The path to load the locales from.
|
|
40
|
+
|
|
41
|
+
• **argv**: `string`[]
|
|
42
|
+
|
|
43
|
+
The process arguments.
|
|
44
|
+
|
|
45
|
+
#### Returns
|
|
46
|
+
|
|
47
|
+
`Promise`\<`number`\>
|
|
48
|
+
|
|
49
|
+
The exit code.
|
|
50
|
+
|
|
51
|
+
#### Inherited from
|
|
52
|
+
|
|
53
|
+
`CLIBase.execute`
|
|
54
|
+
|
|
55
|
+
***
|
|
56
|
+
|
|
57
|
+
### configureRoot()
|
|
58
|
+
|
|
59
|
+
> `protected` **configureRoot**(`program`): `void`
|
|
60
|
+
|
|
61
|
+
Configure any options or actions at the root program level.
|
|
62
|
+
|
|
63
|
+
#### Parameters
|
|
64
|
+
|
|
65
|
+
• **program**: `Command`
|
|
66
|
+
|
|
67
|
+
The root program command.
|
|
68
|
+
|
|
69
|
+
#### Returns
|
|
70
|
+
|
|
71
|
+
`void`
|
|
72
|
+
|
|
73
|
+
#### Inherited from
|
|
74
|
+
|
|
75
|
+
`CLIBase.configureRoot`
|
|
76
|
+
|
|
77
|
+
***
|
|
78
|
+
|
|
79
|
+
### run()
|
|
80
|
+
|
|
81
|
+
> **run**(`argv`, `localesDirectory`?): `Promise`\<`number`\>
|
|
82
|
+
|
|
83
|
+
Run the app.
|
|
84
|
+
|
|
85
|
+
#### Parameters
|
|
86
|
+
|
|
87
|
+
• **argv**: `string`[]
|
|
88
|
+
|
|
89
|
+
The process arguments.
|
|
90
|
+
|
|
91
|
+
• **localesDirectory?**: `string`
|
|
92
|
+
|
|
93
|
+
The directory for the locales, default to relative to the script.
|
|
94
|
+
|
|
95
|
+
#### Returns
|
|
96
|
+
|
|
97
|
+
`Promise`\<`number`\>
|
|
98
|
+
|
|
99
|
+
The exit code.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Function: actionCommandAddress()
|
|
2
|
+
|
|
3
|
+
> **actionCommandAddress**(`opts`): `Promise`\<`void`\>
|
|
4
|
+
|
|
5
|
+
Action the address command.
|
|
6
|
+
|
|
7
|
+
## Parameters
|
|
8
|
+
|
|
9
|
+
• **opts**: `object` & `ICliOutputOptionsConsole` & `ICliOutputOptionsEnv` & `ICliOutputOptionsJson`
|
|
10
|
+
|
|
11
|
+
The options for the command.
|
|
12
|
+
|
|
13
|
+
## Returns
|
|
14
|
+
|
|
15
|
+
`Promise`\<`void`\>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Function: actionCommandMnemonic()
|
|
2
|
+
|
|
3
|
+
> **actionCommandMnemonic**(`opts`): `Promise`\<`void`\>
|
|
4
|
+
|
|
5
|
+
Action the mnemonic command.
|
|
6
|
+
|
|
7
|
+
## Parameters
|
|
8
|
+
|
|
9
|
+
• **opts**: `object` & `ICliOutputOptionsConsole` & `ICliOutputOptionsEnv` & `ICliOutputOptionsJson`
|
|
10
|
+
|
|
11
|
+
The options for the command.
|
|
12
|
+
|
|
13
|
+
## Returns
|
|
14
|
+
|
|
15
|
+
`Promise`\<`void`\>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# @twin.org/crypto-cli
|
|
2
|
+
|
|
3
|
+
## Classes
|
|
4
|
+
|
|
5
|
+
- [CLI](classes/CLI.md)
|
|
6
|
+
|
|
7
|
+
## Functions
|
|
8
|
+
|
|
9
|
+
- [buildCommandAddress](functions/buildCommandAddress.md)
|
|
10
|
+
- [actionCommandAddress](functions/actionCommandAddress.md)
|
|
11
|
+
- [buildCommandMnemonic](functions/buildCommandMnemonic.md)
|
|
12
|
+
- [actionCommandMnemonic](functions/actionCommandMnemonic.md)
|
package/locales/en.json
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
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
|
+
"commands": {
|
|
12
|
+
"mnemonic": {
|
|
13
|
+
"summary": "Create a mnemonic.",
|
|
14
|
+
"description": "Create a mnemonic, will also generate the equivalent seed in hex and base64 format.",
|
|
15
|
+
"options": {
|
|
16
|
+
"strength": {
|
|
17
|
+
"param": "--strength '<'number'>'",
|
|
18
|
+
"description": "The number of words in the mnemonic, defaults to 256 which produces 24 words."
|
|
19
|
+
},
|
|
20
|
+
"seed-format": {
|
|
21
|
+
"param": "--seed-format '<'format'>'",
|
|
22
|
+
"description": "The format to output the seed."
|
|
23
|
+
},
|
|
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
|
+
},
|
|
37
|
+
"progress": {
|
|
38
|
+
"writingJsonFile": "Writing JSON file",
|
|
39
|
+
"writingEnvFile": "Writing env file"
|
|
40
|
+
},
|
|
41
|
+
"labels": {
|
|
42
|
+
"mnemonic": "Mnemonic",
|
|
43
|
+
"seed": "Seed"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"address": {
|
|
47
|
+
"summary": "Create bech32 addresses and keys from the seed.",
|
|
48
|
+
"description": "Create a number of bech32 addresses and their associated key pairs from the seed.",
|
|
49
|
+
"options": {
|
|
50
|
+
"seed": {
|
|
51
|
+
"param": "--seed '<'seed'>'",
|
|
52
|
+
"description": "The seed to use for generating the addresses, this can be either hex, base64 or an environment variable name. For an environment variable start the value with a !"
|
|
53
|
+
},
|
|
54
|
+
"start": {
|
|
55
|
+
"param": "--start '<'number'>'",
|
|
56
|
+
"description": "The index of the first address to create."
|
|
57
|
+
},
|
|
58
|
+
"count": {
|
|
59
|
+
"param": "--count '<'number'>'",
|
|
60
|
+
"description": "The number of addresses to create, max 100."
|
|
61
|
+
},
|
|
62
|
+
"account": {
|
|
63
|
+
"param": "--account '<'number'>'",
|
|
64
|
+
"description": "The account used to generate the bech32 addresses."
|
|
65
|
+
},
|
|
66
|
+
"hrp": {
|
|
67
|
+
"param": "--hrp '<'hrp'>'",
|
|
68
|
+
"description": "The human readable part of the bech32 addresses."
|
|
69
|
+
},
|
|
70
|
+
"coin": {
|
|
71
|
+
"param": "--coin '<'coin'>'",
|
|
72
|
+
"description": "The coin type used to generate the bech32 addresses."
|
|
73
|
+
},
|
|
74
|
+
"key-type": {
|
|
75
|
+
"param": "--key-type '<'type'>'",
|
|
76
|
+
"description": "The type of key to generate."
|
|
77
|
+
},
|
|
78
|
+
"key-format": {
|
|
79
|
+
"param": "--key-format '<'format'>'",
|
|
80
|
+
"description": "The format to output the keys."
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
"progress": {
|
|
84
|
+
"generatingAddresses": "Generating addresses"
|
|
85
|
+
},
|
|
86
|
+
"labels": {
|
|
87
|
+
"seed": "Seed",
|
|
88
|
+
"start": "Start",
|
|
89
|
+
"count": "Count",
|
|
90
|
+
"account": "Account",
|
|
91
|
+
"hrp": "HRP",
|
|
92
|
+
"coin": "Coin",
|
|
93
|
+
"key-type": "Key Type",
|
|
94
|
+
"key-format": "Key Format",
|
|
95
|
+
"index": "Index",
|
|
96
|
+
"address": "Address",
|
|
97
|
+
"public-key": "Public Key",
|
|
98
|
+
"private-key": "Private Key"
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@twin.org/crypto-cli",
|
|
3
|
+
"version": "0.0.1-next.3",
|
|
4
|
+
"description": "A command line interface for interacting with the crypto tools",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/twinfoundation/framework.git",
|
|
8
|
+
"directory": "packages/crypto-cli"
|
|
9
|
+
},
|
|
10
|
+
"author": "martyn.janes@iota.org",
|
|
11
|
+
"license": "Apache-2.0",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=20.0.0"
|
|
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
|
+
"dependencies": {
|
|
31
|
+
"@twin.org/cli-core": "0.0.1-next.3",
|
|
32
|
+
"@twin.org/core": "0.0.1-next.3",
|
|
33
|
+
"@twin.org/crypto": "0.0.1-next.3",
|
|
34
|
+
"@twin.org/nameof": "next",
|
|
35
|
+
"commander": "12.1.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@twin.org/merge-locales": "next",
|
|
39
|
+
"@twin.org/nameof-transformer": "next",
|
|
40
|
+
"@types/node": "22.5.5",
|
|
41
|
+
"@vitest/coverage-v8": "2.1.1",
|
|
42
|
+
"copyfiles": "2.4.1",
|
|
43
|
+
"rimraf": "6.0.1",
|
|
44
|
+
"rollup": "4.21.3",
|
|
45
|
+
"rollup-plugin-typescript2": "0.36.0",
|
|
46
|
+
"ts-patch": "3.2.1",
|
|
47
|
+
"typedoc": "0.26.7",
|
|
48
|
+
"typedoc-plugin-markdown": "4.2.7",
|
|
49
|
+
"typescript": "5.6.2",
|
|
50
|
+
"vitest": "2.1.1"
|
|
51
|
+
},
|
|
52
|
+
"main": "./dist/cjs/index.cjs",
|
|
53
|
+
"module": "./dist/esm/index.mjs",
|
|
54
|
+
"types": "./dist/types/index.d.ts",
|
|
55
|
+
"exports": {
|
|
56
|
+
".": {
|
|
57
|
+
"require": "./dist/cjs/index.cjs",
|
|
58
|
+
"import": "./dist/esm/index.mjs",
|
|
59
|
+
"types": "./dist/types/index.d.ts"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"files": [
|
|
63
|
+
"bin",
|
|
64
|
+
"dist/cjs",
|
|
65
|
+
"dist/esm",
|
|
66
|
+
"dist/locales",
|
|
67
|
+
"dist/types",
|
|
68
|
+
"locales",
|
|
69
|
+
"docs"
|
|
70
|
+
],
|
|
71
|
+
"bin": {
|
|
72
|
+
"twin-crypto": "bin/index.js"
|
|
73
|
+
}
|
|
74
|
+
}
|