@igo2/auth 1.15.5 → 1.15.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/esm2020/igo2-auth.mjs +4 -4
  2. package/esm2020/lib/auth-form/auth-facebook.component.mjs +60 -60
  3. package/esm2020/lib/auth-form/auth-form.component.mjs +276 -276
  4. package/esm2020/lib/auth-form/auth-google.component.mjs +98 -98
  5. package/esm2020/lib/auth-form/auth-intern.component.mjs +118 -118
  6. package/esm2020/lib/auth-form/auth-microsoft.component.mjs +93 -93
  7. package/esm2020/lib/auth-form/auth-microsoftb2c.component.mjs +92 -92
  8. package/esm2020/lib/auth-form/index.mjs +4 -4
  9. package/esm2020/lib/auth-routing.module.mjs +23 -23
  10. package/esm2020/lib/auth.module.mjs +90 -90
  11. package/esm2020/lib/shared/admin.guard.mjs +32 -32
  12. package/esm2020/lib/shared/auth-microsoft.provider.mjs +83 -83
  13. package/esm2020/lib/shared/auth-msalBroadcastServiceb2c.service.mjs +37 -37
  14. package/esm2020/lib/shared/auth-msalServiceb2c.service..mjs +79 -79
  15. package/esm2020/lib/shared/auth.guard.mjs +31 -31
  16. package/esm2020/lib/shared/auth.interceptor.mjs +154 -154
  17. package/esm2020/lib/shared/auth.interface.mjs +1 -1
  18. package/esm2020/lib/shared/auth.service.mjs +157 -157
  19. package/esm2020/lib/shared/logged.guard.mjs +31 -31
  20. package/esm2020/lib/shared/profils.guard.mjs +36 -36
  21. package/esm2020/lib/shared/protected.directive.mjs +18 -18
  22. package/esm2020/lib/shared/storage.interface.mjs +1 -1
  23. package/esm2020/lib/shared/storage.service.mjs +90 -90
  24. package/esm2020/lib/shared/token.service.mjs +46 -46
  25. package/esm2020/public_api.mjs +18 -18
  26. package/fesm2015/igo2-auth.mjs +1577 -1577
  27. package/fesm2020/igo2-auth.mjs +1475 -1475
  28. package/index.d.ts +5 -5
  29. package/lib/auth-form/auth-facebook.component.d.ts +18 -18
  30. package/lib/auth-form/auth-form.component.d.ts +42 -42
  31. package/lib/auth-form/auth-google.component.d.ts +24 -24
  32. package/lib/auth-form/auth-intern.component.d.ts +21 -21
  33. package/lib/auth-form/auth-microsoft.component.d.ts +23 -23
  34. package/lib/auth-form/auth-microsoftb2c.component.d.ts +23 -23
  35. package/lib/auth-form/index.d.ts +4 -4
  36. package/lib/auth-routing.module.d.ts +7 -7
  37. package/lib/auth.module.d.ts +23 -23
  38. package/lib/shared/admin.guard.d.ts +13 -13
  39. package/lib/shared/auth-microsoft.provider.d.ts +30 -30
  40. package/lib/shared/auth-msalBroadcastServiceb2c.service.d.ts +15 -15
  41. package/lib/shared/auth-msalServiceb2c.service..d.ts +33 -33
  42. package/lib/shared/auth.guard.d.ts +13 -13
  43. package/lib/shared/auth.interceptor.d.ts +24 -24
  44. package/lib/shared/auth.interface.d.ts +99 -99
  45. package/lib/shared/auth.service.d.ts +44 -44
  46. package/lib/shared/logged.guard.d.ts +13 -13
  47. package/lib/shared/profils.guard.d.ts +13 -13
  48. package/lib/shared/protected.directive.d.ts +8 -8
  49. package/lib/shared/storage.interface.d.ts +4 -4
  50. package/lib/shared/storage.service.d.ts +18 -18
  51. package/lib/shared/token.service.d.ts +15 -15
  52. package/package.json +3 -3
  53. package/public_api.d.ts +15 -15
@@ -30,1625 +30,1625 @@ import * as i4 from '@angular/material/icon';
30
30
  import { MatIconModule } from '@angular/material/icon';
31
31
  import { Md5 } from 'ts-md5';
32
32
 
33
- class TokenService {
34
- constructor(injector) {
35
- this.injector = injector;
36
- }
37
- set(token) {
38
- localStorage.setItem(this.tokenKey, token);
39
- }
40
- remove() {
41
- localStorage.removeItem(this.tokenKey);
42
- }
43
- get() {
44
- return localStorage.getItem(this.tokenKey);
45
- }
46
- decode() {
47
- const token = this.get();
48
- if (!token) {
49
- return;
50
- }
51
- return jwtDecode(token);
52
- }
53
- isExpired() {
54
- const jwt = this.decode();
55
- const currentTime = new Date().getTime() / 1000;
56
- if (jwt && currentTime < jwt.exp) {
57
- return false;
58
- }
59
- return true;
60
- }
61
- get tokenKey() {
62
- const config = this.injector.get(ConfigService);
63
- this.options = config.getConfig('auth') || {};
64
- return this.options.tokenKey;
65
- }
66
- }
67
- TokenService.ɵfac = function TokenService_Factory(t) { return new (t || TokenService)(i0.ɵɵinject(i0.Injector)); };
68
- TokenService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: TokenService, factory: TokenService.ɵfac, providedIn: 'root' });
69
- (function () {
70
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TokenService, [{
71
- type: Injectable,
72
- args: [{
73
- providedIn: 'root'
74
- }]
75
- }], function () { return [{ type: i0.Injector }]; }, null);
33
+ class TokenService {
34
+ constructor(injector) {
35
+ this.injector = injector;
36
+ }
37
+ set(token) {
38
+ localStorage.setItem(this.tokenKey, token);
39
+ }
40
+ remove() {
41
+ localStorage.removeItem(this.tokenKey);
42
+ }
43
+ get() {
44
+ return localStorage.getItem(this.tokenKey);
45
+ }
46
+ decode() {
47
+ const token = this.get();
48
+ if (!token) {
49
+ return;
50
+ }
51
+ return jwtDecode(token);
52
+ }
53
+ isExpired() {
54
+ const jwt = this.decode();
55
+ const currentTime = new Date().getTime() / 1000;
56
+ if (jwt && currentTime < jwt.exp) {
57
+ return false;
58
+ }
59
+ return true;
60
+ }
61
+ get tokenKey() {
62
+ const config = this.injector.get(ConfigService);
63
+ this.options = config.getConfig('auth') || {};
64
+ return this.options.tokenKey;
65
+ }
66
+ }
67
+ TokenService.ɵfac = function TokenService_Factory(t) { return new (t || TokenService)(i0.ɵɵinject(i0.Injector)); };
68
+ TokenService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: TokenService, factory: TokenService.ɵfac, providedIn: 'root' });
69
+ (function () {
70
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TokenService, [{
71
+ type: Injectable,
72
+ args: [{
73
+ providedIn: 'root'
74
+ }]
75
+ }], function () { return [{ type: i0.Injector }]; }, null);
76
76
  })();
77
77
 
78
- class AuthService {
79
- constructor(http, tokenService, config, languageService, messageService, router) {
80
- this.http = http;
81
- this.tokenService = tokenService;
82
- this.config = config;
83
- this.languageService = languageService;
84
- this.messageService = messageService;
85
- this.router = router;
86
- this.authenticate$ = new BehaviorSubject(undefined);
87
- this.logged$ = new BehaviorSubject(undefined);
88
- this.languageForce = false;
89
- this.anonymous = false;
90
- this.authenticate$.next(this.authenticated);
91
- this.authenticate$.subscribe((authenticated) => {
92
- this.logged$.next(authenticated);
93
- globalCacheBusterNotifier.next();
94
- });
95
- }
96
- get hasAuthService() {
97
- return this.config.getConfig('auth.url') !== undefined;
98
- }
99
- login(username, password) {
100
- const myHeader = new HttpHeaders({ 'Content-Type': 'application/json' });
101
- const body = {
102
- username,
103
- password: this.encodePassword(password)
104
- };
105
- return this.loginCall(body, myHeader);
106
- }
107
- loginWithToken(token, type, infosUser) {
108
- const myHeader = new HttpHeaders({ 'Content-Type': 'application/json' });
109
- const body = {
110
- token,
111
- typeConnection: type,
112
- infosUser
113
- };
114
- return this.loginCall(body, myHeader);
115
- }
116
- loginAnonymous() {
117
- this.anonymous = true;
118
- this.logged$.next(true);
119
- return of(true);
120
- }
121
- refresh() {
122
- const url = this.config.getConfig('auth.url');
123
- return this.http.post(`${url}/refresh`, {}).pipe(tap((data) => {
124
- this.tokenService.set(data.token);
125
- }), catchError((err) => {
126
- err.error.caught = true;
127
- throw err;
128
- }));
129
- }
130
- logout() {
131
- this.anonymous = false;
132
- this.tokenService.remove();
133
- this.authenticate$.next(false);
134
- return of(true);
135
- }
136
- isAuthenticated() {
137
- return !this.tokenService.isExpired();
138
- }
139
- getToken() {
140
- return this.tokenService.get();
141
- }
142
- decodeToken() {
143
- if (this.isAuthenticated()) {
144
- return this.tokenService.decode();
145
- }
146
- return false;
147
- }
148
- goToRedirectUrl() {
149
- if (!this.router) {
150
- return;
151
- }
152
- const redirectUrl = this.redirectUrl || this.router.url;
153
- const options = this.config.getConfig('auth') || {};
154
- if (redirectUrl === options.loginRoute) {
155
- const homeRoute = options.homeRoute || '/';
156
- this.router.navigateByUrl(homeRoute);
157
- }
158
- else if (redirectUrl) {
159
- this.router.navigateByUrl(redirectUrl);
160
- }
161
- }
162
- getUserInfo() {
163
- const url = this.config.getConfig('auth.url') + '/info';
164
- return this.http.get(url);
165
- }
166
- getProfils() {
167
- const url = this.config.getConfig('auth.url');
168
- return this.http.get(`${url}/profils`);
169
- }
170
- updateUser(user) {
171
- const url = this.config.getConfig('auth.url');
172
- return this.http.patch(url, user);
173
- }
174
- encodePassword(password) {
175
- return Base64.encode(password);
176
- }
177
- // authenticated or anonymous
178
- get logged() {
179
- return this.authenticated || this.isAnonymous;
180
- }
181
- get isAnonymous() {
182
- return this.anonymous;
183
- }
184
- get authenticated() {
185
- return this.isAuthenticated();
186
- }
187
- get isAdmin() {
188
- const token = this.decodeToken();
189
- if (token && token.user && token.user.isAdmin) {
190
- return true;
191
- }
192
- return false;
193
- }
194
- loginCall(body, headers) {
195
- const url = this.config.getConfig('auth.url');
196
- return this.http.post(`${url}/login`, body, { headers }).pipe(tap((data) => {
197
- this.tokenService.set(data.token);
198
- const tokenDecoded = this.decodeToken();
199
- if (tokenDecoded && tokenDecoded.user) {
200
- if (tokenDecoded.user.locale && !this.languageForce) {
201
- this.languageService.setLanguage(tokenDecoded.user.locale);
202
- }
203
- if (tokenDecoded.user.isExpired) {
204
- this.messageService.alert('igo.auth.error.Password expired');
205
- }
206
- }
207
- this.authenticate$.next(true);
208
- }), catchError((err) => {
209
- err.error.caught = true;
210
- throw err;
211
- }));
212
- }
213
- }
214
- AuthService.ɵfac = function AuthService_Factory(t) { return new (t || AuthService)(i0.ɵɵinject(i1.HttpClient), i0.ɵɵinject(TokenService), i0.ɵɵinject(i2.ConfigService), i0.ɵɵinject(i2.LanguageService), i0.ɵɵinject(i2.MessageService), i0.ɵɵinject(i3.Router, 8)); };
215
- AuthService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AuthService, factory: AuthService.ɵfac, providedIn: 'root' });
216
- (function () {
217
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthService, [{
218
- type: Injectable,
219
- args: [{
220
- providedIn: 'root'
221
- }]
222
- }], function () {
223
- return [{ type: i1.HttpClient }, { type: TokenService }, { type: i2.ConfigService }, { type: i2.LanguageService }, { type: i2.MessageService }, { type: i3.Router, decorators: [{
224
- type: Optional
225
- }] }];
226
- }, null);
78
+ class AuthService {
79
+ constructor(http, tokenService, config, languageService, messageService, router) {
80
+ this.http = http;
81
+ this.tokenService = tokenService;
82
+ this.config = config;
83
+ this.languageService = languageService;
84
+ this.messageService = messageService;
85
+ this.router = router;
86
+ this.authenticate$ = new BehaviorSubject(undefined);
87
+ this.logged$ = new BehaviorSubject(undefined);
88
+ this.languageForce = false;
89
+ this.anonymous = false;
90
+ this.authenticate$.next(this.authenticated);
91
+ this.authenticate$.subscribe((authenticated) => {
92
+ this.logged$.next(authenticated);
93
+ globalCacheBusterNotifier.next();
94
+ });
95
+ }
96
+ get hasAuthService() {
97
+ return this.config.getConfig('auth.url') !== undefined;
98
+ }
99
+ login(username, password) {
100
+ const myHeader = new HttpHeaders({ 'Content-Type': 'application/json' });
101
+ const body = {
102
+ username,
103
+ password: this.encodePassword(password)
104
+ };
105
+ return this.loginCall(body, myHeader);
106
+ }
107
+ loginWithToken(token, type, infosUser) {
108
+ const myHeader = new HttpHeaders({ 'Content-Type': 'application/json' });
109
+ const body = {
110
+ token,
111
+ typeConnection: type,
112
+ infosUser
113
+ };
114
+ return this.loginCall(body, myHeader);
115
+ }
116
+ loginAnonymous() {
117
+ this.anonymous = true;
118
+ this.logged$.next(true);
119
+ return of(true);
120
+ }
121
+ refresh() {
122
+ const url = this.config.getConfig('auth.url');
123
+ return this.http.post(`${url}/refresh`, {}).pipe(tap((data) => {
124
+ this.tokenService.set(data.token);
125
+ }), catchError((err) => {
126
+ err.error.caught = true;
127
+ throw err;
128
+ }));
129
+ }
130
+ logout() {
131
+ this.anonymous = false;
132
+ this.tokenService.remove();
133
+ this.authenticate$.next(false);
134
+ return of(true);
135
+ }
136
+ isAuthenticated() {
137
+ return !this.tokenService.isExpired();
138
+ }
139
+ getToken() {
140
+ return this.tokenService.get();
141
+ }
142
+ decodeToken() {
143
+ if (this.isAuthenticated()) {
144
+ return this.tokenService.decode();
145
+ }
146
+ return false;
147
+ }
148
+ goToRedirectUrl() {
149
+ if (!this.router) {
150
+ return;
151
+ }
152
+ const redirectUrl = this.redirectUrl || this.router.url;
153
+ const options = this.config.getConfig('auth') || {};
154
+ if (redirectUrl === options.loginRoute) {
155
+ const homeRoute = options.homeRoute || '/';
156
+ this.router.navigateByUrl(homeRoute);
157
+ }
158
+ else if (redirectUrl) {
159
+ this.router.navigateByUrl(redirectUrl);
160
+ }
161
+ }
162
+ getUserInfo() {
163
+ const url = this.config.getConfig('auth.url') + '/info';
164
+ return this.http.get(url);
165
+ }
166
+ getProfils() {
167
+ const url = this.config.getConfig('auth.url');
168
+ return this.http.get(`${url}/profils`);
169
+ }
170
+ updateUser(user) {
171
+ const url = this.config.getConfig('auth.url');
172
+ return this.http.patch(url, user);
173
+ }
174
+ encodePassword(password) {
175
+ return Base64.encode(password);
176
+ }
177
+ // authenticated or anonymous
178
+ get logged() {
179
+ return this.authenticated || this.isAnonymous;
180
+ }
181
+ get isAnonymous() {
182
+ return this.anonymous;
183
+ }
184
+ get authenticated() {
185
+ return this.isAuthenticated();
186
+ }
187
+ get isAdmin() {
188
+ const token = this.decodeToken();
189
+ if (token && token.user && token.user.isAdmin) {
190
+ return true;
191
+ }
192
+ return false;
193
+ }
194
+ loginCall(body, headers) {
195
+ const url = this.config.getConfig('auth.url');
196
+ return this.http.post(`${url}/login`, body, { headers }).pipe(tap((data) => {
197
+ this.tokenService.set(data.token);
198
+ const tokenDecoded = this.decodeToken();
199
+ if (tokenDecoded && tokenDecoded.user) {
200
+ if (tokenDecoded.user.locale && !this.languageForce) {
201
+ this.languageService.setLanguage(tokenDecoded.user.locale);
202
+ }
203
+ if (tokenDecoded.user.isExpired) {
204
+ this.messageService.alert('igo.auth.error.Password expired');
205
+ }
206
+ }
207
+ this.authenticate$.next(true);
208
+ }), catchError((err) => {
209
+ err.error.caught = true;
210
+ throw err;
211
+ }));
212
+ }
213
+ }
214
+ AuthService.ɵfac = function AuthService_Factory(t) { return new (t || AuthService)(i0.ɵɵinject(i1.HttpClient), i0.ɵɵinject(TokenService), i0.ɵɵinject(i2.ConfigService), i0.ɵɵinject(i2.LanguageService), i0.ɵɵinject(i2.MessageService), i0.ɵɵinject(i3.Router, 8)); };
215
+ AuthService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AuthService, factory: AuthService.ɵfac, providedIn: 'root' });
216
+ (function () {
217
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthService, [{
218
+ type: Injectable,
219
+ args: [{
220
+ providedIn: 'root'
221
+ }]
222
+ }], function () {
223
+ return [{ type: i1.HttpClient }, { type: TokenService }, { type: i2.ConfigService }, { type: i2.LanguageService }, { type: i2.MessageService }, { type: i3.Router, decorators: [{
224
+ type: Optional
225
+ }] }];
226
+ }, null);
227
227
  })();
228
228
 
229
- class AuthGoogleComponent {
230
- constructor(authService, config, languageService, appRef) {
231
- this.authService = authService;
232
- this.config = config;
233
- this.languageService = languageService;
234
- this.appRef = appRef;
235
- this.login = new EventEmitter();
236
- this.options = this.config.getConfig('auth.google') || {};
237
- if (this.options.apiKey && this.options.clientId) {
238
- this.loadSDKGoogle();
239
- this.loadPlatform();
240
- }
241
- else {
242
- console.warn('Google authentification needs "apiKey" and "clientId" options');
243
- }
244
- }
245
- handleSignInClick() {
246
- window.gapi.auth2.getAuthInstance().signIn();
247
- }
248
- handleSignOutClick() {
249
- window.gapi.auth2.getAuthInstance().signOut();
250
- }
251
- handleClientLoad() {
252
- window.gapi.load('client:auth2', () => this.initClient());
253
- }
254
- initClient() {
255
- window.gapi.client
256
- .init({
257
- apiKey: this.options.apiKey,
258
- clientId: this.options.clientId,
259
- discoveryDocs: [
260
- 'https://people.googleapis.com/$discovery/rest?version=v1'
261
- ],
262
- scope: 'profile'
263
- })
264
- .then(() => {
265
- this.handleSignOutClick();
266
- this.updateTextButton();
267
- window.gapi.auth2.getAuthInstance().isSignedIn.listen(rep => {
268
- this.updateSigninStatus(rep);
269
- });
270
- });
271
- }
272
- updateSigninStatus(isSignedIn) {
273
- this.updateTextButton();
274
- if (isSignedIn) {
275
- this.loginGoogle(window.gapi.client.getToken().access_token);
276
- }
277
- }
278
- updateTextButton() {
279
- const btn = document.querySelector('span[id^="not_signed_"]');
280
- if (btn && this.languageService.getLanguage() !== 'en') {
281
- if (btn.innerHTML === 'Sign in with Google') {
282
- btn.innerHTML = this.languageService.translate.instant('igo.auth.google.login');
283
- }
284
- else if (btn.innerHTML === 'Signed in with Google') {
285
- btn.innerHTML = this.languageService.translate.instant('igo.auth.google.logged');
286
- }
287
- }
288
- }
289
- loginGoogle(token) {
290
- this.authService.loginWithToken(token, 'google').subscribe(() => {
291
- this.appRef.tick();
292
- this.login.emit(true);
293
- });
294
- }
295
- loadSDKGoogle() {
296
- const fjs = document.getElementsByTagName('script')[0];
297
- const js = document.createElement('script');
298
- js.id = 'google-jssdk';
299
- js.src = 'https://apis.google.com/js/api.js';
300
- js.onload = () => {
301
- this.handleClientLoad();
302
- };
303
- fjs.parentNode.insertBefore(js, fjs);
304
- }
305
- loadPlatform() {
306
- const fjs = document.getElementsByTagName('script')[0];
307
- const js = document.createElement('script');
308
- js.id = 'google-platform';
309
- js.src = 'https://apis.google.com/js/platform.js';
310
- fjs.parentNode.insertBefore(js, fjs);
311
- }
312
- }
313
- AuthGoogleComponent.ɵfac = function AuthGoogleComponent_Factory(t) { return new (t || AuthGoogleComponent)(i0.ɵɵdirectiveInject(AuthService), i0.ɵɵdirectiveInject(i2.ConfigService), i0.ɵɵdirectiveInject(i2.LanguageService), i0.ɵɵdirectiveInject(i0.ApplicationRef)); };
314
- AuthGoogleComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AuthGoogleComponent, selectors: [["igo-auth-google"]], outputs: { login: "login" }, decls: 1, vars: 0, consts: [["data-height", "40", "data-width", "265", "data-longtitle", "true", 1, "g-signin2", "google-login-button"]], template: function AuthGoogleComponent_Template(rf, ctx) {
315
- if (rf & 1) {
316
- i0.ɵɵelement(0, "div", 0);
317
- }
318
- }, styles: ["[_nghost-%COMP%]{padding:10px 10px 10px 0;display:inline-block}.google-login-button[_ngcontent-%COMP%] .abcRioButton{color:#000000de}"], changeDetection: 0 });
319
- (function () {
320
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthGoogleComponent, [{
321
- type: Component,
322
- args: [{ selector: 'igo-auth-google', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"g-signin2 google-login-button\" data-height=\"40\" data-width=\"265\" data-longtitle=\"true\">\n", styles: [":host{padding:10px 10px 10px 0;display:inline-block}.google-login-button ::ng-deep .abcRioButton{color:#000000de}\n"] }]
323
- }], function () { return [{ type: AuthService }, { type: i2.ConfigService }, { type: i2.LanguageService }, { type: i0.ApplicationRef }]; }, { login: [{
324
- type: Output
325
- }] });
229
+ class AuthGoogleComponent {
230
+ constructor(authService, config, languageService, appRef) {
231
+ this.authService = authService;
232
+ this.config = config;
233
+ this.languageService = languageService;
234
+ this.appRef = appRef;
235
+ this.login = new EventEmitter();
236
+ this.options = this.config.getConfig('auth.google') || {};
237
+ if (this.options.apiKey && this.options.clientId) {
238
+ this.loadSDKGoogle();
239
+ this.loadPlatform();
240
+ }
241
+ else {
242
+ console.warn('Google authentification needs "apiKey" and "clientId" options');
243
+ }
244
+ }
245
+ handleSignInClick() {
246
+ window.gapi.auth2.getAuthInstance().signIn();
247
+ }
248
+ handleSignOutClick() {
249
+ window.gapi.auth2.getAuthInstance().signOut();
250
+ }
251
+ handleClientLoad() {
252
+ window.gapi.load('client:auth2', () => this.initClient());
253
+ }
254
+ initClient() {
255
+ window.gapi.client
256
+ .init({
257
+ apiKey: this.options.apiKey,
258
+ clientId: this.options.clientId,
259
+ discoveryDocs: [
260
+ 'https://people.googleapis.com/$discovery/rest?version=v1'
261
+ ],
262
+ scope: 'profile'
263
+ })
264
+ .then(() => {
265
+ this.handleSignOutClick();
266
+ this.updateTextButton();
267
+ window.gapi.auth2.getAuthInstance().isSignedIn.listen(rep => {
268
+ this.updateSigninStatus(rep);
269
+ });
270
+ });
271
+ }
272
+ updateSigninStatus(isSignedIn) {
273
+ this.updateTextButton();
274
+ if (isSignedIn) {
275
+ this.loginGoogle(window.gapi.client.getToken().access_token);
276
+ }
277
+ }
278
+ updateTextButton() {
279
+ const btn = document.querySelector('span[id^="not_signed_"]');
280
+ if (btn && this.languageService.getLanguage() !== 'en') {
281
+ if (btn.innerHTML === 'Sign in with Google') {
282
+ btn.innerHTML = this.languageService.translate.instant('igo.auth.google.login');
283
+ }
284
+ else if (btn.innerHTML === 'Signed in with Google') {
285
+ btn.innerHTML = this.languageService.translate.instant('igo.auth.google.logged');
286
+ }
287
+ }
288
+ }
289
+ loginGoogle(token) {
290
+ this.authService.loginWithToken(token, 'google').subscribe(() => {
291
+ this.appRef.tick();
292
+ this.login.emit(true);
293
+ });
294
+ }
295
+ loadSDKGoogle() {
296
+ const fjs = document.getElementsByTagName('script')[0];
297
+ const js = document.createElement('script');
298
+ js.id = 'google-jssdk';
299
+ js.src = 'https://apis.google.com/js/api.js';
300
+ js.onload = () => {
301
+ this.handleClientLoad();
302
+ };
303
+ fjs.parentNode.insertBefore(js, fjs);
304
+ }
305
+ loadPlatform() {
306
+ const fjs = document.getElementsByTagName('script')[0];
307
+ const js = document.createElement('script');
308
+ js.id = 'google-platform';
309
+ js.src = 'https://apis.google.com/js/platform.js';
310
+ fjs.parentNode.insertBefore(js, fjs);
311
+ }
312
+ }
313
+ AuthGoogleComponent.ɵfac = function AuthGoogleComponent_Factory(t) { return new (t || AuthGoogleComponent)(i0.ɵɵdirectiveInject(AuthService), i0.ɵɵdirectiveInject(i2.ConfigService), i0.ɵɵdirectiveInject(i2.LanguageService), i0.ɵɵdirectiveInject(i0.ApplicationRef)); };
314
+ AuthGoogleComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AuthGoogleComponent, selectors: [["igo-auth-google"]], outputs: { login: "login" }, decls: 1, vars: 0, consts: [["data-height", "40", "data-width", "265", "data-longtitle", "true", 1, "g-signin2", "google-login-button"]], template: function AuthGoogleComponent_Template(rf, ctx) {
315
+ if (rf & 1) {
316
+ i0.ɵɵelement(0, "div", 0);
317
+ }
318
+ }, styles: ["[_nghost-%COMP%]{padding:10px 10px 10px 0;display:inline-block}.google-login-button[_ngcontent-%COMP%] .abcRioButton{color:#000000de}"], changeDetection: 0 });
319
+ (function () {
320
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthGoogleComponent, [{
321
+ type: Component,
322
+ args: [{ selector: 'igo-auth-google', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"g-signin2 google-login-button\" data-height=\"40\" data-width=\"265\" data-longtitle=\"true\">\n", styles: [":host{padding:10px 10px 10px 0;display:inline-block}.google-login-button ::ng-deep .abcRioButton{color:#000000de}\n"] }]
323
+ }], function () { return [{ type: AuthService }, { type: i2.ConfigService }, { type: i2.LanguageService }, { type: i0.ApplicationRef }]; }, { login: [{
324
+ type: Output
325
+ }] });
326
326
  })();
327
327
 
328
- function AuthInternComponent_button_12_Template(rf, ctx) {
329
- if (rf & 1) {
330
- const _r3 = i0.ɵɵgetCurrentView();
331
- i0.ɵɵelementStart(0, "button", 7);
332
- i0.ɵɵlistener("click", function AuthInternComponent_button_12_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r3); const ctx_r2 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r2.loginAnonymous()); });
333
- i0.ɵɵtext(1);
334
- i0.ɵɵpipe(2, "translate");
335
- i0.ɵɵelementEnd();
336
- }
337
- if (rf & 2) {
338
- const ctx_r0 = i0.ɵɵnextContext();
339
- i0.ɵɵproperty("disabled", ctx_r0.loading);
340
- i0.ɵɵadvance(1);
341
- i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(2, 2, "igo.auth.accessAnonymous"), " ");
342
- }
343
- }
344
- function AuthInternComponent_div_13_Template(rf, ctx) {
345
- if (rf & 1) {
346
- i0.ɵɵelementStart(0, "div");
347
- i0.ɵɵelement(1, "br");
348
- i0.ɵɵelementStart(2, "font", 8);
349
- i0.ɵɵtext(3);
350
- i0.ɵɵelementEnd()();
351
- }
352
- if (rf & 2) {
353
- const ctx_r1 = i0.ɵɵnextContext();
354
- i0.ɵɵadvance(3);
355
- i0.ɵɵtextInterpolate(ctx_r1.error);
356
- }
357
- }
358
- class AuthInternComponent {
359
- constructor(auth, languageService, fb) {
360
- this.auth = auth;
361
- this.languageService = languageService;
362
- this._allowAnonymous = true;
363
- this.error = '';
364
- this.loading = false;
365
- this.login = new EventEmitter();
366
- this.form = fb.group({
367
- username: ['', Validators.required],
368
- password: ['', Validators.required]
369
- });
370
- }
371
- get allowAnonymous() {
372
- return this._allowAnonymous;
373
- }
374
- set allowAnonymous(value) {
375
- this._allowAnonymous = value;
376
- }
377
- loginUser(values) {
378
- this.loading = true;
379
- this.auth.login(values.username, values.password).subscribe(() => {
380
- this.login.emit(true);
381
- this.loading = false;
382
- }, (error) => {
383
- try {
384
- this.languageService.translate
385
- .get('igo.auth.error.' + error.error.message)
386
- .subscribe(errorMsg => (this.error = errorMsg));
387
- }
388
- catch (e) {
389
- this.error = error.error.message;
390
- }
391
- this.loading = false;
392
- });
393
- return false;
394
- }
395
- loginAnonymous() {
396
- this.auth.loginAnonymous().subscribe(() => {
397
- this.login.emit(true);
398
- });
399
- }
400
- }
401
- AuthInternComponent.ɵfac = function AuthInternComponent_Factory(t) { return new (t || AuthInternComponent)(i0.ɵɵdirectiveInject(AuthService), i0.ɵɵdirectiveInject(i2.LanguageService), i0.ɵɵdirectiveInject(i3$1.UntypedFormBuilder)); };
402
- AuthInternComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AuthInternComponent, selectors: [["igo-auth-intern"]], inputs: { allowAnonymous: "allowAnonymous" }, outputs: { login: "login" }, decls: 14, vars: 12, consts: [["role", "form", 3, "formGroup", "ngSubmit"], [1, "full-width"], ["matInput", "", "required", "", "formControlName", "username", 3, "placeholder"], ["matInput", "", "required", "", "type", "password", "formControlName", "password", 3, "placeholder"], ["mat-raised-button", "", "type", "submit"], ["mat-raised-button", "", "class", "anonymous", "type", "button", 3, "disabled", "click", 4, "ngIf"], [4, "ngIf"], ["mat-raised-button", "", "type", "button", 1, "anonymous", 3, "disabled", "click"], ["size", "3", "color", "red"]], template: function AuthInternComponent_Template(rf, ctx) {
403
- if (rf & 1) {
404
- i0.ɵɵelementStart(0, "form", 0);
405
- i0.ɵɵlistener("ngSubmit", function AuthInternComponent_Template_form_ngSubmit_0_listener() { return ctx.loginUser(ctx.form.value); });
406
- i0.ɵɵelementStart(1, "div")(2, "mat-form-field", 1);
407
- i0.ɵɵelement(3, "input", 2);
408
- i0.ɵɵpipe(4, "translate");
409
- i0.ɵɵelementEnd()();
410
- i0.ɵɵelementStart(5, "div")(6, "mat-form-field", 1);
411
- i0.ɵɵelement(7, "input", 3);
412
- i0.ɵɵpipe(8, "translate");
413
- i0.ɵɵelementEnd()();
414
- i0.ɵɵelementStart(9, "button", 4);
415
- i0.ɵɵtext(10);
416
- i0.ɵɵpipe(11, "translate");
417
- i0.ɵɵelementEnd();
418
- i0.ɵɵtemplate(12, AuthInternComponent_button_12_Template, 3, 4, "button", 5);
419
- i0.ɵɵtemplate(13, AuthInternComponent_div_13_Template, 4, 1, "div", 6);
420
- i0.ɵɵelementEnd();
421
- }
422
- if (rf & 2) {
423
- i0.ɵɵproperty("formGroup", ctx.form);
424
- i0.ɵɵadvance(3);
425
- i0.ɵɵpropertyInterpolate("placeholder", i0.ɵɵpipeBind1(4, 6, "igo.auth.user"));
426
- i0.ɵɵadvance(4);
427
- i0.ɵɵpropertyInterpolate("placeholder", i0.ɵɵpipeBind1(8, 8, "igo.auth.password"));
428
- i0.ɵɵadvance(3);
429
- i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(11, 10, "igo.auth.login"));
430
- i0.ɵɵadvance(2);
431
- i0.ɵɵproperty("ngIf", ctx.allowAnonymous);
432
- i0.ɵɵadvance(1);
433
- i0.ɵɵproperty("ngIf", ctx.error);
434
- }
435
- }, dependencies: [i1$1.NgIf, i3$1.ɵNgNoValidate, i3$1.DefaultValueAccessor, i3$1.NgControlStatus, i3$1.NgControlStatusGroup, i3$1.RequiredValidator, i3$1.FormGroupDirective, i3$1.FormControlName, i5.MatFormField, i6.MatInput, i5$1.MatButton, i6$1.TranslatePipe], styles: [".full-width[_ngcontent-%COMP%]{width:100%}.anonymous[_ngcontent-%COMP%]{margin-left:10px}"] });
436
- (function () {
437
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthInternComponent, [{
438
- type: Component,
439
- args: [{ selector: 'igo-auth-intern', changeDetection: ChangeDetectionStrategy.Default, template: "<form [formGroup]=\"form\" role=\"form\" (ngSubmit)=\"loginUser(form.value)\">\n <div>\n <mat-form-field class=\"full-width\">\n <input matInput required placeholder=\"{{'igo.auth.user' | translate}}\" formControlName=\"username\">\n </mat-form-field>\n </div>\n\n <div>\n <mat-form-field class=\"full-width\">\n <input matInput required type=\"password\" placeholder=\"{{'igo.auth.password' | translate}}\" formControlName=\"password\">\n </mat-form-field>\n </div>\n\n <button mat-raised-button type=\"submit\">{{'igo.auth.login' | translate}}</button>\n <button *ngIf=\"allowAnonymous\" mat-raised-button class=\"anonymous\" type=\"button\" [disabled]=\"loading\" (click)=\"loginAnonymous()\">\n {{'igo.auth.accessAnonymous' | translate }}\n </button>\n <div *ngIf=\"error\">\n <br/>\n <font size=\"3\" color=\"red\">{{error}}</font>\n </div>\n</form>\n\n<!--\nThis part was removed from the below line to fix Angular issue 30616 : [disabled]=\"!form.valid || loading\n <button mat-raised-button type=\"submit\" [disabled]=\"!form.valid || loading\">{{'igo.auth.login' | translate}}</button>*/\n-->\n", styles: [".full-width{width:100%}.anonymous{margin-left:10px}\n"] }]
440
- }], function () { return [{ type: AuthService }, { type: i2.LanguageService }, { type: i3$1.UntypedFormBuilder }]; }, { allowAnonymous: [{
441
- type: Input
442
- }], login: [{
443
- type: Output
444
- }] });
328
+ function AuthInternComponent_button_12_Template(rf, ctx) {
329
+ if (rf & 1) {
330
+ const _r3 = i0.ɵɵgetCurrentView();
331
+ i0.ɵɵelementStart(0, "button", 7);
332
+ i0.ɵɵlistener("click", function AuthInternComponent_button_12_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r3); const ctx_r2 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r2.loginAnonymous()); });
333
+ i0.ɵɵtext(1);
334
+ i0.ɵɵpipe(2, "translate");
335
+ i0.ɵɵelementEnd();
336
+ }
337
+ if (rf & 2) {
338
+ const ctx_r0 = i0.ɵɵnextContext();
339
+ i0.ɵɵproperty("disabled", ctx_r0.loading);
340
+ i0.ɵɵadvance(1);
341
+ i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(2, 2, "igo.auth.accessAnonymous"), " ");
342
+ }
343
+ }
344
+ function AuthInternComponent_div_13_Template(rf, ctx) {
345
+ if (rf & 1) {
346
+ i0.ɵɵelementStart(0, "div");
347
+ i0.ɵɵelement(1, "br");
348
+ i0.ɵɵelementStart(2, "font", 8);
349
+ i0.ɵɵtext(3);
350
+ i0.ɵɵelementEnd()();
351
+ }
352
+ if (rf & 2) {
353
+ const ctx_r1 = i0.ɵɵnextContext();
354
+ i0.ɵɵadvance(3);
355
+ i0.ɵɵtextInterpolate(ctx_r1.error);
356
+ }
357
+ }
358
+ class AuthInternComponent {
359
+ constructor(auth, languageService, fb) {
360
+ this.auth = auth;
361
+ this.languageService = languageService;
362
+ this._allowAnonymous = true;
363
+ this.error = '';
364
+ this.loading = false;
365
+ this.login = new EventEmitter();
366
+ this.form = fb.group({
367
+ username: ['', Validators.required],
368
+ password: ['', Validators.required]
369
+ });
370
+ }
371
+ get allowAnonymous() {
372
+ return this._allowAnonymous;
373
+ }
374
+ set allowAnonymous(value) {
375
+ this._allowAnonymous = value;
376
+ }
377
+ loginUser(values) {
378
+ this.loading = true;
379
+ this.auth.login(values.username, values.password).subscribe(() => {
380
+ this.login.emit(true);
381
+ this.loading = false;
382
+ }, (error) => {
383
+ try {
384
+ this.languageService.translate
385
+ .get('igo.auth.error.' + error.error.message)
386
+ .subscribe(errorMsg => (this.error = errorMsg));
387
+ }
388
+ catch (e) {
389
+ this.error = error.error.message;
390
+ }
391
+ this.loading = false;
392
+ });
393
+ return false;
394
+ }
395
+ loginAnonymous() {
396
+ this.auth.loginAnonymous().subscribe(() => {
397
+ this.login.emit(true);
398
+ });
399
+ }
400
+ }
401
+ AuthInternComponent.ɵfac = function AuthInternComponent_Factory(t) { return new (t || AuthInternComponent)(i0.ɵɵdirectiveInject(AuthService), i0.ɵɵdirectiveInject(i2.LanguageService), i0.ɵɵdirectiveInject(i3$1.UntypedFormBuilder)); };
402
+ AuthInternComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AuthInternComponent, selectors: [["igo-auth-intern"]], inputs: { allowAnonymous: "allowAnonymous" }, outputs: { login: "login" }, decls: 14, vars: 12, consts: [["role", "form", 3, "formGroup", "ngSubmit"], [1, "full-width"], ["matInput", "", "required", "", "formControlName", "username", 3, "placeholder"], ["matInput", "", "required", "", "type", "password", "formControlName", "password", 3, "placeholder"], ["mat-raised-button", "", "type", "submit"], ["mat-raised-button", "", "class", "anonymous", "type", "button", 3, "disabled", "click", 4, "ngIf"], [4, "ngIf"], ["mat-raised-button", "", "type", "button", 1, "anonymous", 3, "disabled", "click"], ["size", "3", "color", "red"]], template: function AuthInternComponent_Template(rf, ctx) {
403
+ if (rf & 1) {
404
+ i0.ɵɵelementStart(0, "form", 0);
405
+ i0.ɵɵlistener("ngSubmit", function AuthInternComponent_Template_form_ngSubmit_0_listener() { return ctx.loginUser(ctx.form.value); });
406
+ i0.ɵɵelementStart(1, "div")(2, "mat-form-field", 1);
407
+ i0.ɵɵelement(3, "input", 2);
408
+ i0.ɵɵpipe(4, "translate");
409
+ i0.ɵɵelementEnd()();
410
+ i0.ɵɵelementStart(5, "div")(6, "mat-form-field", 1);
411
+ i0.ɵɵelement(7, "input", 3);
412
+ i0.ɵɵpipe(8, "translate");
413
+ i0.ɵɵelementEnd()();
414
+ i0.ɵɵelementStart(9, "button", 4);
415
+ i0.ɵɵtext(10);
416
+ i0.ɵɵpipe(11, "translate");
417
+ i0.ɵɵelementEnd();
418
+ i0.ɵɵtemplate(12, AuthInternComponent_button_12_Template, 3, 4, "button", 5);
419
+ i0.ɵɵtemplate(13, AuthInternComponent_div_13_Template, 4, 1, "div", 6);
420
+ i0.ɵɵelementEnd();
421
+ }
422
+ if (rf & 2) {
423
+ i0.ɵɵproperty("formGroup", ctx.form);
424
+ i0.ɵɵadvance(3);
425
+ i0.ɵɵpropertyInterpolate("placeholder", i0.ɵɵpipeBind1(4, 6, "igo.auth.user"));
426
+ i0.ɵɵadvance(4);
427
+ i0.ɵɵpropertyInterpolate("placeholder", i0.ɵɵpipeBind1(8, 8, "igo.auth.password"));
428
+ i0.ɵɵadvance(3);
429
+ i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(11, 10, "igo.auth.login"));
430
+ i0.ɵɵadvance(2);
431
+ i0.ɵɵproperty("ngIf", ctx.allowAnonymous);
432
+ i0.ɵɵadvance(1);
433
+ i0.ɵɵproperty("ngIf", ctx.error);
434
+ }
435
+ }, dependencies: [i1$1.NgIf, i3$1.ɵNgNoValidate, i3$1.DefaultValueAccessor, i3$1.NgControlStatus, i3$1.NgControlStatusGroup, i3$1.RequiredValidator, i3$1.FormGroupDirective, i3$1.FormControlName, i5.MatFormField, i6.MatInput, i5$1.MatButton, i6$1.TranslatePipe], styles: [".full-width[_ngcontent-%COMP%]{width:100%}.anonymous[_ngcontent-%COMP%]{margin-left:10px}"] });
436
+ (function () {
437
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthInternComponent, [{
438
+ type: Component,
439
+ args: [{ selector: 'igo-auth-intern', changeDetection: ChangeDetectionStrategy.Default, template: "<form [formGroup]=\"form\" role=\"form\" (ngSubmit)=\"loginUser(form.value)\">\n <div>\n <mat-form-field class=\"full-width\">\n <input matInput required placeholder=\"{{'igo.auth.user' | translate}}\" formControlName=\"username\">\n </mat-form-field>\n </div>\n\n <div>\n <mat-form-field class=\"full-width\">\n <input matInput required type=\"password\" placeholder=\"{{'igo.auth.password' | translate}}\" formControlName=\"password\">\n </mat-form-field>\n </div>\n\n <button mat-raised-button type=\"submit\">{{'igo.auth.login' | translate}}</button>\n <button *ngIf=\"allowAnonymous\" mat-raised-button class=\"anonymous\" type=\"button\" [disabled]=\"loading\" (click)=\"loginAnonymous()\">\n {{'igo.auth.accessAnonymous' | translate }}\n </button>\n <div *ngIf=\"error\">\n <br/>\n <font size=\"3\" color=\"red\">{{error}}</font>\n </div>\n</form>\n\n<!--\nThis part was removed from the below line to fix Angular issue 30616 : [disabled]=\"!form.valid || loading\n <button mat-raised-button type=\"submit\" [disabled]=\"!form.valid || loading\">{{'igo.auth.login' | translate}}</button>*/\n-->\n", styles: [".full-width{width:100%}.anonymous{margin-left:10px}\n"] }]
440
+ }], function () { return [{ type: AuthService }, { type: i2.LanguageService }, { type: i3$1.UntypedFormBuilder }]; }, { allowAnonymous: [{
441
+ type: Input
442
+ }], login: [{
443
+ type: Output
444
+ }] });
445
445
  })();
446
446
 
447
- class AuthFacebookComponent {
448
- constructor(authService, config, appRef) {
449
- this.authService = authService;
450
- this.config = config;
451
- this.appRef = appRef;
452
- this.login = new EventEmitter();
453
- this.options = this.config.getConfig('auth.facebook') || {};
454
- if (this.options.appId) {
455
- this.loadSDKFacebook();
456
- }
457
- else {
458
- console.warn('Facebook authentification needs "appId" option');
459
- }
460
- }
461
- subscribeEvents() {
462
- window.FB.Event.subscribe('auth.statusChange', rep => {
463
- this.statusChangeCallback(rep);
464
- });
465
- }
466
- statusChangeCallback(response) {
467
- if (response.status === 'connected') {
468
- const accessToken = response.authResponse.accessToken;
469
- this.loginFacebook(accessToken);
470
- }
471
- }
472
- loginFacebook(token) {
473
- this.authService.loginWithToken(token, 'facebook').subscribe(() => {
474
- this.appRef.tick();
475
- this.login.emit(true);
476
- });
477
- }
478
- loadSDKFacebook() {
479
- if (document.getElementById('facebook-jssdk')) {
480
- return;
481
- }
482
- const urlSDK = 'https://connect.facebook.net/fr_CA/sdk.js#xfbml=1&version=v2.9';
483
- const fjs = document.getElementsByTagName('script')[0];
484
- const js = document.createElement('script');
485
- js.id = 'facebook-jssdk';
486
- js.src = `${urlSDK}&appId=${this.options.appId}`;
487
- js.onload = () => {
488
- this.subscribeEvents();
489
- };
490
- fjs.parentNode.insertBefore(js, fjs);
491
- }
492
- }
493
- AuthFacebookComponent.ɵfac = function AuthFacebookComponent_Factory(t) { return new (t || AuthFacebookComponent)(i0.ɵɵdirectiveInject(AuthService), i0.ɵɵdirectiveInject(i2.ConfigService), i0.ɵɵdirectiveInject(i0.ApplicationRef)); };
494
- AuthFacebookComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AuthFacebookComponent, selectors: [["igo-auth-facebook"]], outputs: { login: "login" }, decls: 1, vars: 0, consts: [["scope", "public_profile,email", "data-max-rows", "1", "data-size", "large", "data-button-type", "login_with", "data-show-faces", "false", "data-auto-logout-link", "false", "data-use-continue-as", "false", 1, "fb-login-button"]], template: function AuthFacebookComponent_Template(rf, ctx) {
495
- if (rf & 1) {
496
- i0.ɵɵelement(0, "div", 0);
497
- }
498
- }, styles: ["[_nghost-%COMP%]{padding:10px 10px 10px 0;display:inline-block;position:relative;top:-3px}"], changeDetection: 0 });
499
- (function () {
500
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthFacebookComponent, [{
501
- type: Component,
502
- args: [{ selector: 'igo-auth-facebook', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div scope=\"public_profile,email\"\n class=\"fb-login-button\" data-max-rows=\"1\" data-size=\"large\"\n data-button-type=\"login_with\" data-show-faces=\"false\"\n data-auto-logout-link=\"false\" data-use-continue-as=\"false\">\n</div>\n", styles: [":host{padding:10px 10px 10px 0;display:inline-block;position:relative;top:-3px}\n"] }]
503
- }], function () { return [{ type: AuthService }, { type: i2.ConfigService }, { type: i0.ApplicationRef }]; }, { login: [{
504
- type: Output
505
- }] });
447
+ class AuthFacebookComponent {
448
+ constructor(authService, config, appRef) {
449
+ this.authService = authService;
450
+ this.config = config;
451
+ this.appRef = appRef;
452
+ this.login = new EventEmitter();
453
+ this.options = this.config.getConfig('auth.facebook') || {};
454
+ if (this.options.appId) {
455
+ this.loadSDKFacebook();
456
+ }
457
+ else {
458
+ console.warn('Facebook authentification needs "appId" option');
459
+ }
460
+ }
461
+ subscribeEvents() {
462
+ window.FB.Event.subscribe('auth.statusChange', rep => {
463
+ this.statusChangeCallback(rep);
464
+ });
465
+ }
466
+ statusChangeCallback(response) {
467
+ if (response.status === 'connected') {
468
+ const accessToken = response.authResponse.accessToken;
469
+ this.loginFacebook(accessToken);
470
+ }
471
+ }
472
+ loginFacebook(token) {
473
+ this.authService.loginWithToken(token, 'facebook').subscribe(() => {
474
+ this.appRef.tick();
475
+ this.login.emit(true);
476
+ });
477
+ }
478
+ loadSDKFacebook() {
479
+ if (document.getElementById('facebook-jssdk')) {
480
+ return;
481
+ }
482
+ const urlSDK = 'https://connect.facebook.net/fr_CA/sdk.js#xfbml=1&version=v2.9';
483
+ const fjs = document.getElementsByTagName('script')[0];
484
+ const js = document.createElement('script');
485
+ js.id = 'facebook-jssdk';
486
+ js.src = `${urlSDK}&appId=${this.options.appId}`;
487
+ js.onload = () => {
488
+ this.subscribeEvents();
489
+ };
490
+ fjs.parentNode.insertBefore(js, fjs);
491
+ }
492
+ }
493
+ AuthFacebookComponent.ɵfac = function AuthFacebookComponent_Factory(t) { return new (t || AuthFacebookComponent)(i0.ɵɵdirectiveInject(AuthService), i0.ɵɵdirectiveInject(i2.ConfigService), i0.ɵɵdirectiveInject(i0.ApplicationRef)); };
494
+ AuthFacebookComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AuthFacebookComponent, selectors: [["igo-auth-facebook"]], outputs: { login: "login" }, decls: 1, vars: 0, consts: [["scope", "public_profile,email", "data-max-rows", "1", "data-size", "large", "data-button-type", "login_with", "data-show-faces", "false", "data-auto-logout-link", "false", "data-use-continue-as", "false", 1, "fb-login-button"]], template: function AuthFacebookComponent_Template(rf, ctx) {
495
+ if (rf & 1) {
496
+ i0.ɵɵelement(0, "div", 0);
497
+ }
498
+ }, styles: ["[_nghost-%COMP%]{padding:10px 10px 10px 0;display:inline-block;position:relative;top:-3px}"], changeDetection: 0 });
499
+ (function () {
500
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthFacebookComponent, [{
501
+ type: Component,
502
+ args: [{ selector: 'igo-auth-facebook', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div scope=\"public_profile,email\"\n class=\"fb-login-button\" data-max-rows=\"1\" data-size=\"large\"\n data-button-type=\"login_with\" data-show-faces=\"false\"\n data-auto-logout-link=\"false\" data-use-continue-as=\"false\">\n</div>\n", styles: [":host{padding:10px 10px 10px 0;display:inline-block;position:relative;top:-3px}\n"] }]
503
+ }], function () { return [{ type: AuthService }, { type: i2.ConfigService }, { type: i0.ApplicationRef }]; }, { login: [{
504
+ type: Output
505
+ }] });
506
506
  })();
507
507
 
508
- class AuthMicrosoftComponent {
509
- constructor(authService, config, appRef, msalService, msalGuardConfig) {
510
- this.authService = authService;
511
- this.config = config;
512
- this.appRef = appRef;
513
- this.msalService = msalService;
514
- this.msalGuardConfig = msalGuardConfig;
515
- this._destroying$ = new Subject();
516
- this.login = new EventEmitter();
517
- this.options = this.config.getConfig('auth.microsoft') || {};
518
- this.msalService.instance = new PublicClientApplication({
519
- auth: this.options,
520
- cache: {
521
- cacheLocation: 'sessionStorage'
522
- }
523
- });
524
- this.broadcastService = new MsalBroadcastService(this.msalService.instance, this.msalService);
525
- if (this.options.clientId) {
526
- this.broadcastService.inProgress$
527
- .pipe(filter((status) => status === InteractionStatus.None), takeUntil(this._destroying$))
528
- .subscribe(() => {
529
- this.checkAccount();
530
- });
531
- }
532
- else {
533
- console.warn('Microsoft authentification needs "clientId" option');
534
- }
535
- }
536
- loginMicrosoft() {
537
- this.msalService.loginPopup(Object.assign({}, this.getConf().authRequest))
538
- .subscribe((response) => {
539
- this.msalService.instance.setActiveAccount(response.account);
540
- this.checkAccount();
541
- });
542
- }
543
- checkAccount() {
544
- this.msalService.instance
545
- .acquireTokenSilent(this.getConf().authRequest)
546
- .then((response) => {
547
- const tokenAccess = response.accessToken;
548
- const tokenId = response.idToken;
549
- this.authService.loginWithToken(tokenAccess, 'microsoft', { tokenId }).subscribe(() => {
550
- this.appRef.tick();
551
- this.login.emit(true);
552
- });
553
- })
554
- .catch((error) => __awaiter(this, void 0, void 0, function* () {
555
- if (error instanceof InteractionRequiredAuthError) {
556
- // fallback to interaction when silent call fails
557
- return this.msalService.acquireTokenPopup(this.getConf().authRequest);
558
- }
559
- console.log(error);
560
- })).catch(error => {
561
- console.log('Silent token fails');
562
- });
563
- }
564
- getConf() {
565
- return this.msalGuardConfig.filter(conf => conf.type === 'add')[0];
566
- }
567
- }
568
- AuthMicrosoftComponent.ɵfac = function AuthMicrosoftComponent_Factory(t) { return new (t || AuthMicrosoftComponent)(i0.ɵɵdirectiveInject(AuthService), i0.ɵɵdirectiveInject(i2.ConfigService), i0.ɵɵdirectiveInject(i0.ApplicationRef), i0.ɵɵdirectiveInject(i3$2.MsalService), i0.ɵɵdirectiveInject(MSAL_GUARD_CONFIG)); };
569
- AuthMicrosoftComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AuthMicrosoftComponent, selectors: [["igo-auth-microsoft"]], outputs: { login: "login" }, decls: 4, vars: 3, consts: [["mat-raised-button", "", 1, "microsoft-login-button", 3, "click"], ["svgIcon", "microsoft"]], template: function AuthMicrosoftComponent_Template(rf, ctx) {
570
- if (rf & 1) {
571
- i0.ɵɵelementStart(0, "button", 0);
572
- i0.ɵɵlistener("click", function AuthMicrosoftComponent_Template_button_click_0_listener() { return ctx.loginMicrosoft(); });
573
- i0.ɵɵelement(1, "mat-icon", 1);
574
- i0.ɵɵtext(2);
575
- i0.ɵɵpipe(3, "translate");
576
- i0.ɵɵelementEnd();
577
- }
578
- if (rf & 2) {
579
- i0.ɵɵadvance(2);
580
- i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(3, 1, "igo.auth.microsoft.login"), "\n");
581
- }
582
- }, dependencies: [i4.MatIcon, i5$1.MatButton, i6$1.TranslatePipe], styles: ["[_nghost-%COMP%]{padding:10px 10px 10px 0;display:inline-block;position:relative;top:-15px}[_nghost-%COMP%] > button[_ngcontent-%COMP%]{font-size:15px;height:40px;width:265px}mat-icon[_ngcontent-%COMP%]{margin-right:10px}"], changeDetection: 0 });
583
- (function () {
584
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthMicrosoftComponent, [{
585
- type: Component,
586
- args: [{ selector: 'igo-auth-microsoft', changeDetection: ChangeDetectionStrategy.OnPush, template: "<button class=\"microsoft-login-button\" mat-raised-button (click)=\"loginMicrosoft()\">\n <mat-icon svgIcon=\"microsoft\"></mat-icon>\n {{'igo.auth.microsoft.login' | translate}}\n</button>\n", styles: [":host{padding:10px 10px 10px 0;display:inline-block;position:relative;top:-15px}:host>button{font-size:15px;height:40px;width:265px}mat-icon{margin-right:10px}\n"] }]
587
- }], function () {
588
- return [{ type: AuthService }, { type: i2.ConfigService }, { type: i0.ApplicationRef }, { type: i3$2.MsalService }, { type: undefined, decorators: [{
589
- type: Inject,
590
- args: [MSAL_GUARD_CONFIG]
591
- }] }];
592
- }, { login: [{
593
- type: Output
594
- }] });
508
+ class AuthMicrosoftComponent {
509
+ constructor(authService, config, appRef, msalService, msalGuardConfig) {
510
+ this.authService = authService;
511
+ this.config = config;
512
+ this.appRef = appRef;
513
+ this.msalService = msalService;
514
+ this.msalGuardConfig = msalGuardConfig;
515
+ this._destroying$ = new Subject();
516
+ this.login = new EventEmitter();
517
+ this.options = this.config.getConfig('auth.microsoft') || {};
518
+ this.msalService.instance = new PublicClientApplication({
519
+ auth: this.options,
520
+ cache: {
521
+ cacheLocation: 'sessionStorage'
522
+ }
523
+ });
524
+ this.broadcastService = new MsalBroadcastService(this.msalService.instance, this.msalService);
525
+ if (this.options.clientId) {
526
+ this.broadcastService.inProgress$
527
+ .pipe(filter((status) => status === InteractionStatus.None), takeUntil(this._destroying$))
528
+ .subscribe(() => {
529
+ this.checkAccount();
530
+ });
531
+ }
532
+ else {
533
+ console.warn('Microsoft authentification needs "clientId" option');
534
+ }
535
+ }
536
+ loginMicrosoft() {
537
+ this.msalService.loginPopup(Object.assign({}, this.getConf().authRequest))
538
+ .subscribe((response) => {
539
+ this.msalService.instance.setActiveAccount(response.account);
540
+ this.checkAccount();
541
+ });
542
+ }
543
+ checkAccount() {
544
+ this.msalService.instance
545
+ .acquireTokenSilent(this.getConf().authRequest)
546
+ .then((response) => {
547
+ const tokenAccess = response.accessToken;
548
+ const tokenId = response.idToken;
549
+ this.authService.loginWithToken(tokenAccess, 'microsoft', { tokenId }).subscribe(() => {
550
+ this.appRef.tick();
551
+ this.login.emit(true);
552
+ });
553
+ })
554
+ .catch((error) => __awaiter(this, void 0, void 0, function* () {
555
+ if (error instanceof InteractionRequiredAuthError) {
556
+ // fallback to interaction when silent call fails
557
+ return this.msalService.acquireTokenPopup(this.getConf().authRequest);
558
+ }
559
+ console.log(error);
560
+ })).catch(error => {
561
+ console.log('Silent token fails');
562
+ });
563
+ }
564
+ getConf() {
565
+ return this.msalGuardConfig.filter(conf => conf.type === 'add')[0];
566
+ }
567
+ }
568
+ AuthMicrosoftComponent.ɵfac = function AuthMicrosoftComponent_Factory(t) { return new (t || AuthMicrosoftComponent)(i0.ɵɵdirectiveInject(AuthService), i0.ɵɵdirectiveInject(i2.ConfigService), i0.ɵɵdirectiveInject(i0.ApplicationRef), i0.ɵɵdirectiveInject(i3$2.MsalService), i0.ɵɵdirectiveInject(MSAL_GUARD_CONFIG)); };
569
+ AuthMicrosoftComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AuthMicrosoftComponent, selectors: [["igo-auth-microsoft"]], outputs: { login: "login" }, decls: 4, vars: 3, consts: [["mat-raised-button", "", 1, "microsoft-login-button", 3, "click"], ["svgIcon", "microsoft"]], template: function AuthMicrosoftComponent_Template(rf, ctx) {
570
+ if (rf & 1) {
571
+ i0.ɵɵelementStart(0, "button", 0);
572
+ i0.ɵɵlistener("click", function AuthMicrosoftComponent_Template_button_click_0_listener() { return ctx.loginMicrosoft(); });
573
+ i0.ɵɵelement(1, "mat-icon", 1);
574
+ i0.ɵɵtext(2);
575
+ i0.ɵɵpipe(3, "translate");
576
+ i0.ɵɵelementEnd();
577
+ }
578
+ if (rf & 2) {
579
+ i0.ɵɵadvance(2);
580
+ i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(3, 1, "igo.auth.microsoft.login"), "\n");
581
+ }
582
+ }, dependencies: [i4.MatIcon, i5$1.MatButton, i6$1.TranslatePipe], styles: ["[_nghost-%COMP%]{padding:10px 10px 10px 0;display:inline-block;position:relative;top:-15px}[_nghost-%COMP%] > button[_ngcontent-%COMP%]{font-size:15px;height:40px;width:265px}mat-icon[_ngcontent-%COMP%]{margin-right:10px}"], changeDetection: 0 });
583
+ (function () {
584
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthMicrosoftComponent, [{
585
+ type: Component,
586
+ args: [{ selector: 'igo-auth-microsoft', changeDetection: ChangeDetectionStrategy.OnPush, template: "<button class=\"microsoft-login-button\" mat-raised-button (click)=\"loginMicrosoft()\">\n <mat-icon svgIcon=\"microsoft\"></mat-icon>\n {{'igo.auth.microsoft.login' | translate}}\n</button>\n", styles: [":host{padding:10px 10px 10px 0;display:inline-block;position:relative;top:-15px}:host>button{font-size:15px;height:40px;width:265px}mat-icon{margin-right:10px}\n"] }]
587
+ }], function () {
588
+ return [{ type: AuthService }, { type: i2.ConfigService }, { type: i0.ApplicationRef }, { type: i3$2.MsalService }, { type: undefined, decorators: [{
589
+ type: Inject,
590
+ args: [MSAL_GUARD_CONFIG]
591
+ }] }];
592
+ }, { login: [{
593
+ type: Output
594
+ }] });
595
595
  })();
596
596
 
597
- /*
598
- * Copyright (c) Microsoft Corporation. All rights reserved.
599
- * Licensed under the MIT License.
600
- */
601
- class MsalServiceb2c {
602
- constructor(instance, location) {
603
- this.instance = instance;
604
- this.location = location;
605
- this.name = '@azure/msal-angular';
606
- this.version = '2.0.0-beta.2';
607
- const hash = this.location.path(true).split('#').pop();
608
- if (hash) {
609
- this.redirectHash = `#${hash}`;
610
- }
611
- this.instance.initializeWrapperLibrary(WrapperSKU.Angular, this.version);
612
- }
613
- initialize() {
614
- return from(this.instance.initialize());
615
- }
616
- acquireTokenPopup(request) {
617
- return from(this.instance.acquireTokenPopup(request));
618
- }
619
- acquireTokenRedirect(request) {
620
- return from(this.instance.acquireTokenRedirect(request));
621
- }
622
- acquireTokenSilent(silentRequest) {
623
- return from(this.instance.acquireTokenSilent(silentRequest));
624
- }
625
- handleRedirectObservable(hash) {
626
- return from(this.instance.handleRedirectPromise(hash || this.redirectHash));
627
- }
628
- loginPopup(request) {
629
- return from(this.instance.loginPopup(request));
630
- }
631
- loginRedirect(request) {
632
- return from(this.instance.loginRedirect(request));
633
- }
634
- logout(logoutRequest) {
635
- return from(this.instance.logout(logoutRequest));
636
- }
637
- logoutRedirect(logoutRequest) {
638
- return from(this.instance.logoutRedirect(logoutRequest));
639
- }
640
- logoutPopup(logoutRequest) {
641
- return from(this.instance.logoutPopup(logoutRequest));
642
- }
643
- ssoSilent(request) {
644
- return from(this.instance.ssoSilent(request));
645
- }
646
- /**
647
- * Gets logger for msal-angular.
648
- * If no logger set, returns logger instance created with same options as msal-browser
649
- */
650
- getLogger() {
651
- if (!this.logger) {
652
- this.logger = this.instance.getLogger().clone(this.name, this.version);
653
- }
654
- return this.logger;
655
- }
656
- // Create a logger instance for msal-angular with the same options as msal-browser
657
- setLogger(logger) {
658
- this.logger = logger.clone(this.name, this.version);
659
- this.instance.setLogger(logger);
660
- }
661
- }
662
- MsalServiceb2c.ɵfac = function MsalServiceb2c_Factory(t) { return new (t || MsalServiceb2c)(i0.ɵɵinject(MSAL_INSTANCE), i0.ɵɵinject(i1$1.Location)); };
663
- MsalServiceb2c.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: MsalServiceb2c, factory: MsalServiceb2c.ɵfac });
664
- (function () {
665
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MsalServiceb2c, [{
666
- type: Injectable
667
- }], function () {
668
- return [{ type: undefined, decorators: [{
669
- type: Inject,
670
- args: [MSAL_INSTANCE]
671
- }] }, { type: i1$1.Location }];
672
- }, null);
597
+ /*
598
+ * Copyright (c) Microsoft Corporation. All rights reserved.
599
+ * Licensed under the MIT License.
600
+ */
601
+ class MsalServiceb2c {
602
+ constructor(instance, location) {
603
+ this.instance = instance;
604
+ this.location = location;
605
+ this.name = '@azure/msal-angular';
606
+ this.version = '2.0.0-beta.2';
607
+ const hash = this.location.path(true).split('#').pop();
608
+ if (hash) {
609
+ this.redirectHash = `#${hash}`;
610
+ }
611
+ this.instance.initializeWrapperLibrary(WrapperSKU.Angular, this.version);
612
+ }
613
+ initialize() {
614
+ return from(this.instance.initialize());
615
+ }
616
+ acquireTokenPopup(request) {
617
+ return from(this.instance.acquireTokenPopup(request));
618
+ }
619
+ acquireTokenRedirect(request) {
620
+ return from(this.instance.acquireTokenRedirect(request));
621
+ }
622
+ acquireTokenSilent(silentRequest) {
623
+ return from(this.instance.acquireTokenSilent(silentRequest));
624
+ }
625
+ handleRedirectObservable(hash) {
626
+ return from(this.instance.handleRedirectPromise(hash || this.redirectHash));
627
+ }
628
+ loginPopup(request) {
629
+ return from(this.instance.loginPopup(request));
630
+ }
631
+ loginRedirect(request) {
632
+ return from(this.instance.loginRedirect(request));
633
+ }
634
+ logout(logoutRequest) {
635
+ return from(this.instance.logout(logoutRequest));
636
+ }
637
+ logoutRedirect(logoutRequest) {
638
+ return from(this.instance.logoutRedirect(logoutRequest));
639
+ }
640
+ logoutPopup(logoutRequest) {
641
+ return from(this.instance.logoutPopup(logoutRequest));
642
+ }
643
+ ssoSilent(request) {
644
+ return from(this.instance.ssoSilent(request));
645
+ }
646
+ /**
647
+ * Gets logger for msal-angular.
648
+ * If no logger set, returns logger instance created with same options as msal-browser
649
+ */
650
+ getLogger() {
651
+ if (!this.logger) {
652
+ this.logger = this.instance.getLogger().clone(this.name, this.version);
653
+ }
654
+ return this.logger;
655
+ }
656
+ // Create a logger instance for msal-angular with the same options as msal-browser
657
+ setLogger(logger) {
658
+ this.logger = logger.clone(this.name, this.version);
659
+ this.instance.setLogger(logger);
660
+ }
661
+ }
662
+ MsalServiceb2c.ɵfac = function MsalServiceb2c_Factory(t) { return new (t || MsalServiceb2c)(i0.ɵɵinject(MSAL_INSTANCE), i0.ɵɵinject(i1$1.Location)); };
663
+ MsalServiceb2c.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: MsalServiceb2c, factory: MsalServiceb2c.ɵfac });
664
+ (function () {
665
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MsalServiceb2c, [{
666
+ type: Injectable
667
+ }], function () {
668
+ return [{ type: undefined, decorators: [{
669
+ type: Inject,
670
+ args: [MSAL_INSTANCE]
671
+ }] }, { type: i1$1.Location }];
672
+ }, null);
673
673
  })();
674
674
 
675
- /*
676
- * Copyright (c) Microsoft Corporation. All rights reserved.
677
- * Licensed under the MIT License.
678
- */
679
- class MsalBroadcastServiceb2c {
680
- constructor(msalInstance, authService) {
681
- this.msalInstance = msalInstance;
682
- this.authService = authService;
683
- this._msalSubject = new Subject();
684
- this.msalSubject$ = this._msalSubject.asObservable();
685
- // InProgress as BehaviorSubject so most recent inProgress state will be available upon subscription
686
- this._inProgress = new BehaviorSubject(InteractionStatus.Startup);
687
- this.inProgress$ = this._inProgress.asObservable();
688
- this.msalInstance.addEventCallback((message) => {
689
- this._msalSubject.next(message);
690
- const status = EventMessageUtils.getInteractionStatusFromEvent(message);
691
- if (status !== null) {
692
- this.authService.getLogger().verbose(`BroadcastService - ${message.eventType} results in setting inProgress to ${status}`);
693
- this._inProgress.next(status);
694
- }
695
- });
696
- }
697
- }
698
- MsalBroadcastServiceb2c.ɵfac = function MsalBroadcastServiceb2c_Factory(t) { return new (t || MsalBroadcastServiceb2c)(i0.ɵɵinject(MSAL_INSTANCE), i0.ɵɵinject(MsalServiceb2c)); };
699
- MsalBroadcastServiceb2c.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: MsalBroadcastServiceb2c, factory: MsalBroadcastServiceb2c.ɵfac });
700
- (function () {
701
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MsalBroadcastServiceb2c, [{
702
- type: Injectable
703
- }], function () {
704
- return [{ type: undefined, decorators: [{
705
- type: Inject,
706
- args: [MSAL_INSTANCE]
707
- }] }, { type: MsalServiceb2c }];
708
- }, null);
675
+ /*
676
+ * Copyright (c) Microsoft Corporation. All rights reserved.
677
+ * Licensed under the MIT License.
678
+ */
679
+ class MsalBroadcastServiceb2c {
680
+ constructor(msalInstance, authService) {
681
+ this.msalInstance = msalInstance;
682
+ this.authService = authService;
683
+ this._msalSubject = new Subject();
684
+ this.msalSubject$ = this._msalSubject.asObservable();
685
+ // InProgress as BehaviorSubject so most recent inProgress state will be available upon subscription
686
+ this._inProgress = new BehaviorSubject(InteractionStatus.Startup);
687
+ this.inProgress$ = this._inProgress.asObservable();
688
+ this.msalInstance.addEventCallback((message) => {
689
+ this._msalSubject.next(message);
690
+ const status = EventMessageUtils.getInteractionStatusFromEvent(message);
691
+ if (status !== null) {
692
+ this.authService.getLogger().verbose(`BroadcastService - ${message.eventType} results in setting inProgress to ${status}`);
693
+ this._inProgress.next(status);
694
+ }
695
+ });
696
+ }
697
+ }
698
+ MsalBroadcastServiceb2c.ɵfac = function MsalBroadcastServiceb2c_Factory(t) { return new (t || MsalBroadcastServiceb2c)(i0.ɵɵinject(MSAL_INSTANCE), i0.ɵɵinject(MsalServiceb2c)); };
699
+ MsalBroadcastServiceb2c.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: MsalBroadcastServiceb2c, factory: MsalBroadcastServiceb2c.ɵfac });
700
+ (function () {
701
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MsalBroadcastServiceb2c, [{
702
+ type: Injectable
703
+ }], function () {
704
+ return [{ type: undefined, decorators: [{
705
+ type: Inject,
706
+ args: [MSAL_INSTANCE]
707
+ }] }, { type: MsalServiceb2c }];
708
+ }, null);
709
709
  })();
710
710
 
711
- class AuthMicrosoftb2cComponent {
712
- constructor(authService, config, appRef, msalService, msalGuardConfig) {
713
- this.authService = authService;
714
- this.config = config;
715
- this.appRef = appRef;
716
- this.msalService = msalService;
717
- this.msalGuardConfig = msalGuardConfig;
718
- this._destroying$ = new Subject();
719
- this.login = new EventEmitter();
720
- this.options = this.config.getConfig('auth.microsoftb2c') || {};
721
- this.msalService.instance = new PublicClientApplication({
722
- auth: this.options.browserAuthOptions,
723
- cache: {
724
- cacheLocation: 'sessionStorage'
725
- }
726
- });
727
- this.broadcastService = new MsalBroadcastServiceb2c(this.msalService.instance, this.msalService);
728
- if (this.options.browserAuthOptions.clientId) {
729
- this.broadcastService.inProgress$
730
- .pipe(filter((status) => status === InteractionStatus.None), takeUntil(this._destroying$))
731
- .subscribe(() => {
732
- this.checkAccount();
733
- });
734
- }
735
- else {
736
- console.warn('Microsoft authentification needs "clientId" option');
737
- }
738
- }
739
- loginMicrosoftb2c() {
740
- this.msalService.loginPopup(Object.assign({}, this.getConf().authRequest))
741
- .subscribe((response) => {
742
- this.msalService.instance.setActiveAccount(response.account);
743
- this.checkAccount();
744
- });
745
- }
746
- checkAccount() {
747
- this.msalService.instance
748
- .acquireTokenSilent(this.getConf().authRequest)
749
- .then((response) => {
750
- const token = response.idToken;
751
- this.authService.loginWithToken(token, 'microsoftb2c').subscribe(() => {
752
- this.appRef.tick();
753
- this.login.emit(true);
754
- });
755
- })
756
- .catch((error) => __awaiter(this, void 0, void 0, function* () {
757
- if (error instanceof InteractionRequiredAuthError) {
758
- // fallback to interaction when silent call fails
759
- return this.msalService.acquireTokenPopup(this.getConf().authRequest);
760
- }
761
- })).catch(error => {
762
- console.log('Silent token fails');
763
- });
764
- }
765
- getConf() {
766
- return this.msalGuardConfig.filter(conf => conf.type === 'b2c')[0];
767
- }
768
- }
769
- AuthMicrosoftb2cComponent.ɵfac = function AuthMicrosoftb2cComponent_Factory(t) { return new (t || AuthMicrosoftb2cComponent)(i0.ɵɵdirectiveInject(AuthService), i0.ɵɵdirectiveInject(i2.ConfigService), i0.ɵɵdirectiveInject(i0.ApplicationRef), i0.ɵɵdirectiveInject(MsalServiceb2c), i0.ɵɵdirectiveInject(MSAL_GUARD_CONFIG)); };
770
- AuthMicrosoftb2cComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AuthMicrosoftb2cComponent, selectors: [["igo-auth-microsoftb2c"]], outputs: { login: "login" }, decls: 4, vars: 3, consts: [["mat-raised-button", "", 1, "microsoft-login-button", 3, "click"], ["svgIcon", "microsoft"]], template: function AuthMicrosoftb2cComponent_Template(rf, ctx) {
771
- if (rf & 1) {
772
- i0.ɵɵelementStart(0, "button", 0);
773
- i0.ɵɵlistener("click", function AuthMicrosoftb2cComponent_Template_button_click_0_listener() { return ctx.loginMicrosoftb2c(); });
774
- i0.ɵɵelement(1, "mat-icon", 1);
775
- i0.ɵɵtext(2);
776
- i0.ɵɵpipe(3, "translate");
777
- i0.ɵɵelementEnd();
778
- }
779
- if (rf & 2) {
780
- i0.ɵɵadvance(2);
781
- i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(3, 1, "igo.auth.microsoftb2c.login"), "\n");
782
- }
783
- }, dependencies: [i4.MatIcon, i5$1.MatButton, i6$1.TranslatePipe], styles: ["[_nghost-%COMP%]{padding:10px 10px 10px 0;display:inline-block;position:relative;top:-15px}[_nghost-%COMP%] > button[_ngcontent-%COMP%]{font-size:15px;height:40px;width:265px}mat-icon[_ngcontent-%COMP%]{margin-right:10px}"], changeDetection: 0 });
784
- (function () {
785
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthMicrosoftb2cComponent, [{
786
- type: Component,
787
- args: [{ selector: 'igo-auth-microsoftb2c', changeDetection: ChangeDetectionStrategy.OnPush, template: "<button class=\"microsoft-login-button\" mat-raised-button (click)=\"loginMicrosoftb2c()\">\n <mat-icon svgIcon=\"microsoft\"></mat-icon>\n {{'igo.auth.microsoftb2c.login' | translate}}\n</button>\n", styles: [":host{padding:10px 10px 10px 0;display:inline-block;position:relative;top:-15px}:host>button{font-size:15px;height:40px;width:265px}mat-icon{margin-right:10px}\n"] }]
788
- }], function () {
789
- return [{ type: AuthService }, { type: i2.ConfigService }, { type: i0.ApplicationRef }, { type: MsalServiceb2c }, { type: undefined, decorators: [{
790
- type: Inject,
791
- args: [MSAL_GUARD_CONFIG]
792
- }] }];
793
- }, { login: [{
794
- type: Output
795
- }] });
711
+ class AuthMicrosoftb2cComponent {
712
+ constructor(authService, config, appRef, msalService, msalGuardConfig) {
713
+ this.authService = authService;
714
+ this.config = config;
715
+ this.appRef = appRef;
716
+ this.msalService = msalService;
717
+ this.msalGuardConfig = msalGuardConfig;
718
+ this._destroying$ = new Subject();
719
+ this.login = new EventEmitter();
720
+ this.options = this.config.getConfig('auth.microsoftb2c') || {};
721
+ this.msalService.instance = new PublicClientApplication({
722
+ auth: this.options.browserAuthOptions,
723
+ cache: {
724
+ cacheLocation: 'sessionStorage'
725
+ }
726
+ });
727
+ this.broadcastService = new MsalBroadcastServiceb2c(this.msalService.instance, this.msalService);
728
+ if (this.options.browserAuthOptions.clientId) {
729
+ this.broadcastService.inProgress$
730
+ .pipe(filter((status) => status === InteractionStatus.None), takeUntil(this._destroying$))
731
+ .subscribe(() => {
732
+ this.checkAccount();
733
+ });
734
+ }
735
+ else {
736
+ console.warn('Microsoft authentification needs "clientId" option');
737
+ }
738
+ }
739
+ loginMicrosoftb2c() {
740
+ this.msalService.loginPopup(Object.assign({}, this.getConf().authRequest))
741
+ .subscribe((response) => {
742
+ this.msalService.instance.setActiveAccount(response.account);
743
+ this.checkAccount();
744
+ });
745
+ }
746
+ checkAccount() {
747
+ this.msalService.instance
748
+ .acquireTokenSilent(this.getConf().authRequest)
749
+ .then((response) => {
750
+ const token = response.idToken;
751
+ this.authService.loginWithToken(token, 'microsoftb2c').subscribe(() => {
752
+ this.appRef.tick();
753
+ this.login.emit(true);
754
+ });
755
+ })
756
+ .catch((error) => __awaiter(this, void 0, void 0, function* () {
757
+ if (error instanceof InteractionRequiredAuthError) {
758
+ // fallback to interaction when silent call fails
759
+ return this.msalService.acquireTokenPopup(this.getConf().authRequest);
760
+ }
761
+ })).catch(error => {
762
+ console.log('Silent token fails');
763
+ });
764
+ }
765
+ getConf() {
766
+ return this.msalGuardConfig.filter(conf => conf.type === 'b2c')[0];
767
+ }
768
+ }
769
+ AuthMicrosoftb2cComponent.ɵfac = function AuthMicrosoftb2cComponent_Factory(t) { return new (t || AuthMicrosoftb2cComponent)(i0.ɵɵdirectiveInject(AuthService), i0.ɵɵdirectiveInject(i2.ConfigService), i0.ɵɵdirectiveInject(i0.ApplicationRef), i0.ɵɵdirectiveInject(MsalServiceb2c), i0.ɵɵdirectiveInject(MSAL_GUARD_CONFIG)); };
770
+ AuthMicrosoftb2cComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AuthMicrosoftb2cComponent, selectors: [["igo-auth-microsoftb2c"]], outputs: { login: "login" }, decls: 4, vars: 3, consts: [["mat-raised-button", "", 1, "microsoft-login-button", 3, "click"], ["svgIcon", "microsoft"]], template: function AuthMicrosoftb2cComponent_Template(rf, ctx) {
771
+ if (rf & 1) {
772
+ i0.ɵɵelementStart(0, "button", 0);
773
+ i0.ɵɵlistener("click", function AuthMicrosoftb2cComponent_Template_button_click_0_listener() { return ctx.loginMicrosoftb2c(); });
774
+ i0.ɵɵelement(1, "mat-icon", 1);
775
+ i0.ɵɵtext(2);
776
+ i0.ɵɵpipe(3, "translate");
777
+ i0.ɵɵelementEnd();
778
+ }
779
+ if (rf & 2) {
780
+ i0.ɵɵadvance(2);
781
+ i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(3, 1, "igo.auth.microsoftb2c.login"), "\n");
782
+ }
783
+ }, dependencies: [i4.MatIcon, i5$1.MatButton, i6$1.TranslatePipe], styles: ["[_nghost-%COMP%]{padding:10px 10px 10px 0;display:inline-block;position:relative;top:-15px}[_nghost-%COMP%] > button[_ngcontent-%COMP%]{font-size:15px;height:40px;width:265px}mat-icon[_ngcontent-%COMP%]{margin-right:10px}"], changeDetection: 0 });
784
+ (function () {
785
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthMicrosoftb2cComponent, [{
786
+ type: Component,
787
+ args: [{ selector: 'igo-auth-microsoftb2c', changeDetection: ChangeDetectionStrategy.OnPush, template: "<button class=\"microsoft-login-button\" mat-raised-button (click)=\"loginMicrosoftb2c()\">\n <mat-icon svgIcon=\"microsoft\"></mat-icon>\n {{'igo.auth.microsoftb2c.login' | translate}}\n</button>\n", styles: [":host{padding:10px 10px 10px 0;display:inline-block;position:relative;top:-15px}:host>button{font-size:15px;height:40px;width:265px}mat-icon{margin-right:10px}\n"] }]
788
+ }], function () {
789
+ return [{ type: AuthService }, { type: i2.ConfigService }, { type: i0.ApplicationRef }, { type: MsalServiceb2c }, { type: undefined, decorators: [{
790
+ type: Inject,
791
+ args: [MSAL_GUARD_CONFIG]
792
+ }] }];
793
+ }, { login: [{
794
+ type: Output
795
+ }] });
796
796
  })();
797
797
 
798
- function AuthFormComponent_div_0_div_1_Template(rf, ctx) {
799
- if (rf & 1) {
800
- i0.ɵɵelement(0, "div", 3);
801
- }
802
- }
803
- function AuthFormComponent_div_0_div_2_igo_auth_google_4_Template(rf, ctx) {
804
- if (rf & 1) {
805
- const _r11 = i0.ɵɵgetCurrentView();
806
- i0.ɵɵelementStart(0, "igo-auth-google", 7);
807
- i0.ɵɵlistener("login", function AuthFormComponent_div_0_div_2_igo_auth_google_4_Template_igo_auth_google_login_0_listener() { i0.ɵɵrestoreView(_r11); const ctx_r10 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r10.onLogin()); });
808
- i0.ɵɵelementEnd();
809
- }
810
- }
811
- function AuthFormComponent_div_0_div_2_igo_auth_microsoft_5_Template(rf, ctx) {
812
- if (rf & 1) {
813
- const _r13 = i0.ɵɵgetCurrentView();
814
- i0.ɵɵelementStart(0, "igo-auth-microsoft", 7);
815
- i0.ɵɵlistener("login", function AuthFormComponent_div_0_div_2_igo_auth_microsoft_5_Template_igo_auth_microsoft_login_0_listener() { i0.ɵɵrestoreView(_r13); const ctx_r12 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r12.onLogin()); });
816
- i0.ɵɵelementEnd();
817
- }
818
- }
819
- function AuthFormComponent_div_0_div_2_igo_auth_microsoftb2c_6_Template(rf, ctx) {
820
- if (rf & 1) {
821
- const _r15 = i0.ɵɵgetCurrentView();
822
- i0.ɵɵelementStart(0, "igo-auth-microsoftb2c", 7);
823
- i0.ɵɵlistener("login", function AuthFormComponent_div_0_div_2_igo_auth_microsoftb2c_6_Template_igo_auth_microsoftb2c_login_0_listener() { i0.ɵɵrestoreView(_r15); const ctx_r14 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r14.onLogin()); });
824
- i0.ɵɵelementEnd();
825
- }
826
- }
827
- function AuthFormComponent_div_0_div_2_igo_auth_facebook_7_Template(rf, ctx) {
828
- if (rf & 1) {
829
- const _r17 = i0.ɵɵgetCurrentView();
830
- i0.ɵɵelementStart(0, "igo-auth-facebook", 7);
831
- i0.ɵɵlistener("login", function AuthFormComponent_div_0_div_2_igo_auth_facebook_7_Template_igo_auth_facebook_login_0_listener() { i0.ɵɵrestoreView(_r17); const ctx_r16 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r16.onLogin()); });
832
- i0.ɵɵelementEnd();
833
- }
834
- }
835
- function AuthFormComponent_div_0_div_2_igo_auth_intern_8_Template(rf, ctx) {
836
- if (rf & 1) {
837
- const _r19 = i0.ɵɵgetCurrentView();
838
- i0.ɵɵelementStart(0, "igo-auth-intern", 8);
839
- i0.ɵɵlistener("login", function AuthFormComponent_div_0_div_2_igo_auth_intern_8_Template_igo_auth_intern_login_0_listener() { i0.ɵɵrestoreView(_r19); const ctx_r18 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r18.onLogin()); });
840
- i0.ɵɵelementEnd();
841
- }
842
- if (rf & 2) {
843
- const ctx_r9 = i0.ɵɵnextContext(3);
844
- i0.ɵɵproperty("allowAnonymous", ctx_r9.options.allowAnonymous);
845
- }
846
- }
847
- function AuthFormComponent_div_0_div_2_Template(rf, ctx) {
848
- if (rf & 1) {
849
- i0.ɵɵelementStart(0, "div", 4)(1, "h1");
850
- i0.ɵɵtext(2);
851
- i0.ɵɵpipe(3, "translate");
852
- i0.ɵɵelementEnd();
853
- i0.ɵɵtemplate(4, AuthFormComponent_div_0_div_2_igo_auth_google_4_Template, 1, 0, "igo-auth-google", 5);
854
- i0.ɵɵtemplate(5, AuthFormComponent_div_0_div_2_igo_auth_microsoft_5_Template, 1, 0, "igo-auth-microsoft", 5);
855
- i0.ɵɵtemplate(6, AuthFormComponent_div_0_div_2_igo_auth_microsoftb2c_6_Template, 1, 0, "igo-auth-microsoftb2c", 5);
856
- i0.ɵɵtemplate(7, AuthFormComponent_div_0_div_2_igo_auth_facebook_7_Template, 1, 0, "igo-auth-facebook", 5);
857
- i0.ɵɵtemplate(8, AuthFormComponent_div_0_div_2_igo_auth_intern_8_Template, 1, 1, "igo-auth-intern", 6);
858
- i0.ɵɵelementEnd();
859
- }
860
- if (rf & 2) {
861
- const ctx_r2 = i0.ɵɵnextContext(2);
862
- i0.ɵɵadvance(2);
863
- i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(3, 6, "igo.auth.connection"));
864
- i0.ɵɵadvance(2);
865
- i0.ɵɵproperty("ngIf", ctx_r2.options.google && ctx_r2.options.google.enabled !== false);
866
- i0.ɵɵadvance(1);
867
- i0.ɵɵproperty("ngIf", ctx_r2.options.microsoft && ctx_r2.options.microsoft.enabled !== false);
868
- i0.ɵɵadvance(1);
869
- i0.ɵɵproperty("ngIf", ctx_r2.options.microsoftb2c && ctx_r2.options.microsoftb2c.enabled !== false);
870
- i0.ɵɵadvance(1);
871
- i0.ɵɵproperty("ngIf", ctx_r2.options.facebook && ctx_r2.options.facebook.enabled !== false);
872
- i0.ɵɵadvance(1);
873
- i0.ɵɵproperty("ngIf", !ctx_r2.options.intern || ctx_r2.options.intern.enabled !== false);
874
- }
875
- }
876
- function AuthFormComponent_div_0_div_3_Template(rf, ctx) {
877
- if (rf & 1) {
878
- const _r21 = i0.ɵɵgetCurrentView();
879
- i0.ɵɵelementStart(0, "div", 4)(1, "p");
880
- i0.ɵɵtext(2);
881
- i0.ɵɵpipe(3, "translate");
882
- i0.ɵɵelementEnd();
883
- i0.ɵɵelementStart(4, "button", 9);
884
- i0.ɵɵlistener("click", function AuthFormComponent_div_0_div_3_Template_button_click_4_listener() { i0.ɵɵrestoreView(_r21); const ctx_r20 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r20.logout()); });
885
- i0.ɵɵtext(5);
886
- i0.ɵɵpipe(6, "translate");
887
- i0.ɵɵelementEnd()();
888
- }
889
- if (rf & 2) {
890
- const ctx_r3 = i0.ɵɵnextContext(2);
891
- i0.ɵɵadvance(2);
892
- i0.ɵɵtextInterpolate(i0.ɵɵpipeBind2(3, 2, "igo.auth.welcome", ctx_r3.user));
893
- i0.ɵɵadvance(3);
894
- i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(6, 5, "igo.auth.signOut"));
895
- }
896
- }
897
- function AuthFormComponent_div_0_div_4_button_4_Template(rf, ctx) {
898
- if (rf & 1) {
899
- const _r24 = i0.ɵɵgetCurrentView();
900
- i0.ɵɵelementStart(0, "button", 9);
901
- i0.ɵɵlistener("click", function AuthFormComponent_div_0_div_4_button_4_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r24); const ctx_r23 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r23.home()); });
902
- i0.ɵɵtext(1);
903
- i0.ɵɵpipe(2, "translate");
904
- i0.ɵɵelementEnd();
905
- }
906
- if (rf & 2) {
907
- i0.ɵɵadvance(1);
908
- i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(2, 1, "igo.auth.home"));
909
- }
910
- }
911
- function AuthFormComponent_div_0_div_4_Template(rf, ctx) {
912
- if (rf & 1) {
913
- i0.ɵɵelementStart(0, "div", 4)(1, "p");
914
- i0.ɵɵtext(2);
915
- i0.ɵɵpipe(3, "translate");
916
- i0.ɵɵelementEnd();
917
- i0.ɵɵtemplate(4, AuthFormComponent_div_0_div_4_button_4_Template, 3, 3, "button", 10);
918
- i0.ɵɵelementEnd();
919
- }
920
- if (rf & 2) {
921
- const ctx_r4 = i0.ɵɵnextContext(2);
922
- i0.ɵɵadvance(2);
923
- i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(3, 2, "igo.auth.deconnection"));
924
- i0.ɵɵadvance(2);
925
- i0.ɵɵproperty("ngIf", ctx_r4.options.homeRoute);
926
- }
927
- }
928
- function AuthFormComponent_div_0_Template(rf, ctx) {
929
- if (rf & 1) {
930
- i0.ɵɵelementStart(0, "div");
931
- i0.ɵɵtemplate(1, AuthFormComponent_div_0_div_1_Template, 1, 0, "div", 1);
932
- i0.ɵɵtemplate(2, AuthFormComponent_div_0_div_2_Template, 9, 8, "div", 2);
933
- i0.ɵɵtemplate(3, AuthFormComponent_div_0_div_3_Template, 7, 7, "div", 2);
934
- i0.ɵɵtemplate(4, AuthFormComponent_div_0_div_4_Template, 5, 4, "div", 2);
935
- i0.ɵɵelementEnd();
936
- }
937
- if (rf & 2) {
938
- const ctx_r0 = i0.ɵɵnextContext();
939
- i0.ɵɵadvance(1);
940
- i0.ɵɵproperty("ngIf", !ctx_r0.auth.logged && ctx_r0.backgroundDisable);
941
- i0.ɵɵadvance(1);
942
- i0.ɵɵproperty("ngIf", !ctx_r0.auth.logged && ctx_r0.showLoginDiv);
943
- i0.ɵɵadvance(1);
944
- i0.ɵɵproperty("ngIf", ctx_r0.auth.logged && ctx_r0.showAlreadyConnectedDiv);
945
- i0.ɵɵadvance(1);
946
- i0.ɵɵproperty("ngIf", ctx_r0.showLogoutDiv);
947
- }
948
- }
949
- class AuthFormComponent {
950
- constructor(auth, config, router) {
951
- this.auth = auth;
952
- this.config = config;
953
- this.router = router;
954
- this._backgroundDisable = true;
955
- this._hasAlreadyConnectedDiv = true;
956
- this._hasLogoutDiv = true;
957
- this._showAlreadyConnectedDiv = false;
958
- this._showLogoutDiv = false;
959
- this.login = new EventEmitter();
960
- this.visible = true;
961
- this.options = this.config.getConfig('auth') || {};
962
- this.visible = Object.getOwnPropertyNames(this.options).length !== 0;
963
- }
964
- get backgroundDisable() {
965
- if (this.isLogoutRoute || this.isLogoutRoute) {
966
- return false;
967
- }
968
- return this._backgroundDisable;
969
- }
970
- set backgroundDisable(value) {
971
- this._backgroundDisable = value.toString() === 'true';
972
- }
973
- get hasAlreadyConnectedDiv() {
974
- return this._hasAlreadyConnectedDiv;
975
- }
976
- set hasAlreadyConnectedDiv(value) {
977
- this._hasAlreadyConnectedDiv = value.toString() === 'true';
978
- }
979
- get hasLogoutDiv() {
980
- return this._hasLogoutDiv;
981
- }
982
- set hasLogoutDiv(value) {
983
- this._hasLogoutDiv = value.toString() === 'true';
984
- }
985
- get showAlreadyConnectedDiv() {
986
- if (this.isLogoutRoute) {
987
- return this.hasAlreadyConnectedDiv;
988
- }
989
- return this._showAlreadyConnectedDiv;
990
- }
991
- set showAlreadyConnectedDiv(value) {
992
- this._showAlreadyConnectedDiv = value.toString() === 'true';
993
- }
994
- get showLogoutDiv() {
995
- if (this.isLogoutRoute) {
996
- return this.hasLogoutDiv;
997
- }
998
- return this._showLogoutDiv;
999
- }
1000
- set showLogoutDiv(value) {
1001
- this._showLogoutDiv = value.toString() === 'true';
1002
- }
1003
- get showLoginDiv() {
1004
- if (!this.isLogoutRoute) {
1005
- return true;
1006
- }
1007
- }
1008
- ngOnInit() {
1009
- this.analyzeRoute();
1010
- this.getName();
1011
- }
1012
- onLogin() {
1013
- this.auth.goToRedirectUrl();
1014
- this.getName();
1015
- this.login.emit(true);
1016
- }
1017
- logout() {
1018
- this.auth.logout().subscribe(() => {
1019
- this.user = undefined;
1020
- if (this.router) {
1021
- if (this.options.logoutRoute) {
1022
- this.router.navigate([this.options.logoutRoute]);
1023
- }
1024
- else if (this.options.homeRoute) {
1025
- this.router.navigate([this.options.homeRoute]);
1026
- }
1027
- }
1028
- });
1029
- }
1030
- home() {
1031
- if (this.router && this.options.homeRoute) {
1032
- this.router.navigate([this.options.homeRoute]);
1033
- }
1034
- }
1035
- getName() {
1036
- const tokenDecoded = this.auth.decodeToken();
1037
- if (tokenDecoded) {
1038
- this.user = {
1039
- name: tokenDecoded.user.firstName || tokenDecoded.user.sourceId
1040
- };
1041
- }
1042
- }
1043
- analyzeRoute() {
1044
- if (!this.router) {
1045
- return;
1046
- }
1047
- this.router.events
1048
- .pipe(filter((event) => event instanceof NavigationStart))
1049
- .subscribe((changeEvent) => {
1050
- if (changeEvent.url) {
1051
- const currentRoute = changeEvent.url;
1052
- const logoutRoute = this.options.logoutRoute;
1053
- const loginRoute = this.options.loginRoute;
1054
- this.isLogoutRoute = currentRoute === logoutRoute;
1055
- this.isLoginRoute = currentRoute === loginRoute;
1056
- if (this.isLogoutRoute) {
1057
- this.auth.logout();
1058
- }
1059
- }
1060
- });
1061
- }
1062
- }
1063
- AuthFormComponent.ɵfac = function AuthFormComponent_Factory(t) { return new (t || AuthFormComponent)(i0.ɵɵdirectiveInject(AuthService), i0.ɵɵdirectiveInject(i2.ConfigService), i0.ɵɵdirectiveInject(i3.Router, 8)); };
1064
- AuthFormComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AuthFormComponent, selectors: [["igo-auth-form"]], inputs: { backgroundDisable: "backgroundDisable", hasAlreadyConnectedDiv: "hasAlreadyConnectedDiv", hasLogoutDiv: "hasLogoutDiv", showAlreadyConnectedDiv: "showAlreadyConnectedDiv", showLogoutDiv: "showLogoutDiv" }, outputs: { login: "login" }, decls: 1, vars: 1, consts: [[4, "ngIf"], ["class", "backgroundDisable", 4, "ngIf"], ["class", "login center-block", 4, "ngIf"], [1, "backgroundDisable"], [1, "login", "center-block"], [3, "login", 4, "ngIf"], [3, "allowAnonymous", "login", 4, "ngIf"], [3, "login"], [3, "allowAnonymous", "login"], ["mat-raised-button", "", "type", "button", 3, "click"], ["mat-raised-button", "", "type", "button", 3, "click", 4, "ngIf"]], template: function AuthFormComponent_Template(rf, ctx) {
1065
- if (rf & 1) {
1066
- i0.ɵɵtemplate(0, AuthFormComponent_div_0_Template, 5, 4, "div", 0);
1067
- }
1068
- if (rf & 2) {
1069
- i0.ɵɵproperty("ngIf", ctx.visible);
1070
- }
1071
- }, dependencies: [i1$1.NgIf, i5$1.MatButton, AuthGoogleComponent, AuthInternComponent, AuthFacebookComponent, AuthMicrosoftComponent, AuthMicrosoftb2cComponent, i6$1.TranslatePipe], styles: ["[_nghost-%COMP%]{z-index:999}div.login[_ngcontent-%COMP%]{z-index:200;width:90%;min-width:360px;max-width:600px;padding:25px 50px;border:1px solid;background-color:#fff;border-color:#888}.center-block[_ngcontent-%COMP%]{position:fixed;top:20%;left:50%;transform:translate(-50%)}.backgroundDisable[_ngcontent-%COMP%]{position:fixed;top:0;left:0;background:#000;opacity:.8;z-index:100;height:100%;width:100%}"] });
1072
- (function () {
1073
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthFormComponent, [{
1074
- type: Component,
1075
- args: [{ selector: 'igo-auth-form', changeDetection: ChangeDetectionStrategy.Default, template: "<div *ngIf=\"visible\">\n <div *ngIf=\"!auth.logged && backgroundDisable\" class=\"backgroundDisable\"></div>\n\n <div *ngIf=\"!auth.logged && showLoginDiv\" class=\"login center-block\">\n <h1>{{'igo.auth.connection' | translate}}</h1>\n\n <igo-auth-google\n *ngIf=\"options.google && options.google.enabled !== false\"\n (login)=\"onLogin()\">\n </igo-auth-google>\n <igo-auth-microsoft\n *ngIf=\"options.microsoft && options.microsoft.enabled !== false\"\n (login)=\"onLogin()\">\n </igo-auth-microsoft>\n <igo-auth-microsoftb2c\n *ngIf=\"options.microsoftb2c && options.microsoftb2c.enabled !== false\"\n (login)=\"onLogin()\">\n </igo-auth-microsoftb2c>\n <igo-auth-facebook\n *ngIf=\"options.facebook && options.facebook.enabled !== false\"\n (login)=\"onLogin()\">\n </igo-auth-facebook>\n <igo-auth-intern\n *ngIf=\"!options.intern || options.intern.enabled !== false\"\n [allowAnonymous]=\"options.allowAnonymous\"\n (login)=\"onLogin()\">\n </igo-auth-intern>\n </div>\n\n <div *ngIf=\"auth.logged && showAlreadyConnectedDiv\" class=\"login center-block\">\n <p>{{'igo.auth.welcome' |\u00A0translate: user}}</p>\n <button mat-raised-button type=\"button\" (click)=\"logout()\">{{'igo.auth.signOut' |\u00A0translate}}</button>\n </div>\n\n <div *ngIf=\"showLogoutDiv\" class=\"login center-block\">\n <p>{{'igo.auth.deconnection' |\u00A0translate}}</p>\n <button *ngIf=\"options.homeRoute\" mat-raised-button type=\"button\" (click)=\"home()\">{{'igo.auth.home' |\u00A0translate}}</button>\n </div>\n\n</div>\n", styles: [":host{z-index:999}div.login{z-index:200;width:90%;min-width:360px;max-width:600px;padding:25px 50px;border:1px solid;background-color:#fff;border-color:#888}.center-block{position:fixed;top:20%;left:50%;transform:translate(-50%)}.backgroundDisable{position:fixed;top:0;left:0;background:#000;opacity:.8;z-index:100;height:100%;width:100%}\n"] }]
1076
- }], function () {
1077
- return [{ type: AuthService }, { type: i2.ConfigService }, { type: i3.Router, decorators: [{
1078
- type: Optional
1079
- }] }];
1080
- }, { backgroundDisable: [{
1081
- type: Input
1082
- }], hasAlreadyConnectedDiv: [{
1083
- type: Input
1084
- }], hasLogoutDiv: [{
1085
- type: Input
1086
- }], showAlreadyConnectedDiv: [{
1087
- type: Input
1088
- }], showLogoutDiv: [{
1089
- type: Input
1090
- }], login: [{
1091
- type: Output
1092
- }] });
798
+ function AuthFormComponent_div_0_div_1_Template(rf, ctx) {
799
+ if (rf & 1) {
800
+ i0.ɵɵelement(0, "div", 3);
801
+ }
802
+ }
803
+ function AuthFormComponent_div_0_div_2_igo_auth_google_4_Template(rf, ctx) {
804
+ if (rf & 1) {
805
+ const _r11 = i0.ɵɵgetCurrentView();
806
+ i0.ɵɵelementStart(0, "igo-auth-google", 7);
807
+ i0.ɵɵlistener("login", function AuthFormComponent_div_0_div_2_igo_auth_google_4_Template_igo_auth_google_login_0_listener() { i0.ɵɵrestoreView(_r11); const ctx_r10 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r10.onLogin()); });
808
+ i0.ɵɵelementEnd();
809
+ }
810
+ }
811
+ function AuthFormComponent_div_0_div_2_igo_auth_microsoft_5_Template(rf, ctx) {
812
+ if (rf & 1) {
813
+ const _r13 = i0.ɵɵgetCurrentView();
814
+ i0.ɵɵelementStart(0, "igo-auth-microsoft", 7);
815
+ i0.ɵɵlistener("login", function AuthFormComponent_div_0_div_2_igo_auth_microsoft_5_Template_igo_auth_microsoft_login_0_listener() { i0.ɵɵrestoreView(_r13); const ctx_r12 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r12.onLogin()); });
816
+ i0.ɵɵelementEnd();
817
+ }
818
+ }
819
+ function AuthFormComponent_div_0_div_2_igo_auth_microsoftb2c_6_Template(rf, ctx) {
820
+ if (rf & 1) {
821
+ const _r15 = i0.ɵɵgetCurrentView();
822
+ i0.ɵɵelementStart(0, "igo-auth-microsoftb2c", 7);
823
+ i0.ɵɵlistener("login", function AuthFormComponent_div_0_div_2_igo_auth_microsoftb2c_6_Template_igo_auth_microsoftb2c_login_0_listener() { i0.ɵɵrestoreView(_r15); const ctx_r14 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r14.onLogin()); });
824
+ i0.ɵɵelementEnd();
825
+ }
826
+ }
827
+ function AuthFormComponent_div_0_div_2_igo_auth_facebook_7_Template(rf, ctx) {
828
+ if (rf & 1) {
829
+ const _r17 = i0.ɵɵgetCurrentView();
830
+ i0.ɵɵelementStart(0, "igo-auth-facebook", 7);
831
+ i0.ɵɵlistener("login", function AuthFormComponent_div_0_div_2_igo_auth_facebook_7_Template_igo_auth_facebook_login_0_listener() { i0.ɵɵrestoreView(_r17); const ctx_r16 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r16.onLogin()); });
832
+ i0.ɵɵelementEnd();
833
+ }
834
+ }
835
+ function AuthFormComponent_div_0_div_2_igo_auth_intern_8_Template(rf, ctx) {
836
+ if (rf & 1) {
837
+ const _r19 = i0.ɵɵgetCurrentView();
838
+ i0.ɵɵelementStart(0, "igo-auth-intern", 8);
839
+ i0.ɵɵlistener("login", function AuthFormComponent_div_0_div_2_igo_auth_intern_8_Template_igo_auth_intern_login_0_listener() { i0.ɵɵrestoreView(_r19); const ctx_r18 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r18.onLogin()); });
840
+ i0.ɵɵelementEnd();
841
+ }
842
+ if (rf & 2) {
843
+ const ctx_r9 = i0.ɵɵnextContext(3);
844
+ i0.ɵɵproperty("allowAnonymous", ctx_r9.options.allowAnonymous);
845
+ }
846
+ }
847
+ function AuthFormComponent_div_0_div_2_Template(rf, ctx) {
848
+ if (rf & 1) {
849
+ i0.ɵɵelementStart(0, "div", 4)(1, "h1");
850
+ i0.ɵɵtext(2);
851
+ i0.ɵɵpipe(3, "translate");
852
+ i0.ɵɵelementEnd();
853
+ i0.ɵɵtemplate(4, AuthFormComponent_div_0_div_2_igo_auth_google_4_Template, 1, 0, "igo-auth-google", 5);
854
+ i0.ɵɵtemplate(5, AuthFormComponent_div_0_div_2_igo_auth_microsoft_5_Template, 1, 0, "igo-auth-microsoft", 5);
855
+ i0.ɵɵtemplate(6, AuthFormComponent_div_0_div_2_igo_auth_microsoftb2c_6_Template, 1, 0, "igo-auth-microsoftb2c", 5);
856
+ i0.ɵɵtemplate(7, AuthFormComponent_div_0_div_2_igo_auth_facebook_7_Template, 1, 0, "igo-auth-facebook", 5);
857
+ i0.ɵɵtemplate(8, AuthFormComponent_div_0_div_2_igo_auth_intern_8_Template, 1, 1, "igo-auth-intern", 6);
858
+ i0.ɵɵelementEnd();
859
+ }
860
+ if (rf & 2) {
861
+ const ctx_r2 = i0.ɵɵnextContext(2);
862
+ i0.ɵɵadvance(2);
863
+ i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(3, 6, "igo.auth.connection"));
864
+ i0.ɵɵadvance(2);
865
+ i0.ɵɵproperty("ngIf", ctx_r2.options.google && ctx_r2.options.google.enabled !== false);
866
+ i0.ɵɵadvance(1);
867
+ i0.ɵɵproperty("ngIf", ctx_r2.options.microsoft && ctx_r2.options.microsoft.enabled !== false);
868
+ i0.ɵɵadvance(1);
869
+ i0.ɵɵproperty("ngIf", ctx_r2.options.microsoftb2c && ctx_r2.options.microsoftb2c.enabled !== false);
870
+ i0.ɵɵadvance(1);
871
+ i0.ɵɵproperty("ngIf", ctx_r2.options.facebook && ctx_r2.options.facebook.enabled !== false);
872
+ i0.ɵɵadvance(1);
873
+ i0.ɵɵproperty("ngIf", !ctx_r2.options.intern || ctx_r2.options.intern.enabled !== false);
874
+ }
875
+ }
876
+ function AuthFormComponent_div_0_div_3_Template(rf, ctx) {
877
+ if (rf & 1) {
878
+ const _r21 = i0.ɵɵgetCurrentView();
879
+ i0.ɵɵelementStart(0, "div", 4)(1, "p");
880
+ i0.ɵɵtext(2);
881
+ i0.ɵɵpipe(3, "translate");
882
+ i0.ɵɵelementEnd();
883
+ i0.ɵɵelementStart(4, "button", 9);
884
+ i0.ɵɵlistener("click", function AuthFormComponent_div_0_div_3_Template_button_click_4_listener() { i0.ɵɵrestoreView(_r21); const ctx_r20 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r20.logout()); });
885
+ i0.ɵɵtext(5);
886
+ i0.ɵɵpipe(6, "translate");
887
+ i0.ɵɵelementEnd()();
888
+ }
889
+ if (rf & 2) {
890
+ const ctx_r3 = i0.ɵɵnextContext(2);
891
+ i0.ɵɵadvance(2);
892
+ i0.ɵɵtextInterpolate(i0.ɵɵpipeBind2(3, 2, "igo.auth.welcome", ctx_r3.user));
893
+ i0.ɵɵadvance(3);
894
+ i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(6, 5, "igo.auth.signOut"));
895
+ }
896
+ }
897
+ function AuthFormComponent_div_0_div_4_button_4_Template(rf, ctx) {
898
+ if (rf & 1) {
899
+ const _r24 = i0.ɵɵgetCurrentView();
900
+ i0.ɵɵelementStart(0, "button", 9);
901
+ i0.ɵɵlistener("click", function AuthFormComponent_div_0_div_4_button_4_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r24); const ctx_r23 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r23.home()); });
902
+ i0.ɵɵtext(1);
903
+ i0.ɵɵpipe(2, "translate");
904
+ i0.ɵɵelementEnd();
905
+ }
906
+ if (rf & 2) {
907
+ i0.ɵɵadvance(1);
908
+ i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(2, 1, "igo.auth.home"));
909
+ }
910
+ }
911
+ function AuthFormComponent_div_0_div_4_Template(rf, ctx) {
912
+ if (rf & 1) {
913
+ i0.ɵɵelementStart(0, "div", 4)(1, "p");
914
+ i0.ɵɵtext(2);
915
+ i0.ɵɵpipe(3, "translate");
916
+ i0.ɵɵelementEnd();
917
+ i0.ɵɵtemplate(4, AuthFormComponent_div_0_div_4_button_4_Template, 3, 3, "button", 10);
918
+ i0.ɵɵelementEnd();
919
+ }
920
+ if (rf & 2) {
921
+ const ctx_r4 = i0.ɵɵnextContext(2);
922
+ i0.ɵɵadvance(2);
923
+ i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(3, 2, "igo.auth.deconnection"));
924
+ i0.ɵɵadvance(2);
925
+ i0.ɵɵproperty("ngIf", ctx_r4.options.homeRoute);
926
+ }
927
+ }
928
+ function AuthFormComponent_div_0_Template(rf, ctx) {
929
+ if (rf & 1) {
930
+ i0.ɵɵelementStart(0, "div");
931
+ i0.ɵɵtemplate(1, AuthFormComponent_div_0_div_1_Template, 1, 0, "div", 1);
932
+ i0.ɵɵtemplate(2, AuthFormComponent_div_0_div_2_Template, 9, 8, "div", 2);
933
+ i0.ɵɵtemplate(3, AuthFormComponent_div_0_div_3_Template, 7, 7, "div", 2);
934
+ i0.ɵɵtemplate(4, AuthFormComponent_div_0_div_4_Template, 5, 4, "div", 2);
935
+ i0.ɵɵelementEnd();
936
+ }
937
+ if (rf & 2) {
938
+ const ctx_r0 = i0.ɵɵnextContext();
939
+ i0.ɵɵadvance(1);
940
+ i0.ɵɵproperty("ngIf", !ctx_r0.auth.logged && ctx_r0.backgroundDisable);
941
+ i0.ɵɵadvance(1);
942
+ i0.ɵɵproperty("ngIf", !ctx_r0.auth.logged && ctx_r0.showLoginDiv);
943
+ i0.ɵɵadvance(1);
944
+ i0.ɵɵproperty("ngIf", ctx_r0.auth.logged && ctx_r0.showAlreadyConnectedDiv);
945
+ i0.ɵɵadvance(1);
946
+ i0.ɵɵproperty("ngIf", ctx_r0.showLogoutDiv);
947
+ }
948
+ }
949
+ class AuthFormComponent {
950
+ constructor(auth, config, router) {
951
+ this.auth = auth;
952
+ this.config = config;
953
+ this.router = router;
954
+ this._backgroundDisable = true;
955
+ this._hasAlreadyConnectedDiv = true;
956
+ this._hasLogoutDiv = true;
957
+ this._showAlreadyConnectedDiv = false;
958
+ this._showLogoutDiv = false;
959
+ this.login = new EventEmitter();
960
+ this.visible = true;
961
+ this.options = this.config.getConfig('auth') || {};
962
+ this.visible = Object.getOwnPropertyNames(this.options).length !== 0;
963
+ }
964
+ get backgroundDisable() {
965
+ if (this.isLogoutRoute || this.isLogoutRoute) {
966
+ return false;
967
+ }
968
+ return this._backgroundDisable;
969
+ }
970
+ set backgroundDisable(value) {
971
+ this._backgroundDisable = value.toString() === 'true';
972
+ }
973
+ get hasAlreadyConnectedDiv() {
974
+ return this._hasAlreadyConnectedDiv;
975
+ }
976
+ set hasAlreadyConnectedDiv(value) {
977
+ this._hasAlreadyConnectedDiv = value.toString() === 'true';
978
+ }
979
+ get hasLogoutDiv() {
980
+ return this._hasLogoutDiv;
981
+ }
982
+ set hasLogoutDiv(value) {
983
+ this._hasLogoutDiv = value.toString() === 'true';
984
+ }
985
+ get showAlreadyConnectedDiv() {
986
+ if (this.isLogoutRoute) {
987
+ return this.hasAlreadyConnectedDiv;
988
+ }
989
+ return this._showAlreadyConnectedDiv;
990
+ }
991
+ set showAlreadyConnectedDiv(value) {
992
+ this._showAlreadyConnectedDiv = value.toString() === 'true';
993
+ }
994
+ get showLogoutDiv() {
995
+ if (this.isLogoutRoute) {
996
+ return this.hasLogoutDiv;
997
+ }
998
+ return this._showLogoutDiv;
999
+ }
1000
+ set showLogoutDiv(value) {
1001
+ this._showLogoutDiv = value.toString() === 'true';
1002
+ }
1003
+ get showLoginDiv() {
1004
+ if (!this.isLogoutRoute) {
1005
+ return true;
1006
+ }
1007
+ }
1008
+ ngOnInit() {
1009
+ this.analyzeRoute();
1010
+ this.getName();
1011
+ }
1012
+ onLogin() {
1013
+ this.auth.goToRedirectUrl();
1014
+ this.getName();
1015
+ this.login.emit(true);
1016
+ }
1017
+ logout() {
1018
+ this.auth.logout().subscribe(() => {
1019
+ this.user = undefined;
1020
+ if (this.router) {
1021
+ if (this.options.logoutRoute) {
1022
+ this.router.navigate([this.options.logoutRoute]);
1023
+ }
1024
+ else if (this.options.homeRoute) {
1025
+ this.router.navigate([this.options.homeRoute]);
1026
+ }
1027
+ }
1028
+ });
1029
+ }
1030
+ home() {
1031
+ if (this.router && this.options.homeRoute) {
1032
+ this.router.navigate([this.options.homeRoute]);
1033
+ }
1034
+ }
1035
+ getName() {
1036
+ const tokenDecoded = this.auth.decodeToken();
1037
+ if (tokenDecoded) {
1038
+ this.user = {
1039
+ name: tokenDecoded.user.firstName || tokenDecoded.user.sourceId
1040
+ };
1041
+ }
1042
+ }
1043
+ analyzeRoute() {
1044
+ if (!this.router) {
1045
+ return;
1046
+ }
1047
+ this.router.events
1048
+ .pipe(filter((event) => event instanceof NavigationStart))
1049
+ .subscribe((changeEvent) => {
1050
+ if (changeEvent.url) {
1051
+ const currentRoute = changeEvent.url;
1052
+ const logoutRoute = this.options.logoutRoute;
1053
+ const loginRoute = this.options.loginRoute;
1054
+ this.isLogoutRoute = currentRoute === logoutRoute;
1055
+ this.isLoginRoute = currentRoute === loginRoute;
1056
+ if (this.isLogoutRoute) {
1057
+ this.auth.logout();
1058
+ }
1059
+ }
1060
+ });
1061
+ }
1062
+ }
1063
+ AuthFormComponent.ɵfac = function AuthFormComponent_Factory(t) { return new (t || AuthFormComponent)(i0.ɵɵdirectiveInject(AuthService), i0.ɵɵdirectiveInject(i2.ConfigService), i0.ɵɵdirectiveInject(i3.Router, 8)); };
1064
+ AuthFormComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AuthFormComponent, selectors: [["igo-auth-form"]], inputs: { backgroundDisable: "backgroundDisable", hasAlreadyConnectedDiv: "hasAlreadyConnectedDiv", hasLogoutDiv: "hasLogoutDiv", showAlreadyConnectedDiv: "showAlreadyConnectedDiv", showLogoutDiv: "showLogoutDiv" }, outputs: { login: "login" }, decls: 1, vars: 1, consts: [[4, "ngIf"], ["class", "backgroundDisable", 4, "ngIf"], ["class", "login center-block", 4, "ngIf"], [1, "backgroundDisable"], [1, "login", "center-block"], [3, "login", 4, "ngIf"], [3, "allowAnonymous", "login", 4, "ngIf"], [3, "login"], [3, "allowAnonymous", "login"], ["mat-raised-button", "", "type", "button", 3, "click"], ["mat-raised-button", "", "type", "button", 3, "click", 4, "ngIf"]], template: function AuthFormComponent_Template(rf, ctx) {
1065
+ if (rf & 1) {
1066
+ i0.ɵɵtemplate(0, AuthFormComponent_div_0_Template, 5, 4, "div", 0);
1067
+ }
1068
+ if (rf & 2) {
1069
+ i0.ɵɵproperty("ngIf", ctx.visible);
1070
+ }
1071
+ }, dependencies: [i1$1.NgIf, i5$1.MatButton, AuthGoogleComponent, AuthInternComponent, AuthFacebookComponent, AuthMicrosoftComponent, AuthMicrosoftb2cComponent, i6$1.TranslatePipe], styles: ["[_nghost-%COMP%]{z-index:999}div.login[_ngcontent-%COMP%]{z-index:200;width:90%;min-width:360px;max-width:600px;padding:25px 50px;border:1px solid;background-color:#fff;border-color:#888}.center-block[_ngcontent-%COMP%]{position:fixed;top:20%;left:50%;transform:translate(-50%)}.backgroundDisable[_ngcontent-%COMP%]{position:fixed;top:0;left:0;background:#000;opacity:.8;z-index:100;height:100%;width:100%}"] });
1072
+ (function () {
1073
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthFormComponent, [{
1074
+ type: Component,
1075
+ args: [{ selector: 'igo-auth-form', changeDetection: ChangeDetectionStrategy.Default, template: "<div *ngIf=\"visible\">\n <div *ngIf=\"!auth.logged && backgroundDisable\" class=\"backgroundDisable\"></div>\n\n <div *ngIf=\"!auth.logged && showLoginDiv\" class=\"login center-block\">\n <h1>{{'igo.auth.connection' | translate}}</h1>\n\n <igo-auth-google\n *ngIf=\"options.google && options.google.enabled !== false\"\n (login)=\"onLogin()\">\n </igo-auth-google>\n <igo-auth-microsoft\n *ngIf=\"options.microsoft && options.microsoft.enabled !== false\"\n (login)=\"onLogin()\">\n </igo-auth-microsoft>\n <igo-auth-microsoftb2c\n *ngIf=\"options.microsoftb2c && options.microsoftb2c.enabled !== false\"\n (login)=\"onLogin()\">\n </igo-auth-microsoftb2c>\n <igo-auth-facebook\n *ngIf=\"options.facebook && options.facebook.enabled !== false\"\n (login)=\"onLogin()\">\n </igo-auth-facebook>\n <igo-auth-intern\n *ngIf=\"!options.intern || options.intern.enabled !== false\"\n [allowAnonymous]=\"options.allowAnonymous\"\n (login)=\"onLogin()\">\n </igo-auth-intern>\n </div>\n\n <div *ngIf=\"auth.logged && showAlreadyConnectedDiv\" class=\"login center-block\">\n <p>{{'igo.auth.welcome' |\u00A0translate: user}}</p>\n <button mat-raised-button type=\"button\" (click)=\"logout()\">{{'igo.auth.signOut' |\u00A0translate}}</button>\n </div>\n\n <div *ngIf=\"showLogoutDiv\" class=\"login center-block\">\n <p>{{'igo.auth.deconnection' |\u00A0translate}}</p>\n <button *ngIf=\"options.homeRoute\" mat-raised-button type=\"button\" (click)=\"home()\">{{'igo.auth.home' |\u00A0translate}}</button>\n </div>\n\n</div>\n", styles: [":host{z-index:999}div.login{z-index:200;width:90%;min-width:360px;max-width:600px;padding:25px 50px;border:1px solid;background-color:#fff;border-color:#888}.center-block{position:fixed;top:20%;left:50%;transform:translate(-50%)}.backgroundDisable{position:fixed;top:0;left:0;background:#000;opacity:.8;z-index:100;height:100%;width:100%}\n"] }]
1076
+ }], function () {
1077
+ return [{ type: AuthService }, { type: i2.ConfigService }, { type: i3.Router, decorators: [{
1078
+ type: Optional
1079
+ }] }];
1080
+ }, { backgroundDisable: [{
1081
+ type: Input
1082
+ }], hasAlreadyConnectedDiv: [{
1083
+ type: Input
1084
+ }], hasLogoutDiv: [{
1085
+ type: Input
1086
+ }], showAlreadyConnectedDiv: [{
1087
+ type: Input
1088
+ }], showLogoutDiv: [{
1089
+ type: Input
1090
+ }], login: [{
1091
+ type: Output
1092
+ }] });
1093
1093
  })();
1094
1094
 
1095
- class LoggedGuard {
1096
- constructor(authService, config, router) {
1097
- this.authService = authService;
1098
- this.config = config;
1099
- this.router = router;
1100
- }
1101
- canActivate(route, state) {
1102
- if (this.authService.logged) {
1103
- return true;
1104
- }
1105
- this.authService.redirectUrl = state.url;
1106
- const authConfig = this.config.getConfig('auth');
1107
- if (authConfig && authConfig.loginRoute) {
1108
- this.router.navigateByUrl(authConfig.loginRoute);
1109
- }
1110
- return false;
1111
- }
1112
- }
1113
- LoggedGuard.ɵfac = function LoggedGuard_Factory(t) { return new (t || LoggedGuard)(i0.ɵɵinject(AuthService), i0.ɵɵinject(i2.ConfigService), i0.ɵɵinject(i3.Router)); };
1114
- LoggedGuard.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: LoggedGuard, factory: LoggedGuard.ɵfac, providedIn: 'root' });
1115
- (function () {
1116
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LoggedGuard, [{
1117
- type: Injectable,
1118
- args: [{
1119
- providedIn: 'root'
1120
- }]
1121
- }], function () { return [{ type: AuthService }, { type: i2.ConfigService }, { type: i3.Router }]; }, null);
1095
+ class LoggedGuard {
1096
+ constructor(authService, config, router) {
1097
+ this.authService = authService;
1098
+ this.config = config;
1099
+ this.router = router;
1100
+ }
1101
+ canActivate(route, state) {
1102
+ if (this.authService.logged) {
1103
+ return true;
1104
+ }
1105
+ this.authService.redirectUrl = state.url;
1106
+ const authConfig = this.config.getConfig('auth');
1107
+ if (authConfig && authConfig.loginRoute) {
1108
+ this.router.navigateByUrl(authConfig.loginRoute);
1109
+ }
1110
+ return false;
1111
+ }
1112
+ }
1113
+ LoggedGuard.ɵfac = function LoggedGuard_Factory(t) { return new (t || LoggedGuard)(i0.ɵɵinject(AuthService), i0.ɵɵinject(i2.ConfigService), i0.ɵɵinject(i3.Router)); };
1114
+ LoggedGuard.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: LoggedGuard, factory: LoggedGuard.ɵfac, providedIn: 'root' });
1115
+ (function () {
1116
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LoggedGuard, [{
1117
+ type: Injectable,
1118
+ args: [{
1119
+ providedIn: 'root'
1120
+ }]
1121
+ }], function () { return [{ type: AuthService }, { type: i2.ConfigService }, { type: i3.Router }]; }, null);
1122
1122
  })();
1123
1123
 
1124
- class AuthGuard {
1125
- constructor(authService, config, router) {
1126
- this.authService = authService;
1127
- this.config = config;
1128
- this.router = router;
1129
- }
1130
- canActivate(route, state) {
1131
- if (this.authService.authenticated) {
1132
- return true;
1133
- }
1134
- this.authService.redirectUrl = state.url;
1135
- const authConfig = this.config.getConfig('auth');
1136
- if (authConfig && authConfig.loginRoute) {
1137
- this.router.navigateByUrl(authConfig.loginRoute);
1138
- }
1139
- return false;
1140
- }
1141
- }
1142
- AuthGuard.ɵfac = function AuthGuard_Factory(t) { return new (t || AuthGuard)(i0.ɵɵinject(AuthService), i0.ɵɵinject(i2.ConfigService), i0.ɵɵinject(i3.Router)); };
1143
- AuthGuard.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AuthGuard, factory: AuthGuard.ɵfac, providedIn: 'root' });
1144
- (function () {
1145
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthGuard, [{
1146
- type: Injectable,
1147
- args: [{
1148
- providedIn: 'root'
1149
- }]
1150
- }], function () { return [{ type: AuthService }, { type: i2.ConfigService }, { type: i3.Router }]; }, null);
1124
+ class AuthGuard {
1125
+ constructor(authService, config, router) {
1126
+ this.authService = authService;
1127
+ this.config = config;
1128
+ this.router = router;
1129
+ }
1130
+ canActivate(route, state) {
1131
+ if (this.authService.authenticated) {
1132
+ return true;
1133
+ }
1134
+ this.authService.redirectUrl = state.url;
1135
+ const authConfig = this.config.getConfig('auth');
1136
+ if (authConfig && authConfig.loginRoute) {
1137
+ this.router.navigateByUrl(authConfig.loginRoute);
1138
+ }
1139
+ return false;
1140
+ }
1141
+ }
1142
+ AuthGuard.ɵfac = function AuthGuard_Factory(t) { return new (t || AuthGuard)(i0.ɵɵinject(AuthService), i0.ɵɵinject(i2.ConfigService), i0.ɵɵinject(i3.Router)); };
1143
+ AuthGuard.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AuthGuard, factory: AuthGuard.ɵfac, providedIn: 'root' });
1144
+ (function () {
1145
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthGuard, [{
1146
+ type: Injectable,
1147
+ args: [{
1148
+ providedIn: 'root'
1149
+ }]
1150
+ }], function () { return [{ type: AuthService }, { type: i2.ConfigService }, { type: i3.Router }]; }, null);
1151
1151
  })();
1152
1152
 
1153
- class AdminGuard {
1154
- constructor(authService, config, router) {
1155
- this.authService = authService;
1156
- this.config = config;
1157
- this.router = router;
1158
- }
1159
- canActivate(route, state) {
1160
- const token = this.authService.decodeToken();
1161
- if (token && token.user && token.user.isAdmin) {
1162
- return true;
1163
- }
1164
- this.authService.redirectUrl = state.url;
1165
- const authConfig = this.config.getConfig('auth');
1166
- if (authConfig && authConfig.loginRoute) {
1167
- this.router.navigateByUrl(authConfig.loginRoute);
1168
- }
1169
- return false;
1170
- }
1171
- }
1172
- AdminGuard.ɵfac = function AdminGuard_Factory(t) { return new (t || AdminGuard)(i0.ɵɵinject(AuthService), i0.ɵɵinject(i2.ConfigService), i0.ɵɵinject(i3.Router)); };
1173
- AdminGuard.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AdminGuard, factory: AdminGuard.ɵfac, providedIn: 'root' });
1174
- (function () {
1175
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AdminGuard, [{
1176
- type: Injectable,
1177
- args: [{
1178
- providedIn: 'root'
1179
- }]
1180
- }], function () { return [{ type: AuthService }, { type: i2.ConfigService }, { type: i3.Router }]; }, null);
1153
+ class AdminGuard {
1154
+ constructor(authService, config, router) {
1155
+ this.authService = authService;
1156
+ this.config = config;
1157
+ this.router = router;
1158
+ }
1159
+ canActivate(route, state) {
1160
+ const token = this.authService.decodeToken();
1161
+ if (token && token.user && token.user.isAdmin) {
1162
+ return true;
1163
+ }
1164
+ this.authService.redirectUrl = state.url;
1165
+ const authConfig = this.config.getConfig('auth');
1166
+ if (authConfig && authConfig.loginRoute) {
1167
+ this.router.navigateByUrl(authConfig.loginRoute);
1168
+ }
1169
+ return false;
1170
+ }
1171
+ }
1172
+ AdminGuard.ɵfac = function AdminGuard_Factory(t) { return new (t || AdminGuard)(i0.ɵɵinject(AuthService), i0.ɵɵinject(i2.ConfigService), i0.ɵɵinject(i3.Router)); };
1173
+ AdminGuard.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AdminGuard, factory: AdminGuard.ɵfac, providedIn: 'root' });
1174
+ (function () {
1175
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AdminGuard, [{
1176
+ type: Injectable,
1177
+ args: [{
1178
+ providedIn: 'root'
1179
+ }]
1180
+ }], function () { return [{ type: AuthService }, { type: i2.ConfigService }, { type: i3.Router }]; }, null);
1181
1181
  })();
1182
1182
 
1183
- class ProfilsGuard {
1184
- constructor(authService, config, router) {
1185
- this.authService = authService;
1186
- this.config = config;
1187
- this.router = router;
1188
- }
1189
- canActivate(_route, state) {
1190
- return this.authService.getProfils().pipe(map((profils) => {
1191
- const authConfig = this.config.getConfig('auth');
1192
- if (profils &&
1193
- profils.profils &&
1194
- profils.profils.some(v => authConfig.profilsGuard.indexOf(v) !== -1)) {
1195
- return true;
1196
- }
1197
- this.authService.redirectUrl = state.url;
1198
- if (authConfig && authConfig.loginRoute) {
1199
- this.router.navigateByUrl(authConfig.loginRoute);
1200
- }
1201
- return false;
1202
- }));
1203
- }
1204
- }
1205
- ProfilsGuard.ɵfac = function ProfilsGuard_Factory(t) { return new (t || ProfilsGuard)(i0.ɵɵinject(AuthService), i0.ɵɵinject(i2.ConfigService), i0.ɵɵinject(i3.Router)); };
1206
- ProfilsGuard.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ProfilsGuard, factory: ProfilsGuard.ɵfac, providedIn: 'root' });
1207
- (function () {
1208
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ProfilsGuard, [{
1209
- type: Injectable,
1210
- args: [{
1211
- providedIn: 'root'
1212
- }]
1213
- }], function () { return [{ type: AuthService }, { type: i2.ConfigService }, { type: i3.Router }]; }, null);
1183
+ class ProfilsGuard {
1184
+ constructor(authService, config, router) {
1185
+ this.authService = authService;
1186
+ this.config = config;
1187
+ this.router = router;
1188
+ }
1189
+ canActivate(_route, state) {
1190
+ return this.authService.getProfils().pipe(map((profils) => {
1191
+ const authConfig = this.config.getConfig('auth');
1192
+ if (profils &&
1193
+ profils.profils &&
1194
+ profils.profils.some(v => authConfig.profilsGuard.indexOf(v) !== -1)) {
1195
+ return true;
1196
+ }
1197
+ this.authService.redirectUrl = state.url;
1198
+ if (authConfig && authConfig.loginRoute) {
1199
+ this.router.navigateByUrl(authConfig.loginRoute);
1200
+ }
1201
+ return false;
1202
+ }));
1203
+ }
1204
+ }
1205
+ ProfilsGuard.ɵfac = function ProfilsGuard_Factory(t) { return new (t || ProfilsGuard)(i0.ɵɵinject(AuthService), i0.ɵɵinject(i2.ConfigService), i0.ɵɵinject(i3.Router)); };
1206
+ ProfilsGuard.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ProfilsGuard, factory: ProfilsGuard.ɵfac, providedIn: 'root' });
1207
+ (function () {
1208
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ProfilsGuard, [{
1209
+ type: Injectable,
1210
+ args: [{
1211
+ providedIn: 'root'
1212
+ }]
1213
+ }], function () { return [{ type: AuthService }, { type: i2.ConfigService }, { type: i3.Router }]; }, null);
1214
1214
  })();
1215
1215
 
1216
- class AuthInterceptor {
1217
- constructor(config, tokenService, http) {
1218
- this.config = config;
1219
- this.tokenService = tokenService;
1220
- this.http = http;
1221
- this.refreshInProgress = false;
1222
- }
1223
- get trustHosts() {
1224
- const trustHosts = this.config.getConfig('auth.trustHosts') || [];
1225
- trustHosts.push(window.location.hostname);
1226
- return trustHosts;
1227
- }
1228
- get hostsWithCredentials() {
1229
- return this.config.getConfig('auth.hostsWithCredentials') || [];
1230
- }
1231
- get hostsWithAuthByKey() {
1232
- return this.config.getConfig('auth.hostsByKey') || [];
1233
- }
1234
- intercept(originalReq, next) {
1235
- const withCredentials = this.handleHostsWithCredentials(originalReq.url);
1236
- let req = originalReq.clone();
1237
- const hostWithKey = this.handleHostsAuthByKey(originalReq.url);
1238
- if (hostWithKey) {
1239
- req = req.clone({
1240
- params: req.params.set(hostWithKey.key, hostWithKey.value)
1241
- });
1242
- }
1243
- if (withCredentials) {
1244
- req = originalReq.clone({
1245
- withCredentials
1246
- });
1247
- return next.handle(req);
1248
- }
1249
- this.refreshToken();
1250
- const token = this.tokenService.get();
1251
- const element = document.createElement('a');
1252
- element.href = req.url;
1253
- if (element.host === '') {
1254
- element.href = element.href; // FIX IE11, DO NOT REMOVE
1255
- }
1256
- if (!token || this.trustHosts.indexOf(element.hostname) === -1) {
1257
- return next.handle(req);
1258
- }
1259
- const authHeader = `Bearer ${token}`;
1260
- let authReq = req.clone({
1261
- headers: req.headers.set('Authorization', authHeader)
1262
- });
1263
- const tokenDecoded = this.tokenService.decode();
1264
- if (authReq.params.get('_i') === 'true' &&
1265
- tokenDecoded &&
1266
- tokenDecoded.user &&
1267
- tokenDecoded.user.sourceId) {
1268
- const hashUser = Md5.hashStr(tokenDecoded.user.sourceId);
1269
- authReq = authReq.clone({
1270
- params: authReq.params.set('_i', hashUser)
1271
- });
1272
- }
1273
- else if (authReq.params.get('_i') === 'true') {
1274
- authReq = authReq.clone({
1275
- params: authReq.params.delete('_i')
1276
- });
1277
- }
1278
- return next.handle(authReq);
1279
- }
1280
- interceptXhr(xhr, url) {
1281
- const withCredentials = this.handleHostsWithCredentials(url);
1282
- if (withCredentials) {
1283
- xhr.withCredentials = withCredentials;
1284
- return true;
1285
- }
1286
- this.refreshToken();
1287
- const element = document.createElement('a');
1288
- element.href = url;
1289
- const token = this.tokenService.get();
1290
- if (!token || this.trustHosts.indexOf(element.hostname) === -1) {
1291
- return false;
1292
- }
1293
- xhr.setRequestHeader('Authorization', 'Bearer ' + token);
1294
- return true;
1295
- }
1296
- alterUrlWithKeyAuth(url) {
1297
- const hostWithKey = this.handleHostsAuthByKey(url);
1298
- let interceptedUrl = url;
1299
- if (hostWithKey) {
1300
- const urlDecomposed = interceptedUrl.split(/[?&]/);
1301
- let urlWithKeyAdded = urlDecomposed.shift();
1302
- const paramsToKeep = urlDecomposed.filter(p => p.length !== 0);
1303
- paramsToKeep.push(`${hostWithKey.key}=${hostWithKey.value}`);
1304
- if (paramsToKeep.length) {
1305
- urlWithKeyAdded += '?' + paramsToKeep.join('&');
1306
- }
1307
- return urlWithKeyAdded;
1308
- }
1309
- return;
1310
- }
1311
- handleHostsWithCredentials(reqUrl) {
1312
- let withCredentials = false;
1313
- for (const hostWithCredentials of this.hostsWithCredentials) {
1314
- const domainRegex = new RegExp(hostWithCredentials.domainRegFilters);
1315
- if (domainRegex.test(reqUrl)) {
1316
- withCredentials = hostWithCredentials.withCredentials !== undefined ? hostWithCredentials.withCredentials : undefined;
1317
- break;
1318
- }
1319
- }
1320
- return withCredentials;
1321
- }
1322
- handleHostsAuthByKey(reqUrl) {
1323
- let hostWithKey;
1324
- for (const hostWithAuthByKey of this.hostsWithAuthByKey) {
1325
- const domainRegex = new RegExp(hostWithAuthByKey.domainRegFilters);
1326
- if (domainRegex.test(reqUrl)) {
1327
- var replace = `${hostWithAuthByKey.keyProperty}=${hostWithAuthByKey.keyValue}`;
1328
- var keyAdded = new RegExp(replace, "gm");
1329
- if (!keyAdded.test(reqUrl)) {
1330
- hostWithKey = { key: hostWithAuthByKey.keyProperty, value: hostWithAuthByKey.keyValue };
1331
- break;
1332
- }
1333
- }
1334
- }
1335
- return hostWithKey;
1336
- }
1337
- refreshToken() {
1338
- const jwt = this.tokenService.decode();
1339
- const currentTime = new Date().getTime() / 1000;
1340
- if (!this.refreshInProgress &&
1341
- jwt &&
1342
- currentTime < jwt.exp &&
1343
- currentTime > jwt.exp - 1800) {
1344
- this.refreshInProgress = true;
1345
- const url = this.config.getConfig('auth.url');
1346
- return this.http.post(`${url}/refresh`, {}).subscribe((data) => {
1347
- this.tokenService.set(data.token);
1348
- this.refreshInProgress = false;
1349
- }, err => {
1350
- err.error.caught = true;
1351
- return err;
1352
- });
1353
- }
1354
- }
1355
- }
1356
- AuthInterceptor.ɵfac = function AuthInterceptor_Factory(t) { return new (t || AuthInterceptor)(i0.ɵɵinject(i2.ConfigService), i0.ɵɵinject(TokenService), i0.ɵɵinject(i1.HttpClient)); };
1357
- AuthInterceptor.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AuthInterceptor, factory: AuthInterceptor.ɵfac, providedIn: 'root' });
1358
- (function () {
1359
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthInterceptor, [{
1360
- type: Injectable,
1361
- args: [{
1362
- providedIn: 'root'
1363
- }]
1364
- }], function () { return [{ type: i2.ConfigService }, { type: TokenService }, { type: i1.HttpClient }]; }, null);
1216
+ class AuthInterceptor {
1217
+ constructor(config, tokenService, http) {
1218
+ this.config = config;
1219
+ this.tokenService = tokenService;
1220
+ this.http = http;
1221
+ this.refreshInProgress = false;
1222
+ }
1223
+ get trustHosts() {
1224
+ const trustHosts = this.config.getConfig('auth.trustHosts') || [];
1225
+ trustHosts.push(window.location.hostname);
1226
+ return trustHosts;
1227
+ }
1228
+ get hostsWithCredentials() {
1229
+ return this.config.getConfig('auth.hostsWithCredentials') || [];
1230
+ }
1231
+ get hostsWithAuthByKey() {
1232
+ return this.config.getConfig('auth.hostsByKey') || [];
1233
+ }
1234
+ intercept(originalReq, next) {
1235
+ const withCredentials = this.handleHostsWithCredentials(originalReq.url);
1236
+ let req = originalReq.clone();
1237
+ const hostWithKey = this.handleHostsAuthByKey(originalReq.url);
1238
+ if (hostWithKey) {
1239
+ req = req.clone({
1240
+ params: req.params.set(hostWithKey.key, hostWithKey.value)
1241
+ });
1242
+ }
1243
+ if (withCredentials) {
1244
+ req = originalReq.clone({
1245
+ withCredentials
1246
+ });
1247
+ return next.handle(req);
1248
+ }
1249
+ this.refreshToken();
1250
+ const token = this.tokenService.get();
1251
+ const element = document.createElement('a');
1252
+ element.href = req.url;
1253
+ if (element.host === '') {
1254
+ element.href = element.href; // FIX IE11, DO NOT REMOVE
1255
+ }
1256
+ if (!token || this.trustHosts.indexOf(element.hostname) === -1) {
1257
+ return next.handle(req);
1258
+ }
1259
+ const authHeader = `Bearer ${token}`;
1260
+ let authReq = req.clone({
1261
+ headers: req.headers.set('Authorization', authHeader)
1262
+ });
1263
+ const tokenDecoded = this.tokenService.decode();
1264
+ if (authReq.params.get('_i') === 'true' &&
1265
+ tokenDecoded &&
1266
+ tokenDecoded.user &&
1267
+ tokenDecoded.user.sourceId) {
1268
+ const hashUser = Md5.hashStr(tokenDecoded.user.sourceId);
1269
+ authReq = authReq.clone({
1270
+ params: authReq.params.set('_i', hashUser)
1271
+ });
1272
+ }
1273
+ else if (authReq.params.get('_i') === 'true') {
1274
+ authReq = authReq.clone({
1275
+ params: authReq.params.delete('_i')
1276
+ });
1277
+ }
1278
+ return next.handle(authReq);
1279
+ }
1280
+ interceptXhr(xhr, url) {
1281
+ const withCredentials = this.handleHostsWithCredentials(url);
1282
+ if (withCredentials) {
1283
+ xhr.withCredentials = withCredentials;
1284
+ return true;
1285
+ }
1286
+ this.refreshToken();
1287
+ const element = document.createElement('a');
1288
+ element.href = url;
1289
+ const token = this.tokenService.get();
1290
+ if (!token || this.trustHosts.indexOf(element.hostname) === -1) {
1291
+ return false;
1292
+ }
1293
+ xhr.setRequestHeader('Authorization', 'Bearer ' + token);
1294
+ return true;
1295
+ }
1296
+ alterUrlWithKeyAuth(url) {
1297
+ const hostWithKey = this.handleHostsAuthByKey(url);
1298
+ let interceptedUrl = url;
1299
+ if (hostWithKey) {
1300
+ const urlDecomposed = interceptedUrl.split(/[?&]/);
1301
+ let urlWithKeyAdded = urlDecomposed.shift();
1302
+ const paramsToKeep = urlDecomposed.filter(p => p.length !== 0);
1303
+ paramsToKeep.push(`${hostWithKey.key}=${hostWithKey.value}`);
1304
+ if (paramsToKeep.length) {
1305
+ urlWithKeyAdded += '?' + paramsToKeep.join('&');
1306
+ }
1307
+ return urlWithKeyAdded;
1308
+ }
1309
+ return;
1310
+ }
1311
+ handleHostsWithCredentials(reqUrl) {
1312
+ let withCredentials = false;
1313
+ for (const hostWithCredentials of this.hostsWithCredentials) {
1314
+ const domainRegex = new RegExp(hostWithCredentials.domainRegFilters);
1315
+ if (domainRegex.test(reqUrl)) {
1316
+ withCredentials = hostWithCredentials.withCredentials !== undefined ? hostWithCredentials.withCredentials : undefined;
1317
+ break;
1318
+ }
1319
+ }
1320
+ return withCredentials;
1321
+ }
1322
+ handleHostsAuthByKey(reqUrl) {
1323
+ let hostWithKey;
1324
+ for (const hostWithAuthByKey of this.hostsWithAuthByKey) {
1325
+ const domainRegex = new RegExp(hostWithAuthByKey.domainRegFilters);
1326
+ if (domainRegex.test(reqUrl)) {
1327
+ var replace = `${hostWithAuthByKey.keyProperty}=${hostWithAuthByKey.keyValue}`;
1328
+ var keyAdded = new RegExp(replace, "gm");
1329
+ if (!keyAdded.test(reqUrl)) {
1330
+ hostWithKey = { key: hostWithAuthByKey.keyProperty, value: hostWithAuthByKey.keyValue };
1331
+ break;
1332
+ }
1333
+ }
1334
+ }
1335
+ return hostWithKey;
1336
+ }
1337
+ refreshToken() {
1338
+ const jwt = this.tokenService.decode();
1339
+ const currentTime = new Date().getTime() / 1000;
1340
+ if (!this.refreshInProgress &&
1341
+ jwt &&
1342
+ currentTime < jwt.exp &&
1343
+ currentTime > jwt.exp - 1800) {
1344
+ this.refreshInProgress = true;
1345
+ const url = this.config.getConfig('auth.url');
1346
+ return this.http.post(`${url}/refresh`, {}).subscribe((data) => {
1347
+ this.tokenService.set(data.token);
1348
+ this.refreshInProgress = false;
1349
+ }, err => {
1350
+ err.error.caught = true;
1351
+ return err;
1352
+ });
1353
+ }
1354
+ }
1355
+ }
1356
+ AuthInterceptor.ɵfac = function AuthInterceptor_Factory(t) { return new (t || AuthInterceptor)(i0.ɵɵinject(i2.ConfigService), i0.ɵɵinject(TokenService), i0.ɵɵinject(i1.HttpClient)); };
1357
+ AuthInterceptor.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AuthInterceptor, factory: AuthInterceptor.ɵfac, providedIn: 'root' });
1358
+ (function () {
1359
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthInterceptor, [{
1360
+ type: Injectable,
1361
+ args: [{
1362
+ providedIn: 'root'
1363
+ }]
1364
+ }], function () { return [{ type: i2.ConfigService }, { type: TokenService }, { type: i1.HttpClient }]; }, null);
1365
1365
  })();
1366
1366
 
1367
- function MSALConfigFactory(config) {
1368
- const msConf = config.getConfig('auth.microsoft') || {};
1369
- msConf.redirectUri = msConf.redirectUri || window.location.href;
1370
- msConf.authority = msConf.authority || 'https://login.microsoftonline.com/organizations';
1371
- const myMsalObj = new PublicClientApplication({
1372
- auth: msConf,
1373
- cache: {
1374
- cacheLocation: 'sessionStorage'
1375
- }
1376
- });
1377
- return myMsalObj;
1378
- }
1379
- function MSALConfigFactoryb2c(config) {
1380
- const msConf = config.getConfig('auth.microsoftb2c.browserAuthOptions') || {};
1381
- msConf.redirectUri = msConf.redirectUri || window.location.href;
1382
- msConf.authority = msConf.authority || 'https://login.microsoftonline.com/organizations';
1383
- const myMsalObj = new PublicClientApplication({
1384
- auth: msConf,
1385
- cache: {
1386
- cacheLocation: 'sessionStorage'
1387
- }
1388
- });
1389
- return myMsalObj;
1390
- }
1391
- function MSALAngularConfigFactory(config) {
1392
- const msConf = config.getConfig('auth.microsoft') || {};
1393
- return {
1394
- interactionType: InteractionType.Popup,
1395
- authRequest: {
1396
- scopes: ['user.read'],
1397
- loginHint: 'todo',
1398
- },
1399
- type: 'add'
1400
- };
1401
- }
1402
- function MSALAngularConfigFactoryb2c(config) {
1403
- const msConf = config.getConfig('auth.microsoftb2c.browserAuthOptions') || {};
1404
- return {
1405
- interactionType: InteractionType.Popup,
1406
- authRequest: {
1407
- scopes: [msConf.clientId]
1408
- },
1409
- type: 'b2c'
1410
- };
1411
- }
1412
- function provideAuthMicrosoft(type) {
1413
- if (type === 'b2c') {
1414
- return [
1415
- {
1416
- provide: MSAL_INSTANCE,
1417
- useFactory: MSALConfigFactoryb2c,
1418
- deps: [ConfigService]
1419
- },
1420
- {
1421
- provide: MSAL_GUARD_CONFIG,
1422
- useFactory: MSALAngularConfigFactoryb2c,
1423
- deps: [ConfigService],
1424
- multi: true
1425
- },
1426
- MsalServiceb2c
1427
- ];
1428
- }
1429
- else {
1430
- return [
1431
- {
1432
- provide: MSAL_INSTANCE,
1433
- useFactory: MSALConfigFactory,
1434
- deps: [ConfigService]
1435
- },
1436
- {
1437
- provide: MSAL_GUARD_CONFIG,
1438
- useFactory: MSALAngularConfigFactory,
1439
- deps: [ConfigService],
1440
- multi: true
1441
- },
1442
- MsalService
1443
- ];
1444
- }
1367
+ function MSALConfigFactory(config) {
1368
+ const msConf = config.getConfig('auth.microsoft') || {};
1369
+ msConf.redirectUri = msConf.redirectUri || window.location.href;
1370
+ msConf.authority = msConf.authority || 'https://login.microsoftonline.com/organizations';
1371
+ const myMsalObj = new PublicClientApplication({
1372
+ auth: msConf,
1373
+ cache: {
1374
+ cacheLocation: 'sessionStorage'
1375
+ }
1376
+ });
1377
+ return myMsalObj;
1378
+ }
1379
+ function MSALConfigFactoryb2c(config) {
1380
+ const msConf = config.getConfig('auth.microsoftb2c.browserAuthOptions') || {};
1381
+ msConf.redirectUri = msConf.redirectUri || window.location.href;
1382
+ msConf.authority = msConf.authority || 'https://login.microsoftonline.com/organizations';
1383
+ const myMsalObj = new PublicClientApplication({
1384
+ auth: msConf,
1385
+ cache: {
1386
+ cacheLocation: 'sessionStorage'
1387
+ }
1388
+ });
1389
+ return myMsalObj;
1390
+ }
1391
+ function MSALAngularConfigFactory(config) {
1392
+ const msConf = config.getConfig('auth.microsoft') || {};
1393
+ return {
1394
+ interactionType: InteractionType.Popup,
1395
+ authRequest: {
1396
+ scopes: ['user.read'],
1397
+ loginHint: 'todo',
1398
+ },
1399
+ type: 'add'
1400
+ };
1401
+ }
1402
+ function MSALAngularConfigFactoryb2c(config) {
1403
+ const msConf = config.getConfig('auth.microsoftb2c.browserAuthOptions') || {};
1404
+ return {
1405
+ interactionType: InteractionType.Popup,
1406
+ authRequest: {
1407
+ scopes: [msConf.clientId]
1408
+ },
1409
+ type: 'b2c'
1410
+ };
1411
+ }
1412
+ function provideAuthMicrosoft(type) {
1413
+ if (type === 'b2c') {
1414
+ return [
1415
+ {
1416
+ provide: MSAL_INSTANCE,
1417
+ useFactory: MSALConfigFactoryb2c,
1418
+ deps: [ConfigService]
1419
+ },
1420
+ {
1421
+ provide: MSAL_GUARD_CONFIG,
1422
+ useFactory: MSALAngularConfigFactoryb2c,
1423
+ deps: [ConfigService],
1424
+ multi: true
1425
+ },
1426
+ MsalServiceb2c
1427
+ ];
1428
+ }
1429
+ else {
1430
+ return [
1431
+ {
1432
+ provide: MSAL_INSTANCE,
1433
+ useFactory: MSALConfigFactory,
1434
+ deps: [ConfigService]
1435
+ },
1436
+ {
1437
+ provide: MSAL_GUARD_CONFIG,
1438
+ useFactory: MSALAngularConfigFactory,
1439
+ deps: [ConfigService],
1440
+ multi: true
1441
+ },
1442
+ MsalService
1443
+ ];
1444
+ }
1445
1445
  }
1446
1446
 
1447
- class ProtectedDirective {
1448
- constructor(authentication, el) {
1449
- if (!authentication.isAuthenticated()) {
1450
- el.nativeElement.parentNode.removeChild(el.nativeElement);
1451
- }
1452
- }
1453
- }
1454
- ProtectedDirective.ɵfac = function ProtectedDirective_Factory(t) { return new (t || ProtectedDirective)(i0.ɵɵdirectiveInject(AuthService), i0.ɵɵdirectiveInject(i0.ElementRef)); };
1455
- ProtectedDirective.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: ProtectedDirective, selectors: [["", "igoProtected", ""]] });
1456
- (function () {
1457
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ProtectedDirective, [{
1458
- type: Directive,
1459
- args: [{
1460
- selector: '[igoProtected]'
1461
- }]
1462
- }], function () { return [{ type: AuthService }, { type: i0.ElementRef }]; }, null);
1447
+ class ProtectedDirective {
1448
+ constructor(authentication, el) {
1449
+ if (!authentication.isAuthenticated()) {
1450
+ el.nativeElement.parentNode.removeChild(el.nativeElement);
1451
+ }
1452
+ }
1453
+ }
1454
+ ProtectedDirective.ɵfac = function ProtectedDirective_Factory(t) { return new (t || ProtectedDirective)(i0.ɵɵdirectiveInject(AuthService), i0.ɵɵdirectiveInject(i0.ElementRef)); };
1455
+ ProtectedDirective.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: ProtectedDirective, selectors: [["", "igoProtected", ""]] });
1456
+ (function () {
1457
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ProtectedDirective, [{
1458
+ type: Directive,
1459
+ args: [{
1460
+ selector: '[igoProtected]'
1461
+ }]
1462
+ }], function () { return [{ type: AuthService }, { type: i0.ElementRef }]; }, null);
1463
1463
  })();
1464
1464
 
1465
- class AuthStorageService extends StorageService {
1466
- constructor(config, http, authService, tokenService) {
1467
- super(config);
1468
- this.http = http;
1469
- this.authService = authService;
1470
- this.tokenService = tokenService;
1471
- this.authService.authenticate$.subscribe(isAuthenticated => {
1472
- if (isAuthenticated && this.options.url) {
1473
- this.http
1474
- .get(this.options.url)
1475
- .subscribe((userIgo) => {
1476
- if (userIgo && userIgo.preference) {
1477
- for (const key of Object.keys(userIgo.preference)) {
1478
- const value = userIgo.preference[key];
1479
- super.set(key, value);
1480
- }
1481
- }
1482
- });
1483
- }
1484
- });
1485
- }
1486
- set(key, value, scope = StorageScope.LOCAL) {
1487
- if (scope === StorageScope.LOCAL &&
1488
- this.authService.authenticated &&
1489
- this.options.url) {
1490
- const preference = {};
1491
- preference[key] = value;
1492
- this.http.patch(this.options.url, { preference }).subscribe();
1493
- }
1494
- super.set(key, value, scope);
1495
- }
1496
- remove(key, scope = StorageScope.LOCAL) {
1497
- if (scope === StorageScope.LOCAL &&
1498
- this.authService.authenticated &&
1499
- this.options.url) {
1500
- const preference = {};
1501
- preference[key] = undefined;
1502
- this.http.patch(this.options.url, { preference }).subscribe();
1503
- }
1504
- super.remove(key, scope);
1505
- }
1506
- clear(scope = StorageScope.LOCAL) {
1507
- if (scope === StorageScope.LOCAL &&
1508
- this.authService.authenticated &&
1509
- this.options.url) {
1510
- this.http.patch(this.options.url, { preference: {} }, {
1511
- params: {
1512
- mergePreference: 'false'
1513
- }
1514
- }).subscribe();
1515
- }
1516
- let token;
1517
- if (scope === StorageScope.LOCAL) {
1518
- token = this.tokenService.get();
1519
- }
1520
- super.clear(scope);
1521
- if (token) {
1522
- this.tokenService.set(token);
1523
- }
1524
- if (scope === StorageScope.LOCAL &&
1525
- this.authService.authenticated &&
1526
- this.options.url) {
1527
- this.http
1528
- .get(this.options.url)
1529
- .subscribe((userIgo) => {
1530
- if (userIgo && userIgo.preference) {
1531
- for (const key of Object.keys(userIgo.preference)) {
1532
- const value = userIgo.preference[key];
1533
- super.set(key, value);
1534
- }
1535
- }
1536
- });
1537
- }
1538
- }
1539
- }
1540
- AuthStorageService.ɵfac = function AuthStorageService_Factory(t) { return new (t || AuthStorageService)(i0.ɵɵinject(i2.ConfigService), i0.ɵɵinject(i1.HttpClient), i0.ɵɵinject(AuthService), i0.ɵɵinject(TokenService)); };
1541
- AuthStorageService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AuthStorageService, factory: AuthStorageService.ɵfac, providedIn: 'root' });
1542
- (function () {
1543
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthStorageService, [{
1544
- type: Injectable,
1545
- args: [{
1546
- providedIn: 'root'
1547
- }]
1548
- }], function () { return [{ type: i2.ConfigService }, { type: i1.HttpClient }, { type: AuthService }, { type: TokenService }]; }, null);
1465
+ class AuthStorageService extends StorageService {
1466
+ constructor(config, http, authService, tokenService) {
1467
+ super(config);
1468
+ this.http = http;
1469
+ this.authService = authService;
1470
+ this.tokenService = tokenService;
1471
+ this.authService.authenticate$.subscribe(isAuthenticated => {
1472
+ if (isAuthenticated && this.options.url) {
1473
+ this.http
1474
+ .get(this.options.url)
1475
+ .subscribe((userIgo) => {
1476
+ if (userIgo && userIgo.preference) {
1477
+ for (const key of Object.keys(userIgo.preference)) {
1478
+ const value = userIgo.preference[key];
1479
+ super.set(key, value);
1480
+ }
1481
+ }
1482
+ });
1483
+ }
1484
+ });
1485
+ }
1486
+ set(key, value, scope = StorageScope.LOCAL) {
1487
+ if (scope === StorageScope.LOCAL &&
1488
+ this.authService.authenticated &&
1489
+ this.options.url) {
1490
+ const preference = {};
1491
+ preference[key] = value;
1492
+ this.http.patch(this.options.url, { preference }).subscribe();
1493
+ }
1494
+ super.set(key, value, scope);
1495
+ }
1496
+ remove(key, scope = StorageScope.LOCAL) {
1497
+ if (scope === StorageScope.LOCAL &&
1498
+ this.authService.authenticated &&
1499
+ this.options.url) {
1500
+ const preference = {};
1501
+ preference[key] = undefined;
1502
+ this.http.patch(this.options.url, { preference }).subscribe();
1503
+ }
1504
+ super.remove(key, scope);
1505
+ }
1506
+ clear(scope = StorageScope.LOCAL) {
1507
+ if (scope === StorageScope.LOCAL &&
1508
+ this.authService.authenticated &&
1509
+ this.options.url) {
1510
+ this.http.patch(this.options.url, { preference: {} }, {
1511
+ params: {
1512
+ mergePreference: 'false'
1513
+ }
1514
+ }).subscribe();
1515
+ }
1516
+ let token;
1517
+ if (scope === StorageScope.LOCAL) {
1518
+ token = this.tokenService.get();
1519
+ }
1520
+ super.clear(scope);
1521
+ if (token) {
1522
+ this.tokenService.set(token);
1523
+ }
1524
+ if (scope === StorageScope.LOCAL &&
1525
+ this.authService.authenticated &&
1526
+ this.options.url) {
1527
+ this.http
1528
+ .get(this.options.url)
1529
+ .subscribe((userIgo) => {
1530
+ if (userIgo && userIgo.preference) {
1531
+ for (const key of Object.keys(userIgo.preference)) {
1532
+ const value = userIgo.preference[key];
1533
+ super.set(key, value);
1534
+ }
1535
+ }
1536
+ });
1537
+ }
1538
+ }
1539
+ }
1540
+ AuthStorageService.ɵfac = function AuthStorageService_Factory(t) { return new (t || AuthStorageService)(i0.ɵɵinject(i2.ConfigService), i0.ɵɵinject(i1.HttpClient), i0.ɵɵinject(AuthService), i0.ɵɵinject(TokenService)); };
1541
+ AuthStorageService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AuthStorageService, factory: AuthStorageService.ɵfac, providedIn: 'root' });
1542
+ (function () {
1543
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthStorageService, [{
1544
+ type: Injectable,
1545
+ args: [{
1546
+ providedIn: 'root'
1547
+ }]
1548
+ }], function () { return [{ type: i2.ConfigService }, { type: i1.HttpClient }, { type: AuthService }, { type: TokenService }]; }, null);
1549
1549
  })();
1550
1550
 
1551
- const routes = [
1552
- { path: 'login', component: AuthFormComponent },
1553
- { path: 'logout', component: AuthFormComponent }
1554
- ];
1555
- class AuthRoutingModule {
1556
- }
1557
- AuthRoutingModule.ɵfac = function AuthRoutingModule_Factory(t) { return new (t || AuthRoutingModule)(); };
1558
- AuthRoutingModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: AuthRoutingModule });
1559
- AuthRoutingModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [RouterModule.forChild(routes), RouterModule] });
1560
- (function () {
1561
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthRoutingModule, [{
1562
- type: NgModule,
1563
- args: [{
1564
- imports: [RouterModule.forChild(routes)],
1565
- exports: [RouterModule],
1566
- providers: []
1567
- }]
1568
- }], null, null);
1569
- })();
1551
+ const routes = [
1552
+ { path: 'login', component: AuthFormComponent },
1553
+ { path: 'logout', component: AuthFormComponent }
1554
+ ];
1555
+ class AuthRoutingModule {
1556
+ }
1557
+ AuthRoutingModule.ɵfac = function AuthRoutingModule_Factory(t) { return new (t || AuthRoutingModule)(); };
1558
+ AuthRoutingModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: AuthRoutingModule });
1559
+ AuthRoutingModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [RouterModule.forChild(routes), RouterModule] });
1560
+ (function () {
1561
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthRoutingModule, [{
1562
+ type: NgModule,
1563
+ args: [{
1564
+ imports: [RouterModule.forChild(routes)],
1565
+ exports: [RouterModule],
1566
+ providers: []
1567
+ }]
1568
+ }], null, null);
1569
+ })();
1570
1570
  (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(AuthRoutingModule, { imports: [i3.RouterModule], exports: [RouterModule] }); })();
1571
1571
 
1572
- class IgoAuthModule {
1573
- static forRoot() {
1574
- return {
1575
- ngModule: IgoAuthModule,
1576
- providers: [
1577
- {
1578
- provide: HTTP_INTERCEPTORS,
1579
- useClass: AuthInterceptor,
1580
- multi: true
1581
- },
1582
- {
1583
- provide: StorageService,
1584
- useClass: AuthStorageService
1585
- },
1586
- ...provideAuthMicrosoft('add'),
1587
- ...provideAuthMicrosoft('b2c')
1588
- ]
1589
- };
1590
- }
1591
- }
1592
- IgoAuthModule.ɵfac = function IgoAuthModule_Factory(t) { return new (t || IgoAuthModule)(); };
1593
- IgoAuthModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: IgoAuthModule });
1594
- IgoAuthModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
1595
- ReactiveFormsModule,
1596
- MatFormFieldModule,
1597
- MatInputModule,
1598
- MatIconModule,
1599
- MatButtonModule,
1600
- IgoLanguageModule,
1601
- MsalModule] });
1602
- (function () {
1603
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IgoAuthModule, [{
1604
- type: NgModule,
1605
- args: [{
1606
- imports: [
1607
- CommonModule,
1608
- ReactiveFormsModule,
1609
- MatFormFieldModule,
1610
- MatInputModule,
1611
- MatIconModule,
1612
- MatButtonModule,
1613
- IgoLanguageModule,
1614
- MsalModule
1615
- ],
1616
- declarations: [
1617
- AuthFormComponent,
1618
- AuthGoogleComponent,
1619
- AuthInternComponent,
1620
- AuthFacebookComponent,
1621
- AuthMicrosoftComponent,
1622
- AuthMicrosoftb2cComponent,
1623
- ProtectedDirective
1624
- ],
1625
- exports: [AuthFormComponent, ProtectedDirective]
1626
- }]
1627
- }], null, null);
1628
- })();
1629
- (function () {
1630
- (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(IgoAuthModule, { declarations: [AuthFormComponent,
1631
- AuthGoogleComponent,
1632
- AuthInternComponent,
1633
- AuthFacebookComponent,
1634
- AuthMicrosoftComponent,
1635
- AuthMicrosoftb2cComponent,
1636
- ProtectedDirective], imports: [CommonModule,
1637
- ReactiveFormsModule,
1638
- MatFormFieldModule,
1639
- MatInputModule,
1640
- MatIconModule,
1641
- MatButtonModule,
1642
- IgoLanguageModule,
1643
- MsalModule], exports: [AuthFormComponent, ProtectedDirective] });
1572
+ class IgoAuthModule {
1573
+ static forRoot() {
1574
+ return {
1575
+ ngModule: IgoAuthModule,
1576
+ providers: [
1577
+ {
1578
+ provide: HTTP_INTERCEPTORS,
1579
+ useClass: AuthInterceptor,
1580
+ multi: true
1581
+ },
1582
+ {
1583
+ provide: StorageService,
1584
+ useClass: AuthStorageService
1585
+ },
1586
+ ...provideAuthMicrosoft('add'),
1587
+ ...provideAuthMicrosoft('b2c')
1588
+ ]
1589
+ };
1590
+ }
1591
+ }
1592
+ IgoAuthModule.ɵfac = function IgoAuthModule_Factory(t) { return new (t || IgoAuthModule)(); };
1593
+ IgoAuthModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: IgoAuthModule });
1594
+ IgoAuthModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
1595
+ ReactiveFormsModule,
1596
+ MatFormFieldModule,
1597
+ MatInputModule,
1598
+ MatIconModule,
1599
+ MatButtonModule,
1600
+ IgoLanguageModule,
1601
+ MsalModule] });
1602
+ (function () {
1603
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IgoAuthModule, [{
1604
+ type: NgModule,
1605
+ args: [{
1606
+ imports: [
1607
+ CommonModule,
1608
+ ReactiveFormsModule,
1609
+ MatFormFieldModule,
1610
+ MatInputModule,
1611
+ MatIconModule,
1612
+ MatButtonModule,
1613
+ IgoLanguageModule,
1614
+ MsalModule
1615
+ ],
1616
+ declarations: [
1617
+ AuthFormComponent,
1618
+ AuthGoogleComponent,
1619
+ AuthInternComponent,
1620
+ AuthFacebookComponent,
1621
+ AuthMicrosoftComponent,
1622
+ AuthMicrosoftb2cComponent,
1623
+ ProtectedDirective
1624
+ ],
1625
+ exports: [AuthFormComponent, ProtectedDirective]
1626
+ }]
1627
+ }], null, null);
1628
+ })();
1629
+ (function () {
1630
+ (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(IgoAuthModule, { declarations: [AuthFormComponent,
1631
+ AuthGoogleComponent,
1632
+ AuthInternComponent,
1633
+ AuthFacebookComponent,
1634
+ AuthMicrosoftComponent,
1635
+ AuthMicrosoftb2cComponent,
1636
+ ProtectedDirective], imports: [CommonModule,
1637
+ ReactiveFormsModule,
1638
+ MatFormFieldModule,
1639
+ MatInputModule,
1640
+ MatIconModule,
1641
+ MatButtonModule,
1642
+ IgoLanguageModule,
1643
+ MsalModule], exports: [AuthFormComponent, ProtectedDirective] });
1644
1644
  })();
1645
1645
 
1646
- /*
1647
- * Public API Surface of auth
1646
+ /*
1647
+ * Public API Surface of auth
1648
1648
  */
1649
1649
 
1650
- /**
1651
- * Generated bundle index. Do not edit.
1650
+ /**
1651
+ * Generated bundle index. Do not edit.
1652
1652
  */
1653
1653
 
1654
1654
  export { AdminGuard, AuthFormComponent, AuthGuard, AuthInterceptor, AuthRoutingModule, AuthService, AuthStorageService, IgoAuthModule, LoggedGuard, MSALAngularConfigFactory, MSALAngularConfigFactoryb2c, MSALConfigFactory, MSALConfigFactoryb2c, ProfilsGuard, ProtectedDirective, TokenService, provideAuthMicrosoft };