; Kestrove NSIS installer hooks (tauri.conf.json → bundle.windows.nsis.installerHooks). ; Registers the browser extension's native messaging host for the current user (HKCU, no admin), like ; native-messaging/install.ps1: a manifest next to kestrove-nmh.exe ("path" relative to the manifest, which ; Chrome and Firefox allow on Windows) and one registry key per browser. ; Extension ids: keep in sync with kestrove-apple/App/BrowserIntegration.swift (NativeHostRegistration). ; Chrome: the Chrome Web Store build, then the unpacked development build (pinned by the manifest key). !define KV_HOST "app.kestrove.nmh" !define KV_CHROME_ORIGINS '"chrome-extension://pmhfoafjoogobhfadaicklhkldgnafmk/", "chrome-extension://kogapfibnnpeapfcjkkpgjddbhnjfein/"' !define KV_FIREFOX_IDS '"browser@kestrove.app"' ; A browser keeps kestrove-nmh.exe running while the extension is connected, which locks the file: an update then ; can't replace it and an uninstall can't delete it. The installer only closes the app itself, so stop the helper ; too. It holds no state (it only relays encrypted messages); the browser starts it again when it's next needed. !macro KV_STOP_HELPER nsExec::Exec '"$SYSDIR\taskkill.exe" /F /IM kestrove-nmh.exe' Pop $0 Sleep 500 !macroend !macro NSIS_HOOK_PREINSTALL !insertmacro KV_STOP_HELPER !macroend !macro NSIS_HOOK_POSTINSTALL FileOpen $0 "$INSTDIR\${KV_HOST}.chrome.json" w FileWrite $0 '{"name": "${KV_HOST}", "description": "Kestrove", "path": "kestrove-nmh.exe", "type": "stdio", "allowed_origins": [${KV_CHROME_ORIGINS}]}' FileClose $0 FileOpen $0 "$INSTDIR\${KV_HOST}.firefox.json" w FileWrite $0 '{"name": "${KV_HOST}", "description": "Kestrove", "path": "kestrove-nmh.exe", "type": "stdio", "allowed_extensions": [${KV_FIREFOX_IDS}]}' FileClose $0 WriteRegStr HKCU "Software\Google\Chrome\NativeMessagingHosts\${KV_HOST}" "" "$INSTDIR\${KV_HOST}.chrome.json" WriteRegStr HKCU "Software\Chromium\NativeMessagingHosts\${KV_HOST}" "" "$INSTDIR\${KV_HOST}.chrome.json" WriteRegStr HKCU "Software\Microsoft\Edge\NativeMessagingHosts\${KV_HOST}" "" "$INSTDIR\${KV_HOST}.chrome.json" WriteRegStr HKCU "Software\BraveSoftware\Brave-Browser\NativeMessagingHosts\${KV_HOST}" "" "$INSTDIR\${KV_HOST}.chrome.json" WriteRegStr HKCU "Software\Vivaldi\NativeMessagingHosts\${KV_HOST}" "" "$INSTDIR\${KV_HOST}.chrome.json" WriteRegStr HKCU "Software\Mozilla\NativeMessagingHosts\${KV_HOST}" "" "$INSTDIR\${KV_HOST}.firefox.json" !macroend !macro NSIS_HOOK_PREUNINSTALL !insertmacro KV_STOP_HELPER DeleteRegKey HKCU "Software\Google\Chrome\NativeMessagingHosts\${KV_HOST}" DeleteRegKey HKCU "Software\Chromium\NativeMessagingHosts\${KV_HOST}" DeleteRegKey HKCU "Software\Microsoft\Edge\NativeMessagingHosts\${KV_HOST}" DeleteRegKey HKCU "Software\BraveSoftware\Brave-Browser\NativeMessagingHosts\${KV_HOST}" DeleteRegKey HKCU "Software\Vivaldi\NativeMessagingHosts\${KV_HOST}" DeleteRegKey HKCU "Software\Mozilla\NativeMessagingHosts\${KV_HOST}" Delete "$INSTDIR\${KV_HOST}.chrome.json" Delete "$INSTDIR\${KV_HOST}.firefox.json" !macroend