29
29
)
30
30
from supertokens_python .recipe .webauthn .interfaces .recipe import (
31
31
AuthenticationPayload ,
32
+ AuthenticatorAssertionResponseJSON ,
33
+ AuthenticatorAttestationResponseJSON ,
32
34
RegistrationPayload ,
33
35
)
34
36
from supertokens_python .types .response import StatusResponseBaseModel
@@ -65,12 +67,20 @@ def webauthn_signup(): # type: ignore
65
67
session = None
66
68
if "session" in request .json :
67
69
session = convert_session_to_container (request .json )
70
+
68
71
response = sign_up .sync (
69
72
** {
70
73
** {to_snake (k ): v for k , v in request .json .items ()},
71
74
# Create model without validation so that we can test edge cases
72
75
"credential" : RegistrationPayload .model_construct (
73
- request .json ["credential" ]
76
+ ** {
77
+ k : v
78
+ for k , v in request .json ["credential" ].items ()
79
+ if k != "response"
80
+ },
81
+ response = AuthenticatorAttestationResponseJSON .model_construct (
82
+ ** request .json ["credential" ]["response" ],
83
+ ),
74
84
),
75
85
"session" : session ,
76
86
} # type: ignore
@@ -89,7 +99,14 @@ def webauthn_signin(): # type: ignore
89
99
** {to_snake (k ): v for k , v in request .json .items ()},
90
100
# Create model without validation so that we can test edge cases
91
101
"credential" : AuthenticationPayload .model_construct (
92
- request .json ["credential" ]
102
+ ** {
103
+ k : v
104
+ for k , v in request .json ["credential" ].items ()
105
+ if k != "response"
106
+ },
107
+ response = AuthenticatorAssertionResponseJSON .model_construct (
108
+ ** request .json ["credential" ]["response" ],
109
+ ),
93
110
),
94
111
"session" : session ,
95
112
} # type: ignore
@@ -106,7 +123,14 @@ def webauthn_verify_credentials(): # type: ignore
106
123
** {to_snake (k ): v for k , v in request .json .items ()},
107
124
# Create model without validation so that we can test edge cases
108
125
"credential" : AuthenticationPayload .model_construct (
109
- request .json ["credential" ]
126
+ ** {
127
+ k : v
128
+ for k , v in request .json ["credential" ].items ()
129
+ if k != "response"
130
+ },
131
+ response = AuthenticatorAssertionResponseJSON .model_construct (
132
+ ** request .json ["credential" ]["response" ],
133
+ ),
110
134
),
111
135
} # type: ignore
112
136
),
@@ -145,7 +169,14 @@ def webauthn_register_credential(): # type: ignore
145
169
** {to_snake (k ): v for k , v in request .json .items ()},
146
170
# Create model without validation so that we can test edge cases
147
171
"credential" : RegistrationPayload .model_construct (
148
- request .json ["credential" ]
172
+ ** {
173
+ k : v
174
+ for k , v in request .json ["credential" ].items ()
175
+ if k != "response"
176
+ },
177
+ response = AuthenticatorAttestationResponseJSON .model_construct (
178
+ ** request .json ["credential" ]["response" ],
179
+ ),
149
180
),
150
181
} # type: ignore
151
182
)
0 commit comments