@etherna/sdk-js
Version:
Etherna SDKs for operations on the network
1,406 lines (1,368 loc) • 134 kB
TypeScript
import * as axios from 'axios';
import { AxiosError, AxiosInstance, AxiosRequestConfig } from 'axios';
import { ZodError, z } from 'zod';
import { Chunk as Chunk$1, ChunkedFile, ChunkAddress } from '@fairdatasociety/bmt-js';
export { makeChunkedFile } from '@fairdatasociety/bmt-js';
import { FFmpeg } from '@ffmpeg/ffmpeg';
import * as _noble_secp256k1 from '@noble/secp256k1';
import { Message } from 'js-sha3';
type HexString<Length = number> = string & {
readonly length: Length;
};
interface Bytes$1<Length extends number> extends Uint8Array {
readonly length: Length;
}
type EthAddress = `0x${string}`;
type EnsAddress = `${string}.eth`;
type BeeChain = {
name: "custom" | "gnosis" | "sepolia" | "goerli";
blockTime: number;
};
declare const CHAIN_BLOCK_TIME: {
readonly custom: 2;
readonly gnosis: 5;
readonly sepolia: 2;
readonly goerli: 15;
};
/**
* Add redundancy to the data being uploaded so that downloaders can download it with better UX.
* 0 value is default and does not add any redundancy to the file.
*/
declare const RedundancyLevels: {
readonly OFF: 0;
readonly MEDIUM: 1;
readonly STRONG: 2;
readonly INSANE: 3;
readonly PARANOID: 4;
};
/**
* Specify the retrieve strategy on redundant data.
* The possible values are NONE, DATA, PROX and RACE.
* Strategy NONE means no prefetching takes place.
* Strategy DATA means only data chunks are prefetched.
* Strategy PROX means only chunks that are close to the node are prefetched.
* Strategy RACE means all chunks are prefetched: n data chunks and k parity chunks. The first n chunks to arrive are used to reconstruct the file.
* Multiple strategies can be used in a fallback cascade if the swarm redundancy fallback mode is set to true.
* The default strategy is NONE, DATA, falling back to PROX, falling back to RACE
*/
declare const RedundancyStrategies: {
readonly NONE: 0;
readonly DATA: 1;
readonly PROX: 2;
readonly RACE: 3;
};
declare const ETHERNA_MAX_BATCH_DEPTH = 22;
declare const ETHERNA_WELCOME_BATCH_DEPTH = 20;
declare const ETHERNA_WELCOME_POSTAGE_LABEL: "default";
declare const EmptyAddress: EthAddress;
declare const EmptyReference: Reference;
declare const ZeroHashReference: BytesReference;
declare const MantarayRootPath = "/";
declare const MantarayWebsiteIndexDocumentPathKey = "website-index-document";
declare const MantarayWebsiteErrorDocumentPathKey = "website-error-document";
declare const MantarayEntryMetadataContentTypeKey = "Content-Type";
declare const MantarayEntryMetadataFilenameKey = "Filename";
declare const MantarayEntryMetadataFeedOwnerKey = "swarm-feed-owner";
declare const MantarayEntryMetadataFeedTopicKey = "swarm-feed-topic";
declare const MantarayEntryMetadataFeedTypeKey = "swarm-feed-type";
declare const MANIFEST_PREVIEW_PATH = "preview";
declare const MANIFEST_DETAILS_PATH = "details";
declare const SPAN_SIZE = 8;
declare const MAX_SPAN_LENGTH: number;
declare const SECTION_SIZE = 32;
declare const BRANCHES = 128;
declare const CHUNK_SIZE: number;
declare const MAX_CHUNK_PAYLOAD_SIZE = 4096;
declare const SEGMENT_SIZE = 32;
declare const SEGMENT_PAIR_SIZE: number;
declare const HASH_SIZE = 32;
declare const MIN_PAYLOAD_SIZE = 1;
declare const MAX_PAYLOAD_SIZE = 4096;
declare const CAC_SPAN_OFFSET = 0;
declare const CAC_PAYLOAD_OFFSET: number;
declare const IDENTIFIER_SIZE = 32;
declare const SIGNATURE_SIZE = 65;
declare const SOC_IDENTIFIER_OFFSET = 0;
declare const SOC_SIGNATURE_OFFSET: number;
declare const SOC_SPAN_OFFSET: number;
declare const SOC_PAYLOAD_OFFSET: number;
declare const ADDRESS_HEX_LENGTH = 64;
declare const PSS_TARGET_HEX_LENGTH_MAX = 6;
declare const PUBKEY_HEX_LENGTH = 66;
declare const BATCH_ID_HEX_LENGTH = 64;
declare const REFERENCE_HEX_LENGTH = 64;
declare const ENCRYPTED_REFERENCE_HEX_LENGTH = 128;
declare const REFERENCE_BYTES_LENGTH = 32;
declare const ENCRYPTED_REFERENCE_BYTES_LENGTH = 64;
declare const BUCKET_DEPTH = 16;
declare const STAMPS_DEPTH_MIN = 17;
declare const STAMPS_DEPTH_MAX = 41;
declare const TAGS_LIMIT_MIN = 1;
declare const TAGS_LIMIT_MAX = 1000;
declare const FEED_INDEX_HEX_LENGTH = 16;
type Index = number | Uint8Array | string;
type BatchId = HexString<typeof BATCH_ID_HEX_LENGTH>;
type BucketId = number;
type PostageBatchBucketsData = {
depth: number;
bucketDepth: number;
bucketUpperBound: number;
buckets: PostageBatchBucket[];
};
type PostageBatchBucket = {
bucketID: number;
collisions: number;
};
type Reference = HexString<typeof REFERENCE_HEX_LENGTH>;
type BeeAddress = Reference | `${Reference}/${string}`;
type BytesReference = Bytes$1<32 | 64>;
type PostageBatch = {
batchID: BatchId;
utilization: number;
usable: boolean;
label: string;
depth: number;
amount: string;
bucketDepth: number;
blockNumber: number;
immutableFlag: boolean;
/**
* The time (in seconds) remaining until the batch expires;
* -1 signals that the batch never expires;
* 0 signals that the batch has already expired.
*/
batchTTL: number;
exists: boolean;
};
type Tag = {
uid: number;
startedAt: string;
split: number;
seen: number;
stored: number;
sent: number;
synced: number;
};
type FeedUpdateHeaders = {
/**
* The current feed's index
*/
feedIndex: string;
/**
* The feed's index for next update.
* Only set for the latest update. If update is fetched using previous index, then this is an empty string.
*/
feedIndexNext: string;
};
type BucketCollisions = Map<BucketId, number>;
declare class StampCalculator {
bucketCollisions: Map<number, number>;
dirtyCollisions: Map<number, number>;
maxBucketCount: number;
/** Whether the bucket calculator has been seeded with collisions */
private _isFresh;
constructor(collisionsMap?: Record<BucketId, number> | PostageBatchBucket[]);
get minDepth(): number;
get isFresh(): boolean;
static getBucketId(reference: Reference): BucketId;
/**
* Merges two bucket calculators collisions
*
* @param bucket1 First bucket calculator
* @param bucket2 Second bucket calculator
* @returns A new bucket calculator with the merged collisions
*/
static merge(bucket1: StampCalculator, bucket2: StampCalculator): StampCalculator;
/**
* Seeds the bucket with existing bucket collisions
*
* @param collisionsMap
*/
seed(collisionsMap: Record<BucketId, number> | Map<number, number> | PostageBatchBucket[]): void;
/**
* Merges the current stamp calculator with another one
*
* @param collisionsMap
*/
merge(calculator: StampCalculator): void;
add(reference: Reference): void;
remove(reference: Reference): void;
}
declare const ErrorCodes: readonly ["NOT_FOUND", "SERVER_ERROR", "BAD_REQUEST", "UNAUTHORIZED", "PERMISSION_DENIED", "DUPLICATE", "JWT_MISSING_OR_EXPIRED", "MISSING_FUNDS", "MISSING_BATCH_ID", "MISSING_REFERENCE", "MISSING_SIGNER", "MISSING_WALLET", "OUTDATED_WALLET", "LOCKED_WALLET", "BUCKET_FILLED", "ABORTED_BY_USER", "INVALID_ARGUMENT", "INVALID_API_KEY", "NOT_IMPLEMENTED", "UNSUPPORTED_OPERATION", "TIMEOUT", "VALIDATION_ERROR", "ENCODING_ERROR", "ENCRYPTION_ERROR", "DECRYPTION_ERROR"];
type ErrorCode = (typeof ErrorCodes)[number];
declare class EthernaSdkError extends Error {
code: ErrorCode;
error?: Error;
axiosError?: AxiosError;
zodError?: ZodError;
constructor(code: ErrorCode, message: string, error?: Error | AxiosError | ZodError);
}
declare function getSdkError(err: unknown): EthernaSdkError;
declare function throwSdkError(err: unknown): never;
interface RequestOptions {
timeout?: number;
signal?: AbortSignal;
headers?: Record<string, string>;
}
interface BaseClientOptions {
apiPath?: string;
accessToken?: string;
accessTokenExpiresAt?: number;
disableAccessTokenTimeout?: boolean;
}
declare class BaseClient {
baseUrl: string;
request: AxiosInstance;
apiRequest: AxiosInstance;
accessToken?: string;
disableAccessTokenTimeout?: boolean;
private _apiPath?;
private accessTokenExpiresAt?;
private pendingResolvers;
/**
* @param options Client options
*/
constructor(baseUrl: string, options?: BaseClientOptions);
get apiPath(): string | undefined;
set apiPath(apiPath: string | undefined);
get apiUrl(): string;
updateAccessToken(accessToken: string | undefined, expiresAt?: number): void;
prepareAxiosConfig(opts?: RequestOptions): AxiosRequestConfig;
prepareFetchConfig(opts?: RequestOptions): RequestInit;
fetchSwaggerUrls(): Promise<{
url: string;
name: string;
}[] | null>;
fetchApiPath(): Promise<string>;
autoLoadApiPath(): Promise<void> | undefined;
awaitAccessToken(): Promise<unknown>;
}
type FeedType = "sequence" | "epoch";
interface FeedInfo {
topic: string;
owner: string;
type: FeedType;
}
interface ContentAddressedChunk {
readonly data: Uint8Array;
/** span bytes (8) */
span(): Uint8Array;
/** payload bytes (1-4096) */
payload(): Uint8Array;
address(): Uint8Array;
}
interface SingleOwnerChunk extends ContentAddressedChunk {
identifier(): Uint8Array;
signature(): Uint8Array;
owner(): Uint8Array;
}
interface Data extends Uint8Array {
/**
* Converts the binary data using UTF-8 decoding into string.
*/
text(): string;
/**
* Converts the binary data into hex-string.
*/
hex(): HexString;
/**
* Converts the binary data into string which is then parsed into JSON.
*/
json<T extends Record<string, unknown> | unknown[]>(): T;
}
type RedundancyStrategy = (typeof RedundancyStrategies)[keyof typeof RedundancyStrategies];
type RedundancyLevel = (typeof RedundancyLevels)[keyof typeof RedundancyLevels];
interface RequestUploadOptions extends RequestOptions {
batchId: BatchId;
/**
* If set to true, an ACT will be created for the uploaded data.
*/
act?: boolean;
actHistoryAddress?: Reference | string;
/**
* Will pin the data locally in the Bee node as well.
*
* Locally pinned data is possible to reupload to network if it disappear.
*
* @see [Bee docs - Pinning](https://docs.ethswarm.org/docs/develop/access-the-swarm/pinning)
* @see [Bee API reference - `POST /bzz`](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz/post)
*/
pin?: boolean;
/**
* Will encrypt the uploaded data and return longer hash which also includes the decryption key.
*
* @see [Bee docs - Store with Encryption](https://docs.ethswarm.org/docs/develop/access-the-swarm/store-with-encryption)
* @see [Bee API reference - `POST /bzz`](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz/post)
* @see Reference
*/
encrypt?: boolean;
/**
* Tags keep track of syncing the data with network. This option allows attach existing Tag UUID to the uploaded data.
*
* @see [Bee API reference - `POST /bzz`](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz/post)
* @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/develop/access-the-swarm/syncing)
* @link Tag
*/
tag?: number;
/**
* Determines if the uploaded data should be sent to the network immediately (eq. deferred=false) or in a deferred fashion (eq. deferred=true).
*
* With deferred style client uploads all the data to Bee node first and only then Bee node starts push the data to network itself. The progress of this upload can be tracked with tags.
* With non-deferred style client uploads the data to Bee which immediately starts pushing the data to network. The request is only finished once all the data was pushed through the Bee node to the network.
*
* In future there will be move to the non-deferred style and even the support for deferred upload will be removed from Bee itself.
*
* @default true
*/
deferred?: boolean;
/** Upload progress, ranging 0 to 100 */
onUploadProgress?(completion: number): void;
}
interface RequestDownloadOptions extends RequestOptions {
/**
* Specify the retrieve strategy on redundant data.
*/
redundancyStrategy?: RedundancyStrategy;
/**
* Specify if the retrieve strategies (chunk prefetching on redundant data) are used in a fallback cascade. The default is true.
*/
fallback?: boolean;
/**
* Specify the timeout for chunk retrieval. The default is 30 seconds.
*/
timeoutMs?: number;
actHistoryAddress?: Reference | string;
actTimestamp?: string | number;
gasLimit?: number;
gasPrice?: number;
/** Download progress, ranging 0 to 100 */
onDownloadProgress?(completion: number): void;
}
interface FileUploadOptions extends RequestUploadOptions {
size?: number;
contentType?: string;
filename?: string;
}
interface FileDownloadOptions extends RequestDownloadOptions {
maxResponseSize?: number;
}
interface FeedUpdateOptions extends RequestOptions {
index?: string;
at?: Date;
}
interface FeedUploadOptions extends RequestUploadOptions {
index?: string;
at?: Date;
}
interface AuthenticationOptions extends RequestOptions {
role?: "maintainer" | "creator" | "auditor" | "consumer";
expiry?: number;
}
interface ReferenceResponse {
reference: Reference;
}
interface EthernaGatewayCurrentUser {
etherAddress: string;
etherPreviousAddresses: string[];
username: string;
}
interface EthernaGatewayCredit {
isUnlimited: boolean;
balance: number;
}
interface EthernaGatewayBatchPreview {
batchId: BatchId;
ownerNodeId: string;
}
interface EthernaGatewayBatch extends Omit<PostageBatch, "batchID"> {
id: BatchId;
amountPaid: number;
normalisedBalance: number;
}
interface EthernaGatewayChainState {
block: number;
currentPrice: number;
sourceNodeId: string;
timeStamp: string;
totalAmount: number;
}
interface EthernaGatewayPin {
freePinningEndOfLife: string;
isPinned: boolean;
isPinningInProgress: boolean;
isPinningRequired: boolean;
}
interface EthernaGatewayWelcomeStatus {
isFreePostageBatchConsumed: boolean;
}
declare class Auth {
private instance;
private tokenExpiration;
constructor(instance: BeeClient);
get isAuthenticated(): boolean;
/**
* Authenticate with the Bee node
*
* @param username Bee node admin username (by default empty)
* @param password Bee node admin password
*/
authenticate(username: string, password: string, options?: AuthenticationOptions): Promise<string>;
refreshToken(token: string, options?: AuthenticationOptions): Promise<string | null>;
}
declare class Bytes {
private instance;
constructor(instance: BeeClient);
url(reference: string): string;
download(hash: string, options?: RequestDownloadOptions): Promise<Data>;
upload(data: Uint8Array, options: RequestUploadOptions): Promise<{
reference: Reference;
tagUid: any;
}>;
}
declare class Bzz {
private instance;
constructor(instance: BeeClient);
url(reference: string, path?: string): string;
download(hash: string, options?: FileDownloadOptions): Promise<{
data: Data;
name: string | null;
tagUid: number | undefined;
contentType: string | undefined;
}>;
downloadPath(hash: string, path?: string, options?: FileDownloadOptions): Promise<{
data: Data;
name: string | null;
tagUid: number | undefined;
contentType: string | undefined;
}>;
upload(data: Uint8Array | File | string, options: FileUploadOptions): Promise<{
reference: Reference;
tagUid: any;
}>;
head(path: string, options?: FileDownloadOptions): Promise<{
size: string | undefined;
contentType: string | undefined;
}>;
}
declare class ChainState {
private instance;
private lateBytePrice;
constructor(instance: BeeClient);
getCurrentPrice(options?: RequestOptions): Promise<string>;
}
declare class Chunk {
private instance;
constructor(instance: BeeClient);
download(hash: string, options?: RequestOptions): Promise<Data>;
upload(data: Uint8Array, options: RequestUploadOptions): Promise<{
reference: Reference;
}>;
/**
* Uploads multiple chunks in a single bulk request.
*
* The payload format for each chunk is:
* [chunk_size (2 bytes, little-endian ushort)][chunk_data (span + payload)][chunk_hash (32 bytes)]
*
* The API returns a single reference in the response.
* This is typically a root reference when uploading chunks that are part
* of a larger structure (e.g., a chunked file).
*
* @param chunks Array of chunk data (each chunk should include span + payload)
* @param options Upload options including required batchId
* @returns Object containing the reference returned by the API
*/
bulkUpload(chunks: Chunk$1[], options: RequestUploadOptions): Promise<{
reference: Reference;
}>;
}
declare class Feed {
private instance;
constructor(instance: BeeClient);
makeFeed(topicName: string, owner: EthAddress, type?: FeedType): FeedInfo;
makeFeedFromHex(topicHex: string, owner: EthAddress, type?: FeedType): FeedInfo;
makeReader(feed: FeedInfo): {
download(options?: FeedUpdateOptions): Promise<{
reference: Reference;
}>;
topic: string;
owner: string;
type: FeedType;
};
makeWriter(feed: FeedInfo): {
upload: (reference: string, options: FeedUploadOptions) => Promise<{
reference: Reference;
index: string;
}>;
};
createRootManifest(feed: FeedInfo, options: FeedUploadOptions): Promise<Reference>;
makeRootManifest(feed: FeedInfo): Promise<{
reference: Reference;
save: (options: RequestUploadOptions) => Promise<void>;
}>;
parseFeedFromRootManifest(reference: Reference, opts?: RequestOptions): Promise<FeedInfo>;
fetchLatestFeedUpdate(feed: FeedInfo): Promise<{
feedIndex: string;
feedIndexNext: string;
reference: Reference;
}>;
findNextIndex(feed: FeedInfo): Promise<string>;
private readFeedUpdateHeaders;
private makeFeedIdentifier;
private hashFeedIdentifier;
private makeSequentialFeedIdentifier;
private makeFeedIndexBytes;
}
declare class Offers {
private instance;
constructor(instance: BeeClient);
/**
* Get all resource offers
*
* @param reference Hash of the resource
* @param opts Request options
* @returns Addresses of users that are offering the resource
*/
downloadOffers(reference: Reference, opts?: RequestOptions): Promise<`0x${string}`[]>;
/**
* Get current user's offered resources
*
* @returns Reference list of offered resources
*/
downloadOfferedResources(opts?: RequestOptions): Promise<Reference[]>;
/**
* Check if multiple resources are offered
*
* @param references Hashes of the resources
* @param opts Request options
* @returns Addresses of users that are offering the resource
*/
batchAreOffered(references: Reference[], opts?: RequestOptions): Promise<Record<Reference, boolean>>;
/**
* Offer a resource
*
* @param reference Hash of the resource
* @param opts Request options
* @returns True if successfull
*/
offer(reference: Reference, opts?: RequestOptions): Promise<boolean>;
/**
* Cancel a resource offer
*
* @param reference Hash of the resource
* @param opts Request options
* @returns True if successfull
*/
cancelOffer(reference: Reference, opts?: RequestOptions): Promise<boolean>;
}
declare class Pins {
private instance;
constructor(instance: BeeClient);
isPinned(reference: string, options?: RequestOptions): Promise<boolean>;
download(options?: RequestOptions): Promise<{
references: Reference[];
}>;
pin(reference: string, options?: RequestOptions): Promise<axios.AxiosResponse<any, any, {}>>;
unpin(reference: string, options?: RequestOptions): Promise<axios.AxiosResponse<any, any, {}>>;
/**
* Check if pinning is enabled on the current host
*
* @returns True if pinning is enabled
*/
pinEnabled(): Promise<boolean>;
}
declare class Soc {
private instance;
constructor(instance: BeeClient);
download(identifier: Uint8Array, ownerAddress: EthAddress, options?: RequestOptions): Promise<SingleOwnerChunk>;
upload(identifier: Uint8Array, data: Uint8Array, options: RequestUploadOptions): Promise<{
reference: Reference;
}>;
/**
* Creates a single owner chunk object
*
* @param chunk A chunk object used for the span and payload
* @param identifier The identifier of the chunk
*/
makeSingleOwnerChunk(chunk: ContentAddressedChunk, identifier: Uint8Array): Promise<SingleOwnerChunk>;
private makeSOCAddress;
private makeSingleOwnerChunkFromData;
private recoverChunkOwner;
}
interface CreatePostageBatchOptions extends RequestOptions {
label?: string;
useWelcomeIfPossible?: boolean;
onStatusChange?: <T extends "pending-creation" | "created">(status: T, data: T extends "pending-creation" ? {
postageBatchRef: string | null;
} : T extends "created" ? {
batchId: BatchId;
} : never) => void;
}
interface DownloadPostageBatchOptions extends RequestOptions {
waitUntilUsable?: boolean;
waitUntil?: (batch: PostageBatch) => boolean;
}
interface FetchBestBatchIdOptions extends RequestOptions {
labelQuery?: string;
minDepth?: number;
collisions?: BucketCollisions;
}
interface TopupBatchOptions extends RequestOptions {
by: {
type: "amount";
amount: bigint | string;
} | {
type: "time";
seconds: number;
};
initialAmount?: bigint | string;
waitUntilUpdated?: boolean;
}
interface DiluteBatchOptions extends RequestOptions {
depth: number;
waitUntilUpdated?: boolean;
}
interface ExpandBatchOptions extends DiluteBatchOptions {
ttl?: number;
}
declare class Stamps {
private instance;
constructor(instance: BeeClient);
create(depth: number, amount: bigint | string, options?: CreatePostageBatchOptions): Promise<PostageBatch>;
create(depth: number, ttl: number, options?: CreatePostageBatchOptions): Promise<PostageBatch>;
download(batchId: BatchId, options?: DownloadPostageBatchOptions): Promise<PostageBatch>;
downloadAll(labelQuery?: string, options?: RequestOptions): Promise<(PostageBatch | EthernaGatewayBatchPreview)[]>;
downloadBuckets(batchId: BatchId, options?: RequestOptions): Promise<PostageBatchBucketsData>;
/**
* Find best usable batch to use.
* Use the option:
* - `minDepth` to filter batches with a minimum depth
* - `labelQuery` to filter batches by label
* - `stampCalculator` to provide the bucket collision to upload (best to find the batch with most buckets available)
*
* @param options
* @returns The best batch to use or null if no batch is found
*/
fetchBestBatch(options?: FetchBestBatchIdOptions): Promise<(PostageBatch & {
collisions?: BucketCollisions;
}) | null>;
/**
* Find best usable batchId to use.
* Use the option:
* - `minDepth` to filter batches with a minimum depth
* - `labelQuery` to filter batches by label
* - `stampCalculator` to provide the bucket collision to upload (best to find the batch with most buckets available)
*
* @param options
* @returns The best batchId to use or null if no batch is found
*/
fetchBestBatchId(options?: FetchBestBatchIdOptions): Promise<(BatchId & {
collisions?: BucketCollisions;
}) | null>;
/**
* Topup batch (increase TTL)
*
* @param batchId Id of the swarm batch
* @param byAmount Amount to add to the batch
*/
topup(batchId: BatchId, options: TopupBatchOptions): Promise<PostageBatch>;
/**
* Dillute batch (increase size)
*
* @param batchId Id of the swarm batch
* @param options Dilute options
*/
dilute(batchId: BatchId, options: DiluteBatchOptions): Promise<PostageBatch>;
/**
* (unofficial api) - Dilute a batch + Auto topup to keep the same TTL
*
* @param batchId Id of batch to extend
* @param options Dilute options
*/
expand(batchId: BatchId, options: ExpandBatchOptions): Promise<PostageBatch>;
isWelcomeConsumed(opts?: RequestOptions): Promise<boolean>;
private createWelcomeBatch;
private waitBatchValid;
private fetchIsFillableBatch;
}
declare class System {
private instance;
constructor(instance: BeeClient);
/**
* Get the current byte price
*
* @param opts Request options
* @returns Dollar price per single byte
*/
fetchCurrentBytePrice(opts?: RequestOptions): Promise<string>;
/**
* Fetch creation batch id
*
* @param referenceId Reference id of the batch
* @returns The created batch id if completed
*/
fetchPostageBatchRef(referenceId: string, opts?: RequestOptions): Promise<BatchId | null>;
}
declare class Tags {
private instance;
constructor(instance: BeeClient);
downloadAll(offset?: number, limit?: number, options?: RequestOptions): Promise<{
tags: Tag[];
}>;
download(uid: number, options?: RequestOptions): Promise<Tag>;
create(address: string, options?: RequestOptions): Promise<Tag>;
delete(uid: number, options?: RequestOptions): Promise<axios.AxiosResponse<any, any, {}>>;
}
declare class User {
private instance;
constructor(instance: BeeClient);
/**
* Get the current logged user's info
* @returns Gateway current user
*/
downloadCurrentUser(opts?: RequestOptions): Promise<EthernaGatewayCurrentUser>;
}
type SyncSigner = (digest: string | Uint8Array) => string;
type AsyncSigner = (digest: string | Uint8Array) => Promise<string>;
type Signer = {
sign: SyncSigner | AsyncSigner;
address: EthAddress;
};
interface BeeClientOptions extends BaseClientOptions {
type?: "bee" | "etherna";
signer?: Signer | string;
chain?: BeeChain;
}
declare class BeeClient extends BaseClient {
url: string;
signer?: Signer;
type: "bee" | "etherna";
chain: BeeChain;
auth: Auth;
bytes: Bytes;
bzz: Bzz;
chainstate: ChainState;
chunk: Chunk;
feed: Feed;
pins: Pins;
soc: Soc;
stamps: Stamps;
tags: Tags;
offers: Offers;
user: User;
system: System;
constructor(url: string, opts?: BeeClientOptions);
updateSigner(signer: Signer | EthAddress | string | undefined): void;
}
interface CreditLog {
amount: number;
author: string;
creationDateTime: string;
isApplied: boolean | null;
operationName: string;
reason: string | null;
userAddress: EthAddress;
}
interface CreditBalance {
balance: number;
isUnlimited: boolean;
}
declare class CreditUser {
private instance;
constructor(instance: EthernaCreditClient);
/**
* Get current credit balance
*/
fetchBalance(opts?: RequestOptions): Promise<CreditBalance>;
/**
* Get current user logs
*/
fetchLogs(page?: number, take?: number, opts?: RequestOptions): Promise<CreditLog[]>;
}
interface CreditClientOptions extends BaseClientOptions {
}
declare class EthernaCreditClient extends BaseClient {
user: CreditUser;
/**
* Init a credit client
* @param options Client options
*/
constructor(baseUrl: string, options?: CreditClientOptions);
}
declare const ImageSizeSchema: z.ZodCustom<`${number}w`, `${number}w`>;
declare const ImageTypeSchema: z.ZodDefault<z.ZodEnum<{
jpeg: "jpeg";
png: "png";
webp: "webp";
avif: "avif";
"jpeg-xl": "jpeg-xl";
}>>;
declare const ImageLegacySourcesSchema: z.ZodPipe<z.ZodRecord<z.ZodCustom<`${number}w`, `${number}w`>, z.ZodString>, z.ZodTransform<({
width: number;
type: "jpeg" | "png" | "webp" | "avif" | "jpeg-xl" | null;
path?: string | undefined;
reference?: Reference | undefined;
} & {
type: "jpeg" | "png" | "webp" | "avif" | "jpeg-xl";
})[], Record<`${number}w`, string>>>;
declare const ImageSourceBaseSchema: z.ZodObject<{
width: z.ZodNumber;
type: z.ZodNullable<z.ZodDefault<z.ZodEnum<{
jpeg: "jpeg";
png: "png";
webp: "webp";
avif: "avif";
"jpeg-xl": "jpeg-xl";
}>>>;
path: z.ZodOptional<z.ZodString>;
reference: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<Reference, string>>>;
}, z.core.$strip>;
declare const ImageSourceSchema: z.ZodPipe<z.ZodObject<{
width: z.ZodNumber;
type: z.ZodNullable<z.ZodDefault<z.ZodEnum<{
jpeg: "jpeg";
png: "png";
webp: "webp";
avif: "avif";
"jpeg-xl": "jpeg-xl";
}>>>;
path: z.ZodOptional<z.ZodString>;
reference: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<Reference, string>>>;
}, z.core.$strip>, z.ZodTransform<{
width: number;
type: "jpeg" | "png" | "webp" | "avif" | "jpeg-xl" | null;
path?: string | undefined;
reference?: Reference | undefined;
} & {
type: "jpeg" | "png" | "webp" | "avif" | "jpeg-xl";
}, {
width: number;
type: "jpeg" | "png" | "webp" | "avif" | "jpeg-xl" | null;
path?: string | undefined;
reference?: Reference | undefined;
}>>;
declare const ImageSourcesSchema: z.ZodArray<z.ZodPipe<z.ZodObject<{
width: z.ZodNumber;
type: z.ZodNullable<z.ZodDefault<z.ZodEnum<{
jpeg: "jpeg";
png: "png";
webp: "webp";
avif: "avif";
"jpeg-xl": "jpeg-xl";
}>>>;
path: z.ZodOptional<z.ZodString>;
reference: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<Reference, string>>>;
}, z.core.$strip>, z.ZodTransform<{
width: number;
type: "jpeg" | "png" | "webp" | "avif" | "jpeg-xl" | null;
path?: string | undefined;
reference?: Reference | undefined;
} & {
type: "jpeg" | "png" | "webp" | "avif" | "jpeg-xl";
}, {
width: number;
type: "jpeg" | "png" | "webp" | "avif" | "jpeg-xl" | null;
path?: string | undefined;
reference?: Reference | undefined;
}>>>;
declare const ImageSchema: z.ZodObject<{
aspectRatio: z.ZodNumber;
blurhash: z.ZodString;
sources: z.ZodUnion<[z.ZodArray<z.ZodPipe<z.ZodObject<{
width: z.ZodNumber;
type: z.ZodNullable<z.ZodDefault<z.ZodEnum<{
jpeg: "jpeg";
png: "png";
webp: "webp";
avif: "avif";
"jpeg-xl": "jpeg-xl";
}>>>;
path: z.ZodOptional<z.ZodString>;
reference: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<Reference, string>>>;
}, z.core.$strip>, z.ZodTransform<{
width: number;
type: "jpeg" | "png" | "webp" | "avif" | "jpeg-xl" | null;
path?: string | undefined;
reference?: Reference | undefined;
} & {
type: "jpeg" | "png" | "webp" | "avif" | "jpeg-xl";
}, {
width: number;
type: "jpeg" | "png" | "webp" | "avif" | "jpeg-xl" | null;
path?: string | undefined;
reference?: Reference | undefined;
}>>>, z.ZodPipe<z.ZodRecord<z.ZodCustom<`${number}w`, `${number}w`>, z.ZodString>, z.ZodTransform<({
width: number;
type: "jpeg" | "png" | "webp" | "avif" | "jpeg-xl" | null;
path?: string | undefined;
reference?: Reference | undefined;
} & {
type: "jpeg" | "png" | "webp" | "avif" | "jpeg-xl";
})[], Record<`${number}w`, string>>>]>;
}, z.core.$strip>;
type ImageSize = z.infer<typeof ImageSizeSchema>;
type ImageType = z.infer<typeof ImageTypeSchema>;
type ImageSource = z.infer<typeof ImageSourceSchema>;
type ImageLegacySources = z.infer<typeof ImageLegacySourcesSchema>;
type ImageSources = z.infer<typeof ImageSourcesSchema>;
type Image = z.infer<typeof ImageSchema>;
declare const MantarayNodeSchema: z.ZodSchema<ReadableMantarayNode>;
declare const MantarayForkSchema: z.ZodObject<{
prefix: z.ZodString;
node: z.ZodType<ReadableMantarayNode, unknown, z.core.$ZodTypeInternals<ReadableMantarayNode, unknown>>;
}, z.core.$strip>;
type ReadableMantarayNode = {
type?: number;
entry?: string;
contentAddress?: string;
metadata?: Record<string, string>;
forks: Record<string, MantarayNodeFork>;
};
type MantarayNodeFork = z.infer<typeof MantarayForkSchema>;
declare const PlaylistTypeEncryptedSchema: z.ZodEnum<{
private: "private";
protected: "protected";
}>;
declare const PlaylistTypeVisibleSchema: z.ZodLiteral<"public">;
declare const PlaylistTypeSchema: z.ZodUnion<readonly [z.ZodEnum<{
private: "private";
protected: "protected";
}>, z.ZodLiteral<"public">]>;
declare const PlaylistThumbSchema: z.ZodObject<{
blurhash: z.ZodString;
path: z.ZodString;
}, z.core.$strip>;
declare const PlaylistVideoSchema: z.ZodObject<{
r: z.ZodPipe<z.ZodString, z.ZodTransform<Reference, string>>;
t: z.ZodString;
a: z.ZodUnion<[z.ZodPipe<z.ZodNumber, z.ZodTransform<number, number>>, z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>]>;
p: z.ZodOptional<z.ZodUnion<[z.ZodPipe<z.ZodNumber, z.ZodTransform<number, number>>, z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>]>>;
}, z.core.$strip>;
declare const PlaylistPreviewSchema: z.ZodObject<{
id: z.ZodString;
type: z.ZodUnion<readonly [z.ZodEnum<{
private: "private";
protected: "protected";
}>, z.ZodLiteral<"public">]>;
passwordHint: z.ZodOptional<z.ZodString>;
name: z.ZodString;
owner: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
thumb: z.ZodNullable<z.ZodObject<{
blurhash: z.ZodString;
path: z.ZodString;
}, z.core.$strip>>;
createdAt: z.ZodUnion<[z.ZodPipe<z.ZodNumber, z.ZodTransform<number, number>>, z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>]>;
updatedAt: z.ZodUnion<[z.ZodPipe<z.ZodNumber, z.ZodTransform<number, number>>, z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>]>;
}, z.core.$strip>;
declare const PlaylistDetailsSchema: z.ZodObject<{
name: z.ZodOptional<z.ZodString>;
description: z.ZodOptional<z.ZodString>;
videos: z.ZodArray<z.ZodObject<{
r: z.ZodPipe<z.ZodString, z.ZodTransform<Reference, string>>;
t: z.ZodString;
a: z.ZodUnion<[z.ZodPipe<z.ZodNumber, z.ZodTransform<number, number>>, z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>]>;
p: z.ZodOptional<z.ZodUnion<[z.ZodPipe<z.ZodNumber, z.ZodTransform<number, number>>, z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>]>>;
}, z.core.$strip>>;
}, z.core.$strip>;
type PlaylistType = z.infer<typeof PlaylistTypeSchema>;
type PlaylistThumb = z.infer<typeof PlaylistThumbSchema>;
type PlaylistVideo = z.infer<typeof PlaylistVideoSchema>;
type PlaylistPreview = z.infer<typeof PlaylistPreviewSchema>;
type PlaylistDetails = z.infer<typeof PlaylistDetailsSchema>;
declare const UserPlaylistsSchema: z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<Reference, string>>>;
type UserPlaylists = z.infer<typeof UserPlaylistsSchema>;
/**
* / --> preview
* /preview
* /details
* /avatar/
* /480-png
* /1280-png
* /480-avif
* /1280-avif
* /cover/
* /480-png
* /1280-png
* /480-avif
* /1280-avif
*/
declare const ProfilePreviewSchema: z.ZodObject<{
address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
name: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
avatar: z.ZodNullable<z.ZodObject<{
aspectRatio: z.ZodNumber;
blurhash: z.ZodString;
sources: z.ZodUnion<[z.ZodArray<z.ZodPipe<z.ZodObject<{
width: z.ZodNumber;
type: z.ZodNullable<z.ZodDefault<z.ZodEnum<{
jpeg: "jpeg";
png: "png";
webp: "webp";
avif: "avif";
"jpeg-xl": "jpeg-xl";
}>>>;
path: z.ZodOptional<z.ZodString>;
reference: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<Reference, string>>>;
}, z.core.$strip>, z.ZodTransform<{
width: number;
type: "jpeg" | "png" | "webp" | "avif" | "jpeg-xl" | null;
path?: string | undefined;
reference?: Reference | undefined;
} & {
type: "jpeg" | "png" | "webp" | "avif" | "jpeg-xl";
}, {
width: number;
type: "jpeg" | "png" | "webp" | "avif" | "jpeg-xl" | null;
path?: string | undefined;
reference?: Reference | undefined;
}>>>, z.ZodPipe<z.ZodRecord<z.ZodCustom<`${number}w`, `${number}w`>, z.ZodString>, z.ZodTransform<({
width: number;
type: "jpeg" | "png" | "webp" | "avif" | "jpeg-xl" | null;
path?: string | undefined;
reference?: Reference | undefined;
} & {
type: "jpeg" | "png" | "webp" | "avif" | "jpeg-xl";
})[], Record<`${number}w`, string>>>]>;
}, z.core.$strip>>;
}, z.core.$strip>;
declare const ProfileDetailsSchema: z.ZodObject<{
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
cover: z.ZodNullable<z.ZodObject<{
aspectRatio: z.ZodNumber;
blurhash: z.ZodString;
sources: z.ZodUnion<[z.ZodArray<z.ZodPipe<z.ZodObject<{
width: z.ZodNumber;
type: z.ZodNullable<z.ZodDefault<z.ZodEnum<{
jpeg: "jpeg";
png: "png";
webp: "webp";
avif: "avif";
"jpeg-xl": "jpeg-xl";
}>>>;
path: z.ZodOptional<z.ZodString>;
reference: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<Reference, string>>>;
}, z.core.$strip>, z.ZodTransform<{
width: number;
type: "jpeg" | "png" | "webp" | "avif" | "jpeg-xl" | null;
path?: string | undefined;
reference?: Reference | undefined;
} & {
type: "jpeg" | "png" | "webp" | "avif" | "jpeg-xl";
}, {
width: number;
type: "jpeg" | "png" | "webp" | "avif" | "jpeg-xl" | null;
path?: string | undefined;
reference?: Reference | undefined;
}>>>, z.ZodPipe<z.ZodRecord<z.ZodCustom<`${number}w`, `${number}w`>, z.ZodString>, z.ZodTransform<({
width: number;
type: "jpeg" | "png" | "webp" | "avif" | "jpeg-xl" | null;
path?: string | undefined;
reference?: Reference | undefined;
} & {
type: "jpeg" | "png" | "webp" | "avif" | "jpeg-xl";
})[], Record<`${number}w`, string>>>]>;
}, z.core.$strip>>;
location: z.ZodOptional<z.ZodString>;
website: z.ZodOptional<z.ZodString>;
birthday: z.ZodOptional<z.ZodString>;
playlists: z.ZodCatch<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<Reference, string>>>>;
}, z.core.$strip>;
type ProfilePreview = z.infer<typeof ProfilePreviewSchema>;
type ProfileDetails = z.infer<typeof ProfileDetailsSchema>;
declare const quality: z.ZodCustom<`${number}p`, `${number}p`>;
/**
* / --> preview
* /preview
* /details
* /thumb/
* /480-png
* /1280-png
* /480-avif
* /1280-avif
* /sources/
* /720p
* /1080p
* /dash/
* /manifest.mpd
* /...
*/
declare const VideoSourceSchema: z.ZodPipe<z.ZodUnion<readonly [z.ZodObject<{
type: z.ZodOptional<z.ZodLiteral<"mp4">>;
quality: z.ZodCustom<`${number}p`, `${number}p`>;
path: z.ZodOptional<z.ZodString>;
reference: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<Reference, string>>>;
size: z.ZodNumber;
bitrate: z.ZodOptional<z.ZodNumber>;
}, z.core.$strip>, z.ZodObject<{
type: z.ZodEnum<{
dash: "dash";
hls: "hls";
}>;
path: z.ZodString;
size: z.ZodNumber;
}, z.core.$strip>]>, z.ZodTransform<{
quality: `${number}p`;
size: number;
type?: "mp4" | undefined;
path?: string | undefined;
reference?: Reference | undefined;
bitrate?: number | undefined;
} | {
type: "dash" | "hls";
path: string;
size: number;
}, {
quality: `${number}p`;
size: number;
type?: "mp4" | undefined;
path?: string | undefined;
reference?: Reference | undefined;
bitrate?: number | undefined;
} | {
type: "dash" | "hls";
path: string;
size: number;
}>>;
declare const VideoPreviewSchema: z.ZodObject<{
v: z.ZodOptional<z.ZodEnum<{
"1.0": "1.0";
1.1: "1.1";
1.2: "1.2";
"2.0": "2.0";
2.1: "2.1";
}>>;
title: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
createdAt: z.ZodUnion<[z.ZodPipe<z.ZodNumber, z.ZodTransform<number, number>>, z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>]>;
updatedAt: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodPipe<z.ZodNumber, z.ZodTransform<number, number>>, z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>]>>>;
ownerAddress: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
duration: z.ZodNumber;
thumbnail: z.ZodNullable<z.ZodObject<{
aspectRatio: z.ZodNumber;
blurhash: z.ZodString;
sources: z.ZodUnion<[z.ZodArray<z.ZodPipe<z.ZodObject<{
width: z.ZodNumber;
type: z.ZodNullable<z.ZodDefault<z.ZodEnum<{
jpeg: "jpeg";
png: "png";
webp: "webp";
avif: "avif";
"jpeg-xl": "jpeg-xl";
}>>>;
path: z.ZodOptional<z.ZodString>;
reference: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<Reference, string>>>;
}, z.core.$strip>, z.ZodTransform<{
width: number;
type: "jpeg" | "png" | "webp" | "avif" | "jpeg-xl" | null;
path?: string | undefined;
reference?: Reference | undefined;
} & {
type: "jpeg" | "png" | "webp" | "avif" | "jpeg-xl";
}, {
width: number;
type: "jpeg" | "png" | "webp" | "avif" | "jpeg-xl" | null;
path?: string | undefined;
reference?: Reference | undefined;
}>>>, z.ZodPipe<z.ZodRecord<z.ZodCustom<`${number}w`, `${number}w`>, z.ZodString>, z.ZodTransform<({
width: number;
type: "jpeg" | "png" | "webp" | "avif" | "jpeg-xl" | null;
path?: string | undefined;
reference?: Reference | undefined;
} & {
type: "jpeg" | "png" | "webp" | "avif" | "jpeg-xl";
})[], Record<`${number}w`, string>>>]>;
}, z.core.$strip>>;
}, z.core.$strip>;
declare const VideoCaptionSchema: z.ZodObject<{
label: z.ZodString;
lang: z.ZodString;
path: z.ZodString;
}, z.core.$strip>;
declare const VideoDetailsSchema: z.ZodObject<{
description: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
aspectRatio: z.ZodNumber;
sources: z.ZodArray<z.ZodPipe<z.ZodUnion<readonly [z.ZodObject<{
type: z.ZodOptional<z.ZodLiteral<"mp4">>;
quality: z.ZodCustom<`${number}p`, `${number}p`>;
path: z.ZodOptional<z.ZodString>;
reference: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<Reference, string>>>;
size: z.ZodNumber;
bitrate: z.ZodOptional<z.ZodNumber>;
}, z.core.$strip>, z.ZodObject<{
type: z.ZodEnum<{
dash: "dash";
hls: "hls";
}>;
path: z.ZodString;
size: z.ZodNumber;
}, z.core.$strip>]>, z.ZodTransform<{
quality: `${number}p`;
size: number;
type?: "mp4" | undefined;
path?: string | undefined;
reference?: Reference | undefined;
bitrate?: number | undefined;
} | {
type: "dash" | "hls";
path: string;
size: number;
}, {
quality: `${number}p`;
size: number;
type?: "mp4" | undefined;
path?: string | undefined;
reference?: Reference | undefined;
bitrate?: number | undefined;
} | {
type: "dash" | "hls";
path: string;
size: number;
}>>>;
captions: z.ZodDefault<z.ZodArray<z.ZodObject<{
label: z.ZodString;
lang: z.ZodString;
path: z.ZodString;
}, z.core.$strip>>>;
batchId: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<Reference, string>>>>;
personalData: z.ZodOptional<z.ZodString>;
}, z.core.$strip>;
type VideoQuality = z.infer<typeof quality>;
type VideoSource = z.infer<typeof VideoSourceSchema>;
type VideoPreview = z.infer<typeof VideoPreviewSchema>;
type VideoDetails = z.infer<typeof VideoDetailsSchema>;
type VideoCaption = z.infer<typeof VideoCaptionSchema>;
declare const SchemaVersionSchema: z.ZodLiteral<`${string}.${string}`>;
declare const BirthdaySchema: z.ZodString;
declare const SlicedStringSchema: (max: number, min?: number) => z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
declare const EthAddressSchema: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
declare const EnsAddressSchema: z.ZodPipe<z.ZodString, z.ZodTransform<`${string}.eth`, string>>;
declare const EthSafeAddressSchema: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
declare const BeeReferenceSchema: z.ZodPipe<z.ZodString, z.ZodTransform<Reference, string>>;
declare const BeeSafeReferenceSchema: z.ZodPipe<z.ZodNullable<z.ZodString>, z.ZodTransform<Reference, string | null>>;
declare const BeeAddressSchema: z.ZodUnion<[z.ZodPipe<z.ZodString, z.ZodTransform<Reference, string>>, z.ZodTemplateLiteral<`${string}/${string}`>]>;
declare const BatchIdSchema: z.ZodPipe<z.ZodString, z.ZodTransform<BatchId, string>>;
declare const NonEmptyRecordSchema: <Keys extends z.core.$ZodRecordKey, Values extends z.core.$ZodType>(key: Keys, value: Values) => z.ZodRecord<Keys, Values>;
declare const TimestampSchema: z.ZodUnion<[z.ZodPipe<z.ZodNumber, z.ZodTransform<number, number>>, z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>]>;
type SchemaVersion = z.infer<typeof SchemaVersionSchema>;
interface PaginatedResult<T> {
elements: T[];
currentPage: number;
maxPage: number;
pageSize: number;
totalElements: number;
}
interface IndexUser {
address: EthAddress;
creationDateTime: string;
identityManifest: string;
}
interface IndexCurrentUser {
address: EthAddress;
isSuperModerator: boolean;
}
interface IndexUserVideos extends IndexUser {
videos: IndexVideo[];
}
interface IndexVideo {
id: string;
creationDateTime: string;
ownerAddress: EthAddress;
lastValidManifest: IndexVideoManifest | null;
currentVoteValue: VoteValue | null;
totDownvotes: number;
totUpvotes: number;
}
interface IndexVideoPreview {
id: string;
title: string;
hash: Reference;
duration: number;
ownerAddress: EthAddress;
thumbnail: Image | null;
createdAt: number;
updatedAt: number;
indexUrl: string;
}
interface IndexVideoManifest extends Omit<IndexVideoPreview, "id"> {
batchId: BatchId | null;
aspectRatio: number | null;
hash: Reference;
description: string | null;
originalQuality: VideoQuality | null;
personalData: string | null;
sources: VideoSource[];
captions?: VideoCaption[];
}
interface IndexVideoCreation {
id: string;
creationDateTime: string;
encryptionKey: string | null;
encryptionType: IndexEncryptionType;
manifestHash: string;
}
interface IndexVideoValidation {
errorDetails: Array<{
errorMessage: string;
errorNumber: string | number;
}>;
hash: string;
isValid: boolean | null;
validationTime: string;
videoId: string | null;
}
interface IndexVideoComment {
id: string;
isFrozen: boolean;
isEditable: boolean;
ownerAddress: EthAddress;
textHistory: Record<string, string>;
videoId: string;
}
type VoteValue = "Up" | "Down" | "Neutral";
type IndexEncryptionType = "AES256" | "Plain";
interface IndexParameters {
commentMaxLength: number;
videoDescriptionMaxLength: number;
videoTitleMaxLength: number;
}
interface IIndexCommentsInterface {
editComment(id: string, newText: string, opts?: RequestOptions): Promise<IndexVideoComment>;
deleteComment(id: string, opts?: RequestOptions): Promise<boolean>;
}
declare class IndexComments implements IIndexCommentsInterface {
private instance;
constructor(instance: EthernaIndexClient);
/**
* Edit own comment
* @param id Id of the comment
* @param newText New text of the comment
* @param opts Request options
*/
editComment(id: string, newText: string, opts?: RequestOptions): Promise<IndexVideoComment>;
/**
* Delete own comment
* @param id Id of the comment
* @param opts Request options
*/
deleteComment(id: string, opts?: RequestOptions): Promise<boolean>;
}
interface IIndexModerationInterface {
deleteComment(id: string, opts?: RequestOptions): Promise<boolean>;
deleteVideo(id: string, opts?: RequestOptions): Promise<boolean>;
}
declare class IndexModeration implements IIndexModerationInterface {
private instance;
constructor(instance: EthernaIndexClient);
/**
* Delete any comment
* @param id Id of the comment
* @param opts Request options
*/
deleteComment(id: string, opts?: RequestOptions): Promise<boolean>;
/**
* Delete any video
* @param id Id of the video
* @param opts Request options
*/
deleteVideo(id: string, opts?: RequestOptions): Promise<boolean>;
}
interface IIndexSearchInterface {
fetchVideos(query: string, page?: number, take?: number, opts?