@etsoo/appscript 1.2.8 → 1.2.9
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/lib/cjs/app/CoreApp.js +16 -16
- package/lib/mjs/app/CoreApp.js +16 -16
- package/package.json +1 -1
- package/src/app/CoreApp.ts +18 -20
package/lib/cjs/app/CoreApp.js
CHANGED
|
@@ -140,32 +140,31 @@ class CoreApp {
|
|
|
140
140
|
restore() {
|
|
141
141
|
// Devices
|
|
142
142
|
const devices = this.storage.getPersistedData(CoreApp.devicesField, []);
|
|
143
|
-
// Current device id, '' means new, or reload (not included) or duplicate (included)
|
|
144
143
|
if (this.deviceId === '') {
|
|
145
|
-
// First vist, restore
|
|
146
|
-
this.storage.copyFrom(this.persistedFields,
|
|
144
|
+
// First vist, restore and keep the source
|
|
145
|
+
this.storage.copyFrom(this.persistedFields, false);
|
|
147
146
|
// Reset device id
|
|
148
147
|
this._deviceId = this.storage.getData(CoreApp.deviceIdField, '');
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const d = this.getDeviceId();
|
|
152
|
-
if (devices.includes(d)) {
|
|
153
|
-
// Duplicate tab, session data copied
|
|
154
|
-
// Remove the token, deviceId, and passphrase
|
|
155
|
-
this.resetKeys();
|
|
148
|
+
// Totally new, no data restored
|
|
149
|
+
if (this._deviceId === '')
|
|
156
150
|
return false;
|
|
157
|
-
|
|
151
|
+
}
|
|
152
|
+
// Device exists or not
|
|
153
|
+
const d = this.getDeviceId();
|
|
154
|
+
if (devices.includes(d)) {
|
|
155
|
+
// Duplicate tab, session data copied
|
|
156
|
+
// Remove the token, deviceId, and passphrase
|
|
157
|
+
this.resetKeys();
|
|
158
|
+
return false;
|
|
158
159
|
}
|
|
159
160
|
const passphraseEncrypted = this.storage.getData(CoreApp.devicePassphraseField);
|
|
160
161
|
if (passphraseEncrypted) {
|
|
161
162
|
const passphraseDecrypted = this.decrypt(passphraseEncrypted, this.name);
|
|
162
163
|
if (passphraseDecrypted != null) {
|
|
164
|
+
// Add the device to the list
|
|
165
|
+
devices.push(d);
|
|
166
|
+
this.storage.setPersistedData(CoreApp.devicesField, devices);
|
|
163
167
|
this.passphrase = passphraseDecrypted;
|
|
164
|
-
const d = this.getDeviceId();
|
|
165
|
-
if (!devices.includes(d)) {
|
|
166
|
-
devices.push(d);
|
|
167
|
-
this.storage.setPersistedData(CoreApp.devicesField, devices);
|
|
168
|
-
}
|
|
169
168
|
return true;
|
|
170
169
|
}
|
|
171
170
|
// Failed, reset keys
|
|
@@ -182,6 +181,7 @@ class CoreApp {
|
|
|
182
181
|
if (devices != null) {
|
|
183
182
|
const index = devices.indexOf(this.getDeviceId());
|
|
184
183
|
if (index !== -1) {
|
|
184
|
+
// Remove current device from the list
|
|
185
185
|
devices.splice(index, 1);
|
|
186
186
|
this.storage.setPersistedData(CoreApp.devicesField, devices);
|
|
187
187
|
}
|
package/lib/mjs/app/CoreApp.js
CHANGED
|
@@ -137,32 +137,31 @@ export class CoreApp {
|
|
|
137
137
|
restore() {
|
|
138
138
|
// Devices
|
|
139
139
|
const devices = this.storage.getPersistedData(CoreApp.devicesField, []);
|
|
140
|
-
// Current device id, '' means new, or reload (not included) or duplicate (included)
|
|
141
140
|
if (this.deviceId === '') {
|
|
142
|
-
// First vist, restore
|
|
143
|
-
this.storage.copyFrom(this.persistedFields,
|
|
141
|
+
// First vist, restore and keep the source
|
|
142
|
+
this.storage.copyFrom(this.persistedFields, false);
|
|
144
143
|
// Reset device id
|
|
145
144
|
this._deviceId = this.storage.getData(CoreApp.deviceIdField, '');
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
const d = this.getDeviceId();
|
|
149
|
-
if (devices.includes(d)) {
|
|
150
|
-
// Duplicate tab, session data copied
|
|
151
|
-
// Remove the token, deviceId, and passphrase
|
|
152
|
-
this.resetKeys();
|
|
145
|
+
// Totally new, no data restored
|
|
146
|
+
if (this._deviceId === '')
|
|
153
147
|
return false;
|
|
154
|
-
|
|
148
|
+
}
|
|
149
|
+
// Device exists or not
|
|
150
|
+
const d = this.getDeviceId();
|
|
151
|
+
if (devices.includes(d)) {
|
|
152
|
+
// Duplicate tab, session data copied
|
|
153
|
+
// Remove the token, deviceId, and passphrase
|
|
154
|
+
this.resetKeys();
|
|
155
|
+
return false;
|
|
155
156
|
}
|
|
156
157
|
const passphraseEncrypted = this.storage.getData(CoreApp.devicePassphraseField);
|
|
157
158
|
if (passphraseEncrypted) {
|
|
158
159
|
const passphraseDecrypted = this.decrypt(passphraseEncrypted, this.name);
|
|
159
160
|
if (passphraseDecrypted != null) {
|
|
161
|
+
// Add the device to the list
|
|
162
|
+
devices.push(d);
|
|
163
|
+
this.storage.setPersistedData(CoreApp.devicesField, devices);
|
|
160
164
|
this.passphrase = passphraseDecrypted;
|
|
161
|
-
const d = this.getDeviceId();
|
|
162
|
-
if (!devices.includes(d)) {
|
|
163
|
-
devices.push(d);
|
|
164
|
-
this.storage.setPersistedData(CoreApp.devicesField, devices);
|
|
165
|
-
}
|
|
166
165
|
return true;
|
|
167
166
|
}
|
|
168
167
|
// Failed, reset keys
|
|
@@ -179,6 +178,7 @@ export class CoreApp {
|
|
|
179
178
|
if (devices != null) {
|
|
180
179
|
const index = devices.indexOf(this.getDeviceId());
|
|
181
180
|
if (index !== -1) {
|
|
181
|
+
// Remove current device from the list
|
|
182
182
|
devices.splice(index, 1);
|
|
183
183
|
this.storage.setPersistedData(CoreApp.devicesField, devices);
|
|
184
184
|
}
|
package/package.json
CHANGED
package/src/app/CoreApp.ts
CHANGED
|
@@ -676,22 +676,24 @@ export abstract class CoreApp<
|
|
|
676
676
|
[]
|
|
677
677
|
);
|
|
678
678
|
|
|
679
|
-
// Current device id, '' means new, or reload (not included) or duplicate (included)
|
|
680
679
|
if (this.deviceId === '') {
|
|
681
|
-
// First vist, restore
|
|
682
|
-
this.storage.copyFrom(this.persistedFields,
|
|
680
|
+
// First vist, restore and keep the source
|
|
681
|
+
this.storage.copyFrom(this.persistedFields, false);
|
|
683
682
|
|
|
684
683
|
// Reset device id
|
|
685
684
|
this._deviceId = this.storage.getData(CoreApp.deviceIdField, '');
|
|
686
|
-
} else {
|
|
687
|
-
const d = this.getDeviceId();
|
|
688
685
|
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
686
|
+
// Totally new, no data restored
|
|
687
|
+
if (this._deviceId === '') return false;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
// Device exists or not
|
|
691
|
+
const d = this.getDeviceId();
|
|
692
|
+
if (devices.includes(d)) {
|
|
693
|
+
// Duplicate tab, session data copied
|
|
694
|
+
// Remove the token, deviceId, and passphrase
|
|
695
|
+
this.resetKeys();
|
|
696
|
+
return false;
|
|
695
697
|
}
|
|
696
698
|
|
|
697
699
|
const passphraseEncrypted = this.storage.getData<string>(
|
|
@@ -703,16 +705,11 @@ export abstract class CoreApp<
|
|
|
703
705
|
this.name
|
|
704
706
|
);
|
|
705
707
|
if (passphraseDecrypted != null) {
|
|
706
|
-
|
|
708
|
+
// Add the device to the list
|
|
709
|
+
devices.push(d);
|
|
710
|
+
this.storage.setPersistedData(CoreApp.devicesField, devices);
|
|
707
711
|
|
|
708
|
-
|
|
709
|
-
if (!devices.includes(d)) {
|
|
710
|
-
devices.push(d);
|
|
711
|
-
this.storage.setPersistedData(
|
|
712
|
-
CoreApp.devicesField,
|
|
713
|
-
devices
|
|
714
|
-
);
|
|
715
|
-
}
|
|
712
|
+
this.passphrase = passphraseDecrypted;
|
|
716
713
|
|
|
717
714
|
return true;
|
|
718
715
|
}
|
|
@@ -735,6 +732,7 @@ export abstract class CoreApp<
|
|
|
735
732
|
if (devices != null) {
|
|
736
733
|
const index = devices.indexOf(this.getDeviceId());
|
|
737
734
|
if (index !== -1) {
|
|
735
|
+
// Remove current device from the list
|
|
738
736
|
devices.splice(index, 1);
|
|
739
737
|
this.storage.setPersistedData(CoreApp.devicesField, devices);
|
|
740
738
|
}
|