{_('The following keys use an out-dated encryption algorithm and it is recommended to upgrade them. The upgraded key will still be able to decrypt and encrypt your data as usual.')}
{_('ID')}
{_('Upgrade')}
{rows}
);
};
const renderReencryptData = () => {
if (!shim.isElectron()) return null;
if (!props.shouldReencrypt) return null;
const theme = themeStyle(props.themeId);
const buttonLabel = _('Re-encrypt data');
const intro = props.shouldReencrypt ? _('The default encryption method has been changed to a more secure one and it is recommended that you apply it to your data.') : _('You may use the tool below to re-encrypt your data, for example if you know that some of your notes are encrypted with an obsolete encryption method.');
let t = `${intro}\n\n${_('In order to do so, your entire data set will have to be encrypted and synchronised, so it is best to run it overnight.\n\nTo start, please follow these instructions:\n\n1. Synchronise all your devices.\n2. Click "%s".\n3. Let it run to completion. While it runs, avoid changing any note on your other devices, to avoid conflicts.\n4. Once sync is done on this device, sync all your other devices and let it run to completion.\n\nImportant: you only need to run this ONCE on one device.', buttonLabel)}`;
t = t.replace(/\n\n/g, '
{'Note: Only one key is going to be used for encryption (the one marked as "active"). Any of the keys might be used for decryption, depending on how the notes or notebooks were originally encrypted.'}
: null;
const tableComp = !showTable ? null : (
{_('Active')}
{_('ID')}
{_('Date')}
{_('Password')}
{_('Valid')}
{_('Actions')}
{mkComps}
);
if (mkComps.length) {
return (
{headerComp}
{tableComp}
{infoComp}
);
}
return null;
};
const onToggleButtonClick = useCallback(async () => {
const isEnabled = getEncryptionEnabled();
const newEnabled = !isEnabled;
const masterKey = getDefaultMasterKey();
const hasMasterPassword = !!props.masterPassword;
let newPassword = '';
if (isEnabled) {
const answer = await dialogs.confirm(_('Disabling encryption means *all* your notes and attachments are going to be re-synchronised and sent unencrypted to the sync target. Do you wish to continue?'));
if (!answer) return;
} else {
const msg = enableEncryptionConfirmationMessages(masterKey, hasMasterPassword);
newPassword = await dialogs.prompt(msg.join('\n\n'), '', '', { type: 'password' });
}
if (hasMasterPassword && newEnabled) {
if (!(await masterPasswordIsValid(newPassword))) {
alert('Invalid password. Please try again. If you have forgotten your password you will need to reset it.');
return;
}
}
try {
await toggleAndSetupEncryption(EncryptionService.instance(), newEnabled, masterKey, newPassword);
} catch (error) {
await dialogs.alert(error.message);
}
}, [props.masterPassword]);
const renderEncryptionSection = () => {
const decryptedItemsInfo =
{_('Your password is needed to decrypt some of your data.')} {_('Please click on "%s" to proceed, or set the passwords in the "%s" list below.', buttonTitle, _('Encryption keys'))}
);
};
const renderNonExistingMasterKeysSection = () => {
let nonExistingMasterKeySection = null;
const nonExistingMasterKeyIds = props.notLoadedMasterKeys.slice();
for (let i = 0; i < props.masterKeys.length; i++) {
const mk = props.masterKeys[i];
const idx = nonExistingMasterKeyIds.indexOf(mk.id);
if (idx >= 0) nonExistingMasterKeyIds.splice(idx, 1);
}
if (nonExistingMasterKeyIds.length) {
const rows = [];
for (let i = 0; i < nonExistingMasterKeyIds.length; i++) {
const id = nonExistingMasterKeyIds[i];
rows.push(
{id}
);
}
nonExistingMasterKeySection = (
{_('Missing keys')}
{_('The keys with these IDs are used to encrypt some of your items, however the application does not currently have access to them. It is likely they will eventually be downloaded via synchronisation.')}