Socket
Socket
Sign inDemoInstall

auth0-js

Package Overview
Dependencies
Maintainers
2
Versions
262
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

auth0-js - npm Package Compare versions

Comparing version 1.4.3 to 1.5.2

2

bower.json
{
"//": "experimental bower support",
"name": "auth0-js",
"version": "1.4.3",
"version": "1.5.2",
"main": "lib/index.js",

@@ -6,0 +6,0 @@ "dependencies": {

@@ -17,2 +17,6 @@ ;(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

if (obj && !obj.code) {
obj.code = obj.error;
}
var err = Error.call(this, obj.description || obj.message || obj.error);

@@ -116,7 +120,8 @@

Auth0.prototype.getProfile = function (hash, callback, errCallback) {
Auth0.prototype.getProfile = function (token, callback) {
if (!token) { return; }
var self = this;
var fail = function (status, description) {
errCallback({
callback({
error: status,

@@ -143,3 +148,3 @@ error_description: description

return resp.status === 200 ?
callback(resp.user, id_token, access_token, state) :
callback(null, resp.user, id_token, access_token, state) :
fail(resp.status, resp.error);

@@ -160,12 +165,21 @@ });

}).then(function (userinfo) {
callback(userinfo, id_token, access_token, state);
callback(null, userinfo, id_token, access_token, state);
});
}
callback(profile, id_token, access_token, state);
callback(null, profile, id_token, access_token, state);
};
self.parseHash(hash, getUserInfo, errCallback);
if (typeof token === 'string') { // token is a hash
return self.parseHash(token, getUserInfo, callback);
}
getUserInfo(this.decodeJwt(token.id_token), token.id_token, token.access_token);
};
Auth0.prototype.decodeJwt = function (jwt) {
var encoded = jwt && jwt.split('.')[1];
return json_parse(base64_url_decode(encoded));
};
Auth0.prototype.parseHash = function (hash, callback, errCallback) {

@@ -185,4 +199,3 @@ if (hash.match(/error/)) {

var id_token = parsed_qs.id_token;
var encoded = id_token.split('.')[1];
var prof = json_parse(base64_url_decode(encoded));
var prof = this.decodeJwt(id_token);
var invalidJwt = function (error) {

@@ -403,3 +416,62 @@ if (!errCallback) { return; }

Auth0.prototype.loginWithResourceOwner = function (options, callback) {
var self = this;
var query = xtend(
this._getMode(),
options,
{
client_id: this._clientID,
username: options.username || options.email,
grant_type: 'password'
});
var endpoint = '/oauth/ro';
if (use_jsonp()) {
return jsonp('https://' + this._domain + endpoint + '?' + qs.stringify(query), {
param: 'cbx',
timeout: 15000
}, function (err, resp) {
if (err) {
return callback(err);
}
if('error' in resp) {
var error = new LoginError(resp.status, resp.error);
return callback(error);
}
self.getProfile(resp, callback);
});
}
reqwest({
url: 'https://' + this._domain + endpoint,
method: 'post',
type: 'json',
data: query,
crossOrigin: true,
success: function (resp) {
self.getProfile(resp, callback);
}
}).fail(function (err) {
var er = err;
if (!er.status || er.status === 0) { //ie10 trick
er = {};
er.status = 401;
er.responseText = {
code: 'invalid_user_password'
};
}
else {
er.responseText = err;
}
var error = new LoginError(er.status, er.responseText);
callback(error);
});
};
Auth0.prototype.loginWithUsernamePassword = function (options, callback) {
if (callback && callback.length > 1) {
return this.loginWithResourceOwner(options, callback);
}
var self = this;

@@ -406,0 +478,0 @@ var popup;

@@ -1,1 +0,1 @@

!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b){function c(a,b){var c;if("string"==typeof b)try{c=d(b)}catch(e){c={message:b}}else c=b||{description:"server error"};var f=Error.call(this,c.description||c.message||c.error);return f.status=a,f.name=c.code,f.code=c.code,f.details=c,0===a&&(f.code="Unknown",f.message="Unknown error."),f}var d=a("./json_parse");Object&&Object.create&&(c.prototype=Object.create(Error.prototype,{constructor:{value:c}})),b.exports=c},{"./json_parse":5}],2:[function(a,b){b.exports=function(a,b){if(!a[b])throw new Error(b+" is required.")}},{}],3:[function(a,b){var c=a("Base64");b.exports=function(a){var b=a.replace("-","+").replace("_","/");switch(b.length%4){case 0:break;case 2:b+="==";break;case 3:b+="=";break;default:throw"Illegal base64url string!"}return decodeURIComponent(escape(c.atob(b)))}},{Base64:7}],4:[function(a,b){function c(a){return this instanceof c?(f(a,"clientID"),f(a,"callbackURL"),f(a,"domain"),this._clientID=a.clientID,this._callbackURL=a.callbackURL,this._domain=a.domain,this._callbackOnLocationHash=!1||a.callbackOnLocationHash,void 0):new c(a)}function d(a){var b="";for(var c in a)b+=c+"="+a[c]+",";return b.slice(0,-1)}var e="undefined"!=typeof self?self:"undefined"!=typeof window?window:{},f=a("./assert_required"),g=a("./base64_url_decode"),h=a("qs"),i=a("xtend"),j=a("reqwest"),k=a("jsonp"),l=a("./use_jsonp"),m=a("./LoginError"),n=a("./json_parse");c.prototype._redirect=function(a){e.window.location=a},c.prototype._renderAndSubmitWSFedForm=function(a,b){var c=document.createElement("div");c.innerHTML=b;var d=document.body.appendChild(c).children[0];a.popup&&!this._callbackOnLocationHash&&(d.target="auth0_signup_popup"),d.submit()},c.prototype._getMode=function(){return{scope:"openid",response_type:this._callbackOnLocationHash?"token":"code"}},c.prototype.getProfile=function(a,b,c){var d=this,e=function(a,b){c({error:a,error_description:b})},f=function(a,c,f,g){if(a&&!a.user_id){var h="https://"+d._domain+"/api/users/"+a.sub;return l()?k(h+"?access_token="+c,{param:"cbx",timeout:15e3},function(a,d){return a?e(0,a.toString()):200===d.status?b(d.user,c,f,g):e(d.status,d.error)}):j({url:h,method:"get",type:"json",crossOrigin:!0,headers:{Authorization:"Bearer "+c}}).fail(function(a){e(a.status,a.responseText)}).then(function(a){b(a,c,f,g)})}b(a,c,f,g)};d.parseHash(a,f,c)},c.prototype.parseHash=function(a,b,c){if(a.match(/error/)){if(!c)return;a=a.substr(1);var d=h.parse(a);return c({error:d.error,error_description:d.error_description})}if(a.match(/access_token/)){a=a.substr(1);var d=h.parse(a),e=d.id_token,f=e.split(".")[1],i=n(g(f)),j=function(a){c&&c({error:"invalid_token",error_description:a})};return i.aud!==this._clientID?j("The clientID configured ("+this._clientID+") does not match with the clientID set in the token ("+i.aud+")."):i.iss!=="https://"+this._domain+"/"?j("The domain configured (https://"+this._domain+"/) does not match with the domain set in the token ("+i.iss+")."):(b(i,e,d.access_token,d.state),void 0)}},c.prototype.signup=function(a,b){function c(){return"auto_login"in a&&!a.auto_login?(b&&b(),void 0):(e.login(a,b),void 0)}function d(a,c){var d=new m(a,c);if(b)return b(d);throw d}var e=this,f=i(this._getMode(),a,{client_id:this._clientID,redirect_uri:this._callbackURL,email:a.username||a.email,tenant:this._domain.split(".")[0]});return l()?k("https://"+this._domain+"/dbconnections/signup?"+h.stringify(f),{param:"cbx",timeout:15e3},function(a,b){return a?d(0,a):200==b.status?c():d(b.status,b.err)}):(j({url:"https://"+this._domain+"/dbconnections/signup",method:"post",type:"html",data:f,success:c,crossOrigin:!0}).fail(function(a){d(a.status,a.responseText)}),void 0)},c.prototype.changePassword=function(a,b){function c(a,c){var d=new m(a,c);return b?b(d):void 0}var d={tenant:this._domain.split(".")[0],connection:a.connection,email:a.username||a.email,password:a.password};return l()?k("https://"+this._domain+"/dbconnections/change_password?"+h.stringify(d),{param:"cbx",timeout:15e3},function(a,d){return a?c(0,a):200==d.status?b(null,d.message):c(d.status,d.err)}):(j({url:"https://"+this._domain+"/dbconnections/change_password",method:"post",type:"html",data:d,crossOrigin:!0}).fail(function(a){c(a.status,a.responseText)}).then(function(a){b(null,a)}),void 0)},c.prototype.login=c.prototype.signin=function(a,b){if("undefined"!=typeof a.username||"undefined"!=typeof a.email)return this.loginWithUsernamePassword(a,b);if(a.popup)return this.loginWithPopup(a,b);var c=i(this._getMode(),a,{client_id:this._clientID,redirect_uri:this._callbackURL});this._redirect("https://"+this._domain+"/authorize?"+h.stringify(c))},c.prototype.loginWithPopup=function(a,b){function c(){if(!k)return clearInterval(l);if(!k.top&&!k.window)return clearInterval(l),k=null,void 0;var a="";try{/#access_token/.test(k.location.href)&&(clearInterval(l),a=k.location.hash,k.close(),pupup=null),/\?error/.test(k.location.href)&&(clearInterval(l),a="#"+k.location.search.slice(1),k.close(),k=null)}catch(b){}return a.length?e(a):void 0}function e(a){window.location.replace(a),window.location.reload()}var f=i(this._getMode(),a,{client_id:this._clientID,redirect_uri:this._callbackURL}),g="https://"+this._domain+"/authorize?"+h.stringify(f),j=i({width:500,height:600},a.popupOptions),k=window.open(g,null,d(j));if(!k)return b(new Error("Unable to open popup"));var l=setInterval(c,50);k.focus()},c.prototype.loginWithUsernamePassword=function(a,b){function c(a){if(b)return b(a);throw a}var e,f=this;if(a.popup&&!this._callbackOnLocationHash){var g=d(i({width:500,height:600},a.popupOptions||{}));e=window.open("about:blank","auth0_signup_popup",g)}var n=i(this._getMode(),a,{client_id:this._clientID,redirect_uri:this._callbackURL,username:a.username||a.email,tenant:this._domain.split(".")[0]}),o="/usernamepassword/login";return l()?k("https://"+this._domain+o+"?"+h.stringify(n),{param:"cbx",timeout:15e3},function(c,d){if(c)return e&&e.close(),b(c);if("error"in d){e&&e.close();var g=new m(d.status,d.error);return b(g)}f._renderAndSubmitWSFedForm(a,d.form)}):(j({url:"https://"+this._domain+o,method:"post",type:"html",data:n,crossOrigin:!0,success:function(b){f._renderAndSubmitWSFedForm(a,b)}}).fail(function(a){var b=a;e&&e.close(),b.status&&0!==b.status||(b={},b.status=401,b.responseText={code:"invalid_user_password"});var d=new m(b.status,b.responseText);return c(d)}),void 0)},c.prototype.getDelegationToken=function(a,b,c,d){"function"==typeof c&&(d=c,c={}),c.id_token=b;var e=i({grant_type:"urn:ietf:params:oauth:grant-type:jwt-bearer",target:a,client_id:this._clientID},c),f="/delegation";return l()?k("https://"+this._domain+f+"?"+h.stringify(e),{param:"cbx",timeout:15e3},function(a,b){if(a)return d(a);if("error"in b){var c=new m(b.status,b.error_description||b.error);return d(c)}d(null,b)}):(j({url:"https://"+this._domain+f,method:"post",type:"json",data:e,crossOrigin:!0,success:function(a){d(null,a)}}).fail(function(a){try{d(JSON.parse(a.responseText))}catch(b){var c=a;c.status&&0!==c.status||(c={},c.status=401,c.responseText={code:"invalid_operation"}),d(new m(c.status,c.responseText))}}),void 0)},c.prototype.logout=function(a){var b="https://"+this._domain+"/logout";a&&(b+="?"+h.stringify(a)),this._redirect(b)},c.prototype.getSSOData=function(a,b){"function"==typeof a&&(b=a,a=!1);var c="https://"+this._domain+"/user/ssodata";return a&&(c+="?"+h.stringify({ads:1,client_id:this._clientID})),k(c,{param:"cbx",timeout:15e3},function(a,c){b(null,a?{}:c)})},c.prototype.getConnections=function(a){return k("https://"+this._domain+"/public/api/"+this._clientID+"/connections",{param:"cbx",timeout:15e3},a)},b.exports=c},{"./LoginError":1,"./assert_required":2,"./base64_url_decode":3,"./json_parse":5,"./use_jsonp":6,jsonp:9,qs:10,reqwest:11,xtend:13}],5:[function(require,module,exports){module.exports=function(str){return window.JSON?window.JSON.parse(str):eval("("+str+")")}},{}],6:[function(a,b){b.exports=function(){var a=window.XMLHttpRequest?new XMLHttpRequest:null;return a&&"withCredentials"in a?!1:"XDomainRequest"in window&&"http:"===window.location.protocol}},{}],7:[function(a,b,c){!function(){var a="undefined"!=typeof c?c:this,b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",d=function(){try{document.createElement("$")}catch(a){return a}}();a.btoa||(a.btoa=function(a){for(var c,e,f=0,g=b,h="";a.charAt(0|f)||(g="=",f%1);h+=g.charAt(63&c>>8-8*(f%1))){if(e=a.charCodeAt(f+=.75),e>255)throw d;c=c<<8|e}return h}),a.atob||(a.atob=function(a){if(a=a.replace(/=+$/,""),1==a.length%4)throw d;for(var c,e,f=0,g=0,h="";e=a.charAt(g++);~e&&(c=f%4?64*c+e:e,f++%4)?h+=String.fromCharCode(255&c>>(6&-2*f)):0)e=b.indexOf(e);return h})}()},{}],8:[function(a,b){function c(a){return c.enabled(a)?function(b){b=d(b);var e=new Date,f=e-(c[a]||e);c[a]=e,b=a+" "+b+" +"+c.humanize(f),window.console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}:function(){}}function d(a){return a instanceof Error?a.stack||a.message:a}b.exports=c,c.names=[],c.skips=[],c.enable=function(a){try{localStorage.debug=a}catch(b){}for(var d=(a||"").split(/[\s,]+/),e=d.length,f=0;e>f;f++)a=d[f].replace("*",".*?"),"-"===a[0]?c.skips.push(new RegExp("^"+a.substr(1)+"$")):c.names.push(new RegExp("^"+a+"$"))},c.disable=function(){c.enable("")},c.humanize=function(a){var b=1e3,c=6e4,d=60*c;return a>=d?(a/d).toFixed(1)+"h":a>=c?(a/c).toFixed(1)+"m":a>=b?(0|a/b)+"s":a+"ms"},c.enabled=function(a){for(var b=0,d=c.skips.length;d>b;b++)if(c.skips[b].test(a))return!1;for(var b=0,d=c.names.length;d>b;b++)if(c.names[b].test(a))return!0;return!1};try{window.localStorage&&c.enable(localStorage.debug)}catch(e){}},{}],9:[function(a,b){function c(){}function d(a,b,d){function g(){m.parentNode.removeChild(h),window["__jp"+n]=c}"function"==typeof b&&(d=b,b={});var h,i,b=b||{},j=b.param||"callback",k=null!=b.timeout?b.timeout:6e4,l=encodeURIComponent,m=document.getElementsByTagName("script")[0],n=f++;k&&(i=setTimeout(function(){g(),d&&d(new Error("Timeout"))},k)),window["__jp"+n]=function(a){e("jsonp got",a),i&&clearTimeout(i),g(),d&&d(null,a)},a+=(~a.indexOf("?")?"&":"?")+j+"="+l("__jp"+n),a=a.replace("?&","?"),e('jsonp req "%s"',a),h=document.createElement("script"),h.src=a,m.parentNode.insertBefore(h,m)}var e=a("debug")("jsonp");b.exports=d;var f=0},{debug:8}],10:[function(a,b,c){function d(){return t?Object.create(null):{}}function e(a,b){if(0==a[b].length)return a[b]=d();var c=d();for(var e in a[b])s.call(a[b],e)&&(c[e]=a[b][e]);return a[b]=c,c}function f(a,b,c,d){var g=a.shift();if(g){var h=b[c]=b[c]||[];"]"==g?v(h)?""!=d&&h.push(d):"object"==typeof h?h[w(h).length]=d:h=b[c]=[b[c],d]:~u(g,"]")?(g=g.substr(0,g.length-1),!z.test(g)&&v(h)&&(h=e(b,c)),f(a,h,g,d)):(!z.test(g)&&v(h)&&(h=e(b,c)),f(a,h,g,d))}else v(b[c])?b[c].push(d):b[c]="object"==typeof b[c]?d:"undefined"==typeof b[c]?d:[b[c],d]}function g(a,b,c){if(~u(b,"]")){var e=b.split("[");e.length,f(e,a,"base",c)}else{if(!z.test(b)&&v(a.base)){var g=d();for(var h in a.base)g[h]=a.base[h];a.base=g}o(a.base,b,c)}return a}function h(a){if("object"!=typeof a)return a;if(v(a)){var b=[];for(var c in a)s.call(a,c)&&b.push(a[c]);return b}for(var d in a)a[d]=h(a[d]);return a}function i(a){if(!t)return a;if(v(a))return a;if(a&&"object"!=typeof a)return a;for(var b in a)s.call(a,b)&&(a[b]=i(a[b]));return a.__proto__=Object.prototype,a}function j(a){var b={base:{}};return x(w(a),function(c){g(b,c,a[c])}),h(b.base)}function k(a){var b=y(String(a).split("&"),function(a,b){var c=u(b,"="),d=p(b),e=b.substr(0,d||c),f=b.substr(d||c,b.length),f=f.substr(u(f,"=")+1,f.length);return""==e&&(e=b,f=""),""==e?a:g(a,q(e),q(f))},{base:d()}).base;return i(h(b))}function l(a,b){if(!b)throw new TypeError("stringify expects an object");return b+"="+encodeURIComponent(a)}function m(a,b){var c=[];if(!b)throw new TypeError("stringify expects an object");for(var d=0;d<a.length;d++)c.push(A(a[d],b+"["+d+"]"));return c.join("&")}function n(a,b){for(var c,d=[],e=w(a),f=0,g=e.length;g>f;++f)c=e[f],""!=c&&(null==a[c]?d.push(encodeURIComponent(c)+"="):d.push(A(a[c],b?b+"["+encodeURIComponent(c)+"]":encodeURIComponent(c))));return d.join("&")}function o(a,b,c){var d=a[b];void 0===d?a[b]=c:v(d)?d.push(c):a[b]=[d,c]}function p(a){for(var b,c,d=a.length,e=0;d>e;++e)if(c=a[e],"]"==c&&(b=!1),"["==c&&(b=!0),"="==c&&!b)return e}function q(a){try{return decodeURIComponent(a.replace(/\+/g," "))}catch(b){return a}}var r=Object.prototype.toString,s=Object.prototype.hasOwnProperty,t=function(){var a;return Object.create?(a=Object.create(null),a.__proto__=Object.prototype,a.hasOwnProperty===s):!1}(),u="function"==typeof Array.prototype.indexOf?function(a,b){return a.indexOf(b)}:function(a,b){"string"==typeof a&&"undefined"==typeof"a"[0]&&(a=a.split(""));for(var c=0;c<a.length;c++)if(a[c]===b)return c;return-1},v=Array.isArray||function(a){return"[object Array]"==r.call(a)},w=Object.keys||function(a){var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c);return b},x="function"==typeof Array.prototype.forEach?function(a,b){return a.forEach(b)}:function(a,b){for(var c=0;c<a.length;c++)b(a[c])},y=function(a,b,c){if("function"==typeof a.reduce)return a.reduce(b,c);for(var d=c,e=0;e<a.length;e++)d=b(d,a[e]);return d},z=/^[0-9]+$/;c.parse=function(a){return null==a||""==a?{}:"object"==typeof a?j(a):k(a)};var A=c.stringify=function(a,b){return v(a)?m(a,b):"[object Object]"==r.call(a)?n(a,b):"string"==typeof a?l(a,b):b+"="+encodeURIComponent(String(a))}},{}],11:[function(require,module,exports){!function(a,b,c){"undefined"!=typeof module&&module.exports?module.exports=c():"function"==typeof define&&define.amd?define(c):b[a]=c()}("reqwest",this,function(){function handleReadyState(a,b,c){return function(){return a._aborted?c(a.request):(a.request&&4==a.request[readyState]&&(a.request.onreadystatechange=noop,twoHundo.test(a.request.status)?b(a.request):c(a.request)),void 0)}}function setHeaders(a,b){var c,d=b.headers||{};d.Accept=d.Accept||defaultHeaders.accept[b.type]||defaultHeaders.accept["*"],b.crossOrigin||d[requestedWith]||(d[requestedWith]=defaultHeaders.requestedWith),d[contentType]||(d[contentType]=b.contentType||defaultHeaders.contentType);for(c in d)d.hasOwnProperty(c)&&"setRequestHeader"in a&&a.setRequestHeader(c,d[c])}function setCredentials(a,b){"undefined"!=typeof b.withCredentials&&"undefined"!=typeof a.withCredentials&&(a.withCredentials=!!b.withCredentials)}function generalCallback(a){lastValue=a}function urlappend(a,b){return a+(/\?/.test(a)?"&":"?")+b}function handleJsonp(a,b,c,d){var e=uniqid++,f=a.jsonpCallback||"callback",g=a.jsonpCallbackName||reqwest.getcallbackPrefix(e),h=new RegExp("((^|\\?|&)"+f+")=([^&]+)"),i=d.match(h),j=doc.createElement("script"),k=0,l=-1!==navigator.userAgent.indexOf("MSIE 10.0");return i?"?"===i[3]?d=d.replace(h,"$1="+g):g=i[3]:d=urlappend(d,f+"="+g),win[g]=generalCallback,j.type="text/javascript",j.src=d,j.async=!0,"undefined"==typeof j.onreadystatechange||l||(j.event="onclick",j.htmlFor=j.id="_reqwest_"+e),j.onload=j.onreadystatechange=function(){return j[readyState]&&"complete"!==j[readyState]&&"loaded"!==j[readyState]||k?!1:(j.onload=j.onreadystatechange=null,j.onclick&&j.onclick(),b(lastValue),lastValue=void 0,head.removeChild(j),k=1,void 0)},head.appendChild(j),{abort:function(){j.onload=j.onreadystatechange=null,c({},"Request is aborted: timeout",{}),lastValue=void 0,head.removeChild(j),k=1}}}function getRequest(a,b){var c,d=this.o,e=(d.method||"GET").toUpperCase(),f="string"==typeof d?d:d.url,g=d.processData!==!1&&d.data&&"string"!=typeof d.data?reqwest.toQueryString(d.data):d.data||null,h=!1;return"jsonp"!=d.type&&"GET"!=e||!g||(f=urlappend(f,g),g=null),"jsonp"==d.type?handleJsonp(d,a,b,f):(c=xhr(d),c.open(e,f,d.async===!1?!1:!0),setHeaders(c,d),setCredentials(c,d),win[xDomainRequest]&&c instanceof win[xDomainRequest]?(c.onload=a,c.onerror=b,c.onprogress=function(){},h=!0):c.onreadystatechange=handleReadyState(this,a,b),d.before&&d.before(c),h?setTimeout(function(){c.send(g)},200):c.send(g),c)}function Reqwest(a,b){this.o=a,this.fn=b,init.apply(this,arguments)}function setType(a){var b=a.match(/\.(json|jsonp|html|xml)(\?|$)/);return b?b[1]:"js"}function init(o,fn){function complete(a){for(o.timeout&&clearTimeout(self.timeout),self.timeout=null;self._completeHandlers.length>0;)self._completeHandlers.shift()(a)}function success(resp){resp="jsonp"!==type?self.request:resp;var filteredResponse=globalSetupOptions.dataFilter(resp.responseText,type),r=filteredResponse;try{resp.responseText=r}catch(e){}if(r)switch(type){case"json":try{resp=win.JSON?win.JSON.parse(r):eval("("+r+")")}catch(err){return error(resp,"Could not parse JSON in response",err)}break;case"js":resp=eval(r);break;case"html":resp=r;break;case"xml":resp=resp.responseXML&&resp.responseXML.parseError&&resp.responseXML.parseError.errorCode&&resp.responseXML.parseError.reason?null:resp.responseXML}for(self._responseArgs.resp=resp,self._fulfilled=!0,fn(resp),self._successHandler(resp);self._fulfillmentHandlers.length>0;)resp=self._fulfillmentHandlers.shift()(resp);complete(resp)}function error(a,b,c){for(a=self.request,self._responseArgs.resp=a,self._responseArgs.msg=b,self._responseArgs.t=c,self._erred=!0;self._errorHandlers.length>0;)self._errorHandlers.shift()(a,b,c);complete(a)}this.url="string"==typeof o?o:o.url,this.timeout=null,this._fulfilled=!1,this._successHandler=function(){},this._fulfillmentHandlers=[],this._errorHandlers=[],this._completeHandlers=[],this._erred=!1,this._responseArgs={};var self=this,type=o.type||setType(this.url);fn=fn||function(){},o.timeout&&(this.timeout=setTimeout(function(){self.abort()},o.timeout)),o.success&&(this._successHandler=function(){o.success.apply(o,arguments)}),o.error&&this._errorHandlers.push(function(){o.error.apply(o,arguments)}),o.complete&&this._completeHandlers.push(function(){o.complete.apply(o,arguments)}),this.request=getRequest.call(this,success,error)}function reqwest(a,b){return new Reqwest(a,b)}function normalize(a){return a?a.replace(/\r?\n/g,"\r\n"):""}function serial(a,b){var c,d,e,f,g=a.name,h=a.tagName.toLowerCase(),i=function(a){a&&!a.disabled&&b(g,normalize(a.attributes.value&&a.attributes.value.specified?a.value:a.text))};if(!a.disabled&&g)switch(h){case"input":/reset|button|image|file/i.test(a.type)||(c=/checkbox/i.test(a.type),d=/radio/i.test(a.type),e=a.value,(!(c||d)||a.checked)&&b(g,normalize(c&&""===e?"on":e)));break;case"textarea":b(g,normalize(a.value));break;case"select":if("select-one"===a.type.toLowerCase())i(a.selectedIndex>=0?a.options[a.selectedIndex]:null);else for(f=0;a.length&&f<a.length;f++)a.options[f].selected&&i(a.options[f])}}function eachFormElement(){var a,b,c=this,d=function(a,b){var d,e,f;for(d=0;d<b.length;d++)for(f=a[byTag](b[d]),e=0;e<f.length;e++)serial(f[e],c)};for(b=0;b<arguments.length;b++)a=arguments[b],/input|select|textarea/i.test(a.tagName)&&serial(a,c),d(a,["input","select","textarea"])}function serializeQueryString(){return reqwest.toQueryString(reqwest.serializeArray.apply(null,arguments))}function serializeHash(){var a={};return eachFormElement.apply(function(b,c){b in a?(a[b]&&!isArray(a[b])&&(a[b]=[a[b]]),a[b].push(c)):a[b]=c},arguments),a}function buildParams(a,b,c,d){var e,f,g,h=/\[\]$/;if(isArray(b))for(f=0;b&&f<b.length;f++)g=b[f],c||h.test(a)?d(a,g):buildParams(a+"["+("object"==typeof g?f:"")+"]",g,c,d);else if(b&&"[object Object]"===b.toString())for(e in b)buildParams(a+"["+e+"]",b[e],c,d);else d(a,b)}var win=window,doc=document,twoHundo=/^20\d$/,byTag="getElementsByTagName",readyState="readyState",contentType="Content-Type",requestedWith="X-Requested-With",head=doc[byTag]("head")[0],uniqid=0,callbackPrefix="reqwest_"+ +new Date,lastValue,xmlHttpRequest="XMLHttpRequest",xDomainRequest="XDomainRequest",noop=function(){},isArray="function"==typeof Array.isArray?Array.isArray:function(a){return a instanceof Array},defaultHeaders={contentType:"application/x-www-form-urlencoded",requestedWith:xmlHttpRequest,accept:{"*":"text/javascript, text/html, application/xml, text/xml, */*",xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript",js:"application/javascript, text/javascript"}},xhr=function(a){if(a.crossOrigin===!0){var b=win[xmlHttpRequest]?new XMLHttpRequest:null;if(b&&"withCredentials"in b)return b;if(win[xDomainRequest])return new XDomainRequest;throw new Error("Browser does not support cross-origin requests")}return win[xmlHttpRequest]?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP")},globalSetupOptions={dataFilter:function(a){return a}};return Reqwest.prototype={abort:function(){this._aborted=!0,this.request.abort()},retry:function(){init.call(this,this.o,this.fn)},then:function(a,b){return a=a||function(){},b=b||function(){},this._fulfilled?this._responseArgs.resp=a(this._responseArgs.resp):this._erred?b(this._responseArgs.resp,this._responseArgs.msg,this._responseArgs.t):(this._fulfillmentHandlers.push(a),this._errorHandlers.push(b)),this},always:function(a){return this._fulfilled||this._erred?a(this._responseArgs.resp):this._completeHandlers.push(a),this},fail:function(a){return this._erred?a(this._responseArgs.resp,this._responseArgs.msg,this._responseArgs.t):this._errorHandlers.push(a),this}},reqwest.serializeArray=function(){var a=[];return eachFormElement.apply(function(b,c){a.push({name:b,value:c})},arguments),a},reqwest.serialize=function(){if(0===arguments.length)return"";var a,b,c=Array.prototype.slice.call(arguments,0);return a=c.pop(),a&&a.nodeType&&c.push(a)&&(a=null),a&&(a=a.type),b="map"==a?serializeHash:"array"==a?reqwest.serializeArray:serializeQueryString,b.apply(null,c)},reqwest.toQueryString=function(a,b){var c,d,e=b||!1,f=[],g=encodeURIComponent,h=function(a,b){b="function"==typeof b?b():null==b?"":b,f[f.length]=g(a)+"="+g(b)};if(isArray(a))for(d=0;a&&d<a.length;d++)h(a[d].name,a[d].value);else for(c in a)buildParams(c,a[c],e,h);return f.join("&").replace(/%20/g,"+")},reqwest.getcallbackPrefix=function(){return callbackPrefix},reqwest.compat=function(a,b){return a&&(a.type&&(a.method=a.type)&&delete a.type,a.dataType&&(a.type=a.dataType),a.jsonpCallback&&(a.jsonpCallbackName=a.jsonpCallback)&&delete a.jsonpCallback,a.jsonp&&(a.jsonpCallback=a.jsonp)),new Reqwest(a,b)},reqwest.ajaxSetup=function(a){a=a||{};for(var b in a)globalSetupOptions[b]=a[b]},reqwest})},{}],12:[function(a,b){function c(a){return null!==a&&("object"==typeof a||"function"==typeof a)}b.exports=c},{}],13:[function(a,b){function c(){for(var a={},b=0;b<arguments.length;b++){var c=arguments[b];if(e(c))for(var f=d(c),g=0;g<f.length;g++){var h=f[g];a[h]=c[h]}}return a}var d=a("object-keys"),e=a("./has-keys");b.exports=c},{"./has-keys":12,"object-keys":15}],14:[function(a,b){var c=Object.prototype.hasOwnProperty,d=Object.prototype.toString,e=function(a){var b="function"==typeof a&&!(a instanceof RegExp)||"[object Function]"===d.call(a);return b||"undefined"==typeof window||(b=a===window.setTimeout||a===window.alert||a===window.confirm||a===window.prompt),b};b.exports=function(a,b){if(!e(b))throw new TypeError("iterator must be a function");var d,f,g="string"==typeof a,h=a.length,i=arguments.length>2?arguments[2]:null;if(h===+h)for(d=0;h>d;d++)null===i?b(g?a.charAt(d):a[d],d,a):b.call(i,g?a.charAt(d):a[d],d,a);else for(f in a)c.call(a,f)&&(null===i?b(a[f],f,a):b.call(i,a[f],f,a))}},{}],15:[function(a,b){b.exports=Object.keys||a("./shim")},{"./shim":17}],16:[function(a,b){var c=Object.prototype.toString;b.exports=function d(a){var b=c.call(a),d="[object Arguments]"===b;return d||(d="[object Array]"!==b&&null!==a&&"object"==typeof a&&"number"==typeof a.length&&a.length>=0&&"[object Function]"===c.call(a.callee)),d}},{}],17:[function(a,b){!function(){"use strict";var c,d=Object.prototype.hasOwnProperty,e=Object.prototype.toString,f=a("./foreach"),g=a("./isArguments"),h=!{toString:null}.propertyIsEnumerable("toString"),i=function(){}.propertyIsEnumerable("prototype"),j=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"];c=function(a){var b=null!==a&&"object"==typeof a,c="[object Function]"===e.call(a),k=g(a),l=[];if(!b&&!c&&!k)throw new TypeError("Object.keys called on a non-object");if(k)f(a,function(a){l.push(a)});else{var m,n=i&&c;for(m in a)n&&"prototype"===m||!d.call(a,m)||l.push(m)}if(h){var o=a.constructor,p=o&&o.prototype===a;f(j,function(b){p&&"constructor"===b||!d.call(a,b)||l.push(b)})}return l},b.exports=c}()},{"./foreach":14,"./isArguments":16}],18:[function(a){var b="undefined"!=typeof self?self:"undefined"!=typeof window?window:{},c=a("./lib/index");"function"==typeof b.window.define&&b.window.define.amd?b.window.define("auth0",function(){return c}):b.window&&(b.window.Auth0=c)},{"./lib/index":4}]},{},[18]);
!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b){function c(a,b){var c;if("string"==typeof b)try{c=d(b)}catch(e){c={message:b}}else c=b||{description:"server error"};c&&!c.code&&(c.code=c.error);var f=Error.call(this,c.description||c.message||c.error);return f.status=a,f.name=c.code,f.code=c.code,f.details=c,0===a&&(f.code="Unknown",f.message="Unknown error."),f}var d=a("./json_parse");Object&&Object.create&&(c.prototype=Object.create(Error.prototype,{constructor:{value:c}})),b.exports=c},{"./json_parse":5}],2:[function(a,b){b.exports=function(a,b){if(!a[b])throw new Error(b+" is required.")}},{}],3:[function(a,b){var c=a("Base64");b.exports=function(a){var b=a.replace("-","+").replace("_","/");switch(b.length%4){case 0:break;case 2:b+="==";break;case 3:b+="=";break;default:throw"Illegal base64url string!"}return decodeURIComponent(escape(c.atob(b)))}},{Base64:7}],4:[function(a,b){function c(a){return this instanceof c?(f(a,"clientID"),f(a,"callbackURL"),f(a,"domain"),this._clientID=a.clientID,this._callbackURL=a.callbackURL,this._domain=a.domain,this._callbackOnLocationHash=!1||a.callbackOnLocationHash,void 0):new c(a)}function d(a){var b="";for(var c in a)b+=c+"="+a[c]+",";return b.slice(0,-1)}var e="undefined"!=typeof self?self:"undefined"!=typeof window?window:{},f=a("./assert_required"),g=a("./base64_url_decode"),h=a("qs"),i=a("xtend"),j=a("reqwest"),k=a("jsonp"),l=a("./use_jsonp"),m=a("./LoginError"),n=a("./json_parse");c.prototype._redirect=function(a){e.window.location=a},c.prototype._renderAndSubmitWSFedForm=function(a,b){var c=document.createElement("div");c.innerHTML=b;var d=document.body.appendChild(c).children[0];a.popup&&!this._callbackOnLocationHash&&(d.target="auth0_signup_popup"),d.submit()},c.prototype._getMode=function(){return{scope:"openid",response_type:this._callbackOnLocationHash?"token":"code"}},c.prototype.getProfile=function(a,b){if(a){var c=this,d=function(a,c){b({error:a,error_description:c})},e=function(a,e,f,g){if(a&&!a.user_id){var h="https://"+c._domain+"/api/users/"+a.sub;return l()?k(h+"?access_token="+e,{param:"cbx",timeout:15e3},function(a,c){return a?d(0,a.toString()):200===c.status?b(null,c.user,e,f,g):d(c.status,c.error)}):j({url:h,method:"get",type:"json",crossOrigin:!0,headers:{Authorization:"Bearer "+e}}).fail(function(a){d(a.status,a.responseText)}).then(function(a){b(null,a,e,f,g)})}b(null,a,e,f,g)};return"string"==typeof a?c.parseHash(a,e,b):(e(this.decodeJwt(a.id_token),a.id_token,a.access_token),void 0)}},c.prototype.decodeJwt=function(a){var b=a&&a.split(".")[1];return n(g(b))},c.prototype.parseHash=function(a,b,c){if(a.match(/error/)){if(!c)return;a=a.substr(1);var d=h.parse(a);return c({error:d.error,error_description:d.error_description})}if(a.match(/access_token/)){a=a.substr(1);var d=h.parse(a),e=d.id_token,f=this.decodeJwt(e),g=function(a){c&&c({error:"invalid_token",error_description:a})};return f.aud!==this._clientID?g("The clientID configured ("+this._clientID+") does not match with the clientID set in the token ("+f.aud+")."):f.iss!=="https://"+this._domain+"/"?g("The domain configured (https://"+this._domain+"/) does not match with the domain set in the token ("+f.iss+")."):(b(f,e,d.access_token,d.state),void 0)}},c.prototype.signup=function(a,b){function c(){return"auto_login"in a&&!a.auto_login?(b&&b(),void 0):(e.login(a,b),void 0)}function d(a,c){var d=new m(a,c);if(b)return b(d);throw d}var e=this,f=i(this._getMode(),a,{client_id:this._clientID,redirect_uri:this._callbackURL,email:a.username||a.email,tenant:this._domain.split(".")[0]});return l()?k("https://"+this._domain+"/dbconnections/signup?"+h.stringify(f),{param:"cbx",timeout:15e3},function(a,b){return a?d(0,a):200==b.status?c():d(b.status,b.err)}):(j({url:"https://"+this._domain+"/dbconnections/signup",method:"post",type:"html",data:f,success:c,crossOrigin:!0}).fail(function(a){d(a.status,a.responseText)}),void 0)},c.prototype.changePassword=function(a,b){function c(a,c){var d=new m(a,c);return b?b(d):void 0}var d={tenant:this._domain.split(".")[0],connection:a.connection,email:a.username||a.email,password:a.password};return l()?k("https://"+this._domain+"/dbconnections/change_password?"+h.stringify(d),{param:"cbx",timeout:15e3},function(a,d){return a?c(0,a):200==d.status?b(null,d.message):c(d.status,d.err)}):(j({url:"https://"+this._domain+"/dbconnections/change_password",method:"post",type:"html",data:d,crossOrigin:!0}).fail(function(a){c(a.status,a.responseText)}).then(function(a){b(null,a)}),void 0)},c.prototype.login=c.prototype.signin=function(a,b){if("undefined"!=typeof a.username||"undefined"!=typeof a.email)return this.loginWithUsernamePassword(a,b);if(a.popup)return this.loginWithPopup(a,b);var c=i(this._getMode(),a,{client_id:this._clientID,redirect_uri:this._callbackURL});this._redirect("https://"+this._domain+"/authorize?"+h.stringify(c))},c.prototype.loginWithPopup=function(a,b){function c(){if(!k)return clearInterval(l);if(!k.top&&!k.window)return clearInterval(l),k=null,void 0;var a="";try{/#access_token/.test(k.location.href)&&(clearInterval(l),a=k.location.hash,k.close(),pupup=null),/\?error/.test(k.location.href)&&(clearInterval(l),a="#"+k.location.search.slice(1),k.close(),k=null)}catch(b){}return a.length?e(a):void 0}function e(a){window.location.replace(a),window.location.reload()}var f=i(this._getMode(),a,{client_id:this._clientID,redirect_uri:this._callbackURL}),g="https://"+this._domain+"/authorize?"+h.stringify(f),j=i({width:500,height:600},a.popupOptions),k=window.open(g,null,d(j));if(!k)return b(new Error("Unable to open popup"));var l=setInterval(c,50);k.focus()},c.prototype.loginWithResourceOwner=function(a,b){var c=this,d=i(this._getMode(),a,{client_id:this._clientID,username:a.username||a.email,grant_type:"password"}),e="/oauth/ro";return l()?k("https://"+this._domain+e+"?"+h.stringify(d),{param:"cbx",timeout:15e3},function(a,d){if(a)return b(a);if("error"in d){var e=new m(d.status,d.error);return b(e)}c.getProfile(d,b)}):(j({url:"https://"+this._domain+e,method:"post",type:"json",data:d,crossOrigin:!0,success:function(a){c.getProfile(a,b)}}).fail(function(a){var c=a;c.status&&0!==c.status?c.responseText=a:(c={},c.status=401,c.responseText={code:"invalid_user_password"});var d=new m(c.status,c.responseText);b(d)}),void 0)},c.prototype.loginWithUsernamePassword=function(a,b){function c(a){if(b)return b(a);throw a}if(b&&b.length>1)return this.loginWithResourceOwner(a,b);var e,f=this;if(a.popup&&!this._callbackOnLocationHash){var g=d(i({width:500,height:600},a.popupOptions||{}));e=window.open("about:blank","auth0_signup_popup",g)}var n=i(this._getMode(),a,{client_id:this._clientID,redirect_uri:this._callbackURL,username:a.username||a.email,tenant:this._domain.split(".")[0]}),o="/usernamepassword/login";return l()?k("https://"+this._domain+o+"?"+h.stringify(n),{param:"cbx",timeout:15e3},function(c,d){if(c)return e&&e.close(),b(c);if("error"in d){e&&e.close();var g=new m(d.status,d.error);return b(g)}f._renderAndSubmitWSFedForm(a,d.form)}):(j({url:"https://"+this._domain+o,method:"post",type:"html",data:n,crossOrigin:!0,success:function(b){f._renderAndSubmitWSFedForm(a,b)}}).fail(function(a){var b=a;e&&e.close(),b.status&&0!==b.status||(b={},b.status=401,b.responseText={code:"invalid_user_password"});var d=new m(b.status,b.responseText);return c(d)}),void 0)},c.prototype.getDelegationToken=function(a,b,c,d){"function"==typeof c&&(d=c,c={}),c.id_token=b;var e=i({grant_type:"urn:ietf:params:oauth:grant-type:jwt-bearer",target:a,client_id:this._clientID},c),f="/delegation";return l()?k("https://"+this._domain+f+"?"+h.stringify(e),{param:"cbx",timeout:15e3},function(a,b){if(a)return d(a);if("error"in b){var c=new m(b.status,b.error_description||b.error);return d(c)}d(null,b)}):(j({url:"https://"+this._domain+f,method:"post",type:"json",data:e,crossOrigin:!0,success:function(a){d(null,a)}}).fail(function(a){try{d(JSON.parse(a.responseText))}catch(b){var c=a;c.status&&0!==c.status||(c={},c.status=401,c.responseText={code:"invalid_operation"}),d(new m(c.status,c.responseText))}}),void 0)},c.prototype.logout=function(a){var b="https://"+this._domain+"/logout";a&&(b+="?"+h.stringify(a)),this._redirect(b)},c.prototype.getSSOData=function(a,b){"function"==typeof a&&(b=a,a=!1);var c="https://"+this._domain+"/user/ssodata";return a&&(c+="?"+h.stringify({ads:1,client_id:this._clientID})),k(c,{param:"cbx",timeout:15e3},function(a,c){b(null,a?{}:c)})},c.prototype.getConnections=function(a){return k("https://"+this._domain+"/public/api/"+this._clientID+"/connections",{param:"cbx",timeout:15e3},a)},b.exports=c},{"./LoginError":1,"./assert_required":2,"./base64_url_decode":3,"./json_parse":5,"./use_jsonp":6,jsonp:9,qs:10,reqwest:11,xtend:13}],5:[function(require,module,exports){module.exports=function(str){return window.JSON?window.JSON.parse(str):eval("("+str+")")}},{}],6:[function(a,b){b.exports=function(){var a=window.XMLHttpRequest?new XMLHttpRequest:null;return a&&"withCredentials"in a?!1:"XDomainRequest"in window&&"http:"===window.location.protocol}},{}],7:[function(a,b,c){!function(){var a="undefined"!=typeof c?c:this,b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",d=function(){try{document.createElement("$")}catch(a){return a}}();a.btoa||(a.btoa=function(a){for(var c,e,f=0,g=b,h="";a.charAt(0|f)||(g="=",f%1);h+=g.charAt(63&c>>8-8*(f%1))){if(e=a.charCodeAt(f+=.75),e>255)throw d;c=c<<8|e}return h}),a.atob||(a.atob=function(a){if(a=a.replace(/=+$/,""),1==a.length%4)throw d;for(var c,e,f=0,g=0,h="";e=a.charAt(g++);~e&&(c=f%4?64*c+e:e,f++%4)?h+=String.fromCharCode(255&c>>(6&-2*f)):0)e=b.indexOf(e);return h})}()},{}],8:[function(a,b){function c(a){return c.enabled(a)?function(b){b=d(b);var e=new Date,f=e-(c[a]||e);c[a]=e,b=a+" "+b+" +"+c.humanize(f),window.console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}:function(){}}function d(a){return a instanceof Error?a.stack||a.message:a}b.exports=c,c.names=[],c.skips=[],c.enable=function(a){try{localStorage.debug=a}catch(b){}for(var d=(a||"").split(/[\s,]+/),e=d.length,f=0;e>f;f++)a=d[f].replace("*",".*?"),"-"===a[0]?c.skips.push(new RegExp("^"+a.substr(1)+"$")):c.names.push(new RegExp("^"+a+"$"))},c.disable=function(){c.enable("")},c.humanize=function(a){var b=1e3,c=6e4,d=60*c;return a>=d?(a/d).toFixed(1)+"h":a>=c?(a/c).toFixed(1)+"m":a>=b?(0|a/b)+"s":a+"ms"},c.enabled=function(a){for(var b=0,d=c.skips.length;d>b;b++)if(c.skips[b].test(a))return!1;for(var b=0,d=c.names.length;d>b;b++)if(c.names[b].test(a))return!0;return!1};try{window.localStorage&&c.enable(localStorage.debug)}catch(e){}},{}],9:[function(a,b){function c(){}function d(a,b,d){function g(){m.parentNode.removeChild(h),window["__jp"+n]=c}"function"==typeof b&&(d=b,b={});var h,i,b=b||{},j=b.param||"callback",k=null!=b.timeout?b.timeout:6e4,l=encodeURIComponent,m=document.getElementsByTagName("script")[0],n=f++;k&&(i=setTimeout(function(){g(),d&&d(new Error("Timeout"))},k)),window["__jp"+n]=function(a){e("jsonp got",a),i&&clearTimeout(i),g(),d&&d(null,a)},a+=(~a.indexOf("?")?"&":"?")+j+"="+l("__jp"+n),a=a.replace("?&","?"),e('jsonp req "%s"',a),h=document.createElement("script"),h.src=a,m.parentNode.insertBefore(h,m)}var e=a("debug")("jsonp");b.exports=d;var f=0},{debug:8}],10:[function(a,b,c){function d(){return t?Object.create(null):{}}function e(a,b){if(0==a[b].length)return a[b]=d();var c=d();for(var e in a[b])s.call(a[b],e)&&(c[e]=a[b][e]);return a[b]=c,c}function f(a,b,c,d){var g=a.shift();if(g){var h=b[c]=b[c]||[];"]"==g?v(h)?""!=d&&h.push(d):"object"==typeof h?h[w(h).length]=d:h=b[c]=[b[c],d]:~u(g,"]")?(g=g.substr(0,g.length-1),!z.test(g)&&v(h)&&(h=e(b,c)),f(a,h,g,d)):(!z.test(g)&&v(h)&&(h=e(b,c)),f(a,h,g,d))}else v(b[c])?b[c].push(d):b[c]="object"==typeof b[c]?d:"undefined"==typeof b[c]?d:[b[c],d]}function g(a,b,c){if(~u(b,"]")){var e=b.split("[");e.length,f(e,a,"base",c)}else{if(!z.test(b)&&v(a.base)){var g=d();for(var h in a.base)g[h]=a.base[h];a.base=g}o(a.base,b,c)}return a}function h(a){if("object"!=typeof a)return a;if(v(a)){var b=[];for(var c in a)s.call(a,c)&&b.push(a[c]);return b}for(var d in a)a[d]=h(a[d]);return a}function i(a){if(!t)return a;if(v(a))return a;if(a&&"object"!=typeof a)return a;for(var b in a)s.call(a,b)&&(a[b]=i(a[b]));return a.__proto__=Object.prototype,a}function j(a){var b={base:{}};return x(w(a),function(c){g(b,c,a[c])}),h(b.base)}function k(a){var b=y(String(a).split("&"),function(a,b){var c=u(b,"="),d=p(b),e=b.substr(0,d||c),f=b.substr(d||c,b.length),f=f.substr(u(f,"=")+1,f.length);return""==e&&(e=b,f=""),""==e?a:g(a,q(e),q(f))},{base:d()}).base;return i(h(b))}function l(a,b){if(!b)throw new TypeError("stringify expects an object");return b+"="+encodeURIComponent(a)}function m(a,b){var c=[];if(!b)throw new TypeError("stringify expects an object");for(var d=0;d<a.length;d++)c.push(A(a[d],b+"["+d+"]"));return c.join("&")}function n(a,b){for(var c,d=[],e=w(a),f=0,g=e.length;g>f;++f)c=e[f],""!=c&&(null==a[c]?d.push(encodeURIComponent(c)+"="):d.push(A(a[c],b?b+"["+encodeURIComponent(c)+"]":encodeURIComponent(c))));return d.join("&")}function o(a,b,c){var d=a[b];void 0===d?a[b]=c:v(d)?d.push(c):a[b]=[d,c]}function p(a){for(var b,c,d=a.length,e=0;d>e;++e)if(c=a[e],"]"==c&&(b=!1),"["==c&&(b=!0),"="==c&&!b)return e}function q(a){try{return decodeURIComponent(a.replace(/\+/g," "))}catch(b){return a}}var r=Object.prototype.toString,s=Object.prototype.hasOwnProperty,t=function(){var a;return Object.create?(a=Object.create(null),a.__proto__=Object.prototype,a.hasOwnProperty===s):!1}(),u="function"==typeof Array.prototype.indexOf?function(a,b){return a.indexOf(b)}:function(a,b){"string"==typeof a&&"undefined"==typeof"a"[0]&&(a=a.split(""));for(var c=0;c<a.length;c++)if(a[c]===b)return c;return-1},v=Array.isArray||function(a){return"[object Array]"==r.call(a)},w=Object.keys||function(a){var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c);return b},x="function"==typeof Array.prototype.forEach?function(a,b){return a.forEach(b)}:function(a,b){for(var c=0;c<a.length;c++)b(a[c])},y=function(a,b,c){if("function"==typeof a.reduce)return a.reduce(b,c);for(var d=c,e=0;e<a.length;e++)d=b(d,a[e]);return d},z=/^[0-9]+$/;c.parse=function(a){return null==a||""==a?{}:"object"==typeof a?j(a):k(a)};var A=c.stringify=function(a,b){return v(a)?m(a,b):"[object Object]"==r.call(a)?n(a,b):"string"==typeof a?l(a,b):b+"="+encodeURIComponent(String(a))}},{}],11:[function(require,module,exports){!function(a,b,c){"undefined"!=typeof module&&module.exports?module.exports=c():"function"==typeof define&&define.amd?define(c):b[a]=c()}("reqwest",this,function(){function handleReadyState(a,b,c){return function(){return a._aborted?c(a.request):(a.request&&4==a.request[readyState]&&(a.request.onreadystatechange=noop,twoHundo.test(a.request.status)?b(a.request):c(a.request)),void 0)}}function setHeaders(a,b){var c,d=b.headers||{};d.Accept=d.Accept||defaultHeaders.accept[b.type]||defaultHeaders.accept["*"],b.crossOrigin||d[requestedWith]||(d[requestedWith]=defaultHeaders.requestedWith),d[contentType]||(d[contentType]=b.contentType||defaultHeaders.contentType);for(c in d)d.hasOwnProperty(c)&&"setRequestHeader"in a&&a.setRequestHeader(c,d[c])}function setCredentials(a,b){"undefined"!=typeof b.withCredentials&&"undefined"!=typeof a.withCredentials&&(a.withCredentials=!!b.withCredentials)}function generalCallback(a){lastValue=a}function urlappend(a,b){return a+(/\?/.test(a)?"&":"?")+b}function handleJsonp(a,b,c,d){var e=uniqid++,f=a.jsonpCallback||"callback",g=a.jsonpCallbackName||reqwest.getcallbackPrefix(e),h=new RegExp("((^|\\?|&)"+f+")=([^&]+)"),i=d.match(h),j=doc.createElement("script"),k=0,l=-1!==navigator.userAgent.indexOf("MSIE 10.0");return i?"?"===i[3]?d=d.replace(h,"$1="+g):g=i[3]:d=urlappend(d,f+"="+g),win[g]=generalCallback,j.type="text/javascript",j.src=d,j.async=!0,"undefined"==typeof j.onreadystatechange||l||(j.event="onclick",j.htmlFor=j.id="_reqwest_"+e),j.onload=j.onreadystatechange=function(){return j[readyState]&&"complete"!==j[readyState]&&"loaded"!==j[readyState]||k?!1:(j.onload=j.onreadystatechange=null,j.onclick&&j.onclick(),b(lastValue),lastValue=void 0,head.removeChild(j),k=1,void 0)},head.appendChild(j),{abort:function(){j.onload=j.onreadystatechange=null,c({},"Request is aborted: timeout",{}),lastValue=void 0,head.removeChild(j),k=1}}}function getRequest(a,b){var c,d=this.o,e=(d.method||"GET").toUpperCase(),f="string"==typeof d?d:d.url,g=d.processData!==!1&&d.data&&"string"!=typeof d.data?reqwest.toQueryString(d.data):d.data||null,h=!1;return"jsonp"!=d.type&&"GET"!=e||!g||(f=urlappend(f,g),g=null),"jsonp"==d.type?handleJsonp(d,a,b,f):(c=xhr(d),c.open(e,f,d.async===!1?!1:!0),setHeaders(c,d),setCredentials(c,d),win[xDomainRequest]&&c instanceof win[xDomainRequest]?(c.onload=a,c.onerror=b,c.onprogress=function(){},h=!0):c.onreadystatechange=handleReadyState(this,a,b),d.before&&d.before(c),h?setTimeout(function(){c.send(g)},200):c.send(g),c)}function Reqwest(a,b){this.o=a,this.fn=b,init.apply(this,arguments)}function setType(a){var b=a.match(/\.(json|jsonp|html|xml)(\?|$)/);return b?b[1]:"js"}function init(o,fn){function complete(a){for(o.timeout&&clearTimeout(self.timeout),self.timeout=null;self._completeHandlers.length>0;)self._completeHandlers.shift()(a)}function success(resp){resp="jsonp"!==type?self.request:resp;var filteredResponse=globalSetupOptions.dataFilter(resp.responseText,type),r=filteredResponse;try{resp.responseText=r}catch(e){}if(r)switch(type){case"json":try{resp=win.JSON?win.JSON.parse(r):eval("("+r+")")}catch(err){return error(resp,"Could not parse JSON in response",err)}break;case"js":resp=eval(r);break;case"html":resp=r;break;case"xml":resp=resp.responseXML&&resp.responseXML.parseError&&resp.responseXML.parseError.errorCode&&resp.responseXML.parseError.reason?null:resp.responseXML}for(self._responseArgs.resp=resp,self._fulfilled=!0,fn(resp),self._successHandler(resp);self._fulfillmentHandlers.length>0;)resp=self._fulfillmentHandlers.shift()(resp);complete(resp)}function error(a,b,c){for(a=self.request,self._responseArgs.resp=a,self._responseArgs.msg=b,self._responseArgs.t=c,self._erred=!0;self._errorHandlers.length>0;)self._errorHandlers.shift()(a,b,c);complete(a)}this.url="string"==typeof o?o:o.url,this.timeout=null,this._fulfilled=!1,this._successHandler=function(){},this._fulfillmentHandlers=[],this._errorHandlers=[],this._completeHandlers=[],this._erred=!1,this._responseArgs={};var self=this,type=o.type||setType(this.url);fn=fn||function(){},o.timeout&&(this.timeout=setTimeout(function(){self.abort()},o.timeout)),o.success&&(this._successHandler=function(){o.success.apply(o,arguments)}),o.error&&this._errorHandlers.push(function(){o.error.apply(o,arguments)}),o.complete&&this._completeHandlers.push(function(){o.complete.apply(o,arguments)}),this.request=getRequest.call(this,success,error)}function reqwest(a,b){return new Reqwest(a,b)}function normalize(a){return a?a.replace(/\r?\n/g,"\r\n"):""}function serial(a,b){var c,d,e,f,g=a.name,h=a.tagName.toLowerCase(),i=function(a){a&&!a.disabled&&b(g,normalize(a.attributes.value&&a.attributes.value.specified?a.value:a.text))};if(!a.disabled&&g)switch(h){case"input":/reset|button|image|file/i.test(a.type)||(c=/checkbox/i.test(a.type),d=/radio/i.test(a.type),e=a.value,(!(c||d)||a.checked)&&b(g,normalize(c&&""===e?"on":e)));break;case"textarea":b(g,normalize(a.value));break;case"select":if("select-one"===a.type.toLowerCase())i(a.selectedIndex>=0?a.options[a.selectedIndex]:null);else for(f=0;a.length&&f<a.length;f++)a.options[f].selected&&i(a.options[f])}}function eachFormElement(){var a,b,c=this,d=function(a,b){var d,e,f;for(d=0;d<b.length;d++)for(f=a[byTag](b[d]),e=0;e<f.length;e++)serial(f[e],c)};for(b=0;b<arguments.length;b++)a=arguments[b],/input|select|textarea/i.test(a.tagName)&&serial(a,c),d(a,["input","select","textarea"])}function serializeQueryString(){return reqwest.toQueryString(reqwest.serializeArray.apply(null,arguments))}function serializeHash(){var a={};return eachFormElement.apply(function(b,c){b in a?(a[b]&&!isArray(a[b])&&(a[b]=[a[b]]),a[b].push(c)):a[b]=c},arguments),a}function buildParams(a,b,c,d){var e,f,g,h=/\[\]$/;if(isArray(b))for(f=0;b&&f<b.length;f++)g=b[f],c||h.test(a)?d(a,g):buildParams(a+"["+("object"==typeof g?f:"")+"]",g,c,d);else if(b&&"[object Object]"===b.toString())for(e in b)buildParams(a+"["+e+"]",b[e],c,d);else d(a,b)}var win=window,doc=document,twoHundo=/^20\d$/,byTag="getElementsByTagName",readyState="readyState",contentType="Content-Type",requestedWith="X-Requested-With",head=doc[byTag]("head")[0],uniqid=0,callbackPrefix="reqwest_"+ +new Date,lastValue,xmlHttpRequest="XMLHttpRequest",xDomainRequest="XDomainRequest",noop=function(){},isArray="function"==typeof Array.isArray?Array.isArray:function(a){return a instanceof Array},defaultHeaders={contentType:"application/x-www-form-urlencoded",requestedWith:xmlHttpRequest,accept:{"*":"text/javascript, text/html, application/xml, text/xml, */*",xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript",js:"application/javascript, text/javascript"}},xhr=function(a){if(a.crossOrigin===!0){var b=win[xmlHttpRequest]?new XMLHttpRequest:null;if(b&&"withCredentials"in b)return b;if(win[xDomainRequest])return new XDomainRequest;throw new Error("Browser does not support cross-origin requests")}return win[xmlHttpRequest]?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP")},globalSetupOptions={dataFilter:function(a){return a}};return Reqwest.prototype={abort:function(){this._aborted=!0,this.request.abort()},retry:function(){init.call(this,this.o,this.fn)},then:function(a,b){return a=a||function(){},b=b||function(){},this._fulfilled?this._responseArgs.resp=a(this._responseArgs.resp):this._erred?b(this._responseArgs.resp,this._responseArgs.msg,this._responseArgs.t):(this._fulfillmentHandlers.push(a),this._errorHandlers.push(b)),this},always:function(a){return this._fulfilled||this._erred?a(this._responseArgs.resp):this._completeHandlers.push(a),this},fail:function(a){return this._erred?a(this._responseArgs.resp,this._responseArgs.msg,this._responseArgs.t):this._errorHandlers.push(a),this}},reqwest.serializeArray=function(){var a=[];return eachFormElement.apply(function(b,c){a.push({name:b,value:c})},arguments),a},reqwest.serialize=function(){if(0===arguments.length)return"";var a,b,c=Array.prototype.slice.call(arguments,0);return a=c.pop(),a&&a.nodeType&&c.push(a)&&(a=null),a&&(a=a.type),b="map"==a?serializeHash:"array"==a?reqwest.serializeArray:serializeQueryString,b.apply(null,c)},reqwest.toQueryString=function(a,b){var c,d,e=b||!1,f=[],g=encodeURIComponent,h=function(a,b){b="function"==typeof b?b():null==b?"":b,f[f.length]=g(a)+"="+g(b)};if(isArray(a))for(d=0;a&&d<a.length;d++)h(a[d].name,a[d].value);else for(c in a)buildParams(c,a[c],e,h);return f.join("&").replace(/%20/g,"+")},reqwest.getcallbackPrefix=function(){return callbackPrefix},reqwest.compat=function(a,b){return a&&(a.type&&(a.method=a.type)&&delete a.type,a.dataType&&(a.type=a.dataType),a.jsonpCallback&&(a.jsonpCallbackName=a.jsonpCallback)&&delete a.jsonpCallback,a.jsonp&&(a.jsonpCallback=a.jsonp)),new Reqwest(a,b)},reqwest.ajaxSetup=function(a){a=a||{};for(var b in a)globalSetupOptions[b]=a[b]},reqwest})},{}],12:[function(a,b){function c(a){return null!==a&&("object"==typeof a||"function"==typeof a)}b.exports=c},{}],13:[function(a,b){function c(){for(var a={},b=0;b<arguments.length;b++){var c=arguments[b];if(e(c))for(var f=d(c),g=0;g<f.length;g++){var h=f[g];a[h]=c[h]}}return a}var d=a("object-keys"),e=a("./has-keys");b.exports=c},{"./has-keys":12,"object-keys":15}],14:[function(a,b){var c=Object.prototype.hasOwnProperty,d=Object.prototype.toString,e=function(a){var b="function"==typeof a&&!(a instanceof RegExp)||"[object Function]"===d.call(a);return b||"undefined"==typeof window||(b=a===window.setTimeout||a===window.alert||a===window.confirm||a===window.prompt),b};b.exports=function(a,b){if(!e(b))throw new TypeError("iterator must be a function");var d,f,g="string"==typeof a,h=a.length,i=arguments.length>2?arguments[2]:null;if(h===+h)for(d=0;h>d;d++)null===i?b(g?a.charAt(d):a[d],d,a):b.call(i,g?a.charAt(d):a[d],d,a);else for(f in a)c.call(a,f)&&(null===i?b(a[f],f,a):b.call(i,a[f],f,a))}},{}],15:[function(a,b){b.exports=Object.keys||a("./shim")},{"./shim":17}],16:[function(a,b){var c=Object.prototype.toString;b.exports=function d(a){var b=c.call(a),d="[object Arguments]"===b;return d||(d="[object Array]"!==b&&null!==a&&"object"==typeof a&&"number"==typeof a.length&&a.length>=0&&"[object Function]"===c.call(a.callee)),d}},{}],17:[function(a,b){!function(){"use strict";var c,d=Object.prototype.hasOwnProperty,e=Object.prototype.toString,f=a("./foreach"),g=a("./isArguments"),h=!{toString:null}.propertyIsEnumerable("toString"),i=function(){}.propertyIsEnumerable("prototype"),j=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"];c=function(a){var b=null!==a&&"object"==typeof a,c="[object Function]"===e.call(a),k=g(a),l=[];if(!b&&!c&&!k)throw new TypeError("Object.keys called on a non-object");if(k)f(a,function(a){l.push(a)});else{var m,n=i&&c;for(m in a)n&&"prototype"===m||!d.call(a,m)||l.push(m)}if(h){var o=a.constructor,p=o&&o.prototype===a;f(j,function(b){p&&"constructor"===b||!d.call(a,b)||l.push(b)})}return l},b.exports=c}()},{"./foreach":14,"./isArguments":16}],18:[function(a){var b="undefined"!=typeof self?self:"undefined"!=typeof window?window:{},c=a("./lib/index");"function"==typeof b.window.define&&b.window.define.amd?b.window.define("auth0",function(){return c}):b.window&&(b.window.Auth0=c)},{"./lib/index":4}]},{},[18]);

@@ -17,2 +17,6 @@ ;(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

if (obj && !obj.code) {
obj.code = obj.error;
}
var err = Error.call(this, obj.description || obj.message || obj.error);

@@ -116,7 +120,8 @@

Auth0.prototype.getProfile = function (hash, callback, errCallback) {
Auth0.prototype.getProfile = function (token, callback) {
if (!token) { return; }
var self = this;
var fail = function (status, description) {
errCallback({
callback({
error: status,

@@ -143,3 +148,3 @@ error_description: description

return resp.status === 200 ?
callback(resp.user, id_token, access_token, state) :
callback(null, resp.user, id_token, access_token, state) :
fail(resp.status, resp.error);

@@ -160,12 +165,21 @@ });

}).then(function (userinfo) {
callback(userinfo, id_token, access_token, state);
callback(null, userinfo, id_token, access_token, state);
});
}
callback(profile, id_token, access_token, state);
callback(null, profile, id_token, access_token, state);
};
self.parseHash(hash, getUserInfo, errCallback);
if (typeof token === 'string') { // token is a hash
return self.parseHash(token, getUserInfo, callback);
}
getUserInfo(this.decodeJwt(token.id_token), token.id_token, token.access_token);
};
Auth0.prototype.decodeJwt = function (jwt) {
var encoded = jwt && jwt.split('.')[1];
return json_parse(base64_url_decode(encoded));
};
Auth0.prototype.parseHash = function (hash, callback, errCallback) {

@@ -185,4 +199,3 @@ if (hash.match(/error/)) {

var id_token = parsed_qs.id_token;
var encoded = id_token.split('.')[1];
var prof = json_parse(base64_url_decode(encoded));
var prof = this.decodeJwt(id_token);
var invalidJwt = function (error) {

@@ -403,3 +416,62 @@ if (!errCallback) { return; }

Auth0.prototype.loginWithResourceOwner = function (options, callback) {
var self = this;
var query = xtend(
this._getMode(),
options,
{
client_id: this._clientID,
username: options.username || options.email,
grant_type: 'password'
});
var endpoint = '/oauth/ro';
if (use_jsonp()) {
return jsonp('https://' + this._domain + endpoint + '?' + qs.stringify(query), {
param: 'cbx',
timeout: 15000
}, function (err, resp) {
if (err) {
return callback(err);
}
if('error' in resp) {
var error = new LoginError(resp.status, resp.error);
return callback(error);
}
self.getProfile(resp, callback);
});
}
reqwest({
url: 'https://' + this._domain + endpoint,
method: 'post',
type: 'json',
data: query,
crossOrigin: true,
success: function (resp) {
self.getProfile(resp, callback);
}
}).fail(function (err) {
var er = err;
if (!er.status || er.status === 0) { //ie10 trick
er = {};
er.status = 401;
er.responseText = {
code: 'invalid_user_password'
};
}
else {
er.responseText = err;
}
var error = new LoginError(er.status, er.responseText);
callback(error);
});
};
Auth0.prototype.loginWithUsernamePassword = function (options, callback) {
if (callback && callback.length > 1) {
return this.loginWithResourceOwner(options, callback);
}
var self = this;

@@ -406,0 +478,0 @@ var popup;

@@ -51,7 +51,8 @@ var assert_required = require('./assert_required');

Auth0.prototype.getProfile = function (hash, callback, errCallback) {
Auth0.prototype.getProfile = function (token, callback) {
if (!token) { return; }
var self = this;
var fail = function (status, description) {
errCallback({
callback({
error: status,

@@ -78,3 +79,3 @@ error_description: description

return resp.status === 200 ?
callback(resp.user, id_token, access_token, state) :
callback(null, resp.user, id_token, access_token, state) :
fail(resp.status, resp.error);

@@ -95,12 +96,21 @@ });

}).then(function (userinfo) {
callback(userinfo, id_token, access_token, state);
callback(null, userinfo, id_token, access_token, state);
});
}
callback(profile, id_token, access_token, state);
callback(null, profile, id_token, access_token, state);
};
self.parseHash(hash, getUserInfo, errCallback);
if (typeof token === 'string') { // token is a hash
return self.parseHash(token, getUserInfo, callback);
}
getUserInfo(this.decodeJwt(token.id_token), token.id_token, token.access_token);
};
Auth0.prototype.decodeJwt = function (jwt) {
var encoded = jwt && jwt.split('.')[1];
return json_parse(base64_url_decode(encoded));
};
Auth0.prototype.parseHash = function (hash, callback, errCallback) {

@@ -120,4 +130,3 @@ if (hash.match(/error/)) {

var id_token = parsed_qs.id_token;
var encoded = id_token.split('.')[1];
var prof = json_parse(base64_url_decode(encoded));
var prof = this.decodeJwt(id_token);
var invalidJwt = function (error) {

@@ -338,3 +347,62 @@ if (!errCallback) { return; }

Auth0.prototype.loginWithResourceOwner = function (options, callback) {
var self = this;
var query = xtend(
this._getMode(),
options,
{
client_id: this._clientID,
username: options.username || options.email,
grant_type: 'password'
});
var endpoint = '/oauth/ro';
if (use_jsonp()) {
return jsonp('https://' + this._domain + endpoint + '?' + qs.stringify(query), {
param: 'cbx',
timeout: 15000
}, function (err, resp) {
if (err) {
return callback(err);
}
if('error' in resp) {
var error = new LoginError(resp.status, resp.error);
return callback(error);
}
self.getProfile(resp, callback);
});
}
reqwest({
url: 'https://' + this._domain + endpoint,
method: 'post',
type: 'json',
data: query,
crossOrigin: true,
success: function (resp) {
self.getProfile(resp, callback);
}
}).fail(function (err) {
var er = err;
if (!er.status || er.status === 0) { //ie10 trick
er = {};
er.status = 401;
er.responseText = {
code: 'invalid_user_password'
};
}
else {
er.responseText = err;
}
var error = new LoginError(er.status, er.responseText);
callback(error);
});
};
Auth0.prototype.loginWithUsernamePassword = function (options, callback) {
if (callback && callback.length > 1) {
return this.loginWithResourceOwner(options, callback);
}
var self = this;

@@ -341,0 +409,0 @@ var popup;

@@ -16,2 +16,6 @@ var json_parse = require('./json_parse');

if (obj && !obj.code) {
obj.code = obj.error;
}
var err = Error.call(this, obj.description || obj.message || obj.error);

@@ -18,0 +22,0 @@

{
"name": "auth0-js",
"version": "1.4.3",
"version": "1.5.2",
"description": "Auth0 headless browser sdk",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -74,2 +74,14 @@ [![Build Status](https://auth0-tc-hub.herokuapp.com/bt21/status.png)](https://auth0-tc-hub.herokuapp.com/bt21)

});
//trigger login with a db connection and avoid the redirect (best experience for SPA)
$('.login-dbconn').click(function () {
auth0.login({
connection: 'github',
username: $('.username').val(),
password: $('.password').val(),
},
function (err, profile, id_token, access_token) {
// store in cookies
});
});

@@ -95,3 +107,3 @@ //trigger login popup with google

$(function () {
auth0.getProfile(window.location.hash, function (profile, id_token, access_token, state) {
auth0.getProfile(window.location.hash, function (err, profile, id_token, access_token, state) {
alert('hello ' + profile.name);

@@ -98,0 +110,0 @@ //use id_token to call your rest api

@@ -197,17 +197,38 @@ describe('Auth0', function () {

it('should be able to parse the id_token and get the profile', function (done) {
var hash = "#access_token=kQGIQpDnmFjhEeLS&id_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL21kb2NzLmF1dGgwLmNvbS8iLCJzdWIiOiJhdXRoMHw0QVpERjU2Nzg5IiwiYXVkIjoiMEhQNzFHU2Q2UHVvUllKM0RYS2RpWENVVWRHbUJidXAiLCJleHAiOjEzOTM1NDUxMDcsImlhdCI6MTM5MzUwOTEwN30.oXcIvvxNEGNAzUnvTFFEn3SBSoCIrnRrEQllzP56X-c&token_type=bearer&state=Ttct3tBlHDhRnXCv";
describe('from hash', function () {
var auth0 = Auth0({
clientID: '0HP71GSd6PuoRYJ3DXKdiXCUUdGmBbup',
callbackURL: 'https://myapp.com/callback',
domain: 'mdocs.auth0.com'
it('should be able to parse the id_token and get the profile', function (done) {
var hash = "#access_token=jFxsZUQTJXXwcwIm&id_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL2xvZ2luLmF1dGgwLmNvbS8iLCJzdWIiOiJnb29nbGUtb2F1dGgyfDExODMwNDIzMTY0MDMwMTY4NTU3OSIsImF1ZCI6IjBIUDcxR1NkNlB1b1JZSjNEWEtkaVhDVVVkR21CYnVwIiwiZXhwIjoxMzgwMjU4NzU4LCJpYXQiOjEzODAyMjI3NTgsImNsaWVudElEIjoiMEhQNzFHU2Q2UHVvUllKM0RYS2RpWENVVWRHbUJidXAiLCJlbWFpbCI6Impvc2Uucm9tYW5pZWxsb0BxcmFmdGxhYnMuY29tIiwiZmFtaWx5X25hbWUiOiJSb21hbmllbGxvIiwiZ2VuZGVyIjoibWFsZSIsImdpdmVuX25hbWUiOiJKb3NlIiwiaWRlbnRpdGllcyI6W3siYWNjZXNzX3Rva2VuIjoieWEyOS5BSEVTNlpUSllmQnN3a1NFbUU2YTQ2SlpHYVgxV1Jqc2ZrUzd5Vm81RXNPdktKWVhnenpEZl9ZUiIsInByb3ZpZGVyIjoiZ29vZ2xlLW9hdXRoMiIsInVzZXJfaWQiOiIxMTgzMDQyMzE2NDAzMDE2ODU1NzkiLCJjb25uZWN0aW9uIjoiZ29vZ2xlLW9hdXRoMiIsImlzU29jaWFsIjp0cnVlfV0sImxvY2FsZSI6ImVuIiwibmFtZSI6Ikpvc2UgUm9tYW5pZWxsbyIsIm5pY2tuYW1lIjoiam9zZS5yb21hbmllbGxvIiwicGljdHVyZSI6Imh0dHBzOi8vbGg2Lmdvb2dsZXVzZXJjb250ZW50LmNvbS8tcF81dUwxTDFkdkUvQUFBQUFBQUFBQUkvQUFBQUFBQUFBQlEvaVBIRUQ0ajlxblkvcGhvdG8uanBnIiwidXNlcl9pZCI6Imdvb2dsZS1vYXV0aDJ8MTE4MzA0MjMxNjQwMzAxNjg1NTc5In0.Qrhrkp7hCYFyN_Ax9yVPKztuJNFHjnGbyUfLJsccLGU&token_type=bearer&state=Ttct3tBlHDhRnXCv";
var auth0 = Auth0({
clientID: '0HP71GSd6PuoRYJ3DXKdiXCUUdGmBbup',
callbackURL: 'https://myapp.com/callback',
domain: 'login.auth0.com'
});
auth0.getProfile(hash, function (err, profile, id_token, access_token, state) {
expect(profile.name).to.eql('Jose Romaniello');
expect(profile.identities.length).to.eql(1);
expect(access_token).to.eql('jFxsZUQTJXXwcwIm');
expect(state).to.eql('Ttct3tBlHDhRnXCv');
done();
});
});
auth0.getProfile(hash, function (profile, id_token, access_token, state) {
expect(profile.name).to.eql('John Foo');
expect(profile.identities.length).to.eql(1);
expect(access_token).to.eql('kQGIQpDnmFjhEeLS');
expect(state).to.eql('Ttct3tBlHDhRnXCv');
done();
it('should be able to parse an error', function (done) {
var hash = '#error=invalid_grant&error_description=this%20is%20a%20cool%20error%20description';
var auth0 = Auth0({
clientID: 'aaaabcdefgh',
callbackURL: 'https://myapp.com/callback',
domain: 'aaa.auth0.com'
});
auth0.getProfile(hash, function (err) {
expect(err.error).to.be.equal('invalid_grant');
expect(err.error_description).to.be.equal('this is a cool error description');
done();
});
});

@@ -217,24 +238,26 @@

it('should be able to parse an error', function (done) {
var hash = '#error=invalid_grant&error_description=this%20is%20a%20cool%20error%20description';
describe('from token', function () {
var auth0 = Auth0({
clientID: 'aaaabcdefgh',
callbackURL: 'https://myapp.com/callback',
domain: 'aaa.auth0.com'
});
it('should be able to take the id_token and get the profile', function (done) {
var auth0 = Auth0({
clientID: '0HP71GSd6PuoRYJ3DXKdiXCUUdGmBbup',
callbackURL: 'https://myapp.com/callback',
domain: 'mdocs.auth0.com'
});
function neverCall() {
// should never call success as it fails
expect(false).to.be.equal(true);
}
var token = {
access_token: 'jFxsZUQTJXXwcwIm',
id_token: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL2xvZ2luLmF1dGgwLmNvbS8iLCJzdWIiOiJnb29nbGUtb2F1dGgyfDExODMwNDIzMTY0MDMwMTY4NTU3OSIsImF1ZCI6IjBIUDcxR1NkNlB1b1JZSjNEWEtkaVhDVVVkR21CYnVwIiwiZXhwIjoxMzgwMjU4NzU4LCJpYXQiOjEzODAyMjI3NTgsImNsaWVudElEIjoiMEhQNzFHU2Q2UHVvUllKM0RYS2RpWENVVWRHbUJidXAiLCJlbWFpbCI6Impvc2Uucm9tYW5pZWxsb0BxcmFmdGxhYnMuY29tIiwiZmFtaWx5X25hbWUiOiJSb21hbmllbGxvIiwiZ2VuZGVyIjoibWFsZSIsImdpdmVuX25hbWUiOiJKb3NlIiwiaWRlbnRpdGllcyI6W3siYWNjZXNzX3Rva2VuIjoieWEyOS5BSEVTNlpUSllmQnN3a1NFbUU2YTQ2SlpHYVgxV1Jqc2ZrUzd5Vm81RXNPdktKWVhnenpEZl9ZUiIsInByb3ZpZGVyIjoiZ29vZ2xlLW9hdXRoMiIsInVzZXJfaWQiOiIxMTgzMDQyMzE2NDAzMDE2ODU1NzkiLCJjb25uZWN0aW9uIjoiZ29vZ2xlLW9hdXRoMiIsImlzU29jaWFsIjp0cnVlfV0sImxvY2FsZSI6ImVuIiwibmFtZSI6Ikpvc2UgUm9tYW5pZWxsbyIsIm5pY2tuYW1lIjoiam9zZS5yb21hbmllbGxvIiwicGljdHVyZSI6Imh0dHBzOi8vbGg2Lmdvb2dsZXVzZXJjb250ZW50LmNvbS8tcF81dUwxTDFkdkUvQUFBQUFBQUFBQUkvQUFBQUFBQUFBQlEvaVBIRUQ0ajlxblkvcGhvdG8uanBnIiwidXNlcl9pZCI6Imdvb2dsZS1vYXV0aDJ8MTE4MzA0MjMxNjQwMzAxNjg1NTc5In0.Qrhrkp7hCYFyN_Ax9yVPKztuJNFHjnGbyUfLJsccLGU'
};
auth0.getProfile(hash, neverCall, function (error) {
expect(error.error).to.be.equal('invalid_grant');
expect(error.error_description).to.be.equal('this is a cool error description');
done();
auth0.getProfile(token, function (err, profile, id_token, access_token) {
expect(profile.name).to.eql('Jose Romaniello');
expect(profile.identities.length).to.eql(1);
expect(access_token).to.eql('jFxsZUQTJXXwcwIm');
done();
});
});
});
});

@@ -241,0 +264,0 @@

@@ -9,98 +9,90 @@ describe('Auth0 - User And Passwords', function () {

describe('Login', function () {
it('should call the callback when user/pass is wrong', function (done) {
auth0.login({
connection: 'tests',
username: 'testttt@wrong.com',
password: '12345'
}, function (err) {
expect(err.status).to.equal(401);
expect(err.details.code).to.equal('invalid_user_password');
done();
describe('with resource owner', function () {
it('should call the callback when user/pass is wrong', function (done) {
auth0.login({
connection: 'tests',
username: 'testttt@wrong.com',
password: '12345'
}, function (err, profile) {
expect(err.status).to.equal(401);
expect(err.details.code).to.equal('invalid_user_password');
done();
});
});
});
it('should call the callback with err when the connection doesn\'t exists', function (done) {
auth0.login({
connection: 'testsw3eeasdsadsa',
username: 'testttt@wrong.com',
password: '12345'
}, function (err) {
expect(err.status).to.equal(404);
expect(err.message).to.match(/connection not found/ig);
done();
it.skip('should call the callback with err when the connection doesn\'t exists', function (done) {
auth0.login({
connection: 'testsw3eeasdsadsa',
username: 'testttt@wrong.com',
password: '12345'
}, function (err, profile) {
expect(err.status).to.equal(400);
expect(err.message).to.equal('invalid_connection');
done();
});
});
});
it('should render wsfed form after successfull authentication', function (done) {
auth0._renderAndSubmitWSFedForm = function (options, htmlForm) {
expect(htmlForm).to.match(/<form/);
done();
};
it('should return profile after successfull authentication', function (done) {
auth0.login({
connection: 'tests',
username: 'johnfoo@gmail.com',
password: '12345'
}, function (err, profile, id_token, access_token) {
expect(profile.name).to.eql('John Foo');
expect(profile.identities.length).to.eql(1);
expect(id_token).to.exist;
expect(access_token).to.exist;
done();
});
});
auth0.login({
connection: 'tests',
username: 'johnfoo@gmail.com',
password: '12345'
});
});
/*if (!navigator.userAgent.match(/iPad|iPhone|iPod/g)) {
it('should return SSO data after successfull authentication', function (done) {
forceLogout('mdocs.auth0.com', function () {
var loginStarted;
var iframe = document.createElement('iframe');
iframe.name = 'test-iframe';
iframe.style.display = 'none';
iframe.onload = function() {
if (!loginStarted) return;
describe('with wsfed', function () {
auth0.getSSOData(function (err, ssoData) {
expect(ssoData.sso).to.eql(true);
expect(ssoData.lastUsedClientID).to.eql('ptR6URmXef0OfBDHK0aCIy7iPKpdCG4t');
expect(ssoData.lastUsedUsername).to.eql('johnfoo@gmail.com');
expect(ssoData.lastUsedConnection).to.exist;
expect(ssoData.lastUsedConnection.name).to.eql('tests');
expect(ssoData.lastUsedConnection.strategy).to.eql('auth0');
done();
});
};
it('should call the callback when user/pass is wrong', function (done) {
auth0.login({
connection: 'tests',
username: 'testttt@wrong.com',
password: '12345'
}, function (err) {
expect(err.status).to.equal(401);
expect(err.details.code).to.equal('invalid_user_password');
done();
});
});
document.body.appendChild(iframe);
it('should call the callback with err when the connection doesn\'t exists', function (done) {
auth0.login({
connection: 'testsw3eeasdsadsa',
username: 'testttt@wrong.com',
password: '12345'
}, function (err) {
expect(err.status).to.equal(404);
expect(err.message).to.match(/connection not found/ig);
done();
});
});
auth0._renderAndSubmitWSFedForm = function (options, formHtml) {
var div = document.createElement('div');
div.innerHTML = formHtml;
var form = document.body.appendChild(div).children[0];
form.setAttribute('target', 'test-iframe');
form.submit();
loginStarted = true;
};
it('should render wsfed form after successfull authentication', function (done) {
auth0._renderAndSubmitWSFedForm = function (options, htmlForm) {
expect(htmlForm).to.match(/<form/);
done();
};
auth0.login({
connection: 'tests',
username: 'johnfoo@gmail.com',
password: '12345'
});
auth0.login({
connection: 'tests',
username: 'johnfoo@gmail.com',
password: '12345'
});
});
}*/
});
});
describe('Signup', function () {
it('should render wsfed form after successfull signup', function (done) {
auth0._renderAndSubmitWSFedForm = function (options, htmlForm) {
console.log(htmlForm);
expect(htmlForm).to.match(/<form/);
done();
};
auth0.signup({
connection: 'tests',
username: 'johnfoo@gmail.com',
password: '12345'
}, function (err) {
done(err);
});
});
it('should fail when the username is null', function (done) {

@@ -132,16 +124,69 @@ auth0.signup({

it('should not render wsfed form after successfull signup if auto_login is false', function (done) {
auth0._renderAndSubmitWSFedForm = function (options, htmlForm) {
done(new Error('this should not be called'));
};
describe('with resource owner authentication', function () {
auth0.signup({
connection: 'tests',
username: 'johnfoo@gmail.com',
password: '12345',
auto_login: false
}, function (err) {
done(err);
it('should return profile after successfull signup', function (done) {
auth0.signup({
connection: 'tests',
username: 'johnfoo@gmail.com',
password: '12345'
}, function (err, profile, id_token, access_token) {
expect(profile.name).to.eql('John Foo');
expect(profile.identities.length).to.eql(1);
expect(id_token).to.exist;
expect(access_token).to.exist;
done();
});
});
it('should not return profile after successfull signup if auto_login is false', function (done) {
auth0._renderAndSubmitWSFedForm = function (options, htmlForm) {
done(new Error('this should not be called'));
};
auth0.signup({
connection: 'tests',
username: 'johnfoo@gmail.com',
password: '12345',
auto_login: false
}, function (err, profile) {
done(profile);
});
});
});
describe('with wsfed authentication', function () {
it('should render wsfed form after successfull signup', function (done) {
auth0._renderAndSubmitWSFedForm = function (options, htmlForm) {
expect(htmlForm).to.match(/<form/);
done();
};
auth0.signup({
connection: 'tests',
username: 'johnfoo@gmail.com',
password: '12345'
}, function (err) {
done(err);
});
});
it('should not render wsfed form after successfull signup if auto_login is false', function (done) {
auth0._renderAndSubmitWSFedForm = function (options, htmlForm) {
done(new Error('this should not be called'));
};
auth0.signup({
connection: 'tests',
username: 'johnfoo@gmail.com',
password: '12345',
auto_login: false
}, function (err) {
done(err);
});
});
});
});

@@ -148,0 +193,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc