@@ -16,19 +16,23 @@ class default_1 extends Controller {
16
16
async signin ( event ) {
17
17
event . preventDefault ( ) ;
18
18
const data = this . _getData ( ) ;
19
+ const optionsHeaders = {
20
+ 'Content-Type' : 'application/json' ,
21
+ } ;
22
+ this . _dispatchEvent ( 'webauthn:request:options' , { data, headers : optionsHeaders } ) ;
19
23
const resp = await fetch ( this . requestOptionsUrlValue || '/request/options' , {
20
24
method : 'POST' ,
21
- headers : {
22
- 'Content-Type' : 'application/json' ,
23
- } ,
25
+ headers : optionsHeaders ,
24
26
body : JSON . stringify ( data ) ,
25
27
} ) ;
26
28
const asseResp = await startAuthentication ( await resp . json ( ) ) ;
29
+ const responseHeaders = {
30
+ 'Content-Type' : 'application/json' ,
31
+ } ;
32
+ this . _dispatchEvent ( 'webauthn:request:response' , { response : asseResp , headers : responseHeaders } ) ;
27
33
const verificationResp = await fetch ( this . requestResultUrlValue || '/request' , {
28
34
method : 'POST' ,
29
- headers : {
30
- 'Content-Type' : 'application/json' ,
31
- } ,
35
+ headers : responseHeaders ,
32
36
body : JSON . stringify ( asseResp ) ,
33
37
} ) ;
34
38
const verificationJSON = await verificationResp . json ( ) ;
@@ -46,19 +50,23 @@ class default_1 extends Controller {
46
50
async signup ( event ) {
47
51
event . preventDefault ( ) ;
48
52
const data = this . _getData ( ) ;
53
+ const optionsHeaders = {
54
+ 'Content-Type' : 'application/json' ,
55
+ } ;
56
+ this . _dispatchEvent ( 'webauthn:creation:options' , { data, headers : optionsHeaders } ) ;
49
57
const resp = await fetch ( this . creationOptionsUrlValue || '/creation/options' , {
50
58
method : 'POST' ,
51
- headers : {
52
- 'Content-Type' : 'application/json' ,
53
- } ,
59
+ headers : optionsHeaders ,
54
60
body : JSON . stringify ( data ) ,
55
61
} ) ;
56
62
const attResp = await startRegistration ( await resp . json ( ) ) ;
63
+ const responseHeaders = {
64
+ 'Content-Type' : 'application/json' ,
65
+ } ;
66
+ this . _dispatchEvent ( 'webauthn:creation:response' , { response : attResp , headers : responseHeaders } ) ;
57
67
const verificationResp = await fetch ( this . creationResultUrlValue || '/creation' , {
58
68
method : 'POST' ,
59
- headers : {
60
- 'Content-Type' : 'application/json' ,
61
- } ,
69
+ headers : responseHeaders ,
62
70
body : JSON . stringify ( attResp ) ,
63
71
} ) ;
64
72
const verificationJSON = await verificationResp . json ( ) ;
0 commit comments