@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 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
- private readonly keyExchangeData;
28
- constructor(senderId: UserId | string, keyExchangeData: KeyExchangeData);
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, keyExchangeData) {
54
+ constructor(senderId, data) {
55
55
  super();
56
56
  this.senderId = senderId;
57
- this.keyExchangeData = keyExchangeData;
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 (!request.data)
333
- throw new Error("Error sending handshake");
334
- this.sendHandshake(request.data);
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 });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@freesignal/protocol",
3
- "version": "0.7.10",
3
+ "version": "0.7.11",
4
4
  "description": "Signal Protocol implementation in javascript",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "author": "Christian Braghette",