Compare commits

...

13 Commits

Author SHA1 Message Date
Mr. Funk cc1afb8d4a merge fix 2019-05-11 16:56:38 -04:00
Mr. Funk d2c256d0bc fix merge 2019-05-11 16:55:53 -04:00
lastlink 13be5d8eb6 error print 2019-05-07 12:02:37 -04:00
lastlink 0e802df186 more code cleanup 2019-05-07 11:53:44 -04:00
lastlink 1d6ce35289 remove log 2019-05-07 11:53:24 -04:00
lastlink 1809d9104b some cleanup 2019-05-07 11:52:46 -04:00
lastlink 0355354654 fix initial jwk 2019-05-07 11:47:59 -04:00
lastlink 037b8489f6 initial working jwk jws 2019-05-07 11:45:48 -04:00
Mr. Funk 49ab998242 boilerplate function 2019-05-07 09:38:16 -04:00
Mr. Funk 1654ab7880 remove outer div 2019-05-07 09:37:05 -04:00
Mr. Funk 4f5cf492e3 init template 2019-05-07 09:29:53 -04:00
Mr. Funk 7ba413dae6 hide jwk keypair on loading 2019-05-06 23:05:45 -04:00
Mr. Funk 7efe42da10 consistent spacing for reformating 2019-05-06 23:00:01 -04:00
3 changed files with 148 additions and 48 deletions

11
.editorconfig Normal file
View File

@ -0,0 +1,11 @@
# editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
tab_width = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

64
app.js
View File

@ -43,6 +43,8 @@
$('.js-jwk').hidden = true; $('.js-jwk').hidden = true;
$('.js-toc-der-public').hidden = true; $('.js-toc-der-public').hidden = true;
$('.js-toc-der-private').hidden = true; $('.js-toc-der-private').hidden = true;
$('.js-toc-jwk').hidden = true;
$$('.js-toc-pem').forEach(function ($el) { $$('.js-toc-pem').forEach(function ($el) {
$el.hidden = true; $el.hidden = true;
}); });
@ -109,7 +111,69 @@
}); });
}); });
$('form.js-keysign').addEventListener('submit', function (ev) {
ev.preventDefault();
ev.stopPropagation();
$('.js-pem-loading').hidden = false;
$('.js-toc-jws').hidden = true;
$('.js-toc-jwt').hidden = true;
$$('input').map(function ($el) { $el.disabled = true; });
$$('button').map(function ($el) { $el.disabled = true; });
try {
var opts = {
jwk: JSON.parse($('textarea[name="jwk"]').value),
claims: {
exp: "1h",
iss: document.getElementById(`-acmeDomains`).value
}
};
Keypairs.signJwt(opts).then(function (msg) {
document.getElementById(`sign-error`).innerText = null;
$('.js-jwt').innerText = msg;
$('.js-toc-jwt').hidden = false;
var msgArr = msg.split(".")
var protected64 = msgArr[0]
var payload64 = msgArr[1]
var signature = msgArr[2]
var signedMsg = {
protected: protected64
, payload: payload64
, signature
};
$('.js-jws').innerText = JSON.stringify(signedMsg, null, 2);
$('.js-toc-jws').hidden = false;
$('.js-pem-loading').hidden = true;
$$('input').map(function ($el) { $el.disabled = false; });
$$('button').map(function ($el) { $el.disabled = false; });
}).catch(function (error) {
document.getElementById(`sign-error`).innerText = error.message
$('.js-pem-loading').hidden = true;
$$('input').map(function ($el) { $el.disabled = false; });
$$('button').map(function ($el) { $el.disabled = false; });
})
} catch (error) {
document.getElementById(`sign-error`).innerText = error.message
$('.js-pem-loading').hidden = true;
$$('input').map(function ($el) { $el.disabled = false; });
$$('button').map(function ($el) { $el.disabled = false; });
}
});
$('.js-generate').hidden = false; $('.js-generate').hidden = false;
$('.js-sign').hidden = false;
$('textarea[name="jwk"]').value = JSON.stringify({
"crv": "P-256",
"d": "LImWxqqTHbP3LHQfqscDSUzf_uNePGqf9U6ETEcO5Ho",
"kty": "EC",
"x": "vdjQ3T6VBX82LIKDzepYgRsz3HgRwp83yPuonu6vqos",
"y": "IUkEXtAMnppnV1A19sE2bJhUo4WPbq6EYgWxma4oGyg",
"kid": "MnfJYyS9W5gUjrJLdn8ePMzik8ZJz2qc-VZmKOs_oCw"
})
} }
window.addEventListener('load', run); window.addEventListener('load', run);

View File

@ -1,5 +1,6 @@
<html> <html>
<head>
<head>
<title>BlueCrypt</title> <title>BlueCrypt</title>
<style> <style>
textarea { textarea {
@ -96,6 +97,30 @@
<pre><code class="js-input-pem-spki-public" ></code></pre> <pre><code class="js-input-pem-spki-public" ></code></pre>
</details> </details>
<h2>Signing</h2>
<div class="errors" id="sign-error"></div>
<form class="js-keysign">
<div>
<label for="-acmeDomains">Domains:</label>
<input class="js-domains" type="text" id="-acmeDomains" value="example.com www.example.com">
</div>
<div>
<label for="jwk">JWK:</label>
<br>
<textarea id="jwk" name="jwk"></textarea>
</div>
<button class="js-sign" hidden>Sign</button>
</form>
<div class="js-pem-loading" hidden>Loading</div>
<details class="js-toc-jws" hidden>
<summary>JWS </summary>
<pre><code class="js-jws"></code></pre>
</details>
<details class="js-toc-jwt" hidden>
<summary>JWT </summary>
<pre><code class="js-jwt"></code></pre>
</details>
<br> <br>
<p>Bluecrypt&trade; is a collection of lightweight, zero-dependency, libraries written in VanillaJS. <p>Bluecrypt&trade; is a collection of lightweight, zero-dependency, libraries written in VanillaJS.
They are fast, tiny, and secure, using the native features of modern browsers where possible.</p> They are fast, tiny, and secure, using the native features of modern browsers where possible.</p>