text: module.exports=function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return e[o].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){var o=n(13);e.exports=o.fromExpress(n(7))},function(e,t){e.exports=require("boom")},function(e,t){e.exports=require("express")},function(e,t){e.exports=require("jsonwebtoken")},function(e,t){e.exports=require("request")},function(e,t){e.exports=require("superagent")},function(e,t,n){function o(e){return function(t,n,o){if(t.headers.authorization&&"Bearer"===t.headers.authorization.split(" ")[0]){var r=t.headers.authorization.split(" ")[1],a=u.verify(r,t.webtaskContext.data.EXTENSION_SECRET,{audience:p(t.webtaskContext.data.WT_URL,e),issuer:"https://"+t.webtaskContext.data.AUTH0_DOMAIN});return a?o():n.sendStatus(401)}return n.sendStatus(401)}}function r(e,t){var n="https://"+e.webtaskContext.data.AUTH0_DOMAIN+"/oauth/token",o="https://"+e.webtaskContext.data.AUTH0_DOMAIN+"/api/v2/",r=e.webtaskContext.data.AUTH0_CLIENT_ID,a=e.webtaskContext.data.AUTH0_CLIENT_SECRET;s.post(n).send({audience:o,grant_type:"client_credentials",client_id:r,client_secret:a}).type("application/json").end(function(e,n){e||!n.ok?t(null,e):t(n.body.access_token)})}var a=n(2),s=n(5),i=n(15).ManagementClient,c=n(21),u=n(3),l=a.Router(),p=n(12);e.exports=l,l.use("/on-install",o("/.extensions/on-install")),l.use("/on-uninstall",o("/.extensions/on-uninstall")),l.use("/on-update",o("/.extensions/on-update")),l.use(function(e,t,n){r(e,function(t,o){if(o)return n(o);var r=new i({domain:e.webtaskContext.data.AUTH0_DOMAIN,token:t});e.auth0=r,n()})}),l.post("/on-install",function(e,t){e.auth0.rules.create({name:"extension-rule",script:"function (user, context, callback) {\n  callback(null, user, context);\n}",order:2,enabled:!0,stage:"login_success"}).then(function(){t.sendStatus(204)})["catch"](function(){t.sendStatus(500)})}),l.put("/on-update",function(e,t){t.sendStatus(204)}),l["delete"]("/on-uninstall",function(e,t){e.auth0.rules.getAll().then(function(n){var o=c.find(n,{name:"extension-rule"});o&&e.auth0.rules["delete"]({id:o.id}).then(function(){t.sendStatus(204)})["catch"](function(){t.sendStatus(500)})})["catch"](function(){t.sendStatus(500)})})},function(e,t,n){var o=n(2),r=o(),a=n(9),s=n(11),i=n(8);r.use("/.extensions",n(6)),r.use(function(e,t,n){i({scopes:e.webtaskContext.data.AUTH0_SCOPES,clientId:e.webtaskContext.data.AUTH0_CLIENT_ID,rootTenantAuthority:"https://"+e.webtaskContext.data.AUTH0_DOMAIN})(e,t,n)}),r.get("/",function(e,t){t.header("Content-Type","text/html"),t.status(200).send(a({baseUrl:t.locals.baseUrl,domain:"https://"+e.webtaskContext.data.AUTH0_DOMAIN}))}),r.get("/meta",function(e,t){t.status(200).send(s)}),e.exports=r},function(e,t,n){function o(e){return e&&"[object Function]"==h.call(e)}function r(e){return function(t,n,o){f.get(e+"/userinfo").set("Authorization","Bearer "+t.body.access_token).end(function(e,r){return e?void n.redirect(n.locals.baseUrl):(t.userInfo=r.body,void o())})}}function a(e,t){return function(n,r,a){var s=e;o(e)&&(s=e(n)),n.apiToken=d.sign(n.userInfo,s,{algorithm:"HS256",issuer:r.locals.baseUrl,expiresIn:t}),delete n.userinfo,a()}}var s=n(2),i=n(20),c=n(18),u=n(22),l=n(14),p=n(16),d=n(3),f=n(5),h={}.toString;e.exports=function(e){var t=864e5,o=s.Router(),d=function(e,t,n){n()},f=[d];return e=e||{},e.clientName=e.clientName||"Auth0 Extension",e.clientId=e.clientId,e.exp=e.exp||t,e.credentialsRequired="undefined"==typeof e.credentialsRequired?!1:e.credentialsRequired,e.scopes=e.scopes+" openid profile",e.responseType=e.responseType||"token",e.tokenExpiresIn=e.tokenExpiresIn||"10h",e.rootTenantAuthority=e.rootTenantAuthority||"https://auth0.auth0.com",e.authenticatedCallback=e.authenticatedCallback||function(e,t,n,o){o()},e.apiToken&&!e.apiToken.secret&&(console.log('You are using a "development secret" for API token generation. Please setup your secret on "apiToken.secret".'),e.apiToken.secret=n(17).randomBytes(32).toString("hex")),e.apiToken&&e.apiToken.secret&&(f=[r(e.rootTenantAuthority),e.apiToken.payload||d,a(e.apiToken.secret,e.tokenExpiresIn)]),o.use(function(t,n,o){var r="https",a=u.parse(t.originalUrl).pathname.replace(t.path,"");"development"===(process.env.NODE_ENV||"development")&&(r=t.protocol,e.clientId=e.clientId||"N3PAwyqXomhNu6IWivtsa3drBfFjmWJL"),n.locals.baseUrl=u.format({protocol:r,host:t.get("host"),pathname:a}),o()}),o.use(p.urlencoded({extended:!1})),o.use(c({secret:l(),algorithms:["RS256"],credentialsRequired:e.credentialsRequired}).unless({path:["/login","/callback"]})),o.get("/login",function(t,n){var o=n.locals.baseUrl+"/callback";t.query.returnTo&&(o+="?returnTo="+encodeURIComponent(t.query.returnTo));var r;if("string"==typeof e.audience)r="&audience="+encodeURIComponent(e.audience);else if("function"==typeof e.audience){var a=e.audience(t);"string"==typeof a&&(r="&audience="+encodeURIComponent(a))}var s=[e.rootTenantAuthority+"/i/oauth2/authorize","?client_id="+(e.clientId||n.locals.baseUrl),"&response_type="+e.responseType,"&response_mode=form_post","&scope="+encodeURIComponent(e.scopes),"&expiration="+e.exp,"&redirect_uri="+o,r].join("");n.redirect(s)}),o.get("/logout",function(t,n){var o=["html","  head","    script.","      sessionStorage.removeItem('token')","      sessionStorage.removeItem('apiToken')","      window.location.href = '"+e.rootTenantAuthority+"/v2/logout?returnTo=#{baseUrl}';","  body"].join("\n"),r=i.compile(o)({baseUrl:n.locals.baseUrl});n.header("Content-Type","text/html"),n.status(200).send(r)}),o.post("/callback",f,function(t,n){e.authenticatedCallback(t,n,t.body.access_token,function(e){if(e)return n.sendStatus(500);var o=["html","  head","    script.","      sessionStorage.setItem('token', '"+t.body.access_token+"');",1===f.length?"":"      sessionStorage.setItem('apiToken', '"+t.apiToken+"');","      window.location.href = '#{returnTo}';","  body"].join("\n"),r=i.compile(o)({returnTo:t.query.returnTo?t.query.returnTo:n.locals.baseUrl});n.header("Content-Type","text/html"),n.status(200).send(r)})}),o.get("/.well-known/oauth2-client-configuration",function(t,n){n.header("Content-Type","application/json"),n.status(200).send({redirect_uris:[n.locals.baseUrl+"/callback"],client_name:e.clientName,post_logout_redirect_uris:[n.locals.baseUrl]})}),o}},function(e,t,n){var o=n(10);e.exports=function(e){var t,n=[],r=e||{};return function(e,r,a){n.push('<!DOCTYPE html><html><head><title>Sample Extension</title><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=Edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="description"'+o.attr("content",""+r,!0,!0)+'><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="shortcut icon" href="https://cdn.auth0.com/styleguide/2.0.1/lib/logos/img/favicon.png"><link rel="apple-touch-icon" href="apple-touch-icon.png"><link rel="stylesheet" type="text/css" href="https://cdn.auth0.com/manage/v0.3.973/css/index.min.css"><link rel="stylesheet" type="text/css" href="https://cdn.auth0.com/styleguide/latest/index.css"><script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.min.js"></script><script type="text/javascript" src="https://fb.me/react-0.14.0.min.js"></script><script type="text/javascript" src="https://fb.me/react-dom-0.14.0.js"></script><script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js"></script><script type="text/javascript" src="https://cdn.auth0.com/js/jwt-decode-1.4.0.min.js"></script><script type="text/javascript" src="https://cdn.auth0.com/js/navbar-1.0.4.min.js"></script><script type="text/javascript">if (!sessionStorage.getItem("token")) {\n  window.location.href = \''+o.escape(null==(t=e)?"":t)+'/login\';\n}\n</script></head><body class="a0-extension"><header class="dashboard-header"><nav role="navigation" class="navbar navbar-default"><div class="container"><div class="navbar-header"><h1 class="navbar-brand"><a href="http://manage.auth0.com/"><span>Auth0</span></a></h1></div><div id="navbar-collapse" class="collapse navbar-collapse"></div><script type="text/babel">ReactDOM.render(\n  <Navbar baseUrl="'+o.escape(null==(t=e)?"":t)+'" domain="'+o.escape(null==(t=a)?"":t)+'"/>,\n  document.getElementById(\'navbar-collapse\')\n);\n</script></div></nav></header><div class="container"><div class="row"><section class="content-page current"><div class="col-xs-12"><div id="my-application"><h1>Hello world!</h1></div></div></section></div></div></body></html>')}.call(this,"baseUrl"in r?r.baseUrl:"undefined"!=typeof baseUrl?baseUrl:void 0,"description"in r?r.description:"undefined"!=typeof description?description:void 0,"domain"in r?r.domain:"undefined"!=typeof domain?domain:void 0),n.join("")}},function(e,t,n){"use strict";function o(e){return null!=e&&""!==e}function r(e){return(Array.isArray(e)?e.map(r):e&&"object"==typeof e?Object.keys(e).filter(function(t){return e[t]}):[e]).filter(o).join(" ")}t.merge=function a(e,t){if(1===arguments.length){for(var n=e[0],r=1;r<e.length;r++)n=a(n,e[r]);return n}var s=e["class"],i=t["class"];(s||i)&&(s=s||[],i=i||[],Array.isArray(s)||(s=[s]),Array.isArray(i)||(i=[i]),e["class"]=s.concat(i).filter(o));for(var c in t)"class"!=c&&(e[c]=t[c]);return e},t.joinClasses=r,t.cls=function(e,n){for(var o=[],a=0;a<e.length;a++)n&&n[a]?o.push(t.escape(r([e[a]]))):o.push(r(e[a]));var s=r(o);return s.length?' class="'+s+'"':""},t.style=function(e){return e&&"object"==typeof e?Object.keys(e).map(function(t){return t+":"+e[t]}).join(";"):e},t.attr=function(e,n,o,r){return"style"===e&&(n=t.style(n)),"boolean"==typeof n||null==n?n?" "+(r?e:e+'="'+e+'"'):"":0==e.indexOf("data")&&"string"!=typeof n?(-1!==JSON.stringify(n).indexOf("&")&&console.warn("Since Jade 2.0.0, ampersands (`&`) in data attributes will be escaped to `&amp;`"),n&&"function"==typeof n.toISOString&&console.warn("Jade will eliminate the double quotes around dates in ISO form after 2.0.0")," "+e+"='"+JSON.stringify(n).replace(/'/g,"&apos;")+"'"):o?(n&&"function"==typeof n.toISOString&&console.warn("Jade will stringify dates in ISO form after 2.0.0")," "+e+'="'+t.escape(n)+'"'):(n&&"function"==typeof n.toISOString&&console.warn("Jade will stringify dates in ISO form after 2.0.0")," "+e+'="'+n+'"')},t.attrs=function(e,n){var o=[],a=Object.keys(e);if(a.length)for(var s=0;s<a.length;++s){var i=a[s],c=e[i];"class"==i?(c=r(c))&&o.push(" "+i+'="'+c+'"'):o.push(t.attr(i,c,!1,n))}return o.join("")},t.escape=function(e){var t=String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");return t===""+e?e:t},t.rethrow=function s(e,t,o,r){if(!(e instanceof Error))throw e;if(!("undefined"==typeof window&&t||r))throw e.message+=" on line "+o,e;try{r=r||n(19).readFileSync(t,"utf8")}catch(a){s(e,null,o)}var i=3,c=r.split("\n"),u=Math.max(o-i,0),l=Math.min(c.length,o+i),i=c.slice(u,l).map(function(e,t){var n=t+u+1;return(n==o?"  > ":"    ")+n+"| "+e}).join("\n");throw e.path=t,e.message=(t||"Jade")+":"+o+"\n"+i+"\n\n"+e.message,e},t.DebugItem=function(e,t){this.lineno=e,this.filename=t}},function(e,t){e.exports={title:"Sample Extension",name:"sample-extension",version:"1.0.0",author:"javier.centurion@auth0.com",description:"A Sample Extension",type:"application",keywords:["auth0"],auth0:{createClient:!0,scopes:"create:rules read:rules delete:rules",onInstallPath:"/.extensions/on-install",onUninstallPath:"/.extensions/on-uninstall",onUpdatePath:"/.extensions/on-update"}}},function(e,t,n){var o,r;!function(a,s,i){"undefined"!=typeof e&&e.exports?e.exports=i():(o=i,r="function"==typeof o?o.call(t,n,t,e):o,!(void 0!==r&&(e.exports=r)))}("urljoin",this,function(){function e(e,t){return e=e.replace(/:\//g,"://"),e=e.replace(/([^:\s])\/+/g,"$1/"),e=e.replace(/\/(\?|&|#[^!])/g,"$1"),e=e.replace(/(\?.+)\?/g,"$1&")}return function(){var t=arguments,n={};"object"==typeof arguments[0]&&(t=arguments[0],n=arguments[1]||{});var o=[].slice.call(t,0).join("/");return e(o,n)}})},function(e,t,n){function o(e){return function(t,n,o){var r=s(n.x_wt.jtn);return n.originalUrl=n.url,n.url=n.url.replace(r,"/"),n.webtaskContext=i(t),e(n,o)}}function r(e){var t;return e.ext("onRequest",function(e,n){var o=s(e.x_wt.jtn);e.setUrl(e.url.replace(o,"/")),e.webtaskContext=t}),function(n,o,r){var a=e._dispatch();t=i(n),a(o,r)}}function a(e){return function(t,n,o){var r=s(n.x_wt.jtn);return n.originalUrl=n.url,n.url=n.url.replace(r,"/"),n.webtaskContext=i(t),e.emit("request",n,o)}}function s(e){var t="^/api/run/[^/]+/",n="(?:[^/?#]*/?)?";return new RegExp(t+(e?n:""))}function i(e){function t(e,t,o){var r=n(1);"function"==typeof t&&(o=t,t={}),o(r.preconditionFailed("Storage is not available in this context"))}function o(t,o,r){var a=n(1),s=n(4);"function"==typeof o&&(r=o,o={}),s({uri:e.secrets.EXT_STORAGE_URL,method:"GET",headers:o.headers||{},qs:{path:t},json:!0},function(e,t,n){return e?r(a.wrap(e,502)):404===t.statusCode&&Object.hasOwnProperty.call(o,"defaultValue")?r(null,o.defaultValue):t.statusCode>=400?r(a.create(t.statusCode,n&&n.message)):void r(null,n)})}function r(e,t,o,r){var a=n(1);"function"==typeof o&&(r=o,o={}),r(a.preconditionFailed("Storage is not available in this context"))}function a(t,o,r,a){var s=n(1),i=n(4);"function"==typeof r&&(a=r,r={}),i({uri:e.secrets.EXT_STORAGE_URL,method:"PUT",headers:r.headers||{},qs:{path:t},body:o},function(e,t,n){return e?a(s.wrap(e,502)):t.statusCode>=400?a(s.create(t.statusCode,n&&n.message)):void a(null)})}return e.read=e.secrets.EXT_STORAGE_URL?o:t,e.write=e.secrets.EXT_STORAGE_URL?a:r,e}t.fromConnect=t.fromExpress=o,t.fromHapi=r,t.fromServer=t.fromRestify=a},function(e,t){e.exports=require("auth0-api-jwt-rsa-validation")},function(e,t){e.exports=require("auth0@2.1.0")},function(e,t){e.exports=require("body-parser")},function(e,t){e.exports=require("crypto")},function(e,t){e.exports=require("express-jwt")},function(e,t){e.exports=require("fs")},function(e,t){e.exports=require("jade")},function(e,t){e.exports=require("lodash")},function(e,t){e.exports=require("url")}]);
  