Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* ModusBox
- Georgi Georgiev
- Valentin Genev
- Rajiv Mothilal
--------------
******/
'use strict'
/**
* @module src/handlers/transfers
*/
const Logger = require('@mojaloop/central-services-logger')
const Kafka = require('@mojaloop/central-services-shared').Util.Kafka
const Consumer = require('@mojaloop/central-services-stream').Util.Consumer
const Enum = require('@mojaloop/central-services-shared').Enum
const Time = require('@mojaloop/central-services-shared').Util.Time
const ErrorHandler = require('@mojaloop/central-services-error-handling')
const Comparators = require('@mojaloop/central-services-shared').Util.Comparators
const Config = require('../../lib/config')
const TransferService = require('../../domain/transfer')
const Db = require('../../lib/db')
const httpPostRelatedActions = [Enum.Events.Event.Action.RECORD_FUNDS_IN, Enum.Events.Event.Action.RECORD_FUNDS_OUT_PREPARE_RESERVE]
const httpPutRelatedActions = [Enum.Events.Event.Action.RECORD_FUNDS_OUT_COMMIT, Enum.Events.Event.Action.RECORD_FUNDS_OUT_ABORT]
const allowedActions = [].concat(httpPostRelatedActions).concat(httpPutRelatedActions)
const createRecordFundsInOut = async (payload, transactionTimestamp, enums) => {
/** @namespace Db.getKnex **/
const knex = Db.getKnex()
Logger.info(`AdminTransferHandler::${payload.action}::validationPassed::newEntry`)
// Save the valid transfer into the database
******/
'use strict'
/**
* @module src/handlers/positions
*/
const Logger = require('@mojaloop/central-services-logger')
const EventSdk = require('@mojaloop/event-sdk')
const TransferService = require('../../domain/transfer')
const PositionService = require('../../domain/position')
const Utility = require('@mojaloop/central-services-shared').Util
const Kafka = require('@mojaloop/central-services-shared').Util.Kafka
const Producer = require('@mojaloop/central-services-stream').Util.Producer
const Consumer = require('@mojaloop/central-services-stream').Util.Consumer
const Enum = require('@mojaloop/central-services-shared').Enum
const Metrics = require('@mojaloop/central-services-metrics')
const Config = require('../../lib/config')
const Uuid = require('uuid4')
const decodePayload = require('@mojaloop/central-services-shared').Util.StreamingProtocol.decodePayload
const decodeMessages = require('@mojaloop/central-services-shared').Util.StreamingProtocol.decodeMessages
const ErrorHandler = require('@mojaloop/central-services-error-handling')
const location = { module: 'PositionHandler', method: '', path: '' } // var object used as pointer
const consumerCommit = true
const fromSwitch = true
/**
* @function positions
*
* @async
- Name Surname
* Georgi Georgiev
* Rajiv Mothilal
* Valentin Genev
--------------
******/
'use strict'
/**
* @module src/models/position/
*/
const Db = require('../../lib/db')
const Enum = require('@mojaloop/central-services-shared').Enum
const participantFacade = require('../participant/facade')
const Logger = require('@mojaloop/central-services-logger')
const Time = require('@mojaloop/central-services-shared').Util.Time
const MLNumber = require('@mojaloop/ml-number')
const ErrorHandler = require('@mojaloop/central-services-error-handling')
const Config = require('../../lib/config')
const prepareChangeParticipantPositionTransaction = async (transferList) => {
try {
const knex = await Db.getKnex()
const participantName = transferList[0].value.content.payload.payerFsp
const currencyId = transferList[0].value.content.payload.amount.currency
const participantCurrency = await participantFacade.getByNameAndCurrency(participantName, currencyId, Enum.Accounts.LedgerAccountType.POSITION)
const processedTransfers = {} // The list of processed transfers - so that we can store the additional information around the decision. Most importantly the "running" position
const reservedTransfers = []
const abortedTransfers = []
* Georgi Georgiev
* Valentin Genev
* Rajiv Mothilal
* Miguel de Barros
* Shashikant Hirugade
--------------
******/
'use strict'
/**
* @module src/models/transfer/facade/
*/
const Db = require('../../lib/db')
const Enum = require('@mojaloop/central-services-shared').Enum
const TransferEventAction = Enum.Events.Event.Action
const TransferInternalState = Enum.Transfers.TransferInternalState
const TransferExtensionModel = require('./transferExtension')
const ParticipantFacade = require('../participant/facade')
const Time = require('@mojaloop/central-services-shared').Util.Time
const MLNumber = require('@mojaloop/ml-number')
const Config = require('../../lib/config')
const _ = require('lodash')
const ErrorHandler = require('@mojaloop/central-services-error-handling')
const Logger = require('@mojaloop/central-services-logger')
// Alphabetically ordered list of error texts used below
const UnsupportedActionText = 'Unsupported action'
const getById = async (id) => {
try {
* ModusBox
- Georgi Georgiev
- Valentin Genev
- Nikolay Anastasov
- Shashikant Hirugade
- Rajiv Mothilal
--------------
******/
'use strict'
const Model = require('../../../src/domain/participant')
const ParticipantCurrencyModel = require('../../../src/models/participant/participantCurrency')
const time = require('@mojaloop/central-services-shared').Util.Time
const Enum = require('@mojaloop/central-services-shared').Enum
const ErrorHandler = require('@mojaloop/central-services-error-handling')
const testParticipant = {
name: 'fsp',
currency: 'USD',
isDisabled: 0,
createdDate: new Date()
}
exports.prepareData = async (name, currencyId = 'USD', isUnique = true) => {
try {
const participantId = await Model.create(Object.assign(
{},
testParticipant,
{
name: (name || testParticipant.name) + (isUnique ? time.msToday().toString() : '')
Names of the original copyright holders (individuals or organizations)
should be listed with a '*' in the first column. People who have
contributed from an organization can be listed under the organization
that actually holds the copyright for their contributions (see the
Gates Foundation organization for an example). Those individuals should have
their names indented and be marked with a '-'. Email address can be added
optionally within square brackets .
* Gates Foundation
- Name Surname
* Valentin Genev
* Nikolay Anastasov
--------------
******/
'use strict'
const transferStateENUM = require('@mojaloop/central-services-shared').Enum.Transfers.TransferInternalState
const transferStateResult = []
for (const transferState of Object.keys(transferStateENUM)) {
transferStateResult.push({
transferStateId: transferState
})
}
exports.prepareData = () => {
return transferStateResult
}
* ModusBox
- Georgi Georgiev
- Rajiv Mothilal
--------------
******/
'use strict'
/**
* @module src/handlers/timeout
*/
const CronJob = require('cron').CronJob
const Config = require('../../lib/config')
const TimeoutService = require('../../domain/timeout')
const Enum = require('@mojaloop/central-services-shared').Enum
const Kafka = require('@mojaloop/central-services-shared').Util.Kafka
const Producer = require('@mojaloop/central-services-stream').Util.Producer
const Utility = require('@mojaloop/central-services-shared').Util
const ErrorHandler = require('@mojaloop/central-services-error-handling')
const EventSdk = require('@mojaloop/event-sdk')
let timeoutJob
let isRegistered
/**
* @function TransferTimeoutHandler
*
* @async
* @description This is the consumer callback function that gets registered to a cron job.
*
* ... called to validate/insert ...
******/
'use strict'
/**
* @module src/handlers/transfers
*/
const Logger = require('@mojaloop/central-services-logger')
const EventSdk = require('@mojaloop/event-sdk')
const TransferService = require('../../domain/transfer')
const Util = require('@mojaloop/central-services-shared').Util
const Kafka = require('@mojaloop/central-services-shared').Util.Kafka
const Producer = require('@mojaloop/central-services-stream').Util.Producer
const Consumer = require('@mojaloop/central-services-stream').Util.Consumer
const Validator = require('./validator')
const Enum = require('@mojaloop/central-services-shared').Enum
const TransferState = Enum.Transfers.TransferState
const TransferEventType = Enum.Events.Event.Type
const TransferEventAction = Enum.Events.Event.Action
const TransferObjectTransform = require('../../domain/transfer/transform')
const Metrics = require('@mojaloop/central-services-metrics')
const Config = require('../../lib/config')
const decodePayload = require('@mojaloop/central-services-shared').Util.StreamingProtocol.decodePayload
const Comparators = require('@mojaloop/central-services-shared').Util.Comparators
const ErrorHandler = require('@mojaloop/central-services-error-handling')
const consumerCommit = true
const fromSwitch = true
const toDestination = true
/**
* @function TransferPrepareHandler
******/
'use strict'
/**
* @module src/handlers/transfers
*/
const Logger = require('@mojaloop/central-services-logger')
const Decimal = require('decimal.js')
const Config = require('../../lib/config')
const Participant = require('../../domain/participant')
const Transfer = require('../../domain/transfer')
const CryptoConditions = require('../../cryptoConditions')
const Crypto = require('crypto')
const base64url = require('base64url')
const Enum = require('@mojaloop/central-services-shared').Enum
const ErrorHandler = require('@mojaloop/central-services-error-handling')
const allowedScale = Config.AMOUNT.SCALE
const allowedPrecision = Config.AMOUNT.PRECISION
const reasons = []
const validateParticipantById = async function (participantId) {
const participant = await Participant.getById(participantId)
if (!participant) {
reasons.push(`Participant ${participantId} not found`)
}
return !!participant
}
const validateParticipantByName = async function (participantName) {
const participant = await Participant.getByName(participantName)
Gates Foundation organization for an example). Those individuals should have
their names indented and be marked with a '-'. Email address can be added
optionally within square brackets .
* Gates Foundation
- Name Surname
* Georgi Georgiev
--------------
******/
'use strict'
/**
* @module src/domain/transfer/
*/
const Enum = require('@mojaloop/central-services-shared').Enum
const BulkTransferAssociationModel = require('../../models/bulkTransfer/bulkTransferAssociation')
const BulkTransferDuplicateCheckModel = require('../../models/bulkTransfer/bulkTransferDuplicateCheck')
const BulkTransferFulfilmentDuplicateCheckModel = require('../../models/bulkTransfer/bulkTransferFulfilmentDuplicateCheck')
const BulkTransferExtensionModel = require('../../models/bulkTransfer/bulkTransferExtension')
const BulkTransferFacade = require('../../models/bulkTransfer/facade')
const BulkTransferModel = require('../../models/bulkTransfer/bulkTransfer')
const BulkTransferStateChangeModel = require('../../models/bulkTransfer/bulkTransferStateChange')
const IndividualTransferModel = require('../../models/bulkTransfer/individualTransfer')
const IndividualTransferExtensionModel = require('../../models/transfer/transferExtension')
const MLNumber = require('@mojaloop/ml-number')
const Logger = require('@mojaloop/central-services-logger')
const getBulkTransferById = async (id) => {
try {
const bulkTransfer = await BulkTransferModel.getById(id)
let individualTransfers = await IndividualTransferModel.getAllById(id)