dexie / Dexie.js

A Minimalistic Wrapper for IndexedDB
https://dexie.org
Apache License 2.0
11.65k stars 641 forks source link

db import with outdated claims throws websocket error #2061

Open MuffinTheDragon opened 2 months ago

MuffinTheDragon commented 2 months ago

I'm using the import, export feature based on the provided sample

The data import works fine, but if I try to sync with the db or refresh the claims, I get a websocket error:

image

I made some changes recently that synced with the server, then tried importing a backup from about a month ago where my license was expired. But it seems like if the access token is expired, it throws this error

Is that error expected in this case or is there something I might be doing incorrectly?

dfahlander commented 2 months ago

The private key, which is used to authorize refresh token requests, is not exportable (for security reasons) so when it's imported you won't get a valid CryptoKey back. We should probably detect this use case better and require reauthentication when this happens. A workaround is to delete the refreshToken and the private / public key pairs from the $logins table entry holding your user info. Maybe use a transform callback when importing or delete this data directly after import. This should lead to a reauthentication flow

MuffinTheDragon commented 2 months ago

I tried deleting the refresh token as well as the key pairs right after the import call, but it doesn't trigger a reauthentication:

image

image