mirror of
https://github.com/kmc7468/arkvault.git
synced 2026-02-04 08:06:56 +00:00
Zod 4 마이그레이션
This commit is contained in:
@@ -5,14 +5,14 @@ import type { ClientKeys } from "$lib/stores";
|
||||
const serializedClientKeysSchema = z.intersection(
|
||||
z.object({
|
||||
generator: z.literal("ArkVault"),
|
||||
exportedAt: z.string().datetime(),
|
||||
exportedAt: z.iso.datetime(),
|
||||
}),
|
||||
z.object({
|
||||
version: z.literal(1),
|
||||
encryptKey: z.string().base64().nonempty(),
|
||||
decryptKey: z.string().base64().nonempty(),
|
||||
signKey: z.string().base64().nonempty(),
|
||||
verifyKey: z.string().base64().nonempty(),
|
||||
encryptKey: z.base64().nonempty(),
|
||||
decryptKey: z.base64().nonempty(),
|
||||
signKey: z.base64().nonempty(),
|
||||
verifyKey: z.base64().nonempty(),
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
@@ -7,26 +7,26 @@ export const passwordChangeRequest = z.object({
|
||||
export type PasswordChangeRequest = z.input<typeof passwordChangeRequest>;
|
||||
|
||||
export const loginRequest = z.object({
|
||||
email: z.string().email(),
|
||||
email: z.email(),
|
||||
password: z.string().trim().nonempty(),
|
||||
});
|
||||
export type LoginRequest = z.input<typeof loginRequest>;
|
||||
|
||||
export const sessionUpgradeRequest = z.object({
|
||||
encPubKey: z.string().base64().nonempty(),
|
||||
sigPubKey: z.string().base64().nonempty(),
|
||||
encPubKey: z.base64().nonempty(),
|
||||
sigPubKey: z.base64().nonempty(),
|
||||
});
|
||||
export type SessionUpgradeRequest = z.input<typeof sessionUpgradeRequest>;
|
||||
|
||||
export const sessionUpgradeResponse = z.object({
|
||||
id: z.number().int().positive(),
|
||||
challenge: z.string().base64().nonempty(),
|
||||
id: z.int().positive(),
|
||||
challenge: z.base64().nonempty(),
|
||||
});
|
||||
export type SessionUpgradeResponse = z.output<typeof sessionUpgradeResponse>;
|
||||
|
||||
export const sessionUpgradeVerifyRequest = z.object({
|
||||
id: z.number().int().positive(),
|
||||
answerSig: z.string().base64().nonempty(),
|
||||
id: z.int().positive(),
|
||||
answerSig: z.base64().nonempty(),
|
||||
force: z.boolean().default(false),
|
||||
});
|
||||
export type SessionUpgradeVerifyRequest = z.input<typeof sessionUpgradeVerifyRequest>;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const categoryIdSchema = z.union([z.literal("root"), z.number().int().positive()]);
|
||||
export const categoryIdSchema = z.union([z.literal("root"), z.int().positive()]);
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const directoryIdSchema = z.union([z.literal("root"), z.number().int().positive()]);
|
||||
export const directoryIdSchema = z.union([z.literal("root"), z.int().positive()]);
|
||||
|
||||
@@ -3,34 +3,34 @@ import { z } from "zod";
|
||||
import { directoryIdSchema } from "./directory";
|
||||
|
||||
export const fileThumbnailUploadRequest = z.object({
|
||||
dekVersion: z.string().datetime(),
|
||||
contentIv: z.string().base64().nonempty(),
|
||||
dekVersion: z.iso.datetime(),
|
||||
contentIv: z.base64().nonempty(),
|
||||
});
|
||||
export type FileThumbnailUploadRequest = z.input<typeof fileThumbnailUploadRequest>;
|
||||
|
||||
export const fileUploadRequest = z.object({
|
||||
parent: directoryIdSchema,
|
||||
mekVersion: z.number().int().positive(),
|
||||
dek: z.string().base64().nonempty(),
|
||||
dekVersion: z.string().datetime(),
|
||||
hskVersion: z.number().int().positive(),
|
||||
contentHmac: z.string().base64().nonempty(),
|
||||
mekVersion: z.int().positive(),
|
||||
dek: z.base64().nonempty(),
|
||||
dekVersion: z.iso.datetime(),
|
||||
hskVersion: z.int().positive(),
|
||||
contentHmac: z.base64().nonempty(),
|
||||
contentType: z
|
||||
.string()
|
||||
.trim()
|
||||
.nonempty()
|
||||
.refine((value) => mime.getExtension(value) !== null), // MIME type
|
||||
contentIv: z.string().base64().nonempty(),
|
||||
name: z.string().base64().nonempty(),
|
||||
nameIv: z.string().base64().nonempty(),
|
||||
createdAt: z.string().base64().nonempty().optional(),
|
||||
createdAtIv: z.string().base64().nonempty().optional(),
|
||||
lastModifiedAt: z.string().base64().nonempty(),
|
||||
lastModifiedAtIv: z.string().base64().nonempty(),
|
||||
contentIv: z.base64().nonempty(),
|
||||
name: z.base64().nonempty(),
|
||||
nameIv: z.base64().nonempty(),
|
||||
createdAt: z.base64().nonempty().optional(),
|
||||
createdAtIv: z.base64().nonempty().optional(),
|
||||
lastModifiedAt: z.base64().nonempty(),
|
||||
lastModifiedAtIv: z.base64().nonempty(),
|
||||
});
|
||||
export type FileUploadRequest = z.input<typeof fileUploadRequest>;
|
||||
|
||||
export const fileUploadResponse = z.object({
|
||||
file: z.number().int().positive(),
|
||||
file: z.int().positive(),
|
||||
});
|
||||
export type FileUploadResponse = z.output<typeof fileUploadResponse>;
|
||||
|
||||
@@ -38,11 +38,11 @@ const categoryRouter = router({
|
||||
.input(
|
||||
z.object({
|
||||
parent: categoryIdSchema,
|
||||
mekVersion: z.number().int().positive(),
|
||||
dek: z.string().base64().nonempty(),
|
||||
mekVersion: z.int().positive(),
|
||||
dek: z.base64().nonempty(),
|
||||
dekVersion: z.date(),
|
||||
name: z.string().base64().nonempty(),
|
||||
nameIv: z.string().base64().nonempty(),
|
||||
name: z.base64().nonempty(),
|
||||
nameIv: z.base64().nonempty(),
|
||||
}),
|
||||
)
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
@@ -72,10 +72,10 @@ const categoryRouter = router({
|
||||
rename: roleProcedure["activeClient"]
|
||||
.input(
|
||||
z.object({
|
||||
id: z.number().int().positive(),
|
||||
id: z.int().positive(),
|
||||
dekVersion: z.date(),
|
||||
name: z.string().base64().nonempty(),
|
||||
nameIv: z.string().base64().nonempty(),
|
||||
name: z.base64().nonempty(),
|
||||
nameIv: z.base64().nonempty(),
|
||||
}),
|
||||
)
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
@@ -99,7 +99,7 @@ const categoryRouter = router({
|
||||
delete: roleProcedure["activeClient"]
|
||||
.input(
|
||||
z.object({
|
||||
id: z.number().int().positive(),
|
||||
id: z.int().positive(),
|
||||
}),
|
||||
)
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
@@ -116,7 +116,7 @@ const categoryRouter = router({
|
||||
files: roleProcedure["activeClient"]
|
||||
.input(
|
||||
z.object({
|
||||
id: z.number().int().positive(),
|
||||
id: z.int().positive(),
|
||||
recurse: z.boolean().default(false),
|
||||
}),
|
||||
)
|
||||
@@ -137,8 +137,8 @@ const categoryRouter = router({
|
||||
addFile: roleProcedure["activeClient"]
|
||||
.input(
|
||||
z.object({
|
||||
id: z.number().int().positive(),
|
||||
file: z.number().int().positive(),
|
||||
id: z.int().positive(),
|
||||
file: z.int().positive(),
|
||||
}),
|
||||
)
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
@@ -165,8 +165,8 @@ const categoryRouter = router({
|
||||
removeFile: roleProcedure["activeClient"]
|
||||
.input(
|
||||
z.object({
|
||||
id: z.number().int().positive(),
|
||||
file: z.number().int().positive(),
|
||||
id: z.int().positive(),
|
||||
file: z.int().positive(),
|
||||
}),
|
||||
)
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
|
||||
@@ -26,8 +26,8 @@ const clientRouter = router({
|
||||
register: roleProcedure["notClient"]
|
||||
.input(
|
||||
z.object({
|
||||
encPubKey: z.string().base64().nonempty(),
|
||||
sigPubKey: z.string().base64().nonempty(),
|
||||
encPubKey: z.base64().nonempty(),
|
||||
sigPubKey: z.base64().nonempty(),
|
||||
}),
|
||||
)
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
@@ -66,8 +66,8 @@ const clientRouter = router({
|
||||
verify: roleProcedure["notClient"]
|
||||
.input(
|
||||
z.object({
|
||||
id: z.number().int().positive(),
|
||||
answerSig: z.string().base64().nonempty(),
|
||||
id: z.int().positive(),
|
||||
answerSig: z.base64().nonempty(),
|
||||
}),
|
||||
)
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
|
||||
@@ -41,11 +41,11 @@ const directoryRouter = router({
|
||||
.input(
|
||||
z.object({
|
||||
parent: directoryIdSchema,
|
||||
mekVersion: z.number().int().positive(),
|
||||
dek: z.string().base64().nonempty(),
|
||||
mekVersion: z.int().positive(),
|
||||
dek: z.base64().nonempty(),
|
||||
dekVersion: z.date(),
|
||||
name: z.string().base64().nonempty(),
|
||||
nameIv: z.string().base64().nonempty(),
|
||||
name: z.base64().nonempty(),
|
||||
nameIv: z.base64().nonempty(),
|
||||
}),
|
||||
)
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
@@ -75,10 +75,10 @@ const directoryRouter = router({
|
||||
rename: roleProcedure["activeClient"]
|
||||
.input(
|
||||
z.object({
|
||||
id: z.number().int().positive(),
|
||||
id: z.int().positive(),
|
||||
dekVersion: z.date(),
|
||||
name: z.string().base64().nonempty(),
|
||||
nameIv: z.string().base64().nonempty(),
|
||||
name: z.base64().nonempty(),
|
||||
nameIv: z.base64().nonempty(),
|
||||
}),
|
||||
)
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
@@ -102,7 +102,7 @@ const directoryRouter = router({
|
||||
delete: roleProcedure["activeClient"]
|
||||
.input(
|
||||
z.object({
|
||||
id: z.number().int().positive(),
|
||||
id: z.int().positive(),
|
||||
}),
|
||||
)
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
|
||||
@@ -8,7 +8,7 @@ const fileRouter = router({
|
||||
get: roleProcedure["activeClient"]
|
||||
.input(
|
||||
z.object({
|
||||
id: z.number().int().positive(),
|
||||
id: z.int().positive(),
|
||||
}),
|
||||
)
|
||||
.query(async ({ ctx, input }) => {
|
||||
@@ -42,8 +42,8 @@ const fileRouter = router({
|
||||
listByHash: roleProcedure["activeClient"]
|
||||
.input(
|
||||
z.object({
|
||||
hskVersion: z.number().int().positive(),
|
||||
contentHmac: z.string().base64().nonempty(),
|
||||
hskVersion: z.int().positive(),
|
||||
contentHmac: z.base64().nonempty(),
|
||||
}),
|
||||
)
|
||||
.query(async ({ ctx, input }) => {
|
||||
@@ -61,10 +61,10 @@ const fileRouter = router({
|
||||
rename: roleProcedure["activeClient"]
|
||||
.input(
|
||||
z.object({
|
||||
id: z.number().int().positive(),
|
||||
id: z.int().positive(),
|
||||
dekVersion: z.date(),
|
||||
name: z.string().base64().nonempty(),
|
||||
nameIv: z.string().base64().nonempty(),
|
||||
name: z.base64().nonempty(),
|
||||
nameIv: z.base64().nonempty(),
|
||||
}),
|
||||
)
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
@@ -88,7 +88,7 @@ const fileRouter = router({
|
||||
delete: roleProcedure["activeClient"]
|
||||
.input(
|
||||
z.object({
|
||||
id: z.number().int().positive(),
|
||||
id: z.int().positive(),
|
||||
}),
|
||||
)
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
@@ -107,7 +107,7 @@ const fileRouter = router({
|
||||
thumbnail: roleProcedure["activeClient"]
|
||||
.input(
|
||||
z.object({
|
||||
id: z.number().int().positive(),
|
||||
id: z.int().positive(),
|
||||
}),
|
||||
)
|
||||
.query(async ({ ctx, input }) => {
|
||||
|
||||
@@ -17,8 +17,8 @@ const hskRouter = router({
|
||||
registerInitial: roleProcedure["activeClient"]
|
||||
.input(
|
||||
z.object({
|
||||
mekVersion: z.number().int().positive(),
|
||||
hsk: z.string().base64().nonempty(),
|
||||
mekVersion: z.int().positive(),
|
||||
hsk: z.base64().nonempty(),
|
||||
}),
|
||||
)
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
|
||||
@@ -37,8 +37,8 @@ const mekRouter = router({
|
||||
registerInitial: roleProcedure["pendingClient"]
|
||||
.input(
|
||||
z.object({
|
||||
mek: z.string().base64().nonempty(),
|
||||
mekSig: z.string().base64().nonempty(),
|
||||
mek: z.base64().nonempty(),
|
||||
mekSig: z.base64().nonempty(),
|
||||
}),
|
||||
)
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
|
||||
Reference in New Issue
Block a user