v1.6.0: use non-deprecated features, update deps
This commit is contained in:
parent
718c3eb42f
commit
3f7339a491
|
@ -26,7 +26,7 @@ var utils = {
|
||||||
},
|
},
|
||||||
|
|
||||||
b64dec: function(str) {
|
b64dec: function(str) {
|
||||||
return new Buffer(utils.toStandardB64(str), "base64");
|
return Buffer.from(utils.toStandardB64(str), "base64");
|
||||||
},
|
},
|
||||||
|
|
||||||
isB64String: function(x) {
|
isB64String: function(x) {
|
||||||
|
|
|
@ -7,13 +7,7 @@ function _bigIntToBase64Url(fbin) {
|
||||||
// Invalid hex string
|
// Invalid hex string
|
||||||
hex = '0' + hex;
|
hex = '0' + hex;
|
||||||
}
|
}
|
||||||
var buf;
|
var buf = Buffer.from(hex, 'hex');
|
||||||
// See https://github.com/Daplie/rsa-compat.js/issues/9
|
|
||||||
try {
|
|
||||||
buf = Buffer.from(hex, 'hex');
|
|
||||||
} catch(e) {
|
|
||||||
buf = new Buffer(hex, 'hex');
|
|
||||||
}
|
|
||||||
var b64 = buf.toString('base64');
|
var b64 = buf.toString('base64');
|
||||||
var b64Url = b64.replace(/[+]/g, "-").replace(/\//g, "_").replace(/=/g,"");
|
var b64Url = b64.replace(/[+]/g, "-").replace(/\//g, "_").replace(/=/g,"");
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ var forgec = module.exports = {
|
||||||
}
|
}
|
||||||
, _base64UrlToBin: function (base64) {
|
, _base64UrlToBin: function (base64) {
|
||||||
var std64 = forgec._toStandardBase64(base64);
|
var std64 = forgec._toStandardBase64(base64);
|
||||||
var hex = new Buffer(std64, 'base64').toString("hex");
|
var hex = Buffer.from(std64, 'base64').toString("hex");
|
||||||
|
|
||||||
return new forge.jsbn.BigInteger(hex, 16);
|
return new forge.jsbn.BigInteger(hex, 16);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ var ursac = module.exports = {
|
||||||
var components = [];
|
var components = [];
|
||||||
|
|
||||||
[ 'n', 'e', 'p', 'q', 'dp', 'dq', 'qi', 'd' ].forEach(function (key) {
|
[ 'n', 'e', 'p', 'q', 'dp', 'dq', 'qi', 'd' ].forEach(function (key) {
|
||||||
components.push(new Buffer(jwk[key], 'base64'));
|
components.push(Buffer.from(jwk[key], 'base64'));
|
||||||
});
|
});
|
||||||
|
|
||||||
return components;
|
return components;
|
||||||
|
@ -35,7 +35,7 @@ var ursac = module.exports = {
|
||||||
, _publicJwkToComponents: function (jwk) {
|
, _publicJwkToComponents: function (jwk) {
|
||||||
var components = [];
|
var components = [];
|
||||||
[ 'n', 'e' ].forEach(function (key) {
|
[ 'n', 'e' ].forEach(function (key) {
|
||||||
components.push(new Buffer(jwk[key], 'base64'));
|
components.push(Buffer.from(jwk[key], 'base64'));
|
||||||
});
|
});
|
||||||
|
|
||||||
return components;
|
return components;
|
||||||
|
|
8
node.js
8
node.js
|
@ -40,13 +40,13 @@ function create(deps) {
|
||||||
|
|
||||||
RSA.utils._forgeBytesToBuf = function (bytes) {
|
RSA.utils._forgeBytesToBuf = function (bytes) {
|
||||||
var forge = require("node-forge");
|
var forge = require("node-forge");
|
||||||
return new Buffer(forge.util.bytesToHex(bytes), "hex");
|
return Buffer.from(forge.util.bytesToHex(bytes), "hex");
|
||||||
};
|
};
|
||||||
RSA._internal = require('./lib/node');//.create(deps);
|
RSA._internal = require('./lib/node');//.create(deps);
|
||||||
|
|
||||||
RSA._thumbprintInput = function (n, e) {
|
RSA._thumbprintInput = function (n, e) {
|
||||||
// #L147 const rsaThumbprintTemplate = `{"e":"%s","kty":"RSA","n":"%s"}`
|
// #L147 const rsaThumbprintTemplate = `{"e":"%s","kty":"RSA","n":"%s"}`
|
||||||
return new Buffer('{"e":"'+ e + '","kty":"RSA","n":"'+ n +'"}', 'ascii');
|
return Buffer.from('{"e":"'+ e + '","kty":"RSA","n":"'+ n +'"}', 'ascii');
|
||||||
};
|
};
|
||||||
RSA.thumbprint = function (keypair) {
|
RSA.thumbprint = function (keypair) {
|
||||||
var publicKeyJwk = RSA.exportPublicJwk(keypair);
|
var publicKeyJwk = RSA.exportPublicJwk(keypair);
|
||||||
|
@ -176,7 +176,7 @@ function create(deps) {
|
||||||
};
|
};
|
||||||
var sigF = keypair._forge.sign(md);
|
var sigF = keypair._forge.sign(md);
|
||||||
var sig64 = RSA.utils.toWebsafeBase64(
|
var sig64 = RSA.utils.toWebsafeBase64(
|
||||||
new Buffer(forge.util.bytesToHex(sigF), "hex").toString('base64')
|
Buffer.from(forge.util.bytesToHex(sigF), "hex").toString('base64')
|
||||||
);
|
);
|
||||||
|
|
||||||
return sig64;
|
return sig64;
|
||||||
|
@ -209,7 +209,7 @@ function create(deps) {
|
||||||
if (protect) {
|
if (protect) {
|
||||||
protectedHeader = JSON.stringify(protect); // { alg: prot.alg, nonce: prot.nonce, url: prot.url });
|
protectedHeader = JSON.stringify(protect); // { alg: prot.alg, nonce: prot.nonce, url: prot.url });
|
||||||
}
|
}
|
||||||
var protected64 = RSA.utils.toWebsafeBase64(new Buffer(protectedHeader).toString('base64'));
|
var protected64 = RSA.utils.toWebsafeBase64(Buffer.from(protectedHeader).toString('base64'));
|
||||||
var payload64 = RSA.utils.toWebsafeBase64(payload.toString('base64'));
|
var payload64 = RSA.utils.toWebsafeBase64(payload.toString('base64'));
|
||||||
var raw = protected64 + "." + payload64;
|
var raw = protected64 + "." + payload64;
|
||||||
var sha256Buf = crypto.createHash('sha256').update(raw).digest();
|
var sha256Buf = crypto.createHash('sha256').update(raw).digest();
|
||||||
|
|
10
package.json
10
package.json
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "rsa-compat",
|
"name": "rsa-compat",
|
||||||
"version": "1.5.1",
|
"version": "1.6.0",
|
||||||
"description": "RSA utils that work on Windows, Mac, and Linux with or without C compiler",
|
"description": "RSA utils that work on Windows, Mac, and Linux with or without C compiler",
|
||||||
"main": "node.js",
|
"main": "node.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
@ -20,15 +20,9 @@
|
||||||
"certificate",
|
"certificate",
|
||||||
"tls",
|
"tls",
|
||||||
"ssl",
|
"ssl",
|
||||||
"javascript",
|
|
||||||
"js",
|
|
||||||
"node",
|
|
||||||
"node.js",
|
|
||||||
"windows",
|
"windows",
|
||||||
"mac",
|
"mac",
|
||||||
"linux",
|
"linux",
|
||||||
"macOS",
|
|
||||||
"win",
|
|
||||||
"key",
|
"key",
|
||||||
"jwk"
|
"jwk"
|
||||||
],
|
],
|
||||||
|
@ -39,7 +33,7 @@
|
||||||
},
|
},
|
||||||
"homepage": "https://git.coolaj86.com/coolaj86/rsa-compat.js#readme",
|
"homepage": "https://git.coolaj86.com/coolaj86/rsa-compat.js#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"node-forge": "^0.6.41",
|
"node-forge": "^0.7.6",
|
||||||
"ursa-optional": "^0.9.6"
|
"ursa-optional": "^0.9.6"
|
||||||
},
|
},
|
||||||
"trulyOptionalDependencies": {
|
"trulyOptionalDependencies": {
|
||||||
|
|
|
@ -47,7 +47,7 @@ var forgeResult = {
|
||||||
|
|
||||||
var jws = RSA.signJws(
|
var jws = RSA.signJws(
|
||||||
keypair
|
keypair
|
||||||
, new Buffer('24bcc5d4d04d095de47db279b05685c97f787c9b8bd87f88cdaa0137e7228879', 'hex')
|
, Buffer.from('24bcc5d4d04d095de47db279b05685c97f787c9b8bd87f88cdaa0137e7228879', 'hex')
|
||||||
, '8ef5624f5ec9d3ef'
|
, '8ef5624f5ec9d3ef'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue