diff --git a/LICENSE.txt b/LICENSE.txt index 9d0408fa..4103e4ae 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -187,7 +187,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2014-2015 Cédric Belin + Copyright 2014-2016 Cédric Belin Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/akismet.js b/akismet.js index 9e3acc04..b56074a4 100644 --- a/akismet.js +++ b/akismet.js @@ -1,2 +1,2 @@ -!function t(e,r,n){function o(i,a){if(!r[i]){if(!e[i]){var h="function"==typeof require&&require;if(!a&&h)return h(i,!0);if(s)return s(i,!0);var u=new Error("Cannot find module '"+i+"'");throw u.code="MODULE_NOT_FOUND",u}var c=r[i]={exports:{}};e[i][0].call(c.exports,function(t){var r=e[i][1][t];return o(r?r:t)},c,c.exports,t,e,r,n)}return r[i].exports}for(var s="function"==typeof require&&require,i=0;i0;return new t({author:n?i.fromJSON(r):null,content:r.comment_content,date:"string"==typeof r.comment_date_gmt?new Date(r.comment_date_gmt):null,postModified:"string"==typeof r.comment_post_modified_gmt?new Date(r.comment_post_modified_gmt):null,type:r.comment_type,permalink:r.permalink,referrer:r.referrer})}}]),t}();e.exports=a},{"./author":3}],6:[function(t,e,r){"use strict";var n={COMMENT:"comment",PINGBACK:"pingback",TRACKBACK:"trackback"};e.exports=Object.freeze(n)},{}],7:[function(t,e,r){"use strict";var n={CHECK_COMMENT:"/1.1/comment-check",SUBMIT_HAM:"/1.1/submit-ham",SUBMIT_SPAM:"/1.1/submit-spam",VERIFY_KEY:"/1.1/verify-key"};e.exports=Object.freeze(n)},{}],8:[function(t,e,r){"use strict";var n={X_AKISMET_DEBUG_HELP:"x-akismet-debug-help",X_REQUESTED_WITH:"x-requested-with",X_USER_AGENT:"x-user-agent"};e.exports=Object.freeze(n)},{}],9:[function(t,e,r){"use strict";e.exports={Author:t("./author"),Blog:t("./blog"),Comment:t("./comment"),CommentType:t("./comment_type"),EndPoints:t("./end_points"),HTTPHeaders:t("./http_headers")}},{"./author":3,"./blog":4,"./comment":5,"./comment_type":6,"./end_points":7,"./http_headers":8}],10:[function(t,e,r){(function(r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},o=t("./client"),s=o.Client,i=t("./core"),a=i.Author,h=i.Blog,u=i.Comment,c=i.CommentType;e.exports={Author:a,Blog:h,Client:s,Comment:u,CommentType:c},"undefined"!=typeof r.window&&("object"==n(r.window.cedx)&&r.window.cedx||(r.window.cedx={}),r.window.cedx.akismet=e.exports)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./client":2,"./core":9}],11:[function(t,e,r){function n(t){if(t)return o(t)}function o(t){for(var e in n.prototype)t[e]=n.prototype[e];return t}"undefined"!=typeof e&&(e.exports=n),n.prototype.on=n.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},n.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r=this._callbacks["$"+t];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var n,o=0;o1)for(var r=1;r1&&(n=r[0]+"@",t=r[1]),t=t.replace(R,".");var o=t.split("."),i=s(o,e).join(".");return n+i}function a(t){for(var e,r,n=[],o=0,s=t.length;o=55296&&e<=56319&&o65535&&(t-=65536,e+=P(t>>>10&1023|55296),t=56320|1023&t),e+=P(t)}).join("")}function u(t){return t-48<10?t-22:t-65<26?t-65:t-97<26?t-97:x}function c(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function l(t,e,r){var n=0;for(t=r?N(t/T):t>>1,t+=N(t/e);t>I*S>>1;n+=x)t=N(t/I);return N(n+(I+1)*t/(t+j))}function f(t){var e,r,n,s,i,a,c,f,p,d,m=[],y=t.length,v=0,g=E,b=k;for(r=t.lastIndexOf(A),r<0&&(r=0),n=0;n=128&&o("not-basic"),m.push(t.charCodeAt(n));for(s=r>0?r+1:0;s=y&&o("invalid-input"),f=u(t.charCodeAt(s++)),(f>=x||f>N((w-v)/a))&&o("overflow"),v+=f*a,p=c<=b?O:c>=b+S?S:c-b,!(fN(w/d)&&o("overflow"),a*=d;e=m.length+1,b=l(v-i,e,0==i),N(v/e)>w-g&&o("overflow"),g+=N(v/e),v%=e,m.splice(v++,0,g)}return h(m)}function p(t){var e,r,n,s,i,h,u,f,p,d,m,y,v,g,b,_=[];for(t=a(t),y=t.length,e=E,r=0,i=k,h=0;h=e&&mN((w-r)/v)&&o("overflow"),r+=(u-e)*v,e=u,h=0;hw&&o("overflow"),m==e){for(f=r,p=x;d=p<=i?O:p>=i+S?S:p-i,!(f= 0x80 (not a basic code point)","invalid-input":"Invalid input"},I=x-O,N=Math.floor,P=String.fromCharCode;if(b={version:"1.4.1",ucs2:{decode:a,encode:h},decode:f,encode:p,toASCII:m,toUnicode:d},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return b});else if(y&&v)if(e.exports==y)v.exports=b;else for(_ in b)b.hasOwnProperty(_)&&(y[_]=b[_]);else n.punycode=b}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],14:[function(t,e,r){"use strict";function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.exports=function(t,e,r,s){e=e||"&",r=r||"=";var i={};if("string"!=typeof t||0===t.length)return i;var a=/\+/g;t=t.split(e);var h=1e3;s&&"number"==typeof s.maxKeys&&(h=s.maxKeys);var u=t.length;h>0&&u>h&&(u=h);for(var c=0;c=0?(l=m.substr(0,y),f=m.substr(y+1)):(l=m,f=""),p=decodeURIComponent(l),d=decodeURIComponent(f),n(i,p)?o(i[p])?i[p].push(d):i[p]=[i[p],d]:i[p]=d}return i};var o=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},{}],15:[function(t,e,r){"use strict";function n(t,e){if(t.map)return t.map(e);for(var r=[],n=0;n=300)&&(n=new Error(e.statusText||"Unsuccessful HTTP response"),n.original=t,n.response=e,n.status=e.status)}catch(t){n=t}n?r.callback(n,e):r.callback(null,e)})}function p(t,e){var r=g("DELETE",t);return e&&r.end(e),r}var d;"undefined"!=typeof window?d=window:"undefined"!=typeof self?d=self:(console.warn("Using browser-only version of superagent in non-browser environment"),d=this);var m=t("emitter"),y=t("./request-base"),v=t("./is-object"),g=e.exports=t("./request").bind(null,f);g.getXHR=function(){if(!(!d.XMLHttpRequest||d.location&&"file:"==d.location.protocol&&d.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(t){}throw Error("Browser-only verison of superagent could not find XHR")};var b="".trim?function(t){return t.trim()}:function(t){return t.replace(/(^\s*|\s*$)/g,"")};g.serializeObject=o,g.parseString=i,g.types={html:"text/html",json:"application/json",xml:"application/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},g.serialize={"application/x-www-form-urlencoded":o,"application/json":JSON.stringify},g.parse={"application/x-www-form-urlencoded":i,"application/json":JSON.parse},l.prototype.get=function(t){return this.header[t.toLowerCase()]},l.prototype._setHeaderProperties=function(t){var e=this.header["content-type"]||"";this.type=u(e);var r=c(e);for(var n in r)this[n]=r[n]},l.prototype._parseBody=function(t){var e=g.parse[this.type];return!e&&h(this.type)&&(e=g.parse["application/json"]),e&&t&&(t.length||t instanceof Object)?e(t):null},l.prototype._setStatusProperties=function(t){1223===t&&(t=204);var e=t/100|0;this.status=this.statusCode=t,this.statusType=e,this.info=1==e,this.ok=2==e,this.clientError=4==e,this.serverError=5==e,this.error=(4==e||5==e)&&this.toError(),this.accepted=202==t,this.noContent=204==t,this.badRequest=400==t,this.unauthorized=401==t,this.notAcceptable=406==t,this.notFound=404==t,this.forbidden=403==t},l.prototype.toError=function(){var t=this.req,e=t.method,r=t.url,n="cannot "+e+" "+r+" ("+this.status+")",o=new Error(n);return o.status=this.status,o.method=e,o.url=r,o},g.Response=l,m(f.prototype);for(var _ in y)f.prototype[_]=y[_];f.prototype.type=function(t){return this.set("Content-Type",g.types[t]||t),this},f.prototype.responseType=function(t){return this._responseType=t,this},f.prototype.accept=function(t){return this.set("Accept",g.types[t]||t),this},f.prototype.auth=function(t,e,r){switch(r||(r={type:"basic"}),r.type){case"basic":var n=btoa(t+":"+e);this.set("Authorization","Basic "+n);break;case"auto":this.username=t,this.password=e}return this},f.prototype.query=function(t){return"string"!=typeof t&&(t=o(t)),t&&this._query.push(t),this},f.prototype.attach=function(t,e,r){return this._getFormData().append(t,e,r||e.name),this},f.prototype._getFormData=function(){return this._formData||(this._formData=new d.FormData),this._formData},f.prototype.callback=function(t,e){var r=this._callback;this.clearTimeout(),r(t,e)},f.prototype.crossDomainError=function(){var t=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");t.crossDomain=!0,t.status=this.status,t.method=this.method,t.url=this.url,this.callback(t)},f.prototype._timeoutError=function(){var t=this._timeout,e=new Error("timeout of "+t+"ms exceeded");e.timeout=t,this.callback(e)},f.prototype._appendQueryString=function(){var t=this._query.join("&");t&&(this.url+=~this.url.indexOf("?")?"&"+t:"?"+t)},f.prototype.end=function(t){var e=this,r=this.xhr=g.getXHR(),o=this._timeout,s=this._formData||this._data;this._callback=t||n,r.onreadystatechange=function(){if(4==r.readyState){var t;try{t=r.status}catch(e){t=0}if(0==t){if(e.timedout)return e._timeoutError();if(e._aborted)return;return e.crossDomainError()}e.emit("end")}};var i=function(t){t.total>0&&(t.percent=t.loaded/t.total*100),t.direction="download",e.emit("progress",t)};this.hasListeners("progress")&&(r.onprogress=i);try{r.upload&&this.hasListeners("progress")&&(r.upload.onprogress=i)}catch(t){}if(o&&!this._timer&&(this._timer=setTimeout(function(){e.timedout=!0,e.abort()},o)),this._appendQueryString(),this.username&&this.password?r.open(this.method,this.url,!0,this.username,this.password):r.open(this.method,this.url,!0),this._withCredentials&&(r.withCredentials=!0),"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof s&&!this._isHost(s)){var a=this._header["content-type"],u=this._serializer||g.serialize[a?a.split(";")[0]:""];!u&&h(a)&&(u=g.serialize["application/json"]),u&&(s=u(s))}for(var c in this.header)null!=this.header[c]&&r.setRequestHeader(c,this.header[c]);return this._responseType&&(r.responseType=this._responseType),this.emit("request",this),r.send("undefined"!=typeof s?s:null),this},g.Request=f,g.get=function(t,e,r){var n=g("GET",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},g.head=function(t,e,r){var n=g("HEAD",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},g.options=function(t,e,r){var n=g("OPTIONS",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},g.del=p,g.delete=p,g.patch=function(t,e,r){var n=g("PATCH",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},g.post=function(t,e,r){var n=g("POST",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},g.put=function(t,e,r){var n=g("PUT",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n}},{"./is-object":18,"./request":20,"./request-base":19,emitter:11}],18:[function(t,e,r){function n(t){return null!==t&&"object"==typeof t}e.exports=n},{}],19:[function(t,e,r){var n=t("./is-object");r.clearTimeout=function(){return this._timeout=0,clearTimeout(this._timer),this},r.parse=function(t){return this._parser=t,this},r.serialize=function(t){return this._serializer=t,this},r.timeout=function(t){return this._timeout=t,this},r.then=function(t,e){if(!this._fullfilledPromise){var r=this;this._fullfilledPromise=new Promise(function(t,e){r.end(function(r,n){r?e(r):t(n)})})}return this._fullfilledPromise.then(t,e)},r.use=function(t){return t(this),this},r.get=function(t){return this._header[t.toLowerCase()]},r.getHeader=r.get,r.set=function(t,e){if(n(t)){for(var r in t)this.set(r,t[r]);return this}return this._header[t.toLowerCase()]=e,this.header[t]=e,this},r.unset=function(t){return delete this._header[t.toLowerCase()],delete this.header[t],this},r.field=function(t,e){return this._getFormData().append(t,e),this},r.abort=function(){return this._aborted?this:(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort"),this)},r.withCredentials=function(){return this._withCredentials=!0,this},r.redirects=function(t){return this._maxRedirects=t,this},r.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},r._isHost=function(t){var e={}.toString.call(t);switch(e){case"[object File]":case"[object Blob]":case"[object FormData]":return!0;default:return!1}},r.send=function(t){var e=n(t),r=this._header["content-type"];if(e&&n(this._data))for(var o in t)this._data[o]=t[o];else"string"==typeof t?(r||this.type("form"),r=this._header["content-type"],"application/x-www-form-urlencoded"==r?this._data=this._data?this._data+"&"+t:t:this._data=(this._data||"")+t):this._data=t;return!e||this._isHost(t)?this:(r||this.type("json"),this)}},{"./is-object":18}],20:[function(t,e,r){function n(t,e,r){return"function"==typeof r?new t("GET",e).end(r):2==arguments.length?new t("GET",e):new t(e,r)}e.exports=n},{}],21:[function(t,e,r){"use strict";function n(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}function o(t,e,r){if(t&&u.isObject(t)&&t instanceof n)return t;var o=new n;return o.parse(t,e,r),o}function s(t){return u.isString(t)&&(t=o(t)),t instanceof n?t.format():n.prototype.format.call(t)}function i(t,e){return o(t,!1,!0).resolve(e)}function a(t,e){return t?o(t,!1,!0).resolveObject(e):e}var h=t("punycode"),u=t("./util");r.parse=o,r.resolve=i,r.resolveObject=a,r.format=s,r.Url=n;var c=/^([a-z0-9.+-]+:)/i,l=/:[0-9]*$/,f=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,p=["<",">",'"',"`"," ","\r","\n","\t"],d=["{","}","|","\\","^","`"].concat(p),m=["'"].concat(d),y=["%","/","?",";","#"].concat(m),v=["/","?","#"],g=255,b=/^[+a-z0-9A-Z_-]{0,63}$/,_=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,w={javascript:!0,"javascript:":!0},x={javascript:!0,"javascript:":!0},O={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},S=t("querystring");n.prototype.parse=function(t,e,r){if(!u.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var n=t.indexOf("?"),o=n!==-1&&n127?"x":I[P];if(!N.match(b)){var H=R.slice(0,k),M=R.slice(k+1),D=I.match(_);D&&(H.push(D[1]),M.unshift(D[2])),M.length&&(a="/"+M.join(".")+a),this.hostname=H.join(".");break}}}this.hostname.length>g?this.hostname="":this.hostname=this.hostname.toLowerCase(),q||(this.hostname=h.toASCII(this.hostname));var J=this.port?":"+this.port:"",B=this.hostname||"";this.host=B+J,this.href+=this.host,q&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==a[0]&&(a="/"+a))}if(!w[d])for(var k=0,U=m.length;k0)&&r.host.split("@");j&&(r.auth=j.shift(),r.host=r.hostname=j.shift())}return r.search=t.search,r.query=t.query,u.isNull(r.pathname)&&u.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!w.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var T=w.slice(-1)[0],k=(r.host||t.host||w.length>1)&&("."===T||".."===T)||""===T,E=0,A=w.length;A>=0;A--)T=w[A],"."===T?w.splice(A,1):".."===T?(w.splice(A,1),E++):E&&(w.splice(A,1),E--);if(!b&&!_)for(;E--;E)w.unshift("..");!b||""===w[0]||w[0]&&"/"===w[0].charAt(0)||w.unshift(""),k&&"/"!==w.join("/").substr(-1)&&w.push("");var C=""===w[0]||w[0]&&"/"===w[0].charAt(0);if(S){r.hostname=r.host=C?"":w.length?w.shift():"";var j=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@");j&&(r.auth=j.shift(),r.host=r.hostname=j.shift())}return b=b||r.host&&w.length,b&&!C&&w.unshift(""),w.length?r.pathname=w.join("/"):(r.pathname=null,r.path=null),u.isNull(r.pathname)&&u.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},n.prototype.parseHost=function(){var t=this.host,e=l.exec(t);e&&(e=e[0],":"!==e&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},{"./util":22,punycode:13,querystring:16}],22:[function(t,e,r){"use strict";e.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},{}],23:[function(t,e,r){e.exports={description:"Prevent comment spam using Akismet service.",homepage:"https://github.com/cedx/akismet",name:"@cedx/akismet",author:"Cédric Belin ",bugs:"https://github.com/cedx/akismet/issues",license:"Apache-2.0",main:"./lib/index.js",repository:"cedx/akismet",version:"0.8.0",bin:{akismet:"./bin/cli.js"},dependencies:{"body-parser":"^1.15.2",commander:"^2.9.0",cors:"^2.7.1",express:"^4.14.0",forever:"^0.15.2",superagent:"^2.1.0"},devDependencies:{"@cedx/gulp-david":"^2.0.2","babel-preset-es2015":"^6.9.0",babelify:"^7.3.0",browserify:"^13.1.0","codacy-coverage":"^1.1.3",del:"^2.2.1",gulp:"^3.9.1","gulp-istanbul":"^1.0.0","gulp-jshint":"^2.0.1","gulp-load-plugins":"^1.2.4","gulp-mocha":"^3.0.0","gulp-sourcemaps":"^1.6.0","gulp-uglify":"^2.0.0","gulp-zip":"^3.2.0",jsdoc:"^3.4.0",jshint:"^2.9.2",mocha:"^3.0.1","vinyl-buffer":"^1.0.0","vinyl-source-stream":"^1.1.0"},engines:{node:">=6.3.0"},jshintConfig:{browser:!0,esversion:6,freeze:!0,futurehostile:!0,jquery:!0,latedef:"nofunc",mocha:!0,noarg:!0,nocomma:!0,node:!0,nonbsp:!0,nonew:!0,singleGroups:!0,trailing:!0,typed:!0,undef:!0,unused:!0,varstmt:!0},keywords:["akismet","comment","spam","validation"],scripts:{coverage:"codacy-coverage < var/lcov.info",start:"forever start -c node -e var/stderr.log -o var/stdout.log -l var/forever.log --append --minUptime 30000 --spinSleepTime 30000 --uid akismet bin/cli.js",stop:"forever stop akismet",test:"gulp test"}}},{}]},{},[10]); \ No newline at end of file +!function t(e,r,n){function o(i,a){if(!r[i]){if(!e[i]){var h="function"==typeof require&&require;if(!a&&h)return h(i,!0);if(s)return s(i,!0);var u=new Error("Cannot find module '"+i+"'");throw u.code="MODULE_NOT_FOUND",u}var c=r[i]={exports:{}};e[i][0].call(c.exports,function(t){var r=e[i][1][t];return o(r?r:t)},c,c.exports,t,e,r,n)}return r[i].exports}for(var s="function"==typeof require&&require,i=0;i0;return new t({author:n?i.fromJSON(r):null,content:r.comment_content,date:"string"==typeof r.comment_date_gmt?new Date(r.comment_date_gmt):null,postModified:"string"==typeof r.comment_post_modified_gmt?new Date(r.comment_post_modified_gmt):null,type:r.comment_type,permalink:r.permalink,referrer:r.referrer})}}]),t}();e.exports=a},{"./author":3}],6:[function(t,e,r){"use strict";var n={COMMENT:"comment",PINGBACK:"pingback",TRACKBACK:"trackback"};e.exports=Object.freeze(n)},{}],7:[function(t,e,r){"use strict";var n={CHECK_COMMENT:"/1.1/comment-check",SUBMIT_HAM:"/1.1/submit-ham",SUBMIT_SPAM:"/1.1/submit-spam",VERIFY_KEY:"/1.1/verify-key"};e.exports=Object.freeze(n)},{}],8:[function(t,e,r){"use strict";var n={X_AKISMET_DEBUG_HELP:"x-akismet-debug-help",X_REQUESTED_WITH:"x-requested-with",X_USER_AGENT:"x-user-agent"};e.exports=Object.freeze(n)},{}],9:[function(t,e,r){"use strict";e.exports={Author:t("./author"),Blog:t("./blog"),Comment:t("./comment"),CommentType:t("./comment_type"),EndPoints:t("./end_points"),HTTPHeaders:t("./http_headers")}},{"./author":3,"./blog":4,"./comment":5,"./comment_type":6,"./end_points":7,"./http_headers":8}],10:[function(t,e,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},o=t("./client"),s=o.Client,i=t("./core"),a=i.Author,h=i.Blog,u=i.Comment,c=i.CommentType;e.exports={Author:a,Blog:h,Client:s,Comment:u,CommentType:c},"undefined"!=typeof window&&("object"==n(window.cedx)&&window.cedx||(window.cedx={}),window.cedx.akismet=e.exports)},{"./client":2,"./core":9}],11:[function(t,e,r){function n(t){if(t)return o(t)}function o(t){for(var e in n.prototype)t[e]=n.prototype[e];return t}"undefined"!=typeof e&&(e.exports=n),n.prototype.on=n.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},n.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r=this._callbacks["$"+t];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var n,o=0;o1)for(var r=1;r1&&(n=r[0]+"@",t=r[1]),t=t.replace(R,".");var o=t.split("."),i=s(o,e).join(".");return n+i}function a(t){for(var e,r,n=[],o=0,s=t.length;o=55296&&e<=56319&&o65535&&(t-=65536,e+=P(t>>>10&1023|55296),t=56320|1023&t),e+=P(t)}).join("")}function u(t){return t-48<10?t-22:t-65<26?t-65:t-97<26?t-97:x}function c(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function l(t,e,r){var n=0;for(t=r?N(t/T):t>>1,t+=N(t/e);t>I*S>>1;n+=x)t=N(t/I);return N(n+(I+1)*t/(t+j))}function f(t){var e,r,n,s,i,a,c,f,p,d,m=[],y=t.length,v=0,g=E,b=k;for(r=t.lastIndexOf(A),r<0&&(r=0),n=0;n=128&&o("not-basic"),m.push(t.charCodeAt(n));for(s=r>0?r+1:0;s=y&&o("invalid-input"),f=u(t.charCodeAt(s++)),(f>=x||f>N((w-v)/a))&&o("overflow"),v+=f*a,p=c<=b?O:c>=b+S?S:c-b,!(fN(w/d)&&o("overflow"),a*=d;e=m.length+1,b=l(v-i,e,0==i),N(v/e)>w-g&&o("overflow"),g+=N(v/e),v%=e,m.splice(v++,0,g)}return h(m)}function p(t){var e,r,n,s,i,h,u,f,p,d,m,y,v,g,b,_=[];for(t=a(t),y=t.length,e=E,r=0,i=k,h=0;h=e&&mN((w-r)/v)&&o("overflow"),r+=(u-e)*v,e=u,h=0;hw&&o("overflow"),m==e){for(f=r,p=x;d=p<=i?O:p>=i+S?S:p-i,!(f= 0x80 (not a basic code point)","invalid-input":"Invalid input"},I=x-O,N=Math.floor,P=String.fromCharCode;if(b={version:"1.4.1",ucs2:{decode:a,encode:h},decode:f,encode:p,toASCII:m,toUnicode:d},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return b});else if(y&&v)if(e.exports==y)v.exports=b;else for(_ in b)b.hasOwnProperty(_)&&(y[_]=b[_]);else n.punycode=b}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],14:[function(t,e,r){"use strict";function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.exports=function(t,e,r,s){e=e||"&",r=r||"=";var i={};if("string"!=typeof t||0===t.length)return i;var a=/\+/g;t=t.split(e);var h=1e3;s&&"number"==typeof s.maxKeys&&(h=s.maxKeys);var u=t.length;h>0&&u>h&&(u=h);for(var c=0;c=0?(l=m.substr(0,y),f=m.substr(y+1)):(l=m,f=""),p=decodeURIComponent(l),d=decodeURIComponent(f),n(i,p)?o(i[p])?i[p].push(d):i[p]=[i[p],d]:i[p]=d}return i};var o=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},{}],15:[function(t,e,r){"use strict";function n(t,e){if(t.map)return t.map(e);for(var r=[],n=0;n=300)&&(n=new Error(e.statusText||"Unsuccessful HTTP response"),n.original=t,n.response=e,n.status=e.status)}catch(t){n=t}n?r.callback(n,e):r.callback(null,e)})}function p(t,e){var r=g("DELETE",t);return e&&r.end(e),r}var d;"undefined"!=typeof window?d=window:"undefined"!=typeof self?d=self:(console.warn("Using browser-only version of superagent in non-browser environment"),d=this);var m=t("emitter"),y=t("./request-base"),v=t("./is-object"),g=e.exports=t("./request").bind(null,f);g.getXHR=function(){if(!(!d.XMLHttpRequest||d.location&&"file:"==d.location.protocol&&d.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(t){}throw Error("Browser-only verison of superagent could not find XHR")};var b="".trim?function(t){return t.trim()}:function(t){return t.replace(/(^\s*|\s*$)/g,"")};g.serializeObject=o,g.parseString=i,g.types={html:"text/html",json:"application/json",xml:"application/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},g.serialize={"application/x-www-form-urlencoded":o,"application/json":JSON.stringify},g.parse={"application/x-www-form-urlencoded":i,"application/json":JSON.parse},l.prototype.get=function(t){return this.header[t.toLowerCase()]},l.prototype._setHeaderProperties=function(t){var e=this.header["content-type"]||"";this.type=u(e);var r=c(e);for(var n in r)this[n]=r[n]},l.prototype._parseBody=function(t){var e=g.parse[this.type];return!e&&h(this.type)&&(e=g.parse["application/json"]),e&&t&&(t.length||t instanceof Object)?e(t):null},l.prototype._setStatusProperties=function(t){1223===t&&(t=204);var e=t/100|0;this.status=this.statusCode=t,this.statusType=e,this.info=1==e,this.ok=2==e,this.clientError=4==e,this.serverError=5==e,this.error=(4==e||5==e)&&this.toError(),this.accepted=202==t,this.noContent=204==t,this.badRequest=400==t,this.unauthorized=401==t,this.notAcceptable=406==t,this.notFound=404==t,this.forbidden=403==t},l.prototype.toError=function(){var t=this.req,e=t.method,r=t.url,n="cannot "+e+" "+r+" ("+this.status+")",o=new Error(n);return o.status=this.status,o.method=e,o.url=r,o},g.Response=l,m(f.prototype);for(var _ in y)f.prototype[_]=y[_];f.prototype.type=function(t){return this.set("Content-Type",g.types[t]||t),this},f.prototype.responseType=function(t){return this._responseType=t,this},f.prototype.accept=function(t){return this.set("Accept",g.types[t]||t),this},f.prototype.auth=function(t,e,r){switch(r||(r={type:"basic"}),r.type){case"basic":var n=btoa(t+":"+e);this.set("Authorization","Basic "+n);break;case"auto":this.username=t,this.password=e}return this},f.prototype.query=function(t){return"string"!=typeof t&&(t=o(t)),t&&this._query.push(t),this},f.prototype.attach=function(t,e,r){return this._getFormData().append(t,e,r||e.name),this},f.prototype._getFormData=function(){return this._formData||(this._formData=new d.FormData),this._formData},f.prototype.callback=function(t,e){var r=this._callback;this.clearTimeout(),r(t,e)},f.prototype.crossDomainError=function(){var t=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");t.crossDomain=!0,t.status=this.status,t.method=this.method,t.url=this.url,this.callback(t)},f.prototype._timeoutError=function(){var t=this._timeout,e=new Error("timeout of "+t+"ms exceeded");e.timeout=t,this.callback(e)},f.prototype._appendQueryString=function(){var t=this._query.join("&");t&&(this.url+=~this.url.indexOf("?")?"&"+t:"?"+t)},f.prototype.end=function(t){var e=this,r=this.xhr=g.getXHR(),o=this._timeout,s=this._formData||this._data;this._callback=t||n,r.onreadystatechange=function(){if(4==r.readyState){var t;try{t=r.status}catch(e){t=0}if(0==t){if(e.timedout)return e._timeoutError();if(e._aborted)return;return e.crossDomainError()}e.emit("end")}};var i=function(t){t.total>0&&(t.percent=t.loaded/t.total*100),t.direction="download",e.emit("progress",t)};this.hasListeners("progress")&&(r.onprogress=i);try{r.upload&&this.hasListeners("progress")&&(r.upload.onprogress=i)}catch(t){}if(o&&!this._timer&&(this._timer=setTimeout(function(){e.timedout=!0,e.abort()},o)),this._appendQueryString(),this.username&&this.password?r.open(this.method,this.url,!0,this.username,this.password):r.open(this.method,this.url,!0),this._withCredentials&&(r.withCredentials=!0),"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof s&&!this._isHost(s)){var a=this._header["content-type"],u=this._serializer||g.serialize[a?a.split(";")[0]:""];!u&&h(a)&&(u=g.serialize["application/json"]),u&&(s=u(s))}for(var c in this.header)null!=this.header[c]&&r.setRequestHeader(c,this.header[c]);return this._responseType&&(r.responseType=this._responseType),this.emit("request",this),r.send("undefined"!=typeof s?s:null),this},g.Request=f,g.get=function(t,e,r){var n=g("GET",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},g.head=function(t,e,r){var n=g("HEAD",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},g.options=function(t,e,r){var n=g("OPTIONS",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},g.del=p,g.delete=p,g.patch=function(t,e,r){var n=g("PATCH",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},g.post=function(t,e,r){var n=g("POST",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},g.put=function(t,e,r){var n=g("PUT",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n}},{"./is-object":18,"./request":20,"./request-base":19,emitter:11}],18:[function(t,e,r){function n(t){return null!==t&&"object"==typeof t}e.exports=n},{}],19:[function(t,e,r){var n=t("./is-object");r.clearTimeout=function(){return this._timeout=0,clearTimeout(this._timer),this},r.parse=function(t){return this._parser=t,this},r.serialize=function(t){return this._serializer=t,this},r.timeout=function(t){return this._timeout=t,this},r.then=function(t,e){if(!this._fullfilledPromise){var r=this;this._fullfilledPromise=new Promise(function(t,e){r.end(function(r,n){r?e(r):t(n)})})}return this._fullfilledPromise.then(t,e)},r.use=function(t){return t(this),this},r.get=function(t){return this._header[t.toLowerCase()]},r.getHeader=r.get,r.set=function(t,e){if(n(t)){for(var r in t)this.set(r,t[r]);return this}return this._header[t.toLowerCase()]=e,this.header[t]=e,this},r.unset=function(t){return delete this._header[t.toLowerCase()],delete this.header[t],this},r.field=function(t,e){return this._getFormData().append(t,e),this},r.abort=function(){return this._aborted?this:(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort"),this)},r.withCredentials=function(){return this._withCredentials=!0,this},r.redirects=function(t){return this._maxRedirects=t,this},r.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},r._isHost=function(t){var e={}.toString.call(t);switch(e){case"[object File]":case"[object Blob]":case"[object FormData]":return!0;default:return!1}},r.send=function(t){var e=n(t),r=this._header["content-type"];if(e&&n(this._data))for(var o in t)this._data[o]=t[o];else"string"==typeof t?(r||this.type("form"),r=this._header["content-type"],"application/x-www-form-urlencoded"==r?this._data=this._data?this._data+"&"+t:t:this._data=(this._data||"")+t):this._data=t;return!e||this._isHost(t)?this:(r||this.type("json"),this)}},{"./is-object":18}],20:[function(t,e,r){function n(t,e,r){return"function"==typeof r?new t("GET",e).end(r):2==arguments.length?new t("GET",e):new t(e,r)}e.exports=n},{}],21:[function(t,e,r){"use strict";function n(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}function o(t,e,r){if(t&&u.isObject(t)&&t instanceof n)return t;var o=new n;return o.parse(t,e,r),o}function s(t){return u.isString(t)&&(t=o(t)),t instanceof n?t.format():n.prototype.format.call(t)}function i(t,e){return o(t,!1,!0).resolve(e)}function a(t,e){return t?o(t,!1,!0).resolveObject(e):e}var h=t("punycode"),u=t("./util");r.parse=o,r.resolve=i,r.resolveObject=a,r.format=s,r.Url=n;var c=/^([a-z0-9.+-]+:)/i,l=/:[0-9]*$/,f=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,p=["<",">",'"',"`"," ","\r","\n","\t"],d=["{","}","|","\\","^","`"].concat(p),m=["'"].concat(d),y=["%","/","?",";","#"].concat(m),v=["/","?","#"],g=255,b=/^[+a-z0-9A-Z_-]{0,63}$/,_=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,w={javascript:!0,"javascript:":!0},x={javascript:!0,"javascript:":!0},O={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},S=t("querystring");n.prototype.parse=function(t,e,r){if(!u.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var n=t.indexOf("?"),o=n!==-1&&n127?"x":I[P];if(!N.match(b)){var H=R.slice(0,k),M=R.slice(k+1),D=I.match(_);D&&(H.push(D[1]),M.unshift(D[2])),M.length&&(a="/"+M.join(".")+a),this.hostname=H.join(".");break}}}this.hostname.length>g?this.hostname="":this.hostname=this.hostname.toLowerCase(),q||(this.hostname=h.toASCII(this.hostname));var J=this.port?":"+this.port:"",B=this.hostname||"";this.host=B+J,this.href+=this.host,q&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==a[0]&&(a="/"+a))}if(!w[d])for(var k=0,U=m.length;k0)&&r.host.split("@");j&&(r.auth=j.shift(),r.host=r.hostname=j.shift())}return r.search=t.search,r.query=t.query,u.isNull(r.pathname)&&u.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!w.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var T=w.slice(-1)[0],k=(r.host||t.host||w.length>1)&&("."===T||".."===T)||""===T,E=0,A=w.length;A>=0;A--)T=w[A],"."===T?w.splice(A,1):".."===T?(w.splice(A,1),E++):E&&(w.splice(A,1),E--);if(!b&&!_)for(;E--;E)w.unshift("..");!b||""===w[0]||w[0]&&"/"===w[0].charAt(0)||w.unshift(""),k&&"/"!==w.join("/").substr(-1)&&w.push("");var C=""===w[0]||w[0]&&"/"===w[0].charAt(0);if(S){r.hostname=r.host=C?"":w.length?w.shift():"";var j=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@");j&&(r.auth=j.shift(),r.host=r.hostname=j.shift())}return b=b||r.host&&w.length,b&&!C&&w.unshift(""),w.length?r.pathname=w.join("/"):(r.pathname=null,r.path=null),u.isNull(r.pathname)&&u.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},n.prototype.parseHost=function(){var t=this.host,e=l.exec(t);e&&(e=e[0],":"!==e&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},{"./util":22,punycode:13,querystring:16}],22:[function(t,e,r){"use strict";e.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},{}],23:[function(t,e,r){e.exports={description:"Prevent comment spam using Akismet service.",homepage:"https://github.com/cedx/akismet",name:"@cedx/akismet",author:"Cédric Belin ",bugs:"https://github.com/cedx/akismet/issues",license:"Apache-2.0",main:"./lib/index.js",repository:"cedx/akismet",version:"0.8.0",bin:{akismet:"./bin/cli.js"},dependencies:{"body-parser":"^1.15.2",commander:"^2.9.0",cors:"^2.7.1",express:"^4.14.0",forever:"^0.15.2",superagent:"^2.1.0"},devDependencies:{"@cedx/gulp-david":"^2.0.2","babel-preset-es2015":"^6.9.0",babelify:"^7.3.0",browserify:"^13.1.0","codacy-coverage":"^1.1.3",del:"^2.2.1",gulp:"^3.9.1","gulp-istanbul":"^1.0.0","gulp-jshint":"^2.0.1","gulp-load-plugins":"^1.2.4","gulp-mocha":"^3.0.0","gulp-sourcemaps":"^1.6.0","gulp-uglify":"^2.0.0","gulp-zip":"^3.2.0",jsdoc:"^3.4.0",jshint:"^2.9.2",mocha:"^3.0.1","vinyl-buffer":"^1.0.0","vinyl-source-stream":"^1.1.0"},engines:{node:">=6.3.0"},jshintConfig:{browser:!0,esversion:6,freeze:!0,futurehostile:!0,jquery:!0,latedef:"nofunc",mocha:!0,noarg:!0,nocomma:!0,node:!0,nonbsp:!0,nonew:!0,singleGroups:!0,trailing:!0,typed:!0,undef:!0,unused:!0,varstmt:!0},keywords:["akismet","comment","spam","validation"],scripts:{coverage:"codacy-coverage < var/lcov.info",start:"forever start -c node -e var/stderr.log -o var/stdout.log -l var/forever.log --append --minUptime 30000 --spinSleepTime 30000 --uid akismet bin/cli.js",stop:"forever stop akismet",test:"gulp test"}}},{}]},{},[10]); \ No newline at end of file diff --git a/lib/client/client.js b/lib/client/client.js index 07a568e8..513cdaaa 100644 --- a/lib/client/client.js +++ b/lib/client/client.js @@ -50,7 +50,7 @@ class Client { * If possible, the user agent string should always have the following format: `Application Name/Version | Plugin Name/Version`. * @type {string} */ - this.userAgent = `Node.js/${typeof global.window == 'undefined' ? process.version : '0.0.0'} | Akismet/${pkg.version}`; + this.userAgent = `Node.js/${typeof window == 'undefined' ? process.version : '0.0.0'} | Akismet/${pkg.version}`; // Initialize the instance. for(let key in options) { diff --git a/lib/index.js b/lib/index.js index 8dc94d3c..f4403e1a 100644 --- a/lib/index.js +++ b/lib/index.js @@ -15,7 +15,7 @@ module.exports = { }; // Expose the `cedx.akismet` global property in browsers. -if(typeof global.window != 'undefined') { - if(typeof global.window.cedx != 'object' || !global.window.cedx) global.window.cedx = {}; - global.window.cedx.akismet = module.exports; +if(typeof window != 'undefined') { + if(typeof window.cedx != 'object' || !window.cedx) window.cedx = {}; + window.cedx.akismet = module.exports; } diff --git a/lib/server/application.js b/lib/server/application.js index 705f52c9..3c80d8cf 100644 --- a/lib/server/application.js +++ b/lib/server/application.js @@ -2,8 +2,6 @@ * Implementation of the `akismet.Application` class. * @module server/app */ -const fs = require('fs'); -const path = require('path'); const pkg = require('../../package.json'); const program = require('commander'); const Server = require('./server'); @@ -63,7 +61,7 @@ class Application { program.parse(process.argv); // Start the server. - this.startServer(program.port, program.host, program.redirect ? program.redirect : null) + this.startServer(program.port, program.host, program.redirect) .then(() => { if(program.user) this.setUser(program.user); }) diff --git a/web/.htaccess b/web/.htaccess deleted file mode 100644 index de377bfe..00000000 --- a/web/.htaccess +++ /dev/null @@ -1 +0,0 @@ -ErrorDocument 404 /404.html diff --git a/web/404.html b/web/404.html deleted file mode 100644 index 6d629733..00000000 --- a/web/404.html +++ /dev/null @@ -1,153 +0,0 @@ - - - - - Page not found – Akismet for JS - - - - - - - - - - - - - - - - - - - - - - Skip to main content - -
- -
- -
-
-
- - -
- - This is not the web page you are looking for. -
- -

- - - - -

-
- - -
-
- - - - diff --git a/web/index.html b/web/index.html index b7044aeb..57f66f78 100644 --- a/web/index.html +++ b/web/index.html @@ -52,15 +52,16 @@