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 1.1.4 to 1.1.5

docs/custom-storage.md

1

build/auth0-angular.js

@@ -233,2 +233,3 @@ (function () {

function forbidden() {
authStorage.remove();
if (config.loginUrl) {

@@ -235,0 +236,0 @@ $location.path(config.loginUrl);

2

build/auth0-angular.min.js

@@ -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.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){a&&f.reject(a),c=Array.prototype.slice.call(arguments,1),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(){var b=arguments;d.safeApply(function(){a.apply(null,b)})}},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",["ngCookies"]).service("authStorage",["$cookieStore",function(a){this.store=function(b,c,d){a.put("idToken",b),a.put("accessToken",c),d&&a.put("state",d)},this.get=function(){return{idToken:a.get("idToken"),accessToken:a.get("accessToken"),state:a.get("state")}},this.remove=function(){a.remove("idToken"),a.remove("accessToken"),a.remove("state")}}]),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,this.sso=a.sso;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(){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){e.store(a,b,c);var f=j.getProfile(a),g={idToken:a,accessToken:b,state:c,isAuthenticated:!0};return angular.extend(j,g),l("loginSuccess",angular.extend({profile:f,locationEvent:d},g)),f};a.$on("$locationChangeStart",function(a){var b=c.auth0lib.parseHash(f.location.hash);if(!j.isAuthenticated){if(b&&b.id_token)return void m(b.id_token,b.access_token,b.state,a);var d=e.get();if(d&&d.idToken)return j.hasTokenExpired(d.idToken)?void i():void m(d.idToken,d.accessToken,d.state,a);c.sso&&c.auth0js.getSSOData(h.applied(function(a,b){b.sso&&j.signin({popup:!1,connection:b.lastUsedConnection.strategy},c.auth0js)}))}}),a.$on("auth0.forbidden",function(){i()}),c.loginUrl&&a.$on("$routeChangeStart",function(a,b){b.$$route&&b.$$route.requiresLogin&&(j.isAuthenticated||g.path(c.loginUrl))}),c.loginState&&a.$on("$stateChangeStart",function(a,b){b.data&&b.data.requiresLogin&&(j.isAuthenticated||(a.preventDefault(),d.get("$state").go(c.loginState)))}),j.config=c;var n=function(a){var b=k("loginSuccess");if(!(a.popup||a.username||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.hasTokenExpired=function(a){if(!a)return!0;var b=a.split(".");if(3!==b.length)return!0;var c=h.urlBase64Decode(b[1]);if(!c)return!0;try{c=JSON.parse(c)}catch(d){return!0}if(!c.exp)return!0;var e=new Date(0);return e.setUTCSeconds(c.exp),isNaN(e)?!0:e.valueOf()>(new Date).valueOf()?!1:!0},j.getToken=function(a,b){b=b||{scope:"openid"};var d=h.promisify(c.auth0js.getDelegationToken,c.auth0js);return d(a,j.idToken,b).then(function(a){return a.id_token})},j.refreshToken=function(a){return j.getToken(c.clientID,a)},j.signin=function(a,b){a=a||{},n(a);var d=b||c.auth0lib,e=h.promisify(d.signin,d),f=c.isWidget?e(a,null):e(a);return f.spread(function(a,b,c,d){return m(b,c,d)})["catch"](function(a){throw l("loginFailure",{error:a}),a})},j.signup=function(a){a=a||{},n(a);var b=c.auth0lib,d=h.promisify(b.signup,b),e=c.isWidget?d(a,null):d(a);return e.spread(function(a,b,c,d){return m(b,c,d)})["catch"](function(a){throw l("loginFailure",{error:a}),a})},j.reset=function(a){a=a||{};var b=c.auth0lib,d=h.promisify(b.reset,b);return c.isWidget?d(a,null):d(a)},j.signout=function(){e.remove(),j.profile=null,j.idToken=null,j.state=null,j.accessToken=null,j.isAuthenticated=!1,l("logout")},j.getProfile=function(a){var b=h.promisify(c.auth0lib.getProfile,c.auth0lib);return b(a||j.idToken).then(function(a){return j.profile=a,a})},j}]}])}();
!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.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){a&&f.reject(a),c=Array.prototype.slice.call(arguments,1),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(){var b=arguments;d.safeApply(function(){a.apply(null,b)})}},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",["ngCookies"]).service("authStorage",["$cookieStore",function(a){this.store=function(b,c,d){a.put("idToken",b),a.put("accessToken",c),d&&a.put("state",d)},this.get=function(){return{idToken:a.get("idToken"),accessToken:a.get("accessToken"),state:a.get("state")}},this.remove=function(){a.remove("idToken"),a.remove("accessToken"),a.remove("state")}}]),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,this.sso=a.sso;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){e.store(a,b,c);var f=j.getProfile(a),g={idToken:a,accessToken:b,state:c,isAuthenticated:!0};return angular.extend(j,g),l("loginSuccess",angular.extend({profile:f,locationEvent:d},g)),f};a.$on("$locationChangeStart",function(a){var b=c.auth0lib.parseHash(f.location.hash);if(!j.isAuthenticated){if(b&&b.id_token)return void m(b.id_token,b.access_token,b.state,a);var d=e.get();if(d&&d.idToken)return j.hasTokenExpired(d.idToken)?void i():void m(d.idToken,d.accessToken,d.state,a);c.sso&&c.auth0js.getSSOData(h.applied(function(a,b){b.sso&&j.signin({popup:!1,connection:b.lastUsedConnection.strategy},c.auth0js)}))}}),a.$on("auth0.forbidden",function(){i()}),c.loginUrl&&a.$on("$routeChangeStart",function(a,b){b.$$route&&b.$$route.requiresLogin&&(j.isAuthenticated||g.path(c.loginUrl))}),c.loginState&&a.$on("$stateChangeStart",function(a,b){b.data&&b.data.requiresLogin&&(j.isAuthenticated||(a.preventDefault(),d.get("$state").go(c.loginState)))}),j.config=c;var n=function(a){var b=k("loginSuccess");if(!(a.popup||a.username||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.hasTokenExpired=function(a){if(!a)return!0;var b=a.split(".");if(3!==b.length)return!0;var c=h.urlBase64Decode(b[1]);if(!c)return!0;try{c=JSON.parse(c)}catch(d){return!0}if(!c.exp)return!0;var e=new Date(0);return e.setUTCSeconds(c.exp),isNaN(e)?!0:e.valueOf()>(new Date).valueOf()?!1:!0},j.getToken=function(a,b){b=b||{scope:"openid"};var d=h.promisify(c.auth0js.getDelegationToken,c.auth0js);return d(a,j.idToken,b).then(function(a){return a.id_token})},j.refreshToken=function(a){return j.getToken(c.clientID,a)},j.signin=function(a,b){a=a||{},n(a);var d=b||c.auth0lib,e=h.promisify(d.signin,d),f=c.isWidget?e(a,null):e(a);return f.spread(function(a,b,c,d){return m(b,c,d)})["catch"](function(a){throw l("loginFailure",{error:a}),a})},j.signup=function(a){a=a||{},n(a);var b=c.auth0lib,d=h.promisify(b.signup,b),e=c.isWidget?d(a,null):d(a);return e.spread(function(a,b,c,d){return m(b,c,d)})["catch"](function(a){throw l("loginFailure",{error:a}),a})},j.reset=function(a){a=a||{};var b=c.auth0lib,d=h.promisify(b.reset,b);return c.isWidget?d(a,null):d(a)},j.signout=function(){e.remove(),j.profile=null,j.idToken=null,j.state=null,j.accessToken=null,j.isAuthenticated=!1,l("logout")},j.getProfile=function(a){var b=h.promisify(c.auth0lib.getProfile,c.auth0lib);return b(a||j.idToken).then(function(a){return j.profile=a,a})},j}]}])}();
# 1.1.x
## 1.1.5
* Updated documentation to add custom storage
* When forbiden, deleting stored values
## 1.1.3

@@ -4,0 +8,0 @@ * Implemented token expired functionality. Fixes #54

@@ -233,2 +233,3 @@ (function () {

function forbidden() {
authStorage.remove();
if (config.loginUrl) {

@@ -235,0 +236,0 @@ $location.path(config.loginUrl);

@@ -233,2 +233,3 @@ (function () {

function forbidden() {
authStorage.remove();
if (config.loginUrl) {

@@ -235,0 +236,0 @@ $location.path(config.loginUrl);

@@ -233,2 +233,3 @@ (function () {

function forbidden() {
authStorage.remove();
if (config.loginUrl) {

@@ -235,0 +236,0 @@ $location.path(config.loginUrl);

@@ -233,2 +233,3 @@ (function () {

function forbidden() {
authStorage.remove();
if (config.loginUrl) {

@@ -235,0 +236,0 @@ $location.path(config.loginUrl);

@@ -233,2 +233,3 @@ (function () {

function forbidden() {
authStorage.remove();
if (config.loginUrl) {

@@ -235,0 +236,0 @@ $location.path(config.loginUrl);

@@ -233,2 +233,3 @@ (function () {

function forbidden() {
authStorage.remove();
if (config.loginUrl) {

@@ -235,0 +236,0 @@ $location.path(config.loginUrl);

@@ -233,2 +233,3 @@ (function () {

function forbidden() {
authStorage.remove();
if (config.loginUrl) {

@@ -235,0 +236,0 @@ $location.path(config.loginUrl);

@@ -233,2 +233,3 @@ (function () {

function forbidden() {
authStorage.remove();
if (config.loginUrl) {

@@ -235,0 +236,0 @@ $location.path(config.loginUrl);

@@ -233,2 +233,3 @@ (function () {

function forbidden() {
authStorage.remove();
if (config.loginUrl) {

@@ -235,0 +236,0 @@ $location.path(config.loginUrl);

@@ -233,2 +233,3 @@ (function () {

function forbidden() {
authStorage.remove();
if (config.loginUrl) {

@@ -235,0 +236,0 @@ $location.path(config.loginUrl);

{
"name": "auth0-angular",
"version": "1.1.4",
"version": "1.1.5",
"main": "./build/auth0-angular.js",

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

@@ -344,2 +344,6 @@ # Auth0 and AngularJS

### Using your custom storage
**[Click here to learn how to use your custom storage to store the tokens instead of ngCookies](docs/custom-storage.md)**
### Delegation Token

@@ -346,0 +350,0 @@

@@ -234,2 +234,3 @@ (function () {

function forbidden() {
authStorage.remove();
if (config.loginUrl) {

@@ -236,0 +237,0 @@ $location.path(config.loginUrl);

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