caterium-app/public/core/hotfix-v1763.js
pavlov346346-source 71d9cdc92e
Caterium v17.6.5 stability hardening
* Prepare v17.6.5 stability hardening patch

* Move v17.6.5 stability patch logic to script

* Fix v17.6.5 stability patch workflow

* Harden Caterium v17.6.5 stability

* Remove one-time v17.6.5 patch workflow

* Remove one-time v17.6.5 patch script

* Update static stability checks for v17.6.5

* Fix v17.6.5 E2E version expectation

* Update v17.6.5 E2E version expectation

* Remove one-time v17.6.5 test patch workflow

* Capture failing v17.6.5 E2E diagnostics

* Capture v17.6.5 E2E failures

* Make v17.6.5 stability E2E deterministic

* Make v17.6.5 E2E checks deterministic

* Remove one-time deterministic E2E workflow

* Remove one-time E2E diagnostic workflow

* Remove temporary E2E diagnostics

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-09-08 05:55:48 +03:00

72 lines
3.4 KiB
JavaScript

(()=>{
'use strict';
if(window.SunHotfixV1763)return;
const VERSION='17.6.3';
const $=id=>document.getElementById(id);
const esc=value=>window.SunSafe?.escapeHTML?window.SunSafe.escapeHTML(String(value??'')):String(value??'').replace(/[&<>"']/g,c=>({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c]));
let checkingGate=false;
function patchDeveloperOpen(){
const dev=window.SunDeveloperV22;
if(!dev||dev.__sunV1763SafeOpen||typeof dev.open!=='function')return false;
const original=dev.open.bind(dev);
dev.open=(source=null)=>original(source instanceof HTMLElement?source:null);
Object.defineProperty(dev,'__sunV1763SafeOpen',{value:true,configurable:true});
return true;
}
async function platformAdmin(){
const dev=window.SunDeveloperV22,cloud=window.SunCloudV2;
if(!dev||!cloud?.getSession?.()?.user)return false;
if(dev.isPlatformAdmin?.()===true)return true;
try{return await dev.checkPlatformAdmin?.(false)===true}catch(_){return false}
}
async function enhanceDeveloperGate(){
if(checkingGate)return false;
const cloud=window.SunCloudV2,dev=window.SunDeveloperV22;
if(!cloud||!dev)return false;
const session=cloud.getSession?.(),workspace=cloud.getWorkspace?.();
if(!session?.user||workspace)return false;
checkingGate=true;
try{
if(!await platformAdmin())return false;
const gate=$('sunCloudAuthGateV3'),card=gate?.querySelector('.sun-cloud-auth-card');
if(!gate||!card)return false;
if(card.dataset.dev1763==='1')return true;
gate.dataset.saasEnhanced='1';
card.dataset.devEnhanced='1';
card.dataset.dev1763='1';
card.innerHTML=`<div class="sun-cloud-auth-brand"><img src="caterium-login-logo.png" alt="Caterium"><div><h2>Аккаунт разработчика</h2><div class="hint">${esc(session.user.email||'')}</div></div></div><p class="hint">Этот аккаунт управляет платформой и не обязан иметь собственную рабочую компанию.</p><div class="sun-cloud-auth-actions"><button class="primary" type="button" data-open-dev-v1763>Открыть кабинет разработчика</button><button class="outline" type="button" data-signout-v1763>Выйти</button></div><div class="sun-cloud-auth-error" id="sunDevGateStatusV1763"></div>`;
card.querySelector('[data-open-dev-v1763]')?.addEventListener('click',()=>{patchDeveloperOpen();dev.open?.();});
card.querySelector('[data-signout-v1763]')?.addEventListener('click',()=>cloud.signOut?.());
return true;
}finally{checkingGate=false;}
}
function interceptSaasAdmin(event){
const button=event.target?.closest?.('[data-saas-admin]');
if(!button)return;
const dev=window.SunDeveloperV22;
if(!dev)return;
event.preventDefault();
event.stopImmediatePropagation();
patchDeveloperOpen();
dev.open?.();
}
function maintain(){
patchDeveloperOpen();
enhanceDeveloperGate().catch(()=>{});
}
document.addEventListener('click',interceptSaasAdmin,true);
window.addEventListener('sun:cloud-permissions-changed',()=>setTimeout(maintain,0));
window.addEventListener('sun:cloud-state-applied',()=>setTimeout(maintain,0));
setTimeout(maintain,0);
setInterval(()=>{if(!document.hidden)maintain();},10000);
window.SunHotfixV1763={VERSION,patchDeveloperOpen,enhanceDeveloperGate};
})();