@etsoo/appscript 1.4.6 → 1.4.7
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/__tests__/app/CoreApp.ts +4 -4
- package/lib/cjs/app/CoreApp.js +8 -8
- package/lib/cjs/erp/AuthApi.js +3 -3
- package/lib/cjs/i18n/zhHans.js +1 -1
- package/lib/cjs/i18n/zhHant.js +1 -1
- package/lib/mjs/app/CoreApp.js +8 -8
- package/lib/mjs/erp/AuthApi.js +3 -3
- package/lib/mjs/i18n/zhHans.js +1 -1
- package/lib/mjs/i18n/zhHant.js +1 -1
- package/package.json +1 -1
- package/src/app/CoreApp.ts +8 -11
- package/src/erp/AuthApi.ts +3 -3
- package/src/i18n/zhHans.ts +1 -1
- package/src/i18n/zhHant.ts +1 -1
package/__tests__/app/CoreApp.ts
CHANGED
|
@@ -163,8 +163,8 @@ test('Tests for encrypt / decrypt', async () => {
|
|
|
163
163
|
const passphrase = 'My password';
|
|
164
164
|
|
|
165
165
|
// Act
|
|
166
|
-
const encrypted =
|
|
167
|
-
const plain =
|
|
166
|
+
const encrypted = app.encrypt(input, passphrase);
|
|
167
|
+
const plain = app.decrypt(encrypted, passphrase);
|
|
168
168
|
expect(plain).toEqual(input);
|
|
169
169
|
});
|
|
170
170
|
|
|
@@ -174,8 +174,8 @@ test('Tests for encryptEnhanced / decryptEnhanced', async () => {
|
|
|
174
174
|
const passphrase = 'My password';
|
|
175
175
|
|
|
176
176
|
// Act
|
|
177
|
-
const encrypted =
|
|
178
|
-
const plain =
|
|
177
|
+
const encrypted = app.encryptEnhanced(input, passphrase);
|
|
178
|
+
const plain = app.decryptEnhanced(encrypted, passphrase);
|
|
179
179
|
expect(plain).toEqual(input);
|
|
180
180
|
});
|
|
181
181
|
|
package/lib/cjs/app/CoreApp.js
CHANGED
|
@@ -223,7 +223,7 @@ class CoreApp {
|
|
|
223
223
|
const passphraseEncrypted = this.storage.getData(this.fields.devicePassphrase);
|
|
224
224
|
if (passphraseEncrypted) {
|
|
225
225
|
// this.name to identifier different app's secret
|
|
226
|
-
const passphraseDecrypted =
|
|
226
|
+
const passphraseDecrypted = this.decrypt(passphraseEncrypted, this.name);
|
|
227
227
|
if (passphraseDecrypted != null) {
|
|
228
228
|
// Add the device to the list
|
|
229
229
|
devices.push(d);
|
|
@@ -401,7 +401,7 @@ class CoreApp {
|
|
|
401
401
|
return false;
|
|
402
402
|
// Decrypt
|
|
403
403
|
// Should be done within 120 seconds after returning from the backend
|
|
404
|
-
const passphrase =
|
|
404
|
+
const passphrase = this.decrypt(data.passphrase, timestamp.toString());
|
|
405
405
|
if (passphrase == null)
|
|
406
406
|
return false;
|
|
407
407
|
// Update device id and cache it
|
|
@@ -413,10 +413,10 @@ class CoreApp {
|
|
|
413
413
|
this.storage.setPersistedData(this.fields.devices, devices);
|
|
414
414
|
// Current passphrase
|
|
415
415
|
this.passphrase = passphrase;
|
|
416
|
-
this.storage.setData(this.fields.devicePassphrase,
|
|
416
|
+
this.storage.setData(this.fields.devicePassphrase, this.encrypt(passphrase, this.name));
|
|
417
417
|
// Previous passphrase
|
|
418
418
|
if (data.previousPassphrase) {
|
|
419
|
-
const prev =
|
|
419
|
+
const prev = this.decrypt(data.previousPassphrase, timestamp.toString());
|
|
420
420
|
// Update
|
|
421
421
|
const fields = this.initCallEncryptedUpdateFields();
|
|
422
422
|
for (const field of fields) {
|
|
@@ -431,10 +431,10 @@ class CoreApp {
|
|
|
431
431
|
const enhanced = currentValue.indexOf('!') >= 8;
|
|
432
432
|
let newValueSource;
|
|
433
433
|
if (enhanced) {
|
|
434
|
-
newValueSource =
|
|
434
|
+
newValueSource = this.decryptEnhanced(currentValue, prev, 12);
|
|
435
435
|
}
|
|
436
436
|
else {
|
|
437
|
-
newValueSource =
|
|
437
|
+
newValueSource = this.decrypt(currentValue, prev);
|
|
438
438
|
}
|
|
439
439
|
if (newValueSource == null || newValueSource === '') {
|
|
440
440
|
// Reset the field
|
|
@@ -442,8 +442,8 @@ class CoreApp {
|
|
|
442
442
|
continue;
|
|
443
443
|
}
|
|
444
444
|
const newValue = enhanced
|
|
445
|
-
?
|
|
446
|
-
:
|
|
445
|
+
? this.encryptEnhanced(newValueSource)
|
|
446
|
+
: this.encrypt(newValueSource);
|
|
447
447
|
this.storage.setData(field, newValue);
|
|
448
448
|
}
|
|
449
449
|
}
|
package/lib/cjs/erp/AuthApi.js
CHANGED
|
@@ -26,15 +26,15 @@ class AuthApi extends BaseApi_1.BaseApi {
|
|
|
26
26
|
* @param payload Payload
|
|
27
27
|
* @returns Result
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
loginId(id, payload) {
|
|
30
30
|
const { deviceId, region } = this.app;
|
|
31
|
-
id =
|
|
31
|
+
id = this.app.encrypt(id);
|
|
32
32
|
const rq = {
|
|
33
33
|
id,
|
|
34
34
|
deviceId,
|
|
35
35
|
region
|
|
36
36
|
};
|
|
37
|
-
return
|
|
37
|
+
return this.api.get('Auth/LoginId', rq, payload);
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* Reset password
|
package/lib/cjs/i18n/zhHans.js
CHANGED
|
@@ -30,7 +30,7 @@ const shared_1 = require("@etsoo/shared");
|
|
|
30
30
|
* @param localResources Local resources
|
|
31
31
|
* @returns Full culture
|
|
32
32
|
*/
|
|
33
|
-
const zhHans = (resources) => shared_1.DomUtils.
|
|
33
|
+
const zhHans = (resources) => shared_1.DomUtils.zhHans(async () => {
|
|
34
34
|
const [r1, r2] = await Promise.all([
|
|
35
35
|
Promise.resolve().then(() => __importStar(require('./zh-Hans.json'))),
|
|
36
36
|
new Promise((resolve) => {
|
package/lib/cjs/i18n/zhHant.js
CHANGED
|
@@ -30,7 +30,7 @@ const shared_1 = require("@etsoo/shared");
|
|
|
30
30
|
* @param localResources Local resources
|
|
31
31
|
* @returns Full culture
|
|
32
32
|
*/
|
|
33
|
-
const zhHant = (resources) => shared_1.DomUtils.
|
|
33
|
+
const zhHant = (resources) => shared_1.DomUtils.zhHant(async () => {
|
|
34
34
|
const [r1, r2] = await Promise.all([
|
|
35
35
|
Promise.resolve().then(() => __importStar(require('./zh-Hant.json'))),
|
|
36
36
|
new Promise((resolve) => {
|
package/lib/mjs/app/CoreApp.js
CHANGED
|
@@ -197,7 +197,7 @@ export class CoreApp {
|
|
|
197
197
|
const passphraseEncrypted = this.storage.getData(this.fields.devicePassphrase);
|
|
198
198
|
if (passphraseEncrypted) {
|
|
199
199
|
// this.name to identifier different app's secret
|
|
200
|
-
const passphraseDecrypted =
|
|
200
|
+
const passphraseDecrypted = this.decrypt(passphraseEncrypted, this.name);
|
|
201
201
|
if (passphraseDecrypted != null) {
|
|
202
202
|
// Add the device to the list
|
|
203
203
|
devices.push(d);
|
|
@@ -375,7 +375,7 @@ export class CoreApp {
|
|
|
375
375
|
return false;
|
|
376
376
|
// Decrypt
|
|
377
377
|
// Should be done within 120 seconds after returning from the backend
|
|
378
|
-
const passphrase =
|
|
378
|
+
const passphrase = this.decrypt(data.passphrase, timestamp.toString());
|
|
379
379
|
if (passphrase == null)
|
|
380
380
|
return false;
|
|
381
381
|
// Update device id and cache it
|
|
@@ -387,10 +387,10 @@ export class CoreApp {
|
|
|
387
387
|
this.storage.setPersistedData(this.fields.devices, devices);
|
|
388
388
|
// Current passphrase
|
|
389
389
|
this.passphrase = passphrase;
|
|
390
|
-
this.storage.setData(this.fields.devicePassphrase,
|
|
390
|
+
this.storage.setData(this.fields.devicePassphrase, this.encrypt(passphrase, this.name));
|
|
391
391
|
// Previous passphrase
|
|
392
392
|
if (data.previousPassphrase) {
|
|
393
|
-
const prev =
|
|
393
|
+
const prev = this.decrypt(data.previousPassphrase, timestamp.toString());
|
|
394
394
|
// Update
|
|
395
395
|
const fields = this.initCallEncryptedUpdateFields();
|
|
396
396
|
for (const field of fields) {
|
|
@@ -405,10 +405,10 @@ export class CoreApp {
|
|
|
405
405
|
const enhanced = currentValue.indexOf('!') >= 8;
|
|
406
406
|
let newValueSource;
|
|
407
407
|
if (enhanced) {
|
|
408
|
-
newValueSource =
|
|
408
|
+
newValueSource = this.decryptEnhanced(currentValue, prev, 12);
|
|
409
409
|
}
|
|
410
410
|
else {
|
|
411
|
-
newValueSource =
|
|
411
|
+
newValueSource = this.decrypt(currentValue, prev);
|
|
412
412
|
}
|
|
413
413
|
if (newValueSource == null || newValueSource === '') {
|
|
414
414
|
// Reset the field
|
|
@@ -416,8 +416,8 @@ export class CoreApp {
|
|
|
416
416
|
continue;
|
|
417
417
|
}
|
|
418
418
|
const newValue = enhanced
|
|
419
|
-
?
|
|
420
|
-
:
|
|
419
|
+
? this.encryptEnhanced(newValueSource)
|
|
420
|
+
: this.encrypt(newValueSource);
|
|
421
421
|
this.storage.setData(field, newValue);
|
|
422
422
|
}
|
|
423
423
|
}
|
package/lib/mjs/erp/AuthApi.js
CHANGED
|
@@ -23,15 +23,15 @@ export class AuthApi extends BaseApi {
|
|
|
23
23
|
* @param payload Payload
|
|
24
24
|
* @returns Result
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
loginId(id, payload) {
|
|
27
27
|
const { deviceId, region } = this.app;
|
|
28
|
-
id =
|
|
28
|
+
id = this.app.encrypt(id);
|
|
29
29
|
const rq = {
|
|
30
30
|
id,
|
|
31
31
|
deviceId,
|
|
32
32
|
region
|
|
33
33
|
};
|
|
34
|
-
return
|
|
34
|
+
return this.api.get('Auth/LoginId', rq, payload);
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* Reset password
|
package/lib/mjs/i18n/zhHans.js
CHANGED
|
@@ -4,7 +4,7 @@ import { DomUtils } from '@etsoo/shared';
|
|
|
4
4
|
* @param localResources Local resources
|
|
5
5
|
* @returns Full culture
|
|
6
6
|
*/
|
|
7
|
-
export const zhHans = (resources) => DomUtils.
|
|
7
|
+
export const zhHans = (resources) => DomUtils.zhHans(async () => {
|
|
8
8
|
const [r1, r2] = await Promise.all([
|
|
9
9
|
import('./zh-Hans.json'),
|
|
10
10
|
new Promise((resolve) => {
|
package/lib/mjs/i18n/zhHant.js
CHANGED
|
@@ -4,7 +4,7 @@ import { DomUtils } from '@etsoo/shared';
|
|
|
4
4
|
* @param localResources Local resources
|
|
5
5
|
* @returns Full culture
|
|
6
6
|
*/
|
|
7
|
-
export const zhHant = (resources) => DomUtils.
|
|
7
|
+
export const zhHant = (resources) => DomUtils.zhHant(async () => {
|
|
8
8
|
const [r1, r2] = await Promise.all([
|
|
9
9
|
import('./zh-Hant.json'),
|
|
10
10
|
new Promise((resolve) => {
|
package/package.json
CHANGED
package/src/app/CoreApp.ts
CHANGED
|
@@ -362,7 +362,7 @@ export abstract class CoreApp<
|
|
|
362
362
|
);
|
|
363
363
|
if (passphraseEncrypted) {
|
|
364
364
|
// this.name to identifier different app's secret
|
|
365
|
-
const passphraseDecrypted =
|
|
365
|
+
const passphraseDecrypted = this.decrypt(
|
|
366
366
|
passphraseEncrypted,
|
|
367
367
|
this.name
|
|
368
368
|
);
|
|
@@ -578,10 +578,7 @@ export abstract class CoreApp<
|
|
|
578
578
|
|
|
579
579
|
// Decrypt
|
|
580
580
|
// Should be done within 120 seconds after returning from the backend
|
|
581
|
-
const passphrase =
|
|
582
|
-
data.passphrase,
|
|
583
|
-
timestamp.toString()
|
|
584
|
-
);
|
|
581
|
+
const passphrase = this.decrypt(data.passphrase, timestamp.toString());
|
|
585
582
|
if (passphrase == null) return false;
|
|
586
583
|
|
|
587
584
|
// Update device id and cache it
|
|
@@ -600,12 +597,12 @@ export abstract class CoreApp<
|
|
|
600
597
|
this.passphrase = passphrase;
|
|
601
598
|
this.storage.setData(
|
|
602
599
|
this.fields.devicePassphrase,
|
|
603
|
-
|
|
600
|
+
this.encrypt(passphrase, this.name)
|
|
604
601
|
);
|
|
605
602
|
|
|
606
603
|
// Previous passphrase
|
|
607
604
|
if (data.previousPassphrase) {
|
|
608
|
-
const prev =
|
|
605
|
+
const prev = this.decrypt(
|
|
609
606
|
data.previousPassphrase,
|
|
610
607
|
timestamp.toString()
|
|
611
608
|
);
|
|
@@ -626,13 +623,13 @@ export abstract class CoreApp<
|
|
|
626
623
|
let newValueSource: string | undefined;
|
|
627
624
|
|
|
628
625
|
if (enhanced) {
|
|
629
|
-
newValueSource =
|
|
626
|
+
newValueSource = this.decryptEnhanced(
|
|
630
627
|
currentValue,
|
|
631
628
|
prev,
|
|
632
629
|
12
|
|
633
630
|
);
|
|
634
631
|
} else {
|
|
635
|
-
newValueSource =
|
|
632
|
+
newValueSource = this.decrypt(currentValue, prev);
|
|
636
633
|
}
|
|
637
634
|
|
|
638
635
|
if (newValueSource == null || newValueSource === '') {
|
|
@@ -642,8 +639,8 @@ export abstract class CoreApp<
|
|
|
642
639
|
}
|
|
643
640
|
|
|
644
641
|
const newValue = enhanced
|
|
645
|
-
?
|
|
646
|
-
:
|
|
642
|
+
? this.encryptEnhanced(newValueSource)
|
|
643
|
+
: this.encrypt(newValueSource);
|
|
647
644
|
|
|
648
645
|
this.storage.setData(field, newValue);
|
|
649
646
|
}
|
package/src/erp/AuthApi.ts
CHANGED
|
@@ -35,15 +35,15 @@ export class AuthApi extends BaseApi {
|
|
|
35
35
|
* @param payload Payload
|
|
36
36
|
* @returns Result
|
|
37
37
|
*/
|
|
38
|
-
|
|
38
|
+
loginId(id: string, payload?: ResultPayload) {
|
|
39
39
|
const { deviceId, region } = this.app;
|
|
40
|
-
id =
|
|
40
|
+
id = this.app.encrypt(id);
|
|
41
41
|
const rq: LoginIdRQ = {
|
|
42
42
|
id,
|
|
43
43
|
deviceId,
|
|
44
44
|
region
|
|
45
45
|
};
|
|
46
|
-
return
|
|
46
|
+
return this.api.get('Auth/LoginId', rq, payload);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/**
|
package/src/i18n/zhHans.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { DataTypes, DomUtils } from '@etsoo/shared';
|
|
|
6
6
|
* @returns Full culture
|
|
7
7
|
*/
|
|
8
8
|
export const zhHans = (resources: object | (() => Promise<object>)) =>
|
|
9
|
-
DomUtils.
|
|
9
|
+
DomUtils.zhHans(async () => {
|
|
10
10
|
const [r1, r2] = await Promise.all([
|
|
11
11
|
import('./zh-Hans.json'),
|
|
12
12
|
new Promise<object>((resolve) => {
|
package/src/i18n/zhHant.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { DataTypes, DomUtils } from '@etsoo/shared';
|
|
|
6
6
|
* @returns Full culture
|
|
7
7
|
*/
|
|
8
8
|
export const zhHant = (resources: object | (() => Promise<object>)) =>
|
|
9
|
-
DomUtils.
|
|
9
|
+
DomUtils.zhHant(async () => {
|
|
10
10
|
const [r1, r2] = await Promise.all([
|
|
11
11
|
import('./zh-Hant.json'),
|
|
12
12
|
new Promise<object>((resolve) => {
|