INNER CODE UNIT · JavaScript
getPrivateKey
DinoChiesa/jwt-webtool · src/js/app.js:328
function getPrivateKey(header, options) {
editors.privatekey.save();
const keyvalue = $sel("#ta_privatekey")
.value.trim()
.replace(new RegExp("[^\x00-\x7F]", "g"), ""); // strip non - ASCII
return jose.JWK.asKey(keyvalue, "pem", { ...options, ...header });
}
function getPublicKey(header, options) {
options = options || {};
editors.publickey.save();
const fieldValue = $sel("#ta_publickey")
.value.trim()
.replace(new RegExp("[^\x00-\x7F]", "g"), ""); // strip non - ASCII
if (looksLikePem(fieldValue)) {
// if de-serializing from PEM, apply the kid, if any