From 102feccb2edd0191285055f8561bd38e57ebc8a1e081be06c8866b99d1db5fca Mon Sep 17 00:00:00 2001 From: AidarKC Date: Mon, 16 Nov 2026 10:59:27 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=87=D0=B8=D1=81=D1=82=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20=D1=83=D1=81=D1=82=D0=B0=D1=80=D0=B5=D0=B2=D1=88=D0=B8?= =?UTF-8?q?=D0=B9=20=D1=87=D0=B5=D1=80=D0=BD=D0=BE=D0=B2=D0=B8=D0=BA=20?= =?UTF-8?q?=D1=80=D0=B5=D0=B3=D0=B8=D1=81=D1=82=D1=80=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VERSION.properties | 2 +- shine-UI/js/pages/login-password-view.js | 10 +-- shine-UI/js/pages/register-view.js | 17 ++-- shine-UI/js/pages/registration-choice-view.js | 14 +--- .../js/pages/registration-payment-view.js | 19 +---- shine-UI/js/state.js | 78 ++++++++++++------- .../registration-header-bootstrap.test.mjs | 3 + 7 files changed, 71 insertions(+), 72 deletions(-) diff --git a/VERSION.properties b/VERSION.properties index f05d4da2..fd5e366a 100644 --- a/VERSION.properties +++ b/VERSION.properties @@ -1,2 +1,2 @@ -client.version=1.20.50 +client.version=1.20.51 server.version=1.16.26 diff --git a/shine-UI/js/pages/login-password-view.js b/shine-UI/js/pages/login-password-view.js index 92542992..2789b846 100644 --- a/shine-UI/js/pages/login-password-view.js +++ b/shine-UI/js/pages/login-password-view.js @@ -5,6 +5,7 @@ import { authService, authorizeSession, clearAuthMessages, + resetRegistrationFlow, consumeAuthReturnPage, refreshSessions, setAuthBusy, @@ -157,14 +158,7 @@ export function render({ navigate }) { state.loginDraft.password = ''; state.loginDraft.passwordMode = 'single'; state.loginDraft.passwordWords = emptyPasswordWords(); - state.registrationDraft.flowType = ''; - state.registrationDraft.password = ''; - state.registrationDraft.passwordMode = 'single'; - state.registrationDraft.passwordWords = emptyPasswordWords(); - state.registrationDraft.storagePwd = ''; - state.registrationDraft.sessionId = ''; - state.registrationDraft.pendingKeyBundle = null; - state.registrationDraft.pendingSessionMaterial = null; + resetRegistrationFlow(); await refreshSessions(); setAuthInfo(t('screens.login_password_view.text_010', { value1: result.login })); diff --git a/shine-UI/js/pages/register-view.js b/shine-UI/js/pages/register-view.js index 5d761c3b..33a0b2ec 100644 --- a/shine-UI/js/pages/register-view.js +++ b/shine-UI/js/pages/register-view.js @@ -3,7 +3,7 @@ import { createTopBar } from '../components/topbar.js'; import { createVisiblePasswordField } from '../components/visible-password-field.js'; import { confirmPasswordBoundarySpaces } from '../services/password-boundary-warning.js'; import { createRegistrationStepper } from '../components/registration-stepper.js'; -import { authService, clearAuthMessages, state } from '../state.js'; +import { authService, clearAuthMessages, clearRegistrationDraft, state } from '../state.js'; import { PASSWORD_MAX_LENGTH } from '../services/password-words.js'; import { getRegistrationNamespaces, checkRegistrationLogin } from '../services/registration-v2-api.js'; import { normalizeFullLogin } from '../services/shine-namespace-service.js'; @@ -118,11 +118,7 @@ export function render({ navigate }) { if (Number(available.currencyCode ?? 1) !== 1 || Number(ns.currencyCode ?? 1) !== 1) throw new Error(t('screens.register_view.text_025')); if (draft.login !== login) { if (!confirmFundedWalletChange()) return; - state.registrationPayment.walletAddress = ''; - state.registrationPayment.balanceSOL = '0.0000'; - draft.preGeneratedKeyBundle = null; - draft.challengeId = ''; - draft.challengeExpiresAtMs = 0; + clearRegistrationDraft({ preserveFlowType: true }); } draft.login = login; draft.namespaceFeeLamports = String(available.registrationFeeLamports ?? ns.registrationFeeLamports ?? 0); @@ -184,10 +180,11 @@ export function render({ navigate }) { if (warningRevision !== inputRevision || input.value !== value) { status.textContent = t('screens.register_view.text_012'); return; } if (draft.password && draft.password !== value && !confirmFundedWalletChange()) return; if (draft.password && draft.password !== value) { - state.registrationPayment.walletAddress = ''; - state.registrationPayment.balanceSOL = '0.0000'; - draft.challengeId = ''; - draft.challengeExpiresAtMs = 0; + clearRegistrationDraft({ + preserveFlowType: true, + preserveLogin: true, + preserveNamespace: true, + }); } const revision = inputRevision; const thisRequest = ++requestId; diff --git a/shine-UI/js/pages/registration-choice-view.js b/shine-UI/js/pages/registration-choice-view.js index afcd9f6a..a4349ddc 100644 --- a/shine-UI/js/pages/registration-choice-view.js +++ b/shine-UI/js/pages/registration-choice-view.js @@ -1,10 +1,13 @@ import { t } from '../i18n/index.js'; import { createTopBar } from '../components/topbar.js'; -import { state } from '../state.js'; +import { resetRegistrationFlow, state } from '../state.js'; export const pageMeta = { id: 'registration-choice-view', get title() { return t('screens.registration_choice_view.text_001'); }, showAppChrome: false }; export function render({ navigate }) { + // Экран выбора начинает новую регистрацию. Старый незавершённый черновик + // нельзя переносить в новый сценарий, особенно после неудачной попытки. + resetRegistrationFlow(); const screen = document.createElement('section'); screen.className = 'stack registration-screen signup-choice'; const title = document.createElement('h1'); @@ -45,15 +48,6 @@ export function render({ navigate }) { action.textContent = button; action.addEventListener('click', () => { const draft = state.registrationDraft; - if (draft.flowType !== type) { - // При смене namespace старые ключи/коды больше не соответствуют выбранному аккаунту. - draft.login = ''; - draft.password = ''; - draft.preGeneratedKeyBundle = null; - draft.challengeId = ''; - draft.challengeExpiresAtMs = 0; - draft.email = ''; - } draft.flowType = type; draft.uiStep = 1; navigate('register-view'); diff --git a/shine-UI/js/pages/registration-payment-view.js b/shine-UI/js/pages/registration-payment-view.js index 67d9007a..02df39a4 100644 --- a/shine-UI/js/pages/registration-payment-view.js +++ b/shine-UI/js/pages/registration-payment-view.js @@ -140,22 +140,9 @@ export async function completeRegistrationLogin({ navigate, keyBundle }) { state.loginDraft.passwordMode = 'single'; state.loginDraft.passwordWords = EMPTY_PASSWORD_WORDS.slice(); - state.registrationSuccess = { flowType: state.registrationDraft.flowType, login: resumedLogin }; - state.registrationDraft.flowType = ''; - state.registrationDraft.password = ''; - state.registrationDraft.passwordMode = 'single'; - state.registrationDraft.passwordWords = EMPTY_PASSWORD_WORDS.slice(); - state.registrationDraft.passwordWordsLinked = false; - state.registrationDraft.usePromoCode = false; - state.registrationDraft.promoCode = ''; - state.registrationDraft.storagePwd = ''; - state.registrationDraft.sessionId = ''; - state.registrationDraft.pendingKeyBundle = null; - state.registrationDraft.pendingSessionMaterial = null; - state.registrationDraft.preGeneratedKeyBundle = null; - - state.registrationPayment.walletAddress = ''; - state.registrationPayment.balanceSOL = '0.0000'; + const completedFlowType = state.registrationDraft.flowType; + resetRegistrationFlow(); + state.registrationSuccess = { flowType: completedFlowType, login: resumedLogin }; try { await refreshSessions(); diff --git a/shine-UI/js/state.js b/shine-UI/js/state.js index 28138fc1..8fd34007 100644 --- a/shine-UI/js/state.js +++ b/shine-UI/js/state.js @@ -29,6 +29,31 @@ const INVALID_SESSION_CODES = new Set([ 'SESSION_OF_ANOTHER_USER', ]); +function createEmptyRegistrationDraft() { + return { + uiStep: 1, + flowType: '', + namespaceFeeLamports: '', + namespaceServerLogin: '', + email: '', + challengeId: '', + challengeExpiresAtMs: 0, + dataItemId: '', + login: '', + password: '', + passwordMode: 'single', + passwordWords: emptyPasswordWords(), + passwordWordsLinked: false, + usePromoCode: false, + promoCode: '', + sessionId: '', + storagePwd: '', + pendingKeyBundle: null, + pendingSessionMaterial: null, + preGeneratedKeyBundle: null, + }; +} + function isLocalPreviewHost() { const host = String(window.location.hostname || '').toLowerCase(); return host === 'localhost' || host === '127.0.0.1' || host === '::1'; @@ -458,28 +483,7 @@ function createInitialState({ withStoredSession = true } = {}) { tools: normalizeToolsSettings(storedEntrySettings?.tools), }, registrationSuccess: null, - registrationDraft: { - uiStep: 1, - flowType: '', - namespaceFeeLamports: '', - namespaceServerLogin: '', - email: '', - challengeId: '', - challengeExpiresAtMs: 0, - dataItemId: '', - login: '', - password: '', - passwordMode: 'single', - passwordWords: emptyPasswordWords(), - passwordWordsLinked: false, - usePromoCode: false, - promoCode: '', - sessionId: '', - storagePwd: '', - pendingKeyBundle: null, - pendingSessionMaterial: null, - preGeneratedKeyBundle: null, - }, + registrationDraft: createEmptyRegistrationDraft(), registrationHelp: { selectedTopic: 'keys-storage', }, @@ -1200,11 +1204,31 @@ export async function refreshSessions() { } export function resetRegistrationFlow() { - const next = createInitialState(); - state.registrationDraft = next.registrationDraft; - state.registrationSuccess = next.registrationSuccess; - state.registrationHelp = next.registrationHelp; - state.registrationPayment = next.registrationPayment; + clearRegistrationDraft(); + state.registrationSuccess = null; + state.registrationHelp = { selectedTopic: 'keys-storage' }; +} + +/** + * Очищает временные данные регистрации, не затрагивая сохранённые профили и + * ключи уже авторизованных пользователей. При смене логина/пароля старые + * challenge, dataItemId и производные ключи больше не должны переиспользоваться. + */ +export function clearRegistrationDraft({ + preserveFlowType = false, + preserveLogin = false, + preserveNamespace = false, +} = {}) { + const draft = state.registrationDraft; + const preserved = { + flowType: preserveFlowType ? draft.flowType : '', + login: preserveLogin ? draft.login : '', + namespaceFeeLamports: preserveNamespace ? draft.namespaceFeeLamports : '', + namespaceServerLogin: preserveNamespace ? draft.namespaceServerLogin : '', + }; + Object.assign(draft, createEmptyRegistrationDraft(), preserved); + state.registrationPayment.walletAddress = ''; + state.registrationPayment.balanceSOL = '0.0000'; } function resetStateForSignedOut() { diff --git a/shine-UI/tests/registration-header-bootstrap.test.mjs b/shine-UI/tests/registration-header-bootstrap.test.mjs index bd590854..7f1e5889 100644 --- a/shine-UI/tests/registration-header-bootstrap.test.mjs +++ b/shine-UI/tests/registration-header-bootstrap.test.mjs @@ -83,6 +83,9 @@ async function simulateCompletion({ headerFails = false } = {}) { authorizeSession: ({ login }) => calls.push(['authorized', login]), refreshSessions: async () => calls.push(['refreshed']), setAuthInfo: () => calls.push(['info']), + resetRegistrationFlow: () => { + state.registrationDraft.password = ''; + }, console: { warn: (...args) => calls.push(['warning', ...args]) }, }; const func = vm.runInNewContext(`async function completeRegistrationLogin${finish}\ncompleteRegistrationLogin`, context);