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
5
bin/hkdf
5
bin/hkdf
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
'use strict'
|
||||
|
||||
const HKDF = require('node-hkdf-sync')
|
||||
const hkdf = require('futoin-hkdf')
|
||||
|
||||
const label = process.argv[2]
|
||||
const masterSeedHex = process.argv[3].trim()
|
||||
|
|
@ -14,5 +14,4 @@ if (process.argv.length !== 4) {
|
|||
}
|
||||
|
||||
const masterSeed = new Buffer(masterSeedHex, 'hex')
|
||||
const hkdf = new HKDF('sha256', 'lamassu-server-salt', masterSeed)
|
||||
console.log(hkdf.derive(label, 32).toString('hex'))
|
||||
console.log(hkdf(masterSeed, 32, {salt: 'lamassu-server-salt', info: label}).toString('hex'))
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
const _ = require('lodash/fp')
|
||||
const mem = require('mem')
|
||||
const HKDF = require('node-hkdf-sync')
|
||||
const hkdf = require('futoin-hkdf')
|
||||
|
||||
const configManager = require('./config-manager')
|
||||
const pify = require('pify')
|
||||
|
|
@ -24,8 +24,7 @@ function httpError (msg, code) {
|
|||
}
|
||||
|
||||
function computeSeed (masterSeed) {
|
||||
const hkdf = new HKDF('sha256', 'lamassu-server-salt', masterSeed)
|
||||
return hkdf.derive('wallet-seed', 32)
|
||||
return hkdf(masterSeed, 32, {salt: 'lamassu-server-salt', info: 'wallet-seed'}).toString('hex')
|
||||
}
|
||||
|
||||
function fetchWallet (settings, cryptoCode) {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
"express-limiter": "^1.6.0",
|
||||
"express-rate-limit": "^2.9.0",
|
||||
"express-ws": "^3.0.0",
|
||||
"futoin-hkdf": "^1.0.2",
|
||||
"got": "^7.1.0",
|
||||
"helmet": "^3.8.1",
|
||||
"inquirer": "^5.2.0",
|
||||
|
|
@ -42,7 +43,6 @@
|
|||
"morgan": "^1.8.2",
|
||||
"nano-markdown": "^1.2.0",
|
||||
"ndjson": "^1.5.0",
|
||||
"node-hkdf-sync": "^1.0.0",
|
||||
"numeral": "^2.0.3",
|
||||
"p-each-series": "^1.0.0",
|
||||
"pg-native": "^2.2.0",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue