@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.
@@ -2591,6 +2591,7 @@ var AbracadabraBaseProvider = class extends EventEmitter {
2591
2591
  }
2592
2592
  documentUpdateHandler(update, origin) {
2593
2593
  if (origin === this) return;
2594
+ if (!this.isAuthenticated) return;
2594
2595
  this.incrementUnsyncedChanges();
2595
2596
  this.send(UpdateMessage, {
2596
2597
  update,
@@ -2598,6 +2599,7 @@ var AbracadabraBaseProvider = class extends EventEmitter {
2598
2599
  });
2599
2600
  }
2600
2601
  awarenessUpdateHandler({ added, updated, removed }, origin) {
2602
+ if (!this.isAuthenticated) return;
2601
2603
  const changedClients = added.concat(updated).concat(removed);
2602
2604
  this.send(AwarenessMessage, {
2603
2605
  awareness: this.awareness,
@@ -15968,6 +15970,7 @@ var E2EAbracadabraProvider = class E2EAbracadabraProvider extends AbracadabraPro
15968
15970
  this.compactionInFlightTimeout = null;
15969
15971
  this.compactionDebounceTimer = null;
15970
15972
  this.destroyed = false;
15973
+ this._pendingPreAuthUpdates = [];
15971
15974
  this.docKeyManager = configuration.docKeyManager;
15972
15975
  this.keystore = configuration.keystore;
15973
15976
  this.e2eClient = configuration.client;
@@ -16048,10 +16051,27 @@ var E2EAbracadabraProvider = class E2EAbracadabraProvider extends AbracadabraPro
16048
16051
  /** Encrypt local updates before sending over WebSocket. */
16049
16052
  documentUpdateHandler(update, origin) {
16050
16053
  if (origin === this) return;
16054
+ if (!this.isAuthenticated) {
16055
+ this._pendingPreAuthUpdates.push(update);
16056
+ return;
16057
+ }
16051
16058
  this._encryptAndSend(update).catch((e) => {
16052
16059
  console.error("[E2EAbracadabraProvider] failed to encrypt update:", e);
16053
16060
  });
16054
16061
  }
16062
+ /**
16063
+ * Flush updates buffered while unauthenticated once the server confirms the
16064
+ * doc is subscribed, then resume normal live sends.
16065
+ */
16066
+ authenticatedHandler(scope) {
16067
+ super.authenticatedHandler(scope);
16068
+ if (this._pendingPreAuthUpdates.length === 0) return;
16069
+ const pending = this._pendingPreAuthUpdates;
16070
+ this._pendingPreAuthUpdates = [];
16071
+ for (const update of pending) this._encryptAndSend(update).catch((e) => {
16072
+ console.error("[E2EAbracadabraProvider] failed to flush pre-auth update:", e);
16073
+ });
16074
+ }
16055
16075
  async _encryptAndSend(update) {
16056
16076
  const key = await this.ensureDocKey();
16057
16077
  if (!key) {