@libp2p/pubsub 0.0.0 → 1.0.2
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/LICENSE +4 -0
- package/README.md +35 -0
- package/dist/src/errors.d.ts +39 -0
- package/dist/src/errors.d.ts.map +1 -0
- package/dist/src/errors.js +41 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/index.d.ts +180 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +467 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/message/rpc.d.ts +258 -0
- package/dist/src/message/rpc.js +699 -0
- package/dist/src/message/sign.d.ts +17 -0
- package/dist/src/message/sign.d.ts.map +1 -0
- package/dist/src/message/sign.js +84 -0
- package/dist/src/message/sign.js.map +1 -0
- package/dist/src/message/topic-descriptor.d.ts +254 -0
- package/dist/src/message/topic-descriptor.js +647 -0
- package/dist/src/peer-streams.d.ts +67 -0
- package/dist/src/peer-streams.d.ts.map +1 -0
- package/dist/src/peer-streams.js +112 -0
- package/dist/src/peer-streams.js.map +1 -0
- package/dist/src/utils.d.ts +29 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/utils.js +80 -0
- package/dist/src/utils.js.map +1 -0
- package/dist/test/emit-self.spec.d.ts +2 -0
- package/dist/test/emit-self.spec.d.ts.map +1 -0
- package/dist/test/emit-self.spec.js +63 -0
- package/dist/test/emit-self.spec.js.map +1 -0
- package/dist/test/instance.spec.d.ts +2 -0
- package/dist/test/instance.spec.d.ts.map +1 -0
- package/dist/test/instance.spec.js +50 -0
- package/dist/test/instance.spec.js.map +1 -0
- package/dist/test/lifesycle.spec.d.ts +2 -0
- package/dist/test/lifesycle.spec.d.ts.map +1 -0
- package/dist/test/lifesycle.spec.js +192 -0
- package/dist/test/lifesycle.spec.js.map +1 -0
- package/dist/test/message.spec.d.ts +2 -0
- package/dist/test/message.spec.d.ts.map +1 -0
- package/dist/test/message.spec.js +83 -0
- package/dist/test/message.spec.js.map +1 -0
- package/dist/test/pubsub.spec.d.ts +2 -0
- package/dist/test/pubsub.spec.d.ts.map +1 -0
- package/dist/test/pubsub.spec.js +310 -0
- package/dist/test/pubsub.spec.js.map +1 -0
- package/dist/test/sign.spec.d.ts +2 -0
- package/dist/test/sign.spec.d.ts.map +1 -0
- package/dist/test/sign.spec.js +93 -0
- package/dist/test/sign.spec.js.map +1 -0
- package/dist/test/topic-validators.spec.d.ts +2 -0
- package/dist/test/topic-validators.spec.d.ts.map +1 -0
- package/dist/test/topic-validators.spec.js +86 -0
- package/dist/test/topic-validators.spec.js.map +1 -0
- package/dist/test/utils/index.d.ts +23 -0
- package/dist/test/utils/index.d.ts.map +1 -0
- package/dist/test/utils/index.js +86 -0
- package/dist/test/utils/index.js.map +1 -0
- package/dist/test/utils.spec.d.ts +2 -0
- package/dist/test/utils.spec.d.ts.map +1 -0
- package/dist/test/utils.spec.js +53 -0
- package/dist/test/utils.spec.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +192 -4
- package/src/README.md +251 -0
- package/src/errors.ts +45 -0
- package/src/index.ts +610 -0
- package/src/message/rpc.d.ts +258 -0
- package/src/message/rpc.js +699 -0
- package/src/message/rpc.proto +20 -0
- package/src/message/sign.ts +101 -0
- package/src/message/topic-descriptor.d.ts +254 -0
- package/src/message/topic-descriptor.js +647 -0
- package/src/message/topic-descriptor.proto +30 -0
- package/src/peer-streams.ts +169 -0
- package/src/utils.ts +93 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
import { PeerId } from '@libp2p/peer-id';
|
2
|
+
import type { Message } from '@libp2p/interfaces/pubsub';
|
3
|
+
export declare const SignPrefix: Uint8Array;
|
4
|
+
/**
|
5
|
+
* Signs the provided message with the given `peerId`
|
6
|
+
*/
|
7
|
+
export declare function signMessage(peerId: PeerId, message: Message): Promise<Message>;
|
8
|
+
/**
|
9
|
+
* Verifies the signature of the given message
|
10
|
+
*/
|
11
|
+
export declare function verifySignature(message: Message): Promise<boolean>;
|
12
|
+
/**
|
13
|
+
* Returns the PublicKey associated with the given message.
|
14
|
+
* If no, valid PublicKey can be retrieved an error will be returned.
|
15
|
+
*/
|
16
|
+
export declare function messagePublicKey(message: Message): Promise<Uint8Array>;
|
17
|
+
//# sourceMappingURL=sign.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"sign.d.ts","sourceRoot":"","sources":["../../../src/message/sign.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAExC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AAExD,eAAO,MAAM,UAAU,YAAyC,CAAA;AAEhE;;GAEG;AACH,wBAAsB,WAAW,CAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,oBAyBlE;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAE,OAAO,EAAE,OAAO,oBAyBtD;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAE,OAAO,EAAE,OAAO,uBAyBvD"}
|
@@ -0,0 +1,84 @@
|
|
1
|
+
import * as PeerIdFactory from '@libp2p/peer-id-factory';
|
2
|
+
import { RPC } from './rpc.js';
|
3
|
+
import { concat as uint8ArrayConcat } from 'uint8arrays/concat';
|
4
|
+
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
|
5
|
+
import { normalizeOutRpcMessage } from '../utils.js';
|
6
|
+
import { PeerId } from '@libp2p/peer-id';
|
7
|
+
import { keys } from '@libp2p/crypto';
|
8
|
+
export const SignPrefix = uint8ArrayFromString('libp2p-pubsub:');
|
9
|
+
/**
|
10
|
+
* Signs the provided message with the given `peerId`
|
11
|
+
*/
|
12
|
+
export async function signMessage(peerId, message) {
|
13
|
+
// Get the message in bytes, and prepend with the pubsub prefix
|
14
|
+
const bytes = uint8ArrayConcat([
|
15
|
+
SignPrefix,
|
16
|
+
RPC.Message.encode(normalizeOutRpcMessage(message)).finish()
|
17
|
+
]);
|
18
|
+
if (peerId.privateKey == null) {
|
19
|
+
throw new Error('Cannot sign message, no private key present');
|
20
|
+
}
|
21
|
+
if (peerId.publicKey == null) {
|
22
|
+
throw new Error('Cannot sign message, no public key present');
|
23
|
+
}
|
24
|
+
const privateKey = await keys.unmarshalPrivateKey(peerId.privateKey);
|
25
|
+
const signature = await privateKey.sign(bytes);
|
26
|
+
const outputMessage = {
|
27
|
+
...message,
|
28
|
+
signature: signature,
|
29
|
+
key: peerId.publicKey
|
30
|
+
};
|
31
|
+
return outputMessage;
|
32
|
+
}
|
33
|
+
/**
|
34
|
+
* Verifies the signature of the given message
|
35
|
+
*/
|
36
|
+
export async function verifySignature(message) {
|
37
|
+
if (message.signature == null) {
|
38
|
+
throw new Error('Message must contain a signature to be verified');
|
39
|
+
}
|
40
|
+
if (message.from == null) {
|
41
|
+
throw new Error('Message must contain a from property to be verified');
|
42
|
+
}
|
43
|
+
// Get message sans the signature
|
44
|
+
const bytes = uint8ArrayConcat([
|
45
|
+
SignPrefix,
|
46
|
+
RPC.Message.encode({
|
47
|
+
...message,
|
48
|
+
signature: undefined,
|
49
|
+
key: undefined
|
50
|
+
}).finish()
|
51
|
+
]);
|
52
|
+
// Get the public key
|
53
|
+
const pubKeyBytes = await messagePublicKey(message);
|
54
|
+
const pubKey = keys.unmarshalPublicKey(pubKeyBytes);
|
55
|
+
// verify the base message
|
56
|
+
return await pubKey.verify(bytes, message.signature);
|
57
|
+
}
|
58
|
+
/**
|
59
|
+
* Returns the PublicKey associated with the given message.
|
60
|
+
* If no, valid PublicKey can be retrieved an error will be returned.
|
61
|
+
*/
|
62
|
+
export async function messagePublicKey(message) {
|
63
|
+
// should be available in the from property of the message (peer id)
|
64
|
+
if (message.from == null) {
|
65
|
+
throw new Error('Could not get the public key from the originator id');
|
66
|
+
}
|
67
|
+
const from = PeerId.fromBytes(message.from);
|
68
|
+
if (message.key != null) {
|
69
|
+
const keyPeerId = await PeerIdFactory.createFromPubKey(keys.unmarshalPublicKey(message.key));
|
70
|
+
// the key belongs to the sender, return the key
|
71
|
+
if (!keyPeerId.equals(from)) {
|
72
|
+
throw new Error('Public Key does not match the originator');
|
73
|
+
}
|
74
|
+
if (keyPeerId.publicKey != null) {
|
75
|
+
return keyPeerId.publicKey;
|
76
|
+
}
|
77
|
+
}
|
78
|
+
else if (from.publicKey != null) {
|
79
|
+
return from.publicKey;
|
80
|
+
}
|
81
|
+
// We couldn't validate pubkey is from the originator, error
|
82
|
+
throw new Error('Could not get the public key from the originator id');
|
83
|
+
}
|
84
|
+
//# sourceMappingURL=sign.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"sign.js","sourceRoot":"","sources":["../../../src/message/sign.ts"],"names":[],"mappings":"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"}
|
@@ -0,0 +1,254 @@
|
|
1
|
+
import * as $protobuf from 'protobufjs'
|
2
|
+
/** Properties of a TopicDescriptor. */
|
3
|
+
export interface ITopicDescriptor {
|
4
|
+
|
5
|
+
/** TopicDescriptor name */
|
6
|
+
name?: (string|null)
|
7
|
+
|
8
|
+
/** TopicDescriptor auth */
|
9
|
+
auth?: (TopicDescriptor.IAuthOpts|null)
|
10
|
+
|
11
|
+
/** TopicDescriptor enc */
|
12
|
+
enc?: (TopicDescriptor.IEncOpts|null)
|
13
|
+
}
|
14
|
+
|
15
|
+
/** Represents a TopicDescriptor. */
|
16
|
+
export class TopicDescriptor implements ITopicDescriptor {
|
17
|
+
/**
|
18
|
+
* Constructs a new TopicDescriptor.
|
19
|
+
*
|
20
|
+
* @param [p] - Properties to set
|
21
|
+
*/
|
22
|
+
constructor (p?: ITopicDescriptor);
|
23
|
+
|
24
|
+
/** TopicDescriptor name. */
|
25
|
+
public name?: (string|null)
|
26
|
+
|
27
|
+
/** TopicDescriptor auth. */
|
28
|
+
public auth?: (TopicDescriptor.IAuthOpts|null)
|
29
|
+
|
30
|
+
/** TopicDescriptor enc. */
|
31
|
+
public enc?: (TopicDescriptor.IEncOpts|null)
|
32
|
+
|
33
|
+
/** TopicDescriptor _name. */
|
34
|
+
public _name?: 'name'
|
35
|
+
|
36
|
+
/** TopicDescriptor _auth. */
|
37
|
+
public _auth?: 'auth'
|
38
|
+
|
39
|
+
/** TopicDescriptor _enc. */
|
40
|
+
public _enc?: 'enc'
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Encodes the specified TopicDescriptor message. Does not implicitly {@link TopicDescriptor.verify|verify} messages.
|
44
|
+
*
|
45
|
+
* @param m - TopicDescriptor message or plain object to encode
|
46
|
+
* @param [w] - Writer to encode to
|
47
|
+
* @returns Writer
|
48
|
+
*/
|
49
|
+
public static encode (m: ITopicDescriptor, w?: $protobuf.Writer): $protobuf.Writer;
|
50
|
+
|
51
|
+
/**
|
52
|
+
* Decodes a TopicDescriptor message from the specified reader or buffer.
|
53
|
+
*
|
54
|
+
* @param r - Reader or buffer to decode from
|
55
|
+
* @param [l] - Message length if known beforehand
|
56
|
+
* @returns TopicDescriptor
|
57
|
+
* @throws {Error} If the payload is not a reader or valid buffer
|
58
|
+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
59
|
+
*/
|
60
|
+
public static decode (r: ($protobuf.Reader|Uint8Array), l?: number): TopicDescriptor;
|
61
|
+
|
62
|
+
/**
|
63
|
+
* Creates a TopicDescriptor message from a plain object. Also converts values to their respective internal types.
|
64
|
+
*
|
65
|
+
* @param d - Plain object
|
66
|
+
* @returns TopicDescriptor
|
67
|
+
*/
|
68
|
+
public static fromObject (d: { [k: string]: any }): TopicDescriptor;
|
69
|
+
|
70
|
+
/**
|
71
|
+
* Creates a plain object from a TopicDescriptor message. Also converts values to other types if specified.
|
72
|
+
*
|
73
|
+
* @param m - TopicDescriptor
|
74
|
+
* @param [o] - Conversion options
|
75
|
+
* @returns Plain object
|
76
|
+
*/
|
77
|
+
public static toObject (m: TopicDescriptor, o?: $protobuf.IConversionOptions): { [k: string]: any };
|
78
|
+
|
79
|
+
/**
|
80
|
+
* Converts this TopicDescriptor to JSON.
|
81
|
+
*
|
82
|
+
* @returns JSON object
|
83
|
+
*/
|
84
|
+
public toJSON (): { [k: string]: any };
|
85
|
+
}
|
86
|
+
|
87
|
+
export namespace TopicDescriptor {
|
88
|
+
|
89
|
+
/** Properties of an AuthOpts. */
|
90
|
+
interface IAuthOpts {
|
91
|
+
|
92
|
+
/** AuthOpts mode */
|
93
|
+
mode?: (TopicDescriptor.AuthOpts.AuthMode|null)
|
94
|
+
|
95
|
+
/** AuthOpts keys */
|
96
|
+
keys?: (Uint8Array[]|null)
|
97
|
+
}
|
98
|
+
|
99
|
+
/** Represents an AuthOpts. */
|
100
|
+
class AuthOpts implements IAuthOpts {
|
101
|
+
/**
|
102
|
+
* Constructs a new AuthOpts.
|
103
|
+
*
|
104
|
+
* @param [p] - Properties to set
|
105
|
+
*/
|
106
|
+
constructor (p?: TopicDescriptor.IAuthOpts);
|
107
|
+
|
108
|
+
/** AuthOpts mode. */
|
109
|
+
public mode?: (TopicDescriptor.AuthOpts.AuthMode|null)
|
110
|
+
|
111
|
+
/** AuthOpts keys. */
|
112
|
+
public keys: Uint8Array[]
|
113
|
+
|
114
|
+
/** AuthOpts _mode. */
|
115
|
+
public _mode?: 'mode'
|
116
|
+
|
117
|
+
/**
|
118
|
+
* Encodes the specified AuthOpts message. Does not implicitly {@link TopicDescriptor.AuthOpts.verify|verify} messages.
|
119
|
+
*
|
120
|
+
* @param m - AuthOpts message or plain object to encode
|
121
|
+
* @param [w] - Writer to encode to
|
122
|
+
* @returns Writer
|
123
|
+
*/
|
124
|
+
public static encode (m: TopicDescriptor.IAuthOpts, w?: $protobuf.Writer): $protobuf.Writer;
|
125
|
+
|
126
|
+
/**
|
127
|
+
* Decodes an AuthOpts message from the specified reader or buffer.
|
128
|
+
*
|
129
|
+
* @param r - Reader or buffer to decode from
|
130
|
+
* @param [l] - Message length if known beforehand
|
131
|
+
* @returns AuthOpts
|
132
|
+
* @throws {Error} If the payload is not a reader or valid buffer
|
133
|
+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
134
|
+
*/
|
135
|
+
public static decode (r: ($protobuf.Reader|Uint8Array), l?: number): TopicDescriptor.AuthOpts;
|
136
|
+
|
137
|
+
/**
|
138
|
+
* Creates an AuthOpts message from a plain object. Also converts values to their respective internal types.
|
139
|
+
*
|
140
|
+
* @param d - Plain object
|
141
|
+
* @returns AuthOpts
|
142
|
+
*/
|
143
|
+
public static fromObject (d: { [k: string]: any }): TopicDescriptor.AuthOpts;
|
144
|
+
|
145
|
+
/**
|
146
|
+
* Creates a plain object from an AuthOpts message. Also converts values to other types if specified.
|
147
|
+
*
|
148
|
+
* @param m - AuthOpts
|
149
|
+
* @param [o] - Conversion options
|
150
|
+
* @returns Plain object
|
151
|
+
*/
|
152
|
+
public static toObject (m: TopicDescriptor.AuthOpts, o?: $protobuf.IConversionOptions): { [k: string]: any };
|
153
|
+
|
154
|
+
/**
|
155
|
+
* Converts this AuthOpts to JSON.
|
156
|
+
*
|
157
|
+
* @returns JSON object
|
158
|
+
*/
|
159
|
+
public toJSON (): { [k: string]: any };
|
160
|
+
}
|
161
|
+
|
162
|
+
namespace AuthOpts {
|
163
|
+
|
164
|
+
/** AuthMode enum. */
|
165
|
+
enum AuthMode {
|
166
|
+
NONE = 0,
|
167
|
+
KEY = 1,
|
168
|
+
WOT = 2
|
169
|
+
}
|
170
|
+
}
|
171
|
+
|
172
|
+
/** Properties of an EncOpts. */
|
173
|
+
interface IEncOpts {
|
174
|
+
|
175
|
+
/** EncOpts mode */
|
176
|
+
mode?: (TopicDescriptor.EncOpts.EncMode|null)
|
177
|
+
|
178
|
+
/** EncOpts keyHashes */
|
179
|
+
keyHashes?: (Uint8Array[]|null)
|
180
|
+
}
|
181
|
+
|
182
|
+
/** Represents an EncOpts. */
|
183
|
+
class EncOpts implements IEncOpts {
|
184
|
+
/**
|
185
|
+
* Constructs a new EncOpts.
|
186
|
+
*
|
187
|
+
* @param [p] - Properties to set
|
188
|
+
*/
|
189
|
+
constructor (p?: TopicDescriptor.IEncOpts);
|
190
|
+
|
191
|
+
/** EncOpts mode. */
|
192
|
+
public mode?: (TopicDescriptor.EncOpts.EncMode|null)
|
193
|
+
|
194
|
+
/** EncOpts keyHashes. */
|
195
|
+
public keyHashes: Uint8Array[]
|
196
|
+
|
197
|
+
/** EncOpts _mode. */
|
198
|
+
public _mode?: 'mode'
|
199
|
+
|
200
|
+
/**
|
201
|
+
* Encodes the specified EncOpts message. Does not implicitly {@link TopicDescriptor.EncOpts.verify|verify} messages.
|
202
|
+
*
|
203
|
+
* @param m - EncOpts message or plain object to encode
|
204
|
+
* @param [w] - Writer to encode to
|
205
|
+
* @returns Writer
|
206
|
+
*/
|
207
|
+
public static encode (m: TopicDescriptor.IEncOpts, w?: $protobuf.Writer): $protobuf.Writer;
|
208
|
+
|
209
|
+
/**
|
210
|
+
* Decodes an EncOpts message from the specified reader or buffer.
|
211
|
+
*
|
212
|
+
* @param r - Reader or buffer to decode from
|
213
|
+
* @param [l] - Message length if known beforehand
|
214
|
+
* @returns EncOpts
|
215
|
+
* @throws {Error} If the payload is not a reader or valid buffer
|
216
|
+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
217
|
+
*/
|
218
|
+
public static decode (r: ($protobuf.Reader|Uint8Array), l?: number): TopicDescriptor.EncOpts;
|
219
|
+
|
220
|
+
/**
|
221
|
+
* Creates an EncOpts message from a plain object. Also converts values to their respective internal types.
|
222
|
+
*
|
223
|
+
* @param d - Plain object
|
224
|
+
* @returns EncOpts
|
225
|
+
*/
|
226
|
+
public static fromObject (d: { [k: string]: any }): TopicDescriptor.EncOpts;
|
227
|
+
|
228
|
+
/**
|
229
|
+
* Creates a plain object from an EncOpts message. Also converts values to other types if specified.
|
230
|
+
*
|
231
|
+
* @param m - EncOpts
|
232
|
+
* @param [o] - Conversion options
|
233
|
+
* @returns Plain object
|
234
|
+
*/
|
235
|
+
public static toObject (m: TopicDescriptor.EncOpts, o?: $protobuf.IConversionOptions): { [k: string]: any };
|
236
|
+
|
237
|
+
/**
|
238
|
+
* Converts this EncOpts to JSON.
|
239
|
+
*
|
240
|
+
* @returns JSON object
|
241
|
+
*/
|
242
|
+
public toJSON (): { [k: string]: any };
|
243
|
+
}
|
244
|
+
|
245
|
+
namespace EncOpts {
|
246
|
+
|
247
|
+
/** EncMode enum. */
|
248
|
+
enum EncMode {
|
249
|
+
NONE = 0,
|
250
|
+
SHAREDKEY = 1,
|
251
|
+
WOT = 2
|
252
|
+
}
|
253
|
+
}
|
254
|
+
}
|