iancoleman / bip39

A web tool for converting BIP39 mnemonic codes
https://iancoleman.io/bip39/
MIT License
3.45k stars 1.43k forks source link

Problem with 0.4.0 Standalone #395

Closed pieman64 closed 4 years ago

pieman64 commented 4 years ago

Hi Ian,

Any reason why 0.4.0 standalone fails to open in Chrome or Brave?

Earlier versions were fine.

iancoleman commented 4 years ago

Nothing I know specifically that would cause it to fail. All tests are passing in chrome and firefox.

Which version of chrome? Any errors showing in the developer tools?

When you say 'fails to open' does that mean it always shows 'Loading' at the top of the page? Or no content at all? Or it finishes loading but input does nothing?

pieman64 commented 4 years ago

@iancoleman Chrome 79.0.3945.88 (Official Build) (64-bit) - latest on Windows 10.

Developer tools:

Uncaught DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.
    at Object.<anonymous> (file:///C:/UD/bip39-standalone-0.4.0BAD.html:20460:1529148)
    at Object.653../context (file:///C:/UD/bip39-standalone-0.4.0BAD.html:20460:1530049)
    at o (file:///C:/UD/bip39-standalone-0.4.0BAD.html:20460:599)
    at file:///C:/UD/bip39-standalone-0.4.0BAD.html:20460:633
    at Object.659../native (file:///C:/UD/bip39-standalone-0.4.0BAD.html:20460:1531882)
    at o (file:///C:/UD/bip39-standalone-0.4.0BAD.html:20460:599)
    at file:///C:/UD/bip39-standalone-0.4.0BAD.html:20460:633
    at Object.642../lib/account (file:///C:/UD/bip39-standalone-0.4.0BAD.html:20460:1507380)
    at o (file:///C:/UD/bip39-standalone-0.4.0BAD.html:20460:599)
    at file:///C:/UD/bip39-standalone-0.4.0BAD.html:20460:633
(anonymous) @ VM42 bip39-standalone-0.4.0BAD.html:20460
653../context @ VM42 bip39-standalone-0.4.0BAD.html:20460
o @ VM42 bip39-standalone-0.4.0BAD.html:20460
(anonymous) @ VM42 bip39-standalone-0.4.0BAD.html:20460
659../native @ VM42 bip39-standalone-0.4.0BAD.html:20460
o @ VM42 bip39-standalone-0.4.0BAD.html:20460
(anonymous) @ VM42 bip39-standalone-0.4.0BAD.html:20460
642../lib/account @ VM42 bip39-standalone-0.4.0BAD.html:20460
o @ VM42 bip39-standalone-0.4.0BAD.html:20460
(anonymous) @ VM42 bip39-standalone-0.4.0BAD.html:20460
1.base-x @ VM42 bip39-standalone-0.4.0BAD.html:20460
o @ VM42 bip39-standalone-0.4.0BAD.html:20460
r @ VM42 bip39-standalone-0.4.0BAD.html:20460
(anonymous) @ VM42 bip39-standalone-0.4.0BAD.html:20460
(anonymous) @ VM42 bip39-standalone-0.4.0BAD.html:20460
(anonymous) @ VM42 bip39-standalone-0.4.0BAD.html:20460
VM47 bip39-standalone-0.4.0BAD.html:20462 Uncaught ReferenceError: libs is not defined
    at VM47 bip39-standalone-0.4.0BAD.html:20462
(anonymous) @ VM47 bip39-standalone-0.4.0BAD.html:20462
VM48 bip39-standalone-0.4.0BAD.html:22220 Uncaught ReferenceError: libs is not defined
    at VM48 bip39-standalone-0.4.0BAD.html:22220
    at VM48 bip39-standalone-0.4.0BAD.html:22875
(anonymous) @ VM48 bip39-standalone-0.4.0BAD.html:22220
(anonymous) @ VM48 bip39-standalone-0.4.0BAD.html:22875
bip39-standalone-0.4.0BAD.html:35158 Uncaught ReferenceError: libs is not defined
    at new <anonymous> (bip39-standalone-0.4.0BAD.html:35158)
    at bip39-standalone-0.4.0BAD.html:35156
(anonymous) @ bip39-standalone-0.4.0BAD.html:35158
(anonymous) @ bip39-standalone-0.4.0BAD.html:35156
bip39-standalone-0.4.0BAD.html:35495 Uncaught ReferenceError: libs is not defined
    at bip39-standalone-0.4.0BAD.html:35495
    at bip39-standalone-0.4.0BAD.html:38844

Loading is shown permanently top center of the page.

iancoleman commented 4 years ago

Thanks for this.

I was able to reproduce this, it's caused when third-party cookies are blocked. Allowing third-party cookies makes the page work but I do not recommend this as a fix! I'll look into the code to see why this is happening. It seems that this setting causes some side-effects with localStorage which is causing the page to not work.

https://www.chromium.org/for-testers/bug-reporting-guidelines/uncaught-securityerror-failed-to-read-the-localstorage-property-from-window-access-is-denied-for-this-document

This is most likely some dependency in the libraries that requires (or checks for) localStorage during initialisation and is causing an error to throw, so the libraries never get loaded. I'll have to look into it further to know for sure and fix this.

iancoleman commented 4 years ago

It's caused by Nebulas library calling localstorage

https://github.com/nebulasio/neb.js/blob/master/lib/nvm/native.js

It's not possible to override localStorage with some other javascript (eg localStorage = {}) the error still is thrown.

From here need to work out the best way to either exclude that part of the code or override it.

pieman64 commented 4 years ago

When I compile with the latest commit I get the expected ETH address in standalone (without any Chrome or Brave issues) from my 12 word seed but it's giving me an incorrect private key that doesn't match what I expect it to be and it doesn't import into Metamask.

Any ideas Ian?

PaulUD commented 4 years ago

@iancoleman same issue regarding incorrect private key for ETH seed with release 0.4.1.

Standalone works ok again for Chrome but doesn't give the private key I expect.

PaulUD commented 4 years ago

@iancoleman in short pk for ETH 12 word seed in version 0.3.14 gives expected result, same seed in versions after 0.3.14 do not.

Any ideas?

iancoleman commented 4 years ago

Original issue closed by https://github.com/iancoleman/bip39/commit/d07983bc1fa691821cc2580ce4490638cee4f630 - Catch nebulas error on some chrome configs

@pieman64 @PaulUD please continue any further reporting of ethereum issue in https://github.com/iancoleman/bip39/issues/399 thanks.