import { messages } from "./errors.js"; import { PKCError } from "./pkc-error.js"; import type { CommunityIpfsType } from "./community/types.js"; import { CID } from "multiformats/cid"; import type { Multiaddr } from "@multiformats/multiaddr"; import type { KuboRpcClient } from "./types.js"; import type { AddOptions, AddResult, BlockPutOptions, BlockRmOptions, FilesRmOptions, FilesStatOptions, FilesStatResult, FilesWriteOptions, RoutingProvideOptions } from "kubo-rpc-client"; import type { DecryptedChallengeRequestMessageType, DecryptedChallengeRequestMessageTypeWithCommunityAuthor, DecryptedChallengeRequestMessageWithPostCommunityAuthor, DecryptedChallengeRequestMessageWithReplyCommunityAuthor, DecryptedChallengeRequestPublication, PublicationFromDecryptedChallengeRequest, PublicationWithCommunityAuthorFromDecryptedChallengeRequest } from "./pubsub-messages/types.js"; import EventEmitter from "events"; import { RemoteCommunity } from "./community/remote-community.js"; import { PKC } from "./pkc/pkc.js"; import Logger from "./logger.js"; import type { IPNSRecord } from "ipns"; export declare function timestamp(): number; export declare function createAbortError(message?: string): Error; export declare function isAbortError(error: unknown): error is Error; export declare function throwIfAbortSignalAborted(signal?: AbortSignal): void; export declare function interruptibleSleep({ ms, signal }: { ms: number; signal?: AbortSignal; }): { promise: Promise; wake: () => void; }; export declare function sleepUntilTimeoutOrAbort(ms: number, signal?: AbortSignal): Promise; export declare function raceAgainstAbort(promise: Promise, signal?: AbortSignal): Promise; export declare function replaceXWithY(obj: Record, x: any, y: any): any; export declare function removeNullUndefinedValues(obj: T): T; export declare function removeUndefinedValuesRecursively(obj: T): T; export declare function removeNullUndefinedEmptyObjectsValuesRecursively(obj: T): T; export declare const parseDbResponses: (obj: any) => any; export declare function shortifyAddress(address: string): string; export declare function shortifyCid(cid: string): string; export declare function delay(ms: number): Promise; export declare function firstResolve(promises: Promise[]): Promise; export declare function getErrorCodeFromMessage(message: string): keyof typeof messages; export declare function doesDomainAddressHaveCapitalLetter(domainAddress: string): boolean; export declare function getPostUpdateTimestampRange(postUpdates: CommunityIpfsType["postUpdates"], postTimestamp: number): string[]; export declare function isLinkValid(link: string): boolean; export declare function isLinkOfMedia(link: string): boolean; export declare function isLinkOfImage(link: string): boolean; export declare function isLinkOfVideo(link: string): boolean; export declare function isLinkOfAnimatedImage(link: string): boolean; export declare function isLinkOfAudio(link: string): boolean; export declare function contentContainsMarkdownImages(content: string): boolean; export declare function contentContainsMarkdownAudio(content: string): boolean; export declare function contentContainsMarkdownVideos(content: string): boolean; export declare function genToArray(gen: AsyncIterable): Promise; export { isStringDomain, isEthAliasDomain, normalizeEthAliasDomain } from "./domain-util.js"; export declare function areEquivalentCommunityAddresses(addressA: string, addressB: string): boolean; export declare function getEquivalentCommunityAddresses(address: string): string[]; export declare function isIpns(x: string): boolean; export declare function isIpfsCid(x: string): boolean; export declare function isIpfsPath(x: string): boolean; export declare function isIpnsPath(x: string): boolean; export type KuboRpcClientCreateOption = string | URL | Multiaddr | (Record & { url?: string | URL | Multiaddr; }); export declare function parseIpfsRawOptionToIpfsOptions(kuboRpcRawOption: KuboRpcClientCreateOption): KuboRpcClient["_clientOptions"]; export declare function deepMergeRuntimeFields(target: any, source: any): void; export declare function hideClassPrivateProps(_this: any): void; export declare function derivePublicationFromChallengeRequest>(request: T): T extends DecryptedChallengeRequestMessageTypeWithCommunityAuthor ? PublicationWithCommunityAuthorFromDecryptedChallengeRequest : PublicationFromDecryptedChallengeRequest; export declare function isRequestPubsubPublicationOfReply(request: DecryptedChallengeRequestMessageTypeWithCommunityAuthor): request is DecryptedChallengeRequestMessageWithReplyCommunityAuthor; export declare function isRequestPubsubPublicationOfPost(request: DecryptedChallengeRequestMessageTypeWithCommunityAuthor): request is DecryptedChallengeRequestMessageWithPostCommunityAuthor; export declare function resolveWhenPredicateIsTrue(options: { toUpdate: EventEmitter; predicate: () => Promise | boolean; eventName?: string; }): Promise; export declare function rejectWhenAbortSignalFires(opts: { abortSignal?: AbortSignal; error: () => PKCError; }): { promise: Promise; cleanup: () => void; }; export declare function rejectWhenCommunityStopsOrAborts(opts: { community: RemoteCommunity; abortSignal?: AbortSignal; }): { promise: Promise; cleanup: () => void; }; export declare function waitForUpdateInCommunityInstanceWithErrorAndTimeout(opts: { community: RemoteCommunity; timeoutMs: number; abortSignal?: AbortSignal; }): Promise; export declare function calculateIpfsCidV0(content: string): Promise; /** * converts a binary record key to a pubsub topic key */ export declare function binaryKeyToPubsubTopic(key: Uint8Array): string; export declare function ipnsNameToIpnsOverPubsubTopic(ipnsName: string): string; export declare const pubsubTopicToDhtKey: (pubsubTopic: string) => string; export declare const pubsubTopicToDhtKeyCid: (pubsubTopic: string) => CID; export declare function retryKuboBlockPutPinAndProvidePubsubTopic({ ipfsClient: kuboRpcClient, log, pubsubTopic, inputNumOfRetries, blockPutOptions, provideOptions }: { ipfsClient: Pick; log: Logger; pubsubTopic: string; inputNumOfRetries?: number; blockPutOptions?: BlockPutOptions; provideOptions?: RoutingProvideOptions; }): Promise; export declare function retryKuboIpfsAddAndProvide({ ipfsClient: kuboRpcClient, log, content, inputNumOfRetries, addOptions, provideOptions, provideInBackground }: { ipfsClient: Pick; log: Logger; content: string; inputNumOfRetries?: number; addOptions?: AddOptions; provideOptions?: RoutingProvideOptions; provideInBackground: boolean; }): Promise; export declare function retryKuboIpfsAdd({ ipfsClient: kuboRpcClient, log, content, inputNumOfRetries, options }: { ipfsClient: Pick; log: Logger; content: string; inputNumOfRetries?: number; options?: AddOptions; }): Promise; type KuboFilesWriteParameters = Parameters; export declare function writeKuboFilesWithTimeout({ ipfsClient: kuboRpcClient, log, path, content, inputNumOfRetries, options, timeoutMs }: { ipfsClient: Pick; log: Logger; path: KuboFilesWriteParameters[0]; content: KuboFilesWriteParameters[1]; inputNumOfRetries?: number; options?: FilesWriteOptions; timeoutMs?: number; }): Promise; export declare function removeBlocksFromKuboNode({ ipfsClient: kuboRpcClient, log, cids, inputNumOfRetries, options }: { ipfsClient: Pick; log: Logger; cids: string[]; inputNumOfRetries?: number; options?: BlockRmOptions; }): Promise; export declare function removeMfsFilesSafely({ kuboRpcClient, paths, log, inputNumOfRetries, rmOptions }: { kuboRpcClient: PKC["clients"]["kuboRpcClients"][string]; paths: string[]; log?: Logger; inputNumOfRetries?: number; rmOptions?: FilesRmOptions; }): Promise; export declare function statMfsPathSafely({ kuboRpcClient, path, statOptions, log, inputNumOfRetries }: { kuboRpcClient: PKC["clients"]["kuboRpcClients"][string]; path: string; statOptions?: FilesStatOptions; log?: Logger; inputNumOfRetries?: number; }): Promise; export declare const MAX_IPNS_RECORD_SIZE: number; export declare function getIpnsRecordInLocalKuboNode(kuboRpcClient: KuboRpcClient, ipnsName: string): Promise; export declare function fetchAndValidateIpnsRecordFromGateway(gatewayUrl: string, ipnsName: string, opts?: { abortSignal?: AbortSignal; recordContext?: Record; }): Promise; export declare function calculateStringSizeSameAsIpfsAddCidV0(content: string): Promise; export type NetworkErrorDetails = { name: string; message: string; code?: string; errno?: number; syscall?: string; address?: string; port?: number; causes?: NetworkErrorDetails[]; }; export declare function extractNetworkErrorDetails(err: unknown, depth?: number): NetworkErrorDetails | undefined;