Skip to content

Commit fd76a6d

Browse files
committed
Bug 1973969 - factory method for login store with nss key manager
1 parent 7a10bdd commit fd76a6d

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- expose constructors for `ManagedEncryptorDecryptor` and `NSSKeyManager`
66
- change PrimaryPasswordAuthenticator callbacks to be async (a breaking change, but not yet used by anyone)
77
- return Result in PrimaryPasswordAuthenticator callbacks (again a breaking change, but not yet used by anyone)
8+
- add factory for login store with nss key manager: `create_login_store_with_nss_keymanager` to avoid round-tripping the KeyManager trait interface through JS.
89

910
# v141.0 (_2025-06-23_)
1011

components/logins/src/lib.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,19 @@ pub fn create_login_store_with_static_key_manager(path: String, key: String) ->
5555
ManagedEncryptorDecryptor::new(Arc::new(StaticKeyManager::new(key)));
5656
Arc::new(LoginStore::new(path, Arc::new(encdec)).unwrap())
5757
}
58+
59+
// Create a LoginStore with NSSKeyManager by passing in a db path and a PrimaryPasswordAuthenticator.
60+
//
61+
// Note this is only temporarily needed until a bug with UniFFI and JavaScript is fixed, which
62+
// prevents passing around traits in JS
63+
#[cfg(feature = "keydb")]
64+
#[uniffi::export]
65+
pub fn create_login_store_with_nss_keymanager(
66+
path: String,
67+
primary_password_authenticator: Arc<dyn PrimaryPasswordAuthenticator>,
68+
) -> Arc<LoginStore> {
69+
let encdec: ManagedEncryptorDecryptor = ManagedEncryptorDecryptor::new(Arc::new(
70+
NSSKeyManager::new(primary_password_authenticator),
71+
));
72+
Arc::new(LoginStore::new(path, Arc::new(encdec)).unwrap())
73+
}

components/logins/src/logins.udl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ namespace logins {
2929
/// ManagedEncryptorDecryptor by passing in a KeyManager
3030
EncryptorDecryptor create_managed_encdec(KeyManager key_manager);
3131

32-
/// Create a LoginStore by passing in a db path and a static key
32+
/// Create a LoginStore with StaticKeyManager by passing in a db path and a
33+
/// static key
3334
LoginStore create_login_store_with_static_key_manager(string path, string key);
3435
};
3536

0 commit comments

Comments
 (0)