account-lookup-service 15.6.0-iso.2 → 15.6.0-iso.4
Sign up to get free protection for your applications and to get access to all the features.
- package/.circleci/config.yml +1 -1
- package/package.json +2 -2
- package/src/domain/participants/participants.js +14 -5
- package/src/models/participantEndpoint/facade.js +14 -11
- package/src/plugins.js +32 -8
- package/src/server.js +0 -19
- package/test/unit/lib/TransformFacades.test.js +1 -1
- package/test/unit/plugins.test.js +2 -0
package/.circleci/config.yml
CHANGED
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": "15.6.0-iso.
|
4
|
+
"version": "15.6.0-iso.4",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"author": "ModusBox",
|
7
7
|
"contributors": [
|
@@ -157,7 +157,7 @@
|
|
157
157
|
"ioredis-mock": "^8.9.0",
|
158
158
|
"jest": "29.7.0",
|
159
159
|
"jest-junit": "16.0.0",
|
160
|
-
"jsdoc": "4.0.
|
160
|
+
"jsdoc": "4.0.4",
|
161
161
|
"nodemon": "3.1.7",
|
162
162
|
"npm-check-updates": "17.1.4",
|
163
163
|
"nyc": "17.1.0",
|
@@ -222,7 +222,9 @@ const putParticipantsErrorByTypeAndID = async (headers, params, payload, dataUri
|
|
222
222
|
).startTimer()
|
223
223
|
try {
|
224
224
|
const partySubIdOrType = params.SubId || undefined
|
225
|
-
const callbackEndpointType = partySubIdOrType
|
225
|
+
const callbackEndpointType = partySubIdOrType
|
226
|
+
? Enums.EndPoints.FspEndpointTypes.FSPIOP_CALLBACK_URL_PARTICIPANT_SUB_ID_PUT_ERROR
|
227
|
+
: Enums.EndPoints.FspEndpointTypes.FSPIOP_CALLBACK_URL_PARTICIPANT_PUT_ERROR
|
226
228
|
const destinationParticipant = await participant.validateParticipant(headers[Enums.Http.Headers.FSPIOP.DESTINATION])
|
227
229
|
if (destinationParticipant) {
|
228
230
|
const decodedPayload = decodePayload(dataUri, { asParsed: false })
|
@@ -231,7 +233,8 @@ const putParticipantsErrorByTypeAndID = async (headers, params, payload, dataUri
|
|
231
233
|
callbackEndpointType,
|
232
234
|
decodedPayload.body.toString(),
|
233
235
|
headers,
|
234
|
-
params
|
236
|
+
params
|
237
|
+
)
|
235
238
|
} else {
|
236
239
|
await participant.sendErrorToParticipant(
|
237
240
|
headers[Enums.Http.Headers.FSPIOP.SOURCE],
|
@@ -239,15 +242,21 @@ const putParticipantsErrorByTypeAndID = async (headers, params, payload, dataUri
|
|
239
242
|
ErrorHandler.Factory.createFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.DESTINATION_FSP_ERROR).toApiErrorObject(),
|
240
243
|
headers,
|
241
244
|
params,
|
242
|
-
payload
|
245
|
+
payload
|
246
|
+
)
|
243
247
|
}
|
244
248
|
histTimerEnd({ success: true })
|
245
249
|
} catch (err) {
|
246
250
|
Logger.isErrorEnabled && Logger.error(err)
|
247
251
|
try {
|
248
252
|
const callbackEndpointType = params.SubId ? Enums.EndPoints.FspEndpointTypes.FSPIOP_CALLBACK_URL_PARTICIPANT_SUB_ID_PUT_ERROR : Enums.EndPoints.FspEndpointTypes.FSPIOP_CALLBACK_URL_PARTICIPANT_PUT_ERROR
|
249
|
-
await participant.sendErrorToParticipant(
|
250
|
-
|
253
|
+
await participant.sendErrorToParticipant(
|
254
|
+
headers[Enums.Http.Headers.FSPIOP.SOURCE],
|
255
|
+
callbackEndpointType,
|
256
|
+
ErrorHandler.Factory.reformatFSPIOPError(err).toApiErrorObject(),
|
257
|
+
headers,
|
258
|
+
params
|
259
|
+
)
|
251
260
|
} catch (exc) {
|
252
261
|
// We can't do anything else here- we _must_ handle all errors _within_ this function because
|
253
262
|
// we've already sent a sync response- we cannot throw.
|
@@ -102,9 +102,7 @@ exports.sendRequest = async (headers, requestedParticipant, endpointType, method
|
|
102
102
|
content: Config.PROTOCOL_VERSIONS.CONTENT.DEFAULT.toString(),
|
103
103
|
accept: Config.PROTOCOL_VERSIONS.ACCEPT.DEFAULT.toString()
|
104
104
|
}
|
105
|
-
const
|
106
|
-
|
107
|
-
const resp = await Util.Request.sendRequest({
|
105
|
+
const params = {
|
108
106
|
url: requestedEndpoint,
|
109
107
|
headers,
|
110
108
|
source: headers[Enums.Http.Headers.FSPIOP.SOURCE],
|
@@ -113,11 +111,15 @@ exports.sendRequest = async (headers, requestedParticipant, endpointType, method
|
|
113
111
|
payload,
|
114
112
|
responseType: Enums.Http.ResponseTypes.JSON,
|
115
113
|
span,
|
116
|
-
jwsSigner,
|
117
114
|
protocolVersions,
|
118
115
|
hubNameRegex,
|
119
116
|
apiType: Config.API_TYPE
|
120
|
-
}
|
117
|
+
}
|
118
|
+
Logger.isDebugEnabled && Logger.debug(`participant - sendRequest params: ${JSON.stringify(params)}`)
|
119
|
+
|
120
|
+
params.jwsSigner = defineJwsSigner(Config, headers, requestedEndpoint)
|
121
|
+
|
122
|
+
const resp = await Util.Request.sendRequest(params)
|
121
123
|
histTimerEndSendRequestToParticipant({ success: true, endpointType, participantName: requestedParticipant })
|
122
124
|
return resp
|
123
125
|
} catch (err) {
|
@@ -212,10 +214,7 @@ exports.sendErrorToParticipant = async (participantName, endpointType, errorInfo
|
|
212
214
|
clonedHeaders[Enums.Http.Headers.FSPIOP.SOURCE] = Config.HUB_NAME
|
213
215
|
}
|
214
216
|
|
215
|
-
|
216
|
-
const jwsSigner = defineJwsSigner(Config, clonedHeaders, requesterErrorEndpoint)
|
217
|
-
|
218
|
-
await Util.Request.sendRequest({
|
217
|
+
const params = {
|
219
218
|
url: requesterErrorEndpoint,
|
220
219
|
headers: clonedHeaders,
|
221
220
|
source: clonedHeaders[Enums.Http.Headers.FSPIOP.SOURCE],
|
@@ -225,10 +224,14 @@ exports.sendErrorToParticipant = async (participantName, endpointType, errorInfo
|
|
225
224
|
responseType: Enums.Http.ResponseTypes.JSON,
|
226
225
|
hubNameRegex,
|
227
226
|
span,
|
228
|
-
jwsSigner,
|
229
227
|
protocolVersions,
|
230
228
|
apiType: Config.API_TYPE
|
231
|
-
}
|
229
|
+
}
|
230
|
+
Logger.isDebugEnabled && Logger.debug(`participant - sendErrorToParticipant params: ${JSON.stringify(params)}`)
|
231
|
+
|
232
|
+
params.jwsSigner = defineJwsSigner(Config, clonedHeaders, requesterErrorEndpoint)
|
233
|
+
|
234
|
+
await Util.Request.sendRequest(params)
|
232
235
|
histTimerEndSendRequestToParticipant({ success: true, endpointType, participantName })
|
233
236
|
} catch (err) {
|
234
237
|
histTimerEndSendRequestToParticipant({ success: false, endpointType, participantName })
|
package/src/plugins.js
CHANGED
@@ -24,16 +24,22 @@
|
|
24
24
|
******/
|
25
25
|
'use strict'
|
26
26
|
|
27
|
-
const
|
27
|
+
const { randomUUID } = require('node:crypto')
|
28
28
|
const Inert = require('@hapi/inert')
|
29
29
|
const Vision = require('@hapi/vision')
|
30
30
|
const Blipp = require('blipp')
|
31
31
|
const ErrorHandling = require('@mojaloop/central-services-error-handling')
|
32
|
-
const
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
const {
|
33
|
+
APIDocumentation,
|
34
|
+
FSPIOPHeaderValidation,
|
35
|
+
HapiEventPlugin,
|
36
|
+
HapiRawPayload,
|
37
|
+
OpenapiBackendValidator
|
38
|
+
} = require('@mojaloop/central-services-shared').Util.Hapi
|
39
|
+
|
40
|
+
const Config = require('./lib/config')
|
36
41
|
const MetricsPlugin = require('./metrics/plugin')
|
42
|
+
const RequestLogger = require('./lib/requestLogger')
|
37
43
|
|
38
44
|
const registerPlugins = async (server, openAPIBackend) => {
|
39
45
|
await server.register(OpenapiBackendValidator)
|
@@ -121,10 +127,10 @@ const registerPlugins = async (server, openAPIBackend) => {
|
|
121
127
|
Inert,
|
122
128
|
Vision,
|
123
129
|
ErrorHandling,
|
124
|
-
|
125
|
-
|
130
|
+
HapiRawPayload,
|
131
|
+
HapiEventPlugin,
|
126
132
|
{
|
127
|
-
plugin:
|
133
|
+
plugin: FSPIOPHeaderValidation.plugin,
|
128
134
|
options: getOptionsForFSPIOPHeaderValidation()
|
129
135
|
}
|
130
136
|
])
|
@@ -132,6 +138,24 @@ const registerPlugins = async (server, openAPIBackend) => {
|
|
132
138
|
if (Config.DISPLAY_ROUTES === true) {
|
133
139
|
await server.register([Blipp])
|
134
140
|
}
|
141
|
+
|
142
|
+
await server.ext([
|
143
|
+
{
|
144
|
+
type: 'onRequest',
|
145
|
+
method: (request, h) => {
|
146
|
+
request.headers.traceid = request.headers.traceid || randomUUID()
|
147
|
+
RequestLogger.logRequest(request)
|
148
|
+
return h.continue
|
149
|
+
}
|
150
|
+
},
|
151
|
+
{
|
152
|
+
type: 'onPreResponse',
|
153
|
+
method: (request, h) => {
|
154
|
+
RequestLogger.logResponse(request)
|
155
|
+
return h.continue
|
156
|
+
}
|
157
|
+
}
|
158
|
+
])
|
135
159
|
}
|
136
160
|
|
137
161
|
module.exports = {
|
package/src/server.js
CHANGED
@@ -23,7 +23,6 @@
|
|
23
23
|
******/
|
24
24
|
'use strict'
|
25
25
|
|
26
|
-
const { randomUUID } = require('node:crypto')
|
27
26
|
const Hapi = require('@hapi/hapi')
|
28
27
|
const Boom = require('@hapi/boom')
|
29
28
|
|
@@ -37,7 +36,6 @@ const { name, version } = require('../package.json')
|
|
37
36
|
const Db = require('./lib/db')
|
38
37
|
const Util = require('./lib/util')
|
39
38
|
const Plugins = require('./plugins')
|
40
|
-
const RequestLogger = require('./lib/requestLogger')
|
41
39
|
const Migrator = require('./lib/migrator')
|
42
40
|
const APIHandlers = require('./api')
|
43
41
|
const Routes = require('./api/routes')
|
@@ -104,23 +102,6 @@ const createServer = async (port, api, routes, isAdmin, proxyCacheConfig, proxyM
|
|
104
102
|
}
|
105
103
|
}
|
106
104
|
|
107
|
-
await server.ext([
|
108
|
-
{
|
109
|
-
type: 'onPreHandler',
|
110
|
-
method: (request, h) => {
|
111
|
-
request.headers.traceid = request.headers.traceid || randomUUID()
|
112
|
-
RequestLogger.logRequest(request)
|
113
|
-
return h.continue
|
114
|
-
}
|
115
|
-
},
|
116
|
-
{
|
117
|
-
type: 'onPreResponse',
|
118
|
-
method: (request, h) => {
|
119
|
-
RequestLogger.logResponse(request)
|
120
|
-
return h.continue
|
121
|
-
}
|
122
|
-
}
|
123
|
-
])
|
124
105
|
await Plugins.registerPlugins(server, api, isAdmin)
|
125
106
|
|
126
107
|
server.route(routes)
|
@@ -8,7 +8,7 @@ describe('TransformFacades Tests -->', () => {
|
|
8
8
|
const isoPayload = await TransformFacades.FSPIOP.parties.putError({
|
9
9
|
body,
|
10
10
|
headers,
|
11
|
-
params: {
|
11
|
+
params: { Type: 'MSISDN', ID: '123456789' }
|
12
12
|
})
|
13
13
|
expect(isoPayload.body).toBeTruthy()
|
14
14
|
expect(isoPayload.body.Assgnmt).toBeTruthy()
|
@@ -50,6 +50,7 @@ describe('Plugin Tests', () => {
|
|
50
50
|
// Arrange
|
51
51
|
const server = {
|
52
52
|
register: sandbox.spy(),
|
53
|
+
ext: sandbox.spy(),
|
53
54
|
info: {
|
54
55
|
port: '8000'
|
55
56
|
}
|
@@ -72,6 +73,7 @@ describe('Plugin Tests', () => {
|
|
72
73
|
// Arrange
|
73
74
|
const server = {
|
74
75
|
register: sandbox.spy(),
|
76
|
+
ext: sandbox.spy(),
|
75
77
|
info: {
|
76
78
|
port: '8000'
|
77
79
|
}
|