Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pouchdb-authentication

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pouchdb-authentication - npm Package Compare versions

Comparing version 0.5.2 to 0.5.3

4

dist/pouchdb.authentication.min.js

@@ -1,2 +0,2 @@

!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.PouchAuthentication=e()}}(function(){var e;return function t(e,n,r){function o(i,a){if(!n[i]){if(!e[i]){var u="function"==typeof require&&require;if(!a&&u)return u(i,!0);if(s)return s(i,!0);throw new Error("Cannot find module '"+i+"'")}var c=n[i]={exports:{}};e[i][0].call(c.exports,function(t){var n=e[i][1][t];return o(n?n:t)},c,c.exports,t,e,n,r)}return n[i].exports}for(var s="function"==typeof require&&require,i=0;i<r.length;i++)o(r[i]);return o}({1:[function(e,t,n){"use strict";function r(e){return function(t,n){return t&&"unknown_error"===t.name&&(t.message=(t.message||"")+" Unknown error! Did you remember to enable CORS?"),e(t,n)}}function o(e,t,n,o){var a=["name","password","roles","type","salt","metadata"];if(n.metadata){for(var u in n.metadata)if(n.hasOwnProperty(u)&&(-1!==a.indexOf(u)||u.startsWith("_")))return o(new s('cannot use reserved word in metadata: "'+u+'"'));t=i.extend(!0,t,n.metadata)}var c=i.getUsersUrl(e)+"/"+encodeURIComponent(t._id),f=i.extend(!0,{method:"PUT",url:c,body:t},n.ajax||{});i.ajax(f,r(o))}function s(e){this.status=400,this.name="authentication_error",this.message=e,this.error=!0;try{Error.captureStackTrace(this,s)}catch(t){}}var i=e("./utils");n.signup=i.toPromise(function(e,t,n,r){var i=this;if("undefined"==typeof r&&(r="undefined"==typeof n?"undefined"==typeof t?e:t:n,n={}),-1===["http","https"].indexOf(i.type()))return r(new s('This plugin only works for the http/https adapter. So you should use new PouchDB("http://mysite.com:5984/mydb") instead.'));if(!e)return r(new s("You must provide a username"));if(!t)return r(new s("You must provide a password"));var a="org.couchdb.user:"+e,u={name:e,password:t,roles:n.roles||[],type:"user",_id:a};o(i,u,n,r)}),n.signUp=n.signup,n.login=i.toPromise(function(e,t,n,o){var a=this;if("undefined"==typeof o&&(o=n,n={}),-1===["http","https"].indexOf(a.type()))return o(new s("this plugin only works for the http/https adapter"));if(!e)return o(new s("you must provide a username"));if(!t)return o(new s("you must provide a password"));var u=i.extend(!0,{method:"POST",url:i.getSessionUrl(a),headers:{"Content-Type":"application/x-www-form-urlencoded"},body:"name="+encodeURIComponent(e)+"&password="+encodeURIComponent(t)},n.ajax||{});i.ajax(u,r(o))}),n.logIn=n.login,n.logout=i.toPromise(function(e,t){var n=this;"undefined"==typeof t&&(t=e,e={});var o=i.extend(!0,{method:"DELETE",url:i.getSessionUrl(n)},e.ajax||{});i.ajax(o,r(t))}),n.logOut=n.logout,n.getSession=i.toPromise(function(e,t){var n=this;"undefined"==typeof t&&(t=e,e={});var o=i.getSessionUrl(n),s=i.extend(!0,{method:"GET",url:o},e.ajax||{});i.ajax(s,r(t))}),n.getUser=i.toPromise(function(e,t,n){var o=this;if("undefined"==typeof n&&(n="undefined"==typeof t?e:t,t={}),!e)return n(new s("you must provide a username"));var a=i.getUsersUrl(o),u=i.extend(!0,{method:"GET",url:a+"/"+encodeURIComponent("org.couchdb.user:"+e)},t.ajax||{});i.ajax(u,r(n))}),n.putUser=i.toPromise(function(e,t,n){var r=this;return"undefined"==typeof n&&(n="undefined"==typeof t?e:t,t={}),-1===["http","https"].indexOf(r.type())?n(new s('This plugin only works for the http/https adapter. So you should use new PouchDB("http://mysite.com:5984/mydb") instead.')):e?r.getUser(e,t,function(e,s){return e?n(e):void o(r,s,t,n)}):n(new s("You must provide a username"))}),n.changePassword=i.toPromise(function(e,t,n,o){var a=this;return"undefined"==typeof o&&(o="undefined"==typeof n?"undefined"==typeof t?e:t:n,n={}),-1===["http","https"].indexOf(a.type())?o(new s('This plugin only works for the http/https adapter. So you should use new PouchDB("http://mysite.com:5984/mydb") instead.')):e?t?a.getUser(e,n,function(e,s){if(e)return o(e);s.password=t;var u=i.getUsersUrl(a)+"/"+encodeURIComponent(s._id),c=i.extend(!0,{method:"PUT",url:u,body:s},n.ajax||{});i.ajax(c,r(o))}):o(new s("You must provide a password")):o(new s("You must provide a username"))}),n.changeUsername=i.toPromise(function(e,t,n,o){var a=this,u="org.couchdb.user:",c=function(e){return new i.Promise(function(t,n){i.ajax(e,r(function(e,r){return e?n(e):void t(r)}))})},f=function(e,t){var n=i.getUsersUrl(a)+"/"+encodeURIComponent(e._id),r=i.extend(!0,{method:"PUT",url:n,body:e},t.ajax);return c(r)};return"undefined"==typeof o&&(o=n,n={}),n.ajax=n.ajax||{},-1===["http","https"].indexOf(a.type())?o(new s('This plugin only works for the http/https adapter. So you should use new PouchDB("http://mysite.com:5984/mydb") instead.')):t?e?a.getUser(t,n).then(function(){var e=new s("user already exists");throw e.taken=!0,e},function(){return a.getUser(e,n)}).then(function(e){var r=i.clone(e);return delete r._rev,r._id=u+t,r.name=t,r.roles=n.roles||e.roles||{},f(r,n).then(function(){return e._deleted=!0,f(e,n)})}).then(function(e){o(null,e)})["catch"](o):o(new s("You must provide a username to rename")):o(new s("You must provide a new username"))}),i.inherits(s,Error),"undefined"!=typeof window&&window.PouchDB&&window.PouchDB.plugin(n)},{"./utils":2}],2:[function(e,t,n){(function(t){"use strict";function r(e){return e.getUrl().replace(/\/[^\/]+\/?$/,"")}var o=e("pouchdb-promise"),s=e("url-join");n.getUsersUrl=function(e){return s(r(e),"/_users")},n.getSessionUrl=function(e){return s(r(e),"/_session")},n.once=function(e){var t=!1;return n.getArguments(function(n){if(t)throw console.trace(),new Error("once called more than once");t=!0,e.apply(this,n)})},n.getArguments=function(e){return function(){for(var t=arguments.length,n=new Array(t),r=-1;++r<t;)n[r]=arguments[r];return e.call(this,n)}},n.toPromise=function(e){return n.getArguments(function(r){var s,i=this,a="function"==typeof r[r.length-1]?r.pop():!1;a&&(s=function(e,n){t.nextTick(function(){a(e,n)})});var u=new o(function(t,o){try{var s=n.once(function(e,n){e?o(e):t(n)});r.push(s),e.apply(i,r)}catch(a){o(a)}});return s&&u.then(function(e){s(null,e)},s),u.cancel=function(){return this},u})},n.inherits=e("inherits"),n.extend=e("pouchdb-extend"),n.ajax=e("pouchdb-ajax"),n.clone=function(e){return n.extend(!0,{},e)},n.uuid=e("./uuid"),n.Promise=o}).call(this,e("/Users/nolan/workspace/pouchdb-authentication/node_modules/process/browser.js"))},{"./uuid":3,"/Users/nolan/workspace/pouchdb-authentication/node_modules/process/browser.js":19,inherits:9,"pouchdb-ajax":12,"pouchdb-extend":15,"pouchdb-promise":16,"url-join":20}],3:[function(e,t,n){"use strict";function r(e){return 0|Math.random()*e}function o(e,t){t=t||s.length;var n="",o=-1;if(e){for(;++o<e;)n+=s[r(t)];return n}for(;++o<36;)switch(o){case 8:case 13:case 18:case 23:n+="-";break;case 19:n+=s[3&r(16)|8];break;default:n+=s[r(16)]}return n}var s="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split("");t.exports=o},{}],4:[function(e,t,n){"use strict";function r(e){return function(){var t=arguments.length;if(t){for(var n=[],r=-1;++r<t;)n[r]=arguments[r];return e.call(this,n)}return e.call(this,[])}}t.exports=r},{}],5:[function(e,t,n){function r(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31}function o(){var e=arguments,t=this.useColors;if(e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+n.humanize(this.diff),!t)return e;var r="color: "+this.color;e=[e[0],r,"color: inherit"].concat(Array.prototype.slice.call(e,1));var o=0,s=0;return e[0].replace(/%[a-z%]/g,function(e){"%%"!==e&&(o++,"%c"===e&&(s=o))}),e.splice(s,0,r),e}function s(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function i(e){try{null==e?n.storage.removeItem("debug"):n.storage.debug=e}catch(t){}}function a(){var e;try{e=n.storage.debug}catch(t){}return e}function u(){try{return window.localStorage}catch(e){}}n=t.exports=e("./debug"),n.log=s,n.formatArgs=o,n.save=i,n.load=a,n.useColors=r,n.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:u(),n.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],n.formatters.j=function(e){return JSON.stringify(e)},n.enable(a())},{"./debug":6}],6:[function(e,t,n){function r(){return n.colors[f++%n.colors.length]}function o(e){function t(){}function o(){var e=o,t=+new Date,s=t-(c||t);e.diff=s,e.prev=c,e.curr=t,c=t,null==e.useColors&&(e.useColors=n.useColors()),null==e.color&&e.useColors&&(e.color=r());var i=Array.prototype.slice.call(arguments);i[0]=n.coerce(i[0]),"string"!=typeof i[0]&&(i=["%o"].concat(i));var a=0;i[0]=i[0].replace(/%([a-z%])/g,function(t,r){if("%%"===t)return t;a++;var o=n.formatters[r];if("function"==typeof o){var s=i[a];t=o.call(e,s),i.splice(a,1),a--}return t}),"function"==typeof n.formatArgs&&(i=n.formatArgs.apply(e,i));var u=o.log||n.log||console.log.bind(console);u.apply(e,i)}t.enabled=!1,o.enabled=!0;var s=n.enabled(e)?o:t;return s.namespace=e,s}function s(e){n.save(e);for(var t=(e||"").split(/[\s,]+/),r=t.length,o=0;r>o;o++)t[o]&&(e=t[o].replace(/\*/g,".*?"),"-"===e[0]?n.skips.push(new RegExp("^"+e.substr(1)+"$")):n.names.push(new RegExp("^"+e+"$")))}function i(){n.enable("")}function a(e){var t,r;for(t=0,r=n.skips.length;r>t;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;r>t;t++)if(n.names[t].test(e))return!0;return!1}function u(e){return e instanceof Error?e.stack||e.message:e}n=t.exports=o,n.coerce=u,n.disable=i,n.enable=s,n.enabled=a,n.humanize=e("ms"),n.names=[],n.skips=[],n.formatters={};var c,f=0},{ms:11}],7:[function(e,t,n){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function o(e){return"function"==typeof e}function s(e){return"number"==typeof e}function i(e){return"object"==typeof e&&null!==e}function a(e){return void 0===e}t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if(!s(e)||0>e||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,n,r,s,u,c;if(this._events||(this._events={}),"error"===e&&(!this._events.error||i(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t;throw TypeError('Uncaught, unspecified "error" event.')}if(n=this._events[e],a(n))return!1;if(o(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:for(r=arguments.length,s=new Array(r-1),u=1;r>u;u++)s[u-1]=arguments[u];n.apply(this,s)}else if(i(n)){for(r=arguments.length,s=new Array(r-1),u=1;r>u;u++)s[u-1]=arguments[u];for(c=n.slice(),r=c.length,u=0;r>u;u++)c[u].apply(this,s)}return!0},r.prototype.addListener=function(e,t){var n;if(!o(t))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,o(t.listener)?t.listener:t),this._events[e]?i(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,i(this._events[e])&&!this._events[e].warned){var n;n=a(this._maxListeners)?r.defaultMaxListeners:this._maxListeners,n&&n>0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())}return this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}if(!o(t))throw TypeError("listener must be a function");var r=!1;return n.listener=t,this.on(e,n),this},r.prototype.removeListener=function(e,t){var n,r,s,a;if(!o(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],s=n.length,r=-1,n===t||o(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(i(n)){for(a=s;a-->0;)if(n[a]===t||n[a].listener&&n[a].listener===t){r=a;break}if(0>r)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],o(n))this.removeListener(e,n);else for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?o(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.listenerCount=function(e,t){var n;return n=e._events&&e._events[t]?o(e._events[t])?1:e._events[t].length:0}},{}],8:[function(e,t,n){(function(e){"use strict";function n(){f=!0;for(var e,t,n=l.length;n;){for(t=l,l=[],e=-1;++e<n;)t[e]();n=l.length}f=!1}function r(e){1!==l.push(e)||f||o()}var o,s=e.MutationObserver||e.WebKitMutationObserver;if(s){var i=0,a=new s(n),u=e.document.createTextNode("");a.observe(u,{characterData:!0}),o=function(){u.data=i=++i%2}}else if(e.setImmediate||"undefined"==typeof e.MessageChannel)o="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){n(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(n,0)};else{var c=new e.MessageChannel;c.port1.onmessage=n,o=function(){c.port2.postMessage(0)}}var f,l=[];t.exports=r}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],9:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],10:[function(e,t,n){(function(e){e("object"==typeof n?n:this)}).call(this,function(e){var t=Array.prototype.slice,n=Array.prototype.forEach,r=function(e){if("object"!=typeof e)throw e+" is not an object";var o=t.call(arguments,1);return n.call(o,function(t){if(t)for(var n in t)"object"==typeof t[n]&&e[n]?r.call(e,e[n],t[n]):e[n]=t[n]}),e};e.extend=r})},{}],11:[function(e,t,n){function r(e){if(e=""+e,!(e.length>1e4)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]),r=(t[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return n*l;case"days":case"day":case"d":return n*f;case"hours":case"hour":case"hrs":case"hr":case"h":return n*c;case"minutes":case"minute":case"mins":case"min":case"m":return n*u;case"seconds":case"second":case"secs":case"sec":case"s":return n*a;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n}}}}function o(e){return e>=f?Math.round(e/f)+"d":e>=c?Math.round(e/c)+"h":e>=u?Math.round(e/u)+"m":e>=a?Math.round(e/a)+"s":e+"ms"}function s(e){return i(e,f,"day")||i(e,c,"hour")||i(e,u,"minute")||i(e,a,"second")||e+" ms"}function i(e,t,n){return t>e?void 0:1.5*t>e?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}var a=1e3,u=60*a,c=60*u,f=24*c,l=365.25*f;t.exports=function(e,t){return t=t||{},"string"==typeof e?r(e):t["long"]?s(e):o(e)}},{}],12:[function(e,t,n){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e["default"]:e}function o(){for(var e={},t=new p(function(t,n){e.resolve=t,e.reject=n}),n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.promise=t,p.resolve().then(function(){return fetch.apply(null,n)}).then(function(t){e.resolve(t)})["catch"](function(t){e.reject(t)}),e}function s(e,t){var n,r,s,i=new Headers,a={method:e.method,credentials:"include",headers:i};return e.json&&(i.set("Accept","application/json"),i.set("Content-Type",e.headers["Content-Type"]||"application/json")),e.body&&e.body instanceof Blob?d.readAsArrayBuffer(e.body,function(e){a.body=e}):e.body&&e.processData&&"string"!=typeof e.body?a.body=JSON.stringify(e.body):"body"in e?a.body=e.body:a.body=null,Object.keys(e.headers).forEach(function(t){e.headers.hasOwnProperty(t)&&i.set(t,e.headers[t])}),n=o(e.url,a),e.timeout>0&&(r=setTimeout(function(){n.reject(new Error("Load timeout for resource: "+e.url))},e.timeout)),n.promise.then(function(t){return s={statusCode:t.status},e.timeout>0&&clearTimeout(r),s.statusCode>=200&&s.statusCode<300?e.binary?t.blob():t.text():t.json()}).then(function(e){s.statusCode>=200&&s.statusCode<300?t(null,s,e):t(e,s)})["catch"](function(e){t(e,s)}),{abort:n.reject}}function i(e,t){var n,r,o=!1,s=function(){n.abort()},i=function(){o=!0,n.abort()};n=e.xhr?new e.xhr:new XMLHttpRequest;try{n.open(e.method,e.url)}catch(a){t(a,{statusCode:413})}n.withCredentials="withCredentials"in e?e.withCredentials:!0,"GET"===e.method?delete e.headers["Content-Type"]:e.json&&(e.headers.Accept="application/json",e.headers["Content-Type"]=e.headers["Content-Type"]||"application/json",e.body&&e.processData&&"string"!=typeof e.body&&(e.body=JSON.stringify(e.body))),e.binary&&(n.responseType="arraybuffer"),"body"in e||(e.body=null);for(var u in e.headers)e.headers.hasOwnProperty(u)&&n.setRequestHeader(u,e.headers[u]);return e.timeout>0&&(r=setTimeout(i,e.timeout),n.onprogress=function(){clearTimeout(r),4!==n.readyState&&(r=setTimeout(i,e.timeout))},"undefined"!=typeof n.upload&&(n.upload.onprogress=n.onprogress)),n.onreadystatechange=function(){if(4===n.readyState){var r={statusCode:n.status};if(n.status>=200&&n.status<300){var s;s=e.binary?d.blob([n.response||""],{type:n.getResponseHeader("Content-Type")}):n.responseText,t(null,r,s)}else{var i={};if(o)i=new Error("ETIMEDOUT"),r.statusCode=400;else try{i=JSON.parse(n.response)}catch(a){}t(i,r)}}},e.body&&e.body instanceof Blob?d.readAsArrayBuffer(e.body,function(e){n.send(e)}):n.send(e.body),{abort:s}}function a(){try{return new XMLHttpRequest,!0}catch(e){return!1}}function u(e,t){return v||e.xhr?i(e,t):s(e,t)}function c(){return""}function f(e,t){function n(t,n,r){if(!e.binary&&e.json&&"string"==typeof t)try{t=JSON.parse(t)}catch(o){return r(o)}Array.isArray(t)&&(t=t.map(function(e){return e.error||e.missing?y.generateErrorFromResponse(e):e})),e.binary&&g(t,n),r(null,t,n)}function r(e,t){var n,r;if(e.code&&e.status){var o=new Error(e.message||e.code);return o.status=e.status,t(o)}if(e.message&&"ETIMEDOUT"===e.message)return t(e);try{n=JSON.parse(e.responseText),r=y.generateErrorFromResponse(n)}catch(s){r=y.generateErrorFromResponse(e)}t(r)}e=m.clone(e);var o={method:"GET",headers:{},json:!0,processData:!0,timeout:1e4,cache:!1};return e=h.extend(o,e),e.json&&(e.binary||(e.headers.Accept="application/json"),e.headers["Content-Type"]=e.headers["Content-Type"]||"application/json"),e.binary&&(e.encoding=null,e.json=!1),e.processData||(e.json=!1),u(e,function(o,s,i){if(o)return o.status=s?s.statusCode:400,r(o,t);var a,u=s.headers&&s.headers["content-type"],f=i||c();if(!e.binary&&(e.json||!e.processData)&&"object"!=typeof f&&(/json/.test(u)||/^[\s]*\{/.test(f)&&/\}[\s]*$/.test(f)))try{f=JSON.parse(f.toString())}catch(l){}s.statusCode>=200&&s.statusCode<300?n(f,s,t):(a=y.generateErrorFromResponse(f),a.status=s.statusCode,t(a))})}function l(e,t){var n=navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",r=-1!==n.indexOf("safari")&&-1===n.indexOf("chrome"),o=-1!==n.indexOf("msie"),s=-1!==n.indexOf("edge"),i=r||(o||s)&&"GET"===e.method,a="cache"in e?e.cache:!0,u=/^blob:/.test(e.url);if(!u&&(i||!a)){var c=-1!==e.url.indexOf("?");e.url+=(c?"&":"?")+"_nonce="+Date.now()}return f(e,t)}var d=e("pouchdb-binary-utils"),p=r(e("pouchdb-promise")),h=e("js-extend"),y=e("pouchdb-errors"),m=e("pouchdb-utils"),v=a(),g=function(){};t.exports=l},{"js-extend":10,"pouchdb-binary-utils":13,"pouchdb-errors":14,"pouchdb-promise":16,"pouchdb-utils":18}],13:[function(e,t,n){"use strict";function r(e){for(var t="",n=new Uint8Array(e),r=n.byteLength,o=0;r>o;o++)t+=String.fromCharCode(n[o]);return t}function o(e){return h(r(e))}function s(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(n){if("TypeError"!==n.name)throw n;for(var r="undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder,o=new r,s=0;s<e.length;s+=1)o.append(e[s]);return o.getBlob(t.type)}}function i(e){for(var t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n),o=0;t>o;o++)r[o]=e.charCodeAt(o);return n}function a(e,t){return s([i(e)],{type:t})}function u(e,t){return a(p(e),t)}function c(e,t){if("undefined"==typeof FileReader)return t(r((new FileReaderSync).readAsArrayBuffer(e)));var n=new FileReader,o="function"==typeof n.readAsBinaryString;n.onloadend=function(e){var n=e.target.result||"";return o?t(n):void t(r(n))},o?n.readAsBinaryString(e):n.readAsArrayBuffer(e)}function f(e,t){c(e,function(e){t(h(e))})}function l(e,t){if("undefined"==typeof FileReader)return t((new FileReaderSync).readAsArrayBuffer(e));var n=new FileReader;n.onloadend=function(e){var n=e.target.result||new ArrayBuffer(0);t(n)},n.readAsArrayBuffer(e)}function d(){}Object.defineProperty(n,"__esModule",{value:!0});var p=function(e){return atob(e)},h=function(e){return btoa(e)};n.arrayBufferToBase64=o,n.arrayBufferToBinaryString=r,n.atob=p,n.btoa=h,n.base64StringToBlobOrBuffer=u,n.binaryStringToArrayBuffer=i,n.binaryStringToBlobOrBuffer=a,n.blob=s,n.blobOrBufferToBase64=f,n.readAsArrayBuffer=l,n.readAsBinaryString=c,n.typedBuffer=d},{}],14:[function(e,t,n){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e["default"]:e}function o(e){Error.call(this,e.reason),this.status=e.status,this.name=e.error,this.message=e.reason,this.error=!0}function s(e,t,n){function r(t){for(var r in e)"function"!=typeof e[r]&&(this[r]=e[r]);void 0!==n&&(this.name=n),void 0!==t&&(this.reason=t)}return r.prototype=o.prototype,new r(t)}function i(e){var t,n,r,o,i;return n=e.error===!0&&"string"==typeof e.name?e.name:e.error,i=e.reason,r=I("name",n,i),e.missing||"missing"===i||"deleted"===i||"not_found"===n?r=f:"doc_validation"===n?(r=w,o=i):"bad_request"===n&&r.message!==i&&(r=_),r||(r=I("status",e.status,i)||m),t=s(r,i,n),o&&(t.message=o),e.id&&(t.id=e.id),e.status&&(t.status=e.status),e.missing&&(t.missing=e.missing),t}Object.defineProperty(n,"__esModule",{value:!0});var a=r(e("inherits"));a(o,Error),o.prototype.toString=function(){return JSON.stringify({status:this.status,name:this.name,message:this.message,reason:this.reason})};var u=new o({status:401,error:"unauthorized",reason:"Name or password is incorrect."}),c=new o({status:400,error:"bad_request",reason:"Missing JSON list of 'docs'"}),f=new o({status:404,error:"not_found",reason:"missing"}),l=new o({status:409,error:"conflict",reason:"Document update conflict"}),d=new o({status:400,error:"invalid_id",reason:"_id field must contain a string"}),p=new o({status:412,error:"missing_id",reason:"_id is required for puts"}),h=new o({status:400,error:"bad_request",reason:"Only reserved document ids may start with underscore."}),y=new o({status:412,error:"precondition_failed",reason:"Database not open"}),m=new o({status:500,error:"unknown_error",reason:"Database encountered an unknown error"}),v=new o({status:500,error:"badarg",reason:"Some query argument is invalid"}),g=new o({status:400,error:"invalid_request",reason:"Request was invalid"}),b=new o({status:400,error:"query_parse_error",reason:"Some query parameter is invalid"}),w=new o({status:500,error:"doc_validation",reason:"Bad special document member"}),_=new o({status:400,error:"bad_request",reason:"Something wrong with the request"}),E=new o({status:400,error:"bad_request",reason:"Document must be a JSON object"}),j=new o({status:404,error:"not_found",reason:"Database not found"}),x=new o({status:500,error:"indexed_db_went_bad",reason:"unknown"}),S=new o({status:500,error:"web_sql_went_bad",reason:"unknown"}),A=new o({status:500,error:"levelDB_went_went_bad",reason:"unknown"}),O=new o({status:403,error:"forbidden",reason:"Forbidden by design doc validate_doc_update function"}),T=new o({status:400,error:"bad_request",reason:"Invalid rev format"}),C=new o({status:412,error:"file_exists",reason:"The database could not be created, the file already exists."}),B=new o({status:412,error:"missing_stub"}),R=new o({status:413,error:"invalid_url",reason:"Provided URL is invalid"}),L=[u,c,f,l,d,p,h,y,m,v,g,b,w,_,E,j,S,A,O,T,C,B,x,R],I=function(e,t,n){var r=L.filter(function(n){return n[e]===t});return n&&r.filter(function(e){return e.message===n})[0]||r[0]};n.UNAUTHORIZED=u,n.MISSING_BULK_DOCS=c,n.MISSING_DOC=f,n.REV_CONFLICT=l,n.INVALID_ID=d,n.MISSING_ID=p,n.RESERVED_ID=h,n.NOT_OPEN=y,n.UNKNOWN_ERROR=m,n.BAD_ARG=v,n.INVALID_REQUEST=g,n.QUERY_PARSE_ERROR=b,n.DOC_VALIDATION=w,n.BAD_REQUEST=_,n.NOT_AN_OBJECT=E,n.DB_MISSING=j,n.WSQ_ERROR=S,n.LDB_ERROR=A,n.FORBIDDEN=O,n.INVALID_REV=T,n.FILE_EXISTS=C,n.MISSING_STUB=B,n.IDB_ERROR=x,n.INVALID_URL=R,n.getErrorTypeByProp=I,n.createError=s,n.generateErrorFromResponse=i},{inherits:9}],15:[function(e,t,n){"use strict";function r(e){return null===e?String(e):"object"==typeof e||"function"==typeof e?c[p.call(e)]||"object":typeof e}function o(e){return null!==e&&e===e.window}function s(e){if(!e||"object"!==r(e)||e.nodeType||o(e))return!1;try{if(e.constructor&&!h.call(e,"constructor")&&!h.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(t){return!1}var n;for(n in e);return void 0===n||h.call(e,n)}function i(e){return"function"===r(e)}function a(){for(var e=[],t=-1,n=arguments.length,r=new Array(n);++t<n;)r[t]=arguments[t];var o={};e.push({args:r,result:{container:o,key:"key"}});for(var s;s=e.pop();)u(e,s.args,s.result);return o.key}function u(e,t,n){var r,o,a,u,c,f,l,d=t[0]||{},p=1,h=t.length,m=!1,v=/\d+/;for("boolean"==typeof d&&(m=d,d=t[1]||{},p=2),"object"==typeof d||i(d)||(d={}),h===p&&(d=this,--p);h>p;p++)if(null!=(r=t[p])){l=y(r);for(o in r)if(!(o in Object.prototype)){if(l&&!v.test(o))continue;if(a=d[o],u=r[o],d===u)continue;m&&u&&(s(u)||(c=y(u)))?(c?(c=!1,f=a&&y(a)?a:[]):f=a&&s(a)?a:{},e.push({args:[m,f,u],result:{container:d,key:o}})):void 0!==u&&(y(r)&&i(u)||(d[o]=u))}}n.container[n.key]=d}for(var c={},f=["Boolean","Number","String","Function","Array","Date","RegExp","Object","Error"],l=0;l<f.length;l++){var d=f[l];c["[object "+d+"]"]=d.toLowerCase()}var p=c.toString,h=c.hasOwnProperty,y=Array.isArray||function(e){return"array"===r(e)};t.exports=a},{}],16:[function(e,t,n){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e["default"]:e}var o=r(e("lie")),s="function"==typeof Promise?Promise:o;t.exports=s},{lie:17}],17:[function(e,t,n){"use strict";function r(){}function o(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=g,this.queue=[],this.outcome=void 0,e!==r&&u(this,e)}function s(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}function i(e,t,n){h(function(){var r;try{r=t(n)}catch(o){return y.reject(e,o)}r===e?y.reject(e,new TypeError("Cannot resolve promise with itself")):y.resolve(e,r)})}function a(e){var t=e&&e.then;return e&&"object"==typeof e&&"function"==typeof t?function(){t.apply(e,arguments)}:void 0}function u(e,t){function n(t){s||(s=!0,y.reject(e,t))}function r(t){s||(s=!0,y.resolve(e,t))}function o(){t(r,n)}var s=!1,i=c(o);"error"===i.status&&n(i.value)}function c(e,t){var n={};try{n.value=e(t),n.status="success"}catch(r){n.status="error",n.value=r}return n}function f(e){return e instanceof this?e:y.resolve(new this(r),e)}function l(e){var t=new this(r);return y.reject(t,e)}function d(e){function t(e,t){function r(e){i[t]=e,++a!==o||s||(s=!0,y.resolve(c,i))}n.resolve(e).then(r,function(e){s||(s=!0,y.reject(c,e))})}var n=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var o=e.length,s=!1;if(!o)return this.resolve([]);for(var i=new Array(o),a=0,u=-1,c=new this(r);++u<o;)t(e[u],u);return c}function p(e){function t(e){n.resolve(e).then(function(e){s||(s=!0,y.resolve(a,e))},function(e){s||(s=!0,y.reject(a,e))})}var n=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var o=e.length,s=!1;if(!o)return this.resolve([]);for(var i=-1,a=new this(r);++i<o;)t(e[i]);return a}var h=e("immediate"),y={},m=["REJECTED"],v=["FULFILLED"],g=["PENDING"];t.exports=o,o.prototype["catch"]=function(e){return this.then(null,e)},o.prototype.then=function(e,t){if("function"!=typeof e&&this.state===v||"function"!=typeof t&&this.state===m)return this;var n=new this.constructor(r);if(this.state!==g){var o=this.state===v?e:t;i(n,o,this.outcome)}else this.queue.push(new s(n,e,t));return n},s.prototype.callFulfilled=function(e){y.resolve(this.promise,e)},s.prototype.otherCallFulfilled=function(e){i(this.promise,this.onFulfilled,e)},s.prototype.callRejected=function(e){y.reject(this.promise,e)},s.prototype.otherCallRejected=function(e){i(this.promise,this.onRejected,e)},y.resolve=function(e,t){var n=c(a,t);if("error"===n.status)return y.reject(e,n.value);var r=n.value;if(r)u(e,r);else{e.state=v,e.outcome=t;for(var o=-1,s=e.queue.length;++o<s;)e.queue[o].callFulfilled(t)}return e},y.reject=function(e,t){e.state=m,e.outcome=t;for(var n=-1,r=e.queue.length;++n<r;)e.queue[n].callRejected(t);return e},o.resolve=f,o.reject=l,o.all=d,o.race=p},{immediate:8}],18:[function(e,t,n){(function(t){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e["default"]:e}function o(e){return e instanceof ArrayBuffer||"undefined"!=typeof Blob&&e instanceof Blob}function s(e){if("function"==typeof e.slice)return e.slice(0);var t=new ArrayBuffer(e.byteLength),n=new Uint8Array(t),r=new Uint8Array(e);return n.set(r),t}function i(e){if(e instanceof ArrayBuffer)return s(e);var t=e.size,n=e.type;return"function"==typeof e.slice?e.slice(0,t,n):e.webkitSlice(0,t,n)}function a(e){var t=Object.getPrototypeOf(e);if(null===t)return!0;var n=t.constructor;return"function"==typeof n&&n instanceof n&&Y.call(n)==$}function u(e){var t,n,r;if(!e||"object"!=typeof e)return e;if(Array.isArray(e)){for(t=[],n=0,r=e.length;r>n;n++)t[n]=u(e[n]);return t}if(e instanceof Date)return e.toISOString();if(o(e))return i(e);if(!a(e))return e;t={};for(n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var s=u(e[n]);"undefined"!=typeof s&&(t[n]=s)}return t}function c(e){var t=!1;return G(function(n){if(t)throw new Error("once called more than once");t=!0,e.apply(this,n)})}function f(e){return G(function(n){n=u(n);var r,o=this,s="function"==typeof n[n.length-1]?n.pop():!1;s&&(r=function(e,n){t.nextTick(function(){s(e,n)})});var i=new F(function(t,r){var s;try{var i=c(function(e,n){e?r(e):t(n)});n.push(i),s=e.apply(o,n),s&&"function"==typeof s.then&&t(s)}catch(a){r(a)}});return r&&i.then(function(e){r(null,e)},r),i})}function l(e,t){function n(e,t,n){if(H.enabled){for(var r=[e._db_name,t],o=0;o<n.length-1;o++)r.push(n[o]);H.apply(null,r);var s=n[n.length-1];n[n.length-1]=function(n,r){var o=[e._db_name,t];o=o.concat(n?["error",n]:["success",r]),H.apply(null,o),s(n,r)}}}return f(G(function(r){if(this._closed)return F.reject(new Error("database is closed"));if(this._destroyed)return F.reject(new Error("database is destroyed"));
var o=this;return n(o,e,r),this.taskqueue.isReady?t.apply(this,r):new F(function(t,n){o.taskqueue.addTask(function(s){s?n(s):t(o[e].apply(o,r))})})}))}function d(e,t){for(var n={},r=0,o=t.length;o>r;r++){var s=t[r];s in e&&(n[s]=e[s])}return n}function p(e){return e}function h(e){return[{ok:e}]}function y(e,t,n){function r(){var e=[];y.forEach(function(t){t.docs.forEach(function(n){e.push({id:t.id,docs:[n]})})}),n(null,{results:e})}function o(){++l===f&&r()}function s(e,t,n){y[e]={id:t,docs:n},o()}function i(){if(!(v>=m.length)){var e=Math.min(v+K,m.length),t=m.slice(v,e);a(t,v),v+=t.length}}function a(n,r){n.forEach(function(n,o){var a=r+o,u=c[n],f=d(u[0],["atts_since","attachments"]);f.open_revs=u.map(function(e){return e.rev}),f.open_revs=f.open_revs.filter(p);var l=p;0===f.open_revs.length&&(delete f.open_revs,l=h),["revs","attachments","binary","ajax"].forEach(function(e){e in t&&(f[e]=t[e])}),e.get(n,f,function(e,t){var r;r=e?[{error:e}]:l(t),s(a,n,r),i()})})}var u=t.docs,c={};u.forEach(function(e){e.id in c?c[e.id].push(e):c[e.id]=[e]});var f=Object.keys(c).length,l=0,y=new Array(f),m=Object.keys(c),v=0;i()}function m(){return"undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage&&"undefined"!=typeof chrome.storage.local}function v(){return q}function g(e){m()?chrome.storage.onChanged.addListener(function(t){null!=t.db_name&&e.emit(t.dbName.newValue)}):v()&&("undefined"!=typeof addEventListener?addEventListener("storage",function(t){e.emit(t.key)}):window.attachEvent("storage",function(t){e.emit(t.key)}))}function b(){V.EventEmitter.call(this),this._listeners={},g(this)}function w(e){if("undefined"!==console&&e in console){var t=Array.prototype.slice.call(arguments,1);console[e].apply(console,t)}}function _(e,t){var n=6e5;e=parseInt(e,10)||0,t=parseInt(t,10),t!==t||e>=t?t=(e||1)<<1:t+=1,t>n&&(e=n>>1,t=n);var r=Math.random(),o=t-e;return~~(o*r+e)}function E(e){var t=0;return e||(t=2e3),_(e,t)}function j(e,t){w("info","The above "+e+" is totally normal. "+t)}function x(e,t){for(var n in t)if(t.hasOwnProperty(n)){var r=u(t[n]);"undefined"!=typeof r&&(e[n]=r)}}function S(e,t,n){return x(e,t),n&&x(e,n),e}function A(e,t,n){try{return!e(t,n)}catch(r){var o="Filter function threw: "+r.toString();return W.createError(W.BAD_REQUEST,o)}}function O(e){var t={},n=e.filter&&"function"==typeof e.filter;return t.query=e.query_params,function(r){r.doc||(r.doc={});var o=n&&A(e.filter,r.doc,t);if("object"==typeof o)return o;if(o)return!1;if(e.include_docs){if(!e.attachments)for(var s in r.doc._attachments)r.doc._attachments.hasOwnProperty(s)&&(r.doc._attachments[s].stub=!0)}else delete r.doc;return!0}}function T(e){for(var t=[],n=0,r=e.length;r>n;n++)t=t.concat(e[n]);return t}function C(){}function B(e){var t;if(e?"string"!=typeof e?t=W.createError(W.INVALID_ID):/^_/.test(e)&&!/^_(design|local)/.test(e)&&(t=W.createError(W.RESERVED_ID)):t=W.createError(W.MISSING_ID),t)throw t}function R(){return"undefined"!=typeof cordova||"undefined"!=typeof PhoneGap||"undefined"!=typeof phonegap}function L(e,t){return"listenerCount"in e?e.listenerCount(t):V.EventEmitter.listenerCount(e,t)}function I(e){if(!e)return null;var t=e.split("/");return 2===t.length?t:1===t.length?[e,e]:null}function k(e){var t=I(e);return t?t.join("/"):null}function U(e){for(var t=oe.exec(e),n={},r=14;r--;){var o=te[r],s=t[r]||"",i=-1!==["user","password"].indexOf(o);n[o]=i?decodeURIComponent(s):s}return n[ne]={},n[te[12]].replace(re,function(e,t,r){t&&(n[ne][t]=r)}),n}function D(e,t,n){return new F(function(r,o){e.get(t,function(s,i){if(s){if(404!==s.status)return o(s);i={}}var a=i._rev,u=n(i);return u?(u._id=t,u._rev=a,void r(N(e,u,n))):r({updated:!1,rev:a})})})}function N(e,t,n){return e.put(t).then(function(e){return{updated:!0,rev:e.rev}},function(r){if(409!==r.status)throw r;return D(e,t._id,n)})}function P(e){return 0|Math.random()*e}function M(e,t){t=t||se.length;var n="",r=-1;if(e){for(;++r<e;)n+=se[P(t)];return n}for(;++r<36;)switch(r){case 8:case 13:case 18:case 23:n+="-";break;case 19:n+=se[3&P(16)|8];break;default:n+=se[P(16)]}return n}Object.defineProperty(n,"__esModule",{value:!0});var q,F=r(e("pouchdb-promise")),G=r(e("argsarray")),J=r(e("debug")),V=e("events"),z=r(e("inherits")),W=e("pouchdb-errors"),Y=Function.prototype.toString,$=Y.call(Object),H=J("pouchdb:api"),K=6;if(m())q=!1;else try{localStorage.setItem("_pouch_check_localstorage",1),q=!!localStorage.getItem("_pouch_check_localstorage")}catch(Q){q=!1}z(b,V.EventEmitter),b.prototype.addListener=function(e,t,n,r){function o(){function e(){i=!1}if(s._listeners[t]){if(i)return void(i="waiting");i=!0;var a=d(r,["style","include_docs","attachments","conflicts","filter","doc_ids","view","since","query_params","binary"]);n.changes(a).on("change",function(e){e.seq>r.since&&!r.cancelled&&(r.since=e.seq,r.onChange(e))}).on("complete",function(){"waiting"===i&&setTimeout(function(){o()},0),i=!1}).on("error",e)}}if(!this._listeners[t]){var s=this,i=!1;this._listeners[t]=o,this.on(e,o)}},b.prototype.removeListener=function(e,t){t in this._listeners&&V.EventEmitter.prototype.removeListener.call(this,e,this._listeners[t])},b.prototype.notifyLocalWindows=function(e){m()?chrome.storage.local.set({dbName:e}):v()&&(localStorage[e]="a"===localStorage[e]?"b":"a")},b.prototype.notify=function(e){this.emit(e),this.notifyLocalWindows(e)};var X,Z=C.name;X=Z?function(e){return e.name}:function(e){return e.toString().match(/^\s*function\s*(\S*)\s*\(/)[1]};var ee=X,te=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],ne="queryKey",re=/(?:^|&)([^&=]*)=?([^&]*)/g,oe=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,se="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split("");n.adapterFun=l,n.bulkGetShim=y,n.changesHandler=b,n.clone=u,n.defaultBackOff=E,n.explainError=j,n.extend=S,n.filterChange=O,n.flatten=T,n.functionName=ee,n.guardedConsole=w,n.hasLocalStorage=v,n.invalidIdError=B,n.isChromeApp=m,n.isCordova=R,n.listenerCount=L,n.normalizeDdocFunctionName=k,n.once=c,n.parseDdocFunctionName=I,n.parseUri=U,n.pick=d,n.toPromise=f,n.upsert=D,n.uuid=M}).call(this,e("/Users/nolan/workspace/pouchdb-authentication/node_modules/process/browser.js"))},{"/Users/nolan/workspace/pouchdb-authentication/node_modules/process/browser.js":19,argsarray:4,debug:5,events:7,inherits:9,"pouchdb-errors":14,"pouchdb-promise":16}],19:[function(e,t,n){function r(){}var o=t.exports={};o.nextTick=function(){var e="undefined"!=typeof window&&window.setImmediate,t="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(e)return function(e){return window.setImmediate(e)};if(t){var n=[];return window.addEventListener("message",function(e){var t=e.source;if((t===window||null===t)&&"process-tick"===e.data&&(e.stopPropagation(),n.length>0)){var r=n.shift();r()}},!0),function(e){n.push(e),window.postMessage("process-tick","*")}}return function(e){setTimeout(e,0)}}(),o.title="browser",o.browser=!0,o.env={},o.argv=[],o.on=r,o.once=r,o.off=r,o.emit=r,o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")}},{}],20:[function(t,n,r){!function(t,r,o){"undefined"!=typeof n&&n.exports?n.exports=o():"function"==typeof e&&e.amd?e(o):r[t]=o()}("urljoin",this,function(){function e(e,t){return e=e.replace(/:\//g,"://"),e=e.replace(/([^:\s])\/+/g,"$1/"),e=e.replace(/\/(\?|&|#[^!])/g,"$1"),e=e.replace(/(\?.+)\?/g,"$1&")}return function(){var t=arguments,n={};"object"==typeof arguments[0]&&(t=arguments[0],n=arguments[1]||{});var r=[].slice.call(t,0).join("/");return e(r,n)}})},{}]},{},[1])(1)});
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.PouchAuthentication=e()}}(function(){var e;return function e(t,n,r){function o(i,a){if(!n[i]){if(!t[i]){var u="function"==typeof require&&require;if(!a&&u)return u(i,!0);if(s)return s(i,!0);var c=new Error("Cannot find module '"+i+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[i]={exports:{}};t[i][0].call(f.exports,function(e){var n=t[i][1][e];return o(n?n:e)},f,f.exports,e,t,n,r)}return n[i].exports}for(var s="function"==typeof require&&require,i=0;i<r.length;i++)o(r[i]);return o}({1:[function(e,t,n){(function(t){"use strict";function r(e){return e.getUrl().replace(/\/[^\/]+\/?$/,"")}var o=e(16),s=e(21);n.getUsersUrl=function(e){return s(r(e),"/_users")},n.getSessionUrl=function(e){return s(r(e),"/_session")},n.once=function(e){var t=!1;return n.getArguments(function(n){if(t)throw console.trace(),new Error("once called more than once");t=!0,e.apply(this,n)})},n.getArguments=function(e){return function(){for(var t=arguments.length,n=new Array(t),r=-1;++r<t;)n[r]=arguments[r];return e.call(this,n)}},n.toPromise=function(e){return n.getArguments(function(r){var s,i=this,a="function"==typeof r[r.length-1]&&r.pop();a&&(s=function(e,n){t.nextTick(function(){a(e,n)})});var u=new o(function(t,o){try{var s=n.once(function(e,n){e?o(e):t(n)});r.push(s),e.apply(i,r)}catch(e){o(e)}});return s&&u.then(function(e){s(null,e)},s),u.cancel=function(){return this},u})},n.inherits=e(7),n.extend=e(15),n.ajax=e(11),n.clone=function(e){return n.extend(!0,{},e)},n.uuid=e(17).uuid,n.Promise=o}).call(this,e(20))},{11:11,15:15,16:16,17:17,20:20,21:21,7:7}],2:[function(e,t,n){"use strict";function r(e){return function(){var t=arguments.length;if(t){for(var n=[],r=-1;++r<t;)n[r]=arguments[r];return e.call(this,n)}return e.call(this,[])}}t.exports=r},{}],3:[function(e,t,n){function r(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31}function o(){var e=arguments,t=this.useColors;if(e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+n.humanize(this.diff),!t)return e;var r="color: "+this.color;e=[e[0],r,"color: inherit"].concat(Array.prototype.slice.call(e,1));var o=0,s=0;return e[0].replace(/%[a-z%]/g,function(e){"%%"!==e&&(o++,"%c"===e&&(s=o))}),e.splice(s,0,r),e}function s(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function i(e){try{null==e?n.storage.removeItem("debug"):n.storage.debug=e}catch(e){}}function a(){var e;try{e=n.storage.debug}catch(e){}return e}function u(){try{return window.localStorage}catch(e){}}n=t.exports=e(4),n.log=s,n.formatArgs=o,n.save=i,n.load=a,n.useColors=r,n.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:u(),n.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],n.formatters.j=function(e){return JSON.stringify(e)},n.enable(a())},{4:4}],4:[function(e,t,n){function r(){return n.colors[f++%n.colors.length]}function o(e){function t(){}function o(){var e=o,t=+new Date,s=t-(c||t);e.diff=s,e.prev=c,e.curr=t,c=t,null==e.useColors&&(e.useColors=n.useColors()),null==e.color&&e.useColors&&(e.color=r());var i=Array.prototype.slice.call(arguments);i[0]=n.coerce(i[0]),"string"!=typeof i[0]&&(i=["%o"].concat(i));var a=0;i[0]=i[0].replace(/%([a-z%])/g,function(t,r){if("%%"===t)return t;a++;var o=n.formatters[r];if("function"==typeof o){var s=i[a];t=o.call(e,s),i.splice(a,1),a--}return t}),"function"==typeof n.formatArgs&&(i=n.formatArgs.apply(e,i));var u=o.log||n.log||console.log.bind(console);u.apply(e,i)}t.enabled=!1,o.enabled=!0;var s=n.enabled(e)?o:t;return s.namespace=e,s}function s(e){n.save(e);for(var t=(e||"").split(/[\s,]+/),r=t.length,o=0;o<r;o++)t[o]&&(e=t[o].replace(/\*/g,".*?"),"-"===e[0]?n.skips.push(new RegExp("^"+e.substr(1)+"$")):n.names.push(new RegExp("^"+e+"$")))}function i(){n.enable("")}function a(e){var t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1}function u(e){return e instanceof Error?e.stack||e.message:e}n=t.exports=o,n.coerce=u,n.disable=i,n.enable=s,n.enabled=a,n.humanize=e(10),n.names=[],n.skips=[],n.formatters={};var c,f=0},{10:10}],5:[function(e,t,n){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function o(e){return"function"==typeof e}function s(e){return"number"==typeof e}function i(e){return"object"==typeof e&&null!==e}function a(e){return void 0===e}t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if(!s(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,n,r,s,u,c;if(this._events||(this._events={}),"error"===e&&(!this._events.error||i(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t;var f=new Error('Uncaught, unspecified "error" event. ('+t+")");throw f.context=t,f}if(n=this._events[e],a(n))return!1;if(o(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:s=Array.prototype.slice.call(arguments,1),n.apply(this,s)}else if(i(n))for(s=Array.prototype.slice.call(arguments,1),c=n.slice(),r=c.length,u=0;u<r;u++)c[u].apply(this,s);return!0},r.prototype.addListener=function(e,t){var n;if(!o(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,o(t.listener)?t.listener:t),this._events[e]?i(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,i(this._events[e])&&!this._events[e].warned&&(n=a(this._maxListeners)?r.defaultMaxListeners:this._maxListeners,n&&n>0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}if(!o(t))throw TypeError("listener must be a function");var r=!1;return n.listener=t,this.on(e,n),this},r.prototype.removeListener=function(e,t){var n,r,s,a;if(!o(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],s=n.length,r=-1,n===t||o(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(i(n)){for(a=s;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){r=a;break}if(r<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],o(n))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?o(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(o(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},{}],6:[function(e,t,n){(function(e){"use strict";function n(){f=!0;for(var e,t,n=l.length;n;){for(t=l,l=[],e=-1;++e<n;)t[e]();n=l.length}f=!1}function r(e){1!==l.push(e)||f||o()}var o,s=e.MutationObserver||e.WebKitMutationObserver;if(s){var i=0,a=new s(n),u=e.document.createTextNode("");a.observe(u,{characterData:!0}),o=function(){u.data=i=++i%2}}else if(e.setImmediate||"undefined"==typeof e.MessageChannel)o="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){n(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(n,0)};else{var c=new e.MessageChannel;c.port1.onmessage=n,o=function(){c.port2.postMessage(0)}}var f,l=[];t.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],7:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],8:[function(e,t,n){(function(e){e("object"==typeof n?n:this)}).call(this,function(e){var t=Array.prototype.slice,n=Array.prototype.forEach,r=function(e){if("object"!=typeof e)throw e+" is not an object";var o=t.call(arguments,1);return n.call(o,function(t){if(t)for(var n in t)"object"==typeof t[n]&&e[n]?r.call(e,e[n],t[n]):e[n]=t[n]}),e};e.extend=r})},{}],9:[function(e,t,n){"use strict";function r(){}function o(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=g,this.queue=[],this.outcome=void 0,e!==r&&u(this,e)}function s(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}function i(e,t,n){h(function(){var r;try{r=t(n)}catch(t){return y.reject(e,t)}r===e?y.reject(e,new TypeError("Cannot resolve promise with itself")):y.resolve(e,r)})}function a(e){var t=e&&e.then;if(e&&"object"==typeof e&&"function"==typeof t)return function(){t.apply(e,arguments)}}function u(e,t){function n(t){s||(s=!0,y.reject(e,t))}function r(t){s||(s=!0,y.resolve(e,t))}function o(){t(r,n)}var s=!1,i=c(o);"error"===i.status&&n(i.value)}function c(e,t){var n={};try{n.value=e(t),n.status="success"}catch(e){n.status="error",n.value=e}return n}function f(e){return e instanceof this?e:y.resolve(new this(r),e)}function l(e){var t=new this(r);return y.reject(t,e)}function d(e){function t(e,t){function r(e){i[t]=e,++a!==o||s||(s=!0,y.resolve(c,i))}n.resolve(e).then(r,function(e){s||(s=!0,y.reject(c,e))})}var n=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var o=e.length,s=!1;if(!o)return this.resolve([]);for(var i=new Array(o),a=0,u=-1,c=new this(r);++u<o;)t(e[u],u);return c}function p(e){function t(e){n.resolve(e).then(function(e){s||(s=!0,y.resolve(a,e))},function(e){s||(s=!0,y.reject(a,e))})}var n=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var o=e.length,s=!1;if(!o)return this.resolve([]);for(var i=-1,a=new this(r);++i<o;)t(e[i]);return a}var h=e(6),y={},v=["REJECTED"],m=["FULFILLED"],g=["PENDING"];t.exports=o,o.prototype.catch=function(e){return this.then(null,e)},o.prototype.then=function(e,t){if("function"!=typeof e&&this.state===m||"function"!=typeof t&&this.state===v)return this;var n=new this.constructor(r);if(this.state!==g){var o=this.state===m?e:t;i(n,o,this.outcome)}else this.queue.push(new s(n,e,t));return n},s.prototype.callFulfilled=function(e){y.resolve(this.promise,e)},s.prototype.otherCallFulfilled=function(e){i(this.promise,this.onFulfilled,e)},s.prototype.callRejected=function(e){y.reject(this.promise,e)},s.prototype.otherCallRejected=function(e){i(this.promise,this.onRejected,e)},y.resolve=function(e,t){var n=c(a,t);if("error"===n.status)return y.reject(e,n.value);var r=n.value;if(r)u(e,r);else{e.state=m,e.outcome=t;for(var o=-1,s=e.queue.length;++o<s;)e.queue[o].callFulfilled(t)}return e},y.reject=function(e,t){e.state=v,e.outcome=t;for(var n=-1,r=e.queue.length;++n<r;)e.queue[n].callRejected(t);return e},o.resolve=f,o.reject=l,o.all=d,o.race=p},{6:6}],10:[function(e,t,n){function r(e){if(e=""+e,!(e.length>1e4)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]),r=(t[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return n*l;case"days":case"day":case"d":return n*f;case"hours":case"hour":case"hrs":case"hr":case"h":return n*c;case"minutes":case"minute":case"mins":case"min":case"m":return n*u;case"seconds":case"second":case"secs":case"sec":case"s":return n*a;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n}}}}function o(e){return e>=f?Math.round(e/f)+"d":e>=c?Math.round(e/c)+"h":e>=u?Math.round(e/u)+"m":e>=a?Math.round(e/a)+"s":e+"ms"}function s(e){return i(e,f,"day")||i(e,c,"hour")||i(e,u,"minute")||i(e,a,"second")||e+" ms"}function i(e,t,n){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}var a=1e3,u=60*a,c=60*u,f=24*c,l=365.25*f;t.exports=function(e,t){return t=t||{},"string"==typeof e?r(e):t.long?s(e):o(e)}},{}],11:[function(e,t,n){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e.default:e}function o(){for(var e={},t=new p(function(t,n){e.resolve=t,e.reject=n}),n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.promise=t,p.resolve().then(function(){return fetch.apply(null,n)}).then(function(t){e.resolve(t)}).catch(function(t){e.reject(t)}),e}function s(e,t){var n,r,s,i=new Headers,a={method:e.method,credentials:"include",headers:i};return e.json&&(i.set("Accept","application/json"),i.set("Content-Type",e.headers["Content-Type"]||"application/json")),e.body&&e.body instanceof Blob?d.readAsArrayBuffer(e.body,function(e){a.body=e}):e.body&&e.processData&&"string"!=typeof e.body?a.body=JSON.stringify(e.body):"body"in e?a.body=e.body:a.body=null,Object.keys(e.headers).forEach(function(t){e.headers.hasOwnProperty(t)&&i.set(t,e.headers[t])}),n=o(e.url,a),e.timeout>0&&(r=setTimeout(function(){n.reject(new Error("Load timeout for resource: "+e.url))},e.timeout)),n.promise.then(function(t){return s={statusCode:t.status},e.timeout>0&&clearTimeout(r),s.statusCode>=200&&s.statusCode<300?e.binary?t.blob():t.text():t.json()}).then(function(e){s.statusCode>=200&&s.statusCode<300?t(null,s,e):t(e,s)}).catch(function(e){t(e,s)}),{abort:n.reject}}function i(e,t){var n,r,o=!1,s=function(){n.abort()},i=function(){o=!0,n.abort()};n=e.xhr?new e.xhr:new XMLHttpRequest;try{n.open(e.method,e.url)}catch(e){t(e,{statusCode:413})}n.withCredentials=!("withCredentials"in e)||e.withCredentials,"GET"===e.method?delete e.headers["Content-Type"]:e.json&&(e.headers.Accept="application/json",e.headers["Content-Type"]=e.headers["Content-Type"]||"application/json",e.body&&e.processData&&"string"!=typeof e.body&&(e.body=JSON.stringify(e.body))),e.binary&&(n.responseType="arraybuffer"),"body"in e||(e.body=null);for(var a in e.headers)e.headers.hasOwnProperty(a)&&n.setRequestHeader(a,e.headers[a]);return e.timeout>0&&(r=setTimeout(i,e.timeout),n.onprogress=function(){clearTimeout(r),4!==n.readyState&&(r=setTimeout(i,e.timeout))},"undefined"!=typeof n.upload&&(n.upload.onprogress=n.onprogress)),n.onreadystatechange=function(){if(4===n.readyState){var r={statusCode:n.status};if(n.status>=200&&n.status<300){var s;s=e.binary?d.blob([n.response||""],{type:n.getResponseHeader("Content-Type")}):n.responseText,t(null,r,s)}else{var i={};if(o)i=new Error("ETIMEDOUT"),r.statusCode=400;else try{i=JSON.parse(n.response)}catch(e){}t(i,r)}}},e.body&&e.body instanceof Blob?d.readAsArrayBuffer(e.body,function(e){n.send(e)}):n.send(e.body),{abort:s}}function a(){try{return new XMLHttpRequest,!0}catch(e){return!1}}function u(e,t){return m||e.xhr?i(e,t):s(e,t)}function c(){return""}function f(e,t){function n(t,n,r){if(!e.binary&&e.json&&"string"==typeof t)try{t=JSON.parse(t)}catch(e){return r(e)}Array.isArray(t)&&(t=t.map(function(e){return e.error||e.missing?y.generateErrorFromResponse(e):e})),e.binary&&g(t,n),r(null,t,n)}function r(e,t){var n,r;if(e.code&&e.status){var o=new Error(e.message||e.code);return o.status=e.status,t(o)}if(e.message&&"ETIMEDOUT"===e.message)return t(e);try{n=JSON.parse(e.responseText),r=y.generateErrorFromResponse(n)}catch(t){r=y.generateErrorFromResponse(e)}t(r)}e=v.clone(e);var o={method:"GET",headers:{},json:!0,processData:!0,timeout:1e4,cache:!1};return e=h.extend(o,e),e.json&&(e.binary||(e.headers.Accept="application/json"),e.headers["Content-Type"]=e.headers["Content-Type"]||"application/json"),e.binary&&(e.encoding=null,e.json=!1),e.processData||(e.json=!1),u(e,function(o,s,i){if(o)return o.status=s?s.statusCode:400,r(o,t);var a,u=s.headers&&s.headers["content-type"],f=i||c();if(!e.binary&&(e.json||!e.processData)&&"object"!=typeof f&&(/json/.test(u)||/^[\s]*\{/.test(f)&&/\}[\s]*$/.test(f)))try{f=JSON.parse(f.toString())}catch(e){}s.statusCode>=200&&s.statusCode<300?n(f,s,t):(a=y.generateErrorFromResponse(f),a.status=s.statusCode,t(a))})}function l(e,t){var n=navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",r=n.indexOf("safari")!==-1&&n.indexOf("chrome")===-1,o=n.indexOf("msie")!==-1,s=n.indexOf("edge")!==-1,i=r||(o||s)&&"GET"===e.method,a=!("cache"in e)||e.cache,u=/^blob:/.test(e.url);if(!u&&(i||!a)){var c=e.url.indexOf("?")!==-1;e.url+=(c?"&":"?")+"_nonce="+Date.now()}return f(e,t)}var d=e(13),p=r(e(16)),h=e(8),y=e(14),v=e(12),m=a(),g=function(){};t.exports=l},{12:12,13:13,14:14,16:16,8:8}],12:[function(e,t,n){(function(t){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e.default:e}function o(e){return e instanceof ArrayBuffer||"undefined"!=typeof Blob&&e instanceof Blob}function s(e){if("function"==typeof e.slice)return e.slice(0);var t=new ArrayBuffer(e.byteLength),n=new Uint8Array(t),r=new Uint8Array(e);return n.set(r),t}function i(e){if(e instanceof ArrayBuffer)return s(e);var t=e.size,n=e.type;return"function"==typeof e.slice?e.slice(0,t,n):e.webkitSlice(0,t,n)}function a(e){var t=Object.getPrototypeOf(e);if(null===t)return!0;var n=t.constructor;return"function"==typeof n&&n instanceof n&&Q.call(n)==Y}function u(e){var t,n,r;if(!e||"object"!=typeof e)return e;if(Array.isArray(e)){for(t=[],n=0,r=e.length;n<r;n++)t[n]=u(e[n]);return t}if(e instanceof Date)return e.toISOString();if(o(e))return i(e);if(!a(e))return e;t={};for(n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var s=u(e[n]);"undefined"!=typeof s&&(t[n]=s)}return t}function c(e){var t=!1;return G(function(n){if(t)throw new Error("once called more than once");t=!0,e.apply(this,n)})}function f(e){return G(function(n){n=u(n);var r,o=this,s="function"==typeof n[n.length-1]&&n.pop();s&&(r=function(e,n){t.nextTick(function(){s(e,n)})});var i=new F(function(t,r){var s;try{var i=c(function(e,n){e?r(e):t(n)});n.push(i),s=e.apply(o,n),s&&"function"==typeof s.then&&t(s)}catch(e){r(e)}});return r&&i.then(function(e){r(null,e)},r),i})}function l(e,t){function n(e,t,n){if($.enabled){for(var r=[e._db_name,t],o=0;o<n.length-1;o++)r.push(n[o]);$.apply(null,r);var s=n[n.length-1];n[n.length-1]=function(n,r){var o=[e._db_name,t];o=o.concat(n?["error",n]:["success",r]),$.apply(null,o),s(n,r)}}}return f(G(function(r){if(this._closed)return F.reject(new Error("database is closed"));if(this._destroyed)return F.reject(new Error("database is destroyed"));var o=this;return n(o,e,r),this.taskqueue.isReady?t.apply(this,r):new F(function(t,n){o.taskqueue.addTask(function(s){s?n(s):t(o[e].apply(o,r))})})}))}function d(e,t){for(var n={},r=0,o=t.length;r<o;r++){var s=t[r];s in e&&(n[s]=e[s])}return n}function p(e){return e}function h(e){return[{ok:e}]}function y(e,t,n){function r(){var e=[];y.forEach(function(t){t.docs.forEach(function(n){e.push({id:t.id,docs:[n]})})}),n(null,{results:e})}function o(){++l===f&&r()}function s(e,t,n){y[e]={id:t,docs:n},o()}function i(){if(!(m>=v.length)){var e=Math.min(m+H,v.length),t=v.slice(m,e);a(t,m),m+=t.length}}function a(n,r){n.forEach(function(n,o){var a=r+o,u=c[n],f=d(u[0],["atts_since","attachments"]);f.open_revs=u.map(function(e){return e.rev}),f.open_revs=f.open_revs.filter(p);var l=p;0===f.open_revs.length&&(delete f.open_revs,l=h),["revs","attachments","binary","ajax"].forEach(function(e){e in t&&(f[e]=t[e])}),e.get(n,f,function(e,t){var r;r=e?[{error:e}]:l(t),s(a,n,r),i()})})}var u=t.docs,c={};u.forEach(function(e){e.id in c?c[e.id].push(e):c[e.id]=[e]});var f=Object.keys(c).length,l=0,y=new Array(f),v=Object.keys(c),m=0;i()}function v(){return"undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage&&"undefined"!=typeof chrome.storage.local}function m(){return M}function g(e){v()?chrome.storage.onChanged.addListener(function(t){null!=t.db_name&&e.emit(t.dbName.newValue)}):m()&&("undefined"!=typeof addEventListener?addEventListener("storage",function(t){e.emit(t.key)}):window.attachEvent("storage",function(t){e.emit(t.key)}))}function w(){J.EventEmitter.call(this),this._listeners={},g(this)}function b(e){if("undefined"!==console&&e in console){var t=Array.prototype.slice.call(arguments,1);console[e].apply(console,t)}}function _(e,t){var n=6e5;e=parseInt(e,10)||0,t=parseInt(t,10),t!==t||t<=e?t=(e||1)<<1:t+=1,t>n&&(e=n>>1,t=n);var r=Math.random(),o=t-e;return~~(o*r+e)}function E(e){var t=0;return e||(t=2e3),_(e,t)}function S(e,t){b("info","The above "+e+" is totally normal. "+t)}function j(e,t){for(var n in t)if(t.hasOwnProperty(n)){var r=u(t[n]);"undefined"!=typeof r&&(e[n]=r)}}function x(e,t,n){return j(e,t),n&&j(e,n),e}function O(e,t,n){try{return!e(t,n)}catch(e){var r="Filter function threw: "+e.toString();return W.createError(W.BAD_REQUEST,r)}}function R(e){var t={},n=e.filter&&"function"==typeof e.filter;return t.query=e.query_params,function(r){r.doc||(r.doc={});var o=n&&O(e.filter,r.doc,t);if("object"==typeof o)return o;if(o)return!1;if(e.include_docs){if(!e.attachments)for(var s in r.doc._attachments)r.doc._attachments.hasOwnProperty(s)&&(r.doc._attachments[s].stub=!0)}else delete r.doc;return!0}}function A(e){for(var t=[],n=0,r=e.length;n<r;n++)t=t.concat(e[n]);return t}function T(){}function I(e){var t;if(e?"string"!=typeof e?t=W.createError(W.INVALID_ID):/^_/.test(e)&&!/^_(design|local)/.test(e)&&(t=W.createError(W.RESERVED_ID)):t=W.createError(W.MISSING_ID),t)throw t}function D(){return"undefined"!=typeof cordova||"undefined"!=typeof PhoneGap||"undefined"!=typeof phonegap}function C(e,t){return"listenerCount"in e?e.listenerCount(t):J.EventEmitter.listenerCount(e,t)}function B(e){if(!e)return null;var t=e.split("/");return 2===t.length?t:1===t.length?[e,e]:null}function L(e){var t=B(e);return t?t.join("/"):null}function N(e){for(var t=re.exec(e),n={},r=14;r--;){var o=ee[r],s=t[r]||"",i=["user","password"].indexOf(o)!==-1;n[o]=i?decodeURIComponent(s):s}return n[te]={},n[ee[12]].replace(ne,function(e,t,r){t&&(n[te][t]=r)}),n}function U(e,t,n){return new F(function(r,o){e.get(t,function(s,i){if(s){if(404!==s.status)return o(s);i={}}var a=i._rev,u=n(i);return u?(u._id=t,u._rev=a,void r(k(e,u,n))):r({updated:!1,rev:a})})})}function k(e,t,n){return e.put(t).then(function(e){return{updated:!0,rev:e.rev}},function(r){if(409!==r.status)throw r;return U(e,t._id,n)})}function q(e){return 0|Math.random()*e}function P(e,t){t=t||oe.length;var n="",r=-1;if(e){for(;++r<e;)n+=oe[q(t)];return n}for(;++r<36;)switch(r){case 8:case 13:case 18:case 23:n+="-";break;case 19:n+=oe[3&q(16)|8];break;default:n+=oe[q(16)]}return n}Object.defineProperty(n,"__esModule",{value:!0});var M,F=r(e(16)),G=r(e(2)),V=r(e(3)),J=e(5),z=r(e(7)),W=e(14),Q=Function.prototype.toString,Y=Q.call(Object),$=V("pouchdb:api"),H=6;if(v())M=!1;else try{localStorage.setItem("_pouch_check_localstorage",1),M=!!localStorage.getItem("_pouch_check_localstorage")}catch(e){M=!1}z(w,J.EventEmitter),w.prototype.addListener=function(e,t,n,r){function o(){function e(){i=!1}if(s._listeners[t]){if(i)return void(i="waiting");i=!0;var a=d(r,["style","include_docs","attachments","conflicts","filter","doc_ids","view","since","query_params","binary"]);n.changes(a).on("change",function(e){e.seq>r.since&&!r.cancelled&&(r.since=e.seq,r.onChange(e))}).on("complete",function(){"waiting"===i&&setTimeout(function(){o()},0),i=!1}).on("error",e)}}if(!this._listeners[t]){var s=this,i=!1;this._listeners[t]=o,this.on(e,o)}},w.prototype.removeListener=function(e,t){t in this._listeners&&J.EventEmitter.prototype.removeListener.call(this,e,this._listeners[t])},w.prototype.notifyLocalWindows=function(e){v()?chrome.storage.local.set({dbName:e}):m()&&(localStorage[e]="a"===localStorage[e]?"b":"a")},w.prototype.notify=function(e){this.emit(e),this.notifyLocalWindows(e)};var K,X=T.name;K=X?function(e){return e.name}:function(e){return e.toString().match(/^\s*function\s*(\S*)\s*\(/)[1]};var Z=K,ee=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],te="queryKey",ne=/(?:^|&)([^&=]*)=?([^&]*)/g,re=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,oe="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split("");n.adapterFun=l,n.bulkGetShim=y,n.changesHandler=w,n.clone=u,n.defaultBackOff=E,n.explainError=S,n.extend=x,n.filterChange=R,n.flatten=A,n.functionName=Z,n.guardedConsole=b,n.hasLocalStorage=m,n.invalidIdError=I,n.isChromeApp=v,n.isCordova=D,n.listenerCount=C,n.normalizeDdocFunctionName=L,n.once=c,n.parseDdocFunctionName=B,n.parseUri=N,n.pick=d,n.toPromise=f,n.upsert=U,n.uuid=P}).call(this,e(20))},{14:14,16:16,2:2,20:20,3:3,5:5,7:7}],13:[function(e,t,n){"use strict";function r(e){for(var t="",n=new Uint8Array(e),r=n.byteLength,o=0;o<r;o++)t+=String.fromCharCode(n[o]);return t}function o(e){return h(r(e))}function s(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(s){if("TypeError"!==s.name)throw s;for(var n="undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder,r=new n,o=0;o<e.length;o+=1)r.append(e[o]);return r.getBlob(t.type)}}function i(e){for(var t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n),o=0;o<t;o++)r[o]=e.charCodeAt(o);return n}function a(e,t){return s([i(e)],{type:t})}function u(e,t){return a(p(e),t)}function c(e,t){if("undefined"==typeof FileReader)return t(r((new FileReaderSync).readAsArrayBuffer(e)));var n=new FileReader,o="function"==typeof n.readAsBinaryString;n.onloadend=function(e){var n=e.target.result||"";return o?t(n):void t(r(n))},o?n.readAsBinaryString(e):n.readAsArrayBuffer(e)}function f(e,t){c(e,function(e){t(h(e))})}function l(e,t){if("undefined"==typeof FileReader)return t((new FileReaderSync).readAsArrayBuffer(e));var n=new FileReader;n.onloadend=function(e){var n=e.target.result||new ArrayBuffer(0);t(n)},n.readAsArrayBuffer(e)}function d(){}Object.defineProperty(n,"__esModule",{value:!0});var p=function(e){return atob(e)},h=function(e){return btoa(e)};n.arrayBufferToBase64=o,n.arrayBufferToBinaryString=r,n.atob=p,n.btoa=h,n.base64StringToBlobOrBuffer=u,n.binaryStringToArrayBuffer=i,n.binaryStringToBlobOrBuffer=a,n.blob=s,n.blobOrBufferToBase64=f,n.readAsArrayBuffer=l,n.readAsBinaryString=c,n.typedBuffer=d},{}],14:[function(e,t,n){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e.default:e}function o(e){Error.call(this,e.reason),this.status=e.status,this.name=e.error,this.message=e.reason,this.error=!0}function s(e,t,n){function r(t){for(var r in e)"function"!=typeof e[r]&&(this[r]=e[r]);void 0!==n&&(this.name=n),void 0!==t&&(this.reason=t)}return r.prototype=o.prototype,new r(t)}function i(e){var t,n,r,o,i;return n=e.error===!0&&"string"==typeof e.name?e.name:e.error,i=e.reason,r=B("name",n,i),e.missing||"missing"===i||"deleted"===i||"not_found"===n?r=f:"doc_validation"===n?(r=b,o=i):"bad_request"===n&&r.message!==i&&(r=_),r||(r=B("status",e.status,i)||v),t=s(r,i,n),o&&(t.message=o),e.id&&(t.id=e.id),e.status&&(t.status=e.status),e.missing&&(t.missing=e.missing),t}Object.defineProperty(n,"__esModule",{value:!0});var a=r(e(7));a(o,Error),o.prototype.toString=function(){return JSON.stringify({status:this.status,name:this.name,message:this.message,reason:this.reason})};var u=new o({status:401,error:"unauthorized",reason:"Name or password is incorrect."}),c=new o({status:400,error:"bad_request",reason:"Missing JSON list of 'docs'"}),f=new o({status:404,error:"not_found",reason:"missing"}),l=new o({status:409,error:"conflict",reason:"Document update conflict"}),d=new o({status:400,error:"invalid_id",reason:"_id field must contain a string"}),p=new o({status:412,error:"missing_id",reason:"_id is required for puts"}),h=new o({status:400,error:"bad_request",reason:"Only reserved document ids may start with underscore."}),y=new o({status:412,error:"precondition_failed",reason:"Database not open"}),v=new o({status:500,error:"unknown_error",reason:"Database encountered an unknown error"}),m=new o({status:500,error:"badarg",reason:"Some query argument is invalid"}),g=new o({status:400,error:"invalid_request",reason:"Request was invalid"}),w=new o({status:400,error:"query_parse_error",reason:"Some query parameter is invalid"}),b=new o({status:500,error:"doc_validation",reason:"Bad special document member"}),_=new o({status:400,error:"bad_request",reason:"Something wrong with the request"}),E=new o({status:400,error:"bad_request",reason:"Document must be a JSON object"}),S=new o({status:404,error:"not_found",reason:"Database not found"}),j=new o({status:500,error:"indexed_db_went_bad",reason:"unknown"}),x=new o({status:500,error:"web_sql_went_bad",reason:"unknown"}),O=new o({status:500,error:"levelDB_went_went_bad",reason:"unknown"}),R=new o({status:403,error:"forbidden",reason:"Forbidden by design doc validate_doc_update function"}),A=new o({status:400,error:"bad_request",reason:"Invalid rev format"}),T=new o({status:412,error:"file_exists",reason:"The database could not be created, the file already exists."}),I=new o({status:412,error:"missing_stub"}),D=new o({status:413,error:"invalid_url",reason:"Provided URL is invalid"}),C=[u,c,f,l,d,p,h,y,v,m,g,w,b,_,E,S,x,O,R,A,T,I,j,D],B=function(e,t,n){var r=C.filter(function(n){return n[e]===t});return n&&r.filter(function(e){return e.message===n})[0]||r[0]};n.UNAUTHORIZED=u,n.MISSING_BULK_DOCS=c,n.MISSING_DOC=f,n.REV_CONFLICT=l,n.INVALID_ID=d,n.MISSING_ID=p,n.RESERVED_ID=h,n.NOT_OPEN=y,n.UNKNOWN_ERROR=v,n.BAD_ARG=m,n.INVALID_REQUEST=g,n.QUERY_PARSE_ERROR=w,n.DOC_VALIDATION=b,n.BAD_REQUEST=_,n.NOT_AN_OBJECT=E,n.DB_MISSING=S,n.WSQ_ERROR=x,n.LDB_ERROR=O,n.FORBIDDEN=R,n.INVALID_REV=A,n.FILE_EXISTS=T,n.MISSING_STUB=I,n.IDB_ERROR=j,n.INVALID_URL=D,n.getErrorTypeByProp=B,n.createError=s,n.generateErrorFromResponse=i},{7:7}],15:[function(e,t,n){"use strict";function r(e){return null===e?String(e):"object"==typeof e||"function"==typeof e?c[p.call(e)]||"object":typeof e}function o(e){return null!==e&&e===e.window}function s(e){if(!e||"object"!==r(e)||e.nodeType||o(e))return!1;try{if(e.constructor&&!h.call(e,"constructor")&&!h.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(e){return!1}var t;for(t in e);return void 0===t||h.call(e,t)}function i(e){return"function"===r(e)}function a(){for(var e=[],t=-1,n=arguments.length,r=new Array(n);++t<n;)r[t]=arguments[t];
var o={};e.push({args:r,result:{container:o,key:"key"}});for(var s;s=e.pop();)u(e,s.args,s.result);return o.key}function u(e,t,n){var r,o,a,u,c,f,l,d=t[0]||{},p=1,h=t.length,v=!1,m=/\d+/;for("boolean"==typeof d&&(v=d,d=t[1]||{},p=2),"object"==typeof d||i(d)||(d={}),h===p&&(d=this,--p);p<h;p++)if(null!=(r=t[p])){l=y(r);for(o in r)if(!(o in Object.prototype)){if(l&&!m.test(o))continue;if(a=d[o],u=r[o],d===u)continue;v&&u&&(s(u)||(c=y(u)))?(c?(c=!1,f=a&&y(a)?a:[]):f=a&&s(a)?a:{},e.push({args:[v,f,u],result:{container:d,key:o}})):void 0!==u&&(y(r)&&i(u)||(d[o]=u))}}n.container[n.key]=d}for(var c={},f=["Boolean","Number","String","Function","Array","Date","RegExp","Object","Error"],l=0;l<f.length;l++){var d=f[l];c["[object "+d+"]"]=d.toLowerCase()}var p=c.toString,h=c.hasOwnProperty,y=Array.isArray||function(e){return"array"===r(e)};t.exports=a},{}],16:[function(e,t,n){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var o=r(e(9)),s="function"==typeof Promise?Promise:o;t.exports=s},{9:9}],17:[function(e,t,n){arguments[4][12][0].apply(n,arguments)},{12:12,18:18,19:19,2:2,20:20,3:3,5:5,7:7}],18:[function(e,t,n){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e.default:e}function o(e){Error.call(this,e.reason),this.status=e.status,this.name=e.error,this.message=e.reason,this.error=!0}function s(e,t){function n(t){for(var n in e)"function"!=typeof e[n]&&(this[n]=e[n]);void 0!==t&&(this.reason=t)}return n.prototype=o.prototype,new n(t)}function i(e){if("object"!=typeof e){var t=e;e=v,e.data=t}return"error"in e&&"conflict"===e.error&&(e.name="conflict",e.status=409),"name"in e||(e.name=e.error||"unknown"),"status"in e||(e.status=500),"message"in e||(e.message=e.message||e.reason),e}Object.defineProperty(n,"__esModule",{value:!0});var a=r(e(7));a(o,Error),o.prototype.toString=function(){return JSON.stringify({status:this.status,name:this.name,message:this.message,reason:this.reason})};var u=new o({status:401,error:"unauthorized",reason:"Name or password is incorrect."}),c=new o({status:400,error:"bad_request",reason:"Missing JSON list of 'docs'"}),f=new o({status:404,error:"not_found",reason:"missing"}),l=new o({status:409,error:"conflict",reason:"Document update conflict"}),d=new o({status:400,error:"bad_request",reason:"_id field must contain a string"}),p=new o({status:412,error:"missing_id",reason:"_id is required for puts"}),h=new o({status:400,error:"bad_request",reason:"Only reserved document ids may start with underscore."}),y=new o({status:412,error:"precondition_failed",reason:"Database not open"}),v=new o({status:500,error:"unknown_error",reason:"Database encountered an unknown error"}),m=new o({status:500,error:"badarg",reason:"Some query argument is invalid"}),g=new o({status:400,error:"invalid_request",reason:"Request was invalid"}),w=new o({status:400,error:"query_parse_error",reason:"Some query parameter is invalid"}),b=new o({status:500,error:"doc_validation",reason:"Bad special document member"}),_=new o({status:400,error:"bad_request",reason:"Something wrong with the request"}),E=new o({status:400,error:"bad_request",reason:"Document must be a JSON object"}),S=new o({status:404,error:"not_found",reason:"Database not found"}),j=new o({status:500,error:"indexed_db_went_bad",reason:"unknown"}),x=new o({status:500,error:"web_sql_went_bad",reason:"unknown"}),O=new o({status:500,error:"levelDB_went_went_bad",reason:"unknown"}),R=new o({status:403,error:"forbidden",reason:"Forbidden by design doc validate_doc_update function"}),A=new o({status:400,error:"bad_request",reason:"Invalid rev format"}),T=new o({status:412,error:"file_exists",reason:"The database could not be created, the file already exists."}),I=new o({status:412,error:"missing_stub"}),D=new o({status:413,error:"invalid_url",reason:"Provided URL is invalid"});n.UNAUTHORIZED=u,n.MISSING_BULK_DOCS=c,n.MISSING_DOC=f,n.REV_CONFLICT=l,n.INVALID_ID=d,n.MISSING_ID=p,n.RESERVED_ID=h,n.NOT_OPEN=y,n.UNKNOWN_ERROR=v,n.BAD_ARG=m,n.INVALID_REQUEST=g,n.QUERY_PARSE_ERROR=w,n.DOC_VALIDATION=b,n.BAD_REQUEST=_,n.NOT_AN_OBJECT=E,n.DB_MISSING=S,n.WSQ_ERROR=x,n.LDB_ERROR=O,n.FORBIDDEN=R,n.INVALID_REV=A,n.FILE_EXISTS=T,n.MISSING_STUB=I,n.IDB_ERROR=j,n.INVALID_URL=D,n.createError=s,n.generateErrorFromResponse=i},{7:7}],19:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{16:16,9:9}],20:[function(e,t,n){function r(){d&&f&&(d=!1,f.length?l=f.concat(l):p=-1,l.length&&o())}function o(){if(!d){var e=a(r);d=!0;for(var t=l.length;t;){for(f=l,l=[];++p<t;)f&&f[p].run();p=-1,t=l.length}f=null,d=!1,u(e)}}function s(e,t){this.fun=e,this.array=t}function i(){}var a,u,c=t.exports={};!function(){try{a=setTimeout}catch(e){a=function(){throw new Error("setTimeout is not defined")}}try{u=clearTimeout}catch(e){u=function(){throw new Error("clearTimeout is not defined")}}}();var f,l=[],d=!1,p=-1;c.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];l.push(new s(e,t)),1!==l.length||d||a(o,0)},s.prototype.run=function(){this.fun.apply(null,this.array)},c.title="browser",c.browser=!0,c.env={},c.argv=[],c.version="",c.versions={},c.on=i,c.addListener=i,c.once=i,c.off=i,c.removeListener=i,c.removeAllListeners=i,c.emit=i,c.binding=function(e){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(e){throw new Error("process.chdir is not supported")},c.umask=function(){return 0}},{}],21:[function(t,n,r){!function(t,r,o){"undefined"!=typeof n&&n.exports?n.exports=o():"function"==typeof e&&e.amd?e(o):r[t]=o()}("urljoin",this,function(){function e(e,t){return e=e.replace(/:\//g,"://"),e=e.replace(/([^:\s])\/+/g,"$1/"),e=e.replace(/\/(\?|&|#[^!])/g,"$1"),e=e.replace(/(\?.+)\?/g,"$1&")}return function(){var t=arguments,n={};"object"==typeof arguments[0]&&(t=arguments[0],n=arguments[1]||{});var r=[].slice.call(t,0).join("/");return e(r,n)}})},{}],22:[function(e,t,n){"use strict";function r(e){return function(t,n){return t&&"unknown_error"===t.name&&(t.message=(t.message||"")+" Unknown error! Did you remember to enable CORS?"),e(t,n)}}function o(e,t,n,o){var a=["name","password","roles","type","salt","metadata"];if(n.metadata){for(var u in n.metadata)if(n.hasOwnProperty(u)&&(a.indexOf(u)!==-1||u.startsWith("_")))return o(new s('cannot use reserved word in metadata: "'+u+'"'));t=i.extend(!0,t,n.metadata)}var c=i.getUsersUrl(e)+"/"+encodeURIComponent(t._id),f=i.extend(!0,{method:"PUT",url:c,body:t},n.ajax||{});i.ajax(f,r(o))}function s(e){this.status=400,this.name="authentication_error",this.message=e,this.error=!0;try{Error.captureStackTrace(this,s)}catch(e){}}var i=e(1);n.signup=i.toPromise(function(e,t,n,r){var i=this;if("undefined"==typeof r&&(r="undefined"==typeof n?"undefined"==typeof t?e:t:n,n={}),["http","https"].indexOf(i.type())===-1)return r(new s('This plugin only works for the http/https adapter. So you should use new PouchDB("http://mysite.com:5984/mydb") instead.'));if(!e)return r(new s("You must provide a username"));if(!t)return r(new s("You must provide a password"));var a="org.couchdb.user:"+e,u={name:e,password:t,roles:n.roles||[],type:"user",_id:a};o(i,u,n,r)}),n.signUp=n.signup,n.login=i.toPromise(function(e,t,n,o){var a=this;if("undefined"==typeof o&&(o=n,n={}),["http","https"].indexOf(a.type())===-1)return o(new s("this plugin only works for the http/https adapter"));if(!e)return o(new s("you must provide a username"));if(!t)return o(new s("you must provide a password"));var u=i.extend(!0,{method:"POST",url:i.getSessionUrl(a),headers:{"Content-Type":"application/x-www-form-urlencoded"},body:"name="+encodeURIComponent(e)+"&password="+encodeURIComponent(t)},n.ajax||{});i.ajax(u,r(o))}),n.logIn=n.login,n.logout=i.toPromise(function(e,t){var n=this;"undefined"==typeof t&&(t=e,e={});var o=i.extend(!0,{method:"DELETE",url:i.getSessionUrl(n)},e.ajax||{});i.ajax(o,r(t))}),n.logOut=n.logout,n.getSession=i.toPromise(function(e,t){var n=this;"undefined"==typeof t&&(t=e,e={});var o=i.getSessionUrl(n),s=i.extend(!0,{method:"GET",url:o},e.ajax||{});i.ajax(s,r(t))}),n.getUser=i.toPromise(function(e,t,n){var o=this;if("undefined"==typeof n&&(n="undefined"==typeof t?e:t,t={}),!e)return n(new s("you must provide a username"));var a=i.getUsersUrl(o),u=i.extend(!0,{method:"GET",url:a+"/"+encodeURIComponent("org.couchdb.user:"+e)},t.ajax||{});i.ajax(u,r(n))}),n.putUser=i.toPromise(function(e,t,n){var r=this;return"undefined"==typeof n&&(n="undefined"==typeof t?e:t,t={}),["http","https"].indexOf(r.type())===-1?n(new s('This plugin only works for the http/https adapter. So you should use new PouchDB("http://mysite.com:5984/mydb") instead.')):e?r.getUser(e,t,function(e,s){return e?n(e):void o(r,s,t,n)}):n(new s("You must provide a username"))}),n.changePassword=i.toPromise(function(e,t,n,o){var a=this;return"undefined"==typeof o&&(o="undefined"==typeof n?"undefined"==typeof t?e:t:n,n={}),["http","https"].indexOf(a.type())===-1?o(new s('This plugin only works for the http/https adapter. So you should use new PouchDB("http://mysite.com:5984/mydb") instead.')):e?t?a.getUser(e,n,function(e,s){if(e)return o(e);s.password=t;var u=i.getUsersUrl(a)+"/"+encodeURIComponent(s._id),c=i.extend(!0,{method:"PUT",url:u,body:s},n.ajax||{});i.ajax(c,r(o))}):o(new s("You must provide a password")):o(new s("You must provide a username"))}),n.changeUsername=i.toPromise(function(e,t,n,o){var a=this,u="org.couchdb.user:",c=function(e){return new i.Promise(function(t,n){i.ajax(e,r(function(e,r){return e?n(e):void t(r)}))})},f=function(e,t){var n=i.getUsersUrl(a)+"/"+encodeURIComponent(e._id),r=i.extend(!0,{method:"PUT",url:n,body:e},t.ajax);return c(r)};return"undefined"==typeof o&&(o=n,n={}),n.ajax=n.ajax||{},["http","https"].indexOf(a.type())===-1?o(new s('This plugin only works for the http/https adapter. So you should use new PouchDB("http://mysite.com:5984/mydb") instead.')):t?e?a.getUser(t,n).then(function(){var e=new s("user already exists");throw e.taken=!0,e},function(){return a.getUser(e,n)}).then(function(e){var r=i.clone(e);return delete r._rev,r._id=u+t,r.name=t,r.roles=n.roles||e.roles||{},f(r,n).then(function(){return e._deleted=!0,f(e,n)})}).then(function(e){o(null,e)}).catch(o):o(new s("You must provide a username to rename")):o(new s("You must provide a new username"))}),i.inherits(s,Error),"undefined"!=typeof window&&window.PouchDB&&window.PouchDB.plugin(n)},{1:1}]},{},[22])(22)});

@@ -90,3 +90,3 @@ 'use strict';

};
exports.uuid = require('./uuid');
exports.uuid = require('pouchdb-utils').uuid;
exports.Promise = Promise;
{
"name": "pouchdb-authentication",
"version": "0.5.2",
"version": "0.5.3",
"description": "PouchDB Authentication",

@@ -11,8 +11,8 @@ "main": "lib/index.js",

"scripts": {
"jshint": "jshint -c .jshintrc lib/*.js test/test.js",
"build-js": "mkdir -p dist && browserify lib/index.js -s PouchAuthentication -o dist/pouchdb.authentication.js",
"jshint": "jshint -c .jshintrc lib/ test/test.js",
"build-js": "mkdirp dist && browserify . -p bundle-collapser/plugin -s PouchAuthentication > dist/pouchdb.authentication.js",
"min": "uglifyjs dist/pouchdb.authentication.js -mc > dist/pouchdb.authentication.min.js",
"build": "npm run build-js && npm run min",
"dev": "add-cors-to-couchdb && zuul --local 9000 --no-coverage --ui mocha-bdd test/test.js",
"test": "add-cors-to-couchdb && zuul --phantom --ui mocha-bdd test/test.js"
"dev": "zuul --local 9000 --no-coverage --ui mocha-bdd test/test.js",
"test": "zuul --phantom --ui mocha-bdd test/test.js"
},

@@ -33,20 +33,22 @@ "keywords": [

"inherits": "2.0.1",
"lie": "3.0.2",
"pouchdb-ajax": "5.4.4",
"pouchdb-extend": "0.1.2",
"pouchdb-promise": "5.4.4",
"pouchdb-utils": "5.4.5",
"url-join": "1.1.0"
},
"devDependencies": {
"bluebird": "1.2.4",
"browserify": "3.44.2",
"chai": "1.8.1",
"chai-as-promised": "4.1.1",
"istanbul": "0.1.46",
"jshint": "2.3.0",
"mocha": "1.21.5",
"phantomjs": "2.1.1",
"bluebird": "^2.0.0",
"browserify": "13.0.1",
"bundle-collapser": "^1.2.1",
"chai": "^3.5.0",
"chai-as-promised": "^5.3.0",
"istanbul": "^0.1.46",
"jshint": "2.8.0",
"mkdirp": "^0.5.1",
"mocha": "^2.3.3",
"phantomjs-prebuilt": "2.1.7",
"pouchdb-memory": "^1.1.0",
"uglify-js": "2.4.24",
"zuul": "3.9.0"
"uglify-js": "^2.4.24",
"zuul": "^3.10.1"
},

@@ -53,0 +55,0 @@ "files": [

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc