1
0
mirror of http://git.whoc.org.uk/git/password-manager.git synced 2024-12-09 02:25:31 +01:00

First release of /delta version

This commit is contained in:
Giulio Cesare Solaroli 2013-08-30 17:56:53 +02:00
parent bde3c7b985
commit 20bea94ab6
131 changed files with 59632 additions and 79 deletions

View File

@ -109,12 +109,10 @@ Once the index.html files have been built (one for each frontend) and a backend
The POG interface will allow also a very basic access to the DB data that may be useful to check that the application is actually writing something on the DB (even if you will not be able to make much sense out of the data you will see, as they are all encrypted!)
More information about building the PHP backend may be found in the `doc/install.php.txt` file.
But if you have setup a $configuration['setup_password'] in target/php/configuration.php then a page with a textfield and a "Submit" link will appear.
Just input your $configuration['setup_password'] value and click on "Submit" so [POG][pog] setup page will appear.
## Disclaimer
This application has not been fully tested, so there may be still problems due to the new build script or to the new repository structure. So, for the moment, **use it at your own risk!**
[pog]: http://www.phpobjectgenerator.com/
[pog]: http://www.phpobjectgenerator.com/

View File

@ -1,4 +1,5 @@
{
"request.path": "json",
"request.path": "../json",
"dump.path": "/../dump",
"should.pay.toll": "true"
}

View File

@ -1,4 +1,5 @@
{
"request.path": "json",
"request.path": "../json",
"dump.path": "/../dump",
"should.pay.toll": "true"
}

View File

@ -1,4 +1,5 @@
{
"request.path": "index.php",
"request.path": "../index.php",
"dump.path": "/../dump.php",
"should.pay.toll": "false"
}

View File

@ -1,4 +1,5 @@
{
"request.path": "clipperz.py",
"request.path": "../clipperz.py",
"dump.path": "/../clipperz.py",
"should.pay.toll": "false"
}

View File

@ -15,7 +15,7 @@
<script>
Clipperz_IEisBroken = false;
Clipperz_normalizedNewLine = '\n';
Clipperz_dumpUrl = "/../dump/";
Clipperz_dumpUrl = "@dump.path@";
</script>
<!--[if IE]><script>
@ -67,12 +67,22 @@ Clipperz_normalizedNewLine = '\x0d\x0a';
<div id="main">
<h3 class="loading">loading ...</h3>
<!-- script>
_clipperz_pm_test_user = 'joe'
_clipperz_pm_test_passphrase = 'clipperz'
</script -->
@js_EMBEDDED@
<script>
Clipperz.PM.Proxy.defaultProxy = new Clipperz.PM.Proxy.JSON({'url':'@request.path@', 'shouldPayTolls':@should.pay.toll@});
/*offline_data_placeholder*/
/* * /
MochiKit.DOM.addLoadEvent(function () {
Clipperz.Crypto.PRNG.defaultRandomGenerator().fastEntropyAccumulationForTestingPurpose();
});
/ * */
</script>
<div id="javaScriptAlert">
@ -84,8 +94,8 @@ Clipperz_normalizedNewLine = '\x0d\x0a';
</div>
<div id="footer">
Copyright &copy; 2008-2013 Clipperz Srl -
<a href="http://www.clipperz.com/terms_of_service" target="black">Terms of service</a> -
<a href="http://www.clipperz.com/privacy_policy" target="black">Privacy policy</a>
<a href="https://www.clipperz.com/terms_service/" target="black">Terms of service</a> -
<a href="https://www.clipperz.com/privacy_policy/" target="black">Privacy policy</a>
&nbsp;-&nbsp;
Application version: <a href="https://github.com/clipperz/password-manager/tree/@application.version@" target="github">@application.version@</a>
</div>

1353
frontend/delta/css/web.css Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,707 @@
/*
Copyright 2008-2013 Clipperz Srl
This file is part of Clipperz, the online password manager.
For further information about its features and functionalities please
refer to http://www.clipperz.com.
* Clipperz is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
* Clipperz is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public
License along with Clipperz. If not, see http://www.gnu.org/licenses/.
*/
//Clipperz.Async = MochiKit.Async;
if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
if (typeof(Clipperz.Async) == 'undefined') { Clipperz.Async = {}; }
Clipperz.Async.VERSION = "0.1";
Clipperz.Async.NAME = "Clipperz.Async";
Clipperz.Async.Deferred = function(aName, args) {
args = args || {};
Clipperz.Async.Deferred.superclass.constructor.call(this, args.canceller);
this._args = args;
this._name = aName || "Anonymous deferred";
this._count = 0;
this._shouldTrace = ((CLIPPERZ_DEFERRED_TRACING_ENABLED === true) || (args.trace === true));
this._vars = null;
return this;
}
//=============================================================================
Clipperz.Base.extend(Clipperz.Async.Deferred, MochiKit.Async.Deferred, {
'name': function () {
return this._name;
},
'args': function () {
return this._args;
},
//-----------------------------------------------------------------------------
'callback': function (aValue) {
if (this._shouldTrace) {
Clipperz.log("CALLBACK " + this._name, aValue);
}
if (this.chained == false) {
var message;
message = "ERROR [" + this._name + "]";
this.addErrback(function(aResult) {
if (! (aResult instanceof MochiKit.Async.CancelledError)) {
Clipperz.log(message, aResult);
}
return aResult;
});
if (this._shouldTrace) {
var resultMessage;
resultMessage = "RESULT " + this._name + " <==";
// this.addCallback(function(aResult) {
Clipperz.Async.Deferred.superclass.addCallback.call(this, function(aResult) {
Clipperz.log(resultMessage, aResult);
return aResult;
});
}
}
if (CLIPPERZ_DEFERRED_CALL_LOGGING_ENABLED === true) {
Clipperz.log("callback " + this._name, this);
}
return Clipperz.Async.Deferred.superclass.callback.apply(this, arguments);
},
//-----------------------------------------------------------------------------
'addCallback': function () {
var message;
if (this._shouldTrace) {
this._count ++;
message = "[" + this._count + "] " + this._name + " ";
// this.addBoth(function(aResult) {Clipperz.log(message + "-->", aResult); return aResult;});
this.addCallbacks(
function(aResult) {Clipperz.log("-OK- " + message + "-->"/*, aResult*/); return aResult;},
function(aResult) {Clipperz.log("FAIL " + message + "-->"/*, aResult*/); return aResult;}
);
}
Clipperz.Async.Deferred.superclass.addCallback.apply(this, arguments);
if (this._shouldTrace) {
// this.addBoth(function(aResult) {Clipperz.log(message + "<--", aResult); return aResult;});
this.addCallbacks(
function(aResult) {Clipperz.log("-OK- " + message + "<--", aResult); return aResult;},
function(aResult) {Clipperz.log("FAIL " + message + "<--", aResult); return aResult;}
);
}
},
//=============================================================================
'addCallbackPass': function() {
var passFunction;
passFunction = MochiKit.Base.partial.apply(null, arguments);
this.addCallback(function() {
var result;
result = arguments[arguments.length -1];
passFunction();
return result;
});
},
//-----------------------------------------------------------------------------
'addErrbackPass': function() {
var passFunction;
passFunction = MochiKit.Base.partial.apply(null, arguments);
this.addErrback(function() {
var result;
result = arguments[arguments.length -1];
passFunction();
return result;
});
},
//-----------------------------------------------------------------------------
'addBothPass': function() {
var passFunction;
passFunction = MochiKit.Base.partial.apply(null, arguments);
this.addBoth(function() {
var result;
result = arguments[arguments.length -1];
passFunction();
return result;
});
},
//-----------------------------------------------------------------------------
'addIf': function (aThenBlock, anElseBlock) {
this.addCallback(MochiKit.Base.bind(function (aValue) {
var deferredResult;
if (!MochiKit.Base.isUndefinedOrNull(aValue) && aValue) {
deferredResult = Clipperz.Async.callbacks(this._name + " <then>", aThenBlock, null, aValue);
} else {
deferredResult = Clipperz.Async.callbacks(this._name + " <else>", anElseBlock, null, aValue);
}
return deferredResult;
}))
},
//-----------------------------------------------------------------------------
'addMethod': function () {
this.addCallback(MochiKit.Base.method.apply(this, arguments));
},
//-----------------------------------------------------------------------------
'addMethodcaller': function () {
this.addCallback(MochiKit.Base.methodcaller.apply(this, arguments));
},
//=============================================================================
'addLog': function (aLog) {
if (CLIPPERZ_DEFERRED_LOGGING_ENABLED) {
this.addBothPass(function(res) {Clipperz.log(aLog + " ", res);});
}
},
//=============================================================================
'acquireLock': function (aLock) {
// this.addCallback(function (aResult) {
// return Clipperz.Async.callbacks("Clipperz.Async.acquireLock", [
// MochiKit.Base.method(aLock, 'acquire'),
// MochiKit.Base.partial(MochiKit.Async.succeed, aResult)
// ], {trace:false});
// });
this.addCallback(MochiKit.Base.method(aLock, 'acquire'));
},
'releaseLock': function (aLock) {
// this.addCallback(function (aResult) {
// return Clipperz.Async.callbacks("Clipperz.Async.release <ok>", [
// MochiKit.Base.method(aLock, 'release'),
// MochiKit.Base.partial(MochiKit.Async.succeed, aResult)
// ], {trace:false});
// });
// this.addErrback(function (aResult) {
///Clipperz.log("releaseLock.addErrback:", aResult);
// return Clipperz.Async.callbacks("Clipperz.Async.release <fail>", [
// MochiKit.Base.method(aLock, 'release'),
// MochiKit.Base.partial(MochiKit.Async.fail, aResult)
// ], {trace:false});
// });
// this.addBothPass(MochiKit.Base.method(aLock, 'release'));
this.addCallbackPass(MochiKit.Base.method(aLock, 'release'));
this.addErrback(function (anError) {
aLock.release();
return anError;
});
},
//=============================================================================
'collectResults': function (someRequests) {
this.addCallback(Clipperz.Async.collectResults(this._name + " <collect results>", someRequests, this._args));
},
'addCallbackList': function (aRequestList) {
this.addCallback(Clipperz.Async.callbacks, this._name + " <callback list>", aRequestList, this._args);
},
//=============================================================================
'vars': function () {
if (this._vars == null) {
this._vars = {}
}
return this._vars;
},
'setValue': function (aKey) {
this.addCallback(MochiKit.Base.bind(function (aValue) {
this.vars()[aKey] = aValue;
return aValue;
}, this));
},
'getValue': function (aKey) {
this.addCallback(MochiKit.Base.bind(function () {
return this.vars()[aKey];
}, this));
},
//=============================================================================
'wait': function (someSeconds) {
this.addCallback(MochiKit.Async.wait, someSeconds);
},
//=============================================================================
__syntaxFix__: "syntax fix"
});
//#############################################################################
Clipperz.Async.DeferredSynchronizer = function(aName, someMethods) {
this._name = aName || "Anonymous deferred Synchronizer";
this._methods = someMethods;
this._numberOfMethodsDone = 0;
this._methodResults = [];
this._result = new Clipperz.Async.Deferred("Clipperz.Async.DeferredSynchronizer # " + this.name(), {trace:false});
this._result.addMethod(this, 'methodResults');
this._result.addCallback(function(someResults) {
var cancels;
var errors;
var result;
cancels = MochiKit.Base.filter(function(aResult) { return (aResult instanceof MochiKit.Async.CancelledError)}, someResults);
if (cancels.length == 0) {
errors = MochiKit.Base.filter(function(aResult) { return (aResult instanceof Error)}, someResults);
if (errors.length == 0) {
// result = MochiKit.Async.succeed(someResults);
result = someResults;
} else {
result = MochiKit.Async.fail(someResults);
}
} else {
result = MochiKit.Async.fail(cancels[0]);
}
return result;
}/*, this._methodResults */);
return this;
}
MochiKit.Base.update(Clipperz.Async.DeferredSynchronizer.prototype, {
//-----------------------------------------------------------------------------
'name': function() {
return this._name;
},
//-----------------------------------------------------------------------------
'methods': function() {
return this._methods;
},
'methodResults': function() {
return this._methodResults;
},
//-----------------------------------------------------------------------------
'result': function() {
return this._result;
},
//-----------------------------------------------------------------------------
'numberOfMethodsDone':function() {
return this._numberOfMethodsDone;
},
'incrementNumberOfMethodsDone': function() {
this._numberOfMethodsDone ++;
},
//-----------------------------------------------------------------------------
'run': function(args, aValue) {
var deferredResults;
var i, c;
deferredResults = [];
args = args || {};
c = this.methods().length;
for (i=0; i<c; i++) {
var deferredResult;
var methodCalls;
var ii, cc;
//Clipperz.log("TYPEOF", typeof(this.methods()[i]));
if (typeof(this.methods()[i]) == 'function') {
methodCalls = [ this.methods()[i] ];
} else {
methodCalls = this.methods()[i];
}
cc = methodCalls.length;
deferredResult = new Clipperz.Async.Deferred("Clipperz.Async.DeferredSynchronizer.run => " + this.name() + "[" + i + "]", args);
for (ii=0; ii<cc; ii++) {
deferredResult.addCallback(methodCalls[ii]);
}
deferredResult.addBoth(MochiKit.Base.method(this, 'handleMethodCallDone', i));
deferredResults.push(deferredResult);
}
for (i=0; i<c; i++) {
deferredResults[i].callback(aValue);
}
return this.result();
},
//-----------------------------------------------------------------------------
'handleMethodCallDone': function(anIndexValue, aResult) {
this.incrementNumberOfMethodsDone();
this.methodResults()[anIndexValue] = aResult;
if (this.numberOfMethodsDone() < this.methods().length) {
// nothing to do here other than possibly log something
} else if (this.numberOfMethodsDone() == this.methods().length) {
this.result().callback();
} else if (this.numberOfMethodsDone() > this.methods().length) {
alert("Clipperz.Async.Deferred.handleMethodCallDone -> WTF!");
// WTF!!! :(
}
},
//-----------------------------------------------------------------------------
__syntaxFix__: "syntax fix"
});
//#############################################################################
MochiKit.Base.update(Clipperz.Async, {
'callbacks': function (aName, someFunctions, someArguments, aCallbackValue) {
var deferredResult;
var i, c;
deferredResult = new Clipperz.Async.Deferred(aName, someArguments);
c = someFunctions.length;
for (i=0; i<c; i++) {
deferredResult.addCallback(someFunctions[i]);
}
deferredResult.callback(aCallbackValue);
return deferredResult;
},
//-------------------------------------------------------------------------
'forkAndJoin': function (aName, someMethods, args) {
return MochiKit.Base.partial(function (aName, someMethods, args, aValue) {
var synchronizer;
var result;
args = args || {};
synchronizer = new Clipperz.Async.DeferredSynchronizer(aName, someMethods);
result = synchronizer.run(args, aValue);
return result;
}, aName, someMethods, args);
},
//-------------------------------------------------------------------------
'collectResults': function(aName, someRequests, args) {
return MochiKit.Base.partial(function(aName, someRequests, args, aValue) {
var deferredResult;
var requestKeys;
var methods;
requestKeys = MochiKit.Base.keys(someRequests);
methods = MochiKit.Base.values(someRequests);
deferredResult = new Clipperz.Async.Deferred(aName, args);
deferredResult.addCallback(Clipperz.Async.forkAndJoin(aName + " [inner forkAndJoin]", methods, args));
deferredResult.addBoth(function(someResults) {
var returnFunction;
var results;
var i,c;
var result;
if (someResults instanceof MochiKit.Async.CancelledError) {
returnFunction = MochiKit.Async.fail;
result = someResults;
} else {
if (someResults instanceof Error) {
returnFunction = MochiKit.Async.fail;
results = someResults['message'];
} else {
returnFunction = MochiKit.Async.succeed;
results = someResults;
}
result = {};
c = requestKeys.length;
for (i=0; i<c; i++) {
result[requestKeys[i]] = results[i];
}
}
return returnFunction.call(null, result);
});
deferredResult.callback(aValue);
return deferredResult;
}, aName, someRequests, args);
},
//-------------------------------------------------------------------------
'collectAll': function (someDeferredObjects) {
var deferredResult;
deferredResult = new MochiKit.Async.DeferredList(someDeferredObjects, false, false, false);
deferredResult.addCallback(function (aResultList) {
return MochiKit.Base.map(function (aResult) {
if (aResult[0]) {
return aResult[1];
} else {
throw aResult[1];
}
}, aResultList);
});
return deferredResult;
},
//-------------------------------------------------------------------------
'setItem': function (anObject, aKey, aValue) {
anObject[aKey] = aValue;
return anObject;
},
'setItemOnObject': function (aKey, aValue, anObject) {
anObject[aKey] = aValue;
return anObject;
},
'setDeferredItemOnObject': function (aKey, aDeferredFunction, anObject) {
return Clipperz.Async.callbacks("Clipperz.Async.setDeferredItemOnObject", [
aDeferredFunction,
MochiKit.Base.partial(Clipperz.Async.setItem, anObject, aKey)
], {trace:false}, anObject);
},
//-------------------------------------------------------------------------
'deferredIf': function (aName, aThenBlock, anElseBlock) {
return function (aValue) {
var deferredResult;
if (!MochiKit.Base.isUndefinedOrNull(aValue) && aValue) {
deferredResult = Clipperz.Async.callbacks(aName + " <then>", aThenBlock, null, aValue);
} else {
deferredResult = Clipperz.Async.callbacks(aName + " <else>", anElseBlock, null, aValue);
}
return deferredResult;
}
},
//-------------------------------------------------------------------------
'log': function(aMessage, aResult) {
if (CLIPPERZ_DEFERRED_LOGGING_ENABLED) {
Clipperz.log(aMessage + " ", aResult);
}
return aResult;
},
//=========================================================================
'deferredCompare': function (aComparator, aDeferred, bDeferred) {
var deferredResult;
deferredResult = new Clipperz.Async.Deferred("Clipperz.Async.deferredCompare", {trace:false});
deferredResult.addCallback(Clipperz.Async.collectAll, [aDeferred, bDeferred]);
deferredResult.addCallback(function (someResults) {
var result;
if (aComparator(someResults[0], someResults[1]) > 0) {
result = MochiKit.Async.succeed();
} else {
result = MochiKit.Async.fail();
};
return result;
});
deferredResult.callback();
return deferredResult;
},
//-------------------------------------------------------------------------
'insertIntoSortedArray': function (anObject, aDeferredComparator, aSortedResult) {
var deferredResult;
var i, c;
if (aSortedResult.length == 0) {
deferredResult = MochiKit.Async.succeed([anObject]);
} else {
deferredResult = new Clipperz.Async.Deferred("Clipperz.Async.insertIntoSortedArray", {trace:false});
c = aSortedResult.length + 1;
for (i=0; i<c; i++) {
deferredResult.addCallback(function (aDeferredComparator, aObject, bObject, aContext) {
var innerDeferredResult;
innerDeferredResult = new Clipperz.Async.Deferred("Clipperz.Async.insertIntoSortedArray <inner compare>", {trace:false});
innerDeferredResult.addCallback(aDeferredComparator, aObject, bObject);
innerDeferredResult.addErrback(MochiKit.Async.fail, aContext);
innerDeferredResult.callback();
return innerDeferredResult;
}, aDeferredComparator, anObject, aSortedResult[i], i);
}
deferredResult.addMethod(aSortedResult, 'push', anObject);
deferredResult.addErrback(function (anError) {
aSortedResult.splice(anError.message, 0, anObject);
})
deferredResult.addBoth(MochiKit.Async.succeed, aSortedResult);
deferredResult.callback();
}
return deferredResult;
},
//-------------------------------------------------------------------------
'deferredSort': function (aDeferredComparator, someObjects) {
var deferredResult;
var i, c;
deferredResult = new Clipperz.Async.Deferred("Clipperz.Async.deferredSort", {trace:false});
c = someObjects.length;
for (i=0; i<c; i++) {
deferredResult.addCallback(Clipperz.Async.insertIntoSortedArray, someObjects[i], aDeferredComparator);
if ((i % 50) == 0) {
// Clipperz.log("######### sort wait ##########");
deferredResult.addCallback(MochiKit.Async.wait, 0.5);
}
}
deferredResult.callback([]);
return deferredResult;
},
//=========================================================================
'deferredFilter': function (aFunction, someObjects) {
var deferredResult;
var i, c;
deferredResult = new Clipperz.Async.Deferred("Clipperz.Async.deferredFilter", {trace:false});
c = someObjects.length;
for (i=0; i<c; i++) {
deferredResult.addCallback(function (aFunction, anObject, anIndex, aResult) {
var innerDeferredResult;
innerDeferredResult = new Clipperz.Async.Deferred("Clipperz.Async.deferredFilter <inner - " + anIndex + ">", {trace:false});
innerDeferredResult.addCallback(aFunction, anObject);
innerDeferredResult.addCallback(function (aFilterResult) {
if (aFilterResult) {
aResult.push(anObject);
};
});
innerDeferredResult.addBoth(MochiKit.Async.succeed, aResult);
innerDeferredResult.callback();
return innerDeferredResult;
}, aFunction, someObjects[i], i);
}
deferredResult.callback([]);
return deferredResult;
},
'forEach': function (aFunction) {
return MochiKit.Base.partial(function (aFunction, anIterable) {
MochiKit.Iter.forEach(anIterable, aFunction);
}, aFunction);
},
//=========================================================================
'or': function (someValues) {
return Clipperz.Async.callbacks("Clipperz.Async.or", [
MochiKit.Base.values,
MochiKit.Base.flattenArguments,
//function (aValue) { Clipperz.log("Record.hasAnyCleanTextData - flatten", aValue); return aValue; },
function(someInnerValues) {
return MochiKit.Iter.some(someInnerValues, MochiKit.Base.operator.identity);
}
], {trace:false}, someValues);
},
//=========================================================================
'clearResult': function () {},
//=========================================================================
__syntaxFix__: "syntax fix"
});
//#############################################################################
CLIPPERZ_DEFERRED_LOGGING_ENABLED = true;
CLIPPERZ_DEFERRED_TRACING_ENABLED = false;
CLIPPERZ_DEFERRED_CALL_LOGGING_ENABLED = false;

View File

@ -0,0 +1,514 @@
/*
Copyright 2008-2013 Clipperz Srl
This file is part of Clipperz, the online password manager.
For further information about its features and functionalities please
refer to http://www.clipperz.com.
* Clipperz is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
* Clipperz is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public
License along with Clipperz. If not, see http://www.gnu.org/licenses/.
*/
if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
if (typeof(Clipperz.Base) == 'undefined') { Clipperz.Base = {}; }
Clipperz.Base.VERSION = "0.2";
Clipperz.Base.NAME = "Clipperz.Base";
MochiKit.Base.update(Clipperz.Base, {
//-------------------------------------------------------------------------
'__repr__': function () {
return "[" + this.NAME + " " + this.VERSION + "]";
},
//-------------------------------------------------------------------------
'toString': function () {
return this.__repr__();
},
//-------------------------------------------------------------------------
'itemgetter': function (aKeyPath) {
// return MochiKit.Base.compose.apply(null, [MochiKit.Base.itemgetter('key3')]);
return MochiKit.Base.compose.apply(null,
MochiKit.Base.map(
MochiKit.Base.itemgetter,
MochiKit.Iter.reversed(
aKeyPath.split('.')
)
)
);
},
//-------------------------------------------------------------------------
'isUrl': function (aValue) {
return (MochiKit.Base.urlRegExp.test(aValue));
},
'isEmail': function (aValue) {
return (MochiKit.Base.emailRegExp.test(aValue));
},
//-------------------------------------------------------------------------
'caseInsensitiveCompare': function (a, b) {
return MochiKit.Base.compare(a.toLowerCase(), b.toLowerCase());
},
'reverseComparator': function (aComparator) {
return MochiKit.Base.compose(function(aResult) { return -aResult; }, aComparator);
},
'caseInsensitiveKeyComparator': function (aKey) {
return function (a, b) {
return MochiKit.Base.compare(a[aKey].toLowerCase(), b[aKey].toLowerCase());
}
},
//-------------------------------------------------------------------------
/*
'dependsOn': function(module, deps) {
if (!(module in Clipperz)) {
MochiKit[module] = {};
}
if (typeof(dojo) != 'undefined') {
dojo.provide('Clipperz.' + module);
}
for (var i = 0; i < deps.length; i++) {
if (typeof(dojo) != 'undefined') {
dojo.require('Clipperz.' + deps[i]);
}
if (typeof(JSAN) != 'undefined') {
JSAN.use('Clipperz.' + deps[i], []);
}
if (!(deps[i] in Clipperz)) {
throw 'Clipperz.' + module + ' depends on Clipperz.' + deps[i] + '!'
}
}
},
*/
//-------------------------------------------------------------------------
'trim': function (aValue) {
return aValue.replace(/^\s+|\s+$/g, "");
},
//-------------------------------------------------------------------------
'stringToByteArray': function (aValue) {
var result;
var i, c;
result = [];
c = aValue.length;
for (i=0; i<c; i++) {
result[i] = aValue.charCodeAt(i);
}
return result;
},
//.........................................................................
'byteArrayToString': function (anArrayOfBytes) {
var result;
var i, c;
result = "";
c = anArrayOfBytes.length;
for (i=0; i<c; i++) {
result += String.fromCharCode(anArrayOfBytes[i]);
}
return result;
},
//-------------------------------------------------------------------------
'getValueForKeyInFormContent': function (aFormContent, aKey) {
return aFormContent[1][MochiKit.Base.find(aFormContent[0], aKey)];
},
//-------------------------------------------------------------------------
'indexOfObjectInArray': function(anObject, anArray) {
var result;
var i, c;
result = -1;
c = anArray.length;
for (i=0; ((i<c) && (result < 0)); i++) {
if (anArray[i] === anObject) {
result = i;
}
}
return result;
},
//-------------------------------------------------------------------------
'removeObjectAtIndexFromArray': function(anIndex, anArray) {
anArray.splice(anIndex, 1);
},
//-------------------------------------------------------------------------
'removeObjectFromArray': function(anObject, anArray) {
var objectIndex;
objectIndex = Clipperz.Base.indexOfObjectInArray(anObject, anArray);
if (objectIndex > -1) {
Clipperz.Base.removeObjectAtIndexFromArray(objectIndex, anArray);
} else {
Clipperz.log("Trying to remove an object not present in the array");
throw Clipperz.Base.exception.ObjectNotFound;
}
},
'removeFromArray': function(anArray, anObject) {
return Clipperz.Base.removeObjectFromArray(anObject, anArray);
},
//-------------------------------------------------------------------------
'splitStringAtFixedTokenSize': function(aString, aTokenSize) {
var result;
var stringToProcess;
stringToProcess = aString;
result = [];
if (stringToProcess != null) {
while (stringToProcess.length > aTokenSize) {
result.push(stringToProcess.substring(0, aTokenSize));
stringToProcess = stringToProcess.substring(aTokenSize);
}
result.push(stringToProcess);
}
return result;
},
//-------------------------------------------------------------------------
'objectType': function(anObject) {
var result;
if (anObject == null) {
result = null;
} else {
result = typeof(anObject);
if (result == "object") {
if (anObject instanceof Array) {
result = 'array'
} else if (anObject.constructor == Boolean) {
result = 'boolean'
} else if (anObject instanceof Date) {
result = 'date'
} else if (anObject instanceof Error) {
result = 'error'
} else if (anObject instanceof Function) {
result = 'function'
} else if (anObject.constructor == Number) {
result = 'number'
} else if (anObject.constructor == String) {
result = 'string'
} else if (anObject instanceof Object) {
result = 'object'
} else {
throw Clipperz.Base.exception.UnknownType;
}
}
}
return result;
},
//-------------------------------------------------------------------------
'escapeHTML': function(aValue) {
var result;
result = aValue;
result = result.replace(/</g, "&lt;");
result = result.replace(/>/g, "&gt;");
return result;
},
//-------------------------------------------------------------------------
'deepClone': function(anObject) {
var result;
result = Clipperz.Base.evalJSON(Clipperz.Base.serializeJSON(anObject));
return result;
},
//-------------------------------------------------------------------------
// 'deepCompare': function (aObject, bObject) {
// return (Clipperz.Base.serializeJSON(aObject) == Clipperz.Base.serializeJSON(bObject));
// },
//-------------------------------------------------------------------------
'evalJSON': function(aString) {
return JSON.parse(aString);
},
'serializeJSON': function(anObject) {
return JSON.stringify(anObject);
},
'formatJSON': function (anObject, sIndent) {
var realTypeOf = function (v) {
if (typeof(v) == "object") {
if (v === null) return "null";
if (v.constructor == (new Array).constructor) return "array";
if (v.constructor == (new Date).constructor) return "date";
if (v.constructor == (new RegExp).constructor) return "regex";
return "object";
}
return typeof(v);
};
// function FormatJSON(oData, sIndent) {
if (arguments.length < 2) {
var sIndent = "";
}
// var sIndentStyle = " ";
var sIndentStyle = " ";
var sDataType = realTypeOf(anObject);
// open object
if (sDataType == "array") {
if (anObject.length == 0) {
return "[]";
}
var sHTML = "[";
} else if (sDataType == "object") {
var sHTML = "{";
} else {
return "{}";
}
// } else {
// var iCount = 0;
// $.each(anObject, function() {
// iCount++;
// return;
// });
// if (iCount == 0) { // object is empty
// return "{}";
// }
// var sHTML = "{";
// }
// loop through items
var iCount = 0;
// $.each(anObject, function(sKey, vValue) {
MochiKit.Iter.forEach(MochiKit.Base.keys(anObject), function(sKey) {
var vValue = anObject[sKey];
if (iCount > 0) {
sHTML += ",";
}
if (sDataType == "array") {
sHTML += ("\n" + sIndent + sIndentStyle);
} else {
sHTML += ("\n" + sIndent + sIndentStyle + "\"" + sKey + "\"" + ": ");
}
// display relevant data type
switch (realTypeOf(vValue)) {
case "array":
case "object":
sHTML += Clipperz.Base.formatJSON(vValue, (sIndent + sIndentStyle));
break;
case "boolean":
case "number":
sHTML += vValue.toString();
break;
case "null":
sHTML += "null";
break;
case "string":
sHTML += ("\"" + vValue + "\"");
break;
default:
sHTML += ("TYPEOF: " + typeof(vValue));
}
// loop
iCount++;
});
// close object
if (sDataType == "array") {
sHTML += ("\n" + sIndent + "]");
} else {
sHTML += ("\n" + sIndent + "}");
}
// return
return sHTML;
},
//-------------------------------------------------------------------------
'mergeItems': function (anArrayOfValues) {
var result;
var i, c;
result = {};
c = anArrayOfValues.length;
for (i=0; i<c; i++) {
result[anArrayOfValues[i][0]] = anArrayOfValues[i][1];
}
return result;
},
//-------------------------------------------------------------------------
'map': function (fn, lstObj/*, lst... */) {
var result;
if (MochiKit.Base.isArrayLike(lstObj)) {
result = MochiKit.Base.map.apply(this, arguments);
} else {
var keys;
var values;
var computedValues;
keys = MochiKit.Base.keys(lstObj);
values = MochiKit.Base.values(lstObj);
computedValues = MochiKit.Base.map(fn, values);
result = Clipperz.Base.mergeItems(MochiKit.Base.zip(keys, computedValues));
}
return result;
},
//-------------------------------------------------------------------------
'sanitizeString': function(aValue) {
var result;
if (Clipperz.Base.objectType(aValue) == 'string') {
result = aValue;
result = result.replace(/</img,"&lt;");
result = result.replace(/>/img,"&gt;");
} else {
result = aValue;
}
return result;
},
//-------------------------------------------------------------------------
'module': function(aValue) {
// aValue = 'Clipperz.PM.Compact'
//
// if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
// if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
// if (typeof(Clipperz.PM.UI.Common.Components) == 'undefined') { Clipperz.PM.UI.Common.Components = {}; }
var currentScope;
var pathElements;
var i,c;
currentScope = window;
pathElements = aValue.split('.');
c = pathElements.length;
for (i=0; i<c; i++) {
if (typeof(currentScope[pathElements[i]]) == 'undefined') {
currentScope[pathElements[i]] = {};
}
currentScope = currentScope[pathElements[i]];
}
},
//-------------------------------------------------------------------------
'exception': {
'AbstractMethod': new MochiKit.Base.NamedError("Clipperz.Base.exception.AbstractMethod"),
'UnknownType': new MochiKit.Base.NamedError("Clipperz.Base.exception.UnknownType"),
'VulnerabilityIssue': new MochiKit.Base.NamedError("Clipperz.Base.exception.VulnerabilityIssue"),
'MandatoryParameter': new MochiKit.Base.NamedError("Clipperz.Base.exception.MandatoryParameter"),
'ObjectNotFound': new MochiKit.Base.NamedError("Clipperz.Base.exception.ObjectNotFound"),
'raise': function (aName) {
throw Clipperz.Base.exception[aName];
}
},
//-------------------------------------------------------------------------
'extend': YAHOO.extendX,
//-------------------------------------------------------------------------
__syntaxFix__: "syntax fix"
});
// Original regExp courtesy of John Gruber: http://daringfireball.net/2009/11/liberal_regex_for_matching_urls
// Updated to match Clipperz usage pattern.
//MochiKit.Base.urlRegExp = new RegExp(/\b(([\w-]+:\/\/?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|\/)))/);
MochiKit.Base.urlRegExp = new RegExp(/^((([\w-]+:\/\/?)|(www\.))[^\s()<>]+((?:\([\w\d]+\)|([^[:punct:]\s]|\/)))?)/);
// RegExp found here: http://www.tipsntracks.com/117/validate-an-email-address-using-regular-expressions.html
MochiKit.Base.emailRegExp = new RegExp(/^([a-zA-Z0-9_\-\.]+)@(([a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3}))|(([01]?\d\d?|2[0-4]\d|25[0-5])\.){3}([01]?\d\d?|25[0-5]|2[0-4]\d))$/);
MochiKit.Base.registerComparator('Object dummy comparator',
function(a, b) {
return ((a.constructor == Object) && (b.constructor == Object));
},
function(a, b) {
var result;
var aKeys;
var bKeys;
aKeys = MochiKit.Base.keys(a).sort();
bKeys = MochiKit.Base.keys(b).sort();
result = MochiKit.Base.compare(aKeys, bKeys);
if (result == 0) {
var i, c;
c = aKeys.length;
for (i=0; (i<c) && (result == 0); i++) {
result = MochiKit.Base.compare(a[aKeys[i]], b[bKeys[i]]);
}
}
return result;
},
true
);

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,344 @@
/*
Copyright 2008-2013 Clipperz Srl
This file is part of Clipperz, the online password manager.
For further information about its features and functionalities please
refer to http://www.clipperz.com.
* Clipperz is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
* Clipperz is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public
License along with Clipperz. If not, see http://www.gnu.org/licenses/.
*/
if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
Clipperz.CSVProcessor = function(args) {
args = args || {};
// this._status = undefined;
// this._error_input = undefined;
// this._string = undefined;
// this._fields = undefined;
this._quoteChar = args['quoteChar'] || "\042";
this._eol = args['eol'] || "";
this._escapeChar = args['escapeChar'] || "\042";
this._separatorChar = args['separatorChar'] || ",";
this._binary = args['binary'] || false;
this._alwaysQuote = args['alwaysQuote'] || false;
return this;
}
//=============================================================================
Clipperz.CSVProcessor.prototype = MochiKit.Base.update(null, {
//-------------------------------------------------------------------------
'quoteChar': function() {
return this._quoteChar;
},
//-------------------------------------------------------------------------
'eol': function() {
return this._eol;
},
//-------------------------------------------------------------------------
'escapeChar': function() {
return this._escapeChar;
},
//-------------------------------------------------------------------------
'separatorChar': function() {
return this._separatorChar;
},
'setSeparatorChar': function(aValue) {
this._separatorChar = aValue;
},
//-------------------------------------------------------------------------
'binary': function() {
return this._binary;
},
//-------------------------------------------------------------------------
'alwaysQuote': function() {
return this._alwaysQuote;
},
//-------------------------------------------------------------------------
/*
'parse': function(aValue) {
var result;
var lines;
var parameter;
//Clipperz.logDebug(">>> CSVProcessor.parse");
result = [];
lines = aValue.replace(/\r?\n/g, "\n").replace(/^\n* /g, "").replace(/\n$/g, "");;
parameter = {
line: lines
}
do {
var fields;
fields = this.parseLine(parameter);
if (fields != null) {
result.push(fields);
}
parameter.line = parameter.line.replace(/^\n* /g, "").replace(/\n$/g, "");
//Clipperz.logDebug("line: '" + parameter.line + "'");
} while (parameter.line != "");
//Clipperz.logDebug("--- CSVProcessor.parse - result: " + Clipperz.Base.serializeJSON(result));
//Clipperz.logDebug("<<< CSVProcessor.parse");
return result;
},
*/
//-------------------------------------------------------------------------
'deferredParse_core': function(aContext) {
var deferredResult;
if (aContext.line == "") {
deferredResult = MochiKit.Async.succeed(aContext.result);
} else {
var fields;
fields = this.parseLine(aContext);
if (fields != null) {
aContext.result.push(fields);
}
aContext.line = aContext.line.replace(/^\n*/g, "").replace(/\n$/g, "");
deferredResult = new Clipperz.Async.Deferred("CVSProcessor.deferredParse_core");
// deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'importProcessorProgressUpdate', {status:'processing', size:aContext.size, progress:(aContext.size - aContext.line.length)});
deferredResult.addCallbackPass(MochiKit.Signal.signal, this, 'importProcessorProgressUpdate', {status:'processing', size:aContext.size, progress:(aContext.size - aContext.line.length)});
deferredResult.addCallback(MochiKit.Async.wait, 0.2);
deferredResult.addMethod(this, 'deferredParse_core')
deferredResult.callback(aContext);
}
return deferredResult;
},
//.........................................................................
'deferredParse': function(aValue) {
var deferredResult;
var lines;
var context;
lines = aValue.replace(/\r?\n/g, "\n").replace(/^\n*/g, "").replace(/\n$/g, "");
context = {
line: lines,
size: lines.length,