55
55
< script src ="lib/fetch/fetch-3.0.0.js "> </ script >
56
56
< script src ="lib/base64js/base64js-1.3.0.min.js "> </ script >
57
57
< script src ="js/base64url.js "> </ script >
58
- < script src ="js/webauthn.js "> </ script >
59
58
60
- < script >
59
+ < script type ="module ">
60
+ import * as webauthnJson from "./lib/webauthn-json-0.6.1/dist/esm/webauthn-json.js" ;
61
61
62
62
let ceremonyState = { } ;
63
63
let session = {
205
205
if ( useU2f ) {
206
206
return executeU2fRegisterRequest ( request ) ;
207
207
} else {
208
- return webauthn . createCredential ( request . publicKeyCredentialCreationOptions ) ;
208
+ return webauthnJson . create ( { publicKey : request . publicKeyCredentialCreationOptions } ) ;
209
209
}
210
210
}
211
211
329
329
urls,
330
330
useU2f,
331
331
} ;
332
- return executeRequest ( request )
333
- . then ( webauthn . responseToObject ) ;
332
+ return executeRequest ( request ) ;
334
333
} )
335
334
. then ( finishCeremony )
336
335
;
443
442
function executeAuthenticateRequest ( request ) {
444
443
console . log ( 'executeAuthenticateRequest' , request ) ;
445
444
446
- return webauthn . getAssertion ( request . publicKeyCredentialRequestOptions ) ;
445
+ return webauthnJson . get ( { publicKey : request . publicKeyCredentialRequestOptions } ) ;
447
446
}
448
447
449
448
function authenticateWithUsername ( event ) {
529
528
530
529
function init ( ) {
531
530
hideDeviceInfo ( ) ;
531
+
532
+ document . getElementById ( "username" ) . oninput = usernameChanged ;
533
+ document . getElementById ( "registerButton" ) . onclick = register ;
534
+ document . getElementById ( "registerRkButton" ) . onclick = registerResidentKey ;
535
+ document . getElementById ( "authenticateWithUsernameButton" ) . onclick = authenticateWithUsername ;
536
+ document . getElementById ( "authenticateButton" ) . onclick = authenticate ;
537
+ document . getElementById ( "deregisterButton" ) . onclick = deregister ;
538
+ document . getElementById ( "logoutButton" ) . onclick = logout ;
539
+
532
540
return false ;
533
541
}
534
542
@@ -553,7 +561,7 @@ <h1> Test your WebAuthn device </h1>
553
561
< form class ="horizontal ">
554
562
< div class ="row ">
555
563
< label for ="username "> Username:</ label >
556
- < div > < input type ="text " id ="username " onInput =" javascript:usernameChanged(event) " /> </ div >
564
+ < div > < input type ="text " id ="username " /> </ div >
557
565
</ div >
558
566
< div class ="row ">
559
567
< label for ="displayName "> Display name:</ label >
@@ -564,12 +572,12 @@ <h1> Test your WebAuthn device </h1>
564
572
< label for ="credentialNickname "> Credential nickname:</ label >
565
573
< div > < input type ="text " id ="credentialNickname "/> </ div >
566
574
< div >
567
- < button type ="button " id ="registerButton " onClick =" javascript:register() " >
575
+ < button type ="button " id ="registerButton ">
568
576
Register new account
569
577
</ button >
570
578
</ div >
571
579
< div >
572
- < button type ="button " id ="registerRkButton " onClick =" javascript:registerResidentKey() " >
580
+ < button type ="button " id ="registerRkButton ">
573
581
Register new account with resident credential
574
582
</ button >
575
583
</ div >
@@ -579,12 +587,12 @@ <h1> Test your WebAuthn device </h1>
579
587
< div > </ div >
580
588
< div > </ div >
581
589
< div >
582
- < button type ="button " onClick =" javascript:authenticateWithUsername() ">
590
+ < button type ="button " id =" authenticateWithUsernameButton ">
583
591
Authenticate
584
592
</ button >
585
593
</ div >
586
594
< div >
587
- < button type ="button " onClick =" javascript:authenticate() ">
595
+ < button type ="button " id =" authenticateButton ">
588
596
Authenticate without username
589
597
</ button >
590
598
</ div >
@@ -603,7 +611,7 @@ <h1> Test your WebAuthn device </h1>
603
611
< label for ="deregisterCredentialId "> Credential ID:</ label >
604
612
< div > < input type ="text " id ="deregisterCredentialId "/> </ div >
605
613
< div >
606
- < button type ="button " onClick =" javascript:deregister() ">
614
+ < button type ="button " id =" deregisterButton ">
607
615
Deregister
608
616
</ button >
609
617
</ div >
@@ -612,7 +620,7 @@ <h1> Test your WebAuthn device </h1>
612
620
613
621
614
622
< p id ="session "> Not logged in.</ p >
615
- < button id ="logoutButton " disabled ="disabled " onClick =" javascript:logout() " > Log out</ button >
623
+ < button id ="logoutButton " disabled ="disabled "> Log out</ button >
616
624
< p id ="status "> </ p >
617
625
< div id ="messages "> </ div >
618
626
0 commit comments