Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jwk-to-pem

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jwk-to-pem - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

10

package.json
{
"name": "jwk-to-pem",
"version": "1.2.1",
"version": "1.2.2",
"description": "Convert a JSON Web Key to a PEM",

@@ -32,8 +32,8 @@ "main": "src/jwk-to-pem.js",

"devDependencies": {
"chai": "^3.0.0",
"coveralls": "^2.11.2",
"istanbul": "^0.3.15",
"chai": "^3.4.0",
"coveralls": "^2.11.4",
"istanbul": "^0.4.0",
"jwa": "^1.1.0",
"mocha": "^2.2.5"
"mocha": "^2.3.3"
}
}
'use strict';
var asn1 = require('asn1.js'),
curves = require('./ec-curves'),
EC = require('elliptic').ec,
rfc3280 = require('asn1.js-rfc3280');

@@ -9,2 +9,13 @@

var curves = {
'P-256': 'p256',
'P-384': 'p384',
'P-521': 'p521'
},
oids = {
'P-256': [1, 2, 840, 10045, 3, 1, 7],
'P-384': [1, 3, 132, 0, 34],
'P-521': [1, 3, 132, 0, 35]
};
function ecJwkToBuffer (jwk, opts) {

@@ -32,7 +43,9 @@ if ('string' !== typeof jwk.crv) {

var curve = curves[jwk.crv];
if (!curve) {
var curveName = curves[jwk.crv];
if (!curveName) {
throw new Error('Unsupported curve "' + jwk.crv + '"');
}
var curve = new EC(curveName);
var key = {};

@@ -65,21 +78,2 @@

function keyToPem (crv, key, opts) {
var oid;
switch (crv) {
case 'P-256': {
oid = [1, 2, 840, 10045, 3, 1, 7];
break;
}
case 'P-384': {
oid = [1, 3, 132, 0, 34];
break;
}
case 'P-521': {
oid = [1, 3, 132, 0, 35];
break;
}
default: {
throw new Error('Unsupported curve "' + crv + '"');
}
}
var compact = false;

@@ -95,3 +89,3 @@ var subjectPublicKey = key.getPublic(compact, 'hex');

type: 'namedCurve',
value: oid
value: oids[crv]
}, 'der');

@@ -98,0 +92,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc