Skip to content

Commit

Permalink
pass in extra validation arguments to tryDeserializeNewStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
ichub committed Dec 18, 2023
1 parent 0b1e4fc commit 0509323
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions apps/passport-client/src/dispatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,7 @@ async function doSync(
state.serverStorageRevision,
state.serverStorageHash,
state.self,
state.identity,
state.pcds,
state.subscriptions
);
Expand Down
15 changes: 11 additions & 4 deletions apps/passport-client/src/useSyncE2EEStorage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ export async function downloadAndMergeStorage(
knownServerRevision: string | undefined,
knownServerHash: string | undefined,
appSelf: User,
appIdentity: Identity,
appPCDs: PCDCollection,
appSubscriptions: FeedSubscriptionManager
): Promise<SyncStorageResult> {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand All @@ -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");
Expand Down

0 comments on commit 0509323

Please sign in to comment.