Add operator id on CoinATMRadar request (#184)
* Add operator id on CoinATMRadar request * Update coinatmradar.js
This commit is contained in:
parent
2fd4cd50c5
commit
5ee7e40872
4 changed files with 16 additions and 10 deletions
|
|
@ -1,5 +1,9 @@
|
|||
const axios = require('axios')
|
||||
const _ = require('lodash/fp')
|
||||
const hkdf = require('futoin-hkdf')
|
||||
|
||||
const pify = require('pify')
|
||||
const fs = pify(require('fs'))
|
||||
|
||||
const db = require('../db')
|
||||
const configManager = require('../config-manager')
|
||||
|
|
@ -125,9 +129,9 @@ function sendRadar (data) {
|
|||
|
||||
function mapRecord (info) {
|
||||
const timestamp = new Date().toISOString()
|
||||
return getMachines(info)
|
||||
.then(machines => ({
|
||||
operatorId: options.operatorId,
|
||||
return Promise.all([getMachines(info), fs.readFile(options.seedPath, 'utf8')])
|
||||
.then(([machines, hex]) => ({
|
||||
operatorId: computeOperatorId(Buffer.from(hex.trim(), 'hex')),
|
||||
operator: {
|
||||
name: null,
|
||||
phone: null,
|
||||
|
|
@ -147,3 +151,7 @@ function update (info) {
|
|||
.then(sendRadar)
|
||||
.catch(err => logger.error(err))
|
||||
}
|
||||
|
||||
function computeOperatorId (masterSeed) {
|
||||
return hkdf(masterSeed, 32, {salt: 'lamassu-server-salt', info: 'operator-id'}).toString('hex')
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue