Skip to content

Commit

Permalink
Merge pull request #128 from TBD54566975/kendallw/web5-vc-create-sign
Browse files Browse the repository at this point in the history
Remove redundant CLI argument for vc create --sign
  • Loading branch information
KendallWeihe authored Mar 29, 2024
2 parents 917cd2c + 0b69246 commit bca7db6
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions cmd/web5/cmd_vc_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"encoding/json"
"errors"
"fmt"
"time"

Expand All @@ -18,8 +17,7 @@ type vcCreateCMD struct {
ID string `help:"Override the default ID of format urn:vc:uuid:<uuid>."`
IssuanceDate time.Time `help:"Override the default issuanceDate of time.Now()."`
ExpirationDate time.Time `help:"Override the default expirationDate of nil."`
Sign bool `help:"Sign the VC with the provided --portable-did." default:"false"`
PortableDID string `help:"Portable DID used with --sign. Value is a JSON string."`
Sign string `help:"Portable DID used to sign the VC-JWT. Value is a JSON string."`
NoIndent bool `help:"Print the VC without indentation." default:"false"`
}

Expand Down Expand Up @@ -51,13 +49,9 @@ func (c *vcCreateCMD) Run() error {

credential := vc.Create(claims, opts...)

if c.Sign {
if c.PortableDID == "" {
return errors.New("--portable-did must be provided with --sign")
}

if c.Sign != "" {
var portableDID did.PortableDID
err = json.Unmarshal([]byte(c.PortableDID), &portableDID)
err = json.Unmarshal([]byte(c.Sign), &portableDID)
if err != nil {
return fmt.Errorf("%s: %w", "invalid portable DID", err)
}
Expand Down

0 comments on commit bca7db6

Please sign in to comment.