Compare commits

..

3 Commits

Author SHA1 Message Date
semantic-release-bot eeb8a816a0 chore(release): 0.1.0-develop.16 [skip ci]
# [0.1.0-develop.16](https://git.lumeweb.com/LumeWeb/libs5/compare/v0.1.0-develop.15...v0.1.0-develop.16) (2023-09-01)

### Bug Fixes

* add support for browser WS by checking if we are in node ([0a15337](0a153379c8))
2023-09-01 10:21:10 +00:00
Derrick Hammer f81f170ee9
Merge remote-tracking branch 'origin/develop' into develop 2023-09-01 06:20:13 -04:00
Derrick Hammer 0a153379c8
fix: add support for browser WS by checking if we are in node 2023-09-01 06:19:56 -04:00
4 changed files with 13 additions and 6 deletions

View File

@ -1,3 +1,10 @@
# [0.1.0-develop.16](https://git.lumeweb.com/LumeWeb/libs5/compare/v0.1.0-develop.15...v0.1.0-develop.16) (2023-09-01)
### Bug Fixes
* add support for browser WS by checking if we are in node ([0a15337](https://git.lumeweb.com/LumeWeb/libs5/commit/0a153379c87ebbee8c7d7b3015fe4c1b77f379ca))
# [0.1.0-develop.15](https://git.lumeweb.com/LumeWeb/libs5/compare/v0.1.0-develop.14...v0.1.0-develop.15) (2023-09-01)
# [0.1.0-develop.14](https://git.lumeweb.com/LumeWeb/libs5/compare/v0.1.0-develop.13...v0.1.0-develop.14) (2023-08-31)

4
npm-shrinkwrap.json generated
View File

@ -1,12 +1,12 @@
{
"name": "@lumeweb/libs5",
"version": "0.1.0-develop.15",
"version": "0.1.0-develop.16",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@lumeweb/libs5",
"version": "0.1.0-develop.15",
"version": "0.1.0-develop.16",
"dependencies": {
"@noble/curves": "^1.1.0",
"@noble/hashes": "^1.3.1",

View File

@ -1,6 +1,6 @@
{
"name": "@lumeweb/libs5",
"version": "0.1.0-develop.15",
"version": "0.1.0-develop.16",
"type": "module",
"main": "lib/index.js",
"repository": {

View File

@ -1,8 +1,8 @@
import { Logger, Peer } from "../types.js";
import NodeId from "../nodeId.js";
import { URL } from "url";
import { WebSocket } from "ws";
import * as WS from "ws";
import { BasePeer } from "#transports/base.js";
import isNode from "detect-node";
export class WebSocketPeer extends BasePeer implements Peer {
sendMessage(message: Uint8Array): void {
@ -39,7 +39,7 @@ export class WebSocketPeer extends BasePeer implements Peer {
public static async connect(uri: URL): Promise<WebSocket> {
return new Promise((resolve, reject) => {
const socket = new WebSocket(uri);
const socket = isNode ? new WS.WebSocket() : new WebSocket(uri);
socket.addEventListener("open", () => {
resolve(socket);
});