SHA256
Регистрация: бесплатная регистрация работает
This commit is contained in:
@@ -27,7 +27,7 @@ export function render({navigate}) {
|
||||
const methodLabel=document.createElement('label');methodLabel.className='stack'; methodLabel.textContent='Способ регистрации';methodLabel.append(method);
|
||||
const pwLabel=document.createElement('label');pwLabel.className='stack';pwLabel.textContent='Пароль (ключи остаются только у вас)';pwLabel.append(password);
|
||||
form.append(methodLabel,nsLabel,local,full,pwLabel,status,action);
|
||||
let namespaces=[]; let disposed=false; let request=0;
|
||||
let namespaces=[]; let disposed=false; let inputRevision=0; let submission=0;
|
||||
const feeToSol = fee => (Number(fee || '0')/1e9).toFixed(6);
|
||||
function selected() { return namespaces.find(n=>n.name===namespace.value); }
|
||||
function display() {
|
||||
@@ -45,9 +45,11 @@ export function render({navigate}) {
|
||||
}
|
||||
function showFull() {
|
||||
full.textContent=namespace.value?`Полное имя: ${local.value.trim()}@${namespace.value}`:'Нет доступных namespace этого типа';
|
||||
status.textContent='';request++;
|
||||
status.textContent='';
|
||||
}
|
||||
method.addEventListener('change',display);namespace.addEventListener('change',showFull);local.addEventListener('input',showFull);
|
||||
method.addEventListener('change',()=>{inputRevision++;display();});
|
||||
namespace.addEventListener('change',()=>{inputRevision++;showFull();});
|
||||
local.addEventListener('input',()=>{inputRevision++;showFull();});
|
||||
void getRegistrationNamespaces().then(data=>{
|
||||
if(disposed)return;namespaces=Array.isArray(data.namespaces)?data.namespaces:[];display();
|
||||
if(!namespaces.length)status.textContent='Solana namespace ещё не синхронизированы с сервером';
|
||||
@@ -60,11 +62,13 @@ export function render({navigate}) {
|
||||
if(local.value.trim().length < Number(ns.minLocalLength))throw new Error(`Логин не короче ${ns.minLocalLength} символов`);
|
||||
if(!password.value || password.value.length>PASSWORD_MAX_LENGTH)throw new Error('Введите непустой пароль допустимой длины');
|
||||
}catch(error){status.textContent=error.message;return;}
|
||||
const thisRun=++request;
|
||||
const thisRun=++submission;
|
||||
const thisInputRevision=inputRevision;
|
||||
action.disabled=true;status.textContent='Проверяем выбранный логин…';
|
||||
try {
|
||||
const check=await checkRegistrationLogin(login);
|
||||
if(disposed || thisRun!==request)return;
|
||||
if(disposed || thisRun!==submission)return;
|
||||
if(thisInputRevision!==inputRevision)throw new Error('Данные формы изменились. Проверьте их и повторите попытку.');
|
||||
if(!check.loginAvailable)throw new Error('Этот логин уже занят');
|
||||
if(Number(check.namespaceType)!==Number(method.value))throw new Error('Тип namespace изменился. Обновите список.');
|
||||
const draft=state.registrationDraft;
|
||||
@@ -73,13 +77,17 @@ export function render({navigate}) {
|
||||
draft.namespaceFeeLamports=String(check.registrationFeeLamports||ns.registrationFeeLamports);
|
||||
draft.namespaceServerLogin=ns.defaultServerLogin||'';
|
||||
if(changed)draft.preGeneratedKeyBundle=null;
|
||||
if(draft.flowType==='free') {
|
||||
navigate('registration-email-view');
|
||||
return;
|
||||
}
|
||||
status.textContent='Создаём ключи локально (Argon2id)…';
|
||||
const bundle=draft.preGeneratedKeyBundle || await authService.derivePasswordKeyBundle(login,password.value);
|
||||
if(disposed || thisRun!==request)return;
|
||||
if(disposed || thisRun!==submission)return;
|
||||
draft.preGeneratedKeyBundle=bundle;
|
||||
navigate(draft.flowType==='free'?'registration-email-view':'registration-payment-view');
|
||||
}catch(error){if(!disposed && thisRun===request)status.textContent=error.message;}
|
||||
finally {action.disabled=false;}
|
||||
navigate('registration-payment-view');
|
||||
}catch(error){if(!disposed && thisRun===submission)status.textContent=error.message || 'Не удалось продолжить регистрацию.';}
|
||||
finally {if(thisRun===submission)action.disabled=false;}
|
||||
});
|
||||
screen.append(createTopBar({title:'Регистрация',back:{label:'←',onClick:()=>{resetRegistrationFlow();navigate('start-view');}}}),form);
|
||||
return screen;
|
||||
|
||||
Reference in New Issue
Block a user