diff --git a/docs/nostr-auth.md b/docs/nostr-auth.md index 986e7031..c29bdcd5 100644 --- a/docs/nostr-auth.md +++ b/docs/nostr-auth.md @@ -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. diff --git a/tests/state/cache-saved-profiles.test.mjs b/tests/state/cache-saved-profiles.test.mjs index 29c935d3..0866f888 100644 --- a/tests/state/cache-saved-profiles.test.mjs +++ b/tests/state/cache-saved-profiles.test.mjs @@ -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"); +});