@blackbaud/auth-client
Advanced tools
Comparing version 1.11.0 to 1.12.0
@@ -86,3 +86,4 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var SIGNIN_URL = 'https://signin.blackbaud.com/signin/'; | ||
var SIGNIN_BASE_URL = 'https://signin.blackbaud.com/signin/'; | ||
var euc = encodeURIComponent; | ||
function paramsToQS(params) { | ||
@@ -93,3 +94,3 @@ var qs = []; | ||
if (params.hasOwnProperty(p)) { | ||
qs.push(encodeURIComponent(p) + "=" + encodeURIComponent(params[p])); | ||
qs.push(euc(p) + "=" + euc(params[p])); | ||
} | ||
@@ -99,2 +100,9 @@ } | ||
} | ||
function createSigninUrl(inactive) { | ||
var url = SIGNIN_BASE_URL + "?redirectUrl=" + euc(location.href); | ||
if (inactive) { | ||
url += '&inactivity=1'; | ||
} | ||
return url; | ||
} | ||
var BBAuthNavigator = (function () { | ||
@@ -108,3 +116,3 @@ function BBAuthNavigator() { | ||
BBAuthNavigator.redirectToSignin = function (signinRedirectParams) { | ||
var signinUrl = SIGNIN_URL + '?redirectUrl=' + encodeURIComponent(location.href); | ||
var signinUrl = createSigninUrl(); | ||
if (signinRedirectParams) { | ||
@@ -115,2 +123,7 @@ signinUrl += '&' + paramsToQS(signinRedirectParams); | ||
}; | ||
BBAuthNavigator.redirectToSignoutForInactivity = function () { | ||
var signinUrl = createSigninUrl(true); | ||
var signoutUrl = SIGNIN_BASE_URL + "sign-out?redirectUrl=" + euc(signinUrl); | ||
this.navigate(signoutUrl); | ||
}; | ||
return BBAuthNavigator; | ||
@@ -223,3 +236,3 @@ }()); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(__webpack_require__(16)); | ||
__export(__webpack_require__(17)); | ||
__export(__webpack_require__(7)); | ||
@@ -298,2 +311,5 @@ __export(__webpack_require__(10)); | ||
}; | ||
BBAuth.clearTokenCache = function () { | ||
BBAuth.tokenCache = {}; | ||
}; | ||
BBAuth.getTokenInternal = function (args) { | ||
@@ -360,4 +376,4 @@ var forceNewToken = args.forceNewToken, disableRedirect = args.disableRedirect; | ||
var auth_1 = __webpack_require__(1); | ||
var interop_1 = __webpack_require__(17); | ||
var omnibar_user_activity_1 = __webpack_require__(15); | ||
var interop_1 = __webpack_require__(18); | ||
var omnibar_user_activity_1 = __webpack_require__(16); | ||
var navigator_1 = __webpack_require__(0); | ||
@@ -421,3 +437,3 @@ var CLS_EXPANDED = 'sky-omnibar-iframe-expanded'; | ||
function refreshUserCallback() { | ||
auth_1.BBAuth.getToken(true).then(function (token) { | ||
function refreshUser(token) { | ||
interop_1.BBAuthInterop.postOmnibarMessage(iframeEl, { | ||
@@ -427,8 +443,25 @@ messageType: 'refresh-user', | ||
}); | ||
} | ||
auth_1.BBAuth.clearTokenCache(); | ||
auth_1.BBAuth.getToken({ | ||
disableRedirect: true, | ||
forceNewToken: true | ||
}) | ||
.then(refreshUser) | ||
.catch(function () { return refreshUser(undefined); }); | ||
} | ||
function showInactivityCallback() { | ||
interop_1.BBAuthInterop.postOmnibarMessage(iframeEl, { | ||
messageType: 'inactivity-show' | ||
}); | ||
} | ||
function hideInactivityCallback() { | ||
interop_1.BBAuthInterop.postOmnibarMessage(iframeEl, { | ||
messageType: 'inactivity-hide' | ||
}); | ||
} | ||
function handleGetToken(tokenRequestId, disableRedirect) { | ||
auth_1.BBAuth.getToken(false, disableRedirect) | ||
.then(function (token) { | ||
omnibar_user_activity_1.BBOmnibarUserActivity.startTracking(refreshUserCallback); | ||
omnibar_user_activity_1.BBOmnibarUserActivity.startTracking(refreshUserCallback, showInactivityCallback, hideInactivityCallback, disableRedirect); | ||
interop_1.BBAuthInterop.postOmnibarMessage(iframeEl, { | ||
@@ -441,2 +474,3 @@ messageType: 'token', | ||
.catch(function (reason) { | ||
omnibar_user_activity_1.BBOmnibarUserActivity.startTracking(refreshUserCallback, showInactivityCallback, hideInactivityCallback, disableRedirect); | ||
interop_1.BBAuthInterop.postOmnibarMessage(iframeEl, { | ||
@@ -550,2 +584,5 @@ messageType: 'token-fail', | ||
break; | ||
case 'session-renew': | ||
omnibar_user_activity_1.BBOmnibarUserActivity.userRenewedSession(); | ||
break; | ||
} | ||
@@ -725,2 +762,51 @@ } | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var BBOmnibarUserActivityProcessor = (function () { | ||
function BBOmnibarUserActivityProcessor() { | ||
} | ||
BBOmnibarUserActivityProcessor.process = function (args) { | ||
var allowAnonymous = args.allowAnonymous, closeInactivityPrompt = args.closeInactivityPrompt, expirationDate = args.expirationDate, inactivityPromptDuration = args.inactivityPromptDuration, isShowingInactivityPrompt = args.isShowingInactivityPrompt, lastActivity = args.lastActivity, maxSessionAge = args.maxSessionAge, minRenewalAge = args.minRenewalAge, redirectForInactivity = args.redirectForInactivity, renewSession = args.renewSession, showInactivityPrompt = args.showInactivityPrompt; | ||
var now = Date.now(); | ||
// This is for the edge case where the user has signed out in another window but session | ||
// watcher hasn't yet redirected this window to the sign in page. Just return and let | ||
// session watcher trigger the redirect. | ||
if (expirationDate === null) { | ||
return; | ||
} | ||
if (now > expirationDate) { | ||
redirectForInactivity(); | ||
} | ||
// When the inactivity prompt is scheduled to be shown. | ||
var promptDate = expirationDate - inactivityPromptDuration; | ||
// When the next renewal opportunity will occur. | ||
var renewDate = expirationDate - maxSessionAge + minRenewalAge; | ||
// If we're showing the prompt, then don't process renewals based on activity. They will need to | ||
// physically click on the prompt now. | ||
if (isShowingInactivityPrompt) { | ||
// The inactivity prompt was dismissed in another window. Hide this one. | ||
if (now < promptDate) { | ||
closeInactivityPrompt(); | ||
} | ||
} | ||
else { | ||
if (lastActivity > renewDate) { | ||
renewSession(); | ||
} | ||
else if (!allowAnonymous && now > promptDate) { | ||
showInactivityPrompt(); | ||
} | ||
} | ||
}; | ||
return BBOmnibarUserActivityProcessor; | ||
}()); | ||
exports.BBOmnibarUserActivityProcessor = BBOmnibarUserActivityProcessor; | ||
/***/ }), | ||
/* 16 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var omnibar_user_activity_processor_1 = __webpack_require__(15); | ||
var csrf_xhr_1 = __webpack_require__(2); | ||
@@ -731,11 +817,16 @@ var navigator_1 = __webpack_require__(0); | ||
var clientY; | ||
var currentHideInactivityCallback; | ||
var currentRefreshUserCallback; | ||
var currentShowInactivityCallback; | ||
var isShowingInactivityPrompt; | ||
var lastActivity; | ||
var lastRenewal; | ||
var renewOnNextActivity; | ||
var intervalId; | ||
var lastSessionId; | ||
var lastRefreshId = ''; | ||
var ttlCache; | ||
var watcherIFrame; | ||
var currentRefreshUserCallback; | ||
function getTimestamp() { | ||
return new Date().getTime(); | ||
var currentAllowAnonymous; | ||
function trackUserActivity() { | ||
lastActivity = Date.now(); | ||
} | ||
@@ -752,13 +843,29 @@ function trackMouseMove(e) { | ||
} | ||
function renewSession() { | ||
csrf_xhr_1.BBCsrfXhr.request('https://s21aidntoken00blkbapp01.nxt.blackbaud.com/session/renew', { | ||
inactivity: 1 | ||
function getSessionExpiration(refreshId) { | ||
if (ttlCache && ttlCache.refreshId === refreshId) { | ||
return ttlCache.promise; | ||
} | ||
var promise = new Promise(function (resolve, reject) { | ||
csrf_xhr_1.BBCsrfXhr.request('https://s21aidntoken00blkbapp01.nxt.blackbaud.com/session/ttl', undefined, currentAllowAnonymous) | ||
.then(function (ttl) { | ||
var expirationDate = (ttl === null) ? null : Date.now() + ttl * 1000; | ||
resolve(expirationDate); | ||
}) | ||
.catch(function () { | ||
resolve(null); | ||
}); | ||
}); | ||
lastRenewal = getTimestamp(); | ||
renewOnNextActivity = false; | ||
ttlCache = { | ||
promise: promise, | ||
refreshId: refreshId | ||
}; | ||
return promise; | ||
} | ||
function trackUserActivity() { | ||
lastActivity = getTimestamp(); | ||
if (renewOnNextActivity) { | ||
renewSession(); | ||
function renewSession() { | ||
var now = Date.now(); | ||
if (!lastRenewal || now - lastRenewal > BBOmnibarUserActivity.MIN_RENEWAL_RETRY) { | ||
lastRenewal = now; | ||
csrf_xhr_1.BBCsrfXhr.request('https://s21aidntoken00blkbapp01.nxt.blackbaud.com/session/renew', { | ||
inactivity: 1 | ||
}).catch(/* istanbul ignore next */ function () { return undefined; }); | ||
} | ||
@@ -770,2 +877,11 @@ } | ||
} | ||
function showInactivityPrompt() { | ||
isShowingInactivityPrompt = true; | ||
currentShowInactivityCallback(); | ||
} | ||
function closeInactivityPrompt() { | ||
isShowingInactivityPrompt = false; | ||
trackUserActivity(); | ||
currentHideInactivityCallback(); | ||
} | ||
function startActivityTimer() { | ||
@@ -775,10 +891,27 @@ // It's possible the user was active on another web page and just navigated to this | ||
// play it safe and renew the session immediately. | ||
renewSession(); | ||
if (!currentAllowAnonymous) { | ||
renewSession(); | ||
} | ||
intervalId = setInterval(function () { | ||
if (getTimestamp() - lastRenewal > BBOmnibarUserActivity.MIN_RENEWAL_AGE) { | ||
renewOnNextActivity = true; | ||
} | ||
getSessionExpiration(lastRefreshId).then(function (expirationDate) { | ||
omnibar_user_activity_processor_1.BBOmnibarUserActivityProcessor.process({ | ||
allowAnonymous: currentAllowAnonymous, | ||
closeInactivityPrompt: closeInactivityPrompt, | ||
expirationDate: expirationDate, | ||
inactivityPromptDuration: BBOmnibarUserActivity.INACTIVITY_PROMPT_DURATION, | ||
isShowingInactivityPrompt: isShowingInactivityPrompt, | ||
lastActivity: lastActivity, | ||
maxSessionAge: BBOmnibarUserActivity.MAX_SESSION_AGE, | ||
minRenewalAge: BBOmnibarUserActivity.MIN_RENEWAL_AGE, | ||
redirectForInactivity: navigator_1.BBAuthNavigator.redirectToSignoutForInactivity, | ||
renewSession: renewSession, | ||
showInactivityPrompt: showInactivityPrompt | ||
}); | ||
}); | ||
}, BBOmnibarUserActivity.ACTIVITY_TIMER_INTERVAL); | ||
} | ||
function createWatcherIFrame(url) { | ||
function createWatcherIFrame() { | ||
var url = BBOmnibarUserActivity.IDENTITY_SECURITY_TOKEN_SERVICE_ORIGIN + | ||
'/SessionWatcher.html?origin=' + | ||
encodeURIComponent(location.origin); | ||
watcherIFrame = document.createElement('iframe'); | ||
@@ -806,12 +939,15 @@ watcherIFrame.className = 'sky-omnibar-iframe-session-watcher'; | ||
var message = data.message; | ||
// Session ID changes whenever the user logs in the user profile information | ||
// (e.g. name, email address ,etc.) changes | ||
var sessionId = message && message.sessionId; | ||
if (sessionId) { | ||
if (lastSessionId && sessionId !== lastSessionId) { | ||
currentRefreshUserCallback(); | ||
} | ||
lastSessionId = sessionId; | ||
} | ||
else { | ||
// Refresh ID changes whenever a user's session is extended due to activity. | ||
var refreshId = message && message.refreshId; | ||
if (!sessionId && !currentAllowAnonymous) { | ||
navigator_1.BBAuthNavigator.redirectToSignin(); | ||
} | ||
if (lastSessionId !== undefined && sessionId !== lastSessionId) { | ||
currentRefreshUserCallback(); | ||
} | ||
lastRefreshId = refreshId; | ||
lastSessionId = sessionId; | ||
} | ||
@@ -822,5 +958,3 @@ } | ||
window.addEventListener('message', messageListener, false); | ||
createWatcherIFrame(BBOmnibarUserActivity.IDENTITY_SECURITY_TOKEN_SERVICE_ORIGIN + | ||
'/SessionWatcher.html?origin=' + | ||
encodeURIComponent(location.origin)); | ||
createWatcherIFrame(); | ||
} | ||
@@ -830,11 +964,19 @@ var BBOmnibarUserActivity = (function () { | ||
} | ||
BBOmnibarUserActivity.startTracking = function (refreshUserCallback) { | ||
if (!isTracking) { | ||
BBOmnibarUserActivity.startTracking = function (refreshUserCallback, showInactivityCallback, hideInactivityCallback, allowAnonymous) { | ||
if (!isTracking || allowAnonymous !== currentAllowAnonymous) { | ||
BBOmnibarUserActivity.stopTracking(); | ||
currentRefreshUserCallback = refreshUserCallback; | ||
currentShowInactivityCallback = showInactivityCallback; | ||
currentHideInactivityCallback = hideInactivityCallback; | ||
currentAllowAnonymous = allowAnonymous; | ||
addActivityListeners(); | ||
startActivityTimer(); | ||
redirectIfUserLogsOutLater(); | ||
currentRefreshUserCallback = refreshUserCallback; | ||
isTracking = true; | ||
} | ||
}; | ||
BBOmnibarUserActivity.userRenewedSession = function () { | ||
closeInactivityPrompt(); | ||
renewSession(); | ||
}; | ||
BBOmnibarUserActivity.stopTracking = function () { | ||
@@ -858,18 +1000,26 @@ if (watcherIFrame) { | ||
lastRenewal = undefined; | ||
renewOnNextActivity = undefined; | ||
lastSessionId = undefined; | ||
ttlCache = undefined; | ||
isShowingInactivityPrompt = undefined; | ||
currentRefreshUserCallback = undefined; | ||
currentShowInactivityCallback = undefined; | ||
currentHideInactivityCallback = undefined; | ||
currentAllowAnonymous = undefined; | ||
}; | ||
return BBOmnibarUserActivity; | ||
}()); | ||
// The interval in milliseconds that the last activity is evaluated against the session timeout period. | ||
BBOmnibarUserActivity.ACTIVITY_TIMER_INTERVAL = 1000; | ||
// The amount of millseconds that the expiration prompt will show before the session actually expires. | ||
BBOmnibarUserActivity.ABOUT_TO_EXPIRE_PROMPT_TIMEFRAME = 2 * 60 * 1000; | ||
// The amount of millseconds that a session is allowed without activity. | ||
BBOmnibarUserActivity.MAX_SESSION_AGE = 30 * 60 * 1000; | ||
// The minimum time in milliseconds that must elapse before this omnibar instance will issue a session renewal | ||
// after the previous session renewal. | ||
BBOmnibarUserActivity.MIN_RENEWAL_RETRY = 1 * 60 * 1000; | ||
// The tim in millseconds that the expiration prompt will show before the session actually expires. When the | ||
// prompt shows will be determined by subtracting this value from the MAX_SESSION_AGE; for instance, if the | ||
// prompt duration is 2 minutes and the max session age is 15 minutes, the inactivity prompt will be displayed | ||
// 13 minutes after the last user activity. | ||
BBOmnibarUserActivity.INACTIVITY_PROMPT_DURATION = 2 * 60 * 1000; | ||
// The minimum age in milliseconds of the session before it will be renewed in response to user activity. | ||
BBOmnibarUserActivity.MIN_RENEWAL_AGE = 5 * 60 * 1000; | ||
// The minimum amount of milliseconds that must ellapse before this omnibar instance will issue a session renewal | ||
// after the previos time one is | ||
BBOmnibarUserActivity.MIN_RENEWAL_RETRY = 60 * 1000; | ||
// The time in millseconds that a session is allowed without activity. | ||
BBOmnibarUserActivity.MAX_SESSION_AGE = 15 * 60 * 1000; | ||
BBOmnibarUserActivity.IDENTITY_SECURITY_TOKEN_SERVICE_ORIGIN = 'https://s21aidntoken00blkbapp01.nxt.blackbaud.com'; | ||
@@ -880,3 +1030,3 @@ exports.BBOmnibarUserActivity = BBOmnibarUserActivity; | ||
/***/ }), | ||
/* 16 */ | ||
/* 17 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -924,3 +1074,3 @@ | ||
/***/ }), | ||
/* 17 */ | ||
/* 18 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -927,0 +1077,0 @@ |
@@ -1,1 +0,1 @@ | ||
(function e(n,t){if(typeof exports==="object"&&typeof module==="object")module.exports=t();else if(typeof define==="function"&&define.amd)define([],t);else if(typeof exports==="object")exports["BBAuthClient"]=t();else n["BBAuthClient"]=t()})(this,function(){return function(e){var n={};function t(r){if(n[r]){return n[r].exports}var i=n[r]={i:r,l:false,exports:{}};e[r].call(i.exports,i,i.exports,t);i.l=true;return i.exports}t.m=e;t.c=n;t.i=function(e){return e};t.d=function(e,n,r){if(!t.o(e,n)){Object.defineProperty(e,n,{configurable:false,enumerable:true,get:r})}};t.n=function(e){var n=e&&e.__esModule?function n(){return e["default"]}:function n(){return e};t.d(n,"a",n);return n};t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)};t.p="";return t(t.s=4)}([function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:true});var r="https://signin.blackbaud.com/signin/";function i(e){var n=[];for(var t in e){if(e.hasOwnProperty(t)){n.push(encodeURIComponent(t)+"="+encodeURIComponent(e[t]))}}return n.join("&")}var o=function(){function e(){}e.navigate=function(e){location.href=e};e.redirectToSignin=function(e){var n=r+"?redirectUrl="+encodeURIComponent(location.href);if(e){n+="&"+i(e)}this.navigate(n)};return e}();n.BBAuthNavigator=o},function(e,n,t){"use strict";function r(e){for(var t in e)if(!n.hasOwnProperty(t))n[t]=e[t]}Object.defineProperty(n,"__esModule",{value:true});r(t(6))},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:true});var r="https://s21aidntoken00blkbapp01.nxt.blackbaud.com/session/csrf";var i=t(0);function o(e,n,t,r,i){var o=new XMLHttpRequest;o.onreadystatechange=function(){if(o.readyState===4&&o.status===401){i({message:"The user is not logged in."})}else if(o.readyState===4&&o.status===200){r(o.responseText)}};o.open("POST",e,true);o.setRequestHeader(n.name,n.value);o.setRequestHeader("Accept","application/json");o.setRequestHeader("Content-Type","application/json");o.withCredentials=true;if(t){o.send(JSON.stringify(t))}else{o.send()}}function a(e,n,t,r){var i;if(t&&r){i={environment_id:t,permission_scope:r}}return new Promise(function(t,r){o(e,{name:"X-CSRF",value:n},i,function(e){var n=e?JSON.parse(e):undefined;t(n)},r)})}var s=function(){function e(){}e.request=function(e,n,t,o,s){return new Promise(function(u,c){a(r,"token_needed").then(function(n){return a(e,n["csrf_token"],o,s)}).then(u).catch(function(e){if(t){c(e)}else{i.BBAuthNavigator.redirectToSignin(n)}})})};return e}();n.BBCsrfXhr=s},function(e,n,t){"use strict";function r(e){for(var t in e)if(!n.hasOwnProperty(t))n[t]=e[t]}Object.defineProperty(n,"__esModule",{value:true});r(t(16));r(t(7));r(t(10));r(t(9));r(t(12));r(t(13));r(t(14))},function(e,n,t){"use strict";function r(e){for(var t in e)if(!n.hasOwnProperty(t))n[t]=e[t]}Object.defineProperty(n,"__esModule",{value:true});r(t(1));r(t(3))},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:true});var r=t(2);var i=function(){function e(){}e.getToken=function(e,n,t){return r.BBCsrfXhr.request("https://s21aidntoken00blkbapp01.nxt.blackbaud.com/oauth2/token",undefined,e,n,t)};return e}();n.BBAuthTokenIntegration=i},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:true});var r=t(5);function i(e){var n=e.envId,t=e.permissionScope;return"token|"+(n||"-")+"|"+(t||"-")}var o=function(){function e(){}e.getToken=function(n,t){var r;switch(typeof n){case"undefined":r={};break;case"boolean":r={disableRedirect:t,forceNewToken:n};break;default:r=n}return e.getTokenInternal(r)};e.getTokenInternal=function(n){var t=n.forceNewToken,o=n.disableRedirect;if(e.mock){return Promise.resolve("mock_access_token_auth-client@blackbaud.com")}var a=i(n);var s=e.tokenCache[a]=e.tokenCache[a]||{};var u=(new Date).valueOf();if(!t&&s.lastToken&&s.expirationTime&&s.expirationTime-u>60*1e3){return Promise.resolve(s.lastToken)}if(!s.pendingLookupPromise){s.pendingLookupPromise=r.BBAuthTokenIntegration.getToken(o,n.envId,n.permissionScope).then(function(e){s.expirationTime=(new Date).valueOf()+e["expires_in"]*1e3;s.lastToken=e["access_token"];s.pendingLookupPromise=null;return s.lastToken}).catch(function(e){s.pendingLookupPromise=null;throw e})}return s.pendingLookupPromise};return e}();o.mock=false;o.tokenCache={};n.BBAuth=o},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:true});var r=function(){function e(){}return e}();n.BBOmnibarConfig=r},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:true});var r=t(1);var i=t(17);var o=t(15);var a=t(0);var s="sky-omnibar-iframe-expanded";var u="sky-omnibar-loading";var c;var f;var d;var l;var p;function m(){d=document.createElement("iframe");d.className="sky-omnibar-iframe "+u;d.src=S();var e=document.body;if(e.firstChild){e.insertBefore(d,e.firstChild)}else{e.appendChild(d)}}function v(){d.classList.remove(s)}function b(){var e="\nbody {\n margin-top: 50px;\n}\n\n#bb-help-container {\n padding-top: 1px;\n}\n\n.sky-omnibar-iframe,\n.sky-omnibar-placeholder {\n border: none;\n height: 50px;\n width: 100%;\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n z-index: 1000;\n}\n\n.sky-omnibar-placeholder {\n background-color: #4d5259;\n border-top: 5px solid #00b4f1;\n display: none;\n}\n\n.sky-omnibar-placeholder.sky-omnibar-loading {\n display: block;\n}\n\n.sky-omnibar-iframe.sky-omnibar-loading {\n visibility: hidden;\n}\n\n.sky-omnibar-iframe-expanded {\n height: 100%;\n}\n ";f=document.createElement("style");f.appendChild(document.createTextNode(e));document.head.appendChild(f)}function h(){c=document.createElement("div");c.className="sky-omnibar-placeholder "+u;document.body.appendChild(c)}function g(){d.classList.add(s)}function y(){i.BBAuthInterop.postOmnibarMessage(d,{href:document.location.href,messageType:"location-change"})}function k(e){if(l.onSearch){l.onSearch(e).then(function(e){i.BBAuthInterop.postOmnibarMessage(d,{messageType:"search-results",results:e})})}}function B(){r.BBAuth.getToken(true).then(function(e){i.BBAuthInterop.postOmnibarMessage(d,{messageType:"refresh-user",token:e})})}function _(e,n){r.BBAuth.getToken(false,n).then(function(n){o.BBOmnibarUserActivity.startTracking(B);i.BBAuthInterop.postOmnibarMessage(d,{messageType:"token",token:n,tokenRequestId:e})}).catch(function(n){i.BBAuthInterop.postOmnibarMessage(d,{messageType:"token-fail",reason:n,tokenRequestId:e})})}function I(){var e=window.BBHELP;if(e){e.HelpWidget.open()}}function O(e){var n=l.notifications;if(n&&n.onNotificationRead){n.onNotificationRead(e)}}function T(){var e=history.pushState;var n=history.replaceState;function t(){var n=e.apply(history,arguments);y();return n}function r(){var e=n.apply(history,arguments);y();return e}history.pushState=t;history.replaceState=r}function E(){var e=l.notifications;if(e){e.onReady({updateNotifications:function(e){i.BBAuthInterop.postOmnibarMessage(d,{messageType:"notifications-update",notifications:e})}})}}function R(e){if(!i.BBAuthInterop.messageIsFromOmnibar(e)){return}var n=e.data;var t=l.nav;switch(n.messageType){case"ready":i.BBAuthInterop.postOmnibarMessage(d,{messageType:"host-ready"});T();c.classList.remove(u);d.classList.remove(u);i.BBAuthInterop.postOmnibarMessage(d,{enableHelp:l.enableHelp,envId:l.envId,localNavItems:t&&t.localNavItems,localNotifications:!!l.notifications,localSearch:!!l.onSearch,messageType:"nav-ready",services:t&&t.services,svcId:l.svcId});E();y();p();break;case"expand":g();break;case"collapse":v();break;case"navigate-url":a.BBAuthNavigator.navigate(n.url);break;case"navigate":var r=n.navItem;if(!t||!t.beforeNavCallback||t.beforeNavCallback(r)!==false){a.BBAuthNavigator.navigate(r.url)}break;case"search":k(n.searchArgs);break;case"get-token":_(n.tokenRequestId,n.disableRedirect);break;case"help-open":I();break;case"notification-read":O(n.notification);break}}function S(){var e=l.url||"https://host.nxt.blackbaud.com/omnibar/";return e}var A=function(){function e(){}e.load=function(e){l=l=e;return new Promise(function(e){p=e;b();h();m();window.addEventListener("message",R)})};e.destroy=function(){document.head.removeChild(f);document.body.removeChild(c);document.body.removeChild(d);window.removeEventListener("message",R);l=undefined;f=undefined;c=undefined;d=undefined;p=undefined};return e}();n.BBOmnibarExperimental=A},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:true});var r=function(){function e(){}return e}();n.BBOmnibarNavigationItem=r},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:true});var r=function(){function e(){}return e}();n.BBOmnibarNavigation=r},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:true});function r(e){var n=e.split(".");var t=[];for(var r=0,i=n;r<i.length;r++){var o=i[r];var a=parseInt(o,10)||0;t.push(a)}return t}function i(e,n){var t=r(e);var i=r(n);for(var o=0;o<t.length;o++){if(o<i.length){if(i[o]>t[o]){return true}else if(i[o]<t[o]){return false}}}return true}var o=function(){function e(){}e.registerScript=function(e){return new Promise(function(n,t){var r=document.createElement("script");r.onload=n;r.onerror=t;r.src=e;document.body.appendChild(r)})};e.smartRegisterScript=function(n,t,r){if(r&&i(t,r)){return Promise.resolve()}return e.registerScript(n)};return e}();n.BBOmnibarScriptLoader=o},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:true});var r=function(){function e(){}return e}();n.BBOmnibarSearchArgs=r},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:true});var r=function(){function e(){}return e}();n.BBOmnibarSearchResultItem=r},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:true});var r=function(){function e(){}return e}();n.BBOmnibarSearchResults=r},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:true});var r=t(2);var i=t(0);var o;var a;var s;var u;var c;var f;var d;var l;var p;var m;function v(){return(new Date).getTime()}function b(e){if(e.clientX!==a||e.clientY!==s){a=e.clientX;s=e.clientY;g()}}function h(){r.BBCsrfXhr.request("https://s21aidntoken00blkbapp01.nxt.blackbaud.com/session/renew",{inactivity:1});c=v();f=false}function g(){u=v();if(f){h()}}function y(){document.addEventListener("keypress",g);document.addEventListener("mousemove",b)}function k(){h();d=setInterval(function(){if(v()-c>O.MIN_RENEWAL_AGE){f=true}},O.ACTIVITY_TIMER_INTERVAL)}function B(e){p=document.createElement("iframe");p.className="sky-omnibar-iframe-session-watcher";p.width="0";p.height="0";p.frameBorder="0";p.src=e;p.tabIndex=-1;document.body.appendChild(p)}function _(e){if(e.origin===O.IDENTITY_SECURITY_TOKEN_SERVICE_ORIGIN&&typeof e.data==="string"){var n=void 0;try{n=JSON.parse(e.data)}catch(e){return}if(n.messageType==="session_change"){var t=n.message;var r=t&&t.sessionId;if(r){if(l&&r!==l){m()}l=r}else{i.BBAuthNavigator.redirectToSignin()}}}}function I(){window.addEventListener("message",_,false);B(O.IDENTITY_SECURITY_TOKEN_SERVICE_ORIGIN+"/SessionWatcher.html?origin="+encodeURIComponent(location.origin))}var O=function(){function e(){}e.startTracking=function(e){if(!o){y();k();I();m=e;o=true}};e.stopTracking=function(){if(p){document.body.removeChild(p);p=undefined}window.removeEventListener("message",_,false);document.removeEventListener("keypress",g);document.removeEventListener("mousemove",b);if(d){clearInterval(d);d=undefined}o=undefined;a=undefined;s=undefined;u=undefined;c=undefined;f=undefined;l=undefined;m=undefined};return e}();O.ACTIVITY_TIMER_INTERVAL=1e3;O.ABOUT_TO_EXPIRE_PROMPT_TIMEFRAME=2*60*1e3;O.MAX_SESSION_AGE=30*60*1e3;O.MIN_RENEWAL_AGE=5*60*1e3;O.MIN_RENEWAL_RETRY=60*1e3;O.IDENTITY_SECURITY_TOKEN_SERVICE_ORIGIN="https://s21aidntoken00blkbapp01.nxt.blackbaud.com";n.BBOmnibarUserActivity=O},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:true});var r=t(8);var i=t(11);var o=function(){function e(){}e.load=function(e){if(e&&e.experimental){return r.BBOmnibarExperimental.load(e)}return new Promise(function(n){var t=window.jQuery;var r=t&&t.fn&&t.fn.jquery;i.BBOmnibarScriptLoader.smartRegisterScript("https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.0/jquery.js","2.1.0",r).then(function(){return i.BBOmnibarScriptLoader.registerScript("https://cdnjs.cloudflare.com/ajax/libs/easyXDM/2.4.17.1/easyXDM.min.js")}).then(function(){return i.BBOmnibarScriptLoader.registerScript("https://signin.blackbaud.com/Omnibar.min.js")}).then(function(){document.body.classList.add("bb-omnibar-height-padding");var t=document.createElement("div");t.setAttribute("data-omnibar-el","");document.body.appendChild(t);e=e||{};e["z-index"]=1e3;e.afterLoad=n;BBAUTH.Omnibar.load(t,e)})})};return e}();n.BBOmnibar=o},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:true});var r="https://host.nxt.blackbaud.com";var i=function(){function e(){}e.postOmnibarMessage=function(e,n){n.source="auth-client";e.contentWindow.postMessage(n,r)};e.messageIsFromOmnibar=function(e){if(e.origin===r){var n=e.data;return!!n&&n.source==="skyux-spa-omnibar"}return false};return e}();n.BBAuthInterop=i}])}); | ||
(function e(n,t){if(typeof exports==="object"&&typeof module==="object")module.exports=t();else if(typeof define==="function"&&define.amd)define([],t);else if(typeof exports==="object")exports["BBAuthClient"]=t();else n["BBAuthClient"]=t()})(this,function(){return function(e){var n={};function t(r){if(n[r]){return n[r].exports}var i=n[r]={i:r,l:false,exports:{}};e[r].call(i.exports,i,i.exports,t);i.l=true;return i.exports}t.m=e;t.c=n;t.i=function(e){return e};t.d=function(e,n,r){if(!t.o(e,n)){Object.defineProperty(e,n,{configurable:false,enumerable:true,get:r})}};t.n=function(e){var n=e&&e.__esModule?function n(){return e["default"]}:function n(){return e};t.d(n,"a",n);return n};t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)};t.p="";return t(t.s=4)}([function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:true});var r="https://signin.blackbaud.com/signin/";var i=encodeURIComponent;function o(e){var n=[];for(var t in e){if(e.hasOwnProperty(t)){n.push(i(t)+"="+i(e[t]))}}return n.join("&")}function a(e){var n=r+"?redirectUrl="+i(location.href);if(e){n+="&inactivity=1"}return n}var s=function(){function e(){}e.navigate=function(e){location.href=e};e.redirectToSignin=function(e){var n=a();if(e){n+="&"+o(e)}this.navigate(n)};e.redirectToSignoutForInactivity=function(){var e=a(true);var n=r+"sign-out?redirectUrl="+i(e);this.navigate(n)};return e}();n.BBAuthNavigator=s},function(e,n,t){"use strict";function r(e){for(var t in e)if(!n.hasOwnProperty(t))n[t]=e[t]}Object.defineProperty(n,"__esModule",{value:true});r(t(6))},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:true});var r="https://s21aidntoken00blkbapp01.nxt.blackbaud.com/session/csrf";var i=t(0);function o(e,n,t,r,i){var o=new XMLHttpRequest;o.onreadystatechange=function(){if(o.readyState===4&&o.status===401){i({message:"The user is not logged in."})}else if(o.readyState===4&&o.status===200){r(o.responseText)}};o.open("POST",e,true);o.setRequestHeader(n.name,n.value);o.setRequestHeader("Accept","application/json");o.setRequestHeader("Content-Type","application/json");o.withCredentials=true;if(t){o.send(JSON.stringify(t))}else{o.send()}}function a(e,n,t,r){var i;if(t&&r){i={environment_id:t,permission_scope:r}}return new Promise(function(t,r){o(e,{name:"X-CSRF",value:n},i,function(e){var n=e?JSON.parse(e):undefined;t(n)},r)})}var s=function(){function e(){}e.request=function(e,n,t,o,s){return new Promise(function(u,c){a(r,"token_needed").then(function(n){return a(e,n["csrf_token"],o,s)}).then(u).catch(function(e){if(t){c(e)}else{i.BBAuthNavigator.redirectToSignin(n)}})})};return e}();n.BBCsrfXhr=s},function(e,n,t){"use strict";function r(e){for(var t in e)if(!n.hasOwnProperty(t))n[t]=e[t]}Object.defineProperty(n,"__esModule",{value:true});r(t(17));r(t(7));r(t(10));r(t(9));r(t(12));r(t(13));r(t(14))},function(e,n,t){"use strict";function r(e){for(var t in e)if(!n.hasOwnProperty(t))n[t]=e[t]}Object.defineProperty(n,"__esModule",{value:true});r(t(1));r(t(3))},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:true});var r=t(2);var i=function(){function e(){}e.getToken=function(e,n,t){return r.BBCsrfXhr.request("https://s21aidntoken00blkbapp01.nxt.blackbaud.com/oauth2/token",undefined,e,n,t)};return e}();n.BBAuthTokenIntegration=i},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:true});var r=t(5);function i(e){var n=e.envId,t=e.permissionScope;return"token|"+(n||"-")+"|"+(t||"-")}var o=function(){function e(){}e.getToken=function(n,t){var r;switch(typeof n){case"undefined":r={};break;case"boolean":r={disableRedirect:t,forceNewToken:n};break;default:r=n}return e.getTokenInternal(r)};e.clearTokenCache=function(){e.tokenCache={}};e.getTokenInternal=function(n){var t=n.forceNewToken,o=n.disableRedirect;if(e.mock){return Promise.resolve("mock_access_token_auth-client@blackbaud.com")}var a=i(n);var s=e.tokenCache[a]=e.tokenCache[a]||{};var u=(new Date).valueOf();if(!t&&s.lastToken&&s.expirationTime&&s.expirationTime-u>60*1e3){return Promise.resolve(s.lastToken)}if(!s.pendingLookupPromise){s.pendingLookupPromise=r.BBAuthTokenIntegration.getToken(o,n.envId,n.permissionScope).then(function(e){s.expirationTime=(new Date).valueOf()+e["expires_in"]*1e3;s.lastToken=e["access_token"];s.pendingLookupPromise=null;return s.lastToken}).catch(function(e){s.pendingLookupPromise=null;throw e})}return s.pendingLookupPromise};return e}();o.mock=false;o.tokenCache={};n.BBAuth=o},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:true});var r=function(){function e(){}return e}();n.BBOmnibarConfig=r},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:true});var r=t(1);var i=t(18);var o=t(16);var a=t(0);var s="sky-omnibar-iframe-expanded";var u="sky-omnibar-loading";var c;var f;var d;var l;var p;function v(){d=document.createElement("iframe");d.className="sky-omnibar-iframe "+u;d.src=E();var e=document.body;if(e.firstChild){e.insertBefore(d,e.firstChild)}else{e.appendChild(d)}}function m(){d.classList.remove(s)}function h(){var e="\nbody {\n margin-top: 50px;\n}\n\n#bb-help-container {\n padding-top: 1px;\n}\n\n.sky-omnibar-iframe,\n.sky-omnibar-placeholder {\n border: none;\n height: 50px;\n width: 100%;\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n z-index: 1000;\n}\n\n.sky-omnibar-placeholder {\n background-color: #4d5259;\n border-top: 5px solid #00b4f1;\n display: none;\n}\n\n.sky-omnibar-placeholder.sky-omnibar-loading {\n display: block;\n}\n\n.sky-omnibar-iframe.sky-omnibar-loading {\n visibility: hidden;\n}\n\n.sky-omnibar-iframe-expanded {\n height: 100%;\n}\n ";f=document.createElement("style");f.appendChild(document.createTextNode(e));document.head.appendChild(f)}function b(){c=document.createElement("div");c.className="sky-omnibar-placeholder "+u;document.body.appendChild(c)}function y(){d.classList.add(s)}function g(){i.BBAuthInterop.postOmnibarMessage(d,{href:document.location.href,messageType:"location-change"})}function B(e){if(l.onSearch){l.onSearch(e).then(function(e){i.BBAuthInterop.postOmnibarMessage(d,{messageType:"search-results",results:e})})}}function k(){function e(e){i.BBAuthInterop.postOmnibarMessage(d,{messageType:"refresh-user",token:e})}r.BBAuth.clearTokenCache();r.BBAuth.getToken({disableRedirect:true,forceNewToken:true}).then(e).catch(function(){return e(undefined)})}function I(){i.BBAuthInterop.postOmnibarMessage(d,{messageType:"inactivity-show"})}function _(){i.BBAuthInterop.postOmnibarMessage(d,{messageType:"inactivity-hide"})}function T(e,n){r.BBAuth.getToken(false,n).then(function(t){o.BBOmnibarUserActivity.startTracking(k,I,_,n);i.BBAuthInterop.postOmnibarMessage(d,{messageType:"token",token:t,tokenRequestId:e})}).catch(function(t){o.BBOmnibarUserActivity.startTracking(k,I,_,n);i.BBAuthInterop.postOmnibarMessage(d,{messageType:"token-fail",reason:t,tokenRequestId:e})})}function O(){var e=window.BBHELP;if(e){e.HelpWidget.open()}}function A(e){var n=l.notifications;if(n&&n.onNotificationRead){n.onNotificationRead(e)}}function w(){var e=history.pushState;var n=history.replaceState;function t(){var n=e.apply(history,arguments);g();return n}function r(){var e=n.apply(history,arguments);g();return e}history.pushState=t;history.replaceState=r}function S(){var e=l.notifications;if(e){e.onReady({updateNotifications:function(e){i.BBAuthInterop.postOmnibarMessage(d,{messageType:"notifications-update",notifications:e})}})}}function P(e){if(!i.BBAuthInterop.messageIsFromOmnibar(e)){return}var n=e.data;var t=l.nav;switch(n.messageType){case"ready":i.BBAuthInterop.postOmnibarMessage(d,{messageType:"host-ready"});w();c.classList.remove(u);d.classList.remove(u);i.BBAuthInterop.postOmnibarMessage(d,{enableHelp:l.enableHelp,envId:l.envId,localNavItems:t&&t.localNavItems,localNotifications:!!l.notifications,localSearch:!!l.onSearch,messageType:"nav-ready",services:t&&t.services,svcId:l.svcId});S();g();p();break;case"expand":y();break;case"collapse":m();break;case"navigate-url":a.BBAuthNavigator.navigate(n.url);break;case"navigate":var r=n.navItem;if(!t||!t.beforeNavCallback||t.beforeNavCallback(r)!==false){a.BBAuthNavigator.navigate(r.url)}break;case"search":B(n.searchArgs);break;case"get-token":T(n.tokenRequestId,n.disableRedirect);break;case"help-open":O();break;case"notification-read":A(n.notification);break;case"session-renew":o.BBOmnibarUserActivity.userRenewedSession();break}}function E(){var e=l.url||"https://host.nxt.blackbaud.com/omnibar/";return e}var N=function(){function e(){}e.load=function(e){l=l=e;return new Promise(function(e){p=e;h();b();v();window.addEventListener("message",P)})};e.destroy=function(){document.head.removeChild(f);document.body.removeChild(c);document.body.removeChild(d);window.removeEventListener("message",P);l=undefined;f=undefined;c=undefined;d=undefined;p=undefined};return e}();n.BBOmnibarExperimental=N},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:true});var r=function(){function e(){}return e}();n.BBOmnibarNavigationItem=r},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:true});var r=function(){function e(){}return e}();n.BBOmnibarNavigation=r},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:true});function r(e){var n=e.split(".");var t=[];for(var r=0,i=n;r<i.length;r++){var o=i[r];var a=parseInt(o,10)||0;t.push(a)}return t}function i(e,n){var t=r(e);var i=r(n);for(var o=0;o<t.length;o++){if(o<i.length){if(i[o]>t[o]){return true}else if(i[o]<t[o]){return false}}}return true}var o=function(){function e(){}e.registerScript=function(e){return new Promise(function(n,t){var r=document.createElement("script");r.onload=n;r.onerror=t;r.src=e;document.body.appendChild(r)})};e.smartRegisterScript=function(n,t,r){if(r&&i(t,r)){return Promise.resolve()}return e.registerScript(n)};return e}();n.BBOmnibarScriptLoader=o},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:true});var r=function(){function e(){}return e}();n.BBOmnibarSearchArgs=r},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:true});var r=function(){function e(){}return e}();n.BBOmnibarSearchResultItem=r},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:true});var r=function(){function e(){}return e}();n.BBOmnibarSearchResults=r},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:true});var r=function(){function e(){}e.process=function(e){var n=e.allowAnonymous,t=e.closeInactivityPrompt,r=e.expirationDate,i=e.inactivityPromptDuration,o=e.isShowingInactivityPrompt,a=e.lastActivity,s=e.maxSessionAge,u=e.minRenewalAge,c=e.redirectForInactivity,f=e.renewSession,d=e.showInactivityPrompt;var l=Date.now();if(r===null){return}if(l>r){c()}var p=r-i;var v=r-s+u;if(o){if(l<p){t()}}else{if(a>v){f()}else if(!n&&l>p){d()}}};return e}();n.BBOmnibarUserActivityProcessor=r},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:true});var r=t(15);var i=t(2);var o=t(0);var a;var s;var u;var c;var f;var d;var l;var p;var v;var m;var h;var b="";var y;var g;var B;function k(){p=Date.now()}function I(e){if(e.clientX!==s||e.clientY!==u){s=e.clientX;u=e.clientY;k()}}function _(e){if(y&&y.refreshId===e){return y.promise}var n=new Promise(function(e,n){i.BBCsrfXhr.request("https://s21aidntoken00blkbapp01.nxt.blackbaud.com/session/ttl",undefined,B).then(function(n){var t=n===null?null:Date.now()+n*1e3;e(t)}).catch(function(){e(null)})});y={promise:n,refreshId:e};return n}function T(){var e=Date.now();if(!v||e-v>R.MIN_RENEWAL_RETRY){v=e;i.BBCsrfXhr.request("https://s21aidntoken00blkbapp01.nxt.blackbaud.com/session/renew",{inactivity:1}).catch(function(){return undefined})}}function O(){document.addEventListener("keypress",k);document.addEventListener("mousemove",I)}function A(){l=true;d()}function w(){l=false;k();c()}function S(){if(!B){T()}m=setInterval(function(){_(b).then(function(e){r.BBOmnibarUserActivityProcessor.process({allowAnonymous:B,closeInactivityPrompt:w,expirationDate:e,inactivityPromptDuration:R.INACTIVITY_PROMPT_DURATION,isShowingInactivityPrompt:l,lastActivity:p,maxSessionAge:R.MAX_SESSION_AGE,minRenewalAge:R.MIN_RENEWAL_AGE,redirectForInactivity:o.BBAuthNavigator.redirectToSignoutForInactivity,renewSession:T,showInactivityPrompt:A})})},R.ACTIVITY_TIMER_INTERVAL)}function P(){var e=R.IDENTITY_SECURITY_TOKEN_SERVICE_ORIGIN+"/SessionWatcher.html?origin="+encodeURIComponent(location.origin);g=document.createElement("iframe");g.className="sky-omnibar-iframe-session-watcher";g.width="0";g.height="0";g.frameBorder="0";g.src=e;g.tabIndex=-1;document.body.appendChild(g)}function E(e){if(e.origin===R.IDENTITY_SECURITY_TOKEN_SERVICE_ORIGIN&&typeof e.data==="string"){var n=void 0;try{n=JSON.parse(e.data)}catch(e){return}if(n.messageType==="session_change"){var t=n.message;var r=t&&t.sessionId;var i=t&&t.refreshId;if(!r&&!B){o.BBAuthNavigator.redirectToSignin()}if(h!==undefined&&r!==h){f()}b=i;h=r}}}function N(){window.addEventListener("message",E,false);P()}var R=function(){function e(){}e.startTracking=function(n,t,r,i){if(!a||i!==B){e.stopTracking();f=n;d=t;c=r;B=i;O();S();N();a=true}};e.userRenewedSession=function(){w();T()};e.stopTracking=function(){if(g){document.body.removeChild(g);g=undefined}window.removeEventListener("message",E,false);document.removeEventListener("keypress",k);document.removeEventListener("mousemove",I);if(m){clearInterval(m);m=undefined}a=undefined;s=undefined;u=undefined;p=undefined;v=undefined;h=undefined;y=undefined;l=undefined;f=undefined;d=undefined;c=undefined;B=undefined};return e}();R.ACTIVITY_TIMER_INTERVAL=1e3;R.MIN_RENEWAL_RETRY=1*60*1e3;R.INACTIVITY_PROMPT_DURATION=2*60*1e3;R.MIN_RENEWAL_AGE=5*60*1e3;R.MAX_SESSION_AGE=15*60*1e3;R.IDENTITY_SECURITY_TOKEN_SERVICE_ORIGIN="https://s21aidntoken00blkbapp01.nxt.blackbaud.com";n.BBOmnibarUserActivity=R},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:true});var r=t(8);var i=t(11);var o=function(){function e(){}e.load=function(e){if(e&&e.experimental){return r.BBOmnibarExperimental.load(e)}return new Promise(function(n){var t=window.jQuery;var r=t&&t.fn&&t.fn.jquery;i.BBOmnibarScriptLoader.smartRegisterScript("https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.0/jquery.js","2.1.0",r).then(function(){return i.BBOmnibarScriptLoader.registerScript("https://cdnjs.cloudflare.com/ajax/libs/easyXDM/2.4.17.1/easyXDM.min.js")}).then(function(){return i.BBOmnibarScriptLoader.registerScript("https://signin.blackbaud.com/Omnibar.min.js")}).then(function(){document.body.classList.add("bb-omnibar-height-padding");var t=document.createElement("div");t.setAttribute("data-omnibar-el","");document.body.appendChild(t);e=e||{};e["z-index"]=1e3;e.afterLoad=n;BBAUTH.Omnibar.load(t,e)})})};return e}();n.BBOmnibar=o},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:true});var r="https://host.nxt.blackbaud.com";var i=function(){function e(){}e.postOmnibarMessage=function(e,n){n.source="auth-client";e.contentWindow.postMessage(n,r)};e.messageIsFromOmnibar=function(e){if(e.origin===r){var n=e.data;return!!n&&n.source==="skyux-spa-omnibar"}return false};return e}();n.BBAuthInterop=i}])}); |
@@ -0,1 +1,5 @@ | ||
# 1.12.0 (2017-08-15) | ||
- Added support for showing an inactivity prompt. (#41) | ||
# 1.11.0 (2017-08-02) | ||
@@ -2,0 +6,0 @@ |
@@ -1,1 +0,1 @@ | ||
{"name":"@blackbaud/auth-client","version":"1.11.0","description":"Provides methods for obtaining an authentication token from the Blackbaud authentication service.","main":"dist/bundles/auth-client.umd.js","module":"index.js","scripts":{"ci":"npm run test:ci && npm run build","test":"npm run lint && npm run test:unit","test:ci":"npm run test:unit:ci","test:unit":"npm run test:unit:base -- config/karma/local.karma.conf.js","test:unit:ci":"npm run test:unit:base -- config/karma/ci.karma.conf.js","test:unit:base":"node --max-old-space-size=4096 node_modules/karma/bin/karma start","pretest":"npm run lint","compress":"uglifyjs dist/bundles/auth-client.umd.js -m -o dist/bundles/auth-client.umd.min.js","build":"rimraf dist && tsc && webpack --config config/webpack/webpack.prod.config.js && npm run compress","watch":"npm run test:unit -- --auto-watch --no-single-run","lint":"tslint 'src/**/*.ts'"},"repository":{"type":"git","url":"git+https://github.com/blackbaud/auth-client.git"},"author":"Blackbaud, Inc.","license":"MIT","bugs":{"url":"https://github.com/blackbaud/auth-client/issues"},"homepage":"https://github.com/blackbaud/auth-client#readme","devDependencies":{"@types/core-js":"0.9.41","@types/jasmine":"2.5.47","@types/jasmine-ajax":"3.1.36","@types/webpack":"2.2.15","core-js":"2.4.1","fs-extra":"3.0.1","istanbul":"0.4.5","istanbul-instrumenter-loader":"0.1.0","jasmine":"2.6.0","jasmine-ajax":"3.3.1","karma":"1.7.0","karma-browserstack-launcher":"1.2.0","karma-chrome-launcher":"2.1.1","karma-coverage":"1.1.1","karma-firefox-launcher":"1.0.1","karma-jasmine":"1.1.0","karma-mocha-reporter":"2.2.3","karma-sourcemap-loader":"0.3.7","karma-webpack":"2.0.3","raw-loader":"0.5.1","remap-istanbul":"0.9.5","rimraf":"2.6.1","source-map-inline-loader":"github:blackbaud-bobbyearl/source-map-inline-loader","ts-loader":"2.0.3","tslint":"5.2.0","tslint-loader":"3.5.3","typescript":"2.3.2","uglify-js":"3.0.15","webpack":"2.5.1"}} | ||
{"name":"@blackbaud/auth-client","version":"1.12.0","description":"Provides methods for obtaining an authentication token from the Blackbaud authentication service.","main":"dist/bundles/auth-client.umd.js","module":"index.js","scripts":{"ci":"npm run test:ci && npm run build","test":"npm run lint && npm run test:unit","test:ci":"npm run test:unit:ci","test:unit":"npm run test:unit:base -- config/karma/local.karma.conf.js","test:unit:ci":"npm run test:unit:base -- config/karma/ci.karma.conf.js","test:unit:base":"node --max-old-space-size=4096 node_modules/karma/bin/karma start","pretest":"npm run lint","compress":"uglifyjs dist/bundles/auth-client.umd.js -m -o dist/bundles/auth-client.umd.min.js","build":"rimraf dist && tsc && webpack --config config/webpack/webpack.prod.config.js && npm run compress","watch":"npm run test:unit -- --auto-watch --no-single-run","lint":"tslint 'src/**/*.ts'"},"repository":{"type":"git","url":"git+https://github.com/blackbaud/auth-client.git"},"author":"Blackbaud, Inc.","license":"MIT","bugs":{"url":"https://github.com/blackbaud/auth-client/issues"},"homepage":"https://github.com/blackbaud/auth-client#readme","devDependencies":{"@types/core-js":"0.9.41","@types/jasmine":"2.5.47","@types/jasmine-ajax":"3.1.36","@types/webpack":"2.2.15","core-js":"2.4.1","fs-extra":"3.0.1","istanbul":"0.4.5","istanbul-instrumenter-loader":"0.1.0","jasmine":"2.6.0","jasmine-ajax":"3.3.1","karma":"1.7.0","karma-browserstack-launcher":"1.2.0","karma-chrome-launcher":"2.1.1","karma-coverage":"1.1.1","karma-firefox-launcher":"1.0.1","karma-jasmine":"1.1.0","karma-mocha-reporter":"2.2.3","karma-sourcemap-loader":"0.3.7","karma-webpack":"2.0.3","raw-loader":"0.5.1","remap-istanbul":"0.9.5","rimraf":"2.6.1","source-map-inline-loader":"github:blackbaud-bobbyearl/source-map-inline-loader","ts-loader":"2.0.3","tslint":"5.2.0","tslint-loader":"3.5.3","typescript":"2.3.2","uglify-js":"3.0.15","webpack":"2.5.1"}} |
@@ -6,3 +6,4 @@ import { BBAuthGetTokenArgs } from './auth-get-token-args'; | ||
static getToken(argsOrForceNewToken?: boolean | BBAuthGetTokenArgs, disableRedirect?: boolean): Promise<string>; | ||
static clearTokenCache(): void; | ||
private static getTokenInternal(args); | ||
} |
@@ -28,2 +28,5 @@ "use strict"; | ||
}; | ||
BBAuth.clearTokenCache = function () { | ||
BBAuth.tokenCache = {}; | ||
}; | ||
BBAuth.getTokenInternal = function (args) { | ||
@@ -30,0 +33,0 @@ var forceNewToken = args.forceNewToken, disableRedirect = args.disableRedirect; |
@@ -64,3 +64,3 @@ "use strict"; | ||
function refreshUserCallback() { | ||
auth_1.BBAuth.getToken(true).then(function (token) { | ||
function refreshUser(token) { | ||
interop_1.BBAuthInterop.postOmnibarMessage(iframeEl, { | ||
@@ -70,8 +70,25 @@ messageType: 'refresh-user', | ||
}); | ||
} | ||
auth_1.BBAuth.clearTokenCache(); | ||
auth_1.BBAuth.getToken({ | ||
disableRedirect: true, | ||
forceNewToken: true | ||
}) | ||
.then(refreshUser) | ||
.catch(function () { return refreshUser(undefined); }); | ||
} | ||
function showInactivityCallback() { | ||
interop_1.BBAuthInterop.postOmnibarMessage(iframeEl, { | ||
messageType: 'inactivity-show' | ||
}); | ||
} | ||
function hideInactivityCallback() { | ||
interop_1.BBAuthInterop.postOmnibarMessage(iframeEl, { | ||
messageType: 'inactivity-hide' | ||
}); | ||
} | ||
function handleGetToken(tokenRequestId, disableRedirect) { | ||
auth_1.BBAuth.getToken(false, disableRedirect) | ||
.then(function (token) { | ||
omnibar_user_activity_1.BBOmnibarUserActivity.startTracking(refreshUserCallback); | ||
omnibar_user_activity_1.BBOmnibarUserActivity.startTracking(refreshUserCallback, showInactivityCallback, hideInactivityCallback, disableRedirect); | ||
interop_1.BBAuthInterop.postOmnibarMessage(iframeEl, { | ||
@@ -84,2 +101,3 @@ messageType: 'token', | ||
.catch(function (reason) { | ||
omnibar_user_activity_1.BBOmnibarUserActivity.startTracking(refreshUserCallback, showInactivityCallback, hideInactivityCallback, disableRedirect); | ||
interop_1.BBAuthInterop.postOmnibarMessage(iframeEl, { | ||
@@ -193,2 +211,5 @@ messageType: 'token-fail', | ||
break; | ||
case 'session-renew': | ||
omnibar_user_activity_1.BBOmnibarUserActivity.userRenewedSession(); | ||
break; | ||
} | ||
@@ -195,0 +216,0 @@ } |
export declare class BBOmnibarUserActivity { | ||
static ACTIVITY_TIMER_INTERVAL: number; | ||
static ABOUT_TO_EXPIRE_PROMPT_TIMEFRAME: number; | ||
static MIN_RENEWAL_RETRY: number; | ||
static INACTIVITY_PROMPT_DURATION: number; | ||
static MIN_RENEWAL_AGE: number; | ||
static MAX_SESSION_AGE: number; | ||
static MIN_RENEWAL_AGE: number; | ||
static MIN_RENEWAL_RETRY: number; | ||
static IDENTITY_SECURITY_TOKEN_SERVICE_ORIGIN: string; | ||
static startTracking(refreshUserCallback: () => void): void; | ||
static startTracking(refreshUserCallback: () => void, showInactivityCallback: () => void, hideInactivityCallback: () => void, allowAnonymous: boolean): void; | ||
static userRenewedSession(): void; | ||
static stopTracking(): void; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var omnibar_user_activity_processor_1 = require("./omnibar-user-activity-processor"); | ||
var csrf_xhr_1 = require("../shared/csrf-xhr"); | ||
@@ -8,11 +9,16 @@ var navigator_1 = require("../shared/navigator"); | ||
var clientY; | ||
var currentHideInactivityCallback; | ||
var currentRefreshUserCallback; | ||
var currentShowInactivityCallback; | ||
var isShowingInactivityPrompt; | ||
var lastActivity; | ||
var lastRenewal; | ||
var renewOnNextActivity; | ||
var intervalId; | ||
var lastSessionId; | ||
var lastRefreshId = ''; | ||
var ttlCache; | ||
var watcherIFrame; | ||
var currentRefreshUserCallback; | ||
function getTimestamp() { | ||
return new Date().getTime(); | ||
var currentAllowAnonymous; | ||
function trackUserActivity() { | ||
lastActivity = Date.now(); | ||
} | ||
@@ -29,13 +35,29 @@ function trackMouseMove(e) { | ||
} | ||
function renewSession() { | ||
csrf_xhr_1.BBCsrfXhr.request('https://s21aidntoken00blkbapp01.nxt.blackbaud.com/session/renew', { | ||
inactivity: 1 | ||
function getSessionExpiration(refreshId) { | ||
if (ttlCache && ttlCache.refreshId === refreshId) { | ||
return ttlCache.promise; | ||
} | ||
var promise = new Promise(function (resolve, reject) { | ||
csrf_xhr_1.BBCsrfXhr.request('https://s21aidntoken00blkbapp01.nxt.blackbaud.com/session/ttl', undefined, currentAllowAnonymous) | ||
.then(function (ttl) { | ||
var expirationDate = (ttl === null) ? null : Date.now() + ttl * 1000; | ||
resolve(expirationDate); | ||
}) | ||
.catch(function () { | ||
resolve(null); | ||
}); | ||
}); | ||
lastRenewal = getTimestamp(); | ||
renewOnNextActivity = false; | ||
ttlCache = { | ||
promise: promise, | ||
refreshId: refreshId | ||
}; | ||
return promise; | ||
} | ||
function trackUserActivity() { | ||
lastActivity = getTimestamp(); | ||
if (renewOnNextActivity) { | ||
renewSession(); | ||
function renewSession() { | ||
var now = Date.now(); | ||
if (!lastRenewal || now - lastRenewal > BBOmnibarUserActivity.MIN_RENEWAL_RETRY) { | ||
lastRenewal = now; | ||
csrf_xhr_1.BBCsrfXhr.request('https://s21aidntoken00blkbapp01.nxt.blackbaud.com/session/renew', { | ||
inactivity: 1 | ||
}).catch(/* istanbul ignore next */ function () { return undefined; }); | ||
} | ||
@@ -47,2 +69,11 @@ } | ||
} | ||
function showInactivityPrompt() { | ||
isShowingInactivityPrompt = true; | ||
currentShowInactivityCallback(); | ||
} | ||
function closeInactivityPrompt() { | ||
isShowingInactivityPrompt = false; | ||
trackUserActivity(); | ||
currentHideInactivityCallback(); | ||
} | ||
function startActivityTimer() { | ||
@@ -52,10 +83,27 @@ // It's possible the user was active on another web page and just navigated to this | ||
// play it safe and renew the session immediately. | ||
renewSession(); | ||
if (!currentAllowAnonymous) { | ||
renewSession(); | ||
} | ||
intervalId = setInterval(function () { | ||
if (getTimestamp() - lastRenewal > BBOmnibarUserActivity.MIN_RENEWAL_AGE) { | ||
renewOnNextActivity = true; | ||
} | ||
getSessionExpiration(lastRefreshId).then(function (expirationDate) { | ||
omnibar_user_activity_processor_1.BBOmnibarUserActivityProcessor.process({ | ||
allowAnonymous: currentAllowAnonymous, | ||
closeInactivityPrompt: closeInactivityPrompt, | ||
expirationDate: expirationDate, | ||
inactivityPromptDuration: BBOmnibarUserActivity.INACTIVITY_PROMPT_DURATION, | ||
isShowingInactivityPrompt: isShowingInactivityPrompt, | ||
lastActivity: lastActivity, | ||
maxSessionAge: BBOmnibarUserActivity.MAX_SESSION_AGE, | ||
minRenewalAge: BBOmnibarUserActivity.MIN_RENEWAL_AGE, | ||
redirectForInactivity: navigator_1.BBAuthNavigator.redirectToSignoutForInactivity, | ||
renewSession: renewSession, | ||
showInactivityPrompt: showInactivityPrompt | ||
}); | ||
}); | ||
}, BBOmnibarUserActivity.ACTIVITY_TIMER_INTERVAL); | ||
} | ||
function createWatcherIFrame(url) { | ||
function createWatcherIFrame() { | ||
var url = BBOmnibarUserActivity.IDENTITY_SECURITY_TOKEN_SERVICE_ORIGIN + | ||
'/SessionWatcher.html?origin=' + | ||
encodeURIComponent(location.origin); | ||
watcherIFrame = document.createElement('iframe'); | ||
@@ -83,12 +131,15 @@ watcherIFrame.className = 'sky-omnibar-iframe-session-watcher'; | ||
var message = data.message; | ||
// Session ID changes whenever the user logs in the user profile information | ||
// (e.g. name, email address ,etc.) changes | ||
var sessionId = message && message.sessionId; | ||
if (sessionId) { | ||
if (lastSessionId && sessionId !== lastSessionId) { | ||
currentRefreshUserCallback(); | ||
} | ||
lastSessionId = sessionId; | ||
} | ||
else { | ||
// Refresh ID changes whenever a user's session is extended due to activity. | ||
var refreshId = message && message.refreshId; | ||
if (!sessionId && !currentAllowAnonymous) { | ||
navigator_1.BBAuthNavigator.redirectToSignin(); | ||
} | ||
if (lastSessionId !== undefined && sessionId !== lastSessionId) { | ||
currentRefreshUserCallback(); | ||
} | ||
lastRefreshId = refreshId; | ||
lastSessionId = sessionId; | ||
} | ||
@@ -99,5 +150,3 @@ } | ||
window.addEventListener('message', messageListener, false); | ||
createWatcherIFrame(BBOmnibarUserActivity.IDENTITY_SECURITY_TOKEN_SERVICE_ORIGIN + | ||
'/SessionWatcher.html?origin=' + | ||
encodeURIComponent(location.origin)); | ||
createWatcherIFrame(); | ||
} | ||
@@ -107,11 +156,19 @@ var BBOmnibarUserActivity = (function () { | ||
} | ||
BBOmnibarUserActivity.startTracking = function (refreshUserCallback) { | ||
if (!isTracking) { | ||
BBOmnibarUserActivity.startTracking = function (refreshUserCallback, showInactivityCallback, hideInactivityCallback, allowAnonymous) { | ||
if (!isTracking || allowAnonymous !== currentAllowAnonymous) { | ||
BBOmnibarUserActivity.stopTracking(); | ||
currentRefreshUserCallback = refreshUserCallback; | ||
currentShowInactivityCallback = showInactivityCallback; | ||
currentHideInactivityCallback = hideInactivityCallback; | ||
currentAllowAnonymous = allowAnonymous; | ||
addActivityListeners(); | ||
startActivityTimer(); | ||
redirectIfUserLogsOutLater(); | ||
currentRefreshUserCallback = refreshUserCallback; | ||
isTracking = true; | ||
} | ||
}; | ||
BBOmnibarUserActivity.userRenewedSession = function () { | ||
closeInactivityPrompt(); | ||
renewSession(); | ||
}; | ||
BBOmnibarUserActivity.stopTracking = function () { | ||
@@ -135,20 +192,28 @@ if (watcherIFrame) { | ||
lastRenewal = undefined; | ||
renewOnNextActivity = undefined; | ||
lastSessionId = undefined; | ||
ttlCache = undefined; | ||
isShowingInactivityPrompt = undefined; | ||
currentRefreshUserCallback = undefined; | ||
currentShowInactivityCallback = undefined; | ||
currentHideInactivityCallback = undefined; | ||
currentAllowAnonymous = undefined; | ||
}; | ||
return BBOmnibarUserActivity; | ||
}()); | ||
// The interval in milliseconds that the last activity is evaluated against the session timeout period. | ||
BBOmnibarUserActivity.ACTIVITY_TIMER_INTERVAL = 1000; | ||
// The amount of millseconds that the expiration prompt will show before the session actually expires. | ||
BBOmnibarUserActivity.ABOUT_TO_EXPIRE_PROMPT_TIMEFRAME = 2 * 60 * 1000; | ||
// The amount of millseconds that a session is allowed without activity. | ||
BBOmnibarUserActivity.MAX_SESSION_AGE = 30 * 60 * 1000; | ||
// The minimum time in milliseconds that must elapse before this omnibar instance will issue a session renewal | ||
// after the previous session renewal. | ||
BBOmnibarUserActivity.MIN_RENEWAL_RETRY = 1 * 60 * 1000; | ||
// The tim in millseconds that the expiration prompt will show before the session actually expires. When the | ||
// prompt shows will be determined by subtracting this value from the MAX_SESSION_AGE; for instance, if the | ||
// prompt duration is 2 minutes and the max session age is 15 minutes, the inactivity prompt will be displayed | ||
// 13 minutes after the last user activity. | ||
BBOmnibarUserActivity.INACTIVITY_PROMPT_DURATION = 2 * 60 * 1000; | ||
// The minimum age in milliseconds of the session before it will be renewed in response to user activity. | ||
BBOmnibarUserActivity.MIN_RENEWAL_AGE = 5 * 60 * 1000; | ||
// The minimum amount of milliseconds that must ellapse before this omnibar instance will issue a session renewal | ||
// after the previos time one is | ||
BBOmnibarUserActivity.MIN_RENEWAL_RETRY = 60 * 1000; | ||
// The time in millseconds that a session is allowed without activity. | ||
BBOmnibarUserActivity.MAX_SESSION_AGE = 15 * 60 * 1000; | ||
BBOmnibarUserActivity.IDENTITY_SECURITY_TOKEN_SERVICE_ORIGIN = 'https://s21aidntoken00blkbapp01.nxt.blackbaud.com'; | ||
exports.BBOmnibarUserActivity = BBOmnibarUserActivity; | ||
//# sourceMappingURL=omnibar-user-activity.js.map |
export declare class BBAuthNavigator { | ||
static navigate(url: string): void; | ||
static redirectToSignin(signinRedirectParams?: any): void; | ||
static redirectToSignoutForInactivity(): void; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var SIGNIN_URL = 'https://signin.blackbaud.com/signin/'; | ||
var SIGNIN_BASE_URL = 'https://signin.blackbaud.com/signin/'; | ||
var euc = encodeURIComponent; | ||
function paramsToQS(params) { | ||
@@ -9,3 +10,3 @@ var qs = []; | ||
if (params.hasOwnProperty(p)) { | ||
qs.push(encodeURIComponent(p) + "=" + encodeURIComponent(params[p])); | ||
qs.push(euc(p) + "=" + euc(params[p])); | ||
} | ||
@@ -15,2 +16,9 @@ } | ||
} | ||
function createSigninUrl(inactive) { | ||
var url = SIGNIN_BASE_URL + "?redirectUrl=" + euc(location.href); | ||
if (inactive) { | ||
url += '&inactivity=1'; | ||
} | ||
return url; | ||
} | ||
var BBAuthNavigator = (function () { | ||
@@ -24,3 +32,3 @@ function BBAuthNavigator() { | ||
BBAuthNavigator.redirectToSignin = function (signinRedirectParams) { | ||
var signinUrl = SIGNIN_URL + '?redirectUrl=' + encodeURIComponent(location.href); | ||
var signinUrl = createSigninUrl(); | ||
if (signinRedirectParams) { | ||
@@ -31,2 +39,7 @@ signinUrl += '&' + paramsToQS(signinRedirectParams); | ||
}; | ||
BBAuthNavigator.redirectToSignoutForInactivity = function () { | ||
var signinUrl = createSigninUrl(true); | ||
var signoutUrl = SIGNIN_BASE_URL + "sign-out?redirectUrl=" + euc(signinUrl); | ||
this.navigate(signoutUrl); | ||
}; | ||
return BBAuthNavigator; | ||
@@ -33,0 +46,0 @@ }()); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
129308
83
2052