diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2018-02-21 10:45:11 +0100 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2018-02-21 10:45:11 +0100 |
| commit | de737c54c413f96c35b4e9bc6280fc7d26e4fa83 (patch) | |
| tree | 0cf470c59b4c7c8a6327e64610f68f5facd78d6d /app/lib/ipc-facade.js | |
| parent | ae9c255b3ecdec341090c932db6cb261147a7382 (diff) | |
| parent | 1214138633bcca19a1b96622400f3fbcf4044bd9 (diff) | |
| download | mullvadvpn-de737c54c413f96c35b4e9bc6280fc7d26e4fa83.tar.xz mullvadvpn-de737c54c413f96c35b4e9bc6280fc7d26e4fa83.zip | |
Merge branch 'update-flow'
Diffstat (limited to 'app/lib/ipc-facade.js')
| -rw-r--r-- | app/lib/ipc-facade.js | 15 |
1 files changed, 9 insertions, 6 deletions
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')), }), })), }) |
