@mojaloop/sdk-scheme-adapter 24.9.4 → 24.9.6
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/.yarn/cache/{@babel-core-npm-7.27.3-86995da3eb-d70d5e4e99.zip → @babel-core-npm-7.27.4-801e5891a4-e7f961274f.zip} +0 -0
- package/.yarn/cache/{@babel-helpers-npm-7.27.3-fb2512a0e0-c572acf07c.zip → @babel-helpers-npm-7.27.4-ba8f87a40e-a50ce7ff92.zip} +0 -0
- package/.yarn/cache/@babel-parser-npm-7.27.4-c8d264780c-846d267688.zip +0 -0
- package/.yarn/cache/@babel-traverse-npm-7.27.4-fe457ebf1b-ae0047fe78.zip +0 -0
- package/.yarn/cache/{@types-node-npm-22.15.27-e786b3c41a-bf621456bf.zip → @types-node-npm-22.15.29-b40796f35f-201aabe361.zip} +0 -0
- package/.yarn/install-state.gz +0 -0
- package/CHANGELOG.md +14 -0
- package/modules/api-svc/package.json +1 -1
- package/modules/api-svc/src/InboundServer/index.js +12 -0
- package/modules/api-svc/src/index.js +3 -2
- package/modules/api-svc/test/unit/InboundServer.test.js +54 -0
- package/modules/api-svc/test/unit/index.test.js +0 -18
- package/modules/outbound-command-event-handler/package.json +1 -1
- package/modules/outbound-domain-event-handler/package.json +1 -1
- package/modules/private-shared-lib/package.json +1 -1
- package/package.json +2 -2
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/.yarn/install-state.gz
CHANGED
|
Binary file
|
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
# Changelog: [mojaloop/sdk-scheme-adapter](https://github.com/mojaloop/sdk-scheme-adapter)
|
|
2
|
+
### [24.9.6](https://github.com/mojaloop/sdk-scheme-adapter/compare/v24.9.5...v24.9.6) (2025-06-01)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Chore
|
|
6
|
+
|
|
7
|
+
* fix faulty jws replacement logic [@kleyow](https://github.com/kleyow) ([#585](https://github.com/mojaloop/sdk-scheme-adapter/issues/585)) ([efa7ce1](https://github.com/mojaloop/sdk-scheme-adapter/commit/efa7ce19f869a601f868f57ea569202110c9d7f9))
|
|
8
|
+
|
|
9
|
+
### [24.9.5](https://github.com/mojaloop/sdk-scheme-adapter/compare/v24.9.4...v24.9.5) (2025-05-30)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Chore
|
|
13
|
+
|
|
14
|
+
* hot mutate peerJwsKeys instead of restart ([#584](https://github.com/mojaloop/sdk-scheme-adapter/issues/584)) ([08983fc](https://github.com/mojaloop/sdk-scheme-adapter/commit/08983fcc5ab7cde0042cb3e17545d581accb9d3a))
|
|
15
|
+
|
|
2
16
|
### [24.9.4](https://github.com/mojaloop/sdk-scheme-adapter/compare/v24.9.3...v24.9.4) (2025-05-30)
|
|
3
17
|
|
|
4
18
|
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
******/
|
|
27
27
|
const Koa = require('koa');
|
|
28
28
|
|
|
29
|
+
const _ = require('lodash');
|
|
29
30
|
const assert = require('assert').strict;
|
|
30
31
|
const https = require('https');
|
|
31
32
|
const http = require('http');
|
|
@@ -52,6 +53,7 @@ class InboundApi extends EventEmitter {
|
|
|
52
53
|
super({ captureExceptions: true });
|
|
53
54
|
this._conf = conf;
|
|
54
55
|
this._cache = cache;
|
|
56
|
+
this._logger = logger;
|
|
55
57
|
_initialize ||= _validator.initialise(apiSpecs, conf);
|
|
56
58
|
|
|
57
59
|
if (conf.validateInboundJws) {
|
|
@@ -85,6 +87,16 @@ class InboundApi extends EventEmitter {
|
|
|
85
87
|
return this._api.callback();
|
|
86
88
|
}
|
|
87
89
|
|
|
90
|
+
_updatePeerJwsKeys(peerJwsKeys) {
|
|
91
|
+
if (this._conf.pm4mlEnabled && !_.isEqual(this._jwsVerificationKeys, peerJwsKeys) &&
|
|
92
|
+
this._jwsVerificationKeys && typeof this._jwsVerificationKeys === 'object') {
|
|
93
|
+
this._logger && this._logger.isVerboseEnabled && this._logger.verbose('Clearing existing JWS verification keys');
|
|
94
|
+
Object.keys(this._jwsVerificationKeys).forEach(key => delete this._jwsVerificationKeys[key]);
|
|
95
|
+
this._logger && this._logger.isVerboseEnabled && this._logger.verbose('Assigning new peer JWS keys');
|
|
96
|
+
Object.assign(this._jwsVerificationKeys, peerJwsKeys);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
88
100
|
_startJwsWatcher() {
|
|
89
101
|
const FS_EVENT_TYPES = {
|
|
90
102
|
CHANGE: 'change',
|
|
@@ -141,8 +141,7 @@ class Server extends EventEmitter {
|
|
|
141
141
|
|
|
142
142
|
_shouldUpdateInboundServer(newConf) {
|
|
143
143
|
return !_.isEqual(this.conf.inbound, newConf.inbound)
|
|
144
|
-
|| !_.isEqual(this.conf.outbound, newConf.outbound)
|
|
145
|
-
|| !_.isEqual(this.conf.peerJWSKeys, newConf.peerJWSKeys);
|
|
144
|
+
|| !_.isEqual(this.conf.outbound, newConf.outbound);
|
|
146
145
|
}
|
|
147
146
|
|
|
148
147
|
async start() {
|
|
@@ -248,6 +247,8 @@ class Server extends EventEmitter {
|
|
|
248
247
|
restartActionsTaken.updateInboundServer = true;
|
|
249
248
|
}
|
|
250
249
|
|
|
250
|
+
this.inboundServer._api._updatePeerJwsKeys(newConf.peerJWSKeys);
|
|
251
|
+
|
|
251
252
|
this.logger.isDebugEnabled && this.logger.push({ oldConf: this.conf.outbound, newConf: newConf.outbound }).debug('Outbound server configuration');
|
|
252
253
|
const updateOutboundServer = !_.isEqual(this.conf.outbound, newConf.outbound);
|
|
253
254
|
if (updateOutboundServer) {
|
|
@@ -490,5 +490,59 @@ describe('Inbound Server', () => {
|
|
|
490
490
|
|
|
491
491
|
expect(Jws.validator.__validationKeys['mock-jws'].toString()).toEqual('foo-key-updated');
|
|
492
492
|
});
|
|
493
|
+
|
|
494
|
+
it('should overwrite an existing peer JWS key when _updatePeerJwsKeys is called with the same key name', async () => {
|
|
495
|
+
// Arrange
|
|
496
|
+
const serverConfig = JSON.parse(JSON.stringify(defaultConfig));
|
|
497
|
+
serverConfig.validateInboundJws = true;
|
|
498
|
+
const cache = new Cache({
|
|
499
|
+
cacheUrl: serverConfig.cacheUrl,
|
|
500
|
+
logger: logger.push({ component: 'cache' }),
|
|
501
|
+
unsubscribeTimeoutMs: serverConfig.unsubscribeTimeoutMs,
|
|
502
|
+
});
|
|
503
|
+
serverConfig.validateInboundJws = true;
|
|
504
|
+
serverConfig.pm4mlEnabled = true;
|
|
505
|
+
serverConfig.peerJWSKeys = {
|
|
506
|
+
'peer1': 'original-key'
|
|
507
|
+
};
|
|
508
|
+
const svr = new InboundServer(serverConfig, logger, cache);
|
|
509
|
+
|
|
510
|
+
// Save reference before update
|
|
511
|
+
const keysRef = svr._api._jwsVerificationKeys;
|
|
512
|
+
|
|
513
|
+
// Act: Overwrite the key
|
|
514
|
+
svr._api._updatePeerJwsKeys({ 'peer1': 'new-key' });
|
|
515
|
+
|
|
516
|
+
// Assert
|
|
517
|
+
expect(svr._api._jwsVerificationKeys['peer1']).toBe('new-key');
|
|
518
|
+
expect(svr._api._jwsVerificationKeys).toBe(keysRef); // memory reference unchanged
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
it('should add a new peer JWS key when _updatePeerJwsKeys is called with a new key name', async () => {
|
|
522
|
+
// Arrange
|
|
523
|
+
const serverConfig = JSON.parse(JSON.stringify(defaultConfig));
|
|
524
|
+
serverConfig.validateInboundJws = true;
|
|
525
|
+
const cache = new Cache({
|
|
526
|
+
cacheUrl: serverConfig.cacheUrl,
|
|
527
|
+
logger: logger.push({ component: 'cache' }),
|
|
528
|
+
unsubscribeTimeoutMs: serverConfig.unsubscribeTimeoutMs,
|
|
529
|
+
});
|
|
530
|
+
serverConfig.validateInboundJws = true;
|
|
531
|
+
serverConfig.pm4mlEnabled = true;
|
|
532
|
+
serverConfig.peerJWSKeys = {
|
|
533
|
+
'peer1': 'original-key'
|
|
534
|
+
};
|
|
535
|
+
const svr = new InboundServer(serverConfig, logger, cache);
|
|
536
|
+
|
|
537
|
+
// Save reference before update
|
|
538
|
+
const keysRef = svr._api._jwsVerificationKeys;
|
|
539
|
+
|
|
540
|
+
// Act: Add a new key
|
|
541
|
+
svr._api._updatePeerJwsKeys({ 'peer1': 'original-key', 'peer2': 'another-key' });
|
|
542
|
+
// Assert
|
|
543
|
+
expect(svr._api._jwsVerificationKeys['peer1']).toBe('original-key');
|
|
544
|
+
expect(svr._api._jwsVerificationKeys['peer2']).toBe('another-key');
|
|
545
|
+
expect(svr._api._jwsVerificationKeys).toBe(keysRef); // memory reference unchanged
|
|
546
|
+
});
|
|
493
547
|
});
|
|
494
548
|
});
|
|
@@ -99,24 +99,6 @@ describe('Server', () => {
|
|
|
99
99
|
expect(server.restart).toHaveBeenCalledWith(newConf);
|
|
100
100
|
});
|
|
101
101
|
|
|
102
|
-
it('restarts inbound server if peerJWSKeys config is different', async () => {
|
|
103
|
-
// Clone the conf and change peerJWSKeys
|
|
104
|
-
const newConf = JSON.parse(JSON.stringify(conf));
|
|
105
|
-
newConf.peerJWSKeys = [{ kid: 'new-key', key: 'abc123' }];
|
|
106
|
-
|
|
107
|
-
// _shouldUpdateInboundServer should return true
|
|
108
|
-
expect(server._shouldUpdateInboundServer(newConf)).toBe(true);
|
|
109
|
-
|
|
110
|
-
// Simulate a config change event from control server
|
|
111
|
-
controlServer.broadcastConfigChange(newConf);
|
|
112
|
-
|
|
113
|
-
// Wait for the restart to be triggered
|
|
114
|
-
await new Promise((wait) => setTimeout(wait, 1000));
|
|
115
|
-
|
|
116
|
-
expect(server.restart).toHaveBeenCalledTimes(1);
|
|
117
|
-
expect(server.restart).toHaveBeenCalledWith(newConf);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
102
|
it('restarts inbound server if inbound or outbound is different', async () => {
|
|
121
103
|
// Clone the conf and change inbound config
|
|
122
104
|
const newConfInbound = JSON.parse(JSON.stringify(conf));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mojaloop/sdk-scheme-adapter",
|
|
3
|
-
"version": "24.9.
|
|
3
|
+
"version": "24.9.6",
|
|
4
4
|
"description": "mojaloop sdk-scheme-adapter",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/mojaloop/sdk-scheme-adapter",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
84
|
"@types/jest": "29.5.14",
|
|
85
|
-
"@types/node": "22.15.
|
|
85
|
+
"@types/node": "22.15.29",
|
|
86
86
|
"@types/node-cache": "4.2.5",
|
|
87
87
|
"@typescript-eslint/eslint-plugin": "8.33.0",
|
|
88
88
|
"@typescript-eslint/parser": "8.33.0",
|