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

pull/1/head
ansuz 4 years ago
commit ae2f434003

@ -644,6 +644,27 @@ Version 4: Data URL when not a realtime link yet (new pad or "static" app)
return hashes;
};
Hash.getFormData = function (secret, hash, password) {
secret = secret || Hash.getSecrets('form', hash, password);
var keys = secret && secret.keys;
var secondary = keys && keys.secondaryKey;
if (!secondary) { return; }
var curvePair = Nacl.box.keyPair.fromSecretKey(Nacl.util.decodeUTF8(secondary).slice(0,32));
var ret = {};
ret.form_public = Nacl.util.encodeBase64(curvePair.publicKey);
var privateKey = ret.form_private = Nacl.util.encodeBase64(curvePair.secretKey);
var auditorHash = Hash.getViewHashFromKeys({
version: 1,
channel: secret.channel,
keys: { viewKeyStr: Nacl.util.encodeBase64(keys.cryptKey) }
});
var _parsed = Hash.parseTypeHash('pad', auditorHash);
ret.form_auditorHash = _parsed.getHash({auditorKey: privateKey});
return ret;
};
// STORAGE
Hash.hrefToHexChannelId = function (href, password) {
var parsed = Hash.parsePadUrl(href);

@ -2068,6 +2068,7 @@ define([
// can't share the read-only URL and we don't have access to the edit one.
// We should hide the share button.
if (!data.href && !ro) { return; }
$shareBlock.click(function () {
Share.getShareModal(common, {
teamId: APP.team,
@ -4449,6 +4450,18 @@ define([
data = sf ? manager.getSharedFolderData(el) : manager.getFileData(el);
}
parsed = (data.href && data.href.indexOf('#') !== -1) ? Hash.parsePadUrl(data.href) : {};
// Form: get auditor hash
var auditorHash;
if (parsed.hash && parsed.type === "form") {
console.error('ICI');
var formData = Hash.getFormData(null, parsed.hash, data.password);
console.log(formData);
if (formData) {
auditorHash = formData.form_auditorHash;
}
}
var roParsed = Hash.parsePadUrl(data.roHref);
var padType = parsed.type || roParsed.type;
var ro = !sf || (folders[el] && folders[el].version >= 2);
@ -4463,6 +4476,7 @@ define([
viewHash: ro && roParsed.hash,
fileHash: parsed.hash
},
auditorHash: auditorHash,
fileData: {
hash: parsed.hash,
password: data.password

@ -31,22 +31,15 @@ define([
meta.form_auditorHash = hash;
}
var secondary = keys && keys.secondaryKey;
if (!secondary) { return; }
var curvePair = Nacl.box.keyPair.fromSecretKey(Nacl.util.decodeUTF8(secondary).slice(0,32));
var formData = Utils.Hash.getFormData(Utils.secret);
if (!formData) { return; }
var validateKey = keys.secondaryValidateKey;
meta.form_answerValidateKey = validateKey;
publicKey = meta.form_public = Nacl.util.encodeBase64(curvePair.publicKey);
privateKey = meta.form_private = Nacl.util.encodeBase64(curvePair.secretKey);
var auditorHash = Utils.Hash.getViewHashFromKeys({
version: 1,
channel: Utils.secret.channel,
keys: { viewKeyStr: Nacl.util.encodeBase64(keys.cryptKey) }
});
var _parsed = Utils.Hash.parseTypeHash('pad', auditorHash);
meta.form_auditorHash = _parsed.getHash({auditorKey: privateKey});
publicKey = meta.form_public = formData.form_public;
privateKey = meta.form_private = formData.form_private;
meta.form_auditorHash = formData.form_auditorHash;
};
var addRpc = function (sframeChan, Cryptpad, Utils) {
sframeChan.on('EV_FORM_PIN', function (data) {

Loading…
Cancel
Save