Add storage permission for account persistence

Include the Thunderbird storage permission required for browser.storage.local and make AccountStore fail fast when storage.local is unavailable.
This commit is contained in:
Jordan Wages 2026-04-19 18:55:38 -05:00
commit fbfdab048b
2 changed files with 14 additions and 2 deletions

View file

@ -10,7 +10,8 @@
}
},
"permissions": [
"cloudFile"
"cloudFile",
"storage"
],
"host_permissions": [
"http://*/*",

View file

@ -1,8 +1,19 @@
const ACCOUNT_PREFIX = "account:";
const FILE_PREFIX = "uploaded-file:";
function resolveStorageArea() {
const extensionApi = globalThis.browser ?? globalThis.messenger;
const storageArea = extensionApi?.storage?.local;
if (!storageArea) {
throw new Error("Extension storage.local is unavailable. Check the manifest permissions for the add-on.");
}
return storageArea;
}
export class AccountStore {
constructor(storageArea = globalThis.browser?.storage?.local) {
constructor(storageArea = resolveStorageArea()) {
this.storageArea = storageArea;
}