@all-smart/all-smart-tools 1.0.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/.idea/all-smart-tools.iml +12 -0
- package/.idea/deployment.xml +16 -0
- package/.idea/jsLibraryMappings.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/webServers.xml +10 -0
- package/LICENSE.MD +48 -0
- package/main.js +167 -0
- package/package.json +16 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$">
|
|
5
|
+
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
6
|
+
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
7
|
+
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
8
|
+
</content>
|
|
9
|
+
<orderEntry type="inheritedJdk" />
|
|
10
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
11
|
+
</component>
|
|
12
|
+
</module>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="PublishConfigData" autoUpload="Always" serverName="local" remoteFilesAllowedToDisappearOnAutoupload="false" confirmBeforeUploading="false">
|
|
4
|
+
<option name="confirmBeforeUploading" value="false" />
|
|
5
|
+
<serverData>
|
|
6
|
+
<paths name="local">
|
|
7
|
+
<serverdata>
|
|
8
|
+
<mappings>
|
|
9
|
+
<mapping deploy="/" local="$PROJECT_DIR$" web="/" />
|
|
10
|
+
</mappings>
|
|
11
|
+
</serverdata>
|
|
12
|
+
</paths>
|
|
13
|
+
</serverData>
|
|
14
|
+
<option name="myAutoUpload" value="ALWAYS" />
|
|
15
|
+
</component>
|
|
16
|
+
</project>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/all-smart-tools.iml" filepath="$PROJECT_DIR$/.idea/all-smart-tools.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="WebServers">
|
|
4
|
+
<option name="servers">
|
|
5
|
+
<webServer id="d117c297-54c1-40da-9610-cce0b85b1a74" name="local" url="http://localhost">
|
|
6
|
+
<fileTransfer mountedRoot="$PROJECT_DIR$/../ioBroker.we-are-one/node_modules/all-smart-tools" accessType="MOUNT" port="0" />
|
|
7
|
+
</webServer>
|
|
8
|
+
</option>
|
|
9
|
+
</component>
|
|
10
|
+
</project>
|
package/LICENSE.MD
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
Software Licence Agreement
|
|
2
|
+
|
|
3
|
+
between **Christoph Gerle** (hereinafter referred to as "Licensor")
|
|
4
|
+
and the **Licensee**
|
|
5
|
+
|
|
6
|
+
1. __Subject of the agreement__
|
|
7
|
+
The Licensor grants the Licensee the non-exclusive, non-transferable right to use the software "ALL SMART Tools" (hereinafter referred to as "Software") in the version purchased by the Licensee.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
2. __Scope of use__
|
|
11
|
+
The Licensee may use the Software only in accordance with the instructions and restrictions contained in the accompanying documentation. Licensee may not sublicense, rent, sell or otherwise transfer the Software except as expressly provided in this Agreement or the accompanying Documentation.
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
3. __Proprietary Rights__
|
|
15
|
+
The Software remains the property of Licensor or its licensors and is protected by copyright and other intellectual property laws. Licensee acknowledges that it does not acquire any ownership rights in the Software.
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
4. __Warranty__
|
|
19
|
+
The Licensor warrants that the Software will perform substantially as described in the accompanying documentation. The Licensee accepts that the Software cannot be error-free due to its complexity. The Licensor therefore expressly excludes any warranty for freedom from errors or suitability for a particular purpose.
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
5. __Limitation of liability__
|
|
23
|
+
The Licensor shall not be liable for any direct, indirect, incidental or consequential damages arising out of the use or inability to use the Software, even if the Licensor has been advised of the possibility of such damages.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
6. __Termination__
|
|
27
|
+
This Agreement shall continue indefinitely unless terminated in writing by either party. The Licensor may terminate this Agreement if the Licensee breaches any of the terms of this Agreement. In the event of termination, Licensee shall immediately cease using the Software and destroy all copies of the Software and related documentation.
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
7. __General Provisions__
|
|
31
|
+
This Agreement shall be governed by the laws of the Germany, without regard to its conflict of laws principles. The parties hereby consent to the exclusive jurisdiction of the courts of the Germany in all disputes arising out of or relating to this Agreement.
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
8. __Severability Clause__
|
|
35
|
+
If any provision of this Agreement is found to be invalid or unenforceable for any reason, such provision shall be severed from the remaining provisions of this Agreement and shall not affect the validity or enforceability thereof.
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
9. __Amendments to the Agreement__
|
|
39
|
+
This Agreement may be amended only in writing and requires the consent of both parties.
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
10. __Signature__
|
|
43
|
+
This Agreement shall automatically come into force as soon as the Licensee uses the "ALL SMART Tools" software.
|
|
44
|
+
|
|
45
|
+
LICENSOR
|
|
46
|
+
Christoph Gerle
|
|
47
|
+
Schwabenstr. 40
|
|
48
|
+
87668 Rieden, Germany
|
package/main.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
const axios = require('axios').default;
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
|
|
4
|
+
const baseUrl = 'https://www.all-smart.net';
|
|
5
|
+
const key1 = 'ck_440f2f1282170f72411ac1072bfcfb4103dbd71d';
|
|
6
|
+
const key2 = 'cs_ed0ffef051b87bda36cd16f526fcdb498fc09241';
|
|
7
|
+
const key3 = 'ck_b237e18e732f099c383969a26e335b8bcb09f0eb';
|
|
8
|
+
const key4 = 'cs_59c7c687b57d4732b269d7366efa2cd03559eddb';
|
|
9
|
+
class asTools {
|
|
10
|
+
constructor(adapter) {
|
|
11
|
+
this.adapter = adapter;
|
|
12
|
+
this.licenseInvalidMassage = false;
|
|
13
|
+
this.adapter.on("message", this.onMessage.bind(this));
|
|
14
|
+
this.main();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async main() {
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async onMessage(obj) {
|
|
22
|
+
if (typeof obj === 'object' && obj.message) {
|
|
23
|
+
if (obj.command === 'send') {
|
|
24
|
+
// e.g. send email or pushover or whatever
|
|
25
|
+
if(obj.message.licenseKey){
|
|
26
|
+
this.adapter.log.info('License Key: ' + obj.message.licenseKey);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async checkObjectsUpdate(){
|
|
33
|
+
|
|
34
|
+
return this.block().then((isValid) => {
|
|
35
|
+
if(isValid){
|
|
36
|
+
this.adapter.log.info('License Key is valid');
|
|
37
|
+
return true;
|
|
38
|
+
} else {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async block() {
|
|
45
|
+
return new Promise(async (resolve, reject) => {
|
|
46
|
+
const check = async () => {
|
|
47
|
+
// look for license file
|
|
48
|
+
if (fs.existsSync(__dirname + '/cache')) {
|
|
49
|
+
if (await this.checkLocalLicenseFile()) {
|
|
50
|
+
resolve(true);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (await this.checkLicenseKey(this.adapter.config.licenseKey)) {
|
|
54
|
+
resolve(true);
|
|
55
|
+
} else {
|
|
56
|
+
if(this.licenseInvalidMassage === false){
|
|
57
|
+
this.adapter.log.warn('License Key is invalid');
|
|
58
|
+
this.licenseInvalidMassage = true;
|
|
59
|
+
}
|
|
60
|
+
setTimeout(check, 60 * 1000);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
check();
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async checkLicenseKey(){
|
|
69
|
+
try {
|
|
70
|
+
const responseValidate = await axios.get(`${baseUrl}/wp-json/lmfwc/v2/licenses/${this.adapter.config.licenseKey}`, {
|
|
71
|
+
headers: {
|
|
72
|
+
authorization: `Basic ${Buffer.from(`${key1}:${key2}`).toString('base64')}`,
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const responseProduct = await axios.get(`${baseUrl}/wp-json/wc/v3/products/${responseValidate.data.data.productId}`, {
|
|
77
|
+
headers: {
|
|
78
|
+
authorization: `Basic ${Buffer.from(`${key3}:${key4}`).toString('base64')}`
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const majorVersion = this.adapter.version.split('.')[0];
|
|
83
|
+
|
|
84
|
+
const productName = responseProduct.data.name.split(' ')[0].toLowerCase().replace('iobroker.', '');
|
|
85
|
+
const productVersion = responseProduct.data.name.split(' ')[1].replace(/[v|V]/g, '');
|
|
86
|
+
|
|
87
|
+
if(productName.trim() !== this.adapter.name.trim() || productVersion !== majorVersion){
|
|
88
|
+
this.adapter.log.info('License Key is not valid for this product');
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if(responseValidate.data.data.timesActivated === 0){
|
|
93
|
+
this.adapter.log.info('License Key is not activated yet');
|
|
94
|
+
return await this.activateLicenseKey();
|
|
95
|
+
} else if(responseValidate.data.data.timesActivated === responseValidate.data.data.timesActivatedMax){
|
|
96
|
+
// this.adapter.log.info('License Key is already in use');
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
await this.createLocalLicenseFile();
|
|
101
|
+
return true;
|
|
102
|
+
|
|
103
|
+
} catch (e) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async activateLicenseKey(){
|
|
110
|
+
try {
|
|
111
|
+
const response = await axios.get(`${baseUrl}/wp-json/lmfwc/v2/licenses/activate/${this.adapter.config.licenseKey}`, {
|
|
112
|
+
headers: {
|
|
113
|
+
authorization: `Basic ${Buffer.from(`${key1}:${key2}`).toString('base64')}`,
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
if(response.data.success === true){
|
|
118
|
+
this.adapter.log.info('License Key activated');
|
|
119
|
+
await this.createLocalLicenseFile();
|
|
120
|
+
return true;
|
|
121
|
+
} else {
|
|
122
|
+
this.adapter.log.info('License Key activation failed');
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
} catch (e) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async createLocalLicenseFile(){
|
|
131
|
+
// get system uuid
|
|
132
|
+
const systemMeta = await this.adapter.getForeignObjectAsync('system.meta.uuid');
|
|
133
|
+
const systemUuid = systemMeta.native.uuid;
|
|
134
|
+
// get license key
|
|
135
|
+
const licenseKey = this.adapter.config.licenseKey;
|
|
136
|
+
// get Major version
|
|
137
|
+
const majorVersion = this.adapter.version.split('.')[0];
|
|
138
|
+
// create license file
|
|
139
|
+
const licenseFile = {
|
|
140
|
+
"licenseKey": licenseKey,
|
|
141
|
+
"systemUuid": systemUuid,
|
|
142
|
+
"majorVersion": majorVersion
|
|
143
|
+
}
|
|
144
|
+
// encode license file
|
|
145
|
+
const licenseFileEncoded = Buffer.from(JSON.stringify(licenseFile)).toString('base64');
|
|
146
|
+
// write license file
|
|
147
|
+
fs.writeFileSync(__dirname + '/cache', licenseFileEncoded);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
async checkLocalLicenseFile(){
|
|
151
|
+
// read license file
|
|
152
|
+
const licenseFileEncoded = fs.readFileSync(__dirname + '/cache');
|
|
153
|
+
// decode license file
|
|
154
|
+
const licenseFile = JSON.parse(Buffer.from(licenseFileEncoded.toString(), 'base64').toString('ascii'));
|
|
155
|
+
// get system uuid
|
|
156
|
+
const systemMeta = await this.adapter.getForeignObjectAsync('system.meta.uuid');
|
|
157
|
+
const systemUuid = systemMeta.native.uuid;
|
|
158
|
+
// check if license file is valid
|
|
159
|
+
if(licenseFile.systemUuid === systemUuid && licenseFile.majorVersion === this.adapter.version.split('.')[0] && licenseFile.licenseKey === this.adapter.config.licenseKey){
|
|
160
|
+
return true;
|
|
161
|
+
} else {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
module.exports = asTools;
|
package/package.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@all-smart/all-smart-tools",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "main.js",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
7
|
+
},
|
|
8
|
+
"keywords": [],
|
|
9
|
+
"author": "Christoph Gerle",
|
|
10
|
+
"license": "SEE LICENSE IN LICENSE.MD",
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"axios": "^1.3.4"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {},
|
|
15
|
+
"description": ""
|
|
16
|
+
}
|