@nauth-toolkit/client-angular 0.1.55 → 0.1.57
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/esm2022/lib/auth.guard.mjs +83 -0
- package/esm2022/lib/auth.interceptor.mjs +158 -0
- package/esm2022/lib/social-redirect-callback.guard.mjs +81 -0
- package/esm2022/nauth-toolkit-client-angular.mjs +5 -0
- package/esm2022/ngmodule/auth.interceptor.class.mjs +109 -0
- package/esm2022/ngmodule/auth.service.mjs +777 -0
- package/esm2022/ngmodule/http-adapter.mjs +81 -0
- package/esm2022/ngmodule/nauth.module.mjs +65 -0
- package/esm2022/ngmodule/tokens.mjs +6 -0
- package/esm2022/public-api.mjs +19 -0
- package/esm2022/src/standalone/nauth-toolkit-client-angular-src-standalone.mjs +5 -0
- package/esm2022/src/standalone/public-api.mjs +12 -0
- package/esm2022/standalone/auth.guard.mjs +83 -0
- package/esm2022/standalone/auth.interceptor.mjs +158 -0
- package/esm2022/standalone/auth.service.mjs +777 -0
- package/esm2022/standalone/http-adapter.mjs +81 -0
- package/esm2022/standalone/nauth-toolkit-client-angular-standalone.mjs +5 -0
- package/esm2022/standalone/public-api.mjs +16 -0
- package/esm2022/standalone/social-redirect-callback.guard.mjs +81 -0
- package/esm2022/standalone/tokens.mjs +6 -0
- package/fesm2022/nauth-toolkit-client-angular-src-standalone.mjs +17 -0
- package/fesm2022/nauth-toolkit-client-angular-src-standalone.mjs.map +1 -0
- package/fesm2022/nauth-toolkit-client-angular-standalone.mjs +1183 -0
- package/fesm2022/nauth-toolkit-client-angular-standalone.mjs.map +1 -0
- package/fesm2022/nauth-toolkit-client-angular.mjs +1344 -0
- package/fesm2022/nauth-toolkit-client-angular.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/{src/lib/auth.guard.ts → lib/auth.guard.d.ts} +15 -37
- package/lib/auth.interceptor.d.ts +15 -0
- package/lib/social-redirect-callback.guard.d.ts +25 -0
- package/ngmodule/auth.interceptor.class.d.ts +34 -0
- package/ngmodule/auth.service.d.ts +580 -0
- package/ngmodule/http-adapter.d.ts +37 -0
- package/ngmodule/nauth.module.d.ts +31 -0
- package/{src/ngmodule/tokens.ts → ngmodule/tokens.d.ts} +1 -2
- package/package.json +30 -20
- package/{src/public-api.ts → public-api.d.ts} +0 -6
- package/src/standalone/index.d.ts +5 -0
- package/src/standalone/{public-api.ts → public-api.d.ts} +0 -2
- package/standalone/{auth.guard.ts → auth.guard.d.ts} +15 -37
- package/standalone/auth.interceptor.d.ts +15 -0
- package/standalone/auth.service.d.ts +580 -0
- package/standalone/http-adapter.d.ts +37 -0
- package/standalone/index.d.ts +5 -0
- package/standalone/{public-api.ts → public-api.d.ts} +1 -6
- package/standalone/social-redirect-callback.guard.d.ts +25 -0
- package/standalone/{tokens.ts → tokens.d.ts} +1 -2
- package/ng-package.json +0 -12
- package/src/lib/auth.interceptor.ts +0 -194
- package/src/lib/social-redirect-callback.guard.ts +0 -87
- package/src/ngmodule/auth.interceptor.class.ts +0 -124
- package/src/ngmodule/auth.service.ts +0 -865
- package/src/ngmodule/http-adapter.ts +0 -79
- package/src/ngmodule/nauth.module.ts +0 -59
- package/src/package.json +0 -11
- package/src/standalone/ng-package.json +0 -7
- package/src/standalone/package.json +0 -8
- package/standalone/auth.interceptor.ts +0 -194
- package/standalone/auth.service.ts +0 -865
- package/standalone/http-adapter.ts +0 -79
- package/standalone/ng-package.json +0 -7
- package/standalone/package.json +0 -8
- package/standalone/social-redirect-callback.guard.ts +0 -87
- package/tsconfig.json +0 -10
- package/tsconfig.lib.json +0 -28
- package/tsconfig.lib.prod.json +0 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nauth-toolkit/client-angular",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.57",
|
|
4
4
|
"description": "Angular adapter for nauth-toolkit client SDK",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nauth",
|
|
@@ -24,29 +24,39 @@
|
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"@angular/common": ">=17.0.0",
|
|
26
26
|
"@angular/core": ">=17.0.0",
|
|
27
|
-
"@nauth-toolkit/client": "^0.1.
|
|
27
|
+
"@nauth-toolkit/client": "^0.1.57",
|
|
28
28
|
"rxjs": "^7.0.0 || ^8.0.0"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"tslib": "^2.3.0"
|
|
32
32
|
},
|
|
33
|
-
"devDependencies": {
|
|
34
|
-
"@angular/common": "^17.3.12",
|
|
35
|
-
"@angular/compiler": "^17.3.12",
|
|
36
|
-
"@angular/compiler-cli": "^17.3.12",
|
|
37
|
-
"@angular/core": "^17.3.12",
|
|
38
|
-
"@angular/platform-browser": "^17.3.12",
|
|
39
|
-
"@angular/platform-browser-dynamic": "^17.3.12",
|
|
40
|
-
"@angular/router": "^17.3.12",
|
|
41
|
-
"ng-packagr": "^17.0.0",
|
|
42
|
-
"rxjs": "~7.8.0",
|
|
43
|
-
"typescript": "~5.3.3"
|
|
44
|
-
},
|
|
45
|
-
"scripts": {
|
|
46
|
-
"build": "ng-packagr -p ng-package.json",
|
|
47
|
-
"clean": "rm -rf dist"
|
|
48
|
-
},
|
|
49
33
|
"engines": {
|
|
50
34
|
"node": ">=22.0.0"
|
|
51
|
-
}
|
|
52
|
-
|
|
35
|
+
},
|
|
36
|
+
"module": "fesm2022/nauth-toolkit-client-angular.mjs",
|
|
37
|
+
"typings": "index.d.ts",
|
|
38
|
+
"exports": {
|
|
39
|
+
"./package.json": {
|
|
40
|
+
"default": "./package.json"
|
|
41
|
+
},
|
|
42
|
+
".": {
|
|
43
|
+
"types": "./index.d.ts",
|
|
44
|
+
"esm2022": "./esm2022/nauth-toolkit-client-angular.mjs",
|
|
45
|
+
"esm": "./esm2022/nauth-toolkit-client-angular.mjs",
|
|
46
|
+
"default": "./fesm2022/nauth-toolkit-client-angular.mjs"
|
|
47
|
+
},
|
|
48
|
+
"./standalone": {
|
|
49
|
+
"types": "./standalone/index.d.ts",
|
|
50
|
+
"esm2022": "./esm2022/standalone/nauth-toolkit-client-angular-standalone.mjs",
|
|
51
|
+
"esm": "./esm2022/standalone/nauth-toolkit-client-angular-standalone.mjs",
|
|
52
|
+
"default": "./fesm2022/nauth-toolkit-client-angular-standalone.mjs"
|
|
53
|
+
},
|
|
54
|
+
"./src/standalone": {
|
|
55
|
+
"types": "./src/standalone/index.d.ts",
|
|
56
|
+
"esm2022": "./esm2022/src/standalone/nauth-toolkit-client-angular-src-standalone.mjs",
|
|
57
|
+
"esm": "./esm2022/src/standalone/nauth-toolkit-client-angular-src-standalone.mjs",
|
|
58
|
+
"default": "./fesm2022/nauth-toolkit-client-angular-src-standalone.mjs"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"sideEffects": false
|
|
62
|
+
}
|
|
@@ -4,18 +4,12 @@
|
|
|
4
4
|
* This is the default entry point for NgModule-based Angular apps.
|
|
5
5
|
* For standalone components, use: @nauth-toolkit/client-angular/standalone
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
// Re-export core client types and utilities
|
|
9
7
|
export * from '@nauth-toolkit/client';
|
|
10
|
-
|
|
11
|
-
// Export NgModule-specific components (class-based)
|
|
12
8
|
export * from './ngmodule/tokens';
|
|
13
9
|
export * from './ngmodule/auth.service';
|
|
14
10
|
export * from './ngmodule/http-adapter';
|
|
15
11
|
export * from './ngmodule/auth.interceptor.class';
|
|
16
12
|
export * from './ngmodule/nauth.module';
|
|
17
|
-
|
|
18
|
-
// Export functional components (for flexibility in NgModule apps too)
|
|
19
13
|
export * from './lib/auth.interceptor';
|
|
20
14
|
export * from './lib/auth.guard';
|
|
21
15
|
export * from './lib/social-redirect-callback.guard';
|
|
@@ -7,6 +7,4 @@
|
|
|
7
7
|
* NOTE: This simply re-exports the main entry point since both share the same code for now.
|
|
8
8
|
* The split allows future additions like `provideNAuth()` for standalone apps.
|
|
9
9
|
*/
|
|
10
|
-
|
|
11
|
-
// Re-export everything from the main entry point
|
|
12
10
|
export * from '@nauth-toolkit/client-angular';
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { inject } from '@angular/core';
|
|
2
1
|
import { CanActivateFn, Router, UrlTree } from '@angular/router';
|
|
3
2
|
import { AuthService } from './auth.service';
|
|
4
|
-
|
|
5
3
|
/**
|
|
6
4
|
* Functional route guard for authentication (Angular 17+).
|
|
7
5
|
*
|
|
@@ -28,19 +26,7 @@ import { AuthService } from './auth.service';
|
|
|
28
26
|
* ];
|
|
29
27
|
* ```
|
|
30
28
|
*/
|
|
31
|
-
export function authGuard(redirectTo
|
|
32
|
-
return (): boolean | UrlTree => {
|
|
33
|
-
const auth = inject(AuthService);
|
|
34
|
-
const router = inject(Router);
|
|
35
|
-
|
|
36
|
-
if (auth.isAuthenticated()) {
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return router.createUrlTree([redirectTo]);
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
29
|
+
export declare function authGuard(redirectTo?: string): CanActivateFn;
|
|
44
30
|
/**
|
|
45
31
|
* Class-based authentication guard for NgModule compatibility.
|
|
46
32
|
*
|
|
@@ -61,26 +47,18 @@ export function authGuard(redirectTo = '/login'): CanActivateFn {
|
|
|
61
47
|
* })
|
|
62
48
|
* ```
|
|
63
49
|
*/
|
|
64
|
-
export class AuthGuard {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
*/
|
|
79
|
-
canActivate(): boolean | UrlTree {
|
|
80
|
-
if (this.auth.isAuthenticated()) {
|
|
81
|
-
return true;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return this.router.createUrlTree(['/login']);
|
|
85
|
-
}
|
|
50
|
+
export declare class AuthGuard {
|
|
51
|
+
private auth;
|
|
52
|
+
private router;
|
|
53
|
+
/**
|
|
54
|
+
* @param auth - Authentication service
|
|
55
|
+
* @param router - Angular router
|
|
56
|
+
*/
|
|
57
|
+
constructor(auth: AuthService, router: Router);
|
|
58
|
+
/**
|
|
59
|
+
* Check if route can be activated.
|
|
60
|
+
*
|
|
61
|
+
* @returns True if authenticated, otherwise redirects to login
|
|
62
|
+
*/
|
|
63
|
+
canActivate(): boolean | UrlTree;
|
|
86
64
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { HttpHandlerFn, HttpInterceptorFn, HttpRequest } from '@angular/common/http';
|
|
2
|
+
/**
|
|
3
|
+
* Angular HTTP interceptor for nauth-toolkit.
|
|
4
|
+
*
|
|
5
|
+
* Handles:
|
|
6
|
+
* - Cookies mode: withCredentials + CSRF tokens + refresh via POST
|
|
7
|
+
* - JSON mode: refresh via SDK, retry with new token
|
|
8
|
+
*/
|
|
9
|
+
export declare const authInterceptor: HttpInterceptorFn;
|
|
10
|
+
/**
|
|
11
|
+
* Class-based interceptor for NgModule compatibility.
|
|
12
|
+
*/
|
|
13
|
+
export declare class AuthInterceptor {
|
|
14
|
+
intercept(req: HttpRequest<unknown>, next: HttpHandlerFn): import("rxjs").Observable<import("@angular/common/http").HttpEvent<unknown>>;
|
|
15
|
+
}
|