@waku/core 0.0.1 → 0.0.3

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 (134) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/bundle/{index-691c0be6.js → index-a67d7136.js} +1 -1
  3. package/bundle/{index-0a4bdddc.js → index-f7e049ad.js} +1 -1
  4. package/bundle/index.js +24853 -3555
  5. package/bundle/lib/peer_discovery_static_list.js +18 -4
  6. package/bundle/lib/predefined_bootstrap_nodes.js +1 -1
  7. package/bundle/lib/wait_for_remote_peer.js +2 -3
  8. package/bundle/lib/waku_message/topic_only_message.js +2 -3
  9. package/bundle/lib/waku_message/version_0.js +317 -4
  10. package/bundle/{message-e2db79d7.js → message-049c8b67.js} +861 -2
  11. package/bundle/{topic_only_message-34f36fa6.js → topic_only_message-5ad3a869.js} +1 -1
  12. package/dist/index.d.ts +0 -3
  13. package/dist/index.js +0 -3
  14. package/dist/index.js.map +1 -1
  15. package/dist/lib/waku_filter/index.d.ts +2 -2
  16. package/dist/lib/waku_filter/index.js.map +1 -1
  17. package/dist/lib/waku_message/version_0.d.ts +3 -2
  18. package/dist/lib/waku_message/version_0.js +2 -1
  19. package/dist/lib/waku_message/version_0.js.map +1 -1
  20. package/dist/lib/waku_relay/index.d.ts +4 -3
  21. package/dist/lib/waku_relay/index.js.map +1 -1
  22. package/dist/lib/waku_store/index.d.ts +4 -4
  23. package/package.json +4 -123
  24. package/src/index.ts +0 -10
  25. package/src/lib/waku_filter/index.ts +4 -3
  26. package/src/lib/waku_message/version_0.ts +5 -3
  27. package/src/lib/waku_relay/index.ts +4 -3
  28. package/src/lib/waku_store/index.ts +5 -5
  29. package/bundle/crypto-8551d579.js +0 -2585
  30. package/bundle/crypto-b00764b7.js +0 -1772
  31. package/bundle/enr-564d4a51.js +0 -20785
  32. package/bundle/enr-9fc5eed8.js +0 -20786
  33. package/bundle/enr-f6e82a53.js +0 -20785
  34. package/bundle/events-fcbda4dc.js +0 -76
  35. package/bundle/index-02d21809.js +0 -20
  36. package/bundle/index-2ae915be.js +0 -1854
  37. package/bundle/index-a013a259.js +0 -20
  38. package/bundle/index-ba42b4fc.js +0 -862
  39. package/bundle/lib/enr.js +0 -8
  40. package/bundle/lib/peer_discovery_dns.js +0 -5018
  41. package/bundle/lib/utils.js +0 -1
  42. package/bundle/lib/waku_message/version_1.js +0 -463
  43. package/bundle/multiaddr_to_peer_info-c406b1e1.js +0 -19
  44. package/bundle/multiaddr_to_peer_info-fd1de516.js +0 -19
  45. package/bundle/utils-9a3221f2.js +0 -815
  46. package/bundle/version_0-e6fe440c.js +0 -317
  47. package/dist/lib/crypto.d.ts +0 -34
  48. package/dist/lib/crypto.js +0 -79
  49. package/dist/lib/crypto.js.map +0 -1
  50. package/dist/lib/enr/constants.d.ts +0 -4
  51. package/dist/lib/enr/constants.js +0 -8
  52. package/dist/lib/enr/constants.js.map +0 -1
  53. package/dist/lib/enr/enr.d.ts +0 -90
  54. package/dist/lib/enr/enr.js +0 -432
  55. package/dist/lib/enr/enr.js.map +0 -1
  56. package/dist/lib/enr/index.d.ts +0 -5
  57. package/dist/lib/enr/index.js +0 -6
  58. package/dist/lib/enr/index.js.map +0 -1
  59. package/dist/lib/enr/keypair/index.d.ts +0 -8
  60. package/dist/lib/enr/keypair/index.js +0 -53
  61. package/dist/lib/enr/keypair/index.js.map +0 -1
  62. package/dist/lib/enr/keypair/secp256k1.d.ts +0 -13
  63. package/dist/lib/enr/keypair/secp256k1.js +0 -57
  64. package/dist/lib/enr/keypair/secp256k1.js.map +0 -1
  65. package/dist/lib/enr/keypair/types.d.ts +0 -13
  66. package/dist/lib/enr/keypair/types.js +0 -7
  67. package/dist/lib/enr/keypair/types.js.map +0 -1
  68. package/dist/lib/enr/multiaddr_from_fields.d.ts +0 -2
  69. package/dist/lib/enr/multiaddr_from_fields.js +0 -8
  70. package/dist/lib/enr/multiaddr_from_fields.js.map +0 -1
  71. package/dist/lib/enr/multiaddrs_codec.d.ts +0 -3
  72. package/dist/lib/enr/multiaddrs_codec.js +0 -32
  73. package/dist/lib/enr/multiaddrs_codec.js.map +0 -1
  74. package/dist/lib/enr/types.d.ts +0 -8
  75. package/dist/lib/enr/types.js +0 -3
  76. package/dist/lib/enr/types.js.map +0 -1
  77. package/dist/lib/enr/v4.d.ts +0 -3
  78. package/dist/lib/enr/v4.js +0 -14
  79. package/dist/lib/enr/v4.js.map +0 -1
  80. package/dist/lib/enr/waku2_codec.d.ts +0 -8
  81. package/dist/lib/enr/waku2_codec.js +0 -36
  82. package/dist/lib/enr/waku2_codec.js.map +0 -1
  83. package/dist/lib/peer_discovery_dns/dns.d.ts +0 -48
  84. package/dist/lib/peer_discovery_dns/dns.js +0 -158
  85. package/dist/lib/peer_discovery_dns/dns.js.map +0 -1
  86. package/dist/lib/peer_discovery_dns/dns_over_https.d.ts +0 -32
  87. package/dist/lib/peer_discovery_dns/dns_over_https.js +0 -87
  88. package/dist/lib/peer_discovery_dns/dns_over_https.js.map +0 -1
  89. package/dist/lib/peer_discovery_dns/enrtree.d.ts +0 -33
  90. package/dist/lib/peer_discovery_dns/enrtree.js +0 -76
  91. package/dist/lib/peer_discovery_dns/enrtree.js.map +0 -1
  92. package/dist/lib/peer_discovery_dns/fetch_nodes.d.ts +0 -14
  93. package/dist/lib/peer_discovery_dns/fetch_nodes.js +0 -133
  94. package/dist/lib/peer_discovery_dns/fetch_nodes.js.map +0 -1
  95. package/dist/lib/peer_discovery_dns/index.d.ts +0 -30
  96. package/dist/lib/peer_discovery_dns/index.js +0 -54
  97. package/dist/lib/peer_discovery_dns/index.js.map +0 -1
  98. package/dist/lib/utils.d.ts +0 -22
  99. package/dist/lib/utils.js +0 -40
  100. package/dist/lib/utils.js.map +0 -1
  101. package/dist/lib/waku_message/constants.d.ts +0 -12
  102. package/dist/lib/waku_message/constants.js +0 -10
  103. package/dist/lib/waku_message/constants.js.map +0 -1
  104. package/dist/lib/waku_message/ecies.d.ts +0 -17
  105. package/dist/lib/waku_message/ecies.js +0 -126
  106. package/dist/lib/waku_message/ecies.js.map +0 -1
  107. package/dist/lib/waku_message/symmetric.d.ts +0 -3
  108. package/dist/lib/waku_message/symmetric.js +0 -18
  109. package/dist/lib/waku_message/symmetric.js.map +0 -1
  110. package/dist/lib/waku_message/version_1.d.ts +0 -93
  111. package/dist/lib/waku_message/version_1.js +0 -325
  112. package/dist/lib/waku_message/version_1.js.map +0 -1
  113. package/src/lib/crypto.ts +0 -100
  114. package/src/lib/enr/constants.ts +0 -10
  115. package/src/lib/enr/enr.ts +0 -516
  116. package/src/lib/enr/index.ts +0 -5
  117. package/src/lib/enr/keypair/index.ts +0 -76
  118. package/src/lib/enr/keypair/secp256k1.ts +0 -69
  119. package/src/lib/enr/keypair/types.ts +0 -14
  120. package/src/lib/enr/multiaddr_from_fields.ts +0 -18
  121. package/src/lib/enr/multiaddrs_codec.ts +0 -50
  122. package/src/lib/enr/types.ts +0 -11
  123. package/src/lib/enr/v4.ts +0 -22
  124. package/src/lib/enr/waku2_codec.ts +0 -39
  125. package/src/lib/peer_discovery_dns/dns.ts +0 -223
  126. package/src/lib/peer_discovery_dns/dns_over_https.ts +0 -98
  127. package/src/lib/peer_discovery_dns/enrtree.ts +0 -123
  128. package/src/lib/peer_discovery_dns/fetch_nodes.ts +0 -180
  129. package/src/lib/peer_discovery_dns/index.ts +0 -84
  130. package/src/lib/utils.ts +0 -50
  131. package/src/lib/waku_message/constants.ts +0 -10
  132. package/src/lib/waku_message/ecies.ts +0 -194
  133. package/src/lib/waku_message/symmetric.ts +0 -33
  134. package/src/lib/waku_message/version_1.ts +0 -457
@@ -1,317 +0,0 @@
1
- import { d as debug } from './browser-1e1a2f27.js';
2
- import { m as message$1, e as encodeMessage, d as decodeMessage } from './message-e2db79d7.js';
3
-
4
- /* eslint-disable import/export */
5
- var RateLimitProof;
6
- (function (RateLimitProof) {
7
- let _codec;
8
- RateLimitProof.codec = () => {
9
- if (_codec == null) {
10
- _codec = message$1((obj, writer, opts = {}) => {
11
- if (opts.lengthDelimited !== false) {
12
- writer.fork();
13
- }
14
- if (obj.proof != null) {
15
- writer.uint32(10);
16
- writer.bytes(obj.proof);
17
- }
18
- else {
19
- throw new Error('Protocol error: required field "proof" was not found in object');
20
- }
21
- if (obj.merkleRoot != null) {
22
- writer.uint32(18);
23
- writer.bytes(obj.merkleRoot);
24
- }
25
- else {
26
- throw new Error('Protocol error: required field "merkleRoot" was not found in object');
27
- }
28
- if (obj.epoch != null) {
29
- writer.uint32(26);
30
- writer.bytes(obj.epoch);
31
- }
32
- else {
33
- throw new Error('Protocol error: required field "epoch" was not found in object');
34
- }
35
- if (obj.shareX != null) {
36
- writer.uint32(34);
37
- writer.bytes(obj.shareX);
38
- }
39
- else {
40
- throw new Error('Protocol error: required field "shareX" was not found in object');
41
- }
42
- if (obj.shareY != null) {
43
- writer.uint32(42);
44
- writer.bytes(obj.shareY);
45
- }
46
- else {
47
- throw new Error('Protocol error: required field "shareY" was not found in object');
48
- }
49
- if (obj.nullifier != null) {
50
- writer.uint32(50);
51
- writer.bytes(obj.nullifier);
52
- }
53
- else {
54
- throw new Error('Protocol error: required field "nullifier" was not found in object');
55
- }
56
- if (obj.rlnIdentifier != null) {
57
- writer.uint32(58);
58
- writer.bytes(obj.rlnIdentifier);
59
- }
60
- else {
61
- throw new Error('Protocol error: required field "rlnIdentifier" was not found in object');
62
- }
63
- if (opts.lengthDelimited !== false) {
64
- writer.ldelim();
65
- }
66
- }, (reader, length) => {
67
- const obj = {
68
- proof: new Uint8Array(0),
69
- merkleRoot: new Uint8Array(0),
70
- epoch: new Uint8Array(0),
71
- shareX: new Uint8Array(0),
72
- shareY: new Uint8Array(0),
73
- nullifier: new Uint8Array(0),
74
- rlnIdentifier: new Uint8Array(0),
75
- };
76
- const end = length == null ? reader.len : reader.pos + length;
77
- while (reader.pos < end) {
78
- const tag = reader.uint32();
79
- switch (tag >>> 3) {
80
- case 1:
81
- obj.proof = reader.bytes();
82
- break;
83
- case 2:
84
- obj.merkleRoot = reader.bytes();
85
- break;
86
- case 3:
87
- obj.epoch = reader.bytes();
88
- break;
89
- case 4:
90
- obj.shareX = reader.bytes();
91
- break;
92
- case 5:
93
- obj.shareY = reader.bytes();
94
- break;
95
- case 6:
96
- obj.nullifier = reader.bytes();
97
- break;
98
- case 7:
99
- obj.rlnIdentifier = reader.bytes();
100
- break;
101
- default:
102
- reader.skipType(tag & 7);
103
- break;
104
- }
105
- }
106
- if (obj.proof == null) {
107
- throw new Error('Protocol error: value for required field "proof" was not found in protobuf');
108
- }
109
- if (obj.merkleRoot == null) {
110
- throw new Error('Protocol error: value for required field "merkleRoot" was not found in protobuf');
111
- }
112
- if (obj.epoch == null) {
113
- throw new Error('Protocol error: value for required field "epoch" was not found in protobuf');
114
- }
115
- if (obj.shareX == null) {
116
- throw new Error('Protocol error: value for required field "shareX" was not found in protobuf');
117
- }
118
- if (obj.shareY == null) {
119
- throw new Error('Protocol error: value for required field "shareY" was not found in protobuf');
120
- }
121
- if (obj.nullifier == null) {
122
- throw new Error('Protocol error: value for required field "nullifier" was not found in protobuf');
123
- }
124
- if (obj.rlnIdentifier == null) {
125
- throw new Error('Protocol error: value for required field "rlnIdentifier" was not found in protobuf');
126
- }
127
- return obj;
128
- });
129
- }
130
- return _codec;
131
- };
132
- RateLimitProof.encode = (obj) => {
133
- return encodeMessage(obj, RateLimitProof.codec());
134
- };
135
- RateLimitProof.decode = (buf) => {
136
- return decodeMessage(buf, RateLimitProof.codec());
137
- };
138
- })(RateLimitProof || (RateLimitProof = {}));
139
- var WakuMessage;
140
- (function (WakuMessage) {
141
- let _codec;
142
- WakuMessage.codec = () => {
143
- if (_codec == null) {
144
- _codec = message$1((obj, writer, opts = {}) => {
145
- if (opts.lengthDelimited !== false) {
146
- writer.fork();
147
- }
148
- if (obj.payload != null) {
149
- writer.uint32(10);
150
- writer.bytes(obj.payload);
151
- }
152
- if (obj.contentTopic != null) {
153
- writer.uint32(18);
154
- writer.string(obj.contentTopic);
155
- }
156
- if (obj.version != null) {
157
- writer.uint32(24);
158
- writer.uint32(obj.version);
159
- }
160
- if (obj.timestampDeprecated != null) {
161
- writer.uint32(33);
162
- writer.double(obj.timestampDeprecated);
163
- }
164
- if (obj.timestamp != null) {
165
- writer.uint32(80);
166
- writer.sint64(obj.timestamp);
167
- }
168
- if (obj.rateLimitProof != null) {
169
- writer.uint32(170);
170
- RateLimitProof.codec().encode(obj.rateLimitProof, writer);
171
- }
172
- if (opts.lengthDelimited !== false) {
173
- writer.ldelim();
174
- }
175
- }, (reader, length) => {
176
- const obj = {};
177
- const end = length == null ? reader.len : reader.pos + length;
178
- while (reader.pos < end) {
179
- const tag = reader.uint32();
180
- switch (tag >>> 3) {
181
- case 1:
182
- obj.payload = reader.bytes();
183
- break;
184
- case 2:
185
- obj.contentTopic = reader.string();
186
- break;
187
- case 3:
188
- obj.version = reader.uint32();
189
- break;
190
- case 4:
191
- obj.timestampDeprecated = reader.double();
192
- break;
193
- case 10:
194
- obj.timestamp = reader.sint64();
195
- break;
196
- case 21:
197
- obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32());
198
- break;
199
- default:
200
- reader.skipType(tag & 7);
201
- break;
202
- }
203
- }
204
- return obj;
205
- });
206
- }
207
- return _codec;
208
- };
209
- WakuMessage.encode = (obj) => {
210
- return encodeMessage(obj, WakuMessage.codec());
211
- };
212
- WakuMessage.decode = (buf) => {
213
- return decodeMessage(buf, WakuMessage.codec());
214
- };
215
- })(WakuMessage || (WakuMessage = {}));
216
-
217
- var message = /*#__PURE__*/Object.freeze({
218
- __proto__: null,
219
- get RateLimitProof () { return RateLimitProof; },
220
- get WakuMessage () { return WakuMessage; }
221
- });
222
-
223
- const log = debug("waku:message:version-0");
224
- const OneMillion = BigInt(1000000);
225
- const Version = 0;
226
- class MessageV0 {
227
- constructor(proto) {
228
- this.proto = proto;
229
- }
230
- get _rawPayload() {
231
- if (this.proto.payload) {
232
- return new Uint8Array(this.proto.payload);
233
- }
234
- return;
235
- }
236
- get payload() {
237
- return this._rawPayload;
238
- }
239
- get contentTopic() {
240
- return this.proto.contentTopic;
241
- }
242
- get _rawTimestamp() {
243
- return this.proto.timestamp;
244
- }
245
- get timestamp() {
246
- // In the case we receive a value that is bigger than JS's max number,
247
- // we catch the error and return undefined.
248
- try {
249
- if (this.proto.timestamp) {
250
- // nanoseconds 10^-9 to milliseconds 10^-3
251
- const timestamp = this.proto.timestamp / OneMillion;
252
- return new Date(Number(timestamp));
253
- }
254
- if (this.proto.timestampDeprecated) {
255
- return new Date(this.proto.timestampDeprecated * 1000);
256
- }
257
- }
258
- catch (e) {
259
- return;
260
- }
261
- return;
262
- }
263
- get version() {
264
- // https://github.com/status-im/js-waku/issues/921
265
- return this.proto.version ?? 0;
266
- }
267
- get rateLimitProof() {
268
- return this.proto.rateLimitProof;
269
- }
270
- }
271
- class EncoderV0 {
272
- constructor(contentTopic) {
273
- this.contentTopic = contentTopic;
274
- }
275
- async toWire(message$1) {
276
- return WakuMessage.encode(await this.toProtoObj(message$1));
277
- }
278
- async toProtoObj(message) {
279
- const timestamp = message.timestamp ?? new Date();
280
- return {
281
- payload: message.payload,
282
- version: Version,
283
- contentTopic: message.contentTopic ?? this.contentTopic,
284
- timestamp: BigInt(timestamp.valueOf()) * OneMillion,
285
- rateLimitProof: message.rateLimitProof,
286
- };
287
- }
288
- }
289
- class DecoderV0 {
290
- constructor(contentTopic) {
291
- this.contentTopic = contentTopic;
292
- }
293
- fromWireToProtoObj(bytes) {
294
- const protoMessage = WakuMessage.decode(bytes);
295
- log("Message decoded", protoMessage);
296
- return Promise.resolve({
297
- payload: protoMessage.payload ?? undefined,
298
- contentTopic: protoMessage.contentTopic ?? undefined,
299
- version: protoMessage.version ?? undefined,
300
- timestamp: protoMessage.timestamp ?? undefined,
301
- rateLimitProof: protoMessage.rateLimitProof ?? undefined,
302
- });
303
- }
304
- async fromProtoObj(proto) {
305
- // https://github.com/status-im/js-waku/issues/921
306
- if (proto.version === undefined) {
307
- proto.version = 0;
308
- }
309
- if (proto.version !== Version) {
310
- log("Failed to decode due to incorrect version, expected:", Version, ", actual:", proto.version);
311
- return Promise.resolve(undefined);
312
- }
313
- return new MessageV0(proto);
314
- }
315
- }
316
-
317
- export { DecoderV0 as D, EncoderV0 as E, MessageV0 as M, Version as V, WakuMessage as W, message as m };
@@ -1,34 +0,0 @@
1
- import * as secp from "@noble/secp256k1";
2
- export declare function getSubtle(): SubtleCrypto;
3
- export declare const randomBytes: (bytesLength?: number | undefined) => Uint8Array;
4
- export declare const sha256: (...messages: Uint8Array[]) => Promise<Uint8Array>;
5
- /**
6
- * Generate a new private key to be used for asymmetric encryption.
7
- *
8
- * Use {@link getPublicKey} to get the corresponding Public Key.
9
- */
10
- export declare function generatePrivateKey(): Uint8Array;
11
- /**
12
- * Generate a new symmetric key to be used for symmetric encryption.
13
- */
14
- export declare function generateSymmetricKey(): Uint8Array;
15
- /**
16
- * Return the public key for the given private key, to be used for asymmetric
17
- * encryption.
18
- */
19
- export declare const getPublicKey: typeof secp.getPublicKey;
20
- /**
21
- * ECDSA Sign a message with the given private key.
22
- *
23
- * @param message The message to sign, usually a hash.
24
- * @param privateKey The ECDSA private key to use to sign the message.
25
- *
26
- * @returns The signature and the recovery id concatenated.
27
- */
28
- export declare function sign(message: Uint8Array, privateKey: Uint8Array): Promise<Uint8Array>;
29
- export declare function keccak256(input: Uint8Array): Uint8Array;
30
- export declare function compressPublicKey(publicKey: Uint8Array): Uint8Array;
31
- /**
32
- * Verify an ECDSA signature.
33
- */
34
- export declare function verifySignature(signature: Uint8Array, message: Uint8Array | string, publicKey: Uint8Array): boolean;
@@ -1,79 +0,0 @@
1
- import nodeCrypto from "crypto";
2
- import * as secp from "@noble/secp256k1";
3
- import sha3 from "js-sha3";
4
- import { concat } from "./utils.js";
5
- import { Asymmetric, Symmetric } from "./waku_message/constants.js";
6
- const crypto = {
7
- node: nodeCrypto,
8
- web: typeof self === "object" && "crypto" in self ? self.crypto : undefined,
9
- };
10
- export function getSubtle() {
11
- if (crypto.web) {
12
- return crypto.web.subtle;
13
- }
14
- else if (crypto.node) {
15
- return crypto.node.webcrypto.subtle;
16
- }
17
- else {
18
- throw new Error("The environment doesn't have Crypto Subtle API (if in the browser, be sure to use to be in a secure context, ie, https)");
19
- }
20
- }
21
- export const randomBytes = secp.utils.randomBytes;
22
- export const sha256 = secp.utils.sha256;
23
- /**
24
- * Generate a new private key to be used for asymmetric encryption.
25
- *
26
- * Use {@link getPublicKey} to get the corresponding Public Key.
27
- */
28
- export function generatePrivateKey() {
29
- return randomBytes(Asymmetric.keySize);
30
- }
31
- /**
32
- * Generate a new symmetric key to be used for symmetric encryption.
33
- */
34
- export function generateSymmetricKey() {
35
- return randomBytes(Symmetric.keySize);
36
- }
37
- /**
38
- * Return the public key for the given private key, to be used for asymmetric
39
- * encryption.
40
- */
41
- export const getPublicKey = secp.getPublicKey;
42
- /**
43
- * ECDSA Sign a message with the given private key.
44
- *
45
- * @param message The message to sign, usually a hash.
46
- * @param privateKey The ECDSA private key to use to sign the message.
47
- *
48
- * @returns The signature and the recovery id concatenated.
49
- */
50
- export async function sign(message, privateKey) {
51
- const [signature, recoveryId] = await secp.sign(message, privateKey, {
52
- recovered: true,
53
- der: false,
54
- });
55
- return concat([signature, new Uint8Array([recoveryId])], signature.length + 1);
56
- }
57
- export function keccak256(input) {
58
- return new Uint8Array(sha3.keccak256.arrayBuffer(input));
59
- }
60
- export function compressPublicKey(publicKey) {
61
- if (publicKey.length === 64) {
62
- publicKey = concat([new Uint8Array([4]), publicKey], 65);
63
- }
64
- const point = secp.Point.fromHex(publicKey);
65
- return point.toRawBytes(true);
66
- }
67
- /**
68
- * Verify an ECDSA signature.
69
- */
70
- export function verifySignature(signature, message, publicKey) {
71
- try {
72
- const _signature = secp.Signature.fromCompact(signature.slice(0, 64));
73
- return secp.verify(_signature, message, publicKey);
74
- }
75
- catch {
76
- return false;
77
- }
78
- }
79
- //# sourceMappingURL=crypto.js.map
@@ -1 +0,0 @@
1
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
1
- export declare const MAX_RECORD_SIZE = 300;
2
- export declare const ERR_INVALID_ID = "Invalid record id";
3
- export declare const ERR_NO_SIGNATURE = "No valid signature found";
4
- export declare const MULTIADDR_LENGTH_SIZE = 2;
@@ -1,8 +0,0 @@
1
- // Maximum encoded size of an ENR
2
- export const MAX_RECORD_SIZE = 300;
3
- export const ERR_INVALID_ID = "Invalid record id";
4
- export const ERR_NO_SIGNATURE = "No valid signature found";
5
- // The maximum length of byte size of a multiaddr to encode in the `multiaddr` field
6
- // The size is a big endian 16-bit unsigned integer
7
- export const MULTIADDR_LENGTH_SIZE = 2;
8
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/lib/enr/constants.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAC;AAEnC,MAAM,CAAC,MAAM,cAAc,GAAG,mBAAmB,CAAC;AAElD,MAAM,CAAC,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AAE3D,oFAAoF;AACpF,mDAAmD;AACnD,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC"}
@@ -1,90 +0,0 @@
1
- import type { PeerId } from "@libp2p/interface-peer-id";
2
- import { Multiaddr } from "@multiformats/multiaddr";
3
- import { IKeypair, KeypairType } from "./keypair";
4
- import { ENRKey, ENRValue, NodeId, SequenceNumber } from "./types";
5
- import { Waku2 } from "./waku2_codec";
6
- export declare class ENR extends Map<ENRKey, ENRValue> {
7
- static readonly RECORD_PREFIX = "enr:";
8
- seq: SequenceNumber;
9
- signature: Uint8Array | null;
10
- peerId?: PeerId;
11
- private constructor();
12
- static create(kvs?: Record<ENRKey, ENRValue>, seq?: SequenceNumber, signature?: Uint8Array | null): Promise<ENR>;
13
- static createV4(publicKey: Uint8Array, kvs?: Record<ENRKey, ENRValue>): Promise<ENR>;
14
- static createFromPeerId(peerId: PeerId, kvs?: Record<ENRKey, ENRValue>): Promise<ENR>;
15
- static decodeFromValues(decoded: Uint8Array[]): Promise<ENR>;
16
- static decode(encoded: Uint8Array): Promise<ENR>;
17
- static decodeTxt(encoded: string): Promise<ENR>;
18
- set(k: ENRKey, v: ENRValue): this;
19
- get id(): string;
20
- get keypairType(): KeypairType;
21
- get publicKey(): Uint8Array | undefined;
22
- get keypair(): IKeypair | undefined;
23
- get nodeId(): NodeId | undefined;
24
- get ip(): string | undefined;
25
- set ip(ip: string | undefined);
26
- get tcp(): number | undefined;
27
- set tcp(port: number | undefined);
28
- get udp(): number | undefined;
29
- set udp(port: number | undefined);
30
- get ip6(): string | undefined;
31
- set ip6(ip: string | undefined);
32
- get tcp6(): number | undefined;
33
- set tcp6(port: number | undefined);
34
- get udp6(): number | undefined;
35
- set udp6(port: number | undefined);
36
- /**
37
- * Get the `multiaddrs` field from ENR.
38
- *
39
- * This field is used to store multiaddresses that cannot be stored with the current ENR pre-defined keys.
40
- * These can be a multiaddresses that include encapsulation (e.g. wss) or do not use `ip4` nor `ip6` for the host
41
- * address (e.g. `dns4`, `dnsaddr`, etc)..
42
- *
43
- * If the peer information only contains information that can be represented with the ENR pre-defined keys
44
- * (ip, tcp, etc) then the usage of { @link getLocationMultiaddr } should be preferred.
45
- *
46
- * The multiaddresses stored in this field are expected to be location multiaddresses, ie, peer id less.
47
- */
48
- get multiaddrs(): Multiaddr[] | undefined;
49
- /**
50
- * Set the `multiaddrs` field on the ENR.
51
- *
52
- * This field is used to store multiaddresses that cannot be stored with the current ENR pre-defined keys.
53
- * These can be a multiaddresses that include encapsulation (e.g. wss) or do not use `ip4` nor `ip6` for the host
54
- * address (e.g. `dns4`, `dnsaddr`, etc)..
55
- *
56
- * If the peer information only contains information that can be represented with the ENR pre-defined keys
57
- * (ip, tcp, etc) then the usage of { @link setLocationMultiaddr } should be preferred.
58
- * The multiaddresses stored in this field must be location multiaddresses,
59
- * ie, without a peer id.
60
- */
61
- set multiaddrs(multiaddrs: Multiaddr[] | undefined);
62
- getLocationMultiaddr(protocol: "udp" | "udp4" | "udp6" | "tcp" | "tcp4" | "tcp6"): Multiaddr | undefined;
63
- setLocationMultiaddr(multiaddr: Multiaddr): void;
64
- /**
65
- * Returns the full multiaddr from the ENR fields matching the provided
66
- * `protocol` parameter.
67
- * To return full multiaddrs from the `multiaddrs` ENR field,
68
- * use { @link ENR.getFullMultiaddrs }.
69
- *
70
- * @param protocol
71
- */
72
- getFullMultiaddr(protocol: "udp" | "udp4" | "udp6" | "tcp" | "tcp4" | "tcp6"): Multiaddr | undefined;
73
- /**
74
- * Returns the full multiaddrs from the `multiaddrs` ENR field.
75
- */
76
- getFullMultiaddrs(): Multiaddr[];
77
- /**
78
- * Get the `waku2` field from ENR.
79
- */
80
- get waku2(): Waku2 | undefined;
81
- /**
82
- * Set the `waku2` field on the ENR.
83
- */
84
- set waku2(waku2: Waku2 | undefined);
85
- verify(data: Uint8Array, signature: Uint8Array): boolean;
86
- sign(data: Uint8Array, privateKey: Uint8Array): Promise<Uint8Array>;
87
- encodeToValues(privateKey?: Uint8Array): Promise<(ENRKey | ENRValue | number[])[]>;
88
- encode(privateKey?: Uint8Array): Promise<Uint8Array>;
89
- encodeTxt(privateKey?: Uint8Array): Promise<string>;
90
- }