forked from passwordless-id/webauthn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
768 additions
and
220 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
/node_modules | ||
/.vscode | ||
/dist/esm | ||
/dist/types | ||
/dist/esm |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,49 @@ | ||
import * as webauthn from '../../dist/webauthn.min.js' | ||
import { client } from '../../dist/webauthn.min.js' | ||
|
||
const app = new Vue({ | ||
el: '#app', | ||
data: { | ||
username: null, | ||
isRegistered: false, | ||
isAuthenticated: false, | ||
isExternal: false | ||
const app = new Vue({ | ||
el: '#app', | ||
data: { | ||
username: null, | ||
isRegistered: false, | ||
isAuthenticated: false, | ||
isExternal: false | ||
}, | ||
methods: { | ||
async checkIsRegistered() { | ||
console.log(this.username + ' => ' + !!window.localStorage.getItem(this.username)) | ||
this.isRegistered = !!window.localStorage.getItem(this.username) | ||
}, | ||
methods: { | ||
async checkIsRegistered() { | ||
console.log(this.username + ' => ' + !!window.localStorage.getItem(this.username)) | ||
this.isRegistered = !!window.localStorage.getItem(this.username) | ||
}, | ||
async register() { | ||
let res = await webauthn.register(this.username, window.crypto.randomUUID(),{authType: this.isExternal ? 'extern' : 'auto'}) | ||
this.$buefy.toast.open({ | ||
message: 'Registered!', | ||
type: 'is-success' | ||
}) | ||
async register() { | ||
let res = await client.register(this.username, window.crypto.randomUUID(),{authType: this.isExternal ? 'extern' : 'auto'}) | ||
this.$buefy.toast.open({ | ||
message: 'Registered!', | ||
type: 'is-success' | ||
}) | ||
|
||
console.log(res) | ||
console.log(res) | ||
|
||
this.isAuthenticated = true; | ||
window.localStorage.setItem(this.username, res.credential.id) | ||
await this.checkIsRegistered() | ||
}, | ||
async login() { | ||
let credentialId = window.localStorage.getItem(this.username) | ||
let res = await webauthn.login(credentialId ? [credentialId] : [], window.crypto.randomUUID(), {isExternal: this.isExternal}) | ||
console.log(res) | ||
this.isAuthenticated = true; | ||
window.localStorage.setItem(this.username, res.credential.id) | ||
await this.checkIsRegistered() | ||
}, | ||
async login() { | ||
let credentialId = window.localStorage.getItem(this.username) | ||
let res = await client.authenticate(credentialId ? [credentialId] : [], window.crypto.randomUUID(), {isExternal: this.isExternal}) | ||
console.log(res) | ||
|
||
this.isAuthenticated = true; | ||
this.$buefy.toast.open({ | ||
message: 'Signed in!', | ||
type: 'is-success' | ||
}) | ||
}, | ||
async logout() { | ||
this.isAuthenticated = false; | ||
this.$buefy.toast.open({ | ||
message: 'Signed out!', | ||
type: 'is-success' | ||
}) | ||
this.isAuthenticated = true; | ||
this.$buefy.toast.open({ | ||
message: 'Signed in!', | ||
type: 'is-success' | ||
}) | ||
}, | ||
async logout() { | ||
this.isAuthenticated = false; | ||
this.$buefy.toast.open({ | ||
message: 'Signed out!', | ||
type: 'is-success' | ||
}) | ||
|
||
} | ||
} | ||
}) | ||
} | ||
}) |
Oops, something went wrong.