Compare commits

...

2 Commits

Author SHA1 Message Date
d3b459aaf5 v1.0.3: update README 2018-11-23 12:44:06 -07:00
57edc8641b expose importSync and exportSync 2018-11-23 12:42:07 -07:00
3 changed files with 89 additions and 73 deletions

View File

@ -17,6 +17,10 @@ This project is fully functional and tested (and the code is pretty clean).
It is considered to be complete, but if you find a bug please open an issue.
## Looking for ECDSA as well?
Check out [Eckles.js](https://git.coolaj86.com/coolaj86/eckles.js)
## PEM-to-JWK
* [x] PKCS#1 (traditional)

View File

@ -7,8 +7,7 @@ var x509 = require('./x509.js');
var ASN1 = require('./asn1.js');
/*global Promise*/
RSA.parse = function parseRsa(opts) {
return Promise.resolve().then(function () {
RSA.importSync = function (opts) {
if (!opts || !opts.pem || 'string' !== typeof opts.pem) {
throw new Error("must pass { pem: pem } as a string");
}
@ -34,6 +33,13 @@ RSA.parse = function parseRsa(opts) {
jwk = RSA.nueter(jwk);
}
return jwk;
};
RSA.parse = function parseRsa(opts) {
// wrapped in a promise for API compatibility
// with the forthcoming browser version
// (and potential future native node capability)
return Promise.resolve().then(function () {
return RSA.importSync(opts);
});
};
RSA.toJwk = RSA.import = RSA.parse;
@ -53,8 +59,7 @@ RSAPrivateKey ::= SEQUENCE {
}
*/
RSA.pack = function (opts) {
return Promise.resolve().then(function () {
RSA.exportSync = function (opts) {
if (!opts || !opts.jwk || 'object' !== typeof opts.jwk) {
throw new Error("must pass { jwk: jwk }");
}
@ -104,6 +109,13 @@ RSA.pack = function (opts) {
} else {
throw new Error("Sanity Error: reached unreachable code block with format: " + format);
}
};
RSA.pack = function (opts) {
// wrapped in a promise for API compatibility
// with the forthcoming browser version
// (and potential future native node capability)
return Promise.resolve().then(function () {
return RSA.exportSync(opts);
});
};
RSA.toPem = RSA.export = RSA.pack;

View File

@ -1,6 +1,6 @@
{
"name": "rasha",
"version": "1.0.1",
"version": "1.0.3",
"description": "💯 PEM-to-JWK and JWK-to-PEM for RSA keys in a lightweight, zero-dependency library focused on perfect universal compatibility.",
"homepage": "https://git.coolaj86.com/coolaj86/rasha.js",
"main": "index.js",