@waku/core 0.0.36-76fb1ea.0 → 0.0.36-86bbf5b.0
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/bundle/{base_protocol-DbwKyDLW.js → base_protocol-DvQrudwy.js} +1 -1
- package/bundle/{index-JnhMR9ZE.js → index-CTo1my9M.js} +1 -20
- package/bundle/index.js +44 -377
- package/bundle/lib/base_protocol.js +2 -2
- package/bundle/lib/message/version_0.js +2 -2
- package/bundle/{version_0-sWyv9XWm.js → version_0-CyeTW0Vr.js} +57 -780
- package/dist/.tsbuildinfo +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/connection_manager/connection_manager.d.ts +1 -1
- package/dist/lib/connection_manager/connection_manager.js +1 -1
- package/dist/lib/light_push/index.d.ts +1 -5
- package/dist/lib/light_push/index.js +1 -5
- package/dist/lib/light_push/index.js.map +1 -1
- package/dist/lib/light_push/light_push.d.ts +4 -3
- package/dist/lib/light_push/light_push.js +21 -12
- package/dist/lib/light_push/light_push.js.map +1 -1
- package/dist/lib/light_push/push_rpc.d.ts +1 -1
- package/dist/lib/light_push/push_rpc.js.map +1 -1
- package/dist/lib/light_push/utils.d.ts +0 -6
- package/dist/lib/light_push/utils.js +0 -41
- package/dist/lib/light_push/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +0 -5
- package/src/lib/connection_manager/connection_manager.ts +1 -1
- package/src/lib/light_push/index.ts +1 -22
- package/src/lib/light_push/light_push.ts +25 -19
- package/src/lib/light_push/push_rpc.ts +1 -1
- package/src/lib/light_push/utils.ts +0 -57
- package/dist/lib/light_push/light_push_v3.d.ts +0 -9
- package/dist/lib/light_push/light_push_v3.js +0 -171
- package/dist/lib/light_push/light_push_v3.js.map +0 -1
- package/dist/lib/light_push/push_rpc_v2.d.ts +0 -11
- package/dist/lib/light_push/push_rpc_v2.js +0 -32
- package/dist/lib/light_push/push_rpc_v2.js.map +0 -1
- package/dist/lib/light_push/push_rpc_v3.d.ts +0 -11
- package/dist/lib/light_push/push_rpc_v3.js +0 -33
- package/dist/lib/light_push/push_rpc_v3.js.map +0 -1
- package/dist/lib/light_push/status_codes.d.ts +0 -14
- package/dist/lib/light_push/status_codes.js +0 -49
- package/dist/lib/light_push/status_codes.js.map +0 -1
- package/dist/lib/light_push/status_codes_v3.d.ts +0 -4
- package/dist/lib/light_push/status_codes_v3.js +0 -53
- package/dist/lib/light_push/status_codes_v3.js.map +0 -1
- package/src/lib/light_push/light_push_v3.ts +0 -232
- package/src/lib/light_push/push_rpc_v2.ts +0 -38
- package/src/lib/light_push/push_rpc_v3.ts +0 -46
- package/src/lib/light_push/status_codes.ts +0 -71
- package/src/lib/light_push/status_codes_v3.ts +0 -80
@@ -1,7 +1 @@
|
|
1
|
-
import { ProtocolError } from "@waku/interfaces";
|
2
1
|
export declare const isRLNResponseError: (info?: string) => boolean;
|
3
|
-
/**
|
4
|
-
* Maps error information from push response to appropriate ProtocolError
|
5
|
-
* Uses pattern matching to handle various error cases
|
6
|
-
*/
|
7
|
-
export declare function mapInfoToProtocolError(info?: string): ProtocolError;
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import { ProtocolError } from "@waku/interfaces";
|
2
1
|
// should match nwaku
|
3
2
|
// https://github.com/waku-org/nwaku/blob/c3cb06ac6c03f0f382d3941ea53b330f6a8dd127/waku/waku_rln_relay/rln_relay.nim#L309
|
4
3
|
// https://github.com/waku-org/nwaku/blob/c3cb06ac6c03f0f382d3941ea53b330f6a8dd127/tests/waku_rln_relay/rln/waku_rln_relay_utils.nim#L20
|
@@ -16,44 +15,4 @@ export const isRLNResponseError = (info) => {
|
|
16
15
|
info.includes(RLN_MESSAGE_ID_PREFIX_ERROR) ||
|
17
16
|
info.includes(RLN_REMOTE_VALIDATION));
|
18
17
|
};
|
19
|
-
/**
|
20
|
-
* Maps error information from push response to appropriate ProtocolError
|
21
|
-
* Uses pattern matching to handle various error cases
|
22
|
-
*/
|
23
|
-
export function mapInfoToProtocolError(info) {
|
24
|
-
if (!info) {
|
25
|
-
return ProtocolError.REMOTE_PEER_REJECTED;
|
26
|
-
}
|
27
|
-
const lowerInfo = info.toLowerCase();
|
28
|
-
// RLN errors
|
29
|
-
if (isRLNResponseError(info)) {
|
30
|
-
return ProtocolError.RLN_PROOF_GENERATION;
|
31
|
-
}
|
32
|
-
// Rate limiting patterns
|
33
|
-
if (lowerInfo.includes("rate limit") ||
|
34
|
-
lowerInfo.includes("too many requests")) {
|
35
|
-
return ProtocolError.REMOTE_PEER_REJECTED;
|
36
|
-
}
|
37
|
-
// Topic errors
|
38
|
-
if (lowerInfo.includes("topic") &&
|
39
|
-
(lowerInfo.includes("not found") || lowerInfo.includes("not configured"))) {
|
40
|
-
return ProtocolError.TOPIC_NOT_CONFIGURED;
|
41
|
-
}
|
42
|
-
// Size errors
|
43
|
-
if (lowerInfo.includes("too large") || lowerInfo.includes("size")) {
|
44
|
-
return ProtocolError.SIZE_TOO_BIG;
|
45
|
-
}
|
46
|
-
// Decoding errors
|
47
|
-
if (lowerInfo.includes("decode") ||
|
48
|
-
lowerInfo.includes("invalid") ||
|
49
|
-
lowerInfo.includes("malformed")) {
|
50
|
-
return ProtocolError.DECODE_FAILED;
|
51
|
-
}
|
52
|
-
// Empty payload
|
53
|
-
if (lowerInfo.includes("empty") && lowerInfo.includes("payload")) {
|
54
|
-
return ProtocolError.EMPTY_PAYLOAD;
|
55
|
-
}
|
56
|
-
// Default case
|
57
|
-
return ProtocolError.REMOTE_PEER_REJECTED;
|
58
|
-
}
|
59
18
|
//# sourceMappingURL=utils.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/lib/light_push/utils.ts"],"names":[],"mappings":"AAAA,
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/lib/light_push/utils.ts"],"names":[],"mappings":"AAAA,qBAAqB;AACrB,yHAAyH;AACzH,wIAAwI;AACxI,MAAM,2BAA2B,GAAG,8BAA8B,CAAC;AACnE,MAAM,2BAA2B,GAC/B,uDAAuD,CAAC;AAE1D,0BAA0B;AAC1B,wHAAwH;AACxH,gHAAgH;AAChH,MAAM,qBAAqB,GAAG,uBAAuB,CAAC;AAEtD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAa,EAAW,EAAE;IAC3D,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,CACL,IAAI,CAAC,QAAQ,CAAC,2BAA2B,CAAC;QAC1C,IAAI,CAAC,QAAQ,CAAC,2BAA2B,CAAC;QAC1C,IAAI,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CACrC,CAAC;AACJ,CAAC,CAAC"}
|
package/package.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"name":"@waku/core","version":"0.0.36-
|
1
|
+
{"name":"@waku/core","version":"0.0.36-86bbf5b.0","description":"TypeScript implementation of the Waku v2 protocol","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./lib/message/version_0":{"types":"./dist/lib/message/version_0.d.ts","import":"./dist/lib/message/version_0.js"},"./lib/base_protocol":{"types":"./dist/lib/base_protocol.d.ts","import":"./dist/lib/base_protocol.js"}},"typesVersions":{"*":{"lib/*":["dist/lib/*"],"constants/*":["dist/constants/*"]}},"type":"module","homepage":"https://github.com/waku-org/js-waku/tree/master/packages/core#readme","repository":{"type":"git","url":"https://github.com/waku-org/js-waku.git"},"bugs":{"url":"https://github.com/waku-org/js-waku/issues"},"license":"MIT OR Apache-2.0","keywords":["waku","decentralised","communication","web3","ethereum","dapps"],"scripts":{"build":"run-s build:**","build:esm":"tsc","build:bundle":"rollup --config rollup.config.js","fix":"run-s fix:*","fix:lint":"eslint src *.js --fix","check":"run-s check:*","check:tsc":"tsc -p tsconfig.dev.json","check:lint":"eslint src *.js","check:spelling":"cspell \"{README.md,src/**/*.ts}\"","test":"NODE_ENV=test run-s test:*","test:node":"NODE_ENV=test TS_NODE_PROJECT=./tsconfig.dev.json mocha","test:browser":"NODE_ENV=test karma start karma.conf.cjs","watch:build":"tsc -p tsconfig.json -w","watch:test":"mocha --watch","prepublish":"npm run build","reset-hard":"git clean -dfx -e .idea && git reset --hard && npm i && npm run build"},"engines":{"node":">=20"},"dependencies":{"@waku/enr":"0.0.30-86bbf5b.0","@waku/interfaces":"0.0.31-86bbf5b.0","@libp2p/ping":"2.0.1","@waku/proto":"0.0.11-86bbf5b.0","@waku/utils":"0.0.24-86bbf5b.0","debug":"^4.3.4","@noble/hashes":"^1.3.2","it-all":"^3.0.4","it-length-prefixed":"^9.0.4","it-pipe":"^3.0.1","uint8arraylist":"^2.4.3","uuid":"^9.0.0"},"devDependencies":{"@libp2p/peer-id":"^5.0.1","@libp2p/interface":"^2.1.3","@multiformats/multiaddr":"^12.0.0","@rollup/plugin-commonjs":"^25.0.7","@rollup/plugin-json":"^6.0.0","@rollup/plugin-node-resolve":"^15.2.3","@types/chai":"^4.3.11","@types/debug":"^4.1.12","@types/mocha":"^10.0.6","@types/uuid":"^9.0.8","@waku/build-utils":"*","chai":"^4.3.10","sinon":"^18.0.0","cspell":"^8.6.1","fast-check":"^3.19.0","ignore-loader":"^0.1.2","isomorphic-fetch":"^3.0.0","mocha":"^10.3.0","npm-run-all":"^4.1.5","process":"^0.11.10","rollup":"^4.12.0"},"peerDependencies":{"@multiformats/multiaddr":"^12.0.0","libp2p":"2.1.8"},"peerDependenciesMeta":{"@multiformats/multiaddr":{"optional":true},"libp2p":{"optional":true}},"files":["dist","bundle","src/**/*.ts","!**/*.spec.*","!**/*.json","CHANGELOG.md","LICENSE","README.md"]}
|
package/src/index.ts
CHANGED
@@ -11,11 +11,6 @@ export { FilterCore, FilterCodecs } from "./lib/filter/index.js";
|
|
11
11
|
|
12
12
|
export * as waku_light_push from "./lib/light_push/index.js";
|
13
13
|
export { LightPushCodec, LightPushCore } from "./lib/light_push/index.js";
|
14
|
-
export {
|
15
|
-
LightPushCoreV2,
|
16
|
-
LightPushCodecV2,
|
17
|
-
LightPushCoreV3
|
18
|
-
} from "./lib/light_push/index.js";
|
19
14
|
|
20
15
|
export * as waku_store from "./lib/store/index.js";
|
21
16
|
export { StoreCore, StoreCodec } from "./lib/store/index.js";
|
@@ -267,7 +267,7 @@ export class ConnectionManager
|
|
267
267
|
* // Dial using multiaddr with specific protocols
|
268
268
|
* await connectionManager.dialPeer(multiaddr, [
|
269
269
|
* "/vac/waku/relay/2.0.0",
|
270
|
-
* "/vac/waku/lightpush/
|
270
|
+
* "/vac/waku/lightpush/2.0.0-beta1"
|
271
271
|
* ]);
|
272
272
|
* ```
|
273
273
|
*
|
@@ -1,22 +1 @@
|
|
1
|
-
export {
|
2
|
-
LightPushCore,
|
3
|
-
LightPushCodec,
|
4
|
-
LightPushCoreV2,
|
5
|
-
LightPushCodecV2,
|
6
|
-
PushResponse
|
7
|
-
} from "./light_push.js";
|
8
|
-
|
9
|
-
export { LightPushCoreV3 } from "./light_push_v3.js";
|
10
|
-
export { PushRpcV3 } from "./push_rpc_v3.js";
|
11
|
-
export {
|
12
|
-
lightPushStatusCodeToProtocolErrorV3,
|
13
|
-
lightPushStatusDescriptionsV3,
|
14
|
-
getLightPushStatusDescriptionV3
|
15
|
-
} from "./status_codes_v3.js";
|
16
|
-
export {
|
17
|
-
LightPushStatusCode,
|
18
|
-
lightPushStatusCodeToProtocolError,
|
19
|
-
lightPushStatusDescriptions,
|
20
|
-
getLightPushStatusDescription,
|
21
|
-
isSuccessStatusCode
|
22
|
-
} from "./status_codes.js";
|
1
|
+
export { LightPushCore, LightPushCodec, PushResponse } from "./light_push.js";
|
@@ -9,7 +9,7 @@ import {
|
|
9
9
|
PubsubTopic,
|
10
10
|
type ThisOrThat
|
11
11
|
} from "@waku/interfaces";
|
12
|
-
import {
|
12
|
+
import { PushResponse } from "@waku/proto";
|
13
13
|
import { isMessageSizeUnderCap } from "@waku/utils";
|
14
14
|
import { Logger } from "@waku/utils";
|
15
15
|
import all from "it-all";
|
@@ -19,17 +19,19 @@ import { Uint8ArrayList } from "uint8arraylist";
|
|
19
19
|
|
20
20
|
import { BaseProtocol } from "../base_protocol.js";
|
21
21
|
|
22
|
-
import {
|
23
|
-
import {
|
22
|
+
import { PushRpc } from "./push_rpc.js";
|
23
|
+
import { isRLNResponseError } from "./utils.js";
|
24
24
|
|
25
25
|
const log = new Logger("light-push");
|
26
26
|
|
27
27
|
export const LightPushCodec = "/vac/waku/lightpush/2.0.0-beta1";
|
28
|
+
export { PushResponse };
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
type PreparePushMessageResult = ThisOrThat<"query", PushRpcV2>;
|
30
|
+
type PreparePushMessageResult = ThisOrThat<"query", PushRpc>;
|
32
31
|
|
32
|
+
/**
|
33
|
+
* Implements the [Waku v2 Light Push protocol](https://rfc.vac.dev/spec/19/).
|
34
|
+
*/
|
33
35
|
export class LightPushCore extends BaseProtocol implements IBaseProtocolCore {
|
34
36
|
public constructor(
|
35
37
|
public readonly pubsubTopics: PubsubTopic[],
|
@@ -62,7 +64,7 @@ export class LightPushCore extends BaseProtocol implements IBaseProtocolCore {
|
|
62
64
|
};
|
63
65
|
}
|
64
66
|
|
65
|
-
const query =
|
67
|
+
const query = PushRpc.createRequest(protoMessage, encoder.pubsubTopic);
|
66
68
|
return { query, error: null };
|
67
69
|
} catch (error) {
|
68
70
|
log.error("Failed to prepare push message", error);
|
@@ -118,6 +120,7 @@ export class LightPushCore extends BaseProtocol implements IBaseProtocolCore {
|
|
118
120
|
async (source) => await all(source)
|
119
121
|
);
|
120
122
|
} catch (err) {
|
123
|
+
// can fail only because of `stream` abortion
|
121
124
|
log.error("Failed to send waku light push request", err);
|
122
125
|
return {
|
123
126
|
success: null,
|
@@ -133,9 +136,9 @@ export class LightPushCore extends BaseProtocol implements IBaseProtocolCore {
|
|
133
136
|
bytes.append(chunk);
|
134
137
|
});
|
135
138
|
|
136
|
-
let response:
|
139
|
+
let response: PushResponse | undefined;
|
137
140
|
try {
|
138
|
-
response =
|
141
|
+
response = PushRpc.decode(bytes).response;
|
139
142
|
} catch (err) {
|
140
143
|
log.error("Failed to decode push reply", err);
|
141
144
|
return {
|
@@ -158,17 +161,23 @@ export class LightPushCore extends BaseProtocol implements IBaseProtocolCore {
|
|
158
161
|
};
|
159
162
|
}
|
160
163
|
|
161
|
-
if (
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
164
|
+
if (isRLNResponseError(response.info)) {
|
165
|
+
log.error("Remote peer fault: RLN generation");
|
166
|
+
return {
|
167
|
+
success: null,
|
168
|
+
failure: {
|
169
|
+
error: ProtocolError.RLN_PROOF_GENERATION,
|
170
|
+
peerId: peerId
|
171
|
+
}
|
172
|
+
};
|
173
|
+
}
|
167
174
|
|
175
|
+
if (!response.isSuccess) {
|
176
|
+
log.error("Remote peer rejected the message: ", response.info);
|
168
177
|
return {
|
169
178
|
success: null,
|
170
179
|
failure: {
|
171
|
-
error:
|
180
|
+
error: ProtocolError.REMOTE_PEER_REJECTED,
|
172
181
|
peerId: peerId
|
173
182
|
}
|
174
183
|
};
|
@@ -177,6 +186,3 @@ export class LightPushCore extends BaseProtocol implements IBaseProtocolCore {
|
|
177
186
|
return { success: peerId, failure: null };
|
178
187
|
}
|
179
188
|
}
|
180
|
-
|
181
|
-
export const LightPushCoreV2 = LightPushCore;
|
182
|
-
export { PushResponse };
|
@@ -1,5 +1,3 @@
|
|
1
|
-
import { ProtocolError } from "@waku/interfaces";
|
2
|
-
|
3
1
|
// should match nwaku
|
4
2
|
// https://github.com/waku-org/nwaku/blob/c3cb06ac6c03f0f382d3941ea53b330f6a8dd127/waku/waku_rln_relay/rln_relay.nim#L309
|
5
3
|
// https://github.com/waku-org/nwaku/blob/c3cb06ac6c03f0f382d3941ea53b330f6a8dd127/tests/waku_rln_relay/rln/waku_rln_relay_utils.nim#L20
|
@@ -23,58 +21,3 @@ export const isRLNResponseError = (info?: string): boolean => {
|
|
23
21
|
info.includes(RLN_REMOTE_VALIDATION)
|
24
22
|
);
|
25
23
|
};
|
26
|
-
|
27
|
-
/**
|
28
|
-
* Maps error information from push response to appropriate ProtocolError
|
29
|
-
* Uses pattern matching to handle various error cases
|
30
|
-
*/
|
31
|
-
export function mapInfoToProtocolError(info?: string): ProtocolError {
|
32
|
-
if (!info) {
|
33
|
-
return ProtocolError.REMOTE_PEER_REJECTED;
|
34
|
-
}
|
35
|
-
|
36
|
-
const lowerInfo = info.toLowerCase();
|
37
|
-
|
38
|
-
// RLN errors
|
39
|
-
if (isRLNResponseError(info)) {
|
40
|
-
return ProtocolError.RLN_PROOF_GENERATION;
|
41
|
-
}
|
42
|
-
|
43
|
-
// Rate limiting patterns
|
44
|
-
if (
|
45
|
-
lowerInfo.includes("rate limit") ||
|
46
|
-
lowerInfo.includes("too many requests")
|
47
|
-
) {
|
48
|
-
return ProtocolError.REMOTE_PEER_REJECTED;
|
49
|
-
}
|
50
|
-
|
51
|
-
// Topic errors
|
52
|
-
if (
|
53
|
-
lowerInfo.includes("topic") &&
|
54
|
-
(lowerInfo.includes("not found") || lowerInfo.includes("not configured"))
|
55
|
-
) {
|
56
|
-
return ProtocolError.TOPIC_NOT_CONFIGURED;
|
57
|
-
}
|
58
|
-
|
59
|
-
// Size errors
|
60
|
-
if (lowerInfo.includes("too large") || lowerInfo.includes("size")) {
|
61
|
-
return ProtocolError.SIZE_TOO_BIG;
|
62
|
-
}
|
63
|
-
|
64
|
-
// Decoding errors
|
65
|
-
if (
|
66
|
-
lowerInfo.includes("decode") ||
|
67
|
-
lowerInfo.includes("invalid") ||
|
68
|
-
lowerInfo.includes("malformed")
|
69
|
-
) {
|
70
|
-
return ProtocolError.DECODE_FAILED;
|
71
|
-
}
|
72
|
-
|
73
|
-
// Empty payload
|
74
|
-
if (lowerInfo.includes("empty") && lowerInfo.includes("payload")) {
|
75
|
-
return ProtocolError.EMPTY_PAYLOAD;
|
76
|
-
}
|
77
|
-
|
78
|
-
// Default case
|
79
|
-
return ProtocolError.REMOTE_PEER_REJECTED;
|
80
|
-
}
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import type { PeerId } from "@libp2p/interface";
|
2
|
-
import { type CoreProtocolResult, type IBaseProtocolCore, type IEncoder, type IMessage, type Libp2p, PubsubTopic } from "@waku/interfaces";
|
3
|
-
import { BaseProtocol } from "../base_protocol.js";
|
4
|
-
export declare class LightPushCoreV3 extends BaseProtocol implements IBaseProtocolCore {
|
5
|
-
readonly pubsubTopics: PubsubTopic[];
|
6
|
-
constructor(pubsubTopics: PubsubTopic[], libp2p: Libp2p);
|
7
|
-
private preparePushMessage;
|
8
|
-
send(encoder: IEncoder, message: IMessage, peerId: PeerId): Promise<CoreProtocolResult>;
|
9
|
-
}
|
@@ -1,171 +0,0 @@
|
|
1
|
-
import { isSuccessStatusCodeV3, LightPushCodecV3, LightPushStatusCodeV3, ProtocolError } from "@waku/interfaces";
|
2
|
-
import { proto_lightpush_v3 } from "@waku/proto";
|
3
|
-
import { isMessageSizeUnderCap } from "@waku/utils";
|
4
|
-
import { Logger } from "@waku/utils";
|
5
|
-
import all from "it-all";
|
6
|
-
import * as lp from "it-length-prefixed";
|
7
|
-
import { pipe } from "it-pipe";
|
8
|
-
import { Uint8ArrayList } from "uint8arraylist";
|
9
|
-
import { BaseProtocol } from "../base_protocol.js";
|
10
|
-
import { PushRpcV3 } from "./push_rpc_v3.js";
|
11
|
-
import { getLightPushStatusDescriptionV3, lightPushStatusCodeToProtocolErrorV3 } from "./status_codes_v3.js";
|
12
|
-
import { isRLNResponseError } from "./utils.js";
|
13
|
-
const log = new Logger("light-push-v3");
|
14
|
-
export class LightPushCoreV3 extends BaseProtocol {
|
15
|
-
pubsubTopics;
|
16
|
-
constructor(pubsubTopics, libp2p) {
|
17
|
-
super(LightPushCodecV3, libp2p.components, pubsubTopics);
|
18
|
-
this.pubsubTopics = pubsubTopics;
|
19
|
-
}
|
20
|
-
async preparePushMessage(encoder, message) {
|
21
|
-
try {
|
22
|
-
if (!message.payload || message.payload.length === 0) {
|
23
|
-
log.error("Failed to send waku light push: payload is empty");
|
24
|
-
return { query: null, error: ProtocolError.EMPTY_PAYLOAD };
|
25
|
-
}
|
26
|
-
if (!(await isMessageSizeUnderCap(encoder, message))) {
|
27
|
-
log.error("Failed to send waku light push: message is bigger than 1MB");
|
28
|
-
return { query: null, error: ProtocolError.SIZE_TOO_BIG };
|
29
|
-
}
|
30
|
-
const protoMessage = await encoder.toProtoObj(message);
|
31
|
-
if (!protoMessage) {
|
32
|
-
log.error("Failed to encode to protoMessage, aborting push");
|
33
|
-
return {
|
34
|
-
query: null,
|
35
|
-
error: ProtocolError.ENCODE_FAILED
|
36
|
-
};
|
37
|
-
}
|
38
|
-
const query = PushRpcV3.createRequest(protoMessage, encoder.pubsubTopic);
|
39
|
-
return { query, error: null };
|
40
|
-
}
|
41
|
-
catch (error) {
|
42
|
-
log.error("Failed to prepare push message", error);
|
43
|
-
return {
|
44
|
-
query: null,
|
45
|
-
error: ProtocolError.GENERIC_FAIL
|
46
|
-
};
|
47
|
-
}
|
48
|
-
}
|
49
|
-
async send(encoder, message, peerId) {
|
50
|
-
const { query, error: preparationError } = await this.preparePushMessage(encoder, message);
|
51
|
-
if (preparationError || !query) {
|
52
|
-
return {
|
53
|
-
success: null,
|
54
|
-
failure: {
|
55
|
-
error: preparationError,
|
56
|
-
peerId
|
57
|
-
}
|
58
|
-
};
|
59
|
-
}
|
60
|
-
let stream;
|
61
|
-
try {
|
62
|
-
stream = await this.getStream(peerId);
|
63
|
-
}
|
64
|
-
catch (error) {
|
65
|
-
log.error("Failed to get stream", error);
|
66
|
-
return {
|
67
|
-
success: null,
|
68
|
-
failure: {
|
69
|
-
error: ProtocolError.NO_STREAM_AVAILABLE,
|
70
|
-
peerId: peerId
|
71
|
-
}
|
72
|
-
};
|
73
|
-
}
|
74
|
-
let res;
|
75
|
-
try {
|
76
|
-
res = await pipe([query.encode()], lp.encode, stream, lp.decode, async (source) => await all(source));
|
77
|
-
}
|
78
|
-
catch (err) {
|
79
|
-
log.error("Failed to send waku light push request", err);
|
80
|
-
return {
|
81
|
-
success: null,
|
82
|
-
failure: {
|
83
|
-
error: ProtocolError.STREAM_ABORTED,
|
84
|
-
peerId: peerId
|
85
|
-
}
|
86
|
-
};
|
87
|
-
}
|
88
|
-
const bytes = new Uint8ArrayList();
|
89
|
-
res.forEach((chunk) => {
|
90
|
-
bytes.append(chunk);
|
91
|
-
});
|
92
|
-
let response;
|
93
|
-
try {
|
94
|
-
response = proto_lightpush_v3.LightpushResponse.decode(bytes);
|
95
|
-
}
|
96
|
-
catch (err) {
|
97
|
-
log.error("Failed to decode push response", err);
|
98
|
-
return {
|
99
|
-
success: null,
|
100
|
-
failure: {
|
101
|
-
error: ProtocolError.DECODE_FAILED,
|
102
|
-
peerId: peerId
|
103
|
-
}
|
104
|
-
};
|
105
|
-
}
|
106
|
-
if (!response) {
|
107
|
-
log.error("Remote peer fault: No response received");
|
108
|
-
return {
|
109
|
-
success: null,
|
110
|
-
failure: {
|
111
|
-
error: ProtocolError.NO_RESPONSE,
|
112
|
-
peerId: peerId
|
113
|
-
}
|
114
|
-
};
|
115
|
-
}
|
116
|
-
// Validate request ID matches (except for rate limiting responses)
|
117
|
-
if (response.requestId !== query.query?.requestId) {
|
118
|
-
// nwaku sends "N/A" for rate limiting responses
|
119
|
-
if (response.statusCode !== LightPushStatusCodeV3.TOO_MANY_REQUESTS) {
|
120
|
-
log.error("Request ID mismatch", {
|
121
|
-
sent: query.query?.requestId,
|
122
|
-
received: response.requestId
|
123
|
-
});
|
124
|
-
return {
|
125
|
-
success: null,
|
126
|
-
failure: {
|
127
|
-
error: ProtocolError.GENERIC_FAIL,
|
128
|
-
peerId: peerId
|
129
|
-
}
|
130
|
-
};
|
131
|
-
}
|
132
|
-
}
|
133
|
-
const statusCode = response.statusCode;
|
134
|
-
const isSuccess = isSuccessStatusCodeV3(statusCode);
|
135
|
-
// Special handling for nwaku rate limiting
|
136
|
-
if (statusCode === LightPushStatusCodeV3.TOO_MANY_REQUESTS) {
|
137
|
-
if (response.requestId === "N/A") {
|
138
|
-
log.warn("Rate limited by nwaku node", {
|
139
|
-
statusDesc: response.statusDesc || "Request rejected due to too many requests"
|
140
|
-
});
|
141
|
-
}
|
142
|
-
}
|
143
|
-
if (response.relayPeerCount !== undefined) {
|
144
|
-
log.info(`Message relayed to ${response.relayPeerCount} peers`);
|
145
|
-
}
|
146
|
-
if (response.statusDesc && isRLNResponseError(response.statusDesc)) {
|
147
|
-
log.error("Remote peer fault: RLN generation");
|
148
|
-
return {
|
149
|
-
success: null,
|
150
|
-
failure: {
|
151
|
-
error: ProtocolError.RLN_PROOF_GENERATION,
|
152
|
-
peerId: peerId
|
153
|
-
}
|
154
|
-
};
|
155
|
-
}
|
156
|
-
if (!isSuccess) {
|
157
|
-
const errorMessage = getLightPushStatusDescriptionV3(statusCode, response.statusDesc);
|
158
|
-
log.error("Remote peer rejected the message: ", errorMessage);
|
159
|
-
const protocolError = lightPushStatusCodeToProtocolErrorV3(statusCode);
|
160
|
-
return {
|
161
|
-
success: null,
|
162
|
-
failure: {
|
163
|
-
error: protocolError,
|
164
|
-
peerId: peerId
|
165
|
-
}
|
166
|
-
};
|
167
|
-
}
|
168
|
-
return { success: peerId, failure: null };
|
169
|
-
}
|
170
|
-
}
|
171
|
-
//# sourceMappingURL=light_push_v3.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"light_push_v3.js","sourceRoot":"","sources":["../../../src/lib/light_push/light_push_v3.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,qBAAqB,EAErB,gBAAgB,EAChB,qBAAqB,EACrB,aAAa,EAGd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAe,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE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UAAU,CAAC,EAAE,CAAC;YACnE,GAAG,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC;YAC/C,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE;oBACP,KAAK,EAAE,aAAa,CAAC,oBAAoB;oBACzC,MAAM,EAAE,MAAM;iBACf;aACF,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,YAAY,GAAG,+BAA+B,CAClD,UAAU,EACV,QAAQ,CAAC,UAAU,CACpB,CAAC;YACF,GAAG,CAAC,KAAK,CAAC,oCAAoC,EAAE,YAAY,CAAC,CAAC;YAE9D,MAAM,aAAa,GAAG,oCAAoC,CAAC,UAAU,CAAC,CAAC;YACvE,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE;oBACP,KAAK,EAAE,aAAa;oBACpB,MAAM,EAAE,MAAM;iBACf;aACF,CAAC;QACJ,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC5C,CAAC;CACF"}
|
@@ -1,11 +0,0 @@
|
|
1
|
-
import { proto_lightpush_v2 as proto } from "@waku/proto";
|
2
|
-
import type { Uint8ArrayList } from "uint8arraylist";
|
3
|
-
export declare class PushRpcV2 {
|
4
|
-
proto: proto.PushRpc;
|
5
|
-
constructor(proto: proto.PushRpc);
|
6
|
-
static createRequest(message: proto.WakuMessage, pubsubTopic: string): PushRpcV2;
|
7
|
-
static decode(bytes: Uint8ArrayList): PushRpcV2;
|
8
|
-
encode(): Uint8Array;
|
9
|
-
get query(): proto.PushRequest | undefined;
|
10
|
-
get response(): proto.PushResponse | undefined;
|
11
|
-
}
|
@@ -1,32 +0,0 @@
|
|
1
|
-
import { proto_lightpush_v2 as proto } from "@waku/proto";
|
2
|
-
import { v4 as uuid } from "uuid";
|
3
|
-
export class PushRpcV2 {
|
4
|
-
proto;
|
5
|
-
constructor(proto) {
|
6
|
-
this.proto = proto;
|
7
|
-
}
|
8
|
-
static createRequest(message, pubsubTopic) {
|
9
|
-
return new PushRpcV2({
|
10
|
-
requestId: uuid(),
|
11
|
-
request: {
|
12
|
-
message: message,
|
13
|
-
pubsubTopic: pubsubTopic
|
14
|
-
},
|
15
|
-
response: undefined
|
16
|
-
});
|
17
|
-
}
|
18
|
-
static decode(bytes) {
|
19
|
-
const res = proto.PushRpc.decode(bytes);
|
20
|
-
return new PushRpcV2(res);
|
21
|
-
}
|
22
|
-
encode() {
|
23
|
-
return proto.PushRpc.encode(this.proto);
|
24
|
-
}
|
25
|
-
get query() {
|
26
|
-
return this.proto.request;
|
27
|
-
}
|
28
|
-
get response() {
|
29
|
-
return this.proto.response;
|
30
|
-
}
|
31
|
-
}
|
32
|
-
//# sourceMappingURL=push_rpc_v2.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"push_rpc_v2.js","sourceRoot":"","sources":["../../../src/lib/light_push/push_rpc_v2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,IAAI,KAAK,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,MAAM,OAAO,SAAS;IACM;IAA1B,YAA0B,KAAoB;QAApB,UAAK,GAAL,KAAK,CAAe;IAAG,CAAC;IAE3C,MAAM,CAAC,aAAa,CACzB,OAA0B,EAC1B,WAAmB;QAEnB,OAAO,IAAI,SAAS,CAAC;YACnB,SAAS,EAAE,IAAI,EAAE;YACjB,OAAO,EAAE;gBACP,OAAO,EAAE,OAAO;gBAChB,WAAW,EAAE,WAAW;aACzB;YACD,QAAQ,EAAE,SAAS;SACpB,CAAC,CAAC;IACL,CAAC;IAEM,MAAM,CAAC,MAAM,CAAC,KAAqB;QACxC,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACxC,OAAO,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IAEM,MAAM;QACX,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC;IAED,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;IAC5B,CAAC;IAED,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC7B,CAAC;CACF"}
|
@@ -1,11 +0,0 @@
|
|
1
|
-
import { proto_lightpush_v3, WakuMessage } from "@waku/proto";
|
2
|
-
import type { Uint8ArrayList } from "uint8arraylist";
|
3
|
-
export declare class PushRpcV3 {
|
4
|
-
request?: proto_lightpush_v3.LightpushRequest;
|
5
|
-
response?: proto_lightpush_v3.LightpushResponse;
|
6
|
-
private constructor();
|
7
|
-
static createRequest(message: WakuMessage, pubsubTopic?: string): PushRpcV3;
|
8
|
-
static decode(bytes: Uint8ArrayList | Uint8Array): PushRpcV3;
|
9
|
-
encode(): Uint8Array;
|
10
|
-
get query(): proto_lightpush_v3.LightpushRequest | undefined;
|
11
|
-
}
|
@@ -1,33 +0,0 @@
|
|
1
|
-
import { proto_lightpush_v3 } from "@waku/proto";
|
2
|
-
import { v4 as uuid } from "uuid";
|
3
|
-
export class PushRpcV3 {
|
4
|
-
request;
|
5
|
-
response;
|
6
|
-
constructor(request, response) {
|
7
|
-
this.request = request;
|
8
|
-
this.response = response;
|
9
|
-
}
|
10
|
-
static createRequest(message, pubsubTopic) {
|
11
|
-
const request = {
|
12
|
-
requestId: uuid(),
|
13
|
-
message: message,
|
14
|
-
// Only include pubsubTopic if explicitly provided (for nwaku autosharding compatibility)
|
15
|
-
...(pubsubTopic && { pubsubTopic })
|
16
|
-
};
|
17
|
-
return new PushRpcV3(request, undefined);
|
18
|
-
}
|
19
|
-
static decode(bytes) {
|
20
|
-
const response = proto_lightpush_v3.LightpushResponse.decode(bytes);
|
21
|
-
return new PushRpcV3(undefined, response);
|
22
|
-
}
|
23
|
-
encode() {
|
24
|
-
if (!this.request) {
|
25
|
-
throw new Error("Cannot encode without a request");
|
26
|
-
}
|
27
|
-
return proto_lightpush_v3.LightpushRequest.encode(this.request);
|
28
|
-
}
|
29
|
-
get query() {
|
30
|
-
return this.request;
|
31
|
-
}
|
32
|
-
}
|
33
|
-
//# sourceMappingURL=push_rpc_v3.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"push_rpc_v3.js","sourceRoot":"","sources":["../../../src/lib/light_push/push_rpc_v3.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAe,MAAM,aAAa,CAAC;AAE9D,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,MAAM,OAAO,SAAS;IACb,OAAO,CAAuC;IAC9C,QAAQ,CAAwC;IAEvD,YACE,OAA6C,EAC7C,QAA+C;QAE/C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAEM,MAAM,CAAC,aAAa,CACzB,OAAoB,EACpB,WAAoB;QAEpB,MAAM,OAAO,GAAwC;YACnD,SAAS,EAAE,IAAI,EAAE;YACjB,OAAO,EAAE,OAAO;YAChB,yFAAyF;YACzF,GAAG,CAAC,WAAW,IAAI,EAAE,WAAW,EAAE,CAAC;SACpC,CAAC;QAEF,OAAO,IAAI,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAC3C,CAAC;IAEM,MAAM,CAAC,MAAM,CAAC,KAAkC;QACrD,MAAM,QAAQ,GAAG,kBAAkB,CAAC,iBAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACpE,OAAO,IAAI,SAAS,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC5C,CAAC;IAEM,MAAM;QACX,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACrD,CAAC;QACD,OAAO,kBAAkB,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAClE,CAAC;IAED,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF"}
|
@@ -1,14 +0,0 @@
|
|
1
|
-
import { ProtocolError } from "@waku/interfaces";
|
2
|
-
export declare enum LightPushStatusCode {
|
3
|
-
SUCCESS = 200,
|
4
|
-
BAD_REQUEST = 400,
|
5
|
-
UNSUPPORTED_PUBSUB_TOPIC = 404,
|
6
|
-
REQUEST_TOO_LARGE = 413,
|
7
|
-
TOO_MANY_REQUESTS = 429,
|
8
|
-
INTERNAL_SERVER_ERROR = 500,
|
9
|
-
NO_PEERS_TO_RELAY = 503
|
10
|
-
}
|
11
|
-
export declare function lightPushStatusCodeToProtocolError(statusCode: number): ProtocolError | null;
|
12
|
-
export declare const lightPushStatusDescriptions: Record<number, string>;
|
13
|
-
export declare function isSuccessStatusCode(statusCode: number): boolean;
|
14
|
-
export declare function getLightPushStatusDescription(statusCode: number, statusDesc?: string): string;
|