@all-smart/all-smart-tools 1.0.10 → 1.0.11
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/main.js +16 -6
- package/package.json +1 -1
- package/all-smart-all-smart-tools-1.0.10.tgz +0 -0
package/main.js
CHANGED
|
@@ -63,10 +63,23 @@ class asTools {
|
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
async createAdapterStorageObject(){
|
|
67
|
+
await this.adapter.setObjectNotExistsAsync(`${this.adapter.namespace.replace(/\.\d/g, '')}.storage`, {
|
|
68
|
+
"type": "config",
|
|
69
|
+
"common": {
|
|
70
|
+
"name": "Adapter storage",
|
|
71
|
+
"type": "config",
|
|
72
|
+
"expert": true
|
|
73
|
+
},
|
|
74
|
+
"native": {}
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
|
|
66
78
|
async block() {
|
|
67
79
|
return new Promise(async (resolve, reject) => {
|
|
80
|
+
await this.createAdapterStorageObject();
|
|
68
81
|
const check = async () => {
|
|
69
|
-
const adapterObject = await this.adapter.getForeignObjectAsync(
|
|
82
|
+
const adapterObject = await this.adapter.getForeignObjectAsync(`${this.adapter.namespace.replace(/\.\d/g, '')}.storage`);
|
|
70
83
|
if (adapterObject.native.licenseCertificate) {
|
|
71
84
|
if (await this.checkLocalLicenseCertificate()) {
|
|
72
85
|
this.adapter.log.info('License Certificate OK');
|
|
@@ -178,7 +191,7 @@ class asTools {
|
|
|
178
191
|
const licenseCertificateEncoded = Buffer.from(JSON.stringify(licenseCertificate)).toString('base64');
|
|
179
192
|
this.adapter.log.debug(licenseCertificateEncoded);
|
|
180
193
|
// write license certificate
|
|
181
|
-
await this.adapter.extendForeignObjectAsync(
|
|
194
|
+
await this.adapter.extendForeignObjectAsync(`${this.adapter.namespace.replace(/\.\d/g, '')}.storage`, {
|
|
182
195
|
native: {
|
|
183
196
|
licenseCertificate: licenseCertificateEncoded
|
|
184
197
|
}
|
|
@@ -187,13 +200,10 @@ class asTools {
|
|
|
187
200
|
|
|
188
201
|
async checkLocalLicenseCertificate(){
|
|
189
202
|
// read license certificate
|
|
190
|
-
const adapterObj = await this.adapter.getForeignObjectAsync(
|
|
191
|
-
this.adapter.log.debug(`system.adapter.${this.adapter.namespace.replace(/\.\d/g, '')}`);
|
|
192
|
-
this.adapter.log.debug(JSON.stringify(adapterObj));
|
|
203
|
+
const adapterObj = await this.adapter.getForeignObjectAsync(`${this.adapter.namespace.replace(/\.\d/g, '')}.storage`);
|
|
193
204
|
const licenseCertificateEncoded = adapterObj.native.licenseCertificate;
|
|
194
205
|
// decode license file
|
|
195
206
|
const licenseCertificate = JSON.parse(Buffer.from(licenseCertificateEncoded, 'base64').toString('ascii'));
|
|
196
|
-
this.adapter.log.info(JSON.stringify(licenseCertificate));
|
|
197
207
|
// get system uuid
|
|
198
208
|
const systemMeta = await this.adapter.getForeignObjectAsync('system.meta.uuid');
|
|
199
209
|
const systemUuid = systemMeta.native.uuid;
|
package/package.json
CHANGED
|
Binary file
|