@veramo/cli 5.0.1-next.11 → 5.0.1-next.13
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 +5 -4
- 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 +13 -8
- 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 +9 -0
- package/build/lib/agentCreator.js.map +1 -1
- package/build/lib/objectCreator.d.ts +44 -0
- package/build/lib/objectCreator.d.ts.map +1 -1
- package/build/lib/objectCreator.js +46 -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 +9 -7
- 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/package.json +44 -26
- package/src/__tests__/cli.test.ts +42 -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 +8 -6
- package/src/did.ts +34 -27
- package/src/discover.ts +7 -5
- package/src/execute.ts +13 -8
- package/src/explore/index.ts +5 -5
- package/src/lib/agentCreator.ts +9 -0
- package/src/lib/objectCreator.ts +46 -2
- package/src/message.ts +6 -4
- package/src/presentation.ts +53 -48
- package/src/sdr.ts +10 -7
- package/src/server.ts +11 -7
- 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/lib/objectCreator.ts
CHANGED
|
@@ -2,6 +2,50 @@ import { set, get } from 'jsonpointer'
|
|
|
2
2
|
import parse from 'url-parse'
|
|
3
3
|
import { resolve } from 'path'
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Creates objects from a configuration object and a set of pointers.
|
|
7
|
+
*
|
|
8
|
+
* Example:
|
|
9
|
+
* ```ts
|
|
10
|
+
* const { url } = createObjects({ "rpcUrl": "http://localhost:8545", }, { url: '/rpcUrl' })
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* The config can contain references (`$ref`) to other objects within using JSON pointers.
|
|
14
|
+
* Example:
|
|
15
|
+
* ```json5
|
|
16
|
+
* {
|
|
17
|
+
* rpcUrl: "http://localhost:8545",
|
|
18
|
+
* endpoint: {
|
|
19
|
+
* url: {
|
|
20
|
+
* "$ref": "/rpcUrl"
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* The config object can also contain references to NPM modules using the `$require` property.
|
|
26
|
+
* Example:
|
|
27
|
+
* ```json5
|
|
28
|
+
* {
|
|
29
|
+
* agent: {
|
|
30
|
+
* "$require": "@veramo/core#Agent",
|
|
31
|
+
* "$args": {
|
|
32
|
+
* plugins: [
|
|
33
|
+
* { "$require": "@veramo/did-comm#DIDComm" },
|
|
34
|
+
* ]
|
|
35
|
+
* }
|
|
36
|
+
* }
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
* Environment variables can also be specified using the `$env` property.
|
|
40
|
+
*
|
|
41
|
+
* @see Please see {@link https://veramo.io/docs/veramo_agent/configuration_internals | Configuration Internals} for
|
|
42
|
+
* more information.
|
|
43
|
+
*
|
|
44
|
+
* @param config - The configuration object
|
|
45
|
+
* @param pointers - A map of JSON pointers to objects within that config that you wish to create
|
|
46
|
+
*
|
|
47
|
+
* @beta
|
|
48
|
+
*/
|
|
5
49
|
export async function createObjects(config: object, pointers: Record<string, string>): Promise<any> {
|
|
6
50
|
const objects = {}
|
|
7
51
|
|
|
@@ -51,9 +95,9 @@ export async function createObjects(config: object, pointers: Record<string, str
|
|
|
51
95
|
module = resolve(module)
|
|
52
96
|
}
|
|
53
97
|
|
|
54
|
-
const resolvedArgs = args !== undefined ?
|
|
98
|
+
const resolvedArgs = args !== undefined ? await resolveRefs(args) : []
|
|
55
99
|
try {
|
|
56
|
-
let required = member ? (await import(module))[member] :
|
|
100
|
+
let required = member ? (await import(module))[member] : await import(module)
|
|
57
101
|
if (type === 'class') {
|
|
58
102
|
object = new required(...resolvedArgs)
|
|
59
103
|
} else if (type === 'function') {
|
package/src/message.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getAgent } from './setup.js'
|
|
2
|
-
import {
|
|
2
|
+
import { Command } from 'commander'
|
|
3
3
|
import fs from 'fs'
|
|
4
4
|
|
|
5
|
-
const message =
|
|
5
|
+
const message = new Command('message').description('Messages')
|
|
6
6
|
|
|
7
7
|
message
|
|
8
8
|
.command('handle', { isDefault: true })
|
|
@@ -11,8 +11,8 @@ message
|
|
|
11
11
|
.option('-f, --file <string>', 'Path to a file containing raw message')
|
|
12
12
|
.option('--save <boolean>', 'Save message', true)
|
|
13
13
|
|
|
14
|
-
.action(async (options) => {
|
|
15
|
-
const agent = await getAgent(
|
|
14
|
+
.action(async (options: { file: string; raw: string; save: boolean }, cmd: Command) => {
|
|
15
|
+
const agent = await getAgent(cmd.optsWithGlobals().config)
|
|
16
16
|
try {
|
|
17
17
|
let raw
|
|
18
18
|
|
|
@@ -35,3 +35,5 @@ message
|
|
|
35
35
|
console.error(e.message)
|
|
36
36
|
}
|
|
37
37
|
})
|
|
38
|
+
|
|
39
|
+
export { message }
|
package/src/presentation.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { getAgent } from './setup.js'
|
|
2
|
-
import {
|
|
2
|
+
import { Command } from 'commander'
|
|
3
3
|
import inquirer from 'inquirer'
|
|
4
4
|
import qrcode from 'qrcode-terminal'
|
|
5
5
|
import { readStdin } from './util.js'
|
|
6
6
|
import * as fs from 'fs'
|
|
7
7
|
import * as json5 from 'json5'
|
|
8
8
|
import { extractIssuer } from '@veramo/utils'
|
|
9
|
-
import { PartialIdentifier, UniqueVerifiablePresentation } from
|
|
9
|
+
import { PartialIdentifier, UniqueVerifiablePresentation } from '@veramo/core-types'
|
|
10
10
|
|
|
11
|
-
const presentation =
|
|
11
|
+
const presentation = new Command('presentation').description('W3C Verifiable Presentation')
|
|
12
12
|
|
|
13
13
|
presentation
|
|
14
14
|
.command('create', { isDefault: true })
|
|
15
15
|
.description('Create W3C Verifiable Presentation')
|
|
16
16
|
.option('-s, --send', 'Send')
|
|
17
17
|
.option('-q, --qrcode', 'Show qrcode')
|
|
18
|
-
.action(async (cmd) => {
|
|
19
|
-
const agent = await getAgent(
|
|
18
|
+
.action(async (opts: { send: boolean; qrcode: boolean }, cmd: Command) => {
|
|
19
|
+
const agent = await getAgent(cmd.optsWithGlobals().config)
|
|
20
20
|
const myIdentifiers = await agent.didManagerFind()
|
|
21
21
|
if (myIdentifiers.length === 0) {
|
|
22
22
|
console.error('No dids')
|
|
@@ -33,7 +33,7 @@ presentation
|
|
|
33
33
|
...ids.map((id: PartialIdentifier) => id.did),
|
|
34
34
|
]
|
|
35
35
|
|
|
36
|
-
let aud:string[] = []
|
|
36
|
+
let aud: string[] = []
|
|
37
37
|
const answers = await inquirer.prompt([
|
|
38
38
|
{
|
|
39
39
|
type: 'list',
|
|
@@ -72,8 +72,8 @@ presentation
|
|
|
72
72
|
type: 'list',
|
|
73
73
|
name: 'aud',
|
|
74
74
|
message: 'Select Verifier or enter manually',
|
|
75
|
-
choices: identifiers
|
|
76
|
-
}
|
|
75
|
+
choices: identifiers,
|
|
76
|
+
},
|
|
77
77
|
])
|
|
78
78
|
answer = audAnswer.aud
|
|
79
79
|
if (answer === 'manual') {
|
|
@@ -144,8 +144,8 @@ presentation
|
|
|
144
144
|
proofFormat: 'jwt',
|
|
145
145
|
})
|
|
146
146
|
|
|
147
|
-
if (
|
|
148
|
-
for(var verifier in aud) {
|
|
147
|
+
if (opts.send) {
|
|
148
|
+
for (var verifier in aud) {
|
|
149
149
|
try {
|
|
150
150
|
const message = await agent.sendMessageDIDCommAlpha1({
|
|
151
151
|
save: true,
|
|
@@ -163,7 +163,7 @@ presentation
|
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
if (
|
|
166
|
+
if (opts.qrcode) {
|
|
167
167
|
qrcode.generate(verifiablePresentation.proof.jwt)
|
|
168
168
|
} else {
|
|
169
169
|
console.dir(verifiablePresentation, { depth: 10 })
|
|
@@ -178,54 +178,57 @@ presentation
|
|
|
178
178
|
.option('-d, --domain <string>', 'Optional. Specify a domain that the presentation should match.')
|
|
179
179
|
.option('-f, --filename <string>', 'Optional. Read the presentation from a file instead of stdin')
|
|
180
180
|
.option('-r, --raw <string>', 'Optional. Presentation as a parameter string instead of a file or stdin.')
|
|
181
|
-
.action(
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
181
|
+
.action(
|
|
182
|
+
async (options: { challenge: string; domain: string; filename: string; raw: string }, cmd: Command) => {
|
|
183
|
+
const agent = await getAgent(cmd.optsWithGlobals().config)
|
|
184
|
+
let raw: string = ''
|
|
185
|
+
if (options.raw) {
|
|
186
|
+
raw = options.raw
|
|
187
|
+
} else if (options.filename) {
|
|
188
|
+
raw = await fs.promises.readFile(options.filename, 'utf-8')
|
|
189
|
+
} else {
|
|
190
|
+
raw = await readStdin()
|
|
191
|
+
}
|
|
192
|
+
let presentationAsJSON: any
|
|
193
|
+
try {
|
|
194
|
+
presentationAsJSON = json5.parse(raw)
|
|
195
|
+
} catch (e: any) {
|
|
196
|
+
presentationAsJSON = {
|
|
197
|
+
proof: {
|
|
198
|
+
type: 'JwtProof2020',
|
|
199
|
+
jwt: raw,
|
|
200
|
+
},
|
|
201
|
+
} as any
|
|
202
|
+
}
|
|
203
|
+
const result = await agent.verifyPresentation({
|
|
204
|
+
presentation: presentationAsJSON,
|
|
205
|
+
challenge: options.challenge,
|
|
206
|
+
domain: options.domain,
|
|
207
|
+
})
|
|
208
|
+
if (result.verified === true) {
|
|
209
|
+
console.log('Presentation was verified successfully.')
|
|
210
|
+
} else {
|
|
211
|
+
console.error('Presentation could not be verified.')
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
)
|
|
213
215
|
|
|
214
216
|
presentation
|
|
215
217
|
.command('output')
|
|
216
218
|
.description('Print W3C Verifiable Presentation to stdout')
|
|
217
219
|
.option('-t, --tag <string>', 'Optional. Specify the tag for the presentation.')
|
|
218
|
-
.action(async (options) => {
|
|
219
|
-
const agent = await getAgent(
|
|
220
|
+
.action(async (options: { tag: string }, cmd: Command) => {
|
|
221
|
+
const agent = await getAgent(cmd.optsWithGlobals().config)
|
|
220
222
|
|
|
221
|
-
const presentations: UniqueVerifiablePresentation[] = await agent.dataStoreORMGetVerifiablePresentations(
|
|
223
|
+
const presentations: UniqueVerifiablePresentation[] = await agent.dataStoreORMGetVerifiablePresentations(
|
|
224
|
+
{},
|
|
225
|
+
)
|
|
222
226
|
|
|
223
227
|
if (presentations.length > 0) {
|
|
224
|
-
|
|
225
228
|
let selected = null
|
|
226
229
|
const list: any = []
|
|
227
230
|
if (options.tag) {
|
|
228
|
-
const matches = presentations.filter(pres => pres.verifiablePresentation.tag === options.tag)
|
|
231
|
+
const matches = presentations.filter((pres) => pres.verifiablePresentation.tag === options.tag)
|
|
229
232
|
if (matches.length > 1) {
|
|
230
233
|
console.log('Found multiple matching presentations. Only showing the first one.')
|
|
231
234
|
}
|
|
@@ -263,3 +266,5 @@ presentation
|
|
|
263
266
|
console.log('No presentations found.')
|
|
264
267
|
}
|
|
265
268
|
})
|
|
269
|
+
|
|
270
|
+
export { presentation }
|
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' }],
|
|
@@ -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/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