-
Notifications
You must be signed in to change notification settings - Fork 0
/
seismo.min.js
2 lines (2 loc) · 8.76 KB
/
seismo.min.js
1
2
!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b){function c(a,b){if("function"!=typeof b)throw new Error("Bad callback given: "+b);if(!a)throw new Error("No options given");var g=a.onResponse;if(a="string"==typeof a?{uri:a}:JSON.parse(JSON.stringify(a)),a.onResponse=g,a.verbose&&(c.log=f()),a.url&&(a.uri=a.url,delete a.url),!a.uri&&""!==a.uri)throw new Error("options.uri is a required argument");if("string"!=typeof a.uri)throw new Error("options.uri must be a string");for(var h=["proxy","_redirectsFollowed","maxRedirects","followRedirect"],j=0;j<h.length;j++)if(a[h[j]])throw new Error("options."+h[j]+" is not supported");if(a.callback=b,a.method=a.method||"GET",a.headers=a.headers||{},a.body=a.body||null,a.timeout=a.timeout||c.DEFAULT_TIMEOUT,a.headers.host)throw new Error("Options.headers.host is not supported");return a.json&&(a.headers.accept=a.headers.accept||"application/json","GET"!==a.method&&(a.headers["content-type"]="application/json"),"boolean"!=typeof a.json?a.body=JSON.stringify(a.json):"string"!=typeof a.body&&(a.body=JSON.stringify(a.body))),a.onResponse=a.onResponse||e,a.onResponse===!0&&(a.onResponse=b,a.callback=e),!a.headers.authorization&&a.auth&&(a.headers.authorization="Basic "+i(a.auth.username+":"+a.auth.password)),d(a)}function d(a){function b(){k=!0;var b=new Error("ETIMEDOUT");return b.code="ETIMEDOUT",b.duration=a.timeout,c.log.error("Timeout",{id:i._id,milliseconds:a.timeout}),a.callback(b,i)}function d(){if(k)return c.log.debug("Ignoring timed out state change",{state:i.readyState,id:i.id});if(c.log.debug("State change",{state:i.readyState,id:i.id,timed_out:k}),i.readyState===j.OPENED){c.log.debug("Request started",{id:i.id});for(var b in a.headers)i.setRequestHeader(b,a.headers[b])}else i.readyState===j.HEADERS_RECEIVED?e():i.readyState===j.LOADING?(e(),f()):i.readyState===j.DONE&&(e(),f(),g())}function e(){if(!p.response){if(p.response=!0,c.log.debug("Got response",{id:i.id,status:i.status}),clearTimeout(i.timeoutTimer),i.statusCode=i.status,m&&0==i.statusCode){var b=new Error("CORS request rejected: "+a.uri);return b.cors="rejected",p.loading=!0,p.end=!0,a.callback(b,i)}a.onResponse(null,i)}}function f(){p.loading||(p.loading=!0,c.log.debug("Response body loading",{id:i.id}))}function g(){if(!p.end){if(p.end=!0,c.log.debug("Request done",{id:i.id}),i.body=i.responseText,a.json)try{i.body=JSON.parse(i.responseText)}catch(b){return a.callback(b,i)}a.callback(null,i,i.body)}}var i=new j,k=!1,m=h(a.uri),n="withCredentials"in i;if(l+=1,i.seq_id=l,i.id=l+": "+a.method+" "+a.uri,i._id=i.id,m&&!n){var o=new Error("Browser does not support cross-origin request: "+a.uri);return o.cors="unsupported",a.callback(o,i)}i.timeoutTimer=setTimeout(b,a.timeout);var p={response:!1,loading:!1,end:!1};return i.onreadystatechange=d,i.open(a.method,a.uri,!0),m&&(i.withCredentials=!!a.withCredentials),i.send(a.body),i}function e(){}function f(){var a,b,c={},d=["trace","debug","info","warn","error"];for(b=0;b<d.length;b++)a=d[b],c[a]=e,"undefined"!=typeof console&&console&&console[a]&&(c[a]=g(console,a));return c}function g(a,b){function c(c,d){return"object"==typeof d&&(c+=" "+JSON.stringify(d)),a[b].call(a,c)}return c}function h(a){var b,c=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/;try{b=location.href}catch(d){b=document.createElement("a"),b.href="",b=b.href}var e=c.exec(b.toLowerCase())||[],f=c.exec(a.toLowerCase()),g=!(!f||f[1]==e[1]&&f[2]==e[2]&&(f[3]||("http:"===f[1]?80:443))==(e[3]||("http:"===e[1]?80:443)));return g}function i(a){var b,c,d,e,f,g,h,i,j="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",k=0,l=0,m="",n=[];if(!a)return a;do b=a.charCodeAt(k++),c=a.charCodeAt(k++),d=a.charCodeAt(k++),i=b<<16|c<<8|d,e=i>>18&63,f=i>>12&63,g=i>>6&63,h=63&i,n[l++]=j.charAt(e)+j.charAt(f)+j.charAt(g)+j.charAt(h);while(k<a.length);switch(m=n.join(""),a.length%3){case 1:m=m.slice(0,-2)+"==";break;case 2:m=m.slice(0,-1)+"="}return m}var j=XMLHttpRequest;if(!j)throw new Error("missing XMLHttpRequest");b.exports=c,c.log={trace:e,debug:e,info:e,warn:e,error:e};var k=18e4,l=0;c.withCredentials=!1,c.DEFAULT_TIMEOUT=k,c.defaults=function(a){var b=function(b){var c=function(c,d){c="string"==typeof c?{uri:c}:JSON.parse(JSON.stringify(c));for(var e in a)void 0===c[e]&&(c[e]=a[e]);return b(c,d)};return c},d=b(c);return d.get=b(c.get),d.post=b(c.post),d.put=b(c.put),d.head=b(c.head),d};var m=["get","put","post","head"];m.forEach(function(a){var b=a.toUpperCase(),d=a.toLowerCase();c[d]=function(a){"string"==typeof a?a={method:b,uri:a}:(a=JSON.parse(JSON.stringify(a)),a.method=b);var d=[a].concat(Array.prototype.slice.apply(arguments,[1]));return c.apply(this,d)}}),c.couch=function(a,b){function d(a,c,d){if(a)return b(a,c,d);if((c.statusCode<200||c.statusCode>299)&&d.error){a=new Error("CouchDB error: "+(d.error.reason||d.error.error));for(var e in d)a[e]=d[e];return b(a,c,d)}return b(a,c,d)}"string"==typeof a&&(a={uri:a}),a.json=!0,a.body&&(a.json=a.body),delete a.body,b=b||e;var f=c(a,d);return f}},{}],2:[function(a,b){"use strict";function c(a,b){return Object.prototype.hasOwnProperty.call(a,b)}b.exports=function(a,b,e,f){b=b||"&",e=e||"=";var g={};if("string"!=typeof a||0===a.length)return g;var h=/\+/g;a=a.split(b);var i=1e3;f&&"number"==typeof f.maxKeys&&(i=f.maxKeys);var j=a.length;i>0&&j>i&&(j=i);for(var k=0;j>k;++k){var l,m,n,o,p=a[k].replace(h,"%20"),q=p.indexOf(e);q>=0?(l=p.substr(0,q),m=p.substr(q+1)):(l=p,m=""),n=decodeURIComponent(l),o=decodeURIComponent(m),c(g,n)?d(g[n])?g[n].push(o):g[n]=[g[n],o]:g[n]=o}return g};var d=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)}},{}],3:[function(a,b){"use strict";function c(a,b){if(a.map)return a.map(b);for(var c=[],d=0;d<a.length;d++)c.push(b(a[d],d));return c}var d=function(a){switch(typeof a){case"string":return a;case"boolean":return a?"true":"false";case"number":return isFinite(a)?a:"";default:return""}};b.exports=function(a,b,g,h){return b=b||"&",g=g||"=",null===a&&(a=void 0),"object"==typeof a?c(f(a),function(c){var f=encodeURIComponent(d(c))+g;return e(a[c])?a[c].map(function(a){return f+encodeURIComponent(d(a))}).join(b):f+encodeURIComponent(d(a[c]))}).join(b):h?encodeURIComponent(d(h))+g+encodeURIComponent(d(a)):""};var e=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)},f=Object.keys||function(a){var b=[];for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&b.push(c);return b}},{}],4:[function(a,b,c){"use strict";c.decode=c.parse=a("./decode"),c.encode=c.stringify=a("./encode")},{"./decode":2,"./encode":3}],5:[function(a){window.seismo=a("./seismo")},{"./seismo":7}],6:[function(a,b){var c=a("querystring"),d={events:function(a){return"string"==typeof a?"?event="+a:"?"+c.stringify(a)},reports:function(a){return"?"+c.stringify(a)}};b.exports=d},{querystring:4}],7:[function(a,b){var c=a("browser-request"),d=a("./query");b.exports=function(a,b){function e(a,b){c.post({url:g+"/auth",body:a,json:!0},function(a,c){return a?b(a):(b(null,c.body.token),void 0)})}function f(a){return i?(a(null,i),void 0):e(h,function(b,c){return b?a(b):(i=c,a(null,c))})}if(!a)throw new Error("application id is required");if(!b||!b.credentials)throw new Error("options or credentials are missing");var g=b&&b.server||"http://localhost:3005",h=b.credentials;if(!h)throw new Error("options object missing service credentials");var i,j=function(b,d,e){var h=g+"/api/events/"+a;"function"==typeof d&&(e=d),f(function(a,f){return a?e(a):(c.post({url:h,body:{event:b,data:d},headers:{"X-Access-Token":f},json:!0},function(a,b){return a?e({message:"error occured during event posting",err:a}):201!==b.statusCode?e({message:"server error",code:b.statusCode,err:b.body}):(e(null,b.body),void 0)}),void 0)})};return j.query=function(b,e){var h=g+"/api/events/"+a;"function"==typeof b?e=b:h+=d.events(b),f(function(a,b){return a?e(a):(c.get({url:h,headers:{"X-Access-Token":b},json:!0},function(a,b){return a?e({message:"error occured during getting events",err:a}):200!==b.statusCode?e({message:"server error",code:b.statusCode}):(e(null,b.body),void 0)}),void 0)})},j.report=function(b,e){if(!b.report)return e("missing report option");var h=g+"/api/reports/"+b.report+"/"+a;h+=d.reports(b),f(function(a,b){return a?e(a):(c.get({url:h,headers:{"X-Access-Token":b},json:!0},function(a,b){return a?e({message:"error occured during getting events",err:a}):200!==b.statusCode?e({message:"server error",code:b.statusCode}):(e(null,b.body),void 0)}),void 0)})},j}},{"./query":6,"browser-request":1}]},{},[5,6,7]);
//# sourceMappingURL=seismo.map.js