Enable downloading attachments from backup CDN

This commit is contained in:
trevor-signal 2024-05-02 13:11:34 -04:00 committed by GitHub
parent 2964006b79
commit 1e8047cf73
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 989 additions and 385 deletions

View file

@ -78,6 +78,14 @@ export type AttachmentType = {
textAttachment?: TextAttachmentType;
wasTooBig?: boolean;
incrementalMac?: string;
incrementalMacChunkSize?: number;
backupLocator?: {
mediaName: string;
cdnNumber?: number;
};
/** Legacy field. Used only for downloading old attachments */
id?: number;

View file

@ -4,6 +4,11 @@ import { z } from 'zod';
import { MIMETypeSchema, type MIMEType } from './MIME';
import type { AttachmentType } from './Attachment';
export enum MediaTier {
STANDARD = 'standard',
BACKUP = 'backup',
}
export const attachmentDownloadTypeSchema = z.enum([
'long-message',
'attachment',

View file

@ -89,3 +89,6 @@ export type JSONWithUnknownFields<Value> = Value extends Record<
: Value extends Array<infer E>
? ReadonlyArray<JSONWithUnknownFields<E>>
: Value;
export type WithRequiredProperties<T, P extends keyof T> = Omit<T, P> &
Required<Pick<T, P>>;

View file

@ -2,6 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
import type { BackupLevel } from '@signalapp/libsignal-client/zkgroup';
import type { GetBackupCDNCredentialsResponseType } from '../textsecure/WebAPI';
export type BackupCredentialType = Readonly<{
credential: string;
@ -18,3 +19,9 @@ export type BackupSignedPresentationType = Readonly<{
headers: BackupPresentationHeadersType;
level: BackupLevel;
}>;
export type BackupCdnReadCredentialType = Readonly<{
credentials: Readonly<GetBackupCDNCredentialsResponseType>;
retrievedAtMs: number;
cdnNumber: number;
}>;