summaryrefslogtreecommitdiffhomepage
path: root/gui/src/shared
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2022-03-14 13:59:05 +0100
committerOskar Nyberg <oskar@mullvad.net>2022-03-14 13:59:05 +0100
commit4ab205bd9add69264ccdfaaf8cf068515ceddb77 (patch)
tree302357507a7e51ece04f563c5f7018d64adaccac /gui/src/shared
parent6459ae7beefcc5f13eb54254dfe402dd807c62fe (diff)
parent55aa3418f8b7ec6f473fd22819f7e54cb432d097 (diff)
downloadmullvadvpn-4ab205bd9add69264ccdfaaf8cf068515ceddb77.tar.xz
mullvadvpn-4ab205bd9add69264ccdfaaf8cf068515ceddb77.zip
Merge branch 'device-api-electron'
Diffstat (limited to 'gui/src/shared')
-rw-r--r--gui/src/shared/daemon-rpc-types.ts39
-rw-r--r--gui/src/shared/ipc-schema.ts19
-rw-r--r--gui/src/shared/localization-contexts.ts3
-rw-r--r--gui/src/shared/notifications/no-valid-key.ts38
-rw-r--r--gui/src/shared/notifications/notification.ts1
-rw-r--r--gui/src/shared/string-helpers.ts4
6 files changed, 39 insertions, 65 deletions
diff --git a/gui/src/shared/daemon-rpc-types.ts b/gui/src/shared/daemon-rpc-types.ts
index eec1e1f2a4..b08f375e96 100644
--- a/gui/src/shared/daemon-rpc-types.ts
+++ b/gui/src/shared/daemon-rpc-types.ts
@@ -104,8 +104,9 @@ export type DaemonEvent =
| { tunnelState: TunnelState }
| { settings: ISettings }
| { relayList: IRelayList }
- | { wireguardKey: KeygenEvent }
- | { appVersionInfo: IAppVersionInfo };
+ | { appVersionInfo: IAppVersionInfo }
+ | { device: IDeviceEvent }
+ | { deviceRemoval: Array<IDevice> };
export interface ITunnelStateRelayInfo {
endpoint: ITunnelEndpoint;
@@ -321,8 +322,28 @@ export interface IAppVersionInfo {
suggestedIsBeta?: boolean;
}
+export interface IDeviceEvent {
+ deviceConfig?: IDeviceConfig;
+ remote?: boolean;
+}
+
+export interface IDeviceConfig {
+ accountToken: AccountToken;
+ device?: IDevice;
+}
+
+export interface IDevice {
+ id: string;
+ name: string;
+ ports?: Array<string>;
+}
+
+export interface IDeviceRemoval {
+ accountToken: string;
+ deviceId: string;
+}
+
export interface ISettings {
- accountToken?: AccountToken;
allowLan: boolean;
autoConnect: boolean;
blockWhenDisconnected: boolean;
@@ -334,18 +355,6 @@ export interface ISettings {
splitTunnel: SplitTunnelSettings;
}
-export type KeygenEvent = INewWireguardKey | KeygenFailure;
-export type KeygenFailure = 'too_many_keys' | 'generation_failure';
-
-export interface INewWireguardKey {
- newKey: IWireguardPublicKey;
-}
-
-export interface IWireguardPublicKey {
- key: string;
- created: string;
-}
-
export type BridgeState = 'auto' | 'on' | 'off';
export type SplitTunnelSettings = {
diff --git a/gui/src/shared/ipc-schema.ts b/gui/src/shared/ipc-schema.ts
index 0ed0985bf1..29d00bb1c4 100644
--- a/gui/src/shared/ipc-schema.ts
+++ b/gui/src/shared/ipc-schema.ts
@@ -6,15 +6,17 @@ import {
BridgeState,
IAccountData,
IAppVersionInfo,
+ IDevice,
+ IDeviceConfig,
+ IDeviceRemoval,
IDnsOptions,
ILocation,
IRelayList,
ISettings,
- IWireguardPublicKey,
- KeygenEvent,
RelaySettingsUpdate,
TunnelState,
VoucherResponse,
+ IDeviceEvent,
} from './daemon-rpc-types';
import { IGuiSettingsState } from './gui-settings-state';
import { LogLevel } from './logging-types';
@@ -52,11 +54,11 @@ export interface IAppStateSnapshot {
accountHistory?: AccountToken;
tunnelState: TunnelState;
settings: ISettings;
+ deviceConfig?: IDeviceConfig;
relayListPair: IRelayListPair;
currentVersion: ICurrentAppVersionInfo;
upgradeVersion: IAppVersionInfo;
guiSettings: IGuiSettingsState;
- wireguardPublicKey?: IWireguardPublicKey;
translations: ITranslations;
windowsSplitTunnelingApplications?: IApplication[];
macOsScrollbarVisibility?: MacOsScrollbarVisibility;
@@ -166,12 +168,17 @@ export const ipcSchema = {
},
account: {
'': notifyRenderer<IAccountData | undefined>(),
+ device: notifyRenderer<IDeviceEvent>(),
+ devices: notifyRenderer<Array<IDevice>>(),
create: invoke<void, string>(),
login: invoke<AccountToken, void>(),
logout: invoke<void, void>(),
getWwwAuthToken: invoke<void, string>(),
submitVoucher: invoke<string, VoucherResponse>(),
updateData: send<void>(),
+ getDevice: invoke<void, IDevice | undefined>(),
+ listDevices: invoke<AccountToken, Array<IDevice>>(),
+ removeDevice: invoke<IDeviceRemoval, void>(),
},
accountHistory: {
'': notifyRenderer<AccountToken | undefined>(),
@@ -181,12 +188,6 @@ export const ipcSchema = {
'': notifyRenderer<boolean>(),
set: invoke<boolean, void>(),
},
- wireguardKeys: {
- publicKey: notifyRenderer<IWireguardPublicKey | undefined>(),
- keygenEvent: notifyRenderer<KeygenEvent>(),
- generateKey: invoke<void, KeygenEvent>(),
- verifyKey: invoke<void, boolean>(),
- },
problemReport: {
collectLogs: invoke<string | undefined, string>(),
sendReport: invoke<{ email: string; message: string; savedReportId: string }, void>(),
diff --git a/gui/src/shared/localization-contexts.ts b/gui/src/shared/localization-contexts.ts
index b402278571..e323567094 100644
--- a/gui/src/shared/localization-contexts.ts
+++ b/gui/src/shared/localization-contexts.ts
@@ -2,6 +2,7 @@ export type LocalizationContexts =
| 'changelog'
| 'accessibility'
| 'login-view'
+ | 'device-management'
| 'auth-failure'
| 'launch-view'
| 'error-boundary-view'
@@ -29,8 +30,6 @@ export type LocalizationContexts =
| 'wireguard-settings-nav'
| 'openvpn-settings-view'
| 'openvpn-settings-nav'
- | 'wireguard-key-view'
- | 'wireguard-keys-nav'
| 'split-tunneling-view'
| 'split-tunneling-nav'
| 'support-view'
diff --git a/gui/src/shared/notifications/no-valid-key.ts b/gui/src/shared/notifications/no-valid-key.ts
deleted file mode 100644
index 6de28ab8df..0000000000
--- a/gui/src/shared/notifications/no-valid-key.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-import { WgKeyState } from '../../renderer/redux/settings/reducers';
-import { messages } from '../../shared/gettext';
-import { LiftedConstraint, TunnelProtocol } from '../daemon-rpc-types';
-import { InAppNotification, InAppNotificationProvider } from './notification';
-
-interface NoValidKeyNotificationContext {
- tunnelProtocol?: LiftedConstraint<TunnelProtocol>;
- wireGuardKey: WgKeyState;
-}
-
-export class NoValidKeyNotificationProvider implements InAppNotificationProvider {
- public constructor(private context: NoValidKeyNotificationContext) {}
-
- public mayDisplay() {
- const usingWireGuard =
- this.context.tunnelProtocol === 'wireguard' ||
- (this.context.tunnelProtocol === 'any' &&
- (process.platform ?? window.env.platform) !== 'win32');
- const keyInvalid =
- this.context.wireGuardKey.type === 'key-not-set' ||
- this.context.wireGuardKey.type === 'too-many-keys' ||
- this.context.wireGuardKey.type === 'generation-failure' ||
- (this.context.wireGuardKey.type === 'key-set' &&
- this.context.wireGuardKey.key.valid === false) ||
- (this.context.wireGuardKey.type === 'key-set' &&
- this.context.wireGuardKey.key.replacementFailure === 'too_many_keys');
-
- return usingWireGuard && keyInvalid;
- }
-
- public getInAppNotification(): InAppNotification {
- return {
- indicator: 'warning',
- title: messages.pgettext('in-app-notifications', 'VALID WIREGUARD KEY IS MISSING'),
- subtitle: messages.pgettext('in-app-notifications', 'Manage keys under Advanced settings.'),
- };
- }
-}
diff --git a/gui/src/shared/notifications/notification.ts b/gui/src/shared/notifications/notification.ts
index 570bf2f12b..2152da0e79 100644
--- a/gui/src/shared/notifications/notification.ts
+++ b/gui/src/shared/notifications/notification.ts
@@ -41,7 +41,6 @@ export * from './connected';
export * from './connecting';
export * from './disconnected';
export * from './error';
-export * from './no-valid-key';
export * from './inconsistent-version';
export * from './reconnecting';
export * from './unsupported-version';
diff --git a/gui/src/shared/string-helpers.ts b/gui/src/shared/string-helpers.ts
index 30a2ac9d58..c69ebddfcf 100644
--- a/gui/src/shared/string-helpers.ts
+++ b/gui/src/shared/string-helpers.ts
@@ -1,3 +1,7 @@
export function capitalize(inputString: string): string {
return inputString.charAt(0).toUpperCase() + inputString.slice(1);
}
+
+export function capitalizeEveryWord(inputString: string): string {
+ return inputString.split(' ').map(capitalize).join(' ');
+}