Skip to content

Commit ce3a0ed

Browse files
feat(webauthn): implement WebAuthn.enable CDP call
The webauthn_enable tool now actually calls the CDP WebAuthn.enable command, enabling the virtual authenticator environment. Test verifies this by successfully adding a virtual authenticator after calling the tool. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 5f35101 commit ce3a0ed

2 files changed

Lines changed: 25 additions & 6 deletions

File tree

src/tools/webauthn.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
import type {CDPSession} from '../third_party/index.js';
8+
79
import {ToolCategory} from './categories.js';
810
import {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
});

tests/tools/webauthn.test.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,25 @@ import {withMcpContext} from '../utils.js';
1212

1313
describe('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
});

0 commit comments

Comments
 (0)