Skip to content

Use appropriate Namespace/Typings for Firefox build #5789

Open
@martgil

Description

@martgil

I think we can use an appropriate Namespace/Typings when building manifest.json file for Firefox - https://www.npmjs.com/package/@types/firefox-webext-browser

The project is currently reusing chrome's type definition:

addManifest('firefox-consumer', manifest => {
manifest.version = version;
// We decide to use manifest v2 for firefox and below codes are to make v3 manifest to v2
// Read more here: https://github.com/FlowCrypt/flowcrypt-browser/pull/5651#issuecomment-2029591323
manifest.manifest_version = 2;
const manifestV3 = manifest as chrome.runtime.ManifestV3;
manifest.web_accessible_resources = manifestV3.web_accessible_resources?.[0].resources;
manifest.content_security_policy = manifestV3.content_security_policy?.extension_pages;
manifest.permissions = [...(manifestV3.permissions ?? []), ...(manifestV3.host_permissions ?? [])];
delete manifest.host_permissions;
manifest.browser_action = manifestV3.action;
delete manifest.action;
manifest.browser_specific_settings = {
gecko: {
id: '[email protected]',
update_url: 'https://flowcrypt.com/api/update/firefox', // eslint-disable-line @typescript-eslint/naming-convention
strict_min_version: '112.0', // eslint-disable-line @typescript-eslint/naming-convention
},
};
manifest.background = {
type: 'module',
scripts: ['/js/service_worker/background.js'],
};
// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-unused-vars
const { service_worker, ...newManifest } = manifest.background as chrome.runtime.ManifestV3;
manifest = newManifest;
manifest.permissions = manifest.permissions?.filter((p: string) => p !== 'unlimitedStorage');
delete manifest.minimum_chrome_version;
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions