Merge branch 'checkpoint-bug' into merge-checkpoint-bug

pull/1/head
ansuz 7 years ago
commit 41583b7858

@ -68,7 +68,7 @@ define([], function () {
// shim between chainpad and netflux
var msgIn = function (peerId, msg) {
return msg.replace(/^cp\|/, '');
return msg.replace(/^cp\|([A-Za-z0-9+\/=]+\|)?/, '');
};
var msgOut = function (msg) {

@ -443,7 +443,7 @@ define([
patchTransformer: options.patchTransformer || ChainPad.SmartJSONTransformer,
// cryptpad debug logging (default is 1)
// logLevel: 2,
logLevel: 2,
validateContent: options.validateContent || function (content) {
try {
JSON.parse(content);

@ -55,7 +55,16 @@ define([], function () {
if (readOnly) { return; }
try {
var cmsg = Crypto.encrypt(msg);
if (msg.indexOf('[4') === 0) { cmsg = 'cp|' + cmsg; }
if (msg.indexOf('[4') === 0) {
var id = '';
if (window.nacl) {
var hash = window.nacl.hash(window.nacl.util.decodeUTF8(msg));
id = window.nacl.util.encodeBase64(hash.slice(0, 8)) + '|';
} else {
console.log("Checkpoint sent without an ID. Nacl is missing.");
}
cmsg = 'cp|' + id + cmsg;
}
return cmsg;
} catch (err) {
console.log(msg);

Loading…
Cancel
Save