import { FileDialogOptions, DataTransferResponse, DropzoneEventData, TransferSpec, AsperaSdkTransfer, ReadAsArrayBufferResponse, ReadChunkAsArrayBufferResponse } from '../models/models'; import { HttpGatewayInfo } from './models'; /** * HTTP Gateway Core Logic * - File/Folder picking * - Starting and testing * * @remarks * Most logic is called directly by Desktop SDK functions * You may not need to import anything from this file. */ /** * Send a transfer update through the SDK * * @param transfer - Transsfer object to send to consumers */ export declare const sendTransferUpdate: (transfer: AsperaSdkTransfer) => void; /** * Initialize the HTTP Gateway after the /info response has been received and verified. * For v2 gateways, delegates to the old HTTP Gateway SDK. * For v3 gateways, sets up the iframe container for downloads. * * @param response - The /info response from the HTTP Gateway server * * @returns a promise that resolves when the HTTP Gateway is initialized */ export declare const initHttpGateway: (response: HttpGatewayInfo) => Promise; /** * Set up the HTTP Gateway by normalizing the URL, fetching the /info endpoint, * and calling initHttpGateway with the response. * * @param url - The HTTP Gateway URL provided by the consumer * * @returns a promise that resolves when the HTTP Gateway is initialized */ export declare const setupHttpGateway: (url: string) => Promise; /** * Stop an in-progress HTTP Gateway transfer. * Aborts the underlying HTTP request and sets the transfer status to 'cancelled'. * * Note: If the download is being directly handled by the browser's download manager, this will return * an error. The user must cancel the download themselves in the browser's download manger. * * @param id - ID of the transfer * * @returns Promise indicating success */ export declare const httpStopTransfer: (id: string) => Promise; /** * Remove a transfer from HTTP Gateway systems * @param id - ID of the transfer * * @returns Promise indicating success */ export declare const httpRemoveTransfer: (id: string) => Promise; /** * Get the list of http gateway transfers * * @returns list of HTTP Gateway */ export declare const httpGetAllTransfers: () => AsperaSdkTransfer[]; /** * Get a HTTP Gateway transfer by ID * * @returns a transfer or null */ export declare const httpGetTransfer: (id: string) => AsperaSdkTransfer | null; /** * Create HTML input element for file picking */ export declare const createHtmlInputElement: () => HTMLInputElement; /** * Handle drop events and store files for HTTP Gateway * This works on top of desktop. */ export declare const handleHttpGatewayDrop: (items: DataTransferItemList, callback: (data: DropzoneEventData) => void, event: DragEvent) => void; /** * Open native browser file or folder picker for files * * @param options - File picker options * @param folder - Indicate if choosing folders * * @returns Promise that resolves with info about the files picked */ export declare const httpGatewaySelectFileFolderDialog: (options?: FileDialogOptions, folder?: boolean) => Promise; /** * Get a generic transfer object for HTTP Gateway transfers. * * @param transferSpec - TransferSpec being provided for the HTTP Gateway transfer * * @returns a transfer object to track status and send to consumers */ export declare const getSdkTransfer: (transferSpec: TransferSpec) => AsperaSdkTransfer; /** * Try to parse and get a useful string from API calls for HTTP Gateway * * @param error - Error from API call for Gateway * * @returns a string to use for errors */ export declare const getMessageFromError: (error: any) => { message: string; code: number; }; /** * Encodes a JSON string as a base64 string. * * The returned value uses the standard base64 alphabet and must not be assumed to be * URL safe. It may contain `+`, `/`, or `=` padding characters. * * This function first converts the input string to UTF-8 bytes using {@link TextEncoder}, then * converts those bytes into a binary string before passing it to {@link Window.btoa}. * * This extra conversion is necessary because `btoa()` only works for strings in which each * character occupies only one byte. So if you were to pass a string into `btoa()` containing * characters that occupy more than one byte, you will get an error. This is problematic because * a transfer spec could potentially have any number of Unicode characters. * * See the MDN `window.btoa()` documentation for more details: * https://developer.mozilla.org/en-US/docs/Web/API/Window/btoa#unicode_strings * * @param jsonString - The JSON string to encode. May contain arbitrary Unicode characters. * @returns A Base64-encoded representation of the UTF-8 bytes of `jsonString`. */ export declare const base64Encoding: (jsonString: string) => string; /** * Returns the specified file's contents as a base64-encoded string. * * Note: The maximum file size allowed is 50 MiB. * * @param path path to the file to read * * @returns a promise that resolves with the file data as a base64-encoded string and mime type */ export declare const httpGatewayReadAsArrayBuffer: (path: string) => Promise; /** * Read a chunk of a file as a base64-encoded string. * * Note: The maximum chunk size allowed is 50 MiB. * * @param path path to the file to read. For pure JS this will just be the filename. * @param offset offset to start reading the file, in bytes * @param chunkSize the size of the chunk to read, in bytes * * @returns a promise that resolves with the file chunk data as a base64-encoded string and mime type */ export declare const httpGatewayReadChunkAsArrayBuffer: (path: string, offset: number, chunkSize: number) => Promise;