@acontplus/ng-auth 1.0.0 → 1.0.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/index.d.ts CHANGED
@@ -1,21 +1,24 @@
1
1
  import { ITokenProvider } from '@acontplus/ng-infrastructure';
2
2
  export { ITokenProvider, TOKEN_PROVIDER } from '@acontplus/ng-infrastructure';
3
3
  import { CanActivateFn } from '@angular/router';
4
- import { AuthTokens } from '@acontplus/core';
4
+ import { AuthTokens, BaseEntity, UserData } from '@acontplus/core';
5
5
  import * as i0 from '@angular/core';
6
+ import { OnDestroy, OnInit, TemplateRef, Provider } from '@angular/core';
7
+ import { Observable } from 'rxjs';
8
+ import { AbstractControl, FormGroup } from '@angular/forms';
6
9
 
7
10
  declare const authGuard: CanActivateFn;
8
11
 
9
12
  declare class TokenRepository {
10
13
  private environment;
14
+ private platformId;
11
15
  saveTokens(tokens: AuthTokens, rememberMe?: boolean): void;
12
16
  getAccessToken(): string | null;
13
17
  getRefreshToken(): string | null;
14
18
  setToken(token: string, rememberMe?: boolean): void;
15
- setRefreshToken(refreshToken: string, rememberMe?: boolean): void;
19
+ setRefreshToken(_refreshToken: string, _rememberMe?: boolean): void;
16
20
  clearTokens(): void;
17
21
  isAuthenticated(): boolean;
18
- private isRefreshTokenValid;
19
22
  needsRefresh(): boolean;
20
23
  getTokenPayload(): any;
21
24
  static ɵfac: i0.ɵɵFactoryDeclaration<TokenRepository, never>;
@@ -31,4 +34,194 @@ declare class AuthTokenService implements ITokenProvider {
31
34
  static ɵprov: i0.ɵɵInjectableDeclaration<AuthTokenService>;
32
35
  }
33
36
 
34
- export { AuthTokenService, TokenRepository, authGuard };
37
+ declare class CsrfService {
38
+ private http;
39
+ private environment;
40
+ private csrfToken;
41
+ /**
42
+ * Get CSRF token, fetching it if not available
43
+ */
44
+ getCsrfToken(): Promise<string>;
45
+ /**
46
+ * Clear stored CSRF token (useful on logout)
47
+ */
48
+ clearCsrfToken(): void;
49
+ static ɵfac: i0.ɵɵFactoryDeclaration<CsrfService, never>;
50
+ static ɵprov: i0.ɵɵInjectableDeclaration<CsrfService>;
51
+ }
52
+
53
+ interface LoginRequest {
54
+ email: string;
55
+ password: string;
56
+ }
57
+ interface RegisterRequest {
58
+ email: string;
59
+ displayName: string;
60
+ password: string;
61
+ }
62
+ interface RefreshTokenRequest {
63
+ email: string;
64
+ refreshToken: string;
65
+ }
66
+ interface RegisterResponse {
67
+ id: string;
68
+ email: string;
69
+ displayName: string;
70
+ }
71
+ declare class User implements BaseEntity {
72
+ readonly id: number;
73
+ readonly email: string;
74
+ readonly displayName: string;
75
+ private _refreshToken?;
76
+ constructor(id: number, email: string, displayName: string, _refreshToken?: string | undefined);
77
+ get refreshToken(): string | undefined;
78
+ updateRefreshToken(token: string): void;
79
+ clearRefreshToken(): void;
80
+ static create(email: string, displayName: string, _password: string): User;
81
+ }
82
+
83
+ declare abstract class AuthRepository {
84
+ abstract login(request: LoginRequest): Observable<AuthTokens>;
85
+ abstract register(request: RegisterRequest): Observable<User>;
86
+ abstract refreshToken(request: RefreshTokenRequest): Observable<AuthTokens>;
87
+ abstract logout(email: string, refreshToken: string): Observable<void>;
88
+ }
89
+
90
+ declare class AuthHttpRepository extends AuthRepository {
91
+ private readonly http;
92
+ private readonly csrfService;
93
+ private readonly URL;
94
+ login(request: LoginRequest): Observable<AuthTokens>;
95
+ register(request: RegisterRequest): Observable<User>;
96
+ refreshToken(request: RefreshTokenRequest): Observable<AuthTokens>;
97
+ logout(email: string, refreshToken: string): Observable<void>;
98
+ static ɵfac: i0.ɵɵFactoryDeclaration<AuthHttpRepository, never>;
99
+ static ɵprov: i0.ɵɵInjectableDeclaration<AuthHttpRepository>;
100
+ }
101
+
102
+ declare class LoginUseCase {
103
+ private readonly authRepository;
104
+ private readonly authStore;
105
+ private readonly router;
106
+ execute(request: LoginRequest): Observable<AuthTokens>;
107
+ static ɵfac: i0.ɵɵFactoryDeclaration<LoginUseCase, never>;
108
+ static ɵprov: i0.ɵɵInjectableDeclaration<LoginUseCase>;
109
+ }
110
+
111
+ declare class RegisterUseCase {
112
+ private readonly authRepository;
113
+ private readonly router;
114
+ execute(request: RegisterRequest): Observable<User>;
115
+ static ɵfac: i0.ɵɵFactoryDeclaration<RegisterUseCase, never>;
116
+ static ɵprov: i0.ɵɵInjectableDeclaration<RegisterUseCase>;
117
+ }
118
+
119
+ declare class RefreshTokenUseCase {
120
+ private readonly authRepository;
121
+ private readonly userRepository;
122
+ private readonly tokenRepository;
123
+ private readonly authStore;
124
+ execute(): Observable<AuthTokens>;
125
+ static ɵfac: i0.ɵɵFactoryDeclaration<RefreshTokenUseCase, never>;
126
+ static ɵprov: i0.ɵɵInjectableDeclaration<RefreshTokenUseCase>;
127
+ }
128
+
129
+ declare class LogoutUseCase {
130
+ private readonly authRepository;
131
+ private readonly userRepository;
132
+ private readonly tokenRepository;
133
+ private readonly authStore;
134
+ execute(): Observable<void>;
135
+ private cleanup;
136
+ static ɵfac: i0.ɵɵFactoryDeclaration<LogoutUseCase, never>;
137
+ static ɵprov: i0.ɵɵInjectableDeclaration<LogoutUseCase>;
138
+ }
139
+
140
+ declare class AuthStore implements OnDestroy {
141
+ private readonly authRepository;
142
+ private readonly tokenRepository;
143
+ private readonly userRepository;
144
+ private readonly router;
145
+ private readonly _isAuthenticated;
146
+ private readonly _isLoading;
147
+ private readonly _user;
148
+ readonly isAuthenticated: i0.Signal<boolean>;
149
+ readonly isLoading: i0.Signal<boolean>;
150
+ readonly user: i0.Signal<UserData | null>;
151
+ private refreshTokenTimeout?;
152
+ private refreshInProgress$?;
153
+ constructor();
154
+ /**
155
+ * Initialize authentication state on app startup
156
+ */
157
+ private initializeAuthentication;
158
+ /**
159
+ * Schedule token refresh based on actual expiration time
160
+ */
161
+ private scheduleTokenRefresh;
162
+ /**
163
+ * Stop token refresh timer
164
+ */
165
+ private stopTokenRefreshTimer;
166
+ /**
167
+ * Refresh authentication tokens
168
+ */
169
+ refreshToken(): Observable<AuthTokens | null>;
170
+ /**
171
+ * Set authentication state after successful login
172
+ */
173
+ setAuthenticated(tokens: AuthTokens): void;
174
+ /**
175
+ * Logout user and clear all authentication data
176
+ */
177
+ logout(): void;
178
+ /**
179
+ * Perform client-side logout operations
180
+ */
181
+ private performClientLogout;
182
+ /**
183
+ * Check if user is authenticated
184
+ */
185
+ checkAuthentication(): boolean;
186
+ /**
187
+ * Decode JWT token
188
+ */
189
+ private decodeToken;
190
+ /**
191
+ * Cleanup on store destruction
192
+ */
193
+ ngOnDestroy(): void;
194
+ static ɵfac: i0.ɵɵFactoryDeclaration<AuthStore, never>;
195
+ static ɵprov: i0.ɵɵInjectableDeclaration<AuthStore>;
196
+ }
197
+
198
+ declare class LoginComponent implements OnInit {
199
+ title: i0.InputSignal<string>;
200
+ showRegisterButton: i0.InputSignal<boolean>;
201
+ additionalSigninControls: i0.InputSignal<Record<string, AbstractControl<any, any, any>>>;
202
+ additionalSignupControls: i0.InputSignal<Record<string, AbstractControl<any, any, any>>>;
203
+ additionalSigninFields: i0.InputSignal<TemplateRef<any> | null>;
204
+ additionalSignupFields: i0.InputSignal<TemplateRef<any> | null>;
205
+ footerContent: i0.InputSignal<TemplateRef<any> | null>;
206
+ hasFooterContent: i0.Signal<boolean>;
207
+ private readonly fb;
208
+ private readonly loginUseCase;
209
+ private readonly registerUseCase;
210
+ isLoginMode: i0.WritableSignal<boolean>;
211
+ isLoading: i0.WritableSignal<boolean>;
212
+ errorMessage: i0.WritableSignal<string | null>;
213
+ signinForm: FormGroup;
214
+ signupForm: FormGroup;
215
+ constructor();
216
+ ngOnInit(): void;
217
+ switchMode(): void;
218
+ signIn(): void;
219
+ registerUser(): void;
220
+ static ɵfac: i0.ɵɵFactoryDeclaration<LoginComponent, never>;
221
+ static ɵcmp: i0.ɵɵComponentDeclaration<LoginComponent, "acp-login", never, { "title": { "alias": "title"; "required": false; "isSignal": true; }; "showRegisterButton": { "alias": "showRegisterButton"; "required": false; "isSignal": true; }; "additionalSigninControls": { "alias": "additionalSigninControls"; "required": false; "isSignal": true; }; "additionalSignupControls": { "alias": "additionalSignupControls"; "required": false; "isSignal": true; }; "additionalSigninFields": { "alias": "additionalSigninFields"; "required": false; "isSignal": true; }; "additionalSignupFields": { "alias": "additionalSignupFields"; "required": false; "isSignal": true; }; "footerContent": { "alias": "footerContent"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
222
+ }
223
+
224
+ declare const authProviders: Provider[];
225
+
226
+ export { AuthHttpRepository, AuthRepository, AuthStore, AuthTokenService, CsrfService, LoginComponent, LoginUseCase, LogoutUseCase, RefreshTokenUseCase, RegisterUseCase, TokenRepository, User, authGuard, authProviders };
227
+ export type { LoginRequest, RefreshTokenRequest, RegisterRequest, RegisterResponse };
package/package.json CHANGED
@@ -1,17 +1,23 @@
1
1
  {
2
2
  "name": "@acontplus/ng-auth",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Acontplus Angular Authentication Module",
5
5
  "dependencies": {
6
- "@acontplus/ng-infrastructure": "^1.0.0",
7
- "@acontplus/ng-config": "^1.0.0",
6
+ "@acontplus/ng-infrastructure": "^1.0.1",
7
+ "@acontplus/ng-config": "^1.0.1",
8
+ "jwt-decode": "^4.0.0",
9
+ "rxjs": "^7.8.1",
8
10
  "tslib": "^2.3.0"
9
11
  },
10
12
  "peerDependencies": {
11
- "@acontplus/core": "^1.0.12",
13
+ "@acontplus/core": "^1.0.13",
12
14
  "@angular/common": "^20.3.2",
13
15
  "@angular/core": "^20.3.2",
14
- "@angular/router": "^20.3.2"
16
+ "@angular/router": "^20.3.2",
17
+ "@angular/forms": "^20.3.2",
18
+ "@angular/platform-browser": "^20.3.2",
19
+ "@angular/material": "^20.0.0",
20
+ "@angular/cdk": "^20.0.0"
15
21
  },
16
22
  "sideEffects": false,
17
23
  "main": "fesm2022/acontplus-ng-auth.mjs",
@@ -40,7 +46,7 @@
40
46
  "frontend",
41
47
  "library"
42
48
  ],
43
- "author": "Emilio Senguana <sengua2017@gmail.com>",
49
+ "author": "Ivan Paz <ifer343@gmail.com>",
44
50
  "license": "MIT",
45
51
  "bugs": {
46
52
  "url": "https://github.com/Acontplus-S-A-S/acontplus-libs/issues"