GithubHelp home page GithubHelp logo

did-cli's Introduction

Decentralized Identifier client CLI (did-cli)

A command-line client for managing Decentralized Identifiers.

Quickstart

The current client supports the creation of Testnet DIDs on the Veres One ledger as well as the retrieval of those DIDs from the Testnet. You can try the tool out by doing the following commands on a system that has node.js installed:

npm install did-cli
cd node_modules/did-cli
./did generate -r

To retrieve the freshly generated DID:

./did info <DID>

By default, keys and DID Documents will be stored in ~/.dids/<method>/<mode>/, see Setting Up Storage for more details.

Installation

Requirements

  • Linux or Mac OS X
  • Node.js >= 8.6.x
  • npm >= 3.x

Install

Install in a development directory:

npm install did-cli
./node_modules/.bin/did ...

Install globally:

npm install -g did-cli
did ...

Run from npx:

npx did-cli ...

Developing

To download the source and install the client:

git clone https://github.com/digitalbazaar/did-cli.git
cd did-cli
npm install
./did ...

Usage

General

The did command has many commands and options. Help is available with the --help/-h command line option:

did -h
did COMMAND -h

Commands can be more verbose with one ore more --verbose/-v options, or quieted more than the default with --quiet/-q:

did COMMAND -v ...
did COMMAND -vv ...
did COMMAND -q ...

Copies of registered DIDs, keys, and metadata are all stored in your $HOME/.dids/ directory.

Remote commands operate on a ledger. Various ledgers may be available. They can be selected with the --ledger/-l option which defaults to veres.

did COMMAND -l LEDGER ...

Remote ledger commands also have a "live", "test", or "dev" mode selected with --mode/-m which defaults to test:

did COMMAND -m MODE ...

The combination of ledger and mode options will select the default hostnames to connect to. Specific hostnames can be selected with --hostname/-H:

did COMMAND -l example -m test -H host1.example.com ...

Generate a DID

A DID is generated locally with the generate command:

did generate

Other options:

  • --passphrase/-p PASSPHRASE: set a key passphrase
  • --type/-t TYPE: set key type (ex: ed25519 or rsa)
  • --name NAME: set a private name note
  • --description DESCRIPTION: set a private description note
  • --register/-r: register on a ledger

Register on a Ledger

By default generate will only store a DID locally. If you want to also immediately register it to the default Veres One testnet ledger:

did generate -r

You can register local DIDs to a ledger with the register command:

did register DID

Some ledgers may require DID authorization (this topic is outside of the scope of this tool). You can specify an authorization DID key with --auth/-a:

did register DID -a AUTHDID

Some ledgers may require proof-of-work to accept a DID request. Others may allow "accelerators" to be used. These are specified with --accelerator/-A and require an authorization DID:

did register DID -a AUTHDID -A ACCELERATORHOSTNAME

DID Information

Pending (created but not registered) and registered DIDs can be listed with the list command:

did list

Information on a DID can be found with the info command:

did info DID

Notes

It can be useful to store private local notes about DIDs which are otherwise somewhat opaque identifiers. The notes command adds this ability with simple key/value pairs.

All notes for all DIDs can be shown with:

did notes

Notes for specific DID can be shown:

did notes DID

Various notes operations are available:

  • --clear: remove all notes
  • --add KEY VALUE: append VALUE to an array for KEY
  • --remove: remove VALUE from array for KEY
  • --get KEY: get KEY value
  • --set KEY VALUE: set single VALUE for KEY
  • --delete: delete all values for KEY
  • --find KEY VALUE: find DIDs with VALUE set for KEY

If a DID is not specified the commands will operate on all DIDs. As this can be dangerous, any operation with operates on many DIDs must use the --all option.

did notes --delete old-property --all

You can choose any KEY values you wish, although simple strings will be easiest to use. The generate and register commands have an "auto" feature to write some notes. The "name" note is useful to assign simple names to DIDs. The "ledger" note is useful to keep track of where DIDs have been sent.

$ did notes did:example:test:1234 --set name shortname
$ did notes did:example:test:1234 --get name
did:example:test:1234 name
$ did notes --find name shortname
did:example:test:1234

$ did notes did:example:test:A --add url https://example.com/
$ did notes did:example:test:B --add url https://example.com/
$ did notes did:example:test:C --add url https://example.org/
$ did notes --find url https://example.com/
did:example:test:A
did:example:test:B
$ did notes --get url
did:example:test:A url https://example.com/
did:example:test:B url https://example.com/
did:example:test:C url https://example.org/

The notes data is stored in the config.jsonld file in your local DID dir. It can be freely edited as needed. Warning: This file is not currently safe to write to concurrently!

Key Management

A DID has a number of application suite parameters that can store keys. Keys are managed with the with the authn-* commands. To inspect the keys use info:

# show the DID JSON including keys
did info did:example:1234

# show more readable summary
did info did:example:1234 -f human

# show summary with public keys
did info did:example:1234 -f human --public-key

# show local summary with private keys
did info did:example:1234 -f human -L local --private-key

Key material can be added with ed25519-key-add. A unique cryptonym key id will be generated. Note that the updates will be automatically registered on the ledger unless --no-register is provided:

# add a public and private key
did ed25519-key-add did:example:1234 -p authentication --pub PUBLICKEYINFO \
--pvt PRIVATEKEYINFO

Examples

Basic generate and check DID is on ledger:

# generate and register on ledger
did generate -r # generate and register on ledger
# wait a few moments
# ...
did info DID

More extreme checking if ledger has details of multiple hosts. As of this writing, Veres One has multiple testnet hosts hardcoded, but you can specify your own with multiple -H options:

# generate and register on ledger
did generate -r # generate and register to ledger
did info DID

Depending on the ledger, you may be able to see consensus happening after a generate:

# start a retry loop, see info --help for other options
did info DID -f found -L all --retry

Use an accelerator to register a DID faster. This assumes you have registered did:ex:my-did at the accelerator:

did generate -r -a did:ex:test:my-did -A accelerator.example.com

Split creation and later register to multiple ledgers (because you are an expert and have solid reasons for doing this):

# generate with a private name, do not register
did generate --name my-did
# ... time passes
# ...
# ... grrr, I forgot the long DID name
did list
... many many DIDs ...
# hmm... lots of random DID names, which one is it?
did notes --get name
... many other DIDs with names ...
did:example:test:1234 name my-did
# ah! there it is!
# register on a ledger
did register did:example:test:1234
# i'd like to use on other ledgers too
did register -H ledger2.example.com did:example:test:1234

Show which DIDs have a note about being on a ledger:

did notes --get ledger

Tips and tricks:

# reload DIDs on a dev ledger after a wipe
did notes --find ledger veres:dev | xargs -I {} did register -m dev {}
# alternative
for d in `did notes --find ledger veres:dev`; do did register -m dev $did; done

Roadmap

There are plans to support the following other commands and features:

  • Rotating authentication credentials
  • Adding and removing authorization capability descriptions
  • Adding and removing service descriptions
  • Checking the validity of a DID (deep blockchain check)

Support

Bugs, suggestions, requests, and code issues:

Commercial support is available upon request from Digital Bazaar:

did-cli's People

Contributors

cwebber avatar davidlehn avatar dlongley avatar dmitrizagidulin avatar gannan08 avatar mattcollier avatar msporny avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

did-cli's Issues

#update-to-latest `did list` does not work

on commit fad5129

Error: "undefined" ledger not supported
    at _runLedgerCommand (/home/matt/dev/did-cli/did:655:13)
    at Object.handler (/home/matt/dev/did-cli/did:274:13)
    at Object.runCommand (/home/matt/dev/did-cli/node_modules/yargs/lib/command.js:237:40)
    at Object.parseArgs [as _parseArgs] (/home/matt/dev/did-cli/node_modules/yargs/yargs.js:1090:30)
    at Function.get [as argv] (/home/matt/dev/did-cli/node_modules/yargs/yargs.js:1024:21)
    at Object.<anonymous> (/home/matt/dev/did-cli/did:645:7)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)

HTTP API, SDKs and DID Documents (Questions)

Hello,

  1. I think I saw in the docs that V1 plans to expose a REST style interface for DID creation etc, how far away is this?
  2. Do you plan to create this project as an importable SDK for use in node apps?
  3. Finally, why is it not possible to generate DID Docs using this client?

Sorry about all the questions!
Thanks.
D

npm install failing - code ELIFECYCLE

Hello,
I am trying to use npm to install the did-client.
The build is failing with code ELIFECYCLE
I am using node v6.9.4 and npm v4.1.1 on MacOSX.
The full error is shown below:

1 error generated.
make: *** [Release/obj.target/urdna2015/lib/native/IdentifierIssuer.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Darwin 17.4.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/dennisy/node_modules/rdf-canonize
gyp ERR! node -v v6.9.4
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok 
/Users/dennisy
├─┬ [email protected] 
│ ├── [email protected] 
│ └── [email protected] 
├── [email protected] 
├── [email protected] 
├─┬ [email protected] 
│ ├── [email protected] 
│ ├─┬ [email protected] 
│ │ └─┬ [email protected] 
│ │   └── [email protected] 
│ └── [email protected] 
├─┬ [email protected] 
│ └── [email protected] 
└── [email protected] 

npm WARN enoent ENOENT: no such file or directory, open '/Users/dennisy/package.json'
npm WARN [email protected] requires a peer of jsonld@^1.0.1 but none was installed.
npm WARN dennisy No description
npm WARN dennisy No repository field.
npm WARN dennisy No README data
npm WARN dennisy No license field.
npm ERR! Darwin 17.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "did-client"
npm ERR! node v6.9.4
npm ERR! npm  v4.1.1
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the rdf-canonize package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs rdf-canonize
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls rdf-canonize
npm ERR! There is likely additional logging output above.

Thanks in advance.

did key type generation is not supported

Expected Behavior

generate a key with did:key method by calling
./did generate -t key

Current Behavior

cli returns an error: Error: "key" DID type not supported

Possible Solution

  1. add support for key method
    OR
  2. explain in README that key method is not currently supported
    OR
  3. remove -t flag

Steps to Reproduce

  1. ./did generate -h
  2. -t --type flag implies ability to select between veres and key
  3. ./did generate -t key

#update-to-latest `did info` does not work

Using fad5129

./did info did:v1:nym:z6MkpAjEyWmJBWNpfX4bnZSFZGToEK5nxChS3vGQrwvD4kQM -H vop1.digitalbazaar.com
ReferenceError: _getHostnames is not defined
    at api.info (/home/matt/dev/did-cli/lib/drivers/veres/index.js:303:5)
    at _runLedgerCommand (/home/matt/dev/did-cli/did:665:5)
    at Object.handler (/home/matt/dev/did-cli/did:427:13)
    at Object.runCommand (/home/matt/dev/did-cli/node_modules/yargs/lib/command.js:237:40)
    at Object.parseArgs [as _parseArgs] (/home/matt/dev/did-cli/node_modules/yargs/yargs.js:1090:30)
    at Function.get [as argv] (/home/matt/dev/did-cli/node_modules/yargs/yargs.js:1024:21)
    at Object.<anonymous> (/home/matt/dev/did-cli/did:645:7)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)

DID registration fails on v.0.3.1

I wanted to test out the veres-one test network as described on your website: https://veres.one/developers/guides/create-did/

First of all the described procedure to install the client hasn't worked for me.
Running npm install did-client produced the following output:

npm ERR! code 1
npm ERR! Command failed: /usr/bin/git checkout implementation
npm ERR! error: pathspec 'implementation' did not match any file(s) known to git
npm ERR! 

After some research I found this repository and I hope, this is the right place to get a DID client for the veres one test network 🙂

Unfortunately, I was not able to register my own DID.
After changing the did-veres-one-dependency to point to the master-branch to get the project successfully installed (via npm install), the command ./did generate -r returned a TypeError in the veres.js-script (see log output below).
I was not able to fix this issue myself.

Environment:

  • OS: Linux 4.18.0-10-generic x86_64 (Kubuntu 18.10)
  • npm version: 6.4.1
  • node.js version: 8.11.4
  • git version: 2.19.1
  • make: GNU Make 4.2.1
  • cmake version: 3.12.1
  • gcc: gcc (Ubuntu 8.2.0-7ubuntu1) 8.2.0

Steps to reproduce

  • Clone repository and checkout v0.3.1 tag
  • See following commands:
> /m/s/D/S/D/P/v/did-client > ⌂ v0.3.1 * > git status
HEAD detached at v0.3.1
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   package.json

no changes added to commit (use "git add" and/or "git commit -a")

> /m/s/D/S/D/P/v/did-client > ⌂ v0.3.1 * > git diff package.json
diff --git a/package.json b/package.json
index df3bbe7..6c77bab 100644
--- a/package.json
+++ b/package.json
@@ -22,7 +22,7 @@
   "dependencies": {
     "chalk": "^2.3.1",
     "did-client-veres-one": "veres-one/did-client-veres-one#implementation",
-    "did-veres-one": "veres-one/did-veres-one#implementation",
+    "did-veres-one": "veres-one/did-veres-one#master",
     "equihash-signature": "digitalbazaar/equihash-signature#master",
     "fs-extra": "^5.0.0",
     "get-stdin": "^5.0.1",

> /m/s/D/S/D/P/v/did-client > ⌂ v0.3.1 * > ./did generate --name "first" --description "First test DID generation" --register
[Veres One][test] Generating a new Veres One DID...
[Veres One][test] Generating keypair... (5-15 seconds)
[Veres One][test] DID: did:v1:test:nym:z279wo8Mnmw4QEcqnShPjzw5irCnAjqcUqcgXRGtydUdLtv2
[Veres One][test] Storing DID Document on disk...
[Veres One][test] DID Document stored in: <$HOME>/.testdid/did-v1-test-nym-z279wo8Mnmw4QEcqnShPjzw5irCnAjqcUqcgXRGtydUdLtv2.jsonld
[Veres One][test] Local DID generation successful.
[Veres One][test] Preparing to register a DID on Veres One...
[Veres One][test] Generating Equihash proof of work... (60-120 seconds)
TypeError: Cannot read property '0' of undefined
    at _send (/m/s/D/S/D/P/v/did-client/lib/drivers/veres.js:209:47)
    at <anonymous>

> /m/s/D/S/D/P/v/did-client > ⌂ v0.3.1 * > ./did list
did:v1:test:nym:z279wo8Mnmw4QEcqnShPjzw5irCnAjqcUqcgXRGtydUdLtv2

> /m/s/D/S/D/P/v/did-client > ⌂ v0.3.1 * > ./did register did:v1:test:nym:z279wo8Mnmw4QEcqnShPjzw5irCnAjqcUqcgXRGtydUdLtv2
[Veres One][test] Preparing to register a DID on Veres One...
[Veres One][test] Generating Equihash proof of work... (60-120 seconds)
TypeError: Cannot read property '0' of undefined
    at _send (/m/s/D/S/D/P/v/did-client/lib/drivers/veres.js:209:47)
    at <anonymous>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.