diff --git a/packages/backend/src/nest/socket/socket.service.ts b/packages/backend/src/nest/socket/socket.service.ts index 5d687fe2a2..524252e8d9 100644 --- a/packages/backend/src/nest/socket/socket.service.ts +++ b/packages/backend/src/nest/socket/socket.service.ts @@ -17,6 +17,7 @@ import { SaveCSRPayload, CommunityMetadata, } from '@quiet/types' +import cors, { CorsOptions } from 'cors' import EventEmitter from 'events' import { CONFIG_OPTIONS, SERVER_IO_PROVIDER } from '../const' import { ConfigOptions, ServerIoProviderTypes } from '../types' @@ -202,7 +203,6 @@ export class SocketService extends EventEmitter implements OnModuleInit { this.logger(`Creating network for community ${community.id}`) this.emit(SocketActionTypes.CREATE_NETWORK, community) }) - socket.on(SocketActionTypes.LEAVE_COMMUNITY, async () => { this.logger('Leaving community') this.emit(SocketActionTypes.LEAVE_COMMUNITY) diff --git a/packages/desktop/src/renderer/sagas/socket/socket.saga.ts b/packages/desktop/src/renderer/sagas/socket/socket.saga.ts index b0d55b1a3b..63964f1721 100644 --- a/packages/desktop/src/renderer/sagas/socket/socket.saga.ts +++ b/packages/desktop/src/renderer/sagas/socket/socket.saga.ts @@ -60,7 +60,7 @@ function subscribeSocketLifecycle(socket?: Socket) { console.log('closing socket connection') emit(socketActions.suspendConnection()) }) - return () => { } + return () => {} }) } diff --git a/packages/mobile/android/app/src/main/java/com/quietmobile/Backend/BackendWorker.kt b/packages/mobile/android/app/src/main/java/com/quietmobile/Backend/BackendWorker.kt index 6768c741a8..111310380a 100644 --- a/packages/mobile/android/app/src/main/java/com/quietmobile/Backend/BackendWorker.kt +++ b/packages/mobile/android/app/src/main/java/com/quietmobile/Backend/BackendWorker.kt @@ -90,7 +90,6 @@ class BackendWorker(private val context: Context, workerParams: WorkerParameters withContext(Dispatchers.IO) { // Get and store data port for usage in methods across the app val dataPort = Utils.getOpenPort(11000) - val socketIOSecret = "secret" // Init nodejs project launch { @@ -113,7 +112,7 @@ class BackendWorker(private val context: Context, workerParams: WorkerParameters * In any case, websocket won't connect until data server starts listening */ delay(WEBSOCKET_CONNECTION_DELAY) - startWebsocketConnection(dataPort, socketIOSecret) + startWebsocketConnection(dataPort) } val dataPath = Utils.createDirectory(context) @@ -123,7 +122,7 @@ class BackendWorker(private val context: Context, workerParams: WorkerParameters val platform = "mobile" - startNodeProjectWithArguments("bundle.cjs --torBinary $torBinary --dataPath $dataPath --dataPort $dataPort --platform $platform --socketIOSecret $socketIOSecret") + startNodeProjectWithArguments("bundle.cjs --torBinary $torBinary --dataPath $dataPath --dataPort $dataPort --platform $platform") } println("FINISHING BACKEND WORKER") @@ -191,10 +190,10 @@ class BackendWorker(private val context: Context, workerParams: WorkerParameters notificationHandler.notify(message, username) } - private fun startWebsocketConnection(port: Int, socketIOSecret: Any) { + private fun startWebsocketConnection(port: Int) { Log.d("WEBSOCKET CONNECTION", "Starting on $port") // Proceed only if data port is defined - val websocketConnectionPayload = WebsocketConnectionPayload(port, socketIOSecret) + val websocketConnectionPayload = WebsocketConnectionPayload(port) CommunicationModule.handleIncomingEvents( CommunicationModule.WEBSOCKET_CONNECTION_CHANNEL, Gson().toJson(websocketConnectionPayload), diff --git a/packages/mobile/android/app/src/main/java/com/quietmobile/Scheme/WebsocketConnectionPayload.kt b/packages/mobile/android/app/src/main/java/com/quietmobile/Scheme/WebsocketConnectionPayload.kt index 3098c08ca9..a5a490284a 100644 --- a/packages/mobile/android/app/src/main/java/com/quietmobile/Scheme/WebsocketConnectionPayload.kt +++ b/packages/mobile/android/app/src/main/java/com/quietmobile/Scheme/WebsocketConnectionPayload.kt @@ -1,6 +1,5 @@ package com.quietmobile.Scheme data class WebsocketConnectionPayload ( - val dataPort: Int, - val socketIOSecret: Any + val dataPort: Int ) diff --git a/packages/mobile/src/store/init/init.slice.ts b/packages/mobile/src/store/init/init.slice.ts index 8c37d05826..0542edd0f1 100644 --- a/packages/mobile/src/store/init/init.slice.ts +++ b/packages/mobile/src/store/init/init.slice.ts @@ -23,7 +23,6 @@ export interface InitCheckPayload { export interface WebsocketConnectionPayload { dataPort: number - socketIOSecret?: string } export interface CloseConnectionPayload { diff --git a/packages/mobile/src/store/init/startConnection/startConnection.saga.ts b/packages/mobile/src/store/init/startConnection/startConnection.saga.ts index b851520261..bf6b8a6410 100644 --- a/packages/mobile/src/store/init/startConnection/startConnection.saga.ts +++ b/packages/mobile/src/store/init/startConnection/startConnection.saga.ts @@ -2,27 +2,17 @@ import { io, Socket } from 'socket.io-client' import { put, call, cancel, fork, takeEvery, FixedTask } from 'typed-redux-saga' import { PayloadAction } from '@reduxjs/toolkit' import { socket as stateManager } from '@quiet/state-manager' -import { encodeSecret } from '@quiet/common' import { initActions } from '../init.slice' import { eventChannel } from 'redux-saga' export function* startConnectionSaga( action: PayloadAction['payload']> ): Generator { - const { dataPort, socketIOSecret } = action.payload + const { dataPort } = action.payload - console.log('socketIOSecret', socketIOSecret) - - if (!socketIOSecret) return - - const token = encodeSecret(socketIOSecret) - const socket = yield* call(io, `http://127.0.0.1:${dataPort}`, { - withCredentials: true, - extraHeaders: { - authorization: `Basic ${token}`, - }, - }) + const socket = yield* call(io, `http://127.0.0.1:${dataPort}`) yield* fork(handleSocketLifecycleActions, socket, dataPort) + // Handle opening/restoring connection yield* takeEvery(initActions.setWebsocketConnected, setConnectedSaga, socket) } @@ -56,7 +46,7 @@ function subscribeSocketLifecycle(socket: Socket, dataPort: number) { console.log('closing socket connection') emit(initActions.suspendWebsocketConnection()) }) - return () => { } + return () => {} }) }