2024-09-01 19:22:00 +00:00
|
|
|
import { timestamps } from '$lib/server/api/common/utils/table.utils'
|
|
|
|
|
import { type InferSelectModel } from 'drizzle-orm'
|
|
|
|
|
import { pgTable, text, uuid } from 'drizzle-orm/pg-core'
|
|
|
|
|
import { usersTable } from './users.table'
|
2024-07-31 01:50:46 +00:00
|
|
|
|
2024-08-01 16:26:42 +00:00
|
|
|
export enum CredentialsType {
|
2024-07-31 01:50:46 +00:00
|
|
|
SECRET = 'secret',
|
|
|
|
|
PASSWORD = 'password',
|
|
|
|
|
TOTP = 'totp',
|
2024-09-01 19:22:00 +00:00
|
|
|
HOTP = 'hotp',
|
2024-07-31 01:50:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const credentialsTable = pgTable('credentials', {
|
|
|
|
|
id: uuid('id').primaryKey().defaultRandom(),
|
|
|
|
|
user_id: uuid('user_id')
|
|
|
|
|
.notNull()
|
|
|
|
|
.references(() => usersTable.id, { onDelete: 'cascade' }),
|
|
|
|
|
type: text('type').notNull().default(CredentialsType.PASSWORD),
|
|
|
|
|
secret_data: text('secret_data').notNull(),
|
2024-09-01 19:22:00 +00:00
|
|
|
...timestamps,
|
|
|
|
|
})
|
2024-08-15 23:25:41 +00:00
|
|
|
|
2024-09-01 19:22:00 +00:00
|
|
|
export type Credentials = InferSelectModel<typeof credentialsTable>
|