authentication-adal-pkg
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -21,2 +21,3 @@ window.AuthenticationContext = require('adal-angular'); | ||
var resourceUri = null; | ||
var loginResource = null; | ||
var clientId = null; | ||
@@ -32,11 +33,12 @@ var userId = null; | ||
const initialize = (config) => { | ||
authority = config.AUTHORITY; | ||
tenant = config.TENANT; | ||
redirectUriWeb = config.REDIRECTURIWEB; | ||
redirectUriIOS = config.REDIRECTURIIOS; | ||
redirectUriAndroid = config.REDIRECTURIANDROID; | ||
redirectUriWindows = config.REDIRECTURIWINDOWS; | ||
resourceUri = config.RESOURCEURI; | ||
clientId = config.CLIENTID; | ||
userId = config.USERID; | ||
authority = config.authority; | ||
tenant = config.tenant; | ||
redirectUriWeb = config.redirectUriWeb; | ||
redirectUriIOS = config.redirectUriIOS; | ||
redirectUriAndroid = config.redirectUriAndroid; | ||
redirectUriWindows = config.redirectUriWindows; | ||
resourceUri = config.resourceUri; | ||
clientId = config.clientId; | ||
userId = config.userId; | ||
loginResource = config.loginResource; | ||
} | ||
@@ -49,3 +51,4 @@ | ||
clientId: clientId, | ||
redirectUri: redirectUriWeb | ||
redirectUri: redirectUriWeb, | ||
loginResource: loginResource, | ||
}; | ||
@@ -52,0 +55,0 @@ auth = new AuthenticationContext(config); |
23
index.js
@@ -21,2 +21,3 @@ window.AuthenticationContext = require('adal-angular'); | ||
var resourceUri = null; | ||
var loginResource = null; | ||
var clientId = null; | ||
@@ -32,11 +33,12 @@ var userId = null; | ||
const initialize = (config) => { | ||
authority = config.AUTHORITY; | ||
tenant = config.TENANT; | ||
redirectUriWeb = config.REDIRECTURIWEB; | ||
redirectUriIOS = config.REDIRECTURIIOS; | ||
redirectUriAndroid = config.REDIRECTURIANDROID; | ||
redirectUriWindows = config.REDIRECTURIWINDOWS; | ||
resourceUri = config.RESOURCEURI; | ||
clientId = config.CLIENTID; | ||
userId = config.USERID; | ||
authority = config.authority; | ||
tenant = config.tenant; | ||
redirectUriWeb = config.redirectUriWeb; | ||
redirectUriIOS = config.redirectUriIOS; | ||
redirectUriAndroid = config.redirectUriAndroid; | ||
redirectUriWindows = config.redirectUriWindows; | ||
resourceUri = config.resourceUri; | ||
clientId = config.clientId; | ||
userId = config.userId; | ||
loginResource = config.loginResource; | ||
} | ||
@@ -49,3 +51,4 @@ | ||
clientId: clientId, | ||
redirectUri: redirectUriWeb | ||
redirectUri: redirectUriWeb, | ||
loginResource: loginResource, | ||
}; | ||
@@ -52,0 +55,0 @@ auth = new AuthenticationContext(config); |
@@ -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,a=n[Symbol.iterator]();!(r=(u=a.next()).done)&&(t.push(u.value),!e||t.length!==e);r=!0);}catch(n){o=!0,i=n}finally{try{!r&&a.return&&a.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,a=null,c=null,l=null,f=null,R=null,E=null,O=null,d=null,h="",I={},m=function(n){t=n.AUTHORITY,r=n.TENANT,o=n.REDIRECTURIWEB,i=n.REDIRECTURIIOS,u=n.REDIRECTURIANDROID,a=n.REDIRECTURIWINDOWS,c=n.RESOURCEURI,f=n.CLIENTID,R=n.USERID,l=n.LOGINRESOURCE},g=function(n){if(n===e.BROWSER){var i={tenant:r,clientId:f,redirectUri:o,loginResource:l};E=new AuthenticationContext(i)}else O=new Microsoft.ADAL.AuthenticationContext(t)},w={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)}};w.set(e.IN_PROGRESS,!1);var v=function(){return window.cordova&&window.cordova.platformId||"browser"},T=function(){return new Promise(function(n,e){U(n,e)})},p=function(){return new Promise(function(n,t){try{O||g(e.MOBILE),O.tokenCache.clear(),n()}catch(n){t(n)}})},S=function(){return new Promise(function(n,t){try{E||g(e.BROWSER),E.logOut(),w.remove(e.TOKEN),n()}catch(n){t(n)}})},N=function(){return v()===e.BROWSER?S():p()},y=function(n,t,r){return new Promise(function(n,o){var i=function(e,t,r){r?o(r):n(t)};r?(E||g(e.BROWSER),E.acquireTokenPopup(f,null,null,i)):n(t)})},k=function(n,t,r){var o=w.get(e.TOKEN);if(o)n(o);else{E||g(e.BROWSER),E.handleWindowCallback();var i=function(e,r,o){y(e,r,o).then(n).catch(function(n){if("login required"===n)new Promise(function(n,e){U(n,e)});else t(n)})};E.acquireToken(f,i)}},A=function(n,t){O||g(e.MOBILE),O.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{v()===e.BROWSER?k(t,r,n):A(t,r)}catch(n){r(n)}})},C=function(n){switch(n.toLowerCase()){case"android":d=u;break;case"ios":d=i;break;case"windows":d=a}},P=function(){return"true"===w.get(e.IN_PROGRESS)},_=function(){var n=w.get(e.TOKEN),t=w.get(e.TOKEN_EXPIRATION);return t&&parseInt(t,10)>Date.now()/1e3?{response:n,error:null}:h?{response:null,error:h}:{response:null,error:null}},x=function(n,r){Microsoft.ADAL.AuthenticationSettings.setUseBroker(!0).then(function(){g(e.MOBILE),C(v()),O.tokenCache.readItems().then(function(o){o.length>0&&(t=o[0].authority,g(e.MOBILE)),O.acquireTokenSilentAsync(c,f,R).then(n,function(){O.acquireTokenAsync(c,f,d).then(n,r)})})})},B=function(n,t){g(e.BROWSER);var r=_().response;r||P()||h?(E.saveTokenFromHash(E.getRequestInfo(window.location.hash)),n({token:r,error:null})):(w.set(e.IN_PROGRESS,!1),E.login(),n({token:null,error:null}))},U=function(n,t){try{v()===e.BROWSER?B(n,t):x(n,t)}catch(n){t(n)}},D=function(n){try{return jwtDecode(n)}catch(n){return console.error("unable to decode token",n),{}}},W=function n(){return Object.keys(I).length?Promise.resolve(I):b(n).then(function(n){var e=D(n),t=e.family_name,r=e.given_name,o=e.name,i=e.upn;return i||(i=D(n).email),I=q(t,r,o,i)})},K=function(){return w.get(e.TOKEN)},L=function(){var n=w.get(e.TOKEN);if(n){var t=D(n),r=t.family_name,o=t.given_name,i=t.name,u=t.upn;return u||(u=D(n).email),I=q(r,o,i,u)}},q=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(){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=j(),t=function(e){return n[e]},r=t("id_token"),o=(t("state"),!0);if(r){var i=D(r),u=(i.nonce,i.aud,i.exp);i.family_name,i.given_name,i.name,i.upn;o&&(w.set(e.IN_PROGRESS,!1),w.set(e.TOKEN,r),w.set(e.TOKEN_EXPIRATION,u))}}(),{signIn:T,signOut:N,acquireToken:b,initialize:m,getUser:W,getUserFromCache:L,getTokenFromCache:K}}();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,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}; |
@@ -38,12 +38,12 @@ 'use strict'; | ||
var initialize = function initialize(config) { | ||
authority = config.AUTHORITY; | ||
tenant = config.TENANT; | ||
redirectUriWeb = config.REDIRECTURIWEB; | ||
redirectUriIOS = config.REDIRECTURIIOS; | ||
redirectUriAndroid = config.REDIRECTURIANDROID; | ||
redirectUriWindows = config.REDIRECTURIWINDOWS; | ||
resourceUri = config.RESOURCEURI; | ||
clientId = config.CLIENTID; | ||
userId = config.USERID; | ||
loginResource = config.LOGINRESOURCE; | ||
authority = config.authority; | ||
tenant = config.tenant; | ||
redirectUriWeb = config.redirectUriWeb; | ||
redirectUriIOS = config.redirectUriIOS; | ||
redirectUriAndroid = config.redirectUriAndroid; | ||
redirectUriWindows = config.redirectUriWindows; | ||
resourceUri = config.resourceUri; | ||
clientId = config.clientId; | ||
userId = config.userId; | ||
loginResource = config.loginResource; | ||
}; | ||
@@ -50,0 +50,0 @@ |
@@ -32,12 +32,12 @@ window.AuthenticationContext = require('adal-angular'); | ||
const initialize = (config) => { | ||
authority = config.AUTHORITY; | ||
tenant = config.TENANT; | ||
redirectUriWeb = config.REDIRECTURIWEB; | ||
redirectUriIOS = config.REDIRECTURIIOS; | ||
redirectUriAndroid = config.REDIRECTURIANDROID; | ||
redirectUriWindows = config.REDIRECTURIWINDOWS; | ||
resourceUri = config.RESOURCEURI; | ||
clientId = config.CLIENTID; | ||
userId = config.USERID; | ||
loginResource = config.LOGINRESOURCE; | ||
authority = config.authority; | ||
tenant = config.tenant; | ||
redirectUriWeb = config.redirectUriWeb; | ||
redirectUriIOS = config.redirectUriIOS; | ||
redirectUriAndroid = config.redirectUriAndroid; | ||
redirectUriWindows = config.redirectUriWindows; | ||
resourceUri = config.resourceUri; | ||
clientId = config.clientId; | ||
userId = config.userId; | ||
loginResource = config.loginResource; | ||
} | ||
@@ -44,0 +44,0 @@ |
{ | ||
"name": "authentication-adal-pkg", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "An authentication SDK based on MS ADAL ", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
51355
1406