@veramo/cli 5.0.1-next.9 → 5.1.2-next.2
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/build/cli.d.ts +1 -13
- package/build/cli.d.ts.map +1 -1
- package/build/cli.js +3 -16
- package/build/cli.js.map +1 -1
- package/build/config.d.ts +3 -1
- package/build/config.d.ts.map +1 -1
- package/build/config.js +6 -4
- package/build/config.js.map +1 -1
- package/build/createCommand.d.ts +4 -0
- package/build/createCommand.d.ts.map +1 -0
- package/build/createCommand.js +31 -0
- package/build/createCommand.js.map +1 -0
- package/build/credential.d.ts +3 -1
- package/build/credential.d.ts.map +1 -1
- package/build/credential.js +12 -11
- package/build/credential.js.map +1 -1
- package/build/dev.d.ts +3 -1
- package/build/dev.d.ts.map +1 -1
- package/build/dev.js +12 -11
- package/build/dev.js.map +1 -1
- package/build/did.d.ts +3 -1
- package/build/did.d.ts.map +1 -1
- package/build/did.js +31 -25
- package/build/did.js.map +1 -1
- package/build/discover.d.ts +3 -1
- package/build/discover.d.ts.map +1 -1
- package/build/discover.js +6 -5
- package/build/discover.js.map +1 -1
- package/build/execute.d.ts +3 -1
- package/build/execute.d.ts.map +1 -1
- package/build/execute.js +14 -9
- package/build/execute.js.map +1 -1
- package/build/explore/index.d.ts +3 -1
- package/build/explore/index.d.ts.map +1 -1
- package/build/explore/index.js +4 -5
- package/build/explore/index.js.map +1 -1
- package/build/lib/agentCreator.d.ts +9 -0
- package/build/lib/agentCreator.d.ts.map +1 -1
- package/build/lib/agentCreator.js +10 -1
- package/build/lib/agentCreator.js.map +1 -1
- package/build/lib/objectCreator.d.ts +47 -1
- package/build/lib/objectCreator.d.ts.map +1 -1
- package/build/lib/objectCreator.js +48 -2
- package/build/lib/objectCreator.js.map +1 -1
- package/build/message.d.ts +3 -1
- package/build/message.d.ts.map +1 -1
- package/build/message.js +5 -4
- package/build/message.js.map +1 -1
- package/build/presentation.d.ts +3 -1
- package/build/presentation.d.ts.map +1 -1
- package/build/presentation.js +14 -13
- package/build/presentation.js.map +1 -1
- package/build/sdr.d.ts +3 -1
- package/build/sdr.d.ts.map +1 -1
- package/build/sdr.js +10 -8
- package/build/sdr.js.map +1 -1
- package/build/server.d.ts +3 -1
- package/build/server.d.ts.map +1 -1
- package/build/server.js +10 -7
- package/build/server.js.map +1 -1
- package/build/setup.d.ts +9 -1
- package/build/setup.d.ts.map +1 -1
- package/build/setup.js +22 -6
- package/build/setup.js.map +1 -1
- package/default/default.yml +21 -29
- package/package.json +45 -28
- package/src/__tests__/cli.test.ts +49 -0
- package/src/cli.ts +3 -17
- package/src/config.ts +9 -6
- package/src/createCommand.ts +34 -0
- package/src/credential.ts +13 -11
- package/src/dev.ts +15 -13
- package/src/did.ts +34 -27
- package/src/discover.ts +7 -5
- package/src/execute.ts +14 -9
- package/src/explore/index.ts +5 -5
- package/src/lib/agentCreator.ts +10 -1
- package/src/lib/objectCreator.ts +49 -3
- package/src/message.ts +6 -4
- package/src/presentation.ts +53 -48
- package/src/sdr.ts +11 -8
- package/src/server.ts +11 -7
- package/src/setup.ts +22 -6
- package/build/version.d.ts +0 -2
- package/build/version.d.ts.map +0 -1
- package/build/version.js +0 -7
- package/build/version.js.map +0 -1
- package/src/__tests__/default.test.ts +0 -6
- package/src/version.ts +0 -9
package/src/sdr.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ICredentialRequestInput } from '@veramo/selective-disclosure'
|
|
2
2
|
import { getAgent } from './setup.js'
|
|
3
|
-
import {
|
|
3
|
+
import { Command } from 'commander'
|
|
4
4
|
import inquirer from 'inquirer'
|
|
5
5
|
import qrcode from 'qrcode-terminal'
|
|
6
6
|
import { shortDate, shortDid } from './explore/utils.js'
|
|
@@ -9,13 +9,14 @@ import { asArray, extractIssuer } from '@veramo/utils'
|
|
|
9
9
|
|
|
10
10
|
import fuzzy from 'fuzzy'
|
|
11
11
|
|
|
12
|
-
const sdr =
|
|
12
|
+
const sdr = new Command('sdr').description('Selective Disclosure Request')
|
|
13
13
|
|
|
14
14
|
sdr
|
|
15
15
|
.command('create', { isDefault: true })
|
|
16
16
|
.description('create Selective Disclosure Request')
|
|
17
|
-
.
|
|
18
|
-
|
|
17
|
+
.option('-q, --qrcode', 'Show qrcode')
|
|
18
|
+
.action(async (opts: { qrcode: boolean }, cmd: Command) => {
|
|
19
|
+
const agent = await getAgent(cmd.optsWithGlobals().config)
|
|
19
20
|
const identifiers = await agent.didManagerFind()
|
|
20
21
|
|
|
21
22
|
const knownDids = await agent.dataStoreORMGetIdentifiers()
|
|
@@ -253,7 +254,7 @@ sdr
|
|
|
253
254
|
console.log('Subject not specified')
|
|
254
255
|
}
|
|
255
256
|
|
|
256
|
-
if (
|
|
257
|
+
if (opts.qrcode) {
|
|
257
258
|
qrcode.generate(jwt)
|
|
258
259
|
} else {
|
|
259
260
|
console.dir(data, { depth: 10 })
|
|
@@ -264,8 +265,8 @@ sdr
|
|
|
264
265
|
sdr
|
|
265
266
|
.command('respond')
|
|
266
267
|
.description('respond to Selective Disclosure Request')
|
|
267
|
-
.action(async (cmd) => {
|
|
268
|
-
const agent = await getAgent(
|
|
268
|
+
.action(async (opts: {}, cmd: Command) => {
|
|
269
|
+
const agent = await getAgent(cmd.optsWithGlobals().config)
|
|
269
270
|
const sdrMessages = await agent.dataStoreORMGetMessages({
|
|
270
271
|
where: [{ column: 'type', value: ['sdr'] }],
|
|
271
272
|
order: [{ column: 'createdAt', direction: 'DESC' }],
|
|
@@ -278,7 +279,7 @@ sdr
|
|
|
278
279
|
' ' +
|
|
279
280
|
shortDid(message.from) +
|
|
280
281
|
' asking to share: ' +
|
|
281
|
-
|
|
282
|
+
// @ts-ignore
|
|
282
283
|
message.data?.claims?.map((claim) => claim.claimType).join(','),
|
|
283
284
|
value: message,
|
|
284
285
|
}))
|
|
@@ -354,3 +355,5 @@ sdr
|
|
|
354
355
|
|
|
355
356
|
console.dir(verifiablePresentation, { depth: 10 })
|
|
356
357
|
})
|
|
358
|
+
|
|
359
|
+
export { sdr }
|
package/src/server.ts
CHANGED
|
@@ -1,30 +1,34 @@
|
|
|
1
1
|
import express from 'express'
|
|
2
|
-
import {
|
|
2
|
+
import { Command } from 'commander'
|
|
3
3
|
import { getConfig } from './setup.js'
|
|
4
4
|
import { createObjects } from './lib/objectCreator.js'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
.command('server')
|
|
6
|
+
const server = new Command('server')
|
|
8
7
|
.description('Launch OpenAPI server')
|
|
9
8
|
.option('-p, --port <number>', 'Optionally set port to override config')
|
|
10
|
-
.action(async (cmd) => {
|
|
9
|
+
.action(async (opts: { port: number }, cmd: Command) => {
|
|
11
10
|
const app = express()
|
|
12
11
|
|
|
13
12
|
let server: any
|
|
14
13
|
|
|
15
14
|
try {
|
|
16
|
-
const config = await createObjects(getConfig(
|
|
15
|
+
const config = await createObjects(getConfig(cmd.optsWithGlobals().config), { server: '/server' })
|
|
17
16
|
server = config.server
|
|
18
17
|
} catch (e: any) {
|
|
19
|
-
console.
|
|
18
|
+
console.error(e.message)
|
|
20
19
|
process.exit(1)
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
for (let router of server.use) {
|
|
24
23
|
app.use(...router)
|
|
24
|
+
if (typeof router[0] === 'string') {
|
|
25
|
+
console.log(`Listening to route: ${server.baseUrl}${router[0]}`)
|
|
26
|
+
}
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
app.listen(
|
|
29
|
+
app.listen(opts.port || server.port, async () => {
|
|
28
30
|
console.log(`🚀 Cloud Agent ready at ${server.baseUrl}`)
|
|
29
31
|
})
|
|
30
32
|
})
|
|
33
|
+
|
|
34
|
+
export { server }
|
package/src/setup.ts
CHANGED
|
@@ -16,17 +16,33 @@ import { createAgentFromConfig } from './lib/agentCreator.js'
|
|
|
16
16
|
|
|
17
17
|
import fs from 'fs'
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Parses a yaml config file and returns a config object
|
|
21
|
+
* @param filePath
|
|
22
|
+
*/
|
|
23
|
+
export const getConfig = async (filePath: fs.PathLike): Promise<{ version?: number; [x: string]: any }> => {
|
|
24
|
+
let fileContent: string
|
|
25
|
+
|
|
26
|
+
// read file async
|
|
27
|
+
try {
|
|
28
|
+
fileContent = await fs.promises.readFile(filePath, 'utf8')
|
|
29
|
+
} catch (e) {
|
|
30
|
+
console.log('Config file not found: ' + filePath)
|
|
22
31
|
console.log('Use "veramo config create" to create one')
|
|
23
32
|
process.exit(1)
|
|
24
33
|
}
|
|
25
34
|
|
|
26
|
-
|
|
35
|
+
let config
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
config = yaml.parse(fileContent, { prettyErrors: true })
|
|
39
|
+
} catch (e) {
|
|
40
|
+
console.error(`Unable to parse config file: ${e.message} ${e.linePos}`)
|
|
41
|
+
process.exit(1)
|
|
42
|
+
}
|
|
27
43
|
|
|
28
44
|
if (config?.version != 3) {
|
|
29
|
-
console.
|
|
45
|
+
console.error('Unsupported configuration file version:', config.version)
|
|
30
46
|
process.exit(1)
|
|
31
47
|
}
|
|
32
48
|
return config
|
|
@@ -47,7 +63,7 @@ export type ConfiguredAgent = TAgent<EnabledInterfaces>
|
|
|
47
63
|
|
|
48
64
|
export async function getAgent(fileName: string): Promise<ConfiguredAgent> {
|
|
49
65
|
try {
|
|
50
|
-
return await createAgentFromConfig<EnabledInterfaces>(getConfig(fileName))
|
|
66
|
+
return await createAgentFromConfig<EnabledInterfaces>(await getConfig(fileName))
|
|
51
67
|
} catch (e: any) {
|
|
52
68
|
console.log('Unable to create agent from ' + fileName + '.', e.message)
|
|
53
69
|
process.exit(1)
|
package/build/version.d.ts
DELETED
package/build/version.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,CAAA"}
|
package/build/version.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { program } from 'commander';
|
|
2
|
-
import module from "module";
|
|
3
|
-
const requireCjs = module.createRequire(import.meta.url);
|
|
4
|
-
const data = requireCjs("../package.json");
|
|
5
|
-
const { version } = data;
|
|
6
|
-
program.version(version, '-v, --version');
|
|
7
|
-
//# sourceMappingURL=version.js.map
|
package/build/version.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,MAAM,UAAU,GAAG,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzD,MAAM,IAAI,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC;AAC3C,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;AAExB,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,eAAe,CAAC,CAAA"}
|
package/src/version.ts
DELETED