mirror of
https://github.com/vale981/tridactyl
synced 2025-03-06 10:01:39 -05:00
Prevent persistent storage in incognito
This commit is contained in:
parent
ae9707c4cb
commit
480ec7a72e
2 changed files with 11 additions and 9 deletions
|
@ -2609,7 +2609,6 @@ export async function tabopenwait(...addressarr: string[]): Promise<browser.tabs
|
|||
//#background_helper
|
||||
export async function tabopen_helper({ addressarr = [], waitForDom = false }): Promise<browser.tabs.Tab> {
|
||||
let active
|
||||
let waitForDom
|
||||
let container
|
||||
|
||||
const win = await browser.windows.getCurrent()
|
||||
|
|
19
src/state.ts
19
src/state.ts
|
@ -89,10 +89,11 @@ const state = new Proxy(overlay, {
|
|||
set(target, property: keyof State, value) {
|
||||
logger.debug("State changed!", property, value)
|
||||
if (notBackground()) {
|
||||
const inIncognitoContext = browser.extension.inIncognitoContext
|
||||
browser.runtime.sendMessage({
|
||||
type: "state",
|
||||
command: "stateUpdate",
|
||||
args: { property, value },
|
||||
args: { property, value, inIncognitoContext },
|
||||
})
|
||||
return true
|
||||
}
|
||||
|
@ -101,13 +102,6 @@ const state = new Proxy(overlay, {
|
|||
|
||||
// Persist "sets" to storage in the background for some keys
|
||||
if (PERSISTENT_KEYS.includes(property)) {
|
||||
// Ensure we don't accidentally store anything sensitive
|
||||
if (browser.extension.inIncognitoContext) {
|
||||
console.error(
|
||||
"Attempted to write to storage in private window.",
|
||||
)
|
||||
return false
|
||||
}
|
||||
browser.storage.local.set({
|
||||
state: R.pick(PERSISTENT_KEYS, target),
|
||||
} as any)
|
||||
|
@ -136,6 +130,15 @@ notBackground &&
|
|||
if (message.command == "stateUpdate") {
|
||||
const property = message.args.property
|
||||
const value = message.args.value
|
||||
// Ensure we don't accidentally store anything sensitive
|
||||
const inIncognitoContext = message.args.inIncognitoContext
|
||||
if (inIncognitoContext && PERSISTENT_KEYS.includes(property)) {
|
||||
overlay[property] = value
|
||||
console.error(
|
||||
"Attempted to write to storage in private window.",
|
||||
)
|
||||
return
|
||||
}
|
||||
logger.debug("State changed!", property, value)
|
||||
state[property] = value
|
||||
} else if (message.command == "stateGet") {
|
||||
|
|
Loading…
Add table
Reference in a new issue