web/website/control-panel/provision-owner.mjs
unimatrixgit 9dcd9b084a Integrate shared planetary inventories and account sales with the current site
Merge the supplied inventory/exchange package into the latest DuneRealms source.
Keep community-reward receipts, verified UUID linking, native menus and current
website artwork, Dutch naming and account controls. Wire the inventory/sales
adapters into the real CP session and verified-link schema, with isolated reads
and honest unconfigured states. Preserve lobby/ender separation and Core-owned
atomic exchange checkpoints.

Validation: website build and 56 tests; 12 inventory/market adapter tests;
Core/Essentials and NPC/Terrain/Lobby builds and tests; local browser inspection
of the themed inventory, mannequin and History of sales with fictional fixtures.
Paper 1.21.8 source only: live 1.21.4 binaries and databases are unchanged.
2026-10-27 19:44:22 +01:00

10 lines
1.4 KiB
JavaScript

import {readFile,unlink} from 'node:fs/promises';
import {randomUUID,randomBytes,scrypt as rawScrypt} from 'node:crypto';import {promisify} from 'node:util';
import {openDatabase} from '../node/mysql.mjs';
const file=process.argv[2];if(!file||!file.startsWith('/tmp/'))throw Error('Use a private bootstrap JSON file in /tmp.');
const input=JSON.parse(await readFile(file,'utf8'));if(!/^[a-z0-9_]{3,32}$/.test(input.username)||typeof input.password!=='string'||input.password.length<24)throw Error('Invalid owner bootstrap.');
const db=await openDatabase(process.env);try{
const id=randomUUID(),now=Date.now(),salt=randomBytes(16).toString('hex'),hash=(await promisify(rawScrypt)(input.password,salt,64)).toString('hex');
await db.batch([db.prepare('INSERT INTO site_accounts(id,username,display_name,password_salt,password_hash,role,created_at) VALUES(?,?,?,?,?,?,?)').bind(id,input.username,'Unimatrix',salt,hash,'staff',now),db.prepare('INSERT INTO player_profiles(user_id,display_name,minecraft_name,discord_name,created_at,updated_at) VALUES(?,?,?,?,?,?)').bind(id,'Unimatrix','','',now,now),db.prepare('INSERT INTO account_audit(id,actor_id,action,details,created_at) VALUES(?,?,?,?,?)').bind(randomUUID(),id,'owner-provisioned','Explicit owner request; private bootstrap',now)]);
await unlink(file);console.log('Owner staff account provisioned; bootstrap removed.');
}finally{await db.close();}