@all-smart/all-smart-tools 1.0.5 → 1.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/all-smart-all-smart-tools-1.0.10.tgz +0 -0
- package/main.js +14 -7
- package/package.json +1 -1
|
Binary file
|
package/main.js
CHANGED
|
@@ -66,10 +66,14 @@ class asTools {
|
|
|
66
66
|
async block() {
|
|
67
67
|
return new Promise(async (resolve, reject) => {
|
|
68
68
|
const check = async () => {
|
|
69
|
-
|
|
69
|
+
const adapterObject = await this.adapter.getForeignObjectAsync(`system.adapter.${this.adapter.namespace.replace(/\.\d/g, '')}`);
|
|
70
|
+
if (adapterObject.native.licenseCertificate) {
|
|
70
71
|
if (await this.checkLocalLicenseCertificate()) {
|
|
71
|
-
this.adapter.log.info('License
|
|
72
|
+
this.adapter.log.info('License Certificate OK');
|
|
72
73
|
resolve(true);
|
|
74
|
+
} else {
|
|
75
|
+
this.adapter.log.warn('There was an error validating the license')
|
|
76
|
+
reject(false);
|
|
73
77
|
}
|
|
74
78
|
} else if (await this.checkLicenseKey()) {
|
|
75
79
|
resolve(true);
|
|
@@ -171,22 +175,25 @@ class asTools {
|
|
|
171
175
|
"majorVersion": majorVersion
|
|
172
176
|
}
|
|
173
177
|
// encode license certificate
|
|
174
|
-
const
|
|
178
|
+
const licenseCertificateEncoded = Buffer.from(JSON.stringify(licenseCertificate)).toString('base64');
|
|
179
|
+
this.adapter.log.debug(licenseCertificateEncoded);
|
|
175
180
|
// write license certificate
|
|
176
181
|
await this.adapter.extendForeignObjectAsync(`system.adapter.${this.adapter.namespace.replace(/\.\d/g, '')}`, {
|
|
177
182
|
native: {
|
|
178
|
-
licenseCertificate:
|
|
183
|
+
licenseCertificate: licenseCertificateEncoded
|
|
179
184
|
}
|
|
180
185
|
})
|
|
181
186
|
}
|
|
182
187
|
|
|
183
188
|
async checkLocalLicenseCertificate(){
|
|
184
189
|
// read license certificate
|
|
185
|
-
const
|
|
186
|
-
|
|
190
|
+
const adapterObj = await this.adapter.getForeignObjectAsync(`system.adapter.${this.adapter.namespace.replace(/\.\d/g, '')}`);
|
|
191
|
+
this.adapter.log.debug(`system.adapter.${this.adapter.namespace.replace(/\.\d/g, '')}`);
|
|
192
|
+
this.adapter.log.debug(JSON.stringify(adapterObj));
|
|
187
193
|
const licenseCertificateEncoded = adapterObj.native.licenseCertificate;
|
|
188
194
|
// decode license file
|
|
189
|
-
const licenseCertificate = JSON.parse(
|
|
195
|
+
const licenseCertificate = JSON.parse(Buffer.from(licenseCertificateEncoded, 'base64').toString('ascii'));
|
|
196
|
+
this.adapter.log.info(JSON.stringify(licenseCertificate));
|
|
190
197
|
// get system uuid
|
|
191
198
|
const systemMeta = await this.adapter.getForeignObjectAsync('system.meta.uuid');
|
|
192
199
|
const systemUuid = systemMeta.native.uuid;
|