Skip to content
This repository has been archived by the owner on Jun 4, 2023. It is now read-only.

chore: build flags #466

Merged
merged 1 commit into from
May 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ jobs:
env:
ADBLOCK: true

- name: Get commit message
run: echo "::set-output name=message::$(git log --no-merges -1 --oneline)"

- name: Build the app
run: yarn ci-build
env:
Expand All @@ -36,4 +39,4 @@ jobs:
MAC_CERTS: ${{ secrets.mac_certs }}
MAC_CERTS_PASSWORD: ${{ secrets.mac_certs_password }}

RELEASE: ${{ startsWith(github.ref, 'refs/tags/v') }}
RELEASE: ${{ contains(steps.log.outputs.message, 'bump version') }}
222 changes: 112 additions & 110 deletions src/main/services/messaging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,140 +113,142 @@ export const runMessagingService = (appWindow: AppWindow) => {
e.returnValue = appWindow.incognito;
});

ipcMain.on(`form-fill-show-${id}`, async (e, rect, name, value) => {
const items = await getFormFillMenuItems(name, value);
if (process.env.ENABLE_AUTOFILL) {
ipcMain.on(`form-fill-show-${id}`, async (e, rect, name, value) => {
const items = await getFormFillMenuItems(name, value);

if (items.length) {
appWindow.dialogs.formFillDialog.send(`formfill-get-items`, items);
appWindow.dialogs.formFillDialog.inputRect = rect;
if (items.length) {
appWindow.dialogs.formFillDialog.send(`formfill-get-items`, items);
appWindow.dialogs.formFillDialog.inputRect = rect;

appWindow.dialogs.formFillDialog.resize(
items.length,
items.find((r) => r.subtext) != null,
);
appWindow.dialogs.formFillDialog.rearrange();
appWindow.dialogs.formFillDialog.show(false);
} else {
appWindow.dialogs.formFillDialog.resize(
items.length,
items.find((r) => r.subtext) != null,
);
appWindow.dialogs.formFillDialog.rearrange();
appWindow.dialogs.formFillDialog.show(false);
} else {
appWindow.dialogs.formFillDialog.hide();
}
});

ipcMain.on(`form-fill-hide-${id}`, () => {
appWindow.dialogs.formFillDialog.hide();
}
});
});

ipcMain.on(`form-fill-hide-${id}`, () => {
appWindow.dialogs.formFillDialog.hide();
});
ipcMain.on(
`form-fill-update-${id}`,
async (e, _id: string, persistent = false) => {
const url = appWindow.viewManager.selected.url;
const { hostname } = parse(url);

const item =
_id &&
(await Application.instance.storage.findOne<IFormFillData>({
scope: 'formfill',
query: { _id },
}));

if (item && item.type === 'password') {
item.fields.password = await getPassword(
'wexond',
`${hostname}-${item.fields.username}`,
);
}

appWindow.viewManager.selected.send(
`form-fill-update-${id}`,
item,
persistent,
);
},
);

ipcMain.on(`credentials-show-${id}`, (e, data) => {
appWindow.dialogs.credentialsDialog.send('credentials-update', data);
appWindow.dialogs.credentialsDialog.rearrange();
appWindow.dialogs.credentialsDialog.show();
});

ipcMain.on(`credentials-hide-${id}`, () => {
appWindow.dialogs.credentialsDialog.hide();
});

ipcMain.on(
`form-fill-update-${id}`,
async (e, _id: string, persistent = false) => {
const url = appWindow.viewManager.selected.url;
const { hostname } = parse(url);
ipcMain.on(`credentials-save-${id}`, async (e, data) => {
const { username, password, update, oldUsername } = data;
const view = appWindow.viewManager.selected;
const hostname = view.hostname;

const item =
_id &&
(await Application.instance.storage.findOne<IFormFillData>({
if (!update) {
const item = await Application.instance.storage.insert<IFormFillData>({
scope: 'formfill',
query: { _id },
}));
item: {
type: 'password',
url: hostname,
favicon: appWindow.viewManager.selected.favicon,
fields: {
username,
passLength: password.length,
},
},
});

if (item && item.type === 'password') {
item.fields.password = await getPassword(
'wexond',
`${hostname}-${item.fields.username}`,
appWindow.viewManager.settingsView.webContents.send(
'credentials-insert',
item,
);
}

appWindow.viewManager.selected.send(
`form-fill-update-${id}`,
item,
persistent,
);
},
);
} else {
await Application.instance.storage.update({
scope: 'formfill',
query: {
type: 'password',
url: hostname,
'fields.username': oldUsername,
'fields.passLength': password.length,
},
value: {
'fields.username': username,
},
});

ipcMain.on(`credentials-show-${id}`, (e, data) => {
appWindow.dialogs.credentialsDialog.send('credentials-update', data);
appWindow.dialogs.credentialsDialog.rearrange();
appWindow.dialogs.credentialsDialog.show();
});
appWindow.viewManager.settingsView.webContents.send(
'credentials-update',
{ ...data, hostname },
);
}

ipcMain.on(`credentials-hide-${id}`, () => {
appWindow.dialogs.credentialsDialog.hide();
});
await setPassword('wexond', `${hostname}-${username}`, password);

ipcMain.on(`credentials-save-${id}`, async (e, data) => {
const { username, password, update, oldUsername } = data;
const view = appWindow.viewManager.selected;
const hostname = view.hostname;
appWindow.send(`has-credentials-${view.id}`, true);
});

if (!update) {
const item = await Application.instance.storage.insert<IFormFillData>({
scope: 'formfill',
item: {
type: 'password',
url: hostname,
favicon: appWindow.viewManager.selected.favicon,
fields: {
username,
passLength: password.length,
},
},
});
ipcMain.on(`credentials-remove-${id}`, async (e, data: IFormFillData) => {
const { _id, fields } = data;
const view = appWindow.viewManager.selected;

appWindow.viewManager.settingsView.webContents.send(
'credentials-insert',
item,
);
} else {
await Application.instance.storage.update({
await Application.instance.storage.remove({
scope: 'formfill',
query: {
type: 'password',
url: hostname,
'fields.username': oldUsername,
'fields.passLength': password.length,
},
value: {
'fields.username': username,
_id,
},
});

appWindow.viewManager.settingsView.webContents.send(
'credentials-update',
{ ...data, hostname },
);
}
await deletePassword('wexond', `${view.hostname}-${fields.username}`);

await setPassword('wexond', `${hostname}-${username}`, password);

appWindow.send(`has-credentials-${view.id}`, true);
});

ipcMain.on(`credentials-remove-${id}`, async (e, data: IFormFillData) => {
const { _id, fields } = data;
const view = appWindow.viewManager.selected;

await Application.instance.storage.remove({
scope: 'formfill',
query: {
appWindow.viewManager.settingsView.webContents.send(
'credentials-remove',
_id,
},
);
});

await deletePassword('wexond', `${view.hostname}-${fields.username}`);

appWindow.viewManager.settingsView.webContents.send(
'credentials-remove',
_id,
ipcMain.on(
'credentials-get-password',
async (e, id: string, account: string) => {
const password = await getPassword('wexond', account);
e.sender.send(id, password);
},
);
});

ipcMain.on(
'credentials-get-password',
async (e, id: string, account: string) => {
const password = await getPassword('wexond', account);
e.sender.send(id, password);
},
);
}

ipcMain.handle(
`show-bookmarks-bar-dropdown-${id}`,
Expand Down
30 changes: 17 additions & 13 deletions src/main/sessions-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,23 @@ export class SessionsService {

this.clearCache('incognito');

// TODO: remove this after fix for e.sender.session
_setFallbackSession(this.view);
if (process.env.ENABLE_EXTENSIONS) {
// TODO: remove this after fix for e.sender.session
_setFallbackSession(this.view);

extensions.initializeSession(
this.view,
`${app.getAppPath()}/build/extensions-preload.bundle.js`,
);
extensions.initializeSession(
this.view,
`${app.getAppPath()}/build/extensions-preload.bundle.js`,
);

ipcMain.on('load-extensions', () => {
this.loadExtensions();
});
ipcMain.on('load-extensions', () => {
this.loadExtensions();
});

ipcMain.handle('get-extensions', () => {
return this.extensions;
});
ipcMain.handle('get-extensions', () => {
return this.extensions;
});
}

/*
// TODO:
Expand Down Expand Up @@ -164,7 +166,7 @@ export class SessionsService {
!window.dialogs.downloadsDialog.visible,
);

if (extname(fileName) === '.crx') {
if (process.env.ENABLE_EXTENSIONS && extname(fileName) === '.crx') {
const crxBuf = await promises.readFile(item.savePath);
const crxInfo = parseCrx(crxBuf);

Expand Down Expand Up @@ -281,6 +283,8 @@ export class SessionsService {
}

public async loadExtensions() {
if (!process.env.ENABLE_EXTENSIONS) return;

const context = this.view;

if (this.extensionsLoaded) return;
Expand Down
15 changes: 11 additions & 4 deletions src/main/view-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ export class ViewManager {
});

ipcMain.handle(`view-select-${id}`, (e, id: number, focus: boolean) => {
extensions.tabs.activate(id, focus);
if (process.env.ENABLE_EXTENSIONS) {
extensions.tabs.activate(id, focus);
} else {
this.select(id, focus);
}
});

ipcMain.on(`view-destroy-${id}`, (e, id: number) => {
Expand Down Expand Up @@ -130,7 +134,9 @@ export class ViewManager {

this.views.set(id, view);

extensions.tabs.observe(webContents);
if (process.env.ENABLE_EXTENSIONS) {
extensions.tabs.observe(webContents);
}

webContents.once('destroyed', () => {
this.views.delete(id);
Expand Down Expand Up @@ -176,8 +182,9 @@ export class ViewManager {
'findDialog',
'authDialog',
'permissionsDialog',
'formFillDialog',
'credentialsDialog',
...(process.env.ENABLE_AUTOFILL
? ['formFillDialog', 'credentialsDialog']
: []),
].forEach((dialog) => {
if (this.window.dialogs[dialog].tabIds.includes(id)) {
this.window.dialogs[dialog].show();
Expand Down
6 changes: 4 additions & 2 deletions src/main/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ export class View {
}

public async updateCredentials() {
if (this.browserView.isDestroyed()) return;
if (!process.env.ENABLE_AUTOFILL || this.browserView.isDestroyed()) return;

const item = await Application.instance.storage.findOne<any>({
scope: 'formfill',
Expand Down Expand Up @@ -338,7 +338,9 @@ export class View {
this.isNewTab = url.startsWith(NEWTAB_URL);

this.updateData();
this.updateCredentials();

if (process.env.ENABLE_AUTOFILL) this.updateCredentials();

this.updateBookmark();
};

Expand Down
Loading