@igo2/auth 21.0.0-next.2 → 21.0.0-next.21

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.
@@ -5,7 +5,8 @@ import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
5
5
  import { StorageOptions, BaseStorage, StorageScope } from '@igo2/core/storage';
6
6
  import * as rxjs from 'rxjs';
7
7
  import { Observable, BehaviorSubject } from 'rxjs';
8
- import { HttpInterceptor, HttpRequest, HttpHandler, HttpEvent } from '@angular/common/http';
8
+ import { HttpInterceptor, HttpRequest, HttpHandler, HttpEvent, HttpHeaders } from '@angular/common/http';
9
+ import { IXhrInterceptor } from '@igo2/core/auth';
9
10
  import { JwtPayload } from 'jwt-decode';
10
11
 
11
12
  declare class AdminGuard {
@@ -46,7 +47,7 @@ declare class AuthGuard {
46
47
  static ɵprov: i0.ɵɵInjectableDeclaration<AuthGuard>;
47
48
  }
48
49
 
49
- declare class AuthInterceptor implements HttpInterceptor {
50
+ declare class AuthInterceptor implements HttpInterceptor, IXhrInterceptor {
50
51
  private config;
51
52
  private tokenService;
52
53
  private http;
@@ -57,24 +58,15 @@ declare class AuthInterceptor implements HttpInterceptor {
57
58
  private hostsWithAuthByKey;
58
59
  constructor();
59
60
  intercept(originalReq: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>>;
60
- interceptXhr(xhr: any, url: string): boolean;
61
- alterUrlWithKeyAuth(url: string): string;
61
+ interceptXhr(xhr: XMLHttpRequest, url: string): boolean;
62
+ alterUrlWithKeyAuth(url: string): string | undefined;
62
63
  private handleHostsWithCredentials;
63
64
  private handleHostsAuthByKey;
64
- refreshToken(): rxjs.Subscription;
65
+ refreshToken(): rxjs.Subscription | undefined;
65
66
  static ɵfac: i0.ɵɵFactoryDeclaration<AuthInterceptor, never>;
66
67
  static ɵprov: i0.ɵɵInjectableDeclaration<AuthInterceptor>;
67
68
  }
68
69
 
69
- interface AuthFacebookOptions {
70
- enabled?: boolean;
71
- appId: string;
72
- }
73
- interface AuthGoogleOptions {
74
- enabled?: boolean;
75
- apiKey: string;
76
- clientId: string;
77
- }
78
70
  interface User extends BaseUser {
79
71
  source?: string;
80
72
  sourceId?: string;
@@ -108,17 +100,8 @@ interface IAuthUserIgoOptions {
108
100
  }
109
101
  interface AuthByKeyOptions {
110
102
  domainRegFilters?: string;
111
- keyProperty?: string;
112
- keyValue?: string;
113
- }
114
- interface AuthByKeyOptions {
115
- domainRegFilters?: string;
116
- keyProperty?: string;
117
- keyValue?: string;
118
- }
119
- interface WithCredentialsOptions {
120
- withCredentials?: boolean;
121
- domainRegFilters?: string;
103
+ keyProperty: string;
104
+ keyValue: string;
122
105
  }
123
106
  interface WithCredentialsOptions {
124
107
  withCredentials?: boolean;
@@ -167,7 +150,7 @@ declare class AuthService<T extends AuthOptions = AuthOptions> {
167
150
  private router;
168
151
  authenticate$: BehaviorSubject<boolean>;
169
152
  logged$: BehaviorSubject<boolean>;
170
- redirectUrl: string;
153
+ redirectUrl?: string;
171
154
  languageForce: boolean;
172
155
  authOptions: T;
173
156
  private anonymous;
@@ -175,15 +158,15 @@ declare class AuthService<T extends AuthOptions = AuthOptions> {
175
158
  get hasAuthService(): boolean;
176
159
  get user(): User | null;
177
160
  constructor();
178
- login(username: string, password: string): Observable<IUser>;
179
- loginWithToken(token: string, type: string, infosUser?: IInfosUser, applicationId?: string): Observable<IUser>;
161
+ login(username: string, password: string): Observable<IUser | null>;
162
+ loginWithToken(token: string, type: string, infosUser?: IInfosUser, applicationId?: string): Observable<IUser | null>;
180
163
  loginAnonymous(): Observable<boolean>;
181
164
  refresh(): Observable<IToken>;
182
165
  logout(): void;
183
166
  private logoutInternal;
184
167
  isAuthenticated(): boolean;
185
- getToken(): string;
186
- decodeToken(): IgoJwtPayload | null;
168
+ getToken(): string | undefined;
169
+ decodeToken(): IgoJwtPayload | undefined;
187
170
  goToRedirectUrl(): void;
188
171
  getUserInfo(): Observable<User>;
189
172
  getProfils(): Observable<{
@@ -196,7 +179,7 @@ declare class AuthService<T extends AuthOptions = AuthOptions> {
196
179
  get isAnonymous(): boolean;
197
180
  get authenticated(): boolean;
198
181
  get isAdmin(): boolean;
199
- protected loginCall(body: any, headers: any): Observable<IUser>;
182
+ protected loginCall(body: unknown, headers: HttpHeaders): Observable<IUser | null>;
200
183
  private initializeAuthentication;
201
184
  static ɵfac: i0.ɵɵFactoryDeclaration<AuthService<any>, never>;
202
185
  static ɵprov: i0.ɵɵInjectableDeclaration<AuthService<any>>;
@@ -227,8 +210,8 @@ declare class TokenService {
227
210
  constructor();
228
211
  set(token: string): void;
229
212
  remove(): void;
230
- get(): string;
231
- decode(): IgoJwtPayload | null;
213
+ get(): string | undefined;
214
+ decode(): IgoJwtPayload | undefined;
232
215
  isExpired(): boolean;
233
216
  static ɵfac: i0.ɵɵFactoryDeclaration<TokenService, never>;
234
217
  static ɵprov: i0.ɵɵInjectableDeclaration<TokenService>;
@@ -240,7 +223,7 @@ declare class UserService {
240
223
  private options;
241
224
  private baseUrl;
242
225
  private _user$;
243
- user$: Observable<IUser>;
226
+ user$: Observable<IUser | undefined>;
244
227
  constructor();
245
228
  getUser(): Observable<IUser>;
246
229
  sync(): Observable<IUser>;
@@ -256,4 +239,4 @@ declare function withUserIgo(): AuthFeature<AuthFeatureKind.User>;
256
239
  declare function provideAuthentification(...features: AuthFeature<AuthFeatureKind>[]): EnvironmentProviders;
257
240
 
258
241
  export { AdminGuard, AuthFeatureKind, AuthGuard, AuthInterceptor, AuthService, AuthStorageService, LoggedGuard, ProfilsGuard, TokenService, USER_AUTH_OPTIONS, UserService, provideAuthentification, withUserIgo };
259
- export type { AuthByKeyOptions, AuthFacebookOptions, AuthFeature, AuthGoogleOptions, AuthInternOptions, AuthOptions, AuthStorageOptions, IAuthUserIgoOptions, IInfosUser, IUser, IUserPreference, IgoJwtPayload, User, WithCredentialsOptions };
242
+ export type { AuthByKeyOptions, AuthFeature, AuthInternOptions, AuthOptions, AuthStorageOptions, IAuthUserIgoOptions, IInfosUser, IUser, IUserPreference, IgoJwtPayload, User, WithCredentialsOptions };
@@ -1,65 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { inject, ApplicationRef, output, ChangeDetectionStrategy, Component } from '@angular/core';
3
- import { AuthService } from '@igo2/auth';
4
- import { ConfigService } from '@igo2/core/config';
5
-
6
- class AuthFacebookComponent {
7
- authService = inject(AuthService);
8
- config = inject(ConfigService);
9
- appRef = inject(ApplicationRef);
10
- options;
11
- login = output();
12
- constructor() {
13
- this.options = this.config.getConfig('auth.facebook');
14
- if (this.options?.appId) {
15
- this.loadSDKFacebook();
16
- }
17
- else {
18
- console.warn('Facebook authentification needs "appId" option');
19
- }
20
- }
21
- subscribeEvents() {
22
- window.FB.Event.subscribe('auth.statusChange', (rep) => {
23
- this.statusChangeCallback(rep);
24
- });
25
- }
26
- statusChangeCallback(response) {
27
- if (response.status === 'connected') {
28
- const accessToken = response.authResponse.accessToken;
29
- this.loginFacebook(accessToken);
30
- }
31
- }
32
- loginFacebook(token) {
33
- this.authService.loginWithToken(token, 'facebook').subscribe(() => {
34
- this.appRef.tick();
35
- this.login.emit(true);
36
- });
37
- }
38
- loadSDKFacebook() {
39
- if (document.getElementById('facebook-jssdk')) {
40
- return;
41
- }
42
- const urlSDK = 'https://connect.facebook.net/fr_CA/sdk.js#xfbml=1&version=v2.9';
43
- const fjs = document.getElementsByTagName('script')[0];
44
- const js = document.createElement('script');
45
- js.id = 'facebook-jssdk';
46
- js.src = `${urlSDK}&appId=${this.options?.appId}`;
47
- js.onload = () => {
48
- this.subscribeEvents();
49
- };
50
- fjs.parentNode.insertBefore(js, fjs);
51
- }
52
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.10", ngImport: i0, type: AuthFacebookComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
53
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.10", type: AuthFacebookComponent, isStandalone: true, selector: "igo-auth-facebook", outputs: { login: "login" }, ngImport: i0, template: "<div\n class=\"fb-login-button\"\n data-max-rows=\"1\"\n data-size=\"large\"\n data-button-type=\"login_with\"\n data-show-faces=\"false\"\n data-auto-logout-link=\"false\"\n data-use-continue-as=\"false\"\n></div>\n", styles: [":host{padding:10px 10px 10px 0;display:inline-block;position:relative;top:-3px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
54
- }
55
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.10", ngImport: i0, type: AuthFacebookComponent, decorators: [{
56
- type: Component,
57
- args: [{ selector: 'igo-auth-facebook', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div\n class=\"fb-login-button\"\n data-max-rows=\"1\"\n data-size=\"large\"\n data-button-type=\"login_with\"\n data-show-faces=\"false\"\n data-auto-logout-link=\"false\"\n data-use-continue-as=\"false\"\n></div>\n", styles: [":host{padding:10px 10px 10px 0;display:inline-block;position:relative;top:-3px}\n"] }]
58
- }], ctorParameters: () => [], propDecorators: { login: [{ type: i0.Output, args: ["login"] }] } });
59
-
60
- /**
61
- * Generated bundle index. Do not edit.
62
- */
63
-
64
- export { AuthFacebookComponent };
65
- //# sourceMappingURL=igo2-auth-facebook.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"igo2-auth-facebook.mjs","sources":["../../../packages/auth/facebook/src/auth-facebook/auth-facebook.component.ts","../../../packages/auth/facebook/src/auth-facebook/auth-facebook.component.html","../../../packages/auth/facebook/src/igo2-auth-facebook.ts"],"sourcesContent":["import {\n ApplicationRef,\n ChangeDetectionStrategy,\n Component,\n inject,\n output\n} from '@angular/core';\n\nimport { AuthService } from '@igo2/auth';\nimport { ConfigService } from '@igo2/core/config';\n\nimport { AuthFacebookOptions } from '../shared/auth-facebook.interface';\n\n@Component({\n selector: 'igo-auth-facebook',\n templateUrl: './auth-facebook.component.html',\n styleUrls: ['./auth-facebook.component.scss'],\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class AuthFacebookComponent {\n private authService = inject(AuthService);\n private config = inject(ConfigService);\n private appRef = inject(ApplicationRef);\n\n private options?: AuthFacebookOptions;\n\n readonly login = output<boolean>();\n\n constructor() {\n this.options = this.config.getConfig('auth.facebook');\n\n if (this.options?.appId) {\n this.loadSDKFacebook();\n } else {\n console.warn('Facebook authentification needs \"appId\" option');\n }\n }\n\n private subscribeEvents() {\n (window as any).FB.Event.subscribe('auth.statusChange', (rep) => {\n this.statusChangeCallback(rep);\n });\n }\n\n private statusChangeCallback(response) {\n if (response.status === 'connected') {\n const accessToken = response.authResponse.accessToken;\n this.loginFacebook(accessToken);\n }\n }\n\n private loginFacebook(token) {\n this.authService.loginWithToken(token, 'facebook').subscribe(() => {\n this.appRef.tick();\n this.login.emit(true);\n });\n }\n\n private loadSDKFacebook() {\n if (document.getElementById('facebook-jssdk')) {\n return;\n }\n\n const urlSDK =\n 'https://connect.facebook.net/fr_CA/sdk.js#xfbml=1&version=v2.9';\n\n const fjs = document.getElementsByTagName('script')[0];\n const js = document.createElement('script');\n js.id = 'facebook-jssdk';\n js.src = `${urlSDK}&appId=${this.options?.appId}`;\n js.onload = () => {\n this.subscribeEvents();\n };\n fjs.parentNode.insertBefore(js, fjs);\n }\n}\n","<div\n class=\"fb-login-button\"\n data-max-rows=\"1\"\n data-size=\"large\"\n data-button-type=\"login_with\"\n data-show-faces=\"false\"\n data-auto-logout-link=\"false\"\n data-use-continue-as=\"false\"\n></div>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;MAmBa,qBAAqB,CAAA;AACxB,IAAA,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;AACjC,IAAA,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC;AAC9B,IAAA,MAAM,GAAG,MAAM,CAAC,cAAc,CAAC;AAE/B,IAAA,OAAO;IAEN,KAAK,GAAG,MAAM,EAAW;AAElC,IAAA,WAAA,GAAA;QACE,IAAI,CAA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AAE,CAAC,GAAG,GAAG,CAAA,EAAG,MAAM,CAAA,OAAA,EAAU,IAAI,CAAC,OAAO,EAAE,KAAK,CAAA,CAAE;AACjD,QAAA,EAAE,CAAC,MAAM,GAAG,MAAK;YACf,IAAI,CAAC,eAAe,EAAE;AACxB,QAAA,CAAC;QACD,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,EAAE,GAAG,CAAC;IACtC;wGAvDW,qBAAqB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAArB,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,IAAA,EAAA,qBAAqB,0GCnBlC,iOASA,EAAA,MAAA,EAAA,CAAA,mFAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;4FDUa,qBAAqB,EAAA,UAAA,EAAA,CAAA;kBANjC,SAAS;+BACE,mBAAmB,EAAA,eAAA,EAGZ,uBAAuB,CAAC,MAAM,EAAA,QAAA,EAAA,iOAAA,EAAA,MAAA,EAAA,CAAA,mFAAA,CAAA,EAAA;;;AEjBjD;;AAEG;;;;"}
@@ -1,106 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { inject, ApplicationRef, output, ChangeDetectionStrategy, Component } from '@angular/core';
3
- import { AuthService } from '@igo2/auth';
4
- import { ConfigService } from '@igo2/core/config';
5
- import { LanguageService } from '@igo2/core/language';
6
-
7
- class AuthGoogleComponent {
8
- authService = inject(AuthService);
9
- config = inject(ConfigService);
10
- languageService = inject(LanguageService);
11
- appRef = inject(ApplicationRef);
12
- options;
13
- login = output();
14
- constructor() {
15
- this.options = this.config.getConfig('auth.google');
16
- if (this.options?.apiKey && this.options?.clientId) {
17
- this.loadSDKGoogle();
18
- this.loadPlatform();
19
- }
20
- else {
21
- console.warn('Google authentification needs "apiKey" and "clientId" options');
22
- }
23
- }
24
- handleSignInClick() {
25
- window.gapi.auth2.getAuthInstance().signIn();
26
- }
27
- handleSignOutClick() {
28
- window.gapi.auth2.getAuthInstance().signOut();
29
- }
30
- handleClientLoad() {
31
- window.gapi.load('client:auth2', () => this.initClient());
32
- }
33
- initClient() {
34
- window.gapi.client
35
- .init({
36
- apiKey: this.options?.apiKey,
37
- clientId: this.options?.clientId,
38
- discoveryDocs: [
39
- 'https://people.googleapis.com/$discovery/rest?version=v1'
40
- ],
41
- scope: 'profile'
42
- })
43
- .then(() => {
44
- this.handleSignOutClick();
45
- this.updateTextButton();
46
- window.gapi.auth2
47
- .getAuthInstance()
48
- .isSignedIn.listen((rep) => {
49
- this.updateSigninStatus(rep);
50
- });
51
- });
52
- }
53
- updateSigninStatus(isSignedIn) {
54
- this.updateTextButton();
55
- if (isSignedIn) {
56
- this.loginGoogle(window.gapi.client.getToken().access_token);
57
- }
58
- }
59
- updateTextButton() {
60
- const btn = document.querySelector('span[id^="not_signed_"]');
61
- if (btn && this.languageService.getLanguage() !== 'en') {
62
- if (btn.innerHTML === 'Sign in with Google') {
63
- btn.innerHTML = this.languageService.translate.instant('igo.auth.google.login');
64
- }
65
- else if (btn.innerHTML === 'Signed in with Google') {
66
- btn.innerHTML = this.languageService.translate.instant('igo.auth.google.logged');
67
- }
68
- }
69
- }
70
- loginGoogle(token) {
71
- this.authService.loginWithToken(token, 'google').subscribe(() => {
72
- this.appRef.tick();
73
- this.login.emit(true);
74
- });
75
- }
76
- loadSDKGoogle() {
77
- const fjs = document.getElementsByTagName('script')[0];
78
- const js = document.createElement('script');
79
- js.id = 'google-jssdk';
80
- js.src = 'https://apis.google.com/js/api.js';
81
- js.onload = () => {
82
- this.handleClientLoad();
83
- };
84
- fjs.parentNode.insertBefore(js, fjs);
85
- }
86
- loadPlatform() {
87
- const fjs = document.getElementsByTagName('script')[0];
88
- const js = document.createElement('script');
89
- js.id = 'google-platform';
90
- js.src = 'https://apis.google.com/js/platform.js';
91
- fjs.parentNode.insertBefore(js, fjs);
92
- }
93
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.10", ngImport: i0, type: AuthGoogleComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
94
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.10", type: AuthGoogleComponent, isStandalone: true, selector: "igo-auth-google", outputs: { login: "login" }, ngImport: i0, template: "<div\n class=\"g-signin2 google-login-button\"\n data-height=\"40\"\n data-width=\"265\"\n data-longtitle=\"true\"\n></div>\n", styles: [":host{padding:10px 10px 10px 0;display:inline-block}.google-login-button ::ng-deep .abcRioButton{color:#000000de}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
95
- }
96
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.10", ngImport: i0, type: AuthGoogleComponent, decorators: [{
97
- type: Component,
98
- args: [{ selector: 'igo-auth-google', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div\n class=\"g-signin2 google-login-button\"\n data-height=\"40\"\n data-width=\"265\"\n data-longtitle=\"true\"\n></div>\n", styles: [":host{padding:10px 10px 10px 0;display:inline-block}.google-login-button ::ng-deep .abcRioButton{color:#000000de}\n"] }]
99
- }], ctorParameters: () => [], propDecorators: { login: [{ type: i0.Output, args: ["login"] }] } });
100
-
101
- /**
102
- * Generated bundle index. Do not edit.
103
- */
104
-
105
- export { AuthGoogleComponent };
106
- //# sourceMappingURL=igo2-auth-google.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"igo2-auth-google.mjs","sources":["../../../packages/auth/google/src/auth-google/auth-google.component.ts","../../../packages/auth/google/src/auth-google/auth-google.component.html","../../../packages/auth/google/src/igo2-auth-google.ts"],"sourcesContent":["import {\n ApplicationRef,\n ChangeDetectionStrategy,\n Component,\n inject,\n output\n} from '@angular/core';\n\nimport { AuthService } from '@igo2/auth';\nimport { ConfigService } from '@igo2/core/config';\nimport { LanguageService } from '@igo2/core/language';\n\nimport { AuthGoogleOptions } from '../shared/auth-google.interface';\n\n@Component({\n selector: 'igo-auth-google',\n templateUrl: './auth-google.component.html',\n styleUrls: ['./auth-google.component.scss'],\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class AuthGoogleComponent {\n private authService = inject(AuthService);\n private config = inject(ConfigService);\n private languageService = inject(LanguageService);\n private appRef = inject(ApplicationRef);\n\n private options?: AuthGoogleOptions;\n\n readonly login = output<boolean>();\n\n constructor() {\n this.options = this.config.getConfig('auth.google');\n\n if (this.options?.apiKey && this.options?.clientId) {\n this.loadSDKGoogle();\n this.loadPlatform();\n } else {\n console.warn(\n 'Google authentification needs \"apiKey\" and \"clientId\" options'\n );\n }\n }\n\n public handleSignInClick() {\n (window as any).gapi.auth2.getAuthInstance().signIn();\n }\n\n public handleSignOutClick() {\n (window as any).gapi.auth2.getAuthInstance().signOut();\n }\n\n private handleClientLoad() {\n (window as any).gapi.load('client:auth2', () => this.initClient());\n }\n\n private initClient() {\n (window as any).gapi.client\n .init({\n apiKey: this.options?.apiKey,\n clientId: this.options?.clientId,\n discoveryDocs: [\n 'https://people.googleapis.com/$discovery/rest?version=v1'\n ],\n scope: 'profile'\n })\n .then(() => {\n this.handleSignOutClick();\n this.updateTextButton();\n (window as any).gapi.auth2\n .getAuthInstance()\n .isSignedIn.listen((rep) => {\n this.updateSigninStatus(rep);\n });\n });\n }\n\n private updateSigninStatus(isSignedIn) {\n this.updateTextButton();\n if (isSignedIn) {\n this.loginGoogle((window as any).gapi.client.getToken().access_token);\n }\n }\n\n private updateTextButton() {\n const btn = document.querySelector('span[id^=\"not_signed_\"]');\n if (btn && this.languageService.getLanguage() !== 'en') {\n if (btn.innerHTML === 'Sign in with Google') {\n btn.innerHTML = this.languageService.translate.instant(\n 'igo.auth.google.login'\n );\n } else if (btn.innerHTML === 'Signed in with Google') {\n btn.innerHTML = this.languageService.translate.instant(\n 'igo.auth.google.logged'\n );\n }\n }\n }\n\n private loginGoogle(token) {\n this.authService.loginWithToken(token, 'google').subscribe(() => {\n this.appRef.tick();\n this.login.emit(true);\n });\n }\n\n private loadSDKGoogle() {\n const fjs = document.getElementsByTagName('script')[0];\n const js = document.createElement('script');\n js.id = 'google-jssdk';\n js.src = 'https://apis.google.com/js/api.js';\n js.onload = () => {\n this.handleClientLoad();\n };\n fjs.parentNode.insertBefore(js, fjs);\n }\n\n private loadPlatform() {\n const fjs = document.getElementsByTagName('script')[0];\n const js = document.createElement('script');\n js.id = 'google-platform';\n js.src = 'https://apis.google.com/js/platform.js';\n fjs.parentNode.insertBefore(js, fjs);\n }\n}\n","<div\n class=\"g-signin2 google-login-button\"\n data-height=\"40\"\n data-width=\"265\"\n data-longtitle=\"true\"\n></div>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;MAoBa,mBAAmB,CAAA;AACtB,IAAA,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;AACjC,IAAA,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC;AAC9B,IAAA,eAAe,GAAG,MAAM,CAAC,eAAe,CAAC;AACzC,IAAA,MAAM,GAAG,MAAM,CAAC,cAAc,CAAC;AAE/B,IAAA,OAAO;IAEN,KAAK,GAAG,MAAM,EAAW;AAElC,IAAA,WAAA,GAAA;QACE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC;AAEnD,QAAA,IAAI,IAAI,CAAC,OAAO,EAAE,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE;YAClD,IAAI,CAAC,aAAa,EAAE;YACpB,IAAI,CAAC,YAAY,EAAE;QACrB;aAAO;AACL,YAAA,OAAO,CAAC,IAAI,CACV,+DAA+D,CAChE;QACH;IACF;IAEO,iBAAiB,GAAA;QACrB,MAAc,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC,MAAM,EAAE;IACvD;IAE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AAE,EAAE,GAAG,CAAC;IACtC;wGAtGW,mBAAmB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAnB,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,IAAA,EAAA,mBAAmB,wGCpBhC,mIAMA,EAAA,MAAA,EAAA,CAAA,qHAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;4FDca,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBAN/B,SAAS;+BACE,iBAAiB,EAAA,eAAA,EAGV,uBAAuB,CAAC,MAAM,EAAA,QAAA,EAAA,mIAAA,EAAA,MAAA,EAAA,CAAA,qHAAA,CAAA,EAAA;;;AElBjD;;AAEG;;;;"}
@@ -1,24 +0,0 @@
1
- import * as i0 from '@angular/core';
2
-
3
- declare class AuthFacebookComponent {
4
- private authService;
5
- private config;
6
- private appRef;
7
- private options?;
8
- readonly login: i0.OutputEmitterRef<boolean>;
9
- constructor();
10
- private subscribeEvents;
11
- private statusChangeCallback;
12
- private loginFacebook;
13
- private loadSDKFacebook;
14
- static ɵfac: i0.ɵɵFactoryDeclaration<AuthFacebookComponent, never>;
15
- static ɵcmp: i0.ɵɵComponentDeclaration<AuthFacebookComponent, "igo-auth-facebook", never, {}, { "login": "login"; }, never, never, true, never>;
16
- }
17
-
18
- interface AuthFacebookOptions {
19
- enabled?: boolean;
20
- appId: string;
21
- }
22
-
23
- export { AuthFacebookComponent };
24
- export type { AuthFacebookOptions };
@@ -1,31 +0,0 @@
1
- import * as i0 from '@angular/core';
2
-
3
- declare class AuthGoogleComponent {
4
- private authService;
5
- private config;
6
- private languageService;
7
- private appRef;
8
- private options?;
9
- readonly login: i0.OutputEmitterRef<boolean>;
10
- constructor();
11
- handleSignInClick(): void;
12
- handleSignOutClick(): void;
13
- private handleClientLoad;
14
- private initClient;
15
- private updateSigninStatus;
16
- private updateTextButton;
17
- private loginGoogle;
18
- private loadSDKGoogle;
19
- private loadPlatform;
20
- static ɵfac: i0.ɵɵFactoryDeclaration<AuthGoogleComponent, never>;
21
- static ɵcmp: i0.ɵɵComponentDeclaration<AuthGoogleComponent, "igo-auth-google", never, {}, { "login": "login"; }, never, never, true, never>;
22
- }
23
-
24
- interface AuthGoogleOptions {
25
- enabled?: boolean;
26
- apiKey: string;
27
- clientId: string;
28
- }
29
-
30
- export { AuthGoogleComponent };
31
- export type { AuthGoogleOptions };