@libp2p/webrtc 6.0.16-f60bd85b0 → 6.0.18
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 +12 -15
- package/dist/index.min.js.map +4 -4
- package/dist/src/constants.js +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.js +2 -2
- package/dist/src/muxer.d.ts +2 -2
- package/dist/src/muxer.js +2 -2
- package/dist/src/private-to-private/initiate-connection.d.ts +1 -1
- package/dist/src/private-to-private/initiate-connection.js +3 -3
- package/dist/src/private-to-private/signaling-stream-handler.js +2 -2
- package/dist/src/private-to-private/transport.js +3 -3
- package/dist/src/private-to-private/util.d.ts +2 -2
- package/dist/src/private-to-private/util.js +1 -1
- package/dist/src/private-to-public/listener.d.ts +1 -1
- package/dist/src/private-to-public/listener.js +3 -3
- package/dist/src/private-to-public/transport.browser.js +2 -2
- package/dist/src/private-to-public/transport.d.ts +1 -1
- package/dist/src/private-to-public/transport.js +3 -3
- package/dist/src/private-to-public/utils/connect.d.ts +1 -1
- package/dist/src/private-to-public/utils/connect.js +2 -2
- package/dist/src/private-to-public/utils/generate-noise-prologue.js +1 -1
- package/dist/src/private-to-public/utils/get-rtcpeerconnection.js +1 -1
- package/dist/src/stream.d.ts +1 -1
- package/dist/src/stream.js +3 -3
- package/dist/src/util.js +1 -1
- package/dist/typedoc-urls.json +14 -0
- package/package.json +10 -9
- package/src/constants.ts +1 -1
- package/src/index.ts +4 -4
- package/src/muxer.ts +3 -3
- package/src/private-to-private/initiate-connection.ts +4 -4
- package/src/private-to-private/signaling-stream-handler.ts +2 -2
- package/src/private-to-private/transport.ts +3 -3
- package/src/private-to-private/util.ts +2 -2
- package/src/private-to-public/listener.ts +6 -6
- package/src/private-to-public/transport.browser.ts +2 -2
- package/src/private-to-public/transport.ts +3 -3
- package/src/private-to-public/utils/connect.ts +3 -3
- package/src/private-to-public/utils/generate-noise-prologue.ts +1 -1
- package/src/private-to-public/utils/get-rtcpeerconnection.ts +1 -1
- package/src/stream.ts +4 -4
- package/src/util.ts +1 -1
package/dist/src/constants.js
CHANGED
package/dist/src/index.d.ts
CHANGED
|
@@ -251,8 +251,8 @@
|
|
|
251
251
|
* // /ip4/...../udp/../webrtc-direct/certhash/foo
|
|
252
252
|
* ```
|
|
253
253
|
*/
|
|
254
|
-
import type { WebRTCTransportComponents, WebRTCTransportInit } from './private-to-private/transport.
|
|
255
|
-
import type { WebRTCTransportDirectInit, WebRTCDirectTransportComponents } from './private-to-public/transport.
|
|
254
|
+
import type { WebRTCTransportComponents, WebRTCTransportInit } from './private-to-private/transport.ts';
|
|
255
|
+
import type { WebRTCTransportDirectInit, WebRTCDirectTransportComponents } from './private-to-public/transport.ts';
|
|
256
256
|
import type { Transport } from '@libp2p/interface';
|
|
257
257
|
export interface DataChannelOptions {
|
|
258
258
|
/**
|
package/dist/src/index.js
CHANGED
|
@@ -251,8 +251,8 @@
|
|
|
251
251
|
* // /ip4/...../udp/../webrtc-direct/certhash/foo
|
|
252
252
|
* ```
|
|
253
253
|
*/
|
|
254
|
-
import { WebRTCTransport } from
|
|
255
|
-
import { WebRTCDirectTransport } from
|
|
254
|
+
import { WebRTCTransport } from "./private-to-private/transport.js";
|
|
255
|
+
import { WebRTCDirectTransport } from "./private-to-public/transport.js";
|
|
256
256
|
function webRTCDirect(init) {
|
|
257
257
|
return (components) => new WebRTCDirectTransport(components, init);
|
|
258
258
|
}
|
package/dist/src/muxer.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractStreamMuxer } from '@libp2p/utils';
|
|
2
|
-
import { WebRTCStream } from './stream.
|
|
3
|
-
import type { DataChannelOptions } from './index.
|
|
2
|
+
import { WebRTCStream } from './stream.ts';
|
|
3
|
+
import type { DataChannelOptions } from './index.ts';
|
|
4
4
|
import type { ComponentLogger, CounterGroup, StreamMuxer, StreamMuxerFactory, CreateStreamOptions, MultiaddrConnection } from '@libp2p/interface';
|
|
5
5
|
export interface DataChannelMuxerFactoryInit {
|
|
6
6
|
/**
|
package/dist/src/muxer.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractStreamMuxer } from '@libp2p/utils';
|
|
2
|
-
import { MUXER_PROTOCOL } from
|
|
3
|
-
import { createStream, WebRTCStream } from
|
|
2
|
+
import { MUXER_PROTOCOL } from "./constants.js";
|
|
3
|
+
import { createStream, WebRTCStream } from "./stream.js";
|
|
4
4
|
export class DataChannelMuxerFactory {
|
|
5
5
|
protocol;
|
|
6
6
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DataChannelMuxerFactory } from '../muxer.js';
|
|
2
|
-
import type { WebRTCDialEvents, WebRTCTransportMetrics } from './transport.
|
|
2
|
+
import type { WebRTCDialEvents, WebRTCTransportMetrics } from './transport.ts';
|
|
3
3
|
import type { DataChannelOptions } from '../index.js';
|
|
4
4
|
import type { LoggerOptions, ComponentLogger, AbortOptions } from '@libp2p/interface';
|
|
5
5
|
import type { ConnectionManager, TransportManager } from '@libp2p/interface-internal';
|
|
@@ -5,9 +5,9 @@ import { SIGNALING_PROTOCOL } from '../constants.js';
|
|
|
5
5
|
import { SDPHandshakeFailedError } from '../error.js';
|
|
6
6
|
import { DataChannelMuxerFactory } from '../muxer.js';
|
|
7
7
|
import { RTCPeerConnection, RTCSessionDescription } from '../webrtc/index.js';
|
|
8
|
-
import { Message } from
|
|
9
|
-
import { splitAddr } from
|
|
10
|
-
import { readCandidatesUntilConnected } from
|
|
8
|
+
import { Message } from "./pb/message.js";
|
|
9
|
+
import { splitAddr } from "./transport.js";
|
|
10
|
+
import { readCandidatesUntilConnected } from "./util.js";
|
|
11
11
|
export async function initiateConnection({ rtcConfiguration, dataChannel, signal, metrics, multiaddr: ma, connectionManager, transportManager, log, logger, onProgress }) {
|
|
12
12
|
const { circuitAddress, targetPeer } = splitAddr(ma);
|
|
13
13
|
metrics?.dialerEvents.increment({ open: true });
|
|
@@ -2,8 +2,8 @@ import { pbStream } from '@libp2p/utils';
|
|
|
2
2
|
import { multiaddr } from '@multiformats/multiaddr';
|
|
3
3
|
import { SDPHandshakeFailedError } from '../error.js';
|
|
4
4
|
import { RTCSessionDescription } from '../webrtc/index.js';
|
|
5
|
-
import { Message } from
|
|
6
|
-
import { getRemotePeer, readCandidatesUntilConnected } from
|
|
5
|
+
import { Message } from "./pb/message.js";
|
|
6
|
+
import { getRemotePeer, readCandidatesUntilConnected } from "./util.js";
|
|
7
7
|
export async function handleIncomingStream(stream, connection, { peerConnection, signal, log }) {
|
|
8
8
|
log.trace('new inbound signaling stream');
|
|
9
9
|
const messageStream = pbStream(stream).pb(Message);
|
|
@@ -8,9 +8,9 @@ import { DataChannelMuxerFactory } from '../muxer.js';
|
|
|
8
8
|
import { toMultiaddrConnection } from "../rtcpeerconnection-to-conn.js";
|
|
9
9
|
import { getRtcConfiguration } from '../util.js';
|
|
10
10
|
import { RTCPeerConnection } from '../webrtc/index.js';
|
|
11
|
-
import { initiateConnection } from
|
|
12
|
-
import { WebRTCPeerListener } from
|
|
13
|
-
import { handleIncomingStream } from
|
|
11
|
+
import { initiateConnection } from "./initiate-connection.js";
|
|
12
|
+
import { WebRTCPeerListener } from "./listener.js";
|
|
13
|
+
import { handleIncomingStream } from "./signaling-stream-handler.js";
|
|
14
14
|
import { getRemotePeer } from "./util.js";
|
|
15
15
|
export class WebRTCTransport {
|
|
16
16
|
components;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Message } from './pb/message.
|
|
2
|
-
import type { WebRTCDialEvents } from './transport.
|
|
1
|
+
import { Message } from './pb/message.ts';
|
|
2
|
+
import type { WebRTCDialEvents } from './transport.ts';
|
|
3
3
|
import type { RTCPeerConnection } from '../webrtc/index.js';
|
|
4
4
|
import type { AbortOptions, LoggerOptions, PeerId, Stream } from '@libp2p/interface';
|
|
5
5
|
import type { Multiaddr } from '@multiformats/multiaddr';
|
|
@@ -2,7 +2,7 @@ import { ConnectionFailedError, InvalidMessageError, InvalidMultiaddrError } fro
|
|
|
2
2
|
import { peerIdFromString } from '@libp2p/peer-id';
|
|
3
3
|
import { CustomProgressEvent } from 'progress-events';
|
|
4
4
|
import { RTCIceCandidate } from '../webrtc/index.js';
|
|
5
|
-
import { Message } from
|
|
5
|
+
import { Message } from "./pb/message.js";
|
|
6
6
|
export const readCandidatesUntilConnected = async (pc, stream, options) => {
|
|
7
7
|
try {
|
|
8
8
|
const connectedPromise = Promise.withResolvers();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TypedEventEmitter } from 'main-event';
|
|
2
2
|
import type { DataChannelOptions, TransportCertificate } from '../index.js';
|
|
3
|
-
import type { WebRTCDirectTransportCertificateEvents } from './transport.
|
|
3
|
+
import type { WebRTCDirectTransportCertificateEvents } from './transport.ts';
|
|
4
4
|
import type { PeerId, ListenerEvents, Listener, Upgrader, ComponentLogger, CounterGroup, Metrics, PrivateKey } from '@libp2p/interface';
|
|
5
5
|
import type { Keychain } from '@libp2p/keychain';
|
|
6
6
|
import type { Multiaddr } from '@multiformats/multiaddr';
|
|
@@ -6,9 +6,9 @@ import { WebRTCDirect } from '@multiformats/multiaddr-matcher';
|
|
|
6
6
|
import getPort from 'get-port';
|
|
7
7
|
import { TypedEventEmitter, setMaxListeners } from 'main-event';
|
|
8
8
|
import pWaitFor from 'p-wait-for';
|
|
9
|
-
import { connect } from
|
|
10
|
-
import { createDialerRTCPeerConnection } from
|
|
11
|
-
import { stunListener } from
|
|
9
|
+
import { connect } from "./utils/connect.js";
|
|
10
|
+
import { createDialerRTCPeerConnection } from "./utils/get-rtcpeerconnection.js";
|
|
11
|
+
import { stunListener } from "./utils/stun-listener.js";
|
|
12
12
|
let UDP_MUX_LISTENERS = [];
|
|
13
13
|
export class WebRTCDirectListener extends TypedEventEmitter {
|
|
14
14
|
listeningMultiaddr;
|
|
@@ -4,8 +4,8 @@ import { CODE_P2P } from '@multiformats/multiaddr';
|
|
|
4
4
|
import { WebRTCDirect } from '@multiformats/multiaddr-matcher';
|
|
5
5
|
import { UnimplementedError } from "../error.js";
|
|
6
6
|
import { genUfrag } from '../util.js';
|
|
7
|
-
import { connect } from
|
|
8
|
-
import { createDialerRTCPeerConnection } from
|
|
7
|
+
import { connect } from "./utils/connect.js";
|
|
8
|
+
import { createDialerRTCPeerConnection } from "./utils/get-rtcpeerconnection.js";
|
|
9
9
|
export class WebRTCDirectTransport {
|
|
10
10
|
log;
|
|
11
11
|
metrics;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { X509Certificate } from '@peculiar/x509';
|
|
3
3
|
import { Key } from 'interface-datastore';
|
|
4
|
-
import { WebRTCDirectTransport as WebRTCDirectBrowserTransport } from './transport.browser.
|
|
4
|
+
import { WebRTCDirectTransport as WebRTCDirectBrowserTransport } from './transport.browser.ts';
|
|
5
5
|
import type { TransportCertificate } from '../index.js';
|
|
6
6
|
import type { WebRTCTransportDirectInit as WebRTCTransportDirectBrowserInit, WebRTCMetrics, WebRTCDirectTransportComponents } from './transport.browser.ts';
|
|
7
7
|
import type { CreateListenerOptions, Transport, Listener, Startable } from '@libp2p/interface';
|
|
@@ -10,9 +10,9 @@ import { sha256 } from 'multiformats/hashes/sha2';
|
|
|
10
10
|
import { equals as uint8ArrayEquals } from 'uint8arrays/equals';
|
|
11
11
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
|
|
12
12
|
import { DEFAULT_CERTIFICATE_DATASTORE_KEY, DEFAULT_CERTIFICATE_LIFESPAN, DEFAULT_CERTIFICATE_PRIVATE_KEY_NAME, DEFAULT_CERTIFICATE_RENEWAL_THRESHOLD } from '../constants.js';
|
|
13
|
-
import { WebRTCDirectListener } from
|
|
14
|
-
import { WebRTCDirectTransport as WebRTCDirectBrowserTransport } from
|
|
15
|
-
import { formatAsPem } from
|
|
13
|
+
import { WebRTCDirectListener } from "./listener.js";
|
|
14
|
+
import { WebRTCDirectTransport as WebRTCDirectBrowserTransport } from "./transport.browser.js";
|
|
15
|
+
import { formatAsPem } from "./utils/pem.js";
|
|
16
16
|
export class WebRTCDirectTransport extends WebRTCDirectBrowserTransport {
|
|
17
17
|
certificate;
|
|
18
18
|
privateKey;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DataChannelMuxerFactory } from '../../muxer.js';
|
|
2
|
-
import type { DirectRTCPeerConnection } from './get-rtcpeerconnection.
|
|
2
|
+
import type { DirectRTCPeerConnection } from './get-rtcpeerconnection.ts';
|
|
3
3
|
import type { DataChannelOptions } from '../../index.js';
|
|
4
4
|
import type { ComponentLogger, Connection, CounterGroup, Logger, PeerId, PrivateKey, Upgrader } from '@libp2p/interface';
|
|
5
5
|
import type { Multiaddr } from '@multiformats/multiaddr';
|
|
@@ -5,8 +5,8 @@ import { DataChannelMuxerFactory } from '../../muxer.js';
|
|
|
5
5
|
import { toMultiaddrConnection } from "../../rtcpeerconnection-to-conn.js";
|
|
6
6
|
import { createStream } from '../../stream.js';
|
|
7
7
|
import { isFirefox } from '../../util.js';
|
|
8
|
-
import { generateNoisePrologue } from
|
|
9
|
-
import * as sdp from
|
|
8
|
+
import { generateNoisePrologue } from "./generate-noise-prologue.js";
|
|
9
|
+
import * as sdp from "./sdp.js";
|
|
10
10
|
const CONNECTION_STATE_CHANGE_EVENT = isFirefox ? 'iceconnectionstatechange' : 'connectionstatechange';
|
|
11
11
|
function isServer(options, peerConnection) {
|
|
12
12
|
return options.role === 'server';
|
|
@@ -2,7 +2,7 @@ import * as Digest from 'multiformats/hashes/digest';
|
|
|
2
2
|
import { sha256 } from 'multiformats/hashes/sha2';
|
|
3
3
|
import { concat } from 'uint8arrays/concat';
|
|
4
4
|
import { fromString as uint8arrayFromString } from 'uint8arrays/from-string';
|
|
5
|
-
import * as sdp from
|
|
5
|
+
import * as sdp from "./sdp.js";
|
|
6
6
|
const PREFIX = uint8arrayFromString('libp2p-webrtc-noise:');
|
|
7
7
|
/**
|
|
8
8
|
* Generate a noise prologue from the peer connection's certificate.
|
|
@@ -3,7 +3,7 @@ import { PeerConnection } from 'node-datachannel';
|
|
|
3
3
|
import { RTCPeerConnection } from 'node-datachannel/polyfill';
|
|
4
4
|
import { DEFAULT_ICE_SERVERS, MAX_MESSAGE_SIZE } from '../../constants.js';
|
|
5
5
|
import { DataChannelMuxerFactory } from "../../muxer.js";
|
|
6
|
-
import { generateTransportCertificate } from
|
|
6
|
+
import { generateTransportCertificate } from "./generate-certificates.js";
|
|
7
7
|
const crypto = new Crypto();
|
|
8
8
|
export class DirectRTCPeerConnection extends RTCPeerConnection {
|
|
9
9
|
peerConnection;
|
package/dist/src/stream.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractStream } from '@libp2p/utils';
|
|
2
2
|
import { Uint8ArrayList } from 'uint8arraylist';
|
|
3
|
-
import type { DataChannelOptions } from './index.
|
|
3
|
+
import type { DataChannelOptions } from './index.ts';
|
|
4
4
|
import type { AbortOptions, MessageStreamDirection, Logger } from '@libp2p/interface';
|
|
5
5
|
import type { AbstractStreamInit, SendResult } from '@libp2p/utils';
|
|
6
6
|
export interface WebRTCStreamInit extends AbstractStreamInit, DataChannelOptions {
|
package/dist/src/stream.js
CHANGED
|
@@ -5,9 +5,9 @@ import { pushable } from 'it-pushable';
|
|
|
5
5
|
import { pEvent } from 'p-event';
|
|
6
6
|
import { raceSignal } from 'race-signal';
|
|
7
7
|
import { Uint8ArrayList } from 'uint8arraylist';
|
|
8
|
-
import { DEFAULT_FIN_ACK_TIMEOUT, MAX_BUFFERED_AMOUNT, MAX_MESSAGE_SIZE, PROTOBUF_OVERHEAD } from
|
|
9
|
-
import { Message } from
|
|
10
|
-
import { isFirefox } from
|
|
8
|
+
import { DEFAULT_FIN_ACK_TIMEOUT, MAX_BUFFERED_AMOUNT, MAX_MESSAGE_SIZE, PROTOBUF_OVERHEAD } from "./constants.js";
|
|
9
|
+
import { Message } from "./private-to-public/pb/message.js";
|
|
10
|
+
import { isFirefox } from "./util.js";
|
|
11
11
|
export class WebRTCStream extends AbstractStream {
|
|
12
12
|
/**
|
|
13
13
|
* The data channel used to send and receive data
|
package/dist/src/util.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { detect } from 'detect-browser';
|
|
2
2
|
import pDefer from 'p-defer';
|
|
3
3
|
import pTimeout from 'p-timeout';
|
|
4
|
-
import { DATA_CHANNEL_DRAIN_TIMEOUT, DEFAULT_ICE_SERVERS, UFRAG_ALPHABET, UFRAG_PREFIX } from
|
|
4
|
+
import { DATA_CHANNEL_DRAIN_TIMEOUT, DEFAULT_ICE_SERVERS, UFRAG_ALPHABET, UFRAG_PREFIX } from "./constants.js";
|
|
5
5
|
const browser = detect();
|
|
6
6
|
export const isFirefox = ((browser != null) && browser.name === 'firefox');
|
|
7
7
|
export const nopSource = async function* nop() { };
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
"TransportCertificate": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_webrtc.TransportCertificate.html",
|
|
5
|
+
".:TransportCertificate": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_webrtc.TransportCertificate.html",
|
|
6
|
+
"WebRTCDirectTransportComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_webrtc.WebRTCDirectTransportComponents.html",
|
|
7
|
+
"WebRTCTransportComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_webrtc.WebRTCTransportComponents.html",
|
|
8
|
+
"WebRTCTransportDirectInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_webrtc.WebRTCTransportDirectInit.html",
|
|
9
|
+
"WebRTCTransportInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_webrtc.WebRTCTransportInit.html",
|
|
10
|
+
"webRTC": "https://libp2p.github.io/js-libp2p/functions/_libp2p_webrtc.webRTC.html",
|
|
11
|
+
".:webRTC": "https://libp2p.github.io/js-libp2p/functions/_libp2p_webrtc.webRTC.html",
|
|
12
|
+
"webRTCDirect": "https://libp2p.github.io/js-libp2p/functions/_libp2p_webrtc.webRTCDirect.html",
|
|
13
|
+
".:webRTCDirect": "https://libp2p.github.io/js-libp2p/functions/_libp2p_webrtc.webRTCDirect.html"
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/webrtc",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.18",
|
|
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",
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
"exports": {
|
|
27
27
|
".": {
|
|
28
28
|
"types": "./dist/src/index.d.ts",
|
|
29
|
-
"import": "./dist/src/index.js"
|
|
29
|
+
"import": "./dist/src/index.js",
|
|
30
|
+
"module-sync": "./dist/src/index.js"
|
|
30
31
|
}
|
|
31
32
|
},
|
|
32
33
|
"scripts": {
|
|
@@ -45,13 +46,13 @@
|
|
|
45
46
|
},
|
|
46
47
|
"dependencies": {
|
|
47
48
|
"@chainsafe/is-ip": "^2.1.0",
|
|
48
|
-
"@libp2p/crypto": "5.1.15-f60bd85b0",
|
|
49
|
-
"@libp2p/interface": "3.2.0-f60bd85b0",
|
|
50
|
-
"@libp2p/interface-internal": "3.1.0-f60bd85b0",
|
|
51
|
-
"@libp2p/keychain": "6.0.12-f60bd85b0",
|
|
52
49
|
"@chainsafe/libp2p-noise": "^17.0.0",
|
|
53
|
-
"@libp2p/
|
|
54
|
-
"@libp2p/
|
|
50
|
+
"@libp2p/crypto": "^5.1.17",
|
|
51
|
+
"@libp2p/interface": "^3.2.2",
|
|
52
|
+
"@libp2p/interface-internal": "^3.1.2",
|
|
53
|
+
"@libp2p/keychain": "^6.0.14",
|
|
54
|
+
"@libp2p/peer-id": "^6.0.8",
|
|
55
|
+
"@libp2p/utils": "^7.0.17",
|
|
55
56
|
"@multiformats/multiaddr": "^13.0.1",
|
|
56
57
|
"@multiformats/multiaddr-matcher": "^3.0.1",
|
|
57
58
|
"@peculiar/webcrypto": "^1.5.0",
|
|
@@ -80,7 +81,7 @@
|
|
|
80
81
|
"uint8arrays": "^5.1.0"
|
|
81
82
|
},
|
|
82
83
|
"devDependencies": {
|
|
83
|
-
"@libp2p/logger": "6.2.
|
|
84
|
+
"@libp2p/logger": "^6.2.6",
|
|
84
85
|
"@types/sinon": "^21.0.1",
|
|
85
86
|
"aegir": "^47.0.22",
|
|
86
87
|
"any-signal": "^4.1.1",
|
package/src/constants.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -252,10 +252,10 @@
|
|
|
252
252
|
* ```
|
|
253
253
|
*/
|
|
254
254
|
|
|
255
|
-
import { WebRTCTransport } from './private-to-private/transport.
|
|
256
|
-
import { WebRTCDirectTransport } from './private-to-public/transport.
|
|
257
|
-
import type { WebRTCTransportComponents, WebRTCTransportInit } from './private-to-private/transport.
|
|
258
|
-
import type { WebRTCTransportDirectInit, WebRTCDirectTransportComponents } from './private-to-public/transport.
|
|
255
|
+
import { WebRTCTransport } from './private-to-private/transport.ts'
|
|
256
|
+
import { WebRTCDirectTransport } from './private-to-public/transport.ts'
|
|
257
|
+
import type { WebRTCTransportComponents, WebRTCTransportInit } from './private-to-private/transport.ts'
|
|
258
|
+
import type { WebRTCTransportDirectInit, WebRTCDirectTransportComponents } from './private-to-public/transport.ts'
|
|
259
259
|
import type { Transport } from '@libp2p/interface'
|
|
260
260
|
|
|
261
261
|
export interface DataChannelOptions {
|
package/src/muxer.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AbstractStreamMuxer } from '@libp2p/utils'
|
|
2
|
-
import { MUXER_PROTOCOL } from './constants.
|
|
3
|
-
import { createStream, WebRTCStream } from './stream.
|
|
4
|
-
import type { DataChannelOptions } from './index.
|
|
2
|
+
import { MUXER_PROTOCOL } from './constants.ts'
|
|
3
|
+
import { createStream, WebRTCStream } from './stream.ts'
|
|
4
|
+
import type { DataChannelOptions } from './index.ts'
|
|
5
5
|
import type { ComponentLogger, CounterGroup, StreamMuxer, StreamMuxerFactory, CreateStreamOptions, MultiaddrConnection } from '@libp2p/interface'
|
|
6
6
|
|
|
7
7
|
export interface DataChannelMuxerFactoryInit {
|
|
@@ -5,10 +5,10 @@ import { SIGNALING_PROTOCOL } from '../constants.js'
|
|
|
5
5
|
import { SDPHandshakeFailedError } from '../error.js'
|
|
6
6
|
import { DataChannelMuxerFactory } from '../muxer.js'
|
|
7
7
|
import { RTCPeerConnection, RTCSessionDescription } from '../webrtc/index.js'
|
|
8
|
-
import { Message } from './pb/message.
|
|
9
|
-
import { splitAddr } from './transport.
|
|
10
|
-
import { readCandidatesUntilConnected } from './util.
|
|
11
|
-
import type { WebRTCDialEvents, WebRTCTransportMetrics } from './transport.
|
|
8
|
+
import { Message } from './pb/message.ts'
|
|
9
|
+
import { splitAddr } from './transport.ts'
|
|
10
|
+
import { readCandidatesUntilConnected } from './util.ts'
|
|
11
|
+
import type { WebRTCDialEvents, WebRTCTransportMetrics } from './transport.ts'
|
|
12
12
|
import type { DataChannelOptions } from '../index.js'
|
|
13
13
|
import type { LoggerOptions, Connection, ComponentLogger, AbortOptions } from '@libp2p/interface'
|
|
14
14
|
import type { ConnectionManager, TransportManager } from '@libp2p/interface-internal'
|
|
@@ -2,8 +2,8 @@ import { pbStream } from '@libp2p/utils'
|
|
|
2
2
|
import { multiaddr } from '@multiformats/multiaddr'
|
|
3
3
|
import { SDPHandshakeFailedError } from '../error.js'
|
|
4
4
|
import { RTCSessionDescription } from '../webrtc/index.js'
|
|
5
|
-
import { Message } from './pb/message.
|
|
6
|
-
import { getRemotePeer, readCandidatesUntilConnected } from './util.
|
|
5
|
+
import { Message } from './pb/message.ts'
|
|
6
|
+
import { getRemotePeer, readCandidatesUntilConnected } from './util.ts'
|
|
7
7
|
import type { RTCPeerConnection } from '../webrtc/index.js'
|
|
8
8
|
import type { AbortOptions, Connection, Logger, PeerId, Stream } from '@libp2p/interface'
|
|
9
9
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
@@ -8,9 +8,9 @@ import { DataChannelMuxerFactory } from '../muxer.js'
|
|
|
8
8
|
import { toMultiaddrConnection } from '../rtcpeerconnection-to-conn.ts'
|
|
9
9
|
import { getRtcConfiguration } from '../util.js'
|
|
10
10
|
import { RTCPeerConnection } from '../webrtc/index.js'
|
|
11
|
-
import { initiateConnection } from './initiate-connection.
|
|
12
|
-
import { WebRTCPeerListener } from './listener.
|
|
13
|
-
import { handleIncomingStream } from './signaling-stream-handler.
|
|
11
|
+
import { initiateConnection } from './initiate-connection.ts'
|
|
12
|
+
import { WebRTCPeerListener } from './listener.ts'
|
|
13
|
+
import { handleIncomingStream } from './signaling-stream-handler.ts'
|
|
14
14
|
import { getRemotePeer } from './util.ts'
|
|
15
15
|
import type { DataChannelOptions } from '../index.js'
|
|
16
16
|
import type { OutboundConnectionUpgradeEvents, CreateListenerOptions, DialTransportOptions, Transport, Listener, Upgrader, ComponentLogger, Logger, Connection, PeerId, CounterGroup, Metrics, Startable, OpenConnectionProgressEvents, Libp2pEvents, MultiaddrConnection, Stream } from '@libp2p/interface'
|
|
@@ -2,8 +2,8 @@ import { ConnectionFailedError, InvalidMessageError, InvalidMultiaddrError } fro
|
|
|
2
2
|
import { peerIdFromString } from '@libp2p/peer-id'
|
|
3
3
|
import { CustomProgressEvent } from 'progress-events'
|
|
4
4
|
import { RTCIceCandidate } from '../webrtc/index.js'
|
|
5
|
-
import { Message } from './pb/message.
|
|
6
|
-
import type { WebRTCDialEvents } from './transport.
|
|
5
|
+
import { Message } from './pb/message.ts'
|
|
6
|
+
import type { WebRTCDialEvents } from './transport.ts'
|
|
7
7
|
import type { RTCPeerConnection } from '../webrtc/index.js'
|
|
8
8
|
import type { AbortOptions, LoggerOptions, PeerId, Stream } from '@libp2p/interface'
|
|
9
9
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
@@ -6,13 +6,13 @@ import { WebRTCDirect } from '@multiformats/multiaddr-matcher'
|
|
|
6
6
|
import getPort from 'get-port'
|
|
7
7
|
import { TypedEventEmitter, setMaxListeners } from 'main-event'
|
|
8
8
|
import pWaitFor from 'p-wait-for'
|
|
9
|
-
import { connect } from './utils/connect.
|
|
10
|
-
import { createDialerRTCPeerConnection } from './utils/get-rtcpeerconnection.
|
|
11
|
-
import { stunListener } from './utils/stun-listener.
|
|
9
|
+
import { connect } from './utils/connect.ts'
|
|
10
|
+
import { createDialerRTCPeerConnection } from './utils/get-rtcpeerconnection.ts'
|
|
11
|
+
import { stunListener } from './utils/stun-listener.ts'
|
|
12
12
|
import type { DataChannelOptions, TransportCertificate } from '../index.js'
|
|
13
|
-
import type { WebRTCDirectTransportCertificateEvents } from './transport.
|
|
14
|
-
import type { DirectRTCPeerConnection } from './utils/get-rtcpeerconnection.
|
|
15
|
-
import type { StunServer } from './utils/stun-listener.
|
|
13
|
+
import type { WebRTCDirectTransportCertificateEvents } from './transport.ts'
|
|
14
|
+
import type { DirectRTCPeerConnection } from './utils/get-rtcpeerconnection.ts'
|
|
15
|
+
import type { StunServer } from './utils/stun-listener.ts'
|
|
16
16
|
import type { PeerId, ListenerEvents, Listener, Upgrader, ComponentLogger, Logger, CounterGroup, Metrics, PrivateKey } from '@libp2p/interface'
|
|
17
17
|
import type { Keychain } from '@libp2p/keychain'
|
|
18
18
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
@@ -4,8 +4,8 @@ import { CODE_P2P } from '@multiformats/multiaddr'
|
|
|
4
4
|
import { WebRTCDirect } from '@multiformats/multiaddr-matcher'
|
|
5
5
|
import { UnimplementedError } from '../error.ts'
|
|
6
6
|
import { genUfrag } from '../util.js'
|
|
7
|
-
import { connect } from './utils/connect.
|
|
8
|
-
import { createDialerRTCPeerConnection } from './utils/get-rtcpeerconnection.
|
|
7
|
+
import { connect } from './utils/connect.ts'
|
|
8
|
+
import { createDialerRTCPeerConnection } from './utils/get-rtcpeerconnection.ts'
|
|
9
9
|
import type { DataChannelOptions } from '../index.js'
|
|
10
10
|
import type { WebRTCDialEvents } from '../private-to-private/transport.js'
|
|
11
11
|
import type { CreateListenerOptions, Transport, Listener, ComponentLogger, Logger, Connection, CounterGroup, Metrics, PeerId, DialTransportOptions, PrivateKey, Upgrader } from '@libp2p/interface'
|
|
@@ -10,9 +10,9 @@ import { sha256 } from 'multiformats/hashes/sha2'
|
|
|
10
10
|
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
|
|
11
11
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
|
12
12
|
import { DEFAULT_CERTIFICATE_DATASTORE_KEY, DEFAULT_CERTIFICATE_LIFESPAN, DEFAULT_CERTIFICATE_PRIVATE_KEY_NAME, DEFAULT_CERTIFICATE_RENEWAL_THRESHOLD } from '../constants.js'
|
|
13
|
-
import { WebRTCDirectListener } from './listener.
|
|
14
|
-
import { WebRTCDirectTransport as WebRTCDirectBrowserTransport } from './transport.browser.
|
|
15
|
-
import { formatAsPem } from './utils/pem.
|
|
13
|
+
import { WebRTCDirectListener } from './listener.ts'
|
|
14
|
+
import { WebRTCDirectTransport as WebRTCDirectBrowserTransport } from './transport.browser.ts'
|
|
15
|
+
import { formatAsPem } from './utils/pem.ts'
|
|
16
16
|
import type { TransportCertificate } from '../index.js'
|
|
17
17
|
import type { WebRTCTransportDirectInit as WebRTCTransportDirectBrowserInit, WebRTCMetrics, WebRTCDirectTransportComponents } from './transport.browser.ts'
|
|
18
18
|
import type { CreateListenerOptions, Transport, Listener, PrivateKey, Startable } from '@libp2p/interface'
|
|
@@ -5,9 +5,9 @@ import { DataChannelMuxerFactory } from '../../muxer.js'
|
|
|
5
5
|
import { toMultiaddrConnection } from '../../rtcpeerconnection-to-conn.ts'
|
|
6
6
|
import { createStream } from '../../stream.js'
|
|
7
7
|
import { isFirefox } from '../../util.js'
|
|
8
|
-
import { generateNoisePrologue } from './generate-noise-prologue.
|
|
9
|
-
import * as sdp from './sdp.
|
|
10
|
-
import type { DirectRTCPeerConnection } from './get-rtcpeerconnection.
|
|
8
|
+
import { generateNoisePrologue } from './generate-noise-prologue.ts'
|
|
9
|
+
import * as sdp from './sdp.ts'
|
|
10
|
+
import type { DirectRTCPeerConnection } from './get-rtcpeerconnection.ts'
|
|
11
11
|
import type { DataChannelOptions } from '../../index.js'
|
|
12
12
|
import type { ComponentLogger, Connection, CounterGroup, Logger, PeerId, PrivateKey, Upgrader } from '@libp2p/interface'
|
|
13
13
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
@@ -2,7 +2,7 @@ import * as Digest from 'multiformats/hashes/digest'
|
|
|
2
2
|
import { sha256 } from 'multiformats/hashes/sha2'
|
|
3
3
|
import { concat } from 'uint8arrays/concat'
|
|
4
4
|
import { fromString as uint8arrayFromString } from 'uint8arrays/from-string'
|
|
5
|
-
import * as sdp from './sdp.
|
|
5
|
+
import * as sdp from './sdp.ts'
|
|
6
6
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
7
7
|
|
|
8
8
|
const PREFIX = uint8arrayFromString('libp2p-webrtc-noise:')
|
|
@@ -3,7 +3,7 @@ import { PeerConnection } from 'node-datachannel'
|
|
|
3
3
|
import { RTCPeerConnection } from 'node-datachannel/polyfill'
|
|
4
4
|
import { DEFAULT_ICE_SERVERS, MAX_MESSAGE_SIZE } from '../../constants.js'
|
|
5
5
|
import { DataChannelMuxerFactory } from '../../muxer.ts'
|
|
6
|
-
import { generateTransportCertificate } from './generate-certificates.
|
|
6
|
+
import { generateTransportCertificate } from './generate-certificates.ts'
|
|
7
7
|
import type { DataChannelOptions, TransportCertificate } from '../../index.js'
|
|
8
8
|
import type { CounterGroup } from '@libp2p/interface'
|
|
9
9
|
import type { CertificateFingerprint } from 'node-datachannel'
|
package/src/stream.ts
CHANGED
|
@@ -5,10 +5,10 @@ import { pushable } from 'it-pushable'
|
|
|
5
5
|
import { pEvent } from 'p-event'
|
|
6
6
|
import { raceSignal } from 'race-signal'
|
|
7
7
|
import { Uint8ArrayList } from 'uint8arraylist'
|
|
8
|
-
import { DEFAULT_FIN_ACK_TIMEOUT, MAX_BUFFERED_AMOUNT, MAX_MESSAGE_SIZE, PROTOBUF_OVERHEAD } from './constants.
|
|
9
|
-
import { Message } from './private-to-public/pb/message.
|
|
10
|
-
import { isFirefox } from './util.
|
|
11
|
-
import type { DataChannelOptions } from './index.
|
|
8
|
+
import { DEFAULT_FIN_ACK_TIMEOUT, MAX_BUFFERED_AMOUNT, MAX_MESSAGE_SIZE, PROTOBUF_OVERHEAD } from './constants.ts'
|
|
9
|
+
import { Message } from './private-to-public/pb/message.ts'
|
|
10
|
+
import { isFirefox } from './util.ts'
|
|
11
|
+
import type { DataChannelOptions } from './index.ts'
|
|
12
12
|
import type { AbortOptions, MessageStreamDirection, Logger } from '@libp2p/interface'
|
|
13
13
|
import type { AbstractStreamInit, SendResult } from '@libp2p/utils'
|
|
14
14
|
import type { Pushable } from 'it-pushable'
|
package/src/util.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { detect } from 'detect-browser'
|
|
2
2
|
import pDefer from 'p-defer'
|
|
3
3
|
import pTimeout from 'p-timeout'
|
|
4
|
-
import { DATA_CHANNEL_DRAIN_TIMEOUT, DEFAULT_ICE_SERVERS, UFRAG_ALPHABET, UFRAG_PREFIX } from './constants.
|
|
4
|
+
import { DATA_CHANNEL_DRAIN_TIMEOUT, DEFAULT_ICE_SERVERS, UFRAG_ALPHABET, UFRAG_PREFIX } from './constants.ts'
|
|
5
5
|
import type { LoggerOptions } from '@libp2p/interface'
|
|
6
6
|
import type { Duplex, Source } from 'it-stream-types'
|
|
7
7
|
import type { PeerConnection } from 'node-datachannel'
|