@veramo/cli 4.0.1-unstable.2 → 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.
Files changed (92) hide show
  1. package/bin/veramo.js +1 -1
  2. package/build/cli.d.ts +13 -13
  3. package/build/cli.d.ts.map +1 -1
  4. package/build/cli.js +19 -23
  5. package/build/cli.js.map +1 -1
  6. package/build/config.d.ts +1 -1
  7. package/build/config.d.ts.map +1 -1
  8. package/build/config.js +17 -27
  9. package/build/config.js.map +1 -1
  10. package/build/credential.js +34 -70
  11. package/build/credential.js.map +1 -1
  12. package/build/dev.js +40 -62
  13. package/build/dev.js.map +1 -1
  14. package/build/did.js +70 -84
  15. package/build/did.js.map +1 -1
  16. package/build/discover.js +9 -20
  17. package/build/discover.js.map +1 -1
  18. package/build/execute.js +16 -30
  19. package/build/execute.js.map +1 -1
  20. package/build/explore/credentials.d.ts +1 -1
  21. package/build/explore/credentials.d.ts.map +1 -1
  22. package/build/explore/credentials.js +19 -37
  23. package/build/explore/credentials.js.map +1 -1
  24. package/build/explore/index.js +9 -19
  25. package/build/explore/index.js.map +1 -1
  26. package/build/explore/main.d.ts +1 -1
  27. package/build/explore/main.d.ts.map +1 -1
  28. package/build/explore/main.js +24 -42
  29. package/build/explore/main.js.map +1 -1
  30. package/build/explore/managed-identifiers.d.ts +1 -1
  31. package/build/explore/managed-identifiers.d.ts.map +1 -1
  32. package/build/explore/managed-identifiers.js +14 -32
  33. package/build/explore/managed-identifiers.js.map +1 -1
  34. package/build/explore/messages.d.ts +1 -1
  35. package/build/explore/messages.d.ts.map +1 -1
  36. package/build/explore/messages.js +13 -31
  37. package/build/explore/messages.js.map +1 -1
  38. package/build/explore/presentations.d.ts +1 -1
  39. package/build/explore/presentations.d.ts.map +1 -1
  40. package/build/explore/presentations.js +19 -37
  41. package/build/explore/presentations.js.map +1 -1
  42. package/build/explore/styles.js +1 -4
  43. package/build/explore/styles.js.map +1 -1
  44. package/build/explore/utils.js +8 -17
  45. package/build/explore/utils.js.map +1 -1
  46. package/build/lib/agentCreator.d.ts +1 -1
  47. package/build/lib/agentCreator.d.ts.map +1 -1
  48. package/build/lib/agentCreator.js +3 -7
  49. package/build/lib/agentCreator.js.map +1 -1
  50. package/build/lib/objectCreator.d.ts +1 -1
  51. package/build/lib/objectCreator.d.ts.map +1 -1
  52. package/build/lib/objectCreator.js +22 -29
  53. package/build/lib/objectCreator.js.map +1 -1
  54. package/build/message.js +8 -19
  55. package/build/message.js.map +1 -1
  56. package/build/presentation.js +73 -98
  57. package/build/presentation.js.map +1 -1
  58. package/build/sdr.js +50 -68
  59. package/build/sdr.js.map +1 -1
  60. package/build/server.js +13 -25
  61. package/build/server.js.map +1 -1
  62. package/build/setup.d.ts +1 -2
  63. package/build/setup.d.ts.map +1 -1
  64. package/build/setup.js +8 -17
  65. package/build/setup.js.map +1 -1
  66. package/build/util.js +17 -32
  67. package/build/util.js.map +1 -1
  68. package/build/version.js +6 -5
  69. package/build/version.js.map +1 -1
  70. package/default/default.yml +1 -17
  71. package/package.json +29 -23
  72. package/src/cli.ts +15 -14
  73. package/src/config.ts +6 -5
  74. package/src/credential.ts +8 -8
  75. package/src/dev.ts +7 -3
  76. package/src/did.ts +12 -12
  77. package/src/discover.ts +2 -2
  78. package/src/execute.ts +5 -5
  79. package/src/explore/credentials.ts +3 -3
  80. package/src/explore/index.ts +5 -4
  81. package/src/explore/main.ts +6 -6
  82. package/src/explore/managed-identifiers.ts +3 -3
  83. package/src/explore/messages.ts +3 -3
  84. package/src/explore/presentations.ts +3 -3
  85. package/src/lib/agentCreator.ts +3 -3
  86. package/src/lib/objectCreator.ts +15 -15
  87. package/src/message.ts +3 -3
  88. package/src/presentation.ts +45 -32
  89. package/src/sdr.ts +5 -5
  90. package/src/server.ts +5 -3
  91. package/src/setup.ts +3 -5
  92. package/src/version.ts +4 -2
@@ -1,8 +1,8 @@
1
- import { getAgent } from './setup'
1
+ import { getAgent } from './setup.js'
2
2
  import { program } from 'commander'
3
3
  import inquirer from 'inquirer'
4
4
  import qrcode from 'qrcode-terminal'
5
- import { readStdin } from './util'
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'
@@ -15,7 +15,7 @@ presentation
15
15
  .option('-s, --send', 'Send')
16
16
  .option('-q, --qrcode', 'Show qrcode')
17
17
  .action(async (cmd) => {
18
- const agent = getAgent(program.opts().config)
18
+ const agent = await getAgent(program.opts().config)
19
19
  const myIdentifiers = await agent.didManagerFind()
20
20
  if (myIdentifiers.length === 0) {
21
21
  console.error('No dids')
@@ -32,7 +32,7 @@ presentation
32
32
  ...ids.map((id) => id.did),
33
33
  ]
34
34
 
35
- let aud = null
35
+ let aud:string[] = []
36
36
  const answers = await inquirer.prompt([
37
37
  {
38
38
  type: 'list',
@@ -51,10 +51,10 @@ presentation
51
51
  default: 'xyz123',
52
52
  },
53
53
  {
54
- type: 'list',
55
- name: 'aud',
56
- message: 'Verifier DID',
57
- choices: identifiers,
54
+ type: 'input',
55
+ name: 'audnum',
56
+ message: 'Number of Verifiers',
57
+ default: 1,
58
58
  },
59
59
  {
60
60
  type: 'input',
@@ -64,17 +64,28 @@ presentation
64
64
  },
65
65
  ])
66
66
 
67
- if (answers.aud === 'manual') {
67
+ for (let i = 0; i < answers.audnum; i++) {
68
+ let answer = null
68
69
  const audAnswer = await inquirer.prompt([
69
70
  {
70
- type: 'input',
71
+ type: 'list',
71
72
  name: 'aud',
72
- message: 'Enter Verifier DID',
73
- },
73
+ message: 'Select Verifier or enter manually',
74
+ choices: identifiers
75
+ }
74
76
  ])
75
- aud = audAnswer.aud
76
- } else {
77
- aud = answers.aud
77
+ answer = audAnswer.aud
78
+ if (answer === 'manual') {
79
+ const manualAnswer = await inquirer.prompt([
80
+ {
81
+ type: 'input',
82
+ name: 'aud',
83
+ message: 'Enter Verifier DID',
84
+ },
85
+ ])
86
+ answer = manualAnswer.aud
87
+ }
88
+ aud = [...aud, answer]
78
89
  }
79
90
 
80
91
  const credentials = await agent.dataStoreORMGetVerifiableCredentials({
@@ -122,7 +133,7 @@ presentation
122
133
  save: true,
123
134
  presentation: {
124
135
  holder: answers.iss,
125
- verifier: [aud],
136
+ verifier: aud,
126
137
  tag: answers.tag,
127
138
  '@context': ['https://www.w3.org/2018/credentials/v1'],
128
139
  type: answers.type.split(','),
@@ -133,19 +144,21 @@ presentation
133
144
  })
134
145
 
135
146
  if (cmd.send) {
136
- try {
137
- const message = await agent.sendMessageDIDCommAlpha1({
138
- save: true,
139
- data: {
140
- from: answers.iss,
141
- to: aud,
142
- type: 'jwt',
143
- body: verifiablePresentation.proof.jwt,
144
- },
145
- })
146
- console.dir(message, { depth: 10 })
147
- } catch (e) {
148
- console.error(e)
147
+ for(var verifier in aud) {
148
+ try {
149
+ const message = await agent.sendMessageDIDCommAlpha1({
150
+ save: true,
151
+ data: {
152
+ from: answers.iss,
153
+ to: verifier,
154
+ type: 'jwt',
155
+ body: verifiablePresentation.proof.jwt,
156
+ },
157
+ })
158
+ console.dir(message, { depth: 10 })
159
+ } catch (e) {
160
+ console.error(e)
161
+ }
149
162
  }
150
163
  }
151
164
 
@@ -165,7 +178,7 @@ presentation
165
178
  .option('-f, --filename <string>', 'Optional. Read the presentation from a file instead of stdin')
166
179
  .option('-r, --raw <string>', 'Optional. Presentation as a parameter string instead of a file or stdin.')
167
180
  .action(async (options) => {
168
- const agent = getAgent(program.opts().config)
181
+ const agent = await getAgent(program.opts().config)
169
182
  let raw: string = ''
170
183
  if (options.raw) {
171
184
  raw = options.raw
@@ -202,7 +215,7 @@ presentation
202
215
  .description('Print W3C Verifiable Presentation to stdout')
203
216
  .option('-t, --tag <string>', 'Optional. Specify the tag for the presentation.')
204
217
  .action(async (options) => {
205
- const agent = getAgent(program.opts().config)
218
+ const agent = await getAgent(program.opts().config)
206
219
 
207
220
  const presentations = await agent.dataStoreORMGetVerifiablePresentations({})
208
221
 
@@ -211,7 +224,7 @@ presentation
211
224
  let selected = null
212
225
  const list: any = []
213
226
  if (options.tag) {
214
- const matches = presentations.filter(pres => pres.verifiablePresentation.tag === options.tag)
227
+ const matches = presentations.filter((pres) => pres.verifiablePresentation.tag === options.tag)
215
228
  if (matches.length > 1) {
216
229
  console.log('Found multiple matching presentations. Only showing the first one.')
217
230
  }
package/src/sdr.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import { ICredentialRequestInput } from '@veramo/selective-disclosure'
2
- import { getAgent } from './setup'
2
+ import { getAgent } from './setup.js'
3
3
  import { program } from 'commander'
4
4
  import inquirer from 'inquirer'
5
5
  import qrcode from 'qrcode-terminal'
6
- import { shortDate, shortDid } from './explore/utils'
6
+ import { shortDate, shortDid } from './explore/utils.js'
7
7
  import { VerifiableCredential } from '@veramo/core'
8
8
  import { asArray, extractIssuer } from '@veramo/utils'
9
9
 
10
- const fuzzy = require('fuzzy')
10
+ import fuzzy from 'fuzzy'
11
11
 
12
12
  const sdr = program.command('sdr').description('Selective Disclosure Request')
13
13
 
@@ -15,7 +15,7 @@ sdr
15
15
  .command('create', { isDefault: true })
16
16
  .description('create Selective Disclosure Request')
17
17
  .action(async (cmd) => {
18
- const agent = getAgent(program.opts().config)
18
+ const agent = await getAgent(program.opts().config)
19
19
  const identifiers = await agent.didManagerFind()
20
20
 
21
21
  const knownDids = await agent.dataStoreORMGetIdentifiers()
@@ -265,7 +265,7 @@ sdr
265
265
  .command('respond')
266
266
  .description('respond to Selective Disclosure Request')
267
267
  .action(async (cmd) => {
268
- const agent = getAgent(program.opts().config)
268
+ const agent = await getAgent(program.opts().config)
269
269
  const sdrMessages = await agent.dataStoreORMGetMessages({
270
270
  where: [{ column: 'type', value: ['sdr'] }],
271
271
  order: [{ column: 'createdAt', direction: 'DESC' }],
package/src/server.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import express from 'express'
2
2
  import { program } from 'commander'
3
- import { getConfig } from './setup'
4
- import { createObjects } from './lib/objectCreator'
3
+ import { getConfig } from './setup.js'
4
+ import { createObjects } from './lib/objectCreator.js'
5
5
 
6
6
  program
7
7
  .command('server')
@@ -13,14 +13,16 @@ program
13
13
  let server: any
14
14
 
15
15
  try {
16
- const config = createObjects(getConfig(program.opts().config), { server: '/server' })
16
+ const config = await createObjects(getConfig(program.opts().config), { server: '/server' })
17
17
  server = config.server
18
18
  } catch (e: any) {
19
19
  console.log(e.message)
20
20
  process.exit(1)
21
21
  }
22
22
 
23
+ console.log("server: ", server)
23
24
  for (let router of server.use) {
25
+ console.log("router: ", router)
24
26
  app.use(...router)
25
27
  }
26
28
 
package/src/setup.ts CHANGED
@@ -1,4 +1,3 @@
1
- import 'cross-fetch/polyfill'
2
1
  import yaml from 'yaml'
3
2
  import {
4
3
  ICredentialPlugin,
@@ -13,9 +12,8 @@ import {
13
12
  import { ISelectiveDisclosure } from '@veramo/selective-disclosure'
14
13
  import { IDIDComm } from '@veramo/did-comm'
15
14
  import { IDIDDiscovery } from '@veramo/did-discovery'
16
- import { createAgentFromConfig } from './lib/agentCreator'
17
-
18
- const fs = require('fs')
15
+ import { createAgentFromConfig } from './lib/agentCreator.js'
16
+ import fs from "fs"
19
17
 
20
18
  export const getConfig = (fileName: string): any => {
21
19
  if (!fs.existsSync(fileName)) {
@@ -46,7 +44,7 @@ export type EnabledInterfaces = IDIDManager &
46
44
 
47
45
  export type ConfiguredAgent = TAgent<EnabledInterfaces>
48
46
 
49
- export function getAgent(fileName: string): ConfiguredAgent {
47
+ export async function getAgent(fileName: string): Promise<ConfiguredAgent> {
50
48
  try {
51
49
  return createAgentFromConfig<EnabledInterfaces>(getConfig(fileName))
52
50
  } catch (e: any) {
package/src/version.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { program } from 'commander'
2
-
3
- const { version } = require('../package.json')
2
+ import { createRequire } from "module";
3
+ const require = createRequire(import.meta.url);
4
+ const data = require("../package.json");
5
+ const { version } = data
4
6
 
5
7
  program.version(version, '-v, --version')