use builder pattern for MakeCredentail and GetAssertion

This commit is contained in:
2020-03-31 21:30:59 +02:00
8 changed files with 370 additions and 281 deletions

View File

@@ -702,15 +702,16 @@ impl PublicKeyCredentialDescriptor {
pub struct AuthenticatorOptions {
pub rk: bool,
pub uv: bool,
pub up: bool,
}
impl AuthenticatorOptions {
pub fn encoded(&self) -> bool {
self.rk || self.uv
self.rk || self.uv || self.up
}
pub fn encode<W: WriteBytesExt>(&self, encoder: &mut Encoder<W>) -> FidoResult<()> {
let length = (self.rk as usize) + (self.uv as usize);
let length = (self.rk as usize) + (self.uv as usize) + (self.up as usize);
encoder.object(length)?;
if self.rk {
encoder.text("rk")?;
@@ -720,6 +721,10 @@ impl AuthenticatorOptions {
encoder.text("uv")?;
encoder.bool(true)?;
}
if self.up {
encoder.text("up")?;
encoder.bool(true)?;
}
Ok(())
}
}