fix: harden Protobuf Deserialization and Refactor Utilities (#1820)

* refactor: reorganize browser utility functions and improve buffer handling

* fix: harden protobuf deserialization and clean up code

* refactor: simplify data handling in GroupCipher and SenderKey classes

* fix: Ensure consistent Buffer hydration and remove redundant code

* refactor: update decodeAndHydrate calls to use proto types for improved type safety
This commit is contained in:
João Lucas de Oliveira Lopes
2025-09-25 22:45:30 -03:00
committed by GitHub
parent 202c39f3fe
commit 3b46d43beb
23 changed files with 194 additions and 160 deletions
+1 -10
View File
@@ -9,16 +9,7 @@ export class SenderChainKey {
constructor(iteration: number, chainKey: Uint8Array | Buffer) {
this.iteration = iteration
if (Buffer.isBuffer(chainKey)) {
this.chainKey = chainKey
} else if (chainKey instanceof Uint8Array) {
this.chainKey = Buffer.from(chainKey)
} else if (chainKey && typeof chainKey === 'object') {
// backported from @MartinSchere (#1741)
this.chainKey = Buffer.from(Object.values(chainKey)) // temp fix // backported from @MartinSchere (#1741)
} else {
this.chainKey = Buffer.alloc(0)
}
this.chainKey = Buffer.from(chainKey)
}
public getIteration(): number {