SHA256
Очистить устаревший черновик регистрации
This commit is contained in:
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
client.version=1.20.50
|
client.version=1.20.51
|
||||||
server.version=1.16.26
|
server.version=1.16.26
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
authService,
|
authService,
|
||||||
authorizeSession,
|
authorizeSession,
|
||||||
clearAuthMessages,
|
clearAuthMessages,
|
||||||
|
resetRegistrationFlow,
|
||||||
consumeAuthReturnPage,
|
consumeAuthReturnPage,
|
||||||
refreshSessions,
|
refreshSessions,
|
||||||
setAuthBusy,
|
setAuthBusy,
|
||||||
@@ -157,14 +158,7 @@ export function render({ navigate }) {
|
|||||||
state.loginDraft.password = '';
|
state.loginDraft.password = '';
|
||||||
state.loginDraft.passwordMode = 'single';
|
state.loginDraft.passwordMode = 'single';
|
||||||
state.loginDraft.passwordWords = emptyPasswordWords();
|
state.loginDraft.passwordWords = emptyPasswordWords();
|
||||||
state.registrationDraft.flowType = '';
|
resetRegistrationFlow();
|
||||||
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;
|
|
||||||
|
|
||||||
await refreshSessions();
|
await refreshSessions();
|
||||||
setAuthInfo(t('screens.login_password_view.text_010', { value1: result.login }));
|
setAuthInfo(t('screens.login_password_view.text_010', { value1: result.login }));
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { createTopBar } from '../components/topbar.js';
|
|||||||
import { createVisiblePasswordField } from '../components/visible-password-field.js';
|
import { createVisiblePasswordField } from '../components/visible-password-field.js';
|
||||||
import { confirmPasswordBoundarySpaces } from '../services/password-boundary-warning.js';
|
import { confirmPasswordBoundarySpaces } from '../services/password-boundary-warning.js';
|
||||||
import { createRegistrationStepper } from '../components/registration-stepper.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 { PASSWORD_MAX_LENGTH } from '../services/password-words.js';
|
||||||
import { getRegistrationNamespaces, checkRegistrationLogin } from '../services/registration-v2-api.js';
|
import { getRegistrationNamespaces, checkRegistrationLogin } from '../services/registration-v2-api.js';
|
||||||
import { normalizeFullLogin } from '../services/shine-namespace-service.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 (Number(available.currencyCode ?? 1) !== 1 || Number(ns.currencyCode ?? 1) !== 1) throw new Error(t('screens.register_view.text_025'));
|
||||||
if (draft.login !== login) {
|
if (draft.login !== login) {
|
||||||
if (!confirmFundedWalletChange()) return;
|
if (!confirmFundedWalletChange()) return;
|
||||||
state.registrationPayment.walletAddress = '';
|
clearRegistrationDraft({ preserveFlowType: true });
|
||||||
state.registrationPayment.balanceSOL = '0.0000';
|
|
||||||
draft.preGeneratedKeyBundle = null;
|
|
||||||
draft.challengeId = '';
|
|
||||||
draft.challengeExpiresAtMs = 0;
|
|
||||||
}
|
}
|
||||||
draft.login = login;
|
draft.login = login;
|
||||||
draft.namespaceFeeLamports = String(available.registrationFeeLamports ?? ns.registrationFeeLamports ?? 0);
|
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 (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 && !confirmFundedWalletChange()) return;
|
||||||
if (draft.password && draft.password !== value) {
|
if (draft.password && draft.password !== value) {
|
||||||
state.registrationPayment.walletAddress = '';
|
clearRegistrationDraft({
|
||||||
state.registrationPayment.balanceSOL = '0.0000';
|
preserveFlowType: true,
|
||||||
draft.challengeId = '';
|
preserveLogin: true,
|
||||||
draft.challengeExpiresAtMs = 0;
|
preserveNamespace: true,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
const revision = inputRevision;
|
const revision = inputRevision;
|
||||||
const thisRequest = ++requestId;
|
const thisRequest = ++requestId;
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
import { t } from '../i18n/index.js';
|
import { t } from '../i18n/index.js';
|
||||||
import { createTopBar } from '../components/topbar.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 const pageMeta = { id: 'registration-choice-view', get title() { return t('screens.registration_choice_view.text_001'); }, showAppChrome: false };
|
||||||
|
|
||||||
export function render({ navigate }) {
|
export function render({ navigate }) {
|
||||||
|
// Экран выбора начинает новую регистрацию. Старый незавершённый черновик
|
||||||
|
// нельзя переносить в новый сценарий, особенно после неудачной попытки.
|
||||||
|
resetRegistrationFlow();
|
||||||
const screen = document.createElement('section');
|
const screen = document.createElement('section');
|
||||||
screen.className = 'stack registration-screen signup-choice';
|
screen.className = 'stack registration-screen signup-choice';
|
||||||
const title = document.createElement('h1');
|
const title = document.createElement('h1');
|
||||||
@@ -45,15 +48,6 @@ export function render({ navigate }) {
|
|||||||
action.textContent = button;
|
action.textContent = button;
|
||||||
action.addEventListener('click', () => {
|
action.addEventListener('click', () => {
|
||||||
const draft = state.registrationDraft;
|
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.flowType = type;
|
||||||
draft.uiStep = 1;
|
draft.uiStep = 1;
|
||||||
navigate('register-view');
|
navigate('register-view');
|
||||||
|
|||||||
@@ -140,22 +140,9 @@ export async function completeRegistrationLogin({ navigate, keyBundle }) {
|
|||||||
state.loginDraft.passwordMode = 'single';
|
state.loginDraft.passwordMode = 'single';
|
||||||
state.loginDraft.passwordWords = EMPTY_PASSWORD_WORDS.slice();
|
state.loginDraft.passwordWords = EMPTY_PASSWORD_WORDS.slice();
|
||||||
|
|
||||||
state.registrationSuccess = { flowType: state.registrationDraft.flowType, login: resumedLogin };
|
const completedFlowType = state.registrationDraft.flowType;
|
||||||
state.registrationDraft.flowType = '';
|
resetRegistrationFlow();
|
||||||
state.registrationDraft.password = '';
|
state.registrationSuccess = { flowType: completedFlowType, login: resumedLogin };
|
||||||
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';
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await refreshSessions();
|
await refreshSessions();
|
||||||
|
|||||||
+51
-27
@@ -29,6 +29,31 @@ const INVALID_SESSION_CODES = new Set([
|
|||||||
'SESSION_OF_ANOTHER_USER',
|
'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() {
|
function isLocalPreviewHost() {
|
||||||
const host = String(window.location.hostname || '').toLowerCase();
|
const host = String(window.location.hostname || '').toLowerCase();
|
||||||
return host === 'localhost' || host === '127.0.0.1' || host === '::1';
|
return host === 'localhost' || host === '127.0.0.1' || host === '::1';
|
||||||
@@ -458,28 +483,7 @@ function createInitialState({ withStoredSession = true } = {}) {
|
|||||||
tools: normalizeToolsSettings(storedEntrySettings?.tools),
|
tools: normalizeToolsSettings(storedEntrySettings?.tools),
|
||||||
},
|
},
|
||||||
registrationSuccess: null,
|
registrationSuccess: null,
|
||||||
registrationDraft: {
|
registrationDraft: createEmptyRegistrationDraft(),
|
||||||
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,
|
|
||||||
},
|
|
||||||
registrationHelp: {
|
registrationHelp: {
|
||||||
selectedTopic: 'keys-storage',
|
selectedTopic: 'keys-storage',
|
||||||
},
|
},
|
||||||
@@ -1200,11 +1204,31 @@ export async function refreshSessions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function resetRegistrationFlow() {
|
export function resetRegistrationFlow() {
|
||||||
const next = createInitialState();
|
clearRegistrationDraft();
|
||||||
state.registrationDraft = next.registrationDraft;
|
state.registrationSuccess = null;
|
||||||
state.registrationSuccess = next.registrationSuccess;
|
state.registrationHelp = { selectedTopic: 'keys-storage' };
|
||||||
state.registrationHelp = next.registrationHelp;
|
}
|
||||||
state.registrationPayment = next.registrationPayment;
|
|
||||||
|
/**
|
||||||
|
* Очищает временные данные регистрации, не затрагивая сохранённые профили и
|
||||||
|
* ключи уже авторизованных пользователей. При смене логина/пароля старые
|
||||||
|
* 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() {
|
function resetStateForSignedOut() {
|
||||||
|
|||||||
@@ -83,6 +83,9 @@ async function simulateCompletion({ headerFails = false } = {}) {
|
|||||||
authorizeSession: ({ login }) => calls.push(['authorized', login]),
|
authorizeSession: ({ login }) => calls.push(['authorized', login]),
|
||||||
refreshSessions: async () => calls.push(['refreshed']),
|
refreshSessions: async () => calls.push(['refreshed']),
|
||||||
setAuthInfo: () => calls.push(['info']),
|
setAuthInfo: () => calls.push(['info']),
|
||||||
|
resetRegistrationFlow: () => {
|
||||||
|
state.registrationDraft.password = '';
|
||||||
|
},
|
||||||
console: { warn: (...args) => calls.push(['warning', ...args]) },
|
console: { warn: (...args) => calls.push(['warning', ...args]) },
|
||||||
};
|
};
|
||||||
const func = vm.runInNewContext(`async function completeRegistrationLogin${finish}\ncompleteRegistrationLogin`, context);
|
const func = vm.runInNewContext(`async function completeRegistrationLogin${finish}\ncompleteRegistrationLogin`, context);
|
||||||
|
|||||||
Reference in New Issue
Block a user