diff --git a/Cargo.toml b/Cargo.toml index ac626eb..310c5f3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,8 +30,6 @@ criterion = "0.3" [features] default = ["use_pem"] use_pem = ["pem", "simple_asn1"] -no_verify = [] -wasm = ["no_verify"] [[bench]] name = "jwt" diff --git a/src/decoding.rs b/src/decoding.rs index aad2975..c052844 100644 --- a/src/decoding.rs +++ b/src/decoding.rs @@ -1,7 +1,7 @@ use serde::de::DeserializeOwned; use crate::algorithms::AlgorithmFamily; -#[cfg(not(feature = "no_verify"))] +#[cfg(not(target_arch = "wasm32"))] use crate::crypto::verify; use crate::errors::{new_error, ErrorKind, Result}; use crate::header::Header; @@ -165,7 +165,10 @@ fn verify_signature<'a>( } } + #[cfg(not(target_arch = "wasm32"))] let (signature, message) = expect_two!(token.rsplitn(2, '.')); + #[cfg(target_arch = "wasm32")] + let (_, message) = expect_two!(token.rsplitn(2, '.')); let (payload, header) = expect_two!(message.rsplitn(2, '.')); let header = Header::from_encoded(header)?; @@ -174,11 +177,11 @@ fn verify_signature<'a>( } if validation.validate_signature { - #[cfg(not(feature = "no_verify"))] + #[cfg(not(target_arch = "wasm32"))] if !verify(signature, message.as_bytes(), key, header.alg)? { return Err(new_error(ErrorKind::InvalidSignature)); } - #[cfg(feature = "no_verify")] + #[cfg(target_arch = "wasm32")] return Err(new_error(ErrorKind::VerificationNotSupported)); } diff --git a/src/errors.rs b/src/errors.rs index 48e3b50..37403fb 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -79,8 +79,7 @@ pub enum ErrorKind { /// Something unspecified went wrong with crypto Crypto(::ring::error::Unspecified), - /// Verification is disabled by the feature flag `no_verify`. - #[cfg(feature = "no_verify")] + /// Verification is disabled because the target does not support it. VerificationNotSupported, } @@ -106,7 +105,6 @@ impl StdError for Error { ErrorKind::Json(ref err) => Some(err.as_ref()), ErrorKind::Utf8(ref err) => Some(err), ErrorKind::Crypto(ref err) => Some(err), - #[cfg(feature = "no_verify")] ErrorKind::VerificationNotSupported => None, } } @@ -134,7 +132,6 @@ impl fmt::Display for Error { ErrorKind::Utf8(ref err) => write!(f, "UTF-8 error: {}", err), ErrorKind::Crypto(ref err) => write!(f, "Crypto error: {}", err), ErrorKind::Base64(ref err) => write!(f, "Base64 error: {}", err), - #[cfg(feature = "no_verify")] ErrorKind::VerificationNotSupported => write!(f, "{:?}", self.0), } }