{"version":3,"sources":["meteor://💻app/packages/webapp-hashing/webapp-hashing.js"],"names":["crypto","Npm","require","WebAppHashing","calculateClientHash","manifest","includeFilter","runtimeConfigOverride","hash","createHash","runtimeCfg","_","omit","__meteor_runtime_config__","update","JSON","stringify","each","resource","type","where","path","digest","calculateCordovaCompatibilityHash","platformVersion","pluginVersions","plugins","Object","keys","sort","plugin","version"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAIA,MAAM,GAAGC,GAAG,CAACC,OAAJ,CAAY,QAAZ,CAAb;;AAEAC,aAAa,GAAG,EAAhB,C,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEAA,aAAa,CAACC,mBAAd,GACE,UAAUC,QAAV,EAAoBC,aAApB,EAAmCC,qBAAnC,EAA0D;AAC1D,MAAIC,IAAI,GAAGR,MAAM,CAACS,UAAP,CAAkB,MAAlB,CAAX,CAD0D,CAG1D;AACA;;AACA,MAAIC,UAAU,GAAGC,CAAC,CAACC,IAAF,CAAOC,yBAAP,EACf,CAAC,mBAAD,EAAsB,8BAAtB,EACC,0BADD,CADe,CAAjB;;AAIA,MAAIN,qBAAJ,EAA2B;AACzBG,cAAU,GAAGH,qBAAb;AACD;;AAEDC,MAAI,CAACM,MAAL,CAAYC,IAAI,CAACC,SAAL,CAAeN,UAAf,EAA2B,MAA3B,CAAZ;;AAEAC,GAAC,CAACM,IAAF,CAAOZ,QAAP,EAAiB,UAAUa,QAAV,EAAoB;AACjC,QAAI,CAAC,CAAEZ,aAAF,IAAmBA,aAAa,CAACY,QAAQ,CAACC,IAAV,CAAjC,MACCD,QAAQ,CAACE,KAAT,KAAmB,QAAnB,IAA+BF,QAAQ,CAACE,KAAT,KAAmB,UADnD,CAAJ,EACoE;AACpEZ,UAAI,CAACM,MAAL,CAAYI,QAAQ,CAACG,IAArB;AACAb,UAAI,CAACM,MAAL,CAAYI,QAAQ,CAACV,IAArB;AACD;AACF,GAND;;AAOA,SAAOA,IAAI,CAACc,MAAL,CAAY,KAAZ,CAAP;AACD,CAxBD;;AA0BAnB,aAAa,CAACoB,iCAAd,GACE,UAASC,eAAT,EAA0BC,cAA1B,EAA0C;AAC1C,QAAMjB,IAAI,GAAGR,MAAM,CAACS,UAAP,CAAkB,MAAlB,CAAb;AAEAD,MAAI,CAACM,MAAL,CAAYU,eAAZ,EAH0C,CAK1C;;AACA,QAAME,OAAO,GAAGC,MAAM,CAACC,IAAP,CAAYH,cAAZ,EAA4BI,IAA5B,EAAhB;;AACA,OAAK,IAAIC,MAAT,IAAmBJ,OAAnB,EAA4B;AAC1B,UAAMK,OAAO,GAAGN,cAAc,CAACK,MAAD,CAA9B;AACAtB,QAAI,CAACM,MAAL,CAAYgB,MAAZ;AACAtB,QAAI,CAACM,MAAL,CAAYiB,OAAZ;AACD;;AAED,SAAOvB,IAAI,CAACc,MAAL,CAAY,KAAZ,CAAP;AACD,CAfD,C","file":"/packages/webapp-hashing.js","sourcesContent":["var crypto = Npm.require(\"crypto\");\n\nWebAppHashing = {};\n\n// Calculate a hash of all the client resources downloaded by the\n// browser, including the application HTML, runtime config, code, and\n// static files.\n//\n// This hash *must* change if any resources seen by the browser\n// change, and ideally *doesn't* change for any server-only changes\n// (but the second is a performance enhancement, not a hard\n// requirement).\n\nWebAppHashing.calculateClientHash =\n function (manifest, includeFilter, runtimeConfigOverride) {\n var hash = crypto.createHash('sha1');\n\n // Omit the old hashed client values in the new hash. These may be\n // modified in the new boilerplate.\n var runtimeCfg = _.omit(__meteor_runtime_config__,\n ['autoupdateVersion', 'autoupdateVersionRefreshable',\n 'autoupdateVersionCordova']);\n\n if (runtimeConfigOverride) {\n runtimeCfg = runtimeConfigOverride;\n }\n\n hash.update(JSON.stringify(runtimeCfg, 'utf8'));\n\n _.each(manifest, function (resource) {\n if ((! includeFilter || includeFilter(resource.type)) &&\n (resource.where === 'client' || resource.where === 'internal')) {\n hash.update(resource.path);\n hash.update(resource.hash);\n }\n });\n return hash.digest('hex');\n};\n\nWebAppHashing.calculateCordovaCompatibilityHash =\n function(platformVersion, pluginVersions) {\n const hash = crypto.createHash('sha1');\n\n hash.update(platformVersion);\n\n // Sort plugins first so iteration order doesn't affect the hash\n const plugins = Object.keys(pluginVersions).sort();\n for (let plugin of plugins) {\n const version = pluginVersions[plugin];\n hash.update(plugin);\n hash.update(version);\n }\n\n return hash.digest('hex');\n};\n"]}