Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
chore: expose didsignjwt.ResolveSigningVM as a helper API (#3457)
Browse files Browse the repository at this point in the history
Signed-off-by: Filip Burlacu <filip.burlacu@securekey.com>

Signed-off-by: Filip Burlacu <filip.burlacu@securekey.com>
  • Loading branch information
Moopli committed Dec 23, 2022
1 parent 68ce807 commit 6d96423
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pkg/doc/util/didsignjwt/signjwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func SignJWT( // nolint: funlen,gocyclo
signerProvider SignerGetter,
didResolver didResolver,
) (string, error) {
vm, vmID, err := resolveSigningVM(kid, didResolver)
vm, vmID, err := ResolveSigningVM(kid, didResolver)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -166,7 +166,15 @@ func VerifyJWT(compactJWT string,
return nil
}

func resolveSigningVM(kid string, didResolver didResolver) (*did.VerificationMethod, string, error) {
// ResolveSigningVM resolves a DID KeyID using the given did resolver, and returns either:
//
// - the Verification Method identified by the given key ID, or
// - the first Assertion Method in the DID doc, if the DID provided has no fragment component.
//
// Returns:
// - a verification method suitable for signing.
// - the full DID#KID identifier of the returned verification method.
func ResolveSigningVM(kid string, didResolver didResolver) (*did.VerificationMethod, string, error) {
vmSplit := strings.Split(kid, "#")

if len(vmSplit) > vmSectionCount {
Expand Down

0 comments on commit 6d96423

Please sign in to comment.