import type { AxiosResponse, ResponseType, Method } from "axios"; import { uploadFile, uploadLargeFile, uploadDirectory, uploadDirectoryRequest, uploadSmallFile, uploadSmallFileRequest, uploadLargeFileRequest } from "./upload"; import { downloadFile, downloadFileHns, getSkylinkUrl, getHnsUrl, getHnsresUrl, getMetadata, getFileContent, getFileContentRequest, getFileContentHns, openFile, openFileHns, resolveHns, getFileContentBinary, getFileContentBinaryHns } from "./download"; import { pinSkylink } from "./pin"; import { RevisionNumberCache } from "./revision_cache"; import { loadMySky } from "./mysky"; import { extractDomain, getFullDomainUrl } from "./mysky/utils"; import { Headers } from "./request"; /** * Custom client options. * * @property [APIKey] - Authentication password to use for a single Skynet node. * @property [skynetApiKey] - Authentication API key to use for a Skynet portal (sets the "Skynet-Api-Key" header). * @property [customUserAgent] - Custom user agent header to set. * @property [customCookie] - Custom cookie header to set. WARNING: the Cookie header cannot be set in browsers. This is meant for usage in server contexts. * @property [onDownloadProgress] - Optional callback to track download progress. * @property [onUploadProgress] - Optional callback to track upload progress. * @property [loginFn] - A function that, if set, is called when a 401 is returned from the request before re-trying the request. */ export declare type CustomClientOptions = { APIKey?: string; skynetApiKey?: string; customUserAgent?: string; customCookie?: string; onDownloadProgress?: (progress: number, event: ProgressEvent) => void; onUploadProgress?: (progress: number, event: ProgressEvent) => void; loginFn?: (config?: RequestConfig) => Promise; }; /** * Config options for a single request. * * @property endpointPath - The endpoint to contact. * @property [data] - The data for a POST request. * @property [url] - The full url to contact. Will be computed from the portalUrl and endpointPath if not provided. * @property [method] - The request method. * @property [headers] - Any request headers to set. * @property [subdomain] - An optional subdomain to add to the URL. * @property [query] - Query parameters. * @property [extraPath] - An additional path to append to the URL, e.g. a 46-character skylink. * @property [responseType] - The response type. * @property [transformRequest] - A function that allows manually transforming the request. * @property [transformResponse] - A function that allows manually transforming the response. */ export declare type RequestConfig = CustomClientOptions & { endpointPath?: string; data?: FormData | Record; url?: string; method?: Method; headers?: Headers; subdomain?: string; query?: { [key: string]: string | undefined; }; extraPath?: string; responseType?: ResponseType; transformRequest?: (data: unknown) => string; transformResponse?: (data: string) => Record; }; /** * The Skynet Client which can be used to access Skynet. */ export declare class SkynetClient { customOptions: CustomClientOptions; protected initialPortalUrl: string; protected static resolvedPortalUrl?: Promise; protected customPortalUrl?: string; uploadFile: typeof uploadFile; protected uploadSmallFile: typeof uploadSmallFile; protected uploadSmallFileRequest: typeof uploadSmallFileRequest; protected uploadLargeFile: typeof uploadLargeFile; protected uploadLargeFileRequest: typeof uploadLargeFileRequest; uploadDirectory: typeof uploadDirectory; protected uploadDirectoryRequest: typeof uploadDirectoryRequest; downloadFile: typeof downloadFile; downloadFileHns: typeof downloadFileHns; getSkylinkUrl: typeof getSkylinkUrl; getHnsUrl: typeof getHnsUrl; getHnsresUrl: typeof getHnsresUrl; getMetadata: typeof getMetadata; getFileContent: typeof getFileContent; getFileContentBinary: typeof getFileContentBinary; protected getFileContentRequest: typeof getFileContentRequest; getFileContentHns: typeof getFileContentHns; getFileContentBinaryHns: typeof getFileContentBinaryHns; openFile: typeof openFile; openFileHns: typeof openFileHns; resolveHns: typeof resolveHns; pinSkylink: typeof pinSkylink; extractDomain: typeof extractDomain; getFullDomainUrl: typeof getFullDomainUrl; loadMySky: typeof loadMySky; file: { getJSON: (userID: string, path: string, customOptions?: import("./skydb_v2").CustomGetJSONOptions | undefined) => Promise; getEntryData: (userID: string, path: string, customOptions?: import("./registry").CustomGetEntryOptions | undefined) => Promise; getEntryLink: (userID: string, path: string) => Promise; getJSONEncrypted: (userID: string, pathSeed: string, customOptions?: import("./skydb_v2").CustomGetJSONOptions | undefined) => Promise; }; db: { getJSON: (publicKey: string, dataKey: string, customOptions?: import("./skydb_v2").CustomGetJSONOptions | undefined) => Promise; setJSON: (privateKey: string, dataKey: string, json: import(".").JsonData, customOptions?: import("./skydb_v2").CustomSetJSONOptions | undefined) => Promise; deleteJSON: (privateKey: string, dataKey: string, customOptions?: import("./skydb_v2").CustomSetEntryDataOptions | undefined) => Promise; getRawBytes: (publicKey: string, dataKey: string, customOptions?: import("./skydb_v2").CustomGetJSONOptions | undefined) => Promise; setDataLink: (privateKey: string, dataKey: string, dataLink: string, customOptions?: import("./skydb_v2").CustomSetEntryDataOptions | undefined) => Promise; getEntryData: (publicKey: string, dataKey: string, customOptions?: import("./registry").CustomGetEntryOptions | undefined) => Promise; setEntryData: (privateKey: string, dataKey: string, data: Uint8Array, customOptions?: import("./skydb_v2").CustomSetEntryDataOptions | undefined) => Promise; deleteEntryData: (privateKey: string, dataKey: string, customOptions?: import("./skydb_v2").CustomSetEntryDataOptions | undefined) => Promise; }; dbV2: { getJSON: (publicKey: string, dataKey: string, customOptions?: import("./skydb_v2").CustomGetJSONOptions | undefined) => Promise; setJSON: (privateKey: string, dataKey: string, json: import(".").JsonData, customOptions?: import("./skydb_v2").CustomSetJSONOptions | undefined) => Promise; deleteJSON: (privateKey: string, dataKey: string, customOptions?: import("./skydb_v2").CustomSetEntryDataOptions | undefined) => Promise; getRawBytes: (publicKey: string, dataKey: string, customOptions?: import("./skydb_v2").CustomGetJSONOptions | undefined) => Promise; setDataLink: (privateKey: string, dataKey: string, dataLink: string, customOptions?: import("./skydb_v2").CustomSetEntryDataOptions | undefined) => Promise; getEntryData: (publicKey: string, dataKey: string, customOptions?: import("./registry").CustomGetEntryOptions | undefined) => Promise; setEntryData: (privateKey: string, dataKey: string, data: Uint8Array, customOptions?: import("./skydb_v2").CustomSetEntryDataOptions | undefined) => Promise; deleteEntryData: (privateKey: string, dataKey: string, customOptions?: import("./skydb_v2").CustomSetEntryDataOptions | undefined) => Promise; revisionNumberCache: RevisionNumberCache; }; registry: { getEntry: (publicKey: string, dataKey: string, customOptions?: import("./registry").CustomGetEntryOptions | undefined) => Promise; getEntryUrl: (publicKey: string, dataKey: string, customOptions?: import("./registry").CustomGetEntryOptions | undefined) => Promise; getEntryLink: (publicKey: string, dataKey: string, customOptions?: import("./registry").CustomGetEntryOptions | undefined) => Promise; setEntry: (privateKey: string, entry: import("./registry").RegistryEntry, customOptions?: import("./registry").CustomSetEntryOptions | undefined) => Promise; postSignedEntry: (publicKey: string, entry: import("./registry").RegistryEntry, signature: Uint8Array, customOptions?: import("./registry").CustomSetEntryOptions | undefined) => Promise; }; /** * The Skynet Client which can be used to access Skynet. * * @class * @param [initialPortalUrl] The initial portal URL to use to access Skynet, if specified. A request will be made to this URL to get the actual portal URL. To use the default portal while passing custom options, pass "". * @param [customOptions] Configuration for the client. */ constructor(initialPortalUrl?: string, customOptions?: CustomClientOptions); /** * Make the request for the API portal URL. * * @returns - A promise that resolves when the request is complete. */ initPortalUrl(): Promise; /** * Returns the API portal URL. Makes the request to get it if not done so already. * * @returns - the portal URL. */ portalUrl(): Promise; /** * Creates and executes a request. * * @param config - Configuration for the request. * @returns - The response from axios. * @throws - Will throw `ExecuteRequestError` if the request fails. This error contains the original Axios error. */ executeRequest(config: RequestConfig): Promise; /** * Gets the current server URL for the portal. You should generally use * `portalUrl` instead - this method can be used for detecting whether the * current URL is a server URL. * * @returns - The portal server URL. */ protected resolvePortalServerUrl(): Promise; /** * Make a request to resolve the provided `initialPortalUrl`. * * @returns - The portal URL. */ protected resolvePortalUrl(): Promise; } //# sourceMappingURL=client.d.ts.map