Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use appropriate Namespace/Typings for Firefox build #5789

Open
martgil opened this issue Jul 10, 2024 · 0 comments
Open

Use appropriate Namespace/Typings for Firefox build #5789

martgil opened this issue Jul 10, 2024 · 0 comments

Comments

@martgil
Copy link
Collaborator

martgil commented Jul 10, 2024

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;
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant