mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
Remove legacy auth cache migration docs and add regression test
Removes obsolete "Migration notes" from `docs/nostr-auth.md` and adds a regression test to `tests/state/cache-saved-profiles.test.mjs` to confirm that the legacy `userPubKey` localStorage key is ignored during startup. Also polyfills localStorage for the test suite.
This commit is contained in:
1 parent
ad961cd401
commit
f5eba4121f
2 files changed
+14
-12
No files matched your search
+2
-12
@@ -59,16 +59,6 @@ When introducing additional providers, choose a unique string value and extend t
|
||||
When the app reads stored entries it normalises unknown values back to
|
||||
`"nip07"` but keeps recognised alternatives intact.
|
||||
|
||||
## Migration notes
|
||||
## Supported Auth Cache
|
||||
|
||||
Earlier builds only persisted a single `userPubKey` string. During startup the
|
||||
app now:
|
||||
|
||||
1. Attempts to read `bitvid:savedProfiles:v1` and validate the payload.
|
||||
2. If the key is missing (or malformed) but a legacy `userPubKey` entry exists,
|
||||
it seeds `savedProfiles` with that value and writes the new structure.
|
||||
3. Once the JSON payload is written successfully, the legacy `userPubKey` entry
|
||||
is removed.
|
||||
|
||||
Future migrations should follow the same pattern: validate, normalise, write the
|
||||
new format, then clean up legacy keys to avoid data loss.
|
||||
`bitvid:savedProfiles:v1` is the sole supported auth cache. Legacy keys such as `userPubKey` are no longer read or migrated.
|
||||
@@ -1,3 +1,4 @@
|
||||
import "../test-helpers/setup-localstorage.mjs";
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
@@ -149,3 +150,14 @@ test("loadSavedProfilesFromStorage trims stored authType values", () => {
|
||||
assert.equal(stored.entries[0].authType, "extension-provider");
|
||||
assert.equal(stored.entries[0].providerId, "extension-provider");
|
||||
});
|
||||
|
||||
test("loadSavedProfilesFromStorage ignores legacy userPubKey", () => {
|
||||
resetSavedProfilesState();
|
||||
|
||||
localStorage.setItem("userPubKey", SAMPLE_PUBKEY);
|
||||
// Ensure the modern key is missing/empty
|
||||
localStorage.removeItem(STORAGE_KEY);
|
||||
|
||||
const { profiles } = loadSavedProfilesFromStorage();
|
||||
assert.equal(profiles.length, 0, "Expected no profiles to be loaded from legacy key");
|
||||
});
|
||||
Reference in new issue
Block a user