Enables sandbox on about window
This commit is contained in:
parent
58691b2f5e
commit
4591b56f7f
27 changed files with 262 additions and 93 deletions
12
ts/context/activeWindowService.ts
Normal file
12
ts/context/activeWindowService.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
// Copyright 2023 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { ipcRenderer } from 'electron';
|
||||
import { getActiveWindowService } from '../services/ActiveWindowService';
|
||||
|
||||
const activeWindowService = getActiveWindowService(
|
||||
window.document,
|
||||
ipcRenderer
|
||||
);
|
||||
|
||||
export { activeWindowService };
|
12
ts/context/config.ts
Normal file
12
ts/context/config.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
// Copyright 2023 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { RendererConfigType } from '../types/RendererConfig';
|
||||
import { strictAssert } from '../util/assert';
|
||||
|
||||
const params = new URLSearchParams(document.location.search);
|
||||
const configParam = params.get('config');
|
||||
strictAssert(typeof configParam === 'string', 'config is not a string');
|
||||
const config: RendererConfigType = JSON.parse(configParam);
|
||||
|
||||
export { config };
|
15
ts/context/environment.ts
Normal file
15
ts/context/environment.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
// Copyright 2023 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { config } from './config';
|
||||
import {
|
||||
getEnvironment,
|
||||
parseEnvironment,
|
||||
setEnvironment,
|
||||
} from '../environment';
|
||||
|
||||
setEnvironment(parseEnvironment(config.environment));
|
||||
|
||||
const environment = getEnvironment();
|
||||
|
||||
export { environment };
|
22
ts/context/i18n.ts
Normal file
22
ts/context/i18n.ts
Normal file
|
@ -0,0 +1,22 @@
|
|||
// Copyright 2023 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { ipcRenderer } from 'electron';
|
||||
import { config } from './config';
|
||||
import { setupI18n } from '../util/setupI18n';
|
||||
import { strictAssert } from '../util/assert';
|
||||
|
||||
const { resolvedTranslationsLocale } = config;
|
||||
strictAssert(
|
||||
resolvedTranslationsLocale,
|
||||
'locale could not be parsed from config'
|
||||
);
|
||||
strictAssert(
|
||||
typeof resolvedTranslationsLocale === 'string',
|
||||
'locale is not a string'
|
||||
);
|
||||
|
||||
const localeMessages = ipcRenderer.sendSync('locale-data');
|
||||
const i18n = setupI18n(resolvedTranslationsLocale, localeMessages);
|
||||
|
||||
export { i18n };
|
25
ts/context/waitForSettingsChange.ts
Normal file
25
ts/context/waitForSettingsChange.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { ipcRenderer as ipc } from 'electron';
|
||||
|
||||
import { explodePromise } from '../util/explodePromise';
|
||||
|
||||
let preferencesChangeResolvers = new Array<() => void>();
|
||||
|
||||
ipc.on('preferences-changed', _event => {
|
||||
const resolvers = preferencesChangeResolvers;
|
||||
preferencesChangeResolvers = [];
|
||||
|
||||
for (const resolve of resolvers) {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
|
||||
export function waitForSettingsChange(): Promise<void> {
|
||||
const { promise, resolve } = explodePromise<void>();
|
||||
|
||||
preferencesChangeResolvers.push(resolve);
|
||||
|
||||
return promise;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue