@mojaloop/sdk-scheme-adapter 11.18.11 → 11.18.12

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,6 +2,13 @@
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
+ ### [11.18.12](https://github.com/mojaloop/sdk-scheme-adapter/compare/v11.18.11...v11.18.12) (2022-02-15)
6
+
7
+
8
+ ### Chore
9
+
10
+ * add config option for mismatch id's ([#291](https://github.com/mojaloop/sdk-scheme-adapter/issues/291)) ([8e9717a](https://github.com/mojaloop/sdk-scheme-adapter/commit/8e9717a02c6d19f93b78f5b293917050be0ade84))
11
+
5
12
  ### [11.18.11](https://github.com/mojaloop/sdk-scheme-adapter/compare/v11.18.9...v11.18.11) (2021-11-25)
6
13
 
7
14
  ### [11.18.9](https://github.com/mojaloop/sdk-scheme-adapter/compare/v11.18.8...v11.18.9) (2021-10-20)
@@ -140,80 +140,138 @@
140
140
  "expiresAt": 1637308004771
141
141
  },
142
142
  "1004946|@mojaloop/event-sdk>@grpc/proto-loader>yargs>string-width>strip-ansi>ansi-regex": {
143
- "decision": "postpone",
144
- "madeAt": 1637774978679
143
+ "decision": "ignore",
144
+ "madeAt": 1644879175753,
145
+ "expiresAt": 1647471172307
145
146
  },
146
147
  "1004946|@mojaloop/central-services-shared>widdershins>oas-resolver>yargs>string-width>strip-ansi>ansi-regex": {
147
- "decision": "postpone",
148
- "madeAt": 1637774978679
148
+ "decision": "ignore",
149
+ "madeAt": 1644879175753,
150
+ "expiresAt": 1647471172307
149
151
  },
150
152
  "1004946|@mojaloop/central-services-shared>widdershins>oas-resolver>yargs>cliui>string-width>strip-ansi>ansi-regex": {
151
- "decision": "postpone",
152
- "madeAt": 1637774978679
153
+ "decision": "ignore",
154
+ "madeAt": 1644879175753,
155
+ "expiresAt": 1647471172307
153
156
  },
154
157
  "1004946|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-resolver>yargs>cliui>string-width>strip-ansi>ansi-regex": {
155
- "decision": "postpone",
156
- "madeAt": 1637774978679
158
+ "decision": "ignore",
159
+ "madeAt": 1644879175753,
160
+ "expiresAt": 1647471172307
157
161
  },
158
162
  "1004946|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-validator>oas-resolver>yargs>cliui>string-width>strip-ansi>ansi-regex": {
159
- "decision": "postpone",
160
- "madeAt": 1637774978679
163
+ "decision": "ignore",
164
+ "madeAt": 1644879175754,
165
+ "expiresAt": 1647471172307
161
166
  },
162
167
  "1004946|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-validator>oas-resolver>yargs>cliui>wrap-ansi>string-width>strip-ansi>ansi-regex": {
163
- "decision": "postpone",
164
- "madeAt": 1637774978679
168
+ "decision": "ignore",
169
+ "madeAt": 1644879175754,
170
+ "expiresAt": 1647471172307
165
171
  },
166
172
  "1004946|@mojaloop/event-sdk>@grpc/proto-loader>yargs>cliui>wrap-ansi>strip-ansi>ansi-regex": {
167
- "decision": "postpone",
168
- "madeAt": 1637774978679
173
+ "decision": "ignore",
174
+ "madeAt": 1644879175754,
175
+ "expiresAt": 1647471172307
169
176
  },
170
177
  "1004946|@mojaloop/central-services-shared>widdershins>oas-resolver>yargs>cliui>wrap-ansi>strip-ansi>ansi-regex": {
171
- "decision": "postpone",
172
- "madeAt": 1637774978679
178
+ "decision": "ignore",
179
+ "madeAt": 1644879175754,
180
+ "expiresAt": 1647471172307
173
181
  },
174
182
  "1004946|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-resolver>yargs>cliui>wrap-ansi>strip-ansi>ansi-regex": {
175
- "decision": "postpone",
176
- "madeAt": 1637774978679
183
+ "decision": "ignore",
184
+ "madeAt": 1644879175754,
185
+ "expiresAt": 1647471172307
177
186
  },
178
187
  "1004946|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-validator>oas-resolver>yargs>cliui>wrap-ansi>strip-ansi>ansi-regex": {
179
- "decision": "postpone",
180
- "madeAt": 1637774978679
188
+ "decision": "ignore",
189
+ "madeAt": 1644879175754,
190
+ "expiresAt": 1647471172307
181
191
  },
182
192
  "1004946|@mojaloop/event-sdk>@grpc/proto-loader>yargs>cliui>strip-ansi>ansi-regex": {
183
- "decision": "postpone",
184
- "madeAt": 1637774978679
193
+ "decision": "ignore",
194
+ "madeAt": 1644879175754,
195
+ "expiresAt": 1647471172307
185
196
  },
186
197
  "1004854|@mojaloop/central-services-shared>widdershins>openapi-sampler>json-pointer": {
187
- "decision": "postpone",
188
- "madeAt": 1637774979253
198
+ "decision": "ignore",
199
+ "madeAt": 1644879153322,
200
+ "expiresAt": 1647471110577
189
201
  },
190
202
  "1004869|@mojaloop/central-services-shared>widdershins>swagger2openapi>better-ajv-errors>jsonpointer": {
191
- "decision": "postpone",
192
- "madeAt": 1637774979672
203
+ "decision": "ignore",
204
+ "madeAt": 1644879154472,
205
+ "expiresAt": 1647471110577
193
206
  },
194
207
  "1004869|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-validator>better-ajv-errors>jsonpointer": {
195
- "decision": "postpone",
196
- "madeAt": 1637774979672
208
+ "decision": "ignore",
209
+ "madeAt": 1644879154472,
210
+ "expiresAt": 1647471110577
197
211
  },
198
212
  "1004946|@mojaloop/central-services-shared>widdershins>yargs>string-width>strip-ansi>ansi-regex": {
199
- "decision": "postpone",
200
- "madeAt": 1637774980265
213
+ "decision": "ignore",
214
+ "madeAt": 1644879155619,
215
+ "expiresAt": 1647471110577
201
216
  },
202
217
  "1004946|@mojaloop/central-services-shared>widdershins>yargs>cliui>string-width>strip-ansi>ansi-regex": {
203
- "decision": "postpone",
204
- "madeAt": 1637774980265
218
+ "decision": "ignore",
219
+ "madeAt": 1644879155619,
220
+ "expiresAt": 1647471110577
205
221
  },
206
222
  "1005383|@mojaloop/central-services-shared>shins>sanitize-html": {
207
- "decision": "postpone",
208
- "madeAt": 1637774980738
223
+ "decision": "ignore",
224
+ "madeAt": 1644879156746,
225
+ "expiresAt": 1647471110577
209
226
  },
210
227
  "1005384|@mojaloop/central-services-shared>shins>sanitize-html": {
211
- "decision": "postpone",
212
- "madeAt": 1637774980738
228
+ "decision": "ignore",
229
+ "madeAt": 1644879156746,
230
+ "expiresAt": 1647471110577
213
231
  },
214
232
  "1005534|@mojaloop/central-services-shared>widdershins>yargs>yargs-parser": {
215
- "decision": "postpone",
216
- "madeAt": 1637774981266
233
+ "decision": "ignore",
234
+ "madeAt": 1644879157837,
235
+ "expiresAt": 1647471110577
236
+ },
237
+ "1006865|axios>follow-redirects": {
238
+ "decision": "fix",
239
+ "madeAt": 1644879138577
240
+ },
241
+ "1006865|@mojaloop/central-services-shared>axios>follow-redirects": {
242
+ "decision": "fix",
243
+ "madeAt": 1644879138577
244
+ },
245
+ "1007023|axios>follow-redirects": {
246
+ "decision": "fix",
247
+ "madeAt": 1644879138577
248
+ },
249
+ "1007023|@mojaloop/central-services-shared>axios>follow-redirects": {
250
+ "decision": "fix",
251
+ "madeAt": 1644879138577
252
+ },
253
+ "1006899|@mojaloop/central-services-shared>widdershins>node-fetch": {
254
+ "decision": "fix",
255
+ "madeAt": 1644879149946
256
+ },
257
+ "1006899|@mojaloop/event-sdk>grpc>@mapbox/node-pre-gyp>node-fetch": {
258
+ "decision": "fix",
259
+ "madeAt": 1644879149946
260
+ },
261
+ "1006846|@mojaloop/central-services-shared>shins>sanitize-html>postcss": {
262
+ "decision": "ignore",
263
+ "madeAt": 1644879158938,
264
+ "expiresAt": 1647471110577
265
+ },
266
+ "1006886|@mojaloop/central-services-shared>shins>markdown-it": {
267
+ "decision": "ignore",
268
+ "madeAt": 1644879160175,
269
+ "expiresAt": 1647471110577
270
+ },
271
+ "1007017|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-validator>ajv": {
272
+ "decision": "ignore",
273
+ "madeAt": 1644879161354,
274
+ "expiresAt": 1647471110577
217
275
  }
218
276
  },
219
277
  "rules": {},
package/config.js CHANGED
@@ -154,5 +154,10 @@ module.exports = {
154
154
  proxyConfig: env.get('PROXY_CONFIG_PATH').asYamlConfig(),
155
155
  reserveNotification: env.get('RESERVE_NOTIFICATION').default('false').asBool(),
156
156
  // resourceVersions config should be string in format: "resouceOneName=1.0,resourceTwoName=1.1"
157
- resourceVersions: env.get('RESOURCE_VERSIONS').default('').asResourceVersions()
157
+ resourceVersions: env.get('RESOURCE_VERSIONS').default('').asResourceVersions(),
158
+
159
+ // in 3PPI DFSP's generate their own `transferId` which is associated with
160
+ // a transactionRequestId. this option decodes the ilp packet for
161
+ // the `transactionId` to retrieve the quote from cache
162
+ allowDifferentTransferTransactionId: env.get('ALLOW_DIFFERENT_TRANSFER_TRANSACTION_ID').default('false').asBool(),
158
163
  };
@@ -34,6 +34,7 @@ class InboundTransfersModel {
34
34
  this._rejectTransfersOnExpiredQuotes = config.rejectTransfersOnExpiredQuotes;
35
35
  this._allowTransferWithoutQuote = config.allowTransferWithoutQuote;
36
36
  this._reserveNotification = config.reserveNotification;
37
+ this._allowDifferentTransferTransactionId = config.allowDifferentTransferTransactionId;
37
38
 
38
39
  this._mojaloopRequests = new MojaloopRequests({
39
40
  logger: this._logger,
@@ -175,7 +176,7 @@ class InboundTransfersModel {
175
176
  response.expiration = new Date(expiration).toISOString();
176
177
  }
177
178
 
178
- // project our internal quote reponse into mojaloop quote response form
179
+ // project our internal quote response into mojaloop quote response form
179
180
  const mojaloopResponse = shared.internalQuoteResponseToMojaloop(response);
180
181
 
181
182
  // create our ILP packet and condition and tag them on to our internal quote response
@@ -193,7 +194,7 @@ class InboundTransfersModel {
193
194
  fulfilment: fulfilment
194
195
  });
195
196
 
196
- // now store the quoteRespnse data against the quoteId in our cache to be sent as a response to GET /quotes/{ID}
197
+ // now store the quoteResponse data against the quoteId in our cache to be sent as a response to GET /quotes/{ID}
197
198
  await this._cache.set(`quoteResponse_${quoteRequest.quoteId}`, mojaloopResponse);
198
199
 
199
200
  // make a callback to the source fsp with the quote response
@@ -209,21 +210,21 @@ class InboundTransfersModel {
209
210
  }
210
211
 
211
212
  /**
212
- * This is executed as when GET /quotes/{ID} request is made to get the response of a previous POST /quotes request.
213
+ * This is executed as when GET /quotes/{ID} request is made to get the response of a previous POST /quotes request.
213
214
  * Gets the quoteResponse from the cache and makes a callback to the originator with result
214
215
  */
215
216
  async getQuoteRequest(quoteId, sourceFspId) {
216
217
  try {
217
218
  // Get the quoteRespnse data for the quoteId from the cache to be sent as a response to GET /quotes/{ID}
218
219
  const quoteResponse = await this._cache.get(`quoteResponse_${quoteId}`);
219
-
220
+
220
221
  // If no quoteResponse is found in the cache, make an error callback to the source fsp
221
222
  if (!quoteResponse) {
222
223
  const err = new Error('Quote Id not found');
223
224
  const mojaloopError = await this._handleError(err, Errors.MojaloopApiErrorCodes.QUOTE_ID_NOT_FOUND);
224
225
  this._logger.push({ mojaloopError }).log(`Sending error response to ${sourceFspId}`);
225
226
  return await this._mojaloopRequests.putQuotesError(quoteId,
226
- mojaloopError, sourceFspId);
227
+ mojaloopError, sourceFspId);
227
228
  }
228
229
  // Make a PUT /quotes/{ID} callback to the source fsp with the quote response
229
230
  return this._mojaloopRequests.putQuotes(quoteId, quoteResponse, sourceFspId);
@@ -270,14 +271,20 @@ class InboundTransfersModel {
270
271
 
271
272
 
272
273
  /**
273
- * Validates an incoming transfer prepare request and makes a callback to the originator with
274
+ * Validates an incoming transfer prepare request and makes a callback to the originator with
274
275
  * the result
275
276
  */
276
277
  async prepareTransfer(prepareRequest, sourceFspId) {
277
278
  try {
278
-
279
279
  // retrieve our quote data
280
- const quote = await this._cache.get(`quote_${prepareRequest.transferId}`);
280
+ let quote;
281
+
282
+ if (this._allowDifferentTransferTransactionId) {
283
+ const transactionId = this._ilp.getTransactionObject(prepareRequest.ilpPacket).transactionId;
284
+ quote = await this._cache.get(`quote_${transactionId}`);
285
+ } else {
286
+ quote = await this._cache.get(`quote_${prepareRequest.transferId}`);
287
+ }
281
288
 
282
289
  if(!quote) {
283
290
  // Check whether to allow transfers without a previous quote.
@@ -703,7 +710,7 @@ class InboundTransfersModel {
703
710
  }
704
711
 
705
712
  /**
706
- * Forwards Switch notification for fulfiled transfer to the DFSP backend, when acting as a payee
713
+ * Forwards Switch notification for fulfiled transfer to the DFSP backend, when acting as a payee
707
714
  */
708
715
  async sendNotificationToPayee(body, transferId) {
709
716
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mojaloop/sdk-scheme-adapter",
3
- "version": "11.18.11",
3
+ "version": "11.18.12",
4
4
  "description": "An adapter for connecting to Mojaloop API enabled switches.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -21,6 +21,7 @@ const mockTxnReqquestsArguments = require('./data/mockTxnRequestsArguments');
21
21
  const { MojaloopRequests, Ilp, Logger } = require('@mojaloop/sdk-standard-components');
22
22
  const { BackendRequests, HTTPResponseError } = require('../../../../lib/model/lib/requests');
23
23
  const Cache = require('../../../../lib/cache');
24
+ const shared = require('../../../../lib/model/lib/shared');
24
25
 
25
26
  const getTransfersBackendResponse = require('./data/getTransfersBackendResponse');
26
27
  const getTransfersMojaloopResponse = require('./data/getTransfersMojaloopResponse');
@@ -232,9 +233,9 @@ describe('inboundModel', () => {
232
233
 
233
234
  test('calls `mojaloopRequests.putAuthorizations` with the expected arguments.', async () => {
234
235
  await model.getAuthorizations('123456', mockTxnReqArgs.fspId);
235
-
236
+
236
237
  expect(MojaloopRequests.__putAuthorizations).toHaveBeenCalledTimes(1);
237
-
238
+
238
239
  });
239
240
 
240
241
 
@@ -406,6 +407,43 @@ describe('inboundModel', () => {
406
407
  expect(BackendRequests.__postTransfers).toHaveBeenCalledTimes(1);
407
408
  expect(MojaloopRequests.__putTransfers).toHaveBeenCalledTimes(1);
408
409
  });
410
+
411
+ test('allow different transfer and transaction id', async () => {
412
+ const transactionId = 'mockTransactionId';
413
+ const TRANSFER_ID = 'transfer-id';
414
+ shared.mojaloopPrepareToInternalTransfer = jest.fn().mockReturnValueOnce({});
415
+
416
+ cache.set(`quote_${transactionId}`, {
417
+ fulfilment: '',
418
+ mojaloopResponse: {
419
+ response: ''
420
+ }
421
+ });
422
+
423
+ const args = {
424
+ transferId: TRANSFER_ID,
425
+ amount: {
426
+ currency: 'USD',
427
+ amount: 20.13
428
+ },
429
+ ilpPacket: 'mockIlpPacket',
430
+ condition: 'mockGeneratedCondition'
431
+ };
432
+
433
+ const model = new Model({
434
+ ...config,
435
+ cache,
436
+ logger,
437
+ allowDifferentTransferTransactionId: true,
438
+ checkIlp: false,
439
+ });
440
+
441
+ await model.prepareTransfer(args, mockArgs.fspId);
442
+
443
+ expect(MojaloopRequests.__putTransfersError).toHaveBeenCalledTimes(0);
444
+ expect(BackendRequests.__postTransfers).toHaveBeenCalledTimes(1);
445
+ expect(MojaloopRequests.__putTransfers).toHaveBeenCalledTimes(1);
446
+ });
409
447
  });
410
448
 
411
449
  describe('prepareBulkTransfer:', () => {
@@ -574,7 +612,7 @@ describe('inboundModel', () => {
574
612
  }
575
613
  ]
576
614
  };
577
-
615
+
578
616
  const model = new Model({
579
617
  ...config,
580
618
  cache,
@@ -595,7 +633,7 @@ describe('inboundModel', () => {
595
633
  const transferId = '1234';
596
634
  let cache;
597
635
 
598
- beforeEach(async () => {
636
+ beforeEach(async () => {
599
637
  cache = new Cache({
600
638
  host: 'dummycachehost',
601
639
  port: 1234,