Skip to content

feat: expose sharedSessionCookies on WebviewOptions#27

Open
ibetitsmike wants to merge 1 commit intomainfrom
mike/webview-shared-session-cookies
Open

feat: expose sharedSessionCookies on WebviewOptions#27
ibetitsmike wants to merge 1 commit intomainfrom
mike/webview-shared-session-cookies

Conversation

@ibetitsmike
Copy link
Collaborator

Adds a new sharedSessionCookies option to vscode.WebviewOptions so extension-authored desktop webviews can send VS Code's existing Electron session cookies to explicitly allowlisted external origins.

Changes

  • Public API – new sharedSessionCookies?: { allowedOrigins: readonly string[] } on WebviewOptions in vscode.d.ts
  • Protocol plumbingIWebviewContentOptions, ext-host serialization, main-thread revival, and internal WebviewContentOptions all carry the new field
  • Policy helpernormalizeSharedSessionCookies validates/normalizes origins (HTTPS-only except localhost, dedupes, rejects paths/credentials/wildcards)
  • Runtime – preload index.html forwards the policy to the service worker; service worker intercepts allowlisted external-origin requests with credentials: 'include'
  • Safety – desktop/Electron only (browser/web silently ignores); existing iframe sandbox, origin isolation, and postMessage checks are unchanged
  • Tests – serialization, equality, main-thread revival, and cookie policy validation

Add a new sharedSessionCookies option to vscode.WebviewOptions that
allows extension-authored desktop webviews to send existing Electron
session cookies to explicitly allowlisted external origins.

- Add sharedSessionCookies to the public API (vscode.d.ts)
- Plumb through ext-host serialization, protocol, and main-thread revival
- Add normalizeSharedSessionCookies helper with origin validation
- Update areWebviewContentOptionsEqual for the new field
- Propagate policy to preload index.html and service worker
- Service worker intercepts allowlisted external-origin requests with
  credentials: 'include'
- Add tests for serialization, equality, and cookie policy validation
- Desktop/Electron only; browser/web builds safely ignore the option
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant