@acorex/platform 20.1.0 → 20.2.0-next.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.
- package/auth/index.d.ts +12 -29
- package/fesm2022/acorex-platform-auth.mjs +103 -181
- package/fesm2022/acorex-platform-auth.mjs.map +1 -1
- package/fesm2022/acorex-platform-themes-default.mjs +14 -24
- package/fesm2022/acorex-platform-themes-default.mjs.map +1 -1
- package/fesm2022/{acorex-platform-themes-shared-color-chooser-view.component-ChOhTEqX.mjs → acorex-platform-themes-shared-color-chooser-column.component-EZGn900W.mjs} +6 -7
- package/fesm2022/acorex-platform-themes-shared-color-chooser-column.component-EZGn900W.mjs.map +1 -0
- package/fesm2022/acorex-platform-themes-shared-color-chooser-view.component-DTLYX00a.mjs +49 -0
- package/fesm2022/acorex-platform-themes-shared-color-chooser-view.component-DTLYX00a.mjs.map +1 -0
- package/fesm2022/{acorex-platform-themes-shared-icon-chooser-view.component-SXfawqIa.mjs → acorex-platform-themes-shared-icon-chooser-view.component-DMPET9Fu.mjs} +10 -11
- package/fesm2022/acorex-platform-themes-shared-icon-chooser-view.component-DMPET9Fu.mjs.map +1 -0
- package/fesm2022/acorex-platform-themes-shared.mjs +56 -39
- package/fesm2022/acorex-platform-themes-shared.mjs.map +1 -1
- package/fesm2022/{acorex-platform-widgets-button-widget-designer.component-BfWr5Wz8.mjs → acorex-platform-widgets-button-widget-designer.component-BUx-nksc.mjs} +5 -5
- package/fesm2022/{acorex-platform-widgets-button-widget-designer.component-BfWr5Wz8.mjs.map → acorex-platform-widgets-button-widget-designer.component-BUx-nksc.mjs.map} +1 -1
- package/fesm2022/{acorex-platform-widgets-file-list-popup.component-CEPrED5e.mjs → acorex-platform-widgets-file-list-popup.component-n3nuXZNq.mjs} +6 -6
- package/fesm2022/{acorex-platform-widgets-file-list-popup.component-CEPrED5e.mjs.map → acorex-platform-widgets-file-list-popup.component-n3nuXZNq.mjs.map} +1 -1
- package/fesm2022/{acorex-platform-widgets-file-rename-popup.component-DCVTwkGL.mjs → acorex-platform-widgets-file-rename-popup.component-DBRV6X7W.mjs} +8 -8
- package/fesm2022/{acorex-platform-widgets-file-rename-popup.component-DCVTwkGL.mjs.map → acorex-platform-widgets-file-rename-popup.component-DBRV6X7W.mjs.map} +1 -1
- package/fesm2022/{acorex-platform-widgets-rich-text-popup.component-ti6XgNeD.mjs → acorex-platform-widgets-rich-text-popup.component-DPuTM42n.mjs} +3 -3
- package/fesm2022/{acorex-platform-widgets-rich-text-popup.component-ti6XgNeD.mjs.map → acorex-platform-widgets-rich-text-popup.component-DPuTM42n.mjs.map} +1 -1
- package/fesm2022/{acorex-platform-widgets-tabular-data-edit-popup.component-C-OZ-B7h.mjs → acorex-platform-widgets-tabular-data-edit-popup.component-BH1_BkJh.mjs} +5 -5
- package/fesm2022/{acorex-platform-widgets-tabular-data-edit-popup.component-C-OZ-B7h.mjs.map → acorex-platform-widgets-tabular-data-edit-popup.component-BH1_BkJh.mjs.map} +1 -1
- package/fesm2022/{acorex-platform-widgets-tabular-data-view-popup.component-CvPn4SJx.mjs → acorex-platform-widgets-tabular-data-view-popup.component-DCsLuXR9.mjs} +3 -3
- package/fesm2022/{acorex-platform-widgets-tabular-data-view-popup.component-CvPn4SJx.mjs.map → acorex-platform-widgets-tabular-data-view-popup.component-DCsLuXR9.mjs.map} +1 -1
- package/fesm2022/acorex-platform-widgets.mjs +216 -170
- package/fesm2022/acorex-platform-widgets.mjs.map +1 -1
- package/layout/views/index.d.ts +8 -0
- package/package.json +1 -1
- package/themes/default/index.d.ts +10 -1
- package/themes/shared/index.d.ts +4 -0
- package/widgets/index.d.ts +7 -2
- package/fesm2022/acorex-platform-themes-shared-color-chooser-view.component-ChOhTEqX.mjs.map +0 -1
- package/fesm2022/acorex-platform-themes-shared-icon-chooser-view.component-SXfawqIa.mjs.map +0 -1
package/auth/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, TemplateRef, ViewContainerRef, ModuleWithProviders
|
|
2
|
+
import { InjectionToken, TemplateRef, ViewContainerRef, ModuleWithProviders } from '@angular/core';
|
|
3
3
|
import { Observable } from 'rxjs';
|
|
4
4
|
import { AXPLogoConfig, AXPExpressionEvaluatorScopeProvider, AXPExpressionEvaluatorScopeProviderContext } from '@acorex/platform/core';
|
|
5
5
|
import { CanActivateFn } from '@angular/router';
|
|
@@ -165,18 +165,11 @@ interface AXPRefreshTokenResult {
|
|
|
165
165
|
succeed: boolean;
|
|
166
166
|
data?: AXPTokenResult;
|
|
167
167
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
startAuthorizationFlow?(tenantId: string, applicationId: string): Promise<void>;
|
|
174
|
-
completeAuthorizationCodeFlow?(options: {
|
|
175
|
-
code: string;
|
|
176
|
-
redirectUri: string;
|
|
177
|
-
clientId?: string;
|
|
178
|
-
tokenEndpoint?: string;
|
|
179
|
-
}): Promise<void>;
|
|
168
|
+
interface AXPAuthStrategy {
|
|
169
|
+
get name(): string;
|
|
170
|
+
signin(credentials: AXPBaseCredentials): Promise<AXPSignInResult>;
|
|
171
|
+
signout(): Promise<void>;
|
|
172
|
+
refreshToken(context: AXPSessionContext): Promise<AXPRefreshTokenResult>;
|
|
180
173
|
}
|
|
181
174
|
interface AXPSessionData {
|
|
182
175
|
accessToken: string;
|
|
@@ -227,8 +220,6 @@ declare class AXPSessionService {
|
|
|
227
220
|
private readonly applicationLoader;
|
|
228
221
|
private status;
|
|
229
222
|
readonly status$: Observable<AXPSessionStatus>;
|
|
230
|
-
private isLoading;
|
|
231
|
-
readonly isLoading$: Observable<boolean>;
|
|
232
223
|
private currentUserSubject;
|
|
233
224
|
readonly user$: Observable<AXPUser | null>;
|
|
234
225
|
get user(): AXPUser | null;
|
|
@@ -247,16 +238,18 @@ declare class AXPSessionService {
|
|
|
247
238
|
readonly features$: Observable<never[] | AXPFeature[]>;
|
|
248
239
|
get features(): AXPFeature[];
|
|
249
240
|
readonly isAuthenticated$: Observable<boolean>;
|
|
250
|
-
readonly isAuthenticatedWithLoading$: Observable<boolean>;
|
|
251
241
|
readonly isAuthorized$: Observable<boolean>;
|
|
252
242
|
restoreSession(): Promise<void>;
|
|
253
243
|
signin(credentials: AXPBaseCredentials): Promise<void>;
|
|
254
244
|
signout(): Promise<void>;
|
|
255
245
|
refreshToken(): Promise<any>;
|
|
246
|
+
setTenant(tenant: AXPTenant | null): Promise<void>;
|
|
247
|
+
setApplication(application: AXPApplication | null): Promise<void>;
|
|
256
248
|
private loadPermissions;
|
|
257
249
|
private loadFeatures;
|
|
258
250
|
signInComplete(): Promise<void>;
|
|
259
|
-
setSession
|
|
251
|
+
private setSession;
|
|
252
|
+
private updateSession;
|
|
260
253
|
getSessionData(): AXPSessionData | null;
|
|
261
254
|
private clearSession;
|
|
262
255
|
authorize(...keys: string[]): boolean;
|
|
@@ -291,16 +284,6 @@ declare class AXPAuthModule {
|
|
|
291
284
|
static ɵinj: i0.ɵɵInjectorDeclaration<AXPAuthModule>;
|
|
292
285
|
}
|
|
293
286
|
|
|
294
|
-
declare class AXPAuthStrategyRegistryService {
|
|
295
|
-
private strategies;
|
|
296
|
-
private injector;
|
|
297
|
-
constructor(injector: Injector);
|
|
298
|
-
register(...plugins: (new () => AXPAuthStrategy)[]): void;
|
|
299
|
-
get(strategyKey: string): AXPAuthStrategy | undefined;
|
|
300
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<AXPAuthStrategyRegistryService, never>;
|
|
301
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<AXPAuthStrategyRegistryService>;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
287
|
declare class AXPUnauthorizedError extends Error {
|
|
305
288
|
data?: {
|
|
306
289
|
redirectUrl?: string;
|
|
@@ -318,5 +301,5 @@ declare class AXPUnauthenticatedError extends Error {
|
|
|
318
301
|
} | undefined);
|
|
319
302
|
}
|
|
320
303
|
|
|
321
|
-
export { AXPAuthGuard, AXPAuthModule,
|
|
322
|
-
export type { AXPApplication, AXPApplicationLoader, AXPAuthModuleConfigs, AXPBaseCredentials, AXPFeature, AXPFeatureLoader, AXPPermission, AXPPermissionDefinition, AXPPermissionDefinitionProvider, AXPPermissionGroupDefinition, AXPPermissionLoader, AXPRefreshTokenResult, AXPSessionData, AXPSignInResult, AXPTenant, AXPTenantLoader, AXPTokenResult, AXPUser };
|
|
304
|
+
export { AXPAuthGuard, AXPAuthModule, AXPFeatureDirective, AXPFeatureGuard, AXPPermissionDefinitionBuilder, AXPPermissionDefinitionGroupBuilder, AXPPermissionDefinitionProviderContext, AXPPermissionDefinitionService, AXPPermissionDirective, AXPPermissionEvaluatorScopeProvider, AXPPermissionGuard, AXPSessionContext, AXPSessionService, AXPSessionStatus, AXPUnauthenticatedError, AXPUnauthorizedError, AXP_APPLICATION_LOADER, AXP_FEATURE_LOADER, AXP_PERMISSION_DEFINITION_PROVIDER, AXP_PERMISSION_LOADER, AXP_TENANT_LOADER, initializeAppState };
|
|
305
|
+
export type { AXPApplication, AXPApplicationLoader, AXPAuthModuleConfigs, AXPAuthStrategy, AXPBaseCredentials, AXPFeature, AXPFeatureLoader, AXPPermission, AXPPermissionDefinition, AXPPermissionDefinitionProvider, AXPPermissionGroupDefinition, AXPPermissionLoader, AXPRefreshTokenResult, AXPSessionData, AXPSignInResult, AXPTenant, AXPTenantLoader, AXPTokenResult, AXPUser };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { InjectionToken, Injector, Injectable, signal, inject, Input, Directive, provideAppInitializer, Optional, Inject, NgModule } from '@angular/core';
|
|
3
|
-
import { of, map, BehaviorSubject, shareReplay, defaultIfEmpty,
|
|
4
|
-
import { AXPBroadcastEventService } from '@acorex/platform/core';
|
|
5
|
-
import { isEmpty } from 'lodash-es';
|
|
3
|
+
import { of, map, BehaviorSubject, shareReplay, defaultIfEmpty, firstValueFrom, first } from 'rxjs';
|
|
4
|
+
import { AXPBroadcastEventService, AXP_EXPRESSION_EVALUATOR_SCOPE_PROVIDER } from '@acorex/platform/core';
|
|
5
|
+
import { merge, isEmpty } from 'lodash-es';
|
|
6
6
|
|
|
7
7
|
const AXP_APPLICATION_LOADER = new InjectionToken('AXP_APPLICATION_LOADER', {
|
|
8
8
|
providedIn: 'root',
|
|
@@ -21,14 +21,6 @@ class AXPApplicationDefaultLoader {
|
|
|
21
21
|
editionName: 'Standard',
|
|
22
22
|
features: [],
|
|
23
23
|
},
|
|
24
|
-
{
|
|
25
|
-
id: '2',
|
|
26
|
-
name: 'default-app',
|
|
27
|
-
title: 'Default Application',
|
|
28
|
-
version: '1.0.0',
|
|
29
|
-
editionName: 'Standard',
|
|
30
|
-
features: [],
|
|
31
|
-
},
|
|
32
24
|
]);
|
|
33
25
|
}
|
|
34
26
|
}
|
|
@@ -224,9 +216,6 @@ class AXPSessionService {
|
|
|
224
216
|
this.applicationLoader = inject(AXP_APPLICATION_LOADER);
|
|
225
217
|
this.status = new BehaviorSubject(AXPSessionStatus.Unauthenticated);
|
|
226
218
|
this.status$ = this.status.asObservable().pipe(shareReplay(1));
|
|
227
|
-
// Add loading state to prevent premature redirects
|
|
228
|
-
this.isLoading = new BehaviorSubject(true);
|
|
229
|
-
this.isLoading$ = this.isLoading.asObservable().pipe(shareReplay(1));
|
|
230
219
|
this.currentUserSubject = new BehaviorSubject(null);
|
|
231
220
|
this.user$ = this.currentUserSubject.asObservable().pipe(shareReplay(1));
|
|
232
221
|
this.currentTenantSubject = new BehaviorSubject(null);
|
|
@@ -237,17 +226,7 @@ class AXPSessionService {
|
|
|
237
226
|
this.permissions$ = this.permissionsSubject.asObservable().pipe(shareReplay(1), defaultIfEmpty([]));
|
|
238
227
|
this.featuresSubject = new BehaviorSubject([]);
|
|
239
228
|
this.features$ = this.featuresSubject.asObservable().pipe(shareReplay(1), defaultIfEmpty([]));
|
|
240
|
-
this.isAuthenticated$ = this.status$.pipe(map((status) =>
|
|
241
|
-
const isAuth = status === AXPSessionStatus.Authenticated || status === AXPSessionStatus.Authorized;
|
|
242
|
-
return isAuth;
|
|
243
|
-
}), shareReplay(1));
|
|
244
|
-
// Add a new observable that considers loading state
|
|
245
|
-
this.isAuthenticatedWithLoading$ = this.isLoading$.pipe(switchMap((loading) => {
|
|
246
|
-
if (loading) {
|
|
247
|
-
return this.isLoading$.pipe(filter((isLoading) => !isLoading), switchMap(() => this.isAuthenticated$));
|
|
248
|
-
}
|
|
249
|
-
return this.isAuthenticated$;
|
|
250
|
-
}), shareReplay(1));
|
|
229
|
+
this.isAuthenticated$ = this.status$.pipe(map((status) => status === AXPSessionStatus.Authenticated || status === AXPSessionStatus.Authorized), shareReplay(1));
|
|
251
230
|
this.isAuthorized$ = this.status$.pipe(map((status) => status === AXPSessionStatus.Authorized), shareReplay(1));
|
|
252
231
|
}
|
|
253
232
|
static { this.SESSION_KEY = 'AXP_SESSION'; }
|
|
@@ -285,138 +264,108 @@ class AXPSessionService {
|
|
|
285
264
|
return this.featuresSubject.value ?? [];
|
|
286
265
|
}
|
|
287
266
|
async restoreSession() {
|
|
288
|
-
this.
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
this.currentUserSubject.next(sessionData.user);
|
|
294
|
-
this.status.next(AXPSessionStatus.Authenticated);
|
|
295
|
-
await this.loadPermissions();
|
|
296
|
-
await this.loadFeatures();
|
|
297
|
-
await this.signInComplete();
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
else {
|
|
301
|
-
this.status.next(AXPSessionStatus.Unauthorized);
|
|
267
|
+
const sessionData = this.getSessionData();
|
|
268
|
+
if (sessionData) {
|
|
269
|
+
if (sessionData.user) {
|
|
270
|
+
this.currentUserSubject.next(sessionData.user);
|
|
271
|
+
this.status.next(AXPSessionStatus.Authenticated);
|
|
302
272
|
}
|
|
303
|
-
|
|
304
|
-
|
|
273
|
+
// if (sessionData.tenant) {
|
|
274
|
+
// this.setTenant(sessionData.tenant);
|
|
275
|
+
// }
|
|
276
|
+
// if (sessionData.application) {
|
|
277
|
+
// this.setApplication(sessionData.application);
|
|
278
|
+
// }
|
|
279
|
+
await this.loadPermissions();
|
|
280
|
+
await this.loadFeatures();
|
|
281
|
+
await this.signInComplete();
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
305
284
|
this.status.next(AXPSessionStatus.Unauthorized);
|
|
306
285
|
}
|
|
307
|
-
finally {
|
|
308
|
-
this.isLoading.next(false);
|
|
309
|
-
}
|
|
310
286
|
}
|
|
311
287
|
async signin(credentials) {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
this.
|
|
335
|
-
// Load permissions and features
|
|
336
|
-
await this.loadPermissions();
|
|
337
|
-
await this.loadFeatures();
|
|
338
|
-
// If we have both tenant and application, complete the sign-in
|
|
339
|
-
if (this.application && this.tenant) {
|
|
340
|
-
await this.signInComplete();
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
else {
|
|
344
|
-
this.status.next(AXPSessionStatus.Unauthenticated);
|
|
345
|
-
throw new Error(`Invalid Username or Password`);
|
|
346
|
-
}
|
|
288
|
+
//
|
|
289
|
+
this.clearSession();
|
|
290
|
+
//
|
|
291
|
+
const strategy = this.authStrategyRegistry.get(credentials.strategy);
|
|
292
|
+
if (!strategy) {
|
|
293
|
+
throw new Error(`Authentication strategy '${credentials.strategy}' is not supported`);
|
|
294
|
+
}
|
|
295
|
+
const result = await strategy.signin(credentials);
|
|
296
|
+
if (result.succeed) {
|
|
297
|
+
this.currentUserSubject.next(result.data.user);
|
|
298
|
+
this.setSession({
|
|
299
|
+
accessToken: result.data.accessToken,
|
|
300
|
+
refreshToken: result.data.refreshToken,
|
|
301
|
+
strategy: credentials.strategy,
|
|
302
|
+
user: result.data.user,
|
|
303
|
+
application: result.data?.application,
|
|
304
|
+
tenant: result.data?.tenant,
|
|
305
|
+
expiresIn: result.data?.expiresIn,
|
|
306
|
+
idToken: result.data?.idToken ?? null,
|
|
307
|
+
});
|
|
308
|
+
this.status.next(AXPSessionStatus.Authenticated);
|
|
309
|
+
if (this.application && this.tenant)
|
|
310
|
+
await this.signInComplete();
|
|
347
311
|
}
|
|
348
|
-
|
|
349
|
-
console.error('Signin error:', error);
|
|
312
|
+
else {
|
|
350
313
|
this.status.next(AXPSessionStatus.Unauthenticated);
|
|
351
|
-
throw
|
|
352
|
-
}
|
|
353
|
-
finally {
|
|
354
|
-
this.isLoading.next(false);
|
|
355
|
-
console.log('Signin process completed');
|
|
314
|
+
throw new Error(`Invalid Username or Password`);
|
|
356
315
|
}
|
|
357
316
|
}
|
|
358
317
|
async signout() {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
const strategy = this.authStrategyRegistry.get(sessionData?.strategy);
|
|
365
|
-
if (strategy) {
|
|
366
|
-
try {
|
|
367
|
-
await strategy.signout();
|
|
368
|
-
}
|
|
369
|
-
catch (error) {
|
|
370
|
-
}
|
|
371
|
-
}
|
|
318
|
+
const sessionData = this.getSessionData();
|
|
319
|
+
if (sessionData?.strategy) {
|
|
320
|
+
const strategy = this.authStrategyRegistry.get(sessionData?.strategy);
|
|
321
|
+
if (strategy) {
|
|
322
|
+
await strategy.signout();
|
|
372
323
|
}
|
|
373
|
-
//
|
|
374
|
-
const userId = this.user?.id;
|
|
375
|
-
this.clearSession();
|
|
376
|
-
this.status.next(AXPSessionStatus.SignedOut);
|
|
377
|
-
this.eventService.publish(AXPSessionStatus.SignedOut, { id: userId });
|
|
378
|
-
}
|
|
379
|
-
finally {
|
|
380
|
-
this.isLoading.next(false);
|
|
381
324
|
}
|
|
325
|
+
//
|
|
326
|
+
const userId = this.user?.id;
|
|
327
|
+
this.clearSession();
|
|
328
|
+
this.status.next(AXPSessionStatus.SignedOut);
|
|
329
|
+
this.eventService.publish(AXPSessionStatus.SignedOut, { id: userId });
|
|
382
330
|
}
|
|
383
331
|
async refreshToken() {
|
|
384
|
-
console.log('Refreshing token...');
|
|
385
332
|
return new Promise(async (resolve, reject) => {
|
|
386
333
|
const sessionData = this.getSessionData();
|
|
387
334
|
if (!sessionData || !sessionData?.refreshToken) {
|
|
388
|
-
console.log('No session data or refresh token found');
|
|
389
|
-
reject(new Error('No refresh token available'));
|
|
390
335
|
return;
|
|
391
336
|
}
|
|
392
337
|
const strategy = this.authStrategyRegistry.get(sessionData.strategy);
|
|
393
338
|
if (!strategy) {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
return;
|
|
339
|
+
reject();
|
|
340
|
+
throw new Error(`Authentication strategy '${sessionData.strategy}' is not found`);
|
|
397
341
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
this.setSession(result.data);
|
|
403
|
-
resolve(result.data?.accessToken);
|
|
404
|
-
}
|
|
405
|
-
else {
|
|
406
|
-
console.error('Token refresh failed');
|
|
407
|
-
this.clearSession();
|
|
408
|
-
this.status.next(AXPSessionStatus.Expired);
|
|
409
|
-
reject(new Error('Token refresh failed'));
|
|
410
|
-
}
|
|
342
|
+
const result = await strategy.refreshToken(this.getContext());
|
|
343
|
+
if (result.succeed) {
|
|
344
|
+
this.setSession(result.data);
|
|
345
|
+
resolve(result.data?.accessToken);
|
|
411
346
|
}
|
|
412
|
-
|
|
413
|
-
console.error('Error during token refresh:', error);
|
|
347
|
+
else {
|
|
414
348
|
this.clearSession();
|
|
415
349
|
this.status.next(AXPSessionStatus.Expired);
|
|
416
|
-
reject(error);
|
|
417
350
|
}
|
|
418
351
|
});
|
|
419
352
|
}
|
|
353
|
+
async setTenant(tenant) {
|
|
354
|
+
this.currentTenantSubject.next(tenant);
|
|
355
|
+
if (tenant) {
|
|
356
|
+
this.updateSession({ tenant: tenant });
|
|
357
|
+
await this.refreshToken();
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
async setApplication(application) {
|
|
361
|
+
this.currentApplicationSubject.next(application);
|
|
362
|
+
if (application) {
|
|
363
|
+
this.updateSession({ application: application });
|
|
364
|
+
await this.refreshToken();
|
|
365
|
+
await this.loadPermissions();
|
|
366
|
+
await this.loadFeatures();
|
|
367
|
+
}
|
|
368
|
+
}
|
|
420
369
|
async loadPermissions() {
|
|
421
370
|
try {
|
|
422
371
|
const permissions = await firstValueFrom(this.permissionLoader.getList(this.getContext()));
|
|
@@ -438,64 +387,37 @@ class AXPSessionService {
|
|
|
438
387
|
}
|
|
439
388
|
}
|
|
440
389
|
async signInComplete() {
|
|
441
|
-
// Ensure we have the required data
|
|
442
|
-
if (!this.user) {
|
|
443
|
-
this.status.next(AXPSessionStatus.Unauthenticated);
|
|
444
|
-
return;
|
|
445
|
-
}
|
|
446
|
-
// Set status to Authorized
|
|
447
390
|
this.status.next(AXPSessionStatus.Authorized);
|
|
448
|
-
// Double-check the status was set correctly
|
|
449
|
-
setTimeout(() => {
|
|
450
|
-
console.log('Status after timeout:', this.status.value);
|
|
451
|
-
}, 100);
|
|
452
391
|
}
|
|
453
392
|
setSession(tokens) {
|
|
454
393
|
const sessionData = {
|
|
455
394
|
accessToken: tokens.accessToken,
|
|
456
395
|
refreshToken: tokens.refreshToken,
|
|
457
396
|
strategy: tokens.strategy,
|
|
458
|
-
user:
|
|
397
|
+
user: this.user,
|
|
459
398
|
application: tokens.application,
|
|
460
399
|
tenant: tokens.tenant,
|
|
461
400
|
expiresIn: tokens.expiresIn,
|
|
462
401
|
idToken: tokens.idToken,
|
|
463
402
|
};
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
}
|
|
471
|
-
if (tokens.application) {
|
|
472
|
-
this.currentApplicationSubject.next(tokens.application);
|
|
473
|
-
}
|
|
474
|
-
localStorage.setItem(AXPSessionService.SESSION_KEY, JSON.stringify(sessionData));
|
|
403
|
+
this.updateSession(sessionData);
|
|
404
|
+
}
|
|
405
|
+
updateSession(update) {
|
|
406
|
+
const currentSession = this.getSessionData() ?? {};
|
|
407
|
+
const updatedSession = merge({}, currentSession, update);
|
|
408
|
+
localStorage.setItem(AXPSessionService.SESSION_KEY, JSON.stringify(updatedSession));
|
|
475
409
|
}
|
|
476
410
|
getSessionData() {
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
if (sessionDataString) {
|
|
480
|
-
const sessionData = JSON.parse(sessionDataString);
|
|
481
|
-
return sessionData;
|
|
482
|
-
}
|
|
483
|
-
else {
|
|
484
|
-
return null;
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
catch (error) {
|
|
488
|
-
localStorage.removeItem(AXPSessionService.SESSION_KEY);
|
|
489
|
-
return null;
|
|
490
|
-
}
|
|
411
|
+
const sessionDataString = localStorage.getItem(AXPSessionService.SESSION_KEY);
|
|
412
|
+
return sessionDataString ? JSON.parse(sessionDataString) : null;
|
|
491
413
|
}
|
|
492
414
|
clearSession() {
|
|
493
415
|
//
|
|
494
416
|
this.currentUserSubject.next(null);
|
|
495
417
|
//
|
|
496
|
-
this.
|
|
418
|
+
this.setTenant(null);
|
|
497
419
|
//
|
|
498
|
-
this.
|
|
420
|
+
this.setApplication(null);
|
|
499
421
|
//
|
|
500
422
|
this.permissionsSubject.next([]);
|
|
501
423
|
//
|
|
@@ -771,7 +693,7 @@ class AXPPermissionEvaluatorScopeProvider {
|
|
|
771
693
|
|
|
772
694
|
const AXPAuthGuard = (route, state) => {
|
|
773
695
|
const sessionService = inject(AXPSessionService);
|
|
774
|
-
return sessionService.
|
|
696
|
+
return sessionService.isAuthenticated$.pipe(first(), map((value) => {
|
|
775
697
|
if (value) {
|
|
776
698
|
return true;
|
|
777
699
|
}
|
|
@@ -836,9 +758,14 @@ class AXPAuthModule {
|
|
|
836
758
|
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.1.3", ngImport: i0, type: AXPAuthModule, declarations: [AXPPermissionDirective, AXPFeatureDirective], exports: [AXPPermissionDirective, AXPFeatureDirective] }); }
|
|
837
759
|
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXPAuthModule, providers: [
|
|
838
760
|
provideAppInitializer(() => {
|
|
839
|
-
const initializerFn = initializeAppState(inject(AXPSessionService));
|
|
761
|
+
const initializerFn = (initializeAppState)(inject(AXPSessionService));
|
|
840
762
|
return initializerFn();
|
|
841
763
|
}),
|
|
764
|
+
{
|
|
765
|
+
provide: AXP_EXPRESSION_EVALUATOR_SCOPE_PROVIDER,
|
|
766
|
+
useClass: AXPPermissionEvaluatorScopeProvider,
|
|
767
|
+
multi: true,
|
|
768
|
+
},
|
|
842
769
|
] }); }
|
|
843
770
|
}
|
|
844
771
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXPAuthModule, decorators: [{
|
|
@@ -849,9 +776,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImpor
|
|
|
849
776
|
declarations: [AXPPermissionDirective, AXPFeatureDirective],
|
|
850
777
|
providers: [
|
|
851
778
|
provideAppInitializer(() => {
|
|
852
|
-
const initializerFn = initializeAppState(inject(AXPSessionService));
|
|
779
|
+
const initializerFn = (initializeAppState)(inject(AXPSessionService));
|
|
853
780
|
return initializerFn();
|
|
854
781
|
}),
|
|
782
|
+
{
|
|
783
|
+
provide: AXP_EXPRESSION_EVALUATOR_SCOPE_PROVIDER,
|
|
784
|
+
useClass: AXPPermissionEvaluatorScopeProvider,
|
|
785
|
+
multi: true,
|
|
786
|
+
},
|
|
855
787
|
],
|
|
856
788
|
}]
|
|
857
789
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
@@ -861,19 +793,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImpor
|
|
|
861
793
|
args: ['AXPAuthModuleFactory']
|
|
862
794
|
}] }] });
|
|
863
795
|
|
|
864
|
-
class AXPAuthStrategy {
|
|
865
|
-
// OIDC-specific methods (default: throw error)
|
|
866
|
-
startAuthorizationFlow(tenantId, applicationId) {
|
|
867
|
-
throw new Error('startAuthorizationFlow is not implemented for this strategy');
|
|
868
|
-
}
|
|
869
|
-
completeAuthorizationCodeFlow(options) {
|
|
870
|
-
throw new Error('completeAuthorizationCodeFlow is not implemented for this strategy');
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
|
|
874
796
|
/**
|
|
875
797
|
* Generated bundle index. Do not edit.
|
|
876
798
|
*/
|
|
877
799
|
|
|
878
|
-
export { AXPAuthGuard, AXPAuthModule,
|
|
800
|
+
export { AXPAuthGuard, AXPAuthModule, AXPFeatureDirective, AXPFeatureGuard, AXPPermissionDefinitionBuilder, AXPPermissionDefinitionGroupBuilder, AXPPermissionDefinitionProviderContext, AXPPermissionDefinitionService, AXPPermissionDirective, AXPPermissionEvaluatorScopeProvider, AXPPermissionGuard, AXPSessionContext, AXPSessionService, AXPSessionStatus, AXPUnauthenticatedError, AXPUnauthorizedError, AXP_APPLICATION_LOADER, AXP_FEATURE_LOADER, AXP_PERMISSION_DEFINITION_PROVIDER, AXP_PERMISSION_LOADER, AXP_TENANT_LOADER, initializeAppState };
|
|
879
801
|
//# sourceMappingURL=acorex-platform-auth.mjs.map
|