@waku/interfaces 0.0.12 → 0.0.14
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 +19 -0
- package/dist/filter.d.ts +16 -1
- package/dist/message.d.ts +1 -0
- package/dist/misc.d.ts +1 -0
- package/dist/protocols.d.ts +14 -0
- package/dist/protocols.js +8 -0
- package/dist/protocols.js.map +1 -1
- package/dist/receiver.d.ts +3 -2
- package/dist/waku.d.ts +4 -4
- package/package.json +2 -2
- package/src/filter.ts +30 -1
- package/src/message.ts +1 -0
- package/src/misc.ts +2 -0
- package/src/protocols.ts +15 -0
- package/src/receiver.ts +3 -7
- package/src/waku.ts +4 -4
package/CHANGELOG.md
CHANGED
@@ -5,6 +5,25 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The file is maintained by [Release Please](https://github.com/googleapis/release-please) based on [Conventional Commits](https://www.conventionalcommits.org) specification,
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
## [0.0.14](https://github.com/waku-org/js-waku/compare/interfaces-v0.0.13...interfaces-v0.0.14) (2023-05-26)
|
9
|
+
|
10
|
+
|
11
|
+
### ⚠ BREAKING CHANGES
|
12
|
+
|
13
|
+
* filter v2 ([#1332](https://github.com/waku-org/js-waku/issues/1332))
|
14
|
+
|
15
|
+
### Features
|
16
|
+
|
17
|
+
* Filter v2 ([#1332](https://github.com/waku-org/js-waku/issues/1332)) ([8d0e647](https://github.com/waku-org/js-waku/commit/8d0e64796695fbafad0a033552eb4412bdff3d78))
|
18
|
+
|
19
|
+
## [0.0.13](https://github.com/waku-org/js-waku/compare/interfaces-v0.0.12...interfaces-v0.0.13) (2023-05-18)
|
20
|
+
|
21
|
+
|
22
|
+
### Features
|
23
|
+
|
24
|
+
* Add 1MB restriction to LightPush and Relay ([#1351](https://github.com/waku-org/js-waku/issues/1351)) ([72f97d4](https://github.com/waku-org/js-waku/commit/72f97d4545512f92936b1a9b50fa0b53f8603f9d))
|
25
|
+
* Expose `meta` on `IDecodedMessage` ([5724bb2](https://github.com/waku-org/js-waku/commit/5724bb2b21367e4e397acbc5530b3a2bf315194e))
|
26
|
+
|
8
27
|
## [0.0.12](https://github.com/waku-org/js-waku/compare/interfaces-v0.0.11...interfaces-v0.0.12) (2023-05-09)
|
9
28
|
|
10
29
|
|
package/dist/filter.d.ts
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
-
import type {
|
1
|
+
import type { PeerId } from "@libp2p/interface-peer-id";
|
2
|
+
import type { IDecodedMessage, IDecoder } from "./message.js";
|
3
|
+
import type { ContentTopic } from "./misc.js";
|
4
|
+
import type { Callback, PointToPointProtocol } from "./protocols.js";
|
2
5
|
import type { IReceiver } from "./receiver.js";
|
6
|
+
export type ContentFilter = {
|
7
|
+
contentTopic: string;
|
8
|
+
};
|
3
9
|
export type IFilter = IReceiver & PointToPointProtocol;
|
10
|
+
export interface IFilterV2Subscription {
|
11
|
+
subscribe<T extends IDecodedMessage>(decoders: IDecoder<T> | IDecoder<T>[], callback: Callback<T>): Promise<void>;
|
12
|
+
unsubscribe(contentTopics: ContentTopic[]): Promise<void>;
|
13
|
+
ping(): Promise<void>;
|
14
|
+
unsubscribeAll(): Promise<void>;
|
15
|
+
}
|
16
|
+
export type IFilterV2 = IReceiver & PointToPointProtocol & {
|
17
|
+
createSubscription(pubSubTopic?: string, peerId?: PeerId): Promise<IFilterV2Subscription>;
|
18
|
+
};
|
package/dist/message.d.ts
CHANGED
@@ -61,6 +61,7 @@ export interface IDecodedMessage {
|
|
61
61
|
timestamp: Date | undefined;
|
62
62
|
rateLimitProof: IRateLimitProof | undefined;
|
63
63
|
ephemeral: boolean | undefined;
|
64
|
+
meta: Uint8Array | undefined;
|
64
65
|
}
|
65
66
|
export interface IDecoder<T extends IDecodedMessage> {
|
66
67
|
contentTopic: string;
|
package/dist/misc.d.ts
CHANGED
package/dist/protocols.d.ts
CHANGED
@@ -45,6 +45,12 @@ export type ProtocolCreateOptions = {
|
|
45
45
|
* Use recommended bootstrap method to discovery and connect to new nodes.
|
46
46
|
*/
|
47
47
|
defaultBootstrap?: boolean;
|
48
|
+
/**
|
49
|
+
* FilterV2 has been set to default
|
50
|
+
* Use this flag to enable the previous version of the filter protocol
|
51
|
+
* See [Improved Filter protocol specifications](https://github.com/vacp2p/rfc/pull/562)
|
52
|
+
*/
|
53
|
+
useFilterV1?: boolean;
|
48
54
|
};
|
49
55
|
export type ProtocolOptions = {
|
50
56
|
/**
|
@@ -53,6 +59,14 @@ export type ProtocolOptions = {
|
|
53
59
|
peerId?: PeerId;
|
54
60
|
};
|
55
61
|
export type Callback<T extends IDecodedMessage> = (msg: T) => void | Promise<void>;
|
62
|
+
export declare enum SendError {
|
63
|
+
GENERIC_FAIL = "Generic error",
|
64
|
+
ENCODE_FAILED = "Failed to encode",
|
65
|
+
DECODE_FAILED = "Failed to decode",
|
66
|
+
SIZE_TOO_BIG = "Size is too big",
|
67
|
+
NO_RPC_RESPONSE = "No RPC response"
|
68
|
+
}
|
56
69
|
export interface SendResult {
|
70
|
+
error?: SendError;
|
57
71
|
recipients: PeerId[];
|
58
72
|
}
|
package/dist/protocols.js
CHANGED
@@ -5,4 +5,12 @@ export var Protocols;
|
|
5
5
|
Protocols["LightPush"] = "lightpush";
|
6
6
|
Protocols["Filter"] = "filter";
|
7
7
|
})(Protocols || (Protocols = {}));
|
8
|
+
export var SendError;
|
9
|
+
(function (SendError) {
|
10
|
+
SendError["GENERIC_FAIL"] = "Generic error";
|
11
|
+
SendError["ENCODE_FAILED"] = "Failed to encode";
|
12
|
+
SendError["DECODE_FAILED"] = "Failed to decode";
|
13
|
+
SendError["SIZE_TOO_BIG"] = "Size is too big";
|
14
|
+
SendError["NO_RPC_RESPONSE"] = "No RPC response";
|
15
|
+
})(SendError || (SendError = {}));
|
8
16
|
//# sourceMappingURL=protocols.js.map
|
package/dist/protocols.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"protocols.js","sourceRoot":"","sources":["../src/protocols.ts"],"names":[],"mappings":"AAMA,MAAM,CAAN,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,4BAAe,CAAA;IACf,4BAAe,CAAA;IACf,oCAAuB,CAAA;IACvB,8BAAiB,CAAA;AACnB,CAAC,EALW,SAAS,KAAT,SAAS,QAKpB"}
|
1
|
+
{"version":3,"file":"protocols.js","sourceRoot":"","sources":["../src/protocols.ts"],"names":[],"mappings":"AAMA,MAAM,CAAN,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,4BAAe,CAAA;IACf,4BAAe,CAAA;IACf,oCAAuB,CAAA;IACvB,8BAAiB,CAAA;AACnB,CAAC,EALW,SAAS,KAAT,SAAS,QAKpB;AA2DD,MAAM,CAAN,IAAY,SAMX;AAND,WAAY,SAAS;IACnB,2CAA8B,CAAA;IAC9B,+CAAkC,CAAA;IAClC,+CAAkC,CAAA;IAClC,6CAAgC,CAAA;IAChC,gDAAmC,CAAA;AACrC,CAAC,EANW,SAAS,KAAT,SAAS,QAMpB"}
|
package/dist/receiver.d.ts
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
import type { IDecodedMessage, IDecoder } from "./message.js";
|
2
|
-
import type {
|
2
|
+
import type { IAsyncIterator, PubSubTopic, Unsubscribe } from "./misc.js";
|
3
3
|
import type { Callback, ProtocolOptions } from "./protocols.js";
|
4
|
+
type ContentTopic = string;
|
4
5
|
export type ActiveSubscriptions = Map<PubSubTopic, ContentTopic[]>;
|
5
6
|
export interface IReceiver {
|
6
7
|
toSubscriptionIterator: <T extends IDecodedMessage>(decoders: IDecoder<T> | IDecoder<T>[], opts?: ProtocolOptions) => Promise<IAsyncIterator<T>>;
|
7
8
|
subscribe: <T extends IDecodedMessage>(decoders: IDecoder<T> | IDecoder<T>[], callback: Callback<T>, opts?: ProtocolOptions) => Unsubscribe | Promise<Unsubscribe>;
|
8
|
-
getActiveSubscriptions: () => ActiveSubscriptions;
|
9
9
|
}
|
10
|
+
export {};
|
package/dist/waku.d.ts
CHANGED
@@ -2,7 +2,7 @@ import type { Stream } from "@libp2p/interface-connection";
|
|
2
2
|
import type { Libp2p } from "@libp2p/interface-libp2p";
|
3
3
|
import type { PeerId } from "@libp2p/interface-peer-id";
|
4
4
|
import type { Multiaddr } from "@multiformats/multiaddr";
|
5
|
-
import type { IFilter } from "./filter.js";
|
5
|
+
import type { IFilter, IFilterV2 } from "./filter.js";
|
6
6
|
import type { ILightPush } from "./light_push.js";
|
7
7
|
import { Protocols } from "./protocols.js";
|
8
8
|
import type { IRelay } from "./relay.js";
|
@@ -11,7 +11,7 @@ export interface Waku {
|
|
11
11
|
libp2p: Libp2p;
|
12
12
|
relay?: IRelay;
|
13
13
|
store?: IStore;
|
14
|
-
filter?: IFilter;
|
14
|
+
filter?: IFilter | IFilterV2;
|
15
15
|
lightPush?: ILightPush;
|
16
16
|
dial(peer: PeerId | Multiaddr, protocols?: Protocols[]): Promise<Stream>;
|
17
17
|
start(): Promise<void>;
|
@@ -21,7 +21,7 @@ export interface Waku {
|
|
21
21
|
export interface LightNode extends Waku {
|
22
22
|
relay: undefined;
|
23
23
|
store: IStore;
|
24
|
-
filter: IFilter;
|
24
|
+
filter: IFilter | IFilterV2;
|
25
25
|
lightPush: ILightPush;
|
26
26
|
}
|
27
27
|
export interface RelayNode extends Waku {
|
@@ -33,6 +33,6 @@ export interface RelayNode extends Waku {
|
|
33
33
|
export interface FullNode extends Waku {
|
34
34
|
relay: IRelay;
|
35
35
|
store: IStore;
|
36
|
-
filter: IFilter;
|
36
|
+
filter: IFilter | IFilterV2;
|
37
37
|
lightPush: ILightPush;
|
38
38
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@waku/interfaces",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.14",
|
4
4
|
"description": "Definition of Waku interfaces",
|
5
5
|
"types": "./dist/index.d.ts",
|
6
6
|
"module": "./dist/index.js",
|
@@ -67,7 +67,7 @@
|
|
67
67
|
"eslint-plugin-prettier": "^4.2.1",
|
68
68
|
"npm-run-all": "^4.1.5",
|
69
69
|
"prettier": "^2.8.8",
|
70
|
-
"typescript": "^
|
70
|
+
"typescript": "^5.0.4"
|
71
71
|
},
|
72
72
|
"typedoc": {
|
73
73
|
"entryPoint": "./src/index.ts"
|
package/src/filter.ts
CHANGED
@@ -1,4 +1,33 @@
|
|
1
|
-
import type {
|
1
|
+
import type { PeerId } from "@libp2p/interface-peer-id";
|
2
|
+
|
3
|
+
import type { IDecodedMessage, IDecoder } from "./message.js";
|
4
|
+
import type { ContentTopic } from "./misc.js";
|
5
|
+
import type { Callback, PointToPointProtocol } from "./protocols.js";
|
2
6
|
import type { IReceiver } from "./receiver.js";
|
3
7
|
|
8
|
+
export type ContentFilter = {
|
9
|
+
contentTopic: string;
|
10
|
+
};
|
11
|
+
|
4
12
|
export type IFilter = IReceiver & PointToPointProtocol;
|
13
|
+
|
14
|
+
export interface IFilterV2Subscription {
|
15
|
+
subscribe<T extends IDecodedMessage>(
|
16
|
+
decoders: IDecoder<T> | IDecoder<T>[],
|
17
|
+
callback: Callback<T>
|
18
|
+
): Promise<void>;
|
19
|
+
|
20
|
+
unsubscribe(contentTopics: ContentTopic[]): Promise<void>;
|
21
|
+
|
22
|
+
ping(): Promise<void>;
|
23
|
+
|
24
|
+
unsubscribeAll(): Promise<void>;
|
25
|
+
}
|
26
|
+
|
27
|
+
export type IFilterV2 = IReceiver &
|
28
|
+
PointToPointProtocol & {
|
29
|
+
createSubscription(
|
30
|
+
pubSubTopic?: string,
|
31
|
+
peerId?: PeerId
|
32
|
+
): Promise<IFilterV2Subscription>;
|
33
|
+
};
|
package/src/message.ts
CHANGED
package/src/misc.ts
CHANGED
package/src/protocols.ts
CHANGED
@@ -49,6 +49,12 @@ export type ProtocolCreateOptions = {
|
|
49
49
|
* Use recommended bootstrap method to discovery and connect to new nodes.
|
50
50
|
*/
|
51
51
|
defaultBootstrap?: boolean;
|
52
|
+
/**
|
53
|
+
* FilterV2 has been set to default
|
54
|
+
* Use this flag to enable the previous version of the filter protocol
|
55
|
+
* See [Improved Filter protocol specifications](https://github.com/vacp2p/rfc/pull/562)
|
56
|
+
*/
|
57
|
+
useFilterV1?: boolean;
|
52
58
|
};
|
53
59
|
|
54
60
|
export type ProtocolOptions = {
|
@@ -62,6 +68,15 @@ export type Callback<T extends IDecodedMessage> = (
|
|
62
68
|
msg: T
|
63
69
|
) => void | Promise<void>;
|
64
70
|
|
71
|
+
export enum SendError {
|
72
|
+
GENERIC_FAIL = "Generic error",
|
73
|
+
ENCODE_FAILED = "Failed to encode",
|
74
|
+
DECODE_FAILED = "Failed to decode",
|
75
|
+
SIZE_TOO_BIG = "Size is too big",
|
76
|
+
NO_RPC_RESPONSE = "No RPC response",
|
77
|
+
}
|
78
|
+
|
65
79
|
export interface SendResult {
|
80
|
+
error?: SendError;
|
66
81
|
recipients: PeerId[];
|
67
82
|
}
|
package/src/receiver.ts
CHANGED
@@ -1,12 +1,9 @@
|
|
1
1
|
import type { IDecodedMessage, IDecoder } from "./message.js";
|
2
|
-
import type {
|
3
|
-
ContentTopic,
|
4
|
-
IAsyncIterator,
|
5
|
-
PubSubTopic,
|
6
|
-
Unsubscribe,
|
7
|
-
} from "./misc.js";
|
2
|
+
import type { IAsyncIterator, PubSubTopic, Unsubscribe } from "./misc.js";
|
8
3
|
import type { Callback, ProtocolOptions } from "./protocols.js";
|
9
4
|
|
5
|
+
type ContentTopic = string;
|
6
|
+
|
10
7
|
export type ActiveSubscriptions = Map<PubSubTopic, ContentTopic[]>;
|
11
8
|
|
12
9
|
export interface IReceiver {
|
@@ -19,5 +16,4 @@ export interface IReceiver {
|
|
19
16
|
callback: Callback<T>,
|
20
17
|
opts?: ProtocolOptions
|
21
18
|
) => Unsubscribe | Promise<Unsubscribe>;
|
22
|
-
getActiveSubscriptions: () => ActiveSubscriptions;
|
23
19
|
}
|
package/src/waku.ts
CHANGED
@@ -3,7 +3,7 @@ import type { Libp2p } from "@libp2p/interface-libp2p";
|
|
3
3
|
import type { PeerId } from "@libp2p/interface-peer-id";
|
4
4
|
import type { Multiaddr } from "@multiformats/multiaddr";
|
5
5
|
|
6
|
-
import type { IFilter } from "./filter.js";
|
6
|
+
import type { IFilter, IFilterV2 } from "./filter.js";
|
7
7
|
import type { ILightPush } from "./light_push.js";
|
8
8
|
import { Protocols } from "./protocols.js";
|
9
9
|
import type { IRelay } from "./relay.js";
|
@@ -13,7 +13,7 @@ export interface Waku {
|
|
13
13
|
libp2p: Libp2p;
|
14
14
|
relay?: IRelay;
|
15
15
|
store?: IStore;
|
16
|
-
filter?: IFilter;
|
16
|
+
filter?: IFilter | IFilterV2;
|
17
17
|
lightPush?: ILightPush;
|
18
18
|
|
19
19
|
dial(peer: PeerId | Multiaddr, protocols?: Protocols[]): Promise<Stream>;
|
@@ -28,7 +28,7 @@ export interface Waku {
|
|
28
28
|
export interface LightNode extends Waku {
|
29
29
|
relay: undefined;
|
30
30
|
store: IStore;
|
31
|
-
filter: IFilter;
|
31
|
+
filter: IFilter | IFilterV2;
|
32
32
|
lightPush: ILightPush;
|
33
33
|
}
|
34
34
|
|
@@ -42,6 +42,6 @@ export interface RelayNode extends Waku {
|
|
42
42
|
export interface FullNode extends Waku {
|
43
43
|
relay: IRelay;
|
44
44
|
store: IStore;
|
45
|
-
filter: IFilter;
|
45
|
+
filter: IFilter | IFilterV2;
|
46
46
|
lightPush: ILightPush;
|
47
47
|
}
|