@waku/interfaces 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/dist/index.d.ts +136 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/package.json +178 -0
- package/src/index.ts +187 -0
package/dist/index.d.ts
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
import type { GossipSub } from "@chainsafe/libp2p-gossipsub";
|
2
|
+
import type { Stream } from "@libp2p/interface-connection";
|
3
|
+
import type { PeerId } from "@libp2p/interface-peer-id";
|
4
|
+
import type { Peer } from "@libp2p/interface-peer-store";
|
5
|
+
import type { Multiaddr } from "@multiformats/multiaddr";
|
6
|
+
import type { Libp2p } from "libp2p";
|
7
|
+
export declare enum Protocols {
|
8
|
+
Relay = "relay",
|
9
|
+
Store = "store",
|
10
|
+
LightPush = "lightpush",
|
11
|
+
Filter = "filter"
|
12
|
+
}
|
13
|
+
export interface PointToPointProtocol {
|
14
|
+
libp2p: Libp2p;
|
15
|
+
peers: () => Promise<Peer[]>;
|
16
|
+
}
|
17
|
+
export declare type ProtocolOptions = {
|
18
|
+
pubSubTopic?: string;
|
19
|
+
/**
|
20
|
+
* Optionally specify an PeerId for the protocol request. If not included, will use a random peer.
|
21
|
+
*/
|
22
|
+
peerId?: PeerId;
|
23
|
+
};
|
24
|
+
export declare type Callback<T extends Message> = (msg: T) => void | Promise<void>;
|
25
|
+
export interface Filter extends PointToPointProtocol {
|
26
|
+
subscribe: <T extends Message>(decoders: Decoder<T>[], callback: Callback<T>, opts?: ProtocolOptions) => Promise<() => Promise<void>>;
|
27
|
+
}
|
28
|
+
export interface LightPush extends PointToPointProtocol {
|
29
|
+
push: (encoder: Encoder, message: Partial<Message>, opts?: ProtocolOptions) => Promise<SendResult>;
|
30
|
+
}
|
31
|
+
export declare enum PageDirection {
|
32
|
+
BACKWARD = "backward",
|
33
|
+
FORWARD = "forward"
|
34
|
+
}
|
35
|
+
export interface TimeFilter {
|
36
|
+
startTime: Date;
|
37
|
+
endTime: Date;
|
38
|
+
}
|
39
|
+
export declare type StoreQueryOptions = {
|
40
|
+
/**
|
41
|
+
* The direction in which pages are retrieved:
|
42
|
+
* - { @link PageDirection.BACKWARD }: Most recent page first.
|
43
|
+
* - { @link PageDirection.FORWARD }: Oldest page first.
|
44
|
+
*
|
45
|
+
* Note: This does not affect the ordering of messages with the page
|
46
|
+
* (the oldest message is always first).
|
47
|
+
*
|
48
|
+
* @default { @link PageDirection.BACKWARD }
|
49
|
+
*/
|
50
|
+
pageDirection?: PageDirection;
|
51
|
+
/**
|
52
|
+
* The number of message per page.
|
53
|
+
*
|
54
|
+
* @default { @link DefaultPageSize }
|
55
|
+
*/
|
56
|
+
pageSize?: number;
|
57
|
+
/**
|
58
|
+
* Retrieve messages with a timestamp within the provided values.
|
59
|
+
*/
|
60
|
+
timeFilter?: TimeFilter;
|
61
|
+
} & ProtocolOptions;
|
62
|
+
export interface Store extends PointToPointProtocol {
|
63
|
+
queryOrderedCallback: <T extends Message>(decoders: Decoder<T>[], callback: (message: T) => Promise<void | boolean> | boolean | void, options?: StoreQueryOptions) => Promise<void>;
|
64
|
+
queryCallbackOnPromise: <T extends Message>(decoders: Decoder<T>[], callback: (message: Promise<T | undefined>) => Promise<void | boolean> | boolean | void, options?: StoreQueryOptions) => Promise<void>;
|
65
|
+
queryGenerator: <T extends Message>(decoders: Decoder<T>[], options?: StoreQueryOptions) => AsyncGenerator<Promise<T | undefined>[]>;
|
66
|
+
}
|
67
|
+
export interface Relay extends GossipSub {
|
68
|
+
send: (encoder: Encoder, message: Partial<Message>) => Promise<SendResult>;
|
69
|
+
addObserver: <T extends Message>(decoder: Decoder<T>, callback: Callback<T>) => () => void;
|
70
|
+
getMeshPeers: () => string[];
|
71
|
+
}
|
72
|
+
export interface Waku {
|
73
|
+
libp2p: Libp2p;
|
74
|
+
relay?: Relay;
|
75
|
+
store?: Store;
|
76
|
+
filter?: Filter;
|
77
|
+
lightPush?: LightPush;
|
78
|
+
dial(peer: PeerId | Multiaddr, protocols?: Protocols[]): Promise<Stream>;
|
79
|
+
addPeerToAddressBook(peerId: PeerId | string, multiaddrs: Multiaddr[] | string[]): void;
|
80
|
+
start(): Promise<void>;
|
81
|
+
stop(): Promise<void>;
|
82
|
+
isStarted(): boolean;
|
83
|
+
}
|
84
|
+
export interface WakuLight extends Waku {
|
85
|
+
relay: undefined;
|
86
|
+
store: Store;
|
87
|
+
filter: Filter;
|
88
|
+
lightPush: LightPush;
|
89
|
+
}
|
90
|
+
export interface WakuPrivacy extends Waku {
|
91
|
+
relay: Relay;
|
92
|
+
store: undefined;
|
93
|
+
filter: undefined;
|
94
|
+
lightPush: undefined;
|
95
|
+
}
|
96
|
+
export interface WakuFull extends Waku {
|
97
|
+
relay: Relay;
|
98
|
+
store: Store;
|
99
|
+
filter: Filter;
|
100
|
+
lightPush: LightPush;
|
101
|
+
}
|
102
|
+
export interface RateLimitProof {
|
103
|
+
proof: Uint8Array;
|
104
|
+
merkleRoot: Uint8Array;
|
105
|
+
epoch: Uint8Array;
|
106
|
+
shareX: Uint8Array;
|
107
|
+
shareY: Uint8Array;
|
108
|
+
nullifier: Uint8Array;
|
109
|
+
rlnIdentifier: Uint8Array;
|
110
|
+
}
|
111
|
+
export interface ProtoMessage {
|
112
|
+
payload: Uint8Array | undefined;
|
113
|
+
contentTopic: string | undefined;
|
114
|
+
version: number | undefined;
|
115
|
+
timestamp: bigint | undefined;
|
116
|
+
rateLimitProof: RateLimitProof | undefined;
|
117
|
+
}
|
118
|
+
export interface Message {
|
119
|
+
payload: Uint8Array | undefined;
|
120
|
+
contentTopic: string | undefined;
|
121
|
+
timestamp: Date | undefined;
|
122
|
+
rateLimitProof: RateLimitProof | undefined;
|
123
|
+
}
|
124
|
+
export interface Encoder {
|
125
|
+
contentTopic: string;
|
126
|
+
toWire: (message: Partial<Message>) => Promise<Uint8Array | undefined>;
|
127
|
+
toProtoObj: (message: Partial<Message>) => Promise<ProtoMessage | undefined>;
|
128
|
+
}
|
129
|
+
export interface Decoder<T extends Message> {
|
130
|
+
contentTopic: string;
|
131
|
+
fromWireToProtoObj: (bytes: Uint8Array) => Promise<ProtoMessage | undefined>;
|
132
|
+
fromProtoObj: (proto: ProtoMessage) => Promise<T | undefined>;
|
133
|
+
}
|
134
|
+
export interface SendResult {
|
135
|
+
recipients: PeerId[];
|
136
|
+
}
|
package/dist/index.js
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
export var Protocols;
|
2
|
+
(function (Protocols) {
|
3
|
+
Protocols["Relay"] = "relay";
|
4
|
+
Protocols["Store"] = "store";
|
5
|
+
Protocols["LightPush"] = "lightpush";
|
6
|
+
Protocols["Filter"] = "filter";
|
7
|
+
})(Protocols || (Protocols = {}));
|
8
|
+
export var PageDirection;
|
9
|
+
(function (PageDirection) {
|
10
|
+
PageDirection["BACKWARD"] = "backward";
|
11
|
+
PageDirection["FORWARD"] = "forward";
|
12
|
+
})(PageDirection || (PageDirection = {}));
|
13
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,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;AAiCD,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,sCAAqB,CAAA;IACrB,oCAAmB,CAAA;AACrB,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB"}
|
package/package.json
ADDED
@@ -0,0 +1,178 @@
|
|
1
|
+
{
|
2
|
+
"name": "@waku/interfaces",
|
3
|
+
"version": "0.0.1",
|
4
|
+
"description": "Definition of Waku interfaces",
|
5
|
+
"types": "./dist/index.d.ts",
|
6
|
+
"module": "./dist/index.js",
|
7
|
+
"exports": {
|
8
|
+
".": {
|
9
|
+
"types": "./dist/index.d.ts",
|
10
|
+
"import": "./dist/index.js"
|
11
|
+
}
|
12
|
+
},
|
13
|
+
"type": "module",
|
14
|
+
"author": "Waku Team",
|
15
|
+
"homepage": "https://github.com/waku-org/js-waku/tree/master/packages/interfaces#readme",
|
16
|
+
"repository": {
|
17
|
+
"type": "git",
|
18
|
+
"url": "https://github.com/waku-org/js-waku.git"
|
19
|
+
},
|
20
|
+
"bugs": {
|
21
|
+
"url": "https://github.com/waku-org/js-waku/issues"
|
22
|
+
},
|
23
|
+
"license": "MIT OR Apache-2.0",
|
24
|
+
"keywords": [
|
25
|
+
"waku",
|
26
|
+
"decentralized",
|
27
|
+
"secure",
|
28
|
+
"communication",
|
29
|
+
"web3",
|
30
|
+
"ethereum",
|
31
|
+
"dapps",
|
32
|
+
"privacy"
|
33
|
+
],
|
34
|
+
"scripts": {
|
35
|
+
"build": "tsc",
|
36
|
+
"fix": "run-s fix:*",
|
37
|
+
"fix:prettier": "prettier . --write",
|
38
|
+
"fix:lint": "eslint src --ext .ts --ext .cjs --fix",
|
39
|
+
"check": "run-s check:*",
|
40
|
+
"check:lint": "eslint src --ext .ts",
|
41
|
+
"check:prettier": "prettier . --list-different",
|
42
|
+
"check:spelling": "cspell \"{README.md,src/**/*.ts}\"",
|
43
|
+
"check:tsc": "tsc -p tsconfig.dev.json",
|
44
|
+
"prepublish": "npm run build",
|
45
|
+
"reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build",
|
46
|
+
"release": "semantic-release"
|
47
|
+
},
|
48
|
+
"engines": {
|
49
|
+
"node": ">=16"
|
50
|
+
},
|
51
|
+
"dependencies": {
|
52
|
+
"@chainsafe/libp2p-gossipsub": "^4.1.1",
|
53
|
+
"@libp2p/interface-connection": "^3.0.2",
|
54
|
+
"@libp2p/interface-peer-id": "^1.0.5",
|
55
|
+
"@libp2p/interface-peer-store": "^1.2.2",
|
56
|
+
"@multiformats/multiaddr": "^11.0.6",
|
57
|
+
"libp2p": "0.38.0"
|
58
|
+
},
|
59
|
+
"devDependencies": {
|
60
|
+
"@semantic-release/changelog": "^6.0.1",
|
61
|
+
"@semantic-release/commit-analyzer": "^9.0.2",
|
62
|
+
"@semantic-release/git": "^10.0.1",
|
63
|
+
"@semantic-release/github": "^8.0.6",
|
64
|
+
"@semantic-release/npm": "^9.0.1",
|
65
|
+
"@semantic-release/release-notes-generator": "^10.0.3",
|
66
|
+
"@typescript-eslint/eslint-plugin": "^5.8.1",
|
67
|
+
"@typescript-eslint/parser": "^5.8.1",
|
68
|
+
"cspell": "^5.14.0",
|
69
|
+
"eslint": "^8.6.0",
|
70
|
+
"eslint-config-prettier": "^8.3.0",
|
71
|
+
"eslint-plugin-eslint-comments": "^3.2.0",
|
72
|
+
"eslint-plugin-functional": "^4.0.2",
|
73
|
+
"eslint-plugin-import": "^2.25.3",
|
74
|
+
"eslint-plugin-prettier": "^4.0.0",
|
75
|
+
"npm-run-all": "^4.1.5",
|
76
|
+
"prettier": "^2.1.1",
|
77
|
+
"semantic-release": "^19.0.5",
|
78
|
+
"semantic-release-monorepo": "^7.0.5",
|
79
|
+
"typescript": "^4.6.3"
|
80
|
+
},
|
81
|
+
"release": {
|
82
|
+
"branches": [
|
83
|
+
"master"
|
84
|
+
],
|
85
|
+
"extends": "semantic-release-monorepo",
|
86
|
+
"plugins": [
|
87
|
+
[
|
88
|
+
"@semantic-release/commit-analyzer",
|
89
|
+
{
|
90
|
+
"preset": "conventionalcommits",
|
91
|
+
"releaseRules": [
|
92
|
+
{
|
93
|
+
"breaking": true,
|
94
|
+
"release": "patch"
|
95
|
+
},
|
96
|
+
{
|
97
|
+
"revert": true,
|
98
|
+
"release": "patch"
|
99
|
+
},
|
100
|
+
{
|
101
|
+
"type": "feat",
|
102
|
+
"release": "patch"
|
103
|
+
},
|
104
|
+
{
|
105
|
+
"type": "fix",
|
106
|
+
"release": "patch"
|
107
|
+
},
|
108
|
+
{
|
109
|
+
"type": "doc",
|
110
|
+
"release": "patch"
|
111
|
+
},
|
112
|
+
{
|
113
|
+
"type": "test",
|
114
|
+
"release": "patch"
|
115
|
+
},
|
116
|
+
{
|
117
|
+
"scope": "deps",
|
118
|
+
"release": "patch"
|
119
|
+
},
|
120
|
+
{
|
121
|
+
"scope": "no-release",
|
122
|
+
"release": false
|
123
|
+
}
|
124
|
+
]
|
125
|
+
}
|
126
|
+
],
|
127
|
+
[
|
128
|
+
"@semantic-release/release-notes-generator",
|
129
|
+
{
|
130
|
+
"preset": "conventionalcommits",
|
131
|
+
"presetConfig": {
|
132
|
+
"types": [
|
133
|
+
{
|
134
|
+
"type": "feat",
|
135
|
+
"section": "Features"
|
136
|
+
},
|
137
|
+
{
|
138
|
+
"type": "fix",
|
139
|
+
"section": "Bug Fixes"
|
140
|
+
},
|
141
|
+
{
|
142
|
+
"type": "chore",
|
143
|
+
"section": "Trivial Changes"
|
144
|
+
},
|
145
|
+
{
|
146
|
+
"type": "doc",
|
147
|
+
"section": "Documentation"
|
148
|
+
},
|
149
|
+
{
|
150
|
+
"type": "test",
|
151
|
+
"section": "Tests"
|
152
|
+
}
|
153
|
+
]
|
154
|
+
}
|
155
|
+
}
|
156
|
+
],
|
157
|
+
"@semantic-release/changelog",
|
158
|
+
"@semantic-release/npm",
|
159
|
+
"@semantic-release/github",
|
160
|
+
"@semantic-release/git"
|
161
|
+
]
|
162
|
+
},
|
163
|
+
"typedoc": {
|
164
|
+
"entryPoint": "./src/index.ts"
|
165
|
+
},
|
166
|
+
"files": [
|
167
|
+
"dist",
|
168
|
+
"bundle",
|
169
|
+
"src/*.ts",
|
170
|
+
"src/lib/**/*.ts",
|
171
|
+
"src/proto/**/*.ts",
|
172
|
+
"!**/*.spec.*",
|
173
|
+
"!**/*.json",
|
174
|
+
"CHANGELOG.md",
|
175
|
+
"LICENSE",
|
176
|
+
"README.md"
|
177
|
+
]
|
178
|
+
}
|
package/src/index.ts
ADDED
@@ -0,0 +1,187 @@
|
|
1
|
+
import type { GossipSub } from "@chainsafe/libp2p-gossipsub";
|
2
|
+
import type { Stream } from "@libp2p/interface-connection";
|
3
|
+
import type { PeerId } from "@libp2p/interface-peer-id";
|
4
|
+
import type { Peer } from "@libp2p/interface-peer-store";
|
5
|
+
import type { Multiaddr } from "@multiformats/multiaddr";
|
6
|
+
import type { Libp2p } from "libp2p";
|
7
|
+
|
8
|
+
export enum Protocols {
|
9
|
+
Relay = "relay",
|
10
|
+
Store = "store",
|
11
|
+
LightPush = "lightpush",
|
12
|
+
Filter = "filter",
|
13
|
+
}
|
14
|
+
|
15
|
+
export interface PointToPointProtocol {
|
16
|
+
libp2p: Libp2p;
|
17
|
+
peers: () => Promise<Peer[]>;
|
18
|
+
}
|
19
|
+
|
20
|
+
export type ProtocolOptions = {
|
21
|
+
pubSubTopic?: string;
|
22
|
+
/**
|
23
|
+
* Optionally specify an PeerId for the protocol request. If not included, will use a random peer.
|
24
|
+
*/
|
25
|
+
peerId?: PeerId;
|
26
|
+
};
|
27
|
+
|
28
|
+
export type Callback<T extends Message> = (msg: T) => void | Promise<void>;
|
29
|
+
|
30
|
+
export interface Filter extends PointToPointProtocol {
|
31
|
+
subscribe: <T extends Message>(
|
32
|
+
decoders: Decoder<T>[],
|
33
|
+
callback: Callback<T>,
|
34
|
+
opts?: ProtocolOptions
|
35
|
+
) => Promise<() => Promise<void>>;
|
36
|
+
}
|
37
|
+
|
38
|
+
export interface LightPush extends PointToPointProtocol {
|
39
|
+
push: (
|
40
|
+
encoder: Encoder,
|
41
|
+
message: Partial<Message>,
|
42
|
+
opts?: ProtocolOptions
|
43
|
+
) => Promise<SendResult>;
|
44
|
+
}
|
45
|
+
|
46
|
+
export enum PageDirection {
|
47
|
+
BACKWARD = "backward",
|
48
|
+
FORWARD = "forward",
|
49
|
+
}
|
50
|
+
|
51
|
+
export interface TimeFilter {
|
52
|
+
startTime: Date;
|
53
|
+
endTime: Date;
|
54
|
+
}
|
55
|
+
|
56
|
+
export type StoreQueryOptions = {
|
57
|
+
/**
|
58
|
+
* The direction in which pages are retrieved:
|
59
|
+
* - { @link PageDirection.BACKWARD }: Most recent page first.
|
60
|
+
* - { @link PageDirection.FORWARD }: Oldest page first.
|
61
|
+
*
|
62
|
+
* Note: This does not affect the ordering of messages with the page
|
63
|
+
* (the oldest message is always first).
|
64
|
+
*
|
65
|
+
* @default { @link PageDirection.BACKWARD }
|
66
|
+
*/
|
67
|
+
pageDirection?: PageDirection;
|
68
|
+
/**
|
69
|
+
* The number of message per page.
|
70
|
+
*/
|
71
|
+
pageSize?: number;
|
72
|
+
/**
|
73
|
+
* Retrieve messages with a timestamp within the provided values.
|
74
|
+
*/
|
75
|
+
timeFilter?: TimeFilter;
|
76
|
+
} & ProtocolOptions;
|
77
|
+
|
78
|
+
export interface Store extends PointToPointProtocol {
|
79
|
+
queryOrderedCallback: <T extends Message>(
|
80
|
+
decoders: Decoder<T>[],
|
81
|
+
callback: (message: T) => Promise<void | boolean> | boolean | void,
|
82
|
+
options?: StoreQueryOptions
|
83
|
+
) => Promise<void>;
|
84
|
+
queryCallbackOnPromise: <T extends Message>(
|
85
|
+
decoders: Decoder<T>[],
|
86
|
+
callback: (
|
87
|
+
message: Promise<T | undefined>
|
88
|
+
) => Promise<void | boolean> | boolean | void,
|
89
|
+
options?: StoreQueryOptions
|
90
|
+
) => Promise<void>;
|
91
|
+
queryGenerator: <T extends Message>(
|
92
|
+
decoders: Decoder<T>[],
|
93
|
+
options?: StoreQueryOptions
|
94
|
+
) => AsyncGenerator<Promise<T | undefined>[]>;
|
95
|
+
}
|
96
|
+
|
97
|
+
export interface Relay extends GossipSub {
|
98
|
+
send: (encoder: Encoder, message: Partial<Message>) => Promise<SendResult>;
|
99
|
+
addObserver: <T extends Message>(
|
100
|
+
decoder: Decoder<T>,
|
101
|
+
callback: Callback<T>
|
102
|
+
) => () => void;
|
103
|
+
getMeshPeers: () => string[];
|
104
|
+
}
|
105
|
+
|
106
|
+
export interface Waku {
|
107
|
+
libp2p: Libp2p;
|
108
|
+
relay?: Relay;
|
109
|
+
store?: Store;
|
110
|
+
filter?: Filter;
|
111
|
+
lightPush?: LightPush;
|
112
|
+
|
113
|
+
dial(peer: PeerId | Multiaddr, protocols?: Protocols[]): Promise<Stream>;
|
114
|
+
|
115
|
+
addPeerToAddressBook(
|
116
|
+
peerId: PeerId | string,
|
117
|
+
multiaddrs: Multiaddr[] | string[]
|
118
|
+
): void;
|
119
|
+
|
120
|
+
start(): Promise<void>;
|
121
|
+
|
122
|
+
stop(): Promise<void>;
|
123
|
+
|
124
|
+
isStarted(): boolean;
|
125
|
+
}
|
126
|
+
|
127
|
+
export interface WakuLight extends Waku {
|
128
|
+
relay: undefined;
|
129
|
+
store: Store;
|
130
|
+
filter: Filter;
|
131
|
+
lightPush: LightPush;
|
132
|
+
}
|
133
|
+
|
134
|
+
export interface WakuPrivacy extends Waku {
|
135
|
+
relay: Relay;
|
136
|
+
store: undefined;
|
137
|
+
filter: undefined;
|
138
|
+
lightPush: undefined;
|
139
|
+
}
|
140
|
+
|
141
|
+
export interface WakuFull extends Waku {
|
142
|
+
relay: Relay;
|
143
|
+
store: Store;
|
144
|
+
filter: Filter;
|
145
|
+
lightPush: LightPush;
|
146
|
+
}
|
147
|
+
|
148
|
+
export interface RateLimitProof {
|
149
|
+
proof: Uint8Array;
|
150
|
+
merkleRoot: Uint8Array;
|
151
|
+
epoch: Uint8Array;
|
152
|
+
shareX: Uint8Array;
|
153
|
+
shareY: Uint8Array;
|
154
|
+
nullifier: Uint8Array;
|
155
|
+
rlnIdentifier: Uint8Array;
|
156
|
+
}
|
157
|
+
|
158
|
+
export interface ProtoMessage {
|
159
|
+
payload: Uint8Array | undefined;
|
160
|
+
contentTopic: string | undefined;
|
161
|
+
version: number | undefined;
|
162
|
+
timestamp: bigint | undefined;
|
163
|
+
rateLimitProof: RateLimitProof | undefined;
|
164
|
+
}
|
165
|
+
|
166
|
+
export interface Message {
|
167
|
+
payload: Uint8Array | undefined;
|
168
|
+
contentTopic: string | undefined;
|
169
|
+
timestamp: Date | undefined;
|
170
|
+
rateLimitProof: RateLimitProof | undefined;
|
171
|
+
}
|
172
|
+
|
173
|
+
export interface Encoder {
|
174
|
+
contentTopic: string;
|
175
|
+
toWire: (message: Partial<Message>) => Promise<Uint8Array | undefined>;
|
176
|
+
toProtoObj: (message: Partial<Message>) => Promise<ProtoMessage | undefined>;
|
177
|
+
}
|
178
|
+
|
179
|
+
export interface Decoder<T extends Message> {
|
180
|
+
contentTopic: string;
|
181
|
+
fromWireToProtoObj: (bytes: Uint8Array) => Promise<ProtoMessage | undefined>;
|
182
|
+
fromProtoObj: (proto: ProtoMessage) => Promise<T | undefined>;
|
183
|
+
}
|
184
|
+
|
185
|
+
export interface SendResult {
|
186
|
+
recipients: PeerId[];
|
187
|
+
}
|