@@ -3,87 +3,13 @@ use std::{fmt::Display, path::PathBuf};
33use serde:: { Deserialize , Serialize } ;
44use zvariant:: { SerializeDict , Type } ;
55
6- pub use libwebauthn:: ops:: webauthn:: {
7- Assertion , GetAssertionRequest , MakeCredentialRequest , MakeCredentialResponse ,
8- } ;
9-
106#[ derive( Clone , Debug , Default , Serialize , Deserialize ) ]
117pub struct Credential {
128 pub id : String ,
139 pub name : String ,
1410 pub username : Option < String > ,
1511}
1612
17- #[ derive( Clone , Debug ) ]
18- pub enum CredentialRequest {
19- CreatePublicKeyCredentialRequest ( MakeCredentialRequest ) ,
20- GetPublicKeyCredentialRequest ( GetAssertionRequest ) ,
21- }
22-
23- #[ derive( Clone , Debug ) ]
24- pub enum CredentialResponse {
25- CreatePublicKeyCredentialResponse ( Box < MakeCredentialResponseInternal > ) ,
26- GetPublicKeyCredentialResponse ( Box < GetAssertionResponseInternal > ) ,
27- }
28-
29- impl CredentialResponse {
30- pub fn from_make_credential (
31- response : & MakeCredentialResponse ,
32- transports : & [ & str ] ,
33- modality : & str ,
34- ) -> CredentialResponse {
35- CredentialResponse :: CreatePublicKeyCredentialResponse ( Box :: new (
36- MakeCredentialResponseInternal :: new (
37- response. clone ( ) ,
38- transports. iter ( ) . map ( |s| s. to_string ( ) ) . collect ( ) ,
39- modality. to_string ( ) ,
40- ) ,
41- ) )
42- }
43-
44- pub fn from_get_assertion ( assertion : & Assertion , modality : & str ) -> CredentialResponse {
45- CredentialResponse :: GetPublicKeyCredentialResponse ( Box :: new (
46- GetAssertionResponseInternal :: new ( assertion. clone ( ) , modality. to_string ( ) ) ,
47- ) )
48- }
49- }
50-
51- #[ derive( Clone , Debug ) ]
52- pub struct MakeCredentialResponseInternal {
53- pub ctap : MakeCredentialResponse ,
54- pub transport : Vec < String > ,
55- pub attachment_modality : String ,
56- }
57-
58- impl MakeCredentialResponseInternal {
59- pub fn new (
60- response : MakeCredentialResponse ,
61- transport : Vec < String > ,
62- attachment_modality : String ,
63- ) -> Self {
64- Self {
65- ctap : response,
66- transport,
67- attachment_modality,
68- }
69- }
70- }
71-
72- #[ derive( Clone , Debug ) ]
73- pub struct GetAssertionResponseInternal {
74- pub ctap : Assertion ,
75- pub attachment_modality : String ,
76- }
77-
78- impl GetAssertionResponseInternal {
79- pub fn new ( ctap : Assertion , attachment_modality : String ) -> Self {
80- Self {
81- ctap,
82- attachment_modality,
83- }
84- }
85- }
86-
8713#[ derive( SerializeDict , Type ) ]
8814#[ zvariant( signature = "dict" , rename_all = "camelCase" ) ]
8915pub struct GetClientCapabilitiesResponse {
0 commit comments