- Profile
- Bot Telegram - fixed Chip multiselect
This commit is contained in:
@@ -20,10 +20,15 @@ const server_constants = require('./server_constants');
|
||||
// SETTINGS WebPush Configuration
|
||||
const webpush = require('web-push');
|
||||
|
||||
const subject = process.env.URLBASE_APP1; //'mailto:' + process.env.EMAIL_FROM
|
||||
const subject = process.env.URLBASE_APP1;
|
||||
const publicVapidKey = process.env.PUBLIC_VAPI_KEY;
|
||||
const privateVapidKey = process.env.PRIVATE_VAPI_KEY;
|
||||
|
||||
// Code goes here
|
||||
const keySize = 256;
|
||||
const ivSize = 128;
|
||||
const iterations = 100;
|
||||
|
||||
if (process.env.GCM_API_KEY !== "")
|
||||
webpush.setGCMAPIKey(process.env.GCM_API_KEY);
|
||||
|
||||
@@ -34,6 +39,8 @@ webpush.setVapidDetails(subject, publicVapidKey, privateVapidKey);
|
||||
module.exports = {
|
||||
INITDB_FIRSTIME: true,
|
||||
|
||||
LANGADMIN: 'it',
|
||||
|
||||
TYPE_PROJECT: 1,
|
||||
TYPE_TODO: 2,
|
||||
|
||||
@@ -398,6 +405,26 @@ module.exports = {
|
||||
return '';
|
||||
},
|
||||
|
||||
getEmailByIdApp: function (idapp) {
|
||||
const myapp = MYAPPS.find((item) => item.idapp === idapp);
|
||||
return (myapp) ? myapp.email_from : ''
|
||||
},
|
||||
|
||||
getPwdByIdApp: function (idapp) {
|
||||
const myapp = MYAPPS.find((item) => item.idapp === idapp);
|
||||
return (myapp) ? this.decryptdata(myapp.email_pwd) : ''
|
||||
},
|
||||
|
||||
getTelegramBotNameByIdApp: function (idapp) {
|
||||
const myapp = MYAPPS.find((item) => item.idapp === idapp);
|
||||
return (myapp) ? myapp.telegram_bot_name : ''
|
||||
},
|
||||
|
||||
getTelegramKeyByIdApp: function (idapp) {
|
||||
const myapp = MYAPPS.find((item) => item.idapp === idapp);
|
||||
return (myapp) ? myapp.telegram_key : ''
|
||||
},
|
||||
|
||||
getQueryTable(idapp, params) {
|
||||
// console.log('idapp', idapp);
|
||||
// console.table(params);
|
||||
@@ -514,15 +541,60 @@ module.exports = {
|
||||
return CryptoJS.SHA512(mystr, { outputLength: 256 }).toString();
|
||||
},
|
||||
|
||||
encrypt(msg, pass) {
|
||||
var salt = CryptoJS.lib.WordArray.random(128 / 8);
|
||||
|
||||
var key = CryptoJS.PBKDF2(pass, salt, {
|
||||
keySize: keySize / 32,
|
||||
iterations: iterations
|
||||
});
|
||||
|
||||
var iv = CryptoJS.lib.WordArray.random(128 / 8);
|
||||
|
||||
var encrypted = CryptoJS.AES.encrypt(msg, key, {
|
||||
iv: iv,
|
||||
padding: CryptoJS.pad.Pkcs7,
|
||||
mode: CryptoJS.mode.CBC
|
||||
|
||||
});
|
||||
|
||||
// salt, iv will be hex 32 in length
|
||||
// append them to the ciphertext for use in decryption
|
||||
var transitmessage = salt.toString() + iv.toString() + encrypted.toString();
|
||||
return transitmessage;
|
||||
},
|
||||
|
||||
decrypt(transitmessage, pass) {
|
||||
var salt = CryptoJS.enc.Hex.parse(transitmessage.substr(0, 32));
|
||||
var iv = CryptoJS.enc.Hex.parse(transitmessage.substr(32, 32))
|
||||
var encrypted = transitmessage.substring(64);
|
||||
|
||||
var key = CryptoJS.PBKDF2(pass, salt, {
|
||||
keySize: keySize / 32,
|
||||
iterations: iterations
|
||||
});
|
||||
|
||||
var decrypted = CryptoJS.AES.decrypt(encrypted, key, {
|
||||
iv: iv,
|
||||
padding: CryptoJS.pad.Pkcs7,
|
||||
mode: CryptoJS.mode.CBC
|
||||
|
||||
});
|
||||
return decrypted;
|
||||
},
|
||||
|
||||
cryptdata(mydata) {
|
||||
// Encrypt
|
||||
return CryptoJS.AES.encrypt(JSON.stringify(data), process.env.SECRK);
|
||||
//return CryptoJS.AES.encrypt(JSON.stringify(mydata), process.env.SECRK);
|
||||
return this.encrypt(mydata, process.env.SECRK);
|
||||
},
|
||||
|
||||
|
||||
decryptdata(mydatacrypted) {
|
||||
// Decrypt
|
||||
const bytes = CryptoJS.AES.decrypt(mydatacrypted.toString(), process.env.SECRK);
|
||||
return JSON.parse(bytes.toString(CryptoJS.enc.Utf8));
|
||||
// const bytes = CryptoJS.AES.decrypt(mydatacrypted.toString(), process.env.SECRK);
|
||||
// return JSON.parse(bytes.toString(CryptoJS.enc.Utf8));
|
||||
return this.decrypt(mydatacrypted, process.env.SECRK).toString(CryptoJS.enc.Utf8);
|
||||
},
|
||||
|
||||
BoolToInt(mybool) {
|
||||
@@ -575,7 +647,7 @@ module.exports = {
|
||||
|
||||
mkdirpath(dirPath) {
|
||||
// if (!fs.accessSync(dirPath, fs.constants.R_OK | fs.constants.W_OK)) {
|
||||
if (!fs.existsSync(dirPath)){
|
||||
if (!fs.existsSync(dirPath)) {
|
||||
try {
|
||||
fs.mkdirSync(dirPath, { recursive: true });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user