account-lookup-service 15.6.0-iso.19 → 15.6.0-iso.20

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
@@ -28,6 +28,7 @@
28
28
  "GHSA-rm97-x556-q36h", // https://github.com/advisories/GHSA-rm97-x556-q36h
29
29
  "GHSA-rv95-896h-c2vc", // https://github.com/advisories/GHSA-rv95-896h-c2vc
30
30
  "GHSA-952p-6rrq-rcjv", // https://github.com/advisories/GHSA-952p-6rrq-rcjv
31
- "GHSA-3xgq-45jj-v275" // https://github.com/advisories/GHSA-3xgq-45jj-v275
31
+ "GHSA-3xgq-45jj-v275", // https://github.com/advisories/GHSA-3xgq-45jj-v275
32
+ "GHSA-rhx6-c78j-4q9w" // https://github.com/advisories/GHSA-rhx6-c78j-4q9w
32
33
  ]
33
34
  }
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.19",
4
+ "version": "15.6.0-iso.20",
5
5
  "license": "Apache-2.0",
6
6
  "author": "ModusBox",
7
7
  "contributors": [
@@ -93,20 +93,20 @@
93
93
  "@mojaloop/central-services-error-handling": "13.0.2",
94
94
  "@mojaloop/central-services-health": "15.0.0",
95
95
  "@mojaloop/central-services-logger": "11.5.1",
96
- "@mojaloop/central-services-metrics": "12.4.0",
97
- "@mojaloop/central-services-shared": "18.12.1",
96
+ "@mojaloop/central-services-metrics": "12.4.1",
97
+ "@mojaloop/central-services-shared": "18.13.0",
98
98
  "@mojaloop/central-services-stream": "11.3.1",
99
99
  "@mojaloop/database-lib": "11.0.6",
100
100
  "@mojaloop/event-sdk": "14.1.1",
101
101
  "@mojaloop/inter-scheme-proxy-cache-lib": "2.3.0",
102
102
  "@mojaloop/ml-schema-transformer-lib": "2.4.1",
103
- "@mojaloop/sdk-standard-components": "19.6.1",
103
+ "@mojaloop/sdk-standard-components": "19.6.2",
104
104
  "@now-ims/hapi-now-auth": "2.1.0",
105
105
  "ajv": "8.17.1",
106
106
  "ajv-keywords": "5.1.0",
107
107
  "blipp": "4.0.2",
108
108
  "commander": "12.1.0",
109
- "cron": "3.2.1",
109
+ "cron": "3.3.0",
110
110
  "fast-safe-stringify": "^2.1.1",
111
111
  "hapi-auth-bearer-token": "8.0.0",
112
112
  "joi": "17.13.3",
package/src/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- const { loggerFactory, asyncStorage } = require('@mojaloop/central-services-logger/src/contextLogger')
1
+ const { loggerFactory } = require('@mojaloop/central-services-logger/src/contextLogger')
2
2
  const { TransformFacades } = require('@mojaloop/ml-schema-transformer-lib')
3
3
 
4
4
  const logger = loggerFactory('ALS') // global logger without context
@@ -6,6 +6,5 @@ const logger = loggerFactory('ALS') // global logger without context
6
6
  module.exports = {
7
7
  logger,
8
8
  loggerFactory,
9
- asyncStorage,
10
9
  TransformFacades
11
10
  }
package/src/plugins.js CHANGED
@@ -24,22 +24,22 @@
24
24
  ******/
25
25
  'use strict'
26
26
 
27
- const { randomUUID } = require('node:crypto')
28
27
  const Inert = require('@hapi/inert')
29
28
  const Vision = require('@hapi/vision')
30
29
  const Blipp = require('blipp')
31
30
  const ErrorHandling = require('@mojaloop/central-services-error-handling')
31
+ const MetricsPlugin = require('@mojaloop/central-services-metrics').plugin
32
32
  const {
33
33
  APIDocumentation,
34
34
  FSPIOPHeaderValidation,
35
35
  HapiEventPlugin,
36
36
  HapiRawPayload,
37
- OpenapiBackendValidator
37
+ OpenapiBackendValidator,
38
+ loggingPlugin
38
39
  } = require('@mojaloop/central-services-shared').Util.Hapi
39
40
 
41
+ const { logger } = require('./lib')
40
42
  const Config = require('./lib/config')
41
- const MetricsPlugin = require('@mojaloop/central-services-metrics').plugin
42
- const RequestLogger = require('./lib/requestLogger')
43
43
 
44
44
  const registerPlugins = async (server, openAPIBackend) => {
45
45
  await server.register(OpenapiBackendValidator)
@@ -139,23 +139,10 @@ const registerPlugins = async (server, openAPIBackend) => {
139
139
  await server.register([Blipp])
140
140
  }
141
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
- ])
142
+ await server.register({
143
+ plugin: loggingPlugin,
144
+ options: { log: logger }
145
+ })
159
146
  }
160
147
 
161
148
  module.exports = {
@@ -35,7 +35,6 @@ const Db = require('../../../../../../src/lib/db')
35
35
  const oracleEndpointCached = require('../../../../../../src/models/oracle/oracleEndpointCached')
36
36
  const participant = require('../../../../../../src/models/participantEndpoint/facade')
37
37
  const participants = require('../../../../../../src/domain/participants')
38
- const requestLogger = require('../../../../../../src/lib/requestLogger')
39
38
  const Helper = require('../../../../../util/helper')
40
39
  const initServer = require('../../../../../../src/server').initializeApi
41
40
  const Logger = require('@mojaloop/central-services-logger')
@@ -51,8 +50,6 @@ describe('/participants/{Type}/{ID}/{SubId}', () => {
51
50
  beforeAll(async () => {
52
51
  sandbox = Sinon.createSandbox()
53
52
  sandbox.stub(Db, 'connect').returns(Promise.resolve({}))
54
- sandbox.stub(requestLogger, 'logRequest').returns({})
55
- sandbox.stub(requestLogger, 'logResponse').returns({})
56
53
  Config.API_PORT = await getPort()
57
54
  server = await initServer(Config)
58
55
  })
@@ -40,7 +40,6 @@ const Db = require('../../../../../src/lib/db')
40
40
  const oracleEndpointCached = require('../../../../../src/models/oracle/oracleEndpointCached')
41
41
  const participant = require('../../../../../src/models/participantEndpoint/facade')
42
42
  const participants = require('../../../../../src/domain/participants')
43
- const requestLogger = require('../../../../../src/lib/requestLogger')
44
43
  const Helper = require('../../../../util/helper')
45
44
  const initServer = require('../../../../../src/server').initializeApi
46
45
  const Config = require('../../../../../src/lib/config')
@@ -55,8 +54,6 @@ describe('/participants/{Type}/{ID}', () => {
55
54
  beforeAll(async () => {
56
55
  sandbox = Sinon.createSandbox()
57
56
  sandbox.stub(Db, 'connect').returns(Promise.resolve({}))
58
- sandbox.stub(requestLogger, 'logRequest').returns({})
59
- sandbox.stub(requestLogger, 'logResponse').returns({})
60
57
  Config.API_PORT = await getPort()
61
58
  server = await initServer(Config)
62
59
  sandbox.stub(Logger)
@@ -64,7 +64,7 @@ describe('Plugin Tests', () => {
64
64
  await registerPlugins(server, api)
65
65
 
66
66
  // Assert
67
- expect(server.register.callCount).toBe(10)
67
+ expect(server.register.callCount).toBe(11)
68
68
  const firstCallArgs = server.register.getCall(1).args
69
69
  expect(firstCallArgs[0].options.document.info.title.includes('Open API for FSP Interoperability (FSPIOP) (Implementation Friendly Version)')).toBe(true)
70
70
  })
@@ -86,6 +86,6 @@ describe('Plugin Tests', () => {
86
86
  await registerPlugins(server, api)
87
87
 
88
88
  // Assert
89
- expect(server.register.callCount).toBe(9)
89
+ expect(server.register.callCount).toBe(10)
90
90
  })
91
91
  })
@@ -1,54 +0,0 @@
1
- /*****
2
- License
3
- --------------
4
- Copyright © 2017 Bill & Melinda Gates Foundation
5
- The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
6
- http://www.apache.org/licenses/LICENSE-2.0
7
- Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
8
- Contributors
9
- --------------
10
- This is the official list of the Mojaloop project contributors for this file.
11
- Names of the original copyright holders (individuals or organizations)
12
- should be listed with a '*' in the first column. People who have
13
- contributed from an organization can be listed under the organization
14
- that actually holds the copyright for their contributions (see the
15
- Gates Foundation organization for an example). Those individuals should have
16
- their names indented and be marked with a '-'. Email address can be added
17
- optionally within square brackets <email>.
18
- * Gates Foundation
19
-
20
- * Rajiv Mothilal <rajiv.mothilal@modusbox.com>
21
-
22
- --------------
23
- ******/
24
-
25
- 'use strict'
26
-
27
- const { logger, asyncStorage } = require('./index')
28
-
29
- const logRequest = function (request) {
30
- const { path, method, headers, payload, query } = request
31
- const requestId = request.info.id = `${request.info.id}__${headers.traceid}`
32
- asyncStorage.enterWith({ requestId })
33
-
34
- logger.isInfoEnabled && logger.info(`[==> req] ${method.toUpperCase()} ${path}`, { headers, payload, query })
35
- }
36
-
37
- const logResponse = function (request) {
38
- if (logger.isInfoEnabled) {
39
- const { path, method, headers, payload, query, response } = request
40
- const { received } = request.info
41
-
42
- const statusCode = response instanceof Error
43
- ? response.output?.statusCode
44
- : response.statusCode
45
- const respTimeSec = ((Date.now() - received) / 1000).toFixed(3)
46
-
47
- logger.info(`[<== ${statusCode}][${respTimeSec} s] ${method.toUpperCase()} ${path}`, { headers, payload, query })
48
- }
49
- }
50
-
51
- module.exports = {
52
- logRequest,
53
- logResponse
54
- }
@@ -1,115 +0,0 @@
1
- /*****
2
- License
3
- --------------
4
- Copyright © 2017 Bill & Melinda Gates Foundation
5
- The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
6
- http://www.apache.org/licenses/LICENSE-2.0
7
- Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
8
- Contributors
9
- --------------
10
- This is the official list of the Mojaloop project contributors for this file.
11
- Names of the original copyright holders (individuals or organizations)
12
- should be listed with a '*' in the first column. People who have
13
- contributed from an organization can be listed under the organization
14
- that actually holds the copyright for their contributions (see the
15
- Gates Foundation organization for an example). Those individuals should have
16
- their names indented and be marked with a '-'. Email address can be added
17
- optionally within square brackets <email>.
18
- * Gates Foundation
19
- - Name Surname <name.surname@gatesfoundation.com>
20
-
21
- * Crosslake
22
- - Lewis Daly <lewisd@crosslaketech.com>
23
-
24
- --------------
25
- ******/
26
-
27
- 'use strict'
28
-
29
- const Sinon = require('sinon')
30
- const ErrorHandler = require('@mojaloop/central-services-error-handling')
31
-
32
- const requestLogger = require('../../../src/lib/requestLogger')
33
- const { logger } = require('../../../src/lib')
34
- const fixtures = require('../../fixtures')
35
-
36
- let sandbox
37
-
38
- describe('requestLogger', () => {
39
- beforeEach(() => {
40
- sandbox = Sinon.createSandbox()
41
- })
42
-
43
- afterEach(() => {
44
- sandbox.restore()
45
- })
46
-
47
- describe('logRequest', () => {
48
- it('prints the request.payload if it exists', async () => {
49
- // Arrange
50
- const infoSpy = sandbox.spy(logger.mlLogger, 'info')
51
- const req = {
52
- ...fixtures.mockHapiRequestDto(),
53
- url: {
54
- path: '/123/456'
55
- },
56
- query: {},
57
- payload: {
58
- itemA: 123,
59
- itemB: 456
60
- }
61
- }
62
-
63
- // Act
64
- requestLogger.logRequest(req)
65
-
66
- // Assert
67
- expect(infoSpy.calledOnce).toBe(true)
68
- const logLine = infoSpy.firstCall.args[0]
69
- expect(logLine).toContain(JSON.stringify(req.headers))
70
- expect(logLine).toContain(JSON.stringify(req.query))
71
- expect(logLine).toContain(JSON.stringify(req.payload))
72
- })
73
- })
74
-
75
- describe('logResponse', () => {
76
- it('should log response statusCode', async () => {
77
- // Arrange
78
- const infoSpy = sandbox.spy(logger.mlLogger, 'info')
79
- const req = {
80
- ...fixtures.mockHapiRequestDto(),
81
- response: {
82
- statusCode: 500
83
- }
84
- }
85
-
86
- // Act
87
- requestLogger.logResponse(req)
88
-
89
- // Assert
90
- const logLine = infoSpy.firstCall.args[0]
91
- expect(logLine).toContain(JSON.stringify(req.response.statusCode))
92
- })
93
-
94
- it('handles valid json error response', async () => {
95
- // Arrange
96
- const infoSpy = sandbox.spy(logger.mlLogger, 'info')
97
- const response = ErrorHandler.Factory.createFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.VALIDATION_ERROR, 'Invalid currency code')
98
- const statusCode = 123
99
- response.output = {
100
- statusCode
101
- }
102
- const req = {
103
- ...fixtures.mockHapiRequestDto(),
104
- response
105
- }
106
-
107
- // Act
108
- requestLogger.logResponse(req)
109
-
110
- // Assert
111
- const logLine = infoSpy.firstCall.args[0]
112
- expect(logLine).toContain(JSON.stringify(statusCode))
113
- })
114
- })
115
- })