I am newer to the world of extensions, so I may not be doing this right, but when trying to save data to local storage in a content script, I'm sending a message to the background and then using the with-storage example. It appears to work when looking at the console, but when looking through dev tools, I can't find where the data is actually stored in local storage. Am I thinking about this incorrectly or is there an issue I'm missing? Background message code is below, I pulled it from the with-storage example.
import type {PlasmoMessaging} from "@plasmohq/messaging"
import {Storage} from "@plasmohq/storage";
import {SecureStorage} from "@plasmohq/storage/dist/secure";
import assert from "assert"
const PASSWORD = "password"
const TEST_KEY = "ship"
const TEST_DATA = "1701"
const handler: PlasmoMessaging.MessageHandler = async (req, res) => {
await testSecureStorage()
}
async function testSecureStorage() {
const storage = new SecureStorage({area: "local"})
await storage.clear()
await storage.setPassword(PASSWORD)
// Must set password then watch, otherwise the namespace key will mismatch
storage.watch({
[TEST_KEY]: (c) => {
console.log(TEST_KEY, c)
}
})
await storage.set(TEST_KEY, TEST_DATA)
const foo = await storage.get(TEST_KEY)
assert(foo === TEST_DATA, "ENCRYPTION FAILED")
console.log(await storage.getAll())
await storage.set(TEST_KEY, TEST_DATA + "2")
await storage.clear()
}
export default handler
Version
Latest
What OS are you seeing the problem on?
MacOSX
What browsers are you seeing the problem on?
Chrome
Relevant log output
No response
(OPTIONAL) Contribution
[ ] I would like to fix this BUG via a PR
Code of Conduct
[X] I agree to follow this project's Code of Conduct
[X] I checked the current issues for duplicate problems.
What happened?
I am newer to the world of extensions, so I may not be doing this right, but when trying to save data to local storage in a content script, I'm sending a message to the background and then using the with-storage example. It appears to work when looking at the console, but when looking through dev tools, I can't find where the data is actually stored in local storage. Am I thinking about this incorrectly or is there an issue I'm missing? Background message code is below, I pulled it from the with-storage example.
Version
Latest
What OS are you seeing the problem on?
MacOSX
What browsers are you seeing the problem on?
Chrome
Relevant log output
No response
(OPTIONAL) Contribution
Code of Conduct