Skip to content

Commit

Permalink
Fixes #29
Browse files Browse the repository at this point in the history
  • Loading branch information
dagnelies committed Aug 21, 2023
1 parent f86d274 commit d84259e
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 19 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Passwordless.ID / webauthn
==========================

A greatly simplified and opinionated wrapper to invoke the [webauthn protocol](https://w3c.github.io/webauthn/) more conveniently.
It is minimalistik (11kb) and dependency-free.

<img src="demos/img/banner-biometric-auth.svg" />

Expand Down Expand Up @@ -50,7 +51,7 @@ import * as webauthn from '@passwordless-id/webauthn'

```html
<script type="module">
import { client } from 'https://unpkg.com/@passwordless-id/webauthn'
import { client } from 'https://unpkg.com/@passwordless-id/webauthn@1.2.5/dist/webauthn.min.js'
</script>
```
### Import
Expand Down
6 changes: 3 additions & 3 deletions demos/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
</template>
</main>

<script src="https://unpkg.com/vue@2"></script>
<script src="https://unpkg.com/buefy/dist/buefy.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script src="https://unpkg.com/vue@2.7.14/dist/vue.min.js"></script>
<script src="https://unpkg.com/buefy@0.9.23/dist/buefy.min.js"></script>
<script src="https://unpkg.com/browse/axios@1.4.0/dist/axios.min.js"></script>

<script type="module" src="js/basic.js"></script>
</body>
Expand Down
20 changes: 15 additions & 5 deletions demos/example-cdn.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,28 @@


<script type="module">
import { client } from 'https://unpkg.com/@passwordless-id/webauthn'
import { client } from 'https://unpkg.com/@passwordless-id/webauthn@1.2.5/dist/webauthn.min.js'

window.register = async function() {
console.log('Registering...')
let res = client.register('MyUsername', 'random-challenge-base64-encoded')
console.log(res)
try {
let res = await client.register('MyUsername', 'random-challenge-base64-encoded')
alert(JSON.stringify(res))
}
catch(e) {
alert(e)
}
}

window.login = async function() {
console.log('Authenticating...')
let res = client.authenticate([], 'random-challenge-base64-encoded')
console.log(res)
try {
let res = await client.authenticate([], 'random-challenge-base64-encoded')
alert(JSON.stringify(res))
}
catch(e) {
alert(e)
}
}

</script>
Expand Down
19 changes: 14 additions & 5 deletions demos/example-raw.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,25 @@

window.register = async function() {
console.log('Registering...')
let res = client.register('MyUsername', 'random-challenge-base64-encoded')
console.log(res)
try {
let res = await client.register('MyUsername', 'random-challenge-base64-encoded')
alert(JSON.stringify(res))
}
catch(e) {
alert(e)
}
}

window.login = async function() {
console.log('Authenticating...')
let res = client.authenticate([], 'random-challenge-base64-encoded')
console.log(res)
try {
let res = await client.authenticate([], 'random-challenge-base64-encoded')
alert(JSON.stringify(res))
}
catch(e) {
alert(e)
}
}

</script>
</body>
</html>
2 changes: 1 addition & 1 deletion dist/webauthn.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/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": "1.2.4",
"version": "1.2.5",
"description": "A small wrapper around the webauthn protocol to make one's life easier.",
"type": "module",
"main": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export async function register(username :string, challenge :string, options? :Re
name: window.location.hostname
},
user: {
id: await utils.sha256(new TextEncoder().encode(username)), // ID should not be directly "identifiable" for privacy concerns
id: await utils.sha256(new TextEncoder().encode('passwordless.id-user:' + username)), // ID should not be directly "identifiable" for privacy concerns
name: username,
displayName: username,
},
Expand Down

0 comments on commit d84259e

Please sign in to comment.