account-lookup-service 17.8.0-snapshot.12 → 17.8.0-snapshot.13
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 +2 -2
- package/src/domain/parties/services/BasePartiesService.js +22 -0
- package/src/domain/parties/services/PutPartiesErrorService.js +1 -24
- package/src/domain/parties/services/PutPartiesService.js +1 -21
- package/src/domain/parties/services/TimeoutPartiesService.js +1 -1
- package/test/unit/domain/parties/parties.test.js +5 -5
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.
|
4
|
+
"version": "17.8.0-snapshot.13",
|
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.
|
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
|
@@ -127,6 +128,27 @@ class BasePartiesService {
|
|
127
128
|
return this.deps.participant.validateParticipant(participantId)
|
128
129
|
}
|
129
130
|
|
131
|
+
async identifyDestinationForCallback () {
|
132
|
+
this.stepInProgress('identifyDestinationForCallback')
|
133
|
+
const { destination } = this.state
|
134
|
+
|
135
|
+
const schemeParticipant = await this.validateParticipant(destination)
|
136
|
+
if (schemeParticipant) {
|
137
|
+
this.state.requester = destination
|
138
|
+
return
|
139
|
+
}
|
140
|
+
|
141
|
+
const proxyName = this.state.proxyEnabled && await this.deps.proxyCache.lookupProxyByDfspId(destination)
|
142
|
+
if (proxyName) {
|
143
|
+
this.state.requester = proxyName
|
144
|
+
return
|
145
|
+
}
|
146
|
+
|
147
|
+
const errMessage = ERROR_MESSAGES.partyDestinationFspNotFound
|
148
|
+
this.log.warn(`${errMessage} and no proxy`, { destination })
|
149
|
+
throw ErrorHandler.Factory.createFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.DESTINATION_FSP_ERROR, errMessage)
|
150
|
+
}
|
151
|
+
|
130
152
|
async sendErrorCallback ({ errorInfo, headers, params }) {
|
131
153
|
this.stepInProgress('sendErrorCallback')
|
132
154
|
const sendTo = this.state.requester || this.state.source
|
@@ -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.
|
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.
|
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.
|
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(
|
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]).
|
603
|
+
expect(sendRequestCallArgs[1]).toBe(destination)
|
604
604
|
participant.sendRequest.reset()
|
605
605
|
})
|
606
606
|
|