From aae4ad4e3f8c5183c2ffe571e10033948bb6379f Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Fri, 13 Jul 2018 04:33:17 -0600 Subject: [PATCH] v1.5.1: don't cause ursa-optional to install due to error messages --- README.md | 7 +++++++ lib/rsa-ursa.js | 12 +++++++++++- node.js | 8 ++++++-- package.json | 6 +++--- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b06cd6e..72b0064 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,13 @@ node.js npm install --save rsa-compat ``` +For **more efficient** RSA key generation: +(I dropped `ursa` as an "optional dependency" because the non-fatal error messages on unsupported platforms and node versions were confusing people, but I still recommend installing it) + +```bash +npm install --save ursa +``` + **Node < v6** support: ```bash diff --git a/lib/rsa-ursa.js b/lib/rsa-ursa.js index 725e76c..db033e7 100644 --- a/lib/rsa-ursa.js +++ b/lib/rsa-ursa.js @@ -1,6 +1,16 @@ 'use strict'; -var ursa = require('ursa-optional'); +var ursa; +try { + ursa = require('ursa'); +} catch(e) { + try { + ursa = require('ursa-optional'); + } catch(e2) { + throw e; + } +} + function notToJson() { return undefined; diff --git a/node.js b/node.js index dabe709..7577925 100644 --- a/node.js +++ b/node.js @@ -24,9 +24,13 @@ function create(deps) { deps.RSA = RSA; try { - RSA._URSA = require('ursa-optional'); + RSA._URSA = require('ursa'); } catch(e) { - // ignore + try { + RSA._URSA = require('ursa-optional'); + } catch(e) { + // ignore + } } RSA.utils = require('./lib/key-utils.js'); diff --git a/package.json b/package.json index bd7d3c2..8daa577 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rsa-compat", - "version": "1.5.0", + "version": "1.5.1", "description": "RSA utils that work on Windows, Mac, and Linux with or without C compiler", "main": "node.js", "bin": { @@ -42,10 +42,10 @@ "node-forge": "^0.6.41" }, "optionalDependencies": { - "ursa-optional": "^0.9.4" }, "trulyOptionalDependencies": { "buffer-v6-polyfill": "^1.0.3", - "ursa": "^0.9.4" + "ursa": "^0.9.4", + "ursa-optional": "^0.9.4" } }