@strivacity/sdk-angular 1.0.1 → 2.0.0-beta.2

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.
package/README.md CHANGED
@@ -2,13 +2,20 @@
2
2
 
3
3
  > **The SDK supports Angular version 16 and above**
4
4
 
5
- ### Install
5
+ ## Example Apps
6
+
7
+ - [Example app](https://github.com/Strivacity/sdk-js/tree/main/apps/angular)
8
+ - [Ionic Example app](https://github.com/Strivacity/sdk-js/tree/main/apps/ionic-angular)
9
+
10
+ ## Install
6
11
 
7
12
  ```bash
8
13
  npm install @strivacity/sdk-angular
9
14
  ```
10
15
 
11
- ### Usage
16
+ ## Usage
17
+
18
+ ### Add this to your application configuration
12
19
 
13
20
  #### NgModule - Import `StrivacityAuthModule` to your application:
14
21
 
@@ -18,12 +25,13 @@ npm install @strivacity/sdk-angular
18
25
  import { NgModule } from '@angular/core';
19
26
 
20
27
  import { AppComponent } from './app.component';
21
- import { StrivacityAuthModule } from '@strivacity/angular-sdk';
28
+ import { StrivacityAuthModule } from '@strivacity/sdk-angular';
22
29
 
23
30
  @NgModule({
24
31
  declarations: [AppComponent],
25
32
  imports: [
26
33
  ...StrivacityAuthModule.forRoot({
34
+ mode: 'redirect', // or 'popup' or 'native'
27
35
  issuer: 'https://<YOUR_DOMAIN>',
28
36
  scopes: ['openid', 'profile'],
29
37
  clientId: '<YOUR_CLIENT_ID>',
@@ -46,6 +54,7 @@ import { provideStrivacity } from '@strivacity/sdk-angular';
46
54
  export const appConfig: ApplicationConfig = {
47
55
  providers: [
48
56
  ...provideStrivacity({
57
+ mode: 'redirect', // or 'popup' or 'native'
49
58
  issuer: 'https://<YOUR_DOMAIN>',
50
59
  scopes: ['openid', 'profile'],
51
60
  clientId: '<YOUR_CLIENT_ID>',
@@ -55,25 +64,261 @@ export const appConfig: ApplicationConfig = {
55
64
  };
56
65
  ```
57
66
 
58
- #### NgModule - How to use the SDK in your components:
67
+ ### How to use the SDK in your components
68
+
69
+ #### Redirect mode
70
+
71
+ When using redirect mode, the authentication flow involves two main components: a login page that initiates the authentication process, and a callback page that handles the response from the identity provider.
72
+
73
+ In **redirect mode**, users are redirected to the identity provider's login page in the same browser window. After successful authentication, they are redirected back to your application's callback URL.
74
+
75
+ ##### Login page example
76
+
77
+ The login page is where users start the authentication process. This component automatically triggers the login flow when the page loads, redirecting users to the identity provider for authentication.
78
+
79
+ ```html
80
+ <!-- login.component.html -->
81
+ <section>
82
+ <h1>Redirecting...</h1>
83
+ </section>
84
+ ```
85
+
86
+ ```ts
87
+ // login.component.ts
88
+ import { Component, OnInit } from '@angular/core';
89
+ import { StrivacityAuthService } from '@strivacity/sdk-angular';
90
+
91
+ @Component({
92
+ standalone: true,
93
+ selector: 'app-login',
94
+ templateUrl: './login.component.html',
95
+ })
96
+ export class LoginComponent implements OnInit {
97
+ constructor(private strivacityAuthService: StrivacityAuthService) {}
98
+
99
+ ngOnInit(): void {
100
+ this.strivacityAuthService.login().subscribe();
101
+ }
102
+ }
103
+ ```
104
+
105
+ ##### Callback page example
106
+
107
+ The callback page handles the response from the identity provider after successful authentication. It processes the authentication result, extracts the tokens, and redirects users to their intended destination (typically a protected page like a profile or dashboard).
108
+
109
+ ```html
110
+ <!-- callback.component.html -->
111
+ <section>
112
+ @if (error) {
113
+ <h1>Error in authentication</h1>
114
+ <div>
115
+ <h4>{{ error }}</h4>
116
+ <p>{{ errorDescription }}</p>
117
+ </div>
118
+ } @else {
119
+ <h1>Logging in...</h1>
120
+ }
121
+ </section>
122
+ ```
123
+
124
+ ```ts
125
+ // callback.component.ts
126
+ import { Component, OnInit, OnDestroy } from '@angular/core';
127
+ import { ActivatedRoute, Router } from '@angular/router';
128
+ import { Subscription } from 'rxjs';
129
+ import { StrivacityAuthService } from '@strivacity/sdk-angular';
130
+
131
+ @Component({
132
+ standalone: true,
133
+ selector: 'app-callback',
134
+ templateUrl: './callback.component.html',
135
+ })
136
+ export class CallbackComponent implements OnInit, OnDestroy {
137
+ private subscription = new Subscription();
138
+ error: string | null = null;
139
+ errorDescription: string | null = null;
140
+
141
+ constructor(
142
+ private route: ActivatedRoute,
143
+ private router: Router,
144
+ private strivacityAuthService: StrivacityAuthService,
145
+ ) {}
146
+
147
+ ngOnInit(): void {
148
+ this.subscription.add(
149
+ this.strivacityAuthService.handleCallback().subscribe({
150
+ next: () => {
151
+ this.router.navigateByUrl('/profile');
152
+ },
153
+ error: (err) => {
154
+ this.error = this.route.snapshot.queryParamMap.get('error');
155
+ this.errorDescription = this.route.snapshot.queryParamMap.get('error_description');
156
+ console.error('Error during callback handling:', err);
157
+ },
158
+ }),
159
+ );
160
+ }
161
+
162
+ ngOnDestroy(): void {
163
+ this.subscription.unsubscribe();
164
+ }
165
+ }
166
+ ```
167
+
168
+ ##### Profile page example
169
+
170
+ The profile page displays user information and authentication details after successful login. It uses the `StrivacityAuthService` to access the authentication state and display relevant data such as access tokens, ID token claims, and expiration status.
171
+
172
+ We check if the user is authenticated and display their profile information. If the user is not authenticated, we redirect them to the login page.
173
+
174
+ ```html
175
+ <!-- profile.component.html -->
176
+ <section>
177
+ @if (session.loading) {
178
+ <h1>Loading...</h1>
179
+ } @else {
180
+ <dl>
181
+ <dt>
182
+ <strong>accessToken</strong>
183
+ </dt>
184
+ <dd>
185
+ <pre>{{ session.accessToken | json }}</pre>
186
+ </dd>
187
+ <dt>
188
+ <strong>refreshToken</strong>
189
+ </dt>
190
+ <dd>
191
+ <pre>{{ session.refreshToken | json }}</pre>
192
+ </dd>
193
+ <dt>
194
+ <strong>accessTokenExpired</strong>
195
+ </dt>
196
+ <dd>
197
+ <pre>{{ session.accessTokenExpired | json }}</pre>
198
+ </dd>
199
+ <dt>
200
+ <strong>accessTokenExpirationDate</strong>
201
+ </dt>
202
+ <dd>
203
+ <pre>{{ session.accessTokenExpirationDate | date: 'medium' }}</pre>
204
+ </dd>
205
+ <dt>
206
+ <strong>claims</strong>
207
+ </dt>
208
+ <dd>
209
+ <pre>{{ session.idTokenClaims | json }}</pre>
210
+ </dd>
211
+ </dl>
212
+ }
213
+ </section>
214
+ ```
215
+
216
+ ```ts
217
+ // profile.component.ts
218
+ import { Component, OnDestroy } from '@angular/core';
219
+ import { DatePipe, JsonPipe } from '@angular/common';
220
+ import { Subscription } from 'rxjs';
221
+ import { Session, StrivacityAuthService } from '@strivacity/sdk-angular';
222
+
223
+ @Component({
224
+ standalone: true,
225
+ selector: 'app-profile',
226
+ templateUrl: './profile.component.html',
227
+ imports: [JsonPipe, DatePipe],
228
+ })
229
+ export class ProfileComponent implements OnDestroy {
230
+ readonly subscription = new Subscription();
231
+ session: Session = {
232
+ loading: true,
233
+ isAuthenticated: false,
234
+ idTokenClaims: null,
235
+ accessToken: null,
236
+ refreshToken: null,
237
+ accessTokenExpired: false,
238
+ accessTokenExpirationDate: null,
239
+ };
240
+
241
+ constructor(private strivacityAuthService: StrivacityAuthService) {
242
+ this.subscription.add(
243
+ this.strivacityAuthService.session$.subscribe((session) => {
244
+ this.session = session;
245
+ }),
246
+ );
247
+ }
248
+
249
+ ngOnDestroy(): void {
250
+ this.subscription.unsubscribe();
251
+ }
252
+ }
253
+ ```
254
+
255
+ ##### Logout page example
59
256
 
60
- `app.component.html`
257
+ The logout page handles user logout by terminating their session. The `postLogoutRedirectUri` parameter is optional and specifies where users should be redirected after logout. If not provided, users will be redirected to the identity provider's logout page.
61
258
 
62
- ```text
259
+ This URI must be configured in the Admin Console as an allowed post-logout redirect URI for your application.
260
+
261
+ ```html
262
+ <!-- logout.component.html -->
263
+ <section>
264
+ <h1>Logging out...</h1>
265
+ </section>
266
+ ```
267
+
268
+ ```ts
269
+ // logout.component.ts
270
+ import { Component, OnInit, OnDestroy } from '@angular/core';
271
+ import { Router } from '@angular/router';
272
+ import { Subscription, firstValueFrom } from 'rxjs';
273
+ import { StrivacityAuthService } from '@strivacity/sdk-angular';
274
+
275
+ @Component({
276
+ standalone: true,
277
+ selector: 'app-logout',
278
+ templateUrl: './logout.component.html',
279
+ })
280
+ export class LogoutComponent implements OnInit, OnDestroy {
281
+ readonly subscription = new Subscription();
282
+
283
+ constructor(
284
+ private router: Router,
285
+ private strivacityAuthService: StrivacityAuthService,
286
+ ) {}
287
+
288
+ async ngOnInit(): Promise<void> {
289
+ if (this.strivacityAuthService.isAuthenticated()) {
290
+ await firstValueFrom(this.strivacityAuthService.logout({ postLogoutRedirectUri: window.location.origin }));
291
+ } else {
292
+ await this.router.navigateByUrl('/');
293
+ }
294
+ }
295
+
296
+ ngOnDestroy(): void {
297
+ this.subscription.unsubscribe();
298
+ }
299
+ }
300
+ ```
301
+
302
+ ##### Component example
303
+
304
+ Here's a simple component example that demonstrates how to use the SDK in a component with login/logout functionality:
305
+
306
+ ```html
307
+ <!-- app.component.html -->
63
308
  @if (isAuthenticated) {
64
- <div>Welcome, {{ name }}!</div>
65
- <button @click="logout()">Logout</button>
309
+ <div>Welcome, {{ name }}!</div>
310
+ <button (click)="logout()">Logout</button>
66
311
  } @else {
67
- <div>Not logged in</div>
68
- <button @click="login()">Log in</button>
312
+ <div>Not logged in</div>
313
+ <button (click)="login()">Log in</button>
69
314
  }
70
315
  ```
71
316
 
72
- `app.component.ts`
73
-
74
317
  ```ts
75
- import { Component } from '@angular/core';
318
+ // app.component.ts
319
+ import { Component, OnDestroy } from '@angular/core';
76
320
  import { Router } from '@angular/router';
321
+ import { Subscription } from 'rxjs';
77
322
  import { StrivacityAuthService } from '@strivacity/sdk-angular';
78
323
 
79
324
  @Component({
@@ -81,18 +326,25 @@ import { StrivacityAuthService } from '@strivacity/sdk-angular';
81
326
  templateUrl: './app.component.html',
82
327
  styleUrls: ['./app.component.scss'],
83
328
  })
84
- export class AppComponent {
329
+ export class AppComponent implements OnDestroy {
330
+ private subscription = new Subscription();
85
331
  isAuthenticated = false;
86
332
  name = '';
87
333
 
88
334
  constructor(
89
- protected router: Router,
90
- protected strivacityAuthService: StrivacityAuthService,
335
+ private router: Router,
336
+ private strivacityAuthService: StrivacityAuthService,
91
337
  ) {
92
- this.strivacityAuthService.session$.subscribe((session) => {
93
- this.isAuthenticated = session.isAuthenticated;
94
- this.name = `${session.idTokenClaims?.given_name} ${session.idTokenClaims?.family_name}`;
95
- });
338
+ this.subscription.add(
339
+ this.strivacityAuthService.session$.subscribe((session) => {
340
+ this.isAuthenticated = session.isAuthenticated;
341
+ this.name = `${session.idTokenClaims?.given_name} ${session.idTokenClaims?.family_name}`;
342
+ }),
343
+ );
344
+ }
345
+
346
+ ngOnDestroy(): void {
347
+ this.subscription.unsubscribe();
96
348
  }
97
349
 
98
350
  login(): void {
@@ -113,15 +365,242 @@ export class AppComponent {
113
365
  }
114
366
  ```
115
367
 
116
- #### Standalone mode - How to use the SDK in your components:
368
+ #### Native mode
369
+
370
+ If you are using `native` mode, you can use the `sty-login-renderer` component to render the login UI.
371
+
372
+ To customize the UI components used in the authentication flows, define the `widgets` object in your component.
373
+
374
+ ##### Example widgets
375
+
376
+ ```ts
377
+ import {
378
+ CheckboxWidget,
379
+ DateWidget,
380
+ InputWidget,
381
+ LayoutWidget,
382
+ MultiSelectWidget,
383
+ PasscodeWidget,
384
+ LoadingWidget,
385
+ PasswordWidget,
386
+ PhoneWidget,
387
+ SelectWidget,
388
+ StaticWidget,
389
+ SubmitWidget,
390
+ } from './components/widgets';
391
+
392
+ export const widgets = {
393
+ checkbox: CheckboxWidget,
394
+ date: DateWidget,
395
+ input: InputWidget,
396
+ layout: LayoutWidget,
397
+ loading: LoadingWidget,
398
+ passcode: PasscodeWidget,
399
+ password: PasswordWidget,
400
+ phone: PhoneWidget,
401
+ select: SelectWidget,
402
+ multiSelect: MultiSelectWidget,
403
+ static: StaticWidget,
404
+ submit: SubmitWidget,
405
+ };
406
+ ```
407
+
408
+ You can find example widgets here: [Example widgets](https://github.com/Strivacity/sdk-js/tree/main/apps/angular/src/app/components/widgets)
409
+
410
+ ##### Login page example
411
+
412
+ The native mode login page provides a fully customizable authentication experience rendered directly within your application. Unlike redirect mode, native mode keeps users on your site throughout the entire authentication process using the `sty-login-renderer` component.
413
+
414
+ This example demonstrates how to handle session management, implement callback functions for various authentication events, and manage URL parameters for session continuity.
415
+
416
+ ```html
417
+ <!-- login.component.html -->
418
+ <section>
419
+ <sty-login-renderer
420
+ [widgets]="widgets"
421
+ [sessionId]="sessionId"
422
+ (fallback)="onFallback($event)"
423
+ (login)="onLogin()"
424
+ (error)="onError($event)"
425
+ (globalMessage)="onGlobalMessage($event)"
426
+ (blockReady)="onBlockReady($event)"
427
+ ></sty-login-renderer>
428
+ </section>
429
+ ```
430
+
431
+ ```ts
432
+ // login.component.ts
433
+ import { Component, OnInit } from '@angular/core';
434
+ import { Router } from '@angular/router';
435
+ import { StrivacityAuthService, FallbackError, StyLoginRenderer, LoginFlowState } from '@strivacity/sdk-angular';
436
+ import { widgets } from '@/components/widgets'; // Import your custom widgets
437
+
438
+ @Component({
439
+ standalone: true,
440
+ imports: [StyLoginRenderer],
441
+ selector: 'app-login',
442
+ templateUrl: './login.component.html',
443
+ })
444
+ export class LoginComponent implements OnInit {
445
+ readonly widgets = widgets;
446
+ sessionId: string | null = null;
447
+
448
+ constructor(
449
+ private router: Router,
450
+ private strivacityAuthService: StrivacityAuthService,
451
+ ) {}
452
+
453
+ /**
454
+ * Extract session_id from URL parameters and clean up the URL
455
+ * This is necessary for maintaining session state across external login providers
456
+ */
457
+ ngOnInit(): void {
458
+ if (window.location.search !== '') {
459
+ const url = new URL(window.location.href);
460
+ this.sessionId = url.searchParams.get('session_id');
461
+ url.search = '';
462
+ history.replaceState({}, '', url.toString());
463
+ }
464
+ }
465
+
466
+ /**
467
+ * Called when authentication is successful
468
+ * Redirects user to the profile page
469
+ */
470
+ async onLogin(): Promise<void> {
471
+ await this.router.navigateByUrl('/profile');
472
+ }
473
+
474
+ /**
475
+ * Called when native flow cannot handle the authentication
476
+ * Falls back to redirect mode by navigating to the provided URL
477
+ * @param error - FallbackError containing the fallback URL and message
478
+ */
479
+ onFallback(error: FallbackError): void {
480
+ if (error.url) {
481
+ console.log(`Fallback: ${error.url}`);
482
+ location.href = error.url.toString();
483
+ } else {
484
+ console.error(`FallbackError without URL: ${error.message}`);
485
+ alert(error);
486
+ }
487
+ }
488
+
489
+ /**
490
+ * Called when an error occurs during the authentication process
491
+ * @param error - Error message describing what went wrong
492
+ */
493
+ onError(error: string): void {
494
+ console.error(`Error: ${error}`);
495
+ alert(error);
496
+ }
497
+
498
+ /**
499
+ * Called when the authentication flow wants to display a global message
500
+ * @param message - Message to display to the user
501
+ */
502
+ onGlobalMessage(message: string): void {
503
+ alert(message);
504
+ }
505
+
506
+ /**
507
+ * Called when the authentication flow transitions between states
508
+ * Useful for tracking flow progress and inject custom logic such as logging or analytics
509
+ * @param params - Object containing previous and current flow states
510
+ */
511
+ onBlockReady({ previousState, state }: { previousState: LoginFlowState; state: LoginFlowState }): void {
512
+ console.log('previousState', previousState);
513
+ console.log('state', state);
514
+ }
515
+ }
516
+ ```
517
+
518
+ ##### Callback page example
519
+
520
+ The native mode callback page handles authentication responses when external identity providers redirect back to your application. This page checks for session IDs in the URL parameters and either continues the native flow or falls back to standard callback handling.
521
+
522
+ This component is essential for handling social login providers (like Google, Facebook, etc.) that require redirect-based authentication even within native mode flows.
523
+
524
+ ```html
525
+ <!-- callback.component.html -->
526
+ <section>
527
+ @if (error) {
528
+ <h1>Error in authentication</h1>
529
+ <div>
530
+ <h4>{{ error }}</h4>
531
+ <p>{{ errorDescription }}</p>
532
+ </div>
533
+ } @else {
534
+ <h1>Logging in...</h1>
535
+ }
536
+ </section>
537
+ ```
538
+
539
+ ```ts
540
+ // callback.component.ts
541
+ import { Component, OnInit, OnDestroy } from '@angular/core';
542
+ import { ActivatedRoute, Router } from '@angular/router';
543
+ import { Subscription } from 'rxjs';
544
+ import { StrivacityAuthService } from '@strivacity/sdk-angular';
545
+
546
+ @Component({
547
+ standalone: true,
548
+ selector: 'app-callback',
549
+ templateUrl: './callback.component.html',
550
+ })
551
+ export class CallbackComponent implements OnInit, OnDestroy {
552
+ readonly subscription = new Subscription();
553
+ error: string | null = null;
554
+ errorDescription: string | null = null;
555
+
556
+ constructor(
557
+ private route: ActivatedRoute,
558
+ private router: Router,
559
+ private strivacityAuthService: StrivacityAuthService,
560
+ ) {}
561
+
562
+ ngOnInit(): void {
563
+ const url = new URL(window.location.href);
564
+ const sessionId = url.searchParams.get('session_id');
565
+
566
+ if (sessionId) {
567
+ this.router.navigate(['/login'], { queryParams: { session_id: sessionId } });
568
+ return;
569
+ }
570
+
571
+ this.subscription.add(
572
+ this.strivacityAuthService.handleCallback().subscribe({
573
+ next: () => {
574
+ this.router.navigateByUrl('/profile');
575
+ },
576
+ error: (err) => {
577
+ this.error = this.route.snapshot.queryParamMap.get('error');
578
+ this.errorDescription = this.route.snapshot.queryParamMap.get('error_description');
579
+ console.error('Error during callback handling:', err);
580
+ },
581
+ }),
582
+ );
583
+ }
584
+
585
+ ngOnDestroy(): void {
586
+ this.subscription.unsubscribe();
587
+ }
588
+ }
589
+ ```
590
+
591
+ ##### Profile page example
592
+
593
+ Same as the profile page example in redirect mode.
594
+
595
+ ##### Logout page example
117
596
 
118
- Everything in the SDK are standalone, so you can use them by directly importing them to your components.
597
+ Same as the logout page example in redirect mode.
119
598
 
120
- ### API Documentation
599
+ ## API Documentation
121
600
 
122
601
  #### `StrivacityAuthService`
123
602
 
124
- Service that manages Strivacity authentication flows. Supports either `PopupFlow` or `RedirectFlow` types.
603
+ Service that manages Strivacity authentication flows. Supports `PopupFlow`, `RedirectFlow`, or `NativeFlow` types.
125
604
 
126
605
  **Constructor**
127
606
 
@@ -184,11 +663,6 @@ interface Session = {
184
663
  };
185
664
  ```
186
665
 
187
- **Emits**:
188
-
189
- - **Initial State**: When the service is initialized, `session$` will emit an initial state with `loading: true` and other properties set to default or `null` values.
190
- - **State Changes**: As authentication events occur (e.g., login, logout, token refresh), `session$` will emit updated session states reflecting the current authentication status and token details.
191
-
192
666
  **Methods**
193
667
 
194
668
  - **`isAuthenticated()`**: Checks if the user is authenticated.
@@ -197,16 +671,16 @@ interface Session = {
197
671
  isAuthenticated(): Observable<boolean>;
198
672
  ```
199
673
 
200
- - **`login(options?: Parameters<Flow['login']>[0])`**: Logs the user in using the specified options.
674
+ - **`login(options?: LoginOptions)`**: Logs the user in using the specified options.
201
675
 
202
676
  ```typescript
203
- login(options?: Parameters<Flow['login']>[0]): Observable<void>;
677
+ login(options?: LoginOptions): Observable<void>;
204
678
  ```
205
679
 
206
- - **`register(options?: Parameters<Flow['register']>[0])`**: Registers a new user using the specified options.
680
+ - **`register(options?: RegisterOptions)`**: Registers a new user using the specified options.
207
681
 
208
682
  ```typescript
209
- register(options?: Parameters<Flow['register']>[0]): Observable<void>;
683
+ register(options?: RegisterOptions): Observable<void>;
210
684
  ```
211
685
 
212
686
  - **`refresh()`**: Refreshes the current authentication session.
@@ -221,18 +695,74 @@ interface Session = {
221
695
  revoke(): Observable<void>;
222
696
  ```
223
697
 
224
- - **`logout(options?: Parameters<Flow['logout']>[0])`**: Logs the user out using the specified options.
698
+ - **`logout(options?: LogoutOptions)`**: Logs the user out using the specified options.
225
699
 
226
700
  ```typescript
227
- logout(options?: Parameters<Flow['logout']>[0]): Observable<void>;
701
+ logout(options?: LogoutOptions): Observable<void>;
228
702
  ```
229
703
 
230
- - **`handleCallback(url?: Parameters<Flow['handleCallback']>[0])`**: Handles the authentication callback (e.g., after a redirect or popup flow).
704
+ - **`handleCallback(url?: string)`**: Handles the authentication callback (e.g., after a redirect flow).
231
705
 
232
706
  ```typescript
233
- handleCallback(url?: Parameters<Flow['handleCallback']>[0]): Observable<void>;
707
+ handleCallback(url?: string): Observable<void>;
234
708
  ```
235
709
 
236
- ### Links
710
+ #### `StyLoginRenderer` component
711
+
712
+ The `StyLoginRenderer` component is used in native mode to render the authentication UI directly within your application. It provides a fully customizable login experience using your own UI components.
713
+
714
+ ```typescript
715
+ StyLoginRenderer: Component<{
716
+ params?: NativeParams;
717
+ widgets?: PartialRecord<WidgetType, Component>;
718
+ sessionId?: string | null;
719
+ login?: EventEmitter<IdTokenClaims | null>;
720
+ fallback?: EventEmitter<FallbackError>;
721
+ error?: EventEmitter<any>;
722
+ globalMessage?: EventEmitter<string>;
723
+ blockReady?: EventEmitter<{ previousState: LoginFlowState; state: LoginFlowState }>;
724
+ }>;
725
+ ```
726
+
727
+ **Properties**
728
+
729
+ - **`params?: NativeParams`** (optional): Additional parameters to pass to the native login flow. These parameters can include custom configuration options for the authentication process.
730
+
731
+ - **`widgets?: PartialRecord<WidgetType, Component>`** (optional): A collection of Angular components that define the UI widgets used in the authentication flow. Each widget type (input, button, layout, etc.) can be customized with your own components.
732
+
733
+ - **`sessionId?: string | null`** (optional): The session ID for continuing an existing authentication session. This is typically extracted from URL parameters when returning from external identity providers.
734
+
735
+ **Events**
736
+
737
+ - **`(login)?: EventEmitter<IdTokenClaims | null>`** (optional): Event emitted when authentication is successful. Receives the ID token claims as a parameter.
738
+
739
+ - **`(fallback)?: EventEmitter<FallbackError>`** (optional): Event emitted when the native flow cannot handle the authentication and needs to fall back to redirect mode. The error parameter contains the fallback URL.
740
+
741
+ - **`(error)?: EventEmitter<any>`** (optional): Event emitted when an error occurs during the authentication process. Use this to handle and display error messages to users.
742
+
743
+ - **`(globalMessage)?: EventEmitter<string>`** (optional): Event emitted when the authentication flow wants to display a global message to the user (e.g., account lockout warnings, validation messages).
744
+
745
+ - **`(blockReady)?: EventEmitter<{ previousState: LoginFlowState; state: LoginFlowState }>`** (optional): Event emitted when the authentication flow transitions between states. Useful for tracking progress, implementing custom logging, or injecting analytics. Receives both the previous and current flow states.
746
+
747
+ **Widget Types**
748
+
749
+ The `widgets` input accepts the following widget types:
750
+
751
+ - `checkbox`: For checkbox input fields
752
+ - `date`: For date input fields
753
+ - `input`: For text input fields
754
+ - `layout`: For layout containers and form structure
755
+ - `loading`: For loading indicators
756
+ - `multiSelect`: For multi-select dropdown fields
757
+ - `passcode`: For passcode input fields
758
+ - `password`: For password input fields
759
+ - `phone`: For phone number input fields
760
+ - `select`: For single-select dropdown fields
761
+ - `static`: For static text and display elements
762
+ - `submit`: For form submission buttons
763
+
764
+ Each widget component receives inputs specific to its type and function within the authentication flow.
765
+
766
+ ## Links
237
767
 
238
- [Example app](https://github.com/Strivacity/sdk-js/tree/main/apps/angular)
768
+ - [Example app](https://github.com/Strivacity/sdk-js/tree/main/apps/angular)