@libp2p/webrtc 5.0.0 → 5.0.1-18dd3cb26

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/dist/index.min.js CHANGED
@@ -22,7 +22,7 @@ a=candidate:1467250027 1 UDP 1467250027 ${e} ${n} typ host\r
22
22
  a=ice-ufrag:`+t+`
23
23
  `).replace(/\na=ice-pwd:[^\n]*\n/,`
24
24
  a=ice-pwd:`+t+`
25
- `),r}var Hh=Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Mh=r=>[...Array(r)].map(()=>Hh.at(Math.floor(Math.random()*Hh.length))).join("");var Dg=1e4,u8=Q("webrtc-direct").code,Oh=Q("certhash").code,ci=class{log;metrics;components;init;constructor(t,e={}){this.log=t.logger.forComponent("libp2p:webrtc-direct"),this.components=t,this.init=e,t.metrics!=null&&(this.metrics={dialerEvents:t.metrics.registerCounterGroup("libp2p_webrtc-direct_dialer_events_total",{label:"event",help:"Total count of WebRTC-direct dial events by type"})})}[zn]=!0;[Symbol.toStringTag]="@libp2p/webrtc-direct";[Sr]=["@libp2p/transport"];async dial(t,e){let n=await this._connect(t,e);return this.log("dialing address: %a",t),n}createListener(t){throw new $s("WebRTCTransport.createListener")}listenFilter(t){return t.filter(Ef.exactMatch)}dialFilter(t){return this.listenFilter(t)}async _connect(t,e){let n=new AbortController,o=n.signal,s=t.getPeerId();if(s===null)throw new Ks("we need to have the remote's PeerId");let i=Kr(s),a=Dc(ai(t)),c=await yr.generateCertificate({name:"ECDSA",namedCurve:"P-256",hash:Pc(a.code)}),l=new yr({...await Dn(this.init.rtcConfiguration),certificates:[c]});try{let u=new Promise((A,k)=>{let I=l.createDataChannel("",{negotiated:!0,id:0}),V=setTimeout(()=>{let L=`Data channel was never opened: state: ${I.readyState}`;this.log.error(L),this.metrics?.dialerEvents.increment({open_error:!0}),k(new Mn("data",L))},Dg);I.onopen=L=>{clearTimeout(V),A(I)},I.onerror=L=>{clearTimeout(V);let K=`Error opening a data channel for handshaking: ${L.target?.toString()??"not specified"}`;this.log.error(K),this.metrics?.dialerEvents.increment({unknown_error:!0}),k(new Mn("data",K))}}),f="libp2p+webrtc+v1/"+Mh(32),d=await l.createOffer(),w=Ph(d,f);await l.setLocalDescription(w);let x=Dh(t,f);await l.setRemoteDescription(x);let m=await u,h=this.generateNoisePrologue(l,a.code,t),g=Rh({prologueBytes:h})(this.components),b=zr({channel:m,direction:"inbound",logger:this.components.logger,...this.init.dataChannel??{}}),p={...b,sink:b.sink.bind(b),source:async function*(){for await(let A of b.source)for(let k of A)yield k}()},B=new mr(this.components,{peerConnection:l,remoteAddr:t,timeline:{open:Date.now()},metrics:this.metrics?.dialerEvents}),_=Un?"iceconnectionstatechange":"connectionstatechange";l.addEventListener(_,()=>{switch(l.connectionState){case"failed":case"disconnected":case"closed":B.close().catch(A=>{this.log.error("error closing connection",A)}).finally(()=>{n.abort()});break;default:break}},{signal:o}),this.metrics?.dialerEvents.increment({peer_connection:!0});let N=new Ye(this.components,{peerConnection:l,metrics:this.metrics?.dialerEvents,dataChannelOptions:this.init.dataChannel});return await g.secureInbound(p,{signal:o,remotePeer:i}),await e.upgrader.upgradeOutbound(B,{skipProtection:!0,skipEncryption:!0,muxerFactory:N})}catch(u){throw l.close(),u}}generateNoisePrologue(t,e,n){if(t.getConfiguration().certificates?.length===0)throw new tt("no local certificate");let o=Uh(t,{log:this.log});if(o==null)throw new tt("no local fingerprint found");let s=o.trim().toLowerCase().replaceAll(":",""),i=et(s,"hex"),a=Mt(e,i),c=Uc.decode(ai(n)),l=et("libp2p-webrtc-noise:");return St([l,a.bytes,c])}};function Pg(r){return t=>new ci(t,r)}function Og(r){return t=>new Qs(t,r)}return ed(Hg);})();
25
+ `),r}var Hh=Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Mh=r=>[...Array(r)].map(()=>Hh.at(Math.floor(Math.random()*Hh.length))).join("");var Dg=1e4,c8=Q("webrtc-direct").code,Oh=Q("certhash").code,ci=class{log;metrics;components;init;constructor(t,e={}){this.log=t.logger.forComponent("libp2p:webrtc-direct"),this.components=t,this.init=e,t.metrics!=null&&(this.metrics={dialerEvents:t.metrics.registerCounterGroup("libp2p_webrtc-direct_dialer_events_total",{label:"event",help:"Total count of WebRTC-direct dial events by type"})})}[zn]=!0;[Symbol.toStringTag]="@libp2p/webrtc-direct";[Sr]=["@libp2p/transport"];async dial(t,e){let n=await this._connect(t,e);return this.log("dialing address: %a",t),n}createListener(t){throw new $s("WebRTCTransport.createListener")}listenFilter(t){return t.filter(Ef.exactMatch)}dialFilter(t){return this.listenFilter(t)}async _connect(t,e){let n=new AbortController,o=n.signal,s=t.getPeerId();if(s===null)throw new Ks("we need to have the remote's PeerId");let i=Kr(s),a=Dc(ai(t)),c=await yr.generateCertificate({name:"ECDSA",namedCurve:"P-256",hash:Pc(a.code)}),l=new yr({...await Dn(this.init.rtcConfiguration),certificates:[c]});try{let u=new Promise((A,k)=>{let I=l.createDataChannel("",{negotiated:!0,id:0}),V=setTimeout(()=>{let L=`Data channel was never opened: state: ${I.readyState}`;this.log.error(L),this.metrics?.dialerEvents.increment({open_error:!0}),k(new Mn("data",L))},Dg);I.onopen=L=>{clearTimeout(V),A(I)},I.onerror=L=>{clearTimeout(V);let K=`Error opening a data channel for handshaking: ${L.target?.toString()??"not specified"}`;this.log.error(K),this.metrics?.dialerEvents.increment({unknown_error:!0}),k(new Mn("data",K))}}),f="libp2p+webrtc+v1/"+Mh(32),d=await l.createOffer(),w=Ph(d,f);await l.setLocalDescription(w);let x=Dh(t,f);await l.setRemoteDescription(x);let m=await u,h=this.generateNoisePrologue(l,a.code,t),g=Rh({prologueBytes:h})(this.components),b=zr({channel:m,direction:"inbound",logger:this.components.logger,...this.init.dataChannel??{}}),p={...b,sink:b.sink.bind(b),source:async function*(){for await(let A of b.source)for(let k of A)yield k}()},B=new mr(this.components,{peerConnection:l,remoteAddr:t,timeline:{open:Date.now()},metrics:this.metrics?.dialerEvents}),_=Un?"iceconnectionstatechange":"connectionstatechange";l.addEventListener(_,()=>{switch(l.connectionState){case"failed":case"disconnected":case"closed":B.close().catch(A=>{this.log.error("error closing connection",A)}).finally(()=>{n.abort()});break;default:break}},{signal:o}),this.metrics?.dialerEvents.increment({peer_connection:!0});let N=new Ye(this.components,{peerConnection:l,metrics:this.metrics?.dialerEvents,dataChannelOptions:this.init.dataChannel});return await g.secureInbound(p,{signal:o,remotePeer:i}),await e.upgrader.upgradeOutbound(B,{skipProtection:!0,skipEncryption:!0,muxerFactory:N})}catch(u){throw l.close(),u}}generateNoisePrologue(t,e,n){if(t.getConfiguration().certificates?.length===0)throw new tt("no local certificate");let o=Uh(t,{log:this.log});if(o==null)throw new tt("no local fingerprint found");let s=o.trim().toLowerCase().replaceAll(":",""),i=et(s,"hex"),a=Mt(e,i),c=Uc.decode(ai(n)),l=et("libp2p-webrtc-noise:");return St([l,a.bytes,c])}};function Pg(r){return t=>new ci(t,r)}function Og(r){return t=>new Qs(t,r)}return ed(Hg);})();
26
26
  /*! Bundled license information:
27
27
 
28
28
  pvtsutils/build/index.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/webrtc",
3
- "version": "5.0.0",
3
+ "version": "5.0.1-18dd3cb26",
4
4
  "description": "A libp2p transport using WebRTC connections",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/transport-webrtc#readme",
@@ -50,11 +50,11 @@
50
50
  "doc-check": "aegir doc-check"
51
51
  },
52
52
  "dependencies": {
53
- "@chainsafe/libp2p-noise": "^15.0.0",
54
- "@libp2p/interface": "^2.0.0",
55
- "@libp2p/interface-internal": "^2.0.0",
56
- "@libp2p/peer-id": "^5.0.0",
57
- "@libp2p/utils": "^6.0.0",
53
+ "@chainsafe/libp2p-noise": "^16.0.0",
54
+ "@libp2p/interface": "2.0.0-18dd3cb26",
55
+ "@libp2p/interface-internal": "2.0.0-18dd3cb26",
56
+ "@libp2p/peer-id": "5.0.0-18dd3cb26",
57
+ "@libp2p/utils": "6.0.0-18dd3cb26",
58
58
  "@multiformats/mafmt": "^12.1.6",
59
59
  "@multiformats/multiaddr": "^12.2.3",
60
60
  "@multiformats/multiaddr-matcher": "^1.2.1",
@@ -77,13 +77,13 @@
77
77
  "uint8arrays": "^5.1.0"
78
78
  },
79
79
  "devDependencies": {
80
- "@chainsafe/libp2p-yamux": "^6.0.2",
81
- "@libp2p/circuit-relay-v2": "^2.0.0",
82
- "@libp2p/crypto": "^5.0.0",
83
- "@libp2p/identify": "^3.0.0",
84
- "@libp2p/interface-compliance-tests": "^6.0.0",
85
- "@libp2p/logger": "^5.0.0",
86
- "@libp2p/websockets": "^9.0.0",
80
+ "@chainsafe/libp2p-yamux": "^7.0.0",
81
+ "@libp2p/circuit-relay-v2": "2.0.0-18dd3cb26",
82
+ "@libp2p/crypto": "5.0.0-18dd3cb26",
83
+ "@libp2p/identify": "3.0.0-18dd3cb26",
84
+ "@libp2p/interface-compliance-tests": "6.0.0-18dd3cb26",
85
+ "@libp2p/logger": "5.0.0-18dd3cb26",
86
+ "@libp2p/websockets": "9.0.0-18dd3cb26",
87
87
  "@types/sinon": "^17.0.3",
88
88
  "aegir": "^44.0.1",
89
89
  "delay": "^6.0.0",
@@ -93,7 +93,7 @@
93
93
  "it-pair": "^2.0.6",
94
94
  "it-pipe": "^3.0.1",
95
95
  "it-to-buffer": "^4.0.7",
96
- "libp2p": "^2.0.0",
96
+ "libp2p": "2.0.1-18dd3cb26",
97
97
  "p-retry": "^6.2.0",
98
98
  "protons": "^7.5.0",
99
99
  "sinon": "^18.0.0",
@@ -1,8 +0,0 @@
1
- {
2
- "DataChannelOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_webrtc.DataChannelOptions.html",
3
- ".:DataChannelOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_webrtc.DataChannelOptions.html",
4
- "webRTC": "https://libp2p.github.io/js-libp2p/functions/_libp2p_webrtc.webRTC.html",
5
- ".:webRTC": "https://libp2p.github.io/js-libp2p/functions/_libp2p_webrtc.webRTC.html",
6
- "webRTCDirect": "https://libp2p.github.io/js-libp2p/functions/_libp2p_webrtc.webRTCDirect.html",
7
- ".:webRTCDirect": "https://libp2p.github.io/js-libp2p/functions/_libp2p_webrtc.webRTCDirect.html"
8
- }