diff --git a/web/shared-worker/worker/identity-client.js b/web/shared-worker/worker/identity-client.js index 97301c42b..2e4a7f036 100644 --- a/web/shared-worker/worker/identity-client.js +++ b/web/shared-worker/worker/identity-client.js @@ -1,65 +1,66 @@ // @flow import { getNewDeviceKeyUpload, getExistingDeviceKeyUpload, } from './worker-crypto.js'; import { IdentityServiceClientWrapper } from '../../grpc/identity-service-client-wrapper.js'; import { type WorkerResponseMessage, type WorkerRequestMessage, workerRequestMessageTypes, workerResponseMessageTypes, } from '../../types/worker-types.js'; import type { EmscriptenModule } from '../types/module.js'; import type { SQLiteQueryExecutor } from '../types/sqlite-query-executor.js'; let identityClient: ?IdentityServiceClientWrapper = null; async function processAppIdentityClientRequest( sqliteQueryExecutor: SQLiteQueryExecutor, dbModule: EmscriptenModule, message: WorkerRequestMessage, ): Promise { if ( message.type === workerRequestMessageTypes.CREATE_IDENTITY_SERVICE_CLIENT ) { identityClient = new IdentityServiceClientWrapper( message.platformDetails, message.opaqueWasmPath, message.authLayer, async () => getNewDeviceKeyUpload(), async () => getExistingDeviceKeyUpload(), ); return undefined; } if (!identityClient) { throw new Error('Identity client not created'); } if (message.type === workerRequestMessageTypes.CALL_IDENTITY_CLIENT_METHOD) { // Flow doesn't allow us to access methods like this (it needs an index // signature declaration in the object type) - // $FlowFixMe - const method = identityClient[message.method]; + const method: (...$ReadOnlyArray) => mixed = (identityClient: any)[ + message.method + ]; if (typeof method !== 'function') { throw new Error( `Couldn't find identity client method with name '${message.method}'`, ); } const result = await method(...message.args); return { type: workerResponseMessageTypes.CALL_IDENTITY_CLIENT_METHOD, result, }; } return undefined; } function getIdentityClient(): ?IdentityServiceClientWrapper { return identityClient; } export { processAppIdentityClientRequest, getIdentityClient };