@acorex/modules 1.0.0 → 1.0.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.
- package/auth/index.d.ts +1 -0
- package/auth/lib/account/account.module.d.ts +1 -1
- package/auth/lib/account/app-chooser/app-chooser-slot.component.d.ts +1 -1
- package/auth/lib/account/app-chooser/app-chooser.component.d.ts +1 -1
- package/auth/lib/account/profile/profile-slot.component.d.ts +6 -1
- package/auth/lib/account/tenant-chooser/tenant-chooser-dropdown.component.d.ts +1 -1
- package/auth/lib/auth.config.d.ts +5 -5
- package/auth/lib/error-handler.d.ts +1 -1
- package/auth/lib/login/password/password.component.d.ts +1 -1
- package/backend/index.d.ts +2 -0
- package/backend/lib/auth/oidc/application.loader.d.ts +2 -2
- package/backend/lib/auth/oidc/configuration.service.d.ts +60 -0
- package/backend/lib/auth/oidc/feature.loader.d.ts +1 -0
- package/backend/lib/auth/oidc/index.d.ts +3 -0
- package/backend/lib/auth/oidc/oidc.strategy.d.ts +5 -3
- package/backend/lib/auth/oidc/permission.loader.d.ts +11 -2
- package/backend/lib/auth/oidc/signincallback.component.d.ts +1 -0
- package/backend/lib/auth/oidc/tenant.loader.d.ts +2 -2
- package/backend/lib/auth/oidc/usermanager.service.d.ts +4 -1
- package/backend/lib/backend.configs.d.ts +0 -5
- package/backend/lib/data/api/data-provider.d.ts +4 -0
- package/backend/lib/data/index.d.ts +3 -0
- package/backend/lib/data/local/data-Conditioner.d.ts +6 -0
- package/backend/lib/data/local/local-data-provider.d.ts +23 -0
- package/esm2022/auth/index.mjs +2 -1
- package/esm2022/auth/lib/account/account.module.mjs +12 -12
- package/esm2022/auth/lib/account/app-chooser/app-chooser-list.component.mjs +6 -6
- package/esm2022/auth/lib/account/app-chooser/app-chooser-slot.component.mjs +7 -6
- package/esm2022/auth/lib/account/app-chooser/app-chooser.component.mjs +7 -6
- package/esm2022/auth/lib/account/profile/profile-slot.component.mjs +45 -18
- package/esm2022/auth/lib/account/tenant-chooser/tenant-chooser-dropdown.component.mjs +6 -5
- package/esm2022/auth/lib/account/tenant-chooser/tenant-chooser.component.mjs +7 -7
- package/esm2022/auth/lib/auth.config.mjs +7 -6
- package/esm2022/auth/lib/auth.module.mjs +4 -4
- package/esm2022/auth/lib/auth.routes.mjs +7 -6
- package/esm2022/auth/lib/error-handler.mjs +14 -7
- package/esm2022/auth/lib/forgot/password/password.component.mjs +4 -4
- package/esm2022/auth/lib/login/login.module.mjs +5 -6
- package/esm2022/auth/lib/login/password/password.component.mjs +26 -11
- package/esm2022/auth/lib/shared/layouts/blank/blank.layout.mjs +3 -3
- package/esm2022/auth/lib/shared/layouts/master/master.layout.mjs +8 -7
- package/esm2022/auth/lib/shared/services/idle.service.mjs +3 -3
- package/esm2022/auth/lib/store/auth.effects.mjs +3 -3
- package/esm2022/auth/lib/two-factor/two-factor-code/two-factor-code.component.mjs +4 -4
- package/esm2022/auth/lib/two-factor/two-factor.module.mjs +4 -4
- package/esm2022/backend/index.mjs +3 -1
- package/esm2022/backend/lib/auth/oidc/application.loader.mjs +15 -13
- package/esm2022/backend/lib/auth/oidc/configuration.service.mjs +53 -0
- package/esm2022/backend/lib/auth/oidc/feature.loader.mjs +16 -2
- package/esm2022/backend/lib/auth/oidc/index.mjs +4 -1
- package/esm2022/backend/lib/auth/oidc/oidc.strategy.mjs +59 -39
- package/esm2022/backend/lib/auth/oidc/permission.loader.mjs +31 -4
- package/esm2022/backend/lib/auth/oidc/signincallback.component.mjs +27 -7
- package/esm2022/backend/lib/auth/oidc/tenant.loader.mjs +16 -14
- package/esm2022/backend/lib/auth/oidc/usermanager.service.mjs +8 -6
- package/esm2022/backend/lib/backend.configs.mjs +2 -3
- package/esm2022/backend/lib/backend.module.mjs +9 -23
- package/esm2022/backend/lib/data/api/data-provider.mjs +49 -13
- package/esm2022/backend/lib/data/index.mjs +4 -0
- package/esm2022/backend/lib/data/local/data-Conditioner.mjs +76 -0
- package/esm2022/backend/lib/data/local/local-data-provider.mjs +84 -0
- package/esm2022/log-management/acorex-modules-log-management.mjs +5 -0
- package/esm2022/log-management/index.mjs +3 -0
- package/esm2022/log-management/lib/audit-logs.entity.mjs +392 -0
- package/esm2022/log-management/lib/log-management.module.mjs +16 -0
- package/esm2022/notification/index.mjs +3 -1
- package/esm2022/notification/lib/notification.module.mjs +4 -4
- package/fesm2022/{acorex-modules-auth-acorex-modules-auth-3tiGzryz.mjs → acorex-modules-auth-acorex-modules-auth-jEqtVhBE.mjs} +143 -109
- package/fesm2022/acorex-modules-auth-acorex-modules-auth-jEqtVhBE.mjs.map +1 -0
- package/fesm2022/acorex-modules-auth-app-chooser.component-BbtMSwfI.mjs +72 -0
- package/fesm2022/acorex-modules-auth-app-chooser.component-BbtMSwfI.mjs.map +1 -0
- package/fesm2022/{acorex-modules-auth-blank.layout-0xNRyD5z.mjs → acorex-modules-auth-blank.layout-BOdRxDNv.mjs} +4 -4
- package/fesm2022/{acorex-modules-auth-blank.layout-0xNRyD5z.mjs.map → acorex-modules-auth-blank.layout-BOdRxDNv.mjs.map} +1 -1
- package/fesm2022/{acorex-modules-auth-login.module-lGs54nBU.mjs → acorex-modules-auth-login.module-Drm4fC1I.mjs} +13 -12
- package/fesm2022/acorex-modules-auth-login.module-Drm4fC1I.mjs.map +1 -0
- package/fesm2022/{acorex-modules-auth-master.layout-ytopPv2z.mjs → acorex-modules-auth-master.layout-cAm6TYeA.mjs} +12 -10
- package/fesm2022/acorex-modules-auth-master.layout-cAm6TYeA.mjs.map +1 -0
- package/fesm2022/{acorex-modules-auth-password.component-Q9Me4kkK.mjs → acorex-modules-auth-password.component-Ch2Wqi2W.mjs} +12 -10
- package/fesm2022/{acorex-modules-auth-password.component-Q9Me4kkK.mjs.map → acorex-modules-auth-password.component-Ch2Wqi2W.mjs.map} +1 -1
- package/fesm2022/acorex-modules-auth-password.component-D4CkGaq0.mjs +127 -0
- package/fesm2022/acorex-modules-auth-password.component-D4CkGaq0.mjs.map +1 -0
- package/fesm2022/{acorex-modules-auth-routes-jgo2XGe0.mjs → acorex-modules-auth-routes-DyjibH6l.mjs} +2 -2
- package/fesm2022/{acorex-modules-auth-routes-jgo2XGe0.mjs.map → acorex-modules-auth-routes-DyjibH6l.mjs.map} +1 -1
- package/fesm2022/acorex-modules-auth-tenant-chooser.component-CJu2Lfbf.mjs +84 -0
- package/fesm2022/acorex-modules-auth-tenant-chooser.component-CJu2Lfbf.mjs.map +1 -0
- package/fesm2022/{acorex-modules-auth-two-factor-code.component-fP6CLq9T.mjs → acorex-modules-auth-two-factor-code.component-B41iXHoT.mjs} +5 -5
- package/fesm2022/{acorex-modules-auth-two-factor-code.component-fP6CLq9T.mjs.map → acorex-modules-auth-two-factor-code.component-B41iXHoT.mjs.map} +1 -1
- package/fesm2022/{acorex-modules-auth-two-factor.module--fcoNW-s.mjs → acorex-modules-auth-two-factor.module-A0hevYO2.mjs} +12 -10
- package/fesm2022/acorex-modules-auth-two-factor.module-A0hevYO2.mjs.map +1 -0
- package/fesm2022/acorex-modules-auth.mjs +7 -5
- package/fesm2022/acorex-modules-auth.mjs.map +1 -1
- package/fesm2022/acorex-modules-backend.mjs +432 -227
- package/fesm2022/acorex-modules-backend.mjs.map +1 -1
- package/fesm2022/acorex-modules-log-management.mjs +415 -0
- package/fesm2022/acorex-modules-log-management.mjs.map +1 -0
- package/fesm2022/acorex-modules-notification.mjs +7 -4
- package/fesm2022/acorex-modules-notification.mjs.map +1 -1
- package/log-management/README.md +4 -0
- package/log-management/index.d.ts +2 -0
- package/log-management/lib/audit-logs.entity.d.ts +3 -0
- package/log-management/lib/log-management.module.d.ts +6 -0
- package/package.json +7 -1
- package/auth/lib/register/email/email.component.d.ts +0 -5
- package/auth/lib/register/register.module.d.ts +0 -7
- package/auth/lib/register/result/result.component.d.ts +0 -5
- package/backend/lib/auth/userpass/application.loader.d.ts +0 -6
- package/backend/lib/auth/userpass/index.d.ts +0 -4
- package/backend/lib/auth/userpass/permission.loader.d.ts +0 -5
- package/backend/lib/auth/userpass/tenant.loader.d.ts +0 -6
- package/backend/lib/auth/userpass/userpass.strategy.d.ts +0 -12
- package/esm2022/auth/lib/register/email/email.component.mjs +0 -42
- package/esm2022/auth/lib/register/register.module.mjs +0 -59
- package/esm2022/auth/lib/register/result/result.component.mjs +0 -33
- package/esm2022/backend/lib/auth/userpass/application.loader.mjs +0 -30
- package/esm2022/backend/lib/auth/userpass/index.mjs +0 -5
- package/esm2022/backend/lib/auth/userpass/permission.loader.mjs +0 -12
- package/esm2022/backend/lib/auth/userpass/tenant.loader.mjs +0 -26
- package/esm2022/backend/lib/auth/userpass/userpass.strategy.mjs +0 -40
- package/fesm2022/acorex-modules-auth-acorex-modules-auth-3tiGzryz.mjs.map +0 -1
- package/fesm2022/acorex-modules-auth-app-chooser.component-Hh2T5orM.mjs +0 -70
- package/fesm2022/acorex-modules-auth-app-chooser.component-Hh2T5orM.mjs.map +0 -1
- package/fesm2022/acorex-modules-auth-email.component-ZbTwT8iu.mjs +0 -45
- package/fesm2022/acorex-modules-auth-email.component-ZbTwT8iu.mjs.map +0 -1
- package/fesm2022/acorex-modules-auth-login.module-lGs54nBU.mjs.map +0 -1
- package/fesm2022/acorex-modules-auth-master.layout-ytopPv2z.mjs.map +0 -1
- package/fesm2022/acorex-modules-auth-password.component-p1Ks9S5q.mjs +0 -110
- package/fesm2022/acorex-modules-auth-password.component-p1Ks9S5q.mjs.map +0 -1
- package/fesm2022/acorex-modules-auth-register.module-ckbVm-yf.mjs +0 -77
- package/fesm2022/acorex-modules-auth-register.module-ckbVm-yf.mjs.map +0 -1
- package/fesm2022/acorex-modules-auth-result.component-ORUU7lkV.mjs +0 -36
- package/fesm2022/acorex-modules-auth-result.component-ORUU7lkV.mjs.map +0 -1
- package/fesm2022/acorex-modules-auth-tenant-chooser.component-PeGg21Im.mjs +0 -84
- package/fesm2022/acorex-modules-auth-tenant-chooser.component-PeGg21Im.mjs.map +0 -1
- package/fesm2022/acorex-modules-auth-two-factor.module--fcoNW-s.mjs.map +0 -1
@@ -1,27 +1,28 @@
|
|
1
|
-
import * as i0 from '@angular/core';
|
2
|
-
import { InjectionToken, inject, Injectable, Inject, Injector, Component, NgModule } from '@angular/core';
|
3
1
|
import * as i1$1 from '@acorex/modules/auth';
|
4
2
|
import { AXM_AUTH_CONFIG_TOKEN, AXMAuthModule } from '@acorex/modules/auth';
|
5
3
|
import * as i2$1 from '@acorex/platform/auth';
|
6
|
-
import { AXP_TENANT_LOADER, AXP_APPLICATION_LOADER, AXP_PERMISSION_LOADER, AXP_FEATURE_LOADER, AXPAuthModule } from '@acorex/platform/auth';
|
7
|
-
import {
|
4
|
+
import { AXPSessionService, AXP_TENANT_LOADER, AXP_APPLICATION_LOADER, AXP_PERMISSION_LOADER, AXP_FEATURE_LOADER, AXPAuthModule } from '@acorex/platform/auth';
|
5
|
+
import { AXPDataProvider } from '@acorex/platform/common';
|
6
|
+
import * as i0 from '@angular/core';
|
7
|
+
import { inject, Injectable, Inject, Injector, Component, NgModule } from '@angular/core';
|
8
8
|
import * as i2 from '@angular/router';
|
9
9
|
import { ROUTES } from '@angular/router';
|
10
|
+
import { AXP_ROOT_CONFIG_TOKEN } from '@acorex/platform/core';
|
10
11
|
import * as i1 from '@angular/common/http';
|
11
12
|
import { HttpParams } from '@angular/common/http';
|
12
|
-
import { firstValueFrom, map, of, delay } from 'rxjs';
|
13
|
+
import { firstValueFrom, map, BehaviorSubject, tap, filter, take, of, switchMap, delay } from 'rxjs';
|
14
|
+
import * as i1$2 from '@acorex/platform/mocks';
|
15
|
+
import { MockDataService } from '@acorex/platform/mocks';
|
13
16
|
import { UserManager, WebStorageStateStore } from 'oidc-client-ts';
|
14
|
-
|
15
|
-
const AXM_BACKEND_CONFIG_TOKEN = new InjectionToken('AXM_BACKEND_CONFIG_TOKEN');
|
17
|
+
import { isEmpty, endsWith, startsWith, includes, some, every, lte, gte, lt, gt, isEqual, orderBy } from 'lodash-es';
|
16
18
|
|
17
19
|
class AXMBackendDataProvider {
|
18
20
|
constructor(http) {
|
19
21
|
this.http = http;
|
20
|
-
this.configs = inject(
|
22
|
+
this.configs = inject(AXP_ROOT_CONFIG_TOKEN);
|
21
23
|
this.mainUrl = this.configs.baseUrl;
|
22
24
|
}
|
23
25
|
insertOne(entity, entityItem) {
|
24
|
-
console.log('inserting....', entity.name, entityItem);
|
25
26
|
const url = `${this.mainUrl}/${entity.module}/${entity.name}`;
|
26
27
|
return firstValueFrom(this.http.post(url, entityItem));
|
27
28
|
}
|
@@ -37,15 +38,30 @@ class AXMBackendDataProvider {
|
|
37
38
|
return firstValueFrom(this.http.get(url));
|
38
39
|
}
|
39
40
|
getMany(entity, params) {
|
40
|
-
|
41
|
-
let httpParams = new HttpParams()
|
42
|
-
.set('Skip', params?.skip?.toString() ?? '0')
|
43
|
-
.set('Take', params?.take?.toString() ?? '10');
|
41
|
+
let httpParams = new HttpParams().set('Skip', params?.skip?.toString() ?? '0').set('Take', params?.take?.toString() ?? '10');
|
44
42
|
if (params?.sort && params?.sort.length > 0) {
|
45
43
|
const sortParam = params?.sort.map((sort) => `${sort.field}:${sort.dir}`).join(',');
|
46
44
|
httpParams = httpParams.set('$orderby', sortParam);
|
47
45
|
}
|
48
|
-
|
46
|
+
let filterString = params?.customFilter ? params.customFilter : '';
|
47
|
+
if (params?.filter) {
|
48
|
+
const filters = params.filter.filters;
|
49
|
+
if (filters && filters.length > 0) {
|
50
|
+
// Construct filter string from provided filters
|
51
|
+
const dynamicFilters = filters
|
52
|
+
.map((f) => {
|
53
|
+
return `${f.field} ${f.operator.type} ${f.value}`;
|
54
|
+
})
|
55
|
+
.join(',');
|
56
|
+
// Append dynamic filters to custom filter, if both exist
|
57
|
+
filterString = filterString ? `${filterString},${dynamicFilters}` : dynamicFilters;
|
58
|
+
}
|
59
|
+
}
|
60
|
+
// Set the $filter parameter if there are any filters
|
61
|
+
if (filterString) {
|
62
|
+
httpParams = httpParams.set('$filter', filterString);
|
63
|
+
}
|
64
|
+
return firstValueFrom(this.http.get(`${this.mainUrl}/${entity.module}/${params.costumGetter ? params.costumGetter : entity.name}/${params?.sub ? params.sub : ''}`, { params: httpParams })).then((response) => {
|
49
65
|
return {
|
50
66
|
total: response.totalCount,
|
51
67
|
items: response.items,
|
@@ -57,7 +73,6 @@ class AXMBackendDataProvider {
|
|
57
73
|
return firstValueFrom(this.http.put(url, data));
|
58
74
|
}
|
59
75
|
deleteOne(entity, id) {
|
60
|
-
console.log('deleteOne', entity.name, id);
|
61
76
|
const url = `${this.mainUrl}/${entity.module}/${entity.name}/${id}`;
|
62
77
|
return firstValueFrom(this.http.delete(url));
|
63
78
|
}
|
@@ -65,10 +80,33 @@ class AXMBackendDataProvider {
|
|
65
80
|
// return this.getMany(entity.name).then((res) => res.items[0]);
|
66
81
|
return new Promise((resolve) => resolve(true));
|
67
82
|
}
|
68
|
-
|
69
|
-
|
83
|
+
// File uploader function
|
84
|
+
uploadFile(file, title) {
|
85
|
+
const url = `${this.mainUrl}/common/files`;
|
86
|
+
const formData = new FormData();
|
87
|
+
formData.append('File', file);
|
88
|
+
formData.append('Title', title);
|
89
|
+
return firstValueFrom(this.http.post(url, formData));
|
90
|
+
}
|
91
|
+
// Function to upload multiple files
|
92
|
+
uploadMultipleFiles(files, title) {
|
93
|
+
const uploadPromises = files.map((file) => this.uploadFile(file, title));
|
94
|
+
return Promise.all(uploadPromises);
|
95
|
+
}
|
96
|
+
// Function to view a file
|
97
|
+
viewFile(id, name) {
|
98
|
+
const url = `${this.mainUrl}/common/files/${id}/View/${name}`;
|
99
|
+
return firstValueFrom(this.http.get(url, { responseType: 'blob' }));
|
100
|
+
}
|
101
|
+
// Function to download a file
|
102
|
+
downloadFile(id, name) {
|
103
|
+
const url = `${this.mainUrl}/common/files/${id}/Download/${name}`;
|
104
|
+
return firstValueFrom(this.http.get(url, { responseType: 'blob' }));
|
105
|
+
}
|
106
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMBackendDataProvider, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
107
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMBackendDataProvider, providedIn: 'root' }); }
|
70
108
|
}
|
71
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
109
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMBackendDataProvider, decorators: [{
|
72
110
|
type: Injectable,
|
73
111
|
args: [{
|
74
112
|
providedIn: 'root',
|
@@ -78,30 +116,32 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.2", ngImpor
|
|
78
116
|
class AXMOidcApplicationLoader {
|
79
117
|
constructor(http) {
|
80
118
|
this.http = http;
|
81
|
-
this.configs = inject(
|
82
|
-
this.apiGetApps = `${this.configs.
|
83
|
-
this.apiSetApp = `${this.configs.
|
119
|
+
this.configs = inject(AXP_ROOT_CONFIG_TOKEN);
|
120
|
+
this.apiGetApps = `${this.configs.baseUrl}/applications/GetListByTenantId`;
|
121
|
+
this.apiSetApp = `${this.configs.baseUrl}/SetApplication`;
|
84
122
|
}
|
85
123
|
getList() {
|
86
124
|
return this.http.get(this.apiGetApps).pipe(map((response) => {
|
87
|
-
console.log('response', response);
|
88
125
|
return response.items.map((item) => this.mapToAXPApplication(item));
|
89
126
|
}));
|
90
127
|
}
|
128
|
+
//TODO: shoud be removed
|
91
129
|
set(application) {
|
92
130
|
return this.http.post(this.apiSetApp, { applicationId: application.id }).pipe(map((response) => {
|
93
131
|
return {
|
94
|
-
|
95
|
-
|
132
|
+
succeed: true,
|
133
|
+
data: {
|
134
|
+
accessToken: response.token,
|
135
|
+
refreshToken: response.token,
|
136
|
+
}
|
96
137
|
};
|
97
138
|
}));
|
98
139
|
}
|
99
140
|
mapToAXPApplication(item) {
|
100
|
-
console.log('mapToAXPApplication', item);
|
101
141
|
return {
|
102
142
|
id: item.id,
|
103
143
|
name: item.name || 'defaultName',
|
104
|
-
title: item.
|
144
|
+
title: item.title || 'defaultTitle',
|
105
145
|
version: item.version || '1.0.0',
|
106
146
|
description: item.description,
|
107
147
|
logo: item.logo, // Assuming logo is of type AXPLogoConfig or undefined
|
@@ -109,16 +149,77 @@ class AXMOidcApplicationLoader {
|
|
109
149
|
// features: item.features || [],
|
110
150
|
};
|
111
151
|
}
|
112
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
113
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
152
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMOidcApplicationLoader, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
153
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMOidcApplicationLoader }); }
|
114
154
|
}
|
115
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
155
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMOidcApplicationLoader, decorators: [{
|
116
156
|
type: Injectable
|
117
157
|
}], ctorParameters: () => [{ type: i1.HttpClient }] });
|
118
158
|
|
159
|
+
class AXMConfigurationService {
|
160
|
+
constructor(http) {
|
161
|
+
this.http = http;
|
162
|
+
this.configs = inject(AXP_ROOT_CONFIG_TOKEN);
|
163
|
+
this.applicationConfig = null;
|
164
|
+
this.apiGetConfig = `${this.configs.baseUrl}/abp/application-configuration`;
|
165
|
+
this.fetchInProgress = false;
|
166
|
+
this.configSubject = new BehaviorSubject(null);
|
167
|
+
this.init().subscribe(); // Automatically trigger configuration load on service instantiation
|
168
|
+
}
|
169
|
+
init() {
|
170
|
+
if (!this.fetchInProgress) {
|
171
|
+
this.fetchInProgress = true;
|
172
|
+
return this.http.get(this.apiGetConfig).pipe(tap((response) => {
|
173
|
+
console.log('%cGranted ', 'background: #03fc9d; color: #000;', response);
|
174
|
+
this.applicationConfig = response;
|
175
|
+
this.configSubject.next(this.applicationConfig);
|
176
|
+
this.fetchInProgress = false;
|
177
|
+
}));
|
178
|
+
}
|
179
|
+
else {
|
180
|
+
// Adjusted approach to handle TypeScript's type safety requirements
|
181
|
+
return this.configSubject.asObservable().pipe(filter((config) => config !== null), take(1) // Ensures it completes after emitting the first non-null value
|
182
|
+
);
|
183
|
+
}
|
184
|
+
}
|
185
|
+
getConfig() {
|
186
|
+
if (this.applicationConfig) {
|
187
|
+
// If the config is already loaded, return it immediately
|
188
|
+
return of(this.applicationConfig);
|
189
|
+
}
|
190
|
+
else {
|
191
|
+
// If the config is not loaded, initiate loading
|
192
|
+
return this.configSubject.asObservable().pipe(filter((config) => config !== null), take(1), // Ensure it only emits the first non-null value and completes
|
193
|
+
switchMap(() => of(this.applicationConfig)));
|
194
|
+
}
|
195
|
+
}
|
196
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMConfigurationService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
197
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMConfigurationService, providedIn: 'root' }); }
|
198
|
+
}
|
199
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMConfigurationService, decorators: [{
|
200
|
+
type: Injectable,
|
201
|
+
args: [{
|
202
|
+
providedIn: 'root',
|
203
|
+
}]
|
204
|
+
}], ctorParameters: () => [{ type: i1.HttpClient }] });
|
205
|
+
|
119
206
|
class AXMOidcFeatureLoader {
|
207
|
+
constructor() {
|
208
|
+
this.list = [
|
209
|
+
{
|
210
|
+
name: 'axp-entity-list-custom-view',
|
211
|
+
title: 'Custom View',
|
212
|
+
value: false
|
213
|
+
},
|
214
|
+
{
|
215
|
+
name: 'axp-entity-list-quick-search',
|
216
|
+
title: 'Custom View',
|
217
|
+
value: false
|
218
|
+
}
|
219
|
+
];
|
220
|
+
}
|
120
221
|
getList() {
|
121
|
-
return of(
|
222
|
+
return of(this.list).pipe(delay(0));
|
122
223
|
}
|
123
224
|
}
|
124
225
|
|
@@ -126,6 +227,8 @@ class AXMOidcFeatureLoader {
|
|
126
227
|
class AXMOidcUserManagerService {
|
127
228
|
constructor(authConfig) {
|
128
229
|
this.authConfig = authConfig;
|
230
|
+
this.selectedTenant = null;
|
231
|
+
this.selectedApplication = null;
|
129
232
|
if (!authConfig.oidc_settings) {
|
130
233
|
throw new Error('OIDC configuration is missing');
|
131
234
|
}
|
@@ -137,13 +240,13 @@ class AXMOidcUserManagerService {
|
|
137
240
|
getUserManager() {
|
138
241
|
return this.userManager;
|
139
242
|
}
|
140
|
-
|
141
|
-
this.userManager.signinSilentCallback();
|
243
|
+
async signinSilentCallback() {
|
244
|
+
await this.userManager.signinSilentCallback();
|
142
245
|
}
|
143
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
144
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
246
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMOidcUserManagerService, deps: [{ token: AXM_AUTH_CONFIG_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
247
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMOidcUserManagerService, providedIn: 'root' }); }
|
145
248
|
}
|
146
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
249
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMOidcUserManagerService, decorators: [{
|
147
250
|
type: Injectable,
|
148
251
|
args: [{
|
149
252
|
providedIn: 'root',
|
@@ -156,49 +259,64 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.2", ngImpor
|
|
156
259
|
class AXMOidcStrategy {
|
157
260
|
constructor() {
|
158
261
|
this.injector = inject(Injector);
|
262
|
+
this.mockerService = inject(MockDataService);
|
263
|
+
this.dataService = inject(AXPDataProvider);
|
159
264
|
this.userManagerService = this.injector.get(AXMOidcUserManagerService);
|
160
265
|
this.userManager = this.userManagerService.getUserManager();
|
161
266
|
}
|
162
267
|
get name() {
|
163
|
-
return '
|
268
|
+
return 'user-pass';
|
164
269
|
}
|
165
270
|
async signin(credentials) {
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
271
|
+
try {
|
272
|
+
const currentUser = await this.userManager.getUser();
|
273
|
+
if (currentUser && !currentUser.expired && currentUser.profile.name === credentials.username) {
|
274
|
+
const user = {
|
275
|
+
id: currentUser.profile.sub,
|
276
|
+
name: currentUser.profile.name ?? credentials.username,
|
277
|
+
title: currentUser.profile.given_name ?? 'no Name!',
|
278
|
+
avatar: currentUser.profile.picture,
|
279
|
+
};
|
280
|
+
const accessToken = currentUser.access_token;
|
281
|
+
const refreshToken = currentUser.refresh_token ?? '';
|
282
|
+
return {
|
283
|
+
succeed: true,
|
284
|
+
data: { user, accessToken, refreshToken },
|
285
|
+
};
|
286
|
+
}
|
287
|
+
await this.userManager.removeUser();
|
288
|
+
await this.userManager.clearStaleState();
|
289
|
+
const oidcUser = await this.userManager.signinSilent({
|
290
|
+
extraQueryParams: {
|
291
|
+
username: credentials.username,
|
292
|
+
password: credentials.password,
|
293
|
+
},
|
294
|
+
});
|
295
|
+
if (oidcUser) {
|
296
|
+
const profile = oidcUser.profile; // Cast to any to access deeply nested properties
|
297
|
+
const user = {
|
298
|
+
id: profile.sub,
|
299
|
+
name: `${profile.email}`,
|
300
|
+
title: `${profile.name}`,
|
301
|
+
avatar: `${profile.picture}`,
|
302
|
+
};
|
303
|
+
const accessToken = oidcUser.access_token;
|
304
|
+
const refreshToken = oidcUser.refresh_token ?? '';
|
305
|
+
return {
|
306
|
+
succeed: true,
|
307
|
+
data: { user, accessToken, refreshToken },
|
308
|
+
};
|
309
|
+
}
|
310
|
+
return {
|
311
|
+
succeed: false,
|
174
312
|
};
|
175
|
-
const accessToken = currentUser.access_token;
|
176
|
-
const refreshToken = currentUser.refresh_token ?? '';
|
177
|
-
return { user, accessToken, refreshToken };
|
178
313
|
}
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
hardcoded_identity_id: '1',
|
185
|
-
username: credentials.username,
|
186
|
-
password: credentials.password,
|
187
|
-
},
|
188
|
-
});
|
189
|
-
console.log('here is oidcUser', oidcUser);
|
190
|
-
if (oidcUser) {
|
191
|
-
const user = {
|
192
|
-
id: oidcUser.id_token ?? '1',
|
193
|
-
name: oidcUser.profile.name ?? credentials.username,
|
194
|
-
title: oidcUser.profile.given_name ?? 'no Name!',
|
195
|
-
avatar: oidcUser.profile.picture ?? 'https://i.pravatar.cc/150?img=52',
|
196
|
-
};
|
197
|
-
const accessToken = oidcUser.access_token;
|
198
|
-
const refreshToken = oidcUser.refresh_token ?? '';
|
199
|
-
return { user, accessToken, refreshToken };
|
314
|
+
catch (error) {
|
315
|
+
if (error?.message)
|
316
|
+
throw new Error(error.message);
|
317
|
+
// Depending on the error type, you might want to throw a specific error
|
318
|
+
throw new Error('Network or server error occurred');
|
200
319
|
}
|
201
|
-
throw new Error('Invalid credentials');
|
202
320
|
}
|
203
321
|
async signout() {
|
204
322
|
console.log('User signed out');
|
@@ -215,41 +333,107 @@ class AXMOidcStrategy {
|
|
215
333
|
};
|
216
334
|
const accessToken = this.generateAccessToken();
|
217
335
|
const newRefreshToken = this.generateAccessToken();
|
218
|
-
return {
|
336
|
+
return {
|
337
|
+
succeed: true,
|
338
|
+
data: { accessToken, refreshToken: newRefreshToken },
|
339
|
+
};
|
219
340
|
}
|
220
341
|
generateAccessToken() {
|
221
342
|
return 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJPbmxpbmUgSldUIEJ1aWxkZXIiLCJpYXQiOjE3MDU5MjE4ODUsImV4cCI6MTczNzQ1Nzg4NSwiYXVkIjoid3d3LmV4YW1wbGUuY29tIiwic3ViIjoianJvY2tldEBleGFtcGxlLmNvbSIsImlkIjoiMTAiLCJ0aXRsZSI6IkFyYXNoIiwiRW1haWwiOiJqcm9ja2V0QGV4YW1wbGUuY29tIiwiUm9sZSI6WyJNYW5hZ2VyIiwiUHJvamVjdCBBZG1pbmlzdHJhdG9yIl0sIm5hbWUiOiJhZG1pbiJ9.IgJL7uvJNBd9yBvWS4aTms5XjBI4VDyT01KhMSESXdQ';
|
222
343
|
}
|
223
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
224
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
344
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMOidcStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
345
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMOidcStrategy }); }
|
225
346
|
}
|
226
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
347
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMOidcStrategy, decorators: [{
|
227
348
|
type: Injectable
|
228
349
|
}], ctorParameters: () => [] });
|
229
350
|
|
230
351
|
class AXMOidcPermissionLoader {
|
231
|
-
|
232
|
-
|
352
|
+
constructor(http) {
|
353
|
+
this.http = http;
|
354
|
+
this.configs = inject(AXP_ROOT_CONFIG_TOKEN);
|
355
|
+
this.apiGetConfig = `${this.configs.baseUrl}/abp/application-configuration`;
|
356
|
+
}
|
357
|
+
getList(context) {
|
358
|
+
return this.http.get(this.apiGetConfig).pipe(map((response) => this.mapTo(response)));
|
359
|
+
// debugger
|
360
|
+
// if (context.user == null)
|
361
|
+
// return of([]);
|
362
|
+
// else if (context.user.name.toLowerCase() == 'admin')
|
363
|
+
// return of(['axp.admin.console', 'asc.admin.message', 'asc.admin.settings', 'asc.admin.gliding', 'asc.user.gliding']);
|
364
|
+
// else
|
365
|
+
// return of(['asc.user.gliding']);
|
366
|
+
}
|
367
|
+
mapTo(jsonObj) {
|
368
|
+
const policies = jsonObj.auth.grantedPolicies;
|
369
|
+
const truePolicies = Object.keys(policies).filter((key) => policies[key] === true);
|
370
|
+
return truePolicies;
|
371
|
+
}
|
372
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMOidcPermissionLoader, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
373
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMOidcPermissionLoader }); }
|
374
|
+
}
|
375
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMOidcPermissionLoader, decorators: [{
|
376
|
+
type: Injectable
|
377
|
+
}], ctorParameters: () => [{ type: i1.HttpClient }] });
|
378
|
+
|
379
|
+
class SignincallbackComponent {
|
380
|
+
constructor(userManagerService, router, route) {
|
381
|
+
this.userManagerService = userManagerService;
|
382
|
+
this.router = router;
|
383
|
+
this.route = route;
|
384
|
+
this.sessionService = inject(AXPSessionService);
|
233
385
|
}
|
386
|
+
ngOnInit() {
|
387
|
+
const queryParams = this.route.snapshot.queryParams;
|
388
|
+
if (queryParams['tenantid']) {
|
389
|
+
const selectedTenant = {
|
390
|
+
id: queryParams['tenantid'],
|
391
|
+
name: queryParams['tenantname'],
|
392
|
+
title: queryParams['tenanttitle'],
|
393
|
+
};
|
394
|
+
this.sessionService.setTenant(selectedTenant);
|
395
|
+
}
|
396
|
+
if (queryParams['applicationid']) {
|
397
|
+
const selectedApplication = {
|
398
|
+
id: queryParams['applicationid'],
|
399
|
+
name: queryParams['applicationname'],
|
400
|
+
title: queryParams['applicationtitle'],
|
401
|
+
version: '1',
|
402
|
+
editionName: queryParams['editionname'],
|
403
|
+
};
|
404
|
+
this.sessionService.setApplication(selectedApplication);
|
405
|
+
}
|
406
|
+
this.userManagerService.signinSilentCallback();
|
407
|
+
}
|
408
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: SignincallbackComponent, deps: [{ token: AXMOidcUserManagerService }, { token: i2.Router }, { token: i2.ActivatedRoute }], target: i0.ɵɵFactoryTarget.Component }); }
|
409
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.0.2", type: SignincallbackComponent, selector: "ng-component", ngImport: i0, template: '', isInline: true }); }
|
234
410
|
}
|
411
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: SignincallbackComponent, decorators: [{
|
412
|
+
type: Component,
|
413
|
+
args: [{
|
414
|
+
template: '',
|
415
|
+
}]
|
416
|
+
}], ctorParameters: () => [{ type: AXMOidcUserManagerService }, { type: i2.Router }, { type: i2.ActivatedRoute }] });
|
235
417
|
|
236
418
|
class AXMOidcTenantLoader {
|
237
419
|
constructor(http) {
|
238
420
|
this.http = http;
|
239
|
-
this.configs = inject(
|
240
|
-
this.apiGetTenants = `${this.configs.
|
241
|
-
this.apiSetTenant = `${this.configs.
|
421
|
+
this.configs = inject(AXP_ROOT_CONFIG_TOKEN);
|
422
|
+
this.apiGetTenants = `${this.configs.baseUrl}/user-tenants/Tenants`;
|
423
|
+
this.apiSetTenant = `${this.configs.baseUrl}/SetTenant`;
|
242
424
|
}
|
243
425
|
getList() {
|
244
|
-
return this.http
|
245
|
-
.get(this.apiGetTenants)
|
246
|
-
.pipe(map((response) => response.items.map((item) => this.mapToAXPTenant(item))));
|
426
|
+
return this.http.get(this.apiGetTenants).pipe(map((response) => response.items.map((item) => this.mapToAXPTenant(item))));
|
247
427
|
}
|
428
|
+
//TODO: shoud be removed
|
248
429
|
set(tenant) {
|
249
430
|
return this.http.post(this.apiSetTenant, { tenantId: tenant.id }).pipe(map((response) => {
|
250
431
|
return {
|
251
|
-
|
252
|
-
|
432
|
+
succeed: true,
|
433
|
+
data: {
|
434
|
+
accessToken: response.token,
|
435
|
+
refreshToken: response.token,
|
436
|
+
},
|
253
437
|
};
|
254
438
|
}));
|
255
439
|
}
|
@@ -257,171 +441,43 @@ class AXMOidcTenantLoader {
|
|
257
441
|
return {
|
258
442
|
id: item.id,
|
259
443
|
name: item.name || 'defaultName',
|
260
|
-
title: item.
|
444
|
+
title: item.title || 'defaultTitle',
|
261
445
|
// Add other fields and defaults as needed, and handle the logo if applicable
|
262
446
|
};
|
263
447
|
}
|
264
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
265
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
448
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMOidcTenantLoader, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
449
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMOidcTenantLoader }); }
|
266
450
|
}
|
267
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
451
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMOidcTenantLoader, decorators: [{
|
268
452
|
type: Injectable
|
269
453
|
}], ctorParameters: () => [{ type: i1.HttpClient }] });
|
270
454
|
|
271
|
-
class ASCApplicationLoader {
|
272
|
-
getList() {
|
273
|
-
const app = {
|
274
|
-
id: '0',
|
275
|
-
name: 'asc',
|
276
|
-
title: 'Adelide Soaring Club',
|
277
|
-
logo: new AXPTextLogoConfig('ASC'),
|
278
|
-
version: '1.0.1',
|
279
|
-
editionName: 'Standard',
|
280
|
-
};
|
281
|
-
const app2 = {
|
282
|
-
id: '1',
|
283
|
-
name: 'asc1',
|
284
|
-
title: 'Application 2',
|
285
|
-
logo: new AXPTextLogoConfig('ASC'),
|
286
|
-
version: '1.0.1',
|
287
|
-
editionName: 'Standard',
|
288
|
-
};
|
289
|
-
return of([app]).pipe(delay(0));
|
290
|
-
}
|
291
|
-
set(application) {
|
292
|
-
return of({
|
293
|
-
accessToken: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJPbmxpbmUgSldUIEJ1aWxkZXIiLCJpYXQiOjE3MDU5MjE4ODUsImV4cCI6MTczNzQ1Nzg4NSwiYXVkIjoid3d3LmV4YW1wbGUuY29tIiwic3ViIjoianJvY2tldEBleGFtcGxlLmNvbSIsImlkIjoiMTAiLCJ0aXRsZSI6IkFyYXNoIiwiRW1haWwiOiJqcm9ja2V0QGV4YW1wbGUuY29tIiwiUm9sZSI6WyJNYW5hZ2VyIiwiUHJvamVjdCBBZG1pbmlzdHJhdG9yIl0sIm5hbWUiOiJhZG1pbiJ9.IgJL7uvJNBd9yBvWS4aTms5XjBI4VDyT01KhMSESXdQ',
|
294
|
-
refreshToken: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJPbmxpbmUgSldUIEJ1aWxkZXIiLCJpYXQiOjE3MDU5MjE4ODUsImV4cCI6MTczNzQ1Nzg4NSwiYXVkIjoid3d3LmV4YW1wbGUuY29tIiwic3ViIjoianJvY2tldEBleGFtcGxlLmNvbSIsImlkIjoiMTAiLCJ0aXRsZSI6IkFyYXNoIiwiRW1haWwiOiJqcm9ja2V0QGV4YW1wbGUuY29tIiwiUm9sZSI6WyJNYW5hZ2VyIiwiUHJvamVjdCBBZG1pbmlzdHJhdG9yIl0sIm5hbWUiOiJhZG1pbiJ9.IgJL7uvJNBd9yBvWS4aTms5XjBI4VDyT01KhMSESXdQ',
|
295
|
-
}).pipe(delay(500));
|
296
|
-
}
|
297
|
-
}
|
298
|
-
|
299
|
-
class ASCPermissionLoader {
|
300
|
-
getList() {
|
301
|
-
return of([
|
302
|
-
'asc.admin.message',
|
303
|
-
'asc.admin.settings',
|
304
|
-
'asc.admin.gliding',
|
305
|
-
])
|
306
|
-
.pipe(delay(0));
|
307
|
-
}
|
308
|
-
}
|
309
|
-
|
310
|
-
class ASCTenantLoader {
|
311
|
-
getList() {
|
312
|
-
const tenant = {
|
313
|
-
id: '0',
|
314
|
-
name: 'asc',
|
315
|
-
title: 'Adelide Soaring Club',
|
316
|
-
logo: new AXPTextLogoConfig('ASC'),
|
317
|
-
};
|
318
|
-
const tenant2 = {
|
319
|
-
id: '1',
|
320
|
-
name: 'asc1',
|
321
|
-
title: 'Adelide Soaring Club',
|
322
|
-
logo: new AXPTextLogoConfig('ASC'),
|
323
|
-
};
|
324
|
-
return of([tenant]).pipe(delay(0));
|
325
|
-
}
|
326
|
-
set(tenant) {
|
327
|
-
return of({
|
328
|
-
accessToken: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJPbmxpbmUgSldUIEJ1aWxkZXIiLCJpYXQiOjE3MDU5MjE4ODUsImV4cCI6MTczNzQ1Nzg4NSwiYXVkIjoid3d3LmV4YW1wbGUuY29tIiwic3ViIjoianJvY2tldEBleGFtcGxlLmNvbSIsImlkIjoiMTAiLCJ0aXRsZSI6IkFyYXNoIiwiRW1haWwiOiJqcm9ja2V0QGV4YW1wbGUuY29tIiwiUm9sZSI6WyJNYW5hZ2VyIiwiUHJvamVjdCBBZG1pbmlzdHJhdG9yIl0sIm5hbWUiOiJhZG1pbiJ9.IgJL7uvJNBd9yBvWS4aTms5XjBI4VDyT01KhMSESXdQ',
|
329
|
-
refreshToken: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJPbmxpbmUgSldUIEJ1aWxkZXIiLCJpYXQiOjE3MDU5MjE4ODUsImV4cCI6MTczNzQ1Nzg4NSwiYXVkIjoid3d3LmV4YW1wbGUuY29tIiwic3ViIjoianJvY2tldEBleGFtcGxlLmNvbSIsImlkIjoiMTAiLCJ0aXRsZSI6IkFyYXNoIiwiRW1haWwiOiJqcm9ja2V0QGV4YW1wbGUuY29tIiwiUm9sZSI6WyJNYW5hZ2VyIiwiUHJvamVjdCBBZG1pbmlzdHJhdG9yIl0sIm5hbWUiOiJhZG1pbiJ9.IgJL7uvJNBd9yBvWS4aTms5XjBI4VDyT01KhMSESXdQ',
|
330
|
-
}).pipe(delay(0));
|
331
|
-
}
|
332
|
-
}
|
333
|
-
|
334
|
-
class ASCUserPassStrategy {
|
335
|
-
get name() {
|
336
|
-
return 'userpass';
|
337
|
-
}
|
338
|
-
async signin(credentials) {
|
339
|
-
const result = credentials.username == 'admin' && credentials.password == '123';
|
340
|
-
if (result) {
|
341
|
-
const user = {
|
342
|
-
id: '1',
|
343
|
-
name: credentials.username,
|
344
|
-
title: 'Admin',
|
345
|
-
avatar: 'https://i.pravatar.cc/150?img=52',
|
346
|
-
};
|
347
|
-
const accessToken = this.generateAccessToken();
|
348
|
-
const refreshToken = this.generateAccessToken();
|
349
|
-
return { user, accessToken, refreshToken };
|
350
|
-
}
|
351
|
-
else {
|
352
|
-
throw new Error('Invalid credentials');
|
353
|
-
}
|
354
|
-
}
|
355
|
-
async signout() {
|
356
|
-
console.log('User signed out');
|
357
|
-
}
|
358
|
-
async refreshToken(refreshToken) {
|
359
|
-
const user = {
|
360
|
-
id: '1',
|
361
|
-
name: 'admin',
|
362
|
-
title: 'Arash',
|
363
|
-
avatar: 'https://i.pravatar.cc/150?img=52',
|
364
|
-
};
|
365
|
-
const accessToken = this.generateAccessToken();
|
366
|
-
const newRefreshToken = this.generateAccessToken();
|
367
|
-
return { user, accessToken, refreshToken: newRefreshToken };
|
368
|
-
}
|
369
|
-
generateAccessToken() {
|
370
|
-
return 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJPbmxpbmUgSldUIEJ1aWxkZXIiLCJpYXQiOjE3MDU5MjE4ODUsImV4cCI6MTczNzQ1Nzg4NSwiYXVkIjoid3d3LmV4YW1wbGUuY29tIiwic3ViIjoianJvY2tldEBleGFtcGxlLmNvbSIsImlkIjoiMTAiLCJ0aXRsZSI6IkFyYXNoIiwiRW1haWwiOiJqcm9ja2V0QGV4YW1wbGUuY29tIiwiUm9sZSI6WyJNYW5hZ2VyIiwiUHJvamVjdCBBZG1pbmlzdHJhdG9yIl0sIm5hbWUiOiJhZG1pbiJ9.IgJL7uvJNBd9yBvWS4aTms5XjBI4VDyT01KhMSESXdQ';
|
371
|
-
}
|
372
|
-
}
|
373
|
-
|
374
|
-
class SignincallbackComponent {
|
375
|
-
constructor(userManagerService, router, route) {
|
376
|
-
this.userManagerService = userManagerService;
|
377
|
-
this.router = router;
|
378
|
-
this.route = route;
|
379
|
-
}
|
380
|
-
ngOnInit() {
|
381
|
-
this.userManagerService.completeAuthentication();
|
382
|
-
}
|
383
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.2", ngImport: i0, type: SignincallbackComponent, deps: [{ token: AXMOidcUserManagerService }, { token: i2.Router }, { token: i2.ActivatedRoute }], target: i0.ɵɵFactoryTarget.Component }); }
|
384
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.1.2", type: SignincallbackComponent, selector: "ng-component", providers: [], ngImport: i0, template: '', isInline: true }); }
|
385
|
-
}
|
386
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.2", ngImport: i0, type: SignincallbackComponent, decorators: [{
|
387
|
-
type: Component,
|
388
|
-
args: [{
|
389
|
-
template: '',
|
390
|
-
providers: [],
|
391
|
-
}]
|
392
|
-
}], ctorParameters: () => [{ type: AXMOidcUserManagerService }, { type: i2.Router }, { type: i2.ActivatedRoute }] });
|
393
|
-
|
394
455
|
function routesFactory() {
|
395
456
|
const routes = [{ path: 'auth/signincallback', component: SignincallbackComponent }];
|
396
457
|
return routes;
|
397
458
|
}
|
398
459
|
class AXMBackendModule {
|
399
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
400
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
|
401
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
460
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMBackendModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
461
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.0.2", ngImport: i0, type: AXMBackendModule, imports: [i1$1.AXMAuthModule, i2$1.AXPAuthModule] }); }
|
462
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMBackendModule, providers: [
|
402
463
|
{
|
403
464
|
provide: AXPDataProvider,
|
404
|
-
// useClass: AXMLocalDataProvider,
|
405
465
|
useClass: AXMBackendDataProvider,
|
406
466
|
},
|
407
467
|
{
|
408
468
|
provide: AXP_TENANT_LOADER,
|
409
|
-
// useClass: ASCTenantLoader,
|
410
469
|
useClass: AXMOidcTenantLoader,
|
411
470
|
},
|
412
471
|
{
|
413
472
|
provide: AXP_APPLICATION_LOADER,
|
414
|
-
// useClass: ASCApplicationLoader,
|
415
473
|
useClass: AXMOidcApplicationLoader,
|
416
474
|
},
|
417
475
|
{
|
418
476
|
provide: AXP_PERMISSION_LOADER,
|
419
|
-
// useClass: ASCPermissionLoader,
|
420
477
|
useClass: AXMOidcPermissionLoader,
|
421
478
|
},
|
422
479
|
{
|
423
480
|
provide: AXP_FEATURE_LOADER,
|
424
|
-
// useClass: ASCFeatureLoader, //TODO: not implimented
|
425
481
|
useClass: AXMOidcFeatureLoader,
|
426
482
|
},
|
427
483
|
{
|
@@ -431,16 +487,16 @@ class AXMBackendModule {
|
|
431
487
|
},
|
432
488
|
], imports: [AXMAuthModule.forRoot(),
|
433
489
|
AXPAuthModule.forRoot({
|
434
|
-
strategies: [AXMOidcStrategy
|
490
|
+
strategies: [AXMOidcStrategy],
|
435
491
|
})] }); }
|
436
492
|
}
|
437
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
493
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMBackendModule, decorators: [{
|
438
494
|
type: NgModule,
|
439
495
|
args: [{
|
440
496
|
imports: [
|
441
497
|
AXMAuthModule.forRoot(),
|
442
498
|
AXPAuthModule.forRoot({
|
443
|
-
strategies: [AXMOidcStrategy
|
499
|
+
strategies: [AXMOidcStrategy],
|
444
500
|
}),
|
445
501
|
],
|
446
502
|
exports: [],
|
@@ -448,27 +504,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.2", ngImpor
|
|
448
504
|
providers: [
|
449
505
|
{
|
450
506
|
provide: AXPDataProvider,
|
451
|
-
// useClass: AXMLocalDataProvider,
|
452
507
|
useClass: AXMBackendDataProvider,
|
453
508
|
},
|
454
509
|
{
|
455
510
|
provide: AXP_TENANT_LOADER,
|
456
|
-
// useClass: ASCTenantLoader,
|
457
511
|
useClass: AXMOidcTenantLoader,
|
458
512
|
},
|
459
513
|
{
|
460
514
|
provide: AXP_APPLICATION_LOADER,
|
461
|
-
// useClass: ASCApplicationLoader,
|
462
515
|
useClass: AXMOidcApplicationLoader,
|
463
516
|
},
|
464
517
|
{
|
465
518
|
provide: AXP_PERMISSION_LOADER,
|
466
|
-
// useClass: ASCPermissionLoader,
|
467
519
|
useClass: AXMOidcPermissionLoader,
|
468
520
|
},
|
469
521
|
{
|
470
522
|
provide: AXP_FEATURE_LOADER,
|
471
|
-
// useClass: ASCFeatureLoader, //TODO: not implimented
|
472
523
|
useClass: AXMOidcFeatureLoader,
|
473
524
|
},
|
474
525
|
{
|
@@ -480,9 +531,163 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.2", ngImpor
|
|
480
531
|
}]
|
481
532
|
}] });
|
482
533
|
|
534
|
+
function applyCondition(item, condition) {
|
535
|
+
const itemValue = typeof item[condition.field] == 'string'
|
536
|
+
? item[condition.field].toLowerCase()
|
537
|
+
: Array.isArray(item[condition.field])
|
538
|
+
? JSON.stringify(item[condition.field])
|
539
|
+
: item[condition.field];
|
540
|
+
const conditionValue = typeof condition.value == 'string' ? condition.value.toLowerCase() : condition.value;
|
541
|
+
switch (condition.operator.type) {
|
542
|
+
case 'equal':
|
543
|
+
return isEqual(itemValue, conditionValue);
|
544
|
+
case 'notEqual':
|
545
|
+
return !isEqual(itemValue, conditionValue);
|
546
|
+
case 'greaterThan':
|
547
|
+
return gt(itemValue, conditionValue);
|
548
|
+
case 'lessThan':
|
549
|
+
return lt(itemValue, conditionValue);
|
550
|
+
case 'greaterThanOrEqual':
|
551
|
+
return gte(itemValue, conditionValue);
|
552
|
+
case 'lessThanOrEqual':
|
553
|
+
return lte(itemValue, conditionValue);
|
554
|
+
case 'contains':
|
555
|
+
if (!Array.isArray(conditionValue)) {
|
556
|
+
return includes(itemValue, conditionValue);
|
557
|
+
}
|
558
|
+
else
|
559
|
+
return every(conditionValue, (element) => includes(itemValue, element));
|
560
|
+
case 'notContains':
|
561
|
+
if (!Array.isArray(conditionValue)) {
|
562
|
+
return !includes(itemValue, conditionValue);
|
563
|
+
}
|
564
|
+
else
|
565
|
+
return !some(conditionValue, (element) => includes(itemValue, element));
|
566
|
+
case 'startsWith':
|
567
|
+
return startsWith(itemValue, conditionValue);
|
568
|
+
case 'endsWith':
|
569
|
+
return endsWith(itemValue, conditionValue);
|
570
|
+
case 'isEmpty':
|
571
|
+
return isEmpty(itemValue);
|
572
|
+
case 'isNotEmpty':
|
573
|
+
return !isEmpty(itemValue);
|
574
|
+
case 'between':
|
575
|
+
return itemValue >= conditionValue.from && itemValue <= conditionValue.to;
|
576
|
+
default:
|
577
|
+
return true;
|
578
|
+
}
|
579
|
+
}
|
580
|
+
function applyFilterArray(dataArray, filters, logic = 'and') {
|
581
|
+
if (filters && filters.length) {
|
582
|
+
return dataArray?.filter((item) => {
|
583
|
+
if (logic === 'and') {
|
584
|
+
return filters.every((f) => {
|
585
|
+
return f.filters ? applyFilterArray([item], f.filters, f.logic).length > 0 : applyCondition(item, f);
|
586
|
+
});
|
587
|
+
}
|
588
|
+
else {
|
589
|
+
// logic === 'or'
|
590
|
+
return filters.some((f) => {
|
591
|
+
return f.filters ? applyFilterArray([item], f.filters, f.logic).length > 0 : applyCondition(item, f);
|
592
|
+
});
|
593
|
+
}
|
594
|
+
});
|
595
|
+
}
|
596
|
+
else
|
597
|
+
return dataArray;
|
598
|
+
}
|
599
|
+
function applySortArray(dataArray, sorts) {
|
600
|
+
if (sorts && sorts.length > 0) {
|
601
|
+
const sortFields = sorts.map((s) => s.field);
|
602
|
+
const sortOrders = sorts.map((s) => s.dir);
|
603
|
+
return orderBy(dataArray, sortFields, sortOrders);
|
604
|
+
}
|
605
|
+
else
|
606
|
+
return dataArray;
|
607
|
+
}
|
608
|
+
|
609
|
+
class AXMLocalDataProvider {
|
610
|
+
constructor(storageService) {
|
611
|
+
this.storageService = storageService;
|
612
|
+
}
|
613
|
+
insertOne(entity, entityItem) {
|
614
|
+
return this.storageService.insertOrupdateOne(entity.name, entityItem);
|
615
|
+
}
|
616
|
+
insertMany(entity, entityList) {
|
617
|
+
return this.storageService.insertMany(entity.name, entityList);
|
618
|
+
}
|
619
|
+
async getOne(entity, id) {
|
620
|
+
console.log('@LOACAL getOne', entity.name, id);
|
621
|
+
return this.storageService.getOne(entity.name, id);
|
622
|
+
}
|
623
|
+
async getMany(entity, params) {
|
624
|
+
console.log('@LOACAL getMany', entity.name, params);
|
625
|
+
const result = await this.storageService.getMany(entity.name, params);
|
626
|
+
const sortedItems = applySortArray(result, params?.sort);
|
627
|
+
const filteredItems = applyFilterArray(sortedItems, params?.filter?.filters);
|
628
|
+
return new Promise((resolve) => {
|
629
|
+
resolve({
|
630
|
+
items: params ? filteredItems?.slice(params.skip, (params.skip ?? 0) + (params.take ?? 20)) : filteredItems,
|
631
|
+
total: filteredItems?.length ?? 0,
|
632
|
+
});
|
633
|
+
});
|
634
|
+
}
|
635
|
+
updateOne(entity, id, data) {
|
636
|
+
return this.storageService.updateOne(entity.name, id, data);
|
637
|
+
}
|
638
|
+
deleteOne(entity, id) {
|
639
|
+
return this.storageService.deleteOne(entity.name, id);
|
640
|
+
}
|
641
|
+
getFirst(entity) {
|
642
|
+
return this.getMany(entity).then((res) => {
|
643
|
+
return res.items ? res.items[0] : null;
|
644
|
+
});
|
645
|
+
}
|
646
|
+
// Mock file uploader function
|
647
|
+
uploadFile(file, title) {
|
648
|
+
return new Promise((resolve) => {
|
649
|
+
// Mock file ID generation
|
650
|
+
const fileId = `mock-file-id-${Math.random().toString(36).substr(2, 9)}`;
|
651
|
+
const fileRecord = { id: fileId, title, file };
|
652
|
+
this.storageService.insertOrupdateOne('files', fileRecord).then(() => {
|
653
|
+
resolve(fileId);
|
654
|
+
});
|
655
|
+
});
|
656
|
+
}
|
657
|
+
// Mock function to upload multiple files
|
658
|
+
uploadMultipleFiles(files, title) {
|
659
|
+
const uploadPromises = files.map((file) => this.uploadFile(file, title));
|
660
|
+
return Promise.all(uploadPromises);
|
661
|
+
}
|
662
|
+
// Mock function to view a file
|
663
|
+
viewFile(id, name) {
|
664
|
+
return new Promise(async (resolve, reject) => {
|
665
|
+
const fileRecord = await this.storageService.getOne('files', id);
|
666
|
+
if (fileRecord && fileRecord.file) {
|
667
|
+
resolve(fileRecord.file);
|
668
|
+
}
|
669
|
+
else {
|
670
|
+
reject('File not found');
|
671
|
+
}
|
672
|
+
});
|
673
|
+
}
|
674
|
+
// Mock function to download a file
|
675
|
+
downloadFile(id, name) {
|
676
|
+
return this.viewFile(id, name);
|
677
|
+
}
|
678
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMLocalDataProvider, deps: [{ token: i1$2.AXPStorageMockService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
679
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMLocalDataProvider, providedIn: 'root' }); }
|
680
|
+
}
|
681
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMLocalDataProvider, decorators: [{
|
682
|
+
type: Injectable,
|
683
|
+
args: [{
|
684
|
+
providedIn: 'root',
|
685
|
+
}]
|
686
|
+
}], ctorParameters: () => [{ type: i1$2.AXPStorageMockService }] });
|
687
|
+
|
483
688
|
/**
|
484
689
|
* Generated bundle index. Do not edit.
|
485
690
|
*/
|
486
691
|
|
487
|
-
export { AXMBackendModule,
|
692
|
+
export { AXMBackendDataProvider, AXMBackendModule, AXMConfigurationService, AXMLocalDataProvider, AXMOidcApplicationLoader, AXMOidcFeatureLoader, AXMOidcPermissionLoader, AXMOidcStrategy, AXMOidcTenantLoader, AXMOidcUserManagerService, SignincallbackComponent, applyFilterArray, applySortArray };
|
488
693
|
//# sourceMappingURL=acorex-modules-backend.mjs.map
|