@all-smart/all-smart-tools 1.0.10 → 1.0.13

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 CHANGED
@@ -22,6 +22,7 @@ class asTools {
22
22
  async main() {
23
23
  this.checkLxc();
24
24
  this.checkDocker();
25
+ await this.createAdapterStorageObject();
25
26
  }
26
27
 
27
28
  async onMessage(obj) {
@@ -63,10 +64,22 @@ class asTools {
63
64
  });
64
65
  }
65
66
 
67
+ async createAdapterStorageObject(){
68
+ await this.adapter.setForeignObjectNotExistsAsync(`${this.adapter.namespace.replace(/\.\d/g, '')}.storage`, {
69
+ "type": "config",
70
+ "common": {
71
+ "name": "Adapter storage",
72
+ "type": "config",
73
+ "expert": true
74
+ },
75
+ "native": {}
76
+ });
77
+ }
78
+
66
79
  async block() {
67
80
  return new Promise(async (resolve, reject) => {
68
81
  const check = async () => {
69
- const adapterObject = await this.adapter.getForeignObjectAsync(`system.adapter.${this.adapter.namespace.replace(/\.\d/g, '')}`);
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(`system.adapter.${this.adapter.namespace.replace(/\.\d/g, '')}`, {
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(`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));
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@all-smart/all-smart-tools",
3
- "version": "1.0.10",
3
+ "version": "1.0.13",
4
4
  "main": "main.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"