@aakash58/chatbot 1.0.57 → 1.0.58
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/fesm2022/aakash58-chatbot.mjs +54 -3
- package/fesm2022/aakash58-chatbot.mjs.map +1 -1
- package/index.d.ts +14 -1
- package/package.json +1 -1
- package/src/assets/bot.mp3 +0 -0
- package/src/assets/bot.png +0 -0
- package/src/assets/const/app-const.json +0 -8
- package/src/assets/const/app-const.prod.json +0 -8
- package/src/assets/logo.png +0 -0
- package/src/assets/profile.png +0 -0
|
@@ -1398,21 +1398,72 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImpo
|
|
|
1398
1398
|
}]
|
|
1399
1399
|
}], ctorParameters: () => [{ type: HttpService }] });
|
|
1400
1400
|
|
|
1401
|
+
class CryptoHelperService {
|
|
1402
|
+
encoder = new TextEncoder();
|
|
1403
|
+
decoder = new TextDecoder();
|
|
1404
|
+
secretKey = ''; // Will be set by AuthService
|
|
1405
|
+
setSecretKey(key) {
|
|
1406
|
+
this.secretKey = key;
|
|
1407
|
+
}
|
|
1408
|
+
async getKey() {
|
|
1409
|
+
const salt = this.encoder.encode('fixed_salt'); // Keep constant
|
|
1410
|
+
const baseKey = await crypto.subtle.importKey('raw', this.encoder.encode(this.secretKey), 'PBKDF2', false, ['deriveKey']);
|
|
1411
|
+
return crypto.subtle.deriveKey({
|
|
1412
|
+
name: 'PBKDF2',
|
|
1413
|
+
salt,
|
|
1414
|
+
iterations: 100000,
|
|
1415
|
+
hash: 'SHA-256',
|
|
1416
|
+
}, baseKey, { name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt']);
|
|
1417
|
+
}
|
|
1418
|
+
async encrypt(value) {
|
|
1419
|
+
if (!value)
|
|
1420
|
+
return null;
|
|
1421
|
+
const key = await this.getKey();
|
|
1422
|
+
const iv = crypto.getRandomValues(new Uint8Array(12));
|
|
1423
|
+
const encrypted = await crypto.subtle.encrypt({ name: 'AES-GCM', iv }, key, this.encoder.encode(value));
|
|
1424
|
+
const merged = new Uint8Array(iv.length + encrypted.byteLength);
|
|
1425
|
+
merged.set(iv, 0);
|
|
1426
|
+
merged.set(new Uint8Array(encrypted), iv.length);
|
|
1427
|
+
return btoa(String.fromCharCode(...merged));
|
|
1428
|
+
}
|
|
1429
|
+
async decrypt(value) {
|
|
1430
|
+
if (!value)
|
|
1431
|
+
return null;
|
|
1432
|
+
const raw = Uint8Array.from(atob(value), (c) => c.charCodeAt(0));
|
|
1433
|
+
const iv = raw.slice(0, 12);
|
|
1434
|
+
const data = raw.slice(12);
|
|
1435
|
+
const key = await this.getKey();
|
|
1436
|
+
const decrypted = await crypto.subtle.decrypt({ name: 'AES-GCM', iv }, key, data);
|
|
1437
|
+
return this.decoder.decode(decrypted);
|
|
1438
|
+
}
|
|
1439
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: CryptoHelperService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1440
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: CryptoHelperService, providedIn: 'root' });
|
|
1441
|
+
}
|
|
1442
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: CryptoHelperService, decorators: [{
|
|
1443
|
+
type: Injectable,
|
|
1444
|
+
args: [{
|
|
1445
|
+
providedIn: 'root',
|
|
1446
|
+
}]
|
|
1447
|
+
}] });
|
|
1448
|
+
|
|
1401
1449
|
class AuthService {
|
|
1402
1450
|
router;
|
|
1403
1451
|
http;
|
|
1452
|
+
cryptoHelper;
|
|
1404
1453
|
apiUrl;
|
|
1405
1454
|
storageKey;
|
|
1406
1455
|
secretKey;
|
|
1407
1456
|
companyCode;
|
|
1408
1457
|
jwtHelper = new JwtHelperService();
|
|
1409
|
-
constructor(router, http) {
|
|
1458
|
+
constructor(router, http, cryptoHelper) {
|
|
1410
1459
|
this.router = router;
|
|
1411
1460
|
this.http = http;
|
|
1461
|
+
this.cryptoHelper = cryptoHelper;
|
|
1412
1462
|
this.apiUrl = `${AppConst?.data?.apiBaseUrl}${AppConst?.data?.apiSegment}`;
|
|
1413
1463
|
this.storageKey = AppConst?.data?.storageKey;
|
|
1414
1464
|
this.secretKey = AppConst?.data?.secretKey;
|
|
1415
1465
|
this.companyCode = AppConst?.data?.companyCode;
|
|
1466
|
+
this.cryptoHelper.setSecretKey(this.secretKey);
|
|
1416
1467
|
}
|
|
1417
1468
|
logout() {
|
|
1418
1469
|
const url = `${this.apiUrl}Account/Logout`;
|
|
@@ -1528,7 +1579,7 @@ class AuthService {
|
|
|
1528
1579
|
getUserId() {
|
|
1529
1580
|
return this.getLocalStorage('user_id') || 0;
|
|
1530
1581
|
}
|
|
1531
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: AuthService, deps: [{ token: i1$4.Router }, { token: i1$3.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1582
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: AuthService, deps: [{ token: i1$4.Router }, { token: i1$3.HttpClient }, { token: CryptoHelperService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1532
1583
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: AuthService, providedIn: 'root' });
|
|
1533
1584
|
}
|
|
1534
1585
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: AuthService, decorators: [{
|
|
@@ -1536,7 +1587,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImpo
|
|
|
1536
1587
|
args: [{
|
|
1537
1588
|
providedIn: 'root',
|
|
1538
1589
|
}]
|
|
1539
|
-
}], ctorParameters: () => [{ type: i1$4.Router }, { type: i1$3.HttpClient }] });
|
|
1590
|
+
}], ctorParameters: () => [{ type: i1$4.Router }, { type: i1$3.HttpClient }, { type: CryptoHelperService }] });
|
|
1540
1591
|
|
|
1541
1592
|
class Doohbot extends DoohbotInput {
|
|
1542
1593
|
elementRef;
|