From 5cd01a8d7b2bbf8987db8bb3495af78d3f3e949f Mon Sep 17 00:00:00 2001 From: unimatrixgit <95320811+unimatrixgit@users.noreply.github.com> Date: Mon, 16 Nov 2026 07:21:52 +0100 Subject: [PATCH] Fix Company CP artwork loading and responsive image bounds --- website/control-panel/public/cp-v2/cp-v2-company-shell.css | 5 ++++- website/control-panel/public/cp-v2/cp-v2-company-shell.mjs | 6 +++--- website/control-panel/server.mjs | 4 +++- website/tests/company-cp-shell.test.mjs | 3 +++ 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/website/control-panel/public/cp-v2/cp-v2-company-shell.css b/website/control-panel/public/cp-v2/cp-v2-company-shell.css index 64c87254..e966dfe2 100644 --- a/website/control-panel/public/cp-v2/cp-v2-company-shell.css +++ b/website/control-panel/public/cp-v2/cp-v2-company-shell.css @@ -1,6 +1,6 @@ .company-cp-shell{--guild-ink:#122c32;--guild-blue:#224650;--guild-gold:#d4b779;--guild-text:#eee4ca;background:#0b2026;color:var(--guild-text);font-family:Georgia,serif} .company-cp-shell .layout{grid-template-columns:230px minmax(0,1fr) 230px}.company-cp-shell .content{background:linear-gradient(#112a32ed,#0d2029f7),url('https://www.dunerealms.com/assets/political-imperial-chamber-v1.png') center/cover;color:var(--guild-text);min-width:0} -.company-cp-shell .side{background:linear-gradient(#14343ce8,#0c222aed),url('https://www.dunerealms.com/assets/corrino-charter-v2.png') center/cover;border-color:#a58b52}.company-cp-shell .side-hero{background:#173b45;color:#efd49b}.company-cp-shell .category-block{background:#18333b;border-color:#a58b52}.company-cp-shell .category-heading{background:#244854;color:#f0d9ac}.company-cp-shell .navitem{color:#e9dfc8;border-color:#a58b5255;text-decoration:none;position:relative}.company-cp-shell .navitem:hover,.company-cp-shell .navitem[aria-current=page]{background:linear-gradient(90deg,#79663788,#244854);color:#ffe9b4} +.company-cp-shell .side{background:linear-gradient(#14343ce8,#0c222aed),url('https://www.dunerealms.com/assets/political-imperial-chamber-v1.png') center/cover;border-color:#a58b52}.company-cp-shell .side-hero{background:#173b45;color:#efd49b}.company-cp-shell .category-block{background:#18333b;border-color:#a58b52}.company-cp-shell .category-heading{background:#244854;color:#f0d9ac}.company-cp-shell .navitem{color:#e9dfc8;border-color:#a58b5255;text-decoration:none;position:relative}.company-cp-shell .navitem:hover,.company-cp-shell .navitem[aria-current=page]{background:linear-gradient(90deg,#79663788,#244854);color:#ffe9b4} .company-cp-shell .company-switcher{display:flex;align-items:center;gap:18px;background:linear-gradient(90deg,#183943,#122931);border-bottom:3px double #c9ab6a;padding:16px 28px}.company-switcher>img{width:64px;height:64px;object-fit:contain}.company-switcher label{display:grid;gap:8px;color:#e5c78a;font-size:13px;text-transform:uppercase;letter-spacing:.07em}.company-cp-shell select{min-width:min(320px,65vw);max-width:100%;background:#0f2830;color:#f4e8ca;border:1px solid #b1985c;border-radius:6px;padding:11px;font:16px Georgia,serif} .company-cp-shell .hero.company-hero{background:linear-gradient(90deg,#214550ee,#122a34e6),url('https://www.dunerealms.com/assets/political-imperial-chamber-v1.png') center/cover;border:4px double #bda066;box-shadow:inset 0 0 0 4px #294752;min-height:170px}.company-hero small{font:11px Arial,sans-serif;letter-spacing:.13em;color:#dfc184}.company-cp-shell .company-hero h1{color:#ffe2a6}.company-cp-shell .hero>img{width:105px;height:105px;max-height:110px;object-fit:contain}.company-cp-shell .hero p{color:#e5ddc9} .company-cp-shell .cards>.card{border:4px double #bda066;background:linear-gradient(140deg,#24434b,#142e37);color:#eee4ce;box-shadow:inset 0 0 0 4px #182e36}.company-cp-shell .card h2,.company-cp-shell .card h3{color:#edcf91}.company-cp-shell .card p{color:#e0d9c5;line-height:1.7}.company-charter{background:linear-gradient(90deg,#122a32dd,#162c35aa),url('https://www.dunerealms.com/assets/corrino-charter-v2.png') center/cover;padding:32px;border:1px solid #b69a60;border-radius:8px}.company-charter small{color:#e2c384;font:11px Arial,sans-serif;letter-spacing:.14em} @@ -8,3 +8,6 @@ .claims-banner{background:linear-gradient(90deg,#143a35ed,#142c37ad),url('https://www.dunerealms.com/assets/clan-atelier-v1.webp') center/cover;border:3px double #bba16b;border-radius:8px;padding:28px;color:#f0e0b9}.claims-banner small{letter-spacing:.15em;font:11px Arial,sans-serif}.claims-banner h2{font-size:28px}.claims-notice{border-left:3px solid #bd9f60;padding:12px 18px;background:#102c2c;color:#e9dec4;line-height:1.65}.claims-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px;margin-top:20px}.claims-grid article{border:1px solid #b49a6166;background:linear-gradient(140deg,#234537,#142f32);color:#e8dec6;padding:24px;border-radius:8px}.claims-grid h3{color:#e5c788}.claims-grid p{line-height:1.7}.claims-grid button{padding:10px 16px;border:1px solid #a48d5a;background:#193831;color:#c6b993;border-radius:5px}.claims-grid button:disabled{opacity:.65;cursor:not-allowed} @media(max-width:1100px){.company-cp-shell .layout{grid-template-columns:190px minmax(0,1fr)}.company-cp-shell .side-right{grid-column:1/-1;display:grid;grid-template-columns:1fr 1fr}.company-cp-shell .side-right>.side-hero{grid-column:1/-1}} @media(max-width:720px){.company-cp-shell .layout{display:block}.company-cp-shell .side-right{display:none}.company-cp-shell .side-right.open{display:block}.company-facts,.claims-grid{grid-template-columns:1fr}.company-cp-shell .company-switcher{padding:12px 16px}.company-cp-shell .company-hero{padding:22px}.company-cp-shell .hero>img{width:72px}.company-cp-shell .hero h1{font-size:29px}} + +/* Keep artwork inside the shared CP columns at every viewport width. */ +.company-cp-shell .side,.company-record,.company-planned{min-width:0;overflow-wrap:anywhere}.company-record>img{display:block;width:96px;height:96px;max-width:100%;object-fit:contain;margin:0 auto 16px}.company-planned>img{display:block;width:140px;height:170px;max-width:100%;object-fit:contain;margin:0 0 20px}.company-cp-shell .company-switcher>img{flex:0 0 64px;width:64px;height:64px;object-fit:contain}.company-cp-shell .hero>img{max-width:100%} diff --git a/website/control-panel/public/cp-v2/cp-v2-company-shell.mjs b/website/control-panel/public/cp-v2/cp-v2-company-shell.mjs index 3e90f7d4..6bf5b33e 100644 --- a/website/control-panel/public/cp-v2/cp-v2-company-shell.mjs +++ b/website/control-panel/public/cp-v2/cp-v2-company-shell.mjs @@ -12,12 +12,12 @@ window.addEventListener('message',event=>{if(event.source===parent&&event.origin function render(){ if(!ready)return;dispose();dispose=()=>{};const page=companyPage(location.hash),company=companies.find(c=>c.id===selected),label=COMPANY_MENU.find(([id])=>id===page)[1]; left.replaceChildren(el('div','COMPANY AFFAIRS','side-hero'));right.replaceChildren(el('div','THE CORPORATE LEDGER','side-hero'));portals.replaceChildren();portals.classList.add('company-switcher'); - const selector=el('select'),selectionLabel=el('label','Your companies');selector.setAttribute('aria-label','Choose your company');for(const item of companies){const option=el('option',item.name);option.value=item.id;selector.append(option);}selector.value=selected||'';selector.disabled=!companies.length;selector.onchange=()=>{selected=selector.value;const url=new URL(location.href);url.searchParams.set('company',selected);history.replaceState(null,'',url);render();};selectionLabel.append(selector);portals.append(picture('guild.webp'),selectionLabel); + const selector=el('select'),selectionLabel=el('label','Your companies');selector.setAttribute('aria-label','Choose your company');for(const item of companies){const option=el('option',item.name);option.value=item.id;selector.append(option);}if(!companies.length){const option=el('option','No companies available');option.value='';selector.append(option);}selector.value=selected||'';selector.disabled=!companies.length;selector.onchange=()=>{selected=selector.value;const url=new URL(location.href);url.searchParams.set('company',selected);history.replaceState(null,'',url);render();};selectionLabel.append(selector);portals.append(picture('clans/vaerkring-v1.png'),selectionLabel); const group=el('section',undefined,'category-block');group.append(el('div','Company workspace','category-heading'));for(const[id,title]of COMPANY_MENU){const link=el('a',title,'navitem');link.href='#company/'+id;link.dataset.menuHref=outer+'/#company/'+id;if(id===page)link.setAttribute('aria-current','page');group.append(link);}left.append(group); const back=el('a','← Account Centre','navitem');back.href='https://cp.dunerealms.com/';back.target='_top';left.append(back); - const identity=el('section',undefined,'company-record');identity.append(picture('corrino-charter-v2.png'),el('h2',company?.name||'Company CP'),el('p',company?company.role+' · '+company.status:'Your corporate workspace'),el('p','A charter. A purpose. A place among the stars.'));right.append(identity); + const identity=el('section',undefined,'company-record');identity.append(picture('clans/vaerkring-v1.png'),el('h2',company?.name||'Company CP'),el('p',company?company.role+' · '+company.status:'Your corporate workspace'),el('p','A charter. A purpose. A place among the stars.'));right.append(identity); const guide=el('section',undefined,'company-record');guide.append(el('h3','Charters & estates'),el('p','Company land will belong to the organisation. Officers, boundaries and estate upgrades will be managed here.'));right.append(guide); - const hero=el('header',undefined,'hero company-hero'),copy=el('div');copy.append(el('small','VAERKRING · COMMERCE & ENTERPRISE'),el('h1',label),el('p',company?.name||'Select an enterprise to open its workspace.'));hero.append(picture('guild.webp'),copy); + const hero=el('header',undefined,'hero company-hero'),copy=el('div');copy.append(el('small','VAERKRING · COMMERCE & ENTERPRISE'),el('h1',label),el('p',company?.name||'Select an enterprise to open its workspace.'));hero.append(picture('clans/vaerkring-v1.png'),copy); const cards=el('div',undefined,'cards'),card=el('article',undefined,'card full citizen-page-full'),host=el('div',undefined,'citizen-live-host');card.append(host);cards.append(card);content.replaceChildren(hero,cards); if(!company){host.append(el('h2','Your enterprise starts here'),el('p','No company is currently registered with you as founder or CEO. Your companies will appear here when the registry grants you access.'));} else if(page==='claims')dispose=mountClaims(host,{kind:'company',name:company.name}); diff --git a/website/control-panel/server.mjs b/website/control-panel/server.mjs index 49538c76..8643a42a 100644 --- a/website/control-panel/server.mjs +++ b/website/control-panel/server.mjs @@ -1,4 +1,6 @@ export const PANEL_CSP="default-src 'self'; script-src 'self'; worker-src 'self' blob:; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; connect-src 'self' https://usercontent.luckperms.net https://metadata.luckperms.net wss://usersockets.luckperms.net; img-src 'self' data:; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'self' https://www.dunerealms.com https://dunerealms.com https://clans.dunerealms.com https://corp.dunerealms.com https://corp.dunerealms.com"; +// Company artwork is served by the canonical public asset host. +export const COMPANY_CSP=PANEL_CSP.replace("img-src 'self' data:","img-src 'self' data: https://www.dunerealms.com"); import {createElectionDirectory} from './election-directory.mjs'; import {createMenuBadges} from '../node/menu-badges.mjs'; import {startCentralScheduler} from '../node/postbank-payments.mjs'; @@ -274,7 +276,7 @@ export function createPanel(db,settings={},dependencies={}){ if(path.startsWith('/assets/')&&sharedAssets.has(path.slice(8))){const file=path.slice(8);return new Response(request.method==='HEAD'?null:await readFile(new URL('../web/assets/'+file,import.meta.url)),{headers:{'Content-Type':file.endsWith('.svg')?'image/svg+xml':file.endsWith('.png')?'image/png':'image/webp','Cache-Control':'public, max-age=3600'}});} if(path==='/federal-reserve'||path==='/federal-reserve/')return new Response(request.method==='HEAD'?null:await readFile(new URL('./public/cp-v2/reserve-ledger.html',import.meta.url)),{headers:{'Content-Type':'text/html; charset=utf-8','Cache-Control':'no-store','X-Content-Type-Options':'nosniff'}}); // V2 shell is public; private data and writes retain their authenticated API gates. - if(path==='/company-cp')return new Response(request.method==='HEAD'?null:companyCPDocument(await readFile(new URL('./public/cp-v2/index.html',import.meta.url),'utf8')),{headers:{'Content-Security-Policy':PANEL_CSP,'Content-Type':'text/html; charset=utf-8','Cache-Control':'no-store','X-Content-Type-Options':'nosniff'}}); + if(path==='/company-cp')return new Response(request.method==='HEAD'?null:companyCPDocument(await readFile(new URL('./public/cp-v2/index.html',import.meta.url),'utf8')),{headers:{'Content-Security-Policy':COMPANY_CSP,'Content-Type':'text/html; charset=utf-8','Cache-Control':'no-store','X-Content-Type-Options':'nosniff'}}); if(path==='/clan-cp')return new Response(request.method==='HEAD'?null:clanCPDocument(await readFile(new URL('./public/cp-v2/index.html',import.meta.url),'utf8')),{headers:{'Content-Type':'text/html; charset=utf-8','Cache-Control':'no-store','X-Content-Type-Options':'nosniff'}}); if(path==='/politics-cp')return new Response(request.method==='HEAD'?null:politicsCPDocument(await readFile(new URL('./public/cp-v2/index.html',import.meta.url),'utf8')),{headers:{'Content-Type':'text/html; charset=utf-8','Cache-Control':'no-store','X-Content-Type-Options':'nosniff'}}); // All authored cp-v2 browser modules share this bounded public directory. diff --git a/website/tests/company-cp-shell.test.mjs b/website/tests/company-cp-shell.test.mjs index dd716548..6890292d 100644 --- a/website/tests/company-cp-shell.test.mjs +++ b/website/tests/company-cp-shell.test.mjs @@ -6,6 +6,9 @@ test('Company CP clones the Clan frame, has isolated company navigation and perm const response=await app(new Request('https://cp.dunerealms.com/company-cp'));assert.equal(response.status,200);const html=await response.text(); assert.match(html,/data-cp-mode="company"/);assert.match(html,/cp-v2-company-shell.mjs/);assert.match(html,/id="sidebar-right"/);assert.doesNotMatch(html,/src="\/v2\/v2.js|cp-v2-clan-size.mjs|class="dune-site-header"/); assert.match(response.headers.get('content-security-policy'),/frame-ancestors[^;]*https:\/\/corp.dunerealms.com/); + const policy=response.headers.get('content-security-policy'); + assert.match(policy,/img-src 'self' data: https:\/\/www.dunerealms.com(?:;|$)/,'Company portraits and CSS backgrounds must load from the canonical artwork host'); + assert.doesNotMatch(policy,/img-src[^;]*(?:https:;|\*)/,'Artwork permission must remain limited to the canonical host'); assert.equal((await app(new Request('https://cp.dunerealms.com/company-cp',{method:'POST'}))).status,405); assert.equal((await app(new Request('https://cp.dunerealms.com/api/companies/workspace'))).status,401); for(const path of ['cp-v2-company-shell.mjs','cp-v2-company-shell.css','cp-v2-policy-catalogue.mjs','cp-v2-claims.mjs'])assert.equal((await app(new Request('https://cp.dunerealms.com/v2/'+path))).status,200);