Skip to content

Commit b6d1fe7

Browse files
authored
fix: decoded encryption context is frozen (#598)
If the encryption context is empty it should still be frozen.
1 parent b89e042 commit b6d1fe7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

modules/serialize/src/decode_encryption_context.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ export function decodeEncryptionContextFactory(
2323
* Exported for testing. Used by deserializeMessageHeader to compose a complete solution.
2424
* @param encodedEncryptionContext Uint8Array
2525
*/
26-
function decodeEncryptionContext(encodedEncryptionContext: Uint8Array) {
26+
function decodeEncryptionContext(
27+
encodedEncryptionContext: Uint8Array
28+
): Readonly<EncryptionContext> {
2729
const encryptionContext: EncryptionContext = Object.create(null)
2830
/* Check for early return (Postcondition): The case of 0 length is defined as an empty object. */
2931
if (!encodedEncryptionContext.byteLength) {
30-
return encryptionContext
32+
return Object.freeze(encryptionContext)
3133
}
3234
/* Uint8Array is a view on top of the underlying ArrayBuffer.
3335
* This means that raw underlying memory stored in the ArrayBuffer

0 commit comments

Comments
 (0)