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

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 (54) 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/index.d.ts +1 -1
  7. package/dist/src/index.d.ts.map +1 -1
  8. package/dist/src/index.js +1 -1
  9. package/dist/src/index.js.map +1 -1
  10. package/dist/src/network.d.ts.map +1 -1
  11. package/dist/src/network.js +1 -1
  12. package/dist/src/network.js.map +1 -1
  13. package/dist/src/peer-routing/index.js +1 -1
  14. package/dist/src/peer-routing/index.js.map +1 -1
  15. package/dist/src/query/events.d.ts +1 -1
  16. package/dist/src/query/events.d.ts.map +1 -1
  17. package/dist/src/record/validators.d.ts +1 -1
  18. package/dist/src/record/validators.d.ts.map +1 -1
  19. package/dist/src/rpc/handlers/get-value.d.ts +1 -1
  20. package/dist/src/rpc/handlers/get-value.d.ts.map +1 -1
  21. package/dist/src/rpc/handlers/get-value.js +1 -1
  22. package/dist/src/rpc/handlers/get-value.js.map +1 -1
  23. package/dist/src/rpc/handlers/put-value.js +1 -1
  24. package/dist/src/rpc/handlers/put-value.js.map +1 -1
  25. package/dist/src/utils.d.ts.map +1 -1
  26. package/dist/src/utils.js +1 -1
  27. package/dist/src/utils.js.map +1 -1
  28. package/package.json +19 -18
  29. package/src/content-fetching/index.ts +1 -6
  30. package/src/index.ts +1 -1
  31. package/src/network.ts +1 -1
  32. package/src/peer-routing/index.ts +1 -1
  33. package/src/query/events.ts +1 -1
  34. package/src/record/validators.ts +1 -1
  35. package/src/rpc/handlers/get-value.ts +1 -1
  36. package/src/rpc/handlers/put-value.ts +1 -1
  37. package/src/utils.ts +1 -1
  38. package/dist/src/record/index.d.ts +0 -22
  39. package/dist/src/record/index.d.ts.map +0 -1
  40. package/dist/src/record/index.js +0 -53
  41. package/dist/src/record/index.js.map +0 -1
  42. package/dist/src/record/record.d.ts +0 -13
  43. package/dist/src/record/record.d.ts.map +0 -1
  44. package/dist/src/record/record.js +0 -67
  45. package/dist/src/record/record.js.map +0 -1
  46. package/dist/src/record/utils.d.ts +0 -11
  47. package/dist/src/record/utils.d.ts.map +0 -1
  48. package/dist/src/record/utils.js +0 -41
  49. package/dist/src/record/utils.js.map +0 -1
  50. package/dist/typedoc-urls.json +0 -56
  51. package/src/record/index.ts +0 -70
  52. package/src/record/record.proto +0 -20
  53. package/src/record/record.ts +0 -87
  54. package/src/record/utils.ts +0 -46
@@ -1,22 +0,0 @@
1
- import { Record } from './record.js';
2
- import type { Uint8ArrayList } from 'uint8arraylist';
3
- export declare class Libp2pRecord {
4
- key: Uint8Array;
5
- value: Uint8Array;
6
- timeReceived: Date;
7
- constructor(key: Uint8Array, value: Uint8Array, timeReceived: Date);
8
- serialize(): Uint8Array;
9
- /**
10
- * Return the object format ready to be given to the protobuf library.
11
- */
12
- prepareSerialize(): Record;
13
- /**
14
- * Decode a protobuf encoded record
15
- */
16
- static deserialize(raw: Uint8Array | Uint8ArrayList): Libp2pRecord;
17
- /**
18
- * Create a record from the raw object returned from the protobuf library
19
- */
20
- static fromDeserialized(obj: Record): Libp2pRecord;
21
- }
22
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/record/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACP,MAAM,aAAa,CAAA;AAEpB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,qBAAa,YAAY;IAChB,GAAG,EAAE,UAAU,CAAA;IACf,KAAK,EAAE,UAAU,CAAA;IACjB,YAAY,EAAE,IAAI,CAAA;gBAEZ,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,IAAI;IAcnE,SAAS,IAAK,UAAU;IAIxB;;OAEG;IACH,gBAAgB,IAAK,MAAM;IAQ3B;;OAEG;IACH,MAAM,CAAC,WAAW,CAAE,GAAG,EAAE,UAAU,GAAG,cAAc,GAAG,YAAY;IAMnE;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAAE,GAAG,EAAE,MAAM,GAAG,YAAY;CAiBpD"}
@@ -1,53 +0,0 @@
1
- import { Record } from './record.js';
2
- import * as utils from './utils.js';
3
- export class Libp2pRecord {
4
- key;
5
- value;
6
- timeReceived;
7
- constructor(key, value, timeReceived) {
8
- if (!(key instanceof Uint8Array)) {
9
- throw new Error('key must be a Uint8Array');
10
- }
11
- if (!(value instanceof Uint8Array)) {
12
- throw new Error('value must be a Uint8Array');
13
- }
14
- this.key = key;
15
- this.value = value;
16
- this.timeReceived = timeReceived;
17
- }
18
- serialize() {
19
- return Record.encode(this.prepareSerialize());
20
- }
21
- /**
22
- * Return the object format ready to be given to the protobuf library.
23
- */
24
- prepareSerialize() {
25
- return {
26
- key: this.key,
27
- value: this.value,
28
- timeReceived: utils.toRFC3339(this.timeReceived)
29
- };
30
- }
31
- /**
32
- * Decode a protobuf encoded record
33
- */
34
- static deserialize(raw) {
35
- const rec = Record.decode(raw);
36
- return new Libp2pRecord(rec.key, rec.value, new Date(rec.timeReceived));
37
- }
38
- /**
39
- * Create a record from the raw object returned from the protobuf library
40
- */
41
- static fromDeserialized(obj) {
42
- const recvtime = utils.parseRFC3339(obj.timeReceived);
43
- if (obj.key == null) {
44
- throw new Error('key missing from deserialized object');
45
- }
46
- if (obj.value == null) {
47
- throw new Error('value missing from deserialized object');
48
- }
49
- const rec = new Libp2pRecord(obj.key, obj.value, recvtime);
50
- return rec;
51
- }
52
- }
53
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/record/index.ts"],"names":[],"mappings":"AAAA,OAAO,E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GAAG,CAAC,YAAY,CAAC,CAAA;QAErD,IAAI,GAAG,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAA;QACzD,CAAC;QAED,IAAI,GAAG,CAAC,KAAK,IAAI,IAAI,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAA;QAC3D,CAAC;QAED,MAAM,GAAG,GAAG,IAAI,YAAY,CAC1B,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,EAAE,QAAQ,CAC7B,CAAA;QAED,OAAO,GAAG,CAAA;IACZ,CAAC;CACF"}
@@ -1,13 +0,0 @@
1
- import type { Codec } from 'protons-runtime';
2
- import type { Uint8ArrayList } from 'uint8arraylist';
3
- export interface Record {
4
- key: Uint8Array;
5
- value: Uint8Array;
6
- timeReceived: string;
7
- }
8
- export declare namespace Record {
9
- const codec: () => Codec<Record>;
10
- const encode: (obj: Partial<Record>) => Uint8Array;
11
- const decode: (buf: Uint8Array | Uint8ArrayList) => Record;
12
- }
13
- //# sourceMappingURL=record.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../../src/record/record.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,MAAM,WAAW,MAAM;IACrB,GAAG,EAAE,UAAU,CAAA;IACf,KAAK,EAAE,UAAU,CAAA;IACjB,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,yBAAiB,MAAM,CAAC;IAGf,MAAM,KAAK,QAAO,MAAM,MAAM,CA0DpC,CAAA;IAEM,MAAM,MAAM,QAAS,QAAQ,MAAM,CAAC,KAAG,UAE7C,CAAA;IAEM,MAAM,MAAM,QAAS,UAAU,GAAG,cAAc,KAAG,MAEzD,CAAA;CACF"}
@@ -1,67 +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
- import { encodeMessage, decodeMessage, message } from 'protons-runtime';
7
- export var Record;
8
- (function (Record) {
9
- let _codec;
10
- Record.codec = () => {
11
- if (_codec == null) {
12
- _codec = message((obj, w, opts = {}) => {
13
- if (opts.lengthDelimited !== false) {
14
- w.fork();
15
- }
16
- if ((obj.key != null && obj.key.byteLength > 0)) {
17
- w.uint32(10);
18
- w.bytes(obj.key);
19
- }
20
- if ((obj.value != null && obj.value.byteLength > 0)) {
21
- w.uint32(18);
22
- w.bytes(obj.value);
23
- }
24
- if ((obj.timeReceived != null && obj.timeReceived !== '')) {
25
- w.uint32(42);
26
- w.string(obj.timeReceived);
27
- }
28
- if (opts.lengthDelimited !== false) {
29
- w.ldelim();
30
- }
31
- }, (reader, length) => {
32
- const obj = {
33
- key: new Uint8Array(0),
34
- value: new Uint8Array(0),
35
- timeReceived: ''
36
- };
37
- const end = length == null ? reader.len : reader.pos + length;
38
- while (reader.pos < end) {
39
- const tag = reader.uint32();
40
- switch (tag >>> 3) {
41
- case 1:
42
- obj.key = reader.bytes();
43
- break;
44
- case 2:
45
- obj.value = reader.bytes();
46
- break;
47
- case 5:
48
- obj.timeReceived = reader.string();
49
- break;
50
- default:
51
- reader.skipType(tag & 7);
52
- break;
53
- }
54
- }
55
- return obj;
56
- });
57
- }
58
- return _codec;
59
- };
60
- Record.encode = (obj) => {
61
- return encodeMessage(obj, Record.codec());
62
- };
63
- Record.decode = (buf) => {
64
- return decodeMessage(buf, Record.codec());
65
- };
66
- })(Record || (Record = {}));
67
- //# sourceMappingURL=record.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"record.js","sourceRoot":"","sources":["../../../src/record/record.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,+B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O,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAA;IAC3C,CAAC,CAAA;AACH,CAAC,EAtEgB,MAAM,KAAN,MAAM,QAsEtB"}
@@ -1,11 +0,0 @@
1
- /**
2
- * Convert a JavaScript date into an `RFC3339Nano` formatted
3
- * string
4
- */
5
- export declare function toRFC3339(time: Date): string;
6
- /**
7
- * Parses a date string formatted as `RFC3339Nano` into a
8
- * JavaScript Date object
9
- */
10
- export declare function parseRFC3339(time: string): Date;
11
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/record/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,SAAS,CAAE,IAAI,EAAE,IAAI,GAAG,MAAM,CAW7C;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAwBhD"}
@@ -1,41 +0,0 @@
1
- /**
2
- * Convert a JavaScript date into an `RFC3339Nano` formatted
3
- * string
4
- */
5
- export function toRFC3339(time) {
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
- return `${year}-${month}-${day}T${hour}:${minute}:${seconds}.${nanoseconds}Z`;
15
- }
16
- /**
17
- * Parses a date string formatted as `RFC3339Nano` into a
18
- * JavaScript Date object
19
- */
20
- export function parseRFC3339(time) {
21
- const rfc3339Matcher = new RegExp(
22
- // 2006-01-02T
23
- '(\\d{4})-(\\d{2})-(\\d{2})T' +
24
- // 15:04:05
25
- '(\\d{2}):(\\d{2}):(\\d{2})' +
26
- // .999999999Z
27
- '\\.(\\d+)Z');
28
- const m = String(time).trim().match(rfc3339Matcher);
29
- if (m == null) {
30
- throw new Error('Invalid format');
31
- }
32
- const year = parseInt(m[1], 10);
33
- const month = parseInt(m[2], 10) - 1;
34
- const date = parseInt(m[3], 10);
35
- const hour = parseInt(m[4], 10);
36
- const minute = parseInt(m[5], 10);
37
- const second = parseInt(m[6], 10);
38
- const millisecond = parseInt(m[7].slice(0, -6), 10);
39
- return new Date(Date.UTC(year, month, date, hour, minute, second, millisecond));
40
- }
41
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/record/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAE,IAAU;IACnC,MAAM,IAAI,GAAG,IAAI,CAAC,cAAc,EAAE,CAAA;IAClC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IAC7D,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IACtD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IACxD,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IAC5D,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IAC7D,MAAM,YAAY,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAA;IAC9C,MAAM,WAAW,GAAG,MAAM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AE,EAAE,CAAC,CAAA;IAEnD,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAA;AACjF,CAAC"}
@@ -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
- }