Skip to content

Commit

Permalink
Merge pull request #75 from MicahParks/given_keys_from_json_edits
Browse files Browse the repository at this point in the history
Edit typo and struct literal in NewGivenKeysFromJSON
  • Loading branch information
MicahParks committed Nov 30, 2022
2 parents 8c0f8a9 + ac8e1c0 commit cea8844
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions given.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ func NewGivenRSACustomWithOptions(key *rsa.PublicKey, options GivenKeyOptions) (
}
}

// NewGivenKeysFromJSON parses a raw JSON message into a map of key IDs (`kid`) to GivenKeys.
// The returned map is suitable for suitable for passing to `NewGiven()` or as `Options.GivenKeys` to `Get()`
// NewGivenKeysFromJSON parses a raw JSON message into a map of key IDs (`kid`) to GivenKeys. The returned map is
// suitable for passing to `NewGiven()` or as `Options.GivenKeys` to `Get()`
func NewGivenKeysFromJSON(jwksBytes json.RawMessage) (map[string]GivenKey, error) {
// Parse by making a temporary JWKS instance. No need to lock its map since it doesn't escape this function.
j, err := NewJSON(jwksBytes)
Expand All @@ -160,7 +160,10 @@ func NewGivenKeysFromJSON(jwksBytes json.RawMessage) (map[string]GivenKey, error
}
keys := make(map[string]GivenKey, len(j.keys))
for kid, cryptoKey := range j.keys {
keys[kid] = NewGivenCustomWithOptions(cryptoKey.public, GivenKeyOptions{Algorithm: cryptoKey.algorithm})
keys[kid] = GivenKey{
algorithm: cryptoKey.algorithm,
inter: cryptoKey.public,
}
}
return keys, nil
}

0 comments on commit cea8844

Please sign in to comment.