Skip to content

Commit

Permalink
Add support for Manifest V3
Browse files Browse the repository at this point in the history
  • Loading branch information
varjolintu authored and varjolintu committed Jan 27, 2024
1 parent 2c07677 commit 8e4ecdb
Show file tree
Hide file tree
Showing 21 changed files with 475 additions and 117 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
"IGNORE_FULL": true,
"IGNORE_NORMAL": true,
"IGNORE_NOTHING": true,
"importScripts": true,
"initColorTheme": true,
"isEdge": true,
"isFirefox": true,
Expand Down
21 changes: 3 additions & 18 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,11 @@ const BROWSERS = {
'Chromium': 'manifest_chromium.json',
};

async function adjustManifest(manifest) {
async function getDestinationFilename(manifest) {
const manifestFile = await fs.readFile(DEFAULT, { encoding: 'utf8' });
const data = JSON.parse(manifestFile);
const browser = manifest.substring(manifest.indexOf('_') + 1, manifest.indexOf('.'));

if (manifest.includes('firefox')) {
for (const elem in data['icons']) {
data['icons'][elem] = 'icons/keepassxc.svg';
}
for (const elem in data['browser_action']['default_icon']) {
data['browser_action']['default_icon'][elem] = 'icons/keepassxc.svg';
}
delete data['version_name'];
delete data['minimum_chrome_version'];
} else if (manifest.includes('chromium')) {
delete data['applications'];
}

await fs.writeFile(manifest, JSON.stringify(data, null, 4));
return `keepassxc-browser_${data['version']}_${browser}.zip`;
}

Expand All @@ -52,15 +38,14 @@ async function updateTranslations() {
for (const browser in BROWSERS) {
console.log(`KeePassXC-Browser: Creating extension package for ${browser}`);

const fileName = await adjustManifest(BROWSERS[browser]);
await fs.copyFile(BROWSERS[browser], `${DEST}/manifest.json`);
const fileName = await getDestinationFilename(BROWSERS[browser]);
await fs.copyFile(`./dist/${BROWSERS[browser]}`, `${DEST}/manifest.json`);

if (await fs.exists(fileName)) {
await fs.rm(fileName);
}

await zaf.zip(DEST, fileName);
await fs.rm(BROWSERS[browser], { recursive: true });
console.log('Done');
}

Expand Down
160 changes: 160 additions & 0 deletions dist/manifest_chromium.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
{
"manifest_version": 3,
"name": "KeePassXC-Browser",
"version": "1.8.11",
"version_name": "1.8.11",
"minimum_chrome_version": "93",
"description": "__MSG_extensionDescription__",
"author": "KeePassXC Team",
"icons": {
"16": "icons/keepassxc_16x16.png",
"48": "icons/keepassxc_48x48.png",
"64": "icons/keepassxc_64x64.png",
"96": "icons/keepassxc_96x96.png",
"128": "icons/keepassxc_128x128.png"
},
"action": {
"default_icon": {
"16": "icons/keepassxc_16x16.png",
"18": "icons/keepassxc_18x18.png",
"19": "icons/keepassxc_19x19.png",
"32": "icons/keepassxc_32x32.png",
"36": "icons/keepassxc_36x36.png",
"38": "icons/keepassxc_38x38.png",
"64": "icons/keepassxc_64x64.png"
},
"default_title": "KeePassXC-Browser",
"default_popup": "popups/popup.html"
},
"options_ui": {
"page": "options/options.html",
"open_in_tab": true
},
"background": {
"service_worker": "background/background_service.js"
},
"content_scripts": [
{
"matches": [
"<all_urls>"
],
"js": [
"common/browser-polyfill.min.js",
"common/global.js",
"common/global_ui.js",
"common/sites.js",
"content/ui.js",
"content/banner.js",
"content/autocomplete.js",
"content/credential-autocomplete.js",
"content/custom-fields-banner.js",
"content/fields.js",
"content/fill.js",
"content/form.js",
"content/icons.js",
"content/keepassxc-browser.js",
"content/observer-helper.js",
"content/pwgen.js",
"content/totp-autocomplete.js",
"content/totp-field.js",
"content/username-field.js",
"content/passkeys-utils.js"
],
"run_at": "document_idle",
"all_frames": true
}
],
"commands": {
"fill_username_password": {
"description": "__MSG_contextMenuFillUsernameAndPassword__",
"suggested_key": {
"default": "Alt+Shift+U",
"mac": "MacCtrl+Shift+U"
}
},
"fill_password": {
"description": "__MSG_contextMenuFillPassword__",
"suggested_key": {
"default": "Alt+Shift+I",
"mac": "MacCtrl+Shift+I"
}
},
"fill_totp": {
"description": "__MSG_contextMenuFillTOTP__",
"suggested_key": {
"default": "Alt+Shift+O",
"mac": "MacCtrl+Shift+O"
}
},
"show_password_generator": {
"description": "__MSG_contextMenuShowPasswordGenerator__",
"suggested_key": {
"default": "Alt+Shift+G",
"mac": "MacCtrl+Shift+G"
}
},
"save_credentials": {
"description": "__MSG_contextMenuSaveCredentials__"
},
"redetect_fields": {
"description": "__MSG_popupRedetectButton__"
},
"choose_credential_fields": {
"description": "__MSG_popupChooseCredentialsText__"
},
"retrive_credentials_forced": {
"description": "__MSG_popupReopenButton__"
},
"request_autotype": {
"description": "__MSG_contextMenuRequestGlobalAutoType__"
},
"reload_extension": {
"description": "__MSG_popupReloadButton__"
}
},
"web_accessible_resources": [{
"resources": [
"icons/disconnected.svg",
"icons/help.svg",
"icons/keepassxc.svg",
"icons/key.svg",
"icons/locked.svg",
"icons/otp.svg",
"css/autocomplete.css",
"css/banner.css",
"css/button.css",
"css/colors.css",
"css/define.css",
"css/notification.css",
"css/pwgen.css",
"css/username.css",
"css/totp.css",
"content/passkeys.js"
],
"matches": [
"https://*/*",
"http://*/*"
]
}],
"permissions": [
"activeTab",
"contextMenus",
"clipboardWrite",
"nativeMessaging",
"notifications",
"storage",
"tabs",
"webNavigation",
"webRequest",
"webRequestAuthProvider",
"webRequestBlocking"
],
"content_security_policy": {
"extension_pages": "script-src 'self'"
},
"host_permissions": [
"https://*/*",
"http://*/*"
],
"default_locale": "en"
}
166 changes: 166 additions & 0 deletions dist/manifest_firefox.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
{
"manifest_version": 2,
"name": "KeePassXC-Browser",
"version": "1.8.11",
"description": "__MSG_extensionDescription__",
"author": "KeePassXC Team",
"icons": {
"16": "icons/keepassxc.svg",
"48": "icons/keepassxc.svg",
"64": "icons/keepassxc.svg",
"96": "icons/keepassxc.svg",
"128": "icons/keepassxc.svg"
},
"browser_action": {
"default_icon": {
"16": "icons/keepassxc.svg",
"18": "icons/keepassxc.svg",
"19": "icons/keepassxc.svg",
"32": "icons/keepassxc.svg",
"36": "icons/keepassxc.svg",
"38": "icons/keepassxc.svg",
"64": "icons/keepassxc.svg"
},
"default_title": "KeePassXC-Browser",
"default_popup": "popups/popup.html"
},
"options_ui": {
"page": "options/options.html",
"open_in_tab": true
},
"background": {
"scripts": [
"common/browser-polyfill.min.js",
"common/global.js",
"common/sites.js",
"background/nacl.min.js",
"background/nacl-util.min.js",
"background/client.js",
"background/keepass.js",
"background/httpauth.js",
"background/browserAction.js",
"background/page.js",
"background/event.js",
"background/init.js"
]
},
"content_scripts": [
{
"matches": [
"<all_urls>"
],
"js": [
"common/browser-polyfill.min.js",
"common/global.js",
"common/sites.js",
"content/ui.js",
"content/banner.js",
"content/autocomplete.js",
"content/credential-autocomplete.js",
"content/custom-fields-banner.js",
"content/fields.js",
"content/fill.js",
"content/form.js",
"content/icons.js",
"content/keepassxc-browser.js",
"content/observer-helper.js",
"content/pwgen.js",
"content/totp-autocomplete.js",
"content/totp-field.js",
"content/username-field.js",
"content/passkeys-utils.js"
],
"run_at": "document_idle",
"all_frames": true
}
],
"commands": {
"fill_username_password": {
"description": "__MSG_contextMenuFillUsernameAndPassword__",
"suggested_key": {
"default": "Alt+Shift+U",
"mac": "MacCtrl+Shift+U"
}
},
"fill_password": {
"description": "__MSG_contextMenuFillPassword__",
"suggested_key": {
"default": "Alt+Shift+I",
"mac": "MacCtrl+Shift+I"
}
},
"fill_totp": {
"description": "__MSG_contextMenuFillTOTP__",
"suggested_key": {
"default": "Alt+Shift+O",
"mac": "MacCtrl+Shift+O"
}
},
"show_password_generator": {
"description": "__MSG_contextMenuShowPasswordGenerator__",
"suggested_key": {
"default": "Alt+Shift+G",
"mac": "MacCtrl+Shift+G"
}
},
"save_credentials": {
"description": "__MSG_contextMenuSaveCredentials__"
},
"redetect_fields": {
"description": "__MSG_popupRedetectButton__"
},
"choose_credential_fields": {
"description": "__MSG_popupChooseCredentialsText__"
},
"retrive_credentials_forced": {
"description": "__MSG_popupReopenButton__"
},
"request_autotype": {
"description": "__MSG_contextMenuRequestGlobalAutoType__"
},
"reload_extension": {
"description": "__MSG_popupReloadButton__"
}
},
"web_accessible_resources": [
"icons/disconnected.svg",
"icons/help.svg",
"icons/keepassxc.svg",
"icons/key.svg",
"icons/locked.svg",
"icons/otp.svg",
"css/autocomplete.css",
"css/banner.css",
"css/button.css",
"css/colors.css",
"css/define.css",
"css/notification.css",
"css/pwgen.css",
"css/username.css",
"css/totp.css",
"content/passkeys.js"
],
"permissions": [
"activeTab",
"contextMenus",
"clipboardWrite",
"nativeMessaging",
"notifications",
"storage",
"tabs",
"webNavigation",
"webRequest",
"webRequestBlocking",
"https://*/*",
"http://*/*",
"https://api.github.com/"
],
"content_security_policy": "script-src 'self' 'sha256-4nJ8uLezzRE3SiBFdkVN/uNwV9YTOGCqRXg6AvB5rCY='; object-src 'none'",
"applications": {
"gecko": {
"id": "keepassxc-browser@keepassxc.org",
"strict_min_version": "67.0"
}
},
"default_locale": "en"
}
Loading

0 comments on commit 8e4ecdb

Please sign in to comment.