@rxap/authentication 19.1.0 → 21.0.1-dev.1

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.
Files changed (82) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/compodoc/changelog.html +18 -0
  3. package/compodoc/dependencies.html +6 -6
  4. package/compodoc/directives/SignOutDirective.html +80 -163
  5. package/compodoc/injectables/AuthenticationRoutingService.html +10 -70
  6. package/compodoc/injectables/RxapAuthenticationGuard.html +13 -124
  7. package/compodoc/js/search/search_index.js +2 -2
  8. package/compodoc/properties.html +1 -1
  9. package/docs/documentation.json +347 -542
  10. package/docs/html/assets/hierarchy.js +1 -1
  11. package/docs/html/assets/search.js +1 -1
  12. package/docs/html/classes/AuthenticationRoutingService.html +2 -2
  13. package/docs/html/classes/DisabledAuthenticationService.html +2 -2
  14. package/docs/html/classes/RegisterService.html +2 -2
  15. package/docs/html/classes/RxapAuthenticationGuard.html +2 -2
  16. package/docs/html/classes/RxapAuthenticationService.html +2 -2
  17. package/docs/html/classes/SignOutDirective.html +2 -2
  18. package/docs/html/enums/AuthenticationEventType.html +2 -2
  19. package/docs/html/functions/BearerTokenInterceptor.html +1 -1
  20. package/docs/html/functions/provideAuthentication.html +1 -1
  21. package/docs/html/functions/withDisabledAuthentication.html +1 -1
  22. package/docs/html/functions/withInitialAuthenticationState.html +1 -1
  23. package/docs/html/hierarchy.html +1 -1
  24. package/docs/html/index.html +2 -2
  25. package/docs/html/interfaces/AuthenticationAccessToken.html +2 -2
  26. package/docs/html/interfaces/AuthenticationEvent.html +2 -2
  27. package/docs/html/interfaces/IAuthenticationService.html +2 -2
  28. package/docs/html/modules.html +1 -1
  29. package/docs/html/variables/RXAP_AUTHENTICATION_ACCESS_TOKEN.html +1 -1
  30. package/docs/html/variables/RXAP_AUTHENTICATION_DEACTIVATED.html +1 -1
  31. package/docs/html/variables/RXAP_INITIAL_AUTHENTICATION_STATE.html +1 -1
  32. package/docs/markdown/README.md +1 -1
  33. package/docs/markdown/classes/AuthenticationRoutingService.md +4 -18
  34. package/docs/markdown/classes/DisabledAuthenticationService.md +6 -6
  35. package/docs/markdown/classes/RegisterService.md +4 -4
  36. package/docs/markdown/classes/RxapAuthenticationGuard.md +8 -24
  37. package/docs/markdown/classes/RxapAuthenticationService.md +7 -7
  38. package/docs/markdown/classes/SignOutDirective.md +8 -16
  39. package/docs/markdown/enumerations/AuthenticationEventType.md +5 -5
  40. package/docs/markdown/functions/BearerTokenInterceptor.md +2 -2
  41. package/docs/markdown/functions/provideAuthentication.md +2 -2
  42. package/docs/markdown/functions/withDisabledAuthentication.md +2 -2
  43. package/docs/markdown/functions/withInitialAuthenticationState.md +2 -2
  44. package/docs/markdown/globals.md +2 -2
  45. package/docs/markdown/interfaces/AuthenticationAccessToken.md +4 -4
  46. package/docs/markdown/interfaces/AuthenticationEvent.md +3 -3
  47. package/docs/markdown/interfaces/IAuthenticationService.md +6 -6
  48. package/docs/markdown/variables/RXAP_AUTHENTICATION_ACCESS_TOKEN.md +2 -2
  49. package/docs/markdown/variables/RXAP_AUTHENTICATION_DEACTIVATED.md +2 -2
  50. package/docs/markdown/variables/RXAP_INITIAL_AUTHENTICATION_STATE.md +2 -2
  51. package/docs/wiki/Class.AuthenticationRoutingService.md +3 -17
  52. package/docs/wiki/Class.DisabledAuthenticationService.md +5 -5
  53. package/docs/wiki/Class.RegisterService.md +3 -3
  54. package/docs/wiki/Class.RxapAuthenticationGuard.md +7 -23
  55. package/docs/wiki/Class.RxapAuthenticationService.md +6 -6
  56. package/docs/wiki/Class.SignOutDirective.md +7 -15
  57. package/docs/wiki/Enumeration.AuthenticationEventType.md +4 -4
  58. package/docs/wiki/Function.BearerTokenInterceptor.md +1 -1
  59. package/docs/wiki/Function.provideAuthentication.md +1 -1
  60. package/docs/wiki/Function.withDisabledAuthentication.md +1 -1
  61. package/docs/wiki/Function.withInitialAuthenticationState.md +1 -1
  62. package/docs/wiki/Interface.AuthenticationAccessToken.md +3 -3
  63. package/docs/wiki/Interface.AuthenticationEvent.md +2 -2
  64. package/docs/wiki/Interface.IAuthenticationService.md +5 -5
  65. package/docs/wiki/Variable.RXAP_AUTHENTICATION_ACCESS_TOKEN.md +1 -1
  66. package/docs/wiki/Variable.RXAP_AUTHENTICATION_DEACTIVATED.md +1 -1
  67. package/docs/wiki/Variable.RXAP_INITIAL_AUTHENTICATION_STATE.md +1 -1
  68. package/docs/wiki/globals.md +1 -1
  69. package/fesm2022/rxap-authentication.mjs +38 -64
  70. package/fesm2022/rxap-authentication.mjs.map +1 -1
  71. package/package.json +16 -15
  72. package/types/rxap-authentication.d.ts +96 -0
  73. package/index.d.ts +0 -9
  74. package/lib/authentication-routing.service.d.ts +0 -11
  75. package/lib/authentication.guard.d.ts +0 -16
  76. package/lib/authentication.service.d.ts +0 -26
  77. package/lib/bearer-token.interceptor.d.ts +0 -3
  78. package/lib/disabled-authentication.service.d.ts +0 -10
  79. package/lib/provide.d.ts +0 -5
  80. package/lib/register.service.d.ts +0 -7
  81. package/lib/sign-out.directive.d.ts +0 -12
  82. package/lib/tokens.d.ts +0 -10
@@ -1,6 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, inject, Injectable, Inject, Optional, EventEmitter, Directive, Output, HostListener } from '@angular/core';
3
- import * as i1 from '@angular/router';
2
+ import { InjectionToken, inject, Injectable, output, Directive } from '@angular/core';
4
3
  import { Router } from '@angular/router';
5
4
  import { BehaviorSubject, ReplaySubject, take, switchMap, of, EMPTY } from 'rxjs';
6
5
  import { tap } from 'rxjs/operators';
@@ -42,19 +41,20 @@ class RxapAuthenticationService {
42
41
  isAuthenticated() {
43
42
  return Promise.resolve(this._authenticated);
44
43
  }
45
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: RxapAuthenticationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
46
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: RxapAuthenticationService, providedIn: 'root' }); }
44
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RxapAuthenticationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
45
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RxapAuthenticationService, providedIn: 'root' }); }
47
46
  }
48
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: RxapAuthenticationService, decorators: [{
47
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RxapAuthenticationService, decorators: [{
49
48
  type: Injectable,
50
49
  args: [{ providedIn: 'root' }]
51
50
  }], ctorParameters: () => [] });
52
51
 
53
52
  class AuthenticationRoutingService {
54
- constructor(router, authenticationService, deactivated = null) {
55
- this.router = router;
56
- this.authenticationService = authenticationService;
57
- this.deactivated = deactivated;
53
+ constructor() {
54
+ this.router = inject(Router);
55
+ this.authenticationService = inject(RxapAuthenticationService);
56
+ this.deactivated = inject(RXAP_AUTHENTICATION_DEACTIVATED, { optional: true }) ?? null;
57
+ const deactivated = this.deactivated;
58
58
  if (!deactivated) {
59
59
  console.log('Authentication is enabled');
60
60
  this.authenticationService.isAuthenticated$.pipe(tap(isAuthenticated => {
@@ -67,32 +67,21 @@ class AuthenticationRoutingService {
67
67
  })).subscribe();
68
68
  }
69
69
  }
70
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: AuthenticationRoutingService, deps: [{ token: Router }, { token: RxapAuthenticationService }, { token: RXAP_AUTHENTICATION_DEACTIVATED, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
71
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: AuthenticationRoutingService, providedIn: 'root' }); }
70
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AuthenticationRoutingService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
71
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AuthenticationRoutingService, providedIn: 'root' }); }
72
72
  }
73
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: AuthenticationRoutingService, decorators: [{
73
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AuthenticationRoutingService, decorators: [{
74
74
  type: Injectable,
75
75
  args: [{
76
76
  providedIn: 'root',
77
77
  }]
78
- }], ctorParameters: () => [{ type: i1.Router, decorators: [{
79
- type: Inject,
80
- args: [Router]
81
- }] }, { type: RxapAuthenticationService, decorators: [{
82
- type: Inject,
83
- args: [RxapAuthenticationService]
84
- }] }, { type: undefined, decorators: [{
85
- type: Optional
86
- }, {
87
- type: Inject,
88
- args: [RXAP_AUTHENTICATION_DEACTIVATED]
89
- }] }] });
78
+ }], ctorParameters: () => [] });
90
79
 
91
80
  class RxapAuthenticationGuard {
92
- constructor(authentication, router, deactivated = null) {
93
- this.authentication = authentication;
94
- this.router = router;
95
- this.deactivated = deactivated;
81
+ constructor() {
82
+ this.authentication = inject(RxapAuthenticationService);
83
+ this.router = inject(Router);
84
+ this.deactivated = inject(RXAP_AUTHENTICATION_DEACTIVATED, { optional: true }) ?? null;
96
85
  this.lastUrl = null;
97
86
  }
98
87
  canActivate(route, state) {
@@ -172,24 +161,13 @@ class RxapAuthenticationGuard {
172
161
  }
173
162
  return this.router.createUrlTree([lastUrl]);
174
163
  }
175
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: RxapAuthenticationGuard, deps: [{ token: RxapAuthenticationService }, { token: Router }, { token: RXAP_AUTHENTICATION_DEACTIVATED, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
176
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: RxapAuthenticationGuard, providedIn: 'root' }); }
164
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RxapAuthenticationGuard, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
165
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RxapAuthenticationGuard, providedIn: 'root' }); }
177
166
  }
178
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: RxapAuthenticationGuard, decorators: [{
167
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RxapAuthenticationGuard, decorators: [{
179
168
  type: Injectable,
180
169
  args: [{ providedIn: 'root' }]
181
- }], ctorParameters: () => [{ type: RxapAuthenticationService, decorators: [{
182
- type: Inject,
183
- args: [RxapAuthenticationService]
184
- }] }, { type: i1.Router, decorators: [{
185
- type: Inject,
186
- args: [Router]
187
- }] }, { type: undefined, decorators: [{
188
- type: Optional
189
- }, {
190
- type: Inject,
191
- args: [RXAP_AUTHENTICATION_DEACTIVATED]
192
- }] }] });
170
+ }] });
193
171
 
194
172
  function BearerTokenInterceptor(req, next) {
195
173
  const accessToken$ = inject(RXAP_AUTHENTICATION_ACCESS_TOKEN);
@@ -226,10 +204,10 @@ class DisabledAuthenticationService {
226
204
  async isAuthenticated() {
227
205
  return true;
228
206
  }
229
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: DisabledAuthenticationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
230
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: DisabledAuthenticationService }); }
207
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DisabledAuthenticationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
208
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DisabledAuthenticationService }); }
231
209
  }
232
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: DisabledAuthenticationService, decorators: [{
210
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DisabledAuthenticationService, decorators: [{
233
211
  type: Injectable
234
212
  }] });
235
213
 
@@ -257,19 +235,19 @@ class RegisterService {
257
235
  register(email, password) {
258
236
  return Promise.resolve(true);
259
237
  }
260
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: RegisterService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
261
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: RegisterService, providedIn: 'root' }); }
238
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RegisterService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
239
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RegisterService, providedIn: 'root' }); }
262
240
  }
263
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: RegisterService, decorators: [{
241
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RegisterService, decorators: [{
264
242
  type: Injectable,
265
243
  args: [{ providedIn: 'root' }]
266
244
  }], ctorParameters: () => [] });
267
245
 
268
246
  class SignOutDirective {
269
- constructor(auth) {
270
- this.auth = auth;
271
- this.successful = new EventEmitter();
272
- this.failure = new EventEmitter();
247
+ constructor() {
248
+ this.auth = inject(RxapAuthenticationService);
249
+ this.successful = output();
250
+ this.failure = output();
273
251
  }
274
252
  async onClick() {
275
253
  try {
@@ -280,23 +258,19 @@ class SignOutDirective {
280
258
  this.failure.emit(e);
281
259
  }
282
260
  }
283
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: SignOutDirective, deps: [{ token: RxapAuthenticationService }], target: i0.ɵɵFactoryTarget.Directive }); }
284
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.16", type: SignOutDirective, isStandalone: true, selector: "[rxapSignOut]", outputs: { successful: "successful", failure: "failure" }, host: { listeners: { "click": "onClick()" } }, ngImport: i0 }); }
261
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: SignOutDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
262
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.9", type: SignOutDirective, isStandalone: true, selector: "[rxapSignOut]", outputs: { successful: "successful", failure: "failure" }, host: { listeners: { "click": "onClick()" } }, ngImport: i0 }); }
285
263
  }
286
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: SignOutDirective, decorators: [{
264
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: SignOutDirective, decorators: [{
287
265
  type: Directive,
288
266
  args: [{
289
267
  selector: '[rxapSignOut]',
290
268
  standalone: true,
269
+ host: {
270
+ '(click)': 'onClick()',
271
+ },
291
272
  }]
292
- }], ctorParameters: () => [{ type: RxapAuthenticationService }], propDecorators: { successful: [{
293
- type: Output
294
- }], failure: [{
295
- type: Output
296
- }], onClick: [{
297
- type: HostListener,
298
- args: ['click']
299
- }] } });
273
+ }], propDecorators: { successful: [{ type: i0.Output, args: ["successful"] }], failure: [{ type: i0.Output, args: ["failure"] }] } });
300
274
 
301
275
  // region
302
276
  // endregion
@@ -1 +1 @@
1
- {"version":3,"file":"rxap-authentication.mjs","sources":["../../../../../packages/angular/authentication/src/lib/tokens.ts","../../../../../packages/angular/authentication/src/lib/authentication.service.ts","../../../../../packages/angular/authentication/src/lib/authentication-routing.service.ts","../../../../../packages/angular/authentication/src/lib/authentication.guard.ts","../../../../../packages/angular/authentication/src/lib/bearer-token.interceptor.ts","../../../../../packages/angular/authentication/src/lib/disabled-authentication.service.ts","../../../../../packages/angular/authentication/src/lib/provide.ts","../../../../../packages/angular/authentication/src/lib/register.service.ts","../../../../../packages/angular/authentication/src/lib/sign-out.directive.ts","../../../../../packages/angular/authentication/src/index.ts","../../../../../packages/angular/authentication/src/rxap-authentication.ts"],"sourcesContent":["import {\n InjectionToken,\n Provider,\n} from '@angular/core';\nimport { BehaviorSubject } from 'rxjs';\n\nexport const RXAP_AUTHENTICATION_DEACTIVATED = new InjectionToken<boolean>('rxap/authentication/deactivated');\n\nexport interface AuthenticationAccessToken extends Record<string, any> {\n token: string;\n valid?: boolean;\n}\n\nexport const RXAP_AUTHENTICATION_ACCESS_TOKEN = new InjectionToken<BehaviorSubject<AuthenticationAccessToken | null>>(\n 'rxap/authentication/access-token',\n {\n providedIn: 'root',\n factory: () => new BehaviorSubject<AuthenticationAccessToken | null>(null),\n },\n);\n\nexport const RXAP_INITIAL_AUTHENTICATION_STATE = new InjectionToken<boolean>('rxap/authentication/initial-state', {\n providedIn: 'root',\n factory: () => false,\n});\n\nexport function withDisabledAuthentication(disabled = true): Provider {\n return {\n provide: RXAP_AUTHENTICATION_DEACTIVATED,\n useValue: disabled,\n };\n}\n","import {\n inject,\n Injectable,\n} from '@angular/core';\nimport {\n BehaviorSubject,\n Observable,\n ReplaySubject,\n} from 'rxjs';\nimport { RXAP_INITIAL_AUTHENTICATION_STATE } from './tokens';\n\nexport interface IAuthenticationService {\n isAuthenticated$: Observable<boolean | null>;\n events$: Observable<AuthenticationEvent>;\n signOut(): Promise<void>;\n\n isAuthenticated(): Promise<boolean>;\n}\n\nexport enum AuthenticationEventType {\n OnAuthSuccess = 'on-auth-success',\n OnAuthError = 'on-auth-error',\n OnLogout = 'on-logout',\n}\n\nexport interface AuthenticationEvent extends Record<string, any> {\n type: AuthenticationEventType;\n}\n\n@Injectable({ providedIn: 'root' })\nexport class RxapAuthenticationService implements IAuthenticationService {\n\n public isAuthenticated$ = new BehaviorSubject<boolean | null>(null);\n\n public readonly events$ = new ReplaySubject<AuthenticationEvent>();\n\n private _authenticated = inject(RXAP_INITIAL_AUTHENTICATION_STATE);\n\n constructor() {\n this.isAuthenticated().then(isAuthenticated => this.isAuthenticated$.next(isAuthenticated));\n }\n\n public async signOut(): Promise<void> {\n this._authenticated = false;\n this.isAuthenticated$.next(this._authenticated);\n this.events$.next({ type: AuthenticationEventType.OnLogout });\n }\n\n public isAuthenticated(): Promise<boolean> {\n return Promise.resolve(this._authenticated);\n }\n\n}\n","import {\n Inject,\n Injectable,\n Optional,\n} from '@angular/core';\nimport { Router } from '@angular/router';\nimport { RxapAuthenticationService } from './authentication.service';\nimport { RXAP_AUTHENTICATION_DEACTIVATED } from './tokens';\nimport { tap } from 'rxjs/operators';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AuthenticationRoutingService {\n\n constructor(\n @Inject(Router)\n private readonly router: Router,\n @Inject(RxapAuthenticationService)\n private readonly authenticationService: RxapAuthenticationService,\n @Optional()\n @Inject(RXAP_AUTHENTICATION_DEACTIVATED)\n private readonly deactivated: boolean | null = null,\n ) {\n if (!deactivated) {\n console.log('Authentication is enabled');\n this.authenticationService.isAuthenticated$.pipe(\n tap(isAuthenticated => {\n if (isAuthenticated) {\n return this.router.navigate([ '/' ]);\n } else {\n return this.router.navigate([ '/', 'authentication', 'login' ]);\n }\n }),\n ).subscribe();\n }\n }\n\n}\n","import {\n Inject,\n Injectable,\n Optional,\n} from '@angular/core';\nimport {\n ActivatedRouteSnapshot,\n Router,\n RouterStateSnapshot,\n UrlTree,\n} from '@angular/router';\nimport { RxapAuthenticationService } from './authentication.service';\nimport { RXAP_AUTHENTICATION_DEACTIVATED } from './tokens';\n\n@Injectable({ providedIn: 'root' })\nexport class RxapAuthenticationGuard {\n\n public lastUrl: string | null = null;\n\n constructor(\n @Inject(RxapAuthenticationService)\n public authentication: RxapAuthenticationService,\n @Inject(Router)\n public router: Router,\n @Optional()\n @Inject(RXAP_AUTHENTICATION_DEACTIVATED)\n private readonly deactivated: boolean | null = null,\n ) {\n }\n\n public canActivate(\n route: ActivatedRouteSnapshot,\n state: RouterStateSnapshot,\n ): Promise<UrlTree | boolean> {\n console.debug('[RxapAuthenticationGuard] can activate', state.url);\n return this.checkAuthStatus(route, state);\n }\n\n public canActivateChild(\n childRoute: ActivatedRouteSnapshot,\n state: RouterStateSnapshot,\n ): Promise<UrlTree | boolean> {\n console.debug('[RxapAuthenticationGuard] can activate child', state.url);\n return this.checkAuthStatus(childRoute, state);\n }\n\n private async checkAuthStatus(\n route: ActivatedRouteSnapshot,\n state: RouterStateSnapshot,\n ): Promise<UrlTree | boolean> {\n\n if (this.deactivated) {\n return true;\n }\n\n const authenticated = await this.authentication.isAuthenticated();\n\n if (authenticated === null) {\n if (!this.lastUrl || (state.url !== '/' && !state.url.match(/authentication\\/login/))) {\n this.lastUrl = state.url;\n }\n return this.router.createUrlTree([ '/', 'authentication', 'loading' ]);\n }\n if (authenticated) {\n if (this.lastUrl && (state.url/*?*/ === '/' || state.url.match(/authentication\\/login/))) {\n const lastUrl = this.lastUrl;\n this.lastUrl = null;\n return this.createUrlTreeToLastUrl(lastUrl);\n } else {\n if (state.url.match(/authentication/)) {\n if (state.url.match(/authentication\\/reset-password/)) {\n return true;\n }\n return this.router.createUrlTree([ '/' ]);\n } else {\n this.lastUrl = null;\n return true;\n }\n }\n } else {\n if (!state.url.match(/^\\/?authentication/)) {\n this.lastUrl = state.url;\n }\n if (state.url.match(/^\\/?authentication/)) {\n if (this.lastUrl && this.lastUrl.match(/^\\/?authentication/)) {\n const lastUrl = this.lastUrl;\n this.lastUrl = null;\n return this.createUrlTreeToLastUrl(lastUrl);\n }\n return true;\n } else {\n return this.router.createUrlTree([ '/', 'authentication', 'login' ]);\n }\n }\n\n }\n\n private createUrlTreeToLastUrl(lastUrl: string): UrlTree {\n\n const urlMatch = lastUrl.match(/^([^?#]+)(\\?([^#]+))?(#(.+))?$/);\n\n if (urlMatch) {\n\n let queryParams: Record<string, string> = {};\n\n if (urlMatch[3]) {\n const queryParamsString = urlMatch[3];\n queryParams = queryParamsString.split('&').map(param => {\n const split = param.split('=');\n return { [split[0]]: split[1] };\n }).reduce((params, param) => ({ ...params, ...param }), {});\n }\n\n let fragment: string | undefined = undefined;\n\n if (urlMatch[5]) {\n fragment = urlMatch[5];\n }\n\n return this.router.createUrlTree([ urlMatch[1] ], {\n queryParams,\n fragment,\n });\n\n }\n\n return this.router.createUrlTree([ lastUrl ]);\n\n }\n\n}\n","import { HttpEvent, HttpHandlerFn, HttpRequest } from '@angular/common/http';\nimport { inject } from '@angular/core';\nimport {\n Observable,\n switchMap,\n take,\n} from 'rxjs';\nimport { RXAP_AUTHENTICATION_ACCESS_TOKEN } from './tokens';\n\nexport function BearerTokenInterceptor(req: HttpRequest<unknown>, next: HttpHandlerFn): Observable<HttpEvent<unknown>> {\n\n const accessToken$ = inject(RXAP_AUTHENTICATION_ACCESS_TOKEN);\n\n if (req.url.match(/https?:\\/\\/[^/]+\\/api/)) {\n return accessToken$.pipe(\n take(1),\n switchMap(accessToken => {\n if (accessToken && (accessToken.valid === undefined || accessToken.valid)) {\n console.debug('Add access token to request', req.url);\n return next(req.clone({\n setHeaders: {\n Authorization: `Bearer ${ accessToken.token }`,\n },\n }));\n } else {\n console.debug('No valid access token found!', req.url);\n }\n return next(req);\n }),\n );\n } else {\n console.debug('Skip adding access token to request', req.url);\n }\n\n return next(req);\n\n}\n","import { Injectable } from '@angular/core';\nimport {\n EMPTY,\n of,\n} from 'rxjs';\nimport { IAuthenticationService } from './authentication.service';\n\n@Injectable()\nexport class DisabledAuthenticationService implements IAuthenticationService {\n\n public readonly isAuthenticated$ = of(true);\n public readonly events$ = EMPTY;\n\n async signOut() {\n console.log('Authentication is disabled. No sign out possible');\n }\n\n async isAuthenticated() {\n return true;\n }\n\n}\n","import { Provider } from '@angular/core';\nimport { RXAP_INITIAL_AUTHENTICATION_STATE } from './tokens';\nimport {\n IAuthenticationService,\n RxapAuthenticationService,\n} from './authentication.service';\nimport { Constructor } from '@rxap/utilities';\n\nexport function provideAuthentication(\n service: Constructor<IAuthenticationService>,\n ...additionalProviders: Provider[]\n): Provider[] {\n return [\n {\n provide: RxapAuthenticationService,\n useClass: service,\n },\n ...additionalProviders,\n ];\n}\n\nexport function withInitialAuthenticationState(\n state: boolean\n): Provider {\n return {\n provide: RXAP_INITIAL_AUTHENTICATION_STATE,\n useValue: state,\n };\n}\n","import { Injectable } from '@angular/core';\n\n@Injectable({ providedIn: 'root' })\n/* ignore coverage */\nexport class RegisterService {\n\n constructor() {\n console.warn('The default RegisterService implementation should only be used in a development environment!');\n }\n\n public register(email: string, password: string): Promise<boolean> {\n return Promise.resolve(true);\n }\n\n}\n","import {\n Directive,\n EventEmitter,\n HostListener,\n Output,\n} from '@angular/core';\nimport { RxapAuthenticationService } from './authentication.service';\n\n@Directive({\n selector: '[rxapSignOut]',\n standalone: true,\n})\nexport class SignOutDirective {\n\n @Output()\n public successful = new EventEmitter<void>();\n\n @Output()\n public failure = new EventEmitter<Error>();\n\n constructor(private readonly auth: RxapAuthenticationService) {\n }\n\n @HostListener('click')\n public async onClick() {\n try {\n await this.auth.signOut();\n this.successful.emit();\n } catch (e: any) {\n this.failure.emit(e);\n }\n }\n\n}\n\n\n","// region \nexport * from './lib/authentication-routing.service';\nexport * from './lib/authentication.guard';\nexport * from './lib/authentication.service';\nexport * from './lib/bearer-token.interceptor';\nexport * from './lib/disabled-authentication.service';\nexport * from './lib/provide';\nexport * from './lib/register.service';\nexport * from './lib/sign-out.directive';\nexport * from './lib/tokens';\n// endregion\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i1.RxapAuthenticationService"],"mappings":";;;;;;;MAMa,+BAA+B,GAAG,IAAI,cAAc,CAAU,iCAAiC;MAO/F,gCAAgC,GAAG,IAAI,cAAc,CAChE,kCAAkC,EAClC;AACE,IAAA,UAAU,EAAE,MAAM;IAClB,OAAO,EAAE,MAAM,IAAI,eAAe,CAAmC,IAAI,CAAC;AAC3E,CAAA;MAGU,iCAAiC,GAAG,IAAI,cAAc,CAAU,mCAAmC,EAAE;AAChH,IAAA,UAAU,EAAE,MAAM;AAClB,IAAA,OAAO,EAAE,MAAM,KAAK;AACrB,CAAA;AAEe,SAAA,0BAA0B,CAAC,QAAQ,GAAG,IAAI,EAAA;IACxD,OAAO;AACL,QAAA,OAAO,EAAE,+BAA+B;AACxC,QAAA,QAAQ,EAAE,QAAQ;KACnB;AACH;;ICZY;AAAZ,CAAA,UAAY,uBAAuB,EAAA;AACjC,IAAA,uBAAA,CAAA,eAAA,CAAA,GAAA,iBAAiC;AACjC,IAAA,uBAAA,CAAA,aAAA,CAAA,GAAA,eAA6B;AAC7B,IAAA,uBAAA,CAAA,UAAA,CAAA,GAAA,WAAsB;AACxB,CAAC,EAJW,uBAAuB,KAAvB,uBAAuB,GAIlC,EAAA,CAAA,CAAA;MAOY,yBAAyB,CAAA;AAQpC,IAAA,WAAA,GAAA;AANO,QAAA,IAAA,CAAA,gBAAgB,GAAG,IAAI,eAAe,CAAiB,IAAI,CAAC;AAEnD,QAAA,IAAA,CAAA,OAAO,GAAG,IAAI,aAAa,EAAuB;AAE1D,QAAA,IAAA,CAAA,cAAc,GAAG,MAAM,CAAC,iCAAiC,CAAC;AAGhE,QAAA,IAAI,CAAC,eAAe,EAAE,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1
+ {"version":3,"file":"rxap-authentication.mjs","sources":["../../../../../packages/angular/authentication/src/lib/tokens.ts","../../../../../packages/angular/authentication/src/lib/authentication.service.ts","../../../../../packages/angular/authentication/src/lib/authentication-routing.service.ts","../../../../../packages/angular/authentication/src/lib/authentication.guard.ts","../../../../../packages/angular/authentication/src/lib/bearer-token.interceptor.ts","../../../../../packages/angular/authentication/src/lib/disabled-authentication.service.ts","../../../../../packages/angular/authentication/src/lib/provide.ts","../../../../../packages/angular/authentication/src/lib/register.service.ts","../../../../../packages/angular/authentication/src/lib/sign-out.directive.ts","../../../../../packages/angular/authentication/src/index.ts","../../../../../packages/angular/authentication/src/rxap-authentication.ts"],"sourcesContent":["import {\n InjectionToken,\n Provider,\n} from '@angular/core';\nimport { BehaviorSubject } from 'rxjs';\n\nexport const RXAP_AUTHENTICATION_DEACTIVATED = new InjectionToken<boolean>('rxap/authentication/deactivated');\n\nexport interface AuthenticationAccessToken extends Record<string, any> {\n token: string;\n valid?: boolean;\n}\n\nexport const RXAP_AUTHENTICATION_ACCESS_TOKEN = new InjectionToken<BehaviorSubject<AuthenticationAccessToken | null>>(\n 'rxap/authentication/access-token',\n {\n providedIn: 'root',\n factory: () => new BehaviorSubject<AuthenticationAccessToken | null>(null),\n },\n);\n\nexport const RXAP_INITIAL_AUTHENTICATION_STATE = new InjectionToken<boolean>('rxap/authentication/initial-state', {\n providedIn: 'root',\n factory: () => false,\n});\n\nexport function withDisabledAuthentication(disabled = true): Provider {\n return {\n provide: RXAP_AUTHENTICATION_DEACTIVATED,\n useValue: disabled,\n };\n}\n","import {\n inject,\n Injectable,\n} from '@angular/core';\nimport {\n BehaviorSubject,\n Observable,\n ReplaySubject,\n} from 'rxjs';\nimport { RXAP_INITIAL_AUTHENTICATION_STATE } from './tokens';\n\nexport interface IAuthenticationService {\n isAuthenticated$: Observable<boolean | null>;\n events$: Observable<AuthenticationEvent>;\n signOut(): Promise<void>;\n\n isAuthenticated(): Promise<boolean>;\n}\n\nexport enum AuthenticationEventType {\n OnAuthSuccess = 'on-auth-success',\n OnAuthError = 'on-auth-error',\n OnLogout = 'on-logout',\n}\n\nexport interface AuthenticationEvent extends Record<string, any> {\n type: AuthenticationEventType;\n}\n\n@Injectable({ providedIn: 'root' })\nexport class RxapAuthenticationService implements IAuthenticationService {\n\n public isAuthenticated$ = new BehaviorSubject<boolean | null>(null);\n\n public readonly events$ = new ReplaySubject<AuthenticationEvent>();\n\n private _authenticated = inject(RXAP_INITIAL_AUTHENTICATION_STATE);\n\n constructor() {\n this.isAuthenticated().then(isAuthenticated => this.isAuthenticated$.next(isAuthenticated));\n }\n\n public async signOut(): Promise<void> {\n this._authenticated = false;\n this.isAuthenticated$.next(this._authenticated);\n this.events$.next({ type: AuthenticationEventType.OnLogout });\n }\n\n public isAuthenticated(): Promise<boolean> {\n return Promise.resolve(this._authenticated);\n }\n\n}\n","import { Injectable, inject } from '@angular/core';\nimport { Router } from '@angular/router';\nimport { RxapAuthenticationService } from './authentication.service';\nimport { RXAP_AUTHENTICATION_DEACTIVATED } from './tokens';\nimport { tap } from 'rxjs/operators';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AuthenticationRoutingService {\n private readonly router = inject<Router>(Router);\n private readonly authenticationService = inject<RxapAuthenticationService>(RxapAuthenticationService);\n private readonly deactivated = inject(RXAP_AUTHENTICATION_DEACTIVATED, { optional: true }) ?? null;\n\n\n constructor() {\n const deactivated = this.deactivated;\n\n if (!deactivated) {\n console.log('Authentication is enabled');\n this.authenticationService.isAuthenticated$.pipe(\n tap(isAuthenticated => {\n if (isAuthenticated) {\n return this.router.navigate([ '/' ]);\n } else {\n return this.router.navigate([ '/', 'authentication', 'login' ]);\n }\n }),\n ).subscribe();\n }\n }\n\n}\n","import { Injectable, inject } from '@angular/core';\nimport {\n ActivatedRouteSnapshot,\n Router,\n RouterStateSnapshot,\n UrlTree,\n} from '@angular/router';\nimport { RxapAuthenticationService } from './authentication.service';\nimport { RXAP_AUTHENTICATION_DEACTIVATED } from './tokens';\n\n@Injectable({ providedIn: 'root' })\nexport class RxapAuthenticationGuard {\n authentication = inject<RxapAuthenticationService>(RxapAuthenticationService);\n router = inject<Router>(Router);\n private readonly deactivated = inject(RXAP_AUTHENTICATION_DEACTIVATED, { optional: true }) ?? null;\n\n\n public lastUrl: string | null = null;\n\n public canActivate(\n route: ActivatedRouteSnapshot,\n state: RouterStateSnapshot,\n ): Promise<UrlTree | boolean> {\n console.debug('[RxapAuthenticationGuard] can activate', state.url);\n return this.checkAuthStatus(route, state);\n }\n\n public canActivateChild(\n childRoute: ActivatedRouteSnapshot,\n state: RouterStateSnapshot,\n ): Promise<UrlTree | boolean> {\n console.debug('[RxapAuthenticationGuard] can activate child', state.url);\n return this.checkAuthStatus(childRoute, state);\n }\n\n private async checkAuthStatus(\n route: ActivatedRouteSnapshot,\n state: RouterStateSnapshot,\n ): Promise<UrlTree | boolean> {\n\n if (this.deactivated) {\n return true;\n }\n\n const authenticated = await this.authentication.isAuthenticated();\n\n if (authenticated === null) {\n if (!this.lastUrl || (state.url !== '/' && !state.url.match(/authentication\\/login/))) {\n this.lastUrl = state.url;\n }\n return this.router.createUrlTree([ '/', 'authentication', 'loading' ]);\n }\n if (authenticated) {\n if (this.lastUrl && (state.url/*?*/ === '/' || state.url.match(/authentication\\/login/))) {\n const lastUrl = this.lastUrl;\n this.lastUrl = null;\n return this.createUrlTreeToLastUrl(lastUrl);\n } else {\n if (state.url.match(/authentication/)) {\n if (state.url.match(/authentication\\/reset-password/)) {\n return true;\n }\n return this.router.createUrlTree([ '/' ]);\n } else {\n this.lastUrl = null;\n return true;\n }\n }\n } else {\n if (!state.url.match(/^\\/?authentication/)) {\n this.lastUrl = state.url;\n }\n if (state.url.match(/^\\/?authentication/)) {\n if (this.lastUrl && this.lastUrl.match(/^\\/?authentication/)) {\n const lastUrl = this.lastUrl;\n this.lastUrl = null;\n return this.createUrlTreeToLastUrl(lastUrl);\n }\n return true;\n } else {\n return this.router.createUrlTree([ '/', 'authentication', 'login' ]);\n }\n }\n\n }\n\n private createUrlTreeToLastUrl(lastUrl: string): UrlTree {\n\n const urlMatch = lastUrl.match(/^([^?#]+)(\\?([^#]+))?(#(.+))?$/);\n\n if (urlMatch) {\n\n let queryParams: Record<string, string> = {};\n\n if (urlMatch[3]) {\n const queryParamsString = urlMatch[3];\n queryParams = queryParamsString.split('&').map(param => {\n const split = param.split('=');\n return { [split[0]]: split[1] };\n }).reduce((params, param) => ({ ...params, ...param }), {});\n }\n\n let fragment: string | undefined = undefined;\n\n if (urlMatch[5]) {\n fragment = urlMatch[5];\n }\n\n return this.router.createUrlTree([ urlMatch[1] ], {\n queryParams,\n fragment,\n });\n\n }\n\n return this.router.createUrlTree([ lastUrl ]);\n\n }\n\n}\n","import { HttpEvent, HttpHandlerFn, HttpRequest } from '@angular/common/http';\nimport { inject } from '@angular/core';\nimport {\n Observable,\n switchMap,\n take,\n} from 'rxjs';\nimport { RXAP_AUTHENTICATION_ACCESS_TOKEN } from './tokens';\n\nexport function BearerTokenInterceptor(req: HttpRequest<unknown>, next: HttpHandlerFn): Observable<HttpEvent<unknown>> {\n\n const accessToken$ = inject(RXAP_AUTHENTICATION_ACCESS_TOKEN);\n\n if (req.url.match(/https?:\\/\\/[^/]+\\/api/)) {\n return accessToken$.pipe(\n take(1),\n switchMap(accessToken => {\n if (accessToken && (accessToken.valid === undefined || accessToken.valid)) {\n console.debug('Add access token to request', req.url);\n return next(req.clone({\n setHeaders: {\n Authorization: `Bearer ${ accessToken.token }`,\n },\n }));\n } else {\n console.debug('No valid access token found!', req.url);\n }\n return next(req);\n }),\n );\n } else {\n console.debug('Skip adding access token to request', req.url);\n }\n\n return next(req);\n\n}\n","import { Injectable } from '@angular/core';\nimport {\n EMPTY,\n of,\n} from 'rxjs';\nimport { IAuthenticationService } from './authentication.service';\n\n@Injectable()\nexport class DisabledAuthenticationService implements IAuthenticationService {\n\n public readonly isAuthenticated$ = of(true);\n public readonly events$ = EMPTY;\n\n async signOut() {\n console.log('Authentication is disabled. No sign out possible');\n }\n\n async isAuthenticated() {\n return true;\n }\n\n}\n","import { Provider } from '@angular/core';\nimport { RXAP_INITIAL_AUTHENTICATION_STATE } from './tokens';\nimport {\n IAuthenticationService,\n RxapAuthenticationService,\n} from './authentication.service';\nimport { Constructor } from '@rxap/utilities';\n\nexport function provideAuthentication(\n service: Constructor<IAuthenticationService>,\n ...additionalProviders: Provider[]\n): Provider[] {\n return [\n {\n provide: RxapAuthenticationService,\n useClass: service,\n },\n ...additionalProviders,\n ];\n}\n\nexport function withInitialAuthenticationState(\n state: boolean\n): Provider {\n return {\n provide: RXAP_INITIAL_AUTHENTICATION_STATE,\n useValue: state,\n };\n}\n","import { Injectable } from '@angular/core';\n\n@Injectable({ providedIn: 'root' })\n/* ignore coverage */\nexport class RegisterService {\n\n constructor() {\n console.warn('The default RegisterService implementation should only be used in a development environment!');\n }\n\n public register(email: string, password: string): Promise<boolean> {\n return Promise.resolve(true);\n }\n\n}\n","import { Directive, output, inject } from '@angular/core';\nimport { RxapAuthenticationService } from './authentication.service';\n\n@Directive({\n selector: '[rxapSignOut]',\n standalone: true,\n host: {\n '(click)': 'onClick()',\n },\n})\nexport class SignOutDirective {\n private readonly auth = inject(RxapAuthenticationService);\n\n\n public readonly successful = output<void>();\n\n public readonly failure = output<Error>();\n\n public async onClick() {\n try {\n await this.auth.signOut();\n this.successful.emit();\n } catch (e: any) {\n this.failure.emit(e);\n }\n }\n\n}\n\n\n","// region \nexport * from './lib/authentication-routing.service';\nexport * from './lib/authentication.guard';\nexport * from './lib/authentication.service';\nexport * from './lib/bearer-token.interceptor';\nexport * from './lib/disabled-authentication.service';\nexport * from './lib/provide';\nexport * from './lib/register.service';\nexport * from './lib/sign-out.directive';\nexport * from './lib/tokens';\n// endregion\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;MAMa,+BAA+B,GAAG,IAAI,cAAc,CAAU,iCAAiC;MAO/F,gCAAgC,GAAG,I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A,CAAA;kGAAhB,gBAAgB,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,eAAA,EAAA,OAAA,EAAA,EAAA,UAAA,EAAA,YAAA,EAAA,OAAA,EAAA,SAAA,EAAA,EAAA,IAAA,EAAA,EAAA,SAAA,EAAA,EAAA,OAAA,EAAA,WAAA,EAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;2FAAhB,gBAAgB,EAAA,UAAA,EAAA,CAAA;kBAP5B,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,eAAe;AACzB,oBAAA,UAAU,EAAE,IAAI;AAChB,oBAAA,IAAI,EAAE;AACJ,wBAAA,SAAS,EAAE,WAAW;AACvB,qBAAA;AACF,iBAAA;;;ACTD;AAUA;;ACVA;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
- "version": "19.1.0",
2
+ "version": "21.0.1-dev.1",
3
3
  "name": "@rxap/authentication",
4
4
  "description": "Provides authentication services, guards, and interceptors for Angular applications. It supports token-based authentication and provides features such as sign-out functionality and routing based on authentication status. This package also includes utilities for disabling authentication in certain environments and managing access tokens.\n",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "dependencies": {
7
- "@nx/devkit": "20.5.0",
7
+ "@nx/devkit": "22.7.5",
8
8
  "tslib": "2.6.2"
9
9
  },
10
10
  "peerDependencies": {
11
- "@angular/common": "^19.2.1",
12
- "@angular/core": "^19.2.1",
13
- "@angular/router": "^19.2.1",
14
- "@rxap/utilities": "^16.5.1",
15
- "rxjs": "^7.8.1"
11
+ "@angular/common": "^21.2.9",
12
+ "@angular/core": "^21.2.9",
13
+ "@angular/router": "^21.2.9",
14
+ "@rxap/utilities": "^16.5.2-dev.1",
15
+ "rxjs": "^7.8.2"
16
16
  },
17
17
  "author": {
18
18
  "name": "Merzough Münker",
@@ -37,23 +37,23 @@
37
37
  "packageGroup": [
38
38
  {
39
39
  "package": "@angular/common",
40
- "version": "19.2.16"
40
+ "version": "21.2.9"
41
41
  },
42
42
  {
43
43
  "package": "@angular/core",
44
- "version": "19.2.16"
44
+ "version": "21.2.9"
45
45
  },
46
46
  {
47
47
  "package": "@angular/platform-browser",
48
- "version": "19.2.16"
48
+ "version": "21.2.9"
49
49
  },
50
50
  {
51
51
  "package": "@angular/router",
52
- "version": "19.2.16"
52
+ "version": "21.2.9"
53
53
  },
54
54
  {
55
55
  "package": "@rxap/utilities",
56
- "version": "16.5.1"
56
+ "version": "16.5.2-dev.1"
57
57
  }
58
58
  ]
59
59
  },
@@ -69,15 +69,16 @@
69
69
  "schematics": "./generators.json",
70
70
  "sideEffects": false,
71
71
  "module": "fesm2022/rxap-authentication.mjs",
72
- "typings": "index.d.ts",
72
+ "typings": "types/rxap-authentication.d.ts",
73
73
  "exports": {
74
74
  "./package.json": {
75
75
  "default": "./package.json"
76
76
  },
77
77
  ".": {
78
- "types": "./index.d.ts",
78
+ "types": "./types/rxap-authentication.d.ts",
79
79
  "default": "./fesm2022/rxap-authentication.mjs"
80
80
  },
81
81
  "./theme": "./theme.css"
82
- }
82
+ },
83
+ "type": "module"
83
84
  }
@@ -0,0 +1,96 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Provider, InjectionToken } from '@angular/core';
3
+ import { Router, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree } from '@angular/router';
4
+ import * as rxjs from 'rxjs';
5
+ import { Observable, BehaviorSubject, ReplaySubject } from 'rxjs';
6
+ import { HttpRequest, HttpHandlerFn, HttpEvent } from '@angular/common/http';
7
+ import { Constructor } from '@rxap/utilities';
8
+
9
+ declare class AuthenticationRoutingService {
10
+ private readonly router;
11
+ private readonly authenticationService;
12
+ private readonly deactivated;
13
+ constructor();
14
+ static ɵfac: i0.ɵɵFactoryDeclaration<AuthenticationRoutingService, never>;
15
+ static ɵprov: i0.ɵɵInjectableDeclaration<AuthenticationRoutingService>;
16
+ }
17
+
18
+ interface IAuthenticationService {
19
+ isAuthenticated$: Observable<boolean | null>;
20
+ events$: Observable<AuthenticationEvent>;
21
+ signOut(): Promise<void>;
22
+ isAuthenticated(): Promise<boolean>;
23
+ }
24
+ declare enum AuthenticationEventType {
25
+ OnAuthSuccess = "on-auth-success",
26
+ OnAuthError = "on-auth-error",
27
+ OnLogout = "on-logout"
28
+ }
29
+ interface AuthenticationEvent extends Record<string, any> {
30
+ type: AuthenticationEventType;
31
+ }
32
+ declare class RxapAuthenticationService implements IAuthenticationService {
33
+ isAuthenticated$: BehaviorSubject<boolean | null>;
34
+ readonly events$: ReplaySubject<AuthenticationEvent>;
35
+ private _authenticated;
36
+ constructor();
37
+ signOut(): Promise<void>;
38
+ isAuthenticated(): Promise<boolean>;
39
+ static ɵfac: i0.ɵɵFactoryDeclaration<RxapAuthenticationService, never>;
40
+ static ɵprov: i0.ɵɵInjectableDeclaration<RxapAuthenticationService>;
41
+ }
42
+
43
+ declare class RxapAuthenticationGuard {
44
+ authentication: RxapAuthenticationService;
45
+ router: Router;
46
+ private readonly deactivated;
47
+ lastUrl: string | null;
48
+ canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<UrlTree | boolean>;
49
+ canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<UrlTree | boolean>;
50
+ private checkAuthStatus;
51
+ private createUrlTreeToLastUrl;
52
+ static ɵfac: i0.ɵɵFactoryDeclaration<RxapAuthenticationGuard, never>;
53
+ static ɵprov: i0.ɵɵInjectableDeclaration<RxapAuthenticationGuard>;
54
+ }
55
+
56
+ declare function BearerTokenInterceptor(req: HttpRequest<unknown>, next: HttpHandlerFn): Observable<HttpEvent<unknown>>;
57
+
58
+ declare class DisabledAuthenticationService implements IAuthenticationService {
59
+ readonly isAuthenticated$: rxjs.Observable<boolean>;
60
+ readonly events$: rxjs.Observable<never>;
61
+ signOut(): Promise<void>;
62
+ isAuthenticated(): Promise<boolean>;
63
+ static ɵfac: i0.ɵɵFactoryDeclaration<DisabledAuthenticationService, never>;
64
+ static ɵprov: i0.ɵɵInjectableDeclaration<DisabledAuthenticationService>;
65
+ }
66
+
67
+ declare function provideAuthentication(service: Constructor<IAuthenticationService>, ...additionalProviders: Provider[]): Provider[];
68
+ declare function withInitialAuthenticationState(state: boolean): Provider;
69
+
70
+ declare class RegisterService {
71
+ constructor();
72
+ register(email: string, password: string): Promise<boolean>;
73
+ static ɵfac: i0.ɵɵFactoryDeclaration<RegisterService, never>;
74
+ static ɵprov: i0.ɵɵInjectableDeclaration<RegisterService>;
75
+ }
76
+
77
+ declare class SignOutDirective {
78
+ private readonly auth;
79
+ readonly successful: i0.OutputEmitterRef<void>;
80
+ readonly failure: i0.OutputEmitterRef<Error>;
81
+ onClick(): Promise<void>;
82
+ static ɵfac: i0.ɵɵFactoryDeclaration<SignOutDirective, never>;
83
+ static ɵdir: i0.ɵɵDirectiveDeclaration<SignOutDirective, "[rxapSignOut]", never, {}, { "successful": "successful"; "failure": "failure"; }, never, never, true, never>;
84
+ }
85
+
86
+ declare const RXAP_AUTHENTICATION_DEACTIVATED: InjectionToken<boolean>;
87
+ interface AuthenticationAccessToken extends Record<string, any> {
88
+ token: string;
89
+ valid?: boolean;
90
+ }
91
+ declare const RXAP_AUTHENTICATION_ACCESS_TOKEN: InjectionToken<BehaviorSubject<AuthenticationAccessToken | null>>;
92
+ declare const RXAP_INITIAL_AUTHENTICATION_STATE: InjectionToken<boolean>;
93
+ declare function withDisabledAuthentication(disabled?: boolean): Provider;
94
+
95
+ export { AuthenticationEventType, AuthenticationRoutingService, BearerTokenInterceptor, DisabledAuthenticationService, RXAP_AUTHENTICATION_ACCESS_TOKEN, RXAP_AUTHENTICATION_DEACTIVATED, RXAP_INITIAL_AUTHENTICATION_STATE, RegisterService, RxapAuthenticationGuard, RxapAuthenticationService, SignOutDirective, provideAuthentication, withDisabledAuthentication, withInitialAuthenticationState };
96
+ export type { AuthenticationAccessToken, AuthenticationEvent, IAuthenticationService };
package/index.d.ts DELETED
@@ -1,9 +0,0 @@
1
- export * from './lib/authentication-routing.service';
2
- export * from './lib/authentication.guard';
3
- export * from './lib/authentication.service';
4
- export * from './lib/bearer-token.interceptor';
5
- export * from './lib/disabled-authentication.service';
6
- export * from './lib/provide';
7
- export * from './lib/register.service';
8
- export * from './lib/sign-out.directive';
9
- export * from './lib/tokens';
@@ -1,11 +0,0 @@
1
- import { Router } from '@angular/router';
2
- import { RxapAuthenticationService } from './authentication.service';
3
- import * as i0 from "@angular/core";
4
- export declare class AuthenticationRoutingService {
5
- private readonly router;
6
- private readonly authenticationService;
7
- private readonly deactivated;
8
- constructor(router: Router, authenticationService: RxapAuthenticationService, deactivated?: boolean | null);
9
- static ɵfac: i0.ɵɵFactoryDeclaration<AuthenticationRoutingService, [null, null, { optional: true; }]>;
10
- static ɵprov: i0.ɵɵInjectableDeclaration<AuthenticationRoutingService>;
11
- }
@@ -1,16 +0,0 @@
1
- import { ActivatedRouteSnapshot, Router, RouterStateSnapshot, UrlTree } from '@angular/router';
2
- import { RxapAuthenticationService } from './authentication.service';
3
- import * as i0 from "@angular/core";
4
- export declare class RxapAuthenticationGuard {
5
- authentication: RxapAuthenticationService;
6
- router: Router;
7
- private readonly deactivated;
8
- lastUrl: string | null;
9
- constructor(authentication: RxapAuthenticationService, router: Router, deactivated?: boolean | null);
10
- canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<UrlTree | boolean>;
11
- canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<UrlTree | boolean>;
12
- private checkAuthStatus;
13
- private createUrlTreeToLastUrl;
14
- static ɵfac: i0.ɵɵFactoryDeclaration<RxapAuthenticationGuard, [null, null, { optional: true; }]>;
15
- static ɵprov: i0.ɵɵInjectableDeclaration<RxapAuthenticationGuard>;
16
- }
@@ -1,26 +0,0 @@
1
- import { BehaviorSubject, Observable, ReplaySubject } from 'rxjs';
2
- import * as i0 from "@angular/core";
3
- export interface IAuthenticationService {
4
- isAuthenticated$: Observable<boolean | null>;
5
- events$: Observable<AuthenticationEvent>;
6
- signOut(): Promise<void>;
7
- isAuthenticated(): Promise<boolean>;
8
- }
9
- export declare enum AuthenticationEventType {
10
- OnAuthSuccess = "on-auth-success",
11
- OnAuthError = "on-auth-error",
12
- OnLogout = "on-logout"
13
- }
14
- export interface AuthenticationEvent extends Record<string, any> {
15
- type: AuthenticationEventType;
16
- }
17
- export declare class RxapAuthenticationService implements IAuthenticationService {
18
- isAuthenticated$: BehaviorSubject<boolean | null>;
19
- readonly events$: ReplaySubject<AuthenticationEvent>;
20
- private _authenticated;
21
- constructor();
22
- signOut(): Promise<void>;
23
- isAuthenticated(): Promise<boolean>;
24
- static ɵfac: i0.ɵɵFactoryDeclaration<RxapAuthenticationService, never>;
25
- static ɵprov: i0.ɵɵInjectableDeclaration<RxapAuthenticationService>;
26
- }
@@ -1,3 +0,0 @@
1
- import { HttpEvent, HttpHandlerFn, HttpRequest } from '@angular/common/http';
2
- import { Observable } from 'rxjs';
3
- export declare function BearerTokenInterceptor(req: HttpRequest<unknown>, next: HttpHandlerFn): Observable<HttpEvent<unknown>>;
@@ -1,10 +0,0 @@
1
- import { IAuthenticationService } from './authentication.service';
2
- import * as i0 from "@angular/core";
3
- export declare class DisabledAuthenticationService implements IAuthenticationService {
4
- readonly isAuthenticated$: import("rxjs").Observable<boolean>;
5
- readonly events$: import("rxjs").Observable<never>;
6
- signOut(): Promise<void>;
7
- isAuthenticated(): Promise<boolean>;
8
- static ɵfac: i0.ɵɵFactoryDeclaration<DisabledAuthenticationService, never>;
9
- static ɵprov: i0.ɵɵInjectableDeclaration<DisabledAuthenticationService>;
10
- }
package/lib/provide.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import { Provider } from '@angular/core';
2
- import { IAuthenticationService } from './authentication.service';
3
- import { Constructor } from '@rxap/utilities';
4
- export declare function provideAuthentication(service: Constructor<IAuthenticationService>, ...additionalProviders: Provider[]): Provider[];
5
- export declare function withInitialAuthenticationState(state: boolean): Provider;
@@ -1,7 +0,0 @@
1
- import * as i0 from "@angular/core";
2
- export declare class RegisterService {
3
- constructor();
4
- register(email: string, password: string): Promise<boolean>;
5
- static ɵfac: i0.ɵɵFactoryDeclaration<RegisterService, never>;
6
- static ɵprov: i0.ɵɵInjectableDeclaration<RegisterService>;
7
- }
@@ -1,12 +0,0 @@
1
- import { EventEmitter } from '@angular/core';
2
- import { RxapAuthenticationService } from './authentication.service';
3
- import * as i0 from "@angular/core";
4
- export declare class SignOutDirective {
5
- private readonly auth;
6
- successful: EventEmitter<void>;
7
- failure: EventEmitter<Error>;
8
- constructor(auth: RxapAuthenticationService);
9
- onClick(): Promise<void>;
10
- static ɵfac: i0.ɵɵFactoryDeclaration<SignOutDirective, never>;
11
- static ɵdir: i0.ɵɵDirectiveDeclaration<SignOutDirective, "[rxapSignOut]", never, {}, { "successful": "successful"; "failure": "failure"; }, never, never, true, never>;
12
- }
package/lib/tokens.d.ts DELETED
@@ -1,10 +0,0 @@
1
- import { InjectionToken, Provider } from '@angular/core';
2
- import { BehaviorSubject } from 'rxjs';
3
- export declare const RXAP_AUTHENTICATION_DEACTIVATED: InjectionToken<boolean>;
4
- export interface AuthenticationAccessToken extends Record<string, any> {
5
- token: string;
6
- valid?: boolean;
7
- }
8
- export declare const RXAP_AUTHENTICATION_ACCESS_TOKEN: InjectionToken<BehaviorSubject<AuthenticationAccessToken | null>>;
9
- export declare const RXAP_INITIAL_AUTHENTICATION_STATE: InjectionToken<boolean>;
10
- export declare function withDisabledAuthentication(disabled?: boolean): Provider;