Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
viktor44 committed May 11, 2024
2 parents 99dd056 + d513074 commit 9331cbe
Show file tree
Hide file tree
Showing 20 changed files with 75 additions and 36 deletions.
14 changes: 10 additions & 4 deletions packages/app/build/installer.nsh
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
!macro customUnInstall

MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Delete also user data and settings for Station?" IDNO skip
RMDir /r "$APPDATA\Station"
RMDir /r "$APPDATA\Stationv2"
${GetParameters} $R0
${GetOptions} $R0 "--update" $R1
${If} ${Errors}

skip:
MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Delete also user data and settings for Station?" IDNO skip
RMDir /r "$APPDATA\Station"
RMDir /r "$APPDATA\Stationv2"

skip:

${endif}

!macroend
6 changes: 6 additions & 0 deletions packages/app/src/app/duck.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const OPEN_PROCESS_MANAGER = 'browserX/app/OPEN_PROCESS_MANAGER';
export const TOGGLE_PROMPT_DOWNLOAD = 'browserX/app/TOGGLE_PROMPT_DOWNLOAD';

export const SET_APP_METADATA = 'browserX/app/SET_APP_METADATA';
export const DISABLE_SSL_CERT_VERIFICATION = 'browserX/app/DISABLE_SSL_CERT_VERIFICATION';

// Action creators
export const ready = () => ({ type: READY });
Expand Down Expand Up @@ -133,6 +134,11 @@ export const setAppMetadata = (metadata) => {
};
};

export const disableSslCertVerification = (partition) => ({
type: DISABLE_SSL_CERT_VERIFICATION,
partition,
});

// Reducer
export default function app(state = new Map(), action) {
switch (action.type) {
Expand Down
8 changes: 7 additions & 1 deletion packages/app/src/app/sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ import {
setLoadingScreenVisibility,
TOGGLE_PROMPT_DOWNLOAD,
TOGGLE_KBD_SHORTCUTS,
TOGGLE_MAXIMIZE
TOGGLE_MAXIMIZE,
DISABLE_SSL_CERT_VERIFICATION,
} from './duck';
import { DELAY } from '../persistence/backend';
import { getWindowCurrentTabId } from '../windows/get';
Expand Down Expand Up @@ -249,6 +250,10 @@ function* sagaHandleOpenProcessManager() {
yield callService('processManager', 'open', undefined);
}

function* sagaDisableSslCertVerification({ partition }) {
yield callService('defaultSession', 'disableSslCertVerification', partition);
}

/**
* Will load the app metadata in the state.
*/
Expand All @@ -275,6 +280,7 @@ export default function* main(bxApp) {
takeEveryWitness(TOGGLE_KBD_SHORTCUTS, sagaToggleKbdShortcutsOverlay),
takeEveryWitness(CHANGE_APP_FOCUS_STATE, onChangeAppFocusState),
takeEveryWitness(OPEN_PROCESS_MANAGER, sagaHandleOpenProcessManager),
takeEveryWitness(DISABLE_SSL_CERT_VERIFICATION, sagaDisableSslCertVerification),
// For dev purpose
takeEveryWitness('STATION_MANUAL_ERR', sagaTriggerError)
]);
Expand Down
22 changes: 17 additions & 5 deletions packages/app/src/applications/Application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { GradientType, withGradient } from '@getstation/theme';
import ElectronWebview from '../common/components/ElectronWebview';
import * as classNames from 'classnames';
import { clipboard } from 'electron';
import * as remote from '@electron/remote';
// @ts-ignore no declaration file
import { fetchFavicon, setFetchFaviconTimeout } from '@getstation/fetch-favicon';
import Maybe from 'graphql/tsutils/Maybe';
Expand Down Expand Up @@ -41,6 +40,8 @@ import {
} from '../tab-webcontents/duck';
import { getTabWebcontentsById, getWebcontentsAuthInfo, getWebcontentsAuthState } from '../tab-webcontents/selectors';
import { updateLoadingState, updateTabBadge, updateTabFavicons, updateTabTitle, updateTabURL } from '../tabs/duck';
// @ts-ignore no declaration file
import { disableSslCertVerification } from '../app/duck';
import { getTabId, getTabLoadingState } from '../tabs/get';
import { StationTabImmutable } from '../tabs/types';
import { RecursiveImmutableMap, StationState } from '../types';
Expand All @@ -51,6 +52,7 @@ import LazyWebview from './LazyWebview';
import { withGetApplicationState } from './[email protected]';
import { getApplicationDescription } from './selectors';
import { ApplicationImmutable } from './types';
// @ts-ignore no declaration file
import { getForeFrontNavigationStateProperty } from './utils';

type WebviewMethod = (webview: ElectronWebview) => void;
Expand Down Expand Up @@ -97,6 +99,7 @@ export interface OwnProps {
loading: boolean,
manifestURL: Maybe<string>,
applicationId: string,
appstoreApplicationId: string,

applicationName: Maybe<string>,
applicationIcon: Maybe<string>,
Expand Down Expand Up @@ -142,6 +145,7 @@ export interface DispatchProps {
onChooseAccount: Function,
onApplicationRemoved: Function,
updateResetAppModal: Function,
disableSslCertVerification: (partition: string) => any,
}

export interface ComputedProps {
Expand Down Expand Up @@ -388,12 +392,10 @@ class ApplicationImpl extends React.PureComponent {
const webview = this.webView.view;

webview.addEventListener('dom-ready', () => {
const webContents = remote.webContents.fromId(webview.getWebContentsId());

webview.addEventListener('did-navigate-in-page', (e: any) => this.handleDidNavigateInPage(e));
webview.addEventListener('did-navigate', (e: any) => this.handleDidNavigate(e));
webview.addEventListener('ipc-message', (e: any) => this.handleIPCMessage(e));
this.props.onWebcontentsAttached(webContents.id);
this.props.onWebcontentsAttached(webview.getWebContentsId());
});
}
}
Expand All @@ -403,14 +405,22 @@ class ApplicationImpl extends React.PureComponent {
const useNativeWindowOpen = !this.props.notUseNativeWindowOpen;
const tabUrl = tab.get('url', '');
const {
applicationId, applicationName, applicationIcon, themeColor, manifestURL,
applicationId, applicationName, applicationIcon,
appstoreApplicationId, themeColor, manifestURL,
askResetApplication, onChooseAccount,
crashed, errorCode, errorDescription,
canGoBack, themeGradient, email,
promptBasicAuth, performBasicAuth, basicAuthInfo,
useDefaultSession,
} = this.props;

const partition = useDefaultSession ? '' : `persist:${applicationId}`;

// disable SSL check for private applications
if (!useDefaultSession && Number(appstoreApplicationId) > 1000000) {
this.props.disableSslCertVerification(partition);
}

return (
<div>
<div
Expand Down Expand Up @@ -487,6 +497,7 @@ const Application = compose(

return {
manifestURL: application.manifestURL(),
appstoreApplicationId: application.appstoreApplicationId(),
applicationId: data.variables.applicationId,
applicationName: manifestData.name(),
applicationIcon: manifestData.interpretedIconURL(),
Expand Down Expand Up @@ -549,6 +560,7 @@ const Application = compose(
onChooseAccount: (identityId) => setConfigData(applicationId, { identityId }),
onApplicationRemoved: uninstallApplication,
updateResetAppModal: (appFocus) => updateUI('confirmResetApplicationModal', 'isVisible', appFocus),
disableSslCertVerification: disableSslCertVerification,
},
dispatch
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { MultiInstanceConfigPreset as Preset } from '../../manifest-provider/typ
import NormalFlowForm from './components/NormalFlowForm';
import { getPresets } from '../../manifest-provider/helpers';

const requestGoogleSignin = () => window.bx.identities.requestLogin('google');
const requestGoogleSignin = () => window.bxApi.identities.requestLogin('google');

const {
Undefined: UndefinedPreset,
Expand Down Expand Up @@ -79,28 +79,28 @@ export default class MultiInstanceConfigurator extends React.Component<Props, St
}

submitSubdomainForm = (subdomain: string) => {
window.bx.applications.setConfigData(this.props.applicationId, { subdomain });
window.bxApi.applications.setConfigData(this.props.applicationId, { subdomain });
}

submitIdentityForm = (identityId: string) => {
window.bx.applications.setConfigData(this.props.applicationId, { identityId });
window.bxApi.applications.setConfigData(this.props.applicationId, { identityId });
}

submitOnPremiseForm = (customURL: string) => {
window.bx.applications.setConfigData(this.props.applicationId, { customURL });
window.bxApi.applications.setConfigData(this.props.applicationId, { customURL });
}

submitNormalForm = () => {
window.bx.applications.setConfigData(this.props.applicationId, {});
window.bxApi.applications.setConfigData(this.props.applicationId, {});
}

removeApplication = () => {
window.bx.applications.uninstall(this.props.applicationId);
window.bxApi.applications.uninstall(this.props.applicationId);
}

componentDidMount() {
const { manifestURL } = this.props;
window.bx.manifest.getManifest(manifestURL).then(({ body }) => {
window.bxApi.manifest.getManifest(manifestURL).then(({ body }) => {
const manifest = body;
const presets = this.getPresets(manifest);
const selectedPreset = isOnlyOnPremise(presets) ? UndefinedPreset : presets[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ export default class ChooseIdentityForm extends React.PureComponent<Props, State
}

UNSAFE_componentWillMount() {
window.bx.identities.addIdentitiesChangeListener(this.onIdentitiesChanged);
window.bxApi.identities.addIdentitiesChangeListener(this.onIdentitiesChanged);
}

componentWillUnmount() {
window.bx.identities.removeIdentitiesChangeListener(this.onIdentitiesChanged);
window.bxApi.identities.removeIdentitiesChangeListener(this.onIdentitiesChanged);
}

render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const manifestURL = params.get('manifestURL')!;
const applicationId = params.get('applicationId')!;

const themeColorsObservable = new Subject<any>();
window.bx.theme.addThemeColorsChangeListener(
window.bxApi.theme.addThemeColorsChangeListener(
(_: any, result: any) => themeColorsObservable.next(result)
);

Expand Down
8 changes: 4 additions & 4 deletions packages/app/src/notification-center/webview-preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class BxNotification extends EventTarget('click', 'error', 'close', 'show
});

this._registerIPC();
window.bx.notificationCenter.sendNotification(this.id, {
window.bxApi.notificationCenter.sendNotification(this.id, {
timestamp: this.timestamp,
title: this.title,
body: this.body,
Expand All @@ -87,17 +87,17 @@ export class BxNotification extends EventTarget('click', 'error', 'close', 'show
}

close() {
window.bx.notificationCenter.closeNotification(this.id);
window.bxApi.notificationCenter.closeNotification(this.id);
// ipcRenderer.send('notification-close', this.id);
}

_registerIPC() {
window.bx.notificationCenter.addNotificationClickListener(this._handleNotificationClickIPC);
window.bxApi.notificationCenter.addNotificationClickListener(this._handleNotificationClickIPC);
// ipcRenderer.on('trigger-notification-click', this._handleNotificationClickIPC);
}

_unregisterIPC() {
window.bx.notificationCenter.removeNotificationClickListener(this._handleNotificationClickIPC);
window.bxApi.notificationCenter.removeNotificationClickListener(this._handleNotificationClickIPC);
// ipcRenderer.removeListener('trigger-notification-click', this._handleNotificationClickIPC);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/plugins/bxapi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,6 @@ interface Bx {

declare global {
interface Window {
bx: Bx;
bxApi: Bx;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const turnOffAudioVolumeObserver = target => {

let disconnectTurnOffAudioVolumeObserver;

window.bx.notificationCenter.addSnoozeDurationInMsChangeListener((_, duration) => {
window.bxApi.notificationCenter.addSnoozeDurationInMsChangeListener((_, duration) => {
if (duration && !document.location.pathname.includes('/videocall/incall/')) {
disconnectTurnOffAudioVolumeObserver = turnOffAudioVolumeObserver(document.body);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ Audio.prototype.play = function() {
return Promise.resolve();
};

window.bx.notificationCenter.addSnoozeDurationInMsChangeListener((_, duration) => {
window.bxApi.notificationCenter.addSnoozeDurationInMsChangeListener((_, duration) => {
snoozed = Boolean(duration);
});
2 changes: 1 addition & 1 deletion packages/app/src/plugins/webview-preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,6 @@
}
};

contextBridge.exposeInMainWorld('bx', bxApi);
contextBridge.exposeInMainWorld('bxApi', bxApi);

console.log('>>>> contextBridge done')
2 changes: 2 additions & 0 deletions packages/app/src/services/services/session/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ export class SessionService extends ServiceBase implements RPC.Interface<Session
getUserAgent(): Promise<string> {}
// @ts-ignore
getCookies(filter: Electron.CookiesGetFilter): Promise<Electron.Cookie[]> {}
// @ts-ignore
disableSslCertVerification(partition: string) : Promise<void> {}
}
7 changes: 7 additions & 0 deletions packages/app/src/services/services/session/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ export class SessionServiceImpl extends SessionService implements RPC.Interface<
return session.cookies.get(filter);
}

async disableSslCertVerification(partition: string) : Promise<void> {
const session = Electron.session.fromPartition(partition);
session.setCertificateVerifyProc((_, callback) => {
callback(0);
});
}

private async initSession(options?: SessionOptions): Promise<Electron.Session> {
if (options && options.partition) {
return Electron.session.fromPartition(options.partition);
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/static/preload/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ const postload = Object.keys(window);

// List of allowed exposure on globals
export const whitelist = new Set([
'bx',
'bxApi',
'chrome',
'_docs_chrome_extension_exists',
'_docs_chrome_extension_features_version',
Expand Down
2 changes: 1 addition & 1 deletion packages/appstore/src/HOC/withCustomApplications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function withCustomApplications(Component: React.Component<any>)
});

React.useEffect(() => {
window.bx.applications.getPrivateApps().then(({ body }) => {
window.bxApi.applications.getPrivateApps().then(({ body }) => {
setData({
privateApps: body.map(app => {
return {
Expand Down
4 changes: 2 additions & 2 deletions packages/appstore/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const findApplicationByName = (applicationName: string) => {

if ('bx' in window) {
const bxApi = window.bx;
if ('bxApi' in window) {
const bxApi = window.bxApi;

return bxApi.applications.search(applicationName).then(({ body }) => {
return body || [];
Expand Down
2 changes: 1 addition & 1 deletion packages/appstore/src/app-request/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function* handleAppRequest(request: SubmitAppRequestAction): SagaIterator {
};

try {
const { body } = yield call(window.bx.applications.requestPrivate, applicationRecipe);
const { body } = yield call(window.bxApi.applications.requestPrivate, applicationRecipe);
yield put(setApiResponse(ApiResponse.Done));
yield put(setApplicationCreated({ id: body.id, bxAppManifestURL: body.bxAppManifestURL }));
} catch (e) {
Expand Down
4 changes: 2 additions & 2 deletions packages/appstore/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ class AppImpl extends React.Component<Props, IState> {

// tslint:disable-next-line function-name
async UNSAFE_componentWillMount() {
if ('bx' in window) {
if ('bxApi' in window) {
// @ts-ignore : bx attached to window
const bxApi = window.bx;
const bxApi = window.bxApi;

bxApi.theme.addThemeColorsChangeListener((_: any, themeColors: string[]) => {
this.setState({ themeColors })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class AppStoreMyCustomApps extends React.PureComponent<Props, AppStoreMyCustomAp
}

deleteApplication = (app: Application) => {
window.bx.applications.uninstallByManifest(app.bxAppManifestURL).then(() => {
window.bxApi.applications.uninstallByManifest(app.bxAppManifestURL).then(() => {
this.exitFlow(false);
location.reload();
}).catch((e) => {
Expand Down

0 comments on commit 9331cbe

Please sign in to comment.