Compare commits
	
		
			No commits in common. "master" and "v1.2.12" have entirely different histories.
		
	
	
		
	
		
							
								
								
									
										26
									
								
								keypairs.js
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								keypairs.js
									
									
									
									
									
								
							@ -240,7 +240,7 @@ Keypairs.signJws = function (opts) {
 | 
				
			|||||||
      if ('EC' === opts.jwk.kty) {
 | 
					      if ('EC' === opts.jwk.kty) {
 | 
				
			||||||
        // ECDSA JWT signatures differ from "normal" ECDSA signatures
 | 
					        // ECDSA JWT signatures differ from "normal" ECDSA signatures
 | 
				
			||||||
        // https://tools.ietf.org/html/rfc7518#section-3.4
 | 
					        // https://tools.ietf.org/html/rfc7518#section-3.4
 | 
				
			||||||
        binsig = ecdsaAsn1SigToJoseSig(binsig);
 | 
					        binsig = convertIfEcdsa(binsig);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      var sig = binsig.toString('base64')
 | 
					      var sig = binsig.toString('base64')
 | 
				
			||||||
@ -257,7 +257,7 @@ Keypairs.signJws = function (opts) {
 | 
				
			|||||||
      };
 | 
					      };
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function ecdsaAsn1SigToJoseSig(binsig) {
 | 
					    function convertIfEcdsa(binsig) {
 | 
				
			||||||
      // should have asn1 sequence header of 0x30
 | 
					      // should have asn1 sequence header of 0x30
 | 
				
			||||||
      if (0x30 !== binsig[0]) { throw new Error("Impossible EC SHA head marker"); }
 | 
					      if (0x30 !== binsig[0]) { throw new Error("Impossible EC SHA head marker"); }
 | 
				
			||||||
      var index = 2; // first ecdsa "R" header byte
 | 
					      var index = 2; // first ecdsa "R" header byte
 | 
				
			||||||
@ -342,25 +342,3 @@ Enc.bufToUrlBase64 = function (buf) {
 | 
				
			|||||||
  return Buffer.from(buf).toString('base64')
 | 
					  return Buffer.from(buf).toString('base64')
 | 
				
			||||||
    .replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
 | 
					    .replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					 | 
				
			||||||
// For 'rsa-compat' module only
 | 
					 | 
				
			||||||
// PLEASE do not use these sync methods, they are deprecated
 | 
					 | 
				
			||||||
Keypairs._importSync = function (opts) {
 | 
					 | 
				
			||||||
  try {
 | 
					 | 
				
			||||||
    return Eckles.importSync(opts);
 | 
					 | 
				
			||||||
  } catch(e) {
 | 
					 | 
				
			||||||
    try {
 | 
					 | 
				
			||||||
      return Rasha.importSync(opts);
 | 
					 | 
				
			||||||
    } catch(e) {
 | 
					 | 
				
			||||||
      console.error("options.pem does not appear to be a valid RSA or ECDSA public or private key");
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
// PLEASE do not use these, they are deprecated
 | 
					 | 
				
			||||||
Keypairs._exportSync = function (opts) {
 | 
					 | 
				
			||||||
  if ('RSA' === opts.jwk.kty) {
 | 
					 | 
				
			||||||
    return Rasha.exportSync(opts);
 | 
					 | 
				
			||||||
  } else {
 | 
					 | 
				
			||||||
    return Eckles.exportSync(opts);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										10
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								package.json
									
									
									
									
									
								
							@ -1,7 +1,7 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  "name": "keypairs",
 | 
					  "name": "keypairs",
 | 
				
			||||||
  "version": "1.2.14",
 | 
					  "version": "1.2.12",
 | 
				
			||||||
  "description": "Lightweight RSA/ECDSA keypair generation and JWK <-> PEM using node's native RSA and ECDSA support",
 | 
					  "description": "Lightweight RSA/ECDSA keypair generation and JWK <-> PEM",
 | 
				
			||||||
  "main": "keypairs.js",
 | 
					  "main": "keypairs.js",
 | 
				
			||||||
  "files": [
 | 
					  "files": [
 | 
				
			||||||
    "bin/keypairs.js"
 | 
					    "bin/keypairs.js"
 | 
				
			||||||
@ -21,11 +21,7 @@
 | 
				
			|||||||
    "RSA",
 | 
					    "RSA",
 | 
				
			||||||
    "ECDSA",
 | 
					    "ECDSA",
 | 
				
			||||||
    "PEM",
 | 
					    "PEM",
 | 
				
			||||||
    "JWK",
 | 
					    "JWK"
 | 
				
			||||||
    "keypair",
 | 
					 | 
				
			||||||
    "crypto",
 | 
					 | 
				
			||||||
    "sign",
 | 
					 | 
				
			||||||
    "verify"
 | 
					 | 
				
			||||||
  ],
 | 
					  ],
 | 
				
			||||||
  "author": "AJ ONeal <coolaj86@gmail.com> (https://coolaj86.com/)",
 | 
					  "author": "AJ ONeal <coolaj86@gmail.com> (https://coolaj86.com/)",
 | 
				
			||||||
  "license": "MPL-2.0",
 | 
					  "license": "MPL-2.0",
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user