@mojaloop/sdk-scheme-adapter 16.0.0 → 17.0.2-snapshot.10

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.
Files changed (43) hide show
  1. package/.circleci/config.yml +463 -182
  2. package/CHANGELOG.md +24 -0
  3. package/Dockerfile +12 -5
  4. package/audit-resolve.json +30 -91
  5. package/docker-compose.yml +4 -2
  6. package/package.json +21 -19
  7. package/src/InboundServer/index.js +4 -2
  8. package/src/InboundServer/middlewares.js +12 -4
  9. package/src/OutboundServer/index.js +3 -2
  10. package/src/OutboundServer/middlewares.js +6 -2
  11. package/src/TestServer/index.js +4 -2
  12. package/src/index.js +0 -2
  13. package/src/lib/metrics.js +0 -2
  14. package/src/lib/model/AccountsModel.js +4 -7
  15. package/src/lib/model/Async2SyncModel.js +4 -3
  16. package/src/lib/model/InboundTransfersModel.js +16 -14
  17. package/src/lib/model/OutboundBulkQuotesModel.js +4 -7
  18. package/src/lib/model/OutboundBulkTransfersModel.js +4 -7
  19. package/src/lib/model/OutboundRequestToPayModel.js +5 -10
  20. package/src/lib/model/OutboundRequestToPayTransferModel.js +6 -12
  21. package/src/lib/model/OutboundTransfersModel.js +10 -9
  22. package/src/lib/model/common/BackendError.js +1 -13
  23. package/src/lib/model/common/Enums.js +30 -0
  24. package/src/lib/model/common/index.js +3 -2
  25. package/src/lib/router.js +3 -1
  26. package/src/lib/validate.js +10 -1
  27. package/test/config/integration.env +2 -2
  28. package/test/integration/lib/Outbound/parties.test.js +2 -1
  29. package/test/integration/lib/Outbound/quotes.test.js +3 -1
  30. package/test/integration/lib/Outbound/simpleTransfers.test.js +2 -1
  31. package/test/unit/inboundApi/handlers.test.js +3 -1
  32. package/test/unit/lib/model/AccountsModel.test.js +2 -1
  33. package/test/unit/lib/model/InboundTransfersModel.test.js +10 -6
  34. package/test/unit/lib/model/OutboundBulkQuotesModel.test.js +5 -3
  35. package/test/unit/lib/model/OutboundBulkTransfersModel.test.js +4 -3
  36. package/test/unit/lib/model/OutboundRequestToPayModel.test.js +3 -2
  37. package/test/unit/lib/model/OutboundRequestToPayTransferModel.test.js +4 -3
  38. package/test/unit/lib/model/OutboundTransfersModel.test.js +37 -34
  39. package/test/unit/lib/model/PartiesModel.test.js +2 -1
  40. package/test/unit/lib/model/QuotesModel.test.js +2 -1
  41. package/test/unit/lib/model/TransfersModel.test.js +2 -1
  42. package/test/unit/lib/model/data/getBulkTransfersBackendResponse.json +1 -1
  43. package/test/unit/lib/model/data/getBulkTransfersMojaloopResponse.json +1 -1
@@ -22,7 +22,9 @@ const {
22
22
  Errors,
23
23
  } = require('@mojaloop/sdk-standard-components');
24
24
  const shared = require('./lib/shared');
25
- const { TransferStateEnum } = require('./common');
25
+ const { SDKStateEnum } = require('./common');
26
+ const FSPIOPTransferStateEnum = require('@mojaloop/central-services-shared').Enum.Transfers.TransferState;
27
+ const FSPIOPBulkTransferStateEnum = require('@mojaloop/central-services-shared').Enum.Transfers.BulkTransferState;
26
28
 
27
29
  /**
28
30
  * Models the operations required for performing inbound transfers
@@ -74,7 +76,7 @@ class InboundTransfersModel {
74
76
 
75
77
  updateStateWithError(err) {
76
78
  this.data.lastError = err;
77
- this.data.currentState = TransferStateEnum.ERROR_OCCURRED;
79
+ this.data.currentState = SDKStateEnum.ERROR_OCCURRED;
78
80
  return this._save();
79
81
  }
80
82
 
@@ -188,7 +190,7 @@ class InboundTransfersModel {
188
190
  headers: request.headers,
189
191
  body: request.body
190
192
  },
191
- currentState: TransferStateEnum.QUOTE_REQUEST_RECEIVED,
193
+ currentState: SDKStateEnum.QUOTE_REQUEST_RECEIVED,
192
194
  initiatedTimestamp: new Date().toISOString(),
193
195
  };
194
196
 
@@ -237,7 +239,7 @@ class InboundTransfersModel {
237
239
  headers: res.originalRequest.headers,
238
240
  body: res.originalRequest.body,
239
241
  };
240
- this.data.currentState = TransferStateEnum.WAITING_FOR_QUOTE_ACCEPTANCE;
242
+ this.data.currentState = SDKStateEnum.WAITING_FOR_QUOTE_ACCEPTANCE;
241
243
  await this._save();
242
244
  return res;
243
245
  }
@@ -342,7 +344,7 @@ class InboundTransfersModel {
342
344
 
343
345
  // persist our state so we have a record if we crash during processing the prepare
344
346
  this.data.prepare = request;
345
- this.data.currentState = TransferStateEnum.PREPARE_RECEIVED;
347
+ this.data.currentState = SDKStateEnum.PREPARE_RECEIVED;
346
348
  await this._save();
347
349
 
348
350
  // Calculate or retrieve fulfilment and condition
@@ -390,7 +392,7 @@ class InboundTransfersModel {
390
392
  // create a mojaloop transfer fulfil response
391
393
  const mojaloopResponse = {
392
394
  completedTimestamp: response.completedTimestamp || new Date(),
393
- transferState: response.transferState || (this._reserveNotification ? TransferStateEnum.RESERVED : TransferStateEnum.COMPLETED),
395
+ transferState: response.transferState || (this._reserveNotification ? FSPIOPTransferStateEnum.RESERVED : FSPIOPTransferStateEnum.COMMITTED),
394
396
  fulfilment: response.fulfilment || fulfilment,
395
397
  ...response.extensionList && {
396
398
  extensionList: {
@@ -406,7 +408,7 @@ class InboundTransfersModel {
406
408
  headers: res.originalRequest.headers,
407
409
  body: res.originalRequest.body,
408
410
  };
409
- this.data.currentState = response.transferState || (this._reserveNotification ? TransferStateEnum.RESERVED : TransferStateEnum.COMPLETED);
411
+ this.data.currentState = response.transferState || (this._reserveNotification ? SDKStateEnum.RESERVED : SDKStateEnum.COMPLETED);
410
412
  await this._save();
411
413
  return res;
412
414
  } catch(err) {
@@ -679,7 +681,7 @@ class InboundTransfersModel {
679
681
  // create a mojaloop transfer fulfil response
680
682
  const mojaloopResponse = {
681
683
  completedTimestamp: new Date(),
682
- bulkTransferState: 'COMMITTED',
684
+ bulkTransferState: FSPIOPBulkTransferStateEnum.COMMITTED,
683
685
  };
684
686
 
685
687
  if (response.individualTransferResults && response.individualTransferResults.length) {
@@ -784,18 +786,18 @@ class InboundTransfersModel {
784
786
  // tag the final notification body on to the state
785
787
  this.data.finalNotification = body;
786
788
 
787
- if(body.transferState === 'COMMITTED') {
789
+ if(body.transferState === FSPIOPTransferStateEnum.COMMITTED) {
788
790
  // if the transfer was successful in the switch, set the overall transfer state to COMPLETED
789
- this.data.currentState = TransferStateEnum.COMPLETED;
791
+ this.data.currentState = SDKStateEnum.COMPLETED;
790
792
  }
791
- else if(body.transferState === 'ABORTED') {
793
+ else if(body.transferState === FSPIOPTransferStateEnum.ABORTED) {
792
794
  // if the transfer was ABORTED in the switch, set the overall transfer state to ABORTED
793
- this.data.currentState = TransferStateEnum.ABORTED;
795
+ this.data.currentState = SDKStateEnum.ABORTED;
794
796
  }
795
797
  else {
796
798
  // if the final notification has anything other than COMMITTED as the final state, set an error
797
799
  // in the transfer state.
798
- this.data.currentState = TransferStateEnum.ERROR_OCCURED;
800
+ this.data.currentState = SDKStateEnum.ERROR_OCCURED;
799
801
  this.data.lastError = 'Final notification state not COMMITTED';
800
802
  }
801
803
 
@@ -845,7 +847,7 @@ class InboundTransfersModel {
845
847
  originalError: err.stack || util.inspect(err),
846
848
  mojaloopError: mojaloopError,
847
849
  };
848
- this.data.currentState = TransferStateEnum.ERROR_OCCURRED;
850
+ this.data.currentState = SDKStateEnum.ERROR_OCCURRED;
849
851
  await this._save();
850
852
  }
851
853
  return mojaloopError;
@@ -17,10 +17,7 @@ const { MojaloopRequests } = require('@mojaloop/sdk-standard-components');
17
17
  const shared = require('./lib/shared');
18
18
  const { BackendError } = require('./common');
19
19
 
20
- const stateEnum = {
21
- 'ERROR_OCCURRED': 'ERROR_OCCURRED',
22
- 'COMPLETED': 'COMPLETED',
23
- };
20
+ const { SDKStateEnum } = require('./common');
24
21
 
25
22
 
26
23
  /**
@@ -381,16 +378,16 @@ class OutboundBulkQuotesModel {
381
378
 
382
379
  switch(this.data.currentState) {
383
380
  case 'succeeded':
384
- resp.currentState = stateEnum.COMPLETED;
381
+ resp.currentState = SDKStateEnum.COMPLETED;
385
382
  break;
386
383
 
387
384
  case 'errored':
388
- resp.currentState = stateEnum.ERROR_OCCURRED;
385
+ resp.currentState = SDKStateEnum.ERROR_OCCURRED;
389
386
  break;
390
387
 
391
388
  default:
392
389
  this._logger.log(`Bulk quote model response being returned from an unexpected state: ${this.data.currentState}. Returning ERROR_OCCURRED state`);
393
- resp.currentState = stateEnum.ERROR_OCCURRED;
390
+ resp.currentState = SDKStateEnum.ERROR_OCCURRED;
394
391
  break;
395
392
  }
396
393
 
@@ -16,10 +16,7 @@ const StateMachine = require('javascript-state-machine');
16
16
  const { MojaloopRequests } = require('@mojaloop/sdk-standard-components');
17
17
  const { BackendError } = require('./common');
18
18
 
19
- const stateEnum = {
20
- 'ERROR_OCCURRED': 'ERROR_OCCURRED',
21
- 'COMPLETED': 'COMPLETED',
22
- };
19
+ const { SDKStateEnum } = require('./common');
23
20
 
24
21
  /**
25
22
  * Models the state machine and operations required for performing an outbound bulk transfer
@@ -373,16 +370,16 @@ class OutboundBulkTransfersModel {
373
370
 
374
371
  switch(this.data.currentState) {
375
372
  case 'succeeded':
376
- resp.currentState = stateEnum.COMPLETED;
373
+ resp.currentState = SDKStateEnum.COMPLETED;
377
374
  break;
378
375
 
379
376
  case 'errored':
380
- resp.currentState = stateEnum.ERROR_OCCURRED;
377
+ resp.currentState = SDKStateEnum.ERROR_OCCURRED;
381
378
  break;
382
379
 
383
380
  default:
384
381
  this._logger.log(`Bulk transfer model response being returned from an unexpected state: ${this.data.currentState}. Returning ERROR_OCCURRED state`);
385
- resp.currentState = stateEnum.ERROR_OCCURRED;
382
+ resp.currentState = SDKStateEnum.ERROR_OCCURRED;
386
383
  break;
387
384
  }
388
385
 
@@ -17,12 +17,7 @@ const { MojaloopRequests } = require('@mojaloop/sdk-standard-components');
17
17
  const { BackendError } = require('./common');
18
18
  const PartiesModel = require('./PartiesModel');
19
19
 
20
- const transferStateEnum = {
21
- 'WAITING_FOR_PARTY_ACCEPTANCE': 'WAITING_FOR_PARTY_ACCEPTANCE',
22
- 'WAITING_FOR_QUOTE_ACCEPTANCE': 'WAITING_FOR_QUOTE_ACCEPTANCE',
23
- 'ERROR_OCCURRED': 'ERROR_OCCURRED',
24
- 'COMPLETED': 'COMPLETED',
25
- };
20
+ const { SDKStateEnum } = require('./common');
26
21
 
27
22
  class OutboundRequestToPayModel {
28
23
 
@@ -480,20 +475,20 @@ class OutboundRequestToPayModel {
480
475
 
481
476
  switch(this.data.currentState) {
482
477
  case 'payeeResolved':
483
- resp.currentState = transferStateEnum.WAITING_FOR_PARTY_ACCEPTANCE;
478
+ resp.currentState = SDKStateEnum.WAITING_FOR_PARTY_ACCEPTANCE;
484
479
  break;
485
480
 
486
481
  case 'succeeded':
487
- resp.currentState = transferStateEnum.COMPLETED;
482
+ resp.currentState = SDKStateEnum.COMPLETED;
488
483
  break;
489
484
 
490
485
  case 'errored':
491
- resp.currentState = transferStateEnum.ERROR_OCCURRED;
486
+ resp.currentState = SDKStateEnum.ERROR_OCCURRED;
492
487
  break;
493
488
 
494
489
  default:
495
490
  this._logger.log(`Transaction Request model response being returned from an unexpected state: ${this.data.currentState}. Returning ERROR_OCCURRED state`);
496
- resp.currentState = transferStateEnum.ERROR_OCCURRED;
491
+ resp.currentState = SDKStateEnum.ERROR_OCCURRED;
497
492
  break;
498
493
  }
499
494
 
@@ -18,13 +18,7 @@ const shared = require('./lib/shared');
18
18
  const { BackendError } = require('./common');
19
19
  const PartiesModel = require('./PartiesModel');
20
20
 
21
- const requestToPayTransferStateEnum = {
22
- 'WAITING_FOR_QUOTE_ACCEPTANCE': 'WAITING_FOR_QUOTE_ACCEPTANCE',
23
- 'WAITING_FOR_OTP_ACCEPTANCE': 'WAITING_FOR_OTP_ACCEPTANCE',
24
- 'ERROR_OCCURRED': 'ERROR_OCCURRED',
25
- 'COMPLETED': 'COMPLETED',
26
- };
27
-
21
+ const { SDKStateEnum } = require('./common');
28
22
 
29
23
  /**
30
24
  * Models the state machine and operations required for performing an outbound transfer
@@ -826,24 +820,24 @@ class OutboundRequestToPayTransferModel {
826
820
 
827
821
  switch(this.data.currentState) {
828
822
  case 'quoteReceived':
829
- resp.currentState = requestToPayTransferStateEnum.WAITING_FOR_QUOTE_ACCEPTANCE;
823
+ resp.currentState = SDKStateEnum.WAITING_FOR_QUOTE_ACCEPTANCE;
830
824
  break;
831
825
 
832
826
  case 'otpReceived':
833
- resp.currentState = requestToPayTransferStateEnum.WAITING_FOR_OTP_ACCEPTANCE;
827
+ resp.currentState = SDKStateEnum.WAITING_FOR_OTP_ACCEPTANCE;
834
828
  break;
835
829
 
836
830
  case 'succeeded':
837
- resp.currentState = requestToPayTransferStateEnum.COMPLETED;
831
+ resp.currentState = SDKStateEnum.COMPLETED;
838
832
  break;
839
833
 
840
834
  case 'errored':
841
- resp.currentState = requestToPayTransferStateEnum.ERROR_OCCURRED;
835
+ resp.currentState = SDKStateEnum.ERROR_OCCURRED;
842
836
  break;
843
837
 
844
838
  default:
845
839
  this._logger.log(`Transfer model response being returned from an unexpected state: ${this.data.currentState}. Returning ERROR_OCCURRED state`);
846
- resp.currentState = requestToPayTransferStateEnum.ERROR_OCCURRED;
840
+ resp.currentState = SDKStateEnum.ERROR_OCCURRED;
847
841
  break;
848
842
  }
849
843
 
@@ -15,7 +15,8 @@ const { uuid } = require('uuidv4');
15
15
  const StateMachine = require('javascript-state-machine');
16
16
  const { Ilp, MojaloopRequests } = require('@mojaloop/sdk-standard-components');
17
17
  const shared = require('./lib/shared');
18
- const { BackendError, TransferStateEnum } = require('./common');
18
+ const { BackendError, SDKStateEnum } = require('./common');
19
+ const FSPIOPTransferStateEnum = require('@mojaloop/central-services-shared').Enum.Transfers.TransferState;
19
20
  const PartiesModel = require('./PartiesModel');
20
21
 
21
22
  /**
@@ -685,7 +686,7 @@ class OutboundTransfersModel {
685
686
  if(this._checkIlp && !this._ilp.validateFulfil(fulfil.body.fulfilment, this.data.quoteResponse.body.condition)) {
686
687
  throw new Error('Invalid fulfilment received from peer DFSP.');
687
688
  }
688
- if(this._sendFinalNotificationIfRequested && fulfil.body.transferState === 'RESERVED') {
689
+ if(this._sendFinalNotificationIfRequested && fulfil.body.transferState === FSPIOPTransferStateEnum.RESERVED) {
689
690
  // we need to send a PATCH notification back to say we have committed the transfer.
690
691
  // Note that this is normally a switch only responsibility but the capability is
691
692
  // implemented here to support testing use cases where the mojaloop-connector is
@@ -695,7 +696,7 @@ class OutboundTransfersModel {
695
696
  // we will use the current server time as committed timestamp.
696
697
  const patchNotification = {
697
698
  completedTimestamp: (new Date()).toISOString(),
698
- transferState: 'COMMITTED',
699
+ transferState: FSPIOPTransferStateEnum.COMMITTED,
699
700
  };
700
701
  const res = this._requests.patchTransfers(this.data.transferId,
701
702
  patchNotification, this.data.quoteResponseSource);
@@ -885,28 +886,28 @@ class OutboundTransfersModel {
885
886
 
886
887
  switch(this.data.currentState) {
887
888
  case 'payeeResolved':
888
- resp.currentState = TransferStateEnum.WAITING_FOR_PARTY_ACCEPTANCE;
889
+ resp.currentState = SDKStateEnum.WAITING_FOR_PARTY_ACCEPTANCE;
889
890
  break;
890
891
 
891
892
  case 'quoteReceived':
892
- resp.currentState = TransferStateEnum.WAITING_FOR_QUOTE_ACCEPTANCE;
893
+ resp.currentState = SDKStateEnum.WAITING_FOR_QUOTE_ACCEPTANCE;
893
894
  break;
894
895
 
895
896
  case 'succeeded':
896
- resp.currentState = TransferStateEnum.COMPLETED;
897
+ resp.currentState = SDKStateEnum.COMPLETED;
897
898
  break;
898
899
 
899
900
  case 'aborted':
900
- resp.currentState = TransferStateEnum.ABORTED;
901
+ resp.currentState = SDKStateEnum.ABORTED;
901
902
  break;
902
903
 
903
904
  case 'errored':
904
- resp.currentState = TransferStateEnum.ERROR_OCCURRED;
905
+ resp.currentState = SDKStateEnum.ERROR_OCCURRED;
905
906
  break;
906
907
 
907
908
  default:
908
909
  this._logger.log(`Transfer model response being returned from an unexpected state: ${this.data.currentState}. Returning ERROR_OCCURRED state`);
909
- resp.currentState = TransferStateEnum.ERROR_OCCURRED;
910
+ resp.currentState = SDKStateEnum.ERROR_OCCURRED;
910
911
  break;
911
912
  }
912
913
 
@@ -10,17 +10,6 @@
10
10
 
11
11
  'use strict';
12
12
 
13
- const TransferStateEnum = {
14
- 'WAITING_FOR_PARTY_ACCEPTANCE': 'WAITING_FOR_PARTY_ACCEPTANCE',
15
- 'QUOTE_REQUEST_RECEIVED': 'QUOTE_REQUEST_RECEIVED',
16
- 'WAITING_FOR_QUOTE_ACCEPTANCE': 'WAITING_FOR_QUOTE_ACCEPTANCE',
17
- 'PREPARE_RECEIVED': 'PREPARE_RECEIVED',
18
- 'ERROR_OCCURRED': 'ERROR_OCCURRED',
19
- 'COMPLETED': 'COMPLETED',
20
- 'ABORTED': 'ABORTED',
21
- 'RESERVED': 'RESERVED',
22
- };
23
-
24
13
  class BackendError extends Error {
25
14
  constructor(msg, httpStatusCode) {
26
15
  super(msg);
@@ -45,6 +34,5 @@ class BackendError extends Error {
45
34
 
46
35
 
47
36
  module.exports = {
48
- BackendError,
49
- TransferStateEnum,
37
+ BackendError
50
38
  };
@@ -0,0 +1,30 @@
1
+
2
+ /**************************************************************************
3
+ * (C) Copyright ModusBox Inc. 2019 - All rights reserved. *
4
+ * *
5
+ * This file is made available under the terms of the license agreement *
6
+ * specified in the corresponding source code repository. *
7
+ * *
8
+ * ORIGINAL AUTHOR: *
9
+ * Yevhen Kyriukha - yevhen.kyriukha@modusbox.com *
10
+ **************************************************************************/
11
+
12
+ 'use strict';
13
+
14
+ // NOTE: Stick all common SDK ENUMS here. SDKStateEnum is the first attempt at consolidating and cleaning up ENUMS in the SDK.
15
+
16
+ const SDKStateEnum = {
17
+ WAITING_FOR_ACTION: 'WAITING_FOR_ACTION',
18
+ WAITING_FOR_PARTY_ACCEPTANCE: 'WAITING_FOR_PARTY_ACCEPTANCE',
19
+ QUOTE_REQUEST_RECEIVED: 'QUOTE_REQUEST_RECEIVED',
20
+ WAITING_FOR_QUOTE_ACCEPTANCE: 'WAITING_FOR_QUOTE_ACCEPTANCE',
21
+ PREPARE_RECEIVED: 'PREPARE_RECEIVED',
22
+ ERROR_OCCURRED: 'ERROR_OCCURRED',
23
+ COMPLETED: 'COMPLETED',
24
+ ABORTED: 'ABORTED',
25
+ RESERVED: 'RESERVED',
26
+ };
27
+
28
+ module.exports = {
29
+ SDKStateEnum,
30
+ };
@@ -9,11 +9,12 @@
9
9
  **************************************************************************/
10
10
 
11
11
  'use strict';
12
- const { BackendError, TransferStateEnum } = require('./BackendError');
12
+ const { SDKStateEnum } = require('./Enums');
13
+ const { BackendError } = require('./BackendError');
13
14
  const PersistentStateMachine = require('./PersistentStateMachine');
14
15
 
15
16
  module.exports = {
16
17
  BackendError,
17
- TransferStateEnum,
18
+ SDKStateEnum,
18
19
  PersistentStateMachine
19
20
  };
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.logger.push({ handler }).log('Found handler');
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();
@@ -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
- logger.push({ path, result }).log('Matched path');
173
+ if (!this.logExcludePaths.includes(path)) {
174
+ logger.push({path, result}).log('Matched path');
175
+ }
167
176
  return result;
168
177
  }
169
178
 
@@ -26,8 +26,8 @@ JWS_SIGN=false
26
26
  JWS_SIGN_PUT_PARTIES=false
27
27
 
28
28
  # Path to JWS signing key (private key of THIS DFSP)
29
- JWS_SIGNING_KEY_PATH=/jwsSigningKey.key
30
- JWS_VERIFICATION_KEYS_DIRECTORY=/jwsVerificationKeys
29
+ JWS_SIGNING_KEY_PATH=secrets/jwsSigningKey.key
30
+ JWS_VERIFICATION_KEYS_DIRECTORY=secrets/jwsVerificationKeys
31
31
 
32
32
  # Location of certs and key required for TLS
33
33
  # IN_CA_CERT_PATH=./secrets/cacert.pem
@@ -2,6 +2,7 @@
2
2
 
3
3
  const axios = require('axios');
4
4
  const env = require('../../testEnv');
5
+ const { SDKStateEnum } = require('../../../../src/lib/model/common');
5
6
 
6
7
  jest.dontMock('redis');
7
8
 
@@ -12,7 +13,7 @@ describe('/parties', () => {
12
13
  const res = await axios.get(getPartiesURI);
13
14
 
14
15
  expect(res.status).toEqual(200);
15
- expect(res.data.currentState).toEqual('COMPLETED');
16
+ expect(res.data.currentState).toEqual(SDKStateEnum.COMPLETED);
16
17
  expect(typeof res.data.party).toEqual('object');
17
18
  expect(typeof res.data.party.body).toEqual('object');
18
19
  expect(typeof res.data.party.headers).toEqual('object');
@@ -4,6 +4,8 @@ const axios = require('axios');
4
4
  const { uuid } = require('uuidv4');
5
5
  const env = require('../../testEnv');
6
6
  const quotesPostRequest = require('./data/quotesPostRequest.json');
7
+ const { SDKStateEnum } = require('../../../../src/lib/model/common');
8
+
7
9
 
8
10
  jest.dontMock('redis');
9
11
 
@@ -28,7 +30,7 @@ describe('/quotes', () => {
28
30
  });
29
31
 
30
32
  expect(res.status).toEqual(200);
31
- expect(res.data.currentState).toEqual('COMPLETED');
33
+ expect(res.data.currentState).toEqual(SDKStateEnum.COMPLETED);
32
34
  expect(typeof res.data.quotes).toEqual('object');
33
35
  expect(typeof res.data.quotes.body).toEqual('object');
34
36
  expect(typeof res.data.quotes.headers).toEqual('object');
@@ -4,6 +4,7 @@ const axios = require('axios');
4
4
  const { uuid } = require('uuidv4');
5
5
  const env = require('../../testEnv');
6
6
  const transfersPostRequest = require('./data/transfersPostRequest.json');
7
+ const { SDKStateEnum } = require('../../../../src/lib/model/common');
7
8
 
8
9
  jest.dontMock('redis');
9
10
 
@@ -37,7 +38,7 @@ describe('/simpleTransfers', () => {
37
38
  });
38
39
 
39
40
  expect(res.status).toEqual(200);
40
- expect(res.data.currentState).toEqual('COMPLETED');
41
+ expect(res.data.currentState).toEqual(SDKStateEnum.COMPLETED);
41
42
  expect(typeof res.data.transfer).toEqual('object');
42
43
  expect(typeof res.data.transfer.body).toEqual('object');
43
44
  expect(typeof res.data.transfer.headers).toEqual('object');
@@ -22,6 +22,8 @@ const mockArguments = require('./data/mockArguments');
22
22
  const mockTransactionRequestData = require('./data/mockTransactionRequest');
23
23
  const { Logger } = require('@mojaloop/sdk-standard-components');
24
24
 
25
+ const FSPIOPTransferStateEnum = require('@mojaloop/central-services-shared').Enum.Transfers.TransferState;
26
+
25
27
  describe('Inbound API handlers:', () => {
26
28
  let mockArgs;
27
29
  let mockTransactionRequest;
@@ -549,7 +551,7 @@ describe('Inbound API handlers:', () => {
549
551
 
550
552
  },
551
553
  body: {
552
- transferState: 'COMMITTED',
554
+ transferState: FSPIOPTransferStateEnum.COMMITTED,
553
555
  completedTimestamp: '2020-08-18T09:39:33.552Z'
554
556
  }
555
557
  },
@@ -19,6 +19,7 @@ const { AccountsModel } = require('~/lib/model');
19
19
 
20
20
  const StateMachine = require('javascript-state-machine');
21
21
  const { MojaloopRequests, Logger } = require('@mojaloop/sdk-standard-components');
22
+ const { SDKStateEnum } = require('../../../../src/lib/model/common');
22
23
 
23
24
  const defaultConfig = require('./data/defaultConfig');
24
25
  const transferRequest = require('./data/transferRequest');
@@ -83,7 +84,7 @@ describe('AccountsModel', () => {
83
84
  (Math.floor(count / MAX_ITEMS_PER_REQUEST) + ((count % MAX_ITEMS_PER_REQUEST) ? 1 : 0));
84
85
  expect(MojaloopRequests.__postParticipants).toHaveBeenCalledTimes(expectedRequestsCount);
85
86
 
86
- expect(result.currentState).toBe('COMPLETED');
87
+ expect(result.currentState).toBe(SDKStateEnum.COMPLETED);
87
88
  expect(StateMachine.__instance.state).toBe('succeeded');
88
89
  }
89
90
 
@@ -31,6 +31,10 @@ const notificationToPayee = require('./data/notificationToPayee');
31
31
  const notificationAbortedToPayee = require('./data/notificationAbortedToPayee');
32
32
  const notificationReservedToPayee = require('./data/notificationReservedToPayee');
33
33
 
34
+ const { SDKStateEnum } = require('../../../../src/lib/model/common');
35
+ const FSPIOPTransferStateEnum = require('@mojaloop/central-services-shared').Enum.Transfers.TransferState;
36
+ const FSPIOPBulkTransferStateEnum = require('@mojaloop/central-services-shared').Enum.Transfers.BulkTransferState;
37
+
34
38
  describe('inboundModel', () => {
35
39
  let config;
36
40
  let mockArgs;
@@ -324,7 +328,7 @@ describe('inboundModel', () => {
324
328
  const call = MojaloopRequests.__putTransfers.mock.calls[0];
325
329
  expect(call[0]).toEqual(TRANSFER_ID);
326
330
  expect(call[1]).toEqual(getTransfersMojaloopResponse);
327
- expect(call[1].transferState).toEqual('COMMITTED');
331
+ expect(call[1].transferState).toEqual(FSPIOPTransferStateEnum.COMMITTED);
328
332
  });
329
333
 
330
334
  test('getTransfer should not return fulfillment from payer', async () => {
@@ -345,7 +349,7 @@ describe('inboundModel', () => {
345
349
  const call = MojaloopRequests.__putTransfers.mock.calls[0];
346
350
  expect(call[0]).toEqual(TRANSFER_ID);
347
351
  expect(call[1]).toEqual({...getTransfersMojaloopResponse, fulfilment: undefined});
348
- expect(call[1].transferState).toEqual('COMMITTED');
352
+ expect(call[1].transferState).toEqual(FSPIOPTransferStateEnum.COMMITTED);
349
353
  });
350
354
 
351
355
  test('getTransfer should return not found error', async () => {
@@ -601,7 +605,7 @@ describe('inboundModel', () => {
601
605
  const call = MojaloopRequests.__putBulkTransfers.mock.calls[0];
602
606
  expect(call[0]).toEqual(BULK_TRANSFER_ID);
603
607
  expect(call[1]).toEqual(getBulkTransfersMojaloopResponse);
604
- expect(call[1].bulkTransferState).toEqual('COMMITTED');
608
+ expect(call[1].bulkTransferState).toEqual(FSPIOPBulkTransferStateEnum.COMPLETED);
605
609
  });
606
610
 
607
611
  test('getBulkTransfer should not return fulfillment from payer', async () => {
@@ -621,7 +625,7 @@ describe('inboundModel', () => {
621
625
 
622
626
  const call = MojaloopRequests.__putBulkTransfers.mock.calls[0];
623
627
  expect(call[0]).toEqual(BULK_TRANSFER_ID);
624
- expect(call[1].bulkTransferState).toEqual('COMMITTED');
628
+ expect(call[1].bulkTransferState).toEqual(FSPIOPBulkTransferStateEnum.COMPLETED);
625
629
  const expectedResponse = {...getBulkTransfersMojaloopResponse};
626
630
  expectedResponse.individualTransferResults[0].fulfilment = undefined;
627
631
  expect(call[1]).toMatchObject(expectedResponse);
@@ -738,7 +742,7 @@ describe('inboundModel', () => {
738
742
  const notif = JSON.parse(JSON.stringify(notificationToPayee));
739
743
 
740
744
  const expectedRequest = {
741
- currentState: 'COMPLETED',
745
+ currentState: SDKStateEnum.COMPLETED,
742
746
  finalNotification: notif.data,
743
747
  };
744
748
 
@@ -760,7 +764,7 @@ describe('inboundModel', () => {
760
764
  const notif = JSON.parse(JSON.stringify(notificationAbortedToPayee));
761
765
 
762
766
  const expectedRequest = {
763
- currentState: 'ABORTED',
767
+ currentState: SDKStateEnum.ABORTED,
764
768
  finalNotification: notif.data,
765
769
  };
766
770
 
@@ -20,6 +20,8 @@ const Model = require('~/lib/model').OutboundBulkQuotesModel;
20
20
  const { MojaloopRequests, Logger } = require('@mojaloop/sdk-standard-components');
21
21
  const StateMachine = require('javascript-state-machine');
22
22
 
23
+ const { SDKStateEnum } = require('../../../../src/lib/model/common');
24
+
23
25
  const defaultConfig = require('./data/defaultConfig');
24
26
  const bulkQuoteRequest = require('./data/bulkQuoteRequest');
25
27
  const bulkQuoteResponseTemplate = require('./data/bulkQuoteResponse');
@@ -74,7 +76,7 @@ describe('OutboundBulkQuotesModel', () => {
74
76
  await expect(model.run()).rejects.toThrowError(expectError);
75
77
  } else {
76
78
  const result = await model.run();
77
- await expect(result.currentState).toBe('COMPLETED');
79
+ await expect(result.currentState).toBe(SDKStateEnum.COMPLETED);
78
80
  }
79
81
  }
80
82
 
@@ -139,7 +141,7 @@ describe('OutboundBulkQuotesModel', () => {
139
141
  expect(MojaloopRequests.__getBulkQuotes).toHaveBeenCalledTimes(1);
140
142
 
141
143
  // check we stopped at succeeded state
142
- expect(result.currentState).toBe('COMPLETED');
144
+ expect(result.currentState).toBe(SDKStateEnum.COMPLETED);
143
145
  expect(StateMachine.__instance.state).toBe('succeeded');
144
146
  });
145
147
 
@@ -174,7 +176,7 @@ describe('OutboundBulkQuotesModel', () => {
174
176
  expect(MojaloopRequests.__postBulkQuotes).toHaveBeenCalledTimes(1);
175
177
 
176
178
  // check we stopped at 'succeeded' state
177
- expect(result.currentState).toBe('COMPLETED');
179
+ expect(result.currentState).toBe(SDKStateEnum.COMPLETED);
178
180
  expect(StateMachine.__instance.state).toBe('succeeded');
179
181
  });
180
182