@abraca/dabra 2.35.0 → 2.35.1

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.
@@ -2621,6 +2621,7 @@ var AbracadabraBaseProvider = class extends EventEmitter {
2621
2621
  }
2622
2622
  documentUpdateHandler(update, origin) {
2623
2623
  if (origin === this) return;
2624
+ if (!this.isAuthenticated) return;
2624
2625
  this.incrementUnsyncedChanges();
2625
2626
  this.send(UpdateMessage, {
2626
2627
  update,
@@ -2628,6 +2629,7 @@ var AbracadabraBaseProvider = class extends EventEmitter {
2628
2629
  });
2629
2630
  }
2630
2631
  awarenessUpdateHandler({ added, updated, removed }, origin) {
2632
+ if (!this.isAuthenticated) return;
2631
2633
  const changedClients = added.concat(updated).concat(removed);
2632
2634
  this.send(AwarenessMessage, {
2633
2635
  awareness: this.awareness,
@@ -16007,6 +16009,7 @@ var E2EAbracadabraProvider = class E2EAbracadabraProvider extends AbracadabraPro
16007
16009
  this.compactionInFlightTimeout = null;
16008
16010
  this.compactionDebounceTimer = null;
16009
16011
  this.destroyed = false;
16012
+ this._pendingPreAuthUpdates = [];
16010
16013
  this.docKeyManager = configuration.docKeyManager;
16011
16014
  this.keystore = configuration.keystore;
16012
16015
  this.e2eClient = configuration.client;
@@ -16087,10 +16090,27 @@ var E2EAbracadabraProvider = class E2EAbracadabraProvider extends AbracadabraPro
16087
16090
  /** Encrypt local updates before sending over WebSocket. */
16088
16091
  documentUpdateHandler(update, origin) {
16089
16092
  if (origin === this) return;
16093
+ if (!this.isAuthenticated) {
16094
+ this._pendingPreAuthUpdates.push(update);
16095
+ return;
16096
+ }
16090
16097
  this._encryptAndSend(update).catch((e) => {
16091
16098
  console.error("[E2EAbracadabraProvider] failed to encrypt update:", e);
16092
16099
  });
16093
16100
  }
16101
+ /**
16102
+ * Flush updates buffered while unauthenticated once the server confirms the
16103
+ * doc is subscribed, then resume normal live sends.
16104
+ */
16105
+ authenticatedHandler(scope) {
16106
+ super.authenticatedHandler(scope);
16107
+ if (this._pendingPreAuthUpdates.length === 0) return;
16108
+ const pending = this._pendingPreAuthUpdates;
16109
+ this._pendingPreAuthUpdates = [];
16110
+ for (const update of pending) this._encryptAndSend(update).catch((e) => {
16111
+ console.error("[E2EAbracadabraProvider] failed to flush pre-auth update:", e);
16112
+ });
16113
+ }
16094
16114
  async _encryptAndSend(update) {
16095
16115
  const key = await this.ensureDocKey();
16096
16116
  if (!key) {