@dropgate/core 3.0.3 → 3.0.5

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
@@ -3136,8 +3136,6 @@ var DropgateClient = class {
3136
3136
  if (done) break;
3137
3137
  pendingChunks.push(value);
3138
3138
  pendingLength += value.length;
3139
- receivedBytes += value.length;
3140
- if (onBytesReceived) onBytesReceived(receivedBytes);
3141
3139
  while (pendingLength >= ENCRYPTED_CHUNK_SIZE) {
3142
3140
  const buffer = flushPending();
3143
3141
  const encryptedChunk = buffer.subarray(0, ENCRYPTED_CHUNK_SIZE);
@@ -3146,12 +3144,16 @@ var DropgateClient = class {
3146
3144
  pendingLength = buffer.length - ENCRYPTED_CHUNK_SIZE;
3147
3145
  }
3148
3146
  const decryptedBuffer = await decryptChunk(this.cryptoObj, encryptedChunk, cryptoKey);
3147
+ receivedBytes += decryptedBuffer.byteLength;
3148
+ if (onBytesReceived) onBytesReceived(receivedBytes);
3149
3149
  if (onChunk) await onChunk(new Uint8Array(decryptedBuffer));
3150
3150
  }
3151
3151
  }
3152
3152
  if (pendingLength > 0) {
3153
3153
  const buffer = flushPending();
3154
3154
  const decryptedBuffer = await decryptChunk(this.cryptoObj, buffer, cryptoKey);
3155
+ receivedBytes += decryptedBuffer.byteLength;
3156
+ if (onBytesReceived) onBytesReceived(receivedBytes);
3155
3157
  if (onChunk) await onChunk(new Uint8Array(decryptedBuffer));
3156
3158
  }
3157
3159
  } else {