mirror of
https://git.um-react.app/um/lib_um_crypto_rust.git
synced 2026-03-07 20:19:51 +00:00
[kwm] refactor: move Decipher new fn under struct
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use crate::errors::map_js_error;
|
||||
use crate::exports::qmc::JsQMC2;
|
||||
use umc_kuwo::kwm_v1::CipherV1;
|
||||
use umc_kuwo::{Cipher, Header};
|
||||
use umc_kuwo::{Decipher, Header};
|
||||
use wasm_bindgen::prelude::wasm_bindgen;
|
||||
use wasm_bindgen::JsError;
|
||||
|
||||
@@ -27,7 +27,7 @@ impl JsKuwoHeader {
|
||||
/// Create an instance of cipher (decipher) for decryption
|
||||
#[wasm_bindgen(js_name=makeDecipher)]
|
||||
pub fn make_decipher(&self, ekey: Option<String>) -> Result<JsCipher, JsError> {
|
||||
let cipher = self.0.get_decipher(ekey).map_err(map_js_error)?;
|
||||
let cipher = Decipher::new(&self.0, ekey).map_err(map_js_error)?;
|
||||
Ok(JsCipher(cipher))
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,7 @@ pub fn js_kuwo_v2_cipher_factory(ekey: &str) -> Result<JsQMC2, JsError> {
|
||||
|
||||
/// Common V1/V2 wrapper interface, derived from `KuwoHeader.makeCipher`
|
||||
#[wasm_bindgen(js_name=KWMCipher)]
|
||||
pub struct JsCipher(Cipher);
|
||||
pub struct JsCipher(Decipher);
|
||||
|
||||
#[wasm_bindgen(js_class=KWMCipher)]
|
||||
impl JsCipher {
|
||||
|
||||
Reference in New Issue
Block a user