account-lookup-service 17.13.0-snapshot.5 → 17.13.0-snapshot.7

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.5",
4
+ "version": "17.13.0-snapshot.7",
5
5
  "license": "Apache-2.0",
6
6
  "author": "ModusBox",
7
7
  "contributors": [
@@ -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
@@ -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)
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
  }
@@ -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() // todo: think, if we need this?
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
@@ -41,6 +41,7 @@ const Config = require('../lib/config')
41
41
  */
42
42
  exports.createCallbackHeaders = (params) => {
43
43
  const callbackHeaders = { ...params.requestHeaders }
44
+ delete callbackHeaders[Enums.Http.Headers.FSPIOP.PROXY]
44
45
 
45
46
  callbackHeaders[Enums.Http.Headers.FSPIOP.SOURCE] = Config.HUB_NAME
46
47
  callbackHeaders[Enums.Http.Headers.FSPIOP.DESTINATION] = params.requestHeaders[Enums.Http.Headers.FSPIOP.SOURCE]
@@ -947,9 +947,10 @@ describe('Parties Tests', () => {
947
947
  Config.PROXY_CACHE_CONFIG.enabled = true
948
948
  const errorCode = MojaloopApiErrorCodes.PAYEE_IDENTIFIER_NOT_VALID.code
949
949
  const payload = fixtures.errorCallbackResponseDto({ errorCode })
950
+ const source = 'payerFsp'
950
951
  const destination = `dest-${Date.now()}`
951
952
  const proxy = `proxy-${Date.now()}`
952
- const headers = fixtures.partiesCallHeadersDto({ destination, proxy })
953
+ const headers = fixtures.partiesCallHeadersDto({ source, destination, proxy })
953
954
  const { params } = Helper.putByTypeIdRequest
954
955
  participant.validateParticipant = sandbox.stub().resolves(null) // external participant
955
956
  participant.sendRequest = sandbox.stub().resolves()
@@ -971,7 +972,8 @@ describe('Parties Tests', () => {
971
972
  // eslint-disable-next-line no-unused-vars
972
973
  const [sentTo, _, data, cbHeaders] = participant.sendErrorToParticipant.lastCall.args
973
974
  expect(sentTo).toBe(proxy)
974
- expect(cbHeaders[Headers.FSPIOP.DESTINATION]).toBe(destination)
975
+ expect(cbHeaders[Headers.FSPIOP.DESTINATION]).toBe(source)
976
+ expect(cbHeaders[Headers.FSPIOP.PROXY]).toBeUndefined()
975
977
  expect(data.errorInformation.errorCode).toBe('2006')
976
978
  })
977
979
  })
@@ -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()
@@ -46,12 +46,13 @@ describe('PutPartiesErrorService Tests -->', () => {
46
46
  oracle.oracleRequest = jest.fn().mockResolvedValue({
47
47
  data: { partyList: [{ fspId: 'fspId' }] }
48
48
  })
49
- const destination = 'externalDfsp'
49
+ const source = 'externalSource'
50
+ const destination = 'externalDestination'
50
51
  const proxyDest = 'proxyDest'
51
52
  const deps = createMockDeps({ oracle, participant })
52
53
  deps.proxyCache.lookupProxyByDfspId = jest.fn().mockResolvedValue(proxyDest)
53
54
 
54
- const headers = fixtures.partiesCallHeadersDto({ destination, proxy: 'proxyA' })
55
+ const headers = fixtures.partiesCallHeadersDto({ source, destination, proxy: 'proxyA' })
55
56
  const params = fixtures.partiesParamsDto()
56
57
  const dataUri = fixtures.dataUriDto()
57
58
 
@@ -64,7 +65,7 @@ describe('PutPartiesErrorService Tests -->', () => {
64
65
 
65
66
  const [sentTo, , payload, cbHeaders] = participant.sendErrorToParticipant.mock.lastCall
66
67
  expect(sentTo).toBe(proxyDest)
67
- expect(cbHeaders[Headers.FSPIOP.DESTINATION]).toBe(destination)
68
+ expect(cbHeaders[Headers.FSPIOP.DESTINATION]).toBe(source)
68
69
  expect(payload.errorInformation.errorCode).toBe('2006')
69
70
  })
70
71