@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,312 @@
|
|
|
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
|
+
"common": {
|
|
10
|
+
"missingEnv": "The \"{option}\" option is configured as an environment variable, but there is no environment variable with the name \"{value}\" set.",
|
|
11
|
+
"optionInvalidHex": "The \"{option}\" does not appear to be hex. \"{value}\"",
|
|
12
|
+
"optionInvalidBase64": "The \"{option}\" does not appear to be base64. \"{value}\"",
|
|
13
|
+
"optionInvalidHexBase64": "The \"{option}\" does not appear to be hex or base64. \"{value}\"",
|
|
14
|
+
"optionInvalidBech32": "The \"{option}\" does not appear to be bech32. \"{value}\"",
|
|
15
|
+
"optionMinValue": "The \"{option}\" option must be greater than or equal to {minValue}, it is {value}.",
|
|
16
|
+
"optionMaxValue": "The \"{option}\" option must be less than or equal to {maxValue}, it is {value}."
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"validation": {
|
|
20
|
+
"beEmpty": "{fieldName} must be empty",
|
|
21
|
+
"beNotEmpty": "{fieldName} must not be empty",
|
|
22
|
+
"beText": "{fieldName} must be text",
|
|
23
|
+
"beTextValue": "{fieldName} must contain some text",
|
|
24
|
+
"beTextMinMax": "{fieldName} must be longer than {minLength} and shorter than {maxLength} characters",
|
|
25
|
+
"beTextMin": "{fieldName} must be longer than {minLength} characters",
|
|
26
|
+
"beTextMax": "{fieldName} must be shorter than {maxLength} characters",
|
|
27
|
+
"beNumber": "{fieldName} must be a number",
|
|
28
|
+
"beNumberMinMax": "{fieldName} must be >= {minValue} and <= {maxValue}",
|
|
29
|
+
"beNumberMin": "{fieldName} must be >= {minValue}",
|
|
30
|
+
"beNumberMax": "{fieldName} must be <= {maxValue}",
|
|
31
|
+
"beWholeNumber": "{fieldName} must be a whole number",
|
|
32
|
+
"beWholeNumberMinMax": "{fieldName} must be a whole number >= {minValue} and <= {maxValue}",
|
|
33
|
+
"beWholeNumberMin": "{fieldName} must be a whole number >= {minValue}",
|
|
34
|
+
"beWholeNumberMax": "{fieldName} must be a whole number <= {maxValue}",
|
|
35
|
+
"beBigInteger": "{fieldName} must be a bigint",
|
|
36
|
+
"beBigIntegerMinMax": "{fieldName} must be a bigint >= {minValue} and <= {maxValue}",
|
|
37
|
+
"beBigIntegerMin": "{fieldName} must be a bigint >= {minValue}",
|
|
38
|
+
"beBigIntegerMax": "{fieldName} must be a bigint <= {maxValue}",
|
|
39
|
+
"beBoolean": "{fieldName} must be true or false",
|
|
40
|
+
"beDate": "{fieldName} must be a date",
|
|
41
|
+
"beDateTime": "{fieldName} must be a date/time",
|
|
42
|
+
"beTime": "{fieldName} must be a time",
|
|
43
|
+
"beTimestampMilliseconds": "{fieldName} must be a timestamp in milliseconds",
|
|
44
|
+
"beTimestampSeconds": "{fieldName} must be a timestamp in seconds",
|
|
45
|
+
"beObject": "{fieldName} must be an object",
|
|
46
|
+
"beArray": "{fieldName} must be an array",
|
|
47
|
+
"beArrayValue": "{fieldName} must be an array with at least one item",
|
|
48
|
+
"beIncluded": "{fieldName} is unrecognised",
|
|
49
|
+
"beByteArray": "{fieldName} must be a byte array",
|
|
50
|
+
"beUrn": "{fieldName} must be a correctly formatted urn",
|
|
51
|
+
"beUrl": "{fieldName} must be a correctly formatted url",
|
|
52
|
+
"beJSON": "{fieldName} must be correctly formatted JSON",
|
|
53
|
+
"beEmail": "{fieldName} must be a correctly formatted e-mail address",
|
|
54
|
+
"failed": "Validation failed",
|
|
55
|
+
"failedObject": "Validation of \"{objectName}\" failed"
|
|
56
|
+
},
|
|
57
|
+
"guard": {
|
|
58
|
+
"undefined": "Property \"{property}\" must be defined, it is \"{value}\"",
|
|
59
|
+
"string": "Property \"{property}\" must be a string, it is \"{value}\"",
|
|
60
|
+
"stringEmpty": "Property \"{property}\" must have a value, it is empty",
|
|
61
|
+
"stringBase64": "Property \"{property}\" must be a base64 encoded string, it is \"{value}\"",
|
|
62
|
+
"stringBase64Url": "Property \"{property}\" must be a base64 url encoded string, it is \"{value}\"",
|
|
63
|
+
"stringHex": "Property \"{property}\" must be a hex string, it is \"{value}\"",
|
|
64
|
+
"stringHexLength": "Property \"{property}\" must be a hex string of length \"{options}\", it is \"{value}\"",
|
|
65
|
+
"number": "Property \"{property}\" must be a number, it is \"{value}\"",
|
|
66
|
+
"integer": "Property \"{property}\" must be an integer, it is \"{value}\"",
|
|
67
|
+
"bigint": "Property \"{property}\" must be a bigint, it is \"{value}\"",
|
|
68
|
+
"boolean": "Property \"{property}\" must be a boolean, it is \"{value}\"",
|
|
69
|
+
"date": "Property \"{property}\" must be a date, it is \"{value}\"",
|
|
70
|
+
"timestampMilliseconds": "Property \"{property}\" must be a timestamp in milliseconds, it is \"{value}\"",
|
|
71
|
+
"timestampSeconds": "Property \"{property}\" must be a timestamp in seconds, it is \"{value}\"",
|
|
72
|
+
"objectUndefined": "Property \"{property}\" must be an object, it is \"undefined\"",
|
|
73
|
+
"object": "Property \"{property}\" must be an object, it is \"{value}\"",
|
|
74
|
+
"objectValue": "Property \"{property}\" must be an object, with at least one property, it is \"{value}\"",
|
|
75
|
+
"array": "Property \"{property}\" must be an array, it is \"{value}\"",
|
|
76
|
+
"arrayValue": "Property \"{property}\" must be an array with at least one item",
|
|
77
|
+
"arrayOneOf": "Property \"{property}\" must be one of [{options}], it is \"{value}\"",
|
|
78
|
+
"uint8Array": "Property \"{property}\" must be a Uint8Array, it is \"{value}\"",
|
|
79
|
+
"function": "Property \"{property}\" must be a function, it is \"{value}\"",
|
|
80
|
+
"urn": "Property \"{property}\" must be a Urn formatted string, it is \"{value}\"",
|
|
81
|
+
"url": "Property \"{property}\" must be a Url formatted string, it is \"{value}\"",
|
|
82
|
+
"email": "Property \"{property}\" must be string in e-mail format, it is \"{value}\"",
|
|
83
|
+
"length32Multiple": "Property \"{property}\" should be a multiple of 32, it is {value}",
|
|
84
|
+
"lengthEntropy": "Property \"{property}\" should be a multiple of 4, >=16 and <= 32, it is {value}",
|
|
85
|
+
"length3Multiple": "Property \"{property}\" should be a multiple of 3, it is {value}",
|
|
86
|
+
"greaterThan0": "Property \"{property}\" must be greater than zero, it is {value}"
|
|
87
|
+
},
|
|
88
|
+
"objectHelper": {
|
|
89
|
+
"failedBytesToJSON": "Failed converting bytes to JSON"
|
|
90
|
+
},
|
|
91
|
+
"common": {
|
|
92
|
+
"notImplementedMethod": "The method \"{method}\" has not been implemented",
|
|
93
|
+
"validation": "Validation failed"
|
|
94
|
+
},
|
|
95
|
+
"factory": {
|
|
96
|
+
"noUnregister": "There is no {typeName} registered with the name \"{name}\"",
|
|
97
|
+
"noGet": "The requested {typeName} \"{name}\" does not exist in the factory"
|
|
98
|
+
},
|
|
99
|
+
"bitString": {
|
|
100
|
+
"outOfRange": "The index should be >= 0 and less than the length of the bit string"
|
|
101
|
+
},
|
|
102
|
+
"bip39": {
|
|
103
|
+
"missingMnemonicWord": "The mnemonic contains a word not in the wordlist, \"{value}\"",
|
|
104
|
+
"checksumMismatch": "The checksum does not match \"{newChecksum}\" != \"{checksumBits}\""
|
|
105
|
+
},
|
|
106
|
+
"ed25519": {
|
|
107
|
+
"privateKeyLength": "The private key length is incorrect, it should be \"{requiredSize}\" but is \"{actualSize}\"",
|
|
108
|
+
"publicKeyLength": "The public key length is incorrect, it should be \"{requiredSize}\" but is \"{actualSize}\""
|
|
109
|
+
},
|
|
110
|
+
"secp256k1": {
|
|
111
|
+
"privateKeyLength": "The private key length is incorrect, it should be \"{requiredSize}\" but is \"{actualSize}\"",
|
|
112
|
+
"publicKeyLength": "The public key length is incorrect, it should be \"{requiredSize}\" but is \"{actualSize}\""
|
|
113
|
+
},
|
|
114
|
+
"x25519": {
|
|
115
|
+
"invalidPublicKey": "Invalid Ed25519 Public Key"
|
|
116
|
+
},
|
|
117
|
+
"blake2b": {
|
|
118
|
+
"outputLength64": "The output length should be between 1 and 64, it is \"{outputLength}\"",
|
|
119
|
+
"keyLength64": "The key length should be between 1 and 64, it is \"{keyLength}\""
|
|
120
|
+
},
|
|
121
|
+
"sha512": {
|
|
122
|
+
"bitSize": "Only 224, 256, 384 or 512 bits are supported, it is \"{bitSize}\""
|
|
123
|
+
},
|
|
124
|
+
"sha256": {
|
|
125
|
+
"bitSize": "Only 224 or 256 bits are supported, it is \"{bitSize}\""
|
|
126
|
+
},
|
|
127
|
+
"hmacSha256": {
|
|
128
|
+
"bitSize": "Only 224 or 256 bits are supported, it is \"{bitSize}\""
|
|
129
|
+
},
|
|
130
|
+
"hmacSha512": {
|
|
131
|
+
"bitSize": "Only 224, 256, 384 or 512 bits are supported, it is \"{bitSize}\""
|
|
132
|
+
},
|
|
133
|
+
"base32": {
|
|
134
|
+
"invalidCharacter": "Data contains a character \"{invalidCharacter}\" which is not in the charset"
|
|
135
|
+
},
|
|
136
|
+
"base64": {
|
|
137
|
+
"length4Multiple": "Invalid length should be a multiple of 4, it is \"{value}\""
|
|
138
|
+
},
|
|
139
|
+
"bech32": {
|
|
140
|
+
"decodeFailed": "The address contains decoding failed for address \"{bech32}\"",
|
|
141
|
+
"invalidChecksum": "The address contains an invalid checksum in address, \"{bech32}\"",
|
|
142
|
+
"separatorMisused": "The separator character '1' should only be used between hrp and data, \"{bech32}\"",
|
|
143
|
+
"lowerUpper": "The address my use either lowercase or uppercase, \"{bech32}\"",
|
|
144
|
+
"dataTooShort": "The address does not contain enough data to decode, \"{bech32}\""
|
|
145
|
+
},
|
|
146
|
+
"pbkdf2": {
|
|
147
|
+
"keyTooLong": "The requested key length \"{keyLength}\" is too long, based on the \"{macLength}\""
|
|
148
|
+
},
|
|
149
|
+
"chaCha20Poly1305": {
|
|
150
|
+
"noAadWithData": "You can not set the aad when there is already data",
|
|
151
|
+
"noAuthTag": "Can not finalise when the auth tag is not set",
|
|
152
|
+
"authenticationFailed": "The data could not be authenticated",
|
|
153
|
+
"authTagDecrypting": "Can not get the auth tag when decrypting",
|
|
154
|
+
"authTagEncrypting": "Can not set the auth tag when encrypting",
|
|
155
|
+
"noAuthTagSet": "The auth tag has not been set"
|
|
156
|
+
},
|
|
157
|
+
"bip44": {
|
|
158
|
+
"unsupportedKeyType": "The key type \"{keyType}\" is not supported"
|
|
159
|
+
},
|
|
160
|
+
"slip0010": {
|
|
161
|
+
"invalidSeed": "The seed is invalid \"{seed}\""
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
"commands": {
|
|
165
|
+
"mnemonic": {
|
|
166
|
+
"summary": "Create a mnemonic.",
|
|
167
|
+
"description": "Create a mnemonic, will also generate the equivalent seed in hex and base64 format.",
|
|
168
|
+
"options": {
|
|
169
|
+
"strength": {
|
|
170
|
+
"param": "--strength '<'number'>'",
|
|
171
|
+
"description": "The number of words in the mnemonic, defaults to 256 which produces 24 words."
|
|
172
|
+
},
|
|
173
|
+
"seed-format": {
|
|
174
|
+
"param": "--seed-format '<'format'>'",
|
|
175
|
+
"description": "The format to output the seed."
|
|
176
|
+
},
|
|
177
|
+
"no-console": {
|
|
178
|
+
"param": "--no-console",
|
|
179
|
+
"description": "Hides the mnemonic and seed in the console."
|
|
180
|
+
},
|
|
181
|
+
"json": {
|
|
182
|
+
"param": "--json '<'filename'>'",
|
|
183
|
+
"description": "Creates a JSON file containing the mnemonic and seed."
|
|
184
|
+
},
|
|
185
|
+
"env": {
|
|
186
|
+
"param": "--env '<'filename'>'",
|
|
187
|
+
"description": "Creates an env file containing the mnemonic and seed."
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
"progress": {
|
|
191
|
+
"writingJsonFile": "Writing JSON file",
|
|
192
|
+
"writingEnvFile": "Writing env file"
|
|
193
|
+
},
|
|
194
|
+
"labels": {
|
|
195
|
+
"mnemonic": "Mnemonic",
|
|
196
|
+
"seed": "Seed"
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
"address": {
|
|
200
|
+
"summary": "Create bech32 addresses and keys from the seed.",
|
|
201
|
+
"description": "Create a number of bech32 addresses and their associated key pairs from the seed.",
|
|
202
|
+
"options": {
|
|
203
|
+
"seed": {
|
|
204
|
+
"param": "--seed '<'seed'>'",
|
|
205
|
+
"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 !"
|
|
206
|
+
},
|
|
207
|
+
"start": {
|
|
208
|
+
"param": "--start '<'number'>'",
|
|
209
|
+
"description": "The index of the first address to create."
|
|
210
|
+
},
|
|
211
|
+
"count": {
|
|
212
|
+
"param": "--count '<'number'>'",
|
|
213
|
+
"description": "The number of addresses to create, max 100."
|
|
214
|
+
},
|
|
215
|
+
"account": {
|
|
216
|
+
"param": "--account '<'number'>'",
|
|
217
|
+
"description": "The account used to generate the bech32 addresses."
|
|
218
|
+
},
|
|
219
|
+
"hrp": {
|
|
220
|
+
"param": "--hrp '<'hrp'>'",
|
|
221
|
+
"description": "The human readable part of the bech32 addresses."
|
|
222
|
+
},
|
|
223
|
+
"coin": {
|
|
224
|
+
"param": "--coin '<'coin'>'",
|
|
225
|
+
"description": "The coin type used to generate the bech32 addresses."
|
|
226
|
+
},
|
|
227
|
+
"key-type": {
|
|
228
|
+
"param": "--key-type '<'type'>'",
|
|
229
|
+
"description": "The type of key to generate."
|
|
230
|
+
},
|
|
231
|
+
"key-format": {
|
|
232
|
+
"param": "--key-format '<'format'>'",
|
|
233
|
+
"description": "The format to output the keys."
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
"progress": {
|
|
237
|
+
"generatingAddresses": "Generating addresses"
|
|
238
|
+
},
|
|
239
|
+
"labels": {
|
|
240
|
+
"seed": "Seed",
|
|
241
|
+
"start": "Start",
|
|
242
|
+
"count": "Count",
|
|
243
|
+
"account": "Account",
|
|
244
|
+
"hrp": "HRP",
|
|
245
|
+
"coin": "Coin",
|
|
246
|
+
"key-type": "Key Type",
|
|
247
|
+
"key-format": "Key Format",
|
|
248
|
+
"index": "Index",
|
|
249
|
+
"address": "Address",
|
|
250
|
+
"public-key": "Public Key",
|
|
251
|
+
"private-key": "Private Key"
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
"cli": {
|
|
256
|
+
"progress": {
|
|
257
|
+
"done": "Done.",
|
|
258
|
+
"error": "Error",
|
|
259
|
+
"loadingEnvFiles": "Loading env files",
|
|
260
|
+
"pleaseWait": "Please wait...",
|
|
261
|
+
"writingJsonFile": "Writing JSON file",
|
|
262
|
+
"writingEnvFile": "Writing env file",
|
|
263
|
+
"readingJsonFile": "Reading JSON file",
|
|
264
|
+
"readingEnvFile": "Reading env file"
|
|
265
|
+
},
|
|
266
|
+
"options": {
|
|
267
|
+
"lang": {
|
|
268
|
+
"param": "--lang '<'lang'>'",
|
|
269
|
+
"description": "The language to display the output in."
|
|
270
|
+
},
|
|
271
|
+
"load-env": {
|
|
272
|
+
"param": "--load-env [env...]",
|
|
273
|
+
"description": "Load the env files to initialise any environment variables."
|
|
274
|
+
},
|
|
275
|
+
"no-console": {
|
|
276
|
+
"param": "--no-console",
|
|
277
|
+
"description": "Hides the output in the console."
|
|
278
|
+
},
|
|
279
|
+
"json": {
|
|
280
|
+
"param": "--json '<'filename'>'",
|
|
281
|
+
"description": "Creates a JSON file containing the output."
|
|
282
|
+
},
|
|
283
|
+
"env": {
|
|
284
|
+
"param": "--env '<'filename'>'",
|
|
285
|
+
"description": "Creates an env file containing the output."
|
|
286
|
+
},
|
|
287
|
+
"merge-json": {
|
|
288
|
+
"param": "--merge-json",
|
|
289
|
+
"description": "If the JSON file already exists merge the data instead of overwriting."
|
|
290
|
+
},
|
|
291
|
+
"merge-env": {
|
|
292
|
+
"param": "--merge-env",
|
|
293
|
+
"description": "If the env file already exists merge the data instead of overwriting."
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
"errorNames": {
|
|
298
|
+
"error": "Error",
|
|
299
|
+
"generalError": "General",
|
|
300
|
+
"guardError": "Guard",
|
|
301
|
+
"conflictError": "Conflict",
|
|
302
|
+
"notFoundError": "Not Found",
|
|
303
|
+
"notSupportedError": "Not Supported",
|
|
304
|
+
"alreadyExistsError": "Already Exists",
|
|
305
|
+
"notImplementedError": "Not Implemented",
|
|
306
|
+
"validationError": "Validation",
|
|
307
|
+
"unprocessableError": "Unprocessable"
|
|
308
|
+
},
|
|
309
|
+
"validation": {
|
|
310
|
+
"defaultFieldName": "The field"
|
|
311
|
+
}
|
|
312
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CLIBase } from "@twin.org/cli-core";
|
|
2
|
+
/**
|
|
3
|
+
* The main entry point for the CLI.
|
|
4
|
+
*/
|
|
5
|
+
export declare class CLI extends CLIBase {
|
|
6
|
+
/**
|
|
7
|
+
* Run the app.
|
|
8
|
+
* @param argv The process arguments.
|
|
9
|
+
* @param localesDirectory The directory for the locales, default to relative to the script.
|
|
10
|
+
* @returns The exit code.
|
|
11
|
+
*/
|
|
12
|
+
run(argv: string[], localesDirectory?: string): Promise<number>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type CliOutputOptions } from "@twin.org/cli-core";
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
/**
|
|
4
|
+
* Build the address command to be consumed by the CLI.
|
|
5
|
+
* @returns The command.
|
|
6
|
+
*/
|
|
7
|
+
export declare function buildCommandAddress(): Command;
|
|
8
|
+
/**
|
|
9
|
+
* Action the address command.
|
|
10
|
+
* @param opts The options for the command.
|
|
11
|
+
* @param opts.seed The seed for generating the addresses.
|
|
12
|
+
* @param opts.start The start index for the address generation.
|
|
13
|
+
* @param opts.count The number of addresses to generate.
|
|
14
|
+
* @param opts.account The account index for the address generation.
|
|
15
|
+
* @param opts.hrp The human readable part for the address.
|
|
16
|
+
* @param opts.coin The coin type for the address.
|
|
17
|
+
* @param opts.keyType The key type for the address.
|
|
18
|
+
* @param opts.keyFormat The output format of the key.
|
|
19
|
+
*/
|
|
20
|
+
export declare function actionCommandAddress(opts: {
|
|
21
|
+
seed: string;
|
|
22
|
+
start: string;
|
|
23
|
+
count: string;
|
|
24
|
+
account: string;
|
|
25
|
+
hrp: string;
|
|
26
|
+
coin: string;
|
|
27
|
+
keyType: "Ed25519" | "Secp256k1";
|
|
28
|
+
keyFormat: "hex" | "base64";
|
|
29
|
+
} & CliOutputOptions): Promise<void>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type CliOutputOptions } from "@twin.org/cli-core";
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
/**
|
|
4
|
+
* Build the mnemonic command to be consumed by the CLI.
|
|
5
|
+
* @returns The command.
|
|
6
|
+
*/
|
|
7
|
+
export declare function buildCommandMnemonic(): Command;
|
|
8
|
+
/**
|
|
9
|
+
* Action the mnemonic command.
|
|
10
|
+
* @param opts The options for the command.
|
|
11
|
+
* @param opts.strength The mnemonic strength.
|
|
12
|
+
* @param opts.seedFormat The output format of the seed.
|
|
13
|
+
*/
|
|
14
|
+
export declare function actionCommandMnemonic(opts: {
|
|
15
|
+
strength: string;
|
|
16
|
+
seedFormat: "hex" | "base64";
|
|
17
|
+
} & CliOutputOptions): Promise<void>;
|
package/docs/examples.md
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
# @twin.org/crypto-cli - Examples
|
|
2
|
+
|
|
3
|
+
## Command Line Tool
|
|
4
|
+
|
|
5
|
+
First install the tool with the following script.
|
|
6
|
+
|
|
7
|
+
```shell
|
|
8
|
+
npm install @twin.org/crypto-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Running
|
|
12
|
+
|
|
13
|
+
If you run the tool with no command line options:
|
|
14
|
+
|
|
15
|
+
```shell
|
|
16
|
+
twin-crypto
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
You should see output similar to the following
|
|
20
|
+
|
|
21
|
+
```shell
|
|
22
|
+
🌍 TWIN Crypto v1.0.0
|
|
23
|
+
|
|
24
|
+
Usage: twin-crypto [command]
|
|
25
|
+
|
|
26
|
+
Options:
|
|
27
|
+
-V, --version output the version number
|
|
28
|
+
--lang <lang> The language to display the output in. (default: "en")
|
|
29
|
+
-h, --help display help for command
|
|
30
|
+
|
|
31
|
+
Commands:
|
|
32
|
+
mnemonic [options] Create a mnemonic.
|
|
33
|
+
address [options] Create bech32 addresses and keys from the seed.
|
|
34
|
+
help [command] display help for command
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Command
|
|
38
|
+
|
|
39
|
+
### mnemonic
|
|
40
|
+
|
|
41
|
+
The mnemonic command can be used to generate a new mnemonic for use in the other crypto functions.
|
|
42
|
+
|
|
43
|
+
```shell
|
|
44
|
+
twin-crypto mnemonic
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Output
|
|
48
|
+
|
|
49
|
+
```shell
|
|
50
|
+
🌍 TWIN Crypto v1.0.0
|
|
51
|
+
|
|
52
|
+
Mnemonic: cricket pumpkin clump warrior accident appear trophy exchange width ginger thank common must tiny inform feed orient ritual tackle tortoise few survey client object
|
|
53
|
+
Seed: 0x01fb73209537a33a2f03e419caed0eba48005b093b9a8ce35a93f5e3a1ad66ceaccb1afd4cd23ccaef3f0210e377a5118c90c7a5f1800be49a42d1c3dc0bb3fc
|
|
54
|
+
|
|
55
|
+
Done.
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
There are additional options you can specify for this command, to get the detail on these options issue the following command to get help.
|
|
59
|
+
|
|
60
|
+
```shell
|
|
61
|
+
twin-crypto mnemonic --help
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Output
|
|
65
|
+
|
|
66
|
+
```shell
|
|
67
|
+
🌍 TWIN Crypto v1.0.0
|
|
68
|
+
|
|
69
|
+
Usage: twin-crypto mnemonic [options]
|
|
70
|
+
|
|
71
|
+
Create a mnemonic, will also generate the equivalent seed in hex and base64 format.
|
|
72
|
+
|
|
73
|
+
Options:
|
|
74
|
+
--strength <number> The number of words in the mnemonic, defaults to 256 which produces 24 words. (default: "256")
|
|
75
|
+
--seed-format <format> The format to output the seed. (choices: "hex", "base64", default: "hex")
|
|
76
|
+
--no-console Hides the mnemonic and seed in the console.
|
|
77
|
+
--json <filename> Creates a JSON file containing the mnemonic and seed.
|
|
78
|
+
--env <filename> Creates an env file containing the mnemonic and seed.
|
|
79
|
+
-h, --help display help for command
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### Example
|
|
83
|
+
|
|
84
|
+
To output generate mnemonic and base64 formatted seed, store them in a JSON and env file but not display them to the console you would enter the following.
|
|
85
|
+
|
|
86
|
+
```shell
|
|
87
|
+
twin-crypto mnemonic --seed-format base64 --no-console --json my.json --env my.env
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
The env file would look like:
|
|
91
|
+
|
|
92
|
+
```shell
|
|
93
|
+
MNEMONIC="word maze network cabbage romance empty axis scale vintage ride flash soup jelly cook give luxury rigid cigar noodle avocado current write clog little"
|
|
94
|
+
SEED="c/MkRa4rgvvf08nJy2v4Yadip5BpE56FW2jDXmjt4TMfoXrCoYo9Hunq9SQdabh+Mox0vR9J3INoVLCZPQ/UtA=="
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
and the JSON file would be:
|
|
98
|
+
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"mnemonic": "word maze network cabbage romance empty axis scale vintage ride flash soup jelly cook give luxury rigid cigar noodle avocado current write clog little",
|
|
102
|
+
"seed": "c/MkRa4rgvvf08nJy2v4Yadip5BpE56FW2jDXmjt4TMfoXrCoYo9Hunq9SQdabh+Mox0vR9J3INoVLCZPQ/UtA=="
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### address
|
|
107
|
+
|
|
108
|
+
The address command can be used to generate addresses and key pairs based on the specified seed. The seed can be provided from the command line of read from an environment variable or .env file. By default 10 addresses will be generated starting at address index 0, for account 0.
|
|
109
|
+
|
|
110
|
+
```shell
|
|
111
|
+
twin-crypto address --seed 0x01fb73209537a33a2f03e419caed0eba48005b093b9a8ce35a93f5e3a1ad66ceaccb1afd4cd23ccaef3f0210e377a5118c90c7a5f1800be49a42d1c3dc0bb3fc
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Output
|
|
115
|
+
|
|
116
|
+
```shell
|
|
117
|
+
🌍 TWIN Crypto v1.0.0
|
|
118
|
+
|
|
119
|
+
Seed: 0x01fb73209537a33a2f03e419caed0eba48005b093b9a8ce35a93f5e3a1ad66ceaccb1afd4cd23ccaef3f0210e377a5118c90c7a5f1800be49a42d1c3dc0bb3fc
|
|
120
|
+
Start: 0
|
|
121
|
+
Count: 10
|
|
122
|
+
Account: 0
|
|
123
|
+
HRP: iota
|
|
124
|
+
Coin: 4218
|
|
125
|
+
Key Type: Ed25519
|
|
126
|
+
Key Format: hex
|
|
127
|
+
|
|
128
|
+
Generating addresses
|
|
129
|
+
|
|
130
|
+
Index: 0
|
|
131
|
+
Address: iota1qzl6pvdadahge7yyqdyknrutuwnjafntdjlnfv94vndue9qupkr9224vjv7
|
|
132
|
+
Private Key: 0xa72161f8b9714c8382bcb7f72a5ea178880495fa85b1376a138249aaf1b2e837
|
|
133
|
+
Public Key: 0xe6994b391c937a604315a9936393f0ef1ad2d49bf5f21573316dc024c1dcb3ae
|
|
134
|
+
|
|
135
|
+
Index: 1
|
|
136
|
+
Address: iota1qq0hu7h6aguva0z0zlayukdjpq3x5dkvyt4gz5gxd7tvuye70sgqv55tgqd
|
|
137
|
+
Private Key: 0xcc57b040833465b530cd87e0c427162a7313f41e15484ef74f641cbb4739d376
|
|
138
|
+
Public Key: 0xcfee67931921b9cf86dbb7f91807b27a275f57364e71d849b86bfc8f671d0f32
|
|
139
|
+
|
|
140
|
+
Index: 2
|
|
141
|
+
Address: iota1qpqeq9xrnz7w7wenfa2ku02p73a90cpz6h7lprz458ydxjtsy009sutjley
|
|
142
|
+
Private Key: 0x254c4ac4ec71e69bfb244052f8e96435aeefe9da0b0cb432f490fadd51576c49
|
|
143
|
+
Public Key: 0x9fc74352fd77f3c49d714eb67339195a291f6e56bdfca9224962815fac3edc62
|
|
144
|
+
|
|
145
|
+
Index: 3
|
|
146
|
+
Address: iota1qzj5chjj2r6es9m50ssy22adlkankz2cf4gch7gs76mnq4l2c4dck53p87a
|
|
147
|
+
Private Key: 0x9a58e95dc70b77afa5ac93c5b4af890159c0ca8a69a1971181ba1f4a021edd57
|
|
148
|
+
Public Key: 0x42f8ab19112418266e7b84edaa63e12e4ef08106d8ccceb930f0956203532363
|
|
149
|
+
|
|
150
|
+
Index: 4
|
|
151
|
+
Address: iota1qzyyqzdcpufrpg2h8n4ljmzgzcsf0vcym6c7rv8l08s7rufjj2pkzefpl6f
|
|
152
|
+
Private Key: 0xff4ed1b01af12a6b87e9b95a7cdecab4be3ba920e8090457189e0f7b9cff2704
|
|
153
|
+
Public Key: 0x19ebdb080b0b8b485249c18ebc841d574429c994830cda139d84b14bf5f92025
|
|
154
|
+
|
|
155
|
+
Index: 5
|
|
156
|
+
Address: iota1qpuq48kqkk582l4c2l0gx9vrmdnfh69rrr2xdusnl25htwy6j4s4jt5vqe8
|
|
157
|
+
Private Key: 0x3445b21235ec0d35c7b9030262ad361101c08d57cda5d6c8a9a427a8b7c7fa17
|
|
158
|
+
Public Key: 0xb01632576d4f8fbddebc3bc624e2d5beb41f0352a22a7b8aa7895e4e746e4979
|
|
159
|
+
|
|
160
|
+
Index: 6
|
|
161
|
+
Address: iota1qpvn3wgyfm4t78ad9qpdee3dwmcsp5h5k8c6saundlf8f0e5apyhs5xam7e
|
|
162
|
+
Private Key: 0x35e609b27328f02cbf944e256d26b50259af571614f491b5823ac794ec23dd40
|
|
163
|
+
Public Key: 0x6156dbd30118e3e9b65dfdbfcdd8d33a5397e1e83eb5ca9271088189eae725d6
|
|
164
|
+
|
|
165
|
+
Index: 7
|
|
166
|
+
Address: iota1qrvx8r3tch4nufjrwrdes5rgl4ak8qx445532z0rmynrz4j2fa05uwlegwf
|
|
167
|
+
Private Key: 0x512f34563657f31f93f6ff675a5cc2bdecb60c04f70c1e6989600bec709bfe81
|
|
168
|
+
Public Key: 0xeaecd2c8c1b0a5e76e740b65189ae69acdcbe2555343b3bfbd5230873d7d367e
|
|
169
|
+
|
|
170
|
+
Index: 8
|
|
171
|
+
Address: iota1qqeyes0f5nqpe5t86slkph2nufj2e496eexyfxec3q7lu45veyvtcp9tz47
|
|
172
|
+
Private Key: 0xf2249753e80bb53776dccae45195bd36079f17ecd758eb71c0ce3d30d39248e9
|
|
173
|
+
Public Key: 0xd744fe270e65f348fda0761f05df3c597afd85dfa3a2d57ba468a62dae89d658
|
|
174
|
+
|
|
175
|
+
Index: 9
|
|
176
|
+
Address: iota1qrdxdv0uqpy6pwlgp8j5wdscj88jrwxzuhye6z2tzkrqp5l65kk2spzplej
|
|
177
|
+
Private Key: 0x3bfb352e637ef067866e66974647d3758d80629dd1108f77956487da9ace80d9
|
|
178
|
+
Public Key: 0x9d10790d366deb6a73ea7666318cf46c8f5493346fc32865edbc3beda15872c6
|
|
179
|
+
|
|
180
|
+
Done.
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
There are additional options you can specify for this command, to get the detail on these options issue the following command to get help.
|
|
184
|
+
|
|
185
|
+
```shell
|
|
186
|
+
twin-crypto address --help
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Output
|
|
190
|
+
|
|
191
|
+
```shell
|
|
192
|
+
🌍 TWIN Crypto v1.0.0
|
|
193
|
+
|
|
194
|
+
sage: twin-crypto address [options]
|
|
195
|
+
|
|
196
|
+
Create a number of bech32 addresses and their associated key pairs from the seed.
|
|
197
|
+
|
|
198
|
+
Options:
|
|
199
|
+
--seed <seed> 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 !
|
|
200
|
+
--load-env <env> Load the env file to initialise any environment variables.
|
|
201
|
+
--start <number> The index of the first address to create. (default: "0")
|
|
202
|
+
--count <number> The number of addresses to create, max 100. (default: "10")
|
|
203
|
+
--account <number> The account used to generate the bech32 addresses. (default: "0")
|
|
204
|
+
--hrp <hrp> The human readable part of the bech32 addresses. (default: "iota")
|
|
205
|
+
--coin <coin> The coin type used to generate the bech32 addresses. (default: "4218")
|
|
206
|
+
--key-type <type> The type of key to generate. (choices: "Ed25519", "Secp256k1", default: "Ed25519")
|
|
207
|
+
--key-format <format> The format to output the keys. (choices: "hex", "base64", default: "hex")
|
|
208
|
+
--no-console Hides the addresses and keys in the console.
|
|
209
|
+
--json <filename> Creates a JSON file containing the addresses and keys.
|
|
210
|
+
--merge-json If the JSON file already exists merge the data instead of overwriting.
|
|
211
|
+
--env <filename> Creates an env file containing the addresses and keys.
|
|
212
|
+
--merge-env If the env file already exists merge the data instead of overwriting.
|
|
213
|
+
-h, --help display help for command
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
#### Examples
|
|
217
|
+
|
|
218
|
+
To read from an env file and load the variable named SEED from the file, and output only 2 addresses, outputting the keys in base64 format.
|
|
219
|
+
|
|
220
|
+
```shell
|
|
221
|
+
twin-crypto address --load-env my.env --seed !SEED --count 2 --key-format base64
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
You can use the options to store the results in JSON or env files, and the `merge` options allow you to modify existing files should you wish.
|
|
225
|
+
|
|
226
|
+
```shell
|
|
227
|
+
twin-crypto address --load-env my.env --seed !SEED --env address.env --merge-env --json address.json --merge-json
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
The output of this command would produce address.env
|
|
231
|
+
|
|
232
|
+
```shell
|
|
233
|
+
ADDRESS_0_BECH32="iota1qqcpqyrnqtzteu7k26dgjvjp3x76tts526prtwrjq99v50pyv6l9xysdcg8"
|
|
234
|
+
ADDRESS_0_PRIVATE_KEY="0x3b2863db878ce156a46d2142c72baa7807a40a990684604ff86456821228d978"
|
|
235
|
+
ADDRESS_0_PUBLIC_KEY="0x6b6eb9e54b44bfbc65c4a02c6489609fbc9588e640ca44bfdfdb1af4e5874905"
|
|
236
|
+
ADDRESS_1_BECH32="iota1qrqyyyuhfzgrp7ducjapg8pta3w877nu0u5jpe50cxx39qjs08kczw7uj4v"
|
|
237
|
+
ADDRESS_1_PRIVATE_KEY="0xc5038b4c0b1dc46769687e77555a7be176e22de4262cf5aabf11290ab7c8d856"
|
|
238
|
+
ADDRESS_1_PUBLIC_KEY="0x603d9b2d25341d142524867536e3ee94d3e02a45fe498ec4c3473b0449446d77"
|
|
239
|
+
....
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
and address.json
|
|
243
|
+
|
|
244
|
+
```json
|
|
245
|
+
{
|
|
246
|
+
"0": {
|
|
247
|
+
"bech32": "iota1qqcpqyrnqtzteu7k26dgjvjp3x76tts526prtwrjq99v50pyv6l9xysdcg8",
|
|
248
|
+
"privateKey": "0x3b2863db878ce156a46d2142c72baa7807a40a990684604ff86456821228d978",
|
|
249
|
+
"publicKey": "0x6b6eb9e54b44bfbc65c4a02c6489609fbc9588e640ca44bfdfdb1af4e5874905"
|
|
250
|
+
},
|
|
251
|
+
"1": {
|
|
252
|
+
"bech32": "iota1qrqyyyuhfzgrp7ducjapg8pta3w877nu0u5jpe50cxx39qjs08kczw7uj4v",
|
|
253
|
+
"privateKey": "0xc5038b4c0b1dc46769687e77555a7be176e22de4262cf5aabf11290ab7c8d856",
|
|
254
|
+
"publicKey": "0x603d9b2d25341d142524867536e3ee94d3e02a45fe498ec4c3473b0449446d77"
|
|
255
|
+
},
|
|
256
|
+
...
|
|
257
|
+
}
|
|
258
|
+
```
|