Skip to content

Commit

Permalink
Add comments, fix compile
Browse files Browse the repository at this point in the history
  • Loading branch information
Hinton committed Oct 17, 2023
1 parent 35ee037 commit eb65aec
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion crates/bitwarden-uniffi/src/vault/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ impl ClientVault {
/// - OTP Auth URI
/// - Steam URI
pub async fn generate_totp(&self, key: String, time: Option<DateTime<Utc>>) -> TotpResponse {
self.0 .0.read().await.vault().generate_totp(key).await
self.0 .0.read().await.vault().generate_totp(key, time).await
}
}
16 changes: 14 additions & 2 deletions crates/bitwarden/src/vault/totp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,25 @@ use serde::{Deserialize, Serialize};
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[cfg_attr(feature = "mobile", derive(uniffi::Record))]
pub struct TotpResponse {
/// Generated TOTP code
pub code: String,
pub interval: u32,
/// Time period
pub period: u32,
}

/// Generate a OATH or RFC 6238 TOTP code from a provided key.
///
/// https://datatracker.ietf.org/doc/html/rfc6238
///
/// Key can be either:
/// - A base32 encoded string
/// - OTP Auth URI
/// - Steam URI
///
/// Supports providing an optional time, and defaults to current system time if none is provided.
pub async fn generate_totp(_key: String, _time: Option<DateTime<Utc>>) -> TotpResponse {
TotpResponse {
code: "000 000".to_string(),
interval: 30,
period: 30,
}
}
6 changes: 3 additions & 3 deletions languages/kotlin/doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -1283,11 +1283,11 @@ implementations.
<tr>
<th>code</th>
<th>string</th>
<th></th>
<th>Generated TOTP code</th>
</tr>
<tr>
<th>interval</th>
<th>period</th>
<th>integer</th>
<th></th>
<th>Time period</th>
</tr>
</table>

0 comments on commit eb65aec

Please sign in to comment.