@freesignal/protocol 0.7.3 → 0.7.5

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
@@ -37,10 +37,12 @@ type NodeEventData = {
37
37
  payload?: Uint8Array;
38
38
  datagram?: Datagram;
39
39
  request?: BootstrapRequest;
40
+ userId?: UserId;
40
41
  };
41
42
  type SendEventData = {
42
43
  session?: KeySession;
43
44
  datagram: Datagram;
45
+ userId: UserId;
44
46
  };
45
47
  type MessageEventData = {
46
48
  session: KeySession;
package/dist/node.js CHANGED
@@ -129,7 +129,7 @@ class FreeSignalNode {
129
129
  throw new Error("Session not found for sessionTag: " + sessionTag);
130
130
  const encrypted = (0, types_1.encryptData)(session, data);
131
131
  this.sessions.set(receiverId.toString(), session);
132
- return { session, datagram: new types_1.EncryptedDatagram(protocol, session.sessionTag, encrypted).sign(this.privateIdentityKey.signatureKey) };
132
+ return { session, userId: types_1.UserId.from(receiverId), datagram: new types_1.EncryptedDatagram(protocol, session.sessionTag, encrypted).sign(this.privateIdentityKey.signatureKey) };
133
133
  });
134
134
  }
135
135
  sendHandshake(data) {
@@ -138,7 +138,7 @@ class FreeSignalNode {
138
138
  //console.debug("Sending Handshake Ack");
139
139
  const session = yield this.sessions.get(data.sessionTag);
140
140
  if (!session)
141
- throw new Error("Session not found for user: " + data);
141
+ throw new Error("Session not found for sessionTag: " + data.sessionTag);
142
142
  this.emitter.emit('send', yield this.encrypt(session.userId, types_1.Protocols.HANDSHAKE, crypto_1.default.ECDH.scalarMult(this.privateIdentityKey.exchangeKey, session.identityKey.exchangeKey)));
143
143
  return;
144
144
  }
@@ -147,7 +147,7 @@ class FreeSignalNode {
147
147
  yield this.sessions.set(session.sessionTag, session);
148
148
  yield this.users.set(session.userId.toString(), session.sessionTag);
149
149
  const datagram = new types_1.Datagram(types_1.Protocols.HANDSHAKE, (0, utils_1.encodeData)(message), session.sessionTag).sign(this.privateIdentityKey.signatureKey);
150
- this.emitter.emit('send', { session, datagram });
150
+ this.emitter.emit('send', { session, datagram, userId: session.userId });
151
151
  });
152
152
  }
153
153
  sendData(receiverId, data) {
@@ -172,7 +172,7 @@ class FreeSignalNode {
172
172
  if (!session)
173
173
  throw new Error("Session not found for sessionTag: " + sessionTag);
174
174
  const datagram = new types_1.Datagram(types_1.Protocols.PING, undefined, session.sessionTag);
175
- this.emitter.emit('send', { session, datagram });
175
+ this.emitter.emit('send', { session, datagram, userId: session.userId });
176
176
  });
177
177
  }
178
178
  sendDiscover(receiverId, discoverId) {
@@ -196,7 +196,7 @@ class FreeSignalNode {
196
196
  if (yield this.sessions.has(receiverId.toString()))
197
197
  throw new Error("Session exists");
198
198
  const datagram = new types_1.Datagram(types_1.Protocols.BOOTSTRAP, (0, utils_1.encodeData)(yield this.keyExchange.generateData()));
199
- this.emitter.emit('send', { datagram });
199
+ this.emitter.emit('send', { datagram, userId: types_1.UserId.from(receiverId) });
200
200
  });
201
201
  }
202
202
  decrypt(datagram) {
@@ -262,7 +262,7 @@ class FreeSignalNode {
262
262
  const session = yield this.sessions.get(sessionTag);
263
263
  if (!session)
264
264
  throw new Error("Session not found for sessionTag: " + datagram.sessionTag);
265
- this.emitter.emit('send', { session, payload: opened.payload.slice(types_1.UserId.keyLength) });
265
+ this.emitter.emit('send', { session, datagram: types_1.Datagram.from(opened.payload.slice(types_1.UserId.keyLength)), userId: session.userId });
266
266
  return;
267
267
  }
268
268
  case types_1.Protocols.DISCOVER: {
package/package.json CHANGED
@@ -1,45 +1,45 @@
1
- {
2
- "name": "@freesignal/protocol",
3
- "version": "0.7.3",
4
- "description": "Signal Protocol implementation in javascript",
5
- "license": "GPL-3.0-or-later",
6
- "author": "Christian Braghette",
7
- "type": "commonjs",
8
- "exports": {
9
- ".": {
10
- "import": "./dist/index.js",
11
- "require": "./dist/index.js",
12
- "types": "./dist/index.d.ts"
13
- },
14
- "./double-ratchet": {
15
- "import": "./dist/double-ratchet.js",
16
- "require": "./dist/double-ratchet.js",
17
- "types": "./dist/double-ratchet.d.ts"
18
- },
19
- "./node": {
20
- "import": "./dist/node.js",
21
- "require": "./dist/node.js",
22
- "types": "./dist/node.d.ts"
23
- },
24
- "./x3dh": {
25
- "import": "./dist/x3dh.js",
26
- "require": "./dist/x3dh.js",
27
- "types": "./dist/x3dh.d.ts"
28
- }
29
- },
30
- "main": "./dist/index.js",
31
- "scripts": {
32
- "pretest": "tsc",
33
- "test": "node ./dist/test.js",
34
- "prepare": "tsc"
35
- },
36
- "dependencies": {
37
- "@freesignal/crypto": "^0.3.0",
38
- "@freesignal/interfaces": "^0.2.0",
39
- "@freesignal/utils": "^1.4.1",
40
- "easyemitter.ts": "^1.0.3"
41
- },
42
- "devDependencies": {
43
- "@types/node": "^24.2.1"
44
- }
45
- }
1
+ {
2
+ "name": "@freesignal/protocol",
3
+ "version": "0.7.5",
4
+ "description": "Signal Protocol implementation in javascript",
5
+ "license": "GPL-3.0-or-later",
6
+ "author": "Christian Braghette",
7
+ "type": "commonjs",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "require": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ },
14
+ "./double-ratchet": {
15
+ "import": "./dist/double-ratchet.js",
16
+ "require": "./dist/double-ratchet.js",
17
+ "types": "./dist/double-ratchet.d.ts"
18
+ },
19
+ "./node": {
20
+ "import": "./dist/node.js",
21
+ "require": "./dist/node.js",
22
+ "types": "./dist/node.d.ts"
23
+ },
24
+ "./x3dh": {
25
+ "import": "./dist/x3dh.js",
26
+ "require": "./dist/x3dh.js",
27
+ "types": "./dist/x3dh.d.ts"
28
+ }
29
+ },
30
+ "main": "./dist/index.js",
31
+ "scripts": {
32
+ "pretest": "tsc",
33
+ "test": "node ./dist/test.js",
34
+ "prepare": "tsc"
35
+ },
36
+ "dependencies": {
37
+ "@freesignal/crypto": "^0.3.0",
38
+ "@freesignal/interfaces": "^0.2.0",
39
+ "@freesignal/utils": "^1.4.1",
40
+ "easyemitter.ts": "^1.0.3"
41
+ },
42
+ "devDependencies": {
43
+ "@types/node": "^24.2.1"
44
+ }
45
+ }