2019-05-16 22:14:06 +00:00
|
|
|
/* global Whisper, window */
|
2018-04-03 19:03:57 +00:00
|
|
|
|
|
|
|
const electron = require('electron');
|
2018-07-20 21:52:52 +00:00
|
|
|
const semver = require('semver');
|
2019-08-19 22:26:45 +00:00
|
|
|
const curve = require('curve25519-n');
|
2018-04-03 19:03:57 +00:00
|
|
|
|
|
|
|
const { deferredToPromise } = require('./js/modules/deferred_to_promise');
|
|
|
|
|
2019-08-07 00:40:25 +00:00
|
|
|
const { remote } = electron;
|
|
|
|
const { app } = remote;
|
|
|
|
const { systemPreferences } = remote.require('electron');
|
|
|
|
|
2019-10-04 18:06:17 +00:00
|
|
|
const browserWindow = remote.getCurrentWindow();
|
|
|
|
window.isFocused = () => browserWindow.isFocused();
|
|
|
|
|
2019-05-16 22:14:06 +00:00
|
|
|
// Waiting for clients to implement changes on receive side
|
2019-05-24 01:27:42 +00:00
|
|
|
window.ENABLE_STICKER_SEND = true;
|
2019-05-16 22:14:06 +00:00
|
|
|
window.TIMESTAMP_VALIDATION = false;
|
|
|
|
window.PAD_ALL_ATTACHMENTS = false;
|
|
|
|
window.SEND_RECIPIENT_UPDATES = false;
|
|
|
|
|
2018-04-03 19:03:57 +00:00
|
|
|
window.PROTO_ROOT = 'protos';
|
2018-06-02 00:55:35 +00:00
|
|
|
const config = require('url').parse(window.location.toString(), true).query;
|
|
|
|
|
|
|
|
let title = config.name;
|
|
|
|
if (config.environment !== 'production') {
|
|
|
|
title += ` - ${config.environment}`;
|
|
|
|
}
|
|
|
|
if (config.appInstance) {
|
|
|
|
title += ` - ${config.appInstance}`;
|
|
|
|
}
|
|
|
|
|
2019-03-18 19:10:56 +00:00
|
|
|
window.platform = process.platform;
|
2018-06-02 00:55:35 +00:00
|
|
|
window.getTitle = () => title;
|
|
|
|
window.getEnvironment = () => config.environment;
|
2018-06-21 19:02:19 +00:00
|
|
|
window.getAppInstance = () => config.appInstance;
|
2018-06-02 00:55:35 +00:00
|
|
|
window.getVersion = () => config.version;
|
|
|
|
window.isImportMode = () => config.importMode;
|
|
|
|
window.getExpiration = () => config.buildExpiration;
|
|
|
|
window.getNodeVersion = () => config.node_version;
|
|
|
|
window.getHostName = () => config.hostname;
|
2018-10-18 01:01:21 +00:00
|
|
|
window.getServerTrustRoot = () => config.serverTrustRoot;
|
2019-01-16 03:03:56 +00:00
|
|
|
window.isBehindProxy = () => Boolean(config.proxyUrl);
|
2018-04-03 19:03:57 +00:00
|
|
|
|
2019-05-16 22:32:38 +00:00
|
|
|
function setSystemTheme() {
|
|
|
|
window.systemTheme = systemPreferences.isDarkMode() ? 'dark' : 'light';
|
|
|
|
}
|
|
|
|
|
|
|
|
setSystemTheme();
|
|
|
|
|
|
|
|
window.subscribeToSystemThemeChange = fn => {
|
|
|
|
if (!systemPreferences.subscribeNotification) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
systemPreferences.subscribeNotification(
|
|
|
|
'AppleInterfaceThemeChangedNotification',
|
|
|
|
() => {
|
|
|
|
setSystemTheme();
|
|
|
|
fn();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2018-07-20 21:52:52 +00:00
|
|
|
window.isBeforeVersion = (toCheck, baseVersion) => {
|
|
|
|
try {
|
|
|
|
return semver.lt(toCheck, baseVersion);
|
|
|
|
} catch (error) {
|
2018-07-21 19:00:08 +00:00
|
|
|
window.log.error(
|
2018-07-20 21:52:52 +00:00
|
|
|
`isBeforeVersion error: toCheck: ${toCheck}, baseVersion: ${baseVersion}`,
|
|
|
|
error && error.stack ? error.stack : error
|
|
|
|
);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-04-03 19:03:57 +00:00
|
|
|
window.wrapDeferred = deferredToPromise;
|
|
|
|
|
|
|
|
const ipc = electron.ipcRenderer;
|
2018-06-02 00:55:35 +00:00
|
|
|
const localeMessages = ipc.sendSync('locale-data');
|
2018-04-03 19:03:57 +00:00
|
|
|
|
2018-04-27 21:25:04 +00:00
|
|
|
window.setBadgeCount = count => ipc.send('set-badge-count', count);
|
2018-04-03 19:03:57 +00:00
|
|
|
|
2018-05-24 16:32:18 +00:00
|
|
|
// We never do these in our code, so we'll prevent it everywhere
|
2018-05-19 01:21:02 +00:00
|
|
|
window.open = () => null;
|
2018-05-24 16:32:18 +00:00
|
|
|
// eslint-disable-next-line no-eval, no-multi-assign
|
|
|
|
window.eval = global.eval = () => null;
|
2018-05-19 01:21:02 +00:00
|
|
|
|
2019-09-06 20:04:31 +00:00
|
|
|
window.drawAttention = () => {
|
|
|
|
window.log.info('draw attention');
|
|
|
|
ipc.send('draw-attention');
|
|
|
|
};
|
2018-04-03 19:03:57 +00:00
|
|
|
window.showWindow = () => {
|
2018-07-21 19:00:08 +00:00
|
|
|
window.log.info('show window');
|
2018-04-03 19:03:57 +00:00
|
|
|
ipc.send('show-window');
|
|
|
|
};
|
|
|
|
|
|
|
|
window.setAutoHideMenuBar = autoHide =>
|
|
|
|
ipc.send('set-auto-hide-menu-bar', autoHide);
|
|
|
|
|
|
|
|
window.setMenuBarVisibility = visibility =>
|
|
|
|
ipc.send('set-menu-bar-visibility', visibility);
|
|
|
|
|
|
|
|
window.restart = () => {
|
2018-07-21 19:00:08 +00:00
|
|
|
window.log.info('restart');
|
2018-04-03 19:03:57 +00:00
|
|
|
ipc.send('restart');
|
|
|
|
};
|
|
|
|
|
2018-04-27 21:25:04 +00:00
|
|
|
window.closeAbout = () => ipc.send('close-about');
|
2019-03-28 17:09:26 +00:00
|
|
|
window.readyForUpdates = () => ipc.send('ready-for-updates');
|
2018-04-03 19:03:57 +00:00
|
|
|
|
|
|
|
window.updateTrayIcon = unreadCount =>
|
|
|
|
ipc.send('update-tray-icon', unreadCount);
|
|
|
|
|
|
|
|
ipc.on('set-up-with-import', () => {
|
|
|
|
Whisper.events.trigger('setupWithImport');
|
|
|
|
});
|
|
|
|
|
|
|
|
ipc.on('set-up-as-new-device', () => {
|
|
|
|
Whisper.events.trigger('setupAsNewDevice');
|
|
|
|
});
|
|
|
|
|
|
|
|
ipc.on('set-up-as-standalone', () => {
|
|
|
|
Whisper.events.trigger('setupAsStandalone');
|
|
|
|
});
|
|
|
|
|
2018-07-03 22:33:50 +00:00
|
|
|
// Settings-related events
|
|
|
|
|
|
|
|
window.showSettings = () => ipc.send('show-settings');
|
|
|
|
window.showPermissionsPopup = () => ipc.send('show-permissions-popup');
|
|
|
|
|
2019-11-07 21:36:16 +00:00
|
|
|
ipc.on('show-keyboard-shortcuts', () => {
|
|
|
|
window.Events.showKeyboardShortcuts();
|
|
|
|
});
|
2018-07-03 22:33:50 +00:00
|
|
|
ipc.on('add-dark-overlay', () => {
|
2019-11-07 21:36:16 +00:00
|
|
|
window.Events.addDarkOverlay();
|
2018-07-03 22:33:50 +00:00
|
|
|
});
|
|
|
|
ipc.on('remove-dark-overlay', () => {
|
2019-11-07 21:36:16 +00:00
|
|
|
window.Events.removeDarkOverlay();
|
2018-04-03 19:03:57 +00:00
|
|
|
});
|
|
|
|
|
2018-07-03 22:33:50 +00:00
|
|
|
installGetter('device-name', 'getDeviceName');
|
|
|
|
|
|
|
|
installGetter('theme-setting', 'getThemeSetting');
|
|
|
|
installSetter('theme-setting', 'setThemeSetting');
|
|
|
|
installGetter('hide-menu-bar', 'getHideMenuBar');
|
|
|
|
installSetter('hide-menu-bar', 'setHideMenuBar');
|
|
|
|
|
|
|
|
installGetter('notification-setting', 'getNotificationSetting');
|
|
|
|
installSetter('notification-setting', 'setNotificationSetting');
|
|
|
|
installGetter('audio-notification', 'getAudioNotification');
|
|
|
|
installSetter('audio-notification', 'setAudioNotification');
|
|
|
|
|
2018-07-19 01:46:12 +00:00
|
|
|
installGetter('spell-check', 'getSpellCheck');
|
|
|
|
installSetter('spell-check', 'setSpellCheck');
|
|
|
|
|
2018-07-03 22:33:50 +00:00
|
|
|
window.getMediaPermissions = () =>
|
|
|
|
new Promise((resolve, reject) => {
|
|
|
|
ipc.once('get-success-media-permissions', (_event, error, value) => {
|
|
|
|
if (error) {
|
2019-10-04 18:06:17 +00:00
|
|
|
return reject(new Error(error));
|
2018-07-03 22:33:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return resolve(value);
|
|
|
|
});
|
|
|
|
ipc.send('get-media-permissions');
|
|
|
|
});
|
|
|
|
|
2019-10-04 18:06:17 +00:00
|
|
|
window.getBuiltInImages = () =>
|
|
|
|
new Promise((resolve, reject) => {
|
|
|
|
ipc.once('get-success-built-in-images', (_event, error, value) => {
|
|
|
|
if (error) {
|
|
|
|
return reject(new Error(error));
|
|
|
|
}
|
|
|
|
|
|
|
|
return resolve(value);
|
|
|
|
});
|
|
|
|
ipc.send('get-built-in-images');
|
|
|
|
});
|
|
|
|
|
2018-07-03 22:33:50 +00:00
|
|
|
installGetter('is-primary', 'isPrimary');
|
|
|
|
installGetter('sync-request', 'getSyncRequest');
|
|
|
|
installGetter('sync-time', 'getLastSyncTime');
|
|
|
|
installSetter('sync-time', 'setLastSyncTime');
|
|
|
|
|
|
|
|
ipc.on('delete-all-data', () => {
|
|
|
|
const { deleteAllData } = window.Events;
|
|
|
|
if (deleteAllData) {
|
|
|
|
deleteAllData();
|
|
|
|
}
|
|
|
|
});
|
2018-04-03 19:03:57 +00:00
|
|
|
|
2019-05-24 01:27:42 +00:00
|
|
|
ipc.on('show-sticker-pack', (_event, info) => {
|
2019-05-16 22:32:11 +00:00
|
|
|
const { packId, packKey } = info;
|
2019-05-24 01:27:42 +00:00
|
|
|
const { showStickerPack } = window.Events;
|
|
|
|
if (showStickerPack) {
|
|
|
|
showStickerPack(packId, packKey);
|
2019-05-16 22:32:11 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-11-05 19:06:12 +00:00
|
|
|
ipc.on('get-ready-for-shutdown', async () => {
|
2018-11-28 00:20:48 +00:00
|
|
|
const { shutdown } = window.Events || {};
|
2018-11-05 19:06:12 +00:00
|
|
|
if (!shutdown) {
|
|
|
|
window.log.error('preload shutdown handler: shutdown method not found');
|
|
|
|
ipc.send('now-ready-for-shutdown');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
await shutdown();
|
|
|
|
ipc.send('now-ready-for-shutdown');
|
|
|
|
} catch (error) {
|
|
|
|
ipc.send(
|
|
|
|
'now-ready-for-shutdown',
|
|
|
|
error && error.stack ? error.stack : error
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-07-03 22:33:50 +00:00
|
|
|
function installGetter(name, functionName) {
|
|
|
|
ipc.on(`get-${name}`, async () => {
|
|
|
|
const getFn = window.Events[functionName];
|
2019-01-16 03:03:56 +00:00
|
|
|
if (!getFn) {
|
|
|
|
ipc.send(
|
|
|
|
`get-success-${name}`,
|
|
|
|
`installGetter: ${functionName} not found for event ${name}`
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
ipc.send(`get-success-${name}`, null, await getFn());
|
|
|
|
} catch (error) {
|
|
|
|
ipc.send(
|
|
|
|
`get-success-${name}`,
|
|
|
|
error && error.stack ? error.stack : error
|
|
|
|
);
|
2018-07-03 22:33:50 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function installSetter(name, functionName) {
|
|
|
|
ipc.on(`set-${name}`, async (_event, value) => {
|
|
|
|
const setFn = window.Events[functionName];
|
2019-01-16 03:03:56 +00:00
|
|
|
if (!setFn) {
|
|
|
|
ipc.send(
|
|
|
|
`set-success-${name}`,
|
|
|
|
`installSetter: ${functionName} not found for event ${name}`
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
await setFn(value);
|
|
|
|
ipc.send(`set-success-${name}`);
|
|
|
|
} catch (error) {
|
|
|
|
ipc.send(
|
|
|
|
`set-success-${name}`,
|
|
|
|
error && error.stack ? error.stack : error
|
|
|
|
);
|
2018-07-03 22:33:50 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
window.addSetupMenuItems = () => ipc.send('add-setup-menu-items');
|
2018-04-27 21:25:04 +00:00
|
|
|
window.removeSetupMenuItems = () => ipc.send('remove-setup-menu-items');
|
2018-04-03 19:03:57 +00:00
|
|
|
|
|
|
|
// We pull these dependencies in now, from here, because they have Node.js dependencies
|
|
|
|
|
|
|
|
require('./js/logging');
|
|
|
|
|
2018-06-02 00:55:35 +00:00
|
|
|
if (config.proxyUrl) {
|
2018-07-21 19:00:08 +00:00
|
|
|
window.log.info('Using provided proxy url');
|
2018-04-03 19:03:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
window.nodeSetImmediate = setImmediate;
|
2018-05-26 01:01:56 +00:00
|
|
|
|
|
|
|
const { initialize: initializeWebAPI } = require('./js/modules/web_api');
|
|
|
|
|
|
|
|
window.WebAPI = initializeWebAPI({
|
2018-06-02 00:55:35 +00:00
|
|
|
url: config.serverUrl,
|
|
|
|
cdnUrl: config.cdnUrl,
|
|
|
|
certificateAuthority: config.certificateAuthority,
|
2019-01-16 03:03:56 +00:00
|
|
|
contentProxyUrl: config.contentProxyUrl,
|
2018-06-02 00:55:35 +00:00
|
|
|
proxyUrl: config.proxyUrl,
|
2018-05-26 01:01:56 +00:00
|
|
|
});
|
2018-04-03 19:03:57 +00:00
|
|
|
|
|
|
|
// Linux seems to periodically let the event loop stop, so this is a global workaround
|
|
|
|
setInterval(() => {
|
|
|
|
window.nodeSetImmediate(() => {});
|
|
|
|
}, 1000);
|
|
|
|
|
|
|
|
const { autoOrientImage } = require('./js/modules/auto_orient_image');
|
|
|
|
|
|
|
|
window.autoOrientImage = autoOrientImage;
|
|
|
|
window.dataURLToBlobSync = require('blueimp-canvas-to-blob');
|
|
|
|
window.emojiData = require('emoji-datasource');
|
2018-04-24 15:19:39 +00:00
|
|
|
window.filesize = require('filesize');
|
2018-04-03 19:03:57 +00:00
|
|
|
window.libphonenumber = require('google-libphonenumber').PhoneNumberUtil.getInstance();
|
2018-04-27 21:25:04 +00:00
|
|
|
window.libphonenumber.PhoneNumberFormat = require('google-libphonenumber').PhoneNumberFormat;
|
2018-04-03 19:03:57 +00:00
|
|
|
window.loadImage = require('blueimp-load-image');
|
2018-10-18 01:01:21 +00:00
|
|
|
window.getGuid = require('uuid/v4');
|
2018-04-03 19:03:57 +00:00
|
|
|
|
2018-03-26 18:44:45 +00:00
|
|
|
window.React = require('react');
|
|
|
|
window.ReactDOM = require('react-dom');
|
2018-03-24 01:37:04 +00:00
|
|
|
window.moment = require('moment');
|
2019-06-14 22:17:37 +00:00
|
|
|
window.PQueue = require('p-queue');
|
2018-04-03 19:03:57 +00:00
|
|
|
|
2018-05-23 18:09:37 +00:00
|
|
|
const Signal = require('./js/modules/signal');
|
2018-05-05 01:57:11 +00:00
|
|
|
const i18n = require('./js/modules/i18n');
|
|
|
|
const Attachments = require('./app/attachments');
|
2018-03-24 01:37:32 +00:00
|
|
|
|
2018-06-02 00:55:35 +00:00
|
|
|
const { locale } = config;
|
2018-05-05 01:57:11 +00:00
|
|
|
window.i18n = i18n.setup(locale, localeMessages);
|
2018-03-24 01:37:32 +00:00
|
|
|
window.moment.updateLocale(locale, {
|
|
|
|
relativeTime: {
|
|
|
|
s: window.i18n('timestamp_s'),
|
|
|
|
m: window.i18n('timestamp_m'),
|
|
|
|
h: window.i18n('timestamp_h'),
|
|
|
|
},
|
|
|
|
});
|
|
|
|
window.moment.locale(locale);
|
|
|
|
|
2019-05-16 22:32:11 +00:00
|
|
|
const userDataPath = app.getPath('userData');
|
|
|
|
window.baseAttachmentsPath = Attachments.getPath(userDataPath);
|
|
|
|
window.baseStickersPath = Attachments.getStickersPath(userDataPath);
|
2019-05-24 01:27:42 +00:00
|
|
|
window.baseTempPath = Attachments.getTempPath(userDataPath);
|
2019-08-07 00:40:25 +00:00
|
|
|
window.baseDraftPath = Attachments.getDraftPath(userDataPath);
|
2018-05-05 01:57:11 +00:00
|
|
|
window.Signal = Signal.setup({
|
|
|
|
Attachments,
|
2019-05-16 22:32:11 +00:00
|
|
|
userDataPath,
|
2018-05-09 01:03:02 +00:00
|
|
|
getRegionCode: () => window.storage.get('regionCode'),
|
2018-07-21 19:00:08 +00:00
|
|
|
logger: window.log,
|
2018-05-05 01:57:11 +00:00
|
|
|
});
|
2018-04-03 19:03:57 +00:00
|
|
|
|
2019-08-19 22:26:45 +00:00
|
|
|
function wrapWithPromise(fn) {
|
|
|
|
return (...args) => Promise.resolve(fn(...args));
|
|
|
|
}
|
|
|
|
function typedArrayToArrayBuffer(typedArray) {
|
|
|
|
const { buffer, byteOffset, byteLength } = typedArray;
|
|
|
|
return buffer.slice(byteOffset, byteLength + byteOffset);
|
|
|
|
}
|
|
|
|
const externalCurve = {
|
|
|
|
generateKeyPair: () => {
|
|
|
|
const { privKey, pubKey } = curve.generateKeyPair();
|
|
|
|
|
|
|
|
return {
|
|
|
|
privKey: typedArrayToArrayBuffer(privKey),
|
|
|
|
pubKey: typedArrayToArrayBuffer(pubKey),
|
|
|
|
};
|
|
|
|
},
|
|
|
|
createKeyPair: incomingKey => {
|
|
|
|
const incomingKeyBuffer = Buffer.from(incomingKey);
|
|
|
|
const { privKey, pubKey } = curve.createKeyPair(incomingKeyBuffer);
|
|
|
|
|
|
|
|
return {
|
|
|
|
privKey: typedArrayToArrayBuffer(privKey),
|
|
|
|
pubKey: typedArrayToArrayBuffer(pubKey),
|
|
|
|
};
|
|
|
|
},
|
|
|
|
calculateAgreement: (pubKey, privKey) => {
|
|
|
|
const pubKeyBuffer = Buffer.from(pubKey);
|
|
|
|
const privKeyBuffer = Buffer.from(privKey);
|
|
|
|
|
|
|
|
const buffer = curve.calculateAgreement(pubKeyBuffer, privKeyBuffer);
|
|
|
|
|
|
|
|
return typedArrayToArrayBuffer(buffer);
|
|
|
|
},
|
|
|
|
verifySignature: (pubKey, message, signature) => {
|
|
|
|
const pubKeyBuffer = Buffer.from(pubKey);
|
|
|
|
const messageBuffer = Buffer.from(message);
|
|
|
|
const signatureBuffer = Buffer.from(signature);
|
|
|
|
|
|
|
|
const result = curve.verifySignature(
|
|
|
|
pubKeyBuffer,
|
|
|
|
messageBuffer,
|
|
|
|
signatureBuffer
|
|
|
|
);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
},
|
|
|
|
calculateSignature: (privKey, message) => {
|
|
|
|
const privKeyBuffer = Buffer.from(privKey);
|
|
|
|
const messageBuffer = Buffer.from(message);
|
|
|
|
|
|
|
|
const buffer = curve.calculateSignature(privKeyBuffer, messageBuffer);
|
|
|
|
|
|
|
|
return typedArrayToArrayBuffer(buffer);
|
|
|
|
},
|
|
|
|
validatePubKeyFormat: pubKey => {
|
|
|
|
const pubKeyBuffer = Buffer.from(pubKey);
|
|
|
|
|
|
|
|
return curve.validatePubKeyFormat(pubKeyBuffer);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
externalCurve.ECDHE = externalCurve.calculateAgreement;
|
|
|
|
externalCurve.Ed25519Sign = externalCurve.calculateSignature;
|
|
|
|
externalCurve.Ed25519Verify = externalCurve.verifySignature;
|
|
|
|
const externalCurveAsync = {
|
|
|
|
generateKeyPair: wrapWithPromise(externalCurve.generateKeyPair),
|
|
|
|
createKeyPair: wrapWithPromise(externalCurve.createKeyPair),
|
|
|
|
calculateAgreement: wrapWithPromise(externalCurve.calculateAgreement),
|
|
|
|
verifySignature: async (...args) => {
|
|
|
|
// The async verifySignature function has a different signature than the sync function
|
|
|
|
const verifyFailed = externalCurve.verifySignature(...args);
|
|
|
|
if (verifyFailed) {
|
|
|
|
throw new Error('Invalid signature');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
calculateSignature: wrapWithPromise(externalCurve.calculateSignature),
|
|
|
|
validatePubKeyFormat: wrapWithPromise(externalCurve.validatePubKeyFormat),
|
|
|
|
ECDHE: wrapWithPromise(externalCurve.ECDHE),
|
|
|
|
Ed25519Sign: wrapWithPromise(externalCurve.Ed25519Sign),
|
|
|
|
Ed25519Verify: wrapWithPromise(externalCurve.Ed25519Verify),
|
|
|
|
};
|
|
|
|
window.libsignal = window.libsignal || {};
|
|
|
|
window.libsignal.externalCurve = externalCurve;
|
|
|
|
window.libsignal.externalCurveAsync = externalCurveAsync;
|
|
|
|
|
2018-05-05 01:57:11 +00:00
|
|
|
// Pulling these in separately since they access filesystem, electron
|
2018-04-03 19:03:57 +00:00
|
|
|
window.Signal.Backup = require('./js/modules/backup');
|
|
|
|
window.Signal.Debug = require('./js/modules/debug');
|
|
|
|
window.Signal.Logs = require('./js/modules/logs');
|
|
|
|
|
2019-04-10 19:06:21 +00:00
|
|
|
// Add right-click listener for selected text and urls
|
|
|
|
const contextMenu = require('electron-context-menu');
|
|
|
|
|
|
|
|
contextMenu({
|
|
|
|
showInspectElement: false,
|
2019-04-10 19:14:32 +00:00
|
|
|
shouldShowMenu: (event, params) =>
|
|
|
|
Boolean(
|
|
|
|
!params.isEditable &&
|
|
|
|
params.mediaType === 'none' &&
|
|
|
|
(params.linkURL || params.selectionText)
|
|
|
|
),
|
2019-04-10 19:06:21 +00:00
|
|
|
});
|
|
|
|
|
2018-04-03 19:03:57 +00:00
|
|
|
// We pull this in last, because the native module involved appears to be sensitive to
|
|
|
|
// /tmp mounted as noexec on Linux.
|
|
|
|
require('./js/spell_check');
|
2018-12-13 21:41:42 +00:00
|
|
|
|
|
|
|
if (config.environment === 'test') {
|
|
|
|
/* eslint-disable global-require, import/no-extraneous-dependencies */
|
|
|
|
window.test = {
|
|
|
|
glob: require('glob'),
|
|
|
|
fse: require('fs-extra'),
|
|
|
|
tmp: require('tmp'),
|
|
|
|
path: require('path'),
|
|
|
|
basePath: __dirname,
|
|
|
|
attachmentsPath: window.Signal.Migrations.attachmentsPath,
|
|
|
|
};
|
|
|
|
/* eslint-enable global-require, import/no-extraneous-dependencies */
|
|
|
|
}
|