Skip to content
Open
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
110 changes: 95 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ serde_json = "1.0.147"
serde_path_to_error = "0.1.20"
serde_repr = "0.1.20"
serde = { version = "1.0.228", features = ["derive"] }
serde_yaml = "0.9.34"
schemars = { version = "0.8.21", features = ["preserve_order"] }
sha1 = "0.10.6"
sha2 = "0.10.9"
signature = "2.2.0"
Expand Down
8 changes: 6 additions & 2 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,18 @@ skip = [
{ name = "thiserror-impl", version = "2.0.17" },
# until the rand 0.8 -> 0.9 transition finished making its way through
# the crate ecosystem
{ name = "rand", version = "0.8.5" },
{ name = "rand", version = "0.9.2" },
{ name = "rand", version = "0.8.6" },
{ name = "rand", version = "0.9.4" },
{ name = "rand_core", version = "0.6.4" },
{ name = "rand_core", version = "0.9.3" },
{ name = "rand_chacha", version = "0.3.1" },
{ name = "rand_chacha", version = "0.9.0" },
{ name = "getrandom", version = "0.2.16" },
{ name = "getrandom", version = "0.3.4" },
{ name = "indexmap", version = "1.9.3" },
{ name = "indexmap", version = "2.12.1" },
{ name = "hashbrown", version = "0.12.3" },
{ name = "hashbrown", version = "0.16.1" },
]

[licenses]
Expand Down
44 changes: 32 additions & 12 deletions src/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,17 @@ pub fn unlock<S: std::hash::BuildHasher>(

let protected_private_key =
crate::cipherstring::CipherString::new(protected_private_key)?;
let private_key =
match protected_private_key.decrypt_locked_symmetric(&key) {
Ok(private_key) => crate::locked::PrivateKey::new(private_key),
Err(e) => return Err(e),
};
let private_key = crate::locked::PrivateKey::new(
protected_private_key.decrypt_locked_symmetric(&key)?,
);

let mut org_keys = std::collections::HashMap::new();
for (org_id, protected_org_key) in protected_org_keys {
let protected_org_key =
crate::cipherstring::CipherString::new(protected_org_key)?;
let org_key =
match protected_org_key.decrypt_locked_asymmetric(&private_key) {
Ok(org_key) => crate::locked::Keys::new(org_key),
Err(e) => return Err(e),
};
let org_key = crate::locked::Keys::new(
protected_org_key.decrypt_locked_asymmetric(&private_key)?,
);
org_keys.insert(org_id.clone(), org_key);
}

Expand Down Expand Up @@ -171,25 +167,49 @@ async fn sync_once(
pub fn add(
access_token: &str,
refresh_token: &str,
org_id: Option<&str>,
name: &str,
data: &crate::db::EntryData,
fields: &[crate::db::Field],
notes: Option<&str>,
folder_id: Option<&str>,
history: &[crate::db::HistoryEntry],
) -> Result<(Option<String>, ())> {
with_exchange_refresh_token(access_token, refresh_token, |access_token| {
add_once(access_token, name, data, notes, folder_id)
add_once(
access_token,
org_id,
name,
data,
fields,
notes,
folder_id,
history,
)
})
}

fn add_once(
access_token: &str,
org_id: Option<&str>,
name: &str,
data: &crate::db::EntryData,
fields: &[crate::db::Field],
notes: Option<&str>,
folder_id: Option<&str>,
history: &[crate::db::HistoryEntry],
) -> Result<()> {
let (client, _) = api_client()?;
client.add(access_token, name, data, notes, folder_id)?;
client.add(
access_token,
org_id,
name,
data,
fields,
notes,
folder_id,
history,
)?;
Ok(())
}

Expand Down
Loading
Loading