GitHub

jose_error

API reference for jose_error.

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

TypeDefinitionDescription
ReasonTagtype ReasonTag = Literal['InvalidToken', 'InvalidKey', 'InvalidArgument', 'AlgorithmNotAllowed', 'SignatureVerificationFailed', 'DecryptionFailed', 'KeyNotFound', 'AmbiguousKey', 'KeySetUnavailable', 'ClaimValidationFailed']
Claimtype Claim = Literal['iss', 'sub', 'aud', 'exp', 'nbf', 'iat', 'jti', 'typ']
ClaimFailuretype ClaimFailure = Literal['invalid', 'missing', 'mismatch', 'expired', 'notYetValid', 'tooOld', 'future']
AnyReasontype AnyReason = InvalidToken | InvalidKey | InvalidArgument | AlgorithmNotAllowed | SignatureVerificationFailed | DecryptionFailed | KeyNotFound | AmbiguousKey | KeySetUnavailable | ClaimValidationFailed

Classes

Functions

is_jose_error

is_jose_error(u) -> bool
ParameterTypeDescription
uobject

Returns bool

def is_jose_error(u: object) -> bool:
    return isinstance(u, JoseError)

is_jose_error_reason

is_jose_error_reason(u) -> bool
ParameterTypeDescription
uobject

Returns bool

def is_jose_error_reason(u: object) -> bool:
    return isinstance(u, JoseErrorReason)