@freesignal/protocol 0.4.4 → 0.4.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 CHANGED
@@ -17,7 +17,7 @@
17
17
  * along with this program. If not, see <https://www.gnu.org/licenses/>
18
18
  */
19
19
  import { Database, LocalStorage, Crypto, KeyExchangeDataBundle, KeyExchangeData } from "@freesignal/interfaces";
20
- import { Datagram, DatagramHeader, IdentityKey, PrivateIdentityKey, Protocols, UserId } from "./types";
20
+ import { Datagram, DatagramHeader, DiscoverType, IdentityKey, PrivateIdentityKey, Protocols, UserId } from "./types";
21
21
  import { KeyExchange } from "./x3dh";
22
22
  import { ExportedKeySession, KeySession } from "./double-ratchet";
23
23
  export declare class BootstrapRequest {
@@ -65,6 +65,7 @@ export declare class FreeSignalNode {
65
65
  open(datagram: Datagram | Uint8Array): Promise<{
66
66
  header: DatagramHeader;
67
67
  payload?: Uint8Array;
68
+ discoverType?: DiscoverType;
68
69
  }>;
69
70
  }
70
71
  declare class SessionMap implements LocalStorage<string, KeySession> {
package/dist/node.js CHANGED
@@ -187,10 +187,10 @@ class FreeSignalNode {
187
187
  yield this.bundles.set(userId.toString(), (0, utils_1.decodeData)(associatedData));
188
188
  return out;
189
189
  case types_1.Protocols.MESSAGE:
190
- out.payload = (0, utils_1.decodeData)(yield this.decrypt(datagram));
190
+ out.payload = yield this.decrypt(datagram);
191
191
  return out;
192
192
  case types_1.Protocols.RELAY:
193
- out.payload = (0, utils_1.decodeData)(yield this.decrypt(datagram));
193
+ out.payload = yield this.decrypt(datagram);
194
194
  return out;
195
195
  case types_1.Protocols.DISCOVER:
196
196
  const message = (0, utils_1.decodeData)(yield this.decrypt(datagram));
@@ -219,11 +219,14 @@ class FreeSignalNode {
219
219
  }
220
220
  const response = { type: types_1.DiscoverType.RESPONSE, discoverId: message.discoverId, data };
221
221
  out.payload = (yield this.encrypt(datagram.sender, types_1.Protocols.DISCOVER, (0, utils_1.encodeData)(response))).toBytes();
222
+ out.discoverType = types_1.DiscoverType.REQUEST;
222
223
  }
223
224
  else if (message.type === types_1.DiscoverType.RESPONSE && this.discovers.has(message.discoverId)) {
224
225
  this.discovers.delete(message.discoverId);
225
- if (message.data)
226
+ if (message.data) {
226
227
  out.payload = (0, utils_1.encodeData)(message.data);
228
+ out.discoverType = types_1.DiscoverType.RESPONSE;
229
+ }
227
230
  }
228
231
  return out;
229
232
  case types_1.Protocols.BOOTSTRAP:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@freesignal/protocol",
3
- "version": "0.4.4",
3
+ "version": "0.4.6",
4
4
  "description": "Signal Protocol implementation in javascript",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "author": "Christian Braghette",