feat: replacing JSON.parse by Bourne.parse

This commit is contained in:
Richard Ramos 2019-02-17 15:41:20 -04:00
parent e0ad44cae7
commit 787d1b7cc5
4 changed files with 10 additions and 2 deletions

View File

@ -36,6 +36,7 @@
"homepage": "https://github.com/status-im/status-js#readme",
"dependencies": {
"bip39": "^2.5.0",
"bourne": "^1.1.2",
"chance": "^1.0.16",
"ethereum-hdwallet": "0.0.19",
"ethereumjs-util": "^6.0.0",

View File

@ -2,6 +2,7 @@ import web3Lib from "web3";
import utils from "./utils.js";
import mailservers from "./mailservers";
import constants from "./constants";
import Bourne from "bourne";
declare global {
interface Window { web3: any; }
@ -190,7 +191,7 @@ class StatusJS {
const messageHandler = (data: any) => {
try {
const username = utils.generateUsernameFromSeed(data.sig);
const payloadArray = JSON.parse(hexToAscii(data.payload));
const payloadArray = Bourne.parse(hexToAscii(data.payload));
if (this.channels[channelName].lastClockValue < payloadArray[1][3]) {
this.channels[channelName].lastClockValue = payloadArray[1][3];
}
@ -235,7 +236,7 @@ class StatusJS {
}
try {
const payloadArray = JSON.parse(hexToAscii(data.payload));
const payloadArray = Bourne.parse(hexToAscii(data.payload));
if (this.contacts[data.sig].lastClockValue < payloadArray[1][3]) {
this.contacts[data.sig].lastClockValue = payloadArray[1][3];
}

1
src/types.d.ts vendored
View File

@ -1 +1,2 @@
declare module "chance";
declare module "bourne";

View File

@ -1214,6 +1214,11 @@ body-parser@1.18.3, body-parser@^1.16.0:
raw-body "2.3.3"
type-is "~1.6.16"
bourne@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/bourne/-/bourne-1.1.2.tgz#e290b5bd7166635632eaf8ef12b006b2d4a75b83"
integrity sha512-b2dgVkTZhkQirNMohgC00rWfpVqEi9y5tKM1k3JvoNx05ODtfQoPPd4js9CYFQoY0IM8LAmnJulEuWv74zjUOg==
brace-expansion@^1.1.7:
version "1.1.11"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"