SHA256
Исправить восстановление выбранной сессии
This commit is contained in:
+1
-1
@@ -1,2 +1,2 @@
|
||||
client.version=1.20.83
|
||||
client.version=1.20.84
|
||||
server.version=1.16.51
|
||||
|
||||
@@ -1314,12 +1314,13 @@ export class AuthService {
|
||||
const cleanLogin = (login || '').trim();
|
||||
if (!cleanLogin) throw new Error('Нет login для авто-входа');
|
||||
|
||||
const sessionMaterial = await loadSessionMaterial(cleanLogin, targetSessionId);
|
||||
const requestedSessionId = String(preferredSessionId || '').trim();
|
||||
const sessionMaterial = await loadSessionMaterial(cleanLogin, requestedSessionId);
|
||||
if (!sessionMaterial?.sessionId || !sessionMaterial?.sessionKey || !sessionMaterial?.sessionPrivPkcs8) {
|
||||
throw new Error('На устройстве нет сохраненного ключа сессии');
|
||||
}
|
||||
|
||||
const targetSessionId = preferredSessionId || sessionMaterial.sessionId;
|
||||
const targetSessionId = requestedSessionId || sessionMaterial.sessionId;
|
||||
const privateKey = await importPkcs8Ed25519(sessionMaterial.sessionPrivPkcs8);
|
||||
|
||||
const challengeResp = await this.ws.request('SessionChallenge', { sessionId: targetSessionId });
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import test from 'node:test';
|
||||
|
||||
const auth = readFileSync(new URL('../js/services/auth-service.js', import.meta.url), 'utf8');
|
||||
|
||||
test('resumeSession загружает материал до вычисления targetSessionId и поддерживает выбранную сессию', () => {
|
||||
const method = auth.match(/async resumeSessionUnlocked\(login, preferredSessionId = ''\) \{[\s\S]*?\n \}/)?.[0] || '';
|
||||
assert.ok(method, 'метод resumeSessionUnlocked должен существовать');
|
||||
assert.match(method, /const requestedSessionId = String\(preferredSessionId \|\| ''\)\.trim\(\);/);
|
||||
assert.match(method, /loadSessionMaterial\(cleanLogin, requestedSessionId\)/);
|
||||
assert.match(method, /const targetSessionId = requestedSessionId \|\| sessionMaterial\.sessionId;/);
|
||||
assert.ok(
|
||||
method.indexOf('loadSessionMaterial(cleanLogin, requestedSessionId)')
|
||||
< method.indexOf('const targetSessionId = requestedSessionId || sessionMaterial.sessionId;'),
|
||||
'session material должен загружаться до вычисления targetSessionId',
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user