(feat): add cache package
All checks were successful
/ build-web (push) Successful in 7m26s
/ build-desktop (linux) (push) Successful in 11m29s
/ build-mobile (push) Successful in 19m15s
/ release (push) Successful in 3m3s

(feat): improve local storage security
(feat): move settings to dedicated settings package
This commit is contained in:
Alois 2026-07-11 22:08:01 +02:00
commit 790a1db788
54 changed files with 1984 additions and 947 deletions

27
packages/cache/src/schemas.ts vendored Normal file
View file

@ -0,0 +1,27 @@
import { mtp } from "@tensamin/shared/data";
import { z } from "zod";
export const accountIdSchema = z.string().min(1);
export const contactSchema = z.object({
LastMessageAt: z.number(),
UserId: z.number(),
LastMessage: z
.object({ Content: z.base64(), SenderId: z.number() })
.optional(),
Messages: z.array(mtp.MessageGet.response),
});
export const contactsSchema = z.array(contactSchema);
export const userProfileSchema = mtp.GetUserData.response;
// Content remains the protocol base64 ciphertext. This package never decrypts messages.
export const cachedMessageSchema = mtp.MessageGet.response;
export const conversationWindowSchema = z.object({
UserId: z.number(),
LastMessageAt: z.number(),
Messages: z.array(cachedMessageSchema),
});
export type Contact = z.infer<typeof contactSchema>;
export type UserProfile = z.infer<typeof userProfileSchema>;
export type CachedMessage = z.infer<typeof cachedMessageSchema>;
export type ConversationWindow = z.infer<typeof conversationWindowSchema>;