Permalink
Browse files

Comprehensive namespace cleanup.

  • Loading branch information...
gschmidt authored and glasser committed Jul 20, 2013
1 parent 556f6aa commit 3d1c09794f7d87c136dac5ab33ab6cf7b4f9e049
Showing with 913 additions and 644 deletions.
  1. +11 −7 packages/accounts-base/accounts_client.js
  2. +2 −0 packages/accounts-base/accounts_common.js
  3. +6 −4 packages/accounts-base/accounts_server.js
  4. +2 −1 packages/accounts-base/localstorage_token.js
  5. +3 −0 packages/accounts-base/package.js
  6. +1 −0 packages/accounts-facebook/facebook_client.js
  7. +1 −0 packages/accounts-github/github_client.js
  8. +1 −0 packages/accounts-google/google_client.js
  9. +1 −0 packages/accounts-meetup/meetup_client.js
  10. +4 −4 packages/accounts-password/email_tests_setup.js
  11. +3 −1 packages/accounts-password/package.js
  12. +6 −5 packages/accounts-password/password_client.js
  13. +9 −9 packages/accounts-password/password_server.js
  14. +1 −0 packages/accounts-twitter/twitter_client.js
  15. +1 −0 packages/accounts-weibo/weibo_client.js
  16. +2 −2 packages/appcache/appcache-client.js
  17. +1 −1 packages/audit-argument-checks/audit_argument_checks.js
  18. +1 −1 packages/autopublish/autopublish.js
  19. +1 −1 packages/ctl-helper/ctl-helper.js
  20. +3 −0 packages/deps/deps.js
  21. +9 −2 packages/ejson/base64.js
  22. +6 −6 packages/ejson/base64_test.js
  23. +17 −7 packages/ejson/ejson.js
  24. +34 −8 packages/email/email.js
  25. +3 −5 packages/email/email_tests.js
  26. +6 −8 packages/http/httpcall_client.js
  27. +14 −11 packages/http/httpcall_common.js
  28. +10 −9 packages/http/httpcall_server.js
  29. +1 −0 packages/less/package.js
  30. +28 −11 packages/livedata/client_convenience.js
  31. +4 −3 packages/livedata/crossbar.js
  32. +5 −5 packages/livedata/crossbar_tests.js
  33. +15 −41 packages/livedata/livedata_common.js
  34. +36 −32 packages/livedata/livedata_connection.js
  35. +38 −39 packages/livedata/livedata_connection_tests.js
  36. +73 −55 packages/livedata/livedata_server.js
  37. +10 −11 packages/livedata/livedata_tests.js
  38. +3 −2 packages/livedata/package.js
  39. +24 −14 packages/livedata/server_convenience.js
  40. +1 −1 packages/livedata/session_view_tests.js
  41. +14 −13 packages/livedata/stream_client_common.js
  42. +3 −3 packages/livedata/stream_client_nodejs.js
  43. +3 −4 packages/livedata/stream_client_sockjs.js
  44. +2 −2 packages/livedata/stream_server.js
  45. +2 −2 packages/livedata/stream_tests.js
  46. +7 −3 packages/livedata/writefence.js
  47. +3 −0 packages/localstorage/localstorage.js
  48. +0 −2 packages/logging/package.js
  49. +6 −5 packages/meteor/client_environment.js
  50. +4 −0 packages/{logging → meteor}/debug.js
  51. 0 packages/{logging → meteor}/debug_test.js
  52. +2 −0 packages/meteor/dynamics_browser.js
  53. +3 −0 packages/meteor/dynamics_nodejs.js
  54. +44 −0 packages/meteor/errors.js
  55. +5 −0 packages/meteor/fiber_helpers.js
  56. +4 −0 packages/meteor/fiber_stubs_client.js
  57. +12 −2 packages/meteor/helpers.js
  58. +5 −0 packages/meteor/package.js
  59. +6 −5 packages/meteor/server_environment.js
  60. +1 −0 packages/meteor/setimmediate.js
  61. +1 −0 packages/{startup → meteor}/startup_client.js
  62. +1 −0 packages/{startup → meteor}/startup_server.js
  63. +9 −3 packages/meteor/timers.js
  64. +2 −0 packages/meteor/url_common.js
  65. +6 −7 packages/minimongo/minimongo.js
  66. +1 −1 packages/minimongo/selector.js
  67. +12 −11 packages/mongo-livedata/collection.js
  68. +3 −4 packages/mongo-livedata/local_collection_driver.js
  69. +39 −33 packages/mongo-livedata/mongo_driver.js
  70. +10 −9 packages/mongo-livedata/mongo_livedata_tests.js
  71. +2 −1 packages/mongo-livedata/observe_changes_tests.js
  72. +3 −2 packages/mongo-livedata/package.js
  73. +6 −7 packages/mongo-livedata/remote_collection_driver.js
  74. +1 −0 packages/past/package.js
  75. +22 −0 packages/past/past.js
  76. +1 −2 packages/preserve-inputs/preserve-inputs.js
  77. +6 −1 packages/reactive-dict/reactive-dict.js
  78. +9 −5 packages/reload/reload.js
  79. +1 −0 packages/service-configuration/package.js
  80. +5 −4 packages/session/package.js
  81. +4 −4 packages/session/session.js
  82. +2 −0 packages/spark/convenience.js
  83. +15 −13 packages/spark/patch.js
  84. +2 −2 packages/spark/patch_tests.js
  85. +95 −61 packages/spark/spark.js
  86. +19 −19 packages/spark/spark_tests.js
  87. +1 −0 packages/spark/utils.js
  88. +1 −1 packages/spiderable/spiderable.js
  89. +1 −3 packages/srp/biginteger.js
  90. +1 −3 packages/srp/sha256.js
  91. +38 −38 packages/srp/srp.js
  92. +12 −12 packages/srp/srp_tests.js
  93. +5 −3 packages/startup/package.js
  94. +1 −0 packages/stylus/package.js
  95. +13 −12 packages/templating/deftemplate.js
  96. +2 −2 packages/templating/plugin/html_scanner.js
  97. +2 −2 packages/templating/scanner_tests.js
  98. +1 −1 packages/templating/templating_tests.js
  99. +3 −6 packages/test-helpers/stub_stream.js
  100. +5 −5 packages/test-in-browser/driver.js
  101. +1 −0 packages/test-in-browser/package.js
  102. +1 −1 packages/test-in-console/driver.js
  103. +1 −0 packages/tinytest/package.js
  104. +13 −10 packages/tinytest/tinytest.js
  105. +6 −4 packages/tinytest/tinytest_client.js
  106. +1 −1 packages/tinytest/tinytest_server.js
  107. +3 −3 packages/webapp/webapp_server.js
  108. +1 −1 tools/packages.js
@@ -3,8 +3,9 @@
///
// This is reactive.
+// @export Meteor.userId
Meteor.userId = function () {
- return Meteor.default_connection.userId();
+ return Meteor.connection.userId();
};
var loggingIn = false;
@@ -18,12 +19,14 @@ Accounts._setLoggingIn = function (x) {
loggingInDeps.changed();
}
};
+// @export Meteor.loggingIn
Meteor.loggingIn = function () {
loggingInDeps.depend();
return loggingIn;
};
// This calls userId, which is reactive.
+// @export Meteor.user
Meteor.user = function () {
var userId = Meteor.userId();
if (!userId)
@@ -45,7 +48,7 @@ Meteor.user = function () {
// - Updating the Meteor.loggingIn() reactive data source
// - Calling the method in 'wait' mode
// - On success, saving the resume token to localStorage
-// - On success, calling Meteor.default_connection.setUserId()
+// - On success, calling Meteor.connection.setUserId()
// - Setting up an onReconnect handler which logs in with
// the resume token
//
@@ -88,9 +91,9 @@ Accounts.callLoginMethod = function (options) {
// will occur before the callback from the resume login call.)
var onResultReceived = function (err, result) {
if (err || !result || !result.token) {
- Meteor.default_connection.onReconnect = null;
+ Meteor.connection.onReconnect = null;
} else {
- Meteor.default_connection.onReconnect = function() {
+ Meteor.connection.onReconnect = function() {
reconnected = true;
Accounts.callLoginMethod({
methodArguments: [{resume: result.token}],
@@ -153,15 +156,16 @@ Accounts.callLoginMethod = function (options) {
Accounts._makeClientLoggedOut = function() {
Accounts._unstoreLoginToken();
- Meteor.default_connection.setUserId(null);
- Meteor.default_connection.onReconnect = null;
+ Meteor.connection.setUserId(null);
+ Meteor.connection.onReconnect = null;
};
Accounts._makeClientLoggedIn = function(userId, token) {
Accounts._storeLoginToken(userId, token);
- Meteor.default_connection.setUserId(userId);
+ Meteor.connection.setUserId(userId);
};
+// @export Meteor.logout
Meteor.logout = function (callback) {
Meteor.apply('logout', [], {wait: true}, function(error, result) {
if (error) {
@@ -45,6 +45,8 @@ Accounts.config = function(options) {
// Users table. Don't use the normal autopublish, since we want to hide
// some fields. Code to autopublish this is in accounts_server.js.
// XXX Allow users to configure this collection name.
+//
+// @export Meteor.users
Meteor.users = new Meteor.Collection("users", {_preventAutopublish: true});
// There is an allow call in accounts_server that restricts this
// collection.
@@ -2,6 +2,7 @@
/// CURRENT USER
///
+// @export Meteor.userId
Meteor.userId = function () {
// This function only works if called inside a method. In theory, it
// could also be called from publish statements, since they also
@@ -12,12 +13,13 @@ Meteor.userId = function () {
// user expects. The way to make this work in a publish is to do
// Meteor.find(this.userId()).observe and recompute when the user
// record changes.
- var currentInvocation = Meteor._CurrentInvocation.get();
+ var currentInvocation = DDP._CurrentInvocation.get();
if (!currentInvocation)
throw new Error("Meteor.userId can only be invoked in method calls. Use this.userId in publish functions.");
return currentInvocation.userId;
};
+// @export Meteor.user
Meteor.user = function () {
var userId = Meteor.userId();
if (!userId)
@@ -324,15 +326,15 @@ Accounts.addAutopublishFields = function(opts) {
Accounts._autopublishFields.otherUsers, opts.forOtherUsers);
};
-Meteor.default_server.onAutopublish(function () {
+Meteor.server.onAutopublish(function () {
// ['profile', 'username'] -> {profile: 1, username: 1}
var toFieldSelector = function(fields) {
return _.object(_.map(fields, function(field) {
return [field, 1];
}));
};
- Meteor.default_server.publish(null, function () {
+ Meteor.server.publish(null, function () {
if (this.userId) {
return Meteor.users.find(
{_id: this.userId},
@@ -348,7 +350,7 @@ Meteor.default_server.onAutopublish(function () {
// is changed (eg someone logging in). If this is a problem, we can
// instead write a manual publish function which filters out fields
// based on 'this.userId'.
- Meteor.default_server.publish(null, function () {
+ Meteor.server.publish(null, function () {
var selector;
if (this.userId)
selector = {_id: {$ne: this.userId}};
@@ -5,6 +5,7 @@
// Login with a Meteor access token. This is the only public function
// here.
+// @export Meteor.loginWithToken
Meteor.loginWithToken = function (token, callback) {
Accounts.callLoginMethod({
methodArguments: [{resume: token}],
@@ -74,7 +75,7 @@ if (!Accounts._preventAutoLogin) {
// On startup, optimistically present us as logged in while the
// request is in flight. This reduces page flicker on startup.
var userId = Accounts._storedUserId();
- userId && Meteor.default_connection.setUserId(userId);
+ userId && Meteor.connection.setUserId(userId);
Meteor.loginWithToken(token, function (err) {
if (err) {
Meteor._debug("Error logging in with token: " + err);
@@ -11,6 +11,9 @@ Package.on_use(function (api) {
api.use('random', ['client', 'server']);
api.use('service-configuration', ['client', 'server']);
+ // needed for getting the currently logged-in user
+ api.use('livedata', ['client', 'server']);
+
// need this because of the Meteor.users collection but in the future
// we'd probably want to abstract this away
api.use('mongo-livedata', ['client', 'server']);
@@ -1,3 +1,4 @@
+// @export Meteor.loginWithFacebook
Meteor.loginWithFacebook = function(options, callback) {
// support a callback without options
if (! callback && typeof options === "function") {
@@ -1,3 +1,4 @@
+// @export Meteor.loginWithGithub
Meteor.loginWithGithub = function(options, callback) {
// support a callback without options
if (! callback && typeof options === "function") {
@@ -1,3 +1,4 @@
+// @export Meteor.loginWithGoogle
Meteor.loginWithGoogle = function(options, callback) {
// support a callback without options
if (! callback && typeof options === "function") {
@@ -1,3 +1,4 @@
+// @export Meteor.loginWithMeetup
Meteor.loginWithMeetup = function(options, callback) {
// support a callback without options
if (! callback && typeof options === "function") {
@@ -3,20 +3,20 @@
// the string "intercept", storing them in an array that can then
// be retrieved using the getInterceptedEmails method
//
-var oldEmailSend = Email.send;
var interceptedEmails = {}; // (email address) -> (array of contents)
-Email.send = function (options) {
+Email._hookSend(function (options) {
var to = options.to;
if (to.indexOf('intercept') === -1) {
- oldEmailSend(options);
+ return true; // go ahead and send
} else {
if (!interceptedEmails[to])
interceptedEmails[to] = [];
interceptedEmails[to].push(options.text);
+ return false; // skip sending
}
-};
+});
Meteor.methods({
getInterceptedEmails: function (email) {
@@ -11,6 +11,7 @@ Package.on_use(function(api) {
api.use('random', ['server']);
api.use('check', ['server']);
api.use('underscore');
+ api.use('livedata', ['client', 'server']);
api.add_files('email_templates.js', 'server');
api.add_files('password_server.js', 'server');
@@ -20,7 +21,8 @@ Package.on_use(function(api) {
Package.on_test(function(api) {
api.use(['accounts-password', 'tinytest', 'test-helpers', 'deps',
- 'accounts-base', 'random', 'email', 'underscore', 'check']);
+ 'accounts-base', 'random', 'email', 'underscore', 'check',
+ 'livedata']);
api.add_files('password_tests_setup.js', 'server');
api.add_files('password_tests.js', ['client', 'server']);
api.add_files('email_tests_setup.js', 'server');
@@ -1,5 +1,6 @@
// Attempt to log in with a password.
//
+// @export Meteor.loginWithPassword
// @param selector {String|Object} One of the following:
// - {username: (username)}
// - {email: (email)}
@@ -8,7 +9,7 @@
// @param password {String}
// @param callback {Function(error|undefined)}
Meteor.loginWithPassword = function (selector, password, callback) {
- var srp = new Meteor._srp.Client(password);
+ var srp = new SRP.Client(password);
var request = srp.startExchange();
if (typeof selector === 'string')
@@ -50,7 +51,7 @@ Accounts.createUser = function (options, callback) {
if (!options.password)
throw new Error("Must set options.password");
- var verifier = Meteor._srp.generateVerifier(options.password);
+ var verifier = SRP.generateVerifier(options.password);
// strip old password, replacing with the verifier object
delete options.password;
options.srp = verifier;
@@ -77,7 +78,7 @@ Accounts.changePassword = function (oldPassword, newPassword, callback) {
return;
}
- var verifier = Meteor._srp.generateVerifier(newPassword);
+ var verifier = SRP.generateVerifier(newPassword);
if (!oldPassword) {
Meteor.apply('changePassword', [{srp: verifier}], function (error, result) {
@@ -89,7 +90,7 @@ Accounts.changePassword = function (oldPassword, newPassword, callback) {
}
});
} else { // oldPassword
- var srp = new Meteor._srp.Client(oldPassword);
+ var srp = new SRP.Client(oldPassword);
var request = srp.startExchange();
request.user = {id: Meteor.user()._id};
Meteor.apply('beginPasswordExchange', [request], function (error, result) {
@@ -142,7 +143,7 @@ Accounts.resetPassword = function(token, newPassword, callback) {
if (!newPassword)
throw new Error("Need to pass newPassword");
- var verifier = Meteor._srp.generateVerifier(newPassword);
+ var verifier = SRP.generateVerifier(newPassword);
Accounts.callLoginMethod({
methodName: 'resetPassword',
methodArguments: [token, verifier],
@@ -62,7 +62,7 @@ Meteor.methods({beginPasswordExchange: function (request) {
throw new Meteor.Error(403, "User has no password set");
var verifier = user.services.password.srp;
- var srp = new Meteor._srp.Server(verifier);
+ var srp = new SRP.Server(verifier);
var challenge = srp.issueChallenge({A: request.A});
// save off results in the current session so we can verify them
@@ -82,7 +82,7 @@ Accounts.registerLoginHandler(function (options) {
// we're always called from within a 'login' method, so this should
// be safe.
- var currentInvocation = Meteor._CurrentInvocation.get();
+ var currentInvocation = DDP._CurrentInvocation.get();
var serialized = currentInvocation._sessionData.srpChallenge;
if (!serialized || serialized.M !== options.srp.M)
throw new Meteor.Error(403, "Incorrect password");
@@ -127,7 +127,7 @@ Accounts.registerLoginHandler(function (options) {
// Just check the verifier output when the same identity and salt
// are passed. Don't bother with a full exchange.
var verifier = user.services.password.srp;
- var newVerifier = Meteor._srp.generateVerifier(options.password, {
+ var newVerifier = SRP.generateVerifier(options.password, {
identity: verifier.identity, salt: verifier.salt});
if (verifier.verifier !== newVerifier.verifier)
@@ -155,7 +155,7 @@ Meteor.methods({changePassword: function (options) {
// password. For now, we don't allow changePassword without knowing the old
// password.
M: String,
- srp: Match.Optional(Meteor._srp.matchVerifier),
+ srp: Match.Optional(SRP.matchVerifier),
password: Match.Optional(String)
});
@@ -170,7 +170,7 @@ Meteor.methods({changePassword: function (options) {
var verifier = options.srp;
if (!verifier && options.password) {
- verifier = Meteor._srp.generateVerifier(options.password);
+ verifier = SRP.generateVerifier(options.password);
}
if (!verifier)
throw new Meteor.Error(400, "Invalid verifier");
@@ -192,7 +192,7 @@ Accounts.setPassword = function (userId, newPassword) {
var user = Meteor.users.findOne(userId);
if (!user)
throw new Meteor.Error(403, "User not found");
- var newVerifier = Meteor._srp.generateVerifier(newPassword);
+ var newVerifier = SRP.generateVerifier(newPassword);
Meteor.users.update({_id: user._id}, {
$set: {'services.password.srp': newVerifier}});
@@ -293,7 +293,7 @@ Accounts.sendEnrollmentEmail = function (userId, email) {
// the users password, and log them in.
Meteor.methods({resetPassword: function (token, newVerifier) {
check(token, String);
- check(newVerifier, Meteor._srp.matchVerifier);
+ check(newVerifier, SRP.matchVerifier);
var user = Meteor.users.findOne({
"services.password.reset.token": ""+token});
@@ -428,7 +428,7 @@ var createUser = function (options) {
username: Match.Optional(String),
email: Match.Optional(String),
password: Match.Optional(String),
- srp: Match.Optional(Meteor._srp.matchVerifier)
+ srp: Match.Optional(SRP.matchVerifier)
}));
var username = options.username;
@@ -442,7 +442,7 @@ var createUser = function (options) {
if (options.password) {
if (options.srp)
throw new Meteor.Error(400, "Don't pass both password and srp in options");
- options.srp = Meteor._srp.generateVerifier(options.password);
+ options.srp = SRP.generateVerifier(options.password);
}
var user = {services: {}};
@@ -1,3 +1,4 @@
+// @export Meteor.loginWithTwitter
Meteor.loginWithTwitter = function(options, callback) {
// support a callback without options
if (! callback && typeof options === "function") {
@@ -1,3 +1,4 @@
+// @export Meteor.loginWithWeibo
Meteor.loginWithWeibo = function(options, callback) {
// support a callback without options
if (! callback && typeof options === "function") {
@@ -13,7 +13,7 @@ var updatingAppcache = false;
var reloadRetry = null;
var appcacheUpdated = false;
-Meteor._reload.onMigrate('appcache', function(retry) {
+Reload._onMigrate('appcache', function(retry) {
if (appcacheUpdated)
return [true];
@@ -61,7 +61,7 @@ window.applicationCache.addEventListener('obsolete', (function() {
}
else {
appcacheUpdated = true;
- Meteor._reload.reload();
+ Reload._reload();
}
}), false);
@@ -1 +1 @@
-Meteor._LivedataServer._auditArgumentChecks = true;
+DDP._setAuditArgumentChecks(true);
@@ -1 +1 @@
-Meteor.default_server.autopublish();
+Meteor.server.autopublish();
@@ -43,7 +43,7 @@ _.extend(Ctl, {
process.exit(1);
}
- return Meteor.connect(process.env['GALAXY']);
+ return DDP.connect(process.env['GALAXY']);
}),
jobsCollection: _.once(function () {
View
@@ -1,3 +1,6 @@
+// We have to export Deps as a single symbol since we want to be able
+// to change Deps.active later.
+//
// @export Deps
Deps = {};
Deps.active = false;
Oops, something went wrong.

0 comments on commit 3d1c097

Please sign in to comment.