& so it begins
This commit is contained in:
48
packages/logic/domains/2fa/data.ts
Normal file
48
packages/logic/domains/2fa/data.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import * as v from "valibot";
|
||||
|
||||
export const startVerificationSchema = v.object({
|
||||
userId: v.string(),
|
||||
sessionId: v.string(),
|
||||
});
|
||||
|
||||
export const verifyCodeSchema = v.object({
|
||||
verificationToken: v.string(),
|
||||
code: v.string(),
|
||||
});
|
||||
|
||||
export const enable2FACodeSchema = v.object({
|
||||
code: v.string(),
|
||||
});
|
||||
|
||||
export const disable2FASchema = v.object({
|
||||
code: v.string(),
|
||||
});
|
||||
|
||||
export const twoFactorSchema = v.object({
|
||||
id: v.string(),
|
||||
secret: v.string(),
|
||||
backupCodes: v.array(v.string()),
|
||||
userId: v.string(),
|
||||
createdAt: v.date(),
|
||||
updatedAt: v.date(),
|
||||
});
|
||||
export type TwoFactor = v.InferOutput<typeof twoFactorSchema>;
|
||||
|
||||
export type TwoFaSessionStatus = "pending" | "verified" | "failed" | "expired";
|
||||
|
||||
export const twoFaSessionSchema = v.object({
|
||||
id: v.string(),
|
||||
userId: v.string(),
|
||||
sessionId: v.string(),
|
||||
verificationToken: v.string(),
|
||||
codeUsed: v.optional(v.string()),
|
||||
status: v.picklist(["pending", "verified", "failed", "expired"]),
|
||||
attempts: v.number(),
|
||||
maxAttempts: v.number(),
|
||||
verifiedAt: v.optional(v.date()),
|
||||
expiresAt: v.date(),
|
||||
createdAt: v.date(),
|
||||
ipAddress: v.string(),
|
||||
userAgent: v.string(),
|
||||
});
|
||||
export type TwoFaSession = v.InferOutput<typeof twoFaSessionSchema>;
|
||||
Reference in New Issue
Block a user