Skip to content

DO NOT MERGE - add logins store static key manager factory #6696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions components/logins/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,13 @@ pub fn create_static_key_manager(key: String) -> Arc<StaticKeyManager> {
pub fn create_managed_encdec(key_manager: Arc<dyn KeyManager>) -> Arc<ManagedEncryptorDecryptor> {
Arc::new(ManagedEncryptorDecryptor::new(key_manager))
}

// Create a LoginStore by passing in a db path and a static key
//
// Note this is only temporarily needed until a bug with UniFFI and JavaScript is fixed, which
// prevents passing around traits in JS
pub fn create_login_store_with_static_key_manager(path: String, key: String) -> Arc<LoginStore> {
let encdec: ManagedEncryptorDecryptor =
ManagedEncryptorDecryptor::new(Arc::new(StaticKeyManager::new(key)));
Arc::new(LoginStore::new(path, Arc::new(encdec)).unwrap())
}
3 changes: 3 additions & 0 deletions components/logins/src/logins.udl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ namespace logins {
/// Similar to create_static_key_manager above, create a
/// ManagedEncryptorDecryptor by passing in a KeyManager
EncryptorDecryptor create_managed_encdec(KeyManager key_manager);

/// Create a LoginStore by passing in a db path and a static key
LoginStore create_login_store_with_static_key_manager(string path, string key);
};

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