mikeee / ChocoPackages

Packages maintained by mikeee on Chocolatey
6 stars 4 forks source link

Fix broken packages #160

Open mikeee opened 3 weeks ago

mikeee commented 3 weeks ago
alemonmk commented 2 weeks ago

Hi @mikeee, For MSI Afterburner, it turns out you need to request their API with valid browser UA, certain headers and HTTP/2.

PS> $headers = @{
>> 'Sec-Fetch-Dest' = 'document'
>> 'Sec-Fetch-Mode' = 'navigate'
>> 'Accept-Encoding' = 'gzip, deflate, br, zstd'
>> }
PS> Invoke-RestMethod -UserAgent "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:127.0) Gecko/20100101 Firefox/127.0" -HttpVersion 2.0 -Headers $headers -Verbose https://www.msi.com/api/v1/get_token?date=$(Get-Date -format "yyyyMMddHH")
VERBOSE: Requested HTTP/2.0 GET with 0-byte payload
VERBOSE: Received HTTP/2.0 response of content type application/json of unknown size
VERBOSE: Content encoding: utf-8
exp=1730966218~acl=/*~hmac=5070da25b86d47eb3bab40b673df0e4e6040f886ed91206a825cca4ba9e81697

However, -HttpVersion only available with Powershell 7.3.0+, which would put a hard dependency on powershell-core though I would wonder who have choco but not powershell-core installed...

mikeee commented 2 weeks ago

Hi @mikeee, For MSI Afterburner, it turns out you need to request their API with valid browser UA, certain headers and HTTP/2.

PS> $headers = @{
>> 'Sec-Fetch-Dest' = 'document'
>> 'Sec-Fetch-Mode' = 'navigate'
>> 'Accept-Encoding' = 'gzip, deflate, br, zstd'
>> }
PS> Invoke-RestMethod -UserAgent "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:127.0) Gecko/20100101 Firefox/127.0" -HttpVersion 2.0 -Headers $headers -Verbose https://www.msi.com/api/v1/get_token?date=$(Get-Date -format "yyyyMMddHH")
VERBOSE: Requested HTTP/2.0 GET with 0-byte payload
VERBOSE: Received HTTP/2.0 response of content type application/json of unknown size
VERBOSE: Content encoding: utf-8
exp=1730966218~acl=/*~hmac=5070da25b86d47eb3bab40b673df0e4e6040f886ed91206a825cca4ba9e81697

However, -HttpVersion only available with Powershell 7.3.0+, which would put a hard dependency on powershell-core though I would wonder who have choco but not powershell-core installed...

Thank you for the heads up, the installer script was updated but I haven't had time to modify the update script adding a UA and headers- it's on my to-do list soon