Skip to content

Commit 92e3e2e

Browse files
Gerbuuunatinux
andauthored
chore!: update simplewebauthn to v11
* chore: update simplewebauthn to v11 * docs: update readme --------- Co-authored-by: Sébastien Chopin <[email protected]>
1 parent 0f84e17 commit 92e3e2e

File tree

6 files changed

+53
-43
lines changed

6 files changed

+53
-43
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ To enable WebAuthn you need to:
296296
1. Install the peer dependencies:
297297

298298
```bash
299-
npx nypm i @simplewebauthn/server@10 @simplewebauthn/browser@10
299+
npx nypm i @simplewebauthn/server@11 @simplewebauthn/browser@11
300300
```
301301

302302
2. Enable it in your `nuxt.config.ts`

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
"uncrypto": "^0.1.3"
4444
},
4545
"peerDependencies": {
46-
"@simplewebauthn/browser": "^10.0.0",
47-
"@simplewebauthn/server": "^10.0.1"
46+
"@simplewebauthn/browser": "^11.0.0",
47+
"@simplewebauthn/server": "^11.0.0"
4848
},
4949
"peerDependenciesMeta": {
5050
"@simplewebauthn/browser": {
@@ -63,7 +63,7 @@
6363
"@nuxt/test-utils": "^3.14.2",
6464
"@nuxt/ui": "^2.18.6",
6565
"@nuxt/ui-pro": "^1.4.3",
66-
"@simplewebauthn/types": "^10.0.0",
66+
"@simplewebauthn/types": "^11.0.0",
6767
"changelogen": "^0.5.7",
6868
"eslint": "^9.12.0",
6969
"nuxt": "^3.13.2",

pnpm-lock.yaml

Lines changed: 24 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/runtime/app/composables/webauthn.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,18 @@ export function useWebAuthn(options: {
3131
* @default '/api/webauthn/authenticate'
3232
*/
3333
authenticateEndpoint?: string
34+
/**
35+
* Enable browser autofill for authentication
36+
* @default false
37+
*/
38+
useBrowserAutofill?: boolean
3439
} = {}): WebAuthnComposable {
35-
const { registerEndpoint = '/api/webauthn/register', authenticateEndpoint = '/api/webauthn/authenticate' } = options
40+
const {
41+
registerEndpoint = '/api/webauthn/register',
42+
authenticateEndpoint = '/api/webauthn/authenticate',
43+
useBrowserAutofill = false,
44+
} = options
45+
3646
async function register(user: { userName: string, displayName?: string }) {
3747
const { creationOptions, attemptId } = await $fetch<RegistrationInitResponse>(registerEndpoint, {
3848
method: 'POST',
@@ -42,7 +52,9 @@ export function useWebAuthn(options: {
4252
},
4353
})
4454

45-
const attestationResponse = await startRegistration(creationOptions)
55+
const attestationResponse = await startRegistration({
56+
optionsJSON: creationOptions,
57+
})
4658
const verificationResponse = await $fetch<VerifiedRegistrationResponse>(registerEndpoint, {
4759
method: 'POST',
4860
body: {
@@ -65,7 +77,10 @@ export function useWebAuthn(options: {
6577
},
6678
})
6779

68-
const assertionResponse = await startAuthentication(requestOptions)
80+
const assertionResponse = await startAuthentication({
81+
optionsJSON: requestOptions,
82+
useBrowserAutofill,
83+
})
6984
const verificationResponse = await $fetch<VerifiedAuthenticationResponse>(authenticateEndpoint, {
7085
method: 'POST',
7186
body: {

src/runtime/server/lib/webauthn/authenticate.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ export function defineWebAuthnAuthenticateEventHandler<T extends WebAuthnCredent
7171
expectedChallenge,
7272
expectedOrigin: url.origin,
7373
expectedRPID: url.hostname,
74-
authenticator: {
75-
credentialID: credential.id,
76-
credentialPublicKey: new Uint8Array(base64URLStringToBuffer(credential.publicKey)),
74+
credential: {
75+
id: credential.id,
76+
publicKey: new Uint8Array(base64URLStringToBuffer(credential.publicKey)),
7777
counter: credential.counter,
7878
transports: credential.transports,
7979
},

src/runtime/server/lib/webauthn/register.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ export function defineWebAuthnRegisterEventHandler<T extends WebAuthnUser>({
102102
await onSuccess(event, {
103103
user,
104104
credential: {
105-
id: verification.registrationInfo!.credentialID,
106-
publicKey: bufferToBase64URLString(verification.registrationInfo!.credentialPublicKey),
107-
counter: verification.registrationInfo!.counter,
105+
id: verification.registrationInfo!.credential.id,
106+
publicKey: bufferToBase64URLString(verification.registrationInfo!.credential.publicKey),
107+
counter: verification.registrationInfo!.credential.counter,
108108
backedUp: verification.registrationInfo!.credentialBackedUp,
109-
transports: body.response.response.transports,
109+
transports: verification.registrationInfo!.credential.transports,
110110
},
111111
registrationInfo: verification.registrationInfo!,
112112
})

0 commit comments

Comments
 (0)