@veramo/cli 4.3.1-next.9 → 4.3.1-unstable.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/bin/veramo.js +1 -1
- package/build/cli.d.ts +13 -13
- package/build/cli.d.ts.map +1 -1
- package/build/cli.js +23 -19
- package/build/cli.js.map +1 -1
- package/build/config.d.ts +1 -1
- package/build/config.d.ts.map +1 -1
- package/build/config.js +27 -17
- package/build/config.js.map +1 -1
- package/build/credential.js +69 -32
- package/build/credential.js.map +1 -1
- package/build/dev.js +62 -40
- package/build/dev.js.map +1 -1
- package/build/did.js +84 -70
- package/build/did.js.map +1 -1
- package/build/discover.js +20 -9
- package/build/discover.js.map +1 -1
- package/build/execute.js +30 -16
- package/build/execute.js.map +1 -1
- package/build/explore/credentials.d.ts +1 -1
- package/build/explore/credentials.d.ts.map +1 -1
- package/build/explore/credentials.js +37 -19
- package/build/explore/credentials.js.map +1 -1
- package/build/explore/index.js +19 -9
- package/build/explore/index.js.map +1 -1
- package/build/explore/main.d.ts +1 -1
- package/build/explore/main.d.ts.map +1 -1
- package/build/explore/main.js +42 -24
- package/build/explore/main.js.map +1 -1
- package/build/explore/managed-identifiers.d.ts +1 -1
- package/build/explore/managed-identifiers.d.ts.map +1 -1
- package/build/explore/managed-identifiers.js +32 -14
- package/build/explore/managed-identifiers.js.map +1 -1
- package/build/explore/messages.d.ts +1 -1
- package/build/explore/messages.d.ts.map +1 -1
- package/build/explore/messages.js +31 -13
- package/build/explore/messages.js.map +1 -1
- package/build/explore/presentations.d.ts +1 -1
- package/build/explore/presentations.d.ts.map +1 -1
- package/build/explore/presentations.js +37 -19
- package/build/explore/presentations.js.map +1 -1
- package/build/explore/styles.js +4 -1
- package/build/explore/styles.js.map +1 -1
- package/build/explore/utils.js +17 -8
- package/build/explore/utils.js.map +1 -1
- package/build/lib/agentCreator.js +7 -3
- package/build/lib/agentCreator.js.map +1 -1
- package/build/lib/objectCreator.d.ts +1 -1
- package/build/lib/objectCreator.d.ts.map +1 -1
- package/build/lib/objectCreator.js +28 -21
- package/build/lib/objectCreator.js.map +1 -1
- package/build/message.js +19 -8
- package/build/message.js.map +1 -1
- package/build/presentation.js +71 -34
- package/build/presentation.js.map +1 -1
- package/build/sdr.js +68 -50
- package/build/sdr.js.map +1 -1
- package/build/server.js +25 -11
- package/build/server.js.map +1 -1
- package/build/setup.d.ts +1 -0
- package/build/setup.d.ts.map +1 -1
- package/build/setup.js +17 -8
- package/build/setup.js.map +1 -1
- package/build/util.js +32 -17
- package/build/util.js.map +1 -1
- package/build/version.d.ts.map +1 -1
- package/build/version.js +5 -6
- package/build/version.js.map +1 -1
- package/default/default.yml +1 -1
- package/package.json +31 -38
- package/src/cli.ts +14 -15
- package/src/config.ts +4 -5
- package/src/credential.ts +3 -3
- package/src/dev.ts +3 -8
- package/src/did.ts +1 -1
- package/src/discover.ts +1 -1
- package/src/execute.ts +4 -4
- package/src/explore/credentials.ts +3 -3
- package/src/explore/index.ts +3 -4
- package/src/explore/main.ts +6 -6
- package/src/explore/managed-identifiers.ts +3 -3
- package/src/explore/messages.ts +3 -3
- package/src/explore/presentations.ts +3 -3
- package/src/lib/agentCreator.ts +1 -1
- package/src/lib/objectCreator.ts +14 -14
- package/src/message.ts +2 -2
- package/src/presentation.ts +2 -2
- package/src/sdr.ts +3 -3
- package/src/server.ts +3 -3
- package/src/setup.ts +3 -2
- package/src/version.ts +2 -6
package/bin/veramo.js
CHANGED
package/build/cli.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import './did
|
|
2
|
-
import './credential
|
|
3
|
-
import './presentation
|
|
4
|
-
import './explore
|
|
5
|
-
import './sdr
|
|
6
|
-
import './message
|
|
7
|
-
import './discover
|
|
8
|
-
import './version
|
|
9
|
-
import './execute
|
|
10
|
-
import './server
|
|
11
|
-
import './setup
|
|
12
|
-
import './config
|
|
13
|
-
import './dev
|
|
1
|
+
import './did';
|
|
2
|
+
import './credential';
|
|
3
|
+
import './presentation';
|
|
4
|
+
import './explore';
|
|
5
|
+
import './sdr';
|
|
6
|
+
import './message';
|
|
7
|
+
import './discover';
|
|
8
|
+
import './version';
|
|
9
|
+
import './execute';
|
|
10
|
+
import './server';
|
|
11
|
+
import './setup';
|
|
12
|
+
import './config';
|
|
13
|
+
import './dev';
|
|
14
14
|
//# sourceMappingURL=cli.d.ts.map
|
package/build/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAKA,OAAO,OAAO,CAAA;AACd,OAAO,cAAc,CAAA;AACrB,OAAO,gBAAgB,CAAA;AACvB,OAAO,WAAW,CAAA;AAClB,OAAO,OAAO,CAAA;AACd,OAAO,WAAW,CAAA;AAClB,OAAO,YAAY,CAAA;AACnB,OAAO,WAAW,CAAA;AAClB,OAAO,WAAW,CAAA;AAClB,OAAO,UAAU,CAAA;AACjB,OAAO,SAAS,CAAA;AAChB,OAAO,UAAU,CAAA;AACjB,OAAO,OAAO,CAAA"}
|
package/build/cli.js
CHANGED
|
@@ -1,24 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const commander_1 = require("commander");
|
|
7
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
8
|
+
inquirer_1.default.registerPrompt('autocomplete', require('inquirer-autocomplete-prompt'));
|
|
9
|
+
require("./did");
|
|
10
|
+
require("./credential");
|
|
11
|
+
require("./presentation");
|
|
12
|
+
require("./explore");
|
|
13
|
+
require("./sdr");
|
|
14
|
+
require("./message");
|
|
15
|
+
require("./discover");
|
|
16
|
+
require("./version");
|
|
17
|
+
require("./execute");
|
|
18
|
+
require("./server");
|
|
19
|
+
require("./setup");
|
|
20
|
+
require("./config");
|
|
21
|
+
require("./dev");
|
|
18
22
|
if (!process.argv.slice(2).length) {
|
|
19
|
-
program.outputHelp();
|
|
23
|
+
commander_1.program.outputHelp();
|
|
20
24
|
}
|
|
21
25
|
else {
|
|
22
|
-
program.parse(process.argv);
|
|
26
|
+
commander_1.program.parse(process.argv);
|
|
23
27
|
}
|
|
24
28
|
//# sourceMappingURL=cli.js.map
|
package/build/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;AAAA,yCAAmC;AACnC,wDAA+B;AAE/B,kBAAQ,CAAC,cAAc,CAAC,cAAc,EAAE,OAAO,CAAC,8BAA8B,CAAC,CAAC,CAAA;AAEhF,iBAAc;AACd,wBAAqB;AACrB,0BAAuB;AACvB,qBAAkB;AAClB,iBAAc;AACd,qBAAkB;AAClB,sBAAmB;AACnB,qBAAkB;AAClB,qBAAkB;AAClB,oBAAiB;AACjB,mBAAgB;AAChB,oBAAiB;AACjB,iBAAc;AAEd,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE;IACjC,mBAAO,CAAC,UAAU,EAAE,CAAA;CACrB;KAAM;IACL,mBAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;CAC5B"}
|
package/build/config.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import 'cross-fetch/polyfill';
|
|
2
2
|
//# sourceMappingURL=config.d.ts.map
|
package/build/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAA"}
|
package/build/config.js
CHANGED
|
@@ -1,18 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
require("cross-fetch/polyfill");
|
|
13
|
+
const commander_1 = require("commander");
|
|
14
|
+
const kms_local_1 = require("@veramo/kms-local");
|
|
15
|
+
const setup_1 = require("./setup");
|
|
16
|
+
const fs = require('fs');
|
|
17
|
+
const { dirname } = require('path');
|
|
18
|
+
commander_1.program.option('--config <path>', 'Configuration file', './agent.yml');
|
|
19
|
+
const config = commander_1.program.command('config').description('Agent configuration');
|
|
10
20
|
config
|
|
11
21
|
.command('create', { isDefault: true })
|
|
12
22
|
.description('Create default agent config')
|
|
13
23
|
.option('--filename <string>', 'Config file name', './agent.yml')
|
|
14
24
|
.option('--template <string>', 'Use template (default,client)', 'default')
|
|
15
|
-
.action(
|
|
25
|
+
.action((options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
26
|
const { filename, template } = options;
|
|
17
27
|
const templateFile = __dirname + '/../default/' + template + '.yml';
|
|
18
28
|
if (!fs.existsSync(templateFile)) {
|
|
@@ -30,16 +40,16 @@ config
|
|
|
30
40
|
else {
|
|
31
41
|
console.log('File already exists: ' + filename);
|
|
32
42
|
}
|
|
33
|
-
});
|
|
43
|
+
}));
|
|
34
44
|
config
|
|
35
45
|
.command('create-secret-key')
|
|
36
46
|
.alias('gen-key')
|
|
37
47
|
.alias('key-gen')
|
|
38
48
|
.description('generate secret key')
|
|
39
49
|
.option('-q, --quiet', 'Only print the raw key, no instructions', false)
|
|
40
|
-
.action(
|
|
50
|
+
.action((options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
51
|
try {
|
|
42
|
-
const dbEncryptionKey =
|
|
52
|
+
const dbEncryptionKey = yield kms_local_1.SecretBox.createSecretKey();
|
|
43
53
|
if (options.quiet === true) {
|
|
44
54
|
console.log(dbEncryptionKey);
|
|
45
55
|
}
|
|
@@ -57,15 +67,15 @@ config
|
|
|
57
67
|
catch (e) {
|
|
58
68
|
console.error(e.message);
|
|
59
69
|
}
|
|
60
|
-
});
|
|
70
|
+
}));
|
|
61
71
|
config
|
|
62
72
|
.command('check')
|
|
63
73
|
.alias('verify')
|
|
64
74
|
.description('Verify an agent config file syntax')
|
|
65
75
|
.option('-f, --filename <string>', 'Config file name', './agent.yml')
|
|
66
76
|
.option('-m, --method <string>', 'Check that a specific method is exposed by the agent.', 'execute')
|
|
67
|
-
.action(
|
|
68
|
-
const agent = getAgent(options.filename);
|
|
77
|
+
.action((options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
78
|
+
const agent = (0, setup_1.getAgent)(options.filename);
|
|
69
79
|
if (!agent) {
|
|
70
80
|
console.error('unknown error while creating the agent from your config. Consider running `veramo config create` to generate a new configuration file, or to manually compare differences.');
|
|
71
81
|
}
|
|
@@ -77,5 +87,5 @@ config
|
|
|
77
87
|
console.log(`Your Veramo configuration seems fine. An agent can be created and the 'agent.${options.method}()' method can be called on it.`);
|
|
78
88
|
}
|
|
79
89
|
}
|
|
80
|
-
});
|
|
90
|
+
}));
|
|
81
91
|
//# sourceMappingURL=config.js.map
|
package/build/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,gCAA6B;AAC7B,yCAAmC;AACnC,iDAA6C;AAC7C,mCAAkC;AAElC,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;AACxB,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAEnC,mBAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,EAAE,aAAa,CAAC,CAAA;AAEtE,MAAM,MAAM,GAAG,mBAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAA;AAE3E,MAAM;KACH,OAAO,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;KACtC,WAAW,CAAC,6BAA6B,CAAC;KAC1C,MAAM,CAAC,qBAAqB,EAAE,kBAAkB,EAAE,aAAa,CAAC;KAChE,MAAM,CAAC,qBAAqB,EAAE,+BAA+B,EAAE,SAAS,CAAC;KAEzE,MAAM,CAAC,CAAO,OAAO,EAAE,EAAE;IACxB,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,OAA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,eAAe;;;;SAIhB,CAAC,CAAA;SACH;KACF;IAAC,OAAO,CAAM,EAAE;QACf,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;KACzB;AACH,CAAC,CAAA,CAAC,CAAA;AAEJ,MAAM;KACH,OAAO,CAAC,OAAO,CAAC;KAChB,KAAK,CAAC,QAAQ,CAAC;KACf,WAAW,CAAC,oCAAoC,CAAC;KACjD,MAAM,CAAC,yBAAyB,EAAE,kBAAkB,EAAE,aAAa,CAAC;KACpE,MAAM,CAAC,uBAAuB,EAAE,uDAAuD,EAAE,SAAS,CAAC;KACnG,MAAM,CAAC,CAAO,OAAO,EAAE,EAAE;IACxB,MAAM,KAAK,GAAG,IAAA,gBAAQ,EAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;IACxC,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,CAAC,KAAK,CACX,4KAA4K,CAC7K,CAAA;KACF;SAAM;QACL,IAAI,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,UAAU,EAAE;YAC/C,OAAO,CAAC,KAAK,CACX,0DAA0D,OAAO,CAAC,MAAM,6FAA6F,CACtK,CAAA;SACF;aAAM;YACL,OAAO,CAAC,GAAG,CACT,gFAAgF,OAAO,CAAC,MAAM,iCAAiC,CAChI,CAAA;SACF;KACF;AACH,CAAC,CAAA,CAAC,CAAA"}
|
package/build/credential.js
CHANGED
|
@@ -1,28 +1,65 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
const setup_1 = require("./setup");
|
|
39
|
+
const commander_1 = require("commander");
|
|
40
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
41
|
+
const qrcode_terminal_1 = __importDefault(require("qrcode-terminal"));
|
|
42
|
+
const fs = __importStar(require("fs"));
|
|
43
|
+
const json5 = __importStar(require("json5"));
|
|
44
|
+
const util_1 = require("./util");
|
|
45
|
+
const fuzzy = require('fuzzy');
|
|
46
|
+
const credential = commander_1.program.command('credential').description('W3C Verifiable Credential');
|
|
10
47
|
credential
|
|
11
48
|
.command('create', { isDefault: true })
|
|
12
49
|
.description('Create W3C Verifiable Credential')
|
|
13
50
|
.option('-s, --send', 'Send')
|
|
14
51
|
.option('-j, --json', 'Output in JSON')
|
|
15
52
|
.option('-q, --qrcode', 'Show qrcode')
|
|
16
|
-
.action(
|
|
17
|
-
const agent = getAgent(program.opts().config);
|
|
18
|
-
const identifiers =
|
|
19
|
-
const knownDids =
|
|
53
|
+
.action((cmd) => __awaiter(void 0, void 0, void 0, function* () {
|
|
54
|
+
const agent = (0, setup_1.getAgent)(commander_1.program.opts().config);
|
|
55
|
+
const identifiers = yield agent.didManagerFind();
|
|
56
|
+
const knownDids = yield agent.dataStoreORMGetIdentifiers();
|
|
20
57
|
const subjects = [...knownDids.map((id) => id.did)];
|
|
21
58
|
if (identifiers.length === 0) {
|
|
22
59
|
console.error('No dids');
|
|
23
60
|
process.exit();
|
|
24
61
|
}
|
|
25
|
-
const answers =
|
|
62
|
+
const answers = yield inquirer_1.default.prompt([
|
|
26
63
|
{
|
|
27
64
|
type: 'list',
|
|
28
65
|
name: 'proofFormat',
|
|
@@ -42,12 +79,12 @@ credential
|
|
|
42
79
|
type: 'autocomplete',
|
|
43
80
|
name: 'sub',
|
|
44
81
|
pageSize: 15,
|
|
45
|
-
source:
|
|
82
|
+
source: (answers, input) => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
83
|
const res = fuzzy
|
|
47
84
|
.filter(input, subjects)
|
|
48
85
|
.map((el) => (typeof el === 'string' ? el : el.original));
|
|
49
86
|
return res;
|
|
50
|
-
},
|
|
87
|
+
}),
|
|
51
88
|
message: 'Subject DID',
|
|
52
89
|
},
|
|
53
90
|
{
|
|
@@ -90,7 +127,7 @@ credential
|
|
|
90
127
|
credentialSubject,
|
|
91
128
|
};
|
|
92
129
|
if (answers.addStatus) {
|
|
93
|
-
const statusAnswers =
|
|
130
|
+
const statusAnswers = yield inquirer_1.default.prompt([
|
|
94
131
|
{
|
|
95
132
|
type: 'input',
|
|
96
133
|
name: 'type',
|
|
@@ -110,7 +147,7 @@ credential
|
|
|
110
147
|
id: statusAnswers.id,
|
|
111
148
|
};
|
|
112
149
|
}
|
|
113
|
-
const verifiableCredential =
|
|
150
|
+
const verifiableCredential = yield agent.createVerifiableCredential({
|
|
114
151
|
save: true,
|
|
115
152
|
credential,
|
|
116
153
|
proofFormat: answers.proofFormat,
|
|
@@ -127,7 +164,7 @@ credential
|
|
|
127
164
|
type = 'w3c.vc';
|
|
128
165
|
}
|
|
129
166
|
try {
|
|
130
|
-
const message =
|
|
167
|
+
const message = yield agent.sendMessageDIDCommAlpha1({
|
|
131
168
|
save: true,
|
|
132
169
|
data: {
|
|
133
170
|
from: answers.iss,
|
|
@@ -143,7 +180,7 @@ credential
|
|
|
143
180
|
}
|
|
144
181
|
}
|
|
145
182
|
if (cmd.qrcode) {
|
|
146
|
-
|
|
183
|
+
qrcode_terminal_1.default.generate(verifiableCredential.proof.jwt);
|
|
147
184
|
}
|
|
148
185
|
else {
|
|
149
186
|
if (cmd.json) {
|
|
@@ -153,23 +190,23 @@ credential
|
|
|
153
190
|
console.dir(verifiableCredential, { depth: 10 });
|
|
154
191
|
}
|
|
155
192
|
}
|
|
156
|
-
});
|
|
193
|
+
}));
|
|
157
194
|
credential
|
|
158
195
|
.command('verify')
|
|
159
196
|
.description('Verify a W3C Verifiable Credential provided as raw string, file or stdin')
|
|
160
197
|
.option('-f, --filename <string>', 'Optional. Read the credential from a file instead of stdin')
|
|
161
198
|
.option('-r, --raw <string>', 'Optional. Specify the credential as a parameter instead of file or stdin')
|
|
162
|
-
.action(
|
|
163
|
-
const agent = getAgent(program.opts().config);
|
|
199
|
+
.action((options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
200
|
+
const agent = (0, setup_1.getAgent)(commander_1.program.opts().config);
|
|
164
201
|
let raw = '';
|
|
165
202
|
if (options.raw) {
|
|
166
203
|
raw = options.raw;
|
|
167
204
|
}
|
|
168
205
|
else if (options.filename) {
|
|
169
|
-
raw =
|
|
206
|
+
raw = yield fs.promises.readFile(options.filename, 'utf-8');
|
|
170
207
|
}
|
|
171
208
|
else {
|
|
172
|
-
raw =
|
|
209
|
+
raw = yield (0, util_1.readStdin)();
|
|
173
210
|
}
|
|
174
211
|
let credentialAsJSON;
|
|
175
212
|
try {
|
|
@@ -184,7 +221,7 @@ credential
|
|
|
184
221
|
};
|
|
185
222
|
}
|
|
186
223
|
try {
|
|
187
|
-
const result =
|
|
224
|
+
const result = yield agent.verifyCredential({ credential: credentialAsJSON });
|
|
188
225
|
if (result.verified === true) {
|
|
189
226
|
console.log('Credential was verified successfully.');
|
|
190
227
|
}
|
|
@@ -195,13 +232,13 @@ credential
|
|
|
195
232
|
catch (e) {
|
|
196
233
|
console.error(e.message);
|
|
197
234
|
}
|
|
198
|
-
});
|
|
235
|
+
}));
|
|
199
236
|
credential
|
|
200
237
|
.command('output')
|
|
201
238
|
.description('Print W3C Verifiable Credential to stdout')
|
|
202
|
-
.action(
|
|
203
|
-
const agent = getAgent(program.opts().config);
|
|
204
|
-
const credentials =
|
|
239
|
+
.action((cmd) => __awaiter(void 0, void 0, void 0, function* () {
|
|
240
|
+
const agent = (0, setup_1.getAgent)(commander_1.program.opts().config);
|
|
241
|
+
const credentials = yield agent.dataStoreORMGetVerifiableCredentials();
|
|
205
242
|
if (credentials.length > 0) {
|
|
206
243
|
const list = [];
|
|
207
244
|
for (const cred of credentials) {
|
|
@@ -212,7 +249,7 @@ credential
|
|
|
212
249
|
value: cred,
|
|
213
250
|
});
|
|
214
251
|
}
|
|
215
|
-
const answers =
|
|
252
|
+
const answers = yield inquirer_1.default.prompt([
|
|
216
253
|
{
|
|
217
254
|
type: 'list',
|
|
218
255
|
name: 'credential',
|
|
@@ -225,5 +262,5 @@ credential
|
|
|
225
262
|
else {
|
|
226
263
|
console.log('No credentials found.');
|
|
227
264
|
}
|
|
228
|
-
});
|
|
265
|
+
}));
|
|
229
266
|
//# sourceMappingURL=credential.js.map
|
package/build/credential.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credential.js","sourceRoot":"","sources":["../src/credential.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"credential.js","sourceRoot":"","sources":["../src/credential.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAkC;AAClC,yCAAmC;AACnC,wDAA+B;AAC/B,sEAAoC;AACpC,uCAAwB;AACxB,6CAA8B;AAC9B,iCAAkC;AAGlC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;AAE9B,MAAM,UAAU,GAAG,mBAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,WAAW,CAAC,2BAA2B,CAAC,CAAA;AAEzF,UAAU;KACP,OAAO,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;KACtC,WAAW,CAAC,kCAAkC,CAAC;KAC/C,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC;KAC5B,MAAM,CAAC,YAAY,EAAE,gBAAgB,CAAC;KACtC,MAAM,CAAC,cAAc,EAAE,aAAa,CAAC;KACrC,MAAM,CAAC,CAAO,GAAG,EAAE,EAAE;IACpB,MAAM,KAAK,GAAG,IAAA,gBAAQ,EAAC,mBAAO,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAA;IAC7C,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,cAAc,EAAE,CAAA;IAEhD,MAAM,SAAS,GAAG,MAAM,KAAK,CAAC,0BAA0B,EAAE,CAAA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E,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAA;KAC/C;SAAM;QACL,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAA;KACrC;AACH,CAAC,CAAA,CAAC,CAAA"}
|
package/build/dev.js
CHANGED
|
@@ -1,11 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
const api_extractor_1 = require("@microsoft/api-extractor");
|
|
36
|
+
const api_extractor_model_1 = require("@microsoft/api-extractor-model");
|
|
37
|
+
const commander_1 = require("commander");
|
|
38
|
+
const fs_1 = require("fs");
|
|
39
|
+
const path_1 = require("path");
|
|
40
|
+
const TJS = __importStar(require("ts-json-schema-generator"));
|
|
41
|
+
const fs = require('fs');
|
|
9
42
|
const genericTypes = ['boolean', 'string', 'number', 'any', 'Array<string>'];
|
|
10
43
|
function createSchema(generator, symbol) {
|
|
11
44
|
if (genericTypes.includes(symbol)) {
|
|
@@ -52,16 +85,17 @@ function getReference(response) {
|
|
|
52
85
|
return { $ref: '#/components/schemas/' + response };
|
|
53
86
|
}
|
|
54
87
|
}
|
|
55
|
-
const dev = program.command('dev').description('Plugin developer tools');
|
|
88
|
+
const dev = commander_1.program.command('dev').description('Plugin developer tools');
|
|
56
89
|
dev
|
|
57
90
|
.command('generate-plugin-schema')
|
|
58
91
|
.description('generate plugin schema')
|
|
59
92
|
.option('-c, --extractorConfig <string>', 'API Extractor config file', './api-extractor.json')
|
|
60
93
|
.option('-p, --packageConfig <string>', 'package.json file containing a Veramo plugin interface config', './package.json')
|
|
61
|
-
.action(
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
const
|
|
94
|
+
.action((options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
95
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
96
|
+
const apiExtractorJsonPath = (0, path_1.resolve)(options.extractorConfig);
|
|
97
|
+
const extractorConfig = api_extractor_1.ExtractorConfig.loadFileAndPrepare(apiExtractorJsonPath);
|
|
98
|
+
const extractorResult = api_extractor_1.Extractor.invoke(extractorConfig, {
|
|
65
99
|
localBuild: true,
|
|
66
100
|
showVerboseMessages: true,
|
|
67
101
|
});
|
|
@@ -70,9 +104,9 @@ dev
|
|
|
70
104
|
` and ${extractorResult.warningCount} warnings`);
|
|
71
105
|
process.exitCode = 1;
|
|
72
106
|
}
|
|
73
|
-
const packageConfig =
|
|
107
|
+
const packageConfig = require((0, path_1.resolve)(options.packageConfig));
|
|
74
108
|
const interfaces = {};
|
|
75
|
-
for (const pluginInterfaceName in packageConfig
|
|
109
|
+
for (const pluginInterfaceName in (_a = packageConfig === null || packageConfig === void 0 ? void 0 : packageConfig.veramo) === null || _a === void 0 ? void 0 : _a.pluginInterfaces) {
|
|
76
110
|
const entryFile = packageConfig.veramo.pluginInterfaces[pluginInterfaceName];
|
|
77
111
|
const api = {
|
|
78
112
|
components: {
|
|
@@ -81,12 +115,11 @@ dev
|
|
|
81
115
|
},
|
|
82
116
|
};
|
|
83
117
|
const generator = TJS.createGenerator({
|
|
84
|
-
path: resolve(entryFile),
|
|
118
|
+
path: (0, path_1.resolve)(entryFile),
|
|
85
119
|
encodeRefs: false,
|
|
86
120
|
additionalProperties: true,
|
|
87
|
-
skipTypeCheck: true
|
|
88
121
|
});
|
|
89
|
-
const apiModel = new ApiModel();
|
|
122
|
+
const apiModel = new api_extractor_model_1.ApiModel();
|
|
90
123
|
const apiPackage = apiModel.loadPackage(extractorConfig.apiJsonFilePath);
|
|
91
124
|
const entry = apiPackage.entryPoints[0];
|
|
92
125
|
const pluginInterface = entry.findMembersByName(pluginInterfaceName)[0];
|
|
@@ -95,30 +128,19 @@ dev
|
|
|
95
128
|
method.pluginInterfaceName = pluginInterfaceName;
|
|
96
129
|
method.operationId = member.displayName;
|
|
97
130
|
// console.log(member)
|
|
98
|
-
method.parameters = member.parameters[0]
|
|
131
|
+
method.parameters = (_c = (_b = member.parameters[0]) === null || _b === void 0 ? void 0 : _b.parameterTypeExcerpt) === null || _c === void 0 ? void 0 : _c.text;
|
|
99
132
|
method.response = member.returnTypeExcerpt.text
|
|
100
133
|
.replace('Promise<', '')
|
|
101
134
|
.replace('>', '');
|
|
102
135
|
const methodSignature = member;
|
|
103
|
-
method.description = methodSignature.tsdocComment
|
|
104
|
-
?.getChildNodes()[0]
|
|
105
|
-
//@ts-ignore
|
|
106
|
-
?.getChildNodes()[0]?.text;
|
|
136
|
+
method.description = (_g = (_f = (_e = (_d = methodSignature.tsdocComment) === null || _d === void 0 ? void 0 : _d.summarySection) === null || _e === void 0 ? void 0 : _e.getChildNodes()[0]) === null || _f === void 0 ? void 0 : _f.getChildNodes()[0]) === null || _g === void 0 ? void 0 : _g.text;
|
|
107
137
|
method.description = method.description || '';
|
|
108
138
|
if (method.parameters) {
|
|
109
139
|
//@ts-ignore
|
|
110
|
-
api.components.schemas = {
|
|
111
|
-
//@ts-ignore
|
|
112
|
-
...api.components.schemas,
|
|
113
|
-
...createSchema(generator, method.parameters).components.schemas,
|
|
114
|
-
};
|
|
140
|
+
api.components.schemas = Object.assign(Object.assign({}, api.components.schemas), createSchema(generator, method.parameters).components.schemas);
|
|
115
141
|
}
|
|
116
142
|
//@ts-ignore
|
|
117
|
-
api.components.schemas = {
|
|
118
|
-
//@ts-ignore
|
|
119
|
-
...api.components.schemas,
|
|
120
|
-
...createSchema(generator, method.response).components.schemas,
|
|
121
|
-
};
|
|
143
|
+
api.components.schemas = Object.assign(Object.assign({}, api.components.schemas), createSchema(generator, method.response).components.schemas);
|
|
122
144
|
//@ts-ignore
|
|
123
145
|
api.components.methods[method.operationId] = {
|
|
124
146
|
description: method.description,
|
|
@@ -128,16 +150,16 @@ dev
|
|
|
128
150
|
}
|
|
129
151
|
interfaces[pluginInterfaceName] = api;
|
|
130
152
|
}
|
|
131
|
-
writeFileSync(resolve('./
|
|
132
|
-
});
|
|
153
|
+
(0, fs_1.writeFileSync)((0, path_1.resolve)('./plugin.schema.json'), JSON.stringify(interfaces, null, 2));
|
|
154
|
+
}));
|
|
133
155
|
dev
|
|
134
156
|
.command('extract-api')
|
|
135
157
|
.description('Extract API')
|
|
136
158
|
.option('-c, --extractorConfig <string>', 'API Extractor config file', './api-extractor.json')
|
|
137
|
-
.action(
|
|
138
|
-
const apiExtractorJsonPath = resolve(options.extractorConfig);
|
|
139
|
-
const extractorConfig = ExtractorConfig.loadFileAndPrepare(apiExtractorJsonPath);
|
|
140
|
-
const extractorResult = Extractor.invoke(extractorConfig, {
|
|
159
|
+
.action((options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
160
|
+
const apiExtractorJsonPath = (0, path_1.resolve)(options.extractorConfig);
|
|
161
|
+
const extractorConfig = api_extractor_1.ExtractorConfig.loadFileAndPrepare(apiExtractorJsonPath);
|
|
162
|
+
const extractorResult = api_extractor_1.Extractor.invoke(extractorConfig, {
|
|
141
163
|
localBuild: true,
|
|
142
164
|
showVerboseMessages: true,
|
|
143
165
|
});
|
|
@@ -146,5 +168,5 @@ dev
|
|
|
146
168
|
` and ${extractorResult.warningCount} warnings`);
|
|
147
169
|
process.exitCode = 1;
|
|
148
170
|
}
|
|
149
|
-
});
|
|
171
|
+
}));
|
|
150
172
|
//# sourceMappingURL=dev.js.map
|