@agentvault/agentvault 0.19.24 → 0.19.26

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/index.js CHANGED
@@ -48813,27 +48813,33 @@ var init_channel = __esm({
48813
48813
  const a2aCount = Object.keys(this._persisted?.a2aChannels ?? {}).length;
48814
48814
  console.log(`[SecureChannel] A2A sync complete: ${a2aCount} channels`);
48815
48815
  this.emit("a2a_channels_synced", { count: a2aCount });
48816
- if (this._persisted?.a2aChannels && this._ws) {
48817
- for (const [chId, entry] of Object.entries(this._persisted.a2aChannels)) {
48818
- if (!entry.session && !entry.pendingEphemeralPrivateKey && entry.conversationId) {
48819
- try {
48820
- const a2aEphemeral = await generateEphemeralKeypair();
48821
- const ephPubHex = bytesToHex(a2aEphemeral.publicKey);
48822
- const ephPrivHex = bytesToHex(a2aEphemeral.privateKey);
48823
- entry.pendingEphemeralPrivateKey = ephPrivHex;
48824
- this._ws.send(JSON.stringify({
48825
- event: "a2a_key_exchange",
48826
- data: { channel_id: chId, ephemeral_key: ephPubHex }
48827
- }));
48828
- console.log(
48829
- `[SecureChannel] A2A key exchange initiated for channel ${chId.slice(0, 8)}... (role=${entry.role ?? "unknown"})`
48830
- );
48831
- } catch (kxErr) {
48832
- console.warn(`[SecureChannel] A2A key exchange failed for ${chId.slice(0, 8)}...:`, kxErr);
48816
+ if (this._persisted?.a2aChannels) {
48817
+ const channelsNeedingKx = Object.entries(this._persisted.a2aChannels).filter(
48818
+ ([_2, entry]) => !entry.session && !entry.pendingEphemeralPrivateKey && entry.conversationId
48819
+ );
48820
+ if (channelsNeedingKx.length > 0) {
48821
+ setTimeout(async () => {
48822
+ if (!this._ws || this._state !== "ready") return;
48823
+ for (const [chId, entry] of channelsNeedingKx) {
48824
+ try {
48825
+ const a2aEphemeral = await generateEphemeralKeypair();
48826
+ const ephPubHex = bytesToHex(a2aEphemeral.publicKey);
48827
+ const ephPrivHex = bytesToHex(a2aEphemeral.privateKey);
48828
+ entry.pendingEphemeralPrivateKey = ephPrivHex;
48829
+ this._ws.send(JSON.stringify({
48830
+ event: "a2a_key_exchange",
48831
+ data: { channel_id: chId, ephemeral_key: ephPubHex }
48832
+ }));
48833
+ console.log(
48834
+ `[SecureChannel] A2A key exchange initiated for channel ${chId.slice(0, 8)}... (role=${entry.role ?? "unknown"})`
48835
+ );
48836
+ } catch (kxErr) {
48837
+ console.warn(`[SecureChannel] A2A key exchange failed for ${chId.slice(0, 8)}...:`, kxErr);
48838
+ }
48833
48839
  }
48834
- }
48840
+ await this._persistState();
48841
+ }, 3e3);
48835
48842
  }
48836
- await this._persistState();
48837
48843
  }
48838
48844
  } catch (err) {
48839
48845
  console.warn("[SecureChannel] A2A channel sync failed (non-fatal):", err);
@@ -49352,7 +49358,7 @@ var init_channel = __esm({
49352
49358
  previousChainLength: headerObj.previousChainLength,
49353
49359
  messageNumber: headerObj.messageNumber
49354
49360
  },
49355
- headerSignature: hexToBytes(msgData.header_signature),
49361
+ headerSignature: msgData.header_signature ? hexToBytes(msgData.header_signature) : new Uint8Array(64),
49356
49362
  ciphertext: hexToBytes(msgData.ciphertext),
49357
49363
  nonce: hexToBytes(msgData.nonce)
49358
49364
  };