@agrozyme/eckey 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,108 @@
1
+ ## Elliptic Curve Key CLI
2
+
3
+ <!-- toc -->
4
+ * [Usage](#usage)
5
+ * [Commands](#commands)
6
+ <!-- tocstop -->
7
+
8
+ # Usage
9
+
10
+ <!-- usage -->
11
+ ```sh-session
12
+ $ npm install -g @agrozyme/eckey
13
+ $ eckey COMMAND
14
+ running command...
15
+ $ eckey (--version)
16
+ @agrozyme/eckey/0.0.0 win32-x64 node-v16.20.1
17
+ $ eckey --help [COMMAND]
18
+ USAGE
19
+ $ eckey COMMAND
20
+ ...
21
+ ```
22
+ <!-- usagestop -->
23
+
24
+ # Commands
25
+
26
+ <!-- commands -->
27
+ * [`eckey convert`](#eckey-convert)
28
+ * [`eckey help [COMMANDS]`](#eckey-help-commands)
29
+ * [`eckey make`](#eckey-make)
30
+
31
+ ## `eckey convert`
32
+
33
+ convert string to other format
34
+
35
+ ```
36
+ USAGE
37
+ $ eckey convert --data <value> [--from
38
+ base16|base32|base32crockford|base32hex|base58|base58check|base58flickr|base58xmr|base58xrp|base64|base64url|hex|utf
39
+ 8] [--to base16|base32|base32crockford|base32hex|base58|base58check|base58flickr|base58xmr|base58xrp|base64|base64ur
40
+ l|hex|utf8]
41
+
42
+ FLAGS
43
+ --data=<value> (required)
44
+ --from=<option> [default: hex]
45
+ <options: base16|base32|base32crockford|base32hex|base58|base58check|base58flickr|base58xmr|base58xrp
46
+ |base64|base64url|hex|utf8>
47
+ --to=<option> [default: hex]
48
+ <options: base16|base32|base32crockford|base32hex|base58|base58check|base58flickr|base58xmr|base58xrp
49
+ |base64|base64url|hex|utf8>
50
+
51
+ DESCRIPTION
52
+ convert string to other format
53
+
54
+ EXAMPLES
55
+ $ eckey convert
56
+ ```
57
+
58
+ _See code: [dist/commands/convert.ts](https://gitlab.com/agrozyme-package/TypeScript/eckey/blob/v0.0.0/dist/commands/convert.ts)_
59
+
60
+ ## `eckey help [COMMANDS]`
61
+
62
+ Display help for eckey.
63
+
64
+ ```
65
+ USAGE
66
+ $ eckey help [COMMANDS] [-n]
67
+
68
+ ARGUMENTS
69
+ COMMANDS Command to show help for.
70
+
71
+ FLAGS
72
+ -n, --nested-commands Include all nested commands in the output.
73
+
74
+ DESCRIPTION
75
+ Display help for eckey.
76
+ ```
77
+
78
+ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.2.11/src/commands/help.ts)_
79
+
80
+ ## `eckey make`
81
+
82
+ make elliptic curve key pair
83
+
84
+ ```
85
+ USAGE
86
+ $ eckey make --curve
87
+ bls12_381|bn254|ed448|ed448ph|ed25519|ed25519ctx|ed25519ph|jubjub|p256|p384|p521|pallas|schnorr|secp256k1|secp256r1|
88
+ secp384r1|secp521r1|vesta [--format base16|base32|base32crockford|base32hex|base58|base58check|base58flickr|base58xm
89
+ r|base58xrp|base64|base64url|hex|utf8] [--count <value>]
90
+
91
+ FLAGS
92
+ --count=<value> [default: 1]
93
+ --curve=<option> (required)
94
+ <options: bls12_381|bn254|ed448|ed448ph|ed25519|ed25519ctx|ed25519ph|jubjub|p256|p384|p521|pallas|s
95
+ chnorr|secp256k1|secp256r1|secp384r1|secp521r1|vesta>
96
+ --format=<option> [default: hex]
97
+ <options: base16|base32|base32crockford|base32hex|base58|base58check|base58flickr|base58xmr|base58x
98
+ rp|base64|base64url|hex|utf8>
99
+
100
+ DESCRIPTION
101
+ make elliptic curve key pair
102
+
103
+ EXAMPLES
104
+ $ eckey make
105
+ ```
106
+
107
+ _See code: [dist/commands/make.ts](https://gitlab.com/agrozyme-package/TypeScript/eckey/blob/v0.0.0/dist/commands/make.ts)_
108
+ <!-- commandsstop -->
package/bin/dev ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+
3
+ const oclif = require('@oclif/core')
4
+
5
+ const path = require('path')
6
+ const project = path.join(__dirname, '..', 'tsconfig.json')
7
+
8
+ // In dev mode -> use ts-node and dev plugins
9
+ process.env.NODE_ENV = 'development'
10
+
11
+ require('ts-node').register({project})
12
+
13
+ // In dev mode, always show stack traces
14
+ oclif.settings.debug = true;
15
+
16
+ // Start the CLI
17
+ oclif.run().then(oclif.flush).catch(oclif.Errors.handle)
package/bin/dev.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node "%~dp0\dev" %*
package/bin/run ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ const oclif = require('@oclif/core')
4
+
5
+ oclif.run().then(require('@oclif/core/flush')).catch(require('@oclif/core/handle'))
package/bin/run.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node "%~dp0\run" %*
@@ -0,0 +1,12 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class Convert extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ data: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
7
+ from: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
+ to: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
9
+ };
10
+ static args: {};
11
+ run(): Promise<void>;
12
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const crypto_1 = require("@agrozyme/crypto");
4
+ const core_1 = require("@oclif/core");
5
+ const types_1 = require("../types");
6
+ class Convert extends core_1.Command {
7
+ static description = 'convert string to other format';
8
+ static examples = ['<%= config.bin %> <%= command.id %>'];
9
+ static flags = {
10
+ data: core_1.Flags.string({ required: true }),
11
+ from: core_1.Flags.string({ options: types_1.bytesCoderKeys, default: 'hex' }),
12
+ to: core_1.Flags.string({ options: types_1.bytesCoderKeys, default: 'hex' }),
13
+ };
14
+ static args = {};
15
+ async run() {
16
+ const { args, flags } = await this.parse(Convert);
17
+ const { data, from, to } = flags;
18
+ const fromConveter = crypto_1.bytesCoderMap[from];
19
+ const toConveter = crypto_1.bytesCoderMap[to];
20
+ const items = fromConveter.decode(data);
21
+ const result = toConveter.encode(items);
22
+ console.info(`Convert data form ${from} to ${to}:`);
23
+ console.dir({ data, result });
24
+ }
25
+ }
26
+ exports.default = Convert;
@@ -0,0 +1,12 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class Make extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ curve: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
7
+ format: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
+ count: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
9
+ };
10
+ static args: {};
11
+ run(): Promise<void>;
12
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const crypto_1 = require("@agrozyme/crypto");
4
+ const core_1 = require("@oclif/core");
5
+ const types_1 = require("../types");
6
+ class Make extends core_1.Command {
7
+ static description = 'make elliptic curve key pair';
8
+ static examples = ['<%= config.bin %> <%= command.id %>'];
9
+ static flags = {
10
+ curve: core_1.Flags.string({ required: true, options: types_1.curveKeys }),
11
+ format: core_1.Flags.string({ options: types_1.bytesCoderKeys, default: 'hex' }),
12
+ count: core_1.Flags.integer({ min: 1, default: 1 }),
13
+ };
14
+ static args = {};
15
+ async run() {
16
+ const { args, flags } = await this.parse(Make);
17
+ const curve = crypto_1.curveMap[flags.curve];
18
+ const keyConveter = crypto_1.bytesCoderMap[flags.format];
19
+ const items = [];
20
+ for (let index = 0; index < flags.count; index++) {
21
+ const privateKey = curve.randomPrivateKey();
22
+ const publicKey = curve.getPublicKey(privateKey, true);
23
+ const item = { privateKey: keyConveter.encode(privateKey), publicKey: keyConveter.encode(publicKey) };
24
+ items.push(item);
25
+ }
26
+ console.log(`make ${flags.curve} curve ${flags.count} keypair(s) with ${flags.format} format:`);
27
+ console.dir(items);
28
+ }
29
+ }
30
+ exports.default = Make;
@@ -0,0 +1,9 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class Test extends Command {
3
+ static hidden: boolean;
4
+ static description: string;
5
+ static examples: string[];
6
+ static flags: {};
7
+ static args: {};
8
+ run(): Promise<void>;
9
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ class Test extends core_1.Command {
5
+ static hidden = true;
6
+ static description = 'test the command here';
7
+ static examples = ['<%= config.bin %> <%= command.id %>'];
8
+ static flags = {};
9
+ static args = {};
10
+ async run() {
11
+ const { args, flags } = await this.parse(Test);
12
+ // console.dir(bytesCoderMap, { depth: 0 });
13
+ }
14
+ }
15
+ exports.default = Test;
@@ -0,0 +1 @@
1
+ export { run } from '@oclif/core';
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.run = void 0;
4
+ var core_1 = require("@oclif/core");
5
+ Object.defineProperty(exports, "run", { enumerable: true, get: function () { return core_1.run; } });
@@ -0,0 +1,2 @@
1
+ export declare const bytesCoderKeys: string[];
2
+ export declare const curveKeys: string[];
package/dist/types.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.curveKeys = exports.bytesCoderKeys = void 0;
4
+ const crypto_1 = require("@agrozyme/crypto");
5
+ exports.bytesCoderKeys = Object.keys(crypto_1.bytesCoderMap);
6
+ exports.curveKeys = Object.keys(crypto_1.curveMap);
@@ -0,0 +1,151 @@
1
+ {
2
+ "version": "0.0.0",
3
+ "commands": {
4
+ "convert": {
5
+ "id": "convert",
6
+ "description": "convert string to other format",
7
+ "strict": true,
8
+ "pluginName": "@agrozyme/eckey",
9
+ "pluginAlias": "@agrozyme/eckey",
10
+ "pluginType": "core",
11
+ "aliases": [],
12
+ "examples": [
13
+ "<%= config.bin %> <%= command.id %>"
14
+ ],
15
+ "flags": {
16
+ "data": {
17
+ "name": "data",
18
+ "type": "option",
19
+ "required": true,
20
+ "multiple": false
21
+ },
22
+ "from": {
23
+ "name": "from",
24
+ "type": "option",
25
+ "multiple": false,
26
+ "options": [
27
+ "base16",
28
+ "base32",
29
+ "base32crockford",
30
+ "base32hex",
31
+ "base58",
32
+ "base58check",
33
+ "base58flickr",
34
+ "base58xmr",
35
+ "base58xrp",
36
+ "base64",
37
+ "base64url",
38
+ "hex",
39
+ "utf8"
40
+ ],
41
+ "default": "hex"
42
+ },
43
+ "to": {
44
+ "name": "to",
45
+ "type": "option",
46
+ "multiple": false,
47
+ "options": [
48
+ "base16",
49
+ "base32",
50
+ "base32crockford",
51
+ "base32hex",
52
+ "base58",
53
+ "base58check",
54
+ "base58flickr",
55
+ "base58xmr",
56
+ "base58xrp",
57
+ "base64",
58
+ "base64url",
59
+ "hex",
60
+ "utf8"
61
+ ],
62
+ "default": "hex"
63
+ }
64
+ },
65
+ "args": {}
66
+ },
67
+ "make": {
68
+ "id": "make",
69
+ "description": "make elliptic curve key pair",
70
+ "strict": true,
71
+ "pluginName": "@agrozyme/eckey",
72
+ "pluginAlias": "@agrozyme/eckey",
73
+ "pluginType": "core",
74
+ "aliases": [],
75
+ "examples": [
76
+ "<%= config.bin %> <%= command.id %>"
77
+ ],
78
+ "flags": {
79
+ "curve": {
80
+ "name": "curve",
81
+ "type": "option",
82
+ "required": true,
83
+ "multiple": false,
84
+ "options": [
85
+ "bls12_381",
86
+ "bn254",
87
+ "ed448",
88
+ "ed448ph",
89
+ "ed25519",
90
+ "ed25519ctx",
91
+ "ed25519ph",
92
+ "jubjub",
93
+ "p256",
94
+ "p384",
95
+ "p521",
96
+ "pallas",
97
+ "schnorr",
98
+ "secp256k1",
99
+ "secp256r1",
100
+ "secp384r1",
101
+ "secp521r1",
102
+ "vesta"
103
+ ]
104
+ },
105
+ "format": {
106
+ "name": "format",
107
+ "type": "option",
108
+ "multiple": false,
109
+ "options": [
110
+ "base16",
111
+ "base32",
112
+ "base32crockford",
113
+ "base32hex",
114
+ "base58",
115
+ "base58check",
116
+ "base58flickr",
117
+ "base58xmr",
118
+ "base58xrp",
119
+ "base64",
120
+ "base64url",
121
+ "hex",
122
+ "utf8"
123
+ ],
124
+ "default": "hex"
125
+ },
126
+ "count": {
127
+ "name": "count",
128
+ "type": "option",
129
+ "multiple": false,
130
+ "default": 1
131
+ }
132
+ },
133
+ "args": {}
134
+ },
135
+ "test": {
136
+ "id": "test",
137
+ "description": "test the command here",
138
+ "strict": true,
139
+ "pluginName": "@agrozyme/eckey",
140
+ "pluginAlias": "@agrozyme/eckey",
141
+ "pluginType": "core",
142
+ "hidden": true,
143
+ "aliases": [],
144
+ "examples": [
145
+ "<%= config.bin %> <%= command.id %>"
146
+ ],
147
+ "flags": {},
148
+ "args": {}
149
+ }
150
+ }
151
+ }
package/package.json ADDED
@@ -0,0 +1,81 @@
1
+ {
2
+ "name": "@agrozyme/eckey",
3
+ "version": "0.0.0",
4
+ "description": "Elliptic Curve Key CLI",
5
+ "author": "",
6
+ "bin": {
7
+ "eckey": "./bin/run"
8
+ },
9
+ "homepage": "https://gitlab.com/agrozyme-package/TypeScript/eckey",
10
+ "license": "MIT",
11
+ "main": "dist/index.js",
12
+ "repository": "https://gitlab.com/agrozyme-package/TypeScript/eckey.git",
13
+ "files": [
14
+ "/bin",
15
+ "/dist",
16
+ "/npm-shrinkwrap.json",
17
+ "/oclif.manifest.json"
18
+ ],
19
+ "dependencies": {
20
+ "@agrozyme/crypto": "^1",
21
+ "@oclif/core": "^2",
22
+ "@oclif/plugin-help": "^5",
23
+ "@oclif/plugin-plugins": "^3"
24
+ },
25
+ "devDependencies": {
26
+ "@oclif/test": "^2",
27
+ "@types/chai": "^4",
28
+ "@types/jasmine": "^4",
29
+ "@types/node": "^16",
30
+ "chai": "^4",
31
+ "jasmine": "^5",
32
+ "oclif": "^3",
33
+ "pkg": "^5",
34
+ "shx": "^0",
35
+ "ts-node": "^10",
36
+ "ts-node-test-register": "^10",
37
+ "tslib": "^2",
38
+ "typescript": "^5",
39
+ "yarpm": "^1"
40
+ },
41
+ "oclif": {
42
+ "bin": "eckey",
43
+ "dirname": "eckey",
44
+ "commands": "./dist/commands",
45
+ "plugins": [
46
+ "@oclif/plugin-help"
47
+ ],
48
+ "topicSeparator": ":"
49
+ },
50
+ "pkg": {
51
+ "scripts": "dist/**/*.js",
52
+ "assets": "assets/**/*",
53
+ "outputPath": "package",
54
+ "targets": [
55
+ "node16-win",
56
+ "node16-linux",
57
+ "node16-macos"
58
+ ]
59
+ },
60
+ "engines": {
61
+ "node": ">=16"
62
+ },
63
+ "bugs": "https://gitlab.com/agrozyme-package/TypeScript/eckey/issues",
64
+ "keywords": [
65
+ "oclif"
66
+ ],
67
+ "types": "dist/index.d.ts",
68
+ "scripts": {
69
+ "clean": "shx rm -rf dist/ tmp/ package/ && shx rm -f *-debug.log *-error.log .*-debug.log .*-error.log *.tsbuildinfo *.manifest.json",
70
+ "clean:pack": "shx rm -f *.tgz npm-shrinkwrap.json",
71
+ "clean:lock": "shx rm -f package-lock.json yarn.lock pnpm-lock.yaml",
72
+ "clean:all": "yarpm run clean && yarpm run clean:pack && yarpm run clean:lock",
73
+ "build": "yarpm run clean && tsc --build --force && shx cp -R ./src/assets ./dist",
74
+ "test": "jasmine --require=ts-node-test-register test/**/*.ts",
75
+ "oclif:readme": "yarpm run build && oclif readme",
76
+ "oclif:pack": "yarn generate-lock-entry > yarn.lock && oclif pack",
77
+ "package": "yarpm run build && pkg --no-bytecode --public --public-packages=* --compress=GZip .",
78
+ "dev": "node ./bin/dev",
79
+ "start": "node ./bin/run"
80
+ }
81
+ }