account-lookup-service 17.3.1 → 17.4.0-csi-1233.0
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/audit-ci.jsonc
CHANGED
@@ -4,5 +4,7 @@
|
|
4
4
|
// Only use one of ["low": true, "moderate": true, "high": true, "critical": true]
|
5
5
|
"moderate": true,
|
6
6
|
// NOTE: Please add as much information as possible to any items added to the allowList
|
7
|
-
"allowlist": [
|
7
|
+
"allowlist": [
|
8
|
+
"GHSA-jr5f-v2jv-69x6" // https://github.com/advisories/GHSA-jr5f-v2jv-69x6
|
9
|
+
]
|
8
10
|
}
|
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.
|
4
|
+
"version": "17.4.0-csi-1233.0",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"author": "ModusBox",
|
7
7
|
"contributors": [
|
@@ -93,15 +93,15 @@
|
|
93
93
|
"@hapi/vision": "7.0.3",
|
94
94
|
"@mojaloop/central-services-error-handling": "13.0.7",
|
95
95
|
"@mojaloop/central-services-health": "15.0.4",
|
96
|
-
"@mojaloop/central-services-logger": "11.
|
96
|
+
"@mojaloop/central-services-logger": "11.6.1",
|
97
97
|
"@mojaloop/central-services-metrics": "12.4.5",
|
98
|
-
"@mojaloop/central-services-shared": "18.22.
|
98
|
+
"@mojaloop/central-services-shared": "18.22.2-snapshot.2",
|
99
99
|
"@mojaloop/central-services-stream": "11.5.1",
|
100
100
|
"@mojaloop/database-lib": "11.1.3",
|
101
101
|
"@mojaloop/event-sdk": "14.3.0",
|
102
102
|
"@mojaloop/inter-scheme-proxy-cache-lib": "2.3.7",
|
103
103
|
"@mojaloop/ml-schema-transformer-lib": "2.5.6",
|
104
|
-
"@mojaloop/sdk-standard-components": "19.
|
104
|
+
"@mojaloop/sdk-standard-components": "19.10.0",
|
105
105
|
"@now-ims/hapi-now-auth": "2.1.0",
|
106
106
|
"ajv": "8.17.1",
|
107
107
|
"ajv-keywords": "5.1.0",
|
@@ -32,7 +32,7 @@ const oracle = require('../../models/oracle/facade')
|
|
32
32
|
const participant = require('../../models/participantEndpoint/facade')
|
33
33
|
const { createCallbackHeaders } = require('../../lib/headers')
|
34
34
|
const { ERROR_MESSAGES } = require('../../constants')
|
35
|
-
const
|
35
|
+
const logger = require('../../lib').logger.child({ component: 'domain.getPartiesByTypeAndID' })
|
36
36
|
const Config = require('../../lib/config')
|
37
37
|
const utils = require('./utils')
|
38
38
|
const util = require('../../lib/util')
|
@@ -40,32 +40,32 @@ const util = require('../../lib/util')
|
|
40
40
|
const { FspEndpointTypes, FspEndpointTemplates } = Enum.EndPoints
|
41
41
|
const { Headers, RestMethods } = Enum.Http
|
42
42
|
|
43
|
-
const log = logger.child('domain:get-parties')
|
44
|
-
const handleErrorOnSendingCallback = utils.createErrorHandlerOnSendingCallback(Config, log)
|
45
|
-
|
46
43
|
const proxyCacheTtlSec = 40 // todo: make configurable
|
47
44
|
|
48
45
|
const validateRequester = async ({ source, proxy, proxyCache }) => {
|
46
|
+
const log = logger.child({ source, method: 'validateRequester' })
|
49
47
|
const sourceParticipant = await participant.validateParticipant(source)
|
50
48
|
if (sourceParticipant) {
|
51
|
-
log.debug('source is in scheme'
|
49
|
+
log.debug('source is in scheme')
|
52
50
|
return source
|
53
51
|
}
|
54
52
|
|
55
53
|
if (!proxy) {
|
56
54
|
const errMessage = ERROR_MESSAGES.sourceFspNotFound
|
55
|
+
log.warn(errMessage)
|
57
56
|
throw ErrorHandler.Factory.createFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.ID_NOT_FOUND, errMessage)
|
58
57
|
}
|
59
58
|
|
60
59
|
const proxyParticipant = await participant.validateParticipant(proxy)
|
61
60
|
if (!proxyParticipant) {
|
62
61
|
const errMessage = ERROR_MESSAGES.partyProxyNotFound
|
62
|
+
log.warn(errMessage, { proxy })
|
63
63
|
throw ErrorHandler.Factory.createFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.ID_NOT_FOUND, errMessage)
|
64
64
|
}
|
65
65
|
|
66
66
|
const isCached = await proxyCache.addDfspIdToProxyMapping(source, proxy)
|
67
67
|
// think, what if isCached !== true?
|
68
|
-
log.info('source is added to proxyMapping cache:', {
|
68
|
+
log.info('source is added to proxyMapping cache:', { proxy, isCached })
|
69
69
|
return proxy
|
70
70
|
}
|
71
71
|
|
@@ -88,6 +88,7 @@ const getPartiesByTypeAndID = async (headers, params, method, query, span, cache
|
|
88
88
|
'Get party by Type and Id',
|
89
89
|
['success']
|
90
90
|
).startTimer()
|
91
|
+
const log = logger.child({ params })
|
91
92
|
const proxyEnabled = !!(Config.PROXY_CACHE_CONFIG.enabled && proxyCache)
|
92
93
|
const type = params.Type
|
93
94
|
const partySubId = params.SubId
|
@@ -100,7 +101,7 @@ const getPartiesByTypeAndID = async (headers, params, method, query, span, cache
|
|
100
101
|
// without consulting any oracles.
|
101
102
|
|
102
103
|
const childSpan = span ? span.getChild('getPartiesByTypeAndID') : undefined
|
103
|
-
log.info('parties::getPartiesByTypeAndID
|
104
|
+
log.info('parties::getPartiesByTypeAndID start', { source, destination, proxy })
|
104
105
|
|
105
106
|
let requester
|
106
107
|
let fspiopError
|
@@ -155,6 +156,7 @@ const getPartiesByTypeAndID = async (headers, params, method, query, span, cache
|
|
155
156
|
|
156
157
|
if (!Array.isArray(filteredResponsePartyList) || !filteredResponsePartyList.length) {
|
157
158
|
const errMessage = 'Requested FSP/Party not found'
|
159
|
+
log.warn(errMessage)
|
158
160
|
throw ErrorHandler.Factory.createFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.ID_NOT_FOUND, errMessage)
|
159
161
|
}
|
160
162
|
|
@@ -169,7 +171,7 @@ const getPartiesByTypeAndID = async (headers, params, method, query, span, cache
|
|
169
171
|
const schemeParticipant = await participant.validateParticipant(fspId)
|
170
172
|
if (schemeParticipant) {
|
171
173
|
sentCount++
|
172
|
-
log.
|
174
|
+
log.verbose('participant is in scheme', { fspId })
|
173
175
|
return participant.sendRequest(clonedHeaders, party.fspId, callbackEndpointType, RestMethods.GET, undefined, options, childSpan)
|
174
176
|
}
|
175
177
|
|
@@ -183,7 +185,7 @@ const getPartiesByTypeAndID = async (headers, params, method, query, span, cache
|
|
183
185
|
// todo: delete reference in oracle
|
184
186
|
} else {
|
185
187
|
sentCount++
|
186
|
-
log.
|
188
|
+
log.verbose('participant is NOT in scheme, use proxy name', { fspId, proxyName })
|
187
189
|
return participant.sendRequest(clonedHeaders, proxyName, callbackEndpointType, RestMethods.GET, undefined, options, childSpan)
|
188
190
|
}
|
189
191
|
}
|
@@ -222,6 +224,7 @@ const getPartiesByTypeAndID = async (headers, params, method, query, span, cache
|
|
222
224
|
step = 'setSendToProxiesList-10'
|
223
225
|
const isCached = await proxyCache.setSendToProxiesList(alsReq, filteredProxyNames, proxyCacheTtlSec)
|
224
226
|
if (!isCached) {
|
227
|
+
log.warn('failed to setSendToProxiesList')
|
225
228
|
throw ErrorHandler.Factory.createFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.ID_NOT_FOUND, ERROR_MESSAGES.failedToCacheSendToProxiesList)
|
226
229
|
}
|
227
230
|
|
@@ -237,13 +240,14 @@ const getPartiesByTypeAndID = async (headers, params, method, query, span, cache
|
|
237
240
|
// todo: - think, if we should handle failed requests here (e.g., by calling receivedErrorResponse)
|
238
241
|
log.info('setSendToProxiesList flow is done:', { isOk, results, filteredProxyNames, alsReq })
|
239
242
|
if (!isOk) {
|
243
|
+
log.warn('no successful requests sent to proxies')
|
240
244
|
throw ErrorHandler.Factory.createFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.ID_NOT_FOUND, ERROR_MESSAGES.proxyConnectionError)
|
241
245
|
}
|
242
246
|
}
|
243
247
|
}
|
244
248
|
histTimerEnd({ success: true })
|
245
249
|
} catch (err) {
|
246
|
-
fspiopError = await
|
250
|
+
fspiopError = await utils.createErrorHandlerOnSendingCallback(Config, log)(err, headers, params, requester)
|
247
251
|
histTimerEnd({ success: false })
|
248
252
|
if (fspiopError) {
|
249
253
|
util.countFspiopError(fspiopError, { operation: 'getPartiesByTypeAndID', step })
|
@@ -38,15 +38,13 @@ const Metrics = require('@mojaloop/central-services-metrics')
|
|
38
38
|
const oracle = require('../../models/oracle/facade')
|
39
39
|
const participant = require('../../models/participantEndpoint/facade')
|
40
40
|
const { ERROR_MESSAGES } = require('../../constants')
|
41
|
-
const
|
41
|
+
const logger = require('../../lib').logger.child({ component: 'domain.putParties' })
|
42
|
+
|
42
43
|
const Config = require('../../lib/config')
|
43
44
|
const utils = require('./utils')
|
44
45
|
const util = require('../../lib/util')
|
45
46
|
const getPartiesByTypeAndID = require('./getPartiesByTypeAndID')
|
46
47
|
|
47
|
-
const log = logger.child('domain:put-parties')
|
48
|
-
const handleErrorOnSendingCallback = utils.createErrorHandlerOnSendingCallback(Config, log)
|
49
|
-
|
50
48
|
/**
|
51
49
|
* @function putPartiesByTypeAndID
|
52
50
|
*
|
@@ -66,13 +64,14 @@ const putPartiesByTypeAndID = async (headers, params, method, payload, dataUri,
|
|
66
64
|
'Put parties by type and id',
|
67
65
|
['success']
|
68
66
|
).startTimer()
|
67
|
+
const log = logger.child({ params, method: 'putPartiesByTypeAndID' })
|
69
68
|
const type = params.Type
|
70
69
|
const partySubId = params.SubId
|
71
70
|
const source = headers[Headers.FSPIOP.SOURCE]
|
72
71
|
const destination = headers[Headers.FSPIOP.DESTINATION]
|
73
72
|
const proxy = headers[Headers.FSPIOP.PROXY]
|
74
73
|
const proxyEnabled = !!(Config.PROXY_CACHE_CONFIG.enabled && proxyCache)
|
75
|
-
log.info('parties::putPartiesByTypeAndID
|
74
|
+
log.info('parties::putPartiesByTypeAndID start', { source, destination, proxy })
|
76
75
|
|
77
76
|
let sendTo
|
78
77
|
let step
|
@@ -82,6 +81,7 @@ const putPartiesByTypeAndID = async (headers, params, method, payload, dataUri,
|
|
82
81
|
if (!requesterParticipant) {
|
83
82
|
if (!proxyEnabled || !proxy) {
|
84
83
|
const errMessage = ERROR_MESSAGES.sourceFspNotFound
|
84
|
+
log.warn(`${errMessage} and no proxy`)
|
85
85
|
throw ErrorHandler.Factory.createFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.ID_NOT_FOUND, errMessage)
|
86
86
|
}
|
87
87
|
step = 'addDfspIdToProxyMapping-1'
|
@@ -96,14 +96,14 @@ const putPartiesByTypeAndID = async (headers, params, method, payload, dataUri,
|
|
96
96
|
const isExists = await proxyCache.receivedSuccessResponse(alsReq)
|
97
97
|
if (!isExists) {
|
98
98
|
log.warn('destination is NOT in scheme, and no cached sendToProxiesList', { destination, alsReq })
|
99
|
-
// think, if we need to throw an error here
|
99
|
+
// todo: think, if we need to throw an error here
|
100
100
|
} else {
|
101
101
|
const mappingPayload = {
|
102
102
|
fspId: source
|
103
103
|
}
|
104
104
|
step = 'oracleRequest-3'
|
105
105
|
await oracle.oracleRequest(headers, RestMethods.POST, params, null, mappingPayload, cache)
|
106
|
-
log.info('oracle was updated with mappingPayload', { mappingPayload
|
106
|
+
log.info('oracle was updated with mappingPayload', { mappingPayload })
|
107
107
|
}
|
108
108
|
}
|
109
109
|
step = 'validateParticipant-4'
|
@@ -113,6 +113,7 @@ const putPartiesByTypeAndID = async (headers, params, method, payload, dataUri,
|
|
113
113
|
const proxyName = proxyEnabled && await proxyCache.lookupProxyByDfspId(destination)
|
114
114
|
if (!proxyName) {
|
115
115
|
const errMessage = ERROR_MESSAGES.partyDestinationFspNotFound
|
116
|
+
log.warn(errMessage)
|
116
117
|
throw ErrorHandler.Factory.createFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.DESTINATION_FSP_ERROR, errMessage)
|
117
118
|
}
|
118
119
|
sendTo = proxyName
|
@@ -133,7 +134,7 @@ const putPartiesByTypeAndID = async (headers, params, method, payload, dataUri,
|
|
133
134
|
log.info('parties::putPartiesByTypeAndID::callback was sent', { sendTo, options })
|
134
135
|
histTimerEnd({ success: true })
|
135
136
|
} catch (err) {
|
136
|
-
const fspiopError = await
|
137
|
+
const fspiopError = await utils.createErrorHandlerOnSendingCallback(Config, log)(err, headers, params, sendTo)
|
137
138
|
if (fspiopError) {
|
138
139
|
util.countFspiopError(fspiopError, { operation: 'putPartiesByTypeAndID', step })
|
139
140
|
}
|
@@ -160,6 +161,7 @@ const putPartiesErrorByTypeAndID = async (headers, params, payload, dataUri, spa
|
|
160
161
|
'Put parties error by type and id',
|
161
162
|
['success']
|
162
163
|
).startTimer()
|
164
|
+
const log = logger.child({ params, method: 'putPartiesErrorByTypeAndID' })
|
163
165
|
const partySubId = params.SubId
|
164
166
|
const destination = headers[Headers.FSPIOP.DESTINATION]
|
165
167
|
const callbackEndpointType = utils.errorPartyCbType(partySubId)
|
@@ -203,6 +205,7 @@ const putPartiesErrorByTypeAndID = async (headers, params, payload, dataUri, spa
|
|
203
205
|
const proxyName = proxyEnabled && await proxyCache.lookupProxyByDfspId(destination)
|
204
206
|
if (!proxyName) {
|
205
207
|
const errMessage = ERROR_MESSAGES.partyDestinationFspNotFound
|
208
|
+
log.warn(errMessage)
|
206
209
|
throw ErrorHandler.Factory.createFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.DESTINATION_FSP_ERROR, errMessage)
|
207
210
|
}
|
208
211
|
sendTo = proxyName
|
@@ -213,7 +216,7 @@ const putPartiesErrorByTypeAndID = async (headers, params, payload, dataUri, spa
|
|
213
216
|
log.info('putPartiesErrorByTypeAndID callback was sent', { sendTo })
|
214
217
|
histTimerEnd({ success: true })
|
215
218
|
} catch (err) {
|
216
|
-
fspiopError = await
|
219
|
+
fspiopError = await utils.createErrorHandlerOnSendingCallback(Config, log)(err, headers, params, sendTo)
|
217
220
|
if (fspiopError) {
|
218
221
|
util.countFspiopError(fspiopError, { operation: 'putPartiesErrorByTypeAndID', step })
|
219
222
|
}
|