@mojaloop/central-ledger 19.14.0 → 20.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.grype.yaml +3 -0
- package/.license-scanner.json +16 -0
- package/.ncurc.yaml +19 -13
- package/.nvmrc +1 -1
- package/.nycrc.yml +14 -2
- package/CHANGELOG.md +51 -0
- package/Dockerfile +13 -10
- package/README.md +39 -89
- package/audit-ci.jsonc +1 -1
- package/config/default.json +60 -3
- package/config/deprecated.default-settlement.json +160 -0
- package/docker/ml-api-adapter/default.json +28 -0
- package/docker-compose.yml +6 -0
- package/nodemon.json +6 -0
- package/package.json +128 -64
- package/{sbom-v19.13.2.csv → sbom-v20.0.0.csv} +886 -736
- package/scripts/_wait4_all.js +5 -5
- package/scripts/transferSettlementTemp/interchangeFeeCalculation.js +51 -0
- package/src/api/index.ts +30 -0
- package/src/api/interface/swagger.json +2249 -2054
- package/src/api/participants/routes.js +1 -1
- package/src/api/root/handler.int.ts +55 -0
- package/src/api/routes.js +7 -6
- package/src/api/server.ts +27 -0
- package/src/api/server.unit.ts +16 -0
- package/src/api/settlementModels/routes.js +4 -4
- package/src/domain/participant/index.d.ts +47 -0
- package/src/domain/participant/index.int.ts +724 -0
- package/src/domain/participant/index.js +4 -5
- package/src/domain/position/fx-prepare.js +1 -1
- package/src/domain/position/fx-timeout-reserved.js +6 -0
- package/src/domain/position/prepare.js +1 -1
- package/src/handlers/admin/handler.js +1 -1
- package/src/handlers/index.js +30 -0
- package/src/handlers/positions/handler.js +0 -2
- package/src/handlers/positions/handlerBatch.js +5 -5
- package/src/handlers/register.js +44 -29
- package/src/handlers/timeouts/handler.js +1 -4
- package/src/handlers/transfers/fx-abort.int.ts +209 -0
- package/src/handlers/transfers/fx-handlers.int.ts +275 -0
- package/src/handlers/transfers/fx-timeout.int.ts +284 -0
- package/src/handlers/transfers/handler.js +1 -3
- package/src/handlers/transfers/handlers.int.ts +538 -0
- package/src/handlers/transfers/prepare.int.ts +1283 -0
- package/src/handlers/transfers/prepare.js +2 -2
- package/src/knexfile.js +19 -0
- package/src/lib/cache.js +1 -1
- package/src/lib/config/index.ts +60 -0
- package/src/lib/config/resolver.ts +231 -0
- package/src/lib/config/resolver.unit.ts +72 -0
- package/src/lib/config/types.ts +372 -0
- package/src/lib/config/util.ts +523 -0
- package/src/lib/config/util.unit.ts +825 -0
- package/src/lib/migrator.js +3 -3
- package/src/lib/proxyCache.js +3 -3
- package/{migrations → src/migrations}/100100_event.js +1 -1
- package/{migrations → src/migrations}/110100_contactType.js +1 -1
- package/{migrations → src/migrations}/110200_currency.js +1 -1
- package/{migrations → src/migrations}/110201_currency-scale.js +1 -1
- package/{migrations → src/migrations}/110300_endpointType.js +1 -1
- package/{migrations → src/migrations}/110400_ledgerEntryType.js +1 -1
- package/{migrations → src/migrations}/110450_ledgerAccountType.js +1 -1
- package/{migrations → src/migrations}/110500_participantLimitType.js +1 -1
- package/{migrations → src/migrations}/110600_transferParticipantRoleType.js +1 -1
- package/{migrations → src/migrations}/110700_transferState.js +1 -1
- package/{migrations → src/migrations}/110900_settlementState.js +1 -1
- package/{migrations → src/migrations}/112000_bulkTransferState.js +1 -1
- package/{migrations → src/migrations}/112100_bulkProcessingState.js +1 -1
- package/{migrations → src/migrations}/200100_participant.js +1 -1
- package/{migrations → src/migrations}/200200_participantContact.js +1 -1
- package/{migrations → src/migrations}/200300_participantEndpoint.js +1 -1
- package/{migrations → src/migrations}/200400_participantParty.js +1 -1
- package/{migrations → src/migrations}/200600_token.js +1 -1
- package/{migrations → src/migrations}/200601_token-indexes.js +1 -1
- package/{migrations → src/migrations}/300100_transferDuplicateCheck.js +2 -2
- package/{migrations → src/migrations}/300150_bulkTransferDuplicateCheck.js +2 -2
- package/{migrations → src/migrations}/300200_transfer.js +2 -2
- package/{migrations → src/migrations}/300202_transfer-decimal184.js +1 -1
- package/{migrations → src/migrations}/300250_bulkTransfer.js +2 -3
- package/{migrations → src/migrations}/300275_bulkTransferAssociation.js +2 -3
- package/{migrations → src/migrations}/300300_ilpPacket.js +1 -1
- package/{migrations → src/migrations}/300400_transferStateChange.js +1 -1
- package/{migrations → src/migrations}/300450_bulkTransferStateChange.js +1 -1
- package/{migrations → src/migrations}/300500_segment.js +1 -1
- package/{migrations → src/migrations}/310100_participantCurrency.js +1 -1
- package/{migrations → src/migrations}/310200_transferParticipant.js +1 -1
- package/{migrations → src/migrations}/310202_transferParticipant-decimal184.js +1 -1
- package/{migrations → src/migrations}/310204_transferParticipant-participantId.js +2 -2
- package/{migrations → src/migrations}/310300_participantPosition.js +1 -1
- package/{migrations → src/migrations}/310302_participantPosition-decimal184.js +1 -1
- package/{migrations → src/migrations}/310400_participantPositionChange.js +1 -1
- package/{migrations → src/migrations}/310402_participantPositionChange-decimal184.js +1 -1
- package/{migrations → src/migrations}/310403_participantPositionChange-participantCurrencyId.js +2 -2
- package/{migrations → src/migrations}/310404_participantPositionChange-change.js +2 -2
- package/{migrations → src/migrations}/310500_participantLimit.js +1 -1
- package/{migrations → src/migrations}/310502_participantLimit-decimal184.js +1 -1
- package/{migrations → src/migrations}/400100_settlementWindow.js +1 -1
- package/{migrations → src/migrations}/400200_settlement.js +1 -1
- package/{migrations → src/migrations}/400300_settlementSettlementWindow.js +1 -1
- package/{migrations → src/migrations}/400301_settlementSettlementWindow-indexes.js +0 -1
- package/{migrations → src/migrations}/400400_settlementWindowStateChange.js +1 -1
- package/{migrations → src/migrations}/400500_settlementTransferParticipant.js +1 -1
- package/{migrations → src/migrations}/400502_settlementTransferParticipant-decimal184.js +1 -1
- package/{migrations → src/migrations}/400600_settlementParticipantCurrency.js +1 -1
- package/{migrations → src/migrations}/400602_settlementParticipantCurrency-decimal184.js +1 -1
- package/{migrations → src/migrations}/400700_settlementParticipantCurrencyStateChange.js +1 -1
- package/{migrations → src/migrations}/400800_settlementStateChange.js +1 -1
- package/{migrations → src/migrations}/400900_settlementWindowContent.js +1 -1
- package/{migrations → src/migrations}/401000_settlementWindowContentStateChange.js +1 -1
- package/{migrations → src/migrations}/401001_settlementWindowContentStateChange-indexes.js +6 -6
- package/{migrations → src/migrations}/401200_settlementContentAggregation.js +1 -1
- package/{migrations → src/migrations}/401300_settlementModel.js +1 -1
- package/{migrations → src/migrations}/410100_transferFulfilmentDuplicateCheck.js +1 -1
- package/{migrations → src/migrations}/410102_transferFulfilmentDuplicateCheck-dropForeignTransferId.js +1 -1
- package/{migrations → src/migrations}/410103_transferFulfilmentDuplicateCheck-hashNullable.js +1 -1
- package/{migrations → src/migrations}/410200_transferFulfilment.js +1 -1
- package/{migrations → src/migrations}/410202_transferFulfilment-ilpFulfilment.js +1 -1
- package/{migrations → src/migrations}/410203_transferFulfilment-foreignTransferFulfilmentId.js +1 -1
- package/{migrations → src/migrations}/410240_bulkTransferFulfilmentDuplicateCheck.js +1 -1
- package/{migrations → src/migrations}/410250_bulkTransferFulfilment.js +1 -1
- package/{migrations → src/migrations}/410300_transferExtension.js +1 -1
- package/{migrations → src/migrations}/410302_transferExtension-transferErrorId.js +1 -1
- package/{migrations → src/migrations}/410350_bulkTransferExtension.js +1 -1
- package/{migrations → src/migrations}/410400_transferTimeout.js +1 -1
- package/{migrations → src/migrations}/410450_transferErrorDuplicateCheck.js +1 -1
- package/{migrations → src/migrations}/410500_transferError.js +1 -1
- package/{migrations → src/migrations}/410502_transferError-foreignTransferErrorDuplicateCheckId.js +1 -1
- package/{migrations → src/migrations}/410550_bulkTransferError.js +1 -1
- package/{migrations → src/migrations}/410600_expiringTransfer.js +1 -1
- package/{migrations → src/migrations}/500401_quote-hotfix-2719.js +8 -8
- package/{migrations → src/migrations}/500501_feature-fixSubIdRef.js +12 -12
- package/{migrations → src/migrations}/500601_party-2480.js +3 -3
- package/{migrations → src/migrations}/501001_quoteExtension-quote-service-174.js +1 -2
- package/{migrations → src/migrations}/501002_quoteExtension-2522.js +3 -3
- package/{migrations → src/migrations}/600010_fxTransferType.js +1 -1
- package/{migrations → src/migrations}/600012_fxParticipantCurrencyType.js +1 -1
- package/{migrations → src/migrations}/600100_fxTransferDuplicateCheck.js +2 -2
- package/{migrations → src/migrations}/600110_fxTransferErrorDuplicateCheck.js.js +1 -1
- package/{migrations → src/migrations}/600200_fxTransfer.js +2 -2
- package/{migrations → src/migrations}/600400_fxTransferStateChange.js +1 -1
- package/{migrations → src/migrations}/600501_fxWatchList.js +2 -2
- package/{migrations → src/migrations}/600600_fxTransferFulfilmentDuplicateCheck.js +1 -1
- package/{migrations → src/migrations}/600700_fxTransferFulfilment.js +1 -1
- package/{migrations → src/migrations}/600800_fxTransferExtension.js +1 -1
- package/{migrations → src/migrations}/601400_fxTransferTimeout.js +1 -1
- package/{migrations → src/migrations}/601500_fxTransferError.js +1 -1
- package/{migrations → src/migrations}/610200_fxTransferParticipant.js +1 -1
- package/{migrations → src/migrations}/610202_fxTransferParticipant-participantId.js +2 -2
- package/{migrations → src/migrations}/610403_participantPositionChange-fxTransfer.js +1 -1
- package/{migrations → src/migrations}/800100_quotePartyView.js +1 -1
- package/{migrations → src/migrations}/800101_feature-fixSubIdRef.js +1 -1
- package/{migrations → src/migrations}/800200_quoteView.js +1 -1
- package/{migrations → src/migrations}/800300_quoteResponseView.js +1 -1
- package/{migrations → src/migrations}/900100_foreign-keys.js +18 -18
- package/{migrations → src/migrations}/900101_foreign-keys.js +6 -6
- package/{migrations → src/migrations}/910100_feature904DDL.js +7 -7
- package/{migrations → src/migrations}/910101_feature904DataMigration.js +1 -1
- package/{migrations → src/migrations}/910102_feature949DataMigration.js +1 -1
- package/{migrations → src/migrations}/910103_feature1093SettlementByCurrency.js +3 -3
- package/{migrations → src/migrations}/940101_quotePartyIdInfoExtension-2522.js +25 -25
- package/{migrations → src/migrations}/950101_transferParticipantStateChange.js +2 -2
- package/{migrations → src/migrations}/950102_settlementModel-adjustPosition.js +2 -2
- package/{migrations → src/migrations}/950103_dropTransferParticipantStateChange.js +3 -3
- package/{migrations → src/migrations}/950104_settlementModel-settlementAccountTypeId.js +3 -3
- package/src/migrations/950107_settlementWindowContent_foreign_settlementModel.js +63 -0
- package/{migrations → src/migrations}/950108_participantProxy.js +1 -2
- package/{migrations → src/migrations}/950120_fxQuoteConversionTerms_sourceAmount_nullable.js +1 -1
- package/{migrations → src/migrations}/960100_create_externalParticipant.js +2 -2
- package/{migrations → src/migrations}/960110_alter_transferParticipant__addFiled_externalParticipantId.js +2 -2
- package/{migrations → src/migrations}/961001_transferForwarded.js +1 -1
- package/{migrations → src/migrations}/961002_fxTransferForwarded.js +1 -1
- package/src/models/participant/externalParticipant.int.ts +85 -0
- package/src/models/participant/facade.js +4 -2
- package/src/models/participant/participantCurrencyCached.js +1 -1
- package/src/models/position/facade.js +8 -2
- package/src/models/transfer/facade.int.ts +139 -0
- package/src/models/transfer/facade.js +8 -3
- package/src/models/transfer/transferDuplicateCheck.js +2 -2
- package/src/models/transfer/transferError.int.ts +112 -0
- package/src/models/transfer/transferExtension.int.ts +137 -0
- package/src/models/transfer/transferStateChange.int.ts +117 -0
- package/{seeds → src/seeds}/participant.js +1 -1
- package/{seeds → src/seeds}/settlementInterchange.js +1 -0
- package/src/settlement/api/handlerRoutes.js +71 -0
- package/src/settlement/api/handlers/health.js +10 -0
- package/src/settlement/api/handlers/index.js +57 -0
- package/src/settlement/api/handlers/settlementWindows/{id}.js +103 -0
- package/src/settlement/api/handlers/settlementWindows.js +77 -0
- package/src/settlement/api/handlers/settlements/{id}.js +133 -0
- package/src/settlement/api/handlers/settlements/{sid}/participants/{pid}/accounts/{aid}.js +127 -0
- package/src/settlement/api/handlers/settlements/{sid}/participants/{pid}.js +127 -0
- package/src/settlement/api/handlers/settlements.js +114 -0
- package/src/settlement/api/openapiRouting.js +87 -0
- package/src/settlement/api/routes.js +176 -0
- package/src/settlement/domain/rules/index.js +46 -0
- package/src/settlement/domain/settlement/index.js +405 -0
- package/src/settlement/domain/settlementWindow/index.js +117 -0
- package/src/settlement/domain/transactions/index.js +83 -0
- package/src/settlement/domain/transferSettlement/index.js +57 -0
- package/src/settlement/handlers/deferredSettlement/handler.js +180 -0
- package/src/settlement/handlers/grossSettlement/handler.js +180 -0
- package/src/settlement/handlers/index.js +101 -0
- package/src/settlement/handlers/register.js +92 -0
- package/src/settlement/handlers/rules/handler.js +164 -0
- package/src/settlement/interface/swagger-handler.json +34 -0
- package/src/settlement/interface/swagger.json +1560 -0
- package/src/settlement/lib/db.js +32 -0
- package/src/settlement/lib/kafka/index.js +41 -0
- package/src/settlement/lib/kafka/producer.js +142 -0
- package/src/settlement/lib/scriptEngine.js +99 -0
- package/src/settlement/lib/scriptsLoader.js +175 -0
- package/src/settlement/lib/utility.js +243 -0
- package/src/settlement/models/ilpPackets/ilpPacket.js +42 -0
- package/src/settlement/models/lib/enums.js +192 -0
- package/src/settlement/models/misc/migrationLock.js +53 -0
- package/src/settlement/models/settlement/facade.js +1652 -0
- package/src/settlement/models/settlement/index.js +55 -0
- package/src/settlement/models/settlement/participantCurrency.js +48 -0
- package/src/settlement/models/settlement/settlement.js +49 -0
- package/src/settlement/models/settlement/settlementModel.js +44 -0
- package/src/settlement/models/settlement/settlementParticipantCurrency.js +61 -0
- package/src/settlement/models/settlement/settlementStateChange.js +44 -0
- package/src/settlement/models/settlement/settlementTransferParticipant.js +46 -0
- package/src/settlement/models/settlementWindow/facade.js +345 -0
- package/src/settlement/models/settlementWindow/index.js +47 -0
- package/src/settlement/models/settlementWindow/settlementWindowStateChange.js +55 -0
- package/src/settlement/models/settlementWindowContent/facade.js +79 -0
- package/src/settlement/models/settlementWindowContent/index.js +40 -0
- package/src/settlement/models/settlementWindowContent/settlementWindowContentStateChange.js +53 -0
- package/src/settlement/models/transferSettlement/facade.js +363 -0
- package/src/settlement/models/transferSettlement/index.js +42 -0
- package/src/settlement/shared/logger/index.js +7 -0
- package/src/settlement/shared/plugins.js +88 -0
- package/src/settlement/shared/setup.js +224 -0
- package/src/settlement/utils/truthyProperty.js +37 -0
- package/src/shared/legacyUtilShim.js +20 -0
- package/src/shared/plugins.js +3 -3
- package/src/shared/results.ts +22 -0
- package/src/shared/results.unit.ts +38 -0
- package/src/shared/setup.js +14 -1
- package/src/testing/api-helpers.ts +1222 -0
- package/src/testing/exec-async.ts +67 -0
- package/src/testing/harness.snapshot.sql +3895 -0
- package/src/testing/harness.test.ts +15 -0
- package/src/testing/harness.ts +1160 -0
- package/src/testing/kafka.ts +221 -0
- package/src/testing/prng.ts +82 -0
- package/src/testing/rdkafka.test.ts +263 -0
- package/src/testing/run.ts +559 -0
- package/src/testing/snapshot.test.ts +92 -0
- package/src/testing/snapshot.ts +549 -0
- package/src/testing/tap-stream.ts +164 -0
- package/src/testing/types.ts +95 -0
- package/src/testing/util.ts +333 -0
- package/src/types/central-services-error-handling.d.ts +72 -0
- package/src/types/central-services-stream.d.ts +148 -0
- package/test-integration.Dockerfile +0 -2
- package/test.Dockerfile +0 -2
- package/tsconfig.json +40 -0
- package/config/knexfile.js +0 -19
- package/migrations/950107_settlementWindowContent_foreign_settlementModel.js +0 -63
- package/src/api/index.js +0 -16
- package/src/lib/config.js +0 -81
- /package/{migrations → src/migrations}/110101_contactType-indexes.js +0 -0
- /package/{migrations → src/migrations}/110301_endpointType-indexes.js +0 -0
- /package/{migrations → src/migrations}/110401_ledgerEntryType-indexes.js +0 -0
- /package/{migrations → src/migrations}/110451_ledgerAccountType-indexes.js +0 -0
- /package/{migrations → src/migrations}/110501_participantLimitType-indexes.js +0 -0
- /package/{migrations → src/migrations}/110601_transferParticipantRoleType-indexes.js +0 -0
- /package/{migrations → src/migrations}/110800_settlementWindowState.js +0 -0
- /package/{migrations → src/migrations}/111000_amountType.js +0 -0
- /package/{migrations → src/migrations}/111001_amountType-indexes.js +0 -0
- /package/{migrations → src/migrations}/111100_balanceOfPayments.js +0 -0
- /package/{migrations → src/migrations}/111101_balanceOfPayments-indexes.js +0 -0
- /package/{migrations → src/migrations}/111200_partyIdentifierType.js +0 -0
- /package/{migrations → src/migrations}/111201_partyIdentifierType-indexes.js +0 -0
- /package/{migrations → src/migrations}/111300_partyType.js +0 -0
- /package/{migrations → src/migrations}/111301_partyType-indexes.js +0 -0
- /package/{migrations → src/migrations}/111400_quoteDuplicateCheck.js +0 -0
- /package/{migrations → src/migrations}/111500_transactionInitiator.js +0 -0
- /package/{migrations → src/migrations}/111501_transactionInitiator-indexes.js +0 -0
- /package/{migrations → src/migrations}/111600_transactionInitiatorType.js +0 -0
- /package/{migrations → src/migrations}/111601_transactionInitiatorType-indexes.js +0 -0
- /package/{migrations → src/migrations}/111700_settlementDelay.js +0 -0
- /package/{migrations → src/migrations}/111701_settlementDelay-indexes.js +0 -0
- /package/{migrations → src/migrations}/111800_settlementInterchange.js +0 -0
- /package/{migrations → src/migrations}/111801_settlementInterchange-indexes.js +0 -0
- /package/{migrations → src/migrations}/111900_settlementGranularity.js +0 -0
- /package/{migrations → src/migrations}/111901_settlementGranularity-indexes.js +0 -0
- /package/{migrations → src/migrations}/112101_bulkProcessingState-indexes.js +0 -0
- /package/{migrations → src/migrations}/200101_participant-indexes.js +0 -0
- /package/{migrations → src/migrations}/200201_participantContact-indexes.js +0 -0
- /package/{migrations → src/migrations}/200301_participantEndpoint-indexes.js +0 -0
- /package/{migrations → src/migrations}/200401_participantParty-indexes.js +0 -0
- /package/{migrations → src/migrations}/300201_transfer-indexes.js +0 -0
- /package/{migrations → src/migrations}/300251_bulkTransfer-indexes.js +0 -0
- /package/{migrations → src/migrations}/300276_bulkTransferAssociation-indexes.js +0 -0
- /package/{migrations → src/migrations}/300401_transferStateChange-indexes.js +0 -0
- /package/{migrations → src/migrations}/300451_bulkTransferStateChange-indexes.js +0 -0
- /package/{migrations → src/migrations}/300501_segment-indexes.js +0 -0
- /package/{migrations → src/migrations}/310101_participantCurrency-indexes.js +0 -0
- /package/{migrations → src/migrations}/310201_transferParticipant-indexes.js +0 -0
- /package/{migrations → src/migrations}/310203_transferParticipant-indexes.js +0 -0
- /package/{migrations → src/migrations}/310301_participantPosition-indexes.js +0 -0
- /package/{migrations → src/migrations}/310401_participantPositionChange-indexes.js +0 -0
- /package/{migrations → src/migrations}/310405_participantPositionChange-positionChange.js +0 -0
- /package/{migrations → src/migrations}/310406_participantPositionChange-positionChange-revert.js +0 -0
- /package/{migrations → src/migrations}/310501_participantLimit-indexes.js +0 -0
- /package/{migrations → src/migrations}/310503_participantLimit-indexes-composite.js +0 -0
- /package/{migrations → src/migrations}/400401_settlmentWindowStateChange-indexes.js +0 -0
- /package/{migrations → src/migrations}/400501_settlementTransferParticipant-indexes.js +0 -0
- /package/{migrations → src/migrations}/400601_settlementParticipantCurrency-indexes.js +0 -0
- /package/{migrations → src/migrations}/400701_settlementParticipantCurrencyStateChange-indexes.js +0 -0
- /package/{migrations → src/migrations}/400801_settlementStateChange-indexes.js +0 -0
- /package/{migrations → src/migrations}/401002_settlementWindowContent-indexes.js +0 -0
- /package/{migrations → src/migrations}/401201_settlementContentAggregation-indexes.js +0 -0
- /package/{migrations → src/migrations}/401301_settlementModel-indexes.js +0 -0
- /package/{migrations → src/migrations}/410101_transferFulfilmentDuplicateCheck-indexes.js +0 -0
- /package/{migrations → src/migrations}/410201_transferFulfilment-indexes.js +0 -0
- /package/{migrations → src/migrations}/410301_transferExtension-indexes.js +0 -0
- /package/{migrations → src/migrations}/410351_bulkTransferExtension-indexes.js +0 -0
- /package/{migrations → src/migrations}/410401_transferTimeout-indexes.js +0 -0
- /package/{migrations → src/migrations}/410501_transferError-indexes.js +0 -0
- /package/{migrations → src/migrations}/410551_bulkTransferError-indexes.js +0 -0
- /package/{migrations → src/migrations}/410601_expiringTransfer-indexes.js +0 -0
- /package/{migrations → src/migrations}/500100_transactionReference.js +0 -0
- /package/{migrations → src/migrations}/500101_transactionReference-indexes.js +0 -0
- /package/{migrations → src/migrations}/500200_transactionScenario.js +0 -0
- /package/{migrations → src/migrations}/500201_transactionScenario-indexes.js +0 -0
- /package/{migrations → src/migrations}/500300_transactionSubScenario.js +0 -0
- /package/{migrations → src/migrations}/500400_quote.js +0 -0
- /package/{migrations → src/migrations}/500500_quoteParty.js +0 -0
- /package/{migrations → src/migrations}/500600_party.js +0 -0
- /package/{migrations → src/migrations}/500700_quoteResponse.js +0 -0
- /package/{migrations → src/migrations}/500800_quoteResponseIlpPacket.js +0 -0
- /package/{migrations → src/migrations}/500900_geoCode.js +0 -0
- /package/{migrations → src/migrations}/501000_quoteExtension.js +0 -0
- /package/{migrations → src/migrations}/501100_quoteResponseDuplicateCheck.js +0 -0
- /package/{migrations → src/migrations}/501200_quoteError.js +0 -0
- /package/{migrations → src/migrations}/501300_transferRules.js +0 -0
- /package/{migrations → src/migrations}/600011_fxTransferType-indexes.js +0 -0
- /package/{migrations → src/migrations}/600013_fxParticipantCurrencyType-indexes.js +0 -0
- /package/{migrations → src/migrations}/600201_fxTransfer-indexes.js +0 -0
- /package/{migrations → src/migrations}/600401_fxTransferStateChange-indexes.js +0 -0
- /package/{migrations → src/migrations}/600502_fxWatchList-indexes.js +0 -0
- /package/{migrations → src/migrations}/600601_fxTransferFulfilmentDuplicateCheck-indexes.js +0 -0
- /package/{migrations → src/migrations}/600701_fxTransferFulfilment-indexes.js +0 -0
- /package/{migrations → src/migrations}/601401_fxTransferTimeout-indexes.js +0 -0
- /package/{migrations → src/migrations}/601501_fxTransferError-indexes.js +0 -0
- /package/{migrations → src/migrations}/610201_fxTransferParticipant-indexes.js +0 -0
- /package/{migrations → src/migrations}/910102_hotfix954.js +0 -0
- /package/{migrations → src/migrations}/940100_quotePartyIdInfoExtension.js +0 -0
- /package/{migrations → src/migrations}/950100_settlementContentAggregation-decimal184.js +0 -0
- /package/{migrations → src/migrations}/950106_unique_settlement_model_ledger_account_currency.js +0 -0
- /package/{migrations → src/migrations}/950109_fxQuote.js +0 -0
- /package/{migrations → src/migrations}/950110_fxQuoteResponse.js +0 -0
- /package/{migrations → src/migrations}/950111_fxQuoteError.js +0 -0
- /package/{migrations → src/migrations}/950113_fxQuoteDuplicateCheck.js +0 -0
- /package/{migrations → src/migrations}/950114_fxQuoteResponseDuplicateCheck.js +0 -0
- /package/{migrations → src/migrations}/950115_fxQuoteConversionTerms.js +0 -0
- /package/{migrations → src/migrations}/950116_fxQuoteConversionTermsExtension.js +0 -0
- /package/{migrations → src/migrations}/950117_fxQuoteResponseConversionTerms.js +0 -0
- /package/{migrations → src/migrations}/950118_fxQuoteResponseConversionTermsExtension.js +0 -0
- /package/{migrations → src/migrations}/950119_fxCharge.js +0 -0
- /package/{migrations → src/migrations}/960111_alter_fxTransferParticipant__addFiled_externalParticipantId.js +0 -0
- /package/{migrations → src/migrations}/960112_fxTransfer-indexes2.js +0 -0
- /package/{migrations → src/migrations}/960113_fxTransferExtension-indexes.js +0 -0
- /package/{migrations → src/migrations}/960114_fxTransferTimeout-indexes2.js +0 -0
- /package/{migrations → src/migrations}/961000_participantEndpoint_unique.js +0 -0
- /package/{migrations → src/migrations}/migration.template +0 -0
- /package/{seeds → src/seeds}/amountType.js +0 -0
- /package/{seeds → src/seeds}/balanceOfPayments.js +0 -0
- /package/{seeds → src/seeds}/bulkProcessingState.js +0 -0
- /package/{seeds → src/seeds}/bulkTransferState.js +0 -0
- /package/{seeds → src/seeds}/currency.js +0 -0
- /package/{seeds → src/seeds}/endpointType.js +0 -0
- /package/{seeds → src/seeds}/fxParticipantCurrencyType.js +0 -0
- /package/{seeds → src/seeds}/fxTransferType.js +0 -0
- /package/{seeds → src/seeds}/ledgerAccountType.js +0 -0
- /package/{seeds → src/seeds}/ledgerEntryType.js +0 -0
- /package/{seeds → src/seeds}/participantLimitType.js +0 -0
- /package/{seeds → src/seeds}/partyIdentifierType.js +0 -0
- /package/{seeds → src/seeds}/partyType.js +0 -0
- /package/{seeds → src/seeds}/settlementDelay.js +0 -0
- /package/{seeds → src/seeds}/settlementGranularity.js +0 -0
- /package/{seeds → src/seeds}/settlementState.js +0 -0
- /package/{seeds → src/seeds}/settlementWindow1State.js +0 -0
- /package/{seeds → src/seeds}/settlementWindow2Open.js +0 -0
- /package/{seeds → src/seeds}/transactionInitiator.js +0 -0
- /package/{seeds → src/seeds}/transactionInitiatorType.js +0 -0
- /package/{seeds → src/seeds}/transactionScenario.js +0 -0
- /package/{seeds → src/seeds}/transferParticipantRoleType.js +0 -0
- /package/{seeds → src/seeds}/transferState.js +0 -0
- /package/{seeds → src/seeds}/z1000_settlementModel-deprecated.js- +0 -0
|
@@ -142,7 +142,7 @@ const forwardPrepare = async ({ isFx, params, ID }) => {
|
|
|
142
142
|
|
|
143
143
|
/**
|
|
144
144
|
* Calculates proxyObligation.
|
|
145
|
-
* @returns {ProxyObligation} proxyObligation
|
|
145
|
+
* @returns {Promise<ProxyObligation>} proxyObligation
|
|
146
146
|
*/
|
|
147
147
|
const calculateProxyObligation = async ({ payload, isFx, params, functionality, action }) => {
|
|
148
148
|
const proxyObligation = {
|
|
@@ -442,7 +442,7 @@ const sendPositionPrepareMessage = async ({
|
|
|
442
442
|
* @param {error} error - error thrown if something fails within Kafka
|
|
443
443
|
* @param {array} messages - a list of messages to consume for the relevant topic
|
|
444
444
|
*
|
|
445
|
-
|
|
445
|
+
// * @returns {Promise<object>} - Returns a boolean: true if successful, or throws and error if failed
|
|
446
446
|
*/
|
|
447
447
|
const prepare = async (error, messages) => {
|
|
448
448
|
const location = { module: 'PrepareHandler', method: '', path: '' }
|
package/src/knexfile.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const Config = require('./lib/config')
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
client: 'mysql',
|
|
7
|
+
version: '5.5',
|
|
8
|
+
connection: Config.DATABASE.connection,
|
|
9
|
+
pool: Config.DATABASE.pool,
|
|
10
|
+
migrations: {
|
|
11
|
+
directory: './migrations',
|
|
12
|
+
tableName: 'migration',
|
|
13
|
+
stub: './migrations/migration.template'
|
|
14
|
+
},
|
|
15
|
+
seeds: {
|
|
16
|
+
directory: './seeds',
|
|
17
|
+
loadExtensions: ['.js']
|
|
18
|
+
}
|
|
19
|
+
}
|
package/src/lib/cache.js
CHANGED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*****
|
|
2
|
+
License
|
|
3
|
+
--------------
|
|
4
|
+
Copyright © 2020-2026 Mojaloop Foundation
|
|
5
|
+
The Mojaloop files are made available by the Mojaloop Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
10
|
+
|
|
11
|
+
Contributors
|
|
12
|
+
--------------
|
|
13
|
+
This is the official list of the Mojaloop project contributors for this file.
|
|
14
|
+
Names of the original copyright holders (individuals or organizations)
|
|
15
|
+
should be listed with a '*' in the first column. People who have
|
|
16
|
+
contributed from an organization can be listed under the organization
|
|
17
|
+
that actually holds the copyright for their contributions (see the
|
|
18
|
+
Mojaloop Foundation for an example). Those individuals should have
|
|
19
|
+
their names indented and be marked with a '-'. Email address can be added
|
|
20
|
+
optionally within square brackets <email>.
|
|
21
|
+
|
|
22
|
+
* TigerBeetle
|
|
23
|
+
- Lewis Daly <lewis@tigerbeetle.com>
|
|
24
|
+
--------------
|
|
25
|
+
|
|
26
|
+
******/
|
|
27
|
+
|
|
28
|
+
import { makeConfig } from "./resolver"
|
|
29
|
+
import { deepMerge } from "./util"
|
|
30
|
+
import type { ApplicationConfig } from './types'
|
|
31
|
+
|
|
32
|
+
const config = makeConfig()
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Override config values for testing. Ideally we wouldn't need to do this, but because config is
|
|
36
|
+
* typically imported as a global, we need a way to override some config parameters in test.
|
|
37
|
+
*/
|
|
38
|
+
export const overrideForTesting = (override: Partial<ApplicationConfig>) => {
|
|
39
|
+
deepMerge(config, override)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Reset the overriden config.
|
|
44
|
+
*/
|
|
45
|
+
export const resetOverride = () => {
|
|
46
|
+
const fresh = makeConfig()
|
|
47
|
+
Object.keys(config).forEach(key => delete (config as any)[key])
|
|
48
|
+
Object.assign(config, fresh)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default config
|
|
52
|
+
export * from './types'
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Export as CommonJS for backwards compatibility.
|
|
56
|
+
*/
|
|
57
|
+
module.exports = config
|
|
58
|
+
module.exports.default = config
|
|
59
|
+
module.exports.overrideForTesting = overrideForTesting
|
|
60
|
+
module.exports.resetOverride = resetOverride
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/*****
|
|
2
|
+
License
|
|
3
|
+
--------------
|
|
4
|
+
Copyright © 2020-2026 Mojaloop Foundation
|
|
5
|
+
The Mojaloop files are made available by the Mojaloop Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
10
|
+
|
|
11
|
+
Contributors
|
|
12
|
+
--------------
|
|
13
|
+
This is the official list of the Mojaloop project contributors for this file.
|
|
14
|
+
Names of the original copyright holders (individuals or organizations)
|
|
15
|
+
should be listed with a '*' in the first column. People who have
|
|
16
|
+
contributed from an organization can be listed under the organization
|
|
17
|
+
that actually holds the copyright for their contributions (see the
|
|
18
|
+
Mojaloop Foundation for an example). Those individuals should have
|
|
19
|
+
their names indented and be marked with a '-'. Email address can be added
|
|
20
|
+
optionally within square brackets <email>.
|
|
21
|
+
|
|
22
|
+
* TigerBeetle
|
|
23
|
+
- Lewis Daly <lewis@tigerbeetle.com>
|
|
24
|
+
--------------
|
|
25
|
+
|
|
26
|
+
******/
|
|
27
|
+
|
|
28
|
+
import path from 'node:path'
|
|
29
|
+
import parseStringsInObject from 'parse-strings-in-object'
|
|
30
|
+
import RC from 'rc'
|
|
31
|
+
import { ApplicationConfig } from './types'
|
|
32
|
+
import {
|
|
33
|
+
assertBoolean,
|
|
34
|
+
assertDatabaseConfig,
|
|
35
|
+
assertDistLockConfig,
|
|
36
|
+
assertInstrumentationConfig,
|
|
37
|
+
assertInstrumentationMetricsLabels,
|
|
38
|
+
assertKafkaConfig,
|
|
39
|
+
assertNestedFields,
|
|
40
|
+
assertNumber,
|
|
41
|
+
assertProvisioning,
|
|
42
|
+
assertProxyCacheConfig,
|
|
43
|
+
assertString,
|
|
44
|
+
defaultEnvString,
|
|
45
|
+
defaultTo,
|
|
46
|
+
kafkaWithBrokerDefaults
|
|
47
|
+
} from './util'
|
|
48
|
+
import assert from 'node:assert'
|
|
49
|
+
import { logger } from '../../shared/logger'
|
|
50
|
+
|
|
51
|
+
type UnsafeApplicationConfig = Partial<ApplicationConfig>
|
|
52
|
+
|
|
53
|
+
const resolveConfig = (rawConfig: any): UnsafeApplicationConfig => {
|
|
54
|
+
const defaultBroker = defaultTo(rawConfig.KAFKA.DEFAULT_BROKER, 'localhost:9092')
|
|
55
|
+
const kafka = kafkaWithBrokerDefaults(rawConfig.KAFKA, defaultBroker)
|
|
56
|
+
|
|
57
|
+
// Make sure nested fields we depend upon exist.
|
|
58
|
+
assertNestedFields(rawConfig, 'DATABASE')
|
|
59
|
+
assertNestedFields(rawConfig, 'MIGRATIONS')
|
|
60
|
+
assertNestedFields(rawConfig, 'AMOUNT')
|
|
61
|
+
assertNestedFields(rawConfig, 'MONGODB')
|
|
62
|
+
assertNestedFields(rawConfig, 'HANDLERS')
|
|
63
|
+
assertNestedFields(rawConfig, 'HANDLERS.API')
|
|
64
|
+
assertNestedFields(rawConfig, 'HANDLERS.TIMEOUT')
|
|
65
|
+
assertNestedFields(rawConfig, 'HANDLERS.TIMEOUT.DIST_LOCK')
|
|
66
|
+
assertNestedFields(rawConfig, 'HANDLERS.TIMEOUT.DIST_LOCK.redisConfigs')
|
|
67
|
+
assertNestedFields(rawConfig, 'HANDLERS.SETTINGS.RULES')
|
|
68
|
+
assertNestedFields(rawConfig, 'INSTRUMENTATION')
|
|
69
|
+
assertNestedFields(rawConfig, 'HUB_PARTICIPANT')
|
|
70
|
+
assertNestedFields(rawConfig, 'WINDOW_AGGREGATION.RETRY_COUNT')
|
|
71
|
+
assertNestedFields(rawConfig, 'WINDOW_AGGREGATION.RETRY_INTERVAL')
|
|
72
|
+
|
|
73
|
+
const unsafeConfig: UnsafeApplicationConfig = {
|
|
74
|
+
PORT: rawConfig.PORT,
|
|
75
|
+
HOSTNAME: rawConfig.HOSTNAME.replace(/\/$/, ''),
|
|
76
|
+
DATABASE: {
|
|
77
|
+
client: rawConfig.DATABASE.DIALECT,
|
|
78
|
+
connection: {
|
|
79
|
+
host: rawConfig.DATABASE.HOST.replace(/\/$/, ''),
|
|
80
|
+
port: rawConfig.DATABASE.PORT,
|
|
81
|
+
user: rawConfig.DATABASE.USER,
|
|
82
|
+
password: rawConfig.DATABASE.PASSWORD,
|
|
83
|
+
database: rawConfig.DATABASE.SCHEMA
|
|
84
|
+
},
|
|
85
|
+
pool: {
|
|
86
|
+
min: rawConfig.DATABASE.POOL_MIN_SIZE,
|
|
87
|
+
max: rawConfig.DATABASE.POOL_MAX_SIZE,
|
|
88
|
+
acquireTimeoutMillis: rawConfig.DATABASE.ACQUIRE_TIMEOUT_MILLIS,
|
|
89
|
+
createTimeoutMillis: rawConfig.DATABASE.CREATE_TIMEOUT_MILLIS,
|
|
90
|
+
destroyTimeoutMillis: rawConfig.DATABASE.DESTROY_TIMEOUT_MILLIS,
|
|
91
|
+
idleTimeoutMillis: rawConfig.DATABASE.IDLE_TIMEOUT_MILLIS,
|
|
92
|
+
reapIntervalMillis: rawConfig.DATABASE.REAP_INTERVAL_MILLIS,
|
|
93
|
+
createRetryIntervalMillis: rawConfig.DATABASE.CREATE_RETRY_INTERVAL_MILLIS
|
|
94
|
+
},
|
|
95
|
+
debug: rawConfig.DATABASE.DEBUG
|
|
96
|
+
},
|
|
97
|
+
MAX_FULFIL_TIMEOUT_DURATION_SECONDS: defaultTo(rawConfig.MAX_FULFIL_TIMEOUT_DURATION_SECONDS, 300),
|
|
98
|
+
RUN_MIGRATIONS: !rawConfig.MIGRATIONS.DISABLED,
|
|
99
|
+
RUN_DATA_MIGRATIONS: rawConfig.MIGRATIONS.RUN_DATA_MIGRATIONS,
|
|
100
|
+
AMOUNT: {
|
|
101
|
+
PRECISION: rawConfig.AMOUNT.PRECISION,
|
|
102
|
+
SCALE: rawConfig.AMOUNT.SCALE,
|
|
103
|
+
},
|
|
104
|
+
MONGODB_HOST: rawConfig.MONGODB.HOST,
|
|
105
|
+
MONGODB_PORT: rawConfig.MONGODB.PORT,
|
|
106
|
+
MONGODB_USER: rawConfig.MONGODB.USER,
|
|
107
|
+
MONGODB_PASSWORD: rawConfig.MONGODB.PASSWORD,
|
|
108
|
+
MONGODB_DATABASE: rawConfig.MONGODB.DATABASE,
|
|
109
|
+
MONGODB_DEBUG: rawConfig.MONGODB.DEBUG === true,
|
|
110
|
+
MONGODB_DISABLED: rawConfig.MONGODB.DISABLED === true,
|
|
111
|
+
ERROR_HANDLING: rawConfig.ERROR_HANDLING,
|
|
112
|
+
HANDLERS: {
|
|
113
|
+
SETTINGS: rawConfig.HANDLERS.SETTINGS
|
|
114
|
+
},
|
|
115
|
+
HANDLERS_DISABLED: rawConfig.HANDLERS.DISABLED,
|
|
116
|
+
HANDLERS_API_DISABLED: rawConfig.HANDLERS.API.DISABLED,
|
|
117
|
+
HANDLERS_TIMEOUT: rawConfig.HANDLERS.TIMEOUT,
|
|
118
|
+
HANDLERS_TIMEOUT_DISABLED: rawConfig.HANDLERS.TIMEOUT.DISABLED,
|
|
119
|
+
HANDLERS_TIMEOUT_TIMEXP: rawConfig.HANDLERS.TIMEOUT.TIMEXP,
|
|
120
|
+
HANDLERS_TIMEOUT_TIMEZONE: rawConfig.HANDLERS.TIMEOUT.TIMEZONE,
|
|
121
|
+
INSTRUMENTATION_METRICS_DISABLED: rawConfig.INSTRUMENTATION.METRICS.DISABLED,
|
|
122
|
+
INSTRUMENTATION_METRICS_LABELS: rawConfig.INSTRUMENTATION.METRICS.labels,
|
|
123
|
+
INSTRUMENTATION_METRICS_CONFIG: rawConfig.INSTRUMENTATION.METRICS.config,
|
|
124
|
+
PARTICIPANT_INITIAL_POSITION: defaultTo(rawConfig.PARTICIPANT_INITIAL_POSITION, 0),
|
|
125
|
+
HUB_ID: rawConfig.HUB_PARTICIPANT.ID,
|
|
126
|
+
HUB_NAME: rawConfig.HUB_PARTICIPANT.NAME,
|
|
127
|
+
HUB_ACCOUNTS: rawConfig.HUB_PARTICIPANT.ACCOUNTS,
|
|
128
|
+
INTERNAL_TRANSFER_VALIDITY_SECONDS: defaultTo(rawConfig.INTERNAL_TRANSFER_VALIDITY_SECONDS, 432000),
|
|
129
|
+
ENABLE_ON_US_TRANSFERS: rawConfig.ENABLE_ON_US_TRANSFERS,
|
|
130
|
+
PAYEE_PARTICIPANT_CURRENCY_VALIDATION_ENABLED: rawConfig.PAYEE_PARTICIPANT_CURRENCY_VALIDATION_ENABLED,
|
|
131
|
+
CACHE_CONFIG: rawConfig.CACHE,
|
|
132
|
+
PROXY_CACHE_CONFIG: rawConfig.PROXY_CACHE,
|
|
133
|
+
API_DOC_ENDPOINTS_ENABLED: defaultTo(rawConfig.API_DOC_ENDPOINTS_ENABLED, false),
|
|
134
|
+
WINDOW_AGGREGATION_RETRY_COUNT: rawConfig.WINDOW_AGGREGATION.RETRY_COUNT,
|
|
135
|
+
WINDOW_AGGREGATION_RETRY_INTERVAL: rawConfig.WINDOW_AGGREGATION.RETRY_INTERVAL,
|
|
136
|
+
KAFKA_CONFIG: kafka,
|
|
137
|
+
SERVER_PRINT_ROUTES_ON_STARTUP: defaultTo(rawConfig.SERVER_PRINT_ROUTES_ON_STARTUP, true),
|
|
138
|
+
LEDGER: defaultTo(rawConfig.LEDGER, 'LEGACY'),
|
|
139
|
+
EXPERIMENTAL: {
|
|
140
|
+
PROVISIONING: {
|
|
141
|
+
enabled: defaultTo(rawConfig.EXPERIMENTAL?.PROVISIONING?.enabled, false),
|
|
142
|
+
currencies: defaultTo(rawConfig.EXPERIMENTAL?.PROVISIONING?.currencies, []),
|
|
143
|
+
hubAlertEmailAddress: rawConfig.EXPERIMENTAL?.PROVISIONING?.hubAlertEmailAddress,
|
|
144
|
+
},
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return unsafeConfig
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const parseAndValidateConfig = (unsafeConfig: UnsafeApplicationConfig): ApplicationConfig => {
|
|
151
|
+
assertNumber(unsafeConfig.PORT)
|
|
152
|
+
assertString(unsafeConfig.HOSTNAME)
|
|
153
|
+
assertDatabaseConfig(unsafeConfig.DATABASE)
|
|
154
|
+
assertNumber(unsafeConfig.MAX_FULFIL_TIMEOUT_DURATION_SECONDS)
|
|
155
|
+
assertString(unsafeConfig.MONGODB_HOST)
|
|
156
|
+
assertNumber(unsafeConfig.MONGODB_PORT)
|
|
157
|
+
assertString(unsafeConfig.MONGODB_USER)
|
|
158
|
+
assertString(unsafeConfig.MONGODB_DATABASE)
|
|
159
|
+
assertBoolean(unsafeConfig.MONGODB_DEBUG)
|
|
160
|
+
assertBoolean(unsafeConfig.MONGODB_DISABLED)
|
|
161
|
+
assert(unsafeConfig.AMOUNT)
|
|
162
|
+
assertNumber(unsafeConfig.AMOUNT.PRECISION)
|
|
163
|
+
assertNumber(unsafeConfig.AMOUNT.SCALE)
|
|
164
|
+
assert(unsafeConfig.ERROR_HANDLING)
|
|
165
|
+
assertBoolean(unsafeConfig.ERROR_HANDLING.includeCauseExtension)
|
|
166
|
+
assertBoolean(unsafeConfig.ERROR_HANDLING.truncateExtensions)
|
|
167
|
+
assertBoolean(unsafeConfig.HANDLERS_DISABLED)
|
|
168
|
+
assertBoolean(unsafeConfig.HANDLERS_API_DISABLED)
|
|
169
|
+
assert(unsafeConfig.HANDLERS_TIMEOUT)
|
|
170
|
+
assertDistLockConfig(unsafeConfig.HANDLERS_TIMEOUT.DIST_LOCK)
|
|
171
|
+
assertBoolean(unsafeConfig.HANDLERS_TIMEOUT.DISABLED)
|
|
172
|
+
assertString(unsafeConfig.HANDLERS_TIMEOUT.TIMEXP)
|
|
173
|
+
assertString(unsafeConfig.HANDLERS_TIMEOUT.TIMEZONE)
|
|
174
|
+
assertBoolean(unsafeConfig.HANDLERS_TIMEOUT_DISABLED)
|
|
175
|
+
assertString(unsafeConfig.HANDLERS_TIMEOUT_TIMEXP)
|
|
176
|
+
assertString(unsafeConfig.HANDLERS_TIMEOUT_TIMEZONE)
|
|
177
|
+
assert(unsafeConfig.CACHE_CONFIG)
|
|
178
|
+
assertBoolean(unsafeConfig.CACHE_CONFIG.CACHE_ENABLED)
|
|
179
|
+
assertNumber(unsafeConfig.CACHE_CONFIG.MAX_BYTE_SIZE)
|
|
180
|
+
assertNumber(unsafeConfig.CACHE_CONFIG.EXPIRES_IN_MS)
|
|
181
|
+
assert(unsafeConfig.PROXY_CACHE_CONFIG)
|
|
182
|
+
assertBoolean(unsafeConfig.PROXY_CACHE_CONFIG.enabled)
|
|
183
|
+
assertString(unsafeConfig.PROXY_CACHE_CONFIG.type)
|
|
184
|
+
assertProxyCacheConfig(unsafeConfig.PROXY_CACHE_CONFIG.proxyConfig)
|
|
185
|
+
assertKafkaConfig(unsafeConfig.KAFKA_CONFIG)
|
|
186
|
+
assertNumber(unsafeConfig.PARTICIPANT_INITIAL_POSITION)
|
|
187
|
+
assertBoolean(unsafeConfig.RUN_MIGRATIONS)
|
|
188
|
+
assertBoolean(unsafeConfig.RUN_DATA_MIGRATIONS)
|
|
189
|
+
assertNumber(unsafeConfig.INTERNAL_TRANSFER_VALIDITY_SECONDS)
|
|
190
|
+
assertBoolean(unsafeConfig.ENABLE_ON_US_TRANSFERS)
|
|
191
|
+
assertNumber(unsafeConfig.HUB_ID)
|
|
192
|
+
assertString(unsafeConfig.HUB_NAME)
|
|
193
|
+
assert.ok(Array.isArray(unsafeConfig.HUB_ACCOUNTS))
|
|
194
|
+
unsafeConfig.HUB_ACCOUNTS.forEach(unsafeAccountStr => assert(unsafeAccountStr))
|
|
195
|
+
assertBoolean(unsafeConfig.INSTRUMENTATION_METRICS_DISABLED)
|
|
196
|
+
assertInstrumentationMetricsLabels(unsafeConfig.INSTRUMENTATION_METRICS_LABELS)
|
|
197
|
+
assertInstrumentationConfig(unsafeConfig.INSTRUMENTATION_METRICS_CONFIG)
|
|
198
|
+
assertBoolean(unsafeConfig.API_DOC_ENDPOINTS_ENABLED)
|
|
199
|
+
assertBoolean(unsafeConfig.PAYEE_PARTICIPANT_CURRENCY_VALIDATION_ENABLED)
|
|
200
|
+
assertBoolean(unsafeConfig.SERVER_PRINT_ROUTES_ON_STARTUP)
|
|
201
|
+
|
|
202
|
+
assert(unsafeConfig.EXPERIMENTAL)
|
|
203
|
+
assertProvisioning(unsafeConfig.EXPERIMENTAL.PROVISIONING)
|
|
204
|
+
|
|
205
|
+
// Now assert config business logic - apply rules.
|
|
206
|
+
if (unsafeConfig.LEDGER !== 'LEGACY') {
|
|
207
|
+
throw new Error(`LEDGER must be LEGACY. TIGERBEETLE and LOCKSTEP ledgers are currently unsupported.`)
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (unsafeConfig.EXPERIMENTAL.PROVISIONING.enabled) {
|
|
211
|
+
throw new Error(`PROVISIONING not currently implemented.`)
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return unsafeConfig as ApplicationConfig
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const makeConfig = (): ApplicationConfig => {
|
|
218
|
+
const PATH_TO_CONFIG_FILE = defaultEnvString(
|
|
219
|
+
process.env,
|
|
220
|
+
'PATH_TO_CONFIG_FILE',
|
|
221
|
+
path.join(__dirname, '../../..', 'config/default.json')
|
|
222
|
+
)
|
|
223
|
+
logger.info(`makeConfig() - Loading config from: ${PATH_TO_CONFIG_FILE}`)
|
|
224
|
+
const raw = parseStringsInObject(RC('CLEDG', require(PATH_TO_CONFIG_FILE)))
|
|
225
|
+
const resolved = resolveConfig(raw)
|
|
226
|
+
const validated = parseAndValidateConfig(resolved)
|
|
227
|
+
|
|
228
|
+
return validated
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export { makeConfig, resolveConfig, parseAndValidateConfig }
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/*****
|
|
2
|
+
License
|
|
3
|
+
--------------
|
|
4
|
+
Copyright © 2020-2026 Mojaloop Foundation
|
|
5
|
+
The Mojaloop files are made available by the Mojaloop Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
10
|
+
|
|
11
|
+
Contributors
|
|
12
|
+
--------------
|
|
13
|
+
This is the official list of the Mojaloop project contributors for this file.
|
|
14
|
+
Names of the original copyright holders (individuals or organizations)
|
|
15
|
+
should be listed with a '*' in the first column. People who have
|
|
16
|
+
contributed from an organization can be listed under the organization
|
|
17
|
+
that actually holds the copyright for their contributions (see the
|
|
18
|
+
Mojaloop Foundation for an example). Those individuals should have
|
|
19
|
+
their names indented and be marked with a '-'. Email address can be added
|
|
20
|
+
optionally within square brackets <email>.
|
|
21
|
+
|
|
22
|
+
* TigerBeetle
|
|
23
|
+
- Lewis Daly <lewis@tigerbeetle.com>
|
|
24
|
+
--------------
|
|
25
|
+
|
|
26
|
+
******/
|
|
27
|
+
|
|
28
|
+
import { describe, it } from 'node:test'
|
|
29
|
+
import assert from 'node:assert'
|
|
30
|
+
import { makeConfig, parseAndValidateConfig, resolveConfig } from './resolver'
|
|
31
|
+
import parseStringsInObject from 'parse-strings-in-object'
|
|
32
|
+
import RC from 'rc'
|
|
33
|
+
import path from 'node:path'
|
|
34
|
+
|
|
35
|
+
describe('lib/config/resolver', () => {
|
|
36
|
+
it('loads the config', () => {
|
|
37
|
+
const config = makeConfig()
|
|
38
|
+
assert.ok(config)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('throws if LEDGER !== LEGACY', () => {
|
|
42
|
+
// Arrange
|
|
43
|
+
const pathToConfigFile = path.join(__dirname, '../../..', 'config/default.json')
|
|
44
|
+
const raw = parseStringsInObject(RC('CLEDG', require(pathToConfigFile)))
|
|
45
|
+
const resolved = resolveConfig(raw)
|
|
46
|
+
|
|
47
|
+
// Act
|
|
48
|
+
resolved.LEDGER = 'LOCKSTEP'
|
|
49
|
+
|
|
50
|
+
// Assert
|
|
51
|
+
assert.throws(() => parseAndValidateConfig(resolved))
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it('throws if EXPERIMENTAL.PROVISIONING is enabled', () => {
|
|
55
|
+
// Arrange
|
|
56
|
+
const pathToConfigFile = path.join(__dirname, '../../..', 'config/default.json')
|
|
57
|
+
const raw = parseStringsInObject(RC('CLEDG', require(pathToConfigFile)))
|
|
58
|
+
const resolved = resolveConfig(raw)
|
|
59
|
+
|
|
60
|
+
// Act
|
|
61
|
+
resolved.EXPERIMENTAL = {
|
|
62
|
+
PROVISIONING: {
|
|
63
|
+
enabled: true,
|
|
64
|
+
currencies: ['USD'],
|
|
65
|
+
hubAlertEmailAddress: 'test@email.com'
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Assert
|
|
70
|
+
assert.throws(() => parseAndValidateConfig(resolved))
|
|
71
|
+
})
|
|
72
|
+
})
|