soajs.controller 4.2.38 → 4.2.40

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/README.md CHANGED
@@ -38,6 +38,7 @@ Enabling CORS allows different domains to communicate with SOAJS via its gateway
38
38
  More information on the Controller is available on the website section [Controller](https://soajsorg.atlassian.net/wiki/x/loAwb)
39
39
 
40
40
 
41
+
41
42
  ### License
42
43
  *Copyright SOAJS All Rights Reserved.*
43
44
 
@@ -15,12 +15,12 @@ const coreLibs = require("soajs.core.libs");
15
15
  * @param {Object} originalAclObj
16
16
  */
17
17
  module.exports = (originalAclObj) => {
18
-
18
+
19
19
  let aclObj = null;
20
20
  if (originalAclObj) {
21
21
  aclObj = coreLibs.utils.cloneObj(originalAclObj);
22
22
  }
23
-
23
+
24
24
  /**
25
25
  * changes all tokens found in url with a regular expression
26
26
  * @param {String} route
@@ -28,14 +28,18 @@ module.exports = (originalAclObj) => {
28
28
  */
29
29
  function constructRegExp(route) {
30
30
  const { pathToRegexp } = require("path-to-regexp");
31
- let keys = [];
32
- let out = pathToRegexp(route, keys, {sensitive: true});
33
- if (out && out.keys && out.keys.length > 0) {
34
- out = new RegExp(out.toString());
31
+ // let keys = [];
32
+ // let out = pathToRegexp(route, keys, {sensitive: true});
33
+ let out = pathToRegexp(route, { sensitive: true });
34
+ if (out.regexp) {
35
+ return out.regexp;
35
36
  }
37
+ // if (out && out.keys && out.keys.length > 0) {
38
+ // out = new RegExp(out.toString());
39
+ // }
36
40
  return out;
37
41
  }
38
-
42
+
39
43
  /**
40
44
  * check if the given route contains the path param attribute "/:"
41
45
  * @param {String} route
@@ -44,7 +48,7 @@ module.exports = (originalAclObj) => {
44
48
  function isAttributeRoute(route) {
45
49
  return route.includes("/:");
46
50
  }
47
-
51
+
48
52
  /**
49
53
  * recursively loop in acl object,
50
54
  * fetch each entry and its sub entries
@@ -55,9 +59,9 @@ module.exports = (originalAclObj) => {
55
59
  * @param {string} currentSub
56
60
  */
57
61
  function fetchSubObjectsAndReplace(ancestor, object, currentSub) {
58
-
62
+
59
63
  let current = (currentSub) ? object[currentSub] : object;
60
-
64
+
61
65
  /**
62
66
  * if current entry is an object and object has properties and property neither the first nor the last child in object
63
67
  * recursively loop on this child
@@ -66,7 +70,7 @@ module.exports = (originalAclObj) => {
66
70
  if (currentSub && siblings.indexOf(currentSub) !== (siblings.length - 1)) {
67
71
  fetchSubObjectsAndReplace(ancestor, object, siblings[siblings.indexOf(currentSub) + 1]);
68
72
  }
69
-
73
+
70
74
  /**
71
75
  * if current entry is an object and object has properties
72
76
  * recursively loop on first child in object
@@ -77,32 +81,32 @@ module.exports = (originalAclObj) => {
77
81
  fetchSubObjectsAndReplace(object, current, subObjects[0]);
78
82
  }
79
83
  }
80
-
84
+
81
85
  /**
82
86
  * if the the route has an attribute
83
87
  * copy all the info of apis[route]
84
88
  * create a new entry from copied information and push it to apisRegExp
85
89
  */
86
90
  if (currentSub && isAttributeRoute(currentSub)) {
87
-
91
+
88
92
  let oldCurrentSub = currentSub;
89
-
93
+
90
94
  if (!ancestor.apisRegExp) {
91
95
  ancestor.apisRegExp = [];
92
96
  }
93
-
97
+
94
98
  let regExp = constructRegExp(currentSub);
95
99
  let obj = object[oldCurrentSub];
96
100
  obj.regExp = regExp;
97
101
  ancestor.apisRegExp.push(obj);
98
-
102
+
99
103
  delete object[oldCurrentSub];
100
104
  }
101
105
  }
102
-
106
+
103
107
  if (aclObj && typeof aclObj === 'object' && Object.keys(aclObj).length > 0) {
104
108
  fetchSubObjectsAndReplace(null, aclObj, null);
105
109
  }
106
-
110
+
107
111
  return aclObj;
108
112
  };
@@ -240,7 +240,7 @@ let ha = {
240
240
  return cb(hostname);
241
241
  } else {
242
242
  if (process.env.SOAJS_DEPLOY_HA === 'kubernetes' && serviceName && version) {
243
- serviceName += "-v" + version + "-service";
243
+ // serviceName += "-v" + version + "-service";
244
244
  return cb(env + "-" + serviceName + "-v" + version + "-service");
245
245
  } else {
246
246
  lib.getHostFromAPI(serviceName, version, cb);
package/mw/mt/index.js CHANGED
@@ -325,6 +325,7 @@ module.exports = (configuration) => {
325
325
  injectObj.awareness.interConnect.push(item);
326
326
  } else {
327
327
  req.soajs.log.debug(serviceName + " interConnect failed to fetch latestVersion for [" + item.name + "]");
328
+ injectObj.awareness.interConnect.push(item);
328
329
  }
329
330
  return callback();
330
331
  });
package/mw/mt/utils.js CHANGED
@@ -36,11 +36,15 @@ if (process.env.SOAJS_SENSITIVE_ENVS) {
36
36
  const { pathToRegexp } = require("path-to-regexp");
37
37
 
38
38
  function constructRegExp(route) {
39
- let keys = [];
40
- let out = pathToRegexp(route, keys, { sensitive: true });
41
- if (out && out.keys && out.keys.length > 0) {
42
- out = new RegExp(out.toString());
39
+ // let keys = [];
40
+ // let out = pathToRegexp(route, keys, { sensitive: true });
41
+ let out = pathToRegexp(route, { sensitive: true });
42
+ if (out.regexp) {
43
+ return out.regexp;
43
44
  }
45
+ // if (out && out.keys && out.keys.length > 0) {
46
+ // out = new RegExp(out.toString());
47
+ // }
44
48
  return out;
45
49
  }
46
50
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "soajs.controller",
3
3
  "description": "soajs multi tenant API gateway",
4
- "version": "4.2.38",
4
+ "version": "4.2.40",
5
5
  "author": {
6
6
  "name": "soajs team",
7
7
  "email": "team@soajs.org"
@@ -27,17 +27,17 @@
27
27
  "merge": "2.1.1",
28
28
  "netmask": "2.0.2",
29
29
  "oauth2-server": "2.4.1",
30
- "path-to-regexp": "6.2.2",
30
+ "path-to-regexp": "8.3.0",
31
31
  "soajs.core.libs": "1.2.1",
32
- "soajs.core.modules": "5.2.15",
33
- "soajs.urac.driver": "3.2.12",
32
+ "soajs.core.modules": "5.2.16",
33
+ "soajs.urac.driver": "3.2.13",
34
34
  "useragent": "2.3.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@babel/core": "7.27.1",
38
- "@babel/plugin-transform-runtime": "7.27.1",
39
- "@babel/preset-env": "7.27.2",
40
- "@babel/runtime": "7.27.1",
37
+ "@babel/core": "7.28.4",
38
+ "@babel/plugin-transform-runtime": "7.28.3",
39
+ "@babel/preset-env": "7.28.3",
40
+ "@babel/runtime": "7.28.4",
41
41
  "express": "4.21.1",
42
42
  "grunt": "1.6.1",
43
43
  "grunt-babel": "8.0.0",
@@ -49,9 +49,9 @@
49
49
  "grunt-istanbul": "0.8.0",
50
50
  "grunt-jsdoc": "2.4.1",
51
51
  "grunt-mocha-test": "0.13.3",
52
- "mocha": "11.5.0",
53
- "nock": "14.0.4",
52
+ "mocha": "11.7.2",
53
+ "nock": "14.0.10",
54
54
  "request": "2.88.2",
55
- "sinon": "20.0.0"
55
+ "sinon": "21.0.0"
56
56
  }
57
57
  }
@@ -26,6 +26,9 @@ describe("Unit test for: lib - apiPathParam2apiRegExp", function () {
26
26
  },
27
27
  "/refreshToken/:token": {
28
28
  access: false
29
+ },
30
+ "/refreshToken/:token/user/:userId": {
31
+ access: false
29
32
  }
30
33
  }
31
34
  }
@@ -34,6 +37,9 @@ describe("Unit test for: lib - apiPathParam2apiRegExp", function () {
34
37
  it("Vanilla test", function (done) {
35
38
  let response = lib(acl);
36
39
  assert.ok(response.oauth.delete.apisRegExp);
40
+ let _path = "/refreshToken/12242rde21sew/user/ed2ed23werd2wfd3"
41
+ let test = _path.match(response.oauth.delete.apisRegExp[0].regExp);
42
+ assert.ok(test);
37
43
  done();
38
44
  });
39
45
  });