This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| document.getElementById('login').addEventListener('submit', function(event) { | |
| event.preventDefault(); | |
| let username = this.username.value; | |
| startAuthenticationPasswordless({username}) | |
| .then((serverResponse) => { | |
| if(serverResponse.status !== 'startFIDOAuthentication') | |
| throw new Error('Error logging in! Server returned: ' + serverResponse.errorMessage); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| document.getElementById('register').addEventListener('submit', function(event) { | |
| event.preventDefault(); | |
| let username = this.username.value; | |
| let displayName = this.displayName.value; | |
| startPasswordlessEnrolment({username, displayName}) | |
| .then((serverResponse) => { | |
| if(serverResponse.status !== 'startFIDOEnrolmentRK') | |
| throw new Error('Error registering user! Server returned: ' + serverResponse.errorMessage); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| document.getElementById('register').addEventListener('submit', function(event) { | |
| event.preventDefault(); | |
| let username = this.username.value; | |
| let password = this.password.value; | |
| let displayName = this.displayName.value; | |
| registerPassword({username, password, displayName}) | |
| .then((serverResponse) => { | |
| if(serverResponse.status !== 'startFIDOEnrollment') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| document.getElementById('login').addEventListener('submit', function(event) { | |
| event.preventDefault(); | |
| let username = this.username.value; | |
| let password = this.password.value; | |
| loginPassword({username, password}) | |
| .then((serverResponse) => { | |
| if(serverResponse.status !== 'startFIDOAuthentication') | |
| throw new Error('Error logging in! Server returned: ' + serverResponse.errorMessage); | |
| return getGetAssertionChallenge() | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| document.getElementById('register').addEventListener('submit', function(event) { | |
| event.preventDefault(); | |
| let username = this.username.value; | |
| let password = this.password.value; | |
| let displayName = this.displayName.value; | |
| registerPassword({username, password, displayName}) | |
| .then((serverResponse) => { | |
| if(serverResponse.status !== 'startFIDOEnrollment') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var publicKey = { | |
| challenge: challenge, | |
| allowCredentials: [ | |
| { type: "public-key", id: credentialId } | |
| ] | |
| } | |
| navigator.credentials.get({ 'publicKey': publicKey }) | |
| .then((getAssertionResponse) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var challenge = new Uint8Array(32); | |
| window.crypto.getRandomValues(challenge); | |
| var userID = 'Kosv9fPtkDoh4Oz7Yq/pVgWHS8HhdlCto5cR0aBoVMw=' | |
| var id = Uint8Array.from(window.atob(userID), c=>c.charCodeAt(0)) | |
| var publicKey = { | |
| 'challenge': challenge, | |
| 'rp': { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var challenge = new Uint8Array(32); | |
| window.crypto.getRandomValues(challenge); | |
| var userID = 'Kosv9fPtkDoh4Oz7Yq/pVgWHS8HhdlCto5cR0aBoVMw=' | |
| var id = Uint8Array.from(window.atob(userID), c=>c.charCodeAt(0)) | |
| var publicKey = { | |
| 'challenge': challenge, | |
| 'rp': { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| navigator.credentials.get({ 'password': true }) | |
| .then((credential) => { | |
| if(!credential) | |
| throw new Error('No credential found') | |
| // sendServer(credential) // PasswordCredential {iconURL: "", name: "", password: "VeryRandomPassword123456", id: "alice", type: "password"} | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var passwordcred = new PasswordCredential({ | |
| 'type': 'password', | |
| 'id': 'alice', | |
| 'password': 'VeryRandomPassword123456' | |
| }) | |
| navigator.credentials.store(passwordcred) |