Skip to content

Commit

Permalink
Multiple key for browser added
Browse files Browse the repository at this point in the history
  • Loading branch information
HYUN KYU SEO committed Sep 24, 2019
1 parent 7ff781b commit 2d7c2f2
Show file tree
Hide file tree
Showing 10 changed files with 166 additions and 44 deletions.
13 changes: 9 additions & 4 deletions app/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ main {
position: relative;
min-height: 100%;
}
.hidden {
display:none;
}
.hidden-label {
position:absolute;
opacity:0.01;
Expand Down Expand Up @@ -856,14 +859,14 @@ main {
display: table;
clear: both;
}
.downloaded-fingerprint-container a.searched-key-download, .downloaded-fingerprint-container button.searched-key-copy {
.downloaded-key-container a.searched-key-download, .downloaded-key-container button.searched-key-copy {
width:50%;
}
.downloaded-fingerprint-container a.searched-key-download-steg {
.downloaded-key-container a.searched-key-download-steg {
width:100%;
margin-top:1px;
}
.downloaded-fingerprint-container {
.downloaded-key-container {
width:100%;
margin-bottom:0.5em;
}
Expand Down Expand Up @@ -917,7 +920,9 @@ main {
button:disabled img, button[disabled], .button-2.disabled img, .button-2.disabled {
opacity: 0.3;
}
.button-2.disabled, .button-2.disabled:hover, .button-2.disabled:focus, .button-2.disabled:active, button:disabled, button[disabled], button:disabled:hover, button[disabled]:hover, button:disabled:active, button[disabled]:active, button:disabled:focus, button[disabled]:focus {
.button-1.disabled, .button-1.disabled:hover, .button-1.disabled:focus, .button-1.disabled:active,
.button-2.disabled, .button-2.disabled:hover, .button-2.disabled:focus, .button-2.disabled:active,
button:disabled, button[disabled], button:disabled:hover, button[disabled]:hover, button:disabled:active, button[disabled]:active, button:disabled:focus, button[disabled]:focus {
cursor: not-allowed;
background-color: #BEBEBE;
color: #8C8C8C;
Expand Down
16 changes: 9 additions & 7 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,16 @@ <h3>Search for public key</h3>
<button class="button-1 search-pubkey" disabled="">Search</button>
</section>
<section class="cf">
<h3>Search result</h3>
<h3><span class="search-status">Search not started</span>
<span class="copied">Copied</span></h3>
<ul class="search-results">
<li>
<span class="search-status">Search not started</span>
<span class="copied">Copied</span>
</li>
<li class="search-result">
<div class="downloaded-fingerprint-container cf">
<label for="search-result-list" class="hidden-label">Key selector</label>
<div class="select-wrapper">
<select id="search-result-list" class="search-result-list">
</select>
</div>
<div class="downloaded-key-container cf">
<a class="button-1 searched-key-download blob-download" href="#" target="_blank">
<span>Download key</span>
<img class="button-icon-img" src="./ui/download.svg" alt="Download searched key">
Expand All @@ -304,7 +306,7 @@ <h3>Search result</h3>
<span>Copy key</span>
<img class="button-icon-img" src="./ui/copy.svg" alt="Copy searched key to clipboard">
</button>
<a class="button-2 searched-key-download-steg blob-download" href="#" target="_blank">
<a class="button-2 searched-key-download-steg" href="#" target="_blank">
<span>Download key as image</span>
<img class="button-icon-img" src="./ui/download.svg" alt="Download searched key as an image">
</a>
Expand Down
74 changes: 64 additions & 10 deletions app/js/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/pwa.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let cacheName = "mp11101";
let cacheName = "mp12101";

let contentToCache = ["css/main.css","css_include/reset.css","favicon/android-icon-144x144.png","favicon/android-icon-192x192.png","favicon/android-icon-36x36.png","favicon/android-icon-48x48.png","favicon/android-icon-512x512.png","favicon/android-icon-72x72.png","favicon/android-icon-96x96.png","favicon/apple-icon-114x114.png","favicon/apple-icon-120x120.png","favicon/apple-icon-144x144.png","favicon/apple-icon-152x152.png","favicon/apple-icon-180x180.png","favicon/apple-icon-57x57.png","favicon/apple-icon-60x60.png","favicon/apple-icon-72x72.png","favicon/apple-icon-76x76.png","favicon/apple-icon-precomposed.png","favicon/apple-icon.png","favicon/browserconfig.xml","favicon/favicon-16x16.png","favicon/favicon-32x32.png","favicon/favicon-96x96.png","favicon/favicon.ico","favicon/ms-icon-144x144.png","favicon/ms-icon-150x150.png","favicon/ms-icon-310x310.png","favicon/ms-icon-70x70.png","fonts/ibmplexmono-regular-webfont.ttf","fonts/ibmplexmono-regular-webfont.woff","fonts/ibmplexmono-regular-webfont.woff2","fonts/ibmplexsans-bold-webfont.ttf","fonts/ibmplexsans-bold-webfont.woff","fonts/ibmplexsans-bold-webfont.woff2","fonts/ibmplexsans-light-webfont.ttf","fonts/ibmplexsans-light-webfont.woff","fonts/ibmplexsans-light-webfont.woff2","fonts/ibmplexsans-regular-webfont.ttf","fonts/ibmplexsans-regular-webfont.woff","fonts/ibmplexsans-regular-webfont.woff2","fonts/stylesheet.css","index.html","js/main.js","js_include/jquery-3.4.1.min.js","js_include/openpgp.min.js","js_include/steganography.min.js","manifest.json","ui/copy.svg","ui/decrypt.svg","ui/download.svg","ui/dropdown.svg","ui/encrypt.svg","ui/exit-black.svg","ui/exit.svg","ui/expand.svg","ui/generate.svg","ui/menu.svg","ui/minimize.svg","ui/popup.svg","ui/purge.svg","ui/remove.svg","ui/restart.svg","ui/save.svg","ui/selectfile.svg","ui/upload.svg","webapp/apple-launch-1125x2436.png","webapp/apple-launch-1242x2208.png","webapp/apple-launch-1242x2688.png","webapp/apple-launch-1536x2048.png","webapp/apple-launch-1668x2224.png","webapp/apple-launch-1668x2388.png","webapp/apple-launch-2048x1536.png","webapp/apple-launch-2048x2732.png","webapp/apple-launch-2224x1668.png","webapp/apple-launch-2388x1668.png","webapp/apple-launch-2732x2048.png","webapp/apple-launch-750x1334.png","webapp/apple-launch-828x1792.png"];

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "magicpad",
"version": "1.0.1-11",
"version": "1.0.1-12",
"description": "Easy to use OpenPGP client.",
"main": "app.js",
"bin": {
Expand Down
13 changes: 9 additions & 4 deletions src/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ main {
position: relative;
min-height: 100%;
}
.hidden {
display:none;
}
.hidden-label {
position:absolute;
opacity:0.01;
Expand Down Expand Up @@ -856,14 +859,14 @@ main {
display: table;
clear: both;
}
.downloaded-fingerprint-container a.searched-key-download, .downloaded-fingerprint-container button.searched-key-copy {
.downloaded-key-container a.searched-key-download, .downloaded-key-container button.searched-key-copy {
width:50%;
}
.downloaded-fingerprint-container a.searched-key-download-steg {
.downloaded-key-container a.searched-key-download-steg {
width:100%;
margin-top:1px;
}
.downloaded-fingerprint-container {
.downloaded-key-container {
width:100%;
margin-bottom:0.5em;
}
Expand Down Expand Up @@ -917,7 +920,9 @@ main {
button:disabled img, button[disabled], .button-2.disabled img, .button-2.disabled {
opacity: 0.3;
}
.button-2.disabled, .button-2.disabled:hover, .button-2.disabled:focus, .button-2.disabled:active, button:disabled, button[disabled], button:disabled:hover, button[disabled]:hover, button:disabled:active, button[disabled]:active, button:disabled:focus, button[disabled]:focus {
.button-1.disabled, .button-1.disabled:hover, .button-1.disabled:focus, .button-1.disabled:active,
.button-2.disabled, .button-2.disabled:hover, .button-2.disabled:focus, .button-2.disabled:active,
button:disabled, button[disabled], button:disabled:hover, button[disabled]:hover, button:disabled:active, button[disabled]:active, button:disabled:focus, button[disabled]:focus {
cursor: not-allowed;
background-color: #BEBEBE;
color: #8C8C8C;
Expand Down
16 changes: 9 additions & 7 deletions src/html_src/popup/key_server_browser_window.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,16 @@ <h3>Search for public key</h3>
<button class="button-1 search-pubkey" disabled>Search</button>
</section>
<section class="cf">
<h3>Search result</h3>
<h3><span class="search-status">Search not started</span>
<span class="copied">Copied</span></h3>
<ul class="search-results">
<li>
<span class="search-status">Search not started</span>
<span class="copied">Copied</span>
</li>
<li class="search-result">
<div class="downloaded-fingerprint-container cf">
<label for="search-result-list" class="hidden-label">Key selector</label>
<div class="select-wrapper">
<select id="search-result-list" class="search-result-list">
</select>
</div>
<div class="downloaded-key-container cf">
<a class="button-1 searched-key-download blob-download" href="#" target="_blank">
<span>Download key</span>
<img class="button-icon-img" src="./ui/download.svg" alt="Download searched key">
Expand All @@ -109,7 +111,7 @@ <h3>Search result</h3>
<span>Copy key</span>
<img class="button-icon-img" src="./ui/copy.svg" alt="Copy searched key to clipboard">
</button>
<a class="button-2 searched-key-download-steg blob-download" href="#" target="_blank">
<a class="button-2 searched-key-download-steg" href="#" target="_blank">
<span>Download key as image</span>
<img class="button-icon-img" src="./ui/download.svg" alt="Download searched key as an image">
</a>
Expand Down
6 changes: 5 additions & 1 deletion src/js_src/events/key_page/key_server_browser_search.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ $('.searchbox-pubkey').keyup(function(){
//Binding for Copy searched key
$('.searched-key-copy').bind('click',function(){
Clipboard.copy(session.searchedKey);
showCopied($('.search-results').find('.copied'));
showCopied($('.pubkeyserver-search').find('.copied'));
})

//Search for key button
Expand All @@ -18,3 +18,7 @@ $('.search-pubkey').bind('click',function(){
lookupKey($('.searchbox-pubkey').val(),$('.search-key-server-list').val());
}
})

$('.search-result-list').change(function(){
updateKeyLinks();
})
4 changes: 2 additions & 2 deletions src/js_src/events/universal_shell/universal_popup_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ $('.popup-tabs').find('.popup-tab').each(function(){
let $this = $(this);
let $thisParPar = $this.parent().parent();
let $popupTabContent = $thisParPar.parent().find('.popup-tab-content');
$thisParPar.find('.active').removeClass('active');
$thisParPar.find('.popup-tab').removeClass('active');
$this.addClass('active');
$popupTabContent.find('.active').removeClass('active');
$popupTabContent.find('.popup-tab-page').removeClass('active');
$popupTabContent.find('.'+$this.attr('data-tab')).addClass('active');
})
})
64 changes: 57 additions & 7 deletions src/js_src/keyserver_functions/keyserver_search.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,37 @@ const lookupKey = function(query,server) {
if(hkpLookup != undefined){
if(hkpLookup.length > 0){
const searchedKey = await openpgp.key.readArmored(hkpLookup.trim());
const $searchResultList = $('.search-result-list');
if(searchedKey.err != undefined){
$searchStatus.text('Error');
throw errorFinder('searchresultkey');
}
session.searchedKey = hkpLookup.trim();
const buffer = new Uint8Array(searchedKey.keys[0].primaryKey.fingerprint).buffer;
$('.searched-key-download').attr('href', dataURItoBlobURL('data:application/octet-stream;base64;name=searchedKey_public.asc,' + btoa(session.searchedKey))).attr('download', 'searchedKey_public.asc').attr('target','_blank');
$('.downloaded-fingerprint').text(buf2hex(buffer).match(/.{1,4}/g).join(' ').toUpperCase());
createStegKey(pubDataUri,'search',session.searchedKey);
$('.searched-key-download-steg').attr('download', 'searchedKey_public_steg.png')
if(searchedKey.keys.length > 1){
$searchResultList.removeClass('hidden');
$searchStatus.text('Multiple keys found');
} else {
$searchResultList.addClass('hidden');
$searchStatus.text('Key found');
}
$searchResultList.empty();
for(let i = 0; i < searchedKey.keys.length; i++){
const fingerprintBuffer = new Uint8Array(searchedKey.keys[i].primaryKey.fingerprint).buffer;
const fingerprintHex = buf2hex(fingerprintBuffer);
const downloadLink = server + '/pks/lookup?op=get&options=mr&search=0x' + fingerprintHex;
const keyId = searchedKey.keys[i].primaryKey.keyid.toHex();
const $tempOption = $('<option>');
let optionStr = keyId;
if(i == 0){
optionStr = 'Latest - '+optionStr;
$('.searched-key-download').attr('href', downloadLink).attr('target','_blank');
$('.downloaded-fingerprint').text(fingerprintHex.match(/.{1,4}/g).join(' ').toUpperCase());
}
$tempOption.text(optionStr);
$tempOption.val(keyId).attr('data-fingerprint',fingerprintHex);
$searchResultList.append($tempOption);
}
updateKeyLinks();
$searchResults.addClass('search-complete');
$searchStatus.text('Key found');
}
} else {
$searchResults.removeClass('search-complete');
Expand All @@ -42,3 +61,34 @@ const lookupKey = function(query,server) {
}
main();
}

const updateKeyLinks = function(){
const $searchedKeyDownload = $('.searched-key-download');
const $searchedKeyCopy = $('.searched-key-copy');
const $searchedKeyDownloadSteg = $('.searched-key-download-steg');
$searchedKeyCopy.addClass('disabled');
$searchedKeyDownload.addClass('disabled');
$searchedKeyDownloadSteg.addClass('disabled');
let server = $('.search-key-server-list').val();
if (location.protocol == "https:") {
server = location.protocol + server
} else {
server = 'http:'+server
}
const downloadLink = server + '/pks/lookup?op=get&options=mr&search=0x' + $('.search-result-list').val();
$.ajax({
url:downloadLink,
success: function (data){
session.searchedKey = data;
const fingerprintHex = $(".search-result-list option:selected").attr('data-fingerprint');
$('.searched-key-download').attr('href', downloadLink).attr('target','_blank');
$('.downloaded-fingerprint').text(fingerprintHex.match(/.{1,4}/g).join(' ').toUpperCase());
createStegKey(pubDataUri,'search',session.searchedKey);
$('.searched-key-download-steg').attr('download', 'searchedKey_public_steg.png');
$searchedKeyCopy.removeClass('disabled');
$searchedKeyDownload.removeClass('disabled');
$searchedKeyDownloadSteg.removeClass('disabled');
}
});

}

0 comments on commit 2d7c2f2

Please sign in to comment.