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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,4 @@ Released with 1.0.0-beta.37 code base.

- Fix intermittent CI build issues with `dtslint`. (#3479)
- Fix provider "error" / "end" events not fired when Websocket provider disconnects (#3485)
- Fix WSS credentials Base64 encoding (for browser) (#3508)
2 changes: 1 addition & 1 deletion packages/web3-providers-ws/src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if (isNode) {
helpers = require('url').parse;
}
} else {
_btoa = btoa;
_btoa = btoa.bind(window);
helpers = function(url) {
return new URL(url);
};
Expand Down
7 changes: 6 additions & 1 deletion test/e2e.contract.deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,10 @@ describe('contract.deploy [ @E2E ]', function() {
describe('ws', function() {
// Websockets extremely erratic for geth instamine...
if (process.env.GETH_INSTAMINE) return;
var port;

before(async function(){
var port = utils.getWebsocketPort();
port = utils.getWebsocketPort();

web3 = new Web3('ws://localhost:' + port);
accounts = await web3.eth.getAccounts();
Expand Down Expand Up @@ -259,6 +260,10 @@ describe('contract.deploy [ @E2E ]', function() {
done();
})
})

it('can connect over wss with username:password header', function(){
const _web3 = new Web3('wss://usr:psswrd@localhost:' + port);
});
});
});