@mojaloop/central-services-shared 17.6.0 → 17.6.2

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.
@@ -7,22 +7,21 @@ version: 2.1
7
7
  # Orbs used in this pipeline
8
8
  ##
9
9
  orbs:
10
- slack: circleci/slack@4.9.3 # Ref: https://github.com/mojaloop/ci-config/tree/master/slack-templates
10
+ slack: circleci/slack@4.12.5 # Ref: https://github.com/mojaloop/ci-config/tree/master/slack-templates
11
11
  pr-tools: mojaloop/pr-tools@0.1.10 # Ref: https://github.com/mojaloop/ci-config/
12
- gh: circleci/github-cli@2.1.0
12
+ gh: circleci/github-cli@2.2.0
13
13
 
14
14
  ##
15
15
  # defaults
16
16
  #
17
17
  # YAML defaults templates, in alphabetical order
18
18
  ##
19
- defaults_Dependencies: &defaults_Dependencies |
19
+ defaults_docker_Dependencies: &defaults_docker_Dependencies |
20
20
  apk --no-cache add git
21
21
  apk --no-cache add ca-certificates
22
22
  apk --no-cache add curl
23
23
  apk --no-cache add openssh-client
24
- apk add --no-cache -t build-dependencies make gcc g++ python3 libtool autoconf automake jq
25
- npm config set unsafe-perm true
24
+ apk add --no-cache -t build-dependencies make gcc g++ python3 libtool autoconf automake jq bash
26
25
  npm install -g node-gyp
27
26
 
28
27
  defaults_awsCliDependencies: &defaults_awsCliDependencies |
@@ -59,6 +58,62 @@ defaults_configure_git: &defaults_configure_git
59
58
  git config user.email ${GIT_CI_EMAIL}
60
59
  git config user.name ${GIT_CI_USER}
61
60
 
61
+ defaults_configure_nvm: &defaults_configure_nvm
62
+ name: Configure NVM
63
+ command: |
64
+ cd $HOME
65
+
66
+ export ENV_DOT_PROFILE=$HOME/.profile
67
+ touch $ENV_DOT_PROFILE
68
+
69
+ echo "1. Export env variable"
70
+ export NVM_DIR="$HOME/.nvm"
71
+ if [ -z "$NVMRC_VERSION" ]; then
72
+ echo "==> Configuring NVMRC_VERSION!"
73
+ export NVMRC_VERSION=$(cat $CIRCLE_WORKING_DIRECTORY/.nvmrc)
74
+ echo "export NVMRC_VERSION=$NVMRC_VERSION" >> $ENV_DOT_PROFILE
75
+ fi
76
+
77
+ if [ -f "$NVM_DIR" ]; then
78
+ echo "==> $NVM_DIR exists. Skipping steps 2-4!"
79
+ else
80
+ echo "==> $NVM_DIR does not exists. Executing steps 2-4!"
81
+
82
+ echo "2. Installing NVM"
83
+ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
84
+
85
+ echo "3. Executing $NVM_DIR/nvm.sh"
86
+ [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
87
+
88
+ # echo "4. Update $ENV_DOT_PROFILE"
89
+ # echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $ENV_DOT_PROFILE
90
+ # echo "export NVM_DIR=$NVM_DIR" >> $ENV_DOT_PROFILE
91
+ fi
92
+
93
+ ## Ref: https://github.com/nvm-sh/nvm/issues/1102#issuecomment-550572252
94
+ if [ ! -z "$NVM_ARCH_UNOFFICIAL_OVERRIDE" ]; then
95
+ echo "==> Handle NVM_ARCH_UNOFFICIAL_OVERRIDE=$NVM_ARCH_UNOFFICIAL_OVERRIDE!"
96
+ echo "nvm_get_arch() { nvm_echo \"${NVM_ARCH_UNOFFICIAL_OVERRIDE}\"; }" >> $ENV_DOT_PROFILE
97
+ echo "export NVM_NODEJS_ORG_MIRROR=https://unofficial-builds.nodejs.org/download/release" >> $ENV_DOT_PROFILE
98
+ source $ENV_DOT_PROFILE
99
+ fi
100
+
101
+ echo "4. Installing Node version: $NVMRC_VERSION"
102
+ nvm install $NVMRC_VERSION
103
+ nvm alias default $NVMRC_VERSION
104
+ nvm use $NVMRC_VERSION
105
+
106
+ cd $CIRCLE_WORKING_DIRECTORY
107
+
108
+ defaults_display_versions: &defaults_display_versions
109
+ name: Display Versions
110
+ command: |
111
+ echo "What is the active version of Nodejs?"
112
+ echo "node: $(node --version)"
113
+ echo "yarn: $(yarn --version)"
114
+ echo "npm: $(npm --version)"
115
+ echo "nvm: $(nvm --version)"
116
+
62
117
  ##
63
118
  # Executors
64
119
  #
@@ -67,13 +122,18 @@ defaults_configure_git: &defaults_configure_git
67
122
  executors:
68
123
  default-docker:
69
124
  working_directory: &WORKING_DIR /home/circleci/project
125
+ shell: "/bin/sh -leo pipefail" ## Ref: https://circleci.com/docs/env-vars/#alpine-linux
126
+ environment:
127
+ BASH_ENV: /etc/profile ## Ref: https://circleci.com/docs/env-vars/#alpine-linux
128
+ NVM_ARCH_UNOFFICIAL_OVERRIDE: x64-musl ## Ref: https://github.com/nvm-sh/nvm/issues/1102#issuecomment-550572252
70
129
  docker:
71
- - image: node:16.15.0-alpine
130
+ - image: node:lts-alpine
72
131
 
73
132
  default-machine:
74
133
  working_directory: *WORKING_DIR
134
+ shell: "/bin/bash -leo pipefail"
75
135
  machine:
76
- image: ubuntu-2004:current
136
+ image: ubuntu-2204:2023.04.2 # Ref: https://circleci.com/developer/machine/image/ubuntu-2204
77
137
 
78
138
  jobs:
79
139
  setup:
@@ -81,10 +141,14 @@ jobs:
81
141
  steps:
82
142
  - run:
83
143
  name: Install general dependencies
84
- command: *defaults_Dependencies
144
+ command: *defaults_docker_Dependencies
85
145
  - checkout
86
146
  - run:
87
- name: Update NPM install
147
+ <<: *defaults_configure_nvm
148
+ - run:
149
+ <<: *defaults_display_versions
150
+ - run:
151
+ name: Install NPM dependencies
88
152
  command: npm ci
89
153
  - save_cache:
90
154
  key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
@@ -96,8 +160,12 @@ jobs:
96
160
  steps:
97
161
  - run:
98
162
  name: Install general dependencies
99
- command: *defaults_Dependencies
163
+ command: *defaults_docker_Dependencies
100
164
  - checkout
165
+ - run:
166
+ <<: *defaults_configure_nvm
167
+ - run:
168
+ <<: *defaults_display_versions
101
169
  - restore_cache:
102
170
  key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
103
171
  - run:
@@ -109,8 +177,12 @@ jobs:
109
177
  steps:
110
178
  - run:
111
179
  name: Install general dependencies
112
- command: *defaults_Dependencies
180
+ command: *defaults_docker_Dependencies
113
181
  - checkout
182
+ - run:
183
+ <<: *defaults_configure_nvm
184
+ - run:
185
+ <<: *defaults_display_versions
114
186
  - restore_cache:
115
187
  key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
116
188
  - run:
@@ -122,8 +194,12 @@ jobs:
122
194
  steps:
123
195
  - run:
124
196
  name: Install general dependencies
125
- command: *defaults_Dependencies
197
+ command: *defaults_docker_Dependencies
126
198
  - checkout
199
+ - run:
200
+ <<: *defaults_configure_nvm
201
+ - run:
202
+ <<: *defaults_display_versions
127
203
  - restore_cache:
128
204
  key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
129
205
  - run:
@@ -138,7 +214,7 @@ jobs:
138
214
  command: npm -s run test:xunit
139
215
  - store_artifacts:
140
216
  path: ./test/results
141
- prefix: test
217
+ destination: test
142
218
  - store_test_results:
143
219
  path: ./test/results
144
220
 
@@ -147,11 +223,15 @@ jobs:
147
223
  steps:
148
224
  - run:
149
225
  name: Install general dependencies
150
- command: *defaults_Dependencies
226
+ command: *defaults_docker_Dependencies
151
227
  - run:
152
228
  name: Install AWS CLI dependencies
153
229
  command: *defaults_awsCliDependencies
154
230
  - checkout
231
+ - run:
232
+ <<: *defaults_configure_nvm
233
+ - run:
234
+ <<: *defaults_display_versions
155
235
  - restore_cache:
156
236
  key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
157
237
  - run:
@@ -159,27 +239,21 @@ jobs:
159
239
  command: npm -s run test:coverage-check
160
240
  - store_artifacts:
161
241
  path: coverage
162
- prefix: test
242
+ destination: test
163
243
  - store_test_results:
164
244
  path: coverage
165
- - run:
166
- name: Copy code coverage to SonarQube
167
- command: |
168
- if [ "${CIRCLE_BRANCH}" == "master" ];
169
- then
170
- echo "Sending lcov.info to SonarQube..."
171
- aws s3 cp coverage/lcov.info $AWS_S3_DIR_SONARQUBE/${CIRCLE_PROJECT_REPONAME}/lcov.info
172
- else
173
- echo "Not a release (env CIRCLE_BRANCH != 'master'), skipping sending lcov.info to SonarQube."
174
- fi
175
245
 
176
246
  vulnerability-check:
177
247
  executor: default-docker
178
248
  steps:
179
249
  - run:
180
250
  name: Install general dependencies
181
- command: *defaults_Dependencies
251
+ command: *defaults_docker_Dependencies
182
252
  - checkout
253
+ - run:
254
+ <<: *defaults_configure_nvm
255
+ - run:
256
+ <<: *defaults_display_versions
183
257
  - restore_cache:
184
258
  key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
185
259
  - run:
@@ -190,14 +264,14 @@ jobs:
190
264
  command: npm run audit:check -- -o json > ./audit/results/auditResults.json
191
265
  - store_artifacts:
192
266
  path: ./audit/results
193
- prefix: audit
267
+ destination: audit
194
268
 
195
269
  audit-licenses:
196
270
  executor: default-docker
197
271
  steps:
198
272
  - run:
199
273
  name: Install general dependencies
200
- command: *defaults_Dependencies
274
+ command: *defaults_docker_Dependencies
201
275
  - run:
202
276
  <<: *defaults_license_scanner
203
277
  - checkout
@@ -208,14 +282,14 @@ jobs:
208
282
  command: cd /tmp/license-scanner && pathToRepo=$CIRCLE_WORKING_DIRECTORY make run
209
283
  - store_artifacts:
210
284
  path: /tmp/license-scanner/results
211
- prefix: licenses
285
+ destination: licenses
212
286
 
213
287
  release:
214
288
  executor: default-docker
215
289
  steps:
216
290
  - run:
217
291
  name: Install general dependencies
218
- command: *defaults_Dependencies
292
+ command: *defaults_docker_Dependencies
219
293
  - checkout
220
294
  - restore_cache:
221
295
  keys:
@@ -242,6 +316,7 @@ jobs:
242
316
 
243
317
  github-release:
244
318
  executor: default-machine
319
+ shell: "/bin/bash -eo pipefail"
245
320
  steps:
246
321
  - run:
247
322
  name: Install git
@@ -287,7 +362,7 @@ jobs:
287
362
  steps:
288
363
  - run:
289
364
  name: Install general dependencies
290
- command: *defaults_Dependencies
365
+ command: *defaults_docker_Dependencies
291
366
  - checkout
292
367
  - restore_cache:
293
368
  key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
@@ -325,7 +400,7 @@ jobs:
325
400
  steps:
326
401
  - run:
327
402
  name: Install general dependencies
328
- command: *defaults_Dependencies
403
+ command: *defaults_docker_Dependencies
329
404
  - checkout
330
405
  - restore_cache:
331
406
  key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
@@ -362,7 +437,6 @@ jobs:
362
437
  template: SLACK_TEMP_RELEASE_FAILURE
363
438
 
364
439
  workflows:
365
- version: 2
366
440
  build_and_test:
367
441
  jobs:
368
442
  - pr-tools/pr-title-check:
package/.nvmrc CHANGED
@@ -1 +1 @@
1
- 16.15.0
1
+ 18.17.1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
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
+ ### [17.6.2](https://github.com/mojaloop/central-services-shared/compare/v17.6.1...v17.6.2) (2023-08-24)
6
+
7
+ ### [17.6.1](https://github.com/mojaloop/central-services-shared/compare/v17.6.0...v17.6.1) (2023-08-17)
8
+
5
9
  ## [17.6.0](https://github.com/mojaloop/central-services-shared/compare/v17.5.3...v17.6.0) (2023-08-17)
6
10
 
7
11
 
package/audit-ci.jsonc CHANGED
@@ -9,20 +9,9 @@
9
9
  "GHSA-phwq-j96m-2c2q",
10
10
  "GHSA-282f-qqgm-c34q",
11
11
  "GHSA-6vfc-qv3f-vr6c",
12
- "GHSA-6vfc-qv3f-vr6c",
13
- "GHSA-wc69-rhjr-hc9g",
14
- "GHSA-g954-5hwp-pp24",
15
- "GHSA-g954-5hwp-pp24",
16
12
  "GHSA-mjxr-4v3x-q3m4",
17
13
  "GHSA-rjqq-98f6-6j3r",
18
14
  "GHSA-w5p7-h5w8-2hfq",
19
- "GHSA-p9pc-299p-vxgp",
20
- // TODO: There is a conflict with the sub-dependency jsonwebtoken. Not able to fix with 'npm audit fix'. Need too investigate the root cause.
21
- "GHSA-hjrf-2m68-5959",
22
- "GHSA-8cf7-32gw-wr33",
23
- "GHSA-qwph-4952-7xr6",
24
- "GHSA-27h2-hvpr-p74q",
25
- "GHSA-h755-8qp9-cq85", // https://github.com/advisories/GHSA-h755-8qp9-cq85
26
- "GHSA-c2qf-rxjj-qqgw" // https://github.com/advisories/GHSA-c2qf-rxjj-qqgw
15
+ "GHSA-p9pc-299p-vxgp"
27
16
  ]
28
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mojaloop/central-services-shared",
3
- "version": "17.6.0",
3
+ "version": "17.6.2",
4
4
  "description": "Shared code for mojaloop central services",
5
5
  "license": "Apache-2.0",
6
6
  "author": "ModusBox",
@@ -24,9 +24,6 @@
24
24
  ],
25
25
  "main": "src/index.js",
26
26
  "types": "src/index.d.ts",
27
- "engines": {
28
- "node": "=16.x"
29
- },
30
27
  "imports": {
31
28
  "#src/*": "./src/*.js",
32
29
  "#test/*": "./test/*.js"
@@ -60,9 +57,9 @@
60
57
  "axios": "1.4.0",
61
58
  "clone": "2.1.2",
62
59
  "dotenv": "16.3.1",
63
- "env-var": "7.3.1",
60
+ "env-var": "7.4.0",
64
61
  "event-stream": "4.0.1",
65
- "immutable": "4.3.2",
62
+ "immutable": "4.3.3",
66
63
  "lodash": "4.17.21",
67
64
  "mustache": "4.2.0",
68
65
  "openapi-backend": "5.9.2",
@@ -79,7 +76,7 @@
79
76
  "audit-ci": "^6.6.1",
80
77
  "base64url": "3.0.1",
81
78
  "chance": "1.1.11",
82
- "npm-check-updates": "16.12.1",
79
+ "npm-check-updates": "16.13.1",
83
80
  "nyc": "15.1.0",
84
81
  "pre-commit": "1.2.2",
85
82
  "proxyquire": "2.1.3",
@@ -94,10 +91,10 @@
94
91
  "tapes": "4.1.0"
95
92
  },
96
93
  "peerDependencies": {
97
- "@mojaloop/central-services-error-handling": "12.x.x",
98
- "@mojaloop/central-services-logger": "11.x.x",
99
- "@mojaloop/central-services-metrics": "12.x.x",
100
- "@mojaloop/event-sdk": "11.x.x",
94
+ "@mojaloop/central-services-error-handling": ">=12.x.x",
95
+ "@mojaloop/central-services-logger": ">=11.x.x",
96
+ "@mojaloop/central-services-metrics": ">=12.x.x",
97
+ "@mojaloop/event-sdk": ">=12.x.x",
101
98
  "ajv": "8.x.x",
102
99
  "ajv-keywords": "5.x.x"
103
100
  },
@@ -51,7 +51,7 @@ let switchEndpoint
51
51
  */
52
52
  const fetchEndpoints = async (fsp) => {
53
53
  try {
54
- Logger.isInfoEnabled && Logger.info(`[fsp=${fsp}] ~ participantEndpointCache::fetchEndpoints := Refreshing the cache for FSP: ${fsp}`)
54
+ Logger.isDebugEnabled && Logger.debug(`[fsp=${fsp}] ~ participantEndpointCache::fetchEndpoints := Refreshing the cache for FSP: ${fsp}`)
55
55
  const defaultHeaders = Http.SwitchDefaultHeaders(Enum.Http.HeaderResources.SWITCH, Enum.Http.HeaderResources.PARTICIPANTS, Enum.Http.HeaderResources.SWITCH)
56
56
  const url = Mustache.render(switchEndpoint + Enum.EndPoints.FspEndpointTemplates.PARTICIPANT_ENDPOINTS_GET, { fsp })
57
57
  Logger.isDebugEnabled && Logger.debug(`[fsp=${fsp}] ~ participantEndpointCache::fetchEndpoints := URL for FSP: ${url}`)
@@ -86,13 +86,13 @@ const fetchEndpoints = async (fsp) => {
86
86
  */
87
87
  exports.initializeCache = async (policyOptions) => {
88
88
  try {
89
- Logger.isInfoEnabled && Logger.info(`participantEndpointCache::initializeCache::start::clientOptions - ${JSON.stringify(clientOptions)}`)
89
+ Logger.isDebugEnabled && Logger.debug(`participantEndpointCache::initializeCache::start::clientOptions - ${JSON.stringify(clientOptions)}`)
90
90
  client = new Catbox.Client(CatboxMemory, clientOptions)
91
91
  await client.start()
92
92
  policyOptions.generateFunc = fetchEndpoints
93
- Logger.isInfoEnabled && Logger.info(`participantEndpointCache::initializeCache::start::policyOptions - ${JSON.stringify(policyOptions)}`)
93
+ Logger.isDebugEnabled && Logger.debug(`participantEndpointCache::initializeCache::start::policyOptions - ${JSON.stringify(policyOptions)}`)
94
94
  policy = new Catbox.Policy(policyOptions, client, partition)
95
- Logger.isInfoEnabled && Logger.info('participantEndpointCache::initializeCache::Cache initialized successfully')
95
+ Logger.isDebugEnabled && Logger.debug('participantEndpointCache::initializeCache::Cache initialized successfully')
96
96
  return true
97
97
  } catch (err) {
98
98
  Logger.isErrorEnabled && Logger.error(`participantEndpointCache::Cache error:: ERROR:'${err}'`)
@@ -114,7 +114,7 @@ exports.initializeCache = async (policyOptions) => {
114
114
  */
115
115
  exports.getEndpoint = async (switchUrl, fsp, endpointType, options = {}) => {
116
116
  switchEndpoint = switchUrl
117
- Logger.isInfoEnabled && Logger.info(`participantEndpointCache::getEndpoint::endpointType - ${endpointType}`)
117
+ Logger.isDebugEnabled && Logger.debug(`participantEndpointCache::getEndpoint::endpointType - ${endpointType}`)
118
118
  try {
119
119
  const endpoints = await policy.get(fsp)
120
120
  return Mustache.render(new Map(endpoints).get(endpointType), options)
@@ -139,7 +139,7 @@ exports.getEndpoint = async (switchUrl, fsp, endpointType, options = {}) => {
139
139
  */
140
140
  exports.getEndpointAndRender = async (switchUrl, fsp, endpointType, path = '', options) => {
141
141
  switchEndpoint = switchUrl
142
- Logger.isInfoEnabled && Logger.info(`participantEndpointCache::getEndpointAndRender::endpointType - ${endpointType}`)
142
+ Logger.isDebugEnabled && Logger.debug(`participantEndpointCache::getEndpointAndRender::endpointType - ${endpointType}`)
143
143
  try {
144
144
  const endpoints = await policy.get(fsp)
145
145
  const endpoint = new Map(endpoints).get(endpointType)
@@ -159,6 +159,6 @@ exports.getEndpointAndRender = async (switchUrl, fsp, endpointType, path = '', o
159
159
  * @returns {boolean} - Returns the status
160
160
  */
161
161
  exports.stopCache = async () => {
162
- Logger.isInfoEnabled && Logger.info('participantEndpointCache::stopCache::Stopping the cache')
162
+ Logger.isDebugEnabled && Logger.debug('participantEndpointCache::stopCache::Stopping the cache')
163
163
  return client.stop()
164
164
  }
@@ -276,7 +276,7 @@ const commitMessageSync = async (kafkaConsumer, kafkaTopic, message) => {
276
276
  const consumer = kafkaConsumer.getConsumer(kafkaTopic)
277
277
  await consumer.commitMessageSync(message)
278
278
  } catch (err) {
279
- Logger.isInfoEnabled && Logger.info(`No consumer found for topic ${kafkaTopic}`)
279
+ Logger.isDebugEnabled && Logger.debug(`No consumer found for topic ${kafkaTopic}`)
280
280
  Logger.isErrorEnabled && Logger.error(err)
281
281
  throw err
282
282
  }