mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Removed some aes/sha256 from dependencies on clientside
This commit is contained in:
@@ -68,9 +68,11 @@ var Admin = {
|
||||
|
||||
pass_save: function() {
|
||||
if(!w_p) {
|
||||
emit('password', {password: Crypt.crypt_pass(CryptoJS.SHA256(document.getElementById("password").value).toString()), channel: chan.toLowerCase(), oldpass: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase()))});
|
||||
//emit('password', {password: Crypt.crypt_pass(CryptoJS.SHA256(document.getElementById("password").value).toString()), channel: chan.toLowerCase(), oldpass: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase()))});
|
||||
emit('password', {password: Crypt.crypt_pass(document.getElementById("password").value), channel: chan.toLowerCase(), oldpass: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase()))});
|
||||
} else {
|
||||
emit('password', {password: Crypt.crypt_pass(CryptoJS.SHA256(document.getElementById("password").value).toString()), channel: chan.toLowerCase()});
|
||||
//emit('password', {password: Crypt.crypt_pass(CryptoJS.SHA256(document.getElementById("password").value).toString()), channel: chan.toLowerCase()});
|
||||
emit('password', {password: Crypt.crypt_pass(document.getElementById("password").value), channel: chan.toLowerCase()});
|
||||
}
|
||||
},
|
||||
|
||||
@@ -229,7 +231,9 @@ var Admin = {
|
||||
|
||||
shuffle: function() {
|
||||
if(!offline) {
|
||||
emit('shuffle', {adminpass: adminpass !== undefined ? Crypt.crypt_pass(adminpass) : "", channel: chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true)});
|
||||
var u = Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true);
|
||||
if(u == undefined) u = "";
|
||||
emit('shuffle', {adminpass: adminpass !== undefined ? Crypt.crypt_pass(adminpass) : "", channel: chan.toLowerCase(), pass: embed ? '' : u});
|
||||
} else {
|
||||
for(var x = 0; x < full_playlist.length; x++){
|
||||
var num = Math.floor(Math.random()*1000000);
|
||||
|
||||
@@ -683,7 +683,9 @@ var Channel = {
|
||||
function get_history() {
|
||||
if(socket && socket.id) {
|
||||
var p = Crypt.get_userpass();
|
||||
if(p == undefined) p = "";
|
||||
var c = Crypt.crypt_pass(p, true);
|
||||
if(c == undefined) c = "";
|
||||
socket.emit("get_history", {channel: chan.toLowerCase(), all: false, pass: embed ? '' : c});
|
||||
socket.emit("get_history", {channel: chan.toLowerCase(), all: true, pass: ""});
|
||||
} else {
|
||||
|
||||
@@ -42,7 +42,7 @@ var Crypt = {
|
||||
if(Crypt.getCookie(name) === undefined) {
|
||||
cookie = Crypt.create_cookie(name);
|
||||
}
|
||||
var key = btoa("0103060703080703080701") + btoa("0103060703080703080701");
|
||||
/*var key = btoa("0103060703080703080701") + btoa("0103060703080703080701");
|
||||
key = key.substring(0,32);
|
||||
key = btoa(key);
|
||||
var decrypted = CryptoJS.AES.decrypt(
|
||||
@@ -51,14 +51,15 @@ var Crypt = {
|
||||
mode: CryptoJS.mode.CBC,
|
||||
padding: CryptoJS.pad.Pkcs7
|
||||
}
|
||||
);
|
||||
);*/
|
||||
|
||||
return $.parseJSON(decrypted.toString(CryptoJS.enc.Utf8));
|
||||
//return $.parseJSON(decrypted.toString(CryptoJS.enc.Utf8));
|
||||
return $.parseJSON(atob(cookie));
|
||||
},
|
||||
|
||||
decrypt_pass: function(pass) {
|
||||
if(socket) {
|
||||
var key = btoa(socket.id) + btoa(socket.id);
|
||||
/*var key = btoa(socket.id) + btoa(socket.id);
|
||||
key = key.substring(0,32);
|
||||
key = btoa(key);
|
||||
var decrypted = CryptoJS.AES.decrypt(
|
||||
@@ -68,13 +69,14 @@ var Crypt = {
|
||||
padding: CryptoJS.pad.Pkcs7
|
||||
}
|
||||
);
|
||||
return decrypted.toString(CryptoJS.enc.Utf8);
|
||||
return decrypted.toString(CryptoJS.enc.Utf8);*/
|
||||
return atob(pass);
|
||||
} return false;
|
||||
},
|
||||
|
||||
encrypt: function(json_formated, cookie) {
|
||||
var to_encrypt = JSON.stringify(json_formated);
|
||||
var key = btoa("0103060703080703080701") + btoa("0103060703080703080701");
|
||||
/*var key = btoa("0103060703080703080701") + btoa("0103060703080703080701");
|
||||
key = key.substring(0,32);
|
||||
key = btoa(key);
|
||||
var encrypted = CryptoJS.AES.encrypt(
|
||||
@@ -84,8 +86,8 @@ var Crypt = {
|
||||
mode: CryptoJS.mode.CBC,
|
||||
padding: CryptoJS.pad.Pkcs7
|
||||
}
|
||||
);
|
||||
|
||||
);*/
|
||||
var encrypted = btoa(to_encrypt);
|
||||
var CookieDate = new Date();
|
||||
CookieDate.setFullYear(CookieDate.getFullYear( ) +1);
|
||||
if (location.protocol != "https:"){
|
||||
@@ -120,7 +122,7 @@ var Crypt = {
|
||||
else cookie_object = {passwords: {}};
|
||||
|
||||
var string_it = JSON.stringify(cookie_object);
|
||||
var key = btoa("0103060703080703080701") + btoa("0103060703080703080701");
|
||||
/*var key = btoa("0103060703080703080701") + btoa("0103060703080703080701");
|
||||
key = key.substring(0,32);
|
||||
key = btoa(key);
|
||||
var encrypted = CryptoJS.AES.encrypt(
|
||||
@@ -130,7 +132,8 @@ var Crypt = {
|
||||
mode: CryptoJS.mode.CBC,
|
||||
padding: CryptoJS.pad.Pkcs7
|
||||
}
|
||||
);
|
||||
);*/
|
||||
var encrypted = btoa(string_it);
|
||||
|
||||
var CookieDate = new Date();
|
||||
CookieDate.setFullYear(CookieDate.getFullYear( ) +1);
|
||||
@@ -202,7 +205,7 @@ var Crypt = {
|
||||
},
|
||||
|
||||
crypt_chat_pass: function(pass) {
|
||||
var key = btoa(socket.id) + btoa(socket.id);
|
||||
/*var key = btoa(socket.id) + btoa(socket.id);
|
||||
key = key.substring(0,32);
|
||||
key = btoa(key);
|
||||
var iv = btoa(Crypt.makeiv());
|
||||
@@ -214,9 +217,10 @@ var Crypt = {
|
||||
padding: CryptoJS.pad.Pkcs7,
|
||||
iv: CryptoJS.enc.Base64.parse(iv),
|
||||
}
|
||||
);
|
||||
window.encrypted = encrypted;
|
||||
return encrypted.toString() + "$" + iv;
|
||||
);*/
|
||||
//window.encrypted = encrypted;
|
||||
return btoa(pass);
|
||||
//return encrypted.toString() + "$" + iv;
|
||||
},
|
||||
|
||||
crypt_pass: function(pass, userpass) {
|
||||
@@ -225,7 +229,8 @@ var Crypt = {
|
||||
} else {
|
||||
Crypt.tmp_pass = pass;
|
||||
}
|
||||
return Crypt.crypt_chat_pass(pass);
|
||||
//return Crypt.crypt_chat_pass(pass);
|
||||
return btoa(pass);
|
||||
},
|
||||
|
||||
makeiv: function() {
|
||||
|
||||
@@ -151,8 +151,10 @@ function start_auth() {
|
||||
function emit_list() {
|
||||
var add = "";
|
||||
if(private_channel) add = Crypt.getCookie("_uI") + "_";
|
||||
var p = Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true);
|
||||
if(p == undefined) p = "";
|
||||
if(socket.id) {
|
||||
socket.emit("list", {version: parseInt(localStorage.getItem("VERSION")), channel: add + chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true)});
|
||||
socket.emit("list", {version: parseInt(localStorage.getItem("VERSION")), channel: add + chan.toLowerCase(), pass: embed ? '' : p});
|
||||
} else {
|
||||
setTimeout(function(){
|
||||
emit_list();
|
||||
@@ -346,7 +348,9 @@ function get_list_listener(){
|
||||
socket.on("get_list", function(){
|
||||
var add = "";
|
||||
if(private_channel) add = Crypt.getCookie("_uI") + "_";
|
||||
socket.emit("list", { offline: offline, version: parseInt(localStorage.getItem("VERSION")), channel: add + chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true)});
|
||||
var p = Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true);
|
||||
if(p == undefined) p = "";
|
||||
socket.emit("list", { offline: offline, version: parseInt(localStorage.getItem("VERSION")), channel: add + chan.toLowerCase(), pass: embed ? '' : p});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -557,7 +557,9 @@ var List = {
|
||||
return;
|
||||
}
|
||||
if(!offline || (vote == "del" && (hasadmin && (!w_p && adminpass != "")))){
|
||||
emit('vote', {channel: chan, id: id, type: vote, adminpass: adminpass == "" ? "" : Crypt.crypt_pass(adminpass), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true)});
|
||||
var u = Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true);
|
||||
if(u == undefined) u = "";
|
||||
emit('vote', {channel: chan, id: id, type: vote, adminpass: adminpass == "" ? "" : Crypt.crypt_pass(adminpass), pass: embed ? '' : u});
|
||||
} else {
|
||||
if(vote == "pos"){
|
||||
List.voted_song(id, (new Date()).getTime()/1000);
|
||||
@@ -570,7 +572,9 @@ var List = {
|
||||
|
||||
skip: function(way) {
|
||||
if(!offline){
|
||||
emit('skip', {pass: adminpass == "" ? "" : Crypt.crypt_pass(adminpass), id:video_id, channel: chan.toLowerCase(), userpass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true)});
|
||||
var u = Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true);
|
||||
if(u == undefined) u = "";
|
||||
emit('skip', {pass: adminpass == "" ? "" : Crypt.crypt_pass(adminpass), id:video_id, channel: chan.toLowerCase(), userpass: embed ? '' : u});
|
||||
} else {
|
||||
if(way) {
|
||||
Player.playNext();
|
||||
|
||||
@@ -274,7 +274,9 @@ var Player = {
|
||||
paused = false;
|
||||
|
||||
if(!offline) {
|
||||
socket.emit("end", {id: video_id, channel: chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true)});
|
||||
var u = Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true);
|
||||
if(u == undefined) u = "";
|
||||
socket.emit("end", {id: video_id, channel: chan.toLowerCase(), pass: embed ? '' : u});
|
||||
} else {
|
||||
Player.playNext();
|
||||
}
|
||||
@@ -308,7 +310,9 @@ var Player = {
|
||||
$("#pause").toggleClass("hide");
|
||||
}
|
||||
if((paused || was_stopped) && !offline) {
|
||||
socket.emit('pos', {channel: chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true)});
|
||||
var u = Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true);
|
||||
if(u == undefined) u = "";
|
||||
socket.emit('pos', {channel: chan.toLowerCase(), pass: embed ? '' : u});
|
||||
paused = false;
|
||||
was_stopped = false;
|
||||
}
|
||||
@@ -551,7 +555,9 @@ var Player = {
|
||||
if(!user_auth_started) {
|
||||
if(newState.data == 5 || newState.data == 100 || newState.data == 101 || newState.data == 150) {
|
||||
curr_playing = Player.player.getVideoUrl().replace("https://www.youtube.com/watch?v=", "");
|
||||
emit("skip", {error: newState.data, id: video_id, pass: adminpass == "" ? "" : Crypt.crypt_pass(adminpass), channel: chan.toLowerCase(), userpass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true)});
|
||||
var u = Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true);
|
||||
if(u == undefined) u = "";
|
||||
emit("skip", {error: newState.data, id: video_id, pass: adminpass == "" ? "" : Crypt.crypt_pass(adminpass), channel: chan.toLowerCase(), userpass: embed ? '' : u});
|
||||
|
||||
} else if(video_id !== undefined) {
|
||||
Player.loadVideoById(video_id, duration);
|
||||
@@ -748,7 +754,9 @@ var Player = {
|
||||
|
||||
if(!offline) {
|
||||
Player.player.pauseVideo();
|
||||
socket.emit("end", {id: video_id, channel: chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true)});
|
||||
var u = Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true);
|
||||
if(u == undefined) u = "";
|
||||
socket.emit("end", {id: video_id, channel: chan.toLowerCase(), pass: embed ? '' : u});
|
||||
} else {
|
||||
Player.playNext();
|
||||
}
|
||||
|
||||
@@ -453,7 +453,9 @@ var Search = {
|
||||
List.vote(id, "pos");
|
||||
}
|
||||
} else {
|
||||
emit("add", {id: id, start: start, end: end, title: title, adminpass: adminpass == "" ? "" : Crypt.crypt_pass(adminpass), list: chan.toLowerCase(), duration: duration, playlist: playlist, num: num, total: full_num, pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true)});
|
||||
var u = Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true);
|
||||
if(u == undefined) u = "";
|
||||
emit("add", {id: id, start: start, end: end, title: title, adminpass: adminpass == "" ? "" : Crypt.crypt_pass(adminpass), list: chan.toLowerCase(), duration: duration, playlist: playlist, num: num, total: full_num, pass: embed ? '' : u});
|
||||
}//[id, decodeURIComponent(title), adminpass, duration, playlist]);
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user