{"version":3,"sources":["meteor://💻app/packages/webapp/webapp_server.js","meteor://💻app/packages/webapp/connect.js","meteor://💻app/packages/webapp/socket_file.js"],"names":["module1","module","export","WebApp","WebAppInternals","assert","link","default","v","readFileSync","createServer","pathJoin","pathDirname","join","dirname","parseUrl","parse","createHash","connect","compress","cookieParser","query","parseRequest","basicAuth","lookupUserAgent","lookup","isModern","send","removeExistingSocketFile","registerSocketFileCleanup","onMessage","SHORT_SOCKET_TIMEOUT","LONG_SOCKET_TIMEOUT","hasOwn","Object","prototype","hasOwnProperty","NpmModules","version","Npm","require","defaultArch","clientPrograms","archPath","bundledJsCssUrlRewriteHook","url","bundledPrefix","__meteor_runtime_config__","ROOT_URL_PATH_PREFIX","sha1","contents","hash","update","digest","shouldCompress","req","res","headers","filter","camelCase","name","parts","split","toLowerCase","i","length","charAt","toUpperCase","substr","identifyBrowser","userAgentString","userAgent","family","major","minor","patch","categorizeRequest","_","extend","browser","pick","htmlAttributeHooks","getHtmlAttributes","request","combinedAttributes","each","hook","attributes","Error","addHtmlAttributeHook","push","appUrl","RoutePolicy","classify","Meteor","startup","getter","key","arch","program","value","calculateClientHash","clientHash","calculateClientHashRefreshable","calculateClientHashNonRefreshable","getRefreshableAssets","_timeoutAdjustmentRequestCallback","setTimeout","finishListeners","listeners","removeAllListeners","on","l","boilerplateByArch","boilerplateDataCallbacks","create","registerBoilerplateDataCallback","callback","previousCallback","strictEqual","getBoilerplate","getBoilerplateAsync","await","boilerplate","data","assign","baseData","htmlAttributes","madeChanges","promise","Promise","resolve","keys","forEach","then","result","stream","toHTMLStream","statusCode","generateBoilerplateInstance","manifest","additionalOptions","runtimeConfig","clone","runtimeConfigOverrides","Boilerplate","pathMapper","itemPath","baseDataExtension","additionalStaticJs","map","pathname","meteorRuntimeConfig","JSON","stringify","encodeURIComponent","rootUrlPathPrefix","sriMode","inlineScriptsAllowed","inline","staticFilesMiddleware","staticFilesByArch","next","method","decodeURIComponent","e","serveStaticJs","s","writeHead","write","end","has","path","getArchAndPath","paused","info","getStaticFileInfo","maxAge","cacheable","setHeader","sourceMapUrl","type","content","absolutePath","maxage","dotfiles","lastModified","err","Log","error","pipe","originalPath","call","staticArchList","archIndex","indexOf","unshift","splice","some","staticFiles","finalize","pathParts","archKey","startsWith","archCleaned","slice","parsePort","port","parsedPort","parseInt","Number","isNaN","pauseClient","generateClientProgram","runWebAppServer","shuttingDown","syncQueue","_SynchronousQueue","getItemPathname","itemUrl","reloadClientPrograms","runTask","configJson","__meteor_bootstrap__","clientArchs","clientPaths","stack","process","exit","unpause","clientDir","serverDir","programJsonPath","programJson","code","format","item","where","sourceMap","PUBLIC_SETTINGS","configOverrides","oldProgram","newProgram","WebAppHashing","versionRefreshable","versionNonRefreshable","cordovaCompatibilityVersions","manifestUrlPrefix","replace","manifestUrl","Package","autoupdate","AUTOUPDATE_VERSION","Autoupdate","autoupdateVersion","env","generateBoilerplateForArch","defaultOptionsForArch","DDP_DEFAULT_CONNECTION_URL","MOBILE_DDP_URL","absoluteUrl","ROOT_URL","MOBILE_ROOT_URL","generateBoilerplate","refreshableAssets","css","file","app","rawConnectHandlers","use","isValidUrl","getPathParts","shift","isPrefixOf","prefix","array","every","part","response","pathPrefix","prefixParts","meteorInternalHandlers","packageAndAppHandlers","suppressConnectErrors","status","newHeaders","catch","httpServer","onListeningCallbacks","socket","destroyed","message","destroy","connectHandlers","connectApp","onListening","f","startListening","listenOptions","cb","listen","exports","main","argv","startHttpServer","bindEnvironment","METEOR_PRINT_ON_LISTEN","console","log","callbacks","localPort","PORT","unixSocketPath","UNIX_SOCKET_PATH","test","host","BIND_IP","setInlineScriptsAllowed","enableSubresourceIntegrity","use_credentials","setBundledJsCssUrlRewriteHook","hookFn","setBundledJsCssPrefix","self","addStaticJs","npmConnect","connectArgs","handlers","apply","originalUse","useArgs","originalLength","entry","originalHandle","handle","asyncApply","arguments","statSync","unlinkSync","existsSync","socketPath","isSocket","eventEmitter","signal"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;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AT;AAAW,GAAxB;;AAAyB0U,YAAU,CAAC1U,CAAD,EAAG;AAAC0U,cAAU,GAAC1U,CAAX;AAAa,GAApD;;AAAqD2U,YAAU,CAAC3U,CAAD,EAAG;AAAC2U,cAAU,GAAC3U,CAAX;AAAa;;AAAhF,CAAjB,EAAmG,CAAnG;;AAyB3J,MAAMoB,wBAAwB,GAAIwT,UAAD,IAAgB;AACtD,MAAI;AACF,QAAIH,QAAQ,CAACG,UAAD,CAAR,CAAqBC,QAArB,EAAJ,EAAqC;AACnC;AACA;AACAH,gBAAU,CAACE,UAAD,CAAV;AACD,KAJD,MAIO;AACL,YAAM,IAAI5P,KAAJ,CACH,kCAAiC4P,UAAW,kBAA7C,GACA,8DADA,GAEA,2BAHI,CAAN;AAKD;AACF,GAZD,CAYE,OAAOvJ,KAAP,EAAc;AACd;AACA;AACA;AACA,QAAIA,KAAK,CAAC6C,IAAN,KAAe,QAAnB,EAA6B;AAC3B,YAAM7C,KAAN;AACD;AACF;AACF,CArBM;;AA0BA,MAAMhK,yBAAyB,GACpC,CAACuT,UAAD,EAAaE,YAAY,GAAGnH,OAA5B,KAAwC;AACtC,GAAC,MAAD,EAAS,QAAT,EAAmB,QAAnB,EAA6B,SAA7B,EAAwC9F,OAAxC,CAAgDkN,MAAM,IAAI;AACxDD,gBAAY,CAACvO,EAAb,CAAgBwO,MAAhB,EAAwBzP,MAAM,CAACmN,eAAP,CAAuB,MAAM;AACnD,UAAIkC,UAAU,CAACC,UAAD,CAAd,EAA4B;AAC1BF,kBAAU,CAACE,UAAD,CAAV;AACD;AACF,KAJuB,CAAxB;AAKD,GAND;AAOD,CATI,C","file":"/packages/webapp.js","sourcesContent":["import assert from \"assert\";\nimport { readFileSync } from \"fs\";\nimport { createServer } from \"http\";\nimport {\n join as pathJoin,\n dirname as pathDirname,\n} from \"path\";\nimport { parse as parseUrl } from \"url\";\nimport { createHash } from \"crypto\";\nimport { connect } from \"./connect.js\";\nimport compress from \"compression\";\nimport cookieParser from \"cookie-parser\";\nimport query from \"qs-middleware\";\nimport parseRequest from \"parseurl\";\nimport basicAuth from \"basic-auth-connect\";\nimport { lookup as lookupUserAgent } from \"useragent\";\nimport { isModern } from \"meteor/modern-browsers\";\nimport send from \"send\";\nimport {\n removeExistingSocketFile,\n registerSocketFileCleanup,\n} from './socket_file.js';\n\nvar SHORT_SOCKET_TIMEOUT = 5*1000;\nvar LONG_SOCKET_TIMEOUT = 120*1000;\n\nexport const WebApp = {};\nexport const WebAppInternals = {};\n\nconst hasOwn = Object.prototype.hasOwnProperty;\n\n// backwards compat to 2.0 of connect\nconnect.basicAuth = basicAuth;\n\nWebAppInternals.NpmModules = {\n connect: {\n version: Npm.require('connect/package.json').version,\n module: connect,\n }\n};\n\n// Though we might prefer to use web.browser (modern) as the default\n// architecture, safety requires a more compatible defaultArch.\nWebApp.defaultArch = 'web.browser.legacy';\n\n// XXX maps archs to manifests\nWebApp.clientPrograms = {};\n\n// XXX maps archs to program path on filesystem\nvar archPath = {};\n\nvar bundledJsCssUrlRewriteHook = function (url) {\n var bundledPrefix =\n __meteor_runtime_config__.ROOT_URL_PATH_PREFIX || '';\n return bundledPrefix + url;\n};\n\nvar sha1 = function (contents) {\n var hash = createHash('sha1');\n hash.update(contents);\n return hash.digest('hex');\n};\n\n function shouldCompress(req, res) {\n if (req.headers['x-no-compression']) {\n // don't compress responses with this request header\n return false;\n }\n\n // fallback to standard filter function\n return compress.filter(req, res);\n};\n\n// #BrowserIdentification\n//\n// We have multiple places that want to identify the browser: the\n// unsupported browser page, the appcache package, and, eventually\n// delivering browser polyfills only as needed.\n//\n// To avoid detecting the browser in multiple places ad-hoc, we create a\n// Meteor \"browser\" object. It uses but does not expose the npm\n// useragent module (we could choose a different mechanism to identify\n// the browser in the future if we wanted to). The browser object\n// contains\n//\n// * `name`: the name of the browser in camel case\n// * `major`, `minor`, `patch`: integers describing the browser version\n//\n// Also here is an early version of a Meteor `request` object, intended\n// to be a high-level description of the request without exposing\n// details of connect's low-level `req`. Currently it contains:\n//\n// * `browser`: browser identification object described above\n// * `url`: parsed url, including parsed query params\n//\n// As a temporary hack there is a `categorizeRequest` function on WebApp which\n// converts a connect `req` to a Meteor `request`. This can go away once smart\n// packages such as appcache are being passed a `request` object directly when\n// they serve content.\n//\n// This allows `request` to be used uniformly: it is passed to the html\n// attributes hook, and the appcache package can use it when deciding\n// whether to generate a 404 for the manifest.\n//\n// Real routing / server side rendering will probably refactor this\n// heavily.\n\n\n// e.g. \"Mobile Safari\" => \"mobileSafari\"\nvar camelCase = function (name) {\n var parts = name.split(' ');\n parts[0] = parts[0].toLowerCase();\n for (var i = 1; i < parts.length; ++i) {\n parts[i] = parts[i].charAt(0).toUpperCase() + parts[i].substr(1);\n }\n return parts.join('');\n};\n\nvar identifyBrowser = function (userAgentString) {\n var userAgent = lookupUserAgent(userAgentString);\n return {\n name: camelCase(userAgent.family),\n major: +userAgent.major,\n minor: +userAgent.minor,\n patch: +userAgent.patch\n };\n};\n\n// XXX Refactor as part of implementing real routing.\nWebAppInternals.identifyBrowser = identifyBrowser;\n\nWebApp.categorizeRequest = function (req) {\n return _.extend({\n browser: identifyBrowser(req.headers['user-agent']),\n url: parseUrl(req.url, true)\n }, _.pick(req, 'dynamicHead', 'dynamicBody', 'headers', 'cookies'));\n};\n\n// HTML attribute hooks: functions to be called to determine any attributes to\n// be added to the '' tag. Each function is passed a 'request' object (see\n// #BrowserIdentification) and should return null or object.\nvar htmlAttributeHooks = [];\nvar getHtmlAttributes = function (request) {\n var combinedAttributes = {};\n _.each(htmlAttributeHooks || [], function (hook) {\n var attributes = hook(request);\n if (attributes === null)\n return;\n if (typeof attributes !== 'object')\n throw Error(\"HTML attribute hook must return null or object\");\n _.extend(combinedAttributes, attributes);\n });\n return combinedAttributes;\n};\nWebApp.addHtmlAttributeHook = function (hook) {\n htmlAttributeHooks.push(hook);\n};\n\n// Serve app HTML for this URL?\nvar appUrl = function (url) {\n if (url === '/favicon.ico' || url === '/robots.txt')\n return false;\n\n // NOTE: app.manifest is not a web standard like favicon.ico and\n // robots.txt. It is a file name we have chosen to use for HTML5\n // appcache URLs. It is included here to prevent using an appcache\n // then removing it from poisoning an app permanently. Eventually,\n // once we have server side routing, this won't be needed as\n // unknown URLs with return a 404 automatically.\n if (url === '/app.manifest')\n return false;\n\n // Avoid serving app HTML for declared routes such as /sockjs/.\n if (RoutePolicy.classify(url))\n return false;\n\n // we currently return app HTML on all URLs by default\n return true;\n};\n\n\n// We need to calculate the client hash after all packages have loaded\n// to give them a chance to populate __meteor_runtime_config__.\n//\n// Calculating the hash during startup means that packages can only\n// populate __meteor_runtime_config__ during load, not during startup.\n//\n// Calculating instead it at the beginning of main after all startup\n// hooks had run would allow packages to also populate\n// __meteor_runtime_config__ during startup, but that's too late for\n// autoupdate because it needs to have the client hash at startup to\n// insert the auto update version itself into\n// __meteor_runtime_config__ to get it to the client.\n//\n// An alternative would be to give autoupdate a \"post-start,\n// pre-listen\" hook to allow it to insert the auto update version at\n// the right moment.\n\nMeteor.startup(function () {\n function getter(key) {\n return function (arch) {\n arch = arch || WebApp.defaultArch;\n const program = WebApp.clientPrograms[arch];\n const value = program && program[key];\n // If this is the first time we have calculated this hash,\n // program[key] will be a thunk (lazy function with no parameters)\n // that we should call to do the actual computation.\n return typeof value === \"function\"\n ? program[key] = value()\n : value;\n };\n }\n\n WebApp.calculateClientHash = WebApp.clientHash = getter(\"version\");\n WebApp.calculateClientHashRefreshable = getter(\"versionRefreshable\");\n WebApp.calculateClientHashNonRefreshable = getter(\"versionNonRefreshable\");\n WebApp.getRefreshableAssets = getter(\"refreshableAssets\");\n});\n\n\n\n// When we have a request pending, we want the socket timeout to be long, to\n// give ourselves a while to serve it, and to allow sockjs long polls to\n// complete. On the other hand, we want to close idle sockets relatively\n// quickly, so that we can shut down relatively promptly but cleanly, without\n// cutting off anyone's response.\nWebApp._timeoutAdjustmentRequestCallback = function (req, res) {\n // this is really just req.socket.setTimeout(LONG_SOCKET_TIMEOUT);\n req.setTimeout(LONG_SOCKET_TIMEOUT);\n // Insert our new finish listener to run BEFORE the existing one which removes\n // the response from the socket.\n var finishListeners = res.listeners('finish');\n // XXX Apparently in Node 0.12 this event was called 'prefinish'.\n // https://github.com/joyent/node/commit/7c9b6070\n // But it has switched back to 'finish' in Node v4:\n // https://github.com/nodejs/node/pull/1411\n res.removeAllListeners('finish');\n res.on('finish', function () {\n res.setTimeout(SHORT_SOCKET_TIMEOUT);\n });\n _.each(finishListeners, function (l) { res.on('finish', l); });\n};\n\n\n// Will be updated by main before we listen.\n// Map from client arch to boilerplate object.\n// Boilerplate object has:\n// - func: XXX\n// - baseData: XXX\nvar boilerplateByArch = {};\n\n// Register a callback function that can selectively modify boilerplate\n// data given arguments (request, data, arch). The key should be a unique\n// identifier, to prevent accumulating duplicate callbacks from the same\n// call site over time. Callbacks will be called in the order they were\n// registered. A callback should return false if it did not make any\n// changes affecting the boilerplate. Passing null deletes the callback.\n// Any previous callback registered for this key will be returned.\nconst boilerplateDataCallbacks = Object.create(null);\nWebAppInternals.registerBoilerplateDataCallback = function (key, callback) {\n const previousCallback = boilerplateDataCallbacks[key];\n\n if (typeof callback === \"function\") {\n boilerplateDataCallbacks[key] = callback;\n } else {\n assert.strictEqual(callback, null);\n delete boilerplateDataCallbacks[key];\n }\n\n // Return the previous callback in case the new callback needs to call\n // it; for example, when the new callback is a wrapper for the old.\n return previousCallback || null;\n};\n\n// Given a request (as returned from `categorizeRequest`), return the\n// boilerplate HTML to serve for that request.\n//\n// If a previous connect middleware has rendered content for the head or body,\n// returns the boilerplate with that content patched in otherwise\n// memoizes on HTML attributes (used by, eg, appcache) and whether inline\n// scripts are currently allowed.\n// XXX so far this function is always called with arch === 'web.browser'\nfunction getBoilerplate(request, arch) {\n return getBoilerplateAsync(request, arch).await();\n}\n\nfunction getBoilerplateAsync(request, arch) {\n const boilerplate = boilerplateByArch[arch];\n const data = Object.assign({}, boilerplate.baseData, {\n htmlAttributes: getHtmlAttributes(request),\n }, _.pick(request, \"dynamicHead\", \"dynamicBody\"));\n\n let madeChanges = false;\n let promise = Promise.resolve();\n\n Object.keys(boilerplateDataCallbacks).forEach(key => {\n promise = promise.then(() => {\n const callback = boilerplateDataCallbacks[key];\n return callback(request, data, arch);\n }).then(result => {\n // Callbacks should return false if they did not make any changes.\n if (result !== false) {\n madeChanges = true;\n }\n });\n });\n\n return promise.then(() => ({\n stream: boilerplate.toHTMLStream(data),\n statusCode: data.statusCode,\n headers: data.headers,\n }));\n}\n\nWebAppInternals.generateBoilerplateInstance = function (arch,\n manifest,\n additionalOptions) {\n additionalOptions = additionalOptions || {};\n\n var runtimeConfig = _.extend(\n _.clone(__meteor_runtime_config__),\n additionalOptions.runtimeConfigOverrides || {}\n );\n\n return new Boilerplate(arch, manifest, _.extend({\n pathMapper(itemPath) {\n return pathJoin(archPath[arch], itemPath);\n },\n baseDataExtension: {\n additionalStaticJs: _.map(\n additionalStaticJs || [],\n function (contents, pathname) {\n return {\n pathname: pathname,\n contents: contents\n };\n }\n ),\n // Convert to a JSON string, then get rid of most weird characters, then\n // wrap in double quotes. (The outermost JSON.stringify really ought to\n // just be \"wrap in double quotes\" but we use it to be safe.) This might\n // end up inside a \", but normal {{spacebars}} escaping escapes too much! See\n // https://github.com/meteor/meteor/issues/3730\n meteorRuntimeConfig: JSON.stringify(\n encodeURIComponent(JSON.stringify(runtimeConfig))),\n rootUrlPathPrefix: __meteor_runtime_config__.ROOT_URL_PATH_PREFIX || '',\n bundledJsCssUrlRewriteHook: bundledJsCssUrlRewriteHook,\n sriMode: sriMode,\n inlineScriptsAllowed: WebAppInternals.inlineScriptsAllowed(),\n inline: additionalOptions.inline\n }\n }, additionalOptions));\n};\n\n// A mapping from url path to architecture (e.g. \"web.browser\") to static\n// file information with the following fields:\n// - type: the type of file to be served\n// - cacheable: optionally, whether the file should be cached or not\n// - sourceMapUrl: optionally, the url of the source map\n//\n// Info also contains one of the following:\n// - content: the stringified content that should be served at this path\n// - absolutePath: the absolute path on disk to the file\n\n// Serve static files from the manifest or added with\n// `addStaticJs`. Exported for tests.\nWebAppInternals.staticFilesMiddleware = async function (\n staticFilesByArch,\n req,\n res,\n next,\n) {\n if ('GET' != req.method && 'HEAD' != req.method && 'OPTIONS' != req.method) {\n next();\n return;\n }\n var pathname = parseRequest(req).pathname;\n try {\n pathname = decodeURIComponent(pathname);\n } catch (e) {\n next();\n return;\n }\n\n var serveStaticJs = function (s) {\n res.writeHead(200, {\n 'Content-type': 'application/javascript; charset=UTF-8'\n });\n res.write(s);\n res.end();\n };\n\n if (_.has(additionalStaticJs, pathname) &&\n ! WebAppInternals.inlineScriptsAllowed()) {\n serveStaticJs(additionalStaticJs[pathname]);\n return;\n }\n\n const { arch, path } = getArchAndPath(\n pathname,\n identifyBrowser(req.headers[\"user-agent\"]),\n );\n\n // If pauseClient(arch) has been called, program.paused will be a\n // Promise that will be resolved when the program is unpaused.\n const program = WebApp.clientPrograms[arch];\n await program.paused;\n\n if (path === \"/meteor_runtime_config.js\" &&\n ! WebAppInternals.inlineScriptsAllowed()) {\n serveStaticJs(`__meteor_runtime_config__ = ${program.meteorRuntimeConfig};`);\n return;\n }\n\n const info = getStaticFileInfo(staticFilesByArch, pathname, path, arch);\n if (! info) {\n next();\n return;\n }\n\n // We don't need to call pause because, unlike 'static', once we call into\n // 'send' and yield to the event loop, we never call another handler with\n // 'next'.\n\n // Cacheable files are files that should never change. Typically\n // named by their hash (eg meteor bundled js and css files).\n // We cache them ~forever (1yr).\n const maxAge = info.cacheable\n ? 1000 * 60 * 60 * 24 * 365\n : 0;\n\n if (info.cacheable) {\n // Since we use req.headers[\"user-agent\"] to determine whether the\n // client should receive modern or legacy resources, tell the client\n // to invalidate cached resources when/if its user agent string\n // changes in the future.\n res.setHeader(\"Vary\", \"User-Agent\");\n }\n\n // Set the X-SourceMap header, which current Chrome, FireFox, and Safari\n // understand. (The SourceMap header is slightly more spec-correct but FF\n // doesn't understand it.)\n //\n // You may also need to enable source maps in Chrome: open dev tools, click\n // the gear in the bottom right corner, and select \"enable source maps\".\n if (info.sourceMapUrl) {\n res.setHeader('X-SourceMap',\n __meteor_runtime_config__.ROOT_URL_PATH_PREFIX +\n info.sourceMapUrl);\n }\n\n if (info.type === \"js\" ||\n info.type === \"dynamic js\") {\n res.setHeader(\"Content-Type\", \"application/javascript; charset=UTF-8\");\n } else if (info.type === \"css\") {\n res.setHeader(\"Content-Type\", \"text/css; charset=UTF-8\");\n } else if (info.type === \"json\") {\n res.setHeader(\"Content-Type\", \"application/json; charset=UTF-8\");\n }\n\n if (info.hash) {\n res.setHeader('ETag', '\"' + info.hash + '\"');\n }\n\n if (info.content) {\n res.write(info.content);\n res.end();\n } else {\n send(req, info.absolutePath, {\n maxage: maxAge,\n dotfiles: 'allow', // if we specified a dotfile in the manifest, serve it\n lastModified: false // don't set last-modified based on the file date\n }).on('error', function (err) {\n Log.error(\"Error serving static file \" + err);\n res.writeHead(500);\n res.end();\n }).on('directory', function () {\n Log.error(\"Unexpected directory \" + info.absolutePath);\n res.writeHead(500);\n res.end();\n }).pipe(res);\n }\n};\n\nfunction getStaticFileInfo(staticFilesByArch, originalPath, path, arch) {\n if (! hasOwn.call(WebApp.clientPrograms, arch)) {\n return null;\n }\n\n // Get a list of all available static file architectures, with arch\n // first in the list if it exists.\n const staticArchList = Object.keys(staticFilesByArch);\n const archIndex = staticArchList.indexOf(arch);\n if (archIndex > 0) {\n staticArchList.unshift(staticArchList.splice(archIndex, 1)[0]);\n }\n\n let info = null;\n\n staticArchList.some(arch => {\n const staticFiles = staticFilesByArch[arch];\n\n function finalize(path) {\n info = staticFiles[path];\n // Sometimes we register a lazy function instead of actual data in\n // the staticFiles manifest.\n if (typeof info === \"function\") {\n info = staticFiles[path] = info();\n }\n return info;\n }\n\n // If staticFiles contains originalPath with the arch inferred above,\n // use that information.\n if (hasOwn.call(staticFiles, originalPath)) {\n return finalize(originalPath);\n }\n\n // If getArchAndPath returned an alternate path, try that instead.\n if (path !== originalPath &&\n hasOwn.call(staticFiles, path)) {\n return finalize(path);\n }\n });\n\n return info;\n}\n\nfunction getArchAndPath(path, browser) {\n const pathParts = path.split(\"/\");\n const archKey = pathParts[1];\n\n if (archKey.startsWith(\"__\")) {\n const archCleaned = \"web.\" + archKey.slice(2);\n if (hasOwn.call(WebApp.clientPrograms, archCleaned)) {\n pathParts.splice(1, 1); // Remove the archKey part.\n return {\n arch: archCleaned,\n path: pathParts.join(\"/\"),\n };\n }\n }\n\n // TODO Perhaps one day we could infer Cordova clients here, so that we\n // wouldn't have to use prefixed \"/__cordova/...\" URLs.\n const arch = isModern(browser)\n ? \"web.browser\"\n : \"web.browser.legacy\";\n\n if (hasOwn.call(WebApp.clientPrograms, arch)) {\n return { arch, path };\n }\n\n return {\n arch: WebApp.defaultArch,\n path,\n };\n}\n\n// Parse the passed in port value. Return the port as-is if it's a String\n// (e.g. a Windows Server style named pipe), otherwise return the port as an\n// integer.\n//\n// DEPRECATED: Direct use of this function is not recommended; it is no\n// longer used internally, and will be removed in a future release.\nWebAppInternals.parsePort = port => {\n let parsedPort = parseInt(port);\n if (Number.isNaN(parsedPort)) {\n parsedPort = port;\n }\n return parsedPort;\n}\n\nimport { onMessage } from \"meteor/inter-process-messaging\";\n\nonMessage(\"webapp-pause-client\", async ({ arch }) => {\n WebAppInternals.pauseClient(arch);\n});\n\nonMessage(\"webapp-reload-client\", async ({ arch }) => {\n WebAppInternals.generateClientProgram(arch);\n});\n\nfunction runWebAppServer() {\n var shuttingDown = false;\n var syncQueue = new Meteor._SynchronousQueue();\n\n var getItemPathname = function (itemUrl) {\n return decodeURIComponent(parseUrl(itemUrl).pathname);\n };\n\n WebAppInternals.reloadClientPrograms = function () {\n syncQueue.runTask(function() {\n const staticFilesByArch = Object.create(null);\n\n const { configJson } = __meteor_bootstrap__;\n const clientArchs = configJson.clientArchs ||\n Object.keys(configJson.clientPaths);\n\n try {\n clientArchs.forEach(arch => {\n generateClientProgram(arch, staticFilesByArch);\n });\n WebAppInternals.staticFilesByArch = staticFilesByArch;\n } catch (e) {\n Log.error(\"Error reloading the client program: \" + e.stack);\n process.exit(1);\n }\n });\n };\n\n // Pause any incoming requests and make them wait for the program to be\n // unpaused the next time generateClientProgram(arch) is called.\n WebAppInternals.pauseClient = function (arch) {\n syncQueue.runTask(() => {\n const program = WebApp.clientPrograms[arch];\n const { unpause } = program;\n program.paused = new Promise(resolve => {\n if (typeof unpause === \"function\") {\n // If there happens to be an existing program.unpause function,\n // compose it with the resolve function.\n program.unpause = function () {\n unpause();\n resolve();\n };\n } else {\n program.unpause = resolve;\n }\n });\n });\n };\n\n WebAppInternals.generateClientProgram = function (arch) {\n syncQueue.runTask(() => generateClientProgram(arch));\n };\n\n function generateClientProgram(\n arch,\n staticFilesByArch = WebAppInternals.staticFilesByArch,\n ) {\n const clientDir = pathJoin(\n pathDirname(__meteor_bootstrap__.serverDir),\n arch,\n );\n\n // read the control for the client we'll be serving up\n const programJsonPath = pathJoin(clientDir, \"program.json\");\n\n let programJson;\n try {\n programJson = JSON.parse(readFileSync(programJsonPath));\n } catch (e) {\n if (e.code === \"ENOENT\") return;\n throw e;\n }\n\n if (programJson.format !== \"web-program-pre1\") {\n throw new Error(\"Unsupported format for client assets: \" +\n JSON.stringify(programJson.format));\n }\n\n if (! programJsonPath || ! clientDir || ! programJson) {\n throw new Error(\"Client config file not parsed.\");\n }\n\n archPath[arch] = clientDir;\n const staticFiles = staticFilesByArch[arch] = Object.create(null);\n\n const { manifest } = programJson;\n manifest.forEach(item => {\n if (item.url && item.where === \"client\") {\n staticFiles[getItemPathname(item.url)] = {\n absolutePath: pathJoin(clientDir, item.path),\n cacheable: item.cacheable,\n hash: item.hash,\n // Link from source to its map\n sourceMapUrl: item.sourceMapUrl,\n type: item.type\n };\n\n if (item.sourceMap) {\n // Serve the source map too, under the specified URL. We assume\n // all source maps are cacheable.\n staticFiles[getItemPathname(item.sourceMapUrl)] = {\n absolutePath: pathJoin(clientDir, item.sourceMap),\n cacheable: true\n };\n }\n }\n });\n\n const { PUBLIC_SETTINGS } = __meteor_runtime_config__;\n const configOverrides = {\n PUBLIC_SETTINGS,\n };\n\n const oldProgram = WebApp.clientPrograms[arch];\n const newProgram = WebApp.clientPrograms[arch] = {\n format: \"web-program-pre1\",\n manifest: manifest,\n // Use arrow functions so that these versions can be lazily\n // calculated later, and so that they will not be included in the\n // staticFiles[manifestUrl].content string below.\n //\n // Note: these version calculations must be kept in agreement with\n // CordovaBuilder#appendVersion in tools/cordova/builder.js, or hot\n // code push will reload Cordova apps unnecessarily.\n version: () => WebAppHashing.calculateClientHash(\n manifest, null, configOverrides),\n versionRefreshable: () => WebAppHashing.calculateClientHash(\n manifest, type => type === \"css\", configOverrides),\n versionNonRefreshable: () => WebAppHashing.calculateClientHash(\n manifest, type => type !== \"css\", configOverrides),\n cordovaCompatibilityVersions: programJson.cordovaCompatibilityVersions,\n PUBLIC_SETTINGS,\n };\n\n // Expose program details as a string reachable via the following URL.\n const manifestUrlPrefix = \"/__\" + arch.replace(/^web\\./, \"\");\n const manifestUrl = manifestUrlPrefix + getItemPathname(\"/manifest.json\");\n\n staticFiles[manifestUrl] = () => {\n if (Package.autoupdate) {\n const {\n AUTOUPDATE_VERSION =\n Package.autoupdate.Autoupdate.autoupdateVersion\n } = process.env;\n\n if (AUTOUPDATE_VERSION) {\n newProgram.version = AUTOUPDATE_VERSION;\n }\n }\n\n if (typeof newProgram.version === \"function\") {\n newProgram.version = newProgram.version();\n }\n\n return {\n content: JSON.stringify(newProgram),\n cacheable: false,\n hash: newProgram.version,\n type: \"json\"\n };\n };\n\n generateBoilerplateForArch(arch);\n\n // If there are any requests waiting on oldProgram.paused, let them\n // continue now (using the new program).\n if (oldProgram &&\n oldProgram.paused) {\n oldProgram.unpause();\n }\n };\n\n const defaultOptionsForArch = {\n 'web.cordova': {\n runtimeConfigOverrides: {\n // XXX We use absoluteUrl() here so that we serve https://\n // URLs to cordova clients if force-ssl is in use. If we were\n // to use __meteor_runtime_config__.ROOT_URL instead of\n // absoluteUrl(), then Cordova clients would immediately get a\n // HCP setting their DDP_DEFAULT_CONNECTION_URL to\n // http://example.meteor.com. This breaks the app, because\n // force-ssl doesn't serve CORS headers on 302\n // redirects. (Plus it's undesirable to have clients\n // connecting to http://example.meteor.com when force-ssl is\n // in use.)\n DDP_DEFAULT_CONNECTION_URL: process.env.MOBILE_DDP_URL ||\n Meteor.absoluteUrl(),\n ROOT_URL: process.env.MOBILE_ROOT_URL ||\n Meteor.absoluteUrl()\n }\n },\n\n \"web.browser\": {\n runtimeConfigOverrides: {\n isModern: true,\n }\n },\n\n \"web.browser.legacy\": {\n runtimeConfigOverrides: {\n isModern: false,\n }\n },\n };\n\n WebAppInternals.generateBoilerplate = function () {\n // This boilerplate will be served to the mobile devices when used with\n // Meteor/Cordova for the Hot-Code Push and since the file will be served by\n // the device's server, it is important to set the DDP url to the actual\n // Meteor server accepting DDP connections and not the device's file server.\n syncQueue.runTask(function() {\n Object.keys(WebApp.clientPrograms)\n .forEach(generateBoilerplateForArch);\n });\n };\n\n function generateBoilerplateForArch(arch) {\n const program = WebApp.clientPrograms[arch];\n const additionalOptions = defaultOptionsForArch[arch] || {};\n const { baseData } = boilerplateByArch[arch] =\n WebAppInternals.generateBoilerplateInstance(\n arch,\n program.manifest,\n additionalOptions,\n );\n // We need the runtime config with overrides for meteor_runtime_config.js:\n program.meteorRuntimeConfig = JSON.stringify({\n ...__meteor_runtime_config__,\n ...(additionalOptions.runtimeConfigOverrides || null),\n });\n program.refreshableAssets = baseData.css.map(file => ({\n url: bundledJsCssUrlRewriteHook(file.url),\n }));\n }\n\n WebAppInternals.reloadClientPrograms();\n\n // webserver\n var app = connect();\n\n // Packages and apps can add handlers that run before any other Meteor\n // handlers via WebApp.rawConnectHandlers.\n var rawConnectHandlers = connect();\n app.use(rawConnectHandlers);\n\n // Auto-compress any json, javascript, or text.\n app.use(compress({filter: shouldCompress}));\n\n // parse cookies into an object\n app.use(cookieParser());\n\n // We're not a proxy; reject (without crashing) attempts to treat us like\n // one. (See #1212.)\n app.use(function(req, res, next) {\n if (RoutePolicy.isValidUrl(req.url)) {\n next();\n return;\n }\n res.writeHead(400);\n res.write(\"Not a proxy\");\n res.end();\n });\n\n // Parse the query string into res.query. Used by oauth_server, but it's\n // generally pretty handy..\n //\n // Do this before the next middleware destroys req.url if a path prefix\n // is set to close #10111.\n app.use(query());\n\n function getPathParts(path) {\n const parts = path.split(\"/\");\n while (parts[0] === \"\") parts.shift();\n return parts;\n }\n\n function isPrefixOf(prefix, array) {\n return prefix.length <= array.length &&\n prefix.every((part, i) => part === array[i]);\n }\n\n // Strip off the path prefix, if it exists.\n app.use(function (request, response, next) {\n const pathPrefix = __meteor_runtime_config__.ROOT_URL_PATH_PREFIX;\n const { pathname } = parseUrl(request.url);\n\n // check if the path in the url starts with the path prefix\n if (pathPrefix) {\n const prefixParts = getPathParts(pathPrefix);\n const pathParts = getPathParts(pathname);\n if (isPrefixOf(prefixParts, pathParts)) {\n request.url = \"/\" + pathParts.slice(prefixParts.length).join(\"/\");\n return next();\n }\n }\n\n if (pathname === \"/favicon.ico\" ||\n pathname === \"/robots.txt\") {\n return next();\n }\n\n if (pathPrefix) {\n response.writeHead(404);\n response.write(\"Unknown path\");\n response.end();\n return;\n }\n\n next();\n });\n\n // Serve static files from the manifest.\n // This is inspired by the 'static' middleware.\n app.use(function (req, res, next) {\n WebAppInternals.staticFilesMiddleware(\n WebAppInternals.staticFilesByArch,\n req, res, next\n );\n });\n\n // Core Meteor packages like dynamic-import can add handlers before\n // other handlers added by package and application code.\n app.use(WebAppInternals.meteorInternalHandlers = connect());\n\n // Packages and apps can add handlers to this via WebApp.connectHandlers.\n // They are inserted before our default handler.\n var packageAndAppHandlers = connect();\n app.use(packageAndAppHandlers);\n\n var suppressConnectErrors = false;\n // connect knows it is an error handler because it has 4 arguments instead of\n // 3. go figure. (It is not smart enough to find such a thing if it's hidden\n // inside packageAndAppHandlers.)\n app.use(function (err, req, res, next) {\n if (!err || !suppressConnectErrors || !req.headers['x-suppress-error']) {\n next(err);\n return;\n }\n res.writeHead(err.status, { 'Content-Type': 'text/plain' });\n res.end(\"An error message\");\n });\n\n app.use(async function (req, res, next) {\n if (! appUrl(req.url)) {\n return next();\n\n } else {\n var headers = {\n 'Content-Type': 'text/html; charset=utf-8'\n };\n\n if (shuttingDown) {\n headers['Connection'] = 'Close';\n }\n\n var request = WebApp.categorizeRequest(req);\n\n if (request.url.query && request.url.query['meteor_css_resource']) {\n // In this case, we're requesting a CSS resource in the meteor-specific\n // way, but we don't have it. Serve a static css file that indicates that\n // we didn't have it, so we can detect that and refresh. Make sure\n // that any proxies or CDNs don't cache this error! (Normally proxies\n // or CDNs are smart enough not to cache error pages, but in order to\n // make this hack work, we need to return the CSS file as a 200, which\n // would otherwise be cached.)\n headers['Content-Type'] = 'text/css; charset=utf-8';\n headers['Cache-Control'] = 'no-cache';\n res.writeHead(200, headers);\n res.write(\".meteor-css-not-found-error { width: 0px;}\");\n res.end();\n return;\n }\n\n if (request.url.query && request.url.query['meteor_js_resource']) {\n // Similarly, we're requesting a JS resource that we don't have.\n // Serve an uncached 404. (We can't use the same hack we use for CSS,\n // because actually acting on that hack requires us to have the JS\n // already!)\n headers['Cache-Control'] = 'no-cache';\n res.writeHead(404, headers);\n res.end(\"404 Not Found\");\n return;\n }\n\n if (request.url.query && request.url.query['meteor_dont_serve_index']) {\n // When downloading files during a Cordova hot code push, we need\n // to detect if a file is not available instead of inadvertently\n // downloading the default index page.\n // So similar to the situation above, we serve an uncached 404.\n headers['Cache-Control'] = 'no-cache';\n res.writeHead(404, headers);\n res.end(\"404 Not Found\");\n return;\n }\n\n const { arch } = getArchAndPath(\n parseRequest(req).pathname,\n request.browser,\n );\n\n // If pauseClient(arch) has been called, program.paused will be a\n // Promise that will be resolved when the program is unpaused.\n await WebApp.clientPrograms[arch].paused;\n\n return getBoilerplateAsync(request, arch).then(({\n stream,\n statusCode,\n headers: newHeaders,\n }) => {\n if (!statusCode) {\n statusCode = res.statusCode ? res.statusCode : 200;\n }\n\n if (newHeaders) {\n Object.assign(headers, newHeaders);\n }\n\n res.writeHead(statusCode, headers);\n\n stream.pipe(res, {\n // End the response when the stream ends.\n end: true,\n });\n\n }).catch(error => {\n Log.error(\"Error running template: \" + error.stack);\n res.writeHead(500, headers);\n res.end();\n });\n }\n });\n\n // Return 404 by default, if no other handlers serve this URL.\n app.use(function (req, res) {\n res.writeHead(404);\n res.end();\n });\n\n\n var httpServer = createServer(app);\n var onListeningCallbacks = [];\n\n // After 5 seconds w/o data on a socket, kill it. On the other hand, if\n // there's an outstanding request, give it a higher timeout instead (to avoid\n // killing long-polling requests)\n httpServer.setTimeout(SHORT_SOCKET_TIMEOUT);\n\n // Do this here, and then also in livedata/stream_server.js, because\n // stream_server.js kills all the current request handlers when installing its\n // own.\n httpServer.on('request', WebApp._timeoutAdjustmentRequestCallback);\n\n // If the client gave us a bad request, tell it instead of just closing the\n // socket. This lets load balancers in front of us differentiate between \"a\n // server is randomly closing sockets for no reason\" and \"client sent a bad\n // request\".\n //\n // This will only work on Node 6; Node 4 destroys the socket before calling\n // this event. See https://github.com/nodejs/node/pull/4557/ for details.\n httpServer.on('clientError', (err, socket) => {\n // Pre-Node-6, do nothing.\n if (socket.destroyed) {\n return;\n }\n\n if (err.message === 'Parse Error') {\n socket.end('HTTP/1.1 400 Bad Request\\r\\n\\r\\n');\n } else {\n // For other errors, use the default behavior as if we had no clientError\n // handler.\n socket.destroy(err);\n }\n });\n\n // start up app\n _.extend(WebApp, {\n connectHandlers: packageAndAppHandlers,\n rawConnectHandlers: rawConnectHandlers,\n httpServer: httpServer,\n connectApp: app,\n // For testing.\n suppressConnectErrors: function () {\n suppressConnectErrors = true;\n },\n onListening: function (f) {\n if (onListeningCallbacks)\n onListeningCallbacks.push(f);\n else\n f();\n },\n // This can be overridden by users who want to modify how listening works\n // (eg, to run a proxy like Apollo Engine Proxy in front of the server).\n startListening: function (httpServer, listenOptions, cb) {\n httpServer.listen(listenOptions, cb);\n },\n });\n\n // Let the rest of the packages (and Meteor.startup hooks) insert connect\n // middlewares and update __meteor_runtime_config__, then keep going to set up\n // actually serving HTML.\n exports.main = argv => {\n WebAppInternals.generateBoilerplate();\n\n const startHttpServer = listenOptions => {\n WebApp.startListening(httpServer, listenOptions, Meteor.bindEnvironment(() => {\n if (process.env.METEOR_PRINT_ON_LISTEN) {\n console.log(\"LISTENING\");\n }\n const callbacks = onListeningCallbacks;\n onListeningCallbacks = null;\n callbacks.forEach(callback => { callback(); });\n }, e => {\n console.error(\"Error listening:\", e);\n console.error(e && e.stack);\n }));\n };\n\n let localPort = process.env.PORT || 0;\n const unixSocketPath = process.env.UNIX_SOCKET_PATH;\n\n if (unixSocketPath) {\n // Start the HTTP server using a socket file.\n removeExistingSocketFile(unixSocketPath);\n startHttpServer({ path: unixSocketPath });\n registerSocketFileCleanup(unixSocketPath);\n } else {\n localPort = isNaN(Number(localPort)) ? localPort : Number(localPort);\n if (/\\\\\\\\?.+\\\\pipe\\\\?.+/.test(localPort)) {\n // Start the HTTP server using Windows Server style named pipe.\n startHttpServer({ path: localPort });\n } else if (typeof localPort === \"number\") {\n // Start the HTTP server using TCP.\n startHttpServer({\n port: localPort,\n host: process.env.BIND_IP || \"0.0.0.0\"\n });\n } else {\n throw new Error(\"Invalid PORT specified\");\n }\n }\n\n return \"DAEMON\";\n };\n}\n\nvar inlineScriptsAllowed = true;\n\nWebAppInternals.inlineScriptsAllowed = function () {\n return inlineScriptsAllowed;\n};\n\nWebAppInternals.setInlineScriptsAllowed = function (value) {\n inlineScriptsAllowed = value;\n WebAppInternals.generateBoilerplate();\n};\n\nvar sriMode;\n\nWebAppInternals.enableSubresourceIntegrity = function(use_credentials = false) {\n sriMode = use_credentials ? 'use-credentials' : 'anonymous';\n WebAppInternals.generateBoilerplate();\n};\n\nWebAppInternals.setBundledJsCssUrlRewriteHook = function (hookFn) {\n bundledJsCssUrlRewriteHook = hookFn;\n WebAppInternals.generateBoilerplate();\n};\n\nWebAppInternals.setBundledJsCssPrefix = function (prefix) {\n var self = this;\n self.setBundledJsCssUrlRewriteHook(\n function (url) {\n return prefix + url;\n });\n};\n\n// Packages can call `WebAppInternals.addStaticJs` to specify static\n// JavaScript to be included in the app. This static JS will be inlined,\n// unless inline scripts have been disabled, in which case it will be\n// served under `/`.\nvar additionalStaticJs = {};\nWebAppInternals.addStaticJs = function (contents) {\n additionalStaticJs[\"/\" + sha1(contents) + \".js\"] = contents;\n};\n\n// Exported for tests\nWebAppInternals.getBoilerplate = getBoilerplate;\nWebAppInternals.additionalStaticJs = additionalStaticJs;\n\n// Start the server!\nrunWebAppServer();\n","import npmConnect from \"connect\";\n\nexport function connect(...connectArgs) {\n const handlers = npmConnect.apply(this, connectArgs);\n const originalUse = handlers.use;\n\n // Wrap the handlers.use method so that any provided handler functions\n // alway run in a Fiber.\n handlers.use = function use(...useArgs) {\n const { stack } = this;\n const originalLength = stack.length;\n const result = originalUse.apply(this, useArgs);\n\n // If we just added anything to the stack, wrap each new entry.handle\n // with a function that calls Promise.asyncApply to ensure the\n // original handler runs in a Fiber.\n for (let i = originalLength; i < stack.length; ++i) {\n const entry = stack[i];\n const originalHandle = entry.handle;\n\n if (originalHandle.length >= 4) {\n // If the original handle had four (or more) parameters, the\n // wrapper must also have four parameters, since connect uses\n // handle.length to dermine whether to pass the error as the first\n // argument to the handle function.\n entry.handle = function handle(err, req, res, next) {\n return Promise.asyncApply(originalHandle, this, arguments);\n };\n } else {\n entry.handle = function handle(req, res, next) {\n return Promise.asyncApply(originalHandle, this, arguments);\n };\n }\n }\n\n return result;\n };\n\n return handlers;\n}\n","import { statSync, unlinkSync, existsSync } from 'fs';\n\n// Since a new socket file will be created when the HTTP server\n// starts up, if found remove the existing file.\n//\n// WARNING:\n// This will remove the configured socket file without warning. If\n// the configured socket file is already in use by another application,\n// it will still be removed. Node does not provide a reliable way to\n// differentiate between a socket file that is already in use by\n// another application or a stale socket file that has been\n// left over after a SIGKILL. Since we have no reliable way to\n// differentiate between these two scenarios, the best course of\n// action during startup is to remove any existing socket file. This\n// is not the safest course of action as removing the existing socket\n// file could impact an application using it, but this approach helps\n// ensure the HTTP server can startup without manual\n// intervention (e.g. asking for the verification and cleanup of socket\n// files before allowing the HTTP server to be started).\n//\n// The above being said, as long as the socket file path is\n// configured carefully when the application is deployed (and extra\n// care is taken to make sure the configured path is unique and doesn't\n// conflict with another socket file path), then there should not be\n// any issues with this approach.\nexport const removeExistingSocketFile = (socketPath) => {\n try {\n if (statSync(socketPath).isSocket()) {\n // Since a new socket file will be created, remove the existing\n // file.\n unlinkSync(socketPath);\n } else {\n throw new Error(\n `An existing file was found at \"${socketPath}\" and it is not ` +\n 'a socket file. Please confirm PORT is pointing to valid and ' +\n 'un-used socket file path.'\n );\n }\n } catch (error) {\n // If there is no existing socket file to cleanup, great, we'll\n // continue normally. If the caught exception represents any other\n // issue, re-throw.\n if (error.code !== 'ENOENT') {\n throw error;\n }\n }\n};\n\n// Remove the socket file when done to avoid leaving behind a stale one.\n// Note - a stale socket file is still left behind if the running node\n// process is killed via signal 9 - SIGKILL.\nexport const registerSocketFileCleanup =\n (socketPath, eventEmitter = process) => {\n ['exit', 'SIGINT', 'SIGHUP', 'SIGTERM'].forEach(signal => {\n eventEmitter.on(signal, Meteor.bindEnvironment(() => {\n if (existsSync(socketPath)) {\n unlinkSync(socketPath);\n }\n }));\n });\n };\n"]}