Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3363544
D11351.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Referenced Files
None
Subscribers
None
D11351.diff
View Options
diff --git a/lib/types/crypto-types.js b/lib/types/crypto-types.js
--- a/lib/types/crypto-types.js
+++ b/lib/types/crypto-types.js
@@ -56,17 +56,6 @@
+pickledAccount: string,
};
-export type CryptoStore = {
- +primaryAccount: PickledOLMAccount,
- +primaryIdentityKeys: OLMIdentityKeys,
- +notificationAccount: PickledOLMAccount,
- +notificationIdentityKeys: OLMIdentityKeys,
-};
-
-export type CryptoStoreContextType = {
- +getInitializedCryptoStore: () => Promise<CryptoStore>,
-};
-
export type NotificationsOlmDataType = {
+mainSession: string,
+picklingKey: string,
diff --git a/lib/types/redux-types.js b/lib/types/redux-types.js
--- a/lib/types/redux-types.js
+++ b/lib/types/redux-types.js
@@ -20,7 +20,6 @@
UpdateUserAvatarResponse,
} from './avatar-types.js';
import type { CommunityStore, AddCommunityPayload } from './community-types.js';
-import type { CryptoStore } from './crypto-types.js';
import type {
GetVersionActionPayload,
LastCommunicatedPlatformDetails,
@@ -162,7 +161,6 @@
export type NativeAppState = BaseAppState<>;
export type WebAppState = BaseAppState<> & {
- +cryptoStore: ?CryptoStore,
+pushApiPublicKey: ?string,
...
};
diff --git a/lib/utils/reducers-utils.test.js b/lib/utils/reducers-utils.test.js
--- a/lib/utils/reducers-utils.test.js
+++ b/lib/utils/reducers-utils.test.js
@@ -42,7 +42,7 @@
},
windowActive: true,
pushApiPublicKey: null,
- cryptoStore: null,
+
loadingStatuses: {},
calendarFilters: defaultCalendarFilters,
dataLoaded: false,
diff --git a/web/redux/crypto-store-reducer.js b/web/redux/crypto-store-reducer.js
deleted file mode 100644
--- a/web/redux/crypto-store-reducer.js
+++ /dev/null
@@ -1,26 +0,0 @@
-// @flow
-
-import { setNewSessionActionType } from 'lib/keyserver-conn/keyserver-conn-types.js';
-import type { CryptoStore } from 'lib/types/crypto-types.js';
-import { relyingOnAuthoritativeKeyserver } from 'lib/utils/services-utils.js';
-
-import type { Action } from './redux-setup.js';
-import { authoritativeKeyserverID } from '../authoritative-keyserver.js';
-
-const setCryptoStore = 'SET_CRYPTO_STORE';
-
-function reduceCryptoStore(state: ?CryptoStore, action: Action): ?CryptoStore {
- if (action.type === setCryptoStore) {
- return action.payload;
- } else if (
- action.type === setNewSessionActionType &&
- action.payload.sessionChange.cookieInvalidated &&
- action.payload.keyserverID === authoritativeKeyserverID &&
- relyingOnAuthoritativeKeyserver
- ) {
- return null;
- }
- return state;
-}
-
-export { setCryptoStore, reduceCryptoStore };
diff --git a/web/redux/default-state.js b/web/redux/default-state.js
--- a/web/redux/default-state.js
+++ b/web/redux/default-state.js
@@ -40,7 +40,6 @@
},
windowActive: true,
pushApiPublicKey: null,
- cryptoStore: null,
windowDimensions: { width: window.width, height: window.height },
loadingStatuses: {},
calendarFilters: defaultCalendarFilters,
diff --git a/web/redux/persist.js b/web/redux/persist.js
--- a/web/redux/persist.js
+++ b/web/redux/persist.js
@@ -38,6 +38,7 @@
import { nonUserSpecificFieldsWeb } from './redux-setup.js';
import { authoritativeKeyserverID } from '../authoritative-keyserver.js';
import { getCommSharedWorker } from '../shared-worker/shared-worker-provider.js';
+import { getOlmWasmPath } from '../shared-worker/utils/constants.js';
import { isSQLiteSupported } from '../shared-worker/utils/db-utils.js';
import { workerRequestMessageTypes } from '../types/worker-types.js';
@@ -45,7 +46,6 @@
const persistWhitelist = [
'enabledApps',
- 'cryptoStore',
'notifPermissionAlertInfo',
'commServicesAccessToken',
'keyserverStore',
@@ -311,6 +311,16 @@
return handleReduxMigrationFailure(newState);
}
},
+ [13]: async (state: any) => {
+ const { cryptoStore, ...rest } = state;
+ const sharedWorker = await getCommSharedWorker();
+ await sharedWorker.schedule({
+ type: workerRequestMessageTypes.INITIALIZE_CRYPTO_ACCOUNT,
+ olmWasmPath: getOlmWasmPath(),
+ initialCryptoStore: cryptoStore,
+ });
+ return rest;
+ },
};
const migrateStorageToSQLite: StorageMigrationFunction = async debug => {
@@ -356,7 +366,7 @@
{ debug: isDev },
migrateStorageToSQLite,
): any),
- version: 12,
+ version: 13,
transforms: [keyserverStoreTransform],
};
diff --git a/web/redux/redux-setup.js b/web/redux/redux-setup.js
--- a/web/redux/redux-setup.js
+++ b/web/redux/redux-setup.js
@@ -27,7 +27,6 @@
identityInvalidSessionDowngrade,
} from 'lib/shared/session-utils.js';
import type { CommunityStore } from 'lib/types/community-types.js';
-import type { CryptoStore } from 'lib/types/crypto-types.js';
import type { DraftStore } from 'lib/types/draft-types.js';
import type { EnabledApps } from 'lib/types/enabled-apps.js';
import type { EntryStore } from 'lib/types/entry-types.js';
@@ -57,7 +56,6 @@
setInitialReduxState,
} from './action-types.js';
import { reduceCommunityPickerStore } from './community-picker-reducer.js';
-import { reduceCryptoStore, setCryptoStore } from './crypto-store-reducer.js';
import { defaultWebState } from './default-state.js';
import reduceNavInfo from './nav-reducer.js';
import { onStateDifference } from './redux-debug-utils.js';
@@ -108,7 +106,6 @@
+dataLoaded: boolean,
+windowActive: boolean,
+userPolicies: UserPolicies,
- +cryptoStore: ?CryptoStore,
+pushApiPublicKey: ?string,
+_persist: ?PersistState,
+commServicesAccessToken: ?string,
@@ -133,7 +130,6 @@
+type: 'UPDATE_WINDOW_ACTIVE',
+payload: boolean,
}
- | { +type: 'SET_CRYPTO_STORE', +payload: CryptoStore }
| { +type: 'SET_INITIAL_REDUX_STATE', +payload: InitialReduxState };
function reducer(oldState: AppState | void, action: Action): AppState {
@@ -318,10 +314,7 @@
);
}
- if (
- action.type !== updateNavInfoActionType &&
- action.type !== setCryptoStore
- ) {
+ if (action.type !== updateNavInfoActionType) {
const baseReducerResult = baseReducer(state, action, onStateDifference);
state = baseReducerResult.state;
storeOperations = {
@@ -345,7 +338,6 @@
action,
state.threadStore.threadInfos,
),
- cryptoStore: reduceCryptoStore(state.cryptoStore, action),
communityPickerStore,
commServicesAccessToken: reduceServicesAccessToken(
state.commServicesAccessToken,
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
@@ -12,7 +12,6 @@
import {
olmEncryptedMessageTypes,
type OLMIdentityKeys,
- type CryptoStore,
type PickledOLMAccount,
type IdentityKeysBlob,
type SignedIdentityKeysBlob,
@@ -57,6 +56,7 @@
type WorkerResponseMessage,
workerRequestMessageTypes,
workerResponseMessageTypes,
+ type LegacyCryptoStore,
} from '../../types/worker-types.js';
import type { OlmPersistSession } from '../types/sqlite-query-executor.js';
import { isDesktopSafari } from '../utils/db-utils.js';
@@ -201,7 +201,7 @@
async function initializeCryptoAccount(
olmWasmPath: string,
- initialCryptoStore: ?CryptoStore,
+ initialCryptoStore: ?LegacyCryptoStore,
) {
const sqliteQueryExecutor = getSQLiteQueryExecutor();
if (!sqliteQueryExecutor) {
diff --git a/web/types/worker-types.js b/web/types/worker-types.js
--- a/web/types/worker-types.js
+++ b/web/types/worker-types.js
@@ -1,7 +1,11 @@
// @flow
import type { AuthMetadata } from 'lib/shared/identity-client-context.js';
-import type { OlmAPI, CryptoStore } from 'lib/types/crypto-types.js';
+import type {
+ PickledOLMAccount,
+ OLMIdentityKeys,
+ OlmAPI,
+} from 'lib/types/crypto-types.js';
import type { PlatformDetails } from 'lib/types/device-types.js';
import type {
IdentityServiceClient,
@@ -115,10 +119,18 @@
+backupLogDataKey: string,
};
+// Previously used on web in redux. Now only used
+// in a migration to the shared worker.
+export type LegacyCryptoStore = {
+ +primaryAccount: PickledOLMAccount,
+ +primaryIdentityKeys: OLMIdentityKeys,
+ +notificationAccount: PickledOLMAccount,
+ +notificationIdentityKeys: OLMIdentityKeys,
+};
export type InitializeCryptoAccountRequestMessage = {
+type: 12,
+olmWasmPath: string,
- +initialCryptoStore?: CryptoStore,
+ +initialCryptoStore?: LegacyCryptoStore,
};
export type CreateIdentityServiceClientRequestMessage = {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 26, 2:30 AM (22 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2582099
Default Alt Text
D11351.diff (8 KB)
Attached To
Mode
D11351: [web] Migrate crypto store to shared worker
Attached
Detach File
Event Timeline
Log In to Comment