feat(api): Preliminary captcha support database tables

This commit is contained in:
Jesse Wierzbinski 2024-06-12 13:48:58 -10:00
parent 9d8c2e81e9
commit a6159b9d55
No known key found for this signature in database
6 changed files with 2167 additions and 0 deletions

BIN
bun.lockb

Binary file not shown.

View file

@ -0,0 +1,6 @@
CREATE TABLE IF NOT EXISTS "CaptchaChallenges" (
"id" uuid PRIMARY KEY DEFAULT uuid_generate_v7() NOT NULL,
"challenge" jsonb NOT NULL,
"expires_at" timestamp(3) DEFAULT NOW() + INTERVAL '5 minutes',
"created_at" timestamp(3) DEFAULT now() NOT NULL
);

File diff suppressed because it is too large Load diff

View file

@ -183,6 +183,13 @@
"when": 1718147685855,
"tag": "0025_violet_susan_delgado",
"breakpoints": true
},
{
"idx": 26,
"version": "7",
"when": 1718234302625,
"tag": "0026_neat_stranger",
"breakpoints": true
}
]
}

View file

@ -1,4 +1,5 @@
import type { EntityValidator } from "@lysand-org/federation";
import type { Challenge } from "altcha-lib/types";
import { relations, sql } from "drizzle-orm";
import {
type AnyPgColumn,
@ -15,6 +16,21 @@ import {
} from "drizzle-orm/pg-core";
import type { Source as APISource } from "~/types/mastodon/source";
export const CaptchaChallenges = pgTable("CaptchaChallenges", {
id: uuid("id").default(sql`uuid_generate_v7()`).primaryKey().notNull(),
challenge: jsonb("challenge").notNull().$type<Challenge>(),
expiresAt: timestamp("expires_at", {
precision: 3,
mode: "string",
}).default(
// 5 minutes
sql`NOW() + INTERVAL '5 minutes'`,
),
createdAt: timestamp("created_at", { precision: 3, mode: "string" })
.defaultNow()
.notNull(),
});
export const Emojis = pgTable("Emojis", {
id: uuid("id").default(sql`uuid_generate_v7()`).primaryKey().notNull(),
shortcode: text("shortcode").notNull(),

View file

@ -103,6 +103,7 @@
"@lysand-org/federation": "^1.2.0",
"@oclif/core": "^4.0.4",
"@tufjs/canonical-json": "^2.0.0",
"altcha-lib": "^0.3.0",
"blurhash": "^2.0.5",
"chalk": "^5.3.0",
"cli-progress": "^3.12.0",