@etsoo/appscript 1.4.4 → 1.4.6
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 +7 -7
- package/lib/cjs/app/CoreApp.js +37 -34
- package/lib/cjs/app/IApp.d.ts +7 -8
- package/lib/mjs/app/CoreApp.d.ts +7 -7
- package/lib/mjs/app/CoreApp.js +37 -34
- package/lib/mjs/app/IApp.d.ts +7 -8
- package/package.json +1 -1
- package/src/app/CoreApp.ts +42 -45
- package/src/app/IApp.ts +8 -17
package/lib/cjs/app/CoreApp.d.ts
CHANGED
|
@@ -221,7 +221,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
221
221
|
* @param culture New culture definition
|
|
222
222
|
* @param onReady On ready callback
|
|
223
223
|
*/
|
|
224
|
-
changeCulture(culture: DataTypes.CultureDefinition
|
|
224
|
+
changeCulture(culture: DataTypes.CultureDefinition): Promise<DataTypes.StringRecord>;
|
|
225
225
|
/**
|
|
226
226
|
* Update current region label
|
|
227
227
|
*/
|
|
@@ -246,7 +246,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
246
246
|
* @param passphrase Secret passphrase
|
|
247
247
|
* @returns Pure text
|
|
248
248
|
*/
|
|
249
|
-
decrypt(messageEncrypted: string, passphrase?: string):
|
|
249
|
+
decrypt(messageEncrypted: string, passphrase?: string): string | undefined;
|
|
250
250
|
/**
|
|
251
251
|
* Enhanced decrypt message
|
|
252
252
|
* @param messageEncrypted Encrypted message
|
|
@@ -254,7 +254,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
254
254
|
* @param durationSeconds Duration seconds, <= 12 will be considered as month
|
|
255
255
|
* @returns Pure text
|
|
256
256
|
*/
|
|
257
|
-
decryptEnhanced(messageEncrypted: string, passphrase?: string, durationSeconds?: number):
|
|
257
|
+
decryptEnhanced(messageEncrypted: string, passphrase?: string, durationSeconds?: number): string | undefined;
|
|
258
258
|
/**
|
|
259
259
|
* Detect IP data, call only one time
|
|
260
260
|
* @param callback Callback will be called when the IP is ready
|
|
@@ -268,7 +268,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
268
268
|
* @param iterations Iterations, 1000 times, 1 - 99
|
|
269
269
|
* @returns Result
|
|
270
270
|
*/
|
|
271
|
-
encrypt(message: string, passphrase?: string, iterations?: number):
|
|
271
|
+
encrypt(message: string, passphrase?: string, iterations?: number): string;
|
|
272
272
|
/**
|
|
273
273
|
* Enhanced encrypt message
|
|
274
274
|
* @param message Message
|
|
@@ -276,7 +276,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
276
276
|
* @param iterations Iterations, 1000 times, 1 - 99
|
|
277
277
|
* @returns Result
|
|
278
278
|
*/
|
|
279
|
-
encryptEnhanced(message: string, passphrase?: string, iterations?: number):
|
|
279
|
+
encryptEnhanced(message: string, passphrase?: string, iterations?: number): string;
|
|
280
280
|
/**
|
|
281
281
|
* Enchance secret passphrase
|
|
282
282
|
* @param passphrase Secret passphrase
|
|
@@ -430,14 +430,14 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
430
430
|
* @param message Message
|
|
431
431
|
* @param passphrase Secret passphrase
|
|
432
432
|
*/
|
|
433
|
-
hash(message: string, passphrase?: string):
|
|
433
|
+
hash(message: string, passphrase?: string): string;
|
|
434
434
|
/**
|
|
435
435
|
* Hash message Hex, SHA3 or HmacSHA512, 512 as Base64
|
|
436
436
|
* https://cryptojs.gitbook.io/docs/
|
|
437
437
|
* @param message Message
|
|
438
438
|
* @param passphrase Secret passphrase
|
|
439
439
|
*/
|
|
440
|
-
hashHex(message: string, passphrase?: string):
|
|
440
|
+
hashHex(message: string, passphrase?: string): string;
|
|
441
441
|
/**
|
|
442
442
|
* Check use has the specific role permission or not
|
|
443
443
|
* @param roles Roles to check
|
package/lib/cjs/app/CoreApp.js
CHANGED
|
@@ -34,6 +34,7 @@ const EntityStatus_1 = require("../business/EntityStatus");
|
|
|
34
34
|
const ActionResultError_1 = require("../result/ActionResultError");
|
|
35
35
|
const IApp_1 = require("./IApp");
|
|
36
36
|
const UserRole_1 = require("./UserRole");
|
|
37
|
+
let CJ;
|
|
37
38
|
/**
|
|
38
39
|
* Core application
|
|
39
40
|
*/
|
|
@@ -151,12 +152,16 @@ class CoreApp {
|
|
|
151
152
|
this.fields = IApp_1.appFields.reduce((a, v) => ({ ...a, [v]: 'smarterp-' + v + '-' + name }), {});
|
|
152
153
|
// Device id
|
|
153
154
|
this._deviceId = storage.getData(this.fields.deviceId, '');
|
|
154
|
-
// Restore
|
|
155
|
-
this.restore();
|
|
156
155
|
this.setApi(api);
|
|
157
156
|
const { currentCulture, currentRegion } = settings;
|
|
158
|
-
|
|
159
|
-
|
|
157
|
+
// Load resources
|
|
158
|
+
Promise.all([
|
|
159
|
+
Promise.resolve().then(() => __importStar(require('crypto-js'))),
|
|
160
|
+
this.changeCulture(currentCulture)
|
|
161
|
+
]).then(([cj, _resources]) => {
|
|
162
|
+
(CJ = cj), this.changeRegion(currentRegion);
|
|
163
|
+
this.setup();
|
|
164
|
+
});
|
|
160
165
|
}
|
|
161
166
|
getDeviceId() {
|
|
162
167
|
return this.deviceId.substring(0, 15);
|
|
@@ -474,7 +479,7 @@ class CoreApp {
|
|
|
474
479
|
// Overwrite the current value
|
|
475
480
|
if (refreshToken !== '') {
|
|
476
481
|
if (refreshToken != null)
|
|
477
|
-
|
|
482
|
+
refreshToken = this.encrypt(refreshToken);
|
|
478
483
|
this.storage.setData(this.fields.headerToken, refreshToken);
|
|
479
484
|
}
|
|
480
485
|
// Reset tryLogin state
|
|
@@ -525,12 +530,13 @@ class CoreApp {
|
|
|
525
530
|
* @param culture New culture definition
|
|
526
531
|
* @param onReady On ready callback
|
|
527
532
|
*/
|
|
528
|
-
changeCulture(culture
|
|
533
|
+
async changeCulture(culture) {
|
|
529
534
|
// Name
|
|
530
535
|
const { name } = culture;
|
|
531
536
|
// Same?
|
|
532
|
-
|
|
533
|
-
|
|
537
|
+
let resources = culture.resources;
|
|
538
|
+
if (this._culture === name && typeof resources === 'object')
|
|
539
|
+
return resources;
|
|
534
540
|
// Save the cultrue to local storage
|
|
535
541
|
this.storage.setPersistedData(shared_1.DomUtils.CultureField, name);
|
|
536
542
|
// Change the API's Content-Language header
|
|
@@ -540,19 +546,13 @@ class CoreApp {
|
|
|
540
546
|
this._culture = name;
|
|
541
547
|
// Hold the current resources
|
|
542
548
|
this.settings.currentCulture = culture;
|
|
543
|
-
if (typeof
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
if (onReady)
|
|
548
|
-
onReady(result);
|
|
549
|
-
});
|
|
550
|
-
}
|
|
551
|
-
else {
|
|
552
|
-
this.updateRegionLabel();
|
|
553
|
-
if (onReady)
|
|
554
|
-
onReady(culture.resources);
|
|
549
|
+
if (typeof resources !== 'object') {
|
|
550
|
+
resources = await resources();
|
|
551
|
+
// Set static resources back
|
|
552
|
+
culture.resources = resources;
|
|
555
553
|
}
|
|
554
|
+
this.updateRegionLabel();
|
|
555
|
+
return resources;
|
|
556
556
|
}
|
|
557
557
|
/**
|
|
558
558
|
* Update current region label
|
|
@@ -595,12 +595,12 @@ class CoreApp {
|
|
|
595
595
|
* @param passphrase Secret passphrase
|
|
596
596
|
* @returns Pure text
|
|
597
597
|
*/
|
|
598
|
-
|
|
598
|
+
decrypt(messageEncrypted, passphrase) {
|
|
599
599
|
// Iterations
|
|
600
600
|
const iterations = parseInt(messageEncrypted.substring(0, 2), 10);
|
|
601
601
|
if (isNaN(iterations))
|
|
602
602
|
return undefined;
|
|
603
|
-
const { PBKDF2, algo, enc, AES, pad, mode } =
|
|
603
|
+
const { PBKDF2, algo, enc, AES, pad, mode } = CJ;
|
|
604
604
|
try {
|
|
605
605
|
const salt = enc.Hex.parse(messageEncrypted.substring(2, 34));
|
|
606
606
|
const iv = enc.Hex.parse(messageEncrypted.substring(34, 66));
|
|
@@ -628,7 +628,7 @@ class CoreApp {
|
|
|
628
628
|
* @param durationSeconds Duration seconds, <= 12 will be considered as month
|
|
629
629
|
* @returns Pure text
|
|
630
630
|
*/
|
|
631
|
-
|
|
631
|
+
decryptEnhanced(messageEncrypted, passphrase, durationSeconds) {
|
|
632
632
|
// Timestamp splitter
|
|
633
633
|
const pos = messageEncrypted.indexOf('!');
|
|
634
634
|
// Miliseconds chars are longer than 8
|
|
@@ -649,7 +649,7 @@ class CoreApp {
|
|
|
649
649
|
}
|
|
650
650
|
const message = messageEncrypted.substring(pos + 1);
|
|
651
651
|
passphrase = this.encryptionEnhance(passphrase !== null && passphrase !== void 0 ? passphrase : this.passphrase, timestamp);
|
|
652
|
-
return
|
|
652
|
+
return this.decrypt(message, passphrase);
|
|
653
653
|
}
|
|
654
654
|
catch (e) {
|
|
655
655
|
console.log('decryptEnhanced', e);
|
|
@@ -696,10 +696,10 @@ class CoreApp {
|
|
|
696
696
|
* @param iterations Iterations, 1000 times, 1 - 99
|
|
697
697
|
* @returns Result
|
|
698
698
|
*/
|
|
699
|
-
|
|
699
|
+
encrypt(message, passphrase, iterations) {
|
|
700
700
|
// Default 1 * 1000
|
|
701
701
|
iterations !== null && iterations !== void 0 ? iterations : (iterations = 1);
|
|
702
|
-
const { lib, PBKDF2, algo, enc, AES, pad, mode } =
|
|
702
|
+
const { lib, PBKDF2, algo, enc, AES, pad, mode } = CJ;
|
|
703
703
|
const bits = 16; // 128 / 8
|
|
704
704
|
const salt = lib.WordArray.random(bits);
|
|
705
705
|
const key = PBKDF2(passphrase !== null && passphrase !== void 0 ? passphrase : this.passphrase, salt, {
|
|
@@ -725,11 +725,11 @@ class CoreApp {
|
|
|
725
725
|
* @param iterations Iterations, 1000 times, 1 - 99
|
|
726
726
|
* @returns Result
|
|
727
727
|
*/
|
|
728
|
-
|
|
728
|
+
encryptEnhanced(message, passphrase, iterations) {
|
|
729
729
|
// Timestamp
|
|
730
730
|
const timestamp = shared_1.Utils.numberToChars(new Date().getTime());
|
|
731
731
|
passphrase = this.encryptionEnhance(passphrase !== null && passphrase !== void 0 ? passphrase : this.passphrase, timestamp);
|
|
732
|
-
const result =
|
|
732
|
+
const result = this.encrypt(message, passphrase, iterations);
|
|
733
733
|
return timestamp + '!' + result;
|
|
734
734
|
}
|
|
735
735
|
/**
|
|
@@ -1069,8 +1069,8 @@ class CoreApp {
|
|
|
1069
1069
|
* @param message Message
|
|
1070
1070
|
* @param passphrase Secret passphrase
|
|
1071
1071
|
*/
|
|
1072
|
-
|
|
1073
|
-
const { SHA3, enc, HmacSHA512 } =
|
|
1072
|
+
hash(message, passphrase) {
|
|
1073
|
+
const { SHA3, enc, HmacSHA512 } = CJ;
|
|
1074
1074
|
if (passphrase == null)
|
|
1075
1075
|
return SHA3(message, { outputLength: 512 }).toString(enc.Base64);
|
|
1076
1076
|
else
|
|
@@ -1082,8 +1082,8 @@ class CoreApp {
|
|
|
1082
1082
|
* @param message Message
|
|
1083
1083
|
* @param passphrase Secret passphrase
|
|
1084
1084
|
*/
|
|
1085
|
-
|
|
1086
|
-
const { SHA3, enc, HmacSHA512 } =
|
|
1085
|
+
hashHex(message, passphrase) {
|
|
1086
|
+
const { SHA3, enc, HmacSHA512 } = CJ;
|
|
1087
1087
|
if (passphrase == null)
|
|
1088
1088
|
return SHA3(message, { outputLength: 512 }).toString(enc.Hex);
|
|
1089
1089
|
else
|
|
@@ -1206,7 +1206,10 @@ class CoreApp {
|
|
|
1206
1206
|
/**
|
|
1207
1207
|
* Setup callback
|
|
1208
1208
|
*/
|
|
1209
|
-
setup() {
|
|
1209
|
+
setup() {
|
|
1210
|
+
// Restore
|
|
1211
|
+
this.restore();
|
|
1212
|
+
}
|
|
1210
1213
|
/**
|
|
1211
1214
|
* Signout
|
|
1212
1215
|
* @param apiUrl Signout API URL
|
|
@@ -1258,7 +1261,7 @@ class CoreApp {
|
|
|
1258
1261
|
this.authorize(user.token, refreshToken);
|
|
1259
1262
|
}
|
|
1260
1263
|
else {
|
|
1261
|
-
this.
|
|
1264
|
+
this.cachedRefreshToken = this.encrypt(refreshToken);
|
|
1262
1265
|
this.authorize(user.token, undefined);
|
|
1263
1266
|
}
|
|
1264
1267
|
}
|
package/lib/cjs/app/IApp.d.ts
CHANGED
|
@@ -159,9 +159,8 @@ export interface IApp {
|
|
|
159
159
|
/**
|
|
160
160
|
* Change culture
|
|
161
161
|
* @param culture New culture definition
|
|
162
|
-
* @param onReady On ready callback
|
|
163
162
|
*/
|
|
164
|
-
changeCulture(culture: DataTypes.CultureDefinition
|
|
163
|
+
changeCulture(culture: DataTypes.CultureDefinition): Promise<DataTypes.StringRecord>;
|
|
165
164
|
/**
|
|
166
165
|
* Check the action result is about device invalid
|
|
167
166
|
* @param result Action result
|
|
@@ -188,7 +187,7 @@ export interface IApp {
|
|
|
188
187
|
* @param passphrase Secret passphrase
|
|
189
188
|
* @returns Pure text
|
|
190
189
|
*/
|
|
191
|
-
decrypt(messageEncrypted: string, passphrase?: string):
|
|
190
|
+
decrypt(messageEncrypted: string, passphrase?: string): string | undefined;
|
|
192
191
|
/**
|
|
193
192
|
* Enhanced decrypt message
|
|
194
193
|
* @param messageEncrypted Encrypted message
|
|
@@ -196,7 +195,7 @@ export interface IApp {
|
|
|
196
195
|
* @param durationSeconds Duration seconds, <= 12 will be considered as month
|
|
197
196
|
* @returns Pure text
|
|
198
197
|
*/
|
|
199
|
-
decryptEnhanced(messageEncrypted: string, passphrase?: string, durationSeconds?: number):
|
|
198
|
+
decryptEnhanced(messageEncrypted: string, passphrase?: string, durationSeconds?: number): string | undefined;
|
|
200
199
|
/**
|
|
201
200
|
* Detect IP data, call only one time
|
|
202
201
|
* @param callback Callback will be called when the IP is ready
|
|
@@ -209,7 +208,7 @@ export interface IApp {
|
|
|
209
208
|
* @param iterations Iterations, 1000 times, 1 - 99
|
|
210
209
|
* @returns Result
|
|
211
210
|
*/
|
|
212
|
-
encrypt(message: string, passphrase?: string, iterations?: number):
|
|
211
|
+
encrypt(message: string, passphrase?: string, iterations?: number): string;
|
|
213
212
|
/**
|
|
214
213
|
* Enhanced encrypt message
|
|
215
214
|
* @param message Message
|
|
@@ -217,7 +216,7 @@ export interface IApp {
|
|
|
217
216
|
* @param iterations Iterations, 1000 times, 1 - 99
|
|
218
217
|
* @returns Result
|
|
219
218
|
*/
|
|
220
|
-
encryptEnhanced(message: string, passphrase?: string, iterations?: number):
|
|
219
|
+
encryptEnhanced(message: string, passphrase?: string, iterations?: number): string;
|
|
221
220
|
/**
|
|
222
221
|
* Format date to string
|
|
223
222
|
* @param input Input date
|
|
@@ -366,14 +365,14 @@ export interface IApp {
|
|
|
366
365
|
* @param message Message
|
|
367
366
|
* @param passphrase Secret passphrase
|
|
368
367
|
*/
|
|
369
|
-
hash(message: string, passphrase?: string):
|
|
368
|
+
hash(message: string, passphrase?: string): string;
|
|
370
369
|
/**
|
|
371
370
|
* Hash message Hex, SHA3 or HmacSHA512, 512 as Base64
|
|
372
371
|
* https://cryptojs.gitbook.io/docs/
|
|
373
372
|
* @param message Message
|
|
374
373
|
* @param passphrase Secret passphrase
|
|
375
374
|
*/
|
|
376
|
-
hashHex(message: string, passphrase?: string):
|
|
375
|
+
hashHex(message: string, passphrase?: string): string;
|
|
377
376
|
/**
|
|
378
377
|
* Check use has the specific role permission or not
|
|
379
378
|
* @param roles Roles to check
|
package/lib/mjs/app/CoreApp.d.ts
CHANGED
|
@@ -221,7 +221,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
221
221
|
* @param culture New culture definition
|
|
222
222
|
* @param onReady On ready callback
|
|
223
223
|
*/
|
|
224
|
-
changeCulture(culture: DataTypes.CultureDefinition
|
|
224
|
+
changeCulture(culture: DataTypes.CultureDefinition): Promise<DataTypes.StringRecord>;
|
|
225
225
|
/**
|
|
226
226
|
* Update current region label
|
|
227
227
|
*/
|
|
@@ -246,7 +246,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
246
246
|
* @param passphrase Secret passphrase
|
|
247
247
|
* @returns Pure text
|
|
248
248
|
*/
|
|
249
|
-
decrypt(messageEncrypted: string, passphrase?: string):
|
|
249
|
+
decrypt(messageEncrypted: string, passphrase?: string): string | undefined;
|
|
250
250
|
/**
|
|
251
251
|
* Enhanced decrypt message
|
|
252
252
|
* @param messageEncrypted Encrypted message
|
|
@@ -254,7 +254,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
254
254
|
* @param durationSeconds Duration seconds, <= 12 will be considered as month
|
|
255
255
|
* @returns Pure text
|
|
256
256
|
*/
|
|
257
|
-
decryptEnhanced(messageEncrypted: string, passphrase?: string, durationSeconds?: number):
|
|
257
|
+
decryptEnhanced(messageEncrypted: string, passphrase?: string, durationSeconds?: number): string | undefined;
|
|
258
258
|
/**
|
|
259
259
|
* Detect IP data, call only one time
|
|
260
260
|
* @param callback Callback will be called when the IP is ready
|
|
@@ -268,7 +268,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
268
268
|
* @param iterations Iterations, 1000 times, 1 - 99
|
|
269
269
|
* @returns Result
|
|
270
270
|
*/
|
|
271
|
-
encrypt(message: string, passphrase?: string, iterations?: number):
|
|
271
|
+
encrypt(message: string, passphrase?: string, iterations?: number): string;
|
|
272
272
|
/**
|
|
273
273
|
* Enhanced encrypt message
|
|
274
274
|
* @param message Message
|
|
@@ -276,7 +276,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
276
276
|
* @param iterations Iterations, 1000 times, 1 - 99
|
|
277
277
|
* @returns Result
|
|
278
278
|
*/
|
|
279
|
-
encryptEnhanced(message: string, passphrase?: string, iterations?: number):
|
|
279
|
+
encryptEnhanced(message: string, passphrase?: string, iterations?: number): string;
|
|
280
280
|
/**
|
|
281
281
|
* Enchance secret passphrase
|
|
282
282
|
* @param passphrase Secret passphrase
|
|
@@ -430,14 +430,14 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
430
430
|
* @param message Message
|
|
431
431
|
* @param passphrase Secret passphrase
|
|
432
432
|
*/
|
|
433
|
-
hash(message: string, passphrase?: string):
|
|
433
|
+
hash(message: string, passphrase?: string): string;
|
|
434
434
|
/**
|
|
435
435
|
* Hash message Hex, SHA3 or HmacSHA512, 512 as Base64
|
|
436
436
|
* https://cryptojs.gitbook.io/docs/
|
|
437
437
|
* @param message Message
|
|
438
438
|
* @param passphrase Secret passphrase
|
|
439
439
|
*/
|
|
440
|
-
hashHex(message: string, passphrase?: string):
|
|
440
|
+
hashHex(message: string, passphrase?: string): string;
|
|
441
441
|
/**
|
|
442
442
|
* Check use has the specific role permission or not
|
|
443
443
|
* @param roles Roles to check
|
package/lib/mjs/app/CoreApp.js
CHANGED
|
@@ -8,6 +8,7 @@ import { EntityStatus } from '../business/EntityStatus';
|
|
|
8
8
|
import { ActionResultError } from '../result/ActionResultError';
|
|
9
9
|
import { appFields } from './IApp';
|
|
10
10
|
import { UserRole } from './UserRole';
|
|
11
|
+
let CJ;
|
|
11
12
|
/**
|
|
12
13
|
* Core application
|
|
13
14
|
*/
|
|
@@ -125,12 +126,16 @@ export class CoreApp {
|
|
|
125
126
|
this.fields = appFields.reduce((a, v) => ({ ...a, [v]: 'smarterp-' + v + '-' + name }), {});
|
|
126
127
|
// Device id
|
|
127
128
|
this._deviceId = storage.getData(this.fields.deviceId, '');
|
|
128
|
-
// Restore
|
|
129
|
-
this.restore();
|
|
130
129
|
this.setApi(api);
|
|
131
130
|
const { currentCulture, currentRegion } = settings;
|
|
132
|
-
|
|
133
|
-
|
|
131
|
+
// Load resources
|
|
132
|
+
Promise.all([
|
|
133
|
+
import('crypto-js'),
|
|
134
|
+
this.changeCulture(currentCulture)
|
|
135
|
+
]).then(([cj, _resources]) => {
|
|
136
|
+
(CJ = cj), this.changeRegion(currentRegion);
|
|
137
|
+
this.setup();
|
|
138
|
+
});
|
|
134
139
|
}
|
|
135
140
|
getDeviceId() {
|
|
136
141
|
return this.deviceId.substring(0, 15);
|
|
@@ -448,7 +453,7 @@ export class CoreApp {
|
|
|
448
453
|
// Overwrite the current value
|
|
449
454
|
if (refreshToken !== '') {
|
|
450
455
|
if (refreshToken != null)
|
|
451
|
-
|
|
456
|
+
refreshToken = this.encrypt(refreshToken);
|
|
452
457
|
this.storage.setData(this.fields.headerToken, refreshToken);
|
|
453
458
|
}
|
|
454
459
|
// Reset tryLogin state
|
|
@@ -499,12 +504,13 @@ export class CoreApp {
|
|
|
499
504
|
* @param culture New culture definition
|
|
500
505
|
* @param onReady On ready callback
|
|
501
506
|
*/
|
|
502
|
-
changeCulture(culture
|
|
507
|
+
async changeCulture(culture) {
|
|
503
508
|
// Name
|
|
504
509
|
const { name } = culture;
|
|
505
510
|
// Same?
|
|
506
|
-
|
|
507
|
-
|
|
511
|
+
let resources = culture.resources;
|
|
512
|
+
if (this._culture === name && typeof resources === 'object')
|
|
513
|
+
return resources;
|
|
508
514
|
// Save the cultrue to local storage
|
|
509
515
|
this.storage.setPersistedData(DomUtils.CultureField, name);
|
|
510
516
|
// Change the API's Content-Language header
|
|
@@ -514,19 +520,13 @@ export class CoreApp {
|
|
|
514
520
|
this._culture = name;
|
|
515
521
|
// Hold the current resources
|
|
516
522
|
this.settings.currentCulture = culture;
|
|
517
|
-
if (typeof
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
if (onReady)
|
|
522
|
-
onReady(result);
|
|
523
|
-
});
|
|
524
|
-
}
|
|
525
|
-
else {
|
|
526
|
-
this.updateRegionLabel();
|
|
527
|
-
if (onReady)
|
|
528
|
-
onReady(culture.resources);
|
|
523
|
+
if (typeof resources !== 'object') {
|
|
524
|
+
resources = await resources();
|
|
525
|
+
// Set static resources back
|
|
526
|
+
culture.resources = resources;
|
|
529
527
|
}
|
|
528
|
+
this.updateRegionLabel();
|
|
529
|
+
return resources;
|
|
530
530
|
}
|
|
531
531
|
/**
|
|
532
532
|
* Update current region label
|
|
@@ -569,12 +569,12 @@ export class CoreApp {
|
|
|
569
569
|
* @param passphrase Secret passphrase
|
|
570
570
|
* @returns Pure text
|
|
571
571
|
*/
|
|
572
|
-
|
|
572
|
+
decrypt(messageEncrypted, passphrase) {
|
|
573
573
|
// Iterations
|
|
574
574
|
const iterations = parseInt(messageEncrypted.substring(0, 2), 10);
|
|
575
575
|
if (isNaN(iterations))
|
|
576
576
|
return undefined;
|
|
577
|
-
const { PBKDF2, algo, enc, AES, pad, mode } =
|
|
577
|
+
const { PBKDF2, algo, enc, AES, pad, mode } = CJ;
|
|
578
578
|
try {
|
|
579
579
|
const salt = enc.Hex.parse(messageEncrypted.substring(2, 34));
|
|
580
580
|
const iv = enc.Hex.parse(messageEncrypted.substring(34, 66));
|
|
@@ -602,7 +602,7 @@ export class CoreApp {
|
|
|
602
602
|
* @param durationSeconds Duration seconds, <= 12 will be considered as month
|
|
603
603
|
* @returns Pure text
|
|
604
604
|
*/
|
|
605
|
-
|
|
605
|
+
decryptEnhanced(messageEncrypted, passphrase, durationSeconds) {
|
|
606
606
|
// Timestamp splitter
|
|
607
607
|
const pos = messageEncrypted.indexOf('!');
|
|
608
608
|
// Miliseconds chars are longer than 8
|
|
@@ -623,7 +623,7 @@ export class CoreApp {
|
|
|
623
623
|
}
|
|
624
624
|
const message = messageEncrypted.substring(pos + 1);
|
|
625
625
|
passphrase = this.encryptionEnhance(passphrase !== null && passphrase !== void 0 ? passphrase : this.passphrase, timestamp);
|
|
626
|
-
return
|
|
626
|
+
return this.decrypt(message, passphrase);
|
|
627
627
|
}
|
|
628
628
|
catch (e) {
|
|
629
629
|
console.log('decryptEnhanced', e);
|
|
@@ -670,10 +670,10 @@ export class CoreApp {
|
|
|
670
670
|
* @param iterations Iterations, 1000 times, 1 - 99
|
|
671
671
|
* @returns Result
|
|
672
672
|
*/
|
|
673
|
-
|
|
673
|
+
encrypt(message, passphrase, iterations) {
|
|
674
674
|
// Default 1 * 1000
|
|
675
675
|
iterations !== null && iterations !== void 0 ? iterations : (iterations = 1);
|
|
676
|
-
const { lib, PBKDF2, algo, enc, AES, pad, mode } =
|
|
676
|
+
const { lib, PBKDF2, algo, enc, AES, pad, mode } = CJ;
|
|
677
677
|
const bits = 16; // 128 / 8
|
|
678
678
|
const salt = lib.WordArray.random(bits);
|
|
679
679
|
const key = PBKDF2(passphrase !== null && passphrase !== void 0 ? passphrase : this.passphrase, salt, {
|
|
@@ -699,11 +699,11 @@ export class CoreApp {
|
|
|
699
699
|
* @param iterations Iterations, 1000 times, 1 - 99
|
|
700
700
|
* @returns Result
|
|
701
701
|
*/
|
|
702
|
-
|
|
702
|
+
encryptEnhanced(message, passphrase, iterations) {
|
|
703
703
|
// Timestamp
|
|
704
704
|
const timestamp = Utils.numberToChars(new Date().getTime());
|
|
705
705
|
passphrase = this.encryptionEnhance(passphrase !== null && passphrase !== void 0 ? passphrase : this.passphrase, timestamp);
|
|
706
|
-
const result =
|
|
706
|
+
const result = this.encrypt(message, passphrase, iterations);
|
|
707
707
|
return timestamp + '!' + result;
|
|
708
708
|
}
|
|
709
709
|
/**
|
|
@@ -1043,8 +1043,8 @@ export class CoreApp {
|
|
|
1043
1043
|
* @param message Message
|
|
1044
1044
|
* @param passphrase Secret passphrase
|
|
1045
1045
|
*/
|
|
1046
|
-
|
|
1047
|
-
const { SHA3, enc, HmacSHA512 } =
|
|
1046
|
+
hash(message, passphrase) {
|
|
1047
|
+
const { SHA3, enc, HmacSHA512 } = CJ;
|
|
1048
1048
|
if (passphrase == null)
|
|
1049
1049
|
return SHA3(message, { outputLength: 512 }).toString(enc.Base64);
|
|
1050
1050
|
else
|
|
@@ -1056,8 +1056,8 @@ export class CoreApp {
|
|
|
1056
1056
|
* @param message Message
|
|
1057
1057
|
* @param passphrase Secret passphrase
|
|
1058
1058
|
*/
|
|
1059
|
-
|
|
1060
|
-
const { SHA3, enc, HmacSHA512 } =
|
|
1059
|
+
hashHex(message, passphrase) {
|
|
1060
|
+
const { SHA3, enc, HmacSHA512 } = CJ;
|
|
1061
1061
|
if (passphrase == null)
|
|
1062
1062
|
return SHA3(message, { outputLength: 512 }).toString(enc.Hex);
|
|
1063
1063
|
else
|
|
@@ -1180,7 +1180,10 @@ export class CoreApp {
|
|
|
1180
1180
|
/**
|
|
1181
1181
|
* Setup callback
|
|
1182
1182
|
*/
|
|
1183
|
-
setup() {
|
|
1183
|
+
setup() {
|
|
1184
|
+
// Restore
|
|
1185
|
+
this.restore();
|
|
1186
|
+
}
|
|
1184
1187
|
/**
|
|
1185
1188
|
* Signout
|
|
1186
1189
|
* @param apiUrl Signout API URL
|
|
@@ -1232,7 +1235,7 @@ export class CoreApp {
|
|
|
1232
1235
|
this.authorize(user.token, refreshToken);
|
|
1233
1236
|
}
|
|
1234
1237
|
else {
|
|
1235
|
-
this.
|
|
1238
|
+
this.cachedRefreshToken = this.encrypt(refreshToken);
|
|
1236
1239
|
this.authorize(user.token, undefined);
|
|
1237
1240
|
}
|
|
1238
1241
|
}
|
package/lib/mjs/app/IApp.d.ts
CHANGED
|
@@ -159,9 +159,8 @@ export interface IApp {
|
|
|
159
159
|
/**
|
|
160
160
|
* Change culture
|
|
161
161
|
* @param culture New culture definition
|
|
162
|
-
* @param onReady On ready callback
|
|
163
162
|
*/
|
|
164
|
-
changeCulture(culture: DataTypes.CultureDefinition
|
|
163
|
+
changeCulture(culture: DataTypes.CultureDefinition): Promise<DataTypes.StringRecord>;
|
|
165
164
|
/**
|
|
166
165
|
* Check the action result is about device invalid
|
|
167
166
|
* @param result Action result
|
|
@@ -188,7 +187,7 @@ export interface IApp {
|
|
|
188
187
|
* @param passphrase Secret passphrase
|
|
189
188
|
* @returns Pure text
|
|
190
189
|
*/
|
|
191
|
-
decrypt(messageEncrypted: string, passphrase?: string):
|
|
190
|
+
decrypt(messageEncrypted: string, passphrase?: string): string | undefined;
|
|
192
191
|
/**
|
|
193
192
|
* Enhanced decrypt message
|
|
194
193
|
* @param messageEncrypted Encrypted message
|
|
@@ -196,7 +195,7 @@ export interface IApp {
|
|
|
196
195
|
* @param durationSeconds Duration seconds, <= 12 will be considered as month
|
|
197
196
|
* @returns Pure text
|
|
198
197
|
*/
|
|
199
|
-
decryptEnhanced(messageEncrypted: string, passphrase?: string, durationSeconds?: number):
|
|
198
|
+
decryptEnhanced(messageEncrypted: string, passphrase?: string, durationSeconds?: number): string | undefined;
|
|
200
199
|
/**
|
|
201
200
|
* Detect IP data, call only one time
|
|
202
201
|
* @param callback Callback will be called when the IP is ready
|
|
@@ -209,7 +208,7 @@ export interface IApp {
|
|
|
209
208
|
* @param iterations Iterations, 1000 times, 1 - 99
|
|
210
209
|
* @returns Result
|
|
211
210
|
*/
|
|
212
|
-
encrypt(message: string, passphrase?: string, iterations?: number):
|
|
211
|
+
encrypt(message: string, passphrase?: string, iterations?: number): string;
|
|
213
212
|
/**
|
|
214
213
|
* Enhanced encrypt message
|
|
215
214
|
* @param message Message
|
|
@@ -217,7 +216,7 @@ export interface IApp {
|
|
|
217
216
|
* @param iterations Iterations, 1000 times, 1 - 99
|
|
218
217
|
* @returns Result
|
|
219
218
|
*/
|
|
220
|
-
encryptEnhanced(message: string, passphrase?: string, iterations?: number):
|
|
219
|
+
encryptEnhanced(message: string, passphrase?: string, iterations?: number): string;
|
|
221
220
|
/**
|
|
222
221
|
* Format date to string
|
|
223
222
|
* @param input Input date
|
|
@@ -366,14 +365,14 @@ export interface IApp {
|
|
|
366
365
|
* @param message Message
|
|
367
366
|
* @param passphrase Secret passphrase
|
|
368
367
|
*/
|
|
369
|
-
hash(message: string, passphrase?: string):
|
|
368
|
+
hash(message: string, passphrase?: string): string;
|
|
370
369
|
/**
|
|
371
370
|
* Hash message Hex, SHA3 or HmacSHA512, 512 as Base64
|
|
372
371
|
* https://cryptojs.gitbook.io/docs/
|
|
373
372
|
* @param message Message
|
|
374
373
|
* @param passphrase Secret passphrase
|
|
375
374
|
*/
|
|
376
|
-
hashHex(message: string, passphrase?: string):
|
|
375
|
+
hashHex(message: string, passphrase?: string): string;
|
|
377
376
|
/**
|
|
378
377
|
* Check use has the specific role permission or not
|
|
379
378
|
* @param roles Roles to check
|
package/package.json
CHANGED
package/src/app/CoreApp.ts
CHANGED
|
@@ -38,6 +38,10 @@ import {
|
|
|
38
38
|
RefreshTokenResult
|
|
39
39
|
} from './IApp';
|
|
40
40
|
import { UserRole } from './UserRole';
|
|
41
|
+
import type CryptoJS from 'crypto-js';
|
|
42
|
+
|
|
43
|
+
type CJType = typeof CryptoJS;
|
|
44
|
+
let CJ: CJType;
|
|
41
45
|
|
|
42
46
|
/**
|
|
43
47
|
* Core application interface
|
|
@@ -266,15 +270,18 @@ export abstract class CoreApp<
|
|
|
266
270
|
// Device id
|
|
267
271
|
this._deviceId = storage.getData(this.fields.deviceId, '');
|
|
268
272
|
|
|
269
|
-
// Restore
|
|
270
|
-
this.restore();
|
|
271
|
-
|
|
272
273
|
this.setApi(api);
|
|
273
274
|
|
|
274
275
|
const { currentCulture, currentRegion } = settings;
|
|
275
|
-
this.changeCulture(currentCulture, () => this.setup());
|
|
276
276
|
|
|
277
|
-
|
|
277
|
+
// Load resources
|
|
278
|
+
Promise.all([
|
|
279
|
+
import('crypto-js'),
|
|
280
|
+
this.changeCulture(currentCulture)
|
|
281
|
+
]).then(([cj, _resources]) => {
|
|
282
|
+
(CJ = cj), this.changeRegion(currentRegion);
|
|
283
|
+
this.setup();
|
|
284
|
+
});
|
|
278
285
|
}
|
|
279
286
|
|
|
280
287
|
private getDeviceId() {
|
|
@@ -681,10 +688,7 @@ export abstract class CoreApp<
|
|
|
681
688
|
|
|
682
689
|
// Overwrite the current value
|
|
683
690
|
if (refreshToken !== '') {
|
|
684
|
-
if (refreshToken != null)
|
|
685
|
-
this.encrypt(refreshToken).then((result) =>
|
|
686
|
-
this.storage.setData(this.fields.headerToken, result)
|
|
687
|
-
);
|
|
691
|
+
if (refreshToken != null) refreshToken = this.encrypt(refreshToken);
|
|
688
692
|
this.storage.setData(this.fields.headerToken, refreshToken);
|
|
689
693
|
}
|
|
690
694
|
|
|
@@ -742,15 +746,14 @@ export abstract class CoreApp<
|
|
|
742
746
|
* @param culture New culture definition
|
|
743
747
|
* @param onReady On ready callback
|
|
744
748
|
*/
|
|
745
|
-
changeCulture(
|
|
746
|
-
culture: DataTypes.CultureDefinition,
|
|
747
|
-
onReady?: (resources: DataTypes.StringRecord) => void
|
|
748
|
-
) {
|
|
749
|
+
async changeCulture(culture: DataTypes.CultureDefinition) {
|
|
749
750
|
// Name
|
|
750
751
|
const { name } = culture;
|
|
751
752
|
|
|
752
753
|
// Same?
|
|
753
|
-
|
|
754
|
+
let resources = culture.resources;
|
|
755
|
+
if (this._culture === name && typeof resources === 'object')
|
|
756
|
+
return resources;
|
|
754
757
|
|
|
755
758
|
// Save the cultrue to local storage
|
|
756
759
|
this.storage.setPersistedData(DomUtils.CultureField, name);
|
|
@@ -765,16 +768,15 @@ export abstract class CoreApp<
|
|
|
765
768
|
// Hold the current resources
|
|
766
769
|
this.settings.currentCulture = culture;
|
|
767
770
|
|
|
768
|
-
if (typeof
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
});
|
|
774
|
-
} else {
|
|
775
|
-
this.updateRegionLabel();
|
|
776
|
-
if (onReady) onReady(culture.resources);
|
|
771
|
+
if (typeof resources !== 'object') {
|
|
772
|
+
resources = await resources();
|
|
773
|
+
|
|
774
|
+
// Set static resources back
|
|
775
|
+
culture.resources = resources;
|
|
777
776
|
}
|
|
777
|
+
this.updateRegionLabel();
|
|
778
|
+
|
|
779
|
+
return resources;
|
|
778
780
|
}
|
|
779
781
|
|
|
780
782
|
/**
|
|
@@ -826,12 +828,12 @@ export abstract class CoreApp<
|
|
|
826
828
|
* @param passphrase Secret passphrase
|
|
827
829
|
* @returns Pure text
|
|
828
830
|
*/
|
|
829
|
-
|
|
831
|
+
decrypt(messageEncrypted: string, passphrase?: string) {
|
|
830
832
|
// Iterations
|
|
831
833
|
const iterations = parseInt(messageEncrypted.substring(0, 2), 10);
|
|
832
834
|
if (isNaN(iterations)) return undefined;
|
|
833
835
|
|
|
834
|
-
const { PBKDF2, algo, enc, AES, pad, mode } =
|
|
836
|
+
const { PBKDF2, algo, enc, AES, pad, mode } = CJ;
|
|
835
837
|
|
|
836
838
|
try {
|
|
837
839
|
const salt = enc.Hex.parse(messageEncrypted.substring(2, 34));
|
|
@@ -862,7 +864,7 @@ export abstract class CoreApp<
|
|
|
862
864
|
* @param durationSeconds Duration seconds, <= 12 will be considered as month
|
|
863
865
|
* @returns Pure text
|
|
864
866
|
*/
|
|
865
|
-
|
|
867
|
+
decryptEnhanced(
|
|
866
868
|
messageEncrypted: string,
|
|
867
869
|
passphrase?: string,
|
|
868
870
|
durationSeconds?: number
|
|
@@ -895,7 +897,7 @@ export abstract class CoreApp<
|
|
|
895
897
|
timestamp
|
|
896
898
|
);
|
|
897
899
|
|
|
898
|
-
return
|
|
900
|
+
return this.decrypt(message, passphrase);
|
|
899
901
|
} catch (e) {
|
|
900
902
|
console.log('decryptEnhanced', e);
|
|
901
903
|
return undefined;
|
|
@@ -949,13 +951,11 @@ export abstract class CoreApp<
|
|
|
949
951
|
* @param iterations Iterations, 1000 times, 1 - 99
|
|
950
952
|
* @returns Result
|
|
951
953
|
*/
|
|
952
|
-
|
|
954
|
+
encrypt(message: string, passphrase?: string, iterations?: number) {
|
|
953
955
|
// Default 1 * 1000
|
|
954
956
|
iterations ??= 1;
|
|
955
957
|
|
|
956
|
-
const { lib, PBKDF2, algo, enc, AES, pad, mode } =
|
|
957
|
-
'crypto-js'
|
|
958
|
-
);
|
|
958
|
+
const { lib, PBKDF2, algo, enc, AES, pad, mode } = CJ;
|
|
959
959
|
|
|
960
960
|
const bits = 16; // 128 / 8
|
|
961
961
|
const salt = lib.WordArray.random(bits);
|
|
@@ -985,11 +985,7 @@ export abstract class CoreApp<
|
|
|
985
985
|
* @param iterations Iterations, 1000 times, 1 - 99
|
|
986
986
|
* @returns Result
|
|
987
987
|
*/
|
|
988
|
-
|
|
989
|
-
message: string,
|
|
990
|
-
passphrase?: string,
|
|
991
|
-
iterations?: number
|
|
992
|
-
) {
|
|
988
|
+
encryptEnhanced(message: string, passphrase?: string, iterations?: number) {
|
|
993
989
|
// Timestamp
|
|
994
990
|
const timestamp = Utils.numberToChars(new Date().getTime());
|
|
995
991
|
|
|
@@ -998,7 +994,7 @@ export abstract class CoreApp<
|
|
|
998
994
|
timestamp
|
|
999
995
|
);
|
|
1000
996
|
|
|
1001
|
-
const result =
|
|
997
|
+
const result = this.encrypt(message, passphrase, iterations);
|
|
1002
998
|
|
|
1003
999
|
return timestamp + '!' + result;
|
|
1004
1000
|
}
|
|
@@ -1399,8 +1395,8 @@ export abstract class CoreApp<
|
|
|
1399
1395
|
* @param message Message
|
|
1400
1396
|
* @param passphrase Secret passphrase
|
|
1401
1397
|
*/
|
|
1402
|
-
|
|
1403
|
-
const { SHA3, enc, HmacSHA512 } =
|
|
1398
|
+
hash(message: string, passphrase?: string) {
|
|
1399
|
+
const { SHA3, enc, HmacSHA512 } = CJ;
|
|
1404
1400
|
if (passphrase == null)
|
|
1405
1401
|
return SHA3(message, { outputLength: 512 }).toString(enc.Base64);
|
|
1406
1402
|
else return HmacSHA512(message, passphrase).toString(enc.Base64);
|
|
@@ -1412,8 +1408,8 @@ export abstract class CoreApp<
|
|
|
1412
1408
|
* @param message Message
|
|
1413
1409
|
* @param passphrase Secret passphrase
|
|
1414
1410
|
*/
|
|
1415
|
-
|
|
1416
|
-
const { SHA3, enc, HmacSHA512 } =
|
|
1411
|
+
hashHex(message: string, passphrase?: string) {
|
|
1412
|
+
const { SHA3, enc, HmacSHA512 } = CJ;
|
|
1417
1413
|
if (passphrase == null)
|
|
1418
1414
|
return SHA3(message, { outputLength: 512 }).toString(enc.Hex);
|
|
1419
1415
|
else return HmacSHA512(message, passphrase).toString(enc.Hex);
|
|
@@ -1548,7 +1544,10 @@ export abstract class CoreApp<
|
|
|
1548
1544
|
/**
|
|
1549
1545
|
* Setup callback
|
|
1550
1546
|
*/
|
|
1551
|
-
setup() {
|
|
1547
|
+
setup() {
|
|
1548
|
+
// Restore
|
|
1549
|
+
this.restore();
|
|
1550
|
+
}
|
|
1552
1551
|
|
|
1553
1552
|
/**
|
|
1554
1553
|
* Signout
|
|
@@ -1610,9 +1609,7 @@ export abstract class CoreApp<
|
|
|
1610
1609
|
if (keep) {
|
|
1611
1610
|
this.authorize(user.token, refreshToken);
|
|
1612
1611
|
} else {
|
|
1613
|
-
this.encrypt(refreshToken)
|
|
1614
|
-
(result) => (this.cachedRefreshToken = result)
|
|
1615
|
-
);
|
|
1612
|
+
this.cachedRefreshToken = this.encrypt(refreshToken);
|
|
1616
1613
|
this.authorize(user.token, undefined);
|
|
1617
1614
|
}
|
|
1618
1615
|
}
|
package/src/app/IApp.ts
CHANGED
|
@@ -214,12 +214,10 @@ export interface IApp {
|
|
|
214
214
|
/**
|
|
215
215
|
* Change culture
|
|
216
216
|
* @param culture New culture definition
|
|
217
|
-
* @param onReady On ready callback
|
|
218
217
|
*/
|
|
219
218
|
changeCulture(
|
|
220
|
-
culture: DataTypes.CultureDefinition
|
|
221
|
-
|
|
222
|
-
): void;
|
|
219
|
+
culture: DataTypes.CultureDefinition
|
|
220
|
+
): Promise<DataTypes.StringRecord>;
|
|
223
221
|
|
|
224
222
|
/**
|
|
225
223
|
* Check the action result is about device invalid
|
|
@@ -251,10 +249,7 @@ export interface IApp {
|
|
|
251
249
|
* @param passphrase Secret passphrase
|
|
252
250
|
* @returns Pure text
|
|
253
251
|
*/
|
|
254
|
-
decrypt(
|
|
255
|
-
messageEncrypted: string,
|
|
256
|
-
passphrase?: string
|
|
257
|
-
): Promise<string | undefined>;
|
|
252
|
+
decrypt(messageEncrypted: string, passphrase?: string): string | undefined;
|
|
258
253
|
|
|
259
254
|
/**
|
|
260
255
|
* Enhanced decrypt message
|
|
@@ -267,7 +262,7 @@ export interface IApp {
|
|
|
267
262
|
messageEncrypted: string,
|
|
268
263
|
passphrase?: string,
|
|
269
264
|
durationSeconds?: number
|
|
270
|
-
):
|
|
265
|
+
): string | undefined;
|
|
271
266
|
|
|
272
267
|
/**
|
|
273
268
|
* Detect IP data, call only one time
|
|
@@ -282,11 +277,7 @@ export interface IApp {
|
|
|
282
277
|
* @param iterations Iterations, 1000 times, 1 - 99
|
|
283
278
|
* @returns Result
|
|
284
279
|
*/
|
|
285
|
-
encrypt(
|
|
286
|
-
message: string,
|
|
287
|
-
passphrase?: string,
|
|
288
|
-
iterations?: number
|
|
289
|
-
): Promise<string>;
|
|
280
|
+
encrypt(message: string, passphrase?: string, iterations?: number): string;
|
|
290
281
|
|
|
291
282
|
/**
|
|
292
283
|
* Enhanced encrypt message
|
|
@@ -299,7 +290,7 @@ export interface IApp {
|
|
|
299
290
|
message: string,
|
|
300
291
|
passphrase?: string,
|
|
301
292
|
iterations?: number
|
|
302
|
-
):
|
|
293
|
+
): string;
|
|
303
294
|
|
|
304
295
|
/**
|
|
305
296
|
* Format date to string
|
|
@@ -504,7 +495,7 @@ export interface IApp {
|
|
|
504
495
|
* @param message Message
|
|
505
496
|
* @param passphrase Secret passphrase
|
|
506
497
|
*/
|
|
507
|
-
hash(message: string, passphrase?: string):
|
|
498
|
+
hash(message: string, passphrase?: string): string;
|
|
508
499
|
|
|
509
500
|
/**
|
|
510
501
|
* Hash message Hex, SHA3 or HmacSHA512, 512 as Base64
|
|
@@ -512,7 +503,7 @@ export interface IApp {
|
|
|
512
503
|
* @param message Message
|
|
513
504
|
* @param passphrase Secret passphrase
|
|
514
505
|
*/
|
|
515
|
-
hashHex(message: string, passphrase?: string):
|
|
506
|
+
hashHex(message: string, passphrase?: string): string;
|
|
516
507
|
|
|
517
508
|
/**
|
|
518
509
|
* Check use has the specific role permission or not
|