feat: return sql statements as array
This commit is contained in:
parent
e99ec8e88a
commit
e43dd2c336
2 changed files with 9 additions and 14 deletions
|
@ -5,7 +5,6 @@ edition = "2021"
|
||||||
description = "Get the raw database from your Signal backup. Written for webassembly"
|
description = "Get the raw database from your Signal backup. Written for webassembly"
|
||||||
repository = "https://git.duskflower.dev/duskflower/signal-decrypt-backup-wasm"
|
repository = "https://git.duskflower.dev/duskflower/signal-decrypt-backup-wasm"
|
||||||
license = "GPL-3-only"
|
license = "GPL-3-only"
|
||||||
license-file = "LICENSE"
|
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib", "rlib"]
|
crate-type = ["cdylib", "rlib"]
|
||||||
|
|
22
src/lib.rs
22
src/lib.rs
|
@ -41,14 +41,14 @@ type HmacSha256 = Hmac<Sha256>;
|
||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub struct DecryptionResult {
|
pub struct DecryptionResult {
|
||||||
database_bytes: Vec<u8>,
|
database_statements: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
impl DecryptionResult {
|
impl DecryptionResult {
|
||||||
#[wasm_bindgen(getter)]
|
#[wasm_bindgen(getter)]
|
||||||
pub fn database_bytes(&self) -> Vec<u8> {
|
pub fn database_statements(&self) -> Vec<String> {
|
||||||
self.database_bytes.clone()
|
self.database_statements.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,7 +355,7 @@ pub struct BackupDecryptor {
|
||||||
keys: Option<Keys>,
|
keys: Option<Keys>,
|
||||||
header_data: Option<HeaderData>,
|
header_data: Option<HeaderData>,
|
||||||
initialisation_vector: Option<Vec<u8>>,
|
initialisation_vector: Option<Vec<u8>>,
|
||||||
database_bytes: Vec<u8>,
|
database_statements: Vec<String>,
|
||||||
ciphertext_buf: Vec<u8>,
|
ciphertext_buf: Vec<u8>,
|
||||||
plaintext_buf: Vec<u8>,
|
plaintext_buf: Vec<u8>,
|
||||||
total_file_size: usize,
|
total_file_size: usize,
|
||||||
|
@ -379,7 +379,7 @@ impl BackupDecryptor {
|
||||||
keys: None,
|
keys: None,
|
||||||
header_data: None,
|
header_data: None,
|
||||||
initialisation_vector: None,
|
initialisation_vector: None,
|
||||||
database_bytes: Vec::new(),
|
database_statements: Vec::new(),
|
||||||
ciphertext_buf: Vec::new(),
|
ciphertext_buf: Vec::new(),
|
||||||
plaintext_buf: Vec::new(),
|
plaintext_buf: Vec::new(),
|
||||||
total_file_size: 0,
|
total_file_size: 0,
|
||||||
|
@ -544,8 +544,7 @@ impl BackupDecryptor {
|
||||||
if let Some(version) = backup_frame.version {
|
if let Some(version) = backup_frame.version {
|
||||||
if let Some(ver_num) = version.version {
|
if let Some(ver_num) = version.version {
|
||||||
let pragma_sql = format!("PRAGMA user_version = {}", ver_num);
|
let pragma_sql = format!("PRAGMA user_version = {}", ver_num);
|
||||||
self.database_bytes.extend_from_slice(pragma_sql.as_bytes());
|
self.database_statements.push(pragma_sql);
|
||||||
self.database_bytes.push(b';');
|
|
||||||
}
|
}
|
||||||
} else if let Some(statement) = backup_frame.statement {
|
} else if let Some(statement) = backup_frame.statement {
|
||||||
if let Some(sql) = statement.statement {
|
if let Some(sql) = statement.statement {
|
||||||
|
@ -562,13 +561,10 @@ impl BackupDecryptor {
|
||||||
|
|
||||||
process_parameter_placeholders(&sql, ¶ms)?
|
process_parameter_placeholders(&sql, ¶ms)?
|
||||||
} else {
|
} else {
|
||||||
sql
|
sql.clone()
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add to concatenated string
|
self.database_statements.push(processed_sql);
|
||||||
self.database_bytes
|
|
||||||
.extend_from_slice(processed_sql.as_bytes());
|
|
||||||
self.database_bytes.push(b';');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if backup_frame.preference.is_some() || backup_frame.key_value.is_some()
|
} else if backup_frame.preference.is_some() || backup_frame.key_value.is_some()
|
||||||
|
@ -628,7 +624,7 @@ impl BackupDecryptor {
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub fn finish(self) -> Result<DecryptionResult, JsValue> {
|
pub fn finish(self) -> Result<DecryptionResult, JsValue> {
|
||||||
Ok(DecryptionResult {
|
Ok(DecryptionResult {
|
||||||
database_bytes: self.database_bytes,
|
database_statements: self.database_statements,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue