@libp2p/pubsub 0.0.0 → 0.2.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.
Files changed (76) hide show
  1. package/LICENSE +4 -0
  2. package/README.md +35 -0
  3. package/dist/src/errors.d.ts +39 -0
  4. package/dist/src/errors.d.ts.map +1 -0
  5. package/dist/src/errors.js +41 -0
  6. package/dist/src/errors.js.map +1 -0
  7. package/dist/src/index.d.ts +180 -0
  8. package/dist/src/index.d.ts.map +1 -0
  9. package/dist/src/index.js +467 -0
  10. package/dist/src/index.js.map +1 -0
  11. package/dist/src/message/rpc.d.ts +258 -0
  12. package/dist/src/message/rpc.js +699 -0
  13. package/dist/src/message/sign.d.ts +17 -0
  14. package/dist/src/message/sign.d.ts.map +1 -0
  15. package/dist/src/message/sign.js +84 -0
  16. package/dist/src/message/sign.js.map +1 -0
  17. package/dist/src/message/topic-descriptor.d.ts +254 -0
  18. package/dist/src/message/topic-descriptor.js +647 -0
  19. package/dist/src/peer-streams.d.ts +67 -0
  20. package/dist/src/peer-streams.d.ts.map +1 -0
  21. package/dist/src/peer-streams.js +112 -0
  22. package/dist/src/peer-streams.js.map +1 -0
  23. package/dist/src/utils.d.ts +29 -0
  24. package/dist/src/utils.d.ts.map +1 -0
  25. package/dist/src/utils.js +80 -0
  26. package/dist/src/utils.js.map +1 -0
  27. package/dist/test/emit-self.spec.d.ts +2 -0
  28. package/dist/test/emit-self.spec.d.ts.map +1 -0
  29. package/dist/test/emit-self.spec.js +63 -0
  30. package/dist/test/emit-self.spec.js.map +1 -0
  31. package/dist/test/instance.spec.d.ts +2 -0
  32. package/dist/test/instance.spec.d.ts.map +1 -0
  33. package/dist/test/instance.spec.js +50 -0
  34. package/dist/test/instance.spec.js.map +1 -0
  35. package/dist/test/lifesycle.spec.d.ts +2 -0
  36. package/dist/test/lifesycle.spec.d.ts.map +1 -0
  37. package/dist/test/lifesycle.spec.js +192 -0
  38. package/dist/test/lifesycle.spec.js.map +1 -0
  39. package/dist/test/message.spec.d.ts +2 -0
  40. package/dist/test/message.spec.d.ts.map +1 -0
  41. package/dist/test/message.spec.js +83 -0
  42. package/dist/test/message.spec.js.map +1 -0
  43. package/dist/test/pubsub.spec.d.ts +2 -0
  44. package/dist/test/pubsub.spec.d.ts.map +1 -0
  45. package/dist/test/pubsub.spec.js +310 -0
  46. package/dist/test/pubsub.spec.js.map +1 -0
  47. package/dist/test/sign.spec.d.ts +2 -0
  48. package/dist/test/sign.spec.d.ts.map +1 -0
  49. package/dist/test/sign.spec.js +93 -0
  50. package/dist/test/sign.spec.js.map +1 -0
  51. package/dist/test/topic-validators.spec.d.ts +2 -0
  52. package/dist/test/topic-validators.spec.d.ts.map +1 -0
  53. package/dist/test/topic-validators.spec.js +86 -0
  54. package/dist/test/topic-validators.spec.js.map +1 -0
  55. package/dist/test/utils/index.d.ts +22 -0
  56. package/dist/test/utils/index.d.ts.map +1 -0
  57. package/dist/test/utils/index.js +86 -0
  58. package/dist/test/utils/index.js.map +1 -0
  59. package/dist/test/utils.spec.d.ts +2 -0
  60. package/dist/test/utils.spec.d.ts.map +1 -0
  61. package/dist/test/utils.spec.js +53 -0
  62. package/dist/test/utils.spec.js.map +1 -0
  63. package/dist/tsconfig.tsbuildinfo +1 -0
  64. package/package.json +109 -4
  65. package/src/README.md +251 -0
  66. package/src/errors.ts +45 -0
  67. package/src/index.ts +610 -0
  68. package/src/message/rpc.d.ts +258 -0
  69. package/src/message/rpc.js +699 -0
  70. package/src/message/rpc.proto +20 -0
  71. package/src/message/sign.ts +101 -0
  72. package/src/message/topic-descriptor.d.ts +254 -0
  73. package/src/message/topic-descriptor.js +647 -0
  74. package/src/message/topic-descriptor.proto +30 -0
  75. package/src/peer-streams.ts +169 -0
  76. package/src/utils.ts +93 -0
@@ -0,0 +1,258 @@
1
+ import * as $protobuf from 'protobufjs'
2
+ /** Properties of a RPC. */
3
+ export interface IRPC {
4
+
5
+ /** RPC subscriptions */
6
+ subscriptions?: (RPC.ISubOpts[]|null)
7
+
8
+ /** RPC msgs */
9
+ msgs?: (RPC.IMessage[]|null)
10
+ }
11
+
12
+ /** Represents a RPC. */
13
+ export class RPC implements IRPC {
14
+ /**
15
+ * Constructs a new RPC.
16
+ *
17
+ * @param [p] - Properties to set
18
+ */
19
+ constructor (p?: IRPC);
20
+
21
+ /** RPC subscriptions. */
22
+ public subscriptions: RPC.ISubOpts[]
23
+
24
+ /** RPC msgs. */
25
+ public msgs: RPC.IMessage[]
26
+
27
+ /**
28
+ * Encodes the specified RPC message. Does not implicitly {@link RPC.verify|verify} messages.
29
+ *
30
+ * @param m - RPC message or plain object to encode
31
+ * @param [w] - Writer to encode to
32
+ * @returns Writer
33
+ */
34
+ public static encode (m: IRPC, w?: $protobuf.Writer): $protobuf.Writer;
35
+
36
+ /**
37
+ * Decodes a RPC message from the specified reader or buffer.
38
+ *
39
+ * @param r - Reader or buffer to decode from
40
+ * @param [l] - Message length if known beforehand
41
+ * @returns RPC
42
+ * @throws {Error} If the payload is not a reader or valid buffer
43
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
44
+ */
45
+ public static decode (r: ($protobuf.Reader|Uint8Array), l?: number): RPC;
46
+
47
+ /**
48
+ * Creates a RPC message from a plain object. Also converts values to their respective internal types.
49
+ *
50
+ * @param d - Plain object
51
+ * @returns RPC
52
+ */
53
+ public static fromObject (d: { [k: string]: any }): RPC;
54
+
55
+ /**
56
+ * Creates a plain object from a RPC message. Also converts values to other types if specified.
57
+ *
58
+ * @param m - RPC
59
+ * @param [o] - Conversion options
60
+ * @returns Plain object
61
+ */
62
+ public static toObject (m: RPC, o?: $protobuf.IConversionOptions): { [k: string]: any };
63
+
64
+ /**
65
+ * Converts this RPC to JSON.
66
+ *
67
+ * @returns JSON object
68
+ */
69
+ public toJSON (): { [k: string]: any };
70
+ }
71
+
72
+ export namespace RPC {
73
+
74
+ /** Properties of a SubOpts. */
75
+ interface ISubOpts {
76
+
77
+ /** SubOpts subscribe */
78
+ subscribe?: (boolean|null)
79
+
80
+ /** SubOpts topicID */
81
+ topicID?: (string|null)
82
+ }
83
+
84
+ /** Represents a SubOpts. */
85
+ class SubOpts implements ISubOpts {
86
+ /**
87
+ * Constructs a new SubOpts.
88
+ *
89
+ * @param [p] - Properties to set
90
+ */
91
+ constructor (p?: RPC.ISubOpts);
92
+
93
+ /** SubOpts subscribe. */
94
+ public subscribe?: (boolean|null)
95
+
96
+ /** SubOpts topicID. */
97
+ public topicID?: (string|null)
98
+
99
+ /** SubOpts _subscribe. */
100
+ public _subscribe?: 'subscribe'
101
+
102
+ /** SubOpts _topicID. */
103
+ public _topicID?: 'topicID'
104
+
105
+ /**
106
+ * Encodes the specified SubOpts message. Does not implicitly {@link RPC.SubOpts.verify|verify} messages.
107
+ *
108
+ * @param m - SubOpts message or plain object to encode
109
+ * @param [w] - Writer to encode to
110
+ * @returns Writer
111
+ */
112
+ public static encode (m: RPC.ISubOpts, w?: $protobuf.Writer): $protobuf.Writer;
113
+
114
+ /**
115
+ * Decodes a SubOpts message from the specified reader or buffer.
116
+ *
117
+ * @param r - Reader or buffer to decode from
118
+ * @param [l] - Message length if known beforehand
119
+ * @returns SubOpts
120
+ * @throws {Error} If the payload is not a reader or valid buffer
121
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
122
+ */
123
+ public static decode (r: ($protobuf.Reader|Uint8Array), l?: number): RPC.SubOpts;
124
+
125
+ /**
126
+ * Creates a SubOpts message from a plain object. Also converts values to their respective internal types.
127
+ *
128
+ * @param d - Plain object
129
+ * @returns SubOpts
130
+ */
131
+ public static fromObject (d: { [k: string]: any }): RPC.SubOpts;
132
+
133
+ /**
134
+ * Creates a plain object from a SubOpts message. Also converts values to other types if specified.
135
+ *
136
+ * @param m - SubOpts
137
+ * @param [o] - Conversion options
138
+ * @returns Plain object
139
+ */
140
+ public static toObject (m: RPC.SubOpts, o?: $protobuf.IConversionOptions): { [k: string]: any };
141
+
142
+ /**
143
+ * Converts this SubOpts to JSON.
144
+ *
145
+ * @returns JSON object
146
+ */
147
+ public toJSON (): { [k: string]: any };
148
+ }
149
+
150
+ /** Properties of a Message. */
151
+ interface IMessage {
152
+
153
+ /** Message from */
154
+ from?: (Uint8Array|null)
155
+
156
+ /** Message data */
157
+ data?: (Uint8Array|null)
158
+
159
+ /** Message seqno */
160
+ seqno?: (Uint8Array|null)
161
+
162
+ /** Message topicIDs */
163
+ topicIDs?: (string[]|null)
164
+
165
+ /** Message signature */
166
+ signature?: (Uint8Array|null)
167
+
168
+ /** Message key */
169
+ key?: (Uint8Array|null)
170
+ }
171
+
172
+ /** Represents a Message. */
173
+ class Message implements IMessage {
174
+ /**
175
+ * Constructs a new Message.
176
+ *
177
+ * @param [p] - Properties to set
178
+ */
179
+ constructor (p?: RPC.IMessage);
180
+
181
+ /** Message from. */
182
+ public from?: (Uint8Array|null)
183
+
184
+ /** Message data. */
185
+ public data?: (Uint8Array|null)
186
+
187
+ /** Message seqno. */
188
+ public seqno?: (Uint8Array|null)
189
+
190
+ /** Message topicIDs. */
191
+ public topicIDs: string[]
192
+
193
+ /** Message signature. */
194
+ public signature?: (Uint8Array|null)
195
+
196
+ /** Message key. */
197
+ public key?: (Uint8Array|null)
198
+
199
+ /** Message _from. */
200
+ public _from?: 'from'
201
+
202
+ /** Message _data. */
203
+ public _data?: 'data'
204
+
205
+ /** Message _seqno. */
206
+ public _seqno?: 'seqno'
207
+
208
+ /** Message _signature. */
209
+ public _signature?: 'signature'
210
+
211
+ /** Message _key. */
212
+ public _key?: 'key'
213
+
214
+ /**
215
+ * Encodes the specified Message message. Does not implicitly {@link RPC.Message.verify|verify} messages.
216
+ *
217
+ * @param m - Message message or plain object to encode
218
+ * @param [w] - Writer to encode to
219
+ * @returns Writer
220
+ */
221
+ public static encode (m: RPC.IMessage, w?: $protobuf.Writer): $protobuf.Writer;
222
+
223
+ /**
224
+ * Decodes a Message message from the specified reader or buffer.
225
+ *
226
+ * @param r - Reader or buffer to decode from
227
+ * @param [l] - Message length if known beforehand
228
+ * @returns Message
229
+ * @throws {Error} If the payload is not a reader or valid buffer
230
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
231
+ */
232
+ public static decode (r: ($protobuf.Reader|Uint8Array), l?: number): RPC.Message;
233
+
234
+ /**
235
+ * Creates a Message message from a plain object. Also converts values to their respective internal types.
236
+ *
237
+ * @param d - Plain object
238
+ * @returns Message
239
+ */
240
+ public static fromObject (d: { [k: string]: any }): RPC.Message;
241
+
242
+ /**
243
+ * Creates a plain object from a Message message. Also converts values to other types if specified.
244
+ *
245
+ * @param m - Message
246
+ * @param [o] - Conversion options
247
+ * @returns Plain object
248
+ */
249
+ public static toObject (m: RPC.Message, o?: $protobuf.IConversionOptions): { [k: string]: any };
250
+
251
+ /**
252
+ * Converts this Message to JSON.
253
+ *
254
+ * @returns JSON object
255
+ */
256
+ public toJSON (): { [k: string]: any };
257
+ }
258
+ }