import { D as Device, k as DiscoveryMode, A as AuthMode, S as SignalingMode, h as ClientOptions, E as ExplicitFileDataSendParams, I as ISignalingBackend, L as LocalDeviceInfo, l as RoomMember, m as RuntimeIdentity, n as SignalingEnvelope, o as DeviceStatusSnapshot, d as PeerSessionSnapshot, B as BackendPeerBiStream, p as BackendPeerUniStream, M as ManagedConnectionRecord, e as ResolvedPeerIdentity, q as DeviceEvent, r as DesiredPeerProjection, s as CoreClientBridgeHost, N as NativeConnectParams, t as NativeConnectResult, u as SignalingSession, v as SessionEvent, w as BackendConnectionState, x as NativeManagedSessionStartResult, G as GrantScope } from './ITransport-yaruAmx3.js'; import { B as BrowserProtocolStore, N as NamespaceDescriptor, p as IrohMutationReceipt, q as IrohDocEntry, A as AuthContext } from './types-D67HlF0p.js'; import { R as RuntimeCapabilities } from './capabilities-BwzPe51I.js'; interface NativeTrustToken { token: string; expiresAtMs: number; } /** Internal-only gateway record before normalization; includes namespace fields omitted from the public Device type. */ type RawDeviceDoc = Device & { appTag?: string; tag?: string; }; interface WasmBridgeOptions { apiKey?: string; discoveryMode?: DiscoveryMode; space?: string; spaceKey?: string; authMode?: AuthMode; signalingMode?: SignalingMode; projectId?: string; coordinationGateway?: ClientOptions['coordinationGateway']; coordinationAvenueOverride?: ClientOptions['coordinationAvenueOverride']; coordinationRoomGossipFanout?: ClientOptions['coordinationRoomGossipFanout']; attestationTokenProvider?: ClientOptions['attestationTokenProvider']; /** Internal host hint used by the provider-neutral gateway projection. */ coordinationPlatformType?: string; storagePrefix?: string; deviceIdPersistence?: 'persistent' | 'ephemeral'; endpointIdPersistence?: 'persistent' | 'ephemeral'; nodeIdPersistence?: 'persistent' | 'ephemeral'; localDeviceId?: string; deviceName?: string; turnCredentialsProvider?: () => Promise<{ iceServers?: RTCIceServer[]; } | null | undefined>; applicationCrypto?: ExplicitFileDataSendParams['applicationCrypto']; spaceAuth?: 'scoped-token'; } /** * WasmBridge is the browser host wrapper over the Rust/WASM runtime. * * Allowed: * - normalize JS/WASM binding shapes * - forward auth, discovery, signaling, and lifecycle calls into Rust * - expose typed browser-facing results * * Not allowed: * - become a second lifecycle engine * - invent peer identity or connect policy that is not backed by Rust * - normalize app-specific payload protocols into runtime behavior * * Source of truth: * - Rust/WASM owns transport/runtime connection state and lifecycle primitives * - The selected coordination provider owns browser delivery projections * - RuntimeClient owns app-facing orchestration across those surfaces */ declare class WasmBridge implements ISignalingBackend { private static readonly EXPLICIT_FILE_PROTOCOL_TYPE; private static readonly EXPLICIT_FILE_CHUNK_SIZE_BYTES; private static readonly MAX_EXPLICIT_TRANSFER_HEADER_BYTES; private static readonly FALLBACK_EXPLICIT_FILE_NAME; private static readonly MAX_EXPLICIT_FILE_NAME_CHARS; private static readonly FALLBACK_EXPLICIT_MIME_TYPE; private static readonly MAX_EXPLICIT_MIME_TYPE_CHARS; app: any | null; auth: any | null; private readonly appTag; protected options: { appTag: string; apiKey?: string; discoveryMode?: DiscoveryMode; space?: string; spaceKey?: string; authMode: AuthMode; signalingMode?: SignalingMode; projectId: string; coordinationGateway?: ClientOptions['coordinationGateway']; coordinationAvenueOverride?: ClientOptions['coordinationAvenueOverride']; coordinationRoomGossipFanout?: ClientOptions['coordinationRoomGossipFanout']; attestationTokenProvider?: ClientOptions['attestationTokenProvider']; coordinationPlatformType?: string; storagePrefix?: string; deviceIdPersistence?: 'persistent' | 'ephemeral'; endpointIdPersistence?: 'persistent' | 'ephemeral'; nodeIdPersistence?: 'persistent' | 'ephemeral'; localDeviceId?: string; deviceName?: string; strictMode?: boolean; turnCredentialsProvider?: () => Promise<{ iceServers?: RTCIceServer[]; } | null | undefined>; applicationCrypto?: ExplicitFileDataSendParams['applicationCrypto']; spaceTokenProvider?: ClientOptions['spaceTokenProvider']; spaceAuth?: 'scoped-token'; }; private spaceNamespaceIdPromise; private cachedSpaceNamespaceId; private coordinationHostAvailability; private authListeners; private persistenceReady; wasmClient: any; private readonly createdAtMs; private missingWasmWarnings; private readonly wasmReadyWarningDelayMs; private browserCoordinationSignaling; private readonly nativeTrustTokens; private lastObservedFirebaseUserId; private sessionReaders; protected authContext: { userId: string; token?: string | null; refreshToken?: string | null; customToken?: string | null; tokenProvider?: (forceRefresh?: boolean) => Promise; appCheckTokenProvider?: (forceRefresh?: boolean) => Promise; expiresAtMs?: number | null; } | null; private injectedBrowserAuthSessionActive; private readonly presenceManager; private hasSyncedAuthToWasmClient; private lastWasmAuthUserId; private lastWasmAuthToken; private lastDeliveredConnectionStates; private authScopedRuntimeGeneration; private coreClient; private readonly applicationRouteEscalations; private applicationRouteEscalationAttemptKeys; private applicationRouteEscalationUnsubscribe; private routeSubscriptionGeneration; private applicationRouteEscalationSubscriptionEpoch; constructor(options: WasmBridgeOptions); get tag(): string; capabilities(): RuntimeCapabilities; private static readonly WEB_DEVICE_ID_STORAGE_PREFIX; private static readonly EPHEMERAL_DEVICE_ID_TTL_MS; private getDeviceIdentityStorageKey; private getDeviceIdPersistenceMode; private isTicketOnlyMode; private usesProviderNeutralGrant; private createRandomDeviceId; protected resolveWebLogicalDeviceId(): string; private getDefaultBrowserDeviceName; getLocalDeviceInfo(): Promise; private getCoordinationSignaling; usesCoordinationGateway(): boolean; setCoordinationHostAvailability(input: { available: boolean; reason: string; }): void; /** Restore the existing gateway delivery subscription after a native host resumes. */ reconnectCoordinationAfterHostResume(): Promise; getCoordinationNativeTrustToken(forceRefresh?: boolean): Promise; invalidateCoordinationNativeTrustToken(): void; subscribeCoordinationNativeTrustToken(listener: (token: NativeTrustToken | null) => void, options?: { emitCurrent?: boolean; }): () => void; setCoordinationLocalDeviceId(deviceId: string): void; /** Internal native-host hint for provider-neutral roster presentation. */ setCoordinationPlatformType(platformType: string): void; setCoordinationExcludedPeers(excludedPeers: string[]): Promise; joinCoordinationRoom(roomId: string, nodeId: string, ticket: string): Promise; leaveCoordinationRoom(roomId: string): Promise; getCoordinationRoomMembers(roomId: string): Promise; watchCoordinationRoomMembers(roomId: string, callback: (members: RoomMember[]) => void): () => void; private withWebPresenceMetadata; setAuthContext(context: { userId: string; token?: string | null; refreshToken?: string | null; customToken?: string | null; tokenProvider?: (forceRefresh?: boolean) => Promise; appCheckTokenProvider?: (forceRefresh?: boolean) => Promise; expiresAtMs?: number | null; } | null): Promise; private ensureBrowserPlatformAuth; private syncWasmAuthToken; private toRuntimeIdentity; protected getCurrentUserId(): string | null; getCurrentUserIdForScope(): string | null; getAuthContext(): Readonly | null; protected isSpaceMode(): boolean; getResolvedOptions(): Readonly; protected getDiscoveryScopeId(): string | null; protected matchesTag(device: Pick): boolean; matchesLegacyOrCurrentTag(device: Pick): boolean; private stopSessionSubscriptions; private stopRuntimeAuthScopedLoops; stopAuthActivity(options?: { userId?: string | null; }): Promise; setWasmClient(client: any): void; initializePersistentIrohProtocols(store: BrowserProtocolStore): Promise; createPersistentIrohNamespace(generation: number, shareRevision: number): Promise; importPersistentIrohTicket(ticket: string, generation: number, shareRevision: number): Promise; sharePersistentIrohNamespace(namespaceId: string, writable: boolean): Promise; removePersistentIrohNamespace(namespaceId: string, generation: number, shareRevision: number): Promise; putPersistentIrohBytes(namespaceId: string, key: Uint8Array, value: Uint8Array): Promise; setPersistentIrohHash(namespaceId: string, key: Uint8Array, contentHash: string, contentLength: number): Promise; deletePersistentIrohPrefix(namespaceId: string, prefix: Uint8Array): Promise<{ removed: number; operationId: string; }>; queryPersistentIrohNamespace(namespaceId: string, keyPrefix: Uint8Array): Promise; hydratePersistentIrohBlob(contentHash: string): Promise; acknowledgePersistentIrohOutbox(operationId: string): Promise; flushPersistentIrohProtocols(): Promise; shutdownPersistentIrohProtocols(): Promise; private requirePersistentProtocolHost; private warnMissingWasmOnce; private waitForWasmClient; protected normalizeDevice(raw: Record, fallbackId?: string): Device; normalizeDeviceRecord(raw: Record, fallbackId?: string): Device; getResolvedWebLogicalDeviceId(): string; private normalizeDeviceStatusSnapshot; private normalizePeerSessionSnapshot; private toBackendConnectionStateFromPeerSession; private normalizeStateSnapshot; private stabilizeConnectionState; private sameConnectionState; private deliverConnectionState; private get browserPresenceLoopState(); private set browserPresenceLoopState(value); get currentUser(): RuntimeIdentity | null; onAuthChange(callback: (user: RuntimeIdentity | null) => void): () => void; checkForSSOToken(): Promise; waitForAuth(): Promise; signInAnonymously(): Promise; signInWithPluto(): Promise; signOut(): Promise; getTurnCredentials(): Promise; updatePresence(localNodeId: string, ticketStr: string, isOnline?: boolean, ttlMs?: number, metadata?: string, deviceNameOverride?: string): Promise; refreshLivePresence(localNodeId: string, ticketStr: string, metadata?: string, deviceNameOverride?: string): Promise; setOffline(localNodeId: string): Promise; updateDevice(deviceId: string, updates: { deviceName?: string; capabilities?: Device['capabilities']; metadata?: string; excludedPeers?: string[]; }): Promise; deleteDevice(deviceId: string): Promise; cleanupStaleDevices(): Promise; sendMessage(targetId: string, payload: string, state?: string, replyPayload?: string): Promise; pollMessages(targetId: string): Promise; searchDevices(excludeNodeId?: string): Promise; listDeviceStatus(): Promise; getPeerSession(id: string): Promise; listPeerSessions(): Promise; waitForSettledPeer(id: string, timeoutMs?: number): Promise; openPeerBi(id: string, timeoutMs?: number): Promise; openPeerNativeBi(id: string, label: string, timeoutMs?: number): Promise; openPeerBiRaw(id: string, timeoutMs?: number): Promise; openPeerUni(id: string, timeoutMs?: number): Promise; resolvePeerRecords(id: string): Promise; resolvePeerIdentity(id: string): Promise; onDevicesChange(callback: (devices: Device[]) => void, excludeNodeId?: string): () => void; subscribeDevices(userId: string): Promise>; startAutoConnect(userId: string, localDeviceId: string): Promise; startAutoConnectOnce(userId: string, localDeviceId: string): Promise; notifyDisconnectRequested(remoteNodeId: string): void; excludeAutoConnect(deviceId: string, excluded: boolean): Promise; disconnectDevice(deviceId: string): Promise; submitDesiredPeerProjection(revision: number, peers: DesiredPeerProjection[]): Promise; setCoreClient(client: CoreClientBridgeHost | null): void; private startApplicationRouteEscalationSubscription; private stopApplicationRouteEscalationSubscription; private retryManagedApplicationRouteEscalations; private escalateManagedApplicationRoute; connectToDevice(params: NativeConnectParams): Promise; forceReconnect(): void; startPresenceLoop(userId: string, localNodeId: string, deviceName: string, ticket: string, metadata?: string): void; private ensureSpaceNamespaceIdPromise; createSession(session: SignalingSession): Promise; updateSession(sessionId: string, updateData: any): Promise; subscribeSessions(localDeviceId: string): Promise>; getLocalDeviceId(): Promise; isConnected(node_id: string): Promise; private hasConnectedIndependentPeerRoute; getConnectionStates(): Promise; onStateChange(callback: (state: BackendConnectionState) => void): Promise<() => void> | (() => void); sendExplicitFilePath(connectionId: string, filePath: string, transferId?: string): Promise; private sanitizeExplicitFileName; private sanitizeExplicitMimeType; private assertExplicitTransferHeaderSize; private createWebRTCExplicitTransferId; private createWebRTCExplicitTransferFrame; sendExplicitFileData(params: ExplicitFileDataSendParams): Promise; getTransferHistory(limit?: number): Promise>; deleteTransferJob(jobId: string): Promise; watchFriendDevices(friendUserIds: string[], callback: (friendDevices: Map) => void): () => void; updateFriendTicket(friendTicket: string | null): Promise; } declare abstract class DelegatingRuntimeAdapter implements ISignalingBackend { protected readonly backend: ISignalingBackend; protected constructor(backend: ISignalingBackend); get currentUser(): RuntimeIdentity | null; setAuthContext(context: AuthContext | null): Promise | void; signInAnonymously(): Promise; signInWithPluto(): Promise; signOut(): Promise; stopAuthActivity(): Promise; usesCoordinationGateway(): boolean; joinCoordinationRoom(roomId: string, nodeId: string, ticket: string): Promise; leaveCoordinationRoom(roomId: string): Promise; getCoordinationRoomMembers(roomId: string): Promise; watchCoordinationRoomMembers(roomId: string, callback: (members: RoomMember[]) => void): () => void; getTurnCredentials(): Promise; updatePresence(localNodeId: string, ticketStr: string, isOnline: boolean, ttlMs: number, metadata?: string): Promise; refreshLivePresence(localNodeId: string, ticketStr: string, metadata?: string): Promise; setOffline(localNodeId: string): Promise; cleanupStaleDevices(): Promise; searchDevices(excludeNodeId?: string): Promise; listDeviceStatus(): Promise; getPeerSession(id: string): Promise; listPeerSessions(): Promise; waitForSettledPeer(id: string, timeoutMs?: number): Promise; resolvePeerIdentity(id: string): Promise; resolvePeerRecords(id: string): Promise; updateDevice(deviceId: string, updates: { deviceName?: string; capabilities?: Device['capabilities']; metadata?: string; }): Promise; deleteDevice(deviceId: string): Promise; onDevicesChange(callback: (devices: Device[]) => void, excludeNodeId?: string): () => void; onAuthChange(callback: (user: RuntimeIdentity | null) => void): () => void; checkForSSOToken(): Promise; waitForAuth(): Promise; sendMessage(targetId: string, payload: string, state?: string, replyPayload?: string): Promise; pollMessages(targetId: string): Promise; watchFriendDevices(friendUserIds: string[], callback: (friendDevices: Map) => void): () => void; updateFriendTicket(friendTicket: string | null): Promise; subscribeDevices(userId: string): Promise>; startAutoConnect(userId: string, localDeviceId: string): void; submitDesiredPeerProjection(revision: number, peers: DesiredPeerProjection[]): Promise; startPresenceLoop(userId: string, localNodeId: string, deviceName: string, ticket: string, metadata?: string): void; createSession(session: SignalingSession): Promise; updateSession(sessionId: string, updateData: any): Promise; subscribeSessions(localDeviceId: string): Promise>; forceReconnect(): void; getLocalDeviceId(): Promise; getLocalDeviceInfo(): Promise; updateDeviceName(deviceName: string): Promise; startNativeSession(options: { userId: string; deviceName?: string; localDeviceId?: string | null; metadata?: string; autoConnect?: boolean; presence?: boolean; }): Promise; notifyNetworkChange(options?: { reason?: string; }): Promise; getManagedNodeId(options?: { initializeIfMissing?: boolean; }): Promise; startPresence(userId: string, localNodeId: string, deviceName: string, ticket: string, metadata?: string): Promise; startAutoConnectOnce(userId: string, localDeviceId: string): Promise; getEndpointTicket(): Promise; getTicketWithToken(scope: GrantScope, maxConnections: number): Promise; registerSessionToken(token: string, scope: GrantScope, maxConnections: number, expiresAtMs?: number): Promise; revokeTokens(scope: GrantScope): Promise; openPeerBi(id: string, timeoutMs?: number): Promise; incoming_streams(): Promise>; isCurrentTransport(endpointId: string, transportStableId: bigint): Promise; openPeerNativeBi(id: string, label: string, timeoutMs?: number): Promise; openPeerBiRaw(id: string, timeoutMs?: number): Promise; openPeerUni(id: string, timeoutMs?: number): Promise; connectToDevice(params: NativeConnectParams): Promise; disconnectDevice(deviceId: string): Promise; excludeAutoConnect(deviceId: string, excluded: boolean): Promise; isConnected(nodeId: string): Promise; getConnectionStates(): Promise; onStateChange(callback: (state: BackendConnectionState) => void): Promise<() => void> | (() => void); /** @deprecated Use named channels or `openrtc-file-transfer`. */ sendExplicitFilePath(connectionId: string, filePath: string, transferId?: string): Promise; /** @deprecated Use named channels or `openrtc-file-transfer`. */ sendExplicitFileData(params: ExplicitFileDataSendParams): Promise; /** @deprecated Transfer history belongs to the consumer application. */ getTransferHistory(limit?: number): Promise>; /** @deprecated Transfer history belongs to the consumer application. */ deleteTransferJob(jobId: string): Promise; capabilities(): RuntimeCapabilities; onIncomingNativeMessage(callback: (connectionId: string, remoteNodeId: string | null, message: any) => void): Promise<() => void>; unwrap(): ISignalingBackend; /** * Forward setCoreClient() to the inner backend if it implements it. This * lets the core Client inject a reference into backends (e.g. WasmBridge) * that need to escalate transport-level dials into full Client.connect() * handshakes. */ setCoreClient(client: unknown): void; } export { DelegatingRuntimeAdapter as D, WasmBridge as W, type WasmBridgeOptions as a };