diff --git a/CHANGELOG.md b/CHANGELOG.md index fa911274..c3d0b122 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ -## Unreleased +## [2.6.0] - 2019-01-18 - Added possibility to rotate ApiKey. - Now saving ApiKey to rules-configs instead of adding it into the rule. +- API: add groups/roles to user by id or name ## [2.5.2] - 2018-11-28 diff --git a/build/bundle.js b/build/bundle.js index 26d8c288..62298dff 100644 --- a/build/bundle.js +++ b/build/bundle.js @@ -1 +1 @@ -module.exports=function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=148)}([function(e,t){e.exports=require("joi@9.0.4")},function(e,t){e.exports=require("lodash@3.10.1")},function(e,t,r){"use strict";var n=r(15);e.exports=(0,n.config)()},function(e,t){var r=e.exports={version:"2.5.7"};"number"==typeof __e&&(__e=r)},function(e,t){var r=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},function(e,t,r){var n=r(67)("wks"),o=r(69),i=r(4).Symbol,u="function"==typeof i;(e.exports=function(e){return n[e]||(n[e]=u&&i[e]||(u?i:o)("Symbol."+e))}).store=n},function(e,t,r){var n=r(4),o=r(3),i=r(16),u=r(13),a=r(24),s=function(e,t,r){var c,f,d,l=e&s.F,p=e&s.G,h=e&s.S,g=e&s.P,m=e&s.B,v=e&s.W,_=p?o:o[t]||(o[t]={}),y=_.prototype,x=p?n:h?n[t]:(n[t]||{}).prototype;p&&(r=t);for(c in r)(f=!l&&x&&void 0!==x[c])&&a(_,c)||(d=f?x[c]:r[c],_[c]=p&&"function"!=typeof x[c]?r[c]:m&&f?i(d,n):v&&x[c]==d?function(e){var t=function(t,r,n){if(this instanceof e){switch(arguments.length){case 0:return new e;case 1:return new e(t);case 2:return new e(t,r)}return new e(t,r,n)}return e.apply(this,arguments)};return t.prototype=e.prototype,t}(d):g&&"function"==typeof d?i(Function.call,d):d,g&&((_.virtual||(_.virtual={}))[c]=d,e&s.R&&y&&!y[c]&&u(y,c,d)))};s.F=1,s.G=2,s.S=4,s.P=8,s.B=16,s.W=32,s.U=64,s.R=128,e.exports=s},function(e,t){e.exports=require("bluebird@3.4.6")},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e,t,r,n){return new E.default(function(o,i){if(!t)return o([]);if(!r||0===r.length)return o([]);return function(t){return n&&n.length?t(null,n):O(e,t)}(function(e,n){if(e)return i(e);var u=_.default.filter(n,function(e){return U(e.mappings,t,r)});return o(u)})})}function i(e,t,r,n){return Array.isArray(n)&&void 0!==n&&null!==n||(n=[]),new E.default(function(i,u){O(e,function(a,s){if(a)return u(a);var c=_.default.filter(s,function(e){return _.default.includes(e.members,t)});return o(e,r,[].concat((0,h.default)(n),(0,h.default)(c.map(function(e){return e.name}))),s).then(function(e){var t=S(s,_.default.union(c,e));return i(t)}).catch(u)})})}function u(e,t){return new E.default(function(r,n){O(e,function(o,i){return o?n(o):q(e,function(o,u){if(o)return n(o);var a=_.default.find(i,{_id:t}),s=S(i,[a]).filter(function(e){return e._id!==a._id}),c=I([a].concat((0,h.default)(s)),u).map(function(e){return e.role}),f=function(e){return{_id:e._id,name:e.name,description:e.description,applicationId:e.applicationId,applicationType:e.applicationType,permissions:e.permissions&&e.permissions.map(k)}};return G(e,c).then(function(e){return r({_id:a._id,name:a.name,description:a.description,roles:e.map(f)})})})})})}function a(e,t){return new E.default(function(r,n){O(e,function(o,i){return o?n(o):q(e,function(o,u){if(o)return n(o);var a=S(i,t),s=I(a,u).map(function(e){return e.role}),c=function(e){return{_id:e._id,name:e.name,description:e.description,applicationId:e.applicationId,applicationType:e.applicationType,permissions:e.permissions&&e.permissions.map(k)}};return G(e,s).then(function(e){return r({groups:a.map(k),roles:e.map(c)})})})})})}function s(e,t,r,n,i){var u={groups:[],roles:[]};return e.provider.storageContext.read().then(function(a){var s=a.groups,c=void 0===s?[]:s,f=a.roles,d=void 0===f?[]:f,l=a.permissions,p=void 0===l?[]:l,g=_.default.filter(c,function(e){return _.default.includes(e.members,t)});return Array.isArray(i)||(i=[]),M(o)(e,n,[].concat((0,h.default)(i),(0,h.default)(g.map(function(e){return e.name}))),c).then(M(function(e){var t=S(c,_.default.union(g,e));return u.groups=_.default.uniq(t.map(function(e){return e.name})),t})).then(M(function(e){var n=I(e,d).map(function(e){return e.role}),o=d.filter(function(e){return e.users&&e.users.indexOf(t)>-1}),i=[].concat((0,h.default)(n),(0,h.default)(o)),a=i.filter(function(e){return e.applicationId===r});return u.roles=_.default.uniq(a.map(function(e){return e.name})),a})).then(M(function(e){var t=_.default.flattenDeep(_.default.map(e,function(e){return e.permissions})),r=p.filter(function(e){return _.default.includes(t,e._id)});return u.permissions=_.default.uniq(r.map(function(e){return e.name})),u}))})}Object.defineProperty(t,"__esModule",{value:!0}),t.getMembers=t.getPermissionsByRoles=t.getPermissionsForRoles=t.getRolesForUser=t.getRolesForGroups=t.getParentGroups=t.getChildGroups=t.getMappingsWithNames=t.getGroupsCached=t.getRolesCached=t.getPermissionsCached=t.getConnectionsCached=void 0;var c=r(151),f=n(c),d=r(20),l=n(d),p=r(56),h=n(p),g=r(41),m=n(g);t.getDynamicUserGroups=o,t.getUserGroups=i,t.getGroupExpanded=u,t.getGroupsExpanded=a,t.getUserData=s;var v=r(1),_=n(v),y=r(211),x=n(y),w=r(7),E=n(w),b=r(210),T=n(b),A=r(26),P=n(A),M=function(e){return function(){for(var t=arguments.length,r=Array(t),n=0;n-1})},t.getParentGroups=function(e,t){var r=[],n=function t(n){if(-1===r.indexOf(n)){r.push(n);_.default.filter(e,function(e){return _.default.includes(e.nested||[],n)}).forEach(function(e){return t(e._id)})}};return t.forEach(function(e){return n(e._id)}),_.default.filter(e,function(e){return r.indexOf(e._id)>-1})}),I=t.getRolesForGroups=function(e,t){var r=[],n={};return e.forEach(function(e){e.roles&&e.roles.forEach(function(t){n[t]||(n[t]=e)})}),t.forEach(function(e){n[e._id]&&r.push({role:e,group:n[e._id]})}),r},G=(t.getRolesForUser=function(e,t){return e.getGroups().then(function(e){var r=_.default.filter(e,function(e){return _.default.includes(e.members,t)});return S(e,r).filter(function(e){return e.roles&&e.roles.length}).map(function(e){return e.roles})}).then(function(e){return _.default.uniq(_.default.flattenDeep(e))}).then(function(r){return e.getRoles().then(function(e){var n=_.default.filter(e,function(e){return _.default.includes(r,e._id)}),o=_.default.filter(e,function(e){return e.users&&_.default.includes(e.users,t)});return _.default.uniq([].concat((0,h.default)(n),(0,h.default)(o)),"_id")})})},t.getPermissionsForRoles=function(e,t){return e.getPermissions().then(function(e){var r=_.default.flattenDeep(_.default.map(t,function(e){return e.permissions}));return e.filter(function(e){return _.default.includes(r,e._id)})})},t.getPermissionsByRoles=function(e,t){return new E.default(function(r,n){C(e,function(e,o){if(e)return n(e);var i=[];return _.default.forEach(t,function(e){var t=o.filter(function(t){return _.default.includes(e.permissions,t._id)});i.push((0,l.default)({},e,{permissions:_.default.map(t,function(e){return{_id:e._id,name:e.name,description:e.description}})}))}),r(i)})})}),R=(t.getMembers=function(e){var t={};return e.forEach(function(e){e.members&&e.members.forEach(function(r){t[r]||(t[r]=e)})}),(0,f.default)(t).map(function(e){return{userId:e,group:t[e]}})},function(e,t,r){return e.connectionName===t&&r.indexOf(e.groupName)>-1}),U=function(e,t,r){return e&&_.default.filter(e,function(e){return R(e,t,r)}).length>0}},function(e,t,r){var n=r(17);e.exports=function(e){if(!n(e))throw TypeError(e+" is not an object!");return e}},function(e,t,r){"use strict";var n=r(215);n.emitErrs=!0;var o=new n.Logger({transports:[new n.transports.Console({timestamp:!0,level:"debug",handleExceptions:!0,json:!1,colorize:!0})],exitOnError:!1});e.exports=o},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.scopes=t.deleteApi=t.updateApi=t.createApi=t.getApi=void 0;var o=r(7),i=n(o),u=r(214),a=n(u),s=r(15),c=r(2),f=n(c),d=[{value:"read:users"},{value:"read:applications"},{value:"read:connections"},{value:"read:configuration"},{value:"update:configuration"},{value:"read:groups"},{value:"create:groups"},{value:"update:groups"},{value:"delete:groups"},{value:"read:roles"},{value:"create:roles"},{value:"update:roles"},{value:"delete:roles"},{value:"read:permissions"},{value:"create:permissions"},{value:"update:permissions"},{value:"delete:permissions"},{value:"read:resource-server"},{value:"create:resource-server"},{value:"update:resource-server"},{value:"delete:resource-server"}],l=function(e){return e.auth&&e.auth.credentials&&e.auth.credentials.access_token&&e.auth.credentials.access_token.length?i.default.resolve(e.auth.credentials.access_token):s.managementApi.getAccessTokenCached((0,f.default)("AUTH0_DOMAIN"),(0,f.default)("AUTH0_CLIENT_ID"),(0,f.default)("AUTH0_CLIENT_SECRET"))},p=function(e,t,r,n){return new i.default(function(o,i){return l(e).then(function(e){(0,a.default)(r,"https://"+(0,f.default)("AUTH0_DOMAIN")+"/api/v2/"+t).send(n||{}).set("Content-Type","application/json").set("Authorization","Bearer "+e).end(function(e,t){return e?i(e):o(t.body)})})})},h=t.getApi=function(e){return p(e,"resource-servers","GET").then(function(e){return e.filter(function(e){return"urn:auth0-authz-api"===e.identifier})[0]||{}})},g=t.createApi=function(e,t){return p(e,"resource-servers","POST",{name:"auth0-authorization-extension-api",identifier:"urn:auth0-authz-api",signing_alg:"RS256",scopes:d,token_lifetime:t})};t.updateApi=function(e,t){return h(e).then(function(r){return r.id?p(e,"resource-servers/"+r.id,"PATCH",{token_lifetime:t||86400}):g(e,t||86400)})},t.deleteApi=function(e,t){return h(e).then(function(r){return r.id?p(e,"resource-servers/"+r.id,"DELETE"):r.id||t?i.default.resolve():i.default.reject(new Error("Unable to disable resource-server. Is it enabled?"))})},t.scopes=d},function(e,t,r){e.exports=!r(23)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(e,t,r){var n=r(14),o=r(32);e.exports=r(12)?function(e,t,r){return n.f(e,t,o(1,r))}:function(e,t,r){return e[t]=r,e}},function(e,t,r){var n=r(9),o=r(166),i=r(184),u=Object.defineProperty;t.f=r(12)?Object.defineProperty:function(e,t,r){if(n(e),t=i(t,!0),n(r),o)try{return u(e,t,r)}catch(e){}if("get"in r||"set"in r)throw TypeError("Accessors not supported!");return"value"in r&&(e[t]=r.value),e}},function(e,t){e.exports=require("auth0-extension-tools@1.3.2")},function(e,t,r){var n=r(21);e.exports=function(e,t,r){if(n(e),void 0===t)return e;switch(r){case 1:return function(r){return e.call(t,r)};case 2:return function(r,n){return e.call(t,r,n)};case 3:return function(r,n,o){return e.call(t,r,n,o)}}return function(){return e.apply(t,arguments)}}},function(e,t){e.exports=function(e){return"object"==typeof e?null!==e:"function"==typeof e}},function(e,t){e.exports={}},function(e,t){e.exports=require("auth0-extension-hapi-tools@1.2.1")},function(e,t,r){"use strict";t.__esModule=!0;var n=r(54),o=function(e){return e&&e.__esModule?e:{default:e}}(n);t.default=o.default||function(e){for(var t=1;t3&&void 0!==arguments[3]?arguments[3]:2,u=n;return function n(){return t.apply(e,r).then(function(e){return o.default.resolve(e)}).catch(function(e){var t=e.originalError||{},r=t.response&&t.response.header&&t.response.header["x-ratelimit-reset"]||0,a=Math.round((new Date).getTime()/1e3),s=parseInt(r,10)-a;return 429===t.status&&u>0&&r&&s<=10?(u--,s<=0&&(s=1),i(s).then(n)):o.default.reject(e)})}()}},function(e,t){e.exports=function(e){if(void 0==e)throw TypeError("Can't call method on "+e);return e}},function(e,t,r){var n=r(17),o=r(4).document,i=n(o)&&n(o.createElement);e.exports=function(e){return i?o.createElement(e):{}}},function(e,t){e.exports=!0},function(e,t,r){"use strict";function n(e){var t,r;this.promise=new e(function(e,n){if(void 0!==t||void 0!==r)throw TypeError("Bad Promise constructor");t=e,r=n}),this.resolve=o(t),this.reject=o(r)}var o=r(21);e.exports.f=function(e){return new n(e)}},function(e,t,r){var n=r(176),o=r(58);e.exports=Object.keys||function(e){return n(e,o)}},function(e,t){e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},function(e,t,r){var n=r(14).f,o=r(24),i=r(5)("toStringTag");e.exports=function(e,t,r){e&&!o(e=r?e:e.prototype,i)&&n(e,i,{configurable:!0,value:t})}},function(e,t,r){var n=r(67)("keys"),o=r(69);e.exports=function(e){return n[e]||(n[e]=o(e))}},function(e,t,r){var n,o,i,u=r(16),a=r(167),s=r(59),c=r(28),f=r(4),d=f.process,l=f.setImmediate,p=f.clearImmediate,h=f.MessageChannel,g=f.Dispatch,m=0,v={},_=function(){var e=+this;if(v.hasOwnProperty(e)){var t=v[e];delete v[e],t()}},y=function(e){_.call(e.data)};l&&p||(l=function(e){for(var t=[],r=1;arguments.length>r;)t.push(arguments[r++]);return v[++m]=function(){a("function"==typeof e?e:Function(e),t)},n(m),m},p=function(e){delete v[e]},"process"==r(22)(d)?n=function(e){d.nextTick(u(_,e,1))}:g&&g.now?n=function(e){g.now(u(_,e,1))}:h?(o=new h,i=o.port2,o.port1.onmessage=y,n=u(i.postMessage,i,1)):f.addEventListener&&"function"==typeof postMessage&&!f.importScripts?(n=function(e){f.postMessage(e+"","*")},f.addEventListener("message",y,!1)):n="onreadystatechange"in c("script")?function(e){s.appendChild(c("script")).onreadystatechange=function(){s.removeChild(this),_.call(e)}}:function(e){setTimeout(u(_,e,1),0)}),e.exports={set:l,clear:p}},function(e,t){var r=Math.ceil,n=Math.floor;e.exports=function(e){return isNaN(e=+e)?0:(e>0?n:r)(e)}},function(e,t,r){var n=r(60),o=r(27);e.exports=function(e){return n(o(e))}},function(e,t,r){var n=r(36),o=Math.min;e.exports=function(e){return e>0?o(n(e),9007199254740991):0}},function(e,t){e.exports=require("boom@3.2.2")},function(e,t){e.exports=require("path")},function(e,t,r){e.exports={default:r(160),__esModule:!0}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=function(e){return e&&e.__esModule?e:{default:e}}(n);t.default=o.default.object().keys({groupsInToken:o.default.boolean(),rolesInToken:o.default.boolean(),permissionsInToken:o.default.boolean(),persistGroups:o.default.boolean(),persistRoles:o.default.boolean(),persistPermissions:o.default.boolean(),groupsPassthrough:o.default.boolean(),rolesPassthrough:o.default.boolean(),permissionsPassthrough:o.default.boolean()})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=function(e){return e&&e.__esModule?e:{default:e}}(n);t.default=o.default.array().items(o.default.string()).required().min(1)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=function(e){return e&&e.__esModule?e:{default:e}}(n);t.default=o.default.array().items(o.default.string().guid()).required().min(1)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=function(e){return e&&e.__esModule?e:{default:e}}(n);t.default=o.default.object().keys({name:o.default.string().min(1).max(50).required(),description:o.default.string().min(1).max(500).required()})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=function(e){return e&&e.__esModule?e:{default:e}}(n);t.default=o.default.object().keys({name:o.default.string().min(1).max(100).required(),description:o.default.string().min(1).max(500).required(),applicationType:o.default.string().valid("client","resource_server").required(),applicationId:o.default.string().min(1).max(500).required()})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=function(e){return e&&e.__esModule?e:{default:e}}(n);t.default=o.default.object().keys({name:o.default.string().min(1).max(50).required(),description:o.default.string().min(1).max(500).required(),applicationType:o.default.string().valid("client","resource_server").required(),applicationId:o.default.string().min(1).max(500).required(),permissions:o.default.array().items(o.default.string().guid()).default([])})},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=r(73),i=n(o),u=r(2),a=n(u),s=r(49),c=n(s),f=r(136),d=n(f);t.default=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";return e.getApiKey().then(function(r){return r?null:(0,c.default)(e,t)}).then(function(){return i.default.render(d.default,{extensionUrl:(0,a.default)("PUBLIC_WT_URL").replace(/\/$/g,""),updateTime:function(){return(new Date).toISOString()},config:r,userName:n})})}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=r(72),i=n(o),u=r(2),a=n(u),s=function(e){return i.default.createHmac("sha256",e+" + "+(0,a.default)("AUTH0_CLIENT_SECRET")).update((0,a.default)("EXTENSION_SECRET")).digest("hex")};t.default=function(e,t){var r=i.default.randomBytes(32).toString("hex"),n=s(r);return t.rulesConfigs.set({key:"AUTHZ_EXT_API_KEY"},{value:n}).then(function(){return e.updateApiKey(r)}).then(function(){return n})}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(54),i=n(o),u=r(7),a=n(u),s=r(15),c=r(26),f=n(c);e.exports=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:100,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:5;if(null===e||void 0===e)throw new s.ArgumentError("Must provide a auth0 client object.");if(!t&&!e[t])throw new s.ArgumentError("Must provide a valid entity for auth0 client.");var u=e[t].getAll,c=(0,i.default)({},r,{per_page:n}),d=[],l=0,p=0,h=function(){return(0,f.default)(e,u,[(0,i.default)({},c,{include_totals:!0,page:0})]).then(function(e){return l=e.total||0,p=Math.ceil(l/n),(e[t]||e||[]).forEach(function(e){return d.push(e)}),null})},g=function(t){return(0,f.default)(e,u,[(0,i.default)({},c,{page:t})]).then(function(e){return e.forEach(function(e){return d.push(e)}),null})};return function(){return h().then(function(){if(0===l||d.length>=l)return d;for(var e=[],t=1;t<=p;t++)e.push(t);return a.default.map(e,g,{concurrency:o})})}().then(function(){return d})}},function(e,t,r){"use strict";var n=null;e.exports.init=function(e){n=e},e.exports.getDb=function(){if(!n)throw new Error("The database has not been initialized.");return n}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e,t,r,n){return new f.default(function(o,i){var a=[],c=t.length;r=r-1<0?0:r-1,t=t.splice(r*n,n),s.default.eachLimit(t,10,function(t,r){(0,l.default)(e,e.users.get,[{id:t}]).then(function(e){a.push(e),r()}).catch(function(e){return e&&404===e.statusCode?(a.push({user_id:t,name:"",email:t,identities:[{connection:"N/A"}]}),r()):r(e)})},function(e){if(e)return i(e);var t=u.default.sortByOrder(a,"user_id");return o({total:c,users:t})})})}Object.defineProperty(t,"__esModule",{value:!0}),t.getUsersById=o;var i=r(1),u=n(i),a=r(198),s=n(a),c=r(7),f=n(c),d=r(26),l=n(d)},function(e,t,r){e.exports={default:r(155),__esModule:!0}},function(e,t,r){e.exports={default:r(156),__esModule:!0}},function(e,t,r){e.exports={default:r(159),__esModule:!0}},function(e,t,r){"use strict";t.__esModule=!0;var n=r(149),o=function(e){return e&&e.__esModule?e:{default:e}}(n);t.default=function(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t=t.length?{value:void 0,done:!0}:(e=n(t,r),this._i+=e.length,{value:e,done:!1})})},function(e,t){e.exports=require("crypto")},function(e,t){e.exports=require("ejs@2.3.1")},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(2),i=n(o),u=r(137),a=n(u),s=r(51),c=r(138),f=r(135),d=n(f),l=r(10),p=n(l);e.exports=function(e,t,n){return null==n&&(n=function(e){e?(p.default.error("Hapi initialization failed."),p.default.error(e)):p.default.info("Hapi initialization completed.")}),i.default.setProvider(function(t){return e(t)||r.i({WARN_DB_SIZE:409600,MAX_MULTISELECT_USERS:5,MULTISELECT_DEBOUNCE_MS:250,PER_PAGE:10,NODE_ENV:"production",CLIENT_VERSION:"2.5.2"})[t]}),(0,s.init)(new a.default({provider:(0,c.createProvider)(t)})),(0,d.default)(n)}},function(e,t,r){"use strict";var n=r(0),o=function(e){return e&&e.__esModule?e:{default:e}}(n);e.exports=function(e){return{method:"GET",path:"/api/applications/{clientId}",config:{auth:{strategies:["jwt"],scope:["read:applications"]},description:"Get a single application based on its Client ID.",validate:{params:{clientId:o.default.string().required()}},pre:[e.handlers.managementClient]},handler:function(e,t){return e.pre.auth0.clients.get({client_id:e.params.clientId}).then(function(e){return t(e)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(1),i=n(o),u=r(50),a=n(u);e.exports=function(e){return{method:"GET",path:"/api/applications",config:{auth:{strategies:["jwt"],scope:["read:applications"]},pre:[e.handlers.managementClient]},handler:function(e,t){return(0,a.default)(e.pre.auth0,"clients",{is_global:!1,fields:"client_id,name,callbacks,app_type"}).then(function(e){return i.default.chain(e).filter(function(e){return"spa"===e.app_type||"native"===e.app_type||"regular_web"===e.app_type}).sortBy(function(e){return e.name.toLowerCase()}).value()}).then(function(e){return t(e)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";var n=r(11);e.exports=function(){return{method:"DELETE",path:"/api/configuration/resource-server",config:{auth:{strategies:["jwt"],scope:["delete:resource-server"]}},handler:function(e,t){return(0,n.deleteApi)(e).then(function(){return t().code(204)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";var n=r(11);e.exports=function(){return{method:"GET",path:"/api/configuration/resource-server",config:{auth:{strategies:["jwt"],scope:["read:resource-server"]}},handler:function(e,t){return(0,n.getApi)(e).then(function(e){return t({apiAccess:!!e.identifier,token_lifetime:e.token_lifetime})}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";e.exports=function(){return{method:"GET",path:"/api/configuration",config:{auth:{strategies:["jwt"],scope:["read:configuration"]}},handler:function(e,t){return e.storage.getConfiguration().then(function(e){return t(e)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";var n=r(1),o=function(e){return e&&e.__esModule?e:{default:e}}(n);e.exports=function(e){return{method:"GET",path:"/api/configuration/status",config:{auth:{strategies:["jwt"],scope:["read:configuration"]},pre:[e.handlers.managementClient]},handler:function(e,t){return e.pre.auth0.rules.getAll().then(function(e){var t=o.default.find(e,{name:"auth0-authorization-extension"});return{exists:!!t,enabled:!!t&&t.enabled}}).then(function(r){e.storage.getStatus().then(function(e){return t({rule:r,database:e})}).catch(function(){return t({rule:r,database:{size:0,type:"unknown"}})})}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";e.exports=function(){return{method:"GET",path:"/api/configuration/export",config:{auth:{strategies:["jwt"],scope:["read:configuration"]}},handler:function(e,t){return e.storage.provider&&e.storage.provider.storageContext&&"function"==typeof e.storage.provider.storageContext.read?e.storage.provider.storageContext.read().then(function(e){return t(e)}).catch(function(e){return t.error(e)}):t.error(new Error('Unable to use "export" without proper storage'))}}}},function(e,t,r){"use strict";var n=r(0),o=function(e){return e&&e.__esModule?e:{default:e}}(n),i=r(11);e.exports=function(){return{method:"PATCH",path:"/api/configuration/resource-server",config:{auth:{strategies:["jwt"],scope:["update:resource-server"]},validate:{payload:{apiAccess:o.default.boolean().required(),token_lifetime:o.default.number().integer()}}},handler:function(e,t){return e.payload.apiAccess?(0,i.getApi)(e).then(function(t){return t?(0,i.updateApi)(e,e.payload.token_lifetime):(0,i.createApi)(e,e.payload.token_lifetime)}).then(function(){return t().code(204)}).catch(function(e){return t.error(e)}):(0,i.deleteApi)(e).then(function(){return t().code(204)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";var n=r(49),o=function(e){return e&&e.__esModule?e:{default:e}}(n);e.exports=function(e){return{method:"PATCH",path:"/api/configuration/rotate-apikey",config:{auth:{strategies:["jwt"],scope:["update:configuration"]},pre:[e.handlers.managementClient]},handler:function(e,t){return(0,o.default)(e.storage,e.pre.auth0).then(function(e){return t({hash:e})}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(20),i=n(o),u=r(1),a=n(u),s=r(42),c=n(s),f=r(48),d=n(f);e.exports=function(e){return{method:"PATCH",path:"/api/configuration",config:{auth:{strategies:["jwt"],scope:["update:configuration"]},pre:[e.handlers.managementClient],validate:{options:{allowUnknown:!1},payload:c.default}},handler:function(e,t){var r=e.payload;(0,d.default)(e.storage,e.pre.auth0,r,e.auth.credentials.email||"unknown").then(function(t){e.pre.auth0.rules.getAll().then(function(r){var n={name:"auth0-authorization-extension",enabled:!0,script:t},o=a.default.find(r,{name:n.name});return o?e.pre.auth0.rules.update({id:o.id},n):e.pre.auth0.rules.create((0,i.default)({stage:"login_success"},n))})}).then(function(){return e.storage.updateConfiguration(r)}).then(function(e){return t(e)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";var n=r(11);e.exports=function(){return{method:"POST",path:"/api/configuration/resource-server",config:{auth:{strategies:["jwt"],scope:["create:resource-server"]}},handler:function(e,t){return(0,n.createApi)(e).then(function(e){return t(e)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";var n=r(87),o=function(e){return e&&e.__esModule?e:{default:e}}(n);e.exports=function(){return{method:"POST",path:"/api/configuration/import",config:{auth:{strategies:["jwt"],scope:["update:configuration"]},validate:{payload:o.default}},handler:function(e,t){return e.storage.provider&&e.storage.provider.storageContext&&"function"==typeof e.storage.provider.storageContext.write?e.storage.provider.storageContext.storage&&e.storage.provider.storageContext.storage.set?e.storage.provider.storageContext.storage.set(e.payload,{force:!0},function(e){return e?t.error(e):t().code(204)}):e.storage.provider.storageContext.write(e.payload).then(function(){return t().code(204)}).catch(function(e){return t.error(e)}):t.error(new Error('Unable to use "import" without proper storage'))}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=n(o),u=r(42),a=n(u);t.default=i.default.object().keys({configuration:i.default.array().items(function(e){return e.keys({_id:i.default.string().required()})}(a.default)),groups:i.default.array().items(i.default.object()),roles:i.default.array().items(i.default.object()),permissions:i.default.array().items(i.default.object()),applications:i.default.array().items(i.default.object()),rules:i.default.array().items(i.default.object())})},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(1),i=n(o),u=r(50),a=n(u);e.exports=function(e){return{method:"GET",path:"/api/connections",config:{auth:{strategies:["jwt"],scope:["read:connections"]},pre:[e.handlers.managementClient]},handler:function(e,t){return(0,a.default)(e.pre.auth0,"connections",{fields:"id,name,strategy"}).then(function(e){return i.default.chain(e).sortBy(function(e){return e.name.toLowerCase()}).value()}).then(function(e){return t(e)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(55),i=n(o),u=r(1),a=n(u),s=r(2),c=n(s),f=r(11);e.exports=function(e){return{method:"DELETE",path:"/.extensions/on-uninstall",config:{auth:!1,pre:[e.handlers.validateHookToken("/.extensions/on-uninstall"),e.handlers.managementClient]},handler:function(e,t){e.pre.auth0.rules.getAll().then(function(t){var r=a.default.find(t,{name:"auth0-authorization-extension"});return r?e.pre.auth0.rules.delete({id:r.id}):i.default.resolve()}).then(function(){return(0,f.deleteApi)(e,!0)}).then(function(){return e.pre.auth0.clients.delete({client_id:(0,c.default)("AUTH0_CLIENT_ID")})}).then(function(){return t().code(204)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(55),i=n(o),u=r(1),a=n(u),s=r(48),c=n(s);e.exports=function(e){return{method:"PUT",path:"/.extensions/on-update",config:{auth:!1,pre:[e.handlers.validateHookToken("/.extensions/on-update"),e.handlers.managementClient]},handler:function(e,t){e.pre.auth0.rules.getAll().then(function(t){var r={groupsInToken:!0,persistGroups:!0},n="auth0-authorization-extension",o=a.default.find(t,{name:n});return o?(0,c.default)(e.storage,e.pre.auth0,r,n).then(function(t){return e.pre.auth0.rules.update({id:o.id},{name:n,script:t})}):i.default.resolve()}).then(function(){return t().code(204)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(1),i=n(o),u=r(0),a=n(u),s=r(95),c=n(s);e.exports=function(){return{method:"DELETE",path:"/api/groups/{id}/mappings",config:{auth:{strategies:["jwt"],scope:["update:groups"]},description:"Delete one or more group mappings from a group.",tags:["api"],validate:{options:{allowUnknown:!1},params:{id:a.default.string().guid().required()},payload:c.default}},handler:function(e,t){var r=e.payload;e.storage.getGroup(e.params.id).then(function(t){return r.forEach(function(e){var r=i.default.find(t.mappings,{_id:e});r&&t.mappings.splice(t.mappings.indexOf(r),1)}),e.storage.updateGroup(e.params.id,t)}).then(function(){return t().code(204)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";var n=r(0),o=function(e){return e&&e.__esModule?e:{default:e}}(n),i=r(8);e.exports=function(e){return{method:"GET",path:"/api/groups/{id}/mappings",config:{auth:{strategies:["jwt"],scope:["read:groups"]},description:"Get the mappings for a group.",tags:["api"],pre:[e.handlers.managementClient],validate:{params:{id:o.default.string().guid().required()}}},handler:function(e,t){return e.storage.getGroup(e.params.id).then(function(e){return e.mappings||[]}).then(function(t){return(0,i.getMappingsWithNames)(e.pre.auth0,t)}).then(function(e){return t(e)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(212),i=n(o),u=r(96),a=n(u);e.exports=function(){return{method:"PATCH",path:"/api/groups/{id}/mappings",config:{auth:{strategies:["jwt"],scope:["update:groups"]},description:"Create one or more mappings in a group.",tags:["api"],validate:{options:{allowUnknown:!1},payload:a.default}},handler:function(e,t){var r=e.payload;e.storage.getGroup(e.params.id).then(function(t){return t.mappings||(t.mappings=[]),r.forEach(function(e){t.mappings.push({_id:i.default.v4(),groupName:e.groupName,connectionName:e.connectionName})}),e.storage.updateGroup(e.params.id,t)}).then(function(){return t().code(204)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=function(e){return e&&e.__esModule?e:{default:e}}(n);t.default=o.default.object().keys({groupName:o.default.string().min(1).max(50).required(),connectionName:o.default.string().min(1).max(50).required()})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=function(e){return e&&e.__esModule?e:{default:e}}(n);t.default=o.default.array().items(o.default.string().guid()).required().min(1)},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=n(o),u=r(94),a=n(u);t.default=i.default.array().items(a.default).required().min(1)},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(0),i=n(o),u=r(43),a=n(u);e.exports=function(){return{method:"DELETE",path:"/api/groups/{id}/members",config:{auth:{strategies:["jwt"],scope:["update:groups"]},description:"Delete one or more members from a group.",tags:["api"],validate:{options:{allowUnknown:!1},params:{id:i.default.string().guid().required()},payload:a.default}},handler:function(e,t){var r=e.payload;e.storage.getGroup(e.params.id).then(function(t){return r.forEach(function(e){var r=t.members.indexOf(e);r>-1&&t.members.splice(r,1)}),e.storage.updateGroup(e.params.id,t)}).then(function(){return t().code(204)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";var n=r(0),o=function(e){return e&&e.__esModule?e:{default:e}}(n),i=r(52);e.exports=function(e){return{method:"GET",path:"/api/groups/{id}/members",config:{auth:{strategies:["jwt"],scope:["read:groups"]},description:"Get the members for a group.",tags:["api"],pre:[e.handlers.managementClient],validate:{params:{id:o.default.string().guid().required()},query:{per_page:o.default.number().integer().min(1).max(25).default(25),page:o.default.number().integer().min(0).default(0)}}},handler:function(e,t){return e.storage.getGroup(e.params.id).then(function(t){return(0,i.getUsersById)(e.pre.auth0,t.members||[],e.query.page,e.query.per_page)}).then(function(e){return t(e)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(1),i=n(o),u=r(0),a=n(u),s=r(52),c=r(8);e.exports=function(e){return{method:"GET",path:"/api/groups/{id}/members/nested",config:{auth:{strategies:["jwt"],scope:["read:groups"]},description:"Get the nested members for a group.",tags:["api"],pre:[e.handlers.managementClient],validate:{params:{id:a.default.string().guid().required()},query:{per_page:a.default.number().integer().min(1).max(25).default(25),page:a.default.number().integer().min(0).default(0)}}},handler:function(e,t){return e.storage.getGroups().then(function(t){var r=i.default.find(t,{_id:e.params.id}),n=(0,c.getChildGroups)(t,[r]);return(0,c.getMembers)(n)}).then(function(t){var r=t?t.map(function(e){return e.userId}):[];return(0,s.getUsersById)(e.pre.auth0,r,e.query.page,e.query.per_page).then(function(e){var r=t.length,n=e.users.map(function(e){var r=i.default.find(t,{userId:e.user_id});return r&&(r={_id:r.group._id,name:r.group.name,description:r.group.description}),{user:{user_id:e.user_id,name:e.name,nickname:e.nickname,email:e.email},group:r}});return{total:r,nested:i.default.sortByOrder(n,["user.name"],[!0])}})}).then(function(e){return t(e)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(0),i=n(o),u=r(43),a=n(u);e.exports=function(){return{method:"PATCH",path:"/api/groups/{id}/members",config:{auth:{strategies:["jwt"],scope:["update:groups"]},description:"Add one or more members in a group.",tags:["api"],validate:{options:{allowUnknown:!1},params:{id:i.default.string().guid().required()},payload:a.default}},handler:function(e,t){var r=e.payload;e.storage.getGroup(e.params.id).then(function(t){return t.members||(t.members=[]),r.forEach(function(e){-1===t.members.indexOf(e)&&t.members.push(e)}),e.storage.updateGroup(e.params.id,t)}).then(function(){return t().code(204)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(0),i=n(o),u=r(44),a=n(u);e.exports=function(){return{method:"DELETE",path:"/api/groups/{id}/nested",config:{auth:{strategies:["jwt"],scope:["update:groups"]},description:"Delete one or more nested groups from a group.",tags:["api"],validate:{options:{allowUnknown:!1},params:{id:i.default.string().guid().required()},payload:a.default}},handler:function(e,t){var r=e.payload;e.storage.getGroup(e.params.id).then(function(t){return r.forEach(function(e){var r=t.nested.indexOf(e);r>-1&&t.nested.splice(r,1)}),e.storage.updateGroup(e.params.id,t)}).then(function(){return t().code(204)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(0),i=n(o),u=r(1),a=n(u);e.exports=function(){return{method:"GET",path:"/api/groups/{id}/nested",config:{auth:{strategies:["jwt"],scope:["read:groups"]},description:"Get the nested groups for a group.",tags:["api"],validate:{params:{id:i.default.string().guid().required()}}},handler:function(e,t){return e.storage.getGroups().then(function(t){var r=a.default.find(t,{_id:e.params.id});return r.nested||(r.nested=[]),a.default.filter(t,function(e){return r.nested.indexOf(e._id)>-1})}).then(function(e){return a.default.sortByOrder(e,["name"],[!0])}).then(function(e){return t(e)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(0),i=n(o),u=r(44),a=n(u);e.exports=function(){return{method:"PATCH",path:"/api/groups/{id}/nested",config:{auth:{strategies:["jwt"],scope:["update:groups"]},description:"Add one or more nested groups in a group.",tags:["api"],validate:{options:{allowUnknown:!1},params:{id:i.default.string().guid().required()},payload:a.default}},handler:function(e,t){var r=e.payload;e.storage.getGroup(e.params.id).then(function(t){return t.nested||(t.nested=[]),r.forEach(function(r){-1===t.nested.indexOf(r)&&r!==e.params.id&&t.nested.push(r)}),e.storage.updateGroup(e.params.id,t)}).then(function(){return t().code(204)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";var n=r(0),o=function(e){return e&&e.__esModule?e:{default:e}}(n);e.exports=function(){return{method:"DELETE",path:"/api/groups/{id}/roles",config:{auth:{strategies:["jwt"],scope:["update:groups"]},description:"Delete one or more roles from a group.",tags:["api"],validate:{options:{allowUnknown:!1},params:{id:o.default.string().guid().required()},payload:o.default.array().items(o.default.string().guid()).required().min(1)}},handler:function(e,t){var r=e.payload;e.storage.getGroup(e.params.id).then(function(t){return r.forEach(function(e){var r=t.roles.indexOf(e);r>-1&&t.roles.splice(r,1)}),e.storage.updateGroup(e.params.id,t)}).then(function(){return t().code(204)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(1),i=n(o),u=r(0),a=n(u),s=r(8);e.exports=function(e){return{method:"GET",path:"/api/groups/{id}/roles/nested",config:{auth:{strategies:["jwt"],scope:["read:groups"]},description:"Get the nested roles for a group.",tags:["api"],pre:[e.handlers.managementClient],validate:{params:{id:a.default.string().guid().required()}}},handler:function(e,t){return e.storage.getGroups().then(function(t){var r=i.default.find(t,{_id:e.params.id});return(0,s.getParentGroups)(t,[r])}).then(function(t){return e.storage.getRoles().then(function(e){return(0,s.getRolesForGroups)(t,e)})}).then(function(e){return t(e)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";var n=r(0),o=function(e){return e&&e.__esModule?e:{default:e}}(n);e.exports=function(e){return{method:"GET",path:"/api/groups/{id}/roles",config:{auth:{strategies:["jwt"],scope:["read:groups"]},description:"Get the roles for a group.",tags:["api"],pre:[e.handlers.managementClient],validate:{params:{id:o.default.string().guid().required()}}},handler:function(e,t){return e.storage.getGroup(e.params.id).then(function(e){return e.roles||[]}).then(function(t){return e.storage.getRoles().then(function(e){return e.filter(function(e){return t.indexOf(e._id)>-1})})}).then(function(e){return t(e)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";var n=r(0),o=function(e){return e&&e.__esModule?e:{default:e}}(n);e.exports=function(){return{method:"PATCH",path:"/api/groups/{id}/roles",config:{auth:{strategies:["jwt"],scope:["update:groups"]},description:"Add one or more roles to a group.",tags:["api"],validate:{options:{allowUnknown:!1},params:{id:o.default.string().guid().required()},payload:o.default.array().items(o.default.string().guid()).required().min(1)}},handler:function(e,t){var r=e.payload;e.storage.getGroup(e.params.id).then(function(t){return t.roles||(t.roles=[]),r.forEach(function(e){-1===t.roles.indexOf(e)&&t.roles.push(e)}),e.storage.updateGroup(e.params.id,t)}).then(function(){return t().code(204)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";var n=r(0),o=function(e){return e&&e.__esModule?e:{default:e}}(n);e.exports=function(){return{method:"DELETE",path:"/api/groups/{id}",config:{auth:{strategies:["jwt"],scope:["delete:groups"]},description:"Delete a group.",tags:["api"],validate:{options:{allowUnknown:!1},params:{id:o.default.string().guid().required()}}},handler:function(e,t){e.storage.deleteGroup(e.params.id).then(function(){return t().code(204)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";var n=r(0),o=function(e){return e&&e.__esModule?e:{default:e}}(n),i=r(8);e.exports=function(){return{method:"GET",path:"/api/groups/{id}",config:{auth:{strategies:["jwt"],scope:["read:groups"]},description:'Get a single group based on its unique identifier. Add "?expand" to also load all roles and permissions for this group.',tags:["api"],validate:{query:{expand:o.default.boolean()},params:{id:o.default.string().guid().required()}}},handler:function(e,t){return e.query.expand?(0,i.getGroupExpanded)(e.storage,e.params.id).then(function(e){return t(e)}).catch(function(e){return t.error(e)}):e.storage.getGroup(e.params.id).then(function(e){return t({_id:e._id,name:e.name,description:e.description})}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(1),i=n(o),u=r(0),a=n(u);e.exports=function(){return{method:"GET",path:"/api/groups",config:{auth:{strategies:["jwt"],scope:["read:groups"]},description:"Get all groups in the system.",tags:["api"],validate:{query:{q:a.default.string().max(1e3).allow("").default(""),field:a.default.string().max(1e3).allow("").default("")}}},handler:function(e,t){return e.storage.getGroups().then(function(e){return e.map(function(e){var t=e;return t.mappings=t.mappings||[],t.members=t.members||[],t})}).then(function(t){return{groups:i.default.filter(t,function(t){var r=e.query.q;if(!r)return!0;var n=e.query.field;return i.default.includes(t[n].toLowerCase(),r.toLowerCase())}),total:t.length}}).then(function(e){return t(e)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";var n=r(45),o=function(e){return e&&e.__esModule?e:{default:e}}(n);e.exports=function(){return{method:"POST",path:"/api/groups",config:{auth:{strategies:["jwt"],scope:["create:groups"]},description:"Create a new group.",tags:["api"],validate:{options:{allowUnknown:!1},payload:o.default}},handler:function(e,t){var r=e.payload;return e.storage.createGroup(r).then(function(e){return t(e)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(0),i=n(o),u=r(45),a=n(u);e.exports=function(){return{method:"PUT",path:"/api/groups/{id}",config:{auth:{strategies:["jwt"],scope:["update:groups"]},description:"Update a group.",tags:["api"],validate:{options:{allowUnknown:!1},params:{id:i.default.string().guid().required()},payload:a.default}},handler:function(e,t){var r=e.payload;return e.storage.updateGroup(e.params.id,r).then(function(e){return t(e)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";var n=r(197),o=function(e){return e&&e.__esModule?e:{default:e}}(n);e.exports=function(){return{method:"GET",path:"/meta",config:{auth:!1},handler:function(e,t){return t(o.default)}}}},function(e,t,r){"use strict";var n=r(0),o=function(e){return e&&e.__esModule?e:{default:e}}(n);e.exports=function(){return{method:"DELETE",path:"/api/permissions/{id}",config:{auth:{strategies:["jwt"],scope:["delete:permissions"]},description:"Delete a permission.",tags:["api"],validate:{options:{allowUnknown:!1},params:{id:o.default.string().guid().required()}}},handler:function(e,t){e.storage.deletePermission(e.params.id).then(function(){return t().code(204)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";var n=r(0),o=function(e){return e&&e.__esModule?e:{default:e}}(n);e.exports=function(){return{method:"GET",path:"/api/permissions/{id}",config:{auth:{strategies:["jwt"],scope:["read:permissions"]},description:"Get a single permission based on its unique identifier.",tags:["api"],validate:{params:{id:o.default.string().guid().required()}}},handler:function(e,t){return e.storage.getPermission(e.params.id).then(function(e){return t({_id:e._id,name:e.name,description:e.description})}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(1),i=n(o),u=r(0),a=n(u);e.exports=function(){return{method:"GET",path:"/api/permissions",config:{auth:{strategies:["jwt"],scope:["read:permissions"]},description:"Get all permissions in the system.",tags:["api"],validate:{query:{q:a.default.string().max(1e3).allow("").default(""),field:a.default.string().max(1e3).allow("").default("")}}},handler:function(e,t){return e.storage.getPermissions().then(function(t){return{permissions:i.default.filter(t,function(t){var r=e.query.q;if(!r)return!0;var n=e.query.field;return i.default.includes(t[n].toLowerCase(),r.toLowerCase())}),total:t.length}}).then(function(e){return t(e)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";var n=r(46),o=function(e){return e&&e.__esModule?e:{default:e}}(n);e.exports=function(){return{method:"POST",path:"/api/permissions",config:{auth:{strategies:["jwt"],scope:["create:permissions"]},description:"Create a new permission.",tags:["api"],validate:{options:{allowUnknown:!1},payload:o.default}},handler:function(e,t){var r=e.payload;return e.storage.createPermission(r).then(function(e){return t(e)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(0),i=n(o),u=r(46),a=n(u);e.exports=function(){return{method:"PUT",path:"/api/permissions/{id}",config:{auth:{strategies:["jwt"],scope:["update:permissions"]},description:"Update a permission.",tags:["api"],validate:{options:{allowUnknown:!1},params:{id:i.default.string().guid().required()},payload:a.default}},handler:function(e,t){var r=e.payload;return e.storage.updatePermission(e.params.id,r).then(function(e){return t(e)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(0),i=n(o),u=r(120),a=n(u),s=r(8);e.exports=function(e){return{method:"POST",path:"/api/users/{userId}/policy/{clientId}",config:{auth:{strategies:["jwt","extension-secret"]},description:"Execute the authorization policy for a user in the context of a client. This will return the user's groups but also roles and permissions that apply to the current client.",tags:["api"],validate:{params:{userId:i.default.string().required(),clientId:i.default.string().required()},payload:a.default}},handler:function(e,t){var r=e.params,n=r.userId,o=r.clientId,i=e.payload,u=i.connectionName,a=i.groups;return e.storage.provider&&e.storage.provider.storageContext&&e.storage.provider.storageContext.read?(0,s.getUserData)(e.storage,n,o,u,a).then(function(e){return t(e)}).catch(function(e){return t.error(e)}):t.error(new Error("Storage error."))}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=function(e){return e&&e.__esModule?e:{default:e}}(n);t.default=o.default.object().keys({connectionName:o.default.string().required(),groups:o.default.array().items(o.default.string())})},function(e,t,r){"use strict";var n=r(0),o=function(e){return e&&e.__esModule?e:{default:e}}(n);e.exports=function(){return{method:"DELETE",path:"/api/roles/{id}",config:{auth:{strategies:["jwt"],scope:["delete:roles"]},description:"Delete a role.",tags:["api"],validate:{options:{allowUnknown:!1},params:{id:o.default.string().guid().required()}}},handler:function(e,t){e.storage.deleteRole(e.params.id).then(function(){return t().code(204)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";var n=r(0),o=function(e){return e&&e.__esModule?e:{default:e}}(n);e.exports=function(){return{method:"GET",path:"/api/roles/{id}",config:{auth:{strategies:["jwt"],scope:["read:roles"]},description:"Get a single role based on its unique identifier.",tags:["api"],validate:{params:{id:o.default.string().guid().required()}}},handler:function(e,t){return e.storage.getRole(e.params.id).then(function(e){return t({_id:e._id,name:e.name,description:e.description})}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(1),i=n(o),u=r(0),a=n(u);e.exports=function(){return{method:"GET",path:"/api/roles",config:{auth:{strategies:["jwt"],scope:["read:roles"]},description:"Get all roles in the system.",tags:["api"],validate:{query:{q:a.default.string().max(1e3).allow("").default(""),field:a.default.string().max(1e3).allow("").default("")}}},handler:function(e,t){return e.storage.getRoles().then(function(t){return{roles:i.default.filter(t,function(t){var r=e.query.q;if(!r)return!0;var n=e.query.field;return i.default.includes(t[n].toLowerCase(),r.toLowerCase())}),total:t.length}}).then(function(e){return t(e)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(1),i=n(o),u=r(47),a=n(u);e.exports=function(){return{method:"POST",path:"/api/roles",config:{auth:{strategies:["jwt"],scope:["create:roles"]},description:"Create a new role.",tags:["api"],validate:{options:{allowUnknown:!1},payload:a.default}},handler:function(e,t){var r=e.payload;return e.storage.getPermissions().then(function(n){return r.permissions.forEach(function(e){var t=i.default.find(n,{_id:e});if(t&&t.applicationId!==r.applicationId)throw new Error("The permission '"+t.name+"' is linked to a different application.")}),e.storage.createRole(r).then(function(e){return t(e)})}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(1),i=n(o),u=r(0),a=n(u),s=r(47),c=n(s);e.exports=function(){return{method:"PUT",path:"/api/roles/{id}",config:{auth:{strategies:["jwt"],scope:["update:roles"]},description:"Update a role.",tags:["api"],validate:{options:{allowUnknown:!1},params:{id:a.default.string().guid().required()},payload:c.default}},handler:function(e,t){var r=e.payload;return e.storage.getPermissions().then(function(e){r.permissions.forEach(function(t){var n=i.default.find(e,{_id:t});if(n&&n.applicationId!==r.applicationId)throw new Error("The permission '"+n.name+"' is linked to a different application.")})}).then(function(){return e.storage.getRole(e.params.id)}).then(function(n){if(n.applicationId!==r.applicationId)throw new Error("The 'applicationId' of a role cannot be changed.");return e.storage.updateRole(e.params.id,r).then(function(e){return t(e)})}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(0),i=n(o),u=r(1),a=n(u),s=r(8);e.exports=function(){return{method:"GET",path:"/api/users/{id}/groups",config:{auth:{strategies:["jwt"],scope:["read:groups"]},description:'Get the groups for a user. Add "?expand" to also load all roles and permissions for these groups.',tags:["api"],validate:{params:{id:i.default.string().required()}}},handler:function(e,t){return e.query.expand?e.storage.getGroups().then(function(t){return a.default.filter(t,function(t){return a.default.includes(t.members,e.params.id)})}).then(function(t){return(0,s.getGroupsExpanded)(e.storage,t)}).then(function(e){return t(e)}).catch(function(e){return t.error(e)}):e.storage.getGroups().then(function(t){return a.default.filter(t,function(t){return a.default.includes(t.members,e.params.id)})}).then(function(e){return e.map(function(e){return{_id:e._id,name:e.name,description:e.description}})}).then(function(e){return t(e)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(0),i=n(o),u=r(1),a=n(u),s=r(8);e.exports=function(){return{method:"GET",path:"/api/users/{id}/groups/calculate",config:{auth:{strategies:["jwt"],scope:["read:groups"]},description:"Calculate the group memberships for a user (including nested groups).",tags:["api"],validate:{params:{id:i.default.string().required()}}},handler:function(e,t){return e.storage.getGroups().then(function(t){return(0,s.getParentGroups)(t,a.default.filter(t,function(t){return a.default.includes(t.members,e.params.id)}))}).then(function(e){return e.map(function(e){return{_id:e._id,name:e.name,description:e.description}})}).then(function(e){return t(e)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(7),i=n(o),u=r(0),a=n(u);e.exports=function(){return{method:"PATCH",path:"/api/users/{id}/groups",config:{auth:{strategies:["jwt"],scope:["update:groups"]},description:"Add a single user to groups.",tags:["api"],validate:{params:{id:a.default.string().required()},payload:a.default.array().items(a.default.string().guid()).required().min(1)}},handler:function(e,t){var r=e.payload;return i.default.each(r,function(t){return e.storage.getGroup(t).then(function(r){return r.members||(r.members=[]),-1===r.members.indexOf(e.params.id)&&r.members.push(e.params.id),e.storage.updateGroup(t,r)})}).then(function(){return t().code(204)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(7),i=n(o),u=r(0),a=n(u);e.exports=function(){return{method:"DELETE",path:"/api/users/{id}/roles",config:{auth:{strategies:["jwt"],scope:["update:roles"]},description:"Remove a single user from roles.",tags:["api"],validate:{params:{id:a.default.string().required()},payload:a.default.array().items(a.default.string().guid()).required().min(1)}},handler:function(e,t){var r=e.payload;return i.default.each(r,function(t){return e.storage.getRole(t).then(function(r){r.users||(r.users=[]);var n=r.users.indexOf(e.params.id);return n>-1&&r.users.splice(n,1),e.storage.updateRole(t,r)})}).then(function(){return t().code(204)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(0),i=n(o),u=r(1),a=n(u);e.exports=function(){return{method:"GET",path:"/api/users/{id}/roles",config:{auth:{strategies:["jwt"],scope:["read:roles"]},description:"Get the roles for a user.",tags:["api"],validate:{params:{id:i.default.string().required()}}},handler:function(e,t){return e.storage.getRoles().then(function(t){return a.default.filter(t,function(t){return a.default.includes(t.users,e.params.id)})}).then(function(e){return e.map(function(e){return{_id:e._id,name:e.name,applicationId:e.applicationId,description:e.description}})}).then(function(e){return t(e)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";var n=r(0),o=function(e){return e&&e.__esModule?e:{default:e}}(n),i=r(8);e.exports=function(){return{method:"GET",path:"/api/users/{id}/roles/calculate",config:{auth:{strategies:["jwt"],scope:["read:roles"]},description:"Calculate the roles assigned to the user (including through group memberships).",tags:["api"],validate:{params:{id:o.default.string().required()}}},handler:function(e,t){return(0,i.getRolesForUser)(e.storage,e.params.id).then(function(e){return e.map(function(e){return{_id:e._id,name:e.name,applicationId:e.applicationId,description:e.description}})}).then(function(e){return t(e)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(7),i=n(o),u=r(0),a=n(u);e.exports=function(){return{method:"PATCH",path:"/api/users/{id}/roles",config:{auth:{strategies:["jwt"],scope:["update:roles"]},description:"Add a single user to roles.",tags:["api"],validate:{params:{id:a.default.string().required()},payload:a.default.array().items(a.default.string().guid()).required().min(1)}},handler:function(e,t){var r=e.payload;return i.default.each(r,function(t){return e.storage.getRole(t).then(function(r){return r.users||(r.users=[]),-1===r.users.indexOf(e.params.id)&&r.users.push(e.params.id),e.storage.updateRole(t,r)})}).then(function(){return t().code(204)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";var n=r(0),o=function(e){return e&&e.__esModule?e:{default:e}}(n);e.exports=function(e){return{method:"GET",path:"/api/users/{id}",config:{auth:{strategies:["jwt"],scope:["read:users"]},description:"Get a single user based on its unique identifier.",validate:{params:{id:o.default.string().required()}},pre:[e.handlers.managementClient]},handler:function(e,t){return e.pre.auth0.users.get({id:e.params.id}).then(function(e){return t(e)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(0),i=n(o),u=r(2),a=n(u);e.exports=function(e){return{method:"GET",path:"/api/users",config:{auth:{strategies:["jwt"],scope:["read:users"]},description:"Get all users.",validate:{query:{q:i.default.string().max(1e3).allow("").default(""),field:i.default.string().max(1e3).allow("").default(""),per_page:i.default.number().integer().min(1).max(200).default(100),page:i.default.number().integer().min(0).default(0)}},pre:[e.handlers.managementClient]},handler:function(e,t){var r=e.query.page-1<0?0:e.query.page-1,n={sort:"last_login:-1",q:e.query.field?e.query.field+":"+e.query.q:e.query.q,per_page:e.query.per_page||100,page:r||0,include_totals:!0,fields:"user_id,name,email,identities,picture,last_login,logins_count,multifactor,blocked",search_engine:"auth0.auth0.com"!==(0,a.default)("AUTH0_RTA").replace("https://","")?"v2":"v3"};e.pre.auth0.users.getAll(n).then(function(e){return t(e)}).catch(function(e){return t.error(e)})}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=r(53),i=n(o),u=r(56),a=n(u),s=r(206),c=n(s),f=r(203),d=n(f),l=r(207),p=n(l),h=r(213),g=n(h),m=r(200),v=n(m),_=r(204),y=n(_),x=r(202),w=n(x),E=r(205),b=n(E),T=r(2),A=n(T),P=r(10),M=n(P),k=r(143),j=n(k);t.default=function(e){var t={register:d.default,options:{ops:{interval:3e4},reporters:{console:[]}}},r={register:b.default,options:{documentationPage:!1,swaggerUI:!1}};t.options.reporters.console.push(new w.default({color:!!(0,A.default)("LOG_COLOR")})),t.options.reporters.console.push("stdout");var n=(0,g.default)({}),o=new c.default.Server;return o.connection({host:"localhost",port:(0,A.default)("PORT"),routes:{cors:!0,validate:{failAction:n.failAction}}}),o.register([t,p.default,v.default,y.default,r].concat((0,a.default)(j.default)),function(t){return t?e(t,null):(M.default.debug=function(){for(var e=arguments.length,t=Array(e),r=0;r\";\n\n var audience = '';\n audience = audience || (context.request && context.request.query && context.request.query.audience);\n if (audience === 'urn:auth0-authz-api') {\n return callback(new UnauthorizedError('no_end_users'));\n }\n\n audience = audience || (context.request && context.request.body && context.request.body.audience);\n if (audience === 'urn:auth0-authz-api') {\n return callback(new UnauthorizedError('no_end_users'));\n }\n\n getPolicy(user, context, function(err, res, data) {\n if (err) {\n console.log('Error from Authorization Extension:', err);\n return callback(new UnauthorizedError('Authorization Extension: ' + err.message));\n }\n\n if (res.statusCode !== 200) {\n console.log('Error from Authorization Extension:', res.body || res.statusCode);\n return callback(\n new UnauthorizedError('Authorization Extension: ' + ((res.body && (res.body.message || res.body) || res.statusCode)))\n );\n }\n\n // Update the user object.<% if (config.groupsInToken && !config.groupsPassthrough) { %>\n user.groups = data.groups;<% } %><% if (config.groupsInToken && config.groupsPassthrough) { %>\n user.groups = mergeRecords(user.groups, data.groups);<% } %><% if (config.rolesInToken && !config.rolesPassthrough) { %>\n user.roles = data.roles;<% } %><% if (config.rolesInToken && config.rolesPassthrough) { %>\n user.roles = mergeRecords(user.roles, data.roles);<% } %><% if (config.permissionsInToken && !config.permissionsPassthrough) { %>\n user.permissions = data.permissions;<% } %><% if (config.permissionsInToken && config.permissionsPassthrough) { %>\n user.permissions = mergeRecords(user.permissions, data.permissions);<% } %>\n<% if (config.persistGroups || config.persistRoles || config.persistPermissions) { %>\n // Store this in the user profile (app_metadata).\n saveToMetadata(user, data.groups, data.roles, data.permissions, function(err) {\n return callback(err, user, context);\n });\n<% } else { %>\n return callback(null, user, context);\n<% } %> });\n\n // Get the policy for the user.\n function getPolicy(user, context, cb) {\n request.post({\n url: EXTENSION_URL + \"/api/users/\" + user.user_id + \"/policy/\" + context.clientID,\n headers: {\n \"x-api-key\": configuration.AUTHZ_EXT_API_KEY\n },\n json: {\n connectionName: context.connection || user.identities[0].connection,\n groups: user.groups\n },\n timeout: 5000\n }, cb);\n }<% if (config.persistGroups || config.persistRoles || config.persistPermissions) { %>\n\n // Store authorization data in the user profile so we can query it later.\n function saveToMetadata(user, groups, roles, permissions, cb) {\n user.app_metadata = user.app_metadata || {};\n user.app_metadata.authorization = {<% if (config.persistGroups && !config.groupsPassthrough) { %>\n groups: groups,<% } %><% if (config.persistGroups && config.groupsPassthrough) { %>\n groups: mergeRecords(user.groups, groups),<% } %><% if (config.persistRoles && !config.rolesPassthrough) { %>\n roles: roles,<% } %><% if (config.persistRoles && config.rolesPassthrough) { %>\n roles: mergeRecords(user.roles, roles),<% } %><% if (config.persistPermissions && !config.permissionsPassthrough) { %>\n permissions: permissions<% } %><% if (config.persistPermissions && config.permissionsPassthrough) { %>\n permissions: mergeRecords(user.permissions, permissions)<% } %>\n };\n\n auth0.users.updateAppMetadata(user.user_id, user.app_metadata)\n .then(function() {\n cb();\n })\n .catch(function(err){\n cb(err);\n });\n }<% } %><% if (config.groupsPassthrough || config.rolesPassthrough || config.permissionsPassthrough) { %>\n\n // Merge the IdP records with the records of the extension.\n function mergeRecords(idpRecords, extensionRecords) {\n idpRecords = idpRecords || [ ];\n extensionRecords = extensionRecords || [ ];\n\n if (!Array.isArray(idpRecords)) {\n idpRecords = idpRecords.replace(/,/g, ' ').replace(/\\s+/g, ' ').split(' ');\n }\n\n return _.uniq(_.union(idpRecords, extensionRecords));\n }<% } %>\n}"},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=r(20),i=n(o),u=r(53),a=n(u),s=r(152),c=n(s),f=r(153),d=n(f),l=r(1),p=n(l),h=r(7),g=n(h),m=r(15),v=r(2),_=n(v),y=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Record with that identifier is already exists.",r=arguments[2];return 0===e.length?null:r&&1===e.length&&e[0]._id===r?null:g.default.reject(new m.ValidationError(t))},x=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if((0,c.default)(this,e),!t.provider)throw new m.ArgumentError("The 'provider' has to be set when initializing the database.");this.provider=t.provider}return(0,d.default)(e,[{key:"getStatus",value:function(){return(0,_.default)("STORAGE_TYPE")&&"webtask"!==(0,_.default)("STORAGE_TYPE")?g.default.resolve({size:null,type:(0,_.default)("STORAGE_TYPE")}):this.provider.storageContext.read().then(function(e){return{size:Buffer.byteLength((0,a.default)(e),"utf8"),type:"default"}})}},{key:"canChange",value:function(e,t,r){return this.provider.getAll(e).then(function(e){return p.default.filter(e,function(e){return e[t]&&p.default.includes(e[t],r)})}).then(function(r){if(r.length){var n=r.map(function(e){return e.name}).join(", "),o="Unable to touch "+t+" while used in "+e+": "+n;return g.default.reject(new m.ValidationError(o))}return g.default.resolve()})}},{key:"getApiKey",value:function(){return this.provider.getAll("configuration").then(function(e){return e.length?e[0].apikey:null})}},{key:"updateApiKey",value:function(e){var t=this;return this.provider.getAll("configuration").then(function(e){return e.length?e[0]:{}}).then(function(r){return t.provider.update("configuration","v1",(0,i.default)({},r,{apikey:e}),!0)})}},{key:"getConfiguration",value:function(){return this.provider.getAll("configuration").then(function(e){return e.length?e[0]:null})}},{key:"updateConfiguration",value:function(e){return this.provider.update("configuration","v1",e,!0)}},{key:"getRules",value:function(){return this.provider.getAll("rules")}},{key:"createRule",value:function(e){return this.provider.create("rules",e)}},{key:"getPermissions",value:function(){return this.provider.getAll("permissions")}},{key:"getPermission",value:function(e){return this.provider.get("permissions",e)}},{key:"createPermission",value:function(e){var t=this;return this.getPermissions().then(function(t){return y(t.filter(function(t){return t.name.toLowerCase()===e.name.toLowerCase()&&t.applicationId===e.applicationId}),'Permission with name "'+e.name+'" already exists for this application')}).then(function(){return t.provider.create("permissions",e)})}},{key:"updatePermission",value:function(e,t){var r=this;return this.getPermissions().then(function(r){return y(r.filter(function(e){return e.name.toLowerCase()===t.name.toLowerCase()&&e.applicationId===t.applicationId}),'Permission with name "'+t.name+'" already exists for this application',e)}).then(function(){return r.canChange("roles","permissions",e)}).then(function(){return r.canChange("groups","permissions",e)}).then(function(){return r.provider.update("permissions",e,t)})}},{key:"deletePermission",value:function(e){var t=this;return this.canChange("roles","permissions",e).then(function(){return t.provider.delete("permissions",e)})}},{key:"getRoles",value:function(){return this.provider.getAll("roles")}},{key:"getRole",value:function(e){return this.provider.get("roles",e)}},{key:"createRole",value:function(e){var t=this;return this.getRoles().then(function(t){return y(t.filter(function(t){return t.name.toLowerCase()===e.name.toLowerCase()&&t.applicationId===e.applicationId}),'Role with name "'+e.name+'" already exists for this application')}).then(function(){return t.provider.create("roles",e)})}},{key:"updateRole",value:function(e,t){var r=this;return this.getRoles().then(function(r){return y(r.filter(function(e){return e.name.toLowerCase()===t.name.toLowerCase()&&e.applicationId===t.applicationId}),'Role with name "'+t.name+'" already exists for this application',e)}).then(function(){return r.provider.update("roles",e,t)})}},{key:"deleteRole",value:function(e){var t=this;return this.canChange("groups","roles",e).then(function(){return t.provider.delete("roles",e)})}},{key:"getGroups",value:function(){return this.provider.getAll("groups")}},{key:"getGroup",value:function(e){return this.provider.get("groups",e)}},{key:"createGroup",value:function(e){var t=this;return this.getGroups().then(function(t){return y(t.filter(function(t){return t.name.toLowerCase()===e.name.toLowerCase()}),'Group with name "'+e.name+'" already exists')}).then(function(){return t.provider.create("groups",e)})}},{key:"updateGroup",value:function(e,t){var r=this;return this.getGroups().then(function(r){return y(r.filter(function(e){return e.name.toLowerCase()===t.name.toLowerCase()}),'Group with name "'+t.name+'" already exists',e)}).then(function(){return r.provider.update("groups",e,t)})}},{key:"deleteGroup",value:function(e){var t=this;return this.canChange("groups","nested",e).then(function(){return t.provider.delete("groups",e)})}},{key:"getApplications",value:function(){return this.provider.getAll("applications")}},{key:"getApplication",value:function(e){return this.provider.get("applications",e)}},{key:"updateApplication",value:function(e,t){return this.provider.update("applications",e,t,!0)}}]),e}();t.default=x},function(e,t,r){"use strict";(function(e){function n(e){return e&&e.__esModule?e:{default:e}}function o(t){switch((0,f.default)("STORAGE_TYPE")){case"s3":l.default.info("Initializing the S3 Storage Context.");var r=new a.S3StorageContext({path:(0,f.default)("S3_PATH"),bucket:(0,f.default)("S3_BUCKET"),keyId:(0,f.default)("S3_KEY"),keySecret:(0,f.default)("S3_SECRET"),defaultData:{}});return new s.BlobRecordProvider(r,{concurrentWrites:!1});case"webtask":default:l.default.info("Initializing the Webtask Storage Context.");var n=t?new s.WebtaskStorageContext(t,{force:0}):new s.FileStorageContext(u.default.join(e,"../../data.json"),{mergeWrites:!0});return new s.BlobRecordProvider(n,{concurrentWrites:!1})}}Object.defineProperty(t,"__esModule",{value:!0}),t.createProvider=o;var i=r(40),u=n(i),a=r(199),s=r(15),c=r(2),f=n(c),d=r(10),l=n(d)}).call(t,"/")},function(e,t,r){"use strict";(function(t){var n=r(40),o=function(e){return e&&e.__esModule?e:{default:e}}(n);e.exports.register=function(e,r,n){e.route({method:"GET",path:"/app/{param*}",config:{auth:!1},handler:{directory:{path:o.default.join(t,"../../dist"),redirectToSlash:!0}}}),n()},e.exports.register.attributes={name:"assets"}}).call(t,"/")},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(39),i=n(o),u=r(72),a=n(u),s=r(209),c=n(s),f=r(208),d=n(f),l=r(19),p=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(l),h=r(2),g=n(h),m=r(11),v=function(e){return a.default.createHmac("sha256",e+" + "+(0,g.default)("AUTH0_CLIENT_SECRET")).update((0,g.default)("EXTENSION_SECRET")).digest("hex")};e.exports.register=function(e,t,r){e.auth.scheme("extension-secret",function(){return{authenticate:function(e,t){var r=e.headers["x-api-key"];return e.storage.getApiKey().then(function(e){return r&&r===v(e)?t.continue({credentials:{user:"rule"}}):t(i.default.unauthorized("Invalid API Key"))})}}}),e.auth.strategy("extension-secret","extension-secret");var n={dashboardAdmin:{key:(0,g.default)("EXTENSION_SECRET"),verifyOptions:{audience:"urn:api-authz",issuer:(0,g.default)("PUBLIC_WT_URL"),algorithms:["HS256"]}},resourceServer:{key:c.default.hapiJwt2Key({cache:!0,rateLimit:!0,jwksRequestsPerMinute:2,jwksUri:"https://"+(0,g.default)("AUTH0_DOMAIN")+"/.well-known/jwks.json"}),verifyOptions:{audience:"urn:auth0-authz-api",issuer:"https://"+(0,g.default)("AUTH0_DOMAIN")+"/",algorithms:["RS256"]}}};e.auth.strategy("jwt","jwt",{complete:!0,verifyFunc:function(e,t,r){if(!e)return r(null,!1);var o=t.headers.authorization;if(o&&0===o.indexOf("Bearer ")){var u=o.split(" ")[1];if(e&&e.payload&&e.payload.iss==="https://"+(0,g.default)("AUTH0_DOMAIN")+"/")return n.resourceServer.key(e,function(t,o){return t?r(i.default.wrap(t),null,null):d.default.verify(u,o,n.resourceServer.verifyOptions,function(t){return t?r(i.default.unauthorized("Invalid token","Token"),null,null):e.payload.gty&&"client-credentials"!==e.payload.gty?r(i.default.unauthorized("Invalid token","Token"),null,null):e.payload.sub.endsWith("@clients")?(e.payload.scope&&"string"==typeof e.payload.scope&&(e.payload.scope=e.payload.scope.split(" ")),r(null,!0,e.payload)):r(i.default.unauthorized("Invalid token","Token"),null,null)})});if(e&&e.payload&&e.payload.iss===(0,g.default)("PUBLIC_WT_URL"))return d.default.verify(u,n.dashboardAdmin.key,n.dashboardAdmin.verifyOptions,function(t){return t?r(i.default.unauthorized("Invalid token","Token"),null,null):e.payload.access_token&&e.payload.access_token.length?(e.payload.scope=m.scopes.map(function(e){return e.value}),r(null,!0,e.payload)):r(i.default.unauthorized("Invalid token","Token"),null,null)})}return r(null,!1)}}),e.auth.default("jwt");var o={register:p.plugins.dashboardAdminSession,options:{stateKey:"authz-state",nonceKey:"authz-nonce",sessionStorageKey:"authz:apiToken",rta:(0,g.default)("AUTH0_RTA").replace("https://",""),domain:(0,g.default)("AUTH0_DOMAIN"),scopes:"read:resource_servers create:resource_servers update:resource_servers delete:resource_servers read:clients read:connections read:rules create:rules update:rules update:rules_configs read:users",baseUrl:(0,g.default)("PUBLIC_WT_URL"),audience:"urn:api-authz",secret:(0,g.default)("EXTENSION_SECRET"),clientName:"Authorization Extension",onLoginSuccess:function(e,t,r){return e?(e.scope=m.scopes.map(function(e){return e.value}),r(null,!0,e)):r(null,!1)}}};e.register(o,function(e){e&&r(e),r()})},e.exports.register.attributes={name:"auth"}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(19),i=r(2),u=n(i),a=r(10),s=n(a),c=r(15),f=r(39),d=function(e,t,r){if(null===e||void 0===e)throw new c.ArgumentError("Must provide the domain");if("string"!=typeof e||0===e.length)throw new c.ArgumentError("The provided domain is invalid: "+e);if(null===t||void 0===t)throw new c.ArgumentError("Must provide the webtaskUrl");if("string"!=typeof t||0===t.length)throw new c.ArgumentError("The provided webtaskUrl is invalid: "+t);if(null===r||void 0===r)throw new c.ArgumentError("Must provide the extensionSecret");if("string"!=typeof r||0===r.length)throw new c.ArgumentError("The provided extensionSecret is invalid: "+r);return function(n){if(null===n||void 0===n)throw new c.ArgumentError("Must provide the hookPath");if("string"!=typeof n||0===n.length)throw new c.ArgumentError("The provided hookPath is invalid: "+n);return{method:function(o,i){if(o.headers.authorization&&"Bearer"===o.headers.authorization.split(" ")[0]){var u=o.headers.authorization.split(" ")[1];try{if(s.default.info("Validating hook token with signature: "+r.substr(0,4)+"..."),c.validateHookToken(e,t,n,r,u))return i()}catch(e){return s.default.error("Invalid token:",u),i(f.wrap(e,401,e.message))}}var a=new c.HookTokenError("Hook token missing for the call to: "+n);return i(f.unauthorized(a,401,a.message))}}}};e.exports.register=function(e,t,r){e.decorate("server","handlers",{managementClient:o.handlers.managementApiClient({domain:(0,u.default)("AUTH0_DOMAIN"),clientId:(0,u.default)("AUTH0_CLIENT_ID"),clientSecret:(0,u.default)("AUTH0_CLIENT_SECRET"),logger:s.default.error}),validateHookToken:d((0,u.default)("AUTH0_DOMAIN"),(0,u.default)("WT_URL"),(0,u.default)("EXTENSION_SECRET"))}),r()},e.exports.register.attributes={name:"handlers"}},function(e,t,r){"use strict";(function(t){function n(e){return e&&e.__esModule?e:{default:e}}var o=r(20),i=(n(o),r(201)),u=n(i),a=r(73),s=n(a),c=r(40),f=n(c),d=r(19),l=r(2),p=n(l),h=r(147),g=n(h),m=function(e){return{method:"GET",path:e,config:{description:"Render HTML",auth:!1},handler:function(e,r){var n={AUTH0_DOMAIN:(0,p.default)("AUTH0_DOMAIN"),AUTH0_CLIENT_ID:(0,p.default)("AUTH0_CLIENT_ID"),BASE_URL:d.urlHelpers.getBaseUrl(e),API_BASE:d.urlHelpers.getBaseUrl(e),BASE_PATH:d.urlHelpers.getBasePath(e),SEARCH_ENGINE:"auth0.auth0.com"!==(0,p.default)("AUTH0_RTA").replace("https://","")?"v2":"v3"},o=(0,p.default)("CLIENT_VERSION");return o?r(s.default.render(g.default,{config:n,assets:{version:o}})):u.default.readFile(f.default.join(t,"../../dist/manifest.json"),"utf8",function(e,t){var o={config:n,assets:{app:"/app/bundle.js"}};!e&&t&&(o.assets=JSON.parse(t),o.assets.app&&(o.assets.app="/app/"+o.assets.app),o.assets.vendors&&(o.assets.vendors="/app/"+o.assets.vendors),o.assets.style&&(o.assets.style="/app/"+o.assets.style)),r(s.default.render(g.default,o))})}}},v=["/","/api","/configuration","/configuration/rule","/configuration/api","/roles","/roles/{id}","/groups","/groups/{id}","/permissions","/permissions/{id}","/users","/users/{id}","/import-export"];e.exports.register=function(e,t,r){v.map(function(t){return e.route(m(t))}),r()},e.exports.register.attributes={name:"html"}}).call(t,"/")},function(e,t,r){"use strict";e.exports=[{register:r(140)},{register:r(139)},{register:r(141)},{register:r(142)},{register:r(145)},{register:r(144)},{register:r(146)}]},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e){return this.response(s.default.notFound(e))}function i(e){f.default.error(e);var t=e.message&&e.message.error||e.message||e.code||e.name||e.text||e.description||e;return e.message&&429===e.message.statusCode?this.response(s.default.tooManyRequests(t)):this.response(s.default.badRequest(t))}function u(e){return this.response(s.default.unauthorized(e))}var a=r(39),s=n(a),c=r(10),f=n(c);e.exports.register=function(e,t,r){e.decorate("reply","notFound",o),e.decorate("reply","error",i),e.decorate("reply","unauthorized",u),r()},e.exports.register.attributes={name:"reply-decorators"}},function(e,t,r){"use strict";var n=r(2),o=function(e){return e&&e.__esModule?e:{default:e}}(n);e.exports.register=function(e,t,n){e.route(r(119)(e)),e.route(r(75)(e)),e.route(r(76)(e)),e.route(r(80)(e)),e.route(r(79)(e)),e.route(r(81)(e)),e.route(r(86)(e)),e.route(r(84)(e)),e.route(r(83)(e)),e.route(r(78)(e)),e.route(r(82)(e)),e.route(r(85)(e)),e.route(r(77)(e)),e.route(r(88)(e)),e.route(r(89)(e)),e.route(r(90)(e)),e.route(r(114)(e)),e.route(r(115)(e)),e.route(r(116)(e)),e.route(r(117)(e)),e.route(r(118)(e)),e.route(r(121)(e)),e.route(r(122)(e)),e.route(r(123)(e)),e.route(r(124)(e)),e.route(r(125)(e)),e.route(r(108)(e)),e.route(r(109)(e)),e.route(r(110)(e)),e.route(r(111)(e)),e.route(r(112)(e)),e.route(r(104)(e)),e.route(r(106)(e)),e.route(r(105)(e)),e.route(r(107)(e)),e.route(r(101)(e)),e.route(r(102)(e)),e.route(r(103)(e)),e.route(r(92)(e)),e.route(r(91)(e)),e.route(r(93)(e)),e.route(r(97)(e)),e.route(r(98)(e)),e.route(r(99)(e)),e.route(r(100)(e)),e.route(r(113)(e)),e.route(r(133)(e)),e.route(r(134)(e)),e.route(r(126)(e)),e.route(r(127)(e)),e.route(r(128)(e)),e.route(r(130)(e)),e.route(r(131)(e)),e.route(r(129)(e)),e.route(r(132)(e)),e.route({method:"GET",path:"/admins/login",config:{auth:!1},handler:function(e,t){return t("Redirecting to login page...").redirect((0,o.default)("PUBLIC_WT_URL")+"/login")}}),n()},e.exports.register.attributes={name:"routes"}},function(e,t,r){"use strict";var n=r(51);e.exports.register=function(e,t,r){var o=(0,n.getDb)();e.decorate("server","storage",o),e.decorate("request","storage",o),r()},e.exports.register.attributes={name:"storage"}},function(e,t,r){"use strict";e.exports='\n\n\n Auth0 - Authorization\n \n \n \n \n \n \n \n \n <% if (assets.style) { %><% } %>\n <% if (assets.version) { %><% } %>\n\n\n
\n