From dd41b17aa970c2d751cb426197f975abc04cb41c Mon Sep 17 00:00:00 2001 From: gabe Date: Tue, 18 Oct 2022 12:41:08 -0700 Subject: [PATCH 1/2] set iss property in jwts --- credential/exchange/submission.go | 2 +- credential/verification/verification_test.go | 2 +- crypto/jwt.go | 10 +++++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/credential/exchange/submission.go b/credential/exchange/submission.go index f1b84d0a..8cf61ea7 100644 --- a/credential/exchange/submission.go +++ b/credential/exchange/submission.go @@ -454,7 +454,7 @@ func normalizeJSONPartPath(partPath string) string { } func normalizeJSONPath(path string) string { - pathRegex := regexp.MustCompile(`\[.*\]`) + pathRegex := regexp.MustCompile(`\[.*]`) return pathRegex.ReplaceAllString(path, "") } diff --git a/credential/verification/verification_test.go b/credential/verification/verification_test.go index 457aa528..c47045ca 100644 --- a/credential/verification/verification_test.go +++ b/credential/verification/verification_test.go @@ -130,7 +130,7 @@ func getVCJSONSchema() string { "author": "did:example:MDP8AsFhHzhwUvGNuYkX7T", "authored": "2021-01-01T00:00:00+00:00", "schema": { - "$id": "email-schema-1.0", + "$id": "email-schema-1.0", "$schema": "https://json-schema.org/draft/2019-09/schema", "description": "Email", "type": "object", diff --git a/crypto/jwt.go b/crypto/jwt.go index 3d31fa80..03a818ae 100644 --- a/crypto/jwt.go +++ b/crypto/jwt.go @@ -67,10 +67,14 @@ func jwtSignerVerifier(kid string, key interface{}) (jwk.Key, *jwa.SignatureAlgo if err != nil { return nil, nil, errors.Wrap(err, "could not get verification alg from jwk") } - if err := parsedKey.Set(jwk.KeyIDKey, kid); err != nil { + // TODO(gabe) distinguish between issuer and kid + if err = parsedKey.Set(jwt.IssuerKey, kid); err != nil { return nil, nil, fmt.Errorf("could not set kid with provided value: %s", kid) } - if err := parsedKey.Set(jwk.AlgorithmKey, alg); err != nil { + if err = parsedKey.Set(jwk.KeyIDKey, kid); err != nil { + return nil, nil, fmt.Errorf("could not set kid with provided value: %s", kid) + } + if err = parsedKey.Set(jwk.AlgorithmKey, alg); err != nil { return nil, nil, fmt.Errorf("could not set alg with value: %s", alg) } return parsedKey, &alg, nil @@ -86,7 +90,7 @@ func (sv *JWTSigner) SignJWT(kvs map[string]interface{}) ([]byte, error) { t := jwt.New() for k, v := range kvs { if err := t.Set(k, v); err != nil { - err := errors.Wrapf(err, "could not set %s to value: %v", k, v) + err = errors.Wrapf(err, "could not set %s to value: %v", k, v) logrus.WithError(err).Error("could not sign JWT") return nil, err } From 26ee6254fe07a87b87d0f38ba9f6783882e28169 Mon Sep 17 00:00:00 2001 From: gabe Date: Tue, 18 Oct 2022 12:42:41 -0700 Subject: [PATCH 2/2] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 00cdb066..f43b697e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ [![godoc ssi-sdk](https://img.shields.io/badge/godoc-ssi--sdk-blue)](https://pkg.go.dev/github.com/TBD54566975/ssi-sdk) -[![go version 1.17.6](https://img.shields.io/badge/go_version-1.17.6-brightgreen)](https://golang.org/) +[![go version 1.19.2](https://img.shields.io/badge/go_version-1.19.2-brightgreen)](https://golang.org/) [![Go Report Card A+](https://goreportcard.com/badge/github.com/TBD54566975/ssi-sdk)](https://goreportcard.com/report/github.com/TBD54566975/ssi-sdk) [![license Apache 2](https://img.shields.io/badge/license-Apache%202-black)](https://github.com/TBD54566975/ssi-sdk/blob/main/LICENSE) [![issues](https://img.shields.io/github/issues/TBD54566975/ssi-sdk)](https://github.com/TBD54566975/ssi-sdk/issues)