@libp2p/webrtc 5.2.9-fc5122110 → 5.2.10
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 +54 -0
- package/dist/index.min.js +153 -18
- package/dist/src/constants.d.ts +20 -0
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +20 -0
- package/dist/src/constants.js.map +1 -1
- package/dist/src/index.d.ts +54 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +54 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/private-to-public/listener.d.ts +9 -4
- package/dist/src/private-to-public/listener.d.ts.map +1 -1
- package/dist/src/private-to-public/listener.js +7 -18
- package/dist/src/private-to-public/listener.js.map +1 -1
- package/dist/src/private-to-public/transport.d.ts +67 -5
- package/dist/src/private-to-public/transport.d.ts.map +1 -1
- package/dist/src/private-to-public/transport.js +181 -2
- package/dist/src/private-to-public/transport.js.map +1 -1
- package/dist/src/private-to-public/utils/pem.d.ts +6 -0
- package/dist/src/private-to-public/utils/pem.d.ts.map +1 -0
- package/dist/src/private-to-public/utils/pem.js +15 -0
- package/dist/src/private-to-public/utils/pem.js.map +1 -0
- package/dist/typedoc-urls.json +14 -0
- package/package.json +11 -8
- package/src/constants.ts +25 -0
- package/src/index.ts +54 -0
- package/src/private-to-public/listener.ts +17 -26
- package/src/private-to-public/transport.ts +281 -7
- package/src/private-to-public/utils/pem.ts +18 -0
package/README.md
CHANGED
@@ -230,6 +230,60 @@ await pipe(
|
|
230
230
|
)
|
231
231
|
```
|
232
232
|
|
233
|
+
## WebRTC Direct certificate hashes
|
234
|
+
|
235
|
+
WebRTC Direct listeners publish the hash of their TLS certificate as part of
|
236
|
+
the listening multiaddr.
|
237
|
+
|
238
|
+
By default these certificates are generated at start up using an ephemeral
|
239
|
+
keypair that only exists while the node is running.
|
240
|
+
|
241
|
+
This means that the certificate hashes change when the node is restarted,
|
242
|
+
which can be undesirable if multiaddrs are intended to be long lived (e.g.
|
243
|
+
if the node is used as a network bootstrapper).
|
244
|
+
|
245
|
+
To reuse the same certificate and keypair, configure a persistent datastore
|
246
|
+
and the [@libp2p/keychain](https://www.npmjs.com/package/@libp2p/keychain)
|
247
|
+
service as part of your service map:
|
248
|
+
|
249
|
+
## Example - Reuse TLS certificates after restart
|
250
|
+
|
251
|
+
```ts
|
252
|
+
import { LevelDatastore } from 'datastore-level'
|
253
|
+
import { webRTCDirect } from '@libp2p/webrtc'
|
254
|
+
import { keychain } from '@libp2p/keychain'
|
255
|
+
import { createLibp2p } from 'libp2p'
|
256
|
+
|
257
|
+
// store data on disk between restarts
|
258
|
+
const datastore = new LevelDatastore('/path/to/store')
|
259
|
+
|
260
|
+
const listener = await createLibp2p({
|
261
|
+
addresses: {
|
262
|
+
listen: [
|
263
|
+
'/ip4/0.0.0.0/udp/0/webrtc-direct'
|
264
|
+
]
|
265
|
+
},
|
266
|
+
datastore,
|
267
|
+
transports: [
|
268
|
+
webRTCDirect()
|
269
|
+
],
|
270
|
+
services: {
|
271
|
+
keychain: keychain()
|
272
|
+
}
|
273
|
+
})
|
274
|
+
|
275
|
+
await listener.start()
|
276
|
+
|
277
|
+
console.info(listener.getMultiaddrs())
|
278
|
+
// /ip4/...../udp/../webrtc-direct/certhash/foo
|
279
|
+
|
280
|
+
await listener.stop()
|
281
|
+
await listener.start()
|
282
|
+
|
283
|
+
console.info(listener.getMultiaddrs())
|
284
|
+
// /ip4/...../udp/../webrtc-direct/certhash/foo
|
285
|
+
```
|
286
|
+
|
233
287
|
# Install
|
234
288
|
|
235
289
|
```console
|