Skip to content

Commit ce853e6

Browse files
committed
simplify encryption parameters
1 parent b07ae02 commit ce853e6

File tree

3 files changed

+19
-35
lines changed

3 files changed

+19
-35
lines changed

libsql/src/database.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ impl Database {
710710
connector.clone(),
711711
None,
712712
None,
713-
remote_encryption.clone()
713+
remote_encryption.clone(),
714714
),
715715
read_your_writes: *read_your_writes,
716716
context: db.sync_ctx.clone().unwrap(),

libsql/src/hrana/hyper.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl HttpSender {
7070
if let Some(remote_encryption) = &self.remote_encryption {
7171
req_builder = req_builder.header(
7272
"x-turso-encryption-key",
73-
remote_encryption.key_16_bytes_base64_encoded.as_str(),
73+
remote_encryption.key_32_bytes_base64_encoded.as_str(),
7474
);
7575
}
7676

libsql/src/sync.rs

Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,7 @@ struct PushFramesResult {
121121
#[derive(Debug, Clone)]
122122
pub struct EncryptionContext {
123123
/// The base64-encoded key for the encryption, sent on every request.
124-
pub key_16_bytes_base64_encoded: String,
125-
/// Whether the pushed frames are already encrypted.
126-
pub push_is_encrypted: bool,
127-
/// Whether to request the server to decrypt the pulled frames.
128-
pub decrypt_pull: bool,
124+
pub key_32_bytes_base64_encoded: String,
129125
}
130126

131127
pub struct SyncContext {
@@ -318,13 +314,10 @@ impl SyncContext {
318314
}
319315

320316
if let Some(remote_encryption) = &self.remote_encryption {
321-
if remote_encryption.decrypt_pull {
322-
req = req.header("x-turso-decrypt-response", "true");
323-
}
324-
if remote_encryption.push_is_encrypted {
325-
req = req.header("x-turso-encrypted-request", "true");
326-
}
327-
req = req.header("x-turso-encryption-key", remote_encryption.key_16_bytes_base64_encoded.as_str());
317+
req = req.header(
318+
"x-turso-encryption-key",
319+
remote_encryption.key_32_bytes_base64_encoded.as_str(),
320+
);
328321
}
329322

330323
let req = req.body(body.clone().into()).expect("valid body");
@@ -439,13 +432,10 @@ impl SyncContext {
439432
}
440433

441434
if let Some(remote_encryption) = &self.remote_encryption {
442-
if remote_encryption.decrypt_pull {
443-
req = req.header("x-turso-decrypt-response", "true");
444-
}
445-
if remote_encryption.push_is_encrypted {
446-
req = req.header("x-turso-encrypted-request", "true");
447-
}
448-
req = req.header("x-turso-encryption-key", remote_encryption.key_16_bytes_base64_encoded.as_str());
435+
req = req.header(
436+
"x-turso-encryption-key",
437+
remote_encryption.key_32_bytes_base64_encoded.as_str(),
438+
);
449439
}
450440

451441
let req = req.body(Body::empty()).expect("valid request");
@@ -612,13 +602,10 @@ impl SyncContext {
612602
}
613603

614604
if let Some(remote_encryption) = &self.remote_encryption {
615-
if remote_encryption.decrypt_pull {
616-
req = req.header("x-turso-decrypt-response", "true");
617-
}
618-
if remote_encryption.push_is_encrypted {
619-
req = req.header("x-turso-encrypted-request", "true");
620-
}
621-
req = req.header("x-turso-encryption-key", remote_encryption.key_16_bytes_base64_encoded.as_str());
605+
req = req.header(
606+
"x-turso-encryption-key",
607+
remote_encryption.key_32_bytes_base64_encoded.as_str(),
608+
);
622609
}
623610

624611
let req = req.body(Body::empty()).expect("valid request");
@@ -718,13 +705,10 @@ impl SyncContext {
718705
}
719706

720707
if let Some(remote_encryption) = &self.remote_encryption {
721-
if remote_encryption.decrypt_pull {
722-
req = req.header("x-turso-decrypt-response", "true");
723-
}
724-
if remote_encryption.push_is_encrypted {
725-
req = req.header("x-turso-encrypted-request", "true");
726-
}
727-
req = req.header("x-turso-encryption-key", remote_encryption.key_16_bytes_base64_encoded.as_str());
708+
req = req.header(
709+
"x-turso-encryption-key",
710+
remote_encryption.key_32_bytes_base64_encoded.as_str(),
711+
);
728712
}
729713

730714
let req = req.body(Body::empty()).expect("valid request");

0 commit comments

Comments
 (0)