account-lookup-service 17.4.1-csi-1300.3 → 17.4.1-csi-1300.5

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 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.1-csi-1300.3",
4
+ "version": "17.4.1-csi-1300.5",
5
5
  "license": "Apache-2.0",
6
6
  "author": "ModusBox",
7
7
  "contributors": [
@@ -26,8 +26,8 @@
26
26
  const Metrics = require('@mojaloop/central-services-metrics')
27
27
  const libUtil = require('../../lib/util')
28
28
  const { logger } = require('../../lib')
29
- const { GetPartiesService } = require('./services')
30
29
  const { createDeps } = require('./deps')
30
+ const { GetPartiesService } = require('./services')
31
31
 
32
32
  /**
33
33
  * @function getPartiesByTypeAndID
@@ -31,13 +31,10 @@
31
31
 
32
32
  const { Headers } = require('@mojaloop/central-services-shared').Enum.Http
33
33
  const Metrics = require('@mojaloop/central-services-metrics')
34
-
35
34
  const libUtil = require('../../lib/util')
36
- const Config = require('../../lib/config')
37
35
  const { logger } = require('../../lib')
38
-
39
- const services = require('./services')
40
36
  const { createDeps } = require('./deps')
37
+ const services = require('./services')
41
38
 
42
39
  /**
43
40
  * @function putPartiesByTypeAndID
@@ -71,7 +68,7 @@ const putPartiesByTypeAndID = async (headers, params, method, payload, dataUri,
71
68
  const source = headers[Headers.FSPIOP.SOURCE]
72
69
  const destination = headers[Headers.FSPIOP.DESTINATION]
73
70
  const proxy = headers[Headers.FSPIOP.PROXY]
74
- log.info('parties::putPartiesByTypeAndID start', { source, destination, proxy })
71
+ log.info('putPartiesByTypeAndID start', { source, destination, proxy })
75
72
 
76
73
  try {
77
74
  await service.validateSourceParticipant({ source, proxy })
@@ -125,12 +122,12 @@ const putPartiesErrorByTypeAndID = async (headers, params, payload, dataUri, spa
125
122
  const results = {}
126
123
 
127
124
  const destination = headers[Headers.FSPIOP.DESTINATION]
128
- const proxyEnabled = !!(Config.PROXY_CACHE_CONFIG.enabled && proxyCache)
129
- const proxy = proxyEnabled && headers[Headers.FSPIOP.PROXY]
130
- log.info('parties::putPartiesErrorByTypeAndID start', { destination, proxy })
125
+ const proxy = headers[Headers.FSPIOP.PROXY]
126
+ const proxyEnabled = !!(deps.config.PROXY_CACHE_CONFIG.enabled && proxyCache)
127
+ log.info('putPartiesErrorByTypeAndID start', { destination, proxy, proxyEnabled })
131
128
 
132
129
  try {
133
- if (proxy) {
130
+ if (proxyEnabled && proxy) {
134
131
  const notValid = await service.checkPayee({ headers, params, payload, proxy })
135
132
  if (notValid) {
136
133
  const getPartiesService = new services.GetPartiesService(deps)
@@ -39,9 +39,9 @@ class BasePartiesService {
39
39
  this.proxyEnabled = !!(deps.config.PROXY_CACHE_CONFIG?.enabled && deps.proxyCache)
40
40
  }
41
41
 
42
- async handleRequest () {
43
- throw new Error('handleRequest must be implemented by subclass')
44
- }
42
+ // async handleRequest () {
43
+ // throw new Error('handleRequest must be implemented by subclass')
44
+ // }
45
45
 
46
46
  async handleError ({ error, requester, headers, params }) {
47
47
  const log = this.log.child({ method: 'handleError' })
@@ -67,9 +67,10 @@ class BasePartiesService {
67
67
 
68
68
  async sendErrorCallback ({ sendTo, errorInfo, headers, params, payload = undefined }) {
69
69
  const endpointType = this.deps.partiesUtils.errorPartyCbType(params.SubId)
70
- return this.deps.participant.sendErrorToParticipant(
70
+ await this.deps.participant.sendErrorToParticipant(
71
71
  sendTo, endpointType, errorInfo, headers, params, payload, this.deps.childSpan
72
72
  )
73
+ this.log.verbose('sendErrorCallback is done', { sendTo, errorInfo })
73
74
  }
74
75
 
75
76
  async sendDeleteOracleRequest (headers, params) {
@@ -75,7 +75,7 @@ class GetPartiesService extends BasePartiesService {
75
75
 
76
76
  async validateRequester ({ source, proxy }) {
77
77
  this.deps.stepState.inProgress('validateRequester-0')
78
- const log = this.log.child({ source, method: 'validateRequester' })
78
+ const log = this.log.child({ source, proxy, method: 'validateRequester' })
79
79
 
80
80
  const sourceParticipant = await this.validateParticipant(source)
81
81
  if (sourceParticipant) {
@@ -92,12 +92,17 @@ class GetPartiesService extends BasePartiesService {
92
92
  const proxyParticipant = await this.validateParticipant(proxy)
93
93
  if (!proxyParticipant) {
94
94
  const errMessage = ERROR_MESSAGES.partyProxyNotFound
95
- log.warn(errMessage, { proxy })
95
+ log.warn(errMessage)
96
96
  throw ErrorHandler.Factory.createFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.ID_NOT_FOUND, errMessage)
97
97
  }
98
98
 
99
99
  const isCached = await this.deps.proxyCache.addDfspIdToProxyMapping(source, proxy)
100
- // think, what if isCached !== true?
100
+ if (!isCached) {
101
+ const errMessage = 'failed to addDfspIdToProxyMapping'
102
+ log.warn(errMessage)
103
+ throw ErrorHandler.Factory.createFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.ID_NOT_FOUND, errMessage)
104
+ }
105
+
101
106
  log.info('source is added to proxyMapping cache:', { proxy, isCached })
102
107
  return proxy
103
108
  }
@@ -30,9 +30,9 @@ const { ERROR_MESSAGES } = require('../../../constants')
30
30
  const BasePartiesService = require('./BasePartiesService')
31
31
 
32
32
  class PutPartiesErrorService extends BasePartiesService {
33
- async handleRequest () {
34
- // todo: add impl.
35
- }
33
+ // async handleRequest () {
34
+ // // todo: add impl.
35
+ // }
36
36
 
37
37
  async checkPayee ({ headers, params, payload, proxy }) {
38
38
  const notValid = this.deps.partiesUtils.isNotValidPayeeCase(payload)
@@ -70,10 +70,9 @@ class PutPartiesErrorService extends BasePartiesService {
70
70
  async sendErrorCallbackToParticipant ({ sendTo, headers, params, dataUri }) {
71
71
  this.deps.stepState.inProgress('sendErrorToParticipant-5')
72
72
  const errorInfo = PutPartiesErrorService.decodeDataUriPayload(dataUri)
73
- await super.sendErrorCallback({
73
+ return super.sendErrorCallback({
74
74
  sendTo, errorInfo, headers, params
75
75
  })
76
- this.log.verbose('sendErrorCallbackToParticipant is done', { sendTo, errorInfo })
77
76
  }
78
77
  }
79
78
 
@@ -32,9 +32,9 @@ const BasePartiesService = require('./BasePartiesService')
32
32
  const { RestMethods } = BasePartiesService.enums()
33
33
 
34
34
  class PutPartiesService extends BasePartiesService {
35
- async handleRequest () {
36
- // todo: add impl.
37
- }
35
+ // async handleRequest () {
36
+ // // todo: add impl.
37
+ // }
38
38
 
39
39
  async validateSourceParticipant ({ source, proxy }) {
40
40
  this.deps.stepState.inProgress('validateSourceParticipant-1')
@@ -47,8 +47,13 @@ class PutPartiesService extends BasePartiesService {
47
47
  throw ErrorHandler.Factory.createFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.ID_NOT_FOUND, errMessage)
48
48
  }
49
49
  const isCached = await this.deps.proxyCache.addDfspIdToProxyMapping(source, proxy)
50
- // todo: think,if we should throw error if isCached === false?
51
- this.log.info('addDfspIdToProxyMapping is done', { source, proxy, isCached })
50
+ if (!isCached) {
51
+ const errMessage = 'failed to addDfspIdToProxyMapping'
52
+ this.log.warn(errMessage, { source, proxy })
53
+ throw ErrorHandler.Factory.createFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.ID_NOT_FOUND, errMessage)
54
+ }
55
+
56
+ this.log.info('addDfspIdToProxyMapping is done', { source, proxy })
52
57
  }
53
58
  }
54
59