From 47cffb6697caadca5c5629b404e44222a6328a18 Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Sun, 5 Jul 2020 13:50:25 +0200 Subject: [PATCH 1/3] Add profile generator --- assets/styles.css | 6 +++--- views/util/profile-url.php | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 views/util/profile-url.php diff --git a/assets/styles.css b/assets/styles.css index eafa3cd..ab40a53 100644 --- a/assets/styles.css +++ b/assets/styles.css @@ -103,6 +103,9 @@ input[type="submit"][disabled="true"] { pointer-events: none; opacity: 0.3; } +select { + margin: 0 0 16px 0; +} .green { color: green; } @@ -113,9 +116,6 @@ input[type="submit"][disabled="true"] { display: inline-block; margin: 0 0 8px; } -.modesContainer { - margin-top: 16px; -} .modes { display: none; } diff --git a/views/util/profile-url.php b/views/util/profile-url.php new file mode 100644 index 0000000..70c3e62 --- /dev/null +++ b/views/util/profile-url.php @@ -0,0 +1,23 @@ +layout('template.base', ['title' => $title]) ?> + +

Profile URL

+
+
+

This tool generates an URL for your Keyoxide profile page.

+

Public key

+ + +
+ +

Profile URL

+ Waiting for input... +

Help

+

When using the Web Key Directory source, the Input looks like username@domain.org.

+

When using the keys.openpgp.org source, the Input is either the fingerprint of your public key, or the main identity's email address.

+

When using the Keybase source, the Input is the URL obtained by going to your Keybase profile page, clicking on the key id of your keypair and copying the URL of the this key link.

+
+
From 92ce753e01690e491bedbf5b4a9f9846c750fa8b Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Sun, 5 Jul 2020 13:50:38 +0200 Subject: [PATCH 2/3] Add profile generator button to index --- views/index.php | 1 + 1 file changed, 1 insertion(+) diff --git a/views/index.php b/views/index.php index 9d5cfa1..b2de7aa 100644 --- a/views/index.php +++ b/views/index.php @@ -10,6 +10,7 @@

Utilities

+ Profile URL wkd QR

From 140f645055ae1ccabfcd198510f7a50dde80ae8f Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Sun, 5 Jul 2020 13:51:23 +0200 Subject: [PATCH 3/3] Add function to generate profile urls --- assets/scripts.js | 62 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/assets/scripts.js b/assets/scripts.js index 9d8ce44..c5b0ed9 100644 --- a/assets/scripts.js +++ b/assets/scripts.js @@ -658,6 +658,32 @@ async function computeWKDLocalPart(message) { return encodeZBase32(new Uint8Array(hash)); } +async function generateProfileURL(data) { + if (data.input == "") { + return "Waiting for input..."; + } + switch (data.source) { + case "wkd": + return `https://keyoxide.org/${data.input}`; + break; + case "hkp": + if (/.*@.*\..*/.test(data.input)) { + return `https://keyoxide.org/hkp/${data.input}`; + } else { + return `https://keyoxide.org/${data.input}`; + } + break; + case "keybase": + const re = /https\:\/\/keybase.io\/(.*)\/pgp_keys\.asc\?fingerprint\=(.*)/; + if (!re.test(data.input)) { + return "Incorrect Keybase public key URL."; + } + const match = data.input.match(re); + return `https://keyoxide.org/keybase/${match[1]}/${match[2]}`; + break; + } +} + // General purpose let elFormVerify = document.body.querySelector("#form-verify"), elFormEncrypt = document.body.querySelector("#form-encrypt"), @@ -666,7 +692,8 @@ let elFormVerify = document.body.querySelector("#form-verify"), elProfileMode = document.body.querySelector("#profileMode"), elModeSelect = document.body.querySelector("#modeSelect"), elUtilWKD = document.body.querySelector("#form-util-wkd"), - elUtilQR = document.body.querySelector("#form-util-qr"); + elUtilQR = document.body.querySelector("#form-util-qr"), + elUtilProfileURL = document.body.querySelector("#form-util-profile-url"); if (elModeSelect) { elModeSelect.onchange = function (evt) { @@ -870,3 +897,36 @@ if (elUtilQR) { elInput.dispatchEvent(new Event("input")); } + +if (elUtilProfileURL) { + elUtilProfileURL.onsubmit = function (evt) { + evt.preventDefault(); + } + + const elInput = document.body.querySelector("#input"), + elSource = document.body.querySelector("#source"), + elOutput = document.body.querySelector("#output"); + + let data = { + input: elInput.value, + source: elSource.value + }; + + elInput.addEventListener("input", async function(evt) { + data = { + input: elInput.value, + source: elSource.value + }; + elOutput.innerText = await generateProfileURL(data); + }); + + elSource.addEventListener("input", async function(evt) { + data = { + input: elInput.value, + source: elSource.value + }; + elOutput.innerText = await generateProfileURL(data); + }); + + elInput.dispatchEvent(new Event("input")); +}