@agentvault/secure-channel 0.6.9 → 0.6.10
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/channel.d.ts +4 -0
- package/dist/channel.d.ts.map +1 -1
- package/dist/cli.js +19 -0
- package/dist/cli.js.map +2 -2
- package/dist/index.js +19 -0
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
package/dist/channel.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ export declare class SecureChannel extends EventEmitter {
|
|
|
14
14
|
private _reconnectTimer;
|
|
15
15
|
private _pingTimer;
|
|
16
16
|
private _pingTimeout;
|
|
17
|
+
private _pendingAcks;
|
|
18
|
+
private _ackTimer;
|
|
17
19
|
private _stopped;
|
|
18
20
|
private _persisted;
|
|
19
21
|
private static readonly PING_INTERVAL_MS;
|
|
@@ -90,6 +92,8 @@ export declare class SecureChannel extends EventEmitter {
|
|
|
90
92
|
* For each conversation, fetches messages since last sync and decrypts.
|
|
91
93
|
*/
|
|
92
94
|
private _syncMissedMessages;
|
|
95
|
+
private _sendAck;
|
|
96
|
+
private _flushAcks;
|
|
93
97
|
private _startPing;
|
|
94
98
|
private _stopPing;
|
|
95
99
|
private _scheduleReconnect;
|
package/dist/channel.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAa3C,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,EAKb,MAAM,YAAY,CAAC;AAiDpB,qBAAa,aAAc,SAAQ,YAAY;
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAa3C,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,EAKb,MAAM,YAAY,CAAC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AC,IAAI,CAAC;IAyCtE,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA0B3B;;;OAGG;IACG,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC;IAsC1F;;;OAGG;IACG,UAAU,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;YAiCtE,OAAO;IAgDrB,OAAO,CAAC,KAAK;YAsCC,SAAS;IAyIvB,OAAO,CAAC,QAAQ;IAwEhB;;;;OAIG;YACW,sBAAsB;IA2FpC;;;OAGG;YACW,oBAAoB;IAqClC;;;OAGG;YACW,uBAAuB;IAkCrC;;;;OAIG;YACW,mBAAmB;IAkEjC;;;OAGG;YACW,mBAAmB;IA+FjC,OAAO,CAAC,QAAQ;IAMhB,OAAO,CAAC,UAAU;IAMlB,OAAO,CAAC,UAAU;IAoBlB,OAAO,CAAC,SAAS;IAWjB,OAAO,CAAC,kBAAkB;IAiB1B,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,YAAY;IAKpB;;;OAGG;YACW,aAAa;CAc5B"}
|
package/dist/cli.js
CHANGED
|
@@ -45079,6 +45079,8 @@ var SecureChannel = class _SecureChannel extends EventEmitter {
|
|
|
45079
45079
|
_reconnectTimer = null;
|
|
45080
45080
|
_pingTimer = null;
|
|
45081
45081
|
_pingTimeout = null;
|
|
45082
|
+
_pendingAcks = [];
|
|
45083
|
+
_ackTimer = null;
|
|
45082
45084
|
_stopped = false;
|
|
45083
45085
|
_persisted = null;
|
|
45084
45086
|
static PING_INTERVAL_MS = 3e4;
|
|
@@ -45191,7 +45193,12 @@ var SecureChannel = class _SecureChannel extends EventEmitter {
|
|
|
45191
45193
|
}
|
|
45192
45194
|
async stop() {
|
|
45193
45195
|
this._stopped = true;
|
|
45196
|
+
this._flushAcks();
|
|
45194
45197
|
this._stopPing();
|
|
45198
|
+
if (this._ackTimer) {
|
|
45199
|
+
clearTimeout(this._ackTimer);
|
|
45200
|
+
this._ackTimer = null;
|
|
45201
|
+
}
|
|
45195
45202
|
if (this._pollTimer) {
|
|
45196
45203
|
clearTimeout(this._pollTimer);
|
|
45197
45204
|
this._pollTimer = null;
|
|
@@ -45522,6 +45529,7 @@ var SecureChannel = class _SecureChannel extends EventEmitter {
|
|
|
45522
45529
|
ciphertext: msgData.ciphertext
|
|
45523
45530
|
});
|
|
45524
45531
|
const plaintext = session.ratchet.decrypt(encrypted);
|
|
45532
|
+
this._sendAck(msgData.message_id);
|
|
45525
45533
|
if (!session.activated) {
|
|
45526
45534
|
session.activated = true;
|
|
45527
45535
|
console.log(`[SecureChannel] Session ${convId.slice(0, 8)}... activated by first owner message`);
|
|
@@ -45706,6 +45714,7 @@ var SecureChannel = class _SecureChannel extends EventEmitter {
|
|
|
45706
45714
|
ciphertext: msg.ciphertext
|
|
45707
45715
|
});
|
|
45708
45716
|
const plaintext = session.ratchet.decrypt(encrypted);
|
|
45717
|
+
this._sendAck(msg.id);
|
|
45709
45718
|
if (!session.activated) {
|
|
45710
45719
|
session.activated = true;
|
|
45711
45720
|
console.log(`[SecureChannel] Session ${msg.conversation_id.slice(0, 8)}... activated during sync`);
|
|
@@ -45742,6 +45751,16 @@ var SecureChannel = class _SecureChannel extends EventEmitter {
|
|
|
45742
45751
|
} catch {
|
|
45743
45752
|
}
|
|
45744
45753
|
}
|
|
45754
|
+
_sendAck(messageId) {
|
|
45755
|
+
this._pendingAcks.push(messageId);
|
|
45756
|
+
if (this._ackTimer) clearTimeout(this._ackTimer);
|
|
45757
|
+
this._ackTimer = setTimeout(() => this._flushAcks(), 500);
|
|
45758
|
+
}
|
|
45759
|
+
_flushAcks() {
|
|
45760
|
+
if (this._pendingAcks.length === 0 || !this._ws) return;
|
|
45761
|
+
const batch = this._pendingAcks.splice(0, 50);
|
|
45762
|
+
this._ws.send(JSON.stringify({ event: "ack", data: { message_ids: batch } }));
|
|
45763
|
+
}
|
|
45745
45764
|
_startPing(ws) {
|
|
45746
45765
|
this._stopPing();
|
|
45747
45766
|
this._pingTimer = setInterval(() => {
|