@juice-js/auth 1.3.0-alpha.2 → 2.0.0-alpha.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.
@@ -1,19 +1,19 @@
1
1
  import * as i0 from '@angular/core';
2
- import { ChangeDetectionStrategy, Component, Injectable, NgModule, Optional } from '@angular/core';
2
+ import { ChangeDetectionStrategy, Component, Injectable, isDevMode, provideEnvironmentInitializer, NgModule, inject, Optional } from '@angular/core';
3
3
  import * as i3 from '@ngx-translate/core';
4
4
  import { TranslatePipe, TranslateDirective, provideChildTranslateService, MissingTranslationHandler } from '@ngx-translate/core';
5
5
  import * as i1 from 'angular-oauth2-oidc';
6
- import { AuthConfig } from 'angular-oauth2-oidc';
6
+ import { AuthConfig, OAuthService } from 'angular-oauth2-oidc';
7
7
  import * as i1$1 from '@angular/router';
8
8
  import { RouterModule } from '@angular/router';
9
- import { filter, delay, map } from 'rxjs/operators';
9
+ import { filter, delay, switchMap, catchError, map, distinctUntilChanged, skip } from 'rxjs/operators';
10
10
  import * as i2 from '@angular/common/http';
11
- import { HTTP_INTERCEPTORS } from '@angular/common/http';
11
+ import { HttpErrorResponse, HTTP_INTERCEPTORS } from '@angular/common/http';
12
+ import { from, throwError, BehaviorSubject } from 'rxjs';
12
13
  import { SubmitMissingTranslationHandler } from '@juice-js/localize';
13
14
  import { MatDialogModule } from '@angular/material/dialog';
14
15
  import * as i4 from '@juice-js/core';
15
16
  import { TenantService } from '@juice-js/core';
16
- import { from } from 'rxjs';
17
17
  import { DevGuard } from '@juice-js/layout';
18
18
 
19
19
  class LoginComponent {
@@ -49,9 +49,7 @@ class LoginCompletedComponent {
49
49
  // `this.oauthService.state` contains the redirect url after login, if any
50
50
  let redirectUrl = '';
51
51
  if (this.oauthService.state) {
52
- // TODO: should validate the return url. Also, check if the return URL belongs Wto the current application.
53
- redirectUrl = decodeURIComponent(decodeURIComponent(this.oauthService.state));
54
- console.log(redirectUrl);
52
+ redirectUrl = appRelativeUrl(decodeURIComponent(decodeURIComponent(this.oauthService.state)));
55
53
  }
56
54
  this.router.navigateByUrl(redirectUrl);
57
55
  });
@@ -64,6 +62,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
64
62
  type: Component,
65
63
  args: [{ selector: 'page-login-completed', changeDetection: ChangeDetectionStrategy.Eager, standalone: false, template: "<div class=\"container p-4\">\n <h1>{{'Login completed' | translate }}</h1>\n <p>{{'Just to confirm that you did it right!' | translate}}</p>\n\n <p>{{'We are now redirecting you to the requested page...' | translate}}</p>\n</div>\n" }]
66
64
  }], ctorParameters: () => [{ type: i1$1.Router }, { type: i1$1.ActivatedRoute }, { type: i1.OAuthService }] });
65
+ /**
66
+ * The return URL when it is a path of this application (`/…`), otherwise `''` (the app root). The OAuth `state`
67
+ * round-trips through the browser, so an absolute or protocol-relative URL (`https://…`, `//…`, `/\…`) is not
68
+ * followed.
69
+ */
70
+ function appRelativeUrl(url) {
71
+ return url.startsWith('/') && !url.startsWith('//') && !url.startsWith('/\\') ? url : '';
72
+ }
67
73
 
68
74
  class LogoutComponent {
69
75
  constructor(oauthService) {
@@ -139,36 +145,133 @@ class AuthModuleConfig {
139
145
  }
140
146
  }
141
147
 
148
+ /**
149
+ * Renews the access token with the refresh token. Concurrent callers — the interceptor's 401 retries, the guard and
150
+ * the expiry timer — share one request, so a rotating refresh token is redeemed once.
151
+ */
152
+ class AuthTokenRefresher {
153
+ constructor(oauthService) {
154
+ this.oauthService = oauthService;
155
+ }
156
+ /** True when a refresh token is stored, so an expired session can be renewed without a login round-trip. */
157
+ canRefresh() {
158
+ return !!this.oauthService.getRefreshToken();
159
+ }
160
+ /** Resolves true when a new access token was obtained; never rejects. */
161
+ refresh() {
162
+ if (!this.canRefresh()) {
163
+ return Promise.resolve(false);
164
+ }
165
+ this.refreshing ??= this.doRefresh().finally(() => (this.refreshing = undefined));
166
+ return this.refreshing;
167
+ }
168
+ async doRefresh() {
169
+ try {
170
+ // The token endpoint comes from the discovery document, which a page outside AuthGuard may not have loaded.
171
+ if (!this.oauthService.discoveryDocumentLoaded) {
172
+ await this.oauthService.loadDiscoveryDocument();
173
+ }
174
+ await this.oauthService.refreshToken();
175
+ return this.oauthService.hasValidAccessToken();
176
+ }
177
+ catch {
178
+ return false;
179
+ }
180
+ }
181
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AuthTokenRefresher, deps: [{ token: i1.OAuthService }], target: i0.ɵɵFactoryTarget.Injectable }); }
182
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AuthTokenRefresher, providedIn: 'root' }); }
183
+ }
184
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AuthTokenRefresher, decorators: [{
185
+ type: Injectable,
186
+ args: [{
187
+ providedIn: 'root'
188
+ }]
189
+ }], ctorParameters: () => [{ type: i1.OAuthService }] });
190
+
191
+ let warnedUnrestricted = false;
192
+ /**
193
+ * Adds `Authorization: Bearer …` to requests for {@link AuthModuleConfig.allowedUrls} (the app's own origin when that
194
+ * is unset). With a refresh token stored, an expired token is renewed before the request, and a 401 renews it and
195
+ * retries once.
196
+ */
142
197
  class AuthInterceptor {
143
- constructor(auth) {
198
+ constructor(auth, options, refresher) {
144
199
  this.auth = auth;
200
+ this.options = options;
201
+ this.refresher = refresher;
145
202
  }
146
203
  intercept(req, next) {
147
- // Get the auth token from the service.
148
- if (this.auth.hasValidAccessToken()) {
149
- const authToken = this.auth.getAccessToken();
150
- // Clone the request and replace the original headers with
151
- // cloned headers, updated with the authorization.
152
- const authReq = req.clone({
153
- headers: req.headers.set('Authorization', `Bearer ${authToken}`)
154
- });
155
- // send cloned request with header to the next handler.
156
- return next.handle(authReq);
204
+ if (!this.isAllowed(req.url)) {
205
+ return next.handle(req);
206
+ }
207
+ const send = () => next.handle(this.withToken(req));
208
+ if (this.isIdentityServer(req.url)) {
209
+ // The discovery and token requests the refresh itself makes: renewing here would wait on itself.
210
+ return send();
157
211
  }
158
- return next.handle(req);
212
+ const first$ = !this.auth.hasValidAccessToken() && this.refresher.canRefresh()
213
+ ? from(this.refresher.refresh()).pipe(switchMap(send))
214
+ : send();
215
+ return first$.pipe(catchError((error) => {
216
+ if (error instanceof HttpErrorResponse && error.status === 401 && this.refresher.canRefresh()) {
217
+ return from(this.refresher.refresh()).pipe(switchMap((renewed) => renewed ? send() : throwError(() => error)));
218
+ }
219
+ return throwError(() => error);
220
+ }));
159
221
  }
160
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AuthInterceptor, deps: [{ token: i1.OAuthService }], target: i0.ɵɵFactoryTarget.Injectable }); }
222
+ withToken(req) {
223
+ if (!this.auth.hasValidAccessToken()) {
224
+ return req;
225
+ }
226
+ // Clone the request and replace the original headers with cloned headers, updated with the authorization.
227
+ return req.clone({
228
+ headers: req.headers.set('Authorization', `Bearer ${this.auth.getAccessToken()}`)
229
+ });
230
+ }
231
+ isIdentityServer(url) {
232
+ const urls = [this.auth.issuer, this.auth.tokenEndpoint].filter((u) => !!u);
233
+ return urls.some((u) => matches(url, u));
234
+ }
235
+ isAllowed(url) {
236
+ const allowed = this.options?.allowedUrls ?? ['', ownOrigin()];
237
+ if (allowed.includes('*')) {
238
+ if (isDevMode() && !warnedUnrestricted) {
239
+ warnedUnrestricted = true;
240
+ console.warn('[@juice-js/auth] AuthModuleConfig.allowedUrls is [\'*\']: the access token is sent with every '
241
+ + 'request, to any host. List the APIs that should receive it instead.');
242
+ }
243
+ return true;
244
+ }
245
+ return allowed.some((base) => matches(url, base));
246
+ }
247
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AuthInterceptor, deps: [{ token: i1.OAuthService }, { token: AuthModuleConfig }, { token: AuthTokenRefresher }], target: i0.ɵɵFactoryTarget.Injectable }); }
161
248
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AuthInterceptor }); }
162
249
  }
163
250
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AuthInterceptor, decorators: [{
164
251
  type: Injectable
165
- }], ctorParameters: () => [{ type: i1.OAuthService }] });
252
+ }], ctorParameters: () => [{ type: i1.OAuthService }, { type: AuthModuleConfig }, { type: AuthTokenRefresher }] });
253
+ /** The default allow-list's absolute entry; empty outside a browser, which leaves relative URLs only. */
254
+ function ownOrigin() {
255
+ return typeof window !== 'undefined' && window.location?.origin ? window.location.origin : '';
256
+ }
257
+ /** `url` is `base` or continues it with `/` or `?`; an empty base (the app's own origin) matches relative URLs only. */
258
+ function matches(url, base) {
259
+ if (!base) {
260
+ return !/^[a-z][a-z0-9+.-]*:\/\//i.test(url) && !url.startsWith('//');
261
+ }
262
+ const trimmed = base.replace(/\/+$/, '');
263
+ return url === trimmed || url.startsWith(trimmed + '/') || url.startsWith(trimmed + '?');
264
+ }
166
265
 
167
266
  class AuthModule {
168
267
  static forRoot(options) {
268
+ const extra = options?.automaticRefresh
269
+ ? [provideEnvironmentInitializer(renewBeforeExpiry)]
270
+ : [];
169
271
  return {
170
272
  ngModule: AuthModule,
171
273
  providers: [
274
+ ...extra,
172
275
  {
173
276
  provide: HTTP_INTERCEPTORS,
174
277
  useClass: AuthInterceptor,
@@ -242,13 +345,25 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
242
345
  ]
243
346
  }]
244
347
  }] });
348
+ /**
349
+ * `AuthModuleConfig.automaticRefresh`: OAuthService fires `token_expires` at its timeoutFactor (75% of the lifetime
350
+ * by default); renew the access token then, through the shared AuthTokenRefresher.
351
+ */
352
+ function renewBeforeExpiry() {
353
+ const oauthService = inject(OAuthService);
354
+ const refresher = inject(AuthTokenRefresher);
355
+ oauthService.events
356
+ .pipe(filter((e) => e.type === 'token_expires' && e.info === 'access_token'))
357
+ .subscribe(() => void refresher.refresh());
358
+ }
245
359
 
246
360
  class AuthGuard {
247
- constructor(router, oauthService, options, tenantService) {
361
+ constructor(router, oauthService, options, tenantService, refresher) {
248
362
  this.router = router;
249
363
  this.oauthService = oauthService;
250
364
  this.options = options;
251
365
  this.tenantService = tenantService;
366
+ this.refresher = refresher;
252
367
  this.path = new URL(this.options.basePath).pathname;
253
368
  if (tenantService) {
254
369
  var identifier = '/' + tenantService.currentTenant?.identifier || '';
@@ -257,26 +372,34 @@ class AuthGuard {
257
372
  }
258
373
  canActivate(route, state) {
259
374
  if (this.hasValidToken()) {
260
- if (!this.hasValidTenant()) {
261
- // Re-authenticating cannot fix a tenant mismatch: the IdP would hand back the
262
- // same issuer and the /login redirect would bounce straight back here.
263
- return this.router.createUrlTree([`${this.path}/unauthorized`], { queryParams: { reason: 'tenant-mismatch' } });
264
- }
265
- if (this.hasValidRole(route)) {
266
- return true;
267
- }
268
- return this.router.createUrlTree([`${this.path}/unauthorized`], { queryParams: { reason: 'role-mismatch' } });
375
+ return this.authorize(route);
269
376
  }
270
- return from(this.oauthService.loadDiscoveryDocumentAndTryLogin({ disableNonceCheck: true })).pipe(map(() => {
377
+ return from(this.restoreSession()).pipe(map(() => {
271
378
  if (this.hasValidToken()) {
272
- if (this.hasValidRole(route)) {
273
- return true;
274
- }
275
- return this.router.createUrlTree([`${this.path}/unauthorized`], { queryParams: { reason: 'role-mismatch' } });
379
+ return this.authorize(route);
276
380
  }
277
381
  return this.router.createUrlTree([`${this.path}/login`], { queryParams: { returnUrl: state.url } });
278
382
  }));
279
383
  }
384
+ /** Completes an OIDC callback if this is one; otherwise renews an expired session with the refresh token. */
385
+ async restoreSession() {
386
+ await this.oauthService.loadDiscoveryDocumentAndTryLogin({ disableNonceCheck: true });
387
+ if (!this.hasValidToken() && this.refresher.canRefresh()) {
388
+ await this.refresher.refresh();
389
+ }
390
+ }
391
+ /** The tenant and role checks, for a session found valid or just restored. */
392
+ authorize(route) {
393
+ if (!this.hasValidTenant()) {
394
+ // Re-authenticating cannot fix a tenant mismatch: the IdP would hand back the
395
+ // same issuer and the /login redirect would bounce straight back here.
396
+ return this.router.createUrlTree([`${this.path}/unauthorized`], { queryParams: { reason: 'tenant-mismatch' } });
397
+ }
398
+ if (this.hasValidRole(route)) {
399
+ return true;
400
+ }
401
+ return this.router.createUrlTree([`${this.path}/unauthorized`], { queryParams: { reason: 'role-mismatch' } });
402
+ }
280
403
  hasValidRole(route) {
281
404
  const claims = this.oauthService.getIdentityClaims();
282
405
  var { roles } = route.data;
@@ -304,7 +427,7 @@ class AuthGuard {
304
427
  var match = issuer.match(/\/([^\/]+)\/?$/);
305
428
  return match?.[1];
306
429
  }
307
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AuthGuard, deps: [{ token: i1$1.Router }, { token: i1.OAuthService }, { token: AuthModuleConfig }, { token: i4.TenantService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
430
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AuthGuard, deps: [{ token: i1$1.Router }, { token: i1.OAuthService }, { token: AuthModuleConfig }, { token: i4.TenantService, optional: true }, { token: AuthTokenRefresher }], target: i0.ɵɵFactoryTarget.Injectable }); }
308
431
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AuthGuard, providedIn: 'root' }); }
309
432
  }
310
433
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AuthGuard, decorators: [{
@@ -314,7 +437,67 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
314
437
  }]
315
438
  }], ctorParameters: () => [{ type: i1$1.Router }, { type: i1.OAuthService }, { type: AuthModuleConfig }, { type: i4.TenantService, decorators: [{
316
439
  type: Optional
317
- }] }] });
440
+ }] }, { type: AuthTokenRefresher }] });
441
+
442
+ /** The OAuth events after which the signed-in user may be someone else, or nobody. */
443
+ const USER_EVENTS = [
444
+ 'token_received', 'token_refreshed', 'token_refresh_error', 'logout', 'session_terminated', 'session_error',
445
+ ];
446
+ /**
447
+ * Who is signed in, as a stable key (the `sub` claim), for anything that caches per user — menus, permissions,
448
+ * profile data — and must start over when the user changes.
449
+ *
450
+ * A session whose access token expired but can still be refreshed counts as the same user, so a page reload or a
451
+ * token renewal is not reported as a sign-in.
452
+ *
453
+ * ```ts
454
+ * inject(AuthSession).changes.subscribe(() => this.cache.clear());
455
+ * ```
456
+ */
457
+ class AuthSession {
458
+ constructor(oauthService) {
459
+ this.oauthService = oauthService;
460
+ this.key$ = new BehaviorSubject(this.readKey());
461
+ this.user$ = this.key$.pipe(distinctUntilChanged());
462
+ this.changes = this.user$.pipe(skip(1));
463
+ this.oauthService.events
464
+ .pipe(filter((e) => USER_EVENTS.includes(e.type)))
465
+ .subscribe(() => this.key$.next(this.readKey()));
466
+ }
467
+ /** The signed-in user's key now; `null` when nobody is. */
468
+ get userKey() {
469
+ return this.key$.value;
470
+ }
471
+ readKey() {
472
+ if (!this.oauthService.hasValidAccessToken() && !this.oauthService.getRefreshToken()) {
473
+ return null;
474
+ }
475
+ const claims = this.oauthService.getIdentityClaims();
476
+ const sub = claims?.['sub'] ?? subOf(this.oauthService.getAccessToken());
477
+ return typeof sub === 'string' && sub ? sub : null;
478
+ }
479
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AuthSession, deps: [{ token: i1.OAuthService }], target: i0.ɵɵFactoryTarget.Injectable }); }
480
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AuthSession, providedIn: 'root' }); }
481
+ }
482
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AuthSession, decorators: [{
483
+ type: Injectable,
484
+ args: [{
485
+ providedIn: 'root'
486
+ }]
487
+ }], ctorParameters: () => [{ type: i1.OAuthService }] });
488
+ /** The `sub` of a JWT access token, unverified (a key only; the APIs verify the token). */
489
+ function subOf(token) {
490
+ const payload = token?.split('.')[1];
491
+ if (!payload) {
492
+ return undefined;
493
+ }
494
+ try {
495
+ return JSON.parse(atob(payload.replace(/-/g, '+').replace(/_/g, '/')))['sub'];
496
+ }
497
+ catch {
498
+ return undefined;
499
+ }
500
+ }
318
501
 
319
502
  const routes = [
320
503
  { path: 'login', component: LoginComponent, title: 'Login' },
@@ -351,5 +534,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
351
534
  * Generated bundle index. Do not edit.
352
535
  */
353
536
 
354
- export { AuthGuard, AuthInterceptor, AuthModule, AuthModuleConfig, AuthRoutingModule };
537
+ export { AuthGuard, AuthInterceptor, AuthModule, AuthModuleConfig, AuthRoutingModule, AuthSession, AuthTokenRefresher };
355
538
  //# sourceMappingURL=juice-js-auth.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"juice-js-auth.mjs","sources":["../../../../projects/juice-js/auth/src/lib/pages/login/login.component.ts","../../../../projects/juice-js/auth/src/lib/pages/login/login.component.html","../../../../projects/juice-js/auth/src/lib/pages/login-completed/login-completed.component.ts","../../../../projects/juice-js/auth/src/lib/pages/login-completed/login-completed.component.html","../../../../projects/juice-js/auth/src/lib/pages/logout/logout.component.ts","../../../../projects/juice-js/auth/src/lib/pages/logout/logout.component.html","../../../../projects/juice-js/auth/src/lib/pages/logout-completed/logout-completed.component.ts","../../../../projects/juice-js/auth/src/lib/pages/logout-completed/logout-completed.component.html","../../../../projects/juice-js/auth/src/lib/pages/unauthorized/unauthorized.component.ts","../../../../projects/juice-js/auth/src/lib/pages/unauthorized/unauthorized.component.html","../../../../projects/juice-js/auth/src/lib/pages/protected/user-info/user-info.component.ts","../../../../projects/juice-js/auth/src/lib/pages/protected/user-info/user-info.component.html","../../../../projects/juice-js/auth/src/lib/auth/auth-module.config.ts","../../../../projects/juice-js/auth/src/lib/auth/auth.interceptor.ts","../../../../projects/juice-js/auth/src/lib/auth.module.ts","../../../../projects/juice-js/auth/src/lib/auth/auth.guard.ts","../../../../projects/juice-js/auth/src/lib/auth/auth-routing.module.ts","../../../../projects/juice-js/auth/src/public-api.ts","../../../../projects/juice-js/auth/src/juice-js-auth.ts"],"sourcesContent":["import {Component, OnInit, ChangeDetectionStrategy} from '@angular/core';\nimport {OAuthService} from \"angular-oauth2-oidc\";\nimport {ActivatedRoute} from \"@angular/router\";\n\n@Component({\n selector: 'page-login',\n templateUrl: './login.component.html',\n styleUrls: ['./login.component.css'],\n changeDetection: ChangeDetectionStrategy.Eager,\n standalone: false\n})\nexport class LoginComponent implements OnInit {\n\n constructor(private oauthService: OAuthService, private activatedRoute: ActivatedRoute) {\n }\n\n async ngOnInit() {\n const returnUrl = this.activatedRoute.snapshot.queryParams[\"returnUrl\"] ?? '/home';\n\n console.log('[Login] returnUrl', this.activatedRoute.snapshot.queryParams[\"returnUrl\"]);\n\n await this.login(returnUrl);\n }\n\n async login(returnUrl: string) {\n await this.oauthService.loadDiscoveryDocument();\n this.oauthService.initLoginFlow(returnUrl);\n }\n}\n","<div class=\"p-4 text-center\">\n <p>{{'We are redirecting you to login page...' | translate }}</p>\n</div>\n","import {Component, OnInit, ChangeDetectionStrategy} from '@angular/core';\nimport {ActivatedRoute, Router} from \"@angular/router\";\nimport {OAuthService} from \"angular-oauth2-oidc\";\nimport {delay, filter} from \"rxjs/operators\";\n\n@Component({\n selector: 'page-login-completed',\n templateUrl: './login-completed.component.html',\n styleUrls: ['./login-completed.component.css'],\n changeDetection: ChangeDetectionStrategy.Eager,\n standalone: false\n})\nexport class LoginCompletedComponent implements OnInit {\n\n constructor(private router: Router, private activatedRoute: ActivatedRoute, private oauthService: OAuthService) {\n }\n\n async ngOnInit() {\n this.oauthService.events.pipe(\n filter(e => e.type === \"token_received\"),\n delay(2000)\n ).subscribe((e) => {\n // `this.oauthService.state` contains the redirect url after login, if any\n\n let redirectUrl = '';\n if (this.oauthService.state) {\n // TODO: should validate the return url. Also, check if the return URL belongs Wto the current application.\n redirectUrl = decodeURIComponent(decodeURIComponent(this.oauthService.state));\n console.log(redirectUrl);\n }\n\n this.router.navigateByUrl(redirectUrl);\n });\n\n await this.oauthService.loadDiscoveryDocumentAndTryLogin({disableNonceCheck: true});\n }\n\n}\n","<div class=\"container p-4\">\n <h1>{{'Login completed' | translate }}</h1>\n <p>{{'Just to confirm that you did it right!' | translate}}</p>\n\n <p>{{'We are now redirecting you to the requested page...' | translate}}</p>\n</div>\n","import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core';\nimport {OAuthService} from \"angular-oauth2-oidc\";\n\n@Component({\n selector: 'page-logout',\n templateUrl: './logout.component.html',\n styleUrls: ['./logout.component.css'],\n changeDetection: ChangeDetectionStrategy.Eager,\n standalone: false\n})\nexport class LogoutComponent implements OnInit {\n\n constructor(private oauthService: OAuthService) { }\n\n async ngOnInit() {\n await this.oauthService.loadDiscoveryDocument();\n await this.oauthService.revokeTokenAndLogout();\n }\n\n}\n","<div class=\"pt-4 text-center\">\n <p>{{'We are logging you out...'| translate}}</p>\n</div>\n","import {Component, ChangeDetectionStrategy} from '@angular/core';\n\n@Component({\n selector: 'page-logout-completed',\n templateUrl: './logout-completed.component.html',\n styleUrls: ['./logout-completed.component.css'],\n changeDetection: ChangeDetectionStrategy.Eager,\n standalone: false\n})\nexport class LogoutCompletedComponent {\n}\n","<div class=\"container pt-4\">\n <h1>{{'Logout' | translate}}</h1>\n <p>{{'You successfully logged out from the application.' | translate}}</p>\n\n <p>{{'If you want to access the application again,' | translate}} <a routerLink=\"../login\">{{'log in' | translate}}</a>.</p>\n</div>\n","import {Component, ChangeDetectionStrategy} from '@angular/core';\nimport {ActivatedRoute} from '@angular/router';\n\nconst DEFAULT_MESSAGE = 'You are unauthorized to access this resource.';\n\nconst REASON_MESSAGES: {[reason: string]: string} = {\n 'tenant-mismatch': 'Your session belongs to a different tenant. Sign out, then sign in again to access this tenant.',\n 'role-mismatch': 'You do not have the required role to access this resource.',\n};\n\n@Component({\n selector: 'page-unauthorized',\n templateUrl: './unauthorized.component.html',\n changeDetection: ChangeDetectionStrategy.Eager,\n standalone: false\n})\nexport class UnauthorizedComponent {\n message: string;\n\n constructor(activatedRoute: ActivatedRoute) {\n var reason = activatedRoute.snapshot.queryParams['reason'];\n this.message = REASON_MESSAGES[reason] ?? DEFAULT_MESSAGE;\n }\n}\n","<div class=\"container p-4\">\n <h1>{{'Unauthorized' | translate }}</h1>\n <p>{{ message | translate}}</p>\n </div>\n ","import { HttpClient } from '@angular/common/http';\nimport {Component, OnInit, ChangeDetectionStrategy} from '@angular/core';\nimport {OAuthService} from \"angular-oauth2-oidc\";\n\n@Component({\n selector: 'page-user-info',\n templateUrl: './user-info.component.html',\n styleUrls: ['./user-info.component.css'],\n changeDetection: ChangeDetectionStrategy.Eager,\n standalone: false\n})\nexport class UserInfoComponent implements OnInit {\n\n userInfo = '';\n accessToken = '';\n idToken = '';\n\n constructor(private oauthService: OAuthService, private http: HttpClient) {\n }\n\n async ngOnInit() {\n this.accessToken = this.oauthService.getAccessToken();\n this.idToken = this.oauthService.getIdToken();\n\n console.log(this.oauthService.getIdentityClaims());\n\n await this.oauthService.loadDiscoveryDocument();\n\n this.oauthService.loadUserProfile().then(info => {\n this.userInfo = JSON.stringify(info, null, 2);\n });\n\n }\n}\n","<h1>{{'User info' | translate}} </h1>\n<pre>{{userInfo}}</pre>\n\n<h5>{{'Access Token' | translate}}</h5>\n<pre>{{accessToken}}</pre>\n\n<h5>{{'ID Token' | translate}}</h5>\n<pre>{{idToken}}</pre>\n","export class AuthModuleConfig{\n basePath: string = \"\";\n}\n","import { HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';\nimport { Injectable } from '@angular/core';\nimport { OAuthService } from 'angular-oauth2-oidc';\n\n@Injectable()\nexport class AuthInterceptor implements HttpInterceptor {\n\n constructor(private auth: OAuthService) {}\n\n intercept(req: HttpRequest<any>, next: HttpHandler) {\n // Get the auth token from the service.\n if(this.auth.hasValidAccessToken()){\n const authToken = this.auth.getAccessToken();\n\n // Clone the request and replace the original headers with\n // cloned headers, updated with the authorization.\n const authReq = req.clone({\n headers: req.headers.set('Authorization', `Bearer ${authToken}`)\n });\n\n // send cloned request with header to the next handler.\n return next.handle(authReq);\n }\n return next.handle(req);\n }\n}","import { ModuleWithProviders, NgModule, Optional } from '@angular/core';\nimport { TranslatePipe, TranslateDirective, MissingTranslationHandler, provideChildTranslateService } from '@ngx-translate/core';\n\nimport { LoginComponent } from './pages/login/login.component';\nimport { LoginCompletedComponent } from './pages/login-completed/login-completed.component';\nimport { LogoutComponent } from './pages/logout/logout.component';\nimport { LogoutCompletedComponent } from './pages/logout-completed/logout-completed.component';\nimport { UnauthorizedComponent } from './pages/unauthorized/unauthorized.component';\nimport { UserInfoComponent } from './pages/protected/user-info/user-info.component';\nimport { AuthModuleConfig } from './auth/auth-module.config';\nimport { AuthInterceptor } from './auth/auth.interceptor'\n\nimport { SubmitMissingTranslationHandler } from '@juice-js/localize';\nimport { AuthConfig } from 'angular-oauth2-oidc';\nimport { MatDialogModule } from '@angular/material/dialog';\nimport { TenantService } from '@juice-js/core';\nimport { HTTP_INTERCEPTORS } from '@angular/common/http';\n\n@NgModule({\n declarations: [\n LoginComponent,\n LoginCompletedComponent,\n LogoutComponent,\n LogoutCompletedComponent,\n UnauthorizedComponent,\n UserInfoComponent\n ],\n imports: [\n TranslatePipe,\n TranslateDirective,\n MatDialogModule\n ],\n exports: [\n ],\n providers: [\n provideChildTranslateService({\n missingTranslationHandler: {\n provide: MissingTranslationHandler,\n useClass: SubmitMissingTranslationHandler\n }\n })\n ]\n})\nexport class AuthModule {\n public static forRoot(options : any): ModuleWithProviders<AuthModule> {\n return {\n ngModule: AuthModule,\n providers: [\n {\n provide: HTTP_INTERCEPTORS,\n useClass: AuthInterceptor,\n multi: true\n },\n {\n provide: AuthModuleConfig,\n useValue: options\n },\n {\n provide: AuthConfig,\n useFactory: (tenantService: TenantService) : AuthConfig => {\n // Create config from options\n var authConfig = new AuthConfig(options);\n // Replace :tenant with the current tenant\n if(tenantService){\n let identifier = '/' + tenantService.currentTenant?.identifier||'';\n authConfig.issuer = options.issuer?.replace('/:tenant', identifier);\n authConfig.redirectUri = options.redirectUri?.replace('/:tenant', identifier);\n authConfig.postLogoutRedirectUri = options.postLogoutRedirectUri?.replace('/:tenant', identifier);\n }\n return authConfig;\n },\n deps: [TenantService]\n }\n ]\n }\n }\n}\n","import {Injectable, Optional} from '@angular/core';\nimport {ActivatedRouteSnapshot, Router, RouterStateSnapshot} from '@angular/router';\nimport {OAuthService} from 'angular-oauth2-oidc';\nimport {from} from \"rxjs\";\nimport {map} from \"rxjs/operators\";\nimport { AuthModuleConfig } from './auth-module.config';\nimport { TenantService } from '@juice-js/core';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class AuthGuard {\n path: string;\n constructor(private router: Router, private oauthService: OAuthService,\n private options: AuthModuleConfig, @Optional() private tenantService: TenantService){\n this.path = new URL(this.options.basePath).pathname;\n if(tenantService){\n var identifier = '/' + tenantService.currentTenant?.identifier||'';\n this.path = this.path.replace('/:tenant', identifier);\n }\n }\n\n canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {\n if (this.hasValidToken()) {\n if(!this.hasValidTenant()){\n // Re-authenticating cannot fix a tenant mismatch: the IdP would hand back the\n // same issuer and the /login redirect would bounce straight back here.\n return this.router.createUrlTree([`${this.path}/unauthorized`], {queryParams: {reason: 'tenant-mismatch'}});\n }\n if(this.hasValidRole(route)){\n return true;\n }\n return this.router.createUrlTree([`${this.path}/unauthorized`], {queryParams: {reason: 'role-mismatch'}});\n }\n\n return from(this.oauthService.loadDiscoveryDocumentAndTryLogin({disableNonceCheck: true})).pipe(\n map(() => {\n if (this.hasValidToken()) {\n if(this.hasValidRole(route)){\n return true;\n }\n return this.router.createUrlTree([`${this.path}/unauthorized`], {queryParams: {reason: 'role-mismatch'}});\n }\n\n return this.router.createUrlTree([`${this.path}/login`], {queryParams: {returnUrl: state.url}});\n })\n )\n }\n\n private hasValidRole(route: ActivatedRouteSnapshot){\n const claims = this.oauthService.getIdentityClaims();\n var {roles} = route.data;\n var {role} = claims;\n \n if(roles \n && ((typeof role ==\"string\" && !roles.includes(role)) \n || ( Array.isArray(role) && !role.some(r=> roles.includes(r))))){\n return false;\n }\n return true;\n }\n\n private hasValidToken() {\n return this.oauthService.hasValidAccessToken() && this.oauthService.hasValidIdToken();\n }\n\n private hasValidTenant(){\n if(!this.tenantService){\n return true;\n }\n const claims = this.oauthService.getIdentityClaims();\n var tenant = this.tenantService?.currentTenant?.identifier;\n var issuer = claims['iss'];\n return !tenant || this.getTenantFromIssuer(issuer) === tenant;\n }\n\n private getTenantFromIssuer(issuer: string){\n var match = issuer.match(/\\/([^\\/]+)\\/?$/);\n return match?.[1];\n }\n}","import { NgModule } from '@angular/core';\nimport { RouterModule, Routes } from '@angular/router';\nimport { LogoutCompletedComponent } from \"../pages/logout-completed/logout-completed.component\";\nimport { LoginComponent } from \"../pages/login/login.component\";\nimport { LoginCompletedComponent } from \"../pages/login-completed/login-completed.component\";\nimport { UserInfoComponent } from \"../pages/protected/user-info/user-info.component\";\nimport { LogoutComponent } from \"../pages/logout/logout.component\";\nimport { UnauthorizedComponent } from '../pages/unauthorized/unauthorized.component';\nimport { AuthGuard } from './auth.guard';\nimport { DevGuard } from '@juice-js/layout';\n\nconst routes: Routes = [\n {path: 'login', component: LoginComponent, title: 'Login'},\n {path: 'login-completed', component: LoginCompletedComponent, title: 'Login completed'},\n {path: 'logout', component: LogoutComponent},\n {path: 'logout-completed', component: LogoutCompletedComponent, title: 'Logout completed'},\n {path: 'unauthorized', component: UnauthorizedComponent, title: 'Unauthorized'},\n {path: 'user-info', component: UserInfoComponent, canActivate: [AuthGuard, DevGuard], title: 'User info',\n data:{\n menuDisplay: [DevGuard],\n menuIcon: 'account_circle',\n menuOrder: 100,\n }},\n {path: '', redirectTo: 'user-info', pathMatch: 'full'},\n];\n\n@NgModule({\n imports: [RouterModule.forChild(routes)],\n exports: [RouterModule],\n})\nexport class AuthRoutingModule{\n \n}","/*\n * Public API Surface of auth\n */\n\nexport * from './lib/auth.module';\nexport * from './lib/auth/auth.guard';\nexport * from './lib/auth/auth.interceptor';\nexport * from './lib/auth/auth-module.config';\nexport * from './lib/auth/auth-routing.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i2","i1","i3.AuthModuleConfig"],"mappings":";;;;;;;;;;;;;;;;;;MAWa,cAAc,CAAA;IAEzB,WAAA,CAAoB,YAA0B,EAAU,cAA8B,EAAA;QAAlE,IAAA,CAAA,YAAY,GAAZ,YAAY;QAAwB,IAAA,CAAA,cAAc,GAAd,cAAc;IACtE;AAEA,IAAA,MAAM,QAAQ,GAAA;AACZ,QAAA,MAAM,SAAS,GAAG,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,WAAW,CAAC,WAAW,CAAC,IAAI,OAAO;AAElF,QAAA,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;AAEvF,QAAA,MAAM,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;IAC7B;IAEA,MAAM,KAAK,CAAC,SAAiB,EAAA;AAC3B,QAAA,MAAM,IAAI,CAAC,YAAY,CAAC,qBAAqB,EAAE;AAC/C,QAAA,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,SAAS,CAAC;IAC5C;8GAhBW,cAAc,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAAA,EAAA,CAAA,YAAA,EAAA,EAAA,EAAA,KAAA,EAAAA,IAAA,CAAA,cAAA,EAAA,CAAA,EAAA,MAA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AAC,CAAC;oBACxC,OAAO,EAAE,CAAC,YAAY,CAAC;AACxB,iBAAA;;;AC7BD;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"juice-js-auth.mjs","sources":["../../../../projects/juice-js/auth/src/lib/pages/login/login.component.ts","../../../../projects/juice-js/auth/src/lib/pages/login/login.component.html","../../../../projects/juice-js/auth/src/lib/pages/login-completed/login-completed.component.ts","../../../../projects/juice-js/auth/src/lib/pages/login-completed/login-completed.component.html","../../../../projects/juice-js/auth/src/lib/pages/logout/logout.component.ts","../../../../projects/juice-js/auth/src/lib/pages/logout/logout.component.html","../../../../projects/juice-js/auth/src/lib/pages/logout-completed/logout-completed.component.ts","../../../../projects/juice-js/auth/src/lib/pages/logout-completed/logout-completed.component.html","../../../../projects/juice-js/auth/src/lib/pages/unauthorized/unauthorized.component.ts","../../../../projects/juice-js/auth/src/lib/pages/unauthorized/unauthorized.component.html","../../../../projects/juice-js/auth/src/lib/pages/protected/user-info/user-info.component.ts","../../../../projects/juice-js/auth/src/lib/pages/protected/user-info/user-info.component.html","../../../../projects/juice-js/auth/src/lib/auth/auth-module.config.ts","../../../../projects/juice-js/auth/src/lib/auth/auth-token-refresher.ts","../../../../projects/juice-js/auth/src/lib/auth/auth.interceptor.ts","../../../../projects/juice-js/auth/src/lib/auth.module.ts","../../../../projects/juice-js/auth/src/lib/auth/auth.guard.ts","../../../../projects/juice-js/auth/src/lib/auth/auth-session.ts","../../../../projects/juice-js/auth/src/lib/auth/auth-routing.module.ts","../../../../projects/juice-js/auth/src/public-api.ts","../../../../projects/juice-js/auth/src/juice-js-auth.ts"],"sourcesContent":["import {Component, OnInit, ChangeDetectionStrategy} from '@angular/core';\nimport {OAuthService} from \"angular-oauth2-oidc\";\nimport {ActivatedRoute} from \"@angular/router\";\n\n@Component({\n selector: 'page-login',\n templateUrl: './login.component.html',\n styleUrls: ['./login.component.css'],\n changeDetection: ChangeDetectionStrategy.Eager,\n standalone: false\n})\nexport class LoginComponent implements OnInit {\n\n constructor(private oauthService: OAuthService, private activatedRoute: ActivatedRoute) {\n }\n\n async ngOnInit() {\n const returnUrl = this.activatedRoute.snapshot.queryParams[\"returnUrl\"] ?? '/home';\n\n console.log('[Login] returnUrl', this.activatedRoute.snapshot.queryParams[\"returnUrl\"]);\n\n await this.login(returnUrl);\n }\n\n async login(returnUrl: string) {\n await this.oauthService.loadDiscoveryDocument();\n this.oauthService.initLoginFlow(returnUrl);\n }\n}\n","<div class=\"p-4 text-center\">\n <p>{{'We are redirecting you to login page...' | translate }}</p>\n</div>\n","import {Component, OnInit, ChangeDetectionStrategy} from '@angular/core';\nimport {ActivatedRoute, Router} from \"@angular/router\";\nimport {OAuthService} from \"angular-oauth2-oidc\";\nimport {delay, filter} from \"rxjs/operators\";\n\n@Component({\n selector: 'page-login-completed',\n templateUrl: './login-completed.component.html',\n styleUrls: ['./login-completed.component.css'],\n changeDetection: ChangeDetectionStrategy.Eager,\n standalone: false\n})\nexport class LoginCompletedComponent implements OnInit {\n\n constructor(private router: Router, private activatedRoute: ActivatedRoute, private oauthService: OAuthService) {\n }\n\n async ngOnInit() {\n this.oauthService.events.pipe(\n filter(e => e.type === \"token_received\"),\n delay(2000)\n ).subscribe((e) => {\n // `this.oauthService.state` contains the redirect url after login, if any\n let redirectUrl = '';\n if (this.oauthService.state) {\n redirectUrl = appRelativeUrl(decodeURIComponent(decodeURIComponent(this.oauthService.state)));\n }\n\n this.router.navigateByUrl(redirectUrl);\n });\n\n await this.oauthService.loadDiscoveryDocumentAndTryLogin({disableNonceCheck: true});\n }\n\n}\n\n/**\n * The return URL when it is a path of this application (`/…`), otherwise `''` (the app root). The OAuth `state`\n * round-trips through the browser, so an absolute or protocol-relative URL (`https://…`, `//…`, `/\\…`) is not\n * followed.\n */\nexport function appRelativeUrl(url: string): string {\n return url.startsWith('/') && !url.startsWith('//') && !url.startsWith('/\\\\') ? url : '';\n}\n","<div class=\"container p-4\">\n <h1>{{'Login completed' | translate }}</h1>\n <p>{{'Just to confirm that you did it right!' | translate}}</p>\n\n <p>{{'We are now redirecting you to the requested page...' | translate}}</p>\n</div>\n","import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core';\nimport {OAuthService} from \"angular-oauth2-oidc\";\n\n@Component({\n selector: 'page-logout',\n templateUrl: './logout.component.html',\n styleUrls: ['./logout.component.css'],\n changeDetection: ChangeDetectionStrategy.Eager,\n standalone: false\n})\nexport class LogoutComponent implements OnInit {\n\n constructor(private oauthService: OAuthService) { }\n\n async ngOnInit() {\n await this.oauthService.loadDiscoveryDocument();\n await this.oauthService.revokeTokenAndLogout();\n }\n\n}\n","<div class=\"pt-4 text-center\">\n <p>{{'We are logging you out...'| translate}}</p>\n</div>\n","import {Component, ChangeDetectionStrategy} from '@angular/core';\n\n@Component({\n selector: 'page-logout-completed',\n templateUrl: './logout-completed.component.html',\n styleUrls: ['./logout-completed.component.css'],\n changeDetection: ChangeDetectionStrategy.Eager,\n standalone: false\n})\nexport class LogoutCompletedComponent {\n}\n","<div class=\"container pt-4\">\n <h1>{{'Logout' | translate}}</h1>\n <p>{{'You successfully logged out from the application.' | translate}}</p>\n\n <p>{{'If you want to access the application again,' | translate}} <a routerLink=\"../login\">{{'log in' | translate}}</a>.</p>\n</div>\n","import {Component, ChangeDetectionStrategy} from '@angular/core';\nimport {ActivatedRoute} from '@angular/router';\n\nconst DEFAULT_MESSAGE = 'You are unauthorized to access this resource.';\n\nconst REASON_MESSAGES: {[reason: string]: string} = {\n 'tenant-mismatch': 'Your session belongs to a different tenant. Sign out, then sign in again to access this tenant.',\n 'role-mismatch': 'You do not have the required role to access this resource.',\n};\n\n@Component({\n selector: 'page-unauthorized',\n templateUrl: './unauthorized.component.html',\n changeDetection: ChangeDetectionStrategy.Eager,\n standalone: false\n})\nexport class UnauthorizedComponent {\n message: string;\n\n constructor(activatedRoute: ActivatedRoute) {\n var reason = activatedRoute.snapshot.queryParams['reason'];\n this.message = REASON_MESSAGES[reason] ?? DEFAULT_MESSAGE;\n }\n}\n","<div class=\"container p-4\">\n <h1>{{'Unauthorized' | translate }}</h1>\n <p>{{ message | translate}}</p>\n </div>\n ","import { HttpClient } from '@angular/common/http';\nimport {Component, OnInit, ChangeDetectionStrategy} from '@angular/core';\nimport {OAuthService} from \"angular-oauth2-oidc\";\n\n@Component({\n selector: 'page-user-info',\n templateUrl: './user-info.component.html',\n styleUrls: ['./user-info.component.css'],\n changeDetection: ChangeDetectionStrategy.Eager,\n standalone: false\n})\nexport class UserInfoComponent implements OnInit {\n\n userInfo = '';\n accessToken = '';\n idToken = '';\n\n constructor(private oauthService: OAuthService, private http: HttpClient) {\n }\n\n async ngOnInit() {\n this.accessToken = this.oauthService.getAccessToken();\n this.idToken = this.oauthService.getIdToken();\n\n console.log(this.oauthService.getIdentityClaims());\n\n await this.oauthService.loadDiscoveryDocument();\n\n this.oauthService.loadUserProfile().then(info => {\n this.userInfo = JSON.stringify(info, null, 2);\n });\n\n }\n}\n","<h1>{{'User info' | translate}} </h1>\n<pre>{{userInfo}}</pre>\n\n<h5>{{'Access Token' | translate}}</h5>\n<pre>{{accessToken}}</pre>\n\n<h5>{{'ID Token' | translate}}</h5>\n<pre>{{idToken}}</pre>\n","export class AuthModuleConfig{\n basePath: string = \"\";\n\n /**\n * Base URLs the AuthInterceptor sends the bearer token to; a request matches when its URL equals one of them or\n * continues it with `/` or `?`. An empty string matches relative URLs.\n *\n * Unset: the app's own origin only (relative URLs and `window.location.origin`), so the identity server, CDNs\n * and third-party APIs never see the token. List every API host the app calls with the token.\n *\n * `['*']` restores the pre-2.0 behaviour — the token on every request, whatever the host. A migration aid only:\n * it leaks the token to any host the app happens to call.\n */\n allowedUrls?: string[];\n\n /**\n * Renew the access token with the refresh token shortly before it expires (needs the `offline_access` scope).\n * Default false: an app that renews the token itself (e.g. `@hd/layout`'s `provideHdStation`) must not do it twice,\n * or a rotating refresh token is redeemed twice and the second request fails.\n */\n automaticRefresh?: boolean;\n}\n","import { Injectable } from '@angular/core';\nimport { OAuthService } from 'angular-oauth2-oidc';\n\n/**\n * Renews the access token with the refresh token. Concurrent callers — the interceptor's 401 retries, the guard and\n * the expiry timer — share one request, so a rotating refresh token is redeemed once.\n */\n@Injectable({\n providedIn: 'root'\n})\nexport class AuthTokenRefresher {\n private refreshing?: Promise<boolean>;\n\n constructor(private oauthService: OAuthService) {}\n\n /** True when a refresh token is stored, so an expired session can be renewed without a login round-trip. */\n canRefresh(): boolean {\n return !!this.oauthService.getRefreshToken();\n }\n\n /** Resolves true when a new access token was obtained; never rejects. */\n refresh(): Promise<boolean> {\n if (!this.canRefresh()) {\n return Promise.resolve(false);\n }\n this.refreshing ??= this.doRefresh().finally(() => (this.refreshing = undefined));\n return this.refreshing;\n }\n\n private async doRefresh(): Promise<boolean> {\n try {\n // The token endpoint comes from the discovery document, which a page outside AuthGuard may not have loaded.\n if (!this.oauthService.discoveryDocumentLoaded) {\n await this.oauthService.loadDiscoveryDocument();\n }\n await this.oauthService.refreshToken();\n return this.oauthService.hasValidAccessToken();\n } catch {\n return false;\n }\n }\n}\n","import { HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';\nimport { Injectable, isDevMode } from '@angular/core';\nimport { OAuthService } from 'angular-oauth2-oidc';\nimport { Observable, from, throwError } from 'rxjs';\nimport { catchError, switchMap } from 'rxjs/operators';\nimport { AuthModuleConfig } from './auth-module.config';\nimport { AuthTokenRefresher } from './auth-token-refresher';\n\nlet warnedUnrestricted = false;\n\n/**\n * Adds `Authorization: Bearer …` to requests for {@link AuthModuleConfig.allowedUrls} (the app's own origin when that\n * is unset). With a refresh token stored, an expired token is renewed before the request, and a 401 renews it and\n * retries once.\n */\n@Injectable()\nexport class AuthInterceptor implements HttpInterceptor {\n\n constructor(private auth: OAuthService, private options: AuthModuleConfig, private refresher: AuthTokenRefresher) {}\n\n intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {\n if (!this.isAllowed(req.url)) {\n return next.handle(req);\n }\n\n const send = () => next.handle(this.withToken(req));\n if (this.isIdentityServer(req.url)) {\n // The discovery and token requests the refresh itself makes: renewing here would wait on itself.\n return send();\n }\n const first$ = !this.auth.hasValidAccessToken() && this.refresher.canRefresh()\n ? from(this.refresher.refresh()).pipe(switchMap(send))\n : send();\n\n return first$.pipe(\n catchError((error: unknown) => {\n if (error instanceof HttpErrorResponse && error.status === 401 && this.refresher.canRefresh()) {\n return from(this.refresher.refresh()).pipe(\n switchMap((renewed) => renewed ? send() : throwError(() => error))\n );\n }\n return throwError(() => error);\n })\n );\n }\n\n private withToken(req: HttpRequest<any>): HttpRequest<any> {\n if (!this.auth.hasValidAccessToken()) {\n return req;\n }\n // Clone the request and replace the original headers with cloned headers, updated with the authorization.\n return req.clone({\n headers: req.headers.set('Authorization', `Bearer ${this.auth.getAccessToken()}`)\n });\n }\n\n private isIdentityServer(url: string): boolean {\n const urls = [this.auth.issuer, this.auth.tokenEndpoint].filter((u): u is string => !!u);\n return urls.some((u) => matches(url, u));\n }\n\n private isAllowed(url: string): boolean {\n const allowed = this.options?.allowedUrls ?? ['', ownOrigin()];\n if (allowed.includes('*')) {\n if (isDevMode() && !warnedUnrestricted) {\n warnedUnrestricted = true;\n console.warn('[@juice-js/auth] AuthModuleConfig.allowedUrls is [\\'*\\']: the access token is sent with every '\n + 'request, to any host. List the APIs that should receive it instead.');\n }\n return true;\n }\n return allowed.some((base) => matches(url, base));\n }\n}\n\n/** The default allow-list's absolute entry; empty outside a browser, which leaves relative URLs only. */\nfunction ownOrigin(): string {\n return typeof window !== 'undefined' && window.location?.origin ? window.location.origin : '';\n}\n\n/** `url` is `base` or continues it with `/` or `?`; an empty base (the app's own origin) matches relative URLs only. */\nfunction matches(url: string, base: string): boolean {\n if (!base) {\n return !/^[a-z][a-z0-9+.-]*:\\/\\//i.test(url) && !url.startsWith('//');\n }\n const trimmed = base.replace(/\\/+$/, '');\n return url === trimmed || url.startsWith(trimmed + '/') || url.startsWith(trimmed + '?');\n}\n","import { EnvironmentProviders, ModuleWithProviders, NgModule, Provider, inject, provideEnvironmentInitializer } from '@angular/core';\nimport { TranslatePipe, TranslateDirective, MissingTranslationHandler, provideChildTranslateService } from '@ngx-translate/core';\n\nimport { LoginComponent } from './pages/login/login.component';\nimport { LoginCompletedComponent } from './pages/login-completed/login-completed.component';\nimport { LogoutComponent } from './pages/logout/logout.component';\nimport { LogoutCompletedComponent } from './pages/logout-completed/logout-completed.component';\nimport { UnauthorizedComponent } from './pages/unauthorized/unauthorized.component';\nimport { UserInfoComponent } from './pages/protected/user-info/user-info.component';\nimport { AuthModuleConfig } from './auth/auth-module.config';\nimport { AuthInterceptor } from './auth/auth.interceptor'\n\nimport { SubmitMissingTranslationHandler } from '@juice-js/localize';\nimport { AuthConfig, OAuthInfoEvent, OAuthService } from 'angular-oauth2-oidc';\nimport { filter } from 'rxjs/operators';\nimport { AuthTokenRefresher } from './auth/auth-token-refresher';\nimport { MatDialogModule } from '@angular/material/dialog';\nimport { TenantService } from '@juice-js/core';\nimport { HTTP_INTERCEPTORS } from '@angular/common/http';\n\n@NgModule({\n declarations: [\n LoginComponent,\n LoginCompletedComponent,\n LogoutComponent,\n LogoutCompletedComponent,\n UnauthorizedComponent,\n UserInfoComponent\n ],\n imports: [\n TranslatePipe,\n TranslateDirective,\n MatDialogModule\n ],\n exports: [\n ],\n providers: [\n provideChildTranslateService({\n missingTranslationHandler: {\n provide: MissingTranslationHandler,\n useClass: SubmitMissingTranslationHandler\n }\n })\n ]\n})\nexport class AuthModule {\n public static forRoot(options : any): ModuleWithProviders<AuthModule> {\n const extra: (Provider | EnvironmentProviders)[] = options?.automaticRefresh\n ? [provideEnvironmentInitializer(renewBeforeExpiry)]\n : [];\n return {\n ngModule: AuthModule,\n providers: [\n ...extra,\n {\n provide: HTTP_INTERCEPTORS,\n useClass: AuthInterceptor,\n multi: true\n },\n {\n provide: AuthModuleConfig,\n useValue: options\n },\n {\n provide: AuthConfig,\n useFactory: (tenantService: TenantService) : AuthConfig => {\n // Create config from options\n var authConfig = new AuthConfig(options);\n // Replace :tenant with the current tenant\n if(tenantService){\n let identifier = '/' + tenantService.currentTenant?.identifier||'';\n authConfig.issuer = options.issuer?.replace('/:tenant', identifier);\n authConfig.redirectUri = options.redirectUri?.replace('/:tenant', identifier);\n authConfig.postLogoutRedirectUri = options.postLogoutRedirectUri?.replace('/:tenant', identifier);\n }\n return authConfig;\n },\n deps: [TenantService]\n }\n ]\n }\n }\n}\n\n/**\n * `AuthModuleConfig.automaticRefresh`: OAuthService fires `token_expires` at its timeoutFactor (75% of the lifetime\n * by default); renew the access token then, through the shared AuthTokenRefresher.\n */\nfunction renewBeforeExpiry(): void {\n const oauthService = inject(OAuthService);\n const refresher = inject(AuthTokenRefresher);\n oauthService.events\n .pipe(filter((e): e is OAuthInfoEvent => e.type === 'token_expires' && (e as OAuthInfoEvent).info === 'access_token'))\n .subscribe(() => void refresher.refresh());\n}\n","import {Injectable, Optional} from '@angular/core';\nimport {ActivatedRouteSnapshot, Router, RouterStateSnapshot, UrlTree} from '@angular/router';\nimport {OAuthService} from 'angular-oauth2-oidc';\nimport {from} from \"rxjs\";\nimport {map} from \"rxjs/operators\";\nimport { AuthModuleConfig } from './auth-module.config';\nimport { TenantService } from '@juice-js/core';\nimport { AuthTokenRefresher } from './auth-token-refresher';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class AuthGuard {\n path: string;\n constructor(private router: Router, private oauthService: OAuthService,\n private options: AuthModuleConfig, @Optional() private tenantService: TenantService,\n private refresher: AuthTokenRefresher){\n this.path = new URL(this.options.basePath).pathname;\n if(tenantService){\n var identifier = '/' + tenantService.currentTenant?.identifier||'';\n this.path = this.path.replace('/:tenant', identifier);\n }\n }\n\n canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {\n if (this.hasValidToken()) {\n return this.authorize(route);\n }\n\n return from(this.restoreSession()).pipe(\n map(() => {\n if (this.hasValidToken()) {\n return this.authorize(route);\n }\n\n return this.router.createUrlTree([`${this.path}/login`], {queryParams: {returnUrl: state.url}});\n })\n )\n }\n\n /** Completes an OIDC callback if this is one; otherwise renews an expired session with the refresh token. */\n private async restoreSession(): Promise<void> {\n await this.oauthService.loadDiscoveryDocumentAndTryLogin({disableNonceCheck: true});\n if (!this.hasValidToken() && this.refresher.canRefresh()) {\n await this.refresher.refresh();\n }\n }\n\n /** The tenant and role checks, for a session found valid or just restored. */\n private authorize(route: ActivatedRouteSnapshot): true | UrlTree {\n if(!this.hasValidTenant()){\n // Re-authenticating cannot fix a tenant mismatch: the IdP would hand back the\n // same issuer and the /login redirect would bounce straight back here.\n return this.router.createUrlTree([`${this.path}/unauthorized`], {queryParams: {reason: 'tenant-mismatch'}});\n }\n if(this.hasValidRole(route)){\n return true;\n }\n return this.router.createUrlTree([`${this.path}/unauthorized`], {queryParams: {reason: 'role-mismatch'}});\n }\n\n private hasValidRole(route: ActivatedRouteSnapshot){\n const claims = this.oauthService.getIdentityClaims();\n var {roles} = route.data;\n var {role} = claims;\n\n if(roles\n && ((typeof role ==\"string\" && !roles.includes(role))\n || ( Array.isArray(role) && !role.some(r=> roles.includes(r))))){\n return false;\n }\n return true;\n }\n\n private hasValidToken() {\n return this.oauthService.hasValidAccessToken() && this.oauthService.hasValidIdToken();\n }\n\n private hasValidTenant(){\n if(!this.tenantService){\n return true;\n }\n const claims = this.oauthService.getIdentityClaims();\n var tenant = this.tenantService?.currentTenant?.identifier;\n var issuer = claims['iss'];\n return !tenant || this.getTenantFromIssuer(issuer) === tenant;\n }\n\n private getTenantFromIssuer(issuer: string){\n var match = issuer.match(/\\/([^\\/]+)\\/?$/);\n return match?.[1];\n }\n}\n","import { Injectable } from '@angular/core';\nimport { OAuthEvent, OAuthService } from 'angular-oauth2-oidc';\nimport { BehaviorSubject, Observable } from 'rxjs';\nimport { distinctUntilChanged, filter, skip } from 'rxjs/operators';\n\n/** The OAuth events after which the signed-in user may be someone else, or nobody. */\nconst USER_EVENTS: readonly OAuthEvent['type'][] = [\n 'token_received', 'token_refreshed', 'token_refresh_error', 'logout', 'session_terminated', 'session_error',\n];\n\n/**\n * Who is signed in, as a stable key (the `sub` claim), for anything that caches per user — menus, permissions,\n * profile data — and must start over when the user changes.\n *\n * A session whose access token expired but can still be refreshed counts as the same user, so a page reload or a\n * token renewal is not reported as a sign-in.\n *\n * ```ts\n * inject(AuthSession).changes.subscribe(() => this.cache.clear());\n * ```\n */\n@Injectable({\n providedIn: 'root'\n})\nexport class AuthSession {\n private readonly key$: BehaviorSubject<string | null>;\n\n /** The current user key (`null` = nobody), then every change. */\n readonly user$: Observable<string | null>;\n /** Every change after the current value: sign-in (`null` → key), sign-out (key → `null`), another user. */\n readonly changes: Observable<string | null>;\n\n constructor(private oauthService: OAuthService) {\n this.key$ = new BehaviorSubject(this.readKey());\n this.user$ = this.key$.pipe(distinctUntilChanged());\n this.changes = this.user$.pipe(skip(1));\n this.oauthService.events\n .pipe(filter((e) => USER_EVENTS.includes(e.type)))\n .subscribe(() => this.key$.next(this.readKey()));\n }\n\n /** The signed-in user's key now; `null` when nobody is. */\n get userKey(): string | null {\n return this.key$.value;\n }\n\n private readKey(): string | null {\n if (!this.oauthService.hasValidAccessToken() && !this.oauthService.getRefreshToken()) {\n return null;\n }\n const claims = this.oauthService.getIdentityClaims() as Record<string, unknown> | null;\n const sub = claims?.['sub'] ?? subOf(this.oauthService.getAccessToken());\n return typeof sub === 'string' && sub ? sub : null;\n }\n}\n\n/** The `sub` of a JWT access token, unverified (a key only; the APIs verify the token). */\nfunction subOf(token: string | null | undefined): unknown {\n const payload = token?.split('.')[1];\n if (!payload) {\n return undefined;\n }\n try {\n return JSON.parse(atob(payload.replace(/-/g, '+').replace(/_/g, '/')))['sub'];\n } catch {\n return undefined;\n }\n}\n","import { NgModule } from '@angular/core';\nimport { RouterModule, Routes } from '@angular/router';\nimport { LogoutCompletedComponent } from \"../pages/logout-completed/logout-completed.component\";\nimport { LoginComponent } from \"../pages/login/login.component\";\nimport { LoginCompletedComponent } from \"../pages/login-completed/login-completed.component\";\nimport { UserInfoComponent } from \"../pages/protected/user-info/user-info.component\";\nimport { LogoutComponent } from \"../pages/logout/logout.component\";\nimport { UnauthorizedComponent } from '../pages/unauthorized/unauthorized.component';\nimport { AuthGuard } from './auth.guard';\nimport { DevGuard } from '@juice-js/layout';\n\nconst routes: Routes = [\n {path: 'login', component: LoginComponent, title: 'Login'},\n {path: 'login-completed', component: LoginCompletedComponent, title: 'Login completed'},\n {path: 'logout', component: LogoutComponent},\n {path: 'logout-completed', component: LogoutCompletedComponent, title: 'Logout completed'},\n {path: 'unauthorized', component: UnauthorizedComponent, title: 'Unauthorized'},\n {path: 'user-info', component: UserInfoComponent, canActivate: [AuthGuard, DevGuard], title: 'User info',\n data:{\n menuDisplay: [DevGuard],\n menuIcon: 'account_circle',\n menuOrder: 100,\n }},\n {path: '', redirectTo: 'user-info', pathMatch: 'full'},\n];\n\n@NgModule({\n imports: [RouterModule.forChild(routes)],\n exports: [RouterModule],\n})\nexport class AuthRoutingModule{\n \n}","/*\n * Public API Surface of auth\n */\n\nexport * from './lib/auth.module';\nexport * from './lib/auth/auth.guard';\nexport * from './lib/auth/auth.interceptor';\nexport * from './lib/auth/auth-token-refresher';\nexport * from './lib/auth/auth-session';\nexport * from './lib/auth/auth-module.config';\nexport * from './lib/auth/auth-routing.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i2","i1","i2.AuthModuleConfig","i3.AuthTokenRefresher","i3.AuthModuleConfig","i5.AuthTokenRefresher"],"mappings":";;;;;;;;;;;;;;;;;;MAWa,cAAc,CAAA;IAEzB,WAAA,CAAoB,YAA0B,EAAU,cAA8B,EAAA;QAAlE,IAAA,CAAA,YAAY,GAAZ,YAAY;QAAwB,IAAA,CAAA,cAAc,GAAd,cAAc;IACtE;AAEA,IAAA,MAAM,QAAQ,GAAA;AACZ,QAAA,MAAM,SAAS,GAAG,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,WAAW,CAAC,WAAW,CAAC,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,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;oBACxC,OAAO,EAAE,CAAC,YAAY,CAAC;AACxB,iBAAA;;;AC7BD;;AAEG;;ACFH;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juice-js/auth",
3
- "version": "1.3.0-alpha.2",
3
+ "version": "2.0.0-alpha.1",
4
4
  "description": "Provides authentication and authorization for applications.",
5
5
  "author": {
6
6
  "name": "jack@creatorflow.io"
@@ -19,7 +19,7 @@
19
19
  "url": "git+https://github.com/creatorflow-io/juice-layout.git"
20
20
  },
21
21
  "peerDependencies": {
22
- "@juice-js/layout": "1.3.0-alpha.2"
22
+ "@juice-js/layout": "2.0.0-alpha.1"
23
23
  },
24
24
  "dependencies": {
25
25
  "tslib": "^2.3.0"
@@ -38,5 +38,5 @@
38
38
  },
39
39
  "type": "module",
40
40
  "readme": "ERROR: No README data found!",
41
- "_id": "@juice-js/auth@1.3.0-alpha.2"
41
+ "_id": "@juice-js/auth@2.0.0-alpha.1"
42
42
  }
@@ -1,13 +1,13 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { OnInit, ModuleWithProviders } from '@angular/core';
3
3
  import { OAuthService } from 'angular-oauth2-oidc';
4
- import * as _angular_router from '@angular/router';
5
- import { ActivatedRoute, Router, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
6
- import * as _angular_common_http from '@angular/common/http';
7
- import { HttpClient, HttpInterceptor, HttpRequest, HttpHandler } from '@angular/common/http';
4
+ import * as i1 from '@angular/router';
5
+ import { ActivatedRoute, Router, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree } from '@angular/router';
6
+ import { HttpClient, HttpInterceptor, HttpRequest, HttpHandler, HttpEvent } from '@angular/common/http';
8
7
  import * as i7 from '@ngx-translate/core';
9
8
  import * as i8 from '@angular/material/dialog';
10
9
  import * as rxjs from 'rxjs';
10
+ import { Observable } from 'rxjs';
11
11
  import { TenantService } from '@juice-js/core';
12
12
 
13
13
  declare class LoginComponent implements OnInit {
@@ -71,6 +71,40 @@ declare class AuthModule {
71
71
 
72
72
  declare class AuthModuleConfig {
73
73
  basePath: string;
74
+ /**
75
+ * Base URLs the AuthInterceptor sends the bearer token to; a request matches when its URL equals one of them or
76
+ * continues it with `/` or `?`. An empty string matches relative URLs.
77
+ *
78
+ * Unset: the app's own origin only (relative URLs and `window.location.origin`), so the identity server, CDNs
79
+ * and third-party APIs never see the token. List every API host the app calls with the token.
80
+ *
81
+ * `['*']` restores the pre-2.0 behaviour — the token on every request, whatever the host. A migration aid only:
82
+ * it leaks the token to any host the app happens to call.
83
+ */
84
+ allowedUrls?: string[];
85
+ /**
86
+ * Renew the access token with the refresh token shortly before it expires (needs the `offline_access` scope).
87
+ * Default false: an app that renews the token itself (e.g. `@hd/layout`'s `provideHdStation`) must not do it twice,
88
+ * or a rotating refresh token is redeemed twice and the second request fails.
89
+ */
90
+ automaticRefresh?: boolean;
91
+ }
92
+
93
+ /**
94
+ * Renews the access token with the refresh token. Concurrent callers — the interceptor's 401 retries, the guard and
95
+ * the expiry timer — share one request, so a rotating refresh token is redeemed once.
96
+ */
97
+ declare class AuthTokenRefresher {
98
+ private oauthService;
99
+ private refreshing?;
100
+ constructor(oauthService: OAuthService);
101
+ /** True when a refresh token is stored, so an expired session can be renewed without a login round-trip. */
102
+ canRefresh(): boolean;
103
+ /** Resolves true when a new access token was obtained; never rejects. */
104
+ refresh(): Promise<boolean>;
105
+ private doRefresh;
106
+ static ɵfac: i0.ɵɵFactoryDeclaration<AuthTokenRefresher, never>;
107
+ static ɵprov: i0.ɵɵInjectableDeclaration<AuthTokenRefresher>;
74
108
  }
75
109
 
76
110
  declare class AuthGuard {
@@ -78,29 +112,70 @@ declare class AuthGuard {
78
112
  private oauthService;
79
113
  private options;
80
114
  private tenantService;
115
+ private refresher;
81
116
  path: string;
82
- constructor(router: Router, oauthService: OAuthService, options: AuthModuleConfig, tenantService: TenantService);
83
- canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): true | _angular_router.UrlTree | rxjs.Observable<true | _angular_router.UrlTree>;
117
+ constructor(router: Router, oauthService: OAuthService, options: AuthModuleConfig, tenantService: TenantService, refresher: AuthTokenRefresher);
118
+ canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): true | UrlTree | rxjs.Observable<true | UrlTree>;
119
+ /** Completes an OIDC callback if this is one; otherwise renews an expired session with the refresh token. */
120
+ private restoreSession;
121
+ /** The tenant and role checks, for a session found valid or just restored. */
122
+ private authorize;
84
123
  private hasValidRole;
85
124
  private hasValidToken;
86
125
  private hasValidTenant;
87
126
  private getTenantFromIssuer;
88
- static ɵfac: i0.ɵɵFactoryDeclaration<AuthGuard, [null, null, null, { optional: true; }]>;
127
+ static ɵfac: i0.ɵɵFactoryDeclaration<AuthGuard, [null, null, null, { optional: true; }, null]>;
89
128
  static ɵprov: i0.ɵɵInjectableDeclaration<AuthGuard>;
90
129
  }
91
130
 
131
+ /**
132
+ * Adds `Authorization: Bearer …` to requests for {@link AuthModuleConfig.allowedUrls} (the app's own origin when that
133
+ * is unset). With a refresh token stored, an expired token is renewed before the request, and a 401 renews it and
134
+ * retries once.
135
+ */
92
136
  declare class AuthInterceptor implements HttpInterceptor {
93
137
  private auth;
94
- constructor(auth: OAuthService);
95
- intercept(req: HttpRequest<any>, next: HttpHandler): rxjs.Observable<_angular_common_http.HttpEvent<any>>;
138
+ private options;
139
+ private refresher;
140
+ constructor(auth: OAuthService, options: AuthModuleConfig, refresher: AuthTokenRefresher);
141
+ intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>;
142
+ private withToken;
143
+ private isIdentityServer;
144
+ private isAllowed;
96
145
  static ɵfac: i0.ɵɵFactoryDeclaration<AuthInterceptor, never>;
97
146
  static ɵprov: i0.ɵɵInjectableDeclaration<AuthInterceptor>;
98
147
  }
99
148
 
149
+ /**
150
+ * Who is signed in, as a stable key (the `sub` claim), for anything that caches per user — menus, permissions,
151
+ * profile data — and must start over when the user changes.
152
+ *
153
+ * A session whose access token expired but can still be refreshed counts as the same user, so a page reload or a
154
+ * token renewal is not reported as a sign-in.
155
+ *
156
+ * ```ts
157
+ * inject(AuthSession).changes.subscribe(() => this.cache.clear());
158
+ * ```
159
+ */
160
+ declare class AuthSession {
161
+ private oauthService;
162
+ private readonly key$;
163
+ /** The current user key (`null` = nobody), then every change. */
164
+ readonly user$: Observable<string | null>;
165
+ /** Every change after the current value: sign-in (`null` → key), sign-out (key → `null`), another user. */
166
+ readonly changes: Observable<string | null>;
167
+ constructor(oauthService: OAuthService);
168
+ /** The signed-in user's key now; `null` when nobody is. */
169
+ get userKey(): string | null;
170
+ private readKey;
171
+ static ɵfac: i0.ɵɵFactoryDeclaration<AuthSession, never>;
172
+ static ɵprov: i0.ɵɵInjectableDeclaration<AuthSession>;
173
+ }
174
+
100
175
  declare class AuthRoutingModule {
101
176
  static ɵfac: i0.ɵɵFactoryDeclaration<AuthRoutingModule, never>;
102
- static ɵmod: i0.ɵɵNgModuleDeclaration<AuthRoutingModule, never, [typeof _angular_router.RouterModule], [typeof _angular_router.RouterModule]>;
177
+ static ɵmod: i0.ɵɵNgModuleDeclaration<AuthRoutingModule, never, [typeof i1.RouterModule], [typeof i1.RouterModule]>;
103
178
  static ɵinj: i0.ɵɵInjectorDeclaration<AuthRoutingModule>;
104
179
  }
105
180
 
106
- export { AuthGuard, AuthInterceptor, AuthModule, AuthModuleConfig, AuthRoutingModule };
181
+ export { AuthGuard, AuthInterceptor, AuthModule, AuthModuleConfig, AuthRoutingModule, AuthSession, AuthTokenRefresher };