Skip to content

Commit

Permalink
Merge 3d2b26f into a3dc9b4
Browse files Browse the repository at this point in the history
  • Loading branch information
ineiti committed Oct 22, 2020
2 parents a3dc9b4 + 3d2b26f commit 678e6ea
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
21 changes: 20 additions & 1 deletion external/js/cothority/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion external/js/cothority/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@dedis/cothority",
"version": "3.6.0",
"version": "3.6.1",
"description": "A typescript implementation of the cothority",
"main": "index.js",
"browser": "bundle.min.js",
Expand Down Expand Up @@ -54,6 +54,7 @@
"sprintf-js": "^1.1.2",
"toml": "^2.3.5",
"tslib": "^1.10.0",
"url-parse": "^1.4.7",
"util": "^0.11.1",
"ws": "^6.1.2"
},
Expand Down
9 changes: 5 additions & 4 deletions external/js/cothority/src/network/websocket.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Message } from "protobufjs";
import { Observable } from "rxjs";
import URL from "url-parse";
import Log from "../log";
import { IConnection } from "./nodes";
import { Roster } from "./proto";
Expand Down Expand Up @@ -39,18 +40,18 @@ export class WebSocketConnection implements IConnection {
// by the fact that URL will not allow you to have an empty pathname,
// which will always equal to "/" if there isn't any
if (url.pathname.slice(-1) !== "/") {
url.pathname = url.pathname + "/";
url.set("pathname", url.pathname + "/");
}
if (url.username !== "" || url.password !== "") {
throw new Error("addr contains authentication, which is not supported");
}
if (url.search !== "" || url.hash !== "") {
if (url.query !== undefined || url.hash !== "") {
throw new Error("addr contains more data than the origin");
}

if (typeof globalThis !== "undefined" && typeof globalThis.location !== "undefined") {
if (globalThis.location.protocol === "https:") {
url.protocol = "wss";
url.set("protocol", "wss");
}
}

Expand Down Expand Up @@ -112,7 +113,7 @@ export class WebSocketConnection implements IConnection {

return new Observable((sub) => {
const url = new URL(this.url.href);
url.pathname += `${this.service}/${message.$type.name.replace(/.*\./, "")}`;
url.set("pathname", url.pathname + `${this.service}/${message.$type.name.replace(/.*\./, "")}`);
Log.lvl4(`Socket: new WebSocket(${url.href})`);
const ws = factory(url.href);
const bytes = Buffer.from(message.$type.encode(message).finish());
Expand Down

0 comments on commit 678e6ea

Please sign in to comment.