Merge branch 'staging' of github.com:xwiki-labs/cryptpad into staging
This commit is contained in:
commit
12898b3358
5 changed files with 42 additions and 22 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -12,3 +12,4 @@ www/scratch
|
||||||
data
|
data
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
pins/
|
pins/
|
||||||
|
blob/
|
||||||
|
|
|
@ -82,6 +82,8 @@ var mainPages = config.mainPages || ['index', 'privacy', 'terms', 'about', 'cont
|
||||||
var mainPagePattern = new RegExp('^\/(' + mainPages.join('|') + ').html$');
|
var mainPagePattern = new RegExp('^\/(' + mainPages.join('|') + ').html$');
|
||||||
app.get(mainPagePattern, Express.static(__dirname + '/customize.dist'));
|
app.get(mainPagePattern, Express.static(__dirname + '/customize.dist'));
|
||||||
|
|
||||||
|
app.use("/blob", Express.static(__dirname + '/blob'));
|
||||||
|
|
||||||
app.use("/customize", Express.static(__dirname + '/customize'));
|
app.use("/customize", Express.static(__dirname + '/customize'));
|
||||||
app.use("/customize", Express.static(__dirname + '/customize.dist'));
|
app.use("/customize", Express.static(__dirname + '/customize.dist'));
|
||||||
app.use(/^\/[^\/]*$/, Express.static('customize'));
|
app.use(/^\/[^\/]*$/, Express.static('customize'));
|
||||||
|
|
|
@ -23,13 +23,16 @@ define([
|
||||||
return chanKey + keys;
|
return chanKey + keys;
|
||||||
}
|
}
|
||||||
if (!keys.editKeyStr) { return; }
|
if (!keys.editKeyStr) { return; }
|
||||||
return '/1/edit/' + hexToBase64(chanKey) + '/' + Crypto.b64RemoveSlashes(keys.editKeyStr);
|
return '/1/edit/' + hexToBase64(chanKey) + '/'+Crypto.b64RemoveSlashes(keys.editKeyStr)+'/';
|
||||||
};
|
};
|
||||||
var getViewHashFromKeys = Hash.getViewHashFromKeys = function (chanKey, keys) {
|
var getViewHashFromKeys = Hash.getViewHashFromKeys = function (chanKey, keys) {
|
||||||
if (typeof keys === 'string') {
|
if (typeof keys === 'string') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return '/1/view/' + hexToBase64(chanKey) + '/' + Crypto.b64RemoveSlashes(keys.viewKeyStr);
|
return '/1/view/' + hexToBase64(chanKey) + '/'+Crypto.b64RemoveSlashes(keys.viewKeyStr)+'/';
|
||||||
|
};
|
||||||
|
var getFileHashFromKey = Hash.getFileHashFromKey = function (fileKey, cryptKey, type) {
|
||||||
|
return '/2/' + hexToBase64(fileKey) + '/' + Crypto.b64RemoveSlashes(cryptKey) + '/' + Crypto.base64RemoveSlashes(type);
|
||||||
};
|
};
|
||||||
|
|
||||||
var parsePadUrl = Hash.parsePadUrl = function (href) {
|
var parsePadUrl = Hash.parsePadUrl = function (href) {
|
||||||
|
@ -119,7 +122,9 @@ define([
|
||||||
}
|
}
|
||||||
} else if (version === "2") {
|
} else if (version === "2") {
|
||||||
// version 2 hashes are to be used for encrypted blobs
|
// version 2 hashes are to be used for encrypted blobs
|
||||||
// TODO
|
var fileId = secret.file = hashArray[2].replace(/-/g, '/');
|
||||||
|
var key = secret.key = hashArray[3].replace(/-/g, '/');
|
||||||
|
var type = secret.type = hashArray[4].replace(/-/g, '/');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,7 +155,7 @@ define([
|
||||||
var channelId = Util.hexToBase64(createChannelId());
|
var channelId = Util.hexToBase64(createChannelId());
|
||||||
// 18 byte encryption key
|
// 18 byte encryption key
|
||||||
var key = Crypto.b64RemoveSlashes(Crypto.rand64(18));
|
var key = Crypto.b64RemoveSlashes(Crypto.rand64(18));
|
||||||
return '/1/edit/' + [channelId, key].join('/');
|
return '/1/edit/' + [channelId, key].join('/') + '/';
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -159,8 +164,8 @@ Version 0
|
||||||
Version 1
|
Version 1
|
||||||
/code/#/1/edit/3Ujt4F2Sjnjbis6CoYWpoQ/usn4+9CqVja8Q7RZOGTfRgqI
|
/code/#/1/edit/3Ujt4F2Sjnjbis6CoYWpoQ/usn4+9CqVja8Q7RZOGTfRgqI
|
||||||
Version 2
|
Version 2
|
||||||
/file/<fileId>/#/2/<cryptKey>/<contentType>
|
/file/#/2/<fileId>/<cryptKey>/<contentType>
|
||||||
/file/<fileId>/#/2/ajExFODrFH4lVBwxxsrOKw/pdf
|
/file/#/2/K6xWU-LT9BJHCQcDCT-DcQ/ajExFODrFH4lVBwxxsrOKw/image-png
|
||||||
*/
|
*/
|
||||||
var parseHash = Hash.parseHash = function (hash) {
|
var parseHash = Hash.parseHash = function (hash) {
|
||||||
var parsed = {};
|
var parsed = {};
|
||||||
|
@ -177,7 +182,14 @@ Version 2
|
||||||
parsed.mode = hashArr[2];
|
parsed.mode = hashArr[2];
|
||||||
parsed.channel = hashArr[3];
|
parsed.channel = hashArr[3];
|
||||||
parsed.key = hashArr[4];
|
parsed.key = hashArr[4];
|
||||||
parsed.present = hashArr[5] && hashArr[5] === 'present';
|
parsed.present = typeof(hashArr[5]) === "string" && hashArr[5] === 'present';
|
||||||
|
return parsed;
|
||||||
|
}
|
||||||
|
if (hashArr[1] && hashArr[1] === '2') {
|
||||||
|
parsed.version = 2;
|
||||||
|
parsed.file = hashArr[2].replace(/-/g, '/');
|
||||||
|
parsed.key = hashArr[3].replace(/-/g, '/');
|
||||||
|
parsed.type = hashArr[4].replace(/-/g, '/');
|
||||||
return parsed;
|
return parsed;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -514,7 +514,7 @@ define([
|
||||||
|
|
||||||
if (p.type !== parsed.type) { return pad; }
|
if (p.type !== parsed.type) { return pad; }
|
||||||
|
|
||||||
var shouldUpdate = p.hash === parsed.hash;
|
var shouldUpdate = p.hash.replace(/\/$/, '') === parsed.hash.replace(/\/$/, '');
|
||||||
|
|
||||||
// Version 1 : we have up to 4 differents hash for 1 pad, keep the strongest :
|
// Version 1 : we have up to 4 differents hash for 1 pad, keep the strongest :
|
||||||
// Edit > Edit (present) > View > View (present)
|
// Edit > Edit (present) > View > View (present)
|
||||||
|
|
|
@ -16,20 +16,25 @@ define([
|
||||||
var $iframe = $('#pad-iframe').contents();
|
var $iframe = $('#pad-iframe').contents();
|
||||||
|
|
||||||
Cryptpad.addLoadingScreen();
|
Cryptpad.addLoadingScreen();
|
||||||
var toolbar;
|
|
||||||
|
|
||||||
var andThen = function () {
|
var andThen = function () {
|
||||||
var $bar = $iframe.find('.toolbar-container');
|
var $bar = $iframe.find('.toolbar-container');
|
||||||
var secret = Cryptpad.getSecrets();
|
var secret = Cryptpad.getSecrets();
|
||||||
var readOnly = secret.keys && !secret.keys.editKeyStr;
|
|
||||||
if (!secret.keys) {
|
if (secret.keys) { throw new Error("You need a hash"); } // TODO
|
||||||
secret.keys = secret.key;
|
|
||||||
}
|
var cryptKey = secret.key;
|
||||||
|
var fileId = secret.file;
|
||||||
|
var hexFileName = Cryptpad.base64ToHex(fileId);
|
||||||
|
var type = secret.type;
|
||||||
|
|
||||||
|
// Test hash:
|
||||||
|
// #/2/K6xWU-LT9BJHCQcDCT-DcQ/TBo77200c0e-FdldQFcnQx4Y/image-png
|
||||||
|
|
||||||
var $mt = $iframe.find('#encryptedFile');
|
var $mt = $iframe.find('#encryptedFile');
|
||||||
$mt.attr('src', './assets/image.png-encrypted');
|
$mt.attr('src', '/blob/' + hexFileName.slice(0,2) + '/' + hexFileName);
|
||||||
$mt.attr('data-crypto-key', 'TBo77200c0e/FdldQFcnQx4Y');
|
$mt.attr('data-crypto-key', cryptKey);
|
||||||
$mt.attr('data-type', 'image/png');
|
$mt.attr('data-type', type);
|
||||||
require(['/common/media-tag.js'], function (MediaTag) {
|
require(['/common/media-tag.js'], function (MediaTag) {
|
||||||
MediaTag($mt[0]);
|
MediaTag($mt[0]);
|
||||||
Cryptpad.removeLoadingScreen();
|
Cryptpad.removeLoadingScreen();
|
||||||
|
@ -38,7 +43,7 @@ define([
|
||||||
ifrw: ifrw,
|
ifrw: ifrw,
|
||||||
common: Cryptpad
|
common: Cryptpad
|
||||||
};
|
};
|
||||||
toolbar = Toolbar.create($bar, null, null, null, null, configTb);
|
Toolbar.create($bar, null, null, null, null, configTb);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue