|
|
@ -440,6 +440,7 @@ define([
|
|
|
|
if (e) { return void cb({error: e}); }
|
|
|
|
if (e) { return void cb({error: e}); }
|
|
|
|
|
|
|
|
|
|
|
|
store.rpc = call;
|
|
|
|
store.rpc = call;
|
|
|
|
|
|
|
|
store.onRpcReadyEvt.fire();
|
|
|
|
|
|
|
|
|
|
|
|
Store.getPinLimit(null, null, function (obj) {
|
|
|
|
Store.getPinLimit(null, null, function (obj) {
|
|
|
|
if (obj.error) { console.error(obj.error); }
|
|
|
|
if (obj.error) { console.error(obj.error); }
|
|
|
@ -1598,6 +1599,50 @@ define([
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Store.onRejected = function (allowed, _cb) {
|
|
|
|
|
|
|
|
var cb = Util.once(Util.mkAsync(_cb));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// There is an allow list: check if we can authenticate
|
|
|
|
|
|
|
|
if (!Array.isArray(allowed)) { return void cb('EINVAL'); }
|
|
|
|
|
|
|
|
if (!store.loggedIn || !store.proxy.edPublic) { return void cb('EFORBIDDEN'); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var teamModule = store.modules['team'];
|
|
|
|
|
|
|
|
var teams = (teamModule && teamModule.getTeams()) || [];
|
|
|
|
|
|
|
|
var _store;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (allowed.indexOf(store.proxy.edPublic) !== -1) {
|
|
|
|
|
|
|
|
// We are allowed: use our own rpc
|
|
|
|
|
|
|
|
_store = store;
|
|
|
|
|
|
|
|
} else if (teams.some(function (teamId) {
|
|
|
|
|
|
|
|
// We're not allowed: check our teams
|
|
|
|
|
|
|
|
var ed = Util.find(store, ['proxy', 'teams', teamId, 'keys', 'drive', 'edPublic']);
|
|
|
|
|
|
|
|
if (allowed.indexOf(ed) === -1) { return false; }
|
|
|
|
|
|
|
|
// This team is allowed: use its rpc
|
|
|
|
|
|
|
|
var t = teamModule.getTeam(teamId);
|
|
|
|
|
|
|
|
_store = t;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
})) {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var auth = function () {
|
|
|
|
|
|
|
|
var rpc = _store.rpc;
|
|
|
|
|
|
|
|
if (!rpc) { return void cb('EFORBIDDEN'); }
|
|
|
|
|
|
|
|
rpc.send('COOKIE', '', function (err) {
|
|
|
|
|
|
|
|
cb(err);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Wait for the RPC we need to be ready and then tyr to authenticate
|
|
|
|
|
|
|
|
if (_store.onRpcReadyEvt) {
|
|
|
|
|
|
|
|
_store.onRpcReadyEvt.reg(function () {
|
|
|
|
|
|
|
|
auth();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Fall back to the old system in case onRpcReadyEvt doesn't exist (shouldn't happen)
|
|
|
|
|
|
|
|
auth();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Store.joinPad = function (clientId, data) {
|
|
|
|
Store.joinPad = function (clientId, data) {
|
|
|
|
if (data.versionHash) {
|
|
|
|
if (data.versionHash) {
|
|
|
|
return void getVersionHash(clientId, data);
|
|
|
|
return void getVersionHash(clientId, data);
|
|
|
@ -1701,37 +1746,7 @@ define([
|
|
|
|
},
|
|
|
|
},
|
|
|
|
onError: onError,
|
|
|
|
onError: onError,
|
|
|
|
onChannelError: onError,
|
|
|
|
onChannelError: onError,
|
|
|
|
onRejected: function (allowed, _cb) {
|
|
|
|
onRejected: Store.onRejected,
|
|
|
|
var cb = Util.once(Util.mkAsync(_cb));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// There is an allow list: check if we can authenticate
|
|
|
|
|
|
|
|
if (!Array.isArray(allowed)) { return void cb('EINVAL'); }
|
|
|
|
|
|
|
|
if (!store.loggedIn || !store.proxy.edPublic) { return void cb('EFORBIDDEN'); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onReadyEvt.reg(function () {
|
|
|
|
|
|
|
|
var rpc;
|
|
|
|
|
|
|
|
var teamModule = store.modules['team'];
|
|
|
|
|
|
|
|
var teams = (teamModule && teamModule.getTeams()) || [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (allowed.indexOf(store.proxy.edPublic) !== -1) {
|
|
|
|
|
|
|
|
// We are allowed: use our own rpc
|
|
|
|
|
|
|
|
rpc = store.rpc;
|
|
|
|
|
|
|
|
} else if (teams.some(function (teamId) {
|
|
|
|
|
|
|
|
// We're not allowed: check our teams
|
|
|
|
|
|
|
|
var ed = Util.find(store, ['proxy', 'teams', teamId, 'keys', 'drive', 'edPublic']);
|
|
|
|
|
|
|
|
if (allowed.indexOf(ed) === -1) { return false; }
|
|
|
|
|
|
|
|
// This team is allowed: use its rpc
|
|
|
|
|
|
|
|
var t = teamModule.getTeam(teamId);
|
|
|
|
|
|
|
|
rpc = t.rpc;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
})) {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!rpc) { return void cb('EFORBIDDEN'); }
|
|
|
|
|
|
|
|
rpc.send('COOKIE', '', function (err) {
|
|
|
|
|
|
|
|
cb(err);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
onConnectionChange: function (info) {
|
|
|
|
onConnectionChange: function (info) {
|
|
|
|
if (!info.state) {
|
|
|
|
if (!info.state) {
|
|
|
|
channel.bcast("PAD_DISCONNECT");
|
|
|
|
channel.bcast("PAD_DISCONNECT");
|
|
|
@ -2589,7 +2604,7 @@ define([
|
|
|
|
progress: 100*obj.progress/obj.max
|
|
|
|
progress: 100*obj.progress/obj.max
|
|
|
|
};
|
|
|
|
};
|
|
|
|
postMessage(clientId, 'LOADING_DRIVE', data);
|
|
|
|
postMessage(clientId, 'LOADING_DRIVE', data);
|
|
|
|
});
|
|
|
|
}, true);
|
|
|
|
}).nThen(function (waitFor) {
|
|
|
|
}).nThen(function (waitFor) {
|
|
|
|
loadUniversal(Team, 'team', waitFor, clientId);
|
|
|
|
loadUniversal(Team, 'team', waitFor, clientId);
|
|
|
|
}).nThen(function () {
|
|
|
|
}).nThen(function () {
|
|
|
@ -2782,6 +2797,7 @@ define([
|
|
|
|
var rt = window.rt = Listmap.create(listmapConfig);
|
|
|
|
var rt = window.rt = Listmap.create(listmapConfig);
|
|
|
|
store.driveSecret = secret;
|
|
|
|
store.driveSecret = secret;
|
|
|
|
store.proxy = rt.proxy;
|
|
|
|
store.proxy = rt.proxy;
|
|
|
|
|
|
|
|
store.onRpcReadyEvt = Util.mkEvent(true);
|
|
|
|
store.loggedIn = typeof(data.userHash) !== "undefined";
|
|
|
|
store.loggedIn = typeof(data.userHash) !== "undefined";
|
|
|
|
|
|
|
|
|
|
|
|
var returned = {};
|
|
|
|
var returned = {};
|
|
|
|