fix: allow Web Store extension native messaging
- Add the Chrome Web Store extension ID alongside the keyed testing ID. - Register both extension origins in the native messaging host manifest. - Update install output so users can distinguish testing and Web Store IDs. - Add CLI coverage for the generated allowed_origins list.
This commit is contained in:
@@ -9,10 +9,12 @@ import click
|
||||
from rich.console import Console
|
||||
|
||||
from browser_cli.constants import (
|
||||
ALLOWED_EXTENSION_IDS,
|
||||
EXTENSION_ID,
|
||||
NATIVE_HOST_DIRS,
|
||||
NATIVE_HOST_NAME,
|
||||
SUPPORTED_BROWSERS,
|
||||
WEBSTORE_EXTENSION_ID,
|
||||
WINDOWS_NATIVE_HOST_REGISTRY_KEYS,
|
||||
)
|
||||
from browser_cli.platform import install_base_dir, is_windows
|
||||
@@ -75,14 +77,15 @@ def cmd_install(browser):
|
||||
console.print(f" 1. Open [cyan]{ext_url}[/cyan]")
|
||||
console.print(" 2. Enable [bold]Developer mode[/bold] (top-right toggle)")
|
||||
console.print(f" 3. Click [bold]Load unpacked[/bold] → select: [cyan]{Path(__file__).parent.parent.parent / 'extension'}[/cyan]")
|
||||
console.print(f" 4. Extension ID will be [cyan]{EXTENSION_ID}[/cyan] (fixed by built-in key)\n")
|
||||
console.print(f" 4. Testing extension ID will be [cyan]{EXTENSION_ID}[/cyan] (fixed by built-in key)")
|
||||
console.print(f" Chrome Web Store extension ID is [cyan]{WEBSTORE_EXTENSION_ID}[/cyan]\n")
|
||||
|
||||
manifest = {
|
||||
"name": NATIVE_HOST_NAME,
|
||||
"description": "browser-cli native messaging host",
|
||||
"path": str(host_exe),
|
||||
"type": "stdio",
|
||||
"allowed_origins": [f"chrome-extension://{EXTENSION_ID}/"],
|
||||
"allowed_origins": [f"chrome-extension://{extension_id}/" for extension_id in ALLOWED_EXTENSION_IDS],
|
||||
}
|
||||
installed = _install_manifest(browser, host_exe, manifest)
|
||||
if not installed:
|
||||
|
||||
Reference in New Issue
Block a user