Display the public key using a href in the settings page

pull/1/head
yflory 8 years ago
parent 50d9f72b3a
commit 57979f6314

@ -34,6 +34,9 @@ define([
var getFileHashFromKeys = Hash.getFileHashFromKeys = function (fileKey, cryptKey) { var getFileHashFromKeys = Hash.getFileHashFromKeys = function (fileKey, cryptKey) {
return '/1/' + hexToBase64(fileKey) + '/' + Crypto.b64RemoveSlashes(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) { var fixDuplicateSlashes = function (s) {
return s.replace(/\/+/g, '/'); return s.replace(/\/+/g, '/');
@ -188,6 +191,9 @@ Version 1
// version 2 hashes are to be used for encrypted blobs // version 2 hashes are to be used for encrypted blobs
secret.channel = parsed.channel; secret.channel = parsed.channel;
secret.keys = { fileKeyStr: parsed.key }; 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)");
} }
} }
} }

@ -85,6 +85,7 @@ define([
common.getEditHashFromKeys = Hash.getEditHashFromKeys; common.getEditHashFromKeys = Hash.getEditHashFromKeys;
common.getViewHashFromKeys = Hash.getViewHashFromKeys; common.getViewHashFromKeys = Hash.getViewHashFromKeys;
common.getFileHashFromKeys = Hash.getFileHashFromKeys; common.getFileHashFromKeys = Hash.getFileHashFromKeys;
common.getUserHrefFromKeys = Hash.getUserHrefFromKeys;
common.getSecrets = Hash.getSecrets; common.getSecrets = Hash.getSecrets;
common.getHashes = Hash.getHashes; common.getHashes = Hash.getHashes;
common.createChannelId = Hash.createChannelId; common.createChannelId = Hash.createChannelId;

@ -49,13 +49,14 @@ define([
var publicKey = obj.edPublic; var publicKey = obj.edPublic;
if (publicKey) { if (publicKey) {
var userHref = Cryptpad.getUserHrefFromKeys(accountName, publicKey);
var $pubLabel = $('<span>', {'class': 'label'}) var $pubLabel = $('<span>', {'class': 'label'})
.text(Messages.settings_publicSigningKey + ':'); .text(Messages.settings_publicSigningKey + ':');
var $pubKey = $('<input>', {type: 'text', readonly: true}) var $pubKey = $('<input>', {type: 'text', readonly: true})
.css({ .css({
width: '28em' width: '28em'
}) })
.val(publicKey); .val(userHref);
$div.append('<br>').append($pubLabel).append($pubKey); $div.append('<br>').append($pubLabel).append($pubKey);
} }

Loading…
Cancel
Save