Stop using sessionStorage in CryptPad
parent
9f96b737e7
commit
733db7d39f
|
@ -1,9 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html class="cp">
|
||||
<head>
|
||||
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
|
||||
<script data-bootload="main.js" data-main="/common/boot.js" src="/bower_components/requirejs/require.js"></script>
|
||||
</head>
|
||||
<body class="html">
|
||||
</body>
|
||||
</html>
|
193
www/auth/main.js
193
www/auth/main.js
|
@ -1,193 +0,0 @@
|
|||
define([
|
||||
'jquery',
|
||||
'/api/config',
|
||||
'/common/cryptget.js',
|
||||
'/common/pinpad.js',
|
||||
'/common/common-constants.js',
|
||||
'/common/common-hash.js',
|
||||
'/common/outer/local-store.js',
|
||||
'/common/outer/login-block.js',
|
||||
'/common/outer/network-config.js',
|
||||
'/customize/login.js',
|
||||
'/common/test.js',
|
||||
'/bower_components/nthen/index.js',
|
||||
'/bower_components/netflux-websocket/netflux-client.js',
|
||||
'/bower_components/tweetnacl/nacl-fast.min.js'
|
||||
], function ($, ApiConfig, Crypt, Pinpad, Constants, Hash, LocalStore, Block, NetConfig, Login, Test, nThen, Netflux) {
|
||||
var Nacl = window.nacl;
|
||||
|
||||
var signMsg = function (msg, privKey) {
|
||||
var signKey = Nacl.util.decodeBase64(privKey);
|
||||
var buffer = Nacl.util.decodeUTF8(msg);
|
||||
return Nacl.util.encodeBase64(Nacl.sign(buffer, signKey));
|
||||
};
|
||||
|
||||
// TODO: Allow authing for any domain as long as the user clicks an "accept" button
|
||||
// inside of the iframe.
|
||||
var AUTHORIZED_DOMAINS = [
|
||||
/\.cryptpad\.fr$/,
|
||||
/^http(s)?:\/\/localhost\:/
|
||||
];
|
||||
|
||||
// Safari is weird about localStorage in iframes but seems to let sessionStorage slide.
|
||||
localStorage[Constants.userHashKey] = localStorage[Constants.userHashKey] ||
|
||||
sessionStorage[Constants.userHashKey];
|
||||
|
||||
var proxy;
|
||||
var rpc;
|
||||
var network;
|
||||
var rpcError;
|
||||
var contacts = {};
|
||||
|
||||
var loadProxy = function (hash) {
|
||||
nThen(function (waitFor) {
|
||||
var wsUrl = NetConfig.getWebsocketURL();
|
||||
var w = waitFor();
|
||||
Netflux.connect(wsUrl).then(function (_network) {
|
||||
network = _network;
|
||||
w();
|
||||
}, function (err) {
|
||||
rpcError = err;
|
||||
console.error(err);
|
||||
});
|
||||
}).nThen(function (waitFor) {
|
||||
Crypt.get(hash, waitFor(function (err, val) {
|
||||
if (err) {
|
||||
waitFor.abort();
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
var parsed = JSON.parse(val);
|
||||
proxy = parsed;
|
||||
} catch (e) {
|
||||
console.log("Can't parse user drive", e);
|
||||
}
|
||||
}), {
|
||||
network: network
|
||||
});
|
||||
}).nThen(function () {
|
||||
var origin = ApiConfig.fileHost || window.location.origin;
|
||||
// Get contacts and extract their avatar channel and key
|
||||
var getData = function (obj, href) {
|
||||
var parsed = Hash.parsePadUrl(href);
|
||||
if (!parsed || parsed.type !== "file") { return; }
|
||||
var secret = Hash.getSecrets('file', parsed.hash);
|
||||
if (!secret.keys || !secret.channel) { return; }
|
||||
obj.avatarKey = Hash.encodeBase64(secret.keys && secret.keys.cryptKey);
|
||||
obj.avatarSrc = origin + Hash.getBlobPathFromHex(secret.channel);
|
||||
};
|
||||
contacts.teams = proxy.teams || {};
|
||||
contacts.friends = proxy.friends || {};
|
||||
Object.keys(contacts.friends).map(function (key) {
|
||||
var friend = contacts.friends[key];
|
||||
if (!friend) { return; }
|
||||
var ret = {
|
||||
edPublic: friend.edPublic,
|
||||
name: friend.displayName,
|
||||
};
|
||||
getData(ret, friend.avatar);
|
||||
contacts.friends[key] = ret;
|
||||
});
|
||||
Object.keys(contacts.teams).map(function (key) {
|
||||
var team = contacts.teams[key];
|
||||
if (!team) { return; }
|
||||
var avatar = team.metadata && team.metadata.avatar;
|
||||
var ret = {
|
||||
edPublic: team.keys && team.keys.drive && team.keys.drive.edPublic,
|
||||
name: team.metadata && team.metadata.name
|
||||
};
|
||||
getData(ret, avatar);
|
||||
contacts.teams[key] = ret;
|
||||
});
|
||||
contacts.origin = window.location.origin;
|
||||
}).nThen(function (waitFor) {
|
||||
if (!network) { return void waitFor.abort(); }
|
||||
Pinpad.create(network, proxy, waitFor(function (e, call) {
|
||||
if (e) {
|
||||
rpcError = e;
|
||||
return void waitFor.abort();
|
||||
}
|
||||
rpc = call;
|
||||
}));
|
||||
}).nThen(function () {
|
||||
Test(function () {
|
||||
// This is only here to maybe trigger an error.
|
||||
window.drive = proxy['drive'];
|
||||
Test.passed();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
var whenReady = function (cb) {
|
||||
if (proxy && (rpc || rpcError)) { return void cb(); }
|
||||
console.log('CryptPad not ready...');
|
||||
setTimeout(function () {
|
||||
whenReady(cb);
|
||||
}, 100);
|
||||
};
|
||||
|
||||
$(window).on("message", function (jqe) {
|
||||
var evt = jqe.originalEvent;
|
||||
var data = JSON.parse(evt.data);
|
||||
var domain = evt.origin;
|
||||
var srcWindow = evt.source;
|
||||
var ret = { txid: data.txid };
|
||||
console.log('CP receiving', data);
|
||||
if (data.cmd === 'PING') {
|
||||
ret.res = 'PONG';
|
||||
} else if (data.cmd === 'LOGIN') {
|
||||
Login.loginOrRegister(data.data.name, data.data.password, false, false, function (err) {
|
||||
if (err) {
|
||||
ret.error = 'LOGIN_ERROR';
|
||||
srcWindow.postMessage(JSON.stringify(ret), domain);
|
||||
return;
|
||||
}
|
||||
loadProxy(LocalStore.getUserHash());
|
||||
srcWindow.postMessage(JSON.stringify(ret), domain);
|
||||
});
|
||||
return;
|
||||
} else if (data.cmd === 'SIGN') {
|
||||
if (!AUTHORIZED_DOMAINS.filter(function (x) { return x.test(domain); }).length) {
|
||||
ret.error = "UNAUTH_DOMAIN";
|
||||
} else if (!LocalStore.isLoggedIn()) {
|
||||
ret.error = "NOT_LOGGED_IN";
|
||||
} else {
|
||||
return void whenReady(function () {
|
||||
var sig = signMsg(data.data, proxy.edPrivate);
|
||||
ret.res = {
|
||||
uname: proxy.login_name,
|
||||
edPublic: proxy.edPublic,
|
||||
sig: sig
|
||||
};
|
||||
ret.contacts = contacts;
|
||||
srcWindow.postMessage(JSON.stringify(ret), domain);
|
||||
});
|
||||
}
|
||||
} else if (data.cmd === 'UPDATE_LIMIT') {
|
||||
return void whenReady(function () {
|
||||
if (rpcError) {
|
||||
// Tell the user on accounts that there was an issue and they need to wait maximum 24h or contact an admin
|
||||
ret.warning = true;
|
||||
srcWindow.postMessage(JSON.stringify(ret), domain);
|
||||
return;
|
||||
}
|
||||
rpc.updatePinLimits(function (e, limit, plan, note) {
|
||||
if (e) {
|
||||
ret.warning = true;
|
||||
}
|
||||
ret.res = [limit, plan, note];
|
||||
srcWindow.postMessage(JSON.stringify(ret), domain);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
ret.error = "UNKNOWN_CMD";
|
||||
}
|
||||
srcWindow.postMessage(JSON.stringify(ret), domain);
|
||||
});
|
||||
|
||||
var userHash = LocalStore.getUserHash();
|
||||
if (userHash) {
|
||||
loadProxy(userHash);
|
||||
}
|
||||
});
|
|
@ -5,10 +5,6 @@ define(['/customize/application_config.js'], function (AppConfig) {
|
|||
userNameKey: 'User_name',
|
||||
blockHashKey: 'Block_hash',
|
||||
fileHashKey: 'FS_hash',
|
||||
// sessionStorage
|
||||
newPadPathKey: "newPadPath",
|
||||
newPadTeamKey: "newPadTeam",
|
||||
newPadFileData: "newPadFileData",
|
||||
// Store
|
||||
displayNameKey: 'cryptpad.username',
|
||||
oldStorageKey: 'CryptPad_RECENTPADS',
|
||||
|
|
|
@ -55,7 +55,7 @@ define([
|
|||
var addData = function (obj) {
|
||||
obj.ooType = window.location.pathname.replace(/^\//, '').replace(/\/$/, '');
|
||||
obj.ooVersionHash = version;
|
||||
obj.ooForceVersion = localStorage.CryptPad_ooVersion || sessionStorage.CryptPad_ooVersion || "";
|
||||
obj.ooForceVersion = localStorage.CryptPad_ooVersion || "";
|
||||
};
|
||||
var addRpc = function (sframeChan, Cryptpad, Utils) {
|
||||
sframeChan.on('Q_OO_SAVE', function (data, cb) {
|
||||
|
|
|
@ -2730,7 +2730,6 @@ define([
|
|||
* - userHash or anonHash
|
||||
* Todo in cb
|
||||
* - LocalStore.setFSHash if needed
|
||||
* - sessionStorage.User_Hash
|
||||
* - stuff with tokenKey
|
||||
* Event to outer
|
||||
* - requestLogin
|
||||
|
|
|
@ -82,19 +82,6 @@ define([
|
|||
localStorage.setItem(Constants.userNameKey, name);
|
||||
if (cb) { cb(); }
|
||||
};
|
||||
var eraseTempSessionValues = LocalStore.eraseTempSessionValues = function () {
|
||||
// delete sessionStorage values that might have been left over
|
||||
// from the main page's /user redirect
|
||||
[
|
||||
'login',
|
||||
'login_user',
|
||||
'login_pass',
|
||||
'login_rmb',
|
||||
'register'
|
||||
].forEach(function (k) {
|
||||
delete sessionStorage[k];
|
||||
});
|
||||
};
|
||||
var logoutHandlers = [];
|
||||
LocalStore.logout = function (cb, isDeletion) {
|
||||
[
|
||||
|
@ -104,10 +91,8 @@ define([
|
|||
'loginToken',
|
||||
'plan',
|
||||
].forEach(function (k) {
|
||||
sessionStorage.removeItem(k);
|
||||
localStorage.removeItem(k);
|
||||
delete localStorage[k];
|
||||
delete sessionStorage[k];
|
||||
});
|
||||
try {
|
||||
Object.keys(localStorage || {}).forEach(function (k) {
|
||||
|
@ -122,7 +107,6 @@ define([
|
|||
if (!LocalStore.getFSHash()) {
|
||||
LocalStore.setFSHash(Hash.createRandomHash('drive'));
|
||||
}
|
||||
eraseTempSessionValues();
|
||||
|
||||
if (!isDeletion) {
|
||||
logoutHandlers.forEach(function (h) {
|
||||
|
|
|
@ -1,166 +0,0 @@
|
|||
// This file provides the API for the channel for talking to and from the sandbox iframe.
|
||||
define([
|
||||
'/common/sframe-protocol.js',
|
||||
'/common/common-util.js'
|
||||
], function (SFrameProtocol, Util) {
|
||||
|
||||
var mkTxid = function () {
|
||||
return Math.random().toString(16).replace('0.', '') + Math.random().toString(16).replace('0.', '');
|
||||
};
|
||||
|
||||
var create = function (ow, cb, isSandbox, sendData) {
|
||||
var otherWindow;
|
||||
var evReady = Util.mkEvent(true);
|
||||
var handlers = {};
|
||||
var queries = {};
|
||||
|
||||
// list of handlers which are registered from the other side...
|
||||
var insideHandlers = [];
|
||||
var callWhenRegistered = {};
|
||||
|
||||
var chan = {};
|
||||
|
||||
// Send a query. channel.query('Q_SOMETHING', { args: "whatever" }, function (reply) { ... });
|
||||
chan.query = function (q, content, cb, opts) {
|
||||
if (!otherWindow) { throw new Error('not yet initialized'); }
|
||||
if (!SFrameProtocol[q]) {
|
||||
throw new Error('please only make queries are defined in sframe-protocol.js');
|
||||
}
|
||||
opts = opts || {};
|
||||
var txid = mkTxid();
|
||||
var to = opts.timeout || 30000;
|
||||
var timeout = setTimeout(function () {
|
||||
delete queries[txid];
|
||||
console.log("Timeout making query " + q);
|
||||
}, to);
|
||||
queries[txid] = function (data, msg) {
|
||||
clearTimeout(timeout);
|
||||
delete queries[txid];
|
||||
cb(undefined, data.content, msg);
|
||||
};
|
||||
evReady.reg(function () {
|
||||
otherWindow.postMessage(JSON.stringify({
|
||||
txid: txid,
|
||||
content: content,
|
||||
q: q
|
||||
}), '*');
|
||||
});
|
||||
};
|
||||
|
||||
// Fire an event. channel.event('EV_SOMETHING', { args: "whatever" });
|
||||
var event = chan.event = function (e, content) {
|
||||
if (!SFrameProtocol[e]) {
|
||||
throw new Error('please only fire events that are defined in sframe-protocol.js');
|
||||
}
|
||||
if (e.indexOf('EV_') !== 0) {
|
||||
throw new Error('please only use events (starting with EV_) for event messages');
|
||||
}
|
||||
evReady.reg(function () {
|
||||
otherWindow.postMessage(JSON.stringify({ content: content, q: e }), '*');
|
||||
});
|
||||
};
|
||||
|
||||
// Be notified on query or event. channel.on('EV_SOMETHING', function (args, reply) { ... });
|
||||
// If the type is a query, your handler will be invoked with a reply function that takes
|
||||
// one argument (the content to reply with).
|
||||
chan.on = function (queryType, handler, quiet) {
|
||||
if (!SFrameProtocol[queryType]) {
|
||||
throw new Error('please only register handlers which are defined in sframe-protocol.js');
|
||||
}
|
||||
(handlers[queryType] = handlers[queryType] || []).push(function (data, msg) {
|
||||
handler(data.content, function (replyContent) {
|
||||
if (queryType.indexOf('Q_') !== 0) { throw new Error("replies to events are invalid"); }
|
||||
msg.source.postMessage(JSON.stringify({
|
||||
txid: data.txid,
|
||||
content: replyContent
|
||||
}), '*');
|
||||
}, msg);
|
||||
});
|
||||
if (!quiet) {
|
||||
event('EV_REGISTER_HANDLER', queryType);
|
||||
}
|
||||
};
|
||||
|
||||
// If a particular handler is registered, call the callback immediately, otherwise it will be called
|
||||
// when that handler is first registered.
|
||||
// channel.whenReg('Q_SOMETHING', function () { ...query Q_SOMETHING?... });
|
||||
chan.whenReg = function (queryType, cb, always) {
|
||||
if (!SFrameProtocol[queryType]) {
|
||||
throw new Error('please only register handlers which are defined in sframe-protocol.js');
|
||||
}
|
||||
var reg = always;
|
||||
if (insideHandlers.indexOf(queryType) > -1) {
|
||||
cb();
|
||||
} else {
|
||||
reg = true;
|
||||
}
|
||||
if (reg) {
|
||||
(callWhenRegistered[queryType] = callWhenRegistered[queryType] || []).push(cb);
|
||||
}
|
||||
};
|
||||
|
||||
// Same as whenReg except it will invoke every time there is another registration, not just once.
|
||||
chan.onReg = function (queryType, cb) { chan.whenReg(queryType, cb, true); };
|
||||
|
||||
chan.on('EV_REGISTER_HANDLER', function (content) {
|
||||
if (callWhenRegistered[content]) {
|
||||
callWhenRegistered[content].forEach(function (f) { f(); });
|
||||
delete callWhenRegistered[content];
|
||||
}
|
||||
insideHandlers.push(content);
|
||||
});
|
||||
chan.whenReg('EV_REGISTER_HANDLER', evReady.fire);
|
||||
|
||||
// Make sure both iframes are ready
|
||||
var isReady =false;
|
||||
chan.onReady = function (h) {
|
||||
if (isReady) {
|
||||
return void h();
|
||||
}
|
||||
if (typeof(h) !== "function") { return; }
|
||||
chan.on('EV_RPC_READY', function () { isReady = true; h(); });
|
||||
};
|
||||
chan.ready = function () {
|
||||
chan.whenReg('EV_RPC_READY', function () {
|
||||
chan.event('EV_RPC_READY');
|
||||
});
|
||||
};
|
||||
|
||||
var txid;
|
||||
window.addEventListener('message', function (msg) {
|
||||
var data = JSON.parse(msg.data);
|
||||
if (ow !== msg.source) {
|
||||
return;
|
||||
//console.log("DROP Message from unexpected source");
|
||||
//console.log(msg);
|
||||
} else if (!otherWindow) {
|
||||
otherWindow = ow;
|
||||
sendData = sendData || {};
|
||||
sendData.txid = data.txid;
|
||||
ow.postMessage(JSON.stringify(sendData), '*');
|
||||
cb(chan);
|
||||
} else if (typeof(data.q) === 'string' && handlers[data.q]) {
|
||||
handlers[data.q].forEach(function (f) {
|
||||
f(data || JSON.parse(msg.data), msg);
|
||||
data = undefined;
|
||||
});
|
||||
} else if (typeof(data.q) === 'undefined' && queries[data.txid]) {
|
||||
queries[data.txid](data, msg);
|
||||
} else if (data.txid === txid) {
|
||||
// stray message from init
|
||||
return;
|
||||
} else {
|
||||
console.log("DROP Unhandled message");
|
||||
console.log(msg);
|
||||
}
|
||||
});
|
||||
if (isSandbox) {
|
||||
// we're in the sandbox
|
||||
otherWindow = ow;
|
||||
evReady.fire();
|
||||
cb(chan);
|
||||
}
|
||||
};
|
||||
|
||||
return { create: create };
|
||||
});
|
|
@ -1181,15 +1181,6 @@ define([
|
|||
});
|
||||
});
|
||||
|
||||
sframeChan.on('Q_SESSIONSTORAGE_PUT', function (data, cb) {
|
||||
if (typeof (data.value) === "undefined") {
|
||||
delete sessionStorage[data.key];
|
||||
} else {
|
||||
sessionStorage[data.key] = data.value;
|
||||
}
|
||||
cb();
|
||||
});
|
||||
|
||||
sframeChan.on('Q_IS_ONLY_IN_SHARED_FOLDER', function (data, cb) {
|
||||
Cryptpad.isOnlyInSharedFolder(secret.channel, function (err, t) {
|
||||
if (err) { return void cb({error: err}); }
|
||||
|
|
|
@ -462,15 +462,6 @@ define([
|
|||
});
|
||||
};
|
||||
|
||||
funcs.sessionStorage = {
|
||||
put: function (key, value, cb) {
|
||||
ctx.sframeChan.query('Q_SESSIONSTORAGE_PUT', {
|
||||
key: key,
|
||||
value: value
|
||||
}, cb);
|
||||
}
|
||||
};
|
||||
|
||||
funcs.setDisplayName = function (name, cb) {
|
||||
cb = cb || $.noop;
|
||||
ctx.sframeChan.query('Q_SETTINGS_SET_DISPLAY_NAME', name, cb);
|
||||
|
|
|
@ -1,271 +0,0 @@
|
|||
// This file defines all of the RPC calls which are used between the inner and outer iframe.
|
||||
// Define *querys* (which expect a response) using Q_<query name>
|
||||
// Define *events* (which expect no response) using EV_<event name>
|
||||
// Please document the queries and events you create, and please please avoid making generic
|
||||
// "do stuff" events/queries which are used for many different things because it makes the
|
||||
// protocol unclear.
|
||||
//
|
||||
// WARNING: At this point, this protocol is still EXPERIMENTAL. This is not it's final form.
|
||||
// We need to define protocol one piece at a time and then when we are satisfied that we
|
||||
// fully understand the problem, we will define the *right* protocol and this file will be dynomited.
|
||||
//
|
||||
define({
|
||||
// When the iframe first launches, this query is sent repeatedly by the controller
|
||||
// to wait for it to awake and give it the requirejs config to use.
|
||||
'Q_INIT': true,
|
||||
|
||||
// When either the outside or inside registers a query handler, this is sent.
|
||||
'EV_REGISTER_HANDLER': true,
|
||||
|
||||
// When an iframe is ready to receive messages
|
||||
'EV_RPC_READY': true,
|
||||
|
||||
// Realtime events called from the outside.
|
||||
// When someone joins the pad, argument is a string with their netflux id.
|
||||
'EV_RT_JOIN': true,
|
||||
// When someone leaves the pad, argument is a string with their netflux id.
|
||||
'EV_RT_LEAVE': true,
|
||||
// When you have been disconnected, no arguments.
|
||||
'EV_RT_DISCONNECT': true,
|
||||
// When you have connected, argument is an object with myID: string, members: list, readOnly: boolean.
|
||||
'EV_RT_CONNECT': true,
|
||||
// Called after the history is finished synchronizing, no arguments.
|
||||
'EV_RT_READY': true,
|
||||
// Called when the server returns an error in a pad (EEXPIRED, EDELETED).
|
||||
'EV_RT_ERROR': true,
|
||||
// Called from both outside and inside, argument is a (string) chainpad message.
|
||||
'Q_RT_MESSAGE': true,
|
||||
|
||||
// Called from the outside, this informs the inside whenever the user's data has been changed.
|
||||
// The argument is the object representing the content of the user profile minus the netfluxID
|
||||
// which changes per-reconnect.
|
||||
'EV_METADATA_UPDATE': true,
|
||||
|
||||
// Takes one argument only, the title to set for the CURRENT pad which the user is looking at.
|
||||
// This changes the pad title in drive ONLY, the pad title needs to be changed inside of the
|
||||
// iframe and synchronized with the other users. This will not trigger a EV_METADATA_UPDATE
|
||||
// because the metadata contained in EV_METADATA_UPDATE does not contain the pad title.
|
||||
// It also sets the page (tab) title to the selected title, unles it is overridden by
|
||||
// the EV_SET_TAB_TITLE event.
|
||||
'Q_SET_PAD_TITLE_IN_DRIVE': true,
|
||||
// Set the page title (tab title) to the selected value which will override the pad title.
|
||||
// The new title value can contain {title}, which will be replaced by the pad title when it
|
||||
// is set or modified.
|
||||
'EV_SET_TAB_TITLE': true,
|
||||
|
||||
// Update the user's display-name which will be shown to contacts and people in the same pads.
|
||||
'Q_SETTINGS_SET_DISPLAY_NAME': true,
|
||||
|
||||
// Log the user out in all the tabs
|
||||
'Q_LOGOUT': true,
|
||||
// Tell the user that he has been logged out from outside (probably from another tab)
|
||||
'EV_LOGOUT': true,
|
||||
|
||||
// When moving to the login or register page from a pad, we need to redirect to that pad at the
|
||||
// end of the login process. This query set the current href to the sessionStorage.
|
||||
'Q_SET_LOGIN_REDIRECT': true,
|
||||
|
||||
// Store the editing or readonly link of the current pad to the clipboard (share button).
|
||||
'Q_STORE_LINK_TO_CLIPBOARD': true,
|
||||
|
||||
// Use anonymous rpc from inside the iframe (for avatars & pin usage).
|
||||
'Q_ANON_RPC_MESSAGE': true,
|
||||
|
||||
// Get the user's pin limit, usage and plan
|
||||
'Q_PIN_GET_USAGE': true,
|
||||
|
||||
// Write/update the login block when the account password is changed
|
||||
'Q_WRITE_LOGIN_BLOCK': true,
|
||||
|
||||
// Remove login blocks
|
||||
'Q_REMOVE_LOGIN_BLOCK': true,
|
||||
|
||||
// Check the pin limit to determine if we can store the pad in the drive or if we should.
|
||||
// display a warning
|
||||
'Q_GET_PIN_LIMIT_STATUS': true,
|
||||
|
||||
// Move a pad to the trash when using the forget button.
|
||||
'Q_MOVE_TO_TRASH': true,
|
||||
|
||||
// Request the full history from the server when the users clicks on the history button.
|
||||
// Callback is called when the FULL_HISTORY_END message is received in the outside.
|
||||
'Q_GET_FULL_HISTORY': true,
|
||||
'Q_GET_HISTORY_RANGE': true,
|
||||
// When a (full) history message is received from the server.
|
||||
'EV_RT_HIST_MESSAGE': true,
|
||||
|
||||
// Save a pad as a template using the toolbar button
|
||||
'Q_SAVE_AS_TEMPLATE': true,
|
||||
|
||||
// Friend requests from the userlist
|
||||
'Q_SEND_FRIEND_REQUEST': true, // Up query
|
||||
'Q_INCOMING_FRIEND_REQUEST': true, // Down query
|
||||
'EV_FRIEND_REQUEST': true, // Down event when the request is complete
|
||||
|
||||
// Set the tab notification when the content of the pad changes
|
||||
'EV_NOTIFY': true,
|
||||
|
||||
// Send the new settings to the inner iframe when they are changed in the proxy
|
||||
'EV_SETTINGS_UPDATE': true,
|
||||
|
||||
// Get and set (pad) attributes stored in the drive from the inner iframe
|
||||
'Q_GET_ATTRIBUTE': true,
|
||||
'Q_SET_ATTRIBUTE': true,
|
||||
'Q_GET_PAD_ATTRIBUTE': true,
|
||||
'Q_SET_PAD_ATTRIBUTE': true,
|
||||
|
||||
// Check if a pad is only in a shared folder or (also) in the main drive.
|
||||
// This allows us to change the behavior of some buttons (trash icon...)
|
||||
'Q_IS_ONLY_IN_SHARED_FOLDER': true,
|
||||
|
||||
// Open/close the File picker (sent from the iframe to the outside)
|
||||
'EV_FILE_PICKER_OPEN': true,
|
||||
'EV_FILE_PICKER_CLOSE': true,
|
||||
'EV_FILE_PICKER_REFRESH': true,
|
||||
// File selected in the file picker: sent from the filepicker iframe to the outside
|
||||
// and then send to the inner iframe
|
||||
'EV_FILE_PICKED': true,
|
||||
|
||||
// Get all the files from the drive to display them in a file picker secure app
|
||||
'Q_GET_FILES_LIST': true,
|
||||
|
||||
// Template picked, replace the content of the pad
|
||||
'Q_TEMPLATE_USE': true,
|
||||
// Check if we have template(s) for the selected pad type
|
||||
'Q_TEMPLATE_EXIST': true,
|
||||
|
||||
// File upload queries and events
|
||||
'Q_UPLOAD_FILE': true,
|
||||
'EV_FILE_UPLOAD_STATE': true,
|
||||
'Q_CANCEL_PENDING_FILE_UPLOAD': true,
|
||||
|
||||
// Make the browser window navigate to a given URL, if no URL is passed then it will reload.
|
||||
'EV_GOTO_URL': true,
|
||||
// Make the parent window open a given URL in a new tab. It allows us to keep sessionStorage
|
||||
// form the parent window.
|
||||
'EV_OPEN_URL': true,
|
||||
|
||||
// Present mode URL
|
||||
'Q_PRESENT_URL_GET_VALUE': true,
|
||||
'EV_PRESENT_URL_SET_VALUE': true,
|
||||
|
||||
// Put one or more entries to the cache which will go in localStorage.
|
||||
// Cache is wiped after each new release
|
||||
'EV_CACHE_PUT': true,
|
||||
|
||||
// Chat
|
||||
'EV_CHAT_EVENT': true,
|
||||
'Q_CHAT_COMMAND': true,
|
||||
'Q_CHAT_OPENPADCHAT': true,
|
||||
|
||||
// Cursor
|
||||
'EV_CURSOR_EVENT': true,
|
||||
'Q_CURSOR_COMMAND': true,
|
||||
'Q_CURSOR_OPENCHANNEL': true,
|
||||
|
||||
// Put one or more entries to the localStore which will go in localStorage.
|
||||
'EV_LOCALSTORE_PUT': true,
|
||||
// Put one entry in the parent sessionStorage
|
||||
'Q_SESSIONSTORAGE_PUT': true,
|
||||
|
||||
// Merge the anonymous drive (FS_hash) into the current logged in user's drive, to keep the pads
|
||||
// in the drive at registration.
|
||||
'Q_MERGE_ANON_DRIVE': true,
|
||||
|
||||
// Add or remove the avatar from the profile.
|
||||
// We have to pin/unpin the avatar and store/remove the value from the user object
|
||||
'Q_PROFILE_AVATAR_ADD': true,
|
||||
'Q_PROFILE_AVATAR_REMOVE': true,
|
||||
|
||||
// Store outside and get thumbnails inside (stored with localForage (indexedDB) outside)
|
||||
'Q_THUMBNAIL_SET': true,
|
||||
'Q_THUMBNAIL_GET': true,
|
||||
|
||||
// Settings app only
|
||||
// Clear all thumbnails
|
||||
'Q_THUMBNAIL_CLEAR': true,
|
||||
// Backup and restore a drive
|
||||
'Q_SETTINGS_DRIVE_GET': true,
|
||||
'Q_SETTINGS_DRIVE_SET': true,
|
||||
'Q_SETTINGS_DRIVE_RESET': true,
|
||||
// Logout from all the devices where the account is logged in
|
||||
'Q_SETTINGS_LOGOUT': true,
|
||||
// Import pads from this computer's anon session into the current user account
|
||||
'Q_SETTINGS_IMPORT_LOCAL': true,
|
||||
'Q_SETTINGS_DELETE_ACCOUNT': true,
|
||||
|
||||
// Store the language selected in the iframe into localStorage outside
|
||||
'Q_LANGUAGE_SET': true,
|
||||
|
||||
// Anonymous users can empty their drive and remove FS_hash from localStorage
|
||||
'EV_BURN_ANON_DRIVE': true,
|
||||
// Inner drive needs to send command and receive updates from the async store
|
||||
'Q_DRIVE_USEROBJECT': true,
|
||||
'Q_DRIVE_GETOBJECT': true,
|
||||
'Q_DRIVE_RESTORE': true,
|
||||
// Get the pads deleted from the server by other users to remove them from the drive
|
||||
'Q_DRIVE_GETDELETED': true,
|
||||
// Store's userObject need to send log messages to inner to display them in the UI
|
||||
'EV_DRIVE_LOG': true,
|
||||
// Refresh the drive when the drive has changed ('change' or 'remove' events)
|
||||
'EV_DRIVE_CHANGE': true,
|
||||
'EV_DRIVE_REMOVE': true,
|
||||
// Set shared folder hash in the address bar
|
||||
'EV_DRIVE_SET_HASH': true,
|
||||
|
||||
// Remove an owned pad from the server
|
||||
'Q_REMOVE_OWNED_CHANNEL': true,
|
||||
// Clear an owned pad from the server (preserve metadata)
|
||||
'Q_CLEAR_OWNED_CHANNEL': true,
|
||||
|
||||
// Notifications about connection and disconnection from the network
|
||||
'EV_NETWORK_DISCONNECT': true,
|
||||
'EV_NETWORK_RECONNECT': true,
|
||||
// Reload on new version
|
||||
'EV_NEW_VERSION': true,
|
||||
|
||||
// Pad creation screen: create a pad with the selected attributes (owned, expire)
|
||||
'Q_CREATE_PAD': true,
|
||||
// Get the available templates
|
||||
'Q_CREATE_TEMPLATES': true,
|
||||
|
||||
// This is for sending data out of the iframe when we are in testing mode
|
||||
// The exact protocol is defined in common/test.js
|
||||
'EV_TESTDATA': true,
|
||||
|
||||
// OnlyOffice: save a new version
|
||||
'Q_OO_SAVE': true,
|
||||
|
||||
// Ask for the pad password when a pad is protected
|
||||
'EV_PAD_PASSWORD': true,
|
||||
'Q_PAD_PASSWORD_VALUE': true,
|
||||
// Change pad password
|
||||
'Q_PAD_PASSWORD_CHANGE': true,
|
||||
|
||||
// Migrate drive to owned drive
|
||||
'Q_CHANGE_USER_PASSWORD': true,
|
||||
|
||||
// Loading events to display in the loading screen
|
||||
'EV_LOADING_INFO': true,
|
||||
// Critical error outside the iframe during loading screen
|
||||
'EV_LOADING_ERROR': true,
|
||||
|
||||
// Chrome 68 bug...
|
||||
'EV_CHROME_68': true,
|
||||
|
||||
// Get all existing tags
|
||||
'Q_GET_ALL_TAGS': true,
|
||||
|
||||
// Store pads in the drive
|
||||
'EV_AUTOSTORE_DISPLAY_POPUP': true,
|
||||
'Q_AUTOSTORE_STORE': true,
|
||||
'Q_IS_PAD_STORED': true,
|
||||
|
||||
// Import mediatag from a pad
|
||||
'Q_IMPORT_MEDIATAG': true,
|
||||
|
||||
// Ability to get a pad's content from its hash
|
||||
'Q_CRYPTGET': true,
|
||||
'EV_CRYPTGET_DISCONNECT': true,
|
||||
|
||||
});
|
|
@ -67,10 +67,8 @@ define([
|
|||
});
|
||||
});
|
||||
$('#register').on('click', function () {
|
||||
if (sessionStorage) {
|
||||
if ($uname.val()) {
|
||||
sessionStorage.login_user = $uname.val();
|
||||
}
|
||||
if ($uname.val()) {
|
||||
localStorage.login_user = $uname.val();
|
||||
}
|
||||
window.location.href = '/register/';
|
||||
});
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
define(['/bower_components/localforage/dist/localforage.min.js'], function (localForage) {
|
||||
localForage.clear();
|
||||
sessionStorage.clear();
|
||||
localStorage.clear();
|
||||
});
|
||||
|
|
|
@ -37,9 +37,9 @@ define([
|
|||
var $passwd = $('#password');
|
||||
var $confirm = $('#password-confirm');
|
||||
|
||||
if (sessionStorage.login_user) {
|
||||
delete sessionStorage.login_user;
|
||||
$uname.val(sessionStorage.login_user);
|
||||
if (localStorage.login_user) {
|
||||
$uname.val(localStorage.login_user);
|
||||
delete loginStorage.login_user;
|
||||
}
|
||||
|
||||
[ $uname, $passwd, $confirm]
|
||||
|
|
Loading…
Reference in New Issue