#requires -Version 7.0
param([string]$Upstream = (Join-Path $PSScriptRoot '../upstream/SpaceNinjaServer'))
$ErrorActionPreference = 'Stop'
$taskRoot = [IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..'))
$lock = Get-Content -LiteralPath (Join-Path $Upstream 'package-lock.json') -Raw | ConvertFrom-Json -AsHashtable
$package = $lock.packages['node_modules/warframe-public-export-plus']
if (-not $package -or $package.integrity -notlike 'sha512-*') { throw 'A pinned SHA512 PublicExport dependency is required' }
$cache = Join-Path $taskRoot 'upstream/export'
New-Item -ItemType Directory -Path $cache -Force | Out-Null
$archive = Join-Path $cache 'package.tgz'
if (-not (Test-Path -LiteralPath $archive)) { Invoke-WebRequest -Uri $package.resolved -OutFile $archive }
$bytes = [IO.File]::ReadAllBytes($archive)
$digest = 'sha512-' + [Convert]::ToBase64String([Security.Cryptography.SHA512]::HashData($bytes))
if ($digest -ne $package.integrity) { throw 'PublicExport package integrity verification failed' }
tar -xzf $archive -C $cache
if ($LASTEXITCODE -ne 0) { throw 'PublicExport archive extraction failed' }
$destination = Join-Path $taskRoot 'Server/data/export'
New-Item -ItemType Directory -Path $destination -Force | Out-Null
Copy-Item -Path (Join-Path $cache 'package/Export*.json'),(Join-Path $cache 'package/dict.*.json') -Destination $destination -Force
@{name='warframe-public-export-plus'; version=$package.version; source=$package.resolved; integrity=$package.integrity} | ConvertTo-Json | Set-Content -LiteralPath (Join-Path $taskRoot 'Server/data/export-source.json') -Encoding utf8
Write-Output "Imported $($package.version); verified SHA512. Node.js is not needed."
#requires -Version 7.0
param([string]$Upstream = (Join-Path $PSScriptRoot '../upstream/SpaceNinjaServer'))
$ErrorActionPreference = 'Stop'
$taskRoot = [IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..'))
$lock = Get-Content -LiteralPath (Join-Path $Upstream 'package-lock.json') -Raw | ConvertFrom-Json -AsHashtable
$package = $lock.packages['node_modules/warframe-public-export-plus']
if (-not $package -or $package.integrity -notlike 'sha512-*') { throw 'A pinned SHA512 PublicExport dependency is required' }
$cache = Join-Path $taskRoot 'upstream/export'
New-Item -ItemType Directory -Path $cache -Force | Out-Null
$archive = Join-Path $cache 'package.tgz'
if (-not (Test-Path -LiteralPath $archive)) { Invoke-WebRequest -Uri $package.resolved -OutFile $archive }
$bytes = [IO.File]::ReadAllBytes($archive)
$digest = 'sha512-' + [Convert]::ToBase64String([Security.Cryptography.SHA512]::HashData($bytes))
if ($digest -ne $package.integrity) { throw 'PublicExport package integrity verification failed' }
tar -xzf $archive -C $cache
if ($LASTEXITCODE -ne 0) { throw 'PublicExport archive extraction failed' }
$destination = Join-Path $taskRoot 'Server/data/export'
New-Item -ItemType Directory -Path $destination -Force | Out-Null
Copy-Item -Path (Join-Path $cache 'package/Export*.json'),(Join-Path $cache 'package/dict.*.json') -Destination $destination -Force
@{name='warframe-public-export-plus'; version=$package.version; source=$package.resolved; integrity=$package.integrity} | ConvertTo-Json | Set-Content -LiteralPath (Join-Path $taskRoot 'Server/data/export-source.json') -Encoding utf8
Write-Output "Imported $($package.version); verified SHA512. Node.js is not needed."