thorin-plugin-cluster-kube 2.0.9 → 2.0.10

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/index.js CHANGED
@@ -16,7 +16,7 @@ module.exports = function init(thorin, opt, pluginName) {
16
16
  }, // this is the service name
17
17
  token: process.env.CLUSTER_TOKEN || null, // A shared verification token used for auth
18
18
  tokenHeader: 'x-cluster-token', // The HTTP header to place the auth token in
19
- namespace: 'svc.cluster.local', // The kube namespace name
19
+ namespace: process.env.CLUSTER_NAMESPACE || 'svc.cluster.local', // The kube namespace name
20
20
  protocol: 'http', // The default protocol for all communication
21
21
  alias: { // aliases for services.
22
22
  },
@@ -167,21 +167,21 @@ module.exports = function init(thorin, opt) {
167
167
  * */
168
168
  sign(payload, service) {
169
169
  if (!this.#token) return null;
170
- if (!service) service = thorin.app;
171
170
  let expireAt = Date.now() + DEFAULT_TIMEOUT,
172
171
  hashString = payload.type + expireAt.toString();
173
172
  let publicData = {
174
173
  e: expireAt
175
174
  };
176
- if (service.name) {
177
- publicData.n = service.name;
178
- hashString += publicData.n;
179
- }
180
- if (service.type) {
181
- publicData.t = service.type;
182
- hashString += publicData.t;
175
+ if (service) {
176
+ if (service.name) {
177
+ publicData.n = service.name;
178
+ hashString += publicData.n;
179
+ }
180
+ if (service.type) {
181
+ publicData.t = service.type;
182
+ hashString += publicData.t;
183
+ }
183
184
  }
184
-
185
185
  publicData = JSON.stringify(publicData);
186
186
  let hashValue = crypto.createHmac(DEFAULT_ALG, this.#token)
187
187
  .update(hashString)
@@ -244,4 +244,4 @@ module.exports = function init(thorin, opt) {
244
244
  }
245
245
 
246
246
  return ThorinClusterClient;
247
- }
247
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "thorin-plugin-cluster-kube",
3
3
  "author": "UNLOQ Systems",
4
- "version": "2.0.9",
4
+ "version": "2.0.10",
5
5
  "dependencies": {},
6
6
  "description": "Thorin.js cluster plugin for microservice communication within a kubernetes environment",
7
7
  "main": "index.js",
@@ -10,7 +10,7 @@
10
10
  "type": "git",
11
11
  "url": "https://github.com/Thorinjs/Thorin-plugin-cluster-kube"
12
12
  },
13
- "homepage": "http://thorinjs.com",
13
+ "homepage": "https://thorinjs.com",
14
14
  "bugs": {
15
15
  "url": "https://github.com/Thorinjs/Thorin-plugin-cluster-kube/issues"
16
16
  },