diff --git a/apps/meteor/packages/accounts-linkedin/package.js b/apps/meteor/packages/accounts-linkedin/package.js index 1f20ca1624b63..a3078932a0b28 100644 --- a/apps/meteor/packages/accounts-linkedin/package.js +++ b/apps/meteor/packages/accounts-linkedin/package.js @@ -6,6 +6,7 @@ Package.describe({ }); Package.onUse((api) => { + api.versionsFrom('2.5'); api.use('ecmascript'); api.use('accounts-base', ['client', 'server']); api.imply('accounts-base', ['client', 'server']); diff --git a/apps/meteor/packages/autoupdate/autoupdate_client.js b/apps/meteor/packages/autoupdate/autoupdate_client.js index dfd924c7f1cf1..36202d32bc5f1 100644 --- a/apps/meteor/packages/autoupdate/autoupdate_client.js +++ b/apps/meteor/packages/autoupdate/autoupdate_client.js @@ -25,27 +25,37 @@ // The client version of the client code currently running in the // browser. -import { ClientVersions } from './client_versions.js'; +import { ClientVersions } from "./client_versions.js"; -const clientArch = Meteor.isCordova ? 'web.cordova' : Meteor.isModern ? 'web.browser' : 'web.browser.legacy'; +const clientArch = Meteor.isCordova ? "web.cordova" : + Meteor.isModern ? "web.browser" : "web.browser.legacy"; -const autoupdateVersions = ((__meteor_runtime_config__.autoupdate || {}).versions || {})[clientArch] || { - version: 'unknown', - versionRefreshable: 'unknown', - versionNonRefreshable: 'unknown', - assets: [], -}; +const autoupdateVersions = + ((__meteor_runtime_config__.autoupdate || {}).versions || {})[clientArch] || { + version: "unknown", + versionRefreshable: "unknown", + versionNonRefreshable: "unknown", + assets: [], + }; export const Autoupdate = {}; // Stores acceptable client versions. -const clientVersions = (Autoupdate._clientVersions = // Used by a self-test and hot-module-replacement - new ClientVersions()); +const clientVersions = + Autoupdate._clientVersions = // Used by a self-test and hot-module-replacement + new ClientVersions(); -Meteor.connection.registerStoreClient('meteor_autoupdate_clientVersions', clientVersions.createStore()); +Meteor.connection.registerStore( + "meteor_autoupdate_clientVersions", + clientVersions.createStore() +); Autoupdate.newClientAvailable = function () { - return clientVersions.newClientAvailable(clientArch, ['versionRefreshable', 'versionNonRefreshable'], autoupdateVersions); + return clientVersions.newClientAvailable( + clientArch, + ["versionRefreshable", "versionNonRefreshable"], + autoupdateVersions + ); }; // Set to true if the link.onload callback ever fires for any node. @@ -61,15 +71,15 @@ const retry = new Retry({ // server fixing code will result in a restart and reconnect, but // potentially the subscription could have a transient error. minCount: 0, // don't do any immediate retries - baseTimeout: 30 * 1000, // start with 30s + baseTimeout: 30*1000 // start with 30s }); let failures = 0; Autoupdate._retrySubscription = () => { - Meteor.subscribe('meteor_autoupdate_clientVersions', { + Meteor.subscribe("meteor_autoupdate_clientVersions", { onError(error) { - Meteor._debug('autoupdate subscription failed', error); + Meteor._debug("autoupdate subscription failed", error); failures++; retry.retryLater(failures, function () { // Just retry making the subscription, don't reload the whole @@ -101,7 +111,8 @@ Autoupdate._retrySubscription = () => { return; } - if (doc.versionNonRefreshable !== autoupdateVersions.versionNonRefreshable) { + if (doc.versionNonRefreshable !== + autoupdateVersions.versionNonRefreshable) { // Non-refreshable assets have changed, so we have to reload the // whole page rather than just replacing tags. if (stop) stop(); @@ -110,13 +121,7 @@ Autoupdate._retrySubscription = () => { // is provided by the ddp package that autoupdate depends on. // Delay reload in 60 seconds - console.warn( - 'Client version changed from', - autoupdateVersions.versionNonRefreshable, - 'to', - doc.versionNonRefreshable, - `Page will reload in ${reloadDelayInSeconds} seconds`, - ); + console.warn('Client version changed from', autoupdateVersions.versionNonRefreshable, 'to', doc.versionNonRefreshable, `Page will reload in ${reloadDelayInSeconds} seconds`); setTimeout(() => { Package.reload.Reload._reload(); }, reloadDelayInSeconds * 1000); @@ -132,27 +137,30 @@ Autoupdate._retrySubscription = () => { var newCss = doc.assets || []; var oldLinks = []; - Array.prototype.forEach.call(document.getElementsByTagName('link'), function (link) { - if (link.className === '__meteor-css__') { - oldLinks.push(link); + Array.prototype.forEach.call( + document.getElementsByTagName('link'), + function (link) { + if (link.className === '__meteor-css__') { + oldLinks.push(link); + } } - }); + ); function waitUntilCssLoads(link, callback) { var called; link.onload = function () { knownToSupportCssOnLoad = true; - if (!called) { + if (! called) { called = true; callback(); } }; - if (!knownToSupportCssOnLoad) { + if (! knownToSupportCssOnLoad) { var id = Meteor.setInterval(function () { if (link.sheet) { - if (!called) { + if (! called) { called = true; callback(); } @@ -164,26 +172,27 @@ Autoupdate._retrySubscription = () => { let newLinksLeftToLoad = newCss.length; function removeOldLinks() { - if (oldLinks.length > 0 && --newLinksLeftToLoad < 1) { - oldLinks.splice(0).forEach((link) => { + if (oldLinks.length > 0 && + --newLinksLeftToLoad < 1) { + oldLinks.splice(0).forEach(link => { link.parentNode.removeChild(link); }); } } if (newCss.length > 0) { - newCss.forEach((css) => { - const newLink = document.createElement('link'); - newLink.setAttribute('rel', 'stylesheet'); - newLink.setAttribute('type', 'text/css'); - newLink.setAttribute('class', '__meteor-css__'); - newLink.setAttribute('href', css.url); + newCss.forEach(css => { + const newLink = document.createElement("link"); + newLink.setAttribute("rel", "stylesheet"); + newLink.setAttribute("type", "text/css"); + newLink.setAttribute("class", "__meteor-css__"); + newLink.setAttribute("href", css.url); waitUntilCssLoads(newLink, function () { Meteor.setTimeout(removeOldLinks, 200); }); - const head = document.getElementsByTagName('head').item(0); + const head = document.getElementsByTagName("head").item(0); head.appendChild(newLink); }); } else { @@ -191,7 +200,7 @@ Autoupdate._retrySubscription = () => { } } } - }, + } }); }; diff --git a/apps/meteor/packages/autoupdate/autoupdate_server.js b/apps/meteor/packages/autoupdate/autoupdate_server.js index cbf9998d9dc99..a1d468490bfaf 100644 --- a/apps/meteor/packages/autoupdate/autoupdate_server.js +++ b/apps/meteor/packages/autoupdate/autoupdate_server.js @@ -25,17 +25,18 @@ // The ID of each document is the client architecture, and the fields of // the document are the versions described above. -import { ClientVersions } from './client_versions.js'; +import { ClientVersions } from "./client_versions.js"; +var Future = Npm.require("fibers/future"); -export const Autoupdate = (__meteor_runtime_config__.autoupdate = { +export const Autoupdate = __meteor_runtime_config__.autoupdate = { // Map from client architectures (web.browser, web.browser.legacy, // web.cordova) to version fields { version, versionRefreshable, // versionNonRefreshable, refreshable } that will be stored in // ClientVersions documents (whose IDs are client architectures). This // data gets serialized into the boilerplate because it's stored in // __meteor_runtime_config__.autoupdate.versions. - versions: {}, -}); + versions: {} +}; // Stores acceptable client versions. const clientVersions = new ClientVersions(); @@ -52,37 +53,41 @@ Autoupdate.autoupdateVersionRefreshable = null; Autoupdate.autoupdateVersionCordova = null; Autoupdate.appId = __meteor_runtime_config__.appId = process.env.APP_ID; -var syncQueue = new Meteor._AsynchronousQueue(); +var syncQueue = new Meteor._SynchronousQueue(); -async function updateVersions(shouldReloadClientProgram) { +function updateVersions(shouldReloadClientProgram) { // Step 1: load the current client program on the server if (shouldReloadClientProgram) { - await WebAppInternals.reloadClientPrograms(); + WebAppInternals.reloadClientPrograms(); } const { // If the AUTOUPDATE_VERSION environment variable is defined, it takes // precedence, but Autoupdate.autoupdateVersion is still supported as // a fallback. In most cases neither of these values will be defined. - AUTOUPDATE_VERSION = Autoupdate.autoupdateVersion, + AUTOUPDATE_VERSION = Autoupdate.autoupdateVersion } = process.env; // Step 2: update __meteor_runtime_config__.autoupdate.versions. const clientArchs = Object.keys(WebApp.clientPrograms); - clientArchs.forEach((arch) => { + clientArchs.forEach(arch => { Autoupdate.versions[arch] = { - version: AUTOUPDATE_VERSION || WebApp.calculateClientHash(arch), - versionRefreshable: AUTOUPDATE_VERSION || WebApp.calculateClientHashRefreshable(arch), - versionNonRefreshable: AUTOUPDATE_VERSION || WebApp.calculateClientHashNonRefreshable(arch), - versionReplaceable: AUTOUPDATE_VERSION || WebApp.calculateClientHashReplaceable(arch), - versionHmr: WebApp.clientPrograms[arch].hmrVersion, + version: AUTOUPDATE_VERSION || + WebApp.calculateClientHash(arch), + versionRefreshable: AUTOUPDATE_VERSION || + WebApp.calculateClientHashRefreshable(arch), + versionNonRefreshable: AUTOUPDATE_VERSION || + WebApp.calculateClientHashNonRefreshable(arch), + versionReplaceable: AUTOUPDATE_VERSION || + WebApp.calculateClientHashReplaceable(arch), + versionHmr: WebApp.clientPrograms[arch].hmrVersion }; }); // Step 3: form the new client boilerplate which contains the updated // assets and __meteor_runtime_config__. if (shouldReloadClientProgram) { - await WebAppInternals.generateBoilerplate(); + WebAppInternals.generateBoilerplate(); } // Step 4: update the ClientVersions collection. @@ -90,7 +95,7 @@ async function updateVersions(shouldReloadClientProgram) { // `WebApp.getRefreshableAssets`, which is only set after // `WebApp.generateBoilerplate` is called by `main` in webapp. WebApp.onListening(() => { - clientArchs.forEach((arch) => { + clientArchs.forEach(arch => { const payload = { ...Autoupdate.versions[arch], assets: WebApp.getRefreshableAssets(arch), @@ -102,7 +107,7 @@ async function updateVersions(shouldReloadClientProgram) { } Meteor.publish( - 'meteor_autoupdate_clientVersions', + "meteor_autoupdate_clientVersions", function (appId) { // `null` happens when a client doesn't have an appId and passes // `undefined` to `Meteor.subscribe`. `undefined` is translated to @@ -111,77 +116,67 @@ Meteor.publish( // Don't notify clients using wrong appId such as mobile apps built with a // different server but pointing at the same local url - if (Autoupdate.appId && appId && Autoupdate.appId !== appId) return []; + if (Autoupdate.appId && appId && Autoupdate.appId !== appId) + return []; // Random value to delay the updates for 2-10 minutes const randomInterval = Meteor.isProduction ? (Math.floor(Math.random() * 8) + 2) * 1000 * 60 : 0; const stop = clientVersions.watch((version, isNew) => { setTimeout(() => { - (isNew ? this.added : this.changed).call(this, 'meteor_autoupdate_clientVersions', version._id, version); + (isNew ? this.added : this.changed) + .call(this, "meteor_autoupdate_clientVersions", version._id, version) }, randomInterval); }); this.onStop(() => stop()); this.ready(); }, - { is_auto: true }, + {is_auto: true} ); -Meteor.startup(async function () { - await updateVersions(false); +Meteor.startup(function () { + updateVersions(false); // Force any connected clients that are still looking for these older // document IDs to reload. - ['version', 'version-refreshable', 'version-cordova'].forEach((_id) => { + ["version", + "version-refreshable", + "version-cordova", + ].forEach(_id => { clientVersions.set(_id, { - version: 'outdated', + version: "outdated" }); }); }); -function enqueueVersionsRefresh() { - syncQueue.queueTask(async function () { - await updateVersions(true); - }); -} - -const setupListeners = () => { - // Listen for messages pertaining to the client-refresh topic. - import { onMessage } from 'meteor/inter-process-messaging'; - onMessage('client-refresh', enqueueVersionsRefresh); - - // Another way to tell the process to refresh: send SIGHUP signal - process.on( - 'SIGHUP', - Meteor.bindEnvironment(function () { - enqueueVersionsRefresh(); - }, 'handling SIGHUP signal for refresh'), - ); -}; +var fut = new Future(); -if (Meteor._isFibersEnabled) { - var Future = Npm.require('fibers/future'); +// We only want 'refresh' to trigger 'updateVersions' AFTER onListen, +// so we add a queued task that waits for onListen before 'refresh' can queue +// tasks. Note that the `onListening` callbacks do not fire until after +// Meteor.startup, so there is no concern that the 'updateVersions' calls from +// 'refresh' will overlap with the `updateVersions` call from Meteor.startup. - var fut = new Future(); +syncQueue.queueTask(function () { + fut.wait(); +}); - // We only want 'refresh' to trigger 'updateVersions' AFTER onListen, - // so we add a queued task that waits for onListen before 'refresh' can queue - // tasks. Note that the `onListening` callbacks do not fire until after - // Meteor.startup, so there is no concern that the 'updateVersions' calls from - // 'refresh' will overlap with the `updateVersions` call from Meteor.startup. +WebApp.onListening(function () { + fut.return(); +}); +function enqueueVersionsRefresh() { syncQueue.queueTask(function () { - fut.wait(); + updateVersions(true); }); +} - WebApp.onListening(function () { - fut.return(); - }); +// Listen for messages pertaining to the client-refresh topic. +import { onMessage } from "meteor/inter-process-messaging"; +onMessage("client-refresh", enqueueVersionsRefresh); - setupListeners(); -} else { - WebApp.onListening(function () { - Promise.resolve(setupListeners()); - }); -} +// Another way to tell the process to refresh: send SIGHUP signal +process.on('SIGHUP', Meteor.bindEnvironment(function () { + enqueueVersionsRefresh(); +}, "handling SIGHUP signal for refresh")); diff --git a/apps/meteor/packages/autoupdate/package.js b/apps/meteor/packages/autoupdate/package.js index fa3ace41c6a1b..a7ad595e06926 100644 --- a/apps/meteor/packages/autoupdate/package.js +++ b/apps/meteor/packages/autoupdate/package.js @@ -1,10 +1,9 @@ Package.describe({ - name: 'autoupdate', summary: 'Update the client when new client code is available', version: '1.8.0', }); -Package.onUse(function (api) { +Package.onUse(function(api) { api.use(['webapp', 'check', 'inter-process-messaging'], 'server'); api.use(['tracker', 'retry'], 'client'); diff --git a/apps/meteor/packages/flow-router/.npm/package/npm-shrinkwrap.json b/apps/meteor/packages/flow-router/.npm/package/npm-shrinkwrap.json index f07096a8f3474..8110d45c9f30c 100644 --- a/apps/meteor/packages/flow-router/.npm/package/npm-shrinkwrap.json +++ b/apps/meteor/packages/flow-router/.npm/package/npm-shrinkwrap.json @@ -1,20 +1,23 @@ { "lockfileVersion": 1, "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==" - }, "page": { - "version": "1.6.4", - "resolved": "https://github.com/kadirahq/page.js/archive/34ddf45ea8e4c37269ce3df456b44fc0efc595c6.tar.gz", - "integrity": "sha512-BGG5XDCSYGI4C/pGoYdGIIU1YpEYdCYN2HxwuKpYLgIDdT+tlqRs4IOQTJLTRnXKbt9r07Cucj0Y6fTGZcYizw==" - }, - "path-to-regexp": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.2.1.tgz", - "integrity": "sha512-DBw9IhWfevR2zCVwEZURTuQNseCvu/Q9f5ZgqMCK0Rh61bDa4uyjPAOy9b55yKiPT59zZn+7uYKxmWwsguInwg==" + "version": "https://github.com/kadirahq/page.js/archive/34ddf45ea8e4c37269ce3df456b44fc0efc595c6.tar.gz", + "integrity": "sha512-BGG5XDCSYGI4C/pGoYdGIIU1YpEYdCYN2HxwuKpYLgIDdT+tlqRs4IOQTJLTRnXKbt9r07Cucj0Y6fTGZcYizw==", + "dependencies": { + "path-to-regexp": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.2.1.tgz", + "integrity": "sha512-DBw9IhWfevR2zCVwEZURTuQNseCvu/Q9f5ZgqMCK0Rh61bDa4uyjPAOy9b55yKiPT59zZn+7uYKxmWwsguInwg==", + "dependencies": { + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==" + } + } + } + } }, "qs": { "version": "5.2.0", diff --git a/apps/meteor/packages/linkedin-oauth/package.js b/apps/meteor/packages/linkedin-oauth/package.js index ed7b37ae1cd45..314734066248a 100644 --- a/apps/meteor/packages/linkedin-oauth/package.js +++ b/apps/meteor/packages/linkedin-oauth/package.js @@ -7,6 +7,7 @@ Package.describe({ }); Package.onUse((api) => { + api.versionsFrom('2.5'); api.use('ecmascript'); api.use('oauth2', ['client', 'server']); api.use('oauth', ['client', 'server']); diff --git a/apps/meteor/packages/meteor-restivus/package.js b/apps/meteor/packages/meteor-restivus/package.js index 1f2856270ea95..e6e433d866b3c 100644 --- a/apps/meteor/packages/meteor-restivus/package.js +++ b/apps/meteor/packages/meteor-restivus/package.js @@ -6,6 +6,9 @@ Package.describe({ }); Package.onUse(function (api) { + // Minimum Meteor version + api.versionsFrom('2.5'); + // Meteor dependencies api.use('check'); api.use('webapp'); diff --git a/apps/meteor/packages/meteor-run-as-user/lib/collection.overwrites.js b/apps/meteor/packages/meteor-run-as-user/lib/collection.overwrites.js index 9ea5b18a2d08c..01603673d4c7b 100644 --- a/apps/meteor/packages/meteor-run-as-user/lib/collection.overwrites.js +++ b/apps/meteor/packages/meteor-run-as-user/lib/collection.overwrites.js @@ -7,40 +7,48 @@ // This will allow us to run the modifiers inside of a "Meteor.runAsUser" with // security checks. _.each(['insert', 'update', 'remove'], function (method) { - var _super = Mongo.Collection.prototype[method]; - - Mongo.Collection.prototype[method] = function (/* arguments */) { - var self = this; - var args = _.toArray(arguments); - - // Check if this method is run in restricted mode and collection is - // restricted. - if (Meteor.isRestricted() && self._restricted) { - var generatedId = null; - if (method === 'insert' && !_.has(args[0], '_id')) { - generatedId = self._makeNewID(); - } - - // short circuit if there is no way it will pass. - if (self._validators[method].allow.length === 0) { - throw new Meteor.Error(403, 'Access denied. No allow validators set on restricted ' + "collection for method '" + method + "'."); - } - - var validatedMethodName = '_validated' + method.charAt(0).toUpperCase() + method.slice(1); - args.unshift(Meteor.userId()); - - if (method === 'insert') { - args.push(generatedId); - - self[validatedMethodName].apply(self, args); - // xxx: for now we return the id since self._validatedInsert doesn't - // yet return the new id - return generatedId || args[0]._id; - } - - return self[validatedMethodName].apply(self, args); - } - - return _super.apply(self, args); - }; + + var _super = Mongo.Collection.prototype[method]; + + Mongo.Collection.prototype[method] = function ( /* arguments */ ) { + var self = this; + var args = _.toArray(arguments); + + // Check if this method is run in restricted mode and collection is + // restricted. + if (Meteor.isRestricted() && self._restricted) { + + var generatedId = null; + if (method === 'insert' && !_.has(args[0], '_id')) { + generatedId = self._makeNewID(); + } + + // short circuit if there is no way it will pass. + if (self._validators[method].allow.length === 0) { + throw new Meteor.Error( + 403, 'Access denied. No allow validators set on restricted ' + + 'collection for method \'' + method + '\'.'); + } + + var validatedMethodName = + '_validated' + method.charAt(0).toUpperCase() + method.slice(1); + args.unshift(Meteor.userId()); + + if (method === 'insert') { + args.push(generatedId); + + self[validatedMethodName].apply(self, args); + // xxx: for now we return the id since self._validatedInsert doesn't + // yet return the new id + return generatedId || args[0]._id; + + } + + return self[validatedMethodName].apply(self, args); + + } + + return _super.apply(self, args); + }; + }); diff --git a/apps/meteor/packages/meteor-user-presence/package.js b/apps/meteor/packages/meteor-user-presence/package.js index 700c67cdf7374..96950704caa73 100644 --- a/apps/meteor/packages/meteor-user-presence/package.js +++ b/apps/meteor/packages/meteor-user-presence/package.js @@ -6,6 +6,8 @@ Package.describe({ }); Package.onUse(function (api) { + api.versionsFrom('1.0.2.1'); + api.use('tracker'); api.use('check'); api.use('ecmascript');