import { AppDetails } from '../shared'; import { HttpClient } from '../shared/http/client'; import { BasicAuth } from '../auth/types'; type Hash = string; export type BridgeUrl = string; export interface Shard { uuid: string; hash: Hash; } export interface ShardForMultipart extends Shard { UploadId: string; parts: { PartNumber: number; ETag: string; }[]; } export interface StartUploadResponse { uploads: { index: number; uuid: Shard['uuid']; url: string | null; urls: string[] | null; UploadId?: string; }[]; } export type FinishUploadResponse = BucketEntry; export interface BucketEntry { id: string; index: string; bucket: string; name: string; mimetype: string; created: Date; } export interface DownloadableShard { index: number; size: number; hash: Shard['hash']; url: string; } export interface GetDownloadLinksResponse { bucket: string; index: string; created: Date; shards: DownloadableShard[]; version?: number; size: number; hmac?: { value: string; type: 'sha512'; }; } export interface NetworkRequestConfig { client: HttpClient; appDetails: AppDetails; auth: BasicAuth; } type UploadPayload = { index: number; size: number; }; export type StartUploadPayload = { uploads: UploadPayload[]; }; export type HmacPayload = { type: 'sha512'; value: string; }; export type FinishUploadPayload = { index: string; shards: Shard[]; hmac?: HmacPayload; }; export type FinishMultipartUploadPayload = { index: string; shards: ShardForMultipart[]; hmac?: HmacPayload; }; export type UploadFileFunction = (url: string) => Promise; export type UploadFileMultipartFunction = (urls: string[]) => Promise<{ hash: Hash; parts: { PartNumber: number; ETag: string; }[]; }>; export type DownloadFileFunction = (downloadables: DownloadableShard[], fileInfo: GetDownloadLinksResponse) => Promise; export type BinaryData = { slice: (from: number, to: number) => BinaryData; toString(encoding: 'hex'): string; }; export declare enum BinaryDataEncoding { HEX = "hex" } export type ToBinaryDataFunction = (input: string, encoding: BinaryDataEncoding) => BinaryData; export declare enum SymmetricCryptoAlgorithm { AES256CTR = "AES256CTR" } export type Algorithm = { type: SymmetricCryptoAlgorithm; ivSize: number; }; export declare const ALGORITHMS: Record; type CryptoBase = { algorithm: Algorithm; randomBytes: (bytesLength: number) => BinaryData; computeHmac?: (key: BinaryData, shardHashes: string[]) => Promise; }; export type Crypto = CryptoBase & { validateMnemonic: (mnemonic: string) => boolean; generateFileKey: (mnemonic: string, bucketId: string, index: BinaryData | string) => Promise; }; export type CryptoWithBucketKey = CryptoBase & { generateFileKeyFromBucketKey: (bucketKey: Buffer, index: BinaryData) => Promise; }; export type EncryptFileFunction = (algorithm: SymmetricCryptoAlgorithm, key: BinaryData, iv: BinaryData) => Promise; export type DecryptFileFunction = (algorithm: SymmetricCryptoAlgorithm, key: BinaryData, iv: BinaryData, fileSize: number) => Promise; export {};