fix: authorization header and threshold logic
This commit is contained in:
parent
904c383431
commit
57aaa7fb11
3 changed files with 13 additions and 10 deletions
|
|
@ -41,6 +41,8 @@ function post (machineTx, pi) {
|
||||||
|
|
||||||
walletScore = fetchedWalletScore
|
walletScore = fetchedWalletScore
|
||||||
|
|
||||||
|
console.log(fetchedWalletScore)
|
||||||
|
|
||||||
if (_.some(it => it.address === updatedTx.toAddress)(blacklistItems)) {
|
if (_.some(it => it.address === updatedTx.toAddress)(blacklistItems)) {
|
||||||
blacklisted = true
|
blacklisted = true
|
||||||
notifier.notifyIfActive('compliance', 'blacklistNotify', r.tx, false)
|
notifier.notifyIfActive('compliance', 'blacklistNotify', r.tx, false)
|
||||||
|
|
@ -109,6 +111,7 @@ function postProcess (r, pi, isBlacklisted, addressReuse, walletScore) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_.isNil(walletScore) && !walletScore.isValid) {
|
if (!_.isNil(walletScore) && !walletScore.isValid) {
|
||||||
|
console.log('aaaaaaaa')
|
||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
walletScore: walletScore.score,
|
walletScore: walletScore.score,
|
||||||
operatorCompleted: true,
|
operatorCompleted: true,
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@ const MANUAL = 'manual'
|
||||||
const CASH_OUT_DISPENSE_READY = 'cash_out_dispense_ready'
|
const CASH_OUT_DISPENSE_READY = 'cash_out_dispense_ready'
|
||||||
const CONFIRMATION_CODE = 'sms_code'
|
const CONFIRMATION_CODE = 'sms_code'
|
||||||
|
|
||||||
|
const WALLET_SCORE_THRESHOLD = 9
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
anonymousCustomer,
|
anonymousCustomer,
|
||||||
CASSETTE_MAX_CAPACITY,
|
CASSETTE_MAX_CAPACITY,
|
||||||
|
|
@ -34,5 +36,6 @@ module.exports = {
|
||||||
CASH_OUT_DISPENSE_READY,
|
CASH_OUT_DISPENSE_READY,
|
||||||
CONFIRMATION_CODE,
|
CONFIRMATION_CODE,
|
||||||
CASH_OUT_MINIMUM_AMOUNT_OF_CASSETTES,
|
CASH_OUT_MINIMUM_AMOUNT_OF_CASSETTES,
|
||||||
CASH_OUT_MAXIMUM_AMOUNT_OF_CASSETTES
|
CASH_OUT_MAXIMUM_AMOUNT_OF_CASSETTES,
|
||||||
|
WALLET_SCORE_THRESHOLD
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,25 +16,22 @@ function getClient(account) {
|
||||||
|
|
||||||
const apiVersion = ctv1.slice(-2)
|
const apiVersion = ctv1.slice(-2)
|
||||||
const authHeader = {
|
const authHeader = {
|
||||||
"Authorization": account
|
"Authorization": account.authorizationValue
|
||||||
}
|
}
|
||||||
return { apiVersion, authHeader }
|
return { apiVersion, authHeader }
|
||||||
}
|
}
|
||||||
|
|
||||||
function rateWallet(account, cryptoCode, address) {
|
function rateWallet(account, cryptoCode, address) {
|
||||||
const client = getClient(account)
|
const client = getClient(account)
|
||||||
console.log('client', client)
|
|
||||||
if (!_.includes(_.toUpper(cryptoCode), SUPPORTED_COINS) || _.isNil(client)) return Promise.resolve(null)
|
if (!_.includes(_.toUpper(cryptoCode), SUPPORTED_COINS) || _.isNil(client)) return Promise.resolve(null)
|
||||||
|
|
||||||
const { apiVersion, authHeader } = client
|
const { apiVersion, authHeader } = client
|
||||||
const score = Math.floor(Math.random() * (10 - 1 + 1)) + 1
|
const threshold = _.isNil(account) ? WALLET_SCORE_THRESHOLD : account.scoreThreshold
|
||||||
const threshold = _.isNil(account.scoreThreshold) ? WALLET_SCORE_THRESHOLD : account.scoreThreshold
|
|
||||||
return Promise.resolve({ address, score, isValid: score < threshold })
|
|
||||||
|
|
||||||
// return axios.get(`https://rest.ciphertrace.com/aml/${apiVersion}/${_.toLower(cryptoCode)}/risk?address=${address}`, {
|
return axios.get(`https://rest.ciphertrace.com/aml/${apiVersion}/${_.toLower(cryptoCode)}/risk?address=${address}`, {
|
||||||
// headers: authHeader
|
headers: authHeader
|
||||||
// })
|
})
|
||||||
// .then(res => ({ address, score: res.risk, isValid: res.risk <= SCORE_THRESHOLD }))
|
.then(res => ({ address, score: res.data.risk, isValid: res.data.risk < threshold }))
|
||||||
}
|
}
|
||||||
|
|
||||||
function isValidWalletScore(account, score) {
|
function isValidWalletScore(account, score) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue