@veramo/cli 4.0.1-next.8 → 4.0.1-unstable.4
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 +19 -23
- 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 +17 -27
- package/build/config.js.map +1 -1
- package/build/credential.js +34 -70
- package/build/credential.js.map +1 -1
- package/build/dev.js +40 -62
- package/build/dev.js.map +1 -1
- package/build/did.js +70 -84
- package/build/did.js.map +1 -1
- package/build/discover.js +9 -20
- package/build/discover.js.map +1 -1
- package/build/execute.js +16 -30
- 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 +19 -37
- package/build/explore/credentials.js.map +1 -1
- package/build/explore/index.js +9 -19
- 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 +24 -42
- 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 +14 -32
- 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 +13 -31
- 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 +19 -37
- package/build/explore/presentations.js.map +1 -1
- package/build/explore/styles.js +1 -4
- package/build/explore/styles.js.map +1 -1
- package/build/explore/utils.js +8 -17
- package/build/explore/utils.js.map +1 -1
- package/build/lib/agentCreator.d.ts +1 -1
- package/build/lib/agentCreator.d.ts.map +1 -1
- package/build/lib/agentCreator.js +3 -7
- 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 +22 -29
- package/build/lib/objectCreator.js.map +1 -1
- package/build/message.js +8 -19
- package/build/message.js.map +1 -1
- package/build/presentation.js +73 -98
- package/build/presentation.js.map +1 -1
- package/build/sdr.js +50 -68
- package/build/sdr.js.map +1 -1
- package/build/server.js +13 -25
- package/build/server.js.map +1 -1
- package/build/setup.d.ts +1 -2
- package/build/setup.d.ts.map +1 -1
- package/build/setup.js +8 -17
- package/build/setup.js.map +1 -1
- package/build/util.js +17 -32
- package/build/util.js.map +1 -1
- package/build/version.js +6 -5
- package/build/version.js.map +1 -1
- package/default/default.yml +1 -17
- package/package.json +29 -23
- package/src/cli.ts +15 -14
- package/src/config.ts +6 -5
- package/src/credential.ts +8 -8
- package/src/dev.ts +7 -3
- package/src/did.ts +12 -12
- package/src/discover.ts +2 -2
- package/src/execute.ts +5 -5
- package/src/explore/credentials.ts +3 -3
- package/src/explore/index.ts +5 -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 +3 -3
- package/src/lib/objectCreator.ts +15 -15
- package/src/message.ts +3 -3
- package/src/presentation.ts +45 -32
- package/src/sdr.ts +5 -5
- package/src/server.ts +5 -3
- package/src/setup.ts +3 -5
- package/src/version.ts +4 -2
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.js';
|
|
2
|
+
import './credential.js';
|
|
3
|
+
import './presentation.js';
|
|
4
|
+
import './explore/index.js';
|
|
5
|
+
import './sdr.js';
|
|
6
|
+
import './message.js';
|
|
7
|
+
import './discover.js';
|
|
8
|
+
import './version.js';
|
|
9
|
+
import './execute.js';
|
|
10
|
+
import './server.js';
|
|
11
|
+
import './setup.js';
|
|
12
|
+
import './config.js';
|
|
13
|
+
import './dev.js';
|
|
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":"AAMA,OAAO,UAAU,CAAA;AACjB,OAAO,iBAAiB,CAAA;AACxB,OAAO,mBAAmB,CAAA;AAC1B,OAAO,oBAAoB,CAAA;AAC3B,OAAO,UAAU,CAAA;AACjB,OAAO,cAAc,CAAA;AACrB,OAAO,eAAe,CAAA;AACtB,OAAO,cAAc,CAAA;AACrB,OAAO,cAAc,CAAA;AACrB,OAAO,aAAa,CAAA;AACpB,OAAO,YAAY,CAAA;AACnB,OAAO,aAAa,CAAA;AACpB,OAAO,UAAU,CAAA"}
|
package/build/cli.js
CHANGED
|
@@ -1,28 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
require("./server");
|
|
19
|
-
require("./setup");
|
|
20
|
-
require("./config");
|
|
21
|
-
require("./dev");
|
|
1
|
+
import { program } from 'commander';
|
|
2
|
+
import inquirer from 'inquirer';
|
|
3
|
+
import inquirer2 from 'inquirer-autocomplete-prompt';
|
|
4
|
+
inquirer.registerPrompt('autocomplete', inquirer2);
|
|
5
|
+
import './did.js';
|
|
6
|
+
import './credential.js';
|
|
7
|
+
import './presentation.js';
|
|
8
|
+
import './explore/index.js';
|
|
9
|
+
import './sdr.js';
|
|
10
|
+
import './message.js';
|
|
11
|
+
import './discover.js';
|
|
12
|
+
import './version.js';
|
|
13
|
+
import './execute.js';
|
|
14
|
+
import './server.js';
|
|
15
|
+
import './setup.js';
|
|
16
|
+
import './config.js';
|
|
17
|
+
import './dev.js';
|
|
22
18
|
if (!process.argv.slice(2).length) {
|
|
23
|
-
|
|
19
|
+
program.outputHelp();
|
|
24
20
|
}
|
|
25
21
|
else {
|
|
26
|
-
|
|
22
|
+
program.parse(process.argv);
|
|
27
23
|
}
|
|
28
24
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,SAAS,MAAM,8BAA8B,CAAA;AAEpD,QAAQ,CAAC,cAAc,CAAC,cAAc,EAAE,SAAS,CAAC,CAAA;AAElD,OAAO,UAAU,CAAA;AACjB,OAAO,iBAAiB,CAAA;AACxB,OAAO,mBAAmB,CAAA;AAC1B,OAAO,oBAAoB,CAAA;AAC3B,OAAO,UAAU,CAAA;AACjB,OAAO,cAAc,CAAA;AACrB,OAAO,eAAe,CAAA;AACtB,OAAO,cAAc,CAAA;AACrB,OAAO,cAAc,CAAA;AACrB,OAAO,aAAa,CAAA;AACpB,OAAO,YAAY,CAAA;AACnB,OAAO,aAAa,CAAA;AACpB,OAAO,UAAU,CAAA;AAEjB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE;IACjC,OAAO,CAAC,UAAU,EAAE,CAAA;CACrB;KAAM;IACL,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;CAC5B"}
|
package/build/config.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
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":""}
|
package/build/config.js
CHANGED
|
@@ -1,28 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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');
|
|
1
|
+
import { program } from 'commander';
|
|
2
|
+
import { SecretBox } from '@veramo/kms-local';
|
|
3
|
+
import { getAgent } from './setup.js';
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
import { dirname } from 'path';
|
|
6
|
+
import * as url from 'url';
|
|
7
|
+
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
|
8
|
+
program.option('--config <path>', 'Configuration file', './agent.yml');
|
|
9
|
+
const config = program.command('config').description('Agent configuration');
|
|
20
10
|
config
|
|
21
11
|
.command('create', { isDefault: true })
|
|
22
12
|
.description('Create default agent config')
|
|
23
13
|
.option('--filename <string>', 'Config file name', './agent.yml')
|
|
24
14
|
.option('--template <string>', 'Use template (default,client)', 'default')
|
|
25
|
-
.action((options) =>
|
|
15
|
+
.action(async (options) => {
|
|
26
16
|
const { filename, template } = options;
|
|
27
17
|
const templateFile = __dirname + '/../default/' + template + '.yml';
|
|
28
18
|
if (!fs.existsSync(templateFile)) {
|
|
@@ -40,16 +30,16 @@ config
|
|
|
40
30
|
else {
|
|
41
31
|
console.log('File already exists: ' + filename);
|
|
42
32
|
}
|
|
43
|
-
})
|
|
33
|
+
});
|
|
44
34
|
config
|
|
45
35
|
.command('create-secret-key')
|
|
46
36
|
.alias('gen-key')
|
|
47
37
|
.alias('key-gen')
|
|
48
38
|
.description('generate secret key')
|
|
49
39
|
.option('-q, --quiet', 'Only print the raw key, no instructions', false)
|
|
50
|
-
.action((options) =>
|
|
40
|
+
.action(async (options) => {
|
|
51
41
|
try {
|
|
52
|
-
const dbEncryptionKey =
|
|
42
|
+
const dbEncryptionKey = await SecretBox.createSecretKey();
|
|
53
43
|
if (options.quiet === true) {
|
|
54
44
|
console.log(dbEncryptionKey);
|
|
55
45
|
}
|
|
@@ -67,15 +57,15 @@ config
|
|
|
67
57
|
catch (e) {
|
|
68
58
|
console.error(e.message);
|
|
69
59
|
}
|
|
70
|
-
})
|
|
60
|
+
});
|
|
71
61
|
config
|
|
72
62
|
.command('check')
|
|
73
63
|
.alias('verify')
|
|
74
64
|
.description('Verify an agent config file syntax')
|
|
75
65
|
.option('-f, --filename <string>', 'Config file name', './agent.yml')
|
|
76
66
|
.option('-m, --method <string>', 'Check that a specific method is exposed by the agent.', 'execute')
|
|
77
|
-
.action((options) =>
|
|
78
|
-
const agent =
|
|
67
|
+
.action(async (options) => {
|
|
68
|
+
const agent = await getAgent(options.filename);
|
|
79
69
|
if (!agent) {
|
|
80
70
|
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.');
|
|
81
71
|
}
|
|
@@ -87,5 +77,5 @@ config
|
|
|
87
77
|
console.log(`Your Veramo configuration seems fine. An agent can be created and the 'agent.${options.method}()' method can be called on it.`);
|
|
88
78
|
}
|
|
89
79
|
}
|
|
90
|
-
})
|
|
80
|
+
});
|
|
91
81
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAE9B,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,MAAM,SAAS,GAAG,GAAG,CAAC,aAAa,CAAC,IAAI,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAEnE,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,EAAE,aAAa,CAAC,CAAA;AAEtE,MAAM,MAAM,GAAG,OAAO,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,C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
|
|
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');
|
|
1
|
+
import { getAgent } from './setup.js';
|
|
2
|
+
import { program } from 'commander';
|
|
3
|
+
import inquirer from 'inquirer';
|
|
4
|
+
import qrcode from 'qrcode-terminal';
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import * as json5 from 'json5';
|
|
7
|
+
import { readStdin } from './util.js';
|
|
8
|
+
import fuzzy from 'fuzzy';
|
|
9
|
+
const credential = program.command('credential').description('W3C Verifiable Credential');
|
|
47
10
|
credential
|
|
48
11
|
.command('create', { isDefault: true })
|
|
49
12
|
.description('Create W3C Verifiable Credential')
|
|
50
13
|
.option('-s, --send', 'Send')
|
|
51
14
|
.option('-j, --json', 'Output in JSON')
|
|
52
15
|
.option('-q, --qrcode', 'Show qrcode')
|
|
53
|
-
.action((cmd) =>
|
|
54
|
-
const agent =
|
|
55
|
-
const identifiers =
|
|
56
|
-
const knownDids =
|
|
16
|
+
.action(async (cmd) => {
|
|
17
|
+
const agent = await getAgent(program.opts().config);
|
|
18
|
+
const identifiers = await agent.didManagerFind();
|
|
19
|
+
const knownDids = await agent.dataStoreORMGetIdentifiers();
|
|
57
20
|
const subjects = [...knownDids.map((id) => id.did)];
|
|
58
21
|
if (identifiers.length === 0) {
|
|
59
22
|
console.error('No dids');
|
|
60
23
|
process.exit();
|
|
61
24
|
}
|
|
62
|
-
const answers =
|
|
25
|
+
const answers = await inquirer.prompt([
|
|
63
26
|
{
|
|
64
27
|
type: 'list',
|
|
65
28
|
name: 'proofFormat',
|
|
@@ -79,12 +42,12 @@ credential
|
|
|
79
42
|
type: 'autocomplete',
|
|
80
43
|
name: 'sub',
|
|
81
44
|
pageSize: 15,
|
|
82
|
-
source: (answers, input) =>
|
|
45
|
+
source: async (answers, input) => {
|
|
83
46
|
const res = fuzzy
|
|
84
47
|
.filter(input, subjects)
|
|
85
48
|
.map((el) => (typeof el === 'string' ? el : el.original));
|
|
86
49
|
return res;
|
|
87
|
-
}
|
|
50
|
+
},
|
|
88
51
|
message: 'Subject DID',
|
|
89
52
|
},
|
|
90
53
|
{
|
|
@@ -127,7 +90,7 @@ credential
|
|
|
127
90
|
credentialSubject,
|
|
128
91
|
};
|
|
129
92
|
if (answers.addStatus) {
|
|
130
|
-
const statusAnswers =
|
|
93
|
+
const statusAnswers = await inquirer.prompt([
|
|
131
94
|
{
|
|
132
95
|
type: 'input',
|
|
133
96
|
name: 'type',
|
|
@@ -138,7 +101,8 @@ credential
|
|
|
138
101
|
type: 'input',
|
|
139
102
|
name: 'id',
|
|
140
103
|
message: 'Credential status ID',
|
|
141
|
-
|
|
104
|
+
// TODO(nickreynolds): deploy
|
|
105
|
+
default: 'goerli:0x97fd27892cdcD035dAe1fe71235c636044B59348',
|
|
142
106
|
},
|
|
143
107
|
]);
|
|
144
108
|
credential['credentialStatus'] = {
|
|
@@ -146,7 +110,7 @@ credential
|
|
|
146
110
|
id: statusAnswers.id,
|
|
147
111
|
};
|
|
148
112
|
}
|
|
149
|
-
const verifiableCredential =
|
|
113
|
+
const verifiableCredential = await agent.createVerifiableCredential({
|
|
150
114
|
save: true,
|
|
151
115
|
credential,
|
|
152
116
|
proofFormat: answers.proofFormat,
|
|
@@ -163,7 +127,7 @@ credential
|
|
|
163
127
|
type = 'w3c.vc';
|
|
164
128
|
}
|
|
165
129
|
try {
|
|
166
|
-
const message =
|
|
130
|
+
const message = await agent.sendMessageDIDCommAlpha1({
|
|
167
131
|
save: true,
|
|
168
132
|
data: {
|
|
169
133
|
from: answers.iss,
|
|
@@ -179,7 +143,7 @@ credential
|
|
|
179
143
|
}
|
|
180
144
|
}
|
|
181
145
|
if (cmd.qrcode) {
|
|
182
|
-
|
|
146
|
+
qrcode.generate(verifiableCredential.proof.jwt);
|
|
183
147
|
}
|
|
184
148
|
else {
|
|
185
149
|
if (cmd.json) {
|
|
@@ -189,23 +153,23 @@ credential
|
|
|
189
153
|
console.dir(verifiableCredential, { depth: 10 });
|
|
190
154
|
}
|
|
191
155
|
}
|
|
192
|
-
})
|
|
156
|
+
});
|
|
193
157
|
credential
|
|
194
158
|
.command('verify')
|
|
195
159
|
.description('Verify a W3C Verifiable Credential provided as raw string, file or stdin')
|
|
196
160
|
.option('-f, --filename <string>', 'Optional. Read the credential from a file instead of stdin')
|
|
197
161
|
.option('-r, --raw <string>', 'Optional. Specify the credential as a parameter instead of file or stdin')
|
|
198
|
-
.action((options) =>
|
|
199
|
-
const agent =
|
|
162
|
+
.action(async (options) => {
|
|
163
|
+
const agent = await getAgent(program.opts().config);
|
|
200
164
|
let raw = '';
|
|
201
165
|
if (options.raw) {
|
|
202
166
|
raw = options.raw;
|
|
203
167
|
}
|
|
204
168
|
else if (options.filename) {
|
|
205
|
-
raw =
|
|
169
|
+
raw = await fs.promises.readFile(options.filename, 'utf-8');
|
|
206
170
|
}
|
|
207
171
|
else {
|
|
208
|
-
raw =
|
|
172
|
+
raw = await readStdin();
|
|
209
173
|
}
|
|
210
174
|
let credentialAsJSON;
|
|
211
175
|
try {
|
|
@@ -220,7 +184,7 @@ credential
|
|
|
220
184
|
};
|
|
221
185
|
}
|
|
222
186
|
try {
|
|
223
|
-
const result =
|
|
187
|
+
const result = await agent.verifyCredential({ credential: credentialAsJSON });
|
|
224
188
|
if (result.verified === true) {
|
|
225
189
|
console.log('Credential was verified successfully.');
|
|
226
190
|
}
|
|
@@ -231,13 +195,13 @@ credential
|
|
|
231
195
|
catch (e) {
|
|
232
196
|
console.error(e.message);
|
|
233
197
|
}
|
|
234
|
-
})
|
|
198
|
+
});
|
|
235
199
|
credential
|
|
236
200
|
.command('output')
|
|
237
201
|
.description('Print W3C Verifiable Credential to stdout')
|
|
238
|
-
.action((cmd) =>
|
|
239
|
-
const agent =
|
|
240
|
-
const credentials =
|
|
202
|
+
.action(async (cmd) => {
|
|
203
|
+
const agent = await getAgent(program.opts().config);
|
|
204
|
+
const credentials = await agent.dataStoreORMGetVerifiableCredentials();
|
|
241
205
|
if (credentials.length > 0) {
|
|
242
206
|
const list = [];
|
|
243
207
|
for (const cred of credentials) {
|
|
@@ -248,7 +212,7 @@ credential
|
|
|
248
212
|
value: cred,
|
|
249
213
|
});
|
|
250
214
|
}
|
|
251
|
-
const answers =
|
|
215
|
+
const answers = await inquirer.prompt([
|
|
252
216
|
{
|
|
253
217
|
type: 'list',
|
|
254
218
|
name: 'credential',
|
|
@@ -261,5 +225,5 @@ credential
|
|
|
261
225
|
else {
|
|
262
226
|
console.log('No credentials found.');
|
|
263
227
|
}
|
|
264
|
-
})
|
|
228
|
+
});
|
|
265
229
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"credential.js","sourceRoot":"","sources":["../src/credential.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,MAAM,MAAM,iBAAiB,CAAA;AACpC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,UAAU,GAAG,OAAO,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,c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AAC,CAAA;SACH;QAED,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;YACpC;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,YAAY;gBAClB,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,mBAAmB;aAC7B;SACF,CAAC,CAAA;QAEF,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAA;KAC/C;SAAM;QACL,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAA;KACrC;AACH,CAAC,CAAC,CAAA"}
|
package/build/dev.js
CHANGED
|
@@ -1,44 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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');
|
|
1
|
+
import { Extractor, ExtractorConfig } from '@microsoft/api-extractor';
|
|
2
|
+
import { ApiModel, } from '@microsoft/api-extractor-model';
|
|
3
|
+
import { program } from 'commander';
|
|
4
|
+
import { writeFileSync } from 'fs';
|
|
5
|
+
import { resolve } from 'path';
|
|
6
|
+
import * as TJS from 'ts-json-schema-generator';
|
|
7
|
+
import { createRequire } from "module";
|
|
8
|
+
const require = createRequire(import.meta.url);
|
|
42
9
|
const genericTypes = ['boolean', 'string', 'number', 'any', 'Array<string>'];
|
|
43
10
|
function createSchema(generator, symbol) {
|
|
44
11
|
if (genericTypes.includes(symbol)) {
|
|
@@ -83,17 +50,16 @@ function getReference(response) {
|
|
|
83
50
|
return { $ref: '#/components/schemas/' + response };
|
|
84
51
|
}
|
|
85
52
|
}
|
|
86
|
-
const dev =
|
|
53
|
+
const dev = program.command('dev').description('Plugin developer tools');
|
|
87
54
|
dev
|
|
88
55
|
.command('generate-plugin-schema')
|
|
89
56
|
.description('generate plugin schema')
|
|
90
57
|
.option('-c, --extractorConfig <string>', 'API Extractor config file', './api-extractor.json')
|
|
91
58
|
.option('-p, --packageConfig <string>', 'package.json file containing a Veramo plugin interface config', './package.json')
|
|
92
|
-
.action((options) =>
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
const
|
|
96
|
-
const extractorResult = api_extractor_1.Extractor.invoke(extractorConfig, {
|
|
59
|
+
.action(async (options) => {
|
|
60
|
+
const apiExtractorJsonPath = resolve(options.extractorConfig);
|
|
61
|
+
const extractorConfig = ExtractorConfig.loadFileAndPrepare(apiExtractorJsonPath);
|
|
62
|
+
const extractorResult = Extractor.invoke(extractorConfig, {
|
|
97
63
|
localBuild: true,
|
|
98
64
|
showVerboseMessages: true,
|
|
99
65
|
});
|
|
@@ -102,9 +68,9 @@ dev
|
|
|
102
68
|
` and ${extractorResult.warningCount} warnings`);
|
|
103
69
|
process.exitCode = 1;
|
|
104
70
|
}
|
|
105
|
-
const packageConfig = require(
|
|
71
|
+
const packageConfig = require(resolve(options.packageConfig));
|
|
106
72
|
const interfaces = {};
|
|
107
|
-
for (const pluginInterfaceName in
|
|
73
|
+
for (const pluginInterfaceName in packageConfig?.veramo?.pluginInterfaces) {
|
|
108
74
|
const entryFile = packageConfig.veramo.pluginInterfaces[pluginInterfaceName];
|
|
109
75
|
const api = {
|
|
110
76
|
components: {
|
|
@@ -113,11 +79,12 @@ dev
|
|
|
113
79
|
},
|
|
114
80
|
};
|
|
115
81
|
const generator = TJS.createGenerator({
|
|
116
|
-
path:
|
|
82
|
+
path: resolve(entryFile),
|
|
117
83
|
encodeRefs: false,
|
|
118
84
|
additionalProperties: true,
|
|
85
|
+
skipTypeCheck: true,
|
|
119
86
|
});
|
|
120
|
-
const apiModel = new
|
|
87
|
+
const apiModel = new ApiModel();
|
|
121
88
|
const apiPackage = apiModel.loadPackage(extractorConfig.apiJsonFilePath);
|
|
122
89
|
const entry = apiPackage.entryPoints[0];
|
|
123
90
|
const pluginInterface = entry.findMembersByName(pluginInterfaceName)[0];
|
|
@@ -126,19 +93,30 @@ dev
|
|
|
126
93
|
method.pluginInterfaceName = pluginInterfaceName;
|
|
127
94
|
method.operationId = member.displayName;
|
|
128
95
|
// console.log(member)
|
|
129
|
-
method.parameters =
|
|
96
|
+
method.parameters = member.parameters[0]?.parameterTypeExcerpt?.text;
|
|
130
97
|
method.response = member.returnTypeExcerpt.text
|
|
131
98
|
.replace('Promise<', '')
|
|
132
99
|
.replace('>', '');
|
|
133
100
|
const methodSignature = member;
|
|
134
|
-
method.description =
|
|
101
|
+
method.description = methodSignature.tsdocComment?.summarySection
|
|
102
|
+
?.getChildNodes()[0]
|
|
103
|
+
//@ts-ignore
|
|
104
|
+
?.getChildNodes()[0]?.text;
|
|
135
105
|
method.description = method.description || '';
|
|
136
106
|
if (method.parameters) {
|
|
137
107
|
//@ts-ignore
|
|
138
|
-
api.components.schemas =
|
|
108
|
+
api.components.schemas = {
|
|
109
|
+
//@ts-ignore
|
|
110
|
+
...api.components.schemas,
|
|
111
|
+
...createSchema(generator, method.parameters).components.schemas,
|
|
112
|
+
};
|
|
139
113
|
}
|
|
140
114
|
//@ts-ignore
|
|
141
|
-
api.components.schemas =
|
|
115
|
+
api.components.schemas = {
|
|
116
|
+
//@ts-ignore
|
|
117
|
+
...api.components.schemas,
|
|
118
|
+
...createSchema(generator, method.response).components.schemas,
|
|
119
|
+
};
|
|
142
120
|
//@ts-ignore
|
|
143
121
|
api.components.methods[method.operationId] = {
|
|
144
122
|
description: method.description,
|
|
@@ -148,16 +126,16 @@ dev
|
|
|
148
126
|
}
|
|
149
127
|
interfaces[pluginInterfaceName] = api;
|
|
150
128
|
}
|
|
151
|
-
|
|
152
|
-
})
|
|
129
|
+
writeFileSync(resolve('./src/plugin.schema.json'), JSON.stringify(interfaces, null, 2));
|
|
130
|
+
});
|
|
153
131
|
dev
|
|
154
132
|
.command('extract-api')
|
|
155
133
|
.description('Extract API')
|
|
156
134
|
.option('-c, --extractorConfig <string>', 'API Extractor config file', './api-extractor.json')
|
|
157
|
-
.action((options) =>
|
|
158
|
-
const apiExtractorJsonPath =
|
|
159
|
-
const extractorConfig =
|
|
160
|
-
const extractorResult =
|
|
135
|
+
.action(async (options) => {
|
|
136
|
+
const apiExtractorJsonPath = resolve(options.extractorConfig);
|
|
137
|
+
const extractorConfig = ExtractorConfig.loadFileAndPrepare(apiExtractorJsonPath);
|
|
138
|
+
const extractorResult = Extractor.invoke(extractorConfig, {
|
|
161
139
|
localBuild: true,
|
|
162
140
|
showVerboseMessages: true,
|
|
163
141
|
});
|
|
@@ -166,5 +144,5 @@ dev
|
|
|
166
144
|
` and ${extractorResult.warningCount} warnings`);
|
|
167
145
|
process.exitCode = 1;
|
|
168
146
|
}
|
|
169
|
-
})
|
|
147
|
+
});
|
|
170
148
|
//# sourceMappingURL=dev.js.map
|