Files
bookmarks-api/tools/install-native-host.ps1
T

42 lines
1.5 KiB
PowerShell

# Register the native messaging host for the current Windows user.
# Does not load the Firefox extension — see README / AGENTS.md.
$ErrorActionPreference = "Stop"
$Root = Split-Path -Parent $PSScriptRoot
$HostDir = Join-Path $Root "host"
$CmdPath = Join-Path $HostDir "firefox-agent-bridge-host.cmd"
$ManifestPath = Join-Path $HostDir "com.easygoingaming.firefox_agent_bridge.json"
$StateDir = Join-Path $env:LOCALAPPDATA "firefox-agent-bridge"
$TokenPath = Join-Path $StateDir "token"
$HostName = "com.easygoingaming.firefox_agent_bridge"
$ExtensionId = "firefox-agent-bridge@easygoingaming.com"
if (-not (Test-Path $CmdPath)) {
throw "host launcher missing: $CmdPath"
}
New-Item -ItemType Directory -Force -Path $StateDir | Out-Null
if (Test-Path $TokenPath) {
Remove-Item -Force $TokenPath
Write-Host "removed leftover shared token $TokenPath"
}
$manifest = @{
name = $HostName
description = "Bookmarks API native host"
path = $CmdPath
type = "stdio"
allowed_extensions = @($ExtensionId)
} | ConvertTo-Json -Compress
[System.IO.File]::WriteAllText($ManifestPath, $manifest)
Write-Host "wrote $ManifestPath"
$regPath = "HKCU:\Software\Mozilla\NativeMessagingHosts\$HostName"
New-Item -Path $regPath -Force | Out-Null
Set-ItemProperty -Path $regPath -Name "(default)" -Value $ManifestPath
Write-Host "registered $regPath"
Write-Host ""
Write-Host "Load the add-on, then use the toolbar icon → Manage clients to generate a secret."
Write-Host "Store that secret with your other secrets. Do not keep it under $StateDir."