Skip to content

Commit

Permalink
fixes challenge
Browse files Browse the repository at this point in the history
  • Loading branch information
dagnelies committed Aug 8, 2024
1 parent 1042afb commit 0ef2c07
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ What follows is just an example of the most straightforward use case.
```
import {client} from '@passwordless-id/webauthn'
await client.register({
challenge: 'a random string generated by the server',
challenge: 'a random base64url encoded buffer from the server',
user: 'John Doe'
})
```
Expand All @@ -85,7 +85,7 @@ By default, this registers a passkey on any authenticator (local or roaming) wit
```
import {client} from '@passwordless-id/webauthn'
await client.authenticate({
challenge: 'a random string generated by the server'
challenge: 'a random base64url encoded buffer from the server'
})
```

Expand Down
20 changes: 10 additions & 10 deletions docs/demos/js/playground.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,20 @@ const app = new Vue({
},
verification: {
publicKey: "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEWyyMt1l16_1rzDP63Ayw9EFpn1VbSt4NSJ7BOsDzqed5Z3aTfQSvzPBPHb4uYQuuckOKRbdoH9S0fEnSvNxpRg==", // null,
//"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzXUir6UgELFeM9il6id2vgZ1sWbZTk4C5JLIiMpg7lywwTRdp0i+lPP9rEdzcmwKwRLh5QT8DlPFQuKrUc8eXb9r+RPq/CvVOxVCqdK6A9fg0PDnvA3k7c5Ax5V5n/HcSw/uXVAzwstxQsbV5pOk0JDtys7rKiPjdO+XH5TbANNJE7PsS5j90zHLKNQaSybgF8V0v4Oz4I9u7IjVQKEz2V56E4Qfj/D7g0PCu63M5mNz5bGsmUzg5XwSRIaG3J3kDTuyTTGjPYhTnYFyWYXuMu1ZQ7JCe5FUv9m4oj3jH33VQEW3sorea7UOBjnSsLWp8MyE08M4tlY2xgyFL59obQIDAQAB",
//"MIIBIjANBgkqhkiG9w0BA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nii6GNUz56kT2Q4Fc8hR28c3+qufKWuaHLJUnsw6GILQNxemDzirlKBhXFjz7Ht7tyGaqUwFZr9q+93j/95Ag==",
isValid: null
}
},
methods: {
newChallenge() {
return webauthn.utils.randomChallenge()
return webauthn.server.randomChallenge()
},
async register() {
try {
Expand All @@ -85,7 +85,7 @@ const app = new Vue({
console.log(result)
this.registration.result = result
}
catch(e) {
catch (e) {
console.warn(e)
this.$buefy.toast.open({
message: e,
Expand All @@ -107,7 +107,7 @@ const app = new Vue({
this.authentication.json = json

const credential = this.registration?.result?.credential
if(credential) {
if (credential) {
const result = await webauthn.server.verifyAuthentication(json, credential, {
challenge: this.authentication.options.challenge,
origin: this.origin,
Expand All @@ -118,7 +118,7 @@ const app = new Vue({
this.authentication.result = result
}
}
catch(e) {
catch (e) {
console.warn(e)
this.$buefy.toast.open({
message: e,
Expand All @@ -130,7 +130,7 @@ const app = new Vue({
try {
this.verification.isValid = await webauthn.server.verifySignature(this.verification)
}
catch(e) {
catch (e) {
console.warn(e)
this.$buefy.toast.open({
message: e,
Expand All @@ -146,4 +146,4 @@ const app = new Vue({
return webauthn.parsers.parseClient(clientData)
}
}
})
})
2 changes: 1 addition & 1 deletion docs/demos/js/webauthn.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/demos/js/webauthn.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@passwordless-id/webauthn",
"version": "2.0.3",
"version": "2.0.4",
"description": "A small wrapper around the webauthn protocol to make one's life easier.",

"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AuthenticationJSON, NamedAlgo, RegistrationJSON, RegistrationInfo, Auth
import * as utils from './utils'


export async function randomChallenge() {
export function randomChallenge() {
const buffer = crypto.getRandomValues(new Uint8Array(16)); // 128 bits
return utils.toBase64url(buffer);
}
Expand Down

0 comments on commit 0ef2c07

Please sign in to comment.