Skip to content

Commit

Permalink
[keyserver][landing] Fix reset preamble for landing SIWE
Browse files Browse the repository at this point in the history
Summary:
To address `incognito={true}` [not working on Android](https://linear.app/comm/issue/ENG-2577/siwe-webview-incognito-property-not-working-on-android), in D6112 I introduced a "preamble" of sorts to `landing` that would reset `localStorage`.

Sometime since then this has stopped working (see [ENG-9537](https://linear.app/comm/issue/ENG-9537/investigate-issues-with-zerion-wallet)). This diff makes two changes to bring it back:

1. I had to move the preamble to a separate `<script>` tag in the returned HTML. I'm not sure why this was necessary, as my naive prior was that Webpack would execute the first lines of your `entry` first. But testing clearly revealed this to be necessary.
2. I also had to add some lines to clear IndexedDB alongside `localStorage`.

Test Plan:
I created a test environment on my personal server at https://comm.fund and then authorized comm.fund via WalletConnect's "Cloud" interface

I then deployed a dev build to my local device pointed at comm.fund/siwe. I confirmed that this worked by testing 10x times that swiping away `SIWEPanel` after initially connecting a wallet would result in a full reset the next time `SIWEPanel` was opened

I then tested the Android Zerion wallet workflow end-to-end

Reviewers: varun, will

Reviewed By: will

Subscribers: tomek

Differential Revision: https://phab.comm.dev/D13789
  • Loading branch information
Ashoat committed Oct 25, 2024
1 parent fad6010 commit 82f71c8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 8 additions & 0 deletions keyserver/src/responders/landing-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@ async function landingResponder(req: $Request, res: $Response) {
<base href="${basePath}" />
${fontsInclude}
${cssInclude}
<script>
localStorage.clear();
indexedDB.databases().then(databases => {
databases.forEach(db => {
indexedDB.deleteDatabase(db.name);
});
});
</script>
<link
rel="apple-touch-icon"
sizes="180x180"
Expand Down
2 changes: 0 additions & 2 deletions landing/script.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// @flow

localStorage.clear();

import 'isomorphic-fetch';

import invariant from 'invariant';
Expand Down

0 comments on commit 82f71c8

Please sign in to comment.