chore: use monorepo organization
This commit is contained in:
parent
deaf7d6ecc
commit
a687827f7e
1099 changed files with 8184 additions and 11535 deletions
34
packages/server/lib/compliance-triggers.js
Normal file
34
packages/server/lib/compliance-triggers.js
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
const _ = require('lodash/fp')
|
||||
|
||||
function getBackwardsCompatibleTriggers (triggers) {
|
||||
const filtered = _.filter(_.matches({ triggerType: 'txVolume', direction: 'both', thresholdDays: 1 }))(triggers)
|
||||
const grouped = _.groupBy(_.prop('requirement'))(filtered)
|
||||
return _.mapValues(_.compose(_.get('threshold'), _.minBy('threshold')))(grouped)
|
||||
}
|
||||
|
||||
function hasSanctions (triggers) {
|
||||
return _.some(_.matches({ requirement: 'sanctions' }))(triggers)
|
||||
}
|
||||
|
||||
function maxDaysThreshold (triggers) {
|
||||
return _.max(_.map('thresholdDays')(triggers))
|
||||
}
|
||||
|
||||
function getCashLimit (triggers) {
|
||||
const withFiat = _.filter(({ triggerType }) => _.includes(triggerType, ['txVolume', 'txAmount']))
|
||||
const blocking = _.filter(({ requirement }) => _.includes(requirement, ['block', 'suspend']))
|
||||
return _.compose(_.minBy('threshold'), blocking, withFiat)(triggers)
|
||||
}
|
||||
|
||||
const hasRequirement = requirement => _.compose(_.negate(_.isEmpty), _.find(_.matches({ requirement })))
|
||||
|
||||
const hasPhone = hasRequirement('sms')
|
||||
const hasFacephoto = hasRequirement('facephoto')
|
||||
const hasIdScan = hasRequirement('idCardData')
|
||||
|
||||
const AUTH_METHODS = {
|
||||
SMS: 'SMS',
|
||||
EMAIL: 'EMAIL'
|
||||
}
|
||||
|
||||
module.exports = { getBackwardsCompatibleTriggers, hasSanctions, maxDaysThreshold, getCashLimit, hasPhone, hasFacephoto, hasIdScan, AUTH_METHODS }
|
||||
Loading…
Add table
Add a link
Reference in a new issue