Skip to content

Commit

Permalink
fix: libp2p/webtransports in serviceworker
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtPooki committed Mar 23, 2023
1 parent 02bad96 commit f526c32
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 15 deletions.
47 changes: 34 additions & 13 deletions package-lock.json

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

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"build": "webpack --env production",
"serve": "webpack serve --mode=development",
"start": "npm run serve",
"test": "npm run build && playwright test tests"
"test": "npm run build && playwright test tests",
"postinstall": "patch-package"
},
"browser": "./dist/src/index.js",
"browserslist": [
Expand All @@ -25,12 +26,14 @@
"@libp2p/delegated-content-routing": "^4.0.1",
"@libp2p/delegated-peer-routing": "^4.0.1",
"@libp2p/kad-dht": "^8.0.1",
"@libp2p/peer-id": "^2.0.3",
"@libp2p/websockets": "^5.0.3",
"@libp2p/webtransport": "^1.0.7",
"@multiformats/multiaddr": "^12.0.0",
"@multiformats/multiaddr": "^12.1.0",
"blockstore-core": "^3.0.0",
"datastore-core": "^8.0.4",
"datastore-level": "^10.0.1",
"debug": "^4.3.4",
"helia": "next",
"kubo-rpc-client": "^3.0.1",
"libp2p": "^0.42.2",
Expand Down Expand Up @@ -59,6 +62,7 @@
"dexie": "^3.2.3",
"html-webpack-plugin": "^5.3.2",
"node-polyfill-webpack-plugin": "^2.0.1",
"patch-package": "^6.5.1",
"playwright": "^1.12.3",
"rimraf": "^4.1.2",
"style-loader": "^3.1.0",
Expand Down
13 changes: 13 additions & 0 deletions patches/@libp2p+webtransport+1.0.7.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/node_modules/@libp2p/webtransport/dist/src/index.js b/node_modules/@libp2p/webtransport/dist/src/index.js
index 5043a2b..1e31d3c 100644
--- a/node_modules/@libp2p/webtransport/dist/src/index.js
+++ b/node_modules/@libp2p/webtransport/dist/src/index.js
@@ -255,7 +255,7 @@ class WebTransport {
if (certhashes.length === 0) {
throw new Error('Expected multiaddr to contain certhashes');
}
- const wt = new window.WebTransport(`${url}/.well-known/libp2p-webtransport?type=noise`, {
+ const wt = new globalThis.WebTransport(`${url}/.well-known/libp2p-webtransport?type=noise`, {
serverCertificateHashes: certhashes.map(certhash => ({
algorithm: 'sha-256',
value: certhash.digest

0 comments on commit f526c32

Please sign in to comment.