File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44 * SPDX-License-Identifier: Apache-2.0
55 */
66
7+ import type { CDPSession } from '../third_party/index.js' ;
8+
79import { ToolCategory } from './categories.js' ;
810import { defineTool } from './ToolDefinition.js' ;
911
@@ -15,8 +17,11 @@ export const enableWebAuthn = defineTool({
1517 readOnlyHint : false ,
1618 } ,
1719 schema : { } ,
18- handler : async ( _request , response , _context ) => {
19- // Skeleton - does nothing yet
20- response . appendResponseLine ( 'WebAuthn enabled' ) ;
20+ handler : async ( _request , response , context ) => {
21+ const page = context . getSelectedPage ( ) ;
22+ // @ts -expect-error _client is internal Puppeteer API
23+ const session = page . _client ( ) as CDPSession ;
24+ await session . send ( 'WebAuthn.enable' ) ;
25+ response . appendResponseLine ( 'WebAuthn virtual authenticator environment enabled.' ) ;
2126 } ,
2227} ) ;
Original file line number Diff line number Diff line change @@ -12,11 +12,25 @@ import {withMcpContext} from '../utils.js';
1212
1313describe ( 'webauthn' , ( ) => {
1414 describe ( 'webauthn_enable' , ( ) => {
15- it ( 'can be called without error ' , async ( ) => {
15+ it ( 'enables WebAuthn so virtual authenticators can be added ' , async ( ) => {
1616 await withMcpContext ( async ( response , context ) => {
1717 await enableWebAuthn . handler ( { params : { } } , response , context ) ;
18- // If we get here without error, the tool exists and can be called
19- assert . ok ( true ) ;
18+
19+ // Verify WebAuthn is enabled by successfully adding a virtual authenticator
20+ // This will fail if WebAuthn.enable wasn't called
21+ const page = context . getSelectedPage ( ) ;
22+ // @ts -expect-error _client is internal Puppeteer API
23+ const session = page . _client ( ) ;
24+ const result = await session . send ( 'WebAuthn.addVirtualAuthenticator' , {
25+ options : {
26+ protocol : 'ctap2' ,
27+ transport : 'internal' ,
28+ hasResidentKey : true ,
29+ hasUserVerification : true ,
30+ isUserVerified : true ,
31+ } ,
32+ } ) ;
33+ assert . ok ( result . authenticatorId , 'Should return authenticator ID' ) ;
2034 } ) ;
2135 } ) ;
2236 } ) ;
You can’t perform that action at this time.
0 commit comments