mirror of
https://github.com/kmc7468/arkvault.git
synced 2026-02-04 08:06:56 +00:00
DB 입출력시의 타입 가드 추가
This commit is contained in:
@@ -1,15 +1,9 @@
|
||||
import { sqliteTable, text, integer, primaryKey } from "drizzle-orm/sqlite-core";
|
||||
import { user } from "./user";
|
||||
|
||||
export enum UserClientState {
|
||||
Challenging = 0,
|
||||
Pending = 1,
|
||||
Active = 2,
|
||||
}
|
||||
|
||||
export const client = sqliteTable("client", {
|
||||
id: integer("id").primaryKey(),
|
||||
pubKey: text("public_key").notNull().unique(),
|
||||
pubKey: text("public_key").notNull().unique(), // Base64
|
||||
});
|
||||
|
||||
export const userClient = sqliteTable(
|
||||
@@ -21,7 +15,9 @@ export const userClient = sqliteTable(
|
||||
clientId: integer("client_id")
|
||||
.notNull()
|
||||
.references(() => client.id),
|
||||
state: integer("state").notNull().default(UserClientState.Challenging),
|
||||
state: text("state", { enum: ["challenging", "pending", "active"] })
|
||||
.notNull()
|
||||
.default("challenging"),
|
||||
encKey: text("encrypted_key"),
|
||||
},
|
||||
(t) => ({
|
||||
@@ -37,7 +33,7 @@ export const userClientChallenge = sqliteTable("user_client_challenge", {
|
||||
clientId: integer("client_id")
|
||||
.notNull()
|
||||
.references(() => client.id),
|
||||
challenge: text("challenge").notNull().unique(),
|
||||
challenge: text("challenge").notNull().unique(), // Base64
|
||||
allowedIp: text("allowed_ip").notNull(),
|
||||
expiresAt: integer("expires_at").notNull(),
|
||||
expiresAt: integer("expires_at", { mode: "timestamp_ms" }).notNull(),
|
||||
});
|
||||
|
||||
@@ -10,7 +10,7 @@ export const refreshToken = sqliteTable(
|
||||
.notNull()
|
||||
.references(() => user.id),
|
||||
clientId: integer("client_id").references(() => client.id),
|
||||
expiresAt: integer("expires_at").notNull(), // Only used for cleanup
|
||||
expiresAt: integer("expires_at", { mode: "timestamp_ms" }).notNull(), // Only used for cleanup
|
||||
},
|
||||
(t) => ({
|
||||
unq: unique().on(t.userId, t.clientId),
|
||||
|
||||
Reference in New Issue
Block a user