Skip to content

Commit

Permalink
feat: cli identity management improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
simonas-notcat committed Nov 14, 2019
1 parent 3b79989 commit 489b5e9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
8 changes: 4 additions & 4 deletions packages/daf-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ Manage identities
Options:
-l, --list List managed identities
-t, --types List available identity controller types
-c, --create <type> Create identity using <type> identity controller
-d, --delete <did> Delete identity
-c, --create Create identity
-d, --delete Delete identity
-h, --help output usage information
```
### W3C Credentials
Expand Down Expand Up @@ -63,12 +63,12 @@ daf listen

Send:
```
DAF_TG_URI=https://mouro.eu.ngrok.io/graphql daf credential -c -s
DAF_TG_URI=https://custom-tge.eu.ngrok.io/graphql daf credential -c -s
```

Receive:
```
DEBUG=* DAF_TG_URI=https://mouro.eu.ngrok.io/graphql DAF_TG_WSURI=wss://mouro.eu.ngrok.io/graphql daf listen
DEBUG=* DAF_TG_URI=https://custom-tge.eu.ngrok.io/graphql DAF_TG_WSURI=wss://custom-tge.eu.ngrok.io/graphql daf listen
```

### DID Document resolver
Expand Down
28 changes: 24 additions & 4 deletions packages/daf-cli/src/identity-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ program
.description('Manage identities')
.option('-l, --list', 'List managed identities')
.option('-t, --types', 'List available identity controller types')
.option('-c, --create <type>', 'Create identity using <type> identity controller')
.option('-d, --delete <did>', 'Delete identity')
.option('-c, --create', 'Create identity')
.option('-d, --delete', 'Delete identity')
.action(async (cmd) => {
if (cmd.types) {
const list = await core.identityManager.listTypes()
Expand All @@ -36,7 +36,17 @@ program

if (cmd.create) {
try {
const did = await core.identityManager.create(cmd.create)
const types = await core.identityManager.listTypes()

const answers = await inquirer.prompt([
{
type: 'list',
name: 'type',
choices: types,
message: 'Select identity controller'
},
])
const did = await core.identityManager.create(answers.type)
printTable([{ type: cmd.create, did }])

} catch (e) {
Expand All @@ -46,8 +56,18 @@ program

if (cmd.delete) {
try {
const myDids = await core.identityManager.listDids()
const answers = await inquirer.prompt([
{
type: 'list',
name: 'did',
choices: myDids,
message: 'Delete DID'
},
])

const issuers = await core.identityManager.listIssuers()
const issuer = issuers.find(item => item.did === cmd.delete)
const issuer = issuers.find(item => item.did === answers.did)
if (issuer) {
const result = await core.identityManager.delete(issuer.type, issuer.did)
console.log('Success:', result)
Expand Down

0 comments on commit 489b5e9

Please sign in to comment.