account-lookup-service 17.7.0-snapshot.2 → 17.7.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/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [17.7.0](https://github.com/mojaloop/account-lookup-service/compare/v17.6.0...v17.7.0) (2025-03-26)
6
+
7
+
8
+ ### Features
9
+
10
+ * update dependencies to latest versions ([#542](https://github.com/mojaloop/account-lookup-service/issues/542)) ([8867742](https://github.com/mojaloop/account-lookup-service/commit/8867742e5e599f9a0de05eae095e2bd12e37d149))
11
+
5
12
  ## [17.6.0](https://github.com/mojaloop/account-lookup-service/compare/v17.5.0...v17.6.0) (2025-03-19)
6
13
 
7
14
 
package/package.json CHANGED
@@ -1,11 +1,10 @@
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.7.0-snapshot.2",
4
+ "version": "17.7.0",
5
5
  "license": "Apache-2.0",
6
6
  "author": "ModusBox",
7
7
  "contributors": [
8
- "Eugen Klymniuk <eugen.klymniuk@infitx.com>",
9
8
  "Rajiv Mothilal <rajiv.mothilal@modusbox.com>",
10
9
  "Matt Kingston <matt.kingston@modusbox.com>",
11
10
  "Lewis Daly <lewisd@crosslaketech.com>",
@@ -45,8 +44,10 @@
45
44
  "start:api": "node src/index.js server --api",
46
45
  "start:admin": "node src/index.js server --admin",
47
46
  "start:handlers": "node src/handlers/index.js handlers --timeout",
48
- "lint": "standard",
49
- "lint:fix": "standard --fix",
47
+ "standard": "standard",
48
+ "standard:fix": "standard --fix",
49
+ "lint": "npm run standard",
50
+ "lint:fix": "npm run standard:fix",
50
51
  "dev": "nodemon src/index.js server",
51
52
  "test": "npm run test:unit",
52
53
  "test:unit": "NODE_OPTIONS='--experimental-vm-modules --max-old-space-size=8192' jest --runInBand",
@@ -92,7 +93,7 @@
92
93
  "@hapi/vision": "7.0.3",
93
94
  "@mojaloop/central-services-error-handling": "13.0.7",
94
95
  "@mojaloop/central-services-health": "15.0.4",
95
- "@mojaloop/central-services-logger": "11.7.0",
96
+ "@mojaloop/central-services-logger": "11.8.0",
96
97
  "@mojaloop/central-services-metrics": "12.5.0",
97
98
  "@mojaloop/central-services-shared": "18.23.1",
98
99
  "@mojaloop/central-services-stream": "11.5.2",
@@ -189,9 +190,5 @@
189
190
  "scripts": {
190
191
  "postchangelog": "replace '\\[mojaloop/#(\\d+)\\]\\(https://github.com/mojaloop/(.*)/issues/(\\d+)\\)' '[mojaloop/#$1](https://github.com/mojaloop/project/issues/$1)' CHANGELOG.md"
191
192
  }
192
- },
193
- "imports": {
194
- "#src/*": "./src/*.js",
195
- "#test/*": "./test/*.js"
196
193
  }
197
194
  }
package/src/constants.js CHANGED
@@ -1,40 +1,9 @@
1
- /*****
2
- License
3
- --------------
4
- Copyright © 2020-2025 Mojaloop Foundation
5
- The Mojaloop files are made available by the Mojaloop 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
-
7
- http://www.apache.org/licenses/LICENSE-2.0
8
-
9
- 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.
10
-
11
- Contributors
12
- --------------
13
- This is the official list of the Mojaloop project contributors for this file.
14
- Names of the original copyright holders (individuals or organizations)
15
- should be listed with a '*' in the first column. People who have
16
- contributed from an organization can be listed under the organization
17
- that actually holds the copyright for their contributions (see the
18
- Mojaloop Foundation for an example). Those individuals should have
19
- their names indented and be marked with a '-'. Email address can be added
20
- optionally within square brackets <email>.
21
-
22
- * Mojaloop Foundation
23
- * Eugen Klymniuk <eugen.klymniuk@infitx.com>
24
-
25
- --------------
26
- ******/
27
-
28
- const { API_TYPES } = require('@mojaloop/central-services-shared').Util.Hapi
29
-
30
1
  const ERROR_MESSAGES = Object.freeze({
31
- emptyFilteredPartyList: 'Empty oracle partyList, filtered based on callbackEndpointType',
32
- failedToCacheSendToProxiesList: 'Failed to cache sendToProxiesList',
33
- noDiscoveryRequestsForwarded: 'No discovery requests forwarded to participants',
34
2
  sourceFspNotFound: 'Requester FSP not found',
35
3
  partyDestinationFspNotFound: 'Destination FSP not found',
36
4
  partyProxyNotFound: 'Proxy not found',
37
- proxyConnectionError: 'Proxy connection error - no successful requests sent to proxies'
5
+ proxyConnectionError: 'Proxy connection error',
6
+ failedToCacheSendToProxiesList: 'Failed to cache sendToProxiesList'
38
7
  })
39
8
 
40
9
  const HANDLER_TYPES = Object.freeze({
@@ -42,7 +11,6 @@ const HANDLER_TYPES = Object.freeze({
42
11
  })
43
12
 
44
13
  module.exports = {
45
- API_TYPES,
46
14
  ERROR_MESSAGES,
47
15
  HANDLER_TYPES
48
16
  }
@@ -26,18 +26,17 @@
26
26
  ******/
27
27
 
28
28
  const { proxies } = require('@mojaloop/central-services-shared').Util
29
- const { logger } = require('../../lib')
30
- const config = require('../../lib/config')
31
29
  const oracle = require('../../models/oracle/facade')
32
30
  const participant = require('../../models/participantEndpoint/facade')
31
+ const config = require('../../lib/config')
33
32
  const partiesUtils = require('./partiesUtils')
34
33
 
35
- /** @returns {PartiesDeps} */
36
- const createDeps = ({ cache, proxyCache, childSpan, log = logger }) => Object.freeze({
34
+ const createDeps = ({ cache, proxyCache, childSpan, log, stepState }) => Object.freeze({
37
35
  cache,
38
36
  proxyCache,
39
37
  childSpan,
40
38
  log,
39
+ stepState,
41
40
  config,
42
41
  oracle,
43
42
  participant,
@@ -50,22 +50,26 @@ const getPartiesByTypeAndID = async (headers, params, method, query, span, cache
50
50
  ['success']
51
51
  ).startTimer()
52
52
  const childSpan = span ? span.getChild(component) : undefined
53
- const deps = createDeps({ cache, proxyCache, childSpan })
54
- const service = new GetPartiesService(deps, { headers, params, query })
55
- let fspiopError
53
+ const log = logger.child({ component, params })
54
+ const stepState = libUtil.initStepState()
55
+
56
+ const deps = createDeps({ cache, proxyCache, childSpan, log, stepState })
57
+ const service = new GetPartiesService(deps)
58
+ const results = {}
56
59
 
57
60
  try {
58
- await service.handleRequest()
59
- logger.info('getPartiesByTypeAndID is done')
61
+ await service.handleRequest({ headers, params, query, results })
62
+ log.info('getPartiesByTypeAndID is done')
60
63
  histTimerEnd({ success: true })
61
64
  } catch (error) {
62
- fspiopError = await service.handleError(error)
65
+ const { requester } = results
66
+ results.fspiopError = await service.handleError({ error, requester, headers, params })
63
67
  histTimerEnd({ success: false })
64
- if (fspiopError) {
65
- libUtil.countFspiopError(fspiopError, { operation: component, step: service.currenStep })
68
+ if (results.fspiopError) {
69
+ libUtil.countFspiopError(results.fspiopError, { operation: component, step: stepState.step })
66
70
  }
67
71
  } finally {
68
- await libUtil.finishSpanWithError(childSpan, fspiopError)
72
+ await libUtil.finishSpanWithError(childSpan, results.fspiopError)
69
73
  }
70
74
  }
71
75
 
@@ -25,9 +25,13 @@
25
25
  --------------
26
26
  ******/
27
27
 
28
- const { Enum } = require('@mojaloop/central-services-shared')
28
+ const { Enum, Util: { Hapi } } = require('@mojaloop/central-services-shared')
29
+ const { MojaloopApiErrorCodes } = require('@mojaloop/sdk-standard-components').Errors
30
+ // todo: check why do we need sdk-standard-components deps here !!!
31
+ const ErrorHandler = require('@mojaloop/central-services-error-handling')
32
+
33
+ const participant = require('../../models/participantEndpoint/facade')
29
34
  const { TransformFacades } = require('../../lib')
30
- const { API_TYPES } = require('../../constants')
31
35
 
32
36
  const { FspEndpointTypes } = Enum.EndPoints
33
37
  const { Headers } = Enum.Http
@@ -46,7 +50,7 @@ const errorPartyCbType = (partySubId) => partySubId
46
50
 
47
51
  const makePutPartiesErrorPayload = async (config, fspiopError, headers, params) => {
48
52
  const body = fspiopError.toApiErrorObject(config.ERROR_HANDLING)
49
- return config.API_TYPE === API_TYPES.iso20022
53
+ return config.API_TYPE === Hapi.API_TYPES.iso20022
50
54
  ? (await TransformFacades.FSPIOP.parties.putError({ body, headers, params })).body
51
55
  : body
52
56
  }
@@ -77,12 +81,38 @@ const swapSourceDestinationHeaders = (headers) => {
77
81
  }
78
82
  }
79
83
 
84
+ // todo: check if we need this function
85
+ const createErrorHandlerOnSendingCallback = (config, logger) => async (err, headers, params, requester) => {
86
+ try {
87
+ logger.error('error in sending parties callback: ', err)
88
+ const sendTo = requester || headers[Headers.FSPIOP.SOURCE]
89
+ const errorCallbackEndpointType = errorPartyCbType(params.SubId)
90
+ const fspiopError = ErrorHandler.Factory.reformatFSPIOPError(err)
91
+ const errInfo = await makePutPartiesErrorPayload(config, fspiopError, headers, params)
92
+
93
+ await participant.sendErrorToParticipant(sendTo, errorCallbackEndpointType, errInfo, headers, params)
94
+
95
+ logger.info('handleErrorOnSendingCallback in done', { sendTo, params, errInfo })
96
+ return fspiopError
97
+ } catch (exc) {
98
+ // We can't do anything else here- we _must_ handle all errors _within_ this function because
99
+ // we've already sent a sync response- we cannot throw.
100
+ logger.error('failed to handleErrorOnSendingCallback. No further processing! ', exc)
101
+ }
102
+ }
103
+
104
+ function isNotValidPayeeCase (payload) {
105
+ return payload?.errorInformation?.errorCode === MojaloopApiErrorCodes.PAYEE_IDENTIFIER_NOT_VALID.code
106
+ }
107
+
80
108
  module.exports = {
81
109
  getPartyCbType,
82
110
  putPartyCbType,
83
111
  errorPartyCbType,
84
112
  makePutPartiesErrorPayload,
113
+ createErrorHandlerOnSendingCallback,
85
114
  alsRequestDto,
86
115
  partiesRequestOptionsDto,
87
- swapSourceDestinationHeaders
116
+ swapSourceDestinationHeaders,
117
+ isNotValidPayeeCase
88
118
  }
@@ -29,6 +29,7 @@
29
29
 
30
30
  'use strict'
31
31
 
32
+ const { Headers } = require('@mojaloop/central-services-shared').Enum.Http
32
33
  const Metrics = require('@mojaloop/central-services-metrics')
33
34
  const libUtil = require('../../lib/util')
34
35
  const { logger } = require('../../lib')
@@ -36,7 +37,9 @@ const { createDeps } = require('./deps')
36
37
  const services = require('./services')
37
38
 
38
39
  /**
39
- * Sends a callback to inform participant of successful lookup
40
+ * @function putPartiesByTypeAndID
41
+ *
42
+ * @description This sends a callback to inform participant of successful lookup
40
43
  *
41
44
  * @param {object} headers - incoming http request headers
42
45
  * @param {object} params - uri parameters of the http request
@@ -55,25 +58,45 @@ const putPartiesByTypeAndID = async (headers, params, method, payload, dataUri,
55
58
  ['success']
56
59
  ).startTimer()
57
60
  // const childSpan = span ? span.getChild(component) : undefined
58
- const deps = createDeps({ cache, proxyCache })
59
- const service = new services.PutPartiesService(deps, { headers, params, payload, dataUri })
60
- let fspiopError
61
+ const log = logger.child({ component, params })
62
+ const stepState = libUtil.initStepState()
63
+
64
+ const deps = createDeps({ cache, proxyCache, log, stepState })
65
+ const service = new services.PutPartiesService(deps)
66
+ const results = {}
67
+
68
+ const source = headers[Headers.FSPIOP.SOURCE]
69
+ const destination = headers[Headers.FSPIOP.DESTINATION]
70
+ const proxy = headers[Headers.FSPIOP.PROXY]
71
+ log.info('putPartiesByTypeAndID start', { source, destination, proxy })
61
72
 
62
73
  try {
63
- await service.handleRequest()
64
- logger.info('putPartiesByTypeAndID is done')
74
+ await service.validateSourceParticipant({ source, proxy })
75
+
76
+ if (proxy) {
77
+ await service.checkProxySuccessResponse({ destination, source, headers, params })
78
+ }
79
+
80
+ const sendTo = await service.identifyDestinationForSuccessCallback(destination)
81
+ results.requester = sendTo
82
+ await service.sendSuccessCallback({ sendTo, headers, params, dataUri })
83
+
84
+ log.info('putPartiesByTypeAndID callback was sent', { sendTo })
65
85
  histTimerEnd({ success: true })
66
86
  } catch (error) {
67
- fspiopError = await service.handleError(error)
68
- if (fspiopError) {
69
- libUtil.countFspiopError(fspiopError, { operation: component, step: service.currenStep })
87
+ const { requester } = results
88
+ results.fspiopError = await service.handleError({ error, requester, headers, params })
89
+ if (results.fspiopError) {
90
+ libUtil.countFspiopError(results.fspiopError, { operation: component, step: stepState.step })
70
91
  }
71
92
  histTimerEnd({ success: false })
72
93
  }
73
94
  }
74
95
 
75
96
  /**
76
- * Sends error callback to inform participant of failed lookup
97
+ * @function putPartiesErrorByTypeAndID
98
+ *
99
+ * @description This populates the cache of endpoints
77
100
  *
78
101
  * @param {object} headers - incoming http request headers
79
102
  * @param {object} params - uri parameters of the http request
@@ -91,31 +114,53 @@ const putPartiesErrorByTypeAndID = async (headers, params, payload, dataUri, spa
91
114
  ['success']
92
115
  ).startTimer()
93
116
  const childSpan = span ? span.getChild(component) : undefined
94
- const deps = createDeps({ cache, proxyCache, childSpan })
95
- const inputs = { headers, params, payload, dataUri }
96
- const service = new services.PutPartiesErrorService(deps, inputs)
97
- let fspiopError
117
+ const log = logger.child({ component, params })
118
+ const stepState = libUtil.initStepState()
119
+
120
+ const deps = createDeps({ cache, proxyCache, childSpan, log, stepState })
121
+ const service = new services.PutPartiesErrorService(deps)
122
+ const results = {}
123
+
124
+ const destination = headers[Headers.FSPIOP.DESTINATION]
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 })
98
128
 
99
129
  try {
100
- const needDiscovery = await service.handleRequest()
101
- if (needDiscovery) {
102
- const getPartiesService = new services.GetPartiesService(deps, inputs)
103
- await getPartiesService.triggerInterSchemeDiscoveryFlow(
104
- services.GetPartiesService.headersWithoutDestination(headers)
105
- )
106
- // think, if we need to start the whole processing with getPartiesService.handleRequest() ?
130
+ if (proxyEnabled && proxy) {
131
+ const notValid = await service.checkPayee({ headers, params, payload, proxy })
132
+ if (notValid) {
133
+ const getPartiesService = new services.GetPartiesService(deps)
134
+ // todo: think, if we need to remove destination header before starting new discovery
135
+ await getPartiesService.handleRequest({ headers, params, results })
136
+ log.info('putPartiesErrorByTypeAndID triggered new discovery flow')
137
+ histTimerEnd({ success: true })
138
+ return
139
+ }
140
+
141
+ const isLast = await service.checkLastProxyCallback({ destination, proxy, params })
142
+ if (!isLast) {
143
+ log.info('putPartiesErrorByTypeAndID proxy callback was processed', { proxy })
144
+ histTimerEnd({ success: true })
145
+ return
146
+ }
107
147
  }
108
148
 
109
- logger.info('putPartiesErrorByTypeAndID is done')
149
+ const sendTo = await service.identifyDestinationForErrorCallback(destination)
150
+ results.requester = sendTo
151
+ await service.sendErrorCallbackToParticipant({ sendTo, headers, params, dataUri })
152
+
153
+ log.info('putPartiesErrorByTypeAndID callback was sent', { sendTo })
110
154
  histTimerEnd({ success: true })
111
155
  } catch (error) {
112
- fspiopError = await service.handleError(error)
113
- if (fspiopError) {
114
- libUtil.countFspiopError(fspiopError, { operation: component, step: service.currenStep })
156
+ const { requester } = results
157
+ results.fspiopError = await service.handleError({ error, requester, headers, params })
158
+ if (results.fspiopError) {
159
+ libUtil.countFspiopError(results.fspiopError, { operation: component, step: stepState.step })
115
160
  }
116
161
  histTimerEnd({ success: false })
117
162
  } finally {
118
- await libUtil.finishSpanWithError(childSpan, fspiopError)
163
+ await libUtil.finishSpanWithError(childSpan, results.fspiopError)
119
164
  }
120
165
  }
121
166
 
@@ -26,93 +26,33 @@
26
26
  ******/
27
27
 
28
28
  const ErrorHandler = require('@mojaloop/central-services-error-handling')
29
- const { Enum } = require('@mojaloop/central-services-shared')
30
29
  const { decodePayload } = require('@mojaloop/central-services-shared').Util.StreamingProtocol
31
- const { initStepState } = require('../../../lib/util')
32
- const { createCallbackHeaders } = require('../../../lib/headers')
30
+ const { Enum } = require('@mojaloop/central-services-shared')
33
31
 
34
32
  const { FspEndpointTypes, FspEndpointTemplates } = Enum.EndPoints
35
33
  const { Headers, RestMethods } = Enum.Http
36
34
 
37
- /**
38
- * @typedef {Object} PartiesDeps
39
- * @property {Object} cache
40
- * @property {Object} proxyCache
41
- * @property {Object} log
42
- * @property {Object} config
43
- * @property {Object} oracle
44
- * @property {Object} participant
45
- * @property {Proxies} proxies
46
- * @property {Object} partiesUtils
47
- * @property {Object} [childSpan]
48
- */
49
-
50
- /**
51
- * Input parameters from party lookup request
52
- *
53
- * @typedef {Object} PartiesInputs
54
- * @property {Object} headers - incoming http request headers.
55
- * @property {Object} params - uri parameters of the http request.
56
- * @property {Object} [payload] - payload of the request being sent out.
57
- * @property {Object} [query] - uri query parameters of the http request
58
- * @property {string} [dataUri] - encoded payload of the request being sent out.
59
- */
60
-
61
- /**
62
- * Any calculated values we get during request processing
63
- *
64
- * @typedef {Object} PartiesModelState
65
- * @property {string} destination - The destination DFSP ID from headers
66
- * @property {string} source - The source DFSP ID from headers
67
- * @property {string} [proxy] - The proxy DFSP ID from headers, if present
68
- * @property {string} requester - The entity initiating the request (either a DFSP in scheme or a proxy)
69
- * @property {boolean} proxyEnabled - Indicates whether proxy functionality is enabled in the current configuration
70
- * @property {StepState} stepState - Processing steps state
71
- */
72
-
73
35
  class BasePartiesService {
74
- #deps // see PartiesDeps
75
- #inputs // see PartiesInputs
76
- #state // see PartiesModelState
77
-
78
- /**
79
- * @param {PartiesDeps} deps - The dependencies required by the class instance.
80
- * @param {PartiesInputs} inputs - The input parameters from incoming http request.
81
- * @return {void}
82
- */
83
- constructor (deps, inputs) {
84
- this.#deps = Object.freeze(deps)
85
- this.#inputs = Object.freeze(inputs)
86
- this.#state = this.#initiateState()
87
- this.log = this.deps.log.child({
88
- component: this.constructor.name,
89
- params: this.inputs.params
90
- })
36
+ constructor (deps) {
37
+ this.deps = deps
38
+ this.log = this.deps.log.child({ component: this.constructor.name })
39
+ this.proxyEnabled = !!(deps.config.PROXY_CACHE_CONFIG?.enabled && deps.proxyCache)
91
40
  }
92
41
 
93
- /** @returns {PartiesDeps} */
94
- get deps () { return this.#deps }
95
-
96
- /** @returns {PartiesInputs} */
97
- get inputs () { return this.#inputs }
42
+ // async handleRequest () {
43
+ // throw new Error('handleRequest must be implemented by subclass')
44
+ // }
98
45
 
99
- /** @returns {PartiesModelState} */
100
- get state () { return this.#state }
101
-
102
- async handleError (error) {
103
- const { headers, params } = this.inputs
46
+ async handleError ({ error, requester, headers, params }) {
104
47
  const log = this.log.child({ method: 'handleError' })
105
48
  try {
106
49
  log.error('error in processing parties request: ', error)
50
+ const sendTo = requester || headers[Headers.FSPIOP.SOURCE]
107
51
  const fspiopError = ErrorHandler.Factory.reformatFSPIOPError(error)
108
52
  const errorInfo = await this.deps.partiesUtils.makePutPartiesErrorPayload(this.deps.config, fspiopError, headers, params)
109
53
 
110
- await this.sendErrorCallback({
111
- errorInfo,
112
- headers: BasePartiesService.createErrorCallbackHeaders(headers, params),
113
- params
114
- })
115
- log.info('handleError in done')
54
+ await this.sendErrorCallback({ sendTo, errorInfo, headers, params })
55
+ log.info('handleError in done', { sendTo, errorInfo })
116
56
  return fspiopError
117
57
  } catch (exc) {
118
58
  // We can't do anything else here- we _must_ handle all errors _within_ this function because
@@ -122,88 +62,26 @@ class BasePartiesService {
122
62
  }
123
63
 
124
64
  async validateParticipant (participantId) {
125
- this.stepInProgress('validateParticipant')
126
65
  return this.deps.participant.validateParticipant(participantId)
127
66
  }
128
67
 
129
- async sendErrorCallback ({ errorInfo, headers, params }) {
130
- this.stepInProgress('sendErrorCallback')
131
- const sendTo = this.state.requester || this.state.source
68
+ async sendErrorCallback ({ sendTo, errorInfo, headers, params, payload = undefined }) {
132
69
  const endpointType = this.deps.partiesUtils.errorPartyCbType(params.SubId)
133
-
134
70
  await this.deps.participant.sendErrorToParticipant(
135
- sendTo, endpointType, errorInfo, headers, params, undefined, this.deps.childSpan
71
+ sendTo, endpointType, errorInfo, headers, params, payload, this.deps.childSpan
136
72
  )
137
- this.log.info('sendErrorCallback is done', { sendTo, errorInfo })
73
+ this.log.verbose('sendErrorCallback is done', { sendTo, errorInfo })
138
74
  }
139
75
 
140
76
  async sendDeleteOracleRequest (headers, params) {
141
- this.stepInProgress('sendDeleteOracleRequest')
142
77
  return this.deps.oracle.oracleRequest(headers, RestMethods.DELETE, params, null, null, this.deps.cache)
143
78
  }
144
79
 
145
- async removeProxyGetPartiesTimeout (alsReq) {
146
- const isRemoved = await this.deps.proxyCache.removeProxyGetPartiesTimeout(alsReq)
147
- this.log.debug('removeProxyGetPartiesTimeout is done', { isRemoved, alsReq })
148
- return isRemoved
149
- }
150
-
151
- createFspiopIdNotFoundError (errMessage, log = this.log) {
152
- log.warn(errMessage)
153
- return ErrorHandler.Factory.createFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.ID_NOT_FOUND, errMessage)
154
- }
155
-
156
- stepInProgress (stepName) {
157
- this.log.debug('step is in progress', { stepName })
158
- this.state.stepState?.inProgress(stepName)
159
- }
160
-
161
- get currenStep () {
162
- return this.state.stepState?.step
163
- }
164
-
165
- /** @returns {PartiesModelState} */
166
- #initiateState () {
167
- const { headers } = this.inputs
168
- return {
169
- destination: headers[Headers.FSPIOP.DESTINATION],
170
- source: headers[Headers.FSPIOP.SOURCE],
171
- proxy: headers[Headers.FSPIOP.PROXY],
172
- requester: '', // dfsp in scheme OR proxy
173
- proxyEnabled: !!(this.deps.config.PROXY_CACHE_CONFIG?.enabled && this.deps.proxyCache),
174
- stepState: initStepState()
175
- }
176
- }
177
-
178
80
  static decodeDataUriPayload (dataUri) {
179
81
  const decoded = decodePayload(dataUri, { asParsed: false })
180
82
  return decoded.body.toString()
181
83
  }
182
84
 
183
- static headersWithoutDestination (headers) {
184
- const { [Headers.FSPIOP.DESTINATION]: _, ...restHeaders } = headers || {}
185
- return restHeaders
186
- }
187
-
188
- static overrideDestinationHeader (headers, destination) {
189
- const { [Headers.FSPIOP.DESTINATION]: _, ...restHeaders } = headers || {}
190
- return {
191
- ...restHeaders,
192
- ...(destination && { [Headers.FSPIOP.DESTINATION]: destination })
193
- }
194
- }
195
-
196
- static createErrorCallbackHeaders (headers, params) {
197
- return createCallbackHeaders({
198
- requestHeaders: headers,
199
- partyIdType: params.Type,
200
- partyIdentifier: params.ID,
201
- endpointTemplate: params.SubId
202
- ? FspEndpointTemplates.PARTIES_SUB_ID_PUT_ERROR
203
- : FspEndpointTemplates.PARTIES_PUT_ERROR
204
- })
205
- }
206
-
207
85
  static enums () {
208
86
  return {
209
87
  FspEndpointTypes,