import { type Message } from '@bufbuild/protobuf'; import type { AnyMessage, MethodInfo, PartialMessage, ServiceType } from '@bufbuild/protobuf'; import type { ContextValues, StreamResponse, Transport, UnaryResponse } from '@connectrpc/connect'; import { type Credentials } from '../app/viam-transport'; export interface DialOptions { credentials?: Credentials; webrtcOptions?: DialWebRTCOptions; externalAuthAddress?: string; externalAuthToEntity?: string; /** * `accessToken` allows a pre-authenticated client to dial with an authorization header. Direct * dial will have the access token appended to the "Authorization: Bearer" header. WebRTC dial * will appened it to the signaling server communication * * If enabled, other auth options have no affect. Eg. authEntity, credentials, * externalAuthAddress, externalAuthToEntity, webrtcOptions.signalingAccessToken */ accessToken?: string; /** * Set timeout in milliseconds for dialing. * * @deprecated Use `dialTimeoutMs` instead. */ dialTimeout?: number; /** Set timeout in milliseconds for dialing. */ dialTimeoutMs?: number; extraHeaders?: Headers; } export interface DialWebRTCOptions { disableTrickleICE: boolean; rtcConfig?: RTCConfiguration; /** * SignalingExternalAuthAddress is the address to perform external auth yet. This is unlikely to * be needed since the signaler is typically in the same place where authentication happens. */ signalingExternalAuthAddress?: string; /** * SignalingExternalAuthToEntity is the entity to authenticate for after externally * authenticating. This is unlikely to be needed since the signaler is typically in the same place * where authentication happens. */ signalingExternalAuthToEntity?: string; signalingCredentials?: Credentials; /** * `signalingAccessToken` allows a pre-authenticated client to dial with an authorization header * to the signaling server. This skips the Authenticate() request to the singaling server or * external auth but does not skip the AuthenticateTo() request to retrieve the credentials at the * external auth endpoint. * * If enabled, other auth options have no affect. Eg. authEntity, credentials, * signalingAuthEntity, signalingCredentials. */ signalingAccessToken?: string; additionalSdpFields?: Record; /** * When true, sets ICE transport policy to relay-only so only TURN candidates are used. Useful for * testing relay connectivity through a TURN server. */ forceRelay?: boolean; /** * When true, strips TURN servers from the ICE configuration so only host and server-reflexive * candidates are used. Useful for testing direct connectivity without relay fallback. */ forceP2P?: boolean; /** * When set, filters the signaling server's TURN list to only the server whose parsed URI matches * (compared by scheme, host, port, and transport — defaulting transport to UDP if unspecified). * Example: `"turn:turn.viam.com:443"` */ turnUri?: string; /** Overrides the scheme of the matched TURN URI (`"turn"` or `"turns"`). */ turnScheme?: 'turn' | 'turns'; /** Overrides the transport of the matched TURN URI (`"tcp"` or `"udp"`). */ turnTransport?: 'tcp' | 'udp'; /** Overrides the port of the matched TURN URI. */ turnPort?: number; /** * When true, the connection to the signaling server is made over plain HTTP (no TLS). Use this * when connecting to a robot running with `no_tls: true`. */ signalingInsecure?: boolean; } export type TransportFactory = (init: TransportInitOptions) => Transport; interface TransportInitOptions { baseUrl: string; } export declare const wrapTransportWithDebugLogging: (transport: T, connectionId: string) => T; export declare const dialDirect: (address: string, opts?: DialOptions, transportCredentialsInclude?: boolean) => Promise; export declare class AuthenticatedTransport implements Transport { protected readonly transport: Transport; protected readonly extraHeaders: Headers; constructor(opts: TransportInitOptions, defaultFactory: TransportFactory, extraHeaders: Headers); unary: = AnyMessage, O extends Message = AnyMessage>(service: ServiceType, method: MethodInfo, signal: AbortSignal | undefined, timeoutMs: number | undefined, header: HeadersInit | undefined, message: PartialMessage, contextValues?: ContextValues) => Promise>; stream: = AnyMessage, O extends Message = AnyMessage>(service: ServiceType, method: MethodInfo, signal: AbortSignal | undefined, timeoutMs: number | undefined, header: HeadersInit | undefined, input: AsyncIterable>, contextValues?: ContextValues) => Promise>; } export declare const cloneHeaders: (headers: HeadersInit | undefined) => Headers; export interface WebRTCConnection { transport: Transport; peerConnection: RTCPeerConnection; dataChannel: RTCDataChannel; } /** * DialWebRTC makes a connection to given host by signaling with the address provided. A Promise is * returned upon successful connection that contains a transport factory to use with gRPC client as * well as the WebRTC PeerConnection itself. Care should be taken with the PeerConnection and is * currently returned for experimental use. TODO(GOUT-7): figure out decent way to handle reconnect * on connection termination */ export declare const dialWebRTC: (signalingAddress: string, host: string, dialOpts?: DialOptions, transportCredentialsInclude?: boolean) => Promise; export declare const validateDialOptions: (opts?: DialOptions) => void; export {};