Merge branch 'staging' into communities-trim

pull/1/head
yflory 5 years ago
commit 0f697ac865

@ -107,7 +107,7 @@ define([
])*/ ])*/
]) ])
]), ]),
h('div.cp-version-footer', "CryptPad v3.10.0 (Kouprey)") h('div.cp-version-footer', "CryptPad v3.11.0 (LabradorDuck)")
]); ]);
}; };

@ -135,7 +135,7 @@
@colortheme_oocell-bg: #40865c; @colortheme_oocell-bg: #40865c;
@colortheme_oocell-color: #FFF; @colortheme_oocell-color: #FFF;
@colortheme_oocell-warn: #cd2532; @colortheme_oocell-warn: #ffbcc0;
@colortheme_kanban-bg: #8C4; @colortheme_kanban-bg: #8C4;
@colortheme_kanban-color: #000; @colortheme_kanban-color: #000;

@ -14,9 +14,11 @@
right: 10vw; right: 10vw;
bottom: 10vh; bottom: 10vh;
box-sizing: border-box; box-sizing: border-box;
z-index: 1000000; //Z file upload table container z-index: 100000; //Z file upload table container
display: none; display: none;
color: darken(@colortheme_drive-bg, 10%); color: darken(@colortheme_drive-bg, 10%);
max-height: 180px;
overflow-y: auto;
@media screen and (max-width: @browser_media-medium-screen) { @media screen and (max-width: @browser_media-medium-screen) {
left: 5vw; right: 5vw; bottom: 5vw; left: 5vw; right: 5vw; bottom: 5vw;
@ -26,6 +28,9 @@
display: flex; display: flex;
background-color: darken(@colortheme_modal-bg, 10%); background-color: darken(@colortheme_modal-bg, 10%);
font-weight: bold; font-weight: bold;
position: sticky;
top: 0;
z-index: 1;
.cp-fileupload-header-title { .cp-fileupload-header-title {
padding: 0.25em 0.5em; padding: 0.25em 0.5em;
flex-grow: 1; flex-grow: 1;

@ -1,6 +1,7 @@
@import (reference) "/customize/src/less2/include/colortheme-all.less"; @import (reference) "/customize/src/less2/include/colortheme-all.less";
@import (reference) "/customize/src/less2/include/leftside-menu.less"; @import (reference) "/customize/src/less2/include/leftside-menu.less";
@import (reference) "/customize/src/less2/include/buttons.less"; @import (reference) "/customize/src/less2/include/buttons.less";
@import (reference) "/customize/src/less2/include/browser.less";
@sidebar_button-width: 400px; @sidebar_button-width: 400px;
@ -73,6 +74,7 @@
padding: 5px 20px; padding: 5px 20px;
color: @rightside-color; color: @rightside-color;
overflow: auto; overflow: auto;
padding-bottom: 200px;
// Following rules are only in settings // Following rules are only in settings
.cp-sidebarlayout-element { .cp-sidebarlayout-element {
@ -107,6 +109,7 @@
.cp-sidebarlayout-input-block { .cp-sidebarlayout-input-block {
display: inline-flex; display: inline-flex;
width: @sidebar_button-width; width: @sidebar_button-width;
max-width: 100%;
input { input {
flex: 1; flex: 1;
//border-radius: 0.25em 0 0 0.25em; //border-radius: 0.25em 0 0 0.25em;
@ -118,6 +121,7 @@
//border: 1px solid #adadad; //border: 1px solid #adadad;
border-left: 0px; border-left: 0px;
height: @variables_input-height; height: @variables_input-height;
margin: 0 !important;
} }
} }
&>div { &>div {
@ -162,6 +166,25 @@
} }
*/ */
} }
@media screen and (max-width: @browser_media-medium-screen) {
flex-flow: column;
overflow: auto;
#cp-sidebarlayout-leftside {
width: 100% !important; // Override "narrow" mode
padding-bottom: 20px;
.cp-sidebarlayout-categories {
.cp-sidebarlayout-category {
margin: 0;
span.cp-sidebar-layout-category-name {
display: inline !important; // override "narrow" mode
}
}
}
}
#cp-sidebarlayout-rightside {
overflow: unset;
}
}
} }
} }

@ -106,7 +106,7 @@ server {
if ($uri ~ ^\/common\/onlyoffice\/.*\/index\.html.*$) { set $unsafe 1; } if ($uri ~ ^\/common\/onlyoffice\/.*\/index\.html.*$) { set $unsafe 1; }
# everything except the sandbox domain is a privileged scope, as they might be used to handle keys # everything except the sandbox domain is a privileged scope, as they might be used to handle keys
if ($host != sandbox.cryptpad.info) { set $unsafe 0; } if ($host != $sandbox_domain) { set $unsafe 0; }
# privileged contexts allow a few more rights than unprivileged contexts, though limits are still applied # privileged contexts allow a few more rights than unprivileged contexts, though limits are still applied
if ($unsafe) { if ($unsafe) {

@ -1,37 +1,8 @@
/* jshint esversion: 6 */ /* jshint esversion: 6 */
const nThen = require("nthen");
const WebSocketServer = require('ws').Server; const WebSocketServer = require('ws').Server;
const NetfluxSrv = require('chainpad-server'); const NetfluxSrv = require('chainpad-server');
module.exports.create = function (config) { module.exports.create = function (config) {
const wsConfig = {
server: config.httpServer,
};
nThen(function (w) {
require('../storage/file').create(config, w(function (_store) {
config.store = _store;
}));
}).nThen(function (w) {
// XXX embed this in historyKeeper
require("../storage/tasks").create(config, w(function (e, tasks) {
if (e) {
throw e;
}
config.tasks = tasks;
if (config.disableIntegratedTasks) { return; }
config.intervals = config.intervals || {};
config.intervals.taskExpiration = setInterval(function () {
tasks.runAll(function (err) {
if (err) {
// either TASK_CONCURRENCY or an error with tasks.list
// in either case it is already logged.
}
});
}, 1000 * 60 * 5); // run every five minutes
}));
}).nThen(function () {
// asynchronously create a historyKeeper and RPC together // asynchronously create a historyKeeper and RPC together
require('./historyKeeper.js').create(config, function (err, historyKeeper) { require('./historyKeeper.js').create(config, function (err, historyKeeper) {
if (err) { throw err; } if (err) { throw err; }
@ -39,17 +10,20 @@ module.exports.create = function (config) {
var log = config.log; var log = config.log;
// spawn ws server and attach netflux event handlers // spawn ws server and attach netflux event handlers
NetfluxSrv.create(new WebSocketServer(wsConfig)) NetfluxSrv.create(new WebSocketServer({ server: config.httpServer}))
.on('channelClose', historyKeeper.channelClose) .on('channelClose', historyKeeper.channelClose)
.on('channelMessage', historyKeeper.channelMessage) .on('channelMessage', historyKeeper.channelMessage)
.on('channelOpen', historyKeeper.channelOpen) .on('channelOpen', historyKeeper.channelOpen)
.on('sessionClose', function (userId, reason) { .on('sessionClose', function (userId, reason) {
if (['BAD_MESSAGE', 'SOCKET_ERROR', 'SEND_MESSAGE_FAIL_2'].indexOf(reason) !== -1) { if (['BAD_MESSAGE', 'SOCKET_ERROR', 'SEND_MESSAGE_FAIL_2'].indexOf(reason) !== -1) {
if (reason && reason.code === 'ECONNRESET') { return; }
return void log.error('SESSION_CLOSE_WITH_ERROR', { return void log.error('SESSION_CLOSE_WITH_ERROR', {
userId: userId, userId: userId,
reason: reason, reason: reason,
}); });
} }
if (reason && reason === 'SOCKET_CLOSED') { return; }
log.verbose('SESSION_CLOSE_ROUTINE', { log.verbose('SESSION_CLOSE_ROUTINE', {
userId: userId, userId: userId,
reason: reason, reason: reason,
@ -71,5 +45,4 @@ module.exports.create = function (config) {
}) })
.register(historyKeeper.id, historyKeeper.directMessage); .register(historyKeeper.id, historyKeeper.directMessage);
}); });
});
}; };

@ -2,7 +2,7 @@
const BatchRead = require("../batch-read"); const BatchRead = require("../batch-read");
const nThen = require("nthen"); const nThen = require("nthen");
const getFolderSize = require("get-folder-size"); const getFolderSize = require("get-folder-size");
const Util = require("../common-util"); //const Util = require("../common-util");
var Fs = require("fs"); var Fs = require("fs");
@ -94,8 +94,8 @@ var getDiskUsage = function (Env, cb) {
Admin.command = function (Env, safeKey, data, cb, Server) { Admin.command = function (Env, safeKey, data, cb, Server) {
var admins = Env.admins; var admins = Env.admins;
var unsafeKey = Util.unescapeKeyCharacters(safeKey); //var unsafeKey = Util.unescapeKeyCharacters(safeKey);
if (admins.indexOf(unsafeKey) === -1) { if (admins.indexOf(safeKey) === -1) {
return void cb("FORBIDDEN"); return void cb("FORBIDDEN");
} }

@ -6,7 +6,7 @@ const nThen = require("nthen");
const Core = require("./core"); const Core = require("./core");
const Metadata = require("./metadata"); const Metadata = require("./metadata");
Channel.clearOwnedChannel = function (Env, safeKey, channelId, cb) { Channel.clearOwnedChannel = function (Env, safeKey, channelId, cb, Server) {
if (typeof(channelId) !== 'string' || channelId.length !== 32) { if (typeof(channelId) !== 'string' || channelId.length !== 32) {
return cb('INVALID_ARGUMENTS'); return cb('INVALID_ARGUMENTS');
} }
@ -20,19 +20,46 @@ Channel.clearOwnedChannel = function (Env, safeKey, channelId, cb) {
return void cb('INSUFFICIENT_PERMISSIONS'); return void cb('INSUFFICIENT_PERMISSIONS');
} }
return void Env.msgStore.clearChannel(channelId, function (e) { return void Env.msgStore.clearChannel(channelId, function (e) {
cb(e); if (e) { return void cb(e); }
cb();
const channel_cache = Env.historyKeeper.channel_cache;
const clear = function () {
// delete the channel cache because it will have been invalidated
delete channel_cache[channelId];
};
nThen(function (w) {
Server.getChannelUserList(channelId).forEach(function (userId) {
Server.send(userId, [
0,
Env.historyKeeper.id,
'MSG',
userId,
JSON.stringify({
error: 'ECLEARED',
channel: channelId
})
], w());
});
}).nThen(function () {
clear();
}).orTimeout(function () {
Env.Log.warn("ON_CHANNEL_CLEARED_TIMEOUT", channelId);
clear();
}, 30000);
}); });
}); });
}; };
Channel.removeOwnedChannel = function (Env, safeKey, channelId, cb) { Channel.removeOwnedChannel = function (Env, safeKey, channelId, cb, Server) {
if (typeof(channelId) !== 'string' || !Core.isValidId(channelId)) { if (typeof(channelId) !== 'string' || !Core.isValidId(channelId)) {
return cb('INVALID_ARGUMENTS'); return cb('INVALID_ARGUMENTS');
} }
var unsafeKey = Util.unescapeKeyCharacters(safeKey); var unsafeKey = Util.unescapeKeyCharacters(safeKey);
if (Env.blobStore.isFileId(channelId)) { if (Env.blobStore.isFileId(channelId)) {
//var safeKey = Util.escapeKeyCharacters(unsafeKey);
var blobId = channelId; var blobId = channelId;
return void nThen(function (w) { return void nThen(function (w) {
@ -89,6 +116,45 @@ Channel.removeOwnedChannel = function (Env, safeKey, channelId, cb) {
return void cb(e); return void cb(e);
} }
cb(void 0, 'OK'); cb(void 0, 'OK');
const channel_cache = Env.historyKeeper.channel_cache;
const metadata_cache = Env.historyKeeper.metadata_cache;
const clear = function () {
delete channel_cache[channelId];
Server.clearChannel(channelId);
delete metadata_cache[channelId];
};
// an owner of a channel deleted it
nThen(function (w) {
// close the channel in the store
Env.msgStore.closeChannel(channelId, w());
}).nThen(function (w) {
// Server.channelBroadcast would be better
// but we can't trust it to track even one callback,
// let alone many in parallel.
// so we simulate it on this side to avoid race conditions
Server.getChannelUserList(channelId).forEach(function (userId) {
Server.send(userId, [
0,
Env.historyKeeper.id,
"MSG",
userId,
JSON.stringify({
error: 'EDELETED',
channel: channelId,
})
], w());
});
}).nThen(function () {
// clear the channel's data from memory
// once you've sent everyone a notice that the channel has been deleted
clear();
}).orTimeout(function () {
Env.Log.warn('ON_CHANNEL_DELETED_TIMEOUT', channelId);
clear();
}, 30000);
}); });
}); });
}; };
@ -121,6 +187,8 @@ Channel.trimHistory = function (Env, safeKey, data, cb) {
// clear historyKeeper's cache for this channel // clear historyKeeper's cache for this channel
Env.historyKeeper.channelClose(channelId); Env.historyKeeper.channelClose(channelId);
cb(void 0, 'OK'); cb(void 0, 'OK');
delete Env.historyKeeper.channel_cache[channelId];
delete Env.historyKeeper.metadata_cache[channelId];
}); });
}); });
}; };
@ -160,7 +228,7 @@ Channel.isNewChannel = function (Env, channel, cb) {
Otherwise behaves the same as sending to a channel Otherwise behaves the same as sending to a channel
*/ */
Channel.writePrivateMessage = function (Env, args, cb, Server) { // XXX odd signature Channel.writePrivateMessage = function (Env, args, cb, Server) {
var channelId = args[0]; var channelId = args[0];
var msg = args[1]; var msg = args[1];
@ -197,11 +265,10 @@ Channel.writePrivateMessage = function (Env, args, cb, Server) { // XXX odd sign
// if the message isn't valid it won't be stored. // if the message isn't valid it won't be stored.
Env.historyKeeper.channelMessage(Server, channelStruct, fullMessage); Env.historyKeeper.channelMessage(Server, channelStruct, fullMessage);
// call back with the message and the target channel. Server.getChannelUserList(channelId).forEach(function (userId) {
// historyKeeper will take care of broadcasting it if anyone is in the channel Server.send(userId, fullMessage);
cb(void 0, {
channel: channelId,
message: fullMessage
}); });
cb();
}; };

@ -12,8 +12,7 @@ Data.getMetadata = function (Env, channel, cb/* , Server */) {
if (!Core.isValidId(channel)) { return void cb('INVALID_CHAN'); } if (!Core.isValidId(channel)) { return void cb('INVALID_CHAN'); }
if (channel.length !== 32) { return cb("INVALID_CHAN_LENGTH"); } if (channel.length !== 32) { return cb("INVALID_CHAN_LENGTH"); }
// XXX get metadata from the server cache if it is available // FIXME get metadata from the server cache if it is available
// Server isn't always passed, though...
batchMetadata(channel, cb, function (done) { batchMetadata(channel, cb, function (done) {
var ref = {}; var ref = {};
var lineHandler = Meta.createLineHandler(ref, Env.Log.error); var lineHandler = Meta.createLineHandler(ref, Env.Log.error);
@ -37,7 +36,7 @@ Data.getMetadata = function (Env, channel, cb/* , Server */) {
} }
*/ */
var queueMetadata = WriteQueue(); var queueMetadata = WriteQueue();
Data.setMetadata = function (Env, safeKey, data, cb) { Data.setMetadata = function (Env, safeKey, data, cb, Server) {
var unsafeKey = Util.unescapeKeyCharacters(safeKey); var unsafeKey = Util.unescapeKeyCharacters(safeKey);
var channel = data.channel; var channel = data.channel;
@ -108,8 +107,19 @@ Data.setMetadata = function (Env, safeKey, data, cb) {
cb(e); cb(e);
return void next(); return void next();
} }
cb(void 0, metadata); cb(void 0, metadata);
next(); next();
const metadata_cache = Env.historyKeeper.metadata_cache;
const channel_cache = Env.historyKeeper.channel_cache;
metadata_cache[channel] = metadata;
var index = Util.find(channel_cache, [channel, 'index']);
if (index && typeof(index) === 'object') { index.metadata = metadata; }
Server.channelBroadcast(channel, JSON.stringify(metadata), Env.historyKeeper.id);
}); });
}); });
}); });

@ -23,7 +23,7 @@ var sumChannelSizes = function (sizes) {
.reduce(function (a, b) { return a + b; }, 0); .reduce(function (a, b) { return a + b; }, 0);
}; };
// XXX it's possible for this to respond before the server has had a chance // FIXME it's possible for this to respond before the server has had a chance
// to fetch the limits. Maybe we should respond with an error... // to fetch the limits. Maybe we should respond with an error...
// or wait until we actually know the limits before responding // or wait until we actually know the limits before responding
var getLimit = Pinning.getLimit = function (Env, publicKey, cb) { var getLimit = Pinning.getLimit = function (Env, publicKey, cb) {
@ -205,7 +205,6 @@ Pinning.removePins = function (Env, safeKey, cb) {
}; };
Pinning.trimPins = function (Env, safeKey, cb) { Pinning.trimPins = function (Env, safeKey, cb) {
// XXX trim to latest pin checkpoint
cb("NOT_IMPLEMENTED"); cb("NOT_IMPLEMENTED");
}; };
@ -453,10 +452,10 @@ Pinning.loadChannelPins = function (Env) {
Pinning.isChannelPinned = function (Env, channel, cb) { Pinning.isChannelPinned = function (Env, channel, cb) {
Env.evPinnedPadsReady.reg(() => { Env.evPinnedPadsReady.reg(() => {
if (Env.pinnedPads[channel] && Object.keys(Env.pinnedPads[channel]).length) { if (Env.pinnedPads[channel] && Object.keys(Env.pinnedPads[channel]).length) { // FIXME 'Object.keys' here is overkill. We only need to know that it isn't empty
cb(void 0, true); cb(void 0, true);
} else { } else {
delete Env.pinnedPads[channel]; // XXX WAT delete Env.pinnedPads[channel];
cb(void 0, false); cb(void 0, false);
} }
}); });

@ -81,7 +81,8 @@ Quota.updateCachedLimits = function (Env, cb) {
req.on('error', function (e) { req.on('error', function (e) {
Quota.applyCustomLimits(Env); Quota.applyCustomLimits(Env);
if (!Env.domain) { return cb(); } // XXX // FIXME this is always falsey. Maybe we just suppress errors?
if (!Env.domain) { return cb(); }
cb(e); cb(e);
}); });

File diff suppressed because it is too large Load Diff

@ -1,5 +1,15 @@
/* jshint esversion: 6 */
/* global Buffer */
var HK = module.exports; var HK = module.exports;
const nThen = require('nthen');
const Once = require("./once");
const Meta = require("./metadata");
const Nacl = require('tweetnacl/nacl-fast');
const now = function () { return (new Date()).getTime(); };
const ONE_DAY = 1000 * 60 * 60 * 24; // one day in milliseconds
/* getHash /* getHash
* this function slices off the leading portion of a message which is * this function slices off the leading portion of a message which is
most likely unique most likely unique
@ -12,7 +22,7 @@ var HK = module.exports;
* can't be easily migrated * can't be easily migrated
* don't break it! * don't break it!
*/ */
HK.getHash = function (msg, Log) { const getHash = HK.getHash = function (msg, Log) {
if (typeof(msg) !== 'string') { if (typeof(msg) !== 'string') {
if (Log) { if (Log) {
Log.warn('HK_GET_HASH', 'getHash() called on ' + typeof(msg) + ': ' + msg); Log.warn('HK_GET_HASH', 'getHash() called on ' + typeof(msg) + ': ' + msg);
@ -24,10 +34,899 @@ HK.getHash = function (msg, Log) {
// historyKeeper should explicitly store any channel // historyKeeper should explicitly store any channel
// with a 32 character id // with a 32 character id
HK.STANDARD_CHANNEL_LENGTH = 32; const STANDARD_CHANNEL_LENGTH = HK.STANDARD_CHANNEL_LENGTH = 32;
// historyKeeper should not store messages sent to any channel // historyKeeper should not store messages sent to any channel
// with a 34 character id // with a 34 character id
HK.EPHEMERAL_CHANNEL_LENGTH = 34; const EPHEMERAL_CHANNEL_LENGTH = HK.EPHEMERAL_CHANNEL_LENGTH = 34;
const tryParse = function (Env, str) {
try {
return JSON.parse(str);
} catch (err) {
Env.Log.error('HK_PARSE_ERROR', err);
}
};
/* sliceCpIndex
returns a list of all checkpoints which might be relevant for a client connecting to a session
* if there are two or fewer checkpoints, return everything you have
* if there are more than two
* return at least two
* plus any more which were received within the last 100 messages
This is important because the additional history is what prevents
clients from forking on checkpoints and dropping forked history.
*/
const sliceCpIndex = function (cpIndex, line) {
// Remove "old" checkpoints (cp sent before 100 messages ago)
const minLine = Math.max(0, (line - 100));
let start = cpIndex.slice(0, -2);
const end = cpIndex.slice(-2);
start = start.filter(function (obj) {
return obj.line > minLine;
});
return start.concat(end);
};
const isMetadataMessage = function (parsed) {
return Boolean(parsed && parsed.channel);
};
// validateKeyStrings supplied by clients must decode to 32-byte Uint8Arrays
const isValidValidateKeyString = function (key) {
try {
return typeof(key) === 'string' &&
Nacl.util.decodeBase64(key).length === Nacl.sign.publicKeyLength;
} catch (e) {
return false;
}
};
var CHECKPOINT_PATTERN = /^cp\|(([A-Za-z0-9+\/=]+)\|)?/;
/* expireChannel is here to clean up channels that should have been removed
but for some reason are still present
*/
const expireChannel = function (Env, channel) {
return void Env.store.archiveChannel(channel, function (err) {
Env.Log.info("ARCHIVAL_CHANNEL_BY_HISTORY_KEEPER_EXPIRATION", {
channelId: channel,
status: err? String(err): "SUCCESS",
});
});
};
/* dropChannel
* cleans up memory structures which are managed entirely by the historyKeeper
*/
const dropChannel = HK.dropChannel = function (Env, chanName) {
delete Env.metadata_cache[chanName];
delete Env.channel_cache[chanName];
};
/* checkExpired
* synchronously returns true or undefined to indicate whether the channel is expired
* according to its metadata
* has some side effects:
* closes the channel via the store.closeChannel API
* and then broadcasts to all channel members that the channel has expired
* removes the channel from the netflux-server's in-memory cache
* removes the channel metadata from history keeper's in-memory cache
FIXME the boolean nature of this API should be separated from its side effects
*/
const checkExpired = function (Env, Server, channel) {
const store = Env.store;
const metadata_cache = Env.metadata_cache;
if (!(channel && channel.length === STANDARD_CHANNEL_LENGTH)) { return false; }
let metadata = metadata_cache[channel];
if (!(metadata && typeof(metadata.expire) === 'number')) { return false; }
// the number of milliseconds ago the channel should have expired
let pastDue = (+new Date()) - metadata.expire;
// less than zero means that it hasn't expired yet
if (pastDue < 0) { return false; }
// if it should have expired more than a day ago...
// there may have been a problem with scheduling tasks
// or the scheduled tasks may not be running
// so trigger a removal from here
if (pastDue >= ONE_DAY) { expireChannel(Env, channel); }
// close the channel
store.closeChannel(channel, function () {
Server.channelBroadcast(channel, {
error: 'EEXPIRED',
channel: channel
}, Env.id);
dropChannel(channel);
});
// return true to indicate that it has expired
return true;
};
/* computeIndex
can call back with an error or a computed index which includes:
* cpIndex:
* array including any checkpoints pushed within the last 100 messages
* processed by 'sliceCpIndex(cpIndex, line)'
* offsetByHash:
* a map containing message offsets by their hash
* this is for every message in history, so it could be very large...
* except we remove offsets from the map if they occur before the oldest relevant checkpoint
* size: in bytes
* metadata:
* validationKey
* expiration time
* owners
* ??? (anything else we might add in the future)
* line
* the number of messages in history
* including the initial metadata line, if it exists
*/
const computeIndex = function (Env, channelName, cb) {
const store = Env.store;
const Log = Env.Log;
const cpIndex = [];
let messageBuf = [];
let metadata;
let i = 0;
const ref = {};
const CB = Once(cb);
const offsetByHash = {};
let size = 0;
nThen(function (w) {
// iterate over all messages in the channel log
// old channels can contain metadata as the first message of the log
// remember metadata the first time you encounter it
// otherwise index important messages in the log
store.readMessagesBin(channelName, 0, (msgObj, readMore) => {
let msg;
// keep an eye out for the metadata line if you haven't already seen it
// but only check for metadata on the first line
if (!i && !metadata && msgObj.buff.indexOf('{') === 0) {
i++; // always increment the message counter
msg = tryParse(Env, msgObj.buff.toString('utf8'));
if (typeof msg === "undefined") { return readMore(); }
// validate that the current line really is metadata before storing it as such
if (isMetadataMessage(msg)) {
metadata = msg;
return readMore();
}
}
i++;
if (msgObj.buff.indexOf('cp|') > -1) {
msg = msg || tryParse(Env, msgObj.buff.toString('utf8'));
if (typeof msg === "undefined") { return readMore(); }
// cache the offsets of checkpoints if they can be parsed
if (msg[2] === 'MSG' && msg[4].indexOf('cp|') === 0) {
cpIndex.push({
offset: msgObj.offset,
line: i
});
// we only want to store messages since the latest checkpoint
// so clear the buffer every time you see a new one
messageBuf = [];
}
}
// if it's not metadata or a checkpoint then it should be a regular message
// store it in the buffer
messageBuf.push(msgObj);
return readMore();
}, w((err) => {
if (err && err.code !== 'ENOENT') {
w.abort();
return void CB(err);
}
// once indexing is complete you should have a buffer of messages since the latest checkpoint
// map the 'hash' of each message to its byte offset in the log, to be used for reconnecting clients
messageBuf.forEach((msgObj) => {
const msg = tryParse(Env, msgObj.buff.toString('utf8'));
if (typeof msg === "undefined") { return; }
if (msg[0] === 0 && msg[2] === 'MSG' && typeof(msg[4]) === 'string') {
// msgObj.offset is API guaranteed by our storage module
// it should always be a valid positive integer
offsetByHash[getHash(msg[4], Log)] = msgObj.offset;
}
// There is a trailing \n at the end of the file
size = msgObj.offset + msgObj.buff.length + 1;
});
}));
}).nThen(function (w) {
// create a function which will iterate over amendments to the metadata
const handler = Meta.createLineHandler(ref, Log.error);
// initialize the accumulator in case there was a foundational metadata line in the log content
if (metadata) { handler(void 0, metadata); }
// iterate over the dedicated metadata log (if it exists)
// proceed even in the event of a stream error on the metadata log
store.readDedicatedMetadata(channelName, handler, w(function (err) {
if (err) {
return void Log.error("DEDICATED_METADATA_ERROR", err);
}
}));
}).nThen(function () {
// when all is done, cache the metadata in memory
if (ref.index) { // but don't bother if no metadata was found...
metadata = Env.metadata_cache[channelName] = ref.meta;
}
// and return the computed index
CB(null, {
// Only keep the checkpoints included in the last 100 messages
cpIndex: sliceCpIndex(cpIndex, i),
offsetByHash: offsetByHash,
size: size,
metadata: metadata,
line: i
});
});
};
/* getIndex
calls back with an error if anything goes wrong
or with a cached index for a channel if it exists
(along with metadata)
otherwise it calls back with the index computed by 'computeIndex'
as an added bonus:
if the channel exists but its index does not then it caches the index
*/
const getIndex = (Env, channelName, cb) => {
const channel_cache = Env.channel_cache;
const chan = channel_cache[channelName];
// if there is a channel in memory and it has an index cached, return it
if (chan && chan.index) {
// enforce async behaviour
return void setTimeout(function () {
cb(undefined, chan.index);
});
}
Env.batchIndexReads(channelName, cb, function (done) {
computeIndex(Env, channelName, (err, ret) => {
// this is most likely an unrecoverable filesystem error
if (err) { return void done(err); }
// cache the computed result if possible
if (chan) { chan.index = ret; }
// return
done(void 0, ret);
});
});
};
/* storeMessage
* channel id
* the message to store
* whether the message is a checkpoint
* optionally the hash of the message
* it's not always used, but we guard against it
* async but doesn't have a callback
* source of a race condition whereby:
* two messaages can be inserted
* two offsets can be computed using the total size of all the messages
* but the offsets don't correspond to the actual location of the newlines
* because the two actions were performed like ABba...
* the fix is to use callbacks and implement queueing for writes
* to guarantee that offset computation is always atomic with writes
*/
const storeMessage = function (Env, channel, msg, isCp, optionalMessageHash) {
const id = channel.id;
const Log = Env.Log;
Env.queueStorage(id, function (next) {
const msgBin = Buffer.from(msg + '\n', 'utf8');
// Store the message first, and update the index only once it's stored.
// store.messageBin can be async so updating the index first may
// result in a wrong cpIndex
nThen((waitFor) => {
Env.store.messageBin(id, msgBin, waitFor(function (err) {
if (err) {
waitFor.abort();
Log.error("HK_STORE_MESSAGE_ERROR", err.message);
// this error is critical, but there's not much we can do at the moment
// proceed with more messages, but they'll probably fail too
// at least you won't have a memory leak
// TODO make it possible to respond to clients with errors so they know
// their message wasn't stored
return void next();
}
}));
}).nThen((waitFor) => {
getIndex(Env, id, waitFor((err, index) => {
if (err) {
Log.warn("HK_STORE_MESSAGE_INDEX", err.stack);
// non-critical, we'll be able to get the channel index later
return void next();
}
if (typeof (index.line) === "number") { index.line++; }
if (isCp) {
index.cpIndex = sliceCpIndex(index.cpIndex, index.line || 0);
for (let k in index.offsetByHash) {
if (index.offsetByHash[k] < index.cpIndex[0]) {
delete index.offsetByHash[k];
}
}
index.cpIndex.push({
offset: index.size,
line: ((index.line || 0) + 1)
});
}
if (optionalMessageHash) { index.offsetByHash[optionalMessageHash] = index.size; }
index.size += msgBin.length;
// handle the next element in the queue
next();
}));
});
});
};
/* getHistoryOffset
returns a number representing the byte offset from the start of the log
for whatever history you're seeking.
query by providing a 'lastKnownHash',
which is really just a string of the first 64 characters of an encrypted message.
OR by -1 which indicates that we want the full history (byte offset 0)
OR nothing, which indicates that you want whatever messages the historyKeeper deems relevant
(typically the last few checkpoints)
this function embeds a lot of the history keeper's logic:
0. if you passed -1 as the lastKnownHash it means you want the complete history
* I'm not sure why you'd need to call this function if you know it will return 0 in this case...
* it has a side-effect of filling the index cache if it's empty
1. if you provided a lastKnownHash and that message does not exist in the history:
* either the client has made a mistake or the history they knew about no longer exists
* call back with EINVAL
2. if you did not provide a lastKnownHash
* and there are fewer than two checkpoints:
* return 0 (read from the start of the file)
* and there are two or more checkpoints:
* return the offset of the earliest checkpoint which 'sliceCpIndex' considers relevant
3. if you did provide a lastKnownHash
* read through the log until you find the hash that you're looking for
* call back with either the byte offset of the message that you found OR
* -1 if you didn't find it
*/
const getHistoryOffset = (Env, channelName, lastKnownHash, cb) => {
const store = Env.store;
const Log = Env.Log;
// lastKnownhash === -1 means we want the complete history
if (lastKnownHash === -1) { return void cb(null, 0); }
let offset = -1;
nThen((waitFor) => {
getIndex(Env, channelName, waitFor((err, index) => {
if (err) { waitFor.abort(); return void cb(err); }
// check if the "hash" the client is requesting exists in the index
const lkh = index.offsetByHash[lastKnownHash];
// we evict old hashes from the index as new checkpoints are discovered.
// if someone connects and asks for a hash that is no longer relevant,
// we tell them it's an invalid request. This is because of the semantics of "GET_HISTORY"
// which is only ever used when connecting or reconnecting in typical uses of history...
// this assumption should hold for uses by chainpad, but perhaps not for other uses cases.
// EXCEPT: other cases don't use checkpoints!
// clients that are told that their request is invalid should just make another request
// without specifying the hash, and just trust the server to give them the relevant data.
// QUESTION: does this mean mailboxes are causing the server to store too much stuff in memory?
if (lastKnownHash && typeof(lkh) !== "number") {
waitFor.abort();
return void cb(new Error('EINVAL'));
}
// Since last 2 checkpoints
if (!lastKnownHash) {
waitFor.abort();
// Less than 2 checkpoints in the history: return everything
if (index.cpIndex.length < 2) { return void cb(null, 0); }
// Otherwise return the second last checkpoint's index
return void cb(null, index.cpIndex[0].offset);
/* LATER...
in practice, two checkpoints can be very close together
we have measures to avoid duplicate checkpoints, but editors
can produce nearby checkpoints which are slightly different,
and slip past these protections. To be really careful, we can
seek past nearby checkpoints by some number of patches so as
to ensure that all editors have sufficient knowledge of history
to reconcile their differences. */
}
offset = lkh;
}));
}).nThen((waitFor) => {
// if offset is less than zero then presumably the channel has no messages
// returning falls through to the next block and therefore returns -1
if (offset !== -1) { return; }
// do a lookup from the index
// FIXME maybe we don't need this anymore?
// otherwise we have a non-negative offset and we can start to read from there
store.readMessagesBin(channelName, 0, (msgObj, readMore, abort) => {
// tryParse return a parsed message or undefined
const msg = tryParse(Env, msgObj.buff.toString('utf8'));
// if it was undefined then go onto the next message
if (typeof msg === "undefined") { return readMore(); }
if (typeof(msg[4]) !== 'string' || lastKnownHash !== getHash(msg[4], Log)) {
return void readMore();
}
offset = msgObj.offset;
abort();
}, waitFor(function (err) {
if (err) { waitFor.abort(); return void cb(err); }
}));
}).nThen(() => {
cb(null, offset);
});
};
/* getHistoryAsync
* finds the appropriate byte offset from which to begin reading using 'getHistoryOffset'
* streams through the rest of the messages, safely parsing them and returning the parsed content to the handler
* calls back when it has reached the end of the log
Used by:
* GET_HISTORY
*/
const getHistoryAsync = (Env, channelName, lastKnownHash, beforeHash, handler, cb) => {
const store = Env.store;
let offset = -1;
nThen((waitFor) => {
getHistoryOffset(Env, channelName, lastKnownHash, waitFor((err, os) => {
if (err) {
waitFor.abort();
return void cb(err);
}
offset = os;
}));
}).nThen((waitFor) => {
if (offset === -1) { return void cb(new Error("could not find offset")); }
const start = (beforeHash) ? 0 : offset;
store.readMessagesBin(channelName, start, (msgObj, readMore, abort) => {
if (beforeHash && msgObj.offset >= offset) { return void abort(); }
var parsed = tryParse(Env, msgObj.buff.toString('utf8'));
if (!parsed) { return void readMore(); }
handler(parsed, readMore);
}, waitFor(function (err) {
return void cb(err);
}));
});
};
/* getOlderHistory
* allows clients to query for all messages until a known hash is read
* stores all messages in history as they are read
* can therefore be very expensive for memory
* should probably be converted to a streaming interface
Used by:
* GET_HISTORY_RANGE
*/
const getOlderHistory = function (Env, channelName, oldestKnownHash, cb) {
const store = Env.store;
const Log = Env.Log;
var messageBuffer = [];
var found = false;
store.getMessages(channelName, function (msgStr) {
if (found) { return; }
let parsed = tryParse(Env, msgStr);
if (typeof parsed === "undefined") { return; }
// identify classic metadata messages by their inclusion of a channel.
// and don't send metadata, since:
// 1. the user won't be interested in it
// 2. this metadata is potentially incomplete/incorrect
if (isMetadataMessage(parsed)) { return; }
var content = parsed[4];
if (typeof(content) !== 'string') { return; }
var hash = getHash(content, Log);
if (hash === oldestKnownHash) {
found = true;
}
messageBuffer.push(parsed);
}, function (err) {
if (err) {
Log.error("HK_GET_OLDER_HISTORY", err);
}
cb(messageBuffer);
});
};
const handleRPC = function (Env, Server, seq, userId, parsed) {
const HISTORY_KEEPER_ID = Env.id;
/* RPC Calls... */
var rpc_call = parsed.slice(1);
Server.send(userId, [seq, 'ACK']);
try {
// slice off the sequence number and pass in the rest of the message
Env.rpc(Server, rpc_call, function (err, output) {
if (err) {
Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId, JSON.stringify([parsed[0], 'ERROR', err])]);
return;
}
Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId, JSON.stringify([parsed[0]].concat(output))]);
});
} catch (e) {
// if anything throws in the middle, send an error
Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId, JSON.stringify([parsed[0], 'ERROR', 'SERVER_ERROR'])]);
}
};
const handleGetHistory = function (Env, Server, seq, userId, parsed) {
const store = Env.store;
const tasks = Env.tasks;
const metadata_cache = Env.metadata_cache;
const channel_cache = Env.channel_cache;
const HISTORY_KEEPER_ID = Env.id;
const Log = Env.Log;
// parsed[1] is the channel id
// parsed[2] is a validation key or an object containing metadata (optionnal)
// parsed[3] is the last known hash (optionnal)
Server.send(userId, [seq, 'ACK']);
var channelName = parsed[1];
var config = parsed[2];
var metadata = {};
var lastKnownHash;
var txid;
// clients can optionally pass a map of attributes
// if the channel already exists this map will be ignored
// otherwise it will be stored as the initial metadata state for the channel
if (config && typeof config === "object" && !Array.isArray(parsed[2])) {
lastKnownHash = config.lastKnownHash;
metadata = config.metadata || {};
txid = config.txid;
if (metadata.expire) {
metadata.expire = +metadata.expire * 1000 + (+new Date());
}
}
metadata.channel = channelName;
metadata.created = +new Date();
// if the user sends us an invalid key, we won't be able to validate their messages
// so they'll never get written to the log anyway. Let's just drop their message
// on the floor instead of doing a bunch of extra work
// TODO send them an error message so they know something is wrong
if (metadata.validateKey && !isValidValidateKeyString(metadata.validateKey)) {
return void Log.error('HK_INVALID_KEY', metadata.validateKey);
}
nThen(function (waitFor) {
var w = waitFor();
/* unless this is a young channel, we will serve all messages from an offset
this will not include the channel metadata, so we need to explicitly fetch that.
unfortunately, we can't just serve it blindly, since then young channels will
send the metadata twice, so let's do a quick check of what we're going to serve...
*/
getIndex(Env, channelName, waitFor((err, index) => {
/* if there's an error here, it should be encountered
and handled by the next nThen block.
so, let's just fall through...
*/
if (err) { return w(); }
// it's possible that the channel doesn't have metadata
// but in that case there's no point in checking if the channel expired
// or in trying to send metadata, so just skip this block
if (!index || !index.metadata) { return void w(); }
// And then check if the channel is expired. If it is, send the error and abort
// FIXME this is hard to read because 'checkExpired' has side effects
if (checkExpired(Env, Server, channelName)) { return void waitFor.abort(); }
// always send metadata with GET_HISTORY requests
Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId, JSON.stringify(index.metadata)], w);
}));
}).nThen(() => {
let msgCount = 0;
// TODO compute lastKnownHash in a manner such that it will always skip past the metadata line?
getHistoryAsync(Env, channelName, lastKnownHash, false, (msg, readMore) => {
msgCount++;
// avoid sending the metadata message a second time
if (isMetadataMessage(msg) && metadata_cache[channelName]) { return readMore(); }
if (txid) { msg[0] = txid; }
Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId, JSON.stringify(msg)], readMore);
}, (err) => {
if (err && err.code !== 'ENOENT') {
if (err.message !== 'EINVAL') { Log.error("HK_GET_HISTORY", err); }
const parsedMsg = {error:err.message, channel: channelName, txid: txid};
Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId, JSON.stringify(parsedMsg)]);
return;
}
const chan = channel_cache[channelName];
if (msgCount === 0 && !metadata_cache[channelName] && Server.channelContainsUser(channelName, userId)) {
metadata_cache[channelName] = metadata;
// the index will have already been constructed and cached at this point
// but it will not have detected any metadata because it hasn't been written yet
// this means that the cache starts off as invalid, so we have to correct it
if (chan && chan.index) { chan.index.metadata = metadata; }
// new channels will always have their metadata written to a dedicated metadata log
// but any lines after the first which are not amendments in a particular format will be ignored.
// Thus we should be safe from race conditions here if just write metadata to the log as below...
// TODO validate this logic
// otherwise maybe we need to check that the metadata log is empty as well
store.writeMetadata(channelName, JSON.stringify(metadata), function (err) {
if (err) {
// FIXME tell the user that there was a channel error?
return void Log.error('HK_WRITE_METADATA', {
channel: channelName,
error: err,
});
}
});
// write tasks
if(metadata.expire && typeof(metadata.expire) === 'number') {
// the fun part...
// the user has said they want this pad to expire at some point
tasks.write(metadata.expire, "EXPIRE", [ channelName ], function (err) {
if (err) {
// if there is an error, we don't want to crash the whole server...
// just log it, and if there's a problem you'll be able to fix it
// at a later date with the provided information
Log.error('HK_CREATE_EXPIRE_TASK', err);
Log.info('HK_INVALID_EXPIRE_TASK', JSON.stringify([metadata.expire, 'EXPIRE', channelName]));
}
});
}
Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId, JSON.stringify(metadata)]);
}
// End of history message:
let parsedMsg = {state: 1, channel: channelName, txid: txid};
Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId, JSON.stringify(parsedMsg)]);
});
});
};
const handleGetHistoryRange = function (Env, Server, seq, userId, parsed) {
var channelName = parsed[1];
var map = parsed[2];
const HISTORY_KEEPER_ID = Env.id;
if (!(map && typeof(map) === 'object')) {
return void Server.send(userId, [seq, 'ERROR', 'INVALID_ARGS', HISTORY_KEEPER_ID]);
}
var oldestKnownHash = map.from;
var desiredMessages = map.count;
var desiredCheckpoint = map.cpCount;
var txid = map.txid;
if (typeof(desiredMessages) !== 'number' && typeof(desiredCheckpoint) !== 'number') {
return void Server.send(userId, [seq, 'ERROR', 'UNSPECIFIED_COUNT', HISTORY_KEEPER_ID]);
}
if (!txid) {
return void Server.send(userId, [seq, 'ERROR', 'NO_TXID', HISTORY_KEEPER_ID]);
}
Server.send(userId, [seq, 'ACK']);
return void getOlderHistory(Env, channelName, oldestKnownHash, function (messages) {
var toSend = [];
if (typeof (desiredMessages) === "number") {
toSend = messages.slice(-desiredMessages);
} else {
let cpCount = 0;
for (var i = messages.length - 1; i >= 0; i--) {
if (/^cp\|/.test(messages[i][4]) && i !== (messages.length - 1)) {
cpCount++;
}
toSend.unshift(messages[i]);
if (cpCount >= desiredCheckpoint) { break; }
}
}
toSend.forEach(function (msg) {
Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId,
JSON.stringify(['HISTORY_RANGE', txid, msg])]);
});
Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId,
JSON.stringify(['HISTORY_RANGE_END', txid, channelName])
]);
});
};
const handleGetFullHistory = function (Env, Server, seq, userId, parsed) {
const HISTORY_KEEPER_ID = Env.id;
const Log = Env.Log;
// parsed[1] is the channel id
// parsed[2] is a validation key (optionnal)
// parsed[3] is the last known hash (optionnal)
Server.send(userId, [seq, 'ACK']);
// FIXME should we send metadata here too?
// none of the clientside code which uses this API needs metadata, but it won't hurt to send it (2019-08-22)
return void getHistoryAsync(Env, parsed[1], -1, false, (msg, readMore) => {
Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId, JSON.stringify(['FULL_HISTORY', msg])], readMore);
}, (err) => {
let parsedMsg = ['FULL_HISTORY_END', parsed[1]];
if (err) {
Log.error('HK_GET_FULL_HISTORY', err.stack);
parsedMsg = ['ERROR', parsed[1], err.message];
}
Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId, JSON.stringify(parsedMsg)]);
});
};
const directMessageCommands = {
GET_HISTORY: handleGetHistory,
GET_HISTORY_RANGE: handleGetHistoryRange,
GET_FULL_HISTORY: handleGetFullHistory,
};
/* onDirectMessage
* exported for use by the netflux-server
* parses and handles all direct messages directed to the history keeper
* check if it's expired and execute all the associated side-effects
* routes queries to the appropriate handlers
*/
HK.onDirectMessage = function (Env, Server, seq, userId, json) {
const Log = Env.Log;
Log.silly('HK_MESSAGE', json);
let parsed;
try {
parsed = JSON.parse(json[2]);
} catch (err) {
Log.error("HK_PARSE_CLIENT_MESSAGE", json);
return;
}
// If the requested history is for an expired channel, abort
// Note the if we don't have the keys for that channel in metadata_cache, we'll
// have to abort later (once we know the expiration time)
if (checkExpired(Env, Server, parsed[1])) { return; }
// look up the appropriate command in the map of commands or fall back to RPC
var command = directMessageCommands[parsed[0]] || handleRPC;
// run the command with the standard function signature
command(Env, Server, seq, userId, parsed);
};
/* onChannelMessage
Determine what we should store when a message a broadcasted to a channel"
* ignores ephemeral channels
* ignores messages sent to expired channels
* rejects duplicated checkpoints
* validates messages to channels that have validation keys
* caches the id of the last saved checkpoint
* adds timestamps to incoming messages
* writes messages to the store
*/
HK.onChannelMessage = function (Env, Server, channel, msgStruct) {
const Log = Env.Log;
// TODO our usage of 'channel' here looks prone to errors
// we only use it for its 'id', but it can contain other stuff
// also, we're using this RPC from both the RPC and Netflux-server
// we should probably just change this to expect a channel id directly
// don't store messages if the channel id indicates that it's an ephemeral message
if (!channel.id || channel.id.length === EPHEMERAL_CHANNEL_LENGTH) { return; }
const isCp = /^cp\|/.test(msgStruct[4]);
let id;
if (isCp) {
// id becomes either null or an array or results...
id = CHECKPOINT_PATTERN.exec(msgStruct[4]);
if (Array.isArray(id) && id[2] && id[2] === channel.lastSavedCp) {
// Reject duplicate checkpoints
return;
}
}
let metadata;
nThen(function (w) {
// getIndex (and therefore the latest metadata)
getIndex(Env, channel.id, w(function (err, index) {
if (err) {
w.abort();
return void Log.error('CHANNEL_MESSAGE_ERROR', err);
}
if (!index.metadata) {
// if there's no channel metadata then it can't be an expiring channel
// nor can we possibly validate it
return;
}
metadata = index.metadata;
// don't write messages to expired channels
if (checkExpired(Env, Server, channel)) { return void w.abort(); }
// if there's no validateKey present skip to the next block
if (!metadata.validateKey) { return; }
// trim the checkpoint indicator off the message if it's present
let signedMsg = (isCp) ? msgStruct[4].replace(CHECKPOINT_PATTERN, '') : msgStruct[4];
// convert the message from a base64 string into a Uint8Array
// FIXME this can fail and the client won't notice
signedMsg = Nacl.util.decodeBase64(signedMsg);
// FIXME this can blow up
// TODO check that that won't cause any problems other than not being able to append...
const validateKey = Nacl.util.decodeBase64(metadata.validateKey);
// validate the message
const validated = Nacl.sign.open(signedMsg, validateKey);
if (!validated) {
// don't go any further if the message fails validation
w.abort();
Log.info("HK_SIGNED_MESSAGE_REJECTED", 'Channel '+channel.id);
return;
}
}));
}).nThen(function () {
// do checkpoint stuff...
// 1. get the checkpoint id
// 2. reject duplicate checkpoints
if (isCp) {
// if the message is a checkpoint we will have already validated
// that it isn't a duplicate. remember its id so that we can
// repeat this process for the next incoming checkpoint
// WARNING: the fact that we only check the most recent checkpoints
// is a potential source of bugs if one editor has high latency and
// pushes a duplicate of an earlier checkpoint than the latest which
// has been pushed by editors with low latency
// FIXME
if (Array.isArray(id) && id[2]) {
// Store new checkpoint hash
channel.lastSavedCp = id[2];
}
}
// add the time to the message
msgStruct.push(now());
// storeMessage
storeMessage(Env, channel, JSON.stringify(msgStruct), isCp, getHash(msgStruct[4], Log));
});
};

@ -19,7 +19,7 @@ const Store = require("../storage/file");
const BlobStore = require("../storage/blob"); const BlobStore = require("../storage/blob");
const UNAUTHENTICATED_CALLS = { const UNAUTHENTICATED_CALLS = {
GET_FILE_SIZE: Pinning.getFileSize, // XXX TEST GET_FILE_SIZE: Pinning.getFileSize,
GET_MULTIPLE_FILE_SIZE: Pinning.getMultipleFileSize, GET_MULTIPLE_FILE_SIZE: Pinning.getMultipleFileSize,
GET_DELETED_PADS: Pinning.getDeletedPads, GET_DELETED_PADS: Pinning.getDeletedPads,
IS_CHANNEL_PINNED: Pinning.isChannelPinned, IS_CHANNEL_PINNED: Pinning.isChannelPinned,
@ -60,6 +60,7 @@ const AUTHENTICATED_USER_TARGETED = {
WRITE_LOGIN_BLOCK: Block.writeLoginBlock, WRITE_LOGIN_BLOCK: Block.writeLoginBlock,
REMOVE_LOGIN_BLOCK: Block.removeLoginBlock, REMOVE_LOGIN_BLOCK: Block.removeLoginBlock,
ADMIN: Admin.command, ADMIN: Admin.command,
SET_METADATA: Metadata.setMetadata,
}; };
const AUTHENTICATED_USER_SCOPED = { const AUTHENTICATED_USER_SCOPED = {
@ -70,7 +71,6 @@ const AUTHENTICATED_USER_SCOPED = {
EXPIRE_SESSION: Core.expireSessionAsync, EXPIRE_SESSION: Core.expireSessionAsync,
REMOVE_PINS: Pinning.removePins, REMOVE_PINS: Pinning.removePins,
TRIM_PINS: Pinning.trimPins, TRIM_PINS: Pinning.trimPins,
SET_METADATA: Metadata.setMetadata,
COOKIE: Core.haveACookie, COOKIE: Core.haveACookie,
}; };
@ -232,7 +232,9 @@ RPC.create = function (config, cb) {
myDomain: config.myDomain, myDomain: config.myDomain,
mySubdomain: config.mySubdomain, mySubdomain: config.mySubdomain,
customLimits: config.customLimits, customLimits: config.customLimits,
domain: config.domain // XXX // FIXME this attribute isn't in the default conf
// but it is referenced in Quota
domain: config.domain
}; };
Env.defaultStorageLimit = typeof(config.defaultStorageLimit) === 'number' && config.defaultStorageLimit > 0? Env.defaultStorageLimit = typeof(config.defaultStorageLimit) === 'number' && config.defaultStorageLimit > 0?

96
package-lock.json generated

@ -1,6 +1,6 @@
{ {
"name": "cryptpad", "name": "cryptpad",
"version": "3.10.0", "version": "3.11.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -99,9 +99,9 @@
"integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg="
}, },
"chainpad-crypto": { "chainpad-crypto": {
"version": "0.2.2", "version": "0.2.4",
"resolved": "https://registry.npmjs.org/chainpad-crypto/-/chainpad-crypto-0.2.2.tgz", "resolved": "https://registry.npmjs.org/chainpad-crypto/-/chainpad-crypto-0.2.4.tgz",
"integrity": "sha512-7MJ7qPz/C4sJPsDhPMjdSRmliOCPoRO0XM1vUomcgXA6HINlW+if9AAt/H4q154nYhZ/b57njgC6cWgd/RDidg==", "integrity": "sha512-fWbVyeAv35vf/dkkQaefASlJcEfpEvfRI23Mtn+/TBBry7+LYNuJMXJiovVY35pfyw2+trKh1Py5Asg9vrmaVg==",
"requires": { "requires": {
"tweetnacl": "git://github.com/dchest/tweetnacl-js.git#v0.12.2" "tweetnacl": "git://github.com/dchest/tweetnacl-js.git#v0.12.2"
}, },
@ -113,9 +113,9 @@
} }
}, },
"chainpad-server": { "chainpad-server": {
"version": "4.0.1", "version": "4.0.2",
"resolved": "https://registry.npmjs.org/chainpad-server/-/chainpad-server-4.0.1.tgz", "resolved": "https://registry.npmjs.org/chainpad-server/-/chainpad-server-4.0.2.tgz",
"integrity": "sha512-duV57hO0o2cKaOwwWdDeO3hgN2thAqoQENrjozhamGrUjF9bFiNW2cq3Dg3HjOY6yeMNIGgj0jMuLJjTSERKhQ==", "integrity": "sha512-9NrFsATd70uAdksxsCZBIJ/SiREmJ6QLYTNaeFLH/nJpeZ2b7wblVGABCj3JYWvngdEZ7Umc+afbWH8sUmtgeQ==",
"requires": { "requires": {
"nthen": "0.1.8", "nthen": "0.1.8",
"pull-stream": "^3.6.9", "pull-stream": "^3.6.9",
@ -160,9 +160,9 @@
"dev": true "dev": true
}, },
"commander": { "commander": {
"version": "2.20.0", "version": "2.20.3",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
"integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==", "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
"dev": true "dev": true
}, },
"concat-map": { "concat-map": {
@ -240,9 +240,9 @@
} }
}, },
"dom-serializer": { "dom-serializer": {
"version": "0.2.1", "version": "0.2.2",
"resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.2.1.tgz", "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.2.2.tgz",
"integrity": "sha512-sK3ujri04WyjwQXVoK4PU3y8ula1stq10GJZpqHIUgoGZdsGzAGu65BnU3d08aTVSvO7mGPZUc0wTEDL+qGE0Q==", "integrity": "sha512-2/xPb3ORsQ42nHYiSunXkDjPLBaEj/xTwUO4B7XCZQTRk7EBtTOPaygh10YAAh2OI1Qrp6NWfpAhzswj0ydt9g==",
"dev": true, "dev": true,
"requires": { "requires": {
"domelementtype": "^2.0.1", "domelementtype": "^2.0.1",
@ -397,15 +397,9 @@
} }
}, },
"flatten": { "flatten": {
"version": "1.0.2", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/flatten/-/flatten-1.0.2.tgz", "resolved": "https://registry.npmjs.org/flatten/-/flatten-1.0.3.tgz",
"integrity": "sha1-2uRqnXj74lKSJYzB54CkHZXAN4I=", "integrity": "sha512-dVsPA/UwQ8+2uoFe5GHtiBMu48dWLTdsuEd7CKGlZlD78r1TTWBvDuFaFGKCo/ZfEr95Uk56vZoX86OsHkUeIg==",
"dev": true
},
"flow-bin": {
"version": "0.59.0",
"resolved": "https://registry.npmjs.org/flow-bin/-/flow-bin-0.59.0.tgz",
"integrity": "sha512-yJDRffvby5mCTkbwOdXwiGDjeea8Z+BPVuP53/tHqHIZC+KtQD790zopVf7mHk65v+wRn+TZ7tkRSNA9oDmyLg==",
"dev": true "dev": true
}, },
"forwarded": { "forwarded": {
@ -449,9 +443,9 @@
} }
}, },
"glob": { "glob": {
"version": "7.1.4", "version": "7.1.6",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
"integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==",
"dev": true, "dev": true,
"requires": { "requires": {
"fs.realpath": "^1.0.0", "fs.realpath": "^1.0.0",
@ -477,9 +471,9 @@
} }
}, },
"graceful-fs": { "graceful-fs": {
"version": "4.2.2", "version": "4.2.3",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.2.tgz", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz",
"integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==" "integrity": "sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ=="
}, },
"has-ansi": { "has-ansi": {
"version": "2.0.0", "version": "2.0.0",
@ -592,9 +586,9 @@
"dev": true "dev": true
}, },
"jshint": { "jshint": {
"version": "2.10.2", "version": "2.11.0",
"resolved": "https://registry.npmjs.org/jshint/-/jshint-2.10.2.tgz", "resolved": "https://registry.npmjs.org/jshint/-/jshint-2.11.0.tgz",
"integrity": "sha512-e7KZgCSXMJxznE/4WULzybCMNXNAd/bf5TSrvVEq78Q/K8ZwFpmBqQeDtNiHc3l49nV4E/+YeHU/JZjSUIrLAA==", "integrity": "sha512-ooaD/hrBPhu35xXW4gn+o3SOuzht73gdBuffgJzrZBJZPGgGiiTvJEgTyxFvBO2nz0+X1G6etF8SzUODTlLY6Q==",
"dev": true, "dev": true,
"requires": { "requires": {
"cli": "~1.0.0", "cli": "~1.0.0",
@ -634,9 +628,9 @@
"dev": true "dev": true
}, },
"readable-stream": { "readable-stream": {
"version": "2.3.6", "version": "2.3.7",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz",
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==",
"dev": true, "dev": true,
"requires": { "requires": {
"core-util-is": "~1.0.0", "core-util-is": "~1.0.0",
@ -765,16 +759,16 @@
"integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==" "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ=="
}, },
"mime-db": { "mime-db": {
"version": "1.40.0", "version": "1.43.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.43.0.tgz",
"integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==" "integrity": "sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ=="
}, },
"mime-types": { "mime-types": {
"version": "2.1.24", "version": "2.1.26",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.26.tgz",
"integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", "integrity": "sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ==",
"requires": { "requires": {
"mime-db": "1.40.0" "mime-db": "1.43.0"
} }
}, },
"minimatch": { "minimatch": {
@ -847,9 +841,9 @@
"dev": true "dev": true
}, },
"pako": { "pako": {
"version": "1.0.10", "version": "1.0.11",
"resolved": "https://registry.npmjs.org/pako/-/pako-1.0.10.tgz", "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz",
"integrity": "sha512-0DTvPVU3ed8+HNXOu5Bs+o//Mbdj9VNQMUOe9oKCwh8l0GNwpTDMKCWbRjgtD291AWnkAgkqA/LOnQS8AmS1tw==", "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==",
"dev": true "dev": true
}, },
"parseurl": { "parseurl": {
@ -1304,19 +1298,19 @@
} }
}, },
"xml2js": { "xml2js": {
"version": "0.4.19", "version": "0.4.23",
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz", "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz",
"integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==", "integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==",
"dev": true, "dev": true,
"requires": { "requires": {
"sax": ">=0.6.0", "sax": ">=0.6.0",
"xmlbuilder": "~9.0.1" "xmlbuilder": "~11.0.0"
} }
}, },
"xmlbuilder": { "xmlbuilder": {
"version": "9.0.7", "version": "11.0.1",
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz",
"integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=", "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==",
"dev": true "dev": true
} }
} }

@ -1,7 +1,7 @@
{ {
"name": "cryptpad", "name": "cryptpad",
"description": "realtime collaborative visual editor with zero knowlege server", "description": "realtime collaborative visual editor with zero knowlege server",
"version": "3.10.0", "version": "3.11.0",
"license": "AGPL-3.0+", "license": "AGPL-3.0+",
"repository": { "repository": {
"type": "git", "type": "git",
@ -27,7 +27,6 @@
"ws": "^3.3.1" "ws": "^3.3.1"
}, },
"devDependencies": { "devDependencies": {
"flow-bin": "^0.59.0",
"jshint": "^2.10.2", "jshint": "^2.10.2",
"less": "2.7.1", "less": "2.7.1",
"lesshint": "^4.5.0", "lesshint": "^4.5.0",
@ -42,7 +41,6 @@
"lint:js": "jshint --config .jshintrc --exclude-path .jshintignore .", "lint:js": "jshint --config .jshintrc --exclude-path .jshintignore .",
"lint:server": "jshint --config .jshintrc lib", "lint:server": "jshint --config .jshintrc lib",
"lint:less": "./node_modules/lesshint/bin/lesshint -c ./.lesshintrc ./customize.dist/src/less2/", "lint:less": "./node_modules/lesshint/bin/lesshint -c ./.lesshintrc ./customize.dist/src/less2/",
"flow": "./node_modules/.bin/flow",
"test": "node scripts/TestSelenium.js", "test": "node scripts/TestSelenium.js",
"test-rpc": "cd scripts/tests && node test-rpc", "test-rpc": "cd scripts/tests && node test-rpc",
"template": "cd customize.dist/src && for page in ../index.html ../privacy.html ../terms.html ../about.html ../contact.html ../what-is-cryptpad.html ../features.html ../../www/login/index.html ../../www/register/index.html ../../www/user/index.html;do echo $page; cp template.html $page; done;", "template": "cd customize.dist/src && for page in ../index.html ../privacy.html ../terms.html ../about.html ../contact.html ../what-is-cryptpad.html ../features.html ../../www/login/index.html ../../www/register/index.html ../../www/user/index.html;do echo $page; cp template.html $page; done;",

@ -160,8 +160,8 @@ var createUser = function (config, cb) {
wc.leave(); wc.leave();
})); }));
}).nThen(function (w) { }).nThen(function (w) {
// give the server time to write your mailbox data before checking that it's correct // FIXME give the server time to write your mailbox data before checking that it's correct
// XXX chainpad-server sends an ACK before the channel has actually been created // chainpad-server sends an ACK before the channel has actually been created
// causing you to think that everything is good. // causing you to think that everything is good.
// without this timeout the GET_METADATA rpc occasionally returns before // without this timeout the GET_METADATA rpc occasionally returns before
// the metadata has actually been written to the disk. // the metadata has actually been written to the disk.
@ -234,6 +234,18 @@ var createUser = function (config, cb) {
return void cb(err); return void cb(err);
} }
})); }));
}).nThen(function (w) {
// some basic sanity checks...
user.rpc.getServerHash(w(function (err, hash) {
if (err) {
w.abort();
return void cb(err);
}
if (hash !== EMPTY_ARRAY_HASH) {
console.error("EXPECTED EMPTY ARRAY HASH");
process.exit(1);
}
}));
}).nThen(function () { }).nThen(function () {
user.cleanup = function (cb) { user.cleanup = function (cb) {

@ -1124,7 +1124,7 @@ module.exports.create = function (conf, cb) {
// iterate over the messages in a log // iterate over the messages in a log
readMessagesBin: (channelName, start, asyncMsgHandler, cb) => { readMessagesBin: (channelName, start, asyncMsgHandler, cb) => {
if (!isValidChannelId(channelName)) { return void cb(new Error('EINVAL')); } if (!isValidChannelId(channelName)) { return void cb(new Error('EINVAL')); }
// XXX there is a race condition here // FIXME there is a race condition here
// historyKeeper reads the file to find the byte offset of the first interesting message // historyKeeper reads the file to find the byte offset of the first interesting message
// then calls this function again to read from that point. // then calls this function again to read from that point.
// If this task is in the queue already when the file is read again // If this task is in the queue already when the file is read again
@ -1144,7 +1144,7 @@ module.exports.create = function (conf, cb) {
// remove a channel and its associated metadata log if present // remove a channel and its associated metadata log if present
removeChannel: function (channelName, cb) { removeChannel: function (channelName, cb) {
if (!isValidChannelId(channelName)) { return void cb(new Error('EINVAL')); } if (!isValidChannelId(channelName)) { return void cb(new Error('EINVAL')); }
// XXX there's another race condition here... // FIXME there's another race condition here...
// when a remove and an append are scheduled in that order // when a remove and an append are scheduled in that order
// the remove will delete the channel's metadata (including its validateKey) // the remove will delete the channel's metadata (including its validateKey)
// then the append will recreate the channel and insert a message. // then the append will recreate the channel and insert a message.

@ -27,6 +27,8 @@
.cp-support-list-actions { .cp-support-list-actions {
margin: 10px 0px 10px 2px; margin: 10px 0px 10px 2px;
} }
.cp-support-list-ticket:not(.cp-support-list-closed) {
.cp-support-list-message { .cp-support-list-message {
&:last-child:not(.cp-support-fromadmin) { &:last-child:not(.cp-support-fromadmin) {
color: @colortheme_cp-red; color: @colortheme_cp-red;
@ -36,6 +38,7 @@
} }
} }
} }
}
.cp-support-fromadmin { .cp-support-fromadmin {
color: @colortheme_logo-2; color: @colortheme_logo-2;

@ -62,7 +62,9 @@ var factory = function (Util, Crypto, Nacl) {
}; };
Hash.getHiddenHashFromKeys = function (type, secret, opts) { Hash.getHiddenHashFromKeys = function (type, secret, opts) {
var mode = ((secret.keys && secret.keys.editKeyStr) || secret.key) ? 'edit/' : 'view/'; opts = opts || {};
var canEdit = (secret.keys && secret.keys.editKeyStr) || secret.key;
var mode = (!opts.view && canEdit) ? 'edit/' : 'view/';
var pass = secret.password ? 'p/' : ''; var pass = secret.password ? 'p/' : '';
if (secret.keys && secret.keys.fileKeyStr) { mode = ''; } if (secret.keys && secret.keys.fileKeyStr) { mode = ''; }

@ -70,6 +70,7 @@ define([
if (typeof(yes) === 'function') { yes(e); } if (typeof(yes) === 'function') { yes(e); }
break; break;
} }
$(el || window).off('keydown', handler);
}; };
$(el || window).keydown(handler); $(el || window).keydown(handler);
@ -587,7 +588,7 @@ define([
$ok.click(); $ok.click();
}, function () { }, function () {
$cancel.click(); $cancel.click();
}, ok); }, frame);
document.body.appendChild(frame); document.body.appendChild(frame);
setTimeout(function () { setTimeout(function () {
@ -1117,7 +1118,7 @@ define([
var dontShowAgain = h('div.cp-corner-dontshow', [ var dontShowAgain = h('div.cp-corner-dontshow', [
h('span.fa.fa-times'), h('span.fa.fa-times'),
Messages.dontShowAgain || "Don't show again" // XXX Messages.dontShowAgain
]); ]);
var popup = h('div.cp-corner-container', [ var popup = h('div.cp-corner-container', [

@ -554,21 +554,27 @@ define([
if (!data.noPassword) { if (!data.noPassword) {
var hasPassword = data.password; var hasPassword = data.password;
if (hasPassword) { var $pwLabel = $('<label>', {'for': 'cp-app-prop-password'}).text(Messages.creation_passwordValue)
$('<label>', {'for': 'cp-app-prop-password'}).text(Messages.creation_passwordValue) .hide().appendTo($d);
.appendTo($d);
var password = UI.passwordInput({ var password = UI.passwordInput({
id: 'cp-app-prop-password', id: 'cp-app-prop-password',
readonly: 'readonly' readonly: 'readonly'
}); });
var $pwInput = $(password).find('.cp-password-input'); var $password = $(password).hide();
var $pwInput = $password.find('.cp-password-input');
$pwInput.val(data.password).click(function () { $pwInput.val(data.password).click(function () {
$pwInput[0].select(); $pwInput[0].select();
}); });
$d.append(password); $d.append(password);
if (hasPassword) {
$pwLabel.show();
$password.css('display', 'flex');
} }
if (!data.noEditPassword && owned) { // FIXME SHEET fix password change for sheets // In the properties, we should have the edit href if we know it.
// We should know it because the pad is stored, but it's better to check...
if (!data.noEditPassword && owned && data.href) { // FIXME SHEET fix password change for sheets
var sframeChan = common.getSframeChannel(); var sframeChan = common.getSframeChannel();
var isOO = parsed.type === 'sheet'; var isOO = parsed.type === 'sheet';
@ -628,7 +634,7 @@ define([
sframeChan.query(q, { sframeChan.query(q, {
teamId: typeof(owned) !== "boolean" ? owned : undefined, teamId: typeof(owned) !== "boolean" ? owned : undefined,
href: data.href || data.roHref, href: data.href,
password: newPass password: newPass
}, function (err, data) { }, function (err, data) {
$(passwordOk).text(Messages.properties_changePasswordButton); $(passwordOk).text(Messages.properties_changePasswordButton);
@ -638,24 +644,41 @@ define([
return void UI.alert(Messages.properties_passwordError); return void UI.alert(Messages.properties_passwordError);
} }
UI.findOKButton().click(); UI.findOKButton().click();
if (isFile) {
onProgress.stop(); $pwLabel.show();
$password.css('display', 'flex');
$pwInput.val(newPass);
// If the current document is a file or if we're changing the password from a drive,
// we don't have to reload the page at the end.
// Tell the user the password change was successful and abort
if (isFile || priv.app !== parsed.type) {
if (onProgress && onProgress.stop) { onProgress.stop(); }
$(passwordOk).text(Messages.properties_changePasswordButton); $(passwordOk).text(Messages.properties_changePasswordButton);
var alertMsg = data.warning ? Messages.properties_passwordWarningFile var alertMsg = data.warning ? Messages.properties_passwordWarningFile
: Messages.properties_passwordSuccessFile; : Messages.properties_passwordSuccessFile;
return void UI.alert(alertMsg, undefined, {force: true}); return void UI.alert(alertMsg, undefined, {force: true});
} }
// If we didn't have a password, we have to add the /p/
// If we had a password and we changed it to a new one, we just have to reload // Pad password changed: update the href
// If we had a password and we removed it, we have to remove the /p/ // Use hidden hash if needed (we're an owner of this pad so we know it is stored)
var useUnsafe = Util.find(priv, ['settings', 'security', 'unsafeLinks']);
var href = (priv.readOnly && data.roHref) ? data.roHref : data.href;
if (useUnsafe === false) {
var newParsed = Hash.parsePadUrl(href);
var newSecret = Hash.getSecrets(newParsed.type, newParsed.hash, newPass);
var newHash = Hash.getHiddenHashFromKeys(parsed.type, newSecret, {});
href = Hash.hashToHref(newHash, parsed.type);
}
if (data.warning) { if (data.warning) {
return void UI.alert(Messages.properties_passwordWarning, function () { return void UI.alert(Messages.properties_passwordWarning, function () {
common.gotoURL(hasPassword && newPass ? undefined : (data.href || data.roHref)); common.gotoURL(href);
}, {force: true}); }, {force: true});
} }
return void UI.alert(Messages.properties_passwordSuccess, function () { return void UI.alert(Messages.properties_passwordSuccess, function () {
if (!isSharedFolder) { if (!isSharedFolder) {
common.gotoURL(hasPassword && newPass ? undefined : (data.href || data.roHref)); common.gotoURL(href);
} }
}, {force: true}); }, {force: true});
}); });
@ -3817,7 +3840,7 @@ define([
]); ]);
var settings = h('div.cp-creation-remember', [ var settings = h('div.cp-creation-remember', [
UI.createCheckbox('cp-creation-remember', Messages.creation_saveSettings, false), UI.createCheckbox('cp-creation-remember', Messages.dontShowAgain, false),
createHelper('/settings/#creation', Messages.creation_settings), createHelper('/settings/#creation', Messages.creation_settings),
h('div.cp-creation-remember-help.cp-creation-slider', [ h('div.cp-creation-remember-help.cp-creation-slider', [
h('span.fa.fa-exclamation-circle.cp-creation-warning'), h('span.fa.fa-exclamation-circle.cp-creation-warning'),

@ -1037,11 +1037,12 @@ define([
}, waitFor()); }, waitFor());
} }
}).nThen(function () { }).nThen(function () {
common.drive.onChange.fire({path: ['drive', Constants.storageKey]});
cb({ cb({
warning: warning, warning: warning,
hash: newHash, hash: newHash,
href: newHref, href: newHref,
roHref: newRoHref roHref: newRoHref,
}); });
}); });
}; };
@ -1170,6 +1171,7 @@ define([
channel: newSecret.channel channel: newSecret.channel
}, waitFor()); }, waitFor());
}).nThen(function () { }).nThen(function () {
common.drive.onChange.fire({path: ['drive', Constants.storageKey]});
cb({ cb({
warning: warning, warning: warning,
hash: newHash, hash: newHash,
@ -1404,6 +1406,7 @@ define([
}, waitFor()); }, waitFor());
})); }));
}).nThen(function () { }).nThen(function () {
common.drive.onChange.fire({path: ['drive', Constants.storageKey]});
cb({ cb({
warning: warning, warning: warning,
hash: newHash, hash: newHash,
@ -2121,7 +2124,10 @@ define([
var parsedNew = Hash.parsePadUrl(newHref); var parsedNew = Hash.parsePadUrl(newHref);
if (parsedOld.hashData && parsedNew.hashData && if (parsedOld.hashData && parsedNew.hashData &&
parsedOld.getUrl() !== parsedNew.getUrl()) { parsedOld.getUrl() !== parsedNew.getUrl()) {
if (!parsedOld.hashData.key) { oldHref = newHref; return; } if (parsedOld.hashData.version !== 3 && !parsedOld.hashData.key) {
oldHref = newHref;
return;
}
// If different, reload // If different, reload
document.location.reload(); document.location.reload();
return; return;

@ -587,7 +587,7 @@ define([
var displayedCategories = [ROOT, TRASH, SEARCH, RECENT]; var displayedCategories = [ROOT, TRASH, SEARCH, RECENT];
// PCS enabled: display owned pads // PCS enabled: display owned pads
if (AppConfig.displayCreationScreen) { displayedCategories.push(OWNED); } //if (AppConfig.displayCreationScreen) { displayedCategories.push(OWNED); }
// Templates enabled: display template category // Templates enabled: display template category
if (AppConfig.enableTemplates) { displayedCategories.push(TEMPLATE); } if (AppConfig.enableTemplates) { displayedCategories.push(TEMPLATE); }
// Tags used: display Tags category // Tags used: display Tags category
@ -1037,18 +1037,16 @@ define([
var href = isRo ? data.roHref : (data.href || data.roHref); var href = isRo ? data.roHref : (data.href || data.roHref);
var priv = metadataMgr.getPrivateData(); var priv = metadataMgr.getPrivateData();
var useUnsafe = Util.find(priv, ['settings', 'security', 'unsafeLinks']); var useUnsafe = Util.find(priv, ['settings', 'security', 'unsafeLinks']);
if (useUnsafe) { if (useUnsafe !== false) { // true of undefined: use unsafe links
return void window.open(APP.origin + href); return void window.open(APP.origin + href);
} }
// Get hidden hash // Get hidden hash
var parsed = Hash.parsePadUrl(href); var parsed = Hash.parsePadUrl(href);
var secret = Hash.getSecrets(parsed.type, parsed.hash, data.password); var secret = Hash.getSecrets(parsed.type, parsed.hash, data.password);
if (isRo && secret.keys && secret.keys.editKeyStr) { var opts = {};
delete secret.keys.editKeyStr; if (isRo) { opts.view = true; }
delete secret.key; var hash = Hash.getHiddenHashFromKeys(parsed.type, secret, opts);
}
var hash = Hash.getHiddenHashFromKeys(parsed.type, secret);
var hiddenHref = Hash.hashToHref(hash, parsed.type); var hiddenHref = Hash.hashToHref(hash, parsed.type);
window.open(APP.origin + hiddenHref); window.open(APP.origin + hiddenHref);
}; };
@ -1177,14 +1175,10 @@ define([
} else if ($element.is('.cp-app-drive-element-noreadonly')) { } else if ($element.is('.cp-app-drive-element-noreadonly')) {
hide.push('openro'); // Remove open 'view' mode hide.push('openro'); // Remove open 'view' mode
} }
// if it's not a plain text file
// XXX: there is a bug with this code in anon shared folder, so we disable it
if (APP.loggedIn || !APP.newSharedFolder) {
var metadata = manager.getFileData(manager.find(path)); var metadata = manager.getFileData(manager.find(path));
if (!metadata || !Util.isPlainTextFile(metadata.fileType, metadata.title)) { if (!metadata || !Util.isPlainTextFile(metadata.fileType, metadata.title)) {
hide.push('openincode'); hide.push('openincode');
} }
}
} else if ($element.is('.cp-app-drive-element-sharedf')) { } else if ($element.is('.cp-app-drive-element-sharedf')) {
if (containsFolder) { if (containsFolder) {
// More than 1 folder selected: cannot create a new subfolder // More than 1 folder selected: cannot create a new subfolder
@ -1206,8 +1200,7 @@ define([
hide.push('collapseall'); hide.push('collapseall');
} }
containsFolder = true; containsFolder = true;
hide.push('share'); // XXX CONVERT hide.push('savelocal');
hide.push('savelocal'); // XXX CONVERT
hide.push('openro'); hide.push('openro');
hide.push('openincode'); hide.push('openincode');
hide.push('properties'); hide.push('properties');
@ -1943,6 +1936,44 @@ define([
}; };
var getIcon = UI.getIcon; var getIcon = UI.getIcon;
var createShareButton = function (id, $container) {
var $shareBlock = $('<button>', {
'class': 'cp-toolbar-share-button',
title: Messages.shareButton
});
$sharedIcon.clone().appendTo($shareBlock);
$('<span>').text(Messages.shareButton).appendTo($shareBlock);
var data = manager.getSharedFolderData(id);
var parsed = (data.href && data.href.indexOf('#') !== -1) ? Hash.parsePadUrl(data.href) : {};
var roParsed = Hash.parsePadUrl(data.roHref) || {};
if (!parsed.hash && !roParsed.hash) { return void console.error("Invalid href: "+(data.href || data.roHref)); }
var friends = common.getFriends();
var ro = folders[id] && folders[id].version >= 2;
var modal = UIElements.createShareModal({
teamId: APP.team,
origin: APP.origin,
pathname: "/drive/",
friends: friends,
title: data.title,
password: data.password,
sharedFolder: true,
common: common,
hashes: {
editHash: parsed.hash,
viewHash: ro && roParsed.hash,
}
});
// If we're a viewer and this is an old shared folder (no read-only mode), we
// can't share the read-only URL and we don't have access to the edit one.
// We should hide the share button.
if (!modal) { return; }
$shareBlock.click(function () {
UI.openCustomModal(modal);
});
$container.append($shareBlock);
return $shareBlock;
};
// Create the "li" element corresponding to the file/folder located in "path" // Create the "li" element corresponding to the file/folder located in "path"
var createElement = function (path, elPath, root, isFolder) { var createElement = function (path, elPath, root, isFolder) {
// Forbid drag&drop inside the trash // Forbid drag&drop inside the trash
@ -2023,6 +2054,15 @@ define([
}); });
delete APP.newFolder; delete APP.newFolder;
} }
if (isSharedFolder && APP.convertedFolder === element) {
setTimeout(function () {
var $fakeButton = createShareButton(element, $('<div>'));
if (!$fakeButton) { return; }
$fakeButton.click();
}, 100);
}
return $element; return $element;
}; };
@ -2560,43 +2600,6 @@ define([
$container.append($block); $container.append($block);
}; };
var createShareButton = function (id, $container) {
var $shareBlock = $('<button>', {
'class': 'cp-toolbar-share-button',
title: Messages.shareButton
});
$sharedIcon.clone().appendTo($shareBlock);
$('<span>').text(Messages.shareButton).appendTo($shareBlock);
var data = manager.getSharedFolderData(id);
var parsed = (data.href && data.href.indexOf('#') !== -1) ? Hash.parsePadUrl(data.href) : {};
var roParsed = Hash.parsePadUrl(data.roHref) || {};
if (!parsed.hash && !roParsed.hash) { return void console.error("Invalid href: "+(data.href || data.roHref)); }
var friends = common.getFriends();
var ro = folders[id] && folders[id].version >= 2;
var modal = UIElements.createShareModal({
teamId: APP.team,
origin: APP.origin,
pathname: "/drive/",
friends: friends,
title: data.title,
password: data.password,
sharedFolder: true,
common: common,
hashes: {
editHash: parsed.hash,
viewHash: ro && roParsed.hash,
}
});
// If we're a viewer and this is an old shared folder (no read-only mode), we
// can't share the read-only URL and we don't have access to the edit one.
// We should hide the share button.
if (!modal) { return; }
$shareBlock.click(function () {
UI.openCustomModal(modal);
});
$container.append($shareBlock);
};
var SORT_FOLDER_DESC = 'sortFoldersDesc'; var SORT_FOLDER_DESC = 'sortFoldersDesc';
var SORT_FILE_BY = 'sortFilesBy'; var SORT_FILE_BY = 'sortFilesBy';
var SORT_FILE_DESC = 'sortFilesDesc'; var SORT_FILE_DESC = 'sortFilesDesc';
@ -3241,21 +3244,23 @@ define([
var path = currentPath.slice(1); var path = currentPath.slice(1);
var root = Util.find(data, path); var root = Util.find(data, path);
var realPath = [ROOT, SHARED_FOLDER].concat(path);
if (manager.hasSubfolder(root)) { $list.append($folderHeader); } if (manager.hasSubfolder(root)) { $list.append($folderHeader); }
// display sub directories // display sub directories
var keys = Object.keys(root); var keys = Object.keys(root);
var sortedFolders = sortElements(true, currentPath, keys, null, !getSortFolderDesc()); var sortedFolders = sortElements(true, realPath, keys, null, !getSortFolderDesc());
var sortedFiles = sortElements(false, currentPath, keys, APP.store[SORT_FILE_BY], !getSortFileDesc()); var sortedFiles = sortElements(false, realPath, keys, APP.store[SORT_FILE_BY], !getSortFileDesc());
sortedFolders.forEach(function (key) { sortedFolders.forEach(function (key) {
if (manager.isFile(root[key])) { return; } if (manager.isFile(root[key])) { return; }
var $element = createElement(currentPath, key, root, true); var $element = createElement(realPath, key, root, true);
$element.appendTo($list); $element.appendTo($list);
}); });
if (manager.hasFile(root)) { $list.append($fileHeader); } if (manager.hasFile(root)) { $list.append($fileHeader); }
// display files // display files
sortedFiles.forEach(function (key) { sortedFiles.forEach(function (key) {
if (manager.isFolder(root[key])) { return; } if (manager.isFolder(root[key])) { return; }
var $element = createElement(currentPath, key, root, false); var $element = createElement(realPath, key, root, false);
if (!$element) { return; } if (!$element) { return; }
$element.appendTo($list); $element.appendTo($list);
}); });
@ -3340,7 +3345,9 @@ define([
// in history mode we want to focus the version number input // in history mode we want to focus the version number input
if (!history.isHistoryMode && !APP.mobile()) { if (!history.isHistoryMode && !APP.mobile()) {
var st = $tree.scrollTop() || 0; var st = $tree.scrollTop() || 0;
if (!$('.alertify').length) {
$tree.find('#cp-app-drive-tree-search-input').focus(); $tree.find('#cp-app-drive-tree-search-input').focus();
}
$tree.scrollTop(st); $tree.scrollTop(st);
} }
$tree.find('#cp-app-drive-tree-search-input')[0].selectionStart = getSearchCursor(); $tree.find('#cp-app-drive-tree-search-input')[0].selectionStart = getSearchCursor();
@ -3490,6 +3497,9 @@ define([
} else { } else {
$content.scrollTop(s); $content.scrollTop(s);
} }
delete APP.convertedFolder;
appStatus.ready(true); appStatus.ready(true);
}; };
var displayDirectory = APP.displayDirectory = function (path, force) { var displayDirectory = APP.displayDirectory = function (path, force) {
@ -3977,6 +3987,14 @@ define([
common.sessionStorage.put(Constants.newPadTeamKey, APP.team, waitFor()); common.sessionStorage.put(Constants.newPadTeamKey, APP.team, waitFor());
}).nThen(function () { }).nThen(function () {
common.openURL('/code/'); common.openURL('/code/');
// We need to restore sessionStorage for the next time we want to create a pad from this tab
// NOTE: the 100ms timeout is to fix a race condition in firefox where sessionStorage
// would be deleted before the new tab was created
setTimeout(function () {
common.sessionStorage.put(Constants.newPadFileData, '', function () {});
common.sessionStorage.put(Constants.newPadPathKey, '', function () {});
common.sessionStorage.put(Constants.newPadTeamKey, '', function () {});
}, 100);
}); });
} }
@ -4056,8 +4074,7 @@ define([
if (manager.isFolder(el) && !manager.isSharedFolder(el)) { // Folder if (manager.isFolder(el) && !manager.isSharedFolder(el)) { // Folder
// if folder is inside SF // if folder is inside SF
return UI.warn('ERROR: Temporarily disabled'); // XXX CONVERT if (manager.isInSharedFolder(paths[0].path)) {
/*if (manager.isInSharedFolder(paths[0].path)) {
return void UI.alert(Messages.convertFolderToSF_SFParent); return void UI.alert(Messages.convertFolderToSF_SFParent);
} }
// if folder already contains SF // if folder already contains SF
@ -4085,10 +4102,14 @@ define([
if (!res) { return; } if (!res) { return; }
var password = $(convertContent).find('#cp-upload-password').val() || undefined; var password = $(convertContent).find('#cp-upload-password').val() || undefined;
var owned = Util.isChecked($(convertContent).find('#cp-upload-owned')); var owned = Util.isChecked($(convertContent).find('#cp-upload-owned'));
manager.convertFolderToSharedFolder(paths[0].path, owned, password, refresh); manager.convertFolderToSharedFolder(paths[0].path, owned, password, function (err, obj) {
if (err || obj && obj.error) { return void console.error(err || obj.error); }
if (obj && obj.fId) { APP.convertedFolder = obj.fId; }
refresh();
}); });
}*/ });
} else { // File }
} else { // File or shared folder
var sf = manager.isSharedFolder(el); var sf = manager.isSharedFolder(el);
data = sf ? manager.getSharedFolderData(el) : manager.getFileData(el); data = sf ? manager.getSharedFolderData(el) : manager.getFileData(el);
parsed = (data.href && data.href.indexOf('#') !== -1) ? Hash.parsePadUrl(data.href) : {}; parsed = (data.href && data.href.indexOf('#') !== -1) ? Hash.parsePadUrl(data.href) : {};

@ -33,6 +33,16 @@ define([
NetConfig, AppConfig, NetConfig, AppConfig,
Crypto, ChainPad, CpNetflux, Listmap, nThen, Saferphore) { Crypto, ChainPad, CpNetflux, Listmap, nThen, Saferphore) {
// Default settings for new users
var NEW_USER_SETTINGS = {
drive: {
hideDuplicate: true
},
general: {
allowUserFeedback: true
}
};
var create = function () { var create = function () {
var Store = window.Cryptpad_Store = {}; var Store = window.Cryptpad_Store = {};
var postMessage = function () {}; var postMessage = function () {};
@ -2284,7 +2294,7 @@ define([
if (!store.loggedIn) { return void cb(); } if (!store.loggedIn) { return void cb(); }
Store.pinPads(null, data, cb); Store.pinPads(null, data, cb);
}; };
if (!proxy.settings) { proxy.settings = {}; } if (!proxy.settings) { proxy.settings = NEW_USER_SETTINGS; }
if (!proxy.friends_pending) { proxy.friends_pending = {}; } if (!proxy.friends_pending) { proxy.friends_pending = {}; }
var manager = store.manager = ProxyManager.create(proxy.drive, { var manager = store.manager = ProxyManager.create(proxy.drive, {
onSync: function (cb) { onSync(null, cb); }, onSync: function (cb) { onSync(null, cb); },
@ -2370,13 +2380,7 @@ define([
} }
} }
if (!proxy.settings || !proxy.settings.general || returned.feedback = Util.find(proxy, ['settings', 'general', 'allowUserFeedback']);
typeof(proxy.settings.general.allowUserFeedback) !== 'boolean') {
proxy.settings = proxy.settings || {};
proxy.settings.general = proxy.settings.general || {};
proxy.settings.general.allowUserFeedback = true;
}
returned.feedback = proxy.settings.general.allowUserFeedback;
Feedback.init(returned.feedback); Feedback.init(returned.feedback);
if (typeof(cb) === 'function') { cb(returned); } if (typeof(cb) === 'function') { cb(returned); }

@ -587,14 +587,10 @@ define([
// convert a folder to a Shared Folder // convert a folder to a Shared Folder
var _convertFolderToSharedFolder = function (Env, data, cb) { var _convertFolderToSharedFolder = function (Env, data, cb) {
return void cb({ var path = data.path;
error: 'DISABLED'
}); // XXX CONVERT
/*var path = data.path;
var folderElement = Env.user.userObject.find(path); var folderElement = Env.user.userObject.find(path);
// don't try to convert top-level elements (trash, root, etc) to shared-folders // don't try to convert top-level elements (trash, root, etc) to shared-folders
// TODO also validate that you're in root (not templates, etc) if (path.length <= 1 || path[0] !== UserObject.ROOT) {
if (data.path.length <= 1) {
return void cb({ return void cb({
error: 'E_INVAL_PATH', error: 'E_INVAL_PATH',
}); });
@ -664,6 +660,21 @@ define([
newPath: newPath, newPath: newPath,
copy: false, copy: false,
}, waitFor()); }, waitFor());
}).nThen(function (waitFor) {
// Move the owned pads from the old folder to root
var paths = [];
Object.keys(folderElement).forEach(function (el) {
if (!Env.user.userObject.isFile(folderElement[el])) { return; }
var data = Env.user.userObject.getFileData(folderElement[el]);
if (!data || !_ownedByMe(Env, data.owners)) { return; }
// This is an owned pad: move it to ROOT before deleting the initial folder
paths.push(path.concat(el));
});
_move(Env, {
paths: paths,
newPath: [UserObject.ROOT],
copy: false,
}, waitFor());
}).nThen(function () { }).nThen(function () {
// migrate metadata // migrate metadata
var sharedFolderElement = Env.user.proxy[UserObject.SHARED_FOLDERS][SFId]; var sharedFolderElement = Env.user.proxy[UserObject.SHARED_FOLDERS][SFId];
@ -678,9 +689,11 @@ define([
// remove folder // remove folder
Env.user.userObject.delete([path], function () { Env.user.userObject.delete([path], function () {
cb(); cb({
fId: SFId
});
});
}); });
});*/
}; };
// Delete permanently some pads or folders // Delete permanently some pads or folders

@ -53,11 +53,17 @@ define([
var $table = File.$table = $('<table>', { id: 'cp-fileupload-table' }); var $table = File.$table = $('<table>', { id: 'cp-fileupload-table' });
var hover = false;
var createTableContainer = function ($body) { var createTableContainer = function ($body) {
File.$container = $('<div>', { id: 'cp-fileupload' }).append(tableHeader).append($table).appendTo($body); File.$container = $('<div>', { id: 'cp-fileupload' }).append(tableHeader).append($table).appendTo($body);
$('.cp-fileupload-header-close').click(function () { $('.cp-fileupload-header-close').click(function () {
File.$container.fadeOut(); File.$container.fadeOut();
}); });
File.$container.mouseenter(function () {
hover = true;
}).mouseleave(function () {
hover = false;
});
return File.$container; return File.$container;
}; };
@ -202,6 +208,11 @@ define([
window.setTimeout(function () { File.$container.show(); }); window.setTimeout(function () { File.$container.show(); });
var file = queue.queue.shift(); var file = queue.queue.shift();
if (file.dl) { return void file.dl(file); } if (file.dl) { return void file.dl(file); }
if (file.$line && file.$line[0] && !hover) {
var line = file.$line[0];
line.scrollIntoView(false);
}
delete file.$line;
upload(file); upload(file);
}; };
queue.push = function (obj) { queue.push = function (obj) {
@ -217,10 +228,10 @@ define([
$('<div>', {'class':'cp-fileupload-table-progressbar'}).appendTo($progressContainer); $('<div>', {'class':'cp-fileupload-table-progressbar'}).appendTo($progressContainer);
$('<span>', {'class':'cp-fileupload-table-progress-value'}).text(Messages.upload_pending).appendTo($progressContainer); $('<span>', {'class':'cp-fileupload-table-progress-value'}).text(Messages.upload_pending).appendTo($progressContainer);
var $tr = $('<tr>', {id: id}).appendTo($table); var $tr = obj.$line = $('<tr>', {id: id}).appendTo($table);
var $lines = $table.find('tr[id]'); var $lines = $table.find('tr[id]');
if ($lines.length > 5) { if ($lines.length > 5) {
$lines.slice(0, $lines.length - 5).remove(); //$lines.slice(0, $lines.length - 5).remove();
} }
var $cancel = $('<span>', {'class': 'cp-fileupload-table-cancel-button fa fa-times'}).click(function () { var $cancel = $('<span>', {'class': 'cp-fileupload-table-cancel-button fa fa-times'}).click(function () {
@ -250,6 +261,13 @@ define([
// cancel // cancel
$('<td>', {'class': 'cp-fileupload-table-cancel'}).append($cancel).appendTo($tr); $('<td>', {'class': 'cp-fileupload-table-cancel'}).append($cancel).appendTo($tr);
var tw = $table.width();
var cw = File.$container.prop('clientWidth');
var diff = tw - cw;
if (diff && diff > 0) {
$table.css('margin-right', diff+'px');
}
queue.next(); queue.next();
}; };

@ -646,7 +646,7 @@ define([
var opts = parsed.getOptions(); var opts = parsed.getOptions();
var hash = Utils.Hash.getHiddenHashFromKeys(parsed.type, secret, opts); var hash = Utils.Hash.getHiddenHashFromKeys(parsed.type, secret, opts);
var useUnsafe = Utils.Util.find(settings, ['security', 'unsafeLinks']); var useUnsafe = Utils.Util.find(settings, ['security', 'unsafeLinks']);
if (!useUnsafe && window.history && window.history.replaceState) { if (useUnsafe === false && window.history && window.history.replaceState) {
if (!/^#/.test(hash)) { hash = '#' + hash; } if (!/^#/.test(hash)) { hash = '#' + hash; }
window.history.replaceState({}, window.document.title, hash); window.history.replaceState({}, window.document.title, hash);
} }
@ -684,7 +684,7 @@ define([
var opts = parsed.getOptions(); var opts = parsed.getOptions();
var hash = Utils.Hash.getHiddenHashFromKeys(parsed.type, secret, opts); var hash = Utils.Hash.getHiddenHashFromKeys(parsed.type, secret, opts);
var useUnsafe = Utils.Util.find(settings, ['security', 'unsafeLinks']); var useUnsafe = Utils.Util.find(settings, ['security', 'unsafeLinks']);
if (!useUnsafe && window.history && window.history.replaceState) { if (useUnsafe === false && window.history && window.history.replaceState) {
if (!/^#/.test(hash)) { hash = '#' + hash; } if (!/^#/.test(hash)) { hash = '#' + hash; }
window.history.replaceState({}, window.document.title, hash); window.history.replaceState({}, window.document.title, hash);
} }
@ -1125,12 +1125,12 @@ define([
}); });
sframeChan.on('Q_OO_PASSWORD_CHANGE', function (data, cb) { sframeChan.on('Q_OO_PASSWORD_CHANGE', function (data, cb) {
data.href = data.href || currentPad.href; data.href = data.href;
Cryptpad.changeOOPassword(data, cb); Cryptpad.changeOOPassword(data, cb);
}); });
sframeChan.on('Q_PAD_PASSWORD_CHANGE', function (data, cb) { sframeChan.on('Q_PAD_PASSWORD_CHANGE', function (data, cb) {
data.href = data.href || currentPad.href; data.href = data.href;
Cryptpad.changePadPassword(Cryptget, Crypto, data, cb); Cryptpad.changePadPassword(Cryptget, Crypto, data, cb);
}); });

@ -142,7 +142,13 @@ define([
if (!$mt || !$mt.is('media-tag')) { return; } if (!$mt || !$mt.is('media-tag')) { return; }
var chanStr = $mt.attr('src'); var chanStr = $mt.attr('src');
var keyStr = $mt.attr('data-crypto-key'); var keyStr = $mt.attr('data-crypto-key');
var channel = chanStr.replace(/\/blob\/[0-9a-f]{2}\//i, ''); // Remove origin
var a = document.createElement('a');
a.href = chanStr;
var src = a.pathname;
// Get channel id
var channel = src.replace(/\/blob\/[0-9a-f]{2}\//i, '');
// Get key
var key = keyStr.replace(/cryptpad:/i, ''); var key = keyStr.replace(/cryptpad:/i, '');
var metadata = $mt[0]._mediaObject._blob.metadata; var metadata = $mt[0]._mediaObject._blob.metadata;
ctx.sframeChan.query('Q_IMPORT_MEDIATAG', { ctx.sframeChan.query('Q_IMPORT_MEDIATAG', {

@ -181,7 +181,6 @@
"okButton": "D'acord (Enter)", "okButton": "D'acord (Enter)",
"cancel": "Cancel·la", "cancel": "Cancel·la",
"cancelButton": "Cancel·la (Esc)", "cancelButton": "Cancel·la (Esc)",
"doNotAskAgain": "No ho preguntis més (Esc)",
"show_help_button": "Mostra l'ajuda", "show_help_button": "Mostra l'ajuda",
"hide_help_button": "Amaga l'ajuda", "hide_help_button": "Amaga l'ajuda",
"help_button": "Ajuda", "help_button": "Ajuda",
@ -299,7 +298,7 @@
"contacts_confirmRemoveHistory": "De debò voleu suprimir permanentment el vostre historial de xat? Les dades no es podran restaurar", "contacts_confirmRemoveHistory": "De debò voleu suprimir permanentment el vostre historial de xat? Les dades no es podran restaurar",
"contacts_removeHistoryServerError": "Hi ha hagut un error mentre es suprimia el vostre historial del xat. Torneu-ho a provar", "contacts_removeHistoryServerError": "Hi ha hagut un error mentre es suprimia el vostre historial del xat. Torneu-ho a provar",
"contacts_fetchHistory": "Recupera l'historial antic", "contacts_fetchHistory": "Recupera l'historial antic",
"contacts_friends": "Amistats", "contacts_friends": "Contactes",
"contacts_rooms": "Sales", "contacts_rooms": "Sales",
"contacts_leaveRoom": "Deixa aquesta sala", "contacts_leaveRoom": "Deixa aquesta sala",
"contacts_online": "En aquesta sala hi ha una altra persona en línia", "contacts_online": "En aquesta sala hi ha una altra persona en línia",
@ -585,5 +584,37 @@
"upload_mustLogin": "Cal que inicieu la sessió per carregar un fitxer", "upload_mustLogin": "Cal que inicieu la sessió per carregar un fitxer",
"upload_up": "Carrega", "upload_up": "Carrega",
"download_button": "Desxifra i descarrega", "download_button": "Desxifra i descarrega",
"download_mt_button": "Descarrega" "download_mt_button": "Descarrega",
"home_ngi": "Guanyador del premi NGI",
"home_host_agpl": "CryptPad es distribueix sota els termes de la llicència de programari AGPL3",
"home_host": "Aquesta és una instància comunitària independent de CryptPad. El codi font està disponible<a href=\"https://github.com/xwiki-labs/cryptpad\" target=\"_blank\" rel=\"noreferrer noopener\">a GitHub</a>.",
"home_product": "CryptPad és una alternativa, respectuosa amb la privacitat, a les utilitats d'oficina i els serveis al núvol. Tot el contingut desat a CryptPad es xifra abans de ser enviat, això vol dir que ningú pot accedir a les vostres dades sense que li doneu les claus (fins i tot nosaltres).",
"mdToolbar_toc": "Taula de continguts",
"mdToolbar_code": "Codi",
"mdToolbar_check": "Llista de tasques",
"mdToolbar_list": "Llista de vinyetes",
"mdToolbar_nlist": "Llista ordenada",
"mdToolbar_quote": "Cita",
"mdToolbar_link": "Enllaç",
"mdToolbar_heading": "Capçalera",
"mdToolbar_strikethrough": "Tatxat",
"mdToolbar_italic": "Cursiva",
"mdToolbar_bold": "Negreta",
"mdToolbar_tutorial": "https://ca.wikipedia.org/wiki/Markdown",
"mdToolbar_help": "Suport",
"mdToolbar_defaultText": "El vostre text",
"mdToolbar_button": "Mostra o amaga la barra d'eines de Markdown",
"pad_base64": "Aquest document conté imatges emmagatzemades de forma ineficient. Aquestes imatges augmenten significativament la mida del document al CryptDrive i fa que la càrrega sigui més lenta. Podeu migrar les imatges a un format diferent perquè es guardin per separat al CryptDrive. Voleu migrar ara aquestes imatges?",
"todo_markAsIncompleteTitle": "Marca la tasca com incompleta",
"pad_hideToolbar": "Amaga la barra d'eines",
"pad_showToolbar": "Mostra la barra d'eines",
"todo_removeTaskTitle": "Elimina la tasca del llistat",
"todo_markAsCompleteTitle": "Marca la tasca com a completada",
"todo_newTodoNameTitle": "Afegiu la tasca al llistat",
"todo_newTodoNamePlaceholder": "Descriviu la tasca...",
"todo_title": "CryptTasques",
"download_step2": "Desxifrant",
"download_step1": "Descarregant",
"download_dl": "Descarrega",
"download_resourceNotAvailable": "El recurs sol·licitat no estava disponible... Premeu Esc per continuar."
} }

@ -179,7 +179,6 @@
"okButton": "OK (Enter)", "okButton": "OK (Enter)",
"cancel": "Abbrechen", "cancel": "Abbrechen",
"cancelButton": "Abbrechen (Esc)", "cancelButton": "Abbrechen (Esc)",
"doNotAskAgain": "Nicht mehr fragen (Esc)",
"show_help_button": "Hilfe anzeigen", "show_help_button": "Hilfe anzeigen",
"hide_help_button": "Hilfe verbergen", "hide_help_button": "Hilfe verbergen",
"help_button": "Hilfe", "help_button": "Hilfe",
@ -515,8 +514,8 @@
"settings_creationSkipFalse": "Anzeigen", "settings_creationSkipFalse": "Anzeigen",
"settings_templateSkip": "Wahl der Vorlage überspringen", "settings_templateSkip": "Wahl der Vorlage überspringen",
"settings_templateSkipHint": "Wenn du ein neues Pad erstellst und passende Vorlagen vorhanden sind, erscheint ein Dialog zur Auswahl einer Vorlage. Hier kannst du diesen Dialog überspringen und somit keine Vorlage verwenden.", "settings_templateSkipHint": "Wenn du ein neues Pad erstellst und passende Vorlagen vorhanden sind, erscheint ein Dialog zur Auswahl einer Vorlage. Hier kannst du diesen Dialog überspringen und somit keine Vorlage verwenden.",
"settings_ownDriveTitle": "Aktiviere die neuesten Funktionen für dein Konto", "settings_ownDriveTitle": "Account aktualisieren",
"settings_ownDriveHint": "Aus technischen Gründen sind nicht alle neue Funktionen für ältere Konten verfügbar. Ein kostenloses Upgrade wird dein CryptDrive für zukünftige Funktionen vorbereiten, ohne deine Arbeit zu stören.", "settings_ownDriveHint": "Aus technischen Gründen sind nicht alle neue Funktionen für ältere Konten verfügbar. Eine kostenlose Aktualisierung wird die neuen Funktionen aktivieren und dein CryptDrive für zukünftige Aktualisierungen vorbereiten.",
"settings_ownDriveButton": "Upgrade deines Kontos", "settings_ownDriveButton": "Upgrade deines Kontos",
"settings_ownDriveConfirm": "Das Upgrade deines Kontos kann einige Zeit dauern. Du wirst dich auf allen Geräten neu einloggen müssen. Bist du sicher?", "settings_ownDriveConfirm": "Das Upgrade deines Kontos kann einige Zeit dauern. Du wirst dich auf allen Geräten neu einloggen müssen. Bist du sicher?",
"settings_ownDrivePending": "Das Upgrade deines Kontos läuft. Bitte schließe die Seite nicht und lade sie nicht neu, bis dieser Vorgang abgeschlossen ist.", "settings_ownDrivePending": "Das Upgrade deines Kontos läuft. Bitte schließe die Seite nicht und lade sie nicht neu, bis dieser Vorgang abgeschlossen ist.",
@ -911,7 +910,7 @@
"feedback_about": "Wenn du das liest, fragst du dich wahrscheinlich, weshalb dein Browser bei der der Ausführung mancher Aktionen Anfragen an Webseiten sendet", "feedback_about": "Wenn du das liest, fragst du dich wahrscheinlich, weshalb dein Browser bei der der Ausführung mancher Aktionen Anfragen an Webseiten sendet",
"feedback_privacy": "Wir respektieren deine Datenschutz, aber gleichzeitig wollen wir, dass die Benutzung von CryptPad sehr leicht ist. Deshalb wollen wir erfahren, welche Funktion am wichtigsten für unsere Benutzer ist, indem wir diese mit einer genauen Parameterbeschreibung anfordern.", "feedback_privacy": "Wir respektieren deine Datenschutz, aber gleichzeitig wollen wir, dass die Benutzung von CryptPad sehr leicht ist. Deshalb wollen wir erfahren, welche Funktion am wichtigsten für unsere Benutzer ist, indem wir diese mit einer genauen Parameterbeschreibung anfordern.",
"feedback_optout": "Wenn du das nicht möchtest, kannst du es in <a href='/settings/'>deinen Einstellungen</a> deaktivieren", "feedback_optout": "Wenn du das nicht möchtest, kannst du es in <a href='/settings/'>deinen Einstellungen</a> deaktivieren",
"creation_404": "Dieses Pad existiert nicht mehr. Benutze das folgende Formular, um ein neues Pad zu gestalten.", "creation_404": "Dieses Pad existiert nicht mehr. Benutze das folgende Formular, um ein neues Pad zu erstellen.",
"creation_ownedTitle": "Pad-Typ", "creation_ownedTitle": "Pad-Typ",
"creation_owned": "Eigenes Pad", "creation_owned": "Eigenes Pad",
"creation_ownedTrue": "Eigenes Pad", "creation_ownedTrue": "Eigenes Pad",
@ -931,7 +930,6 @@
"creation_noTemplate": "Keine Vorlage", "creation_noTemplate": "Keine Vorlage",
"creation_newTemplate": "Neue Vorlage", "creation_newTemplate": "Neue Vorlage",
"creation_create": "Erstellen", "creation_create": "Erstellen",
"creation_saveSettings": "Dieses Dialog nicht mehr anzeigen",
"creation_settings": "Mehr Einstellungen anzeigen", "creation_settings": "Mehr Einstellungen anzeigen",
"creation_rememberHelp": "Gehe zu deinen Einstellungen, um diese Auswahl zurückzusetzen", "creation_rememberHelp": "Gehe zu deinen Einstellungen, um diese Auswahl zurückzusetzen",
"creation_owners": "Eigentümer", "creation_owners": "Eigentümer",
@ -998,7 +996,6 @@
"crowdfunding_popup_text": "<h3>Wir brauchen deine Hilfe!</h3>Um sicherzustellen, dass CryptPad weiter aktiv entwickelt wird, unterstütze bitte das Projekt über die <a href=\"https://opencollective.com/cryptpad\">OpenCollective Seite</a>, wo du unsere <b>Roadmap</b> und <b>Funding-Ziele</b> lesen kannst.", "crowdfunding_popup_text": "<h3>Wir brauchen deine Hilfe!</h3>Um sicherzustellen, dass CryptPad weiter aktiv entwickelt wird, unterstütze bitte das Projekt über die <a href=\"https://opencollective.com/cryptpad\">OpenCollective Seite</a>, wo du unsere <b>Roadmap</b> und <b>Funding-Ziele</b> lesen kannst.",
"crowdfunding_popup_yes": "OpenCollective besuchen", "crowdfunding_popup_yes": "OpenCollective besuchen",
"crowdfunding_popup_no": "Nicht jetzt", "crowdfunding_popup_no": "Nicht jetzt",
"crowdfunding_popup_never": "Nicht mehr darum bitten",
"invalidHashError": "Das angeforderte Dokument hat eine ungültige URL.", "invalidHashError": "Das angeforderte Dokument hat eine ungültige URL.",
"oo_cantUpload": "Das Hochladen von Dateien ist nicht erlaubt, während andere Nutzer anwesend sind.", "oo_cantUpload": "Das Hochladen von Dateien ist nicht erlaubt, während andere Nutzer anwesend sind.",
"oo_uploaded": "Das Hochladen wurde abgeschlossen. Klicke auf OK zum Neuladen der Seite oder auf Abbrechen zum Fortfahren im schreibgeschützten Modus.", "oo_uploaded": "Das Hochladen wurde abgeschlossen. Klicke auf OK zum Neuladen der Seite oder auf Abbrechen zum Fortfahren im schreibgeschützten Modus.",
@ -1099,7 +1096,7 @@
"support_formMessage": "Gib deine Nachricht ein...", "support_formMessage": "Gib deine Nachricht ein...",
"support_cat_tickets": "Vorhandene Tickets", "support_cat_tickets": "Vorhandene Tickets",
"support_listTitle": "Support-Tickets", "support_listTitle": "Support-Tickets",
"support_listHint": "Hier ist die Liste der an die Administratoren gesendeten Tickets und der dazugehörigen Antworten. Ein geschlossenes Ticket kann nicht wieder geöffnet werden, du kannst jedoch ein neues Ticket eröffnen. Du kannst geschlossene Tickets ausblenden, aber sie werden weiterhin für die Administratoren sichtbar sein.", "support_listHint": "Hier ist die Liste der an die Administratoren gesendeten Tickets und der dazugehörigen Antworten. Ein geschlossenes Ticket kann nicht wieder geöffnet werden, aber du kannst ein neues Ticket eröffnen. Du kannst geschlossene Tickets ausblenden.",
"support_answer": "Antworten", "support_answer": "Antworten",
"support_close": "Ticket schließen", "support_close": "Ticket schließen",
"support_remove": "Ticket entfernen", "support_remove": "Ticket entfernen",
@ -1293,5 +1290,12 @@
"oo_sheetMigration_anonymousEditor": "Die Bearbeitung dieser Tabelle ist für anonyme Benutzer deaktiviert, bis sie von einem registrierten Benutzer auf die neueste Version aktualisiert wird.", "oo_sheetMigration_anonymousEditor": "Die Bearbeitung dieser Tabelle ist für anonyme Benutzer deaktiviert, bis sie von einem registrierten Benutzer auf die neueste Version aktualisiert wird.",
"imprint": "Impressum", "imprint": "Impressum",
"isContact": "{0} ist einer deiner Kontakte", "isContact": "{0} ist einer deiner Kontakte",
"isNotContact": "{0} ist <b>nicht</b> einer deiner Kontakte" "isNotContact": "{0} ist <b>nicht</b> einer deiner Kontakte",
"settings_cat_security": "Vertraulichkeit",
"settings_safeLinksHint": "CryptPad fügt den Pad-Links die Schlüssel zum Entschlüsseln der Inhalte hinzu. Jeder, der Zugriff auf den Browserverlauf hat, kann möglicherweise die Daten lesen. Dazu gehören Browsererweiterungen und Browser, die den Verlauf geräteübergreifend synchronisieren. Die Aktivierung von \"sicheren Links\" verhindert, dass die Schlüssel in den Browserverlauf gelangen oder in der Adressleiste angezeigt werden, wann immer dies möglich ist. Wir empfehlen dringend, diese Funktion zu aktivieren und das Menü {0} Teilen zu verwenden.",
"dontShowAgain": "Nicht mehr anzeigen",
"profile_login": "Du musst dich einloggen, um diesen Benutzer zu deinen Kontakten hinzuzufügen",
"safeLinks_error": "Dieser Link gibt dir keinen Zugriff auf das Dokument",
"settings_safeLinksCheckbox": "Sichere Links aktivieren",
"settings_safeLinksTitle": "Sichere Links"
} }

@ -151,7 +151,6 @@
"okButton": "OK (enter)", "okButton": "OK (enter)",
"cancel": "Ακύρωση", "cancel": "Ακύρωση",
"cancelButton": "Ακύρωση (esc)", "cancelButton": "Ακύρωση (esc)",
"doNotAskAgain": "Να μην ρωτηθώ ξανά (Esc)",
"historyText": "Ιστορικό", "historyText": "Ιστορικό",
"historyButton": "Εμφάνιση ιστορικού του εγγράφου", "historyButton": "Εμφάνιση ιστορικού του εγγράφου",
"history_next": "Μετάβαση στην επόμενη έκδοση", "history_next": "Μετάβαση στην επόμενη έκδοση",

@ -479,7 +479,6 @@
"slide_invalidLess": "Estilo personalizado no válido", "slide_invalidLess": "Estilo personalizado no válido",
"fileShare": "Copiar link", "fileShare": "Copiar link",
"ok": "OK", "ok": "OK",
"doNotAskAgain": "No preguntar nuevamente (Esc)",
"show_help_button": "Mostrar ayuda", "show_help_button": "Mostrar ayuda",
"hide_help_button": "Esconder ayuda", "hide_help_button": "Esconder ayuda",
"help_button": "Ayuda", "help_button": "Ayuda",

@ -184,7 +184,6 @@
"okButton": "OK (Enter)", "okButton": "OK (Enter)",
"cancel": "Keskeytä", "cancel": "Keskeytä",
"cancelButton": "Keskeytä (Esc)", "cancelButton": "Keskeytä (Esc)",
"doNotAskAgain": "Älä kysy uudestaan (Esc)",
"show_help_button": "Näytä ohje", "show_help_button": "Näytä ohje",
"hide_help_button": "Piilota ohje", "hide_help_button": "Piilota ohje",
"help_button": "Ohje", "help_button": "Ohje",

@ -181,7 +181,6 @@
"okButton": "OK (Entrée)", "okButton": "OK (Entrée)",
"cancel": "Annuler", "cancel": "Annuler",
"cancelButton": "Annuler (Échap)", "cancelButton": "Annuler (Échap)",
"doNotAskAgain": "Ne plus demander (Échap)",
"show_help_button": "Afficher l'aide", "show_help_button": "Afficher l'aide",
"hide_help_button": "Cacher l'aide", "hide_help_button": "Cacher l'aide",
"help_button": "Aide", "help_button": "Aide",
@ -522,8 +521,8 @@
"settings_creationSkipFalse": "Afficher", "settings_creationSkipFalse": "Afficher",
"settings_templateSkip": "Passer la fenêtre de choix d'un modèle", "settings_templateSkip": "Passer la fenêtre de choix d'un modèle",
"settings_templateSkipHint": "Quand vous créez un nouveau pad, et si vous possédez des modèles pour ce type de pad, une fenêtre peut apparaître pour demander si vous souhaitez importer un modèle. Ici vous pouvez choisir de ne jamais montrer cette fenêtre et donc de ne jamais utiliser de modèle.", "settings_templateSkipHint": "Quand vous créez un nouveau pad, et si vous possédez des modèles pour ce type de pad, une fenêtre peut apparaître pour demander si vous souhaitez importer un modèle. Ici vous pouvez choisir de ne jamais montrer cette fenêtre et donc de ne jamais utiliser de modèle.",
"settings_ownDriveTitle": "Activer les dernières fonctionnalités du compte", "settings_ownDriveTitle": "Mise à jour du compte",
"settings_ownDriveHint": "Pour des raisons techniques, les comptes utilisateurs les plus anciens n'ont pas accès à toutes les fonctionnalités. Une mise à niveau gratuite permet de préparer votre CryptDrive pour les nouveautés à venir sans perturber vos activités habituelles.", "settings_ownDriveHint": "Les comptes plus anciens n'ont pas accès aux dernières fonctionnalités, pour des raisons techniques. Une mise à niveau gratuite permet d'activer les fonctionnalités actuelles et de préparer votre CryptDrive pour les futures mises à jour.",
"settings_ownDriveButton": "Mettre à niveau votre compte", "settings_ownDriveButton": "Mettre à niveau votre compte",
"settings_ownDriveConfirm": "La mise à niveau peut prendre du temps. Vous devrez vous reconnecter sur tous vos appareils. Voulez-vous continuer ?", "settings_ownDriveConfirm": "La mise à niveau peut prendre du temps. Vous devrez vous reconnecter sur tous vos appareils. Voulez-vous continuer ?",
"settings_ownDrivePending": "Votre compte est en train d'être mis à jour. Veuillez ne pas fermer ou recharger cette page avant que le traitement soit terminé.", "settings_ownDrivePending": "Votre compte est en train d'être mis à jour. Veuillez ne pas fermer ou recharger cette page avant que le traitement soit terminé.",
@ -938,7 +937,6 @@
"creation_noTemplate": "Pas de modèle", "creation_noTemplate": "Pas de modèle",
"creation_newTemplate": "Nouveau modèle", "creation_newTemplate": "Nouveau modèle",
"creation_create": "Créer", "creation_create": "Créer",
"creation_saveSettings": "Ne plus me demander",
"creation_settings": "Voir davantage de préférences", "creation_settings": "Voir davantage de préférences",
"creation_rememberHelp": "Ouvrez votre page de Préférences pour voir ce formulaire à nouveau", "creation_rememberHelp": "Ouvrez votre page de Préférences pour voir ce formulaire à nouveau",
"creation_owners": "Propriétaires", "creation_owners": "Propriétaires",
@ -1006,7 +1004,6 @@
"crowdfunding_popup_text": "<h3>Aider CryptPad</h3>Pour vous assurer que CryptPad soit activement développé, nous vous invitons à supporter le projet via la <a href=\"https://opencollective.com/cryptpad\">page OpenCollective</a>, où vous pouvez trouver notre <b>Roadmap</b> et nos <b>objectifs de financement</b>.", "crowdfunding_popup_text": "<h3>Aider CryptPad</h3>Pour vous assurer que CryptPad soit activement développé, nous vous invitons à supporter le projet via la <a href=\"https://opencollective.com/cryptpad\">page OpenCollective</a>, où vous pouvez trouver notre <b>Roadmap</b> et nos <b>objectifs de financement</b>.",
"crowdfunding_popup_yes": "Voir la page", "crowdfunding_popup_yes": "Voir la page",
"crowdfunding_popup_no": "Pas maintenant", "crowdfunding_popup_no": "Pas maintenant",
"crowdfunding_popup_never": "Ne plus demander",
"survey": "Enquête CryptPad", "survey": "Enquête CryptPad",
"markdown_toc": "Sommaire", "markdown_toc": "Sommaire",
"debug_getGraph": "Obtenir le code permettant de générer un graphe de ce document", "debug_getGraph": "Obtenir le code permettant de générer un graphe de ce document",
@ -1293,5 +1290,12 @@
"oo_sheetMigration_anonymousEditor": "L'édition de cette feuille de calcul est désactivée pour les utilisateurs anonymes jusqu'à ce qu'elle soit mise à jour par un utilisateur enregistré.", "oo_sheetMigration_anonymousEditor": "L'édition de cette feuille de calcul est désactivée pour les utilisateurs anonymes jusqu'à ce qu'elle soit mise à jour par un utilisateur enregistré.",
"imprint": "Mentions légales", "imprint": "Mentions légales",
"isContact": "{0} est dans vos contacts", "isContact": "{0} est dans vos contacts",
"isNotContact": "{0} n'est <b>pas</b> dans vos contacts" "isNotContact": "{0} n'est <b>pas</b> dans vos contacts",
"settings_safeLinksHint": "CryptPad inclut dans ses liens les clés permettant de déchiffrer vos pads. Toute personne ayant accès à votre historique de navigation peut potentiellement lire vos données. Cela inclut les extensions de navigateur intrusives et les navigateurs qui synchronisent votre historique entre les appareils. L'activation des \"liens sécurisés\" empêche les clés d'entrer dans votre historique de navigation ou d'être affichées dans votre barre d'adresse quand cela est possible. Nous vous recommandons vivement d'activer cette fonction et d'utiliser le menu {0} Partager.",
"profile_login": "Vous devez vous connecter pour ajouter cet utilisateur à vos contacts",
"dontShowAgain": "Ne plus demander",
"safeLinks_error": "Le lien utilisé ne permet pas d'ouvrir ce document",
"settings_safeLinksCheckbox": "Activer les liens sécurisés",
"settings_safeLinksTitle": "Liens Sécurisés",
"settings_cat_security": "Confidentialité"
} }

@ -181,7 +181,6 @@
"okButton": "OK (Enter)", "okButton": "OK (Enter)",
"cancel": "Cancella", "cancel": "Cancella",
"cancelButton": "Cancella (Esc)", "cancelButton": "Cancella (Esc)",
"doNotAskAgain": "Non chiedere più (Esc)",
"show_help_button": "Mostra l'aiuto", "show_help_button": "Mostra l'aiuto",
"hide_help_button": "Nascondi l'aiuto", "hide_help_button": "Nascondi l'aiuto",
"help_button": "Aiuto", "help_button": "Aiuto",

@ -184,7 +184,6 @@
"okButton": "OK (enter)", "okButton": "OK (enter)",
"cancel": "Cancel", "cancel": "Cancel",
"cancelButton": "Cancel (esc)", "cancelButton": "Cancel (esc)",
"doNotAskAgain": "Don't ask me again (Esc)",
"show_help_button": "Show help", "show_help_button": "Show help",
"hide_help_button": "Hide help", "hide_help_button": "Hide help",
"help_button": "Help", "help_button": "Help",
@ -535,8 +534,8 @@
"settings_creationSkipFalse": "Display", "settings_creationSkipFalse": "Display",
"settings_templateSkip": "Skip the template selection modal", "settings_templateSkip": "Skip the template selection modal",
"settings_templateSkipHint": "When you create a new empty pad, if you have stored templates for this type of pad, a modal appears to ask if you want to use a template. Here you can choose to never show this modal and so to never use a template.", "settings_templateSkipHint": "When you create a new empty pad, if you have stored templates for this type of pad, a modal appears to ask if you want to use a template. Here you can choose to never show this modal and so to never use a template.",
"settings_ownDriveTitle": "Enable latest account features", "settings_ownDriveTitle": "Update Account",
"settings_ownDriveHint": "For technical reasons, older accounts do not have access to all of our latest features. A free upgrade to a new account will prepare your CryptDrive for upcoming features without disrupting your usual activities.", "settings_ownDriveHint": "Older accounts do not have access to the latest features, due to technical reasons. A free update will enable current features, and prepare your CryptDrive for future updates.",
"settings_ownDriveButton": "Upgrade your account", "settings_ownDriveButton": "Upgrade your account",
"settings_ownDriveConfirm": "Upgrading your account may take some time. You will need to log back in on all your devices. Are you sure?", "settings_ownDriveConfirm": "Upgrading your account may take some time. You will need to log back in on all your devices. Are you sure?",
"settings_ownDrivePending": "Your account is being upgraded. Please do not close or reload this page until the process has completed.", "settings_ownDrivePending": "Your account is being upgraded. Please do not close or reload this page until the process has completed.",
@ -936,7 +935,7 @@
"feedback_about": "If you're reading this, you were probably curious why CryptPad is requesting web pages when you perform certain actions", "feedback_about": "If you're reading this, you were probably curious why CryptPad is requesting web pages when you perform certain actions",
"feedback_privacy": "We care about your privacy, and at the same time we want CryptPad to be very easy to use. We use this file to figure out which UI features matter to our users, by requesting it along with a parameter specifying which action was taken.", "feedback_privacy": "We care about your privacy, and at the same time we want CryptPad to be very easy to use. We use this file to figure out which UI features matter to our users, by requesting it along with a parameter specifying which action was taken.",
"feedback_optout": "If you would like to opt out, visit <a href='/settings/'>your user settings page</a>, where you'll find a checkbox to enable or disable user feedback", "feedback_optout": "If you would like to opt out, visit <a href='/settings/'>your user settings page</a>, where you'll find a checkbox to enable or disable user feedback",
"creation_404": "This pad not longer exists. Use the following form to create a new pad.", "creation_404": "This pad no longer exists. Use the following form to create a new pad.",
"creation_ownedTitle": "Type of pad", "creation_ownedTitle": "Type of pad",
"creation_owned": "Owned pad", "creation_owned": "Owned pad",
"creation_ownedTrue": "Owned pad", "creation_ownedTrue": "Owned pad",
@ -956,7 +955,6 @@
"creation_noTemplate": "No template", "creation_noTemplate": "No template",
"creation_newTemplate": "New template", "creation_newTemplate": "New template",
"creation_create": "Create", "creation_create": "Create",
"creation_saveSettings": "Don't show this again",
"creation_settings": "View more settings", "creation_settings": "View more settings",
"creation_rememberHelp": "Visit your Settings page to reset this preference", "creation_rememberHelp": "Visit your Settings page to reset this preference",
"creation_owners": "Owners", "creation_owners": "Owners",
@ -1028,7 +1026,6 @@
"crowdfunding_popup_text": "<h3>We need your help!</h3>To ensure that CryptPad is actively developed, consider supporting the project via the <a href=\"https://opencollective.com/cryptpad\">OpenCollective page</a>, where you can see our <b>Roadmap</b> and <b>Funding goals</b>.", "crowdfunding_popup_text": "<h3>We need your help!</h3>To ensure that CryptPad is actively developed, consider supporting the project via the <a href=\"https://opencollective.com/cryptpad\">OpenCollective page</a>, where you can see our <b>Roadmap</b> and <b>Funding goals</b>.",
"crowdfunding_popup_yes": "Go to OpenCollective", "crowdfunding_popup_yes": "Go to OpenCollective",
"crowdfunding_popup_no": "Not now", "crowdfunding_popup_no": "Not now",
"crowdfunding_popup_never": "Don't ask me again",
"survey": "CryptPad survey", "survey": "CryptPad survey",
"markdown_toc": "Contents", "markdown_toc": "Contents",
"fm_expirablePad": "Expires: {0}", "fm_expirablePad": "Expires: {0}",
@ -1293,5 +1290,12 @@
"oo_sheetMigration_loading": "Upgrading your spreadsheet to the latest version", "oo_sheetMigration_loading": "Upgrading your spreadsheet to the latest version",
"oo_sheetMigration_complete": "Updated version available, press OK to reload.", "oo_sheetMigration_complete": "Updated version available, press OK to reload.",
"oo_sheetMigration_anonymousEditor": "Editing this spreadsheet is disabled for anonymous users until it is upgraded to the latest version by a registered user.", "oo_sheetMigration_anonymousEditor": "Editing this spreadsheet is disabled for anonymous users until it is upgraded to the latest version by a registered user.",
"imprint": "Legal notice" "imprint": "Legal notice",
"settings_cat_security": "Confidentiality",
"settings_safeLinksTitle": "Safe Links",
"settings_safeLinksCheckbox": "Enable safe links",
"safeLinks_error": "This link does not give you access to the document",
"dontShowAgain": "Don't show again",
"profile_login": "You need to log in to add this user to your contacts",
"settings_safeLinksHint": "CryptPad includes the keys to decrypt your pads in their links. Anyone with access to your browsing history can potentially read your data. This includes intrusive browser extensions and browsers that sync your history across devices. Enabling \"safe links\" prevents the keys from entering your browsing history or being displayed in your address bar whenever possible. We strongly recommend that you enable this feature and use the {0} Share menu."
} }

@ -193,7 +193,6 @@
"crowdfunding_button": "Støtt CryptPad", "crowdfunding_button": "Støtt CryptPad",
"crowdfunding_popup_yes": "Gå til OpenCollective", "crowdfunding_popup_yes": "Gå til OpenCollective",
"crowdfunding_popup_no": "Ikke nå", "crowdfunding_popup_no": "Ikke nå",
"crowdfunding_popup_never": "Ikke spør igjen takk",
"markdown_toc": "Innhold", "markdown_toc": "Innhold",
"fm_expirablePad": "Denne paden vill utgå på dato den {0}", "fm_expirablePad": "Denne paden vill utgå på dato den {0}",
"admin_authError": "Kun admin-tilgang", "admin_authError": "Kun admin-tilgang",

@ -409,7 +409,6 @@
"fileEmbedScript": "", "fileEmbedScript": "",
"fileEmbedTag": "", "fileEmbedTag": "",
"ok": "", "ok": "",
"doNotAskAgain": "",
"show_help_button": "", "show_help_button": "",
"hide_help_button": "", "hide_help_button": "",
"help_button": "", "help_button": "",

@ -395,7 +395,6 @@
"fileEmbedTitle": "Include fișierul într-o pagină externă", "fileEmbedTitle": "Include fișierul într-o pagină externă",
"fileEmbedTag": "După care plasează această etichetă Media oriunde pe pagina unde vrei sa o plasezi", "fileEmbedTag": "După care plasează această etichetă Media oriunde pe pagina unde vrei sa o plasezi",
"ok": "Ok", "ok": "Ok",
"doNotAskAgain": "Nu mă întreba din nou (Esc)",
"show_help_button": "Arată ajutorul", "show_help_button": "Arată ajutorul",
"hide_help_button": "Maschează ajutorul", "hide_help_button": "Maschează ajutorul",
"help_button": "Ajutor", "help_button": "Ajutor",

@ -175,7 +175,6 @@
"okButton": "OK (Enter)", "okButton": "OK (Enter)",
"cancel": "Отмена", "cancel": "Отмена",
"cancelButton": "Отмена (Esc)", "cancelButton": "Отмена (Esc)",
"doNotAskAgain": "Не спрашивать снова (Esc)",
"show_help_button": "Показать справку", "show_help_button": "Показать справку",
"hide_help_button": "Скрыть справку", "hide_help_button": "Скрыть справку",
"help_button": "Справка", "help_button": "Справка",
@ -299,7 +298,6 @@
"fm_removeSeveralPermanentlyDialog": "Вы уверены, что хотите навсегда удалить {0} элементов из вашего Хранилища?", "fm_removeSeveralPermanentlyDialog": "Вы уверены, что хотите навсегда удалить {0} элементов из вашего Хранилища?",
"crowdfunding_button": "Поддержите CryptPad", "crowdfunding_button": "Поддержите CryptPad",
"crowdfunding_popup_no": "Не сейчас", "crowdfunding_popup_no": "Не сейчас",
"crowdfunding_popup_never": "Не спрашивать меня снова",
"markdown_toc": "Содержимое", "markdown_toc": "Содержимое",
"fm_expirablePad": "Этот блокнот истечет {0}", "fm_expirablePad": "Этот блокнот истечет {0}",
"fileEmbedTitle": "Встроить файл во внешнюю страницу", "fileEmbedTitle": "Встроить файл во внешнюю страницу",

@ -96,7 +96,11 @@ define([
var updateObject = function (sframeChan, obj, cb) { var updateObject = function (sframeChan, obj, cb) {
sframeChan.query('Q_DRIVE_GETOBJECT', null, function (err, newObj) { sframeChan.query('Q_DRIVE_GETOBJECT', null, function (err, newObj) {
copyObjectValue(obj, newObj); copyObjectValue(obj, newObj);
// If anon shared folder, make a virtual drive containing this folder
if (!APP.loggedIn && APP.newSharedFolder) { if (!APP.loggedIn && APP.newSharedFolder) {
obj.drive.root = {
sf: APP.newSharedFolder
};
obj.drive.sharedFolders = obj.drive.sharedFolders || {}; obj.drive.sharedFolders = obj.drive.sharedFolders || {};
obj.drive.sharedFolders[APP.newSharedFolder] = { obj.drive.sharedFolders[APP.newSharedFolder] = {
href: APP.anonSFHref, href: APP.anonSFHref,

@ -101,7 +101,11 @@ define([
var time = new Date(data.content.time); var time = new Date(data.content.time);
$(el).find(".cp-notification-content").append(h("span.notification-time", time.toLocaleString())); $(el).find(".cp-notification-content").append(h("span.notification-time", time.toLocaleString()));
$(el).addClass("cp-app-notification-archived"); $(el).addClass("cp-app-notification-archived");
$(el).toggle(!isDataUnread); if (isDataUnread) {
$(el).hide();
} else {
$(el).css('display', 'flex');
}
$(notifsList).append(el); $(notifsList).append(el);
} }
}; };
@ -140,7 +144,7 @@ define([
addNotification(data, el); addNotification(data, el);
}, },
onViewed: function (data) { onViewed: function (data) {
$('.cp-app-notification-archived[data-hash="' + data.hash + '"]').show(); $('.cp-app-notification-archived[data-hash="' + data.hash + '"]').css('display', 'flex');
} }
}); });

@ -575,7 +575,7 @@ define([
var register = h('button.cp-corner-primary', Messages.login_register); var register = h('button.cp-corner-primary', Messages.login_register);
var cancel = h('button.cp-corner-cancel', Messages.cancel); var cancel = h('button.cp-corner-cancel', Messages.cancel);
var actions = h('div', [cancel, register, login]); var actions = h('div', [cancel, register, login]);
var modal = UI.cornerPopup(Messages.profile_login || "You need to log in to add this user to your contacts", actions, '', {alt: true}); // XXX var modal = UI.cornerPopup(Messages.profile_login, actions, '', {alt: true});
$(register).click(function () { $(register).click(function () {
common.setLoginRedirect(function () { common.setLoginRedirect(function () {
common.gotoURL('/register/'); common.gotoURL('/register/');

@ -17,6 +17,10 @@
flex-flow: column; flex-flow: column;
font: @colortheme_app-font; font: @colortheme_app-font;
.cp-sidebarlayout-element {
max-width: 650px;
}
#cp-export-container { #cp-export-container {
font-size: 16px; font-size: 16px;
display: flex; display: flex;
@ -121,8 +125,13 @@
border: 1px solid black; border: 1px solid black;
} }
.cp-settings-language-selector { .cp-settings-language-selector {
#cp-language-selector {
display: inline;
}
button.btn { button.btn {
width: @sidebar_button-width; width: @sidebar_button-width;
max-width: 100%;
margin: 0 !important;
background-color: @colortheme_sidebar-button-alt-bg; background-color: @colortheme_sidebar-button-alt-bg;
border-color: #adadad; border-color: #adadad;
color: black; color: black;
@ -149,6 +158,7 @@
.cp-settings-info-block { .cp-settings-info-block {
[type="text"] { [type="text"] {
width: @sidebar_button-width; width: @sidebar_button-width;
max-width: 100%;
} }
} }

@ -56,7 +56,7 @@ define([
'cp-settings-migrate', 'cp-settings-migrate',
'cp-settings-delete' 'cp-settings-delete'
], ],
'security': [ // XXX 'security': [
'cp-settings-logout-everywhere', 'cp-settings-logout-everywhere',
'cp-settings-autostore', 'cp-settings-autostore',
'cp-settings-safe-links', 'cp-settings-safe-links',
@ -118,6 +118,18 @@ define([
var create = {}; var create = {};
var SPECIAL_HINTS_HANDLER = {
safeLinks: function () {
return $('<span>', {'class': 'cp-sidebarlayout-description'})
.html(Messages._getKey('settings_safeLinksHint', ['<span class="fa fa-shhare-alt"></span>']));
},
};
var DEFAULT_HINT_HANDLER = function (safeKey) {
return $('<span>', {'class': 'cp-sidebarlayout-description'})
.text(Messages['settings_'+safeKey+'Hint'] || 'Coming soon...');
};
var makeBlock = function (key, getter, full) { var makeBlock = function (key, getter, full) {
var safeKey = key.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); }); var safeKey = key.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); });
@ -125,8 +137,14 @@ define([
var $div = $('<div>', {'class': 'cp-settings-' + key + ' cp-sidebarlayout-element'}); var $div = $('<div>', {'class': 'cp-settings-' + key + ' cp-sidebarlayout-element'});
if (full) { if (full) {
$('<label>').text(Messages['settings_'+safeKey+'Title'] || key).appendTo($div); $('<label>').text(Messages['settings_'+safeKey+'Title'] || key).appendTo($div);
$('<span>', {'class': 'cp-sidebarlayout-description'})
.text(Messages['settings_'+safeKey+'Hint'] || 'Coming soon...').appendTo($div); // if this block's hint needs a special renderer, then create it in SPECIAL_HINTS_HANLDER
// otherwise the default will be used
var hintFunction = (typeof(SPECIAL_HINTS_HANDLER[safeKey]) === 'function')?
SPECIAL_HINTS_HANDLER[safeKey]:
DEFAULT_HINT_HANDLER;
hintFunction(safeKey).appendTo($div);
} }
getter(function (content) { getter(function (content) {
$div.append(content); $div.append(content);
@ -571,14 +589,14 @@ define([
// Security // Security
makeBlock('safe-links', function (cb) { makeBlock('safe-links', function (cb) {
// XXX settings_safeLinksTitle, settings_safeLinksHint, settings_safeLinksCheckbox
var $cbox = $(UI.createCheckbox('cp-settings-safe-links', var $cbox = $(UI.createCheckbox('cp-settings-safe-links',
Messages.settings_safeLinksCheckbox, Messages.settings_safeLinksCheckbox,
true, { label: {class: 'noTitle'} })); false, { label: {class: 'noTitle'} }));
var spinner = UI.makeSpinner($cbox); var spinner = UI.makeSpinner($cbox);
// Checkbox: "Enable safe links"
var $checkbox = $cbox.find('input').on('change', function () { var $checkbox = $cbox.find('input').on('change', function () {
spinner.spin(); spinner.spin();
var val = !$checkbox.is(':checked'); var val = !$checkbox.is(':checked');
@ -589,7 +607,7 @@ define([
common.getAttribute(['security', 'unsafeLinks'], function (e, val) { common.getAttribute(['security', 'unsafeLinks'], function (e, val) {
if (e) { return void console.error(e); } if (e) { return void console.error(e); }
if (!val) { if (val === false) {
$checkbox.attr('checked', 'checked'); $checkbox.attr('checked', 'checked');
} }
}); });

@ -42,6 +42,12 @@
.cp-app-contacts-container { .cp-app-contacts-container {
height: 100%; height: 100%;
} }
.cp-app-contacts-input {
textarea {
border: 0px;
color: white;
}
}
} }
& > .cp-team-drive { & > .cp-team-drive {
display: flex; display: flex;

Loading…
Cancel
Save