@libp2p/webrtc 3.2.5-d5ef1c91 → 3.2.6-051154dd
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/README.md +14 -132
- package/dist/index.min.js +10 -11
- package/dist/src/index.d.ts +30 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +30 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/private-to-private/initiate-connection.d.ts +1 -1
- package/dist/src/private-to-private/initiate-connection.d.ts.map +1 -1
- package/dist/src/private-to-private/initiate-connection.js +4 -6
- package/dist/src/private-to-private/initiate-connection.js.map +1 -1
- package/dist/src/private-to-private/signaling-stream-handler.d.ts +2 -1
- package/dist/src/private-to-private/signaling-stream-handler.d.ts.map +1 -1
- package/dist/src/private-to-private/signaling-stream-handler.js +3 -2
- package/dist/src/private-to-private/signaling-stream-handler.js.map +1 -1
- package/dist/src/private-to-private/transport.js +1 -1
- package/dist/src/private-to-private/transport.js.map +1 -1
- package/dist/src/private-to-private/util.d.ts +0 -1
- package/dist/src/private-to-private/util.d.ts.map +1 -1
- package/dist/src/private-to-private/util.js +0 -10
- package/dist/src/private-to-private/util.js.map +1 -1
- package/package.json +10 -10
- package/src/index.ts +31 -0
- package/src/private-to-private/initiate-connection.ts +5 -7
- package/src/private-to-private/signaling-stream-handler.ts +4 -3
- package/src/private-to-private/transport.ts +1 -1
- package/src/private-to-private/util.ts +0 -13
package/README.md
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# @libp2p/webrtc <!-- omit in toc -->
|
|
2
|
-
|
|
3
1
|
[](http://libp2p.io/)
|
|
4
2
|
[](https://discuss.libp2p.io)
|
|
5
3
|
[](https://codecov.io/gh/libp2p/js-libp2p)
|
|
@@ -7,40 +5,11 @@
|
|
|
7
5
|
|
|
8
6
|
> A libp2p transport using WebRTC connections
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
- [Install](#install)
|
|
13
|
-
- [Browser `<script>` tag](#browser-script-tag)
|
|
14
|
-
- [Usage](#usage)
|
|
15
|
-
- [Interfaces](#interfaces)
|
|
16
|
-
- [Transport](#transport)
|
|
17
|
-
- [Connection](#connection)
|
|
18
|
-
- [Development](#development)
|
|
19
|
-
- [Build](#build)
|
|
20
|
-
- [Protocol Buffers](#protocol-buffers)
|
|
21
|
-
- [Test](#test)
|
|
22
|
-
- [Lint](#lint)
|
|
23
|
-
- [Clean](#clean)
|
|
24
|
-
- [Check Dependencies](#check-dependencies)
|
|
25
|
-
- [API Docs](#api-docs)
|
|
26
|
-
- [License](#license)
|
|
27
|
-
- [Contribution](#contribution)
|
|
28
|
-
|
|
29
|
-
## Install
|
|
30
|
-
|
|
31
|
-
```console
|
|
32
|
-
$ npm i @libp2p/webrtc
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### Browser `<script>` tag
|
|
36
|
-
|
|
37
|
-
Loading this module through a script tag will make it's exports available as `Libp2pWebrtc` in the global namespace.
|
|
8
|
+
# About
|
|
38
9
|
|
|
39
|
-
|
|
40
|
-
<script src="https://unpkg.com/@libp2p/webrtc/dist/index.min.js"></script>
|
|
41
|
-
```
|
|
10
|
+
A [libp2p transport](https://docs.libp2p.io/concepts/transports/overview/) based on [WebRTC datachannels](https://webrtc.org/).
|
|
42
11
|
|
|
43
|
-
##
|
|
12
|
+
## Example
|
|
44
13
|
|
|
45
14
|
```js
|
|
46
15
|
import { createLibp2p } from 'libp2p'
|
|
@@ -54,7 +23,7 @@ import { webRTC } from '@libp2p/webrtc'
|
|
|
54
23
|
const node = await createLibp2p({
|
|
55
24
|
transports: [webRTC()],
|
|
56
25
|
connectionEncryption: [noise()],
|
|
57
|
-
})
|
|
26
|
+
})
|
|
58
27
|
|
|
59
28
|
await node.start()
|
|
60
29
|
|
|
@@ -65,118 +34,31 @@ const response = await pipe([fromString(message)], stream, async (source) => awa
|
|
|
65
34
|
const responseDecoded = toString(response.slice(0, response.length))
|
|
66
35
|
```
|
|
67
36
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
### Transport
|
|
71
|
-
|
|
72
|
-

|
|
73
|
-
|
|
74
|
-
Browsers can usually only `dial`, but `listen` is supported in the WebRTC
|
|
75
|
-
transport when paired with another listener like CircuitV2, where you listen on
|
|
76
|
-
a relayed connection.
|
|
77
|
-
|
|
78
|
-
### Connection
|
|
79
|
-
|
|
80
|
-

|
|
81
|
-
|
|
82
|
-
```js
|
|
83
|
-
interface MultiaddrConnection extends Duplex<Uint8Array> {
|
|
84
|
-
close: (err?: Error) => Promise<void>
|
|
85
|
-
remoteAddr: Multiaddr
|
|
86
|
-
timeline: MultiaddrConnectionTimeline
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
class WebRTCMultiaddrConnection implements MultiaddrConnection { }
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
## Development
|
|
93
|
-
|
|
94
|
-
Contributions are welcome! The libp2p implementation in JavaScript is a work in progress. As such, there's a few things you can do right now to help out:
|
|
95
|
-
|
|
96
|
-
- [Check out the existing issues](//github.com/little-bear-labs/js-libp2p-webrtc/issues).
|
|
97
|
-
- **Perform code reviews**.
|
|
98
|
-
- **Add tests**. There can never be enough tests.
|
|
99
|
-
- Go through the modules and **check out existing issues**. This is especially useful for modules in active development. Some knowledge of IPFS/libp2p may be required, as well as the infrastructure behind it - for instance, you may need to read up on p2p and more complex operations like muxing to be able to help technically.
|
|
100
|
-
|
|
101
|
-
Please be aware that all interactions related to libp2p are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).
|
|
102
|
-
|
|
103
|
-
Small note: If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.
|
|
104
|
-
|
|
105
|
-
This module leans heavily on (Aegir)\[<https://github.com/ipfs/aegir>] for most of the `package.json` scripts.
|
|
106
|
-
|
|
107
|
-
### Build
|
|
108
|
-
|
|
109
|
-
The build script is a wrapper to `aegir build`. To build this package:
|
|
37
|
+
# Install
|
|
110
38
|
|
|
111
|
-
```
|
|
112
|
-
npm
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
The build will be located in the `/dist` folder.
|
|
116
|
-
|
|
117
|
-
### Protocol Buffers
|
|
118
|
-
|
|
119
|
-
There is also `npm run generate:proto` script that uses protoc to populate the generated code directory `proto_ts` based on `*.proto` files in src. Don't forget to run this step before `build` any time you make a change to any of the `*.proto` files.
|
|
120
|
-
|
|
121
|
-
### Test
|
|
122
|
-
|
|
123
|
-
To run all tests:
|
|
124
|
-
|
|
125
|
-
```shell
|
|
126
|
-
npm test
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
To run tests for Chrome only:
|
|
130
|
-
|
|
131
|
-
```shell
|
|
132
|
-
npm run test:chrome
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
To run tests for Firefox only:
|
|
136
|
-
|
|
137
|
-
```shell
|
|
138
|
-
npm run test:firefox
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
### Lint
|
|
142
|
-
|
|
143
|
-
Aegir is also used to lint the code, which follows the [Standard](https://github.com/standard/standard) JS linter.
|
|
144
|
-
The VS Code plugin for this standard is located at <https://marketplace.visualstudio.com/items?itemName=standard.vscode-standard>.
|
|
145
|
-
To lint this repo:
|
|
146
|
-
|
|
147
|
-
```shell
|
|
148
|
-
npm run lint
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
You can also auto-fix when applicable:
|
|
152
|
-
|
|
153
|
-
```shell
|
|
154
|
-
npm run lint:fix
|
|
39
|
+
```console
|
|
40
|
+
$ npm i @libp2p/webrtc
|
|
155
41
|
```
|
|
156
42
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
```shell
|
|
160
|
-
npm run clean
|
|
161
|
-
```
|
|
43
|
+
## Browser `<script>` tag
|
|
162
44
|
|
|
163
|
-
|
|
45
|
+
Loading this module through a script tag will make it's exports available as `Libp2pWebrtc` in the global namespace.
|
|
164
46
|
|
|
165
|
-
```
|
|
166
|
-
|
|
47
|
+
```html
|
|
48
|
+
<script src="https://unpkg.com/@libp2p/webrtc/dist/index.min.js"></script>
|
|
167
49
|
```
|
|
168
50
|
|
|
169
|
-
|
|
51
|
+
# API Docs
|
|
170
52
|
|
|
171
53
|
- <https://libp2p.github.io/js-libp2p/modules/_libp2p_webrtc.html>
|
|
172
54
|
|
|
173
|
-
|
|
55
|
+
# License
|
|
174
56
|
|
|
175
57
|
Licensed under either of
|
|
176
58
|
|
|
177
59
|
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
|
|
178
60
|
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
|
|
179
61
|
|
|
180
|
-
|
|
62
|
+
# Contribution
|
|
181
63
|
|
|
182
64
|
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
|