From 050932310f2528bf66ef835a58cd391d64eb72c2 Mon Sep 17 00:00:00 2001 From: Ivan Chub Date: Mon, 18 Dec 2023 14:45:32 -0800 Subject: [PATCH] pass in extra validation arguments to tryDeserializeNewStorage --- apps/passport-client/src/dispatch.ts | 1 + apps/passport-client/src/useSyncE2EEStorage.tsx | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/apps/passport-client/src/dispatch.ts b/apps/passport-client/src/dispatch.ts index 5c2a0284b2..d12c3b428b 100644 --- a/apps/passport-client/src/dispatch.ts +++ b/apps/passport-client/src/dispatch.ts @@ -752,6 +752,7 @@ async function doSync( state.serverStorageRevision, state.serverStorageHash, state.self, + state.identity, state.pcds, state.subscriptions ); diff --git a/apps/passport-client/src/useSyncE2EEStorage.tsx b/apps/passport-client/src/useSyncE2EEStorage.tsx index 9afcd2324e..33236e3db8 100644 --- a/apps/passport-client/src/useSyncE2EEStorage.tsx +++ b/apps/passport-client/src/useSyncE2EEStorage.tsx @@ -261,6 +261,7 @@ export async function downloadAndMergeStorage( knownServerRevision: string | undefined, knownServerHash: string | undefined, appSelf: User, + appIdentity: Identity, appPCDs: PCDCollection, appSubscriptions: FeedSubscriptionManager ): Promise { @@ -290,6 +291,8 @@ export async function downloadAndMergeStorage( // Deserialize downloaded storage, which becomes the default new state if no // merge is necessary. const downloaded = await tryDeserializeNewStorage( + appSelf, + appIdentity, storageResult.value.storage ); if (downloaded === undefined) { @@ -352,7 +355,12 @@ export async function downloadAndMergeStorage( }; } +/** + * {@link appSelf} and {@link appIdentity} are used solely for validation purposes. + */ export async function tryDeserializeNewStorage( + appSelf: User, + appIdentity: Identity, storage: SyncedEncryptedStorage ): Promise< | undefined @@ -371,10 +379,9 @@ export async function tryDeserializeNewStorage( if ( !validateAndLogRunningAppState( "downloadStorage", - undefined, - undefined, - pcds, - true + appSelf, + appIdentity, + pcds ) ) { throw new Error("downloaded e2ee state failed to validate");