@libp2p/kad-dht 12.0.9 → 12.0.10-3e515f007

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 (71) hide show
  1. package/dist/index.min.js +3 -3
  2. package/dist/src/content-fetching/index.d.ts +1 -2
  3. package/dist/src/content-fetching/index.d.ts.map +1 -1
  4. package/dist/src/content-fetching/index.js +1 -5
  5. package/dist/src/content-fetching/index.js.map +1 -1
  6. package/dist/src/content-routing/index.d.ts.map +1 -1
  7. package/dist/src/content-routing/index.js +9 -7
  8. package/dist/src/content-routing/index.js.map +1 -1
  9. package/dist/src/index.d.ts +1 -1
  10. package/dist/src/index.d.ts.map +1 -1
  11. package/dist/src/index.js +1 -1
  12. package/dist/src/index.js.map +1 -1
  13. package/dist/src/network.d.ts.map +1 -1
  14. package/dist/src/network.js +1 -1
  15. package/dist/src/network.js.map +1 -1
  16. package/dist/src/peer-routing/index.js +1 -1
  17. package/dist/src/peer-routing/index.js.map +1 -1
  18. package/dist/src/query/events.d.ts +1 -1
  19. package/dist/src/query/events.d.ts.map +1 -1
  20. package/dist/src/query/manager.d.ts +1 -1
  21. package/dist/src/query/manager.d.ts.map +1 -1
  22. package/dist/src/query/manager.js +5 -2
  23. package/dist/src/query/manager.js.map +1 -1
  24. package/dist/src/query/query-path.d.ts.map +1 -1
  25. package/dist/src/query/query-path.js +3 -0
  26. package/dist/src/query/query-path.js.map +1 -1
  27. package/dist/src/query-self.d.ts.map +1 -1
  28. package/dist/src/query-self.js +3 -2
  29. package/dist/src/query-self.js.map +1 -1
  30. package/dist/src/record/validators.d.ts +1 -1
  31. package/dist/src/record/validators.d.ts.map +1 -1
  32. package/dist/src/rpc/handlers/get-value.d.ts +1 -1
  33. package/dist/src/rpc/handlers/get-value.d.ts.map +1 -1
  34. package/dist/src/rpc/handlers/get-value.js +1 -1
  35. package/dist/src/rpc/handlers/get-value.js.map +1 -1
  36. package/dist/src/rpc/handlers/put-value.js +1 -1
  37. package/dist/src/rpc/handlers/put-value.js.map +1 -1
  38. package/dist/src/utils.d.ts.map +1 -1
  39. package/dist/src/utils.js +1 -1
  40. package/dist/src/utils.js.map +1 -1
  41. package/package.json +19 -18
  42. package/src/content-fetching/index.ts +1 -6
  43. package/src/content-routing/index.ts +11 -7
  44. package/src/index.ts +1 -1
  45. package/src/network.ts +1 -1
  46. package/src/peer-routing/index.ts +1 -1
  47. package/src/query/events.ts +1 -1
  48. package/src/query/manager.ts +7 -3
  49. package/src/query/query-path.ts +4 -0
  50. package/src/query-self.ts +3 -2
  51. package/src/record/validators.ts +1 -1
  52. package/src/rpc/handlers/get-value.ts +1 -1
  53. package/src/rpc/handlers/put-value.ts +1 -1
  54. package/src/utils.ts +1 -1
  55. package/dist/src/record/index.d.ts +0 -22
  56. package/dist/src/record/index.d.ts.map +0 -1
  57. package/dist/src/record/index.js +0 -53
  58. package/dist/src/record/index.js.map +0 -1
  59. package/dist/src/record/record.d.ts +0 -13
  60. package/dist/src/record/record.d.ts.map +0 -1
  61. package/dist/src/record/record.js +0 -67
  62. package/dist/src/record/record.js.map +0 -1
  63. package/dist/src/record/utils.d.ts +0 -11
  64. package/dist/src/record/utils.d.ts.map +0 -1
  65. package/dist/src/record/utils.js +0 -41
  66. package/dist/src/record/utils.js.map +0 -1
  67. package/dist/typedoc-urls.json +0 -56
  68. package/src/record/index.ts +0 -70
  69. package/src/record/record.proto +0 -20
  70. package/src/record/record.ts +0 -87
  71. package/src/record/utils.ts +0 -46
@@ -1,56 +0,0 @@
1
- {
2
- "codec": "https://libp2p.github.io/js-libp2p/functions/_libp2p_kad_dht.MessageType.codec.html",
3
- "EventTypes": "https://libp2p.github.io/js-libp2p/enums/_libp2p_kad_dht.EventTypes.html",
4
- ".:EventTypes": "https://libp2p.github.io/js-libp2p/enums/_libp2p_kad_dht.EventTypes.html",
5
- "MessageType": "https://libp2p.github.io/js-libp2p/enums/_libp2p_kad_dht.MessageType-1.html",
6
- "Record": "https://libp2p.github.io/js-libp2p/classes/_libp2p_kad_dht.Record.html",
7
- "AddPeerEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.AddPeerEvent.html",
8
- ".:AddPeerEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.AddPeerEvent.html",
9
- "DHTRecord": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.DHTRecord.html",
10
- ".:DHTRecord": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.DHTRecord.html",
11
- "DialPeerEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.DialPeerEvent.html",
12
- ".:DialPeerEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.DialPeerEvent.html",
13
- "FinalPeerEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.FinalPeerEvent.html",
14
- ".:FinalPeerEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.FinalPeerEvent.html",
15
- "KadDHT": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.KadDHT.html",
16
- ".:KadDHT": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.KadDHT.html",
17
- "KadDHTComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.KadDHTComponents.html",
18
- ".:KadDHTComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.KadDHTComponents.html",
19
- "KadDHTInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.KadDHTInit.html",
20
- ".:KadDHTInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.KadDHTInit.html",
21
- "PeerInfoMapper": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.PeerInfoMapper.html",
22
- ".:PeerInfoMapper": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.PeerInfoMapper.html",
23
- "PeerResponseEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.PeerResponseEvent.html",
24
- ".:PeerResponseEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.PeerResponseEvent.html",
25
- "ProviderEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.ProviderEvent.html",
26
- ".:ProviderEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.ProviderEvent.html",
27
- "QueryErrorEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.QueryErrorEvent.html",
28
- ".:QueryErrorEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.QueryErrorEvent.html",
29
- "RoutingTable": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.RoutingTable.html",
30
- ".:RoutingTable": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.RoutingTable.html",
31
- "SelectFn": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.SelectFn.html",
32
- ".:SelectFn": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.SelectFn.html",
33
- "SendQueryEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.SendQueryEvent.html",
34
- ".:SendQueryEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.SendQueryEvent.html",
35
- "SingleKadDHT": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.SingleKadDHT.html",
36
- ".:SingleKadDHT": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.SingleKadDHT.html",
37
- "ValidateFn": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.ValidateFn.html",
38
- ".:ValidateFn": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.ValidateFn.html",
39
- "ValueEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.ValueEvent.html",
40
- ".:ValueEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.ValueEvent.html",
41
- "DHTProgressEvents": "https://libp2p.github.io/js-libp2p/types/_libp2p_kad_dht.DHTProgressEvents.html",
42
- ".:DHTProgressEvents": "https://libp2p.github.io/js-libp2p/types/_libp2p_kad_dht.DHTProgressEvents.html",
43
- "MessageName": "https://libp2p.github.io/js-libp2p/types/_libp2p_kad_dht.MessageName.html",
44
- ".:MessageName": "https://libp2p.github.io/js-libp2p/types/_libp2p_kad_dht.MessageName.html",
45
- "QueryEvent": "https://libp2p.github.io/js-libp2p/types/_libp2p_kad_dht.QueryEvent.html",
46
- ".:QueryEvent": "https://libp2p.github.io/js-libp2p/types/_libp2p_kad_dht.QueryEvent.html",
47
- "Selectors": "https://libp2p.github.io/js-libp2p/types/_libp2p_kad_dht.Selectors.html",
48
- ".:Selectors": "https://libp2p.github.io/js-libp2p/types/_libp2p_kad_dht.Selectors.html",
49
- "Validators": "https://libp2p.github.io/js-libp2p/types/_libp2p_kad_dht.Validators.html",
50
- ".:Validators": "https://libp2p.github.io/js-libp2p/types/_libp2p_kad_dht.Validators.html",
51
- "kadDHT": "https://libp2p.github.io/js-libp2p/functions/_libp2p_kad_dht.kadDHT-1.html",
52
- ".:kadDHT": "https://libp2p.github.io/js-libp2p/functions/_libp2p_kad_dht.kadDHT-1.html",
53
- "passthroughMapper": "https://libp2p.github.io/js-libp2p/functions/_libp2p_kad_dht.passthroughMapper.html",
54
- "removePrivateAddressesMapper": "https://libp2p.github.io/js-libp2p/functions/_libp2p_kad_dht.removePrivateAddressesMapper.html",
55
- "removePublicAddressesMapper": "https://libp2p.github.io/js-libp2p/functions/_libp2p_kad_dht.removePublicAddressesMapper.html"
56
- }
@@ -1,70 +0,0 @@
1
- import {
2
- Record
3
- } from './record.js'
4
- import * as utils from './utils.js'
5
- import type { Uint8ArrayList } from 'uint8arraylist'
6
-
7
- export class Libp2pRecord {
8
- public key: Uint8Array
9
- public value: Uint8Array
10
- public timeReceived: Date
11
-
12
- constructor (key: Uint8Array, value: Uint8Array, timeReceived: Date) {
13
- if (!(key instanceof Uint8Array)) {
14
- throw new Error('key must be a Uint8Array')
15
- }
16
-
17
- if (!(value instanceof Uint8Array)) {
18
- throw new Error('value must be a Uint8Array')
19
- }
20
-
21
- this.key = key
22
- this.value = value
23
- this.timeReceived = timeReceived
24
- }
25
-
26
- serialize (): Uint8Array {
27
- return Record.encode(this.prepareSerialize())
28
- }
29
-
30
- /**
31
- * Return the object format ready to be given to the protobuf library.
32
- */
33
- prepareSerialize (): Record {
34
- return {
35
- key: this.key,
36
- value: this.value,
37
- timeReceived: utils.toRFC3339(this.timeReceived)
38
- }
39
- }
40
-
41
- /**
42
- * Decode a protobuf encoded record
43
- */
44
- static deserialize (raw: Uint8Array | Uint8ArrayList): Libp2pRecord {
45
- const rec = Record.decode(raw)
46
-
47
- return new Libp2pRecord(rec.key, rec.value, new Date(rec.timeReceived))
48
- }
49
-
50
- /**
51
- * Create a record from the raw object returned from the protobuf library
52
- */
53
- static fromDeserialized (obj: Record): Libp2pRecord {
54
- const recvtime = utils.parseRFC3339(obj.timeReceived)
55
-
56
- if (obj.key == null) {
57
- throw new Error('key missing from deserialized object')
58
- }
59
-
60
- if (obj.value == null) {
61
- throw new Error('value missing from deserialized object')
62
- }
63
-
64
- const rec = new Libp2pRecord(
65
- obj.key, obj.value, recvtime
66
- )
67
-
68
- return rec
69
- }
70
- }
@@ -1,20 +0,0 @@
1
- syntax = "proto3";
2
-
3
- // Record represents a dht record that contains a value
4
- // for a key value pair
5
- message Record {
6
- // The key that references this record
7
- bytes key = 1;
8
-
9
- // The actual value this record is storing
10
- bytes value = 2;
11
-
12
- // Note: These fields were removed from the Record message
13
- // hash of the authors public key
14
- // optional bytes author = 3;
15
- // A PKI signature for the key+value+author
16
- // optional bytes signature = 4;
17
-
18
- // Time the record was received, set by receiver
19
- string timeReceived = 5;
20
- }
@@ -1,87 +0,0 @@
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 { encodeMessage, decodeMessage, message } from 'protons-runtime'
8
- import type { Codec } from 'protons-runtime'
9
- import type { Uint8ArrayList } from 'uint8arraylist'
10
-
11
- export interface Record {
12
- key: Uint8Array
13
- value: Uint8Array
14
- timeReceived: string
15
- }
16
-
17
- export namespace Record {
18
- let _codec: Codec<Record>
19
-
20
- export const codec = (): Codec<Record> => {
21
- if (_codec == null) {
22
- _codec = message<Record>((obj, w, opts = {}) => {
23
- if (opts.lengthDelimited !== false) {
24
- w.fork()
25
- }
26
-
27
- if ((obj.key != null && obj.key.byteLength > 0)) {
28
- w.uint32(10)
29
- w.bytes(obj.key)
30
- }
31
-
32
- if ((obj.value != null && obj.value.byteLength > 0)) {
33
- w.uint32(18)
34
- w.bytes(obj.value)
35
- }
36
-
37
- if ((obj.timeReceived != null && obj.timeReceived !== '')) {
38
- w.uint32(42)
39
- w.string(obj.timeReceived)
40
- }
41
-
42
- if (opts.lengthDelimited !== false) {
43
- w.ldelim()
44
- }
45
- }, (reader, length) => {
46
- const obj: any = {
47
- key: new Uint8Array(0),
48
- value: new Uint8Array(0),
49
- timeReceived: ''
50
- }
51
-
52
- const end = length == null ? reader.len : reader.pos + length
53
-
54
- while (reader.pos < end) {
55
- const tag = reader.uint32()
56
-
57
- switch (tag >>> 3) {
58
- case 1:
59
- obj.key = reader.bytes()
60
- break
61
- case 2:
62
- obj.value = reader.bytes()
63
- break
64
- case 5:
65
- obj.timeReceived = reader.string()
66
- break
67
- default:
68
- reader.skipType(tag & 7)
69
- break
70
- }
71
- }
72
-
73
- return obj
74
- })
75
- }
76
-
77
- return _codec
78
- }
79
-
80
- export const encode = (obj: Partial<Record>): Uint8Array => {
81
- return encodeMessage(obj, Record.codec())
82
- }
83
-
84
- export const decode = (buf: Uint8Array | Uint8ArrayList): Record => {
85
- return decodeMessage(buf, Record.codec())
86
- }
87
- }
@@ -1,46 +0,0 @@
1
- /**
2
- * Convert a JavaScript date into an `RFC3339Nano` formatted
3
- * string
4
- */
5
- export function toRFC3339 (time: Date): string {
6
- const year = time.getUTCFullYear()
7
- const month = String(time.getUTCMonth() + 1).padStart(2, '0')
8
- const day = String(time.getUTCDate()).padStart(2, '0')
9
- const hour = String(time.getUTCHours()).padStart(2, '0')
10
- const minute = String(time.getUTCMinutes()).padStart(2, '0')
11
- const seconds = String(time.getUTCSeconds()).padStart(2, '0')
12
- const milliseconds = time.getUTCMilliseconds()
13
- const nanoseconds = String(milliseconds * 1000 * 1000).padStart(9, '0')
14
-
15
- return `${year}-${month}-${day}T${hour}:${minute}:${seconds}.${nanoseconds}Z`
16
- }
17
-
18
- /**
19
- * Parses a date string formatted as `RFC3339Nano` into a
20
- * JavaScript Date object
21
- */
22
- export function parseRFC3339 (time: string): Date {
23
- const rfc3339Matcher = new RegExp(
24
- // 2006-01-02T
25
- '(\\d{4})-(\\d{2})-(\\d{2})T' +
26
- // 15:04:05
27
- '(\\d{2}):(\\d{2}):(\\d{2})' +
28
- // .999999999Z
29
- '\\.(\\d+)Z'
30
- )
31
- const m = String(time).trim().match(rfc3339Matcher)
32
-
33
- if (m == null) {
34
- throw new Error('Invalid format')
35
- }
36
-
37
- const year = parseInt(m[1], 10)
38
- const month = parseInt(m[2], 10) - 1
39
- const date = parseInt(m[3], 10)
40
- const hour = parseInt(m[4], 10)
41
- const minute = parseInt(m[5], 10)
42
- const second = parseInt(m[6], 10)
43
- const millisecond = parseInt(m[7].slice(0, -6), 10)
44
-
45
- return new Date(Date.UTC(year, month, date, hour, minute, second, millisecond))
46
- }