Compare commits

..

No commits in common. "e17632405a087712492a27a4a2e04da0c256f496" and "6e2ebf7ff34862c93426233482d47f5e66d53f15" have entirely different histories.

24 changed files with 109 additions and 958 deletions

3
.gitignore vendored
View file

@ -39,6 +39,3 @@ yarn-error.log*
# typescript # typescript
*.tsbuildinfo *.tsbuildinfo
next-env.d.ts next-env.d.ts
# clerk configuration (can include secrets)
/.clerk/

View file

@ -5,9 +5,6 @@
"name": "web", "name": "web",
"dependencies": { "dependencies": {
"@base-ui/react": "^1.0.0", "@base-ui/react": "^1.0.0",
"@next/swc-darwin-arm64": "^16.1.6",
"@vercel/analytics": "^1.6.1",
"@vercel/speed-insights": "^1.3.1",
"@xboxreplay/xboxlive-api": "^3.4.3", "@xboxreplay/xboxlive-api": "^3.4.3",
"@yudiel/react-qr-scanner": "^2.5.0", "@yudiel/react-qr-scanner": "^2.5.0",
"class-variance-authority": "^0.7.1", "class-variance-authority": "^0.7.1",
@ -236,7 +233,7 @@
"@next/eslint-plugin-next": ["@next/eslint-plugin-next@16.0.10", "", { "dependencies": { "fast-glob": "3.3.1" } }, "sha512-b2NlWN70bbPLmfyoLvvidPKWENBYYIe017ZGUpElvQjDytCWgxPJx7L9juxHt0xHvNVA08ZHJdOyhGzon/KJuw=="], "@next/eslint-plugin-next": ["@next/eslint-plugin-next@16.0.10", "", { "dependencies": { "fast-glob": "3.3.1" } }, "sha512-b2NlWN70bbPLmfyoLvvidPKWENBYYIe017ZGUpElvQjDytCWgxPJx7L9juxHt0xHvNVA08ZHJdOyhGzon/KJuw=="],
"@next/swc-darwin-arm64": ["@next/swc-darwin-arm64@16.1.6", "", { "os": "darwin", "cpu": "arm64" }, "sha512-wTzYulosJr/6nFnqGW7FrG3jfUUlEf8UjGA0/pyypJl42ExdVgC6xJgcXQ+V8QFn6niSG2Pb8+MIG1mZr2vczw=="], "@next/swc-darwin-arm64": ["@next/swc-darwin-arm64@16.0.10", "", { "os": "darwin", "cpu": "arm64" }, "sha512-4XgdKtdVsaflErz+B5XeG0T5PeXKDdruDf3CRpnhN+8UebNa5N2H58+3GDgpn/9GBurrQ1uWW768FfscwYkJRg=="],
"@next/swc-darwin-x64": ["@next/swc-darwin-x64@16.0.10", "", { "os": "darwin", "cpu": "x64" }, "sha512-spbEObMvRKkQ3CkYVOME+ocPDFo5UqHb8EMTS78/0mQ+O1nqE8toHJVioZo4TvebATxgA8XMTHHrScPrn68OGw=="], "@next/swc-darwin-x64": ["@next/swc-darwin-x64@16.0.10", "", { "os": "darwin", "cpu": "x64" }, "sha512-spbEObMvRKkQ3CkYVOME+ocPDFo5UqHb8EMTS78/0mQ+O1nqE8toHJVioZo4TvebATxgA8XMTHHrScPrn68OGw=="],
@ -510,10 +507,6 @@
"@unrs/resolver-binding-win32-x64-msvc": ["@unrs/resolver-binding-win32-x64-msvc@1.11.1", "", { "os": "win32", "cpu": "x64" }, "sha512-lrW200hZdbfRtztbygyaq/6jP6AKE8qQN2KvPcJ+x7wiD038YtnYtZ82IMNJ69GJibV7bwL3y9FgK+5w/pYt6g=="], "@unrs/resolver-binding-win32-x64-msvc": ["@unrs/resolver-binding-win32-x64-msvc@1.11.1", "", { "os": "win32", "cpu": "x64" }, "sha512-lrW200hZdbfRtztbygyaq/6jP6AKE8qQN2KvPcJ+x7wiD038YtnYtZ82IMNJ69GJibV7bwL3y9FgK+5w/pYt6g=="],
"@vercel/analytics": ["@vercel/analytics@1.6.1", "", { "peerDependencies": { "@remix-run/react": "^2", "@sveltejs/kit": "^1 || ^2", "next": ">= 13", "react": "^18 || ^19 || ^19.0.0-rc", "svelte": ">= 4", "vue": "^3", "vue-router": "^4" }, "optionalPeers": ["@remix-run/react", "@sveltejs/kit", "next", "react", "svelte", "vue", "vue-router"] }, "sha512-oH9He/bEM+6oKlv3chWuOOcp8Y6fo6/PSro8hEkgCW3pu9/OiCXiUpRUogDh3Fs3LH2sosDrx8CxeOLBEE+afg=="],
"@vercel/speed-insights": ["@vercel/speed-insights@1.3.1", "", { "peerDependencies": { "@sveltejs/kit": "^1 || ^2", "next": ">= 13", "react": "^18 || ^19 || ^19.0.0-rc", "svelte": ">= 4", "vue": "^3", "vue-router": "^4" }, "optionalPeers": ["@sveltejs/kit", "next", "react", "svelte", "vue", "vue-router"] }, "sha512-PbEr7FrMkUrGYvlcLHGkXdCkxnylCWePx7lPxxq36DNdfo9mcUjLOmqOyPDHAOgnfqgGGdmE3XI9L/4+5fr+vQ=="],
"@xboxreplay/errors": ["@xboxreplay/errors@0.1.0", "", {}, "sha512-Tgz1d/OIPDWPeyOvuL5+aai5VCcqObhPnlI3skQuf80GVF3k1I0lPCnGC+8Cm5PV9aLBT5m8qPcJoIUQ2U4y9g=="], "@xboxreplay/errors": ["@xboxreplay/errors@0.1.0", "", {}, "sha512-Tgz1d/OIPDWPeyOvuL5+aai5VCcqObhPnlI3skQuf80GVF3k1I0lPCnGC+8Cm5PV9aLBT5m8qPcJoIUQ2U4y9g=="],
"@xboxreplay/xboxlive-api": ["@xboxreplay/xboxlive-api@3.4.3", "", { "dependencies": { "@xboxreplay/errors": "^0.1.0", "axios": "^0.21.1" } }, "sha512-+iSmNCN4RHXZXBc48e0tJB+tvUs6XEwEWcXTcECrIttgDVN9fsFxroo+6ET+K38FobEM+5xUOfCVNqQoWQthxQ=="], "@xboxreplay/xboxlive-api": ["@xboxreplay/xboxlive-api@3.4.3", "", { "dependencies": { "@xboxreplay/errors": "^0.1.0", "axios": "^0.21.1" } }, "sha512-+iSmNCN4RHXZXBc48e0tJB+tvUs6XEwEWcXTcECrIttgDVN9fsFxroo+6ET+K38FobEM+5xUOfCVNqQoWQthxQ=="],
@ -1562,8 +1555,6 @@
"msw/yargs": ["yargs@17.7.2", "", { "dependencies": { "cliui": "^8.0.1", "escalade": "^3.1.1", "get-caller-file": "^2.0.5", "require-directory": "^2.1.1", "string-width": "^4.2.3", "y18n": "^5.0.5", "yargs-parser": "^21.1.1" } }, "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w=="], "msw/yargs": ["yargs@17.7.2", "", { "dependencies": { "cliui": "^8.0.1", "escalade": "^3.1.1", "get-caller-file": "^2.0.5", "require-directory": "^2.1.1", "string-width": "^4.2.3", "y18n": "^5.0.5", "yargs-parser": "^21.1.1" } }, "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w=="],
"next/@next/swc-darwin-arm64": ["@next/swc-darwin-arm64@16.0.10", "", { "os": "darwin", "cpu": "arm64" }, "sha512-4XgdKtdVsaflErz+B5XeG0T5PeXKDdruDf3CRpnhN+8UebNa5N2H58+3GDgpn/9GBurrQ1uWW768FfscwYkJRg=="],
"next/postcss": ["postcss@8.4.31", "", { "dependencies": { "nanoid": "^3.3.6", "picocolors": "^1.0.0", "source-map-js": "^1.0.2" } }, "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ=="], "next/postcss": ["postcss@8.4.31", "", { "dependencies": { "nanoid": "^3.3.6", "picocolors": "^1.0.0", "source-map-js": "^1.0.2" } }, "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ=="],
"npm-run-path/path-key": ["path-key@4.0.0", "", {}, "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ=="], "npm-run-path/path-key": ["path-key@4.0.0", "", {}, "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ=="],

View file

@ -4,18 +4,12 @@
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",
"prebuild": "node scripts/update-last-modified.js",
"build": "next build", "build": "next build",
"postinstall": "node scripts/update-last-modified.js",
"start": "next start", "start": "next start",
"lint": "eslint", "lint": "eslint"
"update-last-modified": "node scripts/update-last-modified.js"
}, },
"dependencies": { "dependencies": {
"@base-ui/react": "^1.0.0", "@base-ui/react": "^1.0.0",
"@next/swc-darwin-arm64": "^16.1.6",
"@vercel/analytics": "^1.6.1",
"@vercel/speed-insights": "^1.3.1",
"@xboxreplay/xboxlive-api": "^3.4.3", "@xboxreplay/xboxlive-api": "^3.4.3",
"@yudiel/react-qr-scanner": "^2.5.0", "@yudiel/react-qr-scanner": "^2.5.0",
"class-variance-authority": "^0.7.1", "class-variance-authority": "^0.7.1",

Binary file not shown.

View file

@ -1,89 +0,0 @@
const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');
// Get the root directory of the git repository
function getGitRoot() {
try {
return execSync('git rev-parse --show-toplevel').toString().trim();
} catch (error) {
console.error('Error finding git root:', error.message);
return null;
}
}
function getLastCommitDate(filePath) {
try {
const gitRoot = getGitRoot();
if (!gitRoot) {
console.error('Could not find git repository root');
return null;
}
// Get the relative path from git root
const relativePath = path.relative(gitRoot, path.resolve(process.cwd(), filePath));
console.log(`Checking git history for: ${relativePath}`);
// Check if the file is tracked by git
const isTracked = execSync(`git ls-files --error-unmatch "${relativePath}" 2>/dev/null || echo ""`).toString().trim();
if (!isTracked) {
console.log('File is not tracked by git, using current date');
return new Date().toISOString();
}
// Get the last commit date for the file
const lastCommitDate = execSync(
`git log -1 --format="%ad" --date=iso -- "${relativePath}"`,
{ cwd: gitRoot }
).toString().trim();
return lastCommitDate || new Date().toISOString();
} catch (error) {
console.error('Error getting last commit date:', error.message);
return new Date().toISOString();
}
}
function updateLastModified() {
const privacyPagePath = path.join(process.cwd(), 'src/app/privacy/page.tsx');
try {
let content = fs.readFileSync(privacyPagePath, 'utf8');
const lastCommitDate = getLastCommitDate(privacyPagePath);
if (!lastCommitDate) {
console.log('Using current date as fallback');
return;
}
const formattedDate = new Date(lastCommitDate).toLocaleDateString('en-US', {
year: 'numeric',
month: 'long',
day: 'numeric'
});
const lastUpdatedText = `Last updated: ${formattedDate}`;
// Check if we need to add or update the last updated line
if (content.includes('LAST_UPDATED_PLACEHOLDER')) {
// Replace the placeholder with the actual date
const updatedContent = content.replace(
/\{\/\*\s*LAST_UPDATED_PLACEHOLDER\s*\*\/\}/,
`<p className="text-sm text-muted-foreground mb-4">
${lastUpdatedText}
</p>`
);
if (updatedContent !== content) {
fs.writeFileSync(privacyPagePath, updatedContent, 'utf8');
console.log('✅ Updated last modified date in privacy policy');
}
} else {
console.log('ℹ️ Last modified date is up to date');
}
} catch (error) {
console.error('Error updating last modified date:', error.message);
}
}
updateLastModified();

View file

@ -1,15 +0,0 @@
import { NextResponse } from "next/server";
export function GET() {
return NextResponse.json({
"m.homeserver": {
"base_url": "https://chat.frg.network"
},
"org.matrix.msc4143.rtc_foci": [
{
"type": "livekit",
"livekit_service_url": "https://livekit.element.io"
}
]
});
}

View file

@ -17,12 +17,6 @@ import { useRouter } from "next/navigation";
import { cfg } from "@/lib/cfg"; import { cfg } from "@/lib/cfg";
import { getAvatarProfile } from "@/lib/avatar"; import { getAvatarProfile } from "@/lib/avatar";
import localFont from "next/font/local";
const makeSans = localFont({
src: "../../../../../public/font/makesans.ttf",
})
interface PageProps { interface PageProps {
params: Promise<{ params: Promise<{
method: string; method: string;
@ -36,7 +30,6 @@ export default function AccessPage({ params }: PageProps) {
const method = resolvedParams.method; // 'code' or 'qr' const method = resolvedParams.method; // 'code' or 'qr'
const step = resolvedParams.step; // 'verify', 'details', 'success' const step = resolvedParams.step; // 'verify', 'details', 'success'
// Access Code State // Access Code State
const [length, setLength] = useState(6); const [length, setLength] = useState(6);
const [code, setCode] = useState(""); const [code, setCode] = useState("");
@ -472,8 +465,8 @@ export default function AccessPage({ params }: PageProps) {
<ArrowLeft className="w-4 h-4 mr-2" /> <ArrowLeft className="w-4 h-4 mr-2" />
Back to home Back to home
</Link> </Link>
<h1 className={makeSans.className + " text-2xl text-primary font-extrabold lowercase"}> <h1 className="text-2xl font-semibold">
{method === 'code' ? 'access code verification' : 'qr code verification'} {method === 'code' ? 'Access Code Verification' : 'QR Code Verification'}
</h1> </h1>
<p className="text-muted-foreground"> <p className="text-muted-foreground">
{method === 'code' {method === 'code'
@ -594,7 +587,7 @@ export default function AccessPage({ params }: PageProps) {
<ArrowLeft className="w-4 h-4 mr-2" /> <ArrowLeft className="w-4 h-4 mr-2" />
Back to verification Back to verification
</Link> </Link>
<h1 className={makeSans.className + " text-2xl text-primary font-extrabold lowercase"}>server details</h1> <h1 className="text-2xl font-semibold">Server Details</h1>
<p className="text-muted-foreground"> <p className="text-muted-foreground">
Tell us which Minecraft edition you play and your username(s). Tell us which Minecraft edition you play and your username(s).
</p> </p>
@ -628,10 +621,10 @@ export default function AccessPage({ params }: PageProps) {
{needsJavaName && ( {needsJavaName && (
<div className="space-y-2"> <div className="space-y-2">
<Label htmlFor="java-username">Java Username</Label> <Label htmlFor="java-username">Java username</Label>
<Input <Input
id="java-username" id="java-username"
placeholder="Your Java Username" placeholder="Your Java username"
value={javaName} value={javaName}
className="font-mono" className="font-mono"
onChange={(event) => setJavaName(event.target.value)} onChange={(event) => setJavaName(event.target.value)}
@ -644,7 +637,7 @@ export default function AccessPage({ params }: PageProps) {
<Label htmlFor="bedrock-username">Bedrock Gamertag</Label> <Label htmlFor="bedrock-username">Bedrock Gamertag</Label>
<Input <Input
id="bedrock-username" id="bedrock-username"
placeholder="Your Bedrock Gamertag" placeholder="Your Xbox name"
value={bedrockName} value={bedrockName}
className="font-mono" className="font-mono"
onChange={(event) => setBedrockName(event.target.value)} onChange={(event) => setBedrockName(event.target.value)}
@ -689,7 +682,7 @@ export default function AccessPage({ params }: PageProps) {
{/* Header */} {/* Header */}
<div className="text-center space-y-4"> <div className="text-center space-y-4">
<PartyPopper className="w-16 h-16 text-primary mx-auto" /> <PartyPopper className="w-16 h-16 text-primary mx-auto" />
<h1 className={makeSans.className + " text-2xl text-primary font-extrabold lowercase"}>you're whitelisted!</h1> <h1 className="text-2xl font-semibold">You're whitelisted!</h1>
<p className="text-muted-foreground"> <p className="text-muted-foreground">
Welcome to FRG Network! You can now join the server. Welcome to FRG Network! You can now join the server.
As soon as you join, come back and click "Claim my reward" to get a gift on behalf of the team here. As soon as you join, come back and click "Claim my reward" to get a gift on behalf of the team here.
@ -733,7 +726,7 @@ export default function AccessPage({ params }: PageProps) {
<Item variant="outline"> <Item variant="outline">
<ItemMedia> <ItemMedia>
<Avatar size="lg"> <Avatar size="lg">
<AvatarImage src={cfg.server.bedrockFriendAvatar} /> <AvatarImage src={profileData?.avatarUrl || ""} />
<AvatarFallback>?</AvatarFallback> <AvatarFallback>?</AvatarFallback>
</Avatar> </Avatar>
</ItemMedia> </ItemMedia>
@ -760,8 +753,6 @@ export default function AccessPage({ params }: PageProps) {
</Link> </Link>
</Button> </Button>
<Button variant="outline" onClick={handleReset} className="w-full"> <Button variant="outline" onClick={handleReset} className="w-full">
Start over Start over
</Button> </Button>
@ -787,7 +778,7 @@ export default function AccessPage({ params }: PageProps) {
<ArrowLeft className="w-4 h-4 mr-2" /> <ArrowLeft className="w-4 h-4 mr-2" />
Back to success Back to success
</Link> </Link>
<h1 className={makeSans.className + " text-2xl text-primary font-extrabold lowercase"}>claim your reward</h1> <h1 className="text-2xl font-semibold">Claim Your Reward</h1>
<p className="text-muted-foreground"> <p className="text-muted-foreground">
Help us improve your server experience! Complete this survey to receive 2 diamonds as a thank you. Help us improve your server experience! Complete this survey to receive 2 diamonds as a thank you.
</p> </p>

View file

@ -1,41 +0,0 @@
import { NextRequest, NextResponse } from 'next/server';
import { minecraftApi, PlayerIdentifierInput } from '@/lib/minecraft-api';
export async function POST(request: NextRequest) {
try {
const body: PlayerIdentifierInput = await request.json();
// Validate input
if (!body.type || !body.username) {
return NextResponse.json(
{ error: 'Missing required fields: type and username' },
{ status: 400 }
);
}
if (body.type !== 'java' && body.type !== 'bedrock') {
return NextResponse.json(
{ error: 'Invalid type. Must be "java" or "bedrock"' },
{ status: 400 }
);
}
const result = await minecraftApi.resolvePlayerIdentifier(body);
return NextResponse.json({
success: true,
data: result
});
} catch (error) {
console.error('Player resolution error:', error);
return NextResponse.json(
{
success: false,
error: error instanceof Error ? error.message : 'Unknown error occurred'
},
{ status: 500 }
);
}
}

View file

@ -1,6 +1,5 @@
import { NextResponse } from "next/server"; import { NextResponse } from "next/server";
import { servertap } from "@/lib/servertap"; import { servertap } from "@/lib/servertap";
import { minecraftApi } from "@/lib/minecraft-api";
import { verifyAccessCode } from "@/app/actions"; import { verifyAccessCode } from "@/app/actions";
type WhitelistRequest = { type WhitelistRequest = {
@ -10,13 +9,6 @@ type WhitelistRequest = {
accessCode: string; accessCode: string;
}; };
type ResolvedPlayer = {
platform: "java" | "bedrock";
username: string;
uuid?: string;
xuid?: string;
};
export async function POST(request: Request) { export async function POST(request: Request) {
try { try {
const data = (await request.json()) as WhitelistRequest; const data = (await request.json()) as WhitelistRequest;
@ -36,61 +28,25 @@ export async function POST(request: Request) {
const results: string[] = []; const results: string[] = [];
const errors: string[] = []; const errors: string[] = [];
const resolvedPlayers: ResolvedPlayer[] = [];
// Resolve Java player if provided // Handle Java whitelist
if ((preference === "java" || preference === "both") && javaName?.trim()) { if ((preference === "java" || preference === "both") && javaName?.trim()) {
try { const result = await servertap.addToWhitelist(javaName.trim());
const resolved = await minecraftApi.resolvePlayerIdentifier({ if (result.success) {
type: 'java', results.push(`Successfully whitelisted Java player: ${javaName}`);
username: javaName.trim() } else {
}); errors.push(`Failed to whitelist Java player ${javaName}: ${result.error}`);
resolvedPlayers.push(resolved);
} catch (error) {
errors.push(`Failed to resolve Java player ${javaName}: ${error instanceof Error ? error.message : 'Unknown error'}`);
} }
} }
// Resolve Bedrock player if provided // Handle Bedrock whitelist (for now, we'll use the same endpoint but could be different)
if ((preference === "bedrock" || preference === "both") && bedrockName?.trim()) { if ((preference === "bedrock" || preference === "both") && bedrockName?.trim()) {
try { const bedrockNameWithDot = `.${bedrockName.trim()}`;
const resolved = await minecraftApi.resolvePlayerIdentifier({ const result = await servertap.addToWhitelist(bedrockNameWithDot);
type: 'bedrock', if (result.success) {
username: bedrockName.trim() results.push(`Successfully whitelisted Bedrock player: ${bedrockNameWithDot}`);
}); } else {
resolvedPlayers.push(resolved); errors.push(`Failed to whitelist Bedrock player ${bedrockNameWithDot}: ${result.error}`);
} catch (error) {
errors.push(`Failed to resolve Bedrock player ${bedrockName}: ${error instanceof Error ? error.message : 'Unknown error'}`);
}
}
// Add resolved players to whitelist
for (const player of resolvedPlayers) {
// Validate player data before sending to server
if (!player || !player.username || !player.platform) {
errors.push(`Invalid player data: missing username or platform`);
continue;
}
if (player.platform === 'bedrock' && !player.xuid) {
errors.push(`Bedrock gamertag player ${player.username} missing XUID - resolution may have failed`);
continue;
}
if (player.platform === 'java' && !player.uuid) {
errors.push(`Java username player ${player.username} missing UUID - resolution may have failed`);
continue;
}
try {
const result = await servertap.addToWhitelist(player);
if (result.success) {
results.push(`Successfully whitelisted ${player.platform === 'java' ? 'Java username' : 'Bedrock gamertag'} player: ${player.username} (${player.uuid || player.xuid})`);
} else {
errors.push(`Failed to whitelist ${player.platform === 'java' ? 'Java username' : 'Bedrock gamertag'} player ${player.username}: ${result.error}`);
}
} catch (error) {
errors.push(`Failed to whitelist ${player.platform === 'java' ? 'Java username' : 'Bedrock gamertag'} player ${player.username}: ${error instanceof Error ? error.message : 'Unknown error'}`);
} }
} }

View file

@ -47,94 +47,79 @@
--radius-4xl: calc(var(--radius) + 16px); --radius-4xl: calc(var(--radius) + 16px);
} }
[data-sonner-toaster][data-sonner-theme="dark"] [data-sonner-toast][data-styled="true"] [data-cancel] {
@apply rounded-sm border-border dark:bg-input/30 hover:bg-input/50 hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground;
}
[data-sonner-toaster][data-sonner-theme="dark"] [data-sonner-toast][data-styled="true"] [data-action] {
@apply rounded-sm bg-primary text-primary-foreground hover:bg-primary/80;
}
:root { :root {
--background: oklch(1 0 0); --background: oklch(1 0 0);
--foreground: oklch(0.141 0.005 285.823); --foreground: oklch(0.145 0 0);
--card: oklch(1 0 0); --card: oklch(1 0 0);
--card-foreground: oklch(0.141 0.005 285.823); --card-foreground: oklch(0.145 0 0);
--popover: oklch(1 0 0); --popover: oklch(1 0 0);
--popover-foreground: oklch(0.141 0.005 285.823); --popover-foreground: oklch(0.145 0 0);
--primary: oklch(0.646 0.222 41.116); --primary: oklch(0.65 0.18 132);
--primary-foreground: oklch(0.98 0.016 73.684); --primary-foreground: oklch(0.99 0.03 121);
--secondary: oklch(0.967 0.001 286.375); --secondary: oklch(0.967 0.001 286.375);
--secondary-foreground: oklch(0.21 0.006 285.885); --secondary-foreground: oklch(0.21 0.006 285.885);
--muted: oklch(0.967 0.001 286.375); --muted: oklch(0.97 0 0);
--muted-foreground: oklch(0.552 0.016 285.938); --muted-foreground: oklch(0.556 0 0);
--accent: oklch(0.967 0.001 286.375); --accent: oklch(0.65 0.18 132);
--accent-foreground: oklch(0.21 0.006 285.885); --accent-foreground: oklch(0.99 0.03 121);
--destructive: oklch(0.577 0.245 27.325); --destructive: oklch(0.58 0.22 27);
--border: oklch(0.92 0.004 286.32); --border: oklch(0.922 0 0);
--input: oklch(0.92 0.004 286.32); --input: oklch(0.922 0 0);
--ring: oklch(0.705 0.015 286.067); --ring: oklch(0.708 0 0);
--chart-1: oklch(0.837 0.128 66.29); --chart-1: oklch(0.90 0.18 127);
--chart-2: oklch(0.705 0.213 47.604); --chart-2: oklch(0.85 0.21 129);
--chart-3: oklch(0.646 0.222 41.116); --chart-3: oklch(0.77 0.20 131);
--chart-4: oklch(0.553 0.195 38.402); --chart-4: oklch(0.65 0.18 132);
--chart-5: oklch(0.47 0.157 37.304); --chart-5: oklch(0.53 0.14 132);
--radius: 0.625rem; --radius: 0;
--sidebar: oklch(0.985 0 0); --sidebar: oklch(0.985 0 0);
--sidebar-foreground: oklch(0.141 0.005 285.823); --sidebar-foreground: oklch(0.145 0 0);
--sidebar-primary: oklch(0.646 0.222 41.116); --sidebar-primary: oklch(0.65 0.18 132);
--sidebar-primary-foreground: oklch(0.98 0.016 73.684); --sidebar-primary-foreground: oklch(0.99 0.03 121);
--sidebar-accent: oklch(0.967 0.001 286.375); --sidebar-accent: oklch(0.65 0.18 132);
--sidebar-accent-foreground: oklch(0.21 0.006 285.885); --sidebar-accent-foreground: oklch(0.99 0.03 121);
--sidebar-border: oklch(0.92 0.004 286.32); --sidebar-border: oklch(0.922 0 0);
--sidebar-ring: oklch(0.705 0.015 286.067); --sidebar-ring: oklch(0.708 0 0);
} }
.dark { .dark {
--background: oklch(0.141 0.005 285.823); --background: oklch(0.145 0 0);
--foreground: oklch(0.985 0 0); --foreground: oklch(0.985 0 0);
--card: oklch(0.21 0.006 285.885); --card: oklch(0.205 0 0);
--card-foreground: oklch(0.985 0 0); --card-foreground: oklch(0.985 0 0);
--popover: oklch(0.21 0.006 285.885); --popover: oklch(0.205 0 0);
--popover-foreground: oklch(0.985 0 0); --popover-foreground: oklch(0.985 0 0);
--primary: oklch(0.7968 0.2119 135.19); --primary: oklch(0.77 0.20 131);
--primary-foreground: oklch(0.1566 0.0354 125.31); --primary-foreground: oklch(0.27 0.07 132);
--secondary: oklch(0.274 0.006 286.033); --secondary: oklch(0.274 0.006 286.033);
--secondary-foreground: oklch(0.985 0 0); --secondary-foreground: oklch(0.985 0 0);
--muted: oklch(0.274 0.006 286.033); --muted: oklch(0.269 0 0);
--muted-foreground: oklch(0.705 0.015 286.067); --muted-foreground: oklch(0.708 0 0);
--accent: oklch(0.274 0.006 286.033); --accent: oklch(0.77 0.20 131);
--accent-foreground: oklch(0.985 0 0); --accent-foreground: oklch(0.27 0.07 132);
--destructive: oklch(0.704 0.191 22.216); --destructive: oklch(0.704 0.191 22.216);
--border: oklch(1 0 0 / 10%); --border: oklch(1 0 0 / 10%);
--input: oklch(1 0 0 / 15%); --input: oklch(1 0 0 / 15%);
--ring: oklch(0.552 0.016 285.938); --ring: oklch(0.556 0 0);
--chart-1: oklch(0.488 0.243 264.376); --chart-1: oklch(0.90 0.18 127);
--chart-2: oklch(0.696 0.17 162.48); --chart-2: oklch(0.85 0.21 129);
--chart-3: oklch(0.769 0.188 70.08); --chart-3: oklch(0.77 0.20 131);
--chart-4: oklch(0.627 0.265 303.9); --chart-4: oklch(0.65 0.18 132);
--chart-5: oklch(0.645 0.246 16.439); --chart-5: oklch(0.53 0.14 132);
--sidebar: oklch(0.21 0.006 285.885); --sidebar: oklch(0.205 0 0);
--sidebar-foreground: oklch(0.985 0 0); --sidebar-foreground: oklch(0.985 0 0);
--sidebar-primary: oklch(0.488 0.243 264.376); --sidebar-primary: oklch(0.85 0.21 129);
--sidebar-primary-foreground: oklch(0.985 0 0); --sidebar-primary-foreground: oklch(0.27 0.07 132);
--sidebar-accent: oklch(0.274 0.006 286.033); --sidebar-accent: oklch(0.77 0.20 131);
--sidebar-accent-foreground: oklch(0.985 0 0); --sidebar-accent-foreground: oklch(0.27 0.07 132);
--sidebar-border: oklch(1 0 0 / 10%); --sidebar-border: oklch(1 0 0 / 10%);
--sidebar-ring: oklch(0.552 0.016 285.938); --sidebar-ring: oklch(0.556 0 0);
}
@supports (corner-shape: squircle) {
* {
corner-shape: superellipse(2);
--radius:1.5rem;
}
} }
@layer base { @layer base {
* { * {
@apply border-border outline-ring/50; @apply border-border outline-ring/50;
} }
body { body {
@apply bg-background text-foreground; @apply bg-background text-foreground;
} }

View file

@ -3,9 +3,6 @@ import "./globals.css";
import { Toaster } from "@/components/ui/sonner" import { Toaster } from "@/components/ui/sonner"
import { ThemeProvider } from "@/components/theme-provider"; import { ThemeProvider } from "@/components/theme-provider";
import { Google_Sans_Code, Mona_Sans } from "next/font/google"; import { Google_Sans_Code, Mona_Sans } from "next/font/google";
import localFont from 'next/font/local'
import { CookieConsent } from "@/components/cookie-notice";
import { ConditionalAnalytics } from "@/components/conditional-analytics";
export const metadata: Metadata = { export const metadata: Metadata = {
title: "FRG Network", title: "FRG Network",
@ -16,9 +13,7 @@ export const googleSansCode = Google_Sans_Code({
variable: "--font-google-code", variable: "--font-google-code",
subsets: ["latin"], subsets: ["latin"],
}); });
export const makeSans = localFont({
src: "../../public/font/makesans.ttf",
})
export const mona = Mona_Sans({ export const mona = Mona_Sans({
weight: "variable", weight: "variable",
subsets: ["latin"], subsets: ["latin"],
@ -30,22 +25,20 @@ export default function RootLayout({
children: React.ReactNode; children: React.ReactNode;
}>) { }>) {
return ( return (
<html lang="en" className={`${googleSansCode.variable} ${mona.variable}`} suppressHydrationWarning> <html lang="en" className={`${googleSansCode.variable} ${mona.variable}`} suppressHydrationWarning>
<body <body
className={`antialiased`} className={`antialiased`}
> >
<ThemeProvider <ThemeProvider
attribute="class" attribute="class"
defaultTheme="system" defaultTheme="system"
enableSystem enableSystem
disableTransitionOnChange disableTransitionOnChange
> >
{children} {children}
<CookieConsent /> </ThemeProvider>
<ConditionalAnalytics /> <Toaster position="bottom-center" />
</ThemeProvider> </body>
<Toaster position="bottom-center" /> </html>
</body>
</html>
); );
} }

View file

@ -4,11 +4,10 @@ import { Asterisk, QrCode } from "lucide-react";
import { DotGothic16 } from "next/font/google"; import { DotGothic16 } from "next/font/google";
import { cfg } from "@/lib/cfg"; import { cfg } from "@/lib/cfg";
import Link from "next/link"; import Link from "next/link";
import localFont from "next/font/local";
export const makeSans = localFont({ const dots = DotGothic16({
src: "../../public/font/makesans.ttf", weight: "400",
}) });
export default function Page() { export default function Page() {
return ( return (
@ -17,27 +16,24 @@ export default function Page() {
className="font-mona min-w-screen gap-2 min-h-screen flex flex-col items-center p-2 justify-center" className="font-mona min-w-screen gap-2 min-h-screen flex flex-col items-center p-2 justify-center"
> >
<span className="text-muted-foreground font-medium">Authentication for</span> <span className="text-muted-foreground font-medium">Authentication for</span>
<h1 className={makeSans.className + " text-2xl text-primary font-extrabold lowercase"}> <h1 className={dots.className + " text-2xl text-primary"}>
FRG Network FRG Network
</h1> </h1>
<p>A private Minecraft server for me and my friends.</p> <p>A private Minecraft server for me and my friends.</p>
<div className="flex flex-col sm:flex-row gap-2">
{cfg.accessCode.enabled && ( {cfg.accessCode.enabled && (
<Button asChild className="h-24 px-6 flex flex-col rounded-t-xl rounded-b-sm sm:rounded-l-xl sm:rounded-r-sm"> <Button asChild>
<Link href="/access/code/verify"> <Link href="/access/code/verify">
<Asterisk className="size-8" /> I have an access code <Asterisk /> I have an access code
</Link> </Link>
</Button> </Button>
)} )}
{cfg.qr.enabled && ( {cfg.qr.enabled && (
<Button asChild className="h-24 px-6 flex flex-col rounded-t-sm rounded-b-xl sm:rounded-l-sm sm:rounded-r-xl" variant="outline"> <Button variant="outline" asChild>
<Link href="/access/qr/verify"> <Link href="/access/qr/verify">
<QrCode className="size-8" /> I have a QR code <QrCode /> I have a QR code
</Link> </Link>
</Button> </Button>
)} )}
</div>
</div> </div>
</main> </main>
); );

View file

@ -1,104 +0,0 @@
"use client"
import Link from "next/link";
import { Button } from "@/components/ui/button";
import { ArrowLeft } from "lucide-react";
export default function PrivacyPage() {
return (
<div className="min-h-screen max-w-3xl mx-auto p-8 flex items-start gap-3 flex-col">
<Button variant="ghost" onClick={() => window.history.back()}>
<ArrowLeft className="mr-2 h-4 w-4" /> Back to action
</Button>
<h1 className="text-3xl text-primary font-bold mb-1">Privacy Policy</h1>
<p className="text-sm text-muted-foreground mb-4">
Last updated: December 21, 2025
</p>
<p>FRG Network is a private Minecraft server.</p>
<div className="text-sm space-y-6">
<section className="space-y-3">
<h2 className="text-xl font-semibold mb-2">What we collect</h2>
<p>
If you choose to accept our cookie policy, FRG Network use Vercel
Analytics and Speed Insights to analyse how people use our website
and how we can improve our services. This monitors:
</p>
<ul className="list-disc list-inside mt-2 space-y-1 ml-4">
<li>page views and navigation patterns</li>
<li>device type, browser, and operating system</li>
<li>approximate location (country level only)</li>
<li>performance metrics like page load times</li>
</ul>
</section>
<section className="space-y-3">
<h2 className="text-xl font-semibold mb-2">How we use this data</h2>
<p>We use this information to:</p>
<ul className="list-disc list-inside mt-2 space-y-1 ml-4">
<li>improve website performance and user experience</li>
<li>understand how visitors use our site</li>
<li>optimise our content and features</li>
</ul>
</section>
<section className="space-y-3">
<h2 className="text-xl font-semibold mb-2">What we don't collect</h2>
<p>We don't collect:</p>
<ul className="list-disc list-inside space-y-1 ml-4">
<li>personal identifiable information</li>
<li>IP addresses</li>
<li>Minecraft account details or passwords</li>
<li>precise location data</li>
</ul>
</section>
<section className="space-y-3">
<h2 className="text-xl font-semibold mb-2">Third party services</h2>
<p>
We use Vercel Analytics and Speed Insights. You can read their privacy policy {" "}
<Link
href="https://vercel.com/legal/privacy-policy"
target="_blank"
rel="noopener noreferrer"
className="text-primary underline-1 underline decoration-1"
>
here
</Link>.
</p>
</section>
<section className="space-y-3">
<h2 className="text-xl font-semibold mb-2">Your choices and rights</h2>
<div className="space-y-4">
<p>Analytics are entirely optional and this website works without them. You may manage your preferences below:</p>
<div className="flex flex-col sm:flex-row gap-4 items-start">
<Button
variant="outline"
onClick={() => {
localStorage.setItem('analytics-enabled', 'false');
localStorage.setItem('cookie-consent', 'declined');
window.location.reload();
}}
className="w-full sm:w-auto"
>
Disable Analytics
</Button>
<Button
variant="outline"
onClick={() => {
localStorage.clear();
window.location.reload();
}}
className="w-full sm:w-auto"
>
Reset All Preferences
</Button>
</div>
<p className="text-sm text-muted-foreground">
You can also clear your browser's cache at any time to reset all preferences.
This will not affect the functionality of the website in any way.
</p>
</div>
</section>
</div>
</div>
);
}

View file

@ -1,39 +0,0 @@
"use client";
import { Analytics } from "@vercel/analytics/next";
import { SpeedInsights } from "@vercel/speed-insights/next";
export function ConditionalAnalytics() {
return (
<>
<Analytics
beforeSend={(event) => {
// check if user has consented
const analyticsEnabled = localStorage.getItem("analytics-enabled") === "true";
// if not consented, return null to block the event
if (!analyticsEnabled) {
return null;
}
// if consented, return the event to send it
return event;
}}
/>
<SpeedInsights
beforeSend={(event) => {
// check if user has consented
const analyticsEnabled = localStorage.getItem("analytics-enabled") === "true";
// if not consented, return null to block the event
if (!analyticsEnabled) {
return null;
}
// if consented, return the event to send it
return event;
}}
/>
</>
);
}

View file

@ -1,41 +0,0 @@
"use client";
import { useEffect } from "react";
import { toast } from "sonner";
export function CookieConsent() {
useEffect(() => {
const consent = localStorage.getItem("cookie-consent");
if (!consent) {
setTimeout(() => {
toast("Cookies & Analytics", {
description: (
<>
We use Vercel Analytics to get useful info on how people use this site. Analytics are entirely anonymous and do not track individual users.{" "}
<a href="/privacy" className="underline hover:text-primary">
Privacy Policy
</a>
</>
),
duration: Infinity,
action: {
label: "Accept",
onClick: () => {
localStorage.setItem("cookie-consent", "accepted");
localStorage.setItem("analytics-enabled", "true");
},
},
cancel: {
label: "Opt out",
onClick: () => {
localStorage.setItem("cookie-consent", "declined");
localStorage.setItem("analytics-enabled", "false");
},
},
});
}, 1000);
}
}, []);
return null;
}

View file

@ -17,14 +17,14 @@ const buttonVariants = cva(
link: "text-primary underline-offset-4 hover:underline", link: "text-primary underline-offset-4 hover:underline",
}, },
size: { size: {
default: "h-7 gap-1 px-2 py-3 sm:py-2 text-xs/relaxed has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5", default: "h-7 gap-1 px-2 text-xs/relaxed has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
xs: "h-5 gap-1 rounded-sm px-2 py-2 sm:py-1 text-[0.625rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-2.5", xs: "h-5 gap-1 rounded-sm px-2 text-[0.625rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-2.5",
sm: "h-6 gap-1 px-2 py-2 sm:py-1.5 text-xs/relaxed has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3", sm: "h-6 gap-1 px-2 text-xs/relaxed has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
lg: "h-8 gap-1 px-2.5 py-3 sm:py-2 text-xs/relaxed has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2 [&_svg:not([class*='size-'])]:size-4", lg: "h-8 gap-1 px-2.5 text-xs/relaxed has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2 [&_svg:not([class*='size-'])]:size-4",
icon: "size-7 py-3 sm:py-2 [&_svg:not([class*='size-'])]:size-3.5", icon: "size-7 [&_svg:not([class*='size-'])]:size-3.5",
"icon-xs": "size-5 rounded-sm py-2 sm:py-1 [&_svg:not([class*='size-'])]:size-2.5", "icon-xs": "size-5 rounded-sm [&_svg:not([class*='size-'])]:size-2.5",
"icon-sm": "size-6 py-2 sm:py-1.5 [&_svg:not([class*='size-'])]:size-3", "icon-sm": "size-6 [&_svg:not([class*='size-'])]:size-3",
"icon-lg": "size-8 py-3 sm:py-2 [&_svg:not([class*='size-'])]:size-4", "icon-lg": "size-8 [&_svg:not([class*='size-'])]:size-4",
}, },
}, },
defaultVariants: { defaultVariants: {

View file

@ -25,6 +25,5 @@ export const cfg = {
bedrockIp: process.env.NEXT_PUBLIC_SERVER_BEDROCK_IP ?? "", bedrockIp: process.env.NEXT_PUBLIC_SERVER_BEDROCK_IP ?? "",
bedrockPort: process.env.NEXT_PUBLIC_SERVER_BEDROCK_PORT ?? "", bedrockPort: process.env.NEXT_PUBLIC_SERVER_BEDROCK_PORT ?? "",
bedrockFriend: process.env.NEXT_PUBLIC_SERVER_BEDROCK_FRIEND ?? "", bedrockFriend: process.env.NEXT_PUBLIC_SERVER_BEDROCK_FRIEND ?? "",
bedrockFriendAvatar: process.env.NEXT_PUBLIC_SERVER_BEDROCK_FRIEND_AVATAR ?? "",
}, },
}; };

View file

@ -1,18 +0,0 @@
import { execSync } from 'child_process';
import path from 'path';
export function getLastCommitDate(filePath: string): string | null {
try {
const absolutePath = path.resolve(process.cwd(), filePath);
const relativePath = path.relative(process.cwd(), absolutePath);
const lastCommitDate = execSync(
`git log -1 --format="%ad" --date=iso -- "${relativePath}"`
).toString().trim();
return lastCommitDate || null;
} catch (error) {
console.error('Error getting last commit date:', error);
return null;
}
}

View file

@ -9,156 +9,7 @@ interface ApiResponse<T = any> {
data?: T; data?: T;
} }
interface PlayerIdentifierInput {
type: 'java' | 'bedrock';
username: string;
}
interface PlayerIdentifierOutput {
platform: 'java' | 'bedrock';
username: string;
uuid?: string;
xuid?: string;
}
interface MojangResponse {
id: string;
name: string;
}
interface GeyserResponse {
xuid: string;
gamertag: string;
}
class MinecraftApiClient { class MinecraftApiClient {
private cache = new Map<string, PlayerIdentifierOutput>();
private readonly CACHE_TTL = 5 * 60 * 1000; // 5 minutes
private isCacheValid(timestamp: number): boolean {
return Date.now() - timestamp < this.CACHE_TTL;
}
private getCacheKey(type: string, username: string): string {
return `${type}:${username.toLowerCase()}`;
}
private formatUUID(uuid: string): string {
// Convert UUID from Mojang format (no dashes) to dashed format
return `${uuid.slice(0,8)}-${uuid.slice(8,12)}-${uuid.slice(12,16)}-${uuid.slice(16,20)}-${uuid.slice(20)}`;
}
private async resolveJavaUsername(username: string): Promise<PlayerIdentifierOutput> {
const cacheKey = this.getCacheKey('java', username);
const cached = this.cache.get(cacheKey);
if (cached && this.isCacheValid((cached as any).timestamp)) {
return cached;
}
try {
const response = await fetch(`https://api.mojang.com/users/profiles/minecraft/${username}`, {
headers: {
'User-Agent': 'MinecraftResolver/1.0'
}
});
if (response.status === 404) {
throw new Error('Player not found');
}
if (response.status === 429) {
throw new Error('Rate limit exceeded');
}
if (!response.ok) {
throw new Error(`Mojang API error: ${response.status}`);
}
const data: MojangResponse = await response.json();
const result: PlayerIdentifierOutput = {
platform: 'java',
username: data.name,
uuid: this.formatUUID(data.id)
};
// Cache with timestamp
(result as any).timestamp = Date.now();
this.cache.set(cacheKey, result);
return result;
} catch (error) {
throw new Error(`Failed to resolve Java username: ${error instanceof Error ? error.message : 'Unknown error'}`);
}
}
private async resolveBedrockGamertag(gamertag: string): Promise<PlayerIdentifierOutput> {
const cacheKey = this.getCacheKey('bedrock', gamertag);
const cached = this.cache.get(cacheKey);
if (cached && this.isCacheValid((cached as any).timestamp)) {
return cached;
}
try {
// Try GeyserMC API first (most reliable for public use)
const response = await fetch(`https://api.geysermc.org/v2/xbox/xuid/${encodeURIComponent(gamertag)}`, {
headers: {
'User-Agent': 'MinecraftResolver/1.0'
}
});
if (response.status === 404) {
throw new Error(`Gamertag "${gamertag}" not found on Xbox Live`);
}
if (response.status === 429) {
throw new Error('Xbox Live API rate limit exceeded - please try again later');
}
if (!response.ok) {
throw new Error(`GeyserMC API error: ${response.status} ${response.statusText}`);
}
const data: GeyserResponse = await response.json();
// Validate the response data - GeyserMC API only returns XUID, not gamertag
if (!data.xuid) {
throw new Error('Invalid response from GeyserMC API - missing XUID');
}
const result: PlayerIdentifierOutput = {
platform: 'bedrock',
username: gamertag, // Use the input gamertag since API doesn't return it
xuid: data.xuid
};
// Cache with timestamp
(result as any).timestamp = Date.now();
this.cache.set(cacheKey, result);
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(`Failed to resolve Bedrock gamertag "${gamertag}": ${error.message}`);
}
throw new Error(`Failed to resolve Bedrock gamertag "${gamertag}": Unknown error`);
}
}
async resolvePlayerIdentifier(input: PlayerIdentifierInput): Promise<PlayerIdentifierOutput> {
if (!input.username || input.username.trim().length === 0) {
throw new Error('Username is required');
}
const trimmedUsername = input.username.trim();
if (input.type === 'java') {
return this.resolveJavaUsername(trimmedUsername);
} else if (input.type === 'bedrock') {
return this.resolveBedrockGamertag(trimmedUsername);
} else {
throw new Error('Invalid platform type. Must be "java" or "bedrock"');
}
}
private async request<T = any>( private async request<T = any>(
endpoint: string, endpoint: string,
options: RequestInit = {} options: RequestInit = {}
@ -239,4 +90,4 @@ class MinecraftApiClient {
} }
export const minecraftApi = new MinecraftApiClient(); export const minecraftApi = new MinecraftApiClient();
export type { ApiResponse, PlayerIdentifierInput, PlayerIdentifierOutput }; export type { ApiResponse };

View file

@ -4,13 +4,6 @@ type MinecraftPlayer = {
name: string; name: string;
}; };
type ResolvedPlayer = {
platform: "java" | "bedrock";
username: string;
uuid?: string;
xuid?: string;
};
type MinecraftResponse<T> = { type MinecraftResponse<T> = {
success: boolean; success: boolean;
data?: T; data?: T;
@ -79,90 +72,17 @@ class MinecraftClient {
} }
} }
async addToWhitelist(player: string | ResolvedPlayer): Promise<MinecraftResponse<void>> { async addToWhitelist(playerName: string): Promise<MinecraftResponse<void>> {
// Handle legacy string input for backward compatibility
if (typeof player === 'string') {
if (!player || player.trim() === '') {
return {
success: false,
error: 'Player name is required'
};
}
return this.makeRequest("/api/whitelist/add", {
method: "POST",
body: JSON.stringify({ player: player.trim() }),
});
}
// Validate resolved player data
if (!player || !player.username || !player.platform) {
return {
success: false,
error: 'Player data is incomplete: username and platform are required'
};
}
// Validate platform-specific identifiers
if (player.platform === 'bedrock' && !player.xuid) {
return {
success: false,
error: 'Bedrock gamertag players require an XUID'
};
}
if (player.platform === 'java' && !player.uuid) {
return {
success: false,
error: 'Java username players require a UUID'
};
}
// Send resolved player data with UUID/XUID
const payload: any = {
player: player.username.trim(),
platform: player.platform, // Send 'java' and 'bedrock' as platform names
};
if (player.uuid) {
payload.uuid = player.uuid;
}
if (player.xuid) {
payload.xuid = player.xuid;
}
return this.makeRequest("/api/whitelist/add", { return this.makeRequest("/api/whitelist/add", {
method: "POST", method: "POST",
body: JSON.stringify(payload), body: JSON.stringify({ player: playerName }),
}); });
} }
async removeFromWhitelist(player: string | ResolvedPlayer): Promise<MinecraftResponse<void>> { async removeFromWhitelist(playerName: string): Promise<MinecraftResponse<void>> {
// Handle legacy string input for backward compatibility
if (typeof player === 'string') {
return this.makeRequest("/api/whitelist/remove", {
method: "POST",
body: JSON.stringify({ player }),
});
}
// Send resolved player data with UUID/XUID
const payload: any = {
player: player.username.trim(),
platform: player.platform, // Send 'java' and 'bedrock' as platform names
};
if (player.uuid) {
payload.uuid = player.uuid;
}
if (player.xuid) {
payload.xuid = player.xuid;
}
return this.makeRequest("/api/whitelist/remove", { return this.makeRequest("/api/whitelist/remove", {
method: "POST", method: "POST",
body: JSON.stringify(payload), body: JSON.stringify({ player: playerName }),
}); });
} }
@ -191,4 +111,4 @@ export const minecraft = new MinecraftClient();
// Legacy exports for backward compatibility // Legacy exports for backward compatibility
export const servertap = minecraft; export const servertap = minecraft;
export type { MinecraftPlayer as ServerTapPlayer, MinecraftResponse as ServerTapResponse, ResolvedPlayer }; export type { MinecraftPlayer as ServerTapPlayer, MinecraftResponse as ServerTapResponse };

View file

@ -1,28 +0,0 @@
#!/bin/bash
# Test script for the player resolver API endpoint
# Start the dev server first with: npm run dev
echo "Testing Java player resolution..."
curl -X POST http://localhost:3000/api/resolve-player \
-H "Content-Type: application/json" \
-d '{"type": "java", "username": "Notch"}' \
| jq .
echo -e "\nTesting Bedrock player resolution..."
curl -X POST http://localhost:3000/api/resolve-player \
-H "Content-Type: application/json" \
-d '{"type": "bedrock", "username": "TestGamertag"}' \
| jq .
echo -e "\nTesting invalid input..."
curl -X POST http://localhost:3000/api/resolve-player \
-H "Content-Type: application/json" \
-d '{"type": "invalid", "username": ""}' \
| jq .
echo -e "\nTesting missing fields..."
curl -X POST http://localhost:3000/api/resolve-player \
-H "Content-Type: application/json" \
-d '{}' \
| jq .

View file

@ -1,65 +0,0 @@
#!/bin/bash
# Test script for the integrated whitelist with player resolver
# This tests the full flow: resolve player -> send UUID/XUID to server
echo "Testing integrated whitelist with player resolver..."
# Test Java player with valid access code (you'll need to replace with actual access code)
echo -e "\n=== Testing Java Player Resolution + Whitelist ==="
curl -X POST http://localhost:3000/api/whitelist \
-H "Content-Type: application/json" \
-d '{
"javaName": "Notch",
"preference": "java",
"accessCode": "YOUR_ACCESS_CODE_HERE"
}' \
| jq .
# Test Bedrock player with valid access code
echo -e "\n=== Testing Bedrock Player Resolution + Whitelist ==="
curl -X POST http://localhost:3000/api/whitelist \
-H "Content-Type: application/json" \
-d '{
"bedrockName": "TestGamertag",
"preference": "bedrock",
"accessCode": "YOUR_ACCESS_CODE_HERE"
}' \
| jq .
# Test both platforms
echo -e "\n=== Testing Both Platforms Resolution + Whitelist ==="
curl -X POST http://localhost:3000/api/whitelist \
-H "Content-Type: application/json" \
-d '{
"javaName": "Notch",
"bedrockName": "TestGamertag",
"preference": "both",
"accessCode": "YOUR_ACCESS_CODE_HERE"
}' \
| jq .
# Test invalid access code
echo -e "\n=== Testing Invalid Access Code ==="
curl -X POST http://localhost:3000/api/whitelist \
-H "Content-Type: application/json" \
-d '{
"javaName": "Notch",
"preference": "java",
"accessCode": "invalid_code"
}' \
| jq .
# Test invalid username
echo -e "\n=== Testing Invalid Username ==="
curl -X POST http://localhost:3000/api/whitelist \
-H "Content-Type: application/json" \
-d '{
"javaName": "nonexistentplayer12345",
"preference": "java",
"accessCode": "YOUR_ACCESS_CODE_HERE"
}' \
| jq .
echo -e "\n=== Test completed ==="
echo "Note: Replace YOUR_ACCESS_CODE_HERE with a valid access code from your system"

View file

@ -1,23 +0,0 @@
#!/bin/bash
# Test script to verify platform names are sent correctly to server
echo "Testing platform name mapping..."
# Test Java player - should send "java username" as platform
echo -e "\n=== Java Player Platform Test ==="
curl -X POST http://localhost:3000/api/resolve-player \
-H "Content-Type: application/json" \
-d '{"type": "java", "username": "Notch"}' \
| jq .
# Test Bedrock player - should send "bedrock gamertag" as platform
echo -e "\n=== Bedrock Player Platform Test ==="
curl -X POST http://localhost:3000/api/resolve-player \
-H "Content-Type: application/json" \
-d '{"type": "bedrock", "username": "TestGamertag"}' \
| jq .
echo -e "\n=== Platform Mapping Complete ==="
echo "Java platform should be: 'java username'"
echo "Bedrock platform should be: 'bedrock gamertag'"

View file

@ -1,59 +0,0 @@
// Simple test script for the player resolver
// Run with: node test-player-resolver.js
const { minecraftApi } = require('./src/lib/minecraft-api.ts');
async function testJavaPlayer() {
console.log('Testing Java player resolution...');
try {
const result = await minecraftApi.resolvePlayerIdentifier({
type: 'java',
username: 'Notch' // Famous Minecraft player
});
console.log('Java player result:', result);
} catch (error) {
console.error('Java player error:', error.message);
}
}
async function testBedrockPlayer() {
console.log('Testing Bedrock player resolution...');
try {
const result = await minecraftApi.resolvePlayerIdentifier({
type: 'bedrock',
username: 'TestGamertag' // This will likely fail but tests the API
});
console.log('Bedrock player result:', result);
} catch (error) {
console.error('Bedrock player error:', error.message);
}
}
async function testInvalidInput() {
console.log('Testing invalid input...');
try {
await minecraftApi.resolvePlayerIdentifier({
type: 'invalid',
username: ''
});
} catch (error) {
console.error('Expected error for invalid input:', error.message);
}
}
async function runTests() {
console.log('Starting player resolver tests...\n');
await testJavaPlayer();
console.log('\n');
await testBedrockPlayer();
console.log('\n');
await testInvalidInput();
console.log('\n');
console.log('Tests completed!');
}
runTests().catch(console.error);