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

Fix WSS credentials Base64 encoding (for browser) #3509

Merged
merged 3 commits into from
May 8, 2020
Merged

Fix WSS credentials Base64 encoding (for browser) #3509

merged 3 commits into from
May 8, 2020

Conversation

cgewecke
Copy link
Collaborator

@cgewecke cgewecke commented May 8, 2020

Description

Binds btoa to window correctly.

const _web3 = new Web3('wss://usr:psswrd@localhost:8546)

Currently the example above throws these errors in the browser:

Chrome

TypeError: Illegal invocation
    at new s (/var/folders/_p/1jdl7zfx1473cwzhqsz8gx4r0000gn/T/880f08d03d5a7b63dd93c6a4c8d3d895.browserify.js:125206:1235495)

Firefox

'btoa' called on an object that does not implement interface Window.
	s@/var/folders/_p/1jdl7zfx1473cwzhqsz8gx4r0000gn/T/3c102c58b323c6dbbf38414c1423b68e.browserify.js:125206:1235164

Fixes #3508

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have selected the correct base branch.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • Any dependent changes have been merged and published in downstream modules.
  • I ran npm run dtslint with success and extended the tests and types if necessary.
  • I ran npm run test:unit with success.
  • I ran npm run test:cov and my test cases cover all the lines and branches of the added code.
  • I ran npm run build-all and tested the resulting files from dist folder in a browser.
  • I have updated the CHANGELOG.md file in the root folder.
  • I have tested my code on the live network.

@cgewecke cgewecke added 1.x 1.0 related issues Bug Addressing a bug labels May 8, 2020
@coveralls
Copy link

coveralls commented May 8, 2020

Coverage Status

Coverage remained the same at 89.555% when pulling 488b7c2 on issue/3508 into 697b40f on 1.x.

@cgewecke cgewecke added the Review Needed Maintainer(s) need to review label May 8, 2020
Copy link
Collaborator

@ryanio ryanio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for the test case.

@ryanio ryanio merged commit d543605 into 1.x May 8, 2020
@Polycarpik Polycarpik deleted the issue/3508 branch August 12, 2020 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.x 1.0 related issues Bug Addressing a bug Review Needed Maintainer(s) need to review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Websocket Provider's btoa helper's context [browser only]
4 participants