Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validate app state before performing potentially destructive actions: sync, save, download, upload #1348

Merged
merged 73 commits into from
Dec 19, 2023
Merged
Changes from 1 commit
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
65a7536
create function that validates appState and returns list of errors as…
ichub Dec 11, 2023
144f2eb
handle state validation errors in inital state load
ichub Dec 11, 2023
0aa824c
commented some locations where validation logic should be added
ichub Dec 11, 2023
6c55e49
more validation
ichub Dec 11, 2023
dc0d6ff
added more validation
ichub Dec 11, 2023
3db82d9
implemented another validation point
ichub Dec 11, 2023
910a334
more validation
ichub Dec 11, 2023
0629d46
undo a change
ichub Dec 11, 2023
4502d33
add some validation logic inside of localstorage saving and loading o…
ichub Dec 11, 2023
91b5ca1
add a bunch of comments
ichub Dec 11, 2023
71dc18a
added account export button to the invalid user modal
ichub Dec 11, 2023
41bbdc1
add explanation to export button
ichub Dec 15, 2023
6067803
respond to some PR comments
ichub Dec 15, 2023
4268377
some cleanups
ichub Dec 15, 2023
e0710a3
slight refactor
ichub Dec 15, 2023
87e2ece
ensure user uuid is always uploaded with a validation error
ichub Dec 15, 2023
09ee405
more pr review comments
ichub Dec 15, 2023
d8537ca
more pr review comments
ichub Dec 15, 2023
36a242b
fixed another comment
ichub Dec 15, 2023
0535ebd
rename validateState to validateAppState
ichub Dec 15, 2023
f078f9d
consolidated all validation logic into one function
ichub Dec 15, 2023
e793c87
testing
ichub Dec 15, 2023
c79c4c7
undo extra file
ichub Dec 15, 2023
3e30ce2
fix bug
ichub Dec 15, 2023
a908239
fix bug
ichub Dec 15, 2023
2963009
updated comments
ichub Dec 15, 2023
5e9e822
extra validation logic in load initial app state
ichub Dec 15, 2023
6a37eed
early return from sync if userInvalid=true
ichub Dec 15, 2023
687e981
implement suggestion to make validation of state consistent between u…
ichub Dec 15, 2023
3570232
starting to add test for state validation function
ichub Dec 15, 2023
014a81c
update error message based on pr comment
ichub Dec 15, 2023
cebe1b9
update copy in response to feedback
ichub Dec 15, 2023
28aafad
cleaning up test
ichub Dec 18, 2023
82eb229
actually test
ichub Dec 18, 2023
21d0bfb
test logged out state
ichub Dec 18, 2023
f5331b6
more validation test cases
ichub Dec 18, 2023
06b1969
moved state validation out of sync and into uploadSerializedStorage
ichub Dec 18, 2023
b858d54
moved userinvalid check to top of dosync
ichub Dec 18, 2023
a463370
move pcd collection logic to top of validation function
ichub Dec 18, 2023
8f21814
add validationTag to validateState function
ichub Dec 18, 2023
00e5e49
console.log -> console.error
ichub Dec 18, 2023
c527bb0
unwrap errors object when logging to server
ichub Dec 18, 2023
44eb786
update validateState to be less confusing for cases when something is…
ichub Dec 18, 2023
215487b
fix test
ichub Dec 18, 2023
6fab637
testing logged out state
ichub Dec 18, 2023
2071644
one more test case
ichub Dec 18, 2023
5b01b79
cleanup
ichub Dec 18, 2023
e63a5f1
add case for missing identity
ichub Dec 18, 2023
430e506
actually propagate log tag
ichub Dec 18, 2023
f5d9125
more test cleanup
ichub Dec 18, 2023
7fbf563
more cleanup
ichub Dec 18, 2023
95ab85c
another test case
ichub Dec 18, 2023
69a6344
slight refactor
ichub Dec 18, 2023
e11aacd
more validation tests
ichub Dec 18, 2023
2c81bdb
state validation tests look good
ichub Dec 18, 2023
fcec42d
introduce another validation function - initial state
ichub Dec 18, 2023
5fce68d
add comments
ichub Dec 18, 2023
c49362b
remove encryption key check
ichub Dec 18, 2023
cfdc206
undo changes to rate limit service
ichub Dec 18, 2023
85d9e63
fix bug
ichub Dec 18, 2023
67e237c
Merge remote-tracking branch 'origin/main' into ivan/state-validation
ichub Dec 18, 2023
0b1e4fc
fix merge conflict
ichub Dec 18, 2023
0509323
pass in extra validation arguments to tryDeserializeNewStorage
ichub Dec 18, 2023
b7c881d
slight refactor of logValidationErrors
ichub Dec 19, 2023
c0a2128
prevent validation error from being reported by loading pcdcollection…
ichub Dec 19, 2023
0679204
Merge remote-tracking branch 'origin/main' into ivan/state-validation
ichub Dec 19, 2023
f4999f1
early return on upload validation error; this doesn't cause upload lo…
ichub Dec 19, 2023
c7dd380
update copy and styling of the invalid user modal to communicate better
ichub Dec 19, 2023
c9cff96
add mailto link in invalid user modal
ichub Dec 19, 2023
c4a6982
change the way we set userInvalid to also force the modal to open
ichub Dec 19, 2023
e7a843b
don't force userInvalid true
ichub Dec 19, 2023
e67b1d1
add comment explaining early return
ichub Dec 19, 2023
6adbf57
fixed build
ichub Dec 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions apps/passport-client/src/dispatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,10 @@ async function doSync(
serverStorageHash: upRes.value.storageHash
};
} else {
if (upRes.error.name === "ValidationError") {
return { userInvalid: true };
ichub marked this conversation as resolved.
Show resolved Hide resolved
}

// Upload failed. Update AppState if necessary, but not unnecessarily.
// AppState updates will trigger another upload attempt.
const needExtraDownload = upRes.error.name === "Conflict";
Expand All @@ -860,9 +864,6 @@ async function doSync(
if (needExtraDownload && !state.extraDownloadRequested) {
updates.extraDownloadRequested = true;
}
if (upRes.error.name === "ValidationError") {
updates.userInvalid = true;
}

return updates;
}
Expand Down