Commit 92330875 authored by JC Brand's avatar JC Brand

Don't hash web storage ids.

Makes debugging more difficult and uses up extra CPU cycles for no real security benefit.
parent af0093bd
This diff is collapsed.
...@@ -17,7 +17,7 @@ import tpl_bookmarks_list from "templates/bookmarks_list.html" ...@@ -17,7 +17,7 @@ import tpl_bookmarks_list from "templates/bookmarks_list.html"
import tpl_chatroom_bookmark_form from "templates/chatroom_bookmark_form.html"; import tpl_chatroom_bookmark_form from "templates/chatroom_bookmark_form.html";
import tpl_chatroom_bookmark_toggle from "templates/chatroom_bookmark_toggle.html"; import tpl_chatroom_bookmark_toggle from "templates/chatroom_bookmark_toggle.html";
const { Backbone, Promise, Strophe, $iq, b64_sha1, sizzle, _ } = converse.env; const { Backbone, Promise, Strophe, $iq, sizzle, _ } = converse.env;
const u = converse.env.utils; const u = converse.env.utils;
...@@ -243,8 +243,8 @@ converse.plugins.add('converse-bookmarks', { ...@@ -243,8 +243,8 @@ converse.plugins.add('converse-bookmarks', {
const storage = _converse.config.get('storage'), const storage = _converse.config.get('storage'),
cache_key = `converse.room-bookmarks${_converse.bare_jid}`; cache_key = `converse.room-bookmarks${_converse.bare_jid}`;
this.fetched_flag = b64_sha1(cache_key+'fetched'); this.fetched_flag = cache_key+'fetched';
this.browserStorage = new Backbone.BrowserStorage[storage](b64_sha1(cache_key)); this.browserStorage = new Backbone.BrowserStorage[storage](cache_key);
}, },
openBookmarkedRoom (bookmark) { openBookmarkedRoom (bookmark) {
...@@ -434,7 +434,7 @@ converse.plugins.add('converse-bookmarks', { ...@@ -434,7 +434,7 @@ converse.plugins.add('converse-bookmarks', {
_converse.chatboxes.on('remove', this.renderBookmarkListElement, this); _converse.chatboxes.on('remove', this.renderBookmarkListElement, this);
const storage = _converse.config.get('storage'), const storage = _converse.config.get('storage'),
id = b64_sha1(`converse.room-bookmarks${_converse.bare_jid}-list-model`); id = `converse.room-bookmarks${_converse.bare_jid}-list-model`;
this.list_model = new _converse.BookmarksList({'id': id}); this.list_model = new _converse.BookmarksList({'id': id});
this.list_model.browserStorage = new Backbone.BrowserStorage[storage](id); this.list_model.browserStorage = new Backbone.BrowserStorage[storage](id);
this.list_model.fetch(); this.list_model.fetch();
......
...@@ -12,7 +12,7 @@ import tpl_toggle_chats from "templates/toggle_chats.html"; ...@@ -12,7 +12,7 @@ import tpl_toggle_chats from "templates/toggle_chats.html";
import tpl_trimmed_chat from "templates/trimmed_chat.html"; import tpl_trimmed_chat from "templates/trimmed_chat.html";
const { _ , Backbone, Promise, Strophe, b64_sha1, moment } = converse.env; const { _ , Backbone, Promise, Strophe, moment } = converse.env;
const u = converse.env.utils; const u = converse.env.utils;
converse.plugins.add('converse-minimize', { converse.plugins.add('converse-minimize', {
...@@ -414,7 +414,7 @@ converse.plugins.add('converse-minimize', { ...@@ -414,7 +414,7 @@ converse.plugins.add('converse-minimize', {
initToggle () { initToggle () {
const storage = _converse.config.get('storage'), const storage = _converse.config.get('storage'),
id = b64_sha1(`converse.minchatstoggle${_converse.bare_jid}`); id = `converse.minchatstoggle${_converse.bare_jid}`;
this.toggleview = new _converse.MinimizedChatsToggleView({ this.toggleview = new _converse.MinimizedChatsToggleView({
'model': new _converse.MinimizedChatsToggle({'id': id}) 'model': new _converse.MinimizedChatsToggle({'id': id})
}); });
......
...@@ -33,7 +33,7 @@ import tpl_spinner from "templates/spinner.html"; ...@@ -33,7 +33,7 @@ import tpl_spinner from "templates/spinner.html";
import xss from "xss"; import xss from "xss";
const { Backbone, Promise, Strophe, b64_sha1, moment, f, sizzle, _, $build, $iq, $msg, $pres } = converse.env; const { Backbone, Promise, Strophe, moment, f, sizzle, _, $build, $iq, $msg, $pres } = converse.env;
const u = converse.env.utils; const u = converse.env.utils;
const AFFILIATION_CHANGE_COMANDS = ['admin', 'ban', 'owner', 'member', 'revoke']; const AFFILIATION_CHANGE_COMANDS = ['admin', 'ban', 'owner', 'member', 'revoke'];
...@@ -60,9 +60,9 @@ converse.plugins.add('converse-muc-views', { ...@@ -60,9 +60,9 @@ converse.plugins.add('converse-muc-views', {
const { _converse } = this.__super__; const { _converse } = this.__super__;
this.roomspanel = new _converse.RoomsPanel({ this.roomspanel = new _converse.RoomsPanel({
'model': new (_converse.RoomsPanelModel.extend({ 'model': new (_converse.RoomsPanelModel.extend({
'id': b64_sha1(`converse.roomspanel${_converse.bare_jid}`), // Required by sessionStorage 'id': `converse.roomspanel${_converse.bare_jid}`, // Required by web storage
'browserStorage': new Backbone.BrowserStorage[_converse.config.get('storage')]( 'browserStorage': new Backbone.BrowserStorage[_converse.config.get('storage')](
b64_sha1(`converse.roomspanel${_converse.bare_jid}`)) `converse.roomspanel${_converse.bare_jid}`)
}))() }))()
}); });
this.roomspanel.model.fetch(); this.roomspanel.model.fetch();
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
import converse from "@converse/headless/converse-core"; import converse from "@converse/headless/converse-core";
import tpl_toolbar_omemo from "templates/toolbar_omemo.html"; import tpl_toolbar_omemo from "templates/toolbar_omemo.html";
const { Backbone, Promise, Strophe, moment, sizzle, $build, $iq, $msg, _, f, b64_sha1 } = converse.env; const { Backbone, Promise, Strophe, moment, sizzle, $build, $iq, $msg, _, f } = converse.env;
const u = converse.env.utils; const u = converse.env.utils;
Strophe.addNamespace('OMEMO_DEVICELIST', Strophe.NS.OMEMO+".devicelist"); Strophe.addNamespace('OMEMO_DEVICELIST', Strophe.NS.OMEMO+".devicelist");
......
...@@ -13,7 +13,7 @@ import muc from "@converse/headless/converse-muc"; ...@@ -13,7 +13,7 @@ import muc from "@converse/headless/converse-muc";
import tpl_rooms_list from "templates/rooms_list.html"; import tpl_rooms_list from "templates/rooms_list.html";
import tpl_rooms_list_item from "templates/rooms_list_item.html" import tpl_rooms_list_item from "templates/rooms_list_item.html"
const { Backbone, Promise, Strophe, b64_sha1, sizzle, _ } = converse.env; const { Backbone, Promise, Strophe, sizzle, _ } = converse.env;
const u = converse.env.utils; const u = converse.env.utils;
...@@ -170,7 +170,7 @@ converse.plugins.add('converse-roomslist', { ...@@ -170,7 +170,7 @@ converse.plugins.add('converse-roomslist', {
this.model.on('remove', this.showOrHide, this); this.model.on('remove', this.showOrHide, this);
const storage = _converse.config.get('storage'), const storage = _converse.config.get('storage'),
id = b64_sha1(`converse.roomslist${_converse.bare_jid}`); id = `converse.roomslist${_converse.bare_jid}`;
this.list_model = new _converse.RoomsList({'id': id}); this.list_model = new _converse.RoomsList({'id': id});
this.list_model.browserStorage = new Backbone.BrowserStorage[storage](id); this.list_model.browserStorage = new Backbone.BrowserStorage[storage](id);
...@@ -265,7 +265,7 @@ converse.plugins.add('converse-roomslist', { ...@@ -265,7 +265,7 @@ converse.plugins.add('converse-roomslist', {
const initRoomsListView = function () { const initRoomsListView = function () {
const storage = _converse.config.get('storage'), const storage = _converse.config.get('storage'),
id = b64_sha1(`converse.open-rooms-{_converse.bare_jid}`), id = `converse.open-rooms-{_converse.bare_jid}`,
model = new _converse.OpenRooms(); model = new _converse.OpenRooms();
model.browserStorage = new Backbone.BrowserStorage[storage](id); model.browserStorage = new Backbone.BrowserStorage[storage](id);
......
...@@ -813,7 +813,7 @@ converse.plugins.add('converse-rosterview', { ...@@ -813,7 +813,7 @@ converse.plugins.add('converse-rosterview', {
createRosterFilter () { createRosterFilter () {
// Create a model on which we can store filter properties // Create a model on which we can store filter properties
const model = new _converse.RosterFilter(); const model = new _converse.RosterFilter();
model.id = b64_sha1(`_converse.rosterfilter${_converse.bare_jid}`); model.id = `_converse.rosterfilter${_converse.bare_jid}`;
model.browserStorage = new Backbone.BrowserStorage.local(this.filter.id); model.browserStorage = new Backbone.BrowserStorage.local(this.filter.id);
this.filter_view = new _converse.RosterFilterView({'model': model}); this.filter_view = new _converse.RosterFilterView({'model': model});
this.filter_view.model.on('change', this.updateFilter, this); this.filter_view.model.on('change', this.updateFilter, this);
...@@ -930,7 +930,7 @@ converse.plugins.add('converse-rosterview', { ...@@ -930,7 +930,7 @@ converse.plugins.add('converse-rosterview', {
if (view) { if (view) {
return view.model; return view.model;
} }
return this.model.create({name, id: b64_sha1(name)}); return this.model.create({name, 'id': b64_sha1(name)});
}, },
addContactToGroup (contact, name, options) { addContactToGroup (contact, name, options) {
......
...@@ -367,7 +367,7 @@ function initClientConfig () { ...@@ -367,7 +367,7 @@ function initClientConfig () {
* What this means is that config values need to persist across * What this means is that config values need to persist across
* user sessions. * user sessions.
*/ */
const id = b64_sha1('converse.client-config'); const id = 'converse.client-config';
_converse.config = new Backbone.Model({ _converse.config = new Backbone.Model({
'id': id, 'id': id,
'trusted': _converse.trusted && true || false, 'trusted': _converse.trusted && true || false,
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
import converse from "./converse-core"; import converse from "./converse-core";
import sizzle from "sizzle"; import sizzle from "sizzle";
const { Backbone, Promise, Strophe, $iq, b64_sha1, utils, _, f } = converse.env; const { Backbone, Promise, Strophe, $iq, utils, _, f } = converse.env;
converse.plugins.add('converse-disco', { converse.plugins.add('converse-disco', {
...@@ -36,30 +36,30 @@ converse.plugins.add('converse-disco', { ...@@ -36,30 +36,30 @@ converse.plugins.add('converse-disco', {
this.dataforms = new Backbone.Collection(); this.dataforms = new Backbone.Collection();
this.dataforms.browserStorage = new Backbone.BrowserStorage.session( this.dataforms.browserStorage = new Backbone.BrowserStorage.session(
b64_sha1(`converse.dataforms-${this.get('jid')}`) `converse.dataforms-${this.get('jid')}`
); );
this.features = new Backbone.Collection(); this.features = new Backbone.Collection();
this.features.browserStorage = new Backbone.BrowserStorage.session( this.features.browserStorage = new Backbone.BrowserStorage.session(
b64_sha1(`converse.features-${this.get('jid')}`) `converse.features-${this.get('jid')}`
); );
this.features.on('add', this.onFeatureAdded, this); this.features.on('add', this.onFeatureAdded, this);
this.fields = new Backbone.Collection(); this.fields = new Backbone.Collection();
this.fields.browserStorage = new Backbone.BrowserStorage.session( this.fields.browserStorage = new Backbone.BrowserStorage.session(
b64_sha1(`converse.fields-${this.get('jid')}`) `converse.fields-${this.get('jid')}`
); );
this.fields.on('add', this.onFieldAdded, this); this.fields.on('add', this.onFieldAdded, this);
this.identities = new Backbone.Collection(); this.identities = new Backbone.Collection();
this.identities.browserStorage = new Backbone.BrowserStorage.session( this.identities.browserStorage = new Backbone.BrowserStorage.session(
b64_sha1(`converse.identities-${this.get('jid')}`) `converse.identities-${this.get('jid')}`
); );
this.fetchFeatures(); this.fetchFeatures();
this.items = new _converse.DiscoEntities(); this.items = new _converse.DiscoEntities();
this.items.browserStorage = new Backbone.BrowserStorage.session( this.items.browserStorage = new Backbone.BrowserStorage.session(
b64_sha1(`converse.disco-items-${this.get('jid')}`) `converse.disco-items-${this.get('jid')}`
); );
this.items.fetch(); this.items.fetch();
}, },
...@@ -234,7 +234,7 @@ converse.plugins.add('converse-disco', { ...@@ -234,7 +234,7 @@ converse.plugins.add('converse-disco', {
function initStreamFeatures () { function initStreamFeatures () {
_converse.stream_features = new Backbone.Collection(); _converse.stream_features = new Backbone.Collection();
_converse.stream_features.browserStorage = new Backbone.BrowserStorage.session( _converse.stream_features.browserStorage = new Backbone.BrowserStorage.session(
b64_sha1(`converse.stream-features-${_converse.bare_jid}`) `converse.stream-features-${_converse.bare_jid}`
); );
_converse.stream_features.fetch({ _converse.stream_features.fetch({
success (collection) { success (collection) {
...@@ -259,7 +259,7 @@ converse.plugins.add('converse-disco', { ...@@ -259,7 +259,7 @@ converse.plugins.add('converse-disco', {
_converse.disco_entities = new _converse.DiscoEntities(); _converse.disco_entities = new _converse.DiscoEntities();
_converse.disco_entities.browserStorage = new Backbone.BrowserStorage.session( _converse.disco_entities.browserStorage = new Backbone.BrowserStorage.session(
b64_sha1(`converse.disco-entities-${_converse.bare_jid}`) `converse.disco-entities-${_converse.bare_jid}`
); );
const collection = await _converse.disco_entities.fetchEntities(); const collection = await _converse.disco_entities.fetchEntities();
......
...@@ -196,7 +196,7 @@ converse.plugins.add('converse-muc', { ...@@ -196,7 +196,7 @@ converse.plugins.add('converse-muc', {
this.occupants = new _converse.ChatRoomOccupants(); this.occupants = new _converse.ChatRoomOccupants();
this.occupants.browserStorage = new Backbone.BrowserStorage.session( this.occupants.browserStorage = new Backbone.BrowserStorage.session(
b64_sha1(`converse.occupants-${_converse.bare_jid}${this.get('jid')}`) `converse.occupants-${_converse.bare_jid}${this.get('jid')}`
); );
this.occupants.chatroom = this; this.occupants.chatroom = this;
this.registerHandlers(); this.registerHandlers();
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
import "./converse-disco"; import "./converse-disco";
import converse from "./converse-core"; import converse from "./converse-core";
const { Strophe, Backbone, Promise, $iq, $build, $msg, $pres, b64_sha1, f, moment, _ } = converse.env; const { Strophe, Backbone, Promise, $iq, $build, $msg, $pres, f, moment, _ } = converse.env;
Strophe.addNamespace('PUBSUB_ERROR', Strophe.NS.PUBSUB+"#errors"); Strophe.addNamespace('PUBSUB_ERROR', Strophe.NS.PUBSUB+"#errors");
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
import converse from "@converse/headless/converse-core"; import converse from "@converse/headless/converse-core";
const { Backbone, Promise, Strophe, $iq, $pres, b64_sha1, moment, sizzle, _ } = converse.env; const { Backbone, Promise, Strophe, $iq, $pres, moment, sizzle, _ } = converse.env;
const u = converse.env.utils; const u = converse.env.utils;
...@@ -52,17 +52,17 @@ converse.plugins.add('converse-roster', { ...@@ -52,17 +52,17 @@ converse.plugins.add('converse-roster', {
const storage = _converse.config.get('storage'); const storage = _converse.config.get('storage');
_converse.roster = new _converse.RosterContacts(); _converse.roster = new _converse.RosterContacts();
_converse.roster.browserStorage = new Backbone.BrowserStorage[storage]( _converse.roster.browserStorage = new Backbone.BrowserStorage[storage](
b64_sha1(`converse.contacts-${_converse.bare_jid}`)); `converse.contacts-${_converse.bare_jid}`);
_converse.roster.data = new Backbone.Model(); _converse.roster.data = new Backbone.Model();
const id = b64_sha1(`converse-roster-model-${_converse.bare_jid}`); const id = `converse-roster-model-${_converse.bare_jid}`;
_converse.roster.data.id = id; _converse.roster.data.id = id;
_converse.roster.data.browserStorage = new Backbone.BrowserStorage[storage](id); _converse.roster.data.browserStorage = new Backbone.BrowserStorage[storage](id);
_converse.roster.data.fetch(); _converse.roster.data.fetch();
_converse.rostergroups = new _converse.RosterGroups(); _converse.rostergroups = new _converse.RosterGroups();
_converse.rostergroups.browserStorage = new Backbone.BrowserStorage[storage]( _converse.rostergroups.browserStorage = new Backbone.BrowserStorage[storage](
b64_sha1(`converse.roster.groups${_converse.bare_jid}`)); `converse.roster.groups${_converse.bare_jid}`);
_converse.emit('rosterInitialized'); _converse.emit('rosterInitialized');
}; };
...@@ -853,7 +853,7 @@ converse.plugins.add('converse-roster', { ...@@ -853,7 +853,7 @@ converse.plugins.add('converse-roster', {
_converse.presences = new _converse.Presences(); _converse.presences = new _converse.Presences();
} }
_converse.presences.browserStorage = _converse.presences.browserStorage =
new Backbone.BrowserStorage.session(b64_sha1(`converse.presences-${_converse.bare_jid}`)); new Backbone.BrowserStorage.session(`converse.presences-${_converse.bare_jid}`);
_converse.presences.fetch(); _converse.presences.fetch();
_converse.emit('presencesInitialized', reconnecting); _converse.emit('presencesInitialized', reconnecting);
}); });
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
import converse from "./converse-core"; import converse from "./converse-core";
import tpl_vcard from "./templates/vcard.html"; import tpl_vcard from "./templates/vcard.html";
const { Backbone, Promise, Strophe, _, $iq, $build, b64_sha1, moment, sizzle } = converse.env; const { Backbone, Promise, Strophe, _, $iq, $build, moment, sizzle } = converse.env;
const u = converse.env.utils; const u = converse.env.utils;
...@@ -123,7 +123,7 @@ converse.plugins.add('converse-vcard', { ...@@ -123,7 +123,7 @@ converse.plugins.add('converse-vcard', {
/* Event handlers */ /* Event handlers */
_converse.initVCardCollection = function () { _converse.initVCardCollection = function () {
_converse.vcards = new _converse.VCards(); _converse.vcards = new _converse.VCards();
const id = b64_sha1(`${_converse.bare_jid}-converse.vcards`); const id = `${_converse.bare_jid}-converse.vcards`;
_converse.vcards.browserStorage = new Backbone.BrowserStorage[_converse.config.get('storage')](id); _converse.vcards.browserStorage = new Backbone.BrowserStorage[_converse.config.get('storage')](id);
_converse.vcards.fetch(); _converse.vcards.fetch();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment