use super::CAS;
use crate::Error;
use crate::native;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub struct PendingAuth {
inner: native::PendingAuth,
}
impl From<native::PendingAuth> for PendingAuth {
fn from(inner: native::PendingAuth) -> Self {
Self { inner }
}
}
#[wasm_bindgen]
impl PendingAuth {
#[wasm_bindgen(getter)]
pub fn solved(&self) -> bool {
self.inner.solved
}
#[wasm_bindgen(getter, js_name = "isEmailAvailable")]
pub fn is_email_available(&self) -> bool {
self.inner.is_email_available
}
#[wasm_bindgen(getter, js_name = "isTotpAvailable")]
pub fn is_totp_available(&self) -> bool {
self.inner.is_totp_available
}
#[wasm_bindgen(js_name = "sendEmailCode")]
pub async fn send_email_code(&mut self) -> Result<(), Error> {
self.inner.send_email_code().await
}
#[wasm_bindgen(js_name = "solveWithEmailCode")]
pub async fn solve_with_email_code(&mut self, code: String) -> Result<(), Error> {
self.inner.solve_with_email_code(&code).await
}
#[wasm_bindgen(js_name = "solveWithTotp")]
pub async fn solve_with_totp(&mut self, totp: String) -> Result<(), Error> {
self.inner.solve_with_totp(&totp).await
}
pub async fn finish(&mut self) -> Result<CAS, Error> {
self.inner.finish().await.map(CAS::from)
}
}