diff --git a/lib/types/identity-service-types.js b/lib/types/identity-service-types.js --- a/lib/types/identity-service-types.js +++ b/lib/types/identity-service-types.js @@ -160,7 +160,7 @@ username: t.String, }); -export type IdentityDeviceKeyUpload = { +export type IdentityNewDeviceKeyUpload = { +keyPayload: string, +keyPayloadSignature: string, +contentPrekey: string, diff --git a/web/account/account-hooks.js b/web/account/account-hooks.js --- a/web/account/account-hooks.js +++ b/web/account/account-hooks.js @@ -20,7 +20,7 @@ OLMIdentityKeys, NotificationsOlmDataType, } from 'lib/types/crypto-types.js'; -import { type IdentityDeviceKeyUpload } from 'lib/types/identity-service-types.js'; +import { type IdentityNewDeviceKeyUpload } from 'lib/types/identity-service-types.js'; import type { OlmSessionInitializationInfo } from 'lib/types/request-types.js'; import { getConfig } from 'lib/utils/config.js'; import { retrieveAccountKeysSet } from 'lib/utils/olm-utils.js'; @@ -175,7 +175,7 @@ }, [getOrCreateCryptoStore]); } -function useGetDeviceKeyUpload(): () => Promise { +function useGetNewDeviceKeyUpload(): () => Promise { const getOrCreateCryptoStore = useGetOrCreateCryptoStore(); // `getSignedIdentityKeysBlob()` will initialize OLM, so no need to do it // again @@ -431,5 +431,5 @@ useGetOrCreateCryptoStore, OlmSessionCreatorProvider, GetOrCreateCryptoStoreProvider, - useGetDeviceKeyUpload, + useGetNewDeviceKeyUpload, }; diff --git a/web/grpc/identity-service-client-wrapper.js b/web/grpc/identity-service-client-wrapper.js --- a/web/grpc/identity-service-client-wrapper.js +++ b/web/grpc/identity-service-client-wrapper.js @@ -18,7 +18,7 @@ deviceOlmOutboundKeysValidator, type UserDevicesOlmOutboundKeys, type IdentityAuthResult, - type IdentityDeviceKeyUpload, + type IdentityNewDeviceKeyUpload, identityDeviceTypes, identityAuthResultValidator, type UserDevicesOlmInboundKeys, @@ -49,13 +49,13 @@ overridedOpaqueFilepath: ?string; authClient: ?IdentityAuthClient.IdentityClientServicePromiseClient; unauthClient: IdentityUnauthClient.IdentityClientServicePromiseClient; - getDeviceKeyUpload: () => Promise; + getNewDeviceKeyUpload: () => Promise; constructor( platformDetails: PlatformDetails, overridedOpaqueFilepath: ?string, authLayer: ?IdentityServiceAuthLayer, - getDeviceKeyUpload: () => Promise, + getNewDeviceKeyUpload: () => Promise, ) { this.overridedOpaqueFilepath = overridedOpaqueFilepath; if (authLayer) { @@ -66,7 +66,7 @@ } this.unauthClient = IdentityServiceClientWrapper.createUnauthClient(platformDetails); - this.getDeviceKeyUpload = getDeviceKeyUpload; + this.getNewDeviceKeyUpload = getNewDeviceKeyUpload; } static determineSocketAddr(): string { @@ -354,14 +354,14 @@ } const [identityDeviceKeyUpload] = await Promise.all([ - this.getDeviceKeyUpload(), + this.getNewDeviceKeyUpload(), initOpaque(this.overridedOpaqueFilepath), ]); const opaqueLogin = new Login(); const startRequestBytes = opaqueLogin.start(password); - const deviceKeyUpload = authDeviceKeyUpload(identityDeviceKeyUpload); + const deviceKeyUpload = authNewDeviceKeyUpload(identityDeviceKeyUpload); const loginStartRequest = new OpaqueLoginStartRequest(); loginStartRequest.setUsername(username); @@ -409,8 +409,8 @@ siweMessage: string, siweSignature: string, ) => { - const identityDeviceKeyUpload = await this.getDeviceKeyUpload(); - const deviceKeyUpload = authDeviceKeyUpload(identityDeviceKeyUpload); + const identityDeviceKeyUpload = await this.getNewDeviceKeyUpload(); + const deviceKeyUpload = authNewDeviceKeyUpload(identityDeviceKeyUpload); const loginRequest = new WalletAuthRequest(); loginRequest.setSiweMessage(siweMessage); @@ -439,8 +439,8 @@ ownerUserID, nonceChallengeResponse, ) => { - const identityDeviceKeyUpload = await this.getDeviceKeyUpload(); - const deviceKeyUpload = authDeviceKeyUpload(identityDeviceKeyUpload); + const identityDeviceKeyUpload = await this.getNewDeviceKeyUpload(); + const deviceKeyUpload = authNewDeviceKeyUpload(identityDeviceKeyUpload); const challengeResponse = JSON.stringify(nonceChallengeResponse); const request = new SecondaryDeviceKeysUploadRequest(); @@ -519,8 +519,8 @@ }; } -function authDeviceKeyUpload( - uploadData: IdentityDeviceKeyUpload, +function authNewDeviceKeyUpload( + uploadData: IdentityNewDeviceKeyUpload, ): DeviceKeyUpload { const { keyPayload, diff --git a/web/grpc/identity-service-context-provider.react.js b/web/grpc/identity-service-context-provider.react.js --- a/web/grpc/identity-service-context-provider.react.js +++ b/web/grpc/identity-service-context-provider.react.js @@ -10,7 +10,7 @@ import { IdentityServiceClientSharedProxy } from './identity-service-client-proxy.js'; import { IdentityServiceClientWrapper } from './identity-service-client-wrapper.js'; -import { useGetDeviceKeyUpload } from '../account/account-hooks.js'; +import { useGetNewDeviceKeyUpload } from '../account/account-hooks.js'; import { usingSharedWorker } from '../crypto/olm-api.js'; import { useSelector } from '../redux/redux-utils.js'; @@ -25,7 +25,7 @@ const deviceID = useSelector( state => state.cryptoStore?.primaryIdentityKeys.ed25519, ); - const getDeviceKeyUpload = useGetDeviceKeyUpload(); + const getNewDeviceKeyUpload = useGetNewDeviceKeyUpload(); const client = React.useMemo(() => { let authLayer = null; @@ -43,10 +43,10 @@ getConfig().platformDetails, null, authLayer, - getDeviceKeyUpload, + getNewDeviceKeyUpload, ); } - }, [accessToken, deviceID, getDeviceKeyUpload, userID]); + }, [accessToken, deviceID, getNewDeviceKeyUpload, userID]); const getAuthMetadata = React.useCallback<() => Promise>( async () => ({ diff --git a/web/shared-worker/worker/identity-client.js b/web/shared-worker/worker/identity-client.js --- a/web/shared-worker/worker/identity-client.js +++ b/web/shared-worker/worker/identity-client.js @@ -1,6 +1,6 @@ // @flow -import { getDeviceKeyUpload } from './worker-crypto.js'; +import { getNewDeviceKeyUpload } from './worker-crypto.js'; import { IdentityServiceClientWrapper } from '../../grpc/identity-service-client-wrapper.js'; import { type WorkerResponseMessage, @@ -25,7 +25,7 @@ message.platformDetails, message.opaqueWasmPath, message.authLayer, - async () => getDeviceKeyUpload(), + async () => getNewDeviceKeyUpload(), ); return undefined; } diff --git a/web/shared-worker/worker/worker-crypto.js b/web/shared-worker/worker/worker-crypto.js --- a/web/shared-worker/worker/worker-crypto.js +++ b/web/shared-worker/worker/worker-crypto.js @@ -9,7 +9,7 @@ IdentityKeysBlob, SignedIdentityKeysBlob, } from 'lib/types/crypto-types.js'; -import type { IdentityDeviceKeyUpload } from 'lib/types/identity-service-types.js'; +import type { IdentityNewDeviceKeyUpload } from 'lib/types/identity-service-types.js'; import { retrieveAccountKeysSet } from 'lib/utils/olm-utils.js'; import { getProcessingStoreOpsExceptionMessage } from './process-operations.js'; @@ -196,7 +196,7 @@ return signedIdentityKeysBlob; } -function getDeviceKeyUpload(): IdentityDeviceKeyUpload { +function getNewDeviceKeyUpload(): IdentityNewDeviceKeyUpload { if (!cryptoStore) { throw new Error('Crypto account not initialized'); } @@ -226,5 +226,5 @@ clearCryptoStore, processAppOlmApiRequest, getSignedIdentityKeysBlob, - getDeviceKeyUpload, + getNewDeviceKeyUpload, };