diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..c8825d03c --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,17 @@ +# 1.9.0 + +## Features +* Implement new roles functionalities (`KuzzleSecurity.isActionAllowed`, `KuzzleSecurity.getMyRights`, `KuzzleSecurity.getUserRights`) +* Implement the elasticsearch autorefresh features (`Kuzzle.refreshIndex`, `Kuzzle.getAutoRefresh`, `Kuzzle.setAutoRefresh`) +* Implement the `Kuzzle.updateSelf` method that allow to update current user +* Fix issues #81, #82, #73 & #76 + +## List of merged PR +* Merge pull request #88 from kuzzleio/KUZ-574-getRights-methods - _Sébastien Cottinet_ +* Merge pull request #90 from kuzzleio/rename-policies - _Kévin Blondel_ +* Merge pull request #85 from kuzzleio/fix-rc-83-update-and-delete-consistency - _Sébastien Cottinet_ +* Merge pull request #87 from kuzzleio/KUZ-480-isActionAllowed - _Sébastien Cottinet_ +* Merge pull request #86 from kuzzleio/fix-rc-81-refactor-factory-signature - _Kévin Blondel_ +* Merge pull request #84 from kuzzleio/fix-rc-73-paginate-fetchAll - _Sébastien Cottinet_ +* Merge pull request #83 from kuzzleio/fix-rc-76-secure-dataCollectionFactory - _Kévin Blondel_ +* Merge pull request #80 from kuzzleio/kuz-463-es-autorefresh - _Sébastien Cottinet_ diff --git a/dist/kuzzle.js b/dist/kuzzle.js index a2338bd41..9a76f9c0d 100644 --- a/dist/kuzzle.js +++ b/dist/kuzzle.js @@ -1410,6 +1410,136 @@ Kuzzle.prototype.getServerInfo = function (options, cb) { return this; }; +/** + * Forces an index refresh + * + * @param {string} index - The index to refresh. Defaults to Kuzzle.defaultIndex + * @param {object} options - Optional arguments + * @param {responseCallback} cb - Handles the query response + * @returns {Kuzzle} + */ +Kuzzle.prototype.refreshIndex = function () { + var + index, + options, + cb; + + Array.prototype.slice.call(arguments).forEach(function(arg) { + switch (typeof arg) { + case 'string': + index = arg; + break; + case 'object': + options = arg; + break; + case 'function': + cb = arg; + break; + } + }); + + if (!index) { + if (!this.defaultIndex) { + throw new Error('Kuzzle.refreshIndex: index required'); + } + index = this.defaultIndex; + } + + this.query({ index: index, controller: 'admin', action: 'refreshIndex'}, {}, options, cb); + + return this; +}; + +/** + * Returns de current autoRefresh status for the given index + * + * @param {string} index - The index to get the status from. Defaults to Kuzzle.defaultIndex + * @param {object} options - Optinal arguments + * @param {responseCallback} cb - Handles the query response + * @returns {object} this + */ +Kuzzle.prototype.getAutoRefresh = function () { + var + index, + options, + cb; + + Array.prototype.slice.call(arguments).forEach(function (arg) { + switch (typeof arg) { + case 'string': + index = arg; + break; + case 'object': + options = arg; + break; + case 'function': + cb = arg; + break; + } + }); + + if (!index) { + if (!this.defaultIndex) { + throw new Error('Kuzzle.getAutoRefresh: index required'); + } + index = this.defaultIndex; + } + + this.callbackRequired('Kuzzle.getAutoRefresh', cb); + this.query({ index: index, controller: 'admin', action: 'getAutoRefresh'}, {}, options, cb); + + return this; +}; + +/** + * (Un)Sets the autoRefresh flag on the given index + * + * @param {string} index - the index to modify. Defaults to Kuzzle.defaultIndex + * @param {boolean} autoRefresh - The autoRefresh value to set + * @param {object} options - Optional arguments + * @param {responseCallback} cb - Handles the query result + * @returns {object} this + */ +Kuzzle.prototype.setAutoRefresh = function () { + var + index, + autoRefresh, + options, + cb; + + Array.prototype.slice.call(arguments).forEach(function (arg) { + switch (typeof arg) { + case 'string': + index = arg; + break; + case 'boolean': + autoRefresh = arg; + break; + case 'object': + options = arg; + break; + case 'function': + cb = arg; + break; + } + }); + + if (!index) { + if (!this.defaultIndex) { + throw new Error('Kuzzle.setAutoRefresh: index required'); + } + index = this.defaultIndex; + } + + if (autoRefresh === undefined) { + throw new Error('Kuzzle.setAutoRefresh: autoRefresh value is required'); + } + + this.query({ index: index, controller: 'admin', action: 'setAutoRefresh'}, { body: { autoRefresh: autoRefresh }}, options, cb); + + return this; +}; + /** * Return the current Kuzzle's UTC Epoch time, in milliseconds * @param {object} [options] - Optional parameters @@ -1958,8 +2088,6 @@ KuzzleDataCollection.prototype.deleteDocument = function (arg, options, cb) { } else { this.kuzzle.query(this.buildQueryArgs('write', action), data, options); } - - return this; }; /** @@ -2564,7 +2692,7 @@ KuzzleDocument.prototype.delete = function (options, cb) { options = null; } - if (!this.id) { + if (!self.id) { throw new Error('KuzzleDocument.delete: cannot delete a document without a document ID'); } @@ -2574,13 +2702,11 @@ KuzzleDocument.prototype.delete = function (options, cb) { return cb(err); } - cb(null, self); + cb(null, self.id); }); } else { this.kuzzle.query(this.dataCollection.buildQueryArgs('write', 'delete'), this.serialize(), options); } - - return this; }; /** @@ -3805,12 +3931,12 @@ KuzzleSecurity.prototype.updateRole = function (id, content, options, cb) { data.body = content; if (cb) { - self.kuzzle.query(this.buildQueryArgs(action), data, options, function (err, res) { + self.kuzzle.query(this.buildQueryArgs(action), data, options, function (err) { if (err) { return cb(err); } - cb(null, res.result._id); + cb(null, new KuzzleRole(self, id, content)); }); } else { self.kuzzle.query(this.buildQueryArgs(action), data); @@ -4038,11 +4164,23 @@ KuzzleSecurity.prototype.updateProfile = function (id, content, options, cb) { if (cb) { self.kuzzle.query(this.buildQueryArgs(action), data, options, function (err, res) { + var updatedContent = {}; + if (err) { return cb(err); } - cb(null, res.result._id); + Object.keys(res.result._source).forEach(function (property) { + if (property !== 'roles') { + updatedContent[property] = res.result._source[property]; + } + }); + + updatedContent.roles = res.result._source.roles.map(function (role) { + return role._id; + }); + + cb(null, new KuzzleProfile(self, res.result._id, updatedContent)); }); } else { self.kuzzle.query(this.buildQueryArgs(action), data); diff --git a/dist/kuzzle.min.js b/dist/kuzzle.min.js index f47b8f0dc..483823f1d 100644 --- a/dist/kuzzle.min.js +++ b/dist/kuzzle.min.js @@ -1,4 +1,4 @@ -// Official Javascript SDK for Kuzzle v1.8.0 - License: Apache-2.0 -!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g1)for(var c=1;cb;b++)0===(3&b)&&(a=4294967296*Math.random()),e[b]=a>>>((3&b)<<3)&255;return e},"undefined"!=typeof console&&console.warn&&console.warn("[SECURITY] node-uuid: crypto not usable, falling back to insecure Math.random()")}}function e(){if("function"==typeof a)try{var b=a("crypto").randomBytes;l=j=b&&function(){return b(16)},j()}catch(c){}}function f(a,b,c){var d=b&&c||0,e=0;for(b=b||[],a.toLowerCase().replace(/[0-9a-f]{2}/g,function(a){16>e&&(b[d+e++]=q[a])});16>e;)b[d+e++]=0;return b}function g(a,b){var c=b||0,d=p;return d[a[c++]]+d[a[c++]]+d[a[c++]]+d[a[c++]]+"-"+d[a[c++]]+d[a[c++]]+"-"+d[a[c++]]+d[a[c++]]+"-"+d[a[c++]]+d[a[c++]]+"-"+d[a[c++]]+d[a[c++]]+d[a[c++]]+d[a[c++]]+d[a[c++]]+d[a[c++]]}function h(a,b,c){var d=b&&c||0,e=b||[];a=a||{};var f=null!=a.clockseq?a.clockseq:u,h=null!=a.msecs?a.msecs:(new Date).getTime(),i=null!=a.nsecs?a.nsecs:w+1,j=h-v+(i-w)/1e4;if(0>j&&null==a.clockseq&&(f=f+1&16383),(0>j||h>v)&&null==a.nsecs&&(i=0),i>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");v=h,w=i,u=f,h+=122192928e5;var k=(1e4*(268435455&h)+i)%4294967296;e[d++]=k>>>24&255,e[d++]=k>>>16&255,e[d++]=k>>>8&255,e[d++]=255&k;var l=h/4294967296*1e4&268435455;e[d++]=l>>>8&255,e[d++]=255&l,e[d++]=l>>>24&15|16,e[d++]=l>>>16&255,e[d++]=f>>>8|128,e[d++]=255&f;for(var m=a.node||t,n=0;6>n;n++)e[d+n]=m[n];return b?b:g(e)}function i(a,b,c){var d=b&&c||0;"string"==typeof a&&(b="binary"===a?new o(16):null,a=null),a=a||{};var e=a.random||(a.rng||j)();if(e[6]=15&e[6]|64,e[8]=63&e[8]|128,b)for(var f=0;16>f;f++)b[d+f]=e[f];return b||g(e)}var j,k,l,m,n;c?d():e();for(var o="function"==typeof Buffer?Buffer:Array,p=[],q={},r=0;256>r;r++)p[r]=(r+256).toString(16).substr(1),q[p[r]]=r;var s=j(),t=[1|s[0],s[1],s[2],s[3],s[4],s[5]],u=16383&(s[6]<<8|s[7]),v=0,w=0,x=i;x.v1=h,x.v4=i,x.parse=f,x.unparse=g,x.BufferClass=o,x._rng=j,x._mathRNG=k,x._nodeRNG=l,x._whatwgRNG=m,"undefined"!=typeof b&&b.exports?b.exports=x:"function"==typeof define&&define.amd?define(function(){return x}):(n=c.uuid,x.noConflict=function(){return c.uuid=n,x},c.uuid=x)}("undefined"!=typeof window?window:null)},{}],3:[function(a,b,c){(function(c){function d(){var a=this,b=Date.now(),c=-1;a.queueTTL>0&&(a.offlineQueue.forEach(function(d,e){d.ts0&&a.offlineQueue.length>a.queueMaxSize&&a.offlineQueue.splice(0,a.offlineQueue.length-a.queueMaxSize).forEach(function(b){a.emitEvent("offlineQueuePop",b.query)})}function e(a,b){var c=Date.now(),d=this;(void 0!==d.jwtToken||b)&&d.socket.once(a.requestId,function(c){"logout"!==a.action&&c.error&&"Token expired"===c.error.message&&(d.jwtToken=void 0,d.emitEvent("jwtTokenExpired",a,b)),b&&b(c.error,c)}),d.socket.emit("kuzzle",a),d.requestHistory[a.requestId]=c,Object.keys(d.requestHistory).forEach(function(a){d.requestHistory[a]0?(e.call(b,b.offlineQueue[0].query,b.offlineQueue[0].cb),b.emitEvent("offlineQueuePop",b.offlineQueue.shift()),setTimeout(function(){d()},Math.max(0,b.replayInterval))):b.queuing=!1};if(b.offlineQueueLoader){if("function"!=typeof b.offlineQueueLoader)throw new Error("Invalid value for offlineQueueLoader property. Expected: function. Got: "+typeof b.offlineQueueLoader);if(a=b.offlineQueueLoader(),!Array.isArray(a))throw new Error("Invalid value returned by the offlineQueueLoader function. Expected: array. Got: "+typeof a);b.offlineQueue=a.concat(b.offlineQueue).filter(function(a){if(!a.query||void 0===a.query.requestId||!a.query.action||!a.query.controller)throw new Error("Invalid offline queue request. One or more missing properties: requestId, action, controller.");return c.hasOwnProperty(a.query.requestId)?!1:c[a.query.requestId]=!0})}d()}function g(){var a=this;Object.keys(a.subscriptions).forEach(function(b){Object.keys(a.subscriptions[b]).forEach(function(c){var d=a.subscriptions[b][c];d.renew(d.callback)})})}var h=a("node-uuid"),i=a("./kuzzleDataCollection"),j=a("./security/kuzzleSecurity"),k=a("./kuzzleMemoryStorage"),l=a("./security/kuzzleUser");b.exports=Kuzzle=function(b,d,e){var f=this;if(!(this instanceof Kuzzle))return new Kuzzle(b,d,e);if(e||"function"!=typeof d||(e=d,d=null),!b||""===b)throw new Error("URL argument missing");return Object.defineProperties(this,{collections:{value:{},writable:!0},connectCB:{value:e},eventListeners:{value:{connected:{lastEmitted:null,listeners:[]},error:{lastEmitted:null,listeners:[]},disconnected:{lastEmitted:null,listeners:[]},reconnected:{lastEmitted:null,listeners:[]},jwtTokenExpired:{lastEmitted:null,listeners:[]},loginAttempt:{lastEmitted:null,listeners:[]},offlineQueuePush:{listeners:[]},offlineQueuePop:{listeners:[]}}},eventTimeout:{value:200},io:{value:null,writable:!0},queuing:{value:!1,writable:!0},requestHistory:{value:{},writable:!0},socket:{value:null,writable:!0},state:{value:"initializing",writable:!0},subscriptions:{value:{pending:{}},writable:!0},autoReconnect:{value:d&&"boolean"==typeof d.autoReconnect?d.autoReconnect:!0,enumerable:!0},defaultIndex:{value:d&&"string"==typeof d.defaultIndex?d.defaultIndex:void 0,writable:!0,enumerable:!0},reconnectionDelay:{value:d&&"number"==typeof d.reconnectionDelay?d.reconnectionDelay:1e3,enumerable:!0},url:{value:b,enumerable:!0},autoQueue:{value:!1,enumerable:!0,writable:!0},autoReplay:{value:!1,enumerable:!0,writable:!0},autoResubscribe:{value:!0,enumerable:!0,writable:!0},headers:{value:{},enumerable:!0,writable:!0},metadata:{value:{},enumerable:!0,writable:!0},offlineQueue:{value:[],enumerable:!0,writable:!0},queueFilter:{value:null,enumerable:!0,writable:!0},queueMaxSize:{value:500,enumerable:!0,writable:!0},queueTTL:{value:12e4,enumerable:!0,writable:!0},replayInterval:{value:10,enumerable:!0,writable:!0},jwtToken:{value:void 0,enumerable:!0,writable:!0},offlineQueueLoader:{value:null,enumerable:!0,writable:!0}}),"undefined"!=typeof window&&window.io?this.io=window.io:this.io=a("socket.io-client"),d&&(Object.keys(d).forEach(function(a){f.hasOwnProperty(a)&&Object.getOwnPropertyDescriptor(f,a).writable&&(f[a]=d[a])}),"auto"===d.offlineMode&&this.autoReconnect&&(this.autoQueue=this.autoReplay=this.autoResubscribe=!0)),Object.defineProperty(this,"isValid",{value:function(){if("disconnected"===f.state)throw new Error("This Kuzzle object has been invalidated. Did you try to access it after a disconnect call?")}}),Object.defineProperty(this,"addHeaders",{value:function(a,b){return Object.keys(b).forEach(function(c){a[c]||(a[c]=b[c])}),a}}),Object.defineProperty(this,"callbackRequired",{value:function(a,b){if(!b||"function"!=typeof b)throw new Error(a+": a callback argument is required for read queries")}}),Object.defineProperty(this,"security",{value:new j(this),enumerable:!0}),Object.defineProperty(this,"emitEvent",{value:function(a){var b=Date.now(),d=Array.prototype.slice.call(arguments,1),e=this.eventListeners[a];return e.lastEmitted&&e.lastEmitted>=b-this.eventTimeout?!1:(e.listeners.forEach(function(a){c.nextTick(function(){a.fn.apply(void 0,d)})}),void(void 0!==e.lastEmitted&&(e.lastEmitted=b)))}}),Object.defineProperty(this,"memoryStorage",{value:new k(this),enumerable:!0}),d&&d.connect&&"auto"!==d.connect?this.state="ready":this.connect(),this.bluebird?this.bluebird.promisifyAll(this,{suffix:"Promise",filter:function(a,b,c,d){var e=["getAllStatistics","getServerInfo","getStatistics","listCollections","listIndexes","login","logout","now","query","checkToken","whoAmI"];return d&&-1!==e.indexOf(a)}}):void 0},Kuzzle.prototype.connect=function(){var a=this;return-1===["initializing","ready","disconnected","error","offline"].indexOf(this.state)?(a.connectCB&&a.connectCB(null,a),a):(a.state="connecting",a.socket=a.io(a.url,{reconnection:a.autoReconnect,reconnectionDelay:a.reconnectionDelay,forceNew:!0}),a.socket.once("connect",function(){a.state="connected",g.call(a),f.call(a),a.emitEvent("connected"),a.connectCB&&a.connectCB(null,a)}),a.socket.on("connect_error",function(b){var c=new Error('Unable to connect to kuzzle server at "'+a.url+'"');c.internal=b,a.state="error",a.emitEvent("error",c),a.connectCB&&a.connectCB(c)}),a.socket.on("disconnect",function(){a.state="offline",a.autoReconnect||a.disconnect(),a.autoQueue&&(a.queuing=!0),a.emitEvent("disconnected")}),a.socket.on("reconnect",function(){var b=function(){a.autoResubscribe&&g.call(a),a.autoReplay&&(d.call(a),f.call(a)),a.emitEvent("reconnected")};a.state="connected",a.jwtToken?a.checkToken(a.jwtToken,function(c,d){!c&&d.valid||(a.jwtToken=void 0,a.emitEvent("jwtTokenExpired")),b()}):b()}),this)},Kuzzle.prototype.setJwtToken=function(a){if("string"==typeof a)this.jwtToken=a;else{if("object"!=typeof a)return this.emitEvent("loginAttempt",{success:!1,error:"Invalid token argument: "+a}),this;if(!a.result||!a.result.jwt||"string"!=typeof a.result.jwt)return this.emitEvent("loginAttempt",{success:!1,error:"Cannot find a valid JWT token in the following object: "+JSON.stringify(a)}),this;this.jwtToken=a.result.jwt}return g.call(this),this.emitEvent("loginAttempt",{success:!0}),this},Kuzzle.prototype.getJwtToken=function(){return this.jwtToken},Kuzzle.prototype.login=function(a){var b,c,d=this,e={strategy:a};return arguments[1]&&("object"==typeof arguments[1]?b=arguments[1]:"number"==typeof arguments[1]||"string"==typeof arguments[1]?e.expiresIn=arguments[1]:"function"==typeof arguments[1]&&(c=arguments[1])),arguments[2]&&("number"==typeof arguments[2]||"string"==typeof arguments[2]?e.expiresIn=arguments[2]:"function"==typeof arguments[2]&&(c=arguments[2])),arguments[3]&&"function"==typeof arguments[3]&&(c=arguments[3]),"object"==typeof b&&Object.keys(b).forEach(function(a){e[a]=b[a]}),this.query({controller:"auth",action:"login"},{body:e},{queuable:!1},function(a,b){a?(c&&"function"==typeof c&&c(a),d.emitEvent("loginAttempt",{success:!1,error:a.message})):(b.result.jwt&&d.setJwtToken(b.result.jwt),c&&"function"==typeof c&&c(null,b.result))}),d},Kuzzle.prototype.logout=function(a){var b=this,c={action:"logout",controller:"auth",requestId:h.v4(),body:{}};return this.query({controller:"auth",action:"logout"},c,{queuable:!1},function(c){null===c?(b.jwtToken=void 0,"function"==typeof a&&a(null,b)):"function"==typeof a&&a(c)}),b},Kuzzle.prototype.checkToken=function(a,b){var c=this,d={body:{token:a}};return this.callbackRequired("Kuzzle.checkToken",b),this.query({controller:"auth",action:"checkToken"},d,{queuable:!1},function(a,c){return a?b(a):void b(null,c.result)}),c},Kuzzle.prototype.whoAmI=function(a){var b=this;return b.callbackRequired("Kuzzle.whoAmI",a),b.query({controller:"auth",action:"getCurrentUser"},{},{},function(c,d){return c?a(c):void a(null,new l(b.security,d.result._id,d.result._source))}),b},Kuzzle.prototype.updateSelf=function(a,b,c){var d=this,e={},f={controller:"auth",action:"updateSelf"};c||"function"!=typeof b||(c=b,b=null),e.body=a,c?d.query(f,e,b,function(a,b){return a?c(a):void c(null,b.result)}):d.query(f,e,b)},Kuzzle.prototype.addListener=function(a,b){var c,d=Object.keys(this.eventListeners),e=typeof b;if(this.isValid(),-1===d.indexOf(a))throw new Error("["+a+"] is not a known event. Known events: "+d.toString());if("function"!==e)throw new Error("Invalid listener type: expected a function, got a "+e);return c=h.v1(),this.eventListeners[a].listeners.push({id:c,fn:b}),c},Kuzzle.prototype.getAllStatistics=function(a,b){return b||"function"!=typeof a||(b=a,a=null),this.callbackRequired("Kuzzle.getAllStatistics",b),this.query({controller:"admin",action:"getAllStats"},{},a,function(a,c){return a?b(a):void b(null,c.result.hits)}),this},Kuzzle.prototype.getStatistics=function(a,b,c){var d;return c||(1===arguments.length?(c=arguments[0],b=null,a=null):(c=arguments[1],"object"==typeof arguments[0]?(b=arguments[0],a=null):(a=arguments[0],b=null))),d=function(b,d){return b?c(b):void(a?c(null,d.result.hits):c(null,[d.result]))},this.callbackRequired("Kuzzle.getStatistics",c),a?this.query({controller:"admin",action:"getStats"},{body:{startTime:a}},b,d):this.query({controller:"admin",action:"getLastStats"},{},b,d),this},Kuzzle.prototype.dataCollectionFactory=function(a,b){if(this.isValid(),1===arguments.length?(b=arguments[0],a=this.defaultIndex):2===arguments.length&&"object"==typeof b&&(headers=b,b=a,a=this.defaultIndex),!a)throw new Error("Unable to create a new data collection object: no index specified");return this.collections[a]||(this.collections[a]={}),this.collections[a][b]||(this.collections[a][b]=new i(this,a,b)),this.collections[a][b]},Kuzzle.prototype.flushQueue=function(){return this.offlineQueue=[],this},Kuzzle.prototype.listCollections=function(){var a,b,c,d="all",e=Array.prototype.slice.call(arguments);if(e.forEach(function(d){switch(typeof d){case"string":a=d;break;case"object":b=d;break;case"function":c=d}}),!a){if(!this.defaultIndex)throw new Error("Kuzzle.listCollections: index required");a=this.defaultIndex}return this.callbackRequired("Kuzzle.listCollections",c),b&&b.type&&(d=b.type),this.query({index:a,controller:"read",action:"listCollections"},{body:{type:d}},b,function(a,b){return a?c(a):c(null,b.result.collections)}),this},Kuzzle.prototype.listIndexes=function(a,b){return b||"function"!=typeof a||(b=a,a=null),this.callbackRequired("Kuzzle.listIndexes",b),this.query({controller:"read",action:"listIndexes"},{},a,function(a,c){return a?b(a):b(null,c.result.indexes)}),this},Kuzzle.prototype.disconnect=function(){var a;this.logout(),this.state="disconnected",this.socket.close(),this.socket=null;for(a in this.collections)this.collections.hasOwnProperty(a)&&delete this.collections[a]},Kuzzle.prototype.getServerInfo=function(a,b){return b||"function"!=typeof a||(b=a,a=null),this.callbackRequired("Kuzzle.getServerInfo",b),this.query({controller:"read",action:"serverInfo"},{},a,function(a,c){return a?b(a):void b(null,c.result.serverInfo)}),this},Kuzzle.prototype.now=function(a,b){return b||"function"!=typeof a||(b=a,a=null),this.callbackRequired("Kuzzle.now",b),this.query({controller:"read",action:"now"},{},a,function(a,c){return a?b(a):void b(null,c.result.now)}),this},Kuzzle.prototype.query=function(a,b,c,f){var g,i={action:a.action,controller:a.controller,metadata:this.metadata},j=this;if(this.isValid(),f||"function"!=typeof c||(f=c,c=null),c&&(c.metadata&&Object.keys(c.metadata).forEach(function(a){i.metadata[a]=c.metadata[a]}),c.queuable===!1&&"offline"===j.state))return j;b.metadata&&Object.keys(b.metadata).forEach(function(a){i.metadata[a]=b.metadata[a]});for(g in b)"metadata"!==g&&b.hasOwnProperty(g)&&(i[g]=b[g]);return i=j.addHeaders(i,this.headers),void 0===j.jwtToken||"auth"===i.controller&&"checkToken"===i.action||(i.headers=i.headers||{},i.headers.authorization="Bearer "+j.jwtToken),a.collection&&(i.collection=a.collection),a.index&&(i.index=a.index),i.requestId||(i.requestId=h.v4()),"connected"===j.state||c&&c.queuable===!1?"connected"===j.state?e.call(this,i,f):f&&f(new Error("Unable to execute request: not connected to a Kuzzle server.\nDiscarded request: "+JSON.stringify(i))):(j.queuing||-1!==["initializing","connecting"].indexOf(j.state))&&(d.call(this,i,f),j.queueFilter&&!j.queueFilter(i)||(j.offlineQueue.push({ts:Date.now(),query:i,cb:f}),j.emitEvent("offlineQueuePush",{query:i,cb:f}))),j},Kuzzle.prototype.removeAllListeners=function(a){var b=Object.keys(this.eventListeners),c=this;if(a){if(-1===b.indexOf(a))throw new Error("["+a+"] is not a known event. Known events: "+b.toString());this.eventListeners[a].listeners=[]}else b.forEach(function(a){c.eventListeners[a].listeners=[]})},Kuzzle.prototype.removeListener=function(a,b){var c=Object.keys(this.eventListeners),d=this;if(-1===c.indexOf(a))throw new Error("["+a+"] is not a known event. Known events: "+c.toString());this.eventListeners[a].listeners.forEach(function(c,e){c.id===b&&d.eventListeners[a].listeners.splice(e,1)})},Kuzzle.prototype.replayQueue=function(){return"offline"===this.state||this.autoReplay||(d.call(this),f.call(this)),this},Kuzzle.prototype.setDefaultIndex=function(a){if("string"!=typeof a)throw new Error("Invalid default index: ["+a+"] (an index name is expected)");if(0===a.length)throw new Error("Cannot set an empty index as the default index");return this.defaultIndex=a,this},Kuzzle.prototype.setHeaders=function(a,b){var c=this;if("object"!=typeof a||Array.isArray(a))throw new Error("Expected a content object, received a "+typeof a);return b?c.headers=a:Object.keys(a).forEach(function(b){c.headers[b]=a[b]}),c},Kuzzle.prototype.startQueuing=function(){return"offline"!==this.state||this.autoQueue||(this.queuing=!0),this},Kuzzle.prototype.stopQueuing=function(){return"offline"!==this.state||this.autoQueue||(this.queuing=!1),this}}).call(this,a("_process"))},{"./kuzzleDataCollection":4,"./kuzzleMemoryStorage":7,"./security/kuzzleSecurity":11,"./security/kuzzleUser":13,_process:1,"node-uuid":2,"socket.io-client":void 0}],4:[function(a,b,c){function d(a,b,c){if(!b||!c)throw new Error("The KuzzleDataCollection object constructor needs an index and a collection arguments");return Object.defineProperties(this,{collection:{value:c,enumerable:!0},index:{value:b,enumerable:!0},kuzzle:{value:a,enumerable:!0},headers:{value:JSON.parse(JSON.stringify(a.headers)),enumerable:!0,writable:!0}}),Object.defineProperty(this,"buildQueryArgs",{value:function(a,b){return{controller:a,action:b,collection:this.collection,index:this.index}}}),this.kuzzle.bluebird?this.kuzzle.bluebird.promisifyAll(this,{suffix:"Promise",filter:function(a,b,c,d){var e=["publishMessage","setHeaders","subscribe"];return d&&-1===e.indexOf(a)}}):this}var e=a("./kuzzleDocument"),f=a("./kuzzleDataMapping"),g=a("./kuzzleRoom");d.prototype.advancedSearch=function(a,b,c){var d,f=this;return c||"function"!=typeof b||(c=b,b=null),f.kuzzle.callbackRequired("KuzzleDataCollection.advancedSearch",c),d=f.kuzzle.addHeaders({body:a},this.headers),f.kuzzle.query(this.buildQueryArgs("read","search"),d,b,function(a,b){var d=[];return a?c(a):(b.result.hits.forEach(function(a){var b=new e(f,a._id,a._source);b.version=a._version,d.push(b)}),void c(null,{total:b.result.total,documents:d}))}),this},d.prototype.count=function(a,b,c){var d;return c||"function"!=typeof b||(c=b,b=null),this.kuzzle.callbackRequired("KuzzleDataCollection.count",c),d=this.kuzzle.addHeaders({body:a},this.headers),this.kuzzle.query(this.buildQueryArgs("read","count"),d,b,function(a,b){return a?c(a):void c(null,b.result.count)}),this},d.prototype.create=function(a,b){var c={};return b||"function"!=typeof a||(b=a,a=null),c=this.kuzzle.addHeaders(c,this.headers),this.kuzzle.query(this.buildQueryArgs("write","createCollection"),c,a,b),this},d.prototype.createDocument=function(a,b,c,d){var f=this,g={},h="create";return a&&"string"!=typeof a&&(d=c,c=b,b=a,a=null),d||"function"!=typeof c||(d=c,c=null),b instanceof e?g=b.serialize():g.body=b,c&&(h=c.updateIfExist?"createOrReplace":"create"),a&&(g._id=a),g=f.kuzzle.addHeaders(g,f.headers),d?f.kuzzle.query(this.buildQueryArgs("write",h),g,c,function(a,b){var c;return a?d(a):(c=new e(f,b.result._id,b.result._source),c.version=b.result._version,void d(null,c))}):f.kuzzle.query(this.buildQueryArgs("write",h),g,c),this},d.prototype.deleteDocument=function(a,b,c){var d,e={};return"string"==typeof a?(e._id=a,d="delete"):(e.body=a,d="deleteByQuery"),c||"function"!=typeof b||(c=b,b=null),e=this.kuzzle.addHeaders(e,this.headers),c?this.kuzzle.query(this.buildQueryArgs("write",d),e,b,function(a,b){return a?c(a):void("delete"===d?c(null,[b.result._id]):c(null,b.result.ids))}):this.kuzzle.query(this.buildQueryArgs("write",d),e,b),this},d.prototype.fetchDocument=function(a,b,c){var d={_id:a},f=this;return c||"function"!=typeof b||(c=b,b=null),f.kuzzle.callbackRequired("KuzzleDataCollection.fetch",c),d=f.kuzzle.addHeaders(d,this.headers),f.kuzzle.query(this.buildQueryArgs("read","get"),d,b,function(a,b){var d;return a?c(a):(d=new e(f,b.result._id,b.result._source),d.version=b.result._version,void c(null,d))}),this},d.prototype.fetchAllDocuments=function(a,b){return b||"function"!=typeof a||(b=a,a=null),this.kuzzle.callbackRequired("KuzzleDataCollection.fetchAll",b),this.advancedSearch({},a,b),this},d.prototype.getMapping=function(a,b){var c;return b||"function"!=typeof a||(b=a,a=null),this.kuzzle.callbackRequired("KuzzleDataCollection.getMapping",b),c=new f(this),c.refresh(a,b),this},d.prototype.publishMessage=function(a,b){var c={};return a instanceof e?c=a.serialize():c.body=a,c=this.kuzzle.addHeaders(c,this.headers),this.kuzzle.query(this.buildQueryArgs("write","publish"),c,b),this},d.prototype.replaceDocument=function(a,b,c,d){var f=this,g={_id:a,body:b};return d||"function"!=typeof c||(d=c,c=null),g=f.kuzzle.addHeaders(g,this.headers),d?f.kuzzle.query(this.buildQueryArgs("write","createOrReplace"),g,c,function(a,b){var c;return a?d(a):(c=new e(f,b.result._id,b.result._source),c.version=b.result._version,void d(null,c))}):f.kuzzle.query(this.buildQueryArgs("write","createOrReplace"),g,c),this},d.prototype.subscribe=function(a,b,c){var d;return c||"function"!=typeof b||(c=b,b=null),this.kuzzle.callbackRequired("KuzzleDataCollection.subscribe",c),d=new g(this,b),d.renew(a,c)},d.prototype.truncate=function(a,b){var c={};return b||"function"!=typeof a||(b=a,a=null),c=this.kuzzle.addHeaders(c,this.headers),this.kuzzle.query(this.buildQueryArgs("admin","truncateCollection"),c,a,b),this},d.prototype.updateDocument=function(a,b,c,d){var f={_id:a,body:b},g=this;return d||"function"!=typeof c||(d=c,c=null),f=g.kuzzle.addHeaders(f,this.headers),d?g.kuzzle.query(this.buildQueryArgs("write","update"),f,c,function(a,b){var c;return a?d(a):(c=new e(g,b.result._id),void c.refresh(d))}):g.kuzzle.query(this.buildQueryArgs("write","update"),f,c),g},d.prototype.documentFactory=function(a,b){return new e(this,a,b)},d.prototype.roomFactory=function(a){return new g(this,a)},d.prototype.dataMappingFactory=function(a){return new f(this,a)},d.prototype.setHeaders=function(a,b){return this.kuzzle.setHeaders.call(this,a,b),this},b.exports=d},{"./kuzzleDataMapping":5,"./kuzzleDocument":6,"./kuzzleRoom":8}],5:[function(a,b,c){function d(a,b){return Object.defineProperties(this,{collection:{value:a,enumerable:!0},kuzzle:{value:a.kuzzle,enumerable:!0},headers:{value:JSON.parse(JSON.stringify(a.headers)),enumerable:!0,writable:!0},mapping:{value:b||{},enumerable:!0,writable:!0}}),this.kuzzle.bluebird?this.kuzzle.bluebird.promisifyAll(this,{suffix:"Promise",filter:function(a,b,c,d){var e=["set","setHeaders"];return d&&-1===e.indexOf(a)}}):this}d.prototype.apply=function(a,b){var c=this,d=this.kuzzle.addHeaders({body:{properties:this.mapping}},this.headers);return b||"function"!=typeof a||(b=a,a=null),c.kuzzle.query(this.collection.buildQueryArgs("admin","updateMapping"),d,a,function(d){return d?b?b(d):!1:void c.refresh(a,b)}),this},d.prototype.refresh=function(a,b){var c=this,d=this.kuzzle.addHeaders({},this.headers);return b||"function"!=typeof a||(b=a,a=null),this.kuzzle.query(this.collection.buildQueryArgs("admin","getMapping"),d,a,function(a,d){return a?b?b(a):!1:d.result[c.collection.index]?d.result[c.collection.index].mappings[c.collection.collection]?(c.mapping=d.result[c.collection.index].mappings[c.collection.collection].properties,void(b&&b(null,c))):b?b(new Error("No mapping found for collection "+c.collection.collection)):!1:b?b(new Error("No mapping found for index "+c.collection.index)):!1}),this},d.prototype.set=function(a,b){return this.mapping[a]=b,this},d.prototype.setHeaders=function(a,b){return this.kuzzle.setHeaders.call(this,a,b),this},b.exports=d},{}],6:[function(a,b,c){function d(a,b,c){return Object.defineProperties(this,{collection:{value:a.collection,enumerable:!0},dataCollection:{value:a,enumerable:!0},kuzzle:{value:a.kuzzle,enumerable:!0},id:{value:void 0,enumerable:!0,writable:!0},content:{value:{},writable:!0,enumerable:!0},headers:{value:JSON.parse(JSON.stringify(a.headers)),enumerable:!0,writable:!0},version:{value:void 0,enumerable:!0,writable:!0}}),!c&&b&&"object"==typeof b&&(c=b,b=null),c&&(c._version&&(this.version=c._version,delete c._version),this.setContent(c,!0)),b&&Object.defineProperty(this,"id",{value:b,enumerable:!0}),this.kuzzle.bluebird?this.kuzzle.bluebird.promisifyAll(this,{suffix:"Promise",filter:function(a,b,c,d){var e=["delete","refresh","save"];return d&&-1!==e.indexOf(a)}}):this}d.prototype.serialize=function(){var a={};return this.id&&(a._id=this.id),a.body=this.content,a._version=this.version,a=this.kuzzle.addHeaders(a,this.headers)},d.prototype.toString=function(){return JSON.stringify(this.serialize())},d.prototype["delete"]=function(a,b){var c=this;if(b||"function"!=typeof a||(b=a,a=null),!this.id)throw new Error("KuzzleDocument.delete: cannot delete a document without a document ID");return b?this.kuzzle.query(this.dataCollection.buildQueryArgs("write","delete"),this.serialize(),a,function(a){return a?b(a):void b(null,c)}):this.kuzzle.query(this.dataCollection.buildQueryArgs("write","delete"),this.serialize(),a),this},d.prototype.refresh=function(a,b){var c=this;if(b||"function"!=typeof a||(b=a,a=null),!c.id)throw new Error("KuzzleDocument.refresh: cannot retrieve a document if no ID has been provided");this.kuzzle.callbackRequired("KuzzleDocument.refresh",b),c.kuzzle.query(c.dataCollection.buildQueryArgs("read","get"),{_id:c.id},a,function(a,e){var f;return a?b(a):(f=new d(c.dataCollection,c.id,e.result._source),f.version=e.result._version,void b(null,f))})},d.prototype.save=function(a,b){var c=this.serialize(),d=this;return a&&void 0===b&&"function"==typeof a&&(b=a,a=null),d.kuzzle.query(this.dataCollection.buildQueryArgs("write","createOrReplace"),c,a,function(a,c){return a?b?b(a):!1:(d.id=c.result._id,d.version=c.result._version,void(b&&b(null,d)))}),d},d.prototype.publish=function(a){var b=this.serialize();return this.kuzzle.query(this.dataCollection.buildQueryArgs("write","publish"),b,a),this},d.prototype.setContent=function(a,b){var c=this;return b?this.content=a:Object.keys(a).forEach(function(b){c.content[b]=a[b]}),this},d.prototype.subscribe=function(a,b){var c;if(a&&!b&&"function"==typeof a&&(b=a,a=null),this.kuzzle.callbackRequired("KuzzleDocument.subscribe",b),!this.id)throw new Error("KuzzleDocument.subscribe: cannot subscribe to a document if no ID has been provided");return c={ids:{values:[this.id]}},this.dataCollection.subscribe(c,a,b)},d.prototype.setHeaders=function(a,b){return this.kuzzle.setHeaders.call(this,a,b),this},b.exports=d},{}],7:[function(a,b,c){function d(a){return Object.defineProperties(this,{kuzzle:{value:a,enumerable:!0},headers:{value:JSON.parse(JSON.stringify(a.headers)),enumerable:!0,writable:!0}}),this.setHeaders=a.setHeaders.bind(this),this.kuzzle.bluebird?this.kuzzle.bluebird.promisifyAll(this,{suffix:"Promise",filter:function(a,b,c,d){var e=["setHeaders"];return d&&-1===e.indexOf(a)}}):this}!function(){var a=["id","value"],b=["id","keys"],c={append:a,bgrewriteaof:[],bgsave:[],bitcount:["id","start","end"],bitop:["operation","destkey",b],bitpos:["id","bit",{__opts__:["start","end"]}],blpop:[b,"timeout"],brpoplpush:["source","destination"],dbsize:[],decrby:a,del:[b],discard:[],exec:[],exists:[b],expire:["id","seconds"],expireat:["id","timestamp"],flushdb:[],getbit:["id","offset"],getrange:["id","start","end"],hdel:["id",["field","fields"]],hexists:["id","field"],hincrby:["id","field","value"],hmset:["id","values"],hset:["id","field","value"],info:["section"],keys:["pattern"],lastsave:[],lindex:["id","idx"],linsert:["id","position","pivot","value"],lpush:["id",["value","values"]],lrange:["id","start","stop"],lrem:["id","count","value"],lset:["id","idx","value"],ltrim:["id","start","stop"],mset:["values"],multi:[],object:["subcommand","args"],pexpire:["id","milliseconds"],pexpireat:["id","timestamp"],pfadd:["id",["element","elements"]],pfmerge:["destkey",["sourcekey","sourcekeys"]],ping:[],psetex:["id","milliseconds","value"],publish:["channel","message"],randomkey:[],rename:["id","newkey"],renamenx:["id","newkey"],restore:["id","ttl","content"],rpoplpush:["source","destination"],sadd:["id",["member","members"]],save:[],set:["id","value",{__opts__:["ex","px","nx","xx"]}],sdiffstore:["destination",b],setbit:["id","offset","value"],setex:["id","seconds","value"],setrange:["id","offset","value"],sinterstore:["destination",b],sismember:["id","member"],smove:["id","destination","member"],sort:["id",{__opts__:["by","offset","count","get","direction","alpha","store"]}],spop:["id","count"],srem:["id",["member","members"]],sunionstore:["destination",b],unwatch:[],wait:["numslaves","timeout"],zadd:["id",{__opts__:["nx","xx","ch","incr","score","member","members"]}],zcount:["id","min","max"],zincrby:["id","value","member"],zinterstore:["destination",b,{__opts__:["weight","weights","aggregate"]}],zlexcount:["id","min","max"],zrange:["id","start","stop",{__opts__:["withscores"]}],zrangebylex:["id","min","max",{__opts__:["offset","count"]}],zrangebyscore:["id","min","max",{__opts__:["withscores","offset","count"]}],zrem:["id","member"],zremrangebylex:["id","min","max"],zremrangebyscore:["id","min","max"],zrevrangebylex:["id","max","min",{__opts__:["offset","count"]}],zrevrangebyscore:["id","max","min",{__opts__:["withscores","offset","count"]}],zrevrank:["id","member"]};c.decr=c.get=c.dump=c.hgetall=c.hkeys=c.hlen=c.hstrlen=c.hvals=c.incr=c.llen=c.lpop=c.persist=c.pttl=c.rpop=c.scard=c.smembers=c.strlen=c.ttl=c.type=c.zcard=["id"],c.getset=c.lpushx=a,c.del=c.exists=c.mget=c.pfcount=c.sdiff=c.sinter=c.sunion=c.watch=[b],c.incrby=c.incrbyfloat=c.decrby,c.brpop=c.blpop,c.hget=c.hexists,c.hmget=c.hdel,c.hsetnx=c.hset,c.msetnx=c.mset,c.rpush=c.lpush,c.hincrbyfloat=c.hincrby,c.srandmember=c.spop,c.zrevrange=c.zrange,c.zscore=c.zrevrank,Object.keys(c).forEach(function(a){d.prototype[a]=function(){var b,d=Array.prototype.slice.call(arguments),e=null,f={controller:"ms",action:a},g={};return"function"==typeof d[d.length-1]&&(b=d.pop()),d.length&&"object"==typeof d[d.length-1]&&1===Object.keys(d[d.length-1]).length&&void 0!==d[d.length-1].queuable&&(e=d.pop()),c[a].forEach(function(a,b){void 0!==d[b]&&(Array.isArray(a)&&(a=Array.isArray(d[b])?a[1]:a[0]),"id"===a?g._id=d[b]:(g.body||(g.body={}),"object"==typeof a&&void 0!==a.__opts__?a.__opts__.forEach(function(a){void 0!==d[b][a]&&(g.body[a]=d[b][a]); -}):g.body[a]=d[b]))}),this.kuzzle.query(f,g,e,b),this}})}(),b.exports=d},{}],8:[function(a,b,c){function d(a,b){return Object.defineProperties(this,{callback:{value:null,writable:!0},channel:{value:null,writable:!0},id:{value:h.v4()},lastRenewal:{value:null,writable:!0},notifier:{value:null,writable:!0},queue:{value:[],writable:!0},renewalDelay:{value:500},scope:{value:b&&b.scope?b.scope:"all"},state:{value:b&&b.state?b.state:"done"},subscribing:{value:!1,writable:!0},users:{value:b&&b.users?b.users:"none"},collection:{value:a,enumerable:!0},kuzzle:{value:a.kuzzle,enumerable:!0},filters:{value:null,enumerable:!0,writable:!0},headers:{value:JSON.parse(JSON.stringify(a.headers)),enumerable:!0,writable:!0},metadata:{value:b&&b.metadata?b.metadata:{},enumerable:!0,writable:!0},roomId:{value:null,enumerable:!0,writable:!0},subscribeToSelf:{value:b&&"boolean"==typeof b.subscribeToSelf?b.subscribeToSelf:!0,enumerable:!0,writable:!0}}),this.kuzzle.bluebird?this.kuzzle.bluebird.promisifyAll(this,{suffix:"Promise",filter:function(a,b,c,d){var e=["count"];return d&&-1!==e.indexOf(a)}}):this}function e(a){return a.error?this.callback(a.error):"jwtTokenExpired"===a.action?(this.kuzzle.jwtToken=void 0,this.kuzzle.emitEvent("jwtTokenExpired")):void(this.kuzzle.requestHistory[a.requestId]?(this.subscribeToSelf&&this.callback(null,a),delete this.kuzzle.requestHistory[a.requestId]):this.callback(null,a))}function f(){for(var a;this.queue.length>0;)a=this.queue.shift(),this[a.action].apply(this,a.args)}function g(){return"connected"===this.kuzzle.state&&!this.subscribing}var h=a("node-uuid");d.prototype.count=function(a){var b;if(this.kuzzle.callbackRequired("KuzzleRoom.count",a),b=this.kuzzle.addHeaders({body:{roomId:this.roomId}},this.headers),!g.call(this))return this.queue.push({action:"count",args:[a]}),this;if(!this.roomId)throw new Error("KuzzleRoom.count: cannot count subscriptions on an inactive room");return this.kuzzle.query(this.collection.buildQueryArgs("subscribe","count"),b,function(b,c){return b?a(b):void a(null,c.result.count)}),this},d.prototype.renew=function(a,b){var c=Date.now(),d={scope:this.scope,state:this.state,users:this.users},g=this;return!b&&a&&"function"==typeof a&&(b=a,a=null),g.kuzzle.callbackRequired("KuzzleRoom.renew",b),g.lastRenewal&&c-g.lastRenewal<=g.renewalDelay?g:(a&&(g.filters=a),"connected"!==g.kuzzle.state?(g.callback=b,g.kuzzle.subscriptions.pending[g.id]=g,g):g.subscribing?(g.queue.push({action:"renew",args:[a,b]}),g):(g.unsubscribe(),g.roomId=null,g.subscribing=!0,g.callback=b,g.kuzzle.subscriptions.pending[g.id]=g,d.body=g.filters,d=g.kuzzle.addHeaders(d,this.headers),g.kuzzle.query(g.collection.buildQueryArgs("subscribe","on"),d,{metadata:g.metadata},function(a,b){if(delete g.kuzzle.subscriptions.pending[g.id],g.subscribing=!1,a)throw g.queue=[],new Error("Error during Kuzzle subscription: "+a.message);g.lastRenewal=c,g.roomId=b.result.roomId,g.channel=b.result.channel,g.kuzzle.subscriptions[g.roomId]||(g.kuzzle.subscriptions[g.roomId]={}),g.kuzzle.subscriptions[g.roomId][g.id]=g,g.notifier=e.bind(g),g.kuzzle.socket.on(g.channel,g.notifier),f.call(g)}),g))},d.prototype.unsubscribe=function(){var a,b=this,c=b.roomId;return g.call(this)?(c&&(b.kuzzle.socket.off(b.channel,this.notifier),1===Object.keys(b.kuzzle.subscriptions[c]).length?(delete b.kuzzle.subscriptions[c],0===Object.keys(b.kuzzle.subscriptions.pending).length?b.kuzzle.query(b.collection.buildQueryArgs("subscribe","off"),{body:{roomId:c}}):a=setInterval(function(){0===Object.keys(b.kuzzle.subscriptions.pending).length&&(b.kuzzle.subscriptions[c]||b.kuzzle.query(b.collection.buildQueryArgs("subscribe","off"),{body:{roomId:c}}),clearInterval(a))},100)):delete b.kuzzle.subscriptions[c][b.id],b.roomId=null),b):(b.queue.push({action:"unsubscribe",args:[]}),b)},d.prototype.setHeaders=function(a,b){return this.kuzzle.setHeaders.call(this,a,b),this},b.exports=d},{"node-uuid":2}],9:[function(a,b,c){function d(a,b,c){return e.call(this,a,b,c),Object.defineProperties(this,{deleteActionName:{value:"deleteProfile"},updateActionName:{value:"updateProfile"}}),c&&c.roles&&(c.roles=c.roles.map(function(b){return b._id&&b._source?new f(a,b._id,b._source):b})),a.kuzzle.bluebird?a.kuzzle.bluebird.promisifyAll(this,{suffix:"Promise",filter:function(a,b,c,d){var e=["hydrate","save"];return d&&-1!==e.indexOf(a)}}):void 0}var e=a("./kuzzleSecurityDocument"),f=a("./kuzzleRole");d.prototype=Object.create(e.prototype,{constructor:{value:d}}),d.prototype.save=function(a,b){var c,d=this;if(!this.content.roles)throw new Error('Argument "roles" is mandatory in a profile. This argument contains an array of KuzzleRole or an array of id string');return a&&void 0===b&&"function"==typeof a&&(b=a,a=null),c=this.serialize(),d.kuzzle.query(d.kuzzleSecurity.buildQueryArgs("createOrReplaceProfile"),c,a,function(a){return a?b?b(a):!1:void(b&&b(null,d))}),d},d.prototype.addRole=function(a){if("string"!=typeof a&&!(a instanceof f))throw new Error('Parameter "roles" must be a KuzzleRole or a id string');return this.content.roles||(this.content.roles=[]),this.content.roles.push(a),this},d.prototype.setRoles=function(a){if(!Array.isArray(a))throw new Error('Parameter "roles" must be an array of KuzzleRole or an array of string');return a.map(function(a){if("string"!=typeof a&&!(a instanceof f))throw new Error('Parameter "roles" must be an array of KuzzleRole or an array of string')}),this.content.roles=a,this},d.prototype.hydrate=function(a,b){var c=this,e={ids:[]};e.ids=this.content.roles.map(function(a){return"string"==typeof a?a:a instanceof f?a.id:void 0}),a&&void 0===b&&"function"==typeof a&&(b=a,a=null),c.kuzzle.callbackRequired("KuzzleProfile.hydrate",b),c.kuzzle.query(c.kuzzleSecurity.buildQueryArgs("mGetRoles"),{body:e},a,function(a,e){return a?b(a):void b(null,new d(c,c.id,{roles:e.result.hits}))})},d.prototype.serialize=function(){var a={};return this.id&&(a._id=this.id),a.body=this.content,a.body.roles&&Array.isArray(a.body.roles)?(a.body.roles=a.body.roles.map(function(a){return a instanceof f?a.id:a}),a):a},d.prototype.getRoles=function(){return this.content.roles},b.exports=d},{"./kuzzleRole":10,"./kuzzleSecurityDocument":12}],10:[function(a,b,c){function d(a,b,c){return e.call(this,a,b,c),Object.defineProperties(this,{deleteActionName:{value:"deleteRole"},updateActionName:{value:"updateRole"}}),a.kuzzle.bluebird?a.kuzzle.bluebird.promisifyAll(this,{suffix:"Promise",filter:function(a,b,c,d){var e=["save"];return d&&-1!==e.indexOf(a)}}):void 0}var e=a("./kuzzleSecurityDocument");d.prototype=Object.create(e.prototype,{constructor:{value:d}}),d.prototype.save=function(a,b){var c=this.serialize(),d=this;a&&void 0===b&&"function"==typeof a&&(b=a,a=null),d.kuzzle.query(this.kuzzleSecurity.buildQueryArgs("createOrReplaceRole"),c,a,function(a){return a?b?b(a):!1:void(b&&b(null,d))})},b.exports=d},{"./kuzzleSecurityDocument":12}],11:[function(a,b,c){function d(a){return Object.defineProperty(this,"kuzzle",{value:a}),Object.defineProperty(this,"buildQueryArgs",{value:function(a){return{controller:"security",action:a}}}),this.kuzzle.bluebird?this.kuzzle.bluebird.promisifyAll(this,{suffix:"Promise",filter:function(a,b,c,d){var e=["roleFactory","profileFactory","userFactory"];return d&&-1===e.indexOf(a)}}):this}var e=a("./kuzzleRole"),f=a("./kuzzleProfile"),g=a("./kuzzleUser");d.prototype.getRole=function(a,b,c){var d,f=this;if(!a)throw new Error("Id parameter is mandatory for getRole function");c||"function"!=typeof b||(c=b,b=null),d={_id:a},f.kuzzle.callbackRequired("KuzzleSecurity.getRole",c),f.kuzzle.query(this.buildQueryArgs("getRole"),d,b,function(a,b){return a?c(a):void c(null,new e(f,b.result._id,b.result._source))})},d.prototype.searchRoles=function(a,b,c){var d=this;c||"function"!=typeof b||(c=b,b=null),d.kuzzle.callbackRequired("KuzzleSecurity.searchRoles",c),d.kuzzle.query(this.buildQueryArgs("searchRoles"),{body:a},b,function(a,b){var f;return a?c(a):(f=b.result.hits.map(function(a){return new e(d,a._id,a._source)}),void c(null,{total:b.result.total,roles:f}))})},d.prototype.createRole=function(a,b,c,d){var f=this,g={},h="createRole";if(!a||"string"!=typeof a)throw new Error("KuzzleSecurity.createRole: cannot create a role without a role ID");d||"function"!=typeof c||(d=c,c=null),g._id=a,g.body=b,c&&(h=c.replaceIfExist?"createOrReplaceRole":"createRole"),d?f.kuzzle.query(this.buildQueryArgs(h),g,c,function(a,b){var c;return a?d(a):(c=new e(f,b.result._id,b.result._source),void d(null,c))}):f.kuzzle.query(this.buildQueryArgs(h),g)},d.prototype.updateRole=function(a,b,c,d){var e=this,f={},g="updateRole";if(!a||"string"!=typeof a)throw new Error("KuzzleSecurity.updateRole: cannot update a role without a role ID");d||"function"!=typeof c||(d=c,c=null),f._id=a,f.body=b,d?e.kuzzle.query(this.buildQueryArgs(g),f,c,function(a,b){return a?d(a):void d(null,b.result._id)}):e.kuzzle.query(this.buildQueryArgs(g),f)},d.prototype.deleteRole=function(a,b,c){var d={_id:a};c||"function"!=typeof b||(c=b,b=null),c?this.kuzzle.query(this.buildQueryArgs("deleteRole"),d,b,function(a,b){return a?c(a):void c(null,b.result._id)}):this.kuzzle.query(this.buildQueryArgs("deleteRole"),d,b)},d.prototype.roleFactory=function(a,b){return new e(this,a,b)},d.prototype.getProfile=function(a,b,c){var d,e=this,g=!0;if(!a||"string"!=typeof a)throw new Error("Id parameter is mandatory for getProfile function");c||"function"!=typeof b?void 0!==b.hydrate&&(g=b.hydrate):(c=b,b=null),d={_id:a},e.kuzzle.callbackRequired("KuzzleSecurity.getProfile",c),e.kuzzle.query(this.buildQueryArgs("getProfile"),d,b,function(a,b){return a?c(a):(g||(b.result._source.roles=b.result._source.roles.map(function(a){return a._id})),void c(null,new f(e,b.result._id,b.result._source)))})},d.prototype.searchProfiles=function(a,b,c){var d=this;a.hydrate=!0,c||"function"!=typeof b?void 0!==b.hydrate&&(a.hydrate=b.hydrate):(c=b,b=null),d.kuzzle.callbackRequired("KuzzleSecurity.searchProfiles",c),d.kuzzle.query(this.buildQueryArgs("searchProfiles"),{body:a},b,function(a,b){var e;return a?c(a):(e=b.result.hits.map(function(a){return new f(d,a._id,a._source)}),void c(null,{total:b.result.total,profiles:e}))})},d.prototype.createProfile=function(a,b,c,d){var e=this,g={},h="createProfile";if(!a||"string"!=typeof a)throw new Error("KuzzleSecurity.createProfile: cannot create a profile without a profile ID");d||"function"!=typeof c||(d=c,c=null),g._id=a,g.body=b,c&&(h=c.replaceIfExist?"createOrReplaceProfile":"createProfile"),d?e.kuzzle.query(this.buildQueryArgs(h),g,c,function(a,b){var c;return a?d(a):(c=new f(e,b.result._id,b.result._source),void d(null,c))}):e.kuzzle.query(this.buildQueryArgs(h),g)},d.prototype.updateProfile=function(a,b,c,d){var e=this,f={},g="updateProfile";if(!a||"string"!=typeof a)throw new Error("KuzzleSecurity.updateProfile: cannot update a profile without a profile ID");d||"function"!=typeof c||(d=c,c=null),f._id=a,f.body=b,d?e.kuzzle.query(this.buildQueryArgs(g),f,c,function(a,b){return a?d(a):void d(null,b.result._id)}):e.kuzzle.query(this.buildQueryArgs(g),f)},d.prototype.deleteProfile=function(a,b,c){var d={_id:a};c||"function"!=typeof b||(c=b,b=null),c?this.kuzzle.query(this.buildQueryArgs("deleteProfile"),d,b,function(a,b){return a?c(a):void c(null,b.result._id)}):this.kuzzle.query(this.buildQueryArgs("deleteProfile"),d,b)},d.prototype.profileFactory=function(a,b){return new f(this,a,b)},d.prototype.getUser=function(a,b,c){var d,e=this,f=!0;if(!a||"string"!=typeof a)throw new Error("Id parameter is mandatory for getUser function");c||"function"!=typeof b?void 0!==b.hydrate&&(f=b.hydrate):(c=b,b=null),d={_id:a},e.kuzzle.callbackRequired("KuzzleSecurity.getUser",c),e.kuzzle.query(this.buildQueryArgs("getUser"),d,b,function(a,b){return a?c(a):(f||(b.result._source.profile=b.result._source.profile._id),void c(null,new g(e,b.result._id,b.result._source)))})},d.prototype.searchUsers=function(a,b,c){var d=this;a.hydrate=!0,c||"function"!=typeof b?void 0!==b.hydrate&&(a.hydrate=b.hydrate):(c=b,b=null),d.kuzzle.callbackRequired("KuzzleSecurity.searchUsers",c),d.kuzzle.query(this.buildQueryArgs("searchUsers"),{body:a},b,function(a,b){var e;return a?c(a):(e=b.result.hits.map(function(a){return new g(d,a._id,a._source)}),void c(null,{total:b.result.total,users:e}))})},d.prototype.createUser=function(a,b,c,d){var e=this,f={},h="createUser";if(!a||"string"!=typeof a)throw new Error("KuzzleSecurity.createUser: cannot create a user without a user ID");d||"function"!=typeof c||(d=c,c=null),f._id=a,f.body=b,c&&(h=c.replaceIfExist?"createOrReplaceUser":"createUser"),d?e.kuzzle.query(this.buildQueryArgs(h),f,null,function(a,b){var c;return a?d(a):(c=new g(e,b.result._id,b.result._source),void d(null,c))}):e.kuzzle.query(this.buildQueryArgs(h),f)},d.prototype.updateUser=function(a,b,c,d){var e=this,f={},h="updateUser";if(!a||"string"!=typeof a)throw new Error("KuzzleSecurity.updateUser: cannot update an user without an user ID");d||"function"!=typeof c||(d=c,c=null),f._id=a,f.body=b,d?e.kuzzle.query(this.buildQueryArgs(h),f,c,function(a,b){return a?d(a):void d(null,new g(e,b.result._id,b.result._source))}):e.kuzzle.query(this.buildQueryArgs(h),f,c)},d.prototype.deleteUser=function(a,b,c){var d={_id:a};c||"function"!=typeof b||(c=b,b=null),c?this.kuzzle.query(this.buildQueryArgs("deleteUser"),d,b,function(a,b){return a?c(a):void c(null,b.result._id)}):this.kuzzle.query(this.buildQueryArgs("deleteUser"),d,b)},d.prototype.userFactory=function(a,b){return new g(this,a,b)},b.exports=d},{"./kuzzleProfile":9,"./kuzzleRole":10,"./kuzzleUser":13}],12:[function(a,b,c){function d(a,b,c){if(!b)throw new Error("A security document must have an id");return Object.defineProperties(this,{kuzzle:{value:a.kuzzle},kuzzleSecurity:{value:a},id:{value:b,enumerable:!0},content:{value:{},writable:!0,enumerable:!0}}),c&&this.setContent(c,!0),a.kuzzle.bluebird?a.kuzzle.bluebird.promisifyAll(this,{suffix:"Promise",filter:function(a,b,c,d){var e=["delete","update"];return d&&-1!==e.indexOf(a)}}):void 0}d.prototype.setContent=function(a){return this.content=a,this},d.prototype.serialize=function(){var a={};return this.id&&(a._id=this.id),a.body=this.content,a},d.prototype["delete"]=function(a,b){var c=this;a&&void 0===b&&"function"==typeof a&&(b=a,a=null),c.kuzzle.query(this.kuzzleSecurity.buildQueryArgs(this.deleteActionName),{_id:this.id},a,function(a,c){return a?b?b(a):!1:void(b&&b(null,c.result._id))})},d.prototype.update=function(a,b,c){var d={},e=this;if("object"!=typeof a)throw new Error('Parameter "content" must be a object');b&&void 0===c&&"function"==typeof b&&(c=b,b=null),d._id=e.id,d.body=a,e.kuzzle.query(this.kuzzleSecurity.buildQueryArgs(this.updateActionName),d,b,function(a,b){return a?c?c(a):!1:(e.setContent(b.result._source),void(c&&c(null,e)))})},b.exports=d},{}],13:[function(a,b,c){function d(a,b,c){return e.call(this,a,b,c),c.profile&&c.profile._id&&c.profile._source&&(this.content.profile=new f(a,c.profile._id,c.profile._source)),Object.defineProperties(this,{deleteActionName:{value:"deleteUser"},updateActionName:{value:"updateUser"}}),a.kuzzle.bluebird?a.kuzzle.bluebird.promisifyAll(this,{suffix:"Promise",filter:function(a,b,c,d){var e=["hydrate","save"];return d&&-1!==e.indexOf(a)}}):void 0}var e=a("./kuzzleSecurityDocument"),f=a("./kuzzleProfile");d.prototype=Object.create(e.prototype,{constructor:{value:d}}),d.prototype.hydrate=function(a,b){var c=this;if(a&&void 0===b&&"function"==typeof a&&(b=a,a=null),c.kuzzle.callbackRequired("KuzzleUser.hydrate",b),!this.content.profile||"string"!=typeof this.content.profile)throw new Error("The User must contains a profile as string in order to be hydrated");c.kuzzle.query(this.kuzzleSecurity.buildQueryArgs("getProfile"),{_id:this.content.profile},a,function(a,e){var g;return a?b(a):(g=new d(c.kuzzleSecurity,c.id,c.content),g.setProfile(new f(c.kuzzleSecurity,e.result._id,e.result._source)),void b(null,g))})},d.prototype.setProfile=function(a){if("string"!=typeof a&&!(a instanceof f))throw new Error('Parameter "profile" must be a KuzzleProfile or a string');return this.content.profile=a,this},d.prototype.save=function(a,b){var c=this.serialize(),d=this;return a&&void 0===b&&"function"==typeof a&&(b=a,a=null),d.kuzzle.query(this.kuzzleSecurity.buildQueryArgs("createOrReplaceUser"),c,a,function(a){return a?b?b(a):!1:void(b&&b(null,d))}),d},d.prototype.serialize=function(){var a={};return this.id&&(a._id=this.id),a.body=this.content,a.body.profile&&a.body.profile.id&&(a.body.profile=a.body.profile.id),a},d.prototype.getProfiles=function(){return this.content.profile},b.exports=d},{"./kuzzleProfile":9,"./kuzzleSecurityDocument":12}]},{},[3]); +// Official Javascript SDK for Kuzzle v1.7.4 - License: Apache-2.0 +!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g1)for(var c=1;cb;b++)0===(3&b)&&(a=4294967296*Math.random()),e[b]=a>>>((3&b)<<3)&255;return e},"undefined"!=typeof console&&console.warn&&console.warn("[SECURITY] node-uuid: crypto not usable, falling back to insecure Math.random()")}}function e(){if("function"==typeof a)try{var b=a("crypto").randomBytes;l=j=b&&function(){return b(16)},j()}catch(c){}}function f(a,b,c){var d=b&&c||0,e=0;for(b=b||[],a.toLowerCase().replace(/[0-9a-f]{2}/g,function(a){16>e&&(b[d+e++]=q[a])});16>e;)b[d+e++]=0;return b}function g(a,b){var c=b||0,d=p;return d[a[c++]]+d[a[c++]]+d[a[c++]]+d[a[c++]]+"-"+d[a[c++]]+d[a[c++]]+"-"+d[a[c++]]+d[a[c++]]+"-"+d[a[c++]]+d[a[c++]]+"-"+d[a[c++]]+d[a[c++]]+d[a[c++]]+d[a[c++]]+d[a[c++]]+d[a[c++]]}function h(a,b,c){var d=b&&c||0,e=b||[];a=a||{};var f=null!=a.clockseq?a.clockseq:u,h=null!=a.msecs?a.msecs:(new Date).getTime(),i=null!=a.nsecs?a.nsecs:w+1,j=h-v+(i-w)/1e4;if(0>j&&null==a.clockseq&&(f=f+1&16383),(0>j||h>v)&&null==a.nsecs&&(i=0),i>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");v=h,w=i,u=f,h+=122192928e5;var k=(1e4*(268435455&h)+i)%4294967296;e[d++]=k>>>24&255,e[d++]=k>>>16&255,e[d++]=k>>>8&255,e[d++]=255&k;var l=h/4294967296*1e4&268435455;e[d++]=l>>>8&255,e[d++]=255&l,e[d++]=l>>>24&15|16,e[d++]=l>>>16&255,e[d++]=f>>>8|128,e[d++]=255&f;for(var m=a.node||t,n=0;6>n;n++)e[d+n]=m[n];return b?b:g(e)}function i(a,b,c){var d=b&&c||0;"string"==typeof a&&(b="binary"===a?new o(16):null,a=null),a=a||{};var e=a.random||(a.rng||j)();if(e[6]=15&e[6]|64,e[8]=63&e[8]|128,b)for(var f=0;16>f;f++)b[d+f]=e[f];return b||g(e)}var j,k,l,m,n;c?d():e();for(var o="function"==typeof Buffer?Buffer:Array,p=[],q={},r=0;256>r;r++)p[r]=(r+256).toString(16).substr(1),q[p[r]]=r;var s=j(),t=[1|s[0],s[1],s[2],s[3],s[4],s[5]],u=16383&(s[6]<<8|s[7]),v=0,w=0,x=i;x.v1=h,x.v4=i,x.parse=f,x.unparse=g,x.BufferClass=o,x._rng=j,x._mathRNG=k,x._nodeRNG=l,x._whatwgRNG=m,"undefined"!=typeof b&&b.exports?b.exports=x:"function"==typeof define&&define.amd?define(function(){return x}):(n=c.uuid,x.noConflict=function(){return c.uuid=n,x},c.uuid=x)}("undefined"!=typeof window?window:null)},{}],3:[function(a,b,c){(function(c){function d(){var a=this,b=Date.now(),c=-1;a.queueTTL>0&&(a.offlineQueue.forEach(function(d,e){d.ts0&&a.offlineQueue.length>a.queueMaxSize&&a.offlineQueue.splice(0,a.offlineQueue.length-a.queueMaxSize).forEach(function(b){a.emitEvent("offlineQueuePop",b.query)})}function e(a,b){var c=Date.now(),d=this;(void 0!==d.jwtToken||b)&&d.socket.once(a.requestId,function(c){"logout"!==a.action&&c.error&&"Token expired"===c.error.message&&(d.jwtToken=void 0,d.emitEvent("jwtTokenExpired",a,b)),b&&b(c.error,c)}),d.socket.emit("kuzzle",a),d.requestHistory[a.requestId]=c,Object.keys(d.requestHistory).forEach(function(a){d.requestHistory[a]0?(e.call(b,b.offlineQueue[0].query,b.offlineQueue[0].cb),b.emitEvent("offlineQueuePop",b.offlineQueue.shift()),setTimeout(function(){d()},Math.max(0,b.replayInterval))):b.queuing=!1};if(b.offlineQueueLoader){if("function"!=typeof b.offlineQueueLoader)throw new Error("Invalid value for offlineQueueLoader property. Expected: function. Got: "+typeof b.offlineQueueLoader);if(a=b.offlineQueueLoader(),!Array.isArray(a))throw new Error("Invalid value returned by the offlineQueueLoader function. Expected: array. Got: "+typeof a);b.offlineQueue=a.concat(b.offlineQueue).filter(function(a){if(!a.query||void 0===a.query.requestId||!a.query.action||!a.query.controller)throw new Error("Invalid offline queue request. One or more missing properties: requestId, action, controller.");return c.hasOwnProperty(a.query.requestId)?!1:c[a.query.requestId]=!0})}d()}function g(){var a=this;Object.keys(a.subscriptions).forEach(function(b){Object.keys(a.subscriptions[b]).forEach(function(c){var d=a.subscriptions[b][c];d.renew(d.callback)})})}var h=a("node-uuid"),i=a("./kuzzleDataCollection"),j=a("./security/kuzzleSecurity"),k=a("./kuzzleMemoryStorage"),l=a("./security/kuzzleUser");b.exports=Kuzzle=function(b,d,e){var f=this;if(!(this instanceof Kuzzle))return new Kuzzle(b,d,e);if(e||"function"!=typeof d||(e=d,d=null),!b||""===b)throw new Error("URL argument missing");return Object.defineProperties(this,{collections:{value:{},writable:!0},connectCB:{value:e},eventListeners:{value:{connected:{lastEmitted:null,listeners:[]},error:{lastEmitted:null,listeners:[]},disconnected:{lastEmitted:null,listeners:[]},reconnected:{lastEmitted:null,listeners:[]},jwtTokenExpired:{lastEmitted:null,listeners:[]},loginAttempt:{lastEmitted:null,listeners:[]},offlineQueuePush:{listeners:[]},offlineQueuePop:{listeners:[]}}},eventTimeout:{value:200},io:{value:null,writable:!0},queuing:{value:!1,writable:!0},requestHistory:{value:{},writable:!0},socket:{value:null,writable:!0},state:{value:"initializing",writable:!0},subscriptions:{value:{pending:{}},writable:!0},autoReconnect:{value:d&&"boolean"==typeof d.autoReconnect?d.autoReconnect:!0,enumerable:!0},defaultIndex:{value:d&&"string"==typeof d.defaultIndex?d.defaultIndex:void 0,writable:!0,enumerable:!0},reconnectionDelay:{value:d&&"number"==typeof d.reconnectionDelay?d.reconnectionDelay:1e3,enumerable:!0},url:{value:b,enumerable:!0},autoQueue:{value:!1,enumerable:!0,writable:!0},autoReplay:{value:!1,enumerable:!0,writable:!0},autoResubscribe:{value:!0,enumerable:!0,writable:!0},headers:{value:{},enumerable:!0,writable:!0},metadata:{value:{},enumerable:!0,writable:!0},offlineQueue:{value:[],enumerable:!0,writable:!0},queueFilter:{value:null,enumerable:!0,writable:!0},queueMaxSize:{value:500,enumerable:!0,writable:!0},queueTTL:{value:12e4,enumerable:!0,writable:!0},replayInterval:{value:10,enumerable:!0,writable:!0},jwtToken:{value:void 0,enumerable:!0,writable:!0},offlineQueueLoader:{value:null,enumerable:!0,writable:!0}}),"undefined"!=typeof window&&window.io?this.io=window.io:this.io=a("socket.io-client"),d&&(Object.keys(d).forEach(function(a){f.hasOwnProperty(a)&&Object.getOwnPropertyDescriptor(f,a).writable&&(f[a]=d[a])}),"auto"===d.offlineMode&&this.autoReconnect&&(this.autoQueue=this.autoReplay=this.autoResubscribe=!0)),Object.defineProperty(this,"isValid",{value:function(){if("disconnected"===f.state)throw new Error("This Kuzzle object has been invalidated. Did you try to access it after a disconnect call?")}}),Object.defineProperty(this,"addHeaders",{value:function(a,b){return Object.keys(b).forEach(function(c){a[c]||(a[c]=b[c])}),a}}),Object.defineProperty(this,"callbackRequired",{value:function(a,b){if(!b||"function"!=typeof b)throw new Error(a+": a callback argument is required for read queries")}}),Object.defineProperty(this,"security",{value:new j(this),enumerable:!0}),Object.defineProperty(this,"emitEvent",{value:function(a){var b=Date.now(),d=Array.prototype.slice.call(arguments,1),e=this.eventListeners[a];return e.lastEmitted&&e.lastEmitted>=b-this.eventTimeout?!1:(e.listeners.forEach(function(a){c.nextTick(function(){a.fn.apply(void 0,d)})}),void(void 0!==e.lastEmitted&&(e.lastEmitted=b)))}}),Object.defineProperty(this,"memoryStorage",{value:new k(this),enumerable:!0}),d&&d.connect&&"auto"!==d.connect?this.state="ready":this.connect(),this.bluebird?this.bluebird.promisifyAll(this,{suffix:"Promise",filter:function(a,b,c,d){var e=["getAllStatistics","getServerInfo","getStatistics","listCollections","listIndexes","login","logout","now","query","checkToken","whoAmI"];return d&&-1!==e.indexOf(a)}}):void 0},Kuzzle.prototype.connect=function(){var a=this;return-1===["initializing","ready","disconnected","error","offline"].indexOf(this.state)?(a.connectCB&&a.connectCB(null,a),a):(a.state="connecting",a.socket=a.io(a.url,{reconnection:a.autoReconnect,reconnectionDelay:a.reconnectionDelay,forceNew:!0}),a.socket.once("connect",function(){a.state="connected",g.call(a),f.call(a),a.emitEvent("connected"),a.connectCB&&a.connectCB(null,a)}),a.socket.on("connect_error",function(b){var c=new Error('Unable to connect to kuzzle server at "'+a.url+'"');c.internal=b,a.state="error",a.emitEvent("error",c),a.connectCB&&a.connectCB(c)}),a.socket.on("disconnect",function(){a.state="offline",a.autoReconnect||a.disconnect(),a.autoQueue&&(a.queuing=!0),a.emitEvent("disconnected")}),a.socket.on("reconnect",function(){var b=function(){a.autoResubscribe&&g.call(a),a.autoReplay&&(d.call(a),f.call(a)),a.emitEvent("reconnected")};a.state="connected",a.jwtToken?a.checkToken(a.jwtToken,function(c,d){(c||!d.valid)&&(a.jwtToken=void 0,a.emitEvent("jwtTokenExpired")),b()}):b()}),this)},Kuzzle.prototype.setJwtToken=function(a){if("string"==typeof a)this.jwtToken=a;else{if("object"!=typeof a)return this.emitEvent("loginAttempt",{success:!1,error:"Invalid token argument: "+a}),this;if(!a.result||!a.result.jwt||"string"!=typeof a.result.jwt)return this.emitEvent("loginAttempt",{success:!1,error:"Cannot find a valid JWT token in the following object: "+JSON.stringify(a)}),this;this.jwtToken=a.result.jwt}return g.call(this),this.emitEvent("loginAttempt",{success:!0}),this},Kuzzle.prototype.getJwtToken=function(){return this.jwtToken},Kuzzle.prototype.login=function(a){var b,c,d=this,e={strategy:a};return arguments[1]&&("object"==typeof arguments[1]?b=arguments[1]:"number"==typeof arguments[1]||"string"==typeof arguments[1]?e.expiresIn=arguments[1]:"function"==typeof arguments[1]&&(c=arguments[1])),arguments[2]&&("number"==typeof arguments[2]||"string"==typeof arguments[2]?e.expiresIn=arguments[2]:"function"==typeof arguments[2]&&(c=arguments[2])),arguments[3]&&"function"==typeof arguments[3]&&(c=arguments[3]),"object"==typeof b&&Object.keys(b).forEach(function(a){e[a]=b[a]}),this.query({controller:"auth",action:"login"},{body:e},{queuable:!1},function(a,b){a?(c&&"function"==typeof c&&c(a),d.emitEvent("loginAttempt",{success:!1,error:a.message})):(b.result.jwt&&d.setJwtToken(b.result.jwt),c&&"function"==typeof c&&c(null,b.result))}),d},Kuzzle.prototype.logout=function(a){var b=this,c={action:"logout",controller:"auth",requestId:h.v4(),body:{}};return this.query({controller:"auth",action:"logout"},c,{queuable:!1},function(c){null===c?(b.jwtToken=void 0,"function"==typeof a&&a(null,b)):"function"==typeof a&&a(c)}),b},Kuzzle.prototype.checkToken=function(a,b){var c=this,d={body:{token:a}};return this.callbackRequired("Kuzzle.checkToken",b),this.query({controller:"auth",action:"checkToken"},d,{queuable:!1},function(a,c){return a?b(a):void b(null,c.result)}),c},Kuzzle.prototype.whoAmI=function(a){var b=this;return b.callbackRequired("Kuzzle.whoAmI",a),b.query({controller:"auth",action:"getCurrentUser"},{},{},function(c,d){return c?a(c):void a(null,new l(b.security,d.result._id,d.result._source))}),b},Kuzzle.prototype.updateSelf=function(a,b,c){var d=this,e={},f={controller:"auth",action:"updateSelf"};c||"function"!=typeof b||(c=b,b=null),e.body=a,c?d.query(f,e,b,function(a,b){return a?c(a):void c(null,b.result)}):d.query(f,e,b)},Kuzzle.prototype.addListener=function(a,b){var c,d=Object.keys(this.eventListeners),e=typeof b;if(this.isValid(),-1===d.indexOf(a))throw new Error("["+a+"] is not a known event. Known events: "+d.toString());if("function"!==e)throw new Error("Invalid listener type: expected a function, got a "+e);return c=h.v1(),this.eventListeners[a].listeners.push({id:c,fn:b}),c},Kuzzle.prototype.getAllStatistics=function(a,b){return b||"function"!=typeof a||(b=a,a=null),this.callbackRequired("Kuzzle.getAllStatistics",b),this.query({controller:"admin",action:"getAllStats"},{},a,function(a,c){return a?b(a):void b(null,c.result.hits)}),this},Kuzzle.prototype.getStatistics=function(a,b,c){var d;return c||(1===arguments.length?(c=arguments[0],b=null,a=null):(c=arguments[1],"object"==typeof arguments[0]?(b=arguments[0],a=null):(a=arguments[0],b=null))),d=function(b,d){return b?c(b):void(a?c(null,d.result.hits):c(null,[d.result]))},this.callbackRequired("Kuzzle.getStatistics",c),a?this.query({controller:"admin",action:"getStats"},{body:{startTime:a}},b,d):this.query({controller:"admin",action:"getLastStats"},{},b,d),this},Kuzzle.prototype.dataCollectionFactory=function(a,b){if(this.isValid(),1===arguments.length?(b=arguments[0],a=this.defaultIndex):2===arguments.length&&"object"==typeof b&&(headers=b,b=a,a=this.defaultIndex),!a)throw new Error("Unable to create a new data collection object: no index specified");return this.collections[a]||(this.collections[a]={}),this.collections[a][b]||(this.collections[a][b]=new i(this,a,b)),this.collections[a][b]},Kuzzle.prototype.flushQueue=function(){return this.offlineQueue=[],this},Kuzzle.prototype.listCollections=function(){var a,b,c,d="all",e=Array.prototype.slice.call(arguments);if(e.forEach(function(d){switch(typeof d){case"string":a=d;break;case"object":b=d;break;case"function":c=d}}),!a){if(!this.defaultIndex)throw new Error("Kuzzle.listCollections: index required");a=this.defaultIndex}return this.callbackRequired("Kuzzle.listCollections",c),b&&b.type&&(d=b.type),this.query({index:a,controller:"read",action:"listCollections"},{body:{type:d}},b,function(a,b){return a?c(a):c(null,b.result.collections)}),this},Kuzzle.prototype.listIndexes=function(a,b){return b||"function"!=typeof a||(b=a,a=null),this.callbackRequired("Kuzzle.listIndexes",b),this.query({controller:"read",action:"listIndexes"},{},a,function(a,c){return a?b(a):b(null,c.result.indexes)}),this},Kuzzle.prototype.disconnect=function(){var a;this.logout(),this.state="disconnected",this.socket.close(),this.socket=null;for(a in this.collections)this.collections.hasOwnProperty(a)&&delete this.collections[a]},Kuzzle.prototype.getServerInfo=function(a,b){return b||"function"!=typeof a||(b=a,a=null),this.callbackRequired("Kuzzle.getServerInfo",b),this.query({controller:"read",action:"serverInfo"},{},a,function(a,c){return a?b(a):void b(null,c.result.serverInfo)}),this},Kuzzle.prototype.refreshIndex=function(){var a,b,c;if(Array.prototype.slice.call(arguments).forEach(function(d){switch(typeof d){case"string":a=d;break;case"object":b=d;break;case"function":c=d}}),!a){if(!this.defaultIndex)throw new Error("Kuzzle.refreshIndex: index required");a=this.defaultIndex}return this.query({index:a,controller:"admin",action:"refreshIndex"},{},b,c),this},Kuzzle.prototype.getAutoRefresh=function(){var a,b,c;if(Array.prototype.slice.call(arguments).forEach(function(d){switch(typeof d){case"string":a=d;break;case"object":b=d;break;case"function":c=d}}),!a){if(!this.defaultIndex)throw new Error("Kuzzle.getAutoRefresh: index required");a=this.defaultIndex}return this.callbackRequired("Kuzzle.getAutoRefresh",c),this.query({index:a,controller:"admin",action:"getAutoRefresh"},{},b,c),this},Kuzzle.prototype.setAutoRefresh=function(){var a,b,c,d;if(Array.prototype.slice.call(arguments).forEach(function(e){switch(typeof e){case"string":a=e;break;case"boolean":b=e;break;case"object":c=e;break;case"function":d=e}}),!a){if(!this.defaultIndex)throw new Error("Kuzzle.setAutoRefresh: index required");a=this.defaultIndex}if(void 0===b)throw new Error("Kuzzle.setAutoRefresh: autoRefresh value is required");return this.query({index:a,controller:"admin",action:"setAutoRefresh"},{body:{autoRefresh:b}},c,d),this},Kuzzle.prototype.now=function(a,b){return b||"function"!=typeof a||(b=a,a=null),this.callbackRequired("Kuzzle.now",b),this.query({controller:"read",action:"now"},{},a,function(a,c){return a?b(a):void b(null,c.result.now)}),this},Kuzzle.prototype.query=function(a,b,c,f){var g,i={action:a.action,controller:a.controller,metadata:this.metadata},j=this;if(this.isValid(),f||"function"!=typeof c||(f=c,c=null),c&&(c.metadata&&Object.keys(c.metadata).forEach(function(a){i.metadata[a]=c.metadata[a]}),c.queuable===!1&&"offline"===j.state))return j;b.metadata&&Object.keys(b.metadata).forEach(function(a){i.metadata[a]=b.metadata[a]});for(g in b)"metadata"!==g&&b.hasOwnProperty(g)&&(i[g]=b[g]);return i=j.addHeaders(i,this.headers),void 0===j.jwtToken||"auth"===i.controller&&"checkToken"===i.action||(i.headers=i.headers||{},i.headers.authorization="Bearer "+j.jwtToken),a.collection&&(i.collection=a.collection),a.index&&(i.index=a.index),i.requestId||(i.requestId=h.v4()),"connected"===j.state||c&&c.queuable===!1?"connected"===j.state?e.call(this,i,f):f&&f(new Error("Unable to execute request: not connected to a Kuzzle server.\nDiscarded request: "+JSON.stringify(i))):(j.queuing||-1!==["initializing","connecting"].indexOf(j.state))&&(d.call(this,i,f),(!j.queueFilter||j.queueFilter(i))&&(j.offlineQueue.push({ts:Date.now(),query:i,cb:f}),j.emitEvent("offlineQueuePush",{query:i,cb:f}))),j},Kuzzle.prototype.removeAllListeners=function(a){var b=Object.keys(this.eventListeners),c=this;if(a){if(-1===b.indexOf(a))throw new Error("["+a+"] is not a known event. Known events: "+b.toString());this.eventListeners[a].listeners=[]}else b.forEach(function(a){c.eventListeners[a].listeners=[]})},Kuzzle.prototype.removeListener=function(a,b){var c=Object.keys(this.eventListeners),d=this;if(-1===c.indexOf(a))throw new Error("["+a+"] is not a known event. Known events: "+c.toString());this.eventListeners[a].listeners.forEach(function(c,e){c.id===b&&d.eventListeners[a].listeners.splice(e,1)})},Kuzzle.prototype.replayQueue=function(){return"offline"===this.state||this.autoReplay||(d.call(this),f.call(this)),this},Kuzzle.prototype.setDefaultIndex=function(a){if("string"!=typeof a)throw new Error("Invalid default index: ["+a+"] (an index name is expected)");if(0===a.length)throw new Error("Cannot set an empty index as the default index");return this.defaultIndex=a,this},Kuzzle.prototype.setHeaders=function(a,b){var c=this;if("object"!=typeof a||Array.isArray(a))throw new Error("Expected a content object, received a "+typeof a);return b?c.headers=a:Object.keys(a).forEach(function(b){c.headers[b]=a[b]}),c},Kuzzle.prototype.startQueuing=function(){return"offline"!==this.state||this.autoQueue||(this.queuing=!0),this},Kuzzle.prototype.stopQueuing=function(){return"offline"!==this.state||this.autoQueue||(this.queuing=!1),this}}).call(this,a("_process"))},{"./kuzzleDataCollection":4,"./kuzzleMemoryStorage":7,"./security/kuzzleSecurity":11,"./security/kuzzleUser":13,_process:1,"node-uuid":2,"socket.io-client":void 0}],4:[function(a,b,c){function d(a,b,c){if(!b||!c)throw new Error("The KuzzleDataCollection object constructor needs an index and a collection arguments");return Object.defineProperties(this,{collection:{value:c,enumerable:!0},index:{value:b,enumerable:!0},kuzzle:{value:a,enumerable:!0},headers:{value:JSON.parse(JSON.stringify(a.headers)),enumerable:!0,writable:!0}}),Object.defineProperty(this,"buildQueryArgs",{value:function(a,b){return{controller:a,action:b,collection:this.collection,index:this.index}}}),this.kuzzle.bluebird?this.kuzzle.bluebird.promisifyAll(this,{suffix:"Promise",filter:function(a,b,c,d){var e=["publishMessage","setHeaders","subscribe"];return d&&-1===e.indexOf(a)}}):this}var e=a("./kuzzleDocument"),f=a("./kuzzleDataMapping"),g=a("./kuzzleRoom");d.prototype.advancedSearch=function(a,b,c){var d,f=this;return c||"function"!=typeof b||(c=b,b=null),f.kuzzle.callbackRequired("KuzzleDataCollection.advancedSearch",c),d=f.kuzzle.addHeaders({body:a},this.headers),f.kuzzle.query(this.buildQueryArgs("read","search"),d,b,function(a,b){var d=[];return a?c(a):(b.result.hits.forEach(function(a){var b=new e(f,a._id,a._source);b.version=a._version,d.push(b)}),void c(null,{total:b.result.total,documents:d}))}),this},d.prototype.count=function(a,b,c){var d;return c||"function"!=typeof b||(c=b,b=null),this.kuzzle.callbackRequired("KuzzleDataCollection.count",c),d=this.kuzzle.addHeaders({body:a},this.headers),this.kuzzle.query(this.buildQueryArgs("read","count"),d,b,function(a,b){return a?c(a):void c(null,b.result.count)}),this},d.prototype.create=function(a,b){var c={};return b||"function"!=typeof a||(b=a,a=null),c=this.kuzzle.addHeaders(c,this.headers),this.kuzzle.query(this.buildQueryArgs("write","createCollection"),c,a,b),this},d.prototype.createDocument=function(a,b,c,d){var f=this,g={},h="create";return a&&"string"!=typeof a&&(d=c,c=b,b=a,a=null),d||"function"!=typeof c||(d=c,c=null),b instanceof e?g=b.serialize():g.body=b,c&&(h=c.updateIfExist?"createOrReplace":"create"),a&&(g._id=a),g=f.kuzzle.addHeaders(g,f.headers),d?f.kuzzle.query(this.buildQueryArgs("write",h),g,c,function(a,b){var c;return a?d(a):(c=new e(f,b.result._id,b.result._source),c.version=b.result._version,void d(null,c))}):f.kuzzle.query(this.buildQueryArgs("write",h),g,c),this},d.prototype.deleteDocument=function(a,b,c){var d,e={};"string"==typeof a?(e._id=a,d="delete"):(e.body=a,d="deleteByQuery"),c||"function"!=typeof b||(c=b,b=null),e=this.kuzzle.addHeaders(e,this.headers),c?this.kuzzle.query(this.buildQueryArgs("write",d),e,b,function(a,b){return a?c(a):void("delete"===d?c(null,[b.result._id]):c(null,b.result.ids))}):this.kuzzle.query(this.buildQueryArgs("write",d),e,b)},d.prototype.fetchDocument=function(a,b,c){var d={_id:a},f=this;return c||"function"!=typeof b||(c=b,b=null),f.kuzzle.callbackRequired("KuzzleDataCollection.fetch",c),d=f.kuzzle.addHeaders(d,this.headers),f.kuzzle.query(this.buildQueryArgs("read","get"),d,b,function(a,b){var d;return a?c(a):(d=new e(f,b.result._id,b.result._source),d.version=b.result._version,void c(null,d))}),this},d.prototype.fetchAllDocuments=function(a,b){return b||"function"!=typeof a||(b=a,a=null),this.kuzzle.callbackRequired("KuzzleDataCollection.fetchAll",b),this.advancedSearch({},a,b),this},d.prototype.getMapping=function(a,b){var c;return b||"function"!=typeof a||(b=a,a=null),this.kuzzle.callbackRequired("KuzzleDataCollection.getMapping",b),c=new f(this),c.refresh(a,b),this},d.prototype.publishMessage=function(a,b){var c={};return a instanceof e?c=a.serialize():c.body=a,c=this.kuzzle.addHeaders(c,this.headers),this.kuzzle.query(this.buildQueryArgs("write","publish"),c,b),this},d.prototype.replaceDocument=function(a,b,c,d){var f=this,g={_id:a,body:b};return d||"function"!=typeof c||(d=c,c=null),g=f.kuzzle.addHeaders(g,this.headers),d?f.kuzzle.query(this.buildQueryArgs("write","createOrReplace"),g,c,function(a,b){var c;return a?d(a):(c=new e(f,b.result._id,b.result._source),c.version=b.result._version,void d(null,c))}):f.kuzzle.query(this.buildQueryArgs("write","createOrReplace"),g,c),this},d.prototype.subscribe=function(a,b,c){var d;return c||"function"!=typeof b||(c=b,b=null),this.kuzzle.callbackRequired("KuzzleDataCollection.subscribe",c),d=new g(this,b),d.renew(a,c)},d.prototype.truncate=function(a,b){var c={};return b||"function"!=typeof a||(b=a,a=null),c=this.kuzzle.addHeaders(c,this.headers),this.kuzzle.query(this.buildQueryArgs("admin","truncateCollection"),c,a,b),this},d.prototype.updateDocument=function(a,b,c,d){var f={_id:a,body:b},g=this;return d||"function"!=typeof c||(d=c,c=null),f=g.kuzzle.addHeaders(f,this.headers),d?g.kuzzle.query(this.buildQueryArgs("write","update"),f,c,function(a,b){var c;return a?d(a):(c=new e(g,b.result._id),void c.refresh(d))}):g.kuzzle.query(this.buildQueryArgs("write","update"),f,c),g},d.prototype.documentFactory=function(a,b){return new e(this,a,b)},d.prototype.roomFactory=function(a){return new g(this,a)},d.prototype.dataMappingFactory=function(a){return new f(this,a)},d.prototype.setHeaders=function(a,b){return this.kuzzle.setHeaders.call(this,a,b),this},b.exports=d},{"./kuzzleDataMapping":5,"./kuzzleDocument":6,"./kuzzleRoom":8}],5:[function(a,b,c){function d(a,b){return Object.defineProperties(this,{collection:{value:a,enumerable:!0},kuzzle:{value:a.kuzzle,enumerable:!0},headers:{value:JSON.parse(JSON.stringify(a.headers)),enumerable:!0,writable:!0},mapping:{value:b||{},enumerable:!0,writable:!0}}),this.kuzzle.bluebird?this.kuzzle.bluebird.promisifyAll(this,{suffix:"Promise",filter:function(a,b,c,d){var e=["set","setHeaders"];return d&&-1===e.indexOf(a)}}):this}d.prototype.apply=function(a,b){var c=this,d=this.kuzzle.addHeaders({body:{properties:this.mapping}},this.headers);return b||"function"!=typeof a||(b=a,a=null),c.kuzzle.query(this.collection.buildQueryArgs("admin","updateMapping"),d,a,function(d){return d?b?b(d):!1:void c.refresh(a,b)}),this},d.prototype.refresh=function(a,b){var c=this,d=this.kuzzle.addHeaders({},this.headers);return b||"function"!=typeof a||(b=a,a=null),this.kuzzle.query(this.collection.buildQueryArgs("admin","getMapping"),d,a,function(a,d){return a?b?b(a):!1:d.result[c.collection.index]?d.result[c.collection.index].mappings[c.collection.collection]?(c.mapping=d.result[c.collection.index].mappings[c.collection.collection].properties,void(b&&b(null,c))):b?b(new Error("No mapping found for collection "+c.collection.collection)):!1:b?b(new Error("No mapping found for index "+c.collection.index)):!1}),this},d.prototype.set=function(a,b){return this.mapping[a]=b,this},d.prototype.setHeaders=function(a,b){return this.kuzzle.setHeaders.call(this,a,b),this},b.exports=d},{}],6:[function(a,b,c){function d(a,b,c){return Object.defineProperties(this,{collection:{value:a.collection,enumerable:!0},dataCollection:{value:a,enumerable:!0},kuzzle:{value:a.kuzzle,enumerable:!0},id:{value:void 0,enumerable:!0,writable:!0},content:{value:{},writable:!0,enumerable:!0},headers:{value:JSON.parse(JSON.stringify(a.headers)),enumerable:!0,writable:!0},version:{value:void 0,enumerable:!0,writable:!0}}),!c&&b&&"object"==typeof b&&(c=b,b=null),c&&(c._version&&(this.version=c._version,delete c._version),this.setContent(c,!0)),b&&Object.defineProperty(this,"id",{value:b,enumerable:!0}),this.kuzzle.bluebird?this.kuzzle.bluebird.promisifyAll(this,{suffix:"Promise",filter:function(a,b,c,d){var e=["delete","refresh","save"];return d&&-1!==e.indexOf(a)}}):this}d.prototype.serialize=function(){var a={};return this.id&&(a._id=this.id),a.body=this.content,a._version=this.version,a=this.kuzzle.addHeaders(a,this.headers)},d.prototype.toString=function(){return JSON.stringify(this.serialize())},d.prototype["delete"]=function(a,b){var c=this;if(b||"function"!=typeof a||(b=a,a=null),!c.id)throw new Error("KuzzleDocument.delete: cannot delete a document without a document ID");b?this.kuzzle.query(this.dataCollection.buildQueryArgs("write","delete"),this.serialize(),a,function(a){return a?b(a):void b(null,c.id)}):this.kuzzle.query(this.dataCollection.buildQueryArgs("write","delete"),this.serialize(),a)},d.prototype.refresh=function(a,b){var c=this;if(b||"function"!=typeof a||(b=a,a=null),!c.id)throw new Error("KuzzleDocument.refresh: cannot retrieve a document if no ID has been provided");this.kuzzle.callbackRequired("KuzzleDocument.refresh",b),c.kuzzle.query(c.dataCollection.buildQueryArgs("read","get"),{_id:c.id},a,function(a,e){var f;return a?b(a):(f=new d(c.dataCollection,c.id,e.result._source),f.version=e.result._version,void b(null,f))})},d.prototype.save=function(a,b){var c=this.serialize(),d=this;return a&&void 0===b&&"function"==typeof a&&(b=a,a=null),d.kuzzle.query(this.dataCollection.buildQueryArgs("write","createOrReplace"),c,a,function(a,c){return a?b?b(a):!1:(d.id=c.result._id,d.version=c.result._version,void(b&&b(null,d)))}),d},d.prototype.publish=function(a){var b=this.serialize();return this.kuzzle.query(this.dataCollection.buildQueryArgs("write","publish"),b,a),this},d.prototype.setContent=function(a,b){var c=this;return b?this.content=a:Object.keys(a).forEach(function(b){c.content[b]=a[b]}),this},d.prototype.subscribe=function(a,b){var c;if(a&&!b&&"function"==typeof a&&(b=a,a=null),this.kuzzle.callbackRequired("KuzzleDocument.subscribe",b),!this.id)throw new Error("KuzzleDocument.subscribe: cannot subscribe to a document if no ID has been provided");return c={ids:{values:[this.id]}},this.dataCollection.subscribe(c,a,b)},d.prototype.setHeaders=function(a,b){return this.kuzzle.setHeaders.call(this,a,b),this},b.exports=d},{}],7:[function(a,b,c){function d(a){return Object.defineProperties(this,{kuzzle:{value:a,enumerable:!0},headers:{value:JSON.parse(JSON.stringify(a.headers)),enumerable:!0,writable:!0}}),this.setHeaders=a.setHeaders.bind(this),this.kuzzle.bluebird?this.kuzzle.bluebird.promisifyAll(this,{suffix:"Promise",filter:function(a,b,c,d){var e=["setHeaders"];return d&&-1===e.indexOf(a)}}):this}!function(){var a=["id","value"],b=["id","keys"],c={append:a,bgrewriteaof:[],bgsave:[],bitcount:["id","start","end"],bitop:["operation","destkey",b],bitpos:["id","bit",{__opts__:["start","end"]}],blpop:[b,"timeout"],brpoplpush:["source","destination"],dbsize:[],decrby:a,del:[b],discard:[],exec:[],exists:[b],expire:["id","seconds"],expireat:["id","timestamp"],flushdb:[],getbit:["id","offset"],getrange:["id","start","end"],hdel:["id",["field","fields"]],hexists:["id","field"],hincrby:["id","field","value"],hmset:["id","values"],hset:["id","field","value"],info:["section"],keys:["pattern"],lastsave:[],lindex:["id","idx"],linsert:["id","position","pivot","value"],lpush:["id",["value","values"]],lrange:["id","start","stop"],lrem:["id","count","value"],lset:["id","idx","value"],ltrim:["id","start","stop"],mset:["values"],multi:[],object:["subcommand","args"],pexpire:["id","milliseconds"],pexpireat:["id","timestamp"],pfadd:["id",["element","elements"]],pfmerge:["destkey",["sourcekey","sourcekeys"]],ping:[],psetex:["id","milliseconds","value"],publish:["channel","message"],randomkey:[],rename:["id","newkey"],renamenx:["id","newkey"],restore:["id","ttl","content"],rpoplpush:["source","destination"],sadd:["id",["member","members"]],save:[],set:["id","value",{__opts__:["ex","px","nx","xx"]}],sdiffstore:["destination",b],setbit:["id","offset","value"],setex:["id","seconds","value"],setrange:["id","offset","value"],sinterstore:["destination",b],sismember:["id","member"],smove:["id","destination","member"],sort:["id",{__opts__:["by","offset","count","get","direction","alpha","store"]}],spop:["id","count"],srem:["id",["member","members"]],sunionstore:["destination",b],unwatch:[],wait:["numslaves","timeout"],zadd:["id",{__opts__:["nx","xx","ch","incr","score","member","members"]}],zcount:["id","min","max"],zincrby:["id","value","member"],zinterstore:["destination",b,{__opts__:["weight","weights","aggregate"]}],zlexcount:["id","min","max"],zrange:["id","start","stop",{__opts__:["withscores"]}],zrangebylex:["id","min","max",{__opts__:["offset","count"]}],zrangebyscore:["id","min","max",{ +__opts__:["withscores","offset","count"]}],zrem:["id","member"],zremrangebylex:["id","min","max"],zremrangebyscore:["id","min","max"],zrevrangebylex:["id","max","min",{__opts__:["offset","count"]}],zrevrangebyscore:["id","max","min",{__opts__:["withscores","offset","count"]}],zrevrank:["id","member"]};c.decr=c.get=c.dump=c.hgetall=c.hkeys=c.hlen=c.hstrlen=c.hvals=c.incr=c.llen=c.lpop=c.persist=c.pttl=c.rpop=c.scard=c.smembers=c.strlen=c.ttl=c.type=c.zcard=["id"],c.getset=c.lpushx=a,c.del=c.exists=c.mget=c.pfcount=c.sdiff=c.sinter=c.sunion=c.watch=[b],c.incrby=c.incrbyfloat=c.decrby,c.brpop=c.blpop,c.hget=c.hexists,c.hmget=c.hdel,c.hsetnx=c.hset,c.msetnx=c.mset,c.rpush=c.lpush,c.hincrbyfloat=c.hincrby,c.srandmember=c.spop,c.zrevrange=c.zrange,c.zscore=c.zrevrank,Object.keys(c).forEach(function(a){d.prototype[a]=function(){var b,d=Array.prototype.slice.call(arguments),e=null,f={controller:"ms",action:a},g={};return"function"==typeof d[d.length-1]&&(b=d.pop()),d.length&&"object"==typeof d[d.length-1]&&1===Object.keys(d[d.length-1]).length&&void 0!==d[d.length-1].queuable&&(e=d.pop()),c[a].forEach(function(a,b){void 0!==d[b]&&(Array.isArray(a)&&(a=Array.isArray(d[b])?a[1]:a[0]),"id"===a?g._id=d[b]:(g.body||(g.body={}),"object"==typeof a&&void 0!==a.__opts__?a.__opts__.forEach(function(a){void 0!==d[b][a]&&(g.body[a]=d[b][a])}):g.body[a]=d[b]))}),this.kuzzle.query(f,g,e,b),this}})}(),b.exports=d},{}],8:[function(a,b,c){function d(a,b){return Object.defineProperties(this,{callback:{value:null,writable:!0},channel:{value:null,writable:!0},id:{value:h.v4()},lastRenewal:{value:null,writable:!0},notifier:{value:null,writable:!0},queue:{value:[],writable:!0},renewalDelay:{value:500},scope:{value:b&&b.scope?b.scope:"all"},state:{value:b&&b.state?b.state:"done"},subscribing:{value:!1,writable:!0},users:{value:b&&b.users?b.users:"none"},collection:{value:a,enumerable:!0},kuzzle:{value:a.kuzzle,enumerable:!0},filters:{value:null,enumerable:!0,writable:!0},headers:{value:JSON.parse(JSON.stringify(a.headers)),enumerable:!0,writable:!0},metadata:{value:b&&b.metadata?b.metadata:{},enumerable:!0,writable:!0},roomId:{value:null,enumerable:!0,writable:!0},subscribeToSelf:{value:b&&"boolean"==typeof b.subscribeToSelf?b.subscribeToSelf:!0,enumerable:!0,writable:!0}}),this.kuzzle.bluebird?this.kuzzle.bluebird.promisifyAll(this,{suffix:"Promise",filter:function(a,b,c,d){var e=["count"];return d&&-1!==e.indexOf(a)}}):this}function e(a){return a.error?this.callback(a.error):"jwtTokenExpired"===a.action?(this.kuzzle.jwtToken=void 0,this.kuzzle.emitEvent("jwtTokenExpired")):void(this.kuzzle.requestHistory[a.requestId]?(this.subscribeToSelf&&this.callback(null,a),delete this.kuzzle.requestHistory[a.requestId]):this.callback(null,a))}function f(){for(var a;this.queue.length>0;)a=this.queue.shift(),this[a.action].apply(this,a.args)}function g(){return"connected"!==this.kuzzle.state||this.subscribing?!1:!0}var h=a("node-uuid");d.prototype.count=function(a){var b;if(this.kuzzle.callbackRequired("KuzzleRoom.count",a),b=this.kuzzle.addHeaders({body:{roomId:this.roomId}},this.headers),!g.call(this))return this.queue.push({action:"count",args:[a]}),this;if(!this.roomId)throw new Error("KuzzleRoom.count: cannot count subscriptions on an inactive room");return this.kuzzle.query(this.collection.buildQueryArgs("subscribe","count"),b,function(b,c){return b?a(b):void a(null,c.result.count)}),this},d.prototype.renew=function(a,b){var c=Date.now(),d={scope:this.scope,state:this.state,users:this.users},g=this;return!b&&a&&"function"==typeof a&&(b=a,a=null),g.kuzzle.callbackRequired("KuzzleRoom.renew",b),g.lastRenewal&&c-g.lastRenewal<=g.renewalDelay?g:(a&&(g.filters=a),"connected"!==g.kuzzle.state?(g.callback=b,g.kuzzle.subscriptions.pending[g.id]=g,g):g.subscribing?(g.queue.push({action:"renew",args:[a,b]}),g):(g.unsubscribe(),g.roomId=null,g.subscribing=!0,g.callback=b,g.kuzzle.subscriptions.pending[g.id]=g,d.body=g.filters,d=g.kuzzle.addHeaders(d,this.headers),g.kuzzle.query(g.collection.buildQueryArgs("subscribe","on"),d,{metadata:g.metadata},function(a,b){if(delete g.kuzzle.subscriptions.pending[g.id],g.subscribing=!1,a)throw g.queue=[],new Error("Error during Kuzzle subscription: "+a.message);g.lastRenewal=c,g.roomId=b.result.roomId,g.channel=b.result.channel,g.kuzzle.subscriptions[g.roomId]||(g.kuzzle.subscriptions[g.roomId]={}),g.kuzzle.subscriptions[g.roomId][g.id]=g,g.notifier=e.bind(g),g.kuzzle.socket.on(g.channel,g.notifier),f.call(g)}),g))},d.prototype.unsubscribe=function(){var a,b=this,c=b.roomId;return g.call(this)?(c&&(b.kuzzle.socket.off(b.channel,this.notifier),1===Object.keys(b.kuzzle.subscriptions[c]).length?(delete b.kuzzle.subscriptions[c],0===Object.keys(b.kuzzle.subscriptions.pending).length?b.kuzzle.query(b.collection.buildQueryArgs("subscribe","off"),{body:{roomId:c}}):a=setInterval(function(){0===Object.keys(b.kuzzle.subscriptions.pending).length&&(b.kuzzle.subscriptions[c]||b.kuzzle.query(b.collection.buildQueryArgs("subscribe","off"),{body:{roomId:c}}),clearInterval(a))},100)):delete b.kuzzle.subscriptions[c][b.id],b.roomId=null),b):(b.queue.push({action:"unsubscribe",args:[]}),b)},d.prototype.setHeaders=function(a,b){return this.kuzzle.setHeaders.call(this,a,b),this},b.exports=d},{"node-uuid":2}],9:[function(a,b,c){function d(a,b,c){return e.call(this,a,b,c),Object.defineProperties(this,{deleteActionName:{value:"deleteProfile"},updateActionName:{value:"updateProfile"}}),c&&c.roles&&(c.roles=c.roles.map(function(b){return b._id&&b._source?new f(a,b._id,b._source):b})),a.kuzzle.bluebird?a.kuzzle.bluebird.promisifyAll(this,{suffix:"Promise",filter:function(a,b,c,d){var e=["hydrate","save"];return d&&-1!==e.indexOf(a)}}):void 0}var e=a("./kuzzleSecurityDocument"),f=a("./kuzzleRole");d.prototype=Object.create(e.prototype,{constructor:{value:d}}),d.prototype.save=function(a,b){var c,d=this;if(!this.content.roles)throw new Error('Argument "roles" is mandatory in a profile. This argument contains an array of KuzzleRole or an array of id string');return a&&void 0===b&&"function"==typeof a&&(b=a,a=null),c=this.serialize(),d.kuzzle.query(d.kuzzleSecurity.buildQueryArgs("createOrReplaceProfile"),c,a,function(a){return a?b?b(a):!1:void(b&&b(null,d))}),d},d.prototype.addRole=function(a){if("string"!=typeof a&&!(a instanceof f))throw new Error('Parameter "roles" must be a KuzzleRole or a id string');return this.content.roles||(this.content.roles=[]),this.content.roles.push(a),this},d.prototype.setRoles=function(a){if(!Array.isArray(a))throw new Error('Parameter "roles" must be an array of KuzzleRole or an array of string');return a.map(function(a){if("string"!=typeof a&&!(a instanceof f))throw new Error('Parameter "roles" must be an array of KuzzleRole or an array of string')}),this.content.roles=a,this},d.prototype.hydrate=function(a,b){var c=this,e={ids:[]};e.ids=this.content.roles.map(function(a){return"string"==typeof a?a:a instanceof f?a.id:void 0}),a&&void 0===b&&"function"==typeof a&&(b=a,a=null),c.kuzzle.callbackRequired("KuzzleProfile.hydrate",b),c.kuzzle.query(c.kuzzleSecurity.buildQueryArgs("mGetRoles"),{body:e},a,function(a,e){return a?b(a):void b(null,new d(c,c.id,{roles:e.result.hits}))})},d.prototype.serialize=function(){var a={};return this.id&&(a._id=this.id),a.body=this.content,a.body.roles&&Array.isArray(a.body.roles)?(a.body.roles=a.body.roles.map(function(a){return a instanceof f?a.id:a}),a):a},d.prototype.getRoles=function(){return this.content.roles},b.exports=d},{"./kuzzleRole":10,"./kuzzleSecurityDocument":12}],10:[function(a,b,c){function d(a,b,c){return e.call(this,a,b,c),Object.defineProperties(this,{deleteActionName:{value:"deleteRole"},updateActionName:{value:"updateRole"}}),a.kuzzle.bluebird?a.kuzzle.bluebird.promisifyAll(this,{suffix:"Promise",filter:function(a,b,c,d){var e=["save"];return d&&-1!==e.indexOf(a)}}):void 0}var e=a("./kuzzleSecurityDocument");d.prototype=Object.create(e.prototype,{constructor:{value:d}}),d.prototype.save=function(a,b){var c=this.serialize(),d=this;a&&void 0===b&&"function"==typeof a&&(b=a,a=null),d.kuzzle.query(this.kuzzleSecurity.buildQueryArgs("createOrReplaceRole"),c,a,function(a){return a?b?b(a):!1:void(b&&b(null,d))})},b.exports=d},{"./kuzzleSecurityDocument":12}],11:[function(a,b,c){function d(a){return Object.defineProperty(this,"kuzzle",{value:a}),Object.defineProperty(this,"buildQueryArgs",{value:function(a){return{controller:"security",action:a}}}),this.kuzzle.bluebird?this.kuzzle.bluebird.promisifyAll(this,{suffix:"Promise",filter:function(a,b,c,d){var e=["roleFactory","profileFactory","userFactory"];return d&&-1===e.indexOf(a)}}):this}var e=a("./kuzzleRole"),f=a("./kuzzleProfile"),g=a("./kuzzleUser");d.prototype.getRole=function(a,b,c){var d,f=this;if(!a)throw new Error("Id parameter is mandatory for getRole function");c||"function"!=typeof b||(c=b,b=null),d={_id:a},f.kuzzle.callbackRequired("KuzzleSecurity.getRole",c),f.kuzzle.query(this.buildQueryArgs("getRole"),d,b,function(a,b){return a?c(a):void c(null,new e(f,b.result._id,b.result._source))})},d.prototype.searchRoles=function(a,b,c){var d=this;c||"function"!=typeof b||(c=b,b=null),d.kuzzle.callbackRequired("KuzzleSecurity.searchRoles",c),d.kuzzle.query(this.buildQueryArgs("searchRoles"),{body:a},b,function(a,b){var f;return a?c(a):(f=b.result.hits.map(function(a){return new e(d,a._id,a._source)}),void c(null,{total:b.result.total,roles:f}))})},d.prototype.createRole=function(a,b,c,d){var f=this,g={},h="createRole";if(!a||"string"!=typeof a)throw new Error("KuzzleSecurity.createRole: cannot create a role without a role ID");d||"function"!=typeof c||(d=c,c=null),g._id=a,g.body=b,c&&(h=c.replaceIfExist?"createOrReplaceRole":"createRole"),d?f.kuzzle.query(this.buildQueryArgs(h),g,c,function(a,b){var c;return a?d(a):(c=new e(f,b.result._id,b.result._source),void d(null,c))}):f.kuzzle.query(this.buildQueryArgs(h),g)},d.prototype.updateRole=function(a,b,c,d){var f=this,g={},h="updateRole";if(!a||"string"!=typeof a)throw new Error("KuzzleSecurity.updateRole: cannot update a role without a role ID");d||"function"!=typeof c||(d=c,c=null),g._id=a,g.body=b,d?f.kuzzle.query(this.buildQueryArgs(h),g,c,function(c){return c?d(c):void d(null,new e(f,a,b))}):f.kuzzle.query(this.buildQueryArgs(h),g)},d.prototype.deleteRole=function(a,b,c){var d={_id:a};c||"function"!=typeof b||(c=b,b=null),c?this.kuzzle.query(this.buildQueryArgs("deleteRole"),d,b,function(a,b){return a?c(a):void c(null,b.result._id)}):this.kuzzle.query(this.buildQueryArgs("deleteRole"),d,b)},d.prototype.roleFactory=function(a,b){return new e(this,a,b)},d.prototype.getProfile=function(a,b,c){var d,e=this,g=!0;if(!a||"string"!=typeof a)throw new Error("Id parameter is mandatory for getProfile function");c||"function"!=typeof b?void 0!==b.hydrate&&(g=b.hydrate):(c=b,b=null),d={_id:a},e.kuzzle.callbackRequired("KuzzleSecurity.getProfile",c),e.kuzzle.query(this.buildQueryArgs("getProfile"),d,b,function(a,b){return a?c(a):(g||(b.result._source.roles=b.result._source.roles.map(function(a){return a._id})),void c(null,new f(e,b.result._id,b.result._source)))})},d.prototype.searchProfiles=function(a,b,c){var d=this;a.hydrate=!0,c||"function"!=typeof b?void 0!==b.hydrate&&(a.hydrate=b.hydrate):(c=b,b=null),d.kuzzle.callbackRequired("KuzzleSecurity.searchProfiles",c),d.kuzzle.query(this.buildQueryArgs("searchProfiles"),{body:a},b,function(a,b){var e;return a?c(a):(e=b.result.hits.map(function(a){return new f(d,a._id,a._source)}),void c(null,{total:b.result.total,profiles:e}))})},d.prototype.createProfile=function(a,b,c,d){var e=this,g={},h="createProfile";if(!a||"string"!=typeof a)throw new Error("KuzzleSecurity.createProfile: cannot create a profile without a profile ID");d||"function"!=typeof c||(d=c,c=null),g._id=a,g.body=b,c&&(h=c.replaceIfExist?"createOrReplaceProfile":"createProfile"),d?e.kuzzle.query(this.buildQueryArgs(h),g,c,function(a,b){var c;return a?d(a):(c=new f(e,b.result._id,b.result._source),void d(null,c))}):e.kuzzle.query(this.buildQueryArgs(h),g)},d.prototype.updateProfile=function(a,b,c,d){var e=this,g={},h="updateProfile";if(!a||"string"!=typeof a)throw new Error("KuzzleSecurity.updateProfile: cannot update a profile without a profile ID");d||"function"!=typeof c||(d=c,c=null),g._id=a,g.body=b,d?e.kuzzle.query(this.buildQueryArgs(h),g,c,function(a,b){var c={};return a?d(a):(Object.keys(b.result._source).forEach(function(a){"roles"!==a&&(c[a]=b.result._source[a])}),c.roles=b.result._source.roles.map(function(a){return a._id}),void d(null,new f(e,b.result._id,c)))}):e.kuzzle.query(this.buildQueryArgs(h),g)},d.prototype.deleteProfile=function(a,b,c){var d={_id:a};c||"function"!=typeof b||(c=b,b=null),c?this.kuzzle.query(this.buildQueryArgs("deleteProfile"),d,b,function(a,b){return a?c(a):void c(null,b.result._id)}):this.kuzzle.query(this.buildQueryArgs("deleteProfile"),d,b)},d.prototype.profileFactory=function(a,b){return new f(this,a,b)},d.prototype.getUser=function(a,b,c){var d,e=this,f=!0;if(!a||"string"!=typeof a)throw new Error("Id parameter is mandatory for getUser function");c||"function"!=typeof b?void 0!==b.hydrate&&(f=b.hydrate):(c=b,b=null),d={_id:a},e.kuzzle.callbackRequired("KuzzleSecurity.getUser",c),e.kuzzle.query(this.buildQueryArgs("getUser"),d,b,function(a,b){return a?c(a):(f||(b.result._source.profile=b.result._source.profile._id),void c(null,new g(e,b.result._id,b.result._source)))})},d.prototype.searchUsers=function(a,b,c){var d=this;a.hydrate=!0,c||"function"!=typeof b?void 0!==b.hydrate&&(a.hydrate=b.hydrate):(c=b,b=null),d.kuzzle.callbackRequired("KuzzleSecurity.searchUsers",c),d.kuzzle.query(this.buildQueryArgs("searchUsers"),{body:a},b,function(a,b){var e;return a?c(a):(e=b.result.hits.map(function(a){return new g(d,a._id,a._source)}),void c(null,{total:b.result.total,users:e}))})},d.prototype.createUser=function(a,b,c,d){var e=this,f={},h="createUser";if(!a||"string"!=typeof a)throw new Error("KuzzleSecurity.createUser: cannot create a user without a user ID");d||"function"!=typeof c||(d=c,c=null),f._id=a,f.body=b,c&&(h=c.replaceIfExist?"createOrReplaceUser":"createUser"),d?e.kuzzle.query(this.buildQueryArgs(h),f,null,function(a,b){var c;return a?d(a):(c=new g(e,b.result._id,b.result._source),void d(null,c))}):e.kuzzle.query(this.buildQueryArgs(h),f)},d.prototype.updateUser=function(a,b,c,d){var e=this,f={},h="updateUser";if(!a||"string"!=typeof a)throw new Error("KuzzleSecurity.updateUser: cannot update an user without an user ID");d||"function"!=typeof c||(d=c,c=null),f._id=a,f.body=b,d?e.kuzzle.query(this.buildQueryArgs(h),f,c,function(a,b){return a?d(a):void d(null,new g(e,b.result._id,b.result._source))}):e.kuzzle.query(this.buildQueryArgs(h),f,c)},d.prototype.deleteUser=function(a,b,c){var d={_id:a};c||"function"!=typeof b||(c=b,b=null),c?this.kuzzle.query(this.buildQueryArgs("deleteUser"),d,b,function(a,b){return a?c(a):void c(null,b.result._id)}):this.kuzzle.query(this.buildQueryArgs("deleteUser"),d,b)},d.prototype.userFactory=function(a,b){return new g(this,a,b)},b.exports=d},{"./kuzzleProfile":9,"./kuzzleRole":10,"./kuzzleUser":13}],12:[function(a,b,c){function d(a,b,c){if(!b)throw new Error("A security document must have an id");return Object.defineProperties(this,{kuzzle:{value:a.kuzzle},kuzzleSecurity:{value:a},id:{value:b,enumerable:!0},content:{value:{},writable:!0,enumerable:!0}}),c&&this.setContent(c,!0),a.kuzzle.bluebird?a.kuzzle.bluebird.promisifyAll(this,{suffix:"Promise",filter:function(a,b,c,d){var e=["delete","update"];return d&&-1!==e.indexOf(a)}}):void 0}d.prototype.setContent=function(a){return this.content=a,this},d.prototype.serialize=function(){var a={};return this.id&&(a._id=this.id),a.body=this.content,a},d.prototype["delete"]=function(a,b){var c=this;a&&void 0===b&&"function"==typeof a&&(b=a,a=null),c.kuzzle.query(this.kuzzleSecurity.buildQueryArgs(this.deleteActionName),{_id:this.id},a,function(a,c){return a?b?b(a):!1:void(b&&b(null,c.result._id))})},d.prototype.update=function(a,b,c){var d={},e=this;if("object"!=typeof a)throw new Error('Parameter "content" must be a object');b&&void 0===c&&"function"==typeof b&&(c=b,b=null),d._id=e.id,d.body=a,e.kuzzle.query(this.kuzzleSecurity.buildQueryArgs(this.updateActionName),d,b,function(a,b){return a?c?c(a):!1:(e.setContent(b.result._source),void(c&&c(null,e)))})},b.exports=d},{}],13:[function(a,b,c){function d(a,b,c){return e.call(this,a,b,c),c.profile&&c.profile._id&&c.profile._source&&(this.content.profile=new f(a,c.profile._id,c.profile._source)),Object.defineProperties(this,{deleteActionName:{value:"deleteUser"},updateActionName:{value:"updateUser"}}),a.kuzzle.bluebird?a.kuzzle.bluebird.promisifyAll(this,{suffix:"Promise",filter:function(a,b,c,d){var e=["hydrate","save"];return d&&-1!==e.indexOf(a)}}):void 0}var e=a("./kuzzleSecurityDocument"),f=a("./kuzzleProfile");d.prototype=Object.create(e.prototype,{constructor:{value:d}}),d.prototype.hydrate=function(a,b){var c=this;if(a&&void 0===b&&"function"==typeof a&&(b=a,a=null),c.kuzzle.callbackRequired("KuzzleUser.hydrate",b),!this.content.profile||"string"!=typeof this.content.profile)throw new Error("The User must contains a profile as string in order to be hydrated");c.kuzzle.query(this.kuzzleSecurity.buildQueryArgs("getProfile"),{_id:this.content.profile},a,function(a,e){var g;return a?b(a):(g=new d(c.kuzzleSecurity,c.id,c.content),g.setProfile(new f(c.kuzzleSecurity,e.result._id,e.result._source)),void b(null,g))})},d.prototype.setProfile=function(a){if("string"!=typeof a&&!(a instanceof f))throw new Error('Parameter "profile" must be a KuzzleProfile or a string');return this.content.profile=a,this},d.prototype.save=function(a,b){var c=this.serialize(),d=this;return a&&void 0===b&&"function"==typeof a&&(b=a,a=null),d.kuzzle.query(this.kuzzleSecurity.buildQueryArgs("createOrReplaceUser"),c,a,function(a){return a?b?b(a):!1:void(b&&b(null,d))}),d},d.prototype.serialize=function(){var a={};return this.id&&(a._id=this.id),a.body=this.content,a.body.profile&&a.body.profile.id&&(a.body.profile=a.body.profile.id),a},d.prototype.getProfiles=function(){return this.content.profile},b.exports=d},{"./kuzzleProfile":9,"./kuzzleSecurityDocument":12}]},{},[3]); //# sourceMappingURL=kuzzle.min.map \ No newline at end of file diff --git a/dist/kuzzle.min.map b/dist/kuzzle.min.map index a0ec0af74..21a30def1 100644 --- a/dist/kuzzle.min.map +++ b/dist/kuzzle.min.map @@ -1 +1 @@ -{"version":3,"sources":["kuzzle.js"],"names":["e","t","n","r","s","o","u","a","require","i","f","Error","code","l","exports","call","length","1","module","cleanUpNextTick","draining","currentQueue","queue","concat","queueIndex","drainQueue","timeout","setTimeout","len","run","clearTimeout","Item","fun","array","this","noop","process","nextTick","args","Array","arguments","push","prototype","apply","title","browser","env","argv","version","versions","on","addListener","once","off","removeListener","removeAllListeners","emit","binding","name","cwd","chdir","dir","umask","2","_window","setupBrowser","_crypto","crypto","msCrypto","_rng","getRandomValues","_rnds8","Uint8Array","_whatwgRNG","_rnds","_mathRNG","Math","random","console","warn","setupNode","_rb","randomBytes","_nodeRNG","parse","buf","offset","ii","toLowerCase","replace","oct","_hexToByte","unparse","bth","_byteToHex","v1","options","b","clockseq","_clockseq","msecs","Date","getTime","nsecs","_lastNSecs","dt","_lastMSecs","tl","tmh","node","_nodeId","v4","BufferClass","rnds","rng","_previousRoot","Buffer","toString","substr","_seedBytes","uuid","define","amd","noConflict","window","3","cleanQueue","self","now","lastDocumentIndex","queueTTL","offlineQueue","forEach","query","index","ts","splice","droppedRequest","emitEvent","queueMaxSize","emitRequest","request","cb","undefined","jwtToken","socket","requestId","response","action","error","message","requestHistory","Object","keys","key","dequeue","additionalQueue","uniqueQueue","dequeuingProcess","shift","max","replayInterval","queuing","offlineQueueLoader","isArray","filter","controller","hasOwnProperty","renewAllSubscriptions","subscriptions","roomId","subscriptionId","subscription","renew","callback","KuzzleDataCollection","KuzzleSecurity","KuzzleMemoryStorage","KuzzleUser","Kuzzle","url","defineProperties","collections","value","writable","connectCB","eventListeners","connected","lastEmitted","listeners","disconnected","reconnected","jwtTokenExpired","loginAttempt","offlineQueuePush","offlineQueuePop","eventTimeout","io","state","pending","autoReconnect","enumerable","defaultIndex","reconnectionDelay","autoQueue","autoReplay","autoResubscribe","headers","metadata","queueFilter","opt","getOwnPropertyDescriptor","offlineMode","defineProperty","header","errorMessagePrefix","event","slice","eventProperties","listener","fn","connect","bluebird","promisifyAll","suffix","func","target","passes","whitelist","indexOf","reconnection","forceNew","connectionError","internal","disconnect","reconnect","checkToken","err","res","valid","setJwtToken","token","success","result","jwt","JSON","stringify","getJwtToken","login","strategy","credentials","expiresIn","body","queuable","logout","callbackRequired","whoAmI","security","_id","_source","updateSelf","content","data","queryArgs","listenerId","knownEvents","listenerType","isValid","id","getAllStatistics","hits","getStatistics","timestamp","queryCB","startTime","dataCollectionFactory","collection","flushQueue","listCollections","collectionType","arg","type","listIndexes","indexes","close","getServerInfo","serverInfo","attr","object","meta","addHeaders","authorization","eventName","replayQueue","setDefaultIndex","setHeaders","startQueuing","stopQueuing","./kuzzleDataCollection","./kuzzleMemoryStorage","./security/kuzzleSecurity","./security/kuzzleUser","_process","node-uuid","socket.io-client","4","kuzzle","blacklist","KuzzleDocument","KuzzleDataMapping","KuzzleRoom","advancedSearch","filters","buildQueryArgs","documents","doc","newDocument","_version","total","count","create","createDocument","document","serialize","updateIfExist","deleteDocument","ids","fetchDocument","documentId","fetchAllDocuments","getMapping","kuzzleMapping","refresh","publishMessage","replaceDocument","subscribe","room","truncate","updateDocument","documentFactory","roomFactory","dataMappingFactory","mapping","./kuzzleDataMapping","./kuzzleDocument","./kuzzleRoom","5","kuzzleDataCollection","properties","mappings","set","field","6","dataCollection","setContent","save","publish","values","7","bind","keyVal","idOrKeys","commands","append","bgrewriteaof","bgsave","bitcount","bitop","bitpos","__opts__","blpop","brpoplpush","dbsize","decrby","del","discard","exec","exists","expire","expireat","flushdb","getbit","getrange","hdel","hexists","hincrby","hmset","hset","info","lastsave","lindex","linsert","lpush","lrange","lrem","lset","ltrim","mset","multi","pexpire","pexpireat","pfadd","pfmerge","ping","psetex","randomkey","rename","renamenx","restore","rpoplpush","sadd","sdiffstore","setbit","setex","setrange","sinterstore","sismember","smove","sort","spop","srem","sunionstore","unwatch","wait","zadd","zcount","zincrby","zinterstore","zlexcount","zrange","zrangebylex","zrangebyscore","zrem","zremrangebylex","zremrangebyscore","zrevrangebylex","zrevrangebyscore","zrevrank","decr","get","dump","hgetall","hkeys","hlen","hstrlen","hvals","incr","llen","lpop","persist","pttl","rpop","scard","smembers","strlen","ttl","zcard","getset","lpushx","mget","pfcount","sdiff","sinter","sunion","watch","incrby","incrbyfloat","brpop","hget","hmget","hsetnx","msetnx","rpush","hincrbyfloat","srandmember","zrevrange","zscore","command","pop","v","8","channel","lastRenewal","notifier","renewalDelay","scope","subscribing","users","subscribeToSelf","notificationCallback","element","isReady","subscribeQuery","unsubscribe","interval","setInterval","clearInterval","9","KuzzleProfile","kuzzleSecurity","KuzzleSecurityDocument","deleteActionName","updateActionName","roles","map","role","KuzzleRole","constructor","addRole","setRoles","hydrate","getRoles","./kuzzleRole","./kuzzleSecurityDocument","10","11","getRole","searchRoles","createRole","replaceIfExist","updateRole","deleteRole","roleFactory","getProfile","searchProfiles","profiles","createProfile","updateProfile","deleteProfile","profileFactory","getUser","profile","searchUsers","createUser","updateUser","deleteUser","userFactory","./kuz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eAAgBhW,EAASgG,OAAOe,IAAK/G,EAASgG,OAAOgB,cAEpGrH,GAAG,KAAMgZ,OAUb5W,EAAWxI,UAAUqf,WAAa,SAAUZ,GAE1C,GAAuB,gBAAZA,MAA0BA,YAAmBjC,IACtD,KAAM,IAAIve,OAAM,0DAKlB,OAFAuB,MAAKmO,QAAQ8Q,QAAUA,EAEhBjf,MAcTgJ,EAAWxI,UAAUyT,KAAO,SAAUnQ,EAAS8C,GAC7C,GACEwH,GAAOpO,KAAKiS,YACZpM,EAAO7F,IAiBT,OAfI8D,IAAkB+C,SAAPD,GAAuC,kBAAZ9C,KACxC8C,EAAK9C,EACLA,EAAU,MAGZ+B,EAAKmL,OAAO7K,MAAMnG,KAAKid,eAAe1L,eAAe,uBAAwBnD,EAAMtK,EAAS,SAAUqD,GACpG,MAAIA,GACKP,EAAKA,EAAGO,IAAS,OAGtBP,GACFA,EAAG,KAAMf,MAINA,GAQTmD,EAAWxI,UAAUyR,UAAY,WAC/B,GACE7D,KAYF,OAVIpO,MAAK0O,KACPN,EAAKJ,IAAMhO,KAAK0O,IAGlBN,EAAKV,KAAO1N,KAAKmO,QAEbC,EAAKV,KAAKuR,SAAW7Q,EAAKV,KAAKuR,QAAQvQ,KACzCN,EAAKV,KAAKuR,QAAU7Q,EAAKV,KAAKuR,QAAQvQ,IAGjCN,GAQTpF,EAAWxI,UAAUsf,YAAc,WACjC,MAAO9f,MAAKmO,QAAQ8Q,SAGtBjgB,EAAOJ,QAAUoK,IAEduW,kBAAkB,EAAExB,2BAA2B,UAAU","file":"kuzzle.min.js"} \ No newline at end of file +{"version":3,"sources":["kuzzle.js"],"names":["e","t","n","r","s","o","u","a","require","i","f","Error","code","l","exports","call","length",1,"module","cleanUpNextTick","draining","currentQueue","queue","concat","queueIndex","drainQueue","timeout","setTimeout","len","run","clearTimeout","Item","fun","array","this","noop","process","nextTick","args","Array","arguments","push","prototype","apply","title","browser","env","argv","version","versions","on","addListener","once","off","removeListener","removeAllListeners","emit","binding","name","cwd","chdir","dir","umask",2,"_window","setupBrowser","_crypto","crypto","msCrypto","_rng","getRandomValues","_rnds8","Uint8Array","_whatwgRNG","_rnds","_mathRNG","Math","random","console","warn","setupNode","_rb","randomBytes","_nodeRNG","parse","buf","offset","ii","toLowerCase","replace","oct","_hexToByte","unparse","bth","_byteToHex","v1","options","b","clockseq","_clockseq","msecs","Date","getTime","nsecs","_lastNSecs","dt","_lastMSecs","tl","tmh","node","_nodeId","v4","BufferClass","rnds","rng","_previousRoot","Buffer","toString","substr","_seedBytes","uuid","define","amd","noConflict","window",3,"cleanQueue","self","now","lastDocumentIndex","queueTTL","offlineQueue","forEach","query","index","ts","splice","droppedRequest","emitEvent","queueMaxSize","emitRequest","request","cb","undefined","jwtToken","socket","requestId","response","action","error","message","requestHistory","Object","keys","key","dequeue","additionalQueue","uniqueQueue","dequeuingProcess","shift","max","replayInterval","queuing","offlineQueueLoader","isArray","filter","controller","hasOwnProperty","renewAllSubscriptions","subscriptions","roomId","subscriptionId","subscription","renew","callback","KuzzleDataCollection","KuzzleSecurity","KuzzleMemoryStorage","KuzzleUser","Kuzzle","url","defineProperties","collections","value","writable","connectCB","eventListeners","connected","lastEmitted","listeners","disconnected","reconnected","jwtTokenExpired","loginAttempt","offlineQueuePush","offlineQueuePop","eventTimeout","io","state","pending","autoReconnect","enumerable","defaultIndex","reconnectionDelay","autoQueue","autoReplay","autoResubscribe","headers","metadata","queueFilter","opt","getOwnPropertyDescriptor","offlineMode","defineProperty","header","errorMessagePrefix","event","slice","eventProperties","listener","fn","connect","bluebird","promisifyAll","suffix","func","target","passes","whitelist","indexOf","reconnection","forceNew","connectionError","internal","disconnect","reconnect","checkToken","err","res","valid","setJwtToken","token","success","result","jwt","JSON","stringify","getJwtToken","login","strategy","credentials","expiresIn","body","queuable","logout","callbackRequired","whoAmI","security","_id","_source","updateSelf","content","data","queryArgs","listenerId","knownEvents","listenerType","isValid","id","getAllStatistics","hits","getStatistics","timestamp","queryCB","startTime","dataCollectionFactory","collection","flushQueue","listCollections","collectionType","arg","type","listIndexes","indexes","close","getServerInfo","serverInfo","refreshIndex","getAutoRefresh","setAutoRefresh","autoRefresh","attr","object","meta","addHeaders","authorization","eventName","replayQueue","setDefaultIndex","setHeaders","startQueuing","stopQueuing","./kuzzleDataCollection","./kuzzleMemoryStorage","./security/kuzzleSecurity","./security/kuzzleUser","_process","node-uuid","socket.io-client",4,"kuzzle","blacklist","KuzzleDocument","KuzzleDataMapping","KuzzleRoom","advancedSearch","filters","buildQueryArgs","documents","doc","newDocument","_version","total","count","create","createDocument","document","serialize","updateIfExist","deleteDocument","ids","fetchDocument","documentId","fetchAllDocuments","getMapping","kuzzleMapping","refresh","publishMessage","replaceDocument","subscribe","room","truncate","updateDocument","documentFactory","roomFactory","dataMappingFactory","mapping","./kuzzleDataMapping","./kuzzleDocument","./kuzzleRoom",5,"kuzzleDataCollection","properties","mappings","set","field",6,"dataCollection","setContent","save","publish","values",7,"bind","keyVal","idOrKeys","commands","append","bgrewriteaof","bgsave","bitcount","bitop","bitpos","__opts__","blpop","brpoplpush","dbsize","decrby","del","discard","exec","exists","expire","expireat","flushdb","getbit","getrange","hdel","hexists","hincrby","hmset","hset","info","lastsave","lindex","linsert","lpush","lrange","lrem","lset","ltrim","mset","multi","pexpire","pexpireat","pfadd","pfmerge","ping","psetex","randomkey","rename","renamenx","restore","rpoplpush","sadd","sdiffstore","setbit","setex","setrange","sinterstore","sismember","smove","sort","spop","srem","sunionstore","unwatch","wait","zadd","zcount","zincrby","zinterstore","zlexcount","zrange","zrangebylex","zrangebyscore","zrem","zremrangebylex","zremrangebyscore","zrevrangebylex","zrevrangebyscore","zrevrank","decr","get","dump","hgetall","hkeys","hlen","hstrlen","hvals","incr","llen","lpop","persist","pttl","rpop","scard","smembers","strlen","ttl","zcard","getset","lpushx","mget","pfcount","sdiff","sinter","sunion","watch","incrby","incrbyfloat","brpop","hget","hmget","hsetnx","msetnx","rpush","hincrbyfloat","srandmember","zrevrange","zscore","command","pop","v",8,"channel","lastRenewal","notifier","renewalDelay","scope","subscribing","users","subscribeToSelf","notificationCallback","element","isReady","subscribeQuery","unsubscribe","interval","setInterval","clearInterval",9,"KuzzleProfile","kuzzleSecurity","KuzzleSecurityDocument","deleteActionName","updateActionName","roles","map","role","KuzzleRole","constructor","addRole","setRoles","hydrate","getRoles","./kuzzleRole","./kuzzleSecurityDocument",10,11,"getRole","searchRoles","createRole","replaceIfExist","updateRole","deleteRole","roleFactory","getProfile","searchProfiles","profiles","createProfile","updateProfile","updatedContent","property","deleteProfile","profileFactory","getUser","profile","searchUsers","createUser","updateUser","deleteUser","userFactory","./kuzzleProfile","./kuzzleUser",12,"update",13,"hydratedUser","setProfile","getProfiles"],"mappings":";CAAA,QAAUA,GAAEC,EAAEC,EAAEC,GAAG,QAASC,GAAEC,EAAEC,GAAG,IAAIJ,EAAEG,GAAG,CAAC,IAAIJ,EAAEI,GAAG,CAAC,GAAIE,GAAkB,kBAATC,UAAqBA,OAAQ,KAAIF,GAAGC,EAAE,MAAOA,GAAEF,GAAE,EAAI,IAAGI,EAAE,MAAOA,GAAEJ,GAAE,EAAI,IAAIK,GAAE,GAAIC,OAAM,uBAAuBN,EAAE,IAAK,MAAMK,GAAEE,KAAK,mBAAmBF,EAAE,GAAIG,GAAEX,EAAEG,IAAIS,WAAYb,GAAEI,GAAG,GAAGU,KAAKF,EAAEC,QAAQ,SAASd,GAAG,GAAIE,GAAED,EAAEI,GAAG,GAAGL,EAAG,OAAOI,GAAEF,EAAEA,EAAEF,IAAIa,EAAEA,EAAEC,QAAQd,EAAEC,EAAEC,EAAEC,GAAG,MAAOD,GAAEG,GAAGS,QAAkD,IAAI,GAA1CL,GAAkB,kBAATD,UAAqBA,QAAgBH,EAAE,EAAEA,EAAEF,EAAEa,OAAOX,IAAID,EAAED,EAAEE,GAAI,OAAOD,KAAKa,GAAG,SAAST,EAAQU,EAAOJ,GASvd,QAASK,KACLC,GAAW,EACPC,EAAaL,OACbM,EAAQD,EAA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,MAGZ+B,EAAKuL,OAAOjL,MAAMnG,KAAKqd,eAAe1L,eAAe,uBAAwBvD,EAAMtK,EAAS,SAAUqD,GACpG,MAAIA,GACKP,EAAKA,EAAGO,IAAS,OAGtBP,GACFA,EAAG,KAAMf,MAINA,GAQTmD,EAAWxI,UAAU6R,UAAY,WAC/B,GACEjE,KAYF,OAVIpO,MAAK0O,KACPN,EAAKJ,IAAMhO,KAAK0O,IAGlBN,EAAKV,KAAO1N,KAAKmO,QAEbC,EAAKV,KAAK6R,SAAWnR,EAAKV,KAAK6R,QAAQ7Q,KACzCN,EAAKV,KAAK6R,QAAUnR,EAAKV,KAAK6R,QAAQ7Q,IAGjCN,GAQTpF,EAAWxI,UAAU4f,YAAc,WACjC,MAAOpgB,MAAKmO,QAAQoR,SAGtBvgB,EAAOJ,QAAUoK,IAEd6W,kBAAkB,EAAE1B,2BAA2B,UAAU","file":"kuzzle.min.js"} \ No newline at end of file diff --git a/package.json b/package.json index 6422a4f7f..52b1bc75c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kuzzle-sdk", - "version": "1.8.0", + "version": "1.9.0", "description": "Official Javascript SDK for Kuzzle", "author": "The Kuzzle Team ", "repository": { @@ -41,6 +41,7 @@ "mocha": "2.4.5", "proxyquire": "^1.7.3", "rewire": "^2.5.0", - "should": "8.2.2" + "should": "8.2.2", + "sinon": "^1.17.4" } } diff --git a/src/kuzzle.js b/src/kuzzle.js index 12bf53e3d..a8790a923 100644 --- a/src/kuzzle.js +++ b/src/kuzzle.js @@ -592,6 +592,29 @@ Kuzzle.prototype.whoAmI = function (callback) { return self; }; +/** + * Gets the rights array of the currently logged user. + * + * @param {function} cb The callback containing the normalized array of rights. + */ +Kuzzle.prototype.getMyRights = function (options, cb) { + var self = this; + + if (!cb && typeof options === 'function') { + cb = options; + options = null; + } + + self.callbackRequired('Kuzzle.getMyRights', cb); + + self.query({controller: 'auth', action:'getMyRights'}, {}, null, function (err, res) { + if (err) { + return cb(err); + } + + cb(null, res.result.hits); + }); +}; /** * Update current user in Kuzzle. @@ -873,25 +896,27 @@ Kuzzle.prototype.getStatistics = function (timestamp, options, cb) { * Create a new instance of a KuzzleDataCollection object. * If no index is specified, takes the default index. * - * @param {string} [index] - The name of the data index containing the data collection * @param {string} collection - The name of the data collection you want to manipulate + * @param {string} [index] - The name of the data index containing the data collection * @returns {object} A KuzzleDataCollection instance */ -Kuzzle.prototype.dataCollectionFactory = function(index, collection) { +Kuzzle.prototype.dataCollectionFactory = function(collection, index) { this.isValid(); - if (arguments.length === 1) { - collection = arguments[0]; + if (!index) { + if (!this.defaultIndex) { + throw new Error('Unable to create a new data collection object: no index specified'); + } + index = this.defaultIndex; } - else if (arguments.length === 2 && typeof collection === 'object') { - headers = collection; - collection = index; - index = this.defaultIndex; + + if (typeof index !== 'string') { + throw new Error('Invalid "index" argument: string expected, got ' + typeof index); } - if (!index) { - throw new Error('Unable to create a new data collection object: no index specified'); + if (typeof collection !== 'string') { + throw new Error('Invalid "collection" argument: string expected, got ' + typeof collection); } if (!this.collections[index]) { @@ -1041,6 +1066,136 @@ Kuzzle.prototype.getServerInfo = function (options, cb) { return this; }; +/** + * Forces an index refresh + * + * @param {string} index - The index to refresh. Defaults to Kuzzle.defaultIndex + * @param {object} options - Optional arguments + * @param {responseCallback} cb - Handles the query response + * @returns {Kuzzle} + */ +Kuzzle.prototype.refreshIndex = function () { + var + index, + options, + cb; + + Array.prototype.slice.call(arguments).forEach(function(arg) { + switch (typeof arg) { + case 'string': + index = arg; + break; + case 'object': + options = arg; + break; + case 'function': + cb = arg; + break; + } + }); + + if (!index) { + if (!this.defaultIndex) { + throw new Error('Kuzzle.refreshIndex: index required'); + } + index = this.defaultIndex; + } + + this.query({ index: index, controller: 'admin', action: 'refreshIndex'}, {}, options, cb); + + return this; +}; + +/** + * Returns de current autoRefresh status for the given index + * + * @param {string} index - The index to get the status from. Defaults to Kuzzle.defaultIndex + * @param {object} options - Optinal arguments + * @param {responseCallback} cb - Handles the query response + * @returns {object} this + */ +Kuzzle.prototype.getAutoRefresh = function () { + var + index, + options, + cb; + + Array.prototype.slice.call(arguments).forEach(function (arg) { + switch (typeof arg) { + case 'string': + index = arg; + break; + case 'object': + options = arg; + break; + case 'function': + cb = arg; + break; + } + }); + + if (!index) { + if (!this.defaultIndex) { + throw new Error('Kuzzle.getAutoRefresh: index required'); + } + index = this.defaultIndex; + } + + this.callbackRequired('Kuzzle.getAutoRefresh', cb); + this.query({ index: index, controller: 'admin', action: 'getAutoRefresh'}, {}, options, cb); + + return this; +}; + +/** + * (Un)Sets the autoRefresh flag on the given index + * + * @param {string} index - the index to modify. Defaults to Kuzzle.defaultIndex + * @param {boolean} autoRefresh - The autoRefresh value to set + * @param {object} options - Optional arguments + * @param {responseCallback} cb - Handles the query result + * @returns {object} this + */ +Kuzzle.prototype.setAutoRefresh = function () { + var + index, + autoRefresh, + options, + cb; + + Array.prototype.slice.call(arguments).forEach(function (arg) { + switch (typeof arg) { + case 'string': + index = arg; + break; + case 'boolean': + autoRefresh = arg; + break; + case 'object': + options = arg; + break; + case 'function': + cb = arg; + break; + } + }); + + if (!index) { + if (!this.defaultIndex) { + throw new Error('Kuzzle.setAutoRefresh: index required'); + } + index = this.defaultIndex; + } + + if (autoRefresh === undefined) { + throw new Error('Kuzzle.setAutoRefresh: autoRefresh value is required'); + } + + this.query({ index: index, controller: 'admin', action: 'setAutoRefresh'}, { body: { autoRefresh: autoRefresh }}, options, cb); + + return this; +}; + /** * Return the current Kuzzle's UTC Epoch time, in milliseconds * @param {object} [options] - Optional parameters diff --git a/src/kuzzleDataCollection.js b/src/kuzzleDataCollection.js index a10d68e2d..29d7eec57 100644 --- a/src/kuzzleDataCollection.js +++ b/src/kuzzleDataCollection.js @@ -298,8 +298,6 @@ KuzzleDataCollection.prototype.deleteDocument = function (arg, options, cb) { } else { this.kuzzle.query(this.buildQueryArgs('write', action), data, options); } - - return this; }; /** @@ -346,14 +344,27 @@ KuzzleDataCollection.prototype.fetchDocument = function (documentId, options, cb * @returns {Object} this */ KuzzleDataCollection.prototype.fetchAllDocuments = function (options, cb) { + var filters = {}; + if (!cb && typeof options === 'function') { cb = options; options = null; } + // copying pagination options to the search filter + if (options) { + if (options.from) { + filters.from = options.from; + } + + if (options.size) { + filters.size = options.size; + } + } + this.kuzzle.callbackRequired('KuzzleDataCollection.fetchAll', cb); - this.advancedSearch({}, options, cb); + this.advancedSearch(filters, options, cb); return this; }; diff --git a/src/kuzzleDocument.js b/src/kuzzleDocument.js index 6d218b762..3cb940e2e 100644 --- a/src/kuzzleDocument.js +++ b/src/kuzzleDocument.js @@ -142,7 +142,7 @@ KuzzleDocument.prototype.delete = function (options, cb) { options = null; } - if (!this.id) { + if (!self.id) { throw new Error('KuzzleDocument.delete: cannot delete a document without a document ID'); } @@ -152,13 +152,11 @@ KuzzleDocument.prototype.delete = function (options, cb) { return cb(err); } - cb(null, self); + cb(null, self.id); }); } else { this.kuzzle.query(this.dataCollection.buildQueryArgs('write', 'delete'), this.serialize(), options); } - - return this; }; /** diff --git a/src/security/kuzzleSecurity.js b/src/security/kuzzleSecurity.js index 1b3881f71..efa7bbf29 100644 --- a/src/security/kuzzleSecurity.js +++ b/src/security/kuzzleSecurity.js @@ -29,7 +29,7 @@ function KuzzleSecurity(kuzzle) { return this.kuzzle.bluebird.promisifyAll(this, { suffix: 'Promise', filter: function (name, func, target, passes) { - var blacklist = ['roleFactory', 'profileFactory', 'userFactory']; + var blacklist = ['roleFactory', 'profileFactory', 'userFactory', 'isActionAllowed']; return passes && blacklist.indexOf(name) === -1; } @@ -191,12 +191,12 @@ KuzzleSecurity.prototype.updateRole = function (id, content, options, cb) { data.body = content; if (cb) { - self.kuzzle.query(this.buildQueryArgs(action), data, options, function (err, res) { + self.kuzzle.query(this.buildQueryArgs(action), data, options, function (err) { if (err) { return cb(err); } - cb(null, res.result._id); + cb(null, new KuzzleRole(self, id, content)); }); } else { self.kuzzle.query(this.buildQueryArgs(action), data); @@ -424,11 +424,23 @@ KuzzleSecurity.prototype.updateProfile = function (id, content, options, cb) { if (cb) { self.kuzzle.query(this.buildQueryArgs(action), data, options, function (err, res) { + var updatedContent = {}; + if (err) { return cb(err); } - cb(null, res.result._id); + Object.keys(res.result._source).forEach(function (property) { + if (property !== 'roles') { + updatedContent[property] = res.result._source[property]; + } + }); + + updatedContent.roles = res.result._source.roles.map(function (role) { + return role._id; + }); + + cb(null, new KuzzleProfile(self, res.result._id, updatedContent)); }); } else { self.kuzzle.query(this.buildQueryArgs(action), data); @@ -709,5 +721,91 @@ KuzzleSecurity.prototype.userFactory = function(id, content) { return new KuzzleUser(this, id, content); }; +/** + * Tells whether an action is allowed, denied or conditional based on the rights + * rights provided as the first argument. An action is defined as a couple of + * action and controller (mandatory), plus an index and a collection(optional). + * + * @param {object} rights - The rights rights associated to a user + * (see getMyrights and getUserrights). + * @param {string} controller - The controller to check the action onto. + * @param {string} action - The action to perform. + * @param {string} index - (optional) The name of index to perform the action onto. + * @param {string} collection - (optional) The name of the collection to perform the action onto. + * + * @returns {string} ['allowed', 'denied', 'conditional'] where conditional cases + * correspond to rights containing closures. + * See also http://kuzzle.io/guide/#roles-definition + */ +KuzzleSecurity.prototype.isActionAllowed = function(rights, controller, action, index, collection) { + var filteredRights; + + if (!rights || typeof rights !== 'object') { + throw new Error('rights parameter is mandatory for isActionAllowed function'); + } + if (!controller || typeof controller !== 'string') { + throw new Error('controller parameter is mandatory for isActionAllowed function'); + } + if (!action || typeof action !== 'string') { + throw new Error('action parameter is mandatory for isActionAllowed function'); + } + + // We filter in all the rights that match the request (including wildcards). + filteredRights = rights.filter(function (right) { + return right.controller === controller || right.controller === '*'; + }) + .filter(function (right) { + return right.action === action || right.action === '*'; + }) + .filter(function (right) { + return right.index === index || right.index === '*'; + }) + .filter(function (right) { + return right.collection === collection || right.collection === '*'; + }); + + // Then, if at least one right allows the action, we return 'allowed' + if (filteredRights.some(function (item) { return item.value === 'allowed'; })) { + return 'allowed'; + } + // If no right allows the action, we check for conditionals. + if (filteredRights.some(function (item) { return item.value === 'conditional'; })) { + return 'conditional'; + } + // Otherwise we return 'denied'. + return 'denied'; +}; + + +/** + * Gets the rights array of a given user. + * + * @param {string} userId The id of the user. + * @param {function} cb The callback containing the normalized array of rights. + */ +KuzzleSecurity.prototype.getUserRights = function (userId, options, cb) { + var + data = {_id: userId}, + self = this; + + if (!userId || typeof userId !== 'string') { + throw new Error('userId parameter is mandatory for isActionAllowed function'); + } + + if (!cb && typeof options === 'function') { + cb = options; + options = null; + } + + self.kuzzle.callbackRequired('Kuzzle.getUserRights', cb); + + this.kuzzle.query(this.buildQueryArgs('getUserRights'), data, options, function (err, res) { + if (err) { + return cb(err); + } + + cb(null, res.result.hits); + }); +}; -module.exports = KuzzleSecurity; \ No newline at end of file +module.exports = KuzzleSecurity; diff --git a/test/kuzzle/methods.test.js b/test/kuzzle/methods.test.js index 87473e59a..785c25d6e 100644 --- a/test/kuzzle/methods.test.js +++ b/test/kuzzle/methods.test.js @@ -2,6 +2,8 @@ var should = require('should'), rewire = require('rewire'), proxyquire = require('proxyquire'), + sinon = require('sinon'), + sandbox = sinon.sandbox.create(), Kuzzle = rewire('../../src/kuzzle'), KuzzleDataCollection = require('../../src/kuzzleDataCollection'), KuzzleSecurity = require('../../src/security/kuzzleSecurity'), @@ -40,6 +42,10 @@ describe('Kuzzle methods', function () { emitted, kuzzle; + afterEach(() => { + sandbox.restore(); + }); + describe('#getAllStatistics', function () { beforeEach(function () { kuzzle = new Kuzzle('foo'); @@ -172,6 +178,23 @@ describe('Kuzzle methods', function () { kuzzle = new Kuzzle('foo'); }); + it('should throw an error if arguments are not strings', () => { + kuzzle.defaultIndex = 'foobar'; + should(function () { kuzzle.dataCollectionFactory(undefined); }).throw(/string expected/); + should(function () { kuzzle.dataCollectionFactory(undefined, 'foo'); }).throw(/string expected/); + should(function () { kuzzle.dataCollectionFactory(null); }).throw(/string expected/); + should(function () { kuzzle.dataCollectionFactory(null, 'foo'); }).throw(/string expected/); + should(function () { kuzzle.dataCollectionFactory(123); }).throw(/string expected/); + should(function () { kuzzle.dataCollectionFactory(123, 'foo'); }).throw(/string expected/); + should(function () { kuzzle.dataCollectionFactory('foo', 123); }).throw(/string expected/); + should(function () { kuzzle.dataCollectionFactory({foo: 'bar'}); }).throw(/string expected/); + should(function () { kuzzle.dataCollectionFactory({foo: 'bar'}, 'foo'); }).throw(/string expected/); + should(function () { kuzzle.dataCollectionFactory('foo', {foo: 'bar'}); }).throw(/string expected/); + should(function () { kuzzle.dataCollectionFactory(['bar']); }).throw(/string expected/); + should(function () { kuzzle.dataCollectionFactory('foo', ['bar']); }).throw(/string expected/); + should(function () { kuzzle.dataCollectionFactory(['bar'], 'foo'); }).throw(/string expected/); + }); + it('should throw an error if the kuzzle instance has been invalidated', function () { kuzzle.disconnect(); should(function () { kuzzle.dataCollectionFactory('foo'); }).throw(Error); @@ -180,13 +203,13 @@ describe('Kuzzle methods', function () { it('should create and store the data collection instance if needed', function () { var collection = kuzzle.dataCollectionFactory('foo', 'bar'); - should(kuzzle.collections['foo']['bar']).not.be.undefined().and.be.instanceof(KuzzleDataCollection); + should(kuzzle.collections['bar']['foo']).not.be.undefined().and.be.instanceof(KuzzleDataCollection); should(collection).be.instanceof(KuzzleDataCollection); }); it('should simply pull the collection from the collection history if reinvoked', function () { kuzzle.collections['foo'] = { bar: 'qux'}; - should(kuzzle.dataCollectionFactory('foo', 'bar')).be.a.String().and.be.exactly('qux'); + should(kuzzle.dataCollectionFactory('bar', 'foo')).be.a.String().and.be.exactly('qux'); }); it('should use the default index if no index is provided', function () { @@ -198,20 +221,10 @@ describe('Kuzzle methods', function () { collection = kuzzle.dataCollectionFactory('foo'); should(collection).be.instanceof(KuzzleDataCollection); should(collection.index).be.eql(defaultIndex); - - collection = kuzzle.dataCollectionFactory('foo', {some: 'headers'}); - should(collection).be.instanceof(KuzzleDataCollection); - should(collection.index).be.eql(defaultIndex); }); - it('should throw an error if no index is provided and no default index has been set', function (done) { - try { - kuzzle.dataCollectionFactory('foo'); - done(new Error('Should have thrown an error')); - } - catch (e) { - done(); - } + it('should throw an error if no index is provided and no default index has been set', () => { + should(function () { kuzzle.dataCollectionFactory('foo'); }).throw(/no index specified/); }); }); @@ -786,4 +799,166 @@ describe('Kuzzle methods', function () { }); }); }); + + describe('#refreshIndex', function () { + beforeEach(() => { + kuzzle = new Kuzzle('foo'); + }); + + it('should throw an error if no index is set', () => { + should(() => { kuzzle.refreshIndex() }).throw('Kuzzle.refreshIndex: index required'); + }); + + it('should use the default index if no index is given', () => { + var + spy = sandbox.stub(kuzzle, 'query').returns(); + + kuzzle.defaultIndex = 'defaultIndex'; + kuzzle.refreshIndex(); + + should(spy.calledOnce).be.true(); + should(spy.firstCall.args[0].index).be.exactly(kuzzle.defaultIndex); + }); + + it('should parse the given parameters', () => { + var + spy = sandbox.stub(kuzzle, 'query').returns(), + index = 'index', + options = {foo: 'bar'}, + cb = () => {}, + args; + + kuzzle.refreshIndex(index, options, cb); + + should(spy.calledOnce).be.true(); + args = spy.firstCall.args; + + should(args[0].index).be.exactly(index); + should(args[0].controller).be.exactly('admin'); + should(args[0].action).be.exactly('refreshIndex'); + should(args[2]).be.exactly(options); + should(args[3]).be.exactly(cb); + }); + + }); + + describe('#getAutoRefresh', () => { + beforeEach(() => { + kuzzle = new Kuzzle('foo'); + }); + + it('should throw an error if no index is given', () => { + should(() => { kuzzle.getAutoRefresh(); }).throw('Kuzzle.getAutoRefresh: index required'); + }); + + it('should use kuzzle default index if no index is provided', () => { + var + spy = sandbox.stub(kuzzle, 'query').returns(); + + kuzzle.defaultIndex = 'defaultIndex'; + + kuzzle.getAutoRefresh(() => {}); + + should(spy.calledOnce).be.true(); + should(spy.firstCall.args[0].index).be.exactly(kuzzle.defaultIndex); + + }); + + it('should throw an error if no callback is given', () => { + should(() => { kuzzle.getAutoRefresh('index'); }).throw('Kuzzle.getAutoRefresh: a callback argument is required for read queries'); + }); + + it('should parse the given arguments', () => { + var + spy = sandbox.stub(kuzzle, 'query').returns(), + index = 'index', + options = { foo: 'bar'}, + cb = () => {}; + + kuzzle.getAutoRefresh(index, options, cb); + should(spy.calledOnce).be.true(); + should(spy.calledWithExactly( + { index: index, controller: 'admin', action: 'getAutoRefresh' }, + {}, + options, + cb ) + ).be.true(); + + kuzzle.defaultIndex = 'defaultIndex'; + kuzzle.getAutoRefresh(cb); + should(spy.calledTwice).be.true(); + should(spy.secondCall.calledWithExactly( + { index: kuzzle.defaultIndex, controller: 'admin', action: 'getAutoRefresh' }, + {}, + undefined, + cb) + ).be.true(); + + }); + + }); + + describe('#setAutoRefresh', () => { + beforeEach(() => { + kuzzle = new Kuzzle('foo'); + }); + + it('should throw an error if no index is given', () => { + should(() => { kuzzle.setAutoRefresh(); }).throw('Kuzzle.setAutoRefresh: index required'); + }); + + it('should use kuzzle default index if none is provided', () => { + var + spy = sandbox.stub(kuzzle, 'query').returns(), + cb = () => {}; + + kuzzle.defaultIndex = 'defaultIndex'; + kuzzle.setAutoRefresh(true, cb); + should(spy.calledOnce).be.true(); + should(spy.calledWith( + { index: kuzzle.defaultIndex, controller: 'admin', action: 'setAutoRefresh' }, + { body: { autoRefresh: true } }, + undefined, + cb + )).be.true(); + + }); + + it('should throw an error is now autorefresh value is given', () => { + should(() => { + kuzzle.setAutoRefresh('index'); + }).throw('Kuzzle.setAutoRefresh: autoRefresh value is required'); + }); + + it('should parse the given arguments', () => { + var + index = 'index', + autoRefresh = true, + options = { foo: 'bar'}, + cb = () => {}, + spy = sandbox.stub(kuzzle, 'query').returns(); + + kuzzle.defaultIndex = 'defaultIndex'; + + kuzzle.setAutoRefresh(autoRefresh, options, cb); + should(spy.calledOnce).be.true(); + should(spy.firstCall.calledWithExactly( + { index: kuzzle.defaultIndex, controller: 'admin', action: 'setAutoRefresh' }, + { body: { autoRefresh: autoRefresh }}, + options, + cb + )).be.true(); + + kuzzle.setAutoRefresh(index, autoRefresh); + should(spy.calledTwice).be.true(); + should(spy.secondCall.calledWithExactly( + { index: index, controller: 'admin', action: 'setAutoRefresh' }, + { body: { autoRefresh: autoRefresh }}, + undefined, + undefined + )).be.true(); + }); + + }); + }); diff --git a/test/kuzzle/offlineQueue.test.js b/test/kuzzle/offlineQueue.test.js index 57904897c..dbd0866b3 100644 --- a/test/kuzzle/offlineQueue.test.js +++ b/test/kuzzle/offlineQueue.test.js @@ -21,16 +21,17 @@ describe('Offline queue management', () => { describe('#cleanQueue', function () { var cleanQueue = Kuzzle.__get__('cleanQueue'), - now = Date.now(), + now, kuzzle; beforeEach(function () { - var - pastTime = 60000; - + var pastTime = 60000; + kuzzle = new Kuzzle('foo'); // queuing a bunch of requests from 1min ago to right now, 10s apart + now = Date.now(); + while (pastTime >= 0) { kuzzle.offlineQueue.push({ts: now - pastTime, query: {}, cb: function () {}}); pastTime -= 10000; @@ -47,12 +48,12 @@ describe('Offline queue management', () => { cleanQueue.call(kuzzle); // should keep only the latest requests, dating from a few ms ago - process.nextTick(() => { + setTimeout(() => { should(kuzzle.offlineQueue.length).be.exactly(1); should(kuzzle.offlineQueue[0].ts).be.above(now - kuzzle.queueTTL); should(eventFired).be.true(); done(); - }); + }, 50); }); it('should ignore requests timestamps if queueTTL is 0', function () { diff --git a/test/kuzzleDataCollection/methods.test.js b/test/kuzzleDataCollection/methods.test.js index 64e9d4610..4437682f6 100644 --- a/test/kuzzleDataCollection/methods.test.js +++ b/test/kuzzleDataCollection/methods.test.js @@ -1,6 +1,7 @@ var should = require('should'), rewire = require('rewire'), + sinon = require('sinon'), proxyquire = require('proxyquire'), Kuzzle = rewire('../../src/kuzzle'), KuzzleDataCollection = rewire('../../src/kuzzleDataCollection'), @@ -387,7 +388,7 @@ describe('KuzzleDataCollection methods', function () { should(err).be.null(); should(res).be.an.Array().and.match([result.result._id]); done(); - })).be.exactly(collection); + })); should(emitted).be.true(); }); @@ -539,6 +540,17 @@ describe('KuzzleDataCollection methods', function () { collection.fetchAllDocuments({}, function () {}); should(emitted).be.true(); }); + + it('should handle the from and size options', () => { + var + collection = kuzzle.dataCollectionFactory(expectedQuery.collection), + stub = sinon.stub(collection, 'advancedSearch'); + + collection.fetchAllDocuments({from: 123, size: 456}, function () {}); + should(stub.calledOnce).be.true(); + should(stub.calledWithMatch({from: 123, size: 456})).be.true(); + stub.restore(); + }); }); describe('#getMapping', function () { diff --git a/test/kuzzleDocument/methods.test.js b/test/kuzzleDocument/methods.test.js index b4dc5d08d..85f843b56 100644 --- a/test/kuzzleDocument/methods.test.js +++ b/test/kuzzleDocument/methods.test.js @@ -119,7 +119,7 @@ describe('KuzzleDocument methods', function () { expectedQuery.options = options; document.id = 'foo'; - should(document.delete(options)).be.exactly(document); + should(document.delete(options)); should(emitted).be.true(); }); @@ -150,7 +150,7 @@ describe('KuzzleDocument methods', function () { should(emitted).be.false(); }); - it('should resolve the callback with itself as a result', function (done) { + it('should resolve the callback with its own id as a result', function (done) { var document = new KuzzleDocument(dataCollection); this.timeout(50); @@ -159,7 +159,7 @@ describe('KuzzleDocument methods', function () { document.delete(function (err, res) { should(emitted).be.true(); should(err).be.null(); - should(res).be.exactly(document); + should(res).be.exactly(document.id); done(); }); }); diff --git a/test/security/kuzzleSecurity/profilesMethods.test.js b/test/security/kuzzleSecurity/profilesMethods.test.js index ff1f113af..19db441f5 100644 --- a/test/security/kuzzleSecurity/profilesMethods.test.js +++ b/test/security/kuzzleSecurity/profilesMethods.test.js @@ -303,7 +303,17 @@ describe('KuzzleSecurity profiles methods', function () { kuzzle = new Kuzzle('foo', {defaultIndex: 'bar'}); kuzzle.query = queryStub; error = null; - result = { result: {_id: 'foobar', _index: '%kuzzle', _type: 'profiles'} }; + result = { + result: { + _id: 'foobar', + _index: '%kuzzle', + _type: 'profiles', + _source: { + roles: [{_id: 'foo'}], + foo: 'bar' + } + } + }; expectedQuery = { action: 'updateProfile', controller: 'security' @@ -316,17 +326,16 @@ describe('KuzzleSecurity profiles methods', function () { should(kuzzle.security.updateProfile(result.result._id, {'foo': 'bar'}, function (err, res) { should(err).be.null(); - should(res).be.exactly(result.result._id); + should(res).be.instanceOf(KuzzleProfile); done(); })); }); - it('should send the right query to Kuzzle even without callback', function (done) { + it('should send the right query to Kuzzle even without callback', () => { expectedQuery.body = {'foo': 'bar'}; expectedQuery._id = result.result._id; kuzzle.security.updateProfile(result.result._id, {'foo': 'bar'}); - done(); }); it('should throw an error if no id provided', function () { diff --git a/test/security/kuzzleSecurity/rightsMethods.test.js b/test/security/kuzzleSecurity/rightsMethods.test.js new file mode 100644 index 000000000..264659ca7 --- /dev/null +++ b/test/security/kuzzleSecurity/rightsMethods.test.js @@ -0,0 +1,289 @@ +var + should = require('should'), + Kuzzle = require('../../../src/kuzzle'); + +describe('KuzzleSecurity user rights methods', function () { + var + kuzzle, + expectedQuery, + result, + error, + queryStub = function (args, query, options, cb) { + should(args.controller).be.exactly(expectedQuery.controller); + should(args.action).be.exactly(expectedQuery.action); + + if (expectedQuery.options) { + should(options).match(expectedQuery.options); + } + + if (expectedQuery.body) { + if (!query.body) { + query.body = {}; + } + + should(query.body).match(expectedQuery.body); + } else { + should(query.body).be.undefined(); + } + + if (expectedQuery._id) { + should(query._id).be.exactly(expectedQuery._id); + } + + if (cb) { + if (error) { + return cb(error); + } + + cb(error, result); + } + }; + + var exampleRights = [ + { + controller: 'read', action: 'get', index: '*', collection: '*', + value: 'allowed' + }, + { + controller: 'read', action: 'count', index: '*', collection: '*', + value: 'allowed' + }, + { + controller: 'read', action: 'search', index: '*', collection: '*', + value: 'allowed' + }, + { + controller: 'read', action: '*', index: 'index1', collection: 'collection1', + value: 'allowed' + }, + { + controller: 'read', action: '*', index: 'index1', collection: 'collection2', + value: 'allowed' + }, + { + controller: 'write', action: 'update', index: '*', collection: '*', + value: 'allowed' + }, + { + controller: 'write', action: 'create', index: '*', collection: '*', + value: 'allowed' + }, + { + controller: 'write', action: 'createOrReplace', index: '*', collection: '*', + value: 'allowed' + }, + { + controller: 'write', action: 'delete', index: '*', collection: '*', + value: 'conditional' + }, + { + controller: 'write', action: 'publish', index: 'index2', collection: '*', + value: 'allowed' + }, + { + controller: 'security', action: 'searchUsers', index: '*', collection: '*', + value: 'allowed' + }, + { + controller: 'security', action: 'updateUser', index: '*', collection: '*', + value: 'conditional' + } + ]; + + describe('#getUserRights', function () { + beforeEach(function () { + kuzzle = new Kuzzle('foo', {defaultIndex: 'bar'}); + kuzzle.query = queryStub; + error = null; + result = { result: { hits: exampleRights } }; + expectedQuery = { + action: 'getUserRights', + controller: 'security', + _id: 'foobar' + }; + }); + + it('should send the right query to Kuzzle', function (done) { + should(kuzzle.security.getUserRights(expectedQuery._id, function (err, res) { + should(err).be.null(); + should(res).be.exactly(exampleRights); + done(); + })); + }); + + it('should throw if called with no arguments', function () { + should(function () { kuzzle.security.getUserRights() }).throw(Error); + }); + + it('should throw if called with no callback', function () { + should(function () { kuzzle.security.getUserRights(expectedQuery._id) }).throw(Error); + }); + + it('should call the callback with an error if one occurs', function (done) { + error = 'foobar'; + this.timeout(50); + + kuzzle.security.getUserRights(expectedQuery._id, function (err, res) { + should(err).be.exactly('foobar'); + should(res).be.undefined(); + done(); + }); + }); + + it('should call callback with an array', function (done) { + should(kuzzle.security.getUserRights(expectedQuery._id, function (err, res) { + should(err).be.exactly(null); + should(res).be.an.instanceOf(Array); + done(); + })); + }); + + it('should call callback with an array containing rights (if not empty)', function (done) { + should(kuzzle.security.getUserRights(expectedQuery._id, function (err, res) { + should(err).be.exactly(null); + should(res).be.an.instanceOf(Array); + + if (res.length > 0) { + should(res[0]).have.ownProperty('controller'); + should(res[0]).have.ownProperty('action'); + should(res[0]).have.ownProperty('index'); + should(res[0]).have.ownProperty('collection'); + should(res[0]).have.ownProperty('value'); + should(res[0].value).be.oneOf('allowed', 'denied', 'conditional'); + } + + done(); + })); + }); + }); + + describe('#getMyRights', function () { + beforeEach(function () { + kuzzle = new Kuzzle('foo', {defaultIndex: 'bar'}); + kuzzle.query = queryStub; + error = null; + result = { result: { hits: exampleRights } }; + expectedQuery = { + action: 'getMyRights', + controller: 'auth' + }; + }); + + it('should send the right query to Kuzzle', function (done) { + should(kuzzle.getMyRights(function (err, res) { + should(err).be.null(); + should(res).be.exactly(exampleRights); + done(); + })); + }); + + it('should throw if called with no callback', function () { + should(function () { kuzzle.getMyRights() }).throw(Error); + }); + + it('should call the callback with an error if one occurs', function (done) { + error = 'foobar'; + this.timeout(50); + + kuzzle.getMyRights( function (err, res) { + should(err).be.exactly('foobar'); + should(res).be.undefined(); + done(); + }); + }); + + it('should call callback with an array', function (done) { + should(kuzzle.getMyRights(function (err, res) { + should(err).be.exactly(null); + should(res).be.an.instanceOf(Array); + done(); + })); + }); + + it('should call callback with an array containing rights (if not empty)', function (done) { + should(kuzzle.getMyRights(function (err, res) { + should(err).be.exactly(null); + should(res).be.an.instanceOf(Array); + + if (res.length > 0) { + should(res[0]).have.ownProperty('controller'); + should(res[0]).have.ownProperty('action'); + should(res[0]).have.ownProperty('index'); + should(res[0]).have.ownProperty('collection'); + should(res[0]).have.ownProperty('value'); + should(res[0].value).be.oneOf('allowed', 'denied', 'conditional'); + } + + done(); + })); + }); + }); + + describe('#isActionAllowed', function () { + beforeEach(function () { + kuzzle = new Kuzzle('foo', {defaultIndex: 'bar'}); + }); + + it('should return "allowed" to ("read", "get")', function() { + should(kuzzle.security.isActionAllowed(exampleRights, 'read', 'get')) + .be.exactly('allowed'); + }); + + it('should return "allowed" to ("read", "count", "myIndex")', function() { + should(kuzzle.security.isActionAllowed(exampleRights, 'read', 'count', 'myIndex')) + .be.exactly('allowed'); + }); + + it('should return "allowed" to ("read", "search", "myIndex", "myCollection")', function() { + should(kuzzle.security.isActionAllowed(exampleRights, 'read', 'search', 'myIndex', 'myCollection')) + .be.exactly('allowed'); + }); + + it('should return "allowed" to ("read", "search", "index1", "collection1")', function() { + should(kuzzle.security.isActionAllowed(exampleRights, 'read', 'search', 'index1', 'collection1')) + .be.exactly('allowed'); + }); + + it('should return "denied" to ("read", "listIndexes", "index2")', function() { + should(kuzzle.security.isActionAllowed(exampleRights, 'read', 'listIndexes', 'index2')) + .be.exactly('denied'); + }); + + it('should return "allowed" to ("read", "search", "index1", "collection2")', function() { + should(kuzzle.security.isActionAllowed(exampleRights, 'read', 'search', 'index1', 'collection2')) + .be.exactly('allowed'); + }); + + it('should return "denied" to ("write", "replace")', function() { + should(kuzzle.security.isActionAllowed(exampleRights, 'write', 'replace')) + .be.exactly('denied'); + }); + + it('should return "conditional" to ("security", "updateUser")', function() { + should(kuzzle.security.isActionAllowed(exampleRights, 'security', 'updateUser')) + .be.exactly('conditional'); + }); + + it('should return "conditional" to ("write", "delete")', function() { + should(kuzzle.security.isActionAllowed(exampleRights, 'write', 'delete')) + .be.exactly('conditional'); + }); + + it('should return "conditional" to ("write", "delete", "index1", "collection1")', function() { + should(kuzzle.security.isActionAllowed(exampleRights, 'write', 'delete', 'index1', 'collection1')) + .be.exactly('conditional'); + }); + + it('should throw if called with no arguments', function () { + should(function () { kuzzle.security.isActionAllowed() }).throw(Error); + }); + + it('should throw if called with no action, nor controller', function () { + should(function () { kuzzle.security.isActionAllowed(exampleRights) }).throw(Error); + }); + + it('should throw if called with no action', function () { + should(function () { kuzzle.security.isActionAllowed(exampleRights, 'write') }).throw(Error); + }); + }); +}); diff --git a/test/security/kuzzleSecurity/rolesMethods.test.js b/test/security/kuzzleSecurity/rolesMethods.test.js index 69f54cd79..8624b0f11 100644 --- a/test/security/kuzzleSecurity/rolesMethods.test.js +++ b/test/security/kuzzleSecurity/rolesMethods.test.js @@ -231,17 +231,16 @@ describe('KuzzleSecurity roles methods', function () { should(kuzzle.security.updateRole(result.result._id, {'foo': 'bar'}, function (err, res) { should(err).be.null(); - should(res).be.exactly(result.result._id); + should(res).be.instanceOf(KuzzleRole); done(); })); }); - it('should send the right query to Kuzzle even without callback', function (done) { + it('should send the right query to Kuzzle even without callback', function () { expectedQuery.body = {'foo': 'bar'}; expectedQuery._id = result.result._id; kuzzle.security.updateRole(result.result._id, {'foo': 'bar'}); - done(); }); it('should throw an error if no id provided', function () { diff --git a/test/security/kuzzleSecurity/userMethods.test.js b/test/security/kuzzleSecurity/userMethods.test.js index bb21ea318..764a14f15 100644 --- a/test/security/kuzzleSecurity/userMethods.test.js +++ b/test/security/kuzzleSecurity/userMethods.test.js @@ -374,7 +374,7 @@ describe('KuzzleSecurity user methods', function () { }); }); - describe('#deleteRole', function () { + describe('#deleteUser', function () { beforeEach(function () { kuzzle = new Kuzzle('foo', {defaultIndex: 'bar'}); kuzzle.query = queryStub; @@ -424,4 +424,4 @@ describe('KuzzleSecurity user methods', function () { done(); }); }); -}); \ No newline at end of file +});