Skip to content

Commit 9105770

Browse files
ryanbas21claude
andcommitted
fix(vscode): run full OIDC annotation pipeline via handleMessage
The VS Code extension was calling buildNetworkEvent directly, bypassing the OIDC annotation pipeline (annotateOidc, detectDpop, detectPar), well-known config discovery, and causal linking. Now uses the same handleMessage + EventStoreInMemory pipeline as the browser extension. Also adds .vscode/launch.json for Extension Development Host, fixes viewsContainers icon to use SVG file instead of invalid codicon syntax, and removes "type": "module" which prevented CJS extension from loading. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent cfe6703 commit 9105770

7 files changed

Lines changed: 68 additions & 14 deletions

File tree

e2e/mock-oidc-server/start.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { createMockOidcServer } from './server.js';
2+
3+
const { baseUrl } = await createMockOidcServer(3000);
4+
console.log(`Mock OIDC server running at ${baseUrl}`);
5+
console.log(`Test app: ${baseUrl}/test-app`);
6+
console.log('Press Ctrl+C to stop.');
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Run Extension",
6+
"type": "extensionHost",
7+
"request": "launch",
8+
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
9+
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
10+
}
11+
]
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"type": "npm",
6+
"script": "build",
7+
"problemMatcher": [],
8+
"label": "npm: build",
9+
"group": "build"
10+
}
11+
]
12+
}
Lines changed: 4 additions & 0 deletions
Loading

packages/vscode-extension/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"publisher": "wolfcola",
77
"license": "MIT",
88
"private": true,
9-
"type": "module",
109
"engines": {
1110
"vscode": "^1.100.0"
1211
},
@@ -44,7 +43,7 @@
4443
{
4544
"id": "oidc-devtools",
4645
"title": "OIDC DevTools",
47-
"icon": "$(shield)"
46+
"icon": "icons/oidc-devtools.svg"
4847
}
4948
]
5049
},

packages/vscode-extension/src/extension.ts

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as vscode from 'vscode';
2+
import { Effect, ManagedRuntime } from 'effect';
23
import { OidcDebugConfigProvider } from './launch/debug-config-provider.js';
34
import { CdpClient } from './cdp/cdp-client.js';
45
import { discoverTargets, findPageTarget } from './cdp/target-discovery.js';
@@ -7,25 +8,39 @@ import { TimelineTreeProvider } from './providers/timeline-tree.js';
78
import { StatusBar } from './status-bar.js';
89
import { FlowWebviewPanel } from './panels/flow-webview.js';
910
import {
10-
buildNetworkEvent,
11+
handleMessage,
12+
EventStoreService,
13+
EventStoreInMemory,
14+
runDiagnosis,
15+
serializeDiagnosis,
1116
redactFlowState,
1217
renderFlowMarkdown,
13-
runDiagnosis,
1418
} from '@wolfcola/devtools-core';
1519
import type { HarEntry } from '@wolfcola/devtools-core';
16-
import type { AuthEvent } from '@wolfcola/devtools-types';
17-
import type { FlowState } from '@wolfcola/devtools-types';
20+
import type { AuthEvent, FlowState } from '@wolfcola/devtools-types';
1821

1922
let cdpClient: CdpClient | null = null;
2023

2124
export function activate(context: vscode.ExtensionContext): void {
2225
const timeline = new TimelineTreeProvider();
2326
const statusBar = new StatusBar();
27+
const runtime = ManagedRuntime.make(EventStoreInMemory);
2428

2529
vscode.window.registerTreeDataProvider('oidc-devtools.timeline', timeline);
2630

2731
const flowPanel = new FlowWebviewPanel(context.extensionUri);
2832

33+
function processEvent(event: AuthEvent): void {
34+
timeline.addEvent(event);
35+
flowPanel.sendEvent(event);
36+
statusBar.setEventCount(timeline.eventCount);
37+
38+
// Run diagnosis and send to webview
39+
const events = timeline.getEvents();
40+
const diagnosis = runDiagnosis(events);
41+
flowPanel.sendDiagnosis(serializeDiagnosis(diagnosis));
42+
}
43+
2944
const startCmd = vscode.commands.registerCommand('oidc-devtools.startCapture', async () => {
3045
const portInput = await vscode.window.showInputBox({
3146
prompt: 'Chrome debug port',
@@ -56,18 +71,23 @@ export function activate(context: vscode.ExtensionContext): void {
5671
vscode.window.showInformationMessage(`Connected to: ${target.title}`);
5772

5873
cdpClient.on('harEntry', (entry: HarEntry) => {
59-
const event = buildNetworkEvent(entry, null, null);
60-
if (!event.flags.isAuthRelated) return;
61-
timeline.addEvent(event);
62-
flowPanel.sendEvent(event);
63-
statusBar.setEventCount(timeline.eventCount);
74+
runtime
75+
.runPromise(handleMessage({ type: 'NETWORK_EVENT', payload: entry }))
76+
.then((result) => {
77+
if (result) processEvent(result as AuthEvent);
78+
})
79+
.catch(console.error);
6480
});
6581

6682
cdpClient.on('sdkEvent', (_name: string, payload: unknown) => {
6783
const sdkPayload = (payload as { payload?: unknown }).payload;
68-
if (sdkPayload && typeof sdkPayload === 'object') {
69-
timeline.addEvent(sdkPayload as AuthEvent);
70-
statusBar.setEventCount(timeline.eventCount);
84+
if (sdkPayload) {
85+
runtime
86+
.runPromise(handleMessage({ type: 'SDK_EVENT', payload: sdkPayload }))
87+
.then((result) => {
88+
if (result) processEvent(result as AuthEvent);
89+
})
90+
.catch(console.error);
7191
}
7292
});
7393

@@ -92,6 +112,7 @@ export function activate(context: vscode.ExtensionContext): void {
92112
const clearCmd = vscode.commands.registerCommand('oidc-devtools.clearEvents', () => {
93113
timeline.clear();
94114
statusBar.setEventCount(0);
115+
runtime.runPromise(handleMessage({ type: 'CLEAR' })).catch(console.error);
95116
});
96117

97118
const exportCmd = vscode.commands.registerCommand('oidc-devtools.exportFlow', async () => {

screenshots/vscode-1.png

96.3 KB
Loading

0 commit comments

Comments
 (0)