@mojaloop/sdk-scheme-adapter 12.1.0 → 12.2.0

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
@@ -1,4 +1,11 @@
1
1
  # Changelog: [mojaloop/thirdparty-api-svc](https://github.com/mojaloop/thirdparty-api-svc)
2
+ ## [12.2.0](https://github.com/mojaloop/sdk-scheme-adapter/compare/v12.1.0...v12.2.0) (2022-04-21)
3
+
4
+
5
+ ### Features
6
+
7
+ * port use payee FSPID as GET /parties destination header if provided ([#301](https://github.com/mojaloop/sdk-scheme-adapter/issues/301)) ([3ad0ba5](https://github.com/mojaloop/sdk-scheme-adapter/commit/3ad0ba5f745b459ff6d9484c83ac3f384faf34b2))
8
+
2
9
  ## [12.1.0](https://github.com/mojaloop/sdk-scheme-adapter/compare/v12.0.2...v12.1.0) (2022-04-21)
3
10
 
4
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mojaloop/sdk-scheme-adapter",
3
- "version": "12.1.0",
3
+ "version": "12.2.0",
4
4
  "description": "An adapter for connecting to Mojaloop API enabled switches.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -115,7 +115,7 @@ class OutboundBulkQuotesModel {
115
115
 
116
116
  case 'requestBulkQuote':
117
117
  return this._requestBulkQuote();
118
-
118
+
119
119
  case 'getBulkQuote':
120
120
  return this._getBulkQuote(this.data.bulkQuoteId);
121
121
 
@@ -266,7 +266,7 @@ class OutboundBulkQuotesModel {
266
266
  };
267
267
 
268
268
  individualQuote.note && (quote.note = individualQuote.note);
269
-
269
+
270
270
  if (individualQuote.extensions && individualQuote.extensions.length > 0) {
271
271
  bulkQuoteRequest.extensionList = {
272
272
  extension: individualQuote.extensions
@@ -440,7 +440,7 @@ class OutboundBulkQuotesModel {
440
440
  await this.stateMachine.requestBulkQuote();
441
441
  this._logger.log(`Quotes resolved for bulk quote ${this.data.bulkQuoteId}`);
442
442
  break;
443
-
443
+
444
444
  case 'getBulkQuote':
445
445
  await this.stateMachine.getBulkQuote();
446
446
  this._logger.log(`Get bulk quote ${this.data.bulkQuoteId} has been completed`);
@@ -257,7 +257,7 @@ class OutboundBulkTransfersModel {
257
257
  ilpPacket: individualTransfer.ilpPacket,
258
258
  condition: individualTransfer.condition,
259
259
  };
260
-
260
+
261
261
  if (individualTransfer.extensions && individualTransfer.extensions.length > 0) {
262
262
  bulkTransferRequest.extensionList = {
263
263
  extension: individualTransfer.extensions
@@ -297,7 +297,7 @@ class OutboundRequestToPayModel {
297
297
  this._logger.push({ transactionRequestResponse }).log('Transaction Request Response received');
298
298
  this.data.requestToPayState = transactionRequestResponse.transactionRequestState;
299
299
 
300
-
300
+
301
301
  return resolve(transactionRequestResponse);
302
302
  }
303
303
  catch(err) {
@@ -145,7 +145,7 @@ class OutboundRequestToPayTransferModel {
145
145
  }
146
146
  }
147
147
  break;
148
-
148
+
149
149
  case 'otpReceived':
150
150
  // next transition is executeTransfer
151
151
  await this.stateMachine.executeTransfer();
@@ -230,7 +230,7 @@ class OutboundRequestToPayTransferModel {
230
230
  }
231
231
 
232
232
  /**
233
- * This method is used to communicate back to the Payee that a rejection is being
233
+ * This method is used to communicate back to the Payee that a rejection is being
234
234
  * sent because the OTP did not match.
235
235
  */
236
236
  async rejectRequestToPay() {
@@ -241,7 +241,7 @@ class OutboundRequestToPayTransferModel {
241
241
  const response = {
242
242
  status : `${this.data.requestToPayTransactionId} has been REJECTED`
243
243
  };
244
- return JSON.stringify(response);
244
+ return JSON.stringify(response);
245
245
  }
246
246
 
247
247
 
@@ -471,7 +471,7 @@ class OutboundRequestToPayTransferModel {
471
471
  }
472
472
 
473
473
  /**
474
- * Sends request for
474
+ * Sends request for
475
475
  * Starts the quote resolution process by sending a POST /quotes request to the switch;
476
476
  * then waits for a notification from the cache that the quote response has been received
477
477
  */
@@ -480,7 +480,7 @@ class OutboundRequestToPayTransferModel {
480
480
  return new Promise(async (resolve, reject) => {
481
481
 
482
482
  if( this.data.initiatorType && this.data.initiatorType === 'BUSINESS') return resolve();
483
-
483
+
484
484
  // listen for events on the quoteId
485
485
  const otpKey = `otp_${this.data.requestToPayTransactionId}`;
486
486
 
@@ -501,9 +501,9 @@ class OutboundRequestToPayTransferModel {
501
501
 
502
502
  const otpResponseBody = otpResponse.data;
503
503
  this._logger.push({ otpResponseBody }).log('OTP response received');
504
-
504
+
505
505
  this.data.otpResponse = otpResponseBody;
506
-
506
+
507
507
  return resolve(otpResponse);
508
508
  }
509
509
  catch(err) {
@@ -587,7 +587,7 @@ class OutboundRequestToPayTransferModel {
587
587
  return quote;
588
588
  }
589
589
 
590
-
590
+
591
591
  /**
592
592
  * Executes a transfer
593
593
  * Starts the transfer process by sending a POST /transfers (prepare) request to the switch;
@@ -886,7 +886,7 @@ class OutboundRequestToPayTransferModel {
886
886
  }
887
887
 
888
888
 
889
-
889
+
890
890
  }
891
891
 
892
892
 
@@ -277,7 +277,7 @@ class OutboundTransfersModel {
277
277
  // a GET /parties request to the switch
278
278
  try {
279
279
  const res = await this._requests.getParties(this.data.to.idType, this.data.to.idValue,
280
- this.data.to.idSubValue);
280
+ this.data.to.idSubValue, this.data.to.fspId);
281
281
  this._logger.push({ peer: res }).log('Party lookup sent to peer');
282
282
  }
283
283
  catch(err) {
@@ -68,7 +68,7 @@ const mojaloopPartyToInternalParty = (external) => {
68
68
  internal.idType = external.partyIdInfo.partyIdType;
69
69
  internal.idValue = external.partyIdInfo.partyIdentifier;
70
70
  internal.idSubValue = external.partyIdInfo.partySubIdOrType;
71
- // Note: we dont map fspid to internal transferParty object
71
+ internal.fspId = external.partyIdInfo.fspId;
72
72
  if(external.partyIdInfo.extensionList){
73
73
  internal.extensionList = external.partyIdInfo.extensionList.extension;
74
74
  }
@@ -109,6 +109,7 @@ const mojaloopPartyIdInfoToInternalPartyIdInfo = (external) => {
109
109
  internal.idType = external.partyIdType;
110
110
  internal.idValue = external.partyIdentifier;
111
111
  internal.idSubValue = external.partySubIdOrType;
112
+ internal.fspId = external.fspId;
112
113
 
113
114
  return internal;
114
115
  };
@@ -411,19 +412,19 @@ const mojaloopBulkPrepareToInternalBulkTransfer = (external, bulkQuotes, ilp) =>
411
412
  if (bulkQuotes) {
412
413
  // create a map of internal individual quotes payees indexed by quotedId, for faster lookup
413
414
  const internalQuotesPayeesByQuoteId = {};
414
-
415
+
415
416
  for (const quote of bulkQuotes.internalRequest.individualQuotes) {
416
417
  internalQuotesPayeesByQuoteId[quote.quoteId] = quote.to;
417
418
  }
418
-
419
+
419
420
  // create a map of external individual transfers indexed by quotedId, for faster lookup
420
421
  const externalTransferIdsByQuoteId = {};
421
-
422
+
422
423
  for (const transfer of external.individualTransfers) {
423
424
  const transactionObject = ilp.getTransactionObject(transfer.ilpPacket);
424
425
  externalTransferIdsByQuoteId[transactionObject.quoteId] = transfer.transferId;
425
426
  }
426
-
427
+
427
428
  internal = {
428
429
  bulkTransferId: external.bulkTransferId,
429
430
  bulkQuotes: bulkQuotes.response,
@@ -354,6 +354,39 @@ describe('outboundModel', () => {
354
354
  expect(StateMachine.__instance.state).toBe('payeeResolved');
355
355
  });
356
356
 
357
+ test('uses payee party fspid as source header when supplied - resolving payee', async () => {
358
+ config.autoAcceptParty = false;
359
+
360
+ const model = new Model({
361
+ cache,
362
+ logger,
363
+ ...config,
364
+ });
365
+
366
+ let req = JSON.parse(JSON.stringify(transferRequest));
367
+ const testFspId = 'TESTDESTFSPID';
368
+ req.to.fspId = testFspId;
369
+
370
+ await model.initialize(req);
371
+
372
+ expect(StateMachine.__instance.state).toBe('start');
373
+
374
+ // start the model running
375
+ const resultPromise = model.run();
376
+
377
+ // now we started the model running we simulate a callback with the resolved party
378
+ emitPartyCacheMessage(cache, payeeParty);
379
+
380
+ // wait for the model to reach a terminal state
381
+ const result = await resultPromise;
382
+
383
+ // check we stopped at payeeResolved state
384
+ expect(result.currentState).toBe('WAITING_FOR_PARTY_ACCEPTANCE');
385
+ expect(StateMachine.__instance.state).toBe('payeeResolved');
386
+
387
+ // check getParties mojaloop requests method was called with the correct arguments
388
+ expect(MojaloopRequests.__getParties).toHaveBeenCalledWith(req.to.idType, req.to.idValue, req.to.idSubValue, testFspId);
389
+ });
357
390
 
358
391
  test('halts after resolving payee, resumes and then halts after receiving quote response when AUTO_ACCEPT_PARTY is false and AUTO_ACCEPT_QUOTES is false', async () => {
359
392
  config.autoAcceptParty = false;