@etsoo/appscript 1.2.44 → 1.2.45

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.
@@ -475,6 +475,12 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
475
475
  * Persist settings to source when application exit
476
476
  */
477
477
  persist(): void;
478
+ /**
479
+ * Add app name as identifier
480
+ * @param field Field
481
+ * @returns Result
482
+ */
483
+ protected addIdentifier(field: string): string;
478
484
  /**
479
485
  * Setup Api
480
486
  * @param api Api
@@ -119,7 +119,7 @@ class CoreApp {
119
119
  get persistedFields() {
120
120
  return [
121
121
  CoreApp.deviceIdField,
122
- CoreApp.devicePassphraseField,
122
+ this.addIdentifier(CoreApp.devicePassphraseField),
123
123
  CoreApp.serversideDeviceIdField,
124
124
  CoreApp.headerTokenField
125
125
  ];
@@ -129,7 +129,7 @@ class CoreApp {
129
129
  }
130
130
  resetKeys() {
131
131
  this.storage.clear([
132
- CoreApp.devicePassphraseField,
132
+ this.addIdentifier(CoreApp.devicePassphraseField),
133
133
  CoreApp.headerTokenField,
134
134
  CoreApp.serversideDeviceIdField
135
135
  ], false);
@@ -158,7 +158,8 @@ class CoreApp {
158
158
  this.resetKeys();
159
159
  return false;
160
160
  }
161
- const passphraseEncrypted = this.storage.getData(CoreApp.devicePassphraseField);
161
+ // this.name to identifier different app's secret
162
+ const passphraseEncrypted = this.storage.getData(this.addIdentifier(CoreApp.devicePassphraseField));
162
163
  if (passphraseEncrypted) {
163
164
  const passphraseDecrypted = this.decrypt(passphraseEncrypted, this.name);
164
165
  if (passphraseDecrypted != null) {
@@ -191,6 +192,14 @@ class CoreApp {
191
192
  return;
192
193
  this.storage.copyTo(this.persistedFields);
193
194
  }
195
+ /**
196
+ * Add app name as identifier
197
+ * @param field Field
198
+ * @returns Result
199
+ */
200
+ addIdentifier(field) {
201
+ return field + '-' + this.name;
202
+ }
194
203
  /**
195
204
  * Setup Api
196
205
  * @param api Api
@@ -313,7 +322,7 @@ class CoreApp {
313
322
  this.storage.setPersistedData(CoreApp.devicesField, devices);
314
323
  // Current passphrase
315
324
  this.passphrase = passphrase;
316
- this.storage.setData(CoreApp.devicePassphraseField, this.encrypt(passphrase, this.name));
325
+ this.storage.setData(this.addIdentifier(CoreApp.devicePassphraseField), this.encrypt(passphrase, this.name));
317
326
  // Previous passphrase
318
327
  if (data.previousPassphrase) {
319
328
  const prev = this.decrypt(data.previousPassphrase, timestamp.toString());
@@ -443,7 +452,7 @@ class CoreApp {
443
452
  */
444
453
  clearCacheData() {
445
454
  this.clearCacheToken();
446
- this.storage.setData(CoreApp.devicePassphraseField, undefined);
455
+ this.storage.setData(this.addIdentifier(CoreApp.devicePassphraseField), undefined);
447
456
  }
448
457
  /**
449
458
  * Clear cached token
@@ -475,6 +475,12 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
475
475
  * Persist settings to source when application exit
476
476
  */
477
477
  persist(): void;
478
+ /**
479
+ * Add app name as identifier
480
+ * @param field Field
481
+ * @returns Result
482
+ */
483
+ protected addIdentifier(field: string): string;
478
484
  /**
479
485
  * Setup Api
480
486
  * @param api Api
@@ -116,7 +116,7 @@ export class CoreApp {
116
116
  get persistedFields() {
117
117
  return [
118
118
  CoreApp.deviceIdField,
119
- CoreApp.devicePassphraseField,
119
+ this.addIdentifier(CoreApp.devicePassphraseField),
120
120
  CoreApp.serversideDeviceIdField,
121
121
  CoreApp.headerTokenField
122
122
  ];
@@ -126,7 +126,7 @@ export class CoreApp {
126
126
  }
127
127
  resetKeys() {
128
128
  this.storage.clear([
129
- CoreApp.devicePassphraseField,
129
+ this.addIdentifier(CoreApp.devicePassphraseField),
130
130
  CoreApp.headerTokenField,
131
131
  CoreApp.serversideDeviceIdField
132
132
  ], false);
@@ -155,7 +155,8 @@ export class CoreApp {
155
155
  this.resetKeys();
156
156
  return false;
157
157
  }
158
- const passphraseEncrypted = this.storage.getData(CoreApp.devicePassphraseField);
158
+ // this.name to identifier different app's secret
159
+ const passphraseEncrypted = this.storage.getData(this.addIdentifier(CoreApp.devicePassphraseField));
159
160
  if (passphraseEncrypted) {
160
161
  const passphraseDecrypted = this.decrypt(passphraseEncrypted, this.name);
161
162
  if (passphraseDecrypted != null) {
@@ -188,6 +189,14 @@ export class CoreApp {
188
189
  return;
189
190
  this.storage.copyTo(this.persistedFields);
190
191
  }
192
+ /**
193
+ * Add app name as identifier
194
+ * @param field Field
195
+ * @returns Result
196
+ */
197
+ addIdentifier(field) {
198
+ return field + '-' + this.name;
199
+ }
191
200
  /**
192
201
  * Setup Api
193
202
  * @param api Api
@@ -310,7 +319,7 @@ export class CoreApp {
310
319
  this.storage.setPersistedData(CoreApp.devicesField, devices);
311
320
  // Current passphrase
312
321
  this.passphrase = passphrase;
313
- this.storage.setData(CoreApp.devicePassphraseField, this.encrypt(passphrase, this.name));
322
+ this.storage.setData(this.addIdentifier(CoreApp.devicePassphraseField), this.encrypt(passphrase, this.name));
314
323
  // Previous passphrase
315
324
  if (data.previousPassphrase) {
316
325
  const prev = this.decrypt(data.previousPassphrase, timestamp.toString());
@@ -440,7 +449,7 @@ export class CoreApp {
440
449
  */
441
450
  clearCacheData() {
442
451
  this.clearCacheToken();
443
- this.storage.setData(CoreApp.devicePassphraseField, undefined);
452
+ this.storage.setData(this.addIdentifier(CoreApp.devicePassphraseField), undefined);
444
453
  }
445
454
  /**
446
455
  * Clear cached token
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.2.44",
3
+ "version": "1.2.45",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -633,7 +633,7 @@ export abstract class CoreApp<
633
633
  protected get persistedFields() {
634
634
  return [
635
635
  CoreApp.deviceIdField,
636
- CoreApp.devicePassphraseField,
636
+ this.addIdentifier(CoreApp.devicePassphraseField),
637
637
  CoreApp.serversideDeviceIdField,
638
638
  CoreApp.headerTokenField
639
639
  ];
@@ -684,7 +684,7 @@ export abstract class CoreApp<
684
684
  private resetKeys() {
685
685
  this.storage.clear(
686
686
  [
687
- CoreApp.devicePassphraseField,
687
+ this.addIdentifier(CoreApp.devicePassphraseField),
688
688
  CoreApp.headerTokenField,
689
689
  CoreApp.serversideDeviceIdField
690
690
  ],
@@ -723,8 +723,9 @@ export abstract class CoreApp<
723
723
  return false;
724
724
  }
725
725
 
726
+ // this.name to identifier different app's secret
726
727
  const passphraseEncrypted = this.storage.getData<string>(
727
- CoreApp.devicePassphraseField
728
+ this.addIdentifier(CoreApp.devicePassphraseField)
728
729
  );
729
730
  if (passphraseEncrypted) {
730
731
  const passphraseDecrypted = this.decrypt(
@@ -769,6 +770,15 @@ export abstract class CoreApp<
769
770
  this.storage.copyTo(this.persistedFields);
770
771
  }
771
772
 
773
+ /**
774
+ * Add app name as identifier
775
+ * @param field Field
776
+ * @returns Result
777
+ */
778
+ protected addIdentifier(field: string) {
779
+ return field + '-' + this.name;
780
+ }
781
+
772
782
  /**
773
783
  * Setup Api
774
784
  * @param api Api
@@ -913,7 +923,7 @@ export abstract class CoreApp<
913
923
  // Current passphrase
914
924
  this.passphrase = passphrase;
915
925
  this.storage.setData(
916
- CoreApp.devicePassphraseField,
926
+ this.addIdentifier(CoreApp.devicePassphraseField),
917
927
  this.encrypt(passphrase, this.name)
918
928
  );
919
929
 
@@ -1075,7 +1085,10 @@ export abstract class CoreApp<
1075
1085
  */
1076
1086
  clearCacheData() {
1077
1087
  this.clearCacheToken();
1078
- this.storage.setData(CoreApp.devicePassphraseField, undefined);
1088
+ this.storage.setData(
1089
+ this.addIdentifier(CoreApp.devicePassphraseField),
1090
+ undefined
1091
+ );
1079
1092
  }
1080
1093
 
1081
1094
  /**