1 line
No EOL
305 KiB
Text
1 line
No EOL
305 KiB
Text
{"version":3,"sources":["webpack:///index.js","webpack:///webpack/bootstrap eeae6b4349509864cb29","webpack:///external \"winston\"","webpack:///./server/helpers/errorHandlers.js","webpack:///./server/models/index.js","webpack:///./config/siteConfig.js","webpack:///./server/helpers/googleAnalytics.js","webpack:///./server/helpers/lbryApi.js","webpack:///./server/controllers/serveController.js","webpack:///./server/speechPassport/index.js","webpack:///./server/controllers/publishController.js","webpack:///./server/helpers/publishHelpers.js","webpack:///./config/mysqlConfig.js","webpack:///external \"passport-local\"","webpack:///./server/helpers/sequelizeHelpers.js","webpack:///external \"sequelize\"","webpack:///./server/helpers/handlePageRender.jsx","webpack:///external \"react\"","webpack:///external \"react-dom/server\"","webpack:///external \"redux\"","webpack:///external \"react-redux\"","webpack:///external \"react-router-dom\"","webpack:///external \"spee.ch-components\"","webpack:///./server/helpers/renderFullPage.js","webpack:///external \"react-helmet\"","webpack:///./server/helpers/serveHelpers.js","webpack:///./server/helpers/lbryUri.js","webpack:///./server/helpers/handleShowRender.jsx","webpack:///external \"babel-polyfill\"","webpack:///external \"whatwg-fetch\"","webpack:///./speech.js","webpack:///./server/index.js","webpack:///external \"express\"","webpack:///external \"body-parser\"","webpack:///external \"express-handlebars\"","webpack:///external \"handlebars\"","webpack:///external \"helmet\"","webpack:///external \"cookie-session\"","webpack:///external \"http\"","webpack:///./server/middleware/requestLogger.js","webpack:///external \"path\"","webpack:///./config/loggerConfig.js","webpack:///./config/slackConfig.js","webpack:///external \"winston-slack-webhook\"","webpack:///external \"passport\"","webpack:///./server/speechPassport/local-login.js","webpack:///./server/models/certificate.js","webpack:///./server/models/channel.js","webpack:///./server/models/claim.js","webpack:///./server/models/file.js","webpack:///./server/models/request.js","webpack:///./server/models/user.js","webpack:///external \"bcrypt\"","webpack:///./server/speechPassport/local-signup.js","webpack:///external \"axios\"","webpack:///./config/lbryConfig.js","webpack:///external \"universal-analytics\"","webpack:///./server/helpers/authHelpers.js","webpack:///./server/routes/auth/index.js","webpack:///./server/routes/auth/signup.js","webpack:///./server/routes/auth/login.js","webpack:///./server/routes/auth/logout.js","webpack:///./server/routes/auth/user.js","webpack:///./server/routes/api/index.js","webpack:///./server/routes/api/channelAvailability.js","webpack:///external \"fs\"","webpack:///./server/routes/api/channelClaims.js","webpack:///./server/helpers/channelPagination.js","webpack:///./server/routes/api/channelData.js","webpack:///./server/routes/api/channelShortId.js","webpack:///./server/routes/api/claimAvailability.js","webpack:///./server/routes/api/claimData.js","webpack:///./server/routes/api/claimGet.js","webpack:///./server/routes/api/claimLongId.js","webpack:///./server/routes/api/claimPublish.js","webpack:///./server/auth/authentication.js","webpack:///./server/routes/api/claimResolve.js","webpack:///./server/routes/api/claimShortId.js","webpack:///./server/routes/api/claimList.js","webpack:///./server/routes/api/fileAvailability.js","webpack:///./server/helpers/multipartMiddleware.js","webpack:///external \"connect-multiparty\"","webpack:///./server/routes/pages/index.js","webpack:///./server/routes/pages/sendReactApp.js","webpack:///./server/routes/pages/sendEmbedPage.js","webpack:///./server/routes/pages/redirect.js","webpack:///./server/routes/assets/index.js","webpack:///./server/routes/assets/serveAssetByClaim.js","webpack:///external \"redux-saga\"","webpack:///external \"redux-saga/effects\"","webpack:///./server/routes/assets/serveAssetByIdentifierAndClaim.js","webpack:///./server/routes/fallback/index.js","webpack:///./server/routes/fallback/sendReactApp.js"],"names":["module","exports","modules","__webpack_require__","moduleId","installedModules","i","l","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","require","_slicedToArray","sliceIterator","arr","_arr","_n","_d","_e","undefined","_s","_i","Symbol","iterator","next","done","push","value","length","err","Array","isArray","TypeError","logger","handleErrorResponse","originalUrl","ip","error","res","useObjectPropertiesIfNoKeys","_module$exports$retur","returnErrorMessageAndStatus","_module$exports$retur2","status","message","json","createErrorResponsePayload","code","keys","newErrorObject","getOwnPropertyNames","forEach","key","success","Certificate","Channel","Claim","File","Request","User","Sequelize","_require","database","username","password","sequelize","host","dialect","dialectOptions","decimalNumbers","logging","pool","max","min","idle","acquire","authenticate","then","info","catch","db","import","modelName","associate","upsert","Model","values","condition","tableName","findOne","where","obj","debug","update","create","SiteConfig","_this","this","analytics","googleId","assetDefaults","description","thumbnail","title","auth","sessionKey","customComponents","components","containers","pages","details","port","twitter","publishing","additionalClaimAddresses","disabled","disabledMessage","primaryClaimAddress","thumbnailChannel","thumbnailChannelId","uploadDirectory","routes","config","console","log","createServeEventParams","headers","eventCategory","eventAction","eventLabel","ipOverride","userAgentOverride","createPublishTimingEventParams","category","variable","label","startTime","endTime","userTimingCategory","userTimingVariableName","userTimingTime","userTimingLabel","sendGoogleAnalyticsEvent","params","visitorId","replace","ua","strictCidFormat","https","event","sendGoogleAnalyticsTiming","timing","sendGAServeEvent","sendGATimingEvent","chooseGaLbrynetPublishLabel","_ref","channelName","channel_name","channelId","channel_id","axios","_require$api","api","apiHost","apiPort","lbryApiUri","_require2","handleLbrynetResponse","resolve","reject","data","result","Error","JSON","stringify","publishClaim","publishParams","gaStartTime","Date","now","Promise","post","method","response","getClaim","uri","timeout","getClaimList","claimName","resolveUri","_ref2","getDownloadDirectory","_ref3","download_directory","createChannel","amount","returnPaginatedChannelClaims","getClaimId","channelClaimId","claimId","getClaimIdByChannel","getClaimIdByClaim","getLongClaimId","longClaimId","getLongChannelId","longChannelId","all","getClaimIdByLongChannelId","getChannelData","page","longChannelClaimId","getShortChannelIdFromLongChannelId","_ref4","shortChannelClaimId","getChannelClaims","getAllChannelClaims","_ref5","_ref6","channelClaimsArray","paginatedChannelViewData","getLocalFileRecord","file","dataValues","passport","localLoginStrategy","localSignupStrategy","serializeSpeechUser","deserializeSpeechUser","deserializeUser","serializeUser","use","_defineProperty","writable","lbryApi","publishHelpers","_require$publishing","Op","publish","fileName","fileType","publishResults","certificateId","tx","channel","fileRecord","claim_id","metadata","address","claim_address","outpoint","txid","nout","height","filePath","file_path","nsfw","claimRecord","contentType","bid","upsertCriteria","claim","setClaim","setFile","deleteTemporaryFile","claimNameIsAvailable","claimAddresses","findAll","attributes","or","checkChannelAvailability","fs","parsePublishApiRequestBody","license","exec","parsePublishApiRequestFiles","path","type","size","test","validateFileTypeAndSize","thumbnailFileName","thumbnailFilePath","thumbnailFileType","createBasicPublishParams","trim","author","language","createThumbnailPublishParams","unlink","addGetResultsToFileData","fileInfo","getResult","file_name","download_path","createFileData","mysql","warn","returnShortId","claimsArray","longId","claimIndex","shortId","substring","shortIdLength","findIndex","element","possibleMatches","slice","filter","_interopRequireDefault","default","_react","_react2","_server","_redux","_reactRedux","_reactRouterDom","_spee","_renderFullPage","_renderFullPage2","_reactHelmet","_reactHelmet2","siteConfig","req","context","CustomizedReducers","Reducers","CustomizedApp","App","store","createStore","html","renderToString","createElement","Provider","StaticRouter","location","url","GAListener","helmet","renderStatic","redirect","preloadedState","getState","send","toString","meta","link","clientAcceptsHtml","accept","match","requestIsFromBrowser","clientWantsAsset","range","imageIsWanted","videoIsWanted","isValidClaimId","isValidShortId","isValidShortIdOrClaimId","input","serveAssetToClient","NO_FILE","verbose","sendFileOptions","X-Content-Type-Options","Content-Type","sendFile","getClaimIdAndServeAsset","fullClaimId","determineResponseType","hasFileExtension","responseType","flipClaimNameAndIdForBackwardsCompatibility","identifier","tempName","logRequestData","REGEXP_INVALID_CLAIM","REGEXP_INVALID_CHANNEL","REGEXP_ADDRESS","CHANNEL_CHAR","parseIdentifier","componentsRegex","RegExp","_componentsRegex$exec","map","_componentsRegex$exec2","proto","modifierSeperator","modifier","isChannel","startsWith","nameBadChars","join","parseClaim","_componentsRegex$exec3","_componentsRegex$exec4","parseModifier","_componentsRegex$exec5","_componentsRegex$exec6","_reduxSaga","_reduxSaga2","_effects","returnSagaWithParams","saga","regeneratorRuntime","mark","_callee","wrap","_context","prev","stop","sagaMiddleware","middleware","applyMiddleware","action","Actions","onHandleShowPageUri","Sagas","handleShowPageUri","run","Server","configureLogger","userConfig","loggerConfig","configureMysql","mysqlConfig","configureSiteDetails","configureSlack","slackConfig","configureClientBundle","configureModels","configureRoutes","createApp","app","express","enable","publicFolder","Path","process","cwd","static","publicPath","__dirname","bodyParser","urlencoded","extended","requestLogger","speechPassport","cookieSession","maxAge","initialize","session","hbs","expressHandlebars","defaultLayout","handlebars","Handlebars","engine","set","server","http","start","PORT","sync","listen","LoggerConfig","logLevel","configure","transports","Console","level","timestamp","colorize","prettyPrint","handleExceptions","humanReadableUnhandledException","silly","SlackConfig","slackWebHook","slackErrorChannel","slackInfoChannel","winston","add","winstonSlackWebHook","webhookUrl","iconEmoji","SlackWebHook","PassportLocalStrategy","Strategy","returnUserAndChannelInfo","userInstance","userInfo","id","userName","getChannel","shortChannelId","usernameField","passwordField","user","comparePassword","isMatch","STRING","BOOLEAN","INTEGER","TEXT","DECIMAL","define","claimSequence","decodedClaim","depth","effectiveAmount","hasSignature","hex","validAtHeight","valueVersion","claimType","certificateVersion","keyType","publicKey","freezeTableName","belongsTo","foreignKey","allowNull","order","getLongChannelIdFromShortChannelId","_this2","$like","getLongChannelIdFromChannelName","_this3","validateLongChannelId","_this4","hasOne","determineFileExtensionFromContentType","determineThumbnail","storedThumbnail","defaultThumbnail","prepareClaimData","licenseUrl","preview","metadataVersion","source","sourceType","sourceVersion","streamVersion","getShortClaimIdFromLongClaimId","raw","getLongClaimIdFromShortClaimId","getTopFreeClaimIdByClaimName","_this5","validateLongClaimId","_this6","resolveClaim","_this7","claimArray","defaultValue","trendingEligible","hasMany","getRecentClaims","limit","ipAddress","bcrypt","compare","changePassword","newPassword","genSalt","saltError","salt","hash","hashError","hook","options","userData","channelData","certificateData","newUser","newChannel","newCertificate","setChannel","setUser","lbryConfig","handleSignupRequest","handleLoginRequest","handleLogoutRequest","handleUserRequest","signup","login","logIn","logout","channelAvailability","channelClaims","channelShortId","claimAvailability","claimData","claimGet","claimLongId","claimPublish","claimResolve","claimShortId","claimList","fileAvailability","multipartMiddleware","_require3","availableName","body","claims","totalPages","determineTotalPages","paginationPage","getPageFromQuery","extractPageFromClaims","previousPage","determinePreviousPage","currentPage","nextPage","determineNextPage","totalResults","determineTotalClaims","parseInt","pageNumber","claimStartIndex","claimEndIndex","totalClaims","fullPages","Math","floor","channelShortIdRoute","claimInfo","resolveResult","fileData","_ref5$","completed","authenticateUser","_require4","_require5","_require6","files","channelPassword","_parsePublishApiReque","_parsePublishApiReque2","_ref3$","thumbnailPublishParams","lbryTx","authenticateChannelCredentials","userPassword","channelFindParams","resolvedUri","claimsList","multipart","uploadDir","handlePageRequest","handleEmbedRequest","handlePageRender","sendReactApp","sendEmbedPage","render","layout","route","serveAssetByClaim","serveAssetByIdentifierAndClaim","lbryUri","handleShowRender","serverAssetByClaim","serverAssetByIdentifierAndClaim","_lbryUri$parseIdentif","_flipClaimNameAndIdFo","_flipClaimNameAndIdFo2"],"mappings":"AAAAA,OAAOC,QACE,SAAUC,GCGnB,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAH,OAGA,IAAAD,GAAAK,EAAAD,IACAE,EAAAF,EACAG,GAAA,EACAN,WAUA,OANAC,GAAAE,GAAAI,KAAAR,EAAAC,QAAAD,IAAAC,QAAAE,GAGAH,EAAAO,GAAA,EAGAP,EAAAC,QAvBA,GAAAI,KA4DA,OAhCAF,GAAAM,EAAAP,EAGAC,EAAAO,EAAAL,EAGAF,EAAAQ,EAAA,SAAAV,EAAAW,EAAAC,GACAV,EAAAW,EAAAb,EAAAW,IACAG,OAAAC,eAAAf,EAAAW,GACAK,cAAA,EACAC,YAAA,EACAC,IAAAN,KAMAV,EAAAiB,EAAA,SAAApB,GACA,GAAAa,GAAAb,KAAAqB,WACA,WAA2B,MAAArB,GAAA,SAC3B,WAAiC,MAAAA,GAEjC,OADAG,GAAAQ,EAAAE,EAAA,IAAAA,GACAA,GAIAV,EAAAW,EAAA,SAAAQ,EAAAC,GAAsD,MAAAR,QAAAS,UAAAC,eAAAjB,KAAAc,EAAAC,IAGtDpB,EAAAuB,EAAA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AkBpP,EAC3D,IAlBY,UAkBRqP,EACF,MAAOiS,GAAiBjV,EAAK7R,EAI/BkH,GAAiB1B,EAAS1F,EAAID,EAE9B,IAAIyJ,SACJ,KACKA,EAAcud,EAAQ1Q,WAAW1P,EAAOqH,OAAxCxE,UACH,MAAOvJ,GACP,MAAOC,GAAIK,OAAO,KAAKE,MAAMQ,SAAS,EAAOT,QAASP,EAAMO,UAG9D,GAAIyV,UAAWzO,SAAa0C,SAAgBC,QAC5C,KAAI,GAAAgd,GACqDJ,EAAQvR,gBAAgB7O,EAAOsO,WAAnFgB,GADDkR,EACClR,UAAWzO,EADZ2f,EACY3f,YAAa0C,EADzBid,EACyBjd,eAAgBC,EADzCgd,EACyChd,QAC3C,MAAOlK,GACP,MAAOC,GAAIK,OAAO,KAAKE,MAAMQ,SAAS,EAAOT,QAASP,EAAMO,UAE9D,IAAKyV,EAAW,IAAAmR,GACSpS,EAA4C7K,EAASX,GAD9D6d,EAAA7oB,EAAA4oB,EAAA,EACbjd,GADakd,EAAA,GACJ7d,EADI6d,EAAA,GAIhBlS,EAAeJ,EAAcvL,EAAWhC,EAAa2C,GAErDwK,EAAwBnN,EAAa0C,EAAgBV,EAAWW,EAASpK,EAAaC,EAAIE,GAG5FvD,GAAOC,QAAUsqB,G1FiiIX,SAAUvqB,EAAQC,EAASE,GAEjC,Y2F5lIA,IAAMupB,GAAoBvpB,EAAQ,GAElCH,GAAOC,QAAU,SAACic,GAChBA,EAAI/a,IAAI,IAAKuoB,K3FomIT,SAAU1pB,EAAQC,EAASE,GAEjC,Y4FzmIA,IAAMypB,GAAmBzpB,EAAQ,IAE3B0pB,EAAe,SAACzU,EAAK7R,GACzBqmB,EAAiBxU,EAAK7R,GAGxBvD,GAAOC,QAAU4pB","file":"index.js","sourcesContent":["module.exports =\n/******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"/\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 26);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"winston\");\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"]) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); } }; }();\n\nvar logger = __webpack_require__(0);\n\nmodule.exports = {\n handleErrorResponse: function handleErrorResponse(originalUrl, ip, error, res) {\n logger.error('Error on ' + originalUrl, module.exports.useObjectPropertiesIfNoKeys(error));\n\n var _module$exports$retur = module.exports.returnErrorMessageAndStatus(error),\n _module$exports$retur2 = _slicedToArray(_module$exports$retur, 2),\n status = _module$exports$retur2[0],\n message = _module$exports$retur2[1];\n\n res.status(status).json(module.exports.createErrorResponsePayload(status, message));\n },\n returnErrorMessageAndStatus: function returnErrorMessageAndStatus(error) {\n var status = void 0,\n message = void 0;\n // check for daemon being turned off\n if (error.code === 'ECONNREFUSED') {\n status = 503;\n message = 'Connection refused. The daemon may not be running.';\n // fallback for everything else\n } else {\n status = 400;\n if (error.message) {\n message = error.message;\n } else {\n message = error;\n };\n };\n return [status, message];\n },\n useObjectPropertiesIfNoKeys: function useObjectPropertiesIfNoKeys(err) {\n if (Object.keys(err).length === 0) {\n var newErrorObject = {};\n Object.getOwnPropertyNames(err).forEach(function (key) {\n newErrorObject[key] = err[key];\n });\n return newErrorObject;\n }\n return err;\n },\n createErrorResponsePayload: function createErrorResponsePayload(status, message) {\n return {\n status: status,\n success: false,\n message: message\n };\n }\n};\n\n/***/ }),\n/* 2 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar Certificate = __webpack_require__(45);\nvar Channel = __webpack_require__(46);\nvar Claim = __webpack_require__(47);\nvar File = __webpack_require__(48);\nvar Request = __webpack_require__(49);\nvar User = __webpack_require__(50);\n\nvar Sequelize = __webpack_require__(13);\nvar logger = __webpack_require__(0);\n\nvar _require = __webpack_require__(10),\n database = _require.database,\n username = _require.username,\n password = _require.password;\n\n// set sequelize options\n\n\nvar sequelize = new Sequelize(database, username, password, {\n host: 'localhost',\n dialect: 'mysql',\n dialectOptions: { decimalNumbers: true },\n logging: false,\n pool: {\n max: 5,\n min: 0,\n idle: 10000,\n acquire: 10000\n }\n});\n\n// establish mysql connection\nsequelize.authenticate().then(function () {\n logger.info('Sequelize has established mysql connection successfully.');\n}).catch(function (err) {\n logger.error('Sequelize was unable to connect to the database:', err);\n});\n\n// manually add each model to the db object (note: make this dynamic)\nvar db = {};\ndb['Certificate'] = sequelize.import('Certificate', Certificate);\ndb['Channel'] = sequelize.import('Channel', Channel);\ndb['Claim'] = sequelize.import('Claim', Claim);\ndb['File'] = sequelize.import('File', File);\ndb['Request'] = sequelize.import('Request', Request);\ndb['User'] = sequelize.import('User', User);\n\n// run model.association for each model in the db object that has an association\nlogger.info('associating db models...');\nObject.keys(db).forEach(function (modelName) {\n if (db[modelName].associate) {\n logger.info('Associating model:', modelName);\n db[modelName].associate(db);\n }\n});\n\n// add sequelize/Sequelize to db\ndb.sequelize = sequelize;\ndb.Sequelize = Sequelize;\n// add an 'upsert' method to the db object\ndb.upsert = function (Model, values, condition, tableName) {\n return Model.findOne({\n where: condition\n }).then(function (obj) {\n if (obj) {\n // update\n logger.debug('updating record in db.' + tableName);\n return obj.update(values);\n } else {\n // insert\n logger.debug('creating record in db.' + tableName);\n return Model.create(values);\n }\n }).catch(function (error) {\n logger.error(tableName + '.upsert error', error);\n throw error;\n });\n};\n\nmodule.exports = db;\n\n/***/ }),\n/* 3 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nfunction SiteConfig() {\n var _this = this;\n\n this.analytics = {\n googleId: 'default'\n };\n this.assetDefaults = {\n description: 'An asset published on Spee.ch',\n thumbnail: 'https://spee.ch/assets/img/video_thumb_default.png',\n title: 'Spee.ch'\n };\n this.auth = {\n sessionKey: 'default'\n };\n this.customComponents = {\n components: {},\n containers: {},\n pages: {}\n };\n this.details = {\n description: 'Open-source, decentralized image and video sharing.',\n host: 'default',\n port: 3000,\n title: 'Spee.ch',\n twitter: '@spee_ch'\n };\n this.publishing = {\n additionalClaimAddresses: [],\n disabled: false,\n disabledMessage: 'Please check back soon.',\n primaryClaimAddress: 'default',\n thumbnailChannel: 'default',\n thumbnailChannelId: 'default',\n uploadDirectory: '/home/lbry/Uploads'\n };\n this.routes = {};\n this.update = function (config) {\n if (!config) {\n return console.log('No site config received.');\n }\n var analytics = config.analytics,\n assetDefaults = config.assetDefaults,\n auth = config.auth,\n customComponents = config.customComponents,\n details = config.details,\n publishing = config.publishing,\n routes = config.routes;\n\n console.log('Configuring site details...');\n _this.analytics = analytics;\n _this.assetDefaults = assetDefaults;\n _this.auth = auth;\n _this.details = details;\n _this.publishing = publishing;\n _this.customComponents = customComponents;\n _this.routes = routes;\n };\n};\n\nmodule.exports = new SiteConfig();\n\n/***/ }),\n/* 4 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar logger = __webpack_require__(0);\nvar ua = __webpack_require__(55);\n\nvar _require = __webpack_require__(3),\n googleId = _require.analytics.googleId,\n title = _require.details.title;\n\nfunction createServeEventParams(headers, ip, originalUrl) {\n return {\n eventCategory: 'client requests',\n eventAction: 'serve request',\n eventLabel: originalUrl,\n ipOverride: ip,\n userAgentOverride: headers['user-agent']\n };\n};\n\nfunction createPublishTimingEventParams(category, variable, label, startTime, endTime) {\n var duration = endTime - startTime;\n return {\n userTimingCategory: category,\n userTimingVariableName: variable,\n userTimingTime: duration,\n userTimingLabel: label\n };\n};\n\nfunction sendGoogleAnalyticsEvent(ip, params) {\n var visitorId = ip.replace(/\\./g, '-');\n var visitor = ua(googleId, visitorId, { strictCidFormat: false, https: true });\n visitor.event(params, function (err) {\n if (err) {\n logger.error('Google Analytics Event Error >>', err);\n }\n });\n};\n\nfunction sendGoogleAnalyticsTiming(visitorId, params) {\n var visitor = ua(googleId, visitorId, { strictCidFormat: false, https: true });\n visitor.timing(params, function (err) {\n if (err) {\n logger.error('Google Analytics Event Error >>', err);\n }\n logger.debug('Timing event successfully sent to google analytics');\n });\n};\n\nmodule.exports = {\n sendGAServeEvent: function sendGAServeEvent(headers, ip, originalUrl) {\n var params = createServeEventParams(headers, ip, originalUrl);\n sendGoogleAnalyticsEvent(ip, params);\n },\n sendGATimingEvent: function sendGATimingEvent(category, variable, label, startTime, endTime) {\n var params = createPublishTimingEventParams(category, variable, label, startTime, endTime);\n sendGoogleAnalyticsTiming(title, params);\n },\n chooseGaLbrynetPublishLabel: function chooseGaLbrynetPublishLabel(_ref) {\n var channelName = _ref.channel_name,\n channelId = _ref.channel_id;\n\n return channelName || channelId ? 'PUBLISH_IN_CHANNEL_CLAIM' : 'PUBLISH_ANONYMOUS_CLAIM';\n }\n};\n\n/***/ }),\n/* 5 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar axios = __webpack_require__(53);\nvar logger = __webpack_require__(0);\n\nvar _require = __webpack_require__(54),\n _require$api = _require.api,\n apiHost = _require$api.apiHost,\n apiPort = _require$api.apiPort;\n\nvar lbryApiUri = 'http://' + apiHost + ':' + apiPort;\n\nvar _require2 = __webpack_require__(4),\n chooseGaLbrynetPublishLabel = _require2.chooseGaLbrynetPublishLabel,\n sendGATimingEvent = _require2.sendGATimingEvent;\n\nvar handleLbrynetResponse = function handleLbrynetResponse(_ref, resolve, reject) {\n var data = _ref.data;\n\n logger.debug('lbry api data:', data);\n if (data.result) {\n // check for an error\n if (data.result.error) {\n logger.debug('Lbrynet api error:', data.result.error);\n reject(new Error(data.result.error));\n return;\n };\n resolve(data.result);\n return;\n }\n // fallback in case it just timed out\n reject(JSON.stringify(data));\n};\n\nmodule.exports = {\n publishClaim: function publishClaim(publishParams) {\n logger.debug('lbryApi >> Publishing claim to \"' + publishParams.name + '\"');\n var gaStartTime = Date.now();\n return new Promise(function (resolve, reject) {\n axios.post(lbryApiUri, {\n method: 'publish',\n params: publishParams\n }).then(function (response) {\n sendGATimingEvent('lbrynet', 'publish', chooseGaLbrynetPublishLabel(publishParams), gaStartTime, Date.now());\n handleLbrynetResponse(response, resolve, reject);\n }).catch(function (error) {\n reject(error);\n });\n });\n },\n getClaim: function getClaim(uri) {\n logger.debug('lbryApi >> Getting Claim for \"' + uri + '\"');\n var gaStartTime = Date.now();\n return new Promise(function (resolve, reject) {\n axios.post(lbryApiUri, {\n method: 'get',\n params: { uri: uri, timeout: 20 }\n }).then(function (response) {\n sendGATimingEvent('lbrynet', 'getClaim', 'GET', gaStartTime, Date.now());\n handleLbrynetResponse(response, resolve, reject);\n }).catch(function (error) {\n reject(error);\n });\n });\n },\n getClaimList: function getClaimList(claimName) {\n logger.debug('lbryApi >> Getting claim_list for \"' + claimName + '\"');\n var gaStartTime = Date.now();\n return new Promise(function (resolve, reject) {\n axios.post(lbryApiUri, {\n method: 'claim_list',\n params: { name: claimName }\n }).then(function (response) {\n sendGATimingEvent('lbrynet', 'getClaimList', 'CLAIM_LIST', gaStartTime, Date.now());\n handleLbrynetResponse(response, resolve, reject);\n }).catch(function (error) {\n reject(error);\n });\n });\n },\n resolveUri: function resolveUri(uri) {\n logger.debug('lbryApi >> Resolving URI for \"' + uri + '\"');\n var gaStartTime = Date.now();\n return new Promise(function (resolve, reject) {\n axios.post(lbryApiUri, {\n method: 'resolve',\n params: { uri: uri }\n }).then(function (_ref2) {\n var data = _ref2.data;\n\n sendGATimingEvent('lbrynet', 'resolveUri', 'RESOLVE', gaStartTime, Date.now());\n if (data.result[uri].error) {\n // check for errors\n reject(data.result[uri].error);\n } else {\n // if no errors, resolve\n resolve(data.result[uri]);\n }\n }).catch(function (error) {\n reject(error);\n });\n });\n },\n getDownloadDirectory: function getDownloadDirectory() {\n logger.debug('lbryApi >> Retrieving the download directory path from lbry daemon...');\n var gaStartTime = Date.now();\n return new Promise(function (resolve, reject) {\n axios.post(lbryApiUri, {\n method: 'settings_get'\n }).then(function (_ref3) {\n var data = _ref3.data;\n\n sendGATimingEvent('lbrynet', 'getDownloadDirectory', 'SETTINGS_GET', gaStartTime, Date.now());\n if (data.result) {\n resolve(data.result.download_directory);\n } else {\n return new Error('Successfully connected to lbry daemon, but unable to retrieve the download directory.');\n }\n }).catch(function (error) {\n logger.error('Lbrynet Error:', error);\n resolve('/home/lbry/Downloads/');\n });\n });\n },\n createChannel: function createChannel(name) {\n logger.debug('lbryApi >> Creating channel for ' + name + '...');\n var gaStartTime = Date.now();\n return new Promise(function (resolve, reject) {\n axios.post(lbryApiUri, {\n method: 'channel_new',\n params: {\n channel_name: name,\n amount: 0.1\n }\n }).then(function (response) {\n sendGATimingEvent('lbrynet', 'createChannel', 'CHANNEL_NEW', gaStartTime, Date.now());\n handleLbrynetResponse(response, resolve, reject);\n }).catch(function (error) {\n reject(error);\n });\n });\n }\n};\n\n/***/ }),\n/* 6 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"]) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); } }; }();\n\nvar db = __webpack_require__(2);\nvar logger = __webpack_require__(0);\n\nvar _require = __webpack_require__(66),\n returnPaginatedChannelClaims = _require.returnPaginatedChannelClaims;\n\nvar NO_CHANNEL = 'NO_CHANNEL';\nvar NO_CLAIM = 'NO_CLAIM';\nvar NO_FILE = 'NO_FILE';\n\nmodule.exports = {\n getClaimId: function getClaimId(channelName, channelClaimId, name, claimId) {\n if (channelName) {\n return module.exports.getClaimIdByChannel(channelName, channelClaimId, name);\n } else {\n return module.exports.getClaimIdByClaim(name, claimId);\n }\n },\n getClaimIdByClaim: function getClaimIdByClaim(claimName, claimId) {\n logger.debug('getClaimIdByClaim(' + claimName + ', ' + claimId + ')');\n return new Promise(function (resolve, reject) {\n db.Claim.getLongClaimId(claimName, claimId).then(function (longClaimId) {\n if (!longClaimId) {\n resolve(NO_CLAIM);\n }\n resolve(longClaimId);\n }).catch(function (error) {\n reject(error);\n });\n });\n },\n getClaimIdByChannel: function getClaimIdByChannel(channelName, channelClaimId, claimName) {\n logger.debug('getClaimIdByChannel(' + channelName + ', ' + channelClaimId + ', ' + claimName + ')');\n return new Promise(function (resolve, reject) {\n db.Certificate.getLongChannelId(channelName, channelClaimId) // 1. get the long channel id\n .then(function (longChannelId) {\n if (!longChannelId) {\n return [null, null];\n }\n return Promise.all([longChannelId, db.Claim.getClaimIdByLongChannelId(longChannelId, claimName)]); // 2. get the long claim id\n }).then(function (_ref) {\n var _ref2 = _slicedToArray(_ref, 2),\n longChannelId = _ref2[0],\n longClaimId = _ref2[1];\n\n if (!longChannelId) {\n return resolve(NO_CHANNEL);\n }\n if (!longClaimId) {\n return resolve(NO_CLAIM);\n }\n resolve(longClaimId);\n }).catch(function (error) {\n reject(error);\n });\n });\n },\n getChannelData: function getChannelData(channelName, channelClaimId, page) {\n return new Promise(function (resolve, reject) {\n // 1. get the long channel Id (make sure channel exists)\n db.Certificate.getLongChannelId(channelName, channelClaimId).then(function (longChannelClaimId) {\n if (!longChannelClaimId) {\n return [null, null, null];\n }\n // 2. get the short ID and all claims for that channel\n return Promise.all([longChannelClaimId, db.Certificate.getShortChannelIdFromLongChannelId(longChannelClaimId, channelName)]);\n }).then(function (_ref3) {\n var _ref4 = _slicedToArray(_ref3, 2),\n longChannelClaimId = _ref4[0],\n shortChannelClaimId = _ref4[1];\n\n if (!longChannelClaimId) {\n return resolve(NO_CHANNEL);\n }\n // 3. return all the channel information\n resolve({\n channelName: channelName,\n longChannelClaimId: longChannelClaimId,\n shortChannelClaimId: shortChannelClaimId\n });\n }).catch(function (error) {\n reject(error);\n });\n });\n },\n getChannelClaims: function getChannelClaims(channelName, channelClaimId, page) {\n return new Promise(function (resolve, reject) {\n // 1. get the long channel Id (make sure channel exists)\n db.Certificate.getLongChannelId(channelName, channelClaimId).then(function (longChannelClaimId) {\n if (!longChannelClaimId) {\n return [null, null, null];\n }\n // 2. get the short ID and all claims for that channel\n return Promise.all([longChannelClaimId, db.Claim.getAllChannelClaims(longChannelClaimId)]);\n }).then(function (_ref5) {\n var _ref6 = _slicedToArray(_ref5, 2),\n longChannelClaimId = _ref6[0],\n channelClaimsArray = _ref6[1];\n\n if (!longChannelClaimId) {\n return resolve(NO_CHANNEL);\n }\n // 3. format the data for the view, including pagination\n var paginatedChannelViewData = returnPaginatedChannelClaims(channelName, longChannelClaimId, channelClaimsArray, page);\n // 4. return all the channel information and contents\n resolve(paginatedChannelViewData);\n }).catch(function (error) {\n reject(error);\n });\n });\n },\n getLocalFileRecord: function getLocalFileRecord(claimId, name) {\n return db.File.findOne({ where: { claimId: claimId, name: name } }).then(function (file) {\n if (!file) {\n return NO_FILE;\n }\n return file.dataValues;\n });\n }\n};\n\n/***/ }),\n/* 7 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar passport = __webpack_require__(43);\nvar localLoginStrategy = __webpack_require__(44);\nvar localSignupStrategy = __webpack_require__(52);\n\nvar _require = __webpack_require__(56),\n serializeSpeechUser = _require.serializeSpeechUser,\n deserializeSpeechUser = _require.deserializeSpeechUser;\n\npassport.deserializeUser(deserializeSpeechUser);\npassport.serializeUser(serializeSpeechUser);\npassport.use('local-login', localLoginStrategy);\npassport.use('local-signup', localSignupStrategy);\n\nmodule.exports = passport;\n\n/***/ }),\n/* 8 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"]) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); } }; }();\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nvar logger = __webpack_require__(0);\nvar db = __webpack_require__(2);\nvar lbryApi = __webpack_require__(5);\nvar publishHelpers = __webpack_require__(9);\n\nvar _require = __webpack_require__(3),\n _require$publishing = _require.publishing,\n primaryClaimAddress = _require$publishing.primaryClaimAddress,\n additionalClaimAddresses = _require$publishing.additionalClaimAddresses;\n\nvar Sequelize = __webpack_require__(13);\nvar Op = Sequelize.Op;\n\nmodule.exports = {\n publish: function publish(publishParams, fileName, fileType) {\n return new Promise(function (resolve, reject) {\n var publishResults = void 0,\n certificateId = void 0,\n channelName = void 0;\n // publish the file\n return lbryApi.publishClaim(publishParams).then(function (tx) {\n logger.info('Successfully published ' + publishParams.name + ' ' + fileName, tx);\n publishResults = tx;\n // get the channel information\n if (publishParams.channel_name) {\n logger.debug('this claim was published in channel: ' + publishParams.channel_name);\n return db.Channel.findOne({\n where: {\n channelName: publishParams.channel_name\n }\n });\n } else {\n logger.debug('this claim was not published in a channel');\n return null;\n }\n }).then(function (channel) {\n // set channel information\n certificateId = null;\n channelName = null;\n if (channel) {\n certificateId = channel.channelClaimId;\n channelName = channel.channelName;\n }\n logger.debug('certificateId: ' + certificateId);\n }).then(function () {\n // create the File record\n var fileRecord = {\n name: publishParams.name,\n claimId: publishResults.claim_id,\n title: publishParams.metadata.title,\n description: publishParams.metadata.description,\n address: publishParams.claim_address,\n outpoint: publishResults.txid + ':' + publishResults.nout,\n height: 0,\n fileName: fileName,\n filePath: publishParams.file_path,\n fileType: fileType,\n nsfw: publishParams.metadata.nsfw\n };\n // create the Claim record\n var claimRecord = {\n name: publishParams.name,\n claimId: publishResults.claim_id,\n title: publishParams.metadata.title,\n description: publishParams.metadata.description,\n address: publishParams.claim_address,\n thumbnail: publishParams.metadata.thumbnail,\n outpoint: publishResults.txid + ':' + publishResults.nout,\n height: 0,\n contentType: fileType,\n nsfw: publishParams.metadata.nsfw,\n amount: publishParams.bid,\n certificateId: certificateId,\n channelName: channelName\n };\n // upsert criteria\n var upsertCriteria = {\n name: publishParams.name,\n claimId: publishResults.claim_id\n };\n // upsert the records\n return Promise.all([db.upsert(db.File, fileRecord, upsertCriteria, 'File'), db.upsert(db.Claim, claimRecord, upsertCriteria, 'Claim')]);\n }).then(function (_ref) {\n var _ref2 = _slicedToArray(_ref, 2),\n file = _ref2[0],\n claim = _ref2[1];\n\n logger.debug('File and Claim records successfully created');\n return Promise.all([file.setClaim(claim), claim.setFile(file)]);\n }).then(function () {\n logger.debug('File and Claim records successfully associated');\n resolve(publishResults); // resolve the promise with the result from lbryApi.publishClaim;\n }).catch(function (error) {\n logger.error('PUBLISH ERROR', error);\n publishHelpers.deleteTemporaryFile(publishParams.file_path); // delete the local file\n reject(error);\n });\n });\n },\n claimNameIsAvailable: function claimNameIsAvailable(name) {\n var claimAddresses = additionalClaimAddresses || [];\n claimAddresses.push(primaryClaimAddress);\n // find any records where the name is used\n return db.Claim.findAll({\n attributes: ['address'],\n where: {\n name: name,\n address: _defineProperty({}, Op.or, claimAddresses)\n }\n }).then(function (result) {\n if (result.length >= 1) {\n throw new Error('That claim is already in use');\n };\n return name;\n }).catch(function (error) {\n throw error;\n });\n },\n checkChannelAvailability: function checkChannelAvailability(name) {\n return db.Channel.findAll({\n where: { channelName: name }\n }).then(function (result) {\n if (result.length >= 1) {\n throw new Error('That channel has already been claimed');\n }\n return name;\n }).catch(function (error) {\n throw error;\n });\n }\n};\n\n/***/ }),\n/* 9 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar logger = __webpack_require__(0);\nvar fs = __webpack_require__(64);\n\nvar _require = __webpack_require__(3),\n details = _require.details,\n publishing = _require.publishing;\n\nmodule.exports = {\n parsePublishApiRequestBody: function parsePublishApiRequestBody(_ref) {\n var name = _ref.name,\n nsfw = _ref.nsfw,\n license = _ref.license,\n title = _ref.title,\n description = _ref.description,\n thumbnail = _ref.thumbnail;\n\n // validate name\n if (!name) {\n throw new Error('no name field found in request');\n }\n var invalidNameCharacters = /[^A-Za-z0-9,-]/.exec(name);\n if (invalidNameCharacters) {\n throw new Error('The claim name you provided is not allowed. Only the following characters are allowed: A-Z, a-z, 0-9, and \"-\"');\n }\n // optional parameters\n nsfw = nsfw === 'true';\n license = license || null;\n title = title || null;\n description = description || null;\n thumbnail = thumbnail || null;\n // return results\n return {\n name: name,\n nsfw: nsfw,\n license: license,\n title: title,\n description: description,\n thumbnail: thumbnail\n };\n },\n parsePublishApiRequestFiles: function parsePublishApiRequestFiles(_ref2) {\n var file = _ref2.file,\n thumbnail = _ref2.thumbnail;\n\n // make sure a file was provided\n if (!file) {\n throw new Error('no file with key of [file] found in request');\n }\n if (!file.path) {\n throw new Error('no file path found');\n }\n if (!file.type) {\n throw new Error('no file type found');\n }\n if (!file.size) {\n throw new Error('no file type found');\n }\n // validate the file name\n if (/'/.test(file.name)) {\n throw new Error('apostrophes are not allowed in the file name');\n }\n // validate the file\n module.exports.validateFileTypeAndSize(file);\n // return results\n return {\n fileName: file.name,\n filePath: file.path,\n fileType: file.type,\n thumbnailFileName: thumbnail ? thumbnail.name : null,\n thumbnailFilePath: thumbnail ? thumbnail.path : null,\n thumbnailFileType: thumbnail ? thumbnail.type : null\n };\n },\n validateFileTypeAndSize: function validateFileTypeAndSize(file) {\n // check file type and size\n switch (file.type) {\n case 'image/jpeg':\n case 'image/jpg':\n case 'image/png':\n if (file.size > 10000000) {\n logger.debug('publish > file validation > .jpeg/.jpg/.png was too big');\n throw new Error('Sorry, images are limited to 10 megabytes.');\n }\n break;\n case 'image/gif':\n if (file.size > 50000000) {\n logger.debug('publish > file validation > .gif was too big');\n throw new Error('Sorry, .gifs are limited to 50 megabytes.');\n }\n break;\n case 'video/mp4':\n if (file.size > 50000000) {\n logger.debug('publish > file validation > .mp4 was too big');\n throw new Error('Sorry, videos are limited to 50 megabytes.');\n }\n break;\n default:\n logger.debug('publish > file validation > unrecognized file type');\n throw new Error('The ' + file.type + ' content type is not supported. Only, .jpeg, .png, .gif, and .mp4 files are currently supported.');\n }\n return file;\n },\n createBasicPublishParams: function createBasicPublishParams(filePath, name, title, description, license, nsfw, thumbnail) {\n logger.debug('Creating Publish Parameters');\n // provide defaults for title\n if (title === null || title.trim() === '') {\n title = name;\n }\n // provide default for description\n if (description === null || description.trim() === '') {\n description = '';\n }\n // provide default for license\n if (license === null || license.trim() === '') {\n license = ' '; // default to empty string\n }\n // create the publish params\n var publishParams = {\n name: name,\n file_path: filePath,\n bid: 0.01,\n metadata: {\n description: description,\n title: title,\n author: details.title,\n language: 'en',\n license: license,\n nsfw: nsfw\n },\n claim_address: publishing.primaryClaimAddress\n };\n // add thumbnail to channel if video\n if (thumbnail) {\n publishParams['metadata']['thumbnail'] = thumbnail;\n }\n return publishParams;\n },\n createThumbnailPublishParams: function createThumbnailPublishParams(thumbnailFilePath, claimName, license, nsfw) {\n if (!thumbnailFilePath) {\n return;\n }\n logger.debug('Creating Thumbnail Publish Parameters');\n // create the publish params\n return {\n name: claimName + '-thumb',\n file_path: thumbnailFilePath,\n bid: 0.01,\n metadata: {\n title: claimName + ' thumbnail',\n description: 'a thumbnail for ' + claimName,\n author: details.title,\n language: 'en',\n license: license,\n nsfw: nsfw\n },\n claim_address: publishing.primaryClaimAddress,\n channel_name: publishing.thumbnailChannel,\n channel_id: publishing.thumbnailChannelId\n };\n },\n deleteTemporaryFile: function deleteTemporaryFile(filePath) {\n fs.unlink(filePath, function (err) {\n if (err) {\n logger.error('error deleting temporary file ' + filePath);\n throw err;\n }\n logger.debug('successfully deleted ' + filePath);\n });\n },\n addGetResultsToFileData: function addGetResultsToFileData(fileInfo, getResult) {\n fileInfo.fileName = getResult.file_name;\n fileInfo.filePath = getResult.download_path;\n return fileInfo;\n },\n createFileData: function createFileData(_ref3) {\n var name = _ref3.name,\n claimId = _ref3.claimId,\n outpoint = _ref3.outpoint,\n height = _ref3.height,\n address = _ref3.address,\n nsfw = _ref3.nsfw,\n contentType = _ref3.contentType;\n\n return {\n name: name,\n claimId: claimId,\n outpoint: outpoint,\n height: height,\n address: address,\n fileName: '',\n filePath: '',\n fileType: contentType,\n nsfw: nsfw\n };\n }\n};\n\n/***/ }),\n/* 10 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar logger = __webpack_require__(0);\n\nfunction mysql() {\n var _this = this;\n\n this.database = 'default';\n this.username = 'default';\n this.password = 'default';\n this.update = function (config) {\n if (!config) {\n return logger.warn('No MySQL config received.');\n }\n // configure credentials\n logger.info('configuring mysql...');\n var database = config.database,\n username = config.username,\n password = config.password;\n\n _this.database = database;\n _this.username = username;\n _this.password = password;\n };\n};\n\nmodule.exports = new mysql();\n\n/***/ }),\n/* 11 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"passport-local\");\n\n/***/ }),\n/* 12 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nmodule.exports = {\n returnShortId: function returnShortId(claimsArray, longId) {\n var claimIndex = void 0;\n var shortId = longId.substring(0, 1); // default short id is the first letter\n var shortIdLength = 0;\n // find the index of this claim id\n claimIndex = claimsArray.findIndex(function (element) {\n return element.claimId === longId;\n });\n if (claimIndex < 0) {\n throw new Error('claim id not found in claims list');\n }\n // get an array of all claims with lower height\n var possibleMatches = claimsArray.slice(0, claimIndex);\n // remove certificates with the same prefixes until none are left.\n while (possibleMatches.length > 0) {\n shortIdLength += 1;\n shortId = longId.substring(0, shortIdLength);\n possibleMatches = possibleMatches.filter(function (element) {\n return element.claimId && element.claimId.substring(0, shortIdLength) === shortId;\n });\n }\n return shortId;\n }\n};\n\n/***/ }),\n/* 13 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"sequelize\");\n\n/***/ }),\n/* 14 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar _react = __webpack_require__(15);\n\nvar _react2 = _interopRequireDefault(_react);\n\nvar _server = __webpack_require__(16);\n\nvar _redux = __webpack_require__(17);\n\nvar _reactRedux = __webpack_require__(18);\n\nvar _reactRouterDom = __webpack_require__(19);\n\nvar _spee = __webpack_require__(20);\n\nvar _renderFullPage = __webpack_require__(21);\n\nvar _renderFullPage2 = _interopRequireDefault(_renderFullPage);\n\nvar _reactHelmet = __webpack_require__(22);\n\nvar _reactHelmet2 = _interopRequireDefault(_reactHelmet);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n/*\n ^ note: to do this right, maybe\n these should be passed in from the implementation (www.spee.ch) itself,\n so that there are no conflicts between the SSR here and\n the bundle sent to the server?\n there might also be issues if this package uses a different version of spee.ch-components than www.spee.ch does?\n*/\nvar siteConfig = __webpack_require__(3);\n\nmodule.exports = function (req, res) {\n var context = {};\n\n // customize the reducer by passing in intial state configs\n var CustomizedReducers = (0, _spee.Reducers)(siteConfig);\n var CustomizedApp = (0, _spee.App)(siteConfig);\n\n // create a new Redux store instance\n var store = (0, _redux.createStore)(CustomizedReducers);\n\n // render component to a string\n var html = (0, _server.renderToString)(_react2.default.createElement(\n _reactRedux.Provider,\n { store: store },\n _react2.default.createElement(\n _reactRouterDom.StaticRouter,\n { location: req.url, context: context },\n _react2.default.createElement(\n _spee.GAListener,\n null,\n _react2.default.createElement(CustomizedApp, null)\n )\n )\n ));\n\n // get head tags from helmet\n var helmet = _reactHelmet2.default.renderStatic();\n\n // check for a redirect\n if (context.url) {\n // Somewhere a `<Redirect>` was rendered\n return res.redirect(301, context.url);\n } else {}\n // we're good, send the response\n\n\n // get the initial state from our Redux store\n var preloadedState = store.getState();\n\n // send the rendered page back to the client\n res.send((0, _renderFullPage2.default)(helmet, html, preloadedState));\n\n console.log('hello from spee.ch handlePageRender.jsx');\n};\n\n/***/ }),\n/* 15 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"react\");\n\n/***/ }),\n/* 16 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"react-dom/server\");\n\n/***/ }),\n/* 17 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"redux\");\n\n/***/ }),\n/* 18 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"react-redux\");\n\n/***/ }),\n/* 19 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"react-router-dom\");\n\n/***/ }),\n/* 20 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"spee.ch-components\");\n\n/***/ }),\n/* 21 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nmodule.exports = function (helmet, html, preloadedState) {\n // take the html and preloadedState and return the full page\n return '\\n <!DOCTYPE html>\\n <html lang=\"en\" prefix=\"og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#\">\\n <head>\\n <meta charset=\"UTF-8\">\\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no\">\\n <meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">\\n <!--helmet-->\\n ' + helmet.title.toString() + '\\n ' + helmet.meta.toString() + '\\n ' + helmet.link.toString() + '\\n <!--style sheets-->\\n <link rel=\"stylesheet\" href=\"/static/assets/css/reset.css\" type=\"text/css\">\\n <link rel=\"stylesheet\" href=\"/static/assets/css/general.css\" type=\"text/css\">\\n <link rel=\"stylesheet\" href=\"/static/assets/css/mediaQueries.css\" type=\"text/css\">\\n <!--google font-->\\n <link href=\"https://fonts.googleapis.com/css?family=Roboto:300\" rel=\"stylesheet\">\\n </head>\\n <body id=\"main-body\">\\n <div class=\"row row--tall flex-container--column\">\\n <div id=\"react-app\" class=\"row row--tall flex-container--column\">' + html + '</div>\\n </div>\\n <script>\\n window.__PRELOADED_STATE__ = ' + JSON.stringify(preloadedState).replace(/</g, '\\\\<') + '\\n </script>\\n <script src=\"/static/bundle/bundle.js\"></script>\\n </body>\\n </html>\\n ';\n};\n\n/***/ }),\n/* 22 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"react-helmet\");\n\n/***/ }),\n/* 23 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar logger = __webpack_require__(0);\n\nvar _require = __webpack_require__(6),\n getClaimId = _require.getClaimId,\n getLocalFileRecord = _require.getLocalFileRecord;\n\nvar _require2 = __webpack_require__(1),\n handleErrorResponse = _require2.handleErrorResponse;\n\nvar SERVE = 'SERVE';\nvar SHOW = 'SHOW';\nvar NO_FILE = 'NO_FILE';\nvar NO_CHANNEL = 'NO_CHANNEL';\nvar NO_CLAIM = 'NO_CLAIM';\n\nfunction clientAcceptsHtml(_ref) {\n var accept = _ref.accept;\n\n return accept && accept.match(/text\\/html/);\n};\n\nfunction requestIsFromBrowser(headers) {\n return headers['user-agent'] && headers['user-agent'].match(/Mozilla/);\n};\n\nfunction clientWantsAsset(_ref2) {\n var accept = _ref2.accept,\n range = _ref2.range;\n\n var imageIsWanted = accept && accept.match(/image\\/.*/) && !accept.match(/text\\/html/) && !accept.match(/text\\/\\*/);\n var videoIsWanted = accept && range;\n return imageIsWanted || videoIsWanted;\n};\n\nfunction isValidClaimId(claimId) {\n return claimId.length === 40 && !/[^A-Za-z0-9]/g.test(claimId);\n};\n\nfunction isValidShortId(claimId) {\n return claimId.length === 1; // it should really evaluate the short url itself\n};\n\nfunction isValidShortIdOrClaimId(input) {\n return isValidClaimId(input) || isValidShortId(input);\n};\n\nfunction serveAssetToClient(claimId, name, res) {\n return getLocalFileRecord(claimId, name).then(function (fileRecord) {\n // check that a local record was found\n if (fileRecord === NO_FILE) {\n return res.status(307).redirect('/api/claim/get/' + name + '/' + claimId);\n }\n // serve the file\n var filePath = fileRecord.filePath,\n fileType = fileRecord.fileType;\n\n logger.verbose('serving file: ' + filePath);\n var sendFileOptions = {\n headers: {\n 'X-Content-Type-Options': 'nosniff',\n 'Content-Type': fileType || 'image/jpeg'\n }\n };\n res.status(200).sendFile(filePath, sendFileOptions);\n }).catch(function (error) {\n throw error;\n });\n};\n\nmodule.exports = {\n getClaimIdAndServeAsset: function getClaimIdAndServeAsset(channelName, channelClaimId, claimName, claimId, originalUrl, ip, res) {\n // get the claim Id and then serve the asset\n getClaimId(channelName, channelClaimId, claimName, claimId).then(function (fullClaimId) {\n if (fullClaimId === NO_CLAIM) {\n return res.status(404).json({ success: false, message: 'no claim id could be found' });\n } else if (fullClaimId === NO_CHANNEL) {\n return res.status(404).json({ success: false, message: 'no channel id could be found' });\n }\n serveAssetToClient(fullClaimId, claimName, res);\n // postToStats(responseType, originalUrl, ip, claimName, fullClaimId, 'success');\n }).catch(function (error) {\n handleErrorResponse(originalUrl, ip, error, res);\n // postToStats(responseType, originalUrl, ip, claimName, fullClaimId, 'fail');\n });\n },\n determineResponseType: function determineResponseType(hasFileExtension, headers) {\n var responseType = void 0;\n if (hasFileExtension) {\n responseType = SERVE; // assume a serve request if file extension is present\n if (clientAcceptsHtml(headers)) {\n // if the request comes from a browser, change it to a show request\n responseType = SHOW;\n }\n } else {\n responseType = SHOW;\n if (clientWantsAsset(headers) && requestIsFromBrowser(headers)) {\n // this is in case someone embeds a show url\n logger.debug('Show request came from browser but wants an image/video. Changing response to serve...');\n responseType = SERVE;\n }\n }\n return responseType;\n },\n flipClaimNameAndIdForBackwardsCompatibility: function flipClaimNameAndIdForBackwardsCompatibility(identifier, name) {\n // this is a patch for backwards compatability with '/name/claim_id' url format\n if (isValidShortIdOrClaimId(name) && !isValidShortIdOrClaimId(identifier)) {\n var tempName = name;\n name = identifier;\n identifier = tempName;\n }\n return [identifier, name];\n },\n logRequestData: function logRequestData(responseType, claimName, channelName, claimId) {\n logger.debug('responseType ===', responseType);\n logger.debug('claim name === ', claimName);\n logger.debug('channel name ===', channelName);\n logger.debug('claim id ===', claimId);\n }\n};\n\n/***/ }),\n/* 24 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"]) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); } }; }();\n\nvar logger = __webpack_require__(0);\n\nmodule.exports = {\n REGEXP_INVALID_CLAIM: /[^A-Za-z0-9-]/g,\n REGEXP_INVALID_CHANNEL: /[^A-Za-z0-9-@]/g,\n REGEXP_ADDRESS: /^b(?=[^0OIl]{32,33})[0-9A-Za-z]{32,33}$/,\n CHANNEL_CHAR: '@',\n parseIdentifier: function parseIdentifier(identifier) {\n logger.debug('parsing identifier:', identifier);\n var componentsRegex = new RegExp('([^:$#/]*)' + // value (stops at the first separator or end)\n '([:$#]?)([^/]*)' // modifier separator, modifier (stops at the first path separator or end)\n );\n\n var _componentsRegex$exec = componentsRegex.exec(identifier).map(function (match) {\n return match || null;\n }),\n _componentsRegex$exec2 = _slicedToArray(_componentsRegex$exec, 4),\n proto = _componentsRegex$exec2[0],\n value = _componentsRegex$exec2[1],\n modifierSeperator = _componentsRegex$exec2[2],\n modifier = _componentsRegex$exec2[3];\n\n logger.debug(proto + ', ' + value + ', ' + modifierSeperator + ', ' + modifier);\n\n // Validate and process name\n if (!value) {\n throw new Error('Check your url. No channel name provided before \"' + modifierSeperator + '\"');\n }\n var isChannel = value.startsWith(module.exports.CHANNEL_CHAR);\n var channelName = isChannel ? value : null;\n var claimId = void 0;\n if (isChannel) {\n if (!channelName) {\n throw new Error('No channel name after @.');\n }\n var nameBadChars = channelName.match(module.exports.REGEXP_INVALID_CHANNEL);\n if (nameBadChars) {\n throw new Error('Invalid characters in channel name: ' + nameBadChars.join(', ') + '.');\n }\n } else {\n claimId = value;\n }\n\n // Validate and process modifier\n var channelClaimId = void 0;\n if (modifierSeperator) {\n if (!modifier) {\n throw new Error('No modifier provided after separator \"' + modifierSeperator + '\"');\n }\n\n if (modifierSeperator === ':') {\n channelClaimId = modifier;\n } else {\n throw new Error('The \"' + modifierSeperator + '\" modifier is not currently supported');\n }\n }\n return {\n isChannel: isChannel,\n channelName: channelName,\n channelClaimId: channelClaimId,\n claimId: claimId\n };\n },\n parseClaim: function parseClaim(claim) {\n logger.debug('parsing name:', claim);\n var componentsRegex = new RegExp('([^:$#/.]*)' + // name (stops at the first modifier)\n '([:$#.]?)([^/]*)' // modifier separator, modifier (stops at the first path separator or end)\n );\n\n var _componentsRegex$exec3 = componentsRegex.exec(claim).map(function (match) {\n return match || null;\n }),\n _componentsRegex$exec4 = _slicedToArray(_componentsRegex$exec3, 4),\n proto = _componentsRegex$exec4[0],\n claimName = _componentsRegex$exec4[1],\n modifierSeperator = _componentsRegex$exec4[2],\n modifier = _componentsRegex$exec4[3];\n\n logger.debug(proto + ', ' + claimName + ', ' + modifierSeperator + ', ' + modifier);\n\n // Validate and process name\n if (!claimName) {\n throw new Error('No claim name provided before .');\n }\n var nameBadChars = claimName.match(module.exports.REGEXP_INVALID_CLAIM);\n if (nameBadChars) {\n throw new Error('Invalid characters in claim name: ' + nameBadChars.join(', ') + '.');\n }\n // Validate and process modifier\n if (modifierSeperator) {\n if (!modifier) {\n throw new Error('No file extension provided after separator ' + modifierSeperator + '.');\n }\n if (modifierSeperator !== '.') {\n throw new Error('The ' + modifierSeperator + ' modifier is not supported in the claim name');\n }\n }\n // return results\n return {\n claimName: claimName\n };\n },\n parseModifier: function parseModifier(claim) {\n logger.debug('parsing modifier:', claim);\n var componentsRegex = new RegExp('([^:$#/.]*)' + // name (stops at the first modifier)\n '([:$#.]?)([^/]*)' // modifier separator, modifier (stops at the first path separator or end)\n );\n\n var _componentsRegex$exec5 = componentsRegex.exec(claim).map(function (match) {\n return match || null;\n }),\n _componentsRegex$exec6 = _slicedToArray(_componentsRegex$exec5, 4),\n proto = _componentsRegex$exec6[0],\n claimName = _componentsRegex$exec6[1],\n modifierSeperator = _componentsRegex$exec6[2],\n modifier = _componentsRegex$exec6[3];\n\n logger.debug(proto + ', ' + claimName + ', ' + modifierSeperator + ', ' + modifier);\n // Validate and process modifier\n var hasFileExtension = false;\n if (modifierSeperator) {\n hasFileExtension = true;\n }\n return {\n hasFileExtension: hasFileExtension\n };\n }\n};\n\n/***/ }),\n/* 25 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar _react = __webpack_require__(15);\n\nvar _react2 = _interopRequireDefault(_react);\n\nvar _server = __webpack_require__(16);\n\nvar _redux = __webpack_require__(17);\n\nvar _reactRedux = __webpack_require__(18);\n\nvar _reactRouterDom = __webpack_require__(19);\n\nvar _renderFullPage = __webpack_require__(21);\n\nvar _renderFullPage2 = _interopRequireDefault(_renderFullPage);\n\nvar _reduxSaga = __webpack_require__(87);\n\nvar _reduxSaga2 = _interopRequireDefault(_reduxSaga);\n\nvar _effects = __webpack_require__(88);\n\nvar _spee = __webpack_require__(20);\n\nvar _reactHelmet = __webpack_require__(22);\n\nvar _reactHelmet2 = _interopRequireDefault(_reactHelmet);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n// configure the reducers by passing initial state configs\nvar siteConfig = __webpack_require__(3);\n/*\n ^ note: to do this right, maybe\n these should be passed in from the implementation (www.spee.ch) itself,\n so that there are no conflicts between the SSR here and\n the bundle sent to the server?\n there might also be issues if this package uses a different version of spee.ch-components than www.spee.ch does?\n*/\n\nvar CustomizedReducers = (0, _spee.Reducers)(siteConfig);\nvar CustomizedApp = (0, _spee.App)(siteConfig);\n\nvar returnSagaWithParams = function returnSagaWithParams(saga, params) {\n return (/*#__PURE__*/regeneratorRuntime.mark(function _callee() {\n return regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0, _effects.call)(saga, params);\n\n case 2:\n case 'end':\n return _context.stop();\n }\n }\n }, _callee, this);\n })\n );\n};\n\nmodule.exports = function (req, res) {\n var context = {};\n\n // create and apply middleware\n var sagaMiddleware = (0, _reduxSaga2.default)();\n var middleware = (0, _redux.applyMiddleware)(sagaMiddleware);\n\n // create a new Redux store instance\n var store = (0, _redux.createStore)(CustomizedReducers, middleware);\n\n // create saga\n var action = _spee.Actions.onHandleShowPageUri(req.params);\n var saga = returnSagaWithParams(_spee.Sagas.handleShowPageUri, action);\n\n // run the saga middleware\n sagaMiddleware.run(saga).done.then(function () {\n // render component to a string\n var html = (0, _server.renderToString)(_react2.default.createElement(\n _reactRedux.Provider,\n { store: store },\n _react2.default.createElement(\n _reactRouterDom.StaticRouter,\n { location: req.url, context: context },\n _react2.default.createElement(\n _spee.GAListener,\n null,\n _react2.default.createElement(CustomizedApp, null)\n )\n )\n ));\n\n // get head tags from helmet\n var helmet = _reactHelmet2.default.renderStatic();\n\n // check for a redirect\n if (context.url) {\n return res.redirect(301, context.url);\n }\n\n // get the initial state from our Redux store\n var preloadedState = store.getState();\n\n // send the rendered page back to the client\n res.send((0, _renderFullPage2.default)(helmet, html, preloadedState));\n });\n\n console.log('hello from spee.ch handleShowRender.jsx');\n};\n\n/***/ }),\n/* 26 */\n/***/ (function(module, exports, __webpack_require__) {\n\n__webpack_require__(27);\n__webpack_require__(28);\nmodule.exports = __webpack_require__(29);\n\n\n/***/ }),\n/* 27 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"babel-polyfill\");\n\n/***/ }),\n/* 28 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"whatwg-fetch\");\n\n/***/ }),\n/* 29 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar Server = __webpack_require__(30);\n\nvar _exports = {\n Server: Server\n};\n\nmodule.exports = _exports;\n\n/***/ }),\n/* 30 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\n// app dependencies\nvar express = __webpack_require__(31);\nvar bodyParser = __webpack_require__(32);\nvar expressHandlebars = __webpack_require__(33);\nvar Handlebars = __webpack_require__(34);\nvar helmet = __webpack_require__(35);\nvar cookieSession = __webpack_require__(36);\nvar http = __webpack_require__(37);\nvar logger = __webpack_require__(0);\nvar requestLogger = __webpack_require__(38);\nvar Path = __webpack_require__(39);\nvar loggerConfig = __webpack_require__(40);\nvar mysqlConfig = __webpack_require__(10);\nvar siteConfig = __webpack_require__(3);\nvar slackConfig = __webpack_require__(41);\n\nfunction Server() {\n var _this = this;\n\n this.configureLogger = function (userConfig) {\n loggerConfig.update(userConfig);\n };\n this.configureMysql = function (userConfig) {\n mysqlConfig.update(userConfig);\n };\n this.configureSiteDetails = function (userConfig) {\n siteConfig.update(userConfig);\n };\n this.configureSlack = function (userConfig) {\n slackConfig.update(userConfig);\n };\n this.configureClientBundle = function () {\n logger.debug('configure the client here by passing in the bundle and configuring it, or better yet: taking in the components to use dynamically from here.');\n };\n this.configureModels = function () {\n logger.debug('here is where you could add/overwrite the default models');\n };\n this.configureRoutes = function () {\n logger.debug('here is where you could add/overwrite the default routes');\n };\n this.createApp = function () {\n // create an Express application\n var app = express();\n\n // trust the proxy to get ip address for us\n app.enable('trust proxy');\n\n /* add middleware */\n // set HTTP headers to protect against well-known web vulnerabilties\n app.use(helmet());\n // 'express.static' to serve static files from public directory\n if (siteConfig.routes.publicFolder) {\n // take in a different public folder, so it can serve it's own bundle if needed\n var publicFolder = Path.resolve(process.cwd(), siteConfig.routes.publicFolder);\n app.use('/static', express.static(publicFolder));\n logger.info('serving static files from custom path:', publicFolder);\n } else {\n var publicPath = Path.resolve(__dirname, 'public');\n app.use('/static', express.static(publicPath));\n logger.info('serving static files from default path:', publicPath);\n };\n // 'body parser' for parsing application/json\n app.use(bodyParser.json());\n // 'body parser' for parsing application/x-www-form-urlencoded\n app.use(bodyParser.urlencoded({ extended: true }));\n\n // add custom middleware (note: build out to accept dynamically use what is in server/middleware/\n app.use(requestLogger);\n\n // configure passport\n var speechPassport = __webpack_require__(7);\n // initialize passport\n var sessionKey = siteConfig.auth.sessionKey;\n app.use(cookieSession({\n name: 'session',\n keys: [sessionKey],\n maxAge: 24 * 60 * 60 * 1000 // i.e. 24 hours\n }));\n app.use(speechPassport.initialize());\n app.use(speechPassport.session());\n\n // configure handlebars & register it with express app\n var hbs = expressHandlebars.create({\n defaultLayout: 'embed',\n handlebars: Handlebars\n });\n app.engine('handlebars', hbs.engine);\n app.set('view engine', 'handlebars');\n\n // set the routes on the app\n __webpack_require__(57)(app);\n __webpack_require__(62)(app);\n __webpack_require__(81)(app);\n __webpack_require__(85)(app);\n __webpack_require__(90)(app);\n\n _this.app = app;\n };\n this.initialize = function () {\n _this.createApp();\n _this.server = http.Server(_this.app);\n };\n this.start = function () {\n var db = __webpack_require__(2);\n var PORT = siteConfig.details.port;\n // sync sequelize\n db.sequelize.sync()\n // start the server\n .then(function () {\n _this.server.listen(PORT, function () {\n logger.info('Server is listening on PORT ' + PORT);\n });\n }).catch(function (error) {\n logger.error('Startup Error:', error);\n });\n };\n};\n\nmodule.exports = Server;\n\n/***/ }),\n/* 31 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"express\");\n\n/***/ }),\n/* 32 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"body-parser\");\n\n/***/ }),\n/* 33 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"express-handlebars\");\n\n/***/ }),\n/* 34 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"handlebars\");\n\n/***/ }),\n/* 35 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"helmet\");\n\n/***/ }),\n/* 36 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"cookie-session\");\n\n/***/ }),\n/* 37 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"http\");\n\n/***/ }),\n/* 38 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar logger = __webpack_require__(0);\n\nvar requestLogger = function requestLogger(req, res, next) {\n // custom logging middleware to log all incoming http requests\n logger.verbose('Request on ' + req.originalUrl + ' from ' + req.ip);\n next();\n};\n\nmodule.exports = requestLogger;\n\n/***/ }),\n/* 39 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"path\");\n\n/***/ }),\n/* 40 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar logger = __webpack_require__(0);\n\nfunction LoggerConfig() {\n var _this = this;\n\n this.logLevel = 'debug';\n this.update = function (config) {\n if (!config) {\n return logger.warn('No logger config received.');\n }\n logger.info('configuring winston logger...');\n // update values with local config params\n var logLevel = config.logLevel;\n\n _this.logLevel = logLevel;\n // configure the winston logger\n logger.configure({\n transports: [new logger.transports.Console({\n level: _this.logLevel,\n timestamp: false,\n colorize: true,\n prettyPrint: true,\n handleExceptions: true,\n humanReadableUnhandledException: true\n })]\n });\n // test all the log levels\n logger.info('testing winston log levels...');\n logger.error('Level 0');\n logger.warn('Level 1');\n logger.info('Level 2');\n logger.verbose('Level 3');\n logger.debug('Level 4');\n logger.silly('Level 5');\n };\n};\n\nmodule.exports = new LoggerConfig();\n\n/***/ }),\n/* 41 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar winstonSlackWebHook = __webpack_require__(42).SlackWebHook;\nvar winston = __webpack_require__(0);\n\nfunction SlackConfig() {\n var _this = this;\n\n this.slackWebHook = 'default';\n this.slackErrorChannel = 'default';\n this.slackInfoChannel = 'default';\n this.update = function (config) {\n if (!config) {\n return winston.warn('No slack config received');\n }\n // update variables\n winston.info('configuring slack logger...');\n var slackWebHook = config.slackWebHook,\n slackErrorChannel = config.slackErrorChannel,\n slackInfoChannel = config.slackInfoChannel;\n\n _this.slackWebHook = slackWebHook;\n _this.slackErrorChannel = slackErrorChannel;\n _this.slackInfoChannel = slackInfoChannel;\n // update slack webhook settings\n if (_this.slackWebHook) {\n // add a transport for errors to slack\n if (_this.slackErrorChannel) {\n winston.add(winstonSlackWebHook, {\n name: 'slack-errors-transport',\n level: 'warn',\n webhookUrl: _this.slackWebHook,\n channel: _this.slackErrorChannel,\n username: 'spee.ch',\n iconEmoji: ':face_with_head_bandage:'\n });\n };\n if (slackInfoChannel) {\n winston.add(winstonSlackWebHook, {\n name: 'slack-info-transport',\n level: 'info',\n webhookUrl: _this.slackWebHook,\n channel: _this.slackInfoChannel,\n username: 'spee.ch',\n iconEmoji: ':nerd_face:'\n });\n };\n // send test messages\n winston.info('testing slack logger...');\n winston.error('Slack \"error\" logging is online.');\n winston.info('Slack \"info\" logging is online.');\n } else {\n winston.warn('Slack logging is not enabled because no slackWebHook config var provided.');\n }\n };\n};\n\nmodule.exports = new SlackConfig();\n\n/***/ }),\n/* 42 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"winston-slack-webhook\");\n\n/***/ }),\n/* 43 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"passport\");\n\n/***/ }),\n/* 44 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar PassportLocalStrategy = __webpack_require__(11).Strategy;\nvar logger = __webpack_require__(0);\nvar db = __webpack_require__(2);\n\nvar returnUserAndChannelInfo = function returnUserAndChannelInfo(userInstance) {\n return new Promise(function (resolve, reject) {\n var userInfo = {};\n userInfo['id'] = userInstance.id;\n userInfo['userName'] = userInstance.userName;\n userInstance.getChannel().then(function (_ref) {\n var channelName = _ref.channelName,\n channelClaimId = _ref.channelClaimId;\n\n userInfo['channelName'] = channelName;\n userInfo['channelClaimId'] = channelClaimId;\n return db.Certificate.getShortChannelIdFromLongChannelId(channelClaimId, channelName);\n }).then(function (shortChannelId) {\n userInfo['shortChannelId'] = shortChannelId;\n resolve(userInfo);\n }).catch(function (error) {\n reject(error);\n });\n });\n};\n\nmodule.exports = new PassportLocalStrategy({\n usernameField: 'username',\n passwordField: 'password'\n}, function (username, password, done) {\n return db.User.findOne({\n where: { userName: username }\n }).then(function (user) {\n if (!user) {\n logger.debug('no user found');\n return done(null, false, { message: 'Incorrect username or password' });\n }\n return user.comparePassword(password).then(function (isMatch) {\n if (!isMatch) {\n logger.debug('incorrect password');\n return done(null, false, { message: 'Incorrect username or password' });\n }\n logger.debug('Password was a match, returning User');\n return returnUserAndChannelInfo(user).then(function (userInfo) {\n return done(null, userInfo);\n }).catch(function (error) {\n return error;\n });\n }).catch(function (error) {\n return error;\n });\n }).catch(function (error) {\n return done(error);\n });\n});\n\n/***/ }),\n/* 45 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar logger = __webpack_require__(0);\n\nvar _require = __webpack_require__(12),\n returnShortId = _require.returnShortId;\n\nmodule.exports = function (sequelize, _ref) {\n var STRING = _ref.STRING,\n BOOLEAN = _ref.BOOLEAN,\n INTEGER = _ref.INTEGER,\n TEXT = _ref.TEXT,\n DECIMAL = _ref.DECIMAL;\n\n var Certificate = sequelize.define('Certificate', {\n address: {\n type: STRING,\n default: null\n },\n amount: {\n type: DECIMAL(19, 8),\n default: null\n },\n claimId: {\n type: STRING,\n default: null\n },\n claimSequence: {\n type: INTEGER,\n default: null\n },\n decodedClaim: {\n type: BOOLEAN,\n default: null\n },\n depth: {\n type: INTEGER,\n default: null\n },\n effectiveAmount: {\n type: DECIMAL(19, 8),\n default: null\n },\n hasSignature: {\n type: BOOLEAN,\n default: null\n },\n height: {\n type: INTEGER,\n default: null\n },\n hex: {\n type: TEXT('long'),\n default: null\n },\n name: {\n type: STRING,\n default: null\n },\n nout: {\n type: INTEGER,\n default: null\n },\n txid: {\n type: STRING,\n default: null\n },\n validAtHeight: {\n type: INTEGER,\n default: null\n },\n outpoint: {\n type: STRING,\n default: null\n },\n valueVersion: {\n type: STRING,\n default: null\n },\n claimType: {\n type: STRING,\n default: null\n },\n certificateVersion: {\n type: STRING,\n default: null\n },\n keyType: {\n type: STRING,\n default: null\n },\n publicKey: {\n type: TEXT('long'),\n default: null\n }\n }, {\n freezeTableName: true\n });\n\n Certificate.associate = function (db) {\n Certificate.belongsTo(db.Channel, {\n foreignKey: {\n allowNull: true\n }\n });\n };\n\n Certificate.getShortChannelIdFromLongChannelId = function (longChannelId, channelName) {\n var _this = this;\n\n logger.debug('getShortChannelIdFromLongChannelId ' + channelName + ':' + longChannelId);\n return new Promise(function (resolve, reject) {\n _this.findAll({\n where: { name: channelName },\n order: [['height', 'ASC']]\n }).then(function (result) {\n switch (result.length) {\n case 0:\n throw new Error('No channel(s) found with that channel name');\n default:\n return resolve(returnShortId(result, longChannelId));\n }\n }).catch(function (error) {\n reject(error);\n });\n });\n };\n\n Certificate.getLongChannelIdFromShortChannelId = function (channelName, channelClaimId) {\n var _this2 = this;\n\n logger.debug('getLongChannelIdFromShortChannelId(' + channelName + ', ' + channelClaimId + ')');\n return new Promise(function (resolve, reject) {\n _this2.findAll({\n where: {\n name: channelName,\n claimId: {\n $like: channelClaimId + '%'\n }\n },\n order: [['height', 'ASC']]\n }).then(function (result) {\n switch (result.length) {\n case 0:\n return resolve(null);\n default:\n // note results must be sorted\n return resolve(result[0].claimId);\n }\n }).catch(function (error) {\n reject(error);\n });\n });\n };\n\n Certificate.getLongChannelIdFromChannelName = function (channelName) {\n var _this3 = this;\n\n logger.debug('getLongChannelIdFromChannelName(' + channelName + ')');\n return new Promise(function (resolve, reject) {\n _this3.findAll({\n where: { name: channelName },\n order: [['effectiveAmount', 'DESC'], ['height', 'ASC']]\n }).then(function (result) {\n switch (result.length) {\n case 0:\n return resolve(null);\n default:\n return resolve(result[0].claimId);\n }\n }).catch(function (error) {\n reject(error);\n });\n });\n };\n\n Certificate.validateLongChannelId = function (name, claimId) {\n var _this4 = this;\n\n logger.debug('validateLongChannelId(' + name + ', ' + claimId + ')');\n return new Promise(function (resolve, reject) {\n _this4.findOne({\n where: { name: name, claimId: claimId }\n }).then(function (result) {\n if (!result) {\n return resolve(null);\n };\n resolve(claimId);\n }).catch(function (error) {\n reject(error);\n });\n });\n };\n\n Certificate.getLongChannelId = function (channelName, channelClaimId) {\n logger.debug('getLongChannelId(' + channelName + ', ' + channelClaimId + ')');\n if (channelClaimId && channelClaimId.length === 40) {\n // if a full channel id is provided\n return this.validateLongChannelId(channelName, channelClaimId);\n } else if (channelClaimId && channelClaimId.length < 40) {\n // if a short channel id is provided\n return this.getLongChannelIdFromShortChannelId(channelName, channelClaimId);\n } else {\n return this.getLongChannelIdFromChannelName(channelName); // if no channel id provided\n }\n };\n\n return Certificate;\n};\n\n/***/ }),\n/* 46 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nmodule.exports = function (sequelize, _ref) {\n var STRING = _ref.STRING;\n\n var Channel = sequelize.define('Channel', {\n channelName: {\n type: STRING,\n allowNull: false\n },\n channelClaimId: {\n type: STRING,\n allowNull: false\n }\n }, {\n freezeTableName: true\n });\n\n Channel.associate = function (db) {\n Channel.belongsTo(db.User);\n Channel.hasOne(db.Certificate);\n };\n\n return Channel;\n};\n\n/***/ }),\n/* 47 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar logger = __webpack_require__(0);\n\nvar _require = __webpack_require__(12),\n returnShortId = _require.returnShortId;\n\nvar _require2 = __webpack_require__(3),\n defaultThumbnail = _require2.assetDefaults.thumbnail,\n host = _require2.details.host;\n\nfunction determineFileExtensionFromContentType(contentType) {\n switch (contentType) {\n case 'image/jpeg':\n case 'image/jpg':\n return 'jpeg';\n case 'image/png':\n return 'png';\n case 'image/gif':\n return 'gif';\n case 'video/mp4':\n return 'mp4';\n default:\n logger.debug('setting unknown file type as file extension jpeg');\n return 'jpeg';\n }\n};\n\nfunction determineThumbnail(storedThumbnail, defaultThumbnail) {\n if (storedThumbnail === '') {\n return defaultThumbnail;\n }\n return storedThumbnail;\n};\n\nfunction prepareClaimData(claim) {\n // logger.debug('preparing claim data based on resolved data:', claim);\n claim['thumbnail'] = determineThumbnail(claim.thumbnail, defaultThumbnail);\n claim['fileExt'] = determineFileExtensionFromContentType(claim.contentType);\n claim['host'] = host;\n return claim;\n};\n\nmodule.exports = function (sequelize, _ref) {\n var STRING = _ref.STRING,\n BOOLEAN = _ref.BOOLEAN,\n INTEGER = _ref.INTEGER,\n TEXT = _ref.TEXT,\n DECIMAL = _ref.DECIMAL;\n\n var Claim = sequelize.define('Claim', {\n address: {\n type: STRING,\n default: null\n },\n amount: {\n type: DECIMAL(19, 8),\n default: null\n },\n claimId: {\n type: STRING,\n default: null\n },\n claimSequence: {\n type: INTEGER,\n default: null\n },\n decodedClaim: {\n type: BOOLEAN,\n default: null\n },\n depth: {\n type: INTEGER,\n default: null\n },\n effectiveAmount: {\n type: DECIMAL(19, 8),\n default: null\n },\n hasSignature: {\n type: BOOLEAN,\n default: null\n },\n height: {\n type: INTEGER,\n default: null\n },\n hex: {\n type: TEXT('long'),\n default: null\n },\n name: {\n type: STRING,\n default: null\n },\n nout: {\n type: INTEGER,\n default: null\n },\n txid: {\n type: STRING,\n default: null\n },\n validAtHeight: {\n type: INTEGER,\n default: null\n },\n outpoint: {\n type: STRING,\n default: null\n },\n claimType: {\n type: STRING,\n default: null\n },\n certificateId: {\n type: STRING,\n default: null\n },\n author: {\n type: STRING,\n default: null\n },\n description: {\n type: TEXT('long'),\n default: null\n },\n language: {\n type: STRING,\n default: null\n },\n license: {\n type: STRING,\n default: null\n },\n licenseUrl: {\n type: STRING,\n default: null\n },\n nsfw: {\n type: BOOLEAN,\n default: null\n },\n preview: {\n type: STRING,\n default: null\n },\n thumbnail: {\n type: STRING,\n default: null\n },\n title: {\n type: STRING,\n default: null\n },\n metadataVersion: {\n type: STRING,\n default: null\n },\n contentType: {\n type: STRING,\n default: null\n },\n source: {\n type: STRING,\n default: null\n },\n sourceType: {\n type: STRING,\n default: null\n },\n sourceVersion: {\n type: STRING,\n default: null\n },\n streamVersion: {\n type: STRING,\n default: null\n },\n valueVersion: {\n type: STRING,\n default: null\n },\n channelName: {\n type: STRING,\n allowNull: true,\n default: null\n }\n }, {\n freezeTableName: true\n });\n\n Claim.associate = function (db) {\n Claim.belongsTo(db.File, {\n foreignKey: {\n allowNull: true\n }\n });\n };\n\n Claim.getShortClaimIdFromLongClaimId = function (claimId, claimName) {\n var _this = this;\n\n logger.debug('Claim.getShortClaimIdFromLongClaimId for ' + claimName + '#' + claimId);\n return new Promise(function (resolve, reject) {\n _this.findAll({\n where: { name: claimName },\n order: [['height', 'ASC']]\n }).then(function (result) {\n switch (result.length) {\n case 0:\n throw new Error('No claim(s) found with that claim name');\n default:\n resolve(returnShortId(result, claimId));\n }\n }).catch(function (error) {\n reject(error);\n });\n });\n };\n\n Claim.getAllChannelClaims = function (channelClaimId) {\n var _this2 = this;\n\n logger.debug('Claim.getAllChannelClaims for ' + channelClaimId);\n return new Promise(function (resolve, reject) {\n _this2.findAll({\n where: { certificateId: channelClaimId },\n order: [['height', 'ASC']],\n raw: true // returns an array of only data, not an array of instances\n }).then(function (channelClaimsArray) {\n // logger.debug('channelclaimsarray length:', channelClaimsArray.length);\n switch (channelClaimsArray.length) {\n case 0:\n return resolve(null);\n default:\n channelClaimsArray.forEach(function (claim) {\n claim['fileExt'] = determineFileExtensionFromContentType(claim.contentType);\n claim['thumbnail'] = determineThumbnail(claim.thumbnail, defaultThumbnail);\n return claim;\n });\n return resolve(channelClaimsArray);\n }\n }).catch(function (error) {\n reject(error);\n });\n });\n };\n\n Claim.getClaimIdByLongChannelId = function (channelClaimId, claimName) {\n var _this3 = this;\n\n logger.debug('finding claim id for claim ' + claimName + ' from channel ' + channelClaimId);\n return new Promise(function (resolve, reject) {\n _this3.findAll({\n where: { name: claimName, certificateId: channelClaimId },\n order: [['id', 'ASC']]\n }).then(function (result) {\n switch (result.length) {\n case 0:\n return resolve(null);\n case 1:\n return resolve(result[0].claimId);\n default:\n logger.error(result.length + ' records found for \"' + claimName + '\" in channel \"' + channelClaimId + '\"');\n return resolve(result[0].claimId);\n }\n }).catch(function (error) {\n reject(error);\n });\n });\n };\n\n Claim.getLongClaimIdFromShortClaimId = function (name, shortId) {\n var _this4 = this;\n\n return new Promise(function (resolve, reject) {\n _this4.findAll({\n where: {\n name: name,\n claimId: {\n $like: shortId + '%'\n } },\n order: [['height', 'ASC']]\n }).then(function (result) {\n switch (result.length) {\n case 0:\n return resolve(null);\n default:\n // note results must be sorted\n return resolve(result[0].claimId);\n }\n }).catch(function (error) {\n reject(error);\n });\n });\n };\n\n Claim.getTopFreeClaimIdByClaimName = function (name) {\n var _this5 = this;\n\n return new Promise(function (resolve, reject) {\n _this5.findAll({\n where: { name: name },\n order: [['effectiveAmount', 'DESC'], ['height', 'ASC']] // note: maybe height and effective amount need to switch?\n }).then(function (result) {\n logger.debug('length of result', result.length);\n switch (result.length) {\n case 0:\n return resolve(null);\n default:\n return resolve(result[0].dataValues.claimId);\n }\n }).catch(function (error) {\n reject(error);\n });\n });\n };\n\n Claim.validateLongClaimId = function (name, claimId) {\n var _this6 = this;\n\n return new Promise(function (resolve, reject) {\n _this6.findOne({\n where: { name: name, claimId: claimId }\n }).then(function (result) {\n if (!result) {\n return resolve(null);\n };\n resolve(claimId);\n }).catch(function (error) {\n reject(error);\n });\n });\n };\n\n Claim.getLongClaimId = function (claimName, claimId) {\n logger.debug('getLongClaimId(' + claimName + ', ' + claimId + ')');\n if (claimId && claimId.length === 40) {\n // if a full claim id is provided\n return this.validateLongClaimId(claimName, claimId);\n } else if (claimId && claimId.length < 40) {\n return this.getLongClaimIdFromShortClaimId(claimName, claimId); // if a short claim id is provided\n } else {\n return this.getTopFreeClaimIdByClaimName(claimName); // if no claim id is provided\n }\n };\n\n Claim.resolveClaim = function (name, claimId) {\n var _this7 = this;\n\n logger.debug('Claim.resolveClaim: ' + name + ' ' + claimId);\n return new Promise(function (resolve, reject) {\n _this7.findAll({\n where: { name: name, claimId: claimId }\n }).then(function (claimArray) {\n switch (claimArray.length) {\n case 0:\n return resolve(null);\n case 1:\n return resolve(prepareClaimData(claimArray[0].dataValues));\n default:\n logger.error('more than one record matches ' + name + '#' + claimId + ' in db.Claim');\n return resolve(prepareClaimData(claimArray[0].dataValues));\n }\n }).catch(function (error) {\n reject(error);\n });\n });\n };\n\n return Claim;\n};\n\n/***/ }),\n/* 48 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nmodule.exports = function (sequelize, _ref) {\n var STRING = _ref.STRING,\n BOOLEAN = _ref.BOOLEAN,\n INTEGER = _ref.INTEGER;\n\n var File = sequelize.define('File', {\n name: {\n type: STRING,\n allowNull: false\n },\n claimId: {\n type: STRING,\n allowNull: false\n },\n address: {\n type: STRING,\n allowNull: false\n },\n outpoint: {\n type: STRING,\n allowNull: false\n },\n height: {\n type: INTEGER,\n allowNull: false,\n default: 0\n },\n fileName: {\n type: STRING,\n allowNull: false\n },\n filePath: {\n type: STRING,\n allowNull: false\n },\n fileType: {\n type: STRING\n },\n nsfw: {\n type: BOOLEAN,\n allowNull: false,\n defaultValue: false\n },\n trendingEligible: {\n type: BOOLEAN,\n allowNull: false,\n defaultValue: true\n }\n }, {\n freezeTableName: true\n });\n\n File.associate = function (db) {\n File.hasMany(db.Request);\n File.hasOne(db.Claim);\n };\n\n File.getRecentClaims = function () {\n return this.findAll({\n where: { nsfw: false, trendingEligible: true },\n order: [['createdAt', 'DESC']],\n limit: 25\n });\n };\n\n return File;\n};\n\n/***/ }),\n/* 49 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nmodule.exports = function (sequelize, _ref) {\n var STRING = _ref.STRING,\n BOOLEAN = _ref.BOOLEAN,\n TEXT = _ref.TEXT;\n\n var Request = sequelize.define('Request', {\n action: {\n type: STRING,\n allowNull: false\n },\n url: {\n type: STRING,\n allowNull: false\n },\n ipAddress: {\n type: STRING,\n allowNull: true\n },\n result: {\n type: TEXT('long'),\n allowNull: true,\n default: null\n }\n }, {\n freezeTableName: true\n });\n\n Request.associate = function (db) {\n Request.belongsTo(db.File, {\n foreignKey: {\n allowNull: true\n }\n });\n };\n\n return Request;\n};\n\n/***/ }),\n/* 50 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar bcrypt = __webpack_require__(51);\nvar logger = __webpack_require__(0);\n\nmodule.exports = function (sequelize, _ref) {\n var STRING = _ref.STRING;\n\n var User = sequelize.define('User', {\n userName: {\n type: STRING,\n allowNull: false\n },\n password: {\n type: STRING,\n allowNull: false\n }\n }, {\n freezeTableName: true\n });\n\n User.associate = function (db) {\n User.hasOne(db.Channel);\n };\n\n User.prototype.comparePassword = function (password) {\n return bcrypt.compare(password, this.password);\n };\n\n User.prototype.changePassword = function (newPassword) {\n var _this = this;\n\n return new Promise(function (resolve, reject) {\n // generate a salt string to use for hashing\n bcrypt.genSalt(function (saltError, salt) {\n if (saltError) {\n logger.error('salt error', saltError);\n reject(saltError);\n return;\n }\n // generate a hashed version of the user's password\n bcrypt.hash(newPassword, salt, function (hashError, hash) {\n // if there is an error with the hash generation return the error\n if (hashError) {\n logger.error('hash error', hashError);\n reject(hashError);\n return;\n }\n // replace the current password with the new hash\n _this.update({ password: hash }).then(function () {\n resolve();\n }).catch(function (error) {\n reject(error);\n });\n });\n });\n });\n };\n\n // pre-save hook method to hash the user's password before the user's info is saved to the db.\n User.hook('beforeCreate', function (user, options) {\n logger.debug('User.beforeCreate hook...');\n return new Promise(function (resolve, reject) {\n // generate a salt string to use for hashing\n bcrypt.genSalt(function (saltError, salt) {\n if (saltError) {\n logger.error('salt error', saltError);\n reject(saltError);\n return;\n }\n // generate a hashed version of the user's password\n bcrypt.hash(user.password, salt, function (hashError, hash) {\n // if there is an error with the hash generation return the error\n if (hashError) {\n logger.error('hash error', hashError);\n reject(hashError);\n return;\n }\n // replace the password string with the hash password value\n user.password = hash;\n resolve();\n });\n });\n });\n });\n\n return User;\n};\n\n/***/ }),\n/* 51 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"bcrypt\");\n\n/***/ }),\n/* 52 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"]) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); } }; }();\n\nvar PassportLocalStrategy = __webpack_require__(11).Strategy;\nvar lbryApi = __webpack_require__(5);\nvar logger = __webpack_require__(0);\nvar db = __webpack_require__(2);\n\nmodule.exports = new PassportLocalStrategy({\n usernameField: 'username',\n passwordField: 'password'\n}, function (username, password, done) {\n logger.verbose('new channel signup request. user: ' + username + ' pass: ' + password + ' .');\n var userInfo = {};\n // server-side validaton of inputs (username, password)\n\n // create the channel and retrieve the metadata\n return lbryApi.createChannel('@' + username).then(function (tx) {\n // create user record\n var userData = {\n userName: username,\n password: password\n };\n logger.verbose('userData >', userData);\n // create user record\n var channelData = {\n channelName: '@' + username,\n channelClaimId: tx.claim_id\n };\n logger.verbose('channelData >', channelData);\n // create certificate record\n var certificateData = {\n claimId: tx.claim_id,\n name: '@' + username\n // address,\n };\n logger.verbose('certificateData >', certificateData);\n // save user and certificate to db\n return Promise.all([db.User.create(userData), db.Channel.create(channelData), db.Certificate.create(certificateData)]);\n }).then(function (_ref) {\n var _ref2 = _slicedToArray(_ref, 3),\n newUser = _ref2[0],\n newChannel = _ref2[1],\n newCertificate = _ref2[2];\n\n logger.verbose('user and certificate successfully created');\n // store the relevant newUser info to be passed back for req.User\n userInfo['id'] = newUser.id;\n userInfo['userName'] = newUser.userName;\n userInfo['channelName'] = newChannel.channelName;\n userInfo['channelClaimId'] = newChannel.channelClaimId;\n // associate the instances\n return Promise.all([newCertificate.setChannel(newChannel), newChannel.setUser(newUser)]);\n }).then(function () {\n logger.verbose('user and certificate successfully associated');\n return db.Certificate.getShortChannelIdFromLongChannelId(userInfo.channelClaimId, userInfo.channelName);\n }).then(function (shortChannelId) {\n userInfo['shortChannelId'] = shortChannelId;\n return done(null, userInfo);\n }).catch(function (error) {\n logger.error('signup error', error);\n return done(error);\n });\n});\n\n/***/ }),\n/* 53 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"axios\");\n\n/***/ }),\n/* 54 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar lbryConfig = {\n api: {\n apiHost: 'localhost',\n apiPort: '5279'\n }\n};\n\nmodule.exports = lbryConfig;\n\n/***/ }),\n/* 55 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"universal-analytics\");\n\n/***/ }),\n/* 56 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nmodule.exports = {\n serializeSpeechUser: function serializeSpeechUser(user, done) {\n // returns user data to be serialized into session\n console.log('serializing user');\n done(null, user);\n },\n deserializeSpeechUser: function deserializeSpeechUser(user, done) {\n // deserializes session and populates additional info to req.user\n console.log('deserializing user');\n done(null, user);\n }\n};\n\n/***/ }),\n/* 57 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar speechPassport = __webpack_require__(7);\nvar handleSignupRequest = __webpack_require__(58);\nvar handleLoginRequest = __webpack_require__(59);\nvar handleLogoutRequest = __webpack_require__(60);\nvar handleUserRequest = __webpack_require__(61);\n\nmodule.exports = function (app) {\n app.post('/signup', speechPassport.authenticate('local-signup'), handleSignupRequest);\n app.post('/login', handleLoginRequest);\n app.get('/logout', handleLogoutRequest);\n app.get('/user', handleUserRequest);\n};\n\n/***/ }),\n/* 58 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar signup = function signup(req, res) {\n res.status(200).json({\n success: true,\n channelName: req.user.channelName,\n channelClaimId: req.user.channelClaimId,\n shortChannelId: req.user.shortChannelId\n });\n};\n\nmodule.exports = signup;\n\n/***/ }),\n/* 59 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar speechPassport = __webpack_require__(7);\n\nvar login = function login(req, res, next) {\n speechPassport.authenticate('local-login', function (err, user, info) {\n if (err) {\n return next(err);\n }\n if (!user) {\n return res.status(400).json({\n success: false,\n message: info.message\n });\n }\n req.logIn(user, function (err) {\n if (err) {\n return next(err);\n }\n return res.status(200).json({\n success: true,\n channelName: req.user.channelName,\n channelClaimId: req.user.channelClaimId,\n shortChannelId: req.user.shortChannelId\n });\n });\n })(req, res, next);\n};\n\nmodule.exports = login;\n\n/***/ }),\n/* 60 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar logout = function logout(req, res) {\n req.logout();\n res.status(200).json({ success: true, message: 'you successfully logged out' });\n};\n\nmodule.exports = logout;\n\n/***/ }),\n/* 61 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar user = function user(req, res) {\n if (req.user) {\n res.status(200).json({ success: true, data: req.user });\n } else {\n res.status(401).json({ success: false, message: 'user is not logged in' });\n }\n};\n\nmodule.exports = user;\n\n/***/ }),\n/* 62 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar channelAvailability = __webpack_require__(63);\nvar channelClaims = __webpack_require__(65);\nvar channelData = __webpack_require__(67);\nvar channelShortId = __webpack_require__(68);\nvar claimAvailability = __webpack_require__(69);\nvar claimData = __webpack_require__(70);\nvar claimGet = __webpack_require__(71);\nvar claimLongId = __webpack_require__(72);\nvar claimPublish = __webpack_require__(73);\nvar claimResolve = __webpack_require__(75);\nvar claimShortId = __webpack_require__(76);\nvar claimList = __webpack_require__(77);\nvar fileAvailability = __webpack_require__(78);\n\nvar multipartMiddleware = __webpack_require__(79);\n\nmodule.exports = function (app) {\n // channel routes\n app.get('/api/channel/availability/:name', channelAvailability);\n app.get('/api/channel/short-id/:longId/:name', channelShortId);\n app.get('/api/channel/data/:channelName/:channelClaimId', channelData);\n app.get('/api/channel/claims/:channelName/:channelClaimId/:page', channelClaims);\n // claim routes\n app.get('/api/claim/list/:name', claimList);\n app.get('/api/claim/get/:name/:claimId', claimGet);\n app.get('/api/claim/availability/:name', claimAvailability);\n app.get('/api/claim/resolve/:name/:claimId', claimResolve);\n app.post('/api/claim/publish', multipartMiddleware, claimPublish);\n app.get('/api/claim/short-id/:longId/:name', claimShortId);\n app.post('/api/claim/long-id', claimLongId);\n app.get('/api/claim/data/:claimName/:claimId', claimData);\n // file routes\n app.get('/api/file/availability/:name/:claimId', fileAvailability);\n};\n\n/***/ }),\n/* 63 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar _require = __webpack_require__(8),\n checkChannelAvailability = _require.checkChannelAvailability;\n\nvar _require2 = __webpack_require__(4),\n sendGATimingEvent = _require2.sendGATimingEvent;\n\nvar _require3 = __webpack_require__(1),\n handleErrorResponse = _require3.handleErrorResponse;\n\n/*\n\n route to check whether site has published to a channel\n\n*/\n\nvar channelAvailability = function channelAvailability(_ref, res) {\n var ip = _ref.ip,\n originalUrl = _ref.originalUrl,\n name = _ref.params.name;\n\n var gaStartTime = Date.now();\n checkChannelAvailability(name).then(function (availableName) {\n res.status(200).json(availableName);\n sendGATimingEvent('end-to-end', 'claim name availability', name, gaStartTime, Date.now());\n }).catch(function (error) {\n handleErrorResponse(originalUrl, ip, error, res);\n });\n};\n\nmodule.exports = channelAvailability;\n\n/***/ }),\n/* 64 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"fs\");\n\n/***/ }),\n/* 65 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar _require = __webpack_require__(6),\n getChannelClaims = _require.getChannelClaims;\n\nvar _require2 = __webpack_require__(1),\n handleErrorResponse = _require2.handleErrorResponse;\n\nvar NO_CHANNEL = 'NO_CHANNEL';\n\n/*\n\n route to get all claims for channel\n\n*/\n\nvar channelClaims = function channelClaims(_ref, res) {\n var ip = _ref.ip,\n originalUrl = _ref.originalUrl,\n body = _ref.body,\n params = _ref.params;\n\n var channelName = params.channelName;\n var channelClaimId = params.channelClaimId;\n if (channelClaimId === 'none') channelClaimId = null;\n var page = params.page;\n getChannelClaims(channelName, channelClaimId, page).then(function (data) {\n if (data === NO_CHANNEL) {\n return res.status(404).json({ success: false, message: 'No matching channel was found' });\n }\n res.status(200).json({ success: true, data: data });\n }).catch(function (error) {\n handleErrorResponse(originalUrl, ip, error, res);\n });\n};\n\nmodule.exports = channelClaims;\n\n/***/ }),\n/* 66 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar CLAIMS_PER_PAGE = 12;\n\nmodule.exports = {\n returnPaginatedChannelClaims: function returnPaginatedChannelClaims(channelName, longChannelClaimId, claims, page) {\n var totalPages = module.exports.determineTotalPages(claims);\n var paginationPage = module.exports.getPageFromQuery(page);\n var viewData = {\n channelName: channelName,\n longChannelClaimId: longChannelClaimId,\n claims: module.exports.extractPageFromClaims(claims, paginationPage),\n previousPage: module.exports.determinePreviousPage(paginationPage),\n currentPage: paginationPage,\n nextPage: module.exports.determineNextPage(totalPages, paginationPage),\n totalPages: totalPages,\n totalResults: module.exports.determineTotalClaims(claims)\n };\n return viewData;\n },\n getPageFromQuery: function getPageFromQuery(page) {\n if (page) {\n return parseInt(page);\n }\n return 1;\n },\n extractPageFromClaims: function extractPageFromClaims(claims, pageNumber) {\n if (!claims) {\n return []; // if no claims, return this default\n }\n // logger.debug('claims is array?', Array.isArray(claims));\n // logger.debug(`pageNumber ${pageNumber} is number?`, Number.isInteger(pageNumber));\n var claimStartIndex = (pageNumber - 1) * CLAIMS_PER_PAGE;\n var claimEndIndex = claimStartIndex + CLAIMS_PER_PAGE;\n var pageOfClaims = claims.slice(claimStartIndex, claimEndIndex);\n return pageOfClaims;\n },\n determineTotalPages: function determineTotalPages(claims) {\n if (!claims) {\n return 0;\n } else {\n var totalClaims = claims.length;\n if (totalClaims < CLAIMS_PER_PAGE) {\n return 1;\n }\n var fullPages = Math.floor(totalClaims / CLAIMS_PER_PAGE);\n var remainder = totalClaims % CLAIMS_PER_PAGE;\n if (remainder === 0) {\n return fullPages;\n }\n return fullPages + 1;\n }\n },\n determinePreviousPage: function determinePreviousPage(currentPage) {\n if (currentPage === 1) {\n return null;\n }\n return currentPage - 1;\n },\n determineNextPage: function determineNextPage(totalPages, currentPage) {\n if (currentPage === totalPages) {\n return null;\n }\n return currentPage + 1;\n },\n determineTotalClaims: function determineTotalClaims(claims) {\n if (!claims) {\n return 0;\n }\n return claims.length;\n }\n};\n\n/***/ }),\n/* 67 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar _require = __webpack_require__(6),\n getChannelData = _require.getChannelData;\n\nvar _require2 = __webpack_require__(1),\n handleErrorResponse = _require2.handleErrorResponse;\n\nvar NO_CHANNEL = 'NO_CHANNEL';\n\n/*\n\n route to get data for a channel\n\n*/\n\nvar channelData = function channelData(_ref, res) {\n var ip = _ref.ip,\n originalUrl = _ref.originalUrl,\n body = _ref.body,\n params = _ref.params;\n\n var channelName = params.channelName;\n var channelClaimId = params.channelClaimId;\n if (channelClaimId === 'none') channelClaimId = null;\n getChannelData(channelName, channelClaimId, 0).then(function (data) {\n if (data === NO_CHANNEL) {\n return res.status(404).json({ success: false, message: 'No matching channel was found' });\n }\n res.status(200).json({ success: true, data: data });\n }).catch(function (error) {\n handleErrorResponse(originalUrl, ip, error, res);\n });\n};\n\nmodule.exports = channelData;\n\n/***/ }),\n/* 68 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar _require = __webpack_require__(1),\n handleErrorResponse = _require.handleErrorResponse;\n\nvar db = __webpack_require__(2);\n\n/*\n\nroute to get a short channel id from long channel Id\n\n*/\n\nvar channelShortIdRoute = function channelShortIdRoute(_ref, res) {\n var ip = _ref.ip,\n originalUrl = _ref.originalUrl,\n params = _ref.params;\n\n db.Certificate.getShortChannelIdFromLongChannelId(params.longId, params.name).then(function (shortId) {\n res.status(200).json(shortId);\n }).catch(function (error) {\n handleErrorResponse(originalUrl, ip, error, res);\n });\n};\n\nmodule.exports = channelShortIdRoute;\n\n/***/ }),\n/* 69 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar _require = __webpack_require__(8),\n claimNameIsAvailable = _require.claimNameIsAvailable;\n\nvar _require2 = __webpack_require__(4),\n sendGATimingEvent = _require2.sendGATimingEvent;\n\nvar _require3 = __webpack_require__(1),\n handleErrorResponse = _require3.handleErrorResponse;\n\n/*\n\n route to check whether this site published to a claim\n\n*/\n\nvar claimAvailability = function claimAvailability(_ref, res) {\n var ip = _ref.ip,\n originalUrl = _ref.originalUrl,\n name = _ref.params.name;\n\n var gaStartTime = Date.now();\n claimNameIsAvailable(name).then(function (result) {\n res.status(200).json(result);\n sendGATimingEvent('end-to-end', 'claim name availability', name, gaStartTime, Date.now());\n }).catch(function (error) {\n handleErrorResponse(originalUrl, ip, error, res);\n });\n};\n\nmodule.exports = claimAvailability;\n\n/***/ }),\n/* 70 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar _require = __webpack_require__(1),\n handleErrorResponse = _require.handleErrorResponse;\n\nvar db = __webpack_require__(2);\n\n/*\n\n route to return data for a claim\n\n*/\n\nvar claimData = function claimData(_ref, res) {\n var ip = _ref.ip,\n originalUrl = _ref.originalUrl,\n body = _ref.body,\n params = _ref.params;\n\n var claimName = params.claimName;\n var claimId = params.claimId;\n if (claimId === 'none') claimId = null;\n db.Claim.resolveClaim(claimName, claimId).then(function (claimInfo) {\n if (!claimInfo) {\n return res.status(404).json({ success: false, message: 'No claim could be found' });\n }\n res.status(200).json({ success: true, data: claimInfo });\n }).catch(function (error) {\n handleErrorResponse(originalUrl, ip, error, res);\n });\n};\n\nmodule.exports = claimData;\n\n/***/ }),\n/* 71 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"]) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); } }; }();\n\nvar _require = __webpack_require__(5),\n getClaim = _require.getClaim;\n\nvar _require2 = __webpack_require__(9),\n addGetResultsToFileData = _require2.addGetResultsToFileData,\n createFileData = _require2.createFileData;\n\nvar _require3 = __webpack_require__(1),\n handleErrorResponse = _require3.handleErrorResponse;\n\nvar db = __webpack_require__(2);\n\n/*\n\n route to get a claim\n\n*/\n\nvar claimGet = function claimGet(_ref, res) {\n var ip = _ref.ip,\n originalUrl = _ref.originalUrl,\n params = _ref.params;\n\n var name = params.name;\n var claimId = params.claimId;\n // resolve the claim\n db.Claim.resolveClaim(name, claimId).then(function (resolveResult) {\n // make sure a claim actually exists at that uri\n if (!resolveResult) {\n throw new Error('No matching uri found in Claim table');\n }\n var fileData = createFileData(resolveResult);\n // get the claim\n return Promise.all([fileData, getClaim(name + '#' + claimId)]);\n }).then(function (_ref2) {\n var _ref3 = _slicedToArray(_ref2, 2),\n fileData = _ref3[0],\n getResult = _ref3[1];\n\n fileData = addGetResultsToFileData(fileData, getResult);\n return Promise.all([db.upsert(db.File, fileData, { name: name, claimId: claimId }, 'File'), getResult]);\n }).then(function (_ref4) {\n var _ref5 = _slicedToArray(_ref4, 2),\n fileRecord = _ref5[0],\n _ref5$ = _ref5[1],\n message = _ref5$.message,\n completed = _ref5$.completed;\n\n res.status(200).json({ success: true, message: message, completed: completed });\n }).catch(function (error) {\n handleErrorResponse(originalUrl, ip, error, res);\n });\n};\n\nmodule.exports = claimGet;\n\n/***/ }),\n/* 72 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar _require = __webpack_require__(6),\n getClaimId = _require.getClaimId;\n\nvar _require2 = __webpack_require__(1),\n handleErrorResponse = _require2.handleErrorResponse;\n\nvar NO_CHANNEL = 'NO_CHANNEL';\nvar NO_CLAIM = 'NO_CLAIM';\n\n/*\n\n route to get a long claim id\n\n*/\n\nvar claimLongId = function claimLongId(_ref, res) {\n var ip = _ref.ip,\n originalUrl = _ref.originalUrl,\n body = _ref.body,\n params = _ref.params;\n\n var channelName = body.channelName;\n var channelClaimId = body.channelClaimId;\n var claimName = body.claimName;\n var claimId = body.claimId;\n getClaimId(channelName, channelClaimId, claimName, claimId).then(function (result) {\n if (result === NO_CHANNEL) {\n return res.status(404).json({ success: false, message: 'No matching channel could be found' });\n }\n if (result === NO_CLAIM) {\n return res.status(404).json({ success: false, message: 'No matching claim id could be found' });\n }\n res.status(200).json({ success: true, data: result });\n }).catch(function (error) {\n handleErrorResponse(originalUrl, ip, error, res);\n });\n};\n\nmodule.exports = claimLongId;\n\n/***/ }),\n/* 73 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"]) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); } }; }();\n\nvar _require = __webpack_require__(9),\n createBasicPublishParams = _require.createBasicPublishParams,\n createThumbnailPublishParams = _require.createThumbnailPublishParams,\n parsePublishApiRequestBody = _require.parsePublishApiRequestBody,\n parsePublishApiRequestFiles = _require.parsePublishApiRequestFiles;\n\nvar _require2 = __webpack_require__(8),\n claimNameIsAvailable = _require2.claimNameIsAvailable,\n publish = _require2.publish;\n\nvar _require3 = __webpack_require__(74),\n authenticateUser = _require3.authenticateUser;\n\nvar _require4 = __webpack_require__(4),\n sendGATimingEvent = _require4.sendGATimingEvent;\n\nvar _require5 = __webpack_require__(1),\n handleErrorResponse = _require5.handleErrorResponse;\n\nvar _require6 = __webpack_require__(3),\n host = _require6.details.host;\n\n/*\n\n route to publish a claim through the daemon\n\n*/\n\nvar claimPublish = function claimPublish(_ref, res) {\n var body = _ref.body,\n files = _ref.files,\n headers = _ref.headers,\n ip = _ref.ip,\n originalUrl = _ref.originalUrl,\n user = _ref.user;\n\n // define variables\n var channelName = void 0,\n channelId = void 0,\n channelPassword = void 0,\n description = void 0,\n fileName = void 0,\n filePath = void 0,\n fileType = void 0,\n gaStartTime = void 0,\n license = void 0,\n name = void 0,\n nsfw = void 0,\n thumbnail = void 0,\n thumbnailFileName = void 0,\n thumbnailFilePath = void 0,\n thumbnailFileType = void 0,\n title = void 0;\n // record the start time of the request\n gaStartTime = Date.now();\n // validate the body and files of the request\n try {\n var _parsePublishApiReque = parsePublishApiRequestBody(body);\n // validateApiPublishRequest(body, files);\n\n\n name = _parsePublishApiReque.name;\n nsfw = _parsePublishApiReque.nsfw;\n license = _parsePublishApiReque.license;\n title = _parsePublishApiReque.title;\n description = _parsePublishApiReque.description;\n thumbnail = _parsePublishApiReque.thumbnail;\n\n var _parsePublishApiReque2 = parsePublishApiRequestFiles(files);\n\n fileName = _parsePublishApiReque2.fileName;\n filePath = _parsePublishApiReque2.filePath;\n fileType = _parsePublishApiReque2.fileType;\n thumbnailFileName = _parsePublishApiReque2.thumbnailFileName;\n thumbnailFilePath = _parsePublishApiReque2.thumbnailFilePath;\n thumbnailFileType = _parsePublishApiReque2.thumbnailFileType;\n channelName = body.channelName;\n channelId = body.channelId;\n channelPassword = body.channelPassword;\n } catch (error) {\n return res.status(400).json({ success: false, message: error.message });\n }\n // check channel authorization\n Promise.all([authenticateUser(channelName, channelId, channelPassword, user), claimNameIsAvailable(name), createBasicPublishParams(filePath, name, title, description, license, nsfw, thumbnail), createThumbnailPublishParams(thumbnailFilePath, name, license, nsfw)]).then(function (_ref2) {\n var _ref3 = _slicedToArray(_ref2, 4),\n _ref3$ = _ref3[0],\n channelName = _ref3$.channelName,\n channelClaimId = _ref3$.channelClaimId,\n validatedClaimName = _ref3[1],\n publishParams = _ref3[2],\n thumbnailPublishParams = _ref3[3];\n\n // add channel details to the publish params\n if (channelName && channelClaimId) {\n publishParams['channel_name'] = channelName;\n publishParams['channel_id'] = channelClaimId;\n }\n // publish the thumbnail\n if (thumbnailPublishParams) {\n publish(thumbnailPublishParams, thumbnailFileName, thumbnailFileType);\n }\n // publish the asset\n return publish(publishParams, fileName, fileType);\n }).then(function (result) {\n res.status(200).json({\n success: true,\n message: 'publish completed successfully',\n data: {\n name: name,\n claimId: result.claim_id,\n url: host + '/' + result.claim_id + '/' + name,\n lbryTx: result\n }\n });\n // record the publish end time and send to google analytics\n sendGATimingEvent('end-to-end', 'publish', fileType, gaStartTime, Date.now());\n }).catch(function (error) {\n handleErrorResponse(originalUrl, ip, error, res);\n });\n};\n\nmodule.exports = claimPublish;\n\n/***/ }),\n/* 74 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar db = __webpack_require__(2);\nvar logger = __webpack_require__(0);\n\nmodule.exports = {\n authenticateUser: function authenticateUser(channelName, channelId, channelPassword, user) {\n // case: no channelName or channel Id are provided (anonymous), regardless of whether user token is provided\n if (!channelName && !channelId) {\n return {\n channelName: null,\n channelClaimId: null\n };\n }\n // case: channelName or channel Id are provided with user token\n if (user) {\n if (channelName && channelName !== user.channelName) {\n throw new Error('the provided channel name does not match user credentials');\n }\n if (channelId && channelId !== user.channelClaimId) {\n throw new Error('the provided channel id does not match user credentials');\n }\n return {\n channelName: user.channelName,\n channelClaimId: user.channelClaimId\n };\n }\n // case: channelName or channel Id are provided with password instead of user token\n if (!channelPassword) throw new Error('no channel password provided');\n return module.exports.authenticateChannelCredentials(channelName, channelId, channelPassword);\n },\n authenticateChannelCredentials: function authenticateChannelCredentials(channelName, channelId, userPassword) {\n return new Promise(function (resolve, reject) {\n // hoisted variables\n var channelData = void 0;\n // build the params for finding the channel\n var channelFindParams = {};\n if (channelName) channelFindParams['channelName'] = channelName;\n if (channelId) channelFindParams['channelClaimId'] = channelId;\n // find the channel\n db.Channel.findOne({\n where: channelFindParams\n }).then(function (channel) {\n if (!channel) {\n logger.debug('no channel found');\n throw new Error('Authentication failed, you do not have access to that channel');\n }\n channelData = channel.get();\n logger.debug('channel data:', channelData);\n return db.User.findOne({\n where: { userName: channelData.channelName.substring(1) }\n });\n }).then(function (user) {\n if (!user) {\n logger.debug('no user found');\n throw new Error('Authentication failed, you do not have access to that channel');\n }\n return user.comparePassword(userPassword);\n }).then(function (isMatch) {\n if (!isMatch) {\n logger.debug('incorrect password');\n throw new Error('Authentication failed, you do not have access to that channel');\n }\n logger.debug('...password was a match...');\n resolve(channelData);\n }).catch(function (error) {\n reject(error);\n });\n });\n }\n};\n\n/***/ }),\n/* 75 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar _require = __webpack_require__(5),\n resolveUri = _require.resolveUri;\n\nvar _require2 = __webpack_require__(1),\n handleErrorResponse = _require2.handleErrorResponse;\n\n/*\n\n route to run a resolve request on the daemon\n\n*/\n\nvar claimResolve = function claimResolve(_ref, res) {\n var headers = _ref.headers,\n ip = _ref.ip,\n originalUrl = _ref.originalUrl,\n params = _ref.params;\n\n resolveUri(params.name + '#' + params.claimId).then(function (resolvedUri) {\n res.status(200).json(resolvedUri);\n }).catch(function (error) {\n handleErrorResponse(originalUrl, ip, error, res);\n });\n};\n\nmodule.exports = claimResolve;\n\n/***/ }),\n/* 76 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar _require = __webpack_require__(1),\n handleErrorResponse = _require.handleErrorResponse;\n\nvar db = __webpack_require__(2);\n\n/*\n\n route to get a short claim id from long claim Id\n\n*/\n\nvar claimShortId = function claimShortId(_ref, res) {\n var ip = _ref.ip,\n originalUrl = _ref.originalUrl,\n body = _ref.body,\n params = _ref.params;\n\n db.Claim.getShortClaimIdFromLongClaimId(params.longId, params.name).then(function (shortId) {\n res.status(200).json({ success: true, data: shortId });\n }).catch(function (error) {\n handleErrorResponse(originalUrl, ip, error, res);\n });\n};\n\nmodule.exports = claimShortId;\n\n/***/ }),\n/* 77 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar _require = __webpack_require__(5),\n getClaimList = _require.getClaimList;\n\nvar _require2 = __webpack_require__(1),\n handleErrorResponse = _require2.handleErrorResponse;\n\n/*\n\n route to get list of claims\n\n*/\n\nvar claimList = function claimList(_ref, res) {\n var ip = _ref.ip,\n originalUrl = _ref.originalUrl,\n params = _ref.params;\n\n getClaimList(params.name).then(function (claimsList) {\n res.status(200).json(claimsList);\n }).catch(function (error) {\n handleErrorResponse(originalUrl, ip, error, res);\n });\n};\n\nmodule.exports = claimList;\n\n/***/ }),\n/* 78 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar _require = __webpack_require__(1),\n handleErrorResponse = _require.handleErrorResponse;\n\nvar db = __webpack_require__(2);\n\n/*\n\n route to see if asset is available locally\n\n*/\n\nvar fileAvailability = function fileAvailability(_ref, res) {\n var ip = _ref.ip,\n originalUrl = _ref.originalUrl,\n params = _ref.params;\n\n var name = params.name;\n var claimId = params.claimId;\n db.File.findOne({\n where: {\n name: name,\n claimId: claimId\n }\n }).then(function (result) {\n if (result) {\n return res.status(200).json({ success: true, data: true });\n }\n res.status(200).json({ success: true, data: false });\n }).catch(function (error) {\n handleErrorResponse(originalUrl, ip, error, res);\n });\n};\n\nmodule.exports = fileAvailability;\n\n/***/ }),\n/* 79 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar multipart = __webpack_require__(80);\n\nvar _require = __webpack_require__(3),\n uploadDirectory = _require.publishing.uploadDirectory;\n\nvar multipartMiddleware = multipart({ uploadDir: uploadDirectory });\n\nmodule.exports = multipartMiddleware;\n\n/***/ }),\n/* 80 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"connect-multiparty\");\n\n/***/ }),\n/* 81 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar handlePageRequest = __webpack_require__(82);\nvar handleEmbedRequest = __webpack_require__(83);\nvar redirect = __webpack_require__(84);\n\nmodule.exports = function (app) {\n app.get('/', handlePageRequest);\n app.get('/login', handlePageRequest);\n app.get('/about', handlePageRequest);\n app.get('/trending', redirect('/popular'));\n app.get('/popular', handlePageRequest);\n app.get('/new', handlePageRequest);\n app.get('/embed/:claimId/:name', handleEmbedRequest); // route to send embedable video player (for twitter)\n};\n\n/***/ }),\n/* 82 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar handlePageRender = __webpack_require__(14);\n\nvar sendReactApp = function sendReactApp(req, res) {\n handlePageRender(req, res);\n};\n\nmodule.exports = sendReactApp;\n\n/***/ }),\n/* 83 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar _require = __webpack_require__(3),\n host = _require.details.host;\n\nvar sendEmbedPage = function sendEmbedPage(_ref, res) {\n var params = _ref.params;\n\n var claimId = params.claimId;\n var name = params.name;\n // get and render the content\n res.status(200).render('embed', { layout: 'embed', host: host, claimId: claimId, name: name });\n};\n\nmodule.exports = sendEmbedPage;\n\n/***/ }),\n/* 84 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar redirect = function redirect(route) {\n return function (req, res) {\n res.status(301).redirect(route);\n };\n};\n\nmodule.exports = redirect;\n\n/***/ }),\n/* 85 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar serveAssetByClaim = __webpack_require__(86);\nvar serveAssetByIdentifierAndClaim = __webpack_require__(89);\n\nmodule.exports = function (app, db) {\n app.get('/:identifier/:claim', serveAssetByIdentifierAndClaim);\n app.get('/:claim', serveAssetByClaim);\n};\n\n/***/ }),\n/* 86 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar _require = __webpack_require__(4),\n sendGAServeEvent = _require.sendGAServeEvent;\n\nvar _require2 = __webpack_require__(23),\n determineResponseType = _require2.determineResponseType,\n logRequestData = _require2.logRequestData,\n getClaimIdAndServeAsset = _require2.getClaimIdAndServeAsset;\n\nvar lbryUri = __webpack_require__(24);\nvar handleShowRender = __webpack_require__(25);\nvar SERVE = 'SERVE';\n\n/*\n\n route to serve an asset or the react app via the claim name only\n\n*/\n\nvar serverAssetByClaim = function serverAssetByClaim(req, res) {\n var headers = req.headers,\n ip = req.ip,\n originalUrl = req.originalUrl,\n params = req.params;\n // decide if this is a show request\n\n var hasFileExtension = void 0;\n try {\n var _lbryUri$parseModifie = lbryUri.parseModifier(params.claim);\n\n hasFileExtension = _lbryUri$parseModifie.hasFileExtension;\n } catch (error) {\n return res.status(400).json({ success: false, message: error.message });\n }\n var responseType = determineResponseType(hasFileExtension, headers);\n if (responseType !== SERVE) {\n return handleShowRender(req, res);\n }\n // handle serve request\n // send google analytics\n sendGAServeEvent(headers, ip, originalUrl);\n // parse the claim\n var claimName = void 0;\n try {\n var _lbryUri$parseClaim = lbryUri.parseClaim(params.claim);\n\n claimName = _lbryUri$parseClaim.claimName;\n } catch (error) {\n return res.status(400).json({ success: false, message: error.message });\n }\n // log the request data for debugging\n logRequestData(responseType, claimName, null, null);\n // get the claim Id and then serve the asset\n getClaimIdAndServeAsset(null, null, claimName, null, originalUrl, ip, res);\n};\n\nmodule.exports = serverAssetByClaim;\n\n/***/ }),\n/* 87 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"redux-saga\");\n\n/***/ }),\n/* 88 */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"redux-saga/effects\");\n\n/***/ }),\n/* 89 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"]) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); } }; }();\n\nvar _require = __webpack_require__(4),\n sendGAServeEvent = _require.sendGAServeEvent;\n\nvar _require2 = __webpack_require__(23),\n determineResponseType = _require2.determineResponseType,\n flipClaimNameAndIdForBackwardsCompatibility = _require2.flipClaimNameAndIdForBackwardsCompatibility,\n logRequestData = _require2.logRequestData,\n getClaimIdAndServeAsset = _require2.getClaimIdAndServeAsset;\n\nvar lbryUri = __webpack_require__(24);\nvar handleShowRender = __webpack_require__(25);\n\nvar SERVE = 'SERVE';\n\n/*\n\n route to serve an asset or the react app via the claim name and an identifier\n\n*/\n\nvar serverAssetByIdentifierAndClaim = function serverAssetByIdentifierAndClaim(req, res) {\n var headers = req.headers,\n ip = req.ip,\n originalUrl = req.originalUrl,\n params = req.params;\n // decide if this is a show request\n\n var hasFileExtension = void 0;\n try {\n var _lbryUri$parseModifie = lbryUri.parseModifier(params.claim);\n\n hasFileExtension = _lbryUri$parseModifie.hasFileExtension;\n } catch (error) {\n return res.status(400).json({ success: false, message: error.message });\n }\n var responseType = determineResponseType(hasFileExtension, headers);\n if (responseType !== SERVE) {\n return handleShowRender(req, res);\n }\n // handle serve request\n // send google analytics\n sendGAServeEvent(headers, ip, originalUrl);\n // parse the claim\n var claimName = void 0;\n try {\n var _lbryUri$parseClaim = lbryUri.parseClaim(params.claim);\n\n claimName = _lbryUri$parseClaim.claimName;\n } catch (error) {\n return res.status(400).json({ success: false, message: error.message });\n }\n // parse the identifier\n var isChannel = void 0,\n channelName = void 0,\n channelClaimId = void 0,\n claimId = void 0;\n try {\n var _lbryUri$parseIdentif = lbryUri.parseIdentifier(params.identifier);\n\n isChannel = _lbryUri$parseIdentif.isChannel;\n channelName = _lbryUri$parseIdentif.channelName;\n channelClaimId = _lbryUri$parseIdentif.channelClaimId;\n claimId = _lbryUri$parseIdentif.claimId;\n } catch (error) {\n return res.status(400).json({ success: false, message: error.message });\n }\n if (!isChannel) {\n var _flipClaimNameAndIdFo = flipClaimNameAndIdForBackwardsCompatibility(claimId, claimName);\n\n var _flipClaimNameAndIdFo2 = _slicedToArray(_flipClaimNameAndIdFo, 2);\n\n claimId = _flipClaimNameAndIdFo2[0];\n claimName = _flipClaimNameAndIdFo2[1];\n }\n // log the request data for debugging\n logRequestData(responseType, claimName, channelName, claimId);\n // get the claim Id and then serve the asset\n getClaimIdAndServeAsset(channelName, channelClaimId, claimName, claimId, originalUrl, ip, res);\n};\n\nmodule.exports = serverAssetByIdentifierAndClaim;\n\n/***/ }),\n/* 90 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar handlePageRequest = __webpack_require__(91);\n\nmodule.exports = function (app) {\n app.get('*', handlePageRequest);\n};\n\n/***/ }),\n/* 91 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar handlePageRender = __webpack_require__(14);\n\nvar sendReactApp = function sendReactApp(req, res) {\n handlePageRender(req, res);\n};\n\nmodule.exports = sendReactApp;\n\n/***/ })\n/******/ ]);\n\n\n// WEBPACK FOOTER //\n// index.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 26);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap eeae6b4349509864cb29","module.exports = require(\"winston\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"winston\"\n// module id = 0\n// module chunks = 0","const logger = require('winston');\n\nmodule.exports = {\n handleErrorResponse: function (originalUrl, ip, error, res) {\n logger.error(`Error on ${originalUrl}`, module.exports.useObjectPropertiesIfNoKeys(error));\n const [status, message] = module.exports.returnErrorMessageAndStatus(error);\n res\n .status(status)\n .json(module.exports.createErrorResponsePayload(status, message));\n },\n returnErrorMessageAndStatus: function (error) {\n let status, message;\n // check for daemon being turned off\n if (error.code === 'ECONNREFUSED') {\n status = 503;\n message = 'Connection refused. The daemon may not be running.';\n // fallback for everything else\n } else {\n status = 400;\n if (error.message) {\n message = error.message;\n } else {\n message = error;\n };\n };\n return [status, message];\n },\n useObjectPropertiesIfNoKeys: function (err) {\n if (Object.keys(err).length === 0) {\n let newErrorObject = {};\n Object.getOwnPropertyNames(err).forEach((key) => {\n newErrorObject[key] = err[key];\n });\n return newErrorObject;\n }\n return err;\n },\n createErrorResponsePayload (status, message) {\n return {\n status,\n success: false,\n message,\n };\n },\n};\n\n\n\n// WEBPACK FOOTER //\n// ./server/helpers/errorHandlers.js","const Certificate = require('models/certificate.js');\nconst Channel = require('models/channel.js');\nconst Claim = require('models/claim.js');\nconst File = require('models/file.js');\nconst Request = require('models/request.js');\nconst User = require('models/user.js');\n\nconst Sequelize = require('sequelize');\nconst logger = require('winston');\n\nconst {database, username, password} = require('mysqlConfig.js');\n\n// set sequelize options\nconst sequelize = new Sequelize(database, username, password, {\n host : 'localhost',\n dialect : 'mysql',\n dialectOptions: {decimalNumbers: true},\n logging : false,\n pool : {\n max : 5,\n min : 0,\n idle : 10000,\n acquire: 10000,\n },\n});\n\n// establish mysql connection\nsequelize\n .authenticate()\n .then(() => {\n logger.info('Sequelize has established mysql connection successfully.');\n })\n .catch(err => {\n logger.error('Sequelize was unable to connect to the database:', err);\n });\n\n// manually add each model to the db object (note: make this dynamic)\nconst db = {};\ndb['Certificate'] = sequelize.import('Certificate', Certificate);\ndb['Channel'] = sequelize.import('Channel', Channel);\ndb['Claim'] = sequelize.import('Claim', Claim);\ndb['File'] = sequelize.import('File', File);\ndb['Request'] = sequelize.import('Request', Request);\ndb['User'] = sequelize.import('User', User);\n\n// run model.association for each model in the db object that has an association\nlogger.info('associating db models...');\nObject.keys(db).forEach(modelName => {\n if (db[modelName].associate) {\n logger.info('Associating model:', modelName);\n db[modelName].associate(db);\n }\n});\n\n// add sequelize/Sequelize to db\ndb.sequelize = sequelize;\ndb.Sequelize = Sequelize;\n// add an 'upsert' method to the db object\ndb.upsert = (Model, values, condition, tableName) => {\n return Model\n .findOne({\n where: condition,\n })\n .then(obj => {\n if (obj) { // update\n logger.debug(`updating record in db.${tableName}`);\n return obj.update(values);\n } else { // insert\n logger.debug(`creating record in db.${tableName}`);\n return Model.create(values);\n }\n })\n .catch(function (error) {\n logger.error(`${tableName}.upsert error`, error);\n throw error;\n });\n};\n\nmodule.exports = db;\n\n\n\n// WEBPACK FOOTER //\n// ./server/models/index.js","function SiteConfig () {\n this.analytics = {\n googleId: 'default',\n };\n this.assetDefaults = {\n description: 'An asset published on Spee.ch',\n thumbnail : 'https://spee.ch/assets/img/video_thumb_default.png',\n title : 'Spee.ch',\n };\n this.auth = {\n sessionKey: 'default',\n };\n this.customComponents = {\n components: {},\n containers: {},\n pages : {},\n };\n this.details = {\n description: 'Open-source, decentralized image and video sharing.',\n host : 'default',\n port : 3000,\n title : 'Spee.ch',\n twitter : '@spee_ch',\n };\n this.publishing = {\n additionalClaimAddresses: [],\n disabled : false,\n disabledMessage : 'Please check back soon.',\n primaryClaimAddress : 'default',\n thumbnailChannel : 'default',\n thumbnailChannelId : 'default',\n uploadDirectory : '/home/lbry/Uploads',\n };\n this.routes = {};\n this.update = (config) => {\n if (!config) {\n return console.log('No site config received.');\n }\n const { analytics, assetDefaults, auth, customComponents, details, publishing, routes } = config;\n console.log('Configuring site details...');\n this.analytics = analytics;\n this.assetDefaults = assetDefaults;\n this.auth = auth;\n this.details = details;\n this.publishing = publishing;\n this.customComponents = customComponents;\n this.routes = routes;\n };\n};\n\nmodule.exports = new SiteConfig();\n\n\n\n// WEBPACK FOOTER //\n// ./config/siteConfig.js","const logger = require('winston');\nconst ua = require('universal-analytics');\nconst { analytics : { googleId }, details: { title } } = require('../../config/siteConfig.js');\n\nfunction createServeEventParams (headers, ip, originalUrl) {\n return {\n eventCategory : 'client requests',\n eventAction : 'serve request',\n eventLabel : originalUrl,\n ipOverride : ip,\n userAgentOverride: headers['user-agent'],\n };\n};\n\nfunction createPublishTimingEventParams (category, variable, label, startTime, endTime) {\n const duration = endTime - startTime;\n return {\n userTimingCategory : category,\n userTimingVariableName: variable,\n userTimingTime : duration,\n userTimingLabel : label,\n };\n};\n\nfunction sendGoogleAnalyticsEvent (ip, params) {\n const visitorId = ip.replace(/\\./g, '-');\n const visitor = ua(googleId, visitorId, { strictCidFormat: false, https: true });\n visitor.event(params, (err) => {\n if (err) {\n logger.error('Google Analytics Event Error >>', err);\n }\n });\n};\n\nfunction sendGoogleAnalyticsTiming (visitorId, params) {\n const visitor = ua(googleId, visitorId, { strictCidFormat: false, https: true });\n visitor.timing(params, (err) => {\n if (err) {\n logger.error('Google Analytics Event Error >>', err);\n }\n logger.debug(`Timing event successfully sent to google analytics`);\n });\n};\n\nmodule.exports = {\n sendGAServeEvent (headers, ip, originalUrl) {\n const params = createServeEventParams(headers, ip, originalUrl);\n sendGoogleAnalyticsEvent(ip, params);\n },\n sendGATimingEvent (category, variable, label, startTime, endTime) {\n const params = createPublishTimingEventParams(category, variable, label, startTime, endTime);\n sendGoogleAnalyticsTiming(title, params);\n },\n chooseGaLbrynetPublishLabel ({ channel_name: channelName, channel_id: channelId }) {\n return (channelName || channelId ? 'PUBLISH_IN_CHANNEL_CLAIM' : 'PUBLISH_ANONYMOUS_CLAIM');\n },\n};\n\n\n\n// WEBPACK FOOTER //\n// ./server/helpers/googleAnalytics.js","const axios = require('axios');\nconst logger = require('winston');\nconst { api: { apiHost, apiPort } } = require('../../config/lbryConfig.js');\nconst lbryApiUri = 'http://' + apiHost + ':' + apiPort;\nconst { chooseGaLbrynetPublishLabel, sendGATimingEvent } = require('./googleAnalytics.js');\n\nconst handleLbrynetResponse = ({ data }, resolve, reject) => {\n logger.debug('lbry api data:', data);\n if (data.result) {\n // check for an error\n if (data.result.error) {\n logger.debug('Lbrynet api error:', data.result.error);\n reject(new Error(data.result.error));\n return;\n };\n resolve(data.result);\n return;\n }\n // fallback in case it just timed out\n reject(JSON.stringify(data));\n};\n\nmodule.exports = {\n publishClaim (publishParams) {\n logger.debug(`lbryApi >> Publishing claim to \"${publishParams.name}\"`);\n const gaStartTime = Date.now();\n return new Promise((resolve, reject) => {\n axios\n .post(lbryApiUri, {\n method: 'publish',\n params: publishParams,\n })\n .then(response => {\n sendGATimingEvent('lbrynet', 'publish', chooseGaLbrynetPublishLabel(publishParams), gaStartTime, Date.now());\n handleLbrynetResponse(response, resolve, reject);\n })\n .catch(error => {\n reject(error);\n });\n });\n },\n getClaim (uri) {\n logger.debug(`lbryApi >> Getting Claim for \"${uri}\"`);\n const gaStartTime = Date.now();\n return new Promise((resolve, reject) => {\n axios\n .post(lbryApiUri, {\n method: 'get',\n params: { uri, timeout: 20 },\n })\n .then(response => {\n sendGATimingEvent('lbrynet', 'getClaim', 'GET', gaStartTime, Date.now());\n handleLbrynetResponse(response, resolve, reject);\n })\n .catch(error => {\n reject(error);\n });\n });\n },\n getClaimList (claimName) {\n logger.debug(`lbryApi >> Getting claim_list for \"${claimName}\"`);\n const gaStartTime = Date.now();\n return new Promise((resolve, reject) => {\n axios\n .post(lbryApiUri, {\n method: 'claim_list',\n params: { name: claimName },\n })\n .then(response => {\n sendGATimingEvent('lbrynet', 'getClaimList', 'CLAIM_LIST', gaStartTime, Date.now());\n handleLbrynetResponse(response, resolve, reject);\n })\n .catch(error => {\n reject(error);\n });\n });\n },\n resolveUri (uri) {\n logger.debug(`lbryApi >> Resolving URI for \"${uri}\"`);\n const gaStartTime = Date.now();\n return new Promise((resolve, reject) => {\n axios\n .post(lbryApiUri, {\n method: 'resolve',\n params: { uri },\n })\n .then(({ data }) => {\n sendGATimingEvent('lbrynet', 'resolveUri', 'RESOLVE', gaStartTime, Date.now());\n if (data.result[uri].error) { // check for errors\n reject(data.result[uri].error);\n } else { // if no errors, resolve\n resolve(data.result[uri]);\n }\n })\n .catch(error => {\n reject(error);\n });\n });\n },\n getDownloadDirectory () {\n logger.debug('lbryApi >> Retrieving the download directory path from lbry daemon...');\n const gaStartTime = Date.now();\n return new Promise((resolve, reject) => {\n axios\n .post(lbryApiUri, {\n method: 'settings_get',\n })\n .then(({ data }) => {\n sendGATimingEvent('lbrynet', 'getDownloadDirectory', 'SETTINGS_GET', gaStartTime, Date.now());\n if (data.result) {\n resolve(data.result.download_directory);\n } else {\n return new Error('Successfully connected to lbry daemon, but unable to retrieve the download directory.');\n }\n })\n .catch(error => {\n logger.error('Lbrynet Error:', error);\n resolve('/home/lbry/Downloads/');\n });\n });\n },\n createChannel (name) {\n logger.debug(`lbryApi >> Creating channel for ${name}...`);\n const gaStartTime = Date.now();\n return new Promise((resolve, reject) => {\n axios\n .post(lbryApiUri, {\n method: 'channel_new',\n params: {\n channel_name: name,\n amount : 0.1,\n },\n })\n .then(response => {\n sendGATimingEvent('lbrynet', 'createChannel', 'CHANNEL_NEW', gaStartTime, Date.now());\n handleLbrynetResponse(response, resolve, reject);\n })\n .catch(error => {\n reject(error);\n });\n });\n },\n};\n\n\n\n// WEBPACK FOOTER //\n// ./server/helpers/lbryApi.js","const db = require('models');\nconst logger = require('winston');\nconst { returnPaginatedChannelClaims } = require('helpers/channelPagination.js');\n\nconst NO_CHANNEL = 'NO_CHANNEL';\nconst NO_CLAIM = 'NO_CLAIM';\nconst NO_FILE = 'NO_FILE';\n\nmodule.exports = {\n getClaimId (channelName, channelClaimId, name, claimId) {\n if (channelName) {\n return module.exports.getClaimIdByChannel(channelName, channelClaimId, name);\n } else {\n return module.exports.getClaimIdByClaim(name, claimId);\n }\n },\n getClaimIdByClaim (claimName, claimId) {\n logger.debug(`getClaimIdByClaim(${claimName}, ${claimId})`);\n return new Promise((resolve, reject) => {\n db.Claim.getLongClaimId(claimName, claimId)\n .then(longClaimId => {\n if (!longClaimId) {\n resolve(NO_CLAIM);\n }\n resolve(longClaimId);\n })\n .catch(error => {\n reject(error);\n });\n });\n },\n getClaimIdByChannel (channelName, channelClaimId, claimName) {\n logger.debug(`getClaimIdByChannel(${channelName}, ${channelClaimId}, ${claimName})`);\n return new Promise((resolve, reject) => {\n db.Certificate.getLongChannelId(channelName, channelClaimId) // 1. get the long channel id\n .then(longChannelId => {\n if (!longChannelId) {\n return [null, null];\n }\n return Promise.all([longChannelId, db.Claim.getClaimIdByLongChannelId(longChannelId, claimName)]); // 2. get the long claim id\n })\n .then(([longChannelId, longClaimId]) => {\n if (!longChannelId) {\n return resolve(NO_CHANNEL);\n }\n if (!longClaimId) {\n return resolve(NO_CLAIM);\n }\n resolve(longClaimId);\n })\n .catch(error => {\n reject(error);\n });\n });\n },\n getChannelData (channelName, channelClaimId, page) {\n return new Promise((resolve, reject) => {\n // 1. get the long channel Id (make sure channel exists)\n db.Certificate.getLongChannelId(channelName, channelClaimId)\n .then(longChannelClaimId => {\n if (!longChannelClaimId) {\n return [null, null, null];\n }\n // 2. get the short ID and all claims for that channel\n return Promise.all([longChannelClaimId, db.Certificate.getShortChannelIdFromLongChannelId(longChannelClaimId, channelName)]);\n })\n .then(([longChannelClaimId, shortChannelClaimId]) => {\n if (!longChannelClaimId) {\n return resolve(NO_CHANNEL);\n }\n // 3. return all the channel information\n resolve({\n channelName,\n longChannelClaimId,\n shortChannelClaimId,\n });\n })\n .catch(error => {\n reject(error);\n });\n });\n },\n getChannelClaims (channelName, channelClaimId, page) {\n return new Promise((resolve, reject) => {\n // 1. get the long channel Id (make sure channel exists)\n db.Certificate.getLongChannelId(channelName, channelClaimId)\n .then(longChannelClaimId => {\n if (!longChannelClaimId) {\n return [null, null, null];\n }\n // 2. get the short ID and all claims for that channel\n return Promise.all([longChannelClaimId, db.Claim.getAllChannelClaims(longChannelClaimId)]);\n })\n .then(([longChannelClaimId, channelClaimsArray]) => {\n if (!longChannelClaimId) {\n return resolve(NO_CHANNEL);\n }\n // 3. format the data for the view, including pagination\n let paginatedChannelViewData = returnPaginatedChannelClaims(channelName, longChannelClaimId, channelClaimsArray, page);\n // 4. return all the channel information and contents\n resolve(paginatedChannelViewData);\n })\n .catch(error => {\n reject(error);\n });\n });\n },\n getLocalFileRecord (claimId, name) {\n return db.File.findOne({where: {claimId, name}})\n .then(file => {\n if (!file) {\n return NO_FILE;\n }\n return file.dataValues;\n });\n },\n};\n\n\n\n// WEBPACK FOOTER //\n// ./server/controllers/serveController.js","const passport = require('passport');\nconst localLoginStrategy = require('./local-login.js');\nconst localSignupStrategy = require('./local-signup.js');\nconst { serializeSpeechUser, deserializeSpeechUser } = require('helpers/authHelpers.js');\n\npassport.deserializeUser(deserializeSpeechUser);\npassport.serializeUser(serializeSpeechUser);\npassport.use('local-login', localLoginStrategy);\npassport.use('local-signup', localSignupStrategy);\n\nmodule.exports = passport;\n\n\n\n// WEBPACK FOOTER //\n// ./server/speechPassport/index.js","const logger = require('winston');\nconst db = require('models');\nconst lbryApi = require('helpers/lbryApi.js');\nconst publishHelpers = require('helpers/publishHelpers.js');\nconst { publishing: { primaryClaimAddress, additionalClaimAddresses } } = require('siteConfig.js');\nconst Sequelize = require('sequelize');\nconst Op = Sequelize.Op;\n\nmodule.exports = {\n publish (publishParams, fileName, fileType) {\n return new Promise((resolve, reject) => {\n let publishResults, certificateId, channelName;\n // publish the file\n return lbryApi.publishClaim(publishParams)\n .then(tx => {\n logger.info(`Successfully published ${publishParams.name} ${fileName}`, tx);\n publishResults = tx;\n // get the channel information\n if (publishParams.channel_name) {\n logger.debug(`this claim was published in channel: ${publishParams.channel_name}`);\n return db.Channel.findOne({\n where: {\n channelName: publishParams.channel_name,\n },\n });\n } else {\n logger.debug('this claim was not published in a channel');\n return null;\n }\n })\n .then(channel => {\n // set channel information\n certificateId = null;\n channelName = null;\n if (channel) {\n certificateId = channel.channelClaimId;\n channelName = channel.channelName;\n }\n logger.debug(`certificateId: ${certificateId}`);\n })\n .then(() => {\n // create the File record\n const fileRecord = {\n name : publishParams.name,\n claimId : publishResults.claim_id,\n title : publishParams.metadata.title,\n description: publishParams.metadata.description,\n address : publishParams.claim_address,\n outpoint : `${publishResults.txid}:${publishResults.nout}`,\n height : 0,\n fileName,\n filePath : publishParams.file_path,\n fileType,\n nsfw : publishParams.metadata.nsfw,\n };\n // create the Claim record\n const claimRecord = {\n name : publishParams.name,\n claimId : publishResults.claim_id,\n title : publishParams.metadata.title,\n description: publishParams.metadata.description,\n address : publishParams.claim_address,\n thumbnail : publishParams.metadata.thumbnail,\n outpoint : `${publishResults.txid}:${publishResults.nout}`,\n height : 0,\n contentType: fileType,\n nsfw : publishParams.metadata.nsfw,\n amount : publishParams.bid,\n certificateId,\n channelName,\n };\n // upsert criteria\n const upsertCriteria = {\n name : publishParams.name,\n claimId: publishResults.claim_id,\n };\n // upsert the records\n return Promise.all([db.upsert(db.File, fileRecord, upsertCriteria, 'File'), db.upsert(db.Claim, claimRecord, upsertCriteria, 'Claim')]);\n })\n .then(([file, claim]) => {\n logger.debug('File and Claim records successfully created');\n return Promise.all([file.setClaim(claim), claim.setFile(file)]);\n })\n .then(() => {\n logger.debug('File and Claim records successfully associated');\n resolve(publishResults); // resolve the promise with the result from lbryApi.publishClaim;\n })\n .catch(error => {\n logger.error('PUBLISH ERROR', error);\n publishHelpers.deleteTemporaryFile(publishParams.file_path); // delete the local file\n reject(error);\n });\n });\n },\n claimNameIsAvailable (name) {\n const claimAddresses = additionalClaimAddresses || [];\n claimAddresses.push(primaryClaimAddress);\n // find any records where the name is used\n return db.Claim\n .findAll({\n attributes: ['address'],\n where : {\n name,\n address: {\n [Op.or]: claimAddresses,\n },\n },\n })\n .then(result => {\n if (result.length >= 1) {\n throw new Error('That claim is already in use');\n };\n return name;\n })\n .catch(error => {\n throw error;\n });\n },\n checkChannelAvailability (name) {\n return db.Channel\n .findAll({\n where: { channelName: name },\n })\n .then(result => {\n if (result.length >= 1) {\n throw new Error('That channel has already been claimed');\n }\n return name;\n })\n .catch(error => {\n throw error;\n });\n },\n};\n\n\n\n// WEBPACK FOOTER //\n// ./server/controllers/publishController.js","const logger = require('winston');\nconst fs = require('fs');\n\nconst { details, publishing } = require('../../config/siteConfig.js');\n\nmodule.exports = {\n parsePublishApiRequestBody ({name, nsfw, license, title, description, thumbnail}) {\n // validate name\n if (!name) {\n throw new Error('no name field found in request');\n }\n const invalidNameCharacters = /[^A-Za-z0-9,-]/.exec(name);\n if (invalidNameCharacters) {\n throw new Error('The claim name you provided is not allowed. Only the following characters are allowed: A-Z, a-z, 0-9, and \"-\"');\n }\n // optional parameters\n nsfw = (nsfw === 'true');\n license = license || null;\n title = title || null;\n description = description || null;\n thumbnail = thumbnail || null;\n // return results\n return {\n name,\n nsfw,\n license,\n title,\n description,\n thumbnail,\n };\n },\n parsePublishApiRequestFiles ({file, thumbnail}) {\n // make sure a file was provided\n if (!file) {\n throw new Error('no file with key of [file] found in request');\n }\n if (!file.path) {\n throw new Error('no file path found');\n }\n if (!file.type) {\n throw new Error('no file type found');\n }\n if (!file.size) {\n throw new Error('no file type found');\n }\n // validate the file name\n if (/'/.test(file.name)) {\n throw new Error('apostrophes are not allowed in the file name');\n }\n // validate the file\n module.exports.validateFileTypeAndSize(file);\n // return results\n return {\n fileName : file.name,\n filePath : file.path,\n fileType : file.type,\n thumbnailFileName: (thumbnail ? thumbnail.name : null),\n thumbnailFilePath: (thumbnail ? thumbnail.path : null),\n thumbnailFileType: (thumbnail ? thumbnail.type : null),\n };\n },\n validateFileTypeAndSize (file) {\n // check file type and size\n switch (file.type) {\n case 'image/jpeg':\n case 'image/jpg':\n case 'image/png':\n if (file.size > 10000000) {\n logger.debug('publish > file validation > .jpeg/.jpg/.png was too big');\n throw new Error('Sorry, images are limited to 10 megabytes.');\n }\n break;\n case 'image/gif':\n if (file.size > 50000000) {\n logger.debug('publish > file validation > .gif was too big');\n throw new Error('Sorry, .gifs are limited to 50 megabytes.');\n }\n break;\n case 'video/mp4':\n if (file.size > 50000000) {\n logger.debug('publish > file validation > .mp4 was too big');\n throw new Error('Sorry, videos are limited to 50 megabytes.');\n }\n break;\n default:\n logger.debug('publish > file validation > unrecognized file type');\n throw new Error('The ' + file.type + ' content type is not supported. Only, .jpeg, .png, .gif, and .mp4 files are currently supported.');\n }\n return file;\n },\n createBasicPublishParams (filePath, name, title, description, license, nsfw, thumbnail) {\n logger.debug(`Creating Publish Parameters`);\n // provide defaults for title\n if (title === null || title.trim() === '') {\n title = name;\n }\n // provide default for description\n if (description === null || description.trim() === '') {\n description = '';\n }\n // provide default for license\n if (license === null || license.trim() === '') {\n license = ' '; // default to empty string\n }\n // create the publish params\n const publishParams = {\n name,\n file_path: filePath,\n bid : 0.01,\n metadata : {\n description,\n title,\n author : details.title,\n language: 'en',\n license,\n nsfw,\n },\n claim_address: publishing.primaryClaimAddress,\n };\n // add thumbnail to channel if video\n if (thumbnail) {\n publishParams['metadata']['thumbnail'] = thumbnail;\n }\n return publishParams;\n },\n createThumbnailPublishParams (thumbnailFilePath, claimName, license, nsfw) {\n if (!thumbnailFilePath) {\n return;\n }\n logger.debug(`Creating Thumbnail Publish Parameters`);\n // create the publish params\n return {\n name : `${claimName}-thumb`,\n file_path: thumbnailFilePath,\n bid : 0.01,\n metadata : {\n title : `${claimName} thumbnail`,\n description: `a thumbnail for ${claimName}`,\n author : details.title,\n language : 'en',\n license,\n nsfw,\n },\n claim_address: publishing.primaryClaimAddress,\n channel_name : publishing.thumbnailChannel,\n channel_id : publishing.thumbnailChannelId,\n };\n },\n deleteTemporaryFile (filePath) {\n fs.unlink(filePath, err => {\n if (err) {\n logger.error(`error deleting temporary file ${filePath}`);\n throw err;\n }\n logger.debug(`successfully deleted ${filePath}`);\n });\n },\n addGetResultsToFileData (fileInfo, getResult) {\n fileInfo.fileName = getResult.file_name;\n fileInfo.filePath = getResult.download_path;\n return fileInfo;\n },\n createFileData ({ name, claimId, outpoint, height, address, nsfw, contentType }) {\n return {\n name,\n claimId,\n outpoint,\n height,\n address,\n fileName: '',\n filePath: '',\n fileType: contentType,\n nsfw,\n };\n },\n};\n\n\n\n// WEBPACK FOOTER //\n// ./server/helpers/publishHelpers.js","const logger = require('winston');\n\nfunction mysql () {\n this.database = 'default';\n this.username = 'default';\n this.password = 'default';\n this.update = (config) => {\n if (!config) {\n return logger.warn('No MySQL config received.');\n }\n // configure credentials\n logger.info('configuring mysql...');\n const { database, username, password } = config;\n this.database = database;\n this.username = username;\n this.password = password;\n };\n};\n\nmodule.exports = new mysql();\n\n\n\n// WEBPACK FOOTER //\n// ./config/mysqlConfig.js","module.exports = require(\"passport-local\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"passport-local\"\n// module id = 11\n// module chunks = 0","module.exports = {\n returnShortId: function (claimsArray, longId) {\n let claimIndex;\n let shortId = longId.substring(0, 1); // default short id is the first letter\n let shortIdLength = 0;\n // find the index of this claim id\n claimIndex = claimsArray.findIndex(element => {\n return element.claimId === longId;\n });\n if (claimIndex < 0) {\n throw new Error('claim id not found in claims list');\n }\n // get an array of all claims with lower height\n let possibleMatches = claimsArray.slice(0, claimIndex);\n // remove certificates with the same prefixes until none are left.\n while (possibleMatches.length > 0) {\n shortIdLength += 1;\n shortId = longId.substring(0, shortIdLength);\n possibleMatches = possibleMatches.filter(element => {\n return (element.claimId && (element.claimId.substring(0, shortIdLength) === shortId));\n });\n }\n return shortId;\n },\n};\n\n\n\n// WEBPACK FOOTER //\n// ./server/helpers/sequelizeHelpers.js","module.exports = require(\"sequelize\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"sequelize\"\n// module id = 13\n// module chunks = 0","import React from 'react';\nimport { renderToString } from 'react-dom/server';\nimport { createStore } from 'redux';\nimport { Provider } from 'react-redux';\nimport { StaticRouter } from 'react-router-dom';\nimport { Reducers, GAListener, App } from 'spee.ch-components';\n/*\n ^ note: to do this right, maybe\n these should be passed in from the implementation (www.spee.ch) itself,\n so that there are no conflicts between the SSR here and\n the bundle sent to the server?\n there might also be issues if this package uses a different version of spee.ch-components than www.spee.ch does?\n*/\nimport renderFullPage from './renderFullPage.js';\nimport Helmet from 'react-helmet';\n\nconst siteConfig = require('siteConfig.js');\n\nmodule.exports = (req, res) => {\n let context = {};\n\n // customize the reducer by passing in intial state configs\n const CustomizedReducers = Reducers(siteConfig);\n const CustomizedApp = App(siteConfig);\n\n // create a new Redux store instance\n const store = createStore(CustomizedReducers);\n\n // render component to a string\n const html = renderToString(\n <Provider store={store}>\n <StaticRouter location={req.url} context={context}>\n <GAListener>\n <CustomizedApp />\n </GAListener>\n </StaticRouter>\n </Provider>\n );\n\n // get head tags from helmet\n const helmet = Helmet.renderStatic();\n\n // check for a redirect\n if (context.url) {\n // Somewhere a `<Redirect>` was rendered\n return res.redirect(301, context.url);\n } else {\n // we're good, send the response\n }\n\n // get the initial state from our Redux store\n const preloadedState = store.getState();\n\n // send the rendered page back to the client\n res.send(renderFullPage(helmet, html, preloadedState));\n\n console.log('hello from spee.ch handlePageRender.jsx');\n};\n\n\n\n// WEBPACK FOOTER //\n// ./server/helpers/handlePageRender.jsx","module.exports = require(\"react\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"react\"\n// module id = 15\n// module chunks = 0","module.exports = require(\"react-dom/server\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"react-dom/server\"\n// module id = 16\n// module chunks = 0","module.exports = require(\"redux\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"redux\"\n// module id = 17\n// module chunks = 0","module.exports = require(\"react-redux\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"react-redux\"\n// module id = 18\n// module chunks = 0","module.exports = require(\"react-router-dom\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"react-router-dom\"\n// module id = 19\n// module chunks = 0","module.exports = require(\"spee.ch-components\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"spee.ch-components\"\n// module id = 20\n// module chunks = 0","module.exports = (helmet, html, preloadedState) => {\n // take the html and preloadedState and return the full page\n return `\n <!DOCTYPE html>\n <html lang=\"en\" prefix=\"og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#\">\n <head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no\">\n <meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">\n <!--helmet-->\n ${helmet.title.toString()}\n ${helmet.meta.toString()}\n ${helmet.link.toString()}\n <!--style sheets-->\n <link rel=\"stylesheet\" href=\"/static/assets/css/reset.css\" type=\"text/css\">\n <link rel=\"stylesheet\" href=\"/static/assets/css/general.css\" type=\"text/css\">\n <link rel=\"stylesheet\" href=\"/static/assets/css/mediaQueries.css\" type=\"text/css\">\n <!--google font-->\n <link href=\"https://fonts.googleapis.com/css?family=Roboto:300\" rel=\"stylesheet\">\n </head>\n <body id=\"main-body\">\n <div class=\"row row--tall flex-container--column\">\n <div id=\"react-app\" class=\"row row--tall flex-container--column\">${html}</div>\n </div>\n <script>\n window.__PRELOADED_STATE__ = ${JSON.stringify(preloadedState).replace(/</g, '\\\\\\u003c')}\n </script>\n <script src=\"/static/bundle/bundle.js\"></script>\n </body>\n </html>\n `;\n};\n\n\n\n// WEBPACK FOOTER //\n// ./server/helpers/renderFullPage.js","module.exports = require(\"react-helmet\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"react-helmet\"\n// module id = 22\n// module chunks = 0","const logger = require('winston');\nconst { getClaimId, getLocalFileRecord } = require('../controllers/serveController.js');\nconst { handleErrorResponse } = require('./errorHandlers.js');\n\nconst SERVE = 'SERVE';\nconst SHOW = 'SHOW';\nconst NO_FILE = 'NO_FILE';\nconst NO_CHANNEL = 'NO_CHANNEL';\nconst NO_CLAIM = 'NO_CLAIM';\n\nfunction clientAcceptsHtml ({accept}) {\n return accept && accept.match(/text\\/html/);\n};\n\nfunction requestIsFromBrowser (headers) {\n return headers['user-agent'] && headers['user-agent'].match(/Mozilla/);\n};\n\nfunction clientWantsAsset ({accept, range}) {\n const imageIsWanted = accept && accept.match(/image\\/.*/) && !accept.match(/text\\/html/) && !accept.match(/text\\/\\*/);\n const videoIsWanted = accept && range;\n return imageIsWanted || videoIsWanted;\n};\n\nfunction isValidClaimId (claimId) {\n return ((claimId.length === 40) && !/[^A-Za-z0-9]/g.test(claimId));\n};\n\nfunction isValidShortId (claimId) {\n return claimId.length === 1; // it should really evaluate the short url itself\n};\n\nfunction isValidShortIdOrClaimId (input) {\n return (isValidClaimId(input) || isValidShortId(input));\n};\n\nfunction serveAssetToClient (claimId, name, res) {\n return getLocalFileRecord(claimId, name)\n .then(fileRecord => {\n // check that a local record was found\n if (fileRecord === NO_FILE) {\n return res.status(307).redirect(`/api/claim/get/${name}/${claimId}`);\n }\n // serve the file\n const {filePath, fileType} = fileRecord;\n logger.verbose(`serving file: ${filePath}`);\n const sendFileOptions = {\n headers: {\n 'X-Content-Type-Options': 'nosniff',\n 'Content-Type' : fileType || 'image/jpeg',\n },\n };\n res.status(200).sendFile(filePath, sendFileOptions);\n })\n .catch(error => {\n throw error;\n });\n};\n\nmodule.exports = {\n getClaimIdAndServeAsset (channelName, channelClaimId, claimName, claimId, originalUrl, ip, res) {\n // get the claim Id and then serve the asset\n getClaimId(channelName, channelClaimId, claimName, claimId)\n .then(fullClaimId => {\n if (fullClaimId === NO_CLAIM) {\n return res.status(404).json({success: false, message: 'no claim id could be found'});\n } else if (fullClaimId === NO_CHANNEL) {\n return res.status(404).json({success: false, message: 'no channel id could be found'});\n }\n serveAssetToClient(fullClaimId, claimName, res);\n // postToStats(responseType, originalUrl, ip, claimName, fullClaimId, 'success');\n })\n .catch(error => {\n handleErrorResponse(originalUrl, ip, error, res);\n // postToStats(responseType, originalUrl, ip, claimName, fullClaimId, 'fail');\n });\n },\n determineResponseType (hasFileExtension, headers) {\n let responseType;\n if (hasFileExtension) {\n responseType = SERVE; // assume a serve request if file extension is present\n if (clientAcceptsHtml(headers)) { // if the request comes from a browser, change it to a show request\n responseType = SHOW;\n }\n } else {\n responseType = SHOW;\n if (clientWantsAsset(headers) && requestIsFromBrowser(headers)) { // this is in case someone embeds a show url\n logger.debug('Show request came from browser but wants an image/video. Changing response to serve...');\n responseType = SERVE;\n }\n }\n return responseType;\n },\n flipClaimNameAndIdForBackwardsCompatibility (identifier, name) {\n // this is a patch for backwards compatability with '/name/claim_id' url format\n if (isValidShortIdOrClaimId(name) && !isValidShortIdOrClaimId(identifier)) {\n const tempName = name;\n name = identifier;\n identifier = tempName;\n }\n return [identifier, name];\n },\n logRequestData (responseType, claimName, channelName, claimId) {\n logger.debug('responseType ===', responseType);\n logger.debug('claim name === ', claimName);\n logger.debug('channel name ===', channelName);\n logger.debug('claim id ===', claimId);\n },\n};\n\n\n\n// WEBPACK FOOTER //\n// ./server/helpers/serveHelpers.js","const logger = require('winston');\n\nmodule.exports = {\n REGEXP_INVALID_CLAIM : /[^A-Za-z0-9-]/g,\n REGEXP_INVALID_CHANNEL: /[^A-Za-z0-9-@]/g,\n REGEXP_ADDRESS : /^b(?=[^0OIl]{32,33})[0-9A-Za-z]{32,33}$/,\n CHANNEL_CHAR : '@',\n parseIdentifier : function (identifier) {\n logger.debug('parsing identifier:', identifier);\n const componentsRegex = new RegExp(\n '([^:$#/]*)' + // value (stops at the first separator or end)\n '([:$#]?)([^/]*)' // modifier separator, modifier (stops at the first path separator or end)\n );\n const [proto, value, modifierSeperator, modifier] = componentsRegex\n .exec(identifier)\n .map(match => match || null);\n logger.debug(`${proto}, ${value}, ${modifierSeperator}, ${modifier}`);\n\n // Validate and process name\n if (!value) {\n throw new Error(`Check your url. No channel name provided before \"${modifierSeperator}\"`);\n }\n const isChannel = value.startsWith(module.exports.CHANNEL_CHAR);\n const channelName = isChannel ? value : null;\n let claimId;\n if (isChannel) {\n if (!channelName) {\n throw new Error('No channel name after @.');\n }\n const nameBadChars = (channelName).match(module.exports.REGEXP_INVALID_CHANNEL);\n if (nameBadChars) {\n throw new Error(`Invalid characters in channel name: ${nameBadChars.join(', ')}.`);\n }\n } else {\n claimId = value;\n }\n\n // Validate and process modifier\n let channelClaimId;\n if (modifierSeperator) {\n if (!modifier) {\n throw new Error(`No modifier provided after separator \"${modifierSeperator}\"`);\n }\n\n if (modifierSeperator === ':') {\n channelClaimId = modifier;\n } else {\n throw new Error(`The \"${modifierSeperator}\" modifier is not currently supported`);\n }\n }\n return {\n isChannel,\n channelName,\n channelClaimId,\n claimId,\n };\n },\n parseClaim: function (claim) {\n logger.debug('parsing name:', claim);\n const componentsRegex = new RegExp(\n '([^:$#/.]*)' + // name (stops at the first modifier)\n '([:$#.]?)([^/]*)' // modifier separator, modifier (stops at the first path separator or end)\n );\n const [proto, claimName, modifierSeperator, modifier] = componentsRegex\n .exec(claim)\n .map(match => match || null);\n logger.debug(`${proto}, ${claimName}, ${modifierSeperator}, ${modifier}`);\n\n // Validate and process name\n if (!claimName) {\n throw new Error('No claim name provided before .');\n }\n const nameBadChars = (claimName).match(module.exports.REGEXP_INVALID_CLAIM);\n if (nameBadChars) {\n throw new Error(`Invalid characters in claim name: ${nameBadChars.join(', ')}.`);\n }\n // Validate and process modifier\n if (modifierSeperator) {\n if (!modifier) {\n throw new Error(`No file extension provided after separator ${modifierSeperator}.`);\n }\n if (modifierSeperator !== '.') {\n throw new Error(`The ${modifierSeperator} modifier is not supported in the claim name`);\n }\n }\n // return results\n return {\n claimName,\n };\n },\n parseModifier: function (claim) {\n logger.debug('parsing modifier:', claim);\n const componentsRegex = new RegExp(\n '([^:$#/.]*)' + // name (stops at the first modifier)\n '([:$#.]?)([^/]*)' // modifier separator, modifier (stops at the first path separator or end)\n );\n const [proto, claimName, modifierSeperator, modifier] = componentsRegex\n .exec(claim)\n .map(match => match || null);\n logger.debug(`${proto}, ${claimName}, ${modifierSeperator}, ${modifier}`);\n // Validate and process modifier\n let hasFileExtension = false;\n if (modifierSeperator) {\n hasFileExtension = true;\n }\n return {\n hasFileExtension,\n };\n },\n};\n\n\n\n// WEBPACK FOOTER //\n// ./server/helpers/lbryUri.js","import React from 'react';\nimport { renderToString } from 'react-dom/server';\nimport { createStore, applyMiddleware } from 'redux';\nimport { Provider } from 'react-redux';\nimport { StaticRouter } from 'react-router-dom';\nimport renderFullPage from './renderFullPage';\nimport createSagaMiddleware from 'redux-saga';\nimport { call } from 'redux-saga/effects';\nimport { Reducers, GAListener, App, Sagas, Actions } from 'spee.ch-components';\n/*\n ^ note: to do this right, maybe\n these should be passed in from the implementation (www.spee.ch) itself,\n so that there are no conflicts between the SSR here and\n the bundle sent to the server?\n there might also be issues if this package uses a different version of spee.ch-components than www.spee.ch does?\n*/\nimport Helmet from 'react-helmet';\n\n// configure the reducers by passing initial state configs\nconst siteConfig = require('siteConfig.js');\nconst CustomizedReducers = Reducers(siteConfig);\nconst CustomizedApp = App(siteConfig);\n\nconst returnSagaWithParams = (saga, params) => {\n return function * () {\n yield call(saga, params);\n };\n};\n\nmodule.exports = (req, res) => {\n let context = {};\n\n // create and apply middleware\n const sagaMiddleware = createSagaMiddleware();\n const middleware = applyMiddleware(sagaMiddleware);\n\n // create a new Redux store instance\n const store = createStore(CustomizedReducers, middleware);\n\n // create saga\n const action = Actions.onHandleShowPageUri(req.params);\n const saga = returnSagaWithParams(Sagas.handleShowPageUri, action);\n\n // run the saga middleware\n sagaMiddleware\n .run(saga)\n .done\n .then(() => {\n // render component to a string\n const html = renderToString(\n <Provider store={store}>\n <StaticRouter location={req.url} context={context}>\n <GAListener>\n <CustomizedApp />\n </GAListener>\n </StaticRouter>\n </Provider>\n );\n\n // get head tags from helmet\n const helmet = Helmet.renderStatic();\n\n // check for a redirect\n if (context.url) {\n return res.redirect(301, context.url);\n }\n\n // get the initial state from our Redux store\n const preloadedState = store.getState();\n\n // send the rendered page back to the client\n res.send(renderFullPage(helmet, html, preloadedState));\n });\n\n console.log('hello from spee.ch handleShowRender.jsx');\n};\n\n\n\n// WEBPACK FOOTER //\n// ./server/helpers/handleShowRender.jsx","module.exports = require(\"babel-polyfill\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"babel-polyfill\"\n// module id = 27\n// module chunks = 0","module.exports = require(\"whatwg-fetch\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"whatwg-fetch\"\n// module id = 28\n// module chunks = 0","const Server = require('./server');\n\nconst exports = {\n Server,\n};\n\nmodule.exports = exports;\n\n\n\n// WEBPACK FOOTER //\n// ./speech.js","// app dependencies\nconst express = require('express');\nconst bodyParser = require('body-parser');\nconst expressHandlebars = require('express-handlebars');\nconst Handlebars = require('handlebars');\nconst helmet = require('helmet');\nconst cookieSession = require('cookie-session');\nconst http = require('http');\nconst logger = require('winston');\nconst requestLogger = require('middleware/requestLogger.js');\nconst Path = require('path');\nconst loggerConfig = require('loggerConfig.js');\nconst mysqlConfig = require('mysqlConfig.js');\nconst siteConfig = require('siteConfig.js');\nconst slackConfig = require('slackConfig.js');\n\nfunction Server () {\n this.configureLogger = (userConfig) => {\n loggerConfig.update(userConfig);\n };\n this.configureMysql = (userConfig) => {\n mysqlConfig.update(userConfig);\n };\n this.configureSiteDetails = (userConfig) => {\n siteConfig.update(userConfig);\n };\n this.configureSlack = (userConfig) => {\n slackConfig.update(userConfig);\n };\n this.configureClientBundle = () => {\n logger.debug('configure the client here by passing in the bundle and configuring it, or better yet: taking in the components to use dynamically from here.');\n };\n this.configureModels = () => {\n logger.debug('here is where you could add/overwrite the default models')\n };\n this.configureRoutes = () => {\n logger.debug('here is where you could add/overwrite the default routes')\n };\n this.createApp = () => {\n // create an Express application\n const app = express();\n\n // trust the proxy to get ip address for us\n app.enable('trust proxy');\n\n /* add middleware */\n // set HTTP headers to protect against well-known web vulnerabilties\n app.use(helmet());\n // 'express.static' to serve static files from public directory\n if (siteConfig.routes.publicFolder) {\n // take in a different public folder, so it can serve it's own bundle if needed\n const publicFolder = Path.resolve(process.cwd(), siteConfig.routes.publicFolder);\n app.use('/static', express.static(publicFolder));\n logger.info('serving static files from custom path:', publicFolder);\n } else {\n const publicPath = Path.resolve(__dirname, 'public');\n app.use('/static', express.static(publicPath));\n logger.info('serving static files from default path:', publicPath);\n };\n // 'body parser' for parsing application/json\n app.use(bodyParser.json());\n // 'body parser' for parsing application/x-www-form-urlencoded\n app.use(bodyParser.urlencoded({ extended: true }));\n\n // add custom middleware (note: build out to accept dynamically use what is in server/middleware/\n app.use(requestLogger);\n\n // configure passport\n const speechPassport = require('speechPassport');\n // initialize passport\n const sessionKey = siteConfig.auth.sessionKey;\n app.use(cookieSession({\n name : 'session',\n keys : [sessionKey],\n maxAge: 24 * 60 * 60 * 1000, // i.e. 24 hours\n }));\n app.use(speechPassport.initialize());\n app.use(speechPassport.session());\n\n // configure handlebars & register it with express app\n const hbs = expressHandlebars.create({\n defaultLayout: 'embed',\n handlebars : Handlebars,\n });\n app.engine('handlebars', hbs.engine);\n app.set('view engine', 'handlebars');\n\n // set the routes on the app\n require('./routes/auth/')(app);\n require('./routes/api/')(app);\n require('./routes/pages/')(app);\n require('./routes/assets/')(app);\n require('./routes/fallback/')(app);\n\n this.app = app;\n };\n this.initialize = () => {\n this.createApp();\n this.server = http.Server(this.app);\n };\n this.start = () => {\n const db = require('models');\n const PORT = siteConfig.details.port;\n // sync sequelize\n db.sequelize.sync()\n // start the server\n .then(() => {\n this.server.listen(PORT, () => {\n logger.info(`Server is listening on PORT ${PORT}`);\n });\n })\n .catch((error) => {\n logger.error(`Startup Error:`, error);\n });\n };\n};\n\nmodule.exports = Server;\n\n\n\n// WEBPACK FOOTER //\n// ./server/index.js","module.exports = require(\"express\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"express\"\n// module id = 31\n// module chunks = 0","module.exports = require(\"body-parser\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"body-parser\"\n// module id = 32\n// module chunks = 0","module.exports = require(\"express-handlebars\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"express-handlebars\"\n// module id = 33\n// module chunks = 0","module.exports = require(\"handlebars\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"handlebars\"\n// module id = 34\n// module chunks = 0","module.exports = require(\"helmet\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"helmet\"\n// module id = 35\n// module chunks = 0","module.exports = require(\"cookie-session\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"cookie-session\"\n// module id = 36\n// module chunks = 0","module.exports = require(\"http\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"http\"\n// module id = 37\n// module chunks = 0","const logger = require('winston');\n\nconst requestLogger = (req, res, next) => { // custom logging middleware to log all incoming http requests\n logger.verbose(`Request on ${req.originalUrl} from ${req.ip}`);\n next();\n};\n\nmodule.exports = requestLogger;\n\n\n\n// WEBPACK FOOTER //\n// ./server/middleware/requestLogger.js","module.exports = require(\"path\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"path\"\n// module id = 39\n// module chunks = 0","const logger = require('winston');\n\nfunction LoggerConfig () {\n this.logLevel = 'debug';\n this.update = (config) => {\n if (!config) {\n return logger.warn('No logger config received.');\n }\n logger.info('configuring winston logger...');\n // update values with local config params\n const {logLevel} = config;\n this.logLevel = logLevel;\n // configure the winston logger\n logger.configure({\n transports: [\n new (logger.transports.Console)({\n level : this.logLevel,\n timestamp : false,\n colorize : true,\n prettyPrint : true,\n handleExceptions : true,\n humanReadableUnhandledException: true,\n }),\n ],\n });\n // test all the log levels\n logger.info('testing winston log levels...');\n logger.error('Level 0');\n logger.warn('Level 1');\n logger.info('Level 2');\n logger.verbose('Level 3');\n logger.debug('Level 4');\n logger.silly('Level 5');\n };\n};\n\nmodule.exports = new LoggerConfig();\n\n\n\n// WEBPACK FOOTER //\n// ./config/loggerConfig.js","const winstonSlackWebHook = require('winston-slack-webhook').SlackWebHook;\nconst winston = require('winston');\n\nfunction SlackConfig () {\n this.slackWebHook = 'default';\n this.slackErrorChannel = 'default';\n this.slackInfoChannel = 'default';\n this.update = (config) => {\n if (!config) {\n return winston.warn('No slack config received');\n }\n // update variables\n winston.info('configuring slack logger...');\n const {slackWebHook, slackErrorChannel, slackInfoChannel} = config;\n this.slackWebHook = slackWebHook;\n this.slackErrorChannel = slackErrorChannel;\n this.slackInfoChannel = slackInfoChannel;\n // update slack webhook settings\n if (this.slackWebHook) {\n // add a transport for errors to slack\n if (this.slackErrorChannel) {\n winston.add(winstonSlackWebHook, {\n name : 'slack-errors-transport',\n level : 'warn',\n webhookUrl: this.slackWebHook,\n channel : this.slackErrorChannel,\n username : 'spee.ch',\n iconEmoji : ':face_with_head_bandage:',\n });\n };\n if (slackInfoChannel) {\n winston.add(winstonSlackWebHook, {\n name : 'slack-info-transport',\n level : 'info',\n webhookUrl: this.slackWebHook,\n channel : this.slackInfoChannel,\n username : 'spee.ch',\n iconEmoji : ':nerd_face:',\n });\n };\n // send test messages\n winston.info('testing slack logger...');\n winston.error('Slack \"error\" logging is online.');\n winston.info('Slack \"info\" logging is online.');\n } else {\n winston.warn('Slack logging is not enabled because no slackWebHook config var provided.');\n }\n };\n};\n\nmodule.exports = new SlackConfig();\n\n\n\n// WEBPACK FOOTER //\n// ./config/slackConfig.js","module.exports = require(\"winston-slack-webhook\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"winston-slack-webhook\"\n// module id = 42\n// module chunks = 0","module.exports = require(\"passport\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"passport\"\n// module id = 43\n// module chunks = 0","const PassportLocalStrategy = require('passport-local').Strategy;\nconst logger = require('winston');\nconst db = require('models');\n\nconst returnUserAndChannelInfo = (userInstance) => {\n return new Promise((resolve, reject) => {\n let userInfo = {};\n userInfo['id'] = userInstance.id;\n userInfo['userName'] = userInstance.userName;\n userInstance\n .getChannel()\n .then(({channelName, channelClaimId}) => {\n userInfo['channelName'] = channelName;\n userInfo['channelClaimId'] = channelClaimId;\n return db.Certificate.getShortChannelIdFromLongChannelId(channelClaimId, channelName);\n })\n .then(shortChannelId => {\n userInfo['shortChannelId'] = shortChannelId;\n resolve(userInfo);\n })\n .catch(error => {\n reject(error);\n });\n });\n};\n\nmodule.exports = new PassportLocalStrategy(\n {\n usernameField: 'username',\n passwordField: 'password',\n },\n (username, password, done) => {\n return db.User\n .findOne({\n where: {userName: username},\n })\n .then(user => {\n if (!user) {\n logger.debug('no user found');\n return done(null, false, {message: 'Incorrect username or password'});\n }\n return user.comparePassword(password)\n .then(isMatch => {\n if (!isMatch) {\n logger.debug('incorrect password');\n return done(null, false, {message: 'Incorrect username or password'});\n }\n logger.debug('Password was a match, returning User');\n return returnUserAndChannelInfo(user)\n .then(userInfo => {\n return done(null, userInfo);\n })\n .catch(error => {\n return error;\n });\n })\n .catch(error => {\n return error;\n });\n })\n .catch(error => {\n return done(error);\n });\n },\n);\n\n\n\n// WEBPACK FOOTER //\n// ./server/speechPassport/local-login.js","const logger = require('winston');\nconst { returnShortId } = require('../helpers/sequelizeHelpers.js');\n\nmodule.exports = (sequelize, { STRING, BOOLEAN, INTEGER, TEXT, DECIMAL }) => {\n const Certificate = sequelize.define(\n 'Certificate',\n {\n address: {\n type : STRING,\n default: null,\n },\n amount: {\n type : DECIMAL(19, 8),\n default: null,\n },\n claimId: {\n type : STRING,\n default: null,\n },\n claimSequence: {\n type : INTEGER,\n default: null,\n },\n decodedClaim: {\n type : BOOLEAN,\n default: null,\n },\n depth: {\n type : INTEGER,\n default: null,\n },\n effectiveAmount: {\n type : DECIMAL(19, 8),\n default: null,\n },\n hasSignature: {\n type : BOOLEAN,\n default: null,\n },\n height: {\n type : INTEGER,\n default: null,\n },\n hex: {\n type : TEXT('long'),\n default: null,\n },\n name: {\n type : STRING,\n default: null,\n },\n nout: {\n type : INTEGER,\n default: null,\n },\n txid: {\n type : STRING,\n default: null,\n },\n validAtHeight: {\n type : INTEGER,\n default: null,\n },\n outpoint: {\n type : STRING,\n default: null,\n },\n valueVersion: {\n type : STRING,\n default: null,\n },\n claimType: {\n type : STRING,\n default: null,\n },\n certificateVersion: {\n type : STRING,\n default: null,\n },\n keyType: {\n type : STRING,\n default: null,\n },\n publicKey: {\n type : TEXT('long'),\n default: null,\n },\n },\n {\n freezeTableName: true,\n }\n );\n\n Certificate.associate = db => {\n Certificate.belongsTo(db.Channel, {\n foreignKey: {\n allowNull: true,\n },\n });\n };\n\n Certificate.getShortChannelIdFromLongChannelId = function (longChannelId, channelName) {\n logger.debug(`getShortChannelIdFromLongChannelId ${channelName}:${longChannelId}`);\n return new Promise((resolve, reject) => {\n this\n .findAll({\n where: {name: channelName},\n order: [['height', 'ASC']],\n })\n .then(result => {\n switch (result.length) {\n case 0:\n throw new Error('No channel(s) found with that channel name');\n default:\n return resolve(returnShortId(result, longChannelId));\n }\n })\n .catch(error => {\n reject(error);\n });\n });\n };\n\n Certificate.getLongChannelIdFromShortChannelId = function (channelName, channelClaimId) {\n logger.debug(`getLongChannelIdFromShortChannelId(${channelName}, ${channelClaimId})`);\n return new Promise((resolve, reject) => {\n this\n .findAll({\n where: {\n name : channelName,\n claimId: {\n $like: `${channelClaimId}%`,\n },\n },\n order: [['height', 'ASC']],\n })\n .then(result => {\n switch (result.length) {\n case 0:\n return resolve(null);\n default: // note results must be sorted\n return resolve(result[0].claimId);\n }\n })\n .catch(error => {\n reject(error);\n });\n });\n };\n\n Certificate.getLongChannelIdFromChannelName = function (channelName) {\n logger.debug(`getLongChannelIdFromChannelName(${channelName})`);\n return new Promise((resolve, reject) => {\n this\n .findAll({\n where: { name: channelName },\n order: [['effectiveAmount', 'DESC'], ['height', 'ASC']],\n })\n .then(result => {\n switch (result.length) {\n case 0:\n return resolve(null);\n default:\n return resolve(result[0].claimId);\n }\n })\n .catch(error => {\n reject(error);\n });\n });\n };\n\n Certificate.validateLongChannelId = function (name, claimId) {\n logger.debug(`validateLongChannelId(${name}, ${claimId})`);\n return new Promise((resolve, reject) => {\n this.findOne({\n where: {name, claimId},\n })\n .then(result => {\n if (!result) {\n return resolve(null);\n };\n resolve(claimId);\n })\n .catch(error => {\n reject(error);\n });\n });\n };\n\n Certificate.getLongChannelId = function (channelName, channelClaimId) {\n logger.debug(`getLongChannelId(${channelName}, ${channelClaimId})`);\n if (channelClaimId && (channelClaimId.length === 40)) { // if a full channel id is provided\n return this.validateLongChannelId(channelName, channelClaimId);\n } else if (channelClaimId && channelClaimId.length < 40) { // if a short channel id is provided\n return this.getLongChannelIdFromShortChannelId(channelName, channelClaimId);\n } else {\n return this.getLongChannelIdFromChannelName(channelName); // if no channel id provided\n }\n };\n\n return Certificate;\n};\n\n\n\n// WEBPACK FOOTER //\n// ./server/models/certificate.js","module.exports = (sequelize, { STRING }) => {\n const Channel = sequelize.define(\n 'Channel',\n {\n channelName: {\n type : STRING,\n allowNull: false,\n },\n channelClaimId: {\n type : STRING,\n allowNull: false,\n },\n },\n {\n freezeTableName: true,\n }\n );\n\n Channel.associate = db => {\n Channel.belongsTo(db.User);\n Channel.hasOne(db.Certificate);\n };\n\n return Channel;\n};\n\n\n\n// WEBPACK FOOTER //\n// ./server/models/channel.js","const logger = require('winston');\nconst { returnShortId } = require('../helpers/sequelizeHelpers.js');\nconst { assetDefaults: { thumbnail: defaultThumbnail }, details: { host } } = require('../../config/siteConfig.js');\n\nfunction determineFileExtensionFromContentType (contentType) {\n switch (contentType) {\n case 'image/jpeg':\n case 'image/jpg':\n return 'jpeg';\n case 'image/png':\n return 'png';\n case 'image/gif':\n return 'gif';\n case 'video/mp4':\n return 'mp4';\n default:\n logger.debug('setting unknown file type as file extension jpeg');\n return 'jpeg';\n }\n};\n\nfunction determineThumbnail (storedThumbnail, defaultThumbnail) {\n if (storedThumbnail === '') {\n return defaultThumbnail;\n }\n return storedThumbnail;\n};\n\nfunction prepareClaimData (claim) {\n // logger.debug('preparing claim data based on resolved data:', claim);\n claim['thumbnail'] = determineThumbnail(claim.thumbnail, defaultThumbnail);\n claim['fileExt'] = determineFileExtensionFromContentType(claim.contentType);\n claim['host'] = host;\n return claim;\n};\n\nmodule.exports = (sequelize, { STRING, BOOLEAN, INTEGER, TEXT, DECIMAL }) => {\n const Claim = sequelize.define(\n 'Claim',\n {\n address: {\n type : STRING,\n default: null,\n },\n amount: {\n type : DECIMAL(19, 8),\n default: null,\n },\n claimId: {\n type : STRING,\n default: null,\n },\n claimSequence: {\n type : INTEGER,\n default: null,\n },\n decodedClaim: {\n type : BOOLEAN,\n default: null,\n },\n depth: {\n type : INTEGER,\n default: null,\n },\n effectiveAmount: {\n type : DECIMAL(19, 8),\n default: null,\n },\n hasSignature: {\n type : BOOLEAN,\n default: null,\n },\n height: {\n type : INTEGER,\n default: null,\n },\n hex: {\n type : TEXT('long'),\n default: null,\n },\n name: {\n type : STRING,\n default: null,\n },\n nout: {\n type : INTEGER,\n default: null,\n },\n txid: {\n type : STRING,\n default: null,\n },\n validAtHeight: {\n type : INTEGER,\n default: null,\n },\n outpoint: {\n type : STRING,\n default: null,\n },\n claimType: {\n type : STRING,\n default: null,\n },\n certificateId: {\n type : STRING,\n default: null,\n },\n author: {\n type : STRING,\n default: null,\n },\n description: {\n type : TEXT('long'),\n default: null,\n },\n language: {\n type : STRING,\n default: null,\n },\n license: {\n type : STRING,\n default: null,\n },\n licenseUrl: {\n type : STRING,\n default: null,\n },\n nsfw: {\n type : BOOLEAN,\n default: null,\n },\n preview: {\n type : STRING,\n default: null,\n },\n thumbnail: {\n type : STRING,\n default: null,\n },\n title: {\n type : STRING,\n default: null,\n },\n metadataVersion: {\n type : STRING,\n default: null,\n },\n contentType: {\n type : STRING,\n default: null,\n },\n source: {\n type : STRING,\n default: null,\n },\n sourceType: {\n type : STRING,\n default: null,\n },\n sourceVersion: {\n type : STRING,\n default: null,\n },\n streamVersion: {\n type : STRING,\n default: null,\n },\n valueVersion: {\n type : STRING,\n default: null,\n },\n channelName: {\n type : STRING,\n allowNull: true,\n default : null,\n },\n },\n {\n freezeTableName: true,\n }\n );\n\n Claim.associate = db => {\n Claim.belongsTo(db.File, {\n foreignKey: {\n allowNull: true,\n },\n });\n };\n\n Claim.getShortClaimIdFromLongClaimId = function (claimId, claimName) {\n logger.debug(`Claim.getShortClaimIdFromLongClaimId for ${claimName}#${claimId}`);\n return new Promise((resolve, reject) => {\n this\n .findAll({\n where: { name: claimName },\n order: [['height', 'ASC']],\n })\n .then(result => {\n switch (result.length) {\n case 0:\n throw new Error('No claim(s) found with that claim name');\n default:\n resolve(returnShortId(result, claimId));\n }\n })\n .catch(error => {\n reject(error);\n });\n });\n };\n\n Claim.getAllChannelClaims = function (channelClaimId) {\n logger.debug(`Claim.getAllChannelClaims for ${channelClaimId}`);\n return new Promise((resolve, reject) => {\n this\n .findAll({\n where: { certificateId: channelClaimId },\n order: [['height', 'ASC']],\n raw : true, // returns an array of only data, not an array of instances\n })\n .then(channelClaimsArray => {\n // logger.debug('channelclaimsarray length:', channelClaimsArray.length);\n switch (channelClaimsArray.length) {\n case 0:\n return resolve(null);\n default:\n channelClaimsArray.forEach(claim => {\n claim['fileExt'] = determineFileExtensionFromContentType(claim.contentType);\n claim['thumbnail'] = determineThumbnail(claim.thumbnail, defaultThumbnail);\n return claim;\n });\n return resolve(channelClaimsArray);\n }\n })\n .catch(error => {\n reject(error);\n });\n });\n };\n\n Claim.getClaimIdByLongChannelId = function (channelClaimId, claimName) {\n logger.debug(`finding claim id for claim ${claimName} from channel ${channelClaimId}`);\n return new Promise((resolve, reject) => {\n this\n .findAll({\n where: { name: claimName, certificateId: channelClaimId },\n order: [['id', 'ASC']],\n })\n .then(result => {\n switch (result.length) {\n case 0:\n return resolve(null);\n case 1:\n return resolve(result[0].claimId);\n default:\n logger.error(`${result.length} records found for \"${claimName}\" in channel \"${channelClaimId}\"`);\n return resolve(result[0].claimId);\n }\n })\n .catch(error => {\n reject(error);\n });\n });\n };\n\n Claim.getLongClaimIdFromShortClaimId = function (name, shortId) {\n return new Promise((resolve, reject) => {\n this\n .findAll({\n where: {\n name,\n claimId: {\n $like: `${shortId}%`,\n }},\n order: [['height', 'ASC']],\n })\n .then(result => {\n switch (result.length) {\n case 0:\n return resolve(null);\n default: // note results must be sorted\n return resolve(result[0].claimId);\n }\n })\n .catch(error => {\n reject(error);\n });\n });\n };\n\n Claim.getTopFreeClaimIdByClaimName = function (name) {\n return new Promise((resolve, reject) => {\n this\n .findAll({\n where: { name },\n order: [['effectiveAmount', 'DESC'], ['height', 'ASC']], // note: maybe height and effective amount need to switch?\n })\n .then(result => {\n logger.debug('length of result', result.length);\n switch (result.length) {\n case 0:\n return resolve(null);\n default:\n return resolve(result[0].dataValues.claimId);\n }\n })\n .catch(error => {\n reject(error);\n });\n });\n };\n\n Claim.validateLongClaimId = function (name, claimId) {\n return new Promise((resolve, reject) => {\n this.findOne({\n where: {name, claimId},\n })\n .then(result => {\n if (!result) {\n return resolve(null);\n };\n resolve(claimId);\n })\n .catch(error => {\n reject(error);\n });\n });\n };\n\n Claim.getLongClaimId = function (claimName, claimId) {\n logger.debug(`getLongClaimId(${claimName}, ${claimId})`);\n if (claimId && (claimId.length === 40)) { // if a full claim id is provided\n return this.validateLongClaimId(claimName, claimId);\n } else if (claimId && claimId.length < 40) {\n return this.getLongClaimIdFromShortClaimId(claimName, claimId); // if a short claim id is provided\n } else {\n return this.getTopFreeClaimIdByClaimName(claimName); // if no claim id is provided\n }\n };\n\n Claim.resolveClaim = function (name, claimId) {\n logger.debug(`Claim.resolveClaim: ${name} ${claimId}`);\n return new Promise((resolve, reject) => {\n this\n .findAll({\n where: { name, claimId },\n })\n .then(claimArray => {\n switch (claimArray.length) {\n case 0:\n return resolve(null);\n case 1:\n return resolve(prepareClaimData(claimArray[0].dataValues));\n default:\n logger.error(`more than one record matches ${name}#${claimId} in db.Claim`);\n return resolve(prepareClaimData(claimArray[0].dataValues));\n }\n })\n .catch(error => {\n reject(error);\n });\n });\n };\n\n return Claim;\n};\n\n\n\n// WEBPACK FOOTER //\n// ./server/models/claim.js","module.exports = (sequelize, { STRING, BOOLEAN, INTEGER }) => {\n const File = sequelize.define(\n 'File',\n {\n name: {\n type : STRING,\n allowNull: false,\n },\n claimId: {\n type : STRING,\n allowNull: false,\n },\n address: {\n type : STRING,\n allowNull: false,\n },\n outpoint: {\n type : STRING,\n allowNull: false,\n },\n height: {\n type : INTEGER,\n allowNull: false,\n default : 0,\n },\n fileName: {\n type : STRING,\n allowNull: false,\n },\n filePath: {\n type : STRING,\n allowNull: false,\n },\n fileType: {\n type: STRING,\n },\n nsfw: {\n type : BOOLEAN,\n allowNull : false,\n defaultValue: false,\n },\n trendingEligible: {\n type : BOOLEAN,\n allowNull : false,\n defaultValue: true,\n },\n },\n {\n freezeTableName: true,\n }\n );\n\n File.associate = db => {\n File.hasMany(db.Request);\n File.hasOne(db.Claim);\n };\n\n File.getRecentClaims = function () {\n return this.findAll({\n where: { nsfw: false, trendingEligible: true },\n order: [['createdAt', 'DESC']],\n limit: 25,\n });\n };\n\n return File;\n};\n\n\n\n// WEBPACK FOOTER //\n// ./server/models/file.js","module.exports = (sequelize, { STRING, BOOLEAN, TEXT }) => {\n const Request = sequelize.define(\n 'Request',\n {\n action: {\n type : STRING,\n allowNull: false,\n },\n url: {\n type : STRING,\n allowNull: false,\n },\n ipAddress: {\n type : STRING,\n allowNull: true,\n },\n result: {\n type : TEXT('long'),\n allowNull: true,\n default : null,\n },\n },\n {\n freezeTableName: true,\n }\n );\n\n Request.associate = db => {\n Request.belongsTo(db.File, {\n foreignKey: {\n allowNull: true,\n },\n });\n };\n\n return Request;\n};\n\n\n\n// WEBPACK FOOTER //\n// ./server/models/request.js","'use strict';\nconst bcrypt = require('bcrypt');\nconst logger = require('winston');\n\nmodule.exports = (sequelize, { STRING }) => {\n const User = sequelize.define(\n 'User',\n {\n userName: {\n type : STRING,\n allowNull: false,\n },\n password: {\n type : STRING,\n allowNull: false,\n },\n },\n {\n freezeTableName: true,\n }\n );\n\n User.associate = db => {\n User.hasOne(db.Channel);\n };\n\n User.prototype.comparePassword = function (password) {\n return bcrypt.compare(password, this.password);\n };\n\n User.prototype.changePassword = function (newPassword) {\n return new Promise((resolve, reject) => {\n // generate a salt string to use for hashing\n bcrypt.genSalt((saltError, salt) => {\n if (saltError) {\n logger.error('salt error', saltError);\n reject(saltError);\n return;\n }\n // generate a hashed version of the user's password\n bcrypt.hash(newPassword, salt, (hashError, hash) => {\n // if there is an error with the hash generation return the error\n if (hashError) {\n logger.error('hash error', hashError);\n reject(hashError);\n return;\n }\n // replace the current password with the new hash\n this\n .update({password: hash})\n .then(() => {\n resolve();\n })\n .catch(error => {\n reject(error);\n });\n });\n });\n });\n };\n\n // pre-save hook method to hash the user's password before the user's info is saved to the db.\n User.hook('beforeCreate', (user, options) => {\n logger.debug('User.beforeCreate hook...');\n return new Promise((resolve, reject) => {\n // generate a salt string to use for hashing\n bcrypt.genSalt((saltError, salt) => {\n if (saltError) {\n logger.error('salt error', saltError);\n reject(saltError);\n return;\n }\n // generate a hashed version of the user's password\n bcrypt.hash(user.password, salt, (hashError, hash) => {\n // if there is an error with the hash generation return the error\n if (hashError) {\n logger.error('hash error', hashError);\n reject(hashError);\n return;\n }\n // replace the password string with the hash password value\n user.password = hash;\n resolve();\n });\n });\n });\n });\n\n return User;\n};\n\n\n\n// WEBPACK FOOTER //\n// ./server/models/user.js","module.exports = require(\"bcrypt\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"bcrypt\"\n// module id = 51\n// module chunks = 0","const PassportLocalStrategy = require('passport-local').Strategy;\nconst lbryApi = require('../helpers/lbryApi.js');\nconst logger = require('winston');\nconst db = require('models');\n\nmodule.exports = new PassportLocalStrategy(\n {\n usernameField: 'username',\n passwordField: 'password',\n },\n (username, password, done) => {\n logger.verbose(`new channel signup request. user: ${username} pass: ${password} .`);\n let userInfo = {};\n // server-side validaton of inputs (username, password)\n\n // create the channel and retrieve the metadata\n return lbryApi.createChannel(`@${username}`)\n .then(tx => {\n // create user record\n const userData = {\n userName: username,\n password: password,\n };\n logger.verbose('userData >', userData);\n // create user record\n const channelData = {\n channelName : `@${username}`,\n channelClaimId: tx.claim_id,\n };\n logger.verbose('channelData >', channelData);\n // create certificate record\n const certificateData = {\n claimId: tx.claim_id,\n name : `@${username}`,\n // address,\n };\n logger.verbose('certificateData >', certificateData);\n // save user and certificate to db\n return Promise.all([db.User.create(userData), db.Channel.create(channelData), db.Certificate.create(certificateData)]);\n })\n .then(([newUser, newChannel, newCertificate]) => {\n logger.verbose('user and certificate successfully created');\n // store the relevant newUser info to be passed back for req.User\n userInfo['id'] = newUser.id;\n userInfo['userName'] = newUser.userName;\n userInfo['channelName'] = newChannel.channelName;\n userInfo['channelClaimId'] = newChannel.channelClaimId;\n // associate the instances\n return Promise.all([newCertificate.setChannel(newChannel), newChannel.setUser(newUser)]);\n })\n .then(() => {\n logger.verbose('user and certificate successfully associated');\n return db.Certificate.getShortChannelIdFromLongChannelId(userInfo.channelClaimId, userInfo.channelName);\n })\n .then(shortChannelId => {\n userInfo['shortChannelId'] = shortChannelId;\n return done(null, userInfo);\n })\n .catch(error => {\n logger.error('signup error', error);\n return done(error);\n });\n }\n);\n\n\n\n// WEBPACK FOOTER //\n// ./server/speechPassport/local-signup.js","module.exports = require(\"axios\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"axios\"\n// module id = 53\n// module chunks = 0","const lbryConfig = {\n api: {\n apiHost: 'localhost',\n apiPort: '5279',\n },\n};\n\nmodule.exports = lbryConfig;\n\n\n\n// WEBPACK FOOTER //\n// ./config/lbryConfig.js","module.exports = require(\"universal-analytics\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"universal-analytics\"\n// module id = 55\n// module chunks = 0","module.exports = {\n serializeSpeechUser (user, done) { // returns user data to be serialized into session\n console.log('serializing user');\n done(null, user);\n },\n deserializeSpeechUser (user, done) { // deserializes session and populates additional info to req.user\n console.log('deserializing user');\n done(null, user);\n },\n};\n\n\n\n// WEBPACK FOOTER //\n// ./server/helpers/authHelpers.js","const speechPassport = require('speechPassport');\nconst handleSignupRequest = require('./signup');\nconst handleLoginRequest = require('./login');\nconst handleLogoutRequest = require('./logout');\nconst handleUserRequest = require('./user');\n\nmodule.exports = (app) => {\n app.post('/signup', speechPassport.authenticate('local-signup'), handleSignupRequest);\n app.post('/login', handleLoginRequest);\n app.get('/logout', handleLogoutRequest);\n app.get('/user', handleUserRequest);\n};\n\n\n\n// WEBPACK FOOTER //\n// ./server/routes/auth/index.js","const signup = (req, res) => {\n res.status(200).json({\n success : true,\n channelName : req.user.channelName,\n channelClaimId: req.user.channelClaimId,\n shortChannelId: req.user.shortChannelId,\n });\n};\n\nmodule.exports = signup;\n\n\n\n// WEBPACK FOOTER //\n// ./server/routes/auth/signup.js","const speechPassport = require('speechPassport');\n\nconst login = (req, res, next) => {\n speechPassport.authenticate('local-login', (err, user, info) => {\n if (err) {\n return next(err);\n }\n if (!user) {\n return res.status(400).json({\n success: false,\n message: info.message,\n });\n }\n req.logIn(user, (err) => {\n if (err) {\n return next(err);\n }\n return res.status(200).json({\n success : true,\n channelName : req.user.channelName,\n channelClaimId: req.user.channelClaimId,\n shortChannelId: req.user.shortChannelId,\n });\n });\n })(req, res, next);\n};\n\nmodule.exports = login;\n\n\n\n// WEBPACK FOOTER //\n// ./server/routes/auth/login.js","const logout = (req, res) => {\n req.logout();\n res.status(200).json({success: true, message: 'you successfully logged out'});\n};\n\nmodule.exports = logout;\n\n\n\n// WEBPACK FOOTER //\n// ./server/routes/auth/logout.js","const user = (req, res) => {\n if (req.user) {\n res.status(200).json({success: true, data: req.user});\n } else {\n res.status(401).json({success: false, message: 'user is not logged in'});\n }\n};\n\nmodule.exports = user;\n\n\n\n// WEBPACK FOOTER //\n// ./server/routes/auth/user.js","const channelAvailability = require('./channelAvailability');\nconst channelClaims = require('./channelClaims');\nconst channelData = require('./channelData');\nconst channelShortId = require('./channelShortId');\nconst claimAvailability = require('./claimAvailability');\nconst claimData = require('./claimData');\nconst claimGet = require('./claimGet');\nconst claimLongId = require('./claimLongId');\nconst claimPublish = require('./claimPublish');\nconst claimResolve = require('./claimResolve');\nconst claimShortId = require('./claimShortId');\nconst claimList = require('./claimList');\nconst fileAvailability = require('./fileAvailability');\n\nconst multipartMiddleware = require('helpers/multipartMiddleware');\n\nmodule.exports = (app) => {\n // channel routes\n app.get('/api/channel/availability/:name', channelAvailability);\n app.get('/api/channel/short-id/:longId/:name', channelShortId);\n app.get('/api/channel/data/:channelName/:channelClaimId', channelData);\n app.get('/api/channel/claims/:channelName/:channelClaimId/:page', channelClaims);\n // claim routes\n app.get('/api/claim/list/:name', claimList);\n app.get('/api/claim/get/:name/:claimId', claimGet);\n app.get('/api/claim/availability/:name', claimAvailability);\n app.get('/api/claim/resolve/:name/:claimId', claimResolve);\n app.post('/api/claim/publish', multipartMiddleware, claimPublish);\n app.get('/api/claim/short-id/:longId/:name', claimShortId);\n app.post('/api/claim/long-id', claimLongId);\n app.get('/api/claim/data/:claimName/:claimId', claimData);\n // file routes\n app.get('/api/file/availability/:name/:claimId', fileAvailability);\n};\n\n\n\n// WEBPACK FOOTER //\n// ./server/routes/api/index.js","const { checkChannelAvailability } = require('controllers/publishController.js');\nconst { sendGATimingEvent } = require('helpers/googleAnalytics.js');\nconst { handleErrorResponse } = require('helpers/errorHandlers.js');\n\n/*\n\n route to check whether site has published to a channel\n\n*/\n\nconst channelAvailability = ({ ip, originalUrl, params: { name } }, res) => {\n const gaStartTime = Date.now();\n checkChannelAvailability(name)\n .then(availableName => {\n res.status(200).json(availableName);\n sendGATimingEvent('end-to-end', 'claim name availability', name, gaStartTime, Date.now());\n })\n .catch(error => {\n handleErrorResponse(originalUrl, ip, error, res);\n });\n};\n\nmodule.exports = channelAvailability;\n\n\n\n// WEBPACK FOOTER //\n// ./server/routes/api/channelAvailability.js","module.exports = require(\"fs\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"fs\"\n// module id = 64\n// module chunks = 0","const { getChannelClaims } = require('controllers/serveController.js');\nconst { handleErrorResponse } = require('helpers/errorHandlers.js');\n\nconst NO_CHANNEL = 'NO_CHANNEL';\n\n/*\n\n route to get all claims for channel\n\n*/\n\nconst channelClaims = ({ ip, originalUrl, body, params }, res) => {\n const channelName = params.channelName;\n let channelClaimId = params.channelClaimId;\n if (channelClaimId === 'none') channelClaimId = null;\n const page = params.page;\n getChannelClaims(channelName, channelClaimId, page)\n .then(data => {\n if (data === NO_CHANNEL) {\n return res.status(404).json({success: false, message: 'No matching channel was found'});\n }\n res.status(200).json({success: true, data});\n })\n .catch(error => {\n handleErrorResponse(originalUrl, ip, error, res);\n });\n};\n\nmodule.exports = channelClaims;\n\n\n\n// WEBPACK FOOTER //\n// ./server/routes/api/channelClaims.js","const CLAIMS_PER_PAGE = 12;\n\nmodule.exports = {\n returnPaginatedChannelClaims (channelName, longChannelClaimId, claims, page) {\n const totalPages = module.exports.determineTotalPages(claims);\n const paginationPage = module.exports.getPageFromQuery(page);\n const viewData = {\n channelName : channelName,\n longChannelClaimId: longChannelClaimId,\n claims : module.exports.extractPageFromClaims(claims, paginationPage),\n previousPage : module.exports.determinePreviousPage(paginationPage),\n currentPage : paginationPage,\n nextPage : module.exports.determineNextPage(totalPages, paginationPage),\n totalPages : totalPages,\n totalResults : module.exports.determineTotalClaims(claims),\n };\n return viewData;\n },\n getPageFromQuery (page) {\n if (page) {\n return parseInt(page);\n }\n return 1;\n },\n extractPageFromClaims (claims, pageNumber) {\n if (!claims) {\n return []; // if no claims, return this default\n }\n // logger.debug('claims is array?', Array.isArray(claims));\n // logger.debug(`pageNumber ${pageNumber} is number?`, Number.isInteger(pageNumber));\n const claimStartIndex = (pageNumber - 1) * CLAIMS_PER_PAGE;\n const claimEndIndex = claimStartIndex + CLAIMS_PER_PAGE;\n const pageOfClaims = claims.slice(claimStartIndex, claimEndIndex);\n return pageOfClaims;\n },\n determineTotalPages (claims) {\n if (!claims) {\n return 0;\n } else {\n const totalClaims = claims.length;\n if (totalClaims < CLAIMS_PER_PAGE) {\n return 1;\n }\n const fullPages = Math.floor(totalClaims / CLAIMS_PER_PAGE);\n const remainder = totalClaims % CLAIMS_PER_PAGE;\n if (remainder === 0) {\n return fullPages;\n }\n return fullPages + 1;\n }\n },\n determinePreviousPage (currentPage) {\n if (currentPage === 1) {\n return null;\n }\n return currentPage - 1;\n },\n determineNextPage (totalPages, currentPage) {\n if (currentPage === totalPages) {\n return null;\n }\n return currentPage + 1;\n },\n determineTotalClaims (claims) {\n if (!claims) {\n return 0;\n }\n return claims.length;\n },\n};\n\n\n\n// WEBPACK FOOTER //\n// ./server/helpers/channelPagination.js","const { getChannelData } = require('controllers/serveController.js');\nconst { handleErrorResponse } = require('helpers/errorHandlers.js');\n\nconst NO_CHANNEL = 'NO_CHANNEL';\n\n/*\n\n route to get data for a channel\n\n*/\n\nconst channelData = ({ ip, originalUrl, body, params }, res) => {\n const channelName = params.channelName;\n let channelClaimId = params.channelClaimId;\n if (channelClaimId === 'none') channelClaimId = null;\n getChannelData(channelName, channelClaimId, 0)\n .then(data => {\n if (data === NO_CHANNEL) {\n return res.status(404).json({success: false, message: 'No matching channel was found'});\n }\n res.status(200).json({success: true, data});\n })\n .catch(error => {\n handleErrorResponse(originalUrl, ip, error, res);\n });\n};\n\nmodule.exports = channelData;\n\n\n\n// WEBPACK FOOTER //\n// ./server/routes/api/channelData.js","const { handleErrorResponse } = require('helpers/errorHandlers.js');\nconst db = require('models');\n\n/*\n\nroute to get a short channel id from long channel Id\n\n*/\n\nconst channelShortIdRoute = ({ ip, originalUrl, params }, res) => {\n db.Certificate.getShortChannelIdFromLongChannelId(params.longId, params.name)\n .then(shortId => {\n res.status(200).json(shortId);\n })\n .catch(error => {\n handleErrorResponse(originalUrl, ip, error, res);\n });\n};\n\nmodule.exports = channelShortIdRoute;\n\n\n\n// WEBPACK FOOTER //\n// ./server/routes/api/channelShortId.js","const { claimNameIsAvailable } = require('controllers/publishController.js');\nconst { sendGATimingEvent } = require('helpers/googleAnalytics.js');\nconst { handleErrorResponse } = require('helpers/errorHandlers.js');\n\n/*\n\n route to check whether this site published to a claim\n\n*/\n\nconst claimAvailability = ({ ip, originalUrl, params: { name } }, res) => {\n const gaStartTime = Date.now();\n claimNameIsAvailable(name)\n .then(result => {\n res.status(200).json(result);\n sendGATimingEvent('end-to-end', 'claim name availability', name, gaStartTime, Date.now());\n })\n .catch(error => {\n handleErrorResponse(originalUrl, ip, error, res);\n });\n};\n\nmodule.exports = claimAvailability;\n\n\n\n// WEBPACK FOOTER //\n// ./server/routes/api/claimAvailability.js","const { handleErrorResponse } = require('helpers/errorHandlers.js');\nconst db = require('models');\n\n/*\n\n route to return data for a claim\n\n*/\n\nconst claimData = ({ ip, originalUrl, body, params }, res) => {\n const claimName = params.claimName;\n let claimId = params.claimId;\n if (claimId === 'none') claimId = null;\n db.Claim.resolveClaim(claimName, claimId)\n .then(claimInfo => {\n if (!claimInfo) {\n return res.status(404).json({success: false, message: 'No claim could be found'});\n }\n res.status(200).json({success: true, data: claimInfo});\n })\n .catch(error => {\n handleErrorResponse(originalUrl, ip, error, res);\n });\n};\n\nmodule.exports = claimData;\n\n\n\n// WEBPACK FOOTER //\n// ./server/routes/api/claimData.js","const { getClaim } = require('helpers/lbryApi.js');\nconst { addGetResultsToFileData, createFileData } = require('../../helpers/publishHelpers.js');\nconst { handleErrorResponse } = require('helpers/errorHandlers.js');\nconst db = require('models');\n\n/*\n\n route to get a claim\n\n*/\n\nconst claimGet = ({ ip, originalUrl, params }, res) => {\n const name = params.name;\n const claimId = params.claimId;\n // resolve the claim\n db.Claim.resolveClaim(name, claimId)\n .then(resolveResult => {\n // make sure a claim actually exists at that uri\n if (!resolveResult) {\n throw new Error('No matching uri found in Claim table');\n }\n let fileData = createFileData(resolveResult);\n // get the claim\n return Promise.all([fileData, getClaim(`${name}#${claimId}`)]);\n })\n .then(([ fileData, getResult ]) => {\n fileData = addGetResultsToFileData(fileData, getResult);\n return Promise.all([db.upsert(db.File, fileData, {name, claimId}, 'File'), getResult]);\n })\n .then(([ fileRecord, {message, completed} ]) => {\n res.status(200).json({ success: true, message, completed });\n })\n .catch(error => {\n handleErrorResponse(originalUrl, ip, error, res);\n });\n};\n\nmodule.exports = claimGet;\n\n\n\n// WEBPACK FOOTER //\n// ./server/routes/api/claimGet.js","const { getClaimId } = require('controllers/serveController.js');\nconst { handleErrorResponse } = require('helpers/errorHandlers.js');\n\nconst NO_CHANNEL = 'NO_CHANNEL';\nconst NO_CLAIM = 'NO_CLAIM';\n\n/*\n\n route to get a long claim id\n\n*/\n\nconst claimLongId = ({ ip, originalUrl, body, params }, res) => {\n const channelName = body.channelName;\n const channelClaimId = body.channelClaimId;\n const claimName = body.claimName;\n const claimId = body.claimId;\n getClaimId(channelName, channelClaimId, claimName, claimId)\n .then(result => {\n if (result === NO_CHANNEL) {\n return res.status(404).json({success: false, message: 'No matching channel could be found'});\n }\n if (result === NO_CLAIM) {\n return res.status(404).json({success: false, message: 'No matching claim id could be found'});\n }\n res.status(200).json({success: true, data: result});\n })\n .catch(error => {\n handleErrorResponse(originalUrl, ip, error, res);\n });\n};\n\nmodule.exports = claimLongId;\n\n\n\n// WEBPACK FOOTER //\n// ./server/routes/api/claimLongId.js","const { createBasicPublishParams, createThumbnailPublishParams, parsePublishApiRequestBody, parsePublishApiRequestFiles } = require('helpers/publishHelpers.js');\nconst { claimNameIsAvailable, publish } = require('controllers/publishController.js');\nconst { authenticateUser } = require('auth/authentication.js');\nconst { sendGATimingEvent } = require('helpers/googleAnalytics.js');\nconst { handleErrorResponse } = require('helpers/errorHandlers.js');\nconst { details: { host } } = require('siteConfig.js');\n\n/*\n\n route to publish a claim through the daemon\n\n*/\n\nconst claimPublish = ({ body, files, headers, ip, originalUrl, user }, res) => {\n // define variables\n let channelName, channelId, channelPassword, description, fileName, filePath, fileType, gaStartTime, license, name, nsfw, thumbnail, thumbnailFileName, thumbnailFilePath, thumbnailFileType, title;\n // record the start time of the request\n gaStartTime = Date.now();\n // validate the body and files of the request\n try {\n // validateApiPublishRequest(body, files);\n ({name, nsfw, license, title, description, thumbnail} = parsePublishApiRequestBody(body));\n ({fileName, filePath, fileType, thumbnailFileName, thumbnailFilePath, thumbnailFileType} = parsePublishApiRequestFiles(files));\n ({channelName, channelId, channelPassword} = body);\n } catch (error) {\n return res.status(400).json({success: false, message: error.message});\n }\n // check channel authorization\n Promise\n .all([\n authenticateUser(channelName, channelId, channelPassword, user),\n claimNameIsAvailable(name),\n createBasicPublishParams(filePath, name, title, description, license, nsfw, thumbnail),\n createThumbnailPublishParams(thumbnailFilePath, name, license, nsfw),\n ])\n .then(([{channelName, channelClaimId}, validatedClaimName, publishParams, thumbnailPublishParams]) => {\n // add channel details to the publish params\n if (channelName && channelClaimId) {\n publishParams['channel_name'] = channelName;\n publishParams['channel_id'] = channelClaimId;\n }\n // publish the thumbnail\n if (thumbnailPublishParams) {\n publish(thumbnailPublishParams, thumbnailFileName, thumbnailFileType);\n }\n // publish the asset\n return publish(publishParams, fileName, fileType);\n })\n .then(result => {\n res.status(200).json({\n success: true,\n message: 'publish completed successfully',\n data : {\n name,\n claimId: result.claim_id,\n url : `${host}/${result.claim_id}/${name}`,\n lbryTx : result,\n },\n });\n // record the publish end time and send to google analytics\n sendGATimingEvent('end-to-end', 'publish', fileType, gaStartTime, Date.now());\n })\n .catch(error => {\n handleErrorResponse(originalUrl, ip, error, res);\n });\n};\n\nmodule.exports = claimPublish;\n\n\n\n// WEBPACK FOOTER //\n// ./server/routes/api/claimPublish.js","const db = require('models');\nconst logger = require('winston');\n\nmodule.exports = {\n authenticateUser (channelName, channelId, channelPassword, user) {\n // case: no channelName or channel Id are provided (anonymous), regardless of whether user token is provided\n if (!channelName && !channelId) {\n return {\n channelName : null,\n channelClaimId: null,\n };\n }\n // case: channelName or channel Id are provided with user token\n if (user) {\n if (channelName && channelName !== user.channelName) {\n throw new Error('the provided channel name does not match user credentials');\n }\n if (channelId && channelId !== user.channelClaimId) {\n throw new Error('the provided channel id does not match user credentials');\n }\n return {\n channelName : user.channelName,\n channelClaimId: user.channelClaimId,\n };\n }\n // case: channelName or channel Id are provided with password instead of user token\n if (!channelPassword) throw new Error('no channel password provided');\n return module.exports.authenticateChannelCredentials(channelName, channelId, channelPassword);\n },\n authenticateChannelCredentials (channelName, channelId, userPassword) {\n return new Promise((resolve, reject) => {\n // hoisted variables\n let channelData;\n // build the params for finding the channel\n let channelFindParams = {};\n if (channelName) channelFindParams['channelName'] = channelName;\n if (channelId) channelFindParams['channelClaimId'] = channelId;\n // find the channel\n db.Channel\n .findOne({\n where: channelFindParams,\n })\n .then(channel => {\n if (!channel) {\n logger.debug('no channel found');\n throw new Error('Authentication failed, you do not have access to that channel');\n }\n channelData = channel.get();\n logger.debug('channel data:', channelData);\n return db.User.findOne({\n where: { userName: channelData.channelName.substring(1) },\n });\n })\n .then(user => {\n if (!user) {\n logger.debug('no user found');\n throw new Error('Authentication failed, you do not have access to that channel');\n }\n return user.comparePassword(userPassword);\n })\n .then(isMatch => {\n if (!isMatch) {\n logger.debug('incorrect password');\n throw new Error('Authentication failed, you do not have access to that channel');\n }\n logger.debug('...password was a match...');\n resolve(channelData);\n })\n .catch(error => {\n reject(error);\n });\n });\n },\n};\n\n\n\n// WEBPACK FOOTER //\n// ./server/auth/authentication.js","const { resolveUri } = require('helpers/lbryApi.js');\nconst { handleErrorResponse } = require('helpers/errorHandlers.js');\n\n/*\n\n route to run a resolve request on the daemon\n\n*/\n\nconst claimResolve = ({ headers, ip, originalUrl, params }, res) => {\n resolveUri(`${params.name}#${params.claimId}`)\n .then(resolvedUri => {\n res.status(200).json(resolvedUri);\n })\n .catch(error => {\n handleErrorResponse(originalUrl, ip, error, res);\n });\n};\n\nmodule.exports = claimResolve;\n\n\n\n// WEBPACK FOOTER //\n// ./server/routes/api/claimResolve.js","const { handleErrorResponse } = require('helpers/errorHandlers.js');\nconst db = require('models');\n\n/*\n\n route to get a short claim id from long claim Id\n\n*/\n\nconst claimShortId = ({ ip, originalUrl, body, params }, res) => {\n db.Claim.getShortClaimIdFromLongClaimId(params.longId, params.name)\n .then(shortId => {\n res.status(200).json({success: true, data: shortId});\n })\n .catch(error => {\n handleErrorResponse(originalUrl, ip, error, res);\n });\n};\n\nmodule.exports = claimShortId;\n\n\n\n// WEBPACK FOOTER //\n// ./server/routes/api/claimShortId.js","const { getClaimList } = require('helpers/lbryApi.js');\nconst { handleErrorResponse } = require('helpers/errorHandlers.js');\n\n/*\n\n route to get list of claims\n\n*/\n\nconst claimList = ({ ip, originalUrl, params }, res) => {\n getClaimList(params.name)\n .then(claimsList => {\n res.status(200).json(claimsList);\n })\n .catch(error => {\n handleErrorResponse(originalUrl, ip, error, res);\n });\n};\n\nmodule.exports = claimList;\n\n\n\n// WEBPACK FOOTER //\n// ./server/routes/api/claimList.js","const { handleErrorResponse } = require('helpers/errorHandlers.js');\nconst db = require('models');\n\n/*\n\n route to see if asset is available locally\n\n*/\n\nconst fileAvailability = ({ ip, originalUrl, params }, res) => {\n const name = params.name;\n const claimId = params.claimId;\n db.File\n .findOne({\n where: {\n name,\n claimId,\n },\n })\n .then(result => {\n if (result) {\n return res.status(200).json({success: true, data: true});\n }\n res.status(200).json({success: true, data: false});\n })\n .catch(error => {\n handleErrorResponse(originalUrl, ip, error, res);\n });\n};\n\nmodule.exports = fileAvailability;\n\n\n\n// WEBPACK FOOTER //\n// ./server/routes/api/fileAvailability.js","const multipart = require('connect-multiparty');\r\nconst { publishing: { uploadDirectory } } = require('siteConfig.js');\r\nconst multipartMiddleware = multipart({uploadDir: uploadDirectory});\r\n\r\nmodule.exports = multipartMiddleware;\r\n\n\n\n// WEBPACK FOOTER //\n// ./server/helpers/multipartMiddleware.js","module.exports = require(\"connect-multiparty\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"connect-multiparty\"\n// module id = 80\n// module chunks = 0","const handlePageRequest = require('./sendReactApp');\nconst handleEmbedRequest = require('./sendEmbedPage');\nconst redirect = require('./redirect');\n\nmodule.exports = (app) => {\n app.get('/', handlePageRequest);\n app.get('/login', handlePageRequest);\n app.get('/about', handlePageRequest);\n app.get('/trending', redirect('/popular'));\n app.get('/popular', handlePageRequest);\n app.get('/new', handlePageRequest);\n app.get('/embed/:claimId/:name', handleEmbedRequest); // route to send embedable video player (for twitter)\n};\n\n\n\n// WEBPACK FOOTER //\n// ./server/routes/pages/index.js","const handlePageRender = require('helpers/handlePageRender.jsx');\n\nconst sendReactApp = (req, res) => {\n handlePageRender(req, res);\n};\n\nmodule.exports = sendReactApp;\n\n\n\n// WEBPACK FOOTER //\n// ./server/routes/pages/sendReactApp.js","const { details: { host } } = require('siteConfig.js');\n\nconst sendEmbedPage = ({ params }, res) => {\n const claimId = params.claimId;\n const name = params.name;\n // get and render the content\n res.status(200).render('embed', { layout: 'embed', host, claimId, name });\n};\n\nmodule.exports = sendEmbedPage;\n\n\n\n// WEBPACK FOOTER //\n// ./server/routes/pages/sendEmbedPage.js","const redirect = (route) => {\n return (req, res) => {\n res.status(301).redirect(route);\n };\n};\n\nmodule.exports = redirect;\n\n\n\n// WEBPACK FOOTER //\n// ./server/routes/pages/redirect.js","const serveAssetByClaim = require('./serveAssetByClaim');\nconst serveAssetByIdentifierAndClaim = require('./serveAssetByIdentifierAndClaim');\n\nmodule.exports = (app, db) => {\n app.get('/:identifier/:claim', serveAssetByIdentifierAndClaim);\n app.get('/:claim', serveAssetByClaim);\n};\n\n\n\n// WEBPACK FOOTER //\n// ./server/routes/assets/index.js","const { sendGAServeEvent } = require('helpers/googleAnalytics');\nconst { determineResponseType, logRequestData, getClaimIdAndServeAsset } = require('helpers/serveHelpers.js');\nconst lbryUri = require('helpers/lbryUri.js');\nconst handleShowRender = require('helpers/handleShowRender.jsx');\nconst SERVE = 'SERVE';\n\n/*\n\n route to serve an asset or the react app via the claim name only\n\n*/\n\nconst serverAssetByClaim = (req, res) => {\n const { headers, ip, originalUrl, params } = req;\n // decide if this is a show request\n let hasFileExtension;\n try {\n ({ hasFileExtension } = lbryUri.parseModifier(params.claim));\n } catch (error) {\n return res.status(400).json({success: false, message: error.message});\n }\n let responseType = determineResponseType(hasFileExtension, headers);\n if (responseType !== SERVE) {\n return handleShowRender(req, res);\n }\n // handle serve request\n // send google analytics\n sendGAServeEvent(headers, ip, originalUrl);\n // parse the claim\n let claimName;\n try {\n ({claimName} = lbryUri.parseClaim(params.claim));\n } catch (error) {\n return res.status(400).json({success: false, message: error.message});\n }\n // log the request data for debugging\n logRequestData(responseType, claimName, null, null);\n // get the claim Id and then serve the asset\n getClaimIdAndServeAsset(null, null, claimName, null, originalUrl, ip, res);\n};\n\nmodule.exports = serverAssetByClaim;\n\n\n\n// WEBPACK FOOTER //\n// ./server/routes/assets/serveAssetByClaim.js","module.exports = require(\"redux-saga\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"redux-saga\"\n// module id = 87\n// module chunks = 0","module.exports = require(\"redux-saga/effects\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"redux-saga/effects\"\n// module id = 88\n// module chunks = 0","const { sendGAServeEvent } = require('helpers/googleAnalytics');\nconst {\n determineResponseType,\n flipClaimNameAndIdForBackwardsCompatibility,\n logRequestData,\n getClaimIdAndServeAsset,\n} = require('helpers/serveHelpers.js');\nconst lbryUri = require('helpers/lbryUri.js');\nconst handleShowRender = require('helpers/handleShowRender.jsx');\n\nconst SERVE = 'SERVE';\n\n/*\n\n route to serve an asset or the react app via the claim name and an identifier\n\n*/\n\nconst serverAssetByIdentifierAndClaim = (req, res) => {\n const { headers, ip, originalUrl, params } = req;\n // decide if this is a show request\n let hasFileExtension;\n try {\n ({ hasFileExtension } = lbryUri.parseModifier(params.claim));\n } catch (error) {\n return res.status(400).json({success: false, message: error.message});\n }\n let responseType = determineResponseType(hasFileExtension, headers);\n if (responseType !== SERVE) {\n return handleShowRender(req, res);\n }\n // handle serve request\n // send google analytics\n sendGAServeEvent(headers, ip, originalUrl);\n // parse the claim\n let claimName;\n try {\n ({ claimName } = lbryUri.parseClaim(params.claim));\n } catch (error) {\n return res.status(400).json({success: false, message: error.message});\n }\n // parse the identifier\n let isChannel, channelName, channelClaimId, claimId;\n try {\n ({ isChannel, channelName, channelClaimId, claimId } = lbryUri.parseIdentifier(params.identifier));\n } catch (error) {\n return res.status(400).json({success: false, message: error.message});\n }\n if (!isChannel) {\n [claimId, claimName] = flipClaimNameAndIdForBackwardsCompatibility(claimId, claimName);\n }\n // log the request data for debugging\n logRequestData(responseType, claimName, channelName, claimId);\n // get the claim Id and then serve the asset\n getClaimIdAndServeAsset(channelName, channelClaimId, claimName, claimId, originalUrl, ip, res);\n};\n\nmodule.exports = serverAssetByIdentifierAndClaim;\n\n\n\n// WEBPACK FOOTER //\n// ./server/routes/assets/serveAssetByIdentifierAndClaim.js","const handlePageRequest = require('./sendReactApp');\r\n\r\nmodule.exports = (app) => {\r\n app.get('*', handlePageRequest);\r\n};\r\n\n\n\n// WEBPACK FOOTER //\n// ./server/routes/fallback/index.js","const handlePageRender = require('helpers/handlePageRender.jsx');\n\nconst sendReactApp = (req, res) => {\n handlePageRender(req, res);\n};\n\nmodule.exports = sendReactApp;\n\n\n\n// WEBPACK FOOTER //\n// ./server/routes/fallback/sendReactApp.js"],"sourceRoot":""} |