The JoseError every pyfect.jose module fails with (Effect's
effect/jose/JoseError).
reason says what went wrong. Crypto failures become InvalidKey
without the crypto error's detail, so a token's verifier never learns why
a backend rejected a key. Match a reason with catch_reason::
jws.verify(token, key).pipe(
fx.catch_reason(JoseError, SignatureVerificationFailed, lambda _r, _e: fx.succeed(None))
)Types#
| Type | Definition | Description |
|---|---|---|
ReasonTag | type ReasonTag = Literal['InvalidToken', 'InvalidKey', 'InvalidArgument', 'AlgorithmNotAllowed', 'SignatureVerificationFailed', 'DecryptionFailed', 'KeyNotFound', 'AmbiguousKey', 'KeySetUnavailable', 'ClaimValidationFailed'] | |
Claim | type Claim = Literal['iss', 'sub', 'aud', 'exp', 'nbf', 'iat', 'jti', 'typ'] | |
ClaimFailure | type ClaimFailure = Literal['invalid', 'missing', 'mismatch', 'expired', 'notYetValid', 'tooOld', 'future'] | |
AnyReason | type AnyReason = InvalidToken | InvalidKey | InvalidArgument | AlgorithmNotAllowed | SignatureVerificationFailed | DecryptionFailed | KeyNotFound | AmbiguousKey | KeySetUnavailable | ClaimValidationFailed |
Classes#
JoseErrorReasonInvalidTokenInvalidKeyInvalidArgumentAlgorithmNotAllowedSignatureVerificationFailedDecryptionFailedKeyNotFoundAmbiguousKeyKeySetUnavailableClaimValidationFailedJoseError
Functions#
is_jose_error#
is_jose_error(u) -> bool| Parameter | Type | Description |
|---|---|---|
u | object |
Returns bool
def is_jose_error(u: object) -> bool:
return isinstance(u, JoseError)is_jose_error_reason#
is_jose_error_reason(u) -> bool| Parameter | Type | Description |
|---|---|---|
u | object |
Returns bool
def is_jose_error_reason(u: object) -> bool:
return isinstance(u, JoseErrorReason)