Skip to content

Commit

Permalink
🤖 🎨 Autoformat
Browse files Browse the repository at this point in the history
  • Loading branch information
dmihalcik-virtru committed Jan 23, 2025
1 parent c880c6b commit 2ec76c0
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions lib/tdf3/src/tdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,9 @@ export async function sliceAndDecrypt({
isLegacyTDF
);
if (plainSegmentSize && result.payload.length() !== plainSegmentSize) {
throw new DecryptError(`incorrect segment size: found [${result.payload.length()}], expected [${plainSegmentSize}]`);
throw new DecryptError(
`incorrect segment size: found [${result.payload.length()}], expected [${plainSegmentSize}]`
);
}
slice[index].decryptedChunk.set(result);
} catch (e) {
Expand Down Expand Up @@ -950,20 +952,26 @@ export async function readStream(cfg: DecryptConfiguration) {

let mapOfRequestsOffset = 0;
const chunkMap = new Map(
segments.map(({ hash, encryptedSegmentSize = encryptedSegmentSizeDefault, segmentSize = segmentSizeDefault }) => {
const result = (() => {
const chunk: Chunk = {
hash,
encryptedOffset: mapOfRequestsOffset,
encryptedSegmentSize,
decryptedChunk: mailbox<DecryptResult>(),
plainSegmentSize: segmentSize,
};
return chunk;
})();
mapOfRequestsOffset += encryptedSegmentSize;
return [hash, result];
})
segments.map(
({
hash,
encryptedSegmentSize = encryptedSegmentSizeDefault,
segmentSize = segmentSizeDefault,
}) => {
const result = (() => {
const chunk: Chunk = {
hash,
encryptedOffset: mapOfRequestsOffset,
encryptedSegmentSize,
decryptedChunk: mailbox<DecryptResult>(),
plainSegmentSize: segmentSize,
};
return chunk;
})();
mapOfRequestsOffset += encryptedSegmentSize;
return [hash, result];
}
)
);

const cipher = new AesGcmCipher(cfg.cryptoService);
Expand Down

0 comments on commit 2ec76c0

Please sign in to comment.