libp2p 0.46.3 → 0.46.4-6abcd22f

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.
Files changed (62) hide show
  1. package/dist/index.min.js +55 -31
  2. package/dist/src/connection/index.d.ts +0 -8
  3. package/dist/src/connection/index.d.ts.map +1 -1
  4. package/dist/src/connection/index.js +0 -11
  5. package/dist/src/connection/index.js.map +1 -1
  6. package/dist/src/connection-manager/auto-dial.d.ts +2 -0
  7. package/dist/src/connection-manager/auto-dial.d.ts.map +1 -1
  8. package/dist/src/connection-manager/auto-dial.js +20 -5
  9. package/dist/src/connection-manager/auto-dial.js.map +1 -1
  10. package/dist/src/connection-manager/constants.browser.d.ts +18 -0
  11. package/dist/src/connection-manager/constants.browser.d.ts.map +1 -0
  12. package/dist/src/connection-manager/constants.browser.js +18 -0
  13. package/dist/src/connection-manager/constants.browser.js.map +1 -0
  14. package/dist/src/connection-manager/constants.d.ts +1 -36
  15. package/dist/src/connection-manager/constants.d.ts.map +1 -1
  16. package/dist/src/connection-manager/constants.defaults.d.ts +50 -0
  17. package/dist/src/connection-manager/constants.defaults.d.ts.map +1 -0
  18. package/dist/src/connection-manager/constants.defaults.js +50 -0
  19. package/dist/src/connection-manager/constants.defaults.js.map +1 -0
  20. package/dist/src/connection-manager/constants.js +1 -36
  21. package/dist/src/connection-manager/constants.js.map +1 -1
  22. package/dist/src/connection-manager/dial-queue.d.ts.map +1 -1
  23. package/dist/src/connection-manager/dial-queue.js +30 -4
  24. package/dist/src/connection-manager/dial-queue.js.map +1 -1
  25. package/dist/src/connection-manager/index.d.ts +6 -4
  26. package/dist/src/connection-manager/index.d.ts.map +1 -1
  27. package/dist/src/connection-manager/index.js +1 -1
  28. package/dist/src/connection-manager/index.js.map +1 -1
  29. package/dist/src/dcutr/dcutr.d.ts +48 -0
  30. package/dist/src/dcutr/dcutr.d.ts.map +1 -0
  31. package/dist/src/dcutr/dcutr.js +335 -0
  32. package/dist/src/dcutr/dcutr.js.map +1 -0
  33. package/dist/src/dcutr/index.d.ts +92 -0
  34. package/dist/src/dcutr/index.d.ts.map +1 -0
  35. package/dist/src/dcutr/index.js +63 -0
  36. package/dist/src/dcutr/index.js.map +1 -0
  37. package/dist/src/dcutr/pb/message.d.ts +20 -0
  38. package/dist/src/dcutr/pb/message.d.ts.map +1 -0
  39. package/dist/src/dcutr/pb/message.js +77 -0
  40. package/dist/src/dcutr/pb/message.js.map +1 -0
  41. package/dist/src/upgrader.d.ts.map +1 -1
  42. package/dist/src/upgrader.js +0 -5
  43. package/dist/src/upgrader.js.map +1 -1
  44. package/dist/src/version.d.ts +1 -1
  45. package/dist/src/version.d.ts.map +1 -1
  46. package/dist/src/version.js +1 -1
  47. package/dist/src/version.js.map +1 -1
  48. package/package.json +32 -26
  49. package/src/connection/index.ts +0 -14
  50. package/src/connection-manager/auto-dial.ts +26 -5
  51. package/src/connection-manager/constants.browser.ts +21 -0
  52. package/src/connection-manager/constants.defaults.ts +59 -0
  53. package/src/connection-manager/constants.ts +1 -44
  54. package/src/connection-manager/dial-queue.ts +33 -4
  55. package/src/connection-manager/index.ts +8 -6
  56. package/src/dcutr/dcutr.ts +406 -0
  57. package/src/dcutr/index.ts +102 -0
  58. package/src/dcutr/pb/message.proto +12 -0
  59. package/src/dcutr/pb/message.ts +96 -0
  60. package/src/upgrader.ts +0 -5
  61. package/src/version.ts +1 -1
  62. package/dist/typedoc-urls.json +0 -58
@@ -0,0 +1,96 @@
1
+ /* eslint-disable import/export */
2
+ /* eslint-disable complexity */
3
+ /* eslint-disable @typescript-eslint/no-namespace */
4
+ /* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
5
+ /* eslint-disable @typescript-eslint/no-empty-interface */
6
+
7
+ import { enumeration, encodeMessage, decodeMessage, message } from 'protons-runtime'
8
+ import type { Codec } from 'protons-runtime'
9
+ import type { Uint8ArrayList } from 'uint8arraylist'
10
+
11
+ export interface HolePunch {
12
+ type?: HolePunch.Type
13
+ observedAddresses: Uint8Array[]
14
+ }
15
+
16
+ export namespace HolePunch {
17
+ export enum Type {
18
+ UNUSED = 'UNUSED',
19
+ CONNECT = 'CONNECT',
20
+ SYNC = 'SYNC'
21
+ }
22
+
23
+ enum __TypeValues {
24
+ UNUSED = 0,
25
+ CONNECT = 100,
26
+ SYNC = 300
27
+ }
28
+
29
+ export namespace Type {
30
+ export const codec = (): Codec<Type> => {
31
+ return enumeration<Type>(__TypeValues)
32
+ }
33
+ }
34
+
35
+ let _codec: Codec<HolePunch>
36
+
37
+ export const codec = (): Codec<HolePunch> => {
38
+ if (_codec == null) {
39
+ _codec = message<HolePunch>((obj, w, opts = {}) => {
40
+ if (opts.lengthDelimited !== false) {
41
+ w.fork()
42
+ }
43
+
44
+ if (obj.type != null) {
45
+ w.uint32(8)
46
+ HolePunch.Type.codec().encode(obj.type, w)
47
+ }
48
+
49
+ if (obj.observedAddresses != null) {
50
+ for (const value of obj.observedAddresses) {
51
+ w.uint32(18)
52
+ w.bytes(value)
53
+ }
54
+ }
55
+
56
+ if (opts.lengthDelimited !== false) {
57
+ w.ldelim()
58
+ }
59
+ }, (reader, length) => {
60
+ const obj: any = {
61
+ observedAddresses: []
62
+ }
63
+
64
+ const end = length == null ? reader.len : reader.pos + length
65
+
66
+ while (reader.pos < end) {
67
+ const tag = reader.uint32()
68
+
69
+ switch (tag >>> 3) {
70
+ case 1:
71
+ obj.type = HolePunch.Type.codec().decode(reader)
72
+ break
73
+ case 2:
74
+ obj.observedAddresses.push(reader.bytes())
75
+ break
76
+ default:
77
+ reader.skipType(tag & 7)
78
+ break
79
+ }
80
+ }
81
+
82
+ return obj
83
+ })
84
+ }
85
+
86
+ return _codec
87
+ }
88
+
89
+ export const encode = (obj: Partial<HolePunch>): Uint8Array => {
90
+ return encodeMessage(obj, HolePunch.codec())
91
+ }
92
+
93
+ export const decode = (buf: Uint8Array | Uint8ArrayList): HolePunch => {
94
+ return decodeMessage(buf, HolePunch.codec())
95
+ }
96
+ }
package/src/upgrader.ts CHANGED
@@ -415,7 +415,6 @@ export class DefaultUpgrader implements Upgrader {
415
415
  protocols: [protocol]
416
416
  })
417
417
 
418
- connection.addStream(muxedStream)
419
418
  this.components.metrics?.trackProtocolStream(muxedStream, connection)
420
419
 
421
420
  this._onStream({ connection, stream: muxedStream, protocol })
@@ -427,10 +426,6 @@ export class DefaultUpgrader implements Upgrader {
427
426
  await muxedStream.close()
428
427
  }
429
428
  })
430
- },
431
- // Run anytime a stream closes
432
- onStreamEnd: muxedStream => {
433
- connection?.removeStream(muxedStream.id)
434
429
  }
435
430
  })
436
431
 
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
- export const version = '0.46.3'
1
+ export const version = '0.46.4-6abcd22f'
2
2
  export const name = 'libp2p'
@@ -1,58 +0,0 @@
1
- {
2
- "AutoNATComponents": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.autonat.AutoNATComponents.html",
3
- "AutoNATServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.autonat.AutoNATServiceInit.html",
4
- "autoNATService": "https://libp2p.github.io/js-libp2p/functions/libp2p.autonat.autoNATService.html",
5
- "codec": "https://libp2p.github.io/js-libp2p/functions/libp2p.circuit_relay.unknown.Limit.codec.html",
6
- "decode": "https://libp2p.github.io/js-libp2p/functions/libp2p.circuit_relay.unknown.Limit.decode.html",
7
- "encode": "https://libp2p.github.io/js-libp2p/functions/libp2p.circuit_relay.unknown.Limit.encode.html",
8
- "Limit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.circuit_relay.unknown.Limit-1.html",
9
- "CircuitRelayService": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.circuit_relay.CircuitRelayService.html",
10
- "CircuitRelayServiceEvents": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.circuit_relay.CircuitRelayServiceEvents.html",
11
- "RelayReservation": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.circuit_relay.RelayReservation.html",
12
- "circuitRelayServer": "https://libp2p.github.io/js-libp2p/functions/libp2p.circuit_relay.circuitRelayServer.html",
13
- "circuitRelayTransport": "https://libp2p.github.io/js-libp2p/functions/libp2p.circuit_relay.circuitRelayTransport.html",
14
- "FetchService": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.fetch.FetchService.html",
15
- "FetchServiceComponents": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.fetch.FetchServiceComponents.html",
16
- "FetchServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.fetch.FetchServiceInit.html",
17
- "HandleMessageOptions": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.fetch.HandleMessageOptions.html",
18
- "LookupFunction": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.fetch.LookupFunction.html",
19
- "fetchService": "https://libp2p.github.io/js-libp2p/functions/libp2p.fetch.fetchService-1.html",
20
- "Identify": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.identify.unknown.Identify-1.html",
21
- "IdentifyService": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.identify.IdentifyService.html",
22
- "IdentifyServiceComponents": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.identify.IdentifyServiceComponents.html",
23
- "IdentifyServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.identify.IdentifyServiceInit.html",
24
- "Message": "https://libp2p.github.io/js-libp2p/variables/libp2p.identify.Message.html",
25
- "multicodecs": "https://libp2p.github.io/js-libp2p/variables/libp2p.identify.multicodecs.html",
26
- "identifyService": "https://libp2p.github.io/js-libp2p/functions/libp2p.identify.identifyService-1.html",
27
- "AddressFilter": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.unknown.AddressFilter.html",
28
- "AddressManagerInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.unknown.AddressManagerInit.html",
29
- "Components": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.unknown.Components.html",
30
- "ConnectionManagerInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.unknown.ConnectionManagerInit.html",
31
- "TransportManagerInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.unknown.TransportManagerInit.html",
32
- "Libp2pInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.Libp2pInit.html",
33
- "Libp2pOptions": "https://libp2p.github.io/js-libp2p/types/libp2p.index.Libp2pOptions.html",
34
- "ServiceFactoryMap": "https://libp2p.github.io/js-libp2p/types/libp2p.index.ServiceFactoryMap.html",
35
- "createLibp2p": "https://libp2p.github.io/js-libp2p/functions/libp2p.index.createLibp2p.html",
36
- "plaintext": "https://libp2p.github.io/js-libp2p/functions/libp2p.insecure.plaintext.html",
37
- "PingService": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.ping.PingService.html",
38
- "PingServiceComponents": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.ping.PingServiceComponents.html",
39
- "PingServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.ping.PingServiceInit.html",
40
- "pingService": "https://libp2p.github.io/js-libp2p/functions/libp2p.ping.pingService-1.html",
41
- "ProtectorInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.pnet.ProtectorInit.html",
42
- "generateKey": "https://libp2p.github.io/js-libp2p/functions/libp2p.pnet.generateKey.html",
43
- "preSharedKey": "https://libp2p.github.io/js-libp2p/functions/libp2p.pnet.preSharedKey.html",
44
- "UPnPNAT": "https://libp2p.github.io/js-libp2p/classes/libp2p.upnp_nat.unknown.UPnPNAT.html",
45
- "AdvertServiceComponents": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.upnp_nat.unknown.AdvertServiceComponents.html",
46
- "AdvertServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.upnp_nat.unknown.AdvertServiceInit.html",
47
- "CircuitRelayServerComponents": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.upnp_nat.unknown.CircuitRelayServerComponents.html",
48
- "CircuitRelayServerInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.upnp_nat.unknown.CircuitRelayServerInit.html",
49
- "CircuitRelayTransportComponents": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.upnp_nat.unknown.CircuitRelayTransportComponents.html",
50
- "CircuitRelayTransportInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.upnp_nat.unknown.CircuitRelayTransportInit.html",
51
- "RelayDiscoveryComponents": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.upnp_nat.unknown.RelayDiscoveryComponents.html",
52
- "RelayStoreInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.upnp_nat.unknown.RelayStoreInit.html",
53
- "ReservationStoreInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.upnp_nat.unknown.ReservationStoreInit.html",
54
- "PMPOptions": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.upnp_nat.PMPOptions.html",
55
- "UPnPNATComponents": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.upnp_nat.UPnPNATComponents.html",
56
- "UPnPNATInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.upnp_nat.UPnPNATInit.html",
57
- "uPnPNATService": "https://libp2p.github.io/js-libp2p/functions/libp2p.upnp_nat.uPnPNATService.html"
58
- }