decryptCollection now takes the full key material {masterKey,
publicKey, secretKey} and dispatches on keyDecryptionNonce: present
means an owned collection (secretbox under the master key), absent
means a shared collection (sealed box to our public key). Client
already held the keypair for unsealing the auth token, so it just
passes it through.
104 lines
2.7 KiB
TypeScript
104 lines
2.7 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;
|
|
magicMetadata?: Record<string, unknown>;
|
|
pubMagicMetadata?: Record<string, unknown>;
|
|
sharedMagicMetadata?: Record<string, unknown>;
|
|
}
|
|
|
|
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;
|
|
magicMetadata?: Record<string, unknown>;
|
|
pubMagicMetadata?: Record<string, unknown>;
|
|
file: FileBlob;
|
|
thumbnail: FileBlob;
|
|
updationTime: Microseconds;
|
|
}
|
|
|
|
// The key material a logged-in client holds, everything needed to decrypt
|
|
// any collection: the master key (secretbox for owned collection keys) and
|
|
// the X25519 keypair (sealed box for collection keys shared with us).
|
|
export interface KeyMaterial {
|
|
masterKey: Uint8Array;
|
|
publicKey: Uint8Array;
|
|
secretKey: Uint8Array;
|
|
}
|
|
|
|
// Raw shapes as they arrive from the Ente API, before decryption.
|
|
|
|
export interface RawCollection {
|
|
id: number;
|
|
owner: { id: number };
|
|
encryptedKey: string;
|
|
// Absent for collections shared with us: their encryptedKey is a
|
|
// sealed box to our public key, which embeds an ephemeral public key
|
|
// instead of using a nonce.
|
|
keyDecryptionNonce?: string;
|
|
encryptedName?: string;
|
|
nameDecryptionNonce?: string;
|
|
type: string;
|
|
updationTime: number;
|
|
isDeleted?: boolean;
|
|
magicMetadata?: RawMagicMetadata;
|
|
pubMagicMetadata?: RawMagicMetadata;
|
|
sharedMagicMetadata?: RawMagicMetadata;
|
|
}
|
|
|
|
export interface RawMagicMetadata {
|
|
version: number;
|
|
count: number;
|
|
data: string;
|
|
header: string;
|
|
}
|
|
|
|
export interface RawEnteFile {
|
|
id: number;
|
|
collectionID: number;
|
|
ownerID: number;
|
|
encryptedKey: string;
|
|
keyDecryptionNonce: string;
|
|
metadata: { encryptedData: string; decryptionHeader: string };
|
|
magicMetadata?: RawMagicMetadata;
|
|
pubMagicMetadata?: RawMagicMetadata;
|
|
info?: { fileSize?: number; thumbSize?: number };
|
|
file: { decryptionHeader: string };
|
|
thumbnail: { decryptionHeader: string };
|
|
updationTime: number;
|
|
isDeleted?: boolean;
|
|
}
|