From 57979f6314d758d2a5608d79da4ead6e0634b143 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 15 May 2017 13:53:43 +0200 Subject: [PATCH] Display the public key using a href in the settings page --- www/common/common-hash.js | 6 ++++++ www/common/cryptpad-common.js | 1 + www/settings/main.js | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/www/common/common-hash.js b/www/common/common-hash.js index 401291d6c..ff5e29e85 100644 --- a/www/common/common-hash.js +++ b/www/common/common-hash.js @@ -34,6 +34,9 @@ define([ var getFileHashFromKeys = Hash.getFileHashFromKeys = function (fileKey, cryptKey) { return '/1/' + hexToBase64(fileKey) + '/' + Crypto.b64RemoveSlashes(cryptKey) + '/'; }; + var getUserHrefFromKeys = Hash.getUserHrefFromKeys = function (username, pubkey) { + return window.location.origin + '/user/#/1/' + username + '/' + pubkey.replace(/\//g, '-'); + }; var fixDuplicateSlashes = function (s) { return s.replace(/\/+/g, '/'); @@ -188,6 +191,9 @@ Version 1 // version 2 hashes are to be used for encrypted blobs secret.channel = parsed.channel; secret.keys = { fileKeyStr: parsed.key }; + } else if (parsed.type === "user") { + // version 2 hashes are to be used for encrypted blobs + throw new Error("User hashes can't be opened (yet)"); } } } diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index f91069286..5c1b747e5 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -85,6 +85,7 @@ define([ common.getEditHashFromKeys = Hash.getEditHashFromKeys; common.getViewHashFromKeys = Hash.getViewHashFromKeys; common.getFileHashFromKeys = Hash.getFileHashFromKeys; + common.getUserHrefFromKeys = Hash.getUserHrefFromKeys; common.getSecrets = Hash.getSecrets; common.getHashes = Hash.getHashes; common.createChannelId = Hash.createChannelId; diff --git a/www/settings/main.js b/www/settings/main.js index 7abff2e85..6a14fe819 100644 --- a/www/settings/main.js +++ b/www/settings/main.js @@ -49,13 +49,14 @@ define([ var publicKey = obj.edPublic; if (publicKey) { + var userHref = Cryptpad.getUserHrefFromKeys(accountName, publicKey); var $pubLabel = $('', {'class': 'label'}) .text(Messages.settings_publicSigningKey + ':'); var $pubKey = $('', {type: 'text', readonly: true}) .css({ width: '28em' }) - .val(publicKey); + .val(userHref); $div.append('
').append($pubLabel).append($pubKey); }