@mojaloop/sdk-scheme-adapter 18.0.0 → 18.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/.dockerignore +18 -0
- package/.eslintignore +2 -0
- package/CHANGELOG.md +8 -0
- package/audit-resolve.json +5 -0
- package/package.json +2 -2
- package/test/__mocks__/@mojaloop/sdk-standard-components.js +0 -151
- package/test/__mocks__/javascript-state-machine.js +0 -21
- package/test/__mocks__/redis.js +0 -78
- package/test/__mocks__/uuidv4.js +0 -16
- package/test/config/integration.env +0 -146
- package/test/integration/lib/Outbound/data/quotesPostRequest.json +0 -52
- package/test/integration/lib/Outbound/data/transfersPostRequest.json +0 -24
- package/test/integration/lib/Outbound/parties.test.js +0 -31
- package/test/integration/lib/Outbound/quotes.test.js +0 -62
- package/test/integration/lib/Outbound/simpleTransfers.test.js +0 -70
- package/test/integration/lib/cache.test.js +0 -79
- package/test/integration/testEnv.js +0 -4
- package/test/unit/ControlClient.test.js +0 -69
- package/test/unit/ControlServer/events.js +0 -41
- package/test/unit/ControlServer/index.js +0 -227
- package/test/unit/ControlServer.test.js +0 -66
- package/test/unit/InboundServer.test.js +0 -443
- package/test/unit/TestServer.test.js +0 -392
- package/test/unit/api/accounts/accounts.test.js +0 -128
- package/test/unit/api/accounts/data/postAccountsBody.json +0 -7
- package/test/unit/api/accounts/data/postAccountsErrorMojaloopResponse.json +0 -33
- package/test/unit/api/accounts/data/postAccountsErrorTimeoutResponse.json +0 -19
- package/test/unit/api/accounts/data/postAccountsSuccessResponse.json +0 -31
- package/test/unit/api/accounts/data/postAccountsSuccessResponseWithError1.json +0 -34
- package/test/unit/api/accounts/data/postAccountsSuccessResponseWithError2.json +0 -39
- package/test/unit/api/accounts/utils.js +0 -79
- package/test/unit/api/proxy/data/proxyConfig.yaml +0 -82
- package/test/unit/api/proxy/data/requestBody.json +0 -22
- package/test/unit/api/proxy/data/requestHeaders.json +0 -5
- package/test/unit/api/proxy/data/requestQuery.json +0 -6
- package/test/unit/api/proxy/data/responseBody.json +0 -21
- package/test/unit/api/proxy/data/responseHeaders.json +0 -5
- package/test/unit/api/proxy/proxy.test.js +0 -220
- package/test/unit/api/proxy/utils.js +0 -79
- package/test/unit/api/transfers/data/getTransfersCommittedResponse.json +0 -24
- package/test/unit/api/transfers/data/getTransfersErrorNotFound.json +0 -18
- package/test/unit/api/transfers/data/postQuotesBody.json +0 -52
- package/test/unit/api/transfers/data/postTransfersBadBody.json +0 -17
- package/test/unit/api/transfers/data/postTransfersBody.json +0 -24
- package/test/unit/api/transfers/data/postTransfersErrorMojaloopResponse.json +0 -62
- package/test/unit/api/transfers/data/postTransfersErrorTimeoutResponse.json +0 -48
- package/test/unit/api/transfers/data/postTransfersSimpleBody.json +0 -26
- package/test/unit/api/transfers/data/postTransfersSuccessResponse.json +0 -128
- package/test/unit/api/transfers/data/putPartiesBody.json +0 -20
- package/test/unit/api/transfers/data/putQuotesBody.json +0 -37
- package/test/unit/api/transfers/data/putTransfersBody.json +0 -17
- package/test/unit/api/transfers/transfers.test.js +0 -191
- package/test/unit/api/transfers/utils.js +0 -264
- package/test/unit/api/utils.js +0 -86
- package/test/unit/config.test.js +0 -119
- package/test/unit/data/commonHttpHeaders.json +0 -7
- package/test/unit/data/defaultConfig.json +0 -70
- package/test/unit/data/postQuotesBody.json +0 -52
- package/test/unit/data/putParticipantsBody.json +0 -12
- package/test/unit/data/putPartiesBody.json +0 -20
- package/test/unit/data/testFile.json +0 -29
- package/test/unit/data/testFile.yaml +0 -14
- package/test/unit/inboundApi/data/mockArguments.json +0 -117
- package/test/unit/inboundApi/data/mockTransactionRequest.json +0 -42
- package/test/unit/inboundApi/handlers.test.js +0 -786
- package/test/unit/index.test.js +0 -88
- package/test/unit/lib/cache.test.js +0 -145
- package/test/unit/lib/model/AccountsModel.test.js +0 -124
- package/test/unit/lib/model/InboundTransfersModel.test.js +0 -889
- package/test/unit/lib/model/OutboundBulkQuotesModel.test.js +0 -253
- package/test/unit/lib/model/OutboundBulkTransfersModel.test.js +0 -247
- package/test/unit/lib/model/OutboundRequestToPayModel.test.js +0 -166
- package/test/unit/lib/model/OutboundRequestToPayTransferModel.test.js +0 -245
- package/test/unit/lib/model/OutboundTransfersModel.test.js +0 -1579
- package/test/unit/lib/model/PartiesModel.test.js +0 -478
- package/test/unit/lib/model/QuotesModel.test.js +0 -477
- package/test/unit/lib/model/TransfersModel.test.js +0 -481
- package/test/unit/lib/model/common/PersistentStateMachine.test.js +0 -178
- package/test/unit/lib/model/data/authorizationsResponse.json +0 -13
- package/test/unit/lib/model/data/bulkQuoteRequest.json +0 -27
- package/test/unit/lib/model/data/bulkQuoteResponse.json +0 -35
- package/test/unit/lib/model/data/bulkTransferFulfil.json +0 -13
- package/test/unit/lib/model/data/bulkTransferRequest.json +0 -29
- package/test/unit/lib/model/data/defaultConfig.json +0 -59
- package/test/unit/lib/model/data/getBulkTransfersBackendResponse.json +0 -42
- package/test/unit/lib/model/data/getBulkTransfersMojaloopResponse.json +0 -22
- package/test/unit/lib/model/data/getTransfersBackendResponse.json +0 -34
- package/test/unit/lib/model/data/getTransfersMojaloopResponse.json +0 -17
- package/test/unit/lib/model/data/mockArguments.json +0 -188
- package/test/unit/lib/model/data/mockTxnRequestsArguments.json +0 -63
- package/test/unit/lib/model/data/notificationAbortedToPayee.json +0 -10
- package/test/unit/lib/model/data/notificationReservedToPayee.json +0 -10
- package/test/unit/lib/model/data/notificationToPayee.json +0 -10
- package/test/unit/lib/model/data/payeeParty.json +0 -18
- package/test/unit/lib/model/data/putQuotesResponse.json +0 -33
- package/test/unit/lib/model/data/putTransfersResponse.json +0 -5
- package/test/unit/lib/model/data/quoteResponse.json +0 -42
- package/test/unit/lib/model/data/requestToPayRequest.json +0 -20
- package/test/unit/lib/model/data/requestToPayTransferRequest.json +0 -27
- package/test/unit/lib/model/data/transactionRequestResponse.json +0 -18
- package/test/unit/lib/model/data/transferFulfil.json +0 -10
- package/test/unit/lib/model/data/transferRequest.json +0 -26
- package/test/unit/lib/model/mockedLibRequests.js +0 -74
- package/test/unit/mockLogger.js +0 -39
- package/test/unit/outboundApi/data/bulkQuoteRequest.json +0 -28
- package/test/unit/outboundApi/data/bulkTransferRequest.json +0 -28
- package/test/unit/outboundApi/data/mockBulkQuoteError.json +0 -45
- package/test/unit/outboundApi/data/mockBulkTransferError.json +0 -48
- package/test/unit/outboundApi/data/mockError.json +0 -41
- package/test/unit/outboundApi/data/mockGetPartiesError.json +0 -4
- package/test/unit/outboundApi/data/mockRequestToPayError.json +0 -32
- package/test/unit/outboundApi/data/mockRequestToPayTransferError.json +0 -39
- package/test/unit/outboundApi/data/requestToPay.json +0 -21
- package/test/unit/outboundApi/data/requestToPayTransferRequest.json +0 -20
- package/test/unit/outboundApi/data/transferRequest.json +0 -21
- package/test/unit/outboundApi/handlers.test.js +0 -887
package/.dockerignore
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
deploy/
|
|
2
|
+
coverage/
|
|
3
|
+
node_modules/
|
|
4
|
+
.dockerignore
|
|
5
|
+
.editorconfig
|
|
6
|
+
.git/
|
|
7
|
+
.gitignore
|
|
8
|
+
.istanbul.yml
|
|
9
|
+
circle.yml
|
|
10
|
+
docker-compose.circle.yml
|
|
11
|
+
docker-compose.dev.yml
|
|
12
|
+
docker-compose.functional.yml
|
|
13
|
+
docker-compose.yml
|
|
14
|
+
Dockerfile
|
|
15
|
+
LICENSE
|
|
16
|
+
README.md
|
|
17
|
+
sonar-project.properties
|
|
18
|
+
.devspace/
|
package/.eslintignore
ADDED
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
# Changelog: [mojaloop/thirdparty-api-svc](https://github.com/mojaloop/thirdparty-api-svc)
|
|
2
|
+
### [18.0.1](https://github.com/mojaloop/sdk-scheme-adapter/compare/v18.0.0...v18.0.1) (2022-07-12)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Chore
|
|
6
|
+
|
|
7
|
+
* added .npmignore so that the test folder is not included when publishing packages ([#332](https://github.com/mojaloop/sdk-scheme-adapter/issues/332)) ([602b3ab](https://github.com/mojaloop/sdk-scheme-adapter/commit/602b3abfe861123623768e2a1c3497063ce4b909))
|
|
8
|
+
* uodated deps ([#333](https://github.com/mojaloop/sdk-scheme-adapter/issues/333)) ([7f9e027](https://github.com/mojaloop/sdk-scheme-adapter/commit/7f9e0277ff760ad22ab29dc3abee20322030d7dc))
|
|
9
|
+
|
|
2
10
|
## [18.0.0](https://github.com/mojaloop/sdk-scheme-adapter/compare/v17.0.1...v18.0.0) (2022-07-11)
|
|
3
11
|
|
|
4
12
|
|
package/audit-resolve.json
CHANGED
|
@@ -59,6 +59,11 @@
|
|
|
59
59
|
"decision": "ignore",
|
|
60
60
|
"madeAt": 1657217280998,
|
|
61
61
|
"expiresAt": 1659809259103
|
|
62
|
+
},
|
|
63
|
+
"1081008|@mojaloop/central-services-shared>@mojaloop/event-sdk>grpc>protobufjs>moment": {
|
|
64
|
+
"decision": "ignore",
|
|
65
|
+
"madeAt": 1657621042651,
|
|
66
|
+
"expiresAt": 1660213039412
|
|
62
67
|
}
|
|
63
68
|
},
|
|
64
69
|
"rules": {},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mojaloop/sdk-scheme-adapter",
|
|
3
|
-
"version": "18.0.
|
|
3
|
+
"version": "18.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",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@koa/cors": "^3.3.0",
|
|
61
61
|
"@mojaloop/central-services-shared": "17.0.2",
|
|
62
|
-
"@mojaloop/sdk-standard-components": "^17.1.
|
|
62
|
+
"@mojaloop/sdk-standard-components": "^17.1.1",
|
|
63
63
|
"ajv": "8.11.0",
|
|
64
64
|
"axios": "^0.27.2",
|
|
65
65
|
"co-body": "^6.1.0",
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
/**************************************************************************
|
|
2
|
-
* (C) Copyright ModusBox Inc. 2019 - All rights reserved. *
|
|
3
|
-
* *
|
|
4
|
-
* This file is made available under the terms of the license agreement *
|
|
5
|
-
* specified in the corresponding source code repository. *
|
|
6
|
-
* *
|
|
7
|
-
* ORIGINAL AUTHOR: *
|
|
8
|
-
* James Bush - james.bush@modusbox.com *
|
|
9
|
-
**************************************************************************/
|
|
10
|
-
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
const assert = require('assert').strict;
|
|
14
|
-
const util = require('util');
|
|
15
|
-
const { MojaloopRequests, Errors, WSO2Auth, Jws, Logger } = jest.requireActual('@mojaloop/sdk-standard-components');
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
class MockMojaloopRequests extends MojaloopRequests {
|
|
19
|
-
constructor(...args) {
|
|
20
|
-
super(...args);
|
|
21
|
-
MockMojaloopRequests.__instance = this;
|
|
22
|
-
this.postParticipants = MockMojaloopRequests.__postParticipants;
|
|
23
|
-
this.getParties = MockMojaloopRequests.__getParties;
|
|
24
|
-
this.postTransactionRequests = MockMojaloopRequests.__postTransactionRequests;
|
|
25
|
-
this.postQuotes = MockMojaloopRequests.__postQuotes;
|
|
26
|
-
this.putQuotes = MockMojaloopRequests.__putQuotes;
|
|
27
|
-
this.putQuotesError = MockMojaloopRequests.__putQuotesError;
|
|
28
|
-
this.getAuthorizations = MockMojaloopRequests.__getAuthorizations;
|
|
29
|
-
this.putAuthorizations = MockMojaloopRequests.__putAuthorizations;
|
|
30
|
-
this.getTransfers = MockMojaloopRequests.__getTransfers;
|
|
31
|
-
this.putTransactionRequests = MockMojaloopRequests.__putTransactionRequests;
|
|
32
|
-
this.postTransfers = MockMojaloopRequests.__postTransfers;
|
|
33
|
-
this.putTransfers = MockMojaloopRequests.__putTransfers;
|
|
34
|
-
this.putTransfersError = MockMojaloopRequests.__putTransfersError;
|
|
35
|
-
this.getBulkQuotes = MockMojaloopRequests.__getBulkQuotes;
|
|
36
|
-
this.postBulkQuotes = MockMojaloopRequests.__postBulkQuotes;
|
|
37
|
-
this.putBulkQuotes = MockMojaloopRequests.__putBulkQuotes;
|
|
38
|
-
this.putBulkQuotesError = MockMojaloopRequests.__putBulkQuotesError;
|
|
39
|
-
this.getBulkTransfers = MockMojaloopRequests.__getBulkTransfers;
|
|
40
|
-
this.postBulkTransfers = MockMojaloopRequests.__postBulkTransfers;
|
|
41
|
-
this.putBulkTransfers = MockMojaloopRequests.__putBulkTransfers;
|
|
42
|
-
this.putBulkTransfersError = MockMojaloopRequests.__putBulkTransfersError;
|
|
43
|
-
this.patchTransfers = MockMojaloopRequests.__patchTransfers;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
MockMojaloopRequests.__postParticipants = jest.fn(() => Promise.resolve());
|
|
47
|
-
MockMojaloopRequests.__getParties = jest.fn(() => Promise.resolve());
|
|
48
|
-
MockMojaloopRequests.__postTransactionRequests = jest.fn(() => Promise.resolve());
|
|
49
|
-
MockMojaloopRequests.__postQuotes = jest.fn(() => Promise.resolve());
|
|
50
|
-
MockMojaloopRequests.__putQuotes = jest.fn(() => Promise.resolve());
|
|
51
|
-
MockMojaloopRequests.__putQuotesError = jest.fn(() => Promise.resolve());
|
|
52
|
-
MockMojaloopRequests.__getAuthorizations = jest.fn(() => Promise.resolve());
|
|
53
|
-
MockMojaloopRequests.__putAuthorizations = jest.fn(() => Promise.resolve());
|
|
54
|
-
MockMojaloopRequests.__getTransfers = jest.fn(() => Promise.resolve());
|
|
55
|
-
MockMojaloopRequests.__putTransactionRequests = jest.fn(() => Promise.resolve());
|
|
56
|
-
MockMojaloopRequests.__postTransfers = jest.fn(() => Promise.resolve());
|
|
57
|
-
MockMojaloopRequests.__putTransfers = jest.fn(() => Promise.resolve());
|
|
58
|
-
MockMojaloopRequests.__putTransfersError = jest.fn(() => Promise.resolve());
|
|
59
|
-
MockMojaloopRequests.__getBulkQuotes = jest.fn(() => Promise.resolve());
|
|
60
|
-
MockMojaloopRequests.__postBulkQuotes = jest.fn(() => Promise.resolve());
|
|
61
|
-
MockMojaloopRequests.__putBulkQuotes = jest.fn(() => Promise.resolve());
|
|
62
|
-
MockMojaloopRequests.__putBulkQuotesError = jest.fn(() => Promise.resolve());
|
|
63
|
-
MockMojaloopRequests.__getBulkTransfers = jest.fn(() => Promise.resolve());
|
|
64
|
-
MockMojaloopRequests.__postBulkTransfers = jest.fn(() => Promise.resolve());
|
|
65
|
-
MockMojaloopRequests.__putBulkTransfers = jest.fn(() => Promise.resolve());
|
|
66
|
-
MockMojaloopRequests.__putBulkTransfersError = jest.fn(() => Promise.resolve());
|
|
67
|
-
MockMojaloopRequests.__patchTransfers = jest.fn(() => Promise.resolve());
|
|
68
|
-
|
|
69
|
-
class MockIlp {
|
|
70
|
-
constructor(config) {
|
|
71
|
-
assert(config.logger, 'Must supply a logger to Ilp constructor');
|
|
72
|
-
this.logger = config.logger;
|
|
73
|
-
this.logger.log('MockIlp constructed');
|
|
74
|
-
this.config = config;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
calculateFulfil(ilpPacket) {
|
|
78
|
-
this.logger.log(`Mock ILP not calculating fulfil from ilp packet ${ilpPacket}`);
|
|
79
|
-
return 'mockGeneratedFulfilment';
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
calculateConditionFromFulfil(fulfil) {
|
|
83
|
-
this.logger.log(`Mock ILP not calculating condition from fulfil ${fulfil}`);
|
|
84
|
-
return 'mockGeneratedCondition';
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
validateFulfil(fulfil, condition) {
|
|
88
|
-
this.logger.log(`Mock ILP not checking fulfil ${fulfil} against condition ${condition}`);
|
|
89
|
-
return true;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
getResponseIlp(...args) {
|
|
93
|
-
this.logger.log(`MockIlp.getResponseIlp called with args: ${util.inspect(args)}`);
|
|
94
|
-
|
|
95
|
-
return MockIlp.__response;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
getQuoteResponseIlp(...args) {
|
|
99
|
-
this.logger.log(`MockIlp.getQuoteResponseIlp called with args: ${util.inspect(args)}`);
|
|
100
|
-
|
|
101
|
-
return this.getResponseIlp(...args);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
getTransactionObject(...args) {
|
|
106
|
-
this.logger.log(`MockIlp.getTrasnactionObject called with args: ${util.inspect(args)}`);
|
|
107
|
-
|
|
108
|
-
return MockIlp.__transactionObject;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
MockIlp.__response = {
|
|
112
|
-
fulfilment: 'mockGeneratedFulfilment',
|
|
113
|
-
ilpPacket: 'mockBase64encodedIlpPacket',
|
|
114
|
-
condition: 'mockGeneratedCondition'
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
MockIlp.__transactionObject = {
|
|
118
|
-
transactionId: 'mockTransactionId'
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
class MockJwsValidator extends Jws.validator {
|
|
123
|
-
constructor(config) {
|
|
124
|
-
super(config);
|
|
125
|
-
MockJwsValidator.__validationKeys = config.validationKeys;
|
|
126
|
-
this.validate = MockJwsValidator.__validate;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
MockJwsValidator.__validate = jest.fn(() => true);
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
class MockJwsSigner {
|
|
133
|
-
constructor(config) {
|
|
134
|
-
assert(config.logger, 'Must supply a logger to JWS signer constructor');
|
|
135
|
-
this.config = config;
|
|
136
|
-
config.logger.log(`MockJwsSigner constructed with config: ${util.inspect(config)}`);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
module.exports = {
|
|
142
|
-
MojaloopRequests: MockMojaloopRequests,
|
|
143
|
-
Ilp: MockIlp,
|
|
144
|
-
Jws: {
|
|
145
|
-
validator: MockJwsValidator,
|
|
146
|
-
signer: MockJwsSigner
|
|
147
|
-
},
|
|
148
|
-
Errors,
|
|
149
|
-
WSO2Auth,
|
|
150
|
-
Logger,
|
|
151
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**************************************************************************
|
|
2
|
-
* (C) Copyright ModusBox Inc. 2019 - All rights reserved. *
|
|
3
|
-
* *
|
|
4
|
-
* This file is made available under the terms of the license agreement *
|
|
5
|
-
* specified in the corresponding source code repository. *
|
|
6
|
-
* *
|
|
7
|
-
* ORIGINAL AUTHOR: *
|
|
8
|
-
* Yevhen Kyriukha - yevhen.kyriukha@modusbox.com *
|
|
9
|
-
**************************************************************************/
|
|
10
|
-
|
|
11
|
-
const StateMachine = jest.requireActual('javascript-state-machine');
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class MockStateMachine extends StateMachine {
|
|
15
|
-
constructor(...args) {
|
|
16
|
-
super(...args);
|
|
17
|
-
MockStateMachine.__instance = this;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
module.exports = MockStateMachine;
|
package/test/__mocks__/redis.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/**************************************************************************
|
|
2
|
-
* (C) Copyright ModusBox Inc. 2020 - All rights reserved. *
|
|
3
|
-
* *
|
|
4
|
-
* This file is made available under the terms of the license agreement *
|
|
5
|
-
* specified in the corresponding source code repository. *
|
|
6
|
-
* *
|
|
7
|
-
* ORIGINAL AUTHOR: *
|
|
8
|
-
* Yevhen Kyriukha - yevhen.kyriukha@modusbox.com *
|
|
9
|
-
**************************************************************************/
|
|
10
|
-
|
|
11
|
-
const redisMock = require('redis-mock');
|
|
12
|
-
const { promisify } = require('util');
|
|
13
|
-
|
|
14
|
-
const { EventEmitter } = require('events');
|
|
15
|
-
|
|
16
|
-
const events = {};
|
|
17
|
-
|
|
18
|
-
// redis-mock currently ignores callback arguments, the following class fixes that
|
|
19
|
-
class RedisClient extends redisMock.RedisClient {
|
|
20
|
-
constructor(opts) {
|
|
21
|
-
super(opts);
|
|
22
|
-
events[opts.cacheUrl] = events[opts.cacheUrl] || new EventEmitter();
|
|
23
|
-
this.events = events[opts.cacheUrl];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
async subscribe(...args) {
|
|
27
|
-
this.events.on(...args);
|
|
28
|
-
// return promisify(super.subscribe.bind(this))(...args);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async unsubscribe(channel) {
|
|
32
|
-
this.events.removeAllListeners(channel);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async publish(...args) {
|
|
36
|
-
process.nextTick(() => this.events.emit(...args));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
set(...args) {
|
|
40
|
-
return promisify(super.set.bind(this))(...args);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
get(...args) {
|
|
44
|
-
return promisify(super.get.bind(this))(...args);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
keys(...args) {
|
|
48
|
-
return promisify(super.keys.bind(this))(...args);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
end() {
|
|
52
|
-
this.events.removeAllListeners();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
connect() {}
|
|
56
|
-
|
|
57
|
-
async disconnect() {
|
|
58
|
-
return this.end();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
async quit() {
|
|
62
|
-
return this.end();
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
sAdd(...args) {
|
|
66
|
-
return promisify(super.sadd.bind(this))(...args);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
sMembers(...args) {
|
|
70
|
-
return promisify(super.smembers.bind(this))(...args);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
configSet() {}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
module.exports = {
|
|
77
|
-
createClient: (opts) => new RedisClient(opts),
|
|
78
|
-
};
|
package/test/__mocks__/uuidv4.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**************************************************************************
|
|
2
|
-
* (C) Copyright ModusBox Inc. 2019 - All rights reserved. *
|
|
3
|
-
* *
|
|
4
|
-
* This file is made available under the terms of the license agreement *
|
|
5
|
-
* specified in the corresponding source code repository. *
|
|
6
|
-
* *
|
|
7
|
-
* ORIGINAL AUTHOR: *
|
|
8
|
-
* Yevhen Kyriukha - yevhen.kyriukha@modusbox.com *
|
|
9
|
-
**************************************************************************/
|
|
10
|
-
|
|
11
|
-
let id = 0;
|
|
12
|
-
|
|
13
|
-
module.exports = {
|
|
14
|
-
__reset: () => { id = 0; },
|
|
15
|
-
uuid: () => `00000000-0000-1000-8000-${(++id).toString().padStart(12, '0')}`,
|
|
16
|
-
};
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
# Port number that the inbound (Mojaloop API) HTTP server will listen on
|
|
2
|
-
INBOUND_LISTEN_PORT=4000
|
|
3
|
-
|
|
4
|
-
# Port number that the outbound (simplified DFSP outbound API) HTTP server will listen on
|
|
5
|
-
OUTBOUND_LISTEN_PORT=4001
|
|
6
|
-
|
|
7
|
-
# Enable mutual TLS authentication. Useful when not running in a secure
|
|
8
|
-
# environment, i.e. when you're running it locally against your own implementation.
|
|
9
|
-
INBOUND_MUTUAL_TLS_ENABLED=false
|
|
10
|
-
OUTBOUND_MUTUAL_TLS_ENABLED=false
|
|
11
|
-
|
|
12
|
-
# Enable verification or incoming JWS signatures
|
|
13
|
-
# Note that signatures will be required on incoming messages
|
|
14
|
-
# and will be validated against a public key.
|
|
15
|
-
VALIDATE_INBOUND_JWS=false
|
|
16
|
-
|
|
17
|
-
# applicable only if VALIDATE_INBOUND_JWS is "true"
|
|
18
|
-
# allows disabling of validation on incoming PUT /parties/{idType}/{idValue} requests
|
|
19
|
-
VALIDATE_INBOUND_PUT_PARTIES_JWS=false
|
|
20
|
-
|
|
21
|
-
# Enable signing of outgoing requests
|
|
22
|
-
JWS_SIGN=false
|
|
23
|
-
|
|
24
|
-
# applicable only if JWS_SIGN is "true"
|
|
25
|
-
# allows disabling of signing on outgoing PUT /parties/{idType}/{idValue} requests
|
|
26
|
-
JWS_SIGN_PUT_PARTIES=false
|
|
27
|
-
|
|
28
|
-
# Path to JWS signing key (private key of THIS DFSP)
|
|
29
|
-
JWS_SIGNING_KEY_PATH=secrets/jwsSigningKey.key
|
|
30
|
-
JWS_VERIFICATION_KEYS_DIRECTORY=secrets/jwsVerificationKeys
|
|
31
|
-
|
|
32
|
-
# Location of certs and key required for TLS
|
|
33
|
-
# IN_CA_CERT_PATH=./secrets/cacert.pem
|
|
34
|
-
# IN_SERVER_CERT_PATH=./secrets/servercert.pem
|
|
35
|
-
# IN_SERVER_KEY_PATH=./secrets/serverkey.pem
|
|
36
|
-
|
|
37
|
-
# OUT_CA_CERT_PATH=./secrets/cacert.pem
|
|
38
|
-
# OUT_CLIENT_CERT_PATH=./secrets/servercert.pem
|
|
39
|
-
# OUT_CLIENT_KEY_PATH=./secrets/serverkey.pem
|
|
40
|
-
|
|
41
|
-
# The number of space characters by which to indent pretty-printed logs. If set to zero, log events
|
|
42
|
-
# will each be printed on a single line.
|
|
43
|
-
LOG_INDENT=0
|
|
44
|
-
|
|
45
|
-
# REDIS CACHE CONNECTION
|
|
46
|
-
CACHE_URL=redis://redis:6379
|
|
47
|
-
CACHE_SHOULD_EXPIRE=false
|
|
48
|
-
CACHE_EXPIRY_SECONDS=3600
|
|
49
|
-
|
|
50
|
-
# SWITCH ENDPOINT
|
|
51
|
-
# The option 'PEER_ENDPOINT' has no effect if the remaining options 'ALS_ENDPOINT', 'QUOTES_ENDPOINT',
|
|
52
|
-
# 'BULK_QUOTES_ENDPOINT', 'TRANSFERS_ENDPOINT', 'BULK_TRANSFERS_ENDPOINT', 'TRANSACTION_REQUESTS_ENDPOINT' are specified.
|
|
53
|
-
PEER_ENDPOINT=172.17.0.3:4000
|
|
54
|
-
#ALS_ENDPOINT=account-lookup-service.local
|
|
55
|
-
#QUOTES_ENDPOINT=quoting-service.local
|
|
56
|
-
#TRANSFERS_ENDPOINT=ml-api-adapter.local
|
|
57
|
-
#BULK_TRANSFERS_ENDPOINT=bulk-api-adapter.local
|
|
58
|
-
#TRANSACTION_REQUESTS_ENDPOINT=transaction-requests-service.local
|
|
59
|
-
|
|
60
|
-
# BACKEND ENDPOINT
|
|
61
|
-
BACKEND_ENDPOINT=172.17.0.5:4000
|
|
62
|
-
|
|
63
|
-
# FSPID of this DFSP
|
|
64
|
-
DFSP_ID=mojaloop-sdk
|
|
65
|
-
|
|
66
|
-
# Secret used for generation and verification of secure ILP
|
|
67
|
-
ILP_SECRET=Quaixohyaesahju3thivuiChai5cahng
|
|
68
|
-
|
|
69
|
-
# expiry period in seconds for quote and transfers issued by the SDK
|
|
70
|
-
EXPIRY_SECONDS=60
|
|
71
|
-
|
|
72
|
-
# if set to false the SDK will not automatically accept all returned quotes
|
|
73
|
-
# but will halt the transfer after a quote response is received. A further
|
|
74
|
-
# confirmation call will be required to complete the final transfer stage.
|
|
75
|
-
AUTO_ACCEPT_QUOTES=false
|
|
76
|
-
|
|
77
|
-
# if set to false the SDK will not automatically accept a resolved party
|
|
78
|
-
# but will halt the transer after a party lookup response is received. A further
|
|
79
|
-
# cnofirmation call will be required to progress the transfer to quotes state.
|
|
80
|
-
AUTO_ACCEPT_PARTY=false
|
|
81
|
-
|
|
82
|
-
# when set to true, when sending money via the outbound API, the SDK will use the value
|
|
83
|
-
# of FSPIOP-Source header from the received quote response as the payeeFsp value in the
|
|
84
|
-
# transfer prepare request body instead of the value received in the payee party lookup.
|
|
85
|
-
# This behaviour should be enabled when the SDK user DFSP is in a forex enabled switch
|
|
86
|
-
# ecosystem and expects quotes and transfers to be rerouted by the switch to forex
|
|
87
|
-
# entities i.e. forex providing DFSPs. Please see the SDK documentation and switch
|
|
88
|
-
# operator documentation for more information on forex use cases.
|
|
89
|
-
USE_QUOTE_SOURCE_FSP_AS_TRANSFER_PAYEE_FSP=false
|
|
90
|
-
|
|
91
|
-
# set to true to validate ILP, otherwise false to ignore ILP
|
|
92
|
-
CHECK_ILP=true
|
|
93
|
-
|
|
94
|
-
# set to true to enable test features such as request cacheing and retrieval endpoints
|
|
95
|
-
ENABLE_TEST_FEATURES=false
|
|
96
|
-
|
|
97
|
-
# set to true to mock WSO2 oauth2 token endpoint
|
|
98
|
-
ENABLE_OAUTH_TOKEN_ENDPOINT=false
|
|
99
|
-
OAUTH_TOKEN_ENDPOINT_CLIENT_KEY=test-client-key
|
|
100
|
-
OAUTH_TOKEN_ENDPOINT_CLIENT_SECRET=test-client-secret
|
|
101
|
-
OAUTH_TOKEN_ENDPOINT_LISTEN_PORT=6000
|
|
102
|
-
|
|
103
|
-
# WSO2 Bearer Token specific to golden-fsp instance and environment
|
|
104
|
-
WSO2_BEARER_TOKEN=7718fa9b-be13-3fe7-87f0-a12cf1628168
|
|
105
|
-
|
|
106
|
-
# OAuth2 data used to obtain WSO2 bearer token
|
|
107
|
-
OAUTH_TOKEN_ENDPOINT=
|
|
108
|
-
OAUTH_CLIENT_KEY=
|
|
109
|
-
OAUTH_CLIENT_SECRET=
|
|
110
|
-
OAUTH_REFRESH_SECONDS=3600
|
|
111
|
-
|
|
112
|
-
# Set to true to respect expirity timestamps
|
|
113
|
-
REJECT_EXPIRED_QUOTE_RESPONSES=false
|
|
114
|
-
REJECT_TRANSFERS_ON_EXPIRED_QUOTES=false
|
|
115
|
-
REJECT_EXPIRED_TRANSFER_FULFILS=false
|
|
116
|
-
|
|
117
|
-
# Timeout for GET/POST/DELETE - PUT flow processing
|
|
118
|
-
REQUEST_PROCESSING_TIMEOUT_SECONDS=4
|
|
119
|
-
|
|
120
|
-
# Common Account Lookup System (ALS)
|
|
121
|
-
ALS_ENDPOINT=ml-testing-toolkit:5000
|
|
122
|
-
|
|
123
|
-
# QUOTES_ENDPOINT
|
|
124
|
-
QUOTES_ENDPOINT=ml-testing-toolkit:5000
|
|
125
|
-
|
|
126
|
-
# TRANSFERS_ENDPOINT
|
|
127
|
-
TRANSFERS_ENDPOINT=ml-testing-toolkit:5000
|
|
128
|
-
|
|
129
|
-
# To allow transfer without a previous quote request, set this value to true.
|
|
130
|
-
# The incoming transfer request should consists of an ILP packet and a matching condition in this case.
|
|
131
|
-
# The fulfilment will be generated from the provided ILP packet, and must hash to the provided condition.
|
|
132
|
-
ALLOW_TRANSFER_WITHOUT_QUOTE=false
|
|
133
|
-
|
|
134
|
-
# To enable request for notification on fulfiled transfer
|
|
135
|
-
RESERVE_NOTIFICATION=true
|
|
136
|
-
# resources API versions should be string in format: "resourceOneName=1.0,resourceTwoName=1.1"
|
|
137
|
-
RESOURCE_VERSIONS="transfers=1.1,participants=1.1"
|
|
138
|
-
|
|
139
|
-
# Management API websocket connection settings.
|
|
140
|
-
# The Management API uses this for exchanging connector management messages.
|
|
141
|
-
MGMT_API_WS_URL=127.0.0.1
|
|
142
|
-
MGMT_API_WS_PORT=4005
|
|
143
|
-
|
|
144
|
-
# Set to true to enable the use of PM4ML-related services e.g MCM, Management API service
|
|
145
|
-
# when running the scheme-adapter as a mojaloop connector component within Payment Manager for Mojaloop.
|
|
146
|
-
PM4ML_ENABLED=false
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"amount": {
|
|
3
|
-
"amount": "100",
|
|
4
|
-
"currency": "USD"
|
|
5
|
-
},
|
|
6
|
-
"amountType": "SEND",
|
|
7
|
-
"expiration": "2020-01-20T11:31:49.325Z",
|
|
8
|
-
"extensionList": {
|
|
9
|
-
"extension": [
|
|
10
|
-
{
|
|
11
|
-
"key": "qreqkey1",
|
|
12
|
-
"value": "qreqvalue1"
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"key": "qreqkey2",
|
|
16
|
-
"value": "qreqvalue2"
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
},
|
|
20
|
-
"note": "test payment",
|
|
21
|
-
"payee": {
|
|
22
|
-
"partyIdInfo": {
|
|
23
|
-
"fspId": "sim",
|
|
24
|
-
"partyIdType": "PERSONAL_ID",
|
|
25
|
-
"partyIdentifier": "987654321",
|
|
26
|
-
"partySubIdOrType": "PASSPORT"
|
|
27
|
-
},
|
|
28
|
-
"personalInfo": {
|
|
29
|
-
"complexName": {
|
|
30
|
-
"firstName": "John",
|
|
31
|
-
"lastName": "Doe",
|
|
32
|
-
"middleName": "Someone"
|
|
33
|
-
},
|
|
34
|
-
"dateOfBirth": "1980-01-01"
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
"payer": {
|
|
38
|
-
"name": "John Doe",
|
|
39
|
-
"partyIdInfo": {
|
|
40
|
-
"fspId": "mojaloop-sdk",
|
|
41
|
-
"partyIdType": "MSISDN",
|
|
42
|
-
"partyIdentifier": "123456789"
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
"quoteId": "00000000-0000-1000-8000-000000000002",
|
|
46
|
-
"transactionId": "00000000-0000-1000-8000-000000000001",
|
|
47
|
-
"transactionType": {
|
|
48
|
-
"scenario": "TRANSFER",
|
|
49
|
-
"initiator": "PAYEE",
|
|
50
|
-
"initiatorType": "CONSUMER"
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"transferId": "00000000-0000-1000-8000-000000000005",
|
|
3
|
-
"payeeFsp": "sim",
|
|
4
|
-
"payerFsp": "mojaloop-sdk",
|
|
5
|
-
"amount": {
|
|
6
|
-
"amount": "100",
|
|
7
|
-
"currency": "USD"
|
|
8
|
-
},
|
|
9
|
-
"ilpPacket": "AYIBgQAAAAAAAASwNGxldmVsb25lLmRmc3AxLm1lci45T2RTOF81MDdqUUZERmZlakgyOVc4bXFmNEpLMHlGTFGCAUBQU0svMS4wCk5vbmNlOiB1SXlweUYzY3pYSXBFdzVVc05TYWh3CkVuY3J5cHRpb246IG5vbmUKUGF5bWVudC1JZDogMTMyMzZhM2ItOGZhOC00MTYzLTg0NDctNGMzZWQzZGE5OGE3CgpDb250ZW50LUxlbmd0aDogMTM1CkNvbnRlbnQtVHlwZTogYXBwbGljYXRpb24vanNvbgpTZW5kZXItSWRlbnRpZmllcjogOTI4MDYzOTEKCiJ7XCJmZWVcIjowLFwidHJhbnNmZXJDb2RlXCI6XCJpbnZvaWNlXCIsXCJkZWJpdE5hbWVcIjpcImFsaWNlIGNvb3BlclwiLFwiY3JlZGl0TmFtZVwiOlwibWVyIGNoYW50XCIsXCJkZWJpdElkZW50aWZpZXJcIjpcIjkyODA2MzkxXCJ9IgA",
|
|
10
|
-
"condition": "f5sqb7tBTWPd5Y8BDFdMm9BJR_MNI4isf8p8n4D5pHA",
|
|
11
|
-
"expiration": "2020-01-20T11:31:49.325Z",
|
|
12
|
-
"extensionList": {
|
|
13
|
-
"extension": [
|
|
14
|
-
{
|
|
15
|
-
"key": "qreqkey1",
|
|
16
|
-
"value": "qreqvalue1"
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
"key": "qreqkey2",
|
|
20
|
-
"value": "qreqvalue2"
|
|
21
|
-
}
|
|
22
|
-
]
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const axios = require('axios');
|
|
4
|
-
const env = require('../../testEnv');
|
|
5
|
-
const { SDKStateEnum } = require('../../../../src/lib/model/common');
|
|
6
|
-
|
|
7
|
-
jest.dontMock('redis');
|
|
8
|
-
|
|
9
|
-
describe('/parties', () => {
|
|
10
|
-
|
|
11
|
-
test('get - happy flow', async () => {
|
|
12
|
-
const getPartiesURI = `${env.OutboundHostURI}/parties/MSISDN/1234567890`;
|
|
13
|
-
const res = await axios.get(getPartiesURI);
|
|
14
|
-
|
|
15
|
-
expect(res.status).toEqual(200);
|
|
16
|
-
expect(res.data.currentState).toEqual(SDKStateEnum.COMPLETED);
|
|
17
|
-
expect(typeof res.data.party).toEqual('object');
|
|
18
|
-
expect(typeof res.data.party.body).toEqual('object');
|
|
19
|
-
expect(typeof res.data.party.headers).toEqual('object');
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test('get - timeout', (done) => {
|
|
23
|
-
const getPartiesURI = `${env.OutboundHostURI}/parties/MSISDN/0987654321`;
|
|
24
|
-
axios.get(getPartiesURI).catch(err => {
|
|
25
|
-
expect(err.response.status).toEqual(500);
|
|
26
|
-
expect(err.response.data.message).toEqual('Timeout');
|
|
27
|
-
done();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
});
|
|
31
|
-
});
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const axios = require('axios');
|
|
4
|
-
const { uuid } = require('uuidv4');
|
|
5
|
-
const env = require('../../testEnv');
|
|
6
|
-
const quotesPostRequest = require('./data/quotesPostRequest.json');
|
|
7
|
-
const { SDKStateEnum } = require('../../../../src/lib/model/common');
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
jest.dontMock('redis');
|
|
11
|
-
|
|
12
|
-
describe('/quotes', () => {
|
|
13
|
-
|
|
14
|
-
test('post - happy flow', async () => {
|
|
15
|
-
const postQuotesURI = `${env.OutboundHostURI}/quotes`;
|
|
16
|
-
const quoteId = uuid();
|
|
17
|
-
const res = await axios({
|
|
18
|
-
method: 'POST',
|
|
19
|
-
url: postQuotesURI,
|
|
20
|
-
data: {
|
|
21
|
-
fspId: 'switch',
|
|
22
|
-
quotesPostRequest: {
|
|
23
|
-
...quotesPostRequest,
|
|
24
|
-
quoteId
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
headers: {
|
|
28
|
-
'access-control-allow-origin': '*'
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
expect(res.status).toEqual(200);
|
|
33
|
-
expect(res.data.currentState).toEqual(SDKStateEnum.COMPLETED);
|
|
34
|
-
expect(typeof res.data.quotes).toEqual('object');
|
|
35
|
-
expect(typeof res.data.quotes.body).toEqual('object');
|
|
36
|
-
expect(typeof res.data.quotes.headers).toEqual('object');
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
test('post - timeout', (done) => {
|
|
40
|
-
const postQuotesURI = `${env.OutboundHostURI}/quotes`;
|
|
41
|
-
const quoteId = uuid();
|
|
42
|
-
axios({
|
|
43
|
-
method: 'POST',
|
|
44
|
-
url: postQuotesURI,
|
|
45
|
-
data: {
|
|
46
|
-
fspId: 'timeout-fsp-id',
|
|
47
|
-
quotesPostRequest: {
|
|
48
|
-
...quotesPostRequest,
|
|
49
|
-
quoteId
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
headers: {
|
|
53
|
-
'access-control-allow-origin': '*'
|
|
54
|
-
}
|
|
55
|
-
}).catch(err => {
|
|
56
|
-
expect(err.response.status).toEqual(500);
|
|
57
|
-
expect(err.response.data.message).toEqual('Timeout');
|
|
58
|
-
done();
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
});
|