account-lookup-service 17.13.0-snapshot.4 → 17.13.0-snapshot.6

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "account-lookup-service",
3
3
  "description": "Account Lookup Service is used to validate Party and Participant lookups.",
4
- "version": "17.13.0-snapshot.4",
4
+ "version": "17.13.0-snapshot.6",
5
5
  "license": "Apache-2.0",
6
6
  "author": "ModusBox",
7
7
  "contributors": [
package/src/constants.js CHANGED
@@ -29,7 +29,7 @@ const { API_TYPES } = require('@mojaloop/central-services-shared').Util.Hapi
29
29
 
30
30
  const ERROR_MESSAGES = Object.freeze({
31
31
  emptyFilteredPartyList: 'Empty oracle partyList, filtered based on callbackEndpointType',
32
- externalPartyError: 'External party error', // todo: think better message
32
+ externalPartyError: 'External party resolution error',
33
33
  failedToCacheSendToProxiesList: 'Failed to cache sendToProxiesList',
34
34
  noDiscoveryRequestsForwarded: 'No discovery requests forwarded to participants',
35
35
  sourceFspNotFound: 'Requester FSP not found',
@@ -26,12 +26,10 @@
26
26
  ******/
27
27
 
28
28
  const ErrorHandler = require('@mojaloop/central-services-error-handling')
29
- const { Enum } = require('@mojaloop/central-services-shared')
30
- const { decodePayload } = require('@mojaloop/central-services-shared').Util.StreamingProtocol
29
+ const { Enum, Util } = require('@mojaloop/central-services-shared')
31
30
  const { initStepState } = require('../../../lib/util')
32
31
  const { createCallbackHeaders } = require('../../../lib/headers')
33
32
  const { ERROR_MESSAGES } = require('../../../constants')
34
- const { makeAcceptContentTypeHeader } = require('@mojaloop/central-services-shared').Util.Headers
35
33
 
36
34
  const { FspEndpointTypes, FspEndpointTemplates } = Enum.EndPoints
37
35
  const { Headers, RestMethods, HeaderResources } = Enum.Http
@@ -178,7 +176,7 @@ class BasePartiesService {
178
176
  const { headers, params, query } = this.inputs
179
177
 
180
178
  const response = await this.deps.oracle.oracleRequest(headers, RestMethods.GET, params, query, undefined, this.deps.cache)
181
- this.log.debug('oracle discovery raw response:', { response })
179
+ this.log.verbose('oracle discovery raw response:', { response })
182
180
 
183
181
  let { partyList } = response?.data || {}
184
182
  if (!Array.isArray(partyList)) {
@@ -204,6 +202,22 @@ class BasePartiesService {
204
202
  return isRemoved
205
203
  }
206
204
 
205
+ async sendPartyResolutionErrorCallback () {
206
+ this.stepInProgress('sendPartyResolutionErrorCallback')
207
+ const { headers, params } = this.inputs
208
+ const error = this.createFspiopPartyResolutionError(ERROR_MESSAGES.externalPartyError)
209
+ const callbackHeaders = BasePartiesService.createErrorCallbackHeaders(headers, params, this.state.destination)
210
+ const errorInfo = await this.deps.partiesUtils.makePutPartiesErrorPayload(this.deps.config, error, callbackHeaders, params)
211
+
212
+ await this.identifyDestinationForCallback()
213
+ await this.sendErrorCallback({
214
+ errorInfo,
215
+ headers: callbackHeaders,
216
+ params
217
+ })
218
+ this.log.verbose('sendPartyResolutionErrorCallback is done', { callbackHeaders, errorInfo })
219
+ }
220
+
207
221
  createFspiopIdNotFoundError (errMessage, log = this.log) {
208
222
  log.warn(errMessage)
209
223
  return ErrorHandler.Factory.createFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.ID_NOT_FOUND, errMessage)
@@ -242,7 +256,7 @@ class BasePartiesService {
242
256
  }
243
257
 
244
258
  static decodeDataUriPayload (dataUri) {
245
- const decoded = decodePayload(dataUri, { asParsed: false })
259
+ const decoded = Util.StreamingProtocol.decodePayload(dataUri, { asParsed: false })
246
260
  return decoded.body.toString()
247
261
  }
248
262
 
@@ -277,7 +291,7 @@ class BasePartiesService {
277
291
  return {
278
292
  [Headers.FSPIOP.SOURCE]: hubName,
279
293
  [Headers.FSPIOP.DESTINATION]: destination,
280
- [Headers.GENERAL.CONTENT_TYPE.value]: makeAcceptContentTypeHeader(
294
+ [Headers.GENERAL.CONTENT_TYPE.value]: Util.Headers.makeAcceptContentTypeHeader(
281
295
  HeaderResources.PARTIES,
282
296
  config.PROTOCOL_VERSIONS.CONTENT.DEFAULT.toString(),
283
297
  config.API_TYPE
@@ -108,7 +108,7 @@ class GetPartiesService extends BasePartiesService {
108
108
  const isValid = await this.#validateLocalDestinationForExternalSource()
109
109
  if (!isValid) {
110
110
  log.warn('incorrect destination from external source', { destination })
111
- await this.#sendPartyNotFoundErrorCallback(headers)
111
+ await this.sendPartyResolutionErrorCallback()
112
112
  return
113
113
  }
114
114
  }
@@ -181,6 +181,7 @@ class GetPartiesService extends BasePartiesService {
181
181
  if (!filteredPartyList.length) {
182
182
  throw super.createFspiopIdNotFoundError(ERROR_MESSAGES.emptyFilteredPartyList)
183
183
  }
184
+ this.log.verbose('#filterOraclePartyList is done:', { filteredPartyList })
184
185
 
185
186
  return filteredPartyList
186
187
  }
@@ -26,7 +26,6 @@
26
26
  ******/
27
27
 
28
28
  const BasePartiesService = require('./BasePartiesService')
29
- const { ERROR_MESSAGES } = require('../../../constants')
30
29
 
31
30
  class PutPartiesErrorService extends BasePartiesService {
32
31
  async handleRequest () {
@@ -46,7 +45,7 @@ class PutPartiesErrorService extends BasePartiesService {
46
45
  this.log.info('Need to cleanup oracle and forward PARTY_RESOLUTION_FAILURE error')
47
46
  await this.cleanupOracle()
48
47
  await this.removeProxyGetPartiesTimeoutCache(alsReq)
49
- await this.#sendPartyResolutionErrorCallback()
48
+ await this.sendPartyResolutionErrorCallback()
50
49
  return
51
50
  }
52
51
  }
@@ -92,22 +91,6 @@ class PutPartiesErrorService extends BasePartiesService {
92
91
 
93
92
  return isExternal
94
93
  }
95
-
96
- async #sendPartyResolutionErrorCallback () {
97
- this.stepInProgress('#sendPartyResolutionErrorCallback')
98
- const { headers, params } = this.inputs
99
- const error = super.createFspiopPartyResolutionError(ERROR_MESSAGES.externalPartyError)
100
- const callbackHeaders = BasePartiesService.createErrorCallbackHeaders(headers, params, this.state.destination)
101
- const errorInfo = await this.deps.partiesUtils.makePutPartiesErrorPayload(this.deps.config, error, callbackHeaders, params)
102
-
103
- await this.identifyDestinationForCallback()
104
- await super.sendErrorCallback({
105
- errorInfo,
106
- headers: callbackHeaders,
107
- params
108
- })
109
- this.log.verbose('#sendPartyResolutionErrorCallback is done', { callbackHeaders, errorInfo })
110
- }
111
94
  }
112
95
 
113
96
  module.exports = PutPartiesErrorService
@@ -422,6 +422,7 @@ describe('GetPartiesService Tests -->', () => {
422
422
  partyList: [{ fspId: ORACLE_DFSP_DIFFERENT }]
423
423
  })
424
424
  )
425
+ proxyCache.lookupProxyByDfspId = jest.fn().mockResolvedValueOnce(PROXY_ID)
425
426
 
426
427
  const service = new GetPartiesService(deps, { headers, params })
427
428
  await service.handleRequest()