summaryrefslogtreecommitdiffhomepage
path: root/app/lib
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2018-02-21 10:45:11 +0100
committerAndrej Mihajlov <and@mullvad.net>2018-02-21 10:45:11 +0100
commitde737c54c413f96c35b4e9bc6280fc7d26e4fa83 (patch)
tree0cf470c59b4c7c8a6327e64610f68f5facd78d6d /app/lib
parentae9c255b3ecdec341090c932db6cb261147a7382 (diff)
parent1214138633bcca19a1b96622400f3fbcf4044bd9 (diff)
downloadmullvadvpn-de737c54c413f96c35b4e9bc6280fc7d26e4fa83.tar.xz
mullvadvpn-de737c54c413f96c35b4e9bc6280fc7d26e4fa83.zip
Merge branch 'update-flow'
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/backend.js2
-rw-r--r--app/lib/ipc-facade.js15
-rw-r--r--app/lib/jsonrpc-ws-ipc.js4
-rw-r--r--app/lib/rpc-file-security.js1
4 files changed, 13 insertions, 9 deletions
diff --git a/app/lib/backend.js b/app/lib/backend.js
index b12ed54ca9..00c40fa05f 100644
--- a/app/lib/backend.js
+++ b/app/lib/backend.js
@@ -507,7 +507,7 @@ export class Backend {
}
}
- _ensureAuthenticated() {
+ _ensureAuthenticated(): Promise<void> {
const credentials = this._credentials;
if(credentials) {
if(!this._authenticationPromise) {
diff --git a/app/lib/ipc-facade.js b/app/lib/ipc-facade.js
index 244e6bcc4b..0a64a5cc68 100644
--- a/app/lib/ipc-facade.js
+++ b/app/lib/ipc-facade.js
@@ -4,6 +4,8 @@ import JsonRpcWs, { InvalidReply } from './jsonrpc-ws-ipc';
import { object, maybe, string, number, boolean, enumeration, arrayOf, oneOf } from 'validated/schema';
import { validate } from 'validated/object';
+import type { Node as SchemaNode } from 'validated/schema';
+
export type AccountData = { expiry: string };
export type AccountToken = string;
export type Ip = string;
@@ -75,13 +77,14 @@ export type RelaySettingsUpdate = {|
custom_tunnel_endpoint: RelaySettingsCustom
|};
-const Constraint = (v) => oneOf(string, object({
- only: v,
+const constraint = <T>(constraintValue: SchemaNode<T>) => oneOf(string, object({
+ only: constraintValue,
}));
+
const RelaySettingsSchema = oneOf(
object({
normal: object({
- location: Constraint(oneOf(
+ location: constraint(oneOf(
object({
city: arrayOf(string),
}),
@@ -89,10 +92,10 @@ const RelaySettingsSchema = oneOf(
country: string
}),
)),
- tunnel: Constraint(object({
+ tunnel: constraint(object({
openvpn: object({
- port: Constraint(number),
- protocol: Constraint(enumeration('udp', 'tcp')),
+ port: constraint(number),
+ protocol: constraint(enumeration('udp', 'tcp')),
}),
})),
})
diff --git a/app/lib/jsonrpc-ws-ipc.js b/app/lib/jsonrpc-ws-ipc.js
index 002a146606..ecf6309380 100644
--- a/app/lib/jsonrpc-ws-ipc.js
+++ b/app/lib/jsonrpc-ws-ipc.js
@@ -7,7 +7,7 @@ import { log } from '../lib/platform';
export type UnansweredRequest = {
resolve: (mixed) => void,
reject: (mixed) => void,
- timerId: number,
+ timerId: TimeoutID,
message: Object,
}
@@ -154,7 +154,7 @@ export default class Ipc {
}
}
- _getWebSocket() {
+ _getWebSocket(): Promise<WebSocket> {
return new Promise(resolve => {
if (this._websocket && this._websocket.readyState === 1) { // Connected
resolve(this._websocket);
diff --git a/app/lib/rpc-file-security.js b/app/lib/rpc-file-security.js
index da777d9b78..22dedb00be 100644
--- a/app/lib/rpc-file-security.js
+++ b/app/lib/rpc-file-security.js
@@ -24,6 +24,7 @@ function isOwnedAndOnlyWritableByRoot(path: string): boolean {
}
function isOwnedByLocalSystem(path: string): boolean {
+ // $FlowFixMe: this module is only available on Windows
const winsec = require('windows-security');
const ownerSid = winsec.getFileOwnerSid(path, null);
const isWellKnownSid = winsec.isWellKnownSid(ownerSid, winsec.WellKnownSid.LocalSystemSid);