@aiwg/cockpit 2026.7.25 → 2026.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/vscode/smoke.mjs CHANGED
@@ -12,16 +12,24 @@ await writeFile(runtimePath, JSON.stringify({ token: 'vscode-shell-core-token-12
12
12
  const requests = [];
13
13
  globalThis.fetch = async (input, init = {}) => {
14
14
  requests.push({ url: String(input), init });
15
+ if (String(input).endsWith('/bootstrap/nonce')) {
16
+ return new Response(JSON.stringify({ nonce: 'vscode-one-time-nonce', expires_in_ms: 60000 }), {
17
+ status: 201,
18
+ headers: { 'Content-Type': 'application/json' },
19
+ });
20
+ }
15
21
  return new Response(JSON.stringify({ ok: true }), { status: 200, headers: { 'Content-Type': 'application/json' } });
16
22
  };
17
23
 
18
24
  const originalLoad = Module._load;
25
+ const commands = new Map();
26
+ const panel = { webview: { html: '' } };
19
27
  Module._load = function patchedLoad(request, parent, isMain) {
20
28
  if (request === 'vscode') {
21
29
  return {
22
30
  workspace: { getConfiguration: () => ({ get: () => runtimePath }) },
23
- window: { showWarningMessage: () => undefined, createWebviewPanel: () => ({ webview: { html: '' } }) },
24
- commands: { registerCommand: () => ({ dispose: () => undefined }) },
31
+ window: { showWarningMessage: () => undefined, createWebviewPanel: () => panel },
32
+ commands: { registerCommand: (name, callback) => { commands.set(name, callback); return { dispose: () => undefined }; } },
25
33
  env: { openExternal: () => undefined },
26
34
  Uri: { parse: (value) => ({ value }) },
27
35
  ViewColumn: { One: 1 },
@@ -40,6 +48,12 @@ try {
40
48
  requests.some((r) => r.url.endsWith('/api/health') && r.init.headers?.authorization === `Bearer ${rt.token}`),
41
49
  'shell-core performs the authenticated Bridge health check',
42
50
  );
51
+ extension.activate({ subscriptions: [] });
52
+ await commands.get('aiwg-cockpit.open')();
53
+ assert.match(panel.webview.html, /frame-src http:\/\/127\.0\.0\.1:8159;/, 'webview CSP permits only the resolved Bridge origin');
54
+ assert.doesNotMatch(panel.webview.html, /localhost:\*|127\.0\.0\.1:\*/, 'webview CSP has no wildcard local port');
55
+ assert.match(panel.webview.html, /#bootstrap=vscode-one-time-nonce&audience=vscode|#bootstrap=vscode-one-time-nonce&audience=vscode/, 'webview uses one-time fragment bootstrap');
56
+ assert.ok(!panel.webview.html.includes(rt.token), 'webview HTML does not contain the reusable token');
43
57
  console.log('SMOKE OK - VS Code shell delegates runtime resolution to shell-core');
44
58
  } finally {
45
59
  Module._load = originalLoad;