@libp2p/kad-dht 9.3.6-3dfc236e → 9.3.6-6fdaa7dc

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 (137) hide show
  1. package/dist/index.min.js +19 -19
  2. package/dist/src/content-fetching/index.d.ts +2 -2
  3. package/dist/src/content-fetching/index.d.ts.map +1 -1
  4. package/dist/src/content-fetching/index.js +4 -4
  5. package/dist/src/content-fetching/index.js.map +1 -1
  6. package/dist/src/dual-kad-dht.d.ts +5 -5
  7. package/dist/src/dual-kad-dht.d.ts.map +1 -1
  8. package/dist/src/dual-kad-dht.js +5 -5
  9. package/dist/src/dual-kad-dht.js.map +1 -1
  10. package/dist/src/index.d.ts +9 -10
  11. package/dist/src/index.d.ts.map +1 -1
  12. package/dist/src/index.js.map +1 -1
  13. package/dist/src/kad-dht.d.ts +4 -4
  14. package/dist/src/kad-dht.d.ts.map +1 -1
  15. package/dist/src/kad-dht.js +3 -3
  16. package/dist/src/kad-dht.js.map +1 -1
  17. package/dist/src/message/index.d.ts +2 -2
  18. package/dist/src/message/index.d.ts.map +1 -1
  19. package/dist/src/message/index.js +1 -1
  20. package/dist/src/message/index.js.map +1 -1
  21. package/dist/src/network.d.ts +5 -5
  22. package/dist/src/network.d.ts.map +1 -1
  23. package/dist/src/network.js +2 -2
  24. package/dist/src/network.js.map +1 -1
  25. package/dist/src/peer-list/index.d.ts +1 -1
  26. package/dist/src/peer-list/peer-distance-list.d.ts +1 -1
  27. package/dist/src/peer-routing/index.d.ts +3 -3
  28. package/dist/src/peer-routing/index.d.ts.map +1 -1
  29. package/dist/src/peer-routing/index.js +3 -3
  30. package/dist/src/peer-routing/index.js.map +1 -1
  31. package/dist/src/providers.d.ts +2 -2
  32. package/dist/src/providers.d.ts.map +1 -1
  33. package/dist/src/query/events.d.ts +3 -3
  34. package/dist/src/query/events.d.ts.map +1 -1
  35. package/dist/src/query/events.js +1 -1
  36. package/dist/src/query/events.js.map +1 -1
  37. package/dist/src/query/manager.d.ts +3 -3
  38. package/dist/src/query/manager.d.ts.map +1 -1
  39. package/dist/src/query/manager.js +2 -2
  40. package/dist/src/query/manager.js.map +1 -1
  41. package/dist/src/query/query-path.d.ts +2 -2
  42. package/dist/src/query/query-path.d.ts.map +1 -1
  43. package/dist/src/query/query-path.js +1 -1
  44. package/dist/src/query/query-path.js.map +1 -1
  45. package/dist/src/query/types.d.ts +1 -1
  46. package/dist/src/query-self.d.ts +2 -2
  47. package/dist/src/query-self.d.ts.map +1 -1
  48. package/dist/src/record/index.d.ts +22 -0
  49. package/dist/src/record/index.d.ts.map +1 -0
  50. package/dist/src/record/index.js +53 -0
  51. package/dist/src/record/index.js.map +1 -0
  52. package/dist/src/record/record.d.ts +13 -0
  53. package/dist/src/record/record.d.ts.map +1 -0
  54. package/dist/src/record/record.js +67 -0
  55. package/dist/src/record/record.js.map +1 -0
  56. package/dist/src/record/selectors.d.ts +7 -0
  57. package/dist/src/record/selectors.d.ts.map +1 -0
  58. package/dist/src/record/selectors.js +38 -0
  59. package/dist/src/record/selectors.js.map +1 -0
  60. package/dist/src/record/utils.d.ts +11 -0
  61. package/dist/src/record/utils.d.ts.map +1 -0
  62. package/dist/src/record/utils.js +41 -0
  63. package/dist/src/record/utils.js.map +1 -0
  64. package/dist/src/record/validators.d.ts +10 -0
  65. package/dist/src/record/validators.d.ts.map +1 -0
  66. package/dist/src/record/validators.js +54 -0
  67. package/dist/src/record/validators.js.map +1 -0
  68. package/dist/src/routing-table/index.d.ts +6 -6
  69. package/dist/src/routing-table/index.d.ts.map +1 -1
  70. package/dist/src/routing-table/index.js +1 -1
  71. package/dist/src/routing-table/index.js.map +1 -1
  72. package/dist/src/routing-table/k-bucket.d.ts +2 -2
  73. package/dist/src/routing-table/k-bucket.d.ts.map +1 -1
  74. package/dist/src/routing-table/k-bucket.js +1 -1
  75. package/dist/src/routing-table/k-bucket.js.map +1 -1
  76. package/dist/src/routing-table/refresh.d.ts +1 -1
  77. package/dist/src/rpc/handlers/add-provider.d.ts +1 -1
  78. package/dist/src/rpc/handlers/add-provider.js +1 -1
  79. package/dist/src/rpc/handlers/add-provider.js.map +1 -1
  80. package/dist/src/rpc/handlers/find-node.d.ts +2 -2
  81. package/dist/src/rpc/handlers/find-node.d.ts.map +1 -1
  82. package/dist/src/rpc/handlers/get-providers.d.ts +3 -3
  83. package/dist/src/rpc/handlers/get-providers.js +1 -1
  84. package/dist/src/rpc/handlers/get-providers.js.map +1 -1
  85. package/dist/src/rpc/handlers/get-value.d.ts +3 -3
  86. package/dist/src/rpc/handlers/get-value.d.ts.map +1 -1
  87. package/dist/src/rpc/handlers/get-value.js +2 -2
  88. package/dist/src/rpc/handlers/get-value.js.map +1 -1
  89. package/dist/src/rpc/handlers/ping.d.ts +1 -1
  90. package/dist/src/rpc/handlers/put-value.d.ts +1 -1
  91. package/dist/src/rpc/handlers/put-value.js +2 -2
  92. package/dist/src/rpc/handlers/put-value.js.map +1 -1
  93. package/dist/src/rpc/index.d.ts +2 -2
  94. package/dist/src/rpc/index.d.ts.map +1 -1
  95. package/dist/src/topology-listener.d.ts +3 -3
  96. package/dist/src/topology-listener.d.ts.map +1 -1
  97. package/dist/src/topology-listener.js +2 -4
  98. package/dist/src/topology-listener.js.map +1 -1
  99. package/dist/src/utils.d.ts +2 -2
  100. package/dist/src/utils.d.ts.map +1 -1
  101. package/dist/src/utils.js +1 -1
  102. package/dist/src/utils.js.map +1 -1
  103. package/package.json +16 -29
  104. package/src/content-fetching/index.ts +5 -5
  105. package/src/content-routing/index.ts +1 -1
  106. package/src/dual-kad-dht.ts +7 -7
  107. package/src/index.ts +9 -10
  108. package/src/kad-dht.ts +6 -6
  109. package/src/message/index.ts +2 -2
  110. package/src/network.ts +7 -7
  111. package/src/peer-list/index.ts +1 -1
  112. package/src/peer-list/peer-distance-list.ts +1 -1
  113. package/src/peer-routing/index.ts +6 -6
  114. package/src/providers.ts +2 -2
  115. package/src/query/events.ts +4 -4
  116. package/src/query/manager.ts +5 -5
  117. package/src/query/query-path.ts +3 -3
  118. package/src/query/types.ts +1 -1
  119. package/src/query-self.ts +2 -2
  120. package/src/record/index.ts +70 -0
  121. package/src/record/record.proto +20 -0
  122. package/src/record/record.ts +87 -0
  123. package/src/record/selectors.ts +50 -0
  124. package/src/record/utils.ts +46 -0
  125. package/src/record/validators.ts +69 -0
  126. package/src/routing-table/index.ts +6 -6
  127. package/src/routing-table/k-bucket.ts +2 -2
  128. package/src/routing-table/refresh.ts +1 -1
  129. package/src/rpc/handlers/add-provider.ts +2 -2
  130. package/src/rpc/handlers/find-node.ts +3 -3
  131. package/src/rpc/handlers/get-providers.ts +4 -4
  132. package/src/rpc/handlers/get-value.ts +4 -4
  133. package/src/rpc/handlers/ping.ts +1 -1
  134. package/src/rpc/handlers/put-value.ts +3 -3
  135. package/src/rpc/index.ts +2 -2
  136. package/src/topology-listener.ts +4 -6
  137. package/src/utils.ts +3 -3
@@ -1,4 +1,4 @@
1
- import { CodeError } from '@libp2p/interfaces/errors'
1
+ import { CodeError } from '@libp2p/interface/errors'
2
2
  import { logger } from '@libp2p/logger'
3
3
  import { CID } from 'multiformats/cid'
4
4
  import { Message } from '../../message/index.js'
@@ -9,9 +9,9 @@ import {
9
9
  import type { PeerRouting } from '../../peer-routing/index.js'
10
10
  import type { Providers } from '../../providers.js'
11
11
  import type { DHTMessageHandler } from '../index.js'
12
- import type { PeerId } from '@libp2p/interface-peer-id'
13
- import type { PeerInfo } from '@libp2p/interface-peer-info'
14
- import type { PeerStore } from '@libp2p/interface-peer-store'
12
+ import type { PeerId } from '@libp2p/interface/peer-id'
13
+ import type { PeerInfo } from '@libp2p/interface/peer-info'
14
+ import type { PeerStore } from '@libp2p/interface/peer-store'
15
15
  import type { Multiaddr } from '@multiformats/multiaddr'
16
16
 
17
17
  const log = logger('libp2p:kad-dht:rpc:handlers:get-providers')
@@ -1,15 +1,15 @@
1
- import { CodeError } from '@libp2p/interfaces/errors'
1
+ import { CodeError } from '@libp2p/interface/errors'
2
2
  import { logger } from '@libp2p/logger'
3
- import { Libp2pRecord } from '@libp2p/record'
4
3
  import {
5
4
  MAX_RECORD_AGE
6
5
  } from '../../constants.js'
7
6
  import { Message, MESSAGE_TYPE } from '../../message/index.js'
7
+ import { Libp2pRecord } from '../../record/index.js'
8
8
  import { bufferToRecordKey, isPublicKeyKey, fromPublicKeyKey } from '../../utils.js'
9
9
  import type { PeerRouting } from '../../peer-routing/index.js'
10
10
  import type { DHTMessageHandler } from '../index.js'
11
- import type { PeerId } from '@libp2p/interface-peer-id'
12
- import type { PeerStore } from '@libp2p/interface-peer-store'
11
+ import type { PeerId } from '@libp2p/interface/peer-id'
12
+ import type { PeerStore } from '@libp2p/interface/peer-store'
13
13
  import type { Datastore } from 'interface-datastore'
14
14
 
15
15
  const log = logger('libp2p:kad-dht:rpc:handlers:get-value')
@@ -1,7 +1,7 @@
1
1
  import { logger } from '@libp2p/logger'
2
2
  import type { Message } from '../../message/index.js'
3
3
  import type { DHTMessageHandler } from '../index.js'
4
- import type { PeerId } from '@libp2p/interface-peer-id'
4
+ import type { PeerId } from '@libp2p/interface/peer-id'
5
5
 
6
6
  const log = logger('libp2p:kad-dht:rpc:handlers:ping')
7
7
 
@@ -1,11 +1,11 @@
1
- import { CodeError } from '@libp2p/interfaces/errors'
1
+ import { CodeError } from '@libp2p/interface/errors'
2
2
  import { type Logger, logger } from '@libp2p/logger'
3
- import { verifyRecord } from '@libp2p/record/validators'
3
+ import { verifyRecord } from '../../record/validators.js'
4
4
  import { bufferToRecordKey } from '../../utils.js'
5
5
  import type { Validators } from '../../index.js'
6
6
  import type { Message } from '../../message/index.js'
7
7
  import type { DHTMessageHandler } from '../index.js'
8
- import type { PeerId } from '@libp2p/interface-peer-id'
8
+ import type { PeerId } from '@libp2p/interface/peer-id'
9
9
  import type { Datastore } from 'interface-datastore'
10
10
 
11
11
  export interface PutValueHandlerInit {
package/src/rpc/index.ts CHANGED
@@ -12,8 +12,8 @@ import type { Validators } from '../index.js'
12
12
  import type { PeerRouting } from '../peer-routing'
13
13
  import type { Providers } from '../providers'
14
14
  import type { RoutingTable } from '../routing-table'
15
- import type { PeerId } from '@libp2p/interface-peer-id'
16
- import type { IncomingStreamData } from '@libp2p/interface-registrar'
15
+ import type { PeerId } from '@libp2p/interface/peer-id'
16
+ import type { IncomingStreamData } from '@libp2p/interface-internal/registrar'
17
17
 
18
18
  export interface DHTMessageHandler {
19
19
  handle: (peerId: PeerId, msg: Message) => Promise<Message | undefined>
@@ -1,9 +1,8 @@
1
- import { CustomEvent, EventEmitter } from '@libp2p/interfaces/events'
1
+ import { CustomEvent, EventEmitter } from '@libp2p/interface/events'
2
2
  import { logger } from '@libp2p/logger'
3
- import { createTopology } from '@libp2p/topology'
4
3
  import type { KadDHTComponents } from '.'
5
- import type { PeerId } from '@libp2p/interface-peer-id'
6
- import type { Startable } from '@libp2p/interfaces/startable'
4
+ import type { PeerId } from '@libp2p/interface/peer-id'
5
+ import type { Startable } from '@libp2p/interface/startable'
7
6
  import type { Logger } from '@libp2p/logger'
8
7
 
9
8
  export interface TopologyListenerInit {
@@ -51,7 +50,7 @@ export class TopologyListener extends EventEmitter<TopologyListenerEvents> imple
51
50
  this.running = true
52
51
 
53
52
  // register protocol with topology
54
- const topology = createTopology({
53
+ this.registrarId = await this.components.registrar.register(this.protocol, {
55
54
  onConnect: (peerId) => {
56
55
  this.log('observed peer %p with protocol %s', peerId, this.protocol)
57
56
  this.dispatchEvent(new CustomEvent('peer', {
@@ -59,7 +58,6 @@ export class TopologyListener extends EventEmitter<TopologyListenerEvents> imple
59
58
  }))
60
59
  }
61
60
  })
62
- this.registrarId = await this.components.registrar.register(this.protocol, topology)
63
61
  }
64
62
 
65
63
  /**
package/src/utils.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { peerIdFromBytes } from '@libp2p/peer-id'
2
- import { Libp2pRecord } from '@libp2p/record'
3
2
  import { Key } from 'interface-datastore/key'
4
3
  import { sha256 } from 'multiformats/hashes/sha2'
5
4
  import isPrivateIp from 'private-ip'
@@ -7,8 +6,9 @@ import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
7
6
  import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
8
7
  import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
9
8
  import { RECORD_KEY_PREFIX } from './constants.js'
10
- import type { PeerId } from '@libp2p/interface-peer-id'
11
- import type { PeerInfo } from '@libp2p/interface-peer-info'
9
+ import { Libp2pRecord } from './record/index.js'
10
+ import type { PeerId } from '@libp2p/interface/peer-id'
11
+ import type { PeerInfo } from '@libp2p/interface/peer-info'
12
12
 
13
13
  // const IPNS_PREFIX = uint8ArrayFromString('/ipns/')
14
14
  const PK_PREFIX = uint8ArrayFromString('/pk/')