diff --git a/bower.json b/bower.json index b972eb816..d3f90bc94 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "remotestorage", - "version": "1.0.2", + "version": "1.0.3", "main": [ "./release/remotestorage.js" ], diff --git a/doc/version.py b/doc/version.py index a6221b3de..3f6fab60f 100644 --- a/doc/version.py +++ b/doc/version.py @@ -1 +1 @@ -__version__ = '1.0.2' +__version__ = '1.0.3' diff --git a/package-lock.json b/package-lock.json index 450f7c794..02cf5ede2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "remotestoragejs", - "version": "1.0.2", + "version": "1.0.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 20bce9f92..ec3b2a518 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "remotestoragejs", "description": "JavaScript library for integrating remoteStorage", - "version": "1.0.2", + "version": "1.0.3", "private": false, "license": "MIT", "main": "./index.js", diff --git a/release/remotestorage.js b/release/remotestorage.js index c00dd3a03..791847a0c 100644 --- a/release/remotestorage.js +++ b/release/remotestorage.js @@ -1,11 +1,6 @@ -/*! remotestorage.js 1.0.2, https://remotestorage.io, MIT licensed */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("RemoteStorage",[],t):"object"==typeof exports?exports.RemoteStorage=t():e.RemoteStorage=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=17)}([function(e,t,r){"use strict";(function(t){function r(e,t){var o,i,s;if("object"===(void 0===e?"undefined":n(e))&&!Array.isArray(e)&&null!==e)for(o in e)"object"===n(e[o])&&null!==e[o]&&("[object ArrayBuffer]"===e[o].toString()?(t[o]=new ArrayBuffer(e[o].byteLength),i=new Int8Array(e[o]),s=new Int8Array(t[o]),s.set(i)):r(e[o],t[o]))}var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o={logError:function(e){"string"==typeof e?console.error(e):console.error(e.message,e.stack)},globalContext:"undefined"!=typeof window?window:t,getGlobalContext:function(){return"undefined"!=typeof window?window:t},extend:function(e){return Array.prototype.slice.call(arguments,1).forEach(function(t){for(var r in t)e[r]=t[r]}),e},asyncEach:function(e,t){return this.asyncMap(e,t).then(function(){return e})},asyncMap:function(e,t){function r(){++s===i&&o.resolve(a,u)}var o=Promise.defer(),i=e.length,s=0,a=[],u=[];return e.forEach(function(e,o){var i;try{i=t(e)}catch(e){r(),u[o]=e}"object"===(void 0===i?"undefined":n(i))&&"function"==typeof i.then?i.then(function(e){a[o]=e,r()},function(e){u[o]=e,r()}):(r(),a[o]=i)}),o.promise},containingFolder:function(e){if(""===e)return"/";if(!e)throw"Path not given!";return e.replace(/\/+/g,"/").replace(/[^\/]+\/?$/,"")},isFolder:function(e){return"/"===e.substr(-1)},isDocument:function(e){return!o.isFolder(e)},baseName:function(e){var t=e.split("/");return o.isFolder(e)?t[t.length-2]+"/":t[t.length-1]},cleanPath:function(e){return e.replace(/\/+/g,"/").split("/").map(encodeURIComponent).join("/").replace(/'/g,"%27")},bindAll:function(e){for(var t in this)"function"==typeof e[t]&&(e[t]=e[t].bind(e))},equal:function(e,t,r){var i;if(r=r||[],(void 0===e?"undefined":n(e))!==(void 0===t?"undefined":n(t)))return!1;if("number"==typeof e||"boolean"==typeof e||"string"==typeof e)return e===t;if("function"==typeof e)return e.toString()===t.toString();if(e instanceof ArrayBuffer&&t instanceof ArrayBuffer&&(e=new Uint8Array(e),t=new Uint8Array(t)),e instanceof Array){if(e.length!==t.length)return!1;for(var s=0,a=e.length;s=0)continue;u=r.slice(),u.push(t[i])}if(!o.equal(e[i],t[i],u))return!1}}return!0},deepClone:function(e){var t;return void 0===e?void 0:(t=JSON.parse(JSON.stringify(e)),r(e,t),t)},pathsFromRoot:function(e){for(var t=[e],r=e.replace(/\/$/,"").split("/");r.length>1;)r.pop(),t.push(r.join("/")+"/");return t},localStorageAvailable:function(){var e=o.getGlobalContext();if(!("localStorage"in e))return!1;try{return e.localStorage.setItem("rs-check",1),e.localStorage.removeItem("rs-check"),!0}catch(e){return!1}},shouldBeTreatedAsBinary:function(e,t){return t&&t.match(/charset=binary/)||/[\x00-\x1F]/.test(e)},readBinaryData:function(e,r){return new Promise(function(n){var i=void 0;if(o.globalContext.BlobBuilder=o.globalContext.BlobBuilder||o.globalContext.WebKitBlobBuilder,void 0!==o.globalContext.BlobBuilder){var s=new t.BlobBuilder;s.append(e),i=s.getBlob(r)}else i=new Blob([e],{type:r});var a=new FileReader;"function"==typeof a.addEventListener?a.addEventListener("loadend",function(){n(a.result)}):a.onloadend=function(){n(a.result)},a.readAsArrayBuffer(i)})}};e.exports=o}).call(t,r(6))},function(e,t,r){"use strict";function n(){o.logging&&console.log.apply(console,arguments)}var o=r(3);e.exports=n},function(e,t,r){"use strict";var n=r(1),o={addEventListener:function(e,t){if("string"!=typeof e)throw new Error("Argument eventName should be a string");if("function"!=typeof t)throw new Error("Argument handler should be a function");n("[Eventhandling] Adding event listener",e),this._validateEvent(e),this._handlers[e].push(t)},removeEventListener:function(e,t){this._validateEvent(e);for(var r=this._handlers[e].length,n=0;n0&&(e.state=n)}else e[decodeURIComponent(r[0])]=decodeURIComponent(r[1]);return e},{})}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=r(1),s=r(0),a=function e(t,r,n,o,a){if(i("[Authorize] authURL = ",r,"scope = ",n,"redirectUri = ",o,"clientId = ",a),!s.localStorageAvailable()&&"remotestorage"===t.backend){o+=o.indexOf("#")>0?"&":"#";var u={userAddress:t.remote.userAddress,href:t.remote.href,storageApi:t.remote.storageApi,properties:t.remote.properties};o+="rsDiscovery="+btoa(JSON.stringify(u))}var c=r,h=o.indexOf("#");if(c+=r.indexOf("?")>0?"&":"?",c+="redirect_uri="+encodeURIComponent(o.replace(/#.*$/,"")),c+="&scope="+encodeURIComponent(n),c+="&client_id="+encodeURIComponent(a),-1!==h&&h+1!==o.length&&(c+="&state="+encodeURIComponent(o.substring(h+1))),c+="&response_type=token",s.globalContext.cordova)return e.openWindow(c,o,"location=yes,clearsessioncache=yes,clearcache=yes").then(function(e){t.remote.configure({token:e.access_token})});e.setLocation(c)};a.IMPLIED_FAKE_TOKEN=!1,a.Unauthorized=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.name="Unauthorized",this.message=void 0===e?"App authorization expired or revoked.":e,void 0!==t.code&&(this.code=t.code),this.stack=(new Error).stack},a.Unauthorized.prototype=Object.create(Error.prototype),a.Unauthorized.prototype.constructor=a.Unauthorized,a.getLocation=function(){return document.location},a.setLocation=function(e){if("string"==typeof e)document.location.href=e;else{if("object"!==(void 0===e?"undefined":o(e)))throw"Invalid location "+e;document.location=e}},a.openWindow=function(e,t,r){return new Promise(function(o,i){var s=open(e,"_blank",r);if(!s||s.closed)return i("Authorization popup was blocked");var a=function(){return i("Authorization was canceled")},u=function(e){if(0===e.url.indexOf(t)){s.removeEventListener("exit",a),s.close();var r=n(e.url);return r?o(r):i("Authorization error")}};s.addEventListener("loadstart",u),s.addEventListener("exit",a)})},a._rs_supported=function(){return"undefined"!=typeof document};var u;a._rs_init=function(e){u=function(){var n=!1;if(r){if(r.error)throw"access_denied"===r.error?new a.Unauthorized("Authorization failed: access denied",{code:"access_denied"}):new a.Unauthorized("Authorization failed: "+r.error);r.rsDiscovery&&e.remote.configure(r.rsDiscovery),r.access_token&&(e.remote.configure({token:r.access_token}),n=!0),r.remotestorage&&(e.connect(r.remotestorage),n=!0),r.state&&(t=a.getLocation(),a.setLocation(t.href.split("#")[0]+"#"+r.state))}n||e.remote.stopWaitingForToken()};var t,r=n();r&&(t=a.getLocation(),t.hash=""),e.on("features-loaded",u)},a._rs_cleanup=function(e){e.removeEventListener("features-loaded",u)},e.exports=a},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=r(2),i=r(0),s=r(3),a=r(18),u=r(19),c=u.SchemaNotFound,h=function(e,t){if("/"!==t[t.length-1])throw"Not a folder: "+t;"/"===t&&(this.makePath=function(e){return("/"===e[0]?"":"/")+e}),this.storage=e,this.base=t;var r=this.base.split("/");r.length>2?this.moduleName=r[1]:this.moduleName="root",o(this,"change"),this.on=this.on.bind(this),e.onChange(this.base,this._fireChange.bind(this))};h.Types=u,h.prototype={scope:function(e){return new h(this.storage,this.makePath(e))},getListing:function(e,t){if("string"!=typeof e)e="";else if(e.length>0&&"/"!==e[e.length-1])return Promise.reject("Not a folder: "+e);return this.storage.get(this.makePath(e),t).then(function(e){return 404===e.statusCode?{}:e.body})},getAll:function(e,t){if("string"!=typeof e)e="";else if(e.length>0&&"/"!==e[e.length-1])return Promise.reject("Not a folder: "+e);return this.storage.get(this.makePath(e),t).then(function(r){if(404===r.statusCode)return{};if("object"===n(r.body)){var o=Object.keys(r.body);if(0===o.length)return{};var i=o.map(function(o){return this.storage.get(this.makePath(e+o),t).then(function(e){if("string"==typeof e.body)try{e.body=JSON.parse(e.body)}catch(e){}"object"===n(e.body)&&(r.body[o]=e.body)})}.bind(this));return Promise.all(i).then(function(){return r.body})}}.bind(this))},getFile:function(e,t){return"string"!=typeof e?Promise.reject("Argument 'path' of baseClient.getFile must be a string"):this.storage.get(this.makePath(e),t).then(function(e){return{data:e.body,contentType:e.contentType,revision:e.revision}})},storeFile:function(e,t,r){return"string"!=typeof e?Promise.reject("Argument 'mimeType' of baseClient.storeFile must be a string"):"string"!=typeof t?Promise.reject("Argument 'path' of baseClient.storeFile must be a string"):"string"!=typeof r&&"object"!==(void 0===r?"undefined":n(r))?Promise.reject("Argument 'body' of baseClient.storeFile must be a string, ArrayBuffer, or ArrayBufferView"):(this.storage.access.checkPathPermission(this.makePath(t),"rw")||console.warn("WARNING: Editing a document to which only read access ('r') was claimed"),this.storage.put(this.makePath(t),r,e).then(function(e){return 200===e.statusCode||201===e.statusCode?e.revision:Promise.reject("Request (PUT "+this.makePath(t)+") failed with status: "+e.statusCode)}.bind(this)))},getObject:function(e,t){return"string"!=typeof e?Promise.reject("Argument 'path' of baseClient.getObject must be a string"):this.storage.get(this.makePath(e),t).then(function(t){if("object"===n(t.body))return t.body;if("string"==typeof t.body)try{return JSON.parse(t.body)}catch(t){throw"Not valid JSON: "+this.makePath(e)}else if(void 0!==t.body&&200===t.statusCode)return Promise.reject("Not an object: "+this.makePath(e))}.bind(this))},storeObject:function(e,t,r){if("string"!=typeof e)return Promise.reject("Argument 'typeAlias' of baseClient.storeObject must be a string");if("string"!=typeof t)return Promise.reject("Argument 'path' of baseClient.storeObject must be a string");if("object"!==(void 0===r?"undefined":n(r)))return Promise.reject("Argument 'object' of baseClient.storeObject must be an object");this._attachType(r,e);try{var o=this.validate(r);if(!o.valid)return Promise.reject(o)}catch(e){return Promise.reject(e)}return this.storage.put(this.makePath(t),JSON.stringify(r),"application/json; charset=UTF-8").then(function(e){return 200===e.statusCode||201===e.statusCode?e.revision:Promise.reject("Request (PUT "+this.makePath(t)+") failed with status: "+e.statusCode)}.bind(this))},remove:function(e){return"string"!=typeof e?Promise.reject("Argument 'path' of baseClient.remove must be a string"):(this.storage.access.checkPathPermission(this.makePath(e),"rw")||console.warn("WARNING: Removing a document to which only read access ('r') was claimed"),this.storage.delete(this.makePath(e)))},getItemURL:function(e){if("string"!=typeof e)throw"Argument 'path' of baseClient.getItemURL must be a string";return this.storage.connected?(e=this._cleanPath(this.makePath(e)),this.storage.remote.href+e):void 0},cache:function(e,t){if("string"!=typeof e)throw"Argument 'path' of baseClient.cache must be a string";if(void 0===t)t="ALL";else if("string"!=typeof t)throw"Argument 'strategy' of baseClient.cache must be a string or undefined";if("FLUSH"!==t&&"SEEN"!==t&&"ALL"!==t)throw'Argument \'strategy\' of baseclient.cache must be one of ["FLUSH", "SEEN", "ALL"]';return this.storage.caching.set(this.makePath(e),t),this},flush:function(e){return this.storage.local.flush(e)},declareType:function(e,t,r){r||(r=t,t=this._defaultTypeURI(e)),h.Types.declare(this.moduleName,e,t,r)},validate:function(e){var t=h.Types.getSchema(e["@context"]);if(t)return a.validateResult(e,t);throw new c(e["@context"])},schemas:{configurable:!0,get:function(){return h.Types.inScope(this.moduleName)}},_defaultTypeURI:function(e){return"http://remotestorage.io/spec/modules/"+encodeURIComponent(this.moduleName)+"/"+encodeURIComponent(e)},_attachType:function(e,t){e["@context"]=h.Types.resolveAlias(this.moduleName+"/"+t)||this._defaultTypeURI(t)},makePath:function(e){return this.base+(e||"")},_fireChange:function(e){s.changeEvents[e.origin]&&(["new","old","lastCommon"].forEach(function(t){if((!e[t+"ContentType"]||/^application\/(.*)json(.*)/.exec(e[t+"ContentType"]))&&"string"==typeof e[t+"Value"])try{e[t+"Value"]=JSON.parse(e[t+"Value"])}catch(e){}}),this._emit("change",e))},_cleanPath:i.cleanPath},h._rs_init=function(){},e.exports=h},function(e,t){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){"use strict";(function(t,n){function o(e){return"string"!=typeof e?e:"*"===e?"*":'"'+e+'"'}function i(e){return"string"!=typeof e?e:e.replace(/^["']|["']$/g,"")}function s(e,r){return new Promise(function(o){if("undefined"==typeof Blob){var i=new t(new Uint8Array(e));o(i.toString(r))}else{var s;if(m.globalContext.BlobBuilder=m.globalContext.BlobBuilder||m.globalContext.WebKitBlobBuilder,void 0!==m.globalContext.BlobBuilder){var a=new n.BlobBuilder;a.append(e),s=a.getBlob()}else s=new Blob([e]);var u=new FileReader;"function"==typeof u.addEventListener?u.addEventListener("loadend",function(e){o(e.target.result)}):u.onloadend=function(e){o(e.target.result)},u.readAsText(s,r)}})}function a(e){var t,r="UTF-8";return e&&(t=e.match(/charset=(.+)$/))&&(r=t[1]),r}function u(e){return"http://remotestorage.io/spec/folder-description"===e["@context"]&&"object"===d(e.items)}function c(e){return[201,204,304].indexOf(e)>=0}function h(e){return[401,403,404,412].indexOf(e)>=0}var l,f,d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p=r(1),m=r(0),g=r(2),y=r(4),v=r(3),b="remotestorage:wireclient",_={"draft-dejong-remotestorage-00":2,"draft-dejong-remotestorage-01":3,"draft-dejong-remotestorage-02":4,"https://www.w3.org/community/rww/wiki/read-write-web-00#simple":1};if("function"==typeof ArrayBufferView)f=function(e){return e&&e instanceof ArrayBufferView};else{var w=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];f=function(e){for(var t=0;t<8;t++)if(e instanceof w[t])return!0;return!1}}var P=m.isFolder,E=m.cleanPath,S=m.shouldBeTreatedAsBinary,T=function(e){if(this.rs=e,this.connected=!1,g(this,"connected","not-connected"),l){var t;try{t=JSON.parse(localStorage[b])}catch(e){}t&&setTimeout(function(){this.configure(t)}.bind(this),0)}this._revisionCache={},this.connected&&setTimeout(this._emit.bind(this),0,"connected")};T.prototype={_request:function(e,t,r,n,o,u,l){if(("PUT"===e||"DELETE"===e)&&"/"===t[t.length-1])return Promise.reject("Don't "+e+" on directories!");var f,d=this;return r!==y.IMPLIED_FAKE_TOKEN&&(n.Authorization="Bearer "+r),this.rs._emit("wire-busy",{method:e,isFolder:P(t)}),T.request(e,t,{body:o,headers:n,responseType:"arraybuffer"}).then(function(r){if(d.online||(d.online=!0,d.rs._emit("network-online")),d.rs._emit("wire-done",{method:e,isFolder:P(t),success:!0}),h(r.status))return p("[WireClient] Error response status",r.status),f=u?i(r.getResponseHeader("ETag")):void 0,401===r.status&&d.rs._emit("error",new y.Unauthorized),Promise.resolve({statusCode:r.status,revision:f});if(c(r.status)||200===r.status&&"GET"!==e)return f=i(r.getResponseHeader("ETag")),p("[WireClient] Successful request",f),Promise.resolve({statusCode:r.status,revision:f});var n=r.getResponseHeader("Content-Type");f=u?i(r.getResponseHeader("ETag")):200===r.status?l:void 0;var o=a(n);return S(r.response,n)?(p("[WireClient] Successful request with unknown or binary mime-type",f),Promise.resolve({statusCode:r.status,body:r.response,contentType:n,revision:f})):s(r.response,o).then(function(e){return p("[WireClient] Successful request",f),Promise.resolve({statusCode:r.status,body:e,contentType:n,revision:f})})},function(r){return d.online&&(d.online=!1,d.rs._emit("network-offline")),d.rs._emit("wire-done",{method:e,isFolder:P(t),success:!1}),Promise.reject(r)})},configure:function(e){if("object"!==(void 0===e?"undefined":d(e)))throw new Error("WireClient configure settings parameter should be an object");void 0!==e.userAddress&&(this.userAddress=e.userAddress),void 0!==e.href&&(this.href=e.href),void 0!==e.storageApi&&(this.storageApi=e.storageApi),void 0!==e.token&&(this.token=e.token),void 0!==e.properties&&(this.properties=e.properties),void 0!==this.storageApi&&(this._storageApi=_[this.storageApi]||5,this.supportsRevs=this._storageApi>=2),this.href&&this.token?(this.connected=!0,this.online=!0,this._emit("connected")):this.connected=!1,l&&(localStorage[b]=JSON.stringify({userAddress:this.userAddress,href:this.href,storageApi:this.storageApi,token:this.token,properties:this.properties}))},stopWaitingForToken:function(){this.connected||this._emit("not-connected")},get:function(e,t){var r=this;if(!this.connected)return Promise.reject("not connected (path: "+e+")");t||(t={});var n={};return this.supportsRevs&&t.ifNoneMatch&&(n["If-None-Match"]=o(t.ifNoneMatch)),this._request("GET",this.href+E(e),this.token,n,void 0,this.supportsRevs,this._revisionCache[e]).then(function(t){if(!P(e))return Promise.resolve(t);var n={};if(void 0!==t.body)try{t.body=JSON.parse(t.body)}catch(t){return Promise.reject("Folder description at "+r.href+E(e)+" is not JSON")}if(200===t.statusCode&&"object"===d(t.body)){if(0===Object.keys(t.body).length)t.statusCode=404;else if(u(t.body)){for(var o in t.body.items)r._revisionCache[e+o]=t.body.items[o].ETag;n=t.body.items}else Object.keys(t.body).forEach(function(o){r._revisionCache[e+o]=t.body[o],n[o]={ETag:t.body[o]}});return t.body=n,Promise.resolve(t)}return Promise.resolve(t)})},put:function(e,t,r,n){if(!this.connected)return Promise.reject("not connected (path: "+e+")");n||(n={}),!r.match(/charset=/)&&(t instanceof ArrayBuffer||f(t))&&(r+="; charset=binary");var i={"Content-Type":r};return this.supportsRevs&&(n.ifMatch&&(i["If-Match"]=o(n.ifMatch)),n.ifNoneMatch&&(i["If-None-Match"]=o(n.ifNoneMatch))),this._request("PUT",this.href+E(e),this.token,i,t,this.supportsRevs)},delete:function(e,t){if(!this.connected)throw new Error("not connected (path: "+e+")");t||(t={});var r={};return this.supportsRevs&&t.ifMatch&&(r["If-Match"]=o(t.ifMatch)),this._request("DELETE",this.href+E(e),this.token,r,void 0,this.supportsRevs)}},T.isArrayBufferView=f,T.request=function(e,t,r){return new Promise(function(n,o){p("[WireClient]",e,t);var i=!1,s=setTimeout(function(){i=!0,o("timeout")},v.requestTimeout),a=new XMLHttpRequest;if(a.open(e,t,!0),r.responseType&&(a.responseType=r.responseType),r.headers)for(var u in r.headers)a.setRequestHeader(u,r.headers[u]);a.onload=function(){i||(clearTimeout(s),n(a))},a.onerror=function(e){i||(clearTimeout(s),o(e))};var c=r.body;"object"===(void 0===c?"undefined":d(c))&&!f(c)&&c instanceof ArrayBuffer&&(c=new Uint8Array(c)),a.send(c)})},Object.defineProperty(T.prototype,"storageType",{get:function(){if(this.storageApi){var e=this.storageApi.match(/draft-dejong-(remotestorage-\d\d)/);return e?e[1]:"2012.04"}}}),T._rs_init=function(e){l=m.localStorageAvailable(),e.remote=new T(e),this.online=!0},T._rs_supported=function(){return!!XMLHttpRequest},T._rs_cleanup=function(){l&&delete localStorage[b]},e.exports=T}).call(t,r(20).Buffer,r(6))},function(e,t,r){"use strict";function n(e,t,r){return{action:e,path:t,promise:r}}function o(e,t){return e.common.revision!==t&&(!e.remote||e.remote.revision!==t)}function i(e){return e.remote&&e.remote.revision&&!e.remote.itemsMap&&!e.remote.body}function s(e){return e.common&&e.common.revision}function a(e){return(!e.remote||!e.remote.revision||e.remote.revision===e.common.revision)&&(void 0===e.common.body&&!1===e.remote.body||e.remote.body===e.common.body&&e.remote.contentType===e.common.contentType)}function u(e){return e.remote&&!1===e.remote.body&&e.local&&!1===e.local.body&&delete e.local,e}function c(){function e(e){var r,n;r=t.getCurrentSyncInterval(),g.isBackground=!e,n=t.getCurrentSyncInterval(),t._emit("sync-interval-change",{oldValue:r,newValue:n})}var t=this;f.on("background",function(){e(!1)}),f.on("foreground",function(){e(!0)})}var h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},l=r(0),f=r(12),d=r(2),p=r(1),m=r(4),g=r(3),y=l.isFolder,v=l.isDocument,b=l.equal,_=l.deepClone,w=l.pathsFromRoot,P=function(e,t,r,n,o){this.remoteStorage=e,this.local=t,this.local.onDiff(function(e){this.addTask(e),this.doTasks()}.bind(this)),this.remote=r,this.access=n,this.caching=o,this._tasks={},this._running={},this._timeStarted={},d(this,"done","req-done"),this.caching.onActivate(function(e){this.addTask(e),this.doTasks()}.bind(this))};P.prototype={now:function(){return(new Date).getTime()},queueGetRequest:function(e){var t=this;return new Promise(function(r,n){t.remote.connected?t.remote.online?(t.addTask(e,function(){this.local.get(e).then(function(e){return r(e)})}.bind(t)),t.doTasks()):n("cannot fulfill maxAge requirement - remote is not online"):n("cannot fulfill maxAge requirement - remote is not connected")})},corruptServerItemsMap:function(e,t){if("object"!==(void 0===e?"undefined":h(e))||Array.isArray(e))return!0;for(var r in e){var n=e[r];if("object"!==(void 0===n?"undefined":h(n)))return!0;if("string"!=typeof n.ETag)return!0;if(y(r)){if(-1!==r.substring(0,r.length-1).indexOf("/"))return!0}else{if(-1!==r.indexOf("/"))return!0;if(t){if("string"!=typeof n["Content-Type"])return!0;if("number"!=typeof n["Content-Length"])return!0}}}return!1},corruptItemsMap:function(e){if("object"!==(void 0===e?"undefined":h(e))||Array.isArray(e))return!0;for(var t in e)if("boolean"!=typeof e[t])return!0;return!1},corruptRevision:function(e){return"object"!==(void 0===e?"undefined":h(e))||Array.isArray(e)||e.revision&&"string"!=typeof e.revision||e.body&&"string"!=typeof e.body&&"object"!==h(e.body)||e.contentType&&"string"!=typeof e.contentType||e.contentLength&&"number"!=typeof e.contentLength||e.timestamp&&"number"!=typeof e.timestamp||e.itemsMap&&this.corruptItemsMap(e.itemsMap)},isCorrupt:function(e){return"object"!==(void 0===e?"undefined":h(e))||Array.isArray(e)||"string"!=typeof e.path||this.corruptRevision(e.common)||e.local&&this.corruptRevision(e.local)||e.remote&&this.corruptRevision(e.remote)||e.push&&this.corruptRevision(e.push)},hasTasks:function(){return Object.getOwnPropertyNames(this._tasks).length>0},collectDiffTasks:function(){var e=0;return this.local.forAllNodes(function(t){e>100||(this.isCorrupt(t)?(p("[Sync] WARNING: corrupt node in local cache",t),"object"===(void 0===t?"undefined":h(t))&&t.path&&(this.addTask(t.path),e++)):this.needsFetch(t)&&this.access.checkPathPermission(t.path,"r")?(this.addTask(t.path),e++):v(t.path)&&this.needsPush(t)&&this.access.checkPathPermission(t.path,"rw")&&(this.addTask(t.path),e++))}.bind(this)).then(function(){return e},function(e){throw e})},inConflict:function(e){return e.local&&e.remote&&(void 0!==e.remote.body||e.remote.itemsMap)},needsRefresh:function(e){return!!e.common&&(!e.common.timestamp||this.now()-e.common.timestamp>g.syncInterval)},needsFetch:function(e){return!!this.inConflict(e)||!(!e.common||void 0!==e.common.itemsMap||void 0!==e.common.body)||!(!e.remote||void 0!==e.remote.itemsMap||void 0!==e.remote.body)},needsPush:function(e){return!this.inConflict(e)&&(!(!e.local||e.push)||void 0)},needsRemotePut:function(e){return e.local&&e.local.body},needsRemoteDelete:function(e){return e.local&&!1===e.local.body},getParentPath:function(e){var t=e.match(/^(.*\/)([^\/]+\/?)$/);if(t)return t[1];throw new Error('Not a valid path: "'+e+'"')},deleteChildPathsFromTasks:function(){for(var e in this._tasks)for(var t=w(e),r=1;r=r))return!0;return t>=r},collectTasks:function(e){return this.hasTasks()||this.stopped?Promise.resolve():this.collectDiffTasks().then(function(t){return t||!1===e?Promise.resolve():this.collectRefreshTasks()}.bind(this),function(e){throw e})},addTask:function(e,t){this._tasks[e]||(this._tasks[e]=[]),"function"==typeof t&&this._tasks[e].push(t)},sync:function(){return this.done=!1,this.doTasks()?Promise.resolve():this.collectTasks().then(function(){try{this.doTasks()}catch(e){p("[Sync] doTasks error",e)}}.bind(this),function(e){throw p("[Sync] Sync error",e),new Error("Local cache unavailable")})}};var E,S;P._rs_init=function(e){E=function(){p("[Sync] syncCycleCb calling syncCycle"),f.isBrowser()&&c.bind(e)(),e.sync||(e.sync=new P(e,e.local,e.remote,e.access,e.caching),e.syncStopped&&(p("[Sync] Instantiating sync stopped"),e.sync.stopped=!0,delete e.syncStopped)),p("[Sync] syncCycleCb calling syncCycle"),e.syncCycle()},S=function(){e.removeEventListener("connected",S),e.startSync()},e.on("ready",E),e.on("connected",S)},P._rs_cleanup=function(e){e.stopSync(),e.removeEventListener("ready",E),e.removeEventListener("connected",S),e.sync=void 0,delete e.sync},P.SyncError=function(e){this.name="SyncError";var t="Sync failed: ";"object"===(void 0===e?"undefined":h(e))&&"message"in e?(t+=e.message,this.stack=e.stack,this.originalError=e):t+=e,this.message=t},P.SyncError.prototype=Object.create(Error.prototype),P.SyncError.prototype.constructor=P.SyncError,e.exports=P},function(e,t,r){"use strict";function n(e){if("object"===(void 0===e?"undefined":a(e))&&"string"==typeof e.path)if(l(e.path)){if(e.local&&e.local.itemsMap)return e.local;if(e.common&&e.common.itemsMap)return e.common}else{if(e.local&&e.local.body&&e.local.contentType)return e.local;if(e.common&&e.common.body&&e.common.contentType)return e.common;if(e.body&&e.contentType)return{body:e.body,contentType:e.contentType}}}function o(e,t){var r;for(r in e){if(e[r]&&e[r].remote)return!0;var o=n(e[r]);if(o&&o.timestamp&&(new Date).getTime()-o.timestamp<=t)return!1;if(!o)return!0}return!0}function i(e){var t={path:e,common:{}};return l(e)&&(t.common.itemsMap={}),t}function s(e,t){return e.common||(e.common={itemsMap:{}}),e.common.itemsMap||(e.common.itemsMap={}),e.local||(e.local=d(e.common)),e.local.itemsMap||(e.local.itemsMap=e.common.itemsMap),e.local.itemsMap[t]=!0,e}var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u=r(0),c=r(3),h=r(1),l=u.isFolder,f=u.isDocument,d=u.deepClone,p=u.pathsFromRoot,m={get:function(e,t,r){var i=this;return"number"==typeof t?i.getNodes(p(e)).then(function(i){var s=n(i[e]);return o(i,t)?r(e):s?{statusCode:200,body:s.body||s.itemsMap,contentType:s.contentType}:{statusCode:404}}):i.getNodes([e]).then(function(t){var r=n(t[e]);if(r){if(l(e))for(var o in r.itemsMap)r.itemsMap.hasOwnProperty(o)&&!1===r.itemsMap[o]&&delete r.itemsMap[o];return{statusCode:200,body:r.body||r.itemsMap,contentType:r.contentType}}return{statusCode:404}})},put:function(e,t,r){function o(e,o){try{for(var a=0,u=e.length;a0)break}else console.error("Cannot delete non-existing node "+i)}return t})},flush:function(e){var t=this;return t._getAllDescendentPaths(e).then(function(e){return t.getNodes(e)}).then(function(e){for(var r in e){var n=e[r];n&&n.common&&n.local&&t._emitChange({path:n.path,origin:"local",oldValue:!1===n.local.body?void 0:n.local.body,newValue:!1===n.common.body?void 0:n.common.body}),e[r]=void 0}return t.setNodes(e)})},_emitChange:function(e){c.changeEvents[e.origin]&&this._emit("change",e)},fireInitial:function(){if(c.changeEvents.local){var e=this;e.forAllNodes(function(t){var r;f(t.path)&&(r=n(t))&&e._emitChange({path:t.path,origin:"local",oldValue:void 0,oldContentType:void 0,newValue:r.body,newContentType:r.contentType})}).then(function(){e._emit("local-events-done")})}},onDiff:function(e){this.diffHandler=e},migrate:function(e){return"object"!==(void 0===e?"undefined":a(e))||e.common||(e.common={},"string"==typeof e.path?"/"===e.path.substr(-1)&&"object"===a(e.body)&&(e.common.itemsMap=e.body):(e.local||(e.local={}),e.local.body=e.body,e.local.contentType=e.contentType)),e},_updateNodesRunning:!1,_updateNodesQueued:[],_updateNodes:function(e,t){return new Promise(function(r,n){this._doUpdateNodes(e,t,{resolve:r,reject:n})}.bind(this))},_doUpdateNodes:function(e,t,r){var n=this;if(n._updateNodesRunning)return void n._updateNodesQueued.push({paths:e,cb:t,promise:r});n._updateNodesRunning=!0,n.getNodes(e).then(function(o){var i,s=d(o),a=[],c=u.equal;o=t(e,o);for(var h in o)i=o[h],c(i,s[h])?delete o[h]:f(h)&&(c(i.local.body,i.local.previousBody)&&i.local.contentType===i.local.previousContentType||a.push({path:h,origin:"window",oldValue:i.local.previousBody,newValue:!1===i.local.body?void 0:i.local.body,oldContentType:i.local.previousContentType,newContentType:i.local.contentType}),delete i.local.previousBody,delete i.local.previousContentType);n.setNodes(o).then(function(){n._emitChangeEvents(a),r.resolve({statusCode:200})})}).then(function(){return Promise.resolve()},function(e){r.reject(e)}).then(function(){n._updateNodesRunning=!1;var e=n._updateNodesQueued.shift();e&&n._doUpdateNodes(e.paths,e.cb,e.promise)})},_emitChangeEvents:function(e){for(var t=0,r=e.length;t1e3&&e<36e5}var i,s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a=r(0),u=r(11),c=r(13),h=r(14),l=r(5),f=r(3),d=r(4),p=r(8),m=r(1),g=r(26),y=a.getGlobalContext(),v=r(2),b=function(e){if("object"===(void 0===e?"undefined":s(e))&&a.extend(f,e),v(this,"ready","authing","connecting","connected","disconnected","not-connected","conflict","error","features-loaded","sync-interval-change","sync-req-done","sync-done","wire-busy","wire-done","network-offline","network-online"),this._pending=[],this._setGPD({get:this._pendingGPD("get"),put:this._pendingGPD("put"),delete:this._pendingGPD("delete")}),this._cleanups=[],this._pathHandlers={change:{}},this.apiKeys={},i=a.localStorageAvailable()){try{this.apiKeys=JSON.parse(localStorage.getItem("remotestorage:api-keys"))||{}}catch(e){}this.setBackend(localStorage.getItem("remotestorage:backend")||"remotestorage")}var t=this.on;this.on=function(e,r){if(this._allLoaded)switch(e){case"features-loaded":setTimeout(r,0);break;case"ready":this.remote&&setTimeout(r,0);break;case"connected":this.remote&&this.remote.connected&&setTimeout(r,0);break;case"not-connected":this.remote&&!this.remote.connected&&setTimeout(r,0)}return t.call(this,e,r)},this._init(),this.fireInitial=function(){this.local&&setTimeout(this.local.fireInitial.bind(this.local),0)}.bind(this),this.on("ready",this.fireInitial.bind(this)),this.loadModules()};b.Authorize=d,b.SyncError=p.SyncError,b.Unauthorized=d.Unauthorized,b.DiscoveryError=h.DiscoveryError,b.prototype={loadModules:function(){f.modules.forEach(this.addModule.bind(this))},authorize:function(e,t){this.access.setStorageType(this.remote.storageType);var r=this.access.scopeParameter,n=y.cordova?t:String(d.getLocation()),o=n.match(/^(https?:\/\/[^\/]+)/)[0];d(this,e,r,n,o)},impliedauth:function(e,t){e=this.remote.storageApi,t=String(document.location),m("ImpliedAuth proceeding due to absent authURL; storageApi = "+e+" redirectUri = "+t),this.remote.configure({token:d.IMPLIED_FAKE_TOKEN}),document.location=t},connect:function(e,t){var r=this;if(this.setBackend("remotestorage"),e.indexOf("@")<0)return void this._emit("error",new b.DiscoveryError("User address doesn't contain an @."));if(y.cordova){if("string"!=typeof f.cordovaRedirectUri)return void this._emit("error",new b.DiscoveryError("Please supply a custom HTTPS redirect URI for your Cordova app"));if(!y.cordova.InAppBrowser)return void this._emit("error",new b.DiscoveryError("Please include the InAppBrowser Cordova plugin to enable OAuth"))}this.remote.configure({userAddress:e}),this._emit("connecting");var n=setTimeout(function(){this._emit("error",new b.DiscoveryError("No storage information found for this user address."))}.bind(this),f.discoveryTimeout);h(e).then(function(o){if(clearTimeout(n),r._emit("authing"),o.userAddress=e,r.remote.configure(o),!r.remote.connected)if(o.authURL)if(void 0===t)r.authorize(o.authURL,f.cordovaRedirectUri);else{if("string"!=typeof t)throw new Error("Supplied bearer token must be a string");m("Skipping authorization sequence and connecting with known token"),r.remote.configure({token:t})}else r.impliedauth()},function(){clearTimeout(n),r._emit("error",new b.DiscoveryError("No storage information found for this user address."))})},reconnect:function(){this.remote.configure({token:null}),"remotestorage"===this.backend?this.connect(this.remote.userAddress):this.remote.connect()},disconnect:function(){this.remote&&this.remote.configure({userAddress:null,href:null,storageApi:null,token:null,properties:null}),this._setGPD({get:this._pendingGPD("get"),put:this._pendingGPD("put"),delete:this._pendingGPD("delete")});var e=this._cleanups.length,t=0,r=function(){++t>=e&&(this._init(),m("Done cleaning up, emitting disconnected and disconnect events"),this._emit("disconnected"))}.bind(this);e>0?this._cleanups.forEach(function(e){var t=e(this);"object"===(void 0===t?"undefined":s(t))&&"function"==typeof t.then?t.then(r):r()}.bind(this)):r()},setBackend:function(e){this.backend=e,i&&(e?localStorage.setItem("remotestorage:backend",e):localStorage.removeItem("remotestorage:backend"))},onChange:function(e,t){this._pathHandlers.change[e]||(this._pathHandlers.change[e]=[]),this._pathHandlers.change[e].push(t)},enableLog:function(){f.logging=!0},disableLog:function(){f.logging=!1},log:function(){m.apply(b,arguments)},setApiKeys:function(e){var t=this,r=["googledrive","dropbox"];if("object"!==(void 0===e?"undefined":s(e))||!Object.keys(e).every(function(e){return-1!==r.indexOf(e)}))return console.error("setApiKeys() was called with invalid arguments"),!1;Object.keys(e).forEach(function(r){var n=e[r];if(!n)return void delete t.apiKeys[r];switch(r){case"dropbox":t.apiKeys.dropbox={appKey:n},void 0!==t.dropbox&&t.dropbox.clientId===n||u._rs_init(t);break;case"googledrive":t.apiKeys.googledrive={clientId:n},void 0!==t.googledrive&&t.googledrive.clientId===n||c._rs_init(t)}return!0}),i&&localStorage.setItem("remotestorage:api-keys",JSON.stringify(this.apiKeys))},setCordovaRedirectUri:function(e){if("string"!=typeof e||!e.match(/http(s)?:\/\//))throw new Error("Cordova redirect URI must be a URI string");f.cordovaRedirectUri=e},_init:g.loadFeatures,features:g.features,loadFeature:g.loadFeature,featureSupported:g.featureSupported,featureDone:g.featureDone,featuresDone:g.featuresDone,featuresLoaded:g.featuresLoaded,featureInitialized:g.featureInitialized,featureFailed:g.featureFailed,hasFeature:g.hasFeature,_setCachingModule:g._setCachingModule,_collectCleanupFunctions:g._collectCleanupFunctions,_fireReady:g._fireReady,initFeature:g.initFeature,_setGPD:function(e,t){function r(e){return function(){return e.apply(t,arguments).then(n.bind(this))}}this.get=r(e.get),this.put=r(e.put),this.delete=r(e.delete)},_pendingGPD:function(e){return function(){var t=Array.prototype.slice.call(arguments);return new Promise(function(r,n){this._pending.push({method:e,args:t,promise:{resolve:r,reject:n}})}.bind(this))}.bind(this)},_processPending:function(){this._pending.forEach(function(e){try{this[e.method].apply(this,e.args).then(e.promise.resolve,e.promise.reject)}catch(t){e.promise.reject(t)}}.bind(this)),this._pending=[]},_bindChange:function(e){e.on("change",this._dispatchEvent.bind(this,"change"))},_dispatchEvent:function(e,t){var r=this;Object.keys(this._pathHandlers[e]).forEach(function(n){var o=n.length;t.path.substr(0,o)===n&&r._pathHandlers[e][n].forEach(function(e){var o={};for(var i in t)o[i]=t[i];o.relativePath=t.path.replace(new RegExp("^"+n),"");try{e(o)}catch(e){console.error("'change' handler failed: ",e,e.stack),r._emit("error",e)}})})},scope:function(e){if("string"!=typeof e)throw"Argument 'path' of baseClient.scope must be a string";if(!this.access.checkPathPermission(e,"r")){var t=e.replace(/(['\\])/g,"\\$1");console.warn("WARNING: please call remoteStorage.access.claim('"+t+"', 'r') (read only) or remoteStorage.access.claim('"+t+"', 'rw') (read/write) first")}return new l(this,e)},getSyncInterval:function(){return f.syncInterval},setSyncInterval:function(e){if(!o(e))throw e+" is not a valid sync interval";var t=f.syncInterval;f.syncInterval=parseInt(e,10),this._emit("sync-interval-change",{oldValue:t,newValue:e})},getBackgroundSyncInterval:function(){return f.backgroundSyncInterval},setBackgroundSyncInterval:function(e){if(!o(e))throw e+" is not a valid sync interval";var t=f.backgroundSyncInterval;f.backgroundSyncInterval=parseInt(e,10),this._emit("sync-interval-change",{oldValue:t,newValue:e})},getCurrentSyncInterval:function(){return f.isBackground?f.backgroundSyncInterval:f.syncInterval},getRequestTimeout:function(){return f.requestTimeout},setRequestTimeout:function(e){f.requestTimeout=parseInt(e,10)},syncCycle:function(){this.sync.stopped||(this.on("sync-done",function(){m("[Sync] Sync done. Setting timer to",this.getCurrentSyncInterval()),this.sync.stopped||(this._syncTimer&&(clearTimeout(this._syncTimer),this._syncTimer=void 0),this._syncTimer=setTimeout(this.sync.sync.bind(this.sync),this.getCurrentSyncInterval()))}.bind(this)),this.sync.sync())},startSync:function(){return f.cache?(this.sync.stopped=!1,this.syncStopped=!1,this.sync.sync()):(console.warn("Nothing to sync, because caching is disabled."),Promise.resolve())},stopSync:function(){clearTimeout(this._syncTimer),this._syncTimer=void 0,this.sync?(m("[Sync] Stopping sync"),this.sync.stopped=!0):(m("[Sync] Will instantiate sync stopped"),this.syncStopped=!0)}},b.util=a,Object.defineProperty(b.prototype,"connected",{get:function(){return this.remote.connected}});var _=r(15);Object.defineProperty(b.prototype,"access",{get:function(){var e=new _;return Object.defineProperty(this,"access",{value:e}),e},configurable:!0});var w=r(16);Object.defineProperty(b.prototype,"caching",{configurable:!0,get:function(){var e=new w;return Object.defineProperty(this,"caching",{value:e}),e}}),e.exports=b,r(31)},function(e,t,r){"use strict";function n(e){this.defaultValue=e,this._storage={},this.set=this.justSet,this.delete=this.justDelete}function o(e){e._dropboxOrigSync||(e._dropboxOrigSync=e.sync.sync.bind(e.sync),e.sync.sync=function(){return this.dropbox.fetchDelta.apply(this.dropbox,arguments).then(e._dropboxOrigSync,function(t){return e._emit("error",new v.SyncError(t)),Promise.reject(t)})}.bind(e))}function i(e){e._dropboxOrigSync&&(e.sync.sync=e._dropboxOrigSync,delete e._dropboxOrigSync)}function s(e){e._origBaseClientGetItemURL||(e._origBaseClientGetItemURL=p.prototype.getItemURL,p.prototype.getItemURL=function(){throw new Error("getItemURL is not implemented for Dropbox yet")})}function a(e){e._origBaseClientGetItemURL&&(p.prototype.getItemURL=e._origBaseClientGetItemURL,delete e._origBaseClientGetItemURL)}function u(e){e._origRemote||(e._origRemote=e.remote,e.remote=e.dropbox)}function c(e){e._origRemote&&(e.remote=e._origRemote,delete e._origRemote)}function h(e){u(e),e.sync?o(e):e.on("connected",function(){e.sync&&o(e)}),s(e)}function l(e){c(e),i(e),a(e)}var f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},d=r(4),p=r(5),m=r(7),g=r(0),y=r(2),v=r(8),b=void 0,_="remotestorage:dropbox",w=g.isFolder,P=g.cleanPath,E=g.shouldBeTreatedAsBinary,S=g.readBinaryData,T=function(e){return P("/remotestorage/"+e).replace(/\/$/,"")},A=function(e,t){return new RegExp("^"+t.join("\\/")+"(\\/|$)").test(e.error_summary)},R=function(e){return e instanceof ArrayBuffer||m.isArrayBufferView(e)};n.prototype={get:function(e){e=e.toLowerCase();var t=this._storage[e];return void 0===t&&(t=this.defaultValue,this._storage[e]=t),t},propagateSet:function(e,t){return e=e.toLowerCase(),this._storage[e]===t?t:(this._propagate(e,t),this._storage[e]=t,t)},propagateDelete:function(e){return e=e.toLowerCase(),this._propagate(e,this._storage[e]),delete this._storage[e]},_activatePropagation:function(){return this.set=this.propagateSet,this.delete=this.propagateDelete,!0},justSet:function(e,t){return e=e.toLowerCase(),this._storage[e]=t,t},justDelete:function(e){return e=e.toLowerCase(),delete this._storage[e]},_propagate:function(e,t){for(var r=e.split("/").slice(0,-1),n="",o=0,i=r.length;o157286400)return Promise.reject(new Error("Cannot upload file larger than 150MB"));var s,a=n&&(n.ifMatch||"*"===n.ifNoneMatch),u={body:t,contentType:r,path:e};return s=a?this._getMetadata(e).then(function(e){return n&&"*"===n.ifNoneMatch&&e?Promise.resolve({statusCode:412,revision:e.rev}):n&&n.ifMatch&&e&&e.rev!==n.ifMatch?Promise.resolve({statusCode:412,revision:e.rev}):o._uploadSimple(u)}):o._uploadSimple(u),s.then(function(t){return o._shareIfNeeded(e),t})},delete:function(e,t){var r=this;if(!this.connected)throw new Error("not connected (path: "+e+")");var n=this._revCache.get(e);return t&&t.ifMatch&&n&&t.ifMatch!==n?Promise.resolve({statusCode:412,revision:n}):t&&t.ifMatch?this._getMetadata(e).then(function(n){return t&&t.ifMatch&&n&&n.rev!==t.ifMatch?Promise.resolve({statusCode:412,revision:n.rev}):r._deleteSimple(e)}):this._deleteSimple(e)},_shareIfNeeded:function(e){e.match(/^\/public\/.*[^\/]$/)&&void 0===this._itemRefs[e]&&this.share(e)},share:function(e){var t=this,r={body:{path:T(e)}};return this._request("POST","https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings",r).then(function(r){if(200!==r.status&&409!==r.status)return Promise.reject(new Error("Invalid response status:"+r.status));var n;try{n=JSON.parse(r.responseText)}catch(e){return Promise.reject(new Error("Invalid response body: "+r.responseText))}return 409===r.status?A(n,["shared_link_already_exists"])?t._getSharedLink(e):Promise.reject(new Error("API error: "+n.error_summary)):Promise.resolve(n.url)}).then(function(r){return t._itemRefs[e]=r,b&&localStorage.setItem(_+":shares",JSON.stringify(t._itemRefs)),Promise.resolve(r)},function(t){return t.message='Sharing Dropbox file or folder ("'+e+'") failed: '+t.message,Promise.reject(t)})},info:function(){return this._request("POST","https://api.dropboxapi.com/2/users/get_current_account",{}).then(function(e){var t=e.responseText;try{t=JSON.parse(t)}catch(e){return Promise.reject(new Error("Could not query current account info: Invalid API response: "+t))}return Promise.resolve({email:t.email})})},_request:function(e,t,r){var n=this;return r.headers||(r.headers={}),r.headers.Authorization="Bearer "+this.token,"object"!==f(r.body)||R(r.body)||(r.body=JSON.stringify(r.body),r.headers["Content-Type"]="application/json; charset=UTF-8"),this.rs._emit("wire-busy",{method:e,isFolder:w(t)}),m.request.call(this,e,t,r).then(function(o){return o&&503===o.status?(n.online&&(n.online=!1,n.rs._emit("network-offline")),setTimeout(n._request(e,t,r),3210)):(n.online||(n.online=!0,n.rs._emit("network-online")),n.rs._emit("wire-done",{method:e,isFolder:w(t),success:!0}),Promise.resolve(o))},function(r){return n.online&&(n.online=!1,n.rs._emit("network-offline")),n.rs._emit("wire-done",{method:e,isFolder:w(t),success:!1}),Promise.reject(r)})},fetchDelta:function(){var e=Array.prototype.slice.call(arguments),t=this;return t._revCache=new n("rev"),function r(n){var o="https://api.dropboxapi.com/2/files/list_folder",i=void 0;return"string"==typeof n?(o+="/continue",i={cursor:n}):i={path:"/remotestorage",recursive:!0,include_deleted:!0},t._request("POST",o,{body:i}).then(function(n){if(401===n.status)return t.rs._emit("error",new d.Unauthorized),Promise.resolve(e);if(200!==n.status&&409!==n.status)return Promise.reject(new Error("Invalid response status: "+n.status));var o=void 0;try{o=JSON.parse(n.responseText)}catch(e){return Promise.reject(new Error("Invalid response body: "+n.responseText))}if(409===n.status){if(!A(o,["path","not_found"]))return Promise.reject(new Error("API returned an error: "+o.error_summary));o={cursor:null,entries:[],has_more:!1}}return o.entries.forEach(function(e){var r=e.path_lower.substr("/remotestorage".length);"deleted"===e[".tag"]?(t._revCache.set(r,null),t._revCache.set(r+"/",null)):"file"===e[".tag"]&&t._revCache.set(r,e.rev)}),o.has_more?r(o.cursor):void 0}).catch(function(e){return"timeout"===e||e instanceof ProgressEvent?Promise.resolve():Promise.reject(e)})}().then(void 0,function(e){return"object"===(void 0===e?"undefined":f(e))&&"message"in e?e.message="Dropbox: fetchDelta: "+e.message:e="Dropbox: fetchDelta: "+e,Promise.reject(e)}).then(function(){return t._revCache&&t._revCache._activatePropagation(),Promise.resolve(e)})},_getMetadata:function(e){var t={path:T(e)};return this._request("POST","https://api.dropboxapi.com/2/files/get_metadata",{body:t}).then(function(e){if(200!==e.status&&409!==e.status)return Promise.reject(new Error("Invalid response status:"+e.status));var t=void 0;try{t=JSON.parse(e.responseText)}catch(t){return Promise.reject(new Error("Invalid response body: "+e.responseText))}return 409===e.status?A(t,["path","not_found"])?Promise.resolve():Promise.reject(new Error("API error: "+t.error_summary)):Promise.resolve(t)}).then(void 0,function(t){return t.message='Could not load metadata for file or folder ("'+e+'"): '+t.message,Promise.reject(t)})},_uploadSimple:function(e){var t=this,r={path:T(e.path),mode:{".tag":"overwrite"},mute:!0};return e.ifMatch&&(r.mode={".tag":"update",update:e.ifMatch}),this._request("POST","https://content.dropboxapi.com/2/files/upload",{body:e.body,headers:{"Content-Type":"application/octet-stream","Dropbox-API-Arg":JSON.stringify(r)}}).then(function(r){if(200!==r.status&&409!==r.status)return Promise.resolve({statusCode:r.status});var n=r.responseText;try{n=JSON.parse(n)}catch(e){return Promise.reject(new Error("Invalid API result: "+n))}return 409===r.status?A(n,["path","conflict"])?t._getMetadata(e.path).then(function(e){return Promise.resolve({statusCode:412,revision:e.rev})}):Promise.reject(new Error("API error: "+n.error_summary)):(t._revCache.propagateSet(e.path,n.rev),Promise.resolve({statusCode:r.status,revision:n.rev}))})},_deleteSimple:function(e){var t=this,r={path:T(e)};return this._request("POST","https://api.dropboxapi.com/2/files/delete",{body:r}).then(function(e){if(200!==e.status&&409!==e.status)return Promise.resolve({statusCode:e.status});var t=e.responseText;try{t=JSON.parse(t)}catch(e){return Promise.reject(new Error("Invalid response body: "+t))}return 409===e.status?A(t,["path_lookup","not_found"])?Promise.resolve({statusCode:404}):Promise.reject(new Error("API error: "+t.error_summary)):Promise.resolve({statusCode:200})}).then(function(r){return 200!==r.statusCode&&404!==r.statusCode||(t._revCache.delete(e),delete t._itemRefs[e]),Promise.resolve(r)},function(t){return t.message='Could not delete Dropbox file or folder ("'+e+'"): '+t.message,Promise.reject(t)})},_getSharedLink:function(e){var t={body:{path:T(e),direct_only:!0}};return this._request("POST","https://api.dropbox.com/2/sharing/list_shared_links",t).then(function(e){if(200!==e.status&&409!==e.status)return Promise.reject(new Error("Invalid response status: "+e.status));var t;try{t=JSON.parse(e.responseText)}catch(t){return Promise.reject(new Error("Invalid response body: "+e.responseText))}return 409===e.status?Promise.reject(new Error("API error: "+e.error_summary)):t.links.length?Promise.resolve(t.links[0].url):Promise.reject(new Error("No links returned"))},function(t){return t.message='Could not get link to a shared file or folder ("'+e+'"): '+t.message,Promise.reject(t)})}},k._rs_init=function(e){b=g.localStorageAvailable(),e.apiKeys.dropbox&&(e.dropbox=new k(e)),"dropbox"===e.backend&&h(e)},k._rs_supported=function(){return!0},k._rs_cleanup=function(e){l(e),b&&localStorage.removeItem(_),e.setBackend(void 0)},e.exports=k},function(e,t,r){"use strict";var n=r(2),o="undefined"!=typeof window?"browser":"node",i={},s=function(){return i};s.isBrowser=function(){return"browser"===o},s.isNode=function(){return"node"===o},s.goBackground=function(){s._emit("background")},s.goForeground=function(){s._emit("foreground")},s._rs_init=function(){function e(){document[i.hiddenProperty]?s.goBackground():s.goForeground()}n(s,"background","foreground"),"browser"===o&&(void 0!==document.hidden?(i.hiddenProperty="hidden",i.visibilityChangeEvent="visibilitychange"):void 0!==document.mozHidden?(i.hiddenProperty="mozHidden",i.visibilityChangeEvent="mozvisibilitychange"):void 0!==document.msHidden?(i.hiddenProperty="msHidden",i.visibilityChangeEvent="msvisibilitychange"):void 0!==document.webkitHidden&&(i.hiddenProperty="webkitHidden",i.visibilityChangeEvent="webkitvisibilitychange"),document.addEventListener(i.visibilityChangeEvent,e,!1),e())},s._rs_cleanup=function(){},e.exports=s},function(e,t,r){"use strict";function n(e){return"/"===e.substr(-1)&&(e=e.substr(0,e.length-1)),decodeURIComponent(e)}function o(e){return e.replace(/[^\/]+\/?$/,"")}function i(e){var t=e.split("/");return"/"===e.substr(-1)?t[t.length-2]+"/":t[t.length-1]}function s(e){return b(y+"/"+e)}function a(e){e._origBaseClientGetItemURL||(e._origBaseClientGetItemURL=l.prototype.getItemURL,l.prototype.getItemURL=function(){throw new Error("getItemURL is not implemented for Google Drive yet")})}function u(e){e._origBaseClientGetItemURL&&(l.prototype.getItemURL=e._origBaseClientGetItemURL,delete e._origBaseClientGetItemURL)}var c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},h=r(4),l=r(5),f=r(7),d=r(2),p=r(0),m="https://www.googleapis.com",g="remotestorage:googledrive",y="/remotestorage",v=p.isFolder,b=p.cleanPath,_=p.shouldBeTreatedAsBinary,w=p.readBinaryData,P=void 0,E=function(e){this.maxAge=e,this._items={}};E.prototype={get:function(e){var t=this._items[e],r=(new Date).getTime();return t&&t.t>=r-this.maxAge?t.v:void 0},set:function(e,t){this._items[e]={v:t,t:(new Date).getTime()}}};var S=function(e,t){if(d(this,"connected","not-connected"),this.rs=e,this.clientId=t,this._fileIdCache=new E(300),P=p.localStorageAvailable()){var r=void 0;try{r=JSON.parse(localStorage.getItem(g))}catch(e){}r&&this.configure(r)}};S.prototype={connected:!1,online:!0,configure:function(e){var t=this;void 0!==e.userAddress&&(this.userAddress=e.userAddress),void 0!==e.token&&(this.token=e.token);var r=function(){P&&localStorage.setItem(g,JSON.stringify({userAddress:this.userAddress,token:this.token}))},n=function(){this.connected=!1,delete this.token,P&&localStorage.removeItem(g)};this.token?(this.connected=!0,this.userAddress?(this._emit("connected"),r.apply(this)):this.info().then(function(e){t.userAddress=e.user.emailAddress,t._emit("connected"),r.apply(t)}).catch(function(){n.apply(t),t.rs._emit("error",new Error("Could not fetch user info."))})):n.apply(this)},connect:function(){this.rs.setBackend("googledrive"),h(this.rs,"https://accounts.google.com/o/oauth2/auth","https://www.googleapis.com/auth/drive",String(h.getLocation()),this.clientId)},stopWaitingForToken:function(){this.connected||this._emit("not-connected")},get:function(e,t){return"/"===e.substr(-1)?this._getFolder(s(e),t):this._getFile(s(e),t)},put:function(e,t,r,n){function o(e){if(e.status>=200&&e.status<300){var t=JSON.parse(e.responseText),r=t.etag.substring(1,t.etag.length-1);return Promise.resolve({statusCode:200,contentType:t.mimeType,revision:r})}return 412===e.status?Promise.resolve({statusCode:412,revision:"conflict"}):Promise.reject("PUT failed with status "+e.status+" ("+e.responseText+")")}var i=this,a=s(e);return this._getFileId(a).then(function(e){return e?n&&"*"===n.ifNoneMatch?o({status:412}):i._updateFile(e,a,t,r,n).then(o):i._createFile(a,t,r,n).then(o)})},delete:function(e,t){var r=this,n=s(e);return this._getFileId(n).then(function(e){return e?r._getMeta(e).then(function(n){var o=void 0;return"object"===(void 0===n?"undefined":c(n))&&"string"==typeof n.etag&&(o=n.etag.substring(1,n.etag.length-1)),t&&t.ifMatch&&t.ifMatch!==o?{statusCode:412,revision:o}:r._request("DELETE",m+"/drive/v2/files/"+e,{}).then(function(e){return 200===e.status||204===e.status?{statusCode:200}:Promise.reject("Delete failed: "+e.status+" ("+e.responseText+")")})}):Promise.resolve({statusCode:200})})},info:function(){return this._request("GET","https://www.googleapis.com/drive/v2/about?fields=user",{}).then(function(e){try{var t=JSON.parse(e.responseText);return Promise.resolve(t)}catch(e){return Promise.reject(e)}})},_updateFile:function(e,t,r,n,o){var i=this,s={mimeType:n},a={"Content-Type":"application/json; charset=UTF-8"};return o&&o.ifMatch&&(a["If-Match"]='"'+o.ifMatch+'"'),this._request("PUT",m+"/upload/drive/v2/files/"+e+"?uploadType=resumable",{body:JSON.stringify(s),headers:a}).then(function(e){return 412===e.status?e:i._request("PUT",e.getResponseHeader("Location"),{body:n.match(/^application\/json/)?JSON.stringify(r):r})})},_createFile:function(e,t,r){var o=this;return this._getParentId(e).then(function(s){var a=i(e),u={title:n(a),mimeType:r,parents:[{kind:"drive#fileLink",id:s}]};return o._request("POST",m+"/upload/drive/v2/files?uploadType=resumable",{body:JSON.stringify(u),headers:{"Content-Type":"application/json; charset=UTF-8"}}).then(function(e){return o._request("POST",e.getResponseHeader("Location"),{body:r.match(/^application\/json/)?JSON.stringify(t):t})})})},_getFile:function(e,t){var r=this;return this._getFileId(e).then(function(e){return r._getMeta(e).then(function(e){var n=void 0;if("object"===(void 0===e?"undefined":c(e))&&"string"==typeof e.etag&&(n=e.etag.substring(1,e.etag.length-1)),t&&t.ifNoneMatch&&n===t.ifNoneMatch)return Promise.resolve({statusCode:304});var o={};if(!e.downloadUrl){if(!e.exportLinks||!e.exportLinks["text/html"])return Promise.resolve({statusCode:200,body:"",contentType:e.mimeType,revision:n});e.mimeType+=";export=text/html",e.downloadUrl=e.exportLinks["text/html"]}return r._request("GET",e.downloadUrl,o).then(function(t){var r=t.response;if(e.mimeType.match(/^application\/json/))try{r=JSON.parse(r)}catch(e){}else if(_(r,e.mimeType))return w(r,e.mimeType).then(function(t){return{statusCode:200,body:t,contentType:e.mimeType,revision:n}});return Promise.resolve({statusCode:200,body:r,contentType:e.mimeType,revision:n})})})})},_getFolder:function(e){var t=this;return this._getFileId(e).then(function(r){var n=void 0,o=void 0,i=void 0,s=void 0,a=void 0;return r?(n="'"+r+"' in parents",o="items(downloadUrl,etag,fileSize,id,mimeType,title)",t._request("GET",m+"/drive/v2/files?q="+encodeURIComponent(n)+"&fields="+encodeURIComponent(o)+"&maxResults=1000",{}).then(function(r){if(200!==r.status)return Promise.reject("request failed or something: "+r.status);try{i=JSON.parse(r.responseText)}catch(e){return Promise.reject("non-JSON response from GoogleDrive")}a={};var n=!0,o=!1,u=void 0;try{for(var c,h=i.items[Symbol.iterator]();!(n=(c=h.next()).done);n=!0){var l=c.value;s=l.etag.substring(1,l.etag.length-1),"application/vnd.google-apps.folder"===l.mimeType?(t._fileIdCache.set(e+l.title+"/",l.id),a[l.title+"/"]={ETag:s}):(t._fileIdCache.set(e+l.title,l.id),a[l.title]={ETag:s,"Content-Type":l.mimeType,"Content-Length":l.fileSize})}}catch(e){o=!0,u=e}finally{try{!n&&h.return&&h.return()}finally{if(o)throw u}}return Promise.resolve({statusCode:200,body:a,contentType:"application/json; charset=UTF-8",revision:void 0})})):Promise.resolve({statusCode:404})})},_getParentId:function(e){var t=this,r=o(e);return this._getFileId(r).then(function(e){return e?Promise.resolve(e):t._createFolder(r)})},_createFolder:function(e){var t=this;return this._getParentId(e).then(function(r){return t._request("POST",m+"/drive/v2/files",{body:JSON.stringify({title:n(i(e)),mimeType:"application/vnd.google-apps.folder",parents:[{id:r}]}),headers:{"Content-Type":"application/json; charset=UTF-8"}}).then(function(e){var t=JSON.parse(e.responseText);return Promise.resolve(t.id)})})},_getFileId:function(e){var t=this,r=void 0;return"/"===e?Promise.resolve("root"):(r=this._fileIdCache.get(e))?Promise.resolve(r):this._getFolder(o(e)).then(function(){return r=t._fileIdCache.get(e),r?Promise.resolve(r):"/"===e.substr(-1)?t._createFolder(e).then(function(){return t._getFileId(e)}):Promise.resolve()})},_getMeta:function(e){return this._request("GET",m+"/drive/v2/files/"+e,{}).then(function(t){return 200===t.status?Promise.resolve(JSON.parse(t.responseText)):Promise.reject("request (getting metadata for "+e+") failed with status: "+t.status)})},_request:function(e,t,r){var n=this;return r.headers||(r.headers={}),r.headers.Authorization="Bearer "+this.token,this.rs._emit("wire-busy",{method:e,isFolder:v(t)}),f.request.call(this,e,t,r).then(function(r){return r&&401===r.status?void n.connect():(n.online||(n.online=!0,n.rs._emit("network-online")),n.rs._emit("wire-done",{method:e,isFolder:v(t),success:!0}),Promise.resolve(r))},function(r){return n.online&&(n.online=!1,n.rs._emit("network-offline")),n.rs._emit("wire-done",{method:e,isFolder:v(t),success:!1}),Promise.reject(r)})}},S._rs_init=function(e){var t=e.apiKeys.googledrive;t&&(e.googledrive=new S(e,t.clientId),"googledrive"===e.backend&&(e._origRemote=e.remote,e.remote=e.googledrive,a(e)))},S._rs_supported=function(){return!0},S._rs_cleanup=function(e){e.setBackend(void 0),e._origRemote&&(e.remote=e._origRemote,delete e._origRemote),u(e)},e.exports=S},function(e,t,r){"use strict";var n,o,i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s=r(1),a=r(0),u=r(24),c={},h=function(e){return new Promise(function(t,r){return e in c?t(c[e]):new u({tls_only:!1,uri_fallback:!0,request_timeout:5e3}).lookup(e,function(n,a){if(n)return r(n);if("object"!==i(a.idx.links.remotestorage)||"number"!=typeof a.idx.links.remotestorage.length||a.idx.links.remotestorage.length<=0)return s("[Discover] WebFinger record for "+e+" does not have remotestorage defined in the links section ",JSON.stringify(a.json)),r("WebFinger record for "+e+" does not have remotestorage defined in the links section.");var u=a.idx.links.remotestorage[0],h=u.properties["http://tools.ietf.org/html/rfc6749#section-4.2"]||u.properties["auth-endpoint"],l=u.properties["http://remotestorage.io/spec/version"]||u.type;return c[e]={href:u.href,storageType:l,authURL:h,properties:u.properties},o&&(localStorage["remotestorage:discover"]=JSON.stringify({cache:c})),t(c[e])})})};h.DiscoveryError=function(e){this.name="DiscoveryError",this.message=e,this.stack=(new Error).stack},h.DiscoveryError.prototype=Object.create(Error.prototype),h.DiscoveryError.prototype.constructor=h.DiscoveryError,h._rs_init=function(){if(o=a.localStorageAvailable()){var e;try{e=JSON.parse(localStorage["remotestorage:discover"])}catch(e){}e&&(c=e.cache)}},h._rs_supported=function(){return n=!!a.globalContext.XMLHttpRequest},h._rs_cleanup=function(){o&&delete localStorage["remotestorage:discover"]},e.exports=h},function(e,t,r){"use strict";var n=function(){this.reset()};n.prototype={claim:function(e,t){if("string"!=typeof e||-1!==e.indexOf("/")||0===e.length)throw new Error("Scope should be a non-empty string without forward slashes");if(!t.match(/^rw?$/))throw new Error("Mode should be either 'r' or 'rw'");this._adjustRootPaths(e),this.scopeModeMap[e]=t},get:function(e){return this.scopeModeMap[e]},remove:function(e){var t,r={};for(t in this.scopeModeMap)r[t]=this.scopeModeMap[t];this.reset(),delete r[e];for(t in r)this.set(t,r[t])},checkPermission:function(e,t){var r=this.get(e);return r&&("r"===t||"rw"===r)},checkPathPermission:function(e,t){return!!this.checkPermission("*",t)||!!this.checkPermission(this._getModuleName(e),t)},reset:function(){this.rootPaths=[],this.scopeModeMap={}},_getModuleName:function(e){if("/"!==e[0])throw new Error("Path should start with a slash");var t=e.replace(/^\/public/,"").match(/^\/([^\/]*)\//);return t?t[1]:"*"},_adjustRootPaths:function(e){"*"in this.scopeModeMap||"*"===e?this.rootPaths=["/"]:e in this.scopeModeMap||(this.rootPaths.push("/"+e+"/"),this.rootPaths.push("/public/"+e+"/"))},_scopeNameForParameter:function(e){if("*"===e.name&&this.storageType){if("2012.04"===this.storageType)return"";if(this.storageType.match(/remotestorage-0[01]/))return"root"}return e.name},setStorageType:function(e){this.storageType=e}},Object.defineProperty(n.prototype,"scopes",{get:function(){return Object.keys(this.scopeModeMap).map(function(e){return{name:e,mode:this.scopeModeMap[e]}}.bind(this))}}),Object.defineProperty(n.prototype,"scopeParameter",{get:function(){return this.scopes.map(function(e){return this._scopeNameForParameter(e)+":"+e.mode}.bind(this)).join(" ")}}),n._rs_init=function(){},e.exports=n},function(e,t,r){"use strict";var n=r(0),o=r(1),i=n.containingFolder,s=function(){this.reset()};s.prototype={pendingActivations:[],set:function(e,t){if("string"!=typeof e)throw new Error("path should be a string");if(!n.isFolder(e))throw new Error("path should be a folder");if(this._remoteStorage&&this._remoteStorage.access&&!this._remoteStorage.access.checkPathPermission(e,"r"))throw new Error('No access to path "'+e+'". You have to claim access to it first.');if(!t.match(/^(FLUSH|SEEN|ALL)$/))throw new Error("strategy should be 'FLUSH', 'SEEN', or 'ALL'");this._rootPaths[e]=t,"ALL"===t&&(this.activateHandler?this.activateHandler(e):this.pendingActivations.push(e))},enable:function(e){this.set(e,"ALL")},disable:function(e){this.set(e,"FLUSH")},onActivate:function(e){var t;for(o("[Caching] Setting activate handler",e,this.pendingActivations),this.activateHandler=e,t=0;t0&&(r+=l.suffices["*"]?n||",":",",l.suffices["*"]&&s&&(r+=l.name+"=")),r+=i?encodeURIComponent(f[d]).replace(/!/g,"%21"):e(f[d])}else if("object"==typeof f){s&&!l.suffices["*"]&&(r+=l.name+"=");var p=!0;for(var m in f)p||(r+=l.suffices["*"]?n||",":","),p=!1,r+=i?encodeURIComponent(m).replace(/!/g,"%21"):e(m),r+=l.suffices["*"]?"=":",",r+=i?encodeURIComponent(f[m]).replace(/!/g,"%21"):e(f[m])}else s&&(r+=l.name,a&&""===f||(r+="=")),null!=l.truncate&&(f=f.substring(0,l.truncate)),r+=i?encodeURIComponent(f).replace(/!/g,"%21"):e(f)}return r};return _.varNames=u,{prefix:o,substitution:_}}function r(e){if(!(this instanceof r))return new r(e);for(var n=e.split("{"),o=[n.shift()],i=[],s=[],a=[];n.length>0;){var u=n.shift(),c=u.split("}")[0],h=u.substring(c.length+1),l=t(c);s.push(l.substitution),i.push(l.prefix),o.push(h),a=a.concat(l.substitution.varNames)}this.fill=function(e){for(var t=o[0],r=0;r0&&"/"===t.charAt(e.length-1)||"#"===r.charAt(0)||"?"===r.charAt(0))return!0}return!1}function l(e){var t,r,n=new p,o={setErrorReporter:function(e){return"string"==typeof e?this.language(e):(r=e,!0)},addFormat:function(){n.addFormat.apply(n,arguments)},language:function(e){return e?(w[e]||(e=e.split("-")[0]),!!w[e]&&(t=e,e)):t},addLanguage:function(e,t){var r;for(r in y)t[r]&&!t[y[r]]&&(t[y[r]]=t[r]);var n=e.split("-")[0];if(w[n]){w[e]=Object.create(w[n]);for(r in t)void 0===w[n][r]&&(w[n][r]=t[r]),w[e][r]=t[r]}else w[e]=t,w[n]=t;return this},freshApi:function(e){var t=l();return e&&t.language(e),t},validate:function(e,o,i,s){var a=u(t),c=r?function(e,t,n){return r(e,t,n)||a(e,t,n)}:a,h=new p(n,!1,c,i,s);"string"==typeof o&&(o={$ref:o}),h.addSchema("",o);var l=h.validateAll(e,o,null,null,"");return!l&&s&&(l=h.banUnknownProperties(e,o)),this.error=l,this.missing=h.missing,this.valid=null===l,this.valid},validateResult:function(){var e={toString:function(){return this.valid?"valid":this.error.message}};return this.validate.apply(e,arguments),e},validateMultiple:function(e,o,i,s){var a=u(t),c=r?function(e,t,n){return r(e,t,n)||a(e,t,n)}:a,h=new p(n,!0,c,i,s);"string"==typeof o&&(o={$ref:o}),h.addSchema("",o),h.validateAll(e,o,null,null,""),s&&h.banUnknownProperties(e,o);var l={toString:function(){return this.valid?"valid":this.error.message}};return l.errors=h.errors,l.missing=h.missing,l.valid=0===l.errors.length,l},addSchema:function(){return n.addSchema.apply(n,arguments)},getSchema:function(){return n.getSchema.apply(n,arguments)},getSchemaMap:function(){return n.getSchemaMap.apply(n,arguments)},getSchemaUris:function(){return n.getSchemaUris.apply(n,arguments)},getMissingUris:function(){return n.getMissingUris.apply(n,arguments)},dropSchemas:function(){n.dropSchemas.apply(n,arguments)},defineKeyword:function(){n.defineKeyword.apply(n,arguments)},defineError:function(e,t,r){if("string"!=typeof e||!/^[A-Z]+(_[A-Z]+)*$/.test(e))throw new Error("Code name must be a string in UPPER_CASE_WITH_UNDERSCORES");if("number"!=typeof t||t%1!=0||t<1e4)throw new Error("Code number must be an integer > 10000");if(void 0!==y[e])throw new Error("Error already defined: "+e+" as "+y[e]);if(void 0!==v[t])throw new Error("Error code already used: "+v[t]+" as "+t);y[e]=t,v[t]=e,_[e]=_[t]=r;for(var n in w){var o=w[n];o[e]&&(o[t]=o[t]||o[e])}},reset:function(){n.reset(),this.error=null,this.missing=[],this.valid=!0},missing:[],error:null,valid:!0,normSchema:a,resolveUrl:i,getDocumentUri:s,errorCodes:y};return o.language(e||"en"),o}Object.keys||(Object.keys=function(){var e=Object.prototype.hasOwnProperty,t=!{toString:null}.propertyIsEnumerable("toString"),r=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],n=r.length;return function(o){if("object"!=typeof o&&"function"!=typeof o||null===o)throw new TypeError("Object.keys called on non-object");var i=[];for(var s in o)e.call(o,s)&&i.push(s);if(t)for(var a=0;a>>0;if(0===r)return-1;var n=0;if(arguments.length>1&&(n=Number(arguments[1]),n!==n?n=0:0!==n&&n!==1/0&&n!==-1/0&&(n=(n>0||-1)*Math.floor(Math.abs(n)))),n>=r)return-1;for(var o=n>=0?n:Math.max(r-Math.abs(n),0);o=m&&nt.maximum)return this.createError(y.NUMBER_MAXIMUM,{value:e,maximum:t.maximum},"","/maximum",null,e,t);if(t.exclusiveMaximum&&e===t.maximum)return this.createError(y.NUMBER_MAXIMUM_EXCLUSIVE,{value:e,maximum:t.maximum},"","/exclusiveMaximum",null,e,t)}return null},p.prototype.validateNaN=function(e,t){return"number"!=typeof e?null:!0===isNaN(e)||e===1/0||e===-1/0?this.createError(y.NUMBER_NOT_A_NUMBER,{value:e},"","/type",null,e,t):null},p.prototype.validateString=function(e,t,r){return this.validateStringLength(e,t,r)||this.validateStringPattern(e,t,r)||null},p.prototype.validateStringLength=function(e,t){return"string"!=typeof e?null:void 0!==t.minLength&&e.lengtht.maxLength?this.createError(y.STRING_LENGTH_LONG,{length:e.length,maximum:t.maxLength},"","/maxLength",null,e,t):null},p.prototype.validateStringPattern=function(e,t){if("string"!=typeof e||"string"!=typeof t.pattern&&!(t.pattern instanceof RegExp))return null;var r;if(t.pattern instanceof RegExp)r=t.pattern;else{var n,o="",i=t.pattern.match(/^\/(.+)\/([img]*)$/);i?(n=i[1],o=i[2]):n=t.pattern,r=new RegExp(n,o)}return r.test(e)?null:this.createError(y.STRING_PATTERN,{pattern:t.pattern},"","/pattern",null,e,t)},p.prototype.validateArray=function(e,t,r){return Array.isArray(e)?this.validateArrayLength(e,t,r)||this.validateArrayUniqueItems(e,t,r)||this.validateArrayItems(e,t,r)||null:null},p.prototype.validateArrayLength=function(e,t){var r;return void 0!==t.minItems&&e.lengtht.maxItems&&(r=this.createError(y.ARRAY_LENGTH_LONG,{length:e.length,maximum:t.maxItems},"","/maxItems",null,e,t),this.handleError(r))?r:null},p.prototype.validateArrayUniqueItems=function(e,t){if(t.uniqueItems)for(var r=0;rt.maxProperties&&(r=this.createError(y.OBJECT_PROPERTIES_MAXIMUM,{propertyCount:n.length,maximum:t.maxProperties},"","/maxProperties",null,e,t),this.handleError(r))?r:null},p.prototype.validateObjectRequiredProperties=function(e,t){if(void 0!==t.required)for(var r=0;r=n())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n().toString(16)+" bytes");return 0|e}function m(e){return+e!=e&&(e=0),i.alloc(+e)}function g(e,t){if(i.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Y(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return K(e).length;default:if(n)return Y(e).length;t=(""+t).toLowerCase(),n=!0}}function y(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if(r>>>=0,t>>>=0,r<=t)return"";for(e||(e="utf8");;)switch(e){case"hex":return M(this,t,r);case"utf8":case"utf-8":return k(this,t,r);case"ascii":return C(this,t,r);case"latin1":case"binary":return O(this,t,r);case"base64":return R(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function v(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function b(e,t,r,n,o){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof t&&(t=i.from(t,n)),i.isBuffer(t))return 0===t.length?-1:_(e,t,r,n,o);if("number"==typeof t)return t&=255,i.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):_(e,[t],r,n,o);throw new TypeError("val must be string, number or Buffer")}function _(e,t,r,n,o){function i(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}var s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}var c;if(o){var h=-1;for(c=r;ca&&(r=a-u),c=r;c>=0;c--){for(var l=!0,f=0;fo&&(n=o):n=o;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var s=0;s239?4:i>223?3:i>191?2:1;if(o+a<=r){var u,c,h,l;switch(a){case 1:i<128&&(s=i);break;case 2:128==(192&(u=e[o+1]))&&(l=(31&i)<<6|63&u)>127&&(s=l);break;case 3:u=e[o+1],c=e[o+2],128==(192&u)&&128==(192&c)&&(l=(15&i)<<12|(63&u)<<6|63&c)>2047&&(l<55296||l>57343)&&(s=l);break;case 4:u=e[o+1],c=e[o+2],h=e[o+3],128==(192&u)&&128==(192&c)&&128==(192&h)&&(l=(15&i)<<18|(63&u)<<12|(63&c)<<6|63&h)>65535&&l<1114112&&(s=l)}}null===s?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),o+=a}return I(n)}function I(e){var t=e.length;if(t<=Z)return String.fromCharCode.apply(String,e);for(var r="",n=0;nn)&&(r=n);for(var o="",i=t;ir)throw new RangeError("Trying to access beyond buffer length")}function U(e,t,r,n,o,s){if(!i.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||te.length)throw new RangeError("Index out of range")}function j(e,t,r,n){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-r,2);o>>8*(n?o:1-o)}function B(e,t,r,n){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-r,4);o>>8*(n?o:3-o)&255}function L(e,t,r,n,o,i){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function D(e,t,r,n,o){return o||L(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38),X.write(e,t,r,n,23,4),r+4}function F(e,t,r,n,o){return o||L(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308),X.write(e,t,r,n,52,8),r+8}function q(e){if(e=J(e).replace(ee,""),e.length<2)return"";for(;e.length%4!=0;)e+="=";return e}function J(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function G(e){return e<16?"0"+e.toString(16):e.toString(16)}function Y(e,t){t=t||1/0;for(var r,n=e.length,o=null,i=[],s=0;s55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function z(e){for(var t=[],r=0;r>8,o=r%256,i.push(o),i.push(n);return i}function K(e){return $.toByteArray(q(e))}function V(e,t,r,n){for(var o=0;o=t.length||o>=e.length);++o)t[o+r]=e[o];return o}function W(e){return e!==e}/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */ -var $=r(21),X=r(22),Q=r(23);t.Buffer=i,t.SlowBuffer=m,t.INSPECT_MAX_BYTES=50,i.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=n(),i.poolSize=8192,i._augment=function(e){return e.__proto__=i.prototype,e},i.from=function(e,t,r){return s(null,e,t,r)},i.TYPED_ARRAY_SUPPORT&&(i.prototype.__proto__=Uint8Array.prototype,i.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&i[Symbol.species]===i&&Object.defineProperty(i,Symbol.species,{value:null,configurable:!0})),i.alloc=function(e,t,r){return u(null,e,t,r)},i.allocUnsafe=function(e){return c(null,e)},i.allocUnsafeSlow=function(e){return c(null,e)},i.isBuffer=function(e){return!(null==e||!e._isBuffer)},i.compare=function(e,t){if(!i.isBuffer(e)||!i.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,o=0,s=Math.min(r,n);o0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),""},i.prototype.compare=function(e,t,r,n,o){if(!i.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),t<0||r>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=r)return 0;if(n>=o)return-1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,o>>>=0,this===e)return 0;for(var s=o-n,a=r-t,u=Math.min(s,a),c=this.slice(n,o),h=e.slice(t,r),l=0;lo)&&(r=o),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return w(this,e,t,r);case"utf8":case"utf-8":return P(this,e,t,r);case"ascii":return E(this,e,t,r);case"latin1":case"binary":return S(this,e,t,r);case"base64":return T(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Z=4096;i.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t0&&(o*=256);)n+=this[e+--t]*o;return n},i.prototype.readUInt8=function(e,t){return t||x(e,1,this.length),this[e]},i.prototype.readUInt16LE=function(e,t){return t||x(e,2,this.length),this[e]|this[e+1]<<8},i.prototype.readUInt16BE=function(e,t){return t||x(e,2,this.length),this[e]<<8|this[e+1]},i.prototype.readUInt32LE=function(e,t){return t||x(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},i.prototype.readUInt32BE=function(e,t){return t||x(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},i.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||x(e,t,this.length);for(var n=this[e],o=1,i=0;++i=o&&(n-=Math.pow(2,8*t)),n},i.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||x(e,t,this.length);for(var n=t,o=1,i=this[e+--n];n>0&&(o*=256);)i+=this[e+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*t)),i},i.prototype.readInt8=function(e,t){return t||x(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},i.prototype.readInt16LE=function(e,t){t||x(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},i.prototype.readInt16BE=function(e,t){t||x(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},i.prototype.readInt32LE=function(e,t){return t||x(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},i.prototype.readInt32BE=function(e,t){return t||x(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},i.prototype.readFloatLE=function(e,t){return t||x(e,4,this.length),X.read(this,e,!0,23,4)},i.prototype.readFloatBE=function(e,t){return t||x(e,4,this.length),X.read(this,e,!1,23,4)},i.prototype.readDoubleLE=function(e,t){return t||x(e,8,this.length),X.read(this,e,!0,52,8)},i.prototype.readDoubleBE=function(e,t){return t||x(e,8,this.length),X.read(this,e,!1,52,8)},i.prototype.writeUIntLE=function(e,t,r,n){e=+e,t|=0,r|=0,n||U(this,e,t,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[t]=255&e;++i=0&&(i*=256);)this[t+o]=e/i&255;return t+r},i.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||U(this,e,t,1,255,0),i.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},i.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||U(this,e,t,2,65535,0),i.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):j(this,e,t,!0),t+2},i.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||U(this,e,t,2,65535,0),i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):j(this,e,t,!1),t+2},i.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||U(this,e,t,4,4294967295,0),i.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):B(this,e,t,!0),t+4},i.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||U(this,e,t,4,4294967295,0),i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):B(this,e,t,!1),t+4},i.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var o=Math.pow(2,8*r-1);U(this,e,t,r,o-1,-o)}var i=0,s=1,a=0;for(this[t]=255&e;++i>0)-a&255;return t+r},i.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var o=Math.pow(2,8*r-1);U(this,e,t,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+r},i.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||U(this,e,t,1,127,-128),i.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},i.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||U(this,e,t,2,32767,-32768),i.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):j(this,e,t,!0),t+2},i.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||U(this,e,t,2,32767,-32768),i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):j(this,e,t,!1),t+2},i.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||U(this,e,t,4,2147483647,-2147483648),i.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):B(this,e,t,!0),t+4},i.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||U(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):B(this,e,t,!1),t+4},i.prototype.writeFloatLE=function(e,t,r){return D(this,e,t,!0,r)},i.prototype.writeFloatBE=function(e,t,r){return D(this,e,t,!1,r)},i.prototype.writeDoubleLE=function(e,t,r){return F(this,e,t,!0,r)},i.prototype.writeDoubleBE=function(e,t,r){return F(this,e,t,!1,r)},i.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--o)e[o+t]=this[o+r];else if(s<1e3||!i.TYPED_ARRAY_SUPPORT)for(o=0;o>>=0,r=void 0===r?this.length:r>>>0,e||(e=0);var s;if("number"==typeof e)for(s=t;s0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}function o(e){return 3*e.length/4-n(e)}function i(e){var t,r,o,i,s,a=e.length;i=n(e),s=new l(3*a/4-i),r=i>0?a-4:a;var u=0;for(t=0;t>16&255,s[u++]=o>>8&255,s[u++]=255&o;return 2===i?(o=h[e.charCodeAt(t)]<<2|h[e.charCodeAt(t+1)]>>4,s[u++]=255&o):1===i&&(o=h[e.charCodeAt(t)]<<10|h[e.charCodeAt(t+1)]<<4|h[e.charCodeAt(t+2)]>>2,s[u++]=o>>8&255,s[u++]=255&o),s}function s(e){return c[e>>18&63]+c[e>>12&63]+c[e>>6&63]+c[63&e]}function a(e,t,r){for(var n,o=[],i=t;iu?u:s+16383));return 1===n?(t=e[r-1],o+=c[t>>2],o+=c[t<<4&63],o+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],o+=c[t>>10],o+=c[t>>4&63],o+=c[t<<2&63],o+="="),i.push(o),i.join("")}t.byteLength=o,t.toByteArray=i,t.fromByteArray=u;for(var c=[],h=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",d=0,p=f.length;d>1,h=-7,l=r?o-1:0,f=r?-1:1,d=e[t+l];for(l+=f,i=d&(1<<-h)-1,d>>=-h,h+=a;h>0;i=256*i+e[t+l],l+=f,h-=8);for(s=i&(1<<-h)-1,i>>=-h,h+=n;h>0;s=256*s+e[t+l],l+=f,h-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),i-=c}return(d?-1:1)*s*Math.pow(2,i-n)},t.write=function(e,t,r,n,o,i){var s,a,u,c=8*i-o-1,h=(1<>1,f=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:i-1,p=n?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),t+=s+l>=1?f/u:f*Math.pow(2,1-l),t*u>=2&&(s++,u/=2),s+l>=h?(a=0,s=h):s+l>=1?(a=(t*u-1)*Math.pow(2,o),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,o),s=0));o>=8;e[r+d]=255&a,d+=p,a/=256,o-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,c-=8);e[r+d-p]|=128*m}},function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},function(e,t,r){var n,o;/*! +/*! remotestorage.js 1.0.3, https://remotestorage.io, MIT licensed */ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("RemoteStorage",[],t):"object"==typeof exports?exports.RemoteStorage=t():e.RemoteStorage=t()}(window,function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=31)}([function(e,t,r){"use strict";var n=r(3);e.exports=function(){n.logging&&console.log.apply(console,arguments)}},function(e,t,r){"use strict";(function(t){var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};var n={logError:function(e){"string"==typeof e?console.error(e):console.error(e.message,e.stack)},globalContext:"undefined"!=typeof window?window:t,getGlobalContext:function(){return"undefined"!=typeof window?window:t},extend:function(e){return Array.prototype.slice.call(arguments,1).forEach(function(t){for(var r in t)e[r]=t[r]}),e},containingFolder:function(e){if(""===e)return"/";if(!e)throw"Path not given!";return e.replace(/\/+/g,"/").replace(/[^\/]+\/?$/,"")},isFolder:function(e){return"/"===e.substr(-1)},isDocument:function(e){return!n.isFolder(e)},baseName:function(e){var t=e.split("/");return n.isFolder(e)?t[t.length-2]+"/":t[t.length-1]},cleanPath:function(e){return e.replace(/\/+/g,"/").split("/").map(encodeURIComponent).join("/").replace(/'/g,"%27")},bindAll:function(e){for(var t in this)"function"==typeof e[t]&&(e[t]=e[t].bind(e))},equal:function(e,t,o){var i;if(o=o||[],(void 0===e?"undefined":r(e))!==(void 0===t?"undefined":r(t)))return!1;if("number"==typeof e||"boolean"==typeof e||"string"==typeof e)return e===t;if("function"==typeof e)return e.toString()===t.toString();if(e instanceof ArrayBuffer&&t instanceof ArrayBuffer&&(e=new Uint8Array(e),t=new Uint8Array(t)),e instanceof Array){if(e.length!==t.length)return!1;for(var s=0,a=e.length;s=0)continue;(u=o.slice()).push(t[i])}if(!n.equal(e[i],t[i],u))return!1}}return!0},deepClone:function(e){var t;return void 0===e?void 0:(function e(t,n){var o,i;if("object"===(void 0===t?"undefined":r(t))&&!Array.isArray(t)&&null!==t)for(o in t)"object"===r(t[o])&&null!==t[o]&&("[object ArrayBuffer]"===t[o].toString()?(n[o]=new ArrayBuffer(t[o].byteLength),i=new Int8Array(t[o]),new Int8Array(n[o]).set(i)):e(t[o],n[o]))}(e,t=JSON.parse(JSON.stringify(e))),t)},pathsFromRoot:function(e){for(var t=[e],r=e.replace(/\/$/,"").split("/");r.length>1;)r.pop(),t.push(r.join("/")+"/");return t},localStorageAvailable:function(){var e=n.getGlobalContext();if(!("localStorage"in e))return!1;try{return e.localStorage.setItem("rs-check",1),e.localStorage.removeItem("rs-check"),!0}catch(e){return!1}},shouldBeTreatedAsBinary:function(e,t){return t&&t.match(/charset=binary/)||/[\x00-\x1F]/.test(e)},readBinaryData:function(e,r){return new Promise(function(o){var i=void 0;if(n.globalContext.BlobBuilder=n.globalContext.BlobBuilder||n.globalContext.WebKitBlobBuilder,void 0!==n.globalContext.BlobBuilder){var s=new t.BlobBuilder;s.append(e),i=s.getBlob(r)}else i=new Blob([e],{type:r});var a=new FileReader;"function"==typeof a.addEventListener?a.addEventListener("loadend",function(){o(a.result)}):a.onloadend=function(){o(a.result)},a.readAsArrayBuffer(i)})}};e.exports=n}).call(this,r(9))},function(e,t,r){"use strict";var n=r(0),o={addEventListener:function(e,t){if("string"!=typeof e)throw new Error("Argument eventName should be a string");if("function"!=typeof t)throw new Error("Argument handler should be a function");n("[Eventhandling] Adding event listener",e),this._validateEvent(e),this._handlers[e].push(t)},removeEventListener:function(e,t){this._validateEvent(e);for(var r=this._handlers[e].length,n=0;n0&&(e.state=n)}else e[decodeURIComponent(r[0])]=decodeURIComponent(r[1]);return e},{})}var a,u=function e(t,r,n,s,a){if(o("[Authorize] authURL = ",r,"scope = ",n,"redirectUri = ",s,"clientId = ",a),!i.localStorageAvailable()&&"remotestorage"===t.backend){s+=s.indexOf("#")>0?"&":"#";var u={userAddress:t.remote.userAddress,href:t.remote.href,storageApi:t.remote.storageApi,properties:t.remote.properties};s+="rsDiscovery="+btoa(JSON.stringify(u))}var c=r,h=s.indexOf("#");if(c+=r.indexOf("?")>0?"&":"?",c+="redirect_uri="+encodeURIComponent(s.replace(/#.*$/,"")),c+="&scope="+encodeURIComponent(n),c+="&client_id="+encodeURIComponent(a),-1!==h&&h+1!==s.length&&(c+="&state="+encodeURIComponent(s.substring(h+1))),c+="&response_type=token",i.globalContext.cordova)return e.openWindow(c,s,"location=yes,clearsessioncache=yes,clearcache=yes").then(function(e){t.remote.configure({token:e.access_token})});e.setLocation(c)};u.IMPLIED_FAKE_TOKEN=!1,u.Unauthorized=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.name="Unauthorized",this.message=void 0===e?"App authorization expired or revoked.":e,void 0!==t.code&&(this.code=t.code),this.stack=(new Error).stack},u.Unauthorized.prototype=Object.create(Error.prototype),u.Unauthorized.prototype.constructor=u.Unauthorized,u.getLocation=function(){return document.location},u.setLocation=function(e){if("string"==typeof e)document.location.href=e;else{if("object"!==(void 0===e?"undefined":n(e)))throw"Invalid location "+e;document.location=e}},u.openWindow=function(e,t,r){return new Promise(function(n,o){var i=open(e,"_blank",r);if(!i||i.closed)return o("Authorization popup was blocked");var a=function(){return o("Authorization was canceled")};i.addEventListener("loadstart",function(e){if(0===e.url.indexOf(t)){i.removeEventListener("exit",a),i.close();var r=s(e.url);return r?n(r):o("Authorization error")}}),i.addEventListener("exit",a)})},u._rs_supported=function(){return"undefined"!=typeof document},u._rs_init=function(e){a=function(){var n=!1;if(r){if(r.error)throw"access_denied"===r.error?new u.Unauthorized("Authorization failed: access denied",{code:"access_denied"}):new u.Unauthorized("Authorization failed: "+r.error);r.rsDiscovery&&e.remote.configure(r.rsDiscovery),r.access_token&&(e.remote.configure({token:r.access_token}),n=!0),r.remotestorage&&(e.connect(r.remotestorage),n=!0),r.state&&(t=u.getLocation(),u.setLocation(t.href.split("#")[0]+"#"+r.state))}n||e.remote.stopWaitingForToken()};var t,r=s();r&&((t=u.getLocation()).hash=""),e.on("features-loaded",a)},u._rs_cleanup=function(e){e.removeEventListener("features-loaded",a)},e.exports=u},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=r(2),i=r(1),s=r(3),a=r(30),u=r(29),c=u.SchemaNotFound,h=function(e,t){if("/"!==t[t.length-1])throw"Not a folder: "+t;"/"===t&&(this.makePath=function(e){return("/"===e[0]?"":"/")+e}),this.storage=e,this.base=t;var r=this.base.split("/");r.length>2?this.moduleName=r[1]:this.moduleName="root",o(this,"change"),this.on=this.on.bind(this),e.onChange(this.base,this._fireChange.bind(this))};h.Types=u,h.prototype={scope:function(e){return new h(this.storage,this.makePath(e))},getListing:function(e,t){if("string"!=typeof e)e="";else if(e.length>0&&"/"!==e[e.length-1])return Promise.reject("Not a folder: "+e);return this.storage.get(this.makePath(e),t).then(function(e){return 404===e.statusCode?{}:e.body})},getAll:function(e,t){if("string"!=typeof e)e="";else if(e.length>0&&"/"!==e[e.length-1])return Promise.reject("Not a folder: "+e);return this.storage.get(this.makePath(e),t).then(function(r){if(404===r.statusCode)return{};if("object"===n(r.body)){var o=Object.keys(r.body);if(0===o.length)return{};var i=o.map(function(o){return this.storage.get(this.makePath(e+o),t).then(function(e){if("string"==typeof e.body)try{e.body=JSON.parse(e.body)}catch(e){}"object"===n(e.body)&&(r.body[o]=e.body)})}.bind(this));return Promise.all(i).then(function(){return r.body})}}.bind(this))},getFile:function(e,t){return"string"!=typeof e?Promise.reject("Argument 'path' of baseClient.getFile must be a string"):this.storage.get(this.makePath(e),t).then(function(e){return{data:e.body,contentType:e.contentType,revision:e.revision}})},storeFile:function(e,t,r){return"string"!=typeof e?Promise.reject("Argument 'mimeType' of baseClient.storeFile must be a string"):"string"!=typeof t?Promise.reject("Argument 'path' of baseClient.storeFile must be a string"):"string"!=typeof r&&"object"!==(void 0===r?"undefined":n(r))?Promise.reject("Argument 'body' of baseClient.storeFile must be a string, ArrayBuffer, or ArrayBufferView"):(this.storage.access.checkPathPermission(this.makePath(t),"rw")||console.warn("WARNING: Editing a document to which only read access ('r') was claimed"),this.storage.put(this.makePath(t),r,e).then(function(e){return 200===e.statusCode||201===e.statusCode?e.revision:Promise.reject("Request (PUT "+this.makePath(t)+") failed with status: "+e.statusCode)}.bind(this)))},getObject:function(e,t){return"string"!=typeof e?Promise.reject("Argument 'path' of baseClient.getObject must be a string"):this.storage.get(this.makePath(e),t).then(function(t){if("object"===n(t.body))return t.body;if("string"==typeof t.body)try{return JSON.parse(t.body)}catch(t){throw"Not valid JSON: "+this.makePath(e)}else if(void 0!==t.body&&200===t.statusCode)return Promise.reject("Not an object: "+this.makePath(e))}.bind(this))},storeObject:function(e,t,r){if("string"!=typeof e)return Promise.reject("Argument 'typeAlias' of baseClient.storeObject must be a string");if("string"!=typeof t)return Promise.reject("Argument 'path' of baseClient.storeObject must be a string");if("object"!==(void 0===r?"undefined":n(r)))return Promise.reject("Argument 'object' of baseClient.storeObject must be an object");this._attachType(r,e);try{var o=this.validate(r);if(!o.valid)return Promise.reject(o)}catch(e){return Promise.reject(e)}return this.storage.put(this.makePath(t),JSON.stringify(r),"application/json; charset=UTF-8").then(function(e){return 200===e.statusCode||201===e.statusCode?e.revision:Promise.reject("Request (PUT "+this.makePath(t)+") failed with status: "+e.statusCode)}.bind(this))},remove:function(e){return"string"!=typeof e?Promise.reject("Argument 'path' of baseClient.remove must be a string"):(this.storage.access.checkPathPermission(this.makePath(e),"rw")||console.warn("WARNING: Removing a document to which only read access ('r') was claimed"),this.storage.delete(this.makePath(e)))},getItemURL:function(e){if("string"!=typeof e)throw"Argument 'path' of baseClient.getItemURL must be a string";return this.storage.connected?(e=this._cleanPath(this.makePath(e)),this.storage.remote.href+e):void 0},cache:function(e,t){if("string"!=typeof e)throw"Argument 'path' of baseClient.cache must be a string";if(void 0===t)t="ALL";else if("string"!=typeof t)throw"Argument 'strategy' of baseClient.cache must be a string or undefined";if("FLUSH"!==t&&"SEEN"!==t&&"ALL"!==t)throw'Argument \'strategy\' of baseclient.cache must be one of ["FLUSH", "SEEN", "ALL"]';return this.storage.caching.set(this.makePath(e),t),this},flush:function(e){return this.storage.local.flush(e)},declareType:function(e,t,r){r||(r=t,t=this._defaultTypeURI(e)),h.Types.declare(this.moduleName,e,t,r)},validate:function(e){var t=h.Types.getSchema(e["@context"]);if(t)return a.validateResult(e,t);throw new c(e["@context"])},schemas:{configurable:!0,get:function(){return h.Types.inScope(this.moduleName)}},_defaultTypeURI:function(e){return"http://remotestorage.io/spec/modules/"+encodeURIComponent(this.moduleName)+"/"+encodeURIComponent(e)},_attachType:function(e,t){e["@context"]=h.Types.resolveAlias(this.moduleName+"/"+t)||this._defaultTypeURI(t)},makePath:function(e){return this.base+(e||"")},_fireChange:function(e){s.changeEvents[e.origin]&&(["new","old","lastCommon"].forEach(function(t){if((!e[t+"ContentType"]||/^application\/(.*)json(.*)/.exec(e[t+"ContentType"]))&&"string"==typeof e[t+"Value"])try{e[t+"Value"]=JSON.parse(e[t+"Value"])}catch(e){}}),this._emit("change",e))},_cleanPath:i.cleanPath},h._rs_init=function(){},e.exports=h},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=r(1),i=r(3),s=r(0),a=o.isFolder,u=o.isDocument,c=o.deepClone;function h(e){if("object"===(void 0===e?"undefined":n(e))&&"string"==typeof e.path)if(a(e.path)){if(e.local&&e.local.itemsMap)return e.local;if(e.common&&e.common.itemsMap)return e.common}else{if(e.local&&e.local.body&&e.local.contentType)return e.local;if(e.common&&e.common.body&&e.common.contentType)return e.common;if(e.body&&e.contentType)return{body:e.body,contentType:e.contentType}}}function l(e,t){var r;for(r in e){if(e[r]&&e[r].remote)return!0;var n=h(e[r]);if(n&&n.timestamp&&(new Date).getTime()-n.timestamp<=t)return!1;if(!n)return!0}return!0}var f=o.pathsFromRoot;function d(e){var t={path:e,common:{}};return a(e)&&(t.common.itemsMap={}),t}function p(e,t){return e.common||(e.common={itemsMap:{}}),e.common.itemsMap||(e.common.itemsMap={}),e.local||(e.local=c(e.common)),e.local.itemsMap||(e.local.itemsMap=e.common.itemsMap),e.local.itemsMap[t]=!0,e}var m={get:function(e,t,r){return"number"==typeof t?this.getNodes(f(e)).then(function(n){var o=h(n[e]);return l(n,t)?r(e):o?{statusCode:200,body:o.body||o.itemsMap,contentType:o.contentType}:{statusCode:404}}):this.getNodes([e]).then(function(t){var r=h(t[e]);if(r){if(a(e))for(var n in r.itemsMap)r.itemsMap.hasOwnProperty(n)&&!1===r.itemsMap[n]&&delete r.itemsMap[n];return{statusCode:200,body:r.body||r.itemsMap,contentType:r.contentType}}return{statusCode:404}})},put:function(e,t,r){var n=f(e);return this._updateNodes(n,function(e,n){try{for(var o=0,i=e.length;o0)break}else console.error("Cannot delete non-existing node "+o)}return t})},flush:function(e){var t=this;return t._getAllDescendentPaths(e).then(function(e){return t.getNodes(e)}).then(function(e){for(var r in e){var n=e[r];n&&n.common&&n.local&&t._emitChange({path:n.path,origin:"local",oldValue:!1===n.local.body?void 0:n.local.body,newValue:!1===n.common.body?void 0:n.common.body}),e[r]=void 0}return t.setNodes(e)})},_emitChange:function(e){i.changeEvents[e.origin]&&this._emit("change",e)},fireInitial:function(){if(i.changeEvents.local){var e=this;e.forAllNodes(function(t){var r;u(t.path)&&(r=h(t))&&e._emitChange({path:t.path,origin:"local",oldValue:void 0,oldContentType:void 0,newValue:r.body,newContentType:r.contentType})}).then(function(){e._emit("local-events-done")})}},onDiff:function(e){this.diffHandler=e},migrate:function(e){return"object"!==(void 0===e?"undefined":n(e))||e.common||(e.common={},"string"==typeof e.path?"/"===e.path.substr(-1)&&"object"===n(e.body)&&(e.common.itemsMap=e.body):(e.local||(e.local={}),e.local.body=e.body,e.local.contentType=e.contentType)),e},_updateNodesRunning:!1,_updateNodesQueued:[],_updateNodes:function(e,t){return new Promise(function(r,n){this._doUpdateNodes(e,t,{resolve:r,reject:n})}.bind(this))},_doUpdateNodes:function(e,t,r){var n=this;n._updateNodesRunning?n._updateNodesQueued.push({paths:e,cb:t,promise:r}):(n._updateNodesRunning=!0,n.getNodes(e).then(function(i){var s,a=c(i),h=[],l=o.equal;for(var f in i=t(e,i))l(s=i[f],a[f])?delete i[f]:u(f)&&(l(s.local.body,s.local.previousBody)&&s.local.contentType===s.local.previousContentType||h.push({path:f,origin:"window",oldValue:s.local.previousBody,newValue:!1===s.local.body?void 0:s.local.body,oldContentType:s.local.previousContentType,newContentType:s.local.contentType}),delete s.local.previousBody,delete s.local.previousContentType);n.setNodes(i).then(function(){n._emitChangeEvents(h),r.resolve({statusCode:200})})}).then(function(){return Promise.resolve()},function(e){r.reject(e)}).then(function(){n._updateNodesRunning=!1;var e=n._updateNodesQueued.shift();e&&n._doUpdateNodes(e.paths,e.cb,e.promise)}))},_emitChangeEvents:function(e){for(var t=0,r=e.length;t0},collectDiffTasks:function(){var e=0;return this.local.forAllNodes(function(t){e>100||(this.isCorrupt(t)?(a("[Sync] WARNING: corrupt node in local cache",t),"object"===(void 0===t?"undefined":n(t))&&t.path&&(this.addTask(t.path),e++)):this.needsFetch(t)&&this.access.checkPathPermission(t.path,"r")?(this.addTask(t.path),e++):l(t.path)&&this.needsPush(t)&&this.access.checkPathPermission(t.path,"rw")&&(this.addTask(t.path),e++))}.bind(this)).then(function(){return e},function(e){throw e})},inConflict:function(e){return e.local&&e.remote&&(void 0!==e.remote.body||e.remote.itemsMap)},needsRefresh:function(e){return!!e.common&&(!e.common.timestamp||this.now()-e.common.timestamp>c.syncInterval)},needsFetch:function(e){return!!this.inConflict(e)||(!(!e.common||void 0!==e.common.itemsMap||void 0!==e.common.body)||!(!e.remote||void 0!==e.remote.itemsMap||void 0!==e.remote.body))},needsPush:function(e){return!this.inConflict(e)&&(!(!e.local||e.push)||void 0)},needsRemotePut:function(e){return e.local&&e.local.body},needsRemoteDelete:function(e){return e.local&&!1===e.local.body},getParentPath:function(e){var t=e.match(/^(.*\/)([^\/]+\/?)$/);if(t)return t[1];throw new Error('Not a valid path: "'+e+'"')},deleteChildPathsFromTasks:function(){for(var e in this._tasks)for(var t=p(e),r=1;r=e))return!0;return t>=e},collectTasks:function(e){return this.hasTasks()||this.stopped?Promise.resolve():this.collectDiffTasks().then(function(t){return t||!1===e?Promise.resolve():this.collectRefreshTasks()}.bind(this),function(e){throw e})},addTask:function(e,t){this._tasks[e]||(this._tasks[e]=[]),"function"==typeof t&&this._tasks[e].push(t)},sync:function(){return this.done=!1,this.doTasks()?Promise.resolve():this.collectTasks().then(function(){try{this.doTasks()}catch(e){a("[Sync] doTasks error",e)}}.bind(this),function(e){throw a("[Sync] Sync error",e),new Error("Local cache unavailable")})}},_._rs_init=function(e){v=function(){a("[Sync] syncCycleCb calling syncCycle"),i.isBrowser()&&function(){var e=this;function t(t){var r,n;r=e.getCurrentSyncInterval(),c.isBackground=!t,n=e.getCurrentSyncInterval(),e._emit("sync-interval-change",{oldValue:r,newValue:n})}i.on("background",function(){t(!1)}),i.on("foreground",function(){t(!0)})}.bind(e)(),e.sync||(e.sync=new _(e,e.local,e.remote,e.access,e.caching),e.syncStopped&&(a("[Sync] Instantiating sync stopped"),e.sync.stopped=!0,delete e.syncStopped)),a("[Sync] syncCycleCb calling syncCycle"),e.syncCycle()},b=function(){e.removeEventListener("connected",b),e.startSync()},e.on("ready",v),e.on("connected",b)},_._rs_cleanup=function(e){e.stopSync(),e.removeEventListener("ready",v),e.removeEventListener("connected",b),e.sync=void 0,delete e.sync},(_.SyncError=function(e){this.name="SyncError";var t="Sync failed: ";"object"===(void 0===e?"undefined":n(e))&&"message"in e?(t+=e.message,this.stack=e.stack,this.originalError=e):t+=e,this.message=t}).prototype=Object.create(Error.prototype),_.SyncError.prototype.constructor=_.SyncError,e.exports=_},function(e,t,r){"use strict";(function(t,n){var o,i,s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a=r(0),u=r(1),c=r(2),h=r(4),l=r(3),f="remotestorage:wireclient",d={"draft-dejong-remotestorage-00":2,"draft-dejong-remotestorage-01":3,"draft-dejong-remotestorage-02":4,"https://www.w3.org/community/rww/wiki/read-write-web-00#simple":1};if("function"==typeof ArrayBufferView)i=function(e){return e&&e instanceof ArrayBufferView};else{var p=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];i=function(e){for(var t=0;t<8;t++)if(e instanceof p[t])return!0;return!1}}var m=u.isFolder,g=u.cleanPath,y=u.shouldBeTreatedAsBinary;function v(e){return"string"!=typeof e?e:"*"===e?"*":'"'+e+'"'}function b(e){return"string"!=typeof e?e:e.replace(/^["']|["']$/g,"")}var _=function(e){if(this.rs=e,this.connected=!1,c(this,"connected","not-connected"),o){var t;try{t=JSON.parse(localStorage[f])}catch(e){}t&&setTimeout(function(){this.configure(t)}.bind(this),0)}this._revisionCache={},this.connected&&setTimeout(this._emit.bind(this),0,"connected")};_.prototype={_request:function(e,r,o,i,s,c,l){if(("PUT"===e||"DELETE"===e)&&"/"===r[r.length-1])return Promise.reject("Don't "+e+" on directories!");var f,d=this;return o!==h.IMPLIED_FAKE_TOKEN&&(i.Authorization="Bearer "+o),this.rs._emit("wire-busy",{method:e,isFolder:m(r)}),_.request(e,r,{body:s,headers:i,responseType:"arraybuffer"}).then(function(o){if(d.online||(d.online=!0,d.rs._emit("network-online")),d.rs._emit("wire-done",{method:e,isFolder:m(r),success:!0}),g=o.status,[401,403,404,412].indexOf(g)>=0)return a("[WireClient] Error response status",o.status),f=c?b(o.getResponseHeader("ETag")):void 0,401===o.status&&d.rs._emit("error",new h.Unauthorized),Promise.resolve({statusCode:o.status,revision:f});if(function(e){return[201,204,304].indexOf(e)>=0}(o.status)||200===o.status&&"GET"!==e)return f=b(o.getResponseHeader("ETag")),a("[WireClient] Successful request",f),Promise.resolve({statusCode:o.status,revision:f});var i=o.getResponseHeader("Content-Type");f=c?b(o.getResponseHeader("ETag")):200===o.status?l:void 0;var s,p,g,v=function(e){var t,r="UTF-8";return e&&(t=e.match(/charset=(.+)$/))&&(r=t[1]),r}(i);return y(o.response,i)?(a("[WireClient] Successful request with unknown or binary mime-type",f),Promise.resolve({statusCode:o.status,body:o.response,contentType:i,revision:f})):(s=o.response,p=v,new Promise(function(e){if("undefined"==typeof Blob){var r=new t(new Uint8Array(s));e(r.toString(p))}else{var o;if(u.globalContext.BlobBuilder=u.globalContext.BlobBuilder||u.globalContext.WebKitBlobBuilder,void 0!==u.globalContext.BlobBuilder){var i=new n.BlobBuilder;i.append(s),o=i.getBlob()}else o=new Blob([s]);var a=new FileReader;"function"==typeof a.addEventListener?a.addEventListener("loadend",function(t){e(t.target.result)}):a.onloadend=function(t){e(t.target.result)},a.readAsText(o,p)}})).then(function(e){return a("[WireClient] Successful request",f),Promise.resolve({statusCode:o.status,body:e,contentType:i,revision:f})})},function(t){return d.online&&(d.online=!1,d.rs._emit("network-offline")),d.rs._emit("wire-done",{method:e,isFolder:m(r),success:!1}),Promise.reject(t)})},configure:function(e){if("object"!==(void 0===e?"undefined":s(e)))throw new Error("WireClient configure settings parameter should be an object");void 0!==e.userAddress&&(this.userAddress=e.userAddress),void 0!==e.href&&(this.href=e.href),void 0!==e.storageApi&&(this.storageApi=e.storageApi),void 0!==e.token&&(this.token=e.token),void 0!==e.properties&&(this.properties=e.properties),void 0!==this.storageApi&&(this._storageApi=d[this.storageApi]||5,this.supportsRevs=this._storageApi>=2),this.href&&this.token?(this.connected=!0,this.online=!0,this._emit("connected")):this.connected=!1,o&&(localStorage[f]=JSON.stringify({userAddress:this.userAddress,href:this.href,storageApi:this.storageApi,token:this.token,properties:this.properties}))},stopWaitingForToken:function(){this.connected||this._emit("not-connected")},get:function(e,t){var r=this;if(!this.connected)return Promise.reject("not connected (path: "+e+")");t||(t={});var n={};return this.supportsRevs&&t.ifNoneMatch&&(n["If-None-Match"]=v(t.ifNoneMatch)),this._request("GET",this.href+g(e),this.token,n,void 0,this.supportsRevs,this._revisionCache[e]).then(function(t){if(!m(e))return Promise.resolve(t);var n,o={};if(void 0!==t.body)try{t.body=JSON.parse(t.body)}catch(t){return Promise.reject("Folder description at "+r.href+g(e)+" is not JSON")}if(200===t.statusCode&&"object"===s(t.body)){if(0===Object.keys(t.body).length)t.statusCode=404;else if("http://remotestorage.io/spec/folder-description"===(n=t.body)["@context"]&&"object"===s(n.items)){for(var i in t.body.items)r._revisionCache[e+i]=t.body.items[i].ETag;o=t.body.items}else Object.keys(t.body).forEach(function(n){r._revisionCache[e+n]=t.body[n],o[n]={ETag:t.body[n]}});return t.body=o,Promise.resolve(t)}return Promise.resolve(t)})},put:function(e,t,r,n){if(!this.connected)return Promise.reject("not connected (path: "+e+")");n||(n={}),!r.match(/charset=/)&&(t instanceof ArrayBuffer||i(t))&&(r+="; charset=binary");var o={"Content-Type":r};return this.supportsRevs&&(n.ifMatch&&(o["If-Match"]=v(n.ifMatch)),n.ifNoneMatch&&(o["If-None-Match"]=v(n.ifNoneMatch))),this._request("PUT",this.href+g(e),this.token,o,t,this.supportsRevs)},delete:function(e,t){if(!this.connected)throw new Error("not connected (path: "+e+")");t||(t={});var r={};return this.supportsRevs&&t.ifMatch&&(r["If-Match"]=v(t.ifMatch)),this._request("DELETE",this.href+g(e),this.token,r,void 0,this.supportsRevs)}},_.isArrayBufferView=i,_.request=function(e,t,r){return new Promise(function(n,o){a("[WireClient]",e,t);var u=!1,c=setTimeout(function(){u=!0,o("timeout")},l.requestTimeout),h=new XMLHttpRequest;if(h.open(e,t,!0),r.responseType&&(h.responseType=r.responseType),r.headers)for(var f in r.headers)h.setRequestHeader(f,r.headers[f]);h.onload=function(){u||(clearTimeout(c),n(h))},h.onerror=function(e){u||(clearTimeout(c),o(e))};var d=r.body;"object"===(void 0===d?"undefined":s(d))&&!i(d)&&d instanceof ArrayBuffer&&(d=new Uint8Array(d)),h.send(d)})},Object.defineProperty(_.prototype,"storageType",{get:function(){if(this.storageApi){var e=this.storageApi.match(/draft-dejong-(remotestorage-\d\d)/);return e?e[1]:"2012.04"}}}),_._rs_init=function(e){o=u.localStorageAvailable(),e.remote=new _(e),this.online=!0},_._rs_supported=function(){return!!XMLHttpRequest},_._rs_cleanup=function(){o&&delete localStorage[f]},e.exports=_}).call(this,r(28).Buffer,r(9))},function(e,t){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){"use strict";var n=r(1),o=r(0),i=n.containingFolder,s=function(){this.reset()};s.prototype={pendingActivations:[],set:function(e,t){if("string"!=typeof e)throw new Error("path should be a string");if(!n.isFolder(e))throw new Error("path should be a folder");if(this._remoteStorage&&this._remoteStorage.access&&!this._remoteStorage.access.checkPathPermission(e,"r"))throw new Error('No access to path "'+e+'". You have to claim access to it first.');if(!t.match(/^(FLUSH|SEEN|ALL)$/))throw new Error("strategy should be 'FLUSH', 'SEEN', or 'ALL'");this._rootPaths[e]=t,"ALL"===t&&(this.activateHandler?this.activateHandler(e):this.pendingActivations.push(e))},enable:function(e){this.set(e,"ALL")},disable:function(e){this.set(e,"FLUSH")},onActivate:function(e){var t;for(o("[Caching] Setting activate handler",e,this.pendingActivations),this.activateHandler=e,t=0;t=r-this.maxAge?t.v:void 0},set:function(e,t){this._items[e]={v:t,t:(new Date).getTime()}}};var P=function(e,t){if(a(this,"connected","not-connected"),this.rs=e,this.clientId=t,this._fileIdCache=new w(300),g=u.localStorageAvailable()){var r=void 0;try{r=JSON.parse(localStorage.getItem(h))}catch(e){}r&&this.configure(r)}};P.prototype={connected:!1,online:!0,configure:function(e){var t=this;void 0!==e.userAddress&&(this.userAddress=e.userAddress),void 0!==e.token&&(this.token=e.token);var r=function(){g&&localStorage.setItem(h,JSON.stringify({userAddress:this.userAddress,token:this.token}))},n=function(){this.connected=!1,delete this.token,g&&localStorage.removeItem(h)};this.token?(this.connected=!0,this.userAddress?(this._emit("connected"),r.apply(this)):this.info().then(function(e){t.userAddress=e.user.emailAddress,t._emit("connected"),r.apply(t)}).catch(function(){n.apply(t),t.rs._emit("error",new Error("Could not fetch user info."))})):n.apply(this)},connect:function(){this.rs.setBackend("googledrive"),o(this.rs,"https://accounts.google.com/o/oauth2/auth","https://www.googleapis.com/auth/drive",String(o.getLocation()),this.clientId)},stopWaitingForToken:function(){this.connected||this._emit("not-connected")},get:function(e,t){return"/"===e.substr(-1)?this._getFolder(_(e),t):this._getFile(_(e),t)},put:function(e,t,r,n){var o=this,i=_(e);function s(e){if(e.status>=200&&e.status<300){var t=JSON.parse(e.responseText),r=t.etag.substring(1,t.etag.length-1);return Promise.resolve({statusCode:200,contentType:t.mimeType,revision:r})}return 412===e.status?Promise.resolve({statusCode:412,revision:"conflict"}):Promise.reject("PUT failed with status "+e.status+" ("+e.responseText+")")}return this._getFileId(i).then(function(e){return e?n&&"*"===n.ifNoneMatch?s({status:412}):o._updateFile(e,i,t,r,n).then(s):o._createFile(i,t,r,n).then(s)})},delete:function(e,t){var r=this,o=_(e);return this._getFileId(o).then(function(e){return e?r._getMeta(e).then(function(o){var i=void 0;return"object"===(void 0===o?"undefined":n(o))&&"string"==typeof o.etag&&(i=o.etag.substring(1,o.etag.length-1)),t&&t.ifMatch&&t.ifMatch!==i?{statusCode:412,revision:i}:r._request("DELETE",c+"/drive/v2/files/"+e,{}).then(function(e){return 200===e.status||204===e.status?{statusCode:200}:Promise.reject("Delete failed: "+e.status+" ("+e.responseText+")")})}):Promise.resolve({statusCode:200})})},info:function(){return this._request("GET","https://www.googleapis.com/drive/v2/about?fields=user",{}).then(function(e){try{var t=JSON.parse(e.responseText);return Promise.resolve(t)}catch(e){return Promise.reject(e)}})},_updateFile:function(e,t,r,n,o){var i=this,s={mimeType:n},a={"Content-Type":"application/json; charset=UTF-8"};return o&&o.ifMatch&&(a["If-Match"]='"'+o.ifMatch+'"'),this._request("PUT",c+"/upload/drive/v2/files/"+e+"?uploadType=resumable",{body:JSON.stringify(s),headers:a}).then(function(e){return 412===e.status?e:i._request("PUT",e.getResponseHeader("Location"),{body:n.match(/^application\/json/)?JSON.stringify(r):r})})},_createFile:function(e,t,r){var n=this;return this._getParentId(e).then(function(o){var i={title:y(b(e)),mimeType:r,parents:[{kind:"drive#fileLink",id:o}]};return n._request("POST",c+"/upload/drive/v2/files?uploadType=resumable",{body:JSON.stringify(i),headers:{"Content-Type":"application/json; charset=UTF-8"}}).then(function(e){return n._request("POST",e.getResponseHeader("Location"),{body:r.match(/^application\/json/)?JSON.stringify(t):t})})})},_getFile:function(e,t){var r=this;return this._getFileId(e).then(function(e){return r._getMeta(e).then(function(e){var o=void 0;if("object"===(void 0===e?"undefined":n(e))&&"string"==typeof e.etag&&(o=e.etag.substring(1,e.etag.length-1)),t&&t.ifNoneMatch&&o===t.ifNoneMatch)return Promise.resolve({statusCode:304});if(!e.downloadUrl){if(!e.exportLinks||!e.exportLinks["text/html"])return Promise.resolve({statusCode:200,body:"",contentType:e.mimeType,revision:o});e.mimeType+=";export=text/html",e.downloadUrl=e.exportLinks["text/html"]}return r._request("GET",e.downloadUrl,{}).then(function(t){var r=t.response;if(e.mimeType.match(/^application\/json/))try{r=JSON.parse(r)}catch(e){}else if(p(r,e.mimeType))return m(r,e.mimeType).then(function(t){return{statusCode:200,body:t,contentType:e.mimeType,revision:o}});return Promise.resolve({statusCode:200,body:r,contentType:e.mimeType,revision:o})})})})},_getFolder:function(e){var t=this;return this._getFileId(e).then(function(r){var n,o,i=void 0,s=void 0,a=void 0;return r?(n="'"+r+"' in parents",o="items(downloadUrl,etag,fileSize,id,mimeType,title)",t._request("GET",c+"/drive/v2/files?q="+encodeURIComponent(n)+"&fields="+encodeURIComponent(o)+"&maxResults=1000",{}).then(function(r){if(200!==r.status)return Promise.reject("request failed or something: "+r.status);try{i=JSON.parse(r.responseText)}catch(e){return Promise.reject("non-JSON response from GoogleDrive")}a={};var n=!0,o=!1,u=void 0;try{for(var c,h=i.items[Symbol.iterator]();!(n=(c=h.next()).done);n=!0){var l=c.value;s=l.etag.substring(1,l.etag.length-1),"application/vnd.google-apps.folder"===l.mimeType?(t._fileIdCache.set(e+l.title+"/",l.id),a[l.title+"/"]={ETag:s}):(t._fileIdCache.set(e+l.title,l.id),a[l.title]={ETag:s,"Content-Type":l.mimeType,"Content-Length":l.fileSize})}}catch(e){o=!0,u=e}finally{try{!n&&h.return&&h.return()}finally{if(o)throw u}}return Promise.resolve({statusCode:200,body:a,contentType:"application/json; charset=UTF-8",revision:void 0})})):Promise.resolve({statusCode:404})})},_getParentId:function(e){var t=this,r=v(e);return this._getFileId(r).then(function(e){return e?Promise.resolve(e):t._createFolder(r)})},_createFolder:function(e){var t=this;return this._getParentId(e).then(function(r){return t._request("POST",c+"/drive/v2/files",{body:JSON.stringify({title:y(b(e)),mimeType:"application/vnd.google-apps.folder",parents:[{id:r}]}),headers:{"Content-Type":"application/json; charset=UTF-8"}}).then(function(e){var t=JSON.parse(e.responseText);return Promise.resolve(t.id)})})},_getFileId:function(e){var t=this,r=void 0;return"/"===e?Promise.resolve("root"):(r=this._fileIdCache.get(e))?Promise.resolve(r):this._getFolder(v(e)).then(function(){return(r=t._fileIdCache.get(e))?Promise.resolve(r):"/"===e.substr(-1)?t._createFolder(e).then(function(){return t._getFileId(e)}):Promise.resolve()})},_getMeta:function(e){return this._request("GET",c+"/drive/v2/files/"+e,{}).then(function(t){return 200===t.status?Promise.resolve(JSON.parse(t.responseText)):Promise.reject("request (getting metadata for "+e+") failed with status: "+t.status)})},_request:function(e,t,r){var n=this;return r.headers||(r.headers={}),r.headers.Authorization="Bearer "+this.token,this.rs._emit("wire-busy",{method:e,isFolder:f(t)}),s.request.call(this,e,t,r).then(function(r){return r&&401===r.status?void n.connect():(n.online||(n.online=!0,n.rs._emit("network-online")),n.rs._emit("wire-done",{method:e,isFolder:f(t),success:!0}),Promise.resolve(r))},function(r){return n.online&&(n.online=!1,n.rs._emit("network-offline")),n.rs._emit("wire-done",{method:e,isFolder:f(t),success:!1}),Promise.reject(r)})}},P._rs_init=function(e){var t,r=e.apiKeys.googledrive;r&&(e.googledrive=new P(e,r.clientId),"googledrive"===e.backend&&(e._origRemote=e.remote,e.remote=e.googledrive,(t=e)._origBaseClientGetItemURL||(t._origBaseClientGetItemURL=i.prototype.getItemURL,i.prototype.getItemURL=function(){throw new Error("getItemURL is not implemented for Google Drive yet")})))},P._rs_supported=function(){return!0},P._rs_cleanup=function(e){var t;e.setBackend(void 0),e._origRemote&&(e.remote=e._origRemote,delete e._origRemote),(t=e)._origBaseClientGetItemURL&&(i.prototype.getItemURL=t._origBaseClientGetItemURL,delete t._origBaseClientGetItemURL)},e.exports=P},function(e,t,r){"use strict";var n=r(2),o="undefined"!=typeof window?"browser":"node",i={},s=function(){return i};s.isBrowser=function(){return"browser"===o},s.isNode=function(){return"node"===o},s.goBackground=function(){s._emit("background")},s.goForeground=function(){s._emit("foreground")},s._rs_init=function(){function e(){document[i.hiddenProperty]?s.goBackground():s.goForeground()}n(s,"background","foreground"),"browser"===o&&(void 0!==document.hidden?(i.hiddenProperty="hidden",i.visibilityChangeEvent="visibilitychange"):void 0!==document.mozHidden?(i.hiddenProperty="mozHidden",i.visibilityChangeEvent="mozvisibilitychange"):void 0!==document.msHidden?(i.hiddenProperty="msHidden",i.visibilityChangeEvent="msvisibilitychange"):void 0!==document.webkitHidden&&(i.hiddenProperty="webkitHidden",i.visibilityChangeEvent="webkitvisibilitychange"),document.addEventListener(i.visibilityChangeEvent,e,!1),e())},s._rs_cleanup=function(){},e.exports=s},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=r(4),i=r(5),s=r(8),a=r(1),u=r(2),c=r(7),h=void 0,l="remotestorage:dropbox",f=a.isFolder,d=a.cleanPath,p=a.shouldBeTreatedAsBinary,m=a.readBinaryData,g=function(e){return d("/remotestorage/"+e).replace(/\/$/,"")},y=function(e,t){return new RegExp("^"+t.join("\\/")+"(\\/|$)").test(e.error_summary)},v=function(e){return e instanceof ArrayBuffer||s.isArrayBufferView(e)};function b(e){this.defaultValue=e,this._storage={},this.set=this.justSet,this.delete=this.justDelete}b.prototype={get:function(e){e=e.toLowerCase();var t=this._storage[e];return void 0===t&&(t=this.defaultValue,this._storage[e]=t),t},propagateSet:function(e,t){return e=e.toLowerCase(),this._storage[e]===t?t:(this._propagate(e,t),this._storage[e]=t,t)},propagateDelete:function(e){return e=e.toLowerCase(),this._propagate(e,this._storage[e]),delete this._storage[e]},_activatePropagation:function(){return this.set=this.propagateSet,this.delete=this.propagateDelete,!0},justSet:function(e,t){return e=e.toLowerCase(),this._storage[e]=t,t},justDelete:function(e){return e=e.toLowerCase(),delete this._storage[e]},_propagate:function(e,t){for(var r=e.split("/").slice(0,-1),n="",o=0,i=r.length;o157286400)return Promise.reject(new Error("Cannot upload file larger than 150MB"));var s=n&&(n.ifMatch||"*"===n.ifNoneMatch),a={body:t,contentType:r,path:e};return(s?this._getMetadata(e).then(function(e){return n&&"*"===n.ifNoneMatch&&e?Promise.resolve({statusCode:412,revision:e.rev}):n&&n.ifMatch&&e&&e.rev!==n.ifMatch?Promise.resolve({statusCode:412,revision:e.rev}):o._uploadSimple(a)}):o._uploadSimple(a)).then(function(t){return o._shareIfNeeded(e),t})},delete:function(e,t){var r=this;if(!this.connected)throw new Error("not connected (path: "+e+")");var n=this._revCache.get(e);return t&&t.ifMatch&&n&&t.ifMatch!==n?Promise.resolve({statusCode:412,revision:n}):t&&t.ifMatch?this._getMetadata(e).then(function(n){return t&&t.ifMatch&&n&&n.rev!==t.ifMatch?Promise.resolve({statusCode:412,revision:n.rev}):r._deleteSimple(e)}):this._deleteSimple(e)},_shareIfNeeded:function(e){e.match(/^\/public\/.*[^/]$/)&&void 0===this._itemRefs[e]&&this.share(e)},share:function(e){var t=this,r={body:{path:g(e)}};return this._request("POST","https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings",r).then(function(r){if(200!==r.status&&409!==r.status)return Promise.reject(new Error("Invalid response status:"+r.status));var n;try{n=JSON.parse(r.responseText)}catch(e){return Promise.reject(new Error("Invalid response body: "+r.responseText))}return 409===r.status?y(n,["shared_link_already_exists"])?t._getSharedLink(e):Promise.reject(new Error("API error: "+n.error_summary)):Promise.resolve(n.url)}).then(function(r){return t._itemRefs[e]=r,h&&localStorage.setItem(l+":shares",JSON.stringify(t._itemRefs)),Promise.resolve(r)},function(t){return t.message='Sharing Dropbox file or folder ("'+e+'") failed: '+t.message,Promise.reject(t)})},info:function(){return this._request("POST","https://api.dropboxapi.com/2/users/get_current_account",{}).then(function(e){var t=e.responseText;try{t=JSON.parse(t)}catch(e){return Promise.reject(new Error("Could not query current account info: Invalid API response: "+t))}return Promise.resolve({email:t.email})})},_request:function(e,t,r){var o=this;return r.headers||(r.headers={}),r.headers.Authorization="Bearer "+this.token,"object"!==n(r.body)||v(r.body)||(r.body=JSON.stringify(r.body),r.headers["Content-Type"]="application/json; charset=UTF-8"),this.rs._emit("wire-busy",{method:e,isFolder:f(t)}),s.request.call(this,e,t,r).then(function(n){return n&&503===n.status?(o.online&&(o.online=!1,o.rs._emit("network-offline")),setTimeout(o._request(e,t,r),3210)):(o.online||(o.online=!0,o.rs._emit("network-online")),o.rs._emit("wire-done",{method:e,isFolder:f(t),success:!0}),Promise.resolve(n))},function(r){return o.online&&(o.online=!1,o.rs._emit("network-offline")),o.rs._emit("wire-done",{method:e,isFolder:f(t),success:!1}),Promise.reject(r)})},fetchDelta:function(){var e=Array.prototype.slice.call(arguments),t=this;return t._revCache=new b("rev"),function r(n){var i="https://api.dropboxapi.com/2/files/list_folder",s=void 0;return"string"==typeof n?(i+="/continue",s={cursor:n}):s={path:"/remotestorage",recursive:!0,include_deleted:!0},t._request("POST",i,{body:s}).then(function(n){if(401===n.status)return t.rs._emit("error",new o.Unauthorized),Promise.resolve(e);if(200!==n.status&&409!==n.status)return Promise.reject(new Error("Invalid response status: "+n.status));var i=void 0;try{i=JSON.parse(n.responseText)}catch(e){return Promise.reject(new Error("Invalid response body: "+n.responseText))}if(409===n.status){if(!y(i,["path","not_found"]))return Promise.reject(new Error("API returned an error: "+i.error_summary));i={cursor:null,entries:[],has_more:!1}}return i.entries.forEach(function(e){var r=e.path_lower.substr("/remotestorage".length);"deleted"===e[".tag"]?(t._revCache.set(r,null),t._revCache.set(r+"/",null)):"file"===e[".tag"]&&t._revCache.set(r,e.rev)}),i.has_more?r(i.cursor):void 0}).catch(function(e){return"timeout"===e||e instanceof ProgressEvent?Promise.resolve():Promise.reject(e)})}().then(void 0,function(e){return"object"===(void 0===e?"undefined":n(e))&&"message"in e?e.message="Dropbox: fetchDelta: "+e.message:e="Dropbox: fetchDelta: "+e,Promise.reject(e)}).then(function(){return t._revCache&&t._revCache._activatePropagation(),Promise.resolve(e)})},_getMetadata:function(e){var t={path:g(e)};return this._request("POST","https://api.dropboxapi.com/2/files/get_metadata",{body:t}).then(function(e){if(200!==e.status&&409!==e.status)return Promise.reject(new Error("Invalid response status:"+e.status));var t=void 0;try{t=JSON.parse(e.responseText)}catch(t){return Promise.reject(new Error("Invalid response body: "+e.responseText))}return 409===e.status?y(t,["path","not_found"])?Promise.resolve():Promise.reject(new Error("API error: "+t.error_summary)):Promise.resolve(t)}).then(void 0,function(t){return t.message='Could not load metadata for file or folder ("'+e+'"): '+t.message,Promise.reject(t)})},_uploadSimple:function(e){var t=this,r={path:g(e.path),mode:{".tag":"overwrite"},mute:!0};return e.ifMatch&&(r.mode={".tag":"update",update:e.ifMatch}),this._request("POST","https://content.dropboxapi.com/2/files/upload",{body:e.body,headers:{"Content-Type":"application/octet-stream","Dropbox-API-Arg":JSON.stringify(r)}}).then(function(r){if(200!==r.status&&409!==r.status)return Promise.resolve({statusCode:r.status});var n=r.responseText;try{n=JSON.parse(n)}catch(e){return Promise.reject(new Error("Invalid API result: "+n))}return 409===r.status?y(n,["path","conflict"])?t._getMetadata(e.path).then(function(e){return Promise.resolve({statusCode:412,revision:e.rev})}):Promise.reject(new Error("API error: "+n.error_summary)):(t._revCache.propagateSet(e.path,n.rev),Promise.resolve({statusCode:r.status,revision:n.rev}))})},_deleteSimple:function(e){var t=this,r={path:g(e)};return this._request("POST","https://api.dropboxapi.com/2/files/delete",{body:r}).then(function(e){if(200!==e.status&&409!==e.status)return Promise.resolve({statusCode:e.status});var t=e.responseText;try{t=JSON.parse(t)}catch(e){return Promise.reject(new Error("Invalid response body: "+t))}return 409===e.status?y(t,["path_lookup","not_found"])?Promise.resolve({statusCode:404}):Promise.reject(new Error("API error: "+t.error_summary)):Promise.resolve({statusCode:200})}).then(function(r){return 200!==r.statusCode&&404!==r.statusCode||(t._revCache.delete(e),delete t._itemRefs[e]),Promise.resolve(r)},function(t){return t.message='Could not delete Dropbox file or folder ("'+e+'"): '+t.message,Promise.reject(t)})},_getSharedLink:function(e){var t={body:{path:g(e),direct_only:!0}};return this._request("POST","https://api.dropbox.com/2/sharing/list_shared_links",t).then(function(e){if(200!==e.status&&409!==e.status)return Promise.reject(new Error("Invalid response status: "+e.status));var t;try{t=JSON.parse(e.responseText)}catch(t){return Promise.reject(new Error("Invalid response body: "+e.responseText))}return 409===e.status?Promise.reject(new Error("API error: "+e.error_summary)):t.links.length?Promise.resolve(t.links[0].url):Promise.reject(new Error("No links returned"))},function(t){return t.message='Could not get link to a shared file or folder ("'+e+'"): '+t.message,Promise.reject(t)})}},_._rs_init=function(e){h=a.localStorageAvailable(),e.apiKeys.dropbox&&(e.dropbox=new _(e)),"dropbox"===e.backend&&P(e)},_._rs_supported=function(){return!0},_._rs_cleanup=function(e){E(e),h&&localStorage.removeItem(l),e.setBackend(void 0)},e.exports=_},function(e,t,r){"use strict";var n,o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=r(1),s=r(15),a=r(13),u=r(12),c=r(5),h=r(3),l=r(4),f=r(7),d=r(0),p=r(22),m=i.getGlobalContext(),g=r(2);var y=function(e){if("object"===(void 0===e?"undefined":o(e))&&i.extend(h,e),g(this,"ready","authing","connecting","connected","disconnected","not-connected","conflict","error","features-loaded","sync-interval-change","sync-req-done","sync-done","wire-busy","wire-done","network-offline","network-online"),this._pending=[],this._setGPD({get:this._pendingGPD("get"),put:this._pendingGPD("put"),delete:this._pendingGPD("delete")}),this._cleanups=[],this._pathHandlers={change:{}},this.apiKeys={},n=i.localStorageAvailable()){try{this.apiKeys=JSON.parse(localStorage.getItem("remotestorage:api-keys"))||{}}catch(e){}this.setBackend(localStorage.getItem("remotestorage:backend")||"remotestorage")}var t=this.on;this.on=function(e,r){if(this._allLoaded)switch(e){case"features-loaded":setTimeout(r,0);break;case"ready":this.remote&&setTimeout(r,0);break;case"connected":this.remote&&this.remote.connected&&setTimeout(r,0);break;case"not-connected":this.remote&&!this.remote.connected&&setTimeout(r,0)}return t.call(this,e,r)},this._init(),this.fireInitial=function(){this.local&&setTimeout(this.local.fireInitial.bind(this.local),0)}.bind(this),this.on("ready",this.fireInitial.bind(this)),this.loadModules()};function v(e){return"number"==typeof e&&e>1e3&&e<36e5}y.Authorize=l,y.SyncError=f.SyncError,y.Unauthorized=l.Unauthorized,y.DiscoveryError=u.DiscoveryError,y.prototype={loadModules:function(){h.modules.forEach(this.addModule.bind(this))},authorize:function(e,t){this.access.setStorageType(this.remote.storageApi);var r=this.access.scopeParameter,n=m.cordova?t:String(l.getLocation()),o=n.match(/^(https?:\/\/[^/]+)/)[0];l(this,e,r,n,o)},impliedauth:function(e,t){e=this.remote.storageApi,t=String(document.location),d("ImpliedAuth proceeding due to absent authURL; storageApi = "+e+" redirectUri = "+t),this.remote.configure({token:l.IMPLIED_FAKE_TOKEN}),document.location=t},connect:function(e,t){var r=this;if(this.setBackend("remotestorage"),e.indexOf("@")<0)this._emit("error",new y.DiscoveryError("User address doesn't contain an @."));else{if(m.cordova){if("string"!=typeof h.cordovaRedirectUri)return void this._emit("error",new y.DiscoveryError("Please supply a custom HTTPS redirect URI for your Cordova app"));if(!m.cordova.InAppBrowser)return void this._emit("error",new y.DiscoveryError("Please include the InAppBrowser Cordova plugin to enable OAuth"))}this.remote.configure({userAddress:e}),this._emit("connecting");var n=setTimeout(function(){this._emit("error",new y.DiscoveryError("No storage information found for this user address."))}.bind(this),h.discoveryTimeout);u(e).then(function(o){if(clearTimeout(n),r._emit("authing"),o.userAddress=e,r.remote.configure(o),!r.remote.connected)if(o.authURL)if(void 0===t)r.authorize(o.authURL,h.cordovaRedirectUri);else{if("string"!=typeof t)throw new Error("Supplied bearer token must be a string");d("Skipping authorization sequence and connecting with known token"),r.remote.configure({token:t})}else r.impliedauth()},function(){clearTimeout(n),r._emit("error",new y.DiscoveryError("No storage information found for this user address."))})}},reconnect:function(){this.remote.configure({token:null}),"remotestorage"===this.backend?this.connect(this.remote.userAddress):this.remote.connect()},disconnect:function(){this.remote&&this.remote.configure({userAddress:null,href:null,storageApi:null,token:null,properties:null}),this._setGPD({get:this._pendingGPD("get"),put:this._pendingGPD("put"),delete:this._pendingGPD("delete")});var e=this._cleanups.length,t=0,r=function(){++t>=e&&(this._init(),d("Done cleaning up, emitting disconnected and disconnect events"),this._emit("disconnected"))}.bind(this);e>0?this._cleanups.forEach(function(e){var t=e(this);"object"===(void 0===t?"undefined":o(t))&&"function"==typeof t.then?t.then(r):r()}.bind(this)):r()},setBackend:function(e){this.backend=e,n&&(e?localStorage.setItem("remotestorage:backend",e):localStorage.removeItem("remotestorage:backend"))},onChange:function(e,t){this._pathHandlers.change[e]||(this._pathHandlers.change[e]=[]),this._pathHandlers.change[e].push(t)},enableLog:function(){h.logging=!0},disableLog:function(){h.logging=!1},log:function(){d.apply(y,arguments)},setApiKeys:function(e){var t=this,r=["googledrive","dropbox"];if("object"!==(void 0===e?"undefined":o(e))||!Object.keys(e).every(function(e){return-1!==r.indexOf(e)}))return console.error("setApiKeys() was called with invalid arguments"),!1;Object.keys(e).forEach(function(r){var n=e[r];if(n){switch(r){case"dropbox":t.apiKeys.dropbox={appKey:n},void 0!==t.dropbox&&t.dropbox.clientId===n||s._rs_init(t);break;case"googledrive":t.apiKeys.googledrive={clientId:n},void 0!==t.googledrive&&t.googledrive.clientId===n||a._rs_init(t)}return!0}delete t.apiKeys[r]}),n&&localStorage.setItem("remotestorage:api-keys",JSON.stringify(this.apiKeys))},setCordovaRedirectUri:function(e){if("string"!=typeof e||!e.match(/http(s)?:\/\//))throw new Error("Cordova redirect URI must be a URI string");h.cordovaRedirectUri=e},_init:p.loadFeatures,features:p.features,loadFeature:p.loadFeature,featureSupported:p.featureSupported,featureDone:p.featureDone,featuresDone:p.featuresDone,featuresLoaded:p.featuresLoaded,featureInitialized:p.featureInitialized,featureFailed:p.featureFailed,hasFeature:p.hasFeature,_setCachingModule:p._setCachingModule,_collectCleanupFunctions:p._collectCleanupFunctions,_fireReady:p._fireReady,initFeature:p.initFeature,_setGPD:function(e,t){function r(e){return function(){return e.apply(t,arguments).then(function(e){return 403!==e.statusCode&&401!==e.statusCode||this._emit("error",new l.Unauthorized),Promise.resolve(e)}.bind(this))}}this.get=r(e.get),this.put=r(e.put),this.delete=r(e.delete)},_pendingGPD:function(e){return function(){var t=Array.prototype.slice.call(arguments);return new Promise(function(r,n){this._pending.push({method:e,args:t,promise:{resolve:r,reject:n}})}.bind(this))}.bind(this)},_processPending:function(){this._pending.forEach(function(e){try{this[e.method].apply(this,e.args).then(e.promise.resolve,e.promise.reject)}catch(t){e.promise.reject(t)}}.bind(this)),this._pending=[]},_bindChange:function(e){e.on("change",this._dispatchEvent.bind(this,"change"))},_dispatchEvent:function(e,t){var r=this;Object.keys(this._pathHandlers[e]).forEach(function(n){var o=n.length;t.path.substr(0,o)===n&&r._pathHandlers[e][n].forEach(function(e){var o={};for(var i in t)o[i]=t[i];o.relativePath=t.path.replace(new RegExp("^"+n),"");try{e(o)}catch(e){console.error("'change' handler failed: ",e,e.stack),r._emit("error",e)}})})},scope:function(e){if("string"!=typeof e)throw"Argument 'path' of baseClient.scope must be a string";if(!this.access.checkPathPermission(e,"r")){var t=e.replace(/(['\\])/g,"\\$1");console.warn("WARNING: please call remoteStorage.access.claim('"+t+"', 'r') (read only) or remoteStorage.access.claim('"+t+"', 'rw') (read/write) first")}return new c(this,e)},getSyncInterval:function(){return h.syncInterval},setSyncInterval:function(e){if(!v(e))throw e+" is not a valid sync interval";var t=h.syncInterval;h.syncInterval=parseInt(e,10),this._emit("sync-interval-change",{oldValue:t,newValue:e})},getBackgroundSyncInterval:function(){return h.backgroundSyncInterval},setBackgroundSyncInterval:function(e){if(!v(e))throw e+" is not a valid sync interval";var t=h.backgroundSyncInterval;h.backgroundSyncInterval=parseInt(e,10),this._emit("sync-interval-change",{oldValue:t,newValue:e})},getCurrentSyncInterval:function(){return h.isBackground?h.backgroundSyncInterval:h.syncInterval},getRequestTimeout:function(){return h.requestTimeout},setRequestTimeout:function(e){h.requestTimeout=parseInt(e,10)},syncCycle:function(){this.sync&&!this.sync.stopped&&(this.on("sync-done",function(){d("[Sync] Sync done. Setting timer to",this.getCurrentSyncInterval()),this.sync&&!this.sync.stopped&&(this._syncTimer&&(clearTimeout(this._syncTimer),this._syncTimer=void 0),this._syncTimer=setTimeout(this.sync.sync.bind(this.sync),this.getCurrentSyncInterval()))}.bind(this)),this.sync.sync())},startSync:function(){return h.cache?(this.sync.stopped=!1,this.syncStopped=!1,this.sync.sync()):(console.warn("Nothing to sync, because caching is disabled."),Promise.resolve())},stopSync:function(){clearTimeout(this._syncTimer),this._syncTimer=void 0,this.sync?(d("[Sync] Stopping sync"),this.sync.stopped=!0):(d("[Sync] Will instantiate sync stopped"),this.syncStopped=!0)}},y.util=i,Object.defineProperty(y.prototype,"connected",{get:function(){return this.remote.connected}});var b=r(11);Object.defineProperty(y.prototype,"access",{get:function(){var e=new b;return Object.defineProperty(this,"access",{value:e}),e},configurable:!0});var _=r(10);Object.defineProperty(y.prototype,"caching",{configurable:!0,get:function(){var e=new _;return Object.defineProperty(this,"caching",{value:e}),e}}),e.exports=y,r(17)},function(e,t,r){"use strict";var n=r(5),o=r(16);o.prototype.addModule=function(e){var t=e.name,r=e.builder;if(Object.defineProperty(this,t,{configurable:!0,get:function(){var e=this._loadModule(t,r);return Object.defineProperty(this,t,{value:e}),e}}),-1!==t.indexOf("-")){var n=t.replace(/\-[a-z]/g,function(e){return e[1].toUpperCase()});Object.defineProperty(this,n,{get:function(){return this[t]}})}},o.prototype._loadModule=function(e,t){if(t)return t(new n(this,"/"+e+"/"),new n(this,"/public/"+e+"/")).exports;throw"Unknown module: "+e}},function(e,t,r){"use strict";var n=r(2),o=r(0),i=r(6),s=function(){i(this),o("[InMemoryStorage] Registering events"),n(this,"change","local-events-done"),this._storage={}};s.prototype={getNodes:function(e){for(var t={},r=0,n=e.length;r0?this.getNodesFromDb(t).then(function(e){for(var t in r)e[t]=r[t];return e}):Promise.resolve(r)},setNodes:function(e){for(var t in e)this.changesQueued[t]=e[t]||!1;return this.maybeFlush(),Promise.resolve()},maybeFlush:function(){0===this.putsRunning?this.flushChangesQueued():this.commitSlownessWarning||(this.commitSlownessWarning=setInterval(function(){console.warn("WARNING: waited more than 10 seconds for previous commit to finish")},1e4))},flushChangesQueued:function(){this.commitSlownessWarning&&(clearInterval(this.commitSlownessWarning),this.commitSlownessWarning=null),Object.keys(this.changesQueued).length>0&&(this.changesRunning=this.changesQueued,this.changesQueued={},this.setNodesInDb(this.changesRunning).then(this.flushChangesQueued.bind(this)))},getNodesFromDb:function(e){var t=this;return new Promise(function(r,n){var o=t.db.transaction(["nodes"],"readonly"),i=o.objectStore("nodes"),s={};t.getsRunning++,e.map(function(e){i.get(e).onsuccess=function(t){s[e]=t.target.result}}),o.oncomplete=function(){r(s),this.getsRunning--}.bind(t),o.onerror=o.onabort=function(){n("get transaction error/abort"),this.getsRunning--}.bind(t)})},setNodesInDb:function(e){var t=this;return new Promise(function(r,n){var s=t.db.transaction(["nodes"],"readwrite"),a=s.objectStore("nodes"),u=(new Date).getTime();for(var c in t.putsRunning++,i("[IndexedDB] Starting put",e,t.putsRunning),e){var h=e[c];if("object"===(void 0===h?"undefined":o(h)))try{a.put(h)}catch(e){throw i("[IndexedDB] Error while putting",h,e),e}else try{a.delete(c)}catch(e){throw i("[IndexedDB] Error while removing",a,h,e),e}}s.oncomplete=function(){this.putsRunning--,i("[IndexedDB] Finished put",e,this.putsRunning,(new Date).getTime()-u+"ms"),r()}.bind(t),s.onerror=function(){this.putsRunning--,n("transaction error")}.bind(t),s.onabort=function(){n("transaction abort"),this.putsRunning--}.bind(t)})},reset:function(e){var t=this,r=this.db.name;this.db.close(),c.clean(this.db.name,function(){c.open(r,function(r,n){r?i("[IndexedDB] Error while resetting local storage",r):t.db=n,"function"==typeof e&&e(self)})})},forAllNodes:function(e){var t=this;return new Promise(function(r){t.db.transaction(["nodes"],"readonly").objectStore("nodes").openCursor().onsuccess=function(n){var o=n.target.result;o?(e(t.migrate(o.value)),o.continue()):r()}})},closeDB:function(){0===this.putsRunning?this.db.close():setTimeout(this.closeDB.bind(this),100)}},c.open=function(e,t){var r=setTimeout(function(){t("timeout trying to open db")},1e4);try{var n=indexedDB.open(e,2);n.onerror=function(){i("[IndexedDB] Opening DB failed",n),clearTimeout(r),t(n.error)},n.onupgradeneeded=function(e){var t=n.result;i("[IndexedDB] Upgrade: from ",e.oldVersion," to ",e.newVersion),1!==e.oldVersion&&(i("[IndexedDB] Creating object store: nodes"),t.createObjectStore("nodes",{keyPath:"path"})),i("[IndexedDB] Creating object store: changes"),t.createObjectStore("changes",{keyPath:"path"})},n.onsuccess=function(){clearTimeout(r);var o=n.result;if(!o.objectStoreNames.contains("nodes")||!o.objectStoreNames.contains("changes"))return i("[IndexedDB] Missing object store. Resetting the database."),void c.clean(e,function(){c.open(e,t)});t(null,n.result)}}catch(n){i("[IndexedDB] Failed to open database: "+n),i("[IndexedDB] Resetting database and trying again."),clearTimeout(r),c.clean(e,function(){c.open(e,t)})}},c.clean=function(e,t){var r=indexedDB.deleteDatabase(e);r.onsuccess=function(){i("[IndexedDB] Done removing DB"),t()},r.onerror=r.onabort=function(t){console.error('Failed to remove database "'+e+'"',t)}},c._rs_init=function(e){return new Promise(function(t,r){c.open("remotestorage",function(o,i){o?r(o):(n=i,i.onerror=function(){e._emit("error",o)},t())})})},c._rs_supported=function(){return new Promise(function(e,t){var r=u.getGlobalContext(),n=!1;if("undefined"!=typeof navigator&&navigator.userAgent.match(/Android (2|3|4\.[0-3])/)&&(navigator.userAgent.match(/Chrome|Firefox/)||(n=!0)),"indexedDB"in r&&!n)try{var o=indexedDB.open("rs-check");o.onerror=function(){t()},o.onsuccess=function(){o.result.close(),indexedDB.deleteDatabase("rs-check"),e()}}catch(e){t()}else t()})},c._rs_cleanup=function(e){return new Promise(function(t){e.local&&e.local.closeDB(),c.clean("remotestorage",t)})},e.exports=c},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=r(0);var i={get:function(e,t){return this.local?(void 0===t&&("object"===n(this.remote)&&this.remote.connected&&this.remote.online?t=2*this.getSyncInterval():(o("Not setting default maxAge, because remote is offline or not connected"),t=!1)),function(e){return!1!==e&&"number"!=typeof e}(t)?Promise.reject("Argument 'maxAge' must be false or a number"):this.local.get(e,t,this.sync.queueGetRequest.bind(this.sync))):this.remote.get(e)},put:function(e,t,r){return function(e){return"dropbox"===this.backend&&e.match(/^\/public\/.*[^\/]$/)}.bind(this)(e)?i._wrapBusyDone.call(this,this.remote.put(e,t,r)):this.local?this.local.put(e,t,r):i._wrapBusyDone.call(this,this.remote.put(e,t,r))},delete:function(e){return this.local?this.local.delete(e):i._wrapBusyDone.call(this,this.remote.delete(e))},_wrapBusyDone:function(e){var t=this;return this._emit("wire-busy"),e.then(function(e){return t._emit("wire-done",{success:!0}),Promise.resolve(e)},function(e){return t._emit("wire-done",{success:!1}),Promise.reject(e)})}};e.exports=i},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=r(1),i=r(0),s=r(21),a=r(3),u={features:[],featuresDone:0,readyFired:!1,loadFeatures:function(){var e=this;for(var t in this.features=[],this.featuresDone=0,this.readyFired=!1,this.featureModules={WireClient:r(8),Dropbox:r(15),GoogleDrive:r(13),Access:r(11),Discover:r(12),Authorize:r(4),BaseClient:r(5),Env:r(14)},a.cache&&o.extend(this.featureModules,{Caching:r(10),IndexedDB:r(20),LocalStorage:r(19),InMemoryStorage:r(18),Sync:r(7)}),a.disableFeatures.forEach(function(t){e.featureModules[t]&&delete e.featureModules[t]}),this._allLoaded=!1,this.featureModules)this.loadFeature(t)},hasFeature:function(e){for(var t=this.features.length-1;t>=0;t--)if(this.features[t].name===e)return this.features[t].supported;return!1},loadFeature:function(e){var t=this,r=this.featureModules[e],o=!r._rs_supported||r._rs_supported();i("[RemoteStorage] [FEATURE "+e+"] initializing ..."),"object"===(void 0===o?"undefined":n(o))?o.then(function(){t.featureSupported(e,!0),t.initFeature(e)},function(){t.featureSupported(e,!1)}):"boolean"==typeof o?(this.featureSupported(e,o),o&&this.initFeature(e)):this.featureSupported(e,!1)},initFeature:function(e){var t=this,r=this.featureModules[e],o=void 0;try{o=r._rs_init(this)}catch(t){return void this.featureFailed(e,t)}"object"===(void 0===o?"undefined":n(o))&&"function"==typeof o.then?o.then(function(){t.featureInitialized(e)},function(r){t.featureFailed(e,r)}):this.featureInitialized(e)},featureFailed:function(e,t){i("[RemoteStorage] [FEATURE "+e+"] initialization failed ("+t+")"),this.featureDone()},featureSupported:function(e,t){i("[RemoteStorage] [FEATURE "+e+"] "+(t?"":" not")+" supported"),t||this.featureDone()},featureInitialized:function(e){i("[RemoteStorage] [FEATURE "+e+"] initialized."),this.features.push({name:e,init:this.featureModules[e]._rs_init,supported:!0,cleanup:this.featureModules[e]._rs_cleanup}),this.featureDone()},featureDone:function(){this.featuresDone++,this.featuresDone===Object.keys(this.featureModules).length&&setTimeout(this.featuresLoaded.bind(this),0)},_setCachingModule:function(){var e=this;["IndexedDB","LocalStorage","InMemoryStorage"].some(function(t){if(e.features.some(function(e){return e.name===t}))return e.features.local=e.featureModules[t],!0})},_fireReady:function(){try{this.readyFired||(this._emit("ready"),this.readyFired=!0)}catch(e){console.error("'ready' failed: ",e,e.stack),this._emit("error",e)}},featuresLoaded:function(){var e=this;i("[REMOTESTORAGE] All features loaded !"),this._setCachingModule(),this.local=a.cache&&this.features.local&&new this.features.local,this.local&&this.remote?(this._setGPD(s,this),this._bindChange(this.local)):this.remote&&this._setGPD(this.remote,this.remote),this.remote&&(this.remote.on("connected",function(){e._fireReady(),e._emit("connected")}),this.remote.on("not-connected",function(){e._fireReady(),e._emit("not-connected")}),this.remote.connected&&(this._fireReady(),this._emit("connected")),this.hasFeature("Authorize")||this.remote.stopWaitingForToken()),this._collectCleanupFunctions();try{this._allLoaded=!0,this._emit("features-loaded")}catch(e){o.logError(e),this._emit("error",e)}this._processPending()},_collectCleanupFunctions:function(){this._cleanups=[];for(var e=0;e=301&&i.status<=302){var s=i.getResponseHeader("Location");return function(e){return"string"==typeof e&&"https"===e.split("://")[0]}(s)?u():t(a({message:"no redirect URL found",url:e,status:i.status}))}return t(a({message:"error during request",url:e,status:i.status}))}}function u(){i.onreadystatechange=function(){4===i.readyState&&s()},i.onload=function(){s()},i.ontimeout=function(){return t(a({message:"request timed out",url:e,status:i.status}))},i.open("GET",e,!0),i.timeout=n.config.request_timeout,i.setRequestHeader("Accept","application/jrd+json, application/json"),i.send()}return u()},u.prototype.__isValidJSON=function(e){try{JSON.parse(e)}catch(e){return!1}return!0},u.prototype.__isLocalhost=function(e){return/^localhost(\.localdomain)?(\:[0-9]+)?$/.test(e)},u.prototype.__processJRD=function(e,t,r,n){var s=JSON.parse(t);if("object"!=typeof s||"object"!=typeof s.links)return void 0!==s.error?r(a({message:s.error,request:e})):r(a({message:"unknown response from server",request:e}));var u=s.links;Array.isArray(u)||(u=[]);var c={object:s,json:t,idx:{}};c.idx.properties={name:void 0},c.idx.links=JSON.parse(JSON.stringify(i)),u.map(function(e,t){if(o.hasOwnProperty(e.rel)&&c.idx.links[o[e.rel]]){var r={};Object.keys(e).map(function(t,n){r[t]=e[t]}),c.idx.links[o[e.rel]].push(r)}});var h=JSON.parse(t).properties;for(var l in h)h.hasOwnProperty(l)&&"http://packetizer.com/ns/name"===l&&(c.idx.properties.name=h[l]);return n(c)},u.prototype.lookup=function(e,t){if("string"!=typeof e)throw new Error("first parameter must be a user address");if("function"!=typeof t)throw new Error("second parameter must be a callback");var r=this,n="";n=e.indexOf("://")>-1?e.replace(/ /g,"").split("/")[2]:e.replace(/ /g,"").split("@")[1];var o=0,i="https";function a(){var t="";return e.split("://")[1]||(t="acct:"),i+"://"+n+"/.well-known/"+s[o]+"?resource="+t+e}function u(e){if(r.config.uri_fallback&&"webfist.org"!==n&&o!==s.length-1)return o+=1,c();if(!r.config.tls_only&&"https"===i)return o=0,i="http",c();if(!r.config.webfist_fallback||"webfist.org"===n)return t(e);o=0,i="http",n="webfist.org";var u=a();r.__fetchJRD(u,t,function(e){r.__processJRD(u,e,t,function(e){"object"==typeof e.idx.links.webfist&&"string"==typeof e.idx.links.webfist[0].href&&r.__fetchJRD(e.idx.links.webfist[0].href,t,function(e){r.__processJRD(u,e,t,function(e){return t(null,t)})})})})}function c(){var e=a();r.__fetchJRD(e,u,function(n){r.__processJRD(e,n,t,function(e){t(null,e)})})}return r.__isLocalhost(n)&&(i="http"),setTimeout(c,0)},u.prototype.lookupLink=function(e,t,r){if(!i.hasOwnProperty(t))return r("unsupported rel "+t);this.lookup(e,function(e,n){var o=n.idx.links[t];return e?r(e):0===o.length?r('no links found with rel="'+t+'"'):r(null,o[0])})},void 0===(n=function(){return u}.apply(t,[]))||(e.exports=n)}()},function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},function(e,t){t.read=function(e,t,r,n,o){var i,s,a=8*o-n-1,u=(1<>1,h=-7,l=r?o-1:0,f=r?-1:1,d=e[t+l];for(l+=f,i=d&(1<<-h)-1,d>>=-h,h+=a;h>0;i=256*i+e[t+l],l+=f,h-=8);for(s=i&(1<<-h)-1,i>>=-h,h+=n;h>0;s=256*s+e[t+l],l+=f,h-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),i-=c}return(d?-1:1)*s*Math.pow(2,i-n)},t.write=function(e,t,r,n,o,i){var s,a,u,c=8*i-o-1,h=(1<>1,f=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:i-1,p=n?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?f/u:f*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=h?(a=0,s=h):s+l>=1?(a=(t*u-1)*Math.pow(2,o),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,o),s=0));o>=8;e[r+d]=255&a,d+=p,a/=256,o-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,c-=8);e[r+d-p]|=128*m}},function(e,t,r){"use strict";t.byteLength=function(e){return 3*e.length/4-c(e)},t.toByteArray=function(e){var t,r,n,s,a,u=e.length;s=c(e),a=new i(3*u/4-s),r=s>0?u-4:u;var h=0;for(t=0;t>16&255,a[h++]=n>>8&255,a[h++]=255&n;2===s?(n=o[e.charCodeAt(t)]<<2|o[e.charCodeAt(t+1)]>>4,a[h++]=255&n):1===s&&(n=o[e.charCodeAt(t)]<<10|o[e.charCodeAt(t+1)]<<4|o[e.charCodeAt(t+2)]>>2,a[h++]=n>>8&255,a[h++]=255&n);return a},t.fromByteArray=function(e){for(var t,r=e.length,o=r%3,i="",s=[],a=0,u=r-o;au?u:a+16383));1===o?(t=e[r-1],i+=n[t>>2],i+=n[t<<4&63],i+="=="):2===o&&(t=(e[r-2]<<8)+e[r-1],i+=n[t>>10],i+=n[t>>4&63],i+=n[t<<2&63],i+="=");return s.push(i),s.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}function h(e,t,r){for(var o,i,s=[],a=t;a>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return s.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},function(e,t,r){"use strict";(function(e){ +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT */ -"undefined"==typeof XMLHttpRequest&&(XMLHttpRequest=r(25)),function(r){function i(e){return e.toString=function(){return this.message},e}function s(e){return"string"==typeof e&&"https"===e.split("://")[0]}function a(e){"object"!=typeof e&&(e={}),this.config={tls_only:void 0===e.tls_only||e.tls_only,webfist_fallback:void 0!==e.webfist_fallback&&e.webfist_fallback,uri_fallback:void 0!==e.uri_fallback&&e.uri_fallback,request_timeout:void 0!==e.request_timeout?e.request_timeout:1e4}}var u={"http://webfist.org/spec/rel":"webfist","http://webfinger.net/rel/avatar":"avatar",remotestorage:"remotestorage","http://tools.ietf.org/id/draft-dejong-remotestorage":"remotestorage",remoteStorage:"remotestorage","http://www.packetizer.com/rel/share":"share","http://webfinger.net/rel/profile-page":"profile",me:"profile",vcard:"vcard",blog:"blog","http://packetizer.com/rel/blog":"blog","http://schemas.google.com/g/2010#updates-from":"updates","https://camlistore.org/rel/server":"camilstore"},c={avatar:[],remotestorage:[],blog:[],vcard:[],updates:[],share:[],profile:[],webfist:[],camlistore:[]},h=["webfinger","host-meta","host-meta.json"];a.prototype.__fetchJRD=function(e,t,r){function n(){if(!u){if(u=!0,200===c.status)return a.__isValidJSON(c.responseText)?r(c.responseText):t(i({message:"invalid json",url:e,status:c.status}));if(404===c.status)return t(i({message:"resource not found",url:e,status:c.status}));if(c.status>=301&&c.status<=302){return s(c.getResponseHeader("Location"))?o():t(i({message:"no redirect URL found",url:e,status:c.status}))}return t(i({message:"error during request",url:e,status:c.status}))}}function o(){c.onreadystatechange=function(){4===c.readyState&&n()},c.onload=function(){n()},c.ontimeout=function(){return t(i({message:"request timed out",url:e,status:c.status}))},c.open("GET",e,!0),c.timeout=a.config.request_timeout,c.setRequestHeader("Accept","application/jrd+json, application/json"),c.send()}var a=this,u=!1,c=new XMLHttpRequest;return o()},a.prototype.__isValidJSON=function(e){try{JSON.parse(e)}catch(e){return!1}return!0},a.prototype.__isLocalhost=function(e){return/^localhost(\.localdomain)?(\:[0-9]+)?$/.test(e)},a.prototype.__processJRD=function(e,t,r,n){var o=JSON.parse(t);if("object"!=typeof o||"object"!=typeof o.links)return r(i(void 0!==o.error?{message:o.error,request:e}:{message:"unknown response from server",request:e}));var s=o.links;Array.isArray(s)||(s=[]);var a={object:o,json:t,idx:{}};a.idx.properties={name:void 0},a.idx.links=JSON.parse(JSON.stringify(c)),s.map(function(e,t){if(u.hasOwnProperty(e.rel)&&a.idx.links[u[e.rel]]){var r={};Object.keys(e).map(function(t,n){r[t]=e[t]}),a.idx.links[u[e.rel]].push(r)}});var h=JSON.parse(t).properties;for(var l in h)h.hasOwnProperty(l)&&"http://packetizer.com/ns/name"===l&&(a.idx.properties.name=h[l]);return n(a)},a.prototype.lookup=function(e,t){function r(){var t="";return e.split("://")[1]||(t="acct:"),u+"://"+s+"/.well-known/"+h[a]+"?resource="+t+e}function n(e){if(i.config.uri_fallback&&"webfist.org"!==s&&a!==h.length-1)return a+=1,o();if(!i.config.tls_only&&"https"===u)return a=0,u="http",o();if(!i.config.webfist_fallback||"webfist.org"===s)return t(e);a=0,u="http",s="webfist.org";var n=r();i.__fetchJRD(n,t,function(e){i.__processJRD(n,e,t,function(e){"object"==typeof e.idx.links.webfist&&"string"==typeof e.idx.links.webfist[0].href&&i.__fetchJRD(e.idx.links.webfist[0].href,t,function(e){i.__processJRD(n,e,t,function(e){return t(null,t)})})})})}function o(){var e=r();i.__fetchJRD(e,n,function(r){i.__processJRD(e,r,t,function(e){t(null,e)})})}if("string"!=typeof e)throw new Error("first parameter must be a user address");if("function"!=typeof t)throw new Error("second parameter must be a callback");var i=this,s="";s=e.indexOf("://")>-1?e.replace(/ /g,"").split("/")[2]:e.replace(/ /g,"").split("@")[1];var a=0,u="https";return i.__isLocalhost(s)&&(u="http"),setTimeout(o,0)},a.prototype.lookupLink=function(e,t,r){if(!c.hasOwnProperty(t))return r("unsupported rel "+t);this.lookup(e,function(e,n){var o=n.idx.links[t];return e?r(e):0===o.length?r('no links found with rel="'+t+'"'):r(null,o[0])})},n=[],void 0!==(o=function(){return a}.apply(t,n))&&(e.exports=o)}()},function(e,t){e.exports=XMLHttpRequest},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=r(0),i=r(1),s=r(27),a=r(3),u={features:[],featuresDone:0,readyFired:!1,loadFeatures:function(){var e=this;this.features=[],this.featuresDone=0,this.readyFired=!1,this.featureModules={WireClient:r(7),Dropbox:r(11),GoogleDrive:r(13),Access:r(15),Discover:r(14),Authorize:r(4),BaseClient:r(5),Env:r(12)},a.cache&&o.extend(this.featureModules,{Caching:r(16),IndexedDB:r(28),LocalStorage:r(29),InMemoryStorage:r(30),Sync:r(8)}),a.disableFeatures.forEach(function(t){e.featureModules[t]&&delete e.featureModules[t]}),this._allLoaded=!1;for(var t in this.featureModules)this.loadFeature(t)},hasFeature:function(e){for(var t=this.features.length-1;t>=0;t--)if(this.features[t].name===e)return this.features[t].supported;return!1},loadFeature:function(e){var t=this,r=this.featureModules[e],o=!r._rs_supported||r._rs_supported();i("[RemoteStorage] [FEATURE "+e+"] initializing ..."),"object"===(void 0===o?"undefined":n(o))?o.then(function(){t.featureSupported(e,!0),t.initFeature(e)},function(){t.featureSupported(e,!1)}):"boolean"==typeof o?(this.featureSupported(e,o),o&&this.initFeature(e)):this.featureSupported(e,!1)},initFeature:function(e){var t=this,r=this.featureModules[e],o=void 0;try{o=r._rs_init(this)}catch(t){return void this.featureFailed(e,t)}"object"===(void 0===o?"undefined":n(o))&&"function"==typeof o.then?o.then(function(){t.featureInitialized(e)},function(r){t.featureFailed(e,r)}):this.featureInitialized(e)},featureFailed:function(e,t){i("[RemoteStorage] [FEATURE "+e+"] initialization failed ("+t+")"),this.featureDone()},featureSupported:function(e,t){i("[RemoteStorage] [FEATURE "+e+"] "+(t?"":" not")+" supported"),t||this.featureDone()},featureInitialized:function(e){i("[RemoteStorage] [FEATURE "+e+"] initialized."),this.features.push({name:e,init:this.featureModules[e]._rs_init,supported:!0,cleanup:this.featureModules[e]._rs_cleanup}),this.featureDone()},featureDone:function(){++this.featuresDone===Object.keys(this.featureModules).length&&setTimeout(this.featuresLoaded.bind(this),0)},_setCachingModule:function(){var e=this;["IndexedDB","LocalStorage","InMemoryStorage"].some(function(t){if(e.features.some(function(e){return e.name===t}))return e.features.local=e.featureModules[t],!0})},_fireReady:function(){try{this.readyFired||(this._emit("ready"),this.readyFired=!0)}catch(e){console.error("'ready' failed: ",e,e.stack),this._emit("error",e)}},featuresLoaded:function(){var e=this;i("[REMOTESTORAGE] All features loaded !"),this._setCachingModule(),this.local=a.cache&&this.features.local&&new this.features.local,this.local&&this.remote?(this._setGPD(s,this),this._bindChange(this.local)):this.remote&&this._setGPD(this.remote,this.remote),this.remote&&(this.remote.on("connected",function(){e._fireReady(),e._emit("connected")}),this.remote.on("not-connected",function(){e._fireReady(),e._emit("not-connected")}),this.remote.connected&&(this._fireReady(),this._emit("connected")),this.hasFeature("Authorize")||this.remote.stopWaitingForToken()),this._collectCleanupFunctions();try{this._allLoaded=!0,this._emit("features-loaded")}catch(e){o.logError(e),this._emit("error",e)}this._processPending()},_collectCleanupFunctions:function(){this._cleanups=[];for(var e=0;e0?this.getNodesFromDb(t).then(function(e){for(var t in r)e[t]=r[t];return e}):Promise.resolve(r)},setNodes:function(e){for(var t in e)this.changesQueued[t]=e[t]||!1;return this.maybeFlush(),Promise.resolve()},maybeFlush:function(){0===this.putsRunning?this.flushChangesQueued():this.commitSlownessWarning||(this.commitSlownessWarning=setInterval(function(){console.warn("WARNING: waited more than 10 seconds for previous commit to finish")},1e4))},flushChangesQueued:function(){this.commitSlownessWarning&&(clearInterval(this.commitSlownessWarning),this.commitSlownessWarning=null),Object.keys(this.changesQueued).length>0&&(this.changesRunning=this.changesQueued,this.changesQueued={},this.setNodesInDb(this.changesRunning).then(this.flushChangesQueued.bind(this)))},getNodesFromDb:function(e){var t=this;return new Promise(function(r,n){var o=t.db.transaction(["nodes"],"readonly"),i=o.objectStore("nodes"),s={};t.getsRunning++,e.map(function(e){i.get(e).onsuccess=function(t){s[e]=t.target.result}}),o.oncomplete=function(){r(s),this.getsRunning--}.bind(t),o.onerror=o.onabort=function(){n("get transaction error/abort"),this.getsRunning--}.bind(t)})},setNodesInDb:function(e){var t=this;return new Promise(function(r,n){var s=t.db.transaction(["nodes"],"readwrite"),a=s.objectStore("nodes"),u=(new Date).getTime();t.putsRunning++,i("[IndexedDB] Starting put",e,t.putsRunning);for(var c in e){var h=e[c];if("object"===(void 0===h?"undefined":o(h)))try{a.put(h)}catch(e){throw i("[IndexedDB] Error while putting",h,e),e}else try{a.delete(c)}catch(e){throw i("[IndexedDB] Error while removing",a,h,e),e}}s.oncomplete=function(){this.putsRunning--,i("[IndexedDB] Finished put",e,this.putsRunning,(new Date).getTime()-u+"ms"),r()}.bind(t),s.onerror=function(){this.putsRunning--,n("transaction error")}.bind(t),s.onabort=function(){n("transaction abort"),this.putsRunning--}.bind(t)})},reset:function(e){var t=this,r=this.db.name;this.db.close(),c.clean(this.db.name,function(){c.open(r,function(r,n){r?i("[IndexedDB] Error while resetting local storage",r):t.db=n,"function"==typeof e&&e(self)})})},forAllNodes:function(e){var t=this;return new Promise(function(r){t.db.transaction(["nodes"],"readonly").objectStore("nodes").openCursor().onsuccess=function(n){var o=n.target.result;o?(e(t.migrate(o.value)),o.continue()):r()}})},closeDB:function(){this.db.close()}},c.open=function(e,t){var r=setTimeout(function(){t("timeout trying to open db")},1e4);try{var n=indexedDB.open(e,2);n.onerror=function(){i("[IndexedDB] Opening DB failed",n),clearTimeout(r),t(n.error)},n.onupgradeneeded=function(e){var t=n.result;i("[IndexedDB] Upgrade: from ",e.oldVersion," to ",e.newVersion),1!==e.oldVersion&&(i("[IndexedDB] Creating object store: nodes"),t.createObjectStore("nodes",{keyPath:"path"})),i("[IndexedDB] Creating object store: changes"),t.createObjectStore("changes",{keyPath:"path"})},n.onsuccess=function(){clearTimeout(r);var o=n.result;if(!o.objectStoreNames.contains("nodes")||!o.objectStoreNames.contains("changes"))return i("[IndexedDB] Missing object store. Resetting the database."),void c.clean(e,function(){c.open(e,t)});t(null,n.result)}}catch(n){i("[IndexedDB] Failed to open database: "+n),i("[IndexedDB] Resetting database and trying again."),clearTimeout(r),c.clean(e,function(){c.open(e,t)})}},c.clean=function(e,t){var r=indexedDB.deleteDatabase(e);r.onsuccess=function(){i("[IndexedDB] Done removing DB"),t()},r.onerror=r.onabort=function(t){console.error('Failed to remove database "'+e+'"',t)}},c._rs_init=function(e){return new Promise(function(t,r){c.open("remotestorage",function(o,i){o?r(o):(n=i,i.onerror=function(){e._emit("error",o)},t())})})},c._rs_supported=function(){return new Promise(function(e,t){var r=u.getGlobalContext(),n=!1;if("undefined"!=typeof navigator&&navigator.userAgent.match(/Android (2|3|4\.[0-3])/)&&(navigator.userAgent.match(/Chrome|Firefox/)||(n=!0)),"indexedDB"in r&&!n)try{var o=indexedDB.open("rs-check");o.onerror=function(){t()},o.onsuccess=function(){o.result.close(),indexedDB.deleteDatabase("rs-check"),e()}}catch(e){t()}else t()})},c._rs_cleanup=function(e){return new Promise(function(t){e.local&&e.local.closeDB(),c.clean("remotestorage",t)})},e.exports=c},function(e,t,r){"use strict";function n(e){return e.substr(0,c.length)===c||e.substr(0,h.length)===h}function o(e){return e.substr(0,c.length)===c}var i=r(9),s=r(1),a=r(2),u=r(0),c="remotestorage:cache:nodes:",h="remotestorage:cache:changes:",l=function(){i(this),s("[LocalStorage] Registering events"),a(this,"change","local-events-done")};l.prototype={getNodes:function(e){for(var t={},r=0,n=e.length;r=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function p(e,t){if(u.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return F(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return q(e).length;default:if(n)return F(e).length;t=(""+t).toLowerCase(),n=!0}}function m(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function g(e,t,r,n,o){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof t&&(t=u.from(t,n)),u.isBuffer(t))return 0===t.length?-1:y(e,t,r,n,o);if("number"==typeof t)return t&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):y(e,[t],r,n,o);throw new TypeError("val must be string, number or Buffer")}function y(e,t,r,n,o){var i,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){var h=-1;for(i=r;ia&&(r=a-u),i=r;i>=0;i--){for(var l=!0,f=0;fo&&(n=o):n=o;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var s=0;s>8,o=r%256,i.push(o),i.push(n);return i}(t,e.length-r),e,r,n)}function S(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function T(e,t,r){r=Math.min(e.length,r);for(var n=[],o=t;o239?4:c>223?3:c>191?2:1;if(o+l<=r)switch(l){case 1:c<128&&(h=c);break;case 2:128==(192&(i=e[o+1]))&&(u=(31&c)<<6|63&i)>127&&(h=u);break;case 3:i=e[o+1],s=e[o+2],128==(192&i)&&128==(192&s)&&(u=(15&c)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:i=e[o+1],s=e[o+2],a=e[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(h=u)}null===h?(h=65533,l=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),o+=l}return function(e){var t=e.length;if(t<=A)return String.fromCharCode.apply(String,e);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return I(this,t,r);case"utf8":case"utf-8":return T(this,t,r);case"ascii":return R(this,t,r);case"latin1":case"binary":return k(this,t,r);case"base64":return S(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}.apply(this,arguments)},u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===u.compare(this,e)},u.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),""},u.prototype.compare=function(e,t,r,n,o){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),t<0||r>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=r)return 0;if(n>=o)return-1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,o>>>=0,this===e)return 0;for(var i=o-n,s=r-t,a=Math.min(i,s),c=this.slice(n,o),h=e.slice(t,r),l=0;lo)&&(r=o),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return v(this,e,t,r);case"utf8":case"utf-8":return b(this,e,t,r);case"ascii":return _(this,e,t,r);case"latin1":case"binary":return w(this,e,t,r);case"base64":return P(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function R(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;on)&&(r=n);for(var o="",i=t;ir)throw new RangeError("Trying to access beyond buffer length")}function M(e,t,r,n,o,i){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||te.length)throw new RangeError("Index out of range")}function N(e,t,r,n){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-r,2);o>>8*(n?o:1-o)}function x(e,t,r,n){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-r,4);o>>8*(n?o:3-o)&255}function U(e,t,r,n,o,i){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function j(e,t,r,n,i){return i||U(e,0,r,4),o.write(e,t,r,n,23,4),r+4}function B(e,t,r,n,i){return i||U(e,0,r,8),o.write(e,t,r,n,52,8),r+8}u.prototype.slice=function(e,t){var r,n=this.length;if(e=~~e,t=void 0===t?n:~~t,e<0?(e+=n)<0&&(e=0):e>n&&(e=n),t<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(o*=256);)n+=this[e+--t]*o;return n},u.prototype.readUInt8=function(e,t){return t||C(e,1,this.length),this[e]},u.prototype.readUInt16LE=function(e,t){return t||C(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUInt16BE=function(e,t){return t||C(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUInt32LE=function(e,t){return t||C(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUInt32BE=function(e,t){return t||C(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||C(e,t,this.length);for(var n=this[e],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*t)),n},u.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||C(e,t,this.length);for(var n=t,o=1,i=this[e+--n];n>0&&(o*=256);)i+=this[e+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},u.prototype.readInt8=function(e,t){return t||C(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){t||C(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(e,t){t||C(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(e,t){return t||C(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return t||C(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readFloatLE=function(e,t){return t||C(e,4,this.length),o.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return t||C(e,4,this.length),o.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return t||C(e,8,this.length),o.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return t||C(e,8,this.length),o.read(this,e,!1,52,8)},u.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||M(this,e,t,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[t]=255&e;++i=0&&(i*=256);)this[t+o]=e/i&255;return t+r},u.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||M(this,e,t,1,255,0),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},u.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||M(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):N(this,e,t,!0),t+2},u.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||M(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):N(this,e,t,!1),t+2},u.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||M(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):x(this,e,t,!0),t+4},u.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||M(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):x(this,e,t,!1),t+4},u.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var o=Math.pow(2,8*r-1);M(this,e,t,r,o-1,-o)}var i=0,s=1,a=0;for(this[t]=255&e;++i>0)-a&255;return t+r},u.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var o=Math.pow(2,8*r-1);M(this,e,t,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+r},u.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||M(this,e,t,1,127,-128),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||M(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):N(this,e,t,!0),t+2},u.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||M(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):N(this,e,t,!1),t+2},u.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||M(this,e,t,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):x(this,e,t,!0),t+4},u.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||M(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):x(this,e,t,!1),t+4},u.prototype.writeFloatLE=function(e,t,r){return j(this,e,t,!0,r)},u.prototype.writeFloatBE=function(e,t,r){return j(this,e,t,!1,r)},u.prototype.writeDoubleLE=function(e,t,r){return B(this,e,t,!0,r)},u.prototype.writeDoubleBE=function(e,t,r){return B(this,e,t,!1,r)},u.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--o)e[o+t]=this[o+r];else if(i<1e3||!u.TYPED_ARRAY_SUPPORT)for(o=0;o>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function q(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(L,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function J(e,t,r,n){for(var o=0;o=t.length||o>=e.length);++o)t[o+r]=e[o];return o}}).call(this,r(9))},function(e,t,r){"use strict";var n={uris:{},schemas:{},aliases:{},declare:function(e,t,r,n){var o=e+"/"+t;if(n.extends){var i,s=n.extends.split("/");i=1===s.length?e+"/"+s.shift():s.join("/");var a=this.uris[i];if(!a)throw"Type '"+o+"' tries to extend unknown schema '"+i+"'";n.extends=this.schemas[a]}this.uris[o]=r,this.aliases[r]=o,this.schemas[r]=n},resolveAlias:function(e){return this.uris[e]},getSchema:function(e){return this.schemas[e]},inScope:function(e){var t=e.length,r={};for(var n in this.uris)if(n.substr(0,t+1)===e+"/"){var o=this.uris[n];r[o]=this.schemas[o]}return r}},o=function(e){var t=new Error("Schema not found: "+e);return t.name="SchemaNotFound",t};o.prototype=Error.prototype,n.SchemaNotFound=o,e.exports=n},function(e,t,r){var n,o,i;o=[],void 0===(i="function"==typeof(n=function(){var e,t,r,n;Object.keys||(Object.keys=(e=Object.prototype.hasOwnProperty,t=!{toString:null}.propertyIsEnumerable("toString"),n=(r=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"]).length,function(o){if("object"!=typeof o&&"function"!=typeof o||null===o)throw new TypeError("Object.keys called on non-object");var i=[];for(var s in o)e.call(o,s)&&i.push(s);if(t)for(var a=0;a>>0;if(0===r)return-1;var n=0;if(arguments.length>1&&((n=Number(arguments[1]))!=n?n=0:0!==n&&n!==1/0&&n!==-1/0&&(n=(n>0||-1)*Math.floor(Math.abs(n)))),n>=r)return-1;for(var o=n>=0?n:Math.max(r-Math.abs(n),0);o0&&(t+=h.suffices["*"]&&r||",",h.suffices["*"]&&u&&(t+=h.name+"=")),t+=a?encodeURIComponent(l[d]).replace(/!/g,"%21"):s(l[d])}else if("object"==typeof l){u&&!h.suffices["*"]&&(t+=h.name+"=");var p=!0;for(var m in l)p||(t+=h.suffices["*"]&&r||","),p=!1,t+=a?encodeURIComponent(m).replace(/!/g,"%21"):s(m),t+=h.suffices["*"]?"=":",",t+=a?encodeURIComponent(l[m]).replace(/!/g,"%21"):s(l[m])}else u&&(t+=h.name,c&&""===l||(t+="=")),null!=h.truncate&&(l=l.substring(0,h.truncate)),t+=a?encodeURIComponent(l).replace(/!/g,"%21"):s(l)}return t};return _.varNames=h,{prefix:n,substitution:_}}function u(e){if(!(this instanceof u))return new u(e);for(var t=e.split("{"),r=[t.shift()],n=[],o=[],i=[];t.length>0;){var s=t.shift(),c=s.split("}")[0],h=s.substring(c.length+1),l=a(c);o.push(l.substitution),n.push(l.prefix),r.push(h),i=i.concat(l.substitution.varNames)}this.fill=function(e){for(var t=r[0],n=0;n0&&"/"===t.charAt(e.length-1)||"#"===r.charAt(0)||"?"===r.charAt(0))return!0}return!1}(t,e.id)&&void 0===this.schemas[e.id]&&(this.schemas[e.id]=e),e)if("enum"!==n)if("object"==typeof e[n])this.searchSchemas(e[n],t);else if("$ref"===n){var o=m(e[n]);o&&void 0===this.schemas[o]&&void 0===this.missingMap[o]&&(this.missingMap[o]=o)}},c.prototype.addSchema=function(e,t){if("string"!=typeof e||void 0===t){if("object"!=typeof e||"string"!=typeof e.id)return;e=(t=e).id}e===m(e)+"#"&&(e=m(e)),this.schemas[e]=t,delete this.missingMap[e],g(t,e),this.searchSchemas(t,e)},c.prototype.getSchemaMap=function(){var e={};for(var t in this.schemas)e[t]=this.schemas[t];return e},c.prototype.getSchemaUris=function(e){var t=[];for(var r in this.schemas)e&&!e.test(r)||t.push(r);return t},c.prototype.getMissingUris=function(e){var t=[];for(var r in this.missingMap)e&&!e.test(r)||t.push(r);return t},c.prototype.dropSchemas=function(){this.schemas={},this.reset()},c.prototype.reset=function(){this.missing=[],this.missingMap={},this.errors=[]},c.prototype.validateAll=function(e,t,r,n,o){var i;if(!(t=this.resolveRefs(t)))return null;if(t instanceof P)return this.errors.push(t),t;var s,a=this.errors.length,u=null,c=null;if(this.checkRecursive&&e&&"object"==typeof e){if(i=!this.scanned.length,e[this.validatedSchemasKey]){var h=e[this.validatedSchemasKey].indexOf(t);if(-1!==h)return this.errors=this.errors.concat(e[this.validationErrorsKey][h]),null}if(Object.isFrozen(e)&&-1!==(s=this.scannedFrozen.indexOf(e))){var l=this.scannedFrozenSchemas[s].indexOf(t);if(-1!==l)return this.errors=this.errors.concat(this.scannedFrozenValidationErrors[s][l]),null}if(this.scanned.push(e),Object.isFrozen(e))-1===s&&(s=this.scannedFrozen.length,this.scannedFrozen.push(e),this.scannedFrozenSchemas.push([])),u=this.scannedFrozenSchemas[s].length,this.scannedFrozenSchemas[s][u]=t,this.scannedFrozenValidationErrors[s][u]=[];else{if(!e[this.validatedSchemasKey])try{Object.defineProperty(e,this.validatedSchemasKey,{value:[],configurable:!0}),Object.defineProperty(e,this.validationErrorsKey,{value:[],configurable:!0})}catch(t){e[this.validatedSchemasKey]=[],e[this.validationErrorsKey]=[]}c=e[this.validatedSchemasKey].length,e[this.validatedSchemasKey][c]=t,e[this.validationErrorsKey][c]=[]}}var f=this.errors.length,d=this.validateBasic(e,t,o)||this.validateNumeric(e,t,o)||this.validateString(e,t,o)||this.validateArray(e,t,o)||this.validateObject(e,t,o)||this.validateCombinations(e,t,o)||this.validateHypermedia(e,t,o)||this.validateFormat(e,t,o)||this.validateDefinedKeywords(e,t,o)||null;if(i){for(;this.scanned.length;){var p=this.scanned.pop();delete p[this.validatedSchemasKey]}this.scannedFrozen=[],this.scannedFrozenSchemas=[]}if(d||f!==this.errors.length)for(;r&&r.length||n&&n.length;){var m=r&&r.length?""+r.pop():null,g=n&&n.length?""+n.pop():null;d&&(d=d.prefixWith(m,g)),this.prefixErrors(f,m,g)}return null!==u?this.scannedFrozenValidationErrors[s][u]=this.errors.slice(a):null!==c&&(e[this.validationErrorsKey][c]=this.errors.slice(a)),this.handleError(d)},c.prototype.validateFormat=function(e,t){if("string"!=typeof t.format||!this.formatValidators[t.format])return null;var r=this.formatValidators[t.format].call(null,e,t);return"string"==typeof r||"number"==typeof r?this.createError(v.FORMAT_CUSTOM,{message:r},"","/format",null,e,t):r&&"object"==typeof r?this.createError(v.FORMAT_CUSTOM,{message:r.message||"?"},r.dataPath||"",r.schemaPath||"/format",null,e,t):null},c.prototype.validateDefinedKeywords=function(e,t,r){for(var n in this.definedKeywords)if(void 0!==t[n])for(var o=this.definedKeywords[n],i=0;i=l&&nt.maximum)return this.createError(v.NUMBER_MAXIMUM,{value:e,maximum:t.maximum},"","/maximum",null,e,t);if(t.exclusiveMaximum&&e===t.maximum)return this.createError(v.NUMBER_MAXIMUM_EXCLUSIVE,{value:e,maximum:t.maximum},"","/exclusiveMaximum",null,e,t)}return null},c.prototype.validateNaN=function(e,t){return"number"!=typeof e?null:!0===isNaN(e)||e===1/0||e===-1/0?this.createError(v.NUMBER_NOT_A_NUMBER,{value:e},"","/type",null,e,t):null},c.prototype.validateString=function(e,t,r){return this.validateStringLength(e,t,r)||this.validateStringPattern(e,t,r)||null},c.prototype.validateStringLength=function(e,t){return"string"!=typeof e?null:void 0!==t.minLength&&e.lengtht.maxLength?this.createError(v.STRING_LENGTH_LONG,{length:e.length,maximum:t.maxLength},"","/maxLength",null,e,t):null},c.prototype.validateStringPattern=function(e,t){if("string"!=typeof e||"string"!=typeof t.pattern&&!(t.pattern instanceof RegExp))return null;var r;if(t.pattern instanceof RegExp)r=t.pattern;else{var n,o="",i=t.pattern.match(/^\/(.+)\/([img]*)$/);i?(n=i[1],o=i[2]):n=t.pattern,r=new RegExp(n,o)}return r.test(e)?null:this.createError(v.STRING_PATTERN,{pattern:t.pattern},"","/pattern",null,e,t)},c.prototype.validateArray=function(e,t,r){return Array.isArray(e)&&(this.validateArrayLength(e,t,r)||this.validateArrayUniqueItems(e,t,r)||this.validateArrayItems(e,t,r))||null},c.prototype.validateArrayLength=function(e,t){var r;return void 0!==t.minItems&&e.lengtht.maxItems&&(r=this.createError(v.ARRAY_LENGTH_LONG,{length:e.length,maximum:t.maxItems},"","/maxItems",null,e,t),this.handleError(r))?r:null},c.prototype.validateArrayUniqueItems=function(e,t){if(t.uniqueItems)for(var r=0;rt.maxProperties&&(r=this.createError(v.OBJECT_PROPERTIES_MAXIMUM,{propertyCount:n.length,maximum:t.maxProperties},"","/maxProperties",null,e,t),this.handleError(r))?r:null},c.prototype.validateObjectRequiredProperties=function(e,t){if(void 0!==t.required)for(var r=0;r 10000");if(void 0!==v[e])throw new Error("Error already defined: "+e+" as "+v[e]);if(void 0!==b[t])throw new Error("Error code already used: "+b[t]+" as "+t);for(var n in v[e]=t,b[t]=e,w[e]=w[t]=r,E){var o=E[n];o[e]&&(o[t]=o[t]||o[e])}},reset:function(){o.reset(),this.error=null,this.missing=[],this.valid=!0},missing:[],error:null,valid:!0,normSchema:g,resolveUrl:p,getDocumentUri:m,errorCodes:v};return i.language(t||"en"),i}();return S.addLanguage("en-gb",w),S.tv4=S,S})?n.apply(t,o):n)||(e.exports=i)},function(e,t,r){e.exports=r(16)}])}); //# sourceMappingURL=remotestorage.js.map \ No newline at end of file diff --git a/release/remotestorage.js.map b/release/remotestorage.js.map index a1fd63b5b..160e2cbe2 100644 --- a/release/remotestorage.js.map +++ b/release/remotestorage.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///release/remotestorage.js"],"names":["e","t","exports","module","define","amd","RemoteStorage","this","n","r","o","i","l","call","m","c","d","Object","defineProperty","configurable","enumerable","get","__esModule","default","prototype","hasOwnProperty","p","s","Array","isArray","toString","ArrayBuffer","byteLength","Int8Array","set","Symbol","iterator","constructor","logError","console","error","message","stack","globalContext","window","getGlobalContext","extend","slice","arguments","forEach","asyncEach","asyncMap","then","resolve","a","u","Promise","defer","length","promise","containingFolder","replace","isFolder","substr","isDocument","baseName","split","cleanPath","map","encodeURIComponent","join","bindAll","bind","equal","Uint8Array","indexOf","push","deepClone","JSON","parse","stringify","pathsFromRoot","pop","localStorageAvailable","localStorage","setItem","removeItem","shouldBeTreatedAsBinary","match","test","readBinaryData","BlobBuilder","WebKitBlobBuilder","append","getBlob","Blob","type","FileReader","addEventListener","result","onloadend","readAsArrayBuffer","logging","log","apply","Error","_validateEvent","_handlers","removeEventListener","splice","_emit","_delegateEvent","on","_addEvent","off","cache","changeEvents","local","remote","conflict","cordovaRedirectUri","modules","backgroundSyncInterval","disableFeatures","discoveryTimeout","isBackground","requestTimeout","syncInterval","getLocation","href","substring","reduce","decodeURIComponent","rsDiscovery","atob","RegExp","state","backend","userAddress","storageApi","properties","btoa","h","cordova","openWindow","configure","token","access_token","setLocation","IMPLIED_FAKE_TOKEN","Unauthorized","name","code","create","document","location","open","closed","url","close","_rs_supported","_rs_init","remotestorage","connect","stopWaitingForToken","hash","_rs_cleanup","SchemaNotFound","makePath","storage","base","moduleName","onChange","_fireChange","Types","scope","getListing","reject","statusCode","body","getAll","keys","all","getFile","data","contentType","revision","storeFile","access","checkPathPermission","warn","put","getObject","storeObject","_attachType","validate","valid","remove","delete","getItemURL","connected","_cleanPath","caching","flush","declareType","_defaultTypeURI","declare","getSchema","validateResult","schemas","inScope","resolveAlias","origin","exec","Function","eval","target","readAsText","items","f","g","y","v","b","_","draft-dejong-remotestorage-00","draft-dejong-remotestorage-01","draft-dejong-remotestorage-02","https://www.w3.org/community/rww/wiki/read-write-web-00#simple","ArrayBufferView","w","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","P","E","S","T","rs","setTimeout","_revisionCache","_request","Authorization","method","request","headers","responseType","online","success","status","getResponseHeader","response","_storageApi","supportsRevs","ifNoneMatch","ETag","Content-Type","ifMatch","isArrayBufferView","XMLHttpRequest","setRequestHeader","onload","clearTimeout","onerror","send","Buffer","action","path","common","itemsMap","getCurrentSyncInterval","oldValue","newValue","remoteStorage","onDiff","addTask","doTasks","_tasks","_running","_timeStarted","onActivate","now","Date","getTime","queueGetRequest","corruptServerItemsMap","corruptItemsMap","corruptRevision","contentLength","timestamp","isCorrupt","hasTasks","getOwnPropertyNames","collectDiffTasks","forAllNodes","needsFetch","needsPush","inConflict","needsRefresh","needsRemotePut","needsRemoteDelete","getParentPath","deleteChildPathsFromTasks","collectRefreshTasks","checkPath","doTask","getNodes","setNodes","autoMergeFolder","autoMergeDocument","_emitChange","lastCommonValue","oldContentType","newContentType","lastCommonContentType","autoMerge","updateCommonTimestamp","markChildren","deleteRemoteTrees","completeFetch","toBeSaved","missingChildren","completePush","stopped","dealWithFailure","interpretStatus","successful","networkProblems","Math","floor","unAuth","notFound","changed","handleGetResponse","handleResponse","SyncError","numThreads","finishTask","collectTasks","done","sync","isBrowser","syncStopped","syncCycle","startSync","stopSync","originalError","previousBody","previousContentType","_updateNodes","_getAllDescendentPaths","fireInitial","diffHandler","migrate","_updateNodesRunning","_updateNodesQueued","_doUpdateNodes","paths","cb","_emitChangeEvents","shift","_getInternals","getLatest","makeNode","isOutdated","_pending","_setGPD","_pendingGPD","_cleanups","_pathHandlers","change","apiKeys","getItem","setBackend","_allLoaded","_init","loadModules","Authorize","DiscoveryError","addModule","authorize","setStorageType","storageType","scopeParameter","String","impliedauth","InAppBrowser","authURL","reconnect","disconnect","enableLog","disableLog","setApiKeys","every","dropbox","appKey","clientId","googledrive","setCordovaRedirectUri","loadFeatures","features","loadFeature","featureSupported","featureDone","featuresDone","featuresLoaded","featureInitialized","featureFailed","hasFeature","_setCachingModule","_collectCleanupFunctions","_fireReady","initFeature","args","_processPending","_bindChange","_dispatchEvent","relativePath","getSyncInterval","setSyncInterval","parseInt","getBackgroundSyncInterval","setBackgroundSyncInterval","getRequestTimeout","setRequestTimeout","_syncTimer","util","value","defaultValue","_storage","justSet","justDelete","_dropboxOrigSync","fetchDelta","_origBaseClientGetItemURL","_origRemote","A","error_summary","R","toLowerCase","propagateSet","_propagate","propagateDelete","_activatePropagation","k","_revCache","_itemRefs","info","email","catch","_getFolder","responseText","entries","path_lower","rev","has_more","cursor","assign","Dropbox-API-Arg","_shareIfNeeded","_getMetadata","_uploadSimple","_deleteSimple","share","_getSharedLink","recursive","include_deleted","ProgressEvent","mode",".tag","mute","update","direct_only","links","isNode","goBackground","goForeground","hiddenProperty","hidden","visibilityChangeEvent","mozHidden","msHidden","webkitHidden","maxAge","_items","_fileIdCache","user","emailAddress","_getFile","etag","mimeType","_getFileId","_updateFile","_createFile","_getMeta","_getParentId","title","parents","kind","id","downloadUrl","exportLinks","next","Content-Length","fileSize","return","_createFolder","tls_only","uri_fallback","request_timeout","lookup","idx","json","reset","claim","_adjustRootPaths","scopeModeMap","checkPermission","_getModuleName","rootPaths","_scopeNameForParameter","scopes","pendingActivations","_remoteStorage","_rootPaths","activateHandler","enable","disable","encodeURI","charAt","truncate","suffices","varNames","prefix","substitution","concat","fill","template","protocol","authority","host","hostname","port","pathname","search","lastIndexOf","$ref","messageParams","params","dataPath","schemaPath","subErrors","stacktrace","setErrorReporter","language","addFormat","addLanguage","freshApi","addSchema","validateAll","banUnknownProperties","missing","validateMultiple","errors","getSchemaMap","getSchemaUris","getMissingUris","dropSchemas","defineKeyword","defineError","normSchema","resolveUrl","getDocumentUri","errorCodes","propertyIsEnumerable","TypeError","Number","abs","max","isFrozen","random","+","#",".","/",";","?","&","*","fillFromObject","missingMap","formatValidators","collectMultiple","handleError","collectError","returnError","checkRecursive","scanned","scannedFrozen","scannedFrozenSchemas","scannedFrozenValidationErrors","validatedSchemasKey","validationErrorsKey","trackUnknownProperties","knownPropertyPaths","unknownPropertyPaths","errorReporter","definedKeywords","createError","prefixErrors","prefixWith","UNKNOWN_PROPERTY","resolveRefs","CIRCULAR_REFERENCE","urls","searchSchemas","validateBasic","validateNumeric","validateString","validateArray","validateObject","validateCombinations","validateHypermedia","validateFormat","validateDefinedKeywords","format","FORMAT_CUSTOM","KEYWORD_CUSTOM","key","validateType","validateEnum","INVALID_TYPE","expected","enum","ENUM_MISMATCH","validateMultipleOf","validateMinMax","validateNaN","pow","multipleOf","divisibleBy","NUMBER_MULTIPLE_OF","minimum","NUMBER_MINIMUM","exclusiveMinimum","NUMBER_MINIMUM_EXCLUSIVE","maximum","NUMBER_MAXIMUM","exclusiveMaximum","NUMBER_MAXIMUM_EXCLUSIVE","isNaN","NUMBER_NOT_A_NUMBER","validateStringLength","validateStringPattern","minLength","STRING_LENGTH_SHORT","maxLength","STRING_LENGTH_LONG","pattern","STRING_PATTERN","validateArrayLength","validateArrayUniqueItems","validateArrayItems","minItems","ARRAY_LENGTH_SHORT","maxItems","ARRAY_LENGTH_LONG","uniqueItems","ARRAY_UNIQUE","match1","match2","additionalItems","ARRAY_ADDITIONAL_ITEMS","validateObjectMinMaxProperties","validateObjectRequiredProperties","validateObjectProperties","validateObjectDependencies","minProperties","OBJECT_PROPERTIES_MINIMUM","propertyCount","maxProperties","OBJECT_PROPERTIES_MAXIMUM","required","OBJECT_REQUIRED","patternProperties","additionalProperties","OBJECT_ADDITIONAL_PROPERTIES","dependencies","OBJECT_DEPENDENCY_KEY","validateAllOf","validateAnyOf","validateOneOf","validateNot","allOf","anyOf","ANY_OF_MISSING","oneOf","ONE_OF_MULTIPLE","index1","index2","ONE_OF_MISSING","not","NOT_PASSED","rel","tv4","uris","aliases","extends","TYPED_ARRAY_SUPPORT","RangeError","__proto__","isEncoding","write","isBuffer","copy","buffer","W","Q","alloc","isView","Y","K","M","C","O","N","from","readUInt16BE","V","z","H","$","fromByteArray","min","I","Z","fromCharCode","G","x","U","j","B","L","D","X","F","q","J","ee","trim","charCodeAt","toByteArray","SlowBuffer","INSPECT_MAX_BYTES","foo","subarray","kMaxLength","poolSize","_augment","species","allocUnsafe","allocUnsafeSlow","_isBuffer","compare","swap16","swap32","swap64","equals","inspect","includes","isFinite","toJSON","_arr","readUIntLE","readUIntBE","readUInt8","readUInt16LE","readUInt32LE","readUInt32BE","readIntLE","readIntBE","readInt8","readInt16LE","readInt16BE","readInt32LE","readInt32BE","readFloatLE","read","readFloatBE","readDoubleLE","readDoubleBE","writeUIntLE","writeUIntBE","writeUInt8","writeUInt16LE","writeUInt16BE","writeUInt32LE","writeUInt32BE","writeIntLE","writeIntBE","writeInt8","writeInt16LE","writeInt16BE","writeInt32LE","writeInt32BE","writeFloatLE","writeFloatBE","writeDoubleLE","writeDoubleBE","NaN","LN2","config","webfist_fallback","http://webfist.org/spec/rel","http://webfinger.net/rel/avatar","http://tools.ietf.org/id/draft-dejong-remotestorage","http://www.packetizer.com/rel/share","http://webfinger.net/rel/profile-page","me","vcard","blog","http://packetizer.com/rel/blog","http://schemas.google.com/g/2010#updates-from","https://camlistore.org/rel/server","avatar","updates","profile","webfist","camlistore","__fetchJRD","__isValidJSON","onreadystatechange","readyState","ontimeout","timeout","__isLocalhost","__processJRD","object","lookupLink","readyFired","featureModules","WireClient","Dropbox","GoogleDrive","Access","Discover","BaseClient","Env","Caching","IndexedDB","LocalStorage","InMemoryStorage","Sync","supported","init","cleanup","some","_wrapBusyDone","db","getsRunning","putsRunning","changesQueued","changesRunning","getNodesFromDb","maybeFlush","flushChangesQueued","commitSlownessWarning","setInterval","clearInterval","setNodesInDb","transaction","objectStore","onsuccess","oncomplete","onabort","clean","self","openCursor","continue","closeDB","indexedDB","onupgradeneeded","oldVersion","newVersion","createObjectStore","keyPath","objectStoreNames","contains","deleteDatabase","navigator","userAgent","builder","_loadModule","toUpperCase"],"mappings":";CACC,SAASA,EAAEC,GAAG,gBAAiBC,UAAS,gBAAiBC,QAAOA,OAAOD,QAAQD,IAAI,kBAAmBG,SAAQA,OAAOC,IAAID,OAAO,mBAAmBH,GAAG,gBAAiBC,SAAQA,QAAQI,cAAcL,IAAID,EAAEM,cAAcL,KAAKM,KAAK,WAAW,MAAO,UAASP,GAAG,QAASC,GAAEO,GAAG,GAAGC,EAAED,GAAG,MAAOC,GAAED,GAAGN,OAAQ,IAAIQ,GAAED,EAAED,IAAIG,EAAEH,EAAEI,GAAE,EAAGV,WAAY,OAAOF,GAAEQ,GAAGK,KAAKH,EAAER,QAAQQ,EAAEA,EAAER,QAAQD,GAAGS,EAAEE,GAAE,EAAGF,EAAER,QAAQ,GAAIO,KAAK,OAAOR,GAAEa,EAAEd,EAAEC,EAAEc,EAAEN,EAAER,EAAEe,EAAE,SAAShB,EAAES,EAAED,GAAGP,EAAES,EAAEV,EAAES,IAAIQ,OAAOC,eAAelB,EAAES,GAAGU,cAAa,EAAGC,YAAW,EAAGC,IAAIb,KAAKP,EAAEO,EAAE,SAASR,GAAG,GAAIS,GAAET,GAAGA,EAAEsB,WAAW,WAAW,MAAOtB,GAAEuB,SAAS,WAAW,MAAOvB,GAAG,OAAOC,GAAEe,EAAEP,EAAE,IAAIA,GAAGA,GAAGR,EAAES,EAAE,SAASV,EAAEC,GAAG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exports&&\"object\"==typeof module?module.exports=t():\"function\"==typeof define&&define.amd?define(\"RemoteStorage\",[],t):\"object\"==typeof exports?exports.RemoteStorage=t():e.RemoteStorage=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,\"a\",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p=\"\",t(t.s=17)}([function(e,t,r){\"use strict\";(function(t){function r(e,t){var o,i,s;if(\"object\"===(void 0===e?\"undefined\":n(e))&&!Array.isArray(e)&&null!==e)for(o in e)\"object\"===n(e[o])&&null!==e[o]&&(\"[object ArrayBuffer]\"===e[o].toString()?(t[o]=new ArrayBuffer(e[o].byteLength),i=new Int8Array(e[o]),s=new Int8Array(t[o]),s.set(i)):r(e[o],t[o]))}var n=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&\"function\"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?\"symbol\":typeof e},o={logError:function(e){\"string\"==typeof e?console.error(e):console.error(e.message,e.stack)},globalContext:\"undefined\"!=typeof window?window:t,getGlobalContext:function(){return\"undefined\"!=typeof window?window:t},extend:function(e){return Array.prototype.slice.call(arguments,1).forEach(function(t){for(var r in t)e[r]=t[r]}),e},asyncEach:function(e,t){return this.asyncMap(e,t).then(function(){return e})},asyncMap:function(e,t){function r(){++s===i&&o.resolve(a,u)}var o=Promise.defer(),i=e.length,s=0,a=[],u=[];return e.forEach(function(e,o){var i;try{i=t(e)}catch(e){r(),u[o]=e}\"object\"===(void 0===i?\"undefined\":n(i))&&\"function\"==typeof i.then?i.then(function(e){a[o]=e,r()},function(e){u[o]=e,r()}):(r(),a[o]=i)}),o.promise},containingFolder:function(e){if(\"\"===e)return\"/\";if(!e)throw\"Path not given!\";return e.replace(/\\/+/g,\"/\").replace(/[^\\/]+\\/?$/,\"\")},isFolder:function(e){return\"/\"===e.substr(-1)},isDocument:function(e){return!o.isFolder(e)},baseName:function(e){var t=e.split(\"/\");return o.isFolder(e)?t[t.length-2]+\"/\":t[t.length-1]},cleanPath:function(e){return e.replace(/\\/+/g,\"/\").split(\"/\").map(encodeURIComponent).join(\"/\").replace(/'/g,\"%27\")},bindAll:function(e){for(var t in this)\"function\"==typeof e[t]&&(e[t]=e[t].bind(e))},equal:function(e,t,r){var i;if(r=r||[],(void 0===e?\"undefined\":n(e))!==(void 0===t?\"undefined\":n(t)))return!1;if(\"number\"==typeof e||\"boolean\"==typeof e||\"string\"==typeof e)return e===t;if(\"function\"==typeof e)return e.toString()===t.toString();if(e instanceof ArrayBuffer&&t instanceof ArrayBuffer&&(e=new Uint8Array(e),t=new Uint8Array(t)),e instanceof Array){if(e.length!==t.length)return!1;for(var s=0,a=e.length;s=0)continue;u=r.slice(),u.push(t[i])}if(!o.equal(e[i],t[i],u))return!1}}return!0},deepClone:function(e){var t;return void 0===e?void 0:(t=JSON.parse(JSON.stringify(e)),r(e,t),t)},pathsFromRoot:function(e){for(var t=[e],r=e.replace(/\\/$/,\"\").split(\"/\");r.length>1;)r.pop(),t.push(r.join(\"/\")+\"/\");return t},localStorageAvailable:function(){var e=o.getGlobalContext();if(!(\"localStorage\"in e))return!1;try{return e.localStorage.setItem(\"rs-check\",1),e.localStorage.removeItem(\"rs-check\"),!0}catch(e){return!1}},shouldBeTreatedAsBinary:function(e,t){return t&&t.match(/charset=binary/)||/[\\x00-\\x1F]/.test(e)},readBinaryData:function(e,r){return new Promise(function(n){var i=void 0;if(o.globalContext.BlobBuilder=o.globalContext.BlobBuilder||o.globalContext.WebKitBlobBuilder,void 0!==o.globalContext.BlobBuilder){var s=new t.BlobBuilder;s.append(e),i=s.getBlob(r)}else i=new Blob([e],{type:r});var a=new FileReader;\"function\"==typeof a.addEventListener?a.addEventListener(\"loadend\",function(){n(a.result)}):a.onloadend=function(){n(a.result)},a.readAsArrayBuffer(i)})}};e.exports=o}).call(t,r(6))},function(e,t,r){\"use strict\";function n(){o.logging&&console.log.apply(console,arguments)}var o=r(3);e.exports=n},function(e,t,r){\"use strict\";var n=r(1),o={addEventListener:function(e,t){if(\"string\"!=typeof e)throw new Error(\"Argument eventName should be a string\");if(\"function\"!=typeof t)throw new Error(\"Argument handler should be a function\");n(\"[Eventhandling] Adding event listener\",e),this._validateEvent(e),this._handlers[e].push(t)},removeEventListener:function(e,t){this._validateEvent(e);for(var r=this._handlers[e].length,n=0;n0&&(e.state=n)}else e[decodeURIComponent(r[0])]=decodeURIComponent(r[1]);return e},{})}var o=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&\"function\"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?\"symbol\":typeof e},i=r(1),s=r(0),a=function e(t,r,n,o,a){if(i(\"[Authorize] authURL = \",r,\"scope = \",n,\"redirectUri = \",o,\"clientId = \",a),!s.localStorageAvailable()&&\"remotestorage\"===t.backend){o+=o.indexOf(\"#\")>0?\"&\":\"#\";var u={userAddress:t.remote.userAddress,href:t.remote.href,storageApi:t.remote.storageApi,properties:t.remote.properties};o+=\"rsDiscovery=\"+btoa(JSON.stringify(u))}var c=r,h=o.indexOf(\"#\");if(c+=r.indexOf(\"?\")>0?\"&\":\"?\",c+=\"redirect_uri=\"+encodeURIComponent(o.replace(/#.*$/,\"\")),c+=\"&scope=\"+encodeURIComponent(n),c+=\"&client_id=\"+encodeURIComponent(a),-1!==h&&h+1!==o.length&&(c+=\"&state=\"+encodeURIComponent(o.substring(h+1))),c+=\"&response_type=token\",s.globalContext.cordova)return e.openWindow(c,o,\"location=yes,clearsessioncache=yes,clearcache=yes\").then(function(e){t.remote.configure({token:e.access_token})});e.setLocation(c)};a.IMPLIED_FAKE_TOKEN=!1,a.Unauthorized=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.name=\"Unauthorized\",this.message=void 0===e?\"App authorization expired or revoked.\":e,void 0!==t.code&&(this.code=t.code),this.stack=(new Error).stack},a.Unauthorized.prototype=Object.create(Error.prototype),a.Unauthorized.prototype.constructor=a.Unauthorized,a.getLocation=function(){return document.location},a.setLocation=function(e){if(\"string\"==typeof e)document.location.href=e;else{if(\"object\"!==(void 0===e?\"undefined\":o(e)))throw\"Invalid location \"+e;document.location=e}},a.openWindow=function(e,t,r){return new Promise(function(o,i){var s=open(e,\"_blank\",r);if(!s||s.closed)return i(\"Authorization popup was blocked\");var a=function(){return i(\"Authorization was canceled\")},u=function(e){if(0===e.url.indexOf(t)){s.removeEventListener(\"exit\",a),s.close();var r=n(e.url);return r?o(r):i(\"Authorization error\")}};s.addEventListener(\"loadstart\",u),s.addEventListener(\"exit\",a)})},a._rs_supported=function(){return\"undefined\"!=typeof document};var u;a._rs_init=function(e){u=function(){var n=!1;if(r){if(r.error)throw\"access_denied\"===r.error?new a.Unauthorized(\"Authorization failed: access denied\",{code:\"access_denied\"}):new a.Unauthorized(\"Authorization failed: \"+r.error);r.rsDiscovery&&e.remote.configure(r.rsDiscovery),r.access_token&&(e.remote.configure({token:r.access_token}),n=!0),r.remotestorage&&(e.connect(r.remotestorage),n=!0),r.state&&(t=a.getLocation(),a.setLocation(t.href.split(\"#\")[0]+\"#\"+r.state))}n||e.remote.stopWaitingForToken()};var t,r=n();r&&(t=a.getLocation(),t.hash=\"\"),e.on(\"features-loaded\",u)},a._rs_cleanup=function(e){e.removeEventListener(\"features-loaded\",u)},e.exports=a},function(e,t,r){\"use strict\";var n=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&\"function\"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?\"symbol\":typeof e},o=r(2),i=r(0),s=r(3),a=r(18),u=r(19),c=u.SchemaNotFound,h=function(e,t){if(\"/\"!==t[t.length-1])throw\"Not a folder: \"+t;\"/\"===t&&(this.makePath=function(e){return(\"/\"===e[0]?\"\":\"/\")+e}),this.storage=e,this.base=t;var r=this.base.split(\"/\");r.length>2?this.moduleName=r[1]:this.moduleName=\"root\",o(this,\"change\"),this.on=this.on.bind(this),e.onChange(this.base,this._fireChange.bind(this))};h.Types=u,h.prototype={scope:function(e){return new h(this.storage,this.makePath(e))},getListing:function(e,t){if(\"string\"!=typeof e)e=\"\";else if(e.length>0&&\"/\"!==e[e.length-1])return Promise.reject(\"Not a folder: \"+e);return this.storage.get(this.makePath(e),t).then(function(e){return 404===e.statusCode?{}:e.body})},getAll:function(e,t){if(\"string\"!=typeof e)e=\"\";else if(e.length>0&&\"/\"!==e[e.length-1])return Promise.reject(\"Not a folder: \"+e);return this.storage.get(this.makePath(e),t).then(function(r){if(404===r.statusCode)return{};if(\"object\"===n(r.body)){var o=Object.keys(r.body);if(0===o.length)return{};var i=o.map(function(o){return this.storage.get(this.makePath(e+o),t).then(function(e){if(\"string\"==typeof e.body)try{e.body=JSON.parse(e.body)}catch(e){}\"object\"===n(e.body)&&(r.body[o]=e.body)})}.bind(this));return Promise.all(i).then(function(){return r.body})}}.bind(this))},getFile:function(e,t){return\"string\"!=typeof e?Promise.reject(\"Argument 'path' of baseClient.getFile must be a string\"):this.storage.get(this.makePath(e),t).then(function(e){return{data:e.body,contentType:e.contentType,revision:e.revision}})},storeFile:function(e,t,r){return\"string\"!=typeof e?Promise.reject(\"Argument 'mimeType' of baseClient.storeFile must be a string\"):\"string\"!=typeof t?Promise.reject(\"Argument 'path' of baseClient.storeFile must be a string\"):\"string\"!=typeof r&&\"object\"!==(void 0===r?\"undefined\":n(r))?Promise.reject(\"Argument 'body' of baseClient.storeFile must be a string, ArrayBuffer, or ArrayBufferView\"):(this.storage.access.checkPathPermission(this.makePath(t),\"rw\")||console.warn(\"WARNING: Editing a document to which only read access ('r') was claimed\"),this.storage.put(this.makePath(t),r,e).then(function(e){return 200===e.statusCode||201===e.statusCode?e.revision:Promise.reject(\"Request (PUT \"+this.makePath(t)+\") failed with status: \"+e.statusCode)}.bind(this)))},getObject:function(e,t){return\"string\"!=typeof e?Promise.reject(\"Argument 'path' of baseClient.getObject must be a string\"):this.storage.get(this.makePath(e),t).then(function(t){if(\"object\"===n(t.body))return t.body;if(\"string\"==typeof t.body)try{return JSON.parse(t.body)}catch(t){throw\"Not valid JSON: \"+this.makePath(e)}else if(void 0!==t.body&&200===t.statusCode)return Promise.reject(\"Not an object: \"+this.makePath(e))}.bind(this))},storeObject:function(e,t,r){if(\"string\"!=typeof e)return Promise.reject(\"Argument 'typeAlias' of baseClient.storeObject must be a string\");if(\"string\"!=typeof t)return Promise.reject(\"Argument 'path' of baseClient.storeObject must be a string\");if(\"object\"!==(void 0===r?\"undefined\":n(r)))return Promise.reject(\"Argument 'object' of baseClient.storeObject must be an object\");this._attachType(r,e);try{var o=this.validate(r);if(!o.valid)return Promise.reject(o)}catch(e){return Promise.reject(e)}return this.storage.put(this.makePath(t),JSON.stringify(r),\"application/json; charset=UTF-8\").then(function(e){return 200===e.statusCode||201===e.statusCode?e.revision:Promise.reject(\"Request (PUT \"+this.makePath(t)+\") failed with status: \"+e.statusCode)}.bind(this))},remove:function(e){return\"string\"!=typeof e?Promise.reject(\"Argument 'path' of baseClient.remove must be a string\"):(this.storage.access.checkPathPermission(this.makePath(e),\"rw\")||console.warn(\"WARNING: Removing a document to which only read access ('r') was claimed\"),this.storage.delete(this.makePath(e)))},getItemURL:function(e){if(\"string\"!=typeof e)throw\"Argument 'path' of baseClient.getItemURL must be a string\";return this.storage.connected?(e=this._cleanPath(this.makePath(e)),this.storage.remote.href+e):void 0},cache:function(e,t){if(\"string\"!=typeof e)throw\"Argument 'path' of baseClient.cache must be a string\";if(void 0===t)t=\"ALL\";else if(\"string\"!=typeof t)throw\"Argument 'strategy' of baseClient.cache must be a string or undefined\";if(\"FLUSH\"!==t&&\"SEEN\"!==t&&\"ALL\"!==t)throw'Argument \\'strategy\\' of baseclient.cache must be one of [\"FLUSH\", \"SEEN\", \"ALL\"]';return this.storage.caching.set(this.makePath(e),t),this},flush:function(e){return this.storage.local.flush(e)},declareType:function(e,t,r){r||(r=t,t=this._defaultTypeURI(e)),h.Types.declare(this.moduleName,e,t,r)},validate:function(e){var t=h.Types.getSchema(e[\"@context\"]);if(t)return a.validateResult(e,t);throw new c(e[\"@context\"])},schemas:{configurable:!0,get:function(){return h.Types.inScope(this.moduleName)}},_defaultTypeURI:function(e){return\"http://remotestorage.io/spec/modules/\"+encodeURIComponent(this.moduleName)+\"/\"+encodeURIComponent(e)},_attachType:function(e,t){e[\"@context\"]=h.Types.resolveAlias(this.moduleName+\"/\"+t)||this._defaultTypeURI(t)},makePath:function(e){return this.base+(e||\"\")},_fireChange:function(e){s.changeEvents[e.origin]&&([\"new\",\"old\",\"lastCommon\"].forEach(function(t){if((!e[t+\"ContentType\"]||/^application\\/(.*)json(.*)/.exec(e[t+\"ContentType\"]))&&\"string\"==typeof e[t+\"Value\"])try{e[t+\"Value\"]=JSON.parse(e[t+\"Value\"])}catch(e){}}),this._emit(\"change\",e))},_cleanPath:i.cleanPath},h._rs_init=function(){},e.exports=h},function(e,t){var r;r=function(){return this}();try{r=r||Function(\"return this\")()||(0,eval)(\"this\")}catch(e){\"object\"==typeof window&&(r=window)}e.exports=r},function(e,t,r){\"use strict\";(function(t,n){function o(e){return\"string\"!=typeof e?e:\"*\"===e?\"*\":'\"'+e+'\"'}function i(e){return\"string\"!=typeof e?e:e.replace(/^[\"']|[\"']$/g,\"\")}function s(e,r){return new Promise(function(o){if(\"undefined\"==typeof Blob){var i=new t(new Uint8Array(e));o(i.toString(r))}else{var s;if(m.globalContext.BlobBuilder=m.globalContext.BlobBuilder||m.globalContext.WebKitBlobBuilder,void 0!==m.globalContext.BlobBuilder){var a=new n.BlobBuilder;a.append(e),s=a.getBlob()}else s=new Blob([e]);var u=new FileReader;\"function\"==typeof u.addEventListener?u.addEventListener(\"loadend\",function(e){o(e.target.result)}):u.onloadend=function(e){o(e.target.result)},u.readAsText(s,r)}})}function a(e){var t,r=\"UTF-8\";return e&&(t=e.match(/charset=(.+)$/))&&(r=t[1]),r}function u(e){return\"http://remotestorage.io/spec/folder-description\"===e[\"@context\"]&&\"object\"===d(e.items)}function c(e){return[201,204,304].indexOf(e)>=0}function h(e){return[401,403,404,412].indexOf(e)>=0}var l,f,d=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&\"function\"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?\"symbol\":typeof e},p=r(1),m=r(0),g=r(2),y=r(4),v=r(3),b=\"remotestorage:wireclient\",_={\"draft-dejong-remotestorage-00\":2,\"draft-dejong-remotestorage-01\":3,\"draft-dejong-remotestorage-02\":4,\"https://www.w3.org/community/rww/wiki/read-write-web-00#simple\":1};if(\"function\"==typeof ArrayBufferView)f=function(e){return e&&e instanceof ArrayBufferView};else{var w=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];f=function(e){for(var t=0;t<8;t++)if(e instanceof w[t])return!0;return!1}}var P=m.isFolder,E=m.cleanPath,S=m.shouldBeTreatedAsBinary,T=function(e){if(this.rs=e,this.connected=!1,g(this,\"connected\",\"not-connected\"),l){var t;try{t=JSON.parse(localStorage[b])}catch(e){}t&&setTimeout(function(){this.configure(t)}.bind(this),0)}this._revisionCache={},this.connected&&setTimeout(this._emit.bind(this),0,\"connected\")};T.prototype={_request:function(e,t,r,n,o,u,l){if((\"PUT\"===e||\"DELETE\"===e)&&\"/\"===t[t.length-1])return Promise.reject(\"Don't \"+e+\" on directories!\");var f,d=this;return r!==y.IMPLIED_FAKE_TOKEN&&(n.Authorization=\"Bearer \"+r),this.rs._emit(\"wire-busy\",{method:e,isFolder:P(t)}),T.request(e,t,{body:o,headers:n,responseType:\"arraybuffer\"}).then(function(r){if(d.online||(d.online=!0,d.rs._emit(\"network-online\")),d.rs._emit(\"wire-done\",{method:e,isFolder:P(t),success:!0}),h(r.status))return p(\"[WireClient] Error response status\",r.status),f=u?i(r.getResponseHeader(\"ETag\")):void 0,401===r.status&&d.rs._emit(\"error\",new y.Unauthorized),Promise.resolve({statusCode:r.status,revision:f});if(c(r.status)||200===r.status&&\"GET\"!==e)return f=i(r.getResponseHeader(\"ETag\")),p(\"[WireClient] Successful request\",f),Promise.resolve({statusCode:r.status,revision:f});var n=r.getResponseHeader(\"Content-Type\");f=u?i(r.getResponseHeader(\"ETag\")):200===r.status?l:void 0;var o=a(n);return S(r.response,n)?(p(\"[WireClient] Successful request with unknown or binary mime-type\",f),Promise.resolve({statusCode:r.status,body:r.response,contentType:n,revision:f})):s(r.response,o).then(function(e){return p(\"[WireClient] Successful request\",f),Promise.resolve({statusCode:r.status,body:e,contentType:n,revision:f})})},function(r){return d.online&&(d.online=!1,d.rs._emit(\"network-offline\")),d.rs._emit(\"wire-done\",{method:e,isFolder:P(t),success:!1}),Promise.reject(r)})},configure:function(e){if(\"object\"!==(void 0===e?\"undefined\":d(e)))throw new Error(\"WireClient configure settings parameter should be an object\");void 0!==e.userAddress&&(this.userAddress=e.userAddress),void 0!==e.href&&(this.href=e.href),void 0!==e.storageApi&&(this.storageApi=e.storageApi),void 0!==e.token&&(this.token=e.token),void 0!==e.properties&&(this.properties=e.properties),void 0!==this.storageApi&&(this._storageApi=_[this.storageApi]||5,this.supportsRevs=this._storageApi>=2),this.href&&this.token?(this.connected=!0,this.online=!0,this._emit(\"connected\")):this.connected=!1,l&&(localStorage[b]=JSON.stringify({userAddress:this.userAddress,href:this.href,storageApi:this.storageApi,token:this.token,properties:this.properties}))},stopWaitingForToken:function(){this.connected||this._emit(\"not-connected\")},get:function(e,t){var r=this;if(!this.connected)return Promise.reject(\"not connected (path: \"+e+\")\");t||(t={});var n={};return this.supportsRevs&&t.ifNoneMatch&&(n[\"If-None-Match\"]=o(t.ifNoneMatch)),this._request(\"GET\",this.href+E(e),this.token,n,void 0,this.supportsRevs,this._revisionCache[e]).then(function(t){if(!P(e))return Promise.resolve(t);var n={};if(void 0!==t.body)try{t.body=JSON.parse(t.body)}catch(t){return Promise.reject(\"Folder description at \"+r.href+E(e)+\" is not JSON\")}if(200===t.statusCode&&\"object\"===d(t.body)){if(0===Object.keys(t.body).length)t.statusCode=404;else if(u(t.body)){for(var o in t.body.items)r._revisionCache[e+o]=t.body.items[o].ETag;n=t.body.items}else Object.keys(t.body).forEach(function(o){r._revisionCache[e+o]=t.body[o],n[o]={ETag:t.body[o]}});return t.body=n,Promise.resolve(t)}return Promise.resolve(t)})},put:function(e,t,r,n){if(!this.connected)return Promise.reject(\"not connected (path: \"+e+\")\");n||(n={}),!r.match(/charset=/)&&(t instanceof ArrayBuffer||f(t))&&(r+=\"; charset=binary\");var i={\"Content-Type\":r};return this.supportsRevs&&(n.ifMatch&&(i[\"If-Match\"]=o(n.ifMatch)),n.ifNoneMatch&&(i[\"If-None-Match\"]=o(n.ifNoneMatch))),this._request(\"PUT\",this.href+E(e),this.token,i,t,this.supportsRevs)},delete:function(e,t){if(!this.connected)throw new Error(\"not connected (path: \"+e+\")\");t||(t={});var r={};return this.supportsRevs&&t.ifMatch&&(r[\"If-Match\"]=o(t.ifMatch)),this._request(\"DELETE\",this.href+E(e),this.token,r,void 0,this.supportsRevs)}},T.isArrayBufferView=f,T.request=function(e,t,r){return new Promise(function(n,o){p(\"[WireClient]\",e,t);var i=!1,s=setTimeout(function(){i=!0,o(\"timeout\")},v.requestTimeout),a=new XMLHttpRequest;if(a.open(e,t,!0),r.responseType&&(a.responseType=r.responseType),r.headers)for(var u in r.headers)a.setRequestHeader(u,r.headers[u]);a.onload=function(){i||(clearTimeout(s),n(a))},a.onerror=function(e){i||(clearTimeout(s),o(e))};var c=r.body;\"object\"===(void 0===c?\"undefined\":d(c))&&!f(c)&&c instanceof ArrayBuffer&&(c=new Uint8Array(c)),a.send(c)})},Object.defineProperty(T.prototype,\"storageType\",{get:function(){if(this.storageApi){var e=this.storageApi.match(/draft-dejong-(remotestorage-\\d\\d)/);return e?e[1]:\"2012.04\"}}}),T._rs_init=function(e){l=m.localStorageAvailable(),e.remote=new T(e),this.online=!0},T._rs_supported=function(){return!!XMLHttpRequest},T._rs_cleanup=function(){l&&delete localStorage[b]},e.exports=T}).call(t,r(20).Buffer,r(6))},function(e,t,r){\"use strict\";function n(e,t,r){return{action:e,path:t,promise:r}}function o(e,t){return e.common.revision!==t&&(!e.remote||e.remote.revision!==t)}function i(e){return e.remote&&e.remote.revision&&!e.remote.itemsMap&&!e.remote.body}function s(e){return e.common&&e.common.revision}function a(e){return(!e.remote||!e.remote.revision||e.remote.revision===e.common.revision)&&(void 0===e.common.body&&!1===e.remote.body||e.remote.body===e.common.body&&e.remote.contentType===e.common.contentType)}function u(e){return e.remote&&!1===e.remote.body&&e.local&&!1===e.local.body&&delete e.local,e}function c(){function e(e){var r,n;r=t.getCurrentSyncInterval(),g.isBackground=!e,n=t.getCurrentSyncInterval(),t._emit(\"sync-interval-change\",{oldValue:r,newValue:n})}var t=this;f.on(\"background\",function(){e(!1)}),f.on(\"foreground\",function(){e(!0)})}var h=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&\"function\"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?\"symbol\":typeof e},l=r(0),f=r(12),d=r(2),p=r(1),m=r(4),g=r(3),y=l.isFolder,v=l.isDocument,b=l.equal,_=l.deepClone,w=l.pathsFromRoot,P=function(e,t,r,n,o){this.remoteStorage=e,this.local=t,this.local.onDiff(function(e){this.addTask(e),this.doTasks()}.bind(this)),this.remote=r,this.access=n,this.caching=o,this._tasks={},this._running={},this._timeStarted={},d(this,\"done\",\"req-done\"),this.caching.onActivate(function(e){this.addTask(e),this.doTasks()}.bind(this))};P.prototype={now:function(){return(new Date).getTime()},queueGetRequest:function(e){var t=this;return new Promise(function(r,n){t.remote.connected?t.remote.online?(t.addTask(e,function(){this.local.get(e).then(function(e){return r(e)})}.bind(t)),t.doTasks()):n(\"cannot fulfill maxAge requirement - remote is not online\"):n(\"cannot fulfill maxAge requirement - remote is not connected\")})},corruptServerItemsMap:function(e,t){if(\"object\"!==(void 0===e?\"undefined\":h(e))||Array.isArray(e))return!0;for(var r in e){var n=e[r];if(\"object\"!==(void 0===n?\"undefined\":h(n)))return!0;if(\"string\"!=typeof n.ETag)return!0;if(y(r)){if(-1!==r.substring(0,r.length-1).indexOf(\"/\"))return!0}else{if(-1!==r.indexOf(\"/\"))return!0;if(t){if(\"string\"!=typeof n[\"Content-Type\"])return!0;if(\"number\"!=typeof n[\"Content-Length\"])return!0}}}return!1},corruptItemsMap:function(e){if(\"object\"!==(void 0===e?\"undefined\":h(e))||Array.isArray(e))return!0;for(var t in e)if(\"boolean\"!=typeof e[t])return!0;return!1},corruptRevision:function(e){return\"object\"!==(void 0===e?\"undefined\":h(e))||Array.isArray(e)||e.revision&&\"string\"!=typeof e.revision||e.body&&\"string\"!=typeof e.body&&\"object\"!==h(e.body)||e.contentType&&\"string\"!=typeof e.contentType||e.contentLength&&\"number\"!=typeof e.contentLength||e.timestamp&&\"number\"!=typeof e.timestamp||e.itemsMap&&this.corruptItemsMap(e.itemsMap)},isCorrupt:function(e){return\"object\"!==(void 0===e?\"undefined\":h(e))||Array.isArray(e)||\"string\"!=typeof e.path||this.corruptRevision(e.common)||e.local&&this.corruptRevision(e.local)||e.remote&&this.corruptRevision(e.remote)||e.push&&this.corruptRevision(e.push)},hasTasks:function(){return Object.getOwnPropertyNames(this._tasks).length>0},collectDiffTasks:function(){var e=0;return this.local.forAllNodes(function(t){e>100||(this.isCorrupt(t)?(p(\"[Sync] WARNING: corrupt node in local cache\",t),\"object\"===(void 0===t?\"undefined\":h(t))&&t.path&&(this.addTask(t.path),e++)):this.needsFetch(t)&&this.access.checkPathPermission(t.path,\"r\")?(this.addTask(t.path),e++):v(t.path)&&this.needsPush(t)&&this.access.checkPathPermission(t.path,\"rw\")&&(this.addTask(t.path),e++))}.bind(this)).then(function(){return e},function(e){throw e})},inConflict:function(e){return e.local&&e.remote&&(void 0!==e.remote.body||e.remote.itemsMap)},needsRefresh:function(e){return!!e.common&&(!e.common.timestamp||this.now()-e.common.timestamp>g.syncInterval)},needsFetch:function(e){return!!this.inConflict(e)||(!(!e.common||void 0!==e.common.itemsMap||void 0!==e.common.body)||!(!e.remote||void 0!==e.remote.itemsMap||void 0!==e.remote.body))},needsPush:function(e){return!this.inConflict(e)&&(!(!e.local||e.push)||void 0)},needsRemotePut:function(e){return e.local&&e.local.body},needsRemoteDelete:function(e){return e.local&&!1===e.local.body},getParentPath:function(e){var t=e.match(/^(.*\\/)([^\\/]+\\/?)$/);if(t)return t[1];throw new Error('Not a valid path: \"'+e+'\"')},deleteChildPathsFromTasks:function(){for(var e in this._tasks)for(var t=w(e),r=1;r=r))return!0;return t>=r},collectTasks:function(e){return this.hasTasks()||this.stopped?Promise.resolve():this.collectDiffTasks().then(function(t){return t||!1===e?Promise.resolve():this.collectRefreshTasks()}.bind(this),function(e){throw e})},addTask:function(e,t){this._tasks[e]||(this._tasks[e]=[]),\"function\"==typeof t&&this._tasks[e].push(t)},sync:function(){return this.done=!1,this.doTasks()?Promise.resolve():this.collectTasks().then(function(){try{this.doTasks()}catch(e){p(\"[Sync] doTasks error\",e)}}.bind(this),function(e){throw p(\"[Sync] Sync error\",e),new Error(\"Local cache unavailable\")})}};var E,S;P._rs_init=function(e){E=function(){p(\"[Sync] syncCycleCb calling syncCycle\"),f.isBrowser()&&c.bind(e)(),e.sync||(e.sync=new P(e,e.local,e.remote,e.access,e.caching),e.syncStopped&&(p(\"[Sync] Instantiating sync stopped\"),e.sync.stopped=!0,delete e.syncStopped)),p(\"[Sync] syncCycleCb calling syncCycle\"),e.syncCycle()},S=function(){e.removeEventListener(\"connected\",S),e.startSync()},e.on(\"ready\",E),e.on(\"connected\",S)},P._rs_cleanup=function(e){e.stopSync(),e.removeEventListener(\"ready\",E),e.removeEventListener(\"connected\",S),e.sync=void 0,delete e.sync},P.SyncError=function(e){this.name=\"SyncError\";var t=\"Sync failed: \";\"object\"===(void 0===e?\"undefined\":h(e))&&\"message\"in e?(t+=e.message,this.stack=e.stack,this.originalError=e):t+=e,this.message=t},P.SyncError.prototype=Object.create(Error.prototype),P.SyncError.prototype.constructor=P.SyncError,e.exports=P},function(e,t,r){\"use strict\";function n(e){if(\"object\"===(void 0===e?\"undefined\":a(e))&&\"string\"==typeof e.path)if(l(e.path)){if(e.local&&e.local.itemsMap)return e.local;if(e.common&&e.common.itemsMap)return e.common}else{if(e.local&&e.local.body&&e.local.contentType)return e.local;if(e.common&&e.common.body&&e.common.contentType)return e.common;if(e.body&&e.contentType)return{body:e.body,contentType:e.contentType}}}function o(e,t){var r;for(r in e){if(e[r]&&e[r].remote)return!0;var o=n(e[r]);if(o&&o.timestamp&&(new Date).getTime()-o.timestamp<=t)return!1;if(!o)return!0}return!0}function i(e){var t={path:e,common:{}};return l(e)&&(t.common.itemsMap={}),t}function s(e,t){return e.common||(e.common={itemsMap:{}}),e.common.itemsMap||(e.common.itemsMap={}),e.local||(e.local=d(e.common)),e.local.itemsMap||(e.local.itemsMap=e.common.itemsMap),e.local.itemsMap[t]=!0,e}var a=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&\"function\"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?\"symbol\":typeof e},u=r(0),c=r(3),h=r(1),l=u.isFolder,f=u.isDocument,d=u.deepClone,p=u.pathsFromRoot,m={get:function(e,t,r){var i=this;return\"number\"==typeof t?i.getNodes(p(e)).then(function(i){var s=n(i[e]);return o(i,t)?r(e):s?{statusCode:200,body:s.body||s.itemsMap,contentType:s.contentType}:{statusCode:404}}):i.getNodes([e]).then(function(t){var r=n(t[e]);if(r){if(l(e))for(var o in r.itemsMap)r.itemsMap.hasOwnProperty(o)&&!1===r.itemsMap[o]&&delete r.itemsMap[o];return{statusCode:200,body:r.body||r.itemsMap,contentType:r.contentType}}return{statusCode:404}})},put:function(e,t,r){function o(e,o){try{for(var a=0,u=e.length;a0)break}else console.error(\"Cannot delete non-existing node \"+i)}return t})},flush:function(e){var t=this;return t._getAllDescendentPaths(e).then(function(e){return t.getNodes(e)}).then(function(e){for(var r in e){var n=e[r];n&&n.common&&n.local&&t._emitChange({path:n.path,origin:\"local\",oldValue:!1===n.local.body?void 0:n.local.body,newValue:!1===n.common.body?void 0:n.common.body}),e[r]=void 0}return t.setNodes(e)})},_emitChange:function(e){c.changeEvents[e.origin]&&this._emit(\"change\",e)},fireInitial:function(){if(c.changeEvents.local){var e=this;e.forAllNodes(function(t){var r;f(t.path)&&(r=n(t))&&e._emitChange({path:t.path,origin:\"local\",oldValue:void 0,oldContentType:void 0,newValue:r.body,newContentType:r.contentType})}).then(function(){e._emit(\"local-events-done\")})}},onDiff:function(e){this.diffHandler=e},migrate:function(e){return\"object\"!==(void 0===e?\"undefined\":a(e))||e.common||(e.common={},\"string\"==typeof e.path?\"/\"===e.path.substr(-1)&&\"object\"===a(e.body)&&(e.common.itemsMap=e.body):(e.local||(e.local={}),e.local.body=e.body,e.local.contentType=e.contentType)),e},_updateNodesRunning:!1,_updateNodesQueued:[],_updateNodes:function(e,t){return new Promise(function(r,n){this._doUpdateNodes(e,t,{resolve:r,reject:n})}.bind(this))},_doUpdateNodes:function(e,t,r){var n=this;if(n._updateNodesRunning)return void n._updateNodesQueued.push({paths:e,cb:t,promise:r});n._updateNodesRunning=!0,n.getNodes(e).then(function(o){var i,s=d(o),a=[],c=u.equal;o=t(e,o);for(var h in o)i=o[h],c(i,s[h])?delete o[h]:f(h)&&(c(i.local.body,i.local.previousBody)&&i.local.contentType===i.local.previousContentType||a.push({path:h,origin:\"window\",oldValue:i.local.previousBody,newValue:!1===i.local.body?void 0:i.local.body,oldContentType:i.local.previousContentType,newContentType:i.local.contentType}),delete i.local.previousBody,delete i.local.previousContentType);n.setNodes(o).then(function(){n._emitChangeEvents(a),r.resolve({statusCode:200})})}).then(function(){return Promise.resolve()},function(e){r.reject(e)}).then(function(){n._updateNodesRunning=!1;var e=n._updateNodesQueued.shift();e&&n._doUpdateNodes(e.paths,e.cb,e.promise)})},_emitChangeEvents:function(e){for(var t=0,r=e.length;t1e3&&e<36e5}var i,s=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&\"function\"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?\"symbol\":typeof e},a=r(0),u=r(11),c=r(13),h=r(14),l=r(5),f=r(3),d=r(4),p=r(8),m=r(1),g=r(26),y=a.getGlobalContext(),v=r(2),b=function(e){if(\"object\"===(void 0===e?\"undefined\":s(e))&&a.extend(f,e),v(this,\"ready\",\"authing\",\"connecting\",\"connected\",\"disconnected\",\"not-connected\",\"conflict\",\"error\",\"features-loaded\",\"sync-interval-change\",\"sync-req-done\",\"sync-done\",\"wire-busy\",\"wire-done\",\"network-offline\",\"network-online\"),this._pending=[],this._setGPD({get:this._pendingGPD(\"get\"),put:this._pendingGPD(\"put\"),delete:this._pendingGPD(\"delete\")}),this._cleanups=[],this._pathHandlers={change:{}},this.apiKeys={},i=a.localStorageAvailable()){try{this.apiKeys=JSON.parse(localStorage.getItem(\"remotestorage:api-keys\"))||{}}catch(e){}this.setBackend(localStorage.getItem(\"remotestorage:backend\")||\"remotestorage\")}var t=this.on;this.on=function(e,r){if(this._allLoaded)switch(e){case\"features-loaded\":setTimeout(r,0);break;case\"ready\":this.remote&&setTimeout(r,0);break;case\"connected\":this.remote&&this.remote.connected&&setTimeout(r,0);break;case\"not-connected\":this.remote&&!this.remote.connected&&setTimeout(r,0)}return t.call(this,e,r)},this._init(),this.fireInitial=function(){this.local&&setTimeout(this.local.fireInitial.bind(this.local),0)}.bind(this),this.on(\"ready\",this.fireInitial.bind(this)),this.loadModules()};b.Authorize=d,b.SyncError=p.SyncError,b.Unauthorized=d.Unauthorized,b.DiscoveryError=h.DiscoveryError,b.prototype={loadModules:function(){f.modules.forEach(this.addModule.bind(this))},authorize:function(e,t){this.access.setStorageType(this.remote.storageType);var r=this.access.scopeParameter,n=y.cordova?t:String(d.getLocation()),o=n.match(/^(https?:\\/\\/[^\\/]+)/)[0];d(this,e,r,n,o)},impliedauth:function(e,t){e=this.remote.storageApi,t=String(document.location),m(\"ImpliedAuth proceeding due to absent authURL; storageApi = \"+e+\" redirectUri = \"+t),this.remote.configure({token:d.IMPLIED_FAKE_TOKEN}),document.location=t},connect:function(e,t){var r=this;if(this.setBackend(\"remotestorage\"),e.indexOf(\"@\")<0)return void this._emit(\"error\",new b.DiscoveryError(\"User address doesn't contain an @.\"));if(y.cordova){if(\"string\"!=typeof f.cordovaRedirectUri)return void this._emit(\"error\",new b.DiscoveryError(\"Please supply a custom HTTPS redirect URI for your Cordova app\"));if(!y.cordova.InAppBrowser)return void this._emit(\"error\",new b.DiscoveryError(\"Please include the InAppBrowser Cordova plugin to enable OAuth\"))}this.remote.configure({userAddress:e}),this._emit(\"connecting\");var n=setTimeout(function(){this._emit(\"error\",new b.DiscoveryError(\"No storage information found for this user address.\"))}.bind(this),f.discoveryTimeout);h(e).then(function(o){if(clearTimeout(n),r._emit(\"authing\"),o.userAddress=e,r.remote.configure(o),!r.remote.connected)if(o.authURL)if(void 0===t)r.authorize(o.authURL,f.cordovaRedirectUri);else{if(\"string\"!=typeof t)throw new Error(\"Supplied bearer token must be a string\");m(\"Skipping authorization sequence and connecting with known token\"),r.remote.configure({token:t})}else r.impliedauth()},function(){clearTimeout(n),r._emit(\"error\",new b.DiscoveryError(\"No storage information found for this user address.\"))})},reconnect:function(){this.remote.configure({token:null}),\"remotestorage\"===this.backend?this.connect(this.remote.userAddress):this.remote.connect()},disconnect:function(){this.remote&&this.remote.configure({userAddress:null,href:null,storageApi:null,token:null,properties:null}),this._setGPD({get:this._pendingGPD(\"get\"),put:this._pendingGPD(\"put\"),delete:this._pendingGPD(\"delete\")});var e=this._cleanups.length,t=0,r=function(){++t>=e&&(this._init(),m(\"Done cleaning up, emitting disconnected and disconnect events\"),this._emit(\"disconnected\"))}.bind(this);e>0?this._cleanups.forEach(function(e){var t=e(this);\"object\"===(void 0===t?\"undefined\":s(t))&&\"function\"==typeof t.then?t.then(r):r()}.bind(this)):r()},setBackend:function(e){this.backend=e,i&&(e?localStorage.setItem(\"remotestorage:backend\",e):localStorage.removeItem(\"remotestorage:backend\"))},onChange:function(e,t){this._pathHandlers.change[e]||(this._pathHandlers.change[e]=[]),this._pathHandlers.change[e].push(t)},enableLog:function(){f.logging=!0},disableLog:function(){f.logging=!1},log:function(){m.apply(b,arguments)},setApiKeys:function(e){var t=this,r=[\"googledrive\",\"dropbox\"];if(\"object\"!==(void 0===e?\"undefined\":s(e))||!Object.keys(e).every(function(e){return-1!==r.indexOf(e)}))return console.error(\"setApiKeys() was called with invalid arguments\"),!1;Object.keys(e).forEach(function(r){var n=e[r];if(!n)return void delete t.apiKeys[r];switch(r){case\"dropbox\":t.apiKeys.dropbox={appKey:n},void 0!==t.dropbox&&t.dropbox.clientId===n||u._rs_init(t);break;case\"googledrive\":t.apiKeys.googledrive={clientId:n},void 0!==t.googledrive&&t.googledrive.clientId===n||c._rs_init(t)}return!0}),i&&localStorage.setItem(\"remotestorage:api-keys\",JSON.stringify(this.apiKeys))},setCordovaRedirectUri:function(e){if(\"string\"!=typeof e||!e.match(/http(s)?:\\/\\//))throw new Error(\"Cordova redirect URI must be a URI string\");f.cordovaRedirectUri=e},_init:g.loadFeatures,features:g.features,loadFeature:g.loadFeature,featureSupported:g.featureSupported,featureDone:g.featureDone,featuresDone:g.featuresDone,featuresLoaded:g.featuresLoaded,featureInitialized:g.featureInitialized,featureFailed:g.featureFailed,hasFeature:g.hasFeature,_setCachingModule:g._setCachingModule,_collectCleanupFunctions:g._collectCleanupFunctions,_fireReady:g._fireReady,initFeature:g.initFeature,_setGPD:function(e,t){function r(e){return function(){return e.apply(t,arguments).then(n.bind(this))}}this.get=r(e.get),this.put=r(e.put),this.delete=r(e.delete)},_pendingGPD:function(e){return function(){var t=Array.prototype.slice.call(arguments);return new Promise(function(r,n){this._pending.push({method:e,args:t,promise:{resolve:r,reject:n}})}.bind(this))}.bind(this)},_processPending:function(){this._pending.forEach(function(e){try{this[e.method].apply(this,e.args).then(e.promise.resolve,e.promise.reject)}catch(t){e.promise.reject(t)}}.bind(this)),this._pending=[]},_bindChange:function(e){e.on(\"change\",this._dispatchEvent.bind(this,\"change\"))},_dispatchEvent:function(e,t){var r=this;Object.keys(this._pathHandlers[e]).forEach(function(n){var o=n.length;t.path.substr(0,o)===n&&r._pathHandlers[e][n].forEach(function(e){var o={};for(var i in t)o[i]=t[i];o.relativePath=t.path.replace(new RegExp(\"^\"+n),\"\");try{e(o)}catch(e){console.error(\"'change' handler failed: \",e,e.stack),r._emit(\"error\",e)}})})},scope:function(e){if(\"string\"!=typeof e)throw\"Argument 'path' of baseClient.scope must be a string\";if(!this.access.checkPathPermission(e,\"r\")){var t=e.replace(/(['\\\\])/g,\"\\\\$1\");console.warn(\"WARNING: please call remoteStorage.access.claim('\"+t+\"', 'r') (read only) or remoteStorage.access.claim('\"+t+\"', 'rw') (read/write) first\")}return new l(this,e)},getSyncInterval:function(){return f.syncInterval},setSyncInterval:function(e){if(!o(e))throw e+\" is not a valid sync interval\";var t=f.syncInterval;f.syncInterval=parseInt(e,10),this._emit(\"sync-interval-change\",{oldValue:t,newValue:e})},getBackgroundSyncInterval:function(){return f.backgroundSyncInterval},setBackgroundSyncInterval:function(e){if(!o(e))throw e+\" is not a valid sync interval\";var t=f.backgroundSyncInterval;f.backgroundSyncInterval=parseInt(e,10),this._emit(\"sync-interval-change\",{oldValue:t,newValue:e})},getCurrentSyncInterval:function(){return f.isBackground?f.backgroundSyncInterval:f.syncInterval},getRequestTimeout:function(){return f.requestTimeout},setRequestTimeout:function(e){f.requestTimeout=parseInt(e,10)},syncCycle:function(){this.sync.stopped||(this.on(\"sync-done\",function(){m(\"[Sync] Sync done. Setting timer to\",this.getCurrentSyncInterval()),this.sync.stopped||(this._syncTimer&&(clearTimeout(this._syncTimer),this._syncTimer=void 0),this._syncTimer=setTimeout(this.sync.sync.bind(this.sync),this.getCurrentSyncInterval()))}.bind(this)),this.sync.sync())},startSync:function(){return f.cache?(this.sync.stopped=!1,this.syncStopped=!1,this.sync.sync()):(console.warn(\"Nothing to sync, because caching is disabled.\"),Promise.resolve())},stopSync:function(){clearTimeout(this._syncTimer),this._syncTimer=void 0,this.sync?(m(\"[Sync] Stopping sync\"),this.sync.stopped=!0):(m(\"[Sync] Will instantiate sync stopped\"),this.syncStopped=!0)}},b.util=a,Object.defineProperty(b.prototype,\"connected\",{get:function(){return this.remote.connected}});var _=r(15);Object.defineProperty(b.prototype,\"access\",{get:function(){var e=new _;return Object.defineProperty(this,\"access\",{value:e}),e},configurable:!0});var w=r(16);Object.defineProperty(b.prototype,\"caching\",{configurable:!0,get:function(){var e=new w;return Object.defineProperty(this,\"caching\",{value:e}),e}}),e.exports=b,r(31)},function(e,t,r){\"use strict\";function n(e){this.defaultValue=e,this._storage={},this.set=this.justSet,this.delete=this.justDelete}function o(e){e._dropboxOrigSync||(e._dropboxOrigSync=e.sync.sync.bind(e.sync),e.sync.sync=function(){return this.dropbox.fetchDelta.apply(this.dropbox,arguments).then(e._dropboxOrigSync,function(t){return e._emit(\"error\",new v.SyncError(t)),Promise.reject(t)})}.bind(e))}function i(e){e._dropboxOrigSync&&(e.sync.sync=e._dropboxOrigSync,delete e._dropboxOrigSync)}function s(e){e._origBaseClientGetItemURL||(e._origBaseClientGetItemURL=p.prototype.getItemURL,p.prototype.getItemURL=function(){throw new Error(\"getItemURL is not implemented for Dropbox yet\")})}function a(e){e._origBaseClientGetItemURL&&(p.prototype.getItemURL=e._origBaseClientGetItemURL,delete e._origBaseClientGetItemURL)}function u(e){e._origRemote||(e._origRemote=e.remote,e.remote=e.dropbox)}function c(e){e._origRemote&&(e.remote=e._origRemote,delete e._origRemote)}function h(e){u(e),e.sync?o(e):e.on(\"connected\",function(){e.sync&&o(e)}),s(e)}function l(e){c(e),i(e),a(e)}var f=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&\"function\"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?\"symbol\":typeof e},d=r(4),p=r(5),m=r(7),g=r(0),y=r(2),v=r(8),b=void 0,_=\"remotestorage:dropbox\",w=g.isFolder,P=g.cleanPath,E=g.shouldBeTreatedAsBinary,S=g.readBinaryData,T=function(e){return P(\"/remotestorage/\"+e).replace(/\\/$/,\"\")},A=function(e,t){return new RegExp(\"^\"+t.join(\"\\\\/\")+\"(\\\\/|$)\").test(e.error_summary)},R=function(e){return e instanceof ArrayBuffer||m.isArrayBufferView(e)};n.prototype={get:function(e){e=e.toLowerCase();var t=this._storage[e];return void 0===t&&(t=this.defaultValue,this._storage[e]=t),t},propagateSet:function(e,t){return e=e.toLowerCase(),this._storage[e]===t?t:(this._propagate(e,t),this._storage[e]=t,t)},propagateDelete:function(e){return e=e.toLowerCase(),this._propagate(e,this._storage[e]),delete this._storage[e]},_activatePropagation:function(){return this.set=this.propagateSet,this.delete=this.propagateDelete,!0},justSet:function(e,t){return e=e.toLowerCase(),this._storage[e]=t,t},justDelete:function(e){return e=e.toLowerCase(),delete this._storage[e]},_propagate:function(e,t){for(var r=e.split(\"/\").slice(0,-1),n=\"\",o=0,i=r.length;o157286400)return Promise.reject(new Error(\"Cannot upload file larger than 150MB\"));var s,a=n&&(n.ifMatch||\"*\"===n.ifNoneMatch),u={body:t,contentType:r,path:e};return s=a?this._getMetadata(e).then(function(e){return n&&\"*\"===n.ifNoneMatch&&e?Promise.resolve({statusCode:412,revision:e.rev}):n&&n.ifMatch&&e&&e.rev!==n.ifMatch?Promise.resolve({statusCode:412,revision:e.rev}):o._uploadSimple(u)}):o._uploadSimple(u),s.then(function(t){return o._shareIfNeeded(e),t})},delete:function(e,t){var r=this;if(!this.connected)throw new Error(\"not connected (path: \"+e+\")\");var n=this._revCache.get(e);return t&&t.ifMatch&&n&&t.ifMatch!==n?Promise.resolve({statusCode:412,revision:n}):t&&t.ifMatch?this._getMetadata(e).then(function(n){return t&&t.ifMatch&&n&&n.rev!==t.ifMatch?Promise.resolve({statusCode:412,revision:n.rev}):r._deleteSimple(e)}):this._deleteSimple(e)},_shareIfNeeded:function(e){e.match(/^\\/public\\/.*[^\\/]$/)&&void 0===this._itemRefs[e]&&this.share(e)},share:function(e){var t=this,r={body:{path:T(e)}};return this._request(\"POST\",\"https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings\",r).then(function(r){if(200!==r.status&&409!==r.status)return Promise.reject(new Error(\"Invalid response status:\"+r.status));var n;try{n=JSON.parse(r.responseText)}catch(e){return Promise.reject(new Error(\"Invalid response body: \"+r.responseText))}return 409===r.status?A(n,[\"shared_link_already_exists\"])?t._getSharedLink(e):Promise.reject(new Error(\"API error: \"+n.error_summary)):Promise.resolve(n.url)}).then(function(r){return t._itemRefs[e]=r,b&&localStorage.setItem(_+\":shares\",JSON.stringify(t._itemRefs)),Promise.resolve(r)},function(t){return t.message='Sharing Dropbox file or folder (\"'+e+'\") failed: '+t.message,Promise.reject(t)})},info:function(){return this._request(\"POST\",\"https://api.dropboxapi.com/2/users/get_current_account\",{}).then(function(e){var t=e.responseText;try{t=JSON.parse(t)}catch(e){return Promise.reject(new Error(\"Could not query current account info: Invalid API response: \"+t))}return Promise.resolve({email:t.email})})},_request:function(e,t,r){var n=this;return r.headers||(r.headers={}),r.headers.Authorization=\"Bearer \"+this.token,\"object\"!==f(r.body)||R(r.body)||(r.body=JSON.stringify(r.body),r.headers[\"Content-Type\"]=\"application/json; charset=UTF-8\"),this.rs._emit(\"wire-busy\",{method:e,isFolder:w(t)}),m.request.call(this,e,t,r).then(function(o){return o&&503===o.status?(n.online&&(n.online=!1,n.rs._emit(\"network-offline\")),setTimeout(n._request(e,t,r),3210)):(n.online||(n.online=!0,n.rs._emit(\"network-online\")),n.rs._emit(\"wire-done\",{method:e,isFolder:w(t),success:!0}),Promise.resolve(o))},function(r){return n.online&&(n.online=!1,n.rs._emit(\"network-offline\")),n.rs._emit(\"wire-done\",{method:e,isFolder:w(t),success:!1}),Promise.reject(r)})},fetchDelta:function(){var e=Array.prototype.slice.call(arguments),t=this;return t._revCache=new n(\"rev\"),function r(n){var o=\"https://api.dropboxapi.com/2/files/list_folder\",i=void 0;return\"string\"==typeof n?(o+=\"/continue\",i={cursor:n}):i={path:\"/remotestorage\",recursive:!0,include_deleted:!0},t._request(\"POST\",o,{body:i}).then(function(n){if(401===n.status)return t.rs._emit(\"error\",new d.Unauthorized),Promise.resolve(e);if(200!==n.status&&409!==n.status)return Promise.reject(new Error(\"Invalid response status: \"+n.status));var o=void 0;try{o=JSON.parse(n.responseText)}catch(e){return Promise.reject(new Error(\"Invalid response body: \"+n.responseText))}if(409===n.status){if(!A(o,[\"path\",\"not_found\"]))return Promise.reject(new Error(\"API returned an error: \"+o.error_summary));o={cursor:null,entries:[],has_more:!1}}return o.entries.forEach(function(e){var r=e.path_lower.substr(\"/remotestorage\".length);\"deleted\"===e[\".tag\"]?(t._revCache.set(r,null),t._revCache.set(r+\"/\",null)):\"file\"===e[\".tag\"]&&t._revCache.set(r,e.rev)}),o.has_more?r(o.cursor):void 0}).catch(function(e){return\"timeout\"===e||e instanceof ProgressEvent?Promise.resolve():Promise.reject(e)})}().then(void 0,function(e){return\"object\"===(void 0===e?\"undefined\":f(e))&&\"message\"in e?e.message=\"Dropbox: fetchDelta: \"+e.message:e=\"Dropbox: fetchDelta: \"+e,Promise.reject(e)}).then(function(){return t._revCache&&t._revCache._activatePropagation(),Promise.resolve(e)})},_getMetadata:function(e){var t={path:T(e)};return this._request(\"POST\",\"https://api.dropboxapi.com/2/files/get_metadata\",{body:t}).then(function(e){if(200!==e.status&&409!==e.status)return Promise.reject(new Error(\"Invalid response status:\"+e.status));var t=void 0;try{t=JSON.parse(e.responseText)}catch(t){return Promise.reject(new Error(\"Invalid response body: \"+e.responseText))}return 409===e.status?A(t,[\"path\",\"not_found\"])?Promise.resolve():Promise.reject(new Error(\"API error: \"+t.error_summary)):Promise.resolve(t)}).then(void 0,function(t){return t.message='Could not load metadata for file or folder (\"'+e+'\"): '+t.message,Promise.reject(t)})},_uploadSimple:function(e){var t=this,r={path:T(e.path),mode:{\".tag\":\"overwrite\"},mute:!0};return e.ifMatch&&(r.mode={\".tag\":\"update\",update:e.ifMatch}),this._request(\"POST\",\"https://content.dropboxapi.com/2/files/upload\",{body:e.body,headers:{\"Content-Type\":\"application/octet-stream\",\"Dropbox-API-Arg\":JSON.stringify(r)}}).then(function(r){if(200!==r.status&&409!==r.status)return Promise.resolve({statusCode:r.status});var n=r.responseText;try{n=JSON.parse(n)}catch(e){return Promise.reject(new Error(\"Invalid API result: \"+n))}return 409===r.status?A(n,[\"path\",\"conflict\"])?t._getMetadata(e.path).then(function(e){return Promise.resolve({statusCode:412,revision:e.rev})}):Promise.reject(new Error(\"API error: \"+n.error_summary)):(t._revCache.propagateSet(e.path,n.rev),Promise.resolve({statusCode:r.status,revision:n.rev}))})},_deleteSimple:function(e){var t=this,r={path:T(e)};return this._request(\"POST\",\"https://api.dropboxapi.com/2/files/delete\",{body:r}).then(function(e){if(200!==e.status&&409!==e.status)return Promise.resolve({statusCode:e.status});var t=e.responseText;try{t=JSON.parse(t)}catch(e){return Promise.reject(new Error(\"Invalid response body: \"+t))}return 409===e.status?A(t,[\"path_lookup\",\"not_found\"])?Promise.resolve({statusCode:404}):Promise.reject(new Error(\"API error: \"+t.error_summary)):Promise.resolve({statusCode:200})}).then(function(r){return 200!==r.statusCode&&404!==r.statusCode||(t._revCache.delete(e),delete t._itemRefs[e]),Promise.resolve(r)},function(t){return t.message='Could not delete Dropbox file or folder (\"'+e+'\"): '+t.message,Promise.reject(t)})},_getSharedLink:function(e){var t={body:{path:T(e),direct_only:!0}};return this._request(\"POST\",\"https://api.dropbox.com/2/sharing/list_shared_links\",t).then(function(e){if(200!==e.status&&409!==e.status)return Promise.reject(new Error(\"Invalid response status: \"+e.status));var t;try{t=JSON.parse(e.responseText)}catch(t){return Promise.reject(new Error(\"Invalid response body: \"+e.responseText))}return 409===e.status?Promise.reject(new Error(\"API error: \"+e.error_summary)):t.links.length?Promise.resolve(t.links[0].url):Promise.reject(new Error(\"No links returned\"))},function(t){return t.message='Could not get link to a shared file or folder (\"'+e+'\"): '+t.message,Promise.reject(t)})}},k._rs_init=function(e){b=g.localStorageAvailable(),e.apiKeys.dropbox&&(e.dropbox=new k(e)),\"dropbox\"===e.backend&&h(e)},k._rs_supported=function(){return!0},k._rs_cleanup=function(e){l(e),b&&localStorage.removeItem(_),e.setBackend(void 0)},e.exports=k},function(e,t,r){\"use strict\";var n=r(2),o=\"undefined\"!=typeof window?\"browser\":\"node\",i={},s=function(){return i};s.isBrowser=function(){return\"browser\"===o},s.isNode=function(){return\"node\"===o},s.goBackground=function(){s._emit(\"background\")},s.goForeground=function(){s._emit(\"foreground\")},s._rs_init=function(){function e(){document[i.hiddenProperty]?s.goBackground():s.goForeground()}n(s,\"background\",\"foreground\"),\"browser\"===o&&(void 0!==document.hidden?(i.hiddenProperty=\"hidden\",i.visibilityChangeEvent=\"visibilitychange\"):void 0!==document.mozHidden?(i.hiddenProperty=\"mozHidden\",i.visibilityChangeEvent=\"mozvisibilitychange\"):void 0!==document.msHidden?(i.hiddenProperty=\"msHidden\",i.visibilityChangeEvent=\"msvisibilitychange\"):void 0!==document.webkitHidden&&(i.hiddenProperty=\"webkitHidden\",i.visibilityChangeEvent=\"webkitvisibilitychange\"),document.addEventListener(i.visibilityChangeEvent,e,!1),e())},s._rs_cleanup=function(){},e.exports=s},function(e,t,r){\"use strict\";function n(e){return\"/\"===e.substr(-1)&&(e=e.substr(0,e.length-1)),decodeURIComponent(e)}function o(e){return e.replace(/[^\\/]+\\/?$/,\"\")}function i(e){var t=e.split(\"/\");return\"/\"===e.substr(-1)?t[t.length-2]+\"/\":t[t.length-1]}function s(e){return b(y+\"/\"+e)}function a(e){e._origBaseClientGetItemURL||(e._origBaseClientGetItemURL=l.prototype.getItemURL,l.prototype.getItemURL=function(){throw new Error(\"getItemURL is not implemented for Google Drive yet\")})}function u(e){e._origBaseClientGetItemURL&&(l.prototype.getItemURL=e._origBaseClientGetItemURL,delete e._origBaseClientGetItemURL)}var c=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&\"function\"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?\"symbol\":typeof e},h=r(4),l=r(5),f=r(7),d=r(2),p=r(0),m=\"https://www.googleapis.com\",g=\"remotestorage:googledrive\",y=\"/remotestorage\",v=p.isFolder,b=p.cleanPath,_=p.shouldBeTreatedAsBinary,w=p.readBinaryData,P=void 0,E=function(e){this.maxAge=e,this._items={}};E.prototype={get:function(e){var t=this._items[e],r=(new Date).getTime();return t&&t.t>=r-this.maxAge?t.v:void 0},set:function(e,t){this._items[e]={v:t,t:(new Date).getTime()}}};var S=function(e,t){if(d(this,\"connected\",\"not-connected\"),this.rs=e,this.clientId=t,this._fileIdCache=new E(300),P=p.localStorageAvailable()){var r=void 0;try{r=JSON.parse(localStorage.getItem(g))}catch(e){}r&&this.configure(r)}};S.prototype={connected:!1,online:!0,configure:function(e){var t=this;void 0!==e.userAddress&&(this.userAddress=e.userAddress),void 0!==e.token&&(this.token=e.token);var r=function(){P&&localStorage.setItem(g,JSON.stringify({userAddress:this.userAddress,token:this.token}))},n=function(){this.connected=!1,delete this.token,P&&localStorage.removeItem(g)};this.token?(this.connected=!0,this.userAddress?(this._emit(\"connected\"),r.apply(this)):this.info().then(function(e){t.userAddress=e.user.emailAddress,t._emit(\"connected\"),r.apply(t)}).catch(function(){n.apply(t),t.rs._emit(\"error\",new Error(\"Could not fetch user info.\"))})):n.apply(this)},connect:function(){this.rs.setBackend(\"googledrive\"),h(this.rs,\"https://accounts.google.com/o/oauth2/auth\",\"https://www.googleapis.com/auth/drive\",String(h.getLocation()),this.clientId)},stopWaitingForToken:function(){this.connected||this._emit(\"not-connected\")},get:function(e,t){return\"/\"===e.substr(-1)?this._getFolder(s(e),t):this._getFile(s(e),t)},put:function(e,t,r,n){function o(e){if(e.status>=200&&e.status<300){var t=JSON.parse(e.responseText),r=t.etag.substring(1,t.etag.length-1);return Promise.resolve({statusCode:200,contentType:t.mimeType,revision:r})}return 412===e.status?Promise.resolve({statusCode:412,revision:\"conflict\"}):Promise.reject(\"PUT failed with status \"+e.status+\" (\"+e.responseText+\")\")}var i=this,a=s(e);return this._getFileId(a).then(function(e){return e?n&&\"*\"===n.ifNoneMatch?o({status:412}):i._updateFile(e,a,t,r,n).then(o):i._createFile(a,t,r,n).then(o)})},delete:function(e,t){var r=this,n=s(e);return this._getFileId(n).then(function(e){return e?r._getMeta(e).then(function(n){var o=void 0;return\"object\"===(void 0===n?\"undefined\":c(n))&&\"string\"==typeof n.etag&&(o=n.etag.substring(1,n.etag.length-1)),t&&t.ifMatch&&t.ifMatch!==o?{statusCode:412,revision:o}:r._request(\"DELETE\",m+\"/drive/v2/files/\"+e,{}).then(function(e){return 200===e.status||204===e.status?{statusCode:200}:Promise.reject(\"Delete failed: \"+e.status+\" (\"+e.responseText+\")\")})}):Promise.resolve({statusCode:200})})},info:function(){return this._request(\"GET\",\"https://www.googleapis.com/drive/v2/about?fields=user\",{}).then(function(e){try{var t=JSON.parse(e.responseText);return Promise.resolve(t)}catch(e){return Promise.reject(e)}})},_updateFile:function(e,t,r,n,o){var i=this,s={mimeType:n},a={\"Content-Type\":\"application/json; charset=UTF-8\"};return o&&o.ifMatch&&(a[\"If-Match\"]='\"'+o.ifMatch+'\"'),this._request(\"PUT\",m+\"/upload/drive/v2/files/\"+e+\"?uploadType=resumable\",{body:JSON.stringify(s),headers:a}).then(function(e){return 412===e.status?e:i._request(\"PUT\",e.getResponseHeader(\"Location\"),{body:n.match(/^application\\/json/)?JSON.stringify(r):r})})},_createFile:function(e,t,r){var o=this;return this._getParentId(e).then(function(s){var a=i(e),u={title:n(a),mimeType:r,parents:[{kind:\"drive#fileLink\",id:s}]};return o._request(\"POST\",m+\"/upload/drive/v2/files?uploadType=resumable\",{body:JSON.stringify(u),headers:{\"Content-Type\":\"application/json; charset=UTF-8\"}}).then(function(e){return o._request(\"POST\",e.getResponseHeader(\"Location\"),{body:r.match(/^application\\/json/)?JSON.stringify(t):t})})})},_getFile:function(e,t){var r=this;return this._getFileId(e).then(function(e){return r._getMeta(e).then(function(e){var n=void 0;if(\"object\"===(void 0===e?\"undefined\":c(e))&&\"string\"==typeof e.etag&&(n=e.etag.substring(1,e.etag.length-1)),t&&t.ifNoneMatch&&n===t.ifNoneMatch)return Promise.resolve({statusCode:304});var o={};if(!e.downloadUrl){if(!e.exportLinks||!e.exportLinks[\"text/html\"])return Promise.resolve({statusCode:200,body:\"\",contentType:e.mimeType,revision:n});e.mimeType+=\";export=text/html\",e.downloadUrl=e.exportLinks[\"text/html\"]}return r._request(\"GET\",e.downloadUrl,o).then(function(t){var r=t.response;if(e.mimeType.match(/^application\\/json/))try{r=JSON.parse(r)}catch(e){}else if(_(r,e.mimeType))return w(r,e.mimeType).then(function(t){return{statusCode:200,body:t,contentType:e.mimeType,revision:n}});return Promise.resolve({statusCode:200,body:r,contentType:e.mimeType,revision:n})})})})},_getFolder:function(e){var t=this;return this._getFileId(e).then(function(r){var n=void 0,o=void 0,i=void 0,s=void 0,a=void 0;return r?(n=\"'\"+r+\"' in parents\",o=\"items(downloadUrl,etag,fileSize,id,mimeType,title)\",t._request(\"GET\",m+\"/drive/v2/files?q=\"+encodeURIComponent(n)+\"&fields=\"+encodeURIComponent(o)+\"&maxResults=1000\",{}).then(function(r){if(200!==r.status)return Promise.reject(\"request failed or something: \"+r.status);try{i=JSON.parse(r.responseText)}catch(e){return Promise.reject(\"non-JSON response from GoogleDrive\")}a={};var n=!0,o=!1,u=void 0;try{for(var c,h=i.items[Symbol.iterator]();!(n=(c=h.next()).done);n=!0){var l=c.value;s=l.etag.substring(1,l.etag.length-1),\"application/vnd.google-apps.folder\"===l.mimeType?(t._fileIdCache.set(e+l.title+\"/\",l.id),a[l.title+\"/\"]={ETag:s}):(t._fileIdCache.set(e+l.title,l.id),a[l.title]={ETag:s,\"Content-Type\":l.mimeType,\"Content-Length\":l.fileSize})}}catch(e){o=!0,u=e}finally{try{!n&&h.return&&h.return()}finally{if(o)throw u}}return Promise.resolve({statusCode:200,body:a,contentType:\"application/json; charset=UTF-8\",revision:void 0})})):Promise.resolve({statusCode:404})})},_getParentId:function(e){var t=this,r=o(e);return this._getFileId(r).then(function(e){return e?Promise.resolve(e):t._createFolder(r)})},_createFolder:function(e){var t=this;return this._getParentId(e).then(function(r){return t._request(\"POST\",m+\"/drive/v2/files\",{body:JSON.stringify({title:n(i(e)),mimeType:\"application/vnd.google-apps.folder\",parents:[{id:r}]}),headers:{\"Content-Type\":\"application/json; charset=UTF-8\"}}).then(function(e){var t=JSON.parse(e.responseText);return Promise.resolve(t.id)})})},_getFileId:function(e){var t=this,r=void 0;return\"/\"===e?Promise.resolve(\"root\"):(r=this._fileIdCache.get(e))?Promise.resolve(r):this._getFolder(o(e)).then(function(){return r=t._fileIdCache.get(e),r?Promise.resolve(r):\"/\"===e.substr(-1)?t._createFolder(e).then(function(){return t._getFileId(e)}):Promise.resolve()})},_getMeta:function(e){return this._request(\"GET\",m+\"/drive/v2/files/\"+e,{}).then(function(t){return 200===t.status?Promise.resolve(JSON.parse(t.responseText)):Promise.reject(\"request (getting metadata for \"+e+\") failed with status: \"+t.status)})},_request:function(e,t,r){var n=this;return r.headers||(r.headers={}),r.headers.Authorization=\"Bearer \"+this.token,this.rs._emit(\"wire-busy\",{method:e,isFolder:v(t)}),f.request.call(this,e,t,r).then(function(r){return r&&401===r.status?void n.connect():(n.online||(n.online=!0,n.rs._emit(\"network-online\")),n.rs._emit(\"wire-done\",{method:e,isFolder:v(t),success:!0}),Promise.resolve(r))},function(r){return n.online&&(n.online=!1,n.rs._emit(\"network-offline\")),n.rs._emit(\"wire-done\",{method:e,isFolder:v(t),success:!1}),Promise.reject(r)})}},S._rs_init=function(e){var t=e.apiKeys.googledrive;t&&(e.googledrive=new S(e,t.clientId),\"googledrive\"===e.backend&&(e._origRemote=e.remote,e.remote=e.googledrive,a(e)))},S._rs_supported=function(){return!0},S._rs_cleanup=function(e){e.setBackend(void 0),e._origRemote&&(e.remote=e._origRemote,delete e._origRemote),u(e)},e.exports=S},function(e,t,r){\"use strict\";var n,o,i=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&\"function\"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?\"symbol\":typeof e},s=r(1),a=r(0),u=r(24),c={},h=function(e){return new Promise(function(t,r){return e in c?t(c[e]):new u({tls_only:!1,uri_fallback:!0,request_timeout:5e3}).lookup(e,function(n,a){if(n)return r(n);if(\"object\"!==i(a.idx.links.remotestorage)||\"number\"!=typeof a.idx.links.remotestorage.length||a.idx.links.remotestorage.length<=0)return s(\"[Discover] WebFinger record for \"+e+\" does not have remotestorage defined in the links section \",JSON.stringify(a.json)),r(\"WebFinger record for \"+e+\" does not have remotestorage defined in the links section.\");var u=a.idx.links.remotestorage[0],h=u.properties[\"http://tools.ietf.org/html/rfc6749#section-4.2\"]||u.properties[\"auth-endpoint\"],l=u.properties[\"http://remotestorage.io/spec/version\"]||u.type;return c[e]={href:u.href,storageType:l,authURL:h,properties:u.properties},o&&(localStorage[\"remotestorage:discover\"]=JSON.stringify({cache:c})),t(c[e])})})};h.DiscoveryError=function(e){this.name=\"DiscoveryError\",this.message=e,this.stack=(new Error).stack},h.DiscoveryError.prototype=Object.create(Error.prototype),h.DiscoveryError.prototype.constructor=h.DiscoveryError,h._rs_init=function(){if(o=a.localStorageAvailable()){var e;try{e=JSON.parse(localStorage[\"remotestorage:discover\"])}catch(e){}e&&(c=e.cache)}},h._rs_supported=function(){return n=!!a.globalContext.XMLHttpRequest},h._rs_cleanup=function(){o&&delete localStorage[\"remotestorage:discover\"]},e.exports=h},function(e,t,r){\"use strict\";var n=function(){this.reset()};n.prototype={claim:function(e,t){if(\"string\"!=typeof e||-1!==e.indexOf(\"/\")||0===e.length)throw new Error(\"Scope should be a non-empty string without forward slashes\");if(!t.match(/^rw?$/))throw new Error(\"Mode should be either 'r' or 'rw'\");this._adjustRootPaths(e),this.scopeModeMap[e]=t},get:function(e){return this.scopeModeMap[e]},remove:function(e){var t,r={};for(t in this.scopeModeMap)r[t]=this.scopeModeMap[t];this.reset(),delete r[e];for(t in r)this.set(t,r[t])},checkPermission:function(e,t){var r=this.get(e);return r&&(\"r\"===t||\"rw\"===r)},checkPathPermission:function(e,t){return!!this.checkPermission(\"*\",t)||!!this.checkPermission(this._getModuleName(e),t)},reset:function(){this.rootPaths=[],this.scopeModeMap={}},_getModuleName:function(e){if(\"/\"!==e[0])throw new Error(\"Path should start with a slash\");var t=e.replace(/^\\/public/,\"\").match(/^\\/([^\\/]*)\\//);return t?t[1]:\"*\"},_adjustRootPaths:function(e){\"*\"in this.scopeModeMap||\"*\"===e?this.rootPaths=[\"/\"]:e in this.scopeModeMap||(this.rootPaths.push(\"/\"+e+\"/\"),this.rootPaths.push(\"/public/\"+e+\"/\"))},_scopeNameForParameter:function(e){if(\"*\"===e.name&&this.storageType){if(\"2012.04\"===this.storageType)return\"\";if(this.storageType.match(/remotestorage-0[01]/))return\"root\"}return e.name},setStorageType:function(e){this.storageType=e}},Object.defineProperty(n.prototype,\"scopes\",{get:function(){return Object.keys(this.scopeModeMap).map(function(e){return{name:e,mode:this.scopeModeMap[e]}}.bind(this))}}),Object.defineProperty(n.prototype,\"scopeParameter\",{get:function(){return this.scopes.map(function(e){return this._scopeNameForParameter(e)+\":\"+e.mode}.bind(this)).join(\" \")}}),n._rs_init=function(){},e.exports=n},function(e,t,r){\"use strict\";var n=r(0),o=r(1),i=n.containingFolder,s=function(){this.reset()};s.prototype={pendingActivations:[],set:function(e,t){if(\"string\"!=typeof e)throw new Error(\"path should be a string\");if(!n.isFolder(e))throw new Error(\"path should be a folder\");if(this._remoteStorage&&this._remoteStorage.access&&!this._remoteStorage.access.checkPathPermission(e,\"r\"))throw new Error('No access to path \"'+e+'\". You have to claim access to it first.');if(!t.match(/^(FLUSH|SEEN|ALL)$/))throw new Error(\"strategy should be 'FLUSH', 'SEEN', or 'ALL'\");this._rootPaths[e]=t,\"ALL\"===t&&(this.activateHandler?this.activateHandler(e):this.pendingActivations.push(e))},enable:function(e){this.set(e,\"ALL\")},disable:function(e){this.set(e,\"FLUSH\")},onActivate:function(e){var t;for(o(\"[Caching] Setting activate handler\",e,this.pendingActivations),this.activateHandler=e,t=0;t0&&(r+=l.suffices[\"*\"]?n||\",\":\",\",l.suffices[\"*\"]&&s&&(r+=l.name+\"=\")),r+=i?encodeURIComponent(f[d]).replace(/!/g,\"%21\"):e(f[d])}else if(\"object\"==typeof f){s&&!l.suffices[\"*\"]&&(r+=l.name+\"=\");var p=!0;for(var m in f)p||(r+=l.suffices[\"*\"]?n||\",\":\",\"),p=!1,r+=i?encodeURIComponent(m).replace(/!/g,\"%21\"):e(m),r+=l.suffices[\"*\"]?\"=\":\",\",r+=i?encodeURIComponent(f[m]).replace(/!/g,\"%21\"):e(f[m])}else s&&(r+=l.name,a&&\"\"===f||(r+=\"=\")),null!=l.truncate&&(f=f.substring(0,l.truncate)),r+=i?encodeURIComponent(f).replace(/!/g,\"%21\"):e(f)}return r};return _.varNames=u,{prefix:o,substitution:_}}function r(e){if(!(this instanceof r))return new r(e);for(var n=e.split(\"{\"),o=[n.shift()],i=[],s=[],a=[];n.length>0;){var u=n.shift(),c=u.split(\"}\")[0],h=u.substring(c.length+1),l=t(c);s.push(l.substitution),i.push(l.prefix),o.push(h),a=a.concat(l.substitution.varNames)}this.fill=function(e){for(var t=o[0],r=0;r0&&\"/\"===t.charAt(e.length-1)||\"#\"===r.charAt(0)||\"?\"===r.charAt(0))return!0}return!1}function l(e){var t,r,n=new p,o={setErrorReporter:function(e){return\"string\"==typeof e?this.language(e):(r=e,!0)},addFormat:function(){n.addFormat.apply(n,arguments)},language:function(e){return e?(w[e]||(e=e.split(\"-\")[0]),!!w[e]&&(t=e,e)):t},addLanguage:function(e,t){var r;for(r in y)t[r]&&!t[y[r]]&&(t[y[r]]=t[r]);var n=e.split(\"-\")[0];if(w[n]){w[e]=Object.create(w[n]);for(r in t)void 0===w[n][r]&&(w[n][r]=t[r]),w[e][r]=t[r]}else w[e]=t,w[n]=t;return this},freshApi:function(e){var t=l();return e&&t.language(e),t},validate:function(e,o,i,s){var a=u(t),c=r?function(e,t,n){return r(e,t,n)||a(e,t,n)}:a,h=new p(n,!1,c,i,s);\"string\"==typeof o&&(o={$ref:o}),h.addSchema(\"\",o);var l=h.validateAll(e,o,null,null,\"\");return!l&&s&&(l=h.banUnknownProperties(e,o)),this.error=l,this.missing=h.missing,this.valid=null===l,this.valid},validateResult:function(){var e={toString:function(){return this.valid?\"valid\":this.error.message}};return this.validate.apply(e,arguments),e},validateMultiple:function(e,o,i,s){var a=u(t),c=r?function(e,t,n){return r(e,t,n)||a(e,t,n)}:a,h=new p(n,!0,c,i,s);\"string\"==typeof o&&(o={$ref:o}),h.addSchema(\"\",o),h.validateAll(e,o,null,null,\"\"),s&&h.banUnknownProperties(e,o);var l={toString:function(){return this.valid?\"valid\":this.error.message}};return l.errors=h.errors,l.missing=h.missing,l.valid=0===l.errors.length,l},addSchema:function(){return n.addSchema.apply(n,arguments)},getSchema:function(){return n.getSchema.apply(n,arguments)},getSchemaMap:function(){return n.getSchemaMap.apply(n,arguments)},getSchemaUris:function(){return n.getSchemaUris.apply(n,arguments)},getMissingUris:function(){return n.getMissingUris.apply(n,arguments)},dropSchemas:function(){n.dropSchemas.apply(n,arguments)},defineKeyword:function(){n.defineKeyword.apply(n,arguments)},defineError:function(e,t,r){if(\"string\"!=typeof e||!/^[A-Z]+(_[A-Z]+)*$/.test(e))throw new Error(\"Code name must be a string in UPPER_CASE_WITH_UNDERSCORES\");if(\"number\"!=typeof t||t%1!=0||t<1e4)throw new Error(\"Code number must be an integer > 10000\");if(void 0!==y[e])throw new Error(\"Error already defined: \"+e+\" as \"+y[e]);if(void 0!==v[t])throw new Error(\"Error code already used: \"+v[t]+\" as \"+t);y[e]=t,v[t]=e,_[e]=_[t]=r;for(var n in w){var o=w[n];o[e]&&(o[t]=o[t]||o[e])}},reset:function(){n.reset(),this.error=null,this.missing=[],this.valid=!0},missing:[],error:null,valid:!0,normSchema:a,resolveUrl:i,getDocumentUri:s,errorCodes:y};return o.language(e||\"en\"),o}Object.keys||(Object.keys=function(){var e=Object.prototype.hasOwnProperty,t=!{toString:null}.propertyIsEnumerable(\"toString\"),r=[\"toString\",\"toLocaleString\",\"valueOf\",\"hasOwnProperty\",\"isPrototypeOf\",\"propertyIsEnumerable\",\"constructor\"],n=r.length;return function(o){if(\"object\"!=typeof o&&\"function\"!=typeof o||null===o)throw new TypeError(\"Object.keys called on non-object\");var i=[];for(var s in o)e.call(o,s)&&i.push(s);if(t)for(var a=0;a>>0;if(0===r)return-1;var n=0;if(arguments.length>1&&(n=Number(arguments[1]),n!==n?n=0:0!==n&&n!==1/0&&n!==-1/0&&(n=(n>0||-1)*Math.floor(Math.abs(n)))),n>=r)return-1;for(var o=n>=0?n:Math.max(r-Math.abs(n),0);o=m&&nt.maximum)return this.createError(y.NUMBER_MAXIMUM,{value:e,maximum:t.maximum},\"\",\"/maximum\",null,e,t);if(t.exclusiveMaximum&&e===t.maximum)return this.createError(y.NUMBER_MAXIMUM_EXCLUSIVE,{value:e,maximum:t.maximum},\"\",\"/exclusiveMaximum\",null,e,t)}return null},p.prototype.validateNaN=function(e,t){return\"number\"!=typeof e?null:!0===isNaN(e)||e===1/0||e===-1/0?this.createError(y.NUMBER_NOT_A_NUMBER,{value:e},\"\",\"/type\",null,e,t):null},p.prototype.validateString=function(e,t,r){return this.validateStringLength(e,t,r)||this.validateStringPattern(e,t,r)||null},p.prototype.validateStringLength=function(e,t){return\"string\"!=typeof e?null:void 0!==t.minLength&&e.lengtht.maxLength?this.createError(y.STRING_LENGTH_LONG,{length:e.length,maximum:t.maxLength},\"\",\"/maxLength\",null,e,t):null},p.prototype.validateStringPattern=function(e,t){if(\"string\"!=typeof e||\"string\"!=typeof t.pattern&&!(t.pattern instanceof RegExp))return null;var r;if(t.pattern instanceof RegExp)r=t.pattern;else{var n,o=\"\",i=t.pattern.match(/^\\/(.+)\\/([img]*)$/);i?(n=i[1],o=i[2]):n=t.pattern,r=new RegExp(n,o)}return r.test(e)?null:this.createError(y.STRING_PATTERN,{pattern:t.pattern},\"\",\"/pattern\",null,e,t)},p.prototype.validateArray=function(e,t,r){return Array.isArray(e)?this.validateArrayLength(e,t,r)||this.validateArrayUniqueItems(e,t,r)||this.validateArrayItems(e,t,r)||null:null},p.prototype.validateArrayLength=function(e,t){var r;return void 0!==t.minItems&&e.lengtht.maxItems&&(r=this.createError(y.ARRAY_LENGTH_LONG,{length:e.length,maximum:t.maxItems},\"\",\"/maxItems\",null,e,t),this.handleError(r))?r:null},p.prototype.validateArrayUniqueItems=function(e,t){if(t.uniqueItems)for(var r=0;rt.maxProperties&&(r=this.createError(y.OBJECT_PROPERTIES_MAXIMUM,{propertyCount:n.length,maximum:t.maxProperties},\"\",\"/maxProperties\",null,e,t),this.handleError(r))?r:null},p.prototype.validateObjectRequiredProperties=function(e,t){if(void 0!==t.required)for(var r=0;r=n())throw new RangeError(\"Attempt to allocate Buffer larger than maximum size: 0x\"+n().toString(16)+\" bytes\");return 0|e}function m(e){return+e!=e&&(e=0),i.alloc(+e)}function g(e,t){if(i.isBuffer(e))return e.length;if(\"undefined\"!=typeof ArrayBuffer&&\"function\"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;\"string\"!=typeof e&&(e=\"\"+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case\"ascii\":case\"latin1\":case\"binary\":return r;case\"utf8\":case\"utf-8\":case void 0:return Y(e).length;case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return 2*r;case\"hex\":return r>>>1;case\"base64\":return K(e).length;default:if(n)return Y(e).length;t=(\"\"+t).toLowerCase(),n=!0}}function y(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return\"\";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return\"\";if(r>>>=0,t>>>=0,r<=t)return\"\";for(e||(e=\"utf8\");;)switch(e){case\"hex\":return M(this,t,r);case\"utf8\":case\"utf-8\":return k(this,t,r);case\"ascii\":return C(this,t,r);case\"latin1\":case\"binary\":return O(this,t,r);case\"base64\":return R(this,t,r);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return N(this,t,r);default:if(n)throw new TypeError(\"Unknown encoding: \"+e);e=(e+\"\").toLowerCase(),n=!0}}function v(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function b(e,t,r,n,o){if(0===e.length)return-1;if(\"string\"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if(\"string\"==typeof t&&(t=i.from(t,n)),i.isBuffer(t))return 0===t.length?-1:_(e,t,r,n,o);if(\"number\"==typeof t)return t&=255,i.TYPED_ARRAY_SUPPORT&&\"function\"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):_(e,[t],r,n,o);throw new TypeError(\"val must be string, number or Buffer\")}function _(e,t,r,n,o){function i(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}var s=1,a=e.length,u=t.length;if(void 0!==n&&(\"ucs2\"===(n=String(n).toLowerCase())||\"ucs-2\"===n||\"utf16le\"===n||\"utf-16le\"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}var c;if(o){var h=-1;for(c=r;ca&&(r=a-u),c=r;c>=0;c--){for(var l=!0,f=0;fo&&(n=o):n=o;var i=t.length;if(i%2!=0)throw new TypeError(\"Invalid hex string\");n>i/2&&(n=i/2);for(var s=0;s239?4:i>223?3:i>191?2:1;if(o+a<=r){var u,c,h,l;switch(a){case 1:i<128&&(s=i);break;case 2:u=e[o+1],128==(192&u)&&(l=(31&i)<<6|63&u)>127&&(s=l);break;case 3:u=e[o+1],c=e[o+2],128==(192&u)&&128==(192&c)&&(l=(15&i)<<12|(63&u)<<6|63&c)>2047&&(l<55296||l>57343)&&(s=l);break;case 4:u=e[o+1],c=e[o+2],h=e[o+3],128==(192&u)&&128==(192&c)&&128==(192&h)&&(l=(15&i)<<18|(63&u)<<12|(63&c)<<6|63&h)>65535&&l<1114112&&(s=l)}}null===s?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),o+=a}return I(n)}function I(e){var t=e.length;if(t<=Z)return String.fromCharCode.apply(String,e);for(var r=\"\",n=0;nn)&&(r=n);for(var o=\"\",i=t;ir)throw new RangeError(\"Trying to access beyond buffer length\")}function U(e,t,r,n,o,s){if(!i.isBuffer(e))throw new TypeError('\"buffer\" argument must be a Buffer instance');if(t>o||te.length)throw new RangeError(\"Index out of range\")}function j(e,t,r,n){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-r,2);o>>8*(n?o:1-o)}function B(e,t,r,n){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-r,4);o>>8*(n?o:3-o)&255}function L(e,t,r,n,o,i){if(r+n>e.length)throw new RangeError(\"Index out of range\");if(r<0)throw new RangeError(\"Index out of range\")}function D(e,t,r,n,o){return o||L(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38),X.write(e,t,r,n,23,4),r+4}function F(e,t,r,n,o){return o||L(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308),X.write(e,t,r,n,52,8),r+8}function q(e){if(e=J(e).replace(ee,\"\"),e.length<2)return\"\";for(;e.length%4!=0;)e+=\"=\";return e}function J(e){return e.trim?e.trim():e.replace(/^\\s+|\\s+$/g,\"\")}function G(e){return e<16?\"0\"+e.toString(16):e.toString(16)}function Y(e,t){t=t||1/0;for(var r,n=e.length,o=null,i=[],s=0;s55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error(\"Invalid code point\");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function z(e){for(var t=[],r=0;r>8,o=r%256,i.push(o),i.push(n);return i}function K(e){return $.toByteArray(q(e))}function V(e,t,r,n){for(var o=0;o=t.length||o>=e.length);++o)t[o+r]=e[o];return o}function W(e){return e!==e}/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh \n * @license MIT\n */\nvar $=r(21),X=r(22),Q=r(23);t.Buffer=i,t.SlowBuffer=m,t.INSPECT_MAX_BYTES=50,i.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&\"function\"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=n(),i.poolSize=8192,i._augment=function(e){return e.__proto__=i.prototype,e},i.from=function(e,t,r){return s(null,e,t,r)},i.TYPED_ARRAY_SUPPORT&&(i.prototype.__proto__=Uint8Array.prototype,i.__proto__=Uint8Array,\"undefined\"!=typeof Symbol&&Symbol.species&&i[Symbol.species]===i&&Object.defineProperty(i,Symbol.species,{value:null,configurable:!0})),i.alloc=function(e,t,r){return u(null,e,t,r)},i.allocUnsafe=function(e){return c(null,e)},i.allocUnsafeSlow=function(e){return c(null,e)},i.isBuffer=function(e){return!(null==e||!e._isBuffer)},i.compare=function(e,t){if(!i.isBuffer(e)||!i.isBuffer(t))throw new TypeError(\"Arguments must be Buffers\");if(e===t)return 0;for(var r=e.length,n=t.length,o=0,s=Math.min(r,n);o0&&(e=this.toString(\"hex\",0,r).match(/.{2}/g).join(\" \"),this.length>r&&(e+=\" ... \")),\"\"},i.prototype.compare=function(e,t,r,n,o){if(!i.isBuffer(e))throw new TypeError(\"Argument must be a Buffer\");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),t<0||r>e.length||n<0||o>this.length)throw new RangeError(\"out of range index\");if(n>=o&&t>=r)return 0;if(n>=o)return-1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,o>>>=0,this===e)return 0;for(var s=o-n,a=r-t,u=Math.min(s,a),c=this.slice(n,o),h=e.slice(t,r),l=0;lo)&&(r=o),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError(\"Attempt to write outside buffer bounds\");n||(n=\"utf8\");for(var i=!1;;)switch(n){case\"hex\":return w(this,e,t,r);case\"utf8\":case\"utf-8\":return P(this,e,t,r);case\"ascii\":return E(this,e,t,r);case\"latin1\":case\"binary\":return S(this,e,t,r);case\"base64\":return T(this,e,t,r);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return A(this,e,t,r);default:if(i)throw new TypeError(\"Unknown encoding: \"+n);n=(\"\"+n).toLowerCase(),i=!0}},i.prototype.toJSON=function(){return{type:\"Buffer\",data:Array.prototype.slice.call(this._arr||this,0)}};var Z=4096;i.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t0&&(o*=256);)n+=this[e+--t]*o;return n},i.prototype.readUInt8=function(e,t){return t||x(e,1,this.length),this[e]},i.prototype.readUInt16LE=function(e,t){return t||x(e,2,this.length),this[e]|this[e+1]<<8},i.prototype.readUInt16BE=function(e,t){return t||x(e,2,this.length),this[e]<<8|this[e+1]},i.prototype.readUInt32LE=function(e,t){return t||x(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},i.prototype.readUInt32BE=function(e,t){return t||x(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},i.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||x(e,t,this.length);for(var n=this[e],o=1,i=0;++i=o&&(n-=Math.pow(2,8*t)),n},i.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||x(e,t,this.length);for(var n=t,o=1,i=this[e+--n];n>0&&(o*=256);)i+=this[e+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*t)),i},i.prototype.readInt8=function(e,t){return t||x(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},i.prototype.readInt16LE=function(e,t){t||x(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},i.prototype.readInt16BE=function(e,t){t||x(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},i.prototype.readInt32LE=function(e,t){return t||x(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},i.prototype.readInt32BE=function(e,t){return t||x(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},i.prototype.readFloatLE=function(e,t){return t||x(e,4,this.length),X.read(this,e,!0,23,4)},i.prototype.readFloatBE=function(e,t){return t||x(e,4,this.length),X.read(this,e,!1,23,4)},i.prototype.readDoubleLE=function(e,t){return t||x(e,8,this.length),X.read(this,e,!0,52,8)},i.prototype.readDoubleBE=function(e,t){return t||x(e,8,this.length),X.read(this,e,!1,52,8)},i.prototype.writeUIntLE=function(e,t,r,n){if(e=+e,t|=0,r|=0,!n){U(this,e,t,r,Math.pow(2,8*r)-1,0)}var o=1,i=0;for(this[t]=255&e;++i=0&&(i*=256);)this[t+o]=e/i&255;return t+r},i.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||U(this,e,t,1,255,0),i.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},i.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||U(this,e,t,2,65535,0),i.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):j(this,e,t,!0),t+2},i.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||U(this,e,t,2,65535,0),i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):j(this,e,t,!1),t+2},i.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||U(this,e,t,4,4294967295,0),i.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):B(this,e,t,!0),t+4},i.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||U(this,e,t,4,4294967295,0),i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):B(this,e,t,!1),t+4},i.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var o=Math.pow(2,8*r-1);U(this,e,t,r,o-1,-o)}var i=0,s=1,a=0;for(this[t]=255&e;++i>0)-a&255;return t+r},i.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var o=Math.pow(2,8*r-1);U(this,e,t,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+r},i.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||U(this,e,t,1,127,-128),i.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},i.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||U(this,e,t,2,32767,-32768),i.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):j(this,e,t,!0),t+2},i.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||U(this,e,t,2,32767,-32768),i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):j(this,e,t,!1),t+2},i.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||U(this,e,t,4,2147483647,-2147483648),i.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):B(this,e,t,!0),t+4},i.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||U(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):B(this,e,t,!1),t+4},i.prototype.writeFloatLE=function(e,t,r){return D(this,e,t,!0,r)},i.prototype.writeFloatBE=function(e,t,r){return D(this,e,t,!1,r)},i.prototype.writeDoubleLE=function(e,t,r){return F(this,e,t,!0,r)},i.prototype.writeDoubleBE=function(e,t,r){return F(this,e,t,!1,r)},i.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError(\"sourceStart out of bounds\");if(n<0)throw new RangeError(\"sourceEnd out of bounds\");n>this.length&&(n=this.length),e.length-t=0;--o)e[o+t]=this[o+r];else if(s<1e3||!i.TYPED_ARRAY_SUPPORT)for(o=0;o>>=0,r=void 0===r?this.length:r>>>0,e||(e=0);var s;if(\"number\"==typeof e)for(s=t;s0)throw new Error(\"Invalid string. Length must be a multiple of 4\");return\"=\"===e[t-2]?2:\"=\"===e[t-1]?1:0}function o(e){return 3*e.length/4-n(e)}function i(e){var t,r,o,i,s,a=e.length;i=n(e),s=new l(3*a/4-i),r=i>0?a-4:a;var u=0;for(t=0;t>16&255,s[u++]=o>>8&255,s[u++]=255&o;return 2===i?(o=h[e.charCodeAt(t)]<<2|h[e.charCodeAt(t+1)]>>4,s[u++]=255&o):1===i&&(o=h[e.charCodeAt(t)]<<10|h[e.charCodeAt(t+1)]<<4|h[e.charCodeAt(t+2)]>>2,s[u++]=o>>8&255,s[u++]=255&o),s}function s(e){return c[e>>18&63]+c[e>>12&63]+c[e>>6&63]+c[63&e]}function a(e,t,r){for(var n,o=[],i=t;iu?u:s+16383));return 1===n?(t=e[r-1],o+=c[t>>2],o+=c[t<<4&63],o+=\"==\"):2===n&&(t=(e[r-2]<<8)+e[r-1],o+=c[t>>10],o+=c[t>>4&63],o+=c[t<<2&63],o+=\"=\"),i.push(o),i.join(\"\")}t.byteLength=o,t.toByteArray=i,t.fromByteArray=u;for(var c=[],h=[],l=\"undefined\"!=typeof Uint8Array?Uint8Array:Array,f=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",d=0,p=f.length;d>1,h=-7,l=r?o-1:0,f=r?-1:1,d=e[t+l];for(l+=f,i=d&(1<<-h)-1,d>>=-h,h+=a;h>0;i=256*i+e[t+l],l+=f,h-=8);for(s=i&(1<<-h)-1,i>>=-h,h+=n;h>0;s=256*s+e[t+l],l+=f,h-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),i-=c}return(d?-1:1)*s*Math.pow(2,i-n)},t.write=function(e,t,r,n,o,i){var s,a,u,c=8*i-o-1,h=(1<>1,f=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:i-1,p=n?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),t+=s+l>=1?f/u:f*Math.pow(2,1-l),t*u>=2&&(s++,u/=2),s+l>=h?(a=0,s=h):s+l>=1?(a=(t*u-1)*Math.pow(2,o),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,o),s=0));o>=8;e[r+d]=255&a,d+=p,a/=256,o-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,c-=8);e[r+d-p]|=128*m}},function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return\"[object Array]\"==r.call(e)}},function(e,t,r){var n,o;/*!\n * webfinger.js\n * version 2.6.6\n * http://github.com/silverbucket/webfinger.js\n *\n * Developed and Maintained by:\n * Nick Jennings 2012\n *\n * webfinger.js is released under the AGPL (see LICENSE).\n *\n * You don't have to do anything special to choose one license or the other and you don't\n * have to notify anyone which license you are using.\n * Please see the corresponding license file for details of these licenses.\n * You are free to use, modify and distribute this software, but all copyright\n * information must remain.\n *\n */\n\"undefined\"==typeof XMLHttpRequest&&(XMLHttpRequest=r(25)),function(r){function i(e){return e.toString=function(){return this.message},e}function s(e){return\"string\"==typeof e&&\"https\"===e.split(\"://\")[0]}function a(e){\"object\"!=typeof e&&(e={}),this.config={tls_only:void 0===e.tls_only||e.tls_only,webfist_fallback:void 0!==e.webfist_fallback&&e.webfist_fallback,uri_fallback:void 0!==e.uri_fallback&&e.uri_fallback,request_timeout:void 0!==e.request_timeout?e.request_timeout:1e4}}var u={\"http://webfist.org/spec/rel\":\"webfist\",\"http://webfinger.net/rel/avatar\":\"avatar\",remotestorage:\"remotestorage\",\"http://tools.ietf.org/id/draft-dejong-remotestorage\":\"remotestorage\",remoteStorage:\"remotestorage\",\"http://www.packetizer.com/rel/share\":\"share\",\"http://webfinger.net/rel/profile-page\":\"profile\",me:\"profile\",vcard:\"vcard\",blog:\"blog\",\"http://packetizer.com/rel/blog\":\"blog\",\"http://schemas.google.com/g/2010#updates-from\":\"updates\",\"https://camlistore.org/rel/server\":\"camilstore\"},c={avatar:[],remotestorage:[],blog:[],vcard:[],updates:[],share:[],profile:[],webfist:[],camlistore:[]},h=[\"webfinger\",\"host-meta\",\"host-meta.json\"];a.prototype.__fetchJRD=function(e,t,r){function n(){if(!u){if(u=!0,200===c.status)return a.__isValidJSON(c.responseText)?r(c.responseText):t(i({message:\"invalid json\",url:e,status:c.status}));if(404===c.status)return t(i({message:\"resource not found\",url:e,status:c.status}));if(c.status>=301&&c.status<=302){var n=c.getResponseHeader(\"Location\");return s(n)?o():t(i({message:\"no redirect URL found\",url:e,status:c.status}))}return t(i({message:\"error during request\",url:e,status:c.status}))}}function o(){c.onreadystatechange=function(){4===c.readyState&&n()},c.onload=function(){n()},c.ontimeout=function(){return t(i({message:\"request timed out\",url:e,status:c.status}))},c.open(\"GET\",e,!0),c.timeout=a.config.request_timeout,c.setRequestHeader(\"Accept\",\"application/jrd+json, application/json\"),c.send()}var a=this,u=!1,c=new XMLHttpRequest;return o()},a.prototype.__isValidJSON=function(e){try{JSON.parse(e)}catch(e){return!1}return!0},a.prototype.__isLocalhost=function(e){return/^localhost(\\.localdomain)?(\\:[0-9]+)?$/.test(e)},a.prototype.__processJRD=function(e,t,r,n){var o=JSON.parse(t);if(\"object\"!=typeof o||\"object\"!=typeof o.links)return r(void 0!==o.error?i({message:o.error,request:e}):i({message:\"unknown response from server\",request:e}));var s=o.links;Array.isArray(s)||(s=[]);var a={object:o,json:t,idx:{}};a.idx.properties={name:void 0},a.idx.links=JSON.parse(JSON.stringify(c)),s.map(function(e,t){if(u.hasOwnProperty(e.rel)&&a.idx.links[u[e.rel]]){var r={};Object.keys(e).map(function(t,n){r[t]=e[t]}),a.idx.links[u[e.rel]].push(r)}});var h=JSON.parse(t).properties;for(var l in h)h.hasOwnProperty(l)&&\"http://packetizer.com/ns/name\"===l&&(a.idx.properties.name=h[l]);return n(a)},a.prototype.lookup=function(e,t){function r(){var t=\"\";return e.split(\"://\")[1]||(t=\"acct:\"),u+\"://\"+s+\"/.well-known/\"+h[a]+\"?resource=\"+t+e}function n(e){if(i.config.uri_fallback&&\"webfist.org\"!==s&&a!==h.length-1)return a+=1,o();if(!i.config.tls_only&&\"https\"===u)return a=0,u=\"http\",o();if(!i.config.webfist_fallback||\"webfist.org\"===s)return t(e);a=0,u=\"http\",s=\"webfist.org\";var n=r();i.__fetchJRD(n,t,function(e){i.__processJRD(n,e,t,function(e){\"object\"==typeof e.idx.links.webfist&&\"string\"==typeof e.idx.links.webfist[0].href&&i.__fetchJRD(e.idx.links.webfist[0].href,t,function(e){i.__processJRD(n,e,t,function(e){return t(null,t)})})})})}function o(){var e=r();i.__fetchJRD(e,n,function(r){i.__processJRD(e,r,t,function(e){t(null,e)})})}if(\"string\"!=typeof e)throw new Error(\"first parameter must be a user address\");if(\"function\"!=typeof t)throw new Error(\"second parameter must be a callback\");var i=this,s=\"\";s=e.indexOf(\"://\")>-1?e.replace(/ /g,\"\").split(\"/\")[2]:e.replace(/ /g,\"\").split(\"@\")[1];var a=0,u=\"https\";return i.__isLocalhost(s)&&(u=\"http\"),setTimeout(o,0)},a.prototype.lookupLink=function(e,t,r){if(!c.hasOwnProperty(t))return r(\"unsupported rel \"+t);this.lookup(e,function(e,n){var o=n.idx.links[t];return e?r(e):0===o.length?r('no links found with rel=\"'+t+'\"'):r(null,o[0])})},n=[],void 0!==(o=function(){return a}.apply(t,n))&&(e.exports=o)}()},function(e,t){e.exports=XMLHttpRequest},function(e,t,r){\"use strict\";var n=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&\"function\"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?\"symbol\":typeof e},o=r(0),i=r(1),s=r(27),a=r(3),u={features:[],featuresDone:0,readyFired:!1,loadFeatures:function(){var e=this;this.features=[],this.featuresDone=0,this.readyFired=!1,this.featureModules={WireClient:r(7),Dropbox:r(11),GoogleDrive:r(13),Access:r(15),Discover:r(14),Authorize:r(4),BaseClient:r(5),Env:r(12)},a.cache&&o.extend(this.featureModules,{Caching:r(16),IndexedDB:r(28),LocalStorage:r(29),InMemoryStorage:r(30),Sync:r(8)}),a.disableFeatures.forEach(function(t){e.featureModules[t]&&delete e.featureModules[t]}),this._allLoaded=!1;for(var t in this.featureModules)this.loadFeature(t)},hasFeature:function(e){for(var t=this.features.length-1;t>=0;t--)if(this.features[t].name===e)return this.features[t].supported;return!1},loadFeature:function(e){var t=this,r=this.featureModules[e],o=!r._rs_supported||r._rs_supported();i(\"[RemoteStorage] [FEATURE \"+e+\"] initializing ...\"),\"object\"===(void 0===o?\"undefined\":n(o))?o.then(function(){t.featureSupported(e,!0),t.initFeature(e)},function(){t.featureSupported(e,!1)}):\"boolean\"==typeof o?(this.featureSupported(e,o),o&&this.initFeature(e)):this.featureSupported(e,!1)},initFeature:function(e){var t=this,r=this.featureModules[e],o=void 0;try{o=r._rs_init(this)}catch(t){return void this.featureFailed(e,t)}\"object\"===(void 0===o?\"undefined\":n(o))&&\"function\"==typeof o.then?o.then(function(){t.featureInitialized(e)},function(r){t.featureFailed(e,r)}):this.featureInitialized(e)},featureFailed:function(e,t){i(\"[RemoteStorage] [FEATURE \"+e+\"] initialization failed (\"+t+\")\"),this.featureDone()},featureSupported:function(e,t){i(\"[RemoteStorage] [FEATURE \"+e+\"] \"+(t?\"\":\" not\")+\" supported\"),t||this.featureDone()},featureInitialized:function(e){i(\"[RemoteStorage] [FEATURE \"+e+\"] initialized.\"),this.features.push({name:e,init:this.featureModules[e]._rs_init,supported:!0,cleanup:this.featureModules[e]._rs_cleanup}),this.featureDone()},featureDone:function(){++this.featuresDone===Object.keys(this.featureModules).length&&setTimeout(this.featuresLoaded.bind(this),0)},_setCachingModule:function(){var e=this;[\"IndexedDB\",\"LocalStorage\",\"InMemoryStorage\"].some(function(t){if(e.features.some(function(e){return e.name===t}))return e.features.local=e.featureModules[t],!0})},_fireReady:function(){try{this.readyFired||(this._emit(\"ready\"),this.readyFired=!0)}catch(e){console.error(\"'ready' failed: \",e,e.stack),this._emit(\"error\",e)}},featuresLoaded:function(){var e=this;i(\"[REMOTESTORAGE] All features loaded !\"),this._setCachingModule(),this.local=a.cache&&this.features.local&&new this.features.local,this.local&&this.remote?(this._setGPD(s,this),this._bindChange(this.local)):this.remote&&this._setGPD(this.remote,this.remote),this.remote&&(this.remote.on(\"connected\",function(){e._fireReady(),e._emit(\"connected\")}),this.remote.on(\"not-connected\",function(){e._fireReady(),e._emit(\"not-connected\")}),this.remote.connected&&(this._fireReady(),this._emit(\"connected\")),this.hasFeature(\"Authorize\")||this.remote.stopWaitingForToken()),this._collectCleanupFunctions();try{this._allLoaded=!0,this._emit(\"features-loaded\")}catch(e){o.logError(e),this._emit(\"error\",e)}this._processPending()},_collectCleanupFunctions:function(){this._cleanups=[];for(var e=0;e0?this.getNodesFromDb(t).then(function(e){for(var t in r)e[t]=r[t];return e}):Promise.resolve(r)},setNodes:function(e){for(var t in e)this.changesQueued[t]=e[t]||!1;return this.maybeFlush(),Promise.resolve()},maybeFlush:function(){0===this.putsRunning?this.flushChangesQueued():this.commitSlownessWarning||(this.commitSlownessWarning=setInterval(function(){console.warn(\"WARNING: waited more than 10 seconds for previous commit to finish\")},1e4))},flushChangesQueued:function(){this.commitSlownessWarning&&(clearInterval(this.commitSlownessWarning),this.commitSlownessWarning=null),Object.keys(this.changesQueued).length>0&&(this.changesRunning=this.changesQueued,this.changesQueued={},this.setNodesInDb(this.changesRunning).then(this.flushChangesQueued.bind(this)))},getNodesFromDb:function(e){var t=this;return new Promise(function(r,n){var o=t.db.transaction([\"nodes\"],\"readonly\"),i=o.objectStore(\"nodes\"),s={};t.getsRunning++,e.map(function(e){i.get(e).onsuccess=function(t){s[e]=t.target.result}}),o.oncomplete=function(){r(s),this.getsRunning--}.bind(t),o.onerror=o.onabort=function(){n(\"get transaction error/abort\"),this.getsRunning--}.bind(t)})},setNodesInDb:function(e){var t=this;return new Promise(function(r,n){var s=t.db.transaction([\"nodes\"],\"readwrite\"),a=s.objectStore(\"nodes\"),u=(new Date).getTime();t.putsRunning++,i(\"[IndexedDB] Starting put\",e,t.putsRunning);for(var c in e){var h=e[c];if(\"object\"===(void 0===h?\"undefined\":o(h)))try{a.put(h)}catch(e){throw i(\"[IndexedDB] Error while putting\",h,e),e}else try{a.delete(c)}catch(e){throw i(\"[IndexedDB] Error while removing\",a,h,e),e}}s.oncomplete=function(){this.putsRunning--,i(\"[IndexedDB] Finished put\",e,this.putsRunning,(new Date).getTime()-u+\"ms\"),r()}.bind(t),s.onerror=function(){this.putsRunning--,n(\"transaction error\")}.bind(t),s.onabort=function(){n(\"transaction abort\"),this.putsRunning--}.bind(t)})},reset:function(e){var t=this,r=this.db.name;this.db.close(),c.clean(this.db.name,function(){c.open(r,function(r,n){r?i(\"[IndexedDB] Error while resetting local storage\",r):t.db=n,\"function\"==typeof e&&e(self)})})},forAllNodes:function(e){var t=this;return new Promise(function(r){t.db.transaction([\"nodes\"],\"readonly\").objectStore(\"nodes\").openCursor().onsuccess=function(n){var o=n.target.result;o?(e(t.migrate(o.value)),o.continue()):r()}})},closeDB:function(){this.db.close()}},c.open=function(e,t){var r=setTimeout(function(){t(\"timeout trying to open db\")},1e4);try{var n=indexedDB.open(e,2);n.onerror=function(){i(\"[IndexedDB] Opening DB failed\",n),clearTimeout(r),t(n.error)},n.onupgradeneeded=function(e){var t=n.result;i(\"[IndexedDB] Upgrade: from \",e.oldVersion,\" to \",e.newVersion),1!==e.oldVersion&&(i(\"[IndexedDB] Creating object store: nodes\"),t.createObjectStore(\"nodes\",{keyPath:\"path\"})),i(\"[IndexedDB] Creating object store: changes\"),t.createObjectStore(\"changes\",{keyPath:\"path\"})},n.onsuccess=function(){clearTimeout(r);var o=n.result;if(!o.objectStoreNames.contains(\"nodes\")||!o.objectStoreNames.contains(\"changes\"))return i(\"[IndexedDB] Missing object store. Resetting the database.\"),void c.clean(e,function(){c.open(e,t)});t(null,n.result)}}catch(n){i(\"[IndexedDB] Failed to open database: \"+n),i(\"[IndexedDB] Resetting database and trying again.\"),clearTimeout(r),c.clean(e,function(){c.open(e,t)})}},c.clean=function(e,t){var r=indexedDB.deleteDatabase(e);r.onsuccess=function(){i(\"[IndexedDB] Done removing DB\"),t()},r.onerror=r.onabort=function(t){console.error('Failed to remove database \"'+e+'\"',t)}},c._rs_init=function(e){return new Promise(function(t,r){c.open(\"remotestorage\",function(o,i){o?r(o):(n=i,i.onerror=function(){e._emit(\"error\",o)},t())})})},c._rs_supported=function(){return new Promise(function(e,t){var r=u.getGlobalContext(),n=!1;if(\"undefined\"!=typeof navigator&&navigator.userAgent.match(/Android (2|3|4\\.[0-3])/)&&(navigator.userAgent.match(/Chrome|Firefox/)||(n=!0)),\"indexedDB\"in r&&!n)try{var o=indexedDB.open(\"rs-check\");o.onerror=function(){t()},o.onsuccess=function(){o.result.close(),indexedDB.deleteDatabase(\"rs-check\"),e()}}catch(e){t()}else t()})},c._rs_cleanup=function(e){return new Promise(function(t){e.local&&e.local.closeDB(),c.clean(\"remotestorage\",t)})},e.exports=c},function(e,t,r){\"use strict\";function n(e){return e.substr(0,c.length)===c||e.substr(0,h.length)===h}function o(e){return e.substr(0,c.length)===c}var i=r(9),s=r(1),a=r(2),u=r(0),c=\"remotestorage:cache:nodes:\",h=\"remotestorage:cache:changes:\",l=function(){i(this),s(\"[LocalStorage] Registering events\"),a(this,\"change\",\"local-events-done\")};l.prototype={getNodes:function(e){for(var t={},r=0,n=e.length;r= 0) {\n // Circular reference, don't attempt to compare this object.\n // If nothing else returns false, the objects match.\n continue;\n }\n\n seenArg = seen.slice();\n seenArg.push(b[key]);\n }\n\n if (!util.equal(a[key], b[key], seenArg)) {\n return false;\n }\n }\n }\n\n return true;\n },\n\n deepClone (obj) {\n var clone;\n if (obj === undefined) {\n return undefined;\n } else {\n clone = JSON.parse(JSON.stringify(obj));\n fixArrayBuffers(obj, clone);\n return clone;\n }\n },\n\n pathsFromRoot (path) {\n var paths = [path];\n var parts = path.replace(/\\/$/, '').split('/');\n\n while (parts.length > 1) {\n parts.pop();\n paths.push(parts.join('/')+'/');\n }\n return paths;\n },\n\n localStorageAvailable () {\n const context = util.getGlobalContext();\n\n if (!('localStorage' in context)) { return false; }\n\n try {\n context.localStorage.setItem('rs-check', 1);\n context.localStorage.removeItem('rs-check');\n return true;\n } catch(error) {\n return false;\n }\n },\n\n /**\n * Decide if data should be treated as binary based on the content\n * and content-type.\n *\n * @param {string} content - The data\n * @param {string} mimeType - The data's content-type\n *\n * @returns {boolean}\n */\n shouldBeTreatedAsBinary (content, mimeType) {\n // eslint-disable-next-line no-control-regex\n return (mimeType && mimeType.match(/charset=binary/)) || /[\\x00-\\x1F]/.test(content);\n },\n\n /**\n * Read binary data and return it as ArrayBuffer.\n *\n * @param {string} content - The data\n * @param {string} mimeType - The data's content-type\n * @returns {Promise} Resolves with an ArrayBuffer containing the data\n */\n readBinaryData (content, mimeType) {\n return new Promise((resolve) => {\n let blob;\n util.globalContext.BlobBuilder = util.globalContext.BlobBuilder || util.globalContext.WebKitBlobBuilder;\n if (typeof util.globalContext.BlobBuilder !== 'undefined') {\n const bb = new global.BlobBuilder();\n bb.append(content);\n blob = bb.getBlob(mimeType);\n } else {\n blob = new Blob([content], { type: mimeType });\n }\n\n const reader = new FileReader();\n if (typeof reader.addEventListener === 'function') {\n reader.addEventListener('loadend', function () {\n resolve(reader.result); // reader.result contains the contents of blob as a typed array\n });\n } else {\n reader.onloadend = function() {\n resolve(reader.result); // reader.result contains the contents of blob as a typed array\n };\n }\n reader.readAsArrayBuffer(blob);\n });\n }\n\n};\n\nmodule.exports = util;\n","var log = require('./log');\n\n/**\n * @interface\n */\nvar methods = {\n /**\n * Install an event handler for the given event name\n */\n addEventListener: function (eventName, handler) {\n if (typeof(eventName) !== 'string') {\n throw new Error('Argument eventName should be a string');\n }\n if (typeof(handler) !== 'function') {\n throw new Error('Argument handler should be a function');\n }\n log('[Eventhandling] Adding event listener', eventName);\n this._validateEvent(eventName);\n this._handlers[eventName].push(handler);\n },\n\n /**\n * Remove a previously installed event handler\n */\n removeEventListener: function (eventName, handler) {\n this._validateEvent(eventName);\n var hl = this._handlers[eventName].length;\n for (var i=0;i 0) {\n params['state'] = stateValue;\n }\n } else {\n params[decodeURIComponent(kv[0])] = decodeURIComponent(kv[1]);\n }\n\n return params;\n }, {});\n}\n\n\nvar Authorize = function (remoteStorage, authURL, scope, redirectUri, clientId) {\n log('[Authorize] authURL = ', authURL, 'scope = ', scope, 'redirectUri = ', redirectUri, 'clientId = ', clientId);\n\n // keep track of the discovery data during redirect if we can't save it in localStorage\n if (!util.localStorageAvailable() &&\n remoteStorage.backend === 'remotestorage') {\n redirectUri += redirectUri.indexOf('#') > 0 ? '&' : '#';\n\n var discoveryData = {\n userAddress: remoteStorage.remote.userAddress,\n href: remoteStorage.remote.href,\n storageApi: remoteStorage.remote.storageApi,\n properties: remoteStorage.remote.properties\n };\n\n redirectUri += 'rsDiscovery=' + btoa(JSON.stringify(discoveryData));\n }\n\n var url = authURL, hashPos = redirectUri.indexOf('#');\n url += authURL.indexOf('?') > 0 ? '&' : '?';\n url += 'redirect_uri=' + encodeURIComponent(redirectUri.replace(/#.*$/, ''));\n url += '&scope=' + encodeURIComponent(scope);\n url += '&client_id=' + encodeURIComponent(clientId);\n if (hashPos !== - 1 && hashPos+1 !== redirectUri.length) {\n url += '&state=' + encodeURIComponent(redirectUri.substring(hashPos+1));\n }\n url += '&response_type=token';\n\n if (util.globalContext.cordova) {\n return Authorize.openWindow(url, redirectUri, 'location=yes,clearsessioncache=yes,clearcache=yes')\n .then(function(authResult) {\n remoteStorage.remote.configure({\n token: authResult.access_token\n });\n });\n }\n\n Authorize.setLocation(url);\n};\n\nAuthorize.IMPLIED_FAKE_TOKEN = false;\n\nAuthorize.Unauthorized = function(message, options = {}) {\n this.name = 'Unauthorized';\n\n if (typeof message === 'undefined') {\n this.message = 'App authorization expired or revoked.';\n } else {\n this.message = message;\n }\n\n if (typeof options.code !== 'undefined') {\n this.code = options.code;\n }\n\n this.stack = (new Error()).stack;\n};\nAuthorize.Unauthorized.prototype = Object.create(Error.prototype);\nAuthorize.Unauthorized.prototype.constructor = Authorize.Unauthorized;\n\n/**\n * Get current document location\n *\n * Override this method if access to document.location is forbidden\n */\nAuthorize.getLocation = function () {\n return document.location;\n};\n\n/**\n * Set current document location\n *\n * Override this method if access to document.location is forbidden\n */\nAuthorize.setLocation = function (location) {\n if (typeof location === 'string') {\n document.location.href = location;\n } else if (typeof location === 'object') {\n document.location = location;\n } else {\n throw \"Invalid location \" + location;\n }\n};\n\n/**\n * Open new InAppBrowser window for OAuth in Cordova\n */\nAuthorize.openWindow = function (url, redirectUri, options) {\n return new Promise( (resolve, reject) => {\n\n var newWindow = open(url, '_blank', options);\n\n if (!newWindow || newWindow.closed) {\n return reject('Authorization popup was blocked');\n }\n\n var handleExit = function () {\n return reject('Authorization was canceled');\n };\n\n var handleLoadstart = function (event) {\n if (event.url.indexOf(redirectUri) !== 0) {\n return;\n }\n\n newWindow.removeEventListener('exit', handleExit);\n newWindow.close();\n\n var authResult = extractParams(event.url);\n\n if (!authResult) {\n return reject('Authorization error');\n }\n\n return resolve(authResult);\n };\n\n newWindow.addEventListener('loadstart', handleLoadstart);\n newWindow.addEventListener('exit', handleExit);\n\n });\n};\n\n\nAuthorize._rs_supported = function () {\n return typeof(document) !== 'undefined';\n};\n\nvar onFeaturesLoaded;\nAuthorize._rs_init = function (remoteStorage) {\n\n onFeaturesLoaded = function () {\n var authParamsUsed = false;\n if (params) {\n if (params.error) {\n if (params.error === 'access_denied') {\n throw new Authorize.Unauthorized('Authorization failed: access denied', { code: 'access_denied' });\n } else {\n throw new Authorize.Unauthorized(`Authorization failed: ${params.error}`);\n }\n }\n\n // rsDiscovery came with the redirect, because it couldn't be\n // saved in localStorage\n if (params.rsDiscovery) {\n remoteStorage.remote.configure(params.rsDiscovery);\n }\n\n if (params.access_token) {\n remoteStorage.remote.configure({\n token: params.access_token\n });\n authParamsUsed = true;\n }\n if (params.remotestorage) {\n remoteStorage.connect(params.remotestorage);\n authParamsUsed = true;\n }\n if (params.state) {\n location = Authorize.getLocation();\n Authorize.setLocation(location.href.split('#')[0]+'#'+params.state);\n }\n }\n if (!authParamsUsed) {\n remoteStorage.remote.stopWaitingForToken();\n }\n };\n var params = extractParams(),\n location;\n if (params) {\n location = Authorize.getLocation();\n location.hash = '';\n }\n remoteStorage.on('features-loaded', onFeaturesLoaded);\n};\n\nAuthorize._rs_cleanup = function (remoteStorage) {\n remoteStorage.removeEventListener('features-loaded', onFeaturesLoaded);\n};\n\nmodule.exports = Authorize;\n","const eventHandling = require('./eventhandling');\nconst util = require('./util');\nconst config = require('./config');\nconst tv4 = require('tv4');\nconst Types = require('./types');\n\nconst SchemaNotFound = Types.SchemaNotFound;\n\n/**\n * Provides a high-level interface to access data below a given root path.\n */\nvar BaseClient = function (storage, base) {\n if (base[base.length - 1] !== '/') {\n throw \"Not a folder: \" + base;\n }\n\n if (base === '/') {\n // allow absolute and relative paths for the root scope.\n this.makePath = function (path) {\n return (path[0] === '/' ? '' : '/') + path;\n };\n }\n\n /**\n * The instance this operates on.\n */\n this.storage = storage;\n\n /**\n * Base path, which this operates on.\n *\n * For the module's privateClient this would be //, for the\n * corresponding publicClient /public//.\n */\n this.base = base;\n\n /**\n * TODO: document what this does exactly\n */\n var parts = this.base.split('/');\n if (parts.length > 2) {\n this.moduleName = parts[1];\n } else {\n this.moduleName = 'root';\n }\n\n eventHandling(this, 'change');\n this.on = this.on.bind(this);\n storage.onChange(this.base, this._fireChange.bind(this));\n};\n\nBaseClient.Types = Types;\n\nBaseClient.prototype = {\n\n /**\n * Instantiate a new client, scoped to a subpath of the current client's\n * path.\n *\n * @param {string} path - The path to scope the new client to.\n *\n * @returns {BaseClient} A new client operating on a subpath of the current\n * base path.\n */\n scope: function (path) {\n return new BaseClient(this.storage, this.makePath(path));\n },\n\n /**\n * Get a list of child nodes below a given path.\n *\n * @param {string} path - The path to query. It MUST end with a forward slash.\n * @param {number} maxAge - (optional) Either ``false`` or the maximum age of\n * cached listing in milliseconds. See :ref:`max-age`.\n *\n * @returns {Promise} A promise for an object representing child nodes\n */\n getListing: function (path, maxAge) {\n if (typeof(path) !== 'string') {\n path = '';\n } else if (path.length > 0 && path[path.length - 1] !== '/') {\n return Promise.reject(\"Not a folder: \" + path);\n }\n return this.storage.get(this.makePath(path), maxAge).then(\n function (r) {\n return (r.statusCode === 404) ? {} : r.body;\n }\n );\n },\n\n /**\n * Get all objects directly below a given path.\n *\n * @param {string} path - Path to the folder. Must end in a forward slash.\n * @param {number} maxAge - (optional) Either ``false`` or the maximum age of\n * cached objects in milliseconds. See :ref:`max-age`.\n *\n * @returns {Promise} A promise for an object\n */\n getAll: function (path, maxAge) {\n if (typeof(path) !== 'string') {\n path = '';\n } else if (path.length > 0 && path[path.length - 1] !== '/') {\n return Promise.reject(\"Not a folder: \" + path);\n }\n\n return this.storage.get(this.makePath(path), maxAge).then(function (r) {\n if (r.statusCode === 404) { return {}; }\n if (typeof(r.body) === 'object') {\n var keys = Object.keys(r.body);\n if (keys.length === 0) {\n // treat this like 404. it probably means a folder listing that\n // has changes that haven't been pushed out yet.\n return {};\n }\n\n var calls = keys.map(function (key) {\n return this.storage.get(this.makePath(path + key), maxAge)\n .then(function (o) {\n if (typeof(o.body) === 'string') {\n try {\n o.body = JSON.parse(o.body);\n } catch (e) {\n // empty\n }\n }\n if (typeof(o.body) === 'object') {\n r.body[key] = o.body;\n }\n });\n }.bind(this));\n return Promise.all(calls).then(function () {\n return r.body;\n });\n }\n }.bind(this));\n },\n\n /**\n * Get the file at the given path. A file is raw data, as opposed to\n * a JSON object (use :func:`getObject` for that).\n *\n * @param {string} path - Relative path from the module root (without leading\n * slash).\n * @param {number} maxAge - (optional) Either ``false`` or the maximum age of\n * the cached file in milliseconds. See :ref:`max-age`.\n *\n * @returns {Promise} A promise for an object\n */\n getFile: function (path, maxAge) {\n if (typeof(path) !== 'string') {\n return Promise.reject('Argument \\'path\\' of baseClient.getFile must be a string');\n }\n return this.storage.get(this.makePath(path), maxAge).then(function (r) {\n return {\n data: r.body,\n contentType: r.contentType,\n revision: r.revision // (this is new)\n };\n });\n },\n\n /**\n * Store raw data at a given path.\n *\n * @param {string} mimeType - MIME media type of the data being stored\n * @param {string} path - Path relative to the module root\n * @param {string|ArrayBuffer|ArrayBufferView} body - Raw data to store\n *\n * @returns {Promise} A promise for an object\n */\n storeFile: function (mimeType, path, body) {\n if (typeof(mimeType) !== 'string') {\n return Promise.reject('Argument \\'mimeType\\' of baseClient.storeFile must be a string');\n }\n if (typeof(path) !== 'string') {\n return Promise.reject('Argument \\'path\\' of baseClient.storeFile must be a string');\n }\n if (typeof(body) !== 'string' && typeof(body) !== 'object') {\n return Promise.reject('Argument \\'body\\' of baseClient.storeFile must be a string, ArrayBuffer, or ArrayBufferView');\n }\n if (!this.storage.access.checkPathPermission(this.makePath(path), 'rw')) {\n console.warn('WARNING: Editing a document to which only read access (\\'r\\') was claimed');\n }\n\n return this.storage.put(this.makePath(path), body, mimeType).then(function (r) {\n if (r.statusCode === 200 || r.statusCode === 201) {\n return r.revision;\n } else {\n return Promise.reject(\"Request (PUT \" + this.makePath(path) + \") failed with status: \" + r.statusCode);\n }\n }.bind(this));\n },\n\n /**\n * Get a JSON object from the given path.\n *\n * @param {string} path - Relative path from the module root (without leading\n * slash).\n * @param {number} maxAge - (optional) Either ``false`` or the maximum age of\n * cached object in milliseconds. See :ref:`max-age`.\n *\n * @returns {Promise} A promise, which resolves with the requested object (or ``null``\n * if non-existent)\n */\n getObject: function (path, maxAge) {\n if (typeof(path) !== 'string') {\n return Promise.reject('Argument \\'path\\' of baseClient.getObject must be a string');\n }\n return this.storage.get(this.makePath(path), maxAge).then(function (r) {\n if (typeof(r.body) === 'object') { // will be the case for documents stored with rs.js <= 0.10.0-beta2\n return r.body;\n } else if (typeof(r.body) === 'string') {\n try {\n return JSON.parse(r.body);\n } catch (e) {\n throw \"Not valid JSON: \" + this.makePath(path);\n }\n } else if (typeof(r.body) !== 'undefined' && r.statusCode === 200) {\n return Promise.reject(\"Not an object: \" + this.makePath(path));\n }\n }.bind(this));\n },\n\n /**\n * Store object at given path. Triggers synchronization.\n *\n * See ``declareType()`` and :doc:`data types `\n * for an explanation of types\n *\n * @param {string} type - Unique type of this object within this module.\n * @param {string} path - Path relative to the module root.\n * @param {object} object - A JavaScript object to be stored at the given\n * path. Must be serializable as JSON.\n *\n * @returns {Promise} Resolves with revision on success. Rejects with\n * a ValidationError, if validations fail.\n */\n storeObject: function (typeAlias, path, object) {\n if (typeof(typeAlias) !== 'string') {\n return Promise.reject('Argument \\'typeAlias\\' of baseClient.storeObject must be a string');\n }\n if (typeof(path) !== 'string') {\n return Promise.reject('Argument \\'path\\' of baseClient.storeObject must be a string');\n }\n if (typeof(object) !== 'object') {\n return Promise.reject('Argument \\'object\\' of baseClient.storeObject must be an object');\n }\n\n this._attachType(object, typeAlias);\n\n try {\n var validationResult = this.validate(object);\n if (! validationResult.valid) {\n return Promise.reject(validationResult);\n }\n } catch(exc) {\n return Promise.reject(exc);\n }\n\n return this.storage.put(this.makePath(path), JSON.stringify(object), 'application/json; charset=UTF-8').then(function (r) {\n if (r.statusCode === 200 || r.statusCode === 201) {\n return r.revision;\n } else {\n return Promise.reject(\"Request (PUT \" + this.makePath(path) + \") failed with status: \" + r.statusCode);\n }\n }.bind(this));\n },\n\n /**\n * Remove node at given path from storage. Triggers synchronization.\n *\n * @param {string} path - Path relative to the module root.\n * @returns {Promise}\n */\n remove: function (path) {\n if (typeof(path) !== 'string') {\n return Promise.reject('Argument \\'path\\' of baseClient.remove must be a string');\n }\n if (!this.storage.access.checkPathPermission(this.makePath(path), 'rw')) {\n console.warn('WARNING: Removing a document to which only read access (\\'r\\') was claimed');\n }\n\n return this.storage.delete(this.makePath(path));\n },\n\n /**\n * Retrieve full URL of a document. Useful for example for sharing the public\n * URL of an item in the ``/public`` folder.\n *\n * @param {string} path - Path relative to the module root.\n * @returns {string} The full URL of the item, including the storage origin\n */\n getItemURL: function (path) {\n if (typeof(path) !== 'string') {\n throw 'Argument \\'path\\' of baseClient.getItemURL must be a string';\n }\n if (this.storage.connected) {\n path = this._cleanPath( this.makePath(path) );\n return this.storage.remote.href + path;\n } else {\n return undefined;\n }\n },\n\n /**\n * Set caching strategy for a given path and its children.\n *\n * See :ref:`caching-strategies` for a detailed description of the available\n * strategies.\n *\n * @param {string} path - Path to cache\n * @param {string} strategy - Caching strategy. One of 'ALL', 'SEEN', or\n * 'FLUSH'. Defaults to 'ALL'.\n *\n * @returns {BaseClient} The same instance this is called on to allow for method chaining\n */\n cache: function (path, strategy) {\n if (typeof path !== 'string') {\n throw 'Argument \\'path\\' of baseClient.cache must be a string';\n }\n\n if (strategy === undefined) {\n strategy = 'ALL';\n } else if (typeof strategy !== 'string') {\n throw 'Argument \\'strategy\\' of baseClient.cache must be a string or undefined';\n }\n if (strategy !== 'FLUSH' &&\n strategy !== 'SEEN' &&\n strategy !== 'ALL') {\n throw 'Argument \\'strategy\\' of baseclient.cache must be one of '\n + '[\"FLUSH\", \"SEEN\", \"ALL\"]';\n }\n this.storage.caching.set(this.makePath(path), strategy);\n\n return this;\n },\n\n /**\n * TODO: document\n *\n * @param {string} path\n */\n flush: function (path) {\n return this.storage.local.flush(path);\n },\n\n /**\n * Declare a remoteStorage object type using a JSON schema.\n *\n * See :doc:`Defining data types ` for more info.\n *\n * @param {string} alias - A type alias/shortname\n * @param {uri} uri - (optional) JSON-LD URI of the schema. Automatically generated if none given\n * @param {object} schema - A JSON Schema object describing the object type\n **/\n declareType: function(alias, uri, schema) {\n if (! schema) {\n schema = uri;\n uri = this._defaultTypeURI(alias);\n }\n BaseClient.Types.declare(this.moduleName, alias, uri, schema);\n },\n\n /**\n * Validate an object against the associated schema.\n *\n * @param {Object} object - JS object to validate. Must have a ``@context`` property.\n *\n * @returns {Object} An object containing information about validation errors\n **/\n validate: function(object) {\n var schema = BaseClient.Types.getSchema(object['@context']);\n if (schema) {\n return tv4.validateResult(object, schema);\n } else {\n throw new SchemaNotFound(object['@context']);\n }\n },\n\n /**\n * TODO document\n *\n * @private\n */\n schemas: {\n configurable: true,\n get: function() {\n return BaseClient.Types.inScope(this.moduleName);\n }\n },\n\n /**\n * The default JSON-LD @context URL for RS types/objects/documents\n *\n * @private\n */\n _defaultTypeURI: function(alias) {\n return 'http://remotestorage.io/spec/modules/' + encodeURIComponent(this.moduleName) + '/' + encodeURIComponent(alias);\n },\n\n /**\n * Attaches the JSON-LD @content to an object\n *\n * @private\n */\n _attachType: function(object, alias) {\n object['@context'] = BaseClient.Types.resolveAlias(this.moduleName + '/' + alias) || this._defaultTypeURI(alias);\n },\n\n /**\n * TODO: document\n *\n * @private\n */\n makePath: function (path) {\n return this.base + (path || '');\n },\n\n /**\n * TODO: document\n *\n * @private\n */\n _fireChange: function (event) {\n if (config.changeEvents[event.origin]) {\n ['new', 'old', 'lastCommon'].forEach(function (fieldNamePrefix) {\n if ((!event[fieldNamePrefix+'ContentType'])\n || (/^application\\/(.*)json(.*)/.exec(event[fieldNamePrefix+'ContentType']))) {\n if (typeof(event[fieldNamePrefix+'Value']) === 'string') {\n try {\n event[fieldNamePrefix+'Value'] = JSON.parse(event[fieldNamePrefix+'Value']);\n } catch(e) {\n // empty\n }\n }\n }\n });\n this._emit('change', event);\n }\n },\n\n /**\n * TODO: document\n *\n * @private\n */\n _cleanPath: util.cleanPath\n\n};\n\nBaseClient._rs_init = function () {};\n\nmodule.exports = BaseClient;\n","const util = require('./util');\nconst config = require('./config');\nconst log = require('./log');\n\n/**\n * This module defines functions that are mixed into remoteStorage.local when\n * it is instantiated (currently one of indexeddb.js, localstorage.js, or\n * inmemorystorage.js).\n *\n * All remoteStorage.local implementations should therefore implement\n * this.getNodes, this.setNodes, and this.forAllNodes. The rest is blended in\n * here to create a GPD (get/put/delete) interface which the BaseClient can\n * talk to.\n *\n * @interface\n *\n */\n\nconst isFolder = util.isFolder;\nconst isDocument = util.isDocument;\nconst deepClone = util.deepClone;\n\nfunction getLatest(node) {\n if (typeof(node) !== 'object' || typeof(node.path) !== 'string') {\n return;\n }\n if (isFolder(node.path)) {\n if (node.local && node.local.itemsMap) {\n return node.local;\n }\n if (node.common && node.common.itemsMap) {\n return node.common;\n }\n } else {\n if (node.local && node.local.body && node.local.contentType) {\n return node.local;\n }\n if (node.common && node.common.body && node.common.contentType) {\n return node.common;\n }\n // Migration code! Once all apps use at least this version of the lib, we\n // can publish clean-up code that migrates over any old-format data, and\n // stop supporting it. For now, new apps will support data in both\n // formats, thanks to this:\n if (node.body && node.contentType) {\n return {\n body: node.body,\n contentType: node.contentType\n };\n }\n }\n}\n\nfunction isOutdated(nodes, maxAge) {\n var path;\n for (path in nodes) {\n if (nodes[path] && nodes[path].remote) {\n return true;\n }\n var nodeVersion = getLatest(nodes[path]);\n if (nodeVersion && nodeVersion.timestamp && (new Date().getTime()) - nodeVersion.timestamp <= maxAge) {\n return false;\n } else if (!nodeVersion) {\n return true;\n }\n }\n return true;\n}\n\nvar pathsFromRoot = util.pathsFromRoot;\n\nfunction makeNode(path) {\n var node = { path: path, common: { } };\n\n if (isFolder(path)) {\n node.common.itemsMap = {};\n }\n return node;\n}\n\nfunction updateFolderNodeWithItemName(node, itemName) {\n if (!node.common) {\n node.common = {\n itemsMap: {}\n };\n }\n if (!node.common.itemsMap) {\n node.common.itemsMap = {};\n }\n if (!node.local) {\n node.local = deepClone(node.common);\n }\n if (!node.local.itemsMap) {\n node.local.itemsMap = node.common.itemsMap;\n }\n node.local.itemsMap[itemName] = true;\n\n return node;\n}\n\nvar methods = {\n\n // TODO: improve our code structure so that this function\n // could call sync.queueGetRequest directly instead of needing\n // this hacky third parameter as a callback\n get: function (path, maxAge, queueGetRequest) {\n var self = this;\n if (typeof(maxAge) === 'number') {\n return self.getNodes(pathsFromRoot(path))\n .then(function (objs) {\n var node = getLatest(objs[path]);\n if (isOutdated(objs, maxAge)) {\n return queueGetRequest(path);\n } else if (node) {\n return {statusCode: 200, body: node.body || node.itemsMap, contentType: node.contentType};\n } else {\n return {statusCode: 404};\n }\n });\n } else {\n return self.getNodes([path])\n .then(function (objs) {\n var node = getLatest(objs[path]);\n if (node) {\n if (isFolder(path)) {\n for (var i in node.itemsMap) {\n // the hasOwnProperty check here is only because our jshint settings require it:\n if (node.itemsMap.hasOwnProperty(i) && node.itemsMap[i] === false) {\n delete node.itemsMap[i];\n }\n }\n }\n return {statusCode: 200, body: node.body || node.itemsMap, contentType: node.contentType};\n } else {\n return {statusCode: 404};\n }\n });\n }\n },\n\n put: function (path, body, contentType) {\n const paths = pathsFromRoot(path);\n\n function _processNodes(nodePaths, nodes) {\n try {\n for (var i = 0, len = nodePaths.length; i < len; i++) {\n const nodePath = nodePaths[i];\n let node = nodes[nodePath];\n let previous;\n\n if (!node) {\n nodes[nodePath] = node = makeNode(nodePath);\n }\n\n // Document\n if (i === 0) {\n previous = getLatest(node);\n node.local = {\n body: body,\n contentType: contentType,\n previousBody: (previous ? previous.body : undefined),\n previousContentType: (previous ? previous.contentType : undefined),\n };\n }\n // Folder\n else {\n var itemName = nodePaths[i-1].substring(nodePath.length);\n node = updateFolderNodeWithItemName(node, itemName);\n }\n }\n return nodes;\n } catch (e) {\n log('[Cachinglayer] Error during PUT', nodes, e);\n throw e;\n }\n }\n\n return this._updateNodes(paths, _processNodes);\n },\n\n delete: function (path) {\n const paths = pathsFromRoot(path);\n\n return this._updateNodes(paths, function (nodePaths, nodes) {\n for (var i = 0, len = nodePaths.length; i < len; i++) {\n const nodePath = nodePaths[i];\n const node = nodes[nodePath];\n let previous;\n\n if (!node) {\n console.error('Cannot delete non-existing node ' + nodePath);\n continue;\n }\n\n if (i === 0) {\n // Document\n previous = getLatest(node);\n node.local = {\n body: false,\n previousBody: (previous ? previous.body : undefined),\n previousContentType: (previous ? previous.contentType : undefined),\n };\n } else {\n // Folder\n if (!node.local) {\n node.local = deepClone(node.common);\n }\n var itemName = nodePaths[i-1].substring(nodePath.length);\n delete node.local.itemsMap[itemName];\n\n if (Object.getOwnPropertyNames(node.local.itemsMap).length > 0) {\n // This folder still contains other items, don't remove any further ancestors\n break;\n }\n }\n }\n return nodes;\n });\n },\n\n flush: function (path) {\n var self = this;\n return self._getAllDescendentPaths(path).then(function (paths) {\n return self.getNodes(paths);\n }).then(function (nodes) {\n for (var nodePath in nodes) {\n const node = nodes[nodePath];\n\n if (node && node.common && node.local) {\n self._emitChange({\n path: node.path,\n origin: 'local',\n oldValue: (node.local.body === false ? undefined : node.local.body),\n newValue: (node.common.body === false ? undefined : node.common.body)\n });\n }\n nodes[nodePath] = undefined;\n }\n\n return self.setNodes(nodes);\n });\n },\n\n _emitChange: function (obj) {\n if (config.changeEvents[obj.origin]) {\n this._emit('change', obj);\n }\n },\n\n fireInitial: function () {\n if (!config.changeEvents.local) {\n return;\n }\n var self = this;\n self.forAllNodes(function (node) {\n var latest;\n if (isDocument(node.path)) {\n latest = getLatest(node);\n if (latest) {\n self._emitChange({\n path: node.path,\n origin: 'local',\n oldValue: undefined,\n oldContentType: undefined,\n newValue: latest.body,\n newContentType: latest.contentType\n });\n }\n }\n }).then(function () {\n self._emit('local-events-done');\n });\n },\n\n onDiff: function (diffHandler) {\n this.diffHandler = diffHandler;\n },\n\n migrate: function (node) {\n if (typeof(node) === 'object' && !node.common) {\n node.common = {};\n if (typeof(node.path) === 'string') {\n if (node.path.substr(-1) === '/' && typeof(node.body) === 'object') {\n node.common.itemsMap = node.body;\n }\n } else {\n //save legacy content of document node as local version\n if (!node.local) {\n node.local = {};\n }\n node.local.body = node.body;\n node.local.contentType = node.contentType;\n }\n }\n return node;\n },\n\n // FIXME\n // this process of updating nodes needs to be heavily documented first, then\n // refactored. Right now it's almost impossible to refactor as there's no\n // explanation of why things are implemented certain ways or what the goal(s)\n // of the behavior are. -slvrbckt (+1 -les)\n _updateNodesRunning: false,\n _updateNodesQueued: [],\n _updateNodes: function (paths, _processNodes) {\n return new Promise(function(resolve, reject) {\n this._doUpdateNodes(paths, _processNodes, {\n resolve: resolve,\n reject: reject\n });\n }.bind(this));\n },\n _doUpdateNodes: function (paths, _processNodes, promise) {\n var self = this;\n\n if (self._updateNodesRunning) {\n self._updateNodesQueued.push({\n paths: paths,\n cb: _processNodes,\n promise: promise\n });\n return;\n } else {\n self._updateNodesRunning = true;\n }\n\n self.getNodes(paths).then(function (nodes) {\n var existingNodes = deepClone(nodes);\n var changeEvents = [];\n var node;\n var equal = util.equal;\n\n nodes = _processNodes(paths, nodes);\n\n for (var path in nodes) {\n node = nodes[path];\n if (equal(node, existingNodes[path])) {\n delete nodes[path];\n }\n else if (isDocument(path)) {\n if (\n !equal(node.local.body, node.local.previousBody) ||\n node.local.contentType !== node.local.previousContentType\n ) {\n changeEvents.push({\n path: path,\n origin: 'window',\n oldValue: node.local.previousBody,\n newValue: node.local.body === false ? undefined : node.local.body,\n oldContentType: node.local.previousContentType,\n newContentType: node.local.contentType\n });\n }\n delete node.local.previousBody;\n delete node.local.previousContentType;\n }\n }\n\n self.setNodes(nodes).then(function () {\n self._emitChangeEvents(changeEvents);\n promise.resolve({statusCode: 200});\n });\n }).then(function () {\n return Promise.resolve();\n }, function (err) {\n promise.reject(err);\n }).then(function () {\n self._updateNodesRunning = false;\n var nextJob = self._updateNodesQueued.shift();\n if (nextJob) {\n self._doUpdateNodes(nextJob.paths, nextJob.cb, nextJob.promise);\n }\n });\n },\n\n _emitChangeEvents: function (events) {\n for (var i = 0, len = events.length; i < len; i++) {\n this._emitChange(events[i]);\n if (this.diffHandler) {\n this.diffHandler(events[i].path);\n }\n }\n },\n\n _getAllDescendentPaths: function (path) {\n var self = this;\n if (isFolder(path)) {\n return self.getNodes([path]).then(function (nodes) {\n var allPaths = [path];\n var latest = getLatest(nodes[path]);\n\n var itemNames = Object.keys(latest.itemsMap);\n var calls = itemNames.map(function (itemName) {\n return self._getAllDescendentPaths(path+itemName).then(function (paths) {\n for (var i = 0, len = paths.length; i < len; i++) {\n allPaths.push(paths[i]);\n }\n });\n });\n return Promise.all(calls).then(function () {\n return allPaths;\n });\n });\n } else {\n return Promise.resolve([path]);\n }\n },\n\n _getInternals: function () {\n return {\n getLatest: getLatest,\n makeNode: makeNode,\n isOutdated: isOutdated\n };\n }\n};\n\n/**\n * Mixes common caching layer functionality into an object.\n * @param {Object} object - the object to be extended\n *\n * @example\n * var MyConstructor = function () {\n * cachingLayer(this);\n * };\n */\nvar cachingLayer = function (object) {\n for (var key in methods) {\n object[key] = methods[key];\n }\n};\n\nmodule.exports = cachingLayer;\n","const util = require('./util');\nconst Env = require('./env');\nconst eventHandling = require('./eventhandling');\nconst log = require('./log');\nconst Authorize = require('./authorize');\nconst config = require('./config');\n\nconst isFolder = util.isFolder;\nconst isDocument = util.isDocument;\nconst equal = util.equal;\nconst deepClone = util.deepClone;\nconst pathsFromRoot = util.pathsFromRoot;\n\nfunction taskFor(action, path, promise) {\n return {\n action: action,\n path: path,\n promise: promise\n };\n}\n\nfunction nodeChanged(node, etag) {\n return node.common.revision !== etag &&\n (!node.remote || node.remote.revision !== etag);\n}\n\nfunction isStaleChild(node) {\n return node.remote && node.remote.revision && !node.remote.itemsMap && !node.remote.body;\n}\n\nfunction hasCommonRevision(node) {\n return node.common && node.common.revision;\n}\n\nfunction hasNoRemoteChanges(node) {\n if (node.remote && node.remote.revision &&\n node.remote.revision !== node.common.revision) {\n return false;\n }\n return (node.common.body === undefined && node.remote.body === false) ||\n (node.remote.body === node.common.body &&\n node.remote.contentType === node.common.contentType);\n}\n\nfunction mergeMutualDeletion(node) {\n if (node.remote && node.remote.body === false &&\n node.local && node.local.body === false) {\n delete node.local;\n }\n return node;\n}\n\nfunction handleVisibility() {\n let rs = this;\n\n function handleVisibilityChange(fg) {\n var oldValue, newValue;\n oldValue = rs.getCurrentSyncInterval();\n config.isBackground = !fg;\n newValue = rs.getCurrentSyncInterval();\n rs._emit('sync-interval-change', {oldValue: oldValue, newValue: newValue});\n }\n\n Env.on(\"background\", function () {\n handleVisibilityChange(false);\n });\n\n Env.on(\"foreground\", function () {\n handleVisibilityChange(true);\n });\n}\n\n\n/**\n * Class: RemoteStorage.Sync\n *\n * What this class does is basically six things:\n * - retrieving the remote version of relevant documents and folders\n * - add all local and remote documents together into one tree\n * - push local documents out if they don't exist remotely\n * - push local changes out to remote documents (conditionally, to\n * avoid race conditions where both have changed)\n * - adopt the local version of a document to its remote version if\n * both exist and they differ\n * - delete the local version of a document if it was deleted remotely\n * - if any get requests were waiting for remote data, resolve them once\n * this data comes in.\n *\n * It does this using requests to documents, and to folders. Whenever a\n * folder GET comes in, it gives information about all the documents it\n * contains (this is the `markChildren` function).\n **/\nconst Sync = function (remoteStorage, setLocal, setRemote, setAccess, setCaching) {\n this.remoteStorage = remoteStorage;\n this.local = setLocal;\n this.local.onDiff(function (path) {\n this.addTask(path);\n this.doTasks();\n }.bind(this));\n this.remote = setRemote;\n this.access = setAccess;\n this.caching = setCaching;\n this._tasks = {};\n this._running = {};\n this._timeStarted = {};\n eventHandling(this, 'done', 'req-done');\n this.caching.onActivate(function (path) {\n this.addTask(path);\n this.doTasks();\n }.bind(this));\n};\n\nSync.prototype = {\n\n now: function () {\n return new Date().getTime();\n },\n\n queueGetRequest: function (path) {\n return new Promise((resolve, reject) => {\n if (!this.remote.connected) {\n reject('cannot fulfill maxAge requirement - remote is not connected');\n } else if (!this.remote.online) {\n reject('cannot fulfill maxAge requirement - remote is not online');\n } else {\n this.addTask(path, function () {\n this.local.get(path).then(function (r) {\n return resolve(r);\n });\n }.bind(this));\n\n this.doTasks();\n }\n });\n },\n\n corruptServerItemsMap: function (itemsMap, force02) {\n if ((typeof(itemsMap) !== 'object') || (Array.isArray(itemsMap))) {\n return true;\n }\n\n for (var itemName in itemsMap) {\n var item = itemsMap[itemName];\n\n if (typeof(item) !== 'object') {\n return true;\n }\n if (typeof(item.ETag) !== 'string') {\n return true;\n }\n if (isFolder(itemName)) {\n if (itemName.substring(0, itemName.length-1).indexOf('/') !== -1) {\n return true;\n }\n } else {\n if (itemName.indexOf('/') !== -1) {\n return true;\n }\n if (force02) {\n if (typeof(item['Content-Type']) !== 'string') {\n return true;\n }\n if (typeof(item['Content-Length']) !== 'number') {\n return true;\n }\n }\n }\n }\n\n return false;\n },\n\n corruptItemsMap: function (itemsMap) {\n if ((typeof(itemsMap) !== 'object') || (Array.isArray(itemsMap))) {\n return true;\n }\n\n for (var itemName in itemsMap) {\n if (typeof(itemsMap[itemName]) !== 'boolean') {\n return true;\n }\n }\n\n return false;\n },\n\n corruptRevision: function (rev) {\n return ((typeof(rev) !== 'object') ||\n (Array.isArray(rev)) ||\n (rev.revision && typeof(rev.revision) !== 'string') ||\n (rev.body && typeof(rev.body) !== 'string' && typeof(rev.body) !== 'object') ||\n (rev.contentType && typeof(rev.contentType) !== 'string') ||\n (rev.contentLength && typeof(rev.contentLength) !== 'number') ||\n (rev.timestamp && typeof(rev.timestamp) !== 'number') ||\n (rev.itemsMap && this.corruptItemsMap(rev.itemsMap)));\n },\n\n isCorrupt: function (node) {\n return ((typeof(node) !== 'object') ||\n (Array.isArray(node)) ||\n (typeof(node.path) !== 'string') ||\n (this.corruptRevision(node.common)) ||\n (node.local && this.corruptRevision(node.local)) ||\n (node.remote && this.corruptRevision(node.remote)) ||\n (node.push && this.corruptRevision(node.push)));\n },\n\n hasTasks: function () {\n return Object.getOwnPropertyNames(this._tasks).length > 0;\n },\n\n collectDiffTasks: function () {\n var num = 0;\n\n return this.local.forAllNodes(function (node) {\n if (num > 100) { return; }\n\n if (this.isCorrupt(node)) {\n log('[Sync] WARNING: corrupt node in local cache', node);\n if (typeof(node) === 'object' && node.path) {\n this.addTask(node.path);\n num++;\n }\n } else if (this.needsFetch(node) && this.access.checkPathPermission(node.path, 'r')) {\n this.addTask(node.path);\n num++;\n } else if (isDocument(node.path) && this.needsPush(node) &&\n this.access.checkPathPermission(node.path, 'rw')) {\n this.addTask(node.path);\n num++;\n }\n }.bind(this)).then(function () {\n return num;\n }, function (err) {\n throw err;\n });\n },\n\n inConflict: function (node) {\n return (node.local && node.remote &&\n (node.remote.body !== undefined || node.remote.itemsMap));\n },\n\n needsRefresh: function (node) {\n if (node.common) {\n if (!node.common.timestamp) {\n return true;\n }\n return (this.now() - node.common.timestamp > config.syncInterval);\n }\n return false;\n },\n\n needsFetch: function (node) {\n if (this.inConflict(node)) {\n return true;\n }\n if (node.common &&\n node.common.itemsMap === undefined &&\n node.common.body === undefined) {\n return true;\n }\n if (node.remote &&\n node.remote.itemsMap === undefined &&\n node.remote.body === undefined) {\n return true;\n }\n return false;\n },\n\n needsPush: function (node) {\n if (this.inConflict(node)) {\n return false;\n }\n if (node.local && !node.push) {\n return true;\n }\n },\n\n needsRemotePut: function (node) {\n return node.local && node.local.body;\n },\n\n needsRemoteDelete: function (node) {\n return node.local && node.local.body === false;\n },\n\n getParentPath: function (path) {\n var parts = path.match(/^(.*\\/)([^\\/]+\\/?)$/);\n\n if (parts) {\n return parts[1];\n } else {\n throw new Error('Not a valid path: \"'+path+'\"');\n }\n },\n\n deleteChildPathsFromTasks: function () {\n for (var path in this._tasks) {\n var paths = pathsFromRoot(path);\n\n for (var i=1; i {\n return this.handleResponse(task.path, task.action, res);\n }, err => {\n log('[Sync] wireclient rejects its promise!', task.path, task.action, err);\n return this.handleResponse(task.path, task.action, { statusCode: 'offline' });\n })\n .then(completed => {\n delete this._timeStarted[task.path];\n delete this._running[task.path];\n\n if (completed) {\n if (this._tasks[task.path]) {\n for (var i=0; i < this._tasks[task.path].length; i++) {\n this._tasks[task.path][i]();\n }\n delete this._tasks[task.path];\n }\n }\n\n this.remoteStorage._emit('sync-req-done');\n\n this.collectTasks(false).then(() => {\n // See if there are any more tasks that are not refresh tasks\n if (!this.hasTasks() || this.stopped) {\n log('[Sync] Sync is done! Reschedule?', Object.getOwnPropertyNames(this._tasks).length, this.stopped);\n if (!this.done) {\n this.done = true;\n this.remoteStorage._emit('sync-done');\n }\n } else {\n // Use a 10ms timeout to let the JavaScript runtime catch its breath\n // (and hopefully force an IndexedDB auto-commit?), and also to cause\n // the threads to get staggered and get a good spread over time:\n setTimeout(() => { this.doTasks(); }, 10);\n }\n });\n }, err => {\n log('[Sync] Error', err);\n delete this._timeStarted[task.path];\n delete this._running[task.path];\n this.remoteStorage._emit('sync-req-done');\n if (!this.done) {\n this.done = true;\n this.remoteStorage._emit('sync-done');\n }\n });\n },\n\n doTasks: function () {\n let numToHave, numAdded = 0, numToAdd, path;\n if (this.remote.connected) {\n if (this.remote.online) {\n numToHave = this.numThreads;\n } else {\n numToHave = 1;\n }\n } else {\n numToHave = 0;\n }\n numToAdd = numToHave - Object.getOwnPropertyNames(this._running).length;\n if (numToAdd <= 0) {\n return true;\n }\n for (path in this._tasks) {\n if (!this._running[path]) {\n this._timeStarted[path] = this.now();\n this._running[path] = this.doTask(path);\n this._running[path].then(this.finishTask.bind(this));\n numAdded++;\n if (numAdded >= numToAdd) {\n return true;\n }\n }\n }\n return (numAdded >= numToAdd);\n },\n\n collectTasks: function (alsoCheckRefresh) {\n if (this.hasTasks() || this.stopped) {\n return Promise.resolve();\n }\n\n return this.collectDiffTasks().then(function (numDiffs) {\n if (numDiffs || alsoCheckRefresh === false) {\n return Promise.resolve();\n } else {\n return this.collectRefreshTasks();\n }\n }.bind(this), function (err) {\n throw err;\n });\n },\n\n addTask: function (path, cb) {\n if (!this._tasks[path]) {\n this._tasks[path] = [];\n }\n if (typeof(cb) === 'function') {\n this._tasks[path].push(cb);\n }\n },\n\n /**\n * Method: sync\n **/\n sync: function () {\n this.done = false;\n\n if (!this.doTasks()) {\n return this.collectTasks().then(function () {\n try {\n this.doTasks();\n } catch(e) {\n log('[Sync] doTasks error', e);\n }\n }.bind(this), function (e) {\n log('[Sync] Sync error', e);\n throw new Error('Local cache unavailable');\n });\n } else {\n return Promise.resolve();\n }\n },\n};\n\nvar syncCycleCb, syncOnConnect;\nSync._rs_init = function (remoteStorage) {\n\n syncCycleCb = function () {\n // if (!config.cache) return false\n log('[Sync] syncCycleCb calling syncCycle');\n if (Env.isBrowser()) {\n handleVisibility.bind(remoteStorage)();\n }\n\n if (!remoteStorage.sync) {\n // Call this now that all other modules are also ready:\n remoteStorage.sync = new Sync(remoteStorage,\n remoteStorage.local, remoteStorage.remote, remoteStorage.access,\n remoteStorage.caching);\n\n if (remoteStorage.syncStopped) {\n log('[Sync] Instantiating sync stopped');\n remoteStorage.sync.stopped = true;\n delete remoteStorage.syncStopped;\n }\n }\n\n log('[Sync] syncCycleCb calling syncCycle');\n remoteStorage.syncCycle();\n };\n\n syncOnConnect = function() {\n remoteStorage.removeEventListener('connected', syncOnConnect);\n remoteStorage.startSync();\n };\n\n remoteStorage.on('ready', syncCycleCb);\n remoteStorage.on('connected', syncOnConnect);\n};\n\nSync._rs_cleanup = function (remoteStorage) {\n remoteStorage.stopSync();\n remoteStorage.removeEventListener('ready', syncCycleCb);\n remoteStorage.removeEventListener('connected', syncOnConnect);\n\n remoteStorage.sync = undefined;\n delete remoteStorage.sync;\n};\n\nSync.SyncError = function(originalError) {\n this.name = 'SyncError';\n var msg = 'Sync failed: ';\n if (typeof(originalError) === 'object' && 'message' in originalError) {\n msg += originalError.message;\n this.stack = originalError.stack;\n this.originalError = originalError;\n } else {\n msg += originalError;\n }\n this.message = msg;\n};\nSync.SyncError.prototype = Object.create(Error.prototype);\nSync.SyncError.prototype.constructor = Sync.SyncError;\n\nmodule.exports = Sync;\n","'use strict';\n\nconst log = require('./log');\nconst util = require('./util');\nconst eventHandling = require('./eventhandling');\nconst Authorize = require('./authorize');\nconst config = require('./config');\n\n/**\n * This file exposes a get/put/delete interface on top of XMLHttpRequest.\n * It requires to be configured with parameters about the remotestorage server to\n * connect to.\n * Each instance of WireClient is always associated with a single remotestorage\n * server and access token.\n *\n * Usually the WireClient instance can be accessed via `remoteStorage.remote`.\n *\n * This is the get/put/delete interface:\n *\n * - #get() takes a path and optionally a ifNoneMatch option carrying a version\n * string to check. It returns a promise that will be fulfilled with the HTTP\n * response status, the response body, the MIME type as returned in the\n * 'Content-Type' header and the current revision, as returned in the 'ETag'\n * header.\n * - #put() takes a path, the request body and a content type string. It also\n * accepts the ifMatch and ifNoneMatch options, that map to the If-Match and\n * If-None-Match headers respectively. See the remotestorage-01 specification\n * for details on handling these headers. It returns a promise, fulfilled with\n * the same values as the one for #get().\n * - #delete() takes a path and the ifMatch option as well. It returns a promise\n * fulfilled with the same values as the one for #get().\n *\n * In addition to this, the WireClient has some compatibility features to work with\n * remotestorage 2012.04 compatible storages. For example it will cache revisions\n * from folder listings in-memory and return them accordingly as the \"revision\"\n * parameter in response to #get() requests. Similarly it will return 404 when it\n * receives an empty folder listing, to mimic remotestorage-01 behavior. Note\n * that it is not always possible to know the revision beforehand, hence it may\n * be undefined at times (especially for caching-roots).\n *\n * @interface\n */\n\nvar hasLocalStorage;\nvar SETTINGS_KEY = 'remotestorage:wireclient';\n\nvar API_2012 = 1, API_00 = 2, API_01 = 3, API_02 = 4, API_HEAD = 5;\n\nvar STORAGE_APIS = {\n 'draft-dejong-remotestorage-00': API_00,\n 'draft-dejong-remotestorage-01': API_01,\n 'draft-dejong-remotestorage-02': API_02,\n 'https://www.w3.org/community/rww/wiki/read-write-web-00#simple': API_2012\n};\n\nvar isArrayBufferView;\n\nif (typeof(ArrayBufferView) === 'function') {\n isArrayBufferView = function (object) { return object && (object instanceof ArrayBufferView); };\n} else {\n var arrayBufferViews = [\n Int8Array, Uint8Array, Int16Array, Uint16Array,\n Int32Array, Uint32Array, Float32Array, Float64Array\n ];\n isArrayBufferView = function (object) {\n for (let i=0;i<8;i++) {\n if (object instanceof arrayBufferViews[i]) {\n return true;\n }\n }\n return false;\n };\n}\n\nconst isFolder = util.isFolder;\nconst cleanPath = util.cleanPath;\nconst shouldBeTreatedAsBinary = util.shouldBeTreatedAsBinary;\n\nfunction addQuotes(str) {\n if (typeof(str) !== 'string') {\n return str;\n }\n if (str === '*') {\n return '*';\n }\n\n return '\"' + str + '\"';\n}\n\nfunction stripQuotes(str) {\n if (typeof(str) !== 'string') {\n return str;\n }\n\n return str.replace(/^[\"']|[\"']$/g, '');\n}\n\nfunction getTextFromArrayBuffer(arrayBuffer, encoding) {\n return new Promise((resolve/*, reject*/) => {\n if (typeof Blob === 'undefined') {\n var buffer = new Buffer(new Uint8Array(arrayBuffer));\n resolve(buffer.toString(encoding));\n } else {\n var blob;\n util.globalContext.BlobBuilder = util.globalContext.BlobBuilder || util.globalContext.WebKitBlobBuilder;\n if (typeof util.globalContext.BlobBuilder !== 'undefined') {\n var bb = new global.BlobBuilder();\n bb.append(arrayBuffer);\n blob = bb.getBlob();\n } else {\n blob = new Blob([arrayBuffer]);\n }\n\n var fileReader = new FileReader();\n if (typeof fileReader.addEventListener === 'function') {\n fileReader.addEventListener('loadend', function (evt) {\n resolve(evt.target.result);\n });\n } else {\n fileReader.onloadend = function(evt) {\n resolve(evt.target.result);\n };\n }\n fileReader.readAsText(blob, encoding);\n }\n });\n}\n\nfunction determineCharset(mimeType) {\n var charset = 'UTF-8';\n var charsetMatch;\n\n if (mimeType) {\n charsetMatch = mimeType.match(/charset=(.+)$/);\n if (charsetMatch) {\n charset = charsetMatch[1];\n }\n }\n return charset;\n}\n\nfunction isFolderDescription(body) {\n return ((body['@context'] === 'http://remotestorage.io/spec/folder-description')\n && (typeof(body['items']) === 'object'));\n}\n\nfunction isSuccessStatus(status) {\n return [201, 204, 304].indexOf(status) >= 0;\n}\n\nfunction isErrorStatus(status) {\n return [401, 403, 404, 412].indexOf(status) >= 0;\n}\n\n/**\n * Class : WireClient\n **/\nvar WireClient = function WireClient(rs) {\n this.rs = rs;\n this.connected = false;\n\n /**\n * Event: connected\n * Fired when the wireclient connect method realizes that it is in\n * possession of a token and href\n **/\n eventHandling(this, 'connected', 'not-connected');\n\n if (hasLocalStorage) {\n var settings;\n try {\n settings = JSON.parse(localStorage[SETTINGS_KEY]);\n } catch(e) {\n // no settings stored\n }\n if (settings) {\n setTimeout(function () {\n this.configure(settings);\n }.bind(this), 0);\n }\n }\n\n this._revisionCache = {};\n\n if (this.connected) {\n setTimeout(this._emit.bind(this), 0, 'connected');\n }\n};\n\nWireClient.prototype = {\n /**\n * Property: token\n *\n * Holds the bearer token of this WireClient, as obtained in the OAuth dance\n *\n * Example:\n * (start code)\n *\n * remoteStorage.remote.token\n * // -> 'DEADBEEF01=='\n */\n\n /**\n * Property: href\n *\n * Holds the server's base URL, as obtained in the Webfinger discovery\n *\n * Example:\n * (start code)\n *\n * remoteStorage.remote.href\n * // -> 'https://storage.example.com/users/jblogg/'\n */\n\n /**\n * Property: storageApi\n *\n * Holds the spec version the server claims to be compatible with\n *\n * Example:\n * (start code)\n *\n * remoteStorage.remote.storageApi\n * // -> 'draft-dejong-remotestorage-01'\n */\n\n _request: function (method, uri, token, headers, body, getEtag, fakeRevision) {\n if ((method === 'PUT' || method === 'DELETE') && uri[uri.length - 1] === '/') {\n return Promise.reject('Don\\'t ' + method + ' on directories!');\n }\n\n var revision;\n var self = this;\n\n if (token !== Authorize.IMPLIED_FAKE_TOKEN) {\n headers['Authorization'] = 'Bearer ' + token;\n }\n\n this.rs._emit('wire-busy', {\n method: method,\n isFolder: isFolder(uri)\n });\n\n return WireClient.request(method, uri, {\n body: body,\n headers: headers,\n responseType: 'arraybuffer'\n }).then(function(response) {\n if (!self.online) {\n self.online = true;\n self.rs._emit('network-online');\n }\n self.rs._emit('wire-done', {\n method: method,\n isFolder: isFolder(uri),\n success: true\n });\n\n if (isErrorStatus(response.status)) {\n log('[WireClient] Error response status', response.status);\n if (getEtag) {\n revision = stripQuotes(response.getResponseHeader('ETag'));\n } else {\n revision = undefined;\n }\n\n if (response.status === 401) {\n self.rs._emit('error', new Authorize.Unauthorized());\n }\n\n return Promise.resolve({statusCode: response.status, revision: revision});\n } else if (isSuccessStatus(response.status) ||\n (response.status === 200 && method !== 'GET')) {\n revision = stripQuotes(response.getResponseHeader('ETag'));\n log('[WireClient] Successful request', revision);\n return Promise.resolve({statusCode: response.status, revision: revision});\n } else {\n var mimeType = response.getResponseHeader('Content-Type');\n if (getEtag) {\n revision = stripQuotes(response.getResponseHeader('ETag'));\n } else {\n revision = response.status === 200 ? fakeRevision : undefined;\n }\n\n var charset = determineCharset(mimeType);\n\n if (shouldBeTreatedAsBinary(response.response, mimeType)) {\n log('[WireClient] Successful request with unknown or binary mime-type', revision);\n return Promise.resolve({\n statusCode: response.status,\n body: response.response,\n contentType: mimeType,\n revision: revision\n });\n } else {\n return getTextFromArrayBuffer(response.response, charset)\n .then(function (textContent) {\n log('[WireClient] Successful request', revision);\n return Promise.resolve({\n statusCode: response.status,\n body: textContent,\n contentType: mimeType,\n revision: revision\n });\n });\n }\n }\n }, function (error) {\n if (self.online) {\n self.online = false;\n self.rs._emit('network-offline');\n }\n self.rs._emit('wire-done', {\n method: method,\n isFolder: isFolder(uri),\n success: false\n });\n\n return Promise.reject(error);\n });\n },\n\n /**\n *\n * Method: configure\n *\n * Sets the userAddress, href, storageApi, token, and properties of a\n * remote store. Also sets connected and online to true and emits the\n * 'connected' event, if both token and href are present.\n *\n * Parameters:\n * settings - An object that may contain userAddress (string or null),\n * href (string or null), storageApi (string or null), token (string\n * or null), and/or properties (the JSON-parsed properties object\n * from the user's WebFinger record, see section 10 of\n * http://tools.ietf.org/html/draft-dejong-remotestorage-03\n * or null).\n * Fields that are not included (i.e. `undefined`), stay at\n * their current value. To set a field, include that field\n * with a `string` value. To reset a field, for instance when\n * the user disconnected their storage, or you found that the\n * token you have has expired, simply set that field to `null`.\n */\n configure: function (settings) {\n if (typeof settings !== 'object') {\n throw new Error('WireClient configure settings parameter should be an object');\n }\n if (typeof settings.userAddress !== 'undefined') {\n this.userAddress = settings.userAddress;\n }\n if (typeof settings.href !== 'undefined') {\n this.href = settings.href;\n }\n if (typeof settings.storageApi !== 'undefined') {\n this.storageApi = settings.storageApi;\n }\n if (typeof settings.token !== 'undefined') {\n this.token = settings.token;\n }\n if (typeof settings.properties !== 'undefined') {\n this.properties = settings.properties;\n }\n\n if (typeof this.storageApi !== 'undefined') {\n this._storageApi = STORAGE_APIS[this.storageApi] || API_HEAD;\n this.supportsRevs = this._storageApi >= API_00;\n }\n if (this.href && this.token) {\n this.connected = true;\n this.online = true;\n this._emit('connected');\n } else {\n this.connected = false;\n }\n if (hasLocalStorage) {\n localStorage[SETTINGS_KEY] = JSON.stringify({\n userAddress: this.userAddress,\n href: this.href,\n storageApi: this.storageApi,\n token: this.token,\n properties: this.properties\n });\n }\n },\n\n stopWaitingForToken: function () {\n if (!this.connected) {\n this._emit('not-connected');\n }\n },\n\n get: function (path, options) {\n var self = this;\n if (!this.connected) {\n return Promise.reject('not connected (path: ' + path + ')');\n }\n if (!options) { options = {}; }\n var headers = {};\n if (this.supportsRevs) {\n if (options.ifNoneMatch) {\n headers['If-None-Match'] = addQuotes(options.ifNoneMatch);\n }\n }\n // commenting it out as this is doing nothing and jshint is complaining -les\n // else if (options.ifNoneMatch) {\n // var oldRev = this._revisionCache[path];\n // }\n\n\n return this._request('GET', this.href + cleanPath(path), this.token, headers,\n undefined, this.supportsRevs, this._revisionCache[path])\n .then(function (r) {\n if (!isFolder(path)) {\n return Promise.resolve(r);\n }\n var itemsMap = {};\n if (typeof(r.body) !== 'undefined') {\n try {\n r.body = JSON.parse(r.body);\n } catch (e) {\n return Promise.reject('Folder description at ' + self.href + cleanPath(path) + ' is not JSON');\n }\n }\n\n if (r.statusCode === 200 && typeof(r.body) === 'object') {\n // New folder listing received\n if (Object.keys(r.body).length === 0) {\n // Empty folder listing of any spec\n r.statusCode = 404;\n } else if (isFolderDescription(r.body)) {\n // >= 02 spec\n for (var item in r.body.items) {\n self._revisionCache[path + item] = r.body.items[item].ETag;\n }\n itemsMap = r.body.items;\n } else {\n // < 02 spec\n Object.keys(r.body).forEach(function (key){\n self._revisionCache[path + key] = r.body[key];\n itemsMap[key] = {'ETag': r.body[key]};\n });\n }\n r.body = itemsMap;\n return Promise.resolve(r);\n } else {\n return Promise.resolve(r);\n }\n });\n },\n\n put: function (path, body, contentType, options) {\n if (!this.connected) {\n return Promise.reject('not connected (path: ' + path + ')');\n }\n if (!options) { options = {}; }\n if ((!contentType.match(/charset=/)) && (body instanceof ArrayBuffer || isArrayBufferView(body))) {\n contentType += '; charset=binary';\n }\n var headers = { 'Content-Type': contentType };\n if (this.supportsRevs) {\n if (options.ifMatch) {\n headers['If-Match'] = addQuotes(options.ifMatch);\n }\n if (options.ifNoneMatch) {\n headers['If-None-Match'] = addQuotes(options.ifNoneMatch);\n }\n }\n return this._request('PUT', this.href + cleanPath(path), this.token,\n headers, body, this.supportsRevs);\n },\n\n 'delete': function (path, options) {\n if (!this.connected) {\n throw new Error('not connected (path: ' + path + ')');\n }\n if (!options) { options = {}; }\n var headers = {};\n if (this.supportsRevs) {\n if (options.ifMatch) {\n headers['If-Match'] = addQuotes(options.ifMatch);\n }\n }\n return this._request('DELETE', this.href + cleanPath(path), this.token,\n headers,\n undefined, this.supportsRevs);\n }\n};\n\n// Shared isArrayBufferView used by WireClient and Dropbox\nWireClient.isArrayBufferView = isArrayBufferView;\n\n// Shared request function used by WireClient, GoogleDrive and Dropbox.\n// TODO: Should we use fetch ?\nWireClient.request = function (method, url, options) {\n return new Promise ((resolve, reject) => {\n\n log('[WireClient]', method, url);\n\n var timedOut = false;\n\n var timer = setTimeout(function () {\n timedOut = true;\n reject('timeout');\n }, config.requestTimeout);\n\n var xhr = new XMLHttpRequest();\n xhr.open(method, url, true);\n\n if (options.responseType) {\n xhr.responseType = options.responseType;\n }\n\n if (options.headers) {\n for (var key in options.headers) {\n xhr.setRequestHeader(key, options.headers[key]);\n }\n }\n\n xhr.onload = () => {\n if (timedOut) { return; }\n clearTimeout(timer);\n resolve(xhr);\n };\n\n xhr.onerror = (error) => {\n if (timedOut) { return; }\n clearTimeout(timer);\n reject(error);\n };\n\n var body = options.body;\n\n if (typeof(body) === 'object' && !isArrayBufferView(body) && body instanceof ArrayBuffer) {\n body = new Uint8Array(body);\n }\n xhr.send(body);\n });\n};\n\nObject.defineProperty(WireClient.prototype, 'storageType', {\n get: function () {\n if (this.storageApi) {\n var spec = this.storageApi.match(/draft-dejong-(remotestorage-\\d\\d)/);\n return spec ? spec[1] : '2012.04';\n }\n }\n});\n\n\nWireClient._rs_init = function (remoteStorage) {\n hasLocalStorage = util.localStorageAvailable();\n remoteStorage.remote = new WireClient(remoteStorage);\n this.online = true;\n};\n\nWireClient._rs_supported = function () {\n return !! XMLHttpRequest;\n};\n\nWireClient._rs_cleanup = function () {\n if (hasLocalStorage){\n delete localStorage[SETTINGS_KEY];\n }\n};\n\nmodule.exports = WireClient;\n","var g;\r\n\r\n// This works in non-strict mode\r\ng = (function() {\r\n\treturn this;\r\n})();\r\n\r\ntry {\r\n\t// This works if eval is allowed (see CSP)\r\n\tg = g || Function(\"return this\")() || (1, eval)(\"this\");\r\n} catch (e) {\r\n\t// This works if the window reference is available\r\n\tif (typeof window === \"object\") g = window;\r\n}\r\n\r\n// g can still be undefined, but nothing to do about it...\r\n// We return undefined, instead of nothing here, so it's\r\n// easier to handle this case. if(!global) { ...}\r\n\r\nmodule.exports = g;\r\n","/**\n * @class Caching\n *\n * Holds/manages caching configuration.\n **/\n\nvar util = require('./util');\nvar log = require('./log');\n\nvar containingFolder = util.containingFolder;\n\nvar Caching = function () {\n this.reset();\n};\n\nCaching.prototype = {\n pendingActivations: [],\n\n /**\n * Configure caching for a given path explicitly.\n *\n * Not needed when using ``enable``/``disable``.\n *\n * @param {string} path - Path to cache\n * @param {string} strategy - Caching strategy. One of 'ALL', 'SEEN', or 'FLUSH'.\n *\n */\n set: function (path, strategy) {\n if (typeof path !== 'string') {\n throw new Error('path should be a string');\n }\n if (!util.isFolder(path)) {\n throw new Error('path should be a folder');\n }\n if (this._remoteStorage && this._remoteStorage.access &&\n !this._remoteStorage.access.checkPathPermission(path, 'r')) {\n throw new Error('No access to path \"'+path+'\". You have to claim access to it first.');\n }\n if (!strategy.match(/^(FLUSH|SEEN|ALL)$/)) {\n throw new Error(\"strategy should be 'FLUSH', 'SEEN', or 'ALL'\");\n }\n\n this._rootPaths[path] = strategy;\n\n if (strategy === 'ALL') {\n if (this.activateHandler) {\n this.activateHandler(path);\n } else {\n this.pendingActivations.push(path);\n }\n }\n },\n\n /**\n * Enable caching for a given path.\n *\n * Uses caching strategy ``ALL``.\n *\n * @param {string} path - Path to enable caching for\n */\n enable: function (path) {\n this.set(path, 'ALL');\n },\n\n /**\n * Disable caching for a given path.\n *\n * Uses caching strategy ``FLUSH`` (meaning items are only cached until\n * successfully pushed to the remote).\n *\n * @param {string} path - Path to disable caching for\n */\n disable: function (path) {\n this.set(path, 'FLUSH');\n },\n\n /**\n * Set a callback for when caching is activated for a path.\n *\n * @param {function} callback - Callback function\n */\n onActivate: function (cb) {\n var i;\n log('[Caching] Setting activate handler', cb, this.pendingActivations);\n this.activateHandler = cb;\n for (i=0; i { name: \"\", mode: \"\" }\n */\nObject.defineProperty(Access.prototype, 'scopes', {\n get: function() {\n return Object.keys(this.scopeModeMap).map(function(key) {\n return { name: key, mode: this.scopeModeMap[key] };\n }.bind(this));\n }\n});\n\nObject.defineProperty(Access.prototype, 'scopeParameter', {\n get: function() {\n return this.scopes.map(function(scope) {\n return this._scopeNameForParameter(scope) + ':' + scope.mode;\n }.bind(this)).join(' ');\n }\n});\n\n\nAccess._rs_init = function() {};\n\nmodule.exports = Access;\n","'use strict';\n\nconst log = require('./log');\nconst util = require('./util');\nconst WebFinger = require('webfinger.js');\n\n// feature detection flags\nvar haveXMLHttpRequest, hasLocalStorage;\n\n// used to store settings in localStorage\nvar SETTINGS_KEY = 'remotestorage:discover';\n\n// cache loaded from localStorage\nvar cachedInfo = {};\n\n/**\n * This function deals with the Webfinger lookup, discovering a connecting\n * user's storage details.\n *\n * @param {string} userAddress - user@host\n *\n * @returns {Promise} A promise for an object with the following properties.\n * href - Storage base URL,\n * storageApi - RS protocol version,\n * authUrl - OAuth URL,\n * properties - Webfinger link properties\n **/\n\nconst Discover = function Discover(userAddress) {\n return new Promise((resolve, reject) => {\n\n if (userAddress in cachedInfo) {\n return resolve(cachedInfo[userAddress]);\n }\n\n var webFinger = new WebFinger({\n tls_only: false,\n uri_fallback: true,\n request_timeout: 5000\n });\n\n return webFinger.lookup(userAddress, function (err, response) {\n if (err) {\n return reject(err);\n } else if ((typeof response.idx.links.remotestorage !== 'object') ||\n (typeof response.idx.links.remotestorage.length !== 'number') ||\n (response.idx.links.remotestorage.length <= 0)) {\n log(\"[Discover] WebFinger record for \" + userAddress + \" does not have remotestorage defined in the links section \", JSON.stringify(response.json));\n return reject(\"WebFinger record for \" + userAddress + \" does not have remotestorage defined in the links section.\");\n }\n\n var rs = response.idx.links.remotestorage[0];\n var authURL = rs.properties['http://tools.ietf.org/html/rfc6749#section-4.2'] ||\n rs.properties['auth-endpoint'];\n var storageApi = rs.properties['http://remotestorage.io/spec/version'] ||\n rs.type;\n\n // cache fetched data\n cachedInfo[userAddress] = {\n href: rs.href,\n storageApi: storageApi,\n authURL: authURL,\n properties: rs.properties\n };\n\n if (hasLocalStorage) {\n localStorage[SETTINGS_KEY] = JSON.stringify({ cache: cachedInfo });\n }\n\n return resolve(cachedInfo[userAddress]);\n });\n });\n};\n\nDiscover.DiscoveryError = function(message) {\n this.name = 'DiscoveryError';\n this.message = message;\n this.stack = (new Error()).stack;\n};\nDiscover.DiscoveryError.prototype = Object.create(Error.prototype);\nDiscover.DiscoveryError.prototype.constructor = Discover.DiscoveryError;\n\nDiscover._rs_init = function (/*remoteStorage*/) {\n hasLocalStorage = util.localStorageAvailable();\n if (hasLocalStorage) {\n var settings;\n try { settings = JSON.parse(localStorage[SETTINGS_KEY]); } catch(e) { /* empty */ }\n if (settings) {\n cachedInfo = settings.cache;\n }\n }\n};\n\nDiscover._rs_supported = function () {\n haveXMLHttpRequest = !! util.globalContext.XMLHttpRequest;\n return haveXMLHttpRequest;\n};\n\nDiscover._rs_cleanup = function () {\n if (hasLocalStorage) {\n delete localStorage[SETTINGS_KEY];\n }\n};\n\n\nmodule.exports = Discover;\n","/**\n * @class GoogleDrive\n *\n * To use this backend, you need to specify the app's client ID like so:\n *\n * @example\n * remoteStorage.setApiKeys({\n * googledrive: 'your-client-id'\n * });\n *\n * A client ID can be obtained by registering your app in the Google\n * Developers Console: https://console.developers.google.com/flows/enableapi?apiid=drive\n *\n * Docs: https://developers.google.com/drive/v3/web/quickstart/js\n**/\n\nconst Authorize = require('./authorize');\nconst BaseClient = require('./baseclient');\nconst WireClient = require('./wireclient');\nconst eventHandling = require('./eventhandling');\nconst util = require('./util');\n\nconst BASE_URL = 'https://www.googleapis.com';\nconst AUTH_URL = 'https://accounts.google.com/o/oauth2/auth';\nconst AUTH_SCOPE = 'https://www.googleapis.com/auth/drive';\nconst SETTINGS_KEY = 'remotestorage:googledrive';\nconst PATH_PREFIX = '/remotestorage';\n\nconst GD_DIR_MIME_TYPE = 'application/vnd.google-apps.folder';\nconst RS_DIR_MIME_TYPE = 'application/json; charset=UTF-8';\n\nconst isFolder = util.isFolder;\nconst cleanPath = util.cleanPath;\nconst shouldBeTreatedAsBinary = util.shouldBeTreatedAsBinary;\nconst readBinaryData = util.readBinaryData;\n\nlet hasLocalStorage;\n\n/**\n * Produce a title from a filename for metadata.\n *\n * @param {string} filename\n * @returns {string} title\n *\n * @private\n */\nfunction metaTitleFromFileName (filename) {\n if (filename.substr(-1) === '/') {\n filename = filename.substr(0, filename.length - 1);\n }\n\n return decodeURIComponent(filename);\n}\n\n/**\n * Get the parent directory for the given path.\n *\n * @param {string} path\n * @returns {string} parent directory\n *\n * @private\n */\nfunction parentPath (path) {\n return path.replace(/[^\\/]+\\/?$/, '');\n}\n\n/**\n * Get only the filename from a full path.\n *\n * @param {string} path\n * @returns {string} filename\n *\n * @private\n */\nfunction baseName (path) {\n const parts = path.split('/');\n if (path.substr(-1) === '/') {\n return parts[parts.length-2]+'/';\n } else {\n return parts[parts.length-1];\n }\n}\n\n/**\n * Prepend the path with the remoteStorage base directory.\n *\n * @param {string} path - Path\n * @returns {string} Actual path on Google Drive\n *\n * @private\n */\nfunction googleDrivePath (path) {\n return cleanPath(`${PATH_PREFIX}/${path}`);\n}\n\n/**\n * Internal cache object for storing Google file IDs.\n *\n * @param {number} maxAge - Maximum age (in seconds) the content should be cached for\n */\nconst Cache = function (maxAge) {\n this.maxAge = maxAge;\n this._items = {};\n};\n\nCache.prototype = {\n get: function (key) {\n const item = this._items[key];\n const now = new Date().getTime();\n return (item && item.t >= (now - this.maxAge)) ? item.v : undefined;\n },\n\n set: function (key, value) {\n this._items[key] = {\n v: value,\n t: new Date().getTime()\n };\n }\n};\n\nconst GoogleDrive = function (remoteStorage, clientId) {\n\n eventHandling(this, 'connected', 'not-connected');\n\n this.rs = remoteStorage;\n this.clientId = clientId;\n\n this._fileIdCache = new Cache(60 * 5); // IDs expire after 5 minutes (is this a good idea?)\n\n hasLocalStorage = util.localStorageAvailable();\n\n if (hasLocalStorage){\n let settings;\n try {\n settings = JSON.parse(localStorage.getItem(SETTINGS_KEY));\n } catch(e) {\n // no settings stored\n }\n if (settings) {\n this.configure(settings);\n }\n }\n\n};\n\nGoogleDrive.prototype = {\n connected: false,\n online: true,\n\n /**\n * Configure the Google Drive backend.\n *\n * Fetches the user info from Google when no ``userAddress`` is given.\n *\n * @param {Object} settings\n * @param {string} [settings.userAddress] - The user's email address\n * @param {string} [settings.token] - Authorization token\n *\n * @protected\n */\n configure: function (settings) { // Settings parameter compatible with WireClient\n // We only update this.userAddress if settings.userAddress is set to a string or to null\n if (typeof settings.userAddress !== 'undefined') { this.userAddress = settings.userAddress; }\n // Same for this.token. If only one of these two is set, we leave the other one at its existing value\n if (typeof settings.token !== 'undefined') { this.token = settings.token; }\n\n const writeSettingsToCache = function() {\n if (hasLocalStorage) {\n localStorage.setItem(SETTINGS_KEY, JSON.stringify({\n userAddress: this.userAddress,\n token: this.token\n }));\n }\n };\n\n const handleError = function() {\n this.connected = false;\n delete this.token;\n if (hasLocalStorage) {\n localStorage.removeItem(SETTINGS_KEY);\n }\n };\n\n if (this.token) {\n this.connected = true;\n\n if (this.userAddress) {\n this._emit('connected');\n writeSettingsToCache.apply(this);\n } else {\n this.info().then((info) => {\n this.userAddress = info.user.emailAddress;\n this._emit('connected');\n writeSettingsToCache.apply(this);\n }).catch(() => {\n handleError.apply(this);\n this.rs._emit('error', new Error('Could not fetch user info.'));\n });\n }\n } else {\n handleError.apply(this);\n }\n },\n\n /**\n * Initiate the authorization flow's OAuth dance.\n */\n connect: function () {\n this.rs.setBackend('googledrive');\n Authorize(this.rs, AUTH_URL, AUTH_SCOPE, String(Authorize.getLocation()), this.clientId);\n },\n\n /**\n * Stop the authorization process.\n *\n * @protected\n */\n stopWaitingForToken: function () {\n if (!this.connected) {\n this._emit('not-connected');\n }\n },\n\n /**\n * Request a resource (file or directory).\n *\n * @param {string} path - Path of the resource\n * @param {Object} options - Request options\n * @returns {Promise} Resolves with an object containing the status code,\n * body, content-type and revision\n *\n * @protected\n */\n get: function (path, options) {\n if (path.substr(-1) === '/') {\n return this._getFolder(googleDrivePath(path), options);\n } else {\n return this._getFile(googleDrivePath(path), options);\n }\n },\n\n /**\n * Create or update a file.\n *\n * @param {string} path - File path\n * @param body - File content\n * @param {string} contentType - File content-type\n * @param {Object} options\n * @param {string} options.ifNoneMatch - Only create of update the file if the\n * current ETag doesn't match this string\n * @returns {Promise} Resolves with an object containing the status code,\n * content-type and revision\n *\n * @protected\n */\n put: function (path, body, contentType, options) {\n const fullPath = googleDrivePath(path);\n\n function putDone(response) {\n if (response.status >= 200 && response.status < 300) {\n const meta = JSON.parse(response.responseText);\n const etagWithoutQuotes = meta.etag.substring(1, meta.etag.length-1);\n return Promise.resolve({statusCode: 200, contentType: meta.mimeType, revision: etagWithoutQuotes});\n } else if (response.status === 412) {\n return Promise.resolve({statusCode: 412, revision: 'conflict'});\n } else {\n return Promise.reject(\"PUT failed with status \" + response.status + \" (\" + response.responseText + \")\");\n }\n }\n\n return this._getFileId(fullPath).then((id) => {\n if (id) {\n if (options && (options.ifNoneMatch === '*')) {\n return putDone({ status: 412 });\n }\n return this._updateFile(id, fullPath, body, contentType, options).then(putDone);\n } else {\n return this._createFile(fullPath, body, contentType, options).then(putDone);\n }\n });\n },\n\n /**\n * Delete a file.\n *\n * @param {string} path - File path\n * @param {Object} options\n * @param {string} options.ifMatch - only delete the file if it's ETag\n * matches this string\n * @returns {Promise} Resolves with an object containing the status code\n *\n * @protected\n */\n 'delete': function (path, options) {\n const fullPath = googleDrivePath(path);\n\n return this._getFileId(fullPath).then((id) => {\n if (!id) {\n // File doesn't exist. Ignore.\n return Promise.resolve({statusCode: 200});\n }\n\n return this._getMeta(id).then((meta) => {\n let etagWithoutQuotes;\n if ((typeof meta === 'object') && (typeof meta.etag === 'string')) {\n etagWithoutQuotes = meta.etag.substring(1, meta.etag.length-1);\n }\n if (options && options.ifMatch && (options.ifMatch !== etagWithoutQuotes)) {\n return {statusCode: 412, revision: etagWithoutQuotes};\n }\n\n return this._request('DELETE', BASE_URL + '/drive/v2/files/' + id, {}).then((response) => {\n if (response.status === 200 || response.status === 204) {\n return {statusCode: 200};\n } else {\n return Promise.reject(\"Delete failed: \" + response.status + \" (\" + response.responseText + \")\");\n }\n });\n });\n });\n },\n\n /**\n * Fetch the user's info from Google.\n *\n * @returns {Promise} resolves with the user's info.\n *\n * @protected\n */\n info: function () {\n const url = BASE_URL + '/drive/v2/about?fields=user';\n // requesting user info(mainly for userAdress)\n return this._request('GET', url, {}).then(function (resp){\n try {\n const info = JSON.parse(resp.responseText);\n return Promise.resolve(info);\n } catch (e) {\n return Promise.reject(e);\n }\n });\n },\n\n /**\n * Update an existing file.\n *\n * @param {string} id - File ID\n * @param {string} path - File path\n * @param body - File content\n * @param {string} contentType - File content-type\n * @param {Object} options\n * @param {string} options.ifMatch - Only update the file if its ETag\n * matches this string\n * @returns {Promise} Resolves with the response of the network request\n *\n * @private\n */\n _updateFile: function (id, path, body, contentType, options) {\n const metadata = {\n mimeType: contentType\n };\n const headers = {\n 'Content-Type': 'application/json; charset=UTF-8'\n };\n\n if (options && options.ifMatch) {\n headers['If-Match'] = '\"' + options.ifMatch + '\"';\n }\n\n return this._request('PUT', BASE_URL + '/upload/drive/v2/files/' + id + '?uploadType=resumable', {\n body: JSON.stringify(metadata),\n headers: headers\n }).then((response) => {\n if (response.status === 412) {\n return (response);\n } else {\n return this._request('PUT', response.getResponseHeader('Location'), {\n body: contentType.match(/^application\\/json/) ? JSON.stringify(body) : body\n });\n }\n });\n },\n\n /**\n * Create a new file.\n *\n * @param {string} path - File path\n * @param body - File content\n * @param {string} contentType - File content-type\n * @returns {Promise} Resolves with the response of the network request\n *\n * @private\n */\n _createFile: function (path, body, contentType/*, options*/) {\n return this._getParentId(path).then((parentId) => {\n const fileName = baseName(path);\n const metadata = {\n title: metaTitleFromFileName(fileName),\n mimeType: contentType,\n parents: [{\n kind: \"drive#fileLink\",\n id: parentId\n }]\n };\n return this._request('POST', BASE_URL + '/upload/drive/v2/files?uploadType=resumable', {\n body: JSON.stringify(metadata),\n headers: {\n 'Content-Type': 'application/json; charset=UTF-8'\n }\n }).then((response) => {\n return this._request('POST', response.getResponseHeader('Location'), {\n body: contentType.match(/^application\\/json/) ? JSON.stringify(body) : body\n });\n });\n });\n },\n\n /**\n * Request a file.\n *\n * @param {string} path - File path\n * @param {Object} options\n * @param {string} [options.ifNoneMath] - Only return the file if its ETag\n * doesn't match the given string\n * @returns {Promise} Resolves with an object containing the status code,\n * body, content-type and revision\n *\n * @private\n */\n _getFile: function (path, options) {\n return this._getFileId(path).then((id) => {\n return this._getMeta(id).then((meta) => {\n let etagWithoutQuotes;\n if (typeof(meta) === 'object' && typeof(meta.etag) === 'string') {\n etagWithoutQuotes = meta.etag.substring(1, meta.etag.length-1);\n }\n\n if (options && options.ifNoneMatch && (etagWithoutQuotes === options.ifNoneMatch)) {\n return Promise.resolve({statusCode: 304});\n }\n\n const options2 = {};\n if (!meta.downloadUrl) {\n if (meta.exportLinks && meta.exportLinks['text/html']) {\n // Documents that were generated inside GoogleDocs have no\n // downloadUrl, but you can export them to text/html instead:\n meta.mimeType += ';export=text/html';\n meta.downloadUrl = meta.exportLinks['text/html'];\n } else {\n // empty file\n return Promise.resolve({statusCode: 200, body: '', contentType: meta.mimeType, revision: etagWithoutQuotes});\n }\n }\n\n return this._request('GET', meta.downloadUrl, options2).then((response) => {\n let body = response.response;\n if (meta.mimeType.match(/^application\\/json/)) {\n try {\n body = JSON.parse(body);\n } catch(e) {\n // body couldn't be parsed as JSON, so we'll just return it as is\n }\n } else {\n if (shouldBeTreatedAsBinary(body, meta.mimeType)) {\n return readBinaryData(body, meta.mimeType).then((result) => {\n return {\n statusCode: 200,\n body: result,\n contentType: meta.mimeType,\n revision: etagWithoutQuotes\n };\n });\n }\n }\n\n return Promise.resolve({statusCode: 200, body: body, contentType: meta.mimeType, revision: etagWithoutQuotes});\n });\n });\n });\n },\n\n /**\n * Request a directory.\n *\n * @param {string} path - Directory path\n * @param {Object} options\n * @returns {Promise} Resolves with an object containing the status code,\n * body and content-type\n *\n * @private\n */\n _getFolder: function (path/*, options*/) {\n return this._getFileId(path).then((id) => {\n let query, fields, data, etagWithoutQuotes, itemsMap;\n if (! id) {\n return Promise.resolve({statusCode: 404});\n }\n\n query = '\\'' + id + '\\' in parents';\n fields = 'items(downloadUrl,etag,fileSize,id,mimeType,title)';\n return this._request('GET', BASE_URL + '/drive/v2/files?'\n + 'q=' + encodeURIComponent(query)\n + '&fields=' + encodeURIComponent(fields)\n + '&maxResults=1000',\n {})\n .then((response) => {\n if (response.status !== 200) {\n return Promise.reject('request failed or something: ' + response.status);\n }\n\n try {\n data = JSON.parse(response.responseText);\n } catch(e) {\n return Promise.reject('non-JSON response from GoogleDrive');\n }\n\n itemsMap = {};\n for (const item of data.items) {\n etagWithoutQuotes = item.etag.substring(1, item.etag.length-1);\n if (item.mimeType === GD_DIR_MIME_TYPE) {\n this._fileIdCache.set(path + item.title + '/', item.id);\n itemsMap[item.title + '/'] = {\n ETag: etagWithoutQuotes\n };\n } else {\n this._fileIdCache.set(path + item.title, item.id);\n itemsMap[item.title] = {\n ETag: etagWithoutQuotes,\n 'Content-Type': item.mimeType,\n 'Content-Length': item.fileSize\n };\n }\n }\n\n // FIXME: add revision of folder!\n return Promise.resolve({statusCode: 200, body: itemsMap, contentType: RS_DIR_MIME_TYPE, revision: undefined});\n });\n });\n },\n\n /**\n * Get the ID of a parent path.\n *\n * Creates the directory if it doesn't exist yet.\n *\n * @param {string} path - Full path of a directory or file\n * @returns {Promise} Resolves with ID of the parent directory.\n *\n * @private\n */\n _getParentId: function (path) {\n const foldername = parentPath(path);\n\n return this._getFileId(foldername).then((parentId) => {\n if (parentId) {\n return Promise.resolve(parentId);\n } else {\n return this._createFolder(foldername);\n }\n });\n },\n\n /**\n * Create a directory.\n *\n * Creates all parent directories as well if any of them didn't exist yet.\n *\n * @param {string} path - Directory path\n * @returns {Promise} Resolves with the ID of the new directory\n *\n * @private\n */\n _createFolder: function (path) {\n return this._getParentId(path).then((parentId) => {\n return this._request('POST', BASE_URL + '/drive/v2/files', {\n body: JSON.stringify({\n title: metaTitleFromFileName(baseName(path)),\n mimeType: GD_DIR_MIME_TYPE,\n parents: [{\n id: parentId\n }]\n }),\n headers: {\n 'Content-Type': 'application/json; charset=UTF-8'\n }\n }).then((response) => {\n const meta = JSON.parse(response.responseText);\n return Promise.resolve(meta.id);\n });\n });\n },\n\n /**\n * Get the ID of a file.\n *\n * @param {string} path - File path\n * @returns {Promise} Resolves with the ID\n *\n * @private\n */\n _getFileId: function (path) {\n let id;\n\n if (path === '/') {\n // \"root\" is a special alias for the fileId of the root folder\n return Promise.resolve('root');\n } else if ((id = this._fileIdCache.get(path))) {\n // id is cached.\n return Promise.resolve(id);\n }\n // id is not cached (or file doesn't exist).\n // load parent folder listing to propagate / update id cache.\n return this._getFolder(parentPath(path)).then(() => {\n id = this._fileIdCache.get(path);\n if (!id) {\n if (path.substr(-1) === '/') {\n return this._createFolder(path).then(() => {\n return this._getFileId(path);\n });\n } else {\n return Promise.resolve();\n }\n }\n return Promise.resolve(id);\n });\n },\n\n /**\n * Get the metadata for a given file ID.\n *\n * @param {string} id - File ID\n * @returns {Promise} Resolves with an object containing the metadata\n *\n * @private\n */\n _getMeta: function (id) {\n return this._request('GET', BASE_URL + '/drive/v2/files/' + id, {}).then(function (response) {\n if (response.status === 200) {\n return Promise.resolve(JSON.parse(response.responseText));\n } else {\n return Promise.reject(\"request (getting metadata for \" + id + \") failed with status: \" + response.status);\n }\n });\n },\n\n /**\n * Make a network request.\n *\n * @param {string} method - Request method\n * @param {string} url - Target URL\n * @param {Object} options - Request options\n * @returns {Promise} Resolves with the response of the network request\n *\n * @private\n */\n _request: function (method, url, options) {\n if (! options.headers) { options.headers = {}; }\n options.headers['Authorization'] = 'Bearer ' + this.token;\n\n this.rs._emit('wire-busy', {\n method: method,\n isFolder: isFolder(url)\n });\n\n return WireClient.request.call(this, method, url, options).then((xhr) => {\n // Google tokens expire from time to time...\n if (xhr && xhr.status === 401) {\n this.connect();\n return;\n } else {\n if (!this.online) {\n this.online = true;\n this.rs._emit('network-online');\n }\n this.rs._emit('wire-done', {\n method: method,\n isFolder: isFolder(url),\n success: true\n });\n\n return Promise.resolve(xhr);\n }\n }, (error) => {\n if (this.online) {\n this.online = false;\n this.rs._emit('network-offline');\n }\n this.rs._emit('wire-done', {\n method: method,\n isFolder: isFolder(url),\n success: false\n });\n\n return Promise.reject(error);\n });\n }\n};\n\n/**\n * Overwrite BaseClient's getItemURL with our own implementation\n *\n * TODO: Still needs to be implemented. At the moment it just throws\n * and error saying that it's not implemented yet.\n *\n * @param {object} rs - RemoteStorage instance\n *\n * @private\n */\nfunction hookGetItemURL (rs) {\n if (rs._origBaseClientGetItemURL) { return; }\n rs._origBaseClientGetItemURL = BaseClient.prototype.getItemURL;\n BaseClient.prototype.getItemURL = function (/* path */){\n throw new Error('getItemURL is not implemented for Google Drive yet');\n };\n}\n\n/**\n * Restore BaseClient's getItemURL original implementation\n *\n * @param {object} rs - RemoteStorage instance\n *\n * @private\n */\nfunction unHookGetItemURL (rs) {\n if (!rs._origBaseClientGetItemURL) { return; }\n BaseClient.prototype.getItemURL = rs._origBaseClientGetItemURL;\n delete rs._origBaseClientGetItemURL;\n}\n\n/**\n * Initialize the Google Drive backend.\n *\n * @param {Object} remoteStorage - RemoteStorage instance\n *\n * @protected\n */\nGoogleDrive._rs_init = function (remoteStorage) {\n const config = remoteStorage.apiKeys.googledrive;\n if (config) {\n remoteStorage.googledrive = new GoogleDrive(remoteStorage, config.clientId);\n if (remoteStorage.backend === 'googledrive') {\n remoteStorage._origRemote = remoteStorage.remote;\n remoteStorage.remote = remoteStorage.googledrive;\n\n hookGetItemURL(remoteStorage);\n }\n }\n};\n\n/**\n * Inform about the availability of the Google Drive backend.\n *\n * @param {Object} rs - RemoteStorage instance\n * @returns {Boolean}\n *\n * @protected\n */\nGoogleDrive._rs_supported = function () {\n return true;\n};\n\n/**\n * Remove Google Drive as a backend.\n *\n * @param {Object} remoteStorage - RemoteStorage instance\n *\n * @protected\n */\nGoogleDrive._rs_cleanup = function (remoteStorage) {\n remoteStorage.setBackend(undefined);\n if (remoteStorage._origRemote) {\n remoteStorage.remote = remoteStorage._origRemote;\n delete remoteStorage._origRemote;\n }\n unHookGetItemURL(remoteStorage);\n};\n\nmodule.exports = GoogleDrive;\n","const eventHandling = require('./eventhandling');\n\nconst mode = typeof(window) !== 'undefined' ? 'browser' : 'node',\n env = {};\n\nconst Env = function () {\n return env;\n};\n\nEnv.isBrowser = function () {\n return mode === \"browser\";\n};\n\nEnv.isNode = function () {\n return mode === \"node\";\n};\n\nEnv.goBackground = function () {\n Env._emit(\"background\");\n};\n\nEnv.goForeground = function () {\n Env._emit(\"foreground\");\n};\n\nEnv._rs_init = function (/* remoteStorage */) {\n eventHandling(Env, \"background\", \"foreground\");\n\n function visibility () {\n if (document[env.hiddenProperty]) {\n Env.goBackground();\n } else {\n Env.goForeground();\n }\n }\n\n if (mode === 'browser') {\n if (typeof(document.hidden) !== \"undefined\") {\n env.hiddenProperty = \"hidden\";\n env.visibilityChangeEvent = \"visibilitychange\";\n } else if (typeof(document.mozHidden) !== \"undefined\") {\n env.hiddenProperty = \"mozHidden\";\n env.visibilityChangeEvent = \"mozvisibilitychange\";\n } else if (typeof(document.msHidden) !== \"undefined\") {\n env.hiddenProperty = \"msHidden\";\n env.visibilityChangeEvent = \"msvisibilitychange\";\n } else if (typeof(document.webkitHidden) !== \"undefined\") {\n env.hiddenProperty = \"webkitHidden\";\n env.visibilityChangeEvent = \"webkitvisibilitychange\";\n }\n document.addEventListener(env.visibilityChangeEvent, visibility, false);\n visibility();\n }\n};\n\nEnv._rs_cleanup = function (/* remoteStorage */) {\n};\n\n\nmodule.exports = Env;\n","var Authorize = require('./authorize');\nvar BaseClient = require('./baseclient');\nvar WireClient = require('./wireclient');\nvar util = require('./util');\nvar eventHandling = require('./eventhandling');\nvar Sync = require('./sync');\n\n/**\n * WORK IN PROGRESS, NOT RECOMMENDED FOR PRODUCTION USE\n *\n * Dropbox backend for RemoteStorage.js\n * This file exposes a get/put/delete interface which is compatible with\n * .\n *\n * When remoteStorage.backend is set to 'dropbox', this backend will\n * initialize and replace remoteStorage.remote with remoteStorage.dropbox.\n *\n * In order to ensure compatibility with the public folder, \n * gets hijacked to return the Dropbox public share URL.\n *\n * To use this backend, you need to specify the Dropbox app key like so:\n *\n * @example\n * remoteStorage.setApiKeys({\n * dropbox: 'your-app-key'\n * });\n *\n * An app key can be obtained by registering your app at https://www.dropbox.com/developers/apps\n *\n * Known issues:\n *\n * - Storing files larger than 150MB is not yet supported\n * - Listing and deleting folders with more than 10'000 files will cause problems\n * - Content-Type is not fully supported due to limitations of the Dropbox API\n * - Dropbox preserves cases but is not case-sensitive\n * - getItemURL is asynchronous which means it returns useful values\n * after the syncCycle\n */\n\nlet hasLocalStorage;\nconst AUTH_URL = 'https://www.dropbox.com/oauth2/authorize';\nconst SETTINGS_KEY = 'remotestorage:dropbox';\nconst PATH_PREFIX = '/remotestorage';\n\nconst isFolder = util.isFolder;\nconst cleanPath = util.cleanPath;\nconst shouldBeTreatedAsBinary = util.shouldBeTreatedAsBinary;\nconst readBinaryData = util.readBinaryData;\n\n/**\n * Map a local path to a path in Dropbox.\n *\n * @param {string} path - Path\n * @returns {string} Actual path in Dropbox\n *\n * @private\n */\nvar getDropboxPath = function (path) {\n return cleanPath(PATH_PREFIX + '/' + path).replace(/\\/$/, '');\n};\n\nvar compareApiError = function (response, expect) {\n return new RegExp('^' + expect.join('\\\\/') + '(\\\\/|$)').test(response.error_summary);\n};\n\nconst isBinaryData = function (data) {\n return data instanceof ArrayBuffer || WireClient.isArrayBufferView(data);\n};\n\n/**\n * A cache which automatically converts all keys to lower case and can\n * propagate changes up to parent folders.\n *\n * By default the set and delete methods are aliased to justSet and justDelete.\n *\n * @param defaultValue {string} the value that is returned for all keys that don't exist\n * in the cache\n *\n * @class\n *\n */\nfunction LowerCaseCache(defaultValue){\n this.defaultValue = defaultValue;\n this._storage = { };\n this.set = this.justSet;\n this.delete = this.justDelete;\n}\n\nLowerCaseCache.prototype = {\n /**\n * Get a value from the cache or defaultValue, if the key is not in the\n * cache.\n *\n * @protected\n */\n get: function (key) {\n key = key.toLowerCase();\n var stored = this._storage[key];\n if (typeof stored === 'undefined'){\n stored = this.defaultValue;\n this._storage[key] = stored;\n }\n return stored;\n },\n\n /**\n * Set a value and also update the parent folders with that value.\n */\n propagateSet: function (key, value) {\n key = key.toLowerCase();\n if (this._storage[key] === value) {\n return value;\n }\n this._propagate(key, value);\n this._storage[key] = value;\n return value;\n },\n\n /**\n * Delete a value and propagate the changes to the parent folders.\n */\n propagateDelete: function (key) {\n key = key.toLowerCase();\n this._propagate(key, this._storage[key]);\n return delete this._storage[key];\n },\n\n _activatePropagation: function (){\n this.set = this.propagateSet;\n this.delete = this.propagateDelete;\n return true;\n },\n\n /**\n * Set a value without propagating.\n */\n justSet: function (key, value) {\n key = key.toLowerCase();\n this._storage[key] = value;\n return value;\n },\n\n /**\n * Delete a key without propagating.\n */\n justDelete: function (key) {\n key = key.toLowerCase();\n return delete this._storage[key];\n },\n\n _propagate: function (key, rev){\n var folders = key.split('/').slice(0,-1);\n var path = '';\n\n for (var i = 0, len = folders.length; i < len; i++){\n path += folders[i]+'/';\n if (!rev) {\n rev = this._storage[path]+1;\n }\n this._storage[path] = rev;\n }\n }\n};\n\n/**\n * @class\n */\nvar Dropbox = function (rs) {\n\n this.rs = rs;\n this.connected = false;\n this.rs = rs;\n\n eventHandling(this, 'connected', 'not-connected');\n\n this.clientId = rs.apiKeys.dropbox.appKey;\n this._revCache = new LowerCaseCache('rev');\n this._itemRefs = {};\n\n hasLocalStorage = util.localStorageAvailable();\n\n if (hasLocalStorage){\n var settings;\n try {\n settings = JSON.parse(localStorage.getItem(SETTINGS_KEY));\n } catch(e) { /* ok to ignore, probably no data in localStorage */ }\n if (settings) {\n this.configure(settings);\n }\n try {\n this._itemRefs = JSON.parse(localStorage.getItem(SETTINGS_KEY+':shares')) || {};\n } catch(e) { /* ok to ignore, no shares in localStorage */ }\n }\n if (this.connected) {\n setTimeout(this._emit.bind(this), 0, 'connected');\n }\n};\n\nDropbox.prototype = {\n online: true,\n\n /**\n * Set the backed to 'dropbox' and start the authentication flow in order\n * to obtain an API token from Dropbox.\n */\n connect: function () {\n // TODO handling when token is already present\n this.rs.setBackend('dropbox');\n if (this.token){\n hookIt(this.rs);\n } else {\n Authorize(this.rs, AUTH_URL, '', String(Authorize.getLocation()), this.clientId);\n }\n },\n\n /**\n * Sets the connected flag\n * Accepts its parameters according to the .\n * @param {Object} settings\n * @param {string} [settings.userAddress] - The user's email address\n * @param {string} [settings.token] - Authorization token\n *\n * @protected\n **/\n configure: function (settings) {\n // We only update this.userAddress if settings.userAddress is set to a string or to null:\n if (typeof settings.userAddress !== 'undefined') { this.userAddress = settings.userAddress; }\n // Same for this.token. If only one of these two is set, we leave the other one at its existing value:\n if (typeof settings.token !== 'undefined') { this.token = settings.token; }\n\n var writeSettingsToCache = function() {\n if (hasLocalStorage) {\n localStorage.setItem(SETTINGS_KEY, JSON.stringify({\n userAddress: this.userAddress,\n token: this.token\n }));\n }\n };\n\n var handleError = function() {\n this.connected = false;\n if (hasLocalStorage) {\n localStorage.removeItem(SETTINGS_KEY);\n }\n };\n\n if (this.token) {\n this.connected = true;\n if (this.userAddress) {\n this._emit('connected');\n writeSettingsToCache.apply(this);\n } else {\n this.info().then(function (info){\n this.userAddress = info.email;\n this._emit('connected');\n writeSettingsToCache.apply(this);\n }.bind(this)).catch(function() {\n handleError.apply(this);\n this.rs._emit('error', new Error('Could not fetch user info.'));\n }.bind(this));\n }\n } else {\n handleError.apply(this);\n }\n },\n\n /**\n * Stop waiting for the token and emit not-connected\n *\n * @protected\n */\n stopWaitingForToken: function () {\n if (!this.connected) {\n this._emit('not-connected');\n }\n },\n\n /**\n * Get all items in a folder.\n *\n * @param path {string} - path of the folder to get, with leading slash\n * @return {Object}\n * statusCode - HTTP status code\n * body - array of the items found\n * contentType - 'application/json; charset=UTF-8'\n * revision - revision of the folder\n *\n * @private\n */\n _getFolder: function (path) {\n var url = 'https://api.dropboxapi.com/2/files/list_folder';\n var revCache = this._revCache;\n var self = this;\n\n var processResponse = function (resp) {\n var body, listing;\n\n if (resp.status !== 200 && resp.status !== 409) {\n return Promise.reject('Unexpected response status: ' + resp.status);\n }\n\n try {\n body = JSON.parse(resp.responseText);\n } catch (e) {\n return Promise.reject(e);\n }\n\n if (resp.status === 409) {\n if (compareApiError(body, ['path', 'not_found'])) {\n // if the folder is not found, handle it as an empty folder\n return Promise.resolve({});\n }\n\n return Promise.reject(new Error('API returned an error: ' + body.error_summary));\n }\n\n listing = body.entries.reduce(function (map, item) {\n var isDir = item['.tag'] === 'folder';\n var itemName = item.path_lower.split('/').slice(-1)[0] + (isDir ? '/' : '');\n if (isDir){\n map[itemName] = { ETag: revCache.get(path+itemName) };\n } else {\n map[itemName] = { ETag: item.rev };\n }\n return map;\n }, {});\n\n if (body.has_more) {\n return loadNext(body.cursor).then(function (nextListing) {\n return Object.assign(listing, nextListing);\n });\n }\n\n return Promise.resolve(listing);\n };\n\n const loadNext = function (cursor) {\n const continueURL = 'https://api.dropboxapi.com/2/files/list_folder/continue';\n const params = {\n body: { cursor: cursor }\n };\n\n return self._request('POST', continueURL, params).then(processResponse);\n };\n\n return this._request('POST', url, {\n body: {\n path: getDropboxPath(path)\n }\n }).then(processResponse).then(function (listing) {\n return Promise.resolve({\n statusCode: 200,\n body: listing,\n contentType: 'application/json; charset=UTF-8',\n revision: revCache.get(path)\n });\n });\n },\n\n /**\n * Checks for the path in ``_revCache`` and decides based on that if file\n * has changed. Calls ``_getFolder`` is the path points to a folder.\n *\n * Calls ``Dropbox.share`` afterwards to fill ``_itemRefs``.\n *\n * Compatible with ``WireClient.get``\n *\n * @param path {string} - path of the folder to get, with leading slash\n * @param options {Object}\n *\n * @protected\n */\n get: function (path, options) {\n if (! this.connected) { return Promise.reject(\"not connected (path: \" + path + \")\"); }\n var url = 'https://content.dropboxapi.com/2/files/download';\n var self = this;\n\n var savedRev = this._revCache.get(path);\n if (savedRev === null) {\n // file was deleted server side\n return Promise.resolve({statusCode: 404});\n }\n if (options && options.ifNoneMatch &&\n savedRev && (savedRev === options.ifNoneMatch)) {\n // nothing changed.\n return Promise.resolve({statusCode: 304});\n }\n\n //use _getFolder for folders\n if (path.substr(-1) === '/') {\n return this._getFolder(path, options);\n }\n\n var params = {\n headers: {\n 'Dropbox-API-Arg': JSON.stringify({path: getDropboxPath(path)})\n }\n };\n if (options && options.ifNoneMatch) {\n params.headers['If-None-Match'] = options.ifNoneMatch;\n }\n\n return this._request('GET', url, params).then(function (resp) {\n var status = resp.status;\n var meta, body, mime, rev;\n if (status !== 200 && status !== 409) {\n return Promise.resolve({statusCode: status});\n }\n meta = resp.getResponseHeader('Dropbox-API-Result');\n body = resp.responseText;\n\n if (status === 409) {\n meta = body;\n }\n\n try {\n meta = JSON.parse(meta);\n } catch(e) {\n return Promise.reject(e);\n }\n\n if (status === 409) {\n if (compareApiError(meta, ['path', 'not_found'])) {\n return Promise.resolve({statusCode: 404});\n }\n return Promise.reject(new Error('API error while downloading file (\"' + path + '\"): ' + meta.error_summary));\n }\n\n mime = resp.getResponseHeader('Content-Type');\n rev = meta.rev;\n self._revCache.set(path, rev);\n self._shareIfNeeded(path);\n\n // handling binary\n if (shouldBeTreatedAsBinary(resp.response, mime)) {\n return readBinaryData(resp.response, mime).then((result) => {\n return {\n statusCode: status,\n body: result,\n contentType: mime,\n revision: rev\n };\n });\n }\n\n // handling json (always try)\n try {\n body = JSON.parse(body);\n mime = 'application/json; charset=UTF-8';\n } catch(e) {\n //Failed parsing Json, assume it is something else then\n }\n\n return Promise.resolve({statusCode: status, body: body, contentType: mime, revision: rev});\n });\n },\n\n /**\n * Checks for the path in ``_revCache`` and decides based on that if file\n * has changed.\n *\n * Compatible with ``WireClient``\n *\n * Calls ``Dropbox.share`` afterwards to fill ``_itemRefs``.\n *\n * @param {string} path - path of the folder to put, with leading slash\n * @param {Object} options\n * @param {string} options.ifNoneMatch - Only create of update the file if the\n * current ETag doesn't match this string\n * @returns {Promise} Resolves with an object containing the status code,\n * content-type and revision\n * @protected\n */\n put: function (path, body, contentType, options) {\n var self = this;\n\n if (!this.connected) {\n throw new Error(\"not connected (path: \" + path + \")\");\n }\n\n //check if file has changed and return 412\n var savedRev = this._revCache.get(path);\n if (options && options.ifMatch &&\n savedRev && (savedRev !== options.ifMatch)) {\n return Promise.resolve({statusCode: 412, revision: savedRev});\n }\n if (options && (options.ifNoneMatch === '*') &&\n savedRev && (savedRev !== 'rev')) {\n return Promise.resolve({statusCode: 412, revision: savedRev});\n }\n\n if ((!contentType.match(/charset=/)) && isBinaryData(body)) {\n contentType += '; charset=binary';\n }\n\n if (body.length > 150 * 1024 * 1024) {\n //https://www.dropbox.com/developers/core/docs#chunked-upload\n return Promise.reject(new Error(\"Cannot upload file larger than 150MB\"));\n }\n\n var result;\n var needsMetadata = options && (options.ifMatch || (options.ifNoneMatch === '*'));\n var uploadParams = {\n body: body,\n contentType: contentType,\n path: path\n };\n\n if (needsMetadata) {\n result = this._getMetadata(path).then(function (metadata) {\n if (options && (options.ifNoneMatch === '*') && metadata) {\n // if !!metadata === true, the file exists\n return Promise.resolve({\n statusCode: 412,\n revision: metadata.rev\n });\n }\n\n if (options && options.ifMatch && metadata && (metadata.rev !== options.ifMatch)) {\n return Promise.resolve({\n statusCode: 412,\n revision: metadata.rev\n });\n }\n\n return self._uploadSimple(uploadParams);\n });\n } else {\n result = self._uploadSimple(uploadParams);\n }\n\n return result.then(function (ret) {\n self._shareIfNeeded(path);\n return ret;\n });\n },\n\n /**\n * Checks for the path in ``_revCache`` and decides based on that if file\n * has changed.\n *\n * Compatible with ``WireClient.delete``\n *\n * Calls ``Dropbox.share`` afterwards to fill ``_itemRefs``.\n *\n * @param {string} path - path of the folder to delete, with leading slash\n * @param {Object} options\n *\n * @protected\n */\n 'delete': function (path, options) {\n if (!this.connected) {\n throw new Error(\"not connected (path: \" + path + \")\");\n }\n\n //check if file has changed and return 412\n var savedRev = this._revCache.get(path);\n if (options && options.ifMatch && savedRev && (options.ifMatch !== savedRev)) {\n return Promise.resolve({ statusCode: 412, revision: savedRev });\n }\n\n if (options && options.ifMatch) {\n return this._getMetadata(path).then((metadata) => {\n if (options && options.ifMatch && metadata && (metadata.rev !== options.ifMatch)) {\n return Promise.resolve({\n statusCode: 412,\n revision: metadata.rev\n });\n }\n\n return this._deleteSimple(path);\n });\n }\n\n return this._deleteSimple(path);\n },\n\n /**\n * Calls share, if the provided path resides in a public folder.\n *\n * @private\n */\n _shareIfNeeded: function (path) {\n if (path.match(/^\\/public\\/.*[^/]$/) && this._itemRefs[path] === undefined) {\n this.share(path);\n }\n },\n\n /**\n * Gets a publicly-accessible URL for the path from Dropbox and stores it\n * in ``_itemRefs``.\n *\n * @return {Promise} a promise for the URL\n *\n * @private\n */\n share: function (path) {\n var url = 'https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings';\n var options = {\n body: {path: getDropboxPath(path)}\n };\n\n return this._request('POST', url, options).then((response) => {\n if (response.status !== 200 && response.status !== 409) {\n return Promise.reject(new Error('Invalid response status:' + response.status));\n }\n\n var body;\n\n try {\n body = JSON.parse(response.responseText);\n } catch (e) {\n return Promise.reject(new Error('Invalid response body: ' + response.responseText));\n }\n\n if (response.status === 409) {\n if (compareApiError(body, ['shared_link_already_exists'])) {\n return this._getSharedLink(path);\n }\n\n return Promise.reject(new Error('API error: ' + body.error_summary));\n }\n\n return Promise.resolve(body.url);\n }).then((link) => {\n this._itemRefs[path] = link;\n\n if (hasLocalStorage) {\n localStorage.setItem(SETTINGS_KEY+':shares', JSON.stringify(this._itemRefs));\n }\n\n return Promise.resolve(link);\n }, (error) => {\n error.message = 'Sharing Dropbox file or folder (\"' + path + '\") failed: ' + error.message;\n return Promise.reject(error);\n });\n },\n\n /**\n * Fetches the user's info from dropbox and returns a promise for it.\n *\n * @return {Promise} a promise for user info object (email - the user's email address)\n *\n * @protected\n */\n info: function () {\n var url = 'https://api.dropboxapi.com/2/users/get_current_account';\n\n return this._request('POST', url, {}).then(function (response) {\n var info = response.responseText;\n\n try {\n info = JSON.parse(info);\n } catch (e) {\n return Promise.reject(new Error('Could not query current account info: Invalid API response: ' + info));\n }\n\n return Promise.resolve({\n email: info.email\n });\n });\n },\n\n /**\n * Make a network request.\n *\n * @param {string} method - Request method\n * @param {string} url - Target URL\n * @param {object} options - Request options\n * @returns {Promise} Resolves with the response of the network request\n *\n * @private\n */\n _request: function (method, url, options) {\n var self = this;\n\n if (!options.headers) {\n options.headers = {};\n }\n options.headers['Authorization'] = 'Bearer ' + this.token;\n\n if (typeof options.body === 'object' && !isBinaryData(options.body)) {\n options.body = JSON.stringify(options.body);\n options.headers['Content-Type'] = 'application/json; charset=UTF-8';\n }\n\n this.rs._emit('wire-busy', {\n method: method,\n isFolder: isFolder(url)\n });\n\n return WireClient.request.call(this, method, url, options).then(function(xhr) {\n // 503 means retry this later\n if (xhr && xhr.status === 503) {\n if (self.online) {\n self.online = false;\n self.rs._emit('network-offline');\n }\n return setTimeout(self._request(method, url, options), 3210);\n } else {\n if (!self.online) {\n self.online = true;\n self.rs._emit('network-online');\n }\n self.rs._emit('wire-done', {\n method: method,\n isFolder: isFolder(url),\n success: true\n });\n\n return Promise.resolve(xhr);\n }\n }, function(error) {\n if (self.online) {\n self.online = false;\n self.rs._emit('network-offline');\n }\n self.rs._emit('wire-done', {\n method: method,\n isFolder: isFolder(url),\n success: false\n });\n\n return Promise.reject(error);\n });\n },\n\n /**\n * Fetches the revision of all the files from dropbox API and puts them\n * into ``_revCache``. These values can then be used to determine if\n * something has changed.\n *\n * @private\n */\n fetchDelta: function () {\n var args = Array.prototype.slice.call(arguments);\n var self = this;\n\n var fetch = function (cursor) {\n let url = 'https://api.dropboxapi.com/2/files/list_folder';\n let requestBody;\n\n if (typeof cursor === 'string') {\n url += '/continue';\n requestBody = { cursor };\n } else {\n requestBody = {\n path: PATH_PREFIX,\n recursive: true,\n include_deleted: true\n };\n }\n\n return self._request('POST', url, { body: requestBody }).then(function (response) {\n if (response.status === 401) {\n self.rs._emit('error', new Authorize.Unauthorized());\n return Promise.resolve(args);\n }\n\n if (response.status !== 200 && response.status !== 409) {\n return Promise.reject(new Error('Invalid response status: ' + response.status));\n }\n\n let responseBody;\n\n try {\n responseBody = JSON.parse(response.responseText);\n } catch (e) {\n return Promise.reject(new Error('Invalid response body: ' + response.responseText));\n }\n\n if (response.status === 409) {\n if (compareApiError(responseBody, ['path', 'not_found'])) {\n responseBody = {\n cursor: null,\n entries: [],\n has_more: false\n };\n } else {\n return Promise.reject(new Error('API returned an error: ' + responseBody.error_summary));\n }\n }\n\n responseBody.entries.forEach(function (entry) {\n var path = entry.path_lower.substr(PATH_PREFIX.length);\n\n if (entry['.tag'] === 'deleted') {\n // there's no way to know whether the entry was a file or a folder\n self._revCache.set(path, null);\n self._revCache.set(path + '/', null);\n } else if (entry['.tag'] === 'file') {\n self._revCache.set(path, entry.rev);\n }\n });\n\n if (responseBody.has_more) {\n return fetch(responseBody.cursor);\n }\n }).catch((error) => {\n if (error === 'timeout' || error instanceof ProgressEvent) {\n // Offline is handled elsewhere already, just ignore it here\n return Promise.resolve();\n } else {\n return Promise.reject(error);\n }\n });\n };\n\n // Dropbox will always send the complete file list\n self._revCache = new LowerCaseCache('rev');\n\n return fetch().then(undefined, function (error) {\n if (typeof(error) === 'object' && 'message' in error) {\n error.message = 'Dropbox: fetchDelta: ' + error.message;\n } else {\n error = `Dropbox: fetchDelta: ${error}`;\n }\n return Promise.reject(error);\n }).then(function () {\n if (self._revCache) {\n self._revCache._activatePropagation();\n }\n return Promise.resolve(args);\n });\n },\n\n /**\n * Gets metadata for a path (can point to either a file or a folder).\n *\n * @param {string} path - the path to get metadata for\n *\n * @returns {Promise} A promise for the metadata\n *\n * @private\n */\n _getMetadata: function (path) {\n const url = 'https://api.dropboxapi.com/2/files/get_metadata';\n const requestBody = {\n path: getDropboxPath(path)\n };\n\n return this._request('POST', url, { body: requestBody }).then((response) => {\n if (response.status !== 200 && response.status !== 409) {\n return Promise.reject(new Error('Invalid response status:' + response.status));\n }\n\n let responseBody;\n\n try {\n responseBody = JSON.parse(response.responseText);\n } catch (e) {\n return Promise.reject(new Error('Invalid response body: ' + response.responseText));\n }\n\n if (response.status === 409) {\n if (compareApiError(responseBody, ['path', 'not_found'])) {\n return Promise.resolve();\n }\n\n return Promise.reject(new Error('API error: ' + responseBody.error_summary));\n }\n\n return Promise.resolve(responseBody);\n }).then(undefined, (error) => {\n error.message = 'Could not load metadata for file or folder (\"' + path + '\"): ' + error.message;\n return Promise.reject(error);\n });\n },\n\n /**\n * Upload a simple file (the size is no more than 150MB).\n *\n * @param {Object} params\n * @param {string} options.ifMatch - Only update the file if its ETag\n * matches this string\n * @param {string} options.path - path of the file\n * @param {string} options.body - contents of the file to upload\n * @param {string} options.contentType - mime type of the file\n *\n * @return {Promise} A promise for an object with the following structure:\n * statusCode - HTTP status code\n * revision - revision of the newly-created file, if any\n *\n * @private\n */\n _uploadSimple: function (params) {\n var url = 'https://content.dropboxapi.com/2/files/upload';\n var args = {\n path: getDropboxPath(params.path),\n mode: {'.tag': 'overwrite'},\n mute: true\n };\n\n if (params.ifMatch) {\n args.mode = {'.tag': 'update', update: params.ifMatch};\n }\n\n return this._request('POST', url, {\n body: params.body,\n headers: {\n 'Content-Type': 'application/octet-stream',\n 'Dropbox-API-Arg': JSON.stringify(args)\n }\n }).then((response) => {\n if (response.status !== 200 && response.status !== 409) {\n return Promise.resolve({statusCode: response.status});\n }\n\n var body = response.responseText;\n\n try {\n body = JSON.parse(body);\n } catch (e) {\n return Promise.reject(new Error('Invalid API result: ' + body));\n }\n\n if (response.status === 409) {\n if (compareApiError(body, ['path', 'conflict'])) {\n return this._getMetadata(params.path).then(function (metadata) {\n return Promise.resolve({\n statusCode: 412,\n revision: metadata.rev\n });\n });\n }\n return Promise.reject(new Error('API error: ' + body.error_summary));\n }\n\n this._revCache.propagateSet(params.path, body.rev);\n\n return Promise.resolve({ statusCode: response.status, revision: body.rev });\n });\n },\n\n /**\n * Deletes a file or a folder.\n *\n * @param {string} path - the path to delete\n *\n * @returns {Promise} A promise for an object with the following structure:\n * statusCode - HTTP status code\n *\n * @private\n */\n _deleteSimple: function (path) {\n const url = 'https://api.dropboxapi.com/2/files/delete';\n const requestBody = { path: getDropboxPath(path) };\n\n return this._request('POST', url, { body: requestBody }).then((response) => {\n if (response.status !== 200 && response.status !== 409) {\n return Promise.resolve({statusCode: response.status});\n }\n\n var responseBody = response.responseText;\n\n try {\n responseBody = JSON.parse(responseBody);\n } catch (e) {\n return Promise.reject(new Error('Invalid response body: ' + responseBody));\n }\n\n if (response.status === 409) {\n if (compareApiError(responseBody, ['path_lookup', 'not_found'])) {\n return Promise.resolve({statusCode: 404});\n }\n return Promise.reject(new Error('API error: ' + responseBody.error_summary));\n }\n\n return Promise.resolve({statusCode: 200});\n }).then((result) => {\n if (result.statusCode === 200 || result.statusCode === 404) {\n this._revCache.delete(path);\n delete this._itemRefs[path];\n }\n return Promise.resolve(result);\n }, (error) => {\n error.message = 'Could not delete Dropbox file or folder (\"' + path + '\"): ' + error.message;\n return Promise.reject(error);\n });\n },\n\n /**\n * Requests the link for an already-shared file or folder.\n *\n * @param {string} path - path to the file or folder\n *\n * @returns {Promise} A promise for the shared link\n *\n * @private\n */\n _getSharedLink: function (path) {\n var url = 'https://api.dropbox.com/2/sharing/list_shared_links';\n var options = {\n body: {\n path: getDropboxPath(path),\n direct_only: true\n }\n };\n\n return this._request('POST', url, options).then((response) => {\n if (response.status !== 200 && response.status !== 409) {\n return Promise.reject(new Error('Invalid response status: ' + response.status));\n }\n\n var body;\n\n try {\n body = JSON.parse(response.responseText);\n } catch (e) {\n return Promise.reject(new Error('Invalid response body: ' + response.responseText));\n }\n\n if (response.status === 409) {\n return Promise.reject(new Error('API error: ' + response.error_summary));\n }\n\n if (!body.links.length) {\n return Promise.reject(new Error('No links returned'));\n }\n\n return Promise.resolve(body.links[0].url);\n }, (error) => {\n error.message = 'Could not get link to a shared file or folder (\"' + path + '\"): ' + error.message;\n return Promise.reject(error);\n });\n }\n};\n\n/**\n * Hooking the sync\n *\n * TODO: document\n */\nfunction hookSync(rs) {\n if (rs._dropboxOrigSync) { return; } // already hooked\n rs._dropboxOrigSync = rs.sync.sync.bind(rs.sync);\n rs.sync.sync = function () {\n return this.dropbox.fetchDelta.apply(this.dropbox, arguments).\n then(rs._dropboxOrigSync, function (err) {\n rs._emit('error', new Sync.SyncError(err));\n return Promise.reject(err);\n });\n }.bind(rs);\n}\n\n/**\n * Unhooking the sync\n *\n * TODO: document\n */\nfunction unHookSync(rs) {\n if (! rs._dropboxOrigSync) { return; } // not hooked\n rs.sync.sync = rs._dropboxOrigSync;\n delete rs._dropboxOrigSync;\n}\n\n/**\n * Overwrite BaseClient's getItemURL with our own implementation\n *\n * TODO: getItemURL still needs to be implemented\n *\n * @param {object} rs - RemoteStorage instance\n *\n * @private\n */\nfunction hookGetItemURL (rs) {\n if (rs._origBaseClientGetItemURL) { return; }\n rs._origBaseClientGetItemURL = BaseClient.prototype.getItemURL;\n BaseClient.prototype.getItemURL = function (/*path*/) {\n throw new Error('getItemURL is not implemented for Dropbox yet');\n };\n}\n\n/**\n * Restore BaseClient's getItemURL original implementation\n *\n * @param {object} rs - RemoteStorage instance\n *\n * @private\n */\nfunction unHookGetItemURL(rs){\n if (! rs._origBaseClientGetItemURL) { return; }\n BaseClient.prototype.getItemURL = rs._origBaseClientGetItemURL;\n delete rs._origBaseClientGetItemURL;\n}\n\n/**\n * TODO: document\n */\nfunction hookRemote(rs){\n if (rs._origRemote) { return; }\n rs._origRemote = rs.remote;\n rs.remote = rs.dropbox;\n}\n\n/**\n * TODO: document\n */\nfunction unHookRemote(rs){\n if (rs._origRemote) {\n rs.remote = rs._origRemote;\n delete rs._origRemote;\n }\n}\n\n/**\n * TODO: document\n */\nfunction hookIt(rs){\n hookRemote(rs);\n if (rs.sync) {\n hookSync(rs);\n } else {\n // when sync is not available yet, we wait for the remote to be connected,\n // at which point sync should be available as well\n rs.on('connected', function() {\n if (rs.sync) {\n hookSync(rs);\n }\n });\n }\n hookGetItemURL(rs);\n}\n\n/**\n * TODO: document\n */\nfunction unHookIt(rs){\n unHookRemote(rs);\n unHookSync(rs);\n unHookGetItemURL(rs);\n}\n\n/**\n * Initialize the Dropbox backend.\n *\n * @param {object} remoteStorage - RemoteStorage instance\n *\n * @protected\n */\nDropbox._rs_init = function (rs) {\n hasLocalStorage = util.localStorageAvailable();\n if ( rs.apiKeys.dropbox ) {\n rs.dropbox = new Dropbox(rs);\n }\n if (rs.backend === 'dropbox') {\n hookIt(rs);\n }\n};\n\n/**\n * Inform about the availability of the Dropbox backend.\n *\n * @param {object} rs - RemoteStorage instance\n * @returns {Boolean}\n *\n * @protected\n */\nDropbox._rs_supported = function () {\n return true;\n};\n\n/**\n * Remove Dropbox as a backend.\n *\n * @param {object} remoteStorage - RemoteStorage instance\n *\n * @protected\n */\nDropbox._rs_cleanup = function (rs) {\n unHookIt(rs);\n if (hasLocalStorage){\n localStorage.removeItem(SETTINGS_KEY);\n }\n rs.setBackend(undefined);\n};\n\n\nmodule.exports = Dropbox;\n","'use strict';\n\nconst util = require('./util');\nconst Dropbox = require('./dropbox');\nconst GoogleDrive = require('./googledrive');\nconst Discover = require('./discover');\nconst BaseClient = require('./baseclient');\nconst config = require('./config');\nconst Authorize = require('./authorize');\nconst Sync = require('./sync');\nconst log = require('./log');\nconst Features = require('./features');\nconst globalContext = util.getGlobalContext();\nconst eventHandling = require('./eventhandling');\n\nvar hasLocalStorage;\n\n// TODO document and/or refactor (seems weird)\nfunction emitUnauthorized(r) {\n if (r.statusCode === 403 || r.statusCode === 401) {\n this._emit('error', new Authorize.Unauthorized());\n }\n return Promise.resolve(r);\n}\n\n/**\n * Constructor for the remoteStorage object.\n *\n * This class primarily contains feature detection code and convenience API.\n *\n * Depending on which features are built in, it contains different attributes\n * and functions. See the individual features for more information.\n *\n * @param {object} config - an optional configuration object\n * @class\n */\nvar RemoteStorage = function (cfg) {\n\n // Initial configuration property settings.\n if (typeof cfg === 'object') {\n util.extend(config, cfg);\n }\n\n eventHandling(this,\n 'ready', 'authing', 'connecting', 'connected', 'disconnected',\n 'not-connected', 'conflict', 'error', 'features-loaded',\n 'sync-interval-change', 'sync-req-done', 'sync-done',\n 'wire-busy', 'wire-done', 'network-offline', 'network-online'\n );\n\n /**\n * Pending get/put/delete calls\n *\n * @private\n */\n this._pending = [];\n\n /**\n * TODO: document\n *\n * @private\n */\n this._setGPD({\n get: this._pendingGPD('get'),\n put: this._pendingGPD('put'),\n delete: this._pendingGPD('delete')\n });\n\n /**\n * TODO: document\n *\n * @private\n */\n this._cleanups = [];\n\n /**\n * TODO: document\n *\n * @private\n */\n this._pathHandlers = { change: {} };\n\n /**\n * Holds OAuth app keys for Dropbox, Google Drive\n *\n * @private\n */\n this.apiKeys = {};\n\n hasLocalStorage = util.localStorageAvailable();\n\n if (hasLocalStorage) {\n try {\n this.apiKeys = JSON.parse(localStorage.getItem('remotestorage:api-keys')) || {};\n } catch(exc) {\n // ignored\n }\n this.setBackend(localStorage.getItem('remotestorage:backend') || 'remotestorage');\n }\n\n // Keep a reference to the orginal `on` function\n var origOn = this.on;\n\n /**\n * Register an event handler. See :ref:`rs-events` for available event names.\n *\n * @param {string} eventName - Name of the event\n * @param {function} handler - Event handler\n */\n this.on = function (eventName, handler) {\n if (this._allLoaded) {\n // check if the handler should be called immediately, because the\n // event has happened already\n switch(eventName) {\n case 'features-loaded':\n setTimeout(handler, 0);\n break;\n case 'ready':\n if (this.remote) {\n setTimeout(handler, 0);\n }\n break;\n case 'connected':\n if (this.remote && this.remote.connected) {\n setTimeout(handler, 0);\n }\n break;\n case 'not-connected':\n if (this.remote && !this.remote.connected) {\n setTimeout(handler, 0);\n }\n break;\n }\n }\n\n return origOn.call(this, eventName, handler);\n };\n\n // load all features and emit `ready`\n this._init();\n\n /**\n * TODO: document\n */\n this.fireInitial = function () {\n if (this.local) {\n setTimeout(this.local.fireInitial.bind(this.local), 0);\n }\n }.bind(this);\n\n this.on('ready', this.fireInitial.bind(this));\n this.loadModules();\n};\n\n// FIXME: Instead of doing this, would be better to only\n// export setAuthURL / getAuthURL from RemoteStorage prototype\nRemoteStorage.Authorize = Authorize;\n\nRemoteStorage.SyncError = Sync.SyncError;\nRemoteStorage.Unauthorized = Authorize.Unauthorized;\nRemoteStorage.DiscoveryError = Discover.DiscoveryError;\n\nRemoteStorage.prototype = {\n\n /**\n * Load all modules passed as arguments\n *\n * @private\n */\n loadModules: function loadModules() {\n config.modules.forEach(this.addModule.bind(this));\n },\n\n /**\n * TODO: document\n *\n * @param {string} authUrl\n * @param {string} cordovaRedirectUri\n */\n authorize: function authorize(authURL, cordovaRedirectUri) {\n this.access.setStorageType(this.remote.storageApi);\n var scope = this.access.scopeParameter;\n\n var redirectUri = globalContext.cordova ? cordovaRedirectUri : String(Authorize.getLocation());\n\n var clientId = redirectUri.match(/^(https?:\\/\\/[^/]+)/)[0];\n\n Authorize(this, authURL, scope, redirectUri, clientId);\n },\n\n /**\n * TODO: document\n *\n * @private\n */\n impliedauth: function (storageApi, redirectUri) {\n storageApi = this.remote.storageApi;\n redirectUri = String(document.location);\n\n log('ImpliedAuth proceeding due to absent authURL; storageApi = ' + storageApi + ' redirectUri = ' + redirectUri);\n // Set a fixed access token, signalling to not send it as Bearer\n this.remote.configure({\n token: Authorize.IMPLIED_FAKE_TOKEN\n });\n document.location = redirectUri;\n },\n\n /**\n * @property {object} remote\n *\n * Depending on the chosen backend, this is either an instance of ``WireClient``,\n * ``Dropbox`` or ``GoogleDrive``.\n *\n * @property {boolean} remote.connected - Whether or not a remote store is connected\n * @property {boolean} remote.online - Whether last sync action was successful or not\n * @property {string} remote.userAddress - The user address of the connected user\n * @property {string} remote.properties - The properties of the WebFinger link\n */\n\n /**\n * Connect to a remoteStorage server.\n *\n * Discovers the WebFinger profile of the given user address and initiates\n * the OAuth dance.\n *\n * This method must be called *after* all required access has been claimed.\n * When using the connect widget, it will call this method itself.\n *\n * Special cases:\n *\n * 1. If a bearer token is supplied as second argument, the OAuth dance\n * will be skipped and the supplied token be used instead. This is\n * useful outside of browser environments, where the token has been\n * acquired in a different way.\n *\n * 2. If the Webfinger profile for the given user address doesn't contain\n * an auth URL, the library will assume that client and server have\n * established authorization among themselves, which will omit bearer\n * tokens in all requests later on. This is useful for example when using\n * Kerberos and similar protocols.\n *\n * @param {string} userAddress - The user address (user@host) to connect to.\n * @param {string} token - (optional) A bearer token acquired beforehand\n */\n connect: function (userAddress, token) {\n this.setBackend('remotestorage');\n if (userAddress.indexOf('@') < 0) {\n this._emit('error', new RemoteStorage.DiscoveryError(\"User address doesn't contain an @.\"));\n return;\n }\n\n if (globalContext.cordova) {\n if (typeof config.cordovaRedirectUri !== 'string') {\n this._emit('error', new RemoteStorage.DiscoveryError(\"Please supply a custom HTTPS redirect URI for your Cordova app\"));\n return;\n }\n if (!globalContext.cordova.InAppBrowser) {\n this._emit('error', new RemoteStorage.DiscoveryError(\"Please include the InAppBrowser Cordova plugin to enable OAuth\"));\n return;\n }\n }\n\n this.remote.configure({\n userAddress: userAddress\n });\n this._emit('connecting');\n\n var discoveryTimeout = setTimeout(function () {\n this._emit('error', new RemoteStorage.DiscoveryError(\"No storage information found for this user address.\"));\n }.bind(this), config.discoveryTimeout);\n\n Discover(userAddress).then(info => {\n // Info contains fields: href, storageApi, authURL (optional), properties\n\n clearTimeout(discoveryTimeout);\n this._emit('authing');\n info.userAddress = userAddress;\n this.remote.configure(info);\n if (! this.remote.connected) {\n if (info.authURL) {\n if (typeof token === 'undefined') {\n // Normal authorization step; the default way to connect\n this.authorize(info.authURL, config.cordovaRedirectUri);\n } else if (typeof token === 'string') {\n // Token supplied directly by app/developer/user\n log('Skipping authorization sequence and connecting with known token');\n this.remote.configure({ token: token });\n } else {\n throw new Error(\"Supplied bearer token must be a string\");\n }\n } else {\n // In lieu of an excplicit authURL, assume that the browser and\n // server handle any authorization needs; for instance, TLS may\n // trigger the browser to use a client certificate, or a 401 Not\n // Authorized response may make the browser send a Kerberos ticket\n // using the SPNEGO method.\n this.impliedauth();\n }\n }\n }, (/*err*/) => {\n clearTimeout(discoveryTimeout);\n this._emit('error', new RemoteStorage.DiscoveryError(\"No storage information found for this user address.\"));\n });\n },\n\n /**\n * Reconnect the remote server to get a new authorization.\n */\n reconnect: function () {\n this.remote.configure({ token: null });\n\n if (this.backend === 'remotestorage') {\n this.connect(this.remote.userAddress);\n } else {\n this.remote.connect();\n }\n },\n\n /**\n * \"Disconnect\" from remote server to terminate current session.\n *\n * This method clears all stored settings and deletes the entire local\n * cache.\n */\n disconnect: function () {\n if (this.remote) {\n this.remote.configure({\n userAddress: null,\n href: null,\n storageApi: null,\n token: null,\n properties: null\n });\n }\n this._setGPD({\n get: this._pendingGPD('get'),\n put: this._pendingGPD('put'),\n delete: this._pendingGPD('delete')\n });\n var n = this._cleanups.length, i = 0;\n\n var oneDone = function () {\n i++;\n if (i >= n) {\n this._init();\n log('Done cleaning up, emitting disconnected and disconnect events');\n this._emit('disconnected');\n }\n }.bind(this);\n\n if (n > 0) {\n this._cleanups.forEach(function (cleanup) {\n var cleanupResult = cleanup(this);\n if (typeof(cleanupResult) === 'object' && typeof(cleanupResult.then) === 'function') {\n cleanupResult.then(oneDone);\n } else {\n oneDone();\n }\n }.bind(this));\n } else {\n oneDone();\n }\n },\n\n /**\n * TODO: document\n *\n * @private\n */\n setBackend: function (what) {\n this.backend = what;\n if (hasLocalStorage) {\n if (what) {\n localStorage.setItem('remotestorage:backend', what);\n } else {\n localStorage.removeItem('remotestorage:backend');\n }\n }\n },\n\n /**\n * Add a \"change\" event handler to the given path. Whenever a \"change\"\n * happens (as determined by the backend, such as e.g.\n * ) and the affected path is equal to or below the\n * given 'path', the given handler is called.\n *\n * You should usually not use this method directly, but instead use the\n * \"change\" events provided by :doc:`BaseClient `\n *\n * @param {string} path - Absolute path to attach handler to\n * @param {function} handler - Handler function\n */\n onChange: function (path, handler) {\n if (! this._pathHandlers.change[path]) {\n this._pathHandlers.change[path] = [];\n }\n this._pathHandlers.change[path].push(handler);\n },\n\n /**\n * TODO: do we still need this, now that we always instantiate the prototype?\n *\n * Enable remoteStorage logging.\n */\n enableLog: function () {\n config.logging = true;\n },\n\n /**\n * TODO: do we still need this, now that we always instantiate the prototype?\n *\n * Disable remoteStorage logging\n */\n disableLog: function () {\n config.logging = false;\n },\n\n /**\n * log\n *\n * The same as .\n */\n log: function () {\n log.apply(RemoteStorage, arguments);\n },\n\n /**\n * Set the OAuth key/ID for either GoogleDrive or Dropbox backend support.\n *\n * @param {Object} apiKeys - A config object with these properties:\n * @param {string} [apiKeys.type] - Backend type: 'googledrive' or 'dropbox'\n * @param {string} [apiKeys.key] - Client ID for GoogleDrive, or app key for Dropbox\n */\n setApiKeys: function (apiKeys) {\n const validTypes = ['googledrive', 'dropbox'];\n if (typeof apiKeys !== 'object' || !Object.keys(apiKeys).every(type => validTypes.includes(type))) {\n console.error('setApiKeys() was called with invalid arguments') ;\n return false;\n }\n\n Object.keys(apiKeys).forEach(type => {\n let key = apiKeys[type];\n if (!key) { delete this.apiKeys[type]; return; }\n\n switch(type) {\n case 'dropbox':\n this.apiKeys['dropbox'] = { appKey: key };\n if (typeof this.dropbox === 'undefined' ||\n this.dropbox.clientId !== key) {\n Dropbox._rs_init(this);\n }\n break;\n case 'googledrive':\n this.apiKeys['googledrive'] = { clientId: key };\n if (typeof this.googledrive === 'undefined' ||\n this.googledrive.clientId !== key) {\n GoogleDrive._rs_init(this);\n }\n break;\n }\n return true;\n });\n\n if (hasLocalStorage) {\n localStorage.setItem('remotestorage:api-keys', JSON.stringify(this.apiKeys));\n }\n },\n\n /**\n * Set redirect URI to be used for the OAuth redirect within the\n * in-app-browser window in Cordova apps.\n *\n * @param {string} uri - A valid HTTP(S) URI\n */\n setCordovaRedirectUri: function (uri) {\n if (typeof uri !== 'string' || !uri.match(/http(s)?:\\/\\//)) {\n throw new Error(\"Cordova redirect URI must be a URI string\");\n }\n config.cordovaRedirectUri = uri;\n },\n\n\n //\n // FEATURES INITIALIZATION\n //\n\n _init: Features.loadFeatures,\n features: Features.features,\n loadFeature: Features.loadFeature,\n featureSupported: Features.featureSupported,\n featureDone: Features.featureDone,\n featuresDone: Features.featuresDone,\n featuresLoaded: Features.featuresLoaded,\n featureInitialized: Features.featureInitialized,\n featureFailed: Features.featureFailed,\n hasFeature: Features.hasFeature,\n _setCachingModule: Features._setCachingModule,\n _collectCleanupFunctions: Features._collectCleanupFunctions,\n _fireReady: Features._fireReady,\n initFeature: Features.initFeature,\n\n //\n // GET/PUT/DELETE INTERFACE HELPERS\n //\n\n /**\n * TODO: document\n *\n * @private\n */\n _setGPD: function (impl, context) {\n function wrap(func) {\n return function () {\n return func.apply(context, arguments)\n .then(emitUnauthorized.bind(this));\n };\n }\n this.get = wrap(impl.get);\n this.put = wrap(impl.put);\n this.delete = wrap(impl.delete);\n },\n\n /**\n * TODO: document\n *\n * @private\n */\n _pendingGPD: function (methodName) {\n return function () {\n var methodArguments = Array.prototype.slice.call(arguments);\n return new Promise(function(resolve, reject) {\n this._pending.push({\n method: methodName,\n args: methodArguments,\n promise: {\n resolve: resolve,\n reject: reject\n }\n });\n }.bind(this));\n }.bind(this);\n },\n\n /**\n * TODO: document\n *\n * @private\n */\n _processPending: function () {\n this._pending.forEach(function (pending) {\n try {\n this[pending.method].apply(this, pending.args).then(pending.promise.resolve, pending.promise.reject);\n } catch(e) {\n pending.promise.reject(e);\n }\n }.bind(this));\n this._pending = [];\n },\n\n //\n // CHANGE EVENT HANDLING\n //\n\n /**\n * TODO: document\n *\n * @private\n */\n _bindChange: function (object) {\n object.on('change', this._dispatchEvent.bind(this, 'change'));\n },\n\n /**\n * TODO: document\n *\n * @private\n */\n _dispatchEvent: function (eventName, event) {\n var self = this;\n Object.keys(this._pathHandlers[eventName]).forEach(function (path) {\n var pl = path.length;\n if (event.path.substr(0, pl) === path) {\n self._pathHandlers[eventName][path].forEach(function (handler) {\n var ev = {};\n for (var key in event) { ev[key] = event[key]; }\n ev.relativePath = event.path.replace(new RegExp('^' + path), '');\n try {\n handler(ev);\n } catch(e) {\n console.error(\"'change' handler failed: \", e, e.stack);\n self._emit('error', e);\n }\n });\n }\n });\n },\n\n /**\n * This method enables you to quickly instantiate a BaseClient, which you can\n * use to directly read and manipulate data in the connected storage account.\n *\n * Please use this method only for debugging and development, and choose or\n * create a :doc:`data module ` for your app to use.\n *\n * @param {string} path - The base directory of the BaseClient that will be\n * returned (with a leading and a trailing slash)\n *\n * @returns {BaseClient} A client with the specified scope (category/base directory)\n */\n scope: function (path) {\n if (typeof(path) !== 'string') {\n throw 'Argument \\'path\\' of baseClient.scope must be a string';\n }\n\n if (!this.access.checkPathPermission(path, 'r')) {\n var escapedPath = path.replace(/(['\\\\])/g, '\\\\$1');\n console.warn('WARNING: please call remoteStorage.access.claim(\\'' + escapedPath + '\\', \\'r\\') (read only) or remoteStorage.access.claim(\\'' + escapedPath + '\\', \\'rw\\') (read/write) first');\n }\n return new BaseClient(this, path);\n },\n\n\n /**\n * Get the value of the sync interval when application is in the foreground\n *\n * @returns {number} A number of milliseconds\n */\n getSyncInterval: function () {\n return config.syncInterval;\n },\n\n /**\n * Set the value of the sync interval when application is in the foreground\n *\n * @param {number} interval - Sync interval in milliseconds (between 1000 and 3600000)\n */\n setSyncInterval: function (interval) {\n if (!isValidInterval(interval)) {\n throw interval + \" is not a valid sync interval\";\n }\n var oldValue = config.syncInterval;\n config.syncInterval = parseInt(interval, 10);\n this._emit('sync-interval-change', {oldValue: oldValue, newValue: interval});\n },\n\n /**\n * Get the value of the sync interval when application is in the background\n *\n * @returns {number} A number of milliseconds\n */\n getBackgroundSyncInterval: function () {\n return config.backgroundSyncInterval;\n },\n\n /**\n * Set the value of the sync interval when the application is in the\n * background\n *\n * @param interval - Sync interval in milliseconds (between 1000 and 3600000)\n */\n setBackgroundSyncInterval: function (interval) {\n if(!isValidInterval(interval)) {\n throw interval + \" is not a valid sync interval\";\n }\n var oldValue = config.backgroundSyncInterval;\n config.backgroundSyncInterval = parseInt(interval, 10);\n this._emit('sync-interval-change', {oldValue: oldValue, newValue: interval});\n },\n\n /**\n * Get the value of the current sync interval. Can be background or\n * foreground, custom or default.\n *\n * @returns {number} A number of milliseconds\n */\n getCurrentSyncInterval: function () {\n return config.isBackground ? config.backgroundSyncInterval : config.syncInterval;\n },\n\n /**\n * Get the value of the current network request timeout\n *\n * @returns {number} A number of milliseconds\n */\n getRequestTimeout: function () {\n return config.requestTimeout;\n },\n\n /**\n * Set the timeout for network requests.\n *\n * @param timeout - Timeout in milliseconds\n */\n setRequestTimeout: function (timeout) {\n config.requestTimeout = parseInt(timeout, 10);\n },\n\n /**\n * TODO: document\n *\n * @private\n */\n syncCycle: function () {\n if (!this.sync || this.sync.stopped) {\n return;\n }\n\n this.on('sync-done', function () {\n log('[Sync] Sync done. Setting timer to', this.getCurrentSyncInterval());\n if (this.sync && !this.sync.stopped) {\n if (this._syncTimer) {\n clearTimeout(this._syncTimer);\n this._syncTimer = undefined;\n }\n this._syncTimer = setTimeout(this.sync.sync.bind(this.sync), this.getCurrentSyncInterval());\n }\n }.bind(this));\n\n this.sync.sync();\n },\n\n /**\n * Start synchronization with remote storage, downloading and uploading any\n * changes within the cached paths.\n *\n * Please consider: local changes will attempt sync immediately, and remote\n * changes should also be synced timely when using library defaults. So\n * this is mostly useful for letting users sync manually, when pressing a\n * sync button for example. This might feel safer to them sometimes, esp.\n * when shifting between offline and online a lot.\n *\n * @returns {Promise} A Promise which resolves when the sync has finished\n */\n startSync: function () {\n if (!config.cache) {\n console.warn('Nothing to sync, because caching is disabled.');\n return Promise.resolve();\n }\n this.sync.stopped = false;\n this.syncStopped = false;\n return this.sync.sync();\n },\n\n /**\n * Stop the periodic synchronization.\n */\n stopSync: function () {\n clearTimeout(this._syncTimer);\n this._syncTimer = undefined;\n\n if (this.sync) {\n log('[Sync] Stopping sync');\n this.sync.stopped = true;\n } else {\n // The sync class has not been initialized yet, so we make sure it will\n // not start the syncing process as soon as it's initialized.\n log('[Sync] Will instantiate sync stopped');\n this.syncStopped = true;\n }\n }\n\n};\n\n\n/**\n* Check if interval is valid: numeric and between 1000ms and 3600000ms\n*\n* @private\n*/\nfunction isValidInterval(interval) {\n return (typeof interval === 'number' &&\n interval > 1000 &&\n interval < 3600000);\n}\n\nRemoteStorage.util = util;\n\n/**\n * @property connected\n *\n * Boolean property indicating if remoteStorage is currently connected.\n */\nObject.defineProperty(RemoteStorage.prototype, 'connected', {\n get: function () {\n return this.remote.connected;\n }\n});\n\n/**\n * @property access\n *\n * Tracking claimed access scopes. A instance.\n*/\nvar Access = require('./access');\nObject.defineProperty(RemoteStorage.prototype, 'access', {\n get: function() {\n var access = new Access();\n Object.defineProperty(this, 'access', {\n value: access\n });\n return access;\n },\n configurable: true\n});\n\n// TODO Clean up/harmonize how modules are loaded and/or document this architecture properly\n//\n// At this point the remoteStorage object has not been created yet.\n// Only its prototype exists so far, so we define a self-constructing\n// property on there:\n\n/**\n * Property: caching\n *\n * Caching settings. A instance.\n */\n\n// FIXME Was in rs_init of Caching but don't want to require RemoteStorage from there.\nvar Caching = require('./caching');\nObject.defineProperty(RemoteStorage.prototype, 'caching', {\n configurable: true,\n get: function () {\n var caching = new Caching();\n Object.defineProperty(this, 'caching', {\n value: caching\n });\n return caching;\n }\n});\n\n/*\n * @property local\n *\n * Access to the local caching backend used. Usually either a\n * or instance.\n *\n * Not available, when caching is turned off.\n */\n\nmodule.exports = RemoteStorage;\nrequire('./modules');\n","var BaseClient = require('./baseclient');\nvar RemoteStorage = require('./remotestorage');\n\n/*\n * Add remoteStorage data module\n *\n * @param {Object} module - module object needs following properies:\n * @param {string} [module.name] - Name of the module\n * @param {function} [module.builder] - Builder function defining the module\n *\n * The module builder function should return an object containing another\n * object called exports, which will be exported to this \n * instance under the module's name. So when defining a locations module,\n * like in the example below, it would be accessible via\n * `remoteStorage.locations`, which would in turn have a `features` and a\n * `collections` property.\n *\n * The function receives a private and a public client, which are both\n * instances of . In the following example, the\n * scope of privateClient is `/locations` and the scope of publicClient is\n * `/public/locations`.\n *\n * @example\n * RemoteStorage.addModule({name: 'locations', builder: function (privateClient, publicClient) {\n * return {\n * exports: {\n * features: privateClient.scope('features/').defaultType('feature'),\n * collections: privateClient.scope('collections/').defaultType('feature-collection')\n * }\n * };\n * }});\n*/\nRemoteStorage.prototype.addModule = function (module) {\n var moduleName = module.name;\n var moduleBuilder = module.builder;\n Object.defineProperty(this, moduleName, {\n configurable: true,\n get: function () {\n var instance = this._loadModule(moduleName, moduleBuilder);\n Object.defineProperty(this, moduleName, {\n value: instance\n });\n return instance;\n }\n });\n\n if (moduleName.indexOf('-') !== -1) {\n var camelizedName = moduleName.replace(/\\-[a-z]/g, function (s) {\n return s[1].toUpperCase();\n });\n Object.defineProperty(this, camelizedName, {\n get: function () {\n return this[moduleName];\n }\n });\n }\n};\n\n/*\n * Load module\n *\n * @private\n *\n */\nRemoteStorage.prototype._loadModule = function (moduleName, moduleBuilder) {\n if (moduleBuilder) {\n var module = moduleBuilder(new BaseClient(this, '/' + moduleName + '/'),\n new BaseClient(this, '/public/' + moduleName + '/'));\n return module.exports;\n } else {\n throw \"Unknown module: \" + moduleName;\n }\n};\n","var eventHandling = require('./eventhandling');\nvar log = require('./log');\nvar cachingLayer = require('./cachinglayer');\n/**\n * In-memory caching adapter. Used when no IndexedDB or localStorage\n * available.\n *\n * @class\n **/\nvar InMemoryStorage = function () {\n cachingLayer(this);\n log('[InMemoryStorage] Registering events');\n eventHandling(this, 'change', 'local-events-done');\n\n this._storage = {};\n};\n\nInMemoryStorage.prototype = {\n\n getNodes: function (paths) {\n var nodes = {};\n\n for(var i = 0, len = paths.length; i < len; i++) {\n nodes[paths[i]] = this._storage[paths[i]];\n }\n\n return Promise.resolve(nodes);\n },\n\n setNodes: function (nodes) {\n for (var path in nodes) {\n if (nodes[path] === undefined) {\n delete this._storage[path];\n } else {\n this._storage[path] = nodes[path];\n }\n }\n\n return Promise.resolve();\n },\n\n forAllNodes: function (cb) {\n for (var path in this._storage) {\n cb(this.migrate(this._storage[path]));\n }\n return Promise.resolve();\n }\n\n};\n\n/**\n * Initialize the InMemoryStorage backend.\n *\n * @param {Object} remoteStorage - RemoteStorage instance\n *\n * @protected\n */\nInMemoryStorage._rs_init = function () {};\n\n/**\n * Inform about the availability of the InMemoryStorage backend.\n *\n * @returns {Boolean}\n *\n * @protected\n */\nInMemoryStorage._rs_supported = function () {\n // In-memory storage is always supported\n return true;\n};\n\n/**\n * Remove InMemoryStorage as a backend.\n *\n * @protected\n */\nInMemoryStorage._rs_cleanup = function () {};\n\nmodule.exports = InMemoryStorage;\n","const cachingLayer = require('./cachinglayer');\nconst log = require('./log');\nconst eventHandling = require('./eventhandling');\nconst util = require('./util');\n\n/**\n * localStorage caching adapter. Used when no IndexedDB available.\n **/\n\nconst NODES_PREFIX = \"remotestorage:cache:nodes:\";\nconst CHANGES_PREFIX = \"remotestorage:cache:changes:\";\n\nconst LocalStorage = function () {\n cachingLayer(this);\n log('[LocalStorage] Registering events');\n eventHandling(this, 'change', 'local-events-done');\n};\n\nfunction isRemoteStorageKey(key) {\n return key.substr(0, NODES_PREFIX.length) === NODES_PREFIX ||\n key.substr(0, CHANGES_PREFIX.length) === CHANGES_PREFIX;\n}\n\nfunction isNodeKey(key) {\n return key.substr(0, NODES_PREFIX.length) === NODES_PREFIX;\n}\n\nLocalStorage.prototype = {\n\n getNodes: function (paths) {\n var nodes = {};\n\n for(var i = 0, len = paths.length; i < len; i++) {\n try {\n nodes[paths[i]] = JSON.parse(localStorage[NODES_PREFIX+paths[i]]);\n } catch(e) {\n nodes[paths[i]] = undefined;\n }\n }\n\n return Promise.resolve(nodes);\n },\n\n setNodes: function (nodes) {\n for (var path in nodes) {\n // TODO shouldn't we use getItem/setItem?\n localStorage[NODES_PREFIX+path] = JSON.stringify(nodes[path]);\n }\n\n return Promise.resolve();\n },\n\n forAllNodes: function (cb) {\n var node;\n\n for(var i = 0, len = localStorage.length; i < len; i++) {\n if (isNodeKey(localStorage.key(i))) {\n try {\n node = this.migrate(JSON.parse(localStorage[localStorage.key(i)]));\n } catch(e) {\n node = undefined;\n }\n if (node) {\n cb(node);\n }\n }\n }\n return Promise.resolve();\n }\n\n};\n\n/**\n * Initialize the LocalStorage backend.\n *\n * @protected\n */\nLocalStorage._rs_init = function () {};\n\n/**\n * Inform about the availability of the LocalStorage backend.\n *\n * @returns {Boolean}\n *\n * @protected\n */\nLocalStorage._rs_supported = function () {\n return util.localStorageAvailable();\n};\n\n/**\n * Remove LocalStorage as a backend.\n *\n * @protected\n *\n * TODO: tests missing!\n */\nLocalStorage._rs_cleanup = function () {\n let keys = [];\n\n for (var i = 0, len = localStorage.length; i < len; i++) {\n let key = localStorage.key(i);\n if (isRemoteStorageKey(key)) {\n keys.push(key);\n }\n }\n\n keys.forEach(function (key) {\n log('[LocalStorage] Removing', key);\n delete localStorage[key];\n });\n};\n\nmodule.exports = LocalStorage;\n","/**\n * TODO rewrite, doesn't expose GPD anymore, it's in cachinglayer now\n *\n * This file exposes a get/put/delete interface, accessing data in an IndexedDB.\n *\n * There are multiple parts to this interface:\n *\n * The RemoteStorage integration:\n * - IndexedDB._rs_supported() determines if IndexedDB support\n * is available. If it isn't, RemoteStorage won't initialize the feature.\n * - IndexedDB._rs_init() initializes the feature. It returns\n * a promise that is fulfilled as soon as the database has been opened and\n * migrated.\n *\n * The storage interface (IndexedDB object):\n * - Usually this is accessible via \"remoteStorage.local\"\n * - #get() takes a path and returns a promise.\n * - #put() takes a path, body and contentType and also returns a promise.\n * - #delete() takes a path and also returns a promise.\n * - #on('change', ...) events, being fired whenever something changes in\n * the storage. Change events roughly follow the StorageEvent pattern.\n * They have \"oldValue\" and \"newValue\" properties, which can be used to\n * distinguish create/update/delete operations and analyze changes in\n * change handlers. In addition they carry a \"origin\" property, which\n * is either \"window\", \"local\", or \"remote\". \"remote\" events are fired\n * whenever a change comes in from Sync.\n *\n * The sync interface (also on IndexedDB object):\n * - #getNodes([paths]) returns the requested nodes in a promise.\n * - #setNodes(map) stores all the nodes given in the (path -> node) map.\n *\n * @interface\n */\n\nvar log = require('./log');\nvar cachingLayer = require('./cachinglayer');\nvar eventHandling = require('./eventhandling');\nvar util = require('./util');\n\nvar DB_VERSION = 2;\n\nvar DEFAULT_DB_NAME = 'remotestorage';\nvar DEFAULT_DB;\n\nvar IndexedDB = function (database) {\n this.db = database || DEFAULT_DB;\n\n if (!this.db) {\n log(\"[IndexedDB] Failed to open DB\");\n return undefined;\n }\n\n cachingLayer(this);\n eventHandling(this, 'change', 'local-events-done');\n\n this.getsRunning = 0;\n this.putsRunning = 0;\n\n /**\n * Given a node for which uncommitted changes exist, this cache\n * stores either the entire uncommitted node, or false for a deletion.\n * The node's path is used as the key.\n *\n * changesQueued stores changes for which no IndexedDB transaction has\n * been started yet.\n */\n this.changesQueued = {};\n\n /**\n * Given a node for which uncommitted changes exist, this cache\n * stores either the entire uncommitted node, or false for a deletion.\n * The node's path is used as the key.\n *\n * At any time there is at most one IndexedDB transaction running.\n * changesRunning stores the changes that are included in that currently\n * running IndexedDB transaction, or if none is running, of the last one\n * that ran.\n */\n this.changesRunning = {};\n};\n\nIndexedDB.prototype = {\n /**\n * TODO: Document\n */\n getNodes: function (paths) {\n var misses = [], fromCache = {};\n for (let i = 0, len = paths.length; i < len; i++) {\n if (this.changesQueued[paths[i]] !== undefined) {\n fromCache[paths[i]] = util.deepClone(this.changesQueued[paths[i]] || undefined);\n } else if(this.changesRunning[paths[i]] !== undefined) {\n fromCache[paths[i]] = util.deepClone(this.changesRunning[paths[i]] || undefined);\n } else {\n misses.push(paths[i]);\n }\n }\n if (misses.length > 0) {\n return this.getNodesFromDb(misses).then(function (nodes) {\n for (let i in fromCache) {\n nodes[i] = fromCache[i];\n }\n return nodes;\n });\n } else {\n return Promise.resolve(fromCache);\n }\n },\n\n /**\n * TODO: Document\n */\n setNodes: function (nodes) {\n for (var i in nodes) {\n this.changesQueued[i] = nodes[i] || false;\n }\n this.maybeFlush();\n return Promise.resolve();\n },\n\n /**\n * TODO: Document\n */\n maybeFlush: function () {\n if (this.putsRunning === 0) {\n this.flushChangesQueued();\n } else {\n if (!this.commitSlownessWarning) {\n this.commitSlownessWarning = setInterval(function () {\n console.warn('WARNING: waited more than 10 seconds for previous commit to finish');\n }, 10000);\n }\n }\n },\n\n /**\n * TODO: Document\n */\n flushChangesQueued: function () {\n if (this.commitSlownessWarning) {\n clearInterval(this.commitSlownessWarning);\n this.commitSlownessWarning = null;\n }\n if (Object.keys(this.changesQueued).length > 0) {\n this.changesRunning = this.changesQueued;\n this.changesQueued = {};\n this.setNodesInDb(this.changesRunning).then(this.flushChangesQueued.bind(this));\n }\n },\n\n /**\n * TODO: Document\n */\n getNodesFromDb: function (paths) {\n return new Promise((resolve, reject) => {\n\n let transaction = this.db.transaction(['nodes'], 'readonly');\n let nodes = transaction.objectStore('nodes');\n let retrievedNodes = {};\n\n this.getsRunning++;\n\n paths.map(function (path) {\n nodes.get(path).onsuccess = function (evt) {\n retrievedNodes[path] = evt.target.result;\n };\n });\n\n transaction.oncomplete = function () {\n resolve(retrievedNodes);\n this.getsRunning--;\n }.bind(this);\n\n transaction.onerror = transaction.onabort = function () {\n reject('get transaction error/abort');\n this.getsRunning--;\n }.bind(this);\n\n });\n },\n\n /**\n * TODO: Document\n */\n setNodesInDb: function (nodes) {\n return new Promise((resolve, reject) => {\n\n let transaction = this.db.transaction(['nodes'], 'readwrite');\n let nodesStore = transaction.objectStore('nodes');\n let startTime = new Date().getTime();\n\n this.putsRunning++;\n\n log('[IndexedDB] Starting put', nodes, this.putsRunning);\n\n for (var path in nodes) {\n var node = nodes[path];\n if(typeof(node) === 'object') {\n try {\n nodesStore.put(node);\n } catch(e) {\n log('[IndexedDB] Error while putting', node, e);\n throw e;\n }\n } else {\n try {\n nodesStore.delete(path);\n } catch(e) {\n log('[IndexedDB] Error while removing', nodesStore, node, e);\n throw e;\n }\n }\n }\n\n transaction.oncomplete = function () {\n this.putsRunning--;\n log('[IndexedDB] Finished put', nodes, this.putsRunning, (new Date().getTime() - startTime)+'ms');\n resolve();\n }.bind(this);\n\n transaction.onerror = function () {\n this.putsRunning--;\n reject('transaction error');\n }.bind(this);\n\n transaction.onabort = function () {\n reject('transaction abort');\n this.putsRunning--;\n }.bind(this);\n\n });\n },\n\n /**\n * TODO: Document\n */\n reset: function (callback) {\n let dbName = this.db.name;\n\n this.db.close();\n\n IndexedDB.clean(this.db.name, () => {\n IndexedDB.open(dbName, (err, other) => {\n if (err) {\n log('[IndexedDB] Error while resetting local storage', err);\n } else {\n // hacky!\n this.db = other;\n }\n if (typeof callback === 'function') { callback(self); }\n });\n });\n },\n\n /**\n * TODO: Document\n */\n forAllNodes: function (cb) {\n return new Promise((resolve/*, reject*/) => {\n\n let transaction = this.db.transaction(['nodes'], 'readonly');\n let cursorReq = transaction.objectStore('nodes').openCursor();\n\n cursorReq.onsuccess = (evt) => {\n let cursor = evt.target.result;\n\n if (cursor) {\n cb(this.migrate(cursor.value));\n cursor.continue();\n } else {\n resolve();\n }\n };\n });\n },\n\n closeDB: function () {\n if (this.putsRunning === 0) { // check if we are currently writing to the DB\n this.db.close();\n } else {\n setTimeout(this.closeDB.bind(this), 100); // try again a little later\n }\n }\n\n};\n\n/**\n * TODO: Document\n */\nIndexedDB.open = function (name, callback) {\n var timer = setTimeout(function () {\n callback(\"timeout trying to open db\");\n }, 10000);\n\n try {\n var req = indexedDB.open(name, DB_VERSION);\n\n req.onerror = function () {\n log('[IndexedDB] Opening DB failed', req);\n\n clearTimeout(timer);\n callback(req.error);\n };\n\n req.onupgradeneeded = function (event) {\n var db = req.result;\n\n log(\"[IndexedDB] Upgrade: from \", event.oldVersion, \" to \", event.newVersion);\n\n if (event.oldVersion !== 1) {\n log(\"[IndexedDB] Creating object store: nodes\");\n db.createObjectStore('nodes', { keyPath: 'path' });\n }\n\n log(\"[IndexedDB] Creating object store: changes\");\n\n db.createObjectStore('changes', { keyPath: 'path' });\n };\n\n req.onsuccess = function () {\n clearTimeout(timer);\n\n // check if all object stores exist\n var db = req.result;\n if(!db.objectStoreNames.contains('nodes') || !db.objectStoreNames.contains('changes')) {\n log(\"[IndexedDB] Missing object store. Resetting the database.\");\n IndexedDB.clean(name, function() {\n IndexedDB.open(name, callback);\n });\n return;\n }\n\n callback(null, req.result);\n };\n } catch(error) {\n log(\"[IndexedDB] Failed to open database: \" + error);\n log(\"[IndexedDB] Resetting database and trying again.\");\n\n clearTimeout(timer);\n\n IndexedDB.clean(name, function() {\n IndexedDB.open(name, callback);\n });\n }\n};\n\n/**\n * TODO: Document\n */\nIndexedDB.clean = function (databaseName, callback) {\n var req = indexedDB.deleteDatabase(databaseName);\n\n req.onsuccess = function () {\n log('[IndexedDB] Done removing DB');\n callback();\n };\n\n req.onerror = req.onabort = function (evt) {\n console.error('Failed to remove database \"' + databaseName + '\"', evt);\n };\n};\n\n/**\n * Initialize the IndexedDB backend.\n *\n * @param {Object} remoteStorage - RemoteStorage instance\n *\n * @protected\n */\nIndexedDB._rs_init = function (remoteStorage) {\n\n return new Promise((resolve, reject) => {\n\n IndexedDB.open(DEFAULT_DB_NAME, function (err, db) {\n if (err) {\n reject(err);\n } else {\n DEFAULT_DB = db;\n db.onerror = function () { remoteStorage._emit('error', err); };\n resolve();\n }\n });\n\n });\n};\n\n/**\n * Inform about the availability of the IndexedDB backend.\n *\n * @param {Object} rs - RemoteStorage instance\n * @returns {Boolean}\n *\n * @protected\n */\nIndexedDB._rs_supported = function () {\n return new Promise((resolve, reject) => {\n\n var context = util.getGlobalContext();\n\n // FIXME: this is causing an error in chrome\n // context.indexedDB = context.indexedDB || context.webkitIndexedDB ||\n // context.mozIndexedDB || context.oIndexedDB ||\n // context.msIndexedDB;\n\n // Detect browsers with known IndexedDb issues (e.g. Android pre-4.4)\n var poorIndexedDbSupport = false;\n if (typeof navigator !== 'undefined' &&\n navigator.userAgent.match(/Android (2|3|4\\.[0-3])/)) {\n // Chrome and Firefox support IndexedDB\n if (!navigator.userAgent.match(/Chrome|Firefox/)) {\n poorIndexedDbSupport = true;\n }\n }\n\n if ('indexedDB' in context && !poorIndexedDbSupport) {\n try {\n var check = indexedDB.open(\"rs-check\");\n check.onerror = function (/* event */) {\n reject();\n };\n check.onsuccess = function (/* event */) {\n check.result.close();\n indexedDB.deleteDatabase(\"rs-check\");\n resolve();\n };\n } catch(e) {\n reject();\n }\n } else {\n reject();\n }\n\n });\n};\n\n/**\n * Remove IndexedDB as a backend.\n *\n * @param {Object} remoteStorage - RemoteStorage instance\n *\n * @protected\n */\nIndexedDB._rs_cleanup = function (remoteStorage) {\n return new Promise((resolve/*, reject*/) => {\n if (remoteStorage.local) {\n remoteStorage.local.closeDB();\n }\n\n IndexedDB.clean(DEFAULT_DB_NAME, resolve);\n\n });\n};\n\n\nmodule.exports = IndexedDB;\n","const log = require('./log');\n\nfunction shareFirst(path) {\n return ( this.backend === 'dropbox' &&\n path.match(/^\\/public\\/.*[^\\/]$/) );\n}\n\nfunction maxAgeInvalid(maxAge) {\n return maxAge !== false && typeof(maxAge) !== 'number';\n}\n\nvar SyncedGetPutDelete = {\n get: function (path, maxAge) {\n if (this.local) {\n if (maxAge === undefined) {\n if ((typeof this.remote === 'object') &&\n this.remote.connected && this.remote.online) {\n maxAge = 2*this.getSyncInterval();\n } else {\n log('Not setting default maxAge, because remote is offline or not connected');\n maxAge = false;\n }\n }\n\n if (maxAgeInvalid(maxAge)) {\n return Promise.reject('Argument \\'maxAge\\' must be false or a number');\n }\n return this.local.get(path, maxAge, this.sync.queueGetRequest.bind(this.sync));\n } else {\n return this.remote.get(path);\n }\n },\n\n put: function (path, body, contentType) {\n if (shareFirst.bind(this)(path)) {\n return SyncedGetPutDelete._wrapBusyDone.call(this, this.remote.put(path, body, contentType));\n }\n else if (this.local) {\n return this.local.put(path, body, contentType);\n } else {\n return SyncedGetPutDelete._wrapBusyDone.call(this, this.remote.put(path, body, contentType));\n }\n },\n\n 'delete': function (path) {\n if (this.local) {\n return this.local.delete(path);\n } else {\n return SyncedGetPutDelete._wrapBusyDone.call(this, this.remote.delete(path));\n }\n },\n\n _wrapBusyDone: function (result) {\n var self = this;\n this._emit('wire-busy');\n return result.then(function (r) {\n self._emit('wire-done', { success: true });\n return Promise.resolve(r);\n }, function (err) {\n self._emit('wire-done', { success: false });\n return Promise.reject(err);\n });\n }\n};\n\nmodule.exports = SyncedGetPutDelete;\n","'use strict';\n\nconst util = require('./util');\nconst log = require('./log');\nconst SyncedGetPutDelete = require('./syncedgetputdelete');\nconst config = require('./config');\n\nconst Features = {\n features: [],\n featuresDone: 0,\n readyFired: false,\n\n loadFeatures () {\n this.features = [];\n this.featuresDone = 0;\n this.readyFired = false;\n\n this.featureModules = {\n 'WireClient': require('./wireclient'),\n 'Dropbox': require('./dropbox'),\n 'GoogleDrive': require('./googledrive'),\n 'Access': require('./access'),\n 'Discover': require('./discover'),\n 'Authorize': require('./authorize'),\n 'BaseClient': require('./baseclient'),\n 'Env': require('./env')\n };\n\n // enable caching related modules if needed\n if (config.cache) {\n util.extend( this.featureModules, {\n 'Caching': require('./caching'),\n 'IndexedDB': require('./indexeddb'),\n 'LocalStorage': require('./localstorage'),\n 'InMemoryStorage': require('./inmemorystorage'),\n 'Sync': require('./sync')\n });\n }\n\n // disable features set in the config object passed to the RemoteStorage\n // constructor\n // For example: ['IndexedDB']\n config.disableFeatures.forEach( feature => {\n if (this.featureModules[feature]) {\n // this.featureModules[feature] = undefined\n delete this.featureModules[feature];\n }\n\n });\n\n this._allLoaded = false;\n\n for (let featureName in this.featureModules) {\n // FIXME: this has to push the promised return value into an\n // array of promises and use Promise.all to emit `ready`\n // instead of increment a counter of loaded features. -les\n this.loadFeature(featureName);\n }\n },\n\n\n\n /**\n * Method: hasFeature\n *\n * Checks whether a feature is enabled or not within remoteStorage.\n * Returns a boolean.\n *\n * Parameters:\n * name - Capitalized name of the feature. e.g. Authorize, or IndexedDB\n *\n * Example:\n * (start code)\n * if (remoteStorage.hasFeature('LocalStorage')) {\n * console.log('LocalStorage is enabled!');\n * }\n * (end code)\n *\n */\n hasFeature (feature) {\n for (var i = this.features.length - 1; i >= 0; i--) {\n if (this.features[i].name === feature) {\n return this.features[i].supported;\n }\n }\n return false;\n },\n\n\n loadFeature (featureName) {\n const feature = this.featureModules[featureName];\n let supported = !feature._rs_supported || feature._rs_supported();\n\n log(`[RemoteStorage] [FEATURE ${featureName}] initializing ...`);\n\n if (typeof supported === 'object') {\n supported.then( () => {\n this.featureSupported(featureName, true);\n this.initFeature(featureName);\n }, () => {\n this.featureSupported(featureName, false);\n });\n } else if (typeof supported === 'boolean') {\n this.featureSupported(featureName, supported);\n if (supported) {\n this.initFeature(featureName);\n }\n } else {\n this.featureSupported(featureName, false);\n }\n },\n\n initFeature (featureName) {\n const feature = this.featureModules[featureName];\n let initResult;\n try {\n initResult = feature._rs_init(this);\n } catch(e) {\n this.featureFailed(featureName, e);\n return;\n }\n\n if (typeof(initResult) === 'object' && typeof(initResult.then) === 'function') {\n initResult.then(\n () => { this.featureInitialized(featureName); },\n (err) => { this.featureFailed(featureName, err); }\n );\n } else {\n this.featureInitialized(featureName);\n }\n },\n\n featureFailed (featureName, err) {\n log(`[RemoteStorage] [FEATURE ${featureName}] initialization failed (${err})`);\n this.featureDone();\n },\n\n\n featureSupported (featureName, success) {\n log(`[RemoteStorage] [FEATURE ${featureName}] ${success ? '' : ' not'} supported`);\n if (!success) {\n this.featureDone();\n }\n },\n\n featureInitialized (featureName) {\n log(`[RemoteStorage] [FEATURE ${featureName}] initialized.`);\n this.features.push({\n name : featureName,\n init : this.featureModules[featureName]._rs_init,\n supported : true,\n cleanup : this.featureModules[featureName]._rs_cleanup\n });\n this.featureDone();\n },\n\n featureDone () {\n this.featuresDone++;\n if (this.featuresDone === Object.keys(this.featureModules).length) {\n setTimeout(this.featuresLoaded.bind(this), 0);\n }\n },\n\n _setCachingModule () {\n const cachingModules = ['IndexedDB', 'LocalStorage', 'InMemoryStorage'];\n\n cachingModules.some( cachingLayer => {\n if (this.features.some(feature => feature.name === cachingLayer)) {\n this.features.local = this.featureModules[cachingLayer];\n return true;\n }\n });\n },\n\n\n _fireReady() {\n try {\n if (!this.readyFired) {\n this._emit('ready');\n this.readyFired = true;\n }\n } catch(e) {\n console.error(\"'ready' failed: \", e, e.stack);\n this._emit('error', e);\n }\n },\n\n featuresLoaded () {\n log(`[REMOTESTORAGE] All features loaded !`);\n\n this._setCachingModule();\n // eslint-disable-next-line new-cap\n this.local = config.cache && this.features.local && new this.features.local();\n\n // this.remote set by WireClient._rs_init as lazy property on\n // RS.prototype\n\n if (this.local && this.remote) {\n this._setGPD(SyncedGetPutDelete, this);\n this._bindChange(this.local);\n } else if (this.remote) {\n this._setGPD(this.remote, this.remote);\n }\n if (this.remote) {\n this.remote.on('connected', () => {\n this._fireReady();\n this._emit('connected');\n });\n this.remote.on('not-connected', () => {\n this._fireReady();\n this._emit('not-connected');\n });\n if (this.remote.connected) {\n this._fireReady();\n this._emit('connected');\n }\n\n if (!this.hasFeature('Authorize')) {\n this.remote.stopWaitingForToken();\n }\n }\n\n this._collectCleanupFunctions();\n\n try {\n this._allLoaded = true;\n this._emit('features-loaded');\n } catch(exc) {\n util.logError(exc);\n this._emit('error', exc);\n }\n this._processPending();\n },\n\n _collectCleanupFunctions () {\n this._cleanups = [];\n for (let i=0; i < this.features.length; i++) {\n let cleanup = this.features[i].cleanup;\n if (typeof(cleanup) === 'function') {\n this._cleanups.push(cleanup);\n }\n }\n }\n\n};\n\nmodule.exports = Features;\n","module.exports = XMLHttpRequest;\n","/* global define */\n/*!\n * webfinger.js\n * version 2.6.6\n * http://github.com/silverbucket/webfinger.js\n *\n * Developed and Maintained by:\n * Nick Jennings 2012\n *\n * webfinger.js is released under the AGPL (see LICENSE).\n *\n * You don't have to do anything special to choose one license or the other and you don't\n * have to notify anyone which license you are using.\n * Please see the corresponding license file for details of these licenses.\n * You are free to use, modify and distribute this software, but all copyright\n * information must remain.\n *\n */\n\nif (typeof XMLHttpRequest === 'undefined') {\n // XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;\n XMLHttpRequest = require('xhr2');\n}\n\n(function (global) {\n\n // URI to property name map\n var LINK_URI_MAPS = {\n 'http://webfist.org/spec/rel': 'webfist',\n 'http://webfinger.net/rel/avatar': 'avatar',\n 'remotestorage': 'remotestorage',\n 'http://tools.ietf.org/id/draft-dejong-remotestorage': 'remotestorage',\n 'remoteStorage': 'remotestorage',\n 'http://www.packetizer.com/rel/share': 'share',\n 'http://webfinger.net/rel/profile-page': 'profile',\n 'me': 'profile',\n 'vcard': 'vcard',\n 'blog': 'blog',\n 'http://packetizer.com/rel/blog': 'blog',\n 'http://schemas.google.com/g/2010#updates-from': 'updates',\n 'https://camlistore.org/rel/server': 'camilstore'\n };\n\n var LINK_PROPERTIES = {\n 'avatar': [],\n 'remotestorage': [],\n 'blog': [],\n 'vcard': [],\n 'updates': [],\n 'share': [],\n 'profile': [],\n 'webfist': [],\n 'camlistore': []\n };\n\n // list of endpoints to try, fallback from beginning to end.\n var URIS = ['webfinger', 'host-meta', 'host-meta.json'];\n\n function generateErrorObject(obj) {\n obj.toString = function () {\n return this.message;\n };\n return obj;\n }\n\n // given a URL ensures it's HTTPS.\n // returns false for null string or non-HTTPS URL.\n function isSecure(url) {\n if (typeof url !== 'string') {\n return false;\n }\n var parts = url.split('://');\n if (parts[0] === 'https') {\n return true;\n }\n return false;\n }\n\n /**\n * Function: WebFinger\n *\n * WebFinger constructor\n *\n * Returns:\n *\n * return WebFinger object\n */\n function WebFinger(config) {\n if (typeof config !== 'object') {\n config = {};\n }\n\n this.config = {\n tls_only: (typeof config.tls_only !== 'undefined') ? config.tls_only : true,\n webfist_fallback: (typeof config.webfist_fallback !== 'undefined') ? config.webfist_fallback : false,\n uri_fallback: (typeof config.uri_fallback !== 'undefined') ? config.uri_fallback : false,\n request_timeout: (typeof config.request_timeout !== 'undefined') ? config.request_timeout : 10000\n };\n }\n\n // make an http request and look for JRD response, fails if request fails\n // or response not json.\n WebFinger.prototype.__fetchJRD = function (url, errorHandler, sucessHandler) {\n var self = this;\n var handlerSpent = false;\n var xhr = new XMLHttpRequest();\n\n function __processState() {\n if (handlerSpent){\n return;\n }else{\n handlerSpent = true;\n }\n\n if (xhr.status === 200) {\n if (self.__isValidJSON(xhr.responseText)) {\n return sucessHandler(xhr.responseText);\n } else {\n return errorHandler(generateErrorObject({\n message: 'invalid json',\n url: url,\n status: xhr.status\n }));\n }\n } else if (xhr.status === 404) {\n return errorHandler(generateErrorObject({\n message: 'resource not found',\n url: url,\n status: xhr.status\n }));\n } else if ((xhr.status >= 301) && (xhr.status <= 302)) {\n var location = xhr.getResponseHeader('Location');\n if (isSecure(location)) {\n return __makeRequest(location); // follow redirect\n } else {\n return errorHandler(generateErrorObject({\n message: 'no redirect URL found',\n url: url,\n status: xhr.status\n }));\n }\n } else {\n return errorHandler(generateErrorObject({\n message: 'error during request',\n url: url,\n status: xhr.status\n }));\n }\n }\n\n function __makeRequest() {\n xhr.onreadystatechange = function () {\n if (xhr.readyState === 4) {\n __processState();\n }\n };\n\n xhr.onload = function () {\n __processState();\n };\n\n xhr.ontimeout = function () {\n return errorHandler(generateErrorObject({\n message: 'request timed out',\n url: url,\n status: xhr.status\n }));\n };\n\n xhr.open('GET', url, true);\n xhr.timeout = self.config.request_timeout;\n xhr.setRequestHeader('Accept', 'application/jrd+json, application/json');\n xhr.send();\n }\n\n return __makeRequest();\n };\n\n WebFinger.prototype.__isValidJSON = function (str) {\n try {\n JSON.parse(str);\n } catch (e) {\n return false;\n }\n return true;\n };\n\n WebFinger.prototype.__isLocalhost = function (host) {\n var local = /^localhost(\\.localdomain)?(\\:[0-9]+)?$/;\n return local.test(host);\n };\n\n // processes JRD object as if it's a webfinger response object\n // looks for known properties and adds them to profile datat struct.\n WebFinger.prototype.__processJRD = function (URL, JRD, errorHandler, successHandler) {\n var parsedJRD = JSON.parse(JRD);\n if ((typeof parsedJRD !== 'object') ||\n (typeof parsedJRD.links !== 'object')) {\n if (typeof parsedJRD.error !== 'undefined') {\n return errorHandler(generateErrorObject({ message: parsedJRD.error, request: URL }));\n } else {\n return errorHandler(generateErrorObject({ message: 'unknown response from server', request: URL }));\n }\n }\n\n var links = parsedJRD.links;\n if (!Array.isArray(links)) {\n links = [];\n }\n var result = { // webfinger JRD - object, json, and our own indexing\n object: parsedJRD,\n json: JRD,\n idx: {}\n };\n\n result.idx.properties = {\n 'name': undefined\n };\n result.idx.links = JSON.parse(JSON.stringify(LINK_PROPERTIES));\n\n // process links\n links.map(function (link, i) {\n if (LINK_URI_MAPS.hasOwnProperty(link.rel)) {\n if (result.idx.links[LINK_URI_MAPS[link.rel]]) {\n var entry = {};\n Object.keys(link).map(function (item, n) {\n entry[item] = link[item];\n });\n result.idx.links[LINK_URI_MAPS[link.rel]].push(entry);\n }\n }\n });\n\n // process properties\n var props = JSON.parse(JRD).properties;\n for (var key in props) {\n if (props.hasOwnProperty(key)) {\n if (key === 'http://packetizer.com/ns/name') {\n result.idx.properties.name = props[key];\n }\n }\n }\n return successHandler(result);\n };\n\n WebFinger.prototype.lookup = function (address, cb) {\n if (typeof address !== 'string') {\n throw new Error('first parameter must be a user address');\n } else if (typeof cb !== 'function') {\n throw new Error('second parameter must be a callback');\n }\n\n var self = this;\n var host = '';\n if (address.indexOf('://') > -1) {\n // other uri format\n host = address.replace(/ /g,'').split('/')[2];\n } else {\n // useraddress\n host = address.replace(/ /g,'').split('@')[1];\n }\n var uri_index = 0; // track which URIS we've tried already\n var protocol = 'https'; // we use https by default\n\n if (self.__isLocalhost(host)) {\n protocol = 'http';\n }\n\n function __buildURL() {\n var uri = '';\n if (! address.split('://')[1]) {\n // the URI has not been defined, default to acct\n uri = 'acct:';\n }\n return protocol + '://' + host + '/.well-known/' +\n URIS[uri_index] + '?resource=' + uri + address;\n }\n\n // control flow for failures, what to do in various cases, etc.\n function __fallbackChecks(err) {\n if ((self.config.uri_fallback) && (host !== 'webfist.org') && (uri_index !== URIS.length - 1)) { // we have uris left to try\n uri_index = uri_index + 1;\n return __call();\n } else if ((!self.config.tls_only) && (protocol === 'https')) { // try normal http\n uri_index = 0;\n protocol = 'http';\n return __call();\n } else if ((self.config.webfist_fallback) && (host !== 'webfist.org')) { // webfist attempt\n uri_index = 0;\n protocol = 'http';\n host = 'webfist.org';\n // webfist will\n // 1. make a query to the webfist server for the users account\n // 2. from the response, get a link to the actual webfinger json data\n // (stored somewhere in control of the user)\n // 3. make a request to that url and get the json\n // 4. process it like a normal webfinger response\n var URL = __buildURL();\n self.__fetchJRD(URL, cb, function (data) { // get link to users JRD\n self.__processJRD(URL, data, cb, function (result) {\n if ((typeof result.idx.links.webfist === 'object') &&\n (typeof result.idx.links.webfist[0].href === 'string')) {\n self.__fetchJRD(result.idx.links.webfist[0].href, cb, function (JRD) {\n self.__processJRD(URL, JRD, cb, function (result) {\n return cb(null, cb);\n });\n });\n }\n });\n });\n } else {\n return cb(err);\n }\n }\n\n function __call() {\n // make request\n var URL = __buildURL();\n self.__fetchJRD(URL, __fallbackChecks, function (JRD) {\n self.__processJRD(URL, JRD, cb, function (result) { cb(null, result); });\n });\n }\n\n return setTimeout(__call, 0);\n };\n\n WebFinger.prototype.lookupLink = function (address, rel, cb) {\n if (LINK_PROPERTIES.hasOwnProperty(rel)) {\n this.lookup(address, function (err, p) {\n var links = p.idx.links[rel];\n if (err) {\n return cb(err);\n } else if (links.length === 0) {\n return cb('no links found with rel=\"' + rel + '\"');\n } else {\n return cb(null, links[0]);\n }\n });\n } else {\n return cb('unsupported rel ' + rel);\n }\n };\n\n\n\n // AMD support\n if (typeof define === 'function' && define.amd) {\n define([], function () { return WebFinger; });\n // CommonJS and Node.js module support.\n } else if (typeof exports !== 'undefined') {\n // Support Node.js specific `module.exports` (which can be a function)\n if (typeof module !== 'undefined' && module.exports) {\n exports = module.exports = WebFinger;\n }\n // But always support CommonJS module 1.1.1 spec (`exports` cannot be a function)\n exports.WebFinger = WebFinger;\n } else {\n // browser