SHA256
Добавить кошелек блокчейна и озвучивание агента
This commit is contained in:
@@ -852,16 +852,26 @@ export class AuthService {
|
||||
const cleanLogin = (login || '').trim();
|
||||
if (!cleanLogin) throw new Error('Введите логин');
|
||||
|
||||
const user = await this.getUser(cleanLogin);
|
||||
if (!user.exists) throw new Error('Пользователь не найден');
|
||||
|
||||
const keyBundle = await this.derivePasswordKeyBundle(cleanLogin, password);
|
||||
const session = await this.createAuthSession(cleanLogin, keyBundle);
|
||||
return { ...session, keyBundle };
|
||||
}
|
||||
|
||||
async persistSelectedKeys(login, storagePwd, keyBundle, saveOptions = { saveRoot: true, saveBlockchain: true }) {
|
||||
const secrets = { deviceKey: keyBundle.devicePair.privatePkcs8B64 };
|
||||
let currentSecrets = {};
|
||||
try {
|
||||
const loaded = await loadEncryptedUserSecrets(login, storagePwd);
|
||||
if (loaded && typeof loaded === 'object') {
|
||||
currentSecrets = loaded;
|
||||
}
|
||||
} catch {
|
||||
// Если контейнера ещё нет или пароль новый для этого логина — создадим новый ниже.
|
||||
}
|
||||
|
||||
const secrets = {
|
||||
...currentSecrets,
|
||||
deviceKey: keyBundle.devicePair.privatePkcs8B64,
|
||||
};
|
||||
if (saveOptions.saveRoot) secrets.rootKey = keyBundle.rootPair.privatePkcs8B64;
|
||||
if (saveOptions.saveBlockchain) secrets.blockchainKey = keyBundle.blockchainPair.privatePkcs8B64;
|
||||
await saveEncryptedUserSecrets(login, storagePwd, secrets);
|
||||
|
||||
Reference in New Issue
Block a user