2 lines
No EOL
52 KiB
JavaScript
2 lines
No EOL
52 KiB
JavaScript
module.exports=function(e){function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}var t={};return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="/",n(n.s=26)}([function(e,n){e.exports=require("winston")},function(e,n,t){"use strict";var r=function(){function e(e,n){var t=[],r=!0,a=!1,i=void 0;try{for(var o,l=e[Symbol.iterator]();!(r=(o=l.next()).done)&&(t.push(o.value),!n||t.length!==n);r=!0);}catch(e){a=!0,i=e}finally{try{!r&&l.return&&l.return()}finally{if(a)throw i}}return t}return function(n,t){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return e(n,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),a=t(0);e.exports={handleErrorResponse:function(n,t,i,o){a.error("Error on "+n,e.exports.useObjectPropertiesIfNoKeys(i));var l=e.exports.returnErrorMessageAndStatus(i),s=r(l,2),u=s[0],c=s[1];o.status(u).json(e.exports.createErrorResponsePayload(u,c))},returnErrorMessageAndStatus:function(e){var n=void 0,t=void 0;return"ECONNREFUSED"===e.code?(n=503,t="Connection refused. The daemon may not be running."):(n=400,t=e.message?e.message:e),[n,t]},useObjectPropertiesIfNoKeys:function(e){if(0===Object.keys(e).length){var n={};return Object.getOwnPropertyNames(e).forEach(function(t){n[t]=e[t]}),n}return e},createErrorResponsePayload:function(e,n){return{status:e,success:!1,message:n}}}},function(e,n,t){"use strict";var r=t(44),a=t(45),i=t(46),o=t(47),l=t(48),s=t(49),u=t(13),c=t(0),d=t(10),f=d.database,h=d.username,m=d.password,p=new u(f,h,m,{host:"localhost",dialect:"mysql",dialectOptions:{decimalNumbers:!0},logging:!1,pool:{max:5,min:0,idle:1e4,acquire:1e4}});p.authenticate().then(function(){c.info("Sequelize has established mysql connection successfully.")}).catch(function(e){c.error("Sequelize was unable to connect to the database:",e)});var g={};g.Certificate=p.import("Certificate",r),g.Channel=p.import("Channel",a),g.Claim=p.import("Claim",i),g.File=p.import("File",o),g.Request=p.import("Request",l),g.User=p.import("User",s),c.info("associating db models..."),Object.keys(g).forEach(function(e){g[e].associate&&(c.info("Associating model:",e),g[e].associate(g))}),g.sequelize=p,g.Sequelize=u,g.upsert=function(e,n,t,r){return e.findOne({where:t}).then(function(t){return t?(c.debug("updating record in db."+r),t.update(n)):(c.debug("creating record in db."+r),e.create(n))}).catch(function(e){throw c.error(r+".upsert error",e),e})},e.exports=g},function(e,n,t){"use strict";function r(){var e=this;this.analytics={googleId:"default"},this.assetDefaults={description:"An asset published on Spee.ch",thumbnail:"https://spee.ch/assets/img/video_thumb_default.png",title:"A Spee.ch Implementation"},this.auth={sessionKey:"default"},this.customComponents={},this.customContainers={},this.customPages={},this.details={description:"Welcome to my decentralized image and video sharing site.",host:"http://localhost:3000",port:3e3,title:"My Spee.ch Site",twitter:"@exampleTwitterHandle"},this.publishing={additionalClaimAddresses:[],disabled:!1,disabledMessage:"Please check back soon.",primaryClaimAddress:"default",thumbnailChannel:"default",thumbnailChannelId:"default",uploadDirectory:"/home/lbry/Uploads"},this.routes={},this.update=function(n){if(!n)return console.log("No site config received.");var t=n.analytics,r=n.assetDefaults,a=n.auth,i=n.customComponents,o=n.customContainers,l=n.customPages,s=n.details,u=n.publishing,c=n.routes;console.log("Configuring site details..."),e.analytics=t,e.assetDefaults=r,e.auth=a,e.details=s,e.publishing=u,e.customComponents=i,e.customContainers=o,e.customPages=l,e.routes=c}}e.exports=new r},function(e,n,t){"use strict";function r(e,n,t){return{eventCategory:"client requests",eventAction:"serve request",eventLabel:t,ipOverride:n,userAgentOverride:e["user-agent"]}}function a(e,n,t,r,a){return{userTimingCategory:e,userTimingVariableName:n,userTimingTime:a-r,userTimingLabel:t}}function i(e,n){var t=e.replace(/\./g,"-");s(c,t,{strictCidFormat:!1,https:!0}).event(n,function(e){e&&l.error("Google Analytics Event Error >>",e)})}function o(e,n){s(c,e,{strictCidFormat:!1,https:!0}).timing(n,function(e){e&&l.error("Google Analytics Event Error >>",e),l.debug("Timing event successfully sent to google analytics")})}var l=t(0),s=t(54),u=t(3),c=u.analytics.googleId,d=u.details.title;e.exports={sendGAServeEvent:function(e,n,t){i(n,r(e,n,t))},sendGATimingEvent:function(e,n,t,r,i){var l=a(e,n,t,r,i);o(d,l)},chooseGaLbrynetPublishLabel:function(e){var n=e.channel_name,t=e.channel_id;return n||t?"PUBLISH_IN_CHANNEL_CLAIM":"PUBLISH_ANONYMOUS_CLAIM"}}},function(e,n,t){"use strict";var r=t(52),a=t(0),i=t(53),o=i.api,l=o.apiHost,s=o.apiPort,u="http://"+l+":"+s,c=t(4),d=c.chooseGaLbrynetPublishLabel,f=c.sendGATimingEvent,h=function(e,n,t){var r=e.data;if(a.debug("lbry api data:",r),r.result)return r.result.error?(a.debug("Lbrynet api error:",r.result.error),void t(new Error(r.result.error))):void n(r.result);t(JSON.stringify(r))};e.exports={publishClaim:function(e){a.debug('lbryApi >> Publishing claim to "'+e.name+'"');var n=Date.now();return new Promise(function(t,a){r.post(u,{method:"publish",params:e}).then(function(r){f("lbrynet","publish",d(e),n,Date.now()),h(r,t,a)}).catch(function(e){a(e)})})},getClaim:function(e){a.debug('lbryApi >> Getting Claim for "'+e+'"');var n=Date.now();return new Promise(function(t,a){r.post(u,{method:"get",params:{uri:e,timeout:20}}).then(function(e){f("lbrynet","getClaim","GET",n,Date.now()),h(e,t,a)}).catch(function(e){a(e)})})},getClaimList:function(e){a.debug('lbryApi >> Getting claim_list for "'+e+'"');var n=Date.now();return new Promise(function(t,a){r.post(u,{method:"claim_list",params:{name:e}}).then(function(e){f("lbrynet","getClaimList","CLAIM_LIST",n,Date.now()),h(e,t,a)}).catch(function(e){a(e)})})},resolveUri:function(e){a.debug('lbryApi >> Resolving URI for "'+e+'"');var n=Date.now();return new Promise(function(t,a){r.post(u,{method:"resolve",params:{uri:e}}).then(function(r){var i=r.data;f("lbrynet","resolveUri","RESOLVE",n,Date.now()),i.result[e].error?a(i.result[e].error):t(i.result[e])}).catch(function(e){a(e)})})},getDownloadDirectory:function(){a.debug("lbryApi >> Retrieving the download directory path from lbry daemon...");var e=Date.now();return new Promise(function(n,t){r.post(u,{method:"settings_get"}).then(function(t){var r=t.data;if(f("lbrynet","getDownloadDirectory","SETTINGS_GET",e,Date.now()),!r.result)return new Error("Successfully connected to lbry daemon, but unable to retrieve the download directory.");n(r.result.download_directory)}).catch(function(e){a.error("Lbrynet Error:",e),n("/home/lbry/Downloads/")})})},createChannel:function(e){a.debug("lbryApi >> Creating channel for "+e+"...");var n=Date.now();return new Promise(function(t,a){r.post(u,{method:"channel_new",params:{channel_name:e,amount:.1}}).then(function(e){f("lbrynet","createChannel","CHANNEL_NEW",n,Date.now()),h(e,t,a)}).catch(function(e){a(e)})})}}},function(e,n,t){"use strict";var r=function(){function e(e,n){var t=[],r=!0,a=!1,i=void 0;try{for(var o,l=e[Symbol.iterator]();!(r=(o=l.next()).done)&&(t.push(o.value),!n||t.length!==n);r=!0);}catch(e){a=!0,i=e}finally{try{!r&&l.return&&l.return()}finally{if(a)throw i}}return t}return function(n,t){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return e(n,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),a=t(2),i=t(0),o=t(65),l=o.returnPaginatedChannelClaims;e.exports={getClaimId:function(n,t,r,a){return n?e.exports.getClaimIdByChannel(n,t,r):e.exports.getClaimIdByClaim(r,a)},getClaimIdByClaim:function(e,n){return i.debug("getClaimIdByClaim("+e+", "+n+")"),new Promise(function(t,r){a.Claim.getLongClaimId(e,n).then(function(e){e||t("NO_CLAIM"),t(e)}).catch(function(e){r(e)})})},getClaimIdByChannel:function(e,n,t){return i.debug("getClaimIdByChannel("+e+", "+n+", "+t+")"),new Promise(function(i,o){a.Certificate.getLongChannelId(e,n).then(function(e){return e?Promise.all([e,a.Claim.getClaimIdByLongChannelId(e,t)]):[null,null]}).then(function(e){var n=r(e,2),t=n[0],a=n[1];return t?a?void i(a):i("NO_CLAIM"):i("NO_CHANNEL")}).catch(function(e){o(e)})})},getChannelData:function(e,n,t){return new Promise(function(t,i){a.Certificate.getLongChannelId(e,n).then(function(n){return n?Promise.all([n,a.Certificate.getShortChannelIdFromLongChannelId(n,e)]):[null,null,null]}).then(function(n){var a=r(n,2),i=a[0],o=a[1];if(!i)return t("NO_CHANNEL");t({channelName:e,longChannelClaimId:i,shortChannelClaimId:o})}).catch(function(e){i(e)})})},getChannelClaims:function(e,n,t){return new Promise(function(i,o){a.Certificate.getLongChannelId(e,n).then(function(e){return e?Promise.all([e,a.Claim.getAllChannelClaims(e)]):[null,null,null]}).then(function(n){var a=r(n,2),o=a[0],s=a[1];if(!o)return i("NO_CHANNEL");var u=l(e,o,s,t);i(u)}).catch(function(e){o(e)})})},getLocalFileRecord:function(e,n){return a.File.findOne({where:{claimId:e,name:n}}).then(function(e){return e?e.dataValues:"NO_FILE"})}}},function(e,n,t){"use strict";var r=t(42),a=t(43),i=t(51),o=t(55),l=o.serializeSpeechUser,s=o.deserializeSpeechUser;r.deserializeUser(s),r.serializeUser(l),r.use("local-login",a),r.use("local-signup",i),e.exports=r},function(e,n,t){"use strict";function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var a=function(){function e(e,n){var t=[],r=!0,a=!1,i=void 0;try{for(var o,l=e[Symbol.iterator]();!(r=(o=l.next()).done)&&(t.push(o.value),!n||t.length!==n);r=!0);}catch(e){a=!0,i=e}finally{try{!r&&l.return&&l.return()}finally{if(a)throw i}}return t}return function(n,t){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return e(n,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),i=t(0),o=t(2),l=t(5),s=t(9),u=t(3),c=u.publishing,d=c.primaryClaimAddress,f=c.additionalClaimAddresses,h=t(13),m=h.Op;e.exports={publish:function(e,n,t){return new Promise(function(r,u){var c=void 0,d=void 0,f=void 0;return l.publishClaim(e).then(function(t){return i.info("Successfully published "+e.name+" "+n,t),c=t,e.channel_name?(i.debug("this claim was published in channel: "+e.channel_name),o.Channel.findOne({where:{channelName:e.channel_name}})):(i.debug("this claim was not published in a channel"),null)}).then(function(e){d=null,f=null,e&&(d=e.channelClaimId,f=e.channelName),i.debug("certificateId: "+d)}).then(function(){var r={name:e.name,claimId:c.claim_id,title:e.metadata.title,description:e.metadata.description,address:e.claim_address,outpoint:c.txid+":"+c.nout,height:0,fileName:n,filePath:e.file_path,fileType:t,nsfw:e.metadata.nsfw},a={name:e.name,claimId:c.claim_id,title:e.metadata.title,description:e.metadata.description,address:e.claim_address,thumbnail:e.metadata.thumbnail,outpoint:c.txid+":"+c.nout,height:0,contentType:t,nsfw:e.metadata.nsfw,amount:e.bid,certificateId:d,channelName:f},i={name:e.name,claimId:c.claim_id};return Promise.all([o.upsert(o.File,r,i,"File"),o.upsert(o.Claim,a,i,"Claim")])}).then(function(e){var n=a(e,2),t=n[0],r=n[1];return i.debug("File and Claim records successfully created"),Promise.all([t.setClaim(r),r.setFile(t)])}).then(function(){i.debug("File and Claim records successfully associated"),r(c)}).catch(function(n){i.error("PUBLISH ERROR",n),s.deleteTemporaryFile(e.file_path),u(n)})})},claimNameIsAvailable:function(e){var n=f||[];return n.push(d),o.Claim.findAll({attributes:["address"],where:{name:e,address:r({},m.or,n)}}).then(function(n){if(n.length>=1)throw new Error("That claim is already in use");return e}).catch(function(e){throw e})},checkChannelAvailability:function(e){return o.Channel.findAll({where:{channelName:e}}).then(function(n){if(n.length>=1)throw new Error("That channel has already been claimed");return e}).catch(function(e){throw e})}}},function(e,n,t){"use strict";var r=t(0),a=t(63),i=t(3),o=i.details,l=i.publishing;e.exports={parsePublishApiRequestBody:function(e){var n=e.name,t=e.nsfw,r=e.license,a=e.title,i=e.description,o=e.thumbnail;if(!n)throw new Error("no name field found in request");if(/[^A-Za-z0-9,-]/.exec(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 "-"');return t="true"===t,r=r||null,a=a||null,i=i||null,o=o||null,{name:n,nsfw:t,license:r,title:a,description:i,thumbnail:o}},parsePublishApiRequestFiles:function(n){var t=n.file,r=n.thumbnail;if(!t)throw new Error("no file with key of [file] found in request");if(!t.path)throw new Error("no file path found");if(!t.type)throw new Error("no file type found");if(!t.size)throw new Error("no file type found");if(/'/.test(t.name))throw new Error("apostrophes are not allowed in the file name");return e.exports.validateFileTypeAndSize(t),{fileName:t.name,filePath:t.path,fileType:t.type,thumbnailFileName:r?r.name:null,thumbnailFilePath:r?r.path:null,thumbnailFileType:r?r.type:null}},validateFileTypeAndSize:function(e){switch(e.type){case"image/jpeg":case"image/jpg":case"image/png":if(e.size>1e7)throw r.debug("publish > file validation > .jpeg/.jpg/.png was too big"),new Error("Sorry, images are limited to 10 megabytes.");break;case"image/gif":if(e.size>5e7)throw r.debug("publish > file validation > .gif was too big"),new Error("Sorry, .gifs are limited to 50 megabytes.");break;case"video/mp4":if(e.size>5e7)throw r.debug("publish > file validation > .mp4 was too big"),new Error("Sorry, videos are limited to 50 megabytes.");break;default:throw r.debug("publish > file validation > unrecognized file type"),new Error("The "+e.type+" content type is not supported. Only, .jpeg, .png, .gif, and .mp4 files are currently supported.")}return e},createBasicPublishParams:function(e,n,t,a,i,s,u){r.debug("Creating Publish Parameters"),null!==t&&""!==t.trim()||(t=n),null!==a&&""!==a.trim()||(a=""),null!==i&&""!==i.trim()||(i=" ");var c={name:n,file_path:e,bid:.01,metadata:{description:a,title:t,author:o.title,language:"en",license:i,nsfw:s},claim_address:l.primaryClaimAddress};return u&&(c.metadata.thumbnail=u),c},createThumbnailPublishParams:function(e,n,t,a){if(e)return r.debug("Creating Thumbnail Publish Parameters"),{name:n+"-thumb",file_path:e,bid:.01,metadata:{title:n+" thumbnail",description:"a thumbnail for "+n,author:o.title,language:"en",license:t,nsfw:a},claim_address:l.primaryClaimAddress,channel_name:l.thumbnailChannel,channel_id:l.thumbnailChannelId}},deleteTemporaryFile:function(e){a.unlink(e,function(n){if(n)throw r.error("error deleting temporary file "+e),n;r.debug("successfully deleted "+e)})},addGetResultsToFileData:function(e,n){return e.fileName=n.file_name,e.filePath=n.download_path,e},createFileData:function(e){var n=e.name,t=e.claimId,r=e.outpoint,a=e.height,i=e.address,o=e.nsfw;return{name:n,claimId:t,outpoint:r,height:a,address:i,fileName:"",filePath:"",fileType:e.contentType,nsfw:o}}}},function(e,n,t){"use strict";function r(){var e=this;this.database="default",this.username="default",this.password="default",this.update=function(n){if(!n)return a.warn("No MySQL config received.");a.info("configuring mysql...");var t=n.database,r=n.username,i=n.password;e.database=t,e.username=r,e.password=i}}var a=t(0);e.exports=new r},function(e,n){e.exports=require("passport-local")},function(e,n,t){"use strict";e.exports={returnShortId:function(e,n){var t=void 0,r=n.substring(0,1),a=0;if((t=e.findIndex(function(e){return e.claimId===n}))<0)throw new Error("claim id not found in claims list");for(var i=e.slice(0,t);i.length>0;)a+=1,r=n.substring(0,a),i=i.filter(function(e){return e.claimId&&e.claimId.substring(0,a)===r});return r}}},function(e,n){e.exports=require("sequelize")},function(e,n,t){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}var a=t(15),i=r(a),o=t(16),l=t(17),s=t(18),u=t(19),c=t(20),d=t(21),f=r(d),h=t(22),m=r(h),p=t(3);e.exports=function(e,n){var t={},r=(0,c.Reducers)(p),a=(0,c.App)(p),d=(0,c.GAListener)(p),h=(0,l.createStore)(r),g=(0,o.renderToString)(i.default.createElement(s.Provider,{store:h},i.default.createElement(u.StaticRouter,{location:e.url,context:t},i.default.createElement(d,null,i.default.createElement(a,null))))),v=m.default.renderStatic();if(t.url)return n.redirect(301,t.url);var y=h.getState();n.send((0,f.default)(v,g,y)),console.log("hello from spee.ch handlePageRender.jsx")}},function(e,n){e.exports=require("react")},function(e,n){e.exports=require("react-dom/server")},function(e,n){e.exports=require("redux")},function(e,n){e.exports=require("react-redux")},function(e,n){e.exports=require("react-router-dom")},function(e,n){e.exports=require("spee.ch-components")},function(e,n,t){"use strict";e.exports=function(e,n,t){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 \x3c!--helmet--\x3e\n '+e.title.toString()+"\n "+e.meta.toString()+"\n "+e.link.toString()+'\n \x3c!--style sheets--\x3e\n <link rel="stylesheet" href="/assets/css/reset.css" type="text/css">\n <link rel="stylesheet" href="/assets/css/general.css" type="text/css">\n <link rel="stylesheet" href="/assets/css/mediaQueries.css" type="text/css">\n \x3c!--google font--\x3e\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">'+n+"</div>\n </div>\n <script>\n window.__PRELOADED_STATE__ = "+JSON.stringify(t).replace(/</g,"\\<")+'\n <\/script>\n <script src="/bundle/bundle.js"><\/script>\n </body>\n </html>\n '}},function(e,n){e.exports=require("react-helmet")},function(e,n,t){"use strict";function r(e){var n=e.accept;return n&&n.match(/text\/html/)}function a(e){return e["user-agent"]&&e["user-agent"].match(/Mozilla/)}function i(e){var n=e.accept,t=e.range,r=n&&n.match(/image\/.*/)&&!n.match(/text\/html/)&&!n.match(/text\/\*/),a=n&&t;return r||a}function o(e){return 40===e.length&&!/[^A-Za-z0-9]/g.test(e)}function l(e){return 1===e.length}function s(e){return o(e)||l(e)}function u(e,n,t){return h(e,n).then(function(r){if(r===g)return t.status(307).redirect("/api/claim/get/"+n+"/"+e);var a=r.filePath,i=r.fileType;c.verbose("serving file: "+a);var o={headers:{"X-Content-Type-Options":"nosniff","Content-Type":i||"image/jpeg"}};t.status(200).sendFile(a,o)}).catch(function(e){throw e})}var c=t(0),d=t(6),f=d.getClaimId,h=d.getLocalFileRecord,m=t(1),p=m.handleErrorResponse,g="NO_FILE";e.exports={getClaimIdAndServeAsset:function(e,n,t,r,a,i,o){f(e,n,t,r).then(function(e){return"NO_CLAIM"===e?o.status(404).json({success:!1,message:"no claim id could be found"}):"NO_CHANNEL"===e?o.status(404).json({success:!1,message:"no channel id could be found"}):void u(e,t,o)}).catch(function(e){p(a,i,e,o)})},determineResponseType:function(e,n){var t=void 0;return e?(t="SERVE",r(n)&&(t="SHOW")):(t="SHOW",i(n)&&a(n)&&(c.debug("Show request came from browser but wants an image/video. Changing response to serve..."),t="SERVE")),t},flipClaimNameAndIdForBackwardsCompatibility:function(e,n){if(s(n)&&!s(e)){var t=n;n=e,e=t}return[e,n]},logRequestData:function(e,n,t,r){c.debug("responseType ===",e),c.debug("claim name === ",n),c.debug("channel name ===",t),c.debug("claim id ===",r)}}},function(e,n,t){"use strict";var r=function(){function e(e,n){var t=[],r=!0,a=!1,i=void 0;try{for(var o,l=e[Symbol.iterator]();!(r=(o=l.next()).done)&&(t.push(o.value),!n||t.length!==n);r=!0);}catch(e){a=!0,i=e}finally{try{!r&&l.return&&l.return()}finally{if(a)throw i}}return t}return function(n,t){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return e(n,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),a=t(0);e.exports={REGEXP_INVALID_CLAIM:/[^A-Za-z0-9-]/g,REGEXP_INVALID_CHANNEL:/[^A-Za-z0-9-@]/g,REGEXP_ADDRESS:/^b(?=[^0OIl]{32,33})[0-9A-Za-z]{32,33}$/,CHANNEL_CHAR:"@",parseIdentifier:function(n){a.debug("parsing identifier:",n);var t=new RegExp("([^:$#/]*)([:$#]?)([^/]*)"),i=t.exec(n).map(function(e){return e||null}),o=r(i,4),l=o[0],s=o[1],u=o[2],c=o[3];if(a.debug(l+", "+s+", "+u+", "+c),!s)throw new Error('Check your url. No channel name provided before "'+u+'"');var d=s.startsWith(e.exports.CHANNEL_CHAR),f=d?s:null,h=void 0;if(d){if(!f)throw new Error("No channel name after @.");var m=f.match(e.exports.REGEXP_INVALID_CHANNEL);if(m)throw new Error("Invalid characters in channel name: "+m.join(", ")+".")}else h=s;var p=void 0;if(u){if(!c)throw new Error('No modifier provided after separator "'+u+'"');if(":"!==u)throw new Error('The "'+u+'" modifier is not currently supported');p=c}return{isChannel:d,channelName:f,channelClaimId:p,claimId:h}},parseClaim:function(n){a.debug("parsing name:",n);var t=new RegExp("([^:$#/.]*)([:$#.]?)([^/]*)"),i=t.exec(n).map(function(e){return e||null}),o=r(i,4),l=o[0],s=o[1],u=o[2],c=o[3];if(a.debug(l+", "+s+", "+u+", "+c),!s)throw new Error("No claim name provided before .");var d=s.match(e.exports.REGEXP_INVALID_CLAIM);if(d)throw new Error("Invalid characters in claim name: "+d.join(", ")+".");if(u){if(!c)throw new Error("No file extension provided after separator "+u+".");if("."!==u)throw new Error("The "+u+" modifier is not supported in the claim name")}return{claimName:s}},parseModifier:function(e){a.debug("parsing modifier:",e);var n=new RegExp("([^:$#/.]*)([:$#.]?)([^/]*)"),t=n.exec(e).map(function(e){return e||null}),i=r(t,4),o=i[0],l=i[1],s=i[2],u=i[3];a.debug(o+", "+l+", "+s+", "+u);var c=!1;return s&&(c=!0),{hasFileExtension:c}}}},function(e,n,t){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}var a=t(15),i=r(a),o=t(16),l=t(17),s=t(18),u=t(19),c=t(21),d=r(c),f=t(86),h=r(f),m=t(87),p=t(20),g=t(22),v=r(g),y=t(3),b=function(e,n){return regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,(0,m.call)(e,n);case 2:case"end":return t.stop()}},t,this)})};e.exports=function(e,n){var t={},r=(0,p.Reducers)(y),a=(0,p.App)(y),c=(0,p.GAListener)(y),f=(0,h.default)(),m=(0,l.applyMiddleware)(f),g=(0,l.createStore)(r,m),w=p.Actions.onHandleShowPageUri(e.params),C=b(p.Sagas.handleShowPageUri,w);f.run(C).done.then(function(){var r=(0,o.renderToString)(i.default.createElement(s.Provider,{store:g},i.default.createElement(u.StaticRouter,{location:e.url,context:t},i.default.createElement(c,null,i.default.createElement(a,null))))),l=v.default.renderStatic();if(t.url)return n.redirect(301,t.url);var f=g.getState();n.send((0,d.default)(l,r,f))}),console.log("hello from spee.ch handleShowRender.jsx")}},function(e,n,t){t(27),t(28),e.exports=t(29)},function(e,n){e.exports=require("babel-polyfill")},function(e,n){e.exports=require("whatwg-fetch")},function(e,n,t){"use strict";function r(){var e=this;this.configureLogger=function(e){m.update(e)},this.configureMysql=function(e){p.update(e)},this.configureSite=function(e){g.update(e)},this.configureSlack=function(e){v.update(e)},this.configureModels=function(){d.debug("here is where you could add/overwrite the default models")},this.configureRoutes=function(){d.debug("here is where you could add/overwrite the default routes")},this.createApp=function(){var n=a();if(n.enable("trust proxy"),n.use(s()),g.routes.publicFolder){var r=h.resolve(process.cwd(),g.routes.publicFolder);n.use(a.static(r)),d.info("serving static files from custom path:",r)}else{var c=h.resolve(process.cwd(),"public");n.use(a.static(c)),d.warn("serving static files from default static path at "+c+". Please specify a path in your config/siteConfig.js file")}n.use(i.json()),n.use(i.urlencoded({extended:!0})),n.use(f);var m=t(7),p=g.auth.sessionKey;n.use(u({name:"session",keys:[p],maxAge:864e5})),n.use(m.initialize()),n.use(m.session());var v=o.create({defaultLayout:"embed",handlebars:l});n.engine("handlebars",v.engine),n.set("view engine","handlebars"),t(56)(n),t(61)(n),t(80)(n),t(84)(n),t(89)(n),e.app=n},this.initialize=function(){e.createApp(),e.server=c.Server(e.app)},this.start=function(){var n=t(2),r=g.details.port;n.sequelize.sync().then(function(){e.server.listen(r,function(){d.info("Server is listening on PORT "+r)})}).catch(function(e){d.error("Startup Error:",e)})}}var a=t(30),i=t(31),o=t(32),l=t(33),s=t(34),u=t(35),c=t(36),d=t(0),f=t(37),h=t(38),m=t(39),p=t(10),g=t(3),v=t(40);e.exports=r},function(e,n){e.exports=require("express")},function(e,n){e.exports=require("body-parser")},function(e,n){e.exports=require("express-handlebars")},function(e,n){e.exports=require("handlebars")},function(e,n){e.exports=require("helmet")},function(e,n){e.exports=require("cookie-session")},function(e,n){e.exports=require("http")},function(e,n,t){"use strict";var r=t(0),a=function(e,n,t){r.debug("Request on "+e.originalUrl+" from "+e.ip),t()};e.exports=a},function(e,n){e.exports=require("path")},function(e,n,t){"use strict";function r(){var e=this;this.logLevel="debug",this.update=function(n){if(!n)return a.warn("No logger config received.");a.info("configuring winston logger...");var t=n.logLevel;e.logLevel=t,a.configure({transports:[new a.transports.Console({level:e.logLevel,timestamp:!1,colorize:!0,prettyPrint:!0,handleExceptions:!0,humanReadableUnhandledException:!0})]}),a.info("testing winston log levels..."),a.error("Level 0"),a.warn("Level 1"),a.info("Level 2"),a.verbose("Level 3"),a.debug("Level 4"),a.silly("Level 5")}}var a=t(0);e.exports=new r},function(e,n,t){"use strict";function r(){var e=this;this.slackWebHook="default",this.slackErrorChannel="default",this.slackInfoChannel="default",this.update=function(n){if(!n)return i.warn("No slack config received");i.info("configuring slack logger...");var t=n.slackWebHook,r=n.slackErrorChannel,o=n.slackInfoChannel;e.slackWebHook=t,e.slackErrorChannel=r,e.slackInfoChannel=o,e.slackWebHook?(e.slackErrorChannel&&i.add(a,{name:"slack-errors-transport",level:"warn",webhookUrl:e.slackWebHook,channel:e.slackErrorChannel,username:"spee.ch",iconEmoji:":face_with_head_bandage:"}),o&&i.add(a,{name:"slack-info-transport",level:"info",webhookUrl:e.slackWebHook,channel:e.slackInfoChannel,username:"spee.ch",iconEmoji:":nerd_face:"}),i.info("testing slack logger..."),i.error('Slack "error" logging is online.'),i.info('Slack "info" logging is online.')):i.warn("Slack logging is not enabled because no slackWebHook config var provided.")}}var a=t(41).SlackWebHook,i=t(0);e.exports=new r},function(e,n){e.exports=require("winston-slack-webhook")},function(e,n){e.exports=require("passport")},function(e,n,t){"use strict";var r=t(11).Strategy,a=t(0),i=t(2),o=function(e){return new Promise(function(n,t){var r={};r.id=e.id,r.userName=e.userName,e.getChannel().then(function(e){var n=e.channelName,t=e.channelClaimId;return r.channelName=n,r.channelClaimId=t,i.Certificate.getShortChannelIdFromLongChannelId(t,n)}).then(function(e){r.shortChannelId=e,n(r)}).catch(function(e){t(e)})})};e.exports=new r({usernameField:"username",passwordField:"password"},function(e,n,t){return i.User.findOne({where:{userName:e}}).then(function(e){return e?e.comparePassword(n).then(function(n){return n?(a.debug("Password was a match, returning User"),o(e).then(function(e){return t(null,e)}).catch(function(e){return e})):(a.debug("incorrect password"),t(null,!1,{message:"Incorrect username or password"}))}).catch(function(e){return e}):(a.debug("no user found"),t(null,!1,{message:"Incorrect username or password"}))}).catch(function(e){return t(e)})})},function(e,n,t){"use strict";var r=t(0),a=t(12),i=a.returnShortId;e.exports=function(e,n){var t=n.STRING,a=n.BOOLEAN,o=n.INTEGER,l=n.TEXT,s=n.DECIMAL,u=e.define("Certificate",{address:{type:t,default:null},amount:{type:s(19,8),default:null},claimId:{type:t,default:null},claimSequence:{type:o,default:null},decodedClaim:{type:a,default:null},depth:{type:o,default:null},effectiveAmount:{type:s(19,8),default:null},hasSignature:{type:a,default:null},height:{type:o,default:null},hex:{type:l("long"),default:null},name:{type:t,default:null},nout:{type:o,default:null},txid:{type:t,default:null},validAtHeight:{type:o,default:null},outpoint:{type:t,default:null},valueVersion:{type:t,default:null},claimType:{type:t,default:null},certificateVersion:{type:t,default:null},keyType:{type:t,default:null},publicKey:{type:l("long"),default:null}},{freezeTableName:!0});return u.associate=function(e){u.belongsTo(e.Channel,{foreignKey:{allowNull:!0}})},u.getShortChannelIdFromLongChannelId=function(e,n){var t=this;return r.debug("getShortChannelIdFromLongChannelId "+n+":"+e),new Promise(function(r,a){t.findAll({where:{name:n},order:[["height","ASC"]]}).then(function(n){switch(n.length){case 0:throw new Error("No channel(s) found with that channel name");default:return r(i(n,e))}}).catch(function(e){a(e)})})},u.getLongChannelIdFromShortChannelId=function(e,n){var t=this;return r.debug("getLongChannelIdFromShortChannelId("+e+", "+n+")"),new Promise(function(r,a){t.findAll({where:{name:e,claimId:{$like:n+"%"}},order:[["height","ASC"]]}).then(function(e){switch(e.length){case 0:return r(null);default:return r(e[0].claimId)}}).catch(function(e){a(e)})})},u.getLongChannelIdFromChannelName=function(e){var n=this;return r.debug("getLongChannelIdFromChannelName("+e+")"),new Promise(function(t,r){n.findAll({where:{name:e},order:[["effectiveAmount","DESC"],["height","ASC"]]}).then(function(e){switch(e.length){case 0:return t(null);default:return t(e[0].claimId)}}).catch(function(e){r(e)})})},u.validateLongChannelId=function(e,n){var t=this;return r.debug("validateLongChannelId("+e+", "+n+")"),new Promise(function(r,a){t.findOne({where:{name:e,claimId:n}}).then(function(e){if(!e)return r(null);r(n)}).catch(function(e){a(e)})})},u.getLongChannelId=function(e,n){return r.debug("getLongChannelId("+e+", "+n+")"),n&&40===n.length?this.validateLongChannelId(e,n):n&&n.length<40?this.getLongChannelIdFromShortChannelId(e,n):this.getLongChannelIdFromChannelName(e)},u}},function(e,n,t){"use strict";e.exports=function(e,n){var t=n.STRING,r=e.define("Channel",{channelName:{type:t,allowNull:!1},channelClaimId:{type:t,allowNull:!1}},{freezeTableName:!0});return r.associate=function(e){r.belongsTo(e.User),r.hasOne(e.Certificate)},r}},function(e,n,t){"use strict";function r(e){switch(e){case"image/jpeg":case"image/jpg":return"jpeg";case"image/png":return"png";case"image/gif":return"gif";case"video/mp4":return"mp4";default:return o.debug("setting unknown file type as file extension jpeg"),"jpeg"}}function a(e,n){return""===e?n:e}function i(e){return e.thumbnail=a(e.thumbnail,c),e.fileExt=r(e.contentType),e.host=d,e}var o=t(0),l=t(12),s=l.returnShortId,u=t(3),c=u.assetDefaults.thumbnail,d=u.details.host;e.exports=function(e,n){var t=n.STRING,l=n.BOOLEAN,u=n.INTEGER,d=n.TEXT,f=n.DECIMAL,h=e.define("Claim",{address:{type:t,default:null},amount:{type:f(19,8),default:null},claimId:{type:t,default:null},claimSequence:{type:u,default:null},decodedClaim:{type:l,default:null},depth:{type:u,default:null},effectiveAmount:{type:f(19,8),default:null},hasSignature:{type:l,default:null},height:{type:u,default:null},hex:{type:d("long"),default:null},name:{type:t,default:null},nout:{type:u,default:null},txid:{type:t,default:null},validAtHeight:{type:u,default:null},outpoint:{type:t,default:null},claimType:{type:t,default:null},certificateId:{type:t,default:null},author:{type:t,default:null},description:{type:d("long"),default:null},language:{type:t,default:null},license:{type:t,default:null},licenseUrl:{type:t,default:null},nsfw:{type:l,default:null},preview:{type:t,default:null},thumbnail:{type:t,default:null},title:{type:t,default:null},metadataVersion:{type:t,default:null},contentType:{type:t,default:null},source:{type:t,default:null},sourceType:{type:t,default:null},sourceVersion:{type:t,default:null},streamVersion:{type:t,default:null},valueVersion:{type:t,default:null},channelName:{type:t,allowNull:!0,default:null}},{freezeTableName:!0});return h.associate=function(e){h.belongsTo(e.File,{foreignKey:{allowNull:!0}})},h.getShortClaimIdFromLongClaimId=function(e,n){var t=this;return o.debug("Claim.getShortClaimIdFromLongClaimId for "+n+"#"+e),new Promise(function(r,a){t.findAll({where:{name:n},order:[["height","ASC"]]}).then(function(n){switch(n.length){case 0:throw new Error("No claim(s) found with that claim name");default:r(s(n,e))}}).catch(function(e){a(e)})})},h.getAllChannelClaims=function(e){var n=this;return o.debug("Claim.getAllChannelClaims for "+e),new Promise(function(t,i){n.findAll({where:{certificateId:e},order:[["height","ASC"]],raw:!0}).then(function(e){switch(e.length){case 0:return t(null);default:return e.forEach(function(e){return e.fileExt=r(e.contentType),e.thumbnail=a(e.thumbnail,c),e}),t(e)}}).catch(function(e){i(e)})})},h.getClaimIdByLongChannelId=function(e,n){var t=this;return o.debug("finding claim id for claim "+n+" from channel "+e),new Promise(function(r,a){t.findAll({where:{name:n,certificateId:e},order:[["id","ASC"]]}).then(function(t){switch(t.length){case 0:return r(null);case 1:return r(t[0].claimId);default:return o.error(t.length+' records found for "'+n+'" in channel "'+e+'"'),r(t[0].claimId)}}).catch(function(e){a(e)})})},h.getLongClaimIdFromShortClaimId=function(e,n){var t=this;return new Promise(function(r,a){t.findAll({where:{name:e,claimId:{$like:n+"%"}},order:[["height","ASC"]]}).then(function(e){switch(e.length){case 0:return r(null);default:return r(e[0].claimId)}}).catch(function(e){a(e)})})},h.getTopFreeClaimIdByClaimName=function(e){var n=this;return new Promise(function(t,r){n.findAll({where:{name:e},order:[["effectiveAmount","DESC"],["height","ASC"]]}).then(function(e){switch(o.debug("length of result",e.length),e.length){case 0:return t(null);default:return t(e[0].dataValues.claimId)}}).catch(function(e){r(e)})})},h.validateLongClaimId=function(e,n){var t=this;return new Promise(function(r,a){t.findOne({where:{name:e,claimId:n}}).then(function(e){if(!e)return r(null);r(n)}).catch(function(e){a(e)})})},h.getLongClaimId=function(e,n){return o.debug("getLongClaimId("+e+", "+n+")"),n&&40===n.length?this.validateLongClaimId(e,n):n&&n.length<40?this.getLongClaimIdFromShortClaimId(e,n):this.getTopFreeClaimIdByClaimName(e)},h.resolveClaim=function(e,n){var t=this;return o.debug("Claim.resolveClaim: "+e+" "+n),new Promise(function(r,a){t.findAll({where:{name:e,claimId:n}}).then(function(t){switch(t.length){case 0:return r(null);case 1:return r(i(t[0].dataValues));default:return o.error("more than one record matches "+e+"#"+n+" in db.Claim"),r(i(t[0].dataValues))}}).catch(function(e){a(e)})})},h}},function(e,n,t){"use strict";e.exports=function(e,n){var t=n.STRING,r=n.BOOLEAN,a=n.INTEGER,i=e.define("File",{name:{type:t,allowNull:!1},claimId:{type:t,allowNull:!1},address:{type:t,allowNull:!1},outpoint:{type:t,allowNull:!1},height:{type:a,allowNull:!1,default:0},fileName:{type:t,allowNull:!1},filePath:{type:t,allowNull:!1},fileType:{type:t},nsfw:{type:r,allowNull:!1,defaultValue:!1},trendingEligible:{type:r,allowNull:!1,defaultValue:!0}},{freezeTableName:!0});return i.associate=function(e){i.hasMany(e.Request),i.hasOne(e.Claim)},i.getRecentClaims=function(){return this.findAll({where:{nsfw:!1,trendingEligible:!0},order:[["createdAt","DESC"]],limit:25})},i}},function(e,n,t){"use strict";e.exports=function(e,n){var t=n.STRING,r=(n.BOOLEAN,n.TEXT),a=e.define("Request",{action:{type:t,allowNull:!1},url:{type:t,allowNull:!1},ipAddress:{type:t,allowNull:!0},result:{type:r("long"),allowNull:!0,default:null}},{freezeTableName:!0});return a.associate=function(e){a.belongsTo(e.File,{foreignKey:{allowNull:!0}})},a}},function(e,n,t){"use strict";var r=t(50),a=t(0);e.exports=function(e,n){var t=n.STRING,i=e.define("User",{userName:{type:t,allowNull:!1},password:{type:t,allowNull:!1}},{freezeTableName:!0});return i.associate=function(e){i.hasOne(e.Channel)},i.prototype.comparePassword=function(e){return r.compare(e,this.password)},i.prototype.changePassword=function(e){var n=this;return new Promise(function(t,i){r.genSalt(function(o,l){if(o)return a.error("salt error",o),void i(o);r.hash(e,l,function(e,r){if(e)return a.error("hash error",e),void i(e);n.update({password:r}).then(function(){t()}).catch(function(e){i(e)})})})})},i.hook("beforeCreate",function(e,n){return a.debug("User.beforeCreate hook..."),new Promise(function(n,t){r.genSalt(function(i,o){if(i)return a.error("salt error",i),void t(i);r.hash(e.password,o,function(r,i){if(r)return a.error("hash error",r),void t(r);e.password=i,n()})})})}),i}},function(e,n){e.exports=require("bcrypt")},function(e,n,t){"use strict";var r=function(){function e(e,n){var t=[],r=!0,a=!1,i=void 0;try{for(var o,l=e[Symbol.iterator]();!(r=(o=l.next()).done)&&(t.push(o.value),!n||t.length!==n);r=!0);}catch(e){a=!0,i=e}finally{try{!r&&l.return&&l.return()}finally{if(a)throw i}}return t}return function(n,t){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return e(n,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),a=t(11).Strategy,i=t(5),o=t(0),l=t(2);e.exports=new a({usernameField:"username",passwordField:"password"},function(e,n,t){o.verbose("new channel signup request. user: "+e+" pass: "+n+" .");var a={};return i.createChannel("@"+e).then(function(t){var r={userName:e,password:n};o.verbose("userData >",r);var a={channelName:"@"+e,channelClaimId:t.claim_id};o.verbose("channelData >",a);var i={claimId:t.claim_id,name:"@"+e};return o.verbose("certificateData >",i),Promise.all([l.User.create(r),l.Channel.create(a),l.Certificate.create(i)])}).then(function(e){var n=r(e,3),t=n[0],i=n[1],l=n[2];return o.verbose("user and certificate successfully created"),a.id=t.id,a.userName=t.userName,a.channelName=i.channelName,a.channelClaimId=i.channelClaimId,Promise.all([l.setChannel(i),i.setUser(t)])}).then(function(){return o.verbose("user and certificate successfully associated"),l.Certificate.getShortChannelIdFromLongChannelId(a.channelClaimId,a.channelName)}).then(function(e){return a.shortChannelId=e,t(null,a)}).catch(function(e){return o.error("signup error",e),t(e)})})},function(e,n){e.exports=require("axios")},function(e,n,t){"use strict";var r={api:{apiHost:"localhost",apiPort:"5279"}};e.exports=r},function(e,n){e.exports=require("universal-analytics")},function(e,n,t){"use strict";e.exports={serializeSpeechUser:function(e,n){console.log("serializing user"),n(null,e)},deserializeSpeechUser:function(e,n){console.log("deserializing user"),n(null,e)}}},function(e,n,t){"use strict";var r=t(7),a=t(57),i=t(58),o=t(59),l=t(60);e.exports=function(e){e.post("/signup",r.authenticate("local-signup"),a),e.post("/login",i),e.get("/logout",o),e.get("/user",l)}},function(e,n,t){"use strict";var r=function(e,n){n.status(200).json({success:!0,channelName:e.user.channelName,channelClaimId:e.user.channelClaimId,shortChannelId:e.user.shortChannelId})};e.exports=r},function(e,n,t){"use strict";var r=t(7),a=function(e,n,t){r.authenticate("local-login",function(r,a,i){return r?t(r):a?void e.logIn(a,function(r){return r?t(r):n.status(200).json({success:!0,channelName:e.user.channelName,channelClaimId:e.user.channelClaimId,shortChannelId:e.user.shortChannelId})}):n.status(400).json({success:!1,message:i.message})})(e,n,t)};e.exports=a},function(e,n,t){"use strict";var r=function(e,n){e.logout(),n.status(200).json({success:!0,message:"you successfully logged out"})};e.exports=r},function(e,n,t){"use strict";var r=function(e,n){e.user?n.status(200).json({success:!0,data:e.user}):n.status(401).json({success:!1,message:"user is not logged in"})};e.exports=r},function(e,n,t){"use strict";var r=t(62),a=t(64),i=t(66),o=t(67),l=t(68),s=t(69),u=t(70),c=t(71),d=t(72),f=t(74),h=t(75),m=t(76),p=t(77),g=t(78);e.exports=function(e){e.get("/api/channel/availability/:name",r),e.get("/api/channel/short-id/:longId/:name",o),e.get("/api/channel/data/:channelName/:channelClaimId",i),e.get("/api/channel/claims/:channelName/:channelClaimId/:page",a),e.get("/api/claim/list/:name",m),e.get("/api/claim/get/:name/:claimId",u),e.get("/api/claim/availability/:name",l),e.get("/api/claim/resolve/:name/:claimId",f),e.post("/api/claim/publish",g,d),e.get("/api/claim/short-id/:longId/:name",h),e.post("/api/claim/long-id",c),e.get("/api/claim/data/:claimName/:claimId",s),e.get("/api/file/availability/:name/:claimId",p)}},function(e,n,t){"use strict";var r=t(8),a=r.checkChannelAvailability,i=t(4),o=i.sendGATimingEvent,l=t(1),s=l.handleErrorResponse,u=function(e,n){var t=e.ip,r=e.originalUrl,i=e.params.name,l=Date.now();a(i).then(function(e){n.status(200).json(e),o("end-to-end","claim name availability",i,l,Date.now())}).catch(function(e){s(r,t,e,n)})};e.exports=u},function(e,n){e.exports=require("fs")},function(e,n,t){"use strict";var r=t(6),a=r.getChannelClaims,i=t(1),o=i.handleErrorResponse,l=function(e,n){var t=e.ip,r=e.originalUrl,i=(e.body,e.params),l=i.channelName,s=i.channelClaimId;"none"===s&&(s=null);var u=i.page;a(l,s,u).then(function(e){if("NO_CHANNEL"===e)return n.status(404).json({success:!1,message:"No matching channel was found"});n.status(200).json({success:!0,data:e})}).catch(function(e){o(r,t,e,n)})};e.exports=l},function(e,n,t){"use strict";e.exports={returnPaginatedChannelClaims:function(n,t,r,a){var i=e.exports.determineTotalPages(r),o=e.exports.getPageFromQuery(a);return{channelName:n,longChannelClaimId:t,claims:e.exports.extractPageFromClaims(r,o),previousPage:e.exports.determinePreviousPage(o),currentPage:o,nextPage:e.exports.determineNextPage(i,o),totalPages:i,totalResults:e.exports.determineTotalClaims(r)}},getPageFromQuery:function(e){return e?parseInt(e):1},extractPageFromClaims:function(e,n){if(!e)return[];var t=12*(n-1),r=t+12;return e.slice(t,r)},determineTotalPages:function(e){if(e){var n=e.length;if(n<12)return 1;var t=Math.floor(n/12);return 0===n%12?t:t+1}return 0},determinePreviousPage:function(e){return 1===e?null:e-1},determineNextPage:function(e,n){return n===e?null:n+1},determineTotalClaims:function(e){return e?e.length:0}}},function(e,n,t){"use strict";var r=t(6),a=r.getChannelData,i=t(1),o=i.handleErrorResponse,l=function(e,n){var t=e.ip,r=e.originalUrl,i=(e.body,e.params),l=i.channelName,s=i.channelClaimId;"none"===s&&(s=null),a(l,s,0).then(function(e){if("NO_CHANNEL"===e)return n.status(404).json({success:!1,message:"No matching channel was found"});n.status(200).json({success:!0,data:e})}).catch(function(e){o(r,t,e,n)})};e.exports=l},function(e,n,t){"use strict";var r=t(1),a=r.handleErrorResponse,i=t(2),o=function(e,n){var t=e.ip,r=e.originalUrl,o=e.params;i.Certificate.getShortChannelIdFromLongChannelId(o.longId,o.name).then(function(e){n.status(200).json(e)}).catch(function(e){a(r,t,e,n)})};e.exports=o},function(e,n,t){"use strict";var r=t(8),a=r.claimNameIsAvailable,i=t(4),o=i.sendGATimingEvent,l=t(1),s=l.handleErrorResponse,u=function(e,n){var t=e.ip,r=e.originalUrl,i=e.params.name,l=Date.now();a(i).then(function(e){n.status(200).json(e),o("end-to-end","claim name availability",i,l,Date.now())}).catch(function(e){s(r,t,e,n)})};e.exports=u},function(e,n,t){"use strict";var r=t(1),a=r.handleErrorResponse,i=t(2),o=function(e,n){var t=e.ip,r=e.originalUrl,o=(e.body,e.params),l=o.claimName,s=o.claimId;"none"===s&&(s=null),i.Claim.resolveClaim(l,s).then(function(e){if(!e)return n.status(404).json({success:!1,message:"No claim could be found"});n.status(200).json({success:!0,data:e})}).catch(function(e){a(r,t,e,n)})};e.exports=o},function(e,n,t){"use strict";var r=function(){function e(e,n){var t=[],r=!0,a=!1,i=void 0;try{for(var o,l=e[Symbol.iterator]();!(r=(o=l.next()).done)&&(t.push(o.value),!n||t.length!==n);r=!0);}catch(e){a=!0,i=e}finally{try{!r&&l.return&&l.return()}finally{if(a)throw i}}return t}return function(n,t){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return e(n,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),a=t(5),i=a.getClaim,o=t(9),l=o.addGetResultsToFileData,s=o.createFileData,u=t(1),c=u.handleErrorResponse,d=t(2),f=function(e,n){var t=e.ip,a=e.originalUrl,o=e.params,u=o.name,f=o.claimId;d.Claim.resolveClaim(u,f).then(function(e){if(!e)throw new Error("No matching uri found in Claim table");var n=s(e);return Promise.all([n,i(u+"#"+f)])}).then(function(e){var n=r(e,2),t=n[0],a=n[1];return t=l(t,a),Promise.all([d.upsert(d.File,t,{name:u,claimId:f},"File"),a])}).then(function(e){var t=r(e,2),a=(t[0],t[1]),i=a.message,o=a.completed;n.status(200).json({success:!0,message:i,completed:o})}).catch(function(e){c(a,t,e,n)})};e.exports=f},function(e,n,t){"use strict";var r=t(6),a=r.getClaimId,i=t(1),o=i.handleErrorResponse,l=function(e,n){var t=e.ip,r=e.originalUrl,i=e.body,l=(e.params,i.channelName),s=i.channelClaimId,u=i.claimName,c=i.claimId;a(l,s,u,c).then(function(e){return"NO_CHANNEL"===e?n.status(404).json({success:!1,message:"No matching channel could be found"}):"NO_CLAIM"===e?n.status(404).json({success:!1,message:"No matching claim id could be found"}):void n.status(200).json({success:!0,data:e})}).catch(function(e){o(r,t,e,n)})};e.exports=l},function(e,n,t){"use strict";var r=function(){function e(e,n){var t=[],r=!0,a=!1,i=void 0;try{for(var o,l=e[Symbol.iterator]();!(r=(o=l.next()).done)&&(t.push(o.value),!n||t.length!==n);r=!0);}catch(e){a=!0,i=e}finally{try{!r&&l.return&&l.return()}finally{if(a)throw i}}return t}return function(n,t){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return e(n,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),a=t(9),i=a.createBasicPublishParams,o=a.createThumbnailPublishParams,l=a.parsePublishApiRequestBody,s=a.parsePublishApiRequestFiles,u=t(8),c=u.claimNameIsAvailable,d=u.publish,f=t(73),h=f.authenticateUser,m=t(4),p=m.sendGATimingEvent,g=t(1),v=g.handleErrorResponse,y=t(3),b=y.details.host,w=function(e,n){var t=e.body,a=e.files,u=(e.headers,e.ip),f=e.originalUrl,m=e.user,g=void 0,y=void 0,w=void 0,C=void 0,I=void 0,x=void 0,N=void 0,E=void 0,A=void 0,S=void 0,P=void 0,T=void 0,L=void 0,R=void 0,_=void 0,F=void 0;E=Date.now();try{var O=l(t);S=O.name,P=O.nsfw,A=O.license,F=O.title,C=O.description,T=O.thumbnail;var j=s(a);I=j.fileName,x=j.filePath,N=j.fileType,L=j.thumbnailFileName,R=j.thumbnailFilePath,_=j.thumbnailFileType,g=t.channelName,y=t.channelId,w=t.channelPassword}catch(e){return n.status(400).json({success:!1,message:e.message})}Promise.all([h(g,y,w,m),c(S),i(x,S,F,C,A,P,T),o(R,S,A,P)]).then(function(e){var n=r(e,4),t=n[0],a=t.channelName,i=t.channelClaimId,o=(n[1],n[2]),l=n[3];return a&&i&&(o.channel_name=a,o.channel_id=i),l&&d(l,L,_),d(o,I,N)}).then(function(e){n.status(200).json({success:!0,message:"publish completed successfully",data:{name:S,claimId:e.claim_id,url:b+"/"+e.claim_id+"/"+S,lbryTx:e}}),p("end-to-end","publish",N,E,Date.now())}).catch(function(e){v(f,u,e,n)})};e.exports=w},function(e,n,t){"use strict";var r=t(2),a=t(0);e.exports={authenticateUser:function(n,t,r,a){if(!n&&!t)return{channelName:null,channelClaimId:null};if(a){if(n&&n!==a.channelName)throw new Error("the provided channel name does not match user credentials");if(t&&t!==a.channelClaimId)throw new Error("the provided channel id does not match user credentials");return{channelName:a.channelName,channelClaimId:a.channelClaimId}}if(!r)throw new Error("no channel password provided");return e.exports.authenticateChannelCredentials(n,t,r)},authenticateChannelCredentials:function(e,n,t){return new Promise(function(i,o){var l=void 0,s={};e&&(s.channelName=e),n&&(s.channelClaimId=n),r.Channel.findOne({where:s}).then(function(e){if(!e)throw a.debug("no channel found"),new Error("Authentication failed, you do not have access to that channel");return l=e.get(),a.debug("channel data:",l),r.User.findOne({where:{userName:l.channelName.substring(1)}})}).then(function(e){if(!e)throw a.debug("no user found"),new Error("Authentication failed, you do not have access to that channel");return e.comparePassword(t)}).then(function(e){if(!e)throw a.debug("incorrect password"),new Error("Authentication failed, you do not have access to that channel");a.debug("...password was a match..."),i(l)}).catch(function(e){o(e)})})}}},function(e,n,t){"use strict";var r=t(5),a=r.resolveUri,i=t(1),o=i.handleErrorResponse,l=function(e,n){var t=(e.headers,e.ip),r=e.originalUrl,i=e.params;a(i.name+"#"+i.claimId).then(function(e){n.status(200).json(e)}).catch(function(e){o(r,t,e,n)})};e.exports=l},function(e,n,t){"use strict";var r=t(1),a=r.handleErrorResponse,i=t(2),o=function(e,n){var t=e.ip,r=e.originalUrl,o=(e.body,e.params);i.Claim.getShortClaimIdFromLongClaimId(o.longId,o.name).then(function(e){n.status(200).json({success:!0,data:e})}).catch(function(e){a(r,t,e,n)})};e.exports=o},function(e,n,t){"use strict";var r=t(5),a=r.getClaimList,i=t(1),o=i.handleErrorResponse,l=function(e,n){var t=e.ip,r=e.originalUrl,i=e.params;a(i.name).then(function(e){n.status(200).json(e)}).catch(function(e){o(r,t,e,n)})};e.exports=l},function(e,n,t){"use strict";var r=t(1),a=r.handleErrorResponse,i=t(2),o=function(e,n){var t=e.ip,r=e.originalUrl,o=e.params,l=o.name,s=o.claimId;i.File.findOne({where:{name:l,claimId:s}}).then(function(e){if(e)return n.status(200).json({success:!0,data:!0});n.status(200).json({success:!0,data:!1})}).catch(function(e){a(r,t,e,n)})};e.exports=o},function(e,n,t){"use strict";var r=t(79),a=t(3),i=a.publishing.uploadDirectory,o=r({uploadDir:i});e.exports=o},function(e,n){e.exports=require("connect-multiparty")},function(e,n,t){"use strict";var r=t(81),a=t(82),i=t(83);e.exports=function(e){e.get("/",r),e.get("/login",r),e.get("/about",r),e.get("/trending",i("/popular")),e.get("/popular",r),e.get("/new",r),e.get("/embed/:claimId/:name",a)}},function(e,n,t){"use strict";var r=t(14),a=function(e,n){r(e,n)};e.exports=a},function(e,n,t){"use strict";var r=t(3),a=r.details.host,i=function(e,n){var t=e.params,r=t.claimId,i=t.name;n.status(200).render("embed",{layout:"embed",host:a,claimId:r,name:i})};e.exports=i},function(e,n,t){"use strict";var r=function(e){return function(n,t){t.status(301).redirect(e)}};e.exports=r},function(e,n,t){"use strict";var r=t(85),a=t(88);e.exports=function(e,n){e.get("/:identifier/:claim",a),e.get("/:claim",r)}},function(e,n,t){"use strict";var r=t(4),a=r.sendGAServeEvent,i=t(23),o=i.determineResponseType,l=i.logRequestData,s=i.getClaimIdAndServeAsset,u=t(24),c=t(25),d=function(e,n){var t=e.headers,r=e.ip,i=e.originalUrl,d=e.params,f=void 0;try{f=u.parseModifier(d.claim).hasFileExtension}catch(e){return n.status(400).json({success:!1,message:e.message})}var h=o(f,t);if("SERVE"!==h)return c(e,n);a(t,r,i);var m=void 0;try{m=u.parseClaim(d.claim).claimName}catch(e){return n.status(400).json({success:!1,message:e.message})}l(h,m,null,null),s(null,null,m,null,i,r,n)};e.exports=d},function(e,n){e.exports=require("redux-saga")},function(e,n){e.exports=require("redux-saga/effects")},function(e,n,t){"use strict";var r=function(){function e(e,n){var t=[],r=!0,a=!1,i=void 0;try{for(var o,l=e[Symbol.iterator]();!(r=(o=l.next()).done)&&(t.push(o.value),!n||t.length!==n);r=!0);}catch(e){a=!0,i=e}finally{try{!r&&l.return&&l.return()}finally{if(a)throw i}}return t}return function(n,t){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return e(n,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),a=t(4),i=a.sendGAServeEvent,o=t(23),l=o.determineResponseType,s=o.flipClaimNameAndIdForBackwardsCompatibility,u=o.logRequestData,c=o.getClaimIdAndServeAsset,d=t(24),f=t(25),h=function(e,n){var t=e.headers,a=e.ip,o=e.originalUrl,h=e.params,m=void 0;try{m=d.parseModifier(h.claim).hasFileExtension}catch(e){return n.status(400).json({success:!1,message:e.message})}var p=l(m,t);if("SERVE"!==p)return f(e,n);i(t,a,o);var g=void 0;try{g=d.parseClaim(h.claim).claimName}catch(e){return n.status(400).json({success:!1,message:e.message})}var v=void 0,y=void 0,b=void 0,w=void 0;try{var C=d.parseIdentifier(h.identifier);v=C.isChannel,y=C.channelName,b=C.channelClaimId,w=C.claimId}catch(e){return n.status(400).json({success:!1,message:e.message})}if(!v){var I=s(w,g),x=r(I,2);w=x[0],g=x[1]}u(p,g,y,w),c(y,b,g,w,o,a,n)};e.exports=h},function(e,n,t){"use strict";var r=t(90);e.exports=function(e){e.get("*",r)}},function(e,n,t){"use strict";var r=t(14),a=function(e,n){r(e,n)};e.exports=a}]);
|
|
//# sourceMappingURL=index.js.map
|