Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

auth0-angular

Package Overview
Dependencies
Maintainers
3
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

auth0-angular - npm Package Compare versions

Comparing version 2.2.7 to 2.2.9

2

bower.json

@@ -6,3 +6,2 @@ {

"angular": "*",
"angular-cookies": "*",
"auth0.js": "~4.2",

@@ -12,2 +11,3 @@ "auth0-widget.js": ">= 5.2.5"

"devDependencies": {
"angular-cookies": "*",
"angular-mocks": "~1.2.16",

@@ -14,0 +14,0 @@ "angular-route": "~1.2.16"

@@ -7,2 +7,7 @@ (function () {

'auth0.utils'
]).run([
'auth',
function (auth) {
auth.hookEvents();
}
]);

@@ -70,2 +75,5 @@ angular.module('auth0.utils', []).provider('authUtils', function () {

};
authUtils.isWidget = function (lib) {
return lib && lib.getClient;
};
authUtils.promisify = function (nodeback, self) {

@@ -113,31 +121,46 @@ if (angular.isFunction(nodeback)) {

});
angular.module('auth0.interceptor', []).factory('authInterceptor', [
'$rootScope',
'$q',
'$injector',
function ($rootScope, $q, $injector) {
return {
request: function (config) {
// When using auth dependency is never loading, we need to do this manually
// This issue should be related with: https://github.com/angular/angular.js/issues/2367
if (!$injector.has('auth')) {
angular.module('auth0.interceptor', []).provider('authInterceptor', function () {
var skipJWT = 'skipAuthorization';
var authHeader = 'Authorization';
var authPrefix = 'Bearer ';
this.setSkipJWT = function (name) {
skipJWT = name || skipJWT;
};
this.setAuthHeader = function (name) {
authHeader = name || authHeader;
};
this.setAuthPrefix = function (name) {
authPrefix = name || authPrefix;
};
this.$get = [
'$rootScope',
'$q',
'$injector',
function ($rootScope, $q, $injector) {
var auth;
return {
request: function (config) {
// When using auth dependency is never loading, we need to do this manually
// This issue should be related with: https://github.com/angular/angular.js/issues/2367
if (config[skipJWT] || !$injector.has('auth')) {
return config;
}
auth = auth || $injector.get('auth');
config.headers = config.headers || {};
if (auth.idToken && !config.headers[authHeader]) {
config.headers[authHeader] = authPrefix + auth.idToken;
}
return config;
},
responseError: function (response) {
// handle the case where the user is not authenticated
if (response.status === 401) {
$rootScope.$broadcast('auth0.forbiddenRequest', response);
}
return $q.reject(response);
}
var auth = $injector.get('auth');
config.headers = config.headers || {};
if (auth.idToken && !config.headers.Authorization) {
config.headers.Authorization = 'Bearer ' + auth.idToken;
}
return config;
},
responseError: function (response) {
// handle the case where the user is not authenticated
if (response.status === 401) {
$rootScope.$broadcast('auth0.forbidden', response);
}
return $q.reject(response);
}
};
}
]);
};
}
];
});
angular.module('auth0.storage', []).service('authStorage', [

@@ -266,2 +289,3 @@ '$injector',

var callHandler = function (anEvent, locals) {
$rootScope.$broadcast('auth0.' + anEvent, locals);
angular.forEach(getHandlers(anEvent) || [], function (handler) {

@@ -311,3 +335,3 @@ $injector.invoke(handler, auth, locals);

if (storedValues.refreshToken) {
refreshingToken = auth.refreshToken(storedValues.refreshToken);
refreshingToken = auth.refreshIdToken(storedValues.refreshToken);
refreshingToken.then(function (idToken) {

@@ -317,3 +341,3 @@ onSigninOk(idToken, storedValues.accessToken, storedValues.state, storedValues.refreshToken, true);

forbidden();
}).finally(function () {
})['finally'](function () {
refreshingToken = null;

@@ -349,3 +373,3 @@ });

});
$rootScope.$on('auth0.forbidden', function () {
$rootScope.$on('auth0.forbiddenRequest', function () {
forbidden();

@@ -435,3 +459,3 @@ });

};
auth.refreshToken = function (refresh_token) {
auth.refreshIdToken = function (refresh_token) {
var refreshTokenAsync = authUtils.promisify(config.auth0js.refreshToken, config.auth0js);

@@ -464,3 +488,3 @@ return refreshTokenAsync(refresh_token || auth.refreshToken).then(function (delegationResult) {

}, auth0lib);
if (config.isWidget) {
if (authUtils.isWidget(auth0lib)) {
signinCall(options, null);

@@ -467,0 +491,0 @@ } else {

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

!function(){angular.module("auth0",["auth0.storage","auth0.service","auth0.interceptor","auth0.utils"]),angular.module("auth0.utils",[]).provider("authUtils",function(){var a={capitalize:function(a){return a?a.charAt(0).toUpperCase()+a.substring(1).toLowerCase():null},urlBase64Decode: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 window.atob(b)}};angular.extend(this,a),this.$get=["$rootScope","$q",function(b,c){var d={};return angular.extend(d,a),d.safeApply=function(a){var c=b.$root.$$phase;"$apply"===c||"$digest"===c?a&&"function"==typeof a&&a():b.$apply(a)},d.callbackify=function(a,b,c,e){return angular.isFunction(a)?function(f){f=Array.prototype.slice.call(arguments);var g=function(a,d,e){return a?void(c&&c(a)):(e=Array.prototype.slice.call(arguments,1),void(b&&b.apply(null,e)))};f.push(d.applied(g)),a.apply(e,f)}:void 0},d.promisify=function(a,b){return angular.isFunction(a)?function(e){e=Array.prototype.slice.call(arguments);var f=c.defer(),g=function(a,b,c){return a?void f.reject(a):(c=Array.prototype.slice.call(arguments,1),void f.resolve(c.length>1?c:b))};return e.push(d.applied(g)),a.apply(b,e),f.promise.spread=f.promise.spread||function(a,b){return f.promise.then(function(b){return Array.isArray(b)?a.apply(null,b):a(b)},b)},f.promise}:void 0},d.applied=function(a){return function(b,c){b=b,c=c;var e=arguments;d.safeApply(function(){a.apply(null,e)})}},d}]}),angular.module("auth0.interceptor",[]).factory("authInterceptor",["$rootScope","$q","$injector",function(a,b,c){return{request:function(a){if(!c.has("auth"))return a;var b=c.get("auth");return a.headers=a.headers||{},b.idToken&&!a.headers.Authorization&&(a.headers.Authorization="Bearer "+b.idToken),a},responseError:function(c){return 401===c.status&&a.$broadcast("auth0.forbidden",c),b.reject(c)}}}]),angular.module("auth0.storage",[]).service("authStorage",["$injector",function(a){var b,c,d=null;if(localStorage)b=function(a,b){return localStorage.setItem(a,b)},c=function(a){return localStorage.getItem(a)},d=function(a){return localStorage.removeItem(a)};else{var e=a.get("$cookieStore");b=function(a,b){return e.put(a,b)},c=function(a){return e.get(a)},d=function(a){return e.remove(a)}}this.store=function(a,c,d,e){b("idToken",a),c&&b("accessToken",c),d&&b("state",d),e&&b("refreshToken",e)},this.get=function(){return{idToken:c("idToken"),accessToken:c("accessToken"),state:c("state"),refreshToken:c("refreshToken")}},this.remove=function(){d("idToken"),d("accessToken"),d("state"),d("refreshToken")}}]),angular.module("auth0.service",["auth0.storage","auth0.utils"]).provider("auth",["authUtilsProvider",function(a){var b={callbackOnLocationHash:!0},c=this;this.init=function(a,c){if(!c&&"undefined"==typeof Auth0Widget&&"undefined"==typeof Auth0)throw new Error("You must add either Auth0Widget.js or Auth0.js");if(!a)throw new Error("You must set options when calling init");this.loginUrl=a.loginUrl,this.loginState=a.loginState,this.clientID=a.clientID||a.clientId,this.sso=a.sso,this.minutesToRenewToken=a.minutesToRenewToken||120;var d=c;d||"undefined"==typeof Auth0Widget||(d=Auth0Widget),d||"undefined"==typeof Auth0||(d=Auth0),this.auth0lib=new d(angular.extend(b,a)),this.auth0lib.getClient?(this.auth0js=this.auth0lib.getClient(),this.isWidget=!0):(this.auth0js=this.auth0lib,this.isWidget=!1)},this.eventHandlers={},this.on=function(a,b){this.eventHandlers[a]||(this.eventHandlers[a]=[]),this.eventHandlers[a].push(b)};var d=["loginSuccess","loginFailure","logout","forbidden"];angular.forEach(d,function(b){c["add"+a.capitalize(b)+"Handler"]=function(a){c.on(b,a)}}),this.$get=["$rootScope","$q","$injector","authStorage","$window","$location","authUtils",function(a,b,d,e,f,g,h){function i(){e.remove(),c.loginUrl?g.path(c.loginUrl):c.loginState?d.get("$state").go(c.loginState):l("forbidden")}var j={isAuthenticated:!1},k=function(a){return c.eventHandlers[a]},l=function(a,b){angular.forEach(k(a)||[],function(a){d.invoke(a,j,b)})},m=function(a,b,c,d,f){e.store(a,b,c,d);var g=j.getProfile(a),h=j.getTokenPayload(a),i={idToken:a,accessToken:b,state:c,refreshToken:d,isAuthenticated:!0,tokenPayload:h};return angular.extend(j,i),l(f?"authenticated":"loginSuccess",angular.extend({profile:g},i)),g},n=null;a.$on("$locationChangeStart",function(){var a=c.auth0lib.parseHash(f.location.hash);if(!j.isAuthenticated){if(a&&a.id_token)return void m(a.id_token,a.access_token,a.state,a.refresh_token);var b=e.get();if(b&&b.idToken){if(j.hasTokenExpired(b.idToken))return void(b.refreshToken?(n=j.refreshToken(b.refreshToken),n.then(function(a){m(a,b.accessToken,b.state,b.refreshToken,!0)},function(){i()}).finally(function(){n=null})):i());var d=j.getTokenExpirationDate(b.idToken);return d.valueOf()-(new Date).valueOf()<=60*j.config.minutesToRenewToken*1e3&&j.renewIdToken(b.idToken).then(function(a){j.idToken=a,j.tokenPayload=j.getTokenPayload(a)}),void m(b.idToken,b.accessToken,b.state,b.refreshToken,!0)}c.sso&&c.auth0js.getSSOData(h.applied(function(a,b){b.sso&&j.signin({popup:!1,connection:b.lastUsedConnection.strategy},null,null,c.auth0js)}))}}),a.$on("auth0.forbidden",function(){i()}),c.loginUrl&&a.$on("$routeChangeStart",function(a,b){b.$$route&&b.$$route.requiresLogin&&(j.isAuthenticated||n||g.path(c.loginUrl))}),c.loginState&&a.$on("$stateChangeStart",function(a,b){b.data&&b.data.requiresLogin&&(j.isAuthenticated||n||(a.preventDefault(),d.get("$state").go(c.loginState)))}),j.config=c;var o=function(a){var b=k("loginSuccess");if(!(a.popup||a.username||a.email||b&&0!==b.length))throw new Error("You must define a loginSuccess handler if not using popup mode or not doing ro call because that means you are doing a redirect")};return j.hookEvents=function(){},j.getTokenPayload=function(a){var b=a.split(".");if(3!==b.length)throw new Error("Error getting token payload");var c=h.urlBase64Decode(b[1]);if(!c)throw new Error("Error getting token payload");return JSON.parse(c)},j.getTokenExpirationDate=function(a){var b;try{b=j.getTokenPayload(a)}catch(c){return null}if(!b.exp)return null;var d=new Date(0);return d.setUTCSeconds(b.exp),d},j.hasTokenExpired=function(a){if(!a)return!0;var b=j.getTokenExpirationDate(a);return isNaN(b)?!0:b.valueOf()>(new Date).valueOf()?!1:!0},j.getToken=function(a){a=a||{scope:"openid"},a.id_token||a.refresh_token||(a.id_token=j.idToken);var b=h.promisify(c.auth0js.getDelegationToken,c.auth0js);return b(a).then(function(a){return a.id_token})},j.refreshToken=function(a){var b=h.promisify(c.auth0js.refreshToken,c.auth0js);return b(a||j.refreshToken).then(function(a){return a.id_token})},j.renewIdToken=function(a){var b=h.promisify(c.auth0js.renewIdToken,c.auth0js);return b(a||j.idToken).then(function(a){return a.id_token})},j.signin=function(a,b,d,e){a=a||{},o(a);var f=e||c.auth0lib,g=h.callbackify(f.signin,function(a,c,d,e,f){m(c,d,e,f).then(function(a){b&&b(a)})},function(a){l("loginFailure",{error:a}),d&&d(a)},f);c.isWidget?g(a,null):g(a)},j.signup=function(a,b,d){a=a||{},o(a);var e=c.auth0lib,f=h.callbackify(e.signup,function(c,d,e,f,g){angular.isUndefined(a.auto_login)||a.auto_login?m(d,e,f,g).then(function(a){b&&b(a)}):b()},function(a){l("loginFailure",{error:a}),d&&d(a)},e);c.isWidget?f(a,null):f(a)},j.reset=function(a,b,d){a=a||{};var e,f=c.auth0lib;(e=c.isWidget?h.callbackify(f.reset,b,d,f):h.callbackify(f.changePassword,b,d,f))(a)},j.signout=function(){e.remove(),j.profile=null,j.profilePromise=null,j.idToken=null,j.state=null,j.accessToken=null,j.tokenPayload=null,j.isAuthenticated=!1,l("logout")},j.getProfile=function(a){var b=h.promisify(c.auth0lib.getProfile,c.auth0lib);return j.profilePromise=b(a||j.idToken),j.profilePromise.then(function(a){return j.profile=a,a})},j}]}])}();
!function(){angular.module("auth0",["auth0.storage","auth0.service","auth0.interceptor","auth0.utils"]).run(["auth",function(a){a.hookEvents()}]),angular.module("auth0.utils",[]).provider("authUtils",function(){var a={capitalize:function(a){return a?a.charAt(0).toUpperCase()+a.substring(1).toLowerCase():null},urlBase64Decode: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 window.atob(b)}};angular.extend(this,a),this.$get=["$rootScope","$q",function(b,c){var d={};return angular.extend(d,a),d.safeApply=function(a){var c=b.$root.$$phase;"$apply"===c||"$digest"===c?a&&"function"==typeof a&&a():b.$apply(a)},d.callbackify=function(a,b,c,e){return angular.isFunction(a)?function(f){f=Array.prototype.slice.call(arguments);var g=function(a,d,e){return a?void(c&&c(a)):(e=Array.prototype.slice.call(arguments,1),void(b&&b.apply(null,e)))};f.push(d.applied(g)),a.apply(e,f)}:void 0},d.isWidget=function(a){return a&&a.getClient},d.promisify=function(a,b){return angular.isFunction(a)?function(e){e=Array.prototype.slice.call(arguments);var f=c.defer(),g=function(a,b,c){return a?void f.reject(a):(c=Array.prototype.slice.call(arguments,1),void f.resolve(c.length>1?c:b))};return e.push(d.applied(g)),a.apply(b,e),f.promise.spread=f.promise.spread||function(a,b){return f.promise.then(function(b){return Array.isArray(b)?a.apply(null,b):a(b)},b)},f.promise}:void 0},d.applied=function(a){return function(b,c){b=b,c=c;var e=arguments;d.safeApply(function(){a.apply(null,e)})}},d}]}),angular.module("auth0.interceptor",[]).provider("authInterceptor",function(){var a="skipAuthorization",b="Authorization",c="Bearer ";this.setSkipJWT=function(b){a=b||a},this.setAuthHeader=function(a){b=a||b},this.setAuthPrefix=function(a){c=a||c},this.$get=["$rootScope","$q","$injector",function(d,e,f){var g;return{request:function(d){return d[a]||!f.has("auth")?d:(g=g||f.get("auth"),d.headers=d.headers||{},g.idToken&&!d.headers[b]&&(d.headers[b]=c+g.idToken),d)},responseError:function(a){return 401===a.status&&d.$broadcast("auth0.forbiddenRequest",a),e.reject(a)}}}]}),angular.module("auth0.storage",[]).service("authStorage",["$injector",function(a){var b,c,d=null;if(localStorage)b=function(a,b){return localStorage.setItem(a,b)},c=function(a){return localStorage.getItem(a)},d=function(a){return localStorage.removeItem(a)};else{var e=a.get("$cookieStore");b=function(a,b){return e.put(a,b)},c=function(a){return e.get(a)},d=function(a){return e.remove(a)}}this.store=function(a,c,d,e){b("idToken",a),c&&b("accessToken",c),d&&b("state",d),e&&b("refreshToken",e)},this.get=function(){return{idToken:c("idToken"),accessToken:c("accessToken"),state:c("state"),refreshToken:c("refreshToken")}},this.remove=function(){d("idToken"),d("accessToken"),d("state"),d("refreshToken")}}]),angular.module("auth0.service",["auth0.storage","auth0.utils"]).provider("auth",["authUtilsProvider",function(a){var b={callbackOnLocationHash:!0},c=this;this.init=function(a,c){if(!c&&"undefined"==typeof Auth0Widget&&"undefined"==typeof Auth0)throw new Error("You must add either Auth0Widget.js or Auth0.js");if(!a)throw new Error("You must set options when calling init");this.loginUrl=a.loginUrl,this.loginState=a.loginState,this.clientID=a.clientID||a.clientId,this.sso=a.sso,this.minutesToRenewToken=a.minutesToRenewToken||120;var d=c;d||"undefined"==typeof Auth0Widget||(d=Auth0Widget),d||"undefined"==typeof Auth0||(d=Auth0),this.auth0lib=new d(angular.extend(b,a)),this.auth0lib.getClient?(this.auth0js=this.auth0lib.getClient(),this.isWidget=!0):(this.auth0js=this.auth0lib,this.isWidget=!1)},this.eventHandlers={},this.on=function(a,b){this.eventHandlers[a]||(this.eventHandlers[a]=[]),this.eventHandlers[a].push(b)};var d=["loginSuccess","loginFailure","logout","forbidden"];angular.forEach(d,function(b){c["add"+a.capitalize(b)+"Handler"]=function(a){c.on(b,a)}}),this.$get=["$rootScope","$q","$injector","authStorage","$window","$location","authUtils",function(a,b,d,e,f,g,h){function i(){e.remove(),c.loginUrl?g.path(c.loginUrl):c.loginState?d.get("$state").go(c.loginState):l("forbidden")}var j={isAuthenticated:!1},k=function(a){return c.eventHandlers[a]},l=function(b,c){a.$broadcast("auth0."+b,c),angular.forEach(k(b)||[],function(a){d.invoke(a,j,c)})},m=function(a,b,c,d,f){e.store(a,b,c,d);var g=j.getProfile(a),h=j.getTokenPayload(a),i={idToken:a,accessToken:b,state:c,refreshToken:d,isAuthenticated:!0,tokenPayload:h};return angular.extend(j,i),l(f?"authenticated":"loginSuccess",angular.extend({profile:g},i)),g},n=null;a.$on("$locationChangeStart",function(){var a=c.auth0lib.parseHash(f.location.hash);if(!j.isAuthenticated){if(a&&a.id_token)return void m(a.id_token,a.access_token,a.state,a.refresh_token);var b=e.get();if(b&&b.idToken){if(j.hasTokenExpired(b.idToken))return void(b.refreshToken?(n=j.refreshIdToken(b.refreshToken),n.then(function(a){m(a,b.accessToken,b.state,b.refreshToken,!0)},function(){i()})["finally"](function(){n=null})):i());var d=j.getTokenExpirationDate(b.idToken);return d.valueOf()-(new Date).valueOf()<=60*j.config.minutesToRenewToken*1e3&&j.renewIdToken(b.idToken).then(function(a){j.idToken=a,j.tokenPayload=j.getTokenPayload(a)}),void m(b.idToken,b.accessToken,b.state,b.refreshToken,!0)}c.sso&&c.auth0js.getSSOData(h.applied(function(a,b){b.sso&&j.signin({popup:!1,connection:b.lastUsedConnection.strategy},null,null,c.auth0js)}))}}),a.$on("auth0.forbiddenRequest",function(){i()}),c.loginUrl&&a.$on("$routeChangeStart",function(a,b){b.$$route&&b.$$route.requiresLogin&&(j.isAuthenticated||n||g.path(c.loginUrl))}),c.loginState&&a.$on("$stateChangeStart",function(a,b){b.data&&b.data.requiresLogin&&(j.isAuthenticated||n||(a.preventDefault(),d.get("$state").go(c.loginState)))}),j.config=c;var o=function(a){var b=k("loginSuccess");if(!(a.popup||a.username||a.email||b&&0!==b.length))throw new Error("You must define a loginSuccess handler if not using popup mode or not doing ro call because that means you are doing a redirect")};return j.hookEvents=function(){},j.getTokenPayload=function(a){var b=a.split(".");if(3!==b.length)throw new Error("Error getting token payload");var c=h.urlBase64Decode(b[1]);if(!c)throw new Error("Error getting token payload");return JSON.parse(c)},j.getTokenExpirationDate=function(a){var b;try{b=j.getTokenPayload(a)}catch(c){return null}if(!b.exp)return null;var d=new Date(0);return d.setUTCSeconds(b.exp),d},j.hasTokenExpired=function(a){if(!a)return!0;var b=j.getTokenExpirationDate(a);return isNaN(b)?!0:b.valueOf()>(new Date).valueOf()?!1:!0},j.getToken=function(a){a=a||{scope:"openid"},a.id_token||a.refresh_token||(a.id_token=j.idToken);var b=h.promisify(c.auth0js.getDelegationToken,c.auth0js);return b(a).then(function(a){return a.id_token})},j.refreshIdToken=function(a){var b=h.promisify(c.auth0js.refreshToken,c.auth0js);return b(a||j.refreshToken).then(function(a){return a.id_token})},j.renewIdToken=function(a){var b=h.promisify(c.auth0js.renewIdToken,c.auth0js);return b(a||j.idToken).then(function(a){return a.id_token})},j.signin=function(a,b,d,e){a=a||{},o(a);var f=e||c.auth0lib,g=h.callbackify(f.signin,function(a,c,d,e,f){m(c,d,e,f).then(function(a){b&&b(a)})},function(a){l("loginFailure",{error:a}),d&&d(a)},f);h.isWidget(f)?g(a,null):g(a)},j.signup=function(a,b,d){a=a||{},o(a);var e=c.auth0lib,f=h.callbackify(e.signup,function(c,d,e,f,g){angular.isUndefined(a.auto_login)||a.auto_login?m(d,e,f,g).then(function(a){b&&b(a)}):b()},function(a){l("loginFailure",{error:a}),d&&d(a)},e);c.isWidget?f(a,null):f(a)},j.reset=function(a,b,d){a=a||{};var e,f=c.auth0lib;(e=c.isWidget?h.callbackify(f.reset,b,d,f):h.callbackify(f.changePassword,b,d,f))(a)},j.signout=function(){e.remove(),j.profile=null,j.profilePromise=null,j.idToken=null,j.state=null,j.accessToken=null,j.tokenPayload=null,j.isAuthenticated=!1,l("logout")},j.getProfile=function(a){var b=h.promisify(c.auth0lib.getProfile,c.auth0lib);return j.profilePromise=b(a||j.idToken),j.profilePromise.then(function(a){return j.profile=a,a})},j}]}])}();
# 2.2.X
## 2.2.8
* Fixed bug when using auth0js library
## 2.2.7

@@ -4,0 +7,0 @@ * Added `authenticated` event for after refresh

@@ -7,2 +7,7 @@ (function () {

'auth0.utils'
]).run([
'auth',
function (auth) {
auth.hookEvents();
}
]);

@@ -70,2 +75,5 @@ angular.module('auth0.utils', []).provider('authUtils', function () {

};
authUtils.isWidget = function (lib) {
return lib && lib.getClient;
};
authUtils.promisify = function (nodeback, self) {

@@ -113,31 +121,46 @@ if (angular.isFunction(nodeback)) {

});
angular.module('auth0.interceptor', []).factory('authInterceptor', [
'$rootScope',
'$q',
'$injector',
function ($rootScope, $q, $injector) {
return {
request: function (config) {
// When using auth dependency is never loading, we need to do this manually
// This issue should be related with: https://github.com/angular/angular.js/issues/2367
if (!$injector.has('auth')) {
angular.module('auth0.interceptor', []).provider('authInterceptor', function () {
var skipJWT = 'skipAuthorization';
var authHeader = 'Authorization';
var authPrefix = 'Bearer ';
this.setSkipJWT = function (name) {
skipJWT = name || skipJWT;
};
this.setAuthHeader = function (name) {
authHeader = name || authHeader;
};
this.setAuthPrefix = function (name) {
authPrefix = name || authPrefix;
};
this.$get = [
'$rootScope',
'$q',
'$injector',
function ($rootScope, $q, $injector) {
var auth;
return {
request: function (config) {
// When using auth dependency is never loading, we need to do this manually
// This issue should be related with: https://github.com/angular/angular.js/issues/2367
if (config[skipJWT] || !$injector.has('auth')) {
return config;
}
auth = auth || $injector.get('auth');
config.headers = config.headers || {};
if (auth.idToken && !config.headers[authHeader]) {
config.headers[authHeader] = authPrefix + auth.idToken;
}
return config;
},
responseError: function (response) {
// handle the case where the user is not authenticated
if (response.status === 401) {
$rootScope.$broadcast('auth0.forbiddenRequest', response);
}
return $q.reject(response);
}
var auth = $injector.get('auth');
config.headers = config.headers || {};
if (auth.idToken && !config.headers.Authorization) {
config.headers.Authorization = 'Bearer ' + auth.idToken;
}
return config;
},
responseError: function (response) {
// handle the case where the user is not authenticated
if (response.status === 401) {
$rootScope.$broadcast('auth0.forbidden', response);
}
return $q.reject(response);
}
};
}
]);
};
}
];
});
angular.module('auth0.storage', []).service('authStorage', [

@@ -266,2 +289,3 @@ '$injector',

var callHandler = function (anEvent, locals) {
$rootScope.$broadcast('auth0.' + anEvent, locals);
angular.forEach(getHandlers(anEvent) || [], function (handler) {

@@ -311,3 +335,3 @@ $injector.invoke(handler, auth, locals);

if (storedValues.refreshToken) {
refreshingToken = auth.refreshToken(storedValues.refreshToken);
refreshingToken = auth.refreshIdToken(storedValues.refreshToken);
refreshingToken.then(function (idToken) {

@@ -317,3 +341,3 @@ onSigninOk(idToken, storedValues.accessToken, storedValues.state, storedValues.refreshToken, true);

forbidden();
}).finally(function () {
})['finally'](function () {
refreshingToken = null;

@@ -349,3 +373,3 @@ });

});
$rootScope.$on('auth0.forbidden', function () {
$rootScope.$on('auth0.forbiddenRequest', function () {
forbidden();

@@ -435,3 +459,3 @@ });

};
auth.refreshToken = function (refresh_token) {
auth.refreshIdToken = function (refresh_token) {
var refreshTokenAsync = authUtils.promisify(config.auth0js.refreshToken, config.auth0js);

@@ -464,3 +488,3 @@ return refreshTokenAsync(refresh_token || auth.refreshToken).then(function (delegationResult) {

}, auth0lib);
if (config.isWidget) {
if (authUtils.isWidget(auth0lib)) {
signinCall(options, null);

@@ -467,0 +491,0 @@ } else {

@@ -7,2 +7,7 @@ (function () {

'auth0.utils'
]).run([
'auth',
function (auth) {
auth.hookEvents();
}
]);

@@ -70,2 +75,5 @@ angular.module('auth0.utils', []).provider('authUtils', function () {

};
authUtils.isWidget = function (lib) {
return lib && lib.getClient;
};
authUtils.promisify = function (nodeback, self) {

@@ -113,31 +121,46 @@ if (angular.isFunction(nodeback)) {

});
angular.module('auth0.interceptor', []).factory('authInterceptor', [
'$rootScope',
'$q',
'$injector',
function ($rootScope, $q, $injector) {
return {
request: function (config) {
// When using auth dependency is never loading, we need to do this manually
// This issue should be related with: https://github.com/angular/angular.js/issues/2367
if (!$injector.has('auth')) {
angular.module('auth0.interceptor', []).provider('authInterceptor', function () {
var skipJWT = 'skipAuthorization';
var authHeader = 'Authorization';
var authPrefix = 'Bearer ';
this.setSkipJWT = function (name) {
skipJWT = name || skipJWT;
};
this.setAuthHeader = function (name) {
authHeader = name || authHeader;
};
this.setAuthPrefix = function (name) {
authPrefix = name || authPrefix;
};
this.$get = [
'$rootScope',
'$q',
'$injector',
function ($rootScope, $q, $injector) {
var auth;
return {
request: function (config) {
// When using auth dependency is never loading, we need to do this manually
// This issue should be related with: https://github.com/angular/angular.js/issues/2367
if (config[skipJWT] || !$injector.has('auth')) {
return config;
}
auth = auth || $injector.get('auth');
config.headers = config.headers || {};
if (auth.idToken && !config.headers[authHeader]) {
config.headers[authHeader] = authPrefix + auth.idToken;
}
return config;
},
responseError: function (response) {
// handle the case where the user is not authenticated
if (response.status === 401) {
$rootScope.$broadcast('auth0.forbiddenRequest', response);
}
return $q.reject(response);
}
var auth = $injector.get('auth');
config.headers = config.headers || {};
if (auth.idToken && !config.headers.Authorization) {
config.headers.Authorization = 'Bearer ' + auth.idToken;
}
return config;
},
responseError: function (response) {
// handle the case where the user is not authenticated
if (response.status === 401) {
$rootScope.$broadcast('auth0.forbidden', response);
}
return $q.reject(response);
}
};
}
]);
};
}
];
});
angular.module('auth0.storage', []).service('authStorage', [

@@ -266,2 +289,3 @@ '$injector',

var callHandler = function (anEvent, locals) {
$rootScope.$broadcast('auth0.' + anEvent, locals);
angular.forEach(getHandlers(anEvent) || [], function (handler) {

@@ -311,3 +335,3 @@ $injector.invoke(handler, auth, locals);

if (storedValues.refreshToken) {
refreshingToken = auth.refreshToken(storedValues.refreshToken);
refreshingToken = auth.refreshIdToken(storedValues.refreshToken);
refreshingToken.then(function (idToken) {

@@ -317,3 +341,3 @@ onSigninOk(idToken, storedValues.accessToken, storedValues.state, storedValues.refreshToken, true);

forbidden();
}).finally(function () {
})['finally'](function () {
refreshingToken = null;

@@ -349,3 +373,3 @@ });

});
$rootScope.$on('auth0.forbidden', function () {
$rootScope.$on('auth0.forbiddenRequest', function () {
forbidden();

@@ -435,3 +459,3 @@ });

};
auth.refreshToken = function (refresh_token) {
auth.refreshIdToken = function (refresh_token) {
var refreshTokenAsync = authUtils.promisify(config.auth0js.refreshToken, config.auth0js);

@@ -464,3 +488,3 @@ return refreshTokenAsync(refresh_token || auth.refreshToken).then(function (delegationResult) {

}, auth0lib);
if (config.isWidget) {
if (authUtils.isWidget(auth0lib)) {
signinCall(options, null);

@@ -467,0 +491,0 @@ } else {

@@ -7,2 +7,7 @@ (function () {

'auth0.utils'
]).run([
'auth',
function (auth) {
auth.hookEvents();
}
]);

@@ -70,2 +75,5 @@ angular.module('auth0.utils', []).provider('authUtils', function () {

};
authUtils.isWidget = function (lib) {
return lib && lib.getClient;
};
authUtils.promisify = function (nodeback, self) {

@@ -113,31 +121,46 @@ if (angular.isFunction(nodeback)) {

});
angular.module('auth0.interceptor', []).factory('authInterceptor', [
'$rootScope',
'$q',
'$injector',
function ($rootScope, $q, $injector) {
return {
request: function (config) {
// When using auth dependency is never loading, we need to do this manually
// This issue should be related with: https://github.com/angular/angular.js/issues/2367
if (!$injector.has('auth')) {
angular.module('auth0.interceptor', []).provider('authInterceptor', function () {
var skipJWT = 'skipAuthorization';
var authHeader = 'Authorization';
var authPrefix = 'Bearer ';
this.setSkipJWT = function (name) {
skipJWT = name || skipJWT;
};
this.setAuthHeader = function (name) {
authHeader = name || authHeader;
};
this.setAuthPrefix = function (name) {
authPrefix = name || authPrefix;
};
this.$get = [
'$rootScope',
'$q',
'$injector',
function ($rootScope, $q, $injector) {
var auth;
return {
request: function (config) {
// When using auth dependency is never loading, we need to do this manually
// This issue should be related with: https://github.com/angular/angular.js/issues/2367
if (config[skipJWT] || !$injector.has('auth')) {
return config;
}
auth = auth || $injector.get('auth');
config.headers = config.headers || {};
if (auth.idToken && !config.headers[authHeader]) {
config.headers[authHeader] = authPrefix + auth.idToken;
}
return config;
},
responseError: function (response) {
// handle the case where the user is not authenticated
if (response.status === 401) {
$rootScope.$broadcast('auth0.forbiddenRequest', response);
}
return $q.reject(response);
}
var auth = $injector.get('auth');
config.headers = config.headers || {};
if (auth.idToken && !config.headers.Authorization) {
config.headers.Authorization = 'Bearer ' + auth.idToken;
}
return config;
},
responseError: function (response) {
// handle the case where the user is not authenticated
if (response.status === 401) {
$rootScope.$broadcast('auth0.forbidden', response);
}
return $q.reject(response);
}
};
}
]);
};
}
];
});
angular.module('auth0.storage', []).service('authStorage', [

@@ -266,2 +289,3 @@ '$injector',

var callHandler = function (anEvent, locals) {
$rootScope.$broadcast('auth0.' + anEvent, locals);
angular.forEach(getHandlers(anEvent) || [], function (handler) {

@@ -311,3 +335,3 @@ $injector.invoke(handler, auth, locals);

if (storedValues.refreshToken) {
refreshingToken = auth.refreshToken(storedValues.refreshToken);
refreshingToken = auth.refreshIdToken(storedValues.refreshToken);
refreshingToken.then(function (idToken) {

@@ -317,3 +341,3 @@ onSigninOk(idToken, storedValues.accessToken, storedValues.state, storedValues.refreshToken, true);

forbidden();
}).finally(function () {
})['finally'](function () {
refreshingToken = null;

@@ -349,3 +373,3 @@ });

});
$rootScope.$on('auth0.forbidden', function () {
$rootScope.$on('auth0.forbiddenRequest', function () {
forbidden();

@@ -435,3 +459,3 @@ });

};
auth.refreshToken = function (refresh_token) {
auth.refreshIdToken = function (refresh_token) {
var refreshTokenAsync = authUtils.promisify(config.auth0js.refreshToken, config.auth0js);

@@ -464,3 +488,3 @@ return refreshTokenAsync(refresh_token || auth.refreshToken).then(function (delegationResult) {

}, auth0lib);
if (config.isWidget) {
if (authUtils.isWidget(auth0lib)) {
signinCall(options, null);

@@ -467,0 +491,0 @@ } else {

@@ -7,2 +7,7 @@ (function () {

'auth0.utils'
]).run([
'auth',
function (auth) {
auth.hookEvents();
}
]);

@@ -70,2 +75,5 @@ angular.module('auth0.utils', []).provider('authUtils', function () {

};
authUtils.isWidget = function (lib) {
return lib && lib.getClient;
};
authUtils.promisify = function (nodeback, self) {

@@ -113,31 +121,46 @@ if (angular.isFunction(nodeback)) {

});
angular.module('auth0.interceptor', []).factory('authInterceptor', [
'$rootScope',
'$q',
'$injector',
function ($rootScope, $q, $injector) {
return {
request: function (config) {
// When using auth dependency is never loading, we need to do this manually
// This issue should be related with: https://github.com/angular/angular.js/issues/2367
if (!$injector.has('auth')) {
angular.module('auth0.interceptor', []).provider('authInterceptor', function () {
var skipJWT = 'skipAuthorization';
var authHeader = 'Authorization';
var authPrefix = 'Bearer ';
this.setSkipJWT = function (name) {
skipJWT = name || skipJWT;
};
this.setAuthHeader = function (name) {
authHeader = name || authHeader;
};
this.setAuthPrefix = function (name) {
authPrefix = name || authPrefix;
};
this.$get = [
'$rootScope',
'$q',
'$injector',
function ($rootScope, $q, $injector) {
var auth;
return {
request: function (config) {
// When using auth dependency is never loading, we need to do this manually
// This issue should be related with: https://github.com/angular/angular.js/issues/2367
if (config[skipJWT] || !$injector.has('auth')) {
return config;
}
auth = auth || $injector.get('auth');
config.headers = config.headers || {};
if (auth.idToken && !config.headers[authHeader]) {
config.headers[authHeader] = authPrefix + auth.idToken;
}
return config;
},
responseError: function (response) {
// handle the case where the user is not authenticated
if (response.status === 401) {
$rootScope.$broadcast('auth0.forbiddenRequest', response);
}
return $q.reject(response);
}
var auth = $injector.get('auth');
config.headers = config.headers || {};
if (auth.idToken && !config.headers.Authorization) {
config.headers.Authorization = 'Bearer ' + auth.idToken;
}
return config;
},
responseError: function (response) {
// handle the case where the user is not authenticated
if (response.status === 401) {
$rootScope.$broadcast('auth0.forbidden', response);
}
return $q.reject(response);
}
};
}
]);
};
}
];
});
angular.module('auth0.storage', []).service('authStorage', [

@@ -266,2 +289,3 @@ '$injector',

var callHandler = function (anEvent, locals) {
$rootScope.$broadcast('auth0.' + anEvent, locals);
angular.forEach(getHandlers(anEvent) || [], function (handler) {

@@ -311,3 +335,3 @@ $injector.invoke(handler, auth, locals);

if (storedValues.refreshToken) {
refreshingToken = auth.refreshToken(storedValues.refreshToken);
refreshingToken = auth.refreshIdToken(storedValues.refreshToken);
refreshingToken.then(function (idToken) {

@@ -317,3 +341,3 @@ onSigninOk(idToken, storedValues.accessToken, storedValues.state, storedValues.refreshToken, true);

forbidden();
}).finally(function () {
})['finally'](function () {
refreshingToken = null;

@@ -349,3 +373,3 @@ });

});
$rootScope.$on('auth0.forbidden', function () {
$rootScope.$on('auth0.forbiddenRequest', function () {
forbidden();

@@ -435,3 +459,3 @@ });

};
auth.refreshToken = function (refresh_token) {
auth.refreshIdToken = function (refresh_token) {
var refreshTokenAsync = authUtils.promisify(config.auth0js.refreshToken, config.auth0js);

@@ -464,3 +488,3 @@ return refreshTokenAsync(refresh_token || auth.refreshToken).then(function (delegationResult) {

}, auth0lib);
if (config.isWidget) {
if (authUtils.isWidget(auth0lib)) {
signinCall(options, null);

@@ -467,0 +491,0 @@ } else {

@@ -7,2 +7,7 @@ (function () {

'auth0.utils'
]).run([
'auth',
function (auth) {
auth.hookEvents();
}
]);

@@ -70,2 +75,5 @@ angular.module('auth0.utils', []).provider('authUtils', function () {

};
authUtils.isWidget = function (lib) {
return lib && lib.getClient;
};
authUtils.promisify = function (nodeback, self) {

@@ -113,31 +121,46 @@ if (angular.isFunction(nodeback)) {

});
angular.module('auth0.interceptor', []).factory('authInterceptor', [
'$rootScope',
'$q',
'$injector',
function ($rootScope, $q, $injector) {
return {
request: function (config) {
// When using auth dependency is never loading, we need to do this manually
// This issue should be related with: https://github.com/angular/angular.js/issues/2367
if (!$injector.has('auth')) {
angular.module('auth0.interceptor', []).provider('authInterceptor', function () {
var skipJWT = 'skipAuthorization';
var authHeader = 'Authorization';
var authPrefix = 'Bearer ';
this.setSkipJWT = function (name) {
skipJWT = name || skipJWT;
};
this.setAuthHeader = function (name) {
authHeader = name || authHeader;
};
this.setAuthPrefix = function (name) {
authPrefix = name || authPrefix;
};
this.$get = [
'$rootScope',
'$q',
'$injector',
function ($rootScope, $q, $injector) {
var auth;
return {
request: function (config) {
// When using auth dependency is never loading, we need to do this manually
// This issue should be related with: https://github.com/angular/angular.js/issues/2367
if (config[skipJWT] || !$injector.has('auth')) {
return config;
}
auth = auth || $injector.get('auth');
config.headers = config.headers || {};
if (auth.idToken && !config.headers[authHeader]) {
config.headers[authHeader] = authPrefix + auth.idToken;
}
return config;
},
responseError: function (response) {
// handle the case where the user is not authenticated
if (response.status === 401) {
$rootScope.$broadcast('auth0.forbiddenRequest', response);
}
return $q.reject(response);
}
var auth = $injector.get('auth');
config.headers = config.headers || {};
if (auth.idToken && !config.headers.Authorization) {
config.headers.Authorization = 'Bearer ' + auth.idToken;
}
return config;
},
responseError: function (response) {
// handle the case where the user is not authenticated
if (response.status === 401) {
$rootScope.$broadcast('auth0.forbidden', response);
}
return $q.reject(response);
}
};
}
]);
};
}
];
});
angular.module('auth0.storage', []).service('authStorage', [

@@ -266,2 +289,3 @@ '$injector',

var callHandler = function (anEvent, locals) {
$rootScope.$broadcast('auth0.' + anEvent, locals);
angular.forEach(getHandlers(anEvent) || [], function (handler) {

@@ -311,3 +335,3 @@ $injector.invoke(handler, auth, locals);

if (storedValues.refreshToken) {
refreshingToken = auth.refreshToken(storedValues.refreshToken);
refreshingToken = auth.refreshIdToken(storedValues.refreshToken);
refreshingToken.then(function (idToken) {

@@ -317,3 +341,3 @@ onSigninOk(idToken, storedValues.accessToken, storedValues.state, storedValues.refreshToken, true);

forbidden();
}).finally(function () {
})['finally'](function () {
refreshingToken = null;

@@ -349,3 +373,3 @@ });

});
$rootScope.$on('auth0.forbidden', function () {
$rootScope.$on('auth0.forbiddenRequest', function () {
forbidden();

@@ -435,3 +459,3 @@ });

};
auth.refreshToken = function (refresh_token) {
auth.refreshIdToken = function (refresh_token) {
var refreshTokenAsync = authUtils.promisify(config.auth0js.refreshToken, config.auth0js);

@@ -464,3 +488,3 @@ return refreshTokenAsync(refresh_token || auth.refreshToken).then(function (delegationResult) {

}, auth0lib);
if (config.isWidget) {
if (authUtils.isWidget(auth0lib)) {
signinCall(options, null);

@@ -467,0 +491,0 @@ } else {

@@ -7,2 +7,7 @@ (function () {

'auth0.utils'
]).run([
'auth',
function (auth) {
auth.hookEvents();
}
]);

@@ -70,2 +75,5 @@ angular.module('auth0.utils', []).provider('authUtils', function () {

};
authUtils.isWidget = function (lib) {
return lib && lib.getClient;
};
authUtils.promisify = function (nodeback, self) {

@@ -113,31 +121,46 @@ if (angular.isFunction(nodeback)) {

});
angular.module('auth0.interceptor', []).factory('authInterceptor', [
'$rootScope',
'$q',
'$injector',
function ($rootScope, $q, $injector) {
return {
request: function (config) {
// When using auth dependency is never loading, we need to do this manually
// This issue should be related with: https://github.com/angular/angular.js/issues/2367
if (!$injector.has('auth')) {
angular.module('auth0.interceptor', []).provider('authInterceptor', function () {
var skipJWT = 'skipAuthorization';
var authHeader = 'Authorization';
var authPrefix = 'Bearer ';
this.setSkipJWT = function (name) {
skipJWT = name || skipJWT;
};
this.setAuthHeader = function (name) {
authHeader = name || authHeader;
};
this.setAuthPrefix = function (name) {
authPrefix = name || authPrefix;
};
this.$get = [
'$rootScope',
'$q',
'$injector',
function ($rootScope, $q, $injector) {
var auth;
return {
request: function (config) {
// When using auth dependency is never loading, we need to do this manually
// This issue should be related with: https://github.com/angular/angular.js/issues/2367
if (config[skipJWT] || !$injector.has('auth')) {
return config;
}
auth = auth || $injector.get('auth');
config.headers = config.headers || {};
if (auth.idToken && !config.headers[authHeader]) {
config.headers[authHeader] = authPrefix + auth.idToken;
}
return config;
},
responseError: function (response) {
// handle the case where the user is not authenticated
if (response.status === 401) {
$rootScope.$broadcast('auth0.forbiddenRequest', response);
}
return $q.reject(response);
}
var auth = $injector.get('auth');
config.headers = config.headers || {};
if (auth.idToken && !config.headers.Authorization) {
config.headers.Authorization = 'Bearer ' + auth.idToken;
}
return config;
},
responseError: function (response) {
// handle the case where the user is not authenticated
if (response.status === 401) {
$rootScope.$broadcast('auth0.forbidden', response);
}
return $q.reject(response);
}
};
}
]);
};
}
];
});
angular.module('auth0.storage', []).service('authStorage', [

@@ -266,2 +289,3 @@ '$injector',

var callHandler = function (anEvent, locals) {
$rootScope.$broadcast('auth0.' + anEvent, locals);
angular.forEach(getHandlers(anEvent) || [], function (handler) {

@@ -311,3 +335,3 @@ $injector.invoke(handler, auth, locals);

if (storedValues.refreshToken) {
refreshingToken = auth.refreshToken(storedValues.refreshToken);
refreshingToken = auth.refreshIdToken(storedValues.refreshToken);
refreshingToken.then(function (idToken) {

@@ -317,3 +341,3 @@ onSigninOk(idToken, storedValues.accessToken, storedValues.state, storedValues.refreshToken, true);

forbidden();
}).finally(function () {
})['finally'](function () {
refreshingToken = null;

@@ -349,3 +373,3 @@ });

});
$rootScope.$on('auth0.forbidden', function () {
$rootScope.$on('auth0.forbiddenRequest', function () {
forbidden();

@@ -435,3 +459,3 @@ });

};
auth.refreshToken = function (refresh_token) {
auth.refreshIdToken = function (refresh_token) {
var refreshTokenAsync = authUtils.promisify(config.auth0js.refreshToken, config.auth0js);

@@ -464,3 +488,3 @@ return refreshTokenAsync(refresh_token || auth.refreshToken).then(function (delegationResult) {

}, auth0lib);
if (config.isWidget) {
if (authUtils.isWidget(auth0lib)) {
signinCall(options, null);

@@ -467,0 +491,0 @@ } else {

@@ -7,2 +7,7 @@ (function () {

'auth0.utils'
]).run([
'auth',
function (auth) {
auth.hookEvents();
}
]);

@@ -70,2 +75,5 @@ angular.module('auth0.utils', []).provider('authUtils', function () {

};
authUtils.isWidget = function (lib) {
return lib && lib.getClient;
};
authUtils.promisify = function (nodeback, self) {

@@ -113,31 +121,46 @@ if (angular.isFunction(nodeback)) {

});
angular.module('auth0.interceptor', []).factory('authInterceptor', [
'$rootScope',
'$q',
'$injector',
function ($rootScope, $q, $injector) {
return {
request: function (config) {
// When using auth dependency is never loading, we need to do this manually
// This issue should be related with: https://github.com/angular/angular.js/issues/2367
if (!$injector.has('auth')) {
angular.module('auth0.interceptor', []).provider('authInterceptor', function () {
var skipJWT = 'skipAuthorization';
var authHeader = 'Authorization';
var authPrefix = 'Bearer ';
this.setSkipJWT = function (name) {
skipJWT = name || skipJWT;
};
this.setAuthHeader = function (name) {
authHeader = name || authHeader;
};
this.setAuthPrefix = function (name) {
authPrefix = name || authPrefix;
};
this.$get = [
'$rootScope',
'$q',
'$injector',
function ($rootScope, $q, $injector) {
var auth;
return {
request: function (config) {
// When using auth dependency is never loading, we need to do this manually
// This issue should be related with: https://github.com/angular/angular.js/issues/2367
if (config[skipJWT] || !$injector.has('auth')) {
return config;
}
auth = auth || $injector.get('auth');
config.headers = config.headers || {};
if (auth.idToken && !config.headers[authHeader]) {
config.headers[authHeader] = authPrefix + auth.idToken;
}
return config;
},
responseError: function (response) {
// handle the case where the user is not authenticated
if (response.status === 401) {
$rootScope.$broadcast('auth0.forbiddenRequest', response);
}
return $q.reject(response);
}
var auth = $injector.get('auth');
config.headers = config.headers || {};
if (auth.idToken && !config.headers.Authorization) {
config.headers.Authorization = 'Bearer ' + auth.idToken;
}
return config;
},
responseError: function (response) {
// handle the case where the user is not authenticated
if (response.status === 401) {
$rootScope.$broadcast('auth0.forbidden', response);
}
return $q.reject(response);
}
};
}
]);
};
}
];
});
angular.module('auth0.storage', []).service('authStorage', [

@@ -266,2 +289,3 @@ '$injector',

var callHandler = function (anEvent, locals) {
$rootScope.$broadcast('auth0.' + anEvent, locals);
angular.forEach(getHandlers(anEvent) || [], function (handler) {

@@ -311,3 +335,3 @@ $injector.invoke(handler, auth, locals);

if (storedValues.refreshToken) {
refreshingToken = auth.refreshToken(storedValues.refreshToken);
refreshingToken = auth.refreshIdToken(storedValues.refreshToken);
refreshingToken.then(function (idToken) {

@@ -317,3 +341,3 @@ onSigninOk(idToken, storedValues.accessToken, storedValues.state, storedValues.refreshToken, true);

forbidden();
}).finally(function () {
})['finally'](function () {
refreshingToken = null;

@@ -349,3 +373,3 @@ });

});
$rootScope.$on('auth0.forbidden', function () {
$rootScope.$on('auth0.forbiddenRequest', function () {
forbidden();

@@ -435,3 +459,3 @@ });

};
auth.refreshToken = function (refresh_token) {
auth.refreshIdToken = function (refresh_token) {
var refreshTokenAsync = authUtils.promisify(config.auth0js.refreshToken, config.auth0js);

@@ -464,3 +488,3 @@ return refreshTokenAsync(refresh_token || auth.refreshToken).then(function (delegationResult) {

}, auth0lib);
if (config.isWidget) {
if (authUtils.isWidget(auth0lib)) {
signinCall(options, null);

@@ -467,0 +491,0 @@ } else {

@@ -7,2 +7,7 @@ (function () {

'auth0.utils'
]).run([
'auth',
function (auth) {
auth.hookEvents();
}
]);

@@ -70,2 +75,5 @@ angular.module('auth0.utils', []).provider('authUtils', function () {

};
authUtils.isWidget = function (lib) {
return lib && lib.getClient;
};
authUtils.promisify = function (nodeback, self) {

@@ -113,31 +121,46 @@ if (angular.isFunction(nodeback)) {

});
angular.module('auth0.interceptor', []).factory('authInterceptor', [
'$rootScope',
'$q',
'$injector',
function ($rootScope, $q, $injector) {
return {
request: function (config) {
// When using auth dependency is never loading, we need to do this manually
// This issue should be related with: https://github.com/angular/angular.js/issues/2367
if (!$injector.has('auth')) {
angular.module('auth0.interceptor', []).provider('authInterceptor', function () {
var skipJWT = 'skipAuthorization';
var authHeader = 'Authorization';
var authPrefix = 'Bearer ';
this.setSkipJWT = function (name) {
skipJWT = name || skipJWT;
};
this.setAuthHeader = function (name) {
authHeader = name || authHeader;
};
this.setAuthPrefix = function (name) {
authPrefix = name || authPrefix;
};
this.$get = [
'$rootScope',
'$q',
'$injector',
function ($rootScope, $q, $injector) {
var auth;
return {
request: function (config) {
// When using auth dependency is never loading, we need to do this manually
// This issue should be related with: https://github.com/angular/angular.js/issues/2367
if (config[skipJWT] || !$injector.has('auth')) {
return config;
}
auth = auth || $injector.get('auth');
config.headers = config.headers || {};
if (auth.idToken && !config.headers[authHeader]) {
config.headers[authHeader] = authPrefix + auth.idToken;
}
return config;
},
responseError: function (response) {
// handle the case where the user is not authenticated
if (response.status === 401) {
$rootScope.$broadcast('auth0.forbiddenRequest', response);
}
return $q.reject(response);
}
var auth = $injector.get('auth');
config.headers = config.headers || {};
if (auth.idToken && !config.headers.Authorization) {
config.headers.Authorization = 'Bearer ' + auth.idToken;
}
return config;
},
responseError: function (response) {
// handle the case where the user is not authenticated
if (response.status === 401) {
$rootScope.$broadcast('auth0.forbidden', response);
}
return $q.reject(response);
}
};
}
]);
};
}
];
});
angular.module('auth0.storage', []).service('authStorage', [

@@ -266,2 +289,3 @@ '$injector',

var callHandler = function (anEvent, locals) {
$rootScope.$broadcast('auth0.' + anEvent, locals);
angular.forEach(getHandlers(anEvent) || [], function (handler) {

@@ -311,3 +335,3 @@ $injector.invoke(handler, auth, locals);

if (storedValues.refreshToken) {
refreshingToken = auth.refreshToken(storedValues.refreshToken);
refreshingToken = auth.refreshIdToken(storedValues.refreshToken);
refreshingToken.then(function (idToken) {

@@ -317,3 +341,3 @@ onSigninOk(idToken, storedValues.accessToken, storedValues.state, storedValues.refreshToken, true);

forbidden();
}).finally(function () {
})['finally'](function () {
refreshingToken = null;

@@ -349,3 +373,3 @@ });

});
$rootScope.$on('auth0.forbidden', function () {
$rootScope.$on('auth0.forbiddenRequest', function () {
forbidden();

@@ -435,3 +459,3 @@ });

};
auth.refreshToken = function (refresh_token) {
auth.refreshIdToken = function (refresh_token) {
var refreshTokenAsync = authUtils.promisify(config.auth0js.refreshToken, config.auth0js);

@@ -464,3 +488,3 @@ return refreshTokenAsync(refresh_token || auth.refreshToken).then(function (delegationResult) {

}, auth0lib);
if (config.isWidget) {
if (authUtils.isWidget(auth0lib)) {
signinCall(options, null);

@@ -467,0 +491,0 @@ } else {

@@ -7,2 +7,7 @@ (function () {

'auth0.utils'
]).run([
'auth',
function (auth) {
auth.hookEvents();
}
]);

@@ -70,2 +75,5 @@ angular.module('auth0.utils', []).provider('authUtils', function () {

};
authUtils.isWidget = function (lib) {
return lib && lib.getClient;
};
authUtils.promisify = function (nodeback, self) {

@@ -113,31 +121,46 @@ if (angular.isFunction(nodeback)) {

});
angular.module('auth0.interceptor', []).factory('authInterceptor', [
'$rootScope',
'$q',
'$injector',
function ($rootScope, $q, $injector) {
return {
request: function (config) {
// When using auth dependency is never loading, we need to do this manually
// This issue should be related with: https://github.com/angular/angular.js/issues/2367
if (!$injector.has('auth')) {
angular.module('auth0.interceptor', []).provider('authInterceptor', function () {
var skipJWT = 'skipAuthorization';
var authHeader = 'Authorization';
var authPrefix = 'Bearer ';
this.setSkipJWT = function (name) {
skipJWT = name || skipJWT;
};
this.setAuthHeader = function (name) {
authHeader = name || authHeader;
};
this.setAuthPrefix = function (name) {
authPrefix = name || authPrefix;
};
this.$get = [
'$rootScope',
'$q',
'$injector',
function ($rootScope, $q, $injector) {
var auth;
return {
request: function (config) {
// When using auth dependency is never loading, we need to do this manually
// This issue should be related with: https://github.com/angular/angular.js/issues/2367
if (config[skipJWT] || !$injector.has('auth')) {
return config;
}
auth = auth || $injector.get('auth');
config.headers = config.headers || {};
if (auth.idToken && !config.headers[authHeader]) {
config.headers[authHeader] = authPrefix + auth.idToken;
}
return config;
},
responseError: function (response) {
// handle the case where the user is not authenticated
if (response.status === 401) {
$rootScope.$broadcast('auth0.forbiddenRequest', response);
}
return $q.reject(response);
}
var auth = $injector.get('auth');
config.headers = config.headers || {};
if (auth.idToken && !config.headers.Authorization) {
config.headers.Authorization = 'Bearer ' + auth.idToken;
}
return config;
},
responseError: function (response) {
// handle the case where the user is not authenticated
if (response.status === 401) {
$rootScope.$broadcast('auth0.forbidden', response);
}
return $q.reject(response);
}
};
}
]);
};
}
];
});
angular.module('auth0.storage', []).service('authStorage', [

@@ -266,2 +289,3 @@ '$injector',

var callHandler = function (anEvent, locals) {
$rootScope.$broadcast('auth0.' + anEvent, locals);
angular.forEach(getHandlers(anEvent) || [], function (handler) {

@@ -311,3 +335,3 @@ $injector.invoke(handler, auth, locals);

if (storedValues.refreshToken) {
refreshingToken = auth.refreshToken(storedValues.refreshToken);
refreshingToken = auth.refreshIdToken(storedValues.refreshToken);
refreshingToken.then(function (idToken) {

@@ -317,3 +341,3 @@ onSigninOk(idToken, storedValues.accessToken, storedValues.state, storedValues.refreshToken, true);

forbidden();
}).finally(function () {
})['finally'](function () {
refreshingToken = null;

@@ -349,3 +373,3 @@ });

});
$rootScope.$on('auth0.forbidden', function () {
$rootScope.$on('auth0.forbiddenRequest', function () {
forbidden();

@@ -435,3 +459,3 @@ });

};
auth.refreshToken = function (refresh_token) {
auth.refreshIdToken = function (refresh_token) {
var refreshTokenAsync = authUtils.promisify(config.auth0js.refreshToken, config.auth0js);

@@ -464,3 +488,3 @@ return refreshTokenAsync(refresh_token || auth.refreshToken).then(function (delegationResult) {

}, auth0lib);
if (config.isWidget) {
if (authUtils.isWidget(auth0lib)) {
signinCall(options, null);

@@ -467,0 +491,0 @@ } else {

@@ -7,2 +7,7 @@ (function () {

'auth0.utils'
]).run([
'auth',
function (auth) {
auth.hookEvents();
}
]);

@@ -70,2 +75,5 @@ angular.module('auth0.utils', []).provider('authUtils', function () {

};
authUtils.isWidget = function (lib) {
return lib && lib.getClient;
};
authUtils.promisify = function (nodeback, self) {

@@ -113,31 +121,46 @@ if (angular.isFunction(nodeback)) {

});
angular.module('auth0.interceptor', []).factory('authInterceptor', [
'$rootScope',
'$q',
'$injector',
function ($rootScope, $q, $injector) {
return {
request: function (config) {
// When using auth dependency is never loading, we need to do this manually
// This issue should be related with: https://github.com/angular/angular.js/issues/2367
if (!$injector.has('auth')) {
angular.module('auth0.interceptor', []).provider('authInterceptor', function () {
var skipJWT = 'skipAuthorization';
var authHeader = 'Authorization';
var authPrefix = 'Bearer ';
this.setSkipJWT = function (name) {
skipJWT = name || skipJWT;
};
this.setAuthHeader = function (name) {
authHeader = name || authHeader;
};
this.setAuthPrefix = function (name) {
authPrefix = name || authPrefix;
};
this.$get = [
'$rootScope',
'$q',
'$injector',
function ($rootScope, $q, $injector) {
var auth;
return {
request: function (config) {
// When using auth dependency is never loading, we need to do this manually
// This issue should be related with: https://github.com/angular/angular.js/issues/2367
if (config[skipJWT] || !$injector.has('auth')) {
return config;
}
auth = auth || $injector.get('auth');
config.headers = config.headers || {};
if (auth.idToken && !config.headers[authHeader]) {
config.headers[authHeader] = authPrefix + auth.idToken;
}
return config;
},
responseError: function (response) {
// handle the case where the user is not authenticated
if (response.status === 401) {
$rootScope.$broadcast('auth0.forbiddenRequest', response);
}
return $q.reject(response);
}
var auth = $injector.get('auth');
config.headers = config.headers || {};
if (auth.idToken && !config.headers.Authorization) {
config.headers.Authorization = 'Bearer ' + auth.idToken;
}
return config;
},
responseError: function (response) {
// handle the case where the user is not authenticated
if (response.status === 401) {
$rootScope.$broadcast('auth0.forbidden', response);
}
return $q.reject(response);
}
};
}
]);
};
}
];
});
angular.module('auth0.storage', []).service('authStorage', [

@@ -266,2 +289,3 @@ '$injector',

var callHandler = function (anEvent, locals) {
$rootScope.$broadcast('auth0.' + anEvent, locals);
angular.forEach(getHandlers(anEvent) || [], function (handler) {

@@ -311,3 +335,3 @@ $injector.invoke(handler, auth, locals);

if (storedValues.refreshToken) {
refreshingToken = auth.refreshToken(storedValues.refreshToken);
refreshingToken = auth.refreshIdToken(storedValues.refreshToken);
refreshingToken.then(function (idToken) {

@@ -317,3 +341,3 @@ onSigninOk(idToken, storedValues.accessToken, storedValues.state, storedValues.refreshToken, true);

forbidden();
}).finally(function () {
})['finally'](function () {
refreshingToken = null;

@@ -349,3 +373,3 @@ });

});
$rootScope.$on('auth0.forbidden', function () {
$rootScope.$on('auth0.forbiddenRequest', function () {
forbidden();

@@ -435,3 +459,3 @@ });

};
auth.refreshToken = function (refresh_token) {
auth.refreshIdToken = function (refresh_token) {
var refreshTokenAsync = authUtils.promisify(config.auth0js.refreshToken, config.auth0js);

@@ -464,3 +488,3 @@ return refreshTokenAsync(refresh_token || auth.refreshToken).then(function (delegationResult) {

}, auth0lib);
if (config.isWidget) {
if (authUtils.isWidget(auth0lib)) {
signinCall(options, null);

@@ -467,0 +491,0 @@ } else {

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

var AUTH0_CLIENT_ID='lIL36aaqR24YEi2gpccNI4MGf21J2WuY';
var AUTH0_CLIENT_ID='BUIJSW9x60sIHBw8Kd9EmCbj8eDIFxDC';
var AUTH0_CALLBACK_URL=location.href;
var AUTH0_DOMAIN='mgonto.auth0.com';
var AUTH0_DOMAIN='samples.auth0.com';

@@ -7,2 +7,7 @@ (function () {

'auth0.utils'
]).run([
'auth',
function (auth) {
auth.hookEvents();
}
]);

@@ -70,2 +75,5 @@ angular.module('auth0.utils', []).provider('authUtils', function () {

};
authUtils.isWidget = function (lib) {
return lib && lib.getClient;
};
authUtils.promisify = function (nodeback, self) {

@@ -113,31 +121,46 @@ if (angular.isFunction(nodeback)) {

});
angular.module('auth0.interceptor', []).factory('authInterceptor', [
'$rootScope',
'$q',
'$injector',
function ($rootScope, $q, $injector) {
return {
request: function (config) {
// When using auth dependency is never loading, we need to do this manually
// This issue should be related with: https://github.com/angular/angular.js/issues/2367
if (!$injector.has('auth')) {
angular.module('auth0.interceptor', []).provider('authInterceptor', function () {
var skipJWT = 'skipAuthorization';
var authHeader = 'Authorization';
var authPrefix = 'Bearer ';
this.setSkipJWT = function (name) {
skipJWT = name || skipJWT;
};
this.setAuthHeader = function (name) {
authHeader = name || authHeader;
};
this.setAuthPrefix = function (name) {
authPrefix = name || authPrefix;
};
this.$get = [
'$rootScope',
'$q',
'$injector',
function ($rootScope, $q, $injector) {
var auth;
return {
request: function (config) {
// When using auth dependency is never loading, we need to do this manually
// This issue should be related with: https://github.com/angular/angular.js/issues/2367
if (config[skipJWT] || !$injector.has('auth')) {
return config;
}
auth = auth || $injector.get('auth');
config.headers = config.headers || {};
if (auth.idToken && !config.headers[authHeader]) {
config.headers[authHeader] = authPrefix + auth.idToken;
}
return config;
},
responseError: function (response) {
// handle the case where the user is not authenticated
if (response.status === 401) {
$rootScope.$broadcast('auth0.forbiddenRequest', response);
}
return $q.reject(response);
}
var auth = $injector.get('auth');
config.headers = config.headers || {};
if (auth.idToken && !config.headers.Authorization) {
config.headers.Authorization = 'Bearer ' + auth.idToken;
}
return config;
},
responseError: function (response) {
// handle the case where the user is not authenticated
if (response.status === 401) {
$rootScope.$broadcast('auth0.forbidden', response);
}
return $q.reject(response);
}
};
}
]);
};
}
];
});
angular.module('auth0.storage', []).service('authStorage', [

@@ -266,2 +289,3 @@ '$injector',

var callHandler = function (anEvent, locals) {
$rootScope.$broadcast('auth0.' + anEvent, locals);
angular.forEach(getHandlers(anEvent) || [], function (handler) {

@@ -311,3 +335,3 @@ $injector.invoke(handler, auth, locals);

if (storedValues.refreshToken) {
refreshingToken = auth.refreshToken(storedValues.refreshToken);
refreshingToken = auth.refreshIdToken(storedValues.refreshToken);
refreshingToken.then(function (idToken) {

@@ -317,3 +341,3 @@ onSigninOk(idToken, storedValues.accessToken, storedValues.state, storedValues.refreshToken, true);

forbidden();
}).finally(function () {
})['finally'](function () {
refreshingToken = null;

@@ -349,3 +373,3 @@ });

});
$rootScope.$on('auth0.forbidden', function () {
$rootScope.$on('auth0.forbiddenRequest', function () {
forbidden();

@@ -435,3 +459,3 @@ });

};
auth.refreshToken = function (refresh_token) {
auth.refreshIdToken = function (refresh_token) {
var refreshTokenAsync = authUtils.promisify(config.auth0js.refreshToken, config.auth0js);

@@ -464,3 +488,3 @@ return refreshTokenAsync(refresh_token || auth.refreshToken).then(function (delegationResult) {

}, auth0lib);
if (config.isWidget) {
if (authUtils.isWidget(auth0lib)) {
signinCall(options, null);

@@ -467,0 +491,0 @@ } else {

{
"name": "auth0-angular",
"version": "2.2.7",
"version": "2.2.9",
"main": "./build/auth0-angular.js",

@@ -5,0 +5,0 @@ "devDependencies": {

@@ -166,3 +166,3 @@ # Auth0 and AngularJS

authProvider.on('authenticated, function($location) {
authProvider.on('authenticated', function($location) {
// This is after a refresh of the page

@@ -319,3 +319,3 @@ // If the user is still authenticated, you get this event

#### auth.refreshToken(refresh_token)
#### auth.refreshIdToken(refresh_token)

@@ -344,4 +344,5 @@ Given a **expired** `id_token`, you can use the `refresh_token` to get a new and valid `id_token`.

* **loginSucces**: This will get called after a user has successfully logged in. In the handler, you can inject any service you want besides the `profile` and `token` from the user
* **loginFailure**: This will get called if there's an error authenticating the usr. In the handler, you can inject any service you want besides the `error` which was thrown
* **authenticated**: This will get called after a refresh of the page if the user is still authenticated. In the handler, you can inject any service you want.
* **loginSucces**: This will get called after a user has successfully logged in. In the handler, you can inject any service you want besides the `profile` and `token` from the user.
* **loginFailure**: This will get called if there's an error authenticating the usr. In the handler, you can inject any service you want besides the `error` which was thrown.
* **logout**: This will get called after a user has successfully logged out.

@@ -348,0 +349,0 @@ * **forbidden**: This will get called if a request to an API is made and it returns 401 meaning that the user cannot access that resource. That usually happens when the token is expired. In that case, you should redirect the user to the login page in most cases.

(function () {
angular.module('auth0', ['auth0.storage', 'auth0.service', 'auth0.interceptor', 'auth0.utils']);
angular.module('auth0', ['auth0.storage', 'auth0.service', 'auth0.interceptor', 'auth0.utils'])
.run(function(auth) {
auth.hookEvents();
});
angular.module('auth0.utils', [])
.provider('authUtils', function() {
var Utils = {
capitalize: function(string) {
return string ? string.charAt(0).toUpperCase() + string.substring(1).toLowerCase() : null;
},
urlBase64Decode: function(str) {
var output = str.replace('-', '+').replace('_', '/');
switch (output.length % 4) {
case 0: { break; }
case 2: { output += '=='; break; }
case 3: { output += '='; break; }
default: {
throw 'Illegal base64url string!';
}
.provider('authUtils', function() {
var Utils = {
capitalize: function(string) {
return string ? string.charAt(0).toUpperCase() + string.substring(1).toLowerCase() : null;
},
urlBase64Decode: function(str) {
var output = str.replace('-', '+').replace('_', '/');
switch (output.length % 4) {
case 0: { break; }
case 2: { output += '=='; break; }
case 3: { output += '='; break; }
default: {
throw 'Illegal base64url string!';
}
return window.atob(output); //polifyll https://github.com/davidchambers/Base64.js
}
};
return window.atob(output); //polifyll https://github.com/davidchambers/Base64.js
}
};
angular.extend(this, Utils);
angular.extend(this, Utils);
this.$get = function($rootScope, $q) {
var authUtils = {};
angular.extend(authUtils, Utils);
this.$get = function($rootScope, $q) {
var authUtils = {};
angular.extend(authUtils, Utils);
authUtils.safeApply = function(fn) {
var phase = $rootScope.$root.$$phase;
if(phase === '$apply' || phase === '$digest') {
if(fn && (typeof(fn) === 'function')) {
fn();
}
} else {
$rootScope.$apply(fn);
authUtils.safeApply = function(fn) {
var phase = $rootScope.$root.$$phase;
if(phase === '$apply' || phase === '$digest') {
if(fn && (typeof(fn) === 'function')) {
fn();
}
};
authUtils.callbackify = function (nodeback, success, error, self) {
if (angular.isFunction(nodeback)) {
return function (args) {
args = Array.prototype.slice.call(arguments);
var callback = function (err, response, etc) {
if (err) {
error && error(err);
return;
}
// if more arguments then turn into an array for .spread()
etc = Array.prototype.slice.call(arguments, 1);
success && success.apply(null, etc);
};
args.push(authUtils.applied(callback));
nodeback.apply(self, args);
};
} else {
$rootScope.$apply(fn);
}
};
authUtils.promisify = function (nodeback, self) {
if (angular.isFunction(nodeback)) {
return function (args) {
args = Array.prototype.slice.call(arguments);
var dfd = $q.defer();
var callback = function (err, response, etc) {
if (err) {
dfd.reject(err);
return;
}
// if more arguments then turn into an array for .spread()
etc = Array.prototype.slice.call(arguments, 1);
dfd.resolve(etc.length > 1 ? etc : response);
};
authUtils.callbackify = function (nodeback, success, error, self) {
if (angular.isFunction(nodeback)) {
return function (args) {
args = Array.prototype.slice.call(arguments);
var callback = function (err, response, etc) {
if (err) {
error && error(err);
return;
}
// if more arguments then turn into an array for .spread()
etc = Array.prototype.slice.call(arguments, 1);
success && success.apply(null, etc);
};
args.push(authUtils.applied(callback));
nodeback.apply(self, args);
// spread polyfill only for promisify
dfd.promise.spread = dfd.promise.spread || function (fulfilled, rejected) {
return dfd.promise.then(function (array) {
return Array.isArray(array) ? fulfilled.apply(null, array) : fulfilled(array);
}, rejected);
};
return dfd.promise;
};
}
args.push(authUtils.applied(callback));
nodeback.apply(self, args);
};
}
};
authUtils.isWidget = function(lib) {
return lib && lib.getClient;
};
authUtils.applied = function(fn) {
// Adding arguments just due to a bug in Auth0.js.
return function (err, response) {
// Using variables so that they don't get deleted by UglifyJS
err = err;
response = response;
var argsCall = arguments;
authUtils.safeApply(function() {
fn.apply(null, argsCall);
});
authUtils.promisify = function (nodeback, self) {
if (angular.isFunction(nodeback)) {
return function (args) {
args = Array.prototype.slice.call(arguments);
var dfd = $q.defer();
var callback = function (err, response, etc) {
if (err) {
dfd.reject(err);
return;
}
// if more arguments then turn into an array for .spread()
etc = Array.prototype.slice.call(arguments, 1);
dfd.resolve(etc.length > 1 ? etc : response);
};
args.push(authUtils.applied(callback));
nodeback.apply(self, args);
// spread polyfill only for promisify
dfd.promise.spread = dfd.promise.spread || function (fulfilled, rejected) {
return dfd.promise.then(function (array) {
return Array.isArray(array) ? fulfilled.apply(null, array) : fulfilled(array);
}, rejected);
};
return dfd.promise;
};
}
};
return authUtils;
authUtils.applied = function(fn) {
// Adding arguments just due to a bug in Auth0.js.
return function (err, response) {
// Using variables so that they don't get deleted by UglifyJS
err = err;
response = response;
var argsCall = arguments;
authUtils.safeApply(function() {
fn.apply(null, argsCall);
});
};
};
return authUtils;
};
});
});
angular.module('auth0.interceptor', [])
.factory('authInterceptor', function ($rootScope, $q, $injector) {
return {
request: function (config) {
// When using auth dependency is never loading, we need to do this manually
// This issue should be related with: https://github.com/angular/angular.js/issues/2367
if (!$injector.has('auth')) {
.provider('authInterceptor', function() {
var skipJWT = 'skipAuthorization';
var authHeader = 'Authorization';
var authPrefix = 'Bearer ';
this.setSkipJWT = function(name) {
skipJWT = name || skipJWT;
};
this.setAuthHeader = function(name) {
authHeader = name || authHeader;
};
this.setAuthPrefix = function(name) {
authPrefix = name || authPrefix;
};
this.$get = function ($rootScope, $q, $injector) {
var auth;
return {
request: function (config) {
// When using auth dependency is never loading, we need to do this manually
// This issue should be related with: https://github.com/angular/angular.js/issues/2367
if (config[skipJWT] || !$injector.has('auth')) {
return config;
}
auth = auth || $injector.get('auth');
config.headers = config.headers || {};
if (auth.idToken && !config.headers[authHeader]) {
config.headers[authHeader] = authPrefix + auth.idToken;
}
return config;
},
responseError: function (response) {
// handle the case where the user is not authenticated
if (response.status === 401) {
$rootScope.$broadcast('auth0.forbiddenRequest', response);
}
return $q.reject(response);
}
var auth = $injector.get('auth');
config.headers = config.headers || {};
if (auth.idToken && !config.headers.Authorization) {
config.headers.Authorization = 'Bearer '+ auth.idToken;
}
return config;
},
responseError: function (response) {
// handle the case where the user is not authenticated
if (response.status === 401) {
$rootScope.$broadcast('auth0.forbidden', response);
}
return $q.reject(response);
}
};
};

@@ -137,59 +161,60 @@ });

angular.module('auth0.storage', [])
.service('authStorage', function($injector) {
// Sets storage to use
var put, get, remove = null;
if (localStorage) {
put = function(what, value) {
return localStorage.setItem(what, value);
};
get = function(what) {
return localStorage.getItem(what);
};
remove = function(what) {
return localStorage.removeItem(what);
};
} else {
var $cookieStore = $injector.get('$cookieStore');
put = function(what, value) {
return $cookieStore.put(what, value);
};
get = function(what) {
return $cookieStore.get(what);
};
remove = function(what) {
return $cookieStore.remove(what);
};
.service('authStorage', function($injector) {
// Sets storage to use
var put, get, remove = null;
if (localStorage) {
put = function(what, value) {
return localStorage.setItem(what, value);
};
get = function(what) {
return localStorage.getItem(what);
};
remove = function(what) {
return localStorage.removeItem(what);
};
} else {
var $cookieStore = $injector.get('$cookieStore');
put = function(what, value) {
return $cookieStore.put(what, value);
};
get = function(what) {
return $cookieStore.get(what);
};
remove = function(what) {
return $cookieStore.remove(what);
};
}
this.store = function(idToken, accessToken, state, refreshToken) {
put('idToken', idToken);
if (accessToken) {
put('accessToken', accessToken);
}
if (state) {
put('state', state);
}
if (refreshToken) {
put('refreshToken', refreshToken);
}
};
this.store = function(idToken, accessToken, state, refreshToken) {
put('idToken', idToken);
if (accessToken) {
put('accessToken', accessToken);
}
if (state) {
put('state', state);
}
if (refreshToken) {
put('refreshToken', refreshToken);
}
this.get = function() {
return {
idToken: get('idToken'),
accessToken: get('accessToken'),
state: get('state'),
refreshToken: get('refreshToken')
};
};
this.get = function() {
return {
idToken: get('idToken'),
accessToken: get('accessToken'),
state: get('state'),
refreshToken: get('refreshToken')
};
};
this.remove = function() {
remove('idToken');
remove('accessToken');
remove('state');
remove('refreshToken');
};
});
this.remove = function() {
remove('idToken');
remove('accessToken');
remove('state');
remove('refreshToken');
};
});
angular.module('auth0.service', ['auth0.storage', 'auth0.utils']).provider('auth', function(authUtilsProvider) {
angular.module('auth0.service', ['auth0.storage', 'auth0.utils'])
.provider('auth', function(authUtilsProvider) {
var defaultOptions = {

@@ -259,2 +284,3 @@ callbackOnLocationHash: true

var callHandler = function(anEvent, locals) {
$rootScope.$broadcast('auth0.' + anEvent, locals);
angular.forEach(getHandlers(anEvent) || [], function(handler) {

@@ -314,3 +340,3 @@ $injector.invoke(handler, auth, locals);

if (storedValues.refreshToken) {
refreshingToken = auth.refreshToken(storedValues.refreshToken);
refreshingToken = auth.refreshIdToken(storedValues.refreshToken);
refreshingToken.then(function(idToken) {

@@ -320,3 +346,3 @@ onSigninOk(idToken, storedValues.accessToken, storedValues.state, storedValues.refreshToken, true);

forbidden();
}).finally(function() {
})['finally'](function() {
refreshingToken = null;

@@ -353,3 +379,3 @@ });

$rootScope.$on('auth0.forbidden', function() {
$rootScope.$on('auth0.forbiddenRequest', function() {
forbidden();

@@ -470,3 +496,3 @@ });

auth.refreshToken = function(refresh_token) {
auth.refreshIdToken = function(refresh_token) {
var refreshTokenAsync = authUtils.promisify(config.auth0js.refreshToken, config.auth0js);

@@ -505,3 +531,3 @@

if (config.isWidget) {
if (authUtils.isWidget(auth0lib)) {
signinCall(options, null);

@@ -580,2 +606,3 @@ } else {

});
}());

@@ -164,3 +164,3 @@ function executeInConfigBlock(cb, includes) {

$httpProvider.interceptors.push('authInterceptor');
$provide.decorator('auth', function () { return {idToken: 'w00t'}; });
$provide.decorator('auth', function () { return {idToken: 'w00t', hookEvents: function() {}}; });
});

@@ -199,3 +199,3 @@

$httpProvider.interceptors.push('authInterceptor');
$provide.decorator('auth', function () { return {idToken: 'w00t'}; });
$provide.decorator('auth', function () { return {idToken: 'w00t', hookEvents: function() {}}; });
});

@@ -270,3 +270,3 @@

it('should refresh the token OK', function (done) {
auth.refreshToken('refresh_token').then(function (token) {
auth.refreshIdToken('refresh_token').then(function (token) {
expect(token).to.be.ok;

@@ -273,0 +273,0 @@ })

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