@franzzemen/brokenstock-shell 0.0.42 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,7 +5,7 @@ import { Router, RouterLink, RouterLinkActive, ActivatedRoute, RouterOutlet } fr
|
|
|
5
5
|
import { HttpHeader, BEARER_TOKEN_REGEX, USERNAME_REGEX, PASSWORD_REGEX } from '@franzzemen/utility';
|
|
6
6
|
import { validateCredentials } from '@franzzemen/identity';
|
|
7
7
|
import { HttpClient } from '@angular/common/http';
|
|
8
|
-
import {
|
|
8
|
+
import { catchError, from, switchMap, throwError, firstValueFrom } from 'rxjs';
|
|
9
9
|
import * as i3 from '@angular/forms';
|
|
10
10
|
import { NG_VALIDATORS, FormsModule } from '@angular/forms';
|
|
11
11
|
import { Marked } from 'marked';
|
|
@@ -84,9 +84,7 @@ class AuthenticationService {
|
|
|
84
84
|
...(ngDevMode ? [{ debugName: "authenticating" }] : /* istanbul ignore next */ []));
|
|
85
85
|
this.userSession = signal(undefined, /* @ts-ignore */
|
|
86
86
|
...(ngDevMode ? [{ debugName: "userSession" }] : /* istanbul ignore next */ []));
|
|
87
|
-
|
|
88
|
-
...(ngDevMode ? [{ debugName: "effectivePermissions" }] : /* istanbul ignore next */ []));
|
|
89
|
-
/** First-class plan-feature grants for the current session (supersedes effectivePermissions). */
|
|
87
|
+
/** Plan-feature grants for the current session. Absent key = not granted. */
|
|
90
88
|
this.features = signal({}, /* @ts-ignore */
|
|
91
89
|
...(ngDevMode ? [{ debugName: "features" }] : /* istanbul ignore next */ []));
|
|
92
90
|
this.conflictSessions = signal(undefined, /* @ts-ignore */
|
|
@@ -186,7 +184,6 @@ class AuthenticationService {
|
|
|
186
184
|
// @ts-ignore
|
|
187
185
|
delete authResponse.session.token;
|
|
188
186
|
this.userSession.set(authResponse.session);
|
|
189
|
-
this.effectivePermissions.set(authResponse.effectivePermissions ?? {});
|
|
190
187
|
this.features.set(authResponse.features ?? {});
|
|
191
188
|
const auth = response.headers.get(HttpHeader.Authorization);
|
|
192
189
|
if (!auth || !BEARER_TOKEN_REGEX.test(auth)) {
|
|
@@ -245,7 +242,6 @@ class AuthenticationService {
|
|
|
245
242
|
const body = await response.json();
|
|
246
243
|
this.#auth = auth;
|
|
247
244
|
this.userSession.set(body.session);
|
|
248
|
-
this.effectivePermissions.set(body.effectivePermissions ?? {});
|
|
249
245
|
this.features.set(body.features ?? {});
|
|
250
246
|
return true;
|
|
251
247
|
}
|
|
@@ -256,7 +252,6 @@ class AuthenticationService {
|
|
|
256
252
|
#clearSession() {
|
|
257
253
|
this.authenticated.set(false);
|
|
258
254
|
this.userSession.set(undefined);
|
|
259
|
-
this.effectivePermissions.set({});
|
|
260
255
|
this.features.set({});
|
|
261
256
|
this.conflictSessions.set(undefined);
|
|
262
257
|
this.pendingCredentials.set(undefined);
|
|
@@ -297,13 +292,7 @@ const authInterceptor = (req, next) => {
|
|
|
297
292
|
const thinkingService = inject(ThinkingService);
|
|
298
293
|
const authUrls = inject(SHELL_AUTH_URLS);
|
|
299
294
|
const router = inject(Router);
|
|
300
|
-
return next(req).pipe(
|
|
301
|
-
next: (event) => {
|
|
302
|
-
if ('headers' in event && event.headers?.get('x-permissions-stale') === 'true') {
|
|
303
|
-
authService.refresh();
|
|
304
|
-
}
|
|
305
|
-
},
|
|
306
|
-
}), catchError((error) => {
|
|
295
|
+
return next(req).pipe(catchError((error) => {
|
|
307
296
|
const isRefreshOrLogin = req.url === authUrls.refresh || req.url === authUrls.login;
|
|
308
297
|
if (error.status === 401 && !isRefreshOrLogin) {
|
|
309
298
|
return from(authService.refresh()).pipe(switchMap((refreshed) => {
|