Add Android app: phone UI for hosts, SSH terminal with extra key row, keys, snippets, LAN sync and app lock (password + fingerprint), reusing the desktop Node modules via capacitor-nodejs; APKs per ABI in releases for Obtainium
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
// Ersatz für die von store.js genutzten Electron-APIs unter Android.
|
||||
// safeStorage verschlüsselt mit einem 256-Bit-Schlüssel, den die App im Android Keystore verpackt aufbewahrt
|
||||
// und beim Start als MRTERM_VAULT_KEY (base64) an den Node-Prozess übergibt.
|
||||
const crypto = require('crypto');
|
||||
|
||||
const dataDir = () => process.env.DATADIR || require('bridge').getDataPath();
|
||||
const key = () => {
|
||||
const k = Buffer.from(process.env.MRTERM_VAULT_KEY || '', 'base64');
|
||||
return k.length === 32 ? k : null;
|
||||
};
|
||||
|
||||
const safeStorage = {
|
||||
isEncryptionAvailable: () => !!key(),
|
||||
encryptString(plain) {
|
||||
const iv = crypto.randomBytes(12);
|
||||
const c = crypto.createCipheriv('aes-256-gcm', key(), iv);
|
||||
const ct = Buffer.concat([c.update(String(plain), 'utf8'), c.final()]);
|
||||
return Buffer.concat([iv, c.getAuthTag(), ct]);
|
||||
},
|
||||
decryptString(buf) {
|
||||
const d = crypto.createDecipheriv('aes-256-gcm', key(), buf.subarray(0, 12));
|
||||
d.setAuthTag(buf.subarray(12, 28));
|
||||
return Buffer.concat([d.update(buf.subarray(28)), d.final()]).toString('utf8');
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
app: { getPath: () => dataDir(), getVersion: () => process.env.MRTERM_VERSION || '0.0.0', getLocale: () => process.env.MRTERM_LOCALE || 'en' },
|
||||
safeStorage,
|
||||
};
|
||||
Reference in New Issue
Block a user