diff --git a/src/chrome/offscreen/message-handler.ts b/src/chrome/offscreen/message-handler.ts index 8faa02e0..e0d60964 100644 --- a/src/chrome/offscreen/message-handler.ts +++ b/src/chrome/offscreen/message-handler.ts @@ -1,7 +1,7 @@ import { createMessage } from 'chrome/messages/create-message' import { ConnectorClient } from 'connector/connector-client' import { MessagesRouter } from 'message-router' -import { errAsync, okAsync, ResultAsync } from 'neverthrow' +import { errAsync, okAsync } from 'neverthrow' import { Queue } from 'queues/queue' import { AppLogger } from 'utils/logger' import { @@ -47,18 +47,7 @@ export const OffscreenMessageHandler = (input: { const { interactionId } = message.data return messageRouter .add(tabId!, interactionId) - .asyncAndThen(() => - ResultAsync.combine([ - dAppRequestQueue.add(message.data, interactionId), - sendMessageWithConfirmation( - createMessage.getConnectionPassword('offScreen') - ).andThen((connectionPassword) => - connectorClient - .setConnectionPassword(connectionPassword) - .mapErr(() => ({ reason: 'setConnectionPasswordError' })) - ), - ]) - ) + .asyncAndThen(() => dAppRequestQueue.add(message.data, interactionId)) .andThen(() => okAsync({ sendConfirmation: true })) } diff --git a/src/connector/connector-client.ts b/src/connector/connector-client.ts index 960c6ef2..02b938a8 100644 --- a/src/connector/connector-client.ts +++ b/src/connector/connector-client.ts @@ -16,7 +16,6 @@ import { Subscription, switchMap, tap, - timer, withLatestFrom, } from 'rxjs' import { WebRtcClient } from './webrtc/webrtc-client' @@ -27,7 +26,7 @@ import { SignalingSubjects, SignalingSubjectsType } from './signaling/subjects' import { MessageClient } from './messages/message-client' import { waitForDataChannelStatus } from './webrtc/helpers/wait-for-data-channel-status' import { sendMessage } from './messages/helpers/send-message' -import { err, ok, ResultAsync } from 'neverthrow' +import { ResultAsync } from 'neverthrow' import { errorIdentity } from 'utils/error-identity' export type ConnectorClient = ReturnType @@ -154,17 +153,5 @@ export const ConnectorClient = (input: { logger?.debug('๐Ÿ”Œ๐Ÿงน destroying connector client') subscriptions.unsubscribe() }, - connectionPassword: (): ResultAsync => - ResultAsync.fromPromise( - firstValueFrom( - merge( - secretsClient.secrets$.pipe( - map((secrets) => ok(secrets.encryptionKey.toString('hex'))) - ), - timer(100).pipe(map(() => err('connectionPasswordNotSet'))) - ) - ), - (error) => error as string - ).andThen((result) => result), } } diff --git a/src/queues/queue.ts b/src/queues/queue.ts index 75b14d8b..43b55889 100644 --- a/src/queues/queue.ts +++ b/src/queues/queue.ts @@ -49,9 +49,6 @@ export const Queue = ({ subjects.paused.next(paused) const subscriptions = new Subscription() - const log = (name: string, ...args: any[]) => - logger?.debug(`๐Ÿšฆ [${key}] ${name}`, ...args) - const decodeStateData = ( data: QueueStateRaw ): Result, never> => @@ -103,7 +100,7 @@ export const Queue = ({ ): ResultAsync => transformState(state) .asyncAndThen((data) => { - log('saveState', data.ids) + logger?.trace('saveState', data.ids) return storage.setData(key, data) }) .mapErr(() => ({ reason: 'SaveStateError' })) @@ -112,7 +109,7 @@ export const Queue = ({ job: Job, state: QueueState ): ResultAsync, never> => { - log('addJob', { job }) + logger?.debug('addJob', { job }) state.items.set(job.id, { ...job, updatedAt: Date.now() }) state.ids.pending.add(job.id) return okAsync(state) @@ -130,7 +127,7 @@ export const Queue = ({ numberOfRetries?: number }): ResultAsync, QueueInteractionError> => { const jobId = job.id - log('updateJobStatus', { + logger?.debug('updateJobStatus', { jobId: job.id, fromStatus: job.status, toStatus: status, @@ -151,7 +148,7 @@ export const Queue = ({ jobId: string, state: QueueState ): ResultAsync, QueueInteractionError> => { - log('removeJob', { + logger?.debug('removeJob', { jobId, })