@etsoo/appscript 1.1.71 → 1.1.75
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 +10 -4
- package/lib/cjs/app/CoreApp.js +21 -5
- package/lib/mjs/app/CoreApp.d.ts +10 -4
- package/lib/mjs/app/CoreApp.js +21 -5
- package/package.json +1 -1
- package/src/app/CoreApp.ts +29 -10
package/lib/cjs/app/CoreApp.d.ts
CHANGED
|
@@ -68,6 +68,10 @@ export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallP
|
|
|
68
68
|
* Currency, like USD for US dollar
|
|
69
69
|
*/
|
|
70
70
|
readonly currency: string;
|
|
71
|
+
/**
|
|
72
|
+
* Device id
|
|
73
|
+
*/
|
|
74
|
+
readonly deviceId: string;
|
|
71
75
|
/**
|
|
72
76
|
* Country or region, like CN
|
|
73
77
|
*/
|
|
@@ -349,6 +353,12 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
|
|
|
349
353
|
* Country or region, like CN
|
|
350
354
|
*/
|
|
351
355
|
get region(): string;
|
|
356
|
+
private _deviceId;
|
|
357
|
+
/**
|
|
358
|
+
* Country or region, like CN
|
|
359
|
+
*/
|
|
360
|
+
get deviceId(): string;
|
|
361
|
+
protected set deviceId(value: string);
|
|
352
362
|
/**
|
|
353
363
|
* Label delegate
|
|
354
364
|
*/
|
|
@@ -389,10 +399,6 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
|
|
|
389
399
|
* Device id field name
|
|
390
400
|
*/
|
|
391
401
|
protected deviceIdField: string;
|
|
392
|
-
/**
|
|
393
|
-
* Device id
|
|
394
|
-
*/
|
|
395
|
-
protected deviceId: string;
|
|
396
402
|
/**
|
|
397
403
|
* Passphrase for encryption
|
|
398
404
|
*/
|
package/lib/cjs/app/CoreApp.js
CHANGED
|
@@ -20,6 +20,7 @@ class CoreApp {
|
|
|
20
20
|
* @param name Application name
|
|
21
21
|
*/
|
|
22
22
|
constructor(settings, api, notifier, name) {
|
|
23
|
+
this._deviceId = '***';
|
|
23
24
|
/**
|
|
24
25
|
* Response token header field name
|
|
25
26
|
*/
|
|
@@ -72,6 +73,15 @@ class CoreApp {
|
|
|
72
73
|
get region() {
|
|
73
74
|
return this._region;
|
|
74
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Country or region, like CN
|
|
78
|
+
*/
|
|
79
|
+
get deviceId() {
|
|
80
|
+
return this._deviceId;
|
|
81
|
+
}
|
|
82
|
+
set deviceId(value) {
|
|
83
|
+
this._deviceId = value;
|
|
84
|
+
}
|
|
75
85
|
/**
|
|
76
86
|
* Label delegate
|
|
77
87
|
*/
|
|
@@ -154,6 +164,8 @@ class CoreApp {
|
|
|
154
164
|
}
|
|
155
165
|
if (callback)
|
|
156
166
|
callback(false);
|
|
167
|
+
// Clear device id
|
|
168
|
+
shared_1.StorageUtils.setLocalData(this.deviceIdField, null);
|
|
157
169
|
return;
|
|
158
170
|
}
|
|
159
171
|
this.initCallUpdate(result.data, data.timestamp);
|
|
@@ -309,11 +321,14 @@ class CoreApp {
|
|
|
309
321
|
hasher: crypto_js_1.algo.SHA256,
|
|
310
322
|
iterations: 1000 * iterations
|
|
311
323
|
});
|
|
312
|
-
|
|
324
|
+
const bytes = crypto_js_1.AES.decrypt(encrypted, key, {
|
|
313
325
|
iv,
|
|
314
326
|
padding: crypto_js_1.pad.Pkcs7,
|
|
315
327
|
mode: crypto_js_1.mode.CBC
|
|
316
|
-
})
|
|
328
|
+
});
|
|
329
|
+
if (bytes.words.length == 0)
|
|
330
|
+
return undefined;
|
|
331
|
+
return bytes.toString(crypto_js_1.enc.Utf8);
|
|
317
332
|
}
|
|
318
333
|
/**
|
|
319
334
|
* Enhanced decrypt message
|
|
@@ -324,8 +339,9 @@ class CoreApp {
|
|
|
324
339
|
*/
|
|
325
340
|
decryptEnhanced(messageEncrypted, passphrase, durationSeconds) {
|
|
326
341
|
// Timestamp splitter
|
|
327
|
-
const pos = messageEncrypted.indexOf('
|
|
328
|
-
|
|
342
|
+
const pos = messageEncrypted.indexOf('!');
|
|
343
|
+
// Miliseconds chars are longer than 8
|
|
344
|
+
if (pos < 8 || messageEncrypted.length <= 66)
|
|
329
345
|
return undefined;
|
|
330
346
|
const timestamp = messageEncrypted.substring(0, pos);
|
|
331
347
|
if (durationSeconds != null && durationSeconds > 0) {
|
|
@@ -415,7 +431,7 @@ class CoreApp {
|
|
|
415
431
|
// Timestamp
|
|
416
432
|
const timestamp = shared_1.Utils.numberToChars(new Date().getTime());
|
|
417
433
|
passphrase = this.encryptionEnhance(passphrase !== null && passphrase !== void 0 ? passphrase : this.passphrase, timestamp);
|
|
418
|
-
return timestamp + '
|
|
434
|
+
return timestamp + '!' + this.encrypt(message, passphrase, iterations);
|
|
419
435
|
}
|
|
420
436
|
/**
|
|
421
437
|
* Enchance secret passphrase
|
package/lib/mjs/app/CoreApp.d.ts
CHANGED
|
@@ -68,6 +68,10 @@ export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallP
|
|
|
68
68
|
* Currency, like USD for US dollar
|
|
69
69
|
*/
|
|
70
70
|
readonly currency: string;
|
|
71
|
+
/**
|
|
72
|
+
* Device id
|
|
73
|
+
*/
|
|
74
|
+
readonly deviceId: string;
|
|
71
75
|
/**
|
|
72
76
|
* Country or region, like CN
|
|
73
77
|
*/
|
|
@@ -349,6 +353,12 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
|
|
|
349
353
|
* Country or region, like CN
|
|
350
354
|
*/
|
|
351
355
|
get region(): string;
|
|
356
|
+
private _deviceId;
|
|
357
|
+
/**
|
|
358
|
+
* Country or region, like CN
|
|
359
|
+
*/
|
|
360
|
+
get deviceId(): string;
|
|
361
|
+
protected set deviceId(value: string);
|
|
352
362
|
/**
|
|
353
363
|
* Label delegate
|
|
354
364
|
*/
|
|
@@ -389,10 +399,6 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
|
|
|
389
399
|
* Device id field name
|
|
390
400
|
*/
|
|
391
401
|
protected deviceIdField: string;
|
|
392
|
-
/**
|
|
393
|
-
* Device id
|
|
394
|
-
*/
|
|
395
|
-
protected deviceId: string;
|
|
396
402
|
/**
|
|
397
403
|
* Passphrase for encryption
|
|
398
404
|
*/
|
package/lib/mjs/app/CoreApp.js
CHANGED
|
@@ -17,6 +17,7 @@ export class CoreApp {
|
|
|
17
17
|
* @param name Application name
|
|
18
18
|
*/
|
|
19
19
|
constructor(settings, api, notifier, name) {
|
|
20
|
+
this._deviceId = '***';
|
|
20
21
|
/**
|
|
21
22
|
* Response token header field name
|
|
22
23
|
*/
|
|
@@ -69,6 +70,15 @@ export class CoreApp {
|
|
|
69
70
|
get region() {
|
|
70
71
|
return this._region;
|
|
71
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Country or region, like CN
|
|
75
|
+
*/
|
|
76
|
+
get deviceId() {
|
|
77
|
+
return this._deviceId;
|
|
78
|
+
}
|
|
79
|
+
set deviceId(value) {
|
|
80
|
+
this._deviceId = value;
|
|
81
|
+
}
|
|
72
82
|
/**
|
|
73
83
|
* Label delegate
|
|
74
84
|
*/
|
|
@@ -151,6 +161,8 @@ export class CoreApp {
|
|
|
151
161
|
}
|
|
152
162
|
if (callback)
|
|
153
163
|
callback(false);
|
|
164
|
+
// Clear device id
|
|
165
|
+
StorageUtils.setLocalData(this.deviceIdField, null);
|
|
154
166
|
return;
|
|
155
167
|
}
|
|
156
168
|
this.initCallUpdate(result.data, data.timestamp);
|
|
@@ -306,11 +318,14 @@ export class CoreApp {
|
|
|
306
318
|
hasher: algo.SHA256,
|
|
307
319
|
iterations: 1000 * iterations
|
|
308
320
|
});
|
|
309
|
-
|
|
321
|
+
const bytes = AES.decrypt(encrypted, key, {
|
|
310
322
|
iv,
|
|
311
323
|
padding: pad.Pkcs7,
|
|
312
324
|
mode: mode.CBC
|
|
313
|
-
})
|
|
325
|
+
});
|
|
326
|
+
if (bytes.words.length == 0)
|
|
327
|
+
return undefined;
|
|
328
|
+
return bytes.toString(enc.Utf8);
|
|
314
329
|
}
|
|
315
330
|
/**
|
|
316
331
|
* Enhanced decrypt message
|
|
@@ -321,8 +336,9 @@ export class CoreApp {
|
|
|
321
336
|
*/
|
|
322
337
|
decryptEnhanced(messageEncrypted, passphrase, durationSeconds) {
|
|
323
338
|
// Timestamp splitter
|
|
324
|
-
const pos = messageEncrypted.indexOf('
|
|
325
|
-
|
|
339
|
+
const pos = messageEncrypted.indexOf('!');
|
|
340
|
+
// Miliseconds chars are longer than 8
|
|
341
|
+
if (pos < 8 || messageEncrypted.length <= 66)
|
|
326
342
|
return undefined;
|
|
327
343
|
const timestamp = messageEncrypted.substring(0, pos);
|
|
328
344
|
if (durationSeconds != null && durationSeconds > 0) {
|
|
@@ -412,7 +428,7 @@ export class CoreApp {
|
|
|
412
428
|
// Timestamp
|
|
413
429
|
const timestamp = Utils.numberToChars(new Date().getTime());
|
|
414
430
|
passphrase = this.encryptionEnhance(passphrase !== null && passphrase !== void 0 ? passphrase : this.passphrase, timestamp);
|
|
415
|
-
return timestamp + '
|
|
431
|
+
return timestamp + '!' + this.encrypt(message, passphrase, iterations);
|
|
416
432
|
}
|
|
417
433
|
/**
|
|
418
434
|
* Enchance secret passphrase
|
package/package.json
CHANGED
package/src/app/CoreApp.ts
CHANGED
|
@@ -117,6 +117,11 @@ export interface ICoreApp<
|
|
|
117
117
|
*/
|
|
118
118
|
readonly currency: string;
|
|
119
119
|
|
|
120
|
+
/**
|
|
121
|
+
* Device id
|
|
122
|
+
*/
|
|
123
|
+
readonly deviceId: string;
|
|
124
|
+
|
|
120
125
|
/**
|
|
121
126
|
* Country or region, like CN
|
|
122
127
|
*/
|
|
@@ -478,6 +483,17 @@ export abstract class CoreApp<
|
|
|
478
483
|
return this._region;
|
|
479
484
|
}
|
|
480
485
|
|
|
486
|
+
private _deviceId: string = '***';
|
|
487
|
+
/**
|
|
488
|
+
* Country or region, like CN
|
|
489
|
+
*/
|
|
490
|
+
get deviceId() {
|
|
491
|
+
return this._deviceId;
|
|
492
|
+
}
|
|
493
|
+
protected set deviceId(value: string) {
|
|
494
|
+
this._deviceId = value;
|
|
495
|
+
}
|
|
496
|
+
|
|
481
497
|
/**
|
|
482
498
|
* Label delegate
|
|
483
499
|
*/
|
|
@@ -537,11 +553,6 @@ export abstract class CoreApp<
|
|
|
537
553
|
*/
|
|
538
554
|
protected deviceIdField: string = 'SmartERPDeviceId';
|
|
539
555
|
|
|
540
|
-
/**
|
|
541
|
-
* Device id
|
|
542
|
-
*/
|
|
543
|
-
protected deviceId: string;
|
|
544
|
-
|
|
545
556
|
/**
|
|
546
557
|
* Passphrase for encryption
|
|
547
558
|
*/
|
|
@@ -658,6 +669,9 @@ export abstract class CoreApp<
|
|
|
658
669
|
|
|
659
670
|
if (callback) callback(false);
|
|
660
671
|
|
|
672
|
+
// Clear device id
|
|
673
|
+
StorageUtils.setLocalData(this.deviceIdField, null);
|
|
674
|
+
|
|
661
675
|
return;
|
|
662
676
|
}
|
|
663
677
|
|
|
@@ -856,11 +870,14 @@ export abstract class CoreApp<
|
|
|
856
870
|
iterations: 1000 * iterations
|
|
857
871
|
});
|
|
858
872
|
|
|
859
|
-
|
|
873
|
+
const bytes = AES.decrypt(encrypted, key, {
|
|
860
874
|
iv,
|
|
861
875
|
padding: pad.Pkcs7,
|
|
862
876
|
mode: mode.CBC
|
|
863
|
-
})
|
|
877
|
+
});
|
|
878
|
+
if (bytes.words.length == 0) return undefined;
|
|
879
|
+
|
|
880
|
+
return bytes.toString(enc.Utf8);
|
|
864
881
|
}
|
|
865
882
|
|
|
866
883
|
/**
|
|
@@ -876,8 +893,10 @@ export abstract class CoreApp<
|
|
|
876
893
|
durationSeconds?: number
|
|
877
894
|
) {
|
|
878
895
|
// Timestamp splitter
|
|
879
|
-
const pos = messageEncrypted.indexOf('
|
|
880
|
-
|
|
896
|
+
const pos = messageEncrypted.indexOf('!');
|
|
897
|
+
|
|
898
|
+
// Miliseconds chars are longer than 8
|
|
899
|
+
if (pos < 8 || messageEncrypted.length <= 66) return undefined;
|
|
881
900
|
|
|
882
901
|
const timestamp = messageEncrypted.substring(0, pos);
|
|
883
902
|
|
|
@@ -991,7 +1010,7 @@ export abstract class CoreApp<
|
|
|
991
1010
|
timestamp
|
|
992
1011
|
);
|
|
993
1012
|
|
|
994
|
-
return timestamp + '
|
|
1013
|
+
return timestamp + '!' + this.encrypt(message, passphrase, iterations);
|
|
995
1014
|
}
|
|
996
1015
|
|
|
997
1016
|
/**
|