/** * 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 { PeerIdB58 } from "@fluencelabs/interfaces"; import type { PeerId } from "@libp2p/interface"; import { type Multiaddr } from "@multiformats/multiaddr"; import { Subject } from "rxjs"; import { IParticle } from "../particle/interfaces.js"; import { IConnection } from "./interfaces.js"; export declare const PROTOCOL_NAME = "/fluence/particle/2.0.0"; /** * Options to configure fluence relay connection */ export interface RelayConnectionConfig { /** * Peer id of the Fluence Peer */ peerId: PeerId; /** * Multiaddress of the relay to make connection to */ relayAddress: Multiaddr; /** * The dialing timeout in milliseconds */ dialTimeoutMs?: number; /** * The maximum number of inbound streams for the libp2p node. * Default: 1024 */ maxInboundStreams: number; /** * The maximum number of outbound streams for the libp2p node. * Default: 1024 */ maxOutboundStreams: number; } /** * Implementation for JS peers which connects to Fluence through relay node */ export declare class RelayConnection implements IConnection { private config; private relayAddress; private lib2p2Peer; private relayPeerId; constructor(config: RelayConnectionConfig); getRelayPeerId(): string; supportsRelay(): boolean; particleSource: Subject; start(): Promise; stop(): Promise; sendParticle(nextPeerIds: PeerIdB58[], particle: IParticle): Promise; private processIncomingMessage; private connect; }