Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function zeroize(object: Uint8Array | ArrayBuffer | Record | undefined): void {
if (object instanceof Uint8Array) {
sodium.memzero(object);
} else if (object instanceof ArrayBuffer) {
sodium.memzero(new Uint8Array(object));
} else if (typeof object === 'object') {
Object.keys(object)
.map(key => object[key])
.forEach(val => zeroize(val));
} else {
return;
}
}
function zeroize(object: Uint8Array | ArrayBuffer | Record | undefined): void {
if (object instanceof Uint8Array) {
sodium.memzero(object);
} else if (object instanceof ArrayBuffer) {
sodium.memzero(new Uint8Array(object));
} else if (typeof object === 'object') {
Object.keys(object)
.map(key => object[key])
.forEach(val => zeroize(val));
} else {
return;
}
}