-
-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* jws.Sign / jws.Verify * edit jws/BUILD.bazel * jws.Parse * SplitXXXX functions * tweak * get the type / var name correct * jwt.ParseXXX * tweak jwt error * jwt validation * Tweak jwt/BUILD.bazel * Update changes * fix issuer error * remove unused type * fix error message * Update changes * jwk.Parse * Add t.Parallel * jwe.ParseXXX, jwe.Decrypt, jwe.Encrypt * Add missing file * Add to BUILD.bazel * Update Changes * Remove IsContinueError --------- Co-authored-by: Daisuke Maki <lestrrat+github@users.noreplay.github.com>
- Loading branch information
Showing
24 changed files
with
921 additions
and
386 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package jwe | ||
|
||
import "errors" | ||
|
||
type encryptError struct { | ||
error | ||
} | ||
|
||
func (e encryptError) Unwrap() error { | ||
return e.error | ||
} | ||
|
||
func (encryptError) Is(err error) bool { | ||
_, ok := err.(encryptError) | ||
return ok | ||
} | ||
|
||
var errDefaultEncryptError = encryptError{errors.New(`encrypt error`)} | ||
|
||
// EncryptError returns an error that can be passed to `errors.Is` to check if the error is an error returned by `jwe.Encrypt`. | ||
func EncryptError() error { | ||
return errDefaultEncryptError | ||
} | ||
|
||
type decryptError struct { | ||
error | ||
} | ||
|
||
func (e decryptError) Unwrap() error { | ||
return e.error | ||
} | ||
|
||
func (decryptError) Is(err error) bool { | ||
_, ok := err.(decryptError) | ||
return ok | ||
} | ||
|
||
var errDefaultDecryptError = decryptError{errors.New(`decrypt error`)} | ||
|
||
// DecryptError returns an error that can be passed to `errors.Is` to check if the error is an error returned by `jwe.Decrypt`. | ||
func DecryptError() error { | ||
return errDefaultDecryptError | ||
} | ||
|
||
type recipientError struct { | ||
error | ||
} | ||
|
||
func (e recipientError) Unwrap() error { | ||
return e.error | ||
} | ||
|
||
func (recipientError) Is(err error) bool { | ||
_, ok := err.(recipientError) | ||
return ok | ||
} | ||
|
||
var errDefaultRecipientError = recipientError{errors.New(`recipient error`)} | ||
|
||
// RecipientError returns an error that can be passed to `errors.Is` to check if the error is | ||
// an error that occurred while attempting to decrypt a JWE message for a particular recipient. | ||
// | ||
// For example, if the JWE message failed to parse during `jwe.Decrypt`, it will be a | ||
// `jwe.DecryptError`, but NOT `jwe.RecipientError`. However, if the JWE message could not | ||
// be decrypted for any of the recipients, then it will be a `jwe.RecipientError` | ||
// (actually, it will be _multiple_ `jwe.RecipientError` errors, one for each recipient) | ||
func RecipientError() error { | ||
return errDefaultRecipientError | ||
} | ||
|
||
type parseError struct { | ||
error | ||
} | ||
|
||
func (e parseError) Unwrap() error { | ||
return e.error | ||
} | ||
|
||
func (parseError) Is(err error) bool { | ||
_, ok := err.(parseError) | ||
return ok | ||
} | ||
|
||
var errDefaultParseError = parseError{errors.New(`parse error`)} | ||
|
||
// ParseError returns an error that can be passed to `errors.Is` to check if the error | ||
// is an error returned by `jwe.Parse` and related functions. | ||
func ParseError() error { | ||
return errDefaultParseError | ||
} |
Oops, something went wrong.