@mojaloop/sdk-scheme-adapter 12.0.0 → 12.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.
Files changed (263) hide show
  1. package/.circleci/config.yml +619 -0
  2. package/.env.example +13 -0
  3. package/.nvmrc +1 -1
  4. package/.versionrc +1 -0
  5. package/CHANGELOG.md +28 -2
  6. package/CODEOWNERS +2 -0
  7. package/Dockerfile +35 -0
  8. package/LICENSE.md +10 -0
  9. package/PROXY.md +84 -0
  10. package/README.md +228 -0
  11. package/SECURITY.md +18 -0
  12. package/audit-resolve.json +45 -0
  13. package/docker/ml-testing-toolkit/secrets/keygen.sh +5 -0
  14. package/docker/ml-testing-toolkit/secrets/privatekey.pem +27 -0
  15. package/docker/ml-testing-toolkit/secrets/publickey.cer +21 -0
  16. package/docker/ml-testing-toolkit/secrets/tls/createSecrets.sh +29 -0
  17. package/docker/ml-testing-toolkit/secrets/tls/hub_client.csr +28 -0
  18. package/docker/ml-testing-toolkit/secrets/tls/hub_client_cacert.pem +32 -0
  19. package/docker/ml-testing-toolkit/secrets/tls/hub_client_cakey.key +51 -0
  20. package/docker/ml-testing-toolkit/secrets/tls/hub_client_key.key +51 -0
  21. package/docker/ml-testing-toolkit/secrets/tls/hub_server.csr +28 -0
  22. package/docker/ml-testing-toolkit/secrets/tls/hub_server_cacert.pem +32 -0
  23. package/docker/ml-testing-toolkit/secrets/tls/hub_server_cacert.srl +1 -0
  24. package/docker/ml-testing-toolkit/secrets/tls/hub_server_cakey.key +51 -0
  25. package/docker/ml-testing-toolkit/secrets/tls/hub_server_cert.pem +33 -0
  26. package/docker/ml-testing-toolkit/secrets/tls/hub_server_key.key +51 -0
  27. package/docker/ml-testing-toolkit/secrets/tls/openssl.conf +17 -0
  28. package/docker/ml-testing-toolkit/spec_files/api_definitions/central_admin_9.3/api_spec.yaml +2450 -0
  29. package/docker/ml-testing-toolkit/spec_files/api_definitions/central_admin_9.3/response_map.json +96 -0
  30. package/docker/ml-testing-toolkit/spec_files/api_definitions/fspiop_1.0/api_spec.yaml +4187 -0
  31. package/docker/ml-testing-toolkit/spec_files/api_definitions/fspiop_1.0/callback_map.json +542 -0
  32. package/docker/ml-testing-toolkit/spec_files/api_definitions/fspiop_1.0/mockRef.json +83 -0
  33. package/docker/ml-testing-toolkit/spec_files/api_definitions/fspiop_1.0/trigger_templates/transaction_request_followup.json +125 -0
  34. package/docker/ml-testing-toolkit/spec_files/api_definitions/fspiop_1.1/api_spec.yaml +3703 -0
  35. package/docker/ml-testing-toolkit/spec_files/api_definitions/fspiop_1.1/callback_map.json +568 -0
  36. package/docker/ml-testing-toolkit/spec_files/api_definitions/fspiop_1.1/mockRef.json +83 -0
  37. package/docker/ml-testing-toolkit/spec_files/api_definitions/fspiop_1.1/trigger_templates/transaction_request_followup.json +125 -0
  38. package/docker/ml-testing-toolkit/spec_files/api_definitions/settlements_1.0/api_spec.yaml +983 -0
  39. package/docker/ml-testing-toolkit/spec_files/api_definitions/settlements_1.0/mockRef.json +38 -0
  40. package/docker/ml-testing-toolkit/spec_files/api_definitions/settlements_1.0/response_map.json +34 -0
  41. package/docker/ml-testing-toolkit/spec_files/reports/templates/newman/html_template.html +1074 -0
  42. package/docker/ml-testing-toolkit/spec_files/reports/templates/newman/pdf_template.html +765 -0
  43. package/docker/ml-testing-toolkit/spec_files/reports/templates/newman/script.js +98 -0
  44. package/docker/ml-testing-toolkit/spec_files/rules_callback/config.json +3 -0
  45. package/docker/ml-testing-toolkit/spec_files/rules_callback/default.json +426 -0
  46. package/docker/ml-testing-toolkit/spec_files/rules_response/config.json +3 -0
  47. package/docker/ml-testing-toolkit/spec_files/rules_response/default.json +1623 -0
  48. package/docker/ml-testing-toolkit/spec_files/rules_response/default_pisp_rules.json +161 -0
  49. package/docker/ml-testing-toolkit/spec_files/rules_validation/config.json +3 -0
  50. package/docker/ml-testing-toolkit/spec_files/rules_validation/default.json +672 -0
  51. package/docker/ml-testing-toolkit/spec_files/system_config.json +62 -0
  52. package/docker/ml-testing-toolkit/spec_files/user_config.json +45 -0
  53. package/docker/wait4/setup_hosts_file.sh +25 -0
  54. package/docker/wait4/wait4.config.js +71 -0
  55. package/docker/wait4/wait4.js +204 -0
  56. package/docker-compose.yml +67 -0
  57. package/docs/Mojaloop - Modusbox Onboarding functionality.pdf +0 -0
  58. package/docs/dfspInboundApi.yaml +1091 -0
  59. package/jest.config.js +4 -1
  60. package/package.json +17 -17
  61. package/secrets/jwsSigningKey.key +27 -0
  62. package/secrets/jwsVerificationKeys/mojaloop-sdk.pem +9 -0
  63. package/secrets/jwsVerificationKeys/switch.pem +9 -0
  64. package/sequences.puml +99 -0
  65. package/src/ControlAgent/index.js +221 -0
  66. package/{TestServer → src/ControlServer}/handlers.js +0 -0
  67. package/src/ControlServer/index.js +294 -0
  68. package/{InboundServer → src/InboundServer}/api.yaml +0 -0
  69. package/src/InboundServer/api_template.yaml +69 -0
  70. package/{InboundServer → src/InboundServer}/handlers.js +0 -0
  71. package/{InboundServer → src/InboundServer}/index.js +33 -1
  72. package/{InboundServer → src/InboundServer}/middlewares.js +0 -0
  73. package/src/OAuthTestServer/index.js +127 -0
  74. package/{OAuthTestServer → src/OAuthTestServer}/model.js +0 -0
  75. package/{OutboundServer → src/OutboundServer}/api.yaml +0 -0
  76. package/{OutboundServer → src/OutboundServer}/api_interfaces/index.d.ts +0 -0
  77. package/{OutboundServer → src/OutboundServer}/api_interfaces/openapi.d.ts +0 -0
  78. package/{OutboundServer → src/OutboundServer}/api_template/components/parameters/bulkQuoteId.yaml +1 -1
  79. package/{OutboundServer → src/OutboundServer}/api_template/components/parameters/bulkTransferId.yaml +1 -1
  80. package/{OutboundServer → src/OutboundServer}/api_template/components/parameters/requestToPayTransactionId.yaml +1 -1
  81. package/{OutboundServer → src/OutboundServer}/api_template/components/parameters/transferId.yaml +1 -1
  82. package/{OutboundServer → src/OutboundServer}/api_template/components/responses/accountsCreationCompleted.yaml +0 -0
  83. package/{OutboundServer → src/OutboundServer}/api_template/components/responses/accountsCreationError.yaml +0 -0
  84. package/{OutboundServer → src/OutboundServer}/api_template/components/responses/accountsCreationTimeout.yaml +0 -0
  85. package/{OutboundServer → src/OutboundServer}/api_template/components/responses/bulkQuoteBadRequest.yaml +0 -0
  86. package/{OutboundServer → src/OutboundServer}/api_template/components/responses/bulkQuoteServerError.yaml +0 -0
  87. package/{OutboundServer → src/OutboundServer}/api_template/components/responses/bulkQuoteSuccess.yaml +0 -0
  88. package/{OutboundServer → src/OutboundServer}/api_template/components/responses/bulkQuoteTimeout.yaml +0 -0
  89. package/{OutboundServer → src/OutboundServer}/api_template/components/responses/bulkTransferBadRequest.yaml +0 -0
  90. package/{OutboundServer → src/OutboundServer}/api_template/components/responses/bulkTransferServerError.yaml +0 -0
  91. package/{OutboundServer → src/OutboundServer}/api_template/components/responses/bulkTransferSuccess.yaml +0 -0
  92. package/{OutboundServer → src/OutboundServer}/api_template/components/responses/bulkTransferTimeout.yaml +0 -0
  93. package/{OutboundServer → src/OutboundServer}/api_template/components/responses/partiesByIdError404.yaml +1 -1
  94. package/{OutboundServer → src/OutboundServer}/api_template/components/responses/partiesByIdSuccess.yaml +0 -0
  95. package/{OutboundServer → src/OutboundServer}/api_template/components/responses/quotesPostSuccess.yaml +0 -0
  96. package/{OutboundServer → src/OutboundServer}/api_template/components/responses/quotesServerError.yaml +0 -0
  97. package/{OutboundServer → src/OutboundServer}/api_template/components/responses/requestToPaySuccess.yaml +0 -0
  98. package/{OutboundServer → src/OutboundServer}/api_template/components/responses/requestToPayTransferBadRequest.yaml +0 -0
  99. package/{OutboundServer → src/OutboundServer}/api_template/components/responses/requestToPayTransferSuccess.yaml +0 -0
  100. package/{OutboundServer → src/OutboundServer}/api_template/components/responses/simpleTransfersPostSuccess.yaml +0 -0
  101. package/{OutboundServer → src/OutboundServer}/api_template/components/responses/simpleTransfersServerError.yaml +0 -0
  102. package/{OutboundServer → src/OutboundServer}/api_template/components/responses/transferBadRequest.yaml +0 -0
  103. package/{OutboundServer → src/OutboundServer}/api_template/components/responses/transferServerError.yaml +0 -0
  104. package/{OutboundServer → src/OutboundServer}/api_template/components/responses/transferSuccess.yaml +0 -0
  105. package/{OutboundServer → src/OutboundServer}/api_template/components/responses/transferTimeout.yaml +0 -0
  106. package/src/OutboundServer/api_template/components/schemas/accountCreationStatus.yaml +18 -0
  107. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/accountsCreationState.yaml +0 -0
  108. package/src/OutboundServer/api_template/components/schemas/accountsRequest.yaml +20 -0
  109. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/accountsResponse.yaml +1 -1
  110. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/async2SyncCurrentState.yaml +0 -0
  111. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/bulkQuoteErrorResponse.yaml +0 -0
  112. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/bulkQuoteRequest.yaml +2 -2
  113. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/bulkQuoteResponse.yaml +1 -1
  114. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/bulkQuoteStatus.yaml +0 -0
  115. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/bulkQuoteStatusResponse.yaml +1 -1
  116. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/bulkTransferErrorResponse.yaml +0 -0
  117. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/bulkTransferRequest.yaml +2 -2
  118. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/bulkTransferResponse.yaml +1 -1
  119. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/bulkTransferStatus.yaml +0 -0
  120. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/bulkTransferStatusResponse.yaml +1 -1
  121. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/errorAccountsResponse.yaml +0 -0
  122. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/errorQuotesResponse.yaml +0 -0
  123. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/errorResponse.yaml +0 -0
  124. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/errorSimpleTransfersResponse.yaml +0 -0
  125. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/errorTransferResponse.yaml +0 -0
  126. package/src/OutboundServer/api_template/components/schemas/extensionListEmptiable.yaml +6 -0
  127. package/src/OutboundServer/api_template/components/schemas/individualQuote.yaml +32 -0
  128. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/individualQuoteResult.yaml +5 -5
  129. package/src/OutboundServer/api_template/components/schemas/individualTransfer.yaml +32 -0
  130. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/individualTransferFulfilment.yaml +2 -2
  131. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/individualTransferResult.yaml +6 -6
  132. package/src/OutboundServer/api_template/components/schemas/mojaloopError.yaml +5 -0
  133. package/src/OutboundServer/api_template/components/schemas/mojaloopTransactionRequestState.yaml +2 -0
  134. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/partiesByIdResponse.yaml +1 -1
  135. package/src/OutboundServer/api_template/components/schemas/quote.yaml +3 -0
  136. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/quoteError.yaml +0 -0
  137. package/src/OutboundServer/api_template/components/schemas/quotesPostRequest.yaml +13 -0
  138. package/src/OutboundServer/api_template/components/schemas/quotesPostResponse.yaml +48 -0
  139. package/src/OutboundServer/api_template/components/schemas/requestToPayRequest.yaml +39 -0
  140. package/src/OutboundServer/api_template/components/schemas/requestToPayResponse.yaml +41 -0
  141. package/src/OutboundServer/api_template/components/schemas/requestToPayTransferRequest.yaml +42 -0
  142. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/requestToPayTransferResponse.yaml +6 -6
  143. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/simpleTransferServerError.yaml +0 -0
  144. package/src/OutboundServer/api_template/components/schemas/simpleTransfersPostRequest.yaml +12 -0
  145. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/simpleTransfersPostResponse.yaml +1 -1
  146. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/transactionType.yaml +0 -0
  147. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/transferContinuationAcceptOTP.yaml +0 -0
  148. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/transferContinuationAcceptParty.yaml +0 -0
  149. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/transferContinuationAcceptQuote.yaml +0 -0
  150. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/transferError.yaml +0 -0
  151. package/src/OutboundServer/api_template/components/schemas/transferFulfilment.yaml +3 -0
  152. package/src/OutboundServer/api_template/components/schemas/transferParty.yaml +40 -0
  153. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/transferRequest.yaml +4 -4
  154. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/transferResponse.yaml +6 -6
  155. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/transferStatus.yaml +0 -0
  156. package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/transferStatusResponse.yaml +1 -1
  157. package/{OutboundServer → src/OutboundServer}/api_template/health.yaml +0 -0
  158. package/{OutboundServer → src/OutboundServer}/api_template/openapi.yaml +0 -0
  159. package/{OutboundServer → src/OutboundServer}/api_template/paths/accounts.yaml +0 -0
  160. package/{OutboundServer → src/OutboundServer}/api_template/paths/bulkQuotes.yaml +0 -0
  161. package/{OutboundServer → src/OutboundServer}/api_template/paths/bulkQuotes_bulkQuoteId.yaml +0 -0
  162. package/{OutboundServer → src/OutboundServer}/api_template/paths/bulkTransfers.yaml +0 -0
  163. package/{OutboundServer → src/OutboundServer}/api_template/paths/bulkTransfers_bulkTransferId.yaml +0 -0
  164. package/{OutboundServer → src/OutboundServer}/api_template/paths/parties_Type_ID.yaml +2 -2
  165. package/{OutboundServer → src/OutboundServer}/api_template/paths/parties_Type_ID_SubId.yaml +3 -3
  166. package/{OutboundServer → src/OutboundServer}/api_template/paths/quotes.yaml +0 -0
  167. package/{OutboundServer → src/OutboundServer}/api_template/paths/requestToPay.yaml +0 -0
  168. package/{OutboundServer → src/OutboundServer}/api_template/paths/requestToPayTransfer.yaml +0 -0
  169. package/{OutboundServer → src/OutboundServer}/api_template/paths/requestToPayTransfer_requestToPayTransactionId.yaml +0 -0
  170. package/{OutboundServer → src/OutboundServer}/api_template/paths/simpleTransfers.yaml +0 -0
  171. package/{OutboundServer → src/OutboundServer}/api_template/paths/transfers.yaml +0 -0
  172. package/{OutboundServer → src/OutboundServer}/api_template/paths/transfers_transferId.yaml +0 -0
  173. package/{OutboundServer → src/OutboundServer}/handlers.js +0 -0
  174. package/{OutboundServer → src/OutboundServer}/index.js +15 -0
  175. package/{OutboundServer → src/OutboundServer}/middlewares.js +0 -0
  176. package/{TestServer → src/TestServer}/api.yaml +0 -0
  177. package/src/TestServer/handlers.js +63 -0
  178. package/{TestServer → src/TestServer}/index.js +31 -0
  179. package/{config.js → src/config.js} +6 -0
  180. package/{index.d.ts → src/index.d.ts} +0 -0
  181. package/{index.js → src/index.js} +0 -0
  182. package/{lib → src/lib}/api/index.js +0 -0
  183. package/{lib → src/lib}/cache.js +0 -0
  184. package/{lib → src/lib}/check.js +0 -0
  185. package/{lib → src/lib}/model/AccountsModel.js +0 -0
  186. package/{lib → src/lib}/model/Async2SyncModel.js +0 -0
  187. package/{lib → src/lib}/model/InboundTransfersModel.js +0 -0
  188. package/{lib → src/lib}/model/OutboundBulkQuotesModel.js +0 -0
  189. package/{lib → src/lib}/model/OutboundBulkTransfersModel.js +0 -0
  190. package/{lib → src/lib}/model/OutboundRequestToPayModel.js +0 -0
  191. package/{lib → src/lib}/model/OutboundRequestToPayTransferModel.js +0 -0
  192. package/{lib → src/lib}/model/OutboundTransfersModel.js +0 -0
  193. package/{lib → src/lib}/model/PartiesModel.js +0 -0
  194. package/{lib → src/lib}/model/ProxyModel/MatchRules/Expression.js +0 -0
  195. package/{lib → src/lib}/model/ProxyModel/MatchRules/Headers.js +0 -0
  196. package/{lib → src/lib}/model/ProxyModel/MatchRules/MatchRule.js +0 -0
  197. package/{lib → src/lib}/model/ProxyModel/MatchRules/Path.js +0 -0
  198. package/{lib → src/lib}/model/ProxyModel/MatchRules/Query.js +0 -0
  199. package/{lib → src/lib}/model/ProxyModel/MatchRules/index.js +0 -0
  200. package/{lib → src/lib}/model/ProxyModel/Route.js +0 -0
  201. package/{lib → src/lib}/model/ProxyModel/configSchema.json +0 -0
  202. package/{lib → src/lib}/model/ProxyModel/index.js +0 -0
  203. package/{lib → src/lib}/model/QuotesModel.js +0 -0
  204. package/{lib → src/lib}/model/TransfersModel.js +0 -0
  205. package/{lib → src/lib}/model/common/BackendError.js +0 -0
  206. package/{lib → src/lib}/model/common/PersistentStateMachine.js +0 -0
  207. package/{lib → src/lib}/model/common/index.js +0 -0
  208. package/{lib → src/lib}/model/index.js +0 -0
  209. package/{lib → src/lib}/model/lib/deferredJob.js +0 -0
  210. package/{lib → src/lib}/model/lib/index.js +0 -0
  211. package/{lib → src/lib}/model/lib/requests/backendRequests.js +0 -0
  212. package/{lib → src/lib}/model/lib/requests/common.js +0 -0
  213. package/{lib → src/lib}/model/lib/requests/index.js +0 -0
  214. package/{lib → src/lib}/model/lib/shared.js +0 -0
  215. package/{lib → src/lib}/randomphrase/index.js +0 -0
  216. package/{lib → src/lib}/randomphrase/words.json +0 -0
  217. package/{lib → src/lib}/router.js +0 -0
  218. package/{lib → src/lib}/validate.js +0 -0
  219. package/test/config/integration.env +9 -0
  220. package/test/integration/lib/cache.test.js +3 -3
  221. package/test/unit/ControlClient.test.js +113 -0
  222. package/test/unit/ControlServer/events.js +41 -0
  223. package/test/unit/ControlServer/index.js +231 -0
  224. package/test/unit/ControlServer.test.js +126 -0
  225. package/test/unit/InboundServer.test.js +5 -5
  226. package/test/unit/TestServer.test.js +5 -5
  227. package/test/unit/api/utils.js +5 -5
  228. package/test/unit/config.test.js +11 -10
  229. package/test/unit/inboundApi/handlers.test.js +6 -6
  230. package/test/unit/index.test.js +2 -1
  231. package/test/unit/lib/cache.test.js +1 -1
  232. package/test/unit/lib/model/AccountsModel.test.js +2 -2
  233. package/test/unit/lib/model/InboundTransfersModel.test.js +5 -5
  234. package/test/unit/lib/model/OutboundBulkQuotesModel.test.js +2 -2
  235. package/test/unit/lib/model/OutboundBulkTransfersModel.test.js +2 -2
  236. package/test/unit/lib/model/OutboundRequestToPayModel.test.js +3 -3
  237. package/test/unit/lib/model/OutboundRequestToPayTransferModel.test.js +2 -2
  238. package/test/unit/lib/model/OutboundTransfersModel.test.js +3 -3
  239. package/test/unit/lib/model/PartiesModel.test.js +28 -28
  240. package/test/unit/lib/model/QuotesModel.test.js +31 -31
  241. package/test/unit/lib/model/TransfersModel.test.js +3 -3
  242. package/test/unit/lib/model/common/PersistentStateMachine.test.js +13 -13
  243. package/test/unit/lib/model/mockedLibRequests.js +1 -1
  244. package/test/unit/outboundApi/handlers.test.js +3 -3
  245. package/.eslintignore +0 -2
  246. package/InboundServer/api_template.yaml +0 -69
  247. package/OAuthTestServer/index.js +0 -66
  248. package/OutboundServer/api_template/components/schemas/accountCreationStatus.yaml +0 -18
  249. package/OutboundServer/api_template/components/schemas/accountsRequest.yaml +0 -20
  250. package/OutboundServer/api_template/components/schemas/extensionListEmptiable.yaml +0 -6
  251. package/OutboundServer/api_template/components/schemas/individualQuote.yaml +0 -32
  252. package/OutboundServer/api_template/components/schemas/individualTransfer.yaml +0 -32
  253. package/OutboundServer/api_template/components/schemas/mojaloopError.yaml +0 -5
  254. package/OutboundServer/api_template/components/schemas/mojaloopTransactionRequestState.yaml +0 -2
  255. package/OutboundServer/api_template/components/schemas/quote.yaml +0 -3
  256. package/OutboundServer/api_template/components/schemas/quotesPostRequest.yaml +0 -13
  257. package/OutboundServer/api_template/components/schemas/quotesPostResponse.yaml +0 -48
  258. package/OutboundServer/api_template/components/schemas/requestToPayRequest.yaml +0 -39
  259. package/OutboundServer/api_template/components/schemas/requestToPayResponse.yaml +0 -41
  260. package/OutboundServer/api_template/components/schemas/requestToPayTransferRequest.yaml +0 -42
  261. package/OutboundServer/api_template/components/schemas/simpleTransfersPostRequest.yaml +0 -12
  262. package/OutboundServer/api_template/components/schemas/transferFulfilment.yaml +0 -3
  263. package/OutboundServer/api_template/components/schemas/transferParty.yaml +0 -40
package/jest.config.js CHANGED
@@ -11,5 +11,8 @@ module.exports = {
11
11
  lines: 90
12
12
  }
13
13
  },
14
- clearMocks: true
14
+ clearMocks: true,
15
+ moduleNameMapper: {
16
+ "^~/(.*)$": "<rootDir>/src/$1"
17
+ }
15
18
  };
package/package.json CHANGED
@@ -1,27 +1,30 @@
1
1
  {
2
2
  "name": "@mojaloop/sdk-scheme-adapter",
3
- "version": "12.0.0",
3
+ "version": "12.1.0",
4
4
  "description": "An adapter for connecting to Mojaloop API enabled switches.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "engines": {
8
- "node": ">=14.15"
8
+ "node": "=16.x"
9
+ },
10
+ "_moduleAliases": {
11
+ "~": "src"
9
12
  },
10
13
  "scripts": {
11
14
  "audit:resolve": "SHELL=sh resolve-audit --production",
12
15
  "audit:check": "SHELL=sh check-audit --production",
13
16
  "build": "npm run build:openapi; npm run build:dto:outbound",
14
17
  "build:openapi": "npm run build:openapi:inbound && npm run build:openapi:outbound",
15
- "build:openapi:inbound": "openapi bundle --output ./InboundServer/api.yaml --ext yaml ./InboundServer/api_template.yaml",
16
- "build:openapi:outbound": "openapi bundle --output ./OutboundServer/api.yaml --ext yaml ./OutboundServer/api_template/openapi.yaml",
17
- "build:dto:outbound": "openapi-typescript ./OutboundServer/api.yaml --output ./OutboundServer/api_interfaces/openapi.d.ts",
18
- "lint": "eslint .",
19
- "lint:fix": "eslint . --fix",
18
+ "build:openapi:inbound": "openapi bundle --output ./src/InboundServer/api.yaml --ext yaml ./src/InboundServer/api_template.yaml",
19
+ "build:openapi:outbound": "openapi bundle --output ./src/OutboundServer/api.yaml --ext yaml ./src/OutboundServer/api_template/openapi.yaml",
20
+ "build:dto:outbound": "openapi-typescript ./src/OutboundServer/api.yaml --output ./src/OutboundServer/api_interfaces/openapi.d.ts",
21
+ "lint": "eslint ./src/",
22
+ "lint:fix": "eslint ./src/ --fix",
20
23
  "test": "jest --ci --reporters=default --reporters=jest-junit --env=node test/unit/",
21
24
  "test:int": "jest --ci --reporters=default --reporters=jest-junit --env=node test/integration",
22
25
  "validate:api": "npm run validate:api:in; npm run validate:api:out",
23
- "validate:api:in": "swagger-cli validate ./InboundServer/api.yaml",
24
- "validate:api:out": "swagger-cli validate ./OutboundServer/api.yaml",
26
+ "validate:api:in": "swagger-cli validate ./src/InboundServer/api.yaml",
27
+ "validate:api:out": "swagger-cli validate ./src/OutboundServer/api.yaml",
25
28
  "updates:check": "npm run dep:check",
26
29
  "updates:update": "npm run dep:update && npm install",
27
30
  "dep:check": "npx ncu -e 2",
@@ -49,12 +52,6 @@
49
52
  "type": "git",
50
53
  "url": "git@github.com:mojaloop/sdk-scheme-adapter.git"
51
54
  },
52
- "@comment dependencies": [
53
- "koa2-oauth-server is an old unmaintained repo. It uses the now unsupported git protocol.",
54
- "Please see https://github.blog/2021-09-01-improving-git-protocol-security-github/ for more information.",
55
- "If you regenerate package-lock.json, you will manually have to update `git://` to `https://` on its",
56
- "dependencies."
57
- ],
58
55
  "dependencies": {
59
56
  "@koa/cors": "^3.1.0",
60
57
  "@mojaloop/central-services-error-handling": "11.3.0",
@@ -70,12 +67,15 @@
70
67
  "co-body": "^6.1.0",
71
68
  "dotenv": "^10.0.0",
72
69
  "env-var": "^7.0.1",
70
+ "express": "^4.17.2",
71
+ "fast-json-patch": "^3.1.1",
73
72
  "javascript-state-machine": "^3.1.0",
74
73
  "js-yaml": "^4.1.0",
75
74
  "json-schema-ref-parser": "^9.0.9",
76
75
  "koa": "^2.13.1",
77
76
  "koa-body": "^4.2.0",
78
- "koa2-oauth-server": "^1.0.0",
77
+ "module-alias": "^2.2.2",
78
+ "oauth2-server": "^4.0.0-dev.2",
79
79
  "openapi-jsonschema-parameters": "^9.3.0",
80
80
  "promise-timeout": "^1.3.0",
81
81
  "redis": "^3.1.2",
@@ -96,7 +96,7 @@
96
96
  "jest": "^27.2.0",
97
97
  "jest-junit": "^12.2.0",
98
98
  "nock": "^13.1.3",
99
- "npm-audit-resolver": "^2.3.1",
99
+ "npm-audit-resolver": "^3.0.0-0",
100
100
  "npm-check-updates": "^11.8.5",
101
101
  "openapi-response-validator": "^9.3.0",
102
102
  "openapi-typescript": "^4.0.2",
@@ -0,0 +1,27 @@
1
+ -----BEGIN RSA PRIVATE KEY-----
2
+ MIIEowIBAAKCAQEA0eJEh3Op5p6x137lRkAsvmEBbd32dbRChrCUItZbtxjf/qfB
3
+ yD5k8Hn4n4vbqzP8XSGS0f6KmNC+iRaP74HVgzAqc4Uid4J8dtSBq3VmucYQYzLc
4
+ 101QjuvD+SKmZwlw/q0PtulmqlASI2SbMfwcAraMi6ab7v5W4EGNeIPLEIo3BXsQ
5
+ DTCWqiZb7aXkHkcY7sOjAzK/2bNGYFmAthdYrHzvCkqnJ7LAHX3Oj7rJea5MqtuN
6
+ B9POZYaD10n9JuYWdwPqLrw6/hVgPSFEy+ulrVbXf54ZH0dfMThAYRvFrT81yulk
7
+ H95JhXWGdi6cTp6t8LVOKFhnNfxjWw0Jayj9xwIDAQABAoIBADB2u/Y/CgNbr5sg
8
+ DRccqHhJdAgHkep59kadrYch0knEL6zg1clERxCUSYmlxNKSjXp/zyQ4T46b3PNQ
9
+ x2m5pDDHxXWpT10jP1Q9G7gYwuCw0IXnb8EzdB+cZ0M28g+myXW1RoSo/nDjTlzn
10
+ 1UJEgb9Kocd5cFZOWocr+9vRKumlZULMsA8yiNwlAfJHcMBM7acsa3myCqVhLyWt
11
+ 4BQylVuLFa+A6QzpMXEwFCq8EOXf07gl1XVzC6LJ1fTa9gVM3N+YE+oEXKrsHCxG
12
+ /ACgKsjepL27QjJ7qvecWPP0F2LxEZYOm5tbXaKJTobzQUJHgUokanZMhjYprDsZ
13
+ zumLw9kCgYEA/DUWcnLeImlfq/EYdhejkl3J+WX3vhS23OqVgY1amu7CZzaai6vt
14
+ H0TRc8Zsbi4jgmFDU8PFzytP6qz6Tgom4R736z6oBi7bjnGyN17/NSbf+DaRVcM6
15
+ vnZr7jNC2FJlECmIN+dkwUA/YCr2SA7hxZXM9mIYSc+6+glDiIO5Cf0CgYEA1Qo/
16
+ uQbVHhW+Cp8H0kdMuhwUbkBquRrxRZlXS1Vrf3f9me9JLUy9UPWb3y3sKVurG5+O
17
+ SIlr4hDcZyXdE198MtDMhBIGqU9ORSjppJDNDVvtt+n2FD4XmWIU70vKBJBivX0+
18
+ Bow6yduis+p12fuvpvpnKCz8UjOgOQJhLZ4GQBMCgYBP6gpozVjxkm4ML2LO2IKt
19
+ +CXtbo/nnOysZ3BkEoQpH4pd5gFmTF3gUJAFnVPyPZBm2abZvejJ0jGKbLELVVAo
20
+ eQWZdssK2oIbSo9r2CAJmX3SSogWorvUafWdDoUZwlHfoylUfW+BhHgQYsyS3JRR
21
+ ZTwCveZwTPA0FgdeFE7niQKBgQCHaD8+ZFhbCejDqXb4MXdUJ3rY5Lqwsq491YwF
22
+ huKPn32iNNQnJcqCxclv3iln1Cr6oLx34Fig1KSyLv/IS32OcuY635Y6UPznumxe
23
+ u+aJIjADIILXNOwdAplZy6s4oWkRFaSx1rmbCa3tew2zImTv1eJxR76MpOGmupt3
24
+ uiQw3wKBgFjBT/aVKdBeHeP1rIHHldQV5QQxZNkc6D3qn/oAFcwpj9vcGfRjQWjO
25
+ ARzXM2vUWEet4OVn3DXyOdaWFR1ppehz7rAWBiPgsMg4fjAusYb9Mft1GMxMzuwT
26
+ Oyqsp6pzAWFrCD3JAoTLxClV+j5m+SXZ/ItD6ziGpl/h7DyayrFZ
27
+ -----END RSA PRIVATE KEY-----
@@ -0,0 +1,9 @@
1
+ -----BEGIN PUBLIC KEY-----
2
+ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0eJEh3Op5p6x137lRkAs
3
+ vmEBbd32dbRChrCUItZbtxjf/qfByD5k8Hn4n4vbqzP8XSGS0f6KmNC+iRaP74HV
4
+ gzAqc4Uid4J8dtSBq3VmucYQYzLc101QjuvD+SKmZwlw/q0PtulmqlASI2SbMfwc
5
+ AraMi6ab7v5W4EGNeIPLEIo3BXsQDTCWqiZb7aXkHkcY7sOjAzK/2bNGYFmAthdY
6
+ rHzvCkqnJ7LAHX3Oj7rJea5MqtuNB9POZYaD10n9JuYWdwPqLrw6/hVgPSFEy+ul
7
+ rVbXf54ZH0dfMThAYRvFrT81yulkH95JhXWGdi6cTp6t8LVOKFhnNfxjWw0Jayj9
8
+ xwIDAQAB
9
+ -----END PUBLIC KEY-----
@@ -0,0 +1,9 @@
1
+ -----BEGIN PUBLIC KEY-----
2
+ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvs6EjaQYxTPI2dS+L6zJ
3
+ QhszHCP79huvCDPhy/BmTWI4350rjWiclBC/joy7BUGJszIVv6rrwbeN9OORHXwW
4
+ 0XSjcCEeksdkAee9kGvx/A2UcUOsQQ3A3IvoxJAv+HJSmCGeKsc2pMrelBtma54i
5
+ 1JBF6H+SwrcM0a+UVsADQXOzKuyiRYnkCEhZYHXAk7hM3cARvhYydqUnPehFccjS
6
+ 8v6sNTRZnqJ7z/XT3EKYkfizcCkHiV9elB/PGGzkFWLjHZVTC/+hK6WhFYGEktNb
7
+ QfDuMA4mnZT37QZEL1PlhnFfjfnrnpjFjcFzKJ+hHRrHqA9FZlo6J9efnUn/VHVC
8
+ sQIDAQAB
9
+ -----END PUBLIC KEY-----
package/sequences.puml ADDED
@@ -0,0 +1,99 @@
1
+
2
+
3
+ @startuml
4
+ title Mojaloop SDK Interactions
5
+ autonumber
6
+
7
+ participant "DFSP Backend" as backend
8
+ participant "ESB/PortX" as esb
9
+
10
+ box "SDK"
11
+ participant "SDK Inbound Service" as sib
12
+ participant "SDK Outbound Service" as sob
13
+ end box
14
+
15
+
16
+ participant "Switch" as sw
17
+
18
+
19
+ note over sib, sob: All outbound between SDK and Switch have\nJWS added automatically
20
+ note over sib, sob: All inbound from switch have JWS validated
21
+
22
+ note over sib, sob: Mapping between scheme transaction types and DFSP\ntransaction types
23
+ note over sib, sob: JWS and TLS keys managed by SDK
24
+
25
+ == send money ==
26
+
27
+ backend -> sob: POST /transfers
28
+
29
+ sob -> sw: GET /parties
30
+ sw -> sob: PUT /parties
31
+ sob -> sw: POST /quotes
32
+ sw -> sob: PUT /quotes
33
+ sob -> sw: POST /transfers
34
+ sw -> sob: PUT /transfers
35
+
36
+ sob -> backend: HTTP 200
37
+
38
+ == query transfer ==
39
+
40
+ backend -> sob: GET /transfers/{ID}
41
+ sob -> sw: GET /transfers/{ID}
42
+ sw -> sob: PUT /transfers/{ID}
43
+ sob -> backend: transfer info
44
+
45
+ == receive money ==
46
+
47
+ sw -> sib: GET /parties
48
+ sib -> esb: GET /parties
49
+ esb -> backend: lookup user account
50
+ backend -> esb: user details
51
+ esb -> sib: user details
52
+ sib -> sw: PUT /parties
53
+
54
+ sw -> sib: POST /quotes
55
+
56
+ alt SDK handles quote request autonomously
57
+
58
+ sib -> sib: calculate quote
59
+
60
+ else backend calculates quote
61
+
62
+ sib -> esb: POST /quotes
63
+ esb -> backend: quote request
64
+ backend -> esb: quote response
65
+ esb -> sib: quote response
66
+
67
+ end
68
+
69
+ sib -> sib: create ILP packet\ncalculate condition
70
+
71
+ sib -> sw: PUT /quotes
72
+
73
+ sw -> sib: POST /transfers
74
+ sib -> sib: validate ILP
75
+ sib -> esb: POST /transfers
76
+ esb -> backend: accept money?
77
+
78
+ alt accepting money
79
+
80
+ backend -> esb: OK
81
+ esb -> sib: OK
82
+ sib -> sib: calculate ILP fulfilment
83
+ sib -> sw: PUT /transfers
84
+
85
+ sw -> sib: OK notification
86
+ sib -> esb: OK notification
87
+ esb -> backend: money received OK
88
+
89
+ else not accepting money
90
+
91
+ backend -> esb: NOK
92
+ esb -> sib: NOK
93
+ sib -> sw: PUT /transfers/{ID}/error
94
+
95
+ end
96
+
97
+
98
+ @enduml
99
+
@@ -0,0 +1,221 @@
1
+ /**************************************************************************
2
+ * (C) Copyright ModusBox Inc. 2020 - All rights reserved. *
3
+ * *
4
+ * This file is made available under the terms of the license agreement *
5
+ * specified in the corresponding source code repository. *
6
+ * *
7
+ * ORIGINAL AUTHOR: *
8
+ * Matt Kingston - matt.kingston@modusbox.com *
9
+ **************************************************************************/
10
+
11
+ // This server has deliberately been written separate from any other server in the SDK. There is
12
+ // some reasonable argument that it could be part of the outbound or test server. It has not been
13
+ // incorporated in either as, at the time of writing, it is intended to be maintained in a
14
+ // proprietary fork. Therefore, keeping it independent of other servers will avoid the maintenance
15
+ // burden that would otherwise be associated with incorporating it with those.
16
+ //
17
+ // It inherits from the Server class from the 'ws' websocket library for Node, which in turn
18
+ // inherits from EventEmitter. We exploit this to emit an event when a reconfigure message is sent
19
+ // to this server. Then, when this server's reconfigure method is called, it reconfigures itself
20
+ // and sends a message to all clients notifying them of the new application configuration.
21
+ //
22
+ // It expects new configuration to be supplied as an array of JSON patches. It therefore exposes
23
+ // the current configuration to
24
+
25
+ const assert = require('assert').strict;
26
+ const ws = require('ws');
27
+ const jsonPatch = require('fast-json-patch');
28
+ const randomPhrase = require('~/lib/randomphrase');
29
+
30
+
31
+ /**************************************************************************
32
+ * The message protocol messages, verbs, and errors
33
+ *************************************************************************/
34
+ const MESSAGE = {
35
+ CONFIGURATION: 'CONFIGURATION',
36
+ ERROR: 'ERROR',
37
+ };
38
+
39
+ const VERB = {
40
+ READ: 'READ',
41
+ NOTIFY: 'NOTIFY',
42
+ PATCH: 'PATCH'
43
+ };
44
+
45
+ const ERROR = {
46
+ UNSUPPORTED_MESSAGE: 'UNSUPPORTED_MESSAGE',
47
+ UNSUPPORTED_VERB: 'UNSUPPORTED_VERB',
48
+ JSON_PARSE_ERROR: 'JSON_PARSE_ERROR',
49
+ };
50
+
51
+ /**************************************************************************
52
+ * Events emitted by the control client
53
+ *************************************************************************/
54
+ const EVENT = {
55
+ RECONFIGURE: 'RECONFIGURE',
56
+ };
57
+
58
+ /**************************************************************************
59
+ * Private convenience functions
60
+ *************************************************************************/
61
+ const serialise = JSON.stringify;
62
+ const deserialise = (msg) => {
63
+ //reviver function
64
+ return JSON.parse(msg.toString(), (k, v) => {
65
+ if (
66
+ v !== null &&
67
+ typeof v === 'object' &&
68
+ 'type' in v &&
69
+ v.type === 'Buffer' &&
70
+ 'data' in v &&
71
+ Array.isArray(v.data)) {
72
+ return new Buffer(v.data);
73
+ }
74
+ return v;
75
+ });
76
+ };
77
+
78
+ const buildMsg = (verb, msg, data, id = randomPhrase()) => serialise({
79
+ verb,
80
+ msg,
81
+ data,
82
+ id,
83
+ });
84
+
85
+ const buildPatchConfiguration = (oldConf, newConf, id) => {
86
+ const patches = jsonPatch.compare(oldConf, newConf);
87
+ return buildMsg(VERB.PATCH, MESSAGE.CONFIGURATION, patches, id);
88
+ };
89
+
90
+ /**************************************************************************
91
+ * build
92
+ *
93
+ * Public object exposing an API to build valid protocol messages.
94
+ * It is not the only way to build valid messages within the protocol.
95
+ *************************************************************************/
96
+ const build = {
97
+ CONFIGURATION: {
98
+ PATCH: buildPatchConfiguration,
99
+ READ: (id) => buildMsg(VERB.READ, MESSAGE.CONFIGURATION, {}, id),
100
+ NOTIFY: (config, id) => buildMsg(VERB.NOTIFY, MESSAGE.CONFIGURATION, config, id),
101
+ },
102
+ ERROR: {
103
+ NOTIFY: {
104
+ UNSUPPORTED_MESSAGE: (id) => buildMsg(VERB.NOTIFY, MESSAGE.ERROR, ERROR.UNSUPPORTED_MESSAGE, id),
105
+ UNSUPPORTED_VERB: (id) => buildMsg(VERB.NOTIFY, MESSAGE.ERROR, ERROR.UNSUPPORTED_VERB, id),
106
+ JSON_PARSE_ERROR: (id) => buildMsg(VERB.NOTIFY, MESSAGE.ERROR, ERROR.JSON_PARSE_ERROR, id),
107
+ }
108
+ },
109
+ };
110
+
111
+ /**************************************************************************
112
+ * Client
113
+ *
114
+ * The Control Client. Client for the websocket control API.
115
+ * Used to hot-restart the SDK.
116
+ *
117
+ * logger - Logger- see SDK logger used elsewhere
118
+ * address - address of control server
119
+ * port - port of control server
120
+ *************************************************************************/
121
+ class Client extends ws {
122
+ /**
123
+ * Consider this a private constructor.
124
+ * `Client` instances outside of this class should be created via the `Create(...args)` static method.
125
+ */
126
+ constructor({ address = 'localhost', port, logger, appConfig }) {
127
+ super(`ws://${address}:${port}`);
128
+ this._logger = logger;
129
+ this._appConfig = appConfig;
130
+ }
131
+
132
+ // Really only exposed so that a user can import only the client for convenience
133
+ get Build() {
134
+ return build;
135
+ }
136
+
137
+ static Create(...args) {
138
+ return new Promise((resolve, reject) => {
139
+ const client = new Client(...args);
140
+ client.on('open', () => resolve(client));
141
+ client.on('error', (err) => reject(err));
142
+ client.on('message', client._handle);
143
+ });
144
+ }
145
+
146
+ async send(msg) {
147
+ const data = typeof msg === 'string' ? msg : serialise(msg);
148
+ this._logger.push({ data }).log('Sending message');
149
+ return new Promise((resolve) => super.send.call(this, data, resolve));
150
+ }
151
+
152
+ // Receive a single message
153
+ async receive() {
154
+ return new Promise((resolve) => this.once('message', (data) => {
155
+ const msg = deserialise(data);
156
+ this._logger.push({ msg }).log('Received');
157
+ resolve(msg);
158
+ }));
159
+ }
160
+
161
+ // Close connection
162
+ async stop() {
163
+ this._logger.log('Control client shutting down...');
164
+ this.close();
165
+ }
166
+
167
+ reconfigure({ logger = this._logger, port = 0, appConfig = this._appConfig }) {
168
+ assert(port === this._socket.remotePort, 'Cannot reconfigure running port');
169
+ return () => {
170
+ this._logger = logger;
171
+ this._appConfig = appConfig;
172
+ this._logger.log('restarted');
173
+ };
174
+ }
175
+
176
+ // Handle incoming message from the server.
177
+ _handle(data) {
178
+ // TODO: json-schema validation of received message- should be pretty straight-forward
179
+ // and will allow better documentation of the API
180
+ let msg;
181
+ try {
182
+ msg = deserialise(data);
183
+ } catch (err) {
184
+ this._logger.push({ data }).log('Couldn\'t parse received message');
185
+ this.send(build.ERROR.NOTIFY.JSON_PARSE_ERROR());
186
+ }
187
+ this._logger.push({ msg }).log('Handling received message');
188
+ switch (msg.msg) {
189
+ case MESSAGE.CONFIGURATION:
190
+ switch (msg.verb) {
191
+ case VERB.NOTIFY:
192
+ case VERB.PATCH: {
193
+ const dup = JSON.parse(JSON.stringify(this._appConfig)); // fast-json-patch explicitly mutates
194
+ jsonPatch.applyPatch(dup, msg.data);
195
+ this._logger.push({ oldConf: this._appConfig, newConf: dup }).log('Emitting new configuration');
196
+ this.emit(EVENT.RECONFIGURE, dup);
197
+ break;
198
+ }
199
+ default:
200
+ this.send(build.ERROR.NOTIFY.UNSUPPORTED_VERB(msg.id));
201
+ break;
202
+ }
203
+ break;
204
+ default:
205
+ this.send(build.ERROR.NOTIFY.UNSUPPORTED_MESSAGE(msg.id));
206
+ break;
207
+ }
208
+
209
+ }
210
+ }
211
+
212
+
213
+
214
+ module.exports = {
215
+ Client,
216
+ build,
217
+ MESSAGE,
218
+ VERB,
219
+ ERROR,
220
+ EVENT,
221
+ };
File without changes