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

General Bug Fixes/Additons #96

Merged
merged 96 commits into from
Oct 23, 2018
Merged
Show file tree
Hide file tree
Changes from 92 commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
c24cade
added app name/version
walmat Oct 13, 2018
bdc6fc9
added size options grouped in the size dropdown
walmat Oct 14, 2018
f227eb1
fixed broken edit menu toggle
walmat Oct 14, 2018
565291b
progress on site data autofill
walmat Oct 14, 2018
f9e78f0
updated test cases
walmat Oct 14, 2018
bfb60d8
added site autocomplete && proxy location dropdown in the server page
walmat Oct 15, 2018
521fe3d
added core server impl.
walmat Oct 15, 2018
04e5557
added core server impl.
walmat Oct 15, 2018
d4bc58f
fixed css issues for windows
Oct 15, 2018
47b624e
alignment changes
walmat Oct 15, 2018
0db8fca
Merge branch 'issue_88' of https://github.com/walmat/nebula into issu…
walmat Oct 15, 2018
86079ab
added more css adjustments
walmat Oct 15, 2018
8beab0e
Fix Horizontal Scrolling for Create Task Size Select
pr1sm Oct 16, 2018
16cc002
captcha window changes
Oct 16, 2018
4c69f32
captcha window logic impl.
Oct 16, 2018
70748d8
added edit sizes cases
Oct 16, 2018
c4d7c57
progress on site autofill bugs
Oct 16, 2018
c6c359d
progress on site autofill bugs
Oct 16, 2018
54c73d3
buggy site autofill fixed
walmat Oct 16, 2018
6bbf279
rm console log
walmat Oct 16, 2018
8307b33
small change in site matching logic
walmat Oct 16, 2018
c196e93
simplified site matching
walmat Oct 16, 2018
6295b35
hotfix for http site autofill matching
walmat Oct 16, 2018
e02d0ec
progress on updating taskReducers~ test
Oct 16, 2018
577f384
max 5 captcha windows + map to control them, still buggy
Oct 17, 2018
2975c23
fixed buggy captcha windows
Oct 18, 2018
6f77bf2
clearing session still buggy, and closing a yt win -> trying to close…
Oct 18, 2018
70f2bd6
captcha window manager split out
Oct 19, 2018
397787c
progress on captcha window manager
walmat Oct 19, 2018
7f49b73
closing all windows finished, closing consecutive captcha windows is …
walmat Oct 19, 2018
0c9c1de
progress on youtube + captcha closing
walmat Oct 20, 2018
293e1e5
fixed captcha windows + youtube pairing
walmat Oct 20, 2018
aa94a7f
fixed else clause
walmat Oct 20, 2018
9ee61ea
added closing youtube pair when captcha closes
walmat Oct 20, 2018
c4e4f23
hotfix for closing all captchas -> youtubes
walmat Oct 20, 2018
541e51b
fixed taskReducer tests
walmat Oct 21, 2018
8ae5c58
more test fixes
Oct 21, 2018
f5e3659
pr changes
walmat Oct 21, 2018
229de34
Merge branch 'issue_88' of https://github.com/walmat/nebula into issu…
walmat Oct 21, 2018
b96f8f9
added recaptcha path to api
walmat Oct 21, 2018
dbea6f2
fixing broken tests progress
Oct 21, 2018
07883a5
tests fixed
Oct 22, 2018
bcb4549
increase test coverage
Oct 22, 2018
a031864
added app name/version
walmat Oct 13, 2018
4f5d9f2
added size options grouped in the size dropdown
walmat Oct 14, 2018
9b584ad
fixed broken edit menu toggle
walmat Oct 14, 2018
4afd340
progress on site data autofill
walmat Oct 14, 2018
cb36685
updated test cases
walmat Oct 14, 2018
12387fa
added site autocomplete && proxy location dropdown in the server page
walmat Oct 15, 2018
9bf5f17
added core server impl.
walmat Oct 15, 2018
6dc3f12
added core server impl.
walmat Oct 15, 2018
db9ac0e
fixed css issues for windows
Oct 15, 2018
33f0a20
alignment changes
walmat Oct 15, 2018
a8cf274
added more css adjustments
walmat Oct 15, 2018
ed5c577
Fix Horizontal Scrolling for Create Task Size Select
pr1sm Oct 16, 2018
b773970
captcha window changes
Oct 16, 2018
5cd4c6d
captcha window logic impl.
Oct 16, 2018
9c9e975
added edit sizes cases
Oct 16, 2018
d6be651
progress on site autofill bugs
Oct 16, 2018
eef9b9c
progress on site autofill bugs
Oct 16, 2018
1117e86
buggy site autofill fixed
walmat Oct 16, 2018
580f0b2
rm console log
walmat Oct 16, 2018
eafa011
small change in site matching logic
walmat Oct 16, 2018
cbd30a5
simplified site matching
walmat Oct 16, 2018
2891d49
hotfix for http site autofill matching
walmat Oct 16, 2018
ddce2a1
progress on updating taskReducers~ test
Oct 16, 2018
d9f7d5a
max 5 captcha windows + map to control them, still buggy
Oct 17, 2018
393db8e
fixed buggy captcha windows
Oct 18, 2018
47c0af0
clearing session still buggy, and closing a yt win -> trying to close…
Oct 18, 2018
b926440
captcha window manager split out
Oct 19, 2018
4d0db0a
progress on captcha window manager
walmat Oct 19, 2018
88d4032
closing all windows finished, closing consecutive captcha windows is …
walmat Oct 19, 2018
f2e608c
progress on youtube + captcha closing
walmat Oct 20, 2018
0a25bc5
fixed captcha windows + youtube pairing
walmat Oct 20, 2018
97162ce
fixed else clause
walmat Oct 20, 2018
b41ee6b
added closing youtube pair when captcha closes
walmat Oct 20, 2018
8f7767f
hotfix for closing all captchas -> youtubes
walmat Oct 20, 2018
7031be9
fixed taskReducer tests
walmat Oct 21, 2018
d1cfcbe
more test fixes
Oct 21, 2018
7595db6
pr changes
walmat Oct 21, 2018
9b12936
added recaptcha path to api
walmat Oct 21, 2018
071dac2
fixing broken tests progress
Oct 21, 2018
d4d3e6d
tests fixed
Oct 22, 2018
d1197f1
increase test coverage
Oct 22, 2018
eba7862
added in token check into constructor
walmat Oct 22, 2018
5aa79fb
updated init state in initialProxyOptionsState to match reducer
walmat Oct 22, 2018
3dac3c0
rm broken test error, oops!
Oct 23, 2018
18fafb3
fixed category foreach
walmat Oct 23, 2018
38f1f50
small changes/fixes
walmat Oct 23, 2018
3d804e2
fixed serverListReducer connect test
walmat Oct 23, 2018
17e9904
Merge branch 'issue_88' of https://github.com/walmat/nebula into issu…
walmat Oct 23, 2018
cd0e312
edits busted.. :(
walmat Oct 23, 2018
daf754f
fixed tokenContainer rename
walmat Oct 23, 2018
f656107
added more serverListReducer tests && progress on the taskReducer edi…
walmat Oct 23, 2018
918e207
updated flow from requested changes
walmat Oct 23, 2018
cd8c3ff
fixed renderer bug's test case
walmat Oct 23, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion frontend/lib/_electron/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const { default: installExtension, REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS } = req
* Application entry point.
*/
class App {

/**
* Initialize instance.
*/
Expand All @@ -38,6 +37,12 @@ class App {
*/
this._shell = Electron.shell;

/**
* The application's session storage
* @type {session}
*/
this._session = Electron.session;

/**
* Manage the window.
* @type {WindowManager}
Expand Down Expand Up @@ -73,6 +78,14 @@ class App {
return this._shell;
}

/**
* Get the session module.
* @return {session} Application session
*/
get session() {
return this._session;
}

/**
* Get the window manager.
*
Expand Down
2 changes: 1 addition & 1 deletion frontend/lib/_electron/authManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,4 @@ class AuthManager {
}
}

module.exports = AuthManager;
module.exports = AuthManager;
184 changes: 184 additions & 0 deletions frontend/lib/_electron/captchaWindowManager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
const IPCKeys = require('../common/constants');
const moment = require('moment');
const _ = require('underscore');

const Token = require('../common/classes/token');

class CaptchaWindowManager {
pr1sm marked this conversation as resolved.
Show resolved Hide resolved
constructor(context, captchaWindow, session) {
/**
* Application context
*/
this._context = context;

/**
* Main window reference
*/
this._main = this._context._windowManager._main;

/**
* Captcha window that the manager takes care of
*/
this._captchaWindow = captchaWindow;

/**
* Window Manager reference
*/
this._windowManager = this._context._windowManager;

/**
* YouTube window that the manager takes care of
*/
this._youtubeWindow = null;

/**
* All harvested tokens for this window
*/
this._tokens = [];

/**
* Session that the captcha window will use / YouTube window will set
*/
this._session = session;

/**
* IPC Function Definitions
*/
context.ipc.on(IPCKeys.RequestLaunchYoutube, this._onRequestLaunchYoutube.bind(this));
context.ipc.on(IPCKeys.RequestEndSession, this._onRequestEndSession.bind(this));
context.ipc.on(IPCKeys.RequestHarvestToken, this._onRequestHarvestToken.bind(this));
context.ipc.on(
IPCKeys.RequestRefreshCaptchaWindow,
this._onRequestRefreshCaptchaWindow.bind(this),
);

/**
* Constantly check for expired tokens every second
*/
this._checkTokens = setInterval(this.checkTokens, 1000);
}

/**
* Check harvested captcha tokens to see if they're expired or not
*/
checkTokens() {
if (this._tokens && this._tokens.length > 0) {
this._tokens.forEach((token) => {
token.setTimestamp(110 - moment().diff(moment(token.timestamp, 'seconds')));
if (this.isTokenExpired(token)) {
this.removeExpiredToken(token);
}
});
} else {
// don't run the interval check if no tokens are present
clearInterval(this._checkTokens);
walmat marked this conversation as resolved.
Show resolved Hide resolved
this._checkTokens = null;
}
}

static isTokenExpired(token) {
// if token has existed for > 110 seconds
if (moment().diff(moment(token.timestamp), 'seconds') > 110) {
return true;
} return false;
}

/**
* Get the current session
*/
getSession() {
return this._session;
}

/**
* Sets the session
* @param {Object} session - session object to use
*/
setSession(session) {
this._session = session;
}

/**
* See what the proxy is for the given url
* @param {String} url - urk to ping
*/
resolveProxy(url) {
return this._session.resolveProxy(url, proxy => proxy);
}

/**
* Sets the proxy for the window's session
*
* @param {String} proxy proxyRules = schemeProxies[";"<schemeProxies>]
schemeProxies = [<urlScheme>"="]<proxyURIList>
urlScheme = "http" | "https" | "ftp" | "socks"
proxyURIList = <proxyURL>[","<proxyURIList>]
proxyURL = [<proxyScheme>"://"]<proxyHost>[":"<proxyPort>]
*
*
*/
setProxy(proxy) {
this._session.setProxy({
pacScript: null,
proxyRules: proxy,
proxyBypassRules: null,
}, () => {
const p = this.resolveProxy('https://www.google.com/');
console.log(`Using proxy: ${p}`);
});
}

/**
* Sets the 'User-Agent' header for the session
* @param {String} userAgent - user agent to set on all headers
* @param {String} acceptLanguages - the incoming languages to accept from the response (optional)
* should be a comma separated list: "en-US,fr,de,ko,zh-CN,ja"
*/
setUserAgent(userAgent, acceptLanguages) {
this._session.setUserAgent(userAgent, acceptLanguages);
}

/**
* Gets the 'User-Agent' header for the session
*/
getUserAgent() {
return this._session.getUserAgent();
}

removeExpiredToken(token) {
this._tokens = _.reject(this._tokens, el => el.token === token);
}

/**
* Clears the storage data and cache for the session
*/
_onRequestEndSession() {
this._session.flushStorageData();
this._session.clearStorageData([], () => {});
this._session.clearCache(() => {});
}

_onRequestHarvestToken(ev, token, host, sitekey) {
this._tokens.push(new Token(token, moment(), host, sitekey));
if (this._checkTokens === null) {
this._checkTokens = setInterval(this.checkTokens, 1000);
}
}

/**
* Refresh window object
*/
_onRequestRefreshCaptchaWindow() {
this._captchaWindow.reload();
}

async _onRequestLaunchYoutube() {
if (this._youtubeWindow === null) {
const w = await this._windowManager.createNewWindow('youtube');
this._youtubeWindow = w;
} else {
this._youtubeWindow.show();
}
}
}
module.exports = CaptchaWindowManager;
56 changes: 42 additions & 14 deletions frontend/lib/_electron/preload.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { remote } = require('electron');
const { dialog } = require('electron').remote;
const { dialog, app } = require('electron').remote;
const { ipcRenderer, webFrame } = require('electron');
const IPCKeys = require('../common/Constants');
const IPCKeys = require('../common/constants');
const nebulaEnv = require('../_electron/env');

// setup environment
Expand All @@ -14,7 +14,7 @@ webFrame.setLayoutZoomLevelLimits(0, 0);
/**
* Sends IPCMain an event trigger
* @param {String} channel definition for which trigger to look for
* @param {*} msg any object to send along with the event
* @param {*} msg any object to send along with the event || null
*/
const _sendEvent = (channel, msg) => {
ipcRenderer.send(channel, msg);
Expand All @@ -27,6 +27,22 @@ const _deactivate = () => {
_sendEvent(IPCKeys.AuthRequestDeactivate);
};

/**
* Prevent dragover events globally
pr1sm marked this conversation as resolved.
Show resolved Hide resolved
*/
window.addEventListener('dragover', (event) => {
event.preventDefault();
return false;
}, false);

/**
* Prevent drop events globally
pr1sm marked this conversation as resolved.
Show resolved Hide resolved
*/
window.addEventListener('drop', (event) => {
event.preventDefault();
return false;
}, false);

/**
* Sends the deactivate trigger to authManager.js
*
Expand All @@ -44,41 +60,51 @@ const _close = () => {
_sendEvent(IPCKeys.RequestCloseWindow, id);
};

const _closeAllCaptchaWindows = () => {
_sendEvent(IPCKeys.RequestCloseAllCaptchaWindows);
};

/**
* Sends the launch youtube window trigger to windowManager.js
*/
const _launchYoutube = () => {
_sendEvent(IPCKeys.RequestCreateNewWindow, 'youtube');
_sendEvent(IPCKeys.RequestLaunchYoutube);
};

/**
* Sends the launch captcha window trigger to windowManager.js
*/
const _launchHarvester = () => {
const _launchCaptchaHarvester = () => {
_sendEvent(IPCKeys.RequestCreateNewWindow, 'captcha');
};

/**
* Sends the end session trigger to windowManager.js
*/
const _endSession = () => {
_sendEvent(IPCKeys.RequestEndSession);
const _endCaptchaSession = () => {
const { id } = remote.getCurrentWindow();
_sendEvent(IPCKeys.RequestEndSession, id);
};

/**
* Sends the harvest captcha trigger to windowManager.js
*/
const _harvest = (token) => {
const _harvestCaptchaToken = (token) => {
_sendEvent(IPCKeys.HarvestCaptcha, token);
};

/**
* Sends the refresh window trigger to windowManager.js
*/
const _refresh = (window) => {
_sendEvent(IPCKeys.RequestRefresh, window);
const _refreshCaptchaWindow = () => {
_sendEvent(IPCKeys.RequestRefresh);
};

/**
* Send app name/version to the renderer
*/
const _getAppData = () => ({ name: app.getName(), version: app.getVersion() });

/**
* ... TODO!
* Sends the confirmation dialog trigger to windowManager.js
Expand All @@ -100,11 +126,13 @@ process.once('loaded', () => {
window.Bridge = window.Bridge || {};
/* BRIDGED EVENTS */
window.Bridge.launchYoutube = _launchYoutube;
window.Bridge.launchHarvester = _launchHarvester;
window.Bridge.launchCaptchaHarvester = _launchCaptchaHarvester;
pr1sm marked this conversation as resolved.
Show resolved Hide resolved
window.Bridge.closeAllCaptchaWindows = _closeAllCaptchaWindows;
window.Bridge.close = _close;
window.Bridge.refresh = _refresh;
window.Bridge.harvest = _harvest;
window.Bridge.endSession = _endSession;
window.Bridge.refreshCaptchaWindow = _refreshCaptchaWindow;
window.Bridge.harvestCaptchaToken = _harvestCaptchaToken;
window.Bridge.endCaptchaSession = _endCaptchaSession;
window.Bridge.getAppData = _getAppData;
window.Bridge.deactivate = _deactivate;
window.Bridge.authenticate = _authenticate;
window.Bridge.confirmDialog = _confirmDialog;
Expand Down
Loading