Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update JWX lib to use v2 #308

Merged
merged 11 commits into from
Mar 20, 2023
Merged

Update JWX lib to use v2 #308

merged 11 commits into from
Mar 20, 2023

Conversation

decentralgabe
Copy link
Member

No description provided.

@decentralgabe decentralgabe marked this pull request as ready for review March 19, 2023 06:40
@decentralgabe decentralgabe mentioned this pull request Mar 19, 2023
@codecov-commenter
Copy link

codecov-commenter commented Mar 19, 2023

Codecov Report

Merging #308 (5b0208e) into main (8d95593) will decrease coverage by 2.25%.
The diff coverage is 30.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #308      +/-   ##
==========================================
- Coverage   60.93%   58.68%   -2.25%     
==========================================
  Files          42       42              
  Lines        4651     4717      +66     
==========================================
- Hits         2834     2768      -66     
- Misses       1367     1462      +95     
- Partials      450      487      +37     
Impacted Files Coverage Δ
crypto/keys.go 83.51% <ø> (ø)
credential/signing/jwt.go 32.91% <18.18%> (ø)
crypto/jwk.go 44.29% <28.64%> (-29.17%) ⬇️
credential/signing/jws.go 51.35% <33.33%> (ø)
crypto/jwt.go 46.15% <43.48%> (-2.35%) ⬇️
credential/exchange/request.go 44.44% <50.00%> (ø)
cryptosuite/jsonwebkey2020.go 46.15% <66.67%> (-0.37%) ⬇️
did/key.go 72.87% <100.00%> (ø)

andresuribe87 and others added 7 commits March 19, 2023 00:23
* Add simple URL for parsing strings.

* Add credential issuer metadata for oidc.

* Make the linter happy

* PR feedback

* Finish comment

* More PR comments

* Even More PR comments

* Enforce unique CredentialsSupported.ID

ion models

long form did and initial request
* Added style and best practices

* nits

deactivate request

update request

recover

lint

test not passing

fix test

fix reveal value; update test

temp
Comment on lines +79 to +85
func JWKFromPublicKeyJWK(key PublicKeyJWK) (jwk.Key, error) {
keyBytes, err := json.Marshal(key)
if err != nil {
return nil, err
}
return jwk.ParseKey(keyBytes)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why the PublicKeyJWK and PrivateKeyJWK structs are needed in the SDK?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useful to have full object model representations of each key type - especially when there's a need to construct these directly from signature suite test vectors

Copy link
Member Author

@decentralgabe decentralgabe Mar 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mostly usage was from JsonWebKey2020 but it may be worth seeing if we can change it all to jwx.Key in a follow up

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created #309


rsaJWKBytes, err := json.Marshal(rsaJWK)
if err != nil {
return nil, nil, errors.Wrap(err, "failed to marshal rsa jwk")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and elsewhere. When wrapping, the failure will be evident by the root errors.

Suggested change
return nil, nil, errors.Wrap(err, "failed to marshal rsa jwk")
return nil, nil, errors.Wrap(err, "marshaling rsa jwk")

Copy link
Contributor

@andresuribe87 andresuribe87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tiny nit

crypto/jwk.go Outdated
}
rsaJWK, ok := rsaJWKGeneric.(jwk.RSAPrivateKey)
if !ok {
return nil, nil, errors.New("casting rsa jwk")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For root cause errors, it's reasonable to include what you cannot do, or what exactly failed.

Suggested change
return nil, nil, errors.New("casting rsa jwk")
return nil, nil, errors.New("cannot cast to rsa jwk")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, d'oh!

@decentralgabe decentralgabe merged commit 55e0c31 into main Mar 20, 2023
@decentralgabe decentralgabe deleted the jwx-v2 branch March 20, 2023 17:17
decentralgabe added a commit that referenced this pull request Mar 20, 2023
* main:
  Bump github.com/goccy/go-json from 0.10.0 to 0.10.2 (#310)
  Bump golang.org/x/term from 0.5.0 to 0.6.0 (#299)
  Update JWX lib to use v2 (#308)

# Conflicts:
#	credential/signing/jws.go
#	credential/signing/jwt.go
#	crypto/jwk_test.go
#	crypto/jwt.go
#	go.mod
#	go.sum
#	wasm/static/main.wasm
decentralgabe added a commit that referenced this pull request Mar 21, 2023
* origin/main:
  Bump github.com/multiformats/go-multibase from 0.1.1 to 0.2.0 (#313)
  Bump github.com/go-playground/validator/v10 from 10.11.2 to 10.12.0 (#311)
  Bump github.com/goccy/go-json from 0.10.0 to 0.10.2 (#310)
  Bump golang.org/x/term from 0.5.0 to 0.6.0 (#299)
  Update JWX lib to use v2 (#308)
  Added style and best practices (#298)
  Add models for Credential Issuer Metadata (#304)
  Upgrade go version to 1.20.2 (#305)
  add missing param (#297)
  interface to any (#296)

# Conflicts:
#	cryptosuite/cryptosuite.go
#	cryptosuite/jsonwebkey2020.go
#	cryptosuite/jwssignaturesuite.go
#	cryptosuite/jwssignaturesuite_test.go
#	go.mod
#	go.sum
#	util/helpers.go
#	wasm/static/main.wasm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants