okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
8a11d125d
main
1# Fetch and verify the private Node runtime the Windows desktop bundle ships (win-x64). 2# 3# The PowerShell twin of fetch-node.sh: same pinned version, same SHA-256 pin, same refusal to 4# install anything whose digest does not match. Not committed output: node.exe is a ~90 MB binary. 5# 6# Usage: 7# powershell -NoProfile -ExecutionPolicy Bypass -File apps\desktop\scripts\fetch-node.ps1 8# ... -File fetch-node.ps1 -Check # verify what is already installed 9# ... -File fetch-node.ps1 -FromFile node.zip # verify and install a zip you already have (offline) 10# 11# The Node version must satisfy the App Host's own engines.node (>= 24.12.0). 12[CmdletBinding ()] 13param ( 14 [switch ]$Check , 15 [string ]$FromFile ='' , 16 [string ]$Dest ='' 17) 18$ErrorActionPreference ='Stop' 19 20$NodeVersion =if ($env:STRATA_NODE_VERSION ) {$env:STRATA_NODE_VERSION }else {'24.12.0' } 21$Target ='win-x64' 22# SHA-256 of node-v24.12.0-win-x64.zip from nodejs.org's SHASUMS256.txt; keep equal to fetch-node.sh. 23$Expected ='9c125f61ae947b52e779095830f9cac267846a043ef7192183c84016aaad2812' 24if (-not $Dest ) {$Dest =Join-Path $PSScriptRoot '..\src-tauri\resources\node' } 25$Installed =Join-Path $Dest 'node.exe' 26 27function Fail ([string ]$Message ) { [Console ]::Error .WriteLine ("fetch-node: $Message " );exit 1 } 28 29if ($Check ) { 30if (-not (Test-Path -LiteralPath$Installed )) {Fail "not installed at $Installed " } 31$got = (& $Installed --version).Trim () 32Write-Output "fetch-node: $Installed is $got " 33if ($got -ne "v $NodeVersion " ) {Fail "expected v $NodeVersion " } 34exit 0 35} 36 37$Archive ="node-v $NodeVersion - $Target .zip" 38$Work =Join-Path ([IO.Path ]::GetTempPath ()) ("strata-node-" + [Guid ]::NewGuid ().ToString ('N' )) 39New-Item -ItemType Directory -Path$Work |Out-Null 40try { 41$Zip =Join-Path $Work $Archive 42if ($FromFile ) { 43Copy-Item -LiteralPath$FromFile -Destination$Zip 44 }else { 45$Url ="https://nodejs.org/dist/v $NodeVersion / $Archive " 46Write-Output "fetch-node: $Url " 47 [Net.ServicePointManager ]::SecurityProtocol = [Net.SecurityProtocolType ]::Tls12 48$ProgressPreference ='SilentlyContinue' 49Invoke-WebRequest -UseBasicParsing -Uri$Url -OutFile$Zip 50 } 51$Actual = (Get-FileHash -Algorithm SHA256 -LiteralPath$Zip ).Hash .ToLowerInvariant () 52if ($NodeVersion -ne '24.12.0' ) { 53# another version has no recorded digest: say so rather than implying a verification 54 [Console ]::Error .WriteLine ("fetch-node: WARNING - no recorded digest for v $NodeVersion ; this download is NOT authenticated." ) 55 [Console ]::Error .WriteLine ("fetch-node: computed sha256 $Actual - record it in this script and fetch-node.sh." ) 56 }elseif ($Actual -ne $Expected ) { 57Fail "REFUSING - $Archive hashes $Actual , expected $Expected " 58 }else { 59Write-Output 'fetch-node: sha256 verified against the recorded digest' 60 } 61Add-Type -AssemblyName System.IO.Compression.FileSystem 62$zipFile = [IO.Compression.ZipFile ]::OpenRead ($Zip ) 63try { 64$entry =$zipFile .GetEntry ("node-v $NodeVersion - $Target /node.exe" ) 65if (-not $entry ) {Fail "node.exe is not inside $Archive " } 66New-Item -ItemType Directory -Force -Path$Dest |Out-Null 67 [IO.Compression.ZipFileExtensions ]::ExtractToFile ($entry ,$Installed ,$true ) 68 }finally {$zipFile .Dispose () } 69Write-Output "fetch-node: installed at $Installed " 70}finally { 71Remove-Item -LiteralPath$Work -Recurse -Force -ErrorAction SilentlyContinue 72}