@waku/core 0.0.1
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.
- package/CHANGELOG.md +614 -0
- package/README.md +56 -0
- package/bundle/browser-1e1a2f27.js +722 -0
- package/bundle/crypto-8551d579.js +2585 -0
- package/bundle/crypto-b00764b7.js +1772 -0
- package/bundle/enr-564d4a51.js +20785 -0
- package/bundle/enr-9fc5eed8.js +20786 -0
- package/bundle/enr-f6e82a53.js +20785 -0
- package/bundle/events-158407bb.js +1929 -0
- package/bundle/events-fcbda4dc.js +76 -0
- package/bundle/index-02d21809.js +20 -0
- package/bundle/index-0a4bdddc.js +2976 -0
- package/bundle/index-2ae915be.js +1854 -0
- package/bundle/index-64ce43f0.js +69 -0
- package/bundle/index-691c0be6.js +4059 -0
- package/bundle/index-a013a259.js +20 -0
- package/bundle/index-ba42b4fc.js +862 -0
- package/bundle/index.js +13428 -0
- package/bundle/lib/enr.js +8 -0
- package/bundle/lib/peer_discovery_dns.js +5018 -0
- package/bundle/lib/peer_discovery_static_list.js +75 -0
- package/bundle/lib/predefined_bootstrap_nodes.js +59 -0
- package/bundle/lib/utils.js +1 -0
- package/bundle/lib/wait_for_remote_peer.js +327 -0
- package/bundle/lib/waku_message/topic_only_message.js +4 -0
- package/bundle/lib/waku_message/version_0.js +4 -0
- package/bundle/lib/waku_message/version_1.js +463 -0
- package/bundle/message-e2db79d7.js +8393 -0
- package/bundle/multiaddr_to_peer_info-c406b1e1.js +19 -0
- package/bundle/multiaddr_to_peer_info-fd1de516.js +19 -0
- package/bundle/random_subset-75d1c511.js +26 -0
- package/bundle/topic_only_message-34f36fa6.js +82 -0
- package/bundle/utils-9a3221f2.js +815 -0
- package/bundle/version_0-e6fe440c.js +317 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/constants.d.ts +4 -0
- package/dist/lib/constants.js +5 -0
- package/dist/lib/constants.js.map +1 -0
- package/dist/lib/crypto.d.ts +34 -0
- package/dist/lib/crypto.js +79 -0
- package/dist/lib/crypto.js.map +1 -0
- package/dist/lib/enr/constants.d.ts +4 -0
- package/dist/lib/enr/constants.js +8 -0
- package/dist/lib/enr/constants.js.map +1 -0
- package/dist/lib/enr/enr.d.ts +90 -0
- package/dist/lib/enr/enr.js +432 -0
- package/dist/lib/enr/enr.js.map +1 -0
- package/dist/lib/enr/index.d.ts +5 -0
- package/dist/lib/enr/index.js +6 -0
- package/dist/lib/enr/index.js.map +1 -0
- package/dist/lib/enr/keypair/index.d.ts +8 -0
- package/dist/lib/enr/keypair/index.js +53 -0
- package/dist/lib/enr/keypair/index.js.map +1 -0
- package/dist/lib/enr/keypair/secp256k1.d.ts +13 -0
- package/dist/lib/enr/keypair/secp256k1.js +57 -0
- package/dist/lib/enr/keypair/secp256k1.js.map +1 -0
- package/dist/lib/enr/keypair/types.d.ts +13 -0
- package/dist/lib/enr/keypair/types.js +7 -0
- package/dist/lib/enr/keypair/types.js.map +1 -0
- package/dist/lib/enr/multiaddr_from_fields.d.ts +2 -0
- package/dist/lib/enr/multiaddr_from_fields.js +8 -0
- package/dist/lib/enr/multiaddr_from_fields.js.map +1 -0
- package/dist/lib/enr/multiaddrs_codec.d.ts +3 -0
- package/dist/lib/enr/multiaddrs_codec.js +32 -0
- package/dist/lib/enr/multiaddrs_codec.js.map +1 -0
- package/dist/lib/enr/types.d.ts +8 -0
- package/dist/lib/enr/types.js +3 -0
- package/dist/lib/enr/types.js.map +1 -0
- package/dist/lib/enr/v4.d.ts +3 -0
- package/dist/lib/enr/v4.js +14 -0
- package/dist/lib/enr/v4.js.map +1 -0
- package/dist/lib/enr/waku2_codec.d.ts +8 -0
- package/dist/lib/enr/waku2_codec.js +36 -0
- package/dist/lib/enr/waku2_codec.js.map +1 -0
- package/dist/lib/group_by.d.ts +3 -0
- package/dist/lib/group_by.js +13 -0
- package/dist/lib/group_by.js.map +1 -0
- package/dist/lib/multiaddr_to_peer_info.d.ts +3 -0
- package/dist/lib/multiaddr_to_peer_info.js +15 -0
- package/dist/lib/multiaddr_to_peer_info.js.map +1 -0
- package/dist/lib/peer_discovery_dns/dns.d.ts +48 -0
- package/dist/lib/peer_discovery_dns/dns.js +158 -0
- package/dist/lib/peer_discovery_dns/dns.js.map +1 -0
- package/dist/lib/peer_discovery_dns/dns_over_https.d.ts +32 -0
- package/dist/lib/peer_discovery_dns/dns_over_https.js +87 -0
- package/dist/lib/peer_discovery_dns/dns_over_https.js.map +1 -0
- package/dist/lib/peer_discovery_dns/enrtree.d.ts +33 -0
- package/dist/lib/peer_discovery_dns/enrtree.js +76 -0
- package/dist/lib/peer_discovery_dns/enrtree.js.map +1 -0
- package/dist/lib/peer_discovery_dns/fetch_nodes.d.ts +14 -0
- package/dist/lib/peer_discovery_dns/fetch_nodes.js +133 -0
- package/dist/lib/peer_discovery_dns/fetch_nodes.js.map +1 -0
- package/dist/lib/peer_discovery_dns/index.d.ts +30 -0
- package/dist/lib/peer_discovery_dns/index.js +54 -0
- package/dist/lib/peer_discovery_dns/index.js.map +1 -0
- package/dist/lib/peer_discovery_static_list.d.ts +44 -0
- package/dist/lib/peer_discovery_static_list.js +72 -0
- package/dist/lib/peer_discovery_static_list.js.map +1 -0
- package/dist/lib/predefined_bootstrap_nodes.d.ts +35 -0
- package/dist/lib/predefined_bootstrap_nodes.js +56 -0
- package/dist/lib/predefined_bootstrap_nodes.js.map +1 -0
- package/dist/lib/push_or_init_map.d.ts +1 -0
- package/dist/lib/push_or_init_map.js +9 -0
- package/dist/lib/push_or_init_map.js.map +1 -0
- package/dist/lib/random_subset.d.ts +4 -0
- package/dist/lib/random_subset.js +25 -0
- package/dist/lib/random_subset.js.map +1 -0
- package/dist/lib/select_connection.d.ts +2 -0
- package/dist/lib/select_connection.js +19 -0
- package/dist/lib/select_connection.js.map +1 -0
- package/dist/lib/select_peer.d.ts +15 -0
- package/dist/lib/select_peer.js +59 -0
- package/dist/lib/select_peer.js.map +1 -0
- package/dist/lib/to_proto_message.d.ts +3 -0
- package/dist/lib/to_proto_message.js +11 -0
- package/dist/lib/to_proto_message.js.map +1 -0
- package/dist/lib/utils.d.ts +22 -0
- package/dist/lib/utils.js +40 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/lib/wait_for_remote_peer.d.ts +22 -0
- package/dist/lib/wait_for_remote_peer.js +113 -0
- package/dist/lib/wait_for_remote_peer.js.map +1 -0
- package/dist/lib/waku.d.ts +61 -0
- package/dist/lib/waku.js +174 -0
- package/dist/lib/waku.js.map +1 -0
- package/dist/lib/waku_filter/filter_rpc.d.ts +25 -0
- package/dist/lib/waku_filter/filter_rpc.js +44 -0
- package/dist/lib/waku_filter/filter_rpc.js.map +1 -0
- package/dist/lib/waku_filter/index.d.ts +50 -0
- package/dist/lib/waku_filter/index.js +181 -0
- package/dist/lib/waku_filter/index.js.map +1 -0
- package/dist/lib/waku_light_push/index.d.ts +38 -0
- package/dist/lib/waku_light_push/index.js +83 -0
- package/dist/lib/waku_light_push/index.js.map +1 -0
- package/dist/lib/waku_light_push/push_rpc.d.ts +11 -0
- package/dist/lib/waku_light_push/push_rpc.js +31 -0
- package/dist/lib/waku_light_push/push_rpc.js.map +1 -0
- package/dist/lib/waku_message/constants.d.ts +12 -0
- package/dist/lib/waku_message/constants.js +10 -0
- package/dist/lib/waku_message/constants.js.map +1 -0
- package/dist/lib/waku_message/ecies.d.ts +17 -0
- package/dist/lib/waku_message/ecies.js +126 -0
- package/dist/lib/waku_message/ecies.js.map +1 -0
- package/dist/lib/waku_message/symmetric.d.ts +3 -0
- package/dist/lib/waku_message/symmetric.js +18 -0
- package/dist/lib/waku_message/symmetric.js.map +1 -0
- package/dist/lib/waku_message/topic_only_message.d.ts +15 -0
- package/dist/lib/waku_message/topic_only_message.js +31 -0
- package/dist/lib/waku_message/topic_only_message.js.map +1 -0
- package/dist/lib/waku_message/version_0.d.ts +26 -0
- package/dist/lib/waku_message/version_0.js +96 -0
- package/dist/lib/waku_message/version_0.js.map +1 -0
- package/dist/lib/waku_message/version_1.d.ts +93 -0
- package/dist/lib/waku_message/version_1.js +325 -0
- package/dist/lib/waku_message/version_1.js.map +1 -0
- package/dist/lib/waku_relay/constants.d.ts +63 -0
- package/dist/lib/waku_relay/constants.js +67 -0
- package/dist/lib/waku_relay/constants.js.map +1 -0
- package/dist/lib/waku_relay/index.d.ts +65 -0
- package/dist/lib/waku_relay/index.js +111 -0
- package/dist/lib/waku_relay/index.js.map +1 -0
- package/dist/lib/waku_store/history_rpc.d.ts +27 -0
- package/dist/lib/waku_store/history_rpc.js +71 -0
- package/dist/lib/waku_store/history_rpc.js.map +1 -0
- package/dist/lib/waku_store/index.d.ts +126 -0
- package/dist/lib/waku_store/index.js +218 -0
- package/dist/lib/waku_store/index.js.map +1 -0
- package/dist/proto/filter.d.ts +65 -0
- package/dist/proto/filter.js +425 -0
- package/dist/proto/filter.js.map +1 -0
- package/dist/proto/light_push.d.ts +57 -0
- package/dist/proto/light_push.js +369 -0
- package/dist/proto/light_push.js.map +1 -0
- package/dist/proto/message.d.ts +29 -0
- package/dist/proto/message.js +215 -0
- package/dist/proto/message.js.map +1 -0
- package/dist/proto/store.d.ts +104 -0
- package/dist/proto/store.js +602 -0
- package/dist/proto/store.js.map +1 -0
- package/dist/proto/topic_only_message.d.ts +10 -0
- package/dist/proto/topic_only_message.js +46 -0
- package/dist/proto/topic_only_message.js.map +1 -0
- package/package.json +292 -0
- package/src/index.ts +33 -0
- package/src/lib/constants.ts +4 -0
- package/src/lib/crypto.ts +100 -0
- package/src/lib/enr/constants.ts +10 -0
- package/src/lib/enr/enr.ts +516 -0
- package/src/lib/enr/index.ts +5 -0
- package/src/lib/enr/keypair/index.ts +76 -0
- package/src/lib/enr/keypair/secp256k1.ts +69 -0
- package/src/lib/enr/keypair/types.ts +14 -0
- package/src/lib/enr/multiaddr_from_fields.ts +18 -0
- package/src/lib/enr/multiaddrs_codec.ts +50 -0
- package/src/lib/enr/types.ts +11 -0
- package/src/lib/enr/v4.ts +22 -0
- package/src/lib/enr/waku2_codec.ts +39 -0
- package/src/lib/group_by.ts +14 -0
- package/src/lib/multiaddr_to_peer_info.ts +17 -0
- package/src/lib/peer_discovery_dns/dns.ts +223 -0
- package/src/lib/peer_discovery_dns/dns_over_https.ts +98 -0
- package/src/lib/peer_discovery_dns/enrtree.ts +123 -0
- package/src/lib/peer_discovery_dns/fetch_nodes.ts +180 -0
- package/src/lib/peer_discovery_dns/index.ts +84 -0
- package/src/lib/peer_discovery_static_list.ts +118 -0
- package/src/lib/predefined_bootstrap_nodes.ts +72 -0
- package/src/lib/push_or_init_map.ts +13 -0
- package/src/lib/random_subset.ts +30 -0
- package/src/lib/select_connection.ts +24 -0
- package/src/lib/select_peer.ts +77 -0
- package/src/lib/to_proto_message.ts +15 -0
- package/src/lib/utils.ts +50 -0
- package/src/lib/wait_for_remote_peer.ts +151 -0
- package/src/lib/waku.ts +258 -0
- package/src/lib/waku_filter/filter_rpc.ts +57 -0
- package/src/lib/waku_filter/index.ts +291 -0
- package/src/lib/waku_light_push/index.ts +137 -0
- package/src/lib/waku_light_push/push_rpc.ts +39 -0
- package/src/lib/waku_message/constants.ts +10 -0
- package/src/lib/waku_message/ecies.ts +194 -0
- package/src/lib/waku_message/symmetric.ts +33 -0
- package/src/lib/waku_message/topic_only_message.ts +40 -0
- package/src/lib/waku_message/version_0.ts +121 -0
- package/src/lib/waku_message/version_1.ts +457 -0
- package/src/lib/waku_relay/constants.ts +77 -0
- package/src/lib/waku_relay/index.ts +189 -0
- package/src/lib/waku_store/history_rpc.ts +94 -0
- package/src/lib/waku_store/index.ts +372 -0
- package/src/proto/filter.ts +602 -0
- package/src/proto/light_push.ts +526 -0
- package/src/proto/message.ts +304 -0
- package/src/proto/store.ts +844 -0
- package/src/proto/topic_only_message.ts +67 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
import type { Decoder, Encoder, Message, ProtoMessage, RateLimitProof } from "@waku/interfaces";
|
2
|
+
import * as proto from "../../proto/message";
|
3
|
+
export declare const Version = 0;
|
4
|
+
export declare class MessageV0 implements Message {
|
5
|
+
protected proto: proto.WakuMessage;
|
6
|
+
constructor(proto: proto.WakuMessage);
|
7
|
+
get _rawPayload(): Uint8Array | undefined;
|
8
|
+
get payload(): Uint8Array | undefined;
|
9
|
+
get contentTopic(): string | undefined;
|
10
|
+
get _rawTimestamp(): bigint | undefined;
|
11
|
+
get timestamp(): Date | undefined;
|
12
|
+
get version(): number;
|
13
|
+
get rateLimitProof(): RateLimitProof | undefined;
|
14
|
+
}
|
15
|
+
export declare class EncoderV0 implements Encoder {
|
16
|
+
contentTopic: string;
|
17
|
+
constructor(contentTopic: string);
|
18
|
+
toWire(message: Partial<Message>): Promise<Uint8Array>;
|
19
|
+
toProtoObj(message: Partial<Message>): Promise<ProtoMessage>;
|
20
|
+
}
|
21
|
+
export declare class DecoderV0 implements Decoder<MessageV0> {
|
22
|
+
contentTopic: string;
|
23
|
+
constructor(contentTopic: string);
|
24
|
+
fromWireToProtoObj(bytes: Uint8Array): Promise<ProtoMessage | undefined>;
|
25
|
+
fromProtoObj(proto: ProtoMessage): Promise<MessageV0 | undefined>;
|
26
|
+
}
|
@@ -0,0 +1,96 @@
|
|
1
|
+
import debug from "debug";
|
2
|
+
import * as proto from "../../proto/message.js";
|
3
|
+
const log = debug("waku:message:version-0");
|
4
|
+
const OneMillion = BigInt(1000000);
|
5
|
+
export const Version = 0;
|
6
|
+
export class MessageV0 {
|
7
|
+
constructor(proto) {
|
8
|
+
this.proto = proto;
|
9
|
+
}
|
10
|
+
get _rawPayload() {
|
11
|
+
if (this.proto.payload) {
|
12
|
+
return new Uint8Array(this.proto.payload);
|
13
|
+
}
|
14
|
+
return;
|
15
|
+
}
|
16
|
+
get payload() {
|
17
|
+
return this._rawPayload;
|
18
|
+
}
|
19
|
+
get contentTopic() {
|
20
|
+
return this.proto.contentTopic;
|
21
|
+
}
|
22
|
+
get _rawTimestamp() {
|
23
|
+
return this.proto.timestamp;
|
24
|
+
}
|
25
|
+
get timestamp() {
|
26
|
+
// In the case we receive a value that is bigger than JS's max number,
|
27
|
+
// we catch the error and return undefined.
|
28
|
+
try {
|
29
|
+
if (this.proto.timestamp) {
|
30
|
+
// nanoseconds 10^-9 to milliseconds 10^-3
|
31
|
+
const timestamp = this.proto.timestamp / OneMillion;
|
32
|
+
return new Date(Number(timestamp));
|
33
|
+
}
|
34
|
+
if (this.proto.timestampDeprecated) {
|
35
|
+
return new Date(this.proto.timestampDeprecated * 1000);
|
36
|
+
}
|
37
|
+
}
|
38
|
+
catch (e) {
|
39
|
+
return;
|
40
|
+
}
|
41
|
+
return;
|
42
|
+
}
|
43
|
+
get version() {
|
44
|
+
// https://github.com/status-im/js-waku/issues/921
|
45
|
+
return this.proto.version ?? 0;
|
46
|
+
}
|
47
|
+
get rateLimitProof() {
|
48
|
+
return this.proto.rateLimitProof;
|
49
|
+
}
|
50
|
+
}
|
51
|
+
export class EncoderV0 {
|
52
|
+
constructor(contentTopic) {
|
53
|
+
this.contentTopic = contentTopic;
|
54
|
+
}
|
55
|
+
async toWire(message) {
|
56
|
+
return proto.WakuMessage.encode(await this.toProtoObj(message));
|
57
|
+
}
|
58
|
+
async toProtoObj(message) {
|
59
|
+
const timestamp = message.timestamp ?? new Date();
|
60
|
+
return {
|
61
|
+
payload: message.payload,
|
62
|
+
version: Version,
|
63
|
+
contentTopic: message.contentTopic ?? this.contentTopic,
|
64
|
+
timestamp: BigInt(timestamp.valueOf()) * OneMillion,
|
65
|
+
rateLimitProof: message.rateLimitProof,
|
66
|
+
};
|
67
|
+
}
|
68
|
+
}
|
69
|
+
export class DecoderV0 {
|
70
|
+
constructor(contentTopic) {
|
71
|
+
this.contentTopic = contentTopic;
|
72
|
+
}
|
73
|
+
fromWireToProtoObj(bytes) {
|
74
|
+
const protoMessage = proto.WakuMessage.decode(bytes);
|
75
|
+
log("Message decoded", protoMessage);
|
76
|
+
return Promise.resolve({
|
77
|
+
payload: protoMessage.payload ?? undefined,
|
78
|
+
contentTopic: protoMessage.contentTopic ?? undefined,
|
79
|
+
version: protoMessage.version ?? undefined,
|
80
|
+
timestamp: protoMessage.timestamp ?? undefined,
|
81
|
+
rateLimitProof: protoMessage.rateLimitProof ?? undefined,
|
82
|
+
});
|
83
|
+
}
|
84
|
+
async fromProtoObj(proto) {
|
85
|
+
// https://github.com/status-im/js-waku/issues/921
|
86
|
+
if (proto.version === undefined) {
|
87
|
+
proto.version = 0;
|
88
|
+
}
|
89
|
+
if (proto.version !== Version) {
|
90
|
+
log("Failed to decode due to incorrect version, expected:", Version, ", actual:", proto.version);
|
91
|
+
return Promise.resolve(undefined);
|
92
|
+
}
|
93
|
+
return new MessageV0(proto);
|
94
|
+
}
|
95
|
+
}
|
96
|
+
//# sourceMappingURL=version_0.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"version_0.js","sourceRoot":"","sources":["../../../src/lib/waku_message/version_0.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,KAAK,MAAM,qBAAqB,CAAC;AAE7C,MAAM,GAAG,GAAG,KAAK,CAAC,wBAAwB,CAAC,CAAC;AAE5C,MAAM,UAAU,GAAG,MAAM,CAAC,OAAS,CAAC,CAAC;AACrC,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAC;AAEzB,MAAM,OAAO,SAAS;IACpB,YAAsB,KAAwB;QAAxB,UAAK,GAAL,KAAK,CAAmB;IAAG,CAAC;IAElD,IAAI,WAAW;QACb,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;YACtB,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;SAC3C;QACD,OAAO;IACT,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC;IACjC,CAAC;IAED,I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MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,GAAG,UAAU;YACnD,cAAc,EAAE,OAAO,CAAC,cAAc;SACvC,CAAC;IACJ,CAAC;CACF;AAED,MAAM,OAAO,SAAS;IACpB,YAAmB,YAAoB;QAApB,iBAAY,GAAZ,YAAY,CAAQ;IAAG,CAAC;IAE3C,kBAAkB,CAAC,KAAiB;QAClC,MAAM,YAAY,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACrD,GAAG,CAAC,iBAAiB,EAAE,YAAY,CAAC,CAAC;QACrC,OAAO,OAAO,CAAC,OAAO,CAAC;YACrB,OAAO,EAAE,YAAY,CAAC,OAAO,IAAI,SAAS;YAC1C,YAAY,EAAE,YAAY,CAAC,YAAY,IAAI,SAAS;YACpD,OAAO,EAAE,YAAY,CAAC,OAAO,IAAI,SAAS;YAC1C,SAAS,EAAE,YAAY,CAAC,SAAS,IAAI,SAAS;YAC9C,cAAc,EAAE,YAAY,CAAC,cAAc,IAAI,SAAS;SACzD,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,KAAmB;QACpC,kDAAkD;QAClD,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,EAAE;YAC/B,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC;SACnB;QAED,IAAI,KAAK,CAAC,OAAO,KAAK,OAAO,EAAE;YAC7B,GAAG,CACD,sDAAsD,EACtD,OAAO,EACP,WAAW,EACX,KAAK,CAAC,OAAO,CACd,CAAC;YACF,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;SACnC;QAED,OAAO,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;CACF"}
|
@@ -0,0 +1,93 @@
|
|
1
|
+
import type { Decoder, Encoder, Message, ProtoMessage } from "@waku/interfaces";
|
2
|
+
import * as proto from "../../proto/message";
|
3
|
+
import { DecoderV0, MessageV0 } from "./version_0";
|
4
|
+
export declare const Version = 1;
|
5
|
+
export declare type Signature = {
|
6
|
+
signature: Uint8Array;
|
7
|
+
publicKey: Uint8Array | undefined;
|
8
|
+
};
|
9
|
+
export declare class MessageV1 extends MessageV0 implements Message {
|
10
|
+
signature?: Uint8Array | undefined;
|
11
|
+
signaturePublicKey?: Uint8Array | undefined;
|
12
|
+
private readonly _decodedPayload;
|
13
|
+
constructor(proto: proto.WakuMessage, decodedPayload: Uint8Array, signature?: Uint8Array | undefined, signaturePublicKey?: Uint8Array | undefined);
|
14
|
+
get payload(): Uint8Array;
|
15
|
+
}
|
16
|
+
export declare class AsymEncoder implements Encoder {
|
17
|
+
contentTopic: string;
|
18
|
+
private publicKey;
|
19
|
+
private sigPrivKey?;
|
20
|
+
constructor(contentTopic: string, publicKey: Uint8Array, sigPrivKey?: Uint8Array | undefined);
|
21
|
+
toWire(message: Partial<Message>): Promise<Uint8Array | undefined>;
|
22
|
+
toProtoObj(message: Partial<Message>): Promise<ProtoMessage | undefined>;
|
23
|
+
}
|
24
|
+
export declare class SymEncoder implements Encoder {
|
25
|
+
contentTopic: string;
|
26
|
+
private symKey;
|
27
|
+
private sigPrivKey?;
|
28
|
+
constructor(contentTopic: string, symKey: Uint8Array, sigPrivKey?: Uint8Array | undefined);
|
29
|
+
toWire(message: Partial<Message>): Promise<Uint8Array | undefined>;
|
30
|
+
toProtoObj(message: Partial<Message>): Promise<ProtoMessage | undefined>;
|
31
|
+
}
|
32
|
+
export declare class AsymDecoder extends DecoderV0 implements Decoder<MessageV1> {
|
33
|
+
private privateKey;
|
34
|
+
constructor(contentTopic: string, privateKey: Uint8Array);
|
35
|
+
fromProtoObj(protoMessage: ProtoMessage): Promise<MessageV1 | undefined>;
|
36
|
+
}
|
37
|
+
export declare class SymDecoder extends DecoderV0 implements Decoder<MessageV1> {
|
38
|
+
private symKey;
|
39
|
+
constructor(contentTopic: string, symKey: Uint8Array);
|
40
|
+
fromProtoObj(protoMessage: ProtoMessage): Promise<MessageV1 | undefined>;
|
41
|
+
}
|
42
|
+
/**
|
43
|
+
* Proceed with Asymmetric encryption of the data as per [26/WAKU-PAYLOAD](https://rfc.vac.dev/spec/26/).
|
44
|
+
* The data MUST be flags | payload-length | payload | [signature].
|
45
|
+
* The returned result can be set to `WakuMessage.payload`.
|
46
|
+
*
|
47
|
+
* @internal
|
48
|
+
*/
|
49
|
+
export declare function encryptAsymmetric(data: Uint8Array, publicKey: Uint8Array | string): Promise<Uint8Array>;
|
50
|
+
/**
|
51
|
+
* Proceed with Asymmetric decryption of the data as per [26/WAKU-PAYLOAD](https://rfc.vac.dev/spec/26/).
|
52
|
+
* The returned data is expected to be `flags | payload-length | payload | [signature]`.
|
53
|
+
*
|
54
|
+
* @internal
|
55
|
+
*/
|
56
|
+
export declare function decryptAsymmetric(payload: Uint8Array, privKey: Uint8Array): Promise<Uint8Array>;
|
57
|
+
/**
|
58
|
+
* Proceed with Symmetric encryption of the data as per [26/WAKU-PAYLOAD](https://rfc.vac.dev/spec/26/).
|
59
|
+
*
|
60
|
+
* @param data The data to encrypt, expected to be `flags | payload-length | payload | [signature]`.
|
61
|
+
* @param key The key to use for encryption.
|
62
|
+
* @returns The decrypted data, `cipherText | tag | iv` and can be set to `WakuMessage.payload`.
|
63
|
+
*
|
64
|
+
* @internal
|
65
|
+
*/
|
66
|
+
export declare function encryptSymmetric(data: Uint8Array, key: Uint8Array | string): Promise<Uint8Array>;
|
67
|
+
/**
|
68
|
+
* Proceed with Symmetric decryption of the data as per [26/WAKU-PAYLOAD](https://rfc.vac.dev/spec/26/).
|
69
|
+
*
|
70
|
+
* @param payload The cipher data, it is expected to be `cipherText | tag | iv`.
|
71
|
+
* @param key The key to use for decryption.
|
72
|
+
* @returns The decrypted data, expected to be `flags | payload-length | payload | [signature]`.
|
73
|
+
*
|
74
|
+
* @internal
|
75
|
+
*/
|
76
|
+
export declare function decryptSymmetric(payload: Uint8Array, key: Uint8Array | string): Promise<Uint8Array>;
|
77
|
+
/**
|
78
|
+
* Prepare the payload pre-encryption.
|
79
|
+
*
|
80
|
+
* @internal
|
81
|
+
* @returns The encoded payload, ready for encryption using {@link encryptAsymmetric}
|
82
|
+
* or {@link encryptSymmetric}.
|
83
|
+
*/
|
84
|
+
export declare function preCipher(messagePayload: Uint8Array, sigPrivKey?: Uint8Array): Promise<Uint8Array>;
|
85
|
+
/**
|
86
|
+
* Decode a decrypted payload.
|
87
|
+
*
|
88
|
+
* @internal
|
89
|
+
*/
|
90
|
+
export declare function postCipher(message: Uint8Array): {
|
91
|
+
payload: Uint8Array;
|
92
|
+
sig?: Signature;
|
93
|
+
} | undefined;
|
@@ -0,0 +1,325 @@
|
|
1
|
+
import * as secp from "@noble/secp256k1";
|
2
|
+
import debug from "debug";
|
3
|
+
import * as proto from "../../proto/message.js";
|
4
|
+
import { keccak256, randomBytes, sign } from "../crypto.js";
|
5
|
+
import { concat, hexToBytes } from "../utils.js";
|
6
|
+
import { Symmetric } from "./constants.js";
|
7
|
+
import * as ecies from "./ecies.js";
|
8
|
+
import * as symmetric from "./symmetric.js";
|
9
|
+
import { DecoderV0, MessageV0 } from "./version_0.js";
|
10
|
+
const log = debug("waku:message:version-1");
|
11
|
+
const FlagsLength = 1;
|
12
|
+
const FlagMask = 3; // 0011
|
13
|
+
const IsSignedMask = 4; // 0100
|
14
|
+
const PaddingTarget = 256;
|
15
|
+
const SignatureLength = 65;
|
16
|
+
const OneMillion = BigInt(1000000);
|
17
|
+
export const Version = 1;
|
18
|
+
export class MessageV1 extends MessageV0 {
|
19
|
+
constructor(proto, decodedPayload, signature, signaturePublicKey) {
|
20
|
+
super(proto);
|
21
|
+
this.signature = signature;
|
22
|
+
this.signaturePublicKey = signaturePublicKey;
|
23
|
+
this._decodedPayload = decodedPayload;
|
24
|
+
}
|
25
|
+
get payload() {
|
26
|
+
return this._decodedPayload;
|
27
|
+
}
|
28
|
+
}
|
29
|
+
export class AsymEncoder {
|
30
|
+
constructor(contentTopic, publicKey, sigPrivKey) {
|
31
|
+
this.contentTopic = contentTopic;
|
32
|
+
this.publicKey = publicKey;
|
33
|
+
this.sigPrivKey = sigPrivKey;
|
34
|
+
}
|
35
|
+
async toWire(message) {
|
36
|
+
const protoMessage = await this.toProtoObj(message);
|
37
|
+
if (!protoMessage)
|
38
|
+
return;
|
39
|
+
return proto.WakuMessage.encode(protoMessage);
|
40
|
+
}
|
41
|
+
async toProtoObj(message) {
|
42
|
+
const timestamp = message.timestamp ?? new Date();
|
43
|
+
if (!message.payload) {
|
44
|
+
log("No payload to encrypt, skipping: ", message);
|
45
|
+
return;
|
46
|
+
}
|
47
|
+
const preparedPayload = await preCipher(message.payload, this.sigPrivKey);
|
48
|
+
const payload = await encryptAsymmetric(preparedPayload, this.publicKey);
|
49
|
+
return {
|
50
|
+
payload,
|
51
|
+
version: Version,
|
52
|
+
contentTopic: this.contentTopic,
|
53
|
+
timestamp: BigInt(timestamp.valueOf()) * OneMillion,
|
54
|
+
rateLimitProof: message.rateLimitProof,
|
55
|
+
};
|
56
|
+
}
|
57
|
+
}
|
58
|
+
export class SymEncoder {
|
59
|
+
constructor(contentTopic, symKey, sigPrivKey) {
|
60
|
+
this.contentTopic = contentTopic;
|
61
|
+
this.symKey = symKey;
|
62
|
+
this.sigPrivKey = sigPrivKey;
|
63
|
+
}
|
64
|
+
async toWire(message) {
|
65
|
+
const protoMessage = await this.toProtoObj(message);
|
66
|
+
if (!protoMessage)
|
67
|
+
return;
|
68
|
+
return proto.WakuMessage.encode(protoMessage);
|
69
|
+
}
|
70
|
+
async toProtoObj(message) {
|
71
|
+
const timestamp = message.timestamp ?? new Date();
|
72
|
+
if (!message.payload) {
|
73
|
+
log("No payload to encrypt, skipping: ", message);
|
74
|
+
return;
|
75
|
+
}
|
76
|
+
const preparedPayload = await preCipher(message.payload, this.sigPrivKey);
|
77
|
+
const payload = await encryptSymmetric(preparedPayload, this.symKey);
|
78
|
+
return {
|
79
|
+
payload,
|
80
|
+
version: Version,
|
81
|
+
contentTopic: this.contentTopic,
|
82
|
+
timestamp: BigInt(timestamp.valueOf()) * OneMillion,
|
83
|
+
rateLimitProof: message.rateLimitProof,
|
84
|
+
};
|
85
|
+
}
|
86
|
+
}
|
87
|
+
export class AsymDecoder extends DecoderV0 {
|
88
|
+
constructor(contentTopic, privateKey) {
|
89
|
+
super(contentTopic);
|
90
|
+
this.privateKey = privateKey;
|
91
|
+
}
|
92
|
+
async fromProtoObj(protoMessage) {
|
93
|
+
const cipherPayload = protoMessage.payload;
|
94
|
+
if (protoMessage.version !== Version) {
|
95
|
+
log("Failed to decrypt due to incorrect version, expected:", Version, ", actual:", protoMessage.version);
|
96
|
+
return;
|
97
|
+
}
|
98
|
+
let payload;
|
99
|
+
if (!cipherPayload) {
|
100
|
+
log(`No payload to decrypt for contentTopic ${this.contentTopic}`);
|
101
|
+
return;
|
102
|
+
}
|
103
|
+
try {
|
104
|
+
payload = await decryptAsymmetric(cipherPayload, this.privateKey);
|
105
|
+
}
|
106
|
+
catch (e) {
|
107
|
+
log(`Failed to decrypt message using asymmetric decryption for contentTopic: ${this.contentTopic}`, e);
|
108
|
+
return;
|
109
|
+
}
|
110
|
+
if (!payload) {
|
111
|
+
log(`Failed to decrypt payload for contentTopic ${this.contentTopic}`);
|
112
|
+
return;
|
113
|
+
}
|
114
|
+
const res = await postCipher(payload);
|
115
|
+
if (!res) {
|
116
|
+
log(`Failed to decode payload for contentTopic ${this.contentTopic}`);
|
117
|
+
return;
|
118
|
+
}
|
119
|
+
log("Message decrypted", protoMessage);
|
120
|
+
return new MessageV1(protoMessage, res.payload, res.sig?.signature, res.sig?.publicKey);
|
121
|
+
}
|
122
|
+
}
|
123
|
+
export class SymDecoder extends DecoderV0 {
|
124
|
+
constructor(contentTopic, symKey) {
|
125
|
+
super(contentTopic);
|
126
|
+
this.symKey = symKey;
|
127
|
+
}
|
128
|
+
async fromProtoObj(protoMessage) {
|
129
|
+
const cipherPayload = protoMessage.payload;
|
130
|
+
if (protoMessage.version !== Version) {
|
131
|
+
log("Failed to decrypt due to incorrect version, expected:", Version, ", actual:", protoMessage.version);
|
132
|
+
return;
|
133
|
+
}
|
134
|
+
let payload;
|
135
|
+
if (!cipherPayload) {
|
136
|
+
log(`No payload to decrypt for contentTopic ${this.contentTopic}`);
|
137
|
+
return;
|
138
|
+
}
|
139
|
+
try {
|
140
|
+
payload = await decryptSymmetric(cipherPayload, this.symKey);
|
141
|
+
}
|
142
|
+
catch (e) {
|
143
|
+
log(`Failed to decrypt message using asymmetric decryption for contentTopic: ${this.contentTopic}`, e);
|
144
|
+
return;
|
145
|
+
}
|
146
|
+
if (!payload) {
|
147
|
+
log(`Failed to decrypt payload for contentTopic ${this.contentTopic}`);
|
148
|
+
return;
|
149
|
+
}
|
150
|
+
const res = await postCipher(payload);
|
151
|
+
if (!res) {
|
152
|
+
log(`Failed to decode payload for contentTopic ${this.contentTopic}`);
|
153
|
+
return;
|
154
|
+
}
|
155
|
+
log("Message decrypted", protoMessage);
|
156
|
+
return new MessageV1(protoMessage, res.payload, res.sig?.signature, res.sig?.publicKey);
|
157
|
+
}
|
158
|
+
}
|
159
|
+
function getSizeOfPayloadSizeField(message) {
|
160
|
+
const messageDataView = new DataView(message.buffer);
|
161
|
+
return messageDataView.getUint8(0) & FlagMask;
|
162
|
+
}
|
163
|
+
function getPayloadSize(message, sizeOfPayloadSizeField) {
|
164
|
+
let payloadSizeBytes = message.slice(1, 1 + sizeOfPayloadSizeField);
|
165
|
+
// int 32 == 4 bytes
|
166
|
+
if (sizeOfPayloadSizeField < 4) {
|
167
|
+
// If less than 4 bytes pad right (Little Endian).
|
168
|
+
payloadSizeBytes = concat([payloadSizeBytes, new Uint8Array(4 - sizeOfPayloadSizeField)], 4);
|
169
|
+
}
|
170
|
+
const payloadSizeDataView = new DataView(payloadSizeBytes.buffer);
|
171
|
+
return payloadSizeDataView.getInt32(0, true);
|
172
|
+
}
|
173
|
+
function isMessageSigned(message) {
|
174
|
+
const messageDataView = new DataView(message.buffer);
|
175
|
+
return (messageDataView.getUint8(0) & IsSignedMask) == IsSignedMask;
|
176
|
+
}
|
177
|
+
/**
|
178
|
+
* Proceed with Asymmetric encryption of the data as per [26/WAKU-PAYLOAD](https://rfc.vac.dev/spec/26/).
|
179
|
+
* The data MUST be flags | payload-length | payload | [signature].
|
180
|
+
* The returned result can be set to `WakuMessage.payload`.
|
181
|
+
*
|
182
|
+
* @internal
|
183
|
+
*/
|
184
|
+
export async function encryptAsymmetric(data, publicKey) {
|
185
|
+
return ecies.encrypt(hexToBytes(publicKey), data);
|
186
|
+
}
|
187
|
+
/**
|
188
|
+
* Proceed with Asymmetric decryption of the data as per [26/WAKU-PAYLOAD](https://rfc.vac.dev/spec/26/).
|
189
|
+
* The returned data is expected to be `flags | payload-length | payload | [signature]`.
|
190
|
+
*
|
191
|
+
* @internal
|
192
|
+
*/
|
193
|
+
export async function decryptAsymmetric(payload, privKey) {
|
194
|
+
return ecies.decrypt(privKey, payload);
|
195
|
+
}
|
196
|
+
/**
|
197
|
+
* Proceed with Symmetric encryption of the data as per [26/WAKU-PAYLOAD](https://rfc.vac.dev/spec/26/).
|
198
|
+
*
|
199
|
+
* @param data The data to encrypt, expected to be `flags | payload-length | payload | [signature]`.
|
200
|
+
* @param key The key to use for encryption.
|
201
|
+
* @returns The decrypted data, `cipherText | tag | iv` and can be set to `WakuMessage.payload`.
|
202
|
+
*
|
203
|
+
* @internal
|
204
|
+
*/
|
205
|
+
export async function encryptSymmetric(data, key) {
|
206
|
+
const iv = symmetric.generateIv();
|
207
|
+
// Returns `cipher | tag`
|
208
|
+
const cipher = await symmetric.encrypt(iv, hexToBytes(key), data);
|
209
|
+
return concat([cipher, iv]);
|
210
|
+
}
|
211
|
+
/**
|
212
|
+
* Proceed with Symmetric decryption of the data as per [26/WAKU-PAYLOAD](https://rfc.vac.dev/spec/26/).
|
213
|
+
*
|
214
|
+
* @param payload The cipher data, it is expected to be `cipherText | tag | iv`.
|
215
|
+
* @param key The key to use for decryption.
|
216
|
+
* @returns The decrypted data, expected to be `flags | payload-length | payload | [signature]`.
|
217
|
+
*
|
218
|
+
* @internal
|
219
|
+
*/
|
220
|
+
export async function decryptSymmetric(payload, key) {
|
221
|
+
const ivStart = payload.length - Symmetric.ivSize;
|
222
|
+
const cipher = payload.slice(0, ivStart);
|
223
|
+
const iv = payload.slice(ivStart);
|
224
|
+
return symmetric.decrypt(iv, hexToBytes(key), cipher);
|
225
|
+
}
|
226
|
+
/**
|
227
|
+
* Computes the flags & auxiliary-field as per [26/WAKU-PAYLOAD](https://rfc.vac.dev/spec/26/).
|
228
|
+
*/
|
229
|
+
function addPayloadSizeField(msg, payload) {
|
230
|
+
const fieldSize = computeSizeOfPayloadSizeField(payload);
|
231
|
+
let field = new Uint8Array(4);
|
232
|
+
const fieldDataView = new DataView(field.buffer);
|
233
|
+
fieldDataView.setUint32(0, payload.length, true);
|
234
|
+
field = field.slice(0, fieldSize);
|
235
|
+
msg = concat([msg, field]);
|
236
|
+
msg[0] |= fieldSize;
|
237
|
+
return msg;
|
238
|
+
}
|
239
|
+
/**
|
240
|
+
* Returns the size of the auxiliary-field which in turns contains the payload size
|
241
|
+
*/
|
242
|
+
function computeSizeOfPayloadSizeField(payload) {
|
243
|
+
let s = 1;
|
244
|
+
for (let i = payload.length; i >= 256; i /= 256) {
|
245
|
+
s++;
|
246
|
+
}
|
247
|
+
return s;
|
248
|
+
}
|
249
|
+
function validateDataIntegrity(value, expectedSize) {
|
250
|
+
if (value.length !== expectedSize) {
|
251
|
+
return false;
|
252
|
+
}
|
253
|
+
return expectedSize <= 3 || value.findIndex((i) => i !== 0) !== -1;
|
254
|
+
}
|
255
|
+
function getSignature(message) {
|
256
|
+
return message.slice(message.length - SignatureLength, message.length);
|
257
|
+
}
|
258
|
+
function getHash(message, isSigned) {
|
259
|
+
if (isSigned) {
|
260
|
+
return keccak256(message.slice(0, message.length - SignatureLength));
|
261
|
+
}
|
262
|
+
return keccak256(message);
|
263
|
+
}
|
264
|
+
function ecRecoverPubKey(messageHash, signature) {
|
265
|
+
const recoveryDataView = new DataView(signature.slice(64).buffer);
|
266
|
+
const recovery = recoveryDataView.getUint8(0);
|
267
|
+
const _signature = secp.Signature.fromCompact(signature.slice(0, 64));
|
268
|
+
return secp.recoverPublicKey(messageHash, _signature, recovery, false);
|
269
|
+
}
|
270
|
+
/**
|
271
|
+
* Prepare the payload pre-encryption.
|
272
|
+
*
|
273
|
+
* @internal
|
274
|
+
* @returns The encoded payload, ready for encryption using {@link encryptAsymmetric}
|
275
|
+
* or {@link encryptSymmetric}.
|
276
|
+
*/
|
277
|
+
export async function preCipher(messagePayload, sigPrivKey) {
|
278
|
+
let envelope = new Uint8Array([0]); // No flags
|
279
|
+
envelope = addPayloadSizeField(envelope, messagePayload);
|
280
|
+
envelope = concat([envelope, messagePayload]);
|
281
|
+
// Calculate padding:
|
282
|
+
let rawSize = FlagsLength +
|
283
|
+
computeSizeOfPayloadSizeField(messagePayload) +
|
284
|
+
messagePayload.length;
|
285
|
+
if (sigPrivKey) {
|
286
|
+
rawSize += SignatureLength;
|
287
|
+
}
|
288
|
+
const remainder = rawSize % PaddingTarget;
|
289
|
+
const paddingSize = PaddingTarget - remainder;
|
290
|
+
const pad = randomBytes(paddingSize);
|
291
|
+
if (!validateDataIntegrity(pad, paddingSize)) {
|
292
|
+
throw new Error("failed to generate random padding of size " + paddingSize);
|
293
|
+
}
|
294
|
+
envelope = concat([envelope, pad]);
|
295
|
+
if (sigPrivKey) {
|
296
|
+
envelope[0] |= IsSignedMask;
|
297
|
+
const hash = keccak256(envelope);
|
298
|
+
const bytesSignature = await sign(hash, sigPrivKey);
|
299
|
+
envelope = concat([envelope, bytesSignature]);
|
300
|
+
}
|
301
|
+
return envelope;
|
302
|
+
}
|
303
|
+
/**
|
304
|
+
* Decode a decrypted payload.
|
305
|
+
*
|
306
|
+
* @internal
|
307
|
+
*/
|
308
|
+
export function postCipher(message) {
|
309
|
+
const sizeOfPayloadSizeField = getSizeOfPayloadSizeField(message);
|
310
|
+
if (sizeOfPayloadSizeField === 0)
|
311
|
+
return;
|
312
|
+
const payloadSize = getPayloadSize(message, sizeOfPayloadSizeField);
|
313
|
+
const payloadStart = 1 + sizeOfPayloadSizeField;
|
314
|
+
const payload = message.slice(payloadStart, payloadStart + payloadSize);
|
315
|
+
const isSigned = isMessageSigned(message);
|
316
|
+
let sig;
|
317
|
+
if (isSigned) {
|
318
|
+
const signature = getSignature(message);
|
319
|
+
const hash = getHash(message, isSigned);
|
320
|
+
const publicKey = ecRecoverPubKey(hash, signature);
|
321
|
+
sig = { signature, publicKey };
|
322
|
+
}
|
323
|
+
return { payload, sig };
|
324
|
+
}
|
325
|
+
//# sourceMappingURL=version_1.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"version_1.js","sourceRoot":"","sources":["../../../src/lib/waku_message/version_1.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,kBAAkB,CAAC;AAEzC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,KAAK,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,GAAG,GAAG,KAAK,CAAC,wBAAwB,CAAC,CAAC;AAE5C,MAAM,WAAW,GAAG,CAAC,CAAC;AACtB,MAAM,QAAQ,GAAG,CAAC,CAAC,CAAC,OAAO;AAC3B,MAAM,YAAY,GAAG,CAAC,CAAC,CAAC,OAAO;AAC/B,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,MAAM,eAAe,GAAG,EAAE,CA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M,CAAC,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC;KAC/C;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CACxB,OAAmB;IAEnB,MAAM,sBAAsB,GAAG,yBAAyB,CAAC,OAAO,CAAC,CAAC;IAClE,IAAI,sBAAsB,KAAK,CAAC;QAAE,OAAO;IAEzC,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO,EAAE,sBAAsB,CAAC,CAAC;IACpE,MAAM,YAAY,GAAG,CAAC,GAAG,sBAAsB,CAAC;IAChD,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,YAAY,EAAE,YAAY,GAAG,WAAW,CAAC,CAAC;IAExE,MAAM,QAAQ,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IAE1C,IAAI,GAAG,CAAC;IACR,IAAI,QAAQ,EAAE;QACZ,MAAM,SAAS,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;QACxC,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACxC,MAAM,SAAS,GAAG,eAAe,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QACnD,GAAG,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;KAChC;IAED,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;AAC1B,CAAC"}
|
@@ -0,0 +1,63 @@
|
|
1
|
+
export declare const second = 1000;
|
2
|
+
export declare const minute: number;
|
3
|
+
/**
|
4
|
+
* RelayCodec is the libp2p identifier for the waku relay protocol
|
5
|
+
*/
|
6
|
+
export declare const RelayCodecs: string[];
|
7
|
+
export declare const RelayPingContentTopic = "/relay-ping/1/ping/null";
|
8
|
+
/**
|
9
|
+
* RelayGossipFactor affects how many peers we will emit gossip to at each heartbeat.
|
10
|
+
* We will send gossip to RelayGossipFactor * (total number of non-mesh peers), or
|
11
|
+
* RelayDlazy, whichever is greater.
|
12
|
+
*/
|
13
|
+
export declare const RelayGossipFactor = 0.25;
|
14
|
+
/**
|
15
|
+
* GossipsubHeartbeatInitialDelay is the short delay before the heartbeat timer begins
|
16
|
+
* after the router is initialized.
|
17
|
+
*/
|
18
|
+
export declare const RelayHeartbeatInitialDelay = 100;
|
19
|
+
/**
|
20
|
+
* RelayHeartbeatInterval controls the time between heartbeats.
|
21
|
+
*/
|
22
|
+
export declare const RelayHeartbeatInterval = 1000;
|
23
|
+
/**
|
24
|
+
* RelayPrunePeers controls the number of peers to include in prune Peer eXchange.
|
25
|
+
* When we prune a peer that's eligible for PX (has a good score, etc), we will try to
|
26
|
+
* send them signed peer records for up to RelayPrunePeers other peers that we
|
27
|
+
* know of.
|
28
|
+
*/
|
29
|
+
export declare const RelayPrunePeers = 16;
|
30
|
+
/**
|
31
|
+
* RelayPruneBackoff controls the backoff time for pruned peers. This is how long
|
32
|
+
* a peer must wait before attempting to graft into our mesh again after being pruned.
|
33
|
+
* When pruning a peer, we send them our value of RelayPruneBackoff so they know
|
34
|
+
* the minimum time to wait. Peers running older versions may not send a backoff time,
|
35
|
+
* so if we receive a prune message without one, we will wait at least RelayPruneBackoff
|
36
|
+
* before attempting to re-graft.
|
37
|
+
*/
|
38
|
+
export declare const RelayPruneBackoff: number;
|
39
|
+
/**
|
40
|
+
* RelayFanoutTTL controls how long we keep track of the fanout state. If it's been
|
41
|
+
* RelayFanoutTTL since we've published to a topic that we're not subscribed to,
|
42
|
+
* we'll delete the fanout map for that topic.
|
43
|
+
*/
|
44
|
+
export declare const RelayFanoutTTL: number;
|
45
|
+
/**
|
46
|
+
* RelayOpportunisticGraftTicks is the number of heartbeat ticks for attempting to improve the mesh
|
47
|
+
* with opportunistic grafting. Every RelayOpportunisticGraftTicks we will attempt to select some
|
48
|
+
* high-scoring mesh peers to replace lower-scoring ones, if the median score of our mesh peers falls
|
49
|
+
* below a threshold
|
50
|
+
*/
|
51
|
+
export declare const RelayOpportunisticGraftTicks = 60;
|
52
|
+
/**
|
53
|
+
* RelayOpportunisticGraftPeers is the number of peers to opportunistically graft.
|
54
|
+
*/
|
55
|
+
export declare const RelayOpportunisticGraftPeers = 2;
|
56
|
+
/**
|
57
|
+
* RelayMaxIHaveLength is the maximum number of messages to include in an IHAVE message.
|
58
|
+
* Also controls the maximum number of IHAVE ids we will accept and request with IWANT from a
|
59
|
+
* peer within a heartbeat, to protect from IHAVE floods. You should adjust this value from the
|
60
|
+
* default if your system is pushing more than 5000 messages in GossipsubHistoryGossip heartbeats;
|
61
|
+
* with the defaults this is 1666 messages/s.
|
62
|
+
*/
|
63
|
+
export declare const RelayMaxIHaveLength = 5000;
|