Browse Source

v1.2.9: bugfix RSA hash type

tags/v1.2.9
AJ ONeal 1 year ago
parent
commit
e04557c84a
3 changed files with 6 additions and 6 deletions
  1. +4
    -4
      keypairs.js
  2. +1
    -1
      package.json
  3. +1
    -1
      test.js

+ 4
- 4
keypairs.js View File

@@ -154,9 +154,9 @@ Keypairs.signJwt = function (opts) {
var header = opts.header || {};
var claims = JSON.parse(JSON.stringify(opts.claims || {}));
header.typ = 'JWT';
if (!header.kid) {
header.kid = thumb;
}
if (!header.kid) { header.kid = thumb; }
if (!header.alg && opts.alg) { header.alg = opts.alg; }
if (!claims.iat && (false === claims.iat || false === opts.iat)) {
claims.iat = undefined;
} else if (!claims.iat) {
@@ -197,7 +197,7 @@ Keypairs.signJws = function (opts) {
if (!opts.jwk) {
throw new Error("opts.jwk must exist and must declare 'typ'");
}
return ('RSA' === opts.jwk.typ) ? "RS256" : "ES256";
return ('RSA' === opts.jwk.kty) ? "RS256" : "ES256";
}

function sign(pem) {


+ 1
- 1
package.json View File

@@ -1,6 +1,6 @@
{
"name": "keypairs",
"version": "1.2.8",
"version": "1.2.9",
"description": "Lightweight RSA/ECDSA keypair generation and JWK <-> PEM",
"main": "keypairs.js",
"files": [


+ 1
- 1
test.js View File

@@ -90,7 +90,7 @@ Keypairs.parseOrGenerate({ key: '' }).then(function (pair) {
if ('NOERR' === e.code) { throw e; }
return true;
})
, Keypairs.signJwt({ jwk: pair.private, iss: 'https://example.com/', exp: '1h' }).then(function (jwt) {
, Keypairs.signJwt({ jwk: pair.private, alg: 'ES512', iss: 'https://example.com/', exp: '1h' }).then(function (jwt) {
var parts = jwt.split('.');
var now = Math.round(Date.now()/1000);
var token = {


Loading…
Cancel
Save