summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2019-04-16 12:59:39 +0200
committerAndrej Mihajlov <and@mullvad.net>2019-04-16 12:59:39 +0200
commit16ed63820f488c20475746e628393fbb3f6d608d (patch)
tree9466c7b41bdba1a2883dd237f2bde5bcc4b95c51
parent07df6028b848c17cb150cf7eff2f6dbc9e49acd7 (diff)
parenta985dfc08ef33a9c6bbaf2e8cf4ac67b1ffa3f72 (diff)
downloadmullvadvpn-16ed63820f488c20475746e628393fbb3f6d608d.tar.xz
mullvadvpn-16ed63820f488c20475746e628393fbb3f6d608d.zip
Merge branch 'retire-jsonstream'
-rw-r--r--gui/package-lock.json50
-rw-r--r--gui/package.json3
-rw-r--r--gui/src/main/jsonrpc-client.ts8
-rw-r--r--gui/tslint.json3
-rw-r--r--gui/types/JSONStream/index.d.ts38
5 files changed, 43 insertions, 59 deletions
diff --git a/gui/package-lock.json b/gui/package-lock.json
index df00056c6b..48f2773e3b 100644
--- a/gui/package-lock.json
+++ b/gui/package-lock.json
@@ -273,6 +273,26 @@
"integrity": "sha512-hkgzYF+qnIl8uTO8rmUSVSfQ8BIfMXC4yJAF4n8BE758YsKBZvFC4NumnAegj7KmylP0liEZNpb9RRGFMbFejA==",
"dev": true
},
+ "@types/stream-chain": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/@types/stream-chain/-/stream-chain-2.0.0.tgz",
+ "integrity": "sha512-O3IRJcZi4YddlS8jgasH87l+rdNmad9uPAMmMZCfRVhumbWMX6lkBWnIqr9kokO5sx8LHp8peQ1ELhMZHbR0Gg==",
+ "dev": true,
+ "requires": {
+ "@types/node": "*"
+ }
+ },
+ "@types/stream-json": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/@types/stream-json/-/stream-json-1.0.0.tgz",
+ "integrity": "sha512-W9B6R5GPbTq72Oz/oJZ8qSl3+6g2xbBK0et+pK/LwGpoSWsHh2AVEYLuQUBUzg+ps4xZGdYJP5nqsW17DFbxzQ==",
+ "dev": true,
+ "requires": {
+ "@types/events": "*",
+ "@types/node": "*",
+ "@types/stream-chain": "*"
+ }
+ },
"@types/topojson-specification": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@types/topojson-specification/-/topojson-specification-1.0.1.tgz",
@@ -291,15 +311,6 @@
"@types/node": "*"
}
},
- "JSONStream": {
- "version": "1.3.5",
- "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz",
- "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==",
- "requires": {
- "jsonparse": "^1.2.0",
- "through": ">=2.2.7 <3"
- }
- },
"abbrev": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
@@ -4632,11 +4643,6 @@
"integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=",
"dev": true
},
- "jsonparse": {
- "version": "1.3.1",
- "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz",
- "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA="
- },
"jsonrpc-lite": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/jsonrpc-lite/-/jsonrpc-lite-2.0.6.tgz",
@@ -7412,6 +7418,11 @@
"integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=",
"dev": true
},
+ "stream-chain": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/stream-chain/-/stream-chain-2.1.0.tgz",
+ "integrity": "sha512-PAUXdRGm0G8P0+/+JEd3O9kfmB9kwmr2nKIc5zhcsHn0KdBByD5PJ2po21iDzc+TZsOSEbU8j4JbAevJsZkLyQ=="
+ },
"stream-combiner": {
"version": "0.0.4",
"resolved": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.0.4.tgz",
@@ -7421,6 +7432,14 @@
"duplexer": "~0.1.1"
}
},
+ "stream-json": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/stream-json/-/stream-json-1.2.1.tgz",
+ "integrity": "sha512-KcZkgyTENM4HXBDyIguAcyWUogXp+wwWF3wLL5QtWj8SlNESx+4xGWk7rYdFDtTvQ1FhSRkQEWv5xOu4eHU+jQ==",
+ "requires": {
+ "stream-chain": "^2.1.0"
+ }
+ },
"stream-throttle": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/stream-throttle/-/stream-throttle-0.1.3.tgz",
@@ -7608,7 +7627,8 @@
"through": {
"version": "2.3.8",
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
- "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU="
+ "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=",
+ "dev": true
},
"through2": {
"version": "0.2.3",
diff --git a/gui/package.json b/gui/package.json
index 48a45c7775..d10736dc48 100644
--- a/gui/package.json
+++ b/gui/package.json
@@ -12,7 +12,6 @@
"repository": "https://github.com/mullvad/mullvadvpn-app",
"license": "GPL-3.0",
"dependencies": {
- "JSONStream": "^1.3.5",
"connected-react-router": "^5.0.1",
"d3-geo-projection": "^2.6.0",
"electron-log": "^2.2.8",
@@ -31,6 +30,7 @@
"reactxp": "^1.6.1",
"redux": "^4.0.1",
"sprintf-js": "^1.1.2",
+ "stream-json": "^1.2.1",
"uuid": "^3.0.1",
"validated": "^2.0.1"
},
@@ -56,6 +56,7 @@
"@types/react-router": "^4.4.3",
"@types/sinon": "^7.0.5",
"@types/sprintf-js": "^1.1.2",
+ "@types/stream-json": "^1.0.0",
"@types/topojson-specification": "^1.0.1",
"@types/uuid": "^3.4.4",
"browser-sync": "^2.26.3",
diff --git a/gui/src/main/jsonrpc-client.ts b/gui/src/main/jsonrpc-client.ts
index 0a6ada62d8..34e4797442 100644
--- a/gui/src/main/jsonrpc-client.ts
+++ b/gui/src/main/jsonrpc-client.ts
@@ -2,8 +2,8 @@ import assert from 'assert';
import log from 'electron-log';
import { EventEmitter } from 'events';
import jsonrpc from 'jsonrpc-lite';
-import JSONStream from 'JSONStream';
import * as net from 'net';
+import StreamValues from 'stream-json/streamers/StreamValues';
import * as uuid from 'uuid';
export interface IUnansweredRequest {
@@ -325,7 +325,7 @@ export class SocketTransport implements ITransport<{ path: string }> {
public connect(options: { path: string }) {
assert(!this.connection, 'Make sure to close the existing socket');
- const jsonStream = JSONStream.parse(null)
+ const jsonStream = StreamValues.withParser()
.on('data', this.onJsonStreamData)
.once('error', this.onJsonStreamError);
@@ -406,8 +406,8 @@ export class SocketTransport implements ITransport<{ path: string }> {
}
};
- private onJsonStreamData = (data: object) => {
- this.onMessage(data);
+ private onJsonStreamData = (data: { key: number; value: any }) => {
+ this.onMessage(data.value);
};
private onJsonStreamError = (error: Error) => {
diff --git a/gui/tslint.json b/gui/tslint.json
index dd9577239b..a7f1b4f959 100644
--- a/gui/tslint.json
+++ b/gui/tslint.json
@@ -17,7 +17,8 @@
],
"no-submodule-imports": [
true,
- "validated"
+ "validated",
+ "stream-json"
],
"object-literal-sort-keys": false,
"variable-name": [
diff --git a/gui/types/JSONStream/index.d.ts b/gui/types/JSONStream/index.d.ts
deleted file mode 100644
index 622cf71cf5..0000000000
--- a/gui/types/JSONStream/index.d.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-// Type definitions for JSONStream v0.8.0
-// Project: https://github.com/dominictarr/JSONStream
-// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
-// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
-
-/// <reference types="node" />
-
-declare module 'JSONStream' {
- export interface Options {
- recurse: boolean;
- }
-
- export function parse(pattern: any): NodeJS.ReadWriteStream;
- export function parse(patterns: any[]): NodeJS.ReadWriteStream;
-
- /**
- * Create a writable stream.
- * you may pass in custom open, close, and seperator strings. But, by default,
- * JSONStream.stringify() will create an array,
- * (with default options open='[\n', sep='\n,\n', close='\n]\n')
- */
- export function stringify(): NodeJS.ReadWriteStream;
-
- /** If you call JSONStream.stringify(false) the elements will only be seperated by a newline. */
- export function stringify(newlineOnly: NewlineOnlyIndicator): NodeJS.ReadWriteStream;
- type NewlineOnlyIndicator = false;
-
- /**
- * Create a writable stream.
- * you may pass in custom open, close, and seperator strings. But, by default,
- * JSONStream.stringify() will create an array,
- * (with default options open='[\n', sep='\n,\n', close='\n]\n')
- */
- export function stringify(open: string, sep: string, close: string): NodeJS.ReadWriteStream;
-
- export function stringifyObject(): NodeJS.ReadWriteStream;
- export function stringifyObject(open: string, sep: string, close: string): NodeJS.ReadWriteStream;
-}