mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-10 04:22:09 +10:00
chore: remove client API deadweight
This commit is contained in:
@ -1,9 +0,0 @@
|
||||
import { defineClientEventHandler } from "~/server/internal/clients/event-handler";
|
||||
|
||||
export default defineClientEventHandler(async (h3) => {
|
||||
const query = getQuery(h3);
|
||||
|
||||
const gameId = query.game;
|
||||
const versionName = query.version;
|
||||
const chunkId = query.chunk;
|
||||
});
|
||||
@ -1,24 +0,0 @@
|
||||
import { defineClientEventHandler } from "~/server/internal/clients/event-handler";
|
||||
|
||||
export default defineClientEventHandler(async (h3) => {
|
||||
const query = getQuery(h3);
|
||||
const clientId = query.id?.toString();
|
||||
if (!clientId)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "Missing id in query",
|
||||
});
|
||||
|
||||
const certificate = await h3.context.ca.fetchClientCertificate(clientId);
|
||||
if (!certificate) {
|
||||
// Either it doesn't exist or it's blacklisted
|
||||
throw createError({
|
||||
statusCode: 401,
|
||||
statusMessage: "Invalid or blacklisted clientId",
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
certificate: certificate.cert,
|
||||
};
|
||||
});
|
||||
@ -1,5 +0,0 @@
|
||||
import { defineClientEventHandler } from "~/server/internal/clients/event-handler";
|
||||
|
||||
export default defineClientEventHandler(async (h3) => {
|
||||
|
||||
});
|
||||
@ -1,35 +0,0 @@
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
import { CertificateBundle } from "./ca";
|
||||
|
||||
export type CertificateStore = {
|
||||
store(name: string, data: CertificateBundle): Promise<void>;
|
||||
fetch(name: string): Promise<CertificateBundle | undefined>;
|
||||
blacklistCertificate(name: string): Promise<void>;
|
||||
checkBlacklistCertificate(name: string): Promise<boolean>;
|
||||
};
|
||||
|
||||
export const fsCertificateStore = (base: string) => {
|
||||
const blacklist = path.join(base, ".blacklist");
|
||||
fs.mkdirSync(blacklist, { recursive: true });
|
||||
const store: CertificateStore = {
|
||||
async store(name: string, data: CertificateBundle) {
|
||||
const filepath = path.join(base, name);
|
||||
fs.writeFileSync(filepath, JSON.stringify(data));
|
||||
},
|
||||
async fetch(name: string) {
|
||||
const filepath = path.join(base, name);
|
||||
if (!fs.existsSync(filepath)) return undefined;
|
||||
return JSON.parse(fs.readFileSync(filepath, "utf-8"));
|
||||
},
|
||||
async blacklistCertificate(name: string) {
|
||||
const filepath = path.join(blacklist, name);
|
||||
fs.writeFileSync(filepath, Buffer.from([]));
|
||||
},
|
||||
async checkBlacklistCertificate(name: string): Promise<boolean> {
|
||||
const filepath = path.join(blacklist, name);
|
||||
return fs.existsSync(filepath);
|
||||
},
|
||||
};
|
||||
return store;
|
||||
};
|
||||
Reference in New Issue
Block a user