bc-adal-angular
Version:
Library wrapper for Angular 6+, development over Microsoft ADAL (Azure Active Directory Authentication Library) - [https://github.com/AzureAD/azure-activedirectory-library-for-js](https://github.com/AzureAD/azure-activedirectory-library-for-js) that helps
2 lines • 3.86 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("adal-angular"),require("rxjs"),require("rxjs/operators"),require("@angular/router"),require("rxjs/internal/operators/mergeMap"),require("@angular/common"),require("@angular/common/http")):"function"==typeof define&&define.amd?define("bc-adal-angular",["exports","@angular/core","adal-angular","rxjs","rxjs/operators","@angular/router","rxjs/internal/operators/mergeMap","@angular/common","@angular/common/http"],t):t(e["bc-adal-angular"]={},e.ng.core,e.AuthenticationContext,e.rxjs,e.rxjs.operators,e.ng.router,e.rxjs["internal/operators/mergeMap"],e.ng.common,e.ng.common.http)}(this,function(e,r,t,n,o,i,a,u,c){"use strict";var s=new r.InjectionToken("bc.adal.angular.options"),p=function(){function e(e){this.adalOptions=e,this.setOptions(e),this.initAuthenticationContext()}return e.prototype.login=function(){this.context.login()},e.prototype.logout=function(){this.context.logOut()},e.prototype.getOptions=function(){return this.options},e.prototype.setOptions=function(e){this.options=e},Object.defineProperty(e.prototype,"authContext",{get:function(){return this.context},enumerable:!0,configurable:!0}),e.prototype.handleWindowCallback=function(){this.context.handleWindowCallback()},Object.defineProperty(e.prototype,"userInfo",{get:function(){return this.context.getCachedUser()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"accessToken",{get:function(){return this.context.getCachedToken(this.options.clientId)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isAuthenticated",{get:function(){return this.userInfo&&this.accessToken},enumerable:!0,configurable:!0}),e.prototype.getResourceForEndpoint=function(e){return this.context.getResourceForEndpoint(e)},e.prototype.isCallback=function(e){return this.context.isCallback(e)},e.prototype.getLoginError=function(){return this.context.getLoginError()},e.prototype.getAccessToken=function(e,t){return this.context.acquireToken(e,t)},e.prototype.acquireTokenResilient=function(e){var t=this;return new n.Observable(function(r){return t.context.acquireToken(e,function(e,t){t?r.next(t):r.error(e)})}).pipe(o.retry(3))},e.prototype.initAuthenticationContext=function(){this.context=new t(this.options)},e.decorators=[{type:r.Injectable}],e.ctorParameters=function(){return[{type:undefined,decorators:[{type:r.Inject,args:[s]}]}]},e}(),l=function(){function e(e,t){this.router=e,this.adalService=t}return e.prototype.canActivate=function(e,t){var r={queryParams:{redirectUrl:e.url}};return!!this.adalService.userInfo||(this.router.navigate(["accessdenied"],r),!1)},e.decorators=[{type:r.Injectable}],e.ctorParameters=function(){return[{type:i.Router},{type:p}]},e}(),d=function(){function e(e){this.adalService=e}return e.prototype.intercept=function(r,n){var e=this.adalService.getOptions().resource||this.adalService.getResourceForEndpoint(r.url);if(!e)return n.handle(r);if(!this.adalService.isAuthenticated)throw new Error("Cannot send request to registered endpoint if the user is not authenticated.");return this.adalService.acquireTokenResilient(e).pipe(a.mergeMap(function(e){if(!e)return n.handle(r);var t=r.clone({headers:r.headers.set("Authorization","Bearer "+e)});return n.handle(t)}))},e.decorators=[{type:r.Injectable}],e.ctorParameters=function(){return[{type:p}]},e}(),f=function(){function t(){}return t.forRoot=function(e){return{ngModule:t,providers:[p,l,{provide:c.HTTP_INTERCEPTORS,useClass:d,multi:!0},{provide:s,useValue:e}]}},t.decorators=[{type:r.NgModule,args:[{imports:[u.CommonModule,c.HttpClientModule],declarations:[]}]}],t}();e.BcAdalAngularService=p,e.AdalAccessGuard=l,e.BcAdalAngularModule=f,e.ɵb=s,e.ɵc=d,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=bc-adal-angular.umd.min.js.map