@freesignal/protocol 0.7.10 → 0.7.11
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/node.d.ts +2 -3
- package/dist/node.js +7 -8
- package/package.json +1 -1
package/dist/node.d.ts
CHANGED
|
@@ -24,11 +24,10 @@ import EventEmitter, { EventCallback } from "easyemitter.ts";
|
|
|
24
24
|
export declare class BootstrapRequest extends EventEmitter<'change', BootstrapRequest> {
|
|
25
25
|
#private;
|
|
26
26
|
readonly senderId: UserId | string;
|
|
27
|
-
|
|
28
|
-
constructor(senderId: UserId | string,
|
|
27
|
+
readonly data: KeyExchangeData;
|
|
28
|
+
constructor(senderId: UserId | string, data: KeyExchangeData);
|
|
29
29
|
onChange: EventCallback<BootstrapRequest, this>;
|
|
30
30
|
get status(): "pending" | "accepted" | "denied";
|
|
31
|
-
get data(): KeyExchangeData | undefined;
|
|
32
31
|
accept(): void;
|
|
33
32
|
deny(): void;
|
|
34
33
|
}
|
package/dist/node.js
CHANGED
|
@@ -51,10 +51,10 @@ const utils_1 = require("@freesignal/utils");
|
|
|
51
51
|
const crypto_1 = __importDefault(require("@freesignal/crypto"));
|
|
52
52
|
const easyemitter_ts_1 = __importDefault(require("easyemitter.ts"));
|
|
53
53
|
class BootstrapRequest extends easyemitter_ts_1.default {
|
|
54
|
-
constructor(senderId,
|
|
54
|
+
constructor(senderId, data) {
|
|
55
55
|
super();
|
|
56
56
|
this.senderId = senderId;
|
|
57
|
-
this.
|
|
57
|
+
this.data = data;
|
|
58
58
|
_BootstrapRequest_status.set(this, 'pending');
|
|
59
59
|
this.onChange = () => { };
|
|
60
60
|
this.on('change', (data, emitter) => this.onChange(data, emitter));
|
|
@@ -62,9 +62,6 @@ class BootstrapRequest extends easyemitter_ts_1.default {
|
|
|
62
62
|
get status() {
|
|
63
63
|
return __classPrivateFieldGet(this, _BootstrapRequest_status, "f");
|
|
64
64
|
}
|
|
65
|
-
get data() {
|
|
66
|
-
return __classPrivateFieldGet(this, _BootstrapRequest_status, "f") === 'accepted' ? this.keyExchangeData : undefined;
|
|
67
|
-
}
|
|
68
65
|
accept() {
|
|
69
66
|
if (this.status === 'pending') {
|
|
70
67
|
__classPrivateFieldSet(this, _BootstrapRequest_status, 'accepted', "f");
|
|
@@ -328,10 +325,12 @@ class FreeSignalNode {
|
|
|
328
325
|
const keyExchangeData = (0, utils_1.decodeData)(datagram.payload);
|
|
329
326
|
const userId = types_1.UserId.fromKey(keyExchangeData.identityKey);
|
|
330
327
|
const request = new BootstrapRequest(userId, keyExchangeData);
|
|
328
|
+
let sended = false;
|
|
331
329
|
request.onChange = (request) => {
|
|
332
|
-
if (
|
|
333
|
-
|
|
334
|
-
|
|
330
|
+
if (request.status === 'accepted' && !sended) {
|
|
331
|
+
sended = true;
|
|
332
|
+
this.sendHandshake(request.data);
|
|
333
|
+
}
|
|
335
334
|
};
|
|
336
335
|
yield this.bootstraps.set(userId.toString(), request);
|
|
337
336
|
this.emitter.emit('bootstrap', { request });
|