Receiving a burn after reading URL

pull/1/head
yflory 5 years ago
parent 96a00f89df
commit 9ee9e46087

@ -97,6 +97,12 @@
.ckeditor_fix(); .ckeditor_fix();
.cp-burn-after-reading {
text-align: center;
font-size: @colortheme_app-font-size !important;
margin: 0 !important;
}
.cp-markdown-toolbar { .cp-markdown-toolbar {
height: @toolbar_line-height; height: @toolbar_line-height;
background-color: @toolbar-bg-color-l20; background-color: @toolbar-bg-color-l20;

@ -98,6 +98,7 @@ define([
}; };
var mkHelpMenu = function (framework) { var mkHelpMenu = function (framework) {
var $codeMirrorContainer = $('#cp-app-code-container'); var $codeMirrorContainer = $('#cp-app-code-container');
$codeMirrorContainer.prepend(framework._.sfCommon.getBurnAfterReadingWarning());
var helpMenu = framework._.sfCommon.createHelpMenu(['text', 'code']); var helpMenu = framework._.sfCommon.createHelpMenu(['text', 'code']);
$codeMirrorContainer.prepend(helpMenu.menu); $codeMirrorContainer.prepend(helpMenu.menu);

@ -3978,6 +3978,7 @@ define([
UIElements.onServerError = function (common, err, toolbar, cb) { UIElements.onServerError = function (common, err, toolbar, cb) {
if (["EDELETED", "EEXPIRED"].indexOf(err.type) === -1) { return; } if (["EDELETED", "EEXPIRED"].indexOf(err.type) === -1) { return; }
var priv = common.getMetadataMgr().getPrivateData();
var msg = err.type; var msg = err.type;
if (err.type === 'EEXPIRED') { if (err.type === 'EEXPIRED') {
msg = Messages.expiredError; msg = Messages.expiredError;
@ -3985,6 +3986,7 @@ define([
msg += Messages.errorCopy; msg += Messages.errorCopy;
} }
} else if (err.type === 'EDELETED') { } else if (err.type === 'EDELETED') {
if (priv.burnAfterReading) { return void cb(); }
msg = Messages.deletedError; msg = Messages.deletedError;
if (err.loaded) { if (err.loaded) {
msg += Messages.errorCopy; msg += Messages.errorCopy;
@ -4034,6 +4036,26 @@ define([
$password.find('.cp-password-input').focus(); $password.find('.cp-password-input').focus();
}; };
UIElements.displayBurnAfterReadingPage = function (common, cb) {
var info = h('p.cp-password-info', 'XXX Burn after reading'); // XXX
var button = h('button', 'Proceed'); // XXX
$(button).on('click', function () {
cb();
});
var block = h('div#cp-loading-burn-after-reading', [
info,
button
]);
UI.errorLoadingScreen(block);
};
UIElements.getBurnAfterReadingWarning = function (common) {
var priv = common.getMetadataMgr().getPrivateData();
if (!priv.burnAfterReading) { return; }
return h('div.alert.alert-danger.cp-burn-after-reading', 'Pewpewpew'); // XXX
};
var crowdfundingState = false; var crowdfundingState = false;
UIElements.displayCrowdfunding = function (common) { UIElements.displayCrowdfunding = function (common) {
if (crowdfundingState) { return; } if (crowdfundingState) { return; }
@ -4091,6 +4113,9 @@ define([
if (data && data.stored) { return; } // We won't display the popup for dropped files if (data && data.stored) { return; } // We won't display the popup for dropped files
var priv = common.getMetadataMgr().getPrivateData(); var priv = common.getMetadataMgr().getPrivateData();
// This pad will be deleted automatically, it shouldn't be stored
if (priv.burnAfterReading) { return; }
var typeMsg = priv.pathname.indexOf('/file/') !== -1 ? Messages.autostore_file : var typeMsg = priv.pathname.indexOf('/file/') !== -1 ? Messages.autostore_file :
priv.pathname.indexOf('/drive/') !== -1 ? Messages.autostore_sf : priv.pathname.indexOf('/drive/') !== -1 ? Messages.autostore_sf :
Messages.autostore_pad; Messages.autostore_pad;

@ -847,6 +847,10 @@ define([
postMessage('GET_PAD_METADATA', data, cb); postMessage('GET_PAD_METADATA', data, cb);
}; };
common.burnPad = function (data) {
postMessage('BURN_PAD', data);
};
common.changePadPassword = function (Crypt, Crypto, data, cb) { common.changePadPassword = function (Crypt, Crypto, data, cb) {
var href = data.href; var href = data.href;
var newPassword = data.password; var newPassword = data.password;

@ -926,6 +926,7 @@ define([
$rightside.append($forget); $rightside.append($forget);
var helpMenu = common.createHelpMenu(['beta', 'oo']); var helpMenu = common.createHelpMenu(['beta', 'oo']);
$('#cp-app-oo-editor').prepend(common.getBurnAfterReadingWarning());
$('#cp-app-oo-editor').prepend(helpMenu.menu); $('#cp-app-oo-editor').prepend(helpMenu.menu);
toolbar.$drawer.append(helpMenu.button); toolbar.$drawer.append(helpMenu.button);

@ -9,6 +9,7 @@ define([
'/common/common-feedback.js', '/common/common-feedback.js',
'/common/common-realtime.js', '/common/common-realtime.js',
'/common/common-messaging.js', '/common/common-messaging.js',
'/common/pinpad.js',
'/common/outer/sharedfolder.js', '/common/outer/sharedfolder.js',
'/common/outer/cursor.js', '/common/outer/cursor.js',
'/common/outer/onlyoffice.js', '/common/outer/onlyoffice.js',
@ -26,7 +27,7 @@ define([
'/bower_components/nthen/index.js', '/bower_components/nthen/index.js',
'/bower_components/saferphore/index.js', '/bower_components/saferphore/index.js',
], function (Sortify, UserObject, ProxyManager, Migrate, Hash, Util, Constants, Feedback, ], function (Sortify, UserObject, ProxyManager, Migrate, Hash, Util, Constants, Feedback,
Realtime, Messaging, Realtime, Messaging, Pinpad,
SF, Cursor, OnlyOffice, Mailbox, Profile, Team, Messenger, SF, Cursor, OnlyOffice, Mailbox, Profile, Team, Messenger,
NetConfig, AppConfig, NetConfig, AppConfig,
Crypto, ChainPad, CpNetflux, Listmap, nThen, Saferphore) { Crypto, ChainPad, CpNetflux, Listmap, nThen, Saferphore) {
@ -409,19 +410,17 @@ define([
var initRpc = function (clientId, data, cb) { var initRpc = function (clientId, data, cb) {
if (!store.loggedIn) { return cb(); } if (!store.loggedIn) { return cb(); }
if (store.rpc) { return void cb(account); } if (store.rpc) { return void cb(account); }
require(['/common/pinpad.js'], function (Pinpad) { Pinpad.create(store.network, store.proxy, function (e, call) {
Pinpad.create(store.network, store.proxy, function (e, call) { if (e) { return void cb({error: e}); }
if (e) { return void cb({error: e}); }
store.rpc = call; store.rpc = call;
Store.getPinLimit(null, null, function (obj) { Store.getPinLimit(null, null, function (obj) {
if (obj.error) { console.error(obj.error); } if (obj.error) { console.error(obj.error); }
account.limit = obj.limit; account.limit = obj.limit;
account.plan = obj.plan; account.plan = obj.plan;
account.note = obj.note; account.note = obj.note;
cb(obj); cb(obj);
});
}); });
}); });
}; };
@ -1653,6 +1652,28 @@ define([
cb(); cb();
}; };
// Delete a pad received with a burn after reading URL
Store.burnPad = function (clientId, data, cb) {
var channel = data.channel;
var ownerKey = Crypto.b64AddSlashes(data.ownerKey || '');
if (!channel || !ownerKey) { return void console.error("Can't delete BAR pad"); }
try {
var signKey = Hash.decodeBase64(ownerKey);
var pair = Crypto.Nacl.sign.keyPair.fromSecretKey(signKey);
Pinpad.create(store.network, {
edPublic: Hash.encodeBase64(pair.publicKey),
edPrivate: Hash.encodeBase64(pair.secretKey)
}, function (e, rpc) {
if (e) { return void console.error(e); }
rpc.removeOwnedChannel(channel, function (err) {
if (err) { console.error(err); }
});
});
} catch (e) {
console.error(e);
}
};
// Fetch the latest version of the metadata on the server and return it. // Fetch the latest version of the metadata on the server and return it.
// If the pad is stored in our drive, update the local values of "owners" and "expire" // If the pad is stored in our drive, update the local values of "owners" and "expire"
Store.getPadMetadata = function (clientId, data, cb) { Store.getPadMetadata = function (clientId, data, cb) {

@ -80,6 +80,7 @@ define([
IS_NEW_CHANNEL: Store.isNewChannel, IS_NEW_CHANNEL: Store.isNewChannel,
REQUEST_PAD_ACCESS: Store.requestPadAccess, REQUEST_PAD_ACCESS: Store.requestPadAccess,
GIVE_PAD_ACCESS: Store.givePadAccess, GIVE_PAD_ACCESS: Store.givePadAccess,
BURN_PAD: Store.burnPad,
GET_PAD_METADATA: Store.getPadMetadata, GET_PAD_METADATA: Store.getPadMetadata,
SET_PAD_METADATA: Store.setPadMetadata, SET_PAD_METADATA: Store.setPadMetadata,
CHANGE_PAD_PASSWORD_PIN: Store.changePadPasswordPin, CHANGE_PAD_PASSWORD_PIN: Store.changePadPasswordPin,

@ -323,6 +323,7 @@ define([
} }
Utils.crypto = Utils.Crypto.createEncryptor(Utils.secret.keys); Utils.crypto = Utils.Crypto.createEncryptor(Utils.secret.keys);
var parsed = Utils.Hash.parsePadUrl(window.location.href); var parsed = Utils.Hash.parsePadUrl(window.location.href);
var burnAfterReading = parsed && parsed.hashData && parsed.hashData.ownerKey;
if (!parsed.type) { throw new Error(); } if (!parsed.type) { throw new Error(); }
var defaultTitle = Utils.UserObject.getDefaultName(parsed); var defaultTitle = Utils.UserObject.getDefaultName(parsed);
var edPublic, curvePublic, notifications, isTemplate; var edPublic, curvePublic, notifications, isTemplate;
@ -376,6 +377,7 @@ define([
fromFileData: Cryptpad.fromFileData ? { fromFileData: Cryptpad.fromFileData ? {
title: Cryptpad.fromFileData.title title: Cryptpad.fromFileData.title
} : undefined, } : undefined,
burnAfterReading: burnAfterReading,
storeInTeam: Cryptpad.initialTeam || (Cryptpad.initialPath ? -1 : undefined) storeInTeam: Cryptpad.initialTeam || (Cryptpad.initialPath ? -1 : undefined)
}; };
if (window.CryptPad_newSharedFolder) { if (window.CryptPad_newSharedFolder) {
@ -1235,6 +1237,14 @@ define([
window.location.hash = hash; window.location.hash = hash;
}; };
if (burnAfterReading) {
Cryptpad.padRpc.onReadyEvent.reg(function () {
Cryptpad.burnPad({
channel: secret.channel,
ownerKey: burnAfterReading
});
});
}
var cpNfCfg = { var cpNfCfg = {
sframeChan: sframeChan, sframeChan: sframeChan,
channel: secret.channel, channel: secret.channel,
@ -1358,12 +1368,17 @@ define([
}); });
}); });
sframeChan.on('EV_BURN_AFTER_READING', function () {
startRealtime();
});
sframeChan.ready(); sframeChan.ready();
Utils.Feedback.reportAppUsage(); Utils.Feedback.reportAppUsage();
if (!realtime && !Test.testing) { return; } if (!realtime && !Test.testing) { return; }
if (isNewFile && cfg.useCreationScreen && !Test.testing) { return; } if (isNewFile && cfg.useCreationScreen && !Test.testing) { return; }
if (burnAfterReading) { return; }
//if (isNewFile && Utils.LocalStore.isLoggedIn() //if (isNewFile && Utils.LocalStore.isLoggedIn()
// && AppConfig.displayCreationScreen && cfg.useCreationScreen) { return; } // && AppConfig.displayCreationScreen && cfg.useCreationScreen) { return; }

@ -96,6 +96,7 @@ define([
funcs.createMarkdownToolbar = callWithCommon(UIElements.createMarkdownToolbar); funcs.createMarkdownToolbar = callWithCommon(UIElements.createMarkdownToolbar);
funcs.createHelpMenu = callWithCommon(UIElements.createHelpMenu); funcs.createHelpMenu = callWithCommon(UIElements.createHelpMenu);
funcs.getPadCreationScreen = callWithCommon(UIElements.getPadCreationScreen); funcs.getPadCreationScreen = callWithCommon(UIElements.getPadCreationScreen);
funcs.getBurnAfterReadingWarning = callWithCommon(UIElements.getBurnAfterReadingWarning);
funcs.createNewPadModal = callWithCommon(UIElements.createNewPadModal); funcs.createNewPadModal = callWithCommon(UIElements.createNewPadModal);
funcs.onServerError = callWithCommon(UIElements.onServerError); funcs.onServerError = callWithCommon(UIElements.onServerError);
funcs.importMediaTagMenu = callWithCommon(UIElements.importMediaTagMenu); funcs.importMediaTagMenu = callWithCommon(UIElements.importMediaTagMenu);
@ -300,6 +301,13 @@ define([
} }
// If we display the pad creation screen, it will handle deleted pads directly // If we display the pad creation screen, it will handle deleted pads directly
funcs.getPadCreationScreen(c, config, waitFor()); funcs.getPadCreationScreen(c, config, waitFor());
return;
}
if (priv.burnAfterReading) {
UIElements.displayBurnAfterReadingPage(funcs, waitFor(function () {
UI.addLoadingScreen();
ctx.sframeChan.event('EV_BURN_AFTER_READING');
}));
} }
}; };
funcs.createPad = function (cfg, cb) { funcs.createPad = function (cfg, cb) {

@ -350,6 +350,8 @@ define([
var mkHelpMenu = function (framework) { var mkHelpMenu = function (framework) {
var $toolbarContainer = $('#cp-app-kanban-container'); var $toolbarContainer = $('#cp-app-kanban-container');
$toolbarContainer.prepend(framework._.sfCommon.getBurnAfterReadingWarning());
var helpMenu = framework._.sfCommon.createHelpMenu(['kanban']); var helpMenu = framework._.sfCommon.createHelpMenu(['kanban']);
$toolbarContainer.prepend(helpMenu.menu); $toolbarContainer.prepend(helpMenu.menu);

@ -190,6 +190,7 @@ define([
var mkHelpMenu = function (framework) { var mkHelpMenu = function (framework) {
var $toolbarContainer = $('.cke_toolbox_main'); var $toolbarContainer = $('.cke_toolbox_main');
$toolbarContainer.before(framework._.sfCommon.getBurnAfterReadingWarning());
var helpMenu = framework._.sfCommon.createHelpMenu(['text', 'pad']); var helpMenu = framework._.sfCommon.createHelpMenu(['text', 'pad']);
$toolbarContainer.before(helpMenu.menu); $toolbarContainer.before(helpMenu.menu);

@ -1187,6 +1187,7 @@ define([
$drawer.append($export); $drawer.append($export);
var helpMenu = common.createHelpMenu(['poll']); var helpMenu = common.createHelpMenu(['poll']);
$('#cp-app-poll-form').prepend(common.getBurnAfterReadingWarning());
$('#cp-app-poll-form').prepend(helpMenu.menu); $('#cp-app-poll-form').prepend(helpMenu.menu);
$drawer.append(helpMenu.button); $drawer.append(helpMenu.button);

@ -410,6 +410,7 @@ define([
var mkHelpMenu = function (framework) { var mkHelpMenu = function (framework) {
var $codeMirrorContainer = $('#cp-app-slide-editor-container'); var $codeMirrorContainer = $('#cp-app-slide-editor-container');
$codeMirrorContainer.prepend(framework._.sfCommon.getBurnAfterReadingWarning());
var helpMenu = framework._.sfCommon.createHelpMenu(['text', 'slide']); var helpMenu = framework._.sfCommon.createHelpMenu(['text', 'slide']);
$codeMirrorContainer.prepend(helpMenu.menu); $codeMirrorContainer.prepend(helpMenu.menu);

@ -270,6 +270,7 @@ define([
var mkHelpMenu = function (framework) { var mkHelpMenu = function (framework) {
var $appContainer = $('#cp-app-whiteboard-container'); var $appContainer = $('#cp-app-whiteboard-container');
$appContainer.prepend(framework._.sfCommon.getBurnAfterReadingWarning());
var helpMenu = framework._.sfCommon.createHelpMenu(['whiteboard']); var helpMenu = framework._.sfCommon.createHelpMenu(['whiteboard']);
$appContainer.prepend(helpMenu.menu); $appContainer.prepend(helpMenu.menu);
framework._.toolbar.$drawer.append(helpMenu.button); framework._.toolbar.$drawer.append(helpMenu.button);

Loading…
Cancel
Save