Merge pull request #73 from twofas/feature/1.6.4

Feature/1.6.4
This commit is contained in:
Greg Zajac 2024-03-18 22:54:02 +01:00 committed by GitHub
commit 0c52f37103
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
25 changed files with 347 additions and 116 deletions

View File

@ -5,7 +5,9 @@
}, },
"modules": "commonjs" "modules": "commonjs"
}], ["minify", { }], ["minify", {
"builtIns": false "builtIns": false,
"keepFnName": true,
"removeDebugger": true
}]], }]],
"env": { "env": {
"production": { "production": {

View File

@ -1,3 +1,6 @@
API_URL= # API URL for REST requests (default: https://api2.2fas.com)
WS_URL= API_URL=https://api2.2fas.com
# Websocket URL (default: wss://ws.2fas.com)
WS_URL=wss://ws.2fas.com
# [ONLY FOR 2FAS TEAM] Key for localise.biz
LOCO_KEY= LOCO_KEY=

View File

@ -431,7 +431,7 @@
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 52; CURRENT_PROJECT_VERSION = 54;
DEAD_CODE_STRIPPING = YES; DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = ZY8UR5ADFW; DEVELOPMENT_TEAM = ZY8UR5ADFW;
ENABLE_HARDENED_RUNTIME = YES; ENABLE_HARDENED_RUNTIME = YES;
@ -445,7 +445,7 @@
"@executable_path/../../../../Frameworks", "@executable_path/../../../../Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 11.0; MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.6.3; MARKETING_VERSION = 1.6.4;
OTHER_LDFLAGS = ( OTHER_LDFLAGS = (
"-framework", "-framework",
SafariServices, SafariServices,
@ -467,7 +467,7 @@
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 52; CURRENT_PROJECT_VERSION = 54;
DEAD_CODE_STRIPPING = YES; DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = ZY8UR5ADFW; DEVELOPMENT_TEAM = ZY8UR5ADFW;
ENABLE_HARDENED_RUNTIME = YES; ENABLE_HARDENED_RUNTIME = YES;
@ -481,7 +481,7 @@
"@executable_path/../../../../Frameworks", "@executable_path/../../../../Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 11.0; MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.6.3; MARKETING_VERSION = 1.6.4;
OTHER_LDFLAGS = ( OTHER_LDFLAGS = (
"-framework", "-framework",
SafariServices, SafariServices,
@ -505,7 +505,7 @@
CODE_SIGN_ENTITLEMENTS = "macOS (App)/2FAS - Two factor authentication.entitlements"; CODE_SIGN_ENTITLEMENTS = "macOS (App)/2FAS - Two factor authentication.entitlements";
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 52; CURRENT_PROJECT_VERSION = 54;
DEAD_CODE_STRIPPING = YES; DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = ZY8UR5ADFW; DEVELOPMENT_TEAM = ZY8UR5ADFW;
ENABLE_HARDENED_RUNTIME = YES; ENABLE_HARDENED_RUNTIME = YES;
@ -520,7 +520,7 @@
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 11.0; MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.6.3; MARKETING_VERSION = 1.6.4;
OTHER_LDFLAGS = ( OTHER_LDFLAGS = (
"-framework", "-framework",
SafariServices, SafariServices,
@ -546,7 +546,7 @@
CODE_SIGN_IDENTITY = "Apple Distribution"; CODE_SIGN_IDENTITY = "Apple Distribution";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 52; CURRENT_PROJECT_VERSION = 54;
DEAD_CODE_STRIPPING = YES; DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = ZY8UR5ADFW; DEVELOPMENT_TEAM = ZY8UR5ADFW;
ENABLE_HARDENED_RUNTIME = YES; ENABLE_HARDENED_RUNTIME = YES;
@ -561,7 +561,7 @@
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 11.0; MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.6.3; MARKETING_VERSION = 1.6.4;
OTHER_LDFLAGS = ( OTHER_LDFLAGS = (
"-framework", "-framework",
SafariServices, SafariServices,

View File

@ -35,3 +35,27 @@ Please make sure your pull request includes the following:
We will review your pull request and provide feedback as soon as possible. Thank you for your contribution! We will review your pull request and provide feedback as soon as possible. Thank you for your contribution!
By sharing ideas and code with the 2FAS community, either through GitHub or Discord, you agree that these contributions become the property of the 2FAS community and may be implemented into the 2FAS open source code. By sharing ideas and code with the 2FAS community, either through GitHub or Discord, you agree that these contributions become the property of the 2FAS community and may be implemented into the 2FAS open source code.
## Project setup
### Requirements
Before you start, you should have installed:
- NodeJS (currently used version is always available in `.nvmrc` and `package.json` files). If you have installed `nvm`, you can use `nvm use` command in project directory.
- latest `npm` or `yarn`
### First build
1. Copy `.env.example` file and save it as `.env`
2. Run `npm install` or `yarn install`
3. Run command for chosen browser (f.e. `npm run chrome-dev` or `yarn chrome-dev` for Chrome browser)
### Useful scripts
`chrome-dev`, `opera-dev`, `firefox-dev`, `edge-dev`, `safari-dev` - These scripts build extension code for development for chosen browser (without production mode, browserlist-update etc.)
`chrome-prod`, `opera-prod`, `firefox-prod`, `edge-prod`, `safari-prod` - These scripts build production extension code.
`chrome-build`, `opera-build`, `firefox-build`, `edge-build` - These scripts build production extension code and creates zip files for it. There is no script for Safari, because Safari version is created by xCode.
`all-build` - Script that performs build for all browsers (except Safari).
`firefox-run` - Additional script for `web-ext` tool for Firefox. You can read more about `web-ext` [`here`](https://github.com/mozilla/web-ext).
Other scripts are only aliases for longer commands. You don't need to know them and you shouldn't run them separately.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,35 +1,37 @@
{ {
"name": "2fas-browser-extension", "name": "2fas-browser-extension",
"version": "1.6.3", "version": "1.6.4",
"description": "This is the official Browser Extension for the Open Source 2FAS project.", "description": "This is the official Browser Extension for the Open Source 2FAS project.",
"engines": { "engines": {
"node": "20.9.0" "node": "20.9.0"
}, },
"scripts": { "scripts": {
"clean": "rimraf --glob ./public/*", "clean": "npx -y rimraf --glob ./public/*",
"chrome-dev": "yarn clean && yarn generate-locales && cross-env EXT_PLATFORM=Chrome node_modules/.bin/webpack --mode development --progress --config webpack/development.config.js", "chrome-dev": "yon clean && yon generate-locales && npx -y cross-env EXT_PLATFORM=Chrome node_modules/.bin/webpack --mode development --progress --config webpack/development.config.js",
"chrome-prod": "yarn clean && yarn generate-locales && npx update-browserslist-db@latest && cross-env EXT_PLATFORM=Chrome NODE_ENV=production node_modules/.bin/webpack --mode production --progress --config webpack/production.config.js", "chrome-prod": "yon clean && yon generate-locales && yon browserlist-update && npx -y cross-env EXT_PLATFORM=Chrome NODE_ENV=production node_modules/.bin/webpack --mode production --progress --config webpack/production.config.js",
"chrome-build": "yarn chrome-prod && rimraf ./public/.gitkeep && powershell Compress-Archive ./public/* ./build/chrome_ext_%npm_package_version%.zip", "chrome-build": "yon chrome-prod && npx -y rimraf ./public/.gitkeep && yon check-build-directory && npx -y cross-env PLATFORM=Chrome yon zip-build",
"opera-dev": "yarn clean && yarn generate-locales && cross-env EXT_PLATFORM=Opera node_modules/.bin/webpack --mode development --progress --config webpack/development.config.js", "opera-dev": "yon clean && yon generate-locales && npx -y cross-env EXT_PLATFORM=Opera node_modules/.bin/webpack --mode development --progress --config webpack/development.config.js",
"opera-prod": "yarn clean && yarn generate-locales && npx update-browserslist-db@latest && cross-env EXT_PLATFORM=Opera NODE_ENV=production node_modules/.bin/webpack --mode production --progress --config webpack/production.config.js", "opera-prod": "yon clean && yon generate-locales && yon browserlist-update && npx -y cross-env EXT_PLATFORM=Opera NODE_ENV=production node_modules/.bin/webpack --mode production --progress --config webpack/production.config.js",
"opera-build": "yarn opera-prod && rimraf ./public/.gitkeep && powershell Compress-Archive ./public/* ./build/opera_ext_%npm_package_version%.zip", "opera-build": "yon opera-prod && npx -y rimraf ./public/.gitkeep && yon check-build-directory && npx -y cross-env PLATFORM=Opera yon zip-build",
"firefox-dev": "yarn clean && yarn generate-locales && cross-env EXT_PLATFORM=Firefox node_modules/.bin/webpack --mode development --progress --config webpack/development.config.js", "firefox-dev": "yon clean && yon generate-locales && npx -y cross-env EXT_PLATFORM=Firefox node_modules/.bin/webpack --mode development --progress --config webpack/development.config.js",
"firefox-prod": "yarn clean && yarn generate-locales && npx update-browserslist-db@latest && cross-env EXT_PLATFORM=Firefox NODE_ENV=production node_modules/.bin/webpack --mode production --progress --config webpack/production.config.js", "firefox-prod": "yon clean && yon generate-locales && yon browserlist-update && npx -y cross-env EXT_PLATFORM=Firefox NODE_ENV=production node_modules/.bin/webpack --mode production --progress --config webpack/production.config.js",
"firefox-build": "yarn firefox-prod && rimraf ./public/.gitkeep && powershell Compress-Archive ./public/* ./build/firefox_ext_%npm_package_version%.zip", "firefox-build": "yon firefox-prod && npx -y rimraf ./public/.gitkeep && yon check-build-directory && npx -y cross-env PLATFORM=Firefox yon zip-build",
"firefox-run": "web-ext run --source-dir ./public/", "firefox-run": "npx -y web-ext run --source-dir ./public/",
"edge-dev": "yarn clean && yarn generate-locales && cross-env EXT_PLATFORM=Edge node_modules/.bin/webpack --mode development --progress --config webpack/development.config.js", "edge-dev": "yon clean && yon generate-locales && npx -y cross-env EXT_PLATFORM=Edge node_modules/.bin/webpack --mode development --progress --config webpack/development.config.js",
"edge-prod": "yarn clean && yarn generate-locales && npx update-browserslist-db@latest && cross-env EXT_PLATFORM=Edge NODE_ENV=production node_modules/.bin/webpack --mode production --progress --config webpack/production.config.js", "edge-prod": "yon clean && yon generate-locales && yon browserlist-update && npx -y cross-env EXT_PLATFORM=Edge NODE_ENV=production node_modules/.bin/webpack --mode production --progress --config webpack/production.config.js",
"edge-build": "yarn edge-prod && rimraf ./public/.gitkeep && powershell Compress-Archive ./public/* ./build/edge_ext_%npm_package_version%.zip", "edge-build": "yon edge-prod && npx -y rimraf ./public/.gitkeep && yon check-build-directory && npx -y cross-env PLATFORM=Edge yon zip-build",
"safari-dev": "yarn clean && yarn generate-locales && cross-env EXT_PLATFORM=Safari node_modules/.bin/webpack --mode development --progress --config webpack/development.config.js", "safari-dev": "yon clean && yon generate-locales && npx -y cross-env EXT_PLATFORM=Safari node_modules/.bin/webpack --mode development --progress --config webpack/development.config.js",
"safari-prod": "yarn clean && yarn generate-locales && npx update-browserslist-db@latest && cross-env EXT_PLATFORM=Safari NODE_ENV=production node_modules/.bin/webpack --mode production --progress --config webpack/production.config.js", "safari-prod": "yon clean && yon generate-locales && yon browserlist-update && npx -y cross-env EXT_PLATFORM=Safari NODE_ENV=production node_modules/.bin/webpack --mode production --progress --config webpack/production.config.js",
"all-build": "rimraf --glob ./build/* && yarn generate-license-info && yarn chrome-build && yarn opera-build && yarn firefox-build && yarn edge-build", "all-build": "npx -y rimraf --glob ./build/* && yon generate-license-info && yon chrome-build && yon opera-build && yon firefox-build && yon edge-build",
"browserlist-update": "npx update-browserslist-db@latest", "browserlist-update": "npx -y update-browserslist-db@latest",
"loco-export": "node webpack/utils/locoExport.js", "loco-export": "node webpack/utils/locoExport.js",
"loco-import": "node webpack/utils/locoImport.js", "loco-import": "node webpack/utils/locoImport.js",
"check-build-directory": "node webpack/utils/checkBuildDirectoryExists.js",
"generate-locales": "node webpack/utils/generateLocales.js", "generate-locales": "node webpack/utils/generateLocales.js",
"generate-license-info-html": "license-report --output=html >> open-source-licenses.html", "generate-license-info-html": "npx -y license-report --output=html >> open-source-licenses.html",
"generate-license-info-json": "license-report --output=json >> open-source-licenses.json", "generate-license-info-json": "npx -y license-report --output=json >> open-source-licenses.json",
"generate-license-info": "yarn generate-license-info-html && yarn generate-license-info-json" "generate-license-info": "yon generate-license-info-html && yon generate-license-info-json",
"zip-build": "cd ./public/ && npx -y cross-var npx -y bestzip ../build/$PLATFORM_ext_$npm_package_version.zip * & cd .."
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -49,17 +51,14 @@
"url": "https://2fas.com/donate/" "url": "https://2fas.com/donate/"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.23.9", "@babel/core": "^7.24.0",
"@babel/eslint-parser": "^7.23.10", "@babel/eslint-parser": "^7.23.10",
"@babel/plugin-transform-runtime": "^7.23.9", "@babel/plugin-transform-runtime": "^7.24.0",
"@babel/preset-env": "^7.23.9", "@babel/preset-env": "^7.24.0",
"@babel/register": "^7.22.15", "@babel/register": "^7.22.15",
"@babel/runtime": "^7.23.9", "autoprefixer": "^10.4.18",
"autoprefixer": "^10.4.17",
"babel-loader": "^9.1.3", "babel-loader": "^9.1.3",
"babel-plugin-dynamic-import-node": "^2.3.3",
"babel-plugin-transform-minify-booleans": "^6.9.4", "babel-plugin-transform-minify-booleans": "^6.9.4",
"babel-plugin-transform-remove-console": "^6.9.4",
"babel-plugin-transform-remove-debugger": "^6.9.4", "babel-plugin-transform-remove-debugger": "^6.9.4",
"babel-preset-minify": "^0.5.2", "babel-preset-minify": "^0.5.2",
"browserslist": "^4.23.0", "browserslist": "^4.23.0",
@ -82,11 +81,11 @@
"file-loader": "^6.0.0", "file-loader": "^6.0.0",
"html-loader": "^5.0.0", "html-loader": "^5.0.0",
"html-webpack-plugin": "^5.5.3", "html-webpack-plugin": "^5.5.3",
"mini-css-extract-plugin": "^2.8.0", "mini-css-extract-plugin": "^2.8.1",
"noop-loader": "^1.0.0", "noop-loader": "^1.0.0",
"path": "^0.12.7", "path": "^0.12.7",
"postcss": "^8.4.35", "postcss": "^8.4.35",
"postcss-loader": "^8.1.0", "postcss-loader": "^8.1.1",
"postcss-sass": "^0.5.0", "postcss-sass": "^0.5.0",
"precss": "^4.0.0", "precss": "^4.0.0",
"require-dir": "^1.2.0", "require-dir": "^1.2.0",
@ -97,9 +96,9 @@
"stream-browserify": "^3.0.0", "stream-browserify": "^3.0.0",
"streamify": "^1.0.0", "streamify": "^1.0.0",
"style-loader": "^3.3.4", "style-loader": "^3.3.4",
"stylelint": "^15.10.3", "stylelint": "^16.2.1",
"stylelint-config-recommended-scss": "^13.1.0", "stylelint-config-recommended-scss": "^14.0.0",
"stylelint-webpack-plugin": "^4.1.1", "stylelint-webpack-plugin": "^5.0.0",
"svg-inline-loader": "^0.8.2", "svg-inline-loader": "^0.8.2",
"terser-webpack-plugin": "^5.3.9", "terser-webpack-plugin": "^5.3.9",
"url-loader": "^4.1.0", "url-loader": "^4.1.0",
@ -107,9 +106,11 @@
"webpack": "^5.90.3", "webpack": "^5.90.3",
"webpack-cli": "^5.1.4", "webpack-cli": "^5.1.4",
"webpack-node-externals": "^3.0.0", "webpack-node-externals": "^3.0.0",
"ws": "^8.14.1" "ws": "^8.14.1",
"yarn-or-npm": "^3.0.1"
}, },
"dependencies": { "dependencies": {
"@babel/runtime": "^7.24.0",
"qrcode": "^1.5.3", "qrcode": "^1.5.3",
"uuid": "^9.0.0" "uuid": "^9.0.0"
} }

View File

@ -23,7 +23,7 @@ const t = require('./_locales/en/notifications.json');
const config = { const config = {
WebSocketTimeout: 3, // in minutes WebSocketTimeout: 3, // in minutes
ResendPushTimeout: 10, // in seconds ResendPushTimeout: 10, // in seconds
ExtensionVersion: '1.6.3', ExtensionVersion: '1.6.4',
Texts: { Texts: {
Error: { Error: {

View File

@ -62,7 +62,7 @@ const inputToken = (request, inputElement, siteURL) => {
document.activeElement.dispatchEvent(inputEvent); document.activeElement.dispatchEvent(inputEvent);
// NORTON FIX // NORTON FIX
if (siteURL.includes('login.norton')) { if (siteURL.includes('login.norton') || siteURL.includes('indodax.com')) {
document.activeElement.dispatchEvent(new KeyboardEvent('keyup', { key: request.token[i] })); document.activeElement.dispatchEvent(new KeyboardEvent('keyup', { key: request.token[i] }));
} }
// END NORTON FIX // END NORTON FIX

View File

@ -46,17 +46,17 @@ const createObserver = tabData => {
if ( if (
(mutation?.addedNodes && Array.from(mutation?.addedNodes).length > 0) || (mutation?.addedNodes && Array.from(mutation?.addedNodes).length > 0) ||
(mutation?.attributeName === 'disabled' && !mutation?.target?.disabled) || (mutation?.attributeName === 'disabled' && !mutation?.target?.disabled) ||
(mutation?.attirbuteName === 'style' && mutation?.target) (mutation?.attributeName === 'style' && mutation?.target)
) { ) {
addedNodes(mutation, tabData); addedNodes(mutation, tabData);
} }
if (mutation?.type === 'attributes' && mutation?.target) { if (mutation?.type === 'attributes' && mutation?.target) {
await hiddenNodes(mutation, tabData); hiddenNodes(mutation, tabData);
} }
if (mutation?.removedNodes && Array.from(mutation?.removedNodes).length > 0) { if (mutation?.removedNodes && Array.from(mutation?.removedNodes).length > 0) {
await removedNodes(mutation, tabData); removedNodes(mutation, tabData);
} }
}); });
}); });

View File

@ -18,13 +18,16 @@
// //
const notObservedNodes = [ const notObservedNodes = [
'a',
'g', 'g',
'path', 'path',
'html',
'body', 'body',
'head', 'head',
'link', 'link',
'style', 'style',
'script', 'script',
'noscript',
'title', 'title',
'#cdata-section', '#cdata-section',
'#comment', '#comment',
@ -34,29 +37,51 @@ const notObservedNodes = [
'area', 'area',
'audio', 'audio',
'b', 'b',
'base',
'bdi', 'bdi',
'bdo', 'bdo',
'blockquote', 'blockquote',
'br', 'br',
'button',
'canvas', 'canvas',
'caption', 'caption',
'cite', 'cite',
'code', 'code',
'data',
'dd',
'del',
'details',
'dfn',
'dialog', 'dialog',
'dl',
'dt',
'em', 'em',
'embed',
'figure',
'hr', 'hr',
'i', 'i',
'img', 'img',
'ins', 'ins',
'label',
'legend', 'legend',
'map', 'map',
'mark', 'mark',
'meta', 'meta',
'meter',
'object',
'optgroup',
'option', 'option',
'output',
'param',
'picture', 'picture',
'pre', 'pre',
'progress', 'progress',
'q', 'q',
'rp',
'rt',
'ruby',
's',
'samp',
'search', 'search',
'select', 'select',
'small', 'small',
@ -64,11 +89,15 @@ const notObservedNodes = [
'strong', 'strong',
'sub', 'sub',
'sup', 'sup',
'svg',
'summary', 'summary',
'template',
'time',
'track', 'track',
'u', 'u',
'var', 'var',
'video', 'video',
'wbr',
// custom // custom
'tool-tip' 'tool-tip'
]; ];

View File

@ -17,23 +17,34 @@
// along with this program. If not, see <https://www.gnu.org/licenses/> // along with this program. If not, see <https://www.gnu.org/licenses/>
// //
/* global requestAnimationFrame */
const browser = require('webextension-polyfill'); const browser = require('webextension-polyfill');
const findSignificantChanges = require('./findSignificantChanges'); const findSignificantChanges = require('./findSignificantChanges');
const { getInputs, addInputListener, clearFormElementsNumber, addFormElementsNumber, getFormElements } = require('../../functions'); const { getInputs, addInputListener, clearFormElementsNumber, addFormElementsNumber, getFormElements } = require('../../functions');
const getChildNodes = require('./getChildNodes'); const getChildNodes = require('./getChildNodes');
const storeLog = require('../../../partials/storeLog'); const storeLog = require('../../../partials/storeLog');
const notObservedNodes = require('../observerConstants/notObservedNodes'); const notObservedNodes = require('../observerConstants/notObservedNodes');
const uniqueOnly = require('../../../partials/uniqueOnly');
let queue = []; let queue = [];
let tabData = null; let tabData = null;
let timeout;
const process = nodes => { const process = nodes => {
if (document.readyState !== 'complete') {
timeout = window.requestAnimationFrame(() => process(nodes));
}
if (!nodes || nodes.length <= 0 || !tabData) { if (!nodes || nodes.length <= 0 || !tabData) {
return false; return false;
} }
const addedNodes = nodes.filter((value, index, array) => array.indexOf(value) === index); const addedNodes =
nodes
.filter(uniqueOnly)
.filter(node => !notObservedNodes.includes(node.nodeName.toLowerCase()))
.flatMap(getChildNodes)
.filter(uniqueOnly)
.filter(node => !notObservedNodes.includes(node.nodeName.toLowerCase()));
let newInputs = false; let newInputs = false;
let inputs = []; let inputs = [];
@ -73,24 +84,18 @@ const addedNodes = (mutation, tabInfo) => {
return false; return false;
} }
const newNodes = queue.push(mutation.target);
Array.from(mutation?.addedNodes) queue.push(...Array.from(mutation.addedNodes));
.concat(...(Array.from(mutation?.addedNodes).map(node => getChildNodes(node))))
.concat(mutation?.target)
.concat(...getChildNodes(mutation.target))
.filter(node => !notObservedNodes.includes(node.nodeName.toLowerCase()));
if (!newNodes || newNodes.length <= 0) {
return false;
}
queue.push(...newNodes);
if (!tabData) { if (!tabData) {
tabData = tabInfo; tabData = tabInfo;
} }
return requestAnimationFrame(() => process(queue)); if (timeout) {
window.cancelAnimationFrame(timeout);
}
timeout = window.requestAnimationFrame(() => process(queue));
}; };
module.exports = addedNodes; module.exports = addedNodes;

View File

@ -17,7 +17,6 @@
// along with this program. If not, see <https://www.gnu.org/licenses/> // along with this program. If not, see <https://www.gnu.org/licenses/>
// //
/* global requestAnimationFrame */
const browser = require('webextension-polyfill'); const browser = require('webextension-polyfill');
const isVisible = require('../../functions/isVisible'); const isVisible = require('../../functions/isVisible');
const findSignificantChanges = require('./findSignificantChanges'); const findSignificantChanges = require('./findSignificantChanges');
@ -25,16 +24,28 @@ const getChildNodes = require('./getChildNodes');
const { loadFromLocalStorage, saveToLocalStorage } = require('../../../localStorage'); const { loadFromLocalStorage, saveToLocalStorage } = require('../../../localStorage');
const storeLog = require('../../../partials/storeLog'); const storeLog = require('../../../partials/storeLog');
const { clearFormElementsNumber, addFormElementsNumber, getFormElements } = require('../../functions'); const { clearFormElementsNumber, addFormElementsNumber, getFormElements } = require('../../functions');
const uniqueOnly = require('../../../partials/uniqueOnly');
let queue = []; let queue = [];
let tabData = null; let tabData = null;
let timeout;
const process = async nodes => { const process = async nodes => {
if (document.readyState !== 'complete') {
timeout = window.requestAnimationFrame(() => process(nodes));
}
if (!nodes || nodes.length <= 0 || !tabData) { if (!nodes || nodes.length <= 0 || !tabData) {
return false; return false;
} }
const hiddenNodes = nodes.filter((value, index, array) => array.indexOf(value) === index); const hiddenNodes =
nodes
.filter(uniqueOnly)
.filter(node => findSignificantChanges(node) && node.getAttribute('data-twofas-input'))
.flatMap(getChildNodes)
.filter(uniqueOnly)
.filter(node => findSignificantChanges(node) && node.getAttribute('data-twofas-input'));
let storage; let storage;
@ -69,27 +80,22 @@ const process = async nodes => {
}); });
}; };
const hiddenNodes = async (mutation, tabInfo) => { const hiddenNodes = (mutation, tabInfo) => {
if (!mutation?.target || !browser?.runtime?.id) { if (!mutation?.target || !browser?.runtime?.id) {
return false; return false;
} }
const hiddenInputs = queue.push(mutation.target);
Array.from([...getChildNodes(mutation.target)])
.concat(mutation.target)
.filter(node => findSignificantChanges(node) && node.getAttribute('data-twofas-input'));
if (!hiddenInputs || hiddenInputs.length <= 0) {
return false;
}
queue.push(...hiddenInputs);
if (!tabData) { if (!tabData) {
tabData = tabInfo; tabData = tabInfo;
} }
return requestAnimationFrame(() => process(queue)); if (timeout) {
window.cancelAnimationFrame(timeout);
}
timeout = window.requestAnimationFrame(() => process(queue));
}; };
module.exports = hiddenNodes; module.exports = hiddenNodes;

View File

@ -17,7 +17,6 @@
// along with this program. If not, see <https://www.gnu.org/licenses/> // along with this program. If not, see <https://www.gnu.org/licenses/>
// //
/* global requestAnimationFrame */
const browser = require('webextension-polyfill'); const browser = require('webextension-polyfill');
const significantInputs = require('../observerConstants/significantInputs'); const significantInputs = require('../observerConstants/significantInputs');
const { loadFromLocalStorage, saveToLocalStorage } = require('../../../localStorage'); const { loadFromLocalStorage, saveToLocalStorage } = require('../../../localStorage');
@ -25,11 +24,17 @@ const getChildNodes = require('./getChildNodes');
const storeLog = require('../../../partials/storeLog'); const storeLog = require('../../../partials/storeLog');
const { clearFormElementsNumber, addFormElementsNumber, getFormElements } = require('../../functions'); const { clearFormElementsNumber, addFormElementsNumber, getFormElements } = require('../../functions');
const notObservedNodes = require('../observerConstants/notObservedNodes'); const notObservedNodes = require('../observerConstants/notObservedNodes');
const uniqueOnly = require('../../../partials/uniqueOnly');
let queue = []; let queue = [];
let tabData = null; let tabData = null;
let timeout;
const process = async nodes => { const process = async nodes => {
if (document.readyState !== 'complete') {
timeout = window.requestAnimationFrame(() => process(nodes));
}
if (!nodes || nodes.length <= 0 || !tabData) { if (!nodes || nodes.length <= 0 || !tabData) {
return false; return false;
} }
@ -37,7 +42,13 @@ const process = async nodes => {
const ids = []; const ids = [];
let storage; let storage;
const removedNodes = nodes.filter((value, index, array) => array.indexOf(value) === index); const removedNodes =
nodes
.filter(uniqueOnly)
.filter(node => !notObservedNodes.includes(node.nodeName.toLowerCase()))
.flatMap(getChildNodes)
.filter(uniqueOnly)
.filter(node => !notObservedNodes.includes(node.nodeName.toLowerCase()));
removedNodes.forEach(node => { removedNodes.forEach(node => {
const nodeName = node.nodeName.toLowerCase(); const nodeName = node.nodeName.toLowerCase();
@ -80,29 +91,23 @@ const process = async nodes => {
.catch(err => storeLog('error', 40, err, tabData?.url)); .catch(err => storeLog('error', 40, err, tabData?.url));
}; };
const removedNodes = async (mutation, tabInfo) => { const removedNodes = (mutation, tabInfo) => {
if (!mutation?.target || !browser?.runtime?.id) { if (!mutation?.target || !browser?.runtime?.id) {
return false; return false;
} }
const nodes = queue.push(mutation.target);
Array.from(mutation?.removedNodes) queue.push(...Array.from(mutation.removedNodes));
.concat(...(Array.from(mutation?.removedNodes).map(node => getChildNodes(node))))
.concat(mutation?.target)
.concat(...getChildNodes(mutation.target))
.filter(node => !notObservedNodes.includes(node.nodeName.toLowerCase()));
if (!nodes || nodes.length <= 0) {
return false;
}
queue.push(...nodes);
if (!tabData) { if (!tabData) {
tabData = tabInfo; tabData = tabInfo;
} }
return requestAnimationFrame(() => process(queue)); if (timeout) {
window.cancelAnimationFrame(timeout);
}
timeout = window.requestAnimationFrame(() => process(queue));
}; };
module.exports = removedNodes; module.exports = removedNodes;

View File

@ -3,7 +3,7 @@
"name": "2FAS - Two Factor Authentication", "name": "2FAS - Two Factor Authentication",
"short_name": "2FAS", "short_name": "2FAS",
"author": "Two Factor Authentication Service, Inc.", "author": "Two Factor Authentication Service, Inc.",
"version": "1.6.3", "version": "1.6.4",
"description": "__MSG_appDesc__", "description": "__MSG_appDesc__",
"default_locale": "en", "default_locale": "en",
"icons": { "icons": {

View File

@ -3,7 +3,7 @@
"name": "2FAS - Two Factor Authentication", "name": "2FAS - Two Factor Authentication",
"short_name": "2FAS", "short_name": "2FAS",
"author": "Two Factor Authentication Service, Inc.", "author": "Two Factor Authentication Service, Inc.",
"version": "1.6.3", "version": "1.6.4",
"description": "__MSG_appDesc__", "description": "__MSG_appDesc__",
"default_locale": "en", "default_locale": "en",
"icons": { "icons": {

View File

@ -3,7 +3,7 @@
"name": "2FAS - Two Factor Authentication", "name": "2FAS - Two Factor Authentication",
"short_name": "2FAS", "short_name": "2FAS",
"author": "Two Factor Authentication Service, Inc.", "author": "Two Factor Authentication Service, Inc.",
"version": "1.6.3", "version": "1.6.4",
"applications": { "applications": {
"gecko": { "gecko": {
"id": "admin@2fas.com", "id": "admin@2fas.com",

View File

@ -3,7 +3,7 @@
"name": "2FAS - Two Factor Authentication", "name": "2FAS - Two Factor Authentication",
"short_name": "2FAS", "short_name": "2FAS",
"author": "Two Factor Authentication Service, Inc.", "author": "Two Factor Authentication Service, Inc.",
"version": "1.6.3", "version": "1.6.4",
"description": "__MSG_appDesc__", "description": "__MSG_appDesc__",
"default_locale": "en", "default_locale": "en",
"icons": { "icons": {

View File

@ -3,7 +3,7 @@
"name": "2FAS - Two Factor Authentication", "name": "2FAS - Two Factor Authentication",
"short_name": "2FAS", "short_name": "2FAS",
"author": "Two Factor Authentication Service, Inc.", "author": "Two Factor Authentication Service, Inc.",
"version": "1.6.3", "version": "1.6.4",
"description": "__MSG_appDesc__", "description": "__MSG_appDesc__",
"default_locale": "en", "default_locale": "en",
"icons": { "icons": {

View File

@ -25,7 +25,6 @@ const webpack = require('webpack');
const path = require('path'); const path = require('path');
const ESLintPlugin = require('eslint-webpack-plugin'); const ESLintPlugin = require('eslint-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin'); const TerserPlugin = require('terser-webpack-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const backgroundProdConfig = { const backgroundProdConfig = {
name: 'background', name: 'background',
@ -64,14 +63,20 @@ const backgroundProdConfig = {
constants: 'constants' constants: 'constants'
}, },
optimization: { optimization: {
moduleIds: 'named', chunkIds: 'size',
moduleIds: 'size',
concatenateModules: true,
mangleExports: 'size',
removeAvailableModules: true, removeAvailableModules: true,
removeEmptyChunks: true, removeEmptyChunks: true,
mergeDuplicateChunks: true, mergeDuplicateChunks: true,
minimize: true,
minimizer: [ minimizer: [
new TerserPlugin(), new TerserPlugin({
new CssMinimizerPlugin() parallel: true
] })
],
nodeEnv: 'production'
}, },
resolve: { resolve: {
modules: ['node_modules'] modules: ['node_modules']

View File

@ -72,14 +72,21 @@ const contentScriptProdConfig = {
] ]
}, },
optimization: { optimization: {
moduleIds: 'named', chunkIds: 'size',
moduleIds: 'size',
concatenateModules: true,
mangleExports: 'size',
removeAvailableModules: true, removeAvailableModules: true,
removeEmptyChunks: true, removeEmptyChunks: true,
mergeDuplicateChunks: true, mergeDuplicateChunks: true,
minimize: true,
minimizer: [ minimizer: [
new TerserPlugin(), new TerserPlugin({
parallel: true
}),
new CssMinimizerPlugin() new CssMinimizerPlugin()
] ],
nodeEnv: 'production'
}, },
plugins: [ plugins: [
new ESLintPlugin({ new ESLintPlugin({

View File

@ -97,14 +97,21 @@ const installPageProdConfig = {
constants: 'constants' constants: 'constants'
}, },
optimization: { optimization: {
moduleIds: 'named', chunkIds: 'size',
moduleIds: 'size',
concatenateModules: true,
mangleExports: 'size',
removeAvailableModules: true, removeAvailableModules: true,
removeEmptyChunks: true, removeEmptyChunks: true,
mergeDuplicateChunks: true, mergeDuplicateChunks: true,
minimize: true,
minimizer: [ minimizer: [
new TerserPlugin(), new TerserPlugin({
parallel: true
}),
new CssMinimizerPlugin() new CssMinimizerPlugin()
] ],
nodeEnv: 'production'
}, },
resolve: { resolve: {
modules: ['node_modules'] modules: ['node_modules']

View File

@ -108,14 +108,21 @@ const optionsPageProdConfig = {
constants: 'constants' constants: 'constants'
}, },
optimization: { optimization: {
moduleIds: 'named', chunkIds: 'size',
moduleIds: 'size',
concatenateModules: true,
mangleExports: 'size',
removeAvailableModules: true, removeAvailableModules: true,
removeEmptyChunks: true, removeEmptyChunks: true,
mergeDuplicateChunks: true, mergeDuplicateChunks: true,
minimize: true,
minimizer: [ minimizer: [
new TerserPlugin(), new TerserPlugin({
parallel: true
}),
new CssMinimizerPlugin() new CssMinimizerPlugin()
] ],
nodeEnv: 'production'
}, },
resolve: { resolve: {
modules: ['node_modules'] modules: ['node_modules']

View File

@ -0,0 +1,24 @@
//
// This file is part of the 2FAS Browser Extension (https://github.com/twofas/2fas-browser-extension)
// Copyright © 2023 Two Factor Authentication Service, Inc.
// Contributed by Grzegorz Zając. All rights reserved.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>
//
const fs = require('node:fs');
if (!fs.existsSync('./build/')) {
fs.mkdirSync('./build');
}

View File

@ -61,6 +61,10 @@ getDirectories('./src/_locales')
}) })
}) })
.then(res => { .then(res => {
if (!fs.existsSync('./public/')) {
fs.mkdirSync('./public');
}
if (!fs.existsSync('./public/_locales')) { if (!fs.existsSync('./public/_locales')) {
fs.mkdirSync('./public/_locales'); fs.mkdirSync('./public/_locales');
} }