diff --git a/.gitignore b/.gitignore index ccdd4eb..d8a40da 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ target/ .worktrees/ extension/node_modules/ extension/dist/ +extension/dist-firefox/ extension/wasm/ diff --git a/extension/manifest.firefox.json b/extension/manifest.firefox.json new file mode 100644 index 0000000..b74332f --- /dev/null +++ b/extension/manifest.firefox.json @@ -0,0 +1,36 @@ +{ + "manifest_version": 3, + "name": "idfoto", + "version": "0.1.0", + "description": "Two-factor encrypted password manager", + "browser_specific_settings": { + "gecko": { + "id": "idfoto@adlee.work", + "strict_min_version": "128.0" + } + }, + "permissions": ["storage", "activeTab", "clipboardWrite"], + "host_permissions": [""], + "background": { + "scripts": ["service-worker.js"] + }, + "action": { + "default_popup": "popup.html", + "default_icon": { + "16": "icons/icon-16.png", + "48": "icons/icon-48.png", + "128": "icons/icon-128.png" + } + }, + "content_scripts": [{ + "matches": [""], + "js": ["content.js"], + "run_at": "document_idle" + }], + "content_security_policy": { + "extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self'" + }, + "web_accessible_resources": [{ + "resources": ["setup.html", "setup.js", "styles.css", "idfoto_wasm_bg.wasm", "idfoto_wasm.js"] + }] +} diff --git a/extension/package.json b/extension/package.json index 96eca1d..f36c3dd 100644 --- a/extension/package.json +++ b/extension/package.json @@ -4,9 +4,11 @@ "private": true, "scripts": { "build": "webpack --mode production", + "build:firefox": "webpack --config webpack.firefox.config.js --mode production", + "build:all": "npm run build:wasm && npm run build && npm run build:firefox", "dev": "webpack --mode development --watch", - "build:wasm": "wasm-pack build ../crates/idfoto-wasm --target web --out-dir ../../extension/wasm", - "build:all": "npm run build:wasm && npm run build" + "dev:firefox": "webpack --config webpack.firefox.config.js --mode development --watch", + "build:wasm": "wasm-pack build ../crates/idfoto-wasm --target web --out-dir ../../extension/wasm" }, "devDependencies": { "@types/chrome": "^0.1.40", diff --git a/extension/webpack.firefox.config.js b/extension/webpack.firefox.config.js new file mode 100644 index 0000000..c7fe4c6 --- /dev/null +++ b/extension/webpack.firefox.config.js @@ -0,0 +1,36 @@ +const path = require('path'); +const CopyPlugin = require('copy-webpack-plugin'); + +module.exports = { + entry: { + 'service-worker': './src/service-worker/index.ts', + popup: './src/popup/popup.ts', + content: './src/content/detector.ts', + setup: './src/setup/setup.ts', + }, + output: { + path: path.resolve(__dirname, 'dist-firefox'), + filename: '[name].js', + clean: true, + }, + resolve: { + extensions: ['.ts', '.js'], + }, + module: { + rules: [{ test: /\.ts$/, use: 'ts-loader', exclude: /node_modules/ }], + }, + plugins: [ + new CopyPlugin({ + patterns: [ + { from: 'manifest.firefox.json', to: 'manifest.json' }, + { from: 'src/popup/index.html', to: 'popup.html' }, + { from: 'src/popup/styles.css', to: 'styles.css' }, + { from: 'setup.html', to: '.' }, + { from: 'icons', to: 'icons' }, + { from: 'wasm/idfoto_wasm_bg.wasm', to: '.' }, + { from: 'wasm/idfoto_wasm.js', to: '.' }, + ], + }), + ], + experiments: { asyncWebAssembly: true }, +};