Files
quak/src/model/types.ts
sneak f81216333e Phase 5 red: collection and file decryption tests
10 tests covering decryptCollection (key + name decryption from raw
server JSON, type mapping, isShared, missing name, wrong key) and
decryptFile (key + metadata decryption, fileType number-to-string
mapping, file/thumbnail header passthrough, wrong key).

Adds src/model/types.ts with both raw (server) and decrypted (library)
type definitions. src/model/decrypt.ts has throwing stubs.
2026-05-13 17:12:46 -07:00

75 lines
1.6 KiB
TypeScript

export type Microseconds = number;
export type CollectionType =
| "album"
| "folder"
| "favorites"
| "uncategorized"
| "unknown";
export interface Collection {
id: number;
ownerID: number;
key: Uint8Array;
name: string;
type: CollectionType;
updationTime: Microseconds;
isShared: boolean;
}
export type FileType = "image" | "video" | "livePhoto" | "unknown";
export interface FileMetadata {
title: string;
fileType: FileType;
creationTime: Microseconds;
modificationTime: Microseconds;
latitude?: number;
longitude?: number;
hash?: string;
}
export interface FileBlob {
decryptionHeader: string;
size?: number;
}
export interface EnteFile {
id: number;
collectionID: number;
ownerID: number;
key: Uint8Array;
metadata: FileMetadata;
file: FileBlob;
thumbnail: FileBlob;
updationTime: Microseconds;
}
// Raw shapes as they arrive from the Ente API, before decryption.
export interface RawCollection {
id: number;
owner: { id: number };
encryptedKey: string;
keyDecryptionNonce: string;
encryptedName?: string;
nameDecryptionNonce?: string;
type: string;
updationTime: number;
isDeleted?: boolean;
}
export interface RawEnteFile {
id: number;
collectionID: number;
ownerID: number;
encryptedKey: string;
keyDecryptionNonce: string;
metadata: { encryptedData: string; decryptionHeader: string };
info?: { fileSize?: number; thumbSize?: number };
file: { decryptionHeader: string };
thumbnail: { decryptionHeader: string };
updationTime: number;
isDeleted?: boolean;
}