/** * Copyright 2023 Fluence Labs Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { z } from "zod"; /** * Peer ID's id as a base58 string (multihash/CIDv0). */ export type PeerIdB58 = string; declare const relaySchema: z.ZodObject<{ peerId: z.ZodString; multiaddr: z.ZodString; }, "strip", z.ZodTypeAny, { peerId: string; multiaddr: string; }, { peerId: string; multiaddr: string; }>; /** * Relay of the Fluence network specified as a pair of node's multiaddr and it's peer id */ export type Relay = z.infer; export declare const relayOptionsSchema: z.ZodUnion<[z.ZodString, z.ZodObject<{ peerId: z.ZodString; multiaddr: z.ZodString; }, "strip", z.ZodTypeAny, { peerId: string; multiaddr: string; }, { peerId: string; multiaddr: string; }>]>; /** * A relay in Fluence network a client can connect to. * Can be in the form of: * - string: multiaddr in string format * - Relay: relay structure, @see Relay */ export type RelayOptions = z.infer; /** * Fluence Peer's key pair types */ export type KeyTypes = "RSA" | "Ed25519" | "secp256k1"; declare const keyPairOptionsSchema: z.ZodObject<{ /** * Key pair type. Only Ed25519 is supported for now. */ type: z.ZodLiteral<"Ed25519">; /** * Key pair source. Could be byte array or generated randomly. */ source: z.ZodUnion<[z.ZodLiteral<"random">, z.ZodType]>; }, "strip", z.ZodTypeAny, { type: "Ed25519"; source: (Uint8Array | "random") & (Uint8Array | "random" | undefined); }, { type: "Ed25519"; source: (Uint8Array | "random") & (Uint8Array | "random" | undefined); }>; /** * Options to specify key pair used in Fluence Peer */ export type KeyPairOptions = z.infer; /** * Fluence JS Client connection states as string literals */ export declare const ConnectionStates: readonly ["disconnected", "connecting", "connected", "disconnecting"]; /** * Fluence JS Client connection states */ export type ConnectionState = (typeof ConnectionStates)[number]; /** * Public API of Fluence JS Client */ export interface IFluenceClient { /** * Connect to the Fluence network */ connect: () => Promise; /** * Disconnect from the Fluence network */ disconnect(): Promise; /** * Handle connection state changes. Immediately returns current connection state */ onConnectionStateChange(handler: (state: ConnectionState) => void): ConnectionState; /** * Return peer's public key as a base58 string (multihash/CIDv0). */ getPeerId(): string; /** * Return relay's public key as a base58 string (multihash/CIDv0). */ getRelayPeerId(): string; } export declare const configSchema: z.ZodObject<{ keyPair: z.ZodOptional; /** * Key pair source. Could be byte array or generated randomly. */ source: z.ZodUnion<[z.ZodLiteral<"random">, z.ZodType]>; }, "strip", z.ZodTypeAny, { type: "Ed25519"; source: (Uint8Array | "random") & (Uint8Array | "random" | undefined); }, { type: "Ed25519"; source: (Uint8Array | "random") & (Uint8Array | "random" | undefined); }>>; connectionOptions: z.ZodOptional; dialTimeoutMs: z.ZodOptional; maxInboundStreams: z.ZodOptional; maxOutboundStreams: z.ZodOptional; }, "strip", z.ZodTypeAny, { skipCheckConnection?: boolean | undefined; dialTimeoutMs?: number | undefined; maxInboundStreams?: number | undefined; maxOutboundStreams?: number | undefined; }, { skipCheckConnection?: boolean | undefined; dialTimeoutMs?: number | undefined; maxInboundStreams?: number | undefined; maxOutboundStreams?: number | undefined; }>>; defaultTtlMs: z.ZodOptional; CDNUrl: z.ZodOptional; debug: z.ZodOptional; }, "strip", z.ZodTypeAny, { printParticleId?: boolean | undefined; }, { printParticleId?: boolean | undefined; }>>; }, "strip", z.ZodTypeAny, { keyPair?: { type: "Ed25519"; source: (Uint8Array | "random") & (Uint8Array | "random" | undefined); } | undefined; connectionOptions?: { skipCheckConnection?: boolean | undefined; dialTimeoutMs?: number | undefined; maxInboundStreams?: number | undefined; maxOutboundStreams?: number | undefined; } | undefined; defaultTtlMs?: number | undefined; CDNUrl?: string | undefined; debug?: { printParticleId?: boolean | undefined; } | undefined; }, { keyPair?: { type: "Ed25519"; source: (Uint8Array | "random") & (Uint8Array | "random" | undefined); } | undefined; connectionOptions?: { skipCheckConnection?: boolean | undefined; dialTimeoutMs?: number | undefined; maxInboundStreams?: number | undefined; maxOutboundStreams?: number | undefined; } | undefined; defaultTtlMs?: number | undefined; CDNUrl?: string | undefined; debug?: { printParticleId?: boolean | undefined; } | undefined; }>; /** * Configuration used when initiating Fluence Client */ export type ClientConfig = z.infer; export {};