refactor: Rename origin service to runtime-settings
This commit is contained in:
4 files changed
+11
-11
No files matched your search
@@ -1,4 +1,4 @@
|
||||
const origin = require('../services/origin.js');
|
||||
const runtimeSettings = require('../services/runtime-settings.js');
|
||||
const isDev = require('electron-is-dev');
|
||||
|
||||
const csp = {
|
||||
@@ -28,9 +28,9 @@ const generateCSPHeader = () => {
|
||||
const policy = Object.assign({}, csp);
|
||||
|
||||
// If an origin is specified, add it to the connect-src directive
|
||||
if (origin.origin) {
|
||||
if (runtimeSettings.origin) {
|
||||
policy['connect-src'] = policy['connect-src'].slice();
|
||||
policy['connect-src'].push(origin.origin);
|
||||
policy['connect-src'].push(runtimeSettings.origin);
|
||||
}
|
||||
|
||||
return Object.keys(policy)
|
||||
|
||||
@@ -15,7 +15,7 @@ const {
|
||||
} = require('electron');
|
||||
require('./ipc/handlers.js');
|
||||
|
||||
const origin = require('./services/origin.js');
|
||||
const runtimeSettings = require('./services/runtime-settings.js');
|
||||
const { generateCSPHeader } = require('./config/content-security-policy.js');
|
||||
|
||||
const menu = require('./config/menu.js');
|
||||
@@ -131,7 +131,7 @@ app.on('ready', async () => {
|
||||
|
||||
// If the user-specified origin changes, reload the page so that
|
||||
// the CSP can be refreshed with the this source allowed
|
||||
origin.onOriginChange(() => mainWindow.loadURL(emberAppURL));
|
||||
runtimeSettings.onOriginChange(() => mainWindow.loadURL(emberAppURL));
|
||||
|
||||
// If you want to open up dev tools programmatically, call
|
||||
// mainWindow.openDevTools();
|
||||
|
||||
@@ -2,28 +2,28 @@ const { shell } = require('electron');
|
||||
const isDev = require('electron-is-dev');
|
||||
const handle = require('./ipc-handler.js');
|
||||
const boundaryCli = require('../cli/index.js');
|
||||
const origin = require('../services/origin.js');
|
||||
const sessionManager = require('../services/session-manager.js');
|
||||
const runtimeSettings = require('../services/runtime-settings.js');
|
||||
|
||||
/**
|
||||
* Returns the current runtime origin, which is used by the main thread to
|
||||
* rewrite the CSP to allow requests.
|
||||
*/
|
||||
handle('getOrigin', () => origin.origin);
|
||||
handle('getOrigin', () => runtimeSettings.origin);
|
||||
|
||||
/**
|
||||
* Sets the origin to be used in the content security policy and triggers
|
||||
* a main window reload.
|
||||
*/
|
||||
handle('setOrigin', async (requestOrigin) => {
|
||||
await origin.validateOrigin(requestOrigin);
|
||||
origin.origin = requestOrigin;
|
||||
await runtimeSettings.validateOrigin(requestOrigin);
|
||||
runtimeSettings.origin = requestOrigin;
|
||||
});
|
||||
|
||||
/**
|
||||
* Resets the origin.
|
||||
*/
|
||||
handle('resetOrigin', async () => origin.resetOrigin());
|
||||
handle('resetOrigin', async () => runtimeSettings.resetOrigin());
|
||||
|
||||
/**
|
||||
* Opens the specified URL in an external browser. Only secure HTTPs URLs are
|
||||
@@ -55,7 +55,7 @@ handle('cliExists', () => boundaryCli.exists());
|
||||
* Establishes a boundary session and returns session details.
|
||||
*/
|
||||
handle('connect', ({ target_id, token, host_id }) =>
|
||||
sessionManager.start(origin.origin, target_id, token, host_id)
|
||||
sessionManager.start(runtimeSettings.origin, target_id, token, host_id)
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
File renamed without changes.
Reference in new issue
Block a user