param([string]$BaseUrl = 'http://direct-leaks.com/FFL/redemption')
$ErrorActionPreference = 'Stop'
$expectedSize = 21649326
$expectedHash = 'EBFED7BFADFC240CEA309CDE504C4CA57515B382743ECB5BCBB63FD3BD41A77F'
$nonce = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds()
$manifest = (Invoke-WebRequest "$BaseUrl/bundleManifest.json?verify=$nonce" -UseBasicParsing).Content | ConvertFrom-Json
$row = $manifest | Where-Object { $_.Name -eq 'FFRShared.resourceFile' }
if ($null -eq $row -or [int64]$row.Version -ne $expectedSize) {
    throw "STALE MANIFEST: remote FFRShared version is $($row.Version), expected $expectedSize"
}
$temp = Join-Path $env:TEMP "redemption-ffrshared-r48-$nonce.resourceFile"
try {
    Invoke-WebRequest "$BaseUrl/FFRShared.resourceFile?verify=$nonce" -UseBasicParsing -OutFile $temp
    $actualSize = (Get-Item $temp).Length
    $actualHash = (Get-FileHash $temp -Algorithm SHA256).Hash
    if ($actualSize -ne $expectedSize) { throw "STALE BUNDLE SIZE: $actualSize, expected $expectedSize" }
    if ($actualHash -ne $expectedHash) { throw "STALE BUNDLE HASH: $actualHash, expected $expectedHash" }
    Write-Host "UPLOAD VERIFIED: r48 white-wheel FFRShared is live" -ForegroundColor Green
} finally {
    Remove-Item $temp -Force -ErrorAction SilentlyContinue
}
