From b2fe9d780de19aa78e7805767c69a38b0d602ae1 Mon Sep 17 00:00:00 2001 From: Abdulrahim Al Methiab Date: Mon, 15 Jan 2024 22:50:18 +0100 Subject: [PATCH] fix wasm clippy issues --- bindings/wasm/src/sd_jwt/decoder.rs | 12 +++++++----- bindings/wasm/src/sd_jwt/disclosure.rs | 2 +- bindings/wasm/src/sd_jwt/encoder.rs | 14 ++++++++------ bindings/wasm/src/sd_jwt/key_binding_jwt_claims.rs | 2 +- bindings/wasm/src/sd_jwt/mod.rs | 4 ++-- .../wasm/src/sd_jwt/{sd_jwt.rs => wasm_sd_jwt.rs} | 8 +++++--- 6 files changed, 24 insertions(+), 18 deletions(-) rename bindings/wasm/src/sd_jwt/{sd_jwt.rs => wasm_sd_jwt.rs} (93%) diff --git a/bindings/wasm/src/sd_jwt/decoder.rs b/bindings/wasm/src/sd_jwt/decoder.rs index 295b567eb1..0df8100506 100644 --- a/bindings/wasm/src/sd_jwt/decoder.rs +++ b/bindings/wasm/src/sd_jwt/decoder.rs @@ -1,12 +1,13 @@ // Copyright 2020-2024 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use crate::{ - common::{ArrayString, RecordStringAny}, - error::{Result, WasmResult}, -}; +use crate::common::ArrayString; +use crate::common::RecordStringAny; +use crate::error::Result; +use crate::error::WasmResult; use identity_iota::sd_jwt_payload::SdObjectDecoder; -use serde_json::{Map, Value}; +use serde_json::Map; +use serde_json::Value; use wasm_bindgen::prelude::*; /// Substitutes digests in an SD-JWT object by their corresponding plaintext values provided by disclosures. @@ -14,6 +15,7 @@ use wasm_bindgen::prelude::*; pub struct WasmSdObjectDecoder(pub(crate) SdObjectDecoder); #[wasm_bindgen(js_class = SdObjectDecoder)] +#[allow(clippy::new_without_default)] impl WasmSdObjectDecoder { /// Creates a new `SdObjectDecoder` with `sha-256` hasher. #[wasm_bindgen(constructor)] diff --git a/bindings/wasm/src/sd_jwt/disclosure.rs b/bindings/wasm/src/sd_jwt/disclosure.rs index 33870c0ba6..d5313976e0 100644 --- a/bindings/wasm/src/sd_jwt/disclosure.rs +++ b/bindings/wasm/src/sd_jwt/disclosure.rs @@ -49,7 +49,7 @@ impl WasmDisclosure { /// Returns a copy of the base64url-encoded string. #[wasm_bindgen(js_name = toString)] - pub fn to_string(&self) -> String { + pub fn to_string_clone(&self) -> String { self.0.disclosure.clone() } diff --git a/bindings/wasm/src/sd_jwt/encoder.rs b/bindings/wasm/src/sd_jwt/encoder.rs index 6a24a435f1..79ad041dc1 100644 --- a/bindings/wasm/src/sd_jwt/encoder.rs +++ b/bindings/wasm/src/sd_jwt/encoder.rs @@ -2,12 +2,14 @@ // SPDX-License-Identifier: Apache-2.0 use super::disclosure::WasmDisclosure; -use crate::{ - common::{ArrayString, RecordStringAny}, - error::{Result, WasmResult}, -}; -use identity_iota::sd_jwt_payload::{SdObjectEncoder, Sha256Hasher}; -use js_sys::{Array, JsString}; +use crate::common::ArrayString; +use crate::common::RecordStringAny; +use crate::error::Result; +use crate::error::WasmResult; +use identity_iota::sd_jwt_payload::SdObjectEncoder; +use identity_iota::sd_jwt_payload::Sha256Hasher; +use js_sys::Array; +use js_sys::JsString; use serde_json::Value; use wasm_bindgen::prelude::*; diff --git a/bindings/wasm/src/sd_jwt/key_binding_jwt_claims.rs b/bindings/wasm/src/sd_jwt/key_binding_jwt_claims.rs index 45e722526e..dca5c1a8c1 100644 --- a/bindings/wasm/src/sd_jwt/key_binding_jwt_claims.rs +++ b/bindings/wasm/src/sd_jwt/key_binding_jwt_claims.rs @@ -67,7 +67,7 @@ impl WasmKeyBindingJwtClaims { /// Returns a copy of the issued at `iat` property. #[wasm_bindgen] pub fn iat(&self) -> i64 { - self.0.iat.clone() + self.0.iat } /// Returns a copy of the audience `aud` property. diff --git a/bindings/wasm/src/sd_jwt/mod.rs b/bindings/wasm/src/sd_jwt/mod.rs index e4283274ad..f9c9d9db49 100644 --- a/bindings/wasm/src/sd_jwt/mod.rs +++ b/bindings/wasm/src/sd_jwt/mod.rs @@ -5,10 +5,10 @@ mod decoder; mod disclosure; mod encoder; mod key_binding_jwt_claims; -mod sd_jwt; +mod wasm_sd_jwt; pub use decoder::*; pub use disclosure::*; pub use encoder::*; pub use key_binding_jwt_claims::*; -pub use sd_jwt::*; +pub use wasm_sd_jwt::*; diff --git a/bindings/wasm/src/sd_jwt/sd_jwt.rs b/bindings/wasm/src/sd_jwt/wasm_sd_jwt.rs similarity index 93% rename from bindings/wasm/src/sd_jwt/sd_jwt.rs rename to bindings/wasm/src/sd_jwt/wasm_sd_jwt.rs index 82c66c6c3f..7b4f201206 100644 --- a/bindings/wasm/src/sd_jwt/sd_jwt.rs +++ b/bindings/wasm/src/sd_jwt/wasm_sd_jwt.rs @@ -1,10 +1,12 @@ // Copyright 2020-2024 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 +use crate::common::ArrayString; use crate::error::Result; -use crate::{common::ArrayString, error::WasmResult}; +use crate::error::WasmResult; use identity_iota::sd_jwt_payload::SdJwt; -use js_sys::{Array, JsString}; +use js_sys::Array; +use js_sys::JsString; use wasm_bindgen::prelude::*; /// Representation of an SD-JWT of the format @@ -44,7 +46,7 @@ impl WasmSdJwt { /// Serializes the components into the final SD-JWT. #[wasm_bindgen(js_name = toString)] - pub fn to_string(&self) -> String { + pub fn to_string_clone(&self) -> String { self.0.presentation() }