From 93e939e517cfbb29db63f895b06a5bdab778ccb5 Mon Sep 17 00:00:00 2001 From: lastlink Date: Sat, 11 May 2019 22:32:00 +0000 Subject: [PATCH] no-acme (#10) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I’ll make the couple of fixed I figure the hard coded value was a good example of what input would be maybe it should be a placeholder instead or empty --- .editorconfig | 11 +++++ app.js | 68 ++++++++++++++++++++++++++++- index.html | 117 ++++++++++++++++++++++++++++++-------------------- 3 files changed, 148 insertions(+), 48 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..bec4847 --- /dev/null +++ b/.editorconfig @@ -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 \ No newline at end of file diff --git a/app.js b/app.js index 10acaa4..e4250be 100644 --- a/app.js +++ b/app.js @@ -43,6 +43,8 @@ $('.js-jwk').hidden = true; $('.js-toc-der-public').hidden = true; $('.js-toc-der-private').hidden = true; + $('.js-toc-jwk').hidden = true; + $$('.js-toc-pem').forEach(function ($el) { $el.hidden = true; }); @@ -50,8 +52,8 @@ $$('button').map(function ($el) { $el.disabled = true; }); var opts = { kty: $('input[name="kty"]:checked').value - , namedCurve: $('input[name="ec-crv"]:checked').value - , modulusLength: $('input[name="rsa-len"]:checked').value + , namedCurve: $('input[name="ec-crv"]:checked').value + , modulusLength: $('input[name="rsa-len"]:checked').value }; var then = Date.now(); console.log('opts', opts); @@ -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-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); diff --git a/index.html b/index.html index f245129..74b28d1 100644 --- a/index.html +++ b/index.html @@ -1,11 +1,12 @@ - - BlueCrypt -