@learncard/cli 1.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/CHANGELOG.md +12 -0
- package/README.md +37 -0
- package/dist/index.js +113 -0
- package/package.json +32 -0
- package/rollup.config.js +12 -0
- package/src/index.tsx +91 -0
- package/src/random.ts +3 -0
- package/tsconfig.json +36 -0
package/CHANGELOG.md
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
[<img src="https://user-images.githubusercontent.com/2185016/176284693-4ca14052-d067-4ea5-b170-c6cd2594ee23.png" width="400"/>](image.png)
|
|
2
|
+
|
|
3
|
+
# @learncard/cli
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@learncard/cli)
|
|
6
|
+
[](https://www.npmjs.com/package/@learncard/cli)
|
|
7
|
+
[](https://www.npmjs.com/package/@learncard/cli)
|
|
8
|
+
|
|
9
|
+
**LearnCard CLI** is an easy to use node REPL that instantiates a Learn Card wallet for you and gives
|
|
10
|
+
you all the tools you need to easily play around with the Learn Card SDK!
|
|
11
|
+
|
|
12
|
+
## Documentation
|
|
13
|
+
All LearnCard documentation can be found at:
|
|
14
|
+
https://app.gitbook.com/o/6uDv1QDlxaaZC7i8EaGb/s/FXvEJ9j3Vf3FW5Nc557n/
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npx @learncard/cli
|
|
20
|
+
|
|
21
|
+
# Optionally specify a seed
|
|
22
|
+
npx @learncard/cli 1b498556081a298261313657c32d5d0a9ce8285dc4d659e6787392207e4a7ac2
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Contributing
|
|
26
|
+
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
|
|
27
|
+
|
|
28
|
+
Please make sure to update tests as appropriate.
|
|
29
|
+
|
|
30
|
+
## Who is Learning Economy Foundation?
|
|
31
|
+
|
|
32
|
+
**[Learning Economy Foundation (LEF)](https://www.learningeconomy.io)** is a 501(c)(3) non-profit organization leveraging global standards and web3 protocols to bring quality skills and equal opportunity to every human on earth, and address the persistent inequities that exist around the globe in education and employment. We help you build the future of education and work with:
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
## License
|
|
36
|
+
|
|
37
|
+
MIT © [Learning Economy Foundation](https://github.com/Learning-Economy-Foundation)
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var repl = require('pretty-repl');
|
|
4
|
+
var core = require('@learncard/core');
|
|
5
|
+
var gradient = require('gradient-string');
|
|
6
|
+
var figlet = require('figlet');
|
|
7
|
+
var commander = require('commander');
|
|
8
|
+
var crypto = require('crypto');
|
|
9
|
+
|
|
10
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
+
|
|
12
|
+
var repl__default = /*#__PURE__*/_interopDefaultLegacy(repl);
|
|
13
|
+
var gradient__default = /*#__PURE__*/_interopDefaultLegacy(gradient);
|
|
14
|
+
var figlet__default = /*#__PURE__*/_interopDefaultLegacy(figlet);
|
|
15
|
+
var crypto__default = /*#__PURE__*/_interopDefaultLegacy(crypto);
|
|
16
|
+
|
|
17
|
+
const generateRandomSeed = () => crypto__default["default"].randomBytes(32).toString("hex");
|
|
18
|
+
|
|
19
|
+
var name = "@learncard/cli";
|
|
20
|
+
var version = "1.0.0";
|
|
21
|
+
var description = "Test out learn card!";
|
|
22
|
+
var main = "dist/index.js";
|
|
23
|
+
var bin = "dist/index.js";
|
|
24
|
+
var scripts = {
|
|
25
|
+
start: "rollup -c && node dist/index.js",
|
|
26
|
+
build: "rollup -c"
|
|
27
|
+
};
|
|
28
|
+
var author = "Learning Economy Foundation (www.learningeconomy.io)";
|
|
29
|
+
var license = "MIT";
|
|
30
|
+
var dependencies = {
|
|
31
|
+
"@learncard/core": "workspace:*",
|
|
32
|
+
"@learncard/types": "workspace:*",
|
|
33
|
+
"@rollup/plugin-json": "^4.1.0",
|
|
34
|
+
commander: "^9.3.0",
|
|
35
|
+
figlet: "^1.5.2",
|
|
36
|
+
"gradient-string": "^2.0.1",
|
|
37
|
+
"pretty-repl": "^3.1.1",
|
|
38
|
+
rollup: "^2.71.1",
|
|
39
|
+
"rollup-plugin-esbuild": "^4.9.1"
|
|
40
|
+
};
|
|
41
|
+
var devDependencies = {
|
|
42
|
+
"@types/cors": "^2.8.12",
|
|
43
|
+
"@types/figlet": "^1.5.4",
|
|
44
|
+
"@types/node": "^18.0.0",
|
|
45
|
+
nodemon: "^2.0.16",
|
|
46
|
+
"ts-node": "^10.8.1",
|
|
47
|
+
typescript: "^4.7.4"
|
|
48
|
+
};
|
|
49
|
+
var packageJson = {
|
|
50
|
+
name: name,
|
|
51
|
+
version: version,
|
|
52
|
+
description: description,
|
|
53
|
+
main: main,
|
|
54
|
+
bin: bin,
|
|
55
|
+
scripts: scripts,
|
|
56
|
+
author: author,
|
|
57
|
+
license: license,
|
|
58
|
+
dependencies: dependencies,
|
|
59
|
+
devDependencies: devDependencies
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const g = {
|
|
63
|
+
wallet: gradient__default["default"](["cyan", "green"])("wallet"),
|
|
64
|
+
walletFromKey: gradient__default["default"](["cyan", "green"])("walletFromKey"),
|
|
65
|
+
seed: gradient__default["default"](["cyan", "green"])("seed"),
|
|
66
|
+
generateRandomSeed: gradient__default["default"](["cyan", "green"])("generateRandomSeed")
|
|
67
|
+
};
|
|
68
|
+
commander.program.version(packageJson.version).argument("[seed]").action(async (_seed = generateRandomSeed()) => {
|
|
69
|
+
console.clear();
|
|
70
|
+
const seed = _seed.padStart(64, "0");
|
|
71
|
+
console.log(gradient__default["default"](["cyan", "green"])(figlet__default["default"].textSync("Learn Card", "Big Money-ne")));
|
|
72
|
+
console.log("Welcome to the Learn Card CLI!\n");
|
|
73
|
+
console.log(`Your seed is ${seed}
|
|
74
|
+
`);
|
|
75
|
+
console.log("Creating wallet...");
|
|
76
|
+
globalThis.seed = seed;
|
|
77
|
+
globalThis.generateRandomSeed = generateRandomSeed;
|
|
78
|
+
globalThis.walletFromKey = core.walletFromKey;
|
|
79
|
+
globalThis.wallet = await core.walletFromKey(seed);
|
|
80
|
+
process.stdout.moveCursor(0, -1);
|
|
81
|
+
process.stdout.clearLine(1);
|
|
82
|
+
console.log("Wallet created!\n");
|
|
83
|
+
console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510");
|
|
84
|
+
console.log("\u2502 Variables Available \u2502");
|
|
85
|
+
console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");
|
|
86
|
+
console.log("\u2502 Variable \u2502 Description \u2502");
|
|
87
|
+
console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");
|
|
88
|
+
console.log(`\u2502 ${g.wallet} \u2502 Learn Card Wallet \u2502`);
|
|
89
|
+
console.log(`\u2502 ${g.walletFromKey} \u2502 Wallet Instantiation Function \u2502`);
|
|
90
|
+
console.log(`\u2502 ${g.seed} \u2502 Seed used to generate wallet \u2502`);
|
|
91
|
+
console.log(`\u2502 ${g.generateRandomSeed} \u2502 Generates a random seed \u2502`);
|
|
92
|
+
console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518");
|
|
93
|
+
console.log("");
|
|
94
|
+
console.log("For help/documentation regarding your wallet, please read the documentation at\n");
|
|
95
|
+
console.log("https://app.gitbook.com/o/6uDv1QDlxaaZC7i8EaGb/s/FXvEJ9j3Vf3FW5Nc557n/learn-card-packages/learncard-core/quick-start\n");
|
|
96
|
+
console.log("To get a feel for what's possible, try some of the following commands\n");
|
|
97
|
+
console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510");
|
|
98
|
+
console.log("\u2502 Description \u2502 Command \u2502");
|
|
99
|
+
console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");
|
|
100
|
+
console.log(`\u2502 View your did \u2502 ${g.wallet}.did; \u2502`);
|
|
101
|
+
console.log(`\u2502 Generate an unsigned VC \u2502 ${g.wallet}.getTestVc(); \u2502`);
|
|
102
|
+
console.log(`\u2502 Issue a signed VC \u2502 await ${g.wallet}.issueCredential(uvc); \u2502`);
|
|
103
|
+
console.log(`\u2502 Verify a signed VC \u2502 await ${g.wallet}.verifyCredential(vc); \u2502`);
|
|
104
|
+
console.log(`\u2502 Issue a signed VP \u2502 await ${g.wallet}.issuePresentation(vc); \u2502`);
|
|
105
|
+
console.log(`\u2502 Verify a signed VP \u2502 await ${g.wallet}.verifyPresentation(vp); \u2502`);
|
|
106
|
+
console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518");
|
|
107
|
+
console.log("");
|
|
108
|
+
repl__default["default"].start({
|
|
109
|
+
colorize: (input) => {
|
|
110
|
+
return input.replace("walletFromKey", g.walletFromKey).replace("wallet", g.wallet).replace("seed", g.seed).replace("generateRandomSeed", g.generateRandomSeed);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}).parse(process.argv);
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@learncard/cli",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Test out learn card!",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"bin": "dist/index.js",
|
|
7
|
+
"author": "Learning Economy Foundation (www.learningeconomy.io)",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@learncard/core": "1.1.5",
|
|
11
|
+
"@learncard/types": "2.1.1",
|
|
12
|
+
"@rollup/plugin-json": "^4.1.0",
|
|
13
|
+
"commander": "^9.3.0",
|
|
14
|
+
"figlet": "^1.5.2",
|
|
15
|
+
"gradient-string": "^2.0.1",
|
|
16
|
+
"pretty-repl": "^3.1.1",
|
|
17
|
+
"rollup": "^2.71.1",
|
|
18
|
+
"rollup-plugin-esbuild": "^4.9.1"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/cors": "^2.8.12",
|
|
22
|
+
"@types/figlet": "^1.5.4",
|
|
23
|
+
"@types/node": "^18.0.0",
|
|
24
|
+
"nodemon": "^2.0.16",
|
|
25
|
+
"ts-node": "^10.8.1",
|
|
26
|
+
"typescript": "^4.7.4"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"start": "rollup -c && node dist/index.js",
|
|
30
|
+
"build": "rollup -c"
|
|
31
|
+
}
|
|
32
|
+
}
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import json from '@rollup/plugin-json';
|
|
2
|
+
import esbuild from 'rollup-plugin-esbuild';
|
|
3
|
+
|
|
4
|
+
const packageJson = require('./package.json');
|
|
5
|
+
|
|
6
|
+
export default [
|
|
7
|
+
{
|
|
8
|
+
input: ['src/index.tsx'],
|
|
9
|
+
output: [{ file: packageJson.bin, format: 'cjs' }],
|
|
10
|
+
plugins: [json(), esbuild()],
|
|
11
|
+
},
|
|
12
|
+
];
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import repl from 'pretty-repl';
|
|
2
|
+
|
|
3
|
+
import { walletFromKey } from '@learncard/core';
|
|
4
|
+
import gradient from 'gradient-string';
|
|
5
|
+
import figlet from 'figlet';
|
|
6
|
+
import { program } from 'commander';
|
|
7
|
+
|
|
8
|
+
import { generateRandomSeed } from './random';
|
|
9
|
+
|
|
10
|
+
import packageJson from '../package.json';
|
|
11
|
+
|
|
12
|
+
const g = {
|
|
13
|
+
wallet: gradient(['cyan', 'green'])('wallet'),
|
|
14
|
+
walletFromKey: gradient(['cyan', 'green'])('walletFromKey'),
|
|
15
|
+
seed: gradient(['cyan', 'green'])('seed'),
|
|
16
|
+
generateRandomSeed: gradient(['cyan', 'green'])('generateRandomSeed'),
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
program
|
|
20
|
+
.version(packageJson.version)
|
|
21
|
+
.argument('[seed]')
|
|
22
|
+
.action(async (_seed: string = generateRandomSeed()) => {
|
|
23
|
+
console.clear();
|
|
24
|
+
|
|
25
|
+
const seed = _seed.padStart(64, '0');
|
|
26
|
+
|
|
27
|
+
console.log(gradient(['cyan', 'green'])(figlet.textSync('Learn Card', 'Big Money-ne')));
|
|
28
|
+
console.log('Welcome to the Learn Card CLI!\n');
|
|
29
|
+
|
|
30
|
+
console.log(`Your seed is ${seed}\n`);
|
|
31
|
+
|
|
32
|
+
console.log('Creating wallet...');
|
|
33
|
+
|
|
34
|
+
globalThis.seed = seed;
|
|
35
|
+
globalThis.generateRandomSeed = generateRandomSeed;
|
|
36
|
+
globalThis.walletFromKey = walletFromKey;
|
|
37
|
+
globalThis.wallet = await walletFromKey(seed);
|
|
38
|
+
|
|
39
|
+
// delete 'Creating wallet...' message
|
|
40
|
+
process.stdout.moveCursor(0, -1);
|
|
41
|
+
process.stdout.clearLine(1);
|
|
42
|
+
|
|
43
|
+
console.log('Wallet created!\n');
|
|
44
|
+
|
|
45
|
+
console.log('┌────────────────────────────────────────────────────┐');
|
|
46
|
+
console.log('│ Variables Available │');
|
|
47
|
+
console.log('├────────────────────┬───────────────────────────────┤');
|
|
48
|
+
console.log('│ Variable │ Description │');
|
|
49
|
+
console.log('├────────────────────┼───────────────────────────────┤');
|
|
50
|
+
console.log(`│ ${g.wallet} │ Learn Card Wallet │`);
|
|
51
|
+
console.log(`│ ${g.walletFromKey} │ Wallet Instantiation Function │`);
|
|
52
|
+
console.log(`│ ${g.seed} │ Seed used to generate wallet │`);
|
|
53
|
+
console.log(`│ ${g.generateRandomSeed} │ Generates a random seed │`);
|
|
54
|
+
console.log('└────────────────────┴───────────────────────────────┘');
|
|
55
|
+
|
|
56
|
+
console.log('');
|
|
57
|
+
|
|
58
|
+
console.log(
|
|
59
|
+
'For help/documentation regarding your wallet, please read the documentation at\n'
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
console.log(
|
|
63
|
+
'https://app.gitbook.com/o/6uDv1QDlxaaZC7i8EaGb/s/FXvEJ9j3Vf3FW5Nc557n/learn-card-packages/learncard-core/quick-start\n'
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
console.log("To get a feel for what's possible, try some of the following commands\n");
|
|
67
|
+
|
|
68
|
+
console.log('┌─────────────────────────┬──────────────────────────────────────┐');
|
|
69
|
+
console.log('│ Description │ Command │');
|
|
70
|
+
console.log('├─────────────────────────┼──────────────────────────────────────┤');
|
|
71
|
+
console.log(`│ View your did │ ${g.wallet}.did; │`);
|
|
72
|
+
console.log(`│ Generate an unsigned VC │ ${g.wallet}.getTestVc(); │`);
|
|
73
|
+
console.log(`│ Issue a signed VC │ await ${g.wallet}.issueCredential(uvc); │`);
|
|
74
|
+
console.log(`│ Verify a signed VC │ await ${g.wallet}.verifyCredential(vc); │`);
|
|
75
|
+
console.log(`│ Issue a signed VP │ await ${g.wallet}.issuePresentation(vc); │`);
|
|
76
|
+
console.log(`│ Verify a signed VP │ await ${g.wallet}.verifyPresentation(vp); │`);
|
|
77
|
+
console.log('└─────────────────────────┴──────────────────────────────────────┘');
|
|
78
|
+
|
|
79
|
+
console.log('');
|
|
80
|
+
|
|
81
|
+
repl.start({
|
|
82
|
+
colorize: (input: string) => {
|
|
83
|
+
return input
|
|
84
|
+
.replace('walletFromKey', g.walletFromKey)
|
|
85
|
+
.replace('wallet', g.wallet)
|
|
86
|
+
.replace('seed', g.seed)
|
|
87
|
+
.replace('generateRandomSeed', g.generateRandomSeed);
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
})
|
|
91
|
+
.parse(process.argv);
|
package/src/random.ts
ADDED
package/tsconfig.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"lib": ["es2017"],
|
|
4
|
+
"module": "esnext",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"resolveJsonModule": true,
|
|
7
|
+
"removeComments": true,
|
|
8
|
+
"preserveConstEnums": true,
|
|
9
|
+
"strict": true,
|
|
10
|
+
"alwaysStrict": true,
|
|
11
|
+
"strictNullChecks": true,
|
|
12
|
+
"noUncheckedIndexedAccess": true,
|
|
13
|
+
"jsx": "react",
|
|
14
|
+
|
|
15
|
+
"noImplicitAny": true,
|
|
16
|
+
"noImplicitReturns": true,
|
|
17
|
+
"noImplicitThis": true,
|
|
18
|
+
"noUnusedLocals": true,
|
|
19
|
+
"noUnusedParameters": true,
|
|
20
|
+
"allowUnreachableCode": false,
|
|
21
|
+
"noFallthroughCasesInSwitch": true,
|
|
22
|
+
|
|
23
|
+
"target": "es2017",
|
|
24
|
+
"outDir": "dist",
|
|
25
|
+
"declaration": true,
|
|
26
|
+
"sourceMap": true,
|
|
27
|
+
"baseUrl": ".",
|
|
28
|
+
|
|
29
|
+
"esModuleInterop": true,
|
|
30
|
+
"allowSyntheticDefaultImports": true,
|
|
31
|
+
"allowJs": false,
|
|
32
|
+
"skipLibCheck": true,
|
|
33
|
+
"forceConsistentCasingInFileNames": true
|
|
34
|
+
},
|
|
35
|
+
"exclude": ["./dist/**/*", "./node_modules/**/*"]
|
|
36
|
+
}
|