Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

fix(misc) use safeJsonParse from js-utils

Saúl Ibarra Corretgé7ea2b9c8c035
diff --git a/package-lock.json b/package-lock.json
index c34d538bec..3a3ae63a48 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -16,9 +16,8 @@
"@giphy/js-fetch-api": "4.7.1",
"@giphy/react-components": "6.8.1",
"@giphy/react-native-sdk": "2.3.0",
- "@hapi/bourne": "2.0.0",
"@jitsi/excalidraw": "https://github.com/jitsi/excalidraw/releases/download/v0.0.14/jitsi-excalidraw-0.0.14.tgz",
- "@jitsi/js-utils": "2.0.6",
+ "@jitsi/js-utils": "2.1.2",
"@jitsi/logger": "2.0.0",
"@jitsi/rnnoise-wasm": "0.1.0",
"@jitsi/rtcstats": "9.5.1",
@@ -2949,9 +2948,9 @@
}
},
"node_modules/@hapi/bourne": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/@hapi/bourne/-/bourne-2.0.0.tgz",
- "integrity": "sha512-WEezM1FWztfbzqIUbsDzFRVMxSoLy3HugVcux6KDDtTqzPsLE8NDRHfXvev66aH1i2oOKKar3/XDjbvh/OUBdg=="
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/@hapi/bourne/-/bourne-3.0.0.tgz",
+ "integrity": "sha512-Waj1cwPXJDucOib4a3bAISsKJVb15MKi9IvmTI/7ssVEm6sywXGjVJDhl6/umt1pK1ZS7PacXU3A1PmFKHEZ2w=="
},
"node_modules/@hapi/hoek": {
"version": "9.3.0",
@@ -3110,10 +3109,11 @@
}
},
"node_modules/@jitsi/js-utils": {
- "version": "2.0.6",
- "resolved": "https://registry.npmjs.org/@jitsi/js-utils/-/js-utils-2.0.6.tgz",
- "integrity": "sha512-Z5cy1d8JmymAK5O0AOtNQFDqbKictcnafFzDTRxYK7Dcf62GSVlxoHizAhoUowilb+HcZC0W3YA3+NqLtMM//w==",
+ "version": "2.1.2",
+ "resolved": "https://registry.npmjs.org/@jitsi/js-utils/-/js-utils-2.1.2.tgz",
+ "integrity": "sha512-KT6rIr+kJ1AoKf7freQzOH3+ltOyrhe1vyhNukTM/UMStvtrXZyZmNNywhgqegpt0d0DNaHOYLmjj7186AXVcw==",
"dependencies": {
+ "@hapi/bourne": "^3.0.0",
"bowser": "2.7.0",
"js-md5": "0.7.3"
}
@@ -21915,9 +21915,9 @@
}
},
"@hapi/bourne": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/@hapi/bourne/-/bourne-2.0.0.tgz",
- "integrity": "sha512-WEezM1FWztfbzqIUbsDzFRVMxSoLy3HugVcux6KDDtTqzPsLE8NDRHfXvev66aH1i2oOKKar3/XDjbvh/OUBdg=="
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/@hapi/bourne/-/bourne-3.0.0.tgz",
+ "integrity": "sha512-Waj1cwPXJDucOib4a3bAISsKJVb15MKi9IvmTI/7ssVEm6sywXGjVJDhl6/umt1pK1ZS7PacXU3A1PmFKHEZ2w=="
},
"@hapi/hoek": {
"version": "9.3.0",
@@ -22031,10 +22031,11 @@
"integrity": "sha512-iK7p7i6qJFOkjTVZhWDvurDW1u+eMoOhAVgpab9CZEqCTX+W4Ih4AOPrUpf+mjaAHK5XqmQZSc5nVEpMg+xIGQ=="
},
"@jitsi/js-utils": {
- "version": "2.0.6",
- "resolved": "https://registry.npmjs.org/@jitsi/js-utils/-/js-utils-2.0.6.tgz",
- "integrity": "sha512-Z5cy1d8JmymAK5O0AOtNQFDqbKictcnafFzDTRxYK7Dcf62GSVlxoHizAhoUowilb+HcZC0W3YA3+NqLtMM//w==",
+ "version": "2.1.2",
+ "resolved": "https://registry.npmjs.org/@jitsi/js-utils/-/js-utils-2.1.2.tgz",
+ "integrity": "sha512-KT6rIr+kJ1AoKf7freQzOH3+ltOyrhe1vyhNukTM/UMStvtrXZyZmNNywhgqegpt0d0DNaHOYLmjj7186AXVcw==",
"requires": {
+ "@hapi/bourne": "^3.0.0",
"bowser": "2.7.0",
"js-md5": "0.7.3"
},
diff --git a/package.json b/package.json
index 9b89baffb9..207d00454e 100644
--- a/package.json
+++ b/package.json
@@ -22,9 +22,8 @@
"@giphy/js-fetch-api": "4.7.1",
"@giphy/react-components": "6.8.1",
"@giphy/react-native-sdk": "2.3.0",
- "@hapi/bourne": "2.0.0",
"@jitsi/excalidraw": "https://github.com/jitsi/excalidraw/releases/download/v0.0.14/jitsi-excalidraw-0.0.14.tgz",
- "@jitsi/js-utils": "2.0.6",
+ "@jitsi/js-utils": "2.1.2",
"@jitsi/logger": "2.0.0",
"@jitsi/rnnoise-wasm": "0.1.0",
"@jitsi/rtcstats": "9.5.1",
diff --git a/react/features/base/config/functions.any.ts b/react/features/base/config/functions.any.ts
index 1062bc5268..409a2e01c5 100644
--- a/react/features/base/config/functions.any.ts
+++ b/react/features/base/config/functions.any.ts
@@ -1,8 +1,8 @@
-// @ts-expect-error
-import Bourne from '@hapi/bourne';
-// eslint-disable-next-line lines-around-comment
-// @ts-expect-error
+// @ts-ignore
import { jitsiLocalStorage } from '@jitsi/js-utils';
+// eslint-disable-next-line lines-around-comment
+// @ts-ignore
+import { safeJsonParse } from '@jitsi/js-utils/json';
import _ from 'lodash';
import { IReduxState } from '../../app/types';
@@ -223,7 +223,7 @@ export function restoreConfig(baseURL: string) {
if (config) {
try {
- return Bourne.parse(config) || undefined;
+ return safeJsonParse(config) || undefined;
} catch (e) {
// Somehow incorrect data ended up in the storage. Clean it up.
jitsiLocalStorage.removeItem(key);
diff --git a/react/features/base/jitsi-local-storage/setup.web.ts b/react/features/base/jitsi-local-storage/setup.web.ts
index 8da1c95deb..2bc9663def 100644
--- a/react/features/base/jitsi-local-storage/setup.web.ts
+++ b/react/features/base/jitsi-local-storage/setup.web.ts
@@ -1,8 +1,8 @@
-// @ts-expect-error
-import Bourne from '@hapi/bourne';
-// eslint-disable-next-line lines-around-comment
-// @ts-expect-error
+// @ts-ignore
import { jitsiLocalStorage } from '@jitsi/js-utils/jitsi-local-storage';
+// eslint-disable-next-line lines-around-comment
+// @ts-ignore
+import { safeJsonParse } from '@jitsi/js-utils/json';
import { browser } from '../lib-jitsi-meet';
import { inIframe } from '../util/iframeUtils';
@@ -61,7 +61,7 @@ function setupJitsiLocalStorage() {
if (shouldUseHostPageLocalStorage(urlParams)) {
try {
- const localStorageContent = Bourne.parse(urlParams['appData.localStorageContent']);
+ const localStorageContent = safeJsonParse(urlParams['appData.localStorageContent']);
if (typeof localStorageContent === 'object') {
Object.keys(localStorageContent).forEach(key => {
diff --git a/react/features/base/lib-jitsi-meet/functions.native.ts b/react/features/base/lib-jitsi-meet/functions.native.ts
index 1cbb1e6b2a..28b57d0a08 100644
--- a/react/features/base/lib-jitsi-meet/functions.native.ts
+++ b/react/features/base/lib-jitsi-meet/functions.native.ts
@@ -1,5 +1,5 @@
-// @ts-expect-error
-import Bourne from '@hapi/bourne';
+// @ts-ignore
+import { safeJsonParse } from '@jitsi/js-utils/json';
import { NativeModules } from 'react-native';
import { loadScript } from '../util/loadScript.native';
@@ -20,7 +20,7 @@ export async function loadConfig(url: string): Promise<Object> {
try {
const configTxt = await loadScript(url, 10 * 1000 /* Timeout in ms */, true /* skipeval */);
const configJson = await JavaScriptSandbox.evaluate(`${configTxt}\nJSON.stringify(config);`);
- const config = Bourne.parse(configJson);
+ const config = safeJsonParse(configJson);
if (typeof config !== 'object') {
throw new Error('config is not an object');
diff --git a/react/features/base/redux/PersistenceRegistry.ts b/react/features/base/redux/PersistenceRegistry.ts
index cdbbb1cefa..629619218c 100644
--- a/react/features/base/redux/PersistenceRegistry.ts
+++ b/react/features/base/redux/PersistenceRegistry.ts
@@ -1,8 +1,8 @@
-// @ts-expect-error
-import Bourne from '@hapi/bourne';
-// eslint-disable-next-line lines-around-comment
-// @ts-expect-error
+// @ts-ignore
import { jitsiLocalStorage } from '@jitsi/js-utils';
+// eslint-disable-next-line lines-around-comment
+// @ts-ignore
+import { safeJsonParse } from '@jitsi/js-utils/json';
import md5 from 'js-md5';
import logger from './logger';
@@ -193,7 +193,7 @@ class PersistenceRegistry {
if (persistedSubtree) {
try {
- persistedSubtree = Bourne.parse(persistedSubtree);
+ persistedSubtree = safeJsonParse(persistedSubtree);
const filteredSubtree
= this._getFilteredSubtree(persistedSubtree, subtreeConfig);
diff --git a/react/features/base/util/parseURLParams.ts b/react/features/base/util/parseURLParams.ts
index c420e9ec5c..78c2790104 100644
--- a/react/features/base/util/parseURLParams.ts
+++ b/react/features/base/util/parseURLParams.ts
@@ -1,5 +1,5 @@
-// @ts-expect-error
-import Bourne from '@hapi/bourne';
+// @ts-ignore
+import { safeJsonParse } from '@jitsi/js-utils/json';
import { reportError } from './helpers';
@@ -62,7 +62,7 @@ export function parseURLParams(
if (!dontParse) {
const decoded = decodeURIComponent(value).replace(/\\&/, '&');
- value = decoded === 'undefined' ? undefined : Bourne.parse(decoded);
+ value = decoded === 'undefined' ? undefined : safeJsonParse(decoded);
}
} catch (e: any) {
reportError(
diff --git a/react/features/virtual-background/components/VirtualBackgrounds.tsx b/react/features/virtual-background/components/VirtualBackgrounds.tsx
index 767e94aff4..3e20faef5a 100644
--- a/react/features/virtual-background/components/VirtualBackgrounds.tsx
+++ b/react/features/virtual-background/components/VirtualBackgrounds.tsx
@@ -1,8 +1,8 @@
-// @ts-expect-error
-import Bourne from '@hapi/bourne';
-// eslint-disable-next-line lines-around-comment
-// @ts-expect-error
+// @ts-ignore
import { jitsiLocalStorage } from '@jitsi/js-utils/jitsi-local-storage';
+// eslint-disable-next-line lines-around-comment
+// @ts-ignore
+import { safeJsonParse } from '@jitsi/js-utils/json';
import React, { useCallback, useEffect, useState } from 'react';
import { WithTranslation } from 'react-i18next';
import { connect } from 'react-redux';
@@ -217,7 +217,7 @@ function VirtualBackgrounds({
const { classes, cx } = useStyles();
const [ previewIsLoaded, setPreviewIsLoaded ] = useState(false);
const localImages = jitsiLocalStorage.getItem('virtualBackgrounds');
- const [ storedImages, setStoredImages ] = useState<Array<Image>>((localImages && Bourne.parse(localImages)) || []);
+ const [ storedImages, setStoredImages ] = useState<Array<Image>>((localImages && safeJsonParse(localImages)) || []);
const [ loading, setLoading ] = useState(false);
useEffect(() => {