diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index 5405bf319..10db8c37c 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -3559,7 +3559,7 @@ define([ $(link).click(function (e) { e.preventDefault(); e.stopPropagation(); - var obj = { pw: msg.content.password || '' }; + var obj = { pw: msg.content.password || '', f: 1 }; common.openURL(Hash.getNewPadURL(msg.content.href, obj)); }); @@ -3615,7 +3615,7 @@ define([ // Add the pad to your drive // This command will also add your mailbox to the metadata log - // The callback is called when the pad is stored, independantly of the metadata command + // The callback is called when the pad is stored, independently of the metadata command if (data.calendar) { var calendarModule = common.makeUniversal('calendar'); var calendarData = data.calendar; diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 4525c8287..e2d6a3746 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -2619,7 +2619,8 @@ define([ disableCache: localStorage['CRYPTPAD_STORE|disableCache'], driveEvents: !rdyCfg.noDrive, //rdyCfg.driveEvents // Boolean lastVisit: Number(localStorage.lastVisit) || undefined, - blockId: blockId + blockId: blockId, + blockHash: blockHash }; common.userHash = userHash || LocalStore.getUserHash(); diff --git a/www/common/notifications.js b/www/common/notifications.js index 82fb4b45d..8ec80c2e9 100644 --- a/www/common/notifications.js +++ b/www/common/notifications.js @@ -129,6 +129,7 @@ define([ var obj = { p: msg.content.isTemplate ? ['template'] : undefined, t: teamNotification || undefined, + f: 1, pw: msg.content.password || '' }; common.openURL(Hash.getNewPadURL(msg.content.href, obj)); diff --git a/www/common/outer/mailbox-handlers.js b/www/common/outer/mailbox-handlers.js index cfa749084..906be2843 100644 --- a/www/common/outer/mailbox-handlers.js +++ b/www/common/outer/mailbox-handlers.js @@ -8,7 +8,8 @@ define([ '/common/common-hash.js', '/common/common-util.js', '/components/chainpad-crypto/crypto.js', -], function (ApiConfig, Messaging, Hash, Util, Crypto) { + '/common/outer/login-block.js', + ], function (ApiConfig, Messaging, Hash, Util, Crypto, Block) { // Random timeout between 10 and 30 times your sync time (lag + chainpad sync) var getRandomTimeout = function (ctx) { @@ -237,6 +238,14 @@ define([ cb(true); }; + // Encrypt the password under the right key before sending it via URL hash + var encryptPassword = function(ctx, password) { + let uHash = ctx.store.data.blockHash; + let uSecret = Block.parseBlockHash(uHash); + let key = uSecret.keys.symmetric; + return Crypto.encrypt(password, key); + }; + // Hide duplicates when receiving a SHARE_PAD notification: // Keep only one notification per channel: the stronger and more recent one var channels = {}; @@ -265,8 +274,7 @@ define([ } if (content.password) { - var key = ctx.store.driveSecret.keys.cryptKey; - content.password = Crypto.encrypt(content.password, key); + content.password = encryptPassword(ctx, content.password); } // Update the data @@ -384,8 +392,8 @@ define([ var channel = content.channel || content.teamChannel; if (content.password) { - var key = ctx.store.driveSecret.keys.cryptKey; - content.password = Crypto.encrypt(content.password, key); + content.pw = content.password; + content.password = encryptPassword(ctx, content.password); } if (addOwners[channel]) { return void cb(true); } diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index 6c46ced04..b4031d155 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -1083,7 +1083,7 @@ define([ Cryptpad.addSharedFolder(null, secret, cb); } else { var _data = { - password: data.password, + password: data.pw || data.password, href: data.href, channel: data.channel, title: data.title, @@ -1359,7 +1359,7 @@ define([ var viewH = Utils.Hash.getViewHashFromKeys(_secret); var href = Utils.Hash.hashToHref(editH, parsed.type); var roHref = Utils.Hash.hashToHref(viewH, parsed.type); - Cryptpad.setPadAttribute('password', password, w(), parsed.getUrl()); + Cryptpad.setPadAttribute('password', pw, w(), parsed.getUrl()); Cryptpad.setPadAttribute('channel', chan, w(), parsed.getUrl()); Cryptpad.setPadAttribute('href', href, w(), parsed.getUrl()); Cryptpad.setPadAttribute('roHref', roHref, w(), parsed.getUrl());