Remove dead token-based verification system
All checks were successful
Build & Deploy to Staging / Build & Deploy to Staging (push) Successful in 12m26s

- Remove verificationsCache array and loadVerifications() function from verification.ts
- Remove verifyToken() and verifyTokenSync() functions (multi-replica unsafe, never used)
- Remove createVerification() function (stores unused data)
- Remove GET /verify route and verifyPage() helper function
- Remove loadVerifications() call from startup
- Remove createVerification() usage from signup route
- Update imports and test mocks to match removed functions
- Keep active 6-digit code system intact (createPendingVerification, verifyCode, etc.)

All 559 tests passing. The active verification system using pending_verifications
table and 6-digit codes continues to work normally.
This commit is contained in:
Hoid 2026-03-08 08:07:20 +01:00
parent d376d586fe
commit 2793207b39
6 changed files with 108 additions and 146 deletions

View file

@ -0,0 +1,101 @@
import { describe, it, expect } from "vitest";
import request from "supertest";
import { app } from "../index.js";
describe("Dead Token Verification System Removal", () => {
describe("Removed Functions", () => {
it("should not export verificationsCache from verification service", async () => {
try {
const verification = await import("../services/verification.js");
expect(verification).not.toHaveProperty("verificationsCache");
} catch (error) {
// This is fine - the export doesn't exist
expect(true).toBe(true);
}
});
it("should not export loadVerifications from verification service", async () => {
try {
const verification = await import("../services/verification.js");
expect(verification).not.toHaveProperty("loadVerifications");
} catch (error) {
// This is fine - the export doesn't exist
expect(true).toBe(true);
}
});
it("should not export verifyToken from verification service", async () => {
try {
const verification = await import("../services/verification.js");
expect(verification).not.toHaveProperty("verifyToken");
} catch (error) {
// This is fine - the export doesn't exist
expect(true).toBe(true);
}
});
it("should not export verifyTokenSync from verification service", async () => {
try {
const verification = await import("../services/verification.js");
expect(verification).not.toHaveProperty("verifyTokenSync");
} catch (error) {
// This is fine - the export doesn't exist
expect(true).toBe(true);
}
});
it("should not export createVerification from verification service", async () => {
try {
const verification = await import("../services/verification.js");
expect(verification).not.toHaveProperty("createVerification");
} catch (error) {
// This is fine - the export doesn't exist
expect(true).toBe(true);
}
});
});
describe("Removed Routes", () => {
it("should return 404 for GET /verify route", async () => {
const response = await request(app).get("/verify").query({ token: "some-token" });
expect(response.status).toBe(404);
});
it("should return 404 for GET /verify route without token", async () => {
const response = await request(app).get("/verify");
expect(response.status).toBe(404);
});
});
describe("Active System Still Works", () => {
it("should export createPendingVerification", async () => {
const verification = await import("../services/verification.js");
expect(verification).toHaveProperty("createPendingVerification");
expect(typeof verification.createPendingVerification).toBe("function");
});
it("should export verifyCode", async () => {
const verification = await import("../services/verification.js");
expect(verification).toHaveProperty("verifyCode");
expect(typeof verification.verifyCode).toBe("function");
});
it("should export isEmailVerified", async () => {
const verification = await import("../services/verification.js");
expect(verification).toHaveProperty("isEmailVerified");
expect(typeof verification.isEmailVerified).toBe("function");
});
it("should export getVerifiedApiKey", async () => {
const verification = await import("../services/verification.js");
expect(verification).toHaveProperty("getVerifiedApiKey");
expect(typeof verification.getVerifiedApiKey).toBe("function");
});
it("should export PendingVerification interface", async () => {
// TypeScript interface test - if compilation passes, the interface exists
const verification = await import("../services/verification.js");
expect(verification).toBeDefined();
});
});
});