From a71084c46ba48020762699c7a67d601f4fff55fc Mon Sep 17 00:00:00 2001 From: Emelie Graven Date: Wed, 30 Oct 2024 08:27:18 +0100 Subject: [PATCH] chore: Fix typos --- .typos.toml | 7 +++++++ README.md | 12 ++++++------ src/jwe/enc/aescbc_hmac.rs | 6 +++--- src/jwe/jwe_algorithm.rs | 2 +- src/jwe/jwe_context.rs | 20 ++++++++++---------- src/jwe/jwe_header_set.rs | 4 ++-- src/jwk/key_pair.rs | 4 ++-- src/jws/jws_algorithm.rs | 2 +- src/jws/jws_header_set.rs | 2 +- src/jwt.rs | 6 +++--- src/jwt/jwt_context.rs | 6 +++--- 11 files changed, 39 insertions(+), 32 deletions(-) create mode 100644 .typos.toml diff --git a/.typos.toml b/.typos.toml new file mode 100644 index 0000000..9d1e60d --- /dev/null +++ b/.typos.toml @@ -0,0 +1,7 @@ +[files] +extend-exclude = ["data/**"] + +[default.extend-words] +# Can't change the API surface +encrypter = "encrypter" +deriver = "deriver" diff --git a/README.md b/README.md index f8815ff..72af0d3 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ cargo build --release ```sh 1. Update to vX.X.X on cargo.toml and README.md. -2. Run commnads +2. Run commands cargo test cargo publish --dry-run git tag vX.X.X @@ -378,7 +378,7 @@ fn main() -> Result<(), JoseError> { let signer = HS256.signer_from_bytes(key)?; let jwt = jwt::encode_with_signer(&payload, &header, &signer)?; - // Verifing JWT + // Verifying JWT let verifier = HS256.verifier_from_bytes(key)?; let (payload, header) = jwt::decode_with_verifier(&jwt, &verifier)?; @@ -421,7 +421,7 @@ fn main() -> Result<(), JoseError> { let signer = RS256.signer_from_pem(&private_key)?; let jwt = jwt::encode_with_signer(&payload, &header, &signer)?; - // Verifing JWT + // Verifying JWT let public_key = std::fs::read(PUBLIC_KEY).unwrap(); let verifier = RS256.verifier_from_pem(&public_key)?; let (payload, header) = jwt::decode_with_verifier(&jwt, &verifier)?; @@ -475,7 +475,7 @@ fn main() -> Result<(), JoseError> { let signer = PS256.signer_from_pem(&private_key)?; let jwt = jwt::encode_with_signer(&payload, &header, &signer)?; - // Verifing JWT + // Verifying JWT let public_key = std::fs::read(PUBLIC_KEY).unwrap(); let verifier = PS256.verifier_from_pem(&public_key)?; let (payload, header) = jwt::decode_with_verifier(&jwt, &verifier)?; @@ -530,7 +530,7 @@ fn main() -> Result<(), JoseError> { let signer = ES256.signer_from_pem(&private_key)?; let jwt = jwt::encode_with_signer(&payload, &header, &signer)?; - // Verifing JWT + // Verifying JWT let public_key = std::fs::read(PUBLIC_KEY).unwrap(); let verifier = ES256.verifier_from_pem(&public_key)?; let (payload, header) = jwt::decode_with_verifier(&jwt, &verifier)?; @@ -580,7 +580,7 @@ fn main() -> Result<(), JoseError> { let signer = EdDSA.signer_from_pem(&private_key)?; let jwt = jwt::encode_with_signer(&payload, &header, &signer)?; - // Verifing JWT + // Verifying JWT let public_key = std::fs::read(PUBLIC_KEY).unwrap(); let verifier = EdDSA.verifier_from_pem(&public_key)?; let (payload, header) = jwt::decode_with_verifier(&jwt, &verifier)?; diff --git a/src/jwe/enc/aescbc_hmac.rs b/src/jwe/enc/aescbc_hmac.rs index 5833225..882501d 100644 --- a/src/jwe/enc/aescbc_hmac.rs +++ b/src/jwe/enc/aescbc_hmac.rs @@ -29,7 +29,7 @@ impl AescbcHmacJweEncryption { } } - fn calcurate_tag( + fn calculate_tag( &self, aad: &[u8], iv: Option<&[u8]>, @@ -116,7 +116,7 @@ impl JweContentEncryption for AescbcHmacJweEncryption { })() .map_err(|err| JoseError::InvalidKeyFormat(err))?; - let tag = self.calcurate_tag(aad, iv, &encrypted_message, mac_key)?; + let tag = self.calculate_tag(aad, iv, &encrypted_message, mac_key)?; Ok((encrypted_message, Some(tag))) } @@ -155,7 +155,7 @@ impl JweContentEncryption for AescbcHmacJweEncryption { None => bail!("A tag value is required."), }; - let calc_tag = self.calcurate_tag(aad, iv, &encrypted_message, mac_key)?; + let calc_tag = self.calculate_tag(aad, iv, &encrypted_message, mac_key)?; if calc_tag.as_slice() != tag { bail!("The tag doesn't match."); } diff --git a/src/jwe/jwe_algorithm.rs b/src/jwe/jwe_algorithm.rs index 91357a8..fc230f0 100644 --- a/src/jwe/jwe_algorithm.rs +++ b/src/jwe/jwe_algorithm.rs @@ -48,7 +48,7 @@ pub trait JweEncrypter: Debug + Send + Sync { out_header: &mut JweHeader, ) -> Result>, JoseError>; - /// Return a encypted key. + /// Return a encrypted key. /// /// # Arguments /// diff --git a/src/jwe/jwe_context.rs b/src/jwe/jwe_context.rs index 46bbd1b..24826f9 100644 --- a/src/jwe/jwe_context.rs +++ b/src/jwe/jwe_context.rs @@ -500,27 +500,27 @@ impl JweContext { let (ciphertext, tag) = cencryption.encrypt(&key, iv.as_deref(), content, full_aad.as_bytes())?; - let mut writed = false; + let mut written = false; let mut json = String::new(); if let Some(val) = protected_b64 { json.push_str("{\"protected\":\""); json.push_str(&val); json.push_str("\""); - writed = true; + written = true; } if let Some(val) = header { let unprotected_map = val.claims_set(false); if unprotected_map.len() > 0 { let unprotected = serde_json::to_string(unprotected_map)?; - json.push_str(if writed { "," } else { "{" }); + json.push_str(if written { "," } else { "{" }); json.push_str("\"unprotected\":"); json.push_str(&unprotected); - writed = true; + written = true; } } - json.push_str(if writed { "," } else { "{" }); + json.push_str(if written { "," } else { "{" }); json.push_str("\"recipients\":["); for i in 0..recipient_headers.len() { if i > 0 { @@ -751,23 +751,23 @@ impl JweContext { let (ciphertext, tag) = cencryption.encrypt(&key, iv, content, full_aad.as_bytes())?; - let mut writed = false; + let mut written = false; let mut json = String::new(); if let Some(val) = protected_b64 { json.push_str("{\"protected\":\""); json.push_str(&val); json.push_str("\""); - writed = true; + written = true; } if let Some(val) = header { let unprotected_map = val.claims_set(false); if unprotected_map.len() > 0 { let unprotected = serde_json::to_string(unprotected_map)?; - json.push_str(if writed { "," } else { "{" }); + json.push_str(if written { "," } else { "{" }); json.push_str("\"unprotected\":"); json.push_str(&unprotected); - writed = true; + written = true; } } @@ -775,7 +775,7 @@ impl JweContext { let header_map = val.claims_set(); if header_map.len() > 0 { let header = serde_json::to_string(header_map)?; - json.push_str(if writed { "," } else { "{" }); + json.push_str(if written { "," } else { "{" }); json.push_str("\"header\":"); json.push_str(&header); } diff --git a/src/jwe/jwe_header_set.rs b/src/jwe/jwe_header_set.rs index 34fe196..521af43 100644 --- a/src/jwe/jwe_header_set.rs +++ b/src/jwe/jwe_header_set.rs @@ -26,7 +26,7 @@ impl JweHeaderSet { /// # Arguments /// /// * `value` - a algorithm - /// * `protection` - If it dosen't need protection, set false. + /// * `protection` - If it doesn't need protection, set false. pub fn set_algorithm(&mut self, value: impl Into, protection: bool) { let key = "alg"; let value: String = value.into(); @@ -53,7 +53,7 @@ impl JweHeaderSet { /// # Arguments /// /// * `value` - a content encryption - /// * `protection` - If it dosen't need protection, set false. + /// * `protection` - If it doesn't need protection, set false. pub fn set_content_encryption(&mut self, value: impl Into, protection: bool) { let key = "enc"; let value: String = value.into(); diff --git a/src/jwk/key_pair.rs b/src/jwk/key_pair.rs index 82cbfd3..a87c692 100644 --- a/src/jwk/key_pair.rs +++ b/src/jwk/key_pair.rs @@ -3,10 +3,10 @@ use std::fmt::Debug; use crate::jwk::Jwk; pub trait KeyPair: Debug + Send + Sync { - /// Return the applicatable algorithm. + /// Return the applicable algorithm. fn algorithm(&self) -> Option<&str>; - /// Return the applicatable key ID. + /// Return the applicable key ID. fn key_id(&self) -> Option<&str>; fn to_der_private_key(&self) -> Vec; diff --git a/src/jws/jws_algorithm.rs b/src/jws/jws_algorithm.rs index 37d856f..cf33349 100644 --- a/src/jws/jws_algorithm.rs +++ b/src/jws/jws_algorithm.rs @@ -51,7 +51,7 @@ impl Clone for Box { } pub trait JwsVerifier: Debug + Send + Sync { - /// Return the source algrithm instance. + /// Return the source algorithm instance. fn algorithm(&self) -> &dyn JwsAlgorithm; /// Return the source key ID. diff --git a/src/jws/jws_header_set.rs b/src/jws/jws_header_set.rs index f824ac0..31c34b2 100644 --- a/src/jws/jws_header_set.rs +++ b/src/jws/jws_header_set.rs @@ -27,7 +27,7 @@ impl JwsHeaderSet { /// # Arguments /// /// * `value` - a algorithm - /// * `protection` - If it dosen't need protection, set false. + /// * `protection` - If it doesn't need protection, set false. pub fn set_algorithm(&mut self, value: impl Into, protection: bool) { let key = "alg"; let value: String = value.into(); diff --git a/src/jwt.rs b/src/jwt.rs index 29402e2..4f6f4e8 100644 --- a/src/jwt.rs +++ b/src/jwt.rs @@ -20,7 +20,7 @@ use crate::{JoseError, JoseHeader}; static DEFAULT_CONTEXT: Lazy = Lazy::new(|| JwtContext::new()); -/// Return the string repsentation of the JWT with a "none" algorithm. +/// Return the string representation of the JWT with a "none" algorithm. /// /// # Arguments /// @@ -30,7 +30,7 @@ pub fn encode_unsecured(payload: &JwtPayload, header: &JwsHeader) -> Result