@mojaloop/central-ledger 16.3.4-snapshot.0 → 16.4.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/.ncurc.yaml CHANGED
@@ -5,5 +5,11 @@ reject: [
5
5
  # TODO: New versions from 2.2.0 onwards introduce a newer incompatible version of the ILP-Packet that is not compatible with the Mojaloop Specification
6
6
  "ilp-packet",
7
7
  # TODO: v6+ (ref: https://github.com/sindresorhus/get-port/releases/tag/v6.0.0) is an ESM library and thus not compatible with CommonJS. Future story needed to resolve.
8
- "get-port"
8
+ "get-port",
9
+ # There seems to be an issue with seeding or migration with integration tests
10
+ # that lead to some tests failing down the line.
11
+ # Specifically test case "update transfer state to COMMITTED by FULFIL request"
12
+ # "savePayeeTransferResponse::failure Cannot read properties of undefined (reading 'settlementWindowId')"
13
+ # TODO: More investigation
14
+ "knex"
9
15
  ]
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [16.4.0](https://github.com/mojaloop/central-ledger/compare/v16.3.3...v16.4.0) (2023-01-27)
6
+
7
+
8
+ ### Features
9
+
10
+ * **mojaloop/#3078:** get /trans callback is wrong for exp trans ([#938](https://github.com/mojaloop/central-ledger/issues/938)) ([70bdf18](https://github.com/mojaloop/central-ledger/commit/70bdf18c45fd7dd9fcc8a4e91a8b5a1e83f7c5d8)), closes [mojaloop/#3078](https://github.com/mojaloop/project/issues/3078)
11
+
5
12
  ### [16.3.3](https://github.com/mojaloop/central-ledger/compare/v16.3.2...v16.3.3) (2022-12-12)
6
13
 
7
14
 
package/README.md CHANGED
@@ -26,6 +26,8 @@ The following documentation represents the services, APIs and endpoints responsi
26
26
  - [Logging](#logging)
27
27
  - [Tests](#tests)
28
28
  - [Running Integration Tests interactively](#running-integration-tests-interactively)
29
+ - [Development environment](#development-environment)
30
+ - [Auditing Dependencies](#auditing-dependencies)
29
31
  - [Container Scans](#container-scans)
30
32
  - [Automated Releases](#automated-releases)
31
33
  - [Potential problems](#potential-problems)
@@ -45,7 +47,7 @@ The Central Ledger has many options that can be configured through environment v
45
47
  | CLEDG\_DATABASE_URI | The connection string for the database the central ledger will use. Postgres is currently the only supported database. | postgres://\<username>:\<password>@localhost:5432/central_ledger |
46
48
  | CLEDG\_PORT | The port the API server will run on. | 3000 |
47
49
  | CLEDG\_ADMIN_PORT | The port the Admin server will run on. | 3001 |
48
- | CLEDG\_HOSTNAME | The URI that will be used to create and validate links to resources on the central ledger. | http://central-ledger |
50
+ | CLEDG\_HOSTNAME | The URI that will be used to create and validate links to resources on the central ledger. | <http://central-ledger> |
49
51
  | CLEDG\_ENABLE\_BASIC_AUTH | Flag to enable basic auth protection on endpoints that require authorization. Username and password would be the account name and password. | false |
50
52
  | CLEDG\_ENABLE\_TOKEN_AUTH | Flag to enable token protection on endpoints that require authorization. To create a token, reference the [API documentation](API.md). | false |
51
53
  | CLEDG\_LEDGER\_ACCOUNT_NAME | Name of the account setup to receive fees owed to the central ledger. If the account doesn't exist, it will be created on start up. | LedgerName |
@@ -119,6 +121,61 @@ If you want to run integration tests in a repetitive manner, you can startup the
119
121
  npm run test:int
120
122
  ```
121
123
 
124
+ ### Running Functional Tests
125
+
126
+ If you want to run functional tests locally utilizing the [ml-core-test-harness](https://github.com/mojaloop/ml-core-test-harness), you can run the following commands:
127
+
128
+ ```bash
129
+ git clone --depth 1 --branch v0.0.2 https://github.com/mojaloop/ml-core-test-harness.git ./IGNORE/ml-core-test-harness
130
+ ```
131
+
132
+ ```bash
133
+ docker build -t mojaloop/central-ledger:local .
134
+ ```
135
+
136
+ ```bash
137
+ cd IGNORE/ml-core-test-harness
138
+ export CENTRAL_LEDGER_VERSION=local
139
+ docker-compose --project-name ttk-func --ansi never --profile all-services --profile ttk-provisioning --profile ttk-tests up -d
140
+ ```
141
+
142
+ Check test container logs for test results
143
+
144
+ Or access TTK UI using the following URI: <http://localhost:9660>
145
+
146
+ TTK Test files:
147
+ - Test Collection: ./IGNORE/ml-core-test-harness/docker/ml-testing-toolkit/test-cases/collections/tests/p2p.json
148
+ - Env Config: ./IGNORE/ml-core-test-harness/docker/ml-testing-toolkit/test-cases/environments/default-env.json
149
+
150
+ ## Development environment
151
+
152
+ Start Docker dependant Services
153
+
154
+ ```bash
155
+ docker compose -f ./docker-compose.yml -f docker-compose.dev.yml up -d
156
+ ```
157
+
158
+ Start local Central-Ledger Service
159
+
160
+ ```bash
161
+ npm start
162
+ ```
163
+
164
+ Populate Test Data
165
+
166
+ ```bash
167
+ sh ./test/util/scripts/populateTestData.sh
168
+ ```
169
+
170
+ View Logs for Mockserver (i.e. Payee Receiver) and ML-API-Adapter:
171
+
172
+ ```bash
173
+ docker logs -f mockserver
174
+ docker logs -f cl_ml-api-adapter
175
+ ```
176
+
177
+ Postman Test Collection: [./test/util/postman/CL-Local Docker Test.postman_collection.json](./test/util/postman/CL-Local%20Docker%20Test.postman_collection.json)
178
+
122
179
  ## Auditing Dependencies
123
180
 
124
181
  We use `npm-audit-resolver` along with `npm audit` to check dependencies for node vulnerabilities, and keep track of resolved dependencies with an `audit-resolve.json` file.
@@ -144,8 +201,8 @@ As part of our CI/CD process, we use anchore-cli to scan our built docker contai
144
201
  If you find your release builds are failing, refer to the [container scanning](https://github.com/mojaloop/ci-config#container-scanning) in our shared Mojaloop CI config repo. There is a good chance you simply need to update the `mojaloop-policy-generator.js` file and re-run the circleci workflow.
145
202
 
146
203
  For more information on anchore and anchore-cli, refer to:
147
- - [Anchore CLI](https://github.com/anchore/anchore-cli)
148
- - [Circle Orb Registry](https://circleci.com/orbs/registry/orb/anchore/anchore-engine)
204
+ - [Anchore CLI](https://github.com/anchore/anchore-cli)
205
+ - [Circle Orb Registry](https://circleci.com/orbs/registry/orb/anchore/anchore-engine)
149
206
 
150
207
  ## Automated Releases
151
208
 
package/audit-ci.jsonc CHANGED
@@ -19,6 +19,18 @@
19
19
  "GHSA-g64q-3vg8-8f93",
20
20
  "GHSA-5854-jvxx-2cg9",
21
21
  "GHSA-w5p7-h5w8-2hfq",
22
- "GHSA-p9pc-299p-vxgp"
22
+ "GHSA-p9pc-299p-vxgp",
23
+ // TODO: Investigate issue with json5 lib as this is due to an underlying dependant lib dependency.
24
+ "GHSA-9c47-m6qq-7p4h", // https://github.com/advisories/GHSA-9c47-m6qq-7p4h
25
+ // TODO: Upgrade jsonwebtoken in the central-services-shared lib --> https://github.com/mojaloop/project/issues/3097
26
+ "GHSA-qwph-4952-7xr6", // https://github.com/advisories/GHSA-qwph-4952-7xr6
27
+ "GHSA-27h2-hvpr-p74q", // https://github.com/advisories/GHSA-27h2-hvpr-p74q
28
+ // Unable to upgrade Knex due to the following issue:
29
+ // # There seems to be an issue with seeding or migration with integration tests
30
+ // # that lead to some tests failing down the line.
31
+ // # Specifically test case "update transfer state to COMMITTED by FULFIL request"
32
+ // # "savePayeeTransferResponse::failure Cannot read properties of undefined (reading 'settlementWindowId')"
33
+ // TODO: More investigation --> https://github.com/mojaloop/project/issues/3096
34
+ "GHSA-4jv9-3563-23j3" // https://github.com/advisories/GHSA-4jv9-3563-23j3
23
35
  ]
24
36
  }
@@ -0,0 +1,63 @@
1
+ version: "3.7"
2
+ services:
3
+ ## startup central-ledger to run any migrations. You will need to manually start central-ledger using `npm start`
4
+ central-ledger:
5
+ image: mojaloop/central-ledger:local
6
+ deploy:
7
+ replicas: 1
8
+ user: root
9
+ build:
10
+ context: .
11
+ cache_from:
12
+ - mojaloop/central-ledger
13
+ - central-ledger
14
+ container_name: cl_central-ledger
15
+ command:
16
+ - "sh"
17
+ - "-c"
18
+ - "sh /opt/wait-for/wait-for-central-ledger.sh && npm run migrate"
19
+ ports:
20
+ - "3001:3001"
21
+ volumes:
22
+ - ./docker/central-ledger/default.json:/opt/app/config/default.json
23
+ - ./docker/wait-for:/opt/wait-for
24
+ environment:
25
+ - LOG_LEVEL=info
26
+ - CSL_LOG_TRANSPORT=file
27
+ - CLEDG_MONGODB__DISABLED=false
28
+ networks:
29
+ - cl-mojaloop-net
30
+ depends_on:
31
+ - mysql
32
+ - kafka
33
+ - objstore
34
+ healthcheck:
35
+ test: ["CMD", "sh", "-c" ,"apk --no-cache add curl", "&&", "curl", "http://localhost:3001/health"]
36
+ timeout: 20s
37
+ retries: 10
38
+ interval: 30s
39
+
40
+ ## override ml-api-adapter to ignore health checks for central-ledger
41
+ ml-api-adapter:
42
+ image: mojaloop/ml-api-adapter:latest
43
+ container_name: cl_ml-api-adapter
44
+ deploy:
45
+ replicas: 1
46
+ user: root
47
+ command:
48
+ - "sh"
49
+ - "-c"
50
+ - "sh /opt/wait-for/wait-for-ml-api-adapter.sh && node src/api/index.js"
51
+ ports:
52
+ - "3000:3000"
53
+ volumes:
54
+ - ./docker/ml-api-adapter/default.json:/opt/app/config/default.json
55
+ - ./docker/wait-for:/opt/wait-for
56
+ environment:
57
+ - LOG_LEVEL=info
58
+ networks:
59
+ - cl-mojaloop-net
60
+ depends_on:
61
+ - kafka
62
+ ## We override the healthcheck here so we can start ml-api-adapter without the central-ledger running in docker, so we can start it locally
63
+ healthcheck: {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mojaloop/central-ledger",
3
- "version": "16.3.4-snapshot.0",
3
+ "version": "16.4.0",
4
4
  "description": "Central ledger hosted by a scheme to record and settle transfers",
5
5
  "license": "Apache-2.0",
6
6
  "author": "ModusBox",
@@ -77,7 +77,7 @@
77
77
  },
78
78
  "dependencies": {
79
79
  "@hapi/good": "9.0.1",
80
- "@hapi/hapi": "21.1.0",
80
+ "@hapi/hapi": "21.2.0",
81
81
  "@hapi/inert": "7.0.0",
82
82
  "@hapi/joi": "17.1.1",
83
83
  "@hapi/vision": "7.0.0",
@@ -86,24 +86,24 @@
86
86
  "@mojaloop/central-services-health": "14.0.1",
87
87
  "@mojaloop/central-services-logger": "11.2.0",
88
88
  "@mojaloop/central-services-metrics": "12.0.5",
89
- "@mojaloop/central-services-shared": "17.3.1",
89
+ "@mojaloop/central-services-shared": "17.5.0",
90
90
  "@mojaloop/central-services-stream": "11.0.0",
91
91
  "@mojaloop/event-sdk": "11.0.2",
92
92
  "@mojaloop/ml-number": "11.2.1",
93
93
  "@mojaloop/object-store-lib": "12.0.0",
94
94
  "@now-ims/hapi-now-auth": "2.1.0",
95
- "ajv": "8.11.2",
95
+ "ajv": "8.12.0",
96
96
  "ajv-keywords": "5.1.0",
97
97
  "base64url": "3.0.1",
98
98
  "blipp": "4.0.2",
99
99
  "catbox-memory": "4.0.1",
100
- "commander": "9.4.1",
101
- "cron": "2.1.0",
100
+ "commander": "10.0.0",
101
+ "cron": "2.2.0",
102
102
  "decimal.js": "10.4.3",
103
- "docdash": "2.0.0",
103
+ "docdash": "2.0.1",
104
104
  "event-stream": "4.0.1",
105
105
  "five-bells-condition": "5.0.1",
106
- "glob": "8.0.3",
106
+ "glob": "8.1.0",
107
107
  "hapi-auth-basic": "5.0.0",
108
108
  "hapi-auth-bearer-token": "8.0.0",
109
109
  "hapi-swagger": "15.0.0",
@@ -120,17 +120,17 @@
120
120
  },
121
121
  "devDependencies": {
122
122
  "async-retry": "1.3.3",
123
- "audit-ci": "^6.4.0",
123
+ "audit-ci": "^6.6.1",
124
124
  "get-port": "5.1.1",
125
125
  "jsdoc": "4.0.0",
126
126
  "jsonpath": "1.1.1",
127
127
  "nodemon": "2.0.20",
128
- "npm-check-updates": "16.5.6",
128
+ "npm-check-updates": "16.6.3",
129
129
  "nyc": "15.1.0",
130
130
  "pre-commit": "1.2.2",
131
131
  "proxyquire": "2.1.3",
132
132
  "replace": "^1.2.2",
133
- "sinon": "15.0.0",
133
+ "sinon": "15.0.1",
134
134
  "standard": "17.0.0",
135
135
  "standard-version": "^9.5.0",
136
136
  "tap-spec": "^5.0.0",
@@ -336,7 +336,13 @@ const registerBulkFulfilHandler = async () => {
336
336
  */
337
337
  const registerAllHandlers = async () => {
338
338
  try {
339
- await registerBulkFulfilHandler()
339
+ // Lets check if MongoDB is disabled, and print a warning that we are unable to register the handler.
340
+ // This can only happen if you are running all Central-Ledger's services as a single mono-app which is ok for development purposes.
341
+ if (Config.MONGODB_DISABLED) {
342
+ Logger.isWarnEnabled && Logger.warn('Skipping registration of BulkFulfilHandler as Mongo Database is disabled in configuration')
343
+ } else {
344
+ await registerBulkFulfilHandler()
345
+ }
340
346
  return true
341
347
  } catch (err) {
342
348
  Logger.isErrorEnabled && Logger.error(err)
@@ -189,7 +189,13 @@ const registerGetBulkTransferHandler = async () => {
189
189
  */
190
190
  const registerAllHandlers = async () => {
191
191
  try {
192
- await registerGetBulkTransferHandler()
192
+ // Lets check if MongoDB is disabled, and print a warning that we are unable to register the handler.
193
+ // This can only happen if you are running all Central-Ledger's services as a single mono-app which is ok for development purposes.
194
+ if (Config.MONGODB_DISABLED) {
195
+ Logger.isWarnEnabled && Logger.warn('Skipping registration of BulkGetHandler as Mongo Database is disabled in configuration')
196
+ } else {
197
+ await registerGetBulkTransferHandler()
198
+ }
193
199
  return true
194
200
  } catch (err) {
195
201
  Logger.isErrorEnabled && Logger.error(err)
@@ -316,7 +316,13 @@ const registerBulkPrepareHandler = async () => {
316
316
  */
317
317
  const registerAllHandlers = async () => {
318
318
  try {
319
- await registerBulkPrepareHandler()
319
+ // Lets check if MongoDB is disabled, and print a warning that we are unable to register the handler.
320
+ // This can only happen if you are running all Central-Ledger's services as a single mono-app which is ok for development purposes.
321
+ if (Config.MONGODB_DISABLED) {
322
+ Logger.isWarnEnabled && Logger.warn('Skipping registration of BulkPrepareHandler as Mongo Database is disabled in configuration')
323
+ } else {
324
+ await registerBulkPrepareHandler()
325
+ }
320
326
  return true
321
327
  } catch (err) {
322
328
  Logger.isErrorEnabled && Logger.error(err)
@@ -419,7 +419,13 @@ const registerBulkProcessingHandler = async () => {
419
419
  */
420
420
  const registerAllHandlers = async () => {
421
421
  try {
422
- await registerBulkProcessingHandler()
422
+ // Lets check if MongoDB is disabled, and print a warning that we are unable to register the handler.
423
+ // This can only happen if you are running all Central-Ledger's services as a single mono-app which is ok for development purposes.
424
+ if (Config.MONGODB_DISABLED) {
425
+ Logger.isWarnEnabled && Logger.warn('Skipping registration of BulkProcessingHandler as Mongo Database is disabled in configuration')
426
+ } else {
427
+ await registerBulkProcessingHandler()
428
+ }
423
429
  return true
424
430
  } catch (err) {
425
431
  Logger.isErrorEnabled && Logger.error(err)
@@ -771,12 +771,6 @@ const getTransfer = async (error, messages) => {
771
771
  await Kafka.proceed(Config.KAFKA_CONFIG, params, { consumerCommit, fspiopError: fspiopError.toApiErrorObject(Config.ERROR_HANDLING), eventDetail, fromSwitch })
772
772
  throw fspiopError
773
773
  }
774
- if (transfer.transferState === Enum.Transfers.TransferInternalState.EXPIRED_RESERVED) {
775
- Logger.isInfoEnabled && Logger.info(Util.breadcrumb(location, `callbackTransferExpired--${actionLetter}3`))
776
- const fspiopError = ErrorHandler.Factory.createFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.TRANSFER_EXPIRED)
777
- await Kafka.proceed(Config.KAFKA_CONFIG, params, { consumerCommit, fspiopError: fspiopError.toApiErrorObject(Config.ERROR_HANDLING), eventDetail, fromSwitch })
778
- throw fspiopError
779
- }
780
774
 
781
775
  // ============================================================================================
782
776
  Util.breadcrumb(location, { path: 'validationPassed' })