@libp2p/webrtc 5.2.11 → 5.2.12
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
@@ -47,7 +47,7 @@ a=end-of-candidates
|
|
47
47
|
`:`
|
48
48
|
`;return r.sdp=r.sdp.replace(/\na=ice-ufrag:[^\n]*\n/,`
|
49
49
|
a=ice-ufrag:`+e+t).replace(/\na=ice-pwd:[^\n]*\n/,`
|
50
|
-
a=ice-pwd:`+e+t),r}var Jy=de("libp2p-webrtc-noise:");function z1(r,e,t){let n=r.trim().toLowerCase().replaceAll(":",""),o=de(n,"hex"),i=At(tr.code,o),s=Xy.decode(Yy(e)),a=Jy.byteLength+i.bytes.byteLength+s.byteLength;return t==="server"?st([Jy,s,i.bytes],a):st([Jy,i.bytes,s],a)}var sI=ja?"iceconnectionstatechange":"connectionstatechange";async function X1(r,e,t){let n=r.createDataChannel("",{negotiated:!0,id:0});try{if(t.role==="client"){t.log.trace("client creating local offer");let p=await r.createOffer();t.log.trace("client created local offer %s",p.sdp);let y=Zy(p,e);t.log.trace("client setting local offer %s",y.sdp),await r.setLocalDescription(y);let w=W1(t.remoteAddr,e);t.log.trace("client setting server description %s",w.sdp),await r.setRemoteDescription(w)}else{let p=q1(t.remoteAddr,e);t.log.trace("server setting client %s %s",p.type,p.sdp),await r.setRemoteDescription(p),t.log.trace("server creating local answer");let y=await r.createAnswer();t.log.trace("server created local answer");let w=Zy(y,e);t.log.trace("server setting local description %s",y.sdp),await r.setLocalDescription(w)}if(n.readyState!=="open"&&(t.log.trace("%s wait for handshake channel to open, starting status %s",t.role,n.readyState),await Va(n,"open",t.signal)),t.log.trace("%s handshake channel opened",t.role),t.role==="server"){let p=r.remoteFingerprint()?.value??"";t.remoteAddr=t.remoteAddr.encapsulate(F1(p))}let o=$1(r.localDescription?.sdp);if(o==null)throw new Zn("Could not get fingerprint from local description sdp");t.log.trace("%s performing noise handshake",t.role);let i=z1(o,t.remoteAddr,t.role),s=V1({prologueBytes:i})(t),a=cs({channel:n,direction:"outbound",handshake:!0,logger:t.logger,...t.dataChannel??{}}),c=new Ko(t,{peerConnection:r,remoteAddr:t.remoteAddr,timeline:{open:Date.now()},metrics:t.events});r.addEventListener(sI,()=>{switch(r.connectionState){case"failed":case"disconnected":case"closed":c.close().catch(p=>{t.log.error("error closing connection",p),c.abort(p)});break;default:break}}),t.events?.increment({peer_connection:!0});let u=new Yn(t,{peerConnection:r,metrics:t.events,dataChannelOptions:t.dataChannel});if(t.role==="client")return t.log.trace("%s secure inbound",t.role),await s.secureInbound(a,{remotePeer:t.remotePeerId,signal:t.signal}),t.log.trace("%s upgrade outbound",t.role),await t.upgrader.upgradeOutbound(c,{skipProtection:!0,skipEncryption:!0,muxerFactory:u,signal:t.signal});t.log.trace("%s secure outbound",t.role);let h=await s.secureOutbound(a,{remotePeer:t.remotePeerId,signal:t.signal});c.remoteAddr=c.remoteAddr.encapsulate(`/p2p/${h.remotePeer}`),t.log.trace("%s upgrade inbound",t.role),await t.upgrader.upgradeInbound(c,{skipProtection:!0,skipEncryption:!0,muxerFactory:u,signal:t.signal})}catch(o){throw n.close(),o}}async function Y1(r,e,t,n){n==null&&(n=await RTCPeerConnection.generateCertificate({name:"ECDSA",namedCurve:"P-256"}));let o=typeof t=="function"?await t():t;return new RTCPeerConnection({...o??{},certificates:[n]})}async function Z1(r){let e=await Yl(r),t=await crypto.subtle.exportKey("pkcs8",e.privateKey);return["-----BEGIN PRIVATE KEY-----",...ce(new Uint8Array(t),"base64pad").split(/(.{64})/).filter(Boolean),"-----END PRIVATE KEY-----"].join(`
|
50
|
+
a=ice-pwd:`+e+t),r}var Jy=de("libp2p-webrtc-noise:");function z1(r,e,t){let n=r.trim().toLowerCase().replaceAll(":",""),o=de(n,"hex"),i=At(tr.code,o),s=Xy.decode(Yy(e)),a=Jy.byteLength+i.bytes.byteLength+s.byteLength;return t==="server"?st([Jy,s,i.bytes],a):st([Jy,i.bytes,s],a)}var sI=ja?"iceconnectionstatechange":"connectionstatechange";async function X1(r,e,t){let n=r.createDataChannel("",{negotiated:!0,id:0});try{if(t.role==="client"){t.log.trace("client creating local offer");let p=await r.createOffer();t.log.trace("client created local offer %s",p.sdp);let y=Zy(p,e);t.log.trace("client setting local offer %s",y.sdp),await r.setLocalDescription(y);let w=W1(t.remoteAddr,e);t.log.trace("client setting server description %s",w.sdp),await r.setRemoteDescription(w)}else{let p=q1(t.remoteAddr,e);t.log.trace("server setting client %s %s",p.type,p.sdp),await r.setRemoteDescription(p),t.log.trace("server creating local answer");let y=await r.createAnswer();t.log.trace("server created local answer");let w=Zy(y,e);t.log.trace("server setting local description %s",y.sdp),await r.setLocalDescription(w)}if(n.readyState!=="open"&&(t.log.trace("%s wait for handshake channel to open, starting status %s",t.role,n.readyState),await Va(n,"open",t.signal)),t.log.trace("%s handshake channel opened",t.role),t.role==="server"){let p=r.remoteFingerprint()?.value??"";t.remoteAddr=t.remoteAddr.encapsulate(F1(p))}let o=$1(r.localDescription?.sdp);if(o==null)throw new Zn("Could not get fingerprint from local description sdp");t.log.trace("%s performing noise handshake",t.role);let i=z1(o,t.remoteAddr,t.role),s=V1({prologueBytes:i})(t),a=cs({channel:n,direction:"outbound",handshake:!0,logger:t.logger,...t.dataChannel??{}}),c=new Ko(t,{peerConnection:r,remoteAddr:t.remoteAddr,timeline:{open:Date.now()},metrics:t.events});r.addEventListener(sI,()=>{switch(r.connectionState){case"failed":case"disconnected":case"closed":c.close().catch(p=>{t.log.error("error closing connection",p),c.abort(p)});break;default:break}}),t.events?.increment({peer_connection:!0});let u=new Yn(t,{peerConnection:r,metrics:t.events,dataChannelOptions:t.dataChannel});if(t.role==="client")return t.log.trace("%s secure inbound",t.role),await s.secureInbound(a,{remotePeer:t.remotePeerId,signal:t.signal,skipStreamMuxerNegotiation:!0}),t.log.trace("%s upgrade outbound",t.role),await t.upgrader.upgradeOutbound(c,{skipProtection:!0,skipEncryption:!0,muxerFactory:u,signal:t.signal});t.log.trace("%s secure outbound",t.role);let h=await s.secureOutbound(a,{remotePeer:t.remotePeerId,signal:t.signal,skipStreamMuxerNegotiation:!0});c.remoteAddr=c.remoteAddr.encapsulate(`/p2p/${h.remotePeer}`),t.log.trace("%s upgrade inbound",t.role),await t.upgrader.upgradeInbound(c,{skipProtection:!0,skipEncryption:!0,muxerFactory:u,signal:t.signal})}catch(o){throw n.close(),o}}async function Y1(r,e,t,n){n==null&&(n=await RTCPeerConnection.generateCertificate({name:"ECDSA",namedCurve:"P-256"}));let o=typeof t=="function"?await t():t;return new RTCPeerConnection({...o??{},certificates:[n]})}async function Z1(r){let e=await Yl(r),t=await crypto.subtle.exportKey("pkcs8",e.privateKey);return["-----BEGIN PRIVATE KEY-----",...ce(new Uint8Array(t),"base64pad").split(/(.{64})/).filter(Boolean),"-----END PRIVATE KEY-----"].join(`
|
51
51
|
`)}var wp=class{log;metrics;components;init;certificate;privateKey;emitter;renewCertificateTask;constructor(e,t={}){if(this.log=e.logger.forComponent("libp2p:webrtc-direct"),this.components=e,this.init=t,this.emitter=new Ln,t.certificateLifespan!=null&&t.certificateRenewalThreshold!=null&&t.certificateRenewalThreshold>=t.certificateLifespan)throw new ve("Certificate renewal threshold must be less than certificate lifespan");e.metrics!=null&&(this.metrics={dialerEvents:e.metrics.registerCounterGroup("libp2p_webrtc-direct_dialer_events_total",{label:"event",help:"Total count of WebRTC-direct dial events by type"})})}[gl]=!0;[Symbol.toStringTag]="@libp2p/webrtc-direct";[Hi]=["@libp2p/transport"];async start(){this.certificate=await this.getCertificate()}async stop(){this.renewCertificateTask!=null&&clearTimeout(this.renewCertificateTask),this.certificate=void 0}async dial(e,t){this.log("dial %a",e),t.signal.throwIfAborted();let n,o=e.getPeerId();o!=null&&(n=es(o));let i=Dw(),s=await Y1("client",i,typeof this.init.rtcConfiguration=="function"?await this.init.rtcConfiguration():this.init.rtcConfiguration??{});try{return await X1(s,i,{role:"client",log:this.log,logger:this.components.logger,metrics:this.components.metrics,events:this.metrics?.dialerEvents,signal:t.signal,remoteAddr:e,dataChannel:this.init.dataChannel,upgrader:t.upgrader,peerId:this.components.peerId,remotePeerId:n,privateKey:this.components.privateKey})}catch(a){throw s.close(),a}}createListener(e){if(this.certificate==null)throw new Cl;return new ip(this.components,{...this.init,...e,certificate:this.certificate,emitter:this.emitter})}listenFilter(e){return e.filter(fw.exactMatch)}dialFilter(e){return this.listenFilter(e)}async getCertificate(e){if(aI(this.init.certificate))return this.log("using provided TLS certificate"),this.init.certificate;let t=await this.loadOrCreatePrivateKey(),{pem:n,certhash:o}=await this.loadOrCreateCertificate(t,e);return{privateKey:await Z1(t),pem:n,certhash:o}}async loadOrCreatePrivateKey(){if(this.privateKey!=null)return this.privateKey;let e=this.init.certificateKeychainName??_w,t=this.getKeychain();try{if(t==null)throw this.log("no keychain configured - not checking for stored private key"),new _o;this.log.trace("checking for stored private key"),this.privateKey=await t.exportKey(e)}catch(n){if(n.name!=="NotFoundError")throw n;this.log.trace("generating private key"),this.privateKey=await $0("ECDSA","P-256"),t!=null?(this.log.trace("storing private key"),await t.importKey(e,this.privateKey)):this.log("no keychain configured - not storing private key")}return this.privateKey}async loadOrCreateCertificate(e,t){if(this.certificate!=null&&t!==!0)return this.certificate;let n,o=new il(this.init.certificateDatastoreKey??Ew),i=await Yl(e);try{if(t===!0)throw this.log.trace("forcing renewal of TLS certificate"),new _o;this.log.trace("checking for stored TLS certificate"),n=await this.loadCertificate(o,i)}catch(a){if(a.name!=="NotFoundError")throw a;this.log.trace("generating new TLS certificate"),n=await this.createCertificate(o,i)}let s=n.notAfter.getTime()-(this.init.certificateRenewalThreshold??vd)-Date.now();return s<0&&(s=100),this.log("will renew TLS certificate after %d ms",s),this.renewCertificateTask=setTimeout(()=>{this.log("renewing TLS certificate"),this.getCertificate(!0).then(a=>{this.certificate=a,this.emitter.safeDispatchEvent("certificate:renew",{detail:a})}).catch(a=>{this.log.error("could not renew certificate - %e",a)})},s),{pem:n.toString("pem"),certhash:Io.encode((await tr.digest(new Uint8Array(n.rawData))).bytes)}}async loadCertificate(e,t){let n=await this.components.datastore.get(e),o=new zs(n),i=o.notAfter.getTime()-(this.init.certificateRenewalThreshold??vd);if(Date.now()>i)throw this.log("stored TLS certificate has expired"),new _o;this.log("loaded certificate, expires in %d ms",i);let s=await o.publicKey.export(crypto),a=await crypto.subtle.exportKey("raw",s),c=await crypto.subtle.exportKey("raw",t.publicKey);if(!qe(new Uint8Array(a,0,a.byteLength),new Uint8Array(c,0,c.byteLength)))throw this.log("stored TLS certificate public key did not match public key from private key"),new _o;return this.log("loaded certificate, expiry time is %o",i),o}async createCertificate(e,t){let n=new Date,o=new Date(Date.now()+(this.init.certificateLifespan??Cw));n.setMilliseconds(0),o.setMilliseconds(0);let i=await np.createSelfSigned({serialNumber:(BigInt(Math.random().toString().replace(".",""))*100000n).toString(16),name:"CN=example.com, C=US, L=CA, O=example, ST=CA",notBefore:n,notAfter:o,keys:t,extensions:[new Ws(!1,void 0,!0)]},crypto);return this.getKeychain()!=null?(this.log.trace("storing TLS certificate"),await this.components.datastore.put(e,de(i.toString("pem")))):this.log("no keychain is configured so not storing TLS certificate since the private key will not be reused"),i}getKeychain(){try{return this.components.keychain}catch{}}};function aI(r){return r==null?!1:typeof r.privateKey=="string"&&typeof r.pem=="string"&&typeof r.certhash=="string"}function cI(r){return e=>new wp(e,r)}function lI(r){return e=>new Ru(e,r)}return pA(uI);})();
|
52
52
|
/*! Bundled license information:
|
53
53
|
|
@@ -116,7 +116,8 @@ export async function connect(peerConnection, ufrag, options) {
|
|
116
116
|
options.log.trace('%s secure inbound', options.role);
|
117
117
|
await connectionEncrypter.secureInbound(handshakeStream, {
|
118
118
|
remotePeer: options.remotePeerId,
|
119
|
-
signal: options.signal
|
119
|
+
signal: options.signal,
|
120
|
+
skipStreamMuxerNegotiation: true
|
120
121
|
});
|
121
122
|
options.log.trace('%s upgrade outbound', options.role);
|
122
123
|
return await options.upgrader.upgradeOutbound(maConn, {
|
@@ -132,7 +133,8 @@ export async function connect(peerConnection, ufrag, options) {
|
|
132
133
|
options.log.trace('%s secure outbound', options.role);
|
133
134
|
const result = await connectionEncrypter.secureOutbound(handshakeStream, {
|
134
135
|
remotePeer: options.remotePeerId,
|
135
|
-
signal: options.signal
|
136
|
+
signal: options.signal,
|
137
|
+
skipStreamMuxerNegotiation: true
|
136
138
|
});
|
137
139
|
maConn.remoteAddr = maConn.remoteAddr.encapsulate(`/p2p/${result.remotePeer}`);
|
138
140
|
options.log.trace('%s upgrade inbound', options.role);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"connect.js","sourceRoot":"","sources":["../../../../src/private-to-public/utils/connect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAA;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AA6B/B,MAAM,6BAA6B,GAAG,SAAS,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,uBAAuB,CAAA;AAItG,MAAM,CAAC,KAAK,UAAU,OAAO,CAAE,cAAuC,EAAE,KAAa,EAAE,OAAuB;IAC5G,qEAAqE;IACrE,0EAA0E;IAC1E,+CAA+C;IAC/C,MAAM,oBAAoB,GAAG,cAAc,CAAC,iBAAiB,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAA;IA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,IAAI;gBACpB,YAAY;gBACZ,MAAM,EAAE,OAAO,CAAC,MAAM;aACvB,CAAC,CAAA;QACJ,CAAC;QAED,yEAAyE;QACzE,4EAA4E;QAC5E,cAAc;QACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,oBAAoB,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;QACrD,MAAM,MAAM,GAAG,MAAM,mBAAmB,CAAC,cAAc,CAAC,eAAe,EAAE;YACvE,UAAU,EAAE,OAAO,CAAC,YAAY;YAChC,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,0BAA0B,EAAE,IAAI;SACjC,CAAC,CAAA;QAEF,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,QAAQ,MAAM,CAAC,UAAU,EAAE,CAAC,CAAA;QAE9E,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,oBAAoB,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;QAErD,MAAM,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAM,EAAE;YAC5C,cAAc,EAAE,IAAI;YACpB,cAAc,EAAE,IAAI;YACpB,YAAY;YACZ,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAA;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,oBAAoB,CAAC,KAAK,EAAE,CAAA;QAE5B,MAAM,GAAG,CAAA;IACX,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@libp2p/webrtc",
|
3
|
-
"version": "5.2.
|
3
|
+
"version": "5.2.12",
|
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",
|
@@ -86,7 +86,7 @@
|
|
86
86
|
"uint8arrays": "^5.1.0"
|
87
87
|
},
|
88
88
|
"devDependencies": {
|
89
|
-
"@libp2p/interface-compliance-tests": "^6.4.
|
89
|
+
"@libp2p/interface-compliance-tests": "^6.4.5",
|
90
90
|
"@libp2p/logger": "^5.1.15",
|
91
91
|
"@types/sinon": "^17.0.3",
|
92
92
|
"aegir": "^45.1.1",
|
@@ -163,7 +163,8 @@ export async function connect (peerConnection: DirectRTCPeerConnection, ufrag: s
|
|
163
163
|
options.log.trace('%s secure inbound', options.role)
|
164
164
|
await connectionEncrypter.secureInbound(handshakeStream, {
|
165
165
|
remotePeer: options.remotePeerId,
|
166
|
-
signal: options.signal
|
166
|
+
signal: options.signal,
|
167
|
+
skipStreamMuxerNegotiation: true
|
167
168
|
})
|
168
169
|
|
169
170
|
options.log.trace('%s upgrade outbound', options.role)
|
@@ -181,7 +182,8 @@ export async function connect (peerConnection: DirectRTCPeerConnection, ufrag: s
|
|
181
182
|
options.log.trace('%s secure outbound', options.role)
|
182
183
|
const result = await connectionEncrypter.secureOutbound(handshakeStream, {
|
183
184
|
remotePeer: options.remotePeerId,
|
184
|
-
signal: options.signal
|
185
|
+
signal: options.signal,
|
186
|
+
skipStreamMuxerNegotiation: true
|
185
187
|
})
|
186
188
|
|
187
189
|
maConn.remoteAddr = maConn.remoteAddr.encapsulate(`/p2p/${result.remotePeer}`)
|