@@ -4,24 +4,23 @@ import { createPasskey, createUser } from '#tests/db-utils.ts'
44import { test , expect } from '#tests/test-extend.ts'
55
66async function createWebAuthnClient ( page : Page ) {
7- const client = await page . context ( ) . newCDPSession ( page )
8- await client . send ( 'WebAuthn.enable' )
7+ const session = await page . context ( ) . newCDPSession ( page )
8+ await session . send ( 'WebAuthn.enable' )
99
10- const result = await client . send ( 'WebAuthn.addVirtualAuthenticator' , {
10+ const authenticator = await session . send ( 'WebAuthn.addVirtualAuthenticator' , {
1111 options : {
1212 protocol : 'ctap2' ,
1313 transport : 'internal' ,
1414 hasResidentKey : true ,
1515 hasUserVerification : true ,
1616 isUserVerified : true ,
17- // Authenticator will automatically respond to the next prompt in the browser.
1817 automaticPresenceSimulation : true ,
1918 } ,
2019 } )
2120
2221 return {
23- client ,
24- authenticatorId : result . authenticatorId ,
22+ session ,
23+ authenticatorId : authenticator . authenticatorId ,
2524 }
2625}
2726
@@ -30,23 +29,19 @@ test('authenticates using an existing passkey', async ({ navigate, page }) => {
3029
3130 await navigate ( '/login' )
3231
33- // Create a test passkey.
3432 const passkey = createTestPasskey ( {
3533 rpId : new URL ( page . url ( ) ) . hostname ,
3634 } )
3735
38- // Add the passkey to the server.
3936 await using _ = await createPasskey ( {
4037 id : passkey . credential . credentialId ,
38+ userId : user . id ,
4139 aaguid : passkey . credential . aaguid || '' ,
4240 publicKey : passkey . publicKey ,
43- userId : user . id ,
44- counter : passkey . credential . signCount ,
4541 } )
4642
47- // Add the passkey to the browser.
48- const { client, authenticatorId } = await createWebAuthnClient ( page )
49- await client . send ( 'WebAuthn.addCredential' , {
43+ const { session, authenticatorId } = await createWebAuthnClient ( page )
44+ await session . send ( 'WebAuthn.addCredential' , {
5045 authenticatorId,
5146 credential : {
5247 ...passkey . credential ,
@@ -68,8 +63,8 @@ test('displays an error when authenticating via a passkey fails', async ({
6863} ) => {
6964 await navigate ( '/login' )
7065
71- const { client , authenticatorId } = await createWebAuthnClient ( page )
72- await client . send ( 'WebAuthn.setUserVerified' , {
66+ const { session , authenticatorId } = await createWebAuthnClient ( page )
67+ await session . send ( 'WebAuthn.setUserVerified' , {
7368 authenticatorId,
7469 isUserVerified : false ,
7570 } )
0 commit comments