@igo2/auth 20.2.0 → 21.0.0-next.10

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.
@@ -1,8 +1,4 @@
1
- import * as i13 from '@igo2/auth/facebook';
2
- import { AuthFacebookOptions } from '@igo2/auth/facebook';
3
- import * as i11 from '@igo2/auth/google';
4
- import { AuthGoogleOptions } from '@igo2/auth/google';
5
- import * as i14 from '@igo2/auth/microsoft';
1
+ import * as i12 from '@igo2/auth/microsoft';
6
2
  import { AuthMicrosoftOptions, AuthMicrosoftb2cOptions } from '@igo2/auth/microsoft';
7
3
  import * as i0 from '@angular/core';
8
4
  import { OnInit } from '@angular/core';
@@ -16,11 +12,9 @@ import * as i7 from '@angular/material/button';
16
12
  import * as i8 from '@igo2/core/language';
17
13
  import * as i9 from '@azure/msal-angular';
18
14
  import { AuthService, AuthOptions } from '@igo2/auth';
19
- import * as i12 from '@igo2/auth/internal';
15
+ import * as i11 from '@igo2/auth/internal';
20
16
 
21
17
  interface AuthFormOptions {
22
- facebook?: AuthFacebookOptions;
23
- google?: AuthGoogleOptions;
24
18
  microsoft?: AuthMicrosoftOptions;
25
19
  microsoftb2c?: AuthMicrosoftb2cOptions;
26
20
  }
@@ -49,7 +43,7 @@ declare class AuthFormComponent implements OnInit {
49
43
  options?: AuthOptions & AuthFormOptions;
50
44
  user: any;
51
45
  visible: boolean;
52
- private isLogoutRoute;
46
+ private isLogoutRoute?;
53
47
  constructor();
54
48
  ngOnInit(): void;
55
49
  onLogin(): void;
@@ -63,7 +57,7 @@ declare class AuthFormComponent implements OnInit {
63
57
 
64
58
  declare class IgoAuthFormModule {
65
59
  static ɵfac: i0.ɵɵFactoryDeclaration<IgoAuthFormModule, never>;
66
- static ɵmod: i0.ɵɵNgModuleDeclaration<IgoAuthFormModule, never, [typeof i1.CommonModule, typeof i2.ReactiveFormsModule, typeof i3.MatFormFieldModule, typeof i4.MatInputModule, typeof i5.MatIconModule, typeof i6.MatProgressSpinnerModule, typeof i7.MatButtonModule, typeof i8.IgoLanguageModule, typeof i9.MsalModule, typeof AuthFormComponent, typeof i11.AuthGoogleComponent, typeof i12.AuthInternComponent, typeof i13.AuthFacebookComponent, typeof i14.AuthMicrosoftComponent, typeof i14.AuthMicrosoftb2cComponent], [typeof AuthFormComponent]>;
60
+ static ɵmod: i0.ɵɵNgModuleDeclaration<IgoAuthFormModule, never, [typeof i1.CommonModule, typeof i2.ReactiveFormsModule, typeof i3.MatFormFieldModule, typeof i4.MatInputModule, typeof i5.MatIconModule, typeof i6.MatProgressSpinnerModule, typeof i7.MatButtonModule, typeof i8.IgoLanguageModule, typeof i9.MsalModule, typeof AuthFormComponent, typeof i11.AuthInternComponent, typeof i12.AuthMicrosoftComponent, typeof i12.AuthMicrosoftb2cComponent], [typeof AuthFormComponent]>;
67
61
  static ɵinj: i0.ɵɵInjectorDeclaration<IgoAuthFormModule>;
68
62
  }
69
63
 
@@ -43,7 +43,7 @@ interface AuthMicrosoftOptions extends BrowserAuthOptions {
43
43
  }
44
44
  interface AuthMicrosoftb2cOptions {
45
45
  enabled?: boolean;
46
- browserAuthOptions?: BrowserAuthOptions;
46
+ browserAuthOptions: BrowserAuthOptions;
47
47
  options?: AuthMicrosoftb2cOptionsOptions;
48
48
  scopes?: string[];
49
49
  }
@@ -73,8 +73,8 @@ interface MsalGuardConfigurationWithType extends MsalGuardConfiguration {
73
73
  }
74
74
 
75
75
  declare const AUTH_MICROSOFT_DIRECTIVES: readonly [typeof AuthMicrosoftComponent, typeof AuthMicrosoftb2cComponent];
76
- declare function MSALConfigFactory(config: ConfigService): IPublicClientApplication;
77
- declare function MSALConfigFactoryb2c(config: ConfigService): PublicClientApplication;
76
+ declare function MSALConfigFactory(config: ConfigService): IPublicClientApplication | undefined;
77
+ declare function MSALConfigFactoryb2c(config: ConfigService): PublicClientApplication | undefined;
78
78
  declare function MSALAngularConfigFactory(config: ConfigService): MsalGuardConfigurationWithType;
79
79
  declare function MSALAngularConfigFactoryb2c(config: ConfigService): MsalGuardConfigurationWithType;
80
80
  declare function withMicrosoftSupport(type?: string, serviceFactory?: IMsalServiceFactory): AuthFeature<AuthFeatureKind.Microsoft>;
@@ -89,7 +89,7 @@ declare class AuthMsalService extends AuthService<IAuthMsalOptions> {
89
89
  private _isInitialized$;
90
90
  autoLogin: boolean;
91
91
  constructor();
92
- login(): Observable<IUser>;
92
+ login(): Observable<IUser | null>;
93
93
  logout(): void;
94
94
  private getConf;
95
95
  static ɵfac: i0.ɵɵFactoryDeclaration<AuthMsalService, never>;
@@ -5,7 +5,7 @@ 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
9
  import { JwtPayload } from 'jwt-decode';
10
10
 
11
11
  declare class AdminGuard {
@@ -57,24 +57,15 @@ declare class AuthInterceptor implements HttpInterceptor {
57
57
  private hostsWithAuthByKey;
58
58
  constructor();
59
59
  intercept(originalReq: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>>;
60
- interceptXhr(xhr: any, url: string): boolean;
61
- alterUrlWithKeyAuth(url: string): string;
60
+ interceptXhr(xhr: XMLHttpRequest, url: string): boolean;
61
+ alterUrlWithKeyAuth(url: string): string | undefined;
62
62
  private handleHostsWithCredentials;
63
63
  private handleHostsAuthByKey;
64
- refreshToken(): rxjs.Subscription;
64
+ refreshToken(): rxjs.Subscription | undefined;
65
65
  static ɵfac: i0.ɵɵFactoryDeclaration<AuthInterceptor, never>;
66
66
  static ɵprov: i0.ɵɵInjectableDeclaration<AuthInterceptor>;
67
67
  }
68
68
 
69
- interface AuthFacebookOptions {
70
- enabled?: boolean;
71
- appId: string;
72
- }
73
- interface AuthGoogleOptions {
74
- enabled?: boolean;
75
- apiKey: string;
76
- clientId: string;
77
- }
78
69
  interface User extends BaseUser {
79
70
  source?: string;
80
71
  sourceId?: string;
@@ -108,17 +99,8 @@ interface IAuthUserIgoOptions {
108
99
  }
109
100
  interface AuthByKeyOptions {
110
101
  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;
102
+ keyProperty: string;
103
+ keyValue: string;
122
104
  }
123
105
  interface WithCredentialsOptions {
124
106
  withCredentials?: boolean;
@@ -167,7 +149,7 @@ declare class AuthService<T extends AuthOptions = AuthOptions> {
167
149
  private router;
168
150
  authenticate$: BehaviorSubject<boolean>;
169
151
  logged$: BehaviorSubject<boolean>;
170
- redirectUrl: string;
152
+ redirectUrl?: string;
171
153
  languageForce: boolean;
172
154
  authOptions: T;
173
155
  private anonymous;
@@ -175,15 +157,15 @@ declare class AuthService<T extends AuthOptions = AuthOptions> {
175
157
  get hasAuthService(): boolean;
176
158
  get user(): User | null;
177
159
  constructor();
178
- login(username: string, password: string): Observable<IUser>;
179
- loginWithToken(token: string, type: string, infosUser?: IInfosUser, applicationId?: string): Observable<IUser>;
160
+ login(username: string, password: string): Observable<IUser | null>;
161
+ loginWithToken(token: string, type: string, infosUser?: IInfosUser, applicationId?: string): Observable<IUser | null>;
180
162
  loginAnonymous(): Observable<boolean>;
181
163
  refresh(): Observable<IToken>;
182
164
  logout(): void;
183
165
  private logoutInternal;
184
166
  isAuthenticated(): boolean;
185
- getToken(): string;
186
- decodeToken(): IgoJwtPayload | null;
167
+ getToken(): string | undefined;
168
+ decodeToken(): IgoJwtPayload | undefined;
187
169
  goToRedirectUrl(): void;
188
170
  getUserInfo(): Observable<User>;
189
171
  getProfils(): Observable<{
@@ -196,7 +178,7 @@ declare class AuthService<T extends AuthOptions = AuthOptions> {
196
178
  get isAnonymous(): boolean;
197
179
  get authenticated(): boolean;
198
180
  get isAdmin(): boolean;
199
- protected loginCall(body: any, headers: any): Observable<IUser>;
181
+ protected loginCall(body: unknown, headers: HttpHeaders): Observable<IUser | null>;
200
182
  private initializeAuthentication;
201
183
  static ɵfac: i0.ɵɵFactoryDeclaration<AuthService<any>, never>;
202
184
  static ɵprov: i0.ɵɵInjectableDeclaration<AuthService<any>>;
@@ -227,8 +209,8 @@ declare class TokenService {
227
209
  constructor();
228
210
  set(token: string): void;
229
211
  remove(): void;
230
- get(): string;
231
- decode(): IgoJwtPayload | null;
212
+ get(): string | undefined;
213
+ decode(): IgoJwtPayload | undefined;
232
214
  isExpired(): boolean;
233
215
  static ɵfac: i0.ɵɵFactoryDeclaration<TokenService, never>;
234
216
  static ɵprov: i0.ɵɵInjectableDeclaration<TokenService>;
@@ -240,7 +222,7 @@ declare class UserService {
240
222
  private options;
241
223
  private baseUrl;
242
224
  private _user$;
243
- user$: Observable<IUser>;
225
+ user$: Observable<IUser | undefined>;
244
226
  constructor();
245
227
  getUser(): Observable<IUser>;
246
228
  sync(): Observable<IUser>;
@@ -256,4 +238,4 @@ declare function withUserIgo(): AuthFeature<AuthFeatureKind.User>;
256
238
  declare function provideAuthentification(...features: AuthFeature<AuthFeatureKind>[]): EnvironmentProviders;
257
239
 
258
240
  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 };
241
+ export type { AuthByKeyOptions, AuthFeature, AuthInternOptions, AuthOptions, AuthStorageOptions, IAuthUserIgoOptions, IInfosUser, IUser, IUserPreference, IgoJwtPayload, User, WithCredentialsOptions };
@@ -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,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: "20.3.19", ngImport: i0, type: AuthFacebookComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
53
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.19", 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: "20.3.19", ngImport: i0, type: AuthFacebookComponent, decorators: [{
56
- type: Component,
57
- args: [{ selector: 'igo-auth-facebook', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, 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 standalone: true\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":";;;;;MAoBa,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,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC;AAErD,QAAA,IAAI,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE;YACvB,IAAI,CAAC,eAAe,EAAE;QACxB;aAAO;AACL,YAAA,OAAO,CAAC,IAAI,CAAC,gDAAgD,CAAC;QAChE;IACF;IAEQ,eAAe,GAAA;AACpB,QAAA,MAAc,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,mBAAmB,EAAE,CAAC,GAAG,KAAI;AAC9D,YAAA,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC;AAChC,QAAA,CAAC,CAAC;IACJ;AAEQ,IAAA,oBAAoB,CAAC,QAAQ,EAAA;AACnC,QAAA,IAAI,QAAQ,CAAC,MAAM,KAAK,WAAW,EAAE;AACnC,YAAA,MAAM,WAAW,GAAG,QAAQ,CAAC,YAAY,CAAC,WAAW;AACrD,YAAA,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC;QACjC;IACF;AAEQ,IAAA,aAAa,CAAC,KAAK,EAAA;AACzB,QAAA,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,SAAS,CAAC,MAAK;AA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AI,EAAA,QAAA,EAAA,iOAAA,EAAA,MAAA,EAAA,CAAA,mFAAA,CAAA,EAAA;;;AElBlB;;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: "20.3.19", ngImport: i0, type: AuthGoogleComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
94
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.19", 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: "20.3.19", ngImport: i0, type: AuthGoogleComponent, decorators: [{
97
- type: Component,
98
- args: [{ selector: 'igo-auth-google', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, 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 standalone: true\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":";;;;;;MAqBa,mBAAmB,CAAA;AACtB,IAAA,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;AACjC,IAAA,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC;AAC9B,IAAA,eAAe,GAAG,MAAM,CAAC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
- 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 };