@mojaloop/sdk-scheme-adapter 12.0.0 → 12.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/.nvmrc +1 -1
- package/.versionrc +1 -0
- package/CHANGELOG.md +6 -2
- package/OAuthTestServer/index.js +80 -19
- package/audit-resolve.json +25 -0
- package/package.json +5 -10
- package/test/unit/InboundServer.test.js +1 -1
- package/test/unit/config.test.js +1 -1
package/.nvmrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
v16.14
|
package/.versionrc
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
# Changelog
|
|
1
|
+
# Changelog: [mojaloop/thirdparty-api-svc](https://github.com/mojaloop/thirdparty-api-svc)
|
|
2
|
+
### [12.0.1](https://github.com/mojaloop/sdk-scheme-adapter/compare/v12.0.0...v12.0.1) (2022-04-19)
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* remove outdated koa2-oauth-server and bump to node 16 ([#302](https://github.com/mojaloop/sdk-scheme-adapter/issues/302)) ([9c1ae18](https://github.com/mojaloop/sdk-scheme-adapter/commit/9c1ae18375f033fe59c219fa7cc970bd4d0c72f2))
|
|
4
8
|
|
|
5
9
|
## [12.0.0](https://github.com/mojaloop/sdk-scheme-adapter/compare/v11.18.12...v12.0.0) (2022-03-18)
|
|
6
10
|
|
package/OAuthTestServer/index.js
CHANGED
|
@@ -10,11 +10,13 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
13
|
+
const { assert } = require('assert');
|
|
14
|
+
const express = require('express');
|
|
15
|
+
const bodyParser = require('body-parser');
|
|
16
|
+
const OAuth2Server = require('oauth2-server');
|
|
17
17
|
const { InMemoryCache } = require('./model');
|
|
18
|
+
const {Request, Response} = require('oauth2-server');
|
|
19
|
+
const UnauthorizedRequestError = require('oauth2-server/lib/errors/unauthorized-request-error');
|
|
18
20
|
|
|
19
21
|
class OAuthTestServer {
|
|
20
22
|
/**
|
|
@@ -29,36 +31,95 @@ class OAuthTestServer {
|
|
|
29
31
|
this._api = null;
|
|
30
32
|
this._port = port;
|
|
31
33
|
this._logger = logger;
|
|
32
|
-
this.
|
|
33
|
-
this.
|
|
34
|
+
this._clientKey = clientKey;
|
|
35
|
+
this._clientSecret = clientSecret;
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
async start() {
|
|
37
|
-
if (this.
|
|
39
|
+
if (this._app) {
|
|
38
40
|
return;
|
|
39
41
|
}
|
|
40
|
-
|
|
42
|
+
this._app = express();
|
|
43
|
+
|
|
44
|
+
this._oauth = new OAuth2Server({
|
|
45
|
+
model: new InMemoryCache({ clientKey: this._clientKey, clientSecret:this._clientSecret }),
|
|
46
|
+
accessTokenLifetime: 60 * 60,
|
|
47
|
+
allowBearerTokensInQueryString: true,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
this._app.use(bodyParser.urlencoded({ extended: false }));
|
|
51
|
+
this._app.use(bodyParser.json());
|
|
52
|
+
this._app.use(this.tokenMiddleware());
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
await new Promise((resolve) => this._app.listen(this._port, resolve));
|
|
41
56
|
this._logger.push({ port: this._port }).log('Serving OAuth2 Test Server');
|
|
42
57
|
}
|
|
43
58
|
|
|
44
59
|
async stop() {
|
|
45
|
-
|
|
60
|
+
if (!this._app) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
await new Promise(resolve => this._app.close(resolve));
|
|
64
|
+
this._app = null;
|
|
46
65
|
this._logger.log('OAuth2 Test Server shut down complete');
|
|
47
66
|
}
|
|
48
67
|
|
|
49
|
-
|
|
50
|
-
|
|
68
|
+
async reconfigure({ port, clientKey, clientSecret, logger }) {
|
|
69
|
+
assert(port === this._port, 'Cannot reconfigure running port');
|
|
70
|
+
return () => {
|
|
71
|
+
this._port = port;
|
|
72
|
+
this._logger = logger;
|
|
73
|
+
this.stop().then(() => this.start());
|
|
74
|
+
this._api = OAuthTestServer._SetupApi({ clientKey, clientSecret });
|
|
75
|
+
this._logger.log('restarted');
|
|
76
|
+
};
|
|
77
|
+
}
|
|
51
78
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
79
|
+
handleResponse(req, res, response) {
|
|
80
|
+
if (response.status === 302) {
|
|
81
|
+
const location = response.headers.location;
|
|
82
|
+
delete response.headers.location;
|
|
83
|
+
res.set(response.headers);
|
|
84
|
+
res.redirect(location);
|
|
85
|
+
} else {
|
|
86
|
+
res.set(response.headers);
|
|
87
|
+
res.status(response.status).send(response.body);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
handleError(e, req, res, response) {
|
|
92
|
+
if (response) {
|
|
93
|
+
res.set(response.headers);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
res.status(e.code);
|
|
97
|
+
|
|
98
|
+
if (e instanceof UnauthorizedRequestError) {
|
|
99
|
+
return res.send();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
res.send({ error: e.name, error_description: e.message });
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
tokenMiddleware(options) {
|
|
106
|
+
return async (req, res, next) => {
|
|
107
|
+
const request = new Request(req);
|
|
108
|
+
const response = new Response(res);
|
|
109
|
+
|
|
110
|
+
let token;
|
|
111
|
+
|
|
112
|
+
try {
|
|
113
|
+
token = await this._oauth.token(request, response, options);
|
|
114
|
+
res.locals.oauth = {token};
|
|
115
|
+
} catch (e) {
|
|
116
|
+
await this.handleError(e, req, res, response, next);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
57
119
|
|
|
58
|
-
|
|
59
|
-
result.use(result.oauth.token());
|
|
120
|
+
await this.handleResponse(req, res, response);
|
|
60
121
|
|
|
61
|
-
|
|
122
|
+
};
|
|
62
123
|
}
|
|
63
124
|
}
|
|
64
125
|
|
package/audit-resolve.json
CHANGED
|
@@ -389,6 +389,31 @@
|
|
|
389
389
|
"decision": "ignore",
|
|
390
390
|
"madeAt": 1647565602524,
|
|
391
391
|
"expiresAt": 1650157555692
|
|
392
|
+
},
|
|
393
|
+
"1069972|@mojaloop/central-services-shared>@mojaloop/event-sdk>moment": {
|
|
394
|
+
"decision": "ignore",
|
|
395
|
+
"madeAt": 1649898254012,
|
|
396
|
+
"expiresAt": 1652490250295
|
|
397
|
+
},
|
|
398
|
+
"1069972|@mojaloop/event-sdk>moment": {
|
|
399
|
+
"decision": "ignore",
|
|
400
|
+
"madeAt": 1649898254012,
|
|
401
|
+
"expiresAt": 1652490250295
|
|
402
|
+
},
|
|
403
|
+
"1067456|@mojaloop/central-services-shared>widdershins>markdown-it": {
|
|
404
|
+
"decision": "ignore",
|
|
405
|
+
"madeAt": 1649898255401,
|
|
406
|
+
"expiresAt": 1652490250295
|
|
407
|
+
},
|
|
408
|
+
"1068310|@mojaloop/central-services-shared>widdershins>yargs>yargs-parser": {
|
|
409
|
+
"decision": "ignore",
|
|
410
|
+
"madeAt": 1649898256486,
|
|
411
|
+
"expiresAt": 1652490250295
|
|
412
|
+
},
|
|
413
|
+
"1067946|ajv": {
|
|
414
|
+
"decision": "ignore",
|
|
415
|
+
"madeAt": 1649898257344,
|
|
416
|
+
"expiresAt": 1652490250295
|
|
392
417
|
}
|
|
393
418
|
},
|
|
394
419
|
"rules": {},
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mojaloop/sdk-scheme-adapter",
|
|
3
|
-
"version": "12.0.
|
|
3
|
+
"version": "12.0.1",
|
|
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": "
|
|
8
|
+
"node": "=16.x"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"audit:resolve": "SHELL=sh resolve-audit --production",
|
|
@@ -49,12 +49,6 @@
|
|
|
49
49
|
"type": "git",
|
|
50
50
|
"url": "git@github.com:mojaloop/sdk-scheme-adapter.git"
|
|
51
51
|
},
|
|
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
52
|
"dependencies": {
|
|
59
53
|
"@koa/cors": "^3.1.0",
|
|
60
54
|
"@mojaloop/central-services-error-handling": "11.3.0",
|
|
@@ -70,12 +64,13 @@
|
|
|
70
64
|
"co-body": "^6.1.0",
|
|
71
65
|
"dotenv": "^10.0.0",
|
|
72
66
|
"env-var": "^7.0.1",
|
|
67
|
+
"express": "^4.17.2",
|
|
73
68
|
"javascript-state-machine": "^3.1.0",
|
|
74
69
|
"js-yaml": "^4.1.0",
|
|
75
70
|
"json-schema-ref-parser": "^9.0.9",
|
|
76
71
|
"koa": "^2.13.1",
|
|
77
72
|
"koa-body": "^4.2.0",
|
|
78
|
-
"
|
|
73
|
+
"oauth2-server": "^4.0.0-dev.2",
|
|
79
74
|
"openapi-jsonschema-parameters": "^9.3.0",
|
|
80
75
|
"promise-timeout": "^1.3.0",
|
|
81
76
|
"redis": "^3.1.2",
|
|
@@ -96,7 +91,7 @@
|
|
|
96
91
|
"jest": "^27.2.0",
|
|
97
92
|
"jest-junit": "^12.2.0",
|
|
98
93
|
"nock": "^13.1.3",
|
|
99
|
-
"npm-audit-resolver": "^
|
|
94
|
+
"npm-audit-resolver": "^3.0.0-0",
|
|
100
95
|
"npm-check-updates": "^11.8.5",
|
|
101
96
|
"openapi-response-validator": "^9.3.0",
|
|
102
97
|
"openapi-typescript": "^4.0.2",
|
|
@@ -376,7 +376,7 @@ describe('Inbound Server', () => {
|
|
|
376
376
|
|
|
377
377
|
afterEach(async () => {
|
|
378
378
|
await svr.stop();
|
|
379
|
-
fs.
|
|
379
|
+
fs.rmSync(keysDir, { recursive: true });
|
|
380
380
|
});
|
|
381
381
|
|
|
382
382
|
it('updates server configuration when a new JWS verification key '
|