account-lookup-service 17.13.0 → 17.14.0-snapshot.3
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/CLAUDE.md +100 -0
- package/config/default.json +1 -1
- package/docker-compose.yml +1 -1
- package/package.json +6 -6
- package/{sbom-v17.12.10.csv → sbom-v17.13.0.csv} +148 -157
- package/src/domain/parties/services/GetPartiesService.js +3 -3
- package/src/domain/parties/services/PutPartiesErrorService.js +6 -6
- package/src/domain/parties/services/PutPartiesService.js +2 -2
- package/src/lib/config.js +2 -1
- package/src/models/oracle/facade.js +4 -3
- package/test/integration/api/parties.test.js +7 -3
- package/test/unit/domain/parties/parties.test.js +5 -5
@@ -26,10 +26,10 @@
|
|
26
26
|
******/
|
27
27
|
|
28
28
|
const { ERROR_MESSAGES } = require('../../../constants')
|
29
|
+
const { PROXY_CACHE_EXPIRES_IN_SEC } = require('../../../lib/config')
|
29
30
|
const BasePartiesService = require('./BasePartiesService')
|
30
31
|
|
31
32
|
const { RestMethods } = BasePartiesService.enums()
|
32
|
-
const proxyCacheTtlSec = 40 // todo: make configurable
|
33
33
|
|
34
34
|
class GetPartiesService extends BasePartiesService {
|
35
35
|
async handleRequest () {
|
@@ -294,11 +294,11 @@ class GetPartiesService extends BasePartiesService {
|
|
294
294
|
this.stepInProgress('#setProxyListToCache')
|
295
295
|
const alsReq = this.deps.partiesUtils.alsRequestDto(source, params)
|
296
296
|
|
297
|
-
const isCached = await this.deps.proxyCache.setSendToProxiesList(alsReq, proxyNames,
|
297
|
+
const isCached = await this.deps.proxyCache.setSendToProxiesList(alsReq, proxyNames, PROXY_CACHE_EXPIRES_IN_SEC)
|
298
298
|
if (!isCached) {
|
299
299
|
throw super.createFspiopIdNotFoundError(ERROR_MESSAGES.failedToCacheSendToProxiesList)
|
300
300
|
}
|
301
|
-
this.log.verbose('#setProxyListToCache is done: ', { alsReq, proxyNames,
|
301
|
+
this.log.verbose('#setProxyListToCache is done: ', { alsReq, proxyNames, PROXY_CACHE_EXPIRES_IN_SEC })
|
302
302
|
return alsReq
|
303
303
|
}
|
304
304
|
|
@@ -31,7 +31,7 @@ class PutPartiesErrorService extends BasePartiesService {
|
|
31
31
|
async handleRequest () {
|
32
32
|
if (this.state.proxyEnabled && this.state.proxy) {
|
33
33
|
const alsReq = this.deps.partiesUtils.alsRequestDto(this.state.destination, this.inputs.params)
|
34
|
-
const isInterSchemeDiscoveryCase = await this.deps.proxyCache.isPendingCallback(alsReq)
|
34
|
+
const isInterSchemeDiscoveryCase = await this.deps.proxyCache.isPendingCallback(alsReq, this.state.proxy)
|
35
35
|
this.log.verbose(`isInterSchemeDiscoveryCase: ${isInterSchemeDiscoveryCase}`, this.state)
|
36
36
|
|
37
37
|
if (isInterSchemeDiscoveryCase) {
|
@@ -41,11 +41,11 @@ class PutPartiesErrorService extends BasePartiesService {
|
|
41
41
|
return
|
42
42
|
}
|
43
43
|
} else {
|
44
|
-
const isExternal = await this.#isPartyFromExternalDfsp()
|
44
|
+
const isExternal = await this.#isPartyFromExternalDfsp() // !!! DO not clear oracle for the error callback for the same inter-scheme discovery flow
|
45
45
|
if (isExternal) {
|
46
46
|
this.log.info('need to cleanup oracle coz party is from external DFSP')
|
47
47
|
await this.cleanupOracle()
|
48
|
-
await this.removeProxyGetPartiesTimeoutCache(alsReq) // think if we need this
|
48
|
+
await this.removeProxyGetPartiesTimeoutCache(alsReq) // todo: think if we need this
|
49
49
|
}
|
50
50
|
}
|
51
51
|
}
|
@@ -66,9 +66,9 @@ class PutPartiesErrorService extends BasePartiesService {
|
|
66
66
|
async checkLastProxyCallback (alsReq) {
|
67
67
|
this.stepInProgress('checkLastProxyCallback')
|
68
68
|
const { proxy } = this.state
|
69
|
-
const
|
70
|
-
this.log.info(`got ${
|
71
|
-
return
|
69
|
+
const isLastWithoutSuccess = await this.deps.proxyCache.receivedErrorResponse(alsReq, proxy)
|
70
|
+
this.log.info(`got ${isLastWithoutSuccess ? '' : 'NOT '}last inter-scheme error callback from a proxy`, { proxy, alsReq, isLastWithoutSuccess })
|
71
|
+
return isLastWithoutSuccess
|
72
72
|
}
|
73
73
|
|
74
74
|
async sendErrorCallbackToParticipant () {
|
@@ -67,10 +67,10 @@ class PutPartiesService extends BasePartiesService {
|
|
67
67
|
if (this.state.proxyEnabled) {
|
68
68
|
this.stepInProgress('checkProxySuccessResponse')
|
69
69
|
const { headers, params } = this.inputs
|
70
|
-
const { destination, source } = this.state
|
70
|
+
const { destination, source, proxy } = this.state
|
71
71
|
const alsReq = this.deps.partiesUtils.alsRequestDto(destination, params)
|
72
72
|
|
73
|
-
const isExists = await this.deps.proxyCache.receivedSuccessResponse(alsReq)
|
73
|
+
const isExists = await this.deps.proxyCache.receivedSuccessResponse(alsReq, proxy)
|
74
74
|
if (!isExists) {
|
75
75
|
this.log.verbose('NOT inter-scheme receivedSuccessResponse case')
|
76
76
|
await this.removeProxyGetPartiesTimeoutCache(alsReq)
|
package/src/lib/config.js
CHANGED
@@ -176,7 +176,8 @@ const config = {
|
|
176
176
|
PROTOCOL_VERSIONS: getProtocolVersions(DEFAULT_PROTOCOL_VERSION, RC.PROTOCOL_VERSIONS),
|
177
177
|
PROXY_CACHE_CONFIG: RC.PROXY_CACHE,
|
178
178
|
DELETE_PARTICIPANT_VALIDATION_ENABLED: RC.DELETE_PARTICIPANT_VALIDATION_ENABLED || false,
|
179
|
-
HTTP_REQUEST_TIMEOUT_MS: RC.HTTP_REQUEST_TIMEOUT_MS ?? 20_000
|
179
|
+
HTTP_REQUEST_TIMEOUT_MS: RC.HTTP_REQUEST_TIMEOUT_MS ?? 20_000,
|
180
|
+
PROXY_CACHE_EXPIRES_IN_SEC: RC.PROXY_CACHE_EXPIRES_IN_SEC ?? 20
|
180
181
|
}
|
181
182
|
|
182
183
|
if (config.JWS_SIGN) {
|
@@ -141,6 +141,7 @@ const sendOracleGetRequest = async ({
|
|
141
141
|
const log = logger.child({ component: 'sendOracleGetRequest', params })
|
142
142
|
|
143
143
|
try {
|
144
|
+
let hit = false // cache hit
|
144
145
|
let cachedOracleFspResponse
|
145
146
|
cachedOracleFspResponse = cache && cache.get(cache.createKey(`oracleSendRequest_${url}`))
|
146
147
|
|
@@ -161,12 +162,12 @@ const sendOracleGetRequest = async ({
|
|
161
162
|
cache.createKey(`oracleSendRequest_${url}`),
|
162
163
|
cachedOracleFspResponse
|
163
164
|
)
|
164
|
-
histTimerEnd({ success: true, hit: false })
|
165
165
|
} else {
|
166
|
+
hit = true
|
166
167
|
cachedOracleFspResponse = cachedOracleFspResponse.item
|
167
|
-
histTimerEnd({ success: true, hit: true })
|
168
|
-
logger.debug('[oracleRequest]: cache hit for fsp for partyId lookup')
|
169
168
|
}
|
169
|
+
logger.verbose(`[oracleRequest]: cache hit for partyId lookup: ${hit}`, { url, source, destination })
|
170
|
+
histTimerEnd({ success: true, hit })
|
170
171
|
|
171
172
|
return cachedOracleFspResponse
|
172
173
|
} catch (err) {
|
@@ -30,7 +30,7 @@ const { createProxyCache } = require('@mojaloop/inter-scheme-proxy-cache-lib')
|
|
30
30
|
const config = require('../../../src/lib/config')
|
31
31
|
const fixtures = require('../../fixtures')
|
32
32
|
const { AlsApiClient, ProxyApiClient } = require('../../util')
|
33
|
-
const { PAYER_DFSP, PARTY_ID_TYPE } = require('../constants')
|
33
|
+
const { PAYER_DFSP, PARTY_ID_TYPE, PROXY_NAME } = require('../constants')
|
34
34
|
|
35
35
|
const alsClient = new AlsApiClient()
|
36
36
|
const proxyClient = new ProxyApiClient() // mock ISPA
|
@@ -43,6 +43,10 @@ describe('Parties Endpoints Tests -->', () => {
|
|
43
43
|
await proxyCache.connect()
|
44
44
|
})
|
45
45
|
|
46
|
+
// beforeEach(async () => {
|
47
|
+
// await proxyCache.redisClient.flushdb()
|
48
|
+
// })
|
49
|
+
|
46
50
|
afterAll(async () => {
|
47
51
|
await proxyCache.disconnect()
|
48
52
|
})
|
@@ -51,7 +55,7 @@ describe('Parties Endpoints Tests -->', () => {
|
|
51
55
|
test('should do GET /parties/{Type}/{ID} call to proxy', async () => {
|
52
56
|
const partyId = 'PT123456789'
|
53
57
|
const alsReq = fixtures.mockAlsRequestDto(PAYER_DFSP, PARTY_ID_TYPE, partyId)
|
54
|
-
let isExists = await proxyCache.receivedSuccessResponse(alsReq)
|
58
|
+
let isExists = await proxyCache.receivedSuccessResponse(alsReq, PROXY_NAME)
|
55
59
|
expect(isExists).toBe(false)
|
56
60
|
|
57
61
|
let history = await proxyClient.deleteHistory()
|
@@ -72,7 +76,7 @@ describe('Parties Endpoints Tests -->', () => {
|
|
72
76
|
expect(history[0].path).toBe(`/oracle/participants/${PARTY_ID_TYPE}/${partyId}`)
|
73
77
|
expect(history[1].path).toBe(`/parties/${PARTY_ID_TYPE}/${partyId}`)
|
74
78
|
|
75
|
-
isExists = await proxyCache.receivedSuccessResponse(alsReq)
|
79
|
+
isExists = await proxyCache.receivedSuccessResponse(alsReq, PROXY_NAME)
|
76
80
|
expect(isExists).toBe(true)
|
77
81
|
})
|
78
82
|
|
@@ -534,7 +534,7 @@ describe('Parties Tests', () => {
|
|
534
534
|
|
535
535
|
it('should perform sendToProxies alsRequest, if no destination-header and no data in oracle response', async () => {
|
536
536
|
Config.PROXY_CACHE_CONFIG.enabled = true
|
537
|
-
const proxyNames = [
|
537
|
+
const proxyNames = [`proxyA-${Date.now()}`, `proxyB-${Date.now()}`]
|
538
538
|
Util.proxies.getAllProxiesNames = sandbox.stub().resolves(proxyNames)
|
539
539
|
oracle.oracleRequest = sandbox.stub().resolves(null)
|
540
540
|
participant.validateParticipant = sandbox.stub().resolves({})
|
@@ -546,12 +546,12 @@ describe('Parties Tests', () => {
|
|
546
546
|
const headers = fixtures.partiesCallHeadersDto({ source, destination })
|
547
547
|
const alsReq = partiesUtils.alsRequestDto(source, Helper.getByTypeIdRequest.params)
|
548
548
|
|
549
|
-
let isExists = await proxyCache.receivedSuccessResponse(alsReq) // no in cache
|
549
|
+
let isExists = await proxyCache.receivedSuccessResponse(alsReq, proxyNames[0]) // no in cache
|
550
550
|
expect(isExists).toBe(false)
|
551
551
|
|
552
552
|
await partiesDomain.getPartiesByTypeAndID(headers, Helper.getByTypeIdRequest.params, Helper.getByTypeIdRequest.method, Helper.getByTypeIdRequest.query, Helper.mockSpan(), null, proxyCache)
|
553
553
|
|
554
|
-
isExists = await proxyCache.receivedSuccessResponse(alsReq)
|
554
|
+
isExists = await proxyCache.receivedSuccessResponse(alsReq, proxyNames[0])
|
555
555
|
expect(isExists).toBe(true)
|
556
556
|
expect(participant.sendErrorToParticipant.callCount).toBe(0)
|
557
557
|
expect(participant.sendRequest.callCount).toBe(proxyNames.length)
|
@@ -682,8 +682,8 @@ describe('Parties Tests', () => {
|
|
682
682
|
it('should update oracle with partyDetails received from proxy, if previous alsReq is cached', async () => {
|
683
683
|
Config.PROXY_CACHE_CONFIG.enabled = true
|
684
684
|
const source = `source-${Date.now()}`
|
685
|
-
const destination = `
|
686
|
-
const proxy = `
|
685
|
+
const destination = `payeeDfsp-${Date.now()}`
|
686
|
+
const proxy = `proxyAB-${Date.now()}`
|
687
687
|
|
688
688
|
participant.validateParticipant = sandbox.stub()
|
689
689
|
.onFirstCall().resolves(null) // payee
|