@azure/msal-angular
Advanced tools
Comparing version 1.1.2 to 2.0.0-alpha.0
/** | ||
* Generated bundle index. Do not edit. | ||
*/ | ||
export * from './public_api'; | ||
export { defaultMsalAngularConfiguration as ɵa } from './src/msal-angular.configuration'; | ||
export * from './public-api'; |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":4,"metadata":{"BroadcastService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":11,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor"}],"broadcast":[{"__symbolic":"method"}],"getMSALSubject":[{"__symbolic":"method"}],"getMSALItem":[{"__symbolic":"method"}],"subscribe":[{"__symbolic":"method"}]}},"MsalService":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"msal","name":"UserAgentApplication","line":36,"character":33},"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":35,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":39,"character":9},"arguments":[{"__symbolic":"reference","name":"MSAL_CONFIG"}]}],[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":40,"character":9},"arguments":[{"__symbolic":"reference","name":"MSAL_CONFIG_ANGULAR"}]}],null,null],"parameters":[{"__symbolic":"reference","module":"msal","name":"Configuration","line":39,"character":49},{"__symbolic":"reference","name":"MsalAngularConfiguration"},{"__symbolic":"reference","module":"@angular/router","name":"Router","line":41,"character":24},{"__symbolic":"reference","name":"BroadcastService"}]}],"loginPopup":[{"__symbolic":"method"}],"ssoSilent":[{"__symbolic":"method"}],"acquireTokenSilent":[{"__symbolic":"method"}],"acquireTokenPopup":[{"__symbolic":"method"}],"handleRedirectCallback":[{"__symbolic":"method"},{"__symbolic":"method"},{"__symbolic":"method"}],"clearCacheForScope":[{"__symbolic":"method"}],"getScopesForEndpoint":[{"__symbolic":"method"}]}},"MsalGuard":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":18,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":22,"character":9},"arguments":[{"__symbolic":"reference","name":"MSAL_CONFIG"}]}],[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":23,"character":9},"arguments":[{"__symbolic":"reference","name":"MSAL_CONFIG_ANGULAR"}]}],null,null,null,null,null,null],"parameters":[{"__symbolic":"reference","module":"msal","name":"Configuration","line":22,"character":49},{"__symbolic":"reference","name":"MsalAngularConfiguration"},{"__symbolic":"reference","name":"MsalService"},{"__symbolic":"reference","module":"@angular/router","name":"Router","line":25,"character":24},{"__symbolic":"reference","module":"@angular/router","name":"ActivatedRoute","line":26,"character":32},{"__symbolic":"reference","module":"@angular/common","name":"Location","line":27,"character":26},{"__symbolic":"reference","module":"@angular/common","name":"PlatformLocation","line":28,"character":34},{"__symbolic":"reference","name":"BroadcastService"}]}],"getDestinationUrl":[{"__symbolic":"method"}],"loginInteractively":[{"__symbolic":"method"}],"canActivate":[{"__symbolic":"method"}]}},"MsalInterceptor":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":21,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"MsalService"},{"__symbolic":"reference","name":"BroadcastService"}]}],"intercept":[{"__symbolic":"method"}]}},"MsalModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":14,"character":1},"arguments":[{"imports":[{"__symbolic":"reference","module":"@angular/common","name":"CommonModule","line":15,"character":14}],"declarations":[],"providers":[{"__symbolic":"reference","name":"MsalGuard"},{"__symbolic":"reference","name":"BroadcastService"}]}]}],"members":{},"statics":{"forRoot":{"__symbolic":"function","parameters":["config","angularConfig"],"defaults":[null,{"__symbolic":"reference","name":"ɵa"}],"value":{"ngModule":{"__symbolic":"reference","name":"MsalModule"},"providers":[{"provide":{"__symbolic":"reference","name":"MSAL_CONFIG"},"useValue":{"__symbolic":"reference","name":"config"}},{"provide":{"__symbolic":"reference","name":"MSAL_CONFIG_ANGULAR"},"useValue":{"__symbolic":"reference","name":"angularConfig"}},{"__symbolic":"reference","name":"MsalService"}]}}}},"ɵa":{"consentScopes":[],"popUp":false,"extraQueryParameters":{},"unprotectedResources":[],"protectedResourceMap":[]},"MsalAngularConfiguration":{"__symbolic":"interface"},"MSAL_CONFIG":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":7,"character":31},"arguments":["MSAL_CONFIG"]},"MSAL_CONFIG_ANGULAR":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":8,"character":39},"arguments":["MSAL_CONFIG_ANGULAR"]}},"origins":{"BroadcastService":"./src/broadcast.service","MsalService":"./src/msal.service","MsalGuard":"./src/msal-guard.service","MsalInterceptor":"./src/msal.interceptor","MsalModule":"./src/msal.module","ɵa":"./src/msal-angular.configuration","MsalAngularConfiguration":"./src/msal-angular.configuration","MSAL_CONFIG":"./src/constants","MSAL_CONFIG_ANGULAR":"./src/constants"},"importAs":"@azure/msal-angular"} | ||
{"__symbolic":"module","version":4,"metadata":{"MsalService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":19,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":24,"character":9},"arguments":[{"__symbolic":"reference","name":"MSAL_INSTANCE"}]}],null],"parameters":[{"__symbolic":"reference","module":"@azure/msal-browser","name":"IPublicClientApplication","line":24,"character":48},{"__symbolic":"reference","module":"@angular/common","name":"Location","line":25,"character":26}]}],"acquireTokenPopup":[{"__symbolic":"method"}],"acquireTokenRedirect":[{"__symbolic":"method"}],"acquireTokenSilent":[{"__symbolic":"method"}],"handleRedirectObservable":[{"__symbolic":"method"}],"loginPopup":[{"__symbolic":"method"}],"loginRedirect":[{"__symbolic":"method"}],"logout":[{"__symbolic":"method"}],"ssoSilent":[{"__symbolic":"method"}]}},"IMsalService":{"__symbolic":"interface"},"MsalGuard":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":15,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":18,"character":9},"arguments":[{"__symbolic":"reference","name":"MSAL_GUARD_CONFIG"}]}],null,null],"parameters":[{"__symbolic":"reference","name":"MsalGuardConfiguration"},{"__symbolic":"reference","name":"MsalService"},{"__symbolic":"reference","module":"@angular/common","name":"Location","line":20,"character":26}]}],"getDestinationUrl":[{"__symbolic":"method"}],"loginInteractively":[{"__symbolic":"method"}],"canActivate":[{"__symbolic":"method"}]}},"MsalGuardConfiguration":{"__symbolic":"interface"},"MsalInterceptor":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":20,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":23,"character":9},"arguments":[{"__symbolic":"reference","name":"MSAL_INTERCEPTOR_CONFIG"}]}],null],"parameters":[{"__symbolic":"reference","name":"MsalInterceptorConfiguration"},{"__symbolic":"reference","name":"MsalService"}]}],"intercept":[{"__symbolic":"method"}],"getScopesForEndpoint":[{"__symbolic":"method"}]}},"MsalInterceptorConfiguration":{"__symbolic":"interface"},"MSAL_INSTANCE":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":7,"character":33},"arguments":["MSAL_INSTANCE"]},"MSAL_GUARD_CONFIG":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":9,"character":37},"arguments":["MSAL_GUARD_CONFIG"]},"MSAL_INTERCEPTOR_CONFIG":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":11,"character":43},"arguments":["MSAL_INTERCEPTOR_CONFIG"]},"MsalBroadcastService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":10,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":16,"character":9},"arguments":[{"__symbolic":"reference","name":"MSAL_INSTANCE"}]}]],"parameters":[{"__symbolic":"reference","module":"@azure/msal-browser","name":"IPublicClientApplication","line":16,"character":53}]}]}},"MsalModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":15,"character":1},"arguments":[{"declarations":[],"imports":[{"__symbolic":"reference","module":"@angular/common","name":"CommonModule","line":18,"character":8}],"providers":[{"__symbolic":"reference","name":"MsalGuard"},{"__symbolic":"reference","name":"MsalBroadcastService"}]}]}],"members":{},"statics":{"forRoot":{"__symbolic":"function","parameters":["msalInstance","guardConfig","interceptorConfig"],"value":{"ngModule":{"__symbolic":"reference","name":"MsalModule"},"providers":[{"provide":{"__symbolic":"reference","name":"MSAL_INSTANCE"},"useValue":{"__symbolic":"reference","name":"msalInstance"}},{"provide":{"__symbolic":"reference","name":"MSAL_GUARD_CONFIG"},"useValue":{"__symbolic":"reference","name":"guardConfig"}},{"provide":{"__symbolic":"reference","name":"MSAL_INTERCEPTOR_CONFIG"},"useValue":{"__symbolic":"reference","name":"interceptorConfig"}},{"__symbolic":"reference","name":"MsalService"}]}}}}},"origins":{"MsalService":"./msal.service","IMsalService":"./IMsalService","MsalGuard":"./msal.guard","MsalGuardConfiguration":"./msal.guard.config","MsalInterceptor":"./msal.interceptor","MsalInterceptorConfiguration":"./msal.interceptor.config","MSAL_INSTANCE":"./constants","MSAL_GUARD_CONFIG":"./constants","MSAL_INTERCEPTOR_CONFIG":"./constants","MsalBroadcastService":"./msal.broadcast.service","MsalModule":"./msal.module"},"importAs":"@azure/msal-angular"} |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('rxjs/operators'), require('msal'), require('@angular/router'), require('minimatch'), require('@angular/common'), require('@angular/common/http')) : | ||
typeof define === 'function' && define.amd ? define('@azure/msal-angular', ['exports', '@angular/core', 'rxjs', 'rxjs/operators', 'msal', '@angular/router', 'minimatch', '@angular/common', '@angular/common/http'], factory) : | ||
(global = global || self, factory((global.azure = global.azure || {}, global.azure['msal-angular'] = {}), global.ng.core, global.rxjs, global.rxjs.operators, global.msal, global.ng.router, global.minimatch, global.ng.common, global.ng.common.http)); | ||
}(this, (function (exports, core, rxjs, operators, msal, router, minimatch, common, http) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('rxjs'), require('@azure/msal-browser'), require('rxjs/operators'), require('minimatch')) : | ||
typeof define === 'function' && define.amd ? define('@azure/msal-angular', ['exports', '@angular/core', '@angular/common', 'rxjs', '@azure/msal-browser', 'rxjs/operators', 'minimatch'], factory) : | ||
(global = global || self, factory((global.azure = global.azure || {}, global.azure['msal-angular'] = {}), global.ng.core, global.ng.common, global.rxjs, global['@azure/msal-browser'], global.rxjs.operators, global.minimatch)); | ||
}(this, (function (exports, core, common, rxjs, msalBrowser, operators, minimatch) { 'use strict'; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
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 | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
***************************************************************************** */ | ||
/* global Reflect, Promise */ | ||
var extendStatics = function(d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
function __extends(d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
} | ||
var __assign = function() { | ||
__assign = Object.assign || function __assign(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
function __rest(s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
} | ||
function __decorate(decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
} | ||
function __param(paramIndex, decorator) { | ||
return function (target, key) { decorator(target, key, paramIndex); } | ||
} | ||
function __metadata(metadataKey, metadataValue) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); | ||
} | ||
function __awaiter(thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
} | ||
function __generator(thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
} | ||
function __exportStar(m, exports) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
function __values(o) { | ||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
if (m) return m.call(o); | ||
if (o && typeof o.length === "number") return { | ||
next: function () { | ||
if (o && i >= o.length) o = void 0; | ||
return { value: o && o[i++], done: !o }; | ||
} | ||
}; | ||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | ||
} | ||
function __read(o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
} | ||
function __spread() { | ||
for (var ar = [], i = 0; i < arguments.length; i++) | ||
ar = ar.concat(__read(arguments[i])); | ||
return ar; | ||
} | ||
function __spreadArrays() { | ||
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; | ||
for (var r = Array(s), k = 0, i = 0; i < il; i++) | ||
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) | ||
r[k] = a[j]; | ||
return r; | ||
}; | ||
function __await(v) { | ||
return this instanceof __await ? (this.v = v, this) : new __await(v); | ||
} | ||
function __asyncGenerator(thisArg, _arguments, generator) { | ||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); | ||
var g = generator.apply(thisArg, _arguments || []), i, q = []; | ||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; | ||
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } | ||
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } | ||
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } | ||
function fulfill(value) { resume("next", value); } | ||
function reject(value) { resume("throw", value); } | ||
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } | ||
} | ||
function __asyncDelegator(o) { | ||
var i, p; | ||
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; | ||
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } | ||
} | ||
function __asyncValues(o) { | ||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); | ||
var m = o[Symbol.asyncIterator], i; | ||
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); | ||
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } | ||
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } | ||
} | ||
function __makeTemplateObject(cooked, raw) { | ||
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } | ||
return cooked; | ||
}; | ||
function __importStar(mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result.default = mod; | ||
return result; | ||
} | ||
function __importDefault(mod) { | ||
return (mod && mod.__esModule) ? mod : { default: mod }; | ||
} | ||
function __classPrivateFieldGet(receiver, privateMap) { | ||
if (!privateMap.has(receiver)) { | ||
throw new TypeError("attempted to get private field on non-instance"); | ||
} | ||
return privateMap.get(receiver); | ||
} | ||
function __classPrivateFieldSet(receiver, privateMap, value) { | ||
if (!privateMap.has(receiver)) { | ||
throw new TypeError("attempted to set private field on non-instance"); | ||
} | ||
privateMap.set(receiver, value); | ||
return value; | ||
} | ||
/* | ||
@@ -225,26 +11,5 @@ * Copyright (c) Microsoft Corporation. All rights reserved. | ||
*/ | ||
var BroadcastService = /** @class */ (function () { | ||
function BroadcastService() { | ||
this._msalSubject = new rxjs.BehaviorSubject(1); | ||
this.msalItem$ = this._msalSubject.asObservable(); | ||
} | ||
BroadcastService.prototype.broadcast = function (type, payload) { | ||
this._msalSubject.next({ type: type, payload: payload }); | ||
}; | ||
BroadcastService.prototype.getMSALSubject = function () { | ||
return this._msalSubject; | ||
}; | ||
BroadcastService.prototype.getMSALItem = function () { | ||
return this.msalItem$; | ||
}; | ||
BroadcastService.prototype.subscribe = function (type, callback) { | ||
return this.msalItem$ | ||
.pipe(operators.filter(function (message) { return message.type === type; }), operators.map(function (message) { return message.payload; })) | ||
.subscribe(callback); | ||
}; | ||
BroadcastService = __decorate([ | ||
core.Injectable() | ||
], BroadcastService); | ||
return BroadcastService; | ||
}()); | ||
var MSAL_INSTANCE = new core.InjectionToken("MSAL_INSTANCE"); | ||
var MSAL_GUARD_CONFIG = new core.InjectionToken("MSAL_GUARD_CONFIG"); | ||
var MSAL_INTERCEPTOR_CONFIG = new core.InjectionToken("MSAL_INTERCEPTOR_CONFIG"); | ||
@@ -255,234 +20,46 @@ /* | ||
*/ | ||
var MSALError = /** @class */ (function () { | ||
function MSALError(error, errorDesc, scopes) { | ||
this._error = ""; | ||
this._errorDesc = ""; | ||
this._scopes = ""; | ||
this._error = error; | ||
if (errorDesc) { | ||
this._errorDesc = errorDesc; | ||
var MsalService = /** @class */ (function () { | ||
function MsalService(instance, location) { | ||
this.instance = instance; | ||
this.location = location; | ||
var hash = this.location.path(true).split("#").pop(); | ||
if (hash) { | ||
this.redirectHash = "#" + hash; | ||
} | ||
if (scopes) { | ||
this._scopes = scopes; | ||
} | ||
} | ||
Object.defineProperty(MSALError.prototype, "error", { | ||
get: function () { | ||
return this._error; | ||
}, | ||
set: function (value) { | ||
this._error = value; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(MSALError.prototype, "errorDesc", { | ||
get: function () { | ||
return this._errorDesc; | ||
}, | ||
set: function (value) { | ||
this._errorDesc = value; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(MSALError.prototype, "scopes", { | ||
get: function () { | ||
return this._scopes; | ||
}, | ||
set: function (value) { | ||
this._scopes = value; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return MSALError; | ||
}()); | ||
/* | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
var MSAL_CONFIG = new core.InjectionToken("MSAL_CONFIG"); | ||
var MSAL_CONFIG_ANGULAR = new core.InjectionToken("MSAL_CONFIG_ANGULAR"); | ||
/* | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
var buildMsalConfig = function (config) { | ||
return __assign(__assign({}, config), { framework: __assign(__assign({}, config.framework), { isAngular: true }) }); | ||
}; | ||
var ɵ0 = buildMsalConfig; | ||
var MsalService = /** @class */ (function (_super) { | ||
__extends(MsalService, _super); | ||
function MsalService(msalConfig, msalAngularConfig, router, broadcastService) { | ||
var _this = _super.call(this, buildMsalConfig(msalConfig)) || this; | ||
_this.msalConfig = msalConfig; | ||
_this.msalAngularConfig = msalAngularConfig; | ||
_this.router = router; | ||
_this.broadcastService = broadcastService; | ||
window.addEventListener("msal:popUpHashChanged", function () { | ||
_this.getLogger().verbose("popUpHashChanged "); | ||
}); | ||
window.addEventListener("msal:popUpClosed", function (e) { | ||
var errorParts = e.detail.split("|"); | ||
var msalError = new MSALError(errorParts[0], errorParts[1]); | ||
if (_this.getLoginInProgress()) { | ||
broadcastService.broadcast("msal:loginFailure", msalError); | ||
_this.setloginInProgress(false); | ||
} | ||
else if (_this.getAcquireTokenInProgress()) { | ||
broadcastService.broadcast("msal:acquireTokenFailure", msalError); | ||
_this.setAcquireTokenInProgress(false); | ||
} | ||
}); | ||
return _this; | ||
} | ||
MsalService.prototype.loginPopup = function (request) { | ||
var _this = this; | ||
return _super.prototype.loginPopup.call(this, request) | ||
.then(function (authResponse) { | ||
_this.broadcastService.broadcast("msal:loginSuccess", authResponse); | ||
return authResponse; | ||
}) | ||
.catch(function (error) { | ||
_this.broadcastService.broadcast("msal:loginFailure", error); | ||
_this.getLogger().error("Error during login:\n" + error.errorMessage); | ||
throw error; | ||
}); | ||
MsalService.prototype.acquireTokenPopup = function (request) { | ||
return rxjs.from(this.instance.acquireTokenPopup(request)); | ||
}; | ||
MsalService.prototype.ssoSilent = function (request) { | ||
var _this = this; | ||
return _super.prototype.ssoSilent.call(this, request) | ||
.then(function (authResponse) { | ||
_this.broadcastService.broadcast("msal:ssoSuccess", authResponse); | ||
return authResponse; | ||
}) | ||
.catch(function (error) { | ||
_this.broadcastService.broadcast("msal:ssoFailure", error); | ||
_this.getLogger().error("Error during login:\n" + error.errorMessage); | ||
throw error; | ||
}); | ||
MsalService.prototype.acquireTokenRedirect = function (request) { | ||
return rxjs.from(this.instance.acquireTokenRedirect(request)); | ||
}; | ||
MsalService.prototype.acquireTokenSilent = function (request) { | ||
var _this = this; | ||
return _super.prototype.acquireTokenSilent.call(this, request) | ||
.then(function (authResponse) { | ||
_this.broadcastService.broadcast("msal:acquireTokenSuccess", authResponse); | ||
return authResponse; | ||
}) | ||
.catch(function (error) { | ||
_this.broadcastService.broadcast("msal:acquireTokenFailure", error); | ||
_this.getLogger().error("Error when acquiring token for scopes: " + request.scopes + " " + error); | ||
throw error; | ||
}); | ||
MsalService.prototype.acquireTokenSilent = function (silentRequest) { | ||
return rxjs.from(this.instance.acquireTokenSilent(silentRequest)); | ||
}; | ||
MsalService.prototype.acquireTokenPopup = function (request) { | ||
var _this = this; | ||
return _super.prototype.acquireTokenPopup.call(this, request) | ||
.then(function (authResponse) { | ||
_this.broadcastService.broadcast("msal:acquireTokenSuccess", authResponse); | ||
return authResponse; | ||
}) | ||
.catch(function (error) { | ||
_this.broadcastService.broadcast("msal:acquireTokenFailure", error); | ||
_this.getLogger().error("Error when acquiring token for scopes : " + request.scopes + " " + error); | ||
throw error; | ||
}); | ||
MsalService.prototype.handleRedirectObservable = function () { | ||
var handleRedirect = rxjs.from(this.instance.handleRedirectPromise(this.redirectHash)); | ||
this.redirectHash = ""; | ||
return handleRedirect; | ||
}; | ||
MsalService.prototype.handleRedirectCallback = function (authOrTokenCallback, errorReceivedCallback) { | ||
var _this = this; | ||
_super.prototype.handleRedirectCallback.call(this, function (authError, authResponse) { | ||
if (authError) { | ||
if (!_this.getAccount()) { | ||
_this.broadcastService.broadcast("msal:loginFailure", authError); | ||
} | ||
else { | ||
_this.broadcastService.broadcast("msal:acquireTokenFailure", authError); | ||
} | ||
if (errorReceivedCallback) { | ||
errorReceivedCallback(authError, authResponse.accountState); | ||
} | ||
else { | ||
authOrTokenCallback(authError, authResponse); | ||
} | ||
} | ||
else if (authResponse) { | ||
if (authResponse.tokenType === "id_token") { | ||
_this.broadcastService.broadcast("msal:loginSuccess", authResponse); | ||
} | ||
else { | ||
_this.broadcastService.broadcast("msal:acquireTokenSuccess", authResponse); | ||
} | ||
if (errorReceivedCallback) { | ||
authOrTokenCallback(authResponse); | ||
} | ||
else { | ||
authOrTokenCallback(null, authResponse); | ||
} | ||
} | ||
}); | ||
MsalService.prototype.loginPopup = function (request) { | ||
return rxjs.from(this.instance.loginPopup(request)); | ||
}; | ||
MsalService.prototype.clearCacheForScope = function (accessToken) { | ||
return _super.prototype.clearCacheForScope.call(this, accessToken); | ||
MsalService.prototype.loginRedirect = function (request) { | ||
return rxjs.from(this.instance.loginRedirect(request)); | ||
}; | ||
MsalService.prototype.getScopesForEndpoint = function (endpoint) { | ||
if ((this.msalConfig.framework && this.msalConfig.framework.unprotectedResources) || (this.msalAngularConfig && this.msalAngularConfig.unprotectedResources)) { | ||
this.getLogger().info("unprotectedResources is deprecated and ignored. msalAngularConfig.protectedResourceMap now supports glob patterns"); | ||
} | ||
var frameworkProtectedResourceMap = this.msalConfig.framework && this.msalConfig.framework.protectedResourceMap; | ||
if (frameworkProtectedResourceMap) { | ||
this.getLogger().info("msalConfig.framework.protectedResourceMap is deprecated, use msalAngularConfig.protectedResourceMap"); | ||
} | ||
var protectedResourceMap = frameworkProtectedResourceMap && frameworkProtectedResourceMap.size ? frameworkProtectedResourceMap : new Map(this.msalAngularConfig.protectedResourceMap); | ||
var protectedResourcesArray = Array.from(protectedResourceMap.keys()); | ||
var keyMatchesEndpointArray = protectedResourcesArray.filter(function (key) { | ||
var minimatch$1 = new minimatch.Minimatch(key); | ||
return minimatch$1.match(endpoint) || endpoint.indexOf(key) > -1; | ||
}); | ||
// process all protected resources and send the first matched resource | ||
if (keyMatchesEndpointArray.length > 0) { | ||
if (keyMatchesEndpointArray.length > 1) { | ||
this.getLogger().warning("Multiple entries in protectedResourceMap found for resource. Using first entry."); | ||
this.getLogger().warningPii("Multiple entries found for: " + endpoint); | ||
} | ||
var keyForEndpoint = keyMatchesEndpointArray[0]; | ||
if (keyForEndpoint) { | ||
return protectedResourceMap.get(keyForEndpoint); | ||
} | ||
} | ||
/* | ||
* default resource will be clientid if nothing specified | ||
* App will use idtoken for calls to itself | ||
* check if it's staring from http or https, needs to match with app host | ||
*/ | ||
if (endpoint.indexOf("http://") > -1 || endpoint.indexOf("https://") > -1) { | ||
if (msal.UrlUtils.getHostFromUri(endpoint) === msal.UrlUtils.getHostFromUri(_super.prototype.getRedirectUri.call(this))) { | ||
return new Array(this.msalConfig.auth.clientId); | ||
} | ||
} | ||
else { | ||
/* | ||
* in angular level, the url for $http interceptor call could be relative url, | ||
* if it's relative call, we'll treat it as app backend call. | ||
*/ | ||
return new Array(this.msalConfig.auth.clientId); | ||
} | ||
// if not the app's own backend or not a domain listed in the endpoints structure | ||
return null; | ||
MsalService.prototype.logout = function (logoutRequest) { | ||
return rxjs.from(this.instance.logout(logoutRequest)); | ||
}; | ||
MsalService.ctorParameters = function () { return [ | ||
{ type: undefined, decorators: [{ type: core.Inject, args: [MSAL_CONFIG,] }] }, | ||
{ type: undefined, decorators: [{ type: core.Inject, args: [MSAL_CONFIG_ANGULAR,] }] }, | ||
{ type: router.Router }, | ||
{ type: BroadcastService } | ||
]; }; | ||
MsalService = __decorate([ | ||
core.Injectable(), | ||
__param(0, core.Inject(MSAL_CONFIG)), | ||
__param(1, core.Inject(MSAL_CONFIG_ANGULAR)) | ||
], MsalService); | ||
MsalService.prototype.ssoSilent = function (request) { | ||
return rxjs.from(this.instance.ssoSilent(request)); | ||
}; | ||
return MsalService; | ||
}(msal.UserAgentApplication)); | ||
}()); | ||
MsalService.decorators = [ | ||
{ type: core.Injectable } | ||
]; | ||
MsalService.ctorParameters = function () { return [ | ||
{ type: undefined, decorators: [{ type: core.Inject, args: [MSAL_INSTANCE,] }] }, | ||
{ type: common.Location } | ||
]; }; | ||
@@ -494,11 +71,6 @@ /* | ||
var MsalGuard = /** @class */ (function () { | ||
function MsalGuard(msalConfig, msalAngularConfig, authService, router, activatedRoute, location, platformLocation, broadcastService) { | ||
this.msalConfig = msalConfig; | ||
this.msalAngularConfig = msalAngularConfig; | ||
function MsalGuard(msalGuardConfig, authService, location) { | ||
this.msalGuardConfig = msalGuardConfig; | ||
this.authService = authService; | ||
this.router = router; | ||
this.activatedRoute = activatedRoute; | ||
this.location = location; | ||
this.platformLocation = platformLocation; | ||
this.broadcastService = broadcastService; | ||
} | ||
@@ -526,72 +98,34 @@ /** | ||
}; | ||
/** | ||
* Interactively prompt the user to login | ||
* @param url Path of the requested page | ||
*/ | ||
MsalGuard.prototype.loginInteractively = function (url) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var redirectStartPage; | ||
return __generator(this, function (_a) { | ||
if (this.msalAngularConfig.popUp) { | ||
return [2 /*return*/, this.authService.loginPopup({ | ||
scopes: this.msalAngularConfig.consentScopes, | ||
extraQueryParameters: this.msalAngularConfig.extraQueryParameters | ||
}) | ||
.then(function () { return true; }) | ||
.catch(function () { return false; })]; | ||
} | ||
redirectStartPage = this.getDestinationUrl(url); | ||
this.authService.loginRedirect({ | ||
redirectStartPage: redirectStartPage, | ||
scopes: this.msalAngularConfig.consentScopes, | ||
extraQueryParameters: this.msalAngularConfig.extraQueryParameters | ||
}); | ||
return [2 /*return*/]; | ||
}); | ||
}); | ||
if (this.msalGuardConfig.interactionType === msalBrowser.InteractionType.Popup) { | ||
return this.authService.loginPopup(Object.assign({}, this.msalGuardConfig.authRequest)) | ||
.pipe(operators.map(function () { return true; }), operators.catchError(function () { return rxjs.of(false); })); | ||
} | ||
var redirectStartPage = this.getDestinationUrl(url); | ||
this.authService.loginRedirect(Object.assign({ redirectStartPage: redirectStartPage }, this.msalGuardConfig.authRequest)); | ||
return rxjs.of(false); | ||
}; | ||
MsalGuard.prototype.canActivate = function (route, state) { | ||
var _this = this; | ||
this.authService.getLogger().verbose("location change event from old url to new url"); | ||
/* | ||
* If a page with MSAL Guard is set as the redirect for acquireTokenSilent, | ||
* short-circuit to prevent redirecting or popups. | ||
*/ | ||
if (msal.UrlUtils.urlContainsHash(window.location.hash) && msal.WindowUtils.isInIframe()) { | ||
this.authService.getLogger().warning("redirectUri set to page with MSAL Guard. It is recommended to not set redirectUri to a page that requires authentication."); | ||
return false; | ||
if (this.msalGuardConfig.interactionType !== msalBrowser.InteractionType.Popup && this.msalGuardConfig.interactionType !== msalBrowser.InteractionType.Redirect) { | ||
throw new msalBrowser.BrowserConfigurationAuthError("invalid_interaction_type", "Invalid interaction type provided to MSAL Guard. InteractionType.Popup or InteractionType.Redirect must be provided in the MsalGuardConfiguration"); | ||
} | ||
if (!this.authService.getAccount()) { | ||
return this.loginInteractively(state.url); | ||
} | ||
return this.authService.acquireTokenSilent({ | ||
scopes: [this.msalConfig.auth.clientId] | ||
}) | ||
.then(function () { return true; }) | ||
.catch(function (error) { | ||
if (msal.InteractionRequiredAuthError.isInteractionRequiredError(error.errorCode)) { | ||
_this.authService.getLogger().info("Interaction required error in MSAL Guard, prompting for interaction."); | ||
return this.authService.handleRedirectObservable() | ||
.pipe(operators.concatMap(function () { | ||
if (!_this.authService.instance.getAllAccounts().length) { | ||
return _this.loginInteractively(state.url); | ||
} | ||
_this.authService.getLogger().error("Non-interaction error in MSAL Guard: " + error.errorMessage); | ||
throw error; | ||
}); | ||
return rxjs.of(true); | ||
}), operators.catchError(function () { return rxjs.of(false); })); | ||
}; | ||
MsalGuard.ctorParameters = function () { return [ | ||
{ type: undefined, decorators: [{ type: core.Inject, args: [MSAL_CONFIG,] }] }, | ||
{ type: undefined, decorators: [{ type: core.Inject, args: [MSAL_CONFIG_ANGULAR,] }] }, | ||
{ type: MsalService }, | ||
{ type: router.Router }, | ||
{ type: router.ActivatedRoute }, | ||
{ type: common.Location }, | ||
{ type: common.PlatformLocation }, | ||
{ type: BroadcastService } | ||
]; }; | ||
MsalGuard = __decorate([ | ||
core.Injectable(), | ||
__param(0, core.Inject(MSAL_CONFIG)), | ||
__param(1, core.Inject(MSAL_CONFIG_ANGULAR)) | ||
], MsalGuard); | ||
return MsalGuard; | ||
}()); | ||
MsalGuard.decorators = [ | ||
{ type: core.Injectable } | ||
]; | ||
MsalGuard.ctorParameters = function () { return [ | ||
{ type: undefined, decorators: [{ type: core.Inject, args: [MSAL_GUARD_CONFIG,] }] }, | ||
{ type: MsalService }, | ||
{ type: common.Location } | ||
]; }; | ||
@@ -603,42 +137,56 @@ /* | ||
var MsalInterceptor = /** @class */ (function () { | ||
function MsalInterceptor(auth, broadcastService) { | ||
this.auth = auth; | ||
this.broadcastService = broadcastService; | ||
function MsalInterceptor(msalInterceptorConfig, authService) { | ||
this.msalInterceptorConfig = msalInterceptorConfig; | ||
this.authService = authService; | ||
} | ||
MsalInterceptor.prototype.intercept = function (req, next) { | ||
var _this = this; | ||
var scopes = this.auth.getScopesForEndpoint(req.url); | ||
this.auth.getLogger().verbose("Url: " + req.url + " maps to scopes: " + scopes); | ||
// If there are no scopes set for this request, do nothing. | ||
if (!scopes) { | ||
if (this.msalInterceptorConfig.interactionType !== msalBrowser.InteractionType.Popup && this.msalInterceptorConfig.interactionType !== msalBrowser.InteractionType.Redirect) { | ||
throw new msalBrowser.BrowserConfigurationAuthError("invalid_interaction_type", "Invalid interaction type provided to MSAL Interceptor. InteractionType.Popup, InteractionType.Redirect or InteractionType.Silent must be provided in the msalInterceptorConfiguration"); | ||
} | ||
var scopes = this.getScopesForEndpoint(req.url); | ||
var account = this.authService.instance.getAllAccounts()[0]; | ||
if (!scopes || scopes.length === 0) { | ||
return next.handle(req); | ||
} | ||
var token; | ||
// Acquire a token for this request, and attach as proper auth header. | ||
return rxjs.from(this.auth.acquireTokenSilent({ scopes: scopes }) | ||
.then(function (response) { | ||
token = response.tokenType === msal.ServerHashParamKeys.ID_TOKEN ? response.idToken.rawIdToken : response.accessToken; | ||
var authHeader = "Bearer " + token; | ||
return req.clone({ | ||
setHeaders: { | ||
Authorization: authHeader, | ||
} | ||
}); | ||
})) | ||
.pipe(operators.mergeMap(function (nextReq) { return next.handle(nextReq); }), operators.tap(function () { }, function (err) { | ||
if (err instanceof http.HttpErrorResponse && err.status === 401) { | ||
_this.auth.clearCacheForScope(token); | ||
_this.broadcastService.broadcast("msal:notAuthorized", err.message); | ||
// Note: For MSA accounts, include openid scope when calling acquireTokenSilent to return idToken | ||
return this.authService.acquireTokenSilent(Object.assign(Object.assign({}, this.msalInterceptorConfig.authRequest), { scopes: scopes, account: account })) | ||
.pipe(operators.catchError(function () { | ||
if (_this.msalInterceptorConfig.interactionType === msalBrowser.InteractionType.Popup) { | ||
return _this.authService.acquireTokenPopup(Object.assign(Object.assign({}, _this.msalInterceptorConfig.authRequest), { scopes: scopes })); | ||
} | ||
var redirectStartPage = window.location.href; | ||
_this.authService.acquireTokenRedirect(Object.assign(Object.assign({}, _this.msalInterceptorConfig.authRequest), { scopes: scopes, redirectStartPage: redirectStartPage })); | ||
return rxjs.EMPTY; | ||
}), operators.switchMap(function (result) { | ||
var headers = req.headers | ||
.set("Authorization", "Bearer " + result.accessToken); | ||
var requestClone = req.clone({ headers: headers }); | ||
return next.handle(requestClone); | ||
})); | ||
}; | ||
MsalInterceptor.ctorParameters = function () { return [ | ||
{ type: MsalService }, | ||
{ type: BroadcastService } | ||
]; }; | ||
MsalInterceptor = __decorate([ | ||
core.Injectable() | ||
], MsalInterceptor); | ||
MsalInterceptor.prototype.getScopesForEndpoint = function (endpoint) { | ||
var protectedResourcesArray = Array.from(this.msalInterceptorConfig.protectedResourceMap.keys()); | ||
var keyMatchesEndpointArray = protectedResourcesArray.filter(function (key) { | ||
var minimatch$1 = new minimatch.Minimatch(key); | ||
return minimatch$1.match(endpoint) || endpoint.indexOf(key) > -1; | ||
}); | ||
// process all protected resources and send the first matched resource | ||
if (keyMatchesEndpointArray.length > 0) { | ||
var keyForEndpoint = keyMatchesEndpointArray[0]; | ||
if (keyForEndpoint) { | ||
return this.msalInterceptorConfig.protectedResourceMap.get(keyForEndpoint); | ||
} | ||
} | ||
return null; | ||
}; | ||
return MsalInterceptor; | ||
}()); | ||
MsalInterceptor.decorators = [ | ||
{ type: core.Injectable } | ||
]; | ||
MsalInterceptor.ctorParameters = function () { return [ | ||
{ type: undefined, decorators: [{ type: core.Inject, args: [MSAL_INTERCEPTOR_CONFIG,] }] }, | ||
{ type: MsalService } | ||
]; }; | ||
@@ -649,9 +197,20 @@ /* | ||
*/ | ||
var defaultMsalAngularConfiguration = { | ||
consentScopes: [], | ||
popUp: false, | ||
extraQueryParameters: {}, | ||
unprotectedResources: [], | ||
protectedResourceMap: [] | ||
}; | ||
var MsalBroadcastService = /** @class */ (function () { | ||
function MsalBroadcastService(msalInstance) { | ||
var _this = this; | ||
this.msalInstance = msalInstance; | ||
this._msalSubject = new rxjs.Subject(); | ||
this.msalSubject$ = this._msalSubject.asObservable(); | ||
this.msalInstance.addEventCallback(function (message) { | ||
_this._msalSubject.next(message); | ||
}); | ||
} | ||
return MsalBroadcastService; | ||
}()); | ||
MsalBroadcastService.decorators = [ | ||
{ type: core.Injectable } | ||
]; | ||
MsalBroadcastService.ctorParameters = function () { return [ | ||
{ type: undefined, decorators: [{ type: core.Inject, args: [MSAL_INSTANCE,] }] } | ||
]; }; | ||
@@ -665,16 +224,18 @@ /* | ||
} | ||
MsalModule_1 = MsalModule; | ||
MsalModule.forRoot = function (config, angularConfig) { | ||
if (angularConfig === void 0) { angularConfig = defaultMsalAngularConfiguration; } | ||
MsalModule.forRoot = function (msalInstance, guardConfig, interceptorConfig) { | ||
return { | ||
ngModule: MsalModule_1, | ||
ngModule: MsalModule, | ||
providers: [ | ||
{ | ||
provide: MSAL_CONFIG, | ||
useValue: config | ||
provide: MSAL_INSTANCE, | ||
useValue: msalInstance | ||
}, | ||
{ | ||
provide: MSAL_CONFIG_ANGULAR, | ||
useValue: angularConfig | ||
provide: MSAL_GUARD_CONFIG, | ||
useValue: guardConfig | ||
}, | ||
{ | ||
provide: MSAL_INTERCEPTOR_CONFIG, | ||
useValue: interceptorConfig | ||
}, | ||
MsalService | ||
@@ -684,16 +245,30 @@ ] | ||
}; | ||
var MsalModule_1; | ||
MsalModule = MsalModule_1 = __decorate([ | ||
core.NgModule({ | ||
imports: [common.CommonModule], | ||
declarations: [], | ||
providers: [MsalGuard, BroadcastService], | ||
}) | ||
], MsalModule); | ||
return MsalModule; | ||
}()); | ||
MsalModule.decorators = [ | ||
{ type: core.NgModule, args: [{ | ||
declarations: [], | ||
imports: [ | ||
common.CommonModule | ||
], | ||
providers: [ | ||
MsalGuard, | ||
MsalBroadcastService | ||
] | ||
},] } | ||
]; | ||
exports.BroadcastService = BroadcastService; | ||
exports.MSAL_CONFIG = MSAL_CONFIG; | ||
exports.MSAL_CONFIG_ANGULAR = MSAL_CONFIG_ANGULAR; | ||
/* | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
/** | ||
* Generated bundle index. Do not edit. | ||
*/ | ||
exports.MSAL_GUARD_CONFIG = MSAL_GUARD_CONFIG; | ||
exports.MSAL_INSTANCE = MSAL_INSTANCE; | ||
exports.MSAL_INTERCEPTOR_CONFIG = MSAL_INTERCEPTOR_CONFIG; | ||
exports.MsalBroadcastService = MsalBroadcastService; | ||
exports.MsalGuard = MsalGuard; | ||
@@ -703,3 +278,2 @@ exports.MsalInterceptor = MsalInterceptor; | ||
exports.MsalService = MsalService; | ||
exports.ɵa = defaultMsalAngularConfiguration; | ||
@@ -706,0 +280,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
@@ -1,16 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("rxjs"),require("rxjs/operators"),require("msal"),require("@angular/router"),require("minimatch"),require("@angular/common"),require("@angular/common/http")):"function"==typeof define&&define.amd?define("@azure/msal-angular",["exports","@angular/core","rxjs","rxjs/operators","msal","@angular/router","minimatch","@angular/common","@angular/common/http"],t):t(((e=e||self).azure=e.azure||{},e.azure["msal-angular"]={}),e.ng.core,e.rxjs,e.rxjs.operators,e.msal,e.ng.router,e.minimatch,e.ng.common,e.ng.common.http)}(this,(function(e,t,r,o,n,a,i,c,s){"use strict"; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
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 | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
***************************************************************************** */var u=function(e,t){return(u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};var l=function(){return(l=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};function p(e,t,r,o){var n,a=arguments.length,i=a<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,o);else for(var c=e.length-1;c>=0;c--)(n=e[c])&&(i=(a<3?n(i):a>3?n(t,r,i):n(t,r))||i);return a>3&&i&&Object.defineProperty(t,r,i),i}function f(e,t){return function(r,o){t(r,o,e)}}function h(e,t,r,o){return new(r||(r=Promise))((function(n,a){function i(e){try{s(o.next(e))}catch(e){a(e)}}function c(e){try{s(o.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,c)}s((o=o.apply(e,t||[])).next())}))}function g(e,t){var r,o,n,a,i={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,o&&(n=2&a[0]?o.return:a[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,a[1])).done)return n;switch(o=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,o=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(n=(n=i.trys).length>0&&n[n.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){i.label=a[1];break}if(6===a[0]&&i.label<n[1]){i.label=n[1],n=a;break}if(n&&i.label<n[2]){i.label=n[2],i.ops.push(a);break}n[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],o=0}finally{r=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}var d=function(){function e(){this._msalSubject=new r.BehaviorSubject(1),this.msalItem$=this._msalSubject.asObservable()}return e.prototype.broadcast=function(e,t){this._msalSubject.next({type:e,payload:t})},e.prototype.getMSALSubject=function(){return this._msalSubject},e.prototype.getMSALItem=function(){return this.msalItem$},e.prototype.subscribe=function(e,t){return this.msalItem$.pipe(o.filter((function(t){return t.type===e})),o.map((function(e){return e.payload}))).subscribe(t)},e=p([t.Injectable()],e)}(),m=function(){function e(e,t,r){this._error="",this._errorDesc="",this._scopes="",this._error=e,t&&(this._errorDesc=t),r&&(this._scopes=r)}return Object.defineProperty(e.prototype,"error",{get:function(){return this._error},set:function(e){this._error=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"errorDesc",{get:function(){return this._errorDesc},set:function(e){this._errorDesc=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scopes",{get:function(){return this._scopes},set:function(e){this._scopes=e},enumerable:!0,configurable:!0}),e}(),y=new t.InjectionToken("MSAL_CONFIG"),b=new t.InjectionToken("MSAL_CONFIG_ANGULAR"),v=function(e){return l(l({},e),{framework:l(l({},e.framework),{isAngular:!0})})},S=function(e){function r(t,r,o,n){var a=e.call(this,v(t))||this;return a.msalConfig=t,a.msalAngularConfig=r,a.router=o,a.broadcastService=n,window.addEventListener("msal:popUpHashChanged",(function(){a.getLogger().verbose("popUpHashChanged ")})),window.addEventListener("msal:popUpClosed",(function(e){var t=e.detail.split("|"),r=new m(t[0],t[1]);a.getLoginInProgress()?(n.broadcast("msal:loginFailure",r),a.setloginInProgress(!1)):a.getAcquireTokenInProgress()&&(n.broadcast("msal:acquireTokenFailure",r),a.setAcquireTokenInProgress(!1))})),a}return function(e,t){function r(){this.constructor=e}u(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(r,e),r.prototype.loginPopup=function(t){var r=this;return e.prototype.loginPopup.call(this,t).then((function(e){return r.broadcastService.broadcast("msal:loginSuccess",e),e})).catch((function(e){throw r.broadcastService.broadcast("msal:loginFailure",e),r.getLogger().error("Error during login:\n"+e.errorMessage),e}))},r.prototype.ssoSilent=function(t){var r=this;return e.prototype.ssoSilent.call(this,t).then((function(e){return r.broadcastService.broadcast("msal:ssoSuccess",e),e})).catch((function(e){throw r.broadcastService.broadcast("msal:ssoFailure",e),r.getLogger().error("Error during login:\n"+e.errorMessage),e}))},r.prototype.acquireTokenSilent=function(t){var r=this;return e.prototype.acquireTokenSilent.call(this,t).then((function(e){return r.broadcastService.broadcast("msal:acquireTokenSuccess",e),e})).catch((function(e){throw r.broadcastService.broadcast("msal:acquireTokenFailure",e),r.getLogger().error("Error when acquiring token for scopes: "+t.scopes+" "+e),e}))},r.prototype.acquireTokenPopup=function(t){var r=this;return e.prototype.acquireTokenPopup.call(this,t).then((function(e){return r.broadcastService.broadcast("msal:acquireTokenSuccess",e),e})).catch((function(e){throw r.broadcastService.broadcast("msal:acquireTokenFailure",e),r.getLogger().error("Error when acquiring token for scopes : "+t.scopes+" "+e),e}))},r.prototype.handleRedirectCallback=function(t,r){var o=this;e.prototype.handleRedirectCallback.call(this,(function(e,n){e?(o.getAccount()?o.broadcastService.broadcast("msal:acquireTokenFailure",e):o.broadcastService.broadcast("msal:loginFailure",e),r?r(e,n.accountState):t(e,n)):n&&("id_token"===n.tokenType?o.broadcastService.broadcast("msal:loginSuccess",n):o.broadcastService.broadcast("msal:acquireTokenSuccess",n),r?t(n):t(null,n))}))},r.prototype.clearCacheForScope=function(t){return e.prototype.clearCacheForScope.call(this,t)},r.prototype.getScopesForEndpoint=function(t){(this.msalConfig.framework&&this.msalConfig.framework.unprotectedResources||this.msalAngularConfig&&this.msalAngularConfig.unprotectedResources)&&this.getLogger().info("unprotectedResources is deprecated and ignored. msalAngularConfig.protectedResourceMap now supports glob patterns");var r=this.msalConfig.framework&&this.msalConfig.framework.protectedResourceMap;r&&this.getLogger().info("msalConfig.framework.protectedResourceMap is deprecated, use msalAngularConfig.protectedResourceMap");var o=r&&r.size?r:new Map(this.msalAngularConfig.protectedResourceMap),a=Array.from(o.keys()).filter((function(e){return new i.Minimatch(e).match(t)||t.indexOf(e)>-1}));if(a.length>0){a.length>1&&(this.getLogger().warning("Multiple entries in protectedResourceMap found for resource. Using first entry."),this.getLogger().warningPii("Multiple entries found for: "+t));var c=a[0];if(c)return o.get(c)}return t.indexOf("http://")>-1||t.indexOf("https://")>-1?n.UrlUtils.getHostFromUri(t)===n.UrlUtils.getHostFromUri(e.prototype.getRedirectUri.call(this))?new Array(this.msalConfig.auth.clientId):null:new Array(this.msalConfig.auth.clientId)},r.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[y]}]},{type:void 0,decorators:[{type:t.Inject,args:[b]}]},{type:a.Router},{type:d}]},r=p([t.Injectable(),f(0,t.Inject(y)),f(1,t.Inject(b))],r)}(n.UserAgentApplication),w=function(){function e(e,t,r,o,n,a,i,c){this.msalConfig=e,this.msalAngularConfig=t,this.authService=r,this.router=o,this.activatedRoute=n,this.location=a,this.platformLocation=i,this.broadcastService=c}return e.prototype.getDestinationUrl=function(e){var t=document.getElementsByTagName("base"),r=this.location.normalize(t.length?t[0].href:window.location.origin),o=this.location.prepareExternalUrl(e);return o.startsWith("#")?r+"/"+o:""+r+e},e.prototype.loginInteractively=function(e){return h(this,void 0,void 0,(function(){var t;return g(this,(function(r){return this.msalAngularConfig.popUp?[2,this.authService.loginPopup({scopes:this.msalAngularConfig.consentScopes,extraQueryParameters:this.msalAngularConfig.extraQueryParameters}).then((function(){return!0})).catch((function(){return!1}))]:(t=this.getDestinationUrl(e),this.authService.loginRedirect({redirectStartPage:t,scopes:this.msalAngularConfig.consentScopes,extraQueryParameters:this.msalAngularConfig.extraQueryParameters}),[2])}))}))},e.prototype.canActivate=function(e,t){var r=this;return this.authService.getLogger().verbose("location change event from old url to new url"),n.UrlUtils.urlContainsHash(window.location.hash)&&n.WindowUtils.isInIframe()?(this.authService.getLogger().warning("redirectUri set to page with MSAL Guard. It is recommended to not set redirectUri to a page that requires authentication."),!1):this.authService.getAccount()?this.authService.acquireTokenSilent({scopes:[this.msalConfig.auth.clientId]}).then((function(){return!0})).catch((function(e){if(n.InteractionRequiredAuthError.isInteractionRequiredError(e.errorCode))return r.authService.getLogger().info("Interaction required error in MSAL Guard, prompting for interaction."),r.loginInteractively(t.url);throw r.authService.getLogger().error("Non-interaction error in MSAL Guard: "+e.errorMessage),e})):this.loginInteractively(t.url)},e.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[y]}]},{type:void 0,decorators:[{type:t.Inject,args:[b]}]},{type:S},{type:a.Router},{type:a.ActivatedRoute},{type:c.Location},{type:c.PlatformLocation},{type:d}]},e=p([t.Injectable(),f(0,t.Inject(y)),f(1,t.Inject(b))],e)}(),A=function(){function e(e,t){this.auth=e,this.broadcastService=t}return e.prototype.intercept=function(e,t){var a,i=this,c=this.auth.getScopesForEndpoint(e.url);return this.auth.getLogger().verbose("Url: "+e.url+" maps to scopes: "+c),c?r.from(this.auth.acquireTokenSilent({scopes:c}).then((function(t){var r="Bearer "+(a=t.tokenType===n.ServerHashParamKeys.ID_TOKEN?t.idToken.rawIdToken:t.accessToken);return e.clone({setHeaders:{Authorization:r}})}))).pipe(o.mergeMap((function(e){return t.handle(e)})),o.tap((function(){}),(function(e){e instanceof s.HttpErrorResponse&&401===e.status&&(i.auth.clearCacheForScope(a),i.broadcastService.broadcast("msal:notAuthorized",e.message))}))):t.handle(e)},e.ctorParameters=function(){return[{type:S},{type:d}]},e=p([t.Injectable()],e)}(),I={consentScopes:[],popUp:!1,extraQueryParameters:{},unprotectedResources:[],protectedResourceMap:[]},k=function(){function e(){}var r;return r=e,e.forRoot=function(e,t){return void 0===t&&(t=I),{ngModule:r,providers:[{provide:y,useValue:e},{provide:b,useValue:t},S]}},e=r=p([t.NgModule({imports:[c.CommonModule],declarations:[],providers:[w,d]})],e)}();e.BroadcastService=d,e.MSAL_CONFIG=y,e.MSAL_CONFIG_ANGULAR=b,e.MsalGuard=w,e.MsalInterceptor=A,e.MsalModule=k,e.MsalService=S,e.ɵa=I,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common"),require("rxjs"),require("@azure/msal-browser"),require("rxjs/operators"),require("minimatch")):"function"==typeof define&&define.amd?define("@azure/msal-angular",["exports","@angular/core","@angular/common","rxjs","@azure/msal-browser","rxjs/operators","minimatch"],t):t(((e=e||self).azure=e.azure||{},e.azure["msal-angular"]={}),e.ng.core,e.ng.common,e.rxjs,e["@azure/msal-browser"],e.rxjs.operators,e.minimatch)}(this,(function(e,t,r,n,o,i,a){"use strict";var c=new t.InjectionToken("MSAL_INSTANCE"),s=new t.InjectionToken("MSAL_GUARD_CONFIG"),u=new t.InjectionToken("MSAL_INTERCEPTOR_CONFIG"),p=function(){function e(e,t){this.instance=e,this.location=t;var r=this.location.path(!0).split("#").pop();r&&(this.redirectHash="#"+r)}return e.prototype.acquireTokenPopup=function(e){return n.from(this.instance.acquireTokenPopup(e))},e.prototype.acquireTokenRedirect=function(e){return n.from(this.instance.acquireTokenRedirect(e))},e.prototype.acquireTokenSilent=function(e){return n.from(this.instance.acquireTokenSilent(e))},e.prototype.handleRedirectObservable=function(){var e=n.from(this.instance.handleRedirectPromise(this.redirectHash));return this.redirectHash="",e},e.prototype.loginPopup=function(e){return n.from(this.instance.loginPopup(e))},e.prototype.loginRedirect=function(e){return n.from(this.instance.loginRedirect(e))},e.prototype.logout=function(e){return n.from(this.instance.logout(e))},e.prototype.ssoSilent=function(e){return n.from(this.instance.ssoSilent(e))},e}();p.decorators=[{type:t.Injectable}],p.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[c]}]},{type:r.Location}]};var l=function(){function e(e,t,r){this.msalGuardConfig=e,this.authService=t,this.location=r}return e.prototype.getDestinationUrl=function(e){var t=document.getElementsByTagName("base"),r=this.location.normalize(t.length?t[0].href:window.location.origin),n=this.location.prepareExternalUrl(e);return n.startsWith("#")?r+"/"+n:""+r+e},e.prototype.loginInteractively=function(e){if(this.msalGuardConfig.interactionType===o.InteractionType.Popup)return this.authService.loginPopup(Object.assign({},this.msalGuardConfig.authRequest)).pipe(i.map((function(){return!0})),i.catchError((function(){return n.of(!1)})));var t=this.getDestinationUrl(e);return this.authService.loginRedirect(Object.assign({redirectStartPage:t},this.msalGuardConfig.authRequest)),n.of(!1)},e.prototype.canActivate=function(e,t){var r=this;if(this.msalGuardConfig.interactionType!==o.InteractionType.Popup&&this.msalGuardConfig.interactionType!==o.InteractionType.Redirect)throw new o.BrowserConfigurationAuthError("invalid_interaction_type","Invalid interaction type provided to MSAL Guard. InteractionType.Popup or InteractionType.Redirect must be provided in the MsalGuardConfiguration");return this.authService.handleRedirectObservable().pipe(i.concatMap((function(){return r.authService.instance.getAllAccounts().length?n.of(!0):r.loginInteractively(t.url)})),i.catchError((function(){return n.of(!1)})))},e}();l.decorators=[{type:t.Injectable}],l.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[s]}]},{type:p},{type:r.Location}]};var h=function(){function e(e,t){this.msalInterceptorConfig=e,this.authService=t}return e.prototype.intercept=function(e,t){var r=this;if(this.msalInterceptorConfig.interactionType!==o.InteractionType.Popup&&this.msalInterceptorConfig.interactionType!==o.InteractionType.Redirect)throw new o.BrowserConfigurationAuthError("invalid_interaction_type","Invalid interaction type provided to MSAL Interceptor. InteractionType.Popup, InteractionType.Redirect or InteractionType.Silent must be provided in the msalInterceptorConfiguration");var a=this.getScopesForEndpoint(e.url),c=this.authService.instance.getAllAccounts()[0];return a&&0!==a.length?this.authService.acquireTokenSilent(Object.assign(Object.assign({},this.msalInterceptorConfig.authRequest),{scopes:a,account:c})).pipe(i.catchError((function(){if(r.msalInterceptorConfig.interactionType===o.InteractionType.Popup)return r.authService.acquireTokenPopup(Object.assign(Object.assign({},r.msalInterceptorConfig.authRequest),{scopes:a}));var e=window.location.href;return r.authService.acquireTokenRedirect(Object.assign(Object.assign({},r.msalInterceptorConfig.authRequest),{scopes:a,redirectStartPage:e})),n.EMPTY})),i.switchMap((function(r){var n=e.headers.set("Authorization","Bearer "+r.accessToken),o=e.clone({headers:n});return t.handle(o)}))):t.handle(e)},e.prototype.getScopesForEndpoint=function(e){var t=Array.from(this.msalInterceptorConfig.protectedResourceMap.keys()).filter((function(t){return new a.Minimatch(t).match(e)||e.indexOf(t)>-1}));if(t.length>0){var r=t[0];if(r)return this.msalInterceptorConfig.protectedResourceMap.get(r)}return null},e}();h.decorators=[{type:t.Injectable}],h.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[u]}]},{type:p}]};var f=function(e){var t=this;this.msalInstance=e,this._msalSubject=new n.Subject,this.msalSubject$=this._msalSubject.asObservable(),this.msalInstance.addEventCallback((function(e){t._msalSubject.next(e)}))};f.decorators=[{type:t.Injectable}],f.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[c]}]}]};var d=function(){function e(){}return e.forRoot=function(t,r,n){return{ngModule:e,providers:[{provide:c,useValue:t},{provide:s,useValue:r},{provide:u,useValue:n},p]}},e}();d.decorators=[{type:t.NgModule,args:[{declarations:[],imports:[r.CommonModule],providers:[l,f]}]}],e.MSAL_GUARD_CONFIG=s,e.MSAL_INSTANCE=c,e.MSAL_INTERCEPTOR_CONFIG=u,e.MsalBroadcastService=f,e.MsalGuard=l,e.MsalInterceptor=h,e.MsalModule=d,e.MsalService=p,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=azure-msal-angular.umd.min.js.map |
@@ -0,0 +0,0 @@ # Change Log - @azure/msal-angular |
/** | ||
* Generated bundle index. Do not edit. | ||
*/ | ||
export * from './public_api'; | ||
export { defaultMsalAngularConfiguration as ɵa } from './src/msal-angular.configuration'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXp1cmUtbXNhbC1hbmd1bGFyLmpzIiwic291cmNlUm9vdCI6Im5nOi8vQGF6dXJlL21zYWwtYW5ndWxhci8iLCJzb3VyY2VzIjpbImF6dXJlLW1zYWwtYW5ndWxhci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUVILGNBQWMsY0FBYyxDQUFDO0FBRTdCLE9BQU8sRUFBQywrQkFBK0IsSUFBSSxFQUFFLEVBQUMsTUFBTSxrQ0FBa0MsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogR2VuZXJhdGVkIGJ1bmRsZSBpbmRleC4gRG8gbm90IGVkaXQuXG4gKi9cblxuZXhwb3J0ICogZnJvbSAnLi9wdWJsaWNfYXBpJztcblxuZXhwb3J0IHtkZWZhdWx0TXNhbEFuZ3VsYXJDb25maWd1cmF0aW9uIGFzIMm1YX0gZnJvbSAnLi9zcmMvbXNhbC1hbmd1bGFyLmNvbmZpZ3VyYXRpb24nOyJdfQ== | ||
export * from './public-api'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXp1cmUtbXNhbC1hbmd1bGFyLmpzIiwic291cmNlUm9vdCI6IkM6L1VzZXJzL2phbnV0dGVyL0NvZGUvbWljcm9zb2Z0LWF1dGhlbnRpY2F0aW9uLWxpYnJhcnktZm9yLWpzL2xpYi9tc2FsLWFuZ3VsYXIvc3JjLyIsInNvdXJjZXMiOlsiYXp1cmUtbXNhbC1hbmd1bGFyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBRUgsY0FBYyxjQUFjLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEdlbmVyYXRlZCBidW5kbGUgaW5kZXguIERvIG5vdCBlZGl0LlxuICovXG5cbmV4cG9ydCAqIGZyb20gJy4vcHVibGljLWFwaSc7XG4iXX0= |
@@ -1,10 +0,7 @@ | ||
import { __decorate, __param, __awaiter } from 'tslib'; | ||
import { Injectable, InjectionToken, Inject, NgModule } from '@angular/core'; | ||
import { BehaviorSubject, from } from 'rxjs'; | ||
import { filter, map, mergeMap, tap } from 'rxjs/operators'; | ||
import { UserAgentApplication, UrlUtils, WindowUtils, InteractionRequiredAuthError, ServerHashParamKeys } from 'msal'; | ||
import { Router, ActivatedRoute } from '@angular/router'; | ||
import { InjectionToken, Injectable, Inject, NgModule } from '@angular/core'; | ||
import { Location, CommonModule } from '@angular/common'; | ||
import { from, of, EMPTY, Subject } from 'rxjs'; | ||
import { InteractionType, BrowserConfigurationAuthError } from '@azure/msal-browser'; | ||
import { map, catchError, concatMap, switchMap } from 'rxjs/operators'; | ||
import { Minimatch } from 'minimatch'; | ||
import { Location, PlatformLocation, CommonModule } from '@angular/common'; | ||
import { HttpErrorResponse } from '@angular/common/http'; | ||
@@ -15,25 +12,5 @@ /* | ||
*/ | ||
let BroadcastService = class BroadcastService { | ||
constructor() { | ||
this._msalSubject = new BehaviorSubject(1); | ||
this.msalItem$ = this._msalSubject.asObservable(); | ||
} | ||
broadcast(type, payload) { | ||
this._msalSubject.next({ type, payload }); | ||
} | ||
getMSALSubject() { | ||
return this._msalSubject; | ||
} | ||
getMSALItem() { | ||
return this.msalItem$; | ||
} | ||
subscribe(type, callback) { | ||
return this.msalItem$ | ||
.pipe(filter(message => message.type === type), map(message => message.payload)) | ||
.subscribe(callback); | ||
} | ||
}; | ||
BroadcastService = __decorate([ | ||
Injectable() | ||
], BroadcastService); | ||
const MSAL_INSTANCE = new InjectionToken("MSAL_INSTANCE"); | ||
const MSAL_GUARD_CONFIG = new InjectionToken("MSAL_GUARD_CONFIG"); | ||
const MSAL_INTERCEPTOR_CONFIG = new InjectionToken("MSAL_INTERCEPTOR_CONFIG"); | ||
@@ -44,213 +21,45 @@ /* | ||
*/ | ||
class MSALError { | ||
constructor(error, errorDesc, scopes) { | ||
this._error = ""; | ||
this._errorDesc = ""; | ||
this._scopes = ""; | ||
this._error = error; | ||
if (errorDesc) { | ||
this._errorDesc = errorDesc; | ||
class MsalService { | ||
constructor(instance, location) { | ||
this.instance = instance; | ||
this.location = location; | ||
const hash = this.location.path(true).split("#").pop(); | ||
if (hash) { | ||
this.redirectHash = `#${hash}`; | ||
} | ||
if (scopes) { | ||
this._scopes = scopes; | ||
} | ||
} | ||
get error() { | ||
return this._error; | ||
acquireTokenPopup(request) { | ||
return from(this.instance.acquireTokenPopup(request)); | ||
} | ||
set error(value) { | ||
this._error = value; | ||
acquireTokenRedirect(request) { | ||
return from(this.instance.acquireTokenRedirect(request)); | ||
} | ||
get errorDesc() { | ||
return this._errorDesc; | ||
acquireTokenSilent(silentRequest) { | ||
return from(this.instance.acquireTokenSilent(silentRequest)); | ||
} | ||
set errorDesc(value) { | ||
this._errorDesc = value; | ||
handleRedirectObservable() { | ||
const handleRedirect = from(this.instance.handleRedirectPromise(this.redirectHash)); | ||
this.redirectHash = ""; | ||
return handleRedirect; | ||
} | ||
get scopes() { | ||
return this._scopes; | ||
loginPopup(request) { | ||
return from(this.instance.loginPopup(request)); | ||
} | ||
set scopes(value) { | ||
this._scopes = value; | ||
loginRedirect(request) { | ||
return from(this.instance.loginRedirect(request)); | ||
} | ||
} | ||
/* | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
const MSAL_CONFIG = new InjectionToken("MSAL_CONFIG"); | ||
const MSAL_CONFIG_ANGULAR = new InjectionToken("MSAL_CONFIG_ANGULAR"); | ||
/* | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
const buildMsalConfig = (config) => { | ||
return Object.assign(Object.assign({}, config), { framework: Object.assign(Object.assign({}, config.framework), { isAngular: true }) }); | ||
}; | ||
const ɵ0 = buildMsalConfig; | ||
let MsalService = class MsalService extends UserAgentApplication { | ||
constructor(msalConfig, msalAngularConfig, router, broadcastService) { | ||
super(buildMsalConfig(msalConfig)); | ||
this.msalConfig = msalConfig; | ||
this.msalAngularConfig = msalAngularConfig; | ||
this.router = router; | ||
this.broadcastService = broadcastService; | ||
window.addEventListener("msal:popUpHashChanged", () => { | ||
this.getLogger().verbose("popUpHashChanged "); | ||
}); | ||
window.addEventListener("msal:popUpClosed", (e) => { | ||
const errorParts = e.detail.split("|"); | ||
const msalError = new MSALError(errorParts[0], errorParts[1]); | ||
if (this.getLoginInProgress()) { | ||
broadcastService.broadcast("msal:loginFailure", msalError); | ||
this.setloginInProgress(false); | ||
} | ||
else if (this.getAcquireTokenInProgress()) { | ||
broadcastService.broadcast("msal:acquireTokenFailure", msalError); | ||
this.setAcquireTokenInProgress(false); | ||
} | ||
}); | ||
logout(logoutRequest) { | ||
return from(this.instance.logout(logoutRequest)); | ||
} | ||
loginPopup(request) { | ||
return super.loginPopup(request) | ||
.then((authResponse) => { | ||
this.broadcastService.broadcast("msal:loginSuccess", authResponse); | ||
return authResponse; | ||
}) | ||
.catch((error) => { | ||
this.broadcastService.broadcast("msal:loginFailure", error); | ||
this.getLogger().error("Error during login:\n" + error.errorMessage); | ||
throw error; | ||
}); | ||
} | ||
ssoSilent(request) { | ||
return super.ssoSilent(request) | ||
.then((authResponse) => { | ||
this.broadcastService.broadcast("msal:ssoSuccess", authResponse); | ||
return authResponse; | ||
}) | ||
.catch((error) => { | ||
this.broadcastService.broadcast("msal:ssoFailure", error); | ||
this.getLogger().error("Error during login:\n" + error.errorMessage); | ||
throw error; | ||
}); | ||
return from(this.instance.ssoSilent(request)); | ||
} | ||
acquireTokenSilent(request) { | ||
return super.acquireTokenSilent(request) | ||
.then((authResponse) => { | ||
this.broadcastService.broadcast("msal:acquireTokenSuccess", authResponse); | ||
return authResponse; | ||
}) | ||
.catch((error) => { | ||
this.broadcastService.broadcast("msal:acquireTokenFailure", error); | ||
this.getLogger().error("Error when acquiring token for scopes: " + request.scopes + " " + error); | ||
throw error; | ||
}); | ||
} | ||
acquireTokenPopup(request) { | ||
return super.acquireTokenPopup(request) | ||
.then((authResponse) => { | ||
this.broadcastService.broadcast("msal:acquireTokenSuccess", authResponse); | ||
return authResponse; | ||
}) | ||
.catch((error) => { | ||
this.broadcastService.broadcast("msal:acquireTokenFailure", error); | ||
this.getLogger().error("Error when acquiring token for scopes : " + request.scopes + " " + error); | ||
throw error; | ||
}); | ||
} | ||
handleRedirectCallback(authOrTokenCallback, errorReceivedCallback) { | ||
super.handleRedirectCallback((authError, authResponse) => { | ||
if (authError) { | ||
if (!this.getAccount()) { | ||
this.broadcastService.broadcast("msal:loginFailure", authError); | ||
} | ||
else { | ||
this.broadcastService.broadcast("msal:acquireTokenFailure", authError); | ||
} | ||
if (errorReceivedCallback) { | ||
errorReceivedCallback(authError, authResponse.accountState); | ||
} | ||
else { | ||
authOrTokenCallback(authError, authResponse); | ||
} | ||
} | ||
else if (authResponse) { | ||
if (authResponse.tokenType === "id_token") { | ||
this.broadcastService.broadcast("msal:loginSuccess", authResponse); | ||
} | ||
else { | ||
this.broadcastService.broadcast("msal:acquireTokenSuccess", authResponse); | ||
} | ||
if (errorReceivedCallback) { | ||
authOrTokenCallback(authResponse); | ||
} | ||
else { | ||
authOrTokenCallback(null, authResponse); | ||
} | ||
} | ||
}); | ||
} | ||
clearCacheForScope(accessToken) { | ||
return super.clearCacheForScope(accessToken); | ||
} | ||
getScopesForEndpoint(endpoint) { | ||
if ((this.msalConfig.framework && this.msalConfig.framework.unprotectedResources) || (this.msalAngularConfig && this.msalAngularConfig.unprotectedResources)) { | ||
this.getLogger().info("unprotectedResources is deprecated and ignored. msalAngularConfig.protectedResourceMap now supports glob patterns"); | ||
} | ||
const frameworkProtectedResourceMap = this.msalConfig.framework && this.msalConfig.framework.protectedResourceMap; | ||
if (frameworkProtectedResourceMap) { | ||
this.getLogger().info("msalConfig.framework.protectedResourceMap is deprecated, use msalAngularConfig.protectedResourceMap"); | ||
} | ||
const protectedResourceMap = frameworkProtectedResourceMap && frameworkProtectedResourceMap.size ? frameworkProtectedResourceMap : new Map(this.msalAngularConfig.protectedResourceMap); | ||
const protectedResourcesArray = Array.from(protectedResourceMap.keys()); | ||
const keyMatchesEndpointArray = protectedResourcesArray.filter(key => { | ||
const minimatch = new Minimatch(key); | ||
return minimatch.match(endpoint) || endpoint.indexOf(key) > -1; | ||
}); | ||
// process all protected resources and send the first matched resource | ||
if (keyMatchesEndpointArray.length > 0) { | ||
if (keyMatchesEndpointArray.length > 1) { | ||
this.getLogger().warning("Multiple entries in protectedResourceMap found for resource. Using first entry."); | ||
this.getLogger().warningPii(`Multiple entries found for: ${endpoint}`); | ||
} | ||
const keyForEndpoint = keyMatchesEndpointArray[0]; | ||
if (keyForEndpoint) { | ||
return protectedResourceMap.get(keyForEndpoint); | ||
} | ||
} | ||
/* | ||
* default resource will be clientid if nothing specified | ||
* App will use idtoken for calls to itself | ||
* check if it's staring from http or https, needs to match with app host | ||
*/ | ||
if (endpoint.indexOf("http://") > -1 || endpoint.indexOf("https://") > -1) { | ||
if (UrlUtils.getHostFromUri(endpoint) === UrlUtils.getHostFromUri(super.getRedirectUri())) { | ||
return new Array(this.msalConfig.auth.clientId); | ||
} | ||
} | ||
else { | ||
/* | ||
* in angular level, the url for $http interceptor call could be relative url, | ||
* if it's relative call, we'll treat it as app backend call. | ||
*/ | ||
return new Array(this.msalConfig.auth.clientId); | ||
} | ||
// if not the app's own backend or not a domain listed in the endpoints structure | ||
return null; | ||
} | ||
}; | ||
} | ||
MsalService.decorators = [ | ||
{ type: Injectable } | ||
]; | ||
MsalService.ctorParameters = () => [ | ||
{ type: undefined, decorators: [{ type: Inject, args: [MSAL_CONFIG,] }] }, | ||
{ type: undefined, decorators: [{ type: Inject, args: [MSAL_CONFIG_ANGULAR,] }] }, | ||
{ type: Router }, | ||
{ type: BroadcastService } | ||
{ type: undefined, decorators: [{ type: Inject, args: [MSAL_INSTANCE,] }] }, | ||
{ type: Location } | ||
]; | ||
MsalService = __decorate([ | ||
Injectable(), | ||
__param(0, Inject(MSAL_CONFIG)), | ||
__param(1, Inject(MSAL_CONFIG_ANGULAR)) | ||
], MsalService); | ||
@@ -261,12 +70,7 @@ /* | ||
*/ | ||
let MsalGuard = class MsalGuard { | ||
constructor(msalConfig, msalAngularConfig, authService, router, activatedRoute, location, platformLocation, broadcastService) { | ||
this.msalConfig = msalConfig; | ||
this.msalAngularConfig = msalAngularConfig; | ||
class MsalGuard { | ||
constructor(msalGuardConfig, authService, location) { | ||
this.msalGuardConfig = msalGuardConfig; | ||
this.authService = authService; | ||
this.router = router; | ||
this.activatedRoute = activatedRoute; | ||
this.location = location; | ||
this.platformLocation = platformLocation; | ||
this.broadcastService = broadcastService; | ||
} | ||
@@ -294,66 +98,32 @@ /** | ||
} | ||
/** | ||
* Interactively prompt the user to login | ||
* @param url Path of the requested page | ||
*/ | ||
loginInteractively(url) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (this.msalAngularConfig.popUp) { | ||
return this.authService.loginPopup({ | ||
scopes: this.msalAngularConfig.consentScopes, | ||
extraQueryParameters: this.msalAngularConfig.extraQueryParameters | ||
}) | ||
.then(() => true) | ||
.catch(() => false); | ||
} | ||
const redirectStartPage = this.getDestinationUrl(url); | ||
this.authService.loginRedirect({ | ||
redirectStartPage, | ||
scopes: this.msalAngularConfig.consentScopes, | ||
extraQueryParameters: this.msalAngularConfig.extraQueryParameters | ||
}); | ||
}); | ||
if (this.msalGuardConfig.interactionType === InteractionType.Popup) { | ||
return this.authService.loginPopup(Object.assign({}, this.msalGuardConfig.authRequest)) | ||
.pipe(map(() => true), catchError(() => of(false))); | ||
} | ||
const redirectStartPage = this.getDestinationUrl(url); | ||
this.authService.loginRedirect(Object.assign({ redirectStartPage }, this.msalGuardConfig.authRequest)); | ||
return of(false); | ||
} | ||
canActivate(route, state) { | ||
this.authService.getLogger().verbose("location change event from old url to new url"); | ||
/* | ||
* If a page with MSAL Guard is set as the redirect for acquireTokenSilent, | ||
* short-circuit to prevent redirecting or popups. | ||
*/ | ||
if (UrlUtils.urlContainsHash(window.location.hash) && WindowUtils.isInIframe()) { | ||
this.authService.getLogger().warning("redirectUri set to page with MSAL Guard. It is recommended to not set redirectUri to a page that requires authentication."); | ||
return false; | ||
if (this.msalGuardConfig.interactionType !== InteractionType.Popup && this.msalGuardConfig.interactionType !== InteractionType.Redirect) { | ||
throw new BrowserConfigurationAuthError("invalid_interaction_type", "Invalid interaction type provided to MSAL Guard. InteractionType.Popup or InteractionType.Redirect must be provided in the MsalGuardConfiguration"); | ||
} | ||
if (!this.authService.getAccount()) { | ||
return this.loginInteractively(state.url); | ||
} | ||
return this.authService.acquireTokenSilent({ | ||
scopes: [this.msalConfig.auth.clientId] | ||
}) | ||
.then(() => true) | ||
.catch((error) => { | ||
if (InteractionRequiredAuthError.isInteractionRequiredError(error.errorCode)) { | ||
this.authService.getLogger().info("Interaction required error in MSAL Guard, prompting for interaction."); | ||
return this.authService.handleRedirectObservable() | ||
.pipe(concatMap(() => { | ||
if (!this.authService.instance.getAllAccounts().length) { | ||
return this.loginInteractively(state.url); | ||
} | ||
this.authService.getLogger().error(`Non-interaction error in MSAL Guard: ${error.errorMessage}`); | ||
throw error; | ||
}); | ||
return of(true); | ||
}), catchError(() => of(false))); | ||
} | ||
}; | ||
} | ||
MsalGuard.decorators = [ | ||
{ type: Injectable } | ||
]; | ||
MsalGuard.ctorParameters = () => [ | ||
{ type: undefined, decorators: [{ type: Inject, args: [MSAL_CONFIG,] }] }, | ||
{ type: undefined, decorators: [{ type: Inject, args: [MSAL_CONFIG_ANGULAR,] }] }, | ||
{ type: undefined, decorators: [{ type: Inject, args: [MSAL_GUARD_CONFIG,] }] }, | ||
{ type: MsalService }, | ||
{ type: Router }, | ||
{ type: ActivatedRoute }, | ||
{ type: Location }, | ||
{ type: PlatformLocation }, | ||
{ type: BroadcastService } | ||
{ type: Location } | ||
]; | ||
MsalGuard = __decorate([ | ||
Injectable(), | ||
__param(0, Inject(MSAL_CONFIG)), | ||
__param(1, Inject(MSAL_CONFIG_ANGULAR)) | ||
], MsalGuard); | ||
@@ -364,41 +134,55 @@ /* | ||
*/ | ||
let MsalInterceptor = class MsalInterceptor { | ||
constructor(auth, broadcastService) { | ||
this.auth = auth; | ||
this.broadcastService = broadcastService; | ||
class MsalInterceptor { | ||
constructor(msalInterceptorConfig, authService) { | ||
this.msalInterceptorConfig = msalInterceptorConfig; | ||
this.authService = authService; | ||
} | ||
intercept(req, next) { | ||
const scopes = this.auth.getScopesForEndpoint(req.url); | ||
this.auth.getLogger().verbose("Url: " + req.url + " maps to scopes: " + scopes); | ||
// If there are no scopes set for this request, do nothing. | ||
if (!scopes) { | ||
if (this.msalInterceptorConfig.interactionType !== InteractionType.Popup && this.msalInterceptorConfig.interactionType !== InteractionType.Redirect) { | ||
throw new BrowserConfigurationAuthError("invalid_interaction_type", "Invalid interaction type provided to MSAL Interceptor. InteractionType.Popup, InteractionType.Redirect or InteractionType.Silent must be provided in the msalInterceptorConfiguration"); | ||
} | ||
const scopes = this.getScopesForEndpoint(req.url); | ||
const account = this.authService.instance.getAllAccounts()[0]; | ||
if (!scopes || scopes.length === 0) { | ||
return next.handle(req); | ||
} | ||
let token; | ||
// Acquire a token for this request, and attach as proper auth header. | ||
return from(this.auth.acquireTokenSilent({ scopes }) | ||
.then((response) => { | ||
token = response.tokenType === ServerHashParamKeys.ID_TOKEN ? response.idToken.rawIdToken : response.accessToken; | ||
const authHeader = `Bearer ${token}`; | ||
return req.clone({ | ||
setHeaders: { | ||
Authorization: authHeader, | ||
} | ||
}); | ||
})) | ||
.pipe(mergeMap(nextReq => next.handle(nextReq)), tap(() => { }, err => { | ||
if (err instanceof HttpErrorResponse && err.status === 401) { | ||
this.auth.clearCacheForScope(token); | ||
this.broadcastService.broadcast("msal:notAuthorized", err.message); | ||
// Note: For MSA accounts, include openid scope when calling acquireTokenSilent to return idToken | ||
return this.authService.acquireTokenSilent(Object.assign(Object.assign({}, this.msalInterceptorConfig.authRequest), { scopes, account })) | ||
.pipe(catchError(() => { | ||
if (this.msalInterceptorConfig.interactionType === InteractionType.Popup) { | ||
return this.authService.acquireTokenPopup(Object.assign(Object.assign({}, this.msalInterceptorConfig.authRequest), { scopes })); | ||
} | ||
const redirectStartPage = window.location.href; | ||
this.authService.acquireTokenRedirect(Object.assign(Object.assign({}, this.msalInterceptorConfig.authRequest), { scopes, redirectStartPage })); | ||
return EMPTY; | ||
}), switchMap((result) => { | ||
const headers = req.headers | ||
.set("Authorization", `Bearer ${result.accessToken}`); | ||
const requestClone = req.clone({ headers }); | ||
return next.handle(requestClone); | ||
})); | ||
} | ||
}; | ||
getScopesForEndpoint(endpoint) { | ||
const protectedResourcesArray = Array.from(this.msalInterceptorConfig.protectedResourceMap.keys()); | ||
const keyMatchesEndpointArray = protectedResourcesArray.filter(key => { | ||
const minimatch = new Minimatch(key); | ||
return minimatch.match(endpoint) || endpoint.indexOf(key) > -1; | ||
}); | ||
// process all protected resources and send the first matched resource | ||
if (keyMatchesEndpointArray.length > 0) { | ||
const keyForEndpoint = keyMatchesEndpointArray[0]; | ||
if (keyForEndpoint) { | ||
return this.msalInterceptorConfig.protectedResourceMap.get(keyForEndpoint); | ||
} | ||
} | ||
return null; | ||
} | ||
} | ||
MsalInterceptor.decorators = [ | ||
{ type: Injectable } | ||
]; | ||
MsalInterceptor.ctorParameters = () => [ | ||
{ type: MsalService }, | ||
{ type: BroadcastService } | ||
{ type: undefined, decorators: [{ type: Inject, args: [MSAL_INTERCEPTOR_CONFIG,] }] }, | ||
{ type: MsalService } | ||
]; | ||
MsalInterceptor = __decorate([ | ||
Injectable() | ||
], MsalInterceptor); | ||
@@ -409,9 +193,18 @@ /* | ||
*/ | ||
const defaultMsalAngularConfiguration = { | ||
consentScopes: [], | ||
popUp: false, | ||
extraQueryParameters: {}, | ||
unprotectedResources: [], | ||
protectedResourceMap: [] | ||
}; | ||
class MsalBroadcastService { | ||
constructor(msalInstance) { | ||
this.msalInstance = msalInstance; | ||
this._msalSubject = new Subject(); | ||
this.msalSubject$ = this._msalSubject.asObservable(); | ||
this.msalInstance.addEventCallback((message) => { | ||
this._msalSubject.next(message); | ||
}); | ||
} | ||
} | ||
MsalBroadcastService.decorators = [ | ||
{ type: Injectable } | ||
]; | ||
MsalBroadcastService.ctorParameters = () => [ | ||
{ type: undefined, decorators: [{ type: Inject, args: [MSAL_INSTANCE,] }] } | ||
]; | ||
@@ -422,16 +215,19 @@ /* | ||
*/ | ||
var MsalModule_1; | ||
let MsalModule = MsalModule_1 = class MsalModule { | ||
static forRoot(config, angularConfig = defaultMsalAngularConfiguration) { | ||
class MsalModule { | ||
static forRoot(msalInstance, guardConfig, interceptorConfig) { | ||
return { | ||
ngModule: MsalModule_1, | ||
ngModule: MsalModule, | ||
providers: [ | ||
{ | ||
provide: MSAL_CONFIG, | ||
useValue: config | ||
provide: MSAL_INSTANCE, | ||
useValue: msalInstance | ||
}, | ||
{ | ||
provide: MSAL_CONFIG_ANGULAR, | ||
useValue: angularConfig | ||
provide: MSAL_GUARD_CONFIG, | ||
useValue: guardConfig | ||
}, | ||
{ | ||
provide: MSAL_INTERCEPTOR_CONFIG, | ||
useValue: interceptorConfig | ||
}, | ||
MsalService | ||
@@ -441,11 +237,21 @@ ] | ||
} | ||
}; | ||
MsalModule = MsalModule_1 = __decorate([ | ||
NgModule({ | ||
imports: [CommonModule], | ||
declarations: [], | ||
providers: [MsalGuard, BroadcastService], | ||
}) | ||
], MsalModule); | ||
} | ||
MsalModule.decorators = [ | ||
{ type: NgModule, args: [{ | ||
declarations: [], | ||
imports: [ | ||
CommonModule | ||
], | ||
providers: [ | ||
MsalGuard, | ||
MsalBroadcastService | ||
] | ||
},] } | ||
]; | ||
/* | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
/** | ||
@@ -455,3 +261,3 @@ * Generated bundle index. Do not edit. | ||
export { BroadcastService, MSAL_CONFIG, MSAL_CONFIG_ANGULAR, MsalGuard, MsalInterceptor, MsalModule, MsalService, defaultMsalAngularConfiguration as ɵa }; | ||
export { MSAL_GUARD_CONFIG, MSAL_INSTANCE, MSAL_INTERCEPTOR_CONFIG, MsalBroadcastService, MsalGuard, MsalInterceptor, MsalModule, MsalService }; | ||
//# sourceMappingURL=azure-msal-angular.js.map |
{ | ||
"name": "@azure/msal-angular", | ||
"author": { | ||
"name": "Microsoft", | ||
"email": "nugetaad@microsoft.com", | ||
"url": "https://www.microsoft.com" | ||
}, | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/AzureAD/microsoft-authentication-library-for-js.git" | ||
}, | ||
"version": "1.1.2", | ||
"keywords": [ | ||
"implicit", | ||
"angular", | ||
"AAD", | ||
"msal", | ||
"oauth" | ||
], | ||
"version": "2.0.0-alpha.0", | ||
"main": "bundles/azure-msal-angular.umd.js", | ||
"typings": "azure-msal-angular.d.ts", | ||
"engines": { | ||
"node": ">=0.8.0" | ||
"dependencies": { | ||
"minimatch": "^3.0.4", | ||
"path": "^0.12.7", | ||
"tslib": "^2.0.0" | ||
}, | ||
"peerDependencies": { | ||
"@angular/common": "6 - 9", | ||
"@angular/core": "6 - 9", | ||
"msal": "^1.4.4", | ||
"rxjs": "^6.0.0", | ||
"tslib": "^1.10.0" | ||
"@angular/common": "9 - 10", | ||
"@angular/core": "9 - 10", | ||
"@azure/msal-browser": "^2.4.0", | ||
"rxjs": "^6.0.0" | ||
}, | ||
"directories": { | ||
"test": "tests" | ||
}, | ||
"description": "Microsoft Authentication Library for Angular", | ||
"dependencies": { | ||
"minimatch": "^3.0.4", | ||
"path": "^0.12.7" | ||
}, | ||
"module": "fesm5/azure-msal-angular.js", | ||
"module": "fesm2015/azure-msal-angular.js", | ||
"es2015": "fesm2015/azure-msal-angular.js", | ||
"esm5": "esm5/azure-msal-angular.js", | ||
"esm2015": "esm2015/azure-msal-angular.js", | ||
"fesm5": "fesm5/azure-msal-angular.js", | ||
"fesm2015": "fesm2015/azure-msal-angular.js", | ||
@@ -47,0 +21,0 @@ "metadata": "azure-msal-angular.metadata.json", |
336
README.md
# Microsoft Authentication Library for Angular | ||
| [Getting Started](https://docs.microsoft.com/azure/active-directory/develop/tutorial-v2-angular)| [AAD Docs](https://aka.ms/aaddevv2) | [Library Reference](https://azuread.github.io/microsoft-authentication-library-for-js/ref/msal-angular/) | [Support](README.md#community-help-and-support) | [Samples](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples) | ||
| --- | --- | --- | --- | --- | | ||
MSAL for Angular enables client-side Angular web applications, running in a web browser, to authenticate users using [Azure AD](https://docs.microsoft.com/azure/active-directory/develop/v2-overview) work and school accounts (AAD), Microsoft personal accounts (MSA) and social identity providers like Facebook, Google, LinkedIn, Microsoft accounts, etc. through [Azure AD B2C](https://docs.microsoft.com/azure/active-directory-b2c/active-directory-b2c-overview#identity-providers) service. It also enables your app to get tokens to access [Microsoft Cloud](https://www.microsoft.com/enterprise) services such as [Microsoft Graph](https://graph.microsoft.io). | ||
Note: `msal-angular@2` is under development. **We do not recommend using this version in a production environment yet**. | ||
![npm (scoped)](https://img.shields.io/npm/v/@azure/msal-angular)![npm](https://img.shields.io/npm/dw/@azure/msal-angular) | ||
## Installation | ||
| [Getting Started](https://docs.microsoft.com/azure/active-directory/develop/tutorial-v2-angular)| [AAD Docs](https://aka.ms/aaddevv2) | [Library Reference](https://azuread.github.io/microsoft-authentication-library-for-js/ref/msal-angular/) | [Support](README.md#community-help-and-support) | [Samples](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/msal-angular-v2/samples/msal-angular-v2-samples/angular10-sample-app) | ||
| --- | --- | --- | --- | --- | | ||
The MSAL Angular package is available on NPM: | ||
1. [About](#about) | ||
2. [Guides](#guides) | ||
3. [Version Support](#version-support) | ||
4. [Prerequisites](#prerequisites) | ||
5. [Installation](#installation) | ||
6. [Usage](#usage) | ||
7. [Samples](#samples) | ||
8. [Build and running tests](#build-and-running-tests) | ||
9. [Versioning](#versioning) | ||
10. [Community Help and Support](#community-help-and-support) | ||
11. [Contribute](#contribute) | ||
12. [Security Reporting](#security-reporting) | ||
13. [License](#license) | ||
14. [Code of Conduct](#we-value-and-adhere-to-the-microsoft-open-source-code-of-conduct) | ||
`npm install msal @azure/msal-angular --save` | ||
## About | ||
MSAL for Angular enables Angular web applications to authenticate users using [Azure AD](https://docs.microsoft.com/azure/active-directory/develop/v2-overview) work and school accounts (AAD), Microsoft personal accounts (MSA) and social identity providers like Facebook, Google, LinkedIn, Microsoft accounts, etc. through [Azure AD B2C](https://docs.microsoft.com/azure/active-directory-b2c/active-directory-b2c-overview#identity-providers) service. It also enables your app to get tokens to access [Microsoft Cloud](https://www.microsoft.com/enterprise) services such as [Microsoft Graph](https://graph.microsoft.io). | ||
The `@azure/msal-angular` package described by the code in this folder wraps the [`@azure/msal-browser` package](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-browser) and uses it as a peer dependency to enable authentication in Angular Web Applications without backend servers. This version of the library uses the OAuth 2.0 Authorization Code Flow with PKCE. To read more about this protocol, as well as the differences between implicit flow and authorization code flow, see the description provided by [@azure/msal-browser](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-browser#implicit-flow-vs-authorization-code-flow-with-pkce). If you are looking for the version of the library that uses the implicit flow, please see the [`msal-angular-v1` library](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-core). | ||
This is an improvement upon the current `msal-angular` library which will utilize the authorization code flow. Most features available in the old library will be available in this one, but there are nuances to the authentication flow in both. The `@azure/msal-angular` package does NOT support the implicit flow. | ||
## Guides | ||
- [Quickstart](https://docs.microsoft.com/azure/active-directory/develop/quickstart-v2-angular) | ||
- [Upgrade Guide (0.x-1.x)](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-angular/docs/0.x-1.x-upgrade-guide.md) | ||
- [Configuration](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-angular/docs/configuration.md) | ||
- [Upgrade Guide (1.x-2.x)](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/msal-angular-v2/lib/msal-angular/docs/v2-docs/1.x-2.x-upgrade-guide.md) | ||
- [Upgrade Guide (0.x-1.x)](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/msal-angular-v2/lib/msal-angular/docs/v1-docs/0.x-1.x-upgrade-guide.md) | ||
- [Configuration](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/msal-angular-v2/lib/msal-angular/docs/v2-docs/configuration.md) | ||
@@ -28,274 +46,70 @@ ## Version Support | ||
|----------------------|-------------------------|----------------------------| | ||
| 2.x.x | Active development | 9, 10 | | ||
| 1.x.x | Active development | 6, 7, 8, 9 | | ||
| 0.x.x | In maintenance | 4, 5 | | ||
## Samples | ||
## Prerequisites | ||
* [Angular Quickstart](https://github.com/Azure-Samples/active-directory-javascript-singlepageapp-angular) | ||
* [B2C Angular SPA](https://github.com/Azure-Samples/active-directory-b2c-javascript-angular-spa) | ||
* [Angular v6](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-angular-samples/angular6-sample-app) | ||
* [Angular v7](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-angular-samples/angular7-sample-app) | ||
* [Angular v8](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-angular-samples/angular8-sample-app) | ||
* [Angular v9](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-angular-samples/angular9-sample-app) | ||
## Usage | ||
### Prerequisites | ||
Before using MSAL.js, [register an application in Azure AD](https://docs.microsoft.com/azure/active-directory/develop/quickstart-register-app) to get your `clientId`. | ||
### 1. Include and initialize the MSAL module in your app module. | ||
## Installation | ||
Import MsalModule into app.module.ts. To initialize MSAL module you are required to pass the clientId of your application which you can get from the application registration. | ||
```js | ||
@NgModule({ | ||
imports: [ | ||
MsalModule.forRoot({ | ||
auth: { | ||
clientId: "Your client ID" | ||
} | ||
}) | ||
] | ||
}) | ||
export class AppModule {} | ||
The MSAL Angular package is available on NPM: | ||
``` | ||
#### 2. Secure the routes in your application | ||
You can add authentication to secure specific routes in your application by just adding `canActivate : [MsalGuard]` to your route definition. It can be added at the parent or child routes. | ||
```js | ||
{ | ||
path: 'product', | ||
component: ProductComponent, | ||
canActivate: [MsalGuard], | ||
children: [ | ||
{ | ||
path: 'detail/:id', | ||
component: ProductDetailComponent | ||
} | ||
] | ||
}, { | ||
path: 'myProfile', | ||
component: MsGraphComponent, | ||
canActivate: [MsalGuard] | ||
}, | ||
npm install msal @azure/msal-angular --save | ||
``` | ||
When a user visits these routes, the library will prompt the user to authenticate. | ||
## Usage | ||
### 3. Get tokens for Web API calls | ||
MSAL Angular Basics | ||
1. [Initialization](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/msal-angular-v2/lib/msal-angular/docs/v2-docs/initialization.md) | ||
2. [Public APIs](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/msal-angular-v2/lib/msal-angular/docs/v2-docs/public-apis.md) | ||
3. [Known issues](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/msal-angular-v2/lib/msal-angular/docs/v2-docs/known-issues.md) | ||
MSAL Angular allows you to add an Http interceptor (`MsalInterceptor`) in your `app.module.ts` as follows. MsalInterceptor will obtain tokens and add them to all your Http requests in API calls based on the `protectedResourceMap`. | ||
Advanced Topics | ||
1. [Logging](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/msal-angular-v2/lib/msal-angular/docs/v2-docs/logging.md) | ||
2. [CORS API](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/msal-angular-v2/lib/msal-angular/docs/v2-docs/cors-api.md) | ||
3. [Multi-Tenant](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/msal-angular-v2/lib/msal-angular/docs/multi-tenant.md) | ||
4. [Security](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/msal-angular-v2/lib/msal-angular/docs/security.md) | ||
5. [Internet Explorer Support](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/msal-angular-v2/lib/msal-angular/docs/v2-docs/ie-support.md) | ||
```js | ||
@NgModule({ | ||
imports: [ | ||
MsalModule.forRoot({ | ||
auth: { | ||
clientId: "Your client ID" | ||
} | ||
}, { | ||
protectedResourceMap: [ | ||
['https://graph.microsoft.com/v1.0/me', ['user.read']], | ||
['https://api.myapplication.com/users/*', ['customscope.read']] | ||
] | ||
}) | ||
], | ||
providers: [ | ||
ProductService, | ||
{ | ||
provide: HTTP_INTERCEPTORS, | ||
useClass: MsalInterceptor, | ||
multi: true | ||
} | ||
] | ||
}) | ||
export class AppModule {} | ||
``` | ||
All documentation for MSAL Angular v1 can be found [here](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/msal-angular-v2/lib/msal-angular/docs/v1-docs/). | ||
Using MsalInterceptor is optional and you can write your own interceptor if you choose to. Alternatively, you can also explicitly acquire tokens using the acquireToken APIs. | ||
## Samples | ||
As of `@azure/msal-angular@1.1.0`, `protectedResourceMap` supports wildcard patterns that are supported by [minimatch](https://github.com/isaacs/minimatch), and `unprotectedResources` is deprecated and ignored. | ||
### MSAL Angular 1.x Samples | ||
* [Angular Quickstart](https://github.com/Azure-Samples/active-directory-javascript-singlepageapp-angular) | ||
* [B2C Angular SPA](https://github.com/Azure-Samples/active-directory-b2c-javascript-angular-spa) | ||
* [Angular v6](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-angular-samples/angular6-sample-app) | ||
* [Angular v7](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-angular-samples/angular7-sample-app) | ||
* [Angular v8](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-angular-samples/angular8-sample-app) | ||
* [Angular v9](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-angular-samples/angular9-sample-app) | ||
**Note:** When using wildcards, if multiple matching entries are found in the `protectedResourceMap`, the first match found will be used (based on the order of the `protectedResourceMap`). | ||
### MSAL Angular 2.x Samples | ||
* [Angular v10](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/msal-angular-v2/samples/msal-angular-v2-samples/angular10-sample-app) | ||
### 4. Subscribe to event callbacks | ||
## Build and running tests | ||
MSAL wrapper provides below callbacks for various operations. For all callbacks, you need to inject BroadcastService as a dependency in your component/service and also implement a `handleRedirectCallback`: | ||
If you want to build the library and run all the unit tests, you can do the following. | ||
```js | ||
this.authService.handleRedirectCallback((authError, response) => { | ||
// do something here | ||
}); | ||
``` | ||
First navigate to the root directory of the library(msal-angular) and install the dependencies: | ||
1. Login-related events (`loginPopup`/`loginRedirect`) | ||
npm install | ||
```js | ||
this.broadcastService.subscribe("msal:loginFailure", payload => { | ||
// do something here | ||
}); | ||
Then use the following command to build the library and run all the unit tests: | ||
this.broadcastService.subscribe("msal:loginSuccess", payload => { | ||
// do something here | ||
}); | ||
``` | ||
npm run build | ||
2. Token-related events (`acquireTokenSilent()`/`acquireTokenPopup()`/`acquireTokenRedirect()`) | ||
npm run test | ||
```js | ||
this.broadcastService.subscribe("msal:acquireTokenSuccess", payload => { | ||
// do something here | ||
}); | ||
## Versioning | ||
this.broadcastService.subscribe("msal:acquireTokenFailure", payload => { | ||
// do something here | ||
}); | ||
``` | ||
This library controls how users sign-in and access services. We recommend you always take the latest version of our library in your app when possible. We use [semantic versioning](http://semver.org) so you can control the risk associated with updating your app. As an example, always downloading the latest minor version number (e.g. x._y_.x) ensures you get the latest security and feature enhanements but our API surface remains the same. You can always see the latest version and release notes under the Releases tab of GitHub. | ||
3. SSO-related events (`ssoSilent()`) | ||
```js | ||
this.broadcastService.subscribe("msal:ssoSuccess", payload => { | ||
// do something here | ||
}); | ||
this.broadcastService.subscribe("msal:ssoFailure", payload => { | ||
// do something here | ||
}); | ||
``` | ||
4. It is extremely important to unsubscribe. Implement `ngOnDestroy()` in your component and unsubscribe. | ||
```js | ||
private subscription: Subscription; | ||
this.subscription = this.broadcastService.subscribe("msal:acquireTokenFailure", (payload) => {}); | ||
ngOnDestroy() { | ||
this.broadcastService.getMSALSubject().next(1); | ||
if (this.subscription) { | ||
this.subscription.unsubscribe(); | ||
} | ||
} | ||
``` | ||
## MSAL Angular Public API | ||
### Login and AcquireToken APIs | ||
The wrapper exposes APIs for login, logout, acquiring access token and more. | ||
1. `loginRedirect()` | ||
2. `loginPopup()` | ||
3. `logOut()` | ||
4. `acquireTokenSilent()` | ||
5. `acquireTokenPopup()` | ||
6. `acquireTokenRedirect()` | ||
7. `getAccount()` | ||
8. `ssoSilent()` | ||
## Advanced Topics | ||
### Logging | ||
The logger definition has the following properties. Please see the config section for more details on their use: | ||
1. correlationId | ||
2. level | ||
3. piiLoggingEnabled | ||
You can enable logging in your app as shown below: | ||
```js | ||
export function loggerCallback(logLevel, message, piiEnabled) { | ||
console.log(message); | ||
} | ||
@NgModule({ | ||
imports: [ MsalModule.forRoot({ | ||
auth: { | ||
clientId: 'Your client ID', | ||
}, | ||
system: { | ||
logger: new Logger(loggerCallback, { | ||
correlationId: '1234', | ||
level: LogLevel.Verbose, | ||
piiLoggingEnabled: true, | ||
}), | ||
} | ||
})] | ||
}) | ||
``` | ||
### Multi-Tenant | ||
By default, you have multi-tenant support since MSAL sets the tenant in the authority to 'common' if it is not specified in the config. This allows any Microsoft account to authenticate to your application. If you are not interested in multi-tenant behavior, you will need to set the `authority` config property as shown above. | ||
If you allow multi-tenant authentication, and you do not wish to allow all Microsoft account users to use your application, you must provide your own method of filtering the token issuers to only those tenants who are allowed to login. | ||
### Security | ||
Tokens are accessible from Javascript since MSAL is using HTML5 storage. Default storage option is sessionStorage, which keeps the tokens per session. You should ask user to login again for important operations on your app. | ||
You should protect your site for XSS. Please check the article here: [https://www.owasp.org/index.php/XSS\_(Cross_Site_Scripting)\_Prevention_Cheat_Sheet](<https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet>) | ||
### CORS API usage | ||
MSAL will get access tokens using a hidden Iframe for given CORS API endpoints in the config. To make CORS API call, you need to specify your CORS API endpoints as a map in the Angular config. | ||
```js | ||
export const protectedResourceMap:[string, string[]][]= [ | ||
['https://buildtodoservice.azurewebsites.net/api/todolist', [ 'api://a88bb933-319c-41b5-9f04-eff36d985612/access_as_user' ]], | ||
['https://graph.microsoft.com/v1.0/me', ['user.read']] | ||
]; | ||
@NgModule({ | ||
imports: [ | ||
MsalModule.forRoot({ | ||
auth: { | ||
clientId: 'Your client ID', | ||
} | ||
}, { | ||
protectedResourceMap : protectedResourceMap | ||
}) | ||
] | ||
}) | ||
``` | ||
In your API project, you need to enable CORS API requests to receive flight requests. | ||
### Internet Explorer support | ||
This library supports Internet Explorer 11 with the following configuration: | ||
- For CORS API calls, the Iframe needs to access the cookies for the same domain that you did the initial sign in on. IE does not allow to access cookies in Iframe for localhost. Your URL needs to be fully qualified domain i.e http://yoursite.azurewebsites.com. Chrome does not have this restriction. | ||
- If you put your site in the trusted site list, cookies are not accessible for Iframe requests. You need to remove protected mode for Internet zone or add the authority URL for the login to the trusted sites as well. | ||
- IE may clear local storage when navigating between websites in different zones (e.g. your app and the login authority), which results in a broken experience when returning from the login page. To fix, set `storeAuthStateInCookie` to `true`. | ||
- There are known issues with popups in IE. We recommend using redirect flows by setting `popUp` to `false`. | ||
It is recommended that these properties are set dynamically based on the user's browser. | ||
```js | ||
const isIE = | ||
window.navigator.userAgent.indexOf("MSIE ") > -1 || | ||
window.navigator.userAgent.indexOf("Trident/") > -1; | ||
MsalModule.forRoot({ | ||
// ... | ||
cache: { | ||
storeAuthStateInCookie: ieIE | ||
} | ||
}, { | ||
popUp: !isIE | ||
}); | ||
``` | ||
## Community Help and Support | ||
- [FAQs](https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/FAQs) for access to our frequently asked questions | ||
- [Msal Browser FAQ](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/FAQ.md) for access to our frequently asked questions | ||
- [Stack Overflow](http://stackoverflow.com/questions/tagged/msal) using tag "msal". | ||
We highly recommend you ask your questions on Stack Overflow first and browse existing issues to see if someone has asked your question before. | ||
- [GitHub Issues](../../issues) for reporting a bug or feature requests | ||
- [GitHub Issues](https://github.com/AzureAD/microsoft-authentication-library-for-js/issues/templates/edit) for reporting a bug or feature requests | ||
- [User Voice page](https://feedback.azure.com/forums/169401-azure-active-directory) to provide recommendations and/or feedback | ||
@@ -307,20 +121,2 @@ | ||
## Build and running tests | ||
If you want to build the library and run all the unit tests, you can do the following. | ||
First navigate to the root directory of the library(msal-angular) and install the dependencies: | ||
npm install | ||
Then use the following command to build the library and run all the unit tests: | ||
npm run build | ||
npm run test | ||
## Versioning | ||
This library controls how users sign-in and access services. We recommend you always take the latest version of our library in your app when possible. We use [semantic versioning](http://semver.org) so you can control the risk associated with updating your app. As an example, always downloading the latest minor version number (e.g. x._y_.x) ensures you get the latest security and feature enhanements but our API surface remains the same. You can always see the latest version and release notes under the Releases tab of GitHub. | ||
## Security Reporting | ||
@@ -332,3 +128,3 @@ | ||
Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License (the "License"); | ||
Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License (the "License"). | ||
@@ -335,0 +131,0 @@ ## We Value and Adhere to the Microsoft Open Source Code of Conduct |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
0
165302
33
918
2
3
131
1
1
+ Addedtslib@^2.0.0
+ Added@angular/common@10.2.5(transitive)
+ Added@angular/core@10.2.5(transitive)
+ Added@azure/msal-browser@2.39.0(transitive)
+ Added@azure/msal-common@13.3.3(transitive)
+ Addedtslib@2.8.1(transitive)
- Removed@angular/common@9.1.13(transitive)
- Removed@angular/core@9.1.13(transitive)
- Removedmsal@1.4.18(transitive)