Skip to content

Commit fad175c

Browse files
authored
Merge pull request #21 from codebridger/dev
Skip token writes to host local storage on dashboard origins #86exgqfpu
2 parents 55eaab3 + fd7372b commit fad175c

4 files changed

Lines changed: 60 additions & 5 deletions

File tree

CHANGELOG-DEV.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# [1.11.0-dev.4](https://github.com/codebridger/subturtle-extension-apps/compare/v1.11.0-dev.3...v1.11.0-dev.4) (2026-05-06)
2+
3+
4+
### Bug Fixes
5+
6+
* [#86](https://github.com/codebridger/subturtle-extension-apps/issues/86)exgqfpu skip token writes to host LS on dashboard origins ([838451e](https://github.com/codebridger/subturtle-extension-apps/commit/838451e9ad10d3a3755691b4ca586a0d3815a008)), closes [#86exgqfpu](https://github.com/codebridger/subturtle-extension-apps/issues/86exgqfpu)
7+
8+
# [1.11.0-dev.3](https://github.com/codebridger/subturtle-extension-apps/compare/v1.11.0-dev.2...v1.11.0-dev.3) (2026-05-04)
9+
10+
11+
### Bug Fixes
12+
13+
* persist anonymous tokens and stop logout-cascade on anon sessions ([825db93](https://github.com/codebridger/subturtle-extension-apps/commit/825db93ddf441d9c1791ae45016d85e98360e856))
14+
115
# [1.11.0-dev.2](https://github.com/codebridger/subturtle-extension-apps/compare/v1.11.0-dev.1...v1.11.0-dev.2) (2026-05-03)
216

317

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "subturtle-extension",
3-
"version": "1.11.0",
3+
"version": "1.11.0-dev.4",
44
"private": true,
55
"scripts": {
66
"dev": "webpack --watch",
@@ -60,4 +60,4 @@
6060
"vue": "3.5.17",
6161
"vue-router": "4.5.1"
6262
}
63-
}
63+
}

src/plugins/modular-rest.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,43 @@
1+
// IMPORTANT: must precede any import that may touch localStorage at module load.
2+
// Content scripts run in an "isolated world" that shares localStorage with the
3+
// host page. The dashboard at *.subturtle.app and localhost:3000 (dev) uses
4+
// `token` as its own localStorage key for the user's session — when the
5+
// extension's modular-rest client (or our explicit cache write below) writes
6+
// the extension's anonymous token there, it clobbers the dashboard user's
7+
// session and bounces them to /auth/login on the next reload or new tab.
8+
//
9+
// Block 'token' writes/removes from the content-script side on those origins.
10+
// The extension already persists tokens to chrome.storage.sync via the
11+
// background script, so losing the per-page localStorage cache only costs
12+
// one extra /user/loginAnonymous call per content-script mount on dashboard
13+
// origins — it does NOT break extension auth.
14+
function isDashboardOrigin(): boolean {
15+
if (typeof window === "undefined") return false;
16+
const host = window.location.hostname;
17+
const port = window.location.port;
18+
return (
19+
(host === "localhost" && port === "3000") ||
20+
host === "subturtle.app" ||
21+
host === "www.subturtle.app" ||
22+
host === "dashboard.subturtle.app" ||
23+
host === "www.dashboard.subturtle.app"
24+
);
25+
}
26+
27+
if (typeof Storage !== "undefined" && isDashboardOrigin()) {
28+
const origSet = Storage.prototype.setItem;
29+
const origRm = Storage.prototype.removeItem;
30+
Storage.prototype.setItem = function (k: string, v: string) {
31+
// Only suppress writes to localStorage on the dashboard, never sessionStorage.
32+
if (this === window.localStorage && k === "token") return;
33+
return origSet.call(this, k, v);
34+
};
35+
Storage.prototype.removeItem = function (k: string) {
36+
if (this === window.localStorage && k === "token") return;
37+
return origRm.call(this, k);
38+
};
39+
}
40+
141
import { GlobalOptions, authentication } from "@modular-rest/client";
242

343
import { sendMessage, sendMessageToTabs } from "../common/helper/massage";

static/manifest.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "Subturtle",
33
"description": "Turn video subtitles into English lessons. Learn new vocabulary in context as you watch on YouTube and Netflix.",
4-
"version": "1.11.0",
4+
"version": "1.11.0.4",
55
"manifest_version": 3,
66
"icons": {
77
"128": "/assets/logo-128.png",
@@ -79,5 +79,6 @@
7979
"<all_urls>"
8080
]
8181
}
82-
]
83-
}
82+
],
83+
"version_name": "1.11.0-dev.4"
84+
}

0 commit comments

Comments
 (0)