diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 10db8522a..e2968aa94 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -88,6 +88,10 @@ define([ }; postMessage("MIGRATE_ANON_DRIVE", data, cb); }; + // Settings + common.deleteAccount = function (cb) { + postMessage("DELETE_ACCOUNT", null, cb); + }; // Drive common.userObjectCommand = function (data, cb) { postMessage("DRIVE_USEROBJECT", data, cb); diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index ffd31f1b6..6790f2ed1 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -1,4 +1,5 @@ define([ + 'json.sortify', '/common/userObject.js', '/common/migrate-user-object.js', '/common/common-hash.js', @@ -15,7 +16,7 @@ define([ '/bower_components/chainpad-crypto/crypto.js?v=0.1.5', '/bower_components/chainpad/chainpad.dist.js', '/bower_components/chainpad-listmap/chainpad-listmap.js', -], function (UserObject, Migrate, Hash, Util, Constants, Feedback, Realtime, Messaging, Messenger, +], function (Sortify, UserObject, Migrate, Hash, Util, Constants, Feedback, Realtime, Messaging, Messenger, CpNfWorker, NetConfig, AppConfig, Crypto, ChainPad, Listmap) { var Store = {}; @@ -420,6 +421,23 @@ define([ }); }; + Store.deleteAccount = function (data, cb) { + var toSign = { + intent: 'Please delete my account.' + }; + var secret = Hash.getSecrets('drive', storeHash); + toSign.drive = secret.channel; + toSign.edPublic = store.proxy.edPublic; + var signKey = Crypto.Nacl.util.decodeBase64(secret.keys.signKey); + console.log(Sortify(toSign)); + var proof = Crypto.Nacl.sign.detached(Crypto.Nacl.util.decodeUTF8(Sortify(toSign)), signKey); + var proofTxt = Crypto.Nacl.util.encodeBase64(proof); + cb({ + proof: proofTxt, + toSign: JSON.parse(Sortify(toSign)) + }); + }; + /** * add a "What is CryptPad?" pad in the drive * data diff --git a/www/common/outer/store-rpc.js b/www/common/outer/store-rpc.js index 7c4bff116..1043f9dcf 100644 --- a/www/common/outer/store-rpc.js +++ b/www/common/outer/store-rpc.js @@ -172,7 +172,10 @@ define([ case 'DRIVE_USEROBJECT': { Store.userObjectCommand(data, cb); break; } - + // Settings + case 'DELETE_ACCOUNT': { + Store.deleteAccount(data, cb); break; + } case 'IS_NEW_CHANNEL': { Store.isNewChannel(data, cb); break; } diff --git a/www/common/sframe-protocol.js b/www/common/sframe-protocol.js index f49b3ed11..4c3046ad9 100644 --- a/www/common/sframe-protocol.js +++ b/www/common/sframe-protocol.js @@ -193,6 +193,7 @@ define({ 'Q_SETTINGS_LOGOUT': true, // Import pads from this computer's anon session into the current user account 'Q_SETTINGS_IMPORT_LOCAL': true, + 'Q_SETTINGS_DELETE_ACCOUNT': true, // Store the language selected in the iframe into localStorage outside 'Q_LANGUAGE_SET': true, diff --git a/www/settings/app-settings.less b/www/settings/app-settings.less index 187b75da8..bb033c6dc 100644 --- a/www/settings/app-settings.less +++ b/www/settings/app-settings.less @@ -138,5 +138,9 @@ } } } + + .cp-app-settings-delete-alert { + pre { color: inherit; } + } } diff --git a/www/settings/inner.js b/www/settings/inner.js index 86870d950..43967c3e4 100644 --- a/www/settings/inner.js +++ b/www/settings/inner.js @@ -47,7 +47,8 @@ define([ 'cp-settings-logout-everywhere', 'cp-settings-resettips', 'cp-settings-thumbnails', - 'cp-settings-userfeedback' + 'cp-settings-userfeedback', + 'cp-settings-delete' ], 'creation': [ 'cp-settings-creation-owned', @@ -317,6 +318,48 @@ define([ return $div; }; + create['delete'] = function () { + var $div = $('
', { 'class': 'cp-settings-delete cp-sidebarlayout-element'}); + + $('', {'class': 'label'}).text('DELETE ACCOUNT').appendTo($div); // XXX + + $('', {'class': 'cp-sidebarlayout-description'}) + .append('DELETE ACCOUNT DESCRIPTION').appendTo($div); // XXX + + //var $ok = $('', {'class': 'fa fa-check', title: Messages.saved}); + var $spinner = $('', {'class': 'fa fa-spinner fa-pulse'}); + + var $button = $('