UNPKG

hurbis-ui-seguranca-v1-snapshot

Version:

Biblioteca de segurança para autenticação e autorização utilizando Auth0.

1 lines 115 kB
(function(){angular.module("angular-jwt",["angular-jwt.options","angular-jwt.interceptor","angular-jwt.jwt","angular-jwt.authManager"]);angular.module("angular-jwt.authManager",[]).provider("authManager",function(){this.$get=["$rootScope","$injector","$location","jwtHelper","jwtInterceptor","jwtOptions",function(n,t,i,r,u,f){function o(n){return Array.isArray(n)?t.invoke(n,this,{options:null}):n()}function s(n){if(Array.isArray(n)||angular.isFunction(n))return t.invoke(n,e,{});throw new Error("unauthenticatedRedirector must be a function");}function h(){var n=o(e.tokenGetter);if(n)return!r.isTokenExpired(n)}function c(){n.isAuthenticated=!0}function l(){n.isAuthenticated=!1}function a(){var t=o(e.tokenGetter);t&&(r.isTokenExpired(t)?n.$broadcast("tokenHasExpired",t):c())}function p(){if(t.has("$transitions")){var i=t.get("$transitions");i.onStart({},a)}else n.$on("$locationChangeStart",a)}function w(){n.$on("unauthenticated",function(){s(e.unauthenticatedRedirector);l()})}function b(n,t){if(!t)return!1;var i=t.$$route?t.$$route:t.data;i&&i.requiresLogin===!0&&!h()&&(n.preventDefault(),s(e.unauthenticatedRedirector))}function k(n){var t=n.to(),i=n.router.stateService;if(t&&t.data&&t.data.requiresLogin===!0&&!h())return i.target(e.loginPath)}var e=f.getConfig(),v,y;if(n.isAuthenticated=!1,t.has("$transitions")){v=t.get("$transitions");v.onStart({},k)}else y=t.has("$state")?"$stateChangeStart":"$routeChangeStart",n.$on(y,b);return{authenticate:c,unauthenticate:l,getToken:function(){return o(e.tokenGetter)},redirect:function(){return s(e.unauthenticatedRedirector)},checkAuthOnRefresh:p,redirectWhenUnauthenticated:w,isAuthenticated:h}}]});angular.module("angular-jwt.interceptor",[]).provider("jwtInterceptor",function(){this.urlParam;this.authHeader;this.authPrefix;this.whiteListedDomains;this.tokenGetter;var n=this;this.$get=["$q","$injector","$rootScope","urlUtils","jwtOptions",function(t,i,r,u,f){function o(n){var r,t,i;if(!u.isSameOrigin(n)&&!e.whiteListedDomains.length)throw new Error("As of v0.1.0, requests to domains other than the application's origin must be white listed. Use jwtOptionsProvider.config({ whiteListedDomains: [<domain>] }); to whitelist.");for(r=u.urlResolve(n).hostname.toLowerCase(),t=0;t<e.whiteListedDomains.length;t++)if(i=e.whiteListedDomains[t],i instanceof RegExp){if(r.match(i))return!0}else if(r===i.toLowerCase())return!0;return u.isSameOrigin(n)?!0:!1}var e=angular.extend({},f.getConfig(),n);return{request:function(n){if(n.skipAuthorization||!o(n.url))return n;if(e.urlParam){if(n.params=n.params||{},n.params[e.urlParam])return n}else if(n.headers=n.headers||{},n.headers[e.authHeader])return n;var r=t.when(i.invoke(e.tokenGetter,this,{options:n}));return r.then(function(t){return t&&(e.urlParam?n.params[e.urlParam]=t:n.headers[e.authHeader]=e.authPrefix+t),n})},responseError:function(n){return n.status===401&&r.$broadcast("unauthenticated",n),t.reject(n)}}}]});angular.module("angular-jwt.jwt",[]).service("jwtHelper",["$window",function(n){this.urlBase64Decode=function(t){var i=t.replace(/-/g,"+").replace(/_/g,"/");switch(i.length%4){case 0:break;case 2:i+="==";break;case 3:i+="=";break;default:throw"Illegal base64url string!";}return n.decodeURIComponent(escape(n.atob(i)))};this.decodeToken=function(n){var i=n.split("."),t;if(i.length!==3)throw new Error("JWT must have 3 parts");if(t=this.urlBase64Decode(i[1]),!t)throw new Error("Cannot decode the token");return angular.fromJson(t)};this.getTokenExpirationDate=function(n){var i=this.decodeToken(n),t;return typeof i.exp=="undefined"?null:(t=new Date(0),t.setUTCSeconds(i.exp),t)};this.isTokenExpired=function(n,t){var i=this.getTokenExpirationDate(n);return(t=t||0,i===null)?!1:!(i.valueOf()>(new Date).valueOf()+t*1e3)}}]);angular.module("angular-jwt.options",[]).provider("jwtOptions",function(){var n={};this.config=function(t){n=t};this.$get=function(){function t(){var t=this.config=angular.extend({},i,n)}var i={urlParam:null,authHeader:"Authorization",authPrefix:"Bearer ",whiteListedDomains:[],tokenGetter:function(){return null},loginPath:"/",unauthenticatedRedirectPath:"/",unauthenticatedRedirector:["$location",function(n){n.path(this.unauthenticatedRedirectPath)}]};return t.prototype.getConfig=function(){return this.config},new t}});angular.module("angular-jwt.interceptor").service("urlUtils",function(){function t(t){var i=t;return n.setAttribute("href",i),i=n.href,n.setAttribute("href",i),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}function r(n){var r=angular.isString(n)?t(n):n;return r.protocol===i.protocol&&r.host===i.host}var n=document.createElement("a"),i=t(window.location.href);return{urlResolve:t,isSameOrigin:r}})})(),function(n,t){typeof exports=="object"&&typeof module!="undefined"?t(exports):typeof define=="function"&&define.amd?define(["exports"],t):t(n.auth0={})}(this,function(n){"use strict";function a(n,t){return t={exports:{}},n(t,t.exports),t.exports}function lf(n){return null!==n&&"object"==typeof n}function r(n){if(n)return vf(n)}function vf(n){for(var t in r.prototype)n[t]=r.prototype[t];return n}function st(n){if(n)return df(n)}function df(n){for(var t in st.prototype)n[t]=st.prototype[t];return n}function vi(){this._defaults=[]}function sr(n){var t=n.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");return n[t-2]==="="?2:n[t-1]==="="?1:0}function re(n){return n.length*3/4-sr(n)}function ue(n){var t,o,s,i,f,r,e=n.length,u;for(f=sr(n),r=new ie(e*3/4-f),s=f>0?e-4:e,u=0,t=0,o=0;t<s;t+=4,o+=3)i=l[n.charCodeAt(t)]<<18|l[n.charCodeAt(t+1)]<<12|l[n.charCodeAt(t+2)]<<6|l[n.charCodeAt(t+3)],r[u++]=i>>16&255,r[u++]=i>>8&255,r[u++]=i&255;return f===2?(i=l[n.charCodeAt(t)]<<2|l[n.charCodeAt(t+1)]>>4,r[u++]=i&255):f===1&&(i=l[n.charCodeAt(t)]<<10|l[n.charCodeAt(t+1)]<<4|l[n.charCodeAt(t+2)]>>2,r[u++]=i>>8&255,r[u++]=i&255),r}function fe(n){return v[n>>18&63]+v[n>>12&63]+v[n>>6&63]+v[n&63]}function ee(n,t,i){for(var u,f=[],r=t;r<i;r+=3)u=(n[r]<<16)+(n[r+1]<<8)+n[r+2],f.push(fe(u));return f.join("")}function oe(n){for(var i,r=n.length,f=r%3,t="",e=[],o=16383,u=0,s=r-f;u<s;u+=o)e.push(ee(n,u,u+o>s?s:u+o));return f===1?(i=n[r-1],t+=v[i>>2],t+=v[i<<4&63],t+="=="):f===2&&(i=(n[r-2]<<8)+n[r-1],t+=v[i>>10],t+=v[i>>4&63],t+=v[i<<2&63],t+="="),e.push(t),e.join("")}function se(n){var t=n.length%4,i=4-t;return t===0?n:n+new Array(1+i).join("=")}function he(n){for(var i=new Array(n.length),t=0;t<n.length;t++)i[t]=n.charCodeAt(t);return i}function ce(n){for(var i="",t=0;t<n.length;t++)i+=String.fromCharCode(n[t]);return i}function le(n){return ht.fromByteArray(he(n)).replace(/\+/g,"-").replace(/\//g,"_")}function ae(n){return n=se(n).replace(/-/g,"+").replace(/_/g,"/"),ce(ht.toByteArray(n))}function lt(n){this.request=n;this.method=n.method;this.url=n.url;this.body=n._data;this.headers=n._header}function tt(n){this.request=n}function y(n){this._sendTelemetry=n._sendTelemetry===!1?n._sendTelemetry:!0;this._telemetryInfo=n._telemetryInfo||null;this._timesToRetryFailedRequests=n._timesToRetryFailedRequests;this.headers=n.headers||{}}function lr(n,t,i,r){if(i=i==="array"?"object":i,n&&typeof n[t]!==i)throw new Error(r);}function ar(n,t,i){if(typeof n!==t)throw new Error(i);}function vr(n,t,i){if(t.indexOf(n)===-1)throw new Error(i);}function ve(n,t,i){var f,u,r;if((!t.optional||n)&&ar(n,t.type,t.message),t.type==="object"&&i)for(f=Object.keys(i),u=0;u<f.length;u++)r=f[u],(!i[r].optional||n[r])&&(!i[r].condition||i[r].condition(n))&&(lr(n,r,i[r].type,i[r].message),i[r].values&&vr(n[r],i[r].values,i[r].value_message))}function ye(n){return this.supportsIsArray()?Array.isArray(n):cr.call(n)==="[object Array]"}function pe(){return Array.isArray!=null}function we(){return Object.assign?Object.assign:yr}function yr(n){var f,i,t,e,r,s,u,o;if(n===undefined||n===null)throw new TypeError("Cannot convert first argument to object");for(f=Object(n),i=1;i<arguments.length;i++)if(t=arguments[i],t!==undefined&&t!==null)for(e=Object.keys(Object(t)),r=0,s=e.length;r<s;r++)u=e[r],o=Object.getOwnPropertyDescriptor(t,u),o!==undefined&&o.enumerable&&(f[u]=t[u]);return f}function pi(n,t){return t.reduce(function(t,i){return n[i]&&(t[i]=n[i]),t},{})}function be(n,t){var i=[];for(var r in n)t.indexOf(r)===-1&&i.push(r);return i}function ke(n){var t=[];for(var i in n)t.push(n[i]);return t}function wr(){var n=ke(arguments);return n.unshift({}),pr.get().apply(undefined,n)}function de(n,t){return{base:t?pi(n,t):n,"with":function(n,t){return n=t?pi(n,t):n,wr(this.base,n)}}}function ge(n,t){return Object.keys(n).reduce(function(i,r){return t.indexOf(r)===-1&&(i[r]=n[r]),i},{})}function no(n){for(var r="",i=0,t,u=!0,f=!0;i<n.length;)t=n.charCodeAt(i),!f&&t>=65&&t<=90||!u&&t>=48&&t<=57?(r+="_",r+=n[i].toLowerCase()):r+=n[i].toLowerCase(),u=t>=48&&t<=57,f=t>=65&&t<=90,i++;return r}function to(n){var t=n.split("_");return t.reduce(function(n,t){return n+t.charAt(0).toUpperCase()+t.slice(1)},t.shift())}function br(n,t){return typeof n!="object"||i.isArray(n)||n===null?n:(t=t||[],Object.keys(n).reduce(function(i,r){var u=t.indexOf(r)===-1?no(r):r;return i[u]=br(n[r]),i},{}))}function kr(n,t){return typeof n!="object"||i.isArray(n)||n===null?n:(t=t||[],Object.keys(n).reduce(function(i,r){var u=t.indexOf(r)===-1?to(r):r;return i[u]=kr(n[r]),i},{}))}function dr(n){var t=n.match(/^(https?:)\/\/(([^:/?#]*)(?::([0-9]+))?)([/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/);return t&&{href:n,protocol:t[1],host:t[2],hostname:t[3],port:t[4],pathname:t[5],search:t[6],hash:t[7]}}function io(n){if(!n)return undefined;var t=dr(n),i=t.protocol+"//"+t.hostname;return t.port&&(i+=":"+t.port),i}function ro(n){ii().location=n}function uo(){return ii().document}function ii(){return window}function fo(){var i=ii().location,n=i.origin;return n||(n=t.getOriginFromUrl(i.href)),n}function wt(){}function at(){}function it(n){this.disableWarnings=n.disableWarnings}function bt(){this.warn=new it({});this.storage=new at;try{var n=u.getWindow().localStorage;n&&(this.storage=n)}catch(t){this.warn.warning(t);this.warn.warning("Can't use localStorage. Using CookieStorage instead.")}}function nu(n,t){return{error:n,errorDescription:t}}function eo(n){return nu("invalid_token",n)}function o(n,i){return i=i||{},i.ignoreCasing=i.ignoreCasing?i.ignoreCasing:!1,function(r,u){var f;return!r&&!u?n(rt.buildResponse("generic_error","Something went wrong")):(!r&&u.err&&(r=u.err,u=null),!r&&u.error&&(r=u,u=null),r)?(f={original:r},r.response&&r.response.statusCode&&(f.statusCode=r.response.statusCode),r.response&&r.response.statusText&&(f.statusText=r.response.statusText),r.response&&r.response.body&&(r=r.response.body),r.err&&(r=r.err),f.code=r.error||r.code||r.error_code||r.status||null,f.description=r.errorDescription||r.error_description||r.description||r.error||r.details||r.err||null,i.forceLegacyError&&(f.error=f.code,f.error_description=f.description),r.name&&(f.name=r.name),r.policy&&(f.policy=r.policy),n(f)):u.type&&(u.type==="text/html"||u.type==="text/plain")?n(null,u.text):i.ignoreCasing?n(null,u.body||u):n(null,t.toCamelCase(u.body||u))}}function oo(n,i){var r=t.getKeysNotIn(i,iu);return r.length>0&&n.warning("Following parameters are not allowed on the `/authorize` endpoint: ["+r.join(",")+"]"),i}function so(n,i){return t.pick(i,tu)}function hu(n,t){if(this.n=null,this.e=0,n!=null&&t!=null&&n.length>0&&t.length>0)this.n=new eu(n,16),this.e=parseInt(t,16);else throw new Error("Invalid key data");}function lo(n){var t,i,r;for(t in ou)if(i=ou[t],r=i.length,n.substring(0,r)===i)return{alg:t,hash:n.substring(r)};return[]}function gi(n){var t=n.length%4,i=4-t;return t===0?n:n+new Array(1+i).join("=")}function cu(n){for(var i="",t=0;t<n.length;t++)i+=String.fromCharCode(n[t]);return i}function lu(n){for(var i=new Array(n.length),t=0;t<n.length;t++)i[t]=n.charCodeAt(t);return i}function au(n){for(var t,r="",i=0;i<n.length;i++)t=n[i].toString(16),r+=t.length===2?t:"0"+t;return r}function ao(n){return ht.fromByteArray(lu(encodeURIComponent(n).replace(/%([0-9A-F]{2})/g,function(n,t){return String.fromCharCode("0x"+t)}))).replace(/\+/g,"-").replace(/\//g,"_")}function vo(n){return n=gi(n).replace(/\-/g,"+").replace(/_/g,"/"),decodeURIComponent(cu(ht.toByteArray(n)).split("").map(function(n){return"%"+("00"+n.charCodeAt(0).toString(16)).slice(-2)}).join(""))}function yo(n){return au(ht.toByteArray(gi(n)))}function po(n){var t={"+":"-","/":"_","=":""};return n.replace(/[+/=]/g,function(n){return t[n]})}function vu(n){var t=ut.decodeToHEX(n.n),i=ut.decodeToHEX(n.e);return{modulus:t,exp:i}}function wo(n,t){var i=n.jwksURI||f(n.iss,".well-known","jwks.json");return pt.get(i).end(function(i,r){var f=null,u,e;if(i)return t(i);for(u=0;u<r.body.keys.length&&f===null;u++)e=r.body.keys[u],e.kid===n.kid&&(f=e);return t(null,vu(f))})}function pu(n){this.name="ConfigurationError";this.message=n||""}function wu(n){this.name="TokenValidationError";this.message=n||""}function ui(){}function ft(n){var t=n||{};if(this.jwksCache=t.jwksCache||new bu,this.expectedAlg=t.expectedAlg||"RS256",this.issuer=t.issuer,this.audience=t.audience,this.leeway=t.leeway||0,this.__disableExpirationCheck=t.__disableExpirationCheck||!1,this.jwksURI=t.jwksURI,this.leeway<0||this.leeway>60)throw new s.ConfigurationError("The leeway should be positive and lower than a minute.");if(fi.indexOf(this.expectedAlg)===-1)throw new s.ConfigurationError("Algorithm "+this.expectedAlg+" is not supported. (Expected algs: ["+fi.join(",")+"])");}function ku(n,t){var i,r;for(this.plugins=t,i=0;i<this.plugins.length;i++){if(this.plugins[i].version!==ct.raw){r="";this.plugins[i].constructor&&this.plugins[i].constructor.name&&(r=this.plugins[i].constructor.name);throw new Error("Plugin "+r+" version ("+this.plugins[i].version+") is not compatible with the SDK version ("+ct.raw+")");}this.plugins[i].setWebAuth(n)}}function bo(n){var o=new Uint8Array(n),r=[],f="0123456789ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz-._~",e=u.getWindow().crypto||u.getWindow().msCrypto,i,t;if(!e)return null;for(i=e.getRandomValues(o),t=0;t<i.length;t++)r.push(f[i[t]%f.length]);return r.join("")}function et(n){n=n||{};this.namespace=n.namespace||ns;this.keyLength=n.keyLength||32}function vt(n){if(this.url=n.url,this.callback=n.callback,this.timeout=n.timeout||6e4,this.timeoutCallback=n.timeoutCallback||null,this.eventListenerType=n.eventListenerType||"message",this.iframe=null,this.timeoutHandle=null,this._destroyTimeout=null,this.transientMessageEventListener=null,this.proxyEventListener=null,this.eventValidator=n.eventValidator||{isValid:function(){return!0}},typeof this.callback!="function")throw new Error("options.callback must be a function");}function ts(n,t,i){var r=new vt({url:n,eventListenerType:"message",callback:function(n){i(null,n)},timeout:t.timeout,eventValidator:{isValid:function(n){return n.event.data.type==="authorization_response"&&t.state===n.event.data.response.state}},timeoutCallback:function(){i({error:"timeout",error_description:"Timeout during executing web_message communication",state:t.state})}});r.init()}function nr(n){this.webAuth=n;this.warn=new it(n.baseOptions)}function kt(n,t){this.webAuth=n;this.baseOptions=t;this.request=new y(t);this.webMessageHandler=new nr(n)}function is(n){var i=u.getWindow(),r="&"+i.location.hash.substring(1),t=r.split("&"+n+"=");if(t.length===2)return t.pop().split("&").shift()}function gu(n,t){return["co/verifier",encodeURIComponent(n),encodeURIComponent(t)].join("/")}function rs(n,t){try{var i=b.getItem(t);return b.removeItem(t),i||""}catch(r){return""}}function tr(n,t){this.webAuth=n;this.baseOptions=t;this.crossOriginAuthentication=new kt(n,this.baseOptions);this.warn=new it({disableWarnings:!!t._disableDeprecationWarnings})}function us(n){/^https?:\/\//.test(n)||(n=window.location.href);var t=/^(https?:\/\/[-_a-zA-Z.0-9:]+)/.exec(n);return t?t[1]:n}function oi(){this._current_popup=null}function w(n,t){this.baseOptions=t;this.baseOptions.popupOrigin=t.popupOrigin;this.client=n.client;this.webAuth=n;this.transactionManager=new et(this.baseOptions.transaction);this.crossOriginAuthentication=new kt(n,this.baseOptions);this.warn=new it({disableWarnings:!!t._disableDeprecationWarnings})}function yt(n){this.authenticationUrl=n.authenticationUrl;this.timeout=n.timeout||6e4;this.handler=null;this.postMessageDataType=n.postMessageDataType||!1;this.postMessageOrigin=n.postMessageOrigin||u.getWindow().location.origin||u.getWindow().location.protocol+"//"+u.getWindow().location.hostname+(u.getWindow().location.port?":"+u.getWindow().location.port:"")}function rr(n){this.baseOptions=n;this.request=new y(n);this.transactionManager=new et(this.baseOptions.transaction)}function si(n,t){this.baseOptions=t;this.client=n;this.request=new y(this.baseOptions);this.warn=new it({disableWarnings:!!t._disableDeprecationWarnings})}function e(n){i.check(n,{type:"object",message:"options parameter is not valid"},{domain:{type:"string",message:"domain option is required"},clientID:{type:"string",message:"clientID option is required"},responseType:{optional:!0,type:"string",message:"responseType is not valid"},responseMode:{optional:!0,type:"string",message:"responseMode is not valid"},redirectUri:{optional:!0,type:"string",message:"redirectUri is not valid"},scope:{optional:!0,type:"string",message:"scope is not valid"},audience:{optional:!0,type:"string",message:"audience is not valid"},popupOrigin:{optional:!0,type:"string",message:"popupOrigin is not valid"},leeway:{optional:!0,type:"number",message:"leeway is not valid"},plugins:{optional:!0,type:"array",message:"plugins is not valid"},_disableDeprecationWarnings:{optional:!0,type:"boolean",message:"_disableDeprecationWarnings option is not valid"},_sendTelemetry:{optional:!0,type:"boolean",message:"_sendTelemetry option is not valid"},_telemetryInfo:{optional:!0,type:"object",message:"_telemetryInfo option is not valid"},_timesToRetryFailedRequests:{optional:!0,type:"number",message:"_timesToRetryFailedRequests option is not valid"}});n.overrides&&i.check(n.overrides,{type:"object",message:"overrides option is not valid"},{__tenant:{optional:!0,type:"string",message:"__tenant option is required"},__token_issuer:{optional:!0,type:"string",message:"__token_issuer option is required"},__jwks_uri:{optional:!0,type:"string",message:"__jwks_uri is required"}});this.baseOptions=n;this.baseOptions.plugins=new ku(this,this.baseOptions.plugins||[]);this.baseOptions._sendTelemetry=this.baseOptions._sendTelemetry===!1?this.baseOptions._sendTelemetry:!0;this.baseOptions._timesToRetryFailedRequests=n._timesToRetryFailedRequests?parseInt(n._timesToRetryFailedRequests,0):0;this.baseOptions.tenant=this.baseOptions.overrides&&this.baseOptions.overrides.__tenant||this.baseOptions.domain.split(".")[0];this.baseOptions.token_issuer=this.baseOptions.overrides&&this.baseOptions.overrides.__token_issuer||"https://"+this.baseOptions.domain+"/";this.baseOptions.jwksURI=this.baseOptions.overrides&&this.baseOptions.overrides.__jwks_uri;this.transactionManager=new et(this.baseOptions.transaction);this.client=new c(this.baseOptions);this.redirect=new tr(this,this.baseOptions);this.popup=new w(this,this.baseOptions);this.crossOriginAuthentication=new kt(this,this.baseOptions);this.webMessageHandler=new nr(this);this._universalLogin=new si(this,this.baseOptions)}function fs(n,t,i){return{accessToken:n.access_token||null,idToken:n.id_token||null,idTokenPayload:i||null,appState:t||null,refreshToken:n.refresh_token||null,state:n.state||null,expiresIn:n.expires_in?parseInt(n.expires_in,10):null,tokenType:n.token_type||null,scope:n.scope||null}}function hi(n,t){this.baseOptions=t;this.request=n}function ur(n,t){this.baseOptions=t;this.request=n}function c(n,t){arguments.length===2?this.auth0=n:t=n;i.check(t,{type:"object",message:"options parameter is not valid"},{domain:{type:"string",message:"domain option is required"},clientID:{type:"string",message:"clientID option is required"},responseType:{optional:!0,type:"string",message:"responseType is not valid"},responseMode:{optional:!0,type:"string",message:"responseMode is not valid"},redirectUri:{optional:!0,type:"string",message:"redirectUri is not valid"},scope:{optional:!0,type:"string",message:"scope is not valid"},audience:{optional:!0,type:"string",message:"audience is not valid"},_disableDeprecationWarnings:{optional:!0,type:"boolean",message:"_disableDeprecationWarnings option is not valid"},_sendTelemetry:{optional:!0,type:"boolean",message:"_sendTelemetry option is not valid"},_telemetryInfo:{optional:!0,type:"object",message:"_telemetryInfo option is not valid"}});this.baseOptions=t;this.baseOptions._sendTelemetry=this.baseOptions._sendTelemetry===!1?this.baseOptions._sendTelemetry:!0;this.baseOptions.rootUrl="https://"+this.baseOptions.domain;this.request=new y(this.baseOptions);this.passwordless=new hi(this.request,this.baseOptions);this.dbConnection=new ur(this.request,this.baseOptions);this.warn=new it({disableWarnings:!!t._disableDeprecationWarnings})}function dt(n){i.check(n,{type:"object",message:"options parameter is not valid"},{domain:{type:"string",message:"domain option is required"},token:{type:"string",message:"token option is required"},_sendTelemetry:{optional:!0,type:"boolean",message:"_sendTelemetry option is not valid"},_telemetryInfo:{optional:!0,type:"object",message:"_telemetryInfo option is not valid"}});this.baseOptions=n;this.baseOptions.headers={Authorization:"Bearer "+this.baseOptions.token};this.request=new y(this.baseOptions);this.baseOptions.rootUrl=f("https://"+this.baseOptions.domain,"api","v2")}var k=typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},f=a(function(n){(function(t,i,r){n.exports?n.exports=r():typeof undefined=="function"&&undefined.amd?undefined(r):i[t]=r()})("urljoin",k,function(){function n(n){return n=n.replace(/:\//g,"://"),n=n.replace(/([^:\s])\/+/g,"$1/"),n=n.replace(/\/(\?|&|#[^!])/g,"$1"),n.replace(/(\?.+)\?/g,"$1&")}return function(){var t=arguments,i={},r;return typeof arguments[0]=="object"&&(t=arguments[0],i=arguments[1]||{}),r=[].slice.call(t,0).join("/"),n(r,i)}})}),h=a(function(n,t){var r=Object.prototype.hasOwnProperty,i=function(){for(var t=[],n=0;n<256;++n)t.push("%"+((n<16?"0":"")+n.toString(16)).toUpperCase());return t}();t.arrayToObject=function(n,t){for(var r=t&&t.plainObjects?Object.create(null):{},i=0;i<n.length;++i)typeof n[i]!="undefined"&&(r[i]=n[i]);return r};t.merge=function(n,i,u){if(!i)return n;if(typeof i!="object"){if(Array.isArray(n))n.push(i);else if(typeof n=="object")(u.plainObjects||u.allowPrototypes||!r.call(Object.prototype,i))&&(n[i]=!0);else return[n,i];return n}if(typeof n!="object")return[n].concat(i);var f=n;return(Array.isArray(n)&&!Array.isArray(i)&&(f=t.arrayToObject(n,u)),Array.isArray(n)&&Array.isArray(i))?(i.forEach(function(i,f){r.call(n,f)?n[f]&&typeof n[f]=="object"?n[f]=t.merge(n[f],i,u):n.push(i):n[f]=i}),n):Object.keys(i).reduce(function(n,r){var f=i[r];return n[r]=Object.prototype.hasOwnProperty.call(n,r)?t.merge(n[r],f,u):f,n},f)};t.decode=function(n){try{return decodeURIComponent(n.replace(/\+/g," "))}catch(t){return n}};t.encode=function(n){var f,r,u,t;if(n.length===0)return n;for(f=typeof n=="string"?n:String(n),r="",u=0;u<f.length;++u){if(t=f.charCodeAt(u),t===45||t===46||t===95||t===126||t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122){r+=f.charAt(u);continue}if(t<128){r=r+i[t];continue}if(t<2048){r=r+(i[192|t>>6]+i[128|t&63]);continue}if(t<55296||t>=57344){r=r+(i[224|t>>12]+i[128|t>>6&63]+i[128|t&63]);continue}u+=1;t=65536+((t&1023)<<10|f.charCodeAt(u)&1023);r+=i[240|t>>18]+i[128|t>>12&63]+i[128|t>>6&63]+i[128|t&63]}return r};t.compact=function(n,i){var u,e,f,r,o;if(typeof n!="object"||n===null)return n;if(u=i||[],e=u.indexOf(n),e!==-1)return u[e];if(u.push(n),Array.isArray(n)){for(f=[],r=0;r<n.length;++r)n[r]&&typeof n[r]=="object"?f.push(t.compact(n[r],u)):typeof n[r]!="undefined"&&f.push(n[r]);return f}return o=Object.keys(n),o.forEach(function(i){n[i]=t.compact(n[i],u)}),n};t.isRegExp=function(n){return Object.prototype.toString.call(n)==="[object RegExp]"};t.isBuffer=function(n){return n===null||typeof n=="undefined"?!1:!!(n.constructor&&n.constructor.isBuffer&&n.constructor.isBuffer(n))}}),es=h.arrayToObject,os=h.merge,ss=h.decode,hs=h.encode,cs=h.compact,ls=h.isRegExp,as=h.isBuffer,rf=String.prototype.replace,uf=/%20/g,gt={"default":"RFC3986",formatters:{RFC1738:function(n){return rf.call(n,uf,"+")},RFC3986:function(n){return n}},RFC1738:"RFC1738",RFC3986:"RFC3986"},fr={brackets:function(n){return n+"[]"},indices:function(n,t){return n+"["+t+"]"},repeat:function(n){return n}},ff=Date.prototype.toISOString,d={delimiter:"&",encode:!0,encoder:h.encode,encodeValuesOnly:!1,serializeDate:function(n){return ff.call(n)},skipNulls:!1,strictNullHandling:!1},ci=function ci(n,t,i,r,u,f,e,o,s,c,l,a){var v=n,d,p,w,k,b,y;if(typeof e=="function")v=e(t,v);else if(v instanceof Date)v=c(v);else if(v===null){if(r)return f&&!a?f(t):t;v=""}if(typeof v=="string"||typeof v=="number"||typeof v=="boolean"||h.isBuffer(v))return f?(d=a?t:f(t),[l(d)+"="+l(f(v))]):[l(t)+"="+l(String(v))];if(p=[],typeof v=="undefined")return p;for(Array.isArray(e)?w=e:(k=Object.keys(v),w=o?k.sort(o):k),b=0;b<w.length;++b)(y=w[b],u&&v[y]===null)||(p=Array.isArray(v)?p.concat(ci(v[y],i(t,y),i,r,u,f,e,o,s,c,l,a)):p.concat(ci(v[y],t+(s?"."+y:"["+y+"]"),i,r,u,f,e,o,s,c,l,a)));return p},ef=function(n,t){var r=n,i=t||{},l,u,f,e,a,v,o,s;if(i.encoder!==null&&i.encoder!==undefined&&typeof i.encoder!="function")throw new TypeError("Encoder has to be a function.");var y=typeof i.delimiter=="undefined"?d.delimiter:i.delimiter,p=typeof i.strictNullHandling=="boolean"?i.strictNullHandling:d.strictNullHandling,c=typeof i.skipNulls=="boolean"?i.skipNulls:d.skipNulls,w=typeof i.encode=="boolean"?i.encode:d.encode,b=typeof i.encoder=="function"?i.encoder:d.encoder,h=typeof i.sort=="function"?i.sort:null,k=typeof i.allowDots=="undefined"?!1:i.allowDots,g=typeof i.serializeDate=="function"?i.serializeDate:d.serializeDate,nt=typeof i.encodeValuesOnly=="boolean"?i.encodeValuesOnly:d.encodeValuesOnly;if(typeof i.format=="undefined")i.format=gt.default;else if(!Object.prototype.hasOwnProperty.call(gt.formatters,i.format))throw new TypeError("Unknown format option provided.");if(l=gt.formatters[i.format],typeof i.filter=="function"?(f=i.filter,r=f("",r)):Array.isArray(i.filter)&&(f=i.filter,u=f),e=[],typeof r!="object"||r===null)return"";for(a=(i.arrayFormat in fr)?i.arrayFormat:("indices"in i)?i.indices?"indices":"repeat":"indices",v=fr[a],u||(u=Object.keys(r)),h&&u.sort(h),o=0;o<u.length;++o)(s=u[o],c&&r[s]===null)||(e=e.concat(ci(r[s],s,v,p,c,w?b:null,f,h,k,g,l,nt)));return e.join(y)},li=Object.prototype.hasOwnProperty,p={allowDots:!1,allowPrototypes:!1,arrayLimit:20,decoder:h.decode,delimiter:"&",depth:5,parameterLimit:1e3,plainObjects:!1,strictNullHandling:!1},of=function(n,t){for(var i,f,r,e,u={},s=n.split(t.delimiter,t.parameterLimit===Infinity?undefined:t.parameterLimit),o=0;o<s.length;++o)i=s[o],f=i.indexOf("]=")===-1?i.indexOf("="):i.indexOf("]=")+1,f===-1?(r=t.decoder(i),e=t.strictNullHandling?null:""):(r=t.decoder(i.slice(0,f)),e=t.decoder(i.slice(f+1))),u[r]=li.call(u,r)?[].concat(u[r]).concat(e):e;return u},ni=function(n,t,i){var r,u,e,f;return n.length?(r=n.shift(),r==="[]"?(u=[],u=u.concat(ni(n,t,i))):(u=i.plainObjects?Object.create(null):{},e=r.charAt(0)==="["&&r.charAt(r.length-1)==="]"?r.slice(1,-1):r,f=parseInt(e,10),!isNaN(f)&&r!==e&&String(f)===e&&f>=0&&i.parseArrays&&f<=i.arrayLimit?(u=[],u[f]=ni(n,t,i)):u[e]=ni(n,t,i)),u):t},sf=function(n,t,i){var o;if(n){var u=i.allowDots?n.replace(/\.([^.[]+)/g,"[$1]"):n,s=/(\[[^[\]]*])/g,r=/(\[[^[\]]*])/.exec(u),e=r?u.slice(0,r.index):u,f=[];if(e){if(!i.plainObjects&&li.call(Object.prototype,e)&&!i.allowPrototypes)return;f.push(e)}for(o=0;(r=s.exec(u))!==null&&o<i.depth;){if(o+=1,!i.plainObjects&&li.call(Object.prototype,r[1].slice(1,-1))&&!i.allowPrototypes)return;f.push(r[1])}return r&&f.push("["+u.slice(r.index)+"]"),ni(f,t,i)}},hf=function(n,t){var i=t||{},r,f,s;if(i.decoder!==null&&i.decoder!==undefined&&typeof i.decoder!="function")throw new TypeError("Decoder has to be a function.");if(i.delimiter=typeof i.delimiter=="string"||h.isRegExp(i.delimiter)?i.delimiter:p.delimiter,i.depth=typeof i.depth=="number"?i.depth:p.depth,i.arrayLimit=typeof i.arrayLimit=="number"?i.arrayLimit:p.arrayLimit,i.parseArrays=i.parseArrays!==!1,i.decoder=typeof i.decoder=="function"?i.decoder:p.decoder,i.allowDots=typeof i.allowDots=="boolean"?i.allowDots:p.allowDots,i.plainObjects=typeof i.plainObjects=="boolean"?i.plainObjects:p.plainObjects,i.allowPrototypes=typeof i.allowPrototypes=="boolean"?i.allowPrototypes:p.allowPrototypes,i.parameterLimit=typeof i.parameterLimit=="number"?i.parameterLimit:p.parameterLimit,i.strictNullHandling=typeof i.strictNullHandling=="boolean"?i.strictNullHandling:p.strictNullHandling,n===""||n===null||typeof n=="undefined")return i.plainObjects?Object.create(null):{};var e=typeof n=="string"?of(n,i):n,u=i.plainObjects?Object.create(null):{},o=Object.keys(e);for(r=0;r<o.length;++r)f=o[r],s=sf(f,e[f],i),u=h.merge(u,s,i);return h.compact(u)},g={formats:gt,parse:hf,stringify:ef},cf=a(function(n){function t(n){if(n)return i(n)}function i(n){for(var i in t.prototype)n[i]=t.prototype[i];return n}n.exports=t;t.prototype.on=t.prototype.addEventListener=function(n,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(t),this};t.prototype.once=function(n,t){function i(){this.off(n,i);t.apply(this,arguments)}i.fn=t;this.on(n,i);return this};t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(n,t){var i,u,r;if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;if(i=this._callbacks["$"+n],!i)return this;if(1==arguments.length)return delete this._callbacks["$"+n],this;for(r=0;r<i.length;r++)if(u=i[r],u===t||u.fn===t){i.splice(r,1);break}return this};t.prototype.emit=function(n){var r,t,i,u;if(this._callbacks=this._callbacks||{},r=[].slice.call(arguments,1),t=this._callbacks["$"+n],t)for(t=t.slice(0),i=0,u=t.length;i<u;++i)t[i].apply(this,r);return this};t.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};t.prototype.hasListeners=function(n){return!!this.listeners(n).length}}),ot=lf,af=r,er,nt,or,ht,hr,ct,cr,i,pr,t,u,ri,rt,tu,iu,di,ut,yu,s,bu,fi,ei,ir,nf,tf;r.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,this};r.prototype.parse=function(n){return this._parser=n,this};r.prototype.responseType=function(n){return this._responseType=n,this};r.prototype.serialize=function(n){return this._serializer=n,this};r.prototype.timeout=function(n){if(!n||"object"!=typeof n)return this._timeout=n,this._responseTimeout=0,this;for(var t in n)switch(t){case"deadline":this._timeout=n.deadline;break;case"response":this._responseTimeout=n.response;break;default:console.warn("Unknown timeout option",t)}return this};r.prototype.retry=function(n,t){return(arguments.length===0||n===!0)&&(n=1),n<=0&&(n=0),this._maxRetries=n,this._retries=0,this._retryCallback=t,this};er=["ECONNRESET","ETIMEDOUT","EADDRINFO","ESOCKETTIMEDOUT"];r.prototype._shouldRetry=function(n,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var i=this._retryCallback(n,t);if(i===!0)return!0;if(i===!1)return!1}catch(r){console.error(r)}return t&&t.status&&t.status>=500&&t.status!=501?!0:n&&(n.code&&~er.indexOf(n.code)||n.timeout&&n.code=="ECONNABORTED"||n.crossDomain)?!0:!1};r.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this._end()};r.prototype.then=function(n,t){if(!this._fullfilledPromise){var i=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises");this._fullfilledPromise=new Promise(function(n,t){i.end(function(i,r){i?t(i):n(r)})})}return this._fullfilledPromise.then(n,t)};r.prototype.catch=function(n){return this.then(undefined,n)};r.prototype.use=function(n){return n(this),this};r.prototype.ok=function(n){if("function"!=typeof n)throw Error("Callback required");return this._okCallback=n,this};r.prototype._isResponseOK=function(n){return n?this._okCallback?this._okCallback(n):n.status>=200&&n.status<300:!1};r.prototype.get=function(n){return this._header[n.toLowerCase()]};r.prototype.getHeader=r.prototype.get;r.prototype.set=function(n,t){if(ot(n)){for(var i in n)this.set(i,n[i]);return this}return this._header[n.toLowerCase()]=t,this.header[n]=t,this};r.prototype.unset=function(n){return delete this._header[n.toLowerCase()],delete this.header[n],this};r.prototype.field=function(n,t){var i,r;if(null===n||undefined===n)throw new Error(".field(name, val) name can not be empty");if(this._data&&console.error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()"),ot(n)){for(i in n)this.field(i,n[i]);return this}if(Array.isArray(t)){for(r in t)this.field(n,t[r]);return this}if(null===t||undefined===t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=""+t),this._getFormData().append(n,t),this};r.prototype.abort=function(){return this._aborted?this:(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort"),this)};r.prototype._auth=function(n,t,i,r){switch(i.type){case"basic":this.set("Authorization","Basic "+r(n+":"+t));break;case"auto":this.username=n;this.password=t;break;case"bearer":this.set("Authorization","Bearer "+n)}return this};r.prototype.withCredentials=function(n){return n==undefined&&(n=!0),this._withCredentials=n,this};r.prototype.redirects=function(n){return this._maxRedirects=n,this};r.prototype.maxResponseSize=function(n){if("number"!=typeof n)throw TypeError("Invalid argument");return this._maxResponseSize=n,this};r.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}};r.prototype.send=function(n){var i=ot(n),t=this._header["content-type"],r;if(this._formData&&console.error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()"),i&&!this._data)Array.isArray(n)?this._data=[]:this._isHost(n)||(this._data={});else if(n&&this._data&&this._isHost(this._data))throw Error("Can't merge these send calls");if(i&&ot(this._data))for(r in n)this._data[r]=n[r];else"string"==typeof n?(t||this.type("form"),t=this._header["content-type"],this._data="application/x-www-form-urlencoded"==t?this._data?this._data+"&"+n:n:(this._data||"")+n):this._data=n;return!i||this._isHost(n)?this:(t||this.type("json"),this)};r.prototype.sortQuery=function(n){return this._sort=typeof n=="undefined"?!0:n,this};r.prototype._finalizeQueryString=function(){var i=this._query.join("&"),n,t;i&&(this.url+=(this.url.indexOf("?")>=0?"&":"?")+i);this._query.length=0;this._sort&&(n=this.url.indexOf("?"),n>=0&&(t=this.url.substring(n+1).split("&"),"function"==typeof this._sort?t.sort(this._sort):t.sort(),this.url=this.url.substring(0,n)+"?"+t.join("&")))};r.prototype._appendQueryString=function(){console.trace("Unsupported")};r.prototype._timeoutError=function(n,t,i){if(!this._aborted){var r=new Error(n+t+"ms exceeded");r.timeout=t;r.code="ECONNABORTED";r.errno=i;this.timedout=!0;this.abort();this.callback(r)}};r.prototype._setTimeouts=function(){var n=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){n._timeoutError("Timeout of ",n._timeout,"ETIME")},this._timeout));this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){n._timeoutError("Response timeout of ",n._responseTimeout,"ETIMEDOUT")},this._responseTimeout))};var yf=function(n){return n.split(/ *; */).shift()},pf=function(n){return n.split(/ *; */).reduce(function(n,t){var i=t.split(/ *= */),r=i.shift(),u=i.shift();return r&&u&&(n[r]=u),n},{})},wf=function(n){return n.split(/ *, */).reduce(function(n,t){var i=t.split(/ *; */),r=i[0].slice(1,-1),u=i[1].split(/ *= */)[1].slice(1,-1);return n[u]=r,n},{})},bf=function(n,t){return delete n["content-type"],delete n["content-length"],delete n["transfer-encoding"],delete n.host,t&&(delete n.authorization,delete n.cookie),n},ai={type:yf,params:pf,parseLinks:wf,cleanHeader:bf},kf=st;st.prototype.get=function(n){return this.header[n.toLowerCase()]};st.prototype._setHeaderProperties=function(n){var r=n["content-type"]||"",t,i;this.type=ai.type(r);t=ai.params(r);for(i in t)this[i]=t[i];this.links={};try{n.link&&(this.links=ai.parseLinks(n.link))}catch(u){}};st.prototype._setStatusProperties=function(n){var t=n/100|0;this.status=this.statusCode=n;this.statusType=t;this.info=1==t;this.ok=2==t;this.redirect=3==t;this.clientError=4==t;this.serverError=5==t;this.error=4==t||5==t?this.toError():!1;this.accepted=202==n;this.noContent=204==n;this.badRequest=400==n;this.unauthorized=401==n;this.notAcceptable=406==n;this.forbidden=403==n;this.notFound=404==n};["use","on","once","set","query","type","accept","auth","withCredentials","sortQuery","retry","ok","redirects","timeout","buffer","serialize","parse","ca","key","pfx","cert"].forEach(function(n){vi.prototype[n]=function(){return this._defaults.push({fn:n,arguments:arguments}),this}});vi.prototype._setDefaults=function(n){this._defaults.forEach(function(t){n[t.fn].apply(n,t.arguments)})};var ti=vi,pt=a(function(n,t){function a(){}function e(n){var t,i;if(!ot(n))return n;t=[];for(i in n)o(t,i,n[i]);return t.join("&")}function o(n,t,i){if(i!=null)if(Array.isArray(i))i.forEach(function(i){o(n,t,i)});else if(ot(i))for(var r in i)o(n,t+"["+r+"]",i[r]);else n.push(encodeURIComponent(t)+"="+encodeURIComponent(i));else i===null&&n.push(encodeURIComponent(t))}function h(n){for(var r={},f=n.split("&"),t,i,u=0,e=f.length;u<e;++u)t=f[u],i=t.indexOf("="),i==-1?r[decodeURIComponent(t)]="":r[decodeURIComponent(t.slice(0,i))]=decodeURIComponent(t.slice(i+1));return r}function v(n){for(var u=n.split(/\r?\n/),f={},t,i,e,o,r=0,h=u.length;r<h;++r)(i=u[r],t=i.indexOf(":"),t!==-1)&&(e=i.slice(0,t).toLowerCase(),o=s(i.slice(t+1)),f[e]=o);return f}function c(n){return/[\/+]json($|[^-\w])/.test(n)}function f(n){this.req=n;this.xhr=this.req.xhr;this.text=this.req.method!="HEAD"&&(this.xhr.responseType===""||this.xhr.responseType==="text")||typeof this.xhr.responseType=="undefined"?this.xhr.responseText:null;this.statusText=this.req.xhr.statusText;var t=this.xhr.status;t===1223&&(t=204);this._setStatusProperties(t);this.header=this.headers=v(this.xhr.getAllResponseHeaders());this.header["content-type"]=this.xhr.getResponseHeader("content-type");this._setHeaderProperties(this.header);this.body=null===this.text&&n._responseType?this.xhr.response:this.req.method!="HEAD"?this._parseBody(this.text?this.text:this.xhr.response):null}function r(n,t){var i=this;this._query=this._query||[];this.method=n;this.url=t;this.header={};this._header={};this.on("end",function(){var n=null,t=null,r;try{t=new f(i)}catch(u){return n=new Error("Parser is unable to parse the response"),n.parse=!0,n.original=u,i.xhr?(n.rawResponse=typeof i.xhr.responseType=="undefined"?i.xhr.responseText:i.xhr.response,n.status=i.xhr.status?i.xhr.status:null,n.statusCode=n.status):(n.rawResponse=null,n.status=null),i.callback(n)}i.emit("response",t);try{i._isResponseOK(t)||(r=new Error(t.statusText||"Unsuccessful HTTP response"))}catch(e){r=e}r?(r.original=n,r.response=t,r.status=t.status,i.callback(r,t)):i.callback(null,t)})}function l(n,t,r){var u=i("DELETE",n);return"function"==typeof t&&(r=t,t=null),t&&u.send(t),r&&u.end(r),u}var u,i,s;typeof window!="undefined"?u=window:typeof self!="undefined"?u=self:(console.warn("Using browser-only version of superagent in non-browser environment"),u=k);i=t=n.exports=function(n,i){return"function"==typeof i?new t.Request("GET",n).end(i):1==arguments.length?new t.Request("GET",n):new t.Request(n,i)};t.Request=r;i.getXHR=function(){if(!u.XMLHttpRequest||u.location&&"file:"==u.location.protocol&&u.ActiveXObject){try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(n){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(n){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(n){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(n){}}else return new XMLHttpRequest;throw Error("Browser-only version of superagent could not find XHR");};s="".trim?function(n){return n.trim()}:function(n){return n.replace(/(^\s*|\s*$)/g,"")};i.serializeObject=e;i.parseString=h;i.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"};i.serialize={"application/x-www-form-urlencoded":e,"application/json":JSON.stringify};i.parse={"application/x-www-form-urlencoded":h,"application/json":JSON.parse};kf(f.prototype);f.prototype._parseBody=function(n){var t=i.parse[this.type];return this.req._parser?this.req._parser(this,n):(!t&&c(this.type)&&(t=i.parse["application/json"]),t&&n&&(n.length||n instanceof Object)?t(n):null)};f.prototype.toError=function(){var t=this.req,i=t.method,r=t.url,u="cannot "+i+" "+r+" ("+this.status+")",n=new Error(u);return n.status=this.status,n.method=i,n.url=r,n};i.Response=f;cf(r.prototype);af(r.prototype);r.prototype.type=function(n){return this.set("Content-Type",i.types[n]||n),this};r.prototype.accept=function(n){return this.set("Accept",i.types[n]||n),this};r.prototype.auth=function(n,t,i){1===arguments.length&&(t="");typeof t=="object"&&t!==null&&(i=t,t="");i||(i={type:"function"==typeof btoa?"basic":"auto"});var r=function(n){if("function"==typeof btoa)return btoa(n);throw new Error("Cannot use basic auth, btoa is not a function");};return this._auth(n,t,i,r)};r.prototype.query=function(n){return"string"!=typeof n&&(n=e(n)),n&&this._query.push(n),this};r.prototype.attach=function(n,t,i){if(t){if(this._data)throw Error("superagent can't mix .send() and .attach()");this._getFormData().append(n,t,i||t.name)}return this};r.prototype._getFormData=function(){return this._formData||(this._formData=new u.FormData),this._formData};r.prototype.callback=function(n,t){if(this._shouldRetry(n,t))return this._retry();var i=this._callback;this.clearTimeout();n&&(this._maxRetries&&(n.retries=this._retries-1),this.emit("error",n));i(n,t)};r.prototype.crossDomainError=function(){var n=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");n.crossDomain=!0;n.status=this.status;n.method=this.method;n.url=this.url;this.callback(n)};r.prototype.buffer=r.prototype.ca=r.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this};r.prototype.pipe=r.prototype.write=function(){throw Error("Streaming is not supported in browser version of superagent");};r.prototype._isHost=function(n){return n&&"object"==typeof n&&!Array.isArray(n)&&Object.prototype.toString.call(n)!=="[object Object]"};r.prototype.end=function(n){return this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=n||a,this._finalizeQueryString(),this._end()};r.prototype._end=function(){var t=this,n=this.xhr=i.getXHR(),r=this._formData||this._data,o,e,u,f;if(this._setTimeouts(),n.onreadystatechange=function(){var r=n.readyState,i;if(r>=2&&t._responseTimeoutTimer&&clearTimeout(t._responseTimeoutTimer),4==r){try{i=n.status}catch(u){i=0}if(!i)return t.timedout||t._aborted?void 0:t.crossDomainError();t.emit("end")}},o=function(n,i){i.total>0&&(i.percent=i.loaded/i.total*100);i.direction=n;t.emit("progress",i)},this.hasListeners("progress"))try{n.onprogress=o.bind(null,"download");n.upload&&(n.upload.onprogress=o.bind(null,"upload"))}catch(h){}try{this.username&&this.password?n.open(this.method,this.url,!0,this.username,this.password):n.open(this.method,this.url,!0)}catch(s){return this.callback(s)}this._withCredentials&&(n.withCredentials=!0);this._formData||"GET"==this.method||"HEAD"==this.method||"string"==typeof r||this._isHost(r)||(e=this._header["content-type"],u=this._serializer||i.serialize[e?e.split(";")[0]:""],!u&&c(e)&&(u=i.serialize["application/json"]),u&&(r=u(r)));for(f in this.header)null!=this.header[f]&&this.header.hasOwnProperty(f)&&n.setRequestHeader(f,this.header[f]);return this._responseType&&(n.responseType=this._responseType),this.emit("request",this),n.send(typeof r!="undefined"?r:null),this};i.agent=function(){return new ti};["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach(function(n){ti.prototype[n.toLowerCase()]=function(t,r){var u=new i.Request(n,t);return this._setDefaults(u),r&&u.end(r),u}});ti.prototype.del=ti.prototype["delete"];i.get=function(n,t,r){var u=i("GET",n);return"function"==typeof t&&(r=t,t=null),t&&u.query(t),r&&u.end(r),u};i.head=function(n,t,r){var u=i("HEAD",n);return"function"==typeof t&&(r=t,t=null),t&&u.query(t),r&&u.end(r),u};i.options=function(n,t,r){var u=i("OPTIONS",n);return"function"==typeof t&&(r=t,t=null),t&&u.send(t),r&&u.end(r),u};i.del=l;i["delete"]=l;i.patch=function(n,t,r){var u=i("PATCH",n);return"function"==typeof t&&(r=t,t=null),t&&u.send(t),r&&u.end(r),u};i.post=function(n,t,r){var u=i("POST",n);return"function"==typeof t&&(r=t,t=null),t&&u.send(t),r&&u.end(r),u};i.put=function(n,t,r){var u=i("PUT",n);return"function"==typeof t&&(r=t,t=null),t&&u.send(t),r&&u.end(r),u}}),fh=pt.Request,gf=re,ne=ue,te=oe,v=[],l=[],ie=typeof Uint8Array!="undefined"?Uint8Array:Array,yi="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(nt=0,or=yi.length;nt<or;++nt)v[nt]=yi[nt],l[yi.charCodeAt(nt)]=nt;l["-".charCodeAt(0)]=62;l["_".charCodeAt(0)]=63;ht={byteLength:gf,toByteArray:ne,fromByteArray:te};hr={encode:le,decode:ae};ct={raw:"9.7.3"};lt.prototype.abort=function(){this.request.abort()};lt.prototype.getMethod=function(){return this.method};lt.prototype.getBody=function(){return this.body};lt.prototype.getUrl=function(){return this.url};lt.prototype.getHeaders=function(){return this.headers};tt.prototype.set=function(n,t){return this.request=this.request.set(n,t),this};tt.prototype.send=function(n){return this.request=this.request.send(n),this};tt.prototype.withCredentials=function(){return this.request=this.request.withCredentials(),this};tt.prototype.end=function(n){return this.request=this.request.end(n),new lt(this.request)};y.prototype.setCommonConfiguration=function(n,t){var u,r,i;if(t=t||{},this._timesToRetryFailedRequests>0&&(n=n.retry(this._timesToRetryFailedRequests)),t.noHeaders)return n;for(u=this.headers,n=n.set("Content-Type","application/json"),r=Object.keys(this.headers),i=0;i<r.length;i++)n=n.set(r[i],u[r[i]]);return this._sendTelemetry&&(n=n.set("Auth0-Client",this.getTelemetryData())),n};y.prototype.getTelemetryData=function(){var n=this._telemetryInfo||{name:"auth0.js",version:ct.raw},t=JSON.stringify(n);return hr.encode(t)};y.prototype.get=function(n,t){return new tt(this.setCommonConfiguration(pt.get(n),t))};y.prototype.post=function(n,t){return new tt(this.setCommonConfiguration(pt.post(n),t))};y.prototype.patch=function(n,t){return new tt(this.setCommonConfiguration(pt.patch(n),t))};cr=Object.prototype.toString;i={check:ve,attribute:lr,variable:ar,value:vr,isArray:ye,supportsIsArray:pe};pr={get:we,objectAssignPolyfill:yr};t={toSnakeCase:br,toCamelCase:kr,blacklist:ge,merge:de,pick:pi,getKeysNotIn:be,extend:wr,getOriginFromUrl:io,getLocationFromUrl:dr};u={redirect:ro,getDocument:uo,getWindow:ii,getOrigin:fo};wt.prototype.getItem=function(){return null};wt.prototype.removeItem=function(){};wt.prototype.setItem=function(){};ri=a(function(n){(function(t){var i=!1,u,r;typeof undefined=="function"&&undefined.amd&&(undefined(t),i=!0);n.exports=t();i=!0;i||(u=window.Cookies,r=window.Cookies=t(),r.noConflict=function(){return window.Cookies=u,r})})(function(){function n(){for(var n=0,r={},t,i;n<arguments.length;n++){t=arguments[n];for(i in t)r[i]=t[i]}return r}function t(i){function r(t,u,f){var o,c,l,s,v,e,h;if(typeof document!="undefined"){if(arguments.length>1){f=n({path:"/"},r.defaults,f);typeof f.expires=="number"&&(c=new Date,c.setMilliseconds(c.getMilliseconds()+f.expires*864e5),f.expires=c);f.expires=f.expires?f.expires.toUTCString():"";try{o=JSON.stringify(u);/^[\{\[]/.test(o)&&(u=o)}catch(w){}u=i.write?i.write(u,t):encodeURIComponent(String(u)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent);t=encodeURIComponent(String(t));t=t.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent);t=t.replace(/[\(\)]/g,escape);l="";for(s in f)f[s]&&(l+="; "+s,f[s]!==!0)&&(l+="="+f[s]);return document.cookie=t+"="+u+l}t||(o={});for(var y=document.cookie?document.cookie.split("; "):[],p=/(%[0-9A-Z]{2})+/g,a=0;a<y.length;a++){v=y[a].split("=");e=v.slice(1).join("=");this.json||e.charAt(0)!=='"'||(e=e.slice(1,-1));try{if(h=v[0].replace(p,decodeURIComponent),e=i.read?i.read(e,h):i(e,h)||e.replace(p,decodeURIComponent),this.json)try{e=JSON.parse(e)}catch(w){}if(t===h){o=e;break}t||(o[h]=e)}catch(w){}}return o}}return r.set=r,r.get=function(n){return r.call(r,n)},r.getJSON=function(){return r.apply({json:!0},[].slice.call(arguments))},r.defaults={},r.remove=function(t,i){r(t,"",n(i,{expires:-1}))},r.withConverter=t,r}return t(function(){})})});at.prototype.getItem=function(n){return ri.get(n)};at.prototype.remove