@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.cjs CHANGED
@@ -3199,8 +3199,6 @@ var DropgateClient = class {
3199
3199
  if (done) break;
3200
3200
  pendingChunks.push(value);
3201
3201
  pendingLength += value.length;
3202
- receivedBytes += value.length;
3203
- if (onBytesReceived) onBytesReceived(receivedBytes);
3204
3202
  while (pendingLength >= ENCRYPTED_CHUNK_SIZE) {
3205
3203
  const buffer = flushPending();
3206
3204
  const encryptedChunk = buffer.subarray(0, ENCRYPTED_CHUNK_SIZE);
@@ -3209,12 +3207,16 @@ var DropgateClient = class {
3209
3207
  pendingLength = buffer.length - ENCRYPTED_CHUNK_SIZE;
3210
3208
  }
3211
3209
  const decryptedBuffer = await decryptChunk(this.cryptoObj, encryptedChunk, cryptoKey);
3210
+ receivedBytes += decryptedBuffer.byteLength;
3211
+ if (onBytesReceived) onBytesReceived(receivedBytes);
3212
3212
  if (onChunk) await onChunk(new Uint8Array(decryptedBuffer));
3213
3213
  }
3214
3214
  }
3215
3215
  if (pendingLength > 0) {
3216
3216
  const buffer = flushPending();
3217
3217
  const decryptedBuffer = await decryptChunk(this.cryptoObj, buffer, cryptoKey);
3218
+ receivedBytes += decryptedBuffer.byteLength;
3219
+ if (onBytesReceived) onBytesReceived(receivedBytes);
3218
3220
  if (onChunk) await onChunk(new Uint8Array(decryptedBuffer));
3219
3221
  }
3220
3222
  } else {