ssi-sdk icon indicating copy to clipboard operation
ssi-sdk copied to clipboard

added cli tool

Open andorsk opened this issue 1 year ago • 10 comments

added a cli tool for creating did keys. Supported in this PR is just two simple functions.

Getting the key types with:

go run cli.go get key types
[Ed25519 X25519 secp256k1 P-224 P-256 P-384 P-521 RSA]

and creating a did:key:

go run cli.go create key
Generated DID Key:
did:key:z6MknCyPKLhv92CoHZsqJF1XHE6fchHKJfoqh26GAsCwUewD

There is purposely limited scope here, with the idea that future PR's will expand out various features as needed. Exposes IsSupportedKeyType for cli access and uses "github.com/urfave/cli/v2" for generating the cli tool.

andorsk avatar Sep 06 '22 22:09 andorsk

Codecov Report

Merging #183 (248009e) into main (c8caffd) will not change coverage. The diff coverage is 20.00%.

@@           Coverage Diff           @@
##             main     #183   +/-   ##
=======================================
  Coverage   55.16%   55.16%           
=======================================
  Files          40       40           
  Lines        4374     4374           
=======================================
  Hits         2413     2413           
  Misses       1565     1565           
  Partials      396      396           
Impacted Files Coverage Δ
did/peer.go 55.89% <0.00%> (ø)
did/util.go 37.50% <0.00%> (ø)
did/key.go 48.36% <33.33%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov-commenter avatar Sep 06 '22 22:09 codecov-commenter

Nice, great start.

I've never heard of urface/cli but I see it has a lot of usage! Most of my familiarity is with cobra (love/hate). I'd like us to consider the tradeoffs with these too and maybe some others before proceeding. Once we commit to an approach I want to be confident it'll carry us a long way.

I will try to write up my (brief) thoughts soon, but eager to hear what you think.

decentralgabe avatar Sep 06 '22 23:09 decentralgabe

Honestly haha 🤷 !!! I don't know enough about the tradeoff's between urface/cli vs. cobra. I'd imagine there are some edge cases that one does better than the other, but for the general use case they both seem fine.

https://zerokspot.com/weblog/2021/01/25/building-a-cli-using-urfave-cli/ https://mt165.co.uk/blog/golang-cli-library/

Seems like urface/cli is more lightweight but less features? So I guess how bigs the scope of this cli tool? If it's simple, probably cli otherwise if this is going to be very large cobra?

andorsk avatar Sep 06 '22 23:09 andorsk

@decentralgabe thanks for the feedback! Added a few comments. Depending on where we land with some of these thoughts I'll address them accordingly and send a new review request. Sounds like we aren't super off at least.

andorsk avatar Sep 06 '22 23:09 andorsk

I love the effort and this will be needed in the very near future. I think we should hold this pr for now and create a design doc that incorporates all the options necessary to spec out what this would look like.

I say this to make sure that it wont get messy later on.

Some initial thoughts on what should be included in the design doc:

  • create dids with different methods (key,pkh,web,...)
  • functionality to see if an input did is valid or not
  • resolve vs expand functionality
  • support for special key functionality for different key methods

Eventually this CLI will be used for not just DIDS but everything from creating credential manifests, applications, vp and adding these dids to them.

Getting a clearer picture of how all components will tie together in the cli will be helpful.

nitro-neal avatar Sep 07 '22 16:09 nitro-neal

@nitro-neal great idea. There is an issue open right now to discuss this https://github.com/TBD54566975/ssi-sdk/issues/150 but it hasn't gotten much action. I'm happy to iterate on a design doc with others, and then build out the initial PR to submit it to the repo. What do you think?

andorsk avatar Sep 07 '22 16:09 andorsk

Yea! Maybe a good first pass would to update the readme (or make a doc.md in the same directory) to be more full featured kind of showing how it would look in finality with all did functionality and other entities and how a did would be used on those other entities.

We do a formal process for the SSI-Service for inspiration: https://github.com/TBD54566975/ssi-service/tree/main/sip/sips/sip_2

Definitely doesn't have to be as formal or heavy but something that shows the complete picture.

nitro-neal avatar Sep 07 '22 17:09 nitro-neal

Yea...good idea. I can take that.

andorsk avatar Sep 07 '22 17:09 andorsk

Started outlining a document here: https://github.com/TBD54566975/ssi-sdk/pull/185 but have some work to do before it's ready to review.

andorsk avatar Sep 07 '22 17:09 andorsk

putting this on draft until #185 is finished and accepted.

andorsk avatar Sep 08 '22 17:09 andorsk