Unit test fixes
This commit is contained in:
@@ -24,7 +24,7 @@ export default class packet {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
buffer = null;
|
||||
buffer = new Uint8Array(0);
|
||||
decode_offset = 0;
|
||||
token;
|
||||
|
||||
@@ -180,9 +180,11 @@ export default class packet {
|
||||
...this.buffer.slice(nonce.length + mac.length),
|
||||
...this.buffer.slice(nonce.length, nonce.length + mac.length),
|
||||
]);
|
||||
this.buffer = Buffer.from(
|
||||
new XChaCha20Poly1305(key).open(nonce, this.buffer, aad)
|
||||
);
|
||||
const result = new XChaCha20Poly1305(key).open(nonce, this.buffer, aad);
|
||||
if (!result) {
|
||||
throw new Error('decryption failed');
|
||||
}
|
||||
this.buffer = Buffer.from(result);
|
||||
}
|
||||
|
||||
this.buffer = new Uint8Array(this.buffer);
|
||||
|
||||
Reference in New Issue
Block a user