Files
kestrove-desktop/native-messaging/install.ps1
T
samiandClaude Opus 5.5 923c466dea M3: working desktop app + browser pairing channel
- Builds and runs (tauri build --debug); placeholder icons; persistent VaultCore::open in the
  OS app-data dir; Secret Key remembered on the device; tray keeps the app serving the extension.
- Auto-lock: idle (system idle on Windows/macOS, in-app activity on Linux), screen lock, sleep.
- Local IPC for kestrove-nmh: 0700 dir + 0600 Unix socket with peer-uid checks; Windows named
  pipe (first instance, local only, user DACL, client SID check) behind cfg.
- Pairing channel: X25519 → HKDF → 6-word fingerprint confirmed in both UIs, per-connection
  session keys, AES-256-GCM with strict counters. Test vectors shared with kestrove-browser.
- Broker: query/fill/totp/save with origin re-checks; pairing and save prompts in the UI.
- kestrove-nmh relays ciphertext only; native-host installers for Linux/macOS/Windows.
- Tests: unit tests, tests/nmh_stdio.rs (real kestrove-nmh over stdio), examples/test-host.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-16 20:13:54 +09:00

62 lines
2.7 KiB
PowerShell

# Registers the Kestrove native-messaging host for the current user on Windows (HKCU, no admin).
# Linux/macOS: install.sh.
#
# powershell -ExecutionPolicy Bypass -File install.ps1 [-Nmh C:\path\kestrove-nmh.exe]
# [-ChromeId ID] [-FirefoxId ID] [-Browsers chrome,chromium,edge,firefox] [-Uninstall]
#
# Chrome and Brave share the Google\Chrome key. The manifests go to %LOCALAPPDATA%\Kestrove\NativeMessagingHosts.
# allowed_origins / allowed_extensions pin the host to our extension ids (docs/04 A8).
param(
[string]$Nmh = "",
[string]$ChromeId = "kogapfibnnpeapfcjkkpgjddbhnjfein",
[string]$FirefoxId = "[email protected]",
[string[]]$Browsers = @("chrome", "chromium", "edge", "firefox"),
[switch]$Uninstall
)
$ErrorActionPreference = "Stop"
$HostName = "app.kestrove.nmh"
$Here = Split-Path -Parent $MyInvocation.MyCommand.Path
if ($ChromeId -notmatch '^[a-p]{32}$') { throw "-ChromeId must be 32 letters a-p" }
if ($FirefoxId -notmatch '^[A-Za-z0-9._@{}-]+$') { throw "bad -FirefoxId" }
$Keys = @{
chrome = "HKCU:\Software\Google\Chrome\NativeMessagingHosts\$HostName"
chromium = "HKCU:\Software\Chromium\NativeMessagingHosts\$HostName"
edge = "HKCU:\Software\Microsoft\Edge\NativeMessagingHosts\$HostName"
firefox = "HKCU:\Software\Mozilla\NativeMessagingHosts\$HostName"
}
$OutDir = Join-Path $env:LOCALAPPDATA "Kestrove\NativeMessagingHosts"
if ($Uninstall) {
foreach ($b in $Browsers) {
if (Test-Path $Keys[$b]) { Remove-Item $Keys[$b] -Force; Write-Host "removed $($Keys[$b])" }
}
Remove-Item (Join-Path $OutDir "$HostName.*.json") -ErrorAction SilentlyContinue
return
}
if (-not $Nmh) {
foreach ($c in @((Join-Path $Here "kestrove-nmh.exe"), (Join-Path $Here "..\src-tauri\target\release\kestrove-nmh.exe"), (Join-Path $Here "..\src-tauri\target\debug\kestrove-nmh.exe"))) {
if (Test-Path $c) { $Nmh = $c; break }
}
}
if (-not $Nmh -or -not (Test-Path $Nmh)) { throw "kestrove-nmh.exe not found; pass -Nmh" }
$Nmh = (Resolve-Path $Nmh).Path
New-Item -ItemType Directory -Force -Path $OutDir | Out-Null
foreach ($flavor in @("chrome", "firefox")) {
$m = Get-Content -Raw (Join-Path $Here "$HostName.$flavor.json") | ConvertFrom-Json
$m.path = $Nmh
if ($flavor -eq "chrome") { $m.allowed_origins = @("chrome-extension://$ChromeId/") } else { $m.allowed_extensions = @($FirefoxId) }
$m | ConvertTo-Json -Depth 4 | Set-Content -Encoding UTF8 (Join-Path $OutDir "$HostName.$flavor.json")
}
foreach ($b in $Browsers) {
if (-not $Keys.ContainsKey($b)) { throw "unknown browser $b" }
$flavor = if ($b -eq "firefox") { "firefox" } else { "chrome" }
New-Item -Force -Path $Keys[$b] | Out-Null
Set-Item -Path $Keys[$b] -Value (Join-Path $OutDir "$HostName.$flavor.json")
Write-Host "registered $($Keys[$b])"
}