@mojaloop/sdk-scheme-adapter 12.3.0 → 13.0.2

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 (60) hide show
  1. package/.env.example +3 -0
  2. package/CHANGELOG.md +25 -0
  3. package/docker/ml-testing-toolkit/spec_files/api_definitions/fspiop_1.1/trigger_templates/transaction_request_followup.json +2 -2
  4. package/docker/ml-testing-toolkit/spec_files/rules_callback/default.json +7 -7
  5. package/docker/ml-testing-toolkit/spec_files/rules_response/default.json +16 -16
  6. package/docker/ml-testing-toolkit/spec_files/rules_response/default_pisp_rules.json +5 -5
  7. package/docker/ml-testing-toolkit/spec_files/rules_validation/default.json +10 -10
  8. package/package.json +3 -3
  9. package/src/InboundServer/handlers.js +114 -52
  10. package/src/OutboundServer/api.yaml +105 -32
  11. package/src/OutboundServer/api_interfaces/openapi.d.ts +46 -16
  12. package/src/OutboundServer/api_template/components/schemas/accountsResponse.yaml +9 -0
  13. package/src/OutboundServer/api_template/components/schemas/partiesByIdResponse.yaml +10 -3
  14. package/src/OutboundServer/api_template/components/schemas/quotesPostResponse.yaml +42 -34
  15. package/src/OutboundServer/api_template/components/schemas/simpleTransfersPostResponse.yaml +9 -2
  16. package/src/OutboundServer/api_template/components/schemas/transferRequest.yaml +3 -0
  17. package/src/OutboundServer/api_template/components/schemas/transferResponse.yaml +28 -2
  18. package/src/OutboundServer/api_template/components/schemas/transferStatusResponse.yaml +8 -1
  19. package/src/OutboundServer/handlers.js +1 -1
  20. package/src/config.js +1 -1
  21. package/src/lib/model/AccountsModel.js +13 -11
  22. package/src/lib/model/InboundTransfersModel.js +166 -24
  23. package/src/lib/model/OutboundRequestToPayModel.js +5 -6
  24. package/src/lib/model/OutboundRequestToPayTransferModel.js +2 -2
  25. package/src/lib/model/OutboundTransfersModel.js +261 -56
  26. package/src/lib/model/PartiesModel.js +15 -2
  27. package/src/lib/model/common/BackendError.js +28 -4
  28. package/src/lib/model/common/index.js +2 -1
  29. package/test/__mocks__/@mojaloop/sdk-standard-components.js +3 -2
  30. package/test/integration/lib/Outbound/parties.test.js +2 -0
  31. package/test/integration/lib/Outbound/quotes.test.js +2 -0
  32. package/test/integration/lib/Outbound/simpleTransfers.test.js +2 -0
  33. package/test/unit/InboundServer.test.js +9 -9
  34. package/test/unit/TestServer.test.js +11 -13
  35. package/test/unit/api/accounts/data/postAccountsErrorMojaloopResponse.json +11 -3
  36. package/test/unit/api/accounts/data/postAccountsSuccessResponse.json +14 -0
  37. package/test/unit/api/accounts/data/postAccountsSuccessResponseWithError1.json +13 -0
  38. package/test/unit/api/accounts/data/postAccountsSuccessResponseWithError2.json +18 -0
  39. package/test/unit/api/accounts/utils.js +15 -1
  40. package/test/unit/api/transfers/data/getTransfersCommittedResponse.json +18 -15
  41. package/test/unit/api/transfers/data/getTransfersErrorNotFound.json +1 -0
  42. package/test/unit/api/transfers/data/postTransfersErrorMojaloopResponse.json +9 -0
  43. package/test/unit/api/transfers/data/postTransfersErrorTimeoutResponse.json +1 -0
  44. package/test/unit/api/transfers/data/postTransfersSuccessResponse.json +74 -47
  45. package/test/unit/api/transfers/utils.js +85 -4
  46. package/test/unit/data/commonHttpHeaders.json +1 -0
  47. package/test/unit/inboundApi/handlers.test.js +45 -14
  48. package/test/unit/lib/model/AccountsModel.test.js +9 -6
  49. package/test/unit/lib/model/InboundTransfersModel.test.js +210 -30
  50. package/test/unit/lib/model/OutboundRequestToPayModel.test.js +1 -1
  51. package/test/unit/lib/model/OutboundRequestToPayTransferModel.test.js +3 -3
  52. package/test/unit/lib/model/OutboundTransfersModel.test.js +826 -157
  53. package/test/unit/lib/model/PartiesModel.test.js +13 -7
  54. package/test/unit/lib/model/QuotesModel.test.js +8 -2
  55. package/test/unit/lib/model/TransfersModel.test.js +8 -2
  56. package/test/unit/lib/model/data/defaultConfig.json +9 -9
  57. package/test/unit/lib/model/data/mockArguments.json +97 -40
  58. package/test/unit/lib/model/data/payeeParty.json +13 -11
  59. package/test/unit/lib/model/data/quoteResponse.json +36 -25
  60. package/test/unit/lib/model/data/transferFulfil.json +5 -3
package/.env.example CHANGED
@@ -136,6 +136,9 @@ ALS_ENDPOINT=127.0.0.1:6500
136
136
  # To allow transfer without a previous quote request, set this value to true.
137
137
  # The incoming transfer request should consists of an ILP packet and a matching condition in this case.
138
138
  # The fulfilment will be generated from the provided ILP packet, and must hash to the provided condition.
139
+ # If using the sdk-scheme-adapter in place of the deprecated `mojaloop-connector`
140
+ # make sure this is false. Scenarios that use `mojaloop-connector`
141
+ # absolutely requires a previous quote before allowing a transfer to proceed.
139
142
  ALLOW_TRANSFER_WITHOUT_QUOTE=false
140
143
 
141
144
  # To enable request for notification on fulfiled transfer
package/CHANGELOG.md CHANGED
@@ -1,4 +1,29 @@
1
1
  # Changelog: [mojaloop/thirdparty-api-svc](https://github.com/mojaloop/thirdparty-api-svc)
2
+ ### [13.0.2](https://github.com/mojaloop/sdk-scheme-adapter/compare/v13.0.1...v13.0.2) (2022-05-12)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * update outbound interface and response oa3 defs ([#316](https://github.com/mojaloop/sdk-scheme-adapter/issues/316)) ([50d23d8](https://github.com/mojaloop/sdk-scheme-adapter/commit/50d23d8562afdeeeef2203d6196473c7b0e484a5))
8
+
9
+ ### [13.0.1](https://github.com/mojaloop/sdk-scheme-adapter/compare/v13.0.0...v13.0.1) (2022-05-11)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * update package.json with main and type correct path ([#315](https://github.com/mojaloop/sdk-scheme-adapter/issues/315)) ([6d0f9b5](https://github.com/mojaloop/sdk-scheme-adapter/commit/6d0f9b541f79fa50cb6c89a3ac47cf97155f60ae))
15
+
16
+ ## [13.0.0](https://github.com/mojaloop/sdk-scheme-adapter/compare/v12.3.0...v13.0.0) (2022-05-10)
17
+
18
+
19
+ ### ⚠ BREAKING CHANGES
20
+
21
+ * merge in mojaloop-connector differences (#314)
22
+
23
+ ### Refactors
24
+
25
+ * merge in mojaloop-connector differences ([#314](https://github.com/mojaloop/sdk-scheme-adapter/issues/314)) ([e2626f9](https://github.com/mojaloop/sdk-scheme-adapter/commit/e2626f97cd13da7dc3d6d5aaf1d8cadd82fcffcc))
26
+
2
27
  ## [12.3.0](https://github.com/mojaloop/sdk-scheme-adapter/compare/v12.2.3...v12.3.0) (2022-05-04)
3
28
 
4
29
 
@@ -4,8 +4,8 @@
4
4
  "payerFirstName": "Vijay",
5
5
  "payerLastName": "Kumar",
6
6
  "payerDOB": "1984-01-01",
7
- "accept": "application/vnd.interoperability.parties+json;version=1.0",
8
- "contentType": "application/vnd.interoperability.parties+json;version=1.0",
7
+ "accept": "application/vnd.interoperability.parties+json;version=1.1",
8
+ "contentType": "application/vnd.interoperability.parties+json;version=1.1",
9
9
  "transactionId": "e8c4572c-0826-22f4-aa3e-f5bbe928afa6",
10
10
  "TrsNote": "note",
11
11
  "TrsCurrency": "USD",
@@ -40,7 +40,7 @@
40
40
  "path": "/parties/{Type}/{ID}",
41
41
  "params": {
42
42
  "headers": {
43
- "Content-Type": "application/vnd.interoperability.parties+json;version=1.0",
43
+ "Content-Type": "application/vnd.interoperability.parties+json;version=1.1",
44
44
  "Date": "Wed, 27 May 2020 11:13:34 GMT",
45
45
  "X-Forwarded-For": "sed eiusmod sunt",
46
46
  "FSPIOP-Source": "{$config.FSPID}",
@@ -119,7 +119,7 @@
119
119
  "path": "/parties/{Type}/{ID}",
120
120
  "params": {
121
121
  "headers": {
122
- "Content-Type": "application/vnd.interoperability.parties+json;version=1.0",
122
+ "Content-Type": "application/vnd.interoperability.parties+json;version=1.1",
123
123
  "Date": "Wed, 27 May 2020 11:13:34 GMT",
124
124
  "X-Forwarded-For": "sed eiusmod sunt",
125
125
  "FSPIOP-Source": "{$config.FSPID}",
@@ -192,7 +192,7 @@
192
192
  "path": "/quotes/{ID}",
193
193
  "params": {
194
194
  "headers": {
195
- "Content-Type": "application/vnd.interoperability.quotes+json;version=1.0",
195
+ "Content-Type": "application/vnd.interoperability.quotes+json;version=1.1",
196
196
  "Date": "Wed, 27 May 2020 11:13:34 GMT",
197
197
  "FSPIOP-Source": "{$config.FSPID}",
198
198
  "FSPIOP-Destination": "mojaloop-sdk",
@@ -272,7 +272,7 @@
272
272
  "path": "/quotes/{ID}",
273
273
  "params": {
274
274
  "headers": {
275
- "Content-Type": "application/vnd.interoperability.quotes+json;version=1.0",
275
+ "Content-Type": "application/vnd.interoperability.quotes+json;version=1.1",
276
276
  "Date": "Wed, 27 May 2020 11:13:34 GMT",
277
277
  "FSPIOP-Source": "{$config.FSPID}",
278
278
  "FSPIOP-Destination": "mojaloop-sdk",
@@ -357,7 +357,7 @@
357
357
  "path": "/transfers/{ID}",
358
358
  "params": {
359
359
  "headers": {
360
- "Content-Type": "application/vnd.interoperability.transfers+json;version=1.0",
360
+ "Content-Type": "application/vnd.interoperability.transfers+json;version=1.1",
361
361
  "Date": "Wed, 27 May 2020 11:13:34 GMT",
362
362
  "FSPIOP-Source": "{$config.FSPID}",
363
363
  "FSPIOP-Destination": "mojaloop-sdk",
@@ -405,7 +405,7 @@
405
405
  "path": "/transfers/{ID}",
406
406
  "params": {
407
407
  "headers": {
408
- "Content-Type": "application/vnd.interoperability.transfers+json;version=1.0",
408
+ "Content-Type": "application/vnd.interoperability.transfers+json;version=1.1",
409
409
  "Date": "Wed, 27 May 2020 11:13:34 GMT",
410
410
  "FSPIOP-Source": "{$config.FSPID}",
411
411
  "FSPIOP-Destination": "mojaloop-sdk",
@@ -423,4 +423,4 @@
423
423
  "type": "callback",
424
424
  "version": 1
425
425
  }
426
- ]
426
+ ]
@@ -261,8 +261,8 @@
261
261
  "method: 'post',",
262
262
  "header: {",
263
263
  " 'FSPIOP-Source': 'dfspA',",
264
- " 'Accept': 'application/vnd.interoperability.thirdparty+json;version=1.0',",
265
- " 'Content-Type': 'application/vnd.interoperability.thirdparty+json;version=1.0',",
264
+ " 'Accept': 'application/vnd.interoperability.thirdparty+json;version=1.1',",
265
+ " 'Content-Type': 'application/vnd.interoperability.thirdparty+json;version=1.1',",
266
266
  " 'Date': curDate",
267
267
  "},",
268
268
  "body: {",
@@ -342,8 +342,8 @@
342
342
  "method: 'put',",
343
343
  "header: {",
344
344
  " 'FSPIOP-Source': 'auth.dfspA',",
345
- " 'Accept': 'application/vnd.interoperability.thirdparty+json;version=1.0',",
346
- " 'Content-Type': 'application/vnd.interoperability.thirdparty+json;version=1.0',",
345
+ " 'Accept': 'application/vnd.interoperability.thirdparty+json;version=1.1',",
346
+ " 'Content-Type': 'application/vnd.interoperability.thirdparty+json;version=1.1',",
347
347
  " 'Date': curDate",
348
348
  "},",
349
349
  "body: {",
@@ -828,8 +828,8 @@
828
828
  " method: 'put',",
829
829
  " header: {",
830
830
  " 'FSPIOP-Source': 'pispA',",
831
- " 'Accept': 'application/vnd.interoperability.thirdparty+json;version=1.0',",
832
- " 'Content-Type': 'application/vnd.interoperability.thirdparty+json;version=1.0',",
831
+ " 'Accept': 'application/vnd.interoperability.thirdparty+json;version=1.1',",
832
+ " 'Content-Type': 'application/vnd.interoperability.thirdparty+json;version=1.1',",
833
833
  " 'Date': curDate",
834
834
  " },",
835
835
  " body: {",
@@ -909,8 +909,8 @@
909
909
  " method: 'put',",
910
910
  " header: {",
911
911
  " 'FSPIOP-Source': 'pispA',",
912
- " 'Accept': 'application/vnd.interoperability.thirdparty+json;version=1.0',",
913
- " 'Content-Type': 'application/vnd.interoperability.thirdparty+json;version=1.0',",
912
+ " 'Accept': 'application/vnd.interoperability.thirdparty+json;version=1.1',",
913
+ " 'Content-Type': 'application/vnd.interoperability.thirdparty+json;version=1.1',",
914
914
  " 'Date': curDate",
915
915
  " },",
916
916
  " body: {",
@@ -997,8 +997,8 @@
997
997
  "method: 'put',",
998
998
  "header: {",
999
999
  " 'FSPIOP-Source': 'auth.dfspA',",
1000
- " 'Accept': 'application/vnd.interoperability.thirdparty+json;version=1.0',",
1001
- " 'Content-Type': 'application/vnd.interoperability.thirdparty+json;version=1.0',",
1000
+ " 'Accept': 'application/vnd.interoperability.thirdparty+json;version=1.1',",
1001
+ " 'Content-Type': 'application/vnd.interoperability.thirdparty+json;version=1.1',",
1002
1002
  " 'Date': curDate",
1003
1003
  "},",
1004
1004
  "body: {",
@@ -1092,8 +1092,8 @@
1092
1092
  "method: 'delete',",
1093
1093
  "header: {",
1094
1094
  " 'FSPIOP-Source': 'dfspa',",
1095
- " 'Accept': 'application/vnd.interoperability.participants+json;version=1.0',",
1096
- " 'Content-Type': 'application/vnd.interoperability.participants+json;version=1.0',",
1095
+ " 'Accept': 'application/vnd.interoperability.participants+json;version=1.1',",
1096
+ " 'Content-Type': 'application/vnd.interoperability.participants+json;version=1.1',",
1097
1097
  " 'Date': curDate",
1098
1098
  "}",
1099
1099
  "}",
@@ -1153,8 +1153,8 @@
1153
1153
  "method: 'post',",
1154
1154
  "header: {",
1155
1155
  " 'FSPIOP-Source': 'dfspa',",
1156
- " 'Accept': 'application/vnd.interoperability.participants+json;version=1.0',",
1157
- " 'Content-Type': 'application/vnd.interoperability.participants+json;version=1.0',",
1156
+ " 'Accept': 'application/vnd.interoperability.participants+json;version=1.1',",
1157
+ " 'Content-Type': 'application/vnd.interoperability.participants+json;version=1.1',",
1158
1158
  " 'Date': curDate",
1159
1159
  "},",
1160
1160
  "body: {",
@@ -1220,8 +1220,8 @@
1220
1220
  "method: 'delete',",
1221
1221
  "header: {",
1222
1222
  " 'FSPIOP-Source': 'dfspa',",
1223
- " 'Accept': 'application/vnd.interoperability.participants+json;version=1.0',",
1224
- " 'Content-Type': 'application/vnd.interoperability.participants+json;version=1.0',",
1223
+ " 'Accept': 'application/vnd.interoperability.participants+json;version=1.1',",
1224
+ " 'Content-Type': 'application/vnd.interoperability.participants+json;version=1.1',",
1225
1225
  " 'Date': curDate",
1226
1226
  "}",
1227
1227
  "}",
@@ -36,8 +36,8 @@
36
36
  " method: 'POST',",
37
37
  " header: {",
38
38
  " 'FSPIOP-Source': 'switch',",
39
- " 'Accept': 'application/vnd.interoperability.thirdparty+json;version=1.0',",
40
- " 'Content-Type': 'application/vnd.interoperability.thirdparty+json;version=1.0',",
39
+ " 'Accept': 'application/vnd.interoperability.thirdparty+json;version=1.1',",
40
+ " 'Content-Type': 'application/vnd.interoperability.thirdparty+json;version=1.1',",
41
41
  " 'Date': curDate",
42
42
  " },",
43
43
  " body: {",
@@ -135,8 +135,8 @@
135
135
  "method: 'patch',",
136
136
  "header: {",
137
137
  " 'FSPIOP-Source': 'switch',",
138
- " 'Accept': 'application/vnd.interoperability.thirdparty+json;version=1.0',",
139
- " 'Content-Type': 'application/vnd.interoperability.thirdparty+json;version=1.0',",
138
+ " 'Accept': 'application/vnd.interoperability.thirdparty+json;version=1.1',",
139
+ " 'Content-Type': 'application/vnd.interoperability.thirdparty+json;version=1.1',",
140
140
  " 'Date': curDate",
141
141
  "},",
142
142
  "body: {",
@@ -158,4 +158,4 @@
158
158
  "type": "response",
159
159
  "version": 1
160
160
  }
161
- ]
161
+ ]
@@ -40,7 +40,7 @@
40
40
  "path": "/parties/{Type}/{ID}/error",
41
41
  "params": {
42
42
  "headers": {
43
- "Content-Type": "application/vnd.interoperability.parties+json;version=1.0",
43
+ "Content-Type": "application/vnd.interoperability.parties+json;version=1.1",
44
44
  "Date": "Fri, 02 Feb 1996 03:04:05 GMT",
45
45
  "FSPIOP-Source": "switch"
46
46
  },
@@ -110,7 +110,7 @@
110
110
  "path": "/parties/{Type}/{ID}/error",
111
111
  "params": {
112
112
  "headers": {
113
- "Content-Type": "application/vnd.interoperability.parties+json;version=1.0",
113
+ "Content-Type": "application/vnd.interoperability.parties+json;version=1.1",
114
114
  "Date": "Fri, 02 Feb 1996 03:04:05 GMT",
115
115
  "FSPIOP-Source": "switch"
116
116
  },
@@ -180,7 +180,7 @@
180
180
  "path": "/parties/{Type}/{ID}/error",
181
181
  "params": {
182
182
  "headers": {
183
- "Content-Type": "application/vnd.interoperability.parties+json;version=1.0",
183
+ "Content-Type": "application/vnd.interoperability.parties+json;version=1.1",
184
184
  "Date": "Fri, 02 Feb 1996 03:04:05 GMT",
185
185
  "FSPIOP-Source": "switch"
186
186
  },
@@ -250,7 +250,7 @@
250
250
  "path": "/parties/{Type}/{ID}/error",
251
251
  "params": {
252
252
  "headers": {
253
- "Content-Type": "application/vnd.interoperability.parties+json;version=1.0",
253
+ "Content-Type": "application/vnd.interoperability.parties+json;version=1.1",
254
254
  "Date": "Fri, 02 Feb 1996 03:04:05 GMT",
255
255
  "FSPIOP-Source": "switch"
256
256
  },
@@ -320,7 +320,7 @@
320
320
  "path": "/parties/{Type}/{ID}/error",
321
321
  "params": {
322
322
  "headers": {
323
- "Content-Type": "application/vnd.interoperability.parties+json;version=1.0",
323
+ "Content-Type": "application/vnd.interoperability.parties+json;version=1.1",
324
324
  "Date": "Fri, 02 Feb 1996 03:04:05 GMT",
325
325
  "FSPIOP-Source": "switch"
326
326
  },
@@ -384,7 +384,7 @@
384
384
  "path": "/thirdpartyRequests/transactions/{ID}/error",
385
385
  "params": {
386
386
  "headers": {
387
- "Content-Type": "application/vnd.interoperability.thirdparty+json;version=1.0",
387
+ "Content-Type": "application/vnd.interoperability.thirdparty+json;version=1.1",
388
388
  "Date": "Fri, 02 Feb 2020 03:04:05 GMT",
389
389
  "FSPIOP-Source": "switch"
390
390
  },
@@ -448,7 +448,7 @@
448
448
  "path": "/thirdpartyRequests/transactions/{ID}/error",
449
449
  "params": {
450
450
  "headers": {
451
- "Content-Type": "application/vnd.interoperability.thirdparty+json;version=1.0",
451
+ "Content-Type": "application/vnd.interoperability.thirdparty+json;version=1.1",
452
452
  "Date": "Fri, 02 Feb 2020 03:04:05 GMT",
453
453
  "FSPIOP-Source": "switch"
454
454
  },
@@ -512,7 +512,7 @@
512
512
  "path": "/thirdpartyRequests/transactions/{ID}/error",
513
513
  "params": {
514
514
  "headers": {
515
- "Content-Type": "application/vnd.interoperability.thirdparty+json;version=1.0",
515
+ "Content-Type": "application/vnd.interoperability.thirdparty+json;version=1.1",
516
516
  "Date": "Fri, 02 Feb 2020 03:04:05 GMT",
517
517
  "FSPIOP-Source": "switch"
518
518
  },
@@ -576,7 +576,7 @@
576
576
  "path": "/thirdpartyRequests/transactions/{ID}/error",
577
577
  "params": {
578
578
  "headers": {
579
- "Content-Type": "application/vnd.interoperability.thirdparty+json;version=1.0",
579
+ "Content-Type": "application/vnd.interoperability.thirdparty+json;version=1.1",
580
580
  "Date": "Fri, 02 Feb 2020 03:04:05 GMT",
581
581
  "FSPIOP-Source": "switch"
582
582
  },
@@ -640,7 +640,7 @@
640
640
  "path": "/thirdpartyRequests/transactions/{ID}/error",
641
641
  "params": {
642
642
  "headers": {
643
- "Content-Type": "application/vnd.interoperability.thirdparty+json;version=1.0",
643
+ "Content-Type": "application/vnd.interoperability.thirdparty+json;version=1.1",
644
644
  "Date": "Fri, 02 Feb 2020 03:04:05 GMT",
645
645
  "FSPIOP-Source": "switch"
646
646
  },
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@mojaloop/sdk-scheme-adapter",
3
- "version": "12.3.0",
3
+ "version": "13.0.2",
4
4
  "description": "An adapter for connecting to Mojaloop API enabled switches.",
5
- "main": "index.js",
6
- "types": "index.d.ts",
5
+ "main": "src/index.js",
6
+ "types": "src/index.d.ts",
7
7
  "engines": {
8
8
  "node": "=16.x"
9
9
  },
@@ -159,7 +159,10 @@ const postQuotes = async (ctx) => {
159
159
  const sourceFspId = ctx.request.headers['fspiop-source'];
160
160
 
161
161
  // use the model to handle the request
162
- const response = await model.quoteRequest(ctx.request.body, sourceFspId);
162
+ const response = await model.quoteRequest({
163
+ body: ctx.request.body,
164
+ headers: ctx.request.headers,
165
+ }, sourceFspId);
163
166
 
164
167
  // log the result
165
168
  ctx.state.logger.push({ response }).log('Inbound transfers model handled POST /quotes request');
@@ -196,7 +199,10 @@ const postTransfers = async (ctx) => {
196
199
  const sourceFspId = ctx.request.headers['fspiop-source'];
197
200
 
198
201
  // use the model to handle the request
199
- const response = await model.prepareTransfer(ctx.request.body, sourceFspId);
202
+ const response = await model.prepareTransfer({
203
+ body: ctx.request.body,
204
+ headers: ctx.request.headers,
205
+ }, sourceFspId);
200
206
 
201
207
  // log the result
202
208
  ctx.state.logger.push({ response }).log('Inbound transfers model handled POST /transfers request');
@@ -299,8 +305,10 @@ const putAuthorizationsById = async (ctx) => {
299
305
  // publish an event onto the cache for subscribers to action
300
306
  await ctx.state.cache.publish(cacheId, {
301
307
  type: 'authorizationsResponse',
302
- data: ctx.request.body,
303
- headers: ctx.request.headers
308
+ data: {
309
+ body: ctx.request.body,
310
+ headers: ctx.request.headers
311
+ }
304
312
  });
305
313
  ctx.response.status = 200;
306
314
  };
@@ -313,7 +321,10 @@ const putParticipantsById = async (ctx) => {
313
321
  // publish an event onto the cache for subscribers to action
314
322
  await ctx.state.cache.publish(`ac_${ctx.state.path.params.ID}`, {
315
323
  type: 'accountsCreationSuccessfulResponse',
316
- data: ctx.request.body
324
+ data: {
325
+ body: ctx.request.body,
326
+ headers: ctx.request.headers
327
+ }
317
328
  });
318
329
 
319
330
  ctx.response.status = 200;
@@ -327,7 +338,10 @@ const putParticipantsByIdError = async (ctx) => {
327
338
  // publish an event onto the cache for subscribers to action
328
339
  await ctx.state.cache.publish(`ac_${ctx.state.path.params.ID}`, {
329
340
  type: 'accountsCreationErrorResponse',
330
- data: ctx.request.body
341
+ data: {
342
+ body: ctx.request.body,
343
+ headers: ctx.request.headers
344
+ }
331
345
  });
332
346
 
333
347
  ctx.response.status = 200;
@@ -347,7 +361,12 @@ const putParticipantsByTypeAndId = async (ctx) => {
347
361
 
348
362
  // publish an event onto the cache for subscribers to action
349
363
  const cacheId = `${idType}_${idValue}` + (idSubValue ? `_${idSubValue}` : '');
350
- await ctx.state.cache.publish(cacheId, ctx.request.body);
364
+ await ctx.state.cache.publish(cacheId, {
365
+ data: {
366
+ body: ctx.request.body,
367
+ headers: ctx.request.headers
368
+ }
369
+ });
351
370
  ctx.response.status = 200;
352
371
  } else {
353
372
  // SDK does not make participants requests so we should not expect any calls to this method
@@ -370,7 +389,12 @@ const putParticipantsByTypeAndIdError = async(ctx) => {
370
389
  // the subscriber will notice the body contains an errorInformation property
371
390
  // and recognise it as an error response
372
391
  const cacheId = `${idType}_${idValue}` + (idSubValue ? `_${idSubValue}` : '');
373
- await ctx.state.cache.publish(cacheId, ctx.request.body);
392
+ await ctx.state.cache.publish(cacheId, {
393
+ data: {
394
+ body: ctx.request.body,
395
+ headers: ctx.request.headers
396
+ }
397
+ });
374
398
 
375
399
  ctx.response.status = 200;
376
400
  ctx.response.body = '';
@@ -389,32 +413,10 @@ const putPartiesByTypeAndId = async (ctx) => {
389
413
  // publish an event onto the cache for subscribers to finish the action
390
414
  await PartiesModel.triggerDeferredJob({
391
415
  cache: ctx.state.cache,
392
- message: ctx.request.body,
393
- args: {
394
- type: idType,
395
- id: idValue,
396
- subId: idSubValue
397
- }
398
- });
399
-
400
- ctx.response.status = 200;
401
- };
402
-
403
- /**
404
- * Handles a PUT /parties/{Type}/{ID}/error request. This is an error response to a GET /parties/{Type}/{ID} request
405
- */
406
- const putPartiesByTypeAndIdError = async(ctx) => {
407
- const idType = ctx.state.path.params.Type;
408
- const idValue = ctx.state.path.params.ID;
409
- const idSubValue = ctx.state.path.params.SubId;
410
-
411
- // publish an event onto the cache for subscribers to action
412
- // note that we publish the event the same way we publish a success PUT
413
- // the subscriber will notice the body contains an errorInformation property
414
- // and recognizes it as an error response
415
- await PartiesModel.triggerDeferredJob({
416
- cache: ctx.state.cache,
417
- message: ctx.request.body,
416
+ message: {
417
+ headers: ctx.request.headers,
418
+ body: ctx.request.body
419
+ },
418
420
  args: {
419
421
  type: idType,
420
422
  id: idValue,
@@ -423,10 +425,8 @@ const putPartiesByTypeAndIdError = async(ctx) => {
423
425
  });
424
426
 
425
427
  ctx.response.status = 200;
426
- ctx.response.body = '';
427
428
  };
428
429
 
429
-
430
430
  /**
431
431
  * Handles a PUT /quotes/{ID}. This is a response to a POST /quotes request
432
432
  */
@@ -437,14 +437,19 @@ const putQuoteById = async (ctx) => {
437
437
  // publish an event onto the cache for subscribers to action
438
438
  await ctx.state.cache.publish(`qt_${ctx.state.path.params.ID}`, {
439
439
  type: 'quoteResponse',
440
- data: ctx.request.body,
441
- headers: ctx.request.headers
440
+ data: {
441
+ body: ctx.request.body,
442
+ headers: ctx.request.headers
443
+ }
442
444
  });
443
445
 
444
446
  // duplicate publication until legacy code refactored
445
447
  await QuotesModel.triggerDeferredJob({
446
448
  cache: ctx.state.cache,
447
- message: ctx.request.body,
449
+ message: {
450
+ headers: ctx.request.headers,
451
+ body: ctx.request.body
452
+ },
448
453
  args: {
449
454
  quoteId: ctx.state.path.params.ID
450
455
  }
@@ -464,7 +469,10 @@ const putQuotesByIdError = async (ctx) => {
464
469
  // publish an event onto the cache for subscribers to action
465
470
  await ctx.state.cache.publish(`qt_${ctx.state.path.params.ID}`, {
466
471
  type: 'quoteResponseError',
467
- data: ctx.request.body
472
+ data: {
473
+ body: ctx.request.body,
474
+ headers: ctx.request.headers
475
+ }
468
476
  });
469
477
 
470
478
  // duplicate publication until legacy code refactored
@@ -524,8 +532,10 @@ const putTransactionRequestsById = async (ctx) => {
524
532
  // publish an event onto the cache for subscribers to action
525
533
  await ctx.state.cache.publish(`txnreq_${ctx.state.path.params.ID}`, {
526
534
  type: 'transactionRequestResponse',
527
- data: ctx.request.body,
528
- headers: ctx.request.headers
535
+ data: {
536
+ body: ctx.request.body,
537
+ headers: ctx.request.headers
538
+ }
529
539
  });
530
540
 
531
541
  ctx.response.status = 200;
@@ -541,12 +551,18 @@ const putTransfersById = async (ctx) => {
541
551
  // publish an event onto the cache for subscribers to action
542
552
  await ctx.state.cache.publish(`tf_${ctx.state.path.params.ID}`, {
543
553
  type: 'transferFulfil',
544
- data: ctx.request.body
554
+ data: {
555
+ body: ctx.request.body,
556
+ headers: ctx.request.headers
557
+ }
545
558
  });
546
559
 
547
560
  await TransfersModel.triggerDeferredJob({
548
561
  cache: ctx.state.cache,
549
- message: ctx.request.body,
562
+ message: {
563
+ body: ctx.request.body,
564
+ headers: ctx.request.headers
565
+ },
550
566
  args: {
551
567
  transferId: ctx.state.path.params.ID,
552
568
  }
@@ -583,6 +599,35 @@ const patchTransfersById = async (ctx) => {
583
599
  log('Inbound transfers model handled PATCH /transfers/{ID} request');
584
600
  };
585
601
 
602
+ /**
603
+ * Handles a PUT /parties/{Type}/{ID}/error request. This is an error response to a GET /parties/{Type}/{ID} request
604
+ */
605
+ const putPartiesByTypeAndIdError = async(ctx) => {
606
+ const idType = ctx.state.path.params.Type;
607
+ const idValue = ctx.state.path.params.ID;
608
+ const idSubValue = ctx.state.path.params.SubId;
609
+
610
+ // publish an event onto the cache for subscribers to action
611
+ // note that we publish the event the same way we publish a success PUT
612
+ // the subscriber will notice the body contains an errorInformation property
613
+ // and recognizes it as an error response
614
+ await PartiesModel.triggerDeferredJob({
615
+ cache: ctx.state.cache,
616
+ message: {
617
+ headers: ctx.request.headers,
618
+ body: ctx.request.body
619
+ },
620
+ args: {
621
+ type: idType,
622
+ id: idValue,
623
+ subId: idSubValue
624
+ }
625
+ });
626
+
627
+ ctx.response.status = 200;
628
+ ctx.response.body = '';
629
+ };
630
+
586
631
  /**
587
632
  * Handles a PUT /transfers/{ID}/error. This is an error response to a POST /transfers request
588
633
  */
@@ -593,12 +638,18 @@ const putTransfersByIdError = async (ctx) => {
593
638
  // publish an event onto the cache for subscribers to action
594
639
  await ctx.state.cache.publish(`tf_${ctx.state.path.params.ID}`, {
595
640
  type: 'transferError',
596
- data: ctx.request.body
641
+ data: {
642
+ body: ctx.request.body,
643
+ headers: ctx.request.headers
644
+ }
597
645
  });
598
646
 
599
647
  await TransfersModel.triggerDeferredJob({
600
648
  cache: ctx.state.cache,
601
- message: ctx.request.body,
649
+ message: {
650
+ body: ctx.request.body,
651
+ headers: ctx.request.headers
652
+ },
602
653
  args: {
603
654
  transferId: ctx.state.path.params.ID,
604
655
  }
@@ -686,8 +737,10 @@ const putBulkQuotesById = async (ctx) => {
686
737
  // publish an event onto the cache for subscribers to action
687
738
  await ctx.state.cache.publish(`bulkQuotes_${ctx.state.path.params.ID}`, {
688
739
  type: 'bulkQuoteResponse',
689
- data: ctx.request.body,
690
- headers: ctx.request.headers
740
+ data: {
741
+ body: ctx.request.body,
742
+ headers: ctx.request.headers
743
+ }
691
744
  });
692
745
 
693
746
  ctx.response.status = 200;
@@ -700,7 +753,10 @@ const putBulkQuotesByIdError = async(ctx) => {
700
753
  // publish an event onto the cache for subscribers to action
701
754
  await ctx.state.cache.publish(`bulkQuotes_${ctx.state.path.params.ID}`, {
702
755
  type: 'bulkQuoteResponseError',
703
- data: ctx.request.body
756
+ data: {
757
+ body: ctx.request.body,
758
+ headers: ctx.request.headers
759
+ }
704
760
  });
705
761
 
706
762
  ctx.response.status = 200;
@@ -785,8 +841,10 @@ const putBulkTransfersById = async (ctx) => {
785
841
  // publish an event onto the cache for subscribers to action
786
842
  await ctx.state.cache.publish(`bulkTransfer_${ctx.state.path.params.ID}`, {
787
843
  type: 'bulkTransferResponse',
788
- data: ctx.request.body,
789
- headers: ctx.request.headers
844
+ data: {
845
+ body: ctx.request.body,
846
+ headers: ctx.request.headers
847
+ }
790
848
  });
791
849
 
792
850
  ctx.response.status = 200;
@@ -799,13 +857,17 @@ const putBulkTransfersByIdError = async(ctx) => {
799
857
  // publish an event onto the cache for subscribers to action
800
858
  await ctx.state.cache.publish(`bulkTransfer_${ctx.state.path.params.ID}`, {
801
859
  type: 'bulkTransferResponseError',
802
- data: ctx.request.body
860
+ data: {
861
+ body: ctx.request.body,
862
+ headers: ctx.request.headers
863
+ }
803
864
  });
804
865
 
805
866
  ctx.response.status = 200;
806
867
  ctx.response.body = '';
807
868
  };
808
869
 
870
+
809
871
  const healthCheck = async(ctx) => {
810
872
  ctx.response.status = 200;
811
873
  ctx.response.body = '';