minor bugfixes

This commit is contained in:
AJ ONeal 2019-05-06 23:12:13 -06:00
parent b902907a7c
commit 14c24e3aea
4 changed files with 12 additions and 17 deletions

5
app.js
View File

@ -17,11 +17,6 @@
return Array.prototype.slice.call(document.querySelectorAll(sel));
}
function checkTos(tos) {
console.log("TODO checkbox for agree to terms");
return tos;
}
function run() {
console.log('hello');

View File

@ -125,7 +125,7 @@ PEM.parseBlock = PEM.parseBlock || function (str) {
var der = str.split(/\n/).filter(function (line) {
return !/-----/.test(line);
}).join('');
return { der: Enc.base64ToBuf(der) };
return { bytes: Enc.base64ToBuf(der) };
};
Enc.base64ToBuf = function (b64) {

View File

@ -66,8 +66,11 @@ Enc.numToHex = function (d) {
};
Enc.bufToUrlBase64 = function (u8) {
return Enc.bufToBase64(u8)
.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
return Enc.base64ToUrlBase64(Enc.bufToBase64(u8));
};
Enc.base64ToUrlBase64 = function (str) {
return str.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
};
Enc.bufToBase64 = function (u8) {

View File

@ -186,10 +186,6 @@ Keypairs.signJws = function (opts) {
, signature: Enc.bufToUrlBase64(buf)
};
console.log('Signed Base64 Msg:');
console.log(JSON.stringify(signedMsg, null, 2));
console.log('msg:', msg);
return signedMsg;
});
}
@ -219,10 +215,12 @@ Keypairs._sign = function (opts, payload) {
).then(function (signature) {
signature = new Uint8Array(signature); // ArrayBuffer -> u8
// This will come back into play for CSRs, but not for JOSE
if ('EC' === opts.jwk.kty && /x509/i.test(opts.format)) {
signature = Keypairs._ecdsaJoseSigToAsn1Sig(signature);
if ('EC' === opts.jwk.kty && /x509|asn1/i.test(opts.format)) {
return Keypairs._ecdsaJoseSigToAsn1Sig(signature);
} else {
// jose/jws/jwt
return signature;
}
return signature;
});
});
};
@ -261,7 +259,6 @@ Keypairs._import = function (opts) {
opts.jwk.ext = true;
opts.jwk.key_ops = ops;
console.log('jwk', opts.jwk);
return window.crypto.subtle.importKey(
"jwk"
, opts.jwk
@ -298,7 +295,7 @@ Keypairs._ecdsaJoseSigToAsn1Sig = function (bufsig) {
if (len >= 0x80) { head.push(0x81); }
head.push(len);
return Uint8Array.from(head.concat([0x02, r.length], r, [0x02, s.byteLength], s));
return Uint8Array.from(head.concat([0x02, r.length], r, [0x02, s.length], s));
};
function setTime(time) {