Changeset View
Changeset View
Standalone View
Standalone View
web/shared-worker/worker/identity-client.js
// @flow | // @flow | ||||
import { getDeviceKeyUpload } from './worker-crypto.js'; | import { getNewDeviceKeyUpload } from './worker-crypto.js'; | ||||
import { IdentityServiceClientWrapper } from '../../grpc/identity-service-client-wrapper.js'; | import { IdentityServiceClientWrapper } from '../../grpc/identity-service-client-wrapper.js'; | ||||
import { | import { | ||||
type WorkerResponseMessage, | type WorkerResponseMessage, | ||||
type WorkerRequestMessage, | type WorkerRequestMessage, | ||||
workerRequestMessageTypes, | workerRequestMessageTypes, | ||||
workerResponseMessageTypes, | workerResponseMessageTypes, | ||||
} from '../../types/worker-types.js'; | } from '../../types/worker-types.js'; | ||||
import type { EmscriptenModule } from '../types/module.js'; | import type { EmscriptenModule } from '../types/module.js'; | ||||
import type { SQLiteQueryExecutor } from '../types/sqlite-query-executor.js'; | import type { SQLiteQueryExecutor } from '../types/sqlite-query-executor.js'; | ||||
let identityClient: ?IdentityServiceClientWrapper = null; | let identityClient: ?IdentityServiceClientWrapper = null; | ||||
async function processAppIdentityClientRequest( | async function processAppIdentityClientRequest( | ||||
sqliteQueryExecutor: SQLiteQueryExecutor, | sqliteQueryExecutor: SQLiteQueryExecutor, | ||||
dbModule: EmscriptenModule, | dbModule: EmscriptenModule, | ||||
message: WorkerRequestMessage, | message: WorkerRequestMessage, | ||||
): Promise<?WorkerResponseMessage> { | ): Promise<?WorkerResponseMessage> { | ||||
if ( | if ( | ||||
message.type === workerRequestMessageTypes.CREATE_IDENTITY_SERVICE_CLIENT | message.type === workerRequestMessageTypes.CREATE_IDENTITY_SERVICE_CLIENT | ||||
) { | ) { | ||||
identityClient = new IdentityServiceClientWrapper( | identityClient = new IdentityServiceClientWrapper( | ||||
message.platformDetails, | message.platformDetails, | ||||
message.opaqueWasmPath, | message.opaqueWasmPath, | ||||
message.authLayer, | message.authLayer, | ||||
async () => getDeviceKeyUpload(), | async () => getNewDeviceKeyUpload(), | ||||
); | ); | ||||
return undefined; | return undefined; | ||||
} | } | ||||
if (!identityClient) { | if (!identityClient) { | ||||
throw new Error('Identity client not created'); | throw new Error('Identity client not created'); | ||||
} | } | ||||
Show All 25 Lines |