@agentvault/agentvault 0.20.26 → 0.20.27

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/cli.js CHANGED
@@ -62735,10 +62735,10 @@ async function hasPendingWelcome(dataDir2, groupId) {
62735
62735
  return false;
62736
62736
  }
62737
62737
  }
62738
- async function savePendingKpBundle(dataDir2, groupId, kp) {
62738
+ async function savePendingKpBundle(dataDir2, groupId, kp, serializePublicFn) {
62739
62739
  await mkdir(dataDir2, { recursive: true, mode: DIR_MODE });
62740
62740
  const serialized = {
62741
- publicPackage: Buffer.from(kp.publicPackage).toString("base64"),
62741
+ publicPackageBytes: Buffer.from(serializePublicFn(kp.publicPackage)).toString("base64"),
62742
62742
  privatePackage: {
62743
62743
  initPrivateKey: Buffer.from(kp.privatePackage.initPrivateKey).toString("base64"),
62744
62744
  hpkePrivateKey: Buffer.from(kp.privatePackage.hpkePrivateKey).toString("base64"),
@@ -62752,7 +62752,7 @@ async function loadPendingKpBundle(dataDir2, groupId) {
62752
62752
  const raw = await readFile(pendingKpPath(dataDir2, groupId), "utf-8");
62753
62753
  const parsed = JSON.parse(raw);
62754
62754
  return {
62755
- publicPackage: new Uint8Array(Buffer.from(parsed.publicPackage, "base64")),
62755
+ publicPackageBytes: new Uint8Array(Buffer.from(parsed.publicPackageBytes, "base64")),
62756
62756
  privatePackage: {
62757
62757
  initPrivateKey: new Uint8Array(Buffer.from(parsed.privatePackage.initPrivateKey, "base64")),
62758
62758
  hpkePrivateKey: new Uint8Array(Buffer.from(parsed.privatePackage.hpkePrivateKey, "base64")),
@@ -65285,7 +65285,7 @@ var init_channel = __esm({
65285
65285
  const identity = new TextEncoder().encode(this._persisted.deviceId);
65286
65286
  const kp = await mgr.generateKeyPackage(identity);
65287
65287
  this._pendingMlsKpBundle = kp;
65288
- await savePendingKpBundle(this.config.dataDir, groupId, kp);
65288
+ await savePendingKpBundle(this.config.dataDir, groupId, kp, MLSGroupManager.serializeKeyPackage);
65289
65289
  const kpBytes = MLSGroupManager.serializeKeyPackage(kp.publicPackage);
65290
65290
  await fetch(`${this.config.apiUrl}/api/v1/mls/key-packages`, {
65291
65291
  method: "POST",
@@ -67149,17 +67149,26 @@ ${messageText}`;
67149
67149
  async _handleMlsWelcome(data) {
67150
67150
  const groupId = data.group_id;
67151
67151
  const conversationId = data.conversation_id;
67152
- const persistedKpAvailable = await hasPendingWelcome(this.config.dataDir, groupId);
67153
- const kpSource = this._pendingMlsKpBundle ? "pending" : persistedKpAvailable ? "persisted" : this._mlsKeyPackage ? "connect" : "generated";
67152
+ const kpSource = this._pendingMlsKpBundle ? "pending" : this._mlsKeyPackage ? "connect" : await hasPendingWelcome(this.config.dataDir, groupId) ? "persisted" : "generated";
67154
67153
  console.log(`[SecureChannel] Received MLS welcome for group ${groupId?.slice(0, 8)}${conversationId ? ` conv=${conversationId.slice(0, 8)}` : ""} kpSource=${kpSource}`);
67155
67154
  try {
67156
67155
  const welcomeBytes = new Uint8Array(Buffer.from(data.payload, "hex"));
67157
67156
  const mgr = new MLSGroupManager();
67158
- const persistedKp = await loadPendingKpBundle(this.config.dataDir, groupId);
67159
- const kp = this._pendingMlsKpBundle ?? persistedKp ?? this._mlsKeyPackage ?? await (async () => {
67157
+ let kp = this._pendingMlsKpBundle ?? this._mlsKeyPackage;
67158
+ if (!kp) {
67159
+ const persisted = await loadPendingKpBundle(this.config.dataDir, groupId);
67160
+ if (persisted) {
67161
+ kp = {
67162
+ publicPackage: MLSGroupManager.deserializeKeyPackage(persisted.publicPackageBytes),
67163
+ privatePackage: persisted.privatePackage
67164
+ };
67165
+ console.log(`[SecureChannel] Loaded persisted KP bundle for group ${groupId?.slice(0, 8)}`);
67166
+ }
67167
+ }
67168
+ if (!kp) {
67160
67169
  const identity = new TextEncoder().encode(this._deviceId);
67161
- return mgr.generateKeyPackage(identity);
67162
- })();
67170
+ kp = await mgr.generateKeyPackage(identity);
67171
+ }
67163
67172
  console.log(`[SecureChannel] Welcome joinFromWelcome: group=${groupId?.slice(0, 8)} kpSource=${kpSource} welcomeLen=${welcomeBytes.length}`);
67164
67173
  await mgr.joinFromWelcome(welcomeBytes, kp);
67165
67174
  if (conversationId) {
@@ -88963,7 +88972,7 @@ var init_index = __esm({
88963
88972
  init_skill_invoker();
88964
88973
  await init_skill_telemetry();
88965
88974
  await init_policy_enforcer();
88966
- VERSION = true ? "0.20.26" : "0.0.0-dev";
88975
+ VERSION = true ? "0.20.27" : "0.0.0-dev";
88967
88976
  }
88968
88977
  });
88969
88978