Local "invalid signature" error with `@dfinity/auth-client`

If you are experiencing “invalid signature” errors in your local environment, like I was for the past couple days, here’s the fix that worked for me! tldr: clear indexedDB from browser devtools. @dfinity/auth-client is lovely and caches your DelegationIdentity for you via indexedDB. However if you have a cached identity from a previous local replica, that replica will have a different public key and will cause “invalid signature” errors, since we are trying to certify responses with the public key of another chain. I hope this can save someone time :slight_smile:

4 Likes

got it too sometimes :wink:. hope you did not debug it for too long

alternative: always develop in incognito mode and close/reopen your incognito tabs each time you change environment

I close and reopen my browser zillion times a day, that way I’m always sure there is no cached data

3 Likes

@kpeacock could we add a local flag or smth so this doesnt happen during development?

I’m not sure that disabling storage during local development is an ideal “local” behavior either. People can have complicated use cases.

It would be worth creating a troubleshooting section in the Readme, at the very least

1 Like

Not disabling entirely, but storing it in a place that’s less persistent or clearing the indexedDB when initialising the authclient.

I’ve now run into this a few times as well.

For those using Firefox, this is how you can clear your local indexedDB.

  1. Open up dev tools → Storage
  2. Navigate to Indexed DB → → auth-client-dbic-keyval
  3. Delete the delegate (or just wipe this whole key/value store and start with a fresh slate).

Here’s how you can view it in Chrome → View and change IndexedDB data - Chrome Developers

2 Likes