account-lookup-service 17.8.0-snapshot.12 → 17.8.0-snapshot.14

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.8.0-snapshot.12",
4
+ "version": "17.8.0-snapshot.14",
5
5
  "license": "Apache-2.0",
6
6
  "author": "ModusBox",
7
7
  "contributors": [
@@ -99,7 +99,7 @@
99
99
  "@mojaloop/database-lib": "11.1.4",
100
100
  "@mojaloop/event-sdk": "14.4.0",
101
101
  "@mojaloop/inter-scheme-proxy-cache-lib": "2.4.0",
102
- "@mojaloop/ml-schema-transformer-lib": "2.7.0",
102
+ "@mojaloop/ml-schema-transformer-lib": "2.7.1",
103
103
  "@mojaloop/sdk-standard-components": "19.11.3-snapshot.0",
104
104
  "@now-ims/hapi-now-auth": "2.1.0",
105
105
  "ajv": "8.17.1",
@@ -30,6 +30,7 @@ const { Enum } = require('@mojaloop/central-services-shared')
30
30
  const { decodePayload } = require('@mojaloop/central-services-shared').Util.StreamingProtocol
31
31
  const { initStepState } = require('../../../lib/util')
32
32
  const { createCallbackHeaders } = require('../../../lib/headers')
33
+ const { ERROR_MESSAGES } = require('../../../constants')
33
34
 
34
35
  const { FspEndpointTypes, FspEndpointTemplates } = Enum.EndPoints
35
36
  const { Headers, RestMethods } = Enum.Http
@@ -123,8 +124,34 @@ class BasePartiesService {
123
124
  }
124
125
 
125
126
  async validateParticipant (participantId) {
126
- this.stepInProgress('validateParticipant')
127
- return this.deps.participant.validateParticipant(participantId)
127
+ try {
128
+ this.stepInProgress('validateParticipant')
129
+ return this.deps.participant.validateParticipant(participantId)
130
+ } catch (err) {
131
+ this.log.warn(`error in validateParticipant ${participantId}: `, err)
132
+ return null
133
+ }
134
+ }
135
+
136
+ async identifyDestinationForCallback () {
137
+ this.stepInProgress('identifyDestinationForCallback')
138
+ const { destination } = this.state
139
+
140
+ const schemeParticipant = await this.validateParticipant(destination)
141
+ if (schemeParticipant) {
142
+ this.state.requester = destination
143
+ return
144
+ }
145
+
146
+ const proxyName = this.state.proxyEnabled && await this.deps.proxyCache.lookupProxyByDfspId(destination)
147
+ if (proxyName) {
148
+ this.state.requester = proxyName
149
+ return
150
+ }
151
+
152
+ const errMessage = ERROR_MESSAGES.partyDestinationFspNotFound
153
+ this.log.warn(`${errMessage} and no proxy`, { destination })
154
+ throw ErrorHandler.Factory.createFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.DESTINATION_FSP_ERROR, errMessage)
128
155
  }
129
156
 
130
157
  async sendErrorCallback ({ errorInfo, headers, params }) {
@@ -25,8 +25,6 @@
25
25
  --------------
26
26
  ******/
27
27
 
28
- const ErrorHandler = require('@mojaloop/central-services-error-handling')
29
- const { ERROR_MESSAGES } = require('../../../constants')
30
28
  const BasePartiesService = require('./BasePartiesService')
31
29
 
32
30
  class PutPartiesErrorService extends BasePartiesService {
@@ -51,7 +49,7 @@ class PutPartiesErrorService extends BasePartiesService {
51
49
  }
52
50
  }
53
51
 
54
- await this.identifyDestinationForErrorCallback()
52
+ await this.identifyDestinationForCallback()
55
53
  await this.sendErrorCallbackToParticipant()
56
54
  this.log.info('putPartiesByTypeAndID is done')
57
55
  }
@@ -72,27 +70,6 @@ class PutPartiesErrorService extends BasePartiesService {
72
70
  return isLast
73
71
  }
74
72
 
75
- async identifyDestinationForErrorCallback () {
76
- this.stepInProgress('identifyDestinationForErrorCallback')
77
- const { destination } = this.state
78
- const schemeParticipant = await super.validateParticipant(destination)
79
- if (schemeParticipant) {
80
- this.state.requester = destination
81
- return
82
- }
83
-
84
- this.stepInProgress('lookupProxyDestination-4')
85
- const proxyName = this.state.proxyEnabled && await this.deps.proxyCache.lookupProxyByDfspId(destination)
86
- if (proxyName) {
87
- this.state.requester = proxyName
88
- return
89
- }
90
-
91
- const errMessage = ERROR_MESSAGES.partyDestinationFspNotFound
92
- this.log.warn(errMessage, { destination })
93
- throw ErrorHandler.Factory.createFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.DESTINATION_FSP_ERROR, errMessage)
94
- }
95
-
96
73
  async sendErrorCallbackToParticipant () {
97
74
  const { headers, params, dataUri } = this.inputs
98
75
  const errorInfo = PutPartiesErrorService.decodeDataUriPayload(dataUri)
@@ -25,7 +25,6 @@
25
25
  --------------
26
26
  ******/
27
27
 
28
- const ErrorHandler = require('@mojaloop/central-services-error-handling')
29
28
  const { ERROR_MESSAGES } = require('../../../constants')
30
29
  const BasePartiesService = require('./BasePartiesService')
31
30
 
@@ -40,7 +39,7 @@ class PutPartiesService extends BasePartiesService {
40
39
  if (proxy) {
41
40
  await this.checkProxySuccessResponse()
42
41
  }
43
- await this.identifyDestinationForSuccessCallback()
42
+ await this.identifyDestinationForCallback()
44
43
  await this.sendSuccessCallback()
45
44
  }
46
45
 
@@ -85,25 +84,6 @@ class PutPartiesService extends BasePartiesService {
85
84
  }
86
85
  }
87
86
 
88
- async identifyDestinationForSuccessCallback () {
89
- const { destination } = this.state
90
- this.stepInProgress('identifyDestinationForSuccessCallback')
91
- const destinationParticipant = await super.validateParticipant(destination)
92
- if (destinationParticipant) {
93
- this.state.requester = destinationParticipant.name
94
- return
95
- }
96
-
97
- const proxyName = this.state.proxyEnabled && await this.deps.proxyCache.lookupProxyByDfspId(destination)
98
- if (!proxyName) {
99
- const errMessage = ERROR_MESSAGES.partyDestinationFspNotFound
100
- this.log.warn(`${errMessage} and no proxy`, { destination })
101
- throw ErrorHandler.Factory.createFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.DESTINATION_FSP_ERROR, errMessage)
102
- }
103
-
104
- this.state.requester = proxyName
105
- }
106
-
107
87
  async sendSuccessCallback () {
108
88
  const { headers, params, dataUri } = this.inputs
109
89
  const sendTo = this.state.requester
@@ -52,7 +52,7 @@ class TimeoutPartiesService extends PutPartiesErrorService {
52
52
  const { errorInfo, headers, params } = await this.prepareErrorInformation()
53
53
  this.#spanAuditStart(errorInfo)
54
54
 
55
- await this.identifyDestinationForErrorCallback()
55
+ await this.identifyDestinationForCallback()
56
56
  return super.sendErrorCallback({ errorInfo, headers, params })
57
57
  }
58
58
 
@@ -587,20 +587,20 @@ describe('Parties Tests', () => {
587
587
  it('successfully sends the callback to the participant', async () => {
588
588
  expect.hasAssertions()
589
589
  // Arrange
590
- participant.validateParticipant = sandbox.stub().resolves({
591
- name: 'fsp1'
592
- })
590
+ participant.validateParticipant = sandbox.stub().resolves({})
593
591
  participant.sendRequest = sandbox.stub().resolves()
594
592
  const payload = JSON.stringify({ testPayload: true })
595
593
  const dataUri = encodePayload(payload, 'application/json')
594
+ const destination = 'destFsp'
595
+ const headers = fixtures.partiesCallHeadersDto({ destination })
596
596
 
597
597
  // Act
598
- await partiesDomain.putPartiesByTypeAndID(Helper.putByTypeIdRequest.headers, Helper.putByTypeIdRequest.params, 'put', payload, dataUri, null, proxyCache)
598
+ await partiesDomain.putPartiesByTypeAndID(headers, Helper.putByTypeIdRequest.params, 'put', payload, dataUri, null, proxyCache)
599
599
 
600
600
  // Assert
601
601
  expect(participant.sendRequest.callCount).toBe(1)
602
602
  const sendRequestCallArgs = participant.sendRequest.getCall(0).args
603
- expect(sendRequestCallArgs[1]).toStrictEqual('fsp1')
603
+ expect(sendRequestCallArgs[1]).toBe(destination)
604
604
  participant.sendRequest.reset()
605
605
  })
606
606