Skip to content

Commit 5da98f6

Browse files
committed
add logins store static key manager factory
This is for developing as logins for desktop to work around a UniFFI bug preventing us to construct the login manager from Rust-provided structs on JavaScript side.
1 parent 7a3f356 commit 5da98f6

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

components/logins/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,13 @@ pub fn create_static_key_manager(key: String) -> Arc<StaticKeyManager> {
4545
pub fn create_managed_encdec(key_manager: Arc<dyn KeyManager>) -> Arc<ManagedEncryptorDecryptor> {
4646
Arc::new(ManagedEncryptorDecryptor::new(key_manager))
4747
}
48+
49+
// Create a LoginStore by passing in a db path and a static key
50+
//
51+
// Note this is only temporarily needed until a bug with UniFFI and JavaScript is fixed, which
52+
// prevents passing around traits in JS
53+
pub fn create_login_store_with_static_key_manager(path: String, key: String) -> Arc<LoginStore> {
54+
let encdec: ManagedEncryptorDecryptor =
55+
ManagedEncryptorDecryptor::new(Arc::new(StaticKeyManager::new(key)));
56+
Arc::new(LoginStore::new(path, Arc::new(encdec)).unwrap())
57+
}

components/logins/src/logins.udl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ namespace logins {
2828
/// Similar to create_static_key_manager above, create a
2929
/// ManagedEncryptorDecryptor by passing in a KeyManager
3030
EncryptorDecryptor create_managed_encdec(KeyManager key_manager);
31+
32+
/// Create a LoginStore by passing in a db path and a static key
33+
LoginStore create_login_store_with_static_key_manager(string path, string key);
3134
};
3235

3336
/// A login entry from the user, not linked to any database record.

0 commit comments

Comments
 (0)