Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async loadTextFromUser(userId) {
const response = await this.serverApi.getUserData(userId);
if (response.status === 404) return '';
const encryptedText = await response.text();
const encryptedData = fromBase64(encryptedText);
const clear = await this.tanker.decrypt(encryptedData);
return clear;
}
onDecrypt = async () => {
try {
this.log('decryption', this.state.encryptedText);
const binary = fromBase64(this.state.encryptedText, { timeout: 1000 });
const clear = await this.tanker.decrypt(binary);
this.setState({
clearText: clear,
encryptedText: ''
});
this.log('decryptionSuccess', clear);
} catch (e) {
this.log(e);
}
}