@mojaloop/sdk-scheme-adapter 24.2.0-csi-1210.2 → 24.2.0-csi-1210.4

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.
Binary file
@@ -7,11 +7,11 @@ services:
7
7
  sdk-scheme-adapter-api-svc:
8
8
  networks:
9
9
  - mojaloop-net
10
- image: mojaloop/sdk-scheme-adapter:v24.2.0-csi-1210.0
10
+ image: mojaloop/sdk-scheme-adapter:local
11
11
  container_name: sdk-scheme-adapter-api-svc
12
- # build:
13
- # context: ./
14
- # dockerfile: ./Dockerfile
12
+ build:
13
+ context: ./
14
+ dockerfile: ./Dockerfile
15
15
  env_file: ./modules/api-svc/test/config/integration.env
16
16
  ports:
17
17
  - "4000:4000"
@@ -73,7 +73,7 @@
73
73
  "@mojaloop/logging-bc-client-lib": "0.5.8",
74
74
  "@mojaloop/ml-schema-transformer-lib": "2.5.6",
75
75
  "@mojaloop/sdk-scheme-adapter-private-shared-lib": "workspace:^",
76
- "@mojaloop/sdk-standard-components": "v19.9.0-snapshot.0",
76
+ "@mojaloop/sdk-standard-components": "v19.9.0-snapshot.2",
77
77
  "ajv": "8.17.1",
78
78
  "axios": "1.8.1",
79
79
  "body-parser": "1.20.3",
@@ -39,6 +39,7 @@ const {
39
39
  TransfersModel,
40
40
  } = require('../lib/model');
41
41
  const { CacheKeyPrefixes } = require('../lib/model/common');
42
+ const { generateTraceparent } = require('../lib/utils');
42
43
 
43
44
  const { ReturnCodes } = Enum.Http;
44
45
 
@@ -48,6 +49,18 @@ const extractBodyHeadersSourceFspId = ctx => ({
48
49
  headers: { ...ctx.request.headers },
49
50
  });
50
51
 
52
+ const extractTraceHeaders = ctx => {
53
+ const { traceparent = generateTraceparent(), tracestate } = ctx.request.headers;
54
+
55
+ const traceHeaders = {
56
+ traceparent,
57
+ ...(tracestate && { tracestate })
58
+ };
59
+ ctx.state?.logger?.isVerboseEnabled && ctx.state.logger.push({ traceHeaders }).verbose('extracted traceHeaders');
60
+
61
+ return traceHeaders;
62
+ };
63
+
51
64
  /**
52
65
  * @param {Object} ctx - the Koa context object
53
66
  * @returns {InboundTransfersModel}
@@ -116,7 +129,7 @@ const getParticipantsByTypeAndId = async (ctx) => {
116
129
  const model = createInboundTransfersModel(ctx);
117
130
 
118
131
  // use the model to handle the request
119
- const response = await model.getParticipants(idType, idValue, subIdValue, sourceFspId);
132
+ const response = await model.getParticipants(idType, idValue, subIdValue, sourceFspId, extractTraceHeaders(ctx));
120
133
 
121
134
  // log the result
122
135
  ctx.state.logger.isDebugEnabled && ctx.state.logger.push({ response }).debug('Inbound transfers model handled GET /participants/{idType}/{idValue}');
@@ -148,16 +161,7 @@ const getPartiesByTypeAndId = async (ctx) => {
148
161
  // use the transfers model to execute asynchronous stages with the switch
149
162
  const model = createInboundTransfersModel(ctx);
150
163
 
151
- let response;
152
-
153
- // use the model to handle the request
154
- if (ctx.request.header?.tracestate && ctx.request.header?.traceparent) {
155
- const { tracestate, traceparent } = ctx.request.header;
156
- response = await model.getParties(idType, idValue, subIdValue, sourceFspId, { tracestate, traceparent });
157
- } else {
158
- response = await model.getParties(idType, idValue, subIdValue, sourceFspId);
159
- }
160
-
164
+ const response = await model.getParties(idType, idValue, subIdValue, sourceFspId, extractTraceHeaders(ctx));
161
165
 
162
166
  // log the result
163
167
  ctx.state.logger.isDebugEnabled && ctx.state.logger.push({ response }).debug('Inbound transfers model handled GET /parties/{idType}/{idValue} request');
@@ -210,15 +214,7 @@ const postQuotes = async (ctx) => {
210
214
  // use the transfers model to execute asynchronous stages with the switch
211
215
  const model = createInboundTransfersModel(ctx);
212
216
 
213
- let response;
214
-
215
- // use the model to handle the request
216
- if (ctx.request.header?.tracestate && ctx.request.header?.traceparent) {
217
- const { tracestate, traceparent } = ctx.request.header;
218
- response = await model.quoteRequest(quoteRequest, sourceFspId, { tracestate, traceparent });
219
- } else {
220
- response = await model.quoteRequest(quoteRequest, sourceFspId);
221
- }
217
+ const response = await model.quoteRequest(quoteRequest, sourceFspId, extractTraceHeaders(ctx));
222
218
 
223
219
  // log the result
224
220
  ctx.state.logger.isDebugEnabled && ctx.state.logger.push({ response }).debug('Inbound transfers model handled POST /quotes request');
@@ -259,7 +255,7 @@ const postTransfers = async (ctx) => {
259
255
  const model = createInboundTransfersModel(ctx);
260
256
 
261
257
  // use the model to handle the request
262
- const response = await model.prepareTransfer(transferRequest, sourceFspId);
258
+ const response = await model.prepareTransfer(transferRequest, sourceFspId, extractTraceHeaders(ctx));
263
259
 
264
260
  // log the result
265
261
  ctx.state.logger.isDebugEnabled && ctx.state.logger.push({ response }).debug('Inbound transfers model handled POST /transfers request');
@@ -289,7 +285,7 @@ const getTransfersById = async (ctx) => {
289
285
  const model = createInboundTransfersModel(ctx);
290
286
 
291
287
  // use the model to handle the request
292
- const response = await model.getTransfer(transferId, sourceFspId);
288
+ const response = await model.getTransfer(transferId, sourceFspId, extractTraceHeaders(ctx));
293
289
 
294
290
  // log the result
295
291
  ctx.state.logger.isDebugEnabled && ctx.state.logger.push({response}).
@@ -320,7 +316,7 @@ const postTransactionRequests = async (ctx) => {
320
316
  const model = createInboundTransfersModel(ctx);
321
317
 
322
318
  // use the model to handle the request
323
- const response = await model.transactionRequest(transactionRequest, sourceFspId);
319
+ const response = await model.transactionRequest(transactionRequest, sourceFspId, extractTraceHeaders(ctx));
324
320
 
325
321
  // log the result
326
322
  ctx.state.logger.isDebugEnabled && ctx.state.logger.push({ response }).debug('Inbound transfers model handled POST /transactionRequests request');
@@ -577,7 +573,7 @@ const getQuoteById = async (ctx) => {
577
573
  const model = createInboundTransfersModel(ctx);
578
574
 
579
575
  // use the model to handle the request
580
- const response = await model.getQuoteRequest(quoteId, sourceFspId);
576
+ const response = await model.getQuoteRequest(quoteId, sourceFspId, extractTraceHeaders(ctx));
581
577
 
582
578
  // log the result
583
579
  ctx.state.logger.isDebugEnabled && ctx.state.logger.push({ response }).debug('Inbound transfers model handled GET /quotes request');
@@ -619,7 +615,9 @@ const putTransactionRequestsById = async (ctx) => {
619
615
  const model = createInboundTransfersModel(ctx);
620
616
 
621
617
  // use the model to handle the request
622
- const response = await model.putTransactionRequest(putTransactionRequest, transactionRequestId, sourceFspId);
618
+ const response = await model.putTransactionRequest(
619
+ putTransactionRequest, transactionRequestId, sourceFspId, extractTraceHeaders(ctx)
620
+ );
623
621
 
624
622
  // log the result
625
623
  ctx.state.logger.isDebugEnabled && ctx.state.logger.push({ response }).debug('Inbound transfers model handled PUT /transactionRequests/{ID} request');
@@ -800,7 +798,7 @@ const getBulkQuotesById = async (ctx) => {
800
798
  const model = createInboundTransfersModel(ctx);
801
799
 
802
800
  // use the model to handle the request
803
- const response = await model.getBulkQuote(bulkQuoteId, sourceFspId);
801
+ const response = await model.getBulkQuote(bulkQuoteId, sourceFspId, extractTraceHeaders(ctx));
804
802
 
805
803
  // log the result
806
804
  ctx.state.logger.isDebugEnabled && ctx.state.logger.push({response}).
@@ -830,7 +828,7 @@ const postBulkQuotes = async (ctx) => {
830
828
  const model = createInboundTransfersModel(ctx);
831
829
 
832
830
  // use the model to handle the request
833
- const response = await model.bulkQuoteRequest(bulkQuoteRequest, sourceFspId);
831
+ const response = await model.bulkQuoteRequest(bulkQuoteRequest, sourceFspId, extractTraceHeaders(ctx));
834
832
 
835
833
  // log the result
836
834
  ctx.state.logger.isDebugEnabled && ctx.state.logger.push({ response }).debug('Inbound transfers model handled POST /bulkQuotes request');
@@ -895,7 +893,7 @@ const getBulkTransfersById = async (ctx) => {
895
893
  const model = createInboundTransfersModel(ctx);
896
894
 
897
895
  // use the model to handle the request
898
- const response = await model.getBulkTransfer(bulkTransferId, sourceFspId);
896
+ const response = await model.getBulkTransfer(bulkTransferId, sourceFspId, extractTraceHeaders(ctx));
899
897
 
900
898
  // log the result
901
899
  ctx.state.logger.isDebugEnabled && ctx.state.logger.push({response}).
@@ -925,7 +923,7 @@ const postBulkTransfers = async (ctx) => {
925
923
  const model = createInboundTransfersModel(ctx);
926
924
 
927
925
  // use the model to handle the request
928
- const response = await model.prepareBulkTransfer(bulkPrepareRequest, sourceFspId);
926
+ const response = await model.prepareBulkTransfer(bulkPrepareRequest, sourceFspId, extractTraceHeaders(ctx));
929
927
 
930
928
  // log the result
931
929
  ctx.state.logger.isDebugEnabled && ctx.state.logger.push({ response }).debug('Inbound transfers model handled POST /bulkTransfers request');
@@ -995,8 +993,8 @@ const postFxQuotes = async (ctx) => {
995
993
 
996
994
  const model = createInboundTransfersModel(ctx);
997
995
 
998
- model.postFxQuotes({ body, headers }, sourceFspId)
999
- .then(response => logger.push({ response }).verbose(`${logPrefix} is done`))
996
+ model.postFxQuotes({ body, headers }, sourceFspId, extractTraceHeaders(ctx))
997
+ .then(response => logger.push({ response }).debug(`${logPrefix} is done`))
1000
998
  .catch(err => logger.push({ err }).error(`${logPrefix} error`));
1001
999
 
1002
1000
  prepareResponse(ctx);
@@ -1040,8 +1038,8 @@ const postFxTransfers = async (ctx) => {
1040
1038
  const logPrefix = 'Handling POST fxTransfers request';
1041
1039
 
1042
1040
  const model = createInboundTransfersModel(ctx);
1043
- model.postFxTransfers({ body, headers }, sourceFspId)
1044
- .then(response => logger.push({ response }).verbose(`${logPrefix} is done`))
1041
+ model.postFxTransfers({ body, headers }, sourceFspId, extractTraceHeaders(ctx))
1042
+ .then(response => logger.push({ response }).debug(`${logPrefix} is done`))
1045
1043
  .catch(err => logger.push({ err }).error(`${logPrefix} error`));
1046
1044
 
1047
1045
  prepareResponse(ctx);
@@ -36,6 +36,8 @@ const shared = require('./lib/shared');
36
36
  const { BackendRequests, HTTPResponseError } = require('./lib/requests');
37
37
  const { SDKStateEnum, CacheKeyPrefixes } = require('./common');
38
38
 
39
+ const TRACESTATE_KEY_CALLBACK_START_TS = 'tx_callback_start_ts';
40
+
39
41
  /**
40
42
  * Models the operations required for performing inbound transfers
41
43
  */
@@ -124,7 +126,7 @@ class InboundTransfersModel {
124
126
  catch(err) {
125
127
  this._logger.isErrorEnabled && this._logger.push({ err, transactionRequestId }).error('Error in getOTP');
126
128
  const mojaloopError = await this._handleError(err);
127
- this._logger.isDebugEnabled && this._logger.push({ mojaloopError }).debug(`Sending error response to ${sourceFspId}`);
129
+ this._logger.isInfoEnabled && this._logger.push({ mojaloopError }).info(`Sending error response to ${sourceFspId}`);
128
130
  return this._mojaloopRequests.putAuthorizationsError(transactionRequestId, mojaloopError, sourceFspId);
129
131
  }
130
132
  }
@@ -133,7 +135,7 @@ class InboundTransfersModel {
133
135
  /**
134
136
  * Queries the backend API for the specified party and makes a callback to the originator with our dfspId if found
135
137
  */
136
- async getParticipants(idType, idValue, idSubValue, sourceFspId) {
138
+ async getParticipants(idType, idValue, idSubValue, sourceFspId, headers) {
137
139
  try {
138
140
  // make a call to the backend to resolve the party lookup
139
141
  const response = await this._backendRequests.getParties(idType, idValue, idSubValue);
@@ -143,15 +145,22 @@ class InboundTransfersModel {
143
145
  }
144
146
 
145
147
  // make a callback to the source fsp with our dfspId indicating we own the party
146
- return this._mojaloopRequests.putParticipants(idType, idValue, idSubValue, { fspId: this._dfspId },
147
- sourceFspId);
148
+ return this._mojaloopRequests.putParticipants(
149
+ idType,
150
+ idValue,
151
+ idSubValue,
152
+ { fspId: this._dfspId },
153
+ sourceFspId,
154
+ headers
155
+ );
148
156
  }
149
- catch(err) {
157
+ catch (err) {
150
158
  this._logger.isErrorEnabled && this._logger.push({ err, idValue }).error('Error in getParticipants');
151
159
  const mojaloopError = await this._handleError(err);
152
- this._logger.isDebugEnabled && this._logger.push({ mojaloopError }).debug(`Sending error response to ${sourceFspId}`);
153
- return this._mojaloopRequests.putParticipantsError(idType, idValue, idSubValue,
154
- mojaloopError, sourceFspId);
160
+ this._logger.isInfoEnabled && this._logger.push({ mojaloopError }).info(`Sending error response to ${sourceFspId}`);
161
+ return this._mojaloopRequests.putParticipantsError(
162
+ idType, idValue, idSubValue, mojaloopError, sourceFspId, headers
163
+ );
155
164
  }
156
165
  }
157
166
 
@@ -173,26 +182,16 @@ class InboundTransfersModel {
173
182
  party: shared.internalPartyToMojaloopParty(response, this._dfspId, this._supportedCurrencies)
174
183
  };
175
184
 
176
- let { tracestate = undefined, traceparent = undefined } = headers;
177
-
178
- if (tracestate && traceparent) {
179
- const TRACESTATE_KEY_CALLBACK_START_TS = 'tx_callback_start_ts';
180
- tracestate += `,${TRACESTATE_KEY_CALLBACK_START_TS}=${Date.now()}`;
181
- return this._mojaloopRequests.putParties(idType, idValue, idSubValue, mlParty, sourceFspId, { tracestate, traceparent });
185
+ if (headers.tracestate && headers.traceparent) {
186
+ headers.tracestate += `,${TRACESTATE_KEY_CALLBACK_START_TS}=${Date.now()}`;
182
187
  }
183
-
184
- // make a callback to the source fsp with the party info
185
- const partyInfo = await this._mojaloopRequests.putParties(idType, idValue, idSubValue, mlParty, sourceFspId);
186
-
187
- return partyInfo;
188
-
188
+ return this._mojaloopRequests.putParties(idType, idValue, idSubValue, mlParty, sourceFspId, headers);
189
189
  }
190
- catch(err) {
190
+ catch (err) {
191
191
  this._logger.isErrorEnabled && this._logger.push({ err, idValue }).error('Error in getParties');
192
192
  const mojaloopError = await this._handleError(err);
193
- this._logger.isDebugEnabled && this._logger.push({ mojaloopError }).debug(`Sending error response to ${sourceFspId}`);
194
- return this._mojaloopRequests.putPartiesError(idType, idValue, idSubValue,
195
- mojaloopError, sourceFspId);
193
+ this._logger.isInfoEnabled && this._logger.push({ mojaloopError }).info(`Sending error response to ${sourceFspId}`);
194
+ return this._mojaloopRequests.putPartiesError(idType, idValue, idSubValue, mojaloopError, sourceFspId, headers);
196
195
  }
197
196
  }
198
197
 
@@ -258,40 +257,32 @@ class InboundTransfersModel {
258
257
  };
259
258
  await this._save();
260
259
 
261
- let res;
262
-
263
- let { tracestate = undefined, traceparent = undefined } = headers;
264
-
265
-
266
- // make a callback to the source fsp with the quote response
267
- if (tracestate && traceparent) {
268
- const TRACESTATE_KEY_CALLBACK_START_TS = 'tx_callback_start_ts';
269
- tracestate += `,${TRACESTATE_KEY_CALLBACK_START_TS}=${Date.now()}`;
270
- res = await this._mojaloopRequests.putQuotes(quoteRequest.quoteId, mojaloopResponse, sourceFspId, { tracestate, traceparent }, { isoPostQuote: request.isoPostQuote });
271
- } else {
272
- res = await this._mojaloopRequests.putQuotes(quoteRequest.quoteId, mojaloopResponse, sourceFspId, undefined, { isoPostQuote: request.isoPostQuote });
260
+ if (headers.tracestate && headers.traceparent) {
261
+ headers.tracestate += `,${TRACESTATE_KEY_CALLBACK_START_TS}=${Date.now()}`;
273
262
  }
263
+ const res = await this._mojaloopRequests.putQuotes(quoteRequest.quoteId, mojaloopResponse, sourceFspId, headers, { isoPostQuote: request.isoPostQuote });
264
+
274
265
  this.data.quoteResponse = {
275
266
  headers: res.originalRequest.headers,
276
267
  body: mojaloopResponse,
277
268
  };
278
269
  this.data.currentState = SDKStateEnum.WAITING_FOR_QUOTE_ACCEPTANCE;
270
+
279
271
  await this._save();
280
272
  return res;
281
273
  }
282
- catch(err) {
274
+ catch (err) {
283
275
  this._logger.push({ err }).error('Error in quoteRequest');
284
276
  const mojaloopError = await this._handleError(err);
285
- this._logger.isDebugEnabled && this._logger.push({ mojaloopError }).debug(`Sending error response to ${sourceFspId}`);
286
- return await this._mojaloopRequests.putQuotesError(quoteRequest.quoteId,
287
- mojaloopError, sourceFspId);
277
+ this._logger.isInfoEnabled && this._logger.push({ mojaloopError }).info(`Sending error response to ${sourceFspId}`);
278
+ return this._mojaloopRequests.putQuotesError(quoteRequest.quoteId, mojaloopError, sourceFspId, headers);
288
279
  }
289
280
  }
290
281
 
291
282
  /**
292
283
  * Notifies backend about the transactionRequest callback
293
284
  */
294
- async putTransactionRequest(request, transactionRequestId, sourceFspId) {
285
+ async putTransactionRequest(request, transactionRequestId, sourceFspId, headers) {
295
286
  const putTransactionRequest = request.body;
296
287
 
297
288
  try {
@@ -319,9 +310,8 @@ class InboundTransfersModel {
319
310
  catch(err) {
320
311
  this._logger.push({ err, transactionRequestId }).error('Error in putTransactionRequest');
321
312
  const mojaloopError = await this._handleError(err);
322
- this._logger.isDebugEnabled && this._logger.push({ mojaloopError }).debug(`Sending error response to ${sourceFspId}`);
323
- return await this._mojaloopRequests.putQuotesError(transactionRequestId,
324
- mojaloopError, sourceFspId);
313
+ this._logger.isInfoEnabled && this._logger.push({ mojaloopError }).info(`Sending error response to ${sourceFspId}`);
314
+ return await this._mojaloopRequests.putQuotesError(transactionRequestId, mojaloopError, sourceFspId, headers);
325
315
  }
326
316
  }
327
317
 
@@ -329,7 +319,7 @@ class InboundTransfersModel {
329
319
  * This is executed as when GET /quotes/{ID} request is made to get the response of a previous POST /quotes request.
330
320
  * Gets the quoteResponse from the cache and makes a callback to the originator with result
331
321
  */
332
- async getQuoteRequest(quoteId, sourceFspId) {
322
+ async getQuoteRequest(quoteId, sourceFspId, headers) {
333
323
  try {
334
324
  // Get the quoteResponse data for the quoteId from the cache to be sent as a response to GET /quotes/{ID}
335
325
  const quoteResponse = await this._cache.get(`quoteResponse_${quoteId}`);
@@ -339,16 +329,16 @@ class InboundTransfersModel {
339
329
  const err = new Error('Quote Id not found');
340
330
  const mojaloopError = await this._handleError(err, Errors.MojaloopApiErrorCodes.QUOTE_ID_NOT_FOUND);
341
331
  this._logger.push({ mojaloopError, quoteId }).warn(`Sending error response to ${sourceFspId}`);
342
- return await this._mojaloopRequests.putQuotesError(quoteId, mojaloopError, sourceFspId);
332
+ return await this._mojaloopRequests.putQuotesError(quoteId, mojaloopError, sourceFspId, headers);
343
333
  }
344
334
  // Make a PUT /quotes/{ID} callback to the source fsp with the quote response
345
- return this._mojaloopRequests.putQuotes(quoteId, quoteResponse, sourceFspId);
335
+ return this._mojaloopRequests.putQuotes(quoteId, quoteResponse, sourceFspId, headers);
346
336
  }
347
337
  catch(err) {
348
338
  this._logger.push({ err, quoteId }).error('Error in getQuoteRequest');
349
339
  const mojaloopError = await this._handleError(err);
350
- this._logger.isVerboseEnabled && this._logger.push({ mojaloopError }).verbose(`Sending error response to ${sourceFspId}`);
351
- return await this._mojaloopRequests.putQuotesError(quoteId, mojaloopError, sourceFspId);
340
+ this._logger.isInfoEnabled && this._logger.push({ mojaloopError }).info(`Sending error response to ${sourceFspId}`);
341
+ return this._mojaloopRequests.putQuotesError(quoteId, mojaloopError, sourceFspId, headers);
352
342
  }
353
343
  }
354
344
 
@@ -356,7 +346,7 @@ class InboundTransfersModel {
356
346
  * Asks the backend for a response to an incoming transactoin request and makes a callback to the originator with
357
347
  * the result
358
348
  */
359
- async transactionRequest(transactionRequest, sourceFspId) {
349
+ async transactionRequest(transactionRequest, sourceFspId, headers) {
360
350
  try {
361
351
  const internalForm = shared.mojaloopTransactionRequestToInternal(transactionRequest);
362
352
 
@@ -372,14 +362,17 @@ class InboundTransfersModel {
372
362
  const mojaloopResponse = shared.internalTransactionRequestResponseToMojaloop(response);
373
363
 
374
364
  // make a callback to the source fsp with the quote response
375
- return this._mojaloopRequests.putTransactionRequests(transactionRequest.transactionRequestId, mojaloopResponse, sourceFspId);
365
+ return this._mojaloopRequests.putTransactionRequests(
366
+ transactionRequest.transactionRequestId, mojaloopResponse, sourceFspId, headers
367
+ );
376
368
  }
377
- catch(err) {
369
+ catch (err) {
378
370
  this._logger.push({ err }).error(`Error in transactionRequest ${transactionRequest?.transactionRequestId}`);
379
371
  const mojaloopError = await this._handleError(err);
380
- this._logger.isDebugEnabled && this._logger.push({ mojaloopError }).debug(`Sending error response to ${sourceFspId}`);
381
- return this._mojaloopRequests.putTransactionRequestsError(transactionRequest.transactionRequestId,
382
- mojaloopError, sourceFspId);
372
+ this._logger.isInfoEnabled && this._logger.push({ mojaloopError }).info(`Sending error response to ${sourceFspId}`);
373
+ return this._mojaloopRequests.putTransactionRequestsError(
374
+ transactionRequest.transactionRequestId, mojaloopError, sourceFspId, headers
375
+ );
383
376
  }
384
377
  }
385
378
 
@@ -388,7 +381,7 @@ class InboundTransfersModel {
388
381
  * Validates an incoming transfer prepare request and makes a callback to the originator with
389
382
  * the result
390
383
  */
391
- async prepareTransfer(request, sourceFspId) {
384
+ async prepareTransfer(request, sourceFspId, headers) {
392
385
  const prepareRequest = request.body;
393
386
  try {
394
387
  // retrieve our quote data
@@ -408,8 +401,10 @@ class InboundTransfersModel {
408
401
  // This is a different to the a typical mojaloop sdk-scheme-adapter setup which allows this as an option.
409
402
 
410
403
  // Check whether to allow transfers without a previous quote.
411
- if(!this._allowTransferWithoutQuote) {
412
- throw new Error(`Corresponding quote not found for transfer ${prepareRequest.transferId}`);
404
+ if (!this._allowTransferWithoutQuote) {
405
+ const errMessage = `Corresponding quote not found for transfer ${prepareRequest.transferId}`;
406
+ this._logger.isWarnEnabled && this._logger.warn(errMessage);
407
+ throw new Error(errMessage);
413
408
  }
414
409
 
415
410
  if (!this.data) {
@@ -425,18 +420,19 @@ class InboundTransfersModel {
425
420
  // Calculate or retrieve fulfilment and condition
426
421
  let fulfilment = null;
427
422
  let condition = null;
428
- if(quote) {
423
+ if (quote) {
429
424
  fulfilment = quote.fulfilment;
430
425
  condition = quote.mojaloopResponse.condition;
431
- }
432
- else {
426
+ } else {
433
427
  fulfilment = this._ilp.calculateFulfil(prepareRequest.ilpPacket);
434
428
  condition = this._ilp.calculateConditionFromFulfil(fulfilment);
435
429
  }
436
430
 
437
431
  // check incoming ILP matches our persisted values
438
- if(this._checkIlp && (prepareRequest.condition !== condition)) {
439
- throw new Error(`ILP condition in transfer prepare for ${prepareRequest.transferId} does not match quote`);
432
+ if (this._checkIlp && (prepareRequest.condition !== condition)) {
433
+ const errMessage = `ILP condition in transfer prepare for ${prepareRequest.transferId} does not match quote`;
434
+ this._logger.isWarnEnabled && this._logger.warn(errMessage);
435
+ throw new Error(errMessage);
440
436
  }
441
437
 
442
438
  if (this._rejectTransfersOnExpiredQuotes) {
@@ -446,7 +442,7 @@ class InboundTransfersModel {
446
442
  const error = Errors.MojaloopApiErrorObjectFromCode(Errors.MojaloopApiErrorCodes.QUOTE_EXPIRED);
447
443
  this._logger.isErrorEnabled && this._logger.error(`Error in prepareTransfer: quote expired for transfer ${prepareRequest.transferId}, system time=${now} > quote time=${expiration}`);
448
444
  await this.updateStateWithError(error);
449
- return this._mojaloopRequests.putTransfersError(prepareRequest.transferId, error, sourceFspId);
445
+ return this._mojaloopRequests.putTransfersError(prepareRequest.transferId, error, sourceFspId, headers);
450
446
  }
451
447
  }
452
448
 
@@ -461,7 +457,7 @@ class InboundTransfersModel {
461
457
  return 'No response from backend';
462
458
  }
463
459
 
464
- this._logger.isDebugEnabled && this._logger.debug(`Transfer accepted by backend returning homeTransactionId: ${response.homeTransactionId} for mojaloop transferId: ${prepareRequest.transferId}`);
460
+ this._logger.isVerboseEnabled && this._logger.verbose(`Transfer accepted by backend returning homeTransactionId: ${response.homeTransactionId} for mojaloop transferId: ${prepareRequest.transferId}`);
465
461
  this.data.homeTransactionId = response.homeTransactionId;
466
462
 
467
463
  // create a mojaloop transfer fulfil response
@@ -477,29 +473,32 @@ class InboundTransfersModel {
477
473
  };
478
474
 
479
475
  // make a callback to the source fsp with the transfer fulfilment
480
- const res = await this._mojaloopRequests.putTransfers(prepareRequest.transferId, mojaloopResponse,
481
- sourceFspId);
476
+ const res = await this._mojaloopRequests.putTransfers(
477
+ prepareRequest.transferId, mojaloopResponse, sourceFspId, headers
478
+ );
482
479
 
483
480
  this.data.fulfil = {
484
481
  headers: res.originalRequest.headers,
485
482
  body: mojaloopResponse,
486
483
  };
487
484
  this.data.currentState = response.transferState || (this._reserveNotification ? SDKStateEnum.RESERVED : SDKStateEnum.COMPLETED);
485
+
488
486
  await this._save();
489
487
  return res;
490
488
  } catch(err) {
491
- this._logger.isErrorEnabled && this._logger.push({ err }).error(`Error in prepareTransfer: ${request?.body?.transferId}`);
489
+ this._logger.isErrorEnabled && this._logger.push({ err }).error(`Error in prepareTransfer: ${prepareRequest?.transferId}`);
492
490
  const mojaloopError = await this._handleError(err);
493
- this._logger.isDebugEnabled && this._logger.push({ mojaloopError }).debug(`Sending error response to ${sourceFspId}`);
494
- return await this._mojaloopRequests.putTransfersError(prepareRequest.transferId,
495
- mojaloopError, sourceFspId);
491
+ this._logger.isInfoEnabled && this._logger.push({ mojaloopError }).info(`Sending error response to ${sourceFspId}`);
492
+ return this._mojaloopRequests.putTransfersError(
493
+ prepareRequest.transferId, mojaloopError, sourceFspId, headers
494
+ );
496
495
  }
497
496
  }
498
497
 
499
498
  /**
500
499
  * Queries details of a transfer
501
500
  */
502
- async getTransfer(transferId, sourceFspId) {
501
+ async getTransfer(transferId, sourceFspId, headers) {
503
502
  try {
504
503
  // make a call to the backend to get transfer details
505
504
  const response = await this._backendRequests.getTransfers(transferId);
@@ -541,19 +540,17 @@ class InboundTransfersModel {
541
540
  };
542
541
 
543
542
  // make a callback to the source fsp with the transfer fulfilment
544
- return this._mojaloopRequests.putTransfers(transferId, mojaloopResponse,
545
- sourceFspId);
543
+ return this._mojaloopRequests.putTransfers(transferId, mojaloopResponse, sourceFspId, headers);
546
544
  }
547
545
  catch (err) {
548
546
  this._logger.isErrorEnabled && this._logger.push({ err, transferId }).error('Error in getTransfers');
549
547
  const mojaloopError = await this._handleError(err);
550
- this._logger.isDebugEnabled && this._logger.push({ mojaloopError }).debug(`Sending error response to ${sourceFspId}`);
551
- return this._mojaloopRequests.putTransfersError(transferId,
552
- mojaloopError, sourceFspId);
548
+ this._logger.isInfoEnabled && this._logger.push({ mojaloopError }).info(`Sending error response to ${sourceFspId}`);
549
+ return this._mojaloopRequests.putTransfersError(transferId, mojaloopError, sourceFspId, headers);
553
550
  }
554
551
  }
555
552
 
556
- async postFxQuotes(request, sourceFspId) {
553
+ async postFxQuotes(request, sourceFspId, headers) {
557
554
  const { body } = request;
558
555
  try {
559
556
  this.data = dto.fxQuoteRequestStateDto(request);
@@ -579,11 +576,11 @@ class InboundTransfersModel {
579
576
  response: beResponse,
580
577
  mojaloopResponse,
581
578
  fulfilment
582
- // todo: think, if we need to store ilpPacket as well
579
+ // think, if we need to store ilpPacket as well
583
580
  };
584
581
  await this.saveFxState();
585
582
 
586
- const res = await this._mojaloopRequests.putFxQuotes(body.conversionRequestId, mojaloopResponse, sourceFspId);
583
+ const res = await this._mojaloopRequests.putFxQuotes(body.conversionRequestId, mojaloopResponse, sourceFspId, headers);
587
584
 
588
585
  this.data.fxQuoteResponse = {
589
586
  headers: res.originalRequest.headers,
@@ -595,15 +592,16 @@ class InboundTransfersModel {
595
592
 
596
593
  return res;
597
594
  } catch (err) {
598
- this._logger.push({ err }).error('Error in postFxQuotes');
595
+ this._logger.push({ err }).error(`Error in postFxQuotes [conversionRequestId: ${body.conversionRequestId}]`);
599
596
  const mojaloopError = await this._handleError(err);
600
597
  this._logger.push({ mojaloopError }).info(`Sending error response to ${sourceFspId}`);
601
- return this._mojaloopRequests
602
- .putFxQuotesError(body.conversionRequestId, mojaloopError, sourceFspId);
598
+ return this._mojaloopRequests.putFxQuotesError(
599
+ body.conversionRequestId, mojaloopError, sourceFspId, headers
600
+ );
603
601
  }
604
602
  }
605
603
 
606
- async postFxTransfers(request, sourceFspId) {
604
+ async postFxTransfers(request, sourceFspId, headers) {
607
605
  const { body } = request;
608
606
  try {
609
607
  // todo: assume commitRequestId from fxTransfer should be same as conversionTerms.conversionId from fxQuotes
@@ -634,7 +632,7 @@ class InboundTransfersModel {
634
632
  this._logger.error(`Error in prepareFxTransfer: fxQuote expired for fxTransfer ${body.commitRequestId}, system time=${now} > fxQuote time=${expiration}`);
635
633
  await this.updateStateWithError(error);
636
634
  // todo: maybe, throw error here, and process it in catch block?
637
- return this._mojaloopRequests.putFxTransfersError(body.commitRequestId, error, sourceFspId);
635
+ return this._mojaloopRequests.putFxTransfersError(body.commitRequestId, error, sourceFspId, headers);
638
636
  }
639
637
  }
640
638
 
@@ -651,23 +649,23 @@ class InboundTransfersModel {
651
649
 
652
650
  // create a mojaloop fxTransfer fulfil response
653
651
  const mojaloopResponse = shared.internalFxTransferResponseToMojaloop(beResponse, fulfilment);
654
- const res = await this._mojaloopRequests.putFxTransfers(body.commitRequestId, mojaloopResponse, sourceFspId);
652
+ const res = await this._mojaloopRequests.putFxTransfers(body.commitRequestId, mojaloopResponse, sourceFspId, headers);
655
653
 
656
654
  this.data.fulfil = {
657
655
  headers: res.originalRequest.headers,
658
656
  body: mojaloopResponse,
659
657
  };
660
-
661
658
  this.data.currentState = beResponse.conversionState;
662
659
  await this.saveFxState();
663
660
 
664
661
  return res;
665
662
  } catch (err) {
666
- this._logger.push({ err }).error('Error in postFxTransfer');
663
+ this._logger.push({ err }).error(`Error in postFxTransfer [commitRequestId: ${body.commitRequestId}]`);
667
664
  const mojaloopError = await this._handleError(err);
668
665
  this._logger.push({ mojaloopError }).info(`Sending error response to ${sourceFspId}`);
669
- return this._mojaloopRequests
670
- .putFxTransfersError(body.commitRequestId, mojaloopError, sourceFspId);
666
+ return this._mojaloopRequests.putFxTransfersError(
667
+ body.commitRequestId, mojaloopError, sourceFspId, headers
668
+ );
671
669
  }
672
670
  }
673
671
 
@@ -675,7 +673,7 @@ class InboundTransfersModel {
675
673
  * Asks the backend for a response to an incoming bulk quotes request and makes a callback to the originator with
676
674
  * the results.
677
675
  */
678
- async bulkQuoteRequest(bulkQuoteRequest, sourceFspId) {
676
+ async bulkQuoteRequest(bulkQuoteRequest, sourceFspId, headers) {
679
677
  const { bulkQuoteId } = bulkQuoteRequest;
680
678
  const fulfilments = {};
681
679
  try {
@@ -703,7 +701,7 @@ class InboundTransfersModel {
703
701
  const mojaloopIndividualQuote = mojaloopResponse.individualQuoteResults.find(
704
702
  (quoteResult) => quoteResult.quoteId === quote.quoteId
705
703
  );
706
- if(!mojaloopIndividualQuote.errorInformation) {
704
+ if (!mojaloopIndividualQuote.errorInformation) {
707
705
  const quoteRequest = {
708
706
  transactionId: quote.transactionId,
709
707
  quoteId: quote.quoteId,
@@ -718,8 +716,7 @@ class InboundTransfersModel {
718
716
  transferAmount: mojaloopIndividualQuote.transferAmount,
719
717
  note: mojaloopIndividualQuote.note || '',
720
718
  };
721
- const { fulfilment, ilpPacket, condition } = this._ilp.getQuoteResponseIlp(
722
- quoteRequest, quoteResponse);
719
+ const { fulfilment, ilpPacket, condition } = this._ilp.getQuoteResponseIlp(quoteRequest, quoteResponse);
723
720
 
724
721
  // mutate individual quotes in `mojaloopResponse`
725
722
  mojaloopIndividualQuote.ilpPacket = ilpPacket;
@@ -739,21 +736,20 @@ class InboundTransfersModel {
739
736
  });
740
737
 
741
738
  // make a callback to the source fsp with the quote response
742
- return this._mojaloopRequests.putBulkQuotes(bulkQuoteId, mojaloopResponse, sourceFspId);
739
+ return this._mojaloopRequests.putBulkQuotes(bulkQuoteId, mojaloopResponse, sourceFspId, headers);
743
740
  }
744
741
  catch (err) {
745
742
  this._logger.isErrorEnabled && this._logger.push({ err }).error('Error in bulkQuotesRequest');
746
743
  const mojaloopError = await this._handleError(err);
747
- this._logger.isDebugEnabled && this._logger.push({ mojaloopError }).debug(`Sending error response to ${sourceFspId}`);
748
- return await this._mojaloopRequests.putBulkQuotesError(bulkQuoteId,
749
- mojaloopError, sourceFspId);
744
+ this._logger.isInfoEnabled && this._logger.push({ mojaloopError }).info(`Sending error response to ${sourceFspId}`);
745
+ return this._mojaloopRequests.putBulkQuotesError(bulkQuoteId, mojaloopError, sourceFspId, headers);
750
746
  }
751
747
  }
752
748
 
753
749
  /**
754
750
  * Queries details of a bulk quote
755
751
  */
756
- async getBulkQuote(bulkQuoteId, sourceFspId) {
752
+ async getBulkQuote(bulkQuoteId, sourceFspId, headers) {
757
753
  try {
758
754
  // make a call to the backend to get bulk quote details
759
755
  const response = await this._backendRequests.getBulkQuotes(bulkQuoteId);
@@ -766,15 +762,13 @@ class InboundTransfersModel {
766
762
  const mojaloopResponse = shared.internalBulkQuotesResponseToMojaloop(response);
767
763
 
768
764
  // make a callback to the source fsp with the bulk quote response
769
- return this._mojaloopRequests.putBulkQuotes(bulkQuoteId, mojaloopResponse,
770
- sourceFspId);
765
+ return this._mojaloopRequests.putBulkQuotes(bulkQuoteId, mojaloopResponse, sourceFspId, headers);
771
766
  }
772
767
  catch (err) {
773
768
  this._logger.isErrorEnabled && this._logger.push({ err, bulkQuoteId }).error('Error in getBulkQuote');
774
769
  const mojaloopError = await this._handleError(err);
775
- this._logger.isDebugEnabled && this._logger.push({ mojaloopError }).debug(`Sending error response to ${sourceFspId}`);
776
- return this._mojaloopRequests.putBulkQuotesError(bulkQuoteId,
777
- mojaloopError, sourceFspId);
770
+ this._logger.isInfoEnabled && this._logger.push({ mojaloopError }).info(`Sending error response to ${sourceFspId}`);
771
+ return this._mojaloopRequests.putBulkQuotesError(bulkQuoteId, mojaloopError, sourceFspId, headers);
778
772
  }
779
773
  }
780
774
 
@@ -782,7 +776,7 @@ class InboundTransfersModel {
782
776
  * Validates an incoming bulk transfer prepare request and makes a callback to the originator with
783
777
  * the result
784
778
  */
785
- async prepareBulkTransfer(bulkPrepareRequest, sourceFspId) {
779
+ async prepareBulkTransfer(bulkPrepareRequest, sourceFspId, headers) {
786
780
  try {
787
781
  // retrieve bulk quote data
788
782
  const bulkQuote = await this._cache.get(`bulkQuotes_${bulkPrepareRequest.bulkQuoteId}`);
@@ -790,7 +784,9 @@ class InboundTransfersModel {
790
784
  if (!bulkQuote) {
791
785
  // Check whether to allow transfers without a previous quote.
792
786
  if (!this._allowTransferWithoutQuote) {
793
- throw new Error(`Corresponding bulk quotes not found for bulk transfers ${bulkPrepareRequest.bulkTransferId}`);
787
+ const errMessage = `Corresponding bulk quotes not found for bulk transfers ${bulkPrepareRequest.bulkTransferId}`;
788
+ this._logger.isWarnEnabled && this._logger.warn(errMessage);
789
+ throw new Error(errMessage);
794
790
  }
795
791
  }
796
792
 
@@ -846,7 +842,7 @@ class InboundTransfersModel {
846
842
  // TODO: Verify and align with actual schema for bulk transfers error endpoint
847
843
  const error = Errors.MojaloopApiErrorObjectFromCode(Errors.MojaloopApiErrorCodes.QUOTE_EXPIRED);
848
844
  this._logger.isErrorEnabled && this._logger.error(`Error in prepareBulkTransfers: bulk quotes expired for bulk transfers ${bulkPrepareRequest.bulkTransferId}, system time=${now.toISOString()} > quote time=${expiration.toISOString()}`);
849
- return this._mojaloopRequests.putBulkTransfersError(bulkPrepareRequest.bulkTransferId, error, sourceFspId);
845
+ return this._mojaloopRequests.putBulkTransfersError(bulkPrepareRequest.bulkTransferId, error, sourceFspId, headers);
850
846
  }
851
847
  }
852
848
 
@@ -863,8 +859,7 @@ class InboundTransfersModel {
863
859
  this._logger.isErrorEnabled && this._logger.push({ ...individualTransferErrors }).error('Error in prepareBulkTransfers');
864
860
  this._logger.isDebugEnabled && this._logger.push({ ...individualTransferErrors }).debug(`Sending error response to ${sourceFspId}`);
865
861
 
866
- return await this._mojaloopRequests.putBulkTransfersError(bulkPrepareRequest.transferId,
867
- mojaloopErrorResponse, sourceFspId);
862
+ return this._mojaloopRequests.putBulkTransfersError(bulkPrepareRequest.transferId, mojaloopErrorResponse, sourceFspId, headers);
868
863
  }
869
864
 
870
865
  // project the incoming bulk transfer prepare into an internal bulk transfer request
@@ -884,21 +879,20 @@ class InboundTransfersModel {
884
879
  const mojaloopResponse = shared.internalBulkTransfersResponseToMojaloop(response, fulfilments);
885
880
 
886
881
  // make a callback to the source fsp with the transfer fulfilment
887
- return this._mojaloopRequests.putBulkTransfers(bulkPrepareRequest.bulkTransferId, mojaloopResponse, sourceFspId);
882
+ return this._mojaloopRequests.putBulkTransfers(bulkPrepareRequest.bulkTransferId, mojaloopResponse, sourceFspId, headers);
888
883
  }
889
884
  catch (err) {
890
885
  this._logger.isErrorEnabled && this._logger.push({ err }).error('Error in prepareBulkTransfers');
891
886
  const mojaloopError = await this._handleError(err);
892
- this._logger.isDebugEnabled && this._logger.push({ mojaloopError }).debug(`Sending error response to ${sourceFspId}`);
893
- return await this._mojaloopRequests.putBulkTransfersError(bulkPrepareRequest.bulkTransferId,
894
- mojaloopError, sourceFspId);
887
+ this._logger.isInfoEnabled && this._logger.push({ mojaloopError }).info(`Sending error response to ${sourceFspId}`);
888
+ return this._mojaloopRequests.putBulkTransfersError(bulkPrepareRequest.bulkTransferId, mojaloopError, sourceFspId, headers);
895
889
  }
896
890
  }
897
891
 
898
892
  /**
899
893
  * Queries details of a bulk transfer
900
894
  */
901
- async getBulkTransfer(bulkTransferId, sourceFspId) {
895
+ async getBulkTransfer(bulkTransferId, sourceFspId, headers) {
902
896
  try {
903
897
  // make a call to the backend to get bulk transfer details
904
898
  const response = await this._backendRequests.getBulkTransfers(bulkTransferId);
@@ -944,15 +938,13 @@ class InboundTransfersModel {
944
938
  };
945
939
 
946
940
  // make a callback to the source fsp with the bulk transfer fulfilments
947
- return this._mojaloopRequests.putBulkTransfers(bulkTransferId, mojaloopResponse,
948
- sourceFspId);
941
+ return this._mojaloopRequests.putBulkTransfers(bulkTransferId, mojaloopResponse, sourceFspId, headers);
949
942
  }
950
943
  catch (err) {
951
944
  this._logger.isErrorEnabled && this._logger.push({ err, bulkTransferId }).error('Error in getBulkTransfer');
952
945
  const mojaloopError = await this._handleError(err);
953
- this._logger.isDebugEnabled && this._logger.push({ mojaloopError }).debug(`Sending error response to ${sourceFspId}`);
954
- return this._mojaloopRequests.putBulkTransfersError(bulkTransferId,
955
- mojaloopError, sourceFspId);
946
+ this._logger.isInfoEnabled && this._logger.push({ mojaloopError }).info(`Sending error response to ${sourceFspId}`);
947
+ return this._mojaloopRequests.putBulkTransfersError(bulkTransferId, mojaloopError, sourceFspId, headers);
956
948
  }
957
949
  }
958
950
 
@@ -33,6 +33,7 @@ const { Enum, Util: { id: idGenerator } } = require('@mojaloop/central-services-
33
33
  const { Ilp, MojaloopRequests } = require('@mojaloop/sdk-standard-components');
34
34
 
35
35
  const { API_TYPES } = require('../../constants');
36
+ const { generateTraceparent } = require('../../lib/utils');
36
37
  const dto = require('../dto');
37
38
  const shared = require('./lib/shared');
38
39
  const PartiesModel = require('./PartiesModel');
@@ -1233,7 +1234,7 @@ class OutboundTransfersModel {
1233
1234
  * Modifies the data being stored in the cache for UI before it is stored.
1234
1235
  * Works on a copy of original object to avoid side effects
1235
1236
  */
1236
- _modifyDataForUi( data ){
1237
+ _modifyDataForUi(data) {
1237
1238
  // deep cloning to avoid side effects
1238
1239
  let modifiedData = JSON.parse(JSON.stringify(data));
1239
1240
  // Removing iso quote response and extension lists
@@ -1516,21 +1517,18 @@ class OutboundTransfersModel {
1516
1517
  }
1517
1518
  }
1518
1519
 
1519
- #createOtelHeaders() {
1520
- const { traceId } = this.data;
1521
- const spanId = randomBytes(8).toString('hex');
1522
- const flags = '01';
1523
-
1524
- return Object.freeze({
1525
- traceparent: `00-${traceId}-${spanId}-${flags}`,
1526
- });
1527
- }
1528
-
1529
1520
  #generateTraceId() {
1530
1521
  // todo: add possibility to generate traceId based on transferId
1531
1522
  this.data.traceId = randomBytes(16).toString('hex');
1532
- this._logger.isVerboseEnabled && this._logger.verbose(`generated traceId: ${this.data.traceId}`);
1533
- return this.data.traceId;
1523
+ const { traceId, transferId } = this.data;
1524
+ this._logger.isInfoEnabled && this._logger.push({ traceId, transferId }).info('traceId is generated');
1525
+ return traceId;
1526
+ }
1527
+
1528
+ #createOtelHeaders() {
1529
+ return Object.freeze({
1530
+ traceparent: generateTraceparent(this.data.traceId),
1531
+ });
1534
1532
  }
1535
1533
  }
1536
1534
 
@@ -26,8 +26,8 @@
26
26
  ******/
27
27
  'use strict';
28
28
 
29
- const http = require('http');
30
- const { request } = require('@mojaloop/sdk-standard-components');
29
+ const http = require('node:http');
30
+ const { createHttpRequester } = require('@mojaloop/sdk-standard-components').httpRequester;
31
31
  const { buildUrl, HTTPResponseError } = require('./common');
32
32
 
33
33
 
@@ -38,6 +38,7 @@ class BackendRequests {
38
38
  constructor(config) {
39
39
  this.config = config;
40
40
  this.logger = config.logger.push({ component: BackendRequests.name });
41
+ this.requester = createHttpRequester({ logger: this.logger });
41
42
 
42
43
  // FSPID of THIS DFSP
43
44
  this.dfspId = config.dfspId;
@@ -268,7 +269,7 @@ class BackendRequests {
268
269
  async sendRequest(reqOptions) {
269
270
  try {
270
271
  this.logger.isVerboseEnabled && this.logger.push({ reqOptions }).verbose(`Executing HTTP ${reqOptions?.method}...`);
271
- const res = await request({ ...reqOptions, agent: this.agent });
272
+ const res = await this.requester.sendRequest({ ...reqOptions, agent: this.agent });
272
273
 
273
274
  const data = (res.headers['content-length'] === '0' || res.statusCode === 204)
274
275
  ? null
@@ -26,6 +26,7 @@
26
26
  ******/
27
27
 
28
28
  const { hostname } = require('node:os');
29
+ const { randomBytes } = require('node:crypto');
29
30
  const { WSO2Auth, Logger } = require('@mojaloop/sdk-standard-components');
30
31
 
31
32
  const SDK_LOGGER_HIERARCHY = Logger.Logger.logLevels.reverse();
@@ -79,8 +80,15 @@ const transformHeadersIsoToFspiop = (isoHeaders) => {
79
80
  return fspiopHeaders;
80
81
  };
81
82
 
83
+ const generateTraceparent = (traceId = randomBytes(16).toString('hex')) => {
84
+ const spanId = randomBytes(8).toString('hex');
85
+ const flags = '01';
86
+ return `00-${traceId}-${spanId}-${flags}`;
87
+ };
88
+
82
89
  module.exports = {
83
90
  createAuthClient,
84
91
  createLogger,
92
+ generateTraceparent,
85
93
  transformHeadersIsoToFspiop
86
94
  };
@@ -32,6 +32,7 @@ const util = require('util');
32
32
  const {
33
33
  axios,
34
34
  MojaloopRequests, Errors, WSO2Auth, Jws, Logger, common,
35
+ httpRequester,
35
36
  Ilp: { ILP_VERSIONS }
36
37
  } = jest.requireActual('@mojaloop/sdk-standard-components');
37
38
 
@@ -190,7 +191,7 @@ class MockJwsSigner {
190
191
  constructor(config) {
191
192
  assert(config.logger, 'Must supply a logger to JWS signer constructor');
192
193
  this.config = config;
193
- config.logger.log(`MockJwsSigner constructed with config: ${util.inspect(config)}`);
194
+ config.logger.info(`MockJwsSigner constructed with config: ${util.inspect(config)}`);
194
195
  }
195
196
  }
196
197
 
@@ -198,6 +199,7 @@ class MockJwsSigner {
198
199
  module.exports = {
199
200
  axios,
200
201
  Ilp,
202
+ httpRequester,
201
203
  MojaloopRequests: MockMojaloopRequests,
202
204
  Jws: {
203
205
  validator: MockJwsValidator,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mojaloop/sdk-scheme-adapter",
3
- "version": "24.2.0-csi-1210.2",
3
+ "version": "24.2.0-csi-1210.4",
4
4
  "description": "mojaloop sdk-scheme-adapter",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/mojaloop/sdk-scheme-adapter",