fix: stop persisting the editor configuration in localStorage - #613
Draft
dcalhoun wants to merge 4 commits into
Draft
fix: stop persisting the editor configuration in localStorage#613dcalhoun wants to merge 4 commits into
dcalhoun wants to merge 4 commits into
Conversation
XCFramework BuildThis PR's XCFramework is available for testing. Add the following to your .package(url: "https://github.com/wordpress-mobile/GutenbergKit", branch: "pr-build/613")Built from f32075c |
`getGBKit` fell back to a copy of the configuration in `localStorage`. Boot waits for `window.GBKit` before anything reads the configuration, and outside `?dev_mode` aborts when it never arrives, so the fallback could only ever serve a previous session's values to a dev-mode page with no host. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JsMCoa3jNEuvnhxicDVRBV
`GBKit` carries the site credential and the local server's port and tokens, all valid only for the load that injected them, and iOS mirrored it into `localStorage`, which the default website data store keeps on disk across launches. The document-start user script replays the global on every navigation, including the reload after a WebContent process termination, so the copy had no reader. Remove the key as the configuration is injected so devices upgraded from an earlier version are scrubbed. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JsMCoa3jNEuvnhxicDVRBV
`GBKit` carries the site credential and the local server's port and token, all valid only for the load that injected them. The view re-injects the global on every page start and wipes web storage before each load, so the `localStorage` copy had no reader and nothing left to clear on detach. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JsMCoa3jNEuvnhxicDVRBV
The CORS rationale on both platforms named `localStorage` alongside `window.GBKit` as where the editor holds the per-session bearer token. The token now lives in the injected global only. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JsMCoa3jNEuvnhxicDVRBV
dcalhoun
force-pushed
the
task/remove-gbkit-global-from-local-storage
branch
from
September 2, 2026 16:20
b7d738a to
f32075c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Stop mirroring the editor configuration (
window.GBKit) intolocalStorageon iOS and Android, and drop the JavaScript fallback that read it.Why?
GBKitcarries the site credential and the local server's port and tokens, all valid only for the load that injected them. iOS mirrored it intolocalStorage, which the default website data store keeps on disk across launches, so a stale copy could outlive the session and hand a previous session's port and token to anything reading through the fallback.Nothing needs the copy. The persisted copy arrived with the global in #14, when iOS injected the configuration with
evaluateJavaScriptafter the page had loaded. #15 moved iOS to a document-startWKUserScript, which WebKit replays on every navigation, including the reload after a WebContent process termination. Android re-injects the global on every page start and wipes web storage before each load. Boot also waits forwindow.GBKitbefore anything reads the configuration and, outside?dev_mode, aborts when it never arrives, so the fallback was unreachable in production.Stacked atop #611 (
task/stabilize-rest-request-relay), which first worked around the stale relay details inef857d07andc69054dd, then reverted the iOS half in1494ca63pending this change to both platforms.How?
getGBKitreturns the injected global or an empty object.setItemline from the document-start script and removes the key instead, so devices upgraded from an earlier version are scrubbed. A test pins the script's shape.setItemline and the matchingremoveIteminclearConfig.window.GBKitalone as where the token lives.Testing Instructions
make test-js,make test-swift-package, andmake test-android.com.apple.WebKit.WebContentfor the Simulator). The editor should reload with the current post.GBKitkey.Note:
make test-androidfails sixHttpServerAuthenticationTestscases locally with a 407 on a valid token. They fail identically with these changes reverted, and neither the server nor the test has changed since #561.Screenshots or screencast
N/A
🤖 Generated with Claude Code
https://claude.ai/code/session_01JsMCoa3jNEuvnhxicDVRBV