index.js
function loadKeyPair (pub, prv, use) {
  var pubPEM, prvPEM, pubJWK

  try {
    pubPEM = fs.readFileSync(pub).toString('ascii')
  } catch (e) {
    throw new Error('Unable to read the public key from ' + pub)
  }

  try {
    prvPEM = fs.readFileSync(prv).toString('ascii')
  } catch (e) {
    throw new Error('Unable to read the private key from ' + pub)
  }

  try {
    pubJWK = pemjwk.pem2jwk(pubPEM)
  } catch (e) {
    throw new Error('Unable to convert the public key ' + pub + ' to a JWK')
  }

  return {
    pem: {
      pub: pubPEM,
      prv: prvPEM
    },
    jwk: {
      pub: {
        kty: pubJWK.kty,
        use: use,
        alg: 'RS256',
        n: pubJWK.n,
        e: pubJWK.e
      }
    }
  }
}
function loadKeyPair (pub, prv, use) {
  var pubPEM, prvPEM, pubJWK

  try {
    pubPEM = fs.readFileSync(pub).toString('ascii')
  } catch (e) {
    throw new Error('Unable to read the public key from ' + pub)
  }

  try {
    prvPEM = fs.readFileSync(prv).toString('ascii')
  } catch (e) {
    throw new Error('Unable to read the private key from ' + pub)
  }

  try {
    pubJWK = pemjwk.pem2jwk(pubPEM)
  } catch (e) {
    throw new Error('Unable to convert the public key ' + pub + ' to a JWK')
  }

  return {
    pem: {
      pub: pubPEM,
      prv: prvPEM
    },
    jwk: {
      pub: {
        kty: pubJWK.kty,
        use: use,
        alg: 'RS256',
        n: pubJWK.n,
        e: pubJWK.e
      }
    }
  }
}
function loadKeyPair ( pub , prv , use ) { var pubPEM , prvPEM , pubJWK try { pubPEM = fs . readFileSync ( pub ) . toString ( 'ascii' ) } catch ( e ) { throw new Error ( 'Unable to read the public key from ' + pub ) } try { prvPEM = fs . readFileSync ( prv ) . toString ( 'ascii' ) } catch ( e ) { throw new Error ( 'Unable to read the private key from ' + pub ) } try { pubJWK = pemjwk . pem2jwk ( pubPEM ) } catch ( e ) { throw new Error ( 'Unable to convert the public key ' + pub + ' to a JWK' ) } return { pem : { pub : pubPEM , prv : prvPEM } , jwk : { pub : { kty : pubJWK . kty , use : use , alg : 'RS256' , n : pubJWK . n , e : pubJWK . e } } } }
Load single key pair
Load single key pair