Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work in Node.js #2

Open
chrisgitrepo opened this issue Oct 12, 2018 · 4 comments
Open

Doesn't work in Node.js #2

chrisgitrepo opened this issue Oct 12, 2018 · 4 comments

Comments

@chrisgitrepo
Copy link

Due to the use of pidcrypt, I currently get the error below when running in a Node.js environment:

if(j_lm && (navigator.appName == "Microsoft Internet Explorer")) {
________________^
ReferenceError: navigator is not defined

Also, it doesnt look like something that will be fixed: nikvdp/pidcrypt#5

@franciskim
Copy link

Replace the following (from line 100 of node_modules/pidcrypt/jsbn.js):

if(j_lm && (navigator.appName == "Microsoft Internet Explorer")) {
  BigInteger.prototype.am = am2;
  dbits = 30;
}
else if(j_lm && (navigator.appName != "Netscape")) {
  BigInteger.prototype.am = am1;
  dbits = 26;
}

With:

if(j_lm && typeof navigator !== 'undefined' && (navigator.appName == "Microsoft Internet Explorer")) {
  BigInteger.prototype.am = am2;
  dbits = 30;
}
else if(j_lm && typeof navigator !== 'undefined' && (navigator.appName != "Netscape")) {
  BigInteger.prototype.am = am1;
  dbits = 26;
}

@kevinkga
Copy link

@franciskim 's suggestion worked, but come on seriously, can't this dependency be swapped for another one?

@wagerfield
Copy link
Owner

Suggestions more than welcome @kevinkga. Please feel free to find an alternative encryption library and submit a PR.

@kevinkga
Copy link

I've requested @franciskim fix to be merged into pidcrypt nikvdp/pidcrypt#7. @franciskim please let me know if you want some mention or credit for that. I just want to get it fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants