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:
parent
3d43021b72
commit
fbfdab048b
2 changed files with 14 additions and 2 deletions
|
|
@ -10,7 +10,8 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"cloudFile"
|
"cloudFile",
|
||||||
|
"storage"
|
||||||
],
|
],
|
||||||
"host_permissions": [
|
"host_permissions": [
|
||||||
"http://*/*",
|
"http://*/*",
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,19 @@
|
||||||
const ACCOUNT_PREFIX = "account:";
|
const ACCOUNT_PREFIX = "account:";
|
||||||
const FILE_PREFIX = "uploaded-file:";
|
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 {
|
export class AccountStore {
|
||||||
constructor(storageArea = globalThis.browser?.storage?.local) {
|
constructor(storageArea = resolveStorageArea()) {
|
||||||
this.storageArea = storageArea;
|
this.storageArea = storageArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue