@applitools/eg-frpc
Version:
Application that yada yada yada.
54 lines (45 loc) • 1.34 kB
JavaScript
const fs = require('fs')
const crypto = require('crypto')
const frpcVersion = '0.50.0'
module.exports = {frpcVersion, getExpectedBinHash, getBinHash, getSupportedPlatformAndArchList}
const supportedPlatformAndArch = [
{
platform: 'win32',
arch: 'x64',
},
{
platform: 'darwin',
arch: 'x64',
},
{
platform: 'darwin',
arch: 'arm64',
},
{
platform: 'linux',
arch: 'x64',
},
{
platform: 'linux',
arch: 'arm64',
},
]
const binHashMap = new Map()
binHashMap.set('darwin_x64', 'UsbqUbdsYsyzOytQiRy8MkVeI258/t6vM0B54JSpaLg=')
binHashMap.set('darwin_arm64', 'L+Cy6yWh+dQru0KibGKXLp5jyVSi5faHtqC4C05zOEQ=')
binHashMap.set('linux_x64', 'HQp32iV8gbgqg4Cq6YL+gk3rdXjIYKS6QnU6DMQv6Cs=')
binHashMap.set('linux_arm64', 'e0dyLES6Yl03fypHU3DtjeetC96h2XgRtj/j+kgeypg=')
binHashMap.set('win32_x64', 'kmm5sxaggKjnrMRjejpyl31poBai1GF1a/xl1JBpguc=')
function getExpectedBinHash({platform, arch}) {
const key = `${platform}_${arch}`
return binHashMap.has(key) ? binHashMap.get(key) : undefined
}
function getSupportedPlatformAndArchList() {
return supportedPlatformAndArch
}
async function getBinHash(frpcBinPath) {
const hash = crypto.createHash('sha256')
const buffer = await fs.promises.readFile(frpcBinPath)
const actualHash = hash.update(buffer).digest('base64')
return actualHash
}