Compare commits

..
235 changed files with 190 additions and 6119 deletions

View file

@ -44,11 +44,3 @@ test('publication comparison, artifact upload and deployment require canonical m
if (name !== 'Trigger deployment after successful CI') assert.doesNotMatch(body, /DUNEREALMS_DEPLOY_KEY|ssh .*dunedeploy@/);
}
});
test('deployment uses the verified dedicated host and its pinned SSH key', () => {
const deploy = step('Trigger deployment after successful CI');
assert.ok(deploy.includes('95.216.100.187 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICdHgR/5lVFKbOpAYR2+/Bi5LSg+8nDCSm77mJOmJKRg'));
assert.ok(deploy.includes('dunedeploy@95.216.100.187'));
assert.ok(!deploy.includes('91.107.196.242'));
});

View file

@ -87,7 +87,7 @@ jobs:
printf '%s\n' "$DEPLOY_KEY" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
trap 'rm -f ~/.ssh/deploy_key' EXIT
printf '%s\n' '95.216.100.187 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICdHgR/5lVFKbOpAYR2+/Bi5LSg+8nDCSm77mJOmJKRg' >> ~/.ssh/known_hosts
ssh -p 22 -i ~/.ssh/deploy_key -o IdentitiesOnly=yes -o BatchMode=yes -o StrictHostKeyChecking=yes dunedeploy@95.216.100.187 "$GITHUB_SHA"
printf '%s\n' '91.107.196.242 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIC8x/XocsIz41fWHGty0DbZhSvafSQFt9jaHHgzdr55W root@ubuntu-4gb-fsn1-1' >> ~/.ssh/known_hosts
ssh -p 22 -i ~/.ssh/deploy_key -o IdentitiesOnly=yes -o BatchMode=yes -o StrictHostKeyChecking=yes dunedeploy@91.107.196.242 "$GITHUB_SHA"
rm -f ~/.ssh/deploy_key

View file

@ -37,9 +37,6 @@
- Preserve the accepted DuneRealms design and reuse existing navigation, services and domain permissions.
- DuneForge is the existing `#forge/git-workspace` workspace; the root DuneGit register is `/git/`.
- Item cards display authoritative metadata from native Bukkit items or a verified signed HQ design. Do not invent quality, marks, lore, enchantments or stats from material names.
- Official CMS Exchange publications use the existing item-definition key and an immutable `cms.item` binding to the exact In-game Bank Treasury account. Player resales of custom items pay the player. Preserve the recovered HQ publisher, recipient-bound `/redeem` gift flow and atomic publication/payment/delivery receipts; do not replace them with placeholders or infer an official payee from an item's name or origin alone.
- Preserve real voting, banking and item-issuance boundaries. Public presentation must not expose serialized items, signatures or service credentials.
- Describe what is coded, tested, merged and deployed separately. Mark unavailable features honestly.
- The owner requires one shared header and footer across portal, CP and other website surfaces. Use one canonical source and publication path; aligning labels on separate implementations is insufficient. Verify signed-in rendering as well as emitted HTML.
- Workspace menus (Staff, User CP and Bank) must display every menu item in the normal page flow. Never add a viewport height cap, sticky scrolling container or independent scrollbar to `#sidebar` or `#sidebar-right`. Scroll the main page; do not hide overflow to conceal unreachable links. Verify this after shared stylesheet publication.

View file

@ -18,6 +18,3 @@ EXCHANGE_READ_TOKEN=
# Optional private read-only PostgreSQL role for CP inventory/sales.
# Never use the game writer role or publish this URL to browser code.
DUNE_INVENTORY_DATABASE_URL=
# Enable only after the paired native Guild travel release is installed.
GUILD_OPEN_TRAVEL=false

View file

@ -1 +1 @@
export function clanCPDocument(source){return source.replace('<title>DuneRealms · Account Centre</title>','<title>DuneRealms · Clan CP</title>').replace(/<header class="dune-site-header"[^>]*>[\s\S]*?<\/header>/,'').replace(/<footer class="site-footer"><\/footer>/,'').replace(/<script src="https:\/\/www\.dunerealms\.com\/portal-navigation\.js" defer><\/script>/,'').replace(/<link rel="stylesheet" href="https:\/\/www\.dunerealms\.com\/portal-navigation\.css">/,'').replace(/<body\b[^>]*>/,'<body data-cp-mode="clan" class="clan-cp-shell">').replace(/<section class="command-banner">[\s\S]*?<\/section>/,'').replace('</head>','<link rel="stylesheet" href="/v2/cp-v2-clan-shell.css?v=single-scroll-3"><link rel="stylesheet" href="/v2/cp-v2-claims.css"></head>').replace('</body>','<script type="module" src="/v2/cp-v2-clan-size.mjs"></script></body>');}
export function clanCPDocument(source){return source.replace('<title>DuneRealms · Account Centre</title>','<title>DuneRealms · Clan CP</title>').replace(/<header class="dune-site-header"[^>]*>[\s\S]*?<\/header>/,'').replace(/<footer class="site-footer"><\/footer>/,'').replace(/<script src="https:\/\/www\.dunerealms\.com\/portal-navigation\.js" defer><\/script>/,'').replace(/<link rel="stylesheet" href="https:\/\/www\.dunerealms\.com\/portal-navigation\.css">/,'').replace(/<body\b[^>]*>/,'<body data-cp-mode="clan" class="clan-cp-shell">').replace(/<section class="command-banner">[\s\S]*?<\/section>/,'').replace('</head>','<link rel="stylesheet" href="/v2/cp-v2-clan-shell.css?v=single-scroll-2"><link rel="stylesheet" href="/v2/cp-v2-claims.css"></head>').replace('</body>','<script type="module" src="/v2/cp-v2-clan-size.mjs"></script></body>');}

View file

@ -1,5 +1,5 @@
import {isClandestineInstitution} from '../node/clandestine-identity.mjs';
import {membershipRequest,membershipReview,MembershipError,clanAcceptanceStatements} from '../node/membership-recruitment.mjs';
import {membershipRequest,membershipReview,MembershipError} from '../node/membership-recruitment.mjs';
import {JarvisError} from '../node/jarvis-listings.mjs';
import {JARVIS_CLAN_REQUEST_SCHEMA} from '../node/jarvis-clan-requests.mjs';
import {clanRecruitmentQuote} from '../node/jarvis-recruitment-policy.mjs';
@ -104,7 +104,9 @@ export function createClans(db,{origin='https://cp.dunerealms.com',authenticate=
if(role==='owner')return json({message:'Transfer ownership or archive the clan before leaving.'},409);
await db.batch([lock(),checked(db.prepare('DELETE FROM site_clan_members WHERE clan_id=? AND user_id=?').bind(record.id,user.id)),audit(record.id,{})]);
}else if(action==='review'){
await db.batch(await membershipReview({db,kind:'clan',user,record,body,now,canReview:['owner','officer'].includes(role)||deedRights.canManage,lock,audit:details=>audit(record.id,details),integration:requestIntegration,access,accept:async({target,link})=>clanAcceptanceStatements({db,record,target,link,now})}));await requestIntegration?.afterReview?.().catch(()=>console.error('Recruitment completion pending reconciliation'));
await db.batch(await membershipReview({db,kind:'clan',user,record,body,now,canReview:['owner','officer'].includes(role)||deedRights.canManage,lock,audit:details=>audit(record.id,details),integration:requestIntegration,access,accept:async({target,link})=>{
return [{async run(connection){const sql="SELECT c.active,COALESCE(ch.charter_kind,'basic') charter_kind,(SELECT COUNT(*) FROM site_clan_members m WHERE m.clan_id=c.id) member_count FROM site_clans c LEFT JOIN site_clan_charters ch ON ch.clan_id=c.id WHERE c.id=?";const current=connection?(await connection.execute(sql,[record.id]))[0][0]:await db.prepare(sql).bind(record.id).first();if(!current||!current.active)throw new Conflict('The clan is unavailable.');const limit=clanMemberLimit(current.charter_kind);if(Number(current.member_count)>=limit)throw new Conflict(`This clan has at most ${limit} members, including the owner. An outside Consort remains a member of their own clan.`);return {success:true,meta:{changes:0}};}} ,db.prepare("INSERT INTO site_clan_members(user_id,minecraft_uuid,clan_id,clan_role,joined_at) VALUES(?,?,?,'member',?)").bind(target.user_id,link.minecraft_uuid,record.id,now),db.prepare("UPDATE site_clan_requests SET status='withdrawn',updated_at=? WHERE user_id=? AND status='pending' AND clan_id<>?").bind(now,target.user_id,record.id)];
}}));await requestIntegration?.afterReview?.().catch(()=>console.error('Recruitment completion pending reconciliation'));
}else{
if(!deedRights.canManage)return json({message:'Only this clan’s owner can perform that action.'},403);
if(action==='motd'){

View file

@ -1,9 +1,6 @@
import {identity} from '../node/auth.mjs';
import {can} from '../node/permissions.mjs';
import {createItemDesigns} from '../node/item-designs.mjs';
import {issueItemGift} from '../node/item-gifts.mjs';
import {postHQOffer} from '../node/hq-exchange.mjs';
import {createCMSItemPublications} from '../node/cms-item-publication.mjs';
export function createItemDesignAPI(db,keys,settings={},dependencies={}){
const authenticate=dependencies.authenticate||(request=>identity(request,db));
@ -12,7 +9,6 @@ export function createItemDesignAPI(db,keys,settings={},dependencies={}){
return !!fresh&&await can(db,fresh,'web.items.manage');
});
const service=keys?createItemDesigns(db,keys,{authorize:allowed}):null;
const publications=dependencies.publications||(keys&&settings.DUNE_INVENTORY_DATABASE_URL?.startsWith('mysql:')?createCMSItemPublications(db,keys,{secret:settings.GAME_LINK_SECRET,gameSchema:new URL(settings.DUNE_INVENTORY_DATABASE_URL).pathname.slice(1),centralSchema:settings.DB_NAME,bank:dependencies.bank||db,authorize:allowed}):null);
const reply=(body,status=200)=>Response.json(body,{status,headers:{'Cache-Control':'private, no-store',Vary:'Cookie','X-Content-Type-Options':'nosniff'}});
return async request=>{
const url=new URL(request.url);if(url.pathname!=='/api/items/designs'||url.search)return reply({message:'Use the item definition register without identity overrides.'},400);
@ -20,28 +16,14 @@ export function createItemDesignAPI(db,keys,settings={},dependencies={}){
const actor=await authenticate(request);if(!actor)return reply({message:'Sign in first.'},401);
if(!await allowed(actor,db))return reply({message:'Item definition management required.'},403);
if(!service)return reply({message:'The item definition key service is unavailable.'},503);
if(request.method==='GET'){const definitions=await service.list(actor),candidates=publications?await publications.candidates(actor):[];return reply({definitions:definitions.map(row=>({...row,publication:candidates.find(p=>p.keyId===row.keyId)||row.publication||null}))});}
if(request.method==='GET')return reply({definitions:await service.list(actor)});
if(request.headers.get('origin')!==new URL(settings.CP_ORIGIN||'https://cp.dunerealms.com').origin)return reply({message:'Origin rejected.'},403);
if(!/^application\/json(?:;|$)/i.test(request.headers.get('content-type')||''))return reply({message:'JSON required.'},415);
const reader=request.body?.getReader();if(!reader)return reply({message:'Item definition required.'},400);
let input;try{const chunks=[];let length=0;while(true){const {value,done}=await reader.read();if(done)break;length+=value.byteLength;if(length>16384){await reader.cancel();return reply({message:'Item definition exceeds its bound.'},413);}chunks.push(value);}input=JSON.parse(Buffer.concat(chunks).toString('utf8'));}
catch{return reply({message:'Invalid item definition.'},400);}finally{reader.releaseLock();}
if(['seal-publication','withdraw-publication'].includes(input?.action)){
if(Object.keys(input).sort().join(',')!=='action,confirmed,keyId,listingId'||input.confirmed!==true)return reply({message:'Confirm the existing item publication and key.'},400);
if(!publications)return reply({message:'Official item publication is unavailable.'},503);
if(!await (dependencies.canGift||((user)=>can(db,user,'dune.items.give')))(actor))return reply({message:'Item issuance permission required.'},403);
try{return reply(await publications[input.action==='seal-publication'?'seal':'withdraw'](actor,input));}catch(error){return reply({message:error.status||error instanceof TypeError?error.message:'The publication was not confirmed.'},error.status||(error instanceof TypeError?400:503));}
}
if(input?.action==='gift'||input?.action==='publish'){
const gift=input.action==='gift';
const fields=gift?['action','id','revision','recipient','quantity']:['action','id','revision','requestId','quantity','priceMinor','confirmed'];
if(Object.keys(input).length!==fields.length||!fields.every(key=>Object.hasOwn(input,key)))return reply({message:'Review the item revision and publication details.'},400);
if(!await (dependencies.canGift||((user)=>can(db,user,'dune.items.give')))(actor))return reply({message:'Item issuance permission required.'},403);
try{return reply(await (gift?issueItemGift(db,service,actor,input):postHQOffer(dependencies.bank,service,actor,input,settings,{sealPublication:(tx,fields)=>publications.seal(actor,fields,{transactionStore:tx})})),201);}
catch(error){return reply({message:error instanceof TypeError?error.message:gift?'This gift could not be issued from the selected revision.':'Publication could not be confirmed. Retry the same request.'},error instanceof TypeError?400:409);}
}
if(!input||typeof input!=='object'||Array.isArray(input)||Object.keys(input).length!==4||!['action','id','revision','design'].every(key=>Object.hasOwn(input,key))||input.action!=='save')return reply({message:'Use the selected item, current revision and complete design.'},400);
try{const saved=await service.save(actor,input);return reply(saved,saved.revision===1&&!saved.replayed?201:200);}
catch(error){if(error instanceof TypeError)return reply({message:error.message},400);if(error.message==='Item definition management required.')return reply({message:error.message},403);if(/^Item definition (?:changed|revision conflict)/.test(error.message)||error.message.startsWith('Published item definition is sealed.'))return reply({message:error.message},409);throw error;}
catch(error){if(error instanceof TypeError)return reply({message:error.message},400);if(error.message==='Item definition management required.')return reply({message:error.message},403);if(/^Item definition (?:changed|revision conflict)/.test(error.message))return reply({message:error.message},409);throw error;}
};
}

View file

@ -1,11 +1,11 @@
import {readFile} from 'node:fs/promises';
import {identity} from '../node/auth.mjs';
import {can} from '../node/permissions.mjs';
export function createItemRegister(db,{authenticate=request=>identity(request,db),allowed=user=>can(db,user,'web.menu.items'),readCatalogue=()=>readFile(new URL('../web/assets/items/catalogue-v1.json',import.meta.url),'utf8'),publishedDesigns=async()=>[]}={}){
export function createItemRegister(db,{authenticate=request=>identity(request,db),allowed=user=>can(db,user,'web.menu.items'),readCatalogue=()=>readFile(new URL('../web/assets/items/catalogue-v1.json',import.meta.url),'utf8')}={}){
return async request=>{
const reply=(body,status=200)=>Response.json(body,{status,headers:{'Cache-Control':'private, no-store',Vary:'Cookie'}});
if(request.method!=='GET')return reply({message:'Method not allowed'},405);
const user=await authenticate(request);if(!user)return reply({message:'Sign in first.'},401);if(!await allowed(user))return reply({message:'Item registry access required.'},403);
try{const data=JSON.parse(await readCatalogue());if(data.schemaVersion!==1||!Array.isArray(data.items)||data.items.length>1000||!Array.isArray(data.qualityTiers))throw Error();const hq=(await publishedDesigns()).map(({keyId,design,template})=>({id:keyId,name:design.name,quality:design.quality,equipmentMark:design.equipmentMark,baseMaterial:template.material.toUpperCase(),image:template.image,lore:design.lore.map(line=>line.text),enchantments:design.enchantments,kind:'hq'}));const items=new Map([...hq,...data.items].map(item=>[item.id,item]));for(const tier of [{key:'mythic',label:'Mythic',color:'#e69b70'},{key:'relic',label:'Relic',color:'#efb231'}])if(hq.some(item=>item.quality===tier.key)&&!data.qualityTiers.some(t=>t.key===tier.key))data.qualityTiers.push(tier);return reply({...data,items:[...items.values()].slice(0,1000)});}catch{return reply({message:'The published item catalogue is temporarily unavailable.'},503);}
try{const data=JSON.parse(await readCatalogue());if(data.schemaVersion!==1||!Array.isArray(data.items)||data.items.length>1000||!Array.isArray(data.qualityTiers))throw Error();return reply(data);}catch{return reply({message:'The published item catalogue is temporarily unavailable.'},503);}
};
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 183 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 592 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 184 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 675 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 181 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 549 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 184 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 574 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 185 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 658 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 183 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 796 B

Some files were not shown because too many files have changed in this diff Show more