diff --git a/manifest.json b/manifest.json index c8ec4b3..f52161e 100644 --- a/manifest.json +++ b/manifest.json @@ -10,7 +10,8 @@ } }, "permissions": [ - "cloudFile" + "cloudFile", + "storage" ], "host_permissions": [ "http://*/*", diff --git a/src/cloudfile/account-store.js b/src/cloudfile/account-store.js index e704478..eb502de 100644 --- a/src/cloudfile/account-store.js +++ b/src/cloudfile/account-store.js @@ -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; }