SHA256
Auth/UI: Argon2id derivation для login/register + блок Расширенные
This commit is contained in:
@@ -556,11 +556,12 @@ export class AuthService {
|
||||
return payload.exists !== true;
|
||||
}
|
||||
|
||||
async derivePasswordKeyBundle(password) {
|
||||
async derivePasswordKeyBundle(login, password) {
|
||||
const normalizedLogin = String(login ?? '');
|
||||
const normalizedPassword = String(password ?? '');
|
||||
const rootPair = await deriveEd25519FromPassword(normalizedPassword, 'root.key');
|
||||
const blockchainPair = await deriveEd25519FromPassword(normalizedPassword, 'bch.key');
|
||||
const devicePair = await deriveEd25519FromPassword(normalizedPassword, 'dev.key');
|
||||
const rootPair = await deriveEd25519FromPassword(normalizedPassword, 'root.key', { login: normalizedLogin });
|
||||
const blockchainPair = await deriveEd25519FromPassword(normalizedPassword, 'bch.key', { login: normalizedLogin });
|
||||
const devicePair = await deriveEd25519FromPassword(normalizedPassword, 'dev.key', { login: normalizedLogin });
|
||||
return { rootPair, blockchainPair, devicePair };
|
||||
}
|
||||
|
||||
@@ -617,7 +618,7 @@ export class AuthService {
|
||||
const isFree = await this.ensureLoginFree(cleanLogin);
|
||||
if (!isFree) throw new Error('Этот логин уже занят');
|
||||
|
||||
const keyBundle = await this.derivePasswordKeyBundle(password);
|
||||
const keyBundle = await this.derivePasswordKeyBundle(cleanLogin, password);
|
||||
|
||||
const addResp = await this.ws.request('AddUser', {
|
||||
login: cleanLogin,
|
||||
@@ -640,7 +641,7 @@ export class AuthService {
|
||||
const user = await this.getUser(cleanLogin);
|
||||
if (!user.exists) throw new Error('Пользователь не найден');
|
||||
|
||||
const keyBundle = await this.derivePasswordKeyBundle(password);
|
||||
const keyBundle = await this.derivePasswordKeyBundle(cleanLogin, password);
|
||||
const session = await this.createAuthSession(cleanLogin, keyBundle);
|
||||
return { ...session, keyBundle };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user