-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathverification.ts
More file actions
37 lines (34 loc) · 1.32 KB
/
verification.ts
File metadata and controls
37 lines (34 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { index, jsonb, pgTable, text, timestamp } from 'drizzle-orm/pg-core'
export const verificationTypes = [
'magic_link',
'link_email',
'oauth_state',
'change_email',
'oauth_link_state',
] as const
export type VerificationType = (typeof verificationTypes)[number]
export const verification = pgTable(
'verification',
{
id: text('id').primaryKey(),
type: text('type', { enum: verificationTypes }).default('magic_link').notNull(),
identifier: text('identifier').notNull(), // Email for magic_link/link_email; chain:address for wallet nonce
value: text('value').notNull(), // Token hash or nonce
tokenPlain: text('token_plain'), // Plain token for @test.ai when ALLOW_TEST (DB-backed, no fake outbox)
expiresAt: timestamp('expires_at').notNull(),
meta: jsonb('meta').$type<{
codeVerifier?: string
userId?: string
redirectUri?: string
}>(),
consumedAt: timestamp('consumed_at'),
createdAt: timestamp('created_at').defaultNow().notNull(),
updatedAt: timestamp('updated_at').defaultNow().notNull(),
},
table => [
index('verification_identifier_idx').on(table.identifier),
index('verification_expires_at_idx').on(table.expiresAt),
],
)
export type Verification = typeof verification.$inferSelect
export type NewVerification = typeof verification.$inferInsert