|
|
@ -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) { |
|
|
|