@etsoo/appscript 1.4.23 → 1.4.25

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.
@@ -191,6 +191,10 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
191
191
  * @returns true means device is invalid
192
192
  */
193
193
  checkDeviceResult(result: IActionResult): boolean;
194
+ /**
195
+ * Clear device id
196
+ */
197
+ clearDeviceId(): void;
194
198
  /**
195
199
  * Init call
196
200
  * @param callback Callback
@@ -332,10 +332,19 @@ class CoreApp {
332
332
  * @returns true means device is invalid
333
333
  */
334
334
  checkDeviceResult(result) {
335
- if (result.type === 'NoValidData' && result.field === 'Device')
335
+ if (result.type === 'DataProcessingFailed' ||
336
+ (result.type === 'NoValidData' && result.field === 'Device'))
336
337
  return true;
337
338
  return false;
338
339
  }
340
+ /**
341
+ * Clear device id
342
+ */
343
+ clearDeviceId() {
344
+ this._deviceId = '';
345
+ this.storage.clear([this.fields.deviceId], false);
346
+ this.storage.clear([this.fields.deviceId], true);
347
+ }
339
348
  /**
340
349
  * Init call
341
350
  * @param callback Callback
@@ -346,7 +355,7 @@ class CoreApp {
346
355
  var _a;
347
356
  // Reset keys
348
357
  if (resetKeys) {
349
- this._deviceId = '';
358
+ this.clearDeviceId();
350
359
  this.resetKeys();
351
360
  }
352
361
  // Passphrase exists?
@@ -394,7 +403,7 @@ class CoreApp {
394
403
  if (callback)
395
404
  callback(false);
396
405
  // Clear device id
397
- this.storage.setData(this.fields.deviceId, undefined);
406
+ this.clearDeviceId();
398
407
  return;
399
408
  }
400
409
  const updateResult = await this.initCallUpdate(result.data, data.timestamp);
@@ -189,6 +189,10 @@ export interface IApp {
189
189
  * Clear cached token
190
190
  */
191
191
  clearCacheToken(): void;
192
+ /**
193
+ * Clear device id
194
+ */
195
+ clearDeviceId(): void;
192
196
  /**
193
197
  * Decrypt message
194
198
  * @param messageEncrypted Encrypted message
@@ -191,6 +191,10 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
191
191
  * @returns true means device is invalid
192
192
  */
193
193
  checkDeviceResult(result: IActionResult): boolean;
194
+ /**
195
+ * Clear device id
196
+ */
197
+ clearDeviceId(): void;
194
198
  /**
195
199
  * Init call
196
200
  * @param callback Callback
@@ -306,10 +306,19 @@ export class CoreApp {
306
306
  * @returns true means device is invalid
307
307
  */
308
308
  checkDeviceResult(result) {
309
- if (result.type === 'NoValidData' && result.field === 'Device')
309
+ if (result.type === 'DataProcessingFailed' ||
310
+ (result.type === 'NoValidData' && result.field === 'Device'))
310
311
  return true;
311
312
  return false;
312
313
  }
314
+ /**
315
+ * Clear device id
316
+ */
317
+ clearDeviceId() {
318
+ this._deviceId = '';
319
+ this.storage.clear([this.fields.deviceId], false);
320
+ this.storage.clear([this.fields.deviceId], true);
321
+ }
313
322
  /**
314
323
  * Init call
315
324
  * @param callback Callback
@@ -320,7 +329,7 @@ export class CoreApp {
320
329
  var _a;
321
330
  // Reset keys
322
331
  if (resetKeys) {
323
- this._deviceId = '';
332
+ this.clearDeviceId();
324
333
  this.resetKeys();
325
334
  }
326
335
  // Passphrase exists?
@@ -368,7 +377,7 @@ export class CoreApp {
368
377
  if (callback)
369
378
  callback(false);
370
379
  // Clear device id
371
- this.storage.setData(this.fields.deviceId, undefined);
380
+ this.clearDeviceId();
372
381
  return;
373
382
  }
374
383
  const updateResult = await this.initCallUpdate(result.data, data.timestamp);
@@ -189,6 +189,10 @@ export interface IApp {
189
189
  * Clear cached token
190
190
  */
191
191
  clearCacheToken(): void;
192
+ /**
193
+ * Clear device id
194
+ */
195
+ clearDeviceId(): void;
192
196
  /**
193
197
  * Decrypt message
194
198
  * @param messageEncrypted Encrypted message
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.4.23",
3
+ "version": "1.4.25",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -59,14 +59,14 @@
59
59
  },
60
60
  "devDependencies": {
61
61
  "@babel/cli": "^7.22.6",
62
- "@babel/core": "^7.22.7",
62
+ "@babel/core": "^7.22.8",
63
63
  "@babel/plugin-transform-runtime": "^7.22.7",
64
64
  "@babel/preset-env": "^7.22.7",
65
65
  "@babel/runtime-corejs3": "^7.22.6",
66
66
  "@types/crypto-js": "^4.1.1",
67
67
  "@types/jest": "^29.5.2",
68
- "jest": "^29.6.0",
69
- "jest-environment-jsdom": "^29.6.0",
68
+ "jest": "^29.6.1",
69
+ "jest-environment-jsdom": "^29.6.1",
70
70
  "ts-jest": "^29.1.1",
71
71
  "typescript": "^5.1.6"
72
72
  }
@@ -492,11 +492,23 @@ export abstract class CoreApp<
492
492
  * @returns true means device is invalid
493
493
  */
494
494
  checkDeviceResult(result: IActionResult): boolean {
495
- if (result.type === 'NoValidData' && result.field === 'Device')
495
+ if (
496
+ result.type === 'DataProcessingFailed' ||
497
+ (result.type === 'NoValidData' && result.field === 'Device')
498
+ )
496
499
  return true;
497
500
  return false;
498
501
  }
499
502
 
503
+ /**
504
+ * Clear device id
505
+ */
506
+ clearDeviceId() {
507
+ this._deviceId = '';
508
+ this.storage.clear([this.fields.deviceId], false);
509
+ this.storage.clear([this.fields.deviceId], true);
510
+ }
511
+
500
512
  /**
501
513
  * Init call
502
514
  * @param callback Callback
@@ -506,7 +518,7 @@ export abstract class CoreApp<
506
518
  async initCall(callback?: (result: boolean) => void, resetKeys?: boolean) {
507
519
  // Reset keys
508
520
  if (resetKeys) {
509
- this._deviceId = '';
521
+ this.clearDeviceId();
510
522
  this.resetKeys();
511
523
  }
512
524
 
@@ -565,7 +577,7 @@ export abstract class CoreApp<
565
577
  if (callback) callback(false);
566
578
 
567
579
  // Clear device id
568
- this.storage.setData(this.fields.deviceId, undefined);
580
+ this.clearDeviceId();
569
581
 
570
582
  return;
571
583
  }
package/src/app/IApp.ts CHANGED
@@ -253,6 +253,11 @@ export interface IApp {
253
253
  */
254
254
  clearCacheToken(): void;
255
255
 
256
+ /**
257
+ * Clear device id
258
+ */
259
+ clearDeviceId(): void;
260
+
256
261
  /**
257
262
  * Decrypt message
258
263
  * @param messageEncrypted Encrypted message