webpeerjs 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,88 +1,88 @@
1
- {
2
- "name": "webpeerjs",
3
- "version": "0.1.6",
4
- "description": "WebPEER.js is decentralized P2P JS library for communication between applications in browser.",
5
- "main": "./dist/umd/webpeerjs.js",
6
- "module": "./src/webpeerjs.js",
7
- "exports": {
8
- ".": {
9
- "import": "./src/webpeerjs.js",
10
- "require": "./dist/umd/webpeerjs.js"
11
- }
12
- },
13
- "files": [
14
- "dist/",
15
- "src/",
16
- "LICENSE"
17
- ],
18
- "scripts": {
19
- "start": "npm run dev",
20
- "dev": "vite serve test",
21
- "demo": "vite serve demo",
22
- "eslint": "eslint -c ./config/eslint.config.mjs ./src",
23
- "eslint:fix": "eslint -c ./config/eslint.config.mjs ./src --fix",
24
- "removedir": "node -e \"var fs = require('fs'); try{process.argv.slice(1).map((fpath) => fs.rmdirSync(fpath, { recursive: true }))}catch(err){console.log(`Dist not found`)}; process.exit(0);\"",
25
- "build-all": "tsc -p config/tsconfig-rollup.json && rollup -c temp/config/rollup.config.build.js && echo {\"type\": \"commonjs\"}>dist\\umd\\package.json && echo {\"type\": \"module\"}>dist\\esm\\package.json",
26
- "build-types": "tsc -p config/tsconfig-esm.json",
27
- "build": "npm run removedir dist temp && npm run build-all",
28
- "test": "cd test && cd project && npm start"
29
- },
30
- "repository": {
31
- "type": "git",
32
- "url": "git+https://github.com/nuzulul/webpeerjs.git"
33
- },
34
- "keywords": [
35
- "p2p",
36
- "ipfs",
37
- "libp2p",
38
- "peer",
39
- "peer-to-peer",
40
- "decentralized",
41
- "browser-to-browser",
42
- "dapp",
43
- "distributed",
44
- "decentralized-web",
45
- "distributed-web",
46
- "serverless"
47
- ],
48
- "author": {
49
- "name": "Nuzulul Zulkarnain",
50
- "url": "https://nuzulul.github.io"
51
- },
52
- "license": "MIT",
53
- "bugs": {
54
- "url": "https://github.com/nuzulul/webpeerjs/issues"
55
- },
56
- "homepage": "https://github.com/nuzulul/webpeerjs#readme",
57
- "dependencies": {
58
- "@chainsafe/libp2p-gossipsub": "^13.0.0",
59
- "@chainsafe/libp2p-noise": "^15.0.0",
60
- "@chainsafe/libp2p-yamux": "^6.0.2",
61
- "@helia/delegated-routing-v1-http-api-client": "^3.0.1",
62
- "@libp2p/circuit-relay-v2": "^1.0.24",
63
- "@libp2p/dcutr": "^1.1.0",
64
- "@libp2p/identify": "^2.0.2",
65
- "@libp2p/kad-dht": "^12.0.17",
66
- "@libp2p/peer-id": "^4.1.2",
67
- "@libp2p/pubsub-peer-discovery": "^10.0.2",
68
- "@libp2p/simple-metrics": "^1.0.2",
69
- "@libp2p/webrtc": "^4.1.0",
70
- "@libp2p/websockets": "^8.1.0",
71
- "@libp2p/webtransport": "^4.0.32",
72
- "datastore-idb": "^2.1.9",
73
- "libp2p": "^1.6.0"
74
- },
75
- "devDependencies": {
76
- "@eslint/js": "^9.4.0",
77
- "@rollup/plugin-commonjs": "^25.0.8",
78
- "@rollup/plugin-node-resolve": "^15.2.3",
79
- "@rollup/plugin-terser": "^0.4.4",
80
- "@rollup/plugin-typescript": "^11.1.6",
81
- "eslint": "^9.4.0",
82
- "globals": "^15.3.0",
83
- "rollup": "^4.18.0",
84
- "tslib": "^2.6.2",
85
- "typescript": "^5.4.5",
86
- "vite": "^5.2.11"
87
- }
88
- }
1
+ {
2
+ "name": "webpeerjs",
3
+ "version": "0.1.7",
4
+ "description": "WebPEER.js is decentralized P2P JS library for communication between applications in browser.",
5
+ "main": "./dist/umd/webpeerjs.js",
6
+ "module": "./src/webpeerjs.js",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./src/webpeerjs.js",
10
+ "require": "./dist/umd/webpeerjs.js"
11
+ }
12
+ },
13
+ "files": [
14
+ "dist/",
15
+ "src/",
16
+ "LICENSE"
17
+ ],
18
+ "scripts": {
19
+ "start": "npm run dev",
20
+ "dev": "vite serve test",
21
+ "demo": "vite serve demo",
22
+ "eslint": "eslint -c ./config/eslint.config.mjs ./src",
23
+ "eslint:fix": "eslint -c ./config/eslint.config.mjs ./src --fix",
24
+ "removedir": "node -e \"var fs = require('fs'); try{process.argv.slice(1).map((fpath) => fs.rmdirSync(fpath, { recursive: true }))}catch(err){console.log(`Dist not found`)}; process.exit(0);\"",
25
+ "build-all": "tsc -p config/tsconfig-rollup.json && rollup -c temp/config/rollup.config.build.js && echo {\"type\": \"commonjs\"}>dist\\umd\\package.json && echo {\"type\": \"module\"}>dist\\esm\\package.json",
26
+ "build-types": "tsc -p config/tsconfig-esm.json",
27
+ "build": "npm run removedir dist temp && npm run build-all",
28
+ "test": "cd test && cd project && npm start"
29
+ },
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/nuzulul/webpeerjs.git"
33
+ },
34
+ "keywords": [
35
+ "p2p",
36
+ "ipfs",
37
+ "libp2p",
38
+ "peer",
39
+ "peer-to-peer",
40
+ "decentralized",
41
+ "browser-to-browser",
42
+ "dapp",
43
+ "distributed",
44
+ "decentralized-web",
45
+ "distributed-web",
46
+ "serverless"
47
+ ],
48
+ "author": {
49
+ "name": "Nuzulul Zulkarnain",
50
+ "url": "https://nuzulul.github.io"
51
+ },
52
+ "license": "MIT",
53
+ "bugs": {
54
+ "url": "https://github.com/nuzulul/webpeerjs/issues"
55
+ },
56
+ "homepage": "https://github.com/nuzulul/webpeerjs#readme",
57
+ "dependencies": {
58
+ "@chainsafe/libp2p-gossipsub": "^13.0.0",
59
+ "@chainsafe/libp2p-noise": "^15.0.0",
60
+ "@chainsafe/libp2p-yamux": "^6.0.2",
61
+ "@helia/delegated-routing-v1-http-api-client": "^3.0.1",
62
+ "@libp2p/circuit-relay-v2": "^1.0.24",
63
+ "@libp2p/dcutr": "^1.1.0",
64
+ "@libp2p/identify": "^2.0.2",
65
+ "@libp2p/kad-dht": "^12.0.17",
66
+ "@libp2p/peer-id": "^4.1.2",
67
+ "@libp2p/pubsub-peer-discovery": "^10.0.2",
68
+ "@libp2p/simple-metrics": "^1.0.2",
69
+ "@libp2p/webrtc": "^4.1.0",
70
+ "@libp2p/websockets": "^8.1.0",
71
+ "@libp2p/webtransport": "^4.0.32",
72
+ "datastore-idb": "^2.1.9",
73
+ "libp2p": "^1.6.0"
74
+ },
75
+ "devDependencies": {
76
+ "@eslint/js": "^9.4.0",
77
+ "@rollup/plugin-commonjs": "^25.0.8",
78
+ "@rollup/plugin-node-resolve": "^15.2.3",
79
+ "@rollup/plugin-terser": "^0.4.4",
80
+ "@rollup/plugin-typescript": "^11.1.6",
81
+ "eslint": "^9.4.0",
82
+ "globals": "^15.3.0",
83
+ "rollup": "^4.18.0",
84
+ "tslib": "^2.6.2",
85
+ "typescript": "^5.4.5",
86
+ "vite": "^5.2.11"
87
+ }
88
+ }
package/src/config.js CHANGED
@@ -24,13 +24,19 @@ export const CONFIG_TIMEOUT_DIAL_KNOWN_PEERS = 15000
24
24
  export const CONFIG_RUN_ON_TRANSIENT_CONNECTION = false
25
25
  export const CONFIG_WEBRTC_STUN_URLS = 'stun:stun.l.google.com:19302'
26
26
  export const CONFIG_WEBRTC_STUN_URLS_BACKUP = 'stun:global.stun.twilio.com:3478'
27
- export const CONFIG_WEBRTC_TURN_HOST = 'dHVybjpyZWxheTEuZXhwcmVzc3R1cm4uY29tOjM0Nzg='
28
- export const CONFIG_WEBRTC_TURN_USER = 'ZWZJSllZNjdDNElRMzFZQUlP'
29
- export const CONFIG_WEBRTC_TURN_PWD = 'Vk01SmdhODlkYjJaWU9aSA=='
30
- export const CONFIG_WEBRTC_TURN_HOST_BACKUP = 'dHVybjpzdGFuZGFyZC5yZWxheS5tZXRlcmVkLmNhOjgw'
31
- export const CONFIG_WEBRTC_TURN_USER_BACKUP = 'ZmZlNmIxOThjOGMxYjM5ODg1OWFiOGY4'
32
- export const CONFIG_WEBRTC_TURN_PWD_BACKUP = 'aWpkQjVTcTIwREVsZzdDRg=='
33
- export const CONFIG_MESSAGE_SIZE_LIMIT = 10240 // 10KB
27
+ export const CONFIG_WEBRTC_TURN_HOST = 'dHVybjp0dXJuMDEuYnJpZS5maTo1MzQ5'
28
+ export const CONFIG_WEBRTC_TURN_USER = 'YnJpZQ=='
29
+ export const CONFIG_WEBRTC_TURN_PWD = 'Zmk='
30
+ export const CONFIG_WEBRTC_TURN_HOST_BACKUP = 'dHVybjpyZWxheTEuZXhwcmVzc3R1cm4uY29tOjM0Nzg='
31
+ export const CONFIG_WEBRTC_TURN_USER_BACKUP = 'ZWZJSllZNjdDNElRMzFZQUlP'
32
+ export const CONFIG_WEBRTC_TURN_PWD_BACKUP = 'Vk01SmdhODlkYjJaWU9aSA=='
33
+ export const CONFIG_WEBRTC_TURN_HOST_BACKUP1 = 'dHVybjpzdGFuZGFyZC5yZWxheS5tZXRlcmVkLmNhOjgw'
34
+ export const CONFIG_WEBRTC_TURN_USER_BACKUP1 = 'ZmZlNmIxOThjOGMxYjM5ODg1OWFiOGY4'
35
+ export const CONFIG_WEBRTC_TURN_PWD_BACKUP1 = 'aWpkQjVTcTIwREVsZzdDRg=='
36
+ export const CONFIG_MESSAGE_SIZE_LIMIT = 100*1024 // 100KB
37
+ export const CONFIG_DEBUG_ENABLED = false
38
+ export const CONFIG_AUTODIAL_MAX_ERROR_LIMIT = 45
39
+ export const CONFIG_DIAL_MAX_ERROR_LIMIT = 55
34
40
 
35
41
  // this list comes from https://github.com/ipfs/kubo/blob/196887cbe5fbcd41243c1dfb0db681a1cc2914ff/config/bootstrap_peers.go
36
42
  export const CONFIG_KNOWN_DEFAULT_BOOTSTRAP_ADDRESSES = [
package/src/utils.js CHANGED
@@ -28,7 +28,7 @@ const prefix = config.CONFIG_PREFIX
28
28
  export const mkErr = msg => new Error(`${prefix}: ${msg}`)
29
29
 
30
30
  export function mkDebug(msg){
31
- console.debug(msg)
31
+ if(config.CONFIG_DEBUG_ENABLED)console.debug(msg)
32
32
  return
33
33
  }
34
34
 
@@ -51,6 +51,28 @@ export async function first(farr){
51
51
  }
52
52
  }
53
53
 
54
+ //browser detector
55
+ //this code comes from https://stackoverflow.com/a/9851769
56
+
57
+ // Opera 8.0+
58
+ const isOpera = (!!window.opr && !!window.opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
59
+ // Firefox 1.0+
60
+ const isFirefox = typeof InstallTrigger !== 'undefined';
61
+ // Safari 3.0+ "[object HTMLElementConstructor]"
62
+ const isSafari = /constructor/i.test(window.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || (typeof safari !== 'undefined' && window['safari'].pushNotification));
63
+ // Internet Explorer 6-11
64
+ //const isIE = /*@cc_on!@*/false || !!document.documentMode;
65
+ // Edge 20+
66
+ //const isEdge = !isIE && !!window.StyleMedia;
67
+ // Chrome 1 - 79
68
+ const isChrome = !!window.chrome && (!!window.chrome.webstore || !!window.chrome.runtime);
69
+ // Edge (based on chromium) detection
70
+ const isEdgeChromium = isChrome && (navigator.userAgent.indexOf("Edg") != -1);
71
+ // Blink engine detection
72
+ const isBlink = (isChrome || isOpera) && !!window.CSS;
73
+
74
+ export const browser = {isOpera,isFirefox,isSafari,isChrome,isEdgeChromium,isBlink}
75
+
54
76
  //Add id to pupsub message
55
77
  export async function msgIdFnStrictNoSign(msg){
56
78
  var enc = new TextEncoder()
@@ -98,11 +120,19 @@ let lastStats = {
98
120
  open: 0
99
121
  }
100
122
 
123
+ let fail = 0
101
124
  let isDialEnabled = true
102
125
  let lastfailtreshold = 0
103
- let fail = 0
126
+ let isAutoDialEnabled = true
127
+ let lastfailtresholdauto = 0
128
+
104
129
 
105
130
  export function metrics(data){
131
+
132
+ if(isFirefox){
133
+ return {isDialEnabled,isAutoDialEnabled}
134
+ }
135
+
106
136
  try{
107
137
  const webTransportEvents = data.libp2p_webtransport_dialer_events_total
108
138
 
@@ -154,34 +184,50 @@ export function metrics(data){
154
184
  lastStats = webTransportEvents
155
185
 
156
186
  fail = errors+timeouts
157
- const treshold = errors+timeouts+stats.open+stats.pending
158
-
159
- if(treshold>30){
160
- //console.log(`Treeshold hit : ${treshold}`)
161
- }
162
-
163
- if(fail>30){
164
- //console.log(`Open : ${stats.open} , Pending : ${stats.pending} , Succes : ${totals.success} , Fail : ${fail} `)
165
-
166
- }
187
+ //const treshold = errors+timeouts+stats.open+stats.pending
167
188
 
168
- if ((fail-lastfailtreshold)>30){
189
+ if ((fail-lastfailtreshold)>config.CONFIG_DIAL_MAX_ERROR_LIMIT){
169
190
  if(isDialEnabled){
170
191
  isDialEnabled = false
171
- //const str = JSON.stringify({isDialEnabled,fail,lastfailtreshold})
172
192
  console.warn('Peer dial is temporary disabled')
193
+ if(isAutoDialEnabled){
194
+ isAutoDialEnabled = false
195
+ console.warn('Peer autodial is temporary disabled')
196
+ }
173
197
  setTimeout(()=>{
174
198
  if(!isDialEnabled){
175
199
  isDialEnabled = true
176
200
  lastfailtreshold = fail
177
- //const str = JSON.stringify({isDialEnabled,fail,lastfailtreshold})
178
- console.warn('Peer dial is enabled')
201
+ console.warn('Peer dial is resumed')
202
+ if(!isAutoDialEnabled){
203
+ isAutoDialEnabled = true
204
+ lastfailtresholdauto = fail
205
+ console.warn('Peer autodial is resumed')
206
+ }
207
+ }
208
+ },6*60*1000)
209
+ }
210
+ }
211
+
212
+ if ((fail-lastfailtresholdauto)>config.CONFIG_AUTODIAL_MAX_ERROR_LIMIT){
213
+ if(isAutoDialEnabled){
214
+ isAutoDialEnabled = false
215
+ console.warn('Peer autodial is temporary disabled')
216
+ const last = fail
217
+ setTimeout(()=>{
218
+ if(!isAutoDialEnabled && isDialEnabled){
219
+ isAutoDialEnabled = true
220
+ lastfailtresholdauto = fail
221
+ console.warn('Peer autodial is resumed')
222
+ if(isDialEnabled){
223
+ lastfailtreshold = last
224
+ }
179
225
  }
180
226
  },6*60*1000)
181
227
  }
182
228
  }
183
229
 
184
- return isDialEnabled
230
+ return {isDialEnabled,isAutoDialEnabled}
185
231
 
186
232
  }
187
233
  catch{
@@ -200,4 +246,9 @@ export async function getDigest(){
200
246
  const buf = new TextEncoder().encode(Math.random().toString())
201
247
  const digest = await sha256.encode(buf)
202
248
  return digest
249
+ }
250
+
251
+ //detect webtransport
252
+ if(!WebTransport){
253
+ throw mkErr('It seems that your browser does not support the required WebTransport feature')
203
254
  }
package/src/webpeerjs.js CHANGED
@@ -102,16 +102,20 @@ class webpeerjs{
102
102
  //arr to track on connect event
103
103
  #onConnectQueue
104
104
 
105
+ //callback to websocket dialable
106
+ #onWebsocketFn
107
+
105
108
  id
106
109
  status
107
110
  IPFS
108
111
  address
109
112
  peers
110
113
 
111
- constructor(libp2p,dbstore,onMetrics){
114
+ constructor(libp2p,dbstore,onMetrics,onWebsocketFn,onDialFn){
112
115
 
113
116
  this.#libp2p = libp2p
114
117
  this.#dbstore = dbstore
118
+ this.#onWebsocketFn = onWebsocketFn
115
119
  this.#dbstoreData = new Map()
116
120
  this.#discoveredPeers = new Map()
117
121
  this.#webPeersId = []
@@ -581,15 +585,16 @@ class webpeerjs{
581
585
  //const multiaddrs = peer.addresses.map(({ multiaddr }) => multiaddr)
582
586
  //console.log(`changed multiaddrs: peer ${peer.id.toString()} multiaddrs: ${multiaddrs}`)
583
587
  const id = peer.id.toString()
584
- const mddrs = []
585
- peer.addresses.forEach((addr)=>{
586
- const maddr = addr.multiaddr.toString()+'/p2p/'+id
587
- if(maddr.includes('webtransport') && maddr.includes('certhash')){
588
- mddrs.push(maddr)
588
+ const addrs = []
589
+ peer.addresses.forEach((address)=>{
590
+ const addr = address.multiaddr.toString()+'/p2p/'+id
591
+ if(addr.includes('webtransport') && addr.includes('certhash')){
592
+ addrs.push(addr)
589
593
  }
590
594
  })
591
- //this.#ListenAddressChange(mddrs)
592
- this.address = mddrs
595
+ if(!config.CONFIG_RUN_ON_TRANSIENT_CONNECTION)addrs.reverse()
596
+ //this.#ListenAddressChange(addrs)
597
+ this.address = addrs
593
598
  this.#ping()
594
599
  this.#peerDiscoveryHybrid()
595
600
  })
@@ -668,7 +673,8 @@ class webpeerjs{
668
673
 
669
674
  onMetrics((data)=>{
670
675
  const signal = metrics(data)
671
- this.#isDialEnabled = signal
676
+ this.#isDialEnabled = signal.isDialEnabled
677
+ onDialFn(signal.isAutoDialEnabled)
672
678
 
673
679
  })
674
680
 
@@ -1656,7 +1662,7 @@ class webpeerjs{
1656
1662
 
1657
1663
  //dial based on known bootsrap peers address using Websocket expected
1658
1664
  #dialKnownBootstrap(){
1659
-
1665
+ //console.log('#dialKnownBootstrap()')
1660
1666
  if(!navigator.onLine)return
1661
1667
  if(!this.#isDialEnabled)return
1662
1668
 
@@ -1676,6 +1682,7 @@ class webpeerjs{
1676
1682
 
1677
1683
  this.#dialedKnownBootstrap.set(id,addrs)
1678
1684
  this.#isDialWebsocket = true
1685
+ this.#onWebsocketFn(true)
1679
1686
  if(!this.#isConnected(id)){
1680
1687
  this.#dialMultiaddress(mddrs)
1681
1688
  }
@@ -1685,7 +1692,7 @@ class webpeerjs{
1685
1692
 
1686
1693
  //dial based on known bootstrap DNS
1687
1694
  async #dialKnownDNS(){
1688
-
1695
+ //console.log('#dialKnownDNS()')
1689
1696
  if(!navigator.onLine)return
1690
1697
  if(!this.#isDialEnabled)return
1691
1698
 
@@ -1718,6 +1725,7 @@ class webpeerjs{
1718
1725
 
1719
1726
  this.#dialedKnownBootstrap.set(id,addrs)
1720
1727
  this.#isDialWebsocket = true
1728
+ this.#onWebsocketFn(true)
1721
1729
  if(!this.#isConnected(id)){
1722
1730
  this.#dialMultiaddress(mddrs)
1723
1731
  }
@@ -1728,7 +1736,7 @@ class webpeerjs{
1728
1736
 
1729
1737
  //dial based on known bootstrap DNS using DNS resolver only
1730
1738
  async #dialKnownDNSonly(){
1731
-
1739
+ console.log('#dialKnownDNSonly()')
1732
1740
  if(!navigator.onLine)return
1733
1741
  if(!this.#isDialEnabled)return
1734
1742
 
@@ -1765,6 +1773,7 @@ class webpeerjs{
1765
1773
 
1766
1774
 
1767
1775
  this.#isDialWebsocket = true
1776
+ this.#onWebsocketFn(true)
1768
1777
  this.#dialedKnownBootstrap.set(id,addrs)
1769
1778
 
1770
1779
  this.#dialedKnownBootstrap.set(id,addrs)
@@ -1832,6 +1841,21 @@ class webpeerjs{
1832
1841
 
1833
1842
  let onMetricsFn = () => {}
1834
1843
  const onMetrics = f => (onMetricsFn = f)
1844
+
1845
+ let isWebsocket = false
1846
+ let onWebsocketFn = () => {}
1847
+ const onWebsocket = f => (onWebsocketFn = f)
1848
+ onWebsocket((data)=>{
1849
+ isWebsocket = data
1850
+ })
1851
+
1852
+ let isDial = true
1853
+ let onDialFn = () => {}
1854
+ const onDial = f => (onDialFn = f)
1855
+ onDial((data)=>{
1856
+ //if(isDial!=data)console.warn('isDial',data)
1857
+ isDial = data
1858
+ })
1835
1859
 
1836
1860
  let listenaddress = []
1837
1861
 
@@ -1934,6 +1958,7 @@ class webpeerjs{
1934
1958
  pc.createDataChannel('webpeerjs');
1935
1959
  pc.createOffer().then(offer => pc.setLocalDescription(offer));
1936
1960
  })
1961
+ //console.log(ice)
1937
1962
 
1938
1963
  //create libp2p instance
1939
1964
  const libp2p = await createLibp2p({
@@ -1979,24 +2004,26 @@ class webpeerjs{
1979
2004
  ],
1980
2005
  connectionGater: {
1981
2006
  filterMultiaddrForPeer: async (peer, multiaddrTest) => {
1982
- const multiaddrString = multiaddrTest.toString();
2007
+ const multiaddrString = multiaddrTest.toString()
1983
2008
  if (
1984
2009
  multiaddrString.includes("/ip4/127.0.0.1") ||
1985
2010
  multiaddrString.includes("/ip6/")
1986
2011
  ) {
1987
- return false;
2012
+ return false
1988
2013
  }
1989
- return true;
2014
+ if(multiaddrString.includes("/ws/") || multiaddrString.includes("/wss/"))return isWebsocket
2015
+ return isDial
1990
2016
  },
1991
2017
  denyDialMultiaddr: async (multiaddrTest) => {
1992
- const multiaddrString = multiaddrTest.toString();
2018
+ const multiaddrString = multiaddrTest.toString()
1993
2019
  if (
1994
2020
  multiaddrString.includes("/ip4/127.0.0.1") ||
1995
2021
  multiaddrString.includes("/ip6/")
1996
2022
  ) {
1997
- return true;
2023
+ return true
1998
2024
  }
1999
- return false;
2025
+ if(multiaddrString.includes("/ws/") || multiaddrString.includes("/wss/"))return !isWebsocket
2026
+ return !isDial
2000
2027
  },
2001
2028
  },
2002
2029
  peerDiscovery: [
@@ -2042,7 +2069,7 @@ class webpeerjs{
2042
2069
 
2043
2070
 
2044
2071
  //return webpeerjs class
2045
- return new webpeerjs(libp2p,dbstore,onMetrics)
2072
+ return new webpeerjs(libp2p,dbstore,onMetrics,onWebsocketFn,onDialFn)
2046
2073
  }
2047
2074
  }
2048
2075