@freesignal/protocol 0.7.5 → 0.7.6
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 +6 -6
- package/dist/node.js +7 -8
- package/package.json +1 -1
package/dist/node.d.ts
CHANGED
|
@@ -20,13 +20,13 @@ import { Database, LocalStorage, Crypto, KeyExchangeDataBundle, KeyExchangeData
|
|
|
20
20
|
import { Datagram, EncryptedDatagram, IdentityKey, PrivateIdentityKey, Protocols, UserId } from "./types";
|
|
21
21
|
import { KeyExchange } from "./x3dh";
|
|
22
22
|
import { ExportedKeySession, KeySession } from "./double-ratchet";
|
|
23
|
-
import EventEmitter, {
|
|
23
|
+
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
27
|
private readonly keyExchangeData;
|
|
28
28
|
constructor(senderId: UserId | string, keyExchangeData: KeyExchangeData);
|
|
29
|
-
onChange:
|
|
29
|
+
onChange: EventCallback<BootstrapRequest, this>;
|
|
30
30
|
get status(): "pending" | "accepted" | "denied";
|
|
31
31
|
get data(): KeyExchangeData | undefined;
|
|
32
32
|
accept(): void;
|
|
@@ -64,10 +64,10 @@ export declare class FreeSignalNode {
|
|
|
64
64
|
bundles: LocalStorage<string, KeyExchangeDataBundle>;
|
|
65
65
|
bootstraps: LocalStorage<string, BootstrapRequest>;
|
|
66
66
|
}>, privateIdentityKey?: PrivateIdentityKey);
|
|
67
|
-
protected messageHandler:
|
|
68
|
-
protected sendHandler:
|
|
69
|
-
protected handshakeHandler:
|
|
70
|
-
protected bootstrapHandler:
|
|
67
|
+
protected messageHandler: EventCallback<NodeEventData, typeof this.emitter>;
|
|
68
|
+
protected sendHandler: EventCallback<NodeEventData, typeof this.emitter>;
|
|
69
|
+
protected handshakeHandler: EventCallback<NodeEventData, typeof this.emitter>;
|
|
70
|
+
protected bootstrapHandler: EventCallback<NodeEventData, typeof this.emitter>;
|
|
71
71
|
onMessage: (data: MessageEventData) => void;
|
|
72
72
|
onSend: (data: Uint8Array) => void;
|
|
73
73
|
onHandshake: (userId: UserId) => void;
|
package/dist/node.js
CHANGED
|
@@ -57,7 +57,7 @@ class BootstrapRequest extends easyemitter_ts_1.default {
|
|
|
57
57
|
this.keyExchangeData = keyExchangeData;
|
|
58
58
|
_BootstrapRequest_status.set(this, 'pending');
|
|
59
59
|
this.onChange = () => { };
|
|
60
|
-
this.on('change', (data) => this.onChange(data));
|
|
60
|
+
this.on('change', (data, emitter) => this.onChange(data, emitter));
|
|
61
61
|
}
|
|
62
62
|
get status() {
|
|
63
63
|
return __classPrivateFieldGet(this, _BootstrapRequest_status, "f");
|
|
@@ -82,10 +82,10 @@ class FreeSignalNode {
|
|
|
82
82
|
constructor(storage, privateIdentityKey) {
|
|
83
83
|
this.discovers = new Set();
|
|
84
84
|
this.emitter = new easyemitter_ts_1.default();
|
|
85
|
-
this.messageHandler = (data) =>
|
|
86
|
-
this.sendHandler = (data) => this.onSend(data.
|
|
87
|
-
this.handshakeHandler = (data) => { var _a
|
|
88
|
-
this.bootstrapHandler = (data) =>
|
|
85
|
+
this.messageHandler = (data) => this.onMessage({ session: data.session, payload: data.payload });
|
|
86
|
+
this.sendHandler = (data) => this.onSend(data.datagram.toBytes());
|
|
87
|
+
this.handshakeHandler = (data) => { var _a; return this.onHandshake(types_1.UserId.from((_a = data.session) === null || _a === void 0 ? void 0 : _a.userId)); };
|
|
88
|
+
this.bootstrapHandler = (data) => this.onRequest(data.request);
|
|
89
89
|
this.onMessage = () => { };
|
|
90
90
|
this.onSend = () => { };
|
|
91
91
|
this.onHandshake = () => { };
|
|
@@ -309,11 +309,10 @@ class FreeSignalNode {
|
|
|
309
309
|
const keyExchangeData = (0, utils_1.decodeData)(datagram.payload);
|
|
310
310
|
const userId = types_1.UserId.fromKey(keyExchangeData.identityKey);
|
|
311
311
|
const request = new BootstrapRequest(userId, keyExchangeData);
|
|
312
|
-
request.onChange = (
|
|
313
|
-
var _a;
|
|
312
|
+
request.onChange = (request) => {
|
|
314
313
|
if (!request.data)
|
|
315
314
|
throw new Error("Error sending handshake");
|
|
316
|
-
this.sendHandshake(
|
|
315
|
+
this.sendHandshake(request.data);
|
|
317
316
|
};
|
|
318
317
|
yield this.bootstraps.set(userId.toString(), request);
|
|
319
318
|
this.emitter.emit('bootstrap', { request });
|