@etsoo/appscript 1.1.59 → 1.1.60

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.
@@ -113,11 +113,25 @@ export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallP
113
113
  * @param culture New culture definition
114
114
  */
115
115
  changeCulture(culture: DataTypes.CultureDefinition): void;
116
+ /**
117
+ * Decrypt message
118
+ * @param messageEncrypted Encrypted message
119
+ * @param passphrase Secret passphrase
120
+ * @returns Pure text
121
+ */
122
+ decrypt(messageEncrypted: string, passphrase: string): string;
116
123
  /**
117
124
  * Detect IP data, call only one time
118
125
  * @param callback Callback will be called when the IP is ready
119
126
  */
120
127
  detectIP(callback?: IDetectIPCallback): void;
128
+ /**
129
+ * Encrypt message
130
+ * @param message Message
131
+ * @param passphrase Secret passphrase
132
+ * @returns Result
133
+ */
134
+ encrypt(message: string, passphrase: string): string;
121
135
  /**
122
136
  * Format date to string
123
137
  * @param input Input date
@@ -364,12 +378,32 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
364
378
  * @param culture New culture definition
365
379
  */
366
380
  changeCulture(culture: DataTypes.CultureDefinition): void;
381
+ /**
382
+ * Decrypt message
383
+ * @param messageEncrypted Encrypted message
384
+ * @param passphrase Secret passphrase
385
+ * @returns Pure text
386
+ */
387
+ decrypt(messageEncrypted: string, passphrase: string): string;
367
388
  /**
368
389
  * Detect IP data, call only one time
369
390
  * @param callback Callback will be called when the IP is ready
370
391
  */
371
392
  detectIP(callback?: IDetectIPCallback): void;
372
393
  private detectIPCallbacks;
394
+ /**
395
+ * Encrypt message
396
+ * @param message Message
397
+ * @param passphrase Secret passphrase
398
+ * @returns Result
399
+ */
400
+ encrypt(message: string, passphrase: string): string;
401
+ /**
402
+ * Enchance secret passphrase
403
+ * @param passphrase Secret passphrase
404
+ * @returns Enhanced passphrase
405
+ */
406
+ protected encryptionEnhance(passphrase: string): string;
373
407
  /**
374
408
  * Format date to string
375
409
  * @param input Input date
@@ -195,6 +195,15 @@ class CoreApp {
195
195
  region.name = AddressUtils_1.AddressUtils.getRegionLabel(id, this.labelDelegate);
196
196
  });
197
197
  }
198
+ /**
199
+ * Decrypt message
200
+ * @param messageEncrypted Encrypted message
201
+ * @param passphrase Secret passphrase
202
+ * @returns Pure text
203
+ */
204
+ decrypt(messageEncrypted, passphrase) {
205
+ return CryptoJS.AES.decrypt(messageEncrypted, this.encryptionEnhance(passphrase)).toString();
206
+ }
198
207
  /**
199
208
  * Detect IP data, call only one time
200
209
  * @param callback Callback will be called when the IP is ready
@@ -228,6 +237,23 @@ class CoreApp {
228
237
  var _a;
229
238
  (_a = this.ipDetectCallbacks) === null || _a === void 0 ? void 0 : _a.forEach((f) => f());
230
239
  }
240
+ /**
241
+ * Encrypt message
242
+ * @param message Message
243
+ * @param passphrase Secret passphrase
244
+ * @returns Result
245
+ */
246
+ encrypt(message, passphrase) {
247
+ return CryptoJS.AES.encrypt(message, this.encryptionEnhance(passphrase)).toString();
248
+ }
249
+ /**
250
+ * Enchance secret passphrase
251
+ * @param passphrase Secret passphrase
252
+ * @returns Enhanced passphrase
253
+ */
254
+ encryptionEnhance(passphrase) {
255
+ return passphrase;
256
+ }
231
257
  /**
232
258
  * Format date to string
233
259
  * @param input Input date
@@ -113,11 +113,25 @@ export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallP
113
113
  * @param culture New culture definition
114
114
  */
115
115
  changeCulture(culture: DataTypes.CultureDefinition): void;
116
+ /**
117
+ * Decrypt message
118
+ * @param messageEncrypted Encrypted message
119
+ * @param passphrase Secret passphrase
120
+ * @returns Pure text
121
+ */
122
+ decrypt(messageEncrypted: string, passphrase: string): string;
116
123
  /**
117
124
  * Detect IP data, call only one time
118
125
  * @param callback Callback will be called when the IP is ready
119
126
  */
120
127
  detectIP(callback?: IDetectIPCallback): void;
128
+ /**
129
+ * Encrypt message
130
+ * @param message Message
131
+ * @param passphrase Secret passphrase
132
+ * @returns Result
133
+ */
134
+ encrypt(message: string, passphrase: string): string;
121
135
  /**
122
136
  * Format date to string
123
137
  * @param input Input date
@@ -364,12 +378,32 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
364
378
  * @param culture New culture definition
365
379
  */
366
380
  changeCulture(culture: DataTypes.CultureDefinition): void;
381
+ /**
382
+ * Decrypt message
383
+ * @param messageEncrypted Encrypted message
384
+ * @param passphrase Secret passphrase
385
+ * @returns Pure text
386
+ */
387
+ decrypt(messageEncrypted: string, passphrase: string): string;
367
388
  /**
368
389
  * Detect IP data, call only one time
369
390
  * @param callback Callback will be called when the IP is ready
370
391
  */
371
392
  detectIP(callback?: IDetectIPCallback): void;
372
393
  private detectIPCallbacks;
394
+ /**
395
+ * Encrypt message
396
+ * @param message Message
397
+ * @param passphrase Secret passphrase
398
+ * @returns Result
399
+ */
400
+ encrypt(message: string, passphrase: string): string;
401
+ /**
402
+ * Enchance secret passphrase
403
+ * @param passphrase Secret passphrase
404
+ * @returns Enhanced passphrase
405
+ */
406
+ protected encryptionEnhance(passphrase: string): string;
373
407
  /**
374
408
  * Format date to string
375
409
  * @param input Input date
@@ -192,6 +192,15 @@ export class CoreApp {
192
192
  region.name = AddressUtils.getRegionLabel(id, this.labelDelegate);
193
193
  });
194
194
  }
195
+ /**
196
+ * Decrypt message
197
+ * @param messageEncrypted Encrypted message
198
+ * @param passphrase Secret passphrase
199
+ * @returns Pure text
200
+ */
201
+ decrypt(messageEncrypted, passphrase) {
202
+ return CryptoJS.AES.decrypt(messageEncrypted, this.encryptionEnhance(passphrase)).toString();
203
+ }
195
204
  /**
196
205
  * Detect IP data, call only one time
197
206
  * @param callback Callback will be called when the IP is ready
@@ -225,6 +234,23 @@ export class CoreApp {
225
234
  var _a;
226
235
  (_a = this.ipDetectCallbacks) === null || _a === void 0 ? void 0 : _a.forEach((f) => f());
227
236
  }
237
+ /**
238
+ * Encrypt message
239
+ * @param message Message
240
+ * @param passphrase Secret passphrase
241
+ * @returns Result
242
+ */
243
+ encrypt(message, passphrase) {
244
+ return CryptoJS.AES.encrypt(message, this.encryptionEnhance(passphrase)).toString();
245
+ }
246
+ /**
247
+ * Enchance secret passphrase
248
+ * @param passphrase Secret passphrase
249
+ * @returns Enhanced passphrase
250
+ */
251
+ encryptionEnhance(passphrase) {
252
+ return passphrase;
253
+ }
228
254
  /**
229
255
  * Format date to string
230
256
  * @param input Input date
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.1.59",
3
+ "version": "1.1.60",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -54,7 +54,9 @@
54
54
  "dependencies": {
55
55
  "@etsoo/notificationbase": "^1.0.94",
56
56
  "@etsoo/restclient": "^1.0.62",
57
- "@etsoo/shared": "^1.0.75"
57
+ "@etsoo/shared": "^1.0.75",
58
+ "@types/crypto-js": "^4.0.2",
59
+ "crypto-js": "^4.1.1"
58
60
  },
59
61
  "devDependencies": {
60
62
  "@babel/cli": "^7.16.0",
@@ -159,12 +159,28 @@ export interface ICoreApp<
159
159
  */
160
160
  changeCulture(culture: DataTypes.CultureDefinition): void;
161
161
 
162
+ /**
163
+ * Decrypt message
164
+ * @param messageEncrypted Encrypted message
165
+ * @param passphrase Secret passphrase
166
+ * @returns Pure text
167
+ */
168
+ decrypt(messageEncrypted: string, passphrase: string): string;
169
+
162
170
  /**
163
171
  * Detect IP data, call only one time
164
172
  * @param callback Callback will be called when the IP is ready
165
173
  */
166
174
  detectIP(callback?: IDetectIPCallback): void;
167
175
 
176
+ /**
177
+ * Encrypt message
178
+ * @param message Message
179
+ * @param passphrase Secret passphrase
180
+ * @returns Result
181
+ */
182
+ encrypt(message: string, passphrase: string): string;
183
+
168
184
  /**
169
185
  * Format date to string
170
186
  * @param input Input date
@@ -625,6 +641,19 @@ export abstract class CoreApp<
625
641
  });
626
642
  }
627
643
 
644
+ /**
645
+ * Decrypt message
646
+ * @param messageEncrypted Encrypted message
647
+ * @param passphrase Secret passphrase
648
+ * @returns Pure text
649
+ */
650
+ decrypt(messageEncrypted: string, passphrase: string) {
651
+ return CryptoJS.AES.decrypt(
652
+ messageEncrypted,
653
+ this.encryptionEnhance(passphrase)
654
+ ).toString();
655
+ }
656
+
628
657
  /**
629
658
  * Detect IP data, call only one time
630
659
  * @param callback Callback will be called when the IP is ready
@@ -665,6 +694,28 @@ export abstract class CoreApp<
665
694
  this.ipDetectCallbacks?.forEach((f) => f());
666
695
  }
667
696
 
697
+ /**
698
+ * Encrypt message
699
+ * @param message Message
700
+ * @param passphrase Secret passphrase
701
+ * @returns Result
702
+ */
703
+ encrypt(message: string, passphrase: string) {
704
+ return CryptoJS.AES.encrypt(
705
+ message,
706
+ this.encryptionEnhance(passphrase)
707
+ ).toString();
708
+ }
709
+
710
+ /**
711
+ * Enchance secret passphrase
712
+ * @param passphrase Secret passphrase
713
+ * @returns Enhanced passphrase
714
+ */
715
+ protected encryptionEnhance(passphrase: string) {
716
+ return passphrase;
717
+ }
718
+
668
719
  /**
669
720
  * Format date to string
670
721
  * @param input Input date