@mojaloop/sdk-scheme-adapter 15.0.1 → 17.0.1
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/.circleci/config.yml +9 -9
- package/CHANGELOG.md +35 -0
- package/package.json +9 -8
- package/src/InboundServer/index.js +4 -2
- package/src/InboundServer/middlewares.js +12 -4
- package/src/OutboundServer/index.js +3 -2
- package/src/OutboundServer/middlewares.js +6 -2
- package/src/TestServer/index.js +4 -2
- package/src/index.js +0 -2
- package/src/lib/metrics.js +0 -2
- package/src/lib/router.js +3 -1
- package/src/lib/validate.js +10 -1
package/.circleci/config.yml
CHANGED
|
@@ -93,7 +93,7 @@ jobs:
|
|
|
93
93
|
name: Delete build dependencies
|
|
94
94
|
command: apk del build-dependencies
|
|
95
95
|
- save_cache:
|
|
96
|
-
key: dependency-cache-
|
|
96
|
+
key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
|
|
97
97
|
paths:
|
|
98
98
|
- node_modules
|
|
99
99
|
|
|
@@ -105,7 +105,7 @@ jobs:
|
|
|
105
105
|
command: *defaults_Dependencies
|
|
106
106
|
- checkout
|
|
107
107
|
- restore_cache:
|
|
108
|
-
key: dependency-cache-
|
|
108
|
+
key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
|
|
109
109
|
- run:
|
|
110
110
|
name: Execute unit tests
|
|
111
111
|
command: npm run test
|
|
@@ -125,7 +125,7 @@ jobs:
|
|
|
125
125
|
chmod +x ~/docker-compose
|
|
126
126
|
sudo mv ~/docker-compose /usr/local/bin/docker-compose
|
|
127
127
|
- restore_cache:
|
|
128
|
-
key: dependency-cache-
|
|
128
|
+
key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
|
|
129
129
|
- run:
|
|
130
130
|
name: Set up NVM
|
|
131
131
|
command: |
|
|
@@ -171,7 +171,7 @@ jobs:
|
|
|
171
171
|
command: *defaults_Dependencies
|
|
172
172
|
- checkout
|
|
173
173
|
- restore_cache:
|
|
174
|
-
key: dependency-cache-
|
|
174
|
+
key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
|
|
175
175
|
- run:
|
|
176
176
|
name: Execute unit tests
|
|
177
177
|
command: npm run build:openapi && npm run validate:api
|
|
@@ -184,7 +184,7 @@ jobs:
|
|
|
184
184
|
command: *defaults_Dependencies
|
|
185
185
|
- checkout
|
|
186
186
|
- restore_cache:
|
|
187
|
-
key: dependency-cache-
|
|
187
|
+
key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
|
|
188
188
|
- run:
|
|
189
189
|
name: Create dir for lint results
|
|
190
190
|
command: mkdir -p /lintresults
|
|
@@ -202,7 +202,7 @@ jobs:
|
|
|
202
202
|
command: *defaults_Dependencies
|
|
203
203
|
- checkout
|
|
204
204
|
- restore_cache:
|
|
205
|
-
key: dependency-cache-
|
|
205
|
+
key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
|
|
206
206
|
- run:
|
|
207
207
|
name: Create dir for test results
|
|
208
208
|
command: mkdir -p ./audit/results
|
|
@@ -222,7 +222,7 @@ jobs:
|
|
|
222
222
|
- run:
|
|
223
223
|
<<: *defaults_license_scanner
|
|
224
224
|
- restore_cache:
|
|
225
|
-
key: dependency-cache-
|
|
225
|
+
key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
|
|
226
226
|
- run:
|
|
227
227
|
name: Prune non-production packages before running license-scanner
|
|
228
228
|
command: npm prune --production
|
|
@@ -324,7 +324,7 @@ jobs:
|
|
|
324
324
|
command: *defaults_Dependencies
|
|
325
325
|
- checkout
|
|
326
326
|
- restore_cache:
|
|
327
|
-
key: dependency-cache-
|
|
327
|
+
key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
|
|
328
328
|
- run:
|
|
329
329
|
name: Configure git
|
|
330
330
|
command: |
|
|
@@ -413,7 +413,7 @@ jobs:
|
|
|
413
413
|
name: Install general dependencies
|
|
414
414
|
command: *defaults_Dependencies
|
|
415
415
|
- restore_cache:
|
|
416
|
-
key: dependency-cache-
|
|
416
|
+
key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
|
|
417
417
|
- run:
|
|
418
418
|
name: setup environment vars for LATEST release
|
|
419
419
|
command: |
|
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,39 @@
|
|
|
1
1
|
# Changelog: [mojaloop/thirdparty-api-svc](https://github.com/mojaloop/thirdparty-api-svc)
|
|
2
|
+
### [17.0.1](https://github.com/mojaloop/sdk-scheme-adapter/compare/v17.0.0...v17.0.1) (2022-07-04)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* creating inbound server ([#329](https://github.com/mojaloop/sdk-scheme-adapter/issues/329)) ([962420f](https://github.com/mojaloop/sdk-scheme-adapter/commit/962420f6fed02722c5a9aeee6c108b6fbc9f021d))
|
|
8
|
+
|
|
9
|
+
## [17.0.0](https://github.com/mojaloop/sdk-scheme-adapter/compare/v15.0.1...v17.0.0) (2022-07-04)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### ⚠ BREAKING CHANGES
|
|
13
|
+
|
|
14
|
+
* add dummy pr to major version bump due to unsquashed title (#327)
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* suppress health check logs ([#328](https://github.com/mojaloop/sdk-scheme-adapter/issues/328)) ([64fadde](https://github.com/mojaloop/sdk-scheme-adapter/commit/64faddea8307aa0c19d56466d0afe8f8208c4d66))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Chore
|
|
22
|
+
|
|
23
|
+
* add dummy pr to major version bump due to unsquashed title ([#327](https://github.com/mojaloop/sdk-scheme-adapter/issues/327)) ([ff0f29b](https://github.com/mojaloop/sdk-scheme-adapter/commit/ff0f29b7ce560565ee21cf6ae84118e1b391b5b5))
|
|
24
|
+
* **release:** 16.0.0 [skip ci] ([0071c65](https://github.com/mojaloop/sdk-scheme-adapter/commit/0071c65c3665239d0a482e76498f9eec5c288043))
|
|
25
|
+
|
|
26
|
+
## [16.0.0](https://github.com/mojaloop/sdk-scheme-adapter/compare/v15.0.1...v16.0.0) (2022-07-01)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### ⚠ BREAKING CHANGES
|
|
30
|
+
|
|
31
|
+
* add dummy pr to major version bump due to unsquashed title (#327)
|
|
32
|
+
|
|
33
|
+
### Chore
|
|
34
|
+
|
|
35
|
+
* add dummy pr to major version bump due to unsquashed title ([#327](https://github.com/mojaloop/sdk-scheme-adapter/issues/327)) ([ff0f29b](https://github.com/mojaloop/sdk-scheme-adapter/commit/ff0f29b7ce560565ee21cf6ae84118e1b391b5b5))
|
|
36
|
+
|
|
2
37
|
### [15.0.1](https://github.com/mojaloop/sdk-scheme-adapter/compare/v15.0.0...v15.0.1) (2022-07-01)
|
|
3
38
|
|
|
4
39
|
## [15.0.0](https://github.com/mojaloop/sdk-scheme-adapter/compare/v14.0.0...v15.0.0) (2022-06-17)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mojaloop/sdk-scheme-adapter",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "17.0.1",
|
|
4
4
|
"description": "An adapter for connecting to Mojaloop API enabled switches.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"~": "src"
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
|
-
"audit:resolve": "
|
|
15
|
-
"audit:check": "
|
|
14
|
+
"audit:resolve": "resolve-audit --production",
|
|
15
|
+
"audit:check": "check-audit --production",
|
|
16
16
|
"build": "npm run build:openapi; npm run build:dto:outbound",
|
|
17
17
|
"build:openapi": "npm run build:openapi:inbound && npm run build:openapi:outbound",
|
|
18
18
|
"build:openapi:inbound": "openapi bundle --output ./src/InboundServer/api.yaml --ext yaml ./src/InboundServer/api_template.yaml",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"updates:update": "npm run dep:update && npm install",
|
|
30
30
|
"dep:check": "npx ncu -e 2",
|
|
31
31
|
"dep:update": "npx ncu -u",
|
|
32
|
-
"release": "standard-version --releaseCommitMessageFormat 'chore(release): {{currentTag}} [skip ci]'"
|
|
32
|
+
"release": "standard-version --releaseCommitMessageFormat 'chore(release): {{currentTag}} [skip ci]'",
|
|
33
|
+
"snapshot": "standard-version --no-verify --skip.changelog --prerelease snapshot --releaseCommitMessageFormat 'chore(snapshot): {{currentTag}}'"
|
|
33
34
|
},
|
|
34
35
|
"author": "Matt Kingston, James Bush, ModusBox Inc.",
|
|
35
36
|
"contributors": [
|
|
@@ -56,7 +57,7 @@
|
|
|
56
57
|
"dependencies": {
|
|
57
58
|
"@koa/cors": "^3.1.0",
|
|
58
59
|
"@mojaloop/central-services-shared": "17.0.2",
|
|
59
|
-
"@mojaloop/sdk-standard-components": "^17.0
|
|
60
|
+
"@mojaloop/sdk-standard-components": "^17.1.0",
|
|
60
61
|
"ajv": "8.11.0",
|
|
61
62
|
"axios": "^0.27.2",
|
|
62
63
|
"co-body": "^6.1.0",
|
|
@@ -87,7 +88,7 @@
|
|
|
87
88
|
"@redocly/openapi-cli": "^1.0.0-beta.59",
|
|
88
89
|
"@types/jest": "^28.1.4",
|
|
89
90
|
"babel-jest": "^28.1.2",
|
|
90
|
-
"eslint": "^8.
|
|
91
|
+
"eslint": "^8.19.0",
|
|
91
92
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
92
93
|
"eslint-plugin-import": "^2.24.2",
|
|
93
94
|
"eslint-plugin-jest": "^26.5.3",
|
|
@@ -95,12 +96,12 @@
|
|
|
95
96
|
"jest-junit": "^14.0.0",
|
|
96
97
|
"nock": "^13.2.8",
|
|
97
98
|
"npm-audit-resolver": "^3.0.0-0",
|
|
98
|
-
"npm-check-updates": "^15.0.
|
|
99
|
+
"npm-check-updates": "^15.0.2",
|
|
99
100
|
"openapi-response-validator": "^12.0.0",
|
|
100
101
|
"openapi-typescript": "^5.4.0",
|
|
101
102
|
"redis-mock": "^0.56.3",
|
|
102
103
|
"standard-version": "^9.3.1",
|
|
103
|
-
"supertest": "^6.
|
|
104
|
+
"supertest": "^6.2.4",
|
|
104
105
|
"swagger-cli": "^4.0.4"
|
|
105
106
|
}
|
|
106
107
|
}
|
|
@@ -23,6 +23,8 @@ const router = require('../lib/router');
|
|
|
23
23
|
const handlers = require('./handlers');
|
|
24
24
|
const middlewares = require('./middlewares');
|
|
25
25
|
|
|
26
|
+
const logExcludePaths = ['/'];
|
|
27
|
+
|
|
26
28
|
class InboundApi extends EventEmitter {
|
|
27
29
|
constructor(conf, logger, cache, validator, wso2) {
|
|
28
30
|
super({ captureExceptions: true });
|
|
@@ -99,7 +101,7 @@ class InboundApi extends EventEmitter {
|
|
|
99
101
|
api.use(middlewares.createJwsValidator(logger, jwsVerificationKeys, jwsExclusions));
|
|
100
102
|
}
|
|
101
103
|
|
|
102
|
-
api.use(middlewares.applyState({ cache, wso2, conf }));
|
|
104
|
+
api.use(middlewares.applyState({ cache, wso2, conf, logExcludePaths }));
|
|
103
105
|
api.use(middlewares.createLogger(logger));
|
|
104
106
|
api.use(middlewares.createRequestValidator(validator));
|
|
105
107
|
api.use(middlewares.assignFspiopIdentifier());
|
|
@@ -133,7 +135,7 @@ class InboundServer extends EventEmitter {
|
|
|
133
135
|
constructor(conf, logger, cache, wso2) {
|
|
134
136
|
super({ captureExceptions: true });
|
|
135
137
|
this._conf = conf;
|
|
136
|
-
this._validator = new Validate();
|
|
138
|
+
this._validator = new Validate({ logExcludePaths });
|
|
137
139
|
this._logger = logger;
|
|
138
140
|
this._api = new InboundApi(
|
|
139
141
|
conf,
|
|
@@ -353,13 +353,17 @@ const createLogger = (logger) => async (ctx, next) => {
|
|
|
353
353
|
path: ctx.path,
|
|
354
354
|
method: ctx.method
|
|
355
355
|
}});
|
|
356
|
-
ctx.state.
|
|
356
|
+
if (!ctx.state.logExcludePaths.includes(ctx.path)) {
|
|
357
|
+
ctx.state.logger.push({body: ctx.request.body}).log('Request received');
|
|
358
|
+
}
|
|
357
359
|
try {
|
|
358
360
|
await next();
|
|
359
361
|
} catch (err) {
|
|
360
362
|
ctx.state.logger.push(err).log('Error');
|
|
361
363
|
}
|
|
362
|
-
|
|
364
|
+
if (!ctx.state.logExcludePaths.includes(ctx.path)) {
|
|
365
|
+
await ctx.state.logger.log('Request processed');
|
|
366
|
+
}
|
|
363
367
|
};
|
|
364
368
|
|
|
365
369
|
|
|
@@ -369,10 +373,14 @@ const createLogger = (logger) => async (ctx, next) => {
|
|
|
369
373
|
* @return {Function}
|
|
370
374
|
*/
|
|
371
375
|
const createRequestValidator = (validator) => async (ctx, next) => {
|
|
372
|
-
ctx.state.
|
|
376
|
+
if (!ctx.state.logExcludePaths.includes(ctx.path)) {
|
|
377
|
+
ctx.state.logger.log('Validating request');
|
|
378
|
+
}
|
|
373
379
|
try {
|
|
374
380
|
ctx.state.path = validator.validateRequest(ctx, ctx.state.logger);
|
|
375
|
-
ctx.state.
|
|
381
|
+
if (!ctx.state.logExcludePaths.includes(ctx.path)) {
|
|
382
|
+
ctx.state.logger.log('Request passed validation');
|
|
383
|
+
}
|
|
376
384
|
await next();
|
|
377
385
|
} catch (err) {
|
|
378
386
|
ctx.state.logger.push({ err }).log('Request failed validation.');
|
|
@@ -23,6 +23,7 @@ const handlers = require('./handlers');
|
|
|
23
23
|
const middlewares = require('./middlewares');
|
|
24
24
|
|
|
25
25
|
const endpointRegex = /\/.*/g;
|
|
26
|
+
const logExcludePaths = ['/'];
|
|
26
27
|
|
|
27
28
|
class OutboundApi extends EventEmitter {
|
|
28
29
|
constructor(conf, logger, cache, validator, metricsClient, wso2) {
|
|
@@ -36,7 +37,7 @@ class OutboundApi extends EventEmitter {
|
|
|
36
37
|
this._api.use(middlewares.createErrorHandler(this._logger));
|
|
37
38
|
this._api.use(middlewares.createRequestIdGenerator());
|
|
38
39
|
this._api.use(koaBody()); // outbound always expects application/json
|
|
39
|
-
this._api.use(middlewares.applyState({ cache, wso2, conf, metricsClient }));
|
|
40
|
+
this._api.use(middlewares.applyState({ cache, wso2, conf, metricsClient, logExcludePaths }));
|
|
40
41
|
this._api.use(middlewares.createLogger(this._logger));
|
|
41
42
|
|
|
42
43
|
//Note that we strip off any path on peerEndpoint config after the origin.
|
|
@@ -69,7 +70,7 @@ class OutboundApi extends EventEmitter {
|
|
|
69
70
|
class OutboundServer extends EventEmitter {
|
|
70
71
|
constructor(conf, logger, cache, metricsClient, wso2) {
|
|
71
72
|
super({ captureExceptions: true });
|
|
72
|
-
this._validator = new Validate();
|
|
73
|
+
this._validator = new Validate({ logExcludePaths });
|
|
73
74
|
this._conf = conf;
|
|
74
75
|
this._logger = logger;
|
|
75
76
|
this._server = null;
|
|
@@ -20,10 +20,14 @@ const { applyState, createErrorHandler, createLogger, createRequestIdGenerator }
|
|
|
20
20
|
* @return {Function}
|
|
21
21
|
*/
|
|
22
22
|
const createRequestValidator = (validator) => async (ctx, next) => {
|
|
23
|
-
ctx.state.
|
|
23
|
+
if (!ctx.state.logExcludePaths.includes(ctx.path)) {
|
|
24
|
+
ctx.state.logger.log('Validating request');
|
|
25
|
+
}
|
|
24
26
|
try {
|
|
25
27
|
ctx.state.path = validator.validateRequest(ctx, ctx.state.logger);
|
|
26
|
-
ctx.state.
|
|
28
|
+
if (!ctx.state.logExcludePaths.includes(ctx.path)) {
|
|
29
|
+
ctx.state.logger.log('Request passed validation');
|
|
30
|
+
}
|
|
27
31
|
await next();
|
|
28
32
|
} catch (err) {
|
|
29
33
|
ctx.state.logger.push({ err }).log('Request failed validation.');
|
package/src/TestServer/index.js
CHANGED
|
@@ -21,6 +21,8 @@ const router = require('../lib/router');
|
|
|
21
21
|
const handlers = require('./handlers');
|
|
22
22
|
const middlewares = require('../InboundServer/middlewares');
|
|
23
23
|
|
|
24
|
+
const logExcludePaths = ['/'];
|
|
25
|
+
|
|
24
26
|
const getWsIp = (req) => [
|
|
25
27
|
req.socket.remoteAddress,
|
|
26
28
|
...(
|
|
@@ -36,7 +38,7 @@ class TestApi {
|
|
|
36
38
|
|
|
37
39
|
this._api.use(middlewares.createErrorHandler(logger));
|
|
38
40
|
this._api.use(middlewares.createRequestIdGenerator());
|
|
39
|
-
this._api.use(middlewares.applyState({ cache }));
|
|
41
|
+
this._api.use(middlewares.applyState({ cache, logExcludePaths }));
|
|
40
42
|
this._api.use(middlewares.createLogger(logger));
|
|
41
43
|
|
|
42
44
|
this._api.use(middlewares.createRequestValidator(validator));
|
|
@@ -174,7 +176,7 @@ class TestServer {
|
|
|
174
176
|
constructor({ port, logger, cache }) {
|
|
175
177
|
this._port = port;
|
|
176
178
|
this._logger = logger;
|
|
177
|
-
this._validator = new Validate();
|
|
179
|
+
this._validator = new Validate({ logExcludePaths });
|
|
178
180
|
this._api = new TestApi(this._logger.push({ component: 'api' }), this._validator, cache);
|
|
179
181
|
this._server = http.createServer(this._api.callback());
|
|
180
182
|
// TODO: why does this appear to need to be called after creating this._server (try reorder
|
package/src/index.js
CHANGED
|
@@ -78,7 +78,6 @@ class Server extends EventEmitter {
|
|
|
78
78
|
this.conf,
|
|
79
79
|
this.logger.push(LOG_ID.INBOUND),
|
|
80
80
|
this.cache,
|
|
81
|
-
this.metricsClient,
|
|
82
81
|
this.wso2,
|
|
83
82
|
);
|
|
84
83
|
this.inboundServer.on('error', (...args) => {
|
|
@@ -195,7 +194,6 @@ class Server extends EventEmitter {
|
|
|
195
194
|
newConf,
|
|
196
195
|
this.logger.push(LOG_ID.INBOUND),
|
|
197
196
|
this.cache,
|
|
198
|
-
this.metricsClient,
|
|
199
197
|
this.wso2,
|
|
200
198
|
);
|
|
201
199
|
this.inboundServer.on('error', (...args) => {
|
package/src/lib/metrics.js
CHANGED
|
@@ -131,8 +131,6 @@ class MetricsServer {
|
|
|
131
131
|
|
|
132
132
|
result.use(koaBody());
|
|
133
133
|
result.use(async ctx => {
|
|
134
|
-
this._logger.log('Metrics request received');
|
|
135
|
-
|
|
136
134
|
ctx.response.set('Content-Type', this._prometheusRegister.contentType);
|
|
137
135
|
ctx.response.body = await this._prometheusRegister.metrics();
|
|
138
136
|
});
|
package/src/lib/router.js
CHANGED
|
@@ -21,7 +21,9 @@ module.exports = (handlerMap) => async (ctx, next) => {
|
|
|
21
21
|
ctx.response.body = { statusCode: 404, message: 'Not found' };
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
24
|
-
ctx.state.
|
|
24
|
+
if (!ctx.state.logExcludePaths.includes(ctx.path)) {
|
|
25
|
+
ctx.state.logger.push({handler}).log('Found handler');
|
|
26
|
+
}
|
|
25
27
|
await handler(ctx);
|
|
26
28
|
}
|
|
27
29
|
await next();
|
package/src/lib/validate.js
CHANGED
|
@@ -125,6 +125,13 @@ const transformApiDoc = apiDoc => ({
|
|
|
125
125
|
});
|
|
126
126
|
|
|
127
127
|
class Validator {
|
|
128
|
+
/**
|
|
129
|
+
* @param {{logExcludePaths: string[]}} [opts]
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
constructor(opts) {
|
|
133
|
+
this.logExcludePaths = opts?.logExcludePaths || [];
|
|
134
|
+
}
|
|
128
135
|
// apiDoc
|
|
129
136
|
// POJO representing apiDoc API spec. Example:
|
|
130
137
|
// const v = new Validator(require('./apiDoc.json'));
|
|
@@ -163,7 +170,9 @@ class Validator {
|
|
|
163
170
|
}
|
|
164
171
|
result.params = Object.assign({}, ...path.match(result.matcher.regex).slice(1).map((m, i) => ({ [result.matcher.params[i]]: m})));
|
|
165
172
|
|
|
166
|
-
|
|
173
|
+
if (!this.logExcludePaths.includes(path)) {
|
|
174
|
+
logger.push({path, result}).log('Matched path');
|
|
175
|
+
}
|
|
167
176
|
return result;
|
|
168
177
|
}
|
|
169
178
|
|