@all-smart/all-smart-tools 1.0.0 → 1.0.1

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.
Files changed (2) hide show
  1. package/main.js +24 -11
  2. package/package.json +2 -2
package/main.js CHANGED
@@ -10,6 +10,8 @@ class asTools {
10
10
  constructor(adapter) {
11
11
  this.adapter = adapter;
12
12
  this.licenseInvalidMassage = false;
13
+ this.licenseReCheckCount = 0;
14
+ this.reCheckTimeout = null;
13
15
  this.adapter.on("message", this.onMessage.bind(this));
14
16
  this.main();
15
17
  }
@@ -49,19 +51,27 @@ class asTools {
49
51
  if (await this.checkLocalLicenseFile()) {
50
52
  resolve(true);
51
53
  }
52
- }
53
- if (await this.checkLicenseKey(this.adapter.config.licenseKey)) {
54
+ } else if (await this.checkLicenseKey(this.adapter.config.licenseKey)) {
55
+ this.licenseReCheckCount = 0;
54
56
  resolve(true);
55
57
  } else {
56
- if(this.licenseInvalidMassage === false){
57
- this.adapter.log.warn('License Key is invalid');
58
- this.licenseInvalidMassage = true;
58
+ this.licenseReCheckCount++;
59
+ if (this.licenseReCheckCount >= 5) {
60
+ this.adapter.log.warn('License Key re-check limit reached');
61
+ if(this.reCheckTimeout) clearTimeout(this.reCheckTimeout);
62
+ resolve(false);
63
+ } else {
64
+ if (this.licenseInvalidMassage === false) {
65
+ this.adapter.log.warn('License Key is invalid');
66
+ this.licenseInvalidMassage = true;
67
+ }
68
+ if (this.reCheckTimeout) clearTimeout(this.reCheckTimeout);
69
+ setTimeout(check, 60 * 1000);
59
70
  }
60
- setTimeout(check, 60 * 1000);
61
71
  }
62
72
  };
63
73
 
64
- check();
74
+ if(this.licenseReCheckCount <= 5) check();
65
75
  });
66
76
  }
67
77
 
@@ -89,18 +99,20 @@ class asTools {
89
99
  return false;
90
100
  }
91
101
 
92
- if(responseValidate.data.data.timesActivated === 0){
102
+ if(responseValidate.data.data.timesActivated === null || responseValidate.data.data.timesActivated < responseValidate.data.data.timesActivatedMax){
93
103
  this.adapter.log.info('License Key is not activated yet');
94
104
  return await this.activateLicenseKey();
95
105
  } else if(responseValidate.data.data.timesActivated === responseValidate.data.data.timesActivatedMax){
96
- // this.adapter.log.info('License Key is already in use');
106
+ this.adapter.log.info('License Key was already activated');
107
+ this.licenseReCheckCount = 6;
97
108
  return false;
98
109
  }
99
110
 
100
- await this.createLocalLicenseFile();
101
- return true;
111
+ // await this.createLocalLicenseFile(); Why here? This has to be in activateLicenseKey
112
+ // return true;
102
113
 
103
114
  } catch (e) {
115
+ this.adapter.log.debug('License key check error: ' + e)
104
116
  return false;
105
117
  }
106
118
 
@@ -123,6 +135,7 @@ class asTools {
123
135
  return false;
124
136
  }
125
137
  } catch (e) {
138
+ this.adapter.log.debug('Error license key activation: ' + e);
126
139
  return false;
127
140
  }
128
141
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@all-smart/all-smart-tools",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "main": "main.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -9,7 +9,7 @@
9
9
  "author": "Christoph Gerle",
10
10
  "license": "SEE LICENSE IN LICENSE.MD",
11
11
  "dependencies": {
12
- "axios": "^1.3.4"
12
+ "axios": "^1.6.5"
13
13
  },
14
14
  "devDependencies": {},
15
15
  "description": ""