-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PM-16221] uniffi bindings for ssh agent and keygen (#89)
## 🎟️ Tracking https://bitwarden.atlassian.net/browse/PM-16221 ## 📔 Objective Adds bindings so we can add keygen and import to the mobile clients. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## 🦮 Reviewer guidelines <!-- Suggested interactions but feel free to use (or not) as you desire! --> - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹ️ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or⚠️ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or ♻️ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes
- Loading branch information
Showing
10 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[bindings.kotlin] | ||
package_name = "com.bitwarden.ssh" | ||
generate_immutable_records = true | ||
android = true | ||
|
||
[bindings.swift] | ||
ffi_module_name = "BitwardenSshFFI" | ||
module_name = "BitwardenSsh" | ||
generate_immutable_records = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use std::sync::Arc; | ||
|
||
use crate::{ | ||
error::{BitwardenError, Error}, | ||
Client, Result, | ||
}; | ||
|
||
#[derive(uniffi::Object)] | ||
pub struct SshClient(pub Arc<Client>); | ||
|
||
#[uniffi::export] | ||
impl SshClient { | ||
pub fn generate_ssh_key( | ||
&self, | ||
key_algorithm: bitwarden_ssh::generator::KeyAlgorithm, | ||
) -> Result<bitwarden_ssh::SshKey> { | ||
bitwarden_ssh::generator::generate_sshkey(key_algorithm) | ||
.map_err(|e| BitwardenError::E(Error::SshGeneration(e))) | ||
} | ||
|
||
pub fn import_ssh_key( | ||
&self, | ||
imported_key: String, | ||
password: Option<String>, | ||
) -> Result<bitwarden_ssh::SshKey> { | ||
bitwarden_ssh::import::import_key(imported_key, password) | ||
.map_err(|e| BitwardenError::E(Error::SshImport(e))) | ||
} | ||
} |