@mojaloop/central-services-shared 18.5.0-snapshot.3 → 18.5.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
+ ## [18.5.0](https://github.com/mojaloop/central-services-shared/compare/v18.4.0...v18.5.0) (2024-06-25)
6
+
7
+
8
+ ### Features
9
+
10
+ * **csi-164:** parameterize switch id [BREAKING CHANGES] ([#385](https://github.com/mojaloop/central-services-shared/issues/385)) ([9cb880e](https://github.com/mojaloop/central-services-shared/commit/9cb880ecec57d8eb3d6870eeb6a891b1d4d9ad89))
11
+
5
12
  ## [18.4.0](https://github.com/mojaloop/central-services-shared/compare/v18.3.8...v18.4.0) (2024-06-20)
6
13
 
7
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mojaloop/central-services-shared",
3
- "version": "18.5.0-snapshot.3",
3
+ "version": "18.5.0",
4
4
  "description": "Shared code for mojaloop central services",
5
5
  "license": "Apache-2.0",
6
6
  "author": "ModusBox",
package/src/index.d.ts CHANGED
@@ -612,7 +612,7 @@ declare namespace CentralServicesShared {
612
612
  accept: string
613
613
  }
614
614
 
615
- type RequestParams = { url: string, headers: HapiUtil.Dictionary<string>, source: string, destination: string, method?: RestMethodsEnum, payload?: any, responseType?: string, span?: any, jwsSigner?: any, protocolVersions?: ProtocolVersionsType, hubNameRegex: RegExp }
615
+ type RequestParams = { url: string, headers: HapiUtil.Dictionary<string>, source: string, destination: string, hubNameRegex: RegExp, method?: RestMethodsEnum, payload?: any, responseType?: string, span?: any, jwsSigner?: any, protocolVersions?: ProtocolVersionsType }
616
616
  interface Request {
617
617
  sendRequest(params: RequestParams): Promise<any>
618
618
  }
@@ -30,6 +30,8 @@ const ErrorHandler = require('@mojaloop/central-services-error-handling')
30
30
 
31
31
  const resourceVersions = require('../helpers').resourceVersions
32
32
 
33
+ const MISSING_FUNCTION_PARAMETERS = 'Missing parameters for function'
34
+
33
35
  /**
34
36
  * @module src/headers/transformer
35
37
  */
@@ -93,12 +95,15 @@ const getResourceInfoFromHeader = (headerValue) => {
93
95
  * }
94
96
  *
95
97
  * @param {object} headers - the http header from the request
96
- * @param {TransformHeadersConfig} headers - the http header from the request
98
+ * @param {TransformHeadersConfig} config - additional configuration for the transformation
97
99
  *
98
100
  * @returns {object} Returns the normalized headers
99
101
  */
100
102
 
101
103
  const transformHeaders = (headers, config) => {
104
+ if (!config.hubNameRegex) {
105
+ throw ErrorHandler.Factory.createInternalServerFSPIOPError(MISSING_FUNCTION_PARAMETERS)
106
+ }
102
107
  // Normalized keys
103
108
  const normalizedKeys = Object.keys(headers).reduce(
104
109
  function (keys, k) {
@@ -93,7 +93,7 @@ const sendRequest = async ({
93
93
  sendRequestSpan.setTags({ source, destination, method, url })
94
94
  }
95
95
  let requestOptions
96
- if (!url || !method || !headers || (method !== enums.Http.RestMethods.GET && method !== enums.Http.RestMethods.DELETE && !payload) || !source || !destination) {
96
+ if (!url || !method || !headers || (method !== enums.Http.RestMethods.GET && method !== enums.Http.RestMethods.DELETE && !payload) || !source || !destination || !hubNameRegex) {
97
97
  throw ErrorHandler.Factory.createInternalServerFSPIOPError(MISSING_FUNCTION_PARAMETERS)
98
98
  }
99
99
  try {