Skip to content

Commit

Permalink
updated docs, tests & version
Browse files Browse the repository at this point in the history
  • Loading branch information
dagnelies committed Mar 11, 2024
1 parent efed234 commit 748d359
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 20 deletions.
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import * as webauthn from '@passwordless-id/webauthn'

```html
<script type="module">
import { client } from 'https://unpkg.com/@passwordless-id/webauthn@1.4.1/dist/webauthn.min.js'
import { client } from 'https://unpkg.com/@passwordless-id/webauthn@1.5.0/dist/webauthn.min.js'
</script>
```
### Import
Expand Down Expand Up @@ -135,7 +135,7 @@ const registration = await client.register("Arnaud", challenge, {
userVerification: "required",
timeout: 60000,
attestation: true,
userHandle: "recommended to set it to a random 64 bytes value",
userHandle: "Optional server-side user id. Must not reveal personal information.",
debug: false
})
```
Expand Down Expand Up @@ -189,7 +189,10 @@ Example result:
},
"authenticator": {
...
"name": "Windows Hello Hardware Authenticator"
"name": "Windows Hello",
"icon_dark": "https://webauthn.passwordless.id/authenticators/08987058-cadc-4b81-b6e1-30de50dcbe96-dark.png",
"icon_light": "https://webauthn.passwordless.id/authenticators/08987058-cadc-4b81-b6e1-30de50dcbe96-light.png",
"synced": true
},
...
}
Expand Down Expand Up @@ -396,7 +399,7 @@ Registration options

- `discoverable`: (`'discouraged'`, `'preferred'` or `'required'`) If the credential is "discoverable", it can be selected using `authenticate` without providing credential IDs. In that case, a native pop-up will appear for user selection. This may have an impact on the "passkeys" user experience and syncing behavior of the key. *(Default: 'preferred')*
- `attestation`: If enabled, the device attestation and clientData will be provided as base64 encoded binary data. Note that this may impact the authenticator information available or the UX depending on the platform. *(Default: false)*
- `userHandle`: The `userHandle` can be used to re-register credentials for an existing user, thus overriding the current the key pair and username for that `userHandle`. *The default here is based on a hash of the `username`, and thus has some security implications as described in [issue](https://github.com/passwordless-id/webauthn/issues/29). For optimal security and privacy, it is recommended to set the `userHandle` to a random 64 bytes value.*
- `userHandle`: The user "handle" (also known as user "id") can be used to re-register credentials for an existing user, thus overriding the current credential key pair and username for that `userHandle`. *The default here is based on a hash of the `username`, and thus has some security implications as described in [issue](https://github.com/passwordless-id/webauthn/issues/29).*


Authentication options
Expand Down Expand Up @@ -454,7 +457,10 @@ parsers.parseRegistration({
},
"counter": 0,
"aaguid": "08987058-cadc-4b81-b6e1-30de50dcbe96",
"name": "Windows Hello Hardware Authenticator"
"name": "Windows Hello",
"icon_dark": "https://webauthn.passwordless.id/authenticators/08987058-cadc-4b81-b6e1-30de50dcbe96-dark.png",
"icon_light": "https://webauthn.passwordless.id/authenticators/08987058-cadc-4b81-b6e1-30de50dcbe96-light.png",
"synced": true
},
"attestation": null
}
Expand Down Expand Up @@ -540,7 +546,10 @@ parsers.parseAuthenticator("SZYN5YgOjGh0NBcPZHZgW4_krrmihjLHmVzzuoMdl2NFAAAAAAiY
},
"counter": 0,
"aaguid": "08987058-cadc-4b81-b6e1-30de50dcbe96",
"name": "Windows Hello Hardware Authenticator"
"name": "Windows Hello",
"icon_dark": "https://webauthn.passwordless.id/authenticators/08987058-cadc-4b81-b6e1-30de50dcbe96-dark.png",
"icon_light": "https://webauthn.passwordless.id/authenticators/08987058-cadc-4b81-b6e1-30de50dcbe96-light.png",
"synced": true
}
```

Expand Down
2 changes: 1 addition & 1 deletion demos/example-cdn.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


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

window.register = async function() {
console.log('Registering...')
Expand Down
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.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.4.1",
"version": "1.5.0",
"description": "A small wrapper around the webauthn protocol to make one's life easier.",
"type": "module",
"main": "dist/esm/index.js",
Expand Down
3 changes: 1 addition & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,10 @@ export async function authenticate(credentialIds :string[], challenge :string, o

const authentication :AuthenticationEncoded = {
credentialId: auth.id,
//userHash: utils.toBase64url(response.userHandle), // unreliable, optional for authenticators
authenticatorData: utils.toBase64url(response.authenticatorData),
clientData: utils.toBase64url(response.clientDataJSON),
signature: utils.toBase64url(response.signature),
userHandle: response.userHandle ? utils.toBase64url(response.userHandle) : null
userHandle: response.userHandle ? utils.toBase64url(response.userHandle) : undefined // may not be returned by every authenticator
}

return authentication
Expand Down
13 changes: 10 additions & 3 deletions src/parsers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ test('Test parseRegistration', async () => {
},
"counter": 0,
"aaguid": "08987058-cadc-4b81-b6e1-30de50dcbe96",
"name": "Windows Hello Hardware Authenticator"
"icon_dark": "https://webauthn.passwordless.id/authenticators/08987058-cadc-4b81-b6e1-30de50dcbe96-dark.png",
"icon_light": "https://webauthn.passwordless.id/authenticators/08987058-cadc-4b81-b6e1-30de50dcbe96-light.png",
"name": "Windows Hello",
"synced": false,
},
"attestation": null
})
Expand Down Expand Up @@ -69,7 +72,8 @@ test('Test parseAuthentication', async () => {
"attestedData": false,
"extensionsIncluded": false
},
"counter": 1
"counter": 1,
"synced": false
},
"signature": "MEUCIAqtFVRrn7q9HvJCAsOhE3oKJ-Hb4ISfjABu4lH70MKSAiEA666slmop_oCbmNZdc-QemTv2Rq4g_D7UvIhWT_vVp8M="
})
Expand All @@ -90,7 +94,10 @@ test('Test parseAuthenticator', async () => {
},
"counter": 0,
"aaguid": "08987058-cadc-4b81-b6e1-30de50dcbe96",
"name": "Windows Hello Hardware Authenticator"
"icon_dark": "https://webauthn.passwordless.id/authenticators/08987058-cadc-4b81-b6e1-30de50dcbe96-dark.png",
"icon_light": "https://webauthn.passwordless.id/authenticators/08987058-cadc-4b81-b6e1-30de50dcbe96-light.png",
"name": "Windows Hello",
"synced": false,
})
})

Expand Down
5 changes: 4 additions & 1 deletion src/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ test('Test README registration example', async () => {
},
"counter": 0,
"aaguid": "08987058-cadc-4b81-b6e1-30de50dcbe96",
"name": "Windows Hello Hardware Authenticator"
"icon_dark": "https://webauthn.passwordless.id/authenticators/08987058-cadc-4b81-b6e1-30de50dcbe96-dark.png",
"icon_light": "https://webauthn.passwordless.id/authenticators/08987058-cadc-4b81-b6e1-30de50dcbe96-light.png",
"name": "Windows Hello",
"synced": false,
},
"attestation": null
})
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface AuthenticationEncoded {
authenticatorData: string
clientData: string
signature: string
userHandle?: string | null
userHandle?: string
}

export interface AuthenticationParsed {
Expand Down

0 comments on commit 748d359

Please sign in to comment.