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

chore: expose didsignjwt.ResolveSigningVM as a helper API #3457

Merged
merged 1 commit into from
Dec 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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