Skip to content

Commit

Permalink
appease linter
Browse files Browse the repository at this point in the history
  • Loading branch information
lestrrat committed Oct 27, 2023
1 parent bde608c commit 1645492
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
14 changes: 7 additions & 7 deletions jwk/jwk.go
Original file line number Diff line number Diff line change
Expand Up @@ -759,31 +759,31 @@ func IsPrivateKey(k Key) (bool, error) {
return false, fmt.Errorf("jwk.IsPrivateKey: %T is not an asymmetric key", k)
}

type keyValidationErr struct {
type keyValidationError struct {
err error
}

func (e *keyValidationErr) Error() string {
func (e *keyValidationError) Error() string {
return fmt.Sprintf(`key validation failed: %s`, e.err)
}

func (e *keyValidationErr) Unwrap() error {
func (e *keyValidationError) Unwrap() error {
return e.err
}

func (e *keyValidationErr) Is(target error) bool {
_, ok := target.(*keyValidationErr)
func (e *keyValidationError) Is(target error) bool {
_, ok := target.(*keyValidationError)
return ok
}

// NewKeyValidationError wraps the given error with an error that denotes
// `key.Validate()` has failed. This error type should ONLY be used as
// return value from the `Validate()` method.
func NewKeyValidationError(err error) error {
return &keyValidationErr{err: err}
return &keyValidationError{err: err}
}

func IsKeyValidationError(err error) bool {
var kve keyValidationErr
var kve keyValidationError
return errors.Is(err, &kve)
}
5 changes: 1 addition & 4 deletions jws/jws.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,7 @@ func validateKeyBeforeUse(key interface{}) error {
}
jwkKey = converted
}
if err := jwkKey.Validate(); err != nil {
return err
}
return nil
return jwkKey.Validate()
}

// Sign generates a JWS message for the given payload and returns
Expand Down

0 comments on commit 1645492

Please sign in to comment.