@mojaloop/central-services-shared 18.3.4 → 18.4.0-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.
package/CHANGELOG.md CHANGED
@@ -2,35 +2,6 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
- ### [18.3.4](https://github.com/mojaloop/central-services-shared/compare/v18.3.3...v18.3.4) (2024-04-09)
6
-
7
-
8
- ### Chore
9
-
10
- * updated 3p dependencies to address moderate vulns ([#367](https://github.com/mojaloop/central-services-shared/issues/367)) ([08d1c74](https://github.com/mojaloop/central-services-shared/commit/08d1c7474e00fd12585274f39f349f8dea65ffb9))
11
-
12
- ### [18.3.3](https://github.com/mojaloop/central-services-shared/compare/v18.3.2...v18.3.3) (2024-04-05)
13
-
14
-
15
- ### Chore
16
-
17
- * overrides to 3p dependencies to address vulnerabilities ([#366](https://github.com/mojaloop/central-services-shared/issues/366)) ([8e87809](https://github.com/mojaloop/central-services-shared/commit/8e87809c8f552d18dd644fe1242987cec178414c))
18
-
19
- ### [18.3.2](https://github.com/mojaloop/central-services-shared/compare/v18.3.1...v18.3.2) (2024-04-05)
20
-
21
-
22
- ### Chore
23
-
24
- * dependency updates to address issues ([#365](https://github.com/mojaloop/central-services-shared/issues/365)) ([6dd4a53](https://github.com/mojaloop/central-services-shared/commit/6dd4a53fd5092a3af566032fd7a8f4a968778d4d))
25
-
26
- ### [18.3.1](https://github.com/mojaloop/central-services-shared/compare/v18.3.0...v18.3.1) (2024-04-04)
27
-
28
-
29
- ### Chore
30
-
31
- * **deps:** bump express from 4.18.2 to 4.19.2 ([#363](https://github.com/mojaloop/central-services-shared/issues/363)) ([248bad2](https://github.com/mojaloop/central-services-shared/commit/248bad29d36ad9a09832792f45d3a2d8d66ae2da))
32
- * **deps:** bump follow-redirects from 1.15.5 to 1.15.6 ([#364](https://github.com/mojaloop/central-services-shared/issues/364)) ([eed3eeb](https://github.com/mojaloop/central-services-shared/commit/eed3eebf0adefeed5f954d5aa31eddc730e04325))
33
-
34
5
  ## [18.3.0](https://github.com/mojaloop/central-services-shared/compare/v18.2.0...v18.3.0) (2024-03-07)
35
6
 
36
7
 
package/CODEOWNERS CHANGED
@@ -6,7 +6,7 @@
6
6
  ## @global-owner1 and @global-owner2 will be requested for
7
7
  ## review when someone opens a pull request.
8
8
  #* @global-owner1 @global-owner2
9
- * @mdebarros @elnyry-sam-k @vijayg10 @kleyow @oderayi
9
+ * @mdebarros @elnyry-sam-k @vijayg10 @kleyow
10
10
 
11
11
  ## Order is important; the last matching pattern takes the most
12
12
  ## precedence. When someone opens a pull request that only
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mojaloop/central-services-shared",
3
- "version": "18.3.4",
3
+ "version": "18.4.0-snapshot.10",
4
4
  "description": "Shared code for mojaloop central services",
5
5
  "license": "Apache-2.0",
6
6
  "author": "ModusBox",
@@ -71,7 +71,7 @@
71
71
  "yaml": "2.4.1"
72
72
  },
73
73
  "devDependencies": {
74
- "@hapi/hapi": "21.3.8",
74
+ "@hapi/hapi": "21.3.9",
75
75
  "@hapi/joi": "17.1.1",
76
76
  "audit-ci": "^6.6.1",
77
77
  "base64url": "3.0.1",
@@ -90,24 +90,19 @@
90
90
  "tape": "5.7.5",
91
91
  "tapes": "4.1.0"
92
92
  },
93
- "overrides": {
94
- "shins": {
95
- "ejs": "^3.1.7",
96
- "sanitize-html": "2.12.1",
97
- "jsonpointer": "5.0.0",
98
- "markdown-it": "12.3.2",
99
- "yargs-parser": "13.1.2",
100
- "postcss": "8.4.31"
101
- }
102
- },
103
93
  "peerDependencies": {
104
- "@mojaloop/central-services-error-handling": ">=13.x.x",
94
+ "@mojaloop/central-services-error-handling": ">=12.x.x",
105
95
  "@mojaloop/central-services-logger": ">=11.x.x",
106
96
  "@mojaloop/central-services-metrics": ">=12.x.x",
107
97
  "@mojaloop/event-sdk": ">=14.x.x",
108
98
  "ajv": "8.x.x",
109
99
  "ajv-keywords": "5.x.x"
110
100
  },
101
+ "overrides": {
102
+ "shins": {
103
+ "ejs": "3.1.7"
104
+ }
105
+ },
111
106
  "peerDependenciesMeta": {
112
107
  "@mojaloop/central-services-error-handling": {
113
108
  "optional": false
@@ -56,7 +56,9 @@ const TransferParticipantRoleType = {
56
56
  PAYEE_DFSP: 2,
57
57
  HUB: 3,
58
58
  DFSP_SETTLEMENT: 4,
59
- DFSP_POSITION: 5
59
+ DFSP_POSITION: 5,
60
+ INITIATING_FSP: 6,
61
+ COUNTER_PARTY_FSP: 7
60
62
  }
61
63
 
62
64
  const PartyAccountTypes = {
@@ -53,12 +53,16 @@ const FspEndpointTypes = {
53
53
  FSPIOP_CALLBACK_URL_TRANSFER_POST: 'FSPIOP_CALLBACK_URL_TRANSFER_POST',
54
54
  FSPIOP_CALLBACK_URL_TRANSFER_PUT: 'FSPIOP_CALLBACK_URL_TRANSFER_PUT',
55
55
  FSPIOP_CALLBACK_URL_TRANSFER_ERROR: 'FSPIOP_CALLBACK_URL_TRANSFER_ERROR',
56
+ FSPIOP_CALLBACK_URL_FX_TRANSFER_POST: 'FSPIOP_CALLBACK_URL_FX_TRANSFER_POST',
57
+ FSPIOP_CALLBACK_URL_FX_TRANSFER_PUT: 'FSPIOP_CALLBACK_URL_FX_TRANSFER_PUT',
58
+ FSPIOP_CALLBACK_URL_FX_TRANSFER_ERROR: 'FSPIOP_CALLBACK_URL_FX_TRANSFER_ERROR',
56
59
  ALARM_NOTIFICATION_URL: 'ALARM_NOTIFICATION_URL',
57
60
  ALARM_NOTIFICATION_TOPIC: 'ALARM_NOTIFICATION_TOPIC',
58
61
  NET_DEBIT_CAP_THRESHOLD_BREACH_EMAIL: 'NET_DEBIT_CAP_THRESHOLD_BREACH_EMAIL',
59
62
  NET_DEBIT_CAP_ADJUSTMENT_EMAIL: 'NET_DEBIT_CAP_ADJUSTMENT_EMAIL',
60
63
  SETTLEMENT_TRANSFER_POSITION_CHANGE_EMAIL: 'SETTLEMENT_TRANSFER_POSITION_CHANGE_EMAIL',
61
64
  FSPIOP_CALLBACK_URL_QUOTES: 'FSPIOP_CALLBACK_URL_QUOTES',
65
+ FSPIOP_CALLBACK_URL_FX_QUOTES: 'FSPIOP_CALLBACK_URL_FX_QUOTES',
62
66
  FSPIOP_CALLBACK_URL_BULK_QUOTES: 'FSPIOP_CALLBACK_URL_BULK_QUOTES',
63
67
  FSPIOP_CALLBACK_URL_BULK_TRANSFER_POST: 'FSPIOP_CALLBACK_URL_BULK_TRANSFER_POST',
64
68
  FSPIOP_CALLBACK_URL_BULK_TRANSFER_PUT: 'FSPIOP_CALLBACK_URL_BULK_TRANSFER_PUT',
@@ -111,6 +115,12 @@ const FspEndpointTemplates = {
111
115
  ORACLE_PARTICIPANTS_TYPE_ID_SUB_ID: '/participants/{{partyIdType}}/{{partyIdentifier}}?partySubIdOrType={{partySubIdOrType}}',
112
116
  ORACLE_PARTICIPANTS_TYPE_ID_CURRENCY_SUB_ID: '/participants/{{partyIdType}}/{{partyIdentifier}}?currency={{currency}}&partySubIdOrType={{partySubIdOrType}}',
113
117
  ORACLE_PARTICIPANTS_BATCH: '/participants',
118
+ FX_TRANSFERS_POST: '/fxTransfers',
119
+ FX_TRANSFERS_PUT: '/{{fsp}}/fxTransfers/{{ID}}',
120
+ FX_TRANSFERS_PUT_ERROR: '/{{fsp}}/fxTransfers/{{ID}}/error',
121
+ FX_QUOTES_POST: '/fxQuotes',
122
+ FX_QUOTES_PUT: '/{{fsp}}/fxQuotes/{{ID}}',
123
+ FX_QUOTES_ERROR_PUT: '/fxQuotes/{{ID}}/error',
114
124
  TRANSFERS_POST: '/transfers',
115
125
  TRANSFERS_PUT: '/{{fsp}}/transfers/{{ID}}',
116
126
  TRANSFERS_PUT_ERROR: '/{{fsp}}/transfers/{{ID}}/error',
@@ -39,6 +39,7 @@ const Event = {
39
39
  ENDPOINTCACHE: 'endpointcache',
40
40
  EVENT: 'event',
41
41
  FULFIL: 'fulfil',
42
+ FX_QUOTE: 'fxquote',
42
43
  GET: 'get',
43
44
  NOTIFICATION: 'notification',
44
45
  ORACLE: 'oracle',
@@ -78,6 +79,20 @@ const Event = {
78
79
  FAIL: 'fail',
79
80
  FULFIL: 'fulfil',
80
81
  FULFIL_DUPLICATE: 'fulfil-duplicate',
82
+ FX_FULFIL: 'fx-fulfil',
83
+ FX_ABORT: 'fx-abort',
84
+ FX_COMMIT: 'fx-commit',
85
+ FX_PREPARE: 'fx-prepare',
86
+ FX_REJECT: 'fx-reject',
87
+ FX_RESERVE: 'fx-reserve',
88
+ FX_PREPARE_DUPLICATE: 'fx-prepare-duplicate',
89
+ FX_ABORT_VALIDATION: 'fx-abort-validation',
90
+ FX_RESERVED_ABORTED: 'fx-reserved-aborted',
91
+ FX_FULFIL_DUPLICATE: 'fx-fulfil-duplicate',
92
+ FX_ABORT_DUPLICATE: 'fx-abort-duplicate',
93
+ FX_TIMEOUT_RECEIVED: 'fx-timeout-received',
94
+ FX_TIMEOUT_RESERVED: 'fx-timeout-reserved',
95
+ FX_GET: 'fx-get',
81
96
  GET: 'get',
82
97
  INITIATE: 'initiate',
83
98
  LIMIT_ADJUSTMENT: 'limit-adjustment',
@@ -0,0 +1,38 @@
1
+ /*****
2
+ License
3
+ --------------
4
+ Copyright © 2017 Bill & Melinda Gates Foundation
5
+ The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+ Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
8
+ Contributors
9
+ --------------
10
+ This is the official list of the Mojaloop project contributors for this file.
11
+ Names of the original copyright holders (individuals or organizations)
12
+ should be listed with a '*' in the first column. People who have
13
+ contributed from an organization can be listed under the organization
14
+ that actually holds the copyright for their contributions (see the
15
+ Gates Foundation organization for an example). Those individuals should have
16
+ their names indented and be marked with a '-'. Email address can be added
17
+ optionally within square brackets <email>.
18
+ * Gates Foundation
19
+ - Name Surname <name.surname@gatesfoundation.com>
20
+
21
+ * Vijay Kumar Guthi <vijaya.guthi@infitx.com>
22
+ --------------
23
+ ******/
24
+
25
+ const FxTransferType = {
26
+ PAYER_CONVERSION: 1,
27
+ PAYEE_CONVERSION: 2
28
+ }
29
+
30
+ const FxParticipantCurrencyType = {
31
+ SOURCE: 1,
32
+ TARGET: 2
33
+ }
34
+
35
+ module.exports = {
36
+ FxTransferType,
37
+ FxParticipantCurrencyType
38
+ }
@@ -32,6 +32,7 @@ const Transfers = require('./transfers')
32
32
  const Events = require('./events')
33
33
  const Kafka = require('./kafka')
34
34
  const Tags = require('./tags')
35
+ const Fx = require('./fx')
35
36
 
36
37
  module.exports = {
37
38
  Accounts,
@@ -41,5 +42,6 @@ module.exports = {
41
42
  Settlements,
42
43
  Transfers,
43
44
  Kafka,
44
- Tags
45
+ Tags,
46
+ Fx
45
47
  }
@@ -142,6 +142,26 @@ const TopicMap = {
142
142
  functionality: transferEventType.NOTIFICATION,
143
143
  action: transferEventAction.EVENT
144
144
  },
145
+ 'fx-abort': {
146
+ functionality: transferEventType.NOTIFICATION,
147
+ action: transferEventAction.EVENT
148
+ },
149
+ 'fx-commit': {
150
+ functionality: transferEventType.NOTIFICATION,
151
+ action: transferEventAction.EVENT
152
+ },
153
+ 'fx-prepare': {
154
+ functionality: transferEventType.NOTIFICATION,
155
+ action: transferEventAction.EVENT
156
+ },
157
+ 'fx-reject': {
158
+ functionality: transferEventType.NOTIFICATION,
159
+ action: transferEventAction.EVENT
160
+ },
161
+ 'fx-reserve': {
162
+ functionality: transferEventType.NOTIFICATION,
163
+ action: transferEventAction.EVENT
164
+ },
145
165
  'prepare-duplicate': {
146
166
  functionality: transferEventType.NOTIFICATION,
147
167
  action: transferEventAction.EVENT
@@ -192,6 +212,26 @@ const TopicMap = {
192
212
  functionality: transferEventType.TRANSFER,
193
213
  action: transferEventAction.POSITION
194
214
  },
215
+ 'fx-abort': {
216
+ functionality: transferEventType.TRANSFER,
217
+ action: transferEventAction.POSITION
218
+ },
219
+ 'fx-commit': {
220
+ functionality: transferEventType.TRANSFER,
221
+ action: transferEventAction.POSITION
222
+ },
223
+ 'fx-prepare': {
224
+ functionality: transferEventType.TRANSFER,
225
+ action: transferEventAction.POSITION
226
+ },
227
+ 'fx-reject': {
228
+ functionality: transferEventType.TRANSFER,
229
+ action: transferEventAction.POSITION
230
+ },
231
+ 'fx-reserve': {
232
+ functionality: transferEventType.TRANSFER,
233
+ action: transferEventAction.POSITION
234
+ },
195
235
  prepare: {
196
236
  functionality: transferEventType.TRANSFER,
197
237
  action: transferEventAction.POSITION
package/src/index.d.ts CHANGED
@@ -60,12 +60,17 @@ declare namespace CentralServicesShared {
60
60
  FSPIOP_CALLBACK_URL_TRANSFER_POST = 'FSPIOP_CALLBACK_URL_TRANSFER_POST',
61
61
  FSPIOP_CALLBACK_URL_TRANSFER_PUT = 'FSPIOP_CALLBACK_URL_TRANSFER_PUT',
62
62
  FSPIOP_CALLBACK_URL_TRANSFER_ERROR = 'FSPIOP_CALLBACK_URL_TRANSFER_ERROR',
63
+ FSPIOP_CALLBACK_URL_FX_TRANSFER_POST = 'FSPIOP_CALLBACK_URL_FX_TRANSFER_POST',
64
+ FSPIOP_CALLBACK_URL_FX_TRANSFER_PUT = 'FSPIOP_CALLBACK_URL_FX_TRANSFER_PUT',
65
+ FSPIOP_CALLBACK_URL_FX_TRANSFER_ERROR = 'FSPIOP_CALLBACK_URL_FX_TRANSFER_ERROR',
63
66
  ALARM_NOTIFICATION_URL = 'ALARM_NOTIFICATION_URL',
64
67
  ALARM_NOTIFICATION_TOPIC = 'ALARM_NOTIFICATION_TOPIC',
65
68
  NET_DEBIT_CAP_THRESHOLD_BREACH_EMAIL = 'NET_DEBIT_CAP_THRESHOLD_BREACH_EMAIL',
66
69
  NET_DEBIT_CAP_ADJUSTMENT_EMAIL = 'NET_DEBIT_CAP_ADJUSTMENT_EMAIL',
67
70
  SETTLEMENT_TRANSFER_POSITION_CHANGE_EMAIL = 'SETTLEMENT_TRANSFER_POSITION_CHANGE_EMAIL',
68
71
  FSPIOP_CALLBACK_URL_QUOTES = 'FSPIOP_CALLBACK_URL_QUOTES',
72
+ FSPIOP_CALLBACK_URL_FX_QUOTES = 'FSPIOP_CALLBACK_URL_FX_QUOTES',
73
+ FSPIOP_CALLBACK_URL_BULK_QUOTES = 'FSPIOP_CALLBACK_URL_BULK_QUOTES',
69
74
  FSPIOP_CALLBACK_URL_BULK_TRANSFER_POST = 'FSPIOP_CALLBACK_URL_BULK_TRANSFER_POST',
70
75
  FSPIOP_CALLBACK_URL_BULK_TRANSFER_PUT = 'FSPIOP_CALLBACK_URL_BULK_TRANSFER_PUT',
71
76
  FSPIOP_CALLBACK_URL_BULK_TRANSFER_ERROR = 'FSPIOP_CALLBACK_URL_BULK_TRANSFER_ERROR',
@@ -125,6 +130,9 @@ declare namespace CentralServicesShared {
125
130
  FSPIOP_CALLBACK_URL_PARTIES_SUB_ID_PUT: FspEndpointTypesEnum.FSPIOP_CALLBACK_URL_PARTIES_SUB_ID_PUT;
126
131
  FSPIOP_CALLBACK_URL_PARTIES_PUT_ERROR: FspEndpointTypesEnum.FSPIOP_CALLBACK_URL_PARTIES_PUT_ERROR;
127
132
  FSPIOP_CALLBACK_URL_PARTIES_SUB_ID_PUT_ERROR: FspEndpointTypesEnum.FSPIOP_CALLBACK_URL_PARTIES_SUB_ID_PUT_ERROR;
133
+ FSPIOP_CALLBACK_URL_FX_TRANSFER_POST: FspEndpointTypesEnum.FSPIOP_CALLBACK_URL_FX_TRANSFER_POST;
134
+ FSPIOP_CALLBACK_URL_FX_TRANSFER_PUT: FspEndpointTypesEnum.FSPIOP_CALLBACK_URL_FX_TRANSFER_PUT;
135
+ FSPIOP_CALLBACK_URL_FX_TRANSFER_ERROR: FspEndpointTypesEnum.FSPIOP_CALLBACK_URL_FX_TRANSFER_ERROR;
128
136
  FSPIOP_CALLBACK_URL_TRANSFER_POST: FspEndpointTypesEnum.FSPIOP_CALLBACK_URL_TRANSFER_POST;
129
137
  FSPIOP_CALLBACK_URL_TRANSFER_PUT: FspEndpointTypesEnum.FSPIOP_CALLBACK_URL_TRANSFER_PUT;
130
138
  FSPIOP_CALLBACK_URL_TRANSFER_ERROR: FspEndpointTypesEnum.FSPIOP_CALLBACK_URL_TRANSFER_ERROR;
@@ -184,12 +192,20 @@ declare namespace CentralServicesShared {
184
192
  ORACLE_PARTICIPANTS_TYPE_ID_SUB_ID: string;
185
193
  ORACLE_PARTICIPANTS_TYPE_ID_CURRENCY_SUB_ID: string;
186
194
  ORACLE_PARTICIPANTS_BATCH: string;
195
+ FX_TRANSFERS_POST: string;
196
+ FX_TRANSFERS_PUT: string;
197
+ FX_TRANSFERS_PUT_ERROR: string;
198
+ FX_QUOTES_POST: string;
199
+ FX_QUOTES_PUT: string;
200
+ FX_QUOTES_ERROR_PUT: string;
187
201
  TRANSFERS_POST: string;
188
202
  TRANSFERS_PUT: string;
189
203
  TRANSFERS_PUT_ERROR: string;
190
204
  BULK_TRANSFERS_POST: string;
191
205
  BULK_TRANSFERS_PUT: string;
192
206
  BULK_TRANSFERS_PUT_ERROR: string;
207
+ BULK_QUOTES_POST: string;
208
+ BULK_QUOTES_ERROR_PUT: string;
193
209
  TP_TRANSACTION_REQUEST_GET: string;
194
210
  TP_TRANSACTION_REQUEST_POST: string;
195
211
  TP_TRANSACTION_REQUEST_PUT: string;
@@ -241,6 +257,7 @@ declare namespace CentralServicesShared {
241
257
  ENDPOINTCACHE = 'endpointcache',
242
258
  EVENT = 'event',
243
259
  FULFIL = 'fulfil',
260
+ FX_QUOTE = 'fx-quote',
244
261
  GET = 'get',
245
262
  NOTIFICATION = 'notification',
246
263
  ORACLE = 'oracle',
@@ -255,6 +272,8 @@ declare namespace CentralServicesShared {
255
272
  TRANSFER = 'transfer',
256
273
  PARTY = 'party',
257
274
  PARTICIPANT = 'participant',
275
+ DEFERRED_SETTLEMENT = 'deferred-settlement',
276
+ GROSS_SETTLEMENT = 'gross-settlement',
258
277
  VERIFICATION = 'verification'
259
278
  }
260
279
 
@@ -279,6 +298,20 @@ declare namespace CentralServicesShared {
279
298
  FAIL = 'fail',
280
299
  FULFIL = 'fulfil',
281
300
  FULFIL_DUPLICATE = 'fulfil-duplicate',
301
+ FX_FULFIL = 'fx-fulfil',
302
+ FX_ABORT = 'fx-abort',
303
+ FX_COMMIT = 'fx-commit',
304
+ FX_PREPARE = 'fx-prepare',
305
+ FX_REJECT = 'fx-reject',
306
+ FX_RESERVE = 'fx-reserve',
307
+ FX_PREPARE_DUPLICATE = 'fx-prepare-duplicate',
308
+ FX_ABORT_VALIDATION = 'fx-abort-validation',
309
+ FX_RESERVED_ABORTED = 'fx-reserved-aborted',
310
+ FX_FULFIL_DUPLICATE = 'fx-fulfil-duplicate',
311
+ FX_ABORT_DUPLICATE = 'fx-abort-duplicate',
312
+ FX_TIMEOUT_RECEIVED = 'fx-timeout-received',
313
+ FX_TIMEOUT_RESERVED = 'fx-timeout-reserved',
314
+ FX_GET = 'fx-get',
282
315
  GET = 'get',
283
316
  INITIATE = 'initiate',
284
317
  LIMIT_ADJUSTMENT = 'limit-adjustment',
@@ -416,6 +449,20 @@ declare namespace CentralServicesShared {
416
449
  FAIL: EventActionEnum.FAIL;
417
450
  FULFIL: EventActionEnum.FULFIL;
418
451
  FULFIL_DUPLICATE: EventActionEnum.FULFIL_DUPLICATE;
452
+ FX_FULFIL: EventActionEnum.FX_FULFIL;
453
+ FX_ABORT: EventActionEnum.FX_ABORT,
454
+ FX_COMMIT: EventActionEnum.FX_COMMIT,
455
+ FX_PREPARE: EventActionEnum.FX_PREPARE,
456
+ FX_REJECT: EventActionEnum.FX_REJECT,
457
+ FX_RESERVE: EventActionEnum.FX_RESERVE,
458
+ FX_PREPARE_DUPLICATE: EventActionEnum.FX_PREPARE_DUPLICATE,
459
+ FX_ABORT_VALIDATION: EventActionEnum.FX_ABORT_VALIDATION,
460
+ FX_RESERVED_ABORTED: EventActionEnum.FX_RESERVED_ABORTED,
461
+ FX_FULFIL_DUPLICATE: EventActionEnum.FX_FULFIL_DUPLICATE,
462
+ FX_ABORT_DUPLICATE: EventActionEnum.FX_ABORT_DUPLICATE,
463
+ FX_TIMEOUT_RECEIVED: EventActionEnum.FX_TIMEOUT_RECEIVED,
464
+ FX_TIMEOUT_RESERVED: EventActionEnum.FX_TIMEOUT_RESERVED,
465
+ FX_GET: EventActionEnum.FX_GET,
419
466
  GET: EventActionEnum.GET;
420
467
  INITIATE: EventActionEnum.INITIATE;
421
468
  LIMIT_ADJUSTMENT: EventActionEnum.LIMIT_ADJUSTMENT;
@@ -457,6 +504,7 @@ declare namespace CentralServicesShared {
457
504
  ENDPOINTCACHE: EventTypeEnum.ENDPOINTCACHE;
458
505
  EVENT: EventTypeEnum.EVENT;
459
506
  FULFIL: EventTypeEnum.FULFIL;
507
+ FX_QUOTE: EventTypeEnum.FX_QUOTE;
460
508
  GET: EventTypeEnum.GET;
461
509
  NOTIFICATION: EventTypeEnum.NOTIFICATION;
462
510
  ORACLE: EventTypeEnum.ORACLE;
@@ -471,6 +519,8 @@ declare namespace CentralServicesShared {
471
519
  TRANSFER: EventTypeEnum.TRANSFER;
472
520
  PARTY: EventTypeEnum.PARTY;
473
521
  PARTICIPANT: EventTypeEnum.PARTICIPANT;
522
+ DEFERRED_SETTLEMENT: EventTypeEnum.DEFERRED_SETTLEMENT,
523
+ GROSS_SETTLEMENT: EventTypeEnum.GROSS_SETTLEMENT,
474
524
  VERIFICATION: EventTypeEnum.VERIFICATION;
475
525
  };
476
526
  };
@@ -547,6 +597,16 @@ declare namespace CentralServicesShared {
547
597
  AdminNotificationActions: {
548
598
  LIMIT_ADJUSTMENT: AdminNotificationActionsEnum.LIMIT_ADJUSTMENT;
549
599
  };
600
+ };
601
+ Fx: {
602
+ FxTransferType: {
603
+ PAYER_CONVERSION: number;
604
+ PAYEE_CONVERSION: number;
605
+ };
606
+ FxParticipantCurrencyType: {
607
+ SOURCE: number,
608
+ TARGET: number
609
+ };
550
610
  }
551
611
  }
552
612
  interface Endpoints {
@@ -26,16 +26,16 @@
26
26
  'use strict'
27
27
 
28
28
  const Logger = require('@mojaloop/central-services-logger')
29
+ const ErrorHandler = require('@mojaloop/central-services-error-handling')
29
30
  const Catbox = require('@hapi/catbox')
30
31
  const CatboxMemory = require('@hapi/catbox-memory')
32
+ const Mustache = require('mustache')
31
33
  const { Map } = require('immutable')
32
- const Http = require('./http')
33
34
  const Enum = require('../enums')
35
+ const Http = require('./http')
36
+ const request = require('./request')
34
37
  const partition = 'endpoint-cache'
35
38
  const clientOptions = { partition }
36
- const Mustache = require('mustache')
37
- const request = require('./request')
38
- const ErrorHandler = require('@mojaloop/central-services-error-handling')
39
39
  const Metrics = require('@mojaloop/central-services-metrics')
40
40
 
41
41
  let client
@@ -51,7 +51,7 @@ let switchEndpoint
51
51
  * @returns {object} endpointMap Returns the object containing the endpoints for given fsp id
52
52
  */
53
53
  const fetchEndpoints = async (fsp) => {
54
- const histTimer = !!Metrics.isInitiated() && Metrics.getHistogram(
54
+ const histTimer = Metrics.getHistogram(
55
55
  'fetchParticipants',
56
56
  'fetchParticipants - Metrics for fetchParticipants',
57
57
  ['success']
@@ -117,11 +117,12 @@ exports.initializeCache = async (policyOptions) => {
117
117
  * @param {string} fsp - the id of the fsp
118
118
  * @param {string} endpointType - the type of the endpoint
119
119
  * @param {object} options - contains the options for the mustache template function
120
+ * @param {object} renderOptions - contains the options for the rendering the endpoint
120
121
  *
121
122
  * @returns {string} - Returns the endpoint, throws error if failure occurs
122
123
  */
123
- exports.getEndpoint = async (switchUrl, fsp, endpointType, options = {}) => {
124
- const histTimer = !!Metrics.isInitiated() && Metrics.getHistogram(
124
+ exports.getEndpoint = async (switchUrl, fsp, endpointType, options = {}, renderOptions = {}) => {
125
+ const histTimer = Metrics.getHistogram(
125
126
  'getEndpoint',
126
127
  'getEndpoint - Metrics for getEndpoint with cache hit rate',
127
128
  ['success', 'hit']
@@ -139,10 +140,19 @@ exports.getEndpoint = async (switchUrl, fsp, endpointType, options = {}) => {
139
140
  } else {
140
141
  histTimer({ success: true, hit: true })
141
142
  }
142
- return Mustache.render(new Map(endpoints.value).get(endpointType), options)
143
+ const endpoint = new Map(endpoints.value).get(endpointType)
144
+ if (renderOptions.path) {
145
+ const renderedEndpoint = (endpoint === undefined) ? endpoint : endpoint + renderOptions.path
146
+ return Mustache.render(renderedEndpoint, options)
147
+ }
148
+ return Mustache.render(endpoint, options)
149
+ }
150
+ let endpoint = new Map(endpoints).get(endpointType)
151
+ if (renderOptions.path) {
152
+ endpoint = (endpoint === undefined) ? endpoint : endpoint + renderOptions.path
143
153
  }
144
154
  histTimer({ success: true, hit: false })
145
- return Mustache.render(new Map(endpoints).get(endpointType), options)
155
+ return Mustache.render(endpoint, options)
146
156
  } catch (err) {
147
157
  histTimer({ success: false, hit: false })
148
158
  Logger.isErrorEnabled && Logger.error(`participantEndpointCache::getEndpoint:: ERROR:'${err}'`)
@@ -164,35 +174,20 @@ exports.getEndpoint = async (switchUrl, fsp, endpointType, options = {}) => {
164
174
  * @returns {string} - Returns the rendered endpoint, throws error if failure occurs
165
175
  */
166
176
  exports.getEndpointAndRender = async (switchUrl, fsp, endpointType, path = '', options) => {
167
- const histTimer = !!Metrics.isInitiated() && Metrics.getHistogram(
177
+ const histTimer = Metrics.getHistogram(
168
178
  'getEndpointAndRender',
169
- 'getEndpoint - Metrics for getEndpointAndRender with cache hit rate',
170
- ['success', 'hit']
179
+ 'getEndpoint - Metrics for getEndpointAndRender',
180
+ ['success']
171
181
  ).startTimer()
172
182
  switchEndpoint = switchUrl
173
183
  Logger.isDebugEnabled && Logger.debug(`participantEndpointCache::getEndpointAndRender::endpointType - ${endpointType}`)
174
- try {
175
- // If a service passes in `getDecoratedValue` as true, then an object
176
- // { value, cached, report } is returned, where value is the cached value,
177
- // `cached` is null on a cache miss.
178
- const endpoints = await policy.get(fsp)
179
- if ('value' in endpoints && 'cached' in endpoints) {
180
- if (endpoints.cached === null) {
181
- histTimer({ success: true, hit: false })
182
- } else {
183
- histTimer({ success: true, hit: true })
184
- }
185
- const endpoint = new Map(endpoints.value).get(endpointType)
186
- const renderedEndpoint = (endpoint === undefined) ? endpoint : endpoint + path
187
- return Mustache.render(renderedEndpoint, options)
188
- }
189
184
 
190
- const endpoint = new Map(endpoints).get(endpointType)
191
- const renderedEndpoint = (endpoint === undefined) ? endpoint : endpoint + path
192
- histTimer({ success: true, hit: false })
193
- return Mustache.render(renderedEndpoint, options)
185
+ try {
186
+ const endpoint = exports.getEndpoint(switchUrl, fsp, endpointType, options, { path })
187
+ histTimer({ success: true })
188
+ return endpoint
194
189
  } catch (err) {
195
- histTimer({ success: false, hit: false })
190
+ histTimer({ success: false })
196
191
  Logger.isErrorEnabled && Logger.error(`participantEndpointCache::getEndpointAndRender:: ERROR:'${err}'`)
197
192
  throw ErrorHandler.Factory.reformatFSPIOPError(err)
198
193
  }
@@ -18,11 +18,14 @@ const defaultProtocolResources = [
18
18
  'bulkTransfers',
19
19
  'bulkQuotes',
20
20
  'transactionRequests',
21
- 'authorizations'
21
+ 'authorizations',
22
+ 'fxQuotes',
23
+ 'fxTransfers'
22
24
  ]
23
25
 
24
26
  const defaultProtocolVersions = [
25
27
  ...protocolVersions.ONE,
28
+ ...protocolVersions.TWO,
26
29
  protocolVersions.anyVersion
27
30
  ]
28
31
 
@@ -5,12 +5,14 @@ const _ = require('lodash')
5
5
 
6
6
  const protocolVersions = {
7
7
  anyVersion: Symbol('Any'),
8
- ONE: ['1', '1.0', '1.1']
8
+ ONE: ['1', '1.0', '1.1'],
9
+ TWO: ['2', '2.0']
9
10
  }
10
11
 
11
12
  const protocolVersionsMap = [
12
13
  { key: '1', value: '0' },
13
- { key: '1', value: '1' }
14
+ { key: '1', value: '1' },
15
+ { key: '2', value: '0' }
14
16
  ]
15
17
 
16
18
  // Some convenience functions for generating regexes for header matching
@@ -306,7 +306,10 @@ const proceed = async (defaultKafkaConfig, params, opts) => {
306
306
  if (fromSwitch) {
307
307
  message.value.to = message.value.from
308
308
  message.value.from = Enum.Http.Headers.FSPIOP.SWITCH.value
309
- if (message.value.content.headers) message.value.content.headers[Enum.Http.Headers.FSPIOP.DESTINATION] = message.value.to
309
+ if (message.value.content.headers) {
310
+ message.value.content.headers[Enum.Http.Headers.FSPIOP.SOURCE] = message.value.from
311
+ message.value.content.headers[Enum.Http.Headers.FSPIOP.DESTINATION] = message.value.to
312
+ }
310
313
  }
311
314
  if (typeof toDestination === 'string') {
312
315
  message.value.to = toDestination
@@ -48,7 +48,7 @@ let switchEndpoint
48
48
  * @returns {object} participant Returns the object containing the participants
49
49
  */
50
50
  const fetchParticipant = async (fsp) => {
51
- const histTimer = !!Metrics.isInitiated() && Metrics.getHistogram(
51
+ const histTimer = Metrics.getHistogram(
52
52
  'fetchParticipant',
53
53
  'fetchParticipant - Metrics for fetchParticipant',
54
54
  ['success']
@@ -103,7 +103,7 @@ exports.initializeCache = async (policyOptions) => {
103
103
  * @returns {string} - Returns the endpoint, throws error if failure occurs
104
104
  */
105
105
  exports.getParticipant = async (switchUrl, fsp) => {
106
- const histTimer = !!Metrics.isInitiated() && Metrics.getHistogram(
106
+ const histTimer = Metrics.getHistogram(
107
107
  'getParticipant',
108
108
  'getParticipant - Metrics for getParticipant with cache hit rate',
109
109
  ['success', 'hit']
@@ -39,9 +39,6 @@ const MISSING_FUNCTION_PARAMETERS = 'Missing parameters for function'
39
39
  // By default it would insert `"Accept":"application/json, text/plain, */*"`.
40
40
  delete request.defaults.headers.common.Accept
41
41
 
42
- // Enable keepalive for http
43
- request.defaults.httpAgent = new http.Agent({ keepAlive: true })
44
-
45
42
  /**
46
43
  * @function sendRequest
47
44
  *
@@ -80,7 +77,7 @@ const sendRequest = async (
80
77
  protocolVersions = undefined,
81
78
  axiosRequestOptionsOverride = {}
82
79
  ) => {
83
- const histTimerEnd = !!Metrics.isInitiated() && Metrics.getHistogram(
80
+ const histTimerEnd = Metrics.getHistogram(
84
81
  'sendRequest',
85
82
  `sending ${method} request to: ${url} from: ${source} to: ${destination}`,
86
83
  ['success', 'source', 'destination', 'method']
@@ -107,6 +104,7 @@ const sendRequest = async (
107
104
  headers: transformedHeaders,
108
105
  data: payload,
109
106
  responseType,
107
+ httpAgent: new http.Agent({ keepAlive: true }),
110
108
  ...axiosRequestOptionsOverride
111
109
  }
112
110
  // if jwsSigner is passed then sign the request
@@ -122,7 +120,7 @@ const sendRequest = async (
122
120
  const response = await request(requestOptions)
123
121
  Logger.isDebugEnabled && Logger.debug(`Success: sendRequest::response ${JSON.stringify(response, Object.getOwnPropertyNames(response))}`)
124
122
  !!sendRequestSpan && await sendRequestSpan.finish()
125
- !!histTimerEnd && histTimerEnd({ success: true, source, destination, method })
123
+ histTimerEnd({ success: true, source, destination, method })
126
124
  return response
127
125
  } catch (error) {
128
126
  Logger.isErrorEnabled && Logger.error(error)
@@ -148,7 +146,7 @@ const sendRequest = async (
148
146
  await sendRequestSpan.error(fspiopError, state)
149
147
  await sendRequestSpan.finish(fspiopError.message, state)
150
148
  }
151
- !!histTimerEnd && histTimerEnd({ success: false, source, destination, method })
149
+ histTimerEnd({ success: false, source, destination, method })
152
150
  throw fspiopError
153
151
  }
154
152
  }
@@ -1,17 +1,18 @@
1
1
  'use strict'
2
2
 
3
3
  const Test = require('tapes')(require('tape'))
4
- const src = '../../../src'
4
+ const Mustache = require('mustache')
5
+ const Catbox = require('@hapi/catbox')
6
+ const Logger = require('@mojaloop/central-services-logger')
5
7
  const Sinon = require('sinon')
8
+
9
+ const src = '../../../src'
6
10
  const Cache = require(`${src}/util/endpoints`)
7
11
  const request = require(`${src}/util/request`)
8
- const Catbox = require('@hapi/catbox')
9
12
  const Config = require('../../util/config')
10
13
  const Http = require(`${src}/util`).Http
11
14
  const Enum = require(`${src}`).Enum
12
- const Mustache = require('mustache')
13
15
  const Helper = require('../../util/helper')
14
- const Logger = require('@mojaloop/central-services-logger')
15
16
  const FSPIOP_CALLBACK_URL_TRANSFER_PUT = Enum.EndPoints.FspEndpointTypes.FSPIOP_CALLBACK_URL_TRANSFER_PUT
16
17
  const Metrics = require('@mojaloop/central-services-metrics')
17
18
 
@@ -60,6 +61,10 @@ Test('Cache Test', cacheTest => {
60
61
  try {
61
62
  const result = await Cache.getEndpoint(Config.ENDPOINT_SOURCE_URL, fsp, endpointType, { transferId: '97b01bd3-b223-415b-b37b-ab5bef9bdbed' })
62
63
  test.equal(result, expected, 'The results match')
64
+
65
+ const result2 = await Cache.getEndpoint(Config.ENDPOINT_SOURCE_URL, fsp, endpointType, { transferId: '97b01bd3-b223-415b-b37b-ab5bef9bdbed' }, { path: '/additionalPath' })
66
+ test.equal(result2, `${expected}/additionalPath`, 'The results match')
67
+
63
68
  await Cache.stopCache()
64
69
  test.end()
65
70
  } catch (err) {
@@ -83,6 +88,10 @@ Test('Cache Test', cacheTest => {
83
88
  try {
84
89
  const result = await Cache.getEndpoint(Config.ENDPOINT_SOURCE_URL, fsp, endpointType, { transferId: '97b01bd3-b223-415b-b37b-ab5bef9bdbed' })
85
90
  test.equal(result, expected, 'The results match')
91
+
92
+ const result2 = await Cache.getEndpoint(Config.ENDPOINT_SOURCE_URL, fsp, endpointType, { transferId: '97b01bd3-b223-415b-b37b-ab5bef9bdbed' }, { path: '/additionalPath' })
93
+ test.equal(result2, `${expected}/additionalPath`, 'The results match')
94
+
86
95
  await Cache.stopCache()
87
96
  test.end()
88
97
  } catch (err) {
@@ -102,13 +111,11 @@ Test('Cache Test', cacheTest => {
102
111
  try {
103
112
  await Cache.getEndpoint(Config.ENDPOINT_SOURCE_URL, fsp, endpointType, { transferId: '97b01bd3-b223-415b-b37b-ab5bef9bdbed' })
104
113
  test.fail('should throw error')
105
- await Cache.stopCache()
106
- test.end()
107
114
  } catch (e) {
108
115
  test.ok(e instanceof Error)
109
- await Cache.stopCache()
110
- test.end()
111
116
  }
117
+ await Cache.stopCache()
118
+ test.end()
112
119
  })
113
120
 
114
121
  getEndpointTest.test('throw error', async (test) => {