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

authentication-adal-pkg

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

authentication-adal-pkg - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

2

lib/index.js

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

"use strict";function _defineProperty(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}var _slicedToArray=function(){function n(n,e){var t=[],r=!0,o=!1,i=void 0;try{for(var u,c=n[Symbol.iterator]();!(r=(u=c.next()).done)&&(t.push(u.value),!e||t.length!==e);r=!0);}catch(n){o=!0,i=n}finally{try{!r&&c.return&&c.return()}finally{if(o)throw i}}return t}return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return n(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();window.AuthenticationContext=require("adal-angular");var jwtDecode=require("jwt-decode"),eandisAuthenticator=function(n){var e={MOBILE:"mobile",BROWSER:"browser",STATE:"state",NONCE:"nonce",TOKEN:"token",TOKEN_EXPIRATION:"token.expiration",IN_PROGRESS:"progess"},t=null,r=null,o=null,i=null,u=null,c=null,a=null,l=null,f=null,d=null,h=null,m=null,O=null,g="",w={},v=function(n){t=n.authority,r=n.tenant,o=n.redirectUriWeb,i=n.redirectUriIOS,u=n.redirectUriAndroid,c=n.redirectUriWindows,a=n.resourceUri,f=n.clientId,d=n.userId,l=n.loginResource},E=function(n){if(n===e.BROWSER){var i={tenant:r,clientId:f,redirectUri:o,loginResource:l};h=new AuthenticationContext(i)}else m=new Microsoft.ADAL.AuthenticationContext(t)},R={prefix:"auth",set:function(n,e){localStorage.setItem(this.prefix+"-"+n,e)},get:function(n){return localStorage.getItem(this.prefix+"-"+n)},remove:function(n){localStorage.removeItem(this.prefix+"-"+n)}};R.set(e.IN_PROGRESS,!1);var p=function(){return window.cordova&&window.cordova.platformId||"browser"},I=function(){return new Promise(function(n,e){W(n,e)})},y=function(){return new Promise(function(n,t){try{m||E(e.MOBILE),m.tokenCache.clear(),n()}catch(n){t(n)}})},S=function(){return new Promise(function(n,t){try{h||E(e.BROWSER),h.logOut(),R.remove(e.TOKEN),n()}catch(n){t(n)}})},T=function(){return p()===e.BROWSER?S():y()},k=function(n,t,r){return new Promise(function(n,o){var i=function(e,t,r){r?o(r):n(t)};r?(h||E(e.BROWSER),h.acquireTokenPopup(f,null,null,i)):n(t)})},N=function(n,t,r){var o=R.get(e.TOKEN);if(o)n(o);else{h||E(e.BROWSER),h.handleWindowCallback();var i=function(e,r,o){k(e,r,o).then(n).catch(function(n){if("login required"===n)new Promise(function(n,e){W(n,e)});else t(n)})};h.acquireToken(f,i)}},b=function(n,t){m||E(e.MOBILE),m.tokenCache.readItems().then(function(e){var r=e.length-1,o=e[r]&&e[r].accessToken;o?n(o):t(new Error("No token found"))})},A=function(n){return new Promise(function(t,r){try{p()===e.BROWSER?N(t,r,n):b(t,r)}catch(n){r(n)}})},P=function(n){switch(n.toLowerCase()){case"android":O=u;break;case"ios":O=i;break;case"windows":O=c}},_=function(){return"true"===R.get(e.IN_PROGRESS)},x=function(){var n=R.get(e.TOKEN),t=R.get(e.TOKEN_EXPIRATION);return t&&parseInt(t,10)>Date.now()/1e3?{response:n,error:null}:g?{response:null,error:g}:{response:null,error:null}},B=function(n,r){Microsoft.ADAL.AuthenticationSettings.setUseBroker(!0).then(function(){E(e.MOBILE),P(p()),m.tokenCache.readItems().then(function(o){o.length>0&&(t=o[0].authority,E(e.MOBILE)),m.acquireTokenSilentAsync(a,f,d).then(n,function(){m.acquireTokenAsync(a,f,O).then(n,r)})})})},C=function(n,t){E(e.BROWSER);var r=x().response;r||_()||g?(h.saveTokenFromHash(h.getRequestInfo(window.location.hash)),n({token:r,error:null})):(R.set(e.IN_PROGRESS,!1),h.login(),n({token:null,error:null}))},W=function(n,t){try{p()===e.BROWSER?C(n,t):B(n,t)}catch(n){t(n)}},U=function(n){try{return jwtDecode(n)}catch(n){return console.error("unable to decode token",n),{}}},K=function n(){return Object.keys(w).length?Promise.resolve(w):A(n).then(function(n){var e=U(n),t=e.family_name,r=e.given_name,o=e.name,i=e.upn;return i||(i=U(n).email),w=j(t,r,o,i)})},q=function(){return R.get(e.TOKEN)},L=function(){var n=R.get(e.TOKEN);if(n){var t=U(n),r=t.family_name,o=t.given_name,i=t.name,u=t.upn;return u||(u=U(n).email),w=j(r,o,i,u)}},j=function(n,e,t,r){return{familyName:n,givenName:e,name:t,upn:r}},M=function(n){function e(n){var e,t=/\+/g,r=/([^&=]+)=?([^&]*)/g,o=function(){return decodeURIComponent(s.replace(t," "))},i={};for(e=r.exec(n);e;)i[o(e[1])]=o(e[2]),e=r.exec(n);return i}function t(n){var t="";return n.indexOf("#/")>-1?t=n.substring(n.indexOf("#/")+2):n.indexOf("#")>-1&&(t=n.substring(1)),t&&e(t)||null}function r(n){return n.substr(1).split("&").reduce(function(n,e){var t=e.split("="),r=_slicedToArray(t,2),o=r[0],i=r[1];return n.hasOwnProperty(o)?n:Object.assign({},n,_defineProperty({},o,decodeURIComponent(i)))},{})}return t(n||window.location.hash)||r(window.location.search)};return function(){var n=M(),t=function(e){return n[e]},r=t("id_token"),o=(t("state"),!0);if(r){var i=U(r),u=(i.nonce,i.aud,i.exp);i.family_name,i.given_name,i.name,i.upn;o&&(R.set(e.IN_PROGRESS,!1),R.set(e.TOKEN,r),R.set(e.TOKEN_EXPIRATION,u))}}(),{signIn:I,signOut:T,acquireToken:A,initialize:v,getUser:K,getUserFromCache:L,getTokenFromCache:q}}();module.exports={authentication:eandisAuthenticator};
"use strict";function _defineProperty(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}var _slicedToArray=function(){function n(n,e){var t=[],r=!0,o=!1,i=void 0;try{for(var u,c=n[Symbol.iterator]();!(r=(u=c.next()).done)&&(t.push(u.value),!e||t.length!==e);r=!0);}catch(n){o=!0,i=n}finally{try{!r&&c.return&&c.return()}finally{if(o)throw i}}return t}return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return n(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();window.AuthenticationContext=require("adal-angular");var jwtDecode=require("jwt-decode"),eandisAuthenticator=function(n){var e={MOBILE:"mobile",BROWSER:"browser",STATE:"state",NONCE:"nonce",TOKEN:"token",TOKEN_EXPIRATION:"token.expiration",IN_PROGRESS:"progess"},t=null,r=null,o=null,i=null,u=null,c=null,a=null,l=null,s=null,f=null,d=null,h=null,m=null,O="",g={},w=function(n){t=n.authority,r=n.tenant,o=n.redirectUriWeb,i=n.redirectUriIOS,u=n.redirectUriAndroid,c=n.redirectUriWindows,a=n.resourceUri,s=n.clientId,f=n.userId,l=n.loginResource},v=function(n){if(n===e.BROWSER){var i={tenant:r,clientId:s,redirectUri:o,loginResource:l};d=new AuthenticationContext(i)}else h=new Microsoft.ADAL.AuthenticationContext(t)},E={prefix:"auth",set:function(n,e){localStorage.setItem(this.prefix+"-"+n,e)},get:function(n){return localStorage.getItem(this.prefix+"-"+n)},remove:function(n){localStorage.removeItem(this.prefix+"-"+n)}};E.set(e.IN_PROGRESS,!1);var R=function(){return window.cordova&&window.cordova.platformId||"browser"},p=function(){return new Promise(function(n,e){C(n,e)})},I=function(){return new Promise(function(n,t){try{h||v(e.MOBILE),h.tokenCache.clear(),n()}catch(n){t(n)}})},y=function(){return new Promise(function(n,t){try{d||v(e.BROWSER),d.logOut(),E.remove(e.TOKEN),n()}catch(n){t(n)}})},S=function(){return R()===e.BROWSER?y():I()},T=function(n,t,r){return new Promise(function(n,o){var i=function(e,t,r){r?o(r):n(t)};r?(d||v(e.BROWSER),d.acquireTokenPopup(s,null,null,i)):n(t)})},k=function(n,t,r){var o=E.get(e.TOKEN);if(o)n(o);else{d||v(e.BROWSER),d.handleWindowCallback();var i=function(e,r,o){T(e,r,o).then(n).catch(function(n){if("login required"===n)new Promise(function(n,e){C(n,e)});else t(n)})};d.acquireToken(s,i)}},N=function(n,t){h||v(e.MOBILE),h.tokenCache.readItems().then(function(e){var r=e.length-1,o=e[r]&&e[r].accessToken;o?n(o):t(new Error("No token found"))})},b=function(n){return new Promise(function(t,r){try{R()===e.BROWSER?k(t,r,n):N(t,r)}catch(n){r(n)}})},A=function(n){switch(n.toLowerCase()){case"android":m=u;break;case"ios":m=i;break;case"windows":m=c}},P=function(){return"true"===E.get(e.IN_PROGRESS)},_=function(){var n=E.get(e.TOKEN),t=E.get(e.TOKEN_EXPIRATION);return t&&parseInt(t,10)>Date.now()/1e3?{response:n,error:null}:O?{response:null,error:O}:{response:null,error:null}},x=function(n,r){Microsoft.ADAL.AuthenticationSettings.setUseBroker(!0).then(function(){v(e.MOBILE),A(R()),h.tokenCache.readItems().then(function(o){o.length>0&&(t=o[0].authority,v(e.MOBILE)),h.acquireTokenSilentAsync(a,s,f).then(n,function(){h.acquireTokenAsync(a,s,m).then(n,r)})})})},B=function(n,t){v(e.BROWSER);var r=_().response;r||P()||O?(d.saveTokenFromHash(d.getRequestInfo(window.location.hash)),n({token:r,error:null})):(E.set(e.IN_PROGRESS,!1),d.login(),n({token:null,error:null}))},C=function(n,t){try{R()===e.BROWSER?B(n,t):x(n,t)}catch(n){t(n)}},W=function(n){try{return jwtDecode(n)}catch(n){return console.error("unable to decode token",n),{}}},U=function n(){return Object.keys(g).length?Promise.resolve(g):b(n).then(function(n){var e=W(n),t=e.family_name,r=e.given_name,o=e.name,i=e.upn;return i||(i=W(n).email),g=L(t,r,o,i)})},K=function(){return E.get(e.TOKEN)},q=function(){var n=E.get(e.TOKEN);if(n){var t=W(n),r=t.family_name,o=t.given_name,i=t.name,u=t.upn;return u||(u=W(n).email),g=L(r,o,i,u)}},L=function(n,e,t,r){return{familyName:n,givenName:e,name:t,upn:r}},j=function(n){function e(n){var e,t=/\+/g,r=/([^&=]+)=?([^&]*)/g,o=function(n){return decodeURIComponent(n.replace(t," "))},i={};for(e=r.exec(n);e;)i[o(e[1])]=o(e[2]),e=r.exec(n);return i}function t(n){var t="";return n.indexOf("#/")>-1?t=n.substring(n.indexOf("#/")+2):n.indexOf("#")>-1&&(t=n.substring(1)),t&&e(t)||null}function r(n){return n.substr(1).split("&").reduce(function(n,e){var t=e.split("="),r=_slicedToArray(t,2),o=r[0],i=r[1];return n.hasOwnProperty(o)?n:Object.assign({},n,_defineProperty({},o,decodeURIComponent(i)))},{})}return t(n||window.location.hash)||r(window.location.search)};return function(){var n=j(),t=function(e){return n[e]},r=t("id_token"),o=(t("state"),!0);if(r){var i=W(r),u=(i.nonce,i.aud,i.exp);i.family_name,i.given_name,i.name,i.upn;o&&(E.set(e.IN_PROGRESS,!1),E.set(e.TOKEN,r),E.set(e.TOKEN_EXPIRATION,u))}}(),{signIn:p,signOut:S,acquireToken:b,initialize:w,getUser:U,getUserFromCache:q,getTokenFromCache:K}}();module.exports={authentication:eandisAuthenticator};

@@ -333,3 +333,3 @@ 'use strict';

var search = /([^&=]+)=?([^&]*)/g;
var decode = function decode() {
var decode = function(s) {
return decodeURIComponent(s.replace(pl, ' '));

@@ -336,0 +336,0 @@ };

{
"name": "authentication-adal-pkg",
"version": "1.0.4",
"version": "1.0.5",
"description": "An authentication SDK based on MS ADAL ",

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

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