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

angular-aap-auth

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-aap-auth - npm Package Compare versions

Comparing version 1.0.0-alpha.10 to 1.0.0-alpha.11

esm2015/app/modules/auth/auth.config.js

979

bundles/angular-aap-auth.umd.js

@@ -1,315 +0,698 @@

/**
* Copyright 2017 EMBL - European Bioinformatics Institute
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@auth0/angular-jwt'), require('rxjs'), require('rxjs/operators')) :
typeof define === 'function' && define.amd ? define('angular-aap-auth', ['exports', '@angular/core', '@auth0/angular-jwt', 'rxjs', 'rxjs/operators'], factory) :
(factory((global['angular-aap-auth'] = {}),global.ng.core,global.angularJwt,global.RxJS,global.Rx.Observable.prototype));
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@auth0/angular-jwt'), require('rxjs'), require('rxjs/operators')) :
typeof define === 'function' && define.amd ? define('angular-aap-auth', ['exports', '@angular/core', '@auth0/angular-jwt', 'rxjs', 'rxjs/operators'], factory) :
(factory((global['angular-aap-auth'] = {}),global.ng.core,global.angularJwt,global.RxJS,global.rxjs.operators));
}(this, (function (exports,core,angularJwt,rxjs,operators) { 'use strict';
var TokenService = /** @class */ (function () {
function TokenService(_jwt) {
this._jwt = _jwt;
}
TokenService.prototype.getToken = function () {
return this._jwt.tokenGetter();
};
TokenService.prototype.getTokenExpirationDate = function () {
try {
return this._jwt.getTokenExpirationDate();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* The purpose of this very simple service is to interface between the
* AuthService and the specific token manipulation routing of JwtHelperService.
* In this way, if in the future we want to replace JwtHelperService by
* another service, AuthService doesn't need to be modified, only this service.
*/
var TokenService = (function () {
function TokenService(_jwt) {
this._jwt = _jwt;
}
catch (e) {
return null;
}
};
TokenService.prototype.isTokenValid = function () {
try {
return !this._jwt.isTokenExpired();
}
catch (error) {
return false;
}
};
TokenService.prototype.getClaim = function (claim, defaultValue) {
try {
var value = (this._jwt.decodeToken()[claim]);
if (value === undefined) {
return defaultValue;
}
return value;
}
catch (e) {
return defaultValue;
}
};
return TokenService;
}());
TokenService.decorators = [
{ type: core.Injectable },
];
TokenService.ctorParameters = function () { return [
{ type: angularJwt.JwtHelperService, },
]; };
var AAP_CONFIG = new core.InjectionToken('AAP_CONFIG');
function getToken() {
return localStorage.getItem('id_token') || '';
}
function removeToken() {
return localStorage.removeItem('id_token');
}
function updateToken(newToken) {
return localStorage.setItem('id_token', newToken);
}
var DEFAULT_CONF = {
aapURL: 'https://api.aai.ebi.ac.uk',
tokenGetter: getToken,
tokenRemover: removeToken,
tokenUpdater: updateToken
};
var AuthService = /** @class */ (function () {
function AuthService(_rendererFactory, _tokenService, config) {
var _this = this;
this._rendererFactory = _rendererFactory;
this._tokenService = _tokenService;
this.config = config;
this._credentials = new rxjs.BehaviorSubject(null);
this._loginCallbacks = [];
this._logoutCallbacks = [];
this._timeoutID = null;
this._commKeyName = 'AngularAapAuthUpdated';
this._commKeyUpdater = function () { return localStorage.setItem(_this._commKeyName, '' + new Date().getTime()); };
this._domain = encodeURIComponent(window.location.origin);
this._appURL = config.aapURL.replace(/\/$/, '');
this._storageUpdater = config.tokenUpdater;
if (config.tokenRemover) {
this._storageRemover = config.tokenRemover;
}
else {
this._storageRemover = function () { return config.tokenUpdater(null); };
}
var renderer = this._rendererFactory.createRenderer(null, null);
this._listenLoginMessage(renderer);
this._listenChangesFromOtherWindows(renderer);
this._updateCredentials();
/**
* @return {?}
*/
TokenService.prototype.getToken = /**
* @return {?}
*/
function () {
return this._jwt.tokenGetter();
};
/**
* @return {?}
*/
TokenService.prototype.getTokenExpirationDate = /**
* @return {?}
*/
function () {
try {
return this._jwt.getTokenExpirationDate();
}
catch (e) {
return null;
}
};
/**
* @return {?}
*/
TokenService.prototype.isTokenValid = /**
* @return {?}
*/
function () {
try {
return !this._jwt.isTokenExpired();
}
catch (error) {
return false;
}
};
/**
* Get claims from the token.
*
* @template T, C
* @param {?} claim The name of the claim
* @param {?} defaultValue The default value returned in case of error
*
* @return {?} claim or default value
*/
TokenService.prototype.getClaim = /**
* Get claims from the token.
*
* @template T, C
* @param {?} claim The name of the claim
* @param {?} defaultValue The default value returned in case of error
*
* @return {?} claim or default value
*/
function (claim, defaultValue) {
try {
var /** @type {?} */ value = (this._jwt.decodeToken()[claim]);
if (value === undefined) {
return defaultValue;
}
return value;
}
catch (e) {
return defaultValue;
}
};
TokenService.decorators = [
{ type: core.Injectable },
];
/** @nocollapse */
TokenService.ctorParameters = function () {
return [
{ type: angularJwt.JwtHelperService }
];
};
return TokenService;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var /** @type {?} */ AAP_CONFIG = new core.InjectionToken('AAP_CONFIG');
/**
* @return {?}
*/
function getToken() {
return localStorage.getItem('id_token') || '';
}
AuthService.prototype.isAuthenticated = function () {
return this._credentials.asObservable().pipe(operators.map(function (credentials) { return credentials ? true : false; }));
/**
* @return {?}
*/
function removeToken() {
return localStorage.removeItem('id_token');
}
/**
* @param {?} newToken
* @return {?}
*/
function updateToken(newToken) {
return localStorage.setItem('id_token', newToken);
}
var /** @type {?} */ DEFAULT_CONF = {
aapURL: 'https://api.aai.ebi.ac.uk',
tokenGetter: getToken,
tokenRemover: removeToken,
tokenUpdater: updateToken
};
AuthService.prototype.credentials = function () {
return this._credentials.asObservable();
};
AuthService.prototype.realname = function () {
return this._credentials.asObservable().pipe(operators.map(function (credentials) { return credentials ? credentials.realname : null; }));
};
AuthService.prototype.username = function () {
return this._credentials.asObservable().pipe(operators.map(function (credentials) { return credentials ? credentials.username : null; }));
};
AuthService.prototype.token = function () {
return this._credentials.asObservable().pipe(operators.map(function (credentials) { return credentials ? credentials.token : null; }));
};
AuthService.prototype.windowOpen = function (loginOptions, width, height, top, left) {
if (width === void 0) { width = 650; }
if (height === void 0) { height = 1000; }
if (top === void 0) { top = -1; }
if (left === void 0) { left = -1; }
if (left < 0) {
var screenWidth = screen.width;
if (screenWidth > width) {
left = Math.round(screenWidth / 2 - width / 2);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var AuthService = (function () {
function AuthService(_rendererFactory, _tokenService, config) {
var _this = this;
this._rendererFactory = _rendererFactory;
this._tokenService = _tokenService;
this.config = config;
this._credentials = new rxjs.BehaviorSubject(null);
this._loginCallbacks = [];
this._logoutCallbacks = [];
this._timeoutID = null;
this._commKeyName = 'AngularAapAuthUpdated';
this._commKeyUpdater = function () { return localStorage.setItem(_this._commKeyName, '' + new Date().getTime()); };
this._domain = encodeURIComponent(window.location.origin);
this._appURL = config.aapURL.replace(/\/$/, '');
this._storageUpdater = config.tokenUpdater;
if (config.tokenRemover) {
this._storageRemover = config.tokenRemover;
}
}
if (top < 0) {
var screenHeight = screen.height;
if (screenHeight > height) {
top = Math.round(screenHeight / 2 - height / 2);
else {
this._storageRemover = function () { return config.tokenUpdater(null); };
}
var /** @type {?} */ renderer = this._rendererFactory.createRenderer(null, null);
this._listenLoginMessage(renderer);
this._listenChangesFromOtherWindows(renderer);
this._updateCredentials(); // TODO: experiment with setTimeOut
}
var windowOptions = [
"width=" + width,
"height=" + height,
"left=" + left,
"top=" + top,
'personalbar=no',
'toolbar=no',
'scrollbars=yes',
'resizable=yes',
'directories=no',
'location=no',
'menubar=no',
'titlebar=no',
'toolbar=no'
/**
* @return {?}
*/
AuthService.prototype.isAuthenticated = /**
* @return {?}
*/
function () {
return this._credentials.asObservable().pipe(operators.map(function (credentials) { return credentials ? true : false; }));
};
/**
* @return {?}
*/
AuthService.prototype.credentials = /**
* @return {?}
*/
function () {
return this._credentials.asObservable();
};
/**
* @return {?}
*/
AuthService.prototype.realname = /**
* @return {?}
*/
function () {
return this._credentials.asObservable().pipe(operators.map(function (credentials) { return credentials ? credentials.realname : null; }));
};
/**
* @return {?}
*/
AuthService.prototype.username = /**
* @return {?}
*/
function () {
return this._credentials.asObservable().pipe(operators.map(function (credentials) { return credentials ? credentials.username : null; }));
};
/**
* @return {?}
*/
AuthService.prototype.token = /**
* @return {?}
*/
function () {
return this._credentials.asObservable().pipe(operators.map(function (credentials) { return credentials ? credentials.token : null; }));
};
/**
* Functions that opens a window instead of a tab.
*
* See method _filterLoginOptions regarding security risks of certain
* LoginOptions.
*
* @param {?=} loginOptions Options passed as URL parameters to the SSO.
* @param {?=} width Pixel width of the login window.
* @param {?=} height Pixel height of the login window.
* @param {?=} top Position of the top corners. If it is a negative
* number it centres the login window on the screen.
* @param {?=} left Position of the left corners. If it is a negative
* number it centres the login window on the screen.
* @return {?}
*/
AuthService.prototype.windowOpen = /**
* Functions that opens a window instead of a tab.
*
* See method _filterLoginOptions regarding security risks of certain
* LoginOptions.
*
* @param {?=} loginOptions Options passed as URL parameters to the SSO.
* @param {?=} width Pixel width of the login window.
* @param {?=} height Pixel height of the login window.
* @param {?=} top Position of the top corners. If it is a negative
* number it centres the login window on the screen.
* @param {?=} left Position of the left corners. If it is a negative
* number it centres the login window on the screen.
* @return {?}
*/
function (loginOptions, width, height, top, left) {
if (width === void 0) {
width = 650;
}
if (height === void 0) {
height = 1000;
}
if (top === void 0) {
top = -1;
}
if (left === void 0) {
left = -1;
}
if (left < 0) {
var /** @type {?} */ screenWidth = screen.width;
if (screenWidth > width) {
left = Math.round(screenWidth / 2 - width / 2);
}
}
if (top < 0) {
var /** @type {?} */ screenHeight = screen.height;
if (screenHeight > height) {
top = Math.round(screenHeight / 2 - height / 2);
}
}
var /** @type {?} */ windowOptions = [
"width=" + width,
"height=" + height,
"left=" + left,
"top=" + top,
'personalbar=no',
'toolbar=no',
'scrollbars=yes',
'resizable=yes',
'directories=no',
'location=no',
'menubar=no',
'titlebar=no',
'toolbar=no'
];
var /** @type {?} */ loginWindow = window.open(this.getSSOURL(loginOptions), 'Sign in to Elixir', windowOptions.join(','));
if (loginWindow) {
loginWindow.focus();
}
};
/**
* Functions that opens a tab (in modern browser).
*
* See method _filterLoginOptions regarding security risks of certain
* LoginOptions.
*
* @param {?=} loginOptions Options passed as URL parameters to the SSO.
* @return {?}
*/
AuthService.prototype.tabOpen = /**
* Functions that opens a tab (in modern browser).
*
* See method _filterLoginOptions regarding security risks of certain
* LoginOptions.
*
* @param {?=} loginOptions Options passed as URL parameters to the SSO.
* @return {?}
*/
function (loginOptions) {
var /** @type {?} */ loginWindow = window.open(this.getSSOURL(loginOptions), 'Sign in to Elixir');
if (loginWindow) {
loginWindow.focus();
}
};
/**
* Produces a URL that allows logging into the single sign on (SSO) page.
* The URL cans be opened in a new tab using target="_blank",
* or in a new window using window.open().
*
* See method _filterLoginOptions regarding security risks of certain
* LoginOptions.
*
* @param {?=} options
* @return {?} The SSO URL.
*
*/
AuthService.prototype.getSSOURL = /**
* Produces a URL that allows logging into the single sign on (SSO) page.
* The URL cans be opened in a new tab using target="_blank",
* or in a new window using window.open().
*
* See method _filterLoginOptions regarding security risks of certain
* LoginOptions.
*
* @param {?=} options
* @return {?} The SSO URL.
*
*/
function (options) {
var /** @type {?} */ extra = '';
if (options) {
this._filterLoginOptions(options);
extra = Object.keys(options)
.map(function (key) { return [key, options[key]]; })
.reduce(function (accumulator, keyvalue) { return accumulator + "&" + keyvalue[0] + "=" + keyvalue[1]; }, '');
}
return this._appURL + "/sso?from=" + this._domain + extra;
};
/**
* Filters options that are unsecure.
*
* See the advance options that can be requested through the options parameter:
* https://api.aai.ebi.ac.uk/docs/authentication/authentication.index.html#_common_attributes
*
* The time to live paramenter (ttl) default value is 60 minutes. It is a
* big security risk to request longer ttl. If a third party gets hold of
* such token, means that they could use it for a day, week, year
* (essentially, like having the username/password).
*
* @param {?} options
* @return {?}
*/
AuthService.prototype._filterLoginOptions = /**
* Filters options that are unsecure.
*
* See the advance options that can be requested through the options parameter:
* https://api.aai.ebi.ac.uk/docs/authentication/authentication.index.html#_common_attributes
*
* The time to live paramenter (ttl) default value is 60 minutes. It is a
* big security risk to request longer ttl. If a third party gets hold of
* such token, means that they could use it for a day, week, year
* (essentially, like having the username/password).
*
* @param {?} options
* @return {?}
*/
function (options) {
if (Object.keys(options).indexOf('ttl') > -1) {
var /** @type {?} */ ttl = +options['ttl'];
var /** @type {?} */ softLimit = 60;
var /** @type {?} */ hardLimit = 60 * 24;
if (ttl > hardLimit) {
window.console.error("Login requested with an expiration longer than " + hardLimit + " minutes! This is not allowed.");
window.console.error("Expiration request reset to " + hardLimit + " minutes.");
options['ttl'] = '' + hardLimit;
}
else if (ttl > softLimit) {
window.console.warn("Login requested with an expiration longer than " + softLimit + " minutes!");
}
}
};
/**
* Functions that logs out the user.
* It triggers the logout callbacks.
* It is an arrow function (lambda) because in that way it has a reference
* to 'this' when used in setTimeout call.
* @return {?}
*/
AuthService.prototype.logOut = /**
* Functions that logs out the user.
* It triggers the logout callbacks.
* It is an arrow function (lambda) because in that way it has a reference
* to 'this' when used in setTimeout call.
* @return {?}
*/
function () {
this._storageRemover();
this._updateCredentials();
// Triggers updating other windows
this._commKeyUpdater();
};
/**
* Add a callback to the LogIn event.
*
* @param {?} callback The Function called when the login event is triggered and the
* JWT token is received and accepted.
*
* @return {?} The event registration id (necessary to unregister the event).
*/
AuthService.prototype.addLogInEventListener = /**
* Add a callback to the LogIn event.
*
* @param {?} callback The Function called when the login event is triggered and the
* JWT token is received and accepted.
*
* @return {?} The event registration id (necessary to unregister the event).
*/
function (callback) {
return this._loginCallbacks.push(callback);
};
/**
* Remove a callback from the LogIn event.
*
* @param {?} id The id given when event listener was added.
*
* @return {?} true when remove successfully, false otherwise.
*/
AuthService.prototype.removeLogInEventListener = /**
* Remove a callback from the LogIn event.
*
* @param {?} id The id given when event listener was added.
*
* @return {?} true when remove successfully, false otherwise.
*/
function (id) {
return delete this._loginCallbacks[id - 1];
};
/**
* Add a callback to the LogOut event.
*
* @param {?} callback The Function called when the logout event is triggered and the
* JWT token is received and accepted.
*
* @return {?} The registration id (necessary to unregister the event).
*/
AuthService.prototype.addLogOutEventListener = /**
* Add a callback to the LogOut event.
*
* @param {?} callback The Function called when the logout event is triggered and the
* JWT token is received and accepted.
*
* @return {?} The registration id (necessary to unregister the event).
*/
function (callback) {
return this._logoutCallbacks.push(callback);
};
/**
* Remove a callback from the LogOut event.
*
* @param {?} id The id given when event listener was added.
*
* @return {?} true when remove successfully, false otherwise.
*/
AuthService.prototype.removeLogOutEventListener = /**
* Remove a callback from the LogOut event.
*
* @param {?} id The id given when event listener was added.
*
* @return {?} true when remove successfully, false otherwise.
*/
function (id) {
return delete this._logoutCallbacks[id - 1];
};
/**
* Listen for login messages from other windows.
* These messages contain the tokens from the AAP.
* If a token is received then the callbacks are triggered.
* @param {?} renderer
* @return {?}
*/
AuthService.prototype._listenLoginMessage = /**
* Listen for login messages from other windows.
* These messages contain the tokens from the AAP.
* If a token is received then the callbacks are triggered.
* @param {?} renderer
* @return {?}
*/
function (renderer) {
var _this = this;
renderer.listen('window', 'message', function (event) {
if (!_this.messageIsAcceptable(event)) {
return;
}
_this._storageUpdater(event.data);
event.source.close();
_this._updateCredentials();
// Triggers updating other windows
// Triggers updating other windows
_this._commKeyUpdater();
});
};
/**
* Listen to changes in the token from *other* windows.
*
* For inter-window communication messages are transmitted trough changes
* on a dummy storage key property: '_commKeyName'.
*
* Notice that changes in the '_commKeyName' produced by this class doesn't
* trigger this event.
* @param {?} renderer
* @return {?}
*/
AuthService.prototype._listenChangesFromOtherWindows = /**
* Listen to changes in the token from *other* windows.
*
* For inter-window communication messages are transmitted trough changes
* on a dummy storage key property: '_commKeyName'.
*
* Notice that changes in the '_commKeyName' produced by this class doesn't
* trigger this event.
* @param {?} renderer
* @return {?}
*/
function (renderer) {
var _this = this;
renderer.listen('window', 'storage', function (event) {
if (event.key === _this._commKeyName) {
_this._updateCredentials();
}
});
};
/**
* Check if the message is coming from the same domain we use to generate
* the SSO URL, otherwise it's iffy and shouldn't trust it.
* @param {?} event
* @return {?}
*/
AuthService.prototype.messageIsAcceptable = /**
* Check if the message is coming from the same domain we use to generate
* the SSO URL, otherwise it's iffy and shouldn't trust it.
* @param {?} event
* @return {?}
*/
function (event) {
return event.origin === this._appURL;
};
/**
* @return {?}
*/
AuthService.prototype._updateCredentials = /**
* @return {?}
*/
function () {
var _this = this;
var /** @type {?} */ isAuthenticated = this._loggedIn();
if (this._timeoutID) {
window.clearTimeout(this._timeoutID);
}
if (isAuthenticated) {
this._credentials.next({
realname: /** @type {?} */ (this._getRealName()),
username: /** @type {?} */ (this._getUserName()),
token: /** @type {?} */ (this._getToken())
});
this._loginCallbacks.map(function (callback) { return callback && callback(); });
// Schedule future logout event base on token expiration
var /** @type {?} */ expireDate = (this._tokenService.getTokenExpirationDate());
// Coercing dates to numbers with the unary operator '+'
var /** @type {?} */ delay = +expireDate - +new Date();
this._timeoutID = window.setTimeout(function () { return _this.logOut(); }, delay);
}
else {
this._storageRemover(); // Cleanup possible left behind token
this._credentials.next(null);
this._logoutCallbacks.map(function (callback) { return callback && callback(); });
}
};
/**
* Check if there's a user logging on and whether the token is still valid.
*
* @return {?} Whether the user user is authenticated or not.
*/
AuthService.prototype._loggedIn = /**
* Check if there's a user logging on and whether the token is still valid.
*
* @return {?} Whether the user user is authenticated or not.
*/
function () {
return this._tokenService.isTokenValid();
};
/**
* @return {?}
*/
AuthService.prototype._getToken = /**
* @return {?}
*/
function () {
return this._tokenService.getToken();
};
/**
* @return {?}
*/
AuthService.prototype._getUserName = /**
* @return {?}
*/
function () {
return this._tokenService.getClaim('email', null);
};
/**
* @return {?}
*/
AuthService.prototype._getRealName = /**
* @return {?}
*/
function () {
return this._tokenService.getClaim('name', null);
};
AuthService.decorators = [
{ type: core.Injectable },
];
var loginWindow = window.open(this.getSSOURL(loginOptions), 'Sign in to Elixir', windowOptions.join(','));
if (loginWindow) {
loginWindow.focus();
}
};
AuthService.prototype.tabOpen = function (loginOptions) {
var loginWindow = window.open(this.getSSOURL(loginOptions), 'Sign in to Elixir');
if (loginWindow) {
loginWindow.focus();
}
};
AuthService.prototype.getSSOURL = function (options) {
var extra = '';
if (options) {
this._filterLoginOptions(options);
extra = Object.keys(options)
.map(function (key) { return [key, options[key]]; })
.reduce(function (accumulator, keyvalue) { return accumulator + "&" + keyvalue[0] + "=" + keyvalue[1]; }, '');
}
return this._appURL + "/sso?from=" + this._domain + extra;
};
AuthService.prototype._filterLoginOptions = function (options) {
if (Object.keys(options).indexOf('ttl') > -1) {
var ttl = +options['ttl'];
var softLimit = 60;
var hardLimit = 60 * 24;
if (ttl > hardLimit) {
window.console.error("Login requested with an expiration longer than " + hardLimit + " minutes! This is not allowed.");
window.console.error("Expiration request reset to " + hardLimit + " minutes.");
options['ttl'] = '' + hardLimit;
/** @nocollapse */
AuthService.ctorParameters = function () {
return [
{ type: core.RendererFactory2 },
{ type: TokenService },
{ type: undefined, decorators: [{ type: core.Inject, args: [AAP_CONFIG,] }] }
];
};
return AuthService;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var AuthModule = (function () {
function AuthModule(parentModule) {
if (parentModule) {
throw new Error('AuthModule is already loaded. It should only be imported in your application\'s main module.');
}
else if (ttl > softLimit) {
window.console.warn("Login requested with an expiration longer than " + softLimit + " minutes!");
}
}
};
AuthService.prototype.logOut = function () {
this._storageRemover();
this._updateCredentials();
this._commKeyUpdater();
};
AuthService.prototype.addLogInEventListener = function (callback) {
return this._loginCallbacks.push(callback);
};
AuthService.prototype.removeLogInEventListener = function (id) {
return delete this._loginCallbacks[id - 1];
};
AuthService.prototype.addLogOutEventListener = function (callback) {
return this._logoutCallbacks.push(callback);
};
AuthService.prototype.removeLogOutEventListener = function (id) {
return delete this._logoutCallbacks[id - 1];
};
AuthService.prototype._listenLoginMessage = function (renderer) {
var _this = this;
renderer.listen('window', 'message', function (event) {
if (!_this.messageIsAcceptable(event)) {
return;
}
_this._storageUpdater(event.data);
event.source.close();
_this._updateCredentials();
_this._commKeyUpdater();
});
};
AuthService.prototype._listenChangesFromOtherWindows = function (renderer) {
var _this = this;
renderer.listen('window', 'storage', function (event) {
if (event.key === _this._commKeyName) {
_this._updateCredentials();
}
});
};
AuthService.prototype.messageIsAcceptable = function (event) {
return event.origin === this._appURL;
};
AuthService.prototype._updateCredentials = function () {
var _this = this;
var isAuthenticated = this._loggedIn();
if (this._timeoutID) {
window.clearTimeout(this._timeoutID);
}
if (isAuthenticated) {
this._credentials.next({
realname: (this._getRealName()),
username: (this._getUserName()),
token: (this._getToken())
});
this._loginCallbacks.map(function (callback) { return callback && callback(); });
var expireDate = (this._tokenService.getTokenExpirationDate());
var delay = +expireDate - +new Date();
this._timeoutID = window.setTimeout(function () { return _this.logOut(); }, delay);
}
else {
this._storageRemover();
this._credentials.next(null);
this._logoutCallbacks.map(function (callback) { return callback && callback(); });
}
};
AuthService.prototype._loggedIn = function () {
return this._tokenService.isTokenValid();
};
AuthService.prototype._getToken = function () {
return this._tokenService.getToken();
};
AuthService.prototype._getUserName = function () {
return this._tokenService.getClaim('email', null);
};
AuthService.prototype._getRealName = function () {
return this._tokenService.getClaim('name', null);
};
return AuthService;
}());
AuthService.decorators = [
{ type: core.Injectable },
];
AuthService.ctorParameters = function () { return [
{ type: core.RendererFactory2, },
{ type: TokenService, },
{ type: undefined, decorators: [{ type: core.Inject, args: [AAP_CONFIG,] },] },
]; };
var AuthModule = /** @class */ (function () {
function AuthModule(parentModule) {
if (parentModule) {
throw new Error('AuthModule is already loaded. It should only be imported in your application\'s main module.');
}
}
AuthModule.forRoot = function (options) {
return {
ngModule: AuthModule,
providers: [
TokenService,
{
provide: AAP_CONFIG,
useValue: options ? options : DEFAULT_CONF
},
AuthService
]
/**
* @param {?=} options
* @return {?}
*/
AuthModule.forRoot = /**
* @param {?=} options
* @return {?}
*/
function (options) {
return {
ngModule: AuthModule,
providers: [
TokenService,
{
provide: AAP_CONFIG,
useValue: options ? options : DEFAULT_CONF
},
AuthService
]
};
};
AuthModule.decorators = [
{ type: core.NgModule, args: [{},] },
];
/** @nocollapse */
AuthModule.ctorParameters = function () {
return [
{ type: AuthModule, decorators: [{ type: core.Optional }, { type: core.SkipSelf }] }
];
};
};
return AuthModule;
}());
AuthModule.decorators = [
{ type: core.NgModule, args: [{},] },
];
AuthModule.ctorParameters = function () { return [
{ type: AuthModule, decorators: [{ type: core.Optional }, { type: core.SkipSelf },] },
]; };
return AuthModule;
}());
exports.AuthModule = AuthModule;
exports.AuthService = AuthService;
exports.TokenService = TokenService;
exports.ɵb = AAP_CONFIG;
exports.ɵf = DEFAULT_CONF;
exports.ɵc = getToken;
exports.ɵd = removeToken;
exports.ɵe = updateToken;
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
Object.defineProperty(exports, '__esModule', { value: true });
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
exports.AuthModule = AuthModule;
exports.AuthService = AuthService;
exports.TokenService = TokenService;
exports.ɵb = AAP_CONFIG;
exports.ɵf = DEFAULT_CONF;
exports.ɵc = getToken;
exports.ɵd = removeToken;
exports.ɵe = updateToken;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=angular-aap-auth.umd.js.map
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW5ndWxhci1hYXAtYXV0aC51bWQuanMubWFwIiwic291cmNlcyI6WyJuZzovL2FuZ3VsYXItYWFwLWF1dGgvYXBwL21vZHVsZXMvYXV0aC90b2tlbi5zZXJ2aWNlLnRzIiwibmc6Ly9hbmd1bGFyLWFhcC1hdXRoL2FwcC9tb2R1bGV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H1cbiAgICAgICAgfVxuICAgICAgICBpZiAodG9wIDwgMCkge1xuICAgICAgICAgICAgY29uc3Qgc2NyZWVuSGVpZ2h0ID0gc2NyZWVuLmhlaWdodDtcbiAgICAgICAgICAgIGlmIChzY3JlZW5IZWlnaHQgPiBoZWlnaHQpIHtcbiAgICAgICAgICAgICAgICB0b3AgPSBNYXRoLnJvdW5kKHNjcmVlbkhlaWdodCAvIDIgLSBoZWlnaHQgLyAyKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGNvbnN0IHdpbmRvd09wdGlvbnMgPSBbXG4gICAgICAgICAgICBgd2lkdGg9JHt3aWR0aH1gLFxuICAgICAgICAgICAgYGhlaWdodD0ke2hlaWdodH1gLFxuICAgICAgICAgICAgYGxlZnQ9JHtsZWZ0fWAsXG4gICAgICAgICAgICBgdG9wPSR7dG9wfWAsXG4gICAgICAgICAgICAncGVyc29uYWxiYXI9bm8nLFxuICAgICAgICAgICAgJ3Rvb2xiYXI9bm8nLFxuICAgICAgICAgICAgJ3Njcm9sbGJhcnM9eWVzJyxcbiAgICAgICAgICAgICdyZXNpemFibGU9eWVzJyxcbiAgICAgICAgICAgICdkaXJlY3Rvcmllcz1ubycsXG4gICAgICAgICAgICAnbG9jYXRpb249bm8nLFxuICAgICAgICAgICAgJ21lbnViYXI9bm8nLFxuICAgICAgICAgICAgJ3RpdGxlYmFyPW5vJyxcbiAgICAgICAgICAgICd0b29sYmFyPW5vJ1xuICAgICAgICBdO1xuXG4gICAgICAgIGNvbnN0IGxvZ2luV2luZG93ID0gd2luZG93Lm9wZW4odGhpcy5nZXRTU09VUkwobG9naW5PcHRpb25zKSwgJ1NpZ24gaW4gdG8gRWxpeGlyJywgd2luZG93T3B0aW9ucy5qb2luKCcsJykpO1xuICAgICAgICBpZiAobG9naW5XaW5kb3cpIHtcbiAgICAgICAgICAgIGxvZ2luV2luZG93LmZvY3VzKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICAvK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J0IHtcbiAgICBBdXRoU2VydmljZVxufSBmcm9tICcuL2F1dGguc2VydmljZSc7XG5cbkBOZ01vZHVsZSh7fSlcbmV4cG9ydCBjbGFzcyBBdXRoTW9kdWxlIHtcblxuICAgIGNvbnN0cnVjdG9yKEBPcHRpb25hbCgpIEBTa2lwU2VsZigpIHBhcmVudE1vZHVsZTogQXV0aE1vZHVsZSkge1xuICAgICAgICBpZiAocGFyZW50TW9kdWxlKSB7XG4gICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ0F1dGhNb2R1bGUgaXMgYWxyZWFkeSBsb2FkZWQuIEl0IHNob3VsZCBvbmx5IGJlIGltcG9ydGVkIGluIHlvdXIgYXBwbGljYXRpb25cXCdzIG1haW4gbW9kdWxlLicpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgc3RhdGljIGZvclJvb3Qob3B0aW9ucz86IEF1dGhDb25maWcpOiBNb2R1bGVXaXRoUHJvdmlkZXJzIHtcbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIG5nTW9kdWxlOiBBdXRoTW9kdWxlLFxuICAgICAgICAgICAgcHJvdmlkZXJzOiBbXG4gICAgICAgICAgICAgICAgVG9rZW5TZXJ2aWNlLFxuICAgICAgICAgICAgICAgIHtcbiAgICAgICAgICAgICAgICAgICAgcHJvdmlkZTogQUFQX0NPTkZJRyxcbiAgICAgICAgICAgICAgICAgICAgdXNlVmFsdWU6IG9wdGlvbnMgPyBvcHRpb25zIDogREVGQVVMVF9DT05GXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBBdXRoU2VydmljZVxuICAgICAgICAgICAgXVxuICAgICAgICB9O1xuICAgIH1cbn1cbiJdLCJuYW1lcyI6WyJJbmplY3RhYmxlIiwiSnd0SGVscGVyU2VydmljZSIsIkluamVjdGlvblRva2VuIiwiQmVoYXZpb3JTdWJqZWN0IiwibWFwIiwiUmVuZGVyZXJGYWN0b3J5MiIsIkluamVjdCIsIk5nTW9kdWxl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aUJBQ0osQ0FBQzthQUNMOztvQkFyQkpDLGFBQVEsU0FBQyxFQUFFOzs7Ozt3QkFHMEMsVUFBVSx1QkFBL0NDLGFBQVEsWUFBSUMsYUFBUTs7O3lCQTFCckM7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OzsifQ==

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@auth0/angular-jwt"),require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("angular-aap-auth",["exports","@angular/core","@auth0/angular-jwt","rxjs","rxjs/operators"],t):t(e["angular-aap-auth"]={},e.ng.core,e.angularJwt,e.RxJS,e.Rx.Observable.prototype)}(this,function(e,t,n,i,o){"use strict";var r=function(){function e(e){this._jwt=e}return e.prototype.getToken=function(){return this._jwt.tokenGetter()},e.prototype.getTokenExpirationDate=function(){try{return this._jwt.getTokenExpirationDate()}catch(e){return null}},e.prototype.isTokenValid=function(){try{return!this._jwt.isTokenExpired()}catch(e){return!1}},e.prototype.getClaim=function(e,t){try{var n=this._jwt.decodeToken()[e];return n===undefined?t:n}catch(o){return t}},e}();r.decorators=[{type:t.Injectable}],r.ctorParameters=function(){return[{type:n.JwtHelperService}]};var a=new t.InjectionToken("AAP_CONFIG");function s(){return localStorage.getItem("id_token")||""}function u(){return localStorage.removeItem("id_token")}function l(e){return localStorage.setItem("id_token",e)}var c={aapURL:"https://api.aai.ebi.ac.uk",tokenGetter:s,tokenRemover:u,tokenUpdater:l},p=function(){function e(e,t,n){var o=this;this._rendererFactory=e,this._tokenService=t,this.config=n,this._credentials=new i.BehaviorSubject(null),this._loginCallbacks=[],this._logoutCallbacks=[],this._timeoutID=null,this._commKeyName="AngularAapAuthUpdated",this._commKeyUpdater=function(){return localStorage.setItem(o._commKeyName,""+(new Date).getTime())},this._domain=encodeURIComponent(window.location.origin),this._appURL=n.aapURL.replace(/\/$/,""),this._storageUpdater=n.tokenUpdater,n.tokenRemover?this._storageRemover=n.tokenRemover:this._storageRemover=function(){return n.tokenUpdater(null)};var r=this._rendererFactory.createRenderer(null,null);this._listenLoginMessage(r),this._listenChangesFromOtherWindows(r),this._updateCredentials()}return e.prototype.isAuthenticated=function(){return this._credentials.asObservable().pipe(o.map(function(e){return!!e}))},e.prototype.credentials=function(){return this._credentials.asObservable()},e.prototype.realname=function(){return this._credentials.asObservable().pipe(o.map(function(e){return e?e.realname:null}))},e.prototype.username=function(){return this._credentials.asObservable().pipe(o.map(function(e){return e?e.username:null}))},e.prototype.token=function(){return this._credentials.asObservable().pipe(o.map(function(e){return e?e.token:null}))},e.prototype.windowOpen=function(e,t,n,o,r){if(void 0===t&&(t=650),void 0===n&&(n=1e3),void 0===o&&(o=-1),void 0===r&&(r=-1),r<0){var i=screen.width;t<i&&(r=Math.round(i/2-t/2))}if(o<0){var a=screen.height;n<a&&(o=Math.round(a/2-n/2))}var s=["width="+t,"height="+n,"left="+r,"top="+o,"personalbar=no","toolbar=no","scrollbars=yes","resizable=yes","directories=no","location=no","menubar=no","titlebar=no","toolbar=no"],u=window.open(this.getSSOURL(e),"Sign in to Elixir",s.join(","));u&&u.focus()},e.prototype.tabOpen=function(e){var t=window.open(this.getSSOURL(e),"Sign in to Elixir");t&&t.focus()},e.prototype.getSSOURL=function(t){var e="";return t&&(this._filterLoginOptions(t),e=Object.keys(t).map(function(e){return[e,t[e]]}).reduce(function(e,t){return e+"&"+t[0]+"="+t[1]},"")),this._appURL+"/sso?from="+this._domain+e},e.prototype._filterLoginOptions=function(e){if(-1<Object.keys(e).indexOf("ttl")){var t=+e.ttl;1440<t?(window.console.error("Login requested with an expiration longer than 1440 minutes! This is not allowed."),window.console.error("Expiration request reset to 1440 minutes."),e.ttl="1440"):60<t&&window.console.warn("Login requested with an expiration longer than 60 minutes!")}},e.prototype.logOut=function(){this._storageRemover(),this._updateCredentials(),this._commKeyUpdater()},e.prototype.addLogInEventListener=function(e){return this._loginCallbacks.push(e)},e.prototype.removeLogInEventListener=function(e){return delete this._loginCallbacks[e-1]},e.prototype.addLogOutEventListener=function(e){return this._logoutCallbacks.push(e)},e.prototype.removeLogOutEventListener=function(e){return delete this._logoutCallbacks[e-1]},e.prototype._listenLoginMessage=function(e){var t=this;e.listen("window","message",function(e){t.messageIsAcceptable(e)&&(t._storageUpdater(e.data),e.source.close(),t._updateCredentials(),t._commKeyUpdater())})},e.prototype._listenChangesFromOtherWindows=function(e){var t=this;e.listen("window","storage",function(e){e.key===t._commKeyName&&t._updateCredentials()})},e.prototype.messageIsAcceptable=function(e){return e.origin===this._appURL},e.prototype._updateCredentials=function(){var e=this,t=this._loggedIn();if(this._timeoutID&&window.clearTimeout(this._timeoutID),t){this._credentials.next({realname:this._getRealName(),username:this._getUserName(),token:this._getToken()}),this._loginCallbacks.map(function(e){return e&&e()});var n=+this._tokenService.getTokenExpirationDate()-+new Date;this._timeoutID=window.setTimeout(function(){return e.logOut()},n)}else this._storageRemover(),this._credentials.next(null),this._logoutCallbacks.map(function(e){return e&&e()})},e.prototype._loggedIn=function(){return this._tokenService.isTokenValid()},e.prototype._getToken=function(){return this._tokenService.getToken()},e.prototype._getUserName=function(){return this._tokenService.getClaim("email",null)},e.prototype._getRealName=function(){return this._tokenService.getClaim("name",null)},e}();p.decorators=[{type:t.Injectable}],p.ctorParameters=function(){return[{type:t.RendererFactory2},{type:r},{type:undefined,decorators:[{type:t.Inject,args:[a]}]}]};var d=function(){function t(e){if(e)throw new Error("AuthModule is already loaded. It should only be imported in your application's main module.")}return t.forRoot=function(e){return{ngModule:t,providers:[r,{provide:a,useValue:e||c},p]}},t}();d.decorators=[{type:t.NgModule,args:[{}]}],d.ctorParameters=function(){return[{type:d,decorators:[{type:t.Optional},{type:t.SkipSelf}]}]},e.AuthModule=d,e.AuthService=p,e.TokenService=r,e.ɵb=a,e.ɵf=c,e.ɵc=s,e.ɵd=u,e.ɵe=l,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=angular-aap-auth.umd.min.js.map
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@auth0/angular-jwt"),require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("angular-aap-auth",["exports","@angular/core","@auth0/angular-jwt","rxjs","rxjs/operators"],t):t(e["angular-aap-auth"]={},e.ng.core,e.angularJwt,e.RxJS,e.rxjs.operators)}(this,function(e,n,t,i,o){"use strict";var r=function(){function e(e){this._jwt=e}return e.prototype.getToken=function(){return this._jwt.tokenGetter()},e.prototype.getTokenExpirationDate=function(){try{return this._jwt.getTokenExpirationDate()}catch(e){return null}},e.prototype.isTokenValid=function(){try{return!this._jwt.isTokenExpired()}catch(e){return!1}},e.prototype.getClaim=function(e,t){try{var n=this._jwt.decodeToken()[e];return n===undefined?t:n}catch(o){return t}},e.decorators=[{type:n.Injectable}],e.ctorParameters=function(){return[{type:t.JwtHelperService}]},e}(),a=new n.InjectionToken("AAP_CONFIG");function s(){return localStorage.getItem("id_token")||""}function u(){return localStorage.removeItem("id_token")}function l(e){return localStorage.setItem("id_token",e)}var c={aapURL:"https://api.aai.ebi.ac.uk",tokenGetter:s,tokenRemover:u,tokenUpdater:l},p=function(){function e(e,t,n){var o=this;this._rendererFactory=e,this._tokenService=t,this.config=n,this._credentials=new i.BehaviorSubject(null),this._loginCallbacks=[],this._logoutCallbacks=[],this._timeoutID=null,this._commKeyName="AngularAapAuthUpdated",this._commKeyUpdater=function(){return localStorage.setItem(o._commKeyName,""+(new Date).getTime())},this._domain=encodeURIComponent(window.location.origin),this._appURL=n.aapURL.replace(/\/$/,""),this._storageUpdater=n.tokenUpdater,n.tokenRemover?this._storageRemover=n.tokenRemover:this._storageRemover=function(){return n.tokenUpdater(null)};var r=this._rendererFactory.createRenderer(null,null);this._listenLoginMessage(r),this._listenChangesFromOtherWindows(r),this._updateCredentials()}return e.prototype.isAuthenticated=function(){return this._credentials.asObservable().pipe(o.map(function(e){return!!e}))},e.prototype.credentials=function(){return this._credentials.asObservable()},e.prototype.realname=function(){return this._credentials.asObservable().pipe(o.map(function(e){return e?e.realname:null}))},e.prototype.username=function(){return this._credentials.asObservable().pipe(o.map(function(e){return e?e.username:null}))},e.prototype.token=function(){return this._credentials.asObservable().pipe(o.map(function(e){return e?e.token:null}))},e.prototype.windowOpen=function(e,t,n,o,r){if(void 0===t&&(t=650),void 0===n&&(n=1e3),void 0===o&&(o=-1),void 0===r&&(r=-1),r<0){var i=screen.width;t<i&&(r=Math.round(i/2-t/2))}if(o<0){var a=screen.height;n<a&&(o=Math.round(a/2-n/2))}var s=["width="+t,"height="+n,"left="+r,"top="+o,"personalbar=no","toolbar=no","scrollbars=yes","resizable=yes","directories=no","location=no","menubar=no","titlebar=no","toolbar=no"],u=window.open(this.getSSOURL(e),"Sign in to Elixir",s.join(","));u&&u.focus()},e.prototype.tabOpen=function(e){var t=window.open(this.getSSOURL(e),"Sign in to Elixir");t&&t.focus()},e.prototype.getSSOURL=function(t){var e="";return t&&(this._filterLoginOptions(t),e=Object.keys(t).map(function(e){return[e,t[e]]}).reduce(function(e,t){return e+"&"+t[0]+"="+t[1]},"")),this._appURL+"/sso?from="+this._domain+e},e.prototype._filterLoginOptions=function(e){if(-1<Object.keys(e).indexOf("ttl")){var t=+e.ttl;1440<t?(window.console.error("Login requested with an expiration longer than 1440 minutes! This is not allowed."),window.console.error("Expiration request reset to 1440 minutes."),e.ttl="1440"):60<t&&window.console.warn("Login requested with an expiration longer than 60 minutes!")}},e.prototype.logOut=function(){this._storageRemover(),this._updateCredentials(),this._commKeyUpdater()},e.prototype.addLogInEventListener=function(e){return this._loginCallbacks.push(e)},e.prototype.removeLogInEventListener=function(e){return delete this._loginCallbacks[e-1]},e.prototype.addLogOutEventListener=function(e){return this._logoutCallbacks.push(e)},e.prototype.removeLogOutEventListener=function(e){return delete this._logoutCallbacks[e-1]},e.prototype._listenLoginMessage=function(e){var t=this;e.listen("window","message",function(e){t.messageIsAcceptable(e)&&(t._storageUpdater(e.data),e.source.close(),t._updateCredentials(),t._commKeyUpdater())})},e.prototype._listenChangesFromOtherWindows=function(e){var t=this;e.listen("window","storage",function(e){e.key===t._commKeyName&&t._updateCredentials()})},e.prototype.messageIsAcceptable=function(e){return e.origin===this._appURL},e.prototype._updateCredentials=function(){var e=this,t=this._loggedIn();if(this._timeoutID&&window.clearTimeout(this._timeoutID),t){this._credentials.next({realname:this._getRealName(),username:this._getUserName(),token:this._getToken()}),this._loginCallbacks.map(function(e){return e&&e()});var n=+this._tokenService.getTokenExpirationDate()-+new Date;this._timeoutID=window.setTimeout(function(){return e.logOut()},n)}else this._storageRemover(),this._credentials.next(null),this._logoutCallbacks.map(function(e){return e&&e()})},e.prototype._loggedIn=function(){return this._tokenService.isTokenValid()},e.prototype._getToken=function(){return this._tokenService.getToken()},e.prototype._getUserName=function(){return this._tokenService.getClaim("email",null)},e.prototype._getRealName=function(){return this._tokenService.getClaim("name",null)},e.decorators=[{type:n.Injectable}],e.ctorParameters=function(){return[{type:n.RendererFactory2},{type:r},{type:undefined,decorators:[{type:n.Inject,args:[a]}]}]},e}(),d=function(){function t(e){if(e)throw new Error("AuthModule is already loaded. It should only be imported in your application's main module.")}return t.forRoot=function(e){return{ngModule:t,providers:[r,{provide:a,useValue:e||c},p]}},t.decorators=[{type:n.NgModule,args:[{}]}],t.ctorParameters=function(){return[{type:t,decorators:[{type:n.Optional},{type:n.SkipSelf}]}]},t}();e.AuthModule=d,e.AuthService=p,e.TokenService=r,e.ɵb=a,e.ɵf=c,e.ɵc=s,e.ɵd=u,e.ɵe=l,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=angular-aap-auth.umd.min.js.map
/**
* Copyright 2017 EMBL - European Bioinformatics Institute
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
import { Injectable, InjectionToken, Inject, RendererFactory2, NgModule, Optional, SkipSelf } from '@angular/core';
import { JwtHelperService } from '@auth0/angular-jwt';
import { BehaviorSubject } from 'rxjs';
import { map } from 'rxjs/operators';
/**
* @fileoverview added by tsickle

@@ -26,511 +6,7 @@ * @suppress {checkTypes} checked by tsc

/**
* The purpose of this very simple service is to interface between the
* AuthService and the specific token manipulation routing of JwtHelperService.
* In this way, if in the future we want to replace JwtHelperService by
* another service, AuthService doesn't need to be modified, only this service.
*/
class TokenService {
/**
* @param {?} _jwt
*/
constructor(_jwt) {
this._jwt = _jwt;
}
/**
* @return {?}
*/
getToken() {
return this._jwt.tokenGetter();
}
/**
* @return {?}
*/
getTokenExpirationDate() {
try {
return this._jwt.getTokenExpirationDate();
}
catch (/** @type {?} */ e) {
return null;
}
}
/**
* @return {?}
*/
isTokenValid() {
try {
return !this._jwt.isTokenExpired();
}
catch (/** @type {?} */ error) {
return false;
}
}
/**
* Get claims from the token.
*
* @template T, C
* @param {?} claim The name of the claim
* @param {?} defaultValue The default value returned in case of error
*
* @return {?} claim or default value
*/
getClaim(claim, defaultValue) {
try {
const /** @type {?} */ value = /** @type {?} */ (this._jwt.decodeToken()[claim]);
if (value === undefined) {
return defaultValue;
}
return value;
}
catch (/** @type {?} */ e) {
return defaultValue;
}
}
}
TokenService.decorators = [
{ type: Injectable },
];
/** @nocollapse */
TokenService.ctorParameters = () => [
{ type: JwtHelperService, },
];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @record
*/
const AAP_CONFIG = new InjectionToken('AAP_CONFIG');
/**
* @return {?}
*/
function getToken() {
return localStorage.getItem('id_token') || '';
}
/**
* @return {?}
*/
function removeToken() {
return localStorage.removeItem('id_token');
}
/**
* @param {?} newToken
* @return {?}
*/
function updateToken(newToken) {
return localStorage.setItem('id_token', newToken);
}
const DEFAULT_CONF = {
aapURL: 'https://api.aai.ebi.ac.uk',
tokenGetter: getToken,
tokenRemover: removeToken,
tokenUpdater: updateToken
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @record
*/
/**
* @record
*/
class AuthService {
/**
* @param {?} _rendererFactory
* @param {?} _tokenService
* @param {?} config
*/
constructor(_rendererFactory, _tokenService, config) {
this._rendererFactory = _rendererFactory;
this._tokenService = _tokenService;
this.config = config;
this._credentials = new BehaviorSubject(null);
this._loginCallbacks = [];
this._logoutCallbacks = [];
this._timeoutID = null;
this._commKeyName = 'AngularAapAuthUpdated';
this._commKeyUpdater = () => localStorage.setItem(this._commKeyName, '' + new Date().getTime());
this._domain = encodeURIComponent(window.location.origin);
this._appURL = config.aapURL.replace(/\/$/, '');
this._storageUpdater = config.tokenUpdater;
if (config.tokenRemover) {
this._storageRemover = config.tokenRemover;
}
else {
this._storageRemover = () => config.tokenUpdater(null);
}
const /** @type {?} */ renderer = this._rendererFactory.createRenderer(null, null);
this._listenLoginMessage(renderer);
this._listenChangesFromOtherWindows(renderer);
this._updateCredentials(); // TODO: experiment with setTimeOut
}
/**
* @return {?}
*/
isAuthenticated() {
return this._credentials.asObservable().pipe(map(credentials => credentials ? true : false));
}
/**
* @return {?}
*/
credentials() {
return this._credentials.asObservable();
}
/**
* @return {?}
*/
realname() {
return this._credentials.asObservable().pipe(map(credentials => credentials ? credentials.realname : null));
}
/**
* @return {?}
*/
username() {
return this._credentials.asObservable().pipe(map(credentials => credentials ? credentials.username : null));
}
/**
* @return {?}
*/
token() {
return this._credentials.asObservable().pipe(map(credentials => credentials ? credentials.token : null));
}
/**
* Functions that opens a window instead of a tab.
*
* See method _filterLoginOptions regarding security risks of certain
* LoginOptions.
*
* @param {?=} loginOptions Options passed as URL parameters to the SSO.
* @param {?=} width Pixel width of the login window.
* @param {?=} height Pixel height of the login window.
* @param {?=} top Position of the top corners. If it is a negative
* number it centres the login window on the screen.
* @param {?=} left Position of the left corners. If it is a negative
* number it centres the login window on the screen.
* @return {?}
*/
windowOpen(loginOptions, width = 650, height = 1000, top = -1, left = -1) {
if (left < 0) {
const /** @type {?} */ screenWidth = screen.width;
if (screenWidth > width) {
left = Math.round(screenWidth / 2 - width / 2);
}
}
if (top < 0) {
const /** @type {?} */ screenHeight = screen.height;
if (screenHeight > height) {
top = Math.round(screenHeight / 2 - height / 2);
}
}
const /** @type {?} */ windowOptions = [
`width=${width}`,
`height=${height}`,
`left=${left}`,
`top=${top}`,
'personalbar=no',
'toolbar=no',
'scrollbars=yes',
'resizable=yes',
'directories=no',
'location=no',
'menubar=no',
'titlebar=no',
'toolbar=no'
];
const /** @type {?} */ loginWindow = window.open(this.getSSOURL(loginOptions), 'Sign in to Elixir', windowOptions.join(','));
if (loginWindow) {
loginWindow.focus();
}
}
/**
* Functions that opens a tab (in modern browser).
*
* See method _filterLoginOptions regarding security risks of certain
* LoginOptions.
*
* @param {?=} loginOptions Options passed as URL parameters to the SSO.
* @return {?}
*/
tabOpen(loginOptions) {
const /** @type {?} */ loginWindow = window.open(this.getSSOURL(loginOptions), 'Sign in to Elixir');
if (loginWindow) {
loginWindow.focus();
}
}
/**
* Produces a URL that allows logging into the single sign on (SSO) page.
* The URL cans be opened in a new tab using target="_blank",
* or in a new window using window.open().
*
* See method _filterLoginOptions regarding security risks of certain
* LoginOptions.
*
* @param {?=} options
* @return {?} The SSO URL.
*
*/
getSSOURL(options) {
let /** @type {?} */ extra = '';
if (options) {
this._filterLoginOptions(options);
extra = Object.keys(options)
.map(key => [key, options[key]])
.reduce((accumulator, keyvalue) => `${accumulator}&${keyvalue[0]}=${keyvalue[1]}`, '');
}
return `${this._appURL}/sso?from=${this._domain}${extra}`;
}
/**
* Filters options that are unsecure.
*
* See the advance options that can be requested through the options parameter:
* https://api.aai.ebi.ac.uk/docs/authentication/authentication.index.html#_common_attributes
*
* The time to live paramenter (ttl) default value is 60 minutes. It is a
* big security risk to request longer ttl. If a third party gets hold of
* such token, means that they could use it for a day, week, year
* (essentially, like having the username/password).
*
* @param {?} options
* @return {?}
*/
_filterLoginOptions(options) {
if (Object.keys(options).indexOf('ttl') > -1) {
const /** @type {?} */ ttl = +options['ttl'];
const /** @type {?} */ softLimit = 60;
const /** @type {?} */ hardLimit = 60 * 24;
if (ttl > hardLimit) {
window.console.error(`Login requested with an expiration longer than ${hardLimit} minutes! This is not allowed.`);
window.console.error(`Expiration request reset to ${hardLimit} minutes.`);
options['ttl'] = '' + hardLimit;
}
else if (ttl > softLimit) {
window.console.warn(`Login requested with an expiration longer than ${softLimit} minutes!`);
}
}
}
/**
* Functions that logs out the user.
* It triggers the logout callbacks.
* It is an arrow function (lambda) because in that way it has a reference
* to 'this' when used in setTimeout call.
* @return {?}
*/
logOut() {
this._storageRemover();
this._updateCredentials();
// Triggers updating other windows
this._commKeyUpdater();
}
/**
* Add a callback to the LogIn event.
*
* @param {?} callback The Function called when the login event is triggered and the
* JWT token is received and accepted.
*
* @return {?} The event registration id (necessary to unregister the event).
*/
addLogInEventListener(callback) {
return this._loginCallbacks.push(callback);
}
/**
* Remove a callback from the LogIn event.
*
* @param {?} id The id given when event listener was added.
*
* @return {?} true when remove successfully, false otherwise.
*/
removeLogInEventListener(id) {
return delete this._loginCallbacks[id - 1];
}
/**
* Add a callback to the LogOut event.
*
* @param {?} callback The Function called when the logout event is triggered and the
* JWT token is received and accepted.
*
* @return {?} The registration id (necessary to unregister the event).
*/
addLogOutEventListener(callback) {
return this._logoutCallbacks.push(callback);
}
/**
* Remove a callback from the LogOut event.
*
* @param {?} id The id given when event listener was added.
*
* @return {?} true when remove successfully, false otherwise.
*/
removeLogOutEventListener(id) {
return delete this._logoutCallbacks[id - 1];
}
/**
* Listen for login messages from other windows.
* These messages contain the tokens from the AAP.
* If a token is received then the callbacks are triggered.
* @param {?} renderer
* @return {?}
*/
_listenLoginMessage(renderer) {
renderer.listen('window', 'message', (event) => {
if (!this.messageIsAcceptable(event)) {
return;
}
this._storageUpdater(event.data);
event.source.close();
this._updateCredentials();
// Triggers updating other windows
this._commKeyUpdater();
});
}
/**
* Listen to changes in the token from *other* windows.
*
* For inter-window communication messages are transmitted trough changes
* on a dummy storage key property: '_commKeyName'.
*
* Notice that changes in the '_commKeyName' produced by this class doesn't
* trigger this event.
* @param {?} renderer
* @return {?}
*/
_listenChangesFromOtherWindows(renderer) {
renderer.listen('window', 'storage', (event) => {
if (event.key === this._commKeyName) {
this._updateCredentials();
}
});
}
/**
* Check if the message is coming from the same domain we use to generate
* the SSO URL, otherwise it's iffy and shouldn't trust it.
* @param {?} event
* @return {?}
*/
messageIsAcceptable(event) {
return event.origin === this._appURL;
}
/**
* @return {?}
*/
_updateCredentials() {
const /** @type {?} */ isAuthenticated = this._loggedIn();
if (this._timeoutID) {
window.clearTimeout(this._timeoutID);
}
if (isAuthenticated) {
this._credentials.next({
realname: /** @type {?} */ (this._getRealName()),
username: /** @type {?} */ (this._getUserName()),
token: /** @type {?} */ (this._getToken())
});
this._loginCallbacks.map(callback => callback && callback());
// Schedule future logout event base on token expiration
const /** @type {?} */ expireDate = /** @type {?} */ (this._tokenService.getTokenExpirationDate());
// Coercing dates to numbers with the unary operator '+'
const /** @type {?} */ delay = +expireDate - +new Date();
this._timeoutID = window.setTimeout(() => this.logOut(), delay);
}
else {
this._storageRemover(); // Cleanup possible left behind token
this._credentials.next(null);
this._logoutCallbacks.map(callback => callback && callback());
}
}
/**
* Check if there's a user logging on and whether the token is still valid.
*
* @return {?} Whether the user user is authenticated or not.
*/
_loggedIn() {
return this._tokenService.isTokenValid();
}
/**
* @return {?}
*/
_getToken() {
return this._tokenService.getToken();
}
/**
* @return {?}
*/
_getUserName() {
return this._tokenService.getClaim('email', null);
}
/**
* @return {?}
*/
_getRealName() {
return this._tokenService.getClaim('name', null);
}
}
AuthService.decorators = [
{ type: Injectable },
];
/** @nocollapse */
AuthService.ctorParameters = () => [
{ type: RendererFactory2, },
{ type: TokenService, },
{ type: undefined, decorators: [{ type: Inject, args: [AAP_CONFIG,] },] },
];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
class AuthModule {
/**
* @param {?} parentModule
*/
constructor(parentModule) {
if (parentModule) {
throw new Error('AuthModule is already loaded. It should only be imported in your application\'s main module.');
}
}
/**
* @param {?=} options
* @return {?}
*/
static forRoot(options) {
return {
ngModule: AuthModule,
providers: [
TokenService,
{
provide: AAP_CONFIG,
useValue: options ? options : DEFAULT_CONF
},
AuthService
]
};
}
}
AuthModule.decorators = [
{ type: NgModule, args: [{},] },
];
/** @nocollapse */
AuthModule.ctorParameters = () => [
{ type: AuthModule, decorators: [{ type: Optional }, { type: SkipSelf },] },
];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* Generated bundle index. Do not edit.
*/
export { AuthModule, AuthService, TokenService } from './public_api';
export { AAP_CONFIG as ɵb, DEFAULT_CONF as ɵf, getToken as ɵc, removeToken as ɵd, updateToken as ɵe } from './app/modules/auth/auth.config';
export { AuthModule, AuthService, TokenService, AAP_CONFIG as ɵb, DEFAULT_CONF as ɵf, getToken as ɵc, removeToken as ɵd, updateToken as ɵe };
//# sourceMappingURL=angular-aap-auth.js.map
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW5ndWxhci1hYXAtYXV0aC5qcyIsInNvdXJjZVJvb3QiOiJuZzovL2FuZ3VsYXItYWFwLWF1dGgvIiwic291cmNlcyI6WyJhbmd1bGFyLWFhcC1hdXRoLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFJQSxzREFBYyxjQUFjLENBQUM7QUFFN0IsT0FBTyxFQUFDLFVBQVUsSUFBSSxFQUFFLEVBQWtCLFlBQVksSUFBSSxFQUFFLEVBQUMsUUFBUSxJQUFJLEVBQUUsRUFBQyxXQUFXLElBQUksRUFBRSxFQUFDLFdBQVcsSUFBSSxFQUFFLEVBQUMsTUFBTSxnQ0FBZ0MsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogR2VuZXJhdGVkIGJ1bmRsZSBpbmRleC4gRG8gbm90IGVkaXQuXG4gKi9cblxuZXhwb3J0ICogZnJvbSAnLi9wdWJsaWNfYXBpJztcblxuZXhwb3J0IHtBQVBfQ09ORklHIGFzIMm1YixBdXRoQ29uZmlnIGFzIMm1YSxERUZBVUxUX0NPTkYgYXMgybVmLGdldFRva2VuIGFzIMm1YyxyZW1vdmVUb2tlbiBhcyDJtWQsdXBkYXRlVG9rZW4gYXMgybVlfSBmcm9tICcuL2FwcC9tb2R1bGVzL2F1dGgvYXV0aC5jb25maWcnOyJdfQ==

@@ -1,288 +0,11 @@

import { Injectable, InjectionToken, Inject, RendererFactory2, NgModule, Optional, SkipSelf } from '@angular/core';
import { JwtHelperService } from '@auth0/angular-jwt';
import { BehaviorSubject } from 'rxjs';
import { map } from 'rxjs/operators';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* Generated bundle index. Do not edit.
*/
export { AuthModule, AuthService, TokenService } from './public_api';
export { AAP_CONFIG as ɵb, DEFAULT_CONF as ɵf, getToken as ɵc, removeToken as ɵd, updateToken as ɵe } from './app/modules/auth/auth.config';
var TokenService = /** @class */ (function () {
function TokenService(_jwt) {
this._jwt = _jwt;
}
TokenService.prototype.getToken = function () {
return this._jwt.tokenGetter();
};
TokenService.prototype.getTokenExpirationDate = function () {
try {
return this._jwt.getTokenExpirationDate();
}
catch (e) {
return null;
}
};
TokenService.prototype.isTokenValid = function () {
try {
return !this._jwt.isTokenExpired();
}
catch (error) {
return false;
}
};
TokenService.prototype.getClaim = function (claim, defaultValue) {
try {
var value = (this._jwt.decodeToken()[claim]);
if (value === undefined) {
return defaultValue;
}
return value;
}
catch (e) {
return defaultValue;
}
};
return TokenService;
}());
TokenService.decorators = [
{ type: Injectable },
];
TokenService.ctorParameters = function () { return [
{ type: JwtHelperService, },
]; };
var AAP_CONFIG = new InjectionToken('AAP_CONFIG');
function getToken() {
return localStorage.getItem('id_token') || '';
}
function removeToken() {
return localStorage.removeItem('id_token');
}
function updateToken(newToken) {
return localStorage.setItem('id_token', newToken);
}
var DEFAULT_CONF = {
aapURL: 'https://api.aai.ebi.ac.uk',
tokenGetter: getToken,
tokenRemover: removeToken,
tokenUpdater: updateToken
};
var AuthService = /** @class */ (function () {
function AuthService(_rendererFactory, _tokenService, config) {
var _this = this;
this._rendererFactory = _rendererFactory;
this._tokenService = _tokenService;
this.config = config;
this._credentials = new BehaviorSubject(null);
this._loginCallbacks = [];
this._logoutCallbacks = [];
this._timeoutID = null;
this._commKeyName = 'AngularAapAuthUpdated';
this._commKeyUpdater = function () { return localStorage.setItem(_this._commKeyName, '' + new Date().getTime()); };
this._domain = encodeURIComponent(window.location.origin);
this._appURL = config.aapURL.replace(/\/$/, '');
this._storageUpdater = config.tokenUpdater;
if (config.tokenRemover) {
this._storageRemover = config.tokenRemover;
}
else {
this._storageRemover = function () { return config.tokenUpdater(null); };
}
var renderer = this._rendererFactory.createRenderer(null, null);
this._listenLoginMessage(renderer);
this._listenChangesFromOtherWindows(renderer);
this._updateCredentials();
}
AuthService.prototype.isAuthenticated = function () {
return this._credentials.asObservable().pipe(map(function (credentials) { return credentials ? true : false; }));
};
AuthService.prototype.credentials = function () {
return this._credentials.asObservable();
};
AuthService.prototype.realname = function () {
return this._credentials.asObservable().pipe(map(function (credentials) { return credentials ? credentials.realname : null; }));
};
AuthService.prototype.username = function () {
return this._credentials.asObservable().pipe(map(function (credentials) { return credentials ? credentials.username : null; }));
};
AuthService.prototype.token = function () {
return this._credentials.asObservable().pipe(map(function (credentials) { return credentials ? credentials.token : null; }));
};
AuthService.prototype.windowOpen = function (loginOptions, width, height, top, left) {
if (width === void 0) { width = 650; }
if (height === void 0) { height = 1000; }
if (top === void 0) { top = -1; }
if (left === void 0) { left = -1; }
if (left < 0) {
var screenWidth = screen.width;
if (screenWidth > width) {
left = Math.round(screenWidth / 2 - width / 2);
}
}
if (top < 0) {
var screenHeight = screen.height;
if (screenHeight > height) {
top = Math.round(screenHeight / 2 - height / 2);
}
}
var windowOptions = [
"width=" + width,
"height=" + height,
"left=" + left,
"top=" + top,
'personalbar=no',
'toolbar=no',
'scrollbars=yes',
'resizable=yes',
'directories=no',
'location=no',
'menubar=no',
'titlebar=no',
'toolbar=no'
];
var loginWindow = window.open(this.getSSOURL(loginOptions), 'Sign in to Elixir', windowOptions.join(','));
if (loginWindow) {
loginWindow.focus();
}
};
AuthService.prototype.tabOpen = function (loginOptions) {
var loginWindow = window.open(this.getSSOURL(loginOptions), 'Sign in to Elixir');
if (loginWindow) {
loginWindow.focus();
}
};
AuthService.prototype.getSSOURL = function (options) {
var extra = '';
if (options) {
this._filterLoginOptions(options);
extra = Object.keys(options)
.map(function (key) { return [key, options[key]]; })
.reduce(function (accumulator, keyvalue) { return accumulator + "&" + keyvalue[0] + "=" + keyvalue[1]; }, '');
}
return this._appURL + "/sso?from=" + this._domain + extra;
};
AuthService.prototype._filterLoginOptions = function (options) {
if (Object.keys(options).indexOf('ttl') > -1) {
var ttl = +options['ttl'];
var softLimit = 60;
var hardLimit = 60 * 24;
if (ttl > hardLimit) {
window.console.error("Login requested with an expiration longer than " + hardLimit + " minutes! This is not allowed.");
window.console.error("Expiration request reset to " + hardLimit + " minutes.");
options['ttl'] = '' + hardLimit;
}
else if (ttl > softLimit) {
window.console.warn("Login requested with an expiration longer than " + softLimit + " minutes!");
}
}
};
AuthService.prototype.logOut = function () {
this._storageRemover();
this._updateCredentials();
this._commKeyUpdater();
};
AuthService.prototype.addLogInEventListener = function (callback) {
return this._loginCallbacks.push(callback);
};
AuthService.prototype.removeLogInEventListener = function (id) {
return delete this._loginCallbacks[id - 1];
};
AuthService.prototype.addLogOutEventListener = function (callback) {
return this._logoutCallbacks.push(callback);
};
AuthService.prototype.removeLogOutEventListener = function (id) {
return delete this._logoutCallbacks[id - 1];
};
AuthService.prototype._listenLoginMessage = function (renderer) {
var _this = this;
renderer.listen('window', 'message', function (event) {
if (!_this.messageIsAcceptable(event)) {
return;
}
_this._storageUpdater(event.data);
event.source.close();
_this._updateCredentials();
_this._commKeyUpdater();
});
};
AuthService.prototype._listenChangesFromOtherWindows = function (renderer) {
var _this = this;
renderer.listen('window', 'storage', function (event) {
if (event.key === _this._commKeyName) {
_this._updateCredentials();
}
});
};
AuthService.prototype.messageIsAcceptable = function (event) {
return event.origin === this._appURL;
};
AuthService.prototype._updateCredentials = function () {
var _this = this;
var isAuthenticated = this._loggedIn();
if (this._timeoutID) {
window.clearTimeout(this._timeoutID);
}
if (isAuthenticated) {
this._credentials.next({
realname: (this._getRealName()),
username: (this._getUserName()),
token: (this._getToken())
});
this._loginCallbacks.map(function (callback) { return callback && callback(); });
var expireDate = (this._tokenService.getTokenExpirationDate());
var delay = +expireDate - +new Date();
this._timeoutID = window.setTimeout(function () { return _this.logOut(); }, delay);
}
else {
this._storageRemover();
this._credentials.next(null);
this._logoutCallbacks.map(function (callback) { return callback && callback(); });
}
};
AuthService.prototype._loggedIn = function () {
return this._tokenService.isTokenValid();
};
AuthService.prototype._getToken = function () {
return this._tokenService.getToken();
};
AuthService.prototype._getUserName = function () {
return this._tokenService.getClaim('email', null);
};
AuthService.prototype._getRealName = function () {
return this._tokenService.getClaim('name', null);
};
return AuthService;
}());
AuthService.decorators = [
{ type: Injectable },
];
AuthService.ctorParameters = function () { return [
{ type: RendererFactory2, },
{ type: TokenService, },
{ type: undefined, decorators: [{ type: Inject, args: [AAP_CONFIG,] },] },
]; };
var AuthModule = /** @class */ (function () {
function AuthModule(parentModule) {
if (parentModule) {
throw new Error('AuthModule is already loaded. It should only be imported in your application\'s main module.');
}
}
AuthModule.forRoot = function (options) {
return {
ngModule: AuthModule,
providers: [
TokenService,
{
provide: AAP_CONFIG,
useValue: options ? options : DEFAULT_CONF
},
AuthService
]
};
};
return AuthModule;
}());
AuthModule.decorators = [
{ type: NgModule, args: [{},] },
];
AuthModule.ctorParameters = function () { return [
{ type: AuthModule, decorators: [{ type: Optional }, { type: SkipSelf },] },
]; };
export { AuthModule, AuthService, TokenService, AAP_CONFIG as ɵb, DEFAULT_CONF as ɵf, getToken as ɵc, removeToken as ɵd, updateToken as ɵe };
//# sourceMappingURL=angular-aap-auth.js.map
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW5ndWxhci1hYXAtYXV0aC5qcyIsInNvdXJjZVJvb3QiOiJuZzovL2FuZ3VsYXItYWFwLWF1dGgvIiwic291cmNlcyI6WyJhbmd1bGFyLWFhcC1hdXRoLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFJQSxzREFBYyxjQUFjLENBQUM7QUFFN0IsT0FBTyxFQUFDLFVBQVUsSUFBSSxFQUFFLEVBQWtCLFlBQVksSUFBSSxFQUFFLEVBQUMsUUFBUSxJQUFJLEVBQUUsRUFBQyxXQUFXLElBQUksRUFBRSxFQUFDLFdBQVcsSUFBSSxFQUFFLEVBQUMsTUFBTSxnQ0FBZ0MsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogR2VuZXJhdGVkIGJ1bmRsZSBpbmRleC4gRG8gbm90IGVkaXQuXG4gKi9cblxuZXhwb3J0ICogZnJvbSAnLi9wdWJsaWNfYXBpJztcblxuZXhwb3J0IHtBQVBfQ09ORklHIGFzIMm1YixBdXRoQ29uZmlnIGFzIMm1YSxERUZBVUxUX0NPTkYgYXMgybVmLGdldFRva2VuIGFzIMm1YyxyZW1vdmVUb2tlbiBhcyDJtWQsdXBkYXRlVG9rZW4gYXMgybVlfSBmcm9tICcuL2FwcC9tb2R1bGVzL2F1dGgvYXV0aC5jb25maWcnOyJdfQ==
{
"name": "angular-aap-auth",
"version": "1.0.0-alpha.10",
"version": "1.0.0-alpha.11",
"license": "Apache-2.0",

@@ -31,30 +31,30 @@ "private": false,

"devDependencies": {
"@angular-devkit/build-angular": "~0.6.1",
"@angular/cli": "6.0.1",
"@angular/common": "6.0.2",
"@angular/compiler": "6.0.2",
"@angular/compiler-cli": "6.0.2",
"@angular/core": "6.0.2",
"@angular/language-service": "6.0.2",
"@angular/platform-browser": "6.0.2",
"@angular/platform-browser-dynamic": "6.0.2",
"@angular-devkit/build-angular": "~0.6.8",
"@angular/cli": "6.0.8",
"@angular/common": "6.0.5",
"@angular/compiler": "6.0.5",
"@angular/compiler-cli": "6.0.5",
"@angular/core": "6.0.5",
"@angular/language-service": "6.0.5",
"@angular/platform-browser": "6.0.5",
"@angular/platform-browser-dynamic": "6.0.5",
"@auth0/angular-jwt": "^2.0.0",
"@types/jasmine": "~2.8.7",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~10.1.0",
"@types/node": "~10.3.4",
"codelyzer": "^4.3.0",
"core-js": "^2.5.6",
"core-js": "^2.5.7",
"jasmine-core": "^3.1.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.2",
"karma": "~2.0.3",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^1.4.2",
"karma-coverage-istanbul-reporter": "^2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^1.1.0",
"ng-packagr": "^2.4.4",
"ng-packagr": "^3.0.3",
"npm-check-updates": "^2.14.2",
"protractor": "~5.3.2",
"rxjs": "^6.1.0",
"rxjs-tslint-rules": "^4.2.0",
"ts-node": "~6.0.3",
"rxjs": "^6.2.1",
"rxjs-tslint-rules": "^4.4.2",
"ts-node": "~6.1.1",
"tslint": "~5.10.0",

@@ -66,6 +66,11 @@ "typedoc": "^0.11.1",

"main": "bundles/angular-aap-auth.umd.js",
"module": "esm5/angular-aap-auth.js",
"es2015": "esm2015/angular-aap-auth.js",
"module": "fesm5/angular-aap-auth.js",
"es2015": "fesm2015/angular-aap-auth.js",
"esm5": "esm5/angular-aap-auth.js",
"esm2015": "esm2015/angular-aap-auth.js",
"fesm5": "fesm5/angular-aap-auth.js",
"fesm2015": "fesm2015/angular-aap-auth.js",
"typings": "angular-aap-auth.d.ts",
"metadata": "angular-aap-auth.metadata.json"
"metadata": "angular-aap-auth.metadata.json",
"sideEffects": false
}

@@ -40,8 +40,12 @@ # angular-aap-auth

import {
AppComponent
} from './app.component';
import {
AuthModule
} from 'angular-aap-auth';
import {
JwtModule
} from '@auth0/angular-jwt';
import {
AppComponent
} from './app.component';
@NgModule({

@@ -53,6 +57,6 @@ declarations: [

BrowserModule,
AuthModule.forRoot(),
JwtModuld.forRoot({
AuthModule.forRoot(), // Defaults to localStorage `id_token` key.
JwtModule.forRoot({
config: {
tokenGetter: () => localStorage.getItem( 'id_token')
tokenGetter: () => localStorage.getItem('id_token')
}

@@ -79,3 +83,3 @@ })

Observable,
} from 'rxjs/Observable';
} from 'rxjs';

@@ -130,3 +134,3 @@ import {

Observable,
} from 'rxjs/Observable';
} from 'rxjs';
import {

@@ -197,2 +201,5 @@ map

} from 'angular-aap-auth';
import {
JwtModule
} from '@auth0/angular-jwt';

@@ -222,3 +229,3 @@ export function getToken(): string {

}),
JwtModuld.forRoot({
JwtModule.forRoot({
config: {

@@ -244,3 +251,3 @@ tokenGetter: getToken,

Observable,
} from 'rxjs/Observable';
} from 'Observable';
import {

@@ -247,0 +254,0 @@ map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc