diff --git a/VERSION.properties b/VERSION.properties index 6668702e..77b53ade 100644 --- a/VERSION.properties +++ b/VERSION.properties @@ -1,2 +1,2 @@ -client.version=1.20.83 +client.version=1.20.84 server.version=1.16.51 diff --git a/shine-UI/js/services/auth-service.js b/shine-UI/js/services/auth-service.js index 723d21d5..44d40312 100644 --- a/shine-UI/js/services/auth-service.js +++ b/shine-UI/js/services/auth-service.js @@ -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 }); diff --git a/shine-UI/tests/session-resume.test.mjs b/shine-UI/tests/session-resume.test.mjs new file mode 100644 index 00000000..fd2fb950 --- /dev/null +++ b/shine-UI/tests/session-resume.test.mjs @@ -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', + ); +});