Merge branch 'staging' of github.com:xwiki-labs/cryptpad into staging

pull/1/head
yflory 8 years ago
commit e57e4e60da

@ -73,9 +73,12 @@ bower update;
# serverside dependencies # serverside dependencies
npm update; npm update;
``` ```
## Deleting all data and resetting Cryptpad
To reset your instance of Cryptpad and remove all the data that is being stored: To reset your instance of Cryptpad and remove all the data that is being stored:
**WARNING: This will reset your Cryptpad instance and remove all data**
``` ```
# change into your cryptpad directory # change into your cryptpad directory
cd /your/cryptpad/instance/location; cd /your/cryptpad/instance/location;

@ -153,7 +153,7 @@ define([
f(void 0, store); f(void 0, store);
} }
var requestLogin = function (Cryptpad) { var requestLogin = function () {
// log out so that you don't go into an endless loop... // log out so that you don't go into an endless loop...
Cryptpad.logout(); Cryptpad.logout();
@ -162,11 +162,11 @@ define([
window.location.href = '/login/'; window.location.href = '/login/';
}; };
var tokenKey = 'loginToken';
if (Cryptpad.isLoggedIn()) { if (Cryptpad.isLoggedIn()) {
/* This isn't truly secure, since anyone who can read the user's object can /* This isn't truly secure, since anyone who can read the user's object can
set their local loginToken to match that in the object. However, it exposes set their local loginToken to match that in the object. However, it exposes
a UI that will work most of the time. */ a UI that will work most of the time. */
var tokenKey = 'loginToken';
// every user object should have a persistent, random number // every user object should have a persistent, random number
if (typeof(proxy.loginToken) !== 'number') { if (typeof(proxy.loginToken) !== 'number') {
@ -203,6 +203,13 @@ define([
if (typeof(n) !== "string") { return; } if (typeof(n) !== "string") { return; }
Cryptpad.changeDisplayName(n); Cryptpad.changeDisplayName(n);
}); });
proxy.on('change', [tokenKey], function () {
console.log('wut');
var localToken = tryParsing(localStorage.getItem(tokenKey));
if (localToken !== proxy[tokenKey]) {
return void requestLogin();
}
});
}; };
var initialized = false; var initialized = false;

@ -11,12 +11,10 @@
<ul> <ul>
<li><a href="/examples/form/">forms</a></li> <li><a href="/examples/form/">forms</a></li>
<li><a href="/examples/text/">text</a></li> <li><a href="/examples/text/">text</a></li>
<li><a href="/examples/hack/">textareas with executable content</a></li>
<li><a href="/examples/board/">kanban board</a></li> <li><a href="/examples/board/">kanban board</a></li>
<li><a href="/examples/json/">json objects</a></li> <!-- <li><a href="/examples/json/">json objects</a></li> -->
<li><a href="/examples/read/">ajax-like get/put behaviour</a></li> <li><a href="/examples/read/">ajax-like get/put behaviour</a></li>
<li><a href="/examples/render/">render markdown content as html</a></li> <li><a href="/examples/render/">render markdown content as html</a></li>
<li><a href="/examples/style/">edit a page's style tag</a></li> <li><a href="/examples/style/">edit a page's style tag</a></li>
<li><a href="/examples/upload/">upload content</a></li>
</ul> </ul>

@ -1,28 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
<script data-bootload="main.js" data-main="/common/boot.js" src="/bower_components/requirejs/require.js"></script>
<link rel="icon" type="image/png"
href="/customize/main-favicon.png"
data-main-favicon="/customize/main-favicon.png"
data-alt-favicon="/customize/alt-favicon.png"
id="favicon" />
<style>
input {
width: 50vw;
padding: 15px;
}
pre {
max-width: 90vw;
overflow: auto;
}
</style>
</head>
<body>
<h1>Upload</h1>
<input type="file">

@ -1,75 +0,0 @@
define([
'jquery',
'/common/cryptget.js',
'/bower_components/chainpad-crypto/crypto.js'
], function ($, Crypt, Crypto) {
var Nacl = window.nacl;
var key = Nacl.randomBytes(32);
var handleFile = function (body) {
//console.log("plaintext");
//console.log(body);
/*
0 && Crypt.put(body, function (e, out) {
if (e) { return void console.error(e); }
if (out) {
console.log(out);
}
}); */
var data = {};
(function () {
var cyphertext = data.payload = Crypto.encrypt(body, key);
console.log("encrypted");
console.log(cyphertext);
console.log(data);
var decrypted = Crypto.decrypt(cyphertext, key);
//console.log('decrypted');
//console.log(decrypted);
if (decrypted !== body) {
throw new Error("failed to maintain integrity with round trip");
}
// finding... files are entirely too large.
console.log(data.payload.length, body.length); // 1491393, 588323
console.log(body.length / data.payload.length); // 0.3944788529918003
console.log(data.payload.length / body.length); // 2.534990132971174
/*
http://stackoverflow.com/questions/19959072/sending-binary-data-in-javascript-over-http
// Since we deal with Firefox and Chrome only
var bytesToSend = [253, 0, 128, 1];
var bytesArray = new Uint8Array(bytesToSend);
$.ajax({
url: '%your_service_url%',
type: 'POST',
contentType: 'application/octet-stream',
data: bytesArray,
processData: false
});
*/
})();
};
var $file = $('input[type="file"]');
$file.on('change', function (e) {
var file = e.target.files[0];
var reader = new FileReader();
reader.onload = function (e) {
handleFile(e.target.result);
};
reader.readAsText(file);
});
});

@ -273,8 +273,9 @@ define([
$spinner.show(); $spinner.show();
$ok.hide(); $ok.hide();
var token = proxy.loginToken = Math.floor(Math.random()*Number.MAX_SAFE_INTEGER); var token = Math.floor(Math.random()*Number.MAX_SAFE_INTEGER);
localStorage.setItem('loginToken', token); localStorage.setItem('loginToken', token);
proxy.loginToken = token;
Cryptpad.whenRealtimeSyncs(realtime, function () { Cryptpad.whenRealtimeSyncs(realtime, function () {
$spinner.hide(); $spinner.hide();

Loading…
Cancel
Save