bug fixes and improvements
This commit is contained in:
@@ -15,14 +15,23 @@ function jappixmini_addon_xor(str1, str2) {
|
||||
}
|
||||
|
||||
function jappixmini_addon_set_client_secret(password) {
|
||||
client_secret = str_sha1("client_secret:"+password);
|
||||
if (!password) return;
|
||||
|
||||
salt1 = "h8doCRekWto0njyQohKpdx6BN0UTyC6N";
|
||||
salt2 = "jdX8OwFC1kWAq3s9uOyAcE8g3UNNO5t3";
|
||||
|
||||
client_secret1 = str_sha1(salt1+password);
|
||||
client_secret2 = str_sha1(salt2+password);
|
||||
client_secret = client_secret1 + client_secret2;
|
||||
|
||||
setDB('jappix-mini', 'client_secret', client_secret);
|
||||
console.log("client secret set");
|
||||
}
|
||||
|
||||
function jappixmini_addon_get_client_secret() {
|
||||
client_secret = getDB('jappix-mini', 'client_secret');
|
||||
if (client_secret===null) {
|
||||
div = $('<div style="position:fixed;padding:1em;background-color:#F00;color:#fff;top:50px;left:50px;" id="x123">Reintroduce your Friendica password for chatting:</div>');
|
||||
div = $('<div style="position:fixed;padding:1em;background-color:#F00;color:#fff;top:50px;left:50px;">Retype your Friendica password for chatting:</div>');
|
||||
div.append($("<br>"));
|
||||
input = $('<input type="password">')
|
||||
div.append(input);
|
||||
@@ -43,7 +52,7 @@ function jappixmini_addon_encrypt_password(password) {
|
||||
client_secret = jappixmini_addon_get_client_secret();
|
||||
|
||||
// add \0 to password until it has the same length as secret
|
||||
if (client_secret.length<password.length) throw "password too long";
|
||||
if (password.length>client_secret.length-1) throw "password too long";
|
||||
while (password.length<client_secret.length) {
|
||||
password += "\0";
|
||||
}
|
||||
@@ -60,7 +69,7 @@ function jappixmini_addon_decrypt_password(encrypted_password) {
|
||||
|
||||
client_secret = jappixmini_addon_get_client_secret();
|
||||
|
||||
// xor encrypted password with secret
|
||||
// xor password with secret
|
||||
password = jappixmini_addon_xor(client_secret, encrypted_password);
|
||||
|
||||
// remove \0
|
||||
@@ -80,12 +89,12 @@ function jappixmini_manage_roster(contacts, autoapprove, autosubscribe) {
|
||||
var xid = bareXID(from);
|
||||
|
||||
approve = true;
|
||||
if ((!autoapprove) || ($.inArray(xid, contacts) == -1))
|
||||
if ((!autoapprove) || contacts[xid]===undefined)
|
||||
approve = confirm("Accept "+xid+" for chat?");
|
||||
|
||||
if (approve) {
|
||||
acceptSubscribe(xid);
|
||||
//alert("Accepted "+xid+" for chat.");
|
||||
acceptSubscribe(xid, contacts[xid]);
|
||||
console.log("Accepted "+xid+" for chat.");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -94,16 +103,18 @@ function jappixmini_manage_roster(contacts, autoapprove, autosubscribe) {
|
||||
for (i=0; i<contacts.length; i++) {
|
||||
xid = contacts[i];
|
||||
sendSubscribe(xid, "subscribe");
|
||||
console.log("Subscribed to "+xid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function jappixmini_addon_start(server, username, bosh, encrypted_password) {
|
||||
function jappixmini_addon_start(server, username, bosh, encrypted_password, nickname) {
|
||||
// check if settings have changed, reinitialize jappix mini if this is the case
|
||||
settings_identifier = str_sha1(server);
|
||||
settings_identifier += str_sha1(username);
|
||||
settings_identifier += str_sha1(bosh);
|
||||
settings_identifier += str_sha1(encrypted_password);
|
||||
settings_identifier += str_sha1(nickname);
|
||||
|
||||
saved_identifier = getDB("jappix-mini", "settings_identifier");
|
||||
if (saved_identifier != settings_identifier) removeDB('jappix-mini', 'dom');
|
||||
@@ -116,5 +127,6 @@ function jappixmini_addon_start(server, username, bosh, encrypted_password) {
|
||||
password = jappixmini_addon_decrypt_password(encrypted_password);
|
||||
|
||||
// start jappix mini
|
||||
MINI_NICKNAME = nickname;
|
||||
launchMini(true, false, server, username, password);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user