fix: do server side validation on blacklist
address validation imports a lot of files that rely on nodejs to run previouly the build was automatically adding polyfills for that
This commit is contained in:
parent
00dc3d0fcd
commit
62f39f3561
3 changed files with 27 additions and 26 deletions
|
|
@ -1,5 +1,6 @@
|
|||
const _ = require('lodash/fp')
|
||||
|
||||
const { addressDetector } = require('@lamassu/coins')
|
||||
const db = require('./db')
|
||||
const notifierQueries = require('./notifier/queries')
|
||||
|
||||
|
|
@ -16,7 +17,18 @@ const deleteFromBlacklist = address => {
|
|||
return db.none(sql, [address])
|
||||
}
|
||||
|
||||
const isValidAddress = address => {
|
||||
try {
|
||||
return !_.isEmpty(addressDetector.getSupportedCoinsForAddress(address).matches)
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
const insertIntoBlacklist = address => {
|
||||
if (!isValidAddress(address)) {
|
||||
return Promise.reject(new Error('Invalid address'))
|
||||
}
|
||||
return db
|
||||
.none(
|
||||
'INSERT INTO blacklist (address) VALUES ($1);',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue