From f5eba4121fc23fbd482a97acf3fc5d3e38281885 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 7 Jan 2026 00:20:01 +0000 Subject: [PATCH] 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. --- docs/nostr-auth.md | 14 ++------------ tests/state/cache-saved-profiles.test.mjs | 12 ++++++++++++ 2 files changed, 14 insertions(+), 12 deletions(-) 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"); +});