rn: skip logging potentially sensitive data

This commit is contained in:
Saúl Ibarra Corretgé 2019-11-14 13:33:20 +01:00 committed by Saúl Ibarra Corretgé
parent af6642b91b
commit c2c323347a
2 changed files with 23 additions and 10 deletions

View File

@ -4,6 +4,8 @@ import md5 from 'js-md5';
import logger from './logger'; import logger from './logger';
declare var __DEV__;
/** /**
* The name of the {@code localStorage} store where the app persists its values. * The name of the {@code localStorage} store where the app persists its values.
*/ */
@ -87,7 +89,9 @@ class PersistenceRegistry {
// Initialize the checksum. // Initialize the checksum.
this._checksum = this._calculateChecksum(filteredPersistedState); this._checksum = this._calculateChecksum(filteredPersistedState);
logger.info('redux state rehydrated as', filteredPersistedState); if (typeof __DEV__ !== 'undefined' && __DEV__) {
logger.info('redux state rehydrated as', filteredPersistedState);
}
return filteredPersistedState; return filteredPersistedState;
} }
@ -113,7 +117,6 @@ class PersistenceRegistry {
logger.error( logger.error(
'Error persisting redux subtree', 'Error persisting redux subtree',
subtreeName, subtreeName,
filteredState[subtreeName],
error); error);
} }
} }
@ -153,7 +156,7 @@ class PersistenceRegistry {
try { try {
return md5.hex(JSON.stringify(state) || ''); return md5.hex(JSON.stringify(state) || '');
} catch (error) { } catch (error) {
logger.error('Error calculating checksum for state', state, error); logger.error('Error calculating checksum for state', error);
return ''; return '';
} }

View File

@ -15,10 +15,10 @@ import {
CONNECTION_DISCONNECTED, CONNECTION_DISCONNECTED,
CONNECTION_FAILED, CONNECTION_FAILED,
JITSI_CONNECTION_CONFERENCE_KEY, JITSI_CONNECTION_CONFERENCE_KEY,
JITSI_CONNECTION_URL_KEY JITSI_CONNECTION_URL_KEY,
getURLWithoutParams
} from '../../base/connection'; } from '../../base/connection';
import { MiddlewareRegistry } from '../../base/redux'; import { MiddlewareRegistry } from '../../base/redux';
import { toURLString } from '../../base/util';
import { ENTER_PICTURE_IN_PICTURE } from '../picture-in-picture'; import { ENTER_PICTURE_IN_PICTURE } from '../picture-in-picture';
import { sendEvent } from './functions'; import { sendEvent } from './functions';
@ -82,7 +82,7 @@ MiddlewareRegistry.register(store => next => action => {
store, store,
CONFERENCE_TERMINATED, CONFERENCE_TERMINATED,
/* data */ { /* data */ {
url: toURLString(locationURL) url: _normalizeUrl(locationURL)
}); });
} }
@ -106,7 +106,7 @@ MiddlewareRegistry.register(store => next => action => {
CONFERENCE_TERMINATED, CONFERENCE_TERMINATED,
/* data */ { /* data */ {
error: _toErrorString(error), error: _toErrorString(error),
url: toURLString(locationURL) url: _normalizeUrl(locationURL)
}); });
break; break;
} }
@ -161,10 +161,20 @@ function _maybeTriggerEarlyConferenceWillJoin(store, action) {
store, store,
CONFERENCE_WILL_JOIN, CONFERENCE_WILL_JOIN,
/* data */ { /* data */ {
url: toURLString(locationURL) url: _normalizeUrl(locationURL)
}); });
} }
/**
* Normalizes the given URL for presentation over the external API.
*
* @param {URL} url -The URL to normalize.
* @returns {string} - The normalized URL as a string.
*/
function _normalizeUrl(url: URL) {
return getURLWithoutParams(url).href;
}
/** /**
* Sends an event to the native counterpart of the External API for a specific * Sends an event to the native counterpart of the External API for a specific
* conference-related redux action. * conference-related redux action.
@ -186,7 +196,7 @@ function _sendConferenceEvent(
// instance. The external API cannot transport such an object so we have to // instance. The external API cannot transport such an object so we have to
// transport an "equivalent". // transport an "equivalent".
if (conference) { if (conference) {
data.url = toURLString(conference[JITSI_CONFERENCE_URL_KEY]); data.url = _normalizeUrl(conference[JITSI_CONFERENCE_URL_KEY]);
} }
if (_swallowEvent(store, action, data)) { if (_swallowEvent(store, action, data)) {
@ -233,7 +243,7 @@ function _sendConferenceFailedOnConnectionError(store, action) {
store, store,
CONFERENCE_TERMINATED, CONFERENCE_TERMINATED,
/* data */ { /* data */ {
url: toURLString(locationURL), url: _normalizeUrl(locationURL),
error: action.error.name error: action.error.name
}); });
} }