Now addon automatically sends wildcard domain in addition to current domain to increase website compatibility

This commit is contained in:
Grégory Soutadé 2014-01-12 10:27:56 +01:00
parent 71b17a1ff0
commit 8a22db95dc
2 changed files with 37 additions and 3 deletions

View File

@ -1,5 +1,5 @@
/* /*
Copyright (C) 2013 Grégory Soutadé Copyright (C) 2013-2014 Grégory Soutadé
This file is part of gPass. This file is part of gPass.
@ -26,7 +26,7 @@ var pkdbf2 = require("pkdbf2").pkdbf2;
var aes = require("jsaes").aes; var aes = require("jsaes").aes;
var parseURI = require("parseuri").parseURI; var parseURI = require("parseuri").parseURI;
var prefSet = require("simple-prefs"); var prefSet = require("simple-prefs");
var DEBUG = false; var DEBUG = true;
// http://stackoverflow.com/questions/3745666/how-to-convert-from-hex-to-ascii-in-javascript // http://stackoverflow.com/questions/3745666/how-to-convert-from-hex-to-ascii-in-javascript
@ -54,6 +54,26 @@ function debug(s)
console.log(s); console.log(s);
} }
function wildcard_domain(domain)
{
parts = domain.split(".");
if (parts.length >= 3)
{
// Seems to be a two level root domain (ie zzz.xxx.co.uk ...)
if (parts[parts.length-2].lenght <= 3)
{
if (parts.length > 3)
return "*" + "." + parts[parts.length-3] + "." + parts[parts.length-2] + "." + parts[parts.length-1];
}
// Standard root domain (zzz.xxx.com)
else
return "*" + "." + parts[parts.length-2] + "." + parts[parts.length-1];
}
return "";
}
function on_sumbit(e) function on_sumbit(e)
{ {
var form = this; var form = this;
@ -62,6 +82,7 @@ function on_sumbit(e)
domain = parseURI.parseUri(form.ownerDocument.baseURI); domain = parseURI.parseUri(form.ownerDocument.baseURI);
domain = domain["host"]; domain = domain["host"];
wdomain = wildcard_domain(domain);
salt = parseURI.parseUri(prefSet.prefs["account_url"]); salt = parseURI.parseUri(prefSet.prefs["account_url"]);
salt = salt["host"] + salt["path"]; salt = salt["host"] + salt["path"];
@ -116,6 +137,19 @@ function on_sumbit(e)
keys += (keys.length != 0) ? "&" : ""; keys += (keys.length != 0) ? "&" : "";
keys += "k" + a + "=" + a2hex(enc); keys += "k" + a + "=" + a2hex(enc);
if (wdomain != "")
{
v = "@@" + wdomain + ";" + logins[a];
debug("will encrypt " + v);
debug("with " + a2hex(mkey));
enc = aes.encryptLongString(v, aes.init(mkey));
aes.finish();
debug("res " + enc);
keys += (keys.length != 0) ? "&" : "";
keys += "k" + a + "=" + a2hex(enc);
}
} }
debug(keys); debug(keys);

View File

@ -5,7 +5,7 @@
"description": "gPass : global password manager", "description": "gPass : global password manager",
"author": "Grégory Soutadé", "author": "Grégory Soutadé",
"license": "GNU GPL v3", "license": "GNU GPL v3",
"version": "0.1", "version": "0.2",
"preferences": [{ "preferences": [{
"name": "account_url", "name": "account_url",
"title": "Account URL", "title": "Account URL",