@etsoo/appscript 1.2.43 → 1.2.47
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.d.ts +6 -0
- package/lib/cjs/app/CoreApp.js +29 -20
- package/lib/cjs/bridges/IBridgeHost.d.ts +2 -1
- package/lib/cjs/i18n/zh-CN.json +1 -1
- package/lib/cjs/i18n/zh-HK.json +1 -1
- package/lib/mjs/app/CoreApp.d.ts +6 -0
- package/lib/mjs/app/CoreApp.js +29 -20
- package/lib/mjs/bridges/IBridgeHost.d.ts +2 -1
- package/lib/mjs/i18n/zh-CN.json +1 -1
- package/lib/mjs/i18n/zh-HK.json +1 -1
- package/package.json +1 -1
- package/src/app/CoreApp.ts +56 -20
- package/src/bridges/IBridgeHost.ts +2 -1
- package/src/i18n/zh-CN.json +1 -1
- package/src/i18n/zh-HK.json +1 -1
package/lib/cjs/app/CoreApp.d.ts
CHANGED
|
@@ -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
|
package/lib/cjs/app/CoreApp.js
CHANGED
|
@@ -46,7 +46,7 @@ class CoreApp {
|
|
|
46
46
|
this.storage = storage;
|
|
47
47
|
this.name = name;
|
|
48
48
|
// Device id
|
|
49
|
-
this._deviceId = storage.getData(CoreApp.deviceIdField, '');
|
|
49
|
+
this._deviceId = storage.getData(this.addIdentifier(CoreApp.deviceIdField), '');
|
|
50
50
|
// Restore
|
|
51
51
|
this.restore();
|
|
52
52
|
this.setApi(api);
|
|
@@ -118,10 +118,10 @@ class CoreApp {
|
|
|
118
118
|
*/
|
|
119
119
|
get persistedFields() {
|
|
120
120
|
return [
|
|
121
|
-
CoreApp.deviceIdField,
|
|
122
|
-
CoreApp.devicePassphraseField,
|
|
123
|
-
CoreApp.serversideDeviceIdField,
|
|
124
|
-
CoreApp.headerTokenField
|
|
121
|
+
this.addIdentifier(CoreApp.deviceIdField),
|
|
122
|
+
this.addIdentifier(CoreApp.devicePassphraseField),
|
|
123
|
+
this.addIdentifier(CoreApp.serversideDeviceIdField),
|
|
124
|
+
this.addIdentifier(CoreApp.headerTokenField)
|
|
125
125
|
];
|
|
126
126
|
}
|
|
127
127
|
getDeviceId() {
|
|
@@ -129,9 +129,9 @@ class CoreApp {
|
|
|
129
129
|
}
|
|
130
130
|
resetKeys() {
|
|
131
131
|
this.storage.clear([
|
|
132
|
-
CoreApp.devicePassphraseField,
|
|
133
|
-
CoreApp.headerTokenField,
|
|
134
|
-
CoreApp.serversideDeviceIdField
|
|
132
|
+
this.addIdentifier(CoreApp.devicePassphraseField),
|
|
133
|
+
this.addIdentifier(CoreApp.headerTokenField),
|
|
134
|
+
this.addIdentifier(CoreApp.serversideDeviceIdField)
|
|
135
135
|
], false);
|
|
136
136
|
this.passphrase = '';
|
|
137
137
|
}
|
|
@@ -145,7 +145,7 @@ class CoreApp {
|
|
|
145
145
|
// First vist, restore and keep the source
|
|
146
146
|
this.storage.copyFrom(this.persistedFields, false);
|
|
147
147
|
// Reset device id
|
|
148
|
-
this._deviceId = this.storage.getData(CoreApp.deviceIdField, '');
|
|
148
|
+
this._deviceId = this.storage.getData(this.addIdentifier(CoreApp.deviceIdField), '');
|
|
149
149
|
// Totally new, no data restored
|
|
150
150
|
if (this._deviceId === '')
|
|
151
151
|
return false;
|
|
@@ -158,7 +158,8 @@ class CoreApp {
|
|
|
158
158
|
this.resetKeys();
|
|
159
159
|
return false;
|
|
160
160
|
}
|
|
161
|
-
|
|
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
|
|
@@ -247,7 +256,7 @@ class CoreApp {
|
|
|
247
256
|
return;
|
|
248
257
|
}
|
|
249
258
|
// Serverside encrypted device id
|
|
250
|
-
const identifier = this.storage.getData(CoreApp.serversideDeviceIdField);
|
|
259
|
+
const identifier = this.storage.getData(this.addIdentifier(CoreApp.serversideDeviceIdField));
|
|
251
260
|
// Timestamp
|
|
252
261
|
const timestamp = new Date().getTime();
|
|
253
262
|
// Request data
|
|
@@ -283,7 +292,7 @@ class CoreApp {
|
|
|
283
292
|
if (callback)
|
|
284
293
|
callback(false);
|
|
285
294
|
// Clear device id
|
|
286
|
-
this.storage.setData(CoreApp.deviceIdField, undefined);
|
|
295
|
+
this.storage.setData(this.addIdentifier(CoreApp.deviceIdField), undefined);
|
|
287
296
|
return;
|
|
288
297
|
}
|
|
289
298
|
this.initCallUpdate(result.data, data.timestamp);
|
|
@@ -306,14 +315,14 @@ class CoreApp {
|
|
|
306
315
|
return;
|
|
307
316
|
// Update device id and cache it
|
|
308
317
|
this._deviceId = data.deviceId;
|
|
309
|
-
this.storage.setData(CoreApp.deviceIdField, this._deviceId);
|
|
318
|
+
this.storage.setData(this.addIdentifier(CoreApp.deviceIdField), this._deviceId);
|
|
310
319
|
// Devices
|
|
311
320
|
const devices = this.storage.getPersistedData(CoreApp.devicesField, []);
|
|
312
321
|
devices.push(this.getDeviceId());
|
|
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());
|
|
@@ -345,7 +354,7 @@ class CoreApp {
|
|
|
345
354
|
* @returns Fields
|
|
346
355
|
*/
|
|
347
356
|
initCallEncryptedUpdateFields() {
|
|
348
|
-
return [CoreApp.headerTokenField];
|
|
357
|
+
return [this.addIdentifier(CoreApp.headerTokenField)];
|
|
349
358
|
}
|
|
350
359
|
/**
|
|
351
360
|
* Alert action result
|
|
@@ -370,7 +379,7 @@ class CoreApp {
|
|
|
370
379
|
if (refreshToken !== '') {
|
|
371
380
|
if (refreshToken != null)
|
|
372
381
|
refreshToken = this.encrypt(refreshToken);
|
|
373
|
-
this.storage.setData(CoreApp.headerTokenField, refreshToken);
|
|
382
|
+
this.storage.setData(this.addIdentifier(CoreApp.headerTokenField), refreshToken);
|
|
374
383
|
}
|
|
375
384
|
// Reset tryLogin state
|
|
376
385
|
this._isTryingLogin = false;
|
|
@@ -443,14 +452,14 @@ 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
|
|
450
459
|
*/
|
|
451
460
|
clearCacheToken() {
|
|
452
461
|
this.cachedRefreshToken = undefined;
|
|
453
|
-
this.storage.setPersistedData(CoreApp.headerTokenField, undefined);
|
|
462
|
+
this.storage.setPersistedData(this.addIdentifier(CoreApp.headerTokenField), undefined);
|
|
454
463
|
}
|
|
455
464
|
/**
|
|
456
465
|
* Decrypt message
|
|
@@ -705,7 +714,7 @@ class CoreApp {
|
|
|
705
714
|
// Temp refresh token
|
|
706
715
|
if (this.cachedRefreshToken)
|
|
707
716
|
return this.cachedRefreshToken;
|
|
708
|
-
return this.storage.getData(CoreApp.headerTokenField);
|
|
717
|
+
return this.storage.getData(this.addIdentifier(CoreApp.headerTokenField));
|
|
709
718
|
}
|
|
710
719
|
/**
|
|
711
720
|
* Get all regions
|
|
@@ -951,7 +960,7 @@ class CoreApp {
|
|
|
951
960
|
userLogin(user, refreshToken, keep) {
|
|
952
961
|
this.userData = user;
|
|
953
962
|
// Cache the encrypted serverside device id
|
|
954
|
-
this.storage.setData(CoreApp.serversideDeviceIdField, user.deviceId);
|
|
963
|
+
this.storage.setData(this.addIdentifier(CoreApp.serversideDeviceIdField), user.deviceId);
|
|
955
964
|
if (keep) {
|
|
956
965
|
this.authorize(user.token, refreshToken);
|
|
957
966
|
}
|
package/lib/cjs/i18n/zh-CN.json
CHANGED
package/lib/cjs/i18n/zh-HK.json
CHANGED
package/lib/mjs/app/CoreApp.d.ts
CHANGED
|
@@ -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
|
package/lib/mjs/app/CoreApp.js
CHANGED
|
@@ -43,7 +43,7 @@ export class CoreApp {
|
|
|
43
43
|
this.storage = storage;
|
|
44
44
|
this.name = name;
|
|
45
45
|
// Device id
|
|
46
|
-
this._deviceId = storage.getData(CoreApp.deviceIdField, '');
|
|
46
|
+
this._deviceId = storage.getData(this.addIdentifier(CoreApp.deviceIdField), '');
|
|
47
47
|
// Restore
|
|
48
48
|
this.restore();
|
|
49
49
|
this.setApi(api);
|
|
@@ -115,10 +115,10 @@ export class CoreApp {
|
|
|
115
115
|
*/
|
|
116
116
|
get persistedFields() {
|
|
117
117
|
return [
|
|
118
|
-
CoreApp.deviceIdField,
|
|
119
|
-
CoreApp.devicePassphraseField,
|
|
120
|
-
CoreApp.serversideDeviceIdField,
|
|
121
|
-
CoreApp.headerTokenField
|
|
118
|
+
this.addIdentifier(CoreApp.deviceIdField),
|
|
119
|
+
this.addIdentifier(CoreApp.devicePassphraseField),
|
|
120
|
+
this.addIdentifier(CoreApp.serversideDeviceIdField),
|
|
121
|
+
this.addIdentifier(CoreApp.headerTokenField)
|
|
122
122
|
];
|
|
123
123
|
}
|
|
124
124
|
getDeviceId() {
|
|
@@ -126,9 +126,9 @@ export class CoreApp {
|
|
|
126
126
|
}
|
|
127
127
|
resetKeys() {
|
|
128
128
|
this.storage.clear([
|
|
129
|
-
CoreApp.devicePassphraseField,
|
|
130
|
-
CoreApp.headerTokenField,
|
|
131
|
-
CoreApp.serversideDeviceIdField
|
|
129
|
+
this.addIdentifier(CoreApp.devicePassphraseField),
|
|
130
|
+
this.addIdentifier(CoreApp.headerTokenField),
|
|
131
|
+
this.addIdentifier(CoreApp.serversideDeviceIdField)
|
|
132
132
|
], false);
|
|
133
133
|
this.passphrase = '';
|
|
134
134
|
}
|
|
@@ -142,7 +142,7 @@ export class CoreApp {
|
|
|
142
142
|
// First vist, restore and keep the source
|
|
143
143
|
this.storage.copyFrom(this.persistedFields, false);
|
|
144
144
|
// Reset device id
|
|
145
|
-
this._deviceId = this.storage.getData(CoreApp.deviceIdField, '');
|
|
145
|
+
this._deviceId = this.storage.getData(this.addIdentifier(CoreApp.deviceIdField), '');
|
|
146
146
|
// Totally new, no data restored
|
|
147
147
|
if (this._deviceId === '')
|
|
148
148
|
return false;
|
|
@@ -155,7 +155,8 @@ export class CoreApp {
|
|
|
155
155
|
this.resetKeys();
|
|
156
156
|
return false;
|
|
157
157
|
}
|
|
158
|
-
|
|
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
|
|
@@ -244,7 +253,7 @@ export class CoreApp {
|
|
|
244
253
|
return;
|
|
245
254
|
}
|
|
246
255
|
// Serverside encrypted device id
|
|
247
|
-
const identifier = this.storage.getData(CoreApp.serversideDeviceIdField);
|
|
256
|
+
const identifier = this.storage.getData(this.addIdentifier(CoreApp.serversideDeviceIdField));
|
|
248
257
|
// Timestamp
|
|
249
258
|
const timestamp = new Date().getTime();
|
|
250
259
|
// Request data
|
|
@@ -280,7 +289,7 @@ export class CoreApp {
|
|
|
280
289
|
if (callback)
|
|
281
290
|
callback(false);
|
|
282
291
|
// Clear device id
|
|
283
|
-
this.storage.setData(CoreApp.deviceIdField, undefined);
|
|
292
|
+
this.storage.setData(this.addIdentifier(CoreApp.deviceIdField), undefined);
|
|
284
293
|
return;
|
|
285
294
|
}
|
|
286
295
|
this.initCallUpdate(result.data, data.timestamp);
|
|
@@ -303,14 +312,14 @@ export class CoreApp {
|
|
|
303
312
|
return;
|
|
304
313
|
// Update device id and cache it
|
|
305
314
|
this._deviceId = data.deviceId;
|
|
306
|
-
this.storage.setData(CoreApp.deviceIdField, this._deviceId);
|
|
315
|
+
this.storage.setData(this.addIdentifier(CoreApp.deviceIdField), this._deviceId);
|
|
307
316
|
// Devices
|
|
308
317
|
const devices = this.storage.getPersistedData(CoreApp.devicesField, []);
|
|
309
318
|
devices.push(this.getDeviceId());
|
|
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());
|
|
@@ -342,7 +351,7 @@ export class CoreApp {
|
|
|
342
351
|
* @returns Fields
|
|
343
352
|
*/
|
|
344
353
|
initCallEncryptedUpdateFields() {
|
|
345
|
-
return [CoreApp.headerTokenField];
|
|
354
|
+
return [this.addIdentifier(CoreApp.headerTokenField)];
|
|
346
355
|
}
|
|
347
356
|
/**
|
|
348
357
|
* Alert action result
|
|
@@ -367,7 +376,7 @@ export class CoreApp {
|
|
|
367
376
|
if (refreshToken !== '') {
|
|
368
377
|
if (refreshToken != null)
|
|
369
378
|
refreshToken = this.encrypt(refreshToken);
|
|
370
|
-
this.storage.setData(CoreApp.headerTokenField, refreshToken);
|
|
379
|
+
this.storage.setData(this.addIdentifier(CoreApp.headerTokenField), refreshToken);
|
|
371
380
|
}
|
|
372
381
|
// Reset tryLogin state
|
|
373
382
|
this._isTryingLogin = false;
|
|
@@ -440,14 +449,14 @@ 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
|
|
447
456
|
*/
|
|
448
457
|
clearCacheToken() {
|
|
449
458
|
this.cachedRefreshToken = undefined;
|
|
450
|
-
this.storage.setPersistedData(CoreApp.headerTokenField, undefined);
|
|
459
|
+
this.storage.setPersistedData(this.addIdentifier(CoreApp.headerTokenField), undefined);
|
|
451
460
|
}
|
|
452
461
|
/**
|
|
453
462
|
* Decrypt message
|
|
@@ -702,7 +711,7 @@ export class CoreApp {
|
|
|
702
711
|
// Temp refresh token
|
|
703
712
|
if (this.cachedRefreshToken)
|
|
704
713
|
return this.cachedRefreshToken;
|
|
705
|
-
return this.storage.getData(CoreApp.headerTokenField);
|
|
714
|
+
return this.storage.getData(this.addIdentifier(CoreApp.headerTokenField));
|
|
706
715
|
}
|
|
707
716
|
/**
|
|
708
717
|
* Get all regions
|
|
@@ -948,7 +957,7 @@ export class CoreApp {
|
|
|
948
957
|
userLogin(user, refreshToken, keep) {
|
|
949
958
|
this.userData = user;
|
|
950
959
|
// Cache the encrypted serverside device id
|
|
951
|
-
this.storage.setData(CoreApp.serversideDeviceIdField, user.deviceId);
|
|
960
|
+
this.storage.setData(this.addIdentifier(CoreApp.serversideDeviceIdField), user.deviceId);
|
|
952
961
|
if (keep) {
|
|
953
962
|
this.authorize(user.token, refreshToken);
|
|
954
963
|
}
|
package/lib/mjs/i18n/zh-CN.json
CHANGED
package/lib/mjs/i18n/zh-HK.json
CHANGED
package/package.json
CHANGED
package/src/app/CoreApp.ts
CHANGED
|
@@ -632,10 +632,10 @@ export abstract class CoreApp<
|
|
|
632
632
|
*/
|
|
633
633
|
protected get persistedFields() {
|
|
634
634
|
return [
|
|
635
|
-
CoreApp.deviceIdField,
|
|
636
|
-
CoreApp.devicePassphraseField,
|
|
637
|
-
CoreApp.serversideDeviceIdField,
|
|
638
|
-
CoreApp.headerTokenField
|
|
635
|
+
this.addIdentifier(CoreApp.deviceIdField),
|
|
636
|
+
this.addIdentifier(CoreApp.devicePassphraseField),
|
|
637
|
+
this.addIdentifier(CoreApp.serversideDeviceIdField),
|
|
638
|
+
this.addIdentifier(CoreApp.headerTokenField)
|
|
639
639
|
];
|
|
640
640
|
}
|
|
641
641
|
|
|
@@ -661,7 +661,10 @@ export abstract class CoreApp<
|
|
|
661
661
|
this.name = name;
|
|
662
662
|
|
|
663
663
|
// Device id
|
|
664
|
-
this._deviceId = storage.getData(
|
|
664
|
+
this._deviceId = storage.getData(
|
|
665
|
+
this.addIdentifier(CoreApp.deviceIdField),
|
|
666
|
+
''
|
|
667
|
+
);
|
|
665
668
|
|
|
666
669
|
// Restore
|
|
667
670
|
this.restore();
|
|
@@ -684,9 +687,9 @@ export abstract class CoreApp<
|
|
|
684
687
|
private resetKeys() {
|
|
685
688
|
this.storage.clear(
|
|
686
689
|
[
|
|
687
|
-
CoreApp.devicePassphraseField,
|
|
688
|
-
CoreApp.headerTokenField,
|
|
689
|
-
CoreApp.serversideDeviceIdField
|
|
690
|
+
this.addIdentifier(CoreApp.devicePassphraseField),
|
|
691
|
+
this.addIdentifier(CoreApp.headerTokenField),
|
|
692
|
+
this.addIdentifier(CoreApp.serversideDeviceIdField)
|
|
690
693
|
],
|
|
691
694
|
false
|
|
692
695
|
);
|
|
@@ -708,7 +711,10 @@ export abstract class CoreApp<
|
|
|
708
711
|
this.storage.copyFrom(this.persistedFields, false);
|
|
709
712
|
|
|
710
713
|
// Reset device id
|
|
711
|
-
this._deviceId = this.storage.getData(
|
|
714
|
+
this._deviceId = this.storage.getData(
|
|
715
|
+
this.addIdentifier(CoreApp.deviceIdField),
|
|
716
|
+
''
|
|
717
|
+
);
|
|
712
718
|
|
|
713
719
|
// Totally new, no data restored
|
|
714
720
|
if (this._deviceId === '') return false;
|
|
@@ -723,8 +729,9 @@ export abstract class CoreApp<
|
|
|
723
729
|
return false;
|
|
724
730
|
}
|
|
725
731
|
|
|
732
|
+
// this.name to identifier different app's secret
|
|
726
733
|
const passphraseEncrypted = this.storage.getData<string>(
|
|
727
|
-
CoreApp.devicePassphraseField
|
|
734
|
+
this.addIdentifier(CoreApp.devicePassphraseField)
|
|
728
735
|
);
|
|
729
736
|
if (passphraseEncrypted) {
|
|
730
737
|
const passphraseDecrypted = this.decrypt(
|
|
@@ -769,6 +776,15 @@ export abstract class CoreApp<
|
|
|
769
776
|
this.storage.copyTo(this.persistedFields);
|
|
770
777
|
}
|
|
771
778
|
|
|
779
|
+
/**
|
|
780
|
+
* Add app name as identifier
|
|
781
|
+
* @param field Field
|
|
782
|
+
* @returns Result
|
|
783
|
+
*/
|
|
784
|
+
protected addIdentifier(field: string) {
|
|
785
|
+
return field + '-' + this.name;
|
|
786
|
+
}
|
|
787
|
+
|
|
772
788
|
/**
|
|
773
789
|
* Setup Api
|
|
774
790
|
* @param api Api
|
|
@@ -829,7 +845,7 @@ export abstract class CoreApp<
|
|
|
829
845
|
|
|
830
846
|
// Serverside encrypted device id
|
|
831
847
|
const identifier = this.storage.getData<string>(
|
|
832
|
-
CoreApp.serversideDeviceIdField
|
|
848
|
+
this.addIdentifier(CoreApp.serversideDeviceIdField)
|
|
833
849
|
);
|
|
834
850
|
|
|
835
851
|
// Timestamp
|
|
@@ -874,7 +890,10 @@ export abstract class CoreApp<
|
|
|
874
890
|
if (callback) callback(false);
|
|
875
891
|
|
|
876
892
|
// Clear device id
|
|
877
|
-
this.storage.setData(
|
|
893
|
+
this.storage.setData(
|
|
894
|
+
this.addIdentifier(CoreApp.deviceIdField),
|
|
895
|
+
undefined
|
|
896
|
+
);
|
|
878
897
|
|
|
879
898
|
return;
|
|
880
899
|
}
|
|
@@ -900,7 +919,10 @@ export abstract class CoreApp<
|
|
|
900
919
|
|
|
901
920
|
// Update device id and cache it
|
|
902
921
|
this._deviceId = data.deviceId;
|
|
903
|
-
this.storage.setData(
|
|
922
|
+
this.storage.setData(
|
|
923
|
+
this.addIdentifier(CoreApp.deviceIdField),
|
|
924
|
+
this._deviceId
|
|
925
|
+
);
|
|
904
926
|
|
|
905
927
|
// Devices
|
|
906
928
|
const devices = this.storage.getPersistedData<string[]>(
|
|
@@ -913,7 +935,7 @@ export abstract class CoreApp<
|
|
|
913
935
|
// Current passphrase
|
|
914
936
|
this.passphrase = passphrase;
|
|
915
937
|
this.storage.setData(
|
|
916
|
-
CoreApp.devicePassphraseField,
|
|
938
|
+
this.addIdentifier(CoreApp.devicePassphraseField),
|
|
917
939
|
this.encrypt(passphrase, this.name)
|
|
918
940
|
);
|
|
919
941
|
|
|
@@ -959,7 +981,7 @@ export abstract class CoreApp<
|
|
|
959
981
|
* @returns Fields
|
|
960
982
|
*/
|
|
961
983
|
protected initCallEncryptedUpdateFields(): string[] {
|
|
962
|
-
return [CoreApp.headerTokenField];
|
|
984
|
+
return [this.addIdentifier(CoreApp.headerTokenField)];
|
|
963
985
|
}
|
|
964
986
|
|
|
965
987
|
/**
|
|
@@ -987,7 +1009,10 @@ export abstract class CoreApp<
|
|
|
987
1009
|
// Cover the current value
|
|
988
1010
|
if (refreshToken !== '') {
|
|
989
1011
|
if (refreshToken != null) refreshToken = this.encrypt(refreshToken);
|
|
990
|
-
this.storage.setData(
|
|
1012
|
+
this.storage.setData(
|
|
1013
|
+
this.addIdentifier(CoreApp.headerTokenField),
|
|
1014
|
+
refreshToken
|
|
1015
|
+
);
|
|
991
1016
|
}
|
|
992
1017
|
|
|
993
1018
|
// Reset tryLogin state
|
|
@@ -1075,7 +1100,10 @@ export abstract class CoreApp<
|
|
|
1075
1100
|
*/
|
|
1076
1101
|
clearCacheData() {
|
|
1077
1102
|
this.clearCacheToken();
|
|
1078
|
-
this.storage.setData(
|
|
1103
|
+
this.storage.setData(
|
|
1104
|
+
this.addIdentifier(CoreApp.devicePassphraseField),
|
|
1105
|
+
undefined
|
|
1106
|
+
);
|
|
1079
1107
|
}
|
|
1080
1108
|
|
|
1081
1109
|
/**
|
|
@@ -1083,7 +1111,10 @@ export abstract class CoreApp<
|
|
|
1083
1111
|
*/
|
|
1084
1112
|
clearCacheToken() {
|
|
1085
1113
|
this.cachedRefreshToken = undefined;
|
|
1086
|
-
this.storage.setPersistedData(
|
|
1114
|
+
this.storage.setPersistedData(
|
|
1115
|
+
this.addIdentifier(CoreApp.headerTokenField),
|
|
1116
|
+
undefined
|
|
1117
|
+
);
|
|
1087
1118
|
}
|
|
1088
1119
|
|
|
1089
1120
|
/**
|
|
@@ -1395,7 +1426,9 @@ export abstract class CoreApp<
|
|
|
1395
1426
|
getCacheToken(): string | undefined {
|
|
1396
1427
|
// Temp refresh token
|
|
1397
1428
|
if (this.cachedRefreshToken) return this.cachedRefreshToken;
|
|
1398
|
-
return this.storage.getData<string>(
|
|
1429
|
+
return this.storage.getData<string>(
|
|
1430
|
+
this.addIdentifier(CoreApp.headerTokenField)
|
|
1431
|
+
);
|
|
1399
1432
|
}
|
|
1400
1433
|
|
|
1401
1434
|
/**
|
|
@@ -1681,7 +1714,10 @@ export abstract class CoreApp<
|
|
|
1681
1714
|
this.userData = user;
|
|
1682
1715
|
|
|
1683
1716
|
// Cache the encrypted serverside device id
|
|
1684
|
-
this.storage.setData(
|
|
1717
|
+
this.storage.setData(
|
|
1718
|
+
this.addIdentifier(CoreApp.serversideDeviceIdField),
|
|
1719
|
+
user.deviceId
|
|
1720
|
+
);
|
|
1685
1721
|
|
|
1686
1722
|
if (keep) {
|
|
1687
1723
|
this.authorize(user.token, refreshToken);
|
package/src/i18n/zh-CN.json
CHANGED