Skip to content

Commit

Permalink
Merge pull request #1172 from RafaelTaranto/feat/standardize-sencha-p…
Browse files Browse the repository at this point in the history
…arams

LAM-1154 feat: standardize sencha params
  • Loading branch information
RafaelTaranto authored Aug 30, 2024
2 parents 57d3ee4 + f5b2357 commit 1ef05b9
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions lib/update/updater.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict'

const crypto = require('crypto')
var https = require('https')
var Agent = https.Agent
var os = require('os')
Expand Down Expand Up @@ -108,15 +109,6 @@ function fetchVersion (config) {
return packageJson.version
}

function fetchPackages () {
try {
var manifest = JSON.parse(fs.readFileSync('/opt/apps/machine/manifest.json'))
return manifest.packages || []
} catch (ex) {
return []
}
}

Updater.prototype._init = function _init () {
var dataPath = path.resolve(__dirname, '..', '..', this.config.dataPath)

Expand All @@ -138,7 +130,6 @@ Updater.prototype._init = function _init () {
}

this.version = fetchVersion(this.config)
this.installedPackages = fetchPackages()

this.httpsOptions = this._httpsOptions()
return true
Expand All @@ -158,10 +149,10 @@ Updater.prototype._httpsOptions = function _httpsOptions () {
rejectUnauthorized: true,
headers: {
'application-version': this.version,
'installed-packages': this.installedPackages.join(','),
'device-id': this.deviceId,
'device-arch': process.arch,
'node-version': process.version
'node-version': process.version,
'device-os': os.release()
}
}
options.agent = new Agent(options)
Expand Down Expand Up @@ -205,6 +196,14 @@ Updater.prototype.updateHeaders = function updateHeaders (options) {
var machineInfo = machineInfoLoader.load(dataPath)
var watchdogInfo = watchdogInfoLoader.load(dataPath)

var connectionInfoPath = path.resolve(dataPath, 'connection_info.json')
const connectionInfo = JSON.parse(fs.readFileSync(connectionInfoPath))

if (connectionInfo.host) {
options = _.assign(options, {
'device-host': crypto.createHash('sha256').update(connectionInfo.host).digest('hex')
})
}
if (machineInfo.active) {
if (machineInfo.deviceId) {
options = _.assign(options, {
Expand Down

0 comments on commit 1ef05b9

Please sign in to comment.