@nauth-toolkit/client-angular 0.3.2 → 0.4.0

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.
@@ -0,0 +1,43 @@
1
+ import { CanActivateFn } from '@angular/router';
2
+ /**
3
+ * Return a user to a pending OpenID Connect request after they finish signing in.
4
+ *
5
+ * When a third-party application starts an authorization request and the user is not
6
+ * signed in, the consent page stashes the request id (`oidc.setPendingInteraction`) and
7
+ * sends them to login. The ordinary nauth challenge chain then runs — possibly several
8
+ * steps of it — and lands them wherever your app puts people after login. This guard
9
+ * intercepts that landing and sends them back to finish what they started.
10
+ *
11
+ * **You may not need this.** If your app lets the SDK drive navigation, the
12
+ * `navigationHandler` config option is a single chokepoint that can do the same job
13
+ * without touching your routes:
14
+ *
15
+ * ```typescript
16
+ * navigationHandler: async (url) => {
17
+ * const uid = url.startsWith('/auth/challenge') ? null : await client.oidc.takePendingInteraction();
18
+ * void router.navigateByUrl(uid ? client.oidc.interactionRoute(uid) : url);
19
+ * }
20
+ * ```
21
+ *
22
+ * Reach for the guard instead when your own challenge components call
23
+ * `router.navigate()` themselves once a challenge completes — a common pattern, and one
24
+ * that bypasses `navigationHandler` entirely. Guarding the *destination* catches every
25
+ * such path without having to touch any of them.
26
+ *
27
+ * Put it on whatever routes a freshly logged-in user can land on.
28
+ *
29
+ * @param interactionPath - Route rendering the consent screen; defaults to `oidc.interactionPath`
30
+ * @returns A CanActivateFn that redirects to the pending interaction, when there is one
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * const routes: Routes = [
35
+ * {
36
+ * path: 'dashboard',
37
+ * component: DashboardComponent,
38
+ * canActivate: [authGuard(), oidcReturnGuard()],
39
+ * },
40
+ * ];
41
+ * ```
42
+ */
43
+ export declare function oidcReturnGuard(interactionPath?: string): CanActivateFn;
@@ -2,7 +2,7 @@ import { Router } from '@angular/router';
2
2
  import { Observable } from 'rxjs';
3
3
  import { AngularHttpAdapter } from './http-adapter';
4
4
  import { RecaptchaService } from '../lib/recaptcha.service';
5
- import { NAuthClient, NAuthClientConfig, ChallengeResponse, AuthResponse, TokenResponse, AuthUser, ConfirmForgotPasswordResponse, ForgotPasswordResponse, ResetPasswordWithCodeResponse, UpdateProfileRequest, GetChallengeDataResponse, GetSetupDataResponse, GetMFADevicesResponse, MFAStatus, RemoveMFADeviceResponse, AuthEvent, SocialProvider, SocialLoginOptions, LinkedAccountsResponse, SocialVerifyRequest, AuditHistoryResponse, AdminOperations } from '@nauth-toolkit/client';
5
+ import { NAuthClient, NAuthClientConfig, ChallengeResponse, AuthResponse, TokenResponse, AuthUser, ConfirmForgotPasswordResponse, ForgotPasswordResponse, ResetPasswordWithCodeResponse, UpdateProfileRequest, GetChallengeDataResponse, GetSetupDataResponse, GetMFADevicesResponse, MFAStatus, RemoveMFADeviceResponse, AuthEvent, SocialProvider, SocialLoginOptions, LinkedAccountsResponse, SocialVerifyRequest, AuditHistoryResponse, AdminOperations, OIDCOperations } from '@nauth-toolkit/client';
6
6
  import * as i0 from "@angular/core";
7
7
  /**
8
8
  * Angular wrapper around NAuthClient that provides promise-based auth methods and reactive state.
@@ -793,6 +793,30 @@ export declare class AuthService {
793
793
  * ```
794
794
  */
795
795
  get admin(): AdminOperations | undefined;
796
+ /**
797
+ * OpenID Connect interaction operations.
798
+ *
799
+ * Only meaningful when this application *is* an OpenID Connect provider — one whose
800
+ * backend runs `@nauth-toolkit/oidc-provider`. Use it to build the consent screen the
801
+ * provider redirects to, and to remember a pending request across a login detour.
802
+ *
803
+ * @returns OIDCOperations instance
804
+ *
805
+ * @example
806
+ * ```typescript
807
+ * const state = await this.auth.oidc.getInteraction(uid);
808
+ *
809
+ * if (state.gate === 'login_required') {
810
+ * await this.auth.oidc.setPendingInteraction(uid);
811
+ * void this.router.navigate(['/login']);
812
+ * return;
813
+ * }
814
+ *
815
+ * const { redirectTo } = await this.auth.oidc.approve(uid);
816
+ * window.location.assign(redirectTo); // leaves Angular; the provider takes over
817
+ * ```
818
+ */
819
+ get oidc(): OIDCOperations;
796
820
  /**
797
821
  * Initialize by hydrating state from storage.
798
822
  * Called automatically on construction.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nauth-toolkit/client-angular",
3
- "version": "0.3.2",
3
+ "version": "0.4.0",
4
4
  "description": "Angular SDK for nauth-toolkit — services, guards, interceptors",
5
5
  "keywords": [
6
6
  "nauth",
@@ -27,7 +27,7 @@
27
27
  "peerDependencies": {
28
28
  "@angular/common": ">=17.0.0",
29
29
  "@angular/core": ">=17.0.0",
30
- "@nauth-toolkit/client": "^0.3.2",
30
+ "@nauth-toolkit/client": "^0.4.0",
31
31
  "rxjs": "^7.0.0 || ^8.0.0"
32
32
  },
33
33
  "dependencies": {
@@ -63,4 +63,4 @@
63
63
  "default": "./fesm2022/nauth-toolkit-client-angular-src-standalone.mjs"
64
64
  }
65
65
  }
66
- }
66
+ }
package/public-api.d.ts CHANGED
@@ -13,5 +13,6 @@ export * from './ngmodule/nauth.module';
13
13
  export * from './lib/auth.interceptor';
14
14
  export * from './lib/auth.guard';
15
15
  export * from './lib/social-redirect-callback.guard';
16
+ export * from './lib/oidc-return.guard';
16
17
  export * from './lib/recaptcha.service';
17
18
  export * from './lib/recaptcha-provider';